@pixpilot/formily-shadcn 0.34.1 → 0.35.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/Input.d.ts +3 -3
- package/dist/components/array-base/types.d.cts +4 -2
- package/dist/components/array-base/types.d.ts +4 -2
- package/dist/components/array-cards/ArrayCards.cjs +1 -1
- package/dist/components/array-cards/ArrayCards.js +1 -1
- package/dist/components/array-collapse/Item.cjs +3 -2
- package/dist/components/array-collapse/Item.js +3 -2
- package/dist/components/array-common/RenderAction.cjs +1 -1
- package/dist/components/array-common/RenderAction.js +1 -1
- package/dist/components/array-common/ToggleActionButton.cjs +2 -1
- package/dist/components/array-common/ToggleActionButton.js +2 -1
- package/dist/components/array-common/get-edit-description.cjs +2 -2
- package/dist/components/array-common/get-edit-description.js +2 -2
- package/dist/components/array-common/index.cjs +2 -0
- package/dist/components/array-common/index.js +2 -0
- package/dist/components/array-common/use-array-editor.cjs +1 -4
- package/dist/components/array-common/use-array-editor.js +2 -5
- package/dist/components/array-common/use-array-item-edit-labels.cjs +42 -0
- package/dist/components/array-common/use-array-item-edit-labels.js +40 -0
- package/dist/components/array-common/use-array-item-schema.cjs +21 -0
- package/dist/components/array-common/use-array-item-schema.js +18 -0
- package/dist/components/array-dialog/ArrayDialog.cjs +2 -1
- package/dist/components/array-dialog/ArrayDialog.js +2 -1
- package/dist/components/array-dialog/EditDialog.cjs +8 -5
- package/dist/components/array-dialog/EditDialog.js +8 -5
- package/dist/components/array-popover/ArrayPopover.cjs +4 -2
- package/dist/components/array-popover/ArrayPopover.js +4 -2
- package/dist/components/array-popover/Popover.cjs +8 -3
- package/dist/components/array-popover/Popover.js +8 -3
- package/dist/components/schema-field/schema-field-basics.d.cts +259 -259
- package/dist/components/schema-field/schema-field.d.cts +336 -336
- package/dist/components/slider/Slider.d.cts +3 -3
- package/dist/components/slider/Slider.d.ts +3 -3
- package/dist/components/slider/SliderInput.d.ts +3 -3
- package/dist/components/slider/SliderSelect.d.cts +3 -3
- package/dist/components/slider/SliderSelect.d.ts +3 -3
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react4 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: react4.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
|
|
12
12
|
providers?: IconProviderProps[];
|
|
13
|
-
}> &
|
|
13
|
+
}> & react4.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { IconPicker$1 as IconPicker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react6 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: react6.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui0.IconToggleProps, "ref"> & react6.RefAttributes<HTMLButtonElement>>, "ref"> & react6.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { IconToggle$1 as IconToggle };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react9 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/Input.d.ts
|
|
4
4
|
|
|
@@ -6,12 +6,12 @@ import * as react4 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: react9.ForwardRefExoticComponent<Omit<Partial<react9.ClassAttributes<HTMLInputElement> & react9.InputHTMLAttributes<HTMLInputElement> & {
|
|
10
10
|
prefix?: React.ReactNode;
|
|
11
11
|
suffix?: React.ReactNode;
|
|
12
12
|
groupClassName?: string;
|
|
13
13
|
prefixClassName?: string;
|
|
14
14
|
suffixClassName?: string;
|
|
15
|
-
}>, "ref"> &
|
|
15
|
+
}>, "ref"> & react9.RefAttributes<unknown>>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { Input };
|
|
@@ -25,7 +25,7 @@ interface CustomAction {
|
|
|
25
25
|
type?: 'button';
|
|
26
26
|
icon: React.ReactNode;
|
|
27
27
|
tooltip?: string;
|
|
28
|
-
onClick: (ctx: ActionContext) => void;
|
|
28
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement>, ctx: ActionContext) => void;
|
|
29
29
|
hidden?: boolean | ((ctx: ActionContext) => boolean);
|
|
30
30
|
disabled?: boolean | ((ctx: ActionContext) => boolean);
|
|
31
31
|
buttonProps?: Omit<ButtonProps, 'children' | 'onClick'>;
|
|
@@ -39,7 +39,8 @@ interface ToggleAction {
|
|
|
39
39
|
inactiveTooltip?: string;
|
|
40
40
|
tooltip?: string;
|
|
41
41
|
isActive: (ctx: ActionContext) => boolean;
|
|
42
|
-
onToggle
|
|
42
|
+
onToggle?: (ctx: ActionContext, nextActive: boolean) => void;
|
|
43
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>, context: ActionContext) => void;
|
|
43
44
|
hidden?: boolean | ((ctx: ActionContext) => boolean);
|
|
44
45
|
disabled?: boolean | ((ctx: ActionContext) => boolean);
|
|
45
46
|
buttonProps?: Omit<ButtonProps, 'children' | 'onClick'>;
|
|
@@ -71,6 +72,7 @@ interface IArrayBaseProps {
|
|
|
71
72
|
* Runs per item render (context includes index/record/etc).
|
|
72
73
|
*/
|
|
73
74
|
transformActions?: (actions: ActionItem[], context: TransformContext) => ActionItem[];
|
|
75
|
+
description?: React.ReactNode;
|
|
74
76
|
}
|
|
75
77
|
interface IArrayBaseOperationProps extends ButtonProps {
|
|
76
78
|
title?: string;
|
|
@@ -25,7 +25,7 @@ interface CustomAction {
|
|
|
25
25
|
type?: 'button';
|
|
26
26
|
icon: React.ReactNode;
|
|
27
27
|
tooltip?: string;
|
|
28
|
-
onClick: (ctx: ActionContext) => void;
|
|
28
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement>, ctx: ActionContext) => void;
|
|
29
29
|
hidden?: boolean | ((ctx: ActionContext) => boolean);
|
|
30
30
|
disabled?: boolean | ((ctx: ActionContext) => boolean);
|
|
31
31
|
buttonProps?: Omit<ButtonProps, 'children' | 'onClick'>;
|
|
@@ -39,7 +39,8 @@ interface ToggleAction {
|
|
|
39
39
|
inactiveTooltip?: string;
|
|
40
40
|
tooltip?: string;
|
|
41
41
|
isActive: (ctx: ActionContext) => boolean;
|
|
42
|
-
onToggle
|
|
42
|
+
onToggle?: (ctx: ActionContext, nextActive: boolean) => void;
|
|
43
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>, context: ActionContext) => void;
|
|
43
44
|
hidden?: boolean | ((ctx: ActionContext) => boolean);
|
|
44
45
|
disabled?: boolean | ((ctx: ActionContext) => boolean);
|
|
45
46
|
buttonProps?: Omit<ButtonProps, 'children' | 'onClick'>;
|
|
@@ -71,6 +72,7 @@ interface IArrayBaseProps {
|
|
|
71
72
|
* Runs per item render (context includes index/record/etc).
|
|
72
73
|
*/
|
|
73
74
|
transformActions?: (actions: ActionItem[], context: TransformContext) => ActionItem[];
|
|
75
|
+
description?: React.ReactNode;
|
|
74
76
|
}
|
|
75
77
|
interface IArrayBaseOperationProps extends ButtonProps {
|
|
76
78
|
title?: string;
|
|
@@ -20,7 +20,7 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
|
20
20
|
const ArrayCardsBase = (0, __formily_react.observer)((props) => {
|
|
21
21
|
const field = (0, __formily_react.useField)();
|
|
22
22
|
const schema = (0, __formily_react.useFieldSchema)();
|
|
23
|
-
const { onAdd, onCopy, onRemove, onMoveDown, onMoveUp, disabled, actions, transformActions, className, title: titleProp, children,...otherProps } = props;
|
|
23
|
+
const { onAdd, onCopy, onRemove, onMoveDown, onMoveUp, disabled, actions, transformActions, className, title: titleProp, children, description,...otherProps } = props;
|
|
24
24
|
const dataSource = require_use_array_data_source.useArrayDataSource();
|
|
25
25
|
const { ArrayItemsContainer, AddButton } = require_component_context.useArrayComponents();
|
|
26
26
|
const renderItems = () => {
|
|
@@ -16,7 +16,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
16
16
|
const ArrayCardsBase = observer((props) => {
|
|
17
17
|
const field = useField();
|
|
18
18
|
const schema = useFieldSchema();
|
|
19
|
-
const { onAdd, onCopy, onRemove, onMoveDown, onMoveUp, disabled, actions, transformActions, className, title: titleProp, children,...otherProps } = props;
|
|
19
|
+
const { onAdd, onCopy, onRemove, onMoveDown, onMoveUp, disabled, actions, transformActions, className, title: titleProp, children, description,...otherProps } = props;
|
|
20
20
|
const dataSource = useArrayDataSource();
|
|
21
21
|
const { ArrayItemsContainer, AddButton } = useArrayComponents();
|
|
22
22
|
const renderItems = () => {
|
|
@@ -8,6 +8,7 @@ const require_SortableItem = require('../array-sortable/SortableItem.cjs');
|
|
|
8
8
|
require('../array-sortable/index.cjs');
|
|
9
9
|
const require_ArrayItemHeaderRow = require('../array-common/ArrayItemHeaderRow.cjs');
|
|
10
10
|
const require_ItemWrapper = require('../array-common/ItemWrapper.cjs');
|
|
11
|
+
const require_use_array_item_schema = require('../array-common/use-array-item-schema.cjs');
|
|
11
12
|
require('../array-common/index.cjs');
|
|
12
13
|
let __formily_react = require("@formily/react");
|
|
13
14
|
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
@@ -25,7 +26,7 @@ const ArrayCollapseItem = react.default.memo((props) => {
|
|
|
25
26
|
const { index, itemId, itemKey, formCollapse, isOpen, isNewItem, onClick } = props;
|
|
26
27
|
const field = (0, __formily_react.useField)();
|
|
27
28
|
const schema = (0, __formily_react.useFieldSchema)();
|
|
28
|
-
const items =
|
|
29
|
+
const items = require_use_array_item_schema.useArrayItemSchema();
|
|
29
30
|
const itemWrapperProps = require_get_x_component_props.getXComponentProps(items);
|
|
30
31
|
react.default.useEffect(() => {
|
|
31
32
|
if (isNewItem(index)) formCollapse.addActiveKey(itemId);
|
|
@@ -62,7 +63,7 @@ const ArrayCollapseItem = react.default.memo((props) => {
|
|
|
62
63
|
}).catch(() => {});
|
|
63
64
|
else formCollapse.addActiveKey(itemId);
|
|
64
65
|
} }
|
|
65
|
-
}), isOpen &&
|
|
66
|
+
}), isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
66
67
|
className: "border-t px-3 pb-4",
|
|
67
68
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
68
69
|
className: "space-y-4 pt-4",
|
|
@@ -7,6 +7,7 @@ import { SortableItem } from "../array-sortable/SortableItem.js";
|
|
|
7
7
|
import "../array-sortable/index.js";
|
|
8
8
|
import { ArrayItemHeaderRow } from "../array-common/ArrayItemHeaderRow.js";
|
|
9
9
|
import { ItemWrapper } from "../array-common/ItemWrapper.js";
|
|
10
|
+
import { useArrayItemSchema } from "../array-common/use-array-item-schema.js";
|
|
10
11
|
import "../array-common/index.js";
|
|
11
12
|
import { RecursionField, useField, useFieldSchema } from "@formily/react";
|
|
12
13
|
import React from "react";
|
|
@@ -19,7 +20,7 @@ const ArrayCollapseItem = React.memo((props) => {
|
|
|
19
20
|
const { index, itemId, itemKey, formCollapse, isOpen, isNewItem, onClick } = props;
|
|
20
21
|
const field = useField();
|
|
21
22
|
const schema = useFieldSchema();
|
|
22
|
-
const items =
|
|
23
|
+
const items = useArrayItemSchema();
|
|
23
24
|
const itemWrapperProps = getXComponentProps(items);
|
|
24
25
|
React.useEffect(() => {
|
|
25
26
|
if (isNewItem(index)) formCollapse.addActiveKey(itemId);
|
|
@@ -56,7 +57,7 @@ const ArrayCollapseItem = React.memo((props) => {
|
|
|
56
57
|
}).catch(() => {});
|
|
57
58
|
else formCollapse.addActiveKey(itemId);
|
|
58
59
|
} }
|
|
59
|
-
}), isOpen &&
|
|
60
|
+
}), isOpen && /* @__PURE__ */ jsx("div", {
|
|
60
61
|
className: "border-t px-3 pb-4",
|
|
61
62
|
children: /* @__PURE__ */ jsx("div", {
|
|
62
63
|
className: "space-y-4 pt-4",
|
|
@@ -51,7 +51,7 @@ const RenderAction = ({ action, ctx, isHidden, isDisabled, index, array, schema
|
|
|
51
51
|
onClick: (e) => {
|
|
52
52
|
e.stopPropagation();
|
|
53
53
|
if (disabled) return;
|
|
54
|
-
customAction.onClick(ctx);
|
|
54
|
+
customAction.onClick?.(e, ctx);
|
|
55
55
|
},
|
|
56
56
|
children: customAction.icon
|
|
57
57
|
}, customAction.key);
|
|
@@ -47,7 +47,7 @@ const RenderAction = ({ action, ctx, isHidden, isDisabled, index, array, schema
|
|
|
47
47
|
onClick: (e) => {
|
|
48
48
|
e.stopPropagation();
|
|
49
49
|
if (disabled) return;
|
|
50
|
-
customAction.onClick(ctx);
|
|
50
|
+
customAction.onClick?.(e, ctx);
|
|
51
51
|
},
|
|
52
52
|
children: customAction.icon
|
|
53
53
|
}, customAction.key);
|
|
@@ -23,8 +23,9 @@ const ToggleActionButton = ({ action, actionContext, disabled }) => {
|
|
|
23
23
|
onClick: (e) => {
|
|
24
24
|
e.stopPropagation();
|
|
25
25
|
if (disabled) return;
|
|
26
|
+
action.onClick?.(e, actionContext);
|
|
26
27
|
const nextActive = !active;
|
|
27
|
-
action.onToggle(actionContext, nextActive);
|
|
28
|
+
action.onToggle?.(actionContext, nextActive);
|
|
28
29
|
},
|
|
29
30
|
children: iconNode
|
|
30
31
|
}, action.key);
|
|
@@ -19,8 +19,9 @@ const ToggleActionButton = ({ action, actionContext, disabled }) => {
|
|
|
19
19
|
onClick: (e) => {
|
|
20
20
|
e.stopPropagation();
|
|
21
21
|
if (disabled) return;
|
|
22
|
+
action.onClick?.(e, actionContext);
|
|
22
23
|
const nextActive = !active;
|
|
23
|
-
action.onToggle(actionContext, nextActive);
|
|
24
|
+
action.onToggle?.(actionContext, nextActive);
|
|
24
25
|
},
|
|
25
26
|
children: iconNode
|
|
26
27
|
}, action.key);
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Get description text for edit dialog/popover based on context
|
|
5
5
|
*/
|
|
6
6
|
function getEditDescription(isNew, autoSave) {
|
|
7
|
-
if (isNew) return autoSave ? "
|
|
8
|
-
return autoSave ? "
|
|
7
|
+
if (isNew) return autoSave ? "Enter details. Changes apply instantly." : "Enter details, then click save.";
|
|
8
|
+
return autoSave ? "Edit details. Changes apply instantly." : "Edit details, then click save.";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
//#endregion
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Get description text for edit dialog/popover based on context
|
|
4
4
|
*/
|
|
5
5
|
function getEditDescription(isNew, autoSave) {
|
|
6
|
-
if (isNew) return autoSave ? "
|
|
7
|
-
return autoSave ? "
|
|
6
|
+
if (isNew) return autoSave ? "Enter details. Changes apply instantly." : "Enter details, then click save.";
|
|
7
|
+
return autoSave ? "Edit details. Changes apply instantly." : "Edit details, then click save.";
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
@@ -9,5 +9,7 @@ const require_get_edit_description = require('./get-edit-description.cjs');
|
|
|
9
9
|
const require_ShakeStyles = require('./ShakeStyles.cjs');
|
|
10
10
|
const require_use_array_editor = require('./use-array-editor.cjs');
|
|
11
11
|
const require_use_array_item_draft_form = require('./use-array-item-draft-form.cjs');
|
|
12
|
+
const require_use_array_item_edit_labels = require('./use-array-item-edit-labels.cjs');
|
|
13
|
+
const require_use_array_item_schema = require('./use-array-item-schema.cjs');
|
|
12
14
|
const require_use_edit_handlers = require('./use-edit-handlers.cjs');
|
|
13
15
|
const require_use_shake_animation = require('./use-shake-animation.cjs');
|
|
@@ -9,5 +9,7 @@ import { getEditDescription } from "./get-edit-description.js";
|
|
|
9
9
|
import { ShakeStyles } from "./ShakeStyles.js";
|
|
10
10
|
import { useArrayEditor } from "./use-array-editor.js";
|
|
11
11
|
import { useArrayItemDraftForm } from "./use-array-item-draft-form.js";
|
|
12
|
+
import { useArrayItemEditLabels } from "./use-array-item-edit-labels.js";
|
|
13
|
+
import { useArrayItemSchema } from "./use-array-item-schema.js";
|
|
12
14
|
import { useEditHandlers } from "./use-edit-handlers.js";
|
|
13
15
|
import { useShakeAnimation } from "./use-shake-animation.js";
|
|
@@ -27,7 +27,6 @@ function setArrayItemValue(arrayField, index, value) {
|
|
|
27
27
|
function useArrayEditor(props) {
|
|
28
28
|
const { onAdd, onEdit, autoSave } = props;
|
|
29
29
|
const field = (0, __formily_react.useField)();
|
|
30
|
-
const schema = (0, __formily_react.useFieldSchema)();
|
|
31
30
|
const activeItemManager = react.default.useMemo(() => require_create_active_item_manager.createActiveItemManager(), []);
|
|
32
31
|
const handleEdit = (index) => {
|
|
33
32
|
activeItemManager.setActiveItem(index, false);
|
|
@@ -48,7 +47,6 @@ function useArrayEditor(props) {
|
|
|
48
47
|
if (!autoSave && activeItemManager.isNewItem(itemIndex)) field.remove?.(itemIndex).catch(console.error);
|
|
49
48
|
activeItemManager.removeActiveItem(itemIndex);
|
|
50
49
|
};
|
|
51
|
-
const isNewItem = react.default.useCallback((index) => activeItemManager.activeItem === index && activeItemManager.isNew, [activeItemManager]);
|
|
52
50
|
return {
|
|
53
51
|
activeItemManager,
|
|
54
52
|
handleEdit,
|
|
@@ -57,8 +55,7 @@ function useArrayEditor(props) {
|
|
|
57
55
|
handleLiveChange,
|
|
58
56
|
handleCancelClick,
|
|
59
57
|
field,
|
|
60
|
-
|
|
61
|
-
isNewItem
|
|
58
|
+
isNewItem: react.default.useCallback((index) => activeItemManager.activeItem === index && activeItemManager.isNew, [activeItemManager])
|
|
62
59
|
};
|
|
63
60
|
}
|
|
64
61
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createActiveItemManager } from "./create-active-item-manager.js";
|
|
2
|
-
import { useField
|
|
2
|
+
import { useField } from "@formily/react";
|
|
3
3
|
import React from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/components/array-common/use-array-editor.ts
|
|
@@ -24,7 +24,6 @@ function setArrayItemValue(arrayField, index, value) {
|
|
|
24
24
|
function useArrayEditor(props) {
|
|
25
25
|
const { onAdd, onEdit, autoSave } = props;
|
|
26
26
|
const field = useField();
|
|
27
|
-
const schema = useFieldSchema();
|
|
28
27
|
const activeItemManager = React.useMemo(() => createActiveItemManager(), []);
|
|
29
28
|
const handleEdit = (index) => {
|
|
30
29
|
activeItemManager.setActiveItem(index, false);
|
|
@@ -45,7 +44,6 @@ function useArrayEditor(props) {
|
|
|
45
44
|
if (!autoSave && activeItemManager.isNewItem(itemIndex)) field.remove?.(itemIndex).catch(console.error);
|
|
46
45
|
activeItemManager.removeActiveItem(itemIndex);
|
|
47
46
|
};
|
|
48
|
-
const isNewItem = React.useCallback((index) => activeItemManager.activeItem === index && activeItemManager.isNew, [activeItemManager]);
|
|
49
47
|
return {
|
|
50
48
|
activeItemManager,
|
|
51
49
|
handleEdit,
|
|
@@ -54,8 +52,7 @@ function useArrayEditor(props) {
|
|
|
54
52
|
handleLiveChange,
|
|
55
53
|
handleCancelClick,
|
|
56
54
|
field,
|
|
57
|
-
|
|
58
|
-
isNewItem
|
|
55
|
+
isNewItem: React.useCallback((index) => activeItemManager.activeItem === index && activeItemManager.isNew, [activeItemManager])
|
|
59
56
|
};
|
|
60
57
|
}
|
|
61
58
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_get_edit_description = require('./get-edit-description.cjs');
|
|
3
|
+
let react = require("react");
|
|
4
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
5
|
+
|
|
6
|
+
//#region src/components/array-common/use-array-item-edit-labels.ts
|
|
7
|
+
/**
|
|
8
|
+
* Hook to get title and description for array item edit dialogs/popovers
|
|
9
|
+
* Uses schema title/description when available, falls back to defaults
|
|
10
|
+
*/
|
|
11
|
+
function useArrayItemEditLabels({ schema, isNew, autoSave, itemIndex }) {
|
|
12
|
+
const getNonEmptyString = (0, react.useCallback)((value) => {
|
|
13
|
+
if (typeof value !== "string") return void 0;
|
|
14
|
+
const trimmed = value.trim();
|
|
15
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
16
|
+
}, []);
|
|
17
|
+
return {
|
|
18
|
+
title: (0, react.useMemo)(() => {
|
|
19
|
+
const schemaTitle = getNonEmptyString(schema?.title);
|
|
20
|
+
if (schemaTitle !== void 0) return isNew ? `Add ${schemaTitle}` : `Edit ${schemaTitle}`;
|
|
21
|
+
return isNew ? "Add New Item" : `Edit Item #${(itemIndex ?? 0) + 1}`;
|
|
22
|
+
}, [
|
|
23
|
+
getNonEmptyString,
|
|
24
|
+
isNew,
|
|
25
|
+
itemIndex,
|
|
26
|
+
schema?.title
|
|
27
|
+
]),
|
|
28
|
+
description: (0, react.useMemo)(() => {
|
|
29
|
+
const schemaDescription = getNonEmptyString(schema?.description);
|
|
30
|
+
if (schemaDescription !== void 0) return schemaDescription;
|
|
31
|
+
return require_get_edit_description.getEditDescription(isNew, autoSave ?? false);
|
|
32
|
+
}, [
|
|
33
|
+
getNonEmptyString,
|
|
34
|
+
isNew,
|
|
35
|
+
autoSave,
|
|
36
|
+
schema?.description
|
|
37
|
+
])
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.useArrayItemEditLabels = useArrayItemEditLabels;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getEditDescription } from "./get-edit-description.js";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/array-common/use-array-item-edit-labels.ts
|
|
5
|
+
/**
|
|
6
|
+
* Hook to get title and description for array item edit dialogs/popovers
|
|
7
|
+
* Uses schema title/description when available, falls back to defaults
|
|
8
|
+
*/
|
|
9
|
+
function useArrayItemEditLabels({ schema, isNew, autoSave, itemIndex }) {
|
|
10
|
+
const getNonEmptyString = useCallback((value) => {
|
|
11
|
+
if (typeof value !== "string") return void 0;
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
14
|
+
}, []);
|
|
15
|
+
return {
|
|
16
|
+
title: useMemo(() => {
|
|
17
|
+
const schemaTitle = getNonEmptyString(schema?.title);
|
|
18
|
+
if (schemaTitle !== void 0) return isNew ? `Add ${schemaTitle}` : `Edit ${schemaTitle}`;
|
|
19
|
+
return isNew ? "Add New Item" : `Edit Item #${(itemIndex ?? 0) + 1}`;
|
|
20
|
+
}, [
|
|
21
|
+
getNonEmptyString,
|
|
22
|
+
isNew,
|
|
23
|
+
itemIndex,
|
|
24
|
+
schema?.title
|
|
25
|
+
]),
|
|
26
|
+
description: useMemo(() => {
|
|
27
|
+
const schemaDescription = getNonEmptyString(schema?.description);
|
|
28
|
+
if (schemaDescription !== void 0) return schemaDescription;
|
|
29
|
+
return getEditDescription(isNew, autoSave ?? false);
|
|
30
|
+
}, [
|
|
31
|
+
getNonEmptyString,
|
|
32
|
+
isNew,
|
|
33
|
+
autoSave,
|
|
34
|
+
schema?.description
|
|
35
|
+
])
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { useArrayItemEditLabels };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __formily_react = require("@formily/react");
|
|
3
|
+
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
4
|
+
let react = require("react");
|
|
5
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
6
|
+
|
|
7
|
+
//#region src/components/array-common/use-array-item-schema.ts
|
|
8
|
+
/**
|
|
9
|
+
* Hook to get the schema for individual array items
|
|
10
|
+
* Handles both single schema and array of schemas (takes first item)
|
|
11
|
+
*/
|
|
12
|
+
function useArrayItemSchema() {
|
|
13
|
+
const schema = (0, __formily_react.useFieldSchema)();
|
|
14
|
+
return (0, react.useMemo)(() => {
|
|
15
|
+
if (!schema?.items) throw new Error("Array schema must have items defined");
|
|
16
|
+
return Array.isArray(schema.items) ? schema.items[0] ?? schema.items : schema.items;
|
|
17
|
+
}, [schema]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.useArrayItemSchema = useArrayItemSchema;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useFieldSchema } from "@formily/react";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/array-common/use-array-item-schema.ts
|
|
5
|
+
/**
|
|
6
|
+
* Hook to get the schema for individual array items
|
|
7
|
+
* Handles both single schema and array of schemas (takes first item)
|
|
8
|
+
*/
|
|
9
|
+
function useArrayItemSchema() {
|
|
10
|
+
const schema = useFieldSchema();
|
|
11
|
+
return useMemo(() => {
|
|
12
|
+
if (!schema?.items) throw new Error("Array schema must have items defined");
|
|
13
|
+
return Array.isArray(schema.items) ? schema.items[0] ?? schema.items : schema.items;
|
|
14
|
+
}, [schema]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { useArrayItemSchema };
|
|
@@ -4,6 +4,7 @@ const require_component_context = require('../array-base/component-context.cjs')
|
|
|
4
4
|
require('../array-base/index.cjs');
|
|
5
5
|
const require_ArrayItemsList = require('../array-common/ArrayItemsList.cjs');
|
|
6
6
|
const require_use_array_editor = require('../array-common/use-array-editor.cjs');
|
|
7
|
+
const require_use_array_item_schema = require('../array-common/use-array-item-schema.cjs');
|
|
7
8
|
require('../array-common/index.cjs');
|
|
8
9
|
const require_EditDialog = require('./EditDialog.cjs');
|
|
9
10
|
let __formily_react = require("@formily/react");
|
|
@@ -31,7 +32,7 @@ const ArrayDialogBase = (0, __formily_react.observer)((props) => {
|
|
|
31
32
|
autoSave
|
|
32
33
|
});
|
|
33
34
|
const { AddButton } = require_component_context.useArrayComponents();
|
|
34
|
-
const items =
|
|
35
|
+
const items = require_use_array_item_schema.useArrayItemSchema();
|
|
35
36
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_array_base.ArrayBase, {
|
|
36
37
|
...props,
|
|
37
38
|
transformActions,
|
|
@@ -3,6 +3,7 @@ import { ArrayComponentProvider, useArrayComponents } from "../array-base/compon
|
|
|
3
3
|
import "../array-base/index.js";
|
|
4
4
|
import { ArrayItemsList } from "../array-common/ArrayItemsList.js";
|
|
5
5
|
import { useArrayEditor } from "../array-common/use-array-editor.js";
|
|
6
|
+
import { useArrayItemSchema } from "../array-common/use-array-item-schema.js";
|
|
6
7
|
import "../array-common/index.js";
|
|
7
8
|
import { EditDialog } from "./EditDialog.js";
|
|
8
9
|
import { observer, useFieldSchema } from "@formily/react";
|
|
@@ -27,7 +28,7 @@ const ArrayDialogBase = observer((props) => {
|
|
|
27
28
|
autoSave
|
|
28
29
|
});
|
|
29
30
|
const { AddButton } = useArrayComponents();
|
|
30
|
-
const items =
|
|
31
|
+
const items = useArrayItemSchema();
|
|
31
32
|
return /* @__PURE__ */ jsxs(ArrayBase, {
|
|
32
33
|
...props,
|
|
33
34
|
transformActions,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_ArrayItemDraftFields = require('../array-common/ArrayItemDraftFields.cjs');
|
|
3
|
-
const require_get_edit_description = require('../array-common/get-edit-description.cjs');
|
|
4
3
|
const require_ShakeStyles = require('../array-common/ShakeStyles.cjs');
|
|
5
4
|
const require_use_array_item_draft_form = require('../array-common/use-array-item-draft-form.cjs');
|
|
5
|
+
const require_use_array_item_edit_labels = require('../array-common/use-array-item-edit-labels.cjs');
|
|
6
6
|
const require_use_edit_handlers = require('../array-common/use-edit-handlers.cjs');
|
|
7
7
|
const require_use_shake_animation = require('../array-common/use-shake-animation.cjs');
|
|
8
8
|
let __formily_react = require("@formily/react");
|
|
@@ -48,9 +48,12 @@ const EditDialog = (0, __formily_react.observer)(({ schema, onSave, onAutoSave,
|
|
|
48
48
|
onSave,
|
|
49
49
|
onCancel
|
|
50
50
|
});
|
|
51
|
-
const description =
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
const { title, description } = require_use_array_item_edit_labels.useArrayItemEditLabels({
|
|
52
|
+
schema,
|
|
53
|
+
isNew,
|
|
54
|
+
autoSave,
|
|
55
|
+
itemIndex
|
|
56
|
+
});
|
|
54
57
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Dialog, {
|
|
55
58
|
open,
|
|
56
59
|
onOpenChange: (isOpen) => {
|
|
@@ -65,7 +68,7 @@ const EditDialog = (0, __formily_react.observer)(({ schema, onSave, onAutoSave,
|
|
|
65
68
|
},
|
|
66
69
|
children: [
|
|
67
70
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ShakeStyles.ShakeStyles, {}),
|
|
68
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DialogHeader, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DialogTitle, { children:
|
|
71
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DialogHeader, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DialogTitle, { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DialogDescription, { children: description })] }),
|
|
69
72
|
itemIndex != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ArrayItemDraftFields.ArrayItemDraftFields, {
|
|
70
73
|
as: __pixpilot_shadcn_ui.DialogBody,
|
|
71
74
|
schema,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ArrayItemDraftFields } from "../array-common/ArrayItemDraftFields.js";
|
|
2
|
-
import { getEditDescription } from "../array-common/get-edit-description.js";
|
|
3
2
|
import { ShakeStyles } from "../array-common/ShakeStyles.js";
|
|
4
3
|
import { useArrayItemDraftForm } from "../array-common/use-array-item-draft-form.js";
|
|
4
|
+
import { useArrayItemEditLabels } from "../array-common/use-array-item-edit-labels.js";
|
|
5
5
|
import { useEditHandlers } from "../array-common/use-edit-handlers.js";
|
|
6
6
|
import { useShakeAnimation } from "../array-common/use-shake-animation.js";
|
|
7
7
|
import { observer, useField } from "@formily/react";
|
|
@@ -43,9 +43,12 @@ const EditDialog = observer(({ schema, onSave, onAutoSave, onCancel, activeItemM
|
|
|
43
43
|
onSave,
|
|
44
44
|
onCancel
|
|
45
45
|
});
|
|
46
|
-
const description =
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const { title, description } = useArrayItemEditLabels({
|
|
47
|
+
schema,
|
|
48
|
+
isNew,
|
|
49
|
+
autoSave,
|
|
50
|
+
itemIndex
|
|
51
|
+
});
|
|
49
52
|
return /* @__PURE__ */ jsx(Dialog, {
|
|
50
53
|
open,
|
|
51
54
|
onOpenChange: (isOpen) => {
|
|
@@ -60,7 +63,7 @@ const EditDialog = observer(({ schema, onSave, onAutoSave, onCancel, activeItemM
|
|
|
60
63
|
},
|
|
61
64
|
children: [
|
|
62
65
|
/* @__PURE__ */ jsx(ShakeStyles, {}),
|
|
63
|
-
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children:
|
|
66
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: title }), /* @__PURE__ */ jsx(DialogDescription, { children: description })] }),
|
|
64
67
|
itemIndex != null && /* @__PURE__ */ jsx(ArrayItemDraftFields, {
|
|
65
68
|
as: DialogBody,
|
|
66
69
|
schema,
|
|
@@ -4,6 +4,7 @@ const require_component_context = require('../array-base/component-context.cjs')
|
|
|
4
4
|
require('../array-base/index.cjs');
|
|
5
5
|
const require_ArrayItemsList = require('../array-common/ArrayItemsList.cjs');
|
|
6
6
|
const require_use_array_editor = require('../array-common/use-array-editor.cjs');
|
|
7
|
+
const require_use_array_item_schema = require('../array-common/use-array-item-schema.cjs');
|
|
7
8
|
require('../array-common/index.cjs');
|
|
8
9
|
const require_Popover = require('./Popover.cjs');
|
|
9
10
|
let __formily_react = require("@formily/react");
|
|
@@ -18,11 +19,12 @@ __pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
|
18
19
|
//#region src/components/array-popover/ArrayPopover.tsx
|
|
19
20
|
const ArrayPopoverBase = (0, __formily_react.observer)((props) => {
|
|
20
21
|
const { onAdd, onRemove, onMoveDown, onMoveUp, onEdit, autoSave = true, className, children, transformActions,...rest } = props;
|
|
21
|
-
const { activeItemManager,
|
|
22
|
+
const { activeItemManager, handleAdd, isNewItem, handleEdit, handleSaveClick, handleLiveChange, handleCancelClick } = require_use_array_editor.useArrayEditor({
|
|
22
23
|
onAdd,
|
|
23
24
|
onEdit,
|
|
24
25
|
autoSave
|
|
25
26
|
});
|
|
27
|
+
const schema = require_use_array_item_schema.useArrayItemSchema();
|
|
26
28
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_array_base.ArrayBase, {
|
|
27
29
|
...props,
|
|
28
30
|
transformActions,
|
|
@@ -41,7 +43,7 @@ const ArrayPopoverBase = (0, __formily_react.observer)((props) => {
|
|
|
41
43
|
onCancel: handleCancelClick,
|
|
42
44
|
onAutoSave: handleLiveChange,
|
|
43
45
|
autoSave,
|
|
44
|
-
schema
|
|
46
|
+
schema,
|
|
45
47
|
onSave: handleSaveClick,
|
|
46
48
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_array_base.ArrayBase.Addition, {})
|
|
47
49
|
})
|
|
@@ -3,6 +3,7 @@ import { ArrayComponentProvider } from "../array-base/component-context.js";
|
|
|
3
3
|
import "../array-base/index.js";
|
|
4
4
|
import { ArrayItemsList } from "../array-common/ArrayItemsList.js";
|
|
5
5
|
import { useArrayEditor } from "../array-common/use-array-editor.js";
|
|
6
|
+
import { useArrayItemSchema } from "../array-common/use-array-item-schema.js";
|
|
6
7
|
import "../array-common/index.js";
|
|
7
8
|
import { ArrayItemsEditPopover } from "./Popover.js";
|
|
8
9
|
import { observer } from "@formily/react";
|
|
@@ -13,11 +14,12 @@ import { cn } from "@pixpilot/shadcn";
|
|
|
13
14
|
//#region src/components/array-popover/ArrayPopover.tsx
|
|
14
15
|
const ArrayPopoverBase = observer((props) => {
|
|
15
16
|
const { onAdd, onRemove, onMoveDown, onMoveUp, onEdit, autoSave = true, className, children, transformActions,...rest } = props;
|
|
16
|
-
const { activeItemManager,
|
|
17
|
+
const { activeItemManager, handleAdd, isNewItem, handleEdit, handleSaveClick, handleLiveChange, handleCancelClick } = useArrayEditor({
|
|
17
18
|
onAdd,
|
|
18
19
|
onEdit,
|
|
19
20
|
autoSave
|
|
20
21
|
});
|
|
22
|
+
const schema = useArrayItemSchema();
|
|
21
23
|
return /* @__PURE__ */ jsx(ArrayBase, {
|
|
22
24
|
...props,
|
|
23
25
|
transformActions,
|
|
@@ -36,7 +38,7 @@ const ArrayPopoverBase = observer((props) => {
|
|
|
36
38
|
onCancel: handleCancelClick,
|
|
37
39
|
onAutoSave: handleLiveChange,
|
|
38
40
|
autoSave,
|
|
39
|
-
schema
|
|
41
|
+
schema,
|
|
40
42
|
onSave: handleSaveClick,
|
|
41
43
|
children: /* @__PURE__ */ jsx(ArrayBase.Addition, {})
|
|
42
44
|
})
|