From cb7e707f0375cd85af0050f88e43a2e14965a48e Mon Sep 17 00:00:00 2001 From: Mert Sincan Date: Fri, 1 Nov 2024 21:53:41 +0000 Subject: [PATCH 01/10] Fixed #6708 - Forms: Could not resolve "valibot" --- packages/forms/rollup.config.mjs | 16 ++++++++++++++-- packages/forms/scripts/postbuild.mjs | 6 +++++- packages/forms/src/form/Form.d.ts | 11 +---------- packages/forms/src/formfield/FormField.d.ts | 11 +---------- packages/forms/src/resolvers/index.d.ts | 1 - packages/forms/src/resolvers/index.js | 1 - packages/forms/src/resolvers/joi/index.d.ts | 1 + packages/forms/src/resolvers/joi/index.js | 1 + .../forms/src/resolvers/{ => joi}/package.json | 0 .../forms/src/resolvers/superstruct/index.d.ts | 1 + .../forms/src/resolvers/superstruct/index.js | 1 + .../forms/src/resolvers/superstruct/package.json | 5 +++++ packages/forms/src/resolvers/valibot/index.d.ts | 1 + packages/forms/src/resolvers/valibot/index.js | 1 + .../forms/src/resolvers/valibot/package.json | 5 +++++ packages/forms/src/resolvers/yup/index.d.ts | 1 + packages/forms/src/resolvers/yup/index.js | 1 + packages/forms/src/resolvers/yup/package.json | 5 +++++ packages/forms/src/resolvers/zod/index.d.ts | 1 + packages/forms/src/resolvers/zod/index.js | 1 + packages/forms/src/resolvers/zod/package.json | 5 +++++ packages/forms/src/types.d.ts | 9 +++++++++ 22 files changed, 60 insertions(+), 25 deletions(-) delete mode 100644 packages/forms/src/resolvers/index.d.ts delete mode 100644 packages/forms/src/resolvers/index.js create mode 100644 packages/forms/src/resolvers/joi/index.d.ts create mode 100644 packages/forms/src/resolvers/joi/index.js rename packages/forms/src/resolvers/{ => joi}/package.json (100%) create mode 100644 packages/forms/src/resolvers/superstruct/index.d.ts create mode 100644 packages/forms/src/resolvers/superstruct/index.js create mode 100644 packages/forms/src/resolvers/superstruct/package.json create mode 100644 packages/forms/src/resolvers/valibot/index.d.ts create mode 100644 packages/forms/src/resolvers/valibot/index.js create mode 100644 packages/forms/src/resolvers/valibot/package.json create mode 100644 packages/forms/src/resolvers/yup/index.d.ts create mode 100644 packages/forms/src/resolvers/yup/index.js create mode 100644 packages/forms/src/resolvers/yup/package.json create mode 100644 packages/forms/src/resolvers/zod/index.d.ts create mode 100644 packages/forms/src/resolvers/zod/index.js create mode 100644 packages/forms/src/resolvers/zod/package.json create mode 100644 packages/forms/src/types.d.ts diff --git a/packages/forms/rollup.config.mjs b/packages/forms/rollup.config.mjs index 29976a15d..1453dbc3b 100644 --- a/packages/forms/rollup.config.mjs +++ b/packages/forms/rollup.config.mjs @@ -43,7 +43,6 @@ const ALIAS_ENTRIES = [ return targetFile ? path.join(folderPath, targetFile) : null; } }, - { find: '@primevue/forms/resolvers', replacement: path.resolve(__dirname, './src/resolvers/index.js') }, { find: '@primevue/forms/useform', replacement: path.resolve(__dirname, './src/useform/index.js') } ]; @@ -211,7 +210,20 @@ function addStyle() { } function addResolvers() { - ENTRY.format.es({ input: process.env.INPUT_DIR + 'resolvers/index.js', output: process.env.OUTPUT_DIR + 'resolvers/index' }); + fs.readdirSync(path.resolve(__dirname, process.env.INPUT_DIR + 'resolvers'), { withFileTypes: true }) + .filter((dir) => dir.isDirectory()) + .forEach(({ name: folderName }) => { + fs.readdirSync(path.resolve(__dirname, process.env.INPUT_DIR + 'resolvers/' + folderName)).forEach((file) => { + let name = file.split(/(.vue)$|(.js)$/)[0].toLowerCase(); + + if (name === 'index') { + const input = process.env.INPUT_DIR + 'resolvers/' + folderName + '/' + file; + const output = process.env.OUTPUT_DIR + 'resolvers/' + folderName + '/index'; + + ENTRY.format.es({ input, output }); + } + }); + }); } function addUseForm() { diff --git a/packages/forms/scripts/postbuild.mjs b/packages/forms/scripts/postbuild.mjs index 6ba562151..4653468d1 100644 --- a/packages/forms/scripts/postbuild.mjs +++ b/packages/forms/scripts/postbuild.mjs @@ -5,7 +5,11 @@ import { clearPackageJson, copyDependencies, renameDTSFile, resolvePath } from ' const { __dirname, __workspace, INPUT_DIR, OUTPUT_DIR } = resolvePath(import.meta.url); copyDependencies(INPUT_DIR, OUTPUT_DIR, '/style'); -renameDTSFile(OUTPUT_DIR, 'index'); +renameDTSFile(OUTPUT_DIR, 'index', (name) => { + return name !== 'types.d.ts'; +}); + +fs.copySync(path.resolve(__dirname, '../src/types.d.ts'), `${OUTPUT_DIR}/types.d.ts`); fs.copySync(path.resolve(__dirname, '../package.json'), `${OUTPUT_DIR}/package.json`); fs.copySync(path.resolve(__dirname, '../README.md'), `${OUTPUT_DIR}/README.md`); diff --git a/packages/forms/src/form/Form.d.ts b/packages/forms/src/form/Form.d.ts index e1d5f2e04..b975e56e7 100644 --- a/packages/forms/src/form/Form.d.ts +++ b/packages/forms/src/form/Form.d.ts @@ -10,16 +10,7 @@ import type { DefineComponent, DesignToken, EmitFn, PassThrough } from '@primevue/core'; import type { ComponentHooks } from '@primevue/core/basecomponent'; import { VNode } from 'vue'; - -/** - * From primevue/passthrough/index.d.ts - */ -export declare type PassThroughMergePropsType = ((...args: any) => object | undefined) | boolean | undefined; - -export interface PassThroughOptions { - mergeSections?: boolean | undefined; - mergeProps?: PassThroughMergePropsType; -} +import type { PassThroughOptions } from '../types'; export declare type FormPassThroughOptionType = FormPassThroughAttributes | ((options: FormPassThroughMethodOptions) => FormPassThroughAttributes | string) | string | null | undefined; diff --git a/packages/forms/src/formfield/FormField.d.ts b/packages/forms/src/formfield/FormField.d.ts index 5b9d89943..5233b6fee 100644 --- a/packages/forms/src/formfield/FormField.d.ts +++ b/packages/forms/src/formfield/FormField.d.ts @@ -9,16 +9,7 @@ import type { DefineComponent, DesignToken, EmitFn, PassThrough } from '@primevue/core'; import type { ComponentHooks } from '@primevue/core/basecomponent'; import { Component, VNode } from 'vue'; - -/** - * From primevue/passthrough/index.d.ts - */ -export declare type PassThroughMergePropsType = ((...args: any) => object | undefined) | boolean | undefined; - -export interface PassThroughOptions { - mergeSections?: boolean | undefined; - mergeProps?: PassThroughMergePropsType; -} +import type { PassThroughOptions } from '../types'; export declare type FormFieldPassThroughOptionType = FormFieldPassThroughAttributes | ((options: FormFieldPassThroughMethodOptions) => FormFieldPassThroughAttributes | string) | string | null | undefined; diff --git a/packages/forms/src/resolvers/index.d.ts b/packages/forms/src/resolvers/index.d.ts deleted file mode 100644 index 1ee7ceab3..000000000 --- a/packages/forms/src/resolvers/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from '@primeuix/forms/resolvers'; diff --git a/packages/forms/src/resolvers/index.js b/packages/forms/src/resolvers/index.js deleted file mode 100644 index 1ee7ceab3..000000000 --- a/packages/forms/src/resolvers/index.js +++ /dev/null @@ -1 +0,0 @@ -export * from '@primeuix/forms/resolvers'; diff --git a/packages/forms/src/resolvers/joi/index.d.ts b/packages/forms/src/resolvers/joi/index.d.ts new file mode 100644 index 000000000..2aa4f0fa5 --- /dev/null +++ b/packages/forms/src/resolvers/joi/index.d.ts @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/joi'; diff --git a/packages/forms/src/resolvers/joi/index.js b/packages/forms/src/resolvers/joi/index.js new file mode 100644 index 000000000..2aa4f0fa5 --- /dev/null +++ b/packages/forms/src/resolvers/joi/index.js @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/joi'; diff --git a/packages/forms/src/resolvers/package.json b/packages/forms/src/resolvers/joi/package.json similarity index 100% rename from packages/forms/src/resolvers/package.json rename to packages/forms/src/resolvers/joi/package.json diff --git a/packages/forms/src/resolvers/superstruct/index.d.ts b/packages/forms/src/resolvers/superstruct/index.d.ts new file mode 100644 index 000000000..9f6f3f67f --- /dev/null +++ b/packages/forms/src/resolvers/superstruct/index.d.ts @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/superstruct'; diff --git a/packages/forms/src/resolvers/superstruct/index.js b/packages/forms/src/resolvers/superstruct/index.js new file mode 100644 index 000000000..9f6f3f67f --- /dev/null +++ b/packages/forms/src/resolvers/superstruct/index.js @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/superstruct'; diff --git a/packages/forms/src/resolvers/superstruct/package.json b/packages/forms/src/resolvers/superstruct/package.json new file mode 100644 index 000000000..cb300e167 --- /dev/null +++ b/packages/forms/src/resolvers/superstruct/package.json @@ -0,0 +1,5 @@ +{ + "main": "./index.js", + "module": "./index.js", + "types": "./index.d.ts" +} diff --git a/packages/forms/src/resolvers/valibot/index.d.ts b/packages/forms/src/resolvers/valibot/index.d.ts new file mode 100644 index 000000000..f99edfe06 --- /dev/null +++ b/packages/forms/src/resolvers/valibot/index.d.ts @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/valibot'; diff --git a/packages/forms/src/resolvers/valibot/index.js b/packages/forms/src/resolvers/valibot/index.js new file mode 100644 index 000000000..f99edfe06 --- /dev/null +++ b/packages/forms/src/resolvers/valibot/index.js @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/valibot'; diff --git a/packages/forms/src/resolvers/valibot/package.json b/packages/forms/src/resolvers/valibot/package.json new file mode 100644 index 000000000..cb300e167 --- /dev/null +++ b/packages/forms/src/resolvers/valibot/package.json @@ -0,0 +1,5 @@ +{ + "main": "./index.js", + "module": "./index.js", + "types": "./index.d.ts" +} diff --git a/packages/forms/src/resolvers/yup/index.d.ts b/packages/forms/src/resolvers/yup/index.d.ts new file mode 100644 index 000000000..4cdd36f4d --- /dev/null +++ b/packages/forms/src/resolvers/yup/index.d.ts @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/yup'; diff --git a/packages/forms/src/resolvers/yup/index.js b/packages/forms/src/resolvers/yup/index.js new file mode 100644 index 000000000..4cdd36f4d --- /dev/null +++ b/packages/forms/src/resolvers/yup/index.js @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/yup'; diff --git a/packages/forms/src/resolvers/yup/package.json b/packages/forms/src/resolvers/yup/package.json new file mode 100644 index 000000000..cb300e167 --- /dev/null +++ b/packages/forms/src/resolvers/yup/package.json @@ -0,0 +1,5 @@ +{ + "main": "./index.js", + "module": "./index.js", + "types": "./index.d.ts" +} diff --git a/packages/forms/src/resolvers/zod/index.d.ts b/packages/forms/src/resolvers/zod/index.d.ts new file mode 100644 index 000000000..bbcc5d748 --- /dev/null +++ b/packages/forms/src/resolvers/zod/index.d.ts @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/zod'; diff --git a/packages/forms/src/resolvers/zod/index.js b/packages/forms/src/resolvers/zod/index.js new file mode 100644 index 000000000..bbcc5d748 --- /dev/null +++ b/packages/forms/src/resolvers/zod/index.js @@ -0,0 +1 @@ +export * from '@primeuix/forms/resolvers/zod'; diff --git a/packages/forms/src/resolvers/zod/package.json b/packages/forms/src/resolvers/zod/package.json new file mode 100644 index 000000000..cb300e167 --- /dev/null +++ b/packages/forms/src/resolvers/zod/package.json @@ -0,0 +1,5 @@ +{ + "main": "./index.js", + "module": "./index.js", + "types": "./index.d.ts" +} diff --git a/packages/forms/src/types.d.ts b/packages/forms/src/types.d.ts new file mode 100644 index 000000000..af1a3ecfa --- /dev/null +++ b/packages/forms/src/types.d.ts @@ -0,0 +1,9 @@ +/** + * From primevue/passthrough/index.d.ts + */ +export declare type PassThroughMergePropsType = ((...args: any) => object | undefined) | boolean | undefined; + +export interface PassThroughOptions { + mergeSections?: boolean | undefined; + mergeProps?: PassThroughMergePropsType; +} From 2e3dcdac909f2d472a550b4142d66850b9f89d29 Mon Sep 17 00:00:00 2001 From: Mert Sincan Date: Fri, 1 Nov 2024 21:54:30 +0000 Subject: [PATCH 02/10] Update form docs --- apps/showcase/doc/autocomplete/FormsDoc.vue | 6 +++--- apps/showcase/doc/cascadeselect/FormsDoc.vue | 4 ++-- apps/showcase/doc/checkbox/FormsDoc.vue | 6 +++--- apps/showcase/doc/colorpicker/FormsDoc.vue | 6 +++--- apps/showcase/doc/datepicker/FormsDoc.vue | 6 +++--- apps/showcase/doc/editor/FormsDoc.vue | 6 +++--- apps/showcase/doc/forms/DynamicDoc.vue | 4 ++-- apps/showcase/doc/forms/ResolversDoc.vue | 17 +++++++++++++---- apps/showcase/doc/forms/SubmitDoc.vue | 6 +++--- apps/showcase/doc/forms/dynamic/DynamicForm.vue | 2 +- .../showcase/doc/forms/formfield/BuiltInDoc.vue | 6 +++--- .../doc/forms/formfield/NonPrimeVueDoc.vue | 6 +++--- .../doc/forms/formfield/ResolverDoc.vue | 12 +++++++++--- .../doc/forms/formfield/TemplateDoc.vue | 6 +++--- apps/showcase/doc/forms/pt/PTViewer.vue | 2 +- apps/showcase/doc/inputmask/FormsDoc.vue | 6 +++--- apps/showcase/doc/inputnumber/FormsDoc.vue | 6 +++--- apps/showcase/doc/inputotp/FormsDoc.vue | 6 +++--- apps/showcase/doc/inputtext/FormsDoc.vue | 6 +++--- apps/showcase/doc/knob/FormsDoc.vue | 6 +++--- apps/showcase/doc/listbox/FormsDoc.vue | 6 +++--- apps/showcase/doc/multiselect/FormsDoc.vue | 6 +++--- apps/showcase/doc/password/FormsDoc.vue | 6 +++--- apps/showcase/doc/radiobutton/FormsDoc.vue | 6 +++--- apps/showcase/doc/rating/FormsDoc.vue | 6 +++--- apps/showcase/doc/select/FormsDoc.vue | 6 +++--- apps/showcase/doc/selectbutton/FormsDoc.vue | 6 +++--- apps/showcase/doc/slider/FormsDoc.vue | 6 +++--- apps/showcase/doc/textarea/FormsDoc.vue | 6 +++--- apps/showcase/doc/togglebutton/FormsDoc.vue | 6 +++--- apps/showcase/doc/toggleswitch/FormsDoc.vue | 6 +++--- apps/showcase/doc/treeselect/FormsDoc.vue | 6 +++--- 32 files changed, 106 insertions(+), 91 deletions(-) diff --git a/apps/showcase/doc/autocomplete/FormsDoc.vue b/apps/showcase/doc/autocomplete/FormsDoc.vue index dcf30adcc..9307eb5cf 100644 --- a/apps/showcase/doc/autocomplete/FormsDoc.vue +++ b/apps/showcase/doc/autocomplete/FormsDoc.vue @@ -16,7 +16,7 @@