@pixpilot/formily-shadcn 1.4.4 → 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.
Files changed (53) hide show
  1. package/dist/components/Column.d.ts +2 -2
  2. package/dist/components/DatePicker.d.ts +3 -3
  3. package/dist/components/Form.d.ts +2 -2
  4. package/dist/components/FormGrid.d.ts +2 -2
  5. package/dist/components/IconPicker.d.ts +3 -3
  6. package/dist/components/IconToggle.d.ts +3 -3
  7. package/dist/components/Input.d.ts +3 -3
  8. package/dist/components/Radio.d.ts +2 -2
  9. package/dist/components/Rating.d.ts +4 -4
  10. package/dist/components/Row.d.ts +2 -2
  11. package/dist/components/Separator.d.cts +2 -2
  12. package/dist/components/Separator.d.ts +2 -2
  13. package/dist/components/Switch.d.cts +2 -2
  14. package/dist/components/Switch.d.ts +2 -2
  15. package/dist/components/TagsInputInline.d.cts +2 -2
  16. package/dist/components/TagsInputInline.d.ts +3 -3
  17. package/dist/components/Textarea.d.cts +2 -2
  18. package/dist/components/Textarea.d.ts +2 -2
  19. package/dist/components/ToggleButton.d.cts +2 -2
  20. package/dist/components/ToggleButton.d.ts +3 -3
  21. package/dist/components/array-common/ArrayItemDraftFields.cjs +37 -25
  22. package/dist/components/array-common/ArrayItemDraftFields.js +37 -25
  23. package/dist/components/array-common/ArrayItemsList.cjs +3 -2
  24. package/dist/components/array-common/ArrayItemsList.js +3 -2
  25. package/dist/components/array-common/ItemWrapper.cjs +1 -0
  26. package/dist/components/array-common/ItemWrapper.js +1 -0
  27. package/dist/components/array-common/ListItem.cjs +21 -4
  28. package/dist/components/array-common/ListItem.js +23 -6
  29. package/dist/components/array-common/use-array-item-draft-form.cjs +31 -15
  30. package/dist/components/array-common/use-array-item-draft-form.js +31 -15
  31. package/dist/components/array-common/use-array-item-edit-state.cjs +5 -14
  32. package/dist/components/array-common/use-array-item-edit-state.js +5 -13
  33. package/dist/components/array-dialog/EditDialog.cjs +60 -6
  34. package/dist/components/array-dialog/EditDialog.js +60 -6
  35. package/dist/components/array-popover/ArrayPopover.cjs +29 -16
  36. package/dist/components/array-popover/ArrayPopover.js +30 -17
  37. package/dist/components/array-popover/Popover.cjs +88 -88
  38. package/dist/components/array-popover/Popover.js +88 -88
  39. package/dist/components/context/types.d.cts +2 -1
  40. package/dist/components/context/types.d.ts +2 -1
  41. package/dist/components/file-upload/FileUpload.d.ts +8 -8
  42. package/dist/components/file-upload/FileUploadInline.d.ts +8 -8
  43. package/dist/components/schema-field/schema-field-basics.d.ts +302 -302
  44. package/dist/components/schema-field/schema-field-extended.d.cts +632 -632
  45. package/dist/components/schema-field/schema-field-extended.d.ts +307 -307
  46. package/dist/components/schema-field/schema-field.d.cts +412 -412
  47. package/dist/components/schema-field/schema-field.d.ts +412 -412
  48. package/dist/components/slider/Slider.d.cts +3 -3
  49. package/dist/components/slider/Slider.d.ts +2 -2
  50. package/dist/components/slider/SliderInput.d.ts +2 -2
  51. package/dist/components/slider/SliderSelect.d.cts +3 -3
  52. package/dist/components/slider/SliderSelect.d.ts +2 -2
  53. package/package.json +6 -6
@@ -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 (0, __formily_core.createForm)({
20
- values: { draft: currentItemValue },
21
- effects: () => {
22
- if (!autoSave || onDraftChange == null) return;
23
- (0, __formily_core.onFormValuesChange)((form) => {
24
- if (!didSkipInitial) {
25
- didSkipInitial = true;
26
- return;
27
- }
28
- onDraftChangeRef.current?.(form.values.draft);
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 createForm({
17
- values: { draft: currentItemValue },
18
- effects: () => {
19
- if (!autoSave || onDraftChange == null) return;
20
- onFormValuesChange((form) => {
21
- if (!didSkipInitial) {
22
- didSkipInitial = true;
23
- return;
24
- }
25
- onDraftChangeRef.current?.(form.values.draft);
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, onAutoSave, autoSave }) {
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 handleDraftChange = react.default.useCallback((nextValue) => {
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, onAutoSave, autoSave }) {
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 handleDraftChange = React.useCallback((nextValue) => {
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,
@@ -1,4 +1,6 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_use_form_context = require('../../hooks/use-form-context.cjs');
3
+ require('../../hooks/index.cjs');
2
4
  const require_ArrayItemDraftFields = require('../array-common/ArrayItemDraftFields.cjs');
3
5
  const require_ShakeStyles = require('../array-common/ShakeStyles.cjs');
4
6
  const require_use_array_item_edit_state = require('../array-common/use-array-item-edit-state.cjs');
@@ -17,27 +19,67 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
17
19
  * Renders form fields based on the array item schema
18
20
  * RecursionField inherits component registry from parent SchemaField context (preserved through Radix Portal)
19
21
  */
20
- const EditDialog = (0, __formily_react.observer)(({ schema, onSave, onAutoSave, onCancel, activeItemManager, autoSave, className,...rest }) => {
21
- const { activeIndex: itemIndex, open, normalizedAutoSave, draftForm, isDirty, title, description, shouldShake, triggerShake, handleSave, handleCancel } = require_use_array_item_edit_state.useArrayItemEditState({
22
+ const EditDialog = (0, __formily_react.observer)(({ schema, onSave, onAutoSave: _onAutoSave, onCancel, activeItemManager, autoSave, className,...rest }) => {
23
+ const { arrayField, activeIndex: itemIndex, isNewItem, open, normalizedAutoSave, draftForm, basePath, validationPath, isolatedForm, isDirty, title, description, shouldShake, triggerShake, handleSave, handleCancel } = require_use_array_item_edit_state.useArrayItemEditState({
22
24
  schema,
23
25
  activeItemManager,
24
26
  onSave,
25
27
  onCancel,
26
- onAutoSave,
27
28
  autoSave
28
29
  });
30
+ /**
31
+ * Validate the current item's fields before allowing the dialog to close.
32
+ * In non-autoSave mode a dirty (modified but unsaved) form shakes instead.
33
+ * In autoSave mode the parent form fields are validated directly.
34
+ */
35
+ const validateAndClose = react.default.useCallback(() => {
36
+ if (isDirty) {
37
+ triggerShake();
38
+ return;
39
+ }
40
+ Promise.resolve(draftForm.validate(validationPath)).then(() => {
41
+ handleCancel();
42
+ }).catch(() => {
43
+ triggerShake();
44
+ });
45
+ }, [
46
+ draftForm,
47
+ handleCancel,
48
+ isDirty,
49
+ triggerShake,
50
+ validationPath
51
+ ]);
52
+ /**
53
+ * In autoSave mode, newly-added items are inserted into the parent array
54
+ * immediately. Discard removes the item so the user can abandon it.
55
+ */
56
+ const handleDiscard = react.default.useCallback(() => {
57
+ if (itemIndex !== void 0 && normalizedAutoSave && isNewItem) arrayField.remove?.(itemIndex).catch(console.error);
58
+ handleCancel();
59
+ }, [
60
+ arrayField,
61
+ handleCancel,
62
+ isNewItem,
63
+ itemIndex,
64
+ normalizedAutoSave
65
+ ]);
66
+ const { settings = {} } = require_use_form_context.useFormContext();
29
67
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Dialog, {
30
68
  open,
31
69
  onOpenChange: (isOpen) => {
32
- if (!isOpen) handleCancel();
70
+ if (!isOpen) validateAndClose();
33
71
  },
34
72
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DialogContent, {
73
+ ...settings.dialog,
35
74
  ...rest,
36
75
  className: (0, __pixpilot_shadcn_ui.cn)("sm:max-w-[525px]", shouldShake && "pp-shake", className),
37
76
  onInteractOutside: (event) => {
38
- if (!isDirty) return;
39
77
  event.preventDefault();
40
- triggerShake();
78
+ validateAndClose();
79
+ },
80
+ onEscapeKeyDown: (event) => {
81
+ event.preventDefault();
82
+ validateAndClose();
41
83
  },
42
84
  children: [
43
85
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ShakeStyles.ShakeStyles, {}),
@@ -46,6 +88,8 @@ const EditDialog = (0, __formily_react.observer)(({ schema, onSave, onAutoSave,
46
88
  as: __pixpilot_shadcn_ui.DialogBody,
47
89
  schema,
48
90
  form: draftForm,
91
+ basePath,
92
+ isolated: isolatedForm,
49
93
  className: (0, __pixpilot_shadcn_ui.cn)("grid gap-4 py-4")
50
94
  }),
51
95
  !normalizedAutoSave && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DialogFooter, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Button, {
@@ -57,6 +101,16 @@ const EditDialog = (0, __formily_react.observer)(({ schema, onSave, onAutoSave,
57
101
  type: "button",
58
102
  onClick: handleSave,
59
103
  children: "Save Changes"
104
+ })] }),
105
+ normalizedAutoSave && isNewItem && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DialogFooter, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Button, {
106
+ type: "button",
107
+ variant: "outline",
108
+ onClick: handleDiscard,
109
+ children: "Discard"
110
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Button, {
111
+ type: "button",
112
+ onClick: validateAndClose,
113
+ children: "Done"
60
114
  })] })
61
115
  ]
62
116
  })
@@ -1,3 +1,5 @@
1
+ import { useFormContext } from "../../hooks/use-form-context.js";
2
+ import "../../hooks/index.js";
1
3
  import { ArrayItemDraftFields } from "../array-common/ArrayItemDraftFields.js";
2
4
  import { ShakeStyles } from "../array-common/ShakeStyles.js";
3
5
  import { useArrayItemEditState } from "../array-common/use-array-item-edit-state.js";
@@ -12,27 +14,67 @@ import { jsx, jsxs } from "react/jsx-runtime";
12
14
  * Renders form fields based on the array item schema
13
15
  * RecursionField inherits component registry from parent SchemaField context (preserved through Radix Portal)
14
16
  */
15
- const EditDialog = observer(({ schema, onSave, onAutoSave, onCancel, activeItemManager, autoSave, className,...rest }) => {
16
- const { activeIndex: itemIndex, open, normalizedAutoSave, draftForm, isDirty, title, description, shouldShake, triggerShake, handleSave, handleCancel } = useArrayItemEditState({
17
+ const EditDialog = observer(({ schema, onSave, onAutoSave: _onAutoSave, onCancel, activeItemManager, autoSave, className,...rest }) => {
18
+ const { arrayField, activeIndex: itemIndex, isNewItem, open, normalizedAutoSave, draftForm, basePath, validationPath, isolatedForm, isDirty, title, description, shouldShake, triggerShake, handleSave, handleCancel } = useArrayItemEditState({
17
19
  schema,
18
20
  activeItemManager,
19
21
  onSave,
20
22
  onCancel,
21
- onAutoSave,
22
23
  autoSave
23
24
  });
25
+ /**
26
+ * Validate the current item's fields before allowing the dialog to close.
27
+ * In non-autoSave mode a dirty (modified but unsaved) form shakes instead.
28
+ * In autoSave mode the parent form fields are validated directly.
29
+ */
30
+ const validateAndClose = React.useCallback(() => {
31
+ if (isDirty) {
32
+ triggerShake();
33
+ return;
34
+ }
35
+ Promise.resolve(draftForm.validate(validationPath)).then(() => {
36
+ handleCancel();
37
+ }).catch(() => {
38
+ triggerShake();
39
+ });
40
+ }, [
41
+ draftForm,
42
+ handleCancel,
43
+ isDirty,
44
+ triggerShake,
45
+ validationPath
46
+ ]);
47
+ /**
48
+ * In autoSave mode, newly-added items are inserted into the parent array
49
+ * immediately. Discard removes the item so the user can abandon it.
50
+ */
51
+ const handleDiscard = React.useCallback(() => {
52
+ if (itemIndex !== void 0 && normalizedAutoSave && isNewItem) arrayField.remove?.(itemIndex).catch(console.error);
53
+ handleCancel();
54
+ }, [
55
+ arrayField,
56
+ handleCancel,
57
+ isNewItem,
58
+ itemIndex,
59
+ normalizedAutoSave
60
+ ]);
61
+ const { settings = {} } = useFormContext();
24
62
  return /* @__PURE__ */ jsx(Dialog, {
25
63
  open,
26
64
  onOpenChange: (isOpen) => {
27
- if (!isOpen) handleCancel();
65
+ if (!isOpen) validateAndClose();
28
66
  },
29
67
  children: /* @__PURE__ */ jsxs(DialogContent, {
68
+ ...settings.dialog,
30
69
  ...rest,
31
70
  className: cn("sm:max-w-[525px]", shouldShake && "pp-shake", className),
32
71
  onInteractOutside: (event) => {
33
- if (!isDirty) return;
34
72
  event.preventDefault();
35
- triggerShake();
73
+ validateAndClose();
74
+ },
75
+ onEscapeKeyDown: (event) => {
76
+ event.preventDefault();
77
+ validateAndClose();
36
78
  },
37
79
  children: [
38
80
  /* @__PURE__ */ jsx(ShakeStyles, {}),
@@ -41,6 +83,8 @@ const EditDialog = observer(({ schema, onSave, onAutoSave, onCancel, activeItemM
41
83
  as: DialogBody,
42
84
  schema,
43
85
  form: draftForm,
86
+ basePath,
87
+ isolated: isolatedForm,
44
88
  className: cn("grid gap-4 py-4")
45
89
  }),
46
90
  !normalizedAutoSave && /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
@@ -52,6 +96,16 @@ const EditDialog = observer(({ schema, onSave, onAutoSave, onCancel, activeItemM
52
96
  type: "button",
53
97
  onClick: handleSave,
54
98
  children: "Save Changes"
99
+ })] }),
100
+ normalizedAutoSave && isNewItem && /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
101
+ type: "button",
102
+ variant: "outline",
103
+ onClick: handleDiscard,
104
+ children: "Discard"
105
+ }), /* @__PURE__ */ jsx(Button, {
106
+ type: "button",
107
+ onClick: validateAndClose,
108
+ children: "Done"
55
109
  })] })
56
110
  ]
57
111
  })
@@ -35,22 +35,35 @@ const ArrayPopoverBase = (0, __formily_react.observer)((props) => {
35
35
  onMoveUp,
36
36
  onMoveDown,
37
37
  onEdit: handleEdit,
38
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
39
- ...rest,
40
- className: (0, __pixpilot_shadcn.cn)("space-y-2", className),
41
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ArrayItemsList.ArrayItemsList, { isNewItem }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
42
- className: "pt-2",
43
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Popover.ArrayItemsEditPopover, {
44
- activeItemManager,
45
- onCancel: handleCancelClick,
46
- onAutoSave: handleLiveChange,
47
- autoSave,
48
- schema,
49
- onSave: handleSaveClick,
50
- ...popoverProps,
51
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_array_base.ArrayBase.Addition, {})
52
- })
53
- })]
38
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.Popover, {
39
+ open: activeItemManager.activeItem !== void 0,
40
+ modal: true,
41
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
42
+ ...rest,
43
+ className: (0, __pixpilot_shadcn.cn)("space-y-2", className),
44
+ children: [
45
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ArrayItemsList.ArrayItemsList, {
46
+ isNewItem,
47
+ activeIndex: activeItemManager.activeItem
48
+ }),
49
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
50
+ className: "pt-2",
51
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn.PopoverTrigger, {
52
+ asChild: true,
53
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_array_base.ArrayBase.Addition, {})
54
+ })
55
+ }),
56
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Popover.ArrayItemsEditPopover, {
57
+ activeItemManager,
58
+ onCancel: handleCancelClick,
59
+ onAutoSave: handleLiveChange,
60
+ autoSave,
61
+ schema,
62
+ onSave: handleSaveClick,
63
+ ...popoverProps
64
+ })
65
+ ]
66
+ })
54
67
  })
55
68
  });
56
69
  });
@@ -9,7 +9,7 @@ import { ArrayItemsEditPopover } from "./Popover.js";
9
9
  import { observer } from "@formily/react";
10
10
  import React from "react";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
- import { cn } from "@pixpilot/shadcn";
12
+ import { Popover, PopoverTrigger, cn } from "@pixpilot/shadcn";
13
13
 
14
14
  //#region src/components/array-popover/ArrayPopover.tsx
15
15
  const ArrayPopoverBase = observer((props) => {
@@ -30,22 +30,35 @@ const ArrayPopoverBase = observer((props) => {
30
30
  onMoveUp,
31
31
  onMoveDown,
32
32
  onEdit: handleEdit,
33
- children: /* @__PURE__ */ jsxs("div", {
34
- ...rest,
35
- className: cn("space-y-2", className),
36
- children: [/* @__PURE__ */ jsx(ArrayItemsList, { isNewItem }), /* @__PURE__ */ jsx("div", {
37
- className: "pt-2",
38
- children: /* @__PURE__ */ jsx(ArrayItemsEditPopover, {
39
- activeItemManager,
40
- onCancel: handleCancelClick,
41
- onAutoSave: handleLiveChange,
42
- autoSave,
43
- schema,
44
- onSave: handleSaveClick,
45
- ...popoverProps,
46
- children: /* @__PURE__ */ jsx(ArrayBase.Addition, {})
47
- })
48
- })]
33
+ children: /* @__PURE__ */ jsx(Popover, {
34
+ open: activeItemManager.activeItem !== void 0,
35
+ modal: true,
36
+ children: /* @__PURE__ */ jsxs("div", {
37
+ ...rest,
38
+ className: cn("space-y-2", className),
39
+ children: [
40
+ /* @__PURE__ */ jsx(ArrayItemsList, {
41
+ isNewItem,
42
+ activeIndex: activeItemManager.activeItem
43
+ }),
44
+ /* @__PURE__ */ jsx("div", {
45
+ className: "pt-2",
46
+ children: /* @__PURE__ */ jsx(PopoverTrigger, {
47
+ asChild: true,
48
+ children: /* @__PURE__ */ jsx(ArrayBase.Addition, {})
49
+ })
50
+ }),
51
+ /* @__PURE__ */ jsx(ArrayItemsEditPopover, {
52
+ activeItemManager,
53
+ onCancel: handleCancelClick,
54
+ onAutoSave: handleLiveChange,
55
+ autoSave,
56
+ schema,
57
+ onSave: handleSaveClick,
58
+ ...popoverProps
59
+ })
60
+ ]
61
+ })
49
62
  })
50
63
  });
51
64
  });