@pixpilot/formily-shadcn 0.9.0 → 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.
- package/README.md +75 -0
- package/dist/components/array-base/components/addition.cjs +2 -2
- package/dist/components/array-base/components/addition.d.cts +3 -2
- package/dist/components/array-base/components/addition.d.ts +3 -2
- package/dist/components/array-base/components/addition.js +2 -2
- 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/array-base/types.d.cts +2 -2
- package/dist/components/array-base/types.d.ts +2 -2
- package/dist/components/checkbox.d.cts +2 -2
- package/dist/components/checkbox.d.ts +2 -2
- package/dist/components/context/form-context.d.cts +20 -16
- package/dist/components/context/form-context.d.ts +20 -16
- 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 +4 -10
- package/dist/components/date-picker.d.ts +5 -11
- package/dist/components/file-upload/file-upload-inline.d.cts +8 -8
- package/dist/components/file-upload/file-upload.d.cts +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-items-container.cjs +2 -5
- package/dist/components/form-items-container.js +2 -5
- package/dist/components/form.cjs +3 -5
- package/dist/components/form.d.cts +1 -2
- package/dist/components/form.d.ts +1 -2
- package/dist/components/form.js +3 -5
- package/dist/components/icon-picker.cjs +2 -2
- 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/json-schema-form-renderer.cjs +34 -7
- package/dist/components/json-schema-form-renderer.d.cts +8 -3
- package/dist/components/json-schema-form-renderer.d.ts +8 -3
- package/dist/components/json-schema-form-renderer.js +32 -7
- package/dist/components/number-input.d.cts +2 -2
- package/dist/components/number-input.d.ts +2 -2
- package/dist/components/object-container.cjs +33 -7
- package/dist/components/object-container.js +34 -8
- 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/schema-field/index.d.cts +1 -1
- package/dist/components/schema-field/index.d.ts +1 -1
- package/dist/components/schema-field/index.js +1 -1
- package/dist/components/schema-field/schema-field-basics.cjs +4 -4
- package/dist/components/schema-field/schema-field-basics.d.cts +209 -269
- package/dist/components/schema-field/schema-field-basics.d.ts +209 -269
- package/dist/components/schema-field/schema-field-basics.js +3 -3
- package/dist/components/schema-field/schema-field-extended.d.cts +427 -488
- package/dist/components/schema-field/schema-field-extended.d.ts +427 -488
- package/dist/components/schema-field/schema-field.cjs +1 -1
- package/dist/components/schema-field/schema-field.d.cts +236 -297
- package/dist/components/schema-field/schema-field.d.ts +236 -297
- package/dist/components/schema-field/schema-field.js +2 -2
- package/dist/components/separator.d.cts +2 -2
- 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.cts +2 -2
- package/dist/components/tags-input-inline.d.cts +2 -2
- package/dist/components/textarea.d.cts +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 +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/types/form.d.cts +0 -6
- package/dist/types/form.d.ts +0 -6
- 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/_virtual/rolldown_runtime.js +0 -24
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Combobox as Combobox$1 } from "../combobox.js";
|
|
2
2
|
import { Slider as Slider$1 } from "../slider.js";
|
|
3
3
|
import { TagsInputInLine } from "../tags-input-inline.js";
|
|
4
|
-
import {
|
|
4
|
+
import { schemaFieldBasicComponents } from "./schema-field-basics.js";
|
|
5
5
|
import { createSchemaField } from "@formily/react";
|
|
6
6
|
import { TagsInput } from "@pixpilot/shadcn-ui";
|
|
7
7
|
|
|
8
8
|
//#region src/components/schema-field/schema-field.tsx
|
|
9
9
|
const schemaFieldComponents = {
|
|
10
|
-
...
|
|
10
|
+
...schemaFieldBasicComponents,
|
|
11
11
|
Combobox: Combobox$1,
|
|
12
12
|
TagsInput,
|
|
13
13
|
TagsInputInLine,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react16 from "react";
|
|
2
2
|
import * as _radix_ui_react_separator0 from "@radix-ui/react-separator";
|
|
3
3
|
|
|
4
4
|
//#region src/components/separator.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _radix_ui_react_separator0 from "@radix-ui/react-separator";
|
|
|
6
6
|
* Formily-connected Separator component
|
|
7
7
|
* A visual divider for content sections
|
|
8
8
|
*/
|
|
9
|
-
declare const Separator:
|
|
9
|
+
declare const Separator: react16.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_separator0.SeparatorProps & react16.RefAttributes<HTMLDivElement>>, "ref"> & react16.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Separator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react16 from "react";
|
|
2
2
|
import * as _radix_ui_react_separator0 from "@radix-ui/react-separator";
|
|
3
3
|
|
|
4
4
|
//#region src/components/separator.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _radix_ui_react_separator0 from "@radix-ui/react-separator";
|
|
|
6
6
|
* Formily-connected Separator component
|
|
7
7
|
* A visual divider for content sections
|
|
8
8
|
*/
|
|
9
|
-
declare const Separator:
|
|
9
|
+
declare const Separator: react16.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_separator0.SeparatorProps & react16.RefAttributes<HTMLDivElement>>, "ref"> & react16.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Separator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react14 from "react";
|
|
2
2
|
import { SliderProps } from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/slider.d.ts
|
|
@@ -7,6 +7,6 @@ import { SliderProps } from "@pixpilot/shadcn-ui";
|
|
|
7
7
|
* Formily-connected Slider component
|
|
8
8
|
* Range input for selecting numeric values
|
|
9
9
|
*/
|
|
10
|
-
declare const Slider:
|
|
10
|
+
declare const Slider: react14.ForwardRefExoticComponent<Omit<Partial<SliderProps>, "ref"> & react14.RefAttributes<unknown>>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { Slider };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react14 from "react";
|
|
2
2
|
import { SliderProps } from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/slider.d.ts
|
|
@@ -7,6 +7,6 @@ import { SliderProps } from "@pixpilot/shadcn-ui";
|
|
|
7
7
|
* Formily-connected Slider component
|
|
8
8
|
* Range input for selecting numeric values
|
|
9
9
|
*/
|
|
10
|
-
declare const Slider$1:
|
|
10
|
+
declare const Slider$1: react14.ForwardRefExoticComponent<Omit<Partial<SliderProps>, "ref"> & react14.RefAttributes<unknown>>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { Slider$1 as Slider };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react25 from "react";
|
|
2
2
|
import * as _radix_ui_react_switch0 from "@radix-ui/react-switch";
|
|
3
3
|
|
|
4
4
|
//#region src/components/switch.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _radix_ui_react_switch0 from "@radix-ui/react-switch";
|
|
|
6
6
|
* Formily-connected Switch component
|
|
7
7
|
* Toggle switch for boolean values
|
|
8
8
|
*/
|
|
9
|
-
declare const Switch:
|
|
9
|
+
declare const Switch: react25.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_switch0.SwitchProps & react25.RefAttributes<HTMLButtonElement>>, "ref"> & react25.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Switch };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react19 from "react";
|
|
2
2
|
import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/tags-input-inline.d.ts
|
|
@@ -10,6 +10,6 @@ import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
|
10
10
|
* Based on DiceUI's tags-input for inline tag editing with keyboard navigation
|
|
11
11
|
* and validation support.
|
|
12
12
|
*/
|
|
13
|
-
declare const TagsInputInLine:
|
|
13
|
+
declare const TagsInputInLine: react19.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui0.TagsInputProps> & react19.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { TagsInputInLine };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react21 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/textarea.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Formily-connected Textarea component
|
|
6
6
|
*/
|
|
7
|
-
declare const Textarea:
|
|
7
|
+
declare const Textarea: react21.ForwardRefExoticComponent<Omit<Partial<react21.ClassAttributes<HTMLTextAreaElement> & react21.TextareaHTMLAttributes<HTMLTextAreaElement>>, "ref"> & react21.RefAttributes<unknown>>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { Textarea };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react19 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/textarea.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Formily-connected Textarea component
|
|
6
6
|
*/
|
|
7
|
-
declare const Textarea:
|
|
7
|
+
declare const Textarea: react19.ForwardRefExoticComponent<Omit<Partial<react19.ClassAttributes<HTMLTextAreaElement> & react19.TextareaHTMLAttributes<HTMLTextAreaElement>>, "ref"> & react19.RefAttributes<unknown>>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { Textarea };
|
package/dist/hooks/index.js
CHANGED
|
@@ -8,6 +8,11 @@ react = require_rolldown_runtime.__toESM(react);
|
|
|
8
8
|
function useFormContext() {
|
|
9
9
|
return (0, react.use)(require_form_context.FormContext);
|
|
10
10
|
}
|
|
11
|
+
function useFormConfig() {
|
|
12
|
+
const { settings } = useFormContext();
|
|
13
|
+
return settings || {};
|
|
14
|
+
}
|
|
11
15
|
|
|
12
16
|
//#endregion
|
|
17
|
+
exports.useFormConfig = useFormConfig;
|
|
13
18
|
exports.useFormContext = useFormContext;
|
|
@@ -6,6 +6,10 @@ import { use } from "react";
|
|
|
6
6
|
function useFormContext() {
|
|
7
7
|
return use(FormContext);
|
|
8
8
|
}
|
|
9
|
+
function useFormConfig() {
|
|
10
|
+
const { settings } = useFormContext();
|
|
11
|
+
return settings || {};
|
|
12
|
+
}
|
|
9
13
|
|
|
10
14
|
//#endregion
|
|
11
|
-
export { useFormContext };
|
|
15
|
+
export { useFormConfig, useFormContext };
|
package/dist/hooks/use-label.cjs
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_use_form_context = require('./use-form-context.cjs');
|
|
2
3
|
let __formily_react = require("@formily/react");
|
|
3
4
|
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
4
5
|
let __pixpilot_string = require("@pixpilot/string");
|
|
5
6
|
__pixpilot_string = require_rolldown_runtime.__toESM(__pixpilot_string);
|
|
6
7
|
|
|
7
8
|
//#region src/hooks/use-label.ts
|
|
9
|
+
function shouldHaveLabel(value) {
|
|
10
|
+
if (typeof value === "boolean" && value === false) return false;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
8
13
|
function useLabel(label) {
|
|
9
14
|
const schema = (0, __formily_react.useFieldSchema)();
|
|
10
15
|
const name = schema.name;
|
|
11
16
|
const title = schema.title;
|
|
17
|
+
const { useFieldNameAsLabel } = require_use_form_context.useFormConfig().label || {};
|
|
18
|
+
if (!shouldHaveLabel(label) || !shouldHaveLabel(title)) return null;
|
|
12
19
|
if (label != null) return label;
|
|
13
|
-
if (title != null) return
|
|
14
|
-
if (name != null) return typeof name === "string" ? (0, __pixpilot_string.toCapitalCase)(name) : name;
|
|
20
|
+
if (title != null) return title;
|
|
21
|
+
if (name != null && useFieldNameAsLabel) return typeof name === "string" ? (0, __pixpilot_string.toCapitalCase)(name) : name;
|
|
15
22
|
return null;
|
|
16
23
|
}
|
|
17
24
|
|
package/dist/hooks/use-label.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
+
import { useFormConfig } from "./use-form-context.js";
|
|
1
2
|
import { useFieldSchema } from "@formily/react";
|
|
2
3
|
import { toCapitalCase } from "@pixpilot/string";
|
|
3
4
|
|
|
4
5
|
//#region src/hooks/use-label.ts
|
|
6
|
+
function shouldHaveLabel(value) {
|
|
7
|
+
if (typeof value === "boolean" && value === false) return false;
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
5
10
|
function useLabel(label) {
|
|
6
11
|
const schema = useFieldSchema();
|
|
7
12
|
const name = schema.name;
|
|
8
13
|
const title = schema.title;
|
|
14
|
+
const { useFieldNameAsLabel } = useFormConfig().label || {};
|
|
15
|
+
if (!shouldHaveLabel(label) || !shouldHaveLabel(title)) return null;
|
|
9
16
|
if (label != null) return label;
|
|
10
|
-
if (title != null) return
|
|
11
|
-
if (name != null) return typeof name === "string" ? toCapitalCase(name) : name;
|
|
17
|
+
if (title != null) return title;
|
|
18
|
+
if (name != null && useFieldNameAsLabel) return typeof name === "string" ? toCapitalCase(name) : name;
|
|
12
19
|
return null;
|
|
13
20
|
}
|
|
14
21
|
|
package/dist/index.cjs
CHANGED
|
@@ -82,7 +82,6 @@ exports.Radio = require_radio.Radio;
|
|
|
82
82
|
exports.RichTextEditor = require_rich_text_editor.RichTextEditor;
|
|
83
83
|
exports.Row = require_row.Row;
|
|
84
84
|
exports.SchemaField = require_schema_field.SchemaField;
|
|
85
|
-
exports.SchemaFieldBasicComponents = require_schema_field_basics.SchemaFieldBasicComponents;
|
|
86
85
|
exports.SchemaFieldBasics = require_schema_field_basics.SchemaFieldBasics;
|
|
87
86
|
exports.SchemaFieldExtended = require_schema_field_extended.SchemaFieldExtended;
|
|
88
87
|
exports.Select = require_select.Select;
|
|
@@ -103,5 +102,6 @@ Object.defineProperty(exports, 'createForm', {
|
|
|
103
102
|
return __formily_core.createForm;
|
|
104
103
|
}
|
|
105
104
|
});
|
|
105
|
+
exports.schemaFieldBasicComponents = require_schema_field_basics.schemaFieldBasicComponents;
|
|
106
106
|
exports.schemaFieldComponents = require_schema_field.schemaFieldComponents;
|
|
107
107
|
exports.schemaFieldExtendedComponents = require_schema_field_extended.schemaFieldExtendedComponents;
|
package/dist/index.d.cts
CHANGED
|
@@ -23,7 +23,7 @@ import { ConnectedRadio, Radio } from "./components/radio.cjs";
|
|
|
23
23
|
import { RichTextEditor } from "./components/rich-text-editor.cjs";
|
|
24
24
|
import { Row } from "./components/row.cjs";
|
|
25
25
|
import { SchemaField, schemaFieldComponents } from "./components/schema-field/schema-field.cjs";
|
|
26
|
-
import {
|
|
26
|
+
import { SchemaFieldBasics, schemaFieldBasicComponents } from "./components/schema-field/schema-field-basics.cjs";
|
|
27
27
|
import { SchemaFieldExtended, schemaFieldExtendedComponents } from "./components/schema-field/schema-field-extended.cjs";
|
|
28
28
|
import "./components/schema-field/index.cjs";
|
|
29
29
|
import { Select } from "./components/select.cjs";
|
|
@@ -34,4 +34,4 @@ import { TagsInputInLine } from "./components/tags-input-inline.cjs";
|
|
|
34
34
|
import { Textarea } from "./components/textarea.cjs";
|
|
35
35
|
import { Field, FormConsumer, FormProvider, ISchema, ObjectField, VoidField } from "@formily/react";
|
|
36
36
|
import { Form as IForm, createForm } from "@formily/core";
|
|
37
|
-
export { ArrayBase, type ArrayBaseMixins, ArrayCards, ArrayCollapse, Checkbox, Column, Combobox, ConnectedRadio, DatePicker, Field, FileUpload, FileUploadInline, Form, FormConsumer, FormGrid, FormItem, FormProvider, type IArrayBaseOperationProps, type IArrayBaseProps, type IForm, type ISchema, IconPicker, Input, JsonSchemaFormRenderer, JsonSchemaFormRendererProps, NumberInput, ObjectField, Radio, RichTextEditor, Row, SchemaField,
|
|
37
|
+
export { ArrayBase, type ArrayBaseMixins, ArrayCards, ArrayCollapse, Checkbox, Column, Combobox, ConnectedRadio, DatePicker, Field, FileUpload, FileUploadInline, Form, FormConsumer, FormGrid, FormItem, FormProvider, type IArrayBaseOperationProps, type IArrayBaseProps, type IForm, type ISchema, IconPicker, Input, JsonSchemaFormRenderer, JsonSchemaFormRendererProps, NumberInput, ObjectField, Radio, RichTextEditor, Row, SchemaField, SchemaFieldBasics, SchemaFieldExtended, Select, Separator, Slider, Switch, TagsInputInLine, Textarea, VoidField, createForm, schemaFieldBasicComponents, schemaFieldComponents, schemaFieldExtendedComponents };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { ConnectedRadio, Radio } from "./components/radio.js";
|
|
|
23
23
|
import { RichTextEditor } from "./components/rich-text-editor.js";
|
|
24
24
|
import { Row } from "./components/row.js";
|
|
25
25
|
import { SchemaField, schemaFieldComponents } from "./components/schema-field/schema-field.js";
|
|
26
|
-
import {
|
|
26
|
+
import { SchemaFieldBasics, schemaFieldBasicComponents } from "./components/schema-field/schema-field-basics.js";
|
|
27
27
|
import { SchemaFieldExtended, schemaFieldExtendedComponents } from "./components/schema-field/schema-field-extended.js";
|
|
28
28
|
import "./components/schema-field/index.js";
|
|
29
29
|
import { Select } from "./components/select.js";
|
|
@@ -34,4 +34,4 @@ import { TagsInputInLine } from "./components/tags-input-inline.js";
|
|
|
34
34
|
import { Textarea } from "./components/textarea.js";
|
|
35
35
|
import { Field, FormConsumer, FormProvider, ISchema, ObjectField, VoidField } from "@formily/react";
|
|
36
36
|
import { Form as IForm, createForm } from "@formily/core";
|
|
37
|
-
export { ArrayBase, type ArrayBaseMixins, ArrayCards, ArrayCollapse, Checkbox, Column, Combobox, ConnectedRadio, DatePicker, Field, FileUpload, FileUploadInline, Form, FormConsumer, FormGrid, FormItem, FormProvider, type IArrayBaseOperationProps, type IArrayBaseProps, type IForm, type ISchema, IconPicker, Input, JsonSchemaFormRenderer, JsonSchemaFormRendererProps, NumberInput, ObjectField, Radio, RichTextEditor, Row, SchemaField,
|
|
37
|
+
export { ArrayBase, type ArrayBaseMixins, ArrayCards, ArrayCollapse, Checkbox, Column, Combobox, ConnectedRadio, DatePicker, Field, FileUpload, FileUploadInline, Form, FormConsumer, FormGrid, FormItem, FormProvider, type IArrayBaseOperationProps, type IArrayBaseProps, type IForm, type ISchema, IconPicker, Input, JsonSchemaFormRenderer, JsonSchemaFormRendererProps, NumberInput, ObjectField, Radio, RichTextEditor, Row, SchemaField, SchemaFieldBasics, SchemaFieldExtended, Select, Separator, Slider, Switch, TagsInputInLine, Textarea, VoidField, createForm, schemaFieldBasicComponents, schemaFieldComponents, schemaFieldExtendedComponents };
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import { Select } from "./components/select.js";
|
|
|
25
25
|
import { Separator } from "./components/separator.js";
|
|
26
26
|
import { Switch } from "./components/switch.js";
|
|
27
27
|
import { Textarea } from "./components/textarea.js";
|
|
28
|
-
import {
|
|
28
|
+
import { SchemaFieldBasics, schemaFieldBasicComponents } from "./components/schema-field/schema-field-basics.js";
|
|
29
29
|
import { SchemaField, schemaFieldComponents } from "./components/schema-field/schema-field.js";
|
|
30
30
|
import { RichTextEditor } from "./components/rich-text-editor.js";
|
|
31
31
|
import { SchemaFieldExtended, schemaFieldExtendedComponents } from "./components/schema-field/schema-field-extended.js";
|
|
@@ -34,4 +34,4 @@ import { JsonSchemaFormRenderer } from "./components/json-schema-form-renderer.j
|
|
|
34
34
|
import { Field, FormConsumer, FormProvider, ObjectField, VoidField } from "@formily/react";
|
|
35
35
|
import { createForm } from "@formily/core";
|
|
36
36
|
|
|
37
|
-
export { ArrayBase, ArrayCards, ArrayCollapse, Checkbox, Column, Combobox, ConnectedRadio, DatePicker, Field, FileUpload, FileUploadInline, Form, FormConsumer, FormGrid, FormItem, FormProvider, IconPicker, Input, JsonSchemaFormRenderer, NumberInput, ObjectField, Radio, RichTextEditor, Row, SchemaField,
|
|
37
|
+
export { ArrayBase, ArrayCards, ArrayCollapse, Checkbox, Column, Combobox, ConnectedRadio, DatePicker, Field, FileUpload, FileUploadInline, Form, FormConsumer, FormGrid, FormItem, FormProvider, IconPicker, Input, JsonSchemaFormRenderer, NumberInput, ObjectField, Radio, RichTextEditor, Row, SchemaField, SchemaFieldBasics, SchemaFieldExtended, Select, Separator, Slider, Switch, TagsInputInLine, Textarea, VoidField, createForm, schemaFieldBasicComponents, schemaFieldComponents, schemaFieldExtendedComponents };
|
package/dist/types/form.d.cts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
//#region src/types/form.d.ts
|
|
2
|
-
type Space = 'sm' | 'md' | 'lg';
|
|
3
2
|
interface FormSpace {
|
|
4
3
|
density?: 'compact' | 'normal' | 'comfortable' | 'responsive';
|
|
5
|
-
responsive?: {
|
|
6
|
-
mobile?: Space;
|
|
7
|
-
tablet?: Space;
|
|
8
|
-
desktop?: Space;
|
|
9
|
-
};
|
|
10
4
|
}
|
|
11
5
|
//#endregion
|
|
12
6
|
export { FormSpace };
|
package/dist/types/form.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
//#region src/types/form.d.ts
|
|
2
|
-
type Space = 'sm' | 'md' | 'lg';
|
|
3
2
|
interface FormSpace {
|
|
4
3
|
density?: 'compact' | 'normal' | 'comfortable' | 'responsive';
|
|
5
|
-
responsive?: {
|
|
6
|
-
mobile?: Space;
|
|
7
|
-
tablet?: Space;
|
|
8
|
-
desktop?: Space;
|
|
9
|
-
};
|
|
10
4
|
}
|
|
11
5
|
//#endregion
|
|
12
6
|
export { FormSpace };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utils/extract-fields-decorators.ts
|
|
3
|
+
/**
|
|
4
|
+
* Extracts decorator mappings from field configurations.
|
|
5
|
+
*
|
|
6
|
+
* This utility function takes a fields configuration object where each field
|
|
7
|
+
* can optionally define a decorator string, and returns a flat record of
|
|
8
|
+
* field name to decorator mappings.
|
|
9
|
+
*
|
|
10
|
+
* @param fields - The fields configuration with optional decorators
|
|
11
|
+
* @returns Record mapping component names to their decorators
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const fields = {
|
|
15
|
+
* Input: {
|
|
16
|
+
* component: InputComponent,
|
|
17
|
+
* decorator: 'FormItem',
|
|
18
|
+
* },
|
|
19
|
+
* CustomInput: {
|
|
20
|
+
* component: CustomInputComponent,
|
|
21
|
+
* decorator: 'CustomDecorator',
|
|
22
|
+
* },
|
|
23
|
+
* };
|
|
24
|
+
*
|
|
25
|
+
* const decorators = extractFieldsDecorators(fields);
|
|
26
|
+
* // Result: { Input: 'FormItem', CustomInput: 'CustomDecorator' }
|
|
27
|
+
*/
|
|
28
|
+
function extractFieldsDecorators(fields) {
|
|
29
|
+
const fieldsDecorators = {};
|
|
30
|
+
if (fields) Object.entries(fields).forEach(([key, field]) => {
|
|
31
|
+
if (field.decorator != null) fieldsDecorators[key] = field.decorator;
|
|
32
|
+
});
|
|
33
|
+
return fieldsDecorators;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.extractFieldsDecorators = extractFieldsDecorators;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/utils/extract-fields-decorators.ts
|
|
2
|
+
/**
|
|
3
|
+
* Extracts decorator mappings from field configurations.
|
|
4
|
+
*
|
|
5
|
+
* This utility function takes a fields configuration object where each field
|
|
6
|
+
* can optionally define a decorator string, and returns a flat record of
|
|
7
|
+
* field name to decorator mappings.
|
|
8
|
+
*
|
|
9
|
+
* @param fields - The fields configuration with optional decorators
|
|
10
|
+
* @returns Record mapping component names to their decorators
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const fields = {
|
|
14
|
+
* Input: {
|
|
15
|
+
* component: InputComponent,
|
|
16
|
+
* decorator: 'FormItem',
|
|
17
|
+
* },
|
|
18
|
+
* CustomInput: {
|
|
19
|
+
* component: CustomInputComponent,
|
|
20
|
+
* decorator: 'CustomDecorator',
|
|
21
|
+
* },
|
|
22
|
+
* };
|
|
23
|
+
*
|
|
24
|
+
* const decorators = extractFieldsDecorators(fields);
|
|
25
|
+
* // Result: { Input: 'FormItem', CustomInput: 'CustomDecorator' }
|
|
26
|
+
*/
|
|
27
|
+
function extractFieldsDecorators(fields) {
|
|
28
|
+
const fieldsDecorators = {};
|
|
29
|
+
if (fields) Object.entries(fields).forEach(([key, field]) => {
|
|
30
|
+
if (field.decorator != null) fieldsDecorators[key] = field.decorator;
|
|
31
|
+
});
|
|
32
|
+
return fieldsDecorators;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { extractFieldsDecorators };
|
package/dist/utils/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_has_error = require('./has-error.cjs');
|
|
2
2
|
const require_validate_array_item_fields = require('./validate-array-item-fields.cjs');
|
|
3
3
|
const require_create_panel_state_manager = require('./create-panel-state-manager.cjs');
|
|
4
|
+
const require_extract_fields_decorators = require('./extract-fields-decorators.cjs');
|
|
4
5
|
const require_for_each_schema = require('./for-each-schema.cjs');
|
|
5
6
|
const require_get_array_item_info = require('./get-array-item-info.cjs');
|
|
6
7
|
const require_get_default_value = require('./get-default-value.cjs');
|
|
@@ -8,3 +9,4 @@ const require_has_array_item_errors = require('./has-array-item-errors.cjs');
|
|
|
8
9
|
const require_resolve_responsive_space = require('./resolve-responsive-space.cjs');
|
|
9
10
|
const require_transform_schema = require('./transform-schema.cjs');
|
|
10
11
|
require('./use-array-item-editor.cjs');
|
|
12
|
+
const require_validate_schema_components = require('./validate-schema-components.cjs');
|
package/dist/utils/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { fieldsHasError, filedHasError } from "./has-error.js";
|
|
2
2
|
import { validateArrayItemFields } from "./validate-array-item-fields.js";
|
|
3
3
|
import { createPanelStateManager } from "./create-panel-state-manager.js";
|
|
4
|
+
import { extractFieldsDecorators } from "./extract-fields-decorators.js";
|
|
4
5
|
import { forEachSchema } from "./for-each-schema.js";
|
|
5
6
|
import { getArrayItemInfo } from "./get-array-item-info.js";
|
|
6
7
|
import { getDefaultValue, getSchemaDefaultValue } from "./get-default-value.js";
|
|
7
8
|
import { hasArrayItemErrors } from "./has-array-item-errors.js";
|
|
8
|
-
import {
|
|
9
|
+
import { gapYConfig, resolveResponsiveGapClass, resolveResponsiveSpaceClass, resolveSpacingClass, spaceYConfig } from "./resolve-responsive-space.js";
|
|
9
10
|
import { transformSchema } from "./transform-schema.js";
|
|
10
11
|
import "./use-array-item-editor.js";
|
|
12
|
+
import { validateSchemaComponents } from "./validate-schema-components.js";
|
|
@@ -10,74 +10,44 @@ const densitySpaceMap = {
|
|
|
10
10
|
comfortable: "lg"
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
* Space
|
|
14
|
-
*
|
|
13
|
+
* Space-Y spacing configuration
|
|
14
|
+
* Controls vertical spacing between form items
|
|
15
15
|
*/
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const spaceYConfig = {
|
|
17
|
+
fixed: {
|
|
18
|
+
sm: "space-y-3",
|
|
19
|
+
md: "space-y-4",
|
|
20
|
+
lg: "space-y-6"
|
|
21
|
+
},
|
|
22
|
+
responsive: "space-y-3 md:space-y-4 lg:space-y-6"
|
|
20
23
|
};
|
|
21
24
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
25
|
+
* Gap-Y spacing configuration
|
|
26
|
+
* Controls vertical gaps in containers
|
|
24
27
|
*/
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const gapYConfig = {
|
|
29
|
+
fixed: {
|
|
30
|
+
sm: "gap-y-3",
|
|
31
|
+
md: "gap-y-4",
|
|
32
|
+
lg: "gap-y-6"
|
|
33
|
+
},
|
|
34
|
+
responsive: "gap-y-3 md:gap-y-4 lg:gap-y-6"
|
|
29
35
|
};
|
|
30
36
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* - Tablet (md:): normal (space-y-4)
|
|
34
|
-
* - Desktop (lg:): comfortable (space-y-6)
|
|
35
|
-
*/
|
|
36
|
-
const autoResponsiveSpaceClasses = "space-y-3 md:space-y-4 lg:space-y-6";
|
|
37
|
-
/**
|
|
38
|
-
* Responsive breakpoint classes for responsive density mode using gap
|
|
39
|
-
* - Mobile (default): compact (gap-y-3)
|
|
40
|
-
* - Tablet (md:): normal (gap-y-4)
|
|
41
|
-
* - Desktop (lg:): comfortable (gap-y-6)
|
|
42
|
-
*/
|
|
43
|
-
const autoResponsiveGapClasses = "gap-y-3 md:gap-y-4 lg:gap-y-6";
|
|
44
|
-
/**
|
|
45
|
-
* Checks if density is responsive mode
|
|
46
|
-
*
|
|
47
|
-
* @param density - Density value
|
|
48
|
-
* @returns true if density is 'responsive'
|
|
49
|
-
*/
|
|
50
|
-
function isResponsiveDensity(density) {
|
|
51
|
-
return density === "responsive";
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Resolves responsive space value from FormSpace configuration
|
|
55
|
-
* Priority:
|
|
56
|
-
* 1. If responsive is set → use it (ignore density)
|
|
57
|
-
* 2. If density is 'responsive' → return undefined (handled separately with responsive classes)
|
|
58
|
-
* 3. If only other density is set → use density-based mapping
|
|
59
|
-
* 4. Default to undefined (responsive mode)
|
|
60
|
-
*
|
|
61
|
-
* @param formSpace - FormSpace configuration
|
|
62
|
-
* @returns Space value ('sm' | 'md' | 'lg') or undefined for responsive mode
|
|
63
|
-
*/
|
|
64
|
-
function resolveResponsiveSpace(formSpace) {
|
|
65
|
-
if (!formSpace) return;
|
|
66
|
-
if (formSpace.responsive) return formSpace.responsive.desktop || formSpace.responsive.tablet || formSpace.responsive.mobile || "lg";
|
|
67
|
-
if (isResponsiveDensity(formSpace.density)) return;
|
|
68
|
-
if (formSpace.density && !isResponsiveDensity(formSpace.density)) return densitySpaceMap[formSpace.density];
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Gets the Tailwind class for a given space value
|
|
37
|
+
* Resolves spacing class based on density and spacing configuration
|
|
38
|
+
* Generic utility that works with any spacing config
|
|
72
39
|
*
|
|
73
|
-
* @param
|
|
74
|
-
* @
|
|
40
|
+
* @param density - Density value ('compact' | 'normal' | 'comfortable' | 'responsive')
|
|
41
|
+
* @param config - Spacing configuration with fixed and responsive classes
|
|
42
|
+
* @returns Tailwind utility class(es)
|
|
75
43
|
*/
|
|
76
|
-
function
|
|
77
|
-
return
|
|
44
|
+
function resolveSpacingClass(density, config) {
|
|
45
|
+
if (!density || density === "responsive") return config.responsive;
|
|
46
|
+
const space = densitySpaceMap[density];
|
|
47
|
+
return config.fixed[space];
|
|
78
48
|
}
|
|
79
49
|
/**
|
|
80
|
-
* Resolves responsive space and returns the Tailwind class(es)
|
|
50
|
+
* Resolves responsive space and returns the Tailwind space-y class(es)
|
|
81
51
|
* For responsive density, returns responsive breakpoint classes
|
|
82
52
|
* For fixed density, returns single space class
|
|
83
53
|
*
|
|
@@ -85,25 +55,10 @@ function getSpaceClass(space) {
|
|
|
85
55
|
* @returns Tailwind utility class(es)
|
|
86
56
|
*/
|
|
87
57
|
function resolveResponsiveSpaceClass(formSpace) {
|
|
88
|
-
|
|
89
|
-
if (formSpace.responsive && !isResponsiveDensity(formSpace.density)) {
|
|
90
|
-
const space$1 = resolveResponsiveSpace(formSpace);
|
|
91
|
-
return space$1 ? getSpaceClass(space$1) : autoResponsiveSpaceClasses;
|
|
92
|
-
}
|
|
93
|
-
const space = resolveResponsiveSpace(formSpace);
|
|
94
|
-
return space ? getSpaceClass(space) : autoResponsiveSpaceClasses;
|
|
58
|
+
return resolveSpacingClass(formSpace?.density, spaceYConfig);
|
|
95
59
|
}
|
|
96
60
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @param space - Space value
|
|
100
|
-
* @returns Tailwind utility gap class
|
|
101
|
-
*/
|
|
102
|
-
function getGapClass(space) {
|
|
103
|
-
return gapClassMap[space];
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Resolves responsive space and returns the Tailwind gap class(es)
|
|
61
|
+
* Resolves responsive space and returns the Tailwind gap-y class(es)
|
|
107
62
|
* For responsive density, returns responsive breakpoint classes
|
|
108
63
|
* For fixed density, returns single gap class
|
|
109
64
|
*
|
|
@@ -111,21 +66,22 @@ function getGapClass(space) {
|
|
|
111
66
|
* @returns Tailwind utility gap class(es)
|
|
112
67
|
*/
|
|
113
68
|
function resolveResponsiveGapClass(formSpace) {
|
|
114
|
-
|
|
115
|
-
if (formSpace.responsive && !isResponsiveDensity(formSpace.density)) {
|
|
116
|
-
const space$1 = resolveResponsiveSpace(formSpace);
|
|
117
|
-
return space$1 ? getGapClass(space$1) : autoResponsiveGapClasses;
|
|
118
|
-
}
|
|
119
|
-
const space = resolveResponsiveSpace(formSpace);
|
|
120
|
-
return space ? getGapClass(space) : autoResponsiveGapClasses;
|
|
69
|
+
return resolveSpacingClass(formSpace?.density, gapYConfig);
|
|
121
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Deprecated: Use resolveSpacingClass instead
|
|
73
|
+
* @deprecated
|
|
74
|
+
*/
|
|
75
|
+
const autoResponsiveSpaceClasses = spaceYConfig.responsive;
|
|
76
|
+
/**
|
|
77
|
+
* Deprecated: Use resolveSpacingClass instead
|
|
78
|
+
* @deprecated
|
|
79
|
+
*/
|
|
80
|
+
const autoResponsiveGapClasses = gapYConfig.responsive;
|
|
122
81
|
|
|
123
82
|
//#endregion
|
|
124
|
-
exports.
|
|
125
|
-
exports.autoResponsiveSpaceClasses = autoResponsiveSpaceClasses;
|
|
126
|
-
exports.getGapClass = getGapClass;
|
|
127
|
-
exports.getSpaceClass = getSpaceClass;
|
|
128
|
-
exports.isResponsiveDensity = isResponsiveDensity;
|
|
83
|
+
exports.gapYConfig = gapYConfig;
|
|
129
84
|
exports.resolveResponsiveGapClass = resolveResponsiveGapClass;
|
|
130
|
-
exports.
|
|
131
|
-
exports.
|
|
85
|
+
exports.resolveResponsiveSpaceClass = resolveResponsiveSpaceClass;
|
|
86
|
+
exports.resolveSpacingClass = resolveSpacingClass;
|
|
87
|
+
exports.spaceYConfig = spaceYConfig;
|