Skip to content

Commit b232cfa

Browse files
Update docs to meet the latest updates
Signed-off-by: Kiran Parajuli <[email protected]>
1 parent f0e2769 commit b232cfa

File tree

14 files changed

+127
-158
lines changed

14 files changed

+127
-158
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default [
5656
"vue/max-attributes-per-line": [
5757
"error",
5858
{
59-
singleline: 3,
59+
singleline: 4,
6060
multiline: 2,
6161
},
6262
],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"highlight.js": "^11.11.1",
1919
"pinia": "^2.3.0",
2020
"vue": "^3.5.13",
21-
"vue-formik": "^0.1.27",
21+
"vue-formik": "^0.1.29",
2222
"vue-router": "^4.5.0",
2323
"yup": "^1.6.1"
2424
},

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/core/simpleTable/SimpleTable.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ const classesDict = computed(() => {
4949
<th
5050
v-for="column in columns"
5151
:key="column.field"
52-
:style="{ textAlign: column.align ?? 'start' }"
52+
:style="{
53+
textAlign: column.align ?? 'start',
54+
width: column.width ?? 'auto',
55+
}"
5356
:class="classesDict.th"
5457
>
5558
{{ column.header }}

src/components/core/simpleTable/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ interface IColumn {
33
field: string;
44
code?: boolean;
55
align?: "start" | "justify" | "end" | "center";
6+
default?: string | boolean;
7+
width?: number;
68
}
79
interface IRow {
810
[key: string]: string | boolean;

src/components/home/ExpoForm.vue

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
<template>
22
<form class="border border-gray-500 rounded-md p-4" @submit="(e) => {}">
3-
<FormInput
4-
:formik="formik"
5-
name="name"
6-
label="Name:"
7-
type="text"
8-
placeholder="Enter your name"
9-
/>
3+
<FormInput name="name" label="Name:" type="text" placeholder="Enter your name" />
104

115
<FormInput
12-
:formik="formik"
136
name="email"
147
label="Email Address:"
158
type="email"
@@ -21,13 +14,11 @@
2114
<div class="flex flex-col gap-2">
2215
<div v-for="(_, index) in formik.values.contacts" :key="index" class="flex gap-4">
2316
<FormInput
24-
:formik="formik"
2517
:name="`contacts[${index}].code`"
2618
type="tel"
2719
:placeholder="`Enter contact number ${index + 1}`"
2820
/>
2921
<FormInput
30-
:formik="formik"
3122
:name="`contacts[${index}].number`"
3223
type="tel"
3324
:placeholder="`Enter contact number ${index + 1}`"
@@ -68,20 +59,13 @@
6859
</div>
6960

7061
<FormSelectField
71-
:formik="formik"
7262
name="sex"
7363
label="Sex:"
7464
:options="sexOptions"
7565
placeholder="Select your gender"
7666
/>
7767

78-
<FormTextArea
79-
:formik="formik"
80-
name="message"
81-
label="Message:"
82-
placeholder="Enter your message"
83-
rows="4"
84-
/>
68+
<FormTextArea name="message" label="Message:" placeholder="Enter your message" rows="4" />
8569

8670
<!-- addresses -->
8771
<div class="addresses flex flex-col gap-2">
@@ -92,7 +76,6 @@
9276
class="flex items-start gap-4"
9377
>
9478
<FormInput
95-
:formik="formik"
9679
:name="`addresses[${index}]`"
9780
type="text"
9881
:placeholder="`Enter address line ${index + 1}`"
@@ -154,6 +137,7 @@
154137
/* eslint-disable @typescript-eslint/no-explicit-any */
155138
import { FormInput, FormSelectField, FormTextArea } from "vue-formik";
156139
import useFormikForm from "@/composables/formik.ts";
140+
import { provide } from "vue";
157141
158142
const props = defineProps<{
159143
validationSchema: any;
@@ -167,4 +151,6 @@ const sexOptions = [
167151
];
168152
169153
const { formik } = useFormikForm(props.validationSchema);
154+
155+
provide("formik", formik);
170156
</script>

src/constants/examples/whyComponents.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,26 @@ const formik = useFormik({
5050
});
5151
</script>
5252
`;
53+
54+
export const ExampleWithProvideInject = `
55+
<template>
56+
<FormikForm>
57+
<FormInput name="name" label="Name" />
58+
</FormikForm>
59+
</template>
60+
<script setup lang="ts">
61+
import { provide, ref } from "vue";
62+
import { useFormik, FormInput, FormikForm } from "vue-formik";
63+
64+
const formik = useFormik({
65+
initialValues: {
66+
name: "",
67+
},
68+
onSubmit: (values) => {
69+
console.log(values);
70+
},
71+
});
72+
73+
provide("formik", formik);
74+
</script>
75+
`;
Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,20 @@
11
import type { IColumn, IRow } from "@/components/core/simpleTable/types";
2+
import { CommonBooleanProps, CommonProps } from "@/constants/propsVFormik/propsCommon.ts";
23

34
export const FormContentEditablePropsCols = [
45
{ header: "Name", field: "name" },
5-
{ header: "Type", field: "type", code: true },
6+
{ header: "Type", field: "type", code: true, width: "150px" },
7+
{ header: "Required", field: "required", default: false },
68
{ header: "Description", field: "description" },
79
] as IColumn[];
810

911
export const FormContentEditableProps = [
10-
{
11-
name: "formik",
12-
type: "object",
13-
description:
14-
"The Formik instance, which provides methods for managing form state, including validation and field value handling.",
15-
},
16-
{
17-
name: "name",
18-
type: "string",
19-
description: "The name of the form field, used to identify the field in the Formik instance.",
20-
},
21-
{
22-
name: "label",
23-
type: "string",
24-
description:
25-
"An optional label for the input field. If provided, it is displayed as a field label.",
26-
},
27-
{
28-
name: "placeholder",
29-
type: "string",
30-
description:
31-
"An optional placeholder for the input field. It is displayed inside the input when no value is present.",
32-
},
12+
...CommonProps,
13+
...CommonBooleanProps,
3314
{
3415
name: "contentProps",
3516
type: "object",
3617
description:
37-
"Additional props to pass to the contenteditable element, such as attributes like 'contenteditable' or custom data attributes.",
38-
},
39-
{
40-
name: "disabled",
41-
type: "boolean",
42-
description: "Determines if the input field is disabled. Defaults to false.",
43-
},
44-
{
45-
name: "readonly",
46-
type: "boolean",
47-
description: "Determines if the input field is read-only. Defaults to false.",
18+
"Additional props to pass to the contenteditable element, such as attributes like custom data attributes.",
4819
},
4920
] as IRow[];

src/constants/propsVFormik/formInput.ts

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,31 @@
11
import type { IColumn, IRow } from "@/components/core/simpleTable/types.ts";
2+
import { CommonBooleanProps, CommonProps } from "@/constants/propsVFormik/propsCommon.ts";
23

34
export const FormInputPropsCols = [
45
{ header: "Name", field: "name" },
5-
{ header: "Type", field: "type", code: true },
6+
{ header: "Type", field: "type", code: true, width: "100px" },
7+
{ header: "Required", field: "required", default: false },
68
{ header: "Description", field: "description" },
79
] as IColumn[];
810
export const FormInputProps = [
9-
{
10-
name: "formik",
11-
type: "object",
12-
description:
13-
"The Formik instance, which provides methods for managing form state, including validation and field value handling.",
14-
},
15-
{
16-
name: "name",
17-
type: "string",
18-
description: "The name of the form field, used to identify the field in the Formik instance.",
19-
},
20-
{
21-
name: "label",
22-
type: "string",
23-
description:
24-
"An optional label for the input field. If provided, it is displayed as a field label.",
25-
},
11+
...CommonProps,
2612
{
2713
name: "type",
2814
type: "string",
2915
description:
3016
"The type of the input field (e.g., 'text', 'password', 'email'). Defaults to 'text' if not provided.",
3117
},
32-
{
33-
name: "placeholder",
34-
type: "string",
35-
description:
36-
"An optional placeholder for the input field. It is displayed inside the input when no value is present.",
37-
},
3818
{
3919
name: "readonly",
4020
type: "boolean",
4121
description: "Determines if the input field is read-only. Defaults to false.",
4222
},
43-
{
44-
name: "disabled",
45-
type: "boolean",
46-
description: "Determines if the input field is disabled. Defaults to false.",
47-
},
23+
...CommonBooleanProps,
4824
{
4925
name: "inputProps",
5026
type: "object",
5127
description:
52-
"Additional props to pass to the input field, such as attributes like 'required' or custom data attributes.",
28+
"Additional props to pass to the input field, such as attributes like 'min', 'max', 'step', etc.",
5329
},
5430
] as IRow[];
5531

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,26 @@
11
import type { IColumn, IRow } from "@/components/core/simpleTable/types.ts";
2+
import { CommonBooleanProps, CommonProps } from "@/constants/propsVFormik/propsCommon.ts";
23

34
export const FormSelectPropsCols = [
45
{ header: "Name", field: "name" },
5-
{ header: "Type", field: "type", code: true },
6+
{ header: "Type", field: "type", code: true, width: "150px" },
7+
{ header: "Required", field: "required", default: false },
68
{ header: "Description", field: "description" },
79
] as IColumn[];
810

911
export const FormSelectProps = [
10-
{
11-
name: "formik",
12-
type: "object",
13-
description:
14-
"The Formik instance, which provides methods for managing form state, including validation and field value handling.",
15-
},
16-
{
17-
name: "name",
18-
type: "string",
19-
description: "The name of the form field, used to identify the field in the Formik instance.",
20-
},
21-
{
22-
name: "label",
23-
type: "string",
24-
description:
25-
"An optional label for the input field. If provided, it is displayed as a field label.",
26-
},
12+
...CommonProps,
2713
{
2814
name: "options",
2915
type: "Array<{ label: string; value: string | number }>",
3016
description:
3117
"An array of objects representing the selectable options. Each object should have a 'label' and 'value' property.",
3218
},
33-
{
34-
name: "placeholder",
35-
type: "string",
36-
description:
37-
"An optional placeholder for the input field. It is displayed inside the input when no value is present.",
38-
},
39-
{
40-
name: "disabled",
41-
type: "boolean",
42-
description: "Determines if the input field is disabled. Defaults to false.",
43-
},
19+
...CommonBooleanProps,
4420
{
4521
name: "inputProps",
4622
type: "object",
4723
description:
48-
"Additional props to pass to the input field, such as attributes like 'required' or custom data attributes.",
24+
"Additional props to pass to the input field, such as attributes like data attributes, etc.",
4925
},
5026
] as IRow[];

0 commit comments

Comments
 (0)