@pixpilot/formily-shadcn 1.16.0 → 1.17.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/date-picker/DatePicker.d.cts +3 -3
- package/dist/components/date-picker/DatePicker.d.ts +3 -3
- package/dist/components/dialog-item/BaseDialogItem.cjs +114 -0
- package/dist/components/dialog-item/BaseDialogItem.d.cts +56 -0
- package/dist/components/dialog-item/BaseDialogItem.d.ts +56 -0
- package/dist/components/dialog-item/BaseDialogItem.js +109 -0
- package/dist/components/dialog-item/ConnectedDialogItem.cjs +16 -0
- package/dist/components/dialog-item/ConnectedDialogItem.d.cts +15 -0
- package/dist/components/dialog-item/ConnectedDialogItem.d.ts +15 -0
- package/dist/components/dialog-item/ConnectedDialogItem.js +14 -0
- package/dist/components/dialog-item/index.cjs +2 -0
- package/dist/components/dialog-item/index.d.cts +2 -0
- package/dist/components/dialog-item/index.d.ts +2 -0
- package/dist/components/dialog-item/index.js +2 -0
- package/dist/components/dialog-item/mcp.js +127 -0
- package/dist/components/form/Form.d.cts +2 -2
- package/dist/components/form/Form.d.ts +2 -2
- package/dist/components/form-grid/FormGrid.d.cts +2 -2
- package/dist/components/form-grid/FormGrid.d.ts +2 -2
- package/dist/components/form-item/ConnectedFormItem.cjs +2 -34
- 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/ConnectedFormItem.js +3 -34
- package/dist/components/form-item/map-form-item-props.cjs +50 -0
- package/dist/components/form-item/map-form-item-props.js +47 -0
- package/dist/components/overlay-common/OverlayFields.cjs +26 -0
- package/dist/components/overlay-common/OverlayFields.d.cts +1 -0
- package/dist/components/overlay-common/OverlayFields.d.ts +1 -0
- package/dist/components/overlay-common/OverlayFields.js +24 -0
- package/dist/components/overlay-common/OverlayTrigger.cjs +27 -0
- package/dist/components/overlay-common/OverlayTrigger.d.cts +15 -0
- package/dist/components/overlay-common/OverlayTrigger.d.ts +15 -0
- package/dist/components/overlay-common/OverlayTrigger.js +23 -0
- package/dist/components/overlay-common/constants.cjs +10 -0
- package/dist/components/overlay-common/constants.js +9 -0
- package/dist/components/overlay-common/index.cjs +5 -0
- package/dist/components/overlay-common/index.d.cts +4 -0
- package/dist/components/overlay-common/index.d.ts +4 -0
- package/dist/components/overlay-common/index.js +5 -0
- package/dist/components/overlay-common/is-empty-field-value.cjs +23 -0
- package/dist/components/overlay-common/is-empty-field-value.js +22 -0
- package/dist/components/overlay-common/overlay-types.d.cts +27 -0
- package/dist/components/overlay-common/overlay-types.d.ts +27 -0
- package/dist/components/overlay-common/use-overlay.cjs +110 -0
- package/dist/components/overlay-common/use-overlay.d.cts +1 -0
- package/dist/components/overlay-common/use-overlay.d.ts +1 -0
- package/dist/components/overlay-common/use-overlay.js +107 -0
- package/dist/components/popover-item/BasePopoverItem.cjs +108 -0
- package/dist/components/popover-item/BasePopoverItem.d.cts +57 -0
- package/dist/components/popover-item/BasePopoverItem.d.ts +57 -0
- package/dist/components/popover-item/BasePopoverItem.js +104 -0
- package/dist/components/popover-item/ConnectedPopoverItem.cjs +16 -0
- package/dist/components/popover-item/ConnectedPopoverItem.d.cts +15 -0
- package/dist/components/popover-item/ConnectedPopoverItem.d.ts +15 -0
- package/dist/components/popover-item/ConnectedPopoverItem.js +14 -0
- package/dist/components/popover-item/index.cjs +2 -0
- package/dist/components/popover-item/index.d.cts +2 -0
- package/dist/components/popover-item/index.d.ts +2 -0
- package/dist/components/popover-item/index.js +2 -0
- package/dist/components/popover-item/mcp.js +127 -0
- package/dist/components/radio/Radio.d.ts +2 -2
- package/dist/components/row/Row.d.ts +2 -2
- package/dist/components/schema-field/schema-field-basics.cjs +8 -2
- package/dist/components/schema-field/schema-field-basics.d.cts +344 -270
- package/dist/components/schema-field/schema-field-basics.d.ts +337 -263
- package/dist/components/schema-field/schema-field-basics.js +8 -2
- package/dist/components/schema-field/schema-field-extended.d.cts +498 -424
- package/dist/components/schema-field/schema-field-extended.d.ts +480 -406
- package/dist/components/schema-field/schema-field.d.cts +425 -351
- package/dist/components/schema-field/schema-field.d.ts +425 -351
- package/dist/generated/mcp-registry.js +56 -52
- package/dist/index.cjs +12 -2
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +9 -3
- package/package.json +2 -2
|
@@ -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,12 +1,12 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react5 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$1:
|
|
6
|
+
declare const DatePicker$1: react5.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">> & react5.RefAttributes<unknown>>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { DatePicker$1 as DatePicker };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_ShakeStyles = require('../array-common/ShakeStyles.cjs');
|
|
3
|
+
require('../array-common/index.cjs');
|
|
4
|
+
const require_BaseFormItem = require('../form-item/BaseFormItem.cjs');
|
|
5
|
+
require('../form-item/index.cjs');
|
|
6
|
+
const require_OverlayFields = require('../overlay-common/OverlayFields.cjs');
|
|
7
|
+
const require_OverlayTrigger = require('../overlay-common/OverlayTrigger.cjs');
|
|
8
|
+
const require_use_overlay = require('../overlay-common/use-overlay.cjs');
|
|
9
|
+
require('../overlay-common/index.cjs');
|
|
10
|
+
let react = require("react");
|
|
11
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
12
|
+
let __pixpilot_shadcn_ui = require("@pixpilot/shadcn-ui");
|
|
13
|
+
__pixpilot_shadcn_ui = require_rolldown_runtime.__toESM(__pixpilot_shadcn_ui);
|
|
14
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
|
+
react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
16
|
+
let __pixpilot_shadcn = require("@pixpilot/shadcn");
|
|
17
|
+
__pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
18
|
+
|
|
19
|
+
//#region src/components/dialog-item/BaseDialogItem.tsx
|
|
20
|
+
/**
|
|
21
|
+
* Formily decorator that edits a single field inside a dialog.
|
|
22
|
+
*
|
|
23
|
+
* Used in place of FormItem (`x-decorator: 'DialogItem'`), it renders the
|
|
24
|
+
* field's label, description, and validation feedback exactly as FormItem
|
|
25
|
+
* does, but puts a trigger button where the input would sit and moves the
|
|
26
|
+
* input itself into a dialog. The field keeps its own component, so validation
|
|
27
|
+
* and x-reactions behave as they do under FormItem.
|
|
28
|
+
*/
|
|
29
|
+
const BaseDialogItem = ({ children, label, description, trigger: triggerProp, open: openProp, defaultOpen, onOpenChange, validateOnClose, doneLabel = "Done", dialog, feedbackStatus, feedbackText,...formItemProps }) => {
|
|
30
|
+
const { label: effectiveLabel, description: desc, trigger, open, gapClass, hasError, shouldShake, handleOpenChange, requestClose } = require_use_overlay.useOverlay({
|
|
31
|
+
label,
|
|
32
|
+
description,
|
|
33
|
+
trigger: triggerProp,
|
|
34
|
+
open: openProp,
|
|
35
|
+
defaultOpen,
|
|
36
|
+
onOpenChange,
|
|
37
|
+
validateOnClose
|
|
38
|
+
});
|
|
39
|
+
const title = dialog?.title ?? effectiveLabel ?? "Details";
|
|
40
|
+
const overlayDescription = dialog?.description ?? desc;
|
|
41
|
+
const slots = dialog?.slots;
|
|
42
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.Dialog, {
|
|
43
|
+
open,
|
|
44
|
+
onOpenChange: handleOpenChange,
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_BaseFormItem.BaseFormItem, {
|
|
47
|
+
...formItemProps,
|
|
48
|
+
label,
|
|
49
|
+
description,
|
|
50
|
+
feedbackStatus,
|
|
51
|
+
feedbackText,
|
|
52
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DialogTrigger, {
|
|
53
|
+
asChild: true,
|
|
54
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_OverlayTrigger.OverlayTrigger, {
|
|
55
|
+
invalid: hasError,
|
|
56
|
+
...trigger
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
}),
|
|
60
|
+
!open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_OverlayFields.OverlayFields, { children }),
|
|
61
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DialogContent, {
|
|
62
|
+
...overlayDescription == null ? { "aria-describedby": void 0 } : {},
|
|
63
|
+
...slots?.content,
|
|
64
|
+
className: (0, __pixpilot_shadcn.cn)("w-full xs:w-md", shouldShake && "pp-shake", slots?.content?.className),
|
|
65
|
+
onInteractOutside: (event) => {
|
|
66
|
+
slots?.content?.onInteractOutside?.(event);
|
|
67
|
+
if (event.defaultPrevented) return;
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
requestClose();
|
|
70
|
+
},
|
|
71
|
+
onEscapeKeyDown: (event) => {
|
|
72
|
+
slots?.content?.onEscapeKeyDown?.(event);
|
|
73
|
+
if (event.defaultPrevented) return;
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
requestClose();
|
|
76
|
+
},
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ShakeStyles.ShakeStyles, {}),
|
|
79
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DialogHeader, {
|
|
80
|
+
...slots?.header,
|
|
81
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DialogTitle, {
|
|
82
|
+
...slots?.title,
|
|
83
|
+
children: title
|
|
84
|
+
}), overlayDescription != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DialogDescription, {
|
|
85
|
+
...slots?.description,
|
|
86
|
+
children: overlayDescription
|
|
87
|
+
})]
|
|
88
|
+
}),
|
|
89
|
+
open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__pixpilot_shadcn_ui.DialogBody, {
|
|
90
|
+
...slots?.body,
|
|
91
|
+
className: (0, __pixpilot_shadcn.cn)("grid py-1", gapClass, slots?.body?.className),
|
|
92
|
+
children: [children, feedbackText != null && feedbackText !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
93
|
+
className: (0, __pixpilot_shadcn.cn)("text-[0.8rem]", feedbackStatus === "error" && "text-destructive font-medium", feedbackStatus === "warning" && "text-amber-600", feedbackStatus === "success" && "text-green-600"),
|
|
94
|
+
children: feedbackText
|
|
95
|
+
})]
|
|
96
|
+
}),
|
|
97
|
+
doneLabel != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.DialogFooter, {
|
|
98
|
+
...slots?.footer,
|
|
99
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.Button, {
|
|
100
|
+
type: "button",
|
|
101
|
+
"data-slot": "footer-button",
|
|
102
|
+
onClick: requestClose,
|
|
103
|
+
children: doneLabel
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
BaseDialogItem.displayName = "BaseDialogItem";
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
exports.BaseDialogItem = BaseDialogItem;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { SyncReactNode } from "../../types/react.cjs";
|
|
2
|
+
import { FormItemProps } from "../form-item/form-item-types.cjs";
|
|
3
|
+
import "../form-item/index.cjs";
|
|
4
|
+
import { OverlayBaseSlots, OverlayProps } from "../overlay-common/overlay-types.cjs";
|
|
5
|
+
import { OverlayTriggerProps } from "../overlay-common/OverlayTrigger.cjs";
|
|
6
|
+
import "../overlay-common/index.cjs";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { DialogContentProps } from "@pixpilot/shadcn-ui";
|
|
9
|
+
|
|
10
|
+
//#region src/components/dialog-item/BaseDialogItem.d.ts
|
|
11
|
+
interface DialogItemProps extends FormItemProps {
|
|
12
|
+
/**
|
|
13
|
+
* Props for the trigger button, e.g. `{ label: 'Write a bio' }`. Without a
|
|
14
|
+
* label it reads `Add <title>` when the field is empty and `Edit <title>`
|
|
15
|
+
* once it holds a value. Settable from an x-reaction via
|
|
16
|
+
* `decoratorProps.trigger`.
|
|
17
|
+
*/
|
|
18
|
+
trigger?: OverlayTriggerProps;
|
|
19
|
+
/** Controlled open state of the dialog. */
|
|
20
|
+
open?: boolean;
|
|
21
|
+
/** Initial open state when uncontrolled. */
|
|
22
|
+
defaultOpen?: boolean;
|
|
23
|
+
onOpenChange?: (open: boolean) => void;
|
|
24
|
+
/**
|
|
25
|
+
* When false, the dialog closes without validating the field first.
|
|
26
|
+
* Default is true.
|
|
27
|
+
*/
|
|
28
|
+
validateOnClose?: boolean;
|
|
29
|
+
/** Label of the button that closes the dialog. Set to `null` to hide the footer. */
|
|
30
|
+
doneLabel?: SyncReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* The dialog itself — its `title`, `description`, and `slots`, e.g.
|
|
33
|
+
* `{ title: 'Notes', slots: { content: { className: 'w-2xl' } } }`. Title and
|
|
34
|
+
* description default to the field's label and description.
|
|
35
|
+
*/
|
|
36
|
+
dialog?: DialogItemDialogProps;
|
|
37
|
+
}
|
|
38
|
+
interface DialogItemDialogSlots extends OverlayBaseSlots {
|
|
39
|
+
content?: DialogContentProps;
|
|
40
|
+
title?: React.ComponentProps<'div'>;
|
|
41
|
+
description?: React.ComponentProps<'div'>;
|
|
42
|
+
footer?: React.ComponentProps<'div'>;
|
|
43
|
+
}
|
|
44
|
+
type DialogItemDialogProps = OverlayProps<DialogItemDialogSlots>;
|
|
45
|
+
/**
|
|
46
|
+
* Formily decorator that edits a single field inside a dialog.
|
|
47
|
+
*
|
|
48
|
+
* Used in place of FormItem (`x-decorator: 'DialogItem'`), it renders the
|
|
49
|
+
* field's label, description, and validation feedback exactly as FormItem
|
|
50
|
+
* does, but puts a trigger button where the input would sit and moves the
|
|
51
|
+
* input itself into a dialog. The field keeps its own component, so validation
|
|
52
|
+
* and x-reactions behave as they do under FormItem.
|
|
53
|
+
*/
|
|
54
|
+
declare const BaseDialogItem: React.FC<React.PropsWithChildren<DialogItemProps>>;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { BaseDialogItem, DialogItemProps };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { SyncReactNode } from "../../types/react.js";
|
|
2
|
+
import { FormItemProps } from "../form-item/form-item-types.js";
|
|
3
|
+
import "../form-item/index.js";
|
|
4
|
+
import { OverlayBaseSlots, OverlayProps } from "../overlay-common/overlay-types.js";
|
|
5
|
+
import { OverlayTriggerProps } from "../overlay-common/OverlayTrigger.js";
|
|
6
|
+
import "../overlay-common/index.js";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { DialogContentProps } from "@pixpilot/shadcn-ui";
|
|
9
|
+
|
|
10
|
+
//#region src/components/dialog-item/BaseDialogItem.d.ts
|
|
11
|
+
interface DialogItemProps extends FormItemProps {
|
|
12
|
+
/**
|
|
13
|
+
* Props for the trigger button, e.g. `{ label: 'Write a bio' }`. Without a
|
|
14
|
+
* label it reads `Add <title>` when the field is empty and `Edit <title>`
|
|
15
|
+
* once it holds a value. Settable from an x-reaction via
|
|
16
|
+
* `decoratorProps.trigger`.
|
|
17
|
+
*/
|
|
18
|
+
trigger?: OverlayTriggerProps;
|
|
19
|
+
/** Controlled open state of the dialog. */
|
|
20
|
+
open?: boolean;
|
|
21
|
+
/** Initial open state when uncontrolled. */
|
|
22
|
+
defaultOpen?: boolean;
|
|
23
|
+
onOpenChange?: (open: boolean) => void;
|
|
24
|
+
/**
|
|
25
|
+
* When false, the dialog closes without validating the field first.
|
|
26
|
+
* Default is true.
|
|
27
|
+
*/
|
|
28
|
+
validateOnClose?: boolean;
|
|
29
|
+
/** Label of the button that closes the dialog. Set to `null` to hide the footer. */
|
|
30
|
+
doneLabel?: SyncReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* The dialog itself — its `title`, `description`, and `slots`, e.g.
|
|
33
|
+
* `{ title: 'Notes', slots: { content: { className: 'w-2xl' } } }`. Title and
|
|
34
|
+
* description default to the field's label and description.
|
|
35
|
+
*/
|
|
36
|
+
dialog?: DialogItemDialogProps;
|
|
37
|
+
}
|
|
38
|
+
interface DialogItemDialogSlots extends OverlayBaseSlots {
|
|
39
|
+
content?: DialogContentProps;
|
|
40
|
+
title?: React.ComponentProps<'div'>;
|
|
41
|
+
description?: React.ComponentProps<'div'>;
|
|
42
|
+
footer?: React.ComponentProps<'div'>;
|
|
43
|
+
}
|
|
44
|
+
type DialogItemDialogProps = OverlayProps<DialogItemDialogSlots>;
|
|
45
|
+
/**
|
|
46
|
+
* Formily decorator that edits a single field inside a dialog.
|
|
47
|
+
*
|
|
48
|
+
* Used in place of FormItem (`x-decorator: 'DialogItem'`), it renders the
|
|
49
|
+
* field's label, description, and validation feedback exactly as FormItem
|
|
50
|
+
* does, but puts a trigger button where the input would sit and moves the
|
|
51
|
+
* input itself into a dialog. The field keeps its own component, so validation
|
|
52
|
+
* and x-reactions behave as they do under FormItem.
|
|
53
|
+
*/
|
|
54
|
+
declare const BaseDialogItem: React.FC<React.PropsWithChildren<DialogItemProps>>;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { BaseDialogItem, DialogItemProps };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ShakeStyles } from "../array-common/ShakeStyles.js";
|
|
2
|
+
import "../array-common/index.js";
|
|
3
|
+
import { BaseFormItem } from "../form-item/BaseFormItem.js";
|
|
4
|
+
import "../form-item/index.js";
|
|
5
|
+
import { OverlayFields } from "../overlay-common/OverlayFields.js";
|
|
6
|
+
import { OverlayTrigger } from "../overlay-common/OverlayTrigger.js";
|
|
7
|
+
import { useOverlay } from "../overlay-common/use-overlay.js";
|
|
8
|
+
import "../overlay-common/index.js";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { Button, Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@pixpilot/shadcn-ui";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { cn as cn$1 } from "@pixpilot/shadcn";
|
|
13
|
+
|
|
14
|
+
//#region src/components/dialog-item/BaseDialogItem.tsx
|
|
15
|
+
/**
|
|
16
|
+
* Formily decorator that edits a single field inside a dialog.
|
|
17
|
+
*
|
|
18
|
+
* Used in place of FormItem (`x-decorator: 'DialogItem'`), it renders the
|
|
19
|
+
* field's label, description, and validation feedback exactly as FormItem
|
|
20
|
+
* does, but puts a trigger button where the input would sit and moves the
|
|
21
|
+
* input itself into a dialog. The field keeps its own component, so validation
|
|
22
|
+
* and x-reactions behave as they do under FormItem.
|
|
23
|
+
*/
|
|
24
|
+
const BaseDialogItem = ({ children, label, description, trigger: triggerProp, open: openProp, defaultOpen, onOpenChange, validateOnClose, doneLabel = "Done", dialog, feedbackStatus, feedbackText,...formItemProps }) => {
|
|
25
|
+
const { label: effectiveLabel, description: desc, trigger, open, gapClass, hasError, shouldShake, handleOpenChange, requestClose } = useOverlay({
|
|
26
|
+
label,
|
|
27
|
+
description,
|
|
28
|
+
trigger: triggerProp,
|
|
29
|
+
open: openProp,
|
|
30
|
+
defaultOpen,
|
|
31
|
+
onOpenChange,
|
|
32
|
+
validateOnClose
|
|
33
|
+
});
|
|
34
|
+
const title = dialog?.title ?? effectiveLabel ?? "Details";
|
|
35
|
+
const overlayDescription = dialog?.description ?? desc;
|
|
36
|
+
const slots = dialog?.slots;
|
|
37
|
+
return /* @__PURE__ */ jsxs(Dialog, {
|
|
38
|
+
open,
|
|
39
|
+
onOpenChange: handleOpenChange,
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx(BaseFormItem, {
|
|
42
|
+
...formItemProps,
|
|
43
|
+
label,
|
|
44
|
+
description,
|
|
45
|
+
feedbackStatus,
|
|
46
|
+
feedbackText,
|
|
47
|
+
children: /* @__PURE__ */ jsx(DialogTrigger, {
|
|
48
|
+
asChild: true,
|
|
49
|
+
children: /* @__PURE__ */ jsx(OverlayTrigger, {
|
|
50
|
+
invalid: hasError,
|
|
51
|
+
...trigger
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
}),
|
|
55
|
+
!open && /* @__PURE__ */ jsx(OverlayFields, { children }),
|
|
56
|
+
/* @__PURE__ */ jsxs(DialogContent, {
|
|
57
|
+
...overlayDescription == null ? { "aria-describedby": void 0 } : {},
|
|
58
|
+
...slots?.content,
|
|
59
|
+
className: cn$1("w-full xs:w-md", shouldShake && "pp-shake", slots?.content?.className),
|
|
60
|
+
onInteractOutside: (event) => {
|
|
61
|
+
slots?.content?.onInteractOutside?.(event);
|
|
62
|
+
if (event.defaultPrevented) return;
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
requestClose();
|
|
65
|
+
},
|
|
66
|
+
onEscapeKeyDown: (event) => {
|
|
67
|
+
slots?.content?.onEscapeKeyDown?.(event);
|
|
68
|
+
if (event.defaultPrevented) return;
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
requestClose();
|
|
71
|
+
},
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx(ShakeStyles, {}),
|
|
74
|
+
/* @__PURE__ */ jsxs(DialogHeader, {
|
|
75
|
+
...slots?.header,
|
|
76
|
+
children: [/* @__PURE__ */ jsx(DialogTitle, {
|
|
77
|
+
...slots?.title,
|
|
78
|
+
children: title
|
|
79
|
+
}), overlayDescription != null && /* @__PURE__ */ jsx(DialogDescription, {
|
|
80
|
+
...slots?.description,
|
|
81
|
+
children: overlayDescription
|
|
82
|
+
})]
|
|
83
|
+
}),
|
|
84
|
+
open && /* @__PURE__ */ jsxs(DialogBody, {
|
|
85
|
+
...slots?.body,
|
|
86
|
+
className: cn$1("grid py-1", gapClass, slots?.body?.className),
|
|
87
|
+
children: [children, feedbackText != null && feedbackText !== "" && /* @__PURE__ */ jsx("p", {
|
|
88
|
+
className: cn$1("text-[0.8rem]", feedbackStatus === "error" && "text-destructive font-medium", feedbackStatus === "warning" && "text-amber-600", feedbackStatus === "success" && "text-green-600"),
|
|
89
|
+
children: feedbackText
|
|
90
|
+
})]
|
|
91
|
+
}),
|
|
92
|
+
doneLabel != null && /* @__PURE__ */ jsx(DialogFooter, {
|
|
93
|
+
...slots?.footer,
|
|
94
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
95
|
+
type: "button",
|
|
96
|
+
"data-slot": "footer-button",
|
|
97
|
+
onClick: requestClose,
|
|
98
|
+
children: doneLabel
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
BaseDialogItem.displayName = "BaseDialogItem";
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { BaseDialogItem };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_map_form_item_props = require('../form-item/map-form-item-props.cjs');
|
|
3
|
+
const require_BaseDialogItem = require('./BaseDialogItem.cjs');
|
|
4
|
+
let __formily_react = require("@formily/react");
|
|
5
|
+
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
6
|
+
|
|
7
|
+
//#region src/components/dialog-item/ConnectedDialogItem.tsx
|
|
8
|
+
/**
|
|
9
|
+
* DialogItem decorator connected to Formily field state.
|
|
10
|
+
* Maps field label, description, and validation state onto the decorator the
|
|
11
|
+
* same way FormItem does.
|
|
12
|
+
*/
|
|
13
|
+
const DialogItem = (0, __formily_react.connect)(require_BaseDialogItem.BaseDialogItem, (0, __formily_react.mapProps)(require_map_form_item_props.mapFormItemProps));
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.DialogItem = DialogItem;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DialogItemProps } from "./BaseDialogItem.cjs";
|
|
2
|
+
import * as react0 from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/dialog-item/ConnectedDialogItem.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* DialogItem decorator connected to Formily field state.
|
|
8
|
+
* Maps field label, description, and validation state onto the decorator the
|
|
9
|
+
* same way FormItem does.
|
|
10
|
+
*/
|
|
11
|
+
declare const DialogItem: react0.ForwardRefExoticComponent<Omit<Partial<DialogItemProps & {
|
|
12
|
+
children?: react0.ReactNode | undefined;
|
|
13
|
+
}>, "ref"> & react0.RefAttributes<unknown>>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DialogItem };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DialogItemProps } from "./BaseDialogItem.js";
|
|
2
|
+
import * as react2 from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/dialog-item/ConnectedDialogItem.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* DialogItem decorator connected to Formily field state.
|
|
8
|
+
* Maps field label, description, and validation state onto the decorator the
|
|
9
|
+
* same way FormItem does.
|
|
10
|
+
*/
|
|
11
|
+
declare const DialogItem: react2.ForwardRefExoticComponent<Omit<Partial<DialogItemProps & {
|
|
12
|
+
children?: react2.ReactNode | undefined;
|
|
13
|
+
}>, "ref"> & react2.RefAttributes<unknown>>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DialogItem };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { mapFormItemProps } from "../form-item/map-form-item-props.js";
|
|
2
|
+
import { BaseDialogItem } from "./BaseDialogItem.js";
|
|
3
|
+
import { connect, mapProps } from "@formily/react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/dialog-item/ConnectedDialogItem.tsx
|
|
6
|
+
/**
|
|
7
|
+
* DialogItem decorator connected to Formily field state.
|
|
8
|
+
* Maps field label, description, and validation state onto the decorator the
|
|
9
|
+
* same way FormItem does.
|
|
10
|
+
*/
|
|
11
|
+
const DialogItem = connect(BaseDialogItem, mapProps(mapFormItemProps));
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { DialogItem };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { defineProps } from "../../mcp/src/utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/dialog-item/mcp.ts
|
|
4
|
+
const meta = {
|
|
5
|
+
name: "DialogItem",
|
|
6
|
+
category: "Formily",
|
|
7
|
+
description: "A Formily decorator used in place of FormItem (`x-decorator: 'DialogItem'`). It renders the field's label, description, and validation feedback like FormItem, but puts a trigger button where the input would sit and moves the field's own component into a dialog.",
|
|
8
|
+
htmlElement: "div",
|
|
9
|
+
props: defineProps({
|
|
10
|
+
label: "Label content or accessible label for the component.",
|
|
11
|
+
description: "Description content rendered with the component.",
|
|
12
|
+
trigger: {
|
|
13
|
+
description: "Props for the trigger button, e.g. `{ label: 'Write a bio' }`. Without a label it reads `Add <title>` while the field is empty and `Edit <title>` once it holds a value (`item` when the field has no title). Accepts the button's other props too (`icon`, `className`, …). An x-reaction can set this via `decoratorProps.trigger`.",
|
|
14
|
+
defaultValue: "`Add <title>` / `Edit <title>`"
|
|
15
|
+
},
|
|
16
|
+
open: {
|
|
17
|
+
description: "Controlled open state of the dialog.",
|
|
18
|
+
type: "boolean"
|
|
19
|
+
},
|
|
20
|
+
defaultOpen: {
|
|
21
|
+
description: "Initial open state when uncontrolled.",
|
|
22
|
+
type: "boolean",
|
|
23
|
+
defaultValue: "false"
|
|
24
|
+
},
|
|
25
|
+
onOpenChange: "Called when the dialog open state changes.",
|
|
26
|
+
validateOnClose: {
|
|
27
|
+
description: "When true (default), closing validates the field and keeps the dialog open (with a shake) while it is invalid. Set false to always close.",
|
|
28
|
+
type: "boolean",
|
|
29
|
+
defaultValue: "true"
|
|
30
|
+
},
|
|
31
|
+
doneLabel: {
|
|
32
|
+
description: "Label of the button that closes the dialog. Set to `null` to hide the footer.",
|
|
33
|
+
defaultValue: `'Done'`
|
|
34
|
+
},
|
|
35
|
+
dialog: "The dialog itself: `{ title, description, slots }`, e.g. `{ title: 'Notes', slots: { content: { className: 'w-2xl' } } }`. Title and description default to the field's label and description; `slots` takes props for `content`, `header`, `title`, `description`, `body`, and `footer`.",
|
|
36
|
+
slots: "Slot props forwarded to the FormItem parts (label, description, error).",
|
|
37
|
+
descriptionPlacement: "Forwarded to the underlying FormItem.",
|
|
38
|
+
requiredMark: "Forwarded to the underlying FormItem.",
|
|
39
|
+
asterisk: "Forwarded to the underlying FormItem.",
|
|
40
|
+
feedbackStatus: "Forwarded to the underlying FormItem.",
|
|
41
|
+
feedbackText: "Forwarded to the underlying FormItem."
|
|
42
|
+
}),
|
|
43
|
+
examples: [
|
|
44
|
+
{
|
|
45
|
+
title: "Edit a single field in a dialog",
|
|
46
|
+
code: `{
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
age: {
|
|
50
|
+
type: 'number',
|
|
51
|
+
title: 'Age',
|
|
52
|
+
description: 'Enter your age in years.',
|
|
53
|
+
default: 25,
|
|
54
|
+
'x-decorator': 'DialogItem',
|
|
55
|
+
'x-component': 'NumberInput',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}`
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: "Declarative schema field",
|
|
62
|
+
code: `<SchemaField.String name="bio" title="Bio" x-decorator="DialogItem" x-component="Textarea" />`
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: "Trigger label driven by an x-reaction",
|
|
66
|
+
code: `{
|
|
67
|
+
type: 'string',
|
|
68
|
+
title: 'Bio',
|
|
69
|
+
'x-decorator': 'DialogItem',
|
|
70
|
+
'x-component': 'Textarea',
|
|
71
|
+
// Decorator props come from decoratorProps, not componentProps.
|
|
72
|
+
'x-reactions': {
|
|
73
|
+
fulfill: {
|
|
74
|
+
state: {
|
|
75
|
+
decoratorProps: {
|
|
76
|
+
trigger: {
|
|
77
|
+
label: "{{$self.value ? 'Edit bio' : 'Write a bio'}}",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
}`
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
title: "A whole object edited in one dialog",
|
|
87
|
+
code: `{
|
|
88
|
+
type: 'object',
|
|
89
|
+
title: 'Profile',
|
|
90
|
+
'x-decorator': 'DialogItem',
|
|
91
|
+
// type: 'object' resolves to ObjectContainer. Turn off its own label and
|
|
92
|
+
// description — the dialog header already shows them — and use the flat
|
|
93
|
+
// variant so the card chrome does not double up inside the dialog.
|
|
94
|
+
'x-component-props': { variant: 'flat', label: false, description: false },
|
|
95
|
+
properties: {
|
|
96
|
+
firstName: { type: 'string', title: 'First Name' },
|
|
97
|
+
lastName: { type: 'string', title: 'Last Name', required: true },
|
|
98
|
+
},
|
|
99
|
+
}`
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
notes: [
|
|
103
|
+
"Works on an object too: decorating a `type: object` field puts its whole form in the dialog, and closing validates every field inside it, at any depth.",
|
|
104
|
+
"Swap in for FormItem on any field — the field keeps its own `x-component`, so validation, x-reactions, and component props behave exactly as under FormItem.",
|
|
105
|
+
"Edits commit to the form as the user types; there is no draft/Save step. The footer button closes the dialog rather than saving.",
|
|
106
|
+
"Closing (Done, Escape, outside click, or the X) validates the field first. An invalid field keeps the dialog open and shakes it.",
|
|
107
|
+
"While the dialog is closed the input stays mounted in a hidden container, so component state and reactions behave as if it were always rendered.",
|
|
108
|
+
"The trigger renders in an error state, and the label turns red, while the field has a validation error — the message appears under the trigger and inside the dialog.",
|
|
109
|
+
"The dialog heading defaults to the field label; override with `dialog.title` / `dialog.description`."
|
|
110
|
+
],
|
|
111
|
+
keywords: [
|
|
112
|
+
"formily",
|
|
113
|
+
"decorator",
|
|
114
|
+
"dialog",
|
|
115
|
+
"modal",
|
|
116
|
+
"field",
|
|
117
|
+
"form-item"
|
|
118
|
+
],
|
|
119
|
+
related: [
|
|
120
|
+
"FormItem",
|
|
121
|
+
"PopoverItem",
|
|
122
|
+
"ObjectContainer"
|
|
123
|
+
]
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
export { meta };
|
|
@@ -2,7 +2,7 @@ import { FormContextStates } from "../context/form-context.cjs";
|
|
|
2
2
|
import "../context/index.cjs";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { Form } from "@formily/core";
|
|
5
|
-
import * as
|
|
5
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/form/Form.d.ts
|
|
8
8
|
interface IFormProps extends FormContextStates {
|
|
@@ -27,6 +27,6 @@ declare function Form$1({
|
|
|
27
27
|
onAutoSubmit,
|
|
28
28
|
layout,
|
|
29
29
|
settings
|
|
30
|
-
}: IFormProps):
|
|
30
|
+
}: IFormProps): react_jsx_runtime1.JSX.Element;
|
|
31
31
|
//#endregion
|
|
32
32
|
export { Form$1 as Form, IFormProps };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FormContextStates } from "../context/form-context.js";
|
|
2
2
|
import "../context/index.js";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import * as
|
|
4
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
5
5
|
import { Form } from "@formily/core";
|
|
6
6
|
|
|
7
7
|
//#region src/components/form/Form.d.ts
|
|
@@ -27,6 +27,6 @@ declare function Form$1({
|
|
|
27
27
|
onAutoSubmit,
|
|
28
28
|
layout,
|
|
29
29
|
settings
|
|
30
|
-
}: IFormProps):
|
|
30
|
+
}: IFormProps): react_jsx_runtime1.JSX.Element;
|
|
31
31
|
//#endregion
|
|
32
32
|
export { Form$1 as Form, IFormProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/form-grid/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_runtime0.JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { FormGrid, IFormGridProps };
|
|
@@ -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/form-grid/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_runtime3.JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { FormGrid, IFormGridProps };
|