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; +}