@pixpilot/formily-shadcn 0.9.1 → 0.11.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.
- package/README.md +102 -1
- package/dist/components/array-base/components/array-item-label.cjs +1 -1
- package/dist/components/array-base/components/array-item-label.js +1 -1
- package/dist/components/checkbox.d.ts +2 -2
- package/dist/components/column.d.ts +2 -2
- package/dist/components/context/context.d.cts +1 -1
- package/dist/components/context/context.d.ts +1 -1
- package/dist/components/context/form-context.d.cts +52 -19
- package/dist/components/context/form-context.d.ts +52 -19
- package/dist/components/context/index.d.cts +1 -1
- package/dist/components/context/index.d.ts +1 -1
- package/dist/components/date-picker.d.cts +3 -3
- package/dist/components/date-picker.d.ts +3 -3
- package/dist/components/file-upload/file-upload-inline.d.cts +8 -8
- package/dist/components/file-upload/file-upload-inline.d.ts +8 -8
- package/dist/components/file-upload/file-upload.d.cts +8 -8
- package/dist/components/file-upload/file-upload.d.ts +8 -8
- package/dist/components/file-upload/use-file-upload-feedback.cjs +2 -2
- package/dist/components/file-upload/use-file-upload-feedback.js +2 -2
- package/dist/components/form-grid.d.cts +2 -2
- package/dist/components/form-grid.d.ts +2 -2
- package/dist/components/form-item/base-form-item.cjs +85 -0
- package/dist/components/form-item/base-form-item.d.cts +2 -0
- package/dist/components/form-item/base-form-item.d.ts +2 -0
- package/dist/components/form-item/base-form-item.js +80 -0
- package/dist/components/form-item/connected-form-item.cjs +47 -0
- package/dist/components/form-item/connected-form-item.d.cts +13 -0
- package/dist/components/form-item/connected-form-item.d.ts +13 -0
- package/dist/components/form-item/connected-form-item.js +44 -0
- package/dist/components/form-item/form-item-description-popover.cjs +42 -0
- package/dist/components/form-item/form-item-description-popover.js +37 -0
- package/dist/components/form-item/form-item-label.cjs +29 -0
- package/dist/components/form-item/form-item-label.js +25 -0
- package/dist/components/form-item/form-item-types.d.cts +23 -0
- package/dist/components/form-item/form-item-types.d.ts +23 -0
- package/dist/components/form-item/form-item.cjs +2 -0
- package/dist/components/form-item/form-item.d.cts +4 -0
- package/dist/components/form-item/form-item.d.ts +4 -0
- package/dist/components/form-item/form-item.js +2 -0
- package/dist/components/form-item/index.cjs +3 -0
- package/dist/components/form-item/index.d.cts +4 -0
- package/dist/components/form-item/index.d.ts +4 -0
- package/dist/components/form-item/index.js +3 -0
- package/dist/components/form-item/spacing-config.cjs +24 -0
- package/dist/components/form-item/spacing-config.js +23 -0
- package/dist/components/form-items-container.cjs +3 -5
- package/dist/components/form-items-container.js +3 -5
- package/dist/components/form.cjs +5 -14
- package/dist/components/form.d.cts +4 -7
- package/dist/components/form.d.ts +2 -5
- package/dist/components/form.js +5 -14
- package/dist/components/icon-picker.cjs +2 -2
- package/dist/components/icon-picker.d.cts +3 -3
- package/dist/components/icon-picker.d.ts +3 -3
- package/dist/components/icon-picker.js +2 -2
- package/dist/components/input.d.cts +2 -2
- package/dist/components/input.d.ts +2 -2
- package/dist/components/json-schema-form-renderer/index.cjs +4 -0
- package/dist/components/json-schema-form-renderer/index.d.cts +5 -0
- package/dist/components/json-schema-form-renderer/index.d.ts +5 -0
- package/dist/components/json-schema-form-renderer/index.js +4 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-basic.cjs +35 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-basic.d.cts +14 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-basic.d.ts +14 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-basic.js +32 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-extended.cjs +35 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-extended.d.cts +14 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-extended.d.ts +14 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-extended.js +32 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-renderer.cjs +57 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-renderer.d.cts +7 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-renderer.d.ts +7 -0
- package/dist/components/json-schema-form-renderer/json-schema-form-renderer.js +51 -0
- package/dist/components/json-schema-form-renderer/json-schema-form.cjs +36 -0
- package/dist/components/json-schema-form-renderer/json-schema-form.d.cts +14 -0
- package/dist/components/json-schema-form-renderer/json-schema-form.d.ts +14 -0
- package/dist/components/json-schema-form-renderer/json-schema-form.js +33 -0
- package/dist/components/json-schema-form-renderer/types.d.cts +23 -0
- package/dist/components/json-schema-form-renderer/types.d.ts +23 -0
- package/dist/components/number-input.d.cts +2 -2
- package/dist/components/number-input.d.ts +2 -2
- package/dist/components/object-container.cjs +42 -9
- package/dist/components/object-container.js +43 -10
- package/dist/components/radio.d.cts +2 -2
- package/dist/components/radio.d.ts +2 -2
- package/dist/components/rich-text-editor.cjs +1 -1
- package/dist/components/rich-text-editor.js +1 -1
- package/dist/components/row.d.cts +2 -2
- package/dist/components/row.d.ts +2 -2
- package/dist/components/schema-field/index.d.cts +3 -3
- package/dist/components/schema-field/index.d.ts +3 -3
- package/dist/components/schema-field/index.js +3 -3
- package/dist/components/schema-field/schema-field-basics.cjs +67 -24
- package/dist/components/schema-field/schema-field-basics.d.cts +283 -198
- package/dist/components/schema-field/schema-field-basics.d.ts +283 -198
- package/dist/components/schema-field/schema-field-basics.js +65 -23
- package/dist/components/schema-field/schema-field-extended.cjs +23 -8
- package/dist/components/schema-field/schema-field-extended.d.cts +442 -307
- package/dist/components/schema-field/schema-field-extended.d.ts +442 -307
- package/dist/components/schema-field/schema-field-extended.js +23 -9
- package/dist/components/schema-field/schema-field.cjs +23 -8
- package/dist/components/schema-field/schema-field.d.cts +338 -237
- package/dist/components/schema-field/schema-field.d.ts +338 -237
- package/dist/components/schema-field/schema-field.js +23 -9
- package/dist/components/separator.d.ts +2 -2
- package/dist/components/slider.d.cts +2 -2
- package/dist/components/slider.d.ts +2 -2
- package/dist/components/switch.d.ts +2 -2
- package/dist/components/tags-input-inline.d.cts +2 -2
- package/dist/components/tags-input-inline.d.ts +2 -2
- package/dist/components/textarea.d.ts +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/use-form-context.cjs +5 -0
- package/dist/hooks/use-form-context.js +5 -1
- package/dist/hooks/use-label.cjs +9 -2
- package/dist/hooks/use-label.js +9 -2
- package/dist/index.cjs +17 -6
- package/dist/index.d.cts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +11 -6
- package/dist/types/form-item.d.cts +5 -0
- package/dist/types/form-item.d.ts +5 -0
- package/dist/types/form.d.cts +0 -6
- package/dist/types/form.d.ts +0 -6
- package/dist/utils/extract-components.cjs +11 -0
- package/dist/utils/extract-components.js +10 -0
- package/dist/utils/extract-fields-decorators.cjs +37 -0
- package/dist/utils/extract-fields-decorators.js +36 -0
- package/dist/utils/index.cjs +2 -0
- package/dist/utils/index.js +3 -1
- package/dist/utils/resolve-responsive-space.cjs +45 -89
- package/dist/utils/resolve-responsive-space.js +42 -83
- package/dist/utils/transform-schema.cjs +9 -2
- package/dist/utils/transform-schema.js +9 -2
- package/dist/utils/validate-schema-components.cjs +45 -0
- package/dist/utils/validate-schema-components.js +43 -0
- package/package.json +4 -3
- package/dist/components/form-item.cjs +0 -118
- package/dist/components/form-item.d.cts +0 -22
- package/dist/components/form-item.d.ts +0 -22
- package/dist/components/form-item.js +0 -112
- package/dist/components/json-schema-form-renderer.cjs +0 -31
- package/dist/components/json-schema-form-renderer.d.cts +0 -15
- package/dist/components/json-schema-form-renderer.d.ts +0 -15
- package/dist/components/json-schema-form-renderer.js +0 -27
|
@@ -2,7 +2,7 @@ import { FormContextStates } from "./context/form-context.cjs";
|
|
|
2
2
|
import "./context/index.cjs";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { Form } from "@formily/core";
|
|
5
|
-
import * as
|
|
5
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/form.d.ts
|
|
8
8
|
interface IFormProps extends FormContextStates {
|
|
@@ -23,11 +23,8 @@ declare function Form$1({
|
|
|
23
23
|
children,
|
|
24
24
|
onSubmit,
|
|
25
25
|
onAutoSubmit,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
responsive,
|
|
30
|
-
config
|
|
31
|
-
}: IFormProps): react_jsx_runtime0.JSX.Element;
|
|
26
|
+
layout,
|
|
27
|
+
settings
|
|
28
|
+
}: IFormProps): react_jsx_runtime1.JSX.Element;
|
|
32
29
|
//#endregion
|
|
33
30
|
export { Form$1 as Form };
|
|
@@ -23,11 +23,8 @@ declare function Form$1({
|
|
|
23
23
|
children,
|
|
24
24
|
onSubmit,
|
|
25
25
|
onAutoSubmit,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
density,
|
|
29
|
-
responsive,
|
|
30
|
-
config
|
|
26
|
+
layout,
|
|
27
|
+
settings
|
|
31
28
|
}: IFormProps): react_jsx_runtime0.JSX.Element;
|
|
32
29
|
//#endregion
|
|
33
30
|
export { Form$1 as Form };
|
package/dist/components/form.js
CHANGED
|
@@ -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,
|
|
13
|
+
function Form({ form, className, style, children, onSubmit, onAutoSubmit, layout, settings }) {
|
|
14
14
|
const handleSubmit = (e) => {
|
|
15
15
|
e.preventDefault();
|
|
16
16
|
form.submit((values) => {
|
|
@@ -21,24 +21,15 @@ function Form({ form, className, style, children, onSubmit, onAutoSubmit, itemPr
|
|
|
21
21
|
return /* @__PURE__ */ jsx(Provider, {
|
|
22
22
|
value: React.useMemo(() => {
|
|
23
23
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
density,
|
|
27
|
-
responsive,
|
|
28
|
-
config
|
|
24
|
+
layout,
|
|
25
|
+
settings
|
|
29
26
|
};
|
|
30
|
-
}, [
|
|
31
|
-
itemProps,
|
|
32
|
-
objectContainerProps,
|
|
33
|
-
density,
|
|
34
|
-
responsive,
|
|
35
|
-
config
|
|
36
|
-
]),
|
|
27
|
+
}, [layout, settings]),
|
|
37
28
|
children: /* @__PURE__ */ jsx(FormProvider, {
|
|
38
29
|
form,
|
|
39
30
|
children: /* @__PURE__ */ jsx(FormItemContainer, {
|
|
40
31
|
as: "form",
|
|
41
|
-
className: cn(
|
|
32
|
+
className: cn(className),
|
|
42
33
|
style,
|
|
43
34
|
onSubmit: handleSubmit,
|
|
44
35
|
children
|
|
@@ -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 {
|
|
15
|
-
const { iconPicker } =
|
|
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
|
|
1
|
+
import * as react2 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:
|
|
11
|
+
declare const IconPicker: react2.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
|
|
12
12
|
providers?: IconProviderProps[];
|
|
13
|
-
}> &
|
|
13
|
+
}> & react2.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { IconPicker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react8 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:
|
|
11
|
+
declare const IconPicker$1: react8.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
|
|
12
12
|
providers?: IconProviderProps[];
|
|
13
|
-
}> &
|
|
13
|
+
}> & react8.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 {
|
|
11
|
-
const { iconPicker } =
|
|
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
|
|
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:
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react4 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/input.d.ts
|
|
4
4
|
|
|
@@ -6,6 +6,6 @@ import * as react10 from "react";
|
|
|
6
6
|
* Formily-connected Input component
|
|
7
7
|
* Automatically connects shadcn Input to Formily field state
|
|
8
8
|
*/
|
|
9
|
-
declare const Input:
|
|
9
|
+
declare const Input: react4.ForwardRefExoticComponent<Omit<Partial<react4.ClassAttributes<HTMLInputElement> & react4.InputHTMLAttributes<HTMLInputElement>>, "ref"> & react4.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Input };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const require_json_schema_form_renderer = require('./json-schema-form-renderer.cjs');
|
|
2
|
+
const require_json_schema_form = require('./json-schema-form.cjs');
|
|
3
|
+
const require_json_schema_form_basic = require('./json-schema-form-basic.cjs');
|
|
4
|
+
const require_json_schema_form_extended = require('./json-schema-form-extended.cjs');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { JsonSchemaFormComponent, JsonSchemaFormComponents, JsonSchemaFormProps, JsonSchemaFormRendererProps } from "./types.cjs";
|
|
2
|
+
import { JsonSchemaForm } from "./json-schema-form.cjs";
|
|
3
|
+
import { JsonSchemaFormBasic } from "./json-schema-form-basic.cjs";
|
|
4
|
+
import { JsonSchemaFormExtended } from "./json-schema-form-extended.cjs";
|
|
5
|
+
import { JsonSchemaFormRenderer } from "./json-schema-form-renderer.cjs";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { JsonSchemaFormComponent, JsonSchemaFormComponents, JsonSchemaFormProps, JsonSchemaFormRendererProps } from "./types.js";
|
|
2
|
+
import { JsonSchemaForm } from "./json-schema-form.js";
|
|
3
|
+
import { JsonSchemaFormBasic } from "./json-schema-form-basic.js";
|
|
4
|
+
import { JsonSchemaFormExtended } from "./json-schema-form-extended.js";
|
|
5
|
+
import { JsonSchemaFormRenderer } from "./json-schema-form-renderer.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { JsonSchemaFormRenderer } from "./json-schema-form-renderer.js";
|
|
2
|
+
import { JsonSchemaForm } from "./json-schema-form.js";
|
|
3
|
+
import { JsonSchemaFormBasic } from "./json-schema-form-basic.js";
|
|
4
|
+
import { JsonSchemaFormExtended } from "./json-schema-form-extended.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_schema_field_basics = require('../schema-field/schema-field-basics.cjs');
|
|
3
|
+
const require_json_schema_form_renderer = require('./json-schema-form-renderer.cjs');
|
|
4
|
+
let react = require("react");
|
|
5
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
8
|
+
|
|
9
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-basic.tsx
|
|
10
|
+
/**
|
|
11
|
+
* JsonSchemaFormBasic is the basic version that provides only the essential components
|
|
12
|
+
* from the basicComponentRegistry (Input, Checkbox, Select, etc.).
|
|
13
|
+
*
|
|
14
|
+
* User-provided components are merged with basics, with user components taking precedence.
|
|
15
|
+
*/
|
|
16
|
+
const JsonSchemaFormBasic = (props) => {
|
|
17
|
+
const { components,...rest } = props;
|
|
18
|
+
const mergedComponents = react.default.useMemo(() => {
|
|
19
|
+
return {
|
|
20
|
+
fields: {
|
|
21
|
+
...require_schema_field_basics.basicComponentRegistry,
|
|
22
|
+
...components?.fields || {}
|
|
23
|
+
},
|
|
24
|
+
decorators: components?.decorators
|
|
25
|
+
};
|
|
26
|
+
}, [components?.decorators, components?.fields]);
|
|
27
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_json_schema_form_renderer.JsonSchemaFormRenderer, {
|
|
28
|
+
...rest,
|
|
29
|
+
components: mergedComponents
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
JsonSchemaFormBasic.displayName = "JsonSchemaFormBasic";
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.JsonSchemaFormBasic = JsonSchemaFormBasic;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JsonSchemaFormProps } from "./types.cjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-basic.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* JsonSchemaFormBasic is the basic version that provides only the essential components
|
|
8
|
+
* from the basicComponentRegistry (Input, Checkbox, Select, etc.).
|
|
9
|
+
*
|
|
10
|
+
* User-provided components are merged with basics, with user components taking precedence.
|
|
11
|
+
*/
|
|
12
|
+
declare const JsonSchemaFormBasic: React.FC<JsonSchemaFormProps>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JsonSchemaFormBasic };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JsonSchemaFormProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-basic.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* JsonSchemaFormBasic is the basic version that provides only the essential components
|
|
8
|
+
* from the basicComponentRegistry (Input, Checkbox, Select, etc.).
|
|
9
|
+
*
|
|
10
|
+
* User-provided components are merged with basics, with user components taking precedence.
|
|
11
|
+
*/
|
|
12
|
+
declare const JsonSchemaFormBasic: React.FC<JsonSchemaFormProps>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JsonSchemaFormBasic };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { basicComponentRegistry } from "../schema-field/schema-field-basics.js";
|
|
2
|
+
import { JsonSchemaFormRenderer } from "./json-schema-form-renderer.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-basic.tsx
|
|
7
|
+
/**
|
|
8
|
+
* JsonSchemaFormBasic is the basic version that provides only the essential components
|
|
9
|
+
* from the basicComponentRegistry (Input, Checkbox, Select, etc.).
|
|
10
|
+
*
|
|
11
|
+
* User-provided components are merged with basics, with user components taking precedence.
|
|
12
|
+
*/
|
|
13
|
+
const JsonSchemaFormBasic = (props) => {
|
|
14
|
+
const { components,...rest } = props;
|
|
15
|
+
const mergedComponents = React.useMemo(() => {
|
|
16
|
+
return {
|
|
17
|
+
fields: {
|
|
18
|
+
...basicComponentRegistry,
|
|
19
|
+
...components?.fields || {}
|
|
20
|
+
},
|
|
21
|
+
decorators: components?.decorators
|
|
22
|
+
};
|
|
23
|
+
}, [components?.decorators, components?.fields]);
|
|
24
|
+
return /* @__PURE__ */ jsx(JsonSchemaFormRenderer, {
|
|
25
|
+
...rest,
|
|
26
|
+
components: mergedComponents
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
JsonSchemaFormBasic.displayName = "JsonSchemaFormBasic";
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { JsonSchemaFormBasic };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_schema_field_extended = require('../schema-field/schema-field-extended.cjs');
|
|
3
|
+
const require_json_schema_form_renderer = require('./json-schema-form-renderer.cjs');
|
|
4
|
+
let react = require("react");
|
|
5
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
8
|
+
|
|
9
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-extended.tsx
|
|
10
|
+
/**
|
|
11
|
+
* JsonSchemaFormExtended is the extended version that provides all components
|
|
12
|
+
* from the extendedComponentRegistry (including FileUpload, RichTextEditor, etc.).
|
|
13
|
+
*
|
|
14
|
+
* User-provided components are merged with extended defaults, with user components taking precedence.
|
|
15
|
+
*/
|
|
16
|
+
const JsonSchemaFormExtended = (props) => {
|
|
17
|
+
const { components,...rest } = props;
|
|
18
|
+
const mergedComponents = react.default.useMemo(() => {
|
|
19
|
+
return {
|
|
20
|
+
fields: {
|
|
21
|
+
...require_schema_field_extended.extendedComponentRegistry,
|
|
22
|
+
...components?.fields || {}
|
|
23
|
+
},
|
|
24
|
+
decorators: components?.decorators
|
|
25
|
+
};
|
|
26
|
+
}, [components?.decorators, components?.fields]);
|
|
27
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_json_schema_form_renderer.JsonSchemaFormRenderer, {
|
|
28
|
+
...rest,
|
|
29
|
+
components: mergedComponents
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
JsonSchemaFormExtended.displayName = "JsonSchemaFormExtended";
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.JsonSchemaFormExtended = JsonSchemaFormExtended;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JsonSchemaFormProps } from "./types.cjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-extended.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* JsonSchemaFormExtended is the extended version that provides all components
|
|
8
|
+
* from the extendedComponentRegistry (including FileUpload, RichTextEditor, etc.).
|
|
9
|
+
*
|
|
10
|
+
* User-provided components are merged with extended defaults, with user components taking precedence.
|
|
11
|
+
*/
|
|
12
|
+
declare const JsonSchemaFormExtended: React.FC<JsonSchemaFormProps>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JsonSchemaFormExtended };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JsonSchemaFormProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-extended.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* JsonSchemaFormExtended is the extended version that provides all components
|
|
8
|
+
* from the extendedComponentRegistry (including FileUpload, RichTextEditor, etc.).
|
|
9
|
+
*
|
|
10
|
+
* User-provided components are merged with extended defaults, with user components taking precedence.
|
|
11
|
+
*/
|
|
12
|
+
declare const JsonSchemaFormExtended: React.FC<JsonSchemaFormProps>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JsonSchemaFormExtended };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { extendedComponentRegistry } from "../schema-field/schema-field-extended.js";
|
|
2
|
+
import { JsonSchemaFormRenderer } from "./json-schema-form-renderer.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-extended.tsx
|
|
7
|
+
/**
|
|
8
|
+
* JsonSchemaFormExtended is the extended version that provides all components
|
|
9
|
+
* from the extendedComponentRegistry (including FileUpload, RichTextEditor, etc.).
|
|
10
|
+
*
|
|
11
|
+
* User-provided components are merged with extended defaults, with user components taking precedence.
|
|
12
|
+
*/
|
|
13
|
+
const JsonSchemaFormExtended = (props) => {
|
|
14
|
+
const { components,...rest } = props;
|
|
15
|
+
const mergedComponents = React.useMemo(() => {
|
|
16
|
+
return {
|
|
17
|
+
fields: {
|
|
18
|
+
...extendedComponentRegistry,
|
|
19
|
+
...components?.fields || {}
|
|
20
|
+
},
|
|
21
|
+
decorators: components?.decorators
|
|
22
|
+
};
|
|
23
|
+
}, [components?.decorators, components?.fields]);
|
|
24
|
+
return /* @__PURE__ */ jsx(JsonSchemaFormRenderer, {
|
|
25
|
+
...rest,
|
|
26
|
+
components: mergedComponents
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
JsonSchemaFormExtended.displayName = "JsonSchemaFormExtended";
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { JsonSchemaFormExtended };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_extract_fields_decorators = require('../../utils/extract-fields-decorators.cjs');
|
|
3
|
+
const require_transform_schema = require('../../utils/transform-schema.cjs');
|
|
4
|
+
const require_validate_schema_components = require('../../utils/validate-schema-components.cjs');
|
|
5
|
+
require('../../utils/index.cjs');
|
|
6
|
+
const require_form = require('../form.cjs');
|
|
7
|
+
const require_extract_components = require('../../utils/extract-components.cjs');
|
|
8
|
+
let __formily_react = require("@formily/react");
|
|
9
|
+
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
10
|
+
let react = require("react");
|
|
11
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
12
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
14
|
+
let __formily_core = require("@formily/core");
|
|
15
|
+
__formily_core = require_rolldown_runtime.__toESM(__formily_core);
|
|
16
|
+
let __pixpilot_env = require("@pixpilot/env");
|
|
17
|
+
__pixpilot_env = require_rolldown_runtime.__toESM(__pixpilot_env);
|
|
18
|
+
|
|
19
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-renderer.tsx
|
|
20
|
+
const JsonSchemaFormRenderer = (props) => {
|
|
21
|
+
const { schema, children, settings: configProp, components: componentsProp, values,...rest } = props;
|
|
22
|
+
const form = (0, react.useMemo)(() => (0, __formily_core.createForm)({ values: values || {} }), [values]);
|
|
23
|
+
const formSchema = (0, react.useMemo)(() => {
|
|
24
|
+
return require_transform_schema.transformSchema(schema, require_extract_fields_decorators.extractFieldsDecorators(componentsProp?.fields));
|
|
25
|
+
}, [schema, componentsProp]);
|
|
26
|
+
const SchemaField = react.default.useMemo(() => {
|
|
27
|
+
const componentConfigs = { ...componentsProp?.fields };
|
|
28
|
+
if (componentsProp?.decorators) Object.entries(componentsProp.decorators).forEach(([key, decorator]) => {
|
|
29
|
+
componentConfigs[key] = { component: decorator };
|
|
30
|
+
});
|
|
31
|
+
const components = require_extract_components.extractComponents(componentConfigs);
|
|
32
|
+
if ((0, __pixpilot_env.isDevelopment)()) require_validate_schema_components.validateSchemaComponents(formSchema, components);
|
|
33
|
+
return (0, __formily_react.createSchemaField)({
|
|
34
|
+
components,
|
|
35
|
+
scope: {}
|
|
36
|
+
});
|
|
37
|
+
}, [formSchema, componentsProp]);
|
|
38
|
+
const config = (0, react.useMemo)(() => {
|
|
39
|
+
return {
|
|
40
|
+
...configProp,
|
|
41
|
+
label: {
|
|
42
|
+
useFieldNameAsLabel: true,
|
|
43
|
+
...configProp?.label || {}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, [configProp]);
|
|
47
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_form.Form, {
|
|
48
|
+
...rest,
|
|
49
|
+
form,
|
|
50
|
+
settings: config,
|
|
51
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaField, { schema: formSchema }), children]
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
JsonSchemaFormRenderer.displayName = "JsonSchemaFormRenderer";
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
exports.JsonSchemaFormRenderer = JsonSchemaFormRenderer;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JsonSchemaFormRendererProps } from "./types.cjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-renderer.d.ts
|
|
5
|
+
declare const JsonSchemaFormRenderer: React.FC<JsonSchemaFormRendererProps>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { JsonSchemaFormRenderer };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JsonSchemaFormRendererProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-renderer.d.ts
|
|
5
|
+
declare const JsonSchemaFormRenderer: React.FC<JsonSchemaFormRendererProps>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { JsonSchemaFormRenderer };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { extractFieldsDecorators } from "../../utils/extract-fields-decorators.js";
|
|
2
|
+
import { transformSchema } from "../../utils/transform-schema.js";
|
|
3
|
+
import { validateSchemaComponents } from "../../utils/validate-schema-components.js";
|
|
4
|
+
import "../../utils/index.js";
|
|
5
|
+
import { Form as Form$1 } from "../form.js";
|
|
6
|
+
import { extractComponents } from "../../utils/extract-components.js";
|
|
7
|
+
import { createSchemaField } from "@formily/react";
|
|
8
|
+
import React, { useMemo } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { createForm } from "@formily/core";
|
|
11
|
+
import { isDevelopment } from "@pixpilot/env";
|
|
12
|
+
|
|
13
|
+
//#region src/components/json-schema-form-renderer/json-schema-form-renderer.tsx
|
|
14
|
+
const JsonSchemaFormRenderer = (props) => {
|
|
15
|
+
const { schema, children, settings: configProp, components: componentsProp, values,...rest } = props;
|
|
16
|
+
const form = useMemo(() => createForm({ values: values || {} }), [values]);
|
|
17
|
+
const formSchema = useMemo(() => {
|
|
18
|
+
return transformSchema(schema, extractFieldsDecorators(componentsProp?.fields));
|
|
19
|
+
}, [schema, componentsProp]);
|
|
20
|
+
const SchemaField = React.useMemo(() => {
|
|
21
|
+
const componentConfigs = { ...componentsProp?.fields };
|
|
22
|
+
if (componentsProp?.decorators) Object.entries(componentsProp.decorators).forEach(([key, decorator]) => {
|
|
23
|
+
componentConfigs[key] = { component: decorator };
|
|
24
|
+
});
|
|
25
|
+
const components = extractComponents(componentConfigs);
|
|
26
|
+
if (isDevelopment()) validateSchemaComponents(formSchema, components);
|
|
27
|
+
return createSchemaField({
|
|
28
|
+
components,
|
|
29
|
+
scope: {}
|
|
30
|
+
});
|
|
31
|
+
}, [formSchema, componentsProp]);
|
|
32
|
+
const config = useMemo(() => {
|
|
33
|
+
return {
|
|
34
|
+
...configProp,
|
|
35
|
+
label: {
|
|
36
|
+
useFieldNameAsLabel: true,
|
|
37
|
+
...configProp?.label || {}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}, [configProp]);
|
|
41
|
+
return /* @__PURE__ */ jsxs(Form$1, {
|
|
42
|
+
...rest,
|
|
43
|
+
form,
|
|
44
|
+
settings: config,
|
|
45
|
+
children: [/* @__PURE__ */ jsx(SchemaField, { schema: formSchema }), children]
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
JsonSchemaFormRenderer.displayName = "JsonSchemaFormRenderer";
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { JsonSchemaFormRenderer };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_schema_field = require('../schema-field/schema-field.cjs');
|
|
3
|
+
require('../schema-field/index.cjs');
|
|
4
|
+
const require_json_schema_form_renderer = require('./json-schema-form-renderer.cjs');
|
|
5
|
+
let react = require("react");
|
|
6
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
9
|
+
|
|
10
|
+
//#region src/components/json-schema-form-renderer/json-schema-form.tsx
|
|
11
|
+
/**
|
|
12
|
+
* JsonSchemaForm is the "batteries-included" version that automatically provides
|
|
13
|
+
* all default components (Slider, Combobox, TagsInput, etc.) from the defaultComponentRegistry.
|
|
14
|
+
*
|
|
15
|
+
* User-provided components are merged with defaults, with user components taking precedence.
|
|
16
|
+
*/
|
|
17
|
+
const JsonSchemaForm = (props) => {
|
|
18
|
+
const { components,...rest } = props;
|
|
19
|
+
const mergedComponents = react.default.useMemo(() => {
|
|
20
|
+
return {
|
|
21
|
+
fields: {
|
|
22
|
+
...require_schema_field.defaultComponentRegistry,
|
|
23
|
+
...components?.fields || {}
|
|
24
|
+
},
|
|
25
|
+
decorators: components?.decorators
|
|
26
|
+
};
|
|
27
|
+
}, [components?.decorators, components?.fields]);
|
|
28
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_json_schema_form_renderer.JsonSchemaFormRenderer, {
|
|
29
|
+
...rest,
|
|
30
|
+
components: mergedComponents
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
JsonSchemaForm.displayName = "JsonSchemaForm";
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.JsonSchemaForm = JsonSchemaForm;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JsonSchemaFormProps } from "./types.cjs";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/json-schema-form-renderer/json-schema-form.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* JsonSchemaForm is the "batteries-included" version that automatically provides
|
|
8
|
+
* all default components (Slider, Combobox, TagsInput, etc.) from the defaultComponentRegistry.
|
|
9
|
+
*
|
|
10
|
+
* User-provided components are merged with defaults, with user components taking precedence.
|
|
11
|
+
*/
|
|
12
|
+
declare const JsonSchemaForm: React.FC<JsonSchemaFormProps>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JsonSchemaForm };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JsonSchemaFormProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/json-schema-form-renderer/json-schema-form.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* JsonSchemaForm is the "batteries-included" version that automatically provides
|
|
8
|
+
* all default components (Slider, Combobox, TagsInput, etc.) from the defaultComponentRegistry.
|
|
9
|
+
*
|
|
10
|
+
* User-provided components are merged with defaults, with user components taking precedence.
|
|
11
|
+
*/
|
|
12
|
+
declare const JsonSchemaForm: React.FC<JsonSchemaFormProps>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { JsonSchemaForm };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defaultComponentRegistry } from "../schema-field/schema-field.js";
|
|
2
|
+
import "../schema-field/index.js";
|
|
3
|
+
import { JsonSchemaFormRenderer } from "./json-schema-form-renderer.js";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/components/json-schema-form-renderer/json-schema-form.tsx
|
|
8
|
+
/**
|
|
9
|
+
* JsonSchemaForm is the "batteries-included" version that automatically provides
|
|
10
|
+
* all default components (Slider, Combobox, TagsInput, etc.) from the defaultComponentRegistry.
|
|
11
|
+
*
|
|
12
|
+
* User-provided components are merged with defaults, with user components taking precedence.
|
|
13
|
+
*/
|
|
14
|
+
const JsonSchemaForm = (props) => {
|
|
15
|
+
const { components,...rest } = props;
|
|
16
|
+
const mergedComponents = React.useMemo(() => {
|
|
17
|
+
return {
|
|
18
|
+
fields: {
|
|
19
|
+
...defaultComponentRegistry,
|
|
20
|
+
...components?.fields || {}
|
|
21
|
+
},
|
|
22
|
+
decorators: components?.decorators
|
|
23
|
+
};
|
|
24
|
+
}, [components?.decorators, components?.fields]);
|
|
25
|
+
return /* @__PURE__ */ jsx(JsonSchemaFormRenderer, {
|
|
26
|
+
...rest,
|
|
27
|
+
components: mergedComponents
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
JsonSchemaForm.displayName = "JsonSchemaForm";
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { JsonSchemaForm };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Form } from "../form.cjs";
|
|
2
|
+
import { ISchema } from "@formily/react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/json-schema-form-renderer/types.d.ts
|
|
5
|
+
interface JsonSchemaFormComponent {
|
|
6
|
+
component: React.ComponentType<any>;
|
|
7
|
+
decorator?: string;
|
|
8
|
+
}
|
|
9
|
+
interface JsonSchemaFormComponents {
|
|
10
|
+
fields?: Record<string, JsonSchemaFormComponent>;
|
|
11
|
+
decorators?: Record<string, React.ComponentType<any>>;
|
|
12
|
+
}
|
|
13
|
+
interface JsonSchemaFormRendererProps extends Omit<React.ComponentProps<typeof Form>, 'form'> {
|
|
14
|
+
schema: ISchema;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
values?: Record<string, any>;
|
|
17
|
+
components: Partial<JsonSchemaFormComponents>;
|
|
18
|
+
}
|
|
19
|
+
interface JsonSchemaFormProps extends Omit<JsonSchemaFormRendererProps, 'components'> {
|
|
20
|
+
components?: JsonSchemaFormComponents;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { JsonSchemaFormComponent, JsonSchemaFormComponents, JsonSchemaFormProps, JsonSchemaFormRendererProps };
|