@pixpilot/formily-shadcn 1.17.1 → 1.18.1
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/array-drawer/ArrayDrawer.cjs +70 -0
- package/dist/components/array-drawer/ArrayDrawer.d.cts +16 -0
- package/dist/components/array-drawer/ArrayDrawer.d.ts +16 -0
- package/dist/components/array-drawer/ArrayDrawer.js +66 -0
- package/dist/components/array-drawer/EditDrawer.cjs +129 -0
- package/dist/components/array-drawer/EditDrawer.js +124 -0
- package/dist/components/array-drawer/index.d.cts +1 -0
- package/dist/components/array-drawer/index.d.ts +1 -0
- package/dist/components/array-drawer/mcp.js +59 -0
- package/dist/components/date-picker/DatePicker.d.cts +3 -3
- package/dist/components/dialog-item/ConnectedDialogItem.d.cts +4 -4
- package/dist/components/drawer-item/BaseDrawerItem.cjs +112 -0
- package/dist/components/drawer-item/BaseDrawerItem.d.cts +59 -0
- package/dist/components/drawer-item/BaseDrawerItem.d.ts +59 -0
- package/dist/components/drawer-item/BaseDrawerItem.js +107 -0
- package/dist/components/drawer-item/ConnectedDrawerItem.cjs +16 -0
- package/dist/components/drawer-item/ConnectedDrawerItem.d.cts +15 -0
- package/dist/components/drawer-item/ConnectedDrawerItem.d.ts +15 -0
- package/dist/components/drawer-item/ConnectedDrawerItem.js +14 -0
- package/dist/components/drawer-item/index.d.cts +2 -0
- package/dist/components/drawer-item/index.d.ts +2 -0
- package/dist/components/drawer-item/mcp.js +119 -0
- package/dist/components/form-item/BaseFormItem.cjs +1 -0
- package/dist/components/form-item/BaseFormItem.js +1 -0
- package/dist/components/form-item/ConnectedFormItem.d.cts +4 -4
- package/dist/components/form-item/ConnectedFormItem.d.ts +4 -4
- package/dist/components/form-item/FormItemLabel.cjs +3 -2
- package/dist/components/form-item/FormItemLabel.js +3 -2
- package/dist/components/popover-item/ConnectedPopoverItem.d.cts +4 -4
- package/dist/components/popover-item/ConnectedPopoverItem.d.ts +4 -4
- package/dist/components/radio/Radio.d.cts +2 -2
- package/dist/components/row/Row.d.cts +2 -2
- package/dist/components/schema-field/schema-field-basics.cjs +7 -0
- package/dist/components/schema-field/schema-field-basics.d.cts +435 -329
- package/dist/components/schema-field/schema-field-basics.d.ts +442 -336
- package/dist/components/schema-field/schema-field-basics.js +7 -0
- package/dist/components/schema-field/schema-field-extended.d.cts +578 -472
- package/dist/components/schema-field/schema-field-extended.d.ts +578 -472
- package/dist/components/schema-field/schema-field.d.cts +523 -417
- package/dist/components/schema-field/schema-field.d.ts +530 -424
- package/dist/generated/mcp-registry.js +80 -76
- package/dist/index.cjs +6 -0
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +4 -1
- package/package.json +3 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_use_form_context = require('../../hooks/use-form-context.cjs');
|
|
3
|
+
const require_array_base = require('../array-base/array-base.cjs');
|
|
4
|
+
const require_component_context = require('../array-base/component-context.cjs');
|
|
5
|
+
const require_ArrayItemsList = require('../array-common/ArrayItemsList.cjs');
|
|
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');
|
|
8
|
+
const require_EditDrawer = require('./EditDrawer.cjs');
|
|
9
|
+
let __formily_react = require("@formily/react");
|
|
10
|
+
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
11
|
+
let react = require("react");
|
|
12
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
13
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
15
|
+
|
|
16
|
+
//#region src/components/array-drawer/ArrayDrawer.tsx
|
|
17
|
+
/**
|
|
18
|
+
* ArrayDrawer component displays array items as a simple list with controls,
|
|
19
|
+
* editing each item inside a drawer opened from its row.
|
|
20
|
+
* Each item shows:
|
|
21
|
+
* - Left: Move up/down buttons
|
|
22
|
+
* - Center: Item label (Item 1, Item 2, etc.)
|
|
23
|
+
* - Right: Edit and Remove buttons
|
|
24
|
+
*/
|
|
25
|
+
const ArrayDrawerBase = (0, __formily_react.observer)((props) => {
|
|
26
|
+
const schema = (0, __formily_react.useFieldSchema)();
|
|
27
|
+
const { onAdd, onRemove, onMoveDown, onMoveUp, onEdit, className, transformActions, drawerProps } = props;
|
|
28
|
+
const { settings = {} } = require_use_form_context.useFormContext();
|
|
29
|
+
const { autoSave: globalAutoSave } = settings.dialog || {};
|
|
30
|
+
const autoSave = props.autoSave ?? globalAutoSave ?? false;
|
|
31
|
+
const { activeItemManager, handleAdd, handleEdit, isNewItem, handleSaveClick, handleLiveChange, handleCancelClick } = require_use_array_editor.useArrayEditor({
|
|
32
|
+
onAdd,
|
|
33
|
+
onEdit,
|
|
34
|
+
autoSave
|
|
35
|
+
});
|
|
36
|
+
const { AddButton } = require_component_context.useArrayComponents();
|
|
37
|
+
const items = require_use_array_item_schema.useArrayItemSchema();
|
|
38
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_array_base.ArrayBase, {
|
|
39
|
+
...props,
|
|
40
|
+
autoSave,
|
|
41
|
+
transformActions,
|
|
42
|
+
onAdd: handleAdd,
|
|
43
|
+
onRemove,
|
|
44
|
+
onMoveUp,
|
|
45
|
+
onMoveDown,
|
|
46
|
+
onEdit: handleEdit,
|
|
47
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ArrayItemsList.ArrayItemsList, {
|
|
48
|
+
className,
|
|
49
|
+
isNewItem,
|
|
50
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AddButton, { schema })
|
|
51
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EditDrawer.EditDrawer, {
|
|
52
|
+
...drawerProps,
|
|
53
|
+
onSave: handleSaveClick,
|
|
54
|
+
onAutoSave: handleLiveChange,
|
|
55
|
+
onCancel: handleCancelClick,
|
|
56
|
+
activeItemManager,
|
|
57
|
+
schema: items,
|
|
58
|
+
autoSave
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
const ArrayDrawerComponent = (rest) => {
|
|
63
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_component_context.ArrayComponentProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ArrayDrawerBase, { ...rest }) });
|
|
64
|
+
};
|
|
65
|
+
const ArrayDrawer = ArrayDrawerComponent;
|
|
66
|
+
ArrayDrawer.displayName = "ArrayDrawer";
|
|
67
|
+
require_array_base.ArrayBase.mixin(ArrayDrawer);
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.ArrayDrawer = ArrayDrawer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ArrayComponentProps } from "../array-base/types.cjs";
|
|
2
|
+
import "../array-base/index.cjs";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/array-drawer/ArrayDrawer.d.ts
|
|
6
|
+
type Props = ArrayComponentProps & {
|
|
7
|
+
drawerProps?: React.HTMLAttributes<HTMLDivElement> & {
|
|
8
|
+
/** Edge the drawer anchors to (`top | bottom | left | right`, default `bottom`). */
|
|
9
|
+
direction?: 'top' | 'bottom' | 'left' | 'right';
|
|
10
|
+
/** Detach the drawer from the viewport edges (gap + full rounding). Default `false`. */
|
|
11
|
+
floating?: boolean;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
declare const ArrayDrawer: React.FC<Props>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ArrayDrawer };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ArrayComponentProps } from "../array-base/types.js";
|
|
2
|
+
import "../array-base/index.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/array-drawer/ArrayDrawer.d.ts
|
|
6
|
+
type Props = ArrayComponentProps & {
|
|
7
|
+
drawerProps?: React.HTMLAttributes<HTMLDivElement> & {
|
|
8
|
+
/** Edge the drawer anchors to (`top | bottom | left | right`, default `bottom`). */
|
|
9
|
+
direction?: 'top' | 'bottom' | 'left' | 'right';
|
|
10
|
+
/** Detach the drawer from the viewport edges (gap + full rounding). Default `false`. */
|
|
11
|
+
floating?: boolean;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
declare const ArrayDrawer: React.FC<Props>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ArrayDrawer };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useFormContext } from "../../hooks/use-form-context.js";
|
|
2
|
+
import { ArrayBase } from "../array-base/array-base.js";
|
|
3
|
+
import { ArrayComponentProvider, useArrayComponents } from "../array-base/component-context.js";
|
|
4
|
+
import { ArrayItemsList } from "../array-common/ArrayItemsList.js";
|
|
5
|
+
import { useArrayEditor } from "../array-common/use-array-editor.js";
|
|
6
|
+
import { useArrayItemSchema } from "../array-common/use-array-item-schema.js";
|
|
7
|
+
import { EditDrawer } from "./EditDrawer.js";
|
|
8
|
+
import { observer, useFieldSchema } from "@formily/react";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
//#region src/components/array-drawer/ArrayDrawer.tsx
|
|
13
|
+
/**
|
|
14
|
+
* ArrayDrawer component displays array items as a simple list with controls,
|
|
15
|
+
* editing each item inside a drawer opened from its row.
|
|
16
|
+
* Each item shows:
|
|
17
|
+
* - Left: Move up/down buttons
|
|
18
|
+
* - Center: Item label (Item 1, Item 2, etc.)
|
|
19
|
+
* - Right: Edit and Remove buttons
|
|
20
|
+
*/
|
|
21
|
+
const ArrayDrawerBase = observer((props) => {
|
|
22
|
+
const schema = useFieldSchema();
|
|
23
|
+
const { onAdd, onRemove, onMoveDown, onMoveUp, onEdit, className, transformActions, drawerProps } = props;
|
|
24
|
+
const { settings = {} } = useFormContext();
|
|
25
|
+
const { autoSave: globalAutoSave } = settings.dialog || {};
|
|
26
|
+
const autoSave = props.autoSave ?? globalAutoSave ?? false;
|
|
27
|
+
const { activeItemManager, handleAdd, handleEdit, isNewItem, handleSaveClick, handleLiveChange, handleCancelClick } = useArrayEditor({
|
|
28
|
+
onAdd,
|
|
29
|
+
onEdit,
|
|
30
|
+
autoSave
|
|
31
|
+
});
|
|
32
|
+
const { AddButton } = useArrayComponents();
|
|
33
|
+
const items = useArrayItemSchema();
|
|
34
|
+
return /* @__PURE__ */ jsxs(ArrayBase, {
|
|
35
|
+
...props,
|
|
36
|
+
autoSave,
|
|
37
|
+
transformActions,
|
|
38
|
+
onAdd: handleAdd,
|
|
39
|
+
onRemove,
|
|
40
|
+
onMoveUp,
|
|
41
|
+
onMoveDown,
|
|
42
|
+
onEdit: handleEdit,
|
|
43
|
+
children: [/* @__PURE__ */ jsx(ArrayItemsList, {
|
|
44
|
+
className,
|
|
45
|
+
isNewItem,
|
|
46
|
+
children: /* @__PURE__ */ jsx(AddButton, { schema })
|
|
47
|
+
}), /* @__PURE__ */ jsx(EditDrawer, {
|
|
48
|
+
...drawerProps,
|
|
49
|
+
onSave: handleSaveClick,
|
|
50
|
+
onAutoSave: handleLiveChange,
|
|
51
|
+
onCancel: handleCancelClick,
|
|
52
|
+
activeItemManager,
|
|
53
|
+
schema: items,
|
|
54
|
+
autoSave
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
const ArrayDrawerComponent = (rest) => {
|
|
59
|
+
return /* @__PURE__ */ jsx(ArrayComponentProvider, { children: /* @__PURE__ */ jsx(ArrayDrawerBase, { ...rest }) });
|
|
60
|
+
};
|
|
61
|
+
const ArrayDrawer = ArrayDrawerComponent;
|
|
62
|
+
ArrayDrawer.displayName = "ArrayDrawer";
|
|
63
|
+
ArrayBase.mixin(ArrayDrawer);
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { ArrayDrawer };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_use_form_context = require('../../hooks/use-form-context.cjs');
|
|
3
|
+
const require_ArrayItemDraftFields = require('../array-common/ArrayItemDraftFields.cjs');
|
|
4
|
+
const require_ShakeStyles = require('../array-common/ShakeStyles.cjs');
|
|
5
|
+
const require_use_array_item_edit_state = require('../array-common/use-array-item-edit-state.cjs');
|
|
6
|
+
let __formily_react = require("@formily/react");
|
|
7
|
+
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
8
|
+
let react = require("react");
|
|
9
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
10
|
+
let __pixpilot_shadcn_ui = require("@pixpilot/shadcn-ui");
|
|
11
|
+
__pixpilot_shadcn_ui = require_rolldown_runtime.__toESM(__pixpilot_shadcn_ui);
|
|
12
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
14
|
+
|
|
15
|
+
//#region src/components/array-drawer/EditDrawer.tsx
|
|
16
|
+
/**
|
|
17
|
+
* Drawer for editing array items
|
|
18
|
+
* Renders form fields based on the array item schema
|
|
19
|
+
* RecursionField inherits component registry from parent SchemaField context (preserved through Radix Portal)
|
|
20
|
+
*/
|
|
21
|
+
const EditDrawer = (0, __formily_react.observer)(({ schema, onSave, onAutoSave: _onAutoSave, onCancel, activeItemManager, className, autoSave, direction,...rest }) => {
|
|
22
|
+
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({
|
|
23
|
+
schema,
|
|
24
|
+
activeItemManager,
|
|
25
|
+
onSave,
|
|
26
|
+
onCancel,
|
|
27
|
+
autoSave
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Validate the current item's fields before allowing the drawer to close.
|
|
31
|
+
* In non-autoSave mode a dirty (modified but unsaved) form shakes instead.
|
|
32
|
+
* In autoSave mode the parent form fields are validated directly.
|
|
33
|
+
*/
|
|
34
|
+
const validateAndClose = react.default.useCallback(() => {
|
|
35
|
+
if (isDirty) {
|
|
36
|
+
triggerShake();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
Promise.resolve(draftForm.validate(validationPath)).then(() => {
|
|
40
|
+
handleCancel();
|
|
41
|
+
}).catch(() => {
|
|
42
|
+
triggerShake();
|
|
43
|
+
});
|
|
44
|
+
}, [
|
|
45
|
+
draftForm,
|
|
46
|
+
handleCancel,
|
|
47
|
+
isDirty,
|
|
48
|
+
triggerShake,
|
|
49
|
+
validationPath
|
|
50
|
+
]);
|
|
51
|
+
/**
|
|
52
|
+
* In autoSave mode, newly-added items are inserted into the parent array
|
|
53
|
+
* immediately. Discard removes the item so the user can abandon it.
|
|
54
|
+
*/
|
|
55
|
+
const handleDiscard = react.default.useCallback(() => {
|
|
56
|
+
if (itemIndex !== void 0 && normalizedAutoSave && isNewItem) arrayField.remove?.(itemIndex).catch(console.error);
|
|
57
|
+
handleCancel();
|
|
58
|
+
}, [
|
|
59
|
+
arrayField,
|
|
60
|
+
handleCancel,
|
|
61
|
+
isNewItem,
|
|
62
|
+
itemIndex,
|
|
63
|
+
normalizedAutoSave
|
|
64
|
+
]);
|
|
65
|
+
const { settings = {} } = require_use_form_context.useFormContext();
|
|
66
|
+
const { autoSave: _globalAutoSave,...drawerSettings } = settings.dialog || {};
|
|
67
|
+
const drawerContentProps = {
|
|
68
|
+
...drawerSettings,
|
|
69
|
+
...rest
|
|
70
|
+
};
|
|
71
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Drawer, {
|
|
72
|
+
open,
|
|
73
|
+
direction,
|
|
74
|
+
onOpenChange: (isOpen) => {
|
|
75
|
+
if (!isOpen) validateAndClose();
|
|
76
|
+
},
|
|
77
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DrawerContent, {
|
|
78
|
+
...drawerContentProps,
|
|
79
|
+
className: (0, __pixpilot_shadcn_ui.cn)("sm:mx-auto sm:max-w-[525px]", shouldShake && "pp-shake", drawerContentProps.className, className),
|
|
80
|
+
onInteractOutside: (event) => {
|
|
81
|
+
drawerContentProps.onInteractOutside?.(event);
|
|
82
|
+
if (event.defaultPrevented) return;
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
validateAndClose();
|
|
85
|
+
},
|
|
86
|
+
onEscapeKeyDown: (event) => {
|
|
87
|
+
drawerContentProps.onEscapeKeyDown?.(event);
|
|
88
|
+
if (event.defaultPrevented) return;
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
validateAndClose();
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ShakeStyles.ShakeStyles, {}),
|
|
94
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DrawerHeader, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DrawerTitle, { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DrawerDescription, { children: description })] }),
|
|
95
|
+
itemIndex != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ArrayItemDraftFields.ArrayItemDraftFields, {
|
|
96
|
+
as: __pixpilot_shadcn_ui.DrawerBody,
|
|
97
|
+
schema,
|
|
98
|
+
form: draftForm,
|
|
99
|
+
basePath,
|
|
100
|
+
isolated: isolatedForm,
|
|
101
|
+
className: (0, __pixpilot_shadcn_ui.cn)("grid gap-4 py-4")
|
|
102
|
+
}),
|
|
103
|
+
!normalizedAutoSave && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DrawerFooter, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Button, {
|
|
104
|
+
type: "button",
|
|
105
|
+
variant: "outline",
|
|
106
|
+
onClick: handleCancel,
|
|
107
|
+
children: "Cancel"
|
|
108
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Button, {
|
|
109
|
+
type: "button",
|
|
110
|
+
onClick: handleSave,
|
|
111
|
+
children: "Save Changes"
|
|
112
|
+
})] }),
|
|
113
|
+
normalizedAutoSave && isNewItem && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DrawerFooter, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Button, {
|
|
114
|
+
type: "button",
|
|
115
|
+
variant: "outline",
|
|
116
|
+
onClick: handleDiscard,
|
|
117
|
+
children: "Discard"
|
|
118
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Button, {
|
|
119
|
+
type: "button",
|
|
120
|
+
onClick: validateAndClose,
|
|
121
|
+
children: "Done"
|
|
122
|
+
})] })
|
|
123
|
+
]
|
|
124
|
+
})
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
exports.EditDrawer = EditDrawer;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { useFormContext } from "../../hooks/use-form-context.js";
|
|
2
|
+
import { ArrayItemDraftFields } from "../array-common/ArrayItemDraftFields.js";
|
|
3
|
+
import { ShakeStyles } from "../array-common/ShakeStyles.js";
|
|
4
|
+
import { useArrayItemEditState } from "../array-common/use-array-item-edit-state.js";
|
|
5
|
+
import { observer } from "@formily/react";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { Button, Drawer, DrawerBody, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, cn } from "@pixpilot/shadcn-ui";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
//#region src/components/array-drawer/EditDrawer.tsx
|
|
11
|
+
/**
|
|
12
|
+
* Drawer for editing array items
|
|
13
|
+
* Renders form fields based on the array item schema
|
|
14
|
+
* RecursionField inherits component registry from parent SchemaField context (preserved through Radix Portal)
|
|
15
|
+
*/
|
|
16
|
+
const EditDrawer = observer(({ schema, onSave, onAutoSave: _onAutoSave, onCancel, activeItemManager, className, autoSave, direction,...rest }) => {
|
|
17
|
+
const { arrayField, activeIndex: itemIndex, isNewItem, open, normalizedAutoSave, draftForm, basePath, validationPath, isolatedForm, isDirty, title, description, shouldShake, triggerShake, handleSave, handleCancel } = useArrayItemEditState({
|
|
18
|
+
schema,
|
|
19
|
+
activeItemManager,
|
|
20
|
+
onSave,
|
|
21
|
+
onCancel,
|
|
22
|
+
autoSave
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Validate the current item's fields before allowing the drawer to close.
|
|
26
|
+
* In non-autoSave mode a dirty (modified but unsaved) form shakes instead.
|
|
27
|
+
* In autoSave mode the parent form fields are validated directly.
|
|
28
|
+
*/
|
|
29
|
+
const validateAndClose = React.useCallback(() => {
|
|
30
|
+
if (isDirty) {
|
|
31
|
+
triggerShake();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
Promise.resolve(draftForm.validate(validationPath)).then(() => {
|
|
35
|
+
handleCancel();
|
|
36
|
+
}).catch(() => {
|
|
37
|
+
triggerShake();
|
|
38
|
+
});
|
|
39
|
+
}, [
|
|
40
|
+
draftForm,
|
|
41
|
+
handleCancel,
|
|
42
|
+
isDirty,
|
|
43
|
+
triggerShake,
|
|
44
|
+
validationPath
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* In autoSave mode, newly-added items are inserted into the parent array
|
|
48
|
+
* immediately. Discard removes the item so the user can abandon it.
|
|
49
|
+
*/
|
|
50
|
+
const handleDiscard = React.useCallback(() => {
|
|
51
|
+
if (itemIndex !== void 0 && normalizedAutoSave && isNewItem) arrayField.remove?.(itemIndex).catch(console.error);
|
|
52
|
+
handleCancel();
|
|
53
|
+
}, [
|
|
54
|
+
arrayField,
|
|
55
|
+
handleCancel,
|
|
56
|
+
isNewItem,
|
|
57
|
+
itemIndex,
|
|
58
|
+
normalizedAutoSave
|
|
59
|
+
]);
|
|
60
|
+
const { settings = {} } = useFormContext();
|
|
61
|
+
const { autoSave: _globalAutoSave,...drawerSettings } = settings.dialog || {};
|
|
62
|
+
const drawerContentProps = {
|
|
63
|
+
...drawerSettings,
|
|
64
|
+
...rest
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ jsx(Drawer, {
|
|
67
|
+
open,
|
|
68
|
+
direction,
|
|
69
|
+
onOpenChange: (isOpen) => {
|
|
70
|
+
if (!isOpen) validateAndClose();
|
|
71
|
+
},
|
|
72
|
+
children: /* @__PURE__ */ jsxs(DrawerContent, {
|
|
73
|
+
...drawerContentProps,
|
|
74
|
+
className: cn("sm:mx-auto sm:max-w-[525px]", shouldShake && "pp-shake", drawerContentProps.className, className),
|
|
75
|
+
onInteractOutside: (event) => {
|
|
76
|
+
drawerContentProps.onInteractOutside?.(event);
|
|
77
|
+
if (event.defaultPrevented) return;
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
validateAndClose();
|
|
80
|
+
},
|
|
81
|
+
onEscapeKeyDown: (event) => {
|
|
82
|
+
drawerContentProps.onEscapeKeyDown?.(event);
|
|
83
|
+
if (event.defaultPrevented) return;
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
validateAndClose();
|
|
86
|
+
},
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsx(ShakeStyles, {}),
|
|
89
|
+
/* @__PURE__ */ jsxs(DrawerHeader, { children: [/* @__PURE__ */ jsx(DrawerTitle, { children: title }), /* @__PURE__ */ jsx(DrawerDescription, { children: description })] }),
|
|
90
|
+
itemIndex != null && /* @__PURE__ */ jsx(ArrayItemDraftFields, {
|
|
91
|
+
as: DrawerBody,
|
|
92
|
+
schema,
|
|
93
|
+
form: draftForm,
|
|
94
|
+
basePath,
|
|
95
|
+
isolated: isolatedForm,
|
|
96
|
+
className: cn("grid gap-4 py-4")
|
|
97
|
+
}),
|
|
98
|
+
!normalizedAutoSave && /* @__PURE__ */ jsxs(DrawerFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
99
|
+
type: "button",
|
|
100
|
+
variant: "outline",
|
|
101
|
+
onClick: handleCancel,
|
|
102
|
+
children: "Cancel"
|
|
103
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
104
|
+
type: "button",
|
|
105
|
+
onClick: handleSave,
|
|
106
|
+
children: "Save Changes"
|
|
107
|
+
})] }),
|
|
108
|
+
normalizedAutoSave && isNewItem && /* @__PURE__ */ jsxs(DrawerFooter, { children: [/* @__PURE__ */ jsx(Button, {
|
|
109
|
+
type: "button",
|
|
110
|
+
variant: "outline",
|
|
111
|
+
onClick: handleDiscard,
|
|
112
|
+
children: "Discard"
|
|
113
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
114
|
+
type: "button",
|
|
115
|
+
onClick: validateAndClose,
|
|
116
|
+
children: "Done"
|
|
117
|
+
})] })
|
|
118
|
+
]
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
export { EditDrawer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { ArrayDrawer } from "./ArrayDrawer.cjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { ArrayDrawer } from "./ArrayDrawer.js";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineProps } from "../../mcp/src/utils.js";
|
|
2
|
+
import { commonArrayPropDocs, perItemStylingNote } from "../array-common/array-mcp-props.js";
|
|
3
|
+
|
|
4
|
+
//#region src/components/array-drawer/mcp.ts
|
|
5
|
+
const meta = {
|
|
6
|
+
name: "ArrayDrawer",
|
|
7
|
+
category: "Formily Arrays",
|
|
8
|
+
description: "A Formily array field that renders items as a compact list; each item is edited inside a drawer opened from its row.",
|
|
9
|
+
htmlElement: "div",
|
|
10
|
+
props: defineProps({
|
|
11
|
+
...commonArrayPropDocs,
|
|
12
|
+
autoSave: {
|
|
13
|
+
description: "When true, edits commit to the array live and the Save/Cancel buttons are hidden. When false (default), edits only commit on Save. Falls back to the form-level `settings.dialog.autoSave`.",
|
|
14
|
+
type: "boolean",
|
|
15
|
+
defaultValue: "false"
|
|
16
|
+
},
|
|
17
|
+
drawerProps: "Props forwarded to the edit drawer — e.g. `className` to size/scroll the drawer, `direction` (`top | bottom | left | right`, default `bottom`) to change the anchored edge, `floating` (boolean) to detach it from the viewport edges with a gap and full rounding, and vaul/Radix content handlers like `onInteractOutside`, `onEscapeKeyDown`."
|
|
18
|
+
}),
|
|
19
|
+
examples: [{
|
|
20
|
+
title: "Edit items in a drawer",
|
|
21
|
+
code: `{
|
|
22
|
+
type: 'array',
|
|
23
|
+
'x-component': 'ArrayDrawer',
|
|
24
|
+
items: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
name: { type: 'string', 'x-decorator': 'FormItem', 'x-component': 'Input' },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
properties: {
|
|
31
|
+
addition: { type: 'void', title: 'Add', 'x-component': 'ArrayDrawer.Addition' },
|
|
32
|
+
},
|
|
33
|
+
}`
|
|
34
|
+
}, {
|
|
35
|
+
title: "Side drawer",
|
|
36
|
+
code: `'x-component-props': {
|
|
37
|
+
drawerProps: { direction: 'right' },
|
|
38
|
+
}`
|
|
39
|
+
}],
|
|
40
|
+
notes: [perItemStylingNote, "The list container is styled via the array node `x-component-props.className`; the drawer is styled via `x-component-props.drawerProps.className`."],
|
|
41
|
+
keywords: [
|
|
42
|
+
"formily",
|
|
43
|
+
"array",
|
|
44
|
+
"drawer",
|
|
45
|
+
"sheet",
|
|
46
|
+
"list",
|
|
47
|
+
"repeater"
|
|
48
|
+
],
|
|
49
|
+
related: [
|
|
50
|
+
"ArrayDialog",
|
|
51
|
+
"ArrayPopover",
|
|
52
|
+
"ArrayCards",
|
|
53
|
+
"ArrayCollapse",
|
|
54
|
+
"ArrayInline"
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { meta };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react2 from "react";
|
|
2
2
|
import { DatePickerProps } from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/date-picker/DatePicker.d.ts
|
|
5
5
|
|
|
6
|
-
declare const DatePicker:
|
|
6
|
+
declare const DatePicker: react2.ForwardRefExoticComponent<Partial<{
|
|
7
7
|
value?: Date;
|
|
8
8
|
onChange?: (date: Date | undefined) => void;
|
|
9
9
|
placeholder?: string;
|
|
10
|
-
} & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> &
|
|
10
|
+
} & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react2.RefAttributes<unknown>>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { DatePicker };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DialogItemProps } from "./BaseDialogItem.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react0 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/dialog-item/ConnectedDialogItem.d.ts
|
|
5
5
|
|
|
@@ -8,8 +8,8 @@ import * as react1 from "react";
|
|
|
8
8
|
* Maps field label, description, and validation state onto the decorator the
|
|
9
9
|
* same way FormItem does.
|
|
10
10
|
*/
|
|
11
|
-
declare const DialogItem:
|
|
12
|
-
children?:
|
|
13
|
-
}>, "ref"> &
|
|
11
|
+
declare const DialogItem: react0.ForwardRefExoticComponent<Omit<Partial<DialogItemProps & {
|
|
12
|
+
children?: react0.ReactNode | undefined;
|
|
13
|
+
}>, "ref"> & react0.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { DialogItem };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_ShakeStyles = require('../array-common/ShakeStyles.cjs');
|
|
3
|
+
const require_BaseFormItem = require('../form-item/BaseFormItem.cjs');
|
|
4
|
+
const require_OverlayFields = require('../overlay-common/OverlayFields.cjs');
|
|
5
|
+
const require_OverlayTrigger = require('../overlay-common/OverlayTrigger.cjs');
|
|
6
|
+
const require_use_overlay = require('../overlay-common/use-overlay.cjs');
|
|
7
|
+
let react = require("react");
|
|
8
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
9
|
+
let __pixpilot_shadcn_ui = require("@pixpilot/shadcn-ui");
|
|
10
|
+
__pixpilot_shadcn_ui = require_rolldown_runtime.__toESM(__pixpilot_shadcn_ui);
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
13
|
+
let __pixpilot_shadcn = require("@pixpilot/shadcn");
|
|
14
|
+
__pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
15
|
+
|
|
16
|
+
//#region src/components/drawer-item/BaseDrawerItem.tsx
|
|
17
|
+
/**
|
|
18
|
+
* Formily decorator that edits a single field inside a drawer.
|
|
19
|
+
*
|
|
20
|
+
* Used in place of FormItem (`x-decorator: 'DrawerItem'`), it renders the
|
|
21
|
+
* field's label, description, and validation feedback exactly as FormItem
|
|
22
|
+
* does, but puts a trigger button where the input would sit and moves the
|
|
23
|
+
* input itself into a drawer. The field keeps its own component, so validation
|
|
24
|
+
* and x-reactions behave as they do under FormItem.
|
|
25
|
+
*/
|
|
26
|
+
const BaseDrawerItem = ({ children, label, description, trigger: triggerProp, open: openProp, defaultOpen, onOpenChange, validateOnClose, doneLabel = "Done", drawer, feedbackStatus, feedbackText,...formItemProps }) => {
|
|
27
|
+
const { label: effectiveLabel, description: desc, trigger, open, gapClass, hasError, shouldShake, handleOpenChange, requestClose } = require_use_overlay.useOverlay({
|
|
28
|
+
label,
|
|
29
|
+
description,
|
|
30
|
+
trigger: triggerProp,
|
|
31
|
+
open: openProp,
|
|
32
|
+
defaultOpen,
|
|
33
|
+
onOpenChange,
|
|
34
|
+
validateOnClose
|
|
35
|
+
});
|
|
36
|
+
const title = drawer?.title ?? effectiveLabel ?? "Details";
|
|
37
|
+
const overlayDescription = drawer?.description ?? desc;
|
|
38
|
+
const slots = drawer?.slots;
|
|
39
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.Drawer, {
|
|
40
|
+
open,
|
|
41
|
+
onOpenChange: handleOpenChange,
|
|
42
|
+
direction: drawer?.direction,
|
|
43
|
+
children: [
|
|
44
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_BaseFormItem.BaseFormItem, {
|
|
45
|
+
...formItemProps,
|
|
46
|
+
label,
|
|
47
|
+
description,
|
|
48
|
+
feedbackStatus,
|
|
49
|
+
feedbackText,
|
|
50
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DrawerTrigger, {
|
|
51
|
+
asChild: true,
|
|
52
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_OverlayTrigger.OverlayTrigger, {
|
|
53
|
+
invalid: hasError,
|
|
54
|
+
...trigger
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
}),
|
|
58
|
+
!open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_OverlayFields.OverlayFields, { children }),
|
|
59
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DrawerContent, {
|
|
60
|
+
...overlayDescription == null ? { "aria-describedby": void 0 } : {},
|
|
61
|
+
...slots?.content,
|
|
62
|
+
className: (0, __pixpilot_shadcn.cn)("sm:mx-auto sm:max-w-md", shouldShake && "pp-shake", slots?.content?.className),
|
|
63
|
+
onInteractOutside: (event) => {
|
|
64
|
+
slots?.content?.onInteractOutside?.(event);
|
|
65
|
+
if (event.defaultPrevented) return;
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
requestClose();
|
|
68
|
+
},
|
|
69
|
+
onEscapeKeyDown: (event) => {
|
|
70
|
+
slots?.content?.onEscapeKeyDown?.(event);
|
|
71
|
+
if (event.defaultPrevented) return;
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
requestClose();
|
|
74
|
+
},
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ShakeStyles.ShakeStyles, {}),
|
|
77
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DrawerHeader, {
|
|
78
|
+
...slots?.header,
|
|
79
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DrawerTitle, {
|
|
80
|
+
...slots?.title,
|
|
81
|
+
children: title
|
|
82
|
+
}), overlayDescription != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DrawerDescription, {
|
|
83
|
+
...slots?.description,
|
|
84
|
+
children: overlayDescription
|
|
85
|
+
})]
|
|
86
|
+
}),
|
|
87
|
+
open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DrawerBody, {
|
|
88
|
+
...slots?.body,
|
|
89
|
+
className: (0, __pixpilot_shadcn.cn)("grid py-1", gapClass, slots?.body?.className),
|
|
90
|
+
children: [children, feedbackText != null && feedbackText !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
91
|
+
className: (0, __pixpilot_shadcn.cn)("text-[0.8rem]", feedbackStatus === "error" && "text-destructive font-medium", feedbackStatus === "warning" && "text-amber-600", feedbackStatus === "success" && "text-green-600"),
|
|
92
|
+
children: feedbackText
|
|
93
|
+
})]
|
|
94
|
+
}),
|
|
95
|
+
doneLabel != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DrawerFooter, {
|
|
96
|
+
...slots?.footer,
|
|
97
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Button, {
|
|
98
|
+
type: "button",
|
|
99
|
+
"data-slot": "footer-button",
|
|
100
|
+
onClick: requestClose,
|
|
101
|
+
children: doneLabel
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
BaseDrawerItem.displayName = "BaseDrawerItem";
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
exports.BaseDrawerItem = BaseDrawerItem;
|