@pixpilot/formily-shadcn 0.34.0 → 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/FormGrid.d.ts +2 -2
- package/dist/components/IconPicker.d.cts +3 -3
- package/dist/components/IconToggle.d.cts +2 -2
- package/dist/components/Input.d.cts +3 -3
- package/dist/components/Radio.d.cts +2 -2
- package/dist/components/Radio.d.ts +2 -2
- package/dist/components/Row.d.cts +2 -2
- package/dist/components/Separator.d.cts +2 -2
- package/dist/components/Switch.d.cts +2 -2
- package/dist/components/array-base/types.d.cts +9 -2
- package/dist/components/array-base/types.d.ts +9 -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/ArrayItemDraftFields.cjs +58 -0
- package/dist/components/array-common/ArrayItemDraftFields.js +54 -0
- package/dist/components/array-common/RenderAction.cjs +1 -1
- package/dist/components/array-common/RenderAction.js +1 -1
- package/dist/components/array-common/ShakeStyles.cjs +15 -0
- package/dist/components/array-common/ShakeStyles.js +12 -0
- 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 +12 -0
- package/dist/components/array-common/get-edit-description.js +11 -0
- package/dist/components/array-common/index.cjs +8 -0
- package/dist/components/array-common/index.js +8 -0
- package/dist/components/array-common/use-array-editor.cjs +28 -12
- package/dist/components/array-common/use-array-editor.js +29 -13
- package/dist/components/array-common/use-array-item-draft-form.cjs +39 -0
- package/dist/components/array-common/use-array-item-draft-form.js +36 -0
- 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-common/use-edit-handlers.cjs +30 -0
- package/dist/components/array-common/use-edit-handlers.js +28 -0
- package/dist/components/array-common/use-shake-animation.cjs +39 -0
- package/dist/components/array-common/use-shake-animation.js +37 -0
- package/dist/components/array-dialog/ArrayDialog.cjs +9 -4
- package/dist/components/array-dialog/ArrayDialog.js +9 -4
- package/dist/components/array-dialog/EditDialog.cjs +55 -24
- package/dist/components/array-dialog/EditDialog.js +55 -25
- package/dist/components/array-popover/ArrayPopover.cjs +9 -4
- package/dist/components/array-popover/ArrayPopover.js +9 -4
- package/dist/components/array-popover/Popover.cjs +58 -26
- package/dist/components/array-popover/Popover.js +59 -28
- package/dist/components/schema-field/schema-field-basics.d.cts +259 -259
- package/dist/components/schema-field/schema-field-basics.d.ts +244 -244
- package/dist/components/schema-field/schema-field-extended.d.ts +541 -541
- package/dist/components/schema-field/schema-field.d.cts +336 -336
- package/dist/components/schema-field/schema-field.d.ts +321 -321
- 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,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/FormGrid.d.ts
|
|
5
5
|
interface IFormGridProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
@@ -7,6 +7,6 @@ declare function FormGrid({
|
|
|
7
7
|
className,
|
|
8
8
|
children,
|
|
9
9
|
...rest
|
|
10
|
-
}: IFormGridProps):
|
|
10
|
+
}: IFormGridProps): react_jsx_runtime1.JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { FormGrid };
|
|
@@ -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:
|
|
11
|
+
declare const IconPicker: react4.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
|
|
12
12
|
providers?: IconProviderProps[];
|
|
13
|
-
}> &
|
|
13
|
+
}> & react4.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { 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:
|
|
9
|
+
declare const IconToggle: 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,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 react7 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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
3
3
|
import { RadioGroup } from "@pixpilot/shadcn";
|
|
4
4
|
|
|
5
5
|
//#region src/components/Radio.d.ts
|
|
@@ -15,7 +15,7 @@ type RadioProps = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Radio component with options rendering
|
|
17
17
|
*/
|
|
18
|
-
declare function Radio(props: RadioProps):
|
|
18
|
+
declare function Radio(props: RadioProps): react_jsx_runtime2.JSX.Element;
|
|
19
19
|
declare namespace Radio {
|
|
20
20
|
var displayName: string;
|
|
21
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
3
3
|
import { RadioGroup } from "@pixpilot/shadcn";
|
|
4
4
|
|
|
5
5
|
//#region src/components/Radio.d.ts
|
|
@@ -15,7 +15,7 @@ type RadioProps = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Radio component with options rendering
|
|
17
17
|
*/
|
|
18
|
-
declare function Radio(props: RadioProps):
|
|
18
|
+
declare function Radio(props: RadioProps): react_jsx_runtime2.JSX.Element;
|
|
19
19
|
declare namespace Radio {
|
|
20
20
|
var displayName: string;
|
|
21
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Row.d.ts
|
|
5
5
|
interface IRowProps {
|
|
@@ -36,6 +36,6 @@ interface IRowProps {
|
|
|
36
36
|
declare function Row({
|
|
37
37
|
className,
|
|
38
38
|
children
|
|
39
|
-
}: IRowProps):
|
|
39
|
+
}: IRowProps): react_jsx_runtime3.JSX.Element;
|
|
40
40
|
//#endregion
|
|
41
41
|
export { Row };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react13 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: react13.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_separator0.SeparatorProps & react13.RefAttributes<HTMLDivElement>>, "ref"> & react13.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_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: react16.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_switch0.SwitchProps & react16.RefAttributes<HTMLButtonElement>>, "ref"> & react16.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Switch };
|
|
@@ -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;
|
|
@@ -80,6 +82,11 @@ interface IArrayBaseOperationProps extends ButtonProps {
|
|
|
80
82
|
type ComposedArrayProps<T = Record<string, unknown>> = React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement> & IArrayBaseProps & T>> & ArrayBaseMixins;
|
|
81
83
|
interface ArrayComponentProps extends React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement> & IArrayBaseProps & {
|
|
82
84
|
title?: string;
|
|
85
|
+
/**
|
|
86
|
+
* When true, array item editors (popover/dialog) commit changes live.
|
|
87
|
+
* When false (default), they only commit on Save.
|
|
88
|
+
*/
|
|
89
|
+
autoSave?: boolean;
|
|
83
90
|
}> {}
|
|
84
91
|
//#endregion
|
|
85
92
|
export { ActionContext, ActionItem, ArrayBaseMixins, ArrayComponentProps, BuiltInOperation, ComposedArrayProps, CustomAction, IArrayBaseOperationProps, IArrayBaseProps, OperationOverride, ToggleAction, TransformContext };
|
|
@@ -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;
|
|
@@ -80,6 +82,11 @@ interface IArrayBaseOperationProps extends ButtonProps {
|
|
|
80
82
|
type ComposedArrayProps<T = Record<string, unknown>> = React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement> & IArrayBaseProps & T>> & ArrayBaseMixins;
|
|
81
83
|
interface ArrayComponentProps extends React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement> & IArrayBaseProps & {
|
|
82
84
|
title?: string;
|
|
85
|
+
/**
|
|
86
|
+
* When true, array item editors (popover/dialog) commit changes live.
|
|
87
|
+
* When false (default), they only commit on Save.
|
|
88
|
+
*/
|
|
89
|
+
autoSave?: boolean;
|
|
83
90
|
}> {}
|
|
84
91
|
//#endregion
|
|
85
92
|
export { ActionContext, ActionItem, ArrayBaseMixins, ArrayComponentProps, BuiltInOperation, ComposedArrayProps, CustomAction, IArrayBaseOperationProps, IArrayBaseProps, OperationOverride, ToggleAction, TransformContext };
|
|
@@ -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",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_get_x_component_props = require('../../utils/get-x-component-props.cjs');
|
|
3
|
+
require('../../utils/index.cjs');
|
|
4
|
+
let __formily_react = require("@formily/react");
|
|
5
|
+
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
6
|
+
let react = require("react");
|
|
7
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
10
|
+
|
|
11
|
+
//#region src/components/array-common/ArrayItemDraftFields.tsx
|
|
12
|
+
function mergeClassName(a, b) {
|
|
13
|
+
const aa = a?.trim();
|
|
14
|
+
const bb = b?.trim();
|
|
15
|
+
const hasA = aa != null && aa.length > 0;
|
|
16
|
+
const hasB = bb != null && bb.length > 0;
|
|
17
|
+
if (!hasA && !hasB) return void 0;
|
|
18
|
+
if (hasA && !hasB) return aa;
|
|
19
|
+
if (!hasA && hasB) return bb;
|
|
20
|
+
return `${aa} ${bb}`;
|
|
21
|
+
}
|
|
22
|
+
function ArrayItemDraftFields({ schema, form, basePath = "draft", as: Component = "div", className }) {
|
|
23
|
+
const schemaComponents = react.default.use(__formily_react.SchemaComponentsContext);
|
|
24
|
+
const schemaOptions = react.default.use(__formily_react.SchemaOptionsContext);
|
|
25
|
+
const schemaExpressionScope = react.default.use(__formily_react.SchemaExpressionScopeContext);
|
|
26
|
+
const schemaMarkup = react.default.use(__formily_react.SchemaMarkupContext);
|
|
27
|
+
const schemaContext = react.default.use(__formily_react.SchemaContext);
|
|
28
|
+
const { className: itemWrapperClassName,...itemWrapperRestProps } = require_get_x_component_props.getXComponentProps(schema);
|
|
29
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
30
|
+
...itemWrapperRestProps,
|
|
31
|
+
className: mergeClassName(className, itemWrapperClassName),
|
|
32
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.FormProvider, {
|
|
33
|
+
form,
|
|
34
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaOptionsContext, {
|
|
35
|
+
value: schemaOptions,
|
|
36
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaComponentsContext, {
|
|
37
|
+
value: schemaComponents,
|
|
38
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__formily_react.SchemaExpressionScopeContext, {
|
|
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
|
+
})
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
exports.ArrayItemDraftFields = ArrayItemDraftFields;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getXComponentProps } from "../../utils/get-x-component-props.js";
|
|
2
|
+
import "../../utils/index.js";
|
|
3
|
+
import { FormProvider, RecursionField, SchemaComponentsContext, SchemaContext, SchemaExpressionScopeContext, SchemaMarkupContext, SchemaOptionsContext } from "@formily/react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/components/array-common/ArrayItemDraftFields.tsx
|
|
8
|
+
function mergeClassName(a, b) {
|
|
9
|
+
const aa = a?.trim();
|
|
10
|
+
const bb = b?.trim();
|
|
11
|
+
const hasA = aa != null && aa.length > 0;
|
|
12
|
+
const hasB = bb != null && bb.length > 0;
|
|
13
|
+
if (!hasA && !hasB) return void 0;
|
|
14
|
+
if (hasA && !hasB) return aa;
|
|
15
|
+
if (!hasA && hasB) return bb;
|
|
16
|
+
return `${aa} ${bb}`;
|
|
17
|
+
}
|
|
18
|
+
function ArrayItemDraftFields({ schema, form, basePath = "draft", as: Component = "div", className }) {
|
|
19
|
+
const schemaComponents = React.use(SchemaComponentsContext);
|
|
20
|
+
const schemaOptions = React.use(SchemaOptionsContext);
|
|
21
|
+
const schemaExpressionScope = React.use(SchemaExpressionScopeContext);
|
|
22
|
+
const schemaMarkup = React.use(SchemaMarkupContext);
|
|
23
|
+
const schemaContext = React.use(SchemaContext);
|
|
24
|
+
const { className: itemWrapperClassName,...itemWrapperRestProps } = getXComponentProps(schema);
|
|
25
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
26
|
+
...itemWrapperRestProps,
|
|
27
|
+
className: mergeClassName(className, itemWrapperClassName),
|
|
28
|
+
children: /* @__PURE__ */ jsx(FormProvider, {
|
|
29
|
+
form,
|
|
30
|
+
children: /* @__PURE__ */ jsx(SchemaOptionsContext, {
|
|
31
|
+
value: schemaOptions,
|
|
32
|
+
children: /* @__PURE__ */ jsx(SchemaComponentsContext, {
|
|
33
|
+
value: schemaComponents,
|
|
34
|
+
children: /* @__PURE__ */ jsx(SchemaExpressionScopeContext, {
|
|
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
|
+
})
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { ArrayItemDraftFields };
|
|
@@ -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);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
6
|
+
|
|
7
|
+
//#region src/components/array-common/ShakeStyles.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Inline styles for shake animation
|
|
10
|
+
* Can be included in any component that needs shake effect
|
|
11
|
+
*/
|
|
12
|
+
const ShakeStyles = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: `@keyframes pp-shake { 0% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } 100% { transform: translateX(0); } } .pp-shake { animation: pp-shake 220ms ease-in-out; }` });
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.ShakeStyles = ShakeStyles;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/array-common/ShakeStyles.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Inline styles for shake animation
|
|
7
|
+
* Can be included in any component that needs shake effect
|
|
8
|
+
*/
|
|
9
|
+
const ShakeStyles = () => /* @__PURE__ */ jsx("style", { children: `@keyframes pp-shake { 0% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } 100% { transform: translateX(0); } } .pp-shake { animation: pp-shake 220ms ease-in-out; }` });
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ShakeStyles };
|
|
@@ -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);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/array-common/get-edit-description.ts
|
|
3
|
+
/**
|
|
4
|
+
* Get description text for edit dialog/popover based on context
|
|
5
|
+
*/
|
|
6
|
+
function getEditDescription(isNew, 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
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.getEditDescription = getEditDescription;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/components/array-common/get-edit-description.ts
|
|
2
|
+
/**
|
|
3
|
+
* Get description text for edit dialog/popover based on context
|
|
4
|
+
*/
|
|
5
|
+
function getEditDescription(isNew, 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
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { getEditDescription };
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
const require_ArrayItemDraftFields = require('./ArrayItemDraftFields.cjs');
|
|
1
2
|
const require_ArrayItemHeaderRow = require('./ArrayItemHeaderRow.cjs');
|
|
2
3
|
const require_ItemWrapper = require('./ItemWrapper.cjs');
|
|
3
4
|
const require_ListItem = require('./ListItem.cjs');
|
|
4
5
|
const require_use_array_data_source = require('./use-array-data-source.cjs');
|
|
5
6
|
const require_ArrayItemsList = require('./ArrayItemsList.cjs');
|
|
6
7
|
const require_create_active_item_manager = require('./create-active-item-manager.cjs');
|
|
8
|
+
const require_get_edit_description = require('./get-edit-description.cjs');
|
|
9
|
+
const require_ShakeStyles = require('./ShakeStyles.cjs');
|
|
7
10
|
const require_use_array_editor = require('./use-array-editor.cjs');
|
|
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');
|
|
14
|
+
const require_use_edit_handlers = require('./use-edit-handlers.cjs');
|
|
15
|
+
const require_use_shake_animation = require('./use-shake-animation.cjs');
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { ArrayItemDraftFields } from "./ArrayItemDraftFields.js";
|
|
1
2
|
import { ArrayItemHeaderRow } from "./ArrayItemHeaderRow.js";
|
|
2
3
|
import { ItemWrapper } from "./ItemWrapper.js";
|
|
3
4
|
import { ListItem } from "./ListItem.js";
|
|
4
5
|
import { useArrayDataSource } from "./use-array-data-source.js";
|
|
5
6
|
import { ArrayItemsList } from "./ArrayItemsList.js";
|
|
6
7
|
import { createActiveItemManager } from "./create-active-item-manager.js";
|
|
8
|
+
import { getEditDescription } from "./get-edit-description.js";
|
|
9
|
+
import { ShakeStyles } from "./ShakeStyles.js";
|
|
7
10
|
import { useArrayEditor } from "./use-array-editor.js";
|
|
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";
|
|
14
|
+
import { useEditHandlers } from "./use-edit-handlers.js";
|
|
15
|
+
import { useShakeAnimation } from "./use-shake-animation.js";
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_validate_array_item_fields = require('../../utils/validate-array-item-fields.cjs');
|
|
3
|
-
require('../../utils/index.cjs');
|
|
4
2
|
const require_create_active_item_manager = require('./create-active-item-manager.cjs');
|
|
5
3
|
let __formily_react = require("@formily/react");
|
|
6
4
|
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
@@ -8,10 +6,27 @@ let react = require("react");
|
|
|
8
6
|
react = require_rolldown_runtime.__toESM(react);
|
|
9
7
|
|
|
10
8
|
//#region src/components/array-common/use-array-editor.ts
|
|
9
|
+
function setArrayItemValue(arrayField, index, value) {
|
|
10
|
+
const address = `${arrayField.address.toString()}.${index}`;
|
|
11
|
+
const form = arrayField.form;
|
|
12
|
+
if (form && typeof form.setValuesIn === "function") {
|
|
13
|
+
form.setValuesIn(address, value);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(arrayField.value)) {
|
|
17
|
+
const next = [...arrayField.value];
|
|
18
|
+
next[index] = value;
|
|
19
|
+
const field = arrayField;
|
|
20
|
+
if (typeof field.setValue === "function") {
|
|
21
|
+
field.setValue(next);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
Object.assign(arrayField, { value: next });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
11
27
|
function useArrayEditor(props) {
|
|
12
|
-
const { onAdd, onEdit } = props;
|
|
28
|
+
const { onAdd, onEdit, autoSave } = props;
|
|
13
29
|
const field = (0, __formily_react.useField)();
|
|
14
|
-
const schema = (0, __formily_react.useFieldSchema)();
|
|
15
30
|
const activeItemManager = react.default.useMemo(() => require_create_active_item_manager.createActiveItemManager(), []);
|
|
16
31
|
const handleEdit = (index) => {
|
|
17
32
|
activeItemManager.setActiveItem(index, false);
|
|
@@ -21,25 +36,26 @@ function useArrayEditor(props) {
|
|
|
21
36
|
activeItemManager.setActiveItem(index, true);
|
|
22
37
|
onAdd?.(index);
|
|
23
38
|
};
|
|
24
|
-
const handleSaveClick = (itemIndex) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
const handleSaveClick = (itemIndex, nextValue) => {
|
|
40
|
+
setArrayItemValue(field, itemIndex, nextValue);
|
|
41
|
+
activeItemManager.removeActiveItem(itemIndex);
|
|
42
|
+
};
|
|
43
|
+
const handleLiveChange = (itemIndex, nextValue) => {
|
|
44
|
+
setArrayItemValue(field, itemIndex, nextValue);
|
|
28
45
|
};
|
|
29
46
|
const handleCancelClick = (itemIndex) => {
|
|
30
|
-
if (activeItemManager.isNewItem(itemIndex)) field.remove?.(itemIndex).catch(console.error);
|
|
47
|
+
if (!autoSave && activeItemManager.isNewItem(itemIndex)) field.remove?.(itemIndex).catch(console.error);
|
|
31
48
|
activeItemManager.removeActiveItem(itemIndex);
|
|
32
49
|
};
|
|
33
|
-
const isNewItem = react.default.useCallback((index) => activeItemManager.activeItem === index && activeItemManager.isNew, [activeItemManager]);
|
|
34
50
|
return {
|
|
35
51
|
activeItemManager,
|
|
36
52
|
handleEdit,
|
|
37
53
|
handleAdd,
|
|
38
54
|
handleSaveClick,
|
|
55
|
+
handleLiveChange,
|
|
39
56
|
handleCancelClick,
|
|
40
57
|
field,
|
|
41
|
-
|
|
42
|
-
isNewItem
|
|
58
|
+
isNewItem: react.default.useCallback((index) => activeItemManager.activeItem === index && activeItemManager.isNew, [activeItemManager])
|
|
43
59
|
};
|
|
44
60
|
}
|
|
45
61
|
|