From 07a0b9a9103c0fb118c7de327ddb22427def3a67 Mon Sep 17 00:00:00 2001 From: zernonia Date: Sun, 21 Apr 2024 20:27:28 +0800 Subject: [PATCH] chore: add examples --- apps/www/__registry__/index.ts | 100 ++++++++++++++++-- .../src/content/docs/components/auto-form.md | 36 ++++++- .../default/example/AutoFormArray.vue | 38 +++++++ .../{AutoForm.vue => AutoFormBasic.vue} | 0 .../example/AutoFormConfirmPassword.vue | 36 +++++++ .../default/example/AutoFormControlled.vue | 37 +++++++ .../default/example/AutoFormDependencies.vue | 72 +++++++++++++ .../example/AutoFormInputWithoutLabel.vue | 48 +++++++++ .../default/example/AutoFormSubObject.vue | 54 ++++++++++ .../default/ui/auto-form/AutoForm.vue | 11 +- .../ui/auto-form/AutoFormFieldArray.vue | 2 +- .../ui/auto-form/AutoFormFieldObject.vue | 2 +- .../new-york/example/AutoFormArray.vue | 38 +++++++ .../{AutoForm.vue => AutoFormBasic.vue} | 0 .../example/AutoFormConfirmPassword.vue | 36 +++++++ .../new-york/example/AutoFormControlled.vue | 37 +++++++ .../new-york/example/AutoFormDependencies.vue | 72 +++++++++++++ .../example/AutoFormInputWithoutLabel.vue | 48 +++++++++ .../new-york/example/AutoFormSubObject.vue | 54 ++++++++++ .../new-york/ui/auto-form/AutoForm.vue | 11 +- .../registry/styles/default/auto-form.json | 6 +- .../registry/styles/new-york/auto-form.json | 2 +- 22 files changed, 714 insertions(+), 26 deletions(-) create mode 100644 apps/www/src/lib/registry/default/example/AutoFormArray.vue rename apps/www/src/lib/registry/default/example/{AutoForm.vue => AutoFormBasic.vue} (100%) create mode 100644 apps/www/src/lib/registry/default/example/AutoFormConfirmPassword.vue create mode 100644 apps/www/src/lib/registry/default/example/AutoFormControlled.vue create mode 100644 apps/www/src/lib/registry/default/example/AutoFormDependencies.vue create mode 100644 apps/www/src/lib/registry/default/example/AutoFormInputWithoutLabel.vue create mode 100644 apps/www/src/lib/registry/default/example/AutoFormSubObject.vue create mode 100644 apps/www/src/lib/registry/new-york/example/AutoFormArray.vue rename apps/www/src/lib/registry/new-york/example/{AutoForm.vue => AutoFormBasic.vue} (100%) create mode 100644 apps/www/src/lib/registry/new-york/example/AutoFormConfirmPassword.vue create mode 100644 apps/www/src/lib/registry/new-york/example/AutoFormControlled.vue create mode 100644 apps/www/src/lib/registry/new-york/example/AutoFormDependencies.vue create mode 100644 apps/www/src/lib/registry/new-york/example/AutoFormInputWithoutLabel.vue create mode 100644 apps/www/src/lib/registry/new-york/example/AutoFormSubObject.vue diff --git a/apps/www/__registry__/index.ts b/apps/www/__registry__/index.ts index 8689a294..40a63868 100644 --- a/apps/www/__registry__/index.ts +++ b/apps/www/__registry__/index.ts @@ -38,12 +38,54 @@ export const Index = { component: () => import("../src/lib/registry/default/example/AspectRatioDemo.vue").then((m) => m.default), files: ["../src/lib/registry/default/example/AspectRatioDemo.vue"], }, - "AutoForm": { - name: "AutoForm", + "AutoFormArray": { + name: "AutoFormArray", type: "components:example", registryDependencies: ["button","toast","auto-form"], - component: () => import("../src/lib/registry/default/example/AutoForm.vue").then((m) => m.default), - files: ["../src/lib/registry/default/example/AutoForm.vue"], + component: () => import("../src/lib/registry/default/example/AutoFormArray.vue").then((m) => m.default), + files: ["../src/lib/registry/default/example/AutoFormArray.vue"], + }, + "AutoFormBasic": { + name: "AutoFormBasic", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/default/example/AutoFormBasic.vue").then((m) => m.default), + files: ["../src/lib/registry/default/example/AutoFormBasic.vue"], + }, + "AutoFormConfirmPassword": { + name: "AutoFormConfirmPassword", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/default/example/AutoFormConfirmPassword.vue").then((m) => m.default), + files: ["../src/lib/registry/default/example/AutoFormConfirmPassword.vue"], + }, + "AutoFormControlled": { + name: "AutoFormControlled", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/default/example/AutoFormControlled.vue").then((m) => m.default), + files: ["../src/lib/registry/default/example/AutoFormControlled.vue"], + }, + "AutoFormDependencies": { + name: "AutoFormDependencies", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/default/example/AutoFormDependencies.vue").then((m) => m.default), + files: ["../src/lib/registry/default/example/AutoFormDependencies.vue"], + }, + "AutoFormInputWithoutLabel": { + name: "AutoFormInputWithoutLabel", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/default/example/AutoFormInputWithoutLabel.vue").then((m) => m.default), + files: ["../src/lib/registry/default/example/AutoFormInputWithoutLabel.vue"], + }, + "AutoFormSubObject": { + name: "AutoFormSubObject", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/default/example/AutoFormSubObject.vue").then((m) => m.default), + files: ["../src/lib/registry/default/example/AutoFormSubObject.vue"], }, "AvatarDemo": { name: "AvatarDemo", @@ -1285,12 +1327,54 @@ export const Index = { component: () => import("../src/lib/registry/new-york/example/AspectRatioDemo.vue").then((m) => m.default), files: ["../src/lib/registry/new-york/example/AspectRatioDemo.vue"], }, - "AutoForm": { - name: "AutoForm", + "AutoFormArray": { + name: "AutoFormArray", type: "components:example", registryDependencies: ["button","toast","auto-form"], - component: () => import("../src/lib/registry/new-york/example/AutoForm.vue").then((m) => m.default), - files: ["../src/lib/registry/new-york/example/AutoForm.vue"], + component: () => import("../src/lib/registry/new-york/example/AutoFormArray.vue").then((m) => m.default), + files: ["../src/lib/registry/new-york/example/AutoFormArray.vue"], + }, + "AutoFormBasic": { + name: "AutoFormBasic", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/new-york/example/AutoFormBasic.vue").then((m) => m.default), + files: ["../src/lib/registry/new-york/example/AutoFormBasic.vue"], + }, + "AutoFormConfirmPassword": { + name: "AutoFormConfirmPassword", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/new-york/example/AutoFormConfirmPassword.vue").then((m) => m.default), + files: ["../src/lib/registry/new-york/example/AutoFormConfirmPassword.vue"], + }, + "AutoFormControlled": { + name: "AutoFormControlled", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/new-york/example/AutoFormControlled.vue").then((m) => m.default), + files: ["../src/lib/registry/new-york/example/AutoFormControlled.vue"], + }, + "AutoFormDependencies": { + name: "AutoFormDependencies", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/new-york/example/AutoFormDependencies.vue").then((m) => m.default), + files: ["../src/lib/registry/new-york/example/AutoFormDependencies.vue"], + }, + "AutoFormInputWithoutLabel": { + name: "AutoFormInputWithoutLabel", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/new-york/example/AutoFormInputWithoutLabel.vue").then((m) => m.default), + files: ["../src/lib/registry/new-york/example/AutoFormInputWithoutLabel.vue"], + }, + "AutoFormSubObject": { + name: "AutoFormSubObject", + type: "components:example", + registryDependencies: ["button","toast","auto-form"], + component: () => import("../src/lib/registry/new-york/example/AutoFormSubObject.vue").then((m) => m.default), + files: ["../src/lib/registry/new-york/example/AutoFormSubObject.vue"], }, "AvatarDemo": { name: "AvatarDemo", diff --git a/apps/www/src/content/docs/components/auto-form.md b/apps/www/src/content/docs/components/auto-form.md index 62909ac0..9d0925b5 100644 --- a/apps/www/src/content/docs/components/auto-form.md +++ b/apps/www/src/content/docs/components/auto-form.md @@ -1,7 +1,39 @@ --- title: Auto Form -description: Building forms with VeeValidate and Zod. +description: Automatically generate a form from Zod schema. primitive: https://vee-validate.logaretm.com/v4/guide/overview/ --- - +### Basic + + + +### Input Without Label +This example shows how to use AutoForm input without label. + + + +### Sub Object +Automatically generate a form from a Zod schema. + + + +### Controlled +This example shows how to use AutoForm in a controlled way. + + + +### Confirm Password +Refined schema to validate that two fields match. + + + +### Array support +You can use arrays in your schemas to create dynamic forms. + + + +### Dependencies +Create dependencies between fields. + + diff --git a/apps/www/src/lib/registry/default/example/AutoFormArray.vue b/apps/www/src/lib/registry/default/example/AutoFormArray.vue new file mode 100644 index 00000000..8b97ddc4 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/AutoFormArray.vue @@ -0,0 +1,38 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/AutoForm.vue b/apps/www/src/lib/registry/default/example/AutoFormBasic.vue similarity index 100% rename from apps/www/src/lib/registry/default/example/AutoForm.vue rename to apps/www/src/lib/registry/default/example/AutoFormBasic.vue diff --git a/apps/www/src/lib/registry/default/example/AutoFormConfirmPassword.vue b/apps/www/src/lib/registry/default/example/AutoFormConfirmPassword.vue new file mode 100644 index 00000000..740824e7 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/AutoFormConfirmPassword.vue @@ -0,0 +1,36 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/AutoFormControlled.vue b/apps/www/src/lib/registry/default/example/AutoFormControlled.vue new file mode 100644 index 00000000..14d002a1 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/AutoFormControlled.vue @@ -0,0 +1,37 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/AutoFormDependencies.vue b/apps/www/src/lib/registry/default/example/AutoFormDependencies.vue new file mode 100644 index 00000000..a242d9b0 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/AutoFormDependencies.vue @@ -0,0 +1,72 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/AutoFormInputWithoutLabel.vue b/apps/www/src/lib/registry/default/example/AutoFormInputWithoutLabel.vue new file mode 100644 index 00000000..ec94e250 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/AutoFormInputWithoutLabel.vue @@ -0,0 +1,48 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/AutoFormSubObject.vue b/apps/www/src/lib/registry/default/example/AutoFormSubObject.vue new file mode 100644 index 00000000..4c6a5a11 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/AutoFormSubObject.vue @@ -0,0 +1,54 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/auto-form/AutoForm.vue b/apps/www/src/lib/registry/default/ui/auto-form/AutoForm.vue index 7da60774..3cdf2c89 100644 --- a/apps/www/src/lib/registry/default/ui/auto-form/AutoForm.vue +++ b/apps/www/src/lib/registry/default/ui/auto-form/AutoForm.vue @@ -1,9 +1,9 @@ - + + diff --git a/apps/www/src/lib/registry/new-york/example/AutoForm.vue b/apps/www/src/lib/registry/new-york/example/AutoFormBasic.vue similarity index 100% rename from apps/www/src/lib/registry/new-york/example/AutoForm.vue rename to apps/www/src/lib/registry/new-york/example/AutoFormBasic.vue diff --git a/apps/www/src/lib/registry/new-york/example/AutoFormConfirmPassword.vue b/apps/www/src/lib/registry/new-york/example/AutoFormConfirmPassword.vue new file mode 100644 index 00000000..9f96b908 --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/AutoFormConfirmPassword.vue @@ -0,0 +1,36 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/AutoFormControlled.vue b/apps/www/src/lib/registry/new-york/example/AutoFormControlled.vue new file mode 100644 index 00000000..eb3b3acb --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/AutoFormControlled.vue @@ -0,0 +1,37 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/AutoFormDependencies.vue b/apps/www/src/lib/registry/new-york/example/AutoFormDependencies.vue new file mode 100644 index 00000000..bdd5f505 --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/AutoFormDependencies.vue @@ -0,0 +1,72 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/AutoFormInputWithoutLabel.vue b/apps/www/src/lib/registry/new-york/example/AutoFormInputWithoutLabel.vue new file mode 100644 index 00000000..f2fadc94 --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/AutoFormInputWithoutLabel.vue @@ -0,0 +1,48 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/AutoFormSubObject.vue b/apps/www/src/lib/registry/new-york/example/AutoFormSubObject.vue new file mode 100644 index 00000000..c83aa270 --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/AutoFormSubObject.vue @@ -0,0 +1,54 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/ui/auto-form/AutoForm.vue b/apps/www/src/lib/registry/new-york/ui/auto-form/AutoForm.vue index e883328e..6eb3ce5f 100644 --- a/apps/www/src/lib/registry/new-york/ui/auto-form/AutoForm.vue +++ b/apps/www/src/lib/registry/new-york/ui/auto-form/AutoForm.vue @@ -1,9 +1,9 @@ -\n\n\n" + "content": "\n\n\n" }, { "name": "AutoFormField.vue", @@ -32,7 +32,7 @@ }, { "name": "AutoFormFieldArray.vue", - "content": "\n\n\n" + "content": "\n\n\n" }, { "name": "AutoFormFieldBoolean.vue", @@ -60,7 +60,7 @@ }, { "name": "AutoFormFieldObject.vue", - "content": "\n\n\n" + "content": "\n\n\n" }, { "name": "AutoFormLabel.vue", diff --git a/apps/www/src/public/registry/styles/new-york/auto-form.json b/apps/www/src/public/registry/styles/new-york/auto-form.json index 7e5e2857..d8df2e73 100644 --- a/apps/www/src/public/registry/styles/new-york/auto-form.json +++ b/apps/www/src/public/registry/styles/new-york/auto-form.json @@ -24,7 +24,7 @@ "files": [ { "name": "AutoForm.vue", - "content": "\n\n\n" + "content": "\n\n\n" }, { "name": "AutoFormField.vue",