@pixpilot/formily-shadcn 1.4.5 → 1.5.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/dist/components/IconPicker.d.ts +3 -3
- package/dist/components/IconToggle.d.ts +2 -2
- package/dist/components/Separator.d.cts +2 -2
- package/dist/components/Switch.d.cts +2 -2
- package/dist/components/TagsInputInline.d.cts +3 -3
- package/dist/components/Textarea.d.cts +2 -2
- package/dist/components/ToggleButton.d.cts +3 -3
- package/dist/components/array-common/ArrayItemDraftFields.cjs +37 -25
- package/dist/components/array-common/ArrayItemDraftFields.js +37 -25
- package/dist/components/array-common/ArrayItemsList.cjs +3 -2
- package/dist/components/array-common/ArrayItemsList.js +3 -2
- package/dist/components/array-common/ItemWrapper.cjs +1 -0
- package/dist/components/array-common/ItemWrapper.js +1 -0
- package/dist/components/array-common/ListItem.cjs +21 -4
- package/dist/components/array-common/ListItem.js +23 -6
- package/dist/components/array-common/use-array-item-draft-form.cjs +31 -15
- package/dist/components/array-common/use-array-item-draft-form.js +31 -15
- package/dist/components/array-common/use-array-item-edit-state.cjs +5 -14
- package/dist/components/array-common/use-array-item-edit-state.js +5 -13
- package/dist/components/array-dialog/EditDialog.cjs +56 -6
- package/dist/components/array-dialog/EditDialog.js +56 -6
- package/dist/components/array-popover/ArrayPopover.cjs +29 -16
- package/dist/components/array-popover/ArrayPopover.js +30 -17
- package/dist/components/array-popover/Popover.cjs +88 -88
- package/dist/components/array-popover/Popover.js +88 -88
- package/dist/components/schema-field/schema-field-basics.d.ts +303 -303
- package/dist/components/schema-field/schema-field-extended.d.cts +632 -632
- package/dist/components/schema-field/schema-field-extended.d.ts +633 -633
- package/dist/components/schema-field/schema-field.d.cts +412 -412
- package/dist/components/schema-field/schema-field.d.ts +412 -412
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react7 from "react";
|
|
2
2
|
import { IconPickerProps, IconProviderProps } from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/IconPicker.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: react7.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
|
|
12
12
|
providers?: IconProviderProps[];
|
|
13
|
-
}> &
|
|
13
|
+
}> & react7.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { IconPicker$1 as IconPicker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react4 from "react";
|
|
2
2
|
import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/IconToggle.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
|
6
6
|
* Formily-connected IconToggle component
|
|
7
7
|
* Toggle button with customizable icons for boolean values
|
|
8
8
|
*/
|
|
9
|
-
declare const IconToggle$1:
|
|
9
|
+
declare const IconToggle$1: react4.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui0.IconToggleProps, "ref"> & react4.RefAttributes<HTMLButtonElement>>, "ref"> & react4.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { IconToggle$1 as IconToggle };
|
|
@@ -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 react19 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: react19.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_switch0.SwitchProps & react19.RefAttributes<HTMLButtonElement>>, "ref"> & react19.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Switch };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react26 from "react";
|
|
2
|
+
import * as _pixpilot_shadcn_ui1 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/TagsInputInline.d.ts
|
|
5
5
|
|
|
@@ -10,6 +10,6 @@ import * as _pixpilot_shadcn_ui2 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: react26.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui1.TagsInputProps> & react26.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { TagsInputInLine };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react22 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: react22.ForwardRefExoticComponent<Omit<Partial<react22.ClassAttributes<HTMLTextAreaElement> & react22.TextareaHTMLAttributes<HTMLTextAreaElement>>, "ref"> & react22.RefAttributes<unknown>>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { Textarea };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react28 from "react";
|
|
2
|
+
import * as _pixpilot_shadcn_ui2 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ToggleButton.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Formily-connected IconToggle component
|
|
7
7
|
* Toggle button with customizable icons for boolean values
|
|
8
8
|
*/
|
|
9
|
-
declare const ToggleButton:
|
|
9
|
+
declare const ToggleButton: react28.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui2.ToggleButtonProps, "ref"> & react28.RefAttributes<HTMLButtonElement>>, "ref"> & react28.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { ToggleButton };
|
|
@@ -19,32 +19,29 @@ function mergeClassName(a, b) {
|
|
|
19
19
|
if (!hasA && hasB) return bb;
|
|
20
20
|
return `${aa} ${bb}`;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Renders item fields inside their own FormProvider.
|
|
24
|
+
* SchemaField contexts (component registry, options, …) are captured from
|
|
25
|
+
* the outer tree and re-provided inside the new form context so that string
|
|
26
|
+
* component names like "Input" still resolve correctly.
|
|
27
|
+
*/
|
|
28
|
+
function IsolatedDraftFields({ schema, form, basePath }) {
|
|
23
29
|
const schemaComponents = react.default.use(__formily_react.SchemaComponentsContext);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
value: schemaExpressionScope,
|
|
40
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaMarkupContext, {
|
|
41
|
-
value: schemaMarkup,
|
|
42
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaContext, {
|
|
43
|
-
value: schemaContext,
|
|
44
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.RecursionField, {
|
|
45
|
-
schema,
|
|
46
|
-
name: basePath
|
|
47
|
-
})
|
|
30
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.FormProvider, {
|
|
31
|
+
form,
|
|
32
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaOptionsContext, {
|
|
33
|
+
value: react.default.use(__formily_react.SchemaOptionsContext),
|
|
34
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaComponentsContext, {
|
|
35
|
+
value: schemaComponents,
|
|
36
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaExpressionScopeContext, {
|
|
37
|
+
value: react.default.use(__formily_react.SchemaExpressionScopeContext),
|
|
38
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaMarkupContext, {
|
|
39
|
+
value: react.default.use(__formily_react.SchemaMarkupContext),
|
|
40
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaContext, {
|
|
41
|
+
value: react.default.use(__formily_react.SchemaContext),
|
|
42
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.RecursionField, {
|
|
43
|
+
schema,
|
|
44
|
+
name: basePath
|
|
48
45
|
})
|
|
49
46
|
})
|
|
50
47
|
})
|
|
@@ -53,6 +50,21 @@ function ArrayItemDraftFields({ schema, form, basePath = "draft", as: Component
|
|
|
53
50
|
})
|
|
54
51
|
});
|
|
55
52
|
}
|
|
53
|
+
function ArrayItemDraftFields({ schema, form, basePath = "draft", as: Component = "div", className, isolated = true }) {
|
|
54
|
+
const { className: itemWrapperClassName,...itemWrapperRestProps } = require_get_x_component_props.getXComponentProps(schema);
|
|
55
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
56
|
+
...itemWrapperRestProps,
|
|
57
|
+
className: mergeClassName(className, itemWrapperClassName),
|
|
58
|
+
children: isolated ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IsolatedDraftFields, {
|
|
59
|
+
schema,
|
|
60
|
+
form,
|
|
61
|
+
basePath
|
|
62
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.RecursionField, {
|
|
63
|
+
schema,
|
|
64
|
+
name: basePath
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
}
|
|
56
68
|
|
|
57
69
|
//#endregion
|
|
58
70
|
exports.ArrayItemDraftFields = ArrayItemDraftFields;
|
|
@@ -15,32 +15,29 @@ function mergeClassName(a, b) {
|
|
|
15
15
|
if (!hasA && hasB) return bb;
|
|
16
16
|
return `${aa} ${bb}`;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Renders item fields inside their own FormProvider.
|
|
20
|
+
* SchemaField contexts (component registry, options, …) are captured from
|
|
21
|
+
* the outer tree and re-provided inside the new form context so that string
|
|
22
|
+
* component names like "Input" still resolve correctly.
|
|
23
|
+
*/
|
|
24
|
+
function IsolatedDraftFields({ schema, form, basePath }) {
|
|
19
25
|
const schemaComponents = React.use(SchemaComponentsContext);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
value: schemaExpressionScope,
|
|
36
|
-
children: /* @__PURE__ */ jsx(SchemaMarkupContext, {
|
|
37
|
-
value: schemaMarkup,
|
|
38
|
-
children: /* @__PURE__ */ jsx(SchemaContext, {
|
|
39
|
-
value: schemaContext,
|
|
40
|
-
children: /* @__PURE__ */ jsx(RecursionField, {
|
|
41
|
-
schema,
|
|
42
|
-
name: basePath
|
|
43
|
-
})
|
|
26
|
+
return /* @__PURE__ */ jsx(FormProvider, {
|
|
27
|
+
form,
|
|
28
|
+
children: /* @__PURE__ */ jsx(SchemaOptionsContext, {
|
|
29
|
+
value: React.use(SchemaOptionsContext),
|
|
30
|
+
children: /* @__PURE__ */ jsx(SchemaComponentsContext, {
|
|
31
|
+
value: schemaComponents,
|
|
32
|
+
children: /* @__PURE__ */ jsx(SchemaExpressionScopeContext, {
|
|
33
|
+
value: React.use(SchemaExpressionScopeContext),
|
|
34
|
+
children: /* @__PURE__ */ jsx(SchemaMarkupContext, {
|
|
35
|
+
value: React.use(SchemaMarkupContext),
|
|
36
|
+
children: /* @__PURE__ */ jsx(SchemaContext, {
|
|
37
|
+
value: React.use(SchemaContext),
|
|
38
|
+
children: /* @__PURE__ */ jsx(RecursionField, {
|
|
39
|
+
schema,
|
|
40
|
+
name: basePath
|
|
44
41
|
})
|
|
45
42
|
})
|
|
46
43
|
})
|
|
@@ -49,6 +46,21 @@ function ArrayItemDraftFields({ schema, form, basePath = "draft", as: Component
|
|
|
49
46
|
})
|
|
50
47
|
});
|
|
51
48
|
}
|
|
49
|
+
function ArrayItemDraftFields({ schema, form, basePath = "draft", as: Component = "div", className, isolated = true }) {
|
|
50
|
+
const { className: itemWrapperClassName,...itemWrapperRestProps } = getXComponentProps(schema);
|
|
51
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
52
|
+
...itemWrapperRestProps,
|
|
53
|
+
className: mergeClassName(className, itemWrapperClassName),
|
|
54
|
+
children: isolated ? /* @__PURE__ */ jsx(IsolatedDraftFields, {
|
|
55
|
+
schema,
|
|
56
|
+
form,
|
|
57
|
+
basePath
|
|
58
|
+
}) : /* @__PURE__ */ jsx(RecursionField, {
|
|
59
|
+
schema,
|
|
60
|
+
name: basePath
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
}
|
|
52
64
|
|
|
53
65
|
//#endregion
|
|
54
66
|
export { ArrayItemDraftFields };
|
|
@@ -21,7 +21,7 @@ __pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
|
21
21
|
* Shared component for rendering array items list
|
|
22
22
|
* Displays items with move up/down, edit, and remove controls
|
|
23
23
|
*/
|
|
24
|
-
const ArrayItemsList = (0, __formily_react.observer)(({ isNewItem, children, className, containerProps }) => {
|
|
24
|
+
const ArrayItemsList = (0, __formily_react.observer)(({ isNewItem, activeIndex, children, className, containerProps }) => {
|
|
25
25
|
const field = (0, __formily_react.useField)();
|
|
26
26
|
const schema = (0, __formily_react.useFieldSchema)();
|
|
27
27
|
const dataSource = require_use_array_data_source.useArrayDataSource();
|
|
@@ -39,7 +39,8 @@ const ArrayItemsList = (0, __formily_react.observer)(({ isNewItem, children, cla
|
|
|
39
39
|
itemKey,
|
|
40
40
|
index,
|
|
41
41
|
record,
|
|
42
|
-
isNew
|
|
42
|
+
isNew,
|
|
43
|
+
isAnchor: activeIndex === index && !isNew
|
|
43
44
|
}, itemKey);
|
|
44
45
|
}) }), children]
|
|
45
46
|
});
|
|
@@ -16,7 +16,7 @@ import { cn } from "@pixpilot/shadcn";
|
|
|
16
16
|
* Shared component for rendering array items list
|
|
17
17
|
* Displays items with move up/down, edit, and remove controls
|
|
18
18
|
*/
|
|
19
|
-
const ArrayItemsList = observer(({ isNewItem, children, className, containerProps }) => {
|
|
19
|
+
const ArrayItemsList = observer(({ isNewItem, activeIndex, children, className, containerProps }) => {
|
|
20
20
|
const field = useField();
|
|
21
21
|
const schema = useFieldSchema();
|
|
22
22
|
const dataSource = useArrayDataSource();
|
|
@@ -34,7 +34,8 @@ const ArrayItemsList = observer(({ isNewItem, children, className, containerProp
|
|
|
34
34
|
itemKey,
|
|
35
35
|
index,
|
|
36
36
|
record,
|
|
37
|
-
isNew
|
|
37
|
+
isNew,
|
|
38
|
+
isAnchor: activeIndex === index && !isNew
|
|
38
39
|
}, itemKey);
|
|
39
40
|
}) }), children]
|
|
40
41
|
});
|
|
@@ -16,6 +16,7 @@ const ItemWrapper = (props) => {
|
|
|
16
16
|
const hasErrors = require_has_array_item_errors.hasArrayItemErrors((0, __formily_react.useField)(), index);
|
|
17
17
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
18
18
|
...rest,
|
|
19
|
+
"data-array-item-index": index,
|
|
19
20
|
className: (0, __pixpilot_shadcn_ui.cn)("border-input bg-card rounded-md border transition-colors items-center", hasErrors && "border-destructive border-2", props.className),
|
|
20
21
|
children
|
|
21
22
|
});
|
|
@@ -11,6 +11,7 @@ const ItemWrapper = (props) => {
|
|
|
11
11
|
const hasErrors = hasArrayItemErrors(useField(), index);
|
|
12
12
|
return /* @__PURE__ */ jsx("div", {
|
|
13
13
|
...rest,
|
|
14
|
+
"data-array-item-index": index,
|
|
14
15
|
className: cn("border-input bg-card rounded-md border transition-colors items-center", hasErrors && "border-destructive border-2", props.className),
|
|
15
16
|
children
|
|
16
17
|
});
|
|
@@ -20,7 +20,7 @@ __pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
|
20
20
|
* Individual list item component for array items
|
|
21
21
|
* Displays an item with label and operation controls
|
|
22
22
|
*/
|
|
23
|
-
const ListItem = react.default.memo(({ itemKey, index, record, isNew }) => {
|
|
23
|
+
const ListItem = react.default.memo(({ itemKey, index, record, isNew, isAnchor }) => {
|
|
24
24
|
const schema = (0, __formily_react.useFieldSchema)();
|
|
25
25
|
const hiddenItemSchema = react.default.useMemo(() => {
|
|
26
26
|
return require_get_hidden_item_schema.getHiddenItemSchema(schema.items);
|
|
@@ -29,9 +29,26 @@ const ListItem = react.default.memo(({ itemKey, index, record, isNew }) => {
|
|
|
29
29
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_array_base.ArrayBase.Item, {
|
|
30
30
|
index,
|
|
31
31
|
record,
|
|
32
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
32
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SortableItem.SortableItem, {
|
|
33
33
|
id: itemKey,
|
|
34
|
-
children:
|
|
34
|
+
children: isAnchor ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.PopoverAnchor, {
|
|
35
|
+
asChild: true,
|
|
36
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [hiddenItemSchema ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
37
|
+
style: { display: "none" },
|
|
38
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.RecursionField, {
|
|
39
|
+
schema: hiddenItemSchema,
|
|
40
|
+
name: index
|
|
41
|
+
})
|
|
42
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ItemWrapper.ItemWrapper, {
|
|
43
|
+
className: (0, __pixpilot_shadcn.cn)("px-3 pl-4 py-2", isNewItem && "hidden"),
|
|
44
|
+
index,
|
|
45
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ArrayItemHeaderRow.ArrayItemHeaderRow, {
|
|
46
|
+
schema,
|
|
47
|
+
index,
|
|
48
|
+
slots: { content: { content: "text-foreground font-medium" } }
|
|
49
|
+
})
|
|
50
|
+
})] })
|
|
51
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [hiddenItemSchema ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
35
52
|
style: { display: "none" },
|
|
36
53
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.RecursionField, {
|
|
37
54
|
schema: hiddenItemSchema,
|
|
@@ -45,7 +62,7 @@ const ListItem = react.default.memo(({ itemKey, index, record, isNew }) => {
|
|
|
45
62
|
index,
|
|
46
63
|
slots: { content: { content: "text-foreground font-medium" } }
|
|
47
64
|
})
|
|
48
|
-
})]
|
|
65
|
+
})] })
|
|
49
66
|
})
|
|
50
67
|
}, itemKey);
|
|
51
68
|
});
|
|
@@ -7,15 +7,15 @@ import { getHiddenItemSchema } from "./get-hidden-item-schema.js";
|
|
|
7
7
|
import { ItemWrapper } from "./ItemWrapper.js";
|
|
8
8
|
import { RecursionField, useFieldSchema } from "@formily/react";
|
|
9
9
|
import React from "react";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { cn } from "@pixpilot/shadcn";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { PopoverAnchor, cn } from "@pixpilot/shadcn";
|
|
12
12
|
|
|
13
13
|
//#region src/components/array-common/ListItem.tsx
|
|
14
14
|
/**
|
|
15
15
|
* Individual list item component for array items
|
|
16
16
|
* Displays an item with label and operation controls
|
|
17
17
|
*/
|
|
18
|
-
const ListItem = React.memo(({ itemKey, index, record, isNew }) => {
|
|
18
|
+
const ListItem = React.memo(({ itemKey, index, record, isNew, isAnchor }) => {
|
|
19
19
|
const schema = useFieldSchema();
|
|
20
20
|
const hiddenItemSchema = React.useMemo(() => {
|
|
21
21
|
return getHiddenItemSchema(schema.items);
|
|
@@ -24,9 +24,26 @@ const ListItem = React.memo(({ itemKey, index, record, isNew }) => {
|
|
|
24
24
|
return /* @__PURE__ */ jsx(ArrayBase.Item, {
|
|
25
25
|
index,
|
|
26
26
|
record,
|
|
27
|
-
children: /* @__PURE__ */
|
|
27
|
+
children: /* @__PURE__ */ jsx(SortableItem, {
|
|
28
28
|
id: itemKey,
|
|
29
|
-
children:
|
|
29
|
+
children: isAnchor ? /* @__PURE__ */ jsx(PopoverAnchor, {
|
|
30
|
+
asChild: true,
|
|
31
|
+
children: /* @__PURE__ */ jsxs("div", { children: [hiddenItemSchema ? /* @__PURE__ */ jsx("div", {
|
|
32
|
+
style: { display: "none" },
|
|
33
|
+
children: /* @__PURE__ */ jsx(RecursionField, {
|
|
34
|
+
schema: hiddenItemSchema,
|
|
35
|
+
name: index
|
|
36
|
+
})
|
|
37
|
+
}) : null, /* @__PURE__ */ jsx(ItemWrapper, {
|
|
38
|
+
className: cn("px-3 pl-4 py-2", isNewItem && "hidden"),
|
|
39
|
+
index,
|
|
40
|
+
children: /* @__PURE__ */ jsx(ArrayItemHeaderRow, {
|
|
41
|
+
schema,
|
|
42
|
+
index,
|
|
43
|
+
slots: { content: { content: "text-foreground font-medium" } }
|
|
44
|
+
})
|
|
45
|
+
})] })
|
|
46
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [hiddenItemSchema ? /* @__PURE__ */ jsx("div", {
|
|
30
47
|
style: { display: "none" },
|
|
31
48
|
children: /* @__PURE__ */ jsx(RecursionField, {
|
|
32
49
|
schema: hiddenItemSchema,
|
|
@@ -40,7 +57,7 @@ const ListItem = React.memo(({ itemKey, index, record, isNew }) => {
|
|
|
40
57
|
index,
|
|
41
58
|
slots: { content: { content: "text-foreground font-medium" } }
|
|
42
59
|
})
|
|
43
|
-
})]
|
|
60
|
+
})] })
|
|
44
61
|
})
|
|
45
62
|
}, itemKey);
|
|
46
63
|
});
|
|
@@ -11,29 +11,45 @@ function useArrayItemDraftForm({ arrayField, index, autoSave, onDraftChange, ini
|
|
|
11
11
|
onDraftChangeRef.current = onDraftChange;
|
|
12
12
|
}, [onDraftChange]);
|
|
13
13
|
return react.default.useMemo(() => {
|
|
14
|
+
if (autoSave) {
|
|
15
|
+
const basePath = index ?? "draft";
|
|
16
|
+
const validationPath = index != null ? `${arrayField.address.toString()}.${index}.*` : void 0;
|
|
17
|
+
return {
|
|
18
|
+
form: arrayField.form,
|
|
19
|
+
basePath,
|
|
20
|
+
validationPath,
|
|
21
|
+
isolatedForm: false
|
|
22
|
+
};
|
|
23
|
+
}
|
|
14
24
|
const arrayValue = arrayField.value;
|
|
15
25
|
const hasArray = Array.isArray(arrayValue);
|
|
16
26
|
const arrayLength = hasArray ? arrayValue.length : 0;
|
|
17
27
|
const currentItemValue = index != null && hasArray && index >= 0 && index < arrayLength ? arrayValue[index] : initialDraftValue;
|
|
18
28
|
let didSkipInitial = false;
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
didSkipInitial
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return {
|
|
30
|
+
form: (0, __formily_core.createForm)({
|
|
31
|
+
values: { draft: currentItemValue },
|
|
32
|
+
effects: () => {
|
|
33
|
+
if (onDraftChangeRef.current == null) return;
|
|
34
|
+
(0, __formily_core.onFormValuesChange)((form) => {
|
|
35
|
+
if (!didSkipInitial) {
|
|
36
|
+
didSkipInitial = true;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
onDraftChangeRef.current?.(form.values.draft);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
basePath: "draft",
|
|
44
|
+
validationPath: void 0,
|
|
45
|
+
isolatedForm: true
|
|
46
|
+
};
|
|
32
47
|
}, [
|
|
48
|
+
autoSave,
|
|
49
|
+
arrayField.form,
|
|
50
|
+
arrayField.address,
|
|
33
51
|
arrayField.value,
|
|
34
52
|
index,
|
|
35
|
-
autoSave,
|
|
36
|
-
onDraftChange,
|
|
37
53
|
initialDraftValue
|
|
38
54
|
]);
|
|
39
55
|
}
|
|
@@ -8,29 +8,45 @@ function useArrayItemDraftForm({ arrayField, index, autoSave, onDraftChange, ini
|
|
|
8
8
|
onDraftChangeRef.current = onDraftChange;
|
|
9
9
|
}, [onDraftChange]);
|
|
10
10
|
return React.useMemo(() => {
|
|
11
|
+
if (autoSave) {
|
|
12
|
+
const basePath = index ?? "draft";
|
|
13
|
+
const validationPath = index != null ? `${arrayField.address.toString()}.${index}.*` : void 0;
|
|
14
|
+
return {
|
|
15
|
+
form: arrayField.form,
|
|
16
|
+
basePath,
|
|
17
|
+
validationPath,
|
|
18
|
+
isolatedForm: false
|
|
19
|
+
};
|
|
20
|
+
}
|
|
11
21
|
const arrayValue = arrayField.value;
|
|
12
22
|
const hasArray = Array.isArray(arrayValue);
|
|
13
23
|
const arrayLength = hasArray ? arrayValue.length : 0;
|
|
14
24
|
const currentItemValue = index != null && hasArray && index >= 0 && index < arrayLength ? arrayValue[index] : initialDraftValue;
|
|
15
25
|
let didSkipInitial = false;
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
didSkipInitial
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
return {
|
|
27
|
+
form: createForm({
|
|
28
|
+
values: { draft: currentItemValue },
|
|
29
|
+
effects: () => {
|
|
30
|
+
if (onDraftChangeRef.current == null) return;
|
|
31
|
+
onFormValuesChange((form) => {
|
|
32
|
+
if (!didSkipInitial) {
|
|
33
|
+
didSkipInitial = true;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
onDraftChangeRef.current?.(form.values.draft);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
basePath: "draft",
|
|
41
|
+
validationPath: void 0,
|
|
42
|
+
isolatedForm: true
|
|
43
|
+
};
|
|
29
44
|
}, [
|
|
45
|
+
autoSave,
|
|
46
|
+
arrayField.form,
|
|
47
|
+
arrayField.address,
|
|
30
48
|
arrayField.value,
|
|
31
49
|
index,
|
|
32
|
-
autoSave,
|
|
33
|
-
onDraftChange,
|
|
34
50
|
initialDraftValue
|
|
35
51
|
]);
|
|
36
52
|
}
|
|
@@ -5,30 +5,18 @@ const require_use_edit_handlers = require('./use-edit-handlers.cjs');
|
|
|
5
5
|
const require_use_shake_animation = require('./use-shake-animation.cjs');
|
|
6
6
|
let __formily_react = require("@formily/react");
|
|
7
7
|
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
8
|
-
let react = require("react");
|
|
9
|
-
react = require_rolldown_runtime.__toESM(react);
|
|
10
8
|
|
|
11
9
|
//#region src/components/array-common/use-array-item-edit-state.ts
|
|
12
|
-
function useArrayItemEditState({ schema, activeItemManager, onSave, onCancel,
|
|
10
|
+
function useArrayItemEditState({ schema, activeItemManager, onSave, onCancel, autoSave }) {
|
|
13
11
|
const arrayField = (0, __formily_react.useField)();
|
|
14
12
|
const activeIndex = activeItemManager.activeItem;
|
|
15
13
|
const isNewItem = activeItemManager.isNew;
|
|
16
14
|
const open = activeIndex !== void 0;
|
|
17
15
|
const normalizedAutoSave = autoSave === true || autoSave === "true";
|
|
18
|
-
const
|
|
19
|
-
if (!normalizedAutoSave) return;
|
|
20
|
-
if (activeIndex === void 0) return;
|
|
21
|
-
onAutoSave?.(activeIndex, nextValue);
|
|
22
|
-
}, [
|
|
23
|
-
activeIndex,
|
|
24
|
-
normalizedAutoSave,
|
|
25
|
-
onAutoSave
|
|
26
|
-
]);
|
|
27
|
-
const draftForm = require_use_array_item_draft_form.useArrayItemDraftForm({
|
|
16
|
+
const { form: draftForm, basePath, validationPath, isolatedForm } = require_use_array_item_draft_form.useArrayItemDraftForm({
|
|
28
17
|
arrayField,
|
|
29
18
|
index: activeIndex,
|
|
30
19
|
autoSave: normalizedAutoSave,
|
|
31
|
-
onDraftChange: normalizedAutoSave ? handleDraftChange : void 0,
|
|
32
20
|
initialDraftValue: activeItemManager.draftInitialValue
|
|
33
21
|
});
|
|
34
22
|
const isDirty = !normalizedAutoSave && draftForm.modified;
|
|
@@ -52,6 +40,9 @@ function useArrayItemEditState({ schema, activeItemManager, onSave, onCancel, on
|
|
|
52
40
|
open,
|
|
53
41
|
normalizedAutoSave,
|
|
54
42
|
draftForm,
|
|
43
|
+
basePath,
|
|
44
|
+
validationPath,
|
|
45
|
+
isolatedForm,
|
|
55
46
|
isDirty,
|
|
56
47
|
title,
|
|
57
48
|
description,
|
|
@@ -3,29 +3,18 @@ import { useArrayItemEditLabels } from "./use-array-item-edit-labels.js";
|
|
|
3
3
|
import { useEditHandlers } from "./use-edit-handlers.js";
|
|
4
4
|
import { useShakeAnimation } from "./use-shake-animation.js";
|
|
5
5
|
import { useField } from "@formily/react";
|
|
6
|
-
import React from "react";
|
|
7
6
|
|
|
8
7
|
//#region src/components/array-common/use-array-item-edit-state.ts
|
|
9
|
-
function useArrayItemEditState({ schema, activeItemManager, onSave, onCancel,
|
|
8
|
+
function useArrayItemEditState({ schema, activeItemManager, onSave, onCancel, autoSave }) {
|
|
10
9
|
const arrayField = useField();
|
|
11
10
|
const activeIndex = activeItemManager.activeItem;
|
|
12
11
|
const isNewItem = activeItemManager.isNew;
|
|
13
12
|
const open = activeIndex !== void 0;
|
|
14
13
|
const normalizedAutoSave = autoSave === true || autoSave === "true";
|
|
15
|
-
const
|
|
16
|
-
if (!normalizedAutoSave) return;
|
|
17
|
-
if (activeIndex === void 0) return;
|
|
18
|
-
onAutoSave?.(activeIndex, nextValue);
|
|
19
|
-
}, [
|
|
20
|
-
activeIndex,
|
|
21
|
-
normalizedAutoSave,
|
|
22
|
-
onAutoSave
|
|
23
|
-
]);
|
|
24
|
-
const draftForm = useArrayItemDraftForm({
|
|
14
|
+
const { form: draftForm, basePath, validationPath, isolatedForm } = useArrayItemDraftForm({
|
|
25
15
|
arrayField,
|
|
26
16
|
index: activeIndex,
|
|
27
17
|
autoSave: normalizedAutoSave,
|
|
28
|
-
onDraftChange: normalizedAutoSave ? handleDraftChange : void 0,
|
|
29
18
|
initialDraftValue: activeItemManager.draftInitialValue
|
|
30
19
|
});
|
|
31
20
|
const isDirty = !normalizedAutoSave && draftForm.modified;
|
|
@@ -49,6 +38,9 @@ function useArrayItemEditState({ schema, activeItemManager, onSave, onCancel, on
|
|
|
49
38
|
open,
|
|
50
39
|
normalizedAutoSave,
|
|
51
40
|
draftForm,
|
|
41
|
+
basePath,
|
|
42
|
+
validationPath,
|
|
43
|
+
isolatedForm,
|
|
52
44
|
isDirty,
|
|
53
45
|
title,
|
|
54
46
|
description,
|