@pixpilot/formily-shadcn 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +75 -0
  2. package/dist/components/array-base/components/array-item-label.cjs +1 -1
  3. package/dist/components/array-base/components/array-item-label.js +1 -1
  4. package/dist/components/checkbox.d.cts +2 -2
  5. package/dist/components/checkbox.d.ts +2 -2
  6. package/dist/components/column.d.ts +2 -2
  7. package/dist/components/context/form-context.d.cts +20 -16
  8. package/dist/components/context/form-context.d.ts +20 -16
  9. package/dist/components/context/index.d.cts +1 -1
  10. package/dist/components/context/index.d.ts +1 -1
  11. package/dist/components/date-picker.d.cts +3 -3
  12. package/dist/components/date-picker.d.ts +3 -3
  13. package/dist/components/file-upload/file-upload-inline.d.ts +8 -8
  14. package/dist/components/file-upload/file-upload.d.ts +8 -8
  15. package/dist/components/file-upload/use-file-upload-feedback.cjs +2 -2
  16. package/dist/components/file-upload/use-file-upload-feedback.js +2 -2
  17. package/dist/components/form-grid.d.ts +2 -2
  18. package/dist/components/form-items-container.cjs +2 -5
  19. package/dist/components/form-items-container.js +2 -5
  20. package/dist/components/form.cjs +3 -5
  21. package/dist/components/form.d.cts +1 -2
  22. package/dist/components/form.d.ts +1 -2
  23. package/dist/components/form.js +3 -5
  24. package/dist/components/icon-picker.cjs +2 -2
  25. package/dist/components/icon-picker.d.ts +3 -3
  26. package/dist/components/icon-picker.js +2 -2
  27. package/dist/components/input.d.cts +2 -2
  28. package/dist/components/json-schema-form-renderer.cjs +34 -7
  29. package/dist/components/json-schema-form-renderer.d.cts +8 -3
  30. package/dist/components/json-schema-form-renderer.d.ts +8 -3
  31. package/dist/components/json-schema-form-renderer.js +32 -7
  32. package/dist/components/number-input.d.cts +2 -2
  33. package/dist/components/number-input.d.ts +2 -2
  34. package/dist/components/object-container.cjs +33 -7
  35. package/dist/components/object-container.js +34 -8
  36. package/dist/components/radio.d.ts +2 -2
  37. package/dist/components/rich-text-editor.cjs +1 -1
  38. package/dist/components/rich-text-editor.js +1 -1
  39. package/dist/components/row.d.ts +2 -2
  40. package/dist/components/schema-field/index.d.cts +1 -1
  41. package/dist/components/schema-field/index.d.ts +1 -1
  42. package/dist/components/schema-field/index.js +1 -1
  43. package/dist/components/schema-field/schema-field-basics.cjs +4 -4
  44. package/dist/components/schema-field/schema-field-basics.d.cts +194 -194
  45. package/dist/components/schema-field/schema-field-basics.d.ts +209 -209
  46. package/dist/components/schema-field/schema-field-basics.js +3 -3
  47. package/dist/components/schema-field/schema-field-extended.d.cts +427 -427
  48. package/dist/components/schema-field/schema-field-extended.d.ts +427 -427
  49. package/dist/components/schema-field/schema-field.cjs +1 -1
  50. package/dist/components/schema-field/schema-field.d.cts +237 -237
  51. package/dist/components/schema-field/schema-field.d.ts +236 -236
  52. package/dist/components/schema-field/schema-field.js +2 -2
  53. package/dist/components/separator.d.cts +2 -2
  54. package/dist/components/separator.d.ts +2 -2
  55. package/dist/components/slider.d.cts +2 -2
  56. package/dist/components/slider.d.ts +2 -2
  57. package/dist/components/switch.d.cts +2 -2
  58. package/dist/components/switch.d.ts +2 -2
  59. package/dist/components/tags-input-inline.d.cts +2 -2
  60. package/dist/components/textarea.d.cts +2 -2
  61. package/dist/components/textarea.d.ts +2 -2
  62. package/dist/hooks/index.js +1 -1
  63. package/dist/hooks/use-form-context.cjs +5 -0
  64. package/dist/hooks/use-form-context.js +5 -1
  65. package/dist/hooks/use-label.cjs +9 -2
  66. package/dist/hooks/use-label.js +9 -2
  67. package/dist/index.cjs +1 -1
  68. package/dist/index.d.cts +2 -2
  69. package/dist/index.d.ts +2 -2
  70. package/dist/index.js +2 -2
  71. package/dist/types/form.d.cts +0 -6
  72. package/dist/types/form.d.ts +0 -6
  73. package/dist/utils/extract-fields-decorators.cjs +37 -0
  74. package/dist/utils/extract-fields-decorators.js +36 -0
  75. package/dist/utils/index.cjs +2 -0
  76. package/dist/utils/index.js +3 -1
  77. package/dist/utils/resolve-responsive-space.cjs +45 -89
  78. package/dist/utils/resolve-responsive-space.js +42 -83
  79. package/dist/utils/transform-schema.cjs +9 -2
  80. package/dist/utils/transform-schema.js +9 -2
  81. package/dist/utils/validate-schema-components.cjs +45 -0
  82. package/dist/utils/validate-schema-components.js +43 -0
  83. package/package.json +4 -3
package/README.md CHANGED
@@ -161,3 +161,78 @@ const form = createForm({
161
161
  effects: () => {},
162
162
  });
163
163
  ```
164
+
165
+ ### Form Configuration
166
+
167
+ #### useFieldNameAsLabel
168
+
169
+ The `useFieldNameAsLabel` option controls whether field names are automatically converted to labels when no explicit label is provided.
170
+
171
+ **Default Behavior:**
172
+
173
+ - **`JsonSchemaFormRenderer`** - Sets `useFieldNameAsLabel: true` by default. Field names are automatically capitalized and used as labels if no `title` is provided in the schema.
174
+ - **`Form` component** - Must be explicitly configured. Users need to set `useFieldNameAsLabel: true` in the `config` prop to enable this behavior.
175
+
176
+ **Example with JsonSchemaFormRenderer (enabled by default):**
177
+
178
+ ```tsx
179
+ import { JsonSchemaFormRenderer } from '@pixpilot/formily-shadcn';
180
+
181
+ const schema = {
182
+ type: 'object',
183
+ properties: {
184
+ userName: {
185
+ type: 'string',
186
+ 'x-decorator': 'FormItem',
187
+ 'x-component': 'Input',
188
+ // No title provided - will use "User Name" as label
189
+ },
190
+ },
191
+ };
192
+
193
+ export function MyForm() {
194
+ return <JsonSchemaFormRenderer schema={schema} />;
195
+ }
196
+ ```
197
+
198
+ **Example with Form component (requires explicit configuration):**
199
+
200
+ ```tsx
201
+ import { createForm, Form, SchemaField } from '@pixpilot/formily-shadcn';
202
+
203
+ const form = createForm();
204
+
205
+ const schema = {
206
+ type: 'object',
207
+ properties: {
208
+ userName: {
209
+ type: 'string',
210
+ 'x-decorator': 'FormItem',
211
+ 'x-component': 'Input',
212
+ // No title provided - will use "User Name" as label only if config is set
213
+ },
214
+ },
215
+ };
216
+
217
+ export function MyForm() {
218
+ return (
219
+ <Form
220
+ form={form}
221
+ config={{
222
+ label: {
223
+ useFieldNameAsLabel: true, // Must be explicitly set
224
+ },
225
+ }}
226
+ >
227
+ <SchemaField schema={schema} />
228
+ </Form>
229
+ );
230
+ }
231
+ ```
232
+
233
+ The label resolution priority is:
234
+
235
+ 1. Explicit `label` prop (if provided and not `false`)
236
+ 2. Schema `title` field
237
+ 3. Field `name` capitalized (only if `useFieldNameAsLabel: true`)
238
+ 4. No label
@@ -11,7 +11,7 @@ const ArrayItemLabel = () => {
11
11
  const label = require_use_label.useLabel();
12
12
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
13
13
  className: "font-medium",
14
- children: [label, typeof label === "string" ? ` ${(index ?? 0) + 1}` : ""]
14
+ children: [label, typeof label === "string" || label == null ? ` ${(index ?? 0) + 1}` : ""]
15
15
  });
16
16
  };
17
17
 
@@ -9,7 +9,7 @@ const ArrayItemLabel = () => {
9
9
  const label = useLabel();
10
10
  return /* @__PURE__ */ jsxs("span", {
11
11
  className: "font-medium",
12
- children: [label, typeof label === "string" ? ` ${(index ?? 0) + 1}` : ""]
12
+ children: [label, typeof label === "string" || label == null ? ` ${(index ?? 0) + 1}` : ""]
13
13
  });
14
14
  };
15
15
 
@@ -1,4 +1,4 @@
1
- import * as react0 from "react";
1
+ import * as react1 from "react";
2
2
  import * as _radix_ui_react_checkbox0 from "@radix-ui/react-checkbox";
3
3
 
4
4
  //#region src/components/checkbox.d.ts
@@ -6,6 +6,6 @@ import * as _radix_ui_react_checkbox0 from "@radix-ui/react-checkbox";
6
6
  * Formily-connected Checkbox component
7
7
  * Maps Formily field checked state to shadcn Checkbox
8
8
  */
9
- declare const Checkbox: react0.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_checkbox0.CheckboxProps & react0.RefAttributes<HTMLButtonElement>>, "ref"> & react0.RefAttributes<unknown>>;
9
+ declare const Checkbox: react1.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_checkbox0.CheckboxProps & react1.RefAttributes<HTMLButtonElement>>, "ref"> & react1.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { Checkbox };
@@ -1,4 +1,4 @@
1
- import * as react7 from "react";
1
+ import * as react0 from "react";
2
2
  import * as _radix_ui_react_checkbox0 from "@radix-ui/react-checkbox";
3
3
 
4
4
  //#region src/components/checkbox.d.ts
@@ -6,6 +6,6 @@ import * as _radix_ui_react_checkbox0 from "@radix-ui/react-checkbox";
6
6
  * Formily-connected Checkbox component
7
7
  * Maps Formily field checked state to shadcn Checkbox
8
8
  */
9
- declare const Checkbox: react7.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_checkbox0.CheckboxProps & react7.RefAttributes<HTMLButtonElement>>, "ref"> & react7.RefAttributes<unknown>>;
9
+ declare const Checkbox: react0.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_checkbox0.CheckboxProps & react0.RefAttributes<HTMLButtonElement>>, "ref"> & react0.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { Checkbox };
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as react_jsx_runtime2 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/column.d.ts
5
5
  interface IColumnProps {
@@ -36,6 +36,6 @@ interface IColumnProps {
36
36
  declare function Column({
37
37
  className,
38
38
  children
39
- }: IColumnProps): react_jsx_runtime2.JSX.Element;
39
+ }: IColumnProps): react_jsx_runtime0.JSX.Element;
40
40
  //#endregion
41
41
  export { Column };
@@ -7,6 +7,24 @@ interface FomFileUpload {
7
7
  onUpload?: (files: File[], options: FileUploadProgressCallBacks) => void;
8
8
  maxSize?: number;
9
9
  }
10
+ interface FormConfigProps {
11
+ label?: {
12
+ useFieldNameAsLabel?: boolean;
13
+ };
14
+ iconPicker?: {
15
+ /**
16
+ * Icon providers - can be static providers or async loader functions
17
+ * Users can provide either IconProvider[] or AsyncIconProvider[]
18
+ */
19
+ providers: IconProvider[];
20
+ /**
21
+ * Optional callback when providers are loaded
22
+ */
23
+ onProvidersLoaded?: (providers: IconProvider[]) => void;
24
+ };
25
+ fileUpload?: FomFileUpload;
26
+ richTextEditor?: RichTextEditorProps;
27
+ }
10
28
  interface FormContextStates extends FormSpace {
11
29
  itemProps?: {
12
30
  className?: string;
@@ -14,21 +32,7 @@ interface FormContextStates extends FormSpace {
14
32
  objectContainerProps?: {
15
33
  className?: string;
16
34
  };
17
- config?: {
18
- iconPicker?: {
19
- /**
20
- * Icon providers - can be static providers or async loader functions
21
- * Users can provide either IconProvider[] or AsyncIconProvider[]
22
- */
23
- providers: IconProvider[];
24
- /**
25
- * Optional callback when providers are loaded
26
- */
27
- onProvidersLoaded?: (providers: IconProvider[]) => void;
28
- };
29
- fileUpload?: FomFileUpload;
30
- richTextEditor?: RichTextEditorProps;
31
- };
35
+ settings?: FormConfigProps;
32
36
  }
33
37
  //#endregion
34
- export { FomFileUpload, FormContextStates };
38
+ export { FomFileUpload, FormConfigProps, FormContextStates };
@@ -7,6 +7,24 @@ interface FomFileUpload {
7
7
  onUpload?: (files: File[], options: FileUploadProgressCallBacks) => void;
8
8
  maxSize?: number;
9
9
  }
10
+ interface FormConfigProps {
11
+ label?: {
12
+ useFieldNameAsLabel?: boolean;
13
+ };
14
+ iconPicker?: {
15
+ /**
16
+ * Icon providers - can be static providers or async loader functions
17
+ * Users can provide either IconProvider[] or AsyncIconProvider[]
18
+ */
19
+ providers: IconProvider[];
20
+ /**
21
+ * Optional callback when providers are loaded
22
+ */
23
+ onProvidersLoaded?: (providers: IconProvider[]) => void;
24
+ };
25
+ fileUpload?: FomFileUpload;
26
+ richTextEditor?: RichTextEditorProps;
27
+ }
10
28
  interface FormContextStates extends FormSpace {
11
29
  itemProps?: {
12
30
  className?: string;
@@ -14,21 +32,7 @@ interface FormContextStates extends FormSpace {
14
32
  objectContainerProps?: {
15
33
  className?: string;
16
34
  };
17
- config?: {
18
- iconPicker?: {
19
- /**
20
- * Icon providers - can be static providers or async loader functions
21
- * Users can provide either IconProvider[] or AsyncIconProvider[]
22
- */
23
- providers: IconProvider[];
24
- /**
25
- * Optional callback when providers are loaded
26
- */
27
- onProvidersLoaded?: (providers: IconProvider[]) => void;
28
- };
29
- fileUpload?: FomFileUpload;
30
- richTextEditor?: RichTextEditorProps;
31
- };
35
+ settings?: FormConfigProps;
32
36
  }
33
37
  //#endregion
34
- export { FomFileUpload, FormContextStates };
38
+ export { FomFileUpload, FormConfigProps, FormContextStates };
@@ -1,2 +1,2 @@
1
- import { FomFileUpload, FormContextStates } from "./form-context.cjs";
1
+ import { FomFileUpload, FormConfigProps, FormContextStates } from "./form-context.cjs";
2
2
  import "./context.cjs";
@@ -1,2 +1,2 @@
1
- import { FomFileUpload, FormContextStates } from "./form-context.js";
1
+ import { FomFileUpload, FormConfigProps, FormContextStates } from "./form-context.js";
2
2
  import "./context.js";
@@ -1,11 +1,11 @@
1
- import * as react2 from "react";
1
+ import * as react0 from "react";
2
2
  import { DatePickerProps } from "@pixpilot/shadcn-ui";
3
3
 
4
4
  //#region src/components/date-picker.d.ts
5
- declare const DatePicker: react2.ForwardRefExoticComponent<Partial<{
5
+ declare const DatePicker: react0.ForwardRefExoticComponent<Partial<{
6
6
  value?: Date;
7
7
  onChange?: (date: Date | undefined) => void;
8
8
  placeholder?: string;
9
- } & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react2.RefAttributes<unknown>>;
9
+ } & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react0.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { DatePicker };
@@ -1,11 +1,11 @@
1
- import * as react5 from "react";
1
+ import * as react2 from "react";
2
2
  import { DatePickerProps } from "@pixpilot/shadcn-ui";
3
3
 
4
4
  //#region src/components/date-picker.d.ts
5
- declare const DatePicker$1: react5.ForwardRefExoticComponent<Partial<{
5
+ declare const DatePicker$1: react2.ForwardRefExoticComponent<Partial<{
6
6
  value?: Date;
7
7
  onChange?: (date: Date | undefined) => void;
8
8
  placeholder?: string;
9
- } & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react5.RefAttributes<unknown>>;
9
+ } & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react2.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { DatePicker$1 as DatePicker };
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as _pixpilot_shadcn_ui8 from "@pixpilot/shadcn-ui";
2
+ import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
3
3
 
4
4
  //#region src/components/file-upload/file-upload-inline.d.ts
5
5
 
@@ -7,14 +7,14 @@ import * as _pixpilot_shadcn_ui8 from "@pixpilot/shadcn-ui";
7
7
  * Formily-connected FileUploadInline component
8
8
  * Automatically connects shadcn FileUploadInline to Formily field state
9
9
  */
10
- declare const FileUploadInline$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui8.FileUploadInlineBaseProps & {
10
+ declare const FileUploadInline$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui0.FileUploadInlineBaseProps & {
11
11
  multiple: true;
12
- value?: _pixpilot_shadcn_ui8.FileMetadata[];
13
- onChange?: _pixpilot_shadcn_ui8.OnChangeMultipleFiles;
14
- } & _pixpilot_shadcn_ui8.FileUploadBaseProps>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui8.FileUploadInlineBaseProps & {
12
+ value?: _pixpilot_shadcn_ui0.FileMetadata[];
13
+ onChange?: _pixpilot_shadcn_ui0.OnChangeMultipleFiles;
14
+ } & _pixpilot_shadcn_ui0.FileUploadBaseProps>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui0.FileUploadInlineBaseProps & {
15
15
  multiple?: false;
16
- value?: _pixpilot_shadcn_ui8.FileMetadata | null;
17
- onChange?: _pixpilot_shadcn_ui8.OnChangeSingleFile;
18
- } & _pixpilot_shadcn_ui8.FileUploadBaseProps>, "ref">) & React.RefAttributes<unknown>>;
16
+ value?: _pixpilot_shadcn_ui0.FileMetadata | null;
17
+ onChange?: _pixpilot_shadcn_ui0.OnChangeSingleFile;
18
+ } & _pixpilot_shadcn_ui0.FileUploadBaseProps>, "ref">) & React.RefAttributes<unknown>>;
19
19
  //#endregion
20
20
  export { FileUploadInline$1 as FileUploadInline };
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
2
+ import * as _pixpilot_shadcn_ui8 from "@pixpilot/shadcn-ui";
3
3
 
4
4
  //#region src/components/file-upload/file-upload.d.ts
5
5
 
@@ -7,14 +7,14 @@ import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
7
7
  * Formily-connected FileUploadInline component
8
8
  * Automatically connects shadcn FileUploadInline to Formily field state
9
9
  */
10
- declare const FileUpload$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui0.FileUploadInlineBaseProps & {
10
+ declare const FileUpload$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui8.FileUploadInlineBaseProps & {
11
11
  multiple: true;
12
- value?: _pixpilot_shadcn_ui0.FileMetadata[];
13
- onChange?: _pixpilot_shadcn_ui0.OnChangeMultipleFiles;
14
- } & _pixpilot_shadcn_ui0.FileUploadBaseProps>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui0.FileUploadInlineBaseProps & {
12
+ value?: _pixpilot_shadcn_ui8.FileMetadata[];
13
+ onChange?: _pixpilot_shadcn_ui8.OnChangeMultipleFiles;
14
+ } & _pixpilot_shadcn_ui8.FileUploadBaseProps>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui8.FileUploadInlineBaseProps & {
15
15
  multiple?: false;
16
- value?: _pixpilot_shadcn_ui0.FileMetadata | null;
17
- onChange?: _pixpilot_shadcn_ui0.OnChangeSingleFile;
18
- } & _pixpilot_shadcn_ui0.FileUploadBaseProps>, "ref">) & React.RefAttributes<unknown>>;
16
+ value?: _pixpilot_shadcn_ui8.FileMetadata | null;
17
+ onChange?: _pixpilot_shadcn_ui8.OnChangeSingleFile;
18
+ } & _pixpilot_shadcn_ui8.FileUploadBaseProps>, "ref">) & React.RefAttributes<unknown>>;
19
19
  //#endregion
20
20
  export { FileUpload$1 as FileUpload };
@@ -11,9 +11,9 @@ pretty_bytes = require_rolldown_runtime.__toESM(pretty_bytes);
11
11
  //#region src/components/file-upload/use-file-upload-feedback.ts
12
12
  function useFileUploadFeedback(props) {
13
13
  const { onUpload: onUploadProp, maxSize: maxSizeProp, onFilesReject, onFileValidate } = props;
14
- const { config } = require_use_form_context.useFormContext();
14
+ const { settings } = require_use_form_context.useFormContext();
15
15
  const field = (0, __formily_react.useField)();
16
- const { fileUpload } = config || {};
16
+ const { fileUpload } = settings || {};
17
17
  const onUpload = onUploadProp ?? fileUpload?.onUpload;
18
18
  const maxSize = maxSizeProp ?? fileUpload?.maxSize;
19
19
  if (onUpload == null) {
@@ -7,9 +7,9 @@ import prettyBytes from "pretty-bytes";
7
7
  //#region src/components/file-upload/use-file-upload-feedback.ts
8
8
  function useFileUploadFeedback(props) {
9
9
  const { onUpload: onUploadProp, maxSize: maxSizeProp, onFilesReject, onFileValidate } = props;
10
- const { config } = useFormContext();
10
+ const { settings } = useFormContext();
11
11
  const field = useField();
12
- const { fileUpload } = config || {};
12
+ const { fileUpload } = settings || {};
13
13
  const onUpload = onUploadProp ?? fileUpload?.onUpload;
14
14
  const maxSize = maxSizeProp ?? fileUpload?.maxSize;
15
15
  if (onUpload == null) throw new Error("onUpload prop required for FileUploadInline. Provide handler on form or field props.");
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/form-grid.d.ts
5
5
  interface IFormGridProps extends React.HTMLAttributes<HTMLDivElement> {}
@@ -7,6 +7,6 @@ declare function FormGrid({
7
7
  className,
8
8
  children,
9
9
  ...rest
10
- }: IFormGridProps): react_jsx_runtime0.JSX.Element;
10
+ }: IFormGridProps): react_jsx_runtime1.JSX.Element;
11
11
  //#endregion
12
12
  export { FormGrid };
@@ -12,11 +12,8 @@ __pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
12
12
  //#region src/components/form-items-container.tsx
13
13
  const FormItemContainer = (props) => {
14
14
  const { as: Component = "div", className,...rest } = props;
15
- const { density, responsive } = require_use_form_context.useFormContext();
16
- const spaceClass = require_resolve_responsive_space.resolveResponsiveSpaceClass({
17
- density,
18
- responsive
19
- });
15
+ const { density } = require_use_form_context.useFormContext();
16
+ const spaceClass = require_resolve_responsive_space.resolveResponsiveSpaceClass({ density });
20
17
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
21
18
  ...rest,
22
19
  className: (0, __pixpilot_shadcn.cn)(spaceClass, className)
@@ -8,11 +8,8 @@ import { cn } from "@pixpilot/shadcn";
8
8
  //#region src/components/form-items-container.tsx
9
9
  const FormItemContainer = (props) => {
10
10
  const { as: Component = "div", className,...rest } = props;
11
- const { density, responsive } = useFormContext();
12
- const spaceClass = resolveResponsiveSpaceClass({
13
- density,
14
- responsive
15
- });
11
+ const { density } = useFormContext();
12
+ const spaceClass = resolveResponsiveSpaceClass({ density });
16
13
  return /* @__PURE__ */ jsx(Component, {
17
14
  ...rest,
18
15
  className: cn(spaceClass, className)
@@ -15,7 +15,7 @@ __pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
15
15
  /**
16
16
  * Form component - wraps FormProvider and provides form context
17
17
  */
18
- function Form({ form, className, style, children, onSubmit, onAutoSubmit, itemProps, objectContainerProps, density, responsive, config }) {
18
+ function Form({ form, className, style, children, onSubmit, onAutoSubmit, itemProps, objectContainerProps, density, settings }) {
19
19
  const handleSubmit = (e) => {
20
20
  e.preventDefault();
21
21
  form.submit((values) => {
@@ -29,15 +29,13 @@ function Form({ form, className, style, children, onSubmit, onAutoSubmit, itemPr
29
29
  itemProps,
30
30
  objectContainerProps,
31
31
  density,
32
- responsive,
33
- config
32
+ settings
34
33
  };
35
34
  }, [
36
35
  itemProps,
37
36
  objectContainerProps,
38
37
  density,
39
- responsive,
40
- config
38
+ settings
41
39
  ]),
42
40
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.FormProvider, {
43
41
  form,
@@ -26,8 +26,7 @@ declare function Form$1({
26
26
  itemProps,
27
27
  objectContainerProps,
28
28
  density,
29
- responsive,
30
- config
29
+ settings
31
30
  }: IFormProps): react_jsx_runtime0.JSX.Element;
32
31
  //#endregion
33
32
  export { Form$1 as Form };
@@ -26,8 +26,7 @@ declare function Form$1({
26
26
  itemProps,
27
27
  objectContainerProps,
28
28
  density,
29
- responsive,
30
- config
29
+ settings
31
30
  }: IFormProps): react_jsx_runtime0.JSX.Element;
32
31
  //#endregion
33
32
  export { Form$1 as Form };
@@ -10,7 +10,7 @@ import { cn } from "@pixpilot/shadcn";
10
10
  /**
11
11
  * Form component - wraps FormProvider and provides form context
12
12
  */
13
- function Form({ form, className, style, children, onSubmit, onAutoSubmit, itemProps, objectContainerProps, density, responsive, config }) {
13
+ function Form({ form, className, style, children, onSubmit, onAutoSubmit, itemProps, objectContainerProps, density, settings }) {
14
14
  const handleSubmit = (e) => {
15
15
  e.preventDefault();
16
16
  form.submit((values) => {
@@ -24,15 +24,13 @@ function Form({ form, className, style, children, onSubmit, onAutoSubmit, itemPr
24
24
  itemProps,
25
25
  objectContainerProps,
26
26
  density,
27
- responsive,
28
- config
27
+ settings
29
28
  };
30
29
  }, [
31
30
  itemProps,
32
31
  objectContainerProps,
33
32
  density,
34
- responsive,
35
- config
33
+ settings
36
34
  ]),
37
35
  children: /* @__PURE__ */ jsx(FormProvider, {
38
36
  form,
@@ -11,8 +11,8 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
11
11
  //#region src/components/icon-picker.tsx
12
12
  const IconPickerBase = (props) => {
13
13
  const { providers: propProviders,...restProps } = props;
14
- const { config } = require_use_form_context.useFormContext();
15
- const { iconPicker } = config || {};
14
+ const { settings } = require_use_form_context.useFormContext();
15
+ const { iconPicker } = settings || {};
16
16
  const { providers: contextProviders = [] } = iconPicker || {};
17
17
  const providersToLoad = propProviders !== void 0 ? propProviders : contextProviders;
18
18
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.IconPicker, {
@@ -1,4 +1,4 @@
1
- import * as react3 from "react";
1
+ import * as react4 from "react";
2
2
  import { IconPickerProps, IconProviderProps } from "@pixpilot/shadcn-ui";
3
3
 
4
4
  //#region src/components/icon-picker.d.ts
@@ -8,8 +8,8 @@ import { IconPickerProps, IconProviderProps } from "@pixpilot/shadcn-ui";
8
8
  * Automatically connects to Formily field state
9
9
  * Supports both static and async icon providers
10
10
  */
11
- declare const IconPicker$1: react3.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
11
+ declare const IconPicker$1: react4.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
12
12
  providers?: IconProviderProps[];
13
- }> & react3.RefAttributes<unknown>>;
13
+ }> & react4.RefAttributes<unknown>>;
14
14
  //#endregion
15
15
  export { IconPicker$1 as IconPicker };
@@ -7,8 +7,8 @@ import { jsx } from "react/jsx-runtime";
7
7
  //#region src/components/icon-picker.tsx
8
8
  const IconPickerBase = (props) => {
9
9
  const { providers: propProviders,...restProps } = props;
10
- const { config } = useFormContext();
11
- const { iconPicker } = config || {};
10
+ const { settings } = useFormContext();
11
+ const { iconPicker } = settings || {};
12
12
  const { providers: contextProviders = [] } = iconPicker || {};
13
13
  const providersToLoad = propProviders !== void 0 ? propProviders : contextProviders;
14
14
  return /* @__PURE__ */ jsx(IconPicker, {
@@ -1,4 +1,4 @@
1
- import * as react6 from "react";
1
+ import * as react10 from "react";
2
2
 
3
3
  //#region src/components/input.d.ts
4
4
 
@@ -6,6 +6,6 @@ import * as react6 from "react";
6
6
  * Formily-connected Input component
7
7
  * Automatically connects shadcn Input to Formily field state
8
8
  */
9
- declare const Input: react6.ForwardRefExoticComponent<Omit<Partial<react6.ClassAttributes<HTMLInputElement> & react6.InputHTMLAttributes<HTMLInputElement>>, "ref"> & react6.RefAttributes<unknown>>;
9
+ declare const Input: react10.ForwardRefExoticComponent<Omit<Partial<react10.ClassAttributes<HTMLInputElement> & react10.InputHTMLAttributes<HTMLInputElement>>, "ref"> & react10.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { Input };
@@ -1,28 +1,55 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_extract_fields_decorators = require('../utils/extract-fields-decorators.cjs');
2
3
  const require_transform_schema = require('../utils/transform-schema.cjs');
4
+ const require_validate_schema_components = require('../utils/validate-schema-components.cjs');
3
5
  require('../utils/index.cjs');
4
6
  const require_form = require('./form.cjs');
5
- const require_schema_field = require('./schema-field/schema-field.cjs');
7
+ const require_schema_field_basics = require('./schema-field/schema-field-basics.cjs');
6
8
  require('./schema-field/index.cjs');
9
+ let __formily_react = require("@formily/react");
10
+ __formily_react = require_rolldown_runtime.__toESM(__formily_react);
7
11
  let react = require("react");
8
12
  react = require_rolldown_runtime.__toESM(react);
9
13
  let react_jsx_runtime = require("react/jsx-runtime");
10
14
  react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
11
15
  let __formily_core = require("@formily/core");
12
16
  __formily_core = require_rolldown_runtime.__toESM(__formily_core);
17
+ let __pixpilot_env = require("@pixpilot/env");
18
+ __pixpilot_env = require_rolldown_runtime.__toESM(__pixpilot_env);
13
19
 
14
20
  //#region src/components/json-schema-form-renderer.tsx
15
21
  const JsonSchemaFormRenderer = (props) => {
16
- const { schema, children, schemaField,...rest } = props;
17
- const form = (0, react.useMemo)(() => (0, __formily_core.createForm)(), []);
22
+ const { schema, children, settings: configProp, components: componentsProp, values,...rest } = props;
23
+ const form = (0, react.useMemo)(() => (0, __formily_core.createForm)({ values: values || {} }), [values]);
18
24
  const formSchema = (0, react.useMemo)(() => {
19
- return require_transform_schema.transformSchema(schema);
20
- }, [schema]);
21
- const SchemaFieldComponent = schemaField || require_schema_field.SchemaField;
25
+ return require_transform_schema.transformSchema(schema, require_extract_fields_decorators.extractFieldsDecorators(componentsProp?.fields));
26
+ }, [schema, componentsProp]);
27
+ const SchemaField = react.default.useMemo(() => {
28
+ const mergedComponents = { ...require_schema_field_basics.schemaFieldBasicComponents };
29
+ if (componentsProp?.fields) Object.entries(componentsProp.fields).forEach(([key, field]) => {
30
+ mergedComponents[key] = field.component;
31
+ });
32
+ if (componentsProp?.decorators) Object.assign(mergedComponents, componentsProp.decorators);
33
+ if ((0, __pixpilot_env.isDevelopment)()) require_validate_schema_components.validateSchemaComponents(formSchema, mergedComponents);
34
+ return (0, __formily_react.createSchemaField)({
35
+ components: mergedComponents,
36
+ scope: {}
37
+ });
38
+ }, [formSchema, componentsProp]);
39
+ const config = (0, react.useMemo)(() => {
40
+ return {
41
+ ...configProp,
42
+ label: {
43
+ useFieldNameAsLabel: true,
44
+ ...configProp?.label || {}
45
+ }
46
+ };
47
+ }, [configProp]);
22
48
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_form.Form, {
23
49
  ...rest,
24
50
  form,
25
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaFieldComponent, { schema: formSchema }), children]
51
+ settings: config,
52
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaField, { schema: formSchema }), children]
26
53
  });
27
54
  };
28
55
  JsonSchemaFormRenderer.displayName = "JsonSchemaFormRenderer";
@@ -6,9 +6,14 @@ import React from "react";
6
6
  interface JsonSchemaFormRendererProps extends Omit<React.ComponentProps<typeof Form>, 'form'> {
7
7
  schema: ISchema;
8
8
  children?: React.ReactNode;
9
- schemaField?: React.FC<{
10
- schema: ISchema;
11
- }>;
9
+ values?: Record<string, any>;
10
+ components?: {
11
+ fields?: Record<string, {
12
+ component: React.ComponentType<any>;
13
+ decorator?: string;
14
+ }>;
15
+ decorators?: Record<string, React.ComponentType<any>>;
16
+ };
12
17
  }
13
18
  declare const JsonSchemaFormRenderer: React.FC<JsonSchemaFormRendererProps>;
14
19
  //#endregion