@pixpilot/formily-shadcn 1.12.8 → 1.13.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/Checkbox.d.cts +2 -2
- package/dist/components/DatePicker.d.cts +3 -3
- package/dist/components/Form.cjs +1 -1
- package/dist/components/Form.js +1 -1
- package/dist/components/IconPicker.d.ts +3 -3
- package/dist/components/IconToggle.d.ts +2 -2
- package/dist/components/Input.d.ts +3 -3
- package/dist/components/context/types.d.cts +5 -8
- package/dist/components/context/types.d.ts +5 -8
- package/dist/components/form-item/BaseFormItem.cjs +6 -6
- package/dist/components/form-item/BaseFormItem.js +6 -6
- package/dist/components/form-item/ConnectedFormItem.cjs +6 -8
- package/dist/components/form-item/ConnectedFormItem.js +6 -8
- package/dist/components/form-item/FormItem.d.cts +1 -1
- package/dist/components/form-item/FormItem.d.ts +1 -1
- package/dist/components/form-item/FormItemLabel.cjs +5 -4
- package/dist/components/form-item/FormItemLabel.js +5 -4
- package/dist/components/form-item/form-item-types.d.cts +8 -1
- package/dist/components/form-item/form-item-types.d.ts +8 -1
- package/dist/components/form-item/index.d.cts +1 -1
- package/dist/components/form-item/index.d.ts +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/types/form-item.d.cts +1 -2
- package/dist/types/form-item.d.ts +1 -2
- package/dist/utils/resolve-responsive-space.cjs +6 -6
- package/dist/utils/resolve-responsive-space.js +6 -6
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react1 from "react";
|
|
2
2
|
import * as _radix_ui_react_checkbox0 from "@radix-ui/react-checkbox";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Checkbox.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _radix_ui_react_checkbox0 from "@radix-ui/react-checkbox";
|
|
|
6
6
|
* Formily-connected Checkbox component
|
|
7
7
|
* Maps Formily field checked state to shadcn Checkbox
|
|
8
8
|
*/
|
|
9
|
-
declare const Checkbox:
|
|
9
|
+
declare const Checkbox: react1.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_checkbox0.CheckboxProps & react1.RefAttributes<HTMLButtonElement>>, "ref"> & react1.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Checkbox };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react0 from "react";
|
|
2
2
|
import { DatePickerProps } from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/DatePicker.d.ts
|
|
5
|
-
declare const DatePicker:
|
|
5
|
+
declare const DatePicker: react0.ForwardRefExoticComponent<Partial<{
|
|
6
6
|
value?: Date;
|
|
7
7
|
onChange?: (date: Date | undefined) => void;
|
|
8
8
|
placeholder?: string;
|
|
9
|
-
} & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> &
|
|
9
|
+
} & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react0.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { DatePicker };
|
package/dist/components/Form.cjs
CHANGED
|
@@ -35,7 +35,7 @@ function Form({ form, id, className, style, children, onSubmit, onAutoSubmit, la
|
|
|
35
35
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FormItemContainer.FormItemContainer, {
|
|
36
36
|
as: "form",
|
|
37
37
|
id,
|
|
38
|
-
className: (0, __pixpilot_shadcn.cn)(className),
|
|
38
|
+
className: (0, __pixpilot_shadcn.cn)("flex flex-col", className),
|
|
39
39
|
style,
|
|
40
40
|
onSubmit: handleSubmit,
|
|
41
41
|
children
|
package/dist/components/Form.js
CHANGED
|
@@ -30,7 +30,7 @@ function Form({ form, id, className, style, children, onSubmit, onAutoSubmit, la
|
|
|
30
30
|
children: /* @__PURE__ */ jsx(FormItemContainer, {
|
|
31
31
|
as: "form",
|
|
32
32
|
id,
|
|
33
|
-
className: cn(className),
|
|
33
|
+
className: cn("flex flex-col", className),
|
|
34
34
|
style,
|
|
35
35
|
onSubmit: handleSubmit,
|
|
36
36
|
children
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react11 from "react";
|
|
2
2
|
import { IconPickerProps, IconProviderProps } from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/IconPicker.d.ts
|
|
@@ -8,8 +8,8 @@ import { IconPickerProps, IconProviderProps } from "@pixpilot/shadcn-ui";
|
|
|
8
8
|
* Automatically connects to Formily field state
|
|
9
9
|
* Supports both static and async icon providers
|
|
10
10
|
*/
|
|
11
|
-
declare const IconPicker$1:
|
|
11
|
+
declare const IconPicker$1: react11.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
|
|
12
12
|
providers?: IconProviderProps[];
|
|
13
|
-
}> &
|
|
13
|
+
}> & react11.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { IconPicker$1 as IconPicker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react8 from "react";
|
|
2
2
|
import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/IconToggle.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
|
6
6
|
* Formily-connected IconToggle component
|
|
7
7
|
* Toggle button with customizable icons for boolean values
|
|
8
8
|
*/
|
|
9
|
-
declare const IconToggle$1:
|
|
9
|
+
declare const IconToggle$1: react8.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui0.IconToggleProps, "ref"> & react8.RefAttributes<HTMLButtonElement>>, "ref"> & react8.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { IconToggle$1 as IconToggle };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react4 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/Input.d.ts
|
|
4
4
|
|
|
@@ -6,12 +6,12 @@ import * as react9 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: react4.ForwardRefExoticComponent<Omit<Partial<react4.ClassAttributes<HTMLInputElement> & react4.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"> & react4.RefAttributes<unknown>>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { Input };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ActionItem } from "../array-base/types.cjs";
|
|
2
2
|
import "../array-base/index.cjs";
|
|
3
3
|
import { FormSpace } from "../../types/form.cjs";
|
|
4
|
-
import { DescriptionPlacement, LabelPlacement } from "../../types/form-item.cjs";
|
|
5
4
|
import { FormFileUploadOptions } from "../file-upload/types.cjs";
|
|
6
5
|
import "../file-upload/index.cjs";
|
|
6
|
+
import { FormItemDescriptionProps, FormItemLabelProps } from "../form-item/form-item-types.cjs";
|
|
7
|
+
import "../form-item/index.cjs";
|
|
7
8
|
import { DialogContentProps, IconProvider, PopoverContentProps, RichTextEditorProps } from "@pixpilot/shadcn-ui";
|
|
8
9
|
|
|
9
10
|
//#region src/components/context/types.d.ts
|
|
@@ -53,14 +54,10 @@ interface FormSettings {
|
|
|
53
54
|
interface FormLayoutOptions {
|
|
54
55
|
/** Form density - affects spacing between elements */
|
|
55
56
|
density?: FormSpace['density'];
|
|
56
|
-
/**
|
|
57
|
-
descriptionPlacement?: DescriptionPlacement;
|
|
58
|
-
/** Default label placement for FormItem decorators */
|
|
59
|
-
labelPlacement?: LabelPlacement;
|
|
60
|
-
/** Custom class names for FormItem elements */
|
|
57
|
+
/** Custom props for FormItem elements */
|
|
61
58
|
itemProps?: {
|
|
62
|
-
label?:
|
|
63
|
-
description?:
|
|
59
|
+
label?: FormItemLabelProps;
|
|
60
|
+
description?: FormItemDescriptionProps;
|
|
64
61
|
inputWrapper?: React.HTMLAttributes<HTMLDivElement>;
|
|
65
62
|
error?: React.HTMLAttributes<HTMLParagraphElement>;
|
|
66
63
|
container?: React.HTMLAttributes<HTMLDivElement>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ActionItem } from "../array-base/types.js";
|
|
2
2
|
import "../array-base/index.js";
|
|
3
3
|
import { FormSpace } from "../../types/form.js";
|
|
4
|
-
import { DescriptionPlacement, LabelPlacement } from "../../types/form-item.js";
|
|
5
4
|
import { FormFileUploadOptions } from "../file-upload/types.js";
|
|
6
5
|
import "../file-upload/index.js";
|
|
6
|
+
import { FormItemDescriptionProps, FormItemLabelProps } from "../form-item/form-item-types.js";
|
|
7
|
+
import "../form-item/index.js";
|
|
7
8
|
import { DialogContentProps, IconProvider, PopoverContentProps, RichTextEditorProps } from "@pixpilot/shadcn-ui";
|
|
8
9
|
|
|
9
10
|
//#region src/components/context/types.d.ts
|
|
@@ -53,14 +54,10 @@ interface FormSettings {
|
|
|
53
54
|
interface FormLayoutOptions {
|
|
54
55
|
/** Form density - affects spacing between elements */
|
|
55
56
|
density?: FormSpace['density'];
|
|
56
|
-
/**
|
|
57
|
-
descriptionPlacement?: DescriptionPlacement;
|
|
58
|
-
/** Default label placement for FormItem decorators */
|
|
59
|
-
labelPlacement?: LabelPlacement;
|
|
60
|
-
/** Custom class names for FormItem elements */
|
|
57
|
+
/** Custom props for FormItem elements */
|
|
61
58
|
itemProps?: {
|
|
62
|
-
label?:
|
|
63
|
-
description?:
|
|
59
|
+
label?: FormItemLabelProps;
|
|
60
|
+
description?: FormItemDescriptionProps;
|
|
64
61
|
inputWrapper?: React.HTMLAttributes<HTMLDivElement>;
|
|
65
62
|
error?: React.HTMLAttributes<HTMLParagraphElement>;
|
|
66
63
|
container?: React.HTMLAttributes<HTMLDivElement>;
|
|
@@ -19,7 +19,7 @@ __pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
|
19
19
|
function resolveLegacyDescriptionPlacement(labelPlacement) {
|
|
20
20
|
return labelPlacement === "top" ? "top" : "bottom";
|
|
21
21
|
}
|
|
22
|
-
const BaseFormItem = ({ className, children, label, description, descriptionPlacement, asterisk, feedbackStatus, feedbackText, slots,...props }) => {
|
|
22
|
+
const BaseFormItem = ({ className, children, label, description, descriptionPlacement, requiredMark, asterisk, feedbackStatus, feedbackText, slots,...props }) => {
|
|
23
23
|
const field = (0, __formily_react.useField)();
|
|
24
24
|
const fieldDecoratorProps = field?.decoratorProps;
|
|
25
25
|
const fieldComponentProps = field?.componentProps;
|
|
@@ -29,8 +29,8 @@ const BaseFormItem = ({ className, children, label, description, descriptionPlac
|
|
|
29
29
|
const effectiveLabel = require_use_label.useLabel(label);
|
|
30
30
|
const { layout } = require_use_form_context.useFormContext();
|
|
31
31
|
const itemComponentsProps = layout?.itemProps || {};
|
|
32
|
-
const contextDescriptionPlacement =
|
|
33
|
-
const contextLabelPlacement =
|
|
32
|
+
const { placement: contextDescriptionPlacement,...itemDescriptionProps } = itemComponentsProps.description ?? {};
|
|
33
|
+
const contextLabelPlacement = itemComponentsProps.label?.placement;
|
|
34
34
|
const fieldLabelPlacement = fieldLabelProps?.placement ?? fieldDecoratorProps?.labelPlacement ?? fieldComponentProps?.labelPlacement;
|
|
35
35
|
const propLabelPlacement = slots?.label?.placement;
|
|
36
36
|
const effectiveLabelPlacement = fieldLabelPlacement ?? propLabelPlacement ?? contextLabelPlacement ?? "top";
|
|
@@ -45,7 +45,7 @@ const BaseFormItem = ({ className, children, label, description, descriptionPlac
|
|
|
45
45
|
"data-slot": "form-item-label",
|
|
46
46
|
id: (0, __pixpilot_shadcn_ui.getId)(id, "label"),
|
|
47
47
|
label: effectiveLabel,
|
|
48
|
-
asterisk,
|
|
48
|
+
requiredMark: requiredMark !== void 0 ? requiredMark : asterisk,
|
|
49
49
|
error: feedbackStatus === "error",
|
|
50
50
|
shrink: effectiveLabelPlacement === "end" || effectiveLabelPlacement === "start",
|
|
51
51
|
labelProps: {
|
|
@@ -70,10 +70,10 @@ const BaseFormItem = ({ className, children, label, description, descriptionPlac
|
|
|
70
70
|
});
|
|
71
71
|
const descriptionElement = descriptionRenderedInline ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
72
72
|
"data-slot": "form-item-description",
|
|
73
|
-
...
|
|
73
|
+
...itemDescriptionProps,
|
|
74
74
|
...slots?.description,
|
|
75
75
|
id: descriptionId,
|
|
76
|
-
className: (0, __pixpilot_shadcn.cn)("text-muted-foreground text-[0.8rem]", spacingConfig.description,
|
|
76
|
+
className: (0, __pixpilot_shadcn.cn)("text-muted-foreground text-[0.8rem]", spacingConfig.description, itemDescriptionProps.className, slots?.description?.className),
|
|
77
77
|
children: description
|
|
78
78
|
}) : null;
|
|
79
79
|
const contentElement = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
@@ -13,7 +13,7 @@ import { cn as cn$1 } from "@pixpilot/shadcn";
|
|
|
13
13
|
function resolveLegacyDescriptionPlacement(labelPlacement) {
|
|
14
14
|
return labelPlacement === "top" ? "top" : "bottom";
|
|
15
15
|
}
|
|
16
|
-
const BaseFormItem = ({ className, children, label, description, descriptionPlacement, asterisk, feedbackStatus, feedbackText, slots,...props }) => {
|
|
16
|
+
const BaseFormItem = ({ className, children, label, description, descriptionPlacement, requiredMark, asterisk, feedbackStatus, feedbackText, slots,...props }) => {
|
|
17
17
|
const field = useField();
|
|
18
18
|
const fieldDecoratorProps = field?.decoratorProps;
|
|
19
19
|
const fieldComponentProps = field?.componentProps;
|
|
@@ -23,8 +23,8 @@ const BaseFormItem = ({ className, children, label, description, descriptionPlac
|
|
|
23
23
|
const effectiveLabel = useLabel(label);
|
|
24
24
|
const { layout } = useFormContext();
|
|
25
25
|
const itemComponentsProps = layout?.itemProps || {};
|
|
26
|
-
const contextDescriptionPlacement =
|
|
27
|
-
const contextLabelPlacement =
|
|
26
|
+
const { placement: contextDescriptionPlacement,...itemDescriptionProps } = itemComponentsProps.description ?? {};
|
|
27
|
+
const contextLabelPlacement = itemComponentsProps.label?.placement;
|
|
28
28
|
const fieldLabelPlacement = fieldLabelProps?.placement ?? fieldDecoratorProps?.labelPlacement ?? fieldComponentProps?.labelPlacement;
|
|
29
29
|
const propLabelPlacement = slots?.label?.placement;
|
|
30
30
|
const effectiveLabelPlacement = fieldLabelPlacement ?? propLabelPlacement ?? contextLabelPlacement ?? "top";
|
|
@@ -39,7 +39,7 @@ const BaseFormItem = ({ className, children, label, description, descriptionPlac
|
|
|
39
39
|
"data-slot": "form-item-label",
|
|
40
40
|
id: getId(id, "label"),
|
|
41
41
|
label: effectiveLabel,
|
|
42
|
-
asterisk,
|
|
42
|
+
requiredMark: requiredMark !== void 0 ? requiredMark : asterisk,
|
|
43
43
|
error: feedbackStatus === "error",
|
|
44
44
|
shrink: effectiveLabelPlacement === "end" || effectiveLabelPlacement === "start",
|
|
45
45
|
labelProps: {
|
|
@@ -64,10 +64,10 @@ const BaseFormItem = ({ className, children, label, description, descriptionPlac
|
|
|
64
64
|
});
|
|
65
65
|
const descriptionElement = descriptionRenderedInline ? /* @__PURE__ */ jsx("p", {
|
|
66
66
|
"data-slot": "form-item-description",
|
|
67
|
-
...
|
|
67
|
+
...itemDescriptionProps,
|
|
68
68
|
...slots?.description,
|
|
69
69
|
id: descriptionId,
|
|
70
|
-
className: cn$1("text-muted-foreground text-[0.8rem]", spacingConfig.description,
|
|
70
|
+
className: cn$1("text-muted-foreground text-[0.8rem]", spacingConfig.description, itemDescriptionProps.className, slots?.description?.className),
|
|
71
71
|
children: description
|
|
72
72
|
}) : null;
|
|
73
73
|
const contentElement = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -15,7 +15,7 @@ const FormItem = (0, __formily_react.connect)(require_BaseFormItem.BaseFormItem,
|
|
|
15
15
|
if ((0, __formily_core.isVoidField)(field)) return {
|
|
16
16
|
label: field.title ?? props.label,
|
|
17
17
|
description: props.description ?? field.description,
|
|
18
|
-
|
|
18
|
+
requiredMark: props.requiredMark !== void 0 ? props.requiredMark : props.asterisk
|
|
19
19
|
};
|
|
20
20
|
const takeFeedbackStatus = () => {
|
|
21
21
|
if (field.validating) return void 0;
|
|
@@ -30,18 +30,16 @@ const FormItem = (0, __formily_react.connect)(require_BaseFormItem.BaseFormItem,
|
|
|
30
30
|
if (field.selfWarnings?.length) return field.selfWarnings.join(", ");
|
|
31
31
|
if (field.selfSuccesses?.length) return field.selfSuccesses.join(", ");
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return false;
|
|
38
|
-
};
|
|
33
|
+
let resolvedRequiredMark = props.requiredMark;
|
|
34
|
+
if (resolvedRequiredMark === void 0) if (props.asterisk !== void 0) resolvedRequiredMark = Boolean(props.asterisk);
|
|
35
|
+
else if (schema.parent && Array.isArray(schema.parent.required) && schema.parent.required.includes(schema.name)) resolvedRequiredMark = true;
|
|
36
|
+
else resolvedRequiredMark = field.required && field.pattern !== "readPretty";
|
|
39
37
|
return {
|
|
40
38
|
label: props.label ?? field.title,
|
|
41
39
|
description: props.description ?? field.description,
|
|
42
40
|
feedbackStatus: takeFeedbackStatus(),
|
|
43
41
|
feedbackText: takeFeedbackText(),
|
|
44
|
-
|
|
42
|
+
requiredMark: resolvedRequiredMark
|
|
45
43
|
};
|
|
46
44
|
}));
|
|
47
45
|
|
|
@@ -12,7 +12,7 @@ const FormItem = connect(BaseFormItem, mapProps((props, field) => {
|
|
|
12
12
|
if (isVoidField(field)) return {
|
|
13
13
|
label: field.title ?? props.label,
|
|
14
14
|
description: props.description ?? field.description,
|
|
15
|
-
|
|
15
|
+
requiredMark: props.requiredMark !== void 0 ? props.requiredMark : props.asterisk
|
|
16
16
|
};
|
|
17
17
|
const takeFeedbackStatus = () => {
|
|
18
18
|
if (field.validating) return void 0;
|
|
@@ -27,18 +27,16 @@ const FormItem = connect(BaseFormItem, mapProps((props, field) => {
|
|
|
27
27
|
if (field.selfWarnings?.length) return field.selfWarnings.join(", ");
|
|
28
28
|
if (field.selfSuccesses?.length) return field.selfSuccesses.join(", ");
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return false;
|
|
35
|
-
};
|
|
30
|
+
let resolvedRequiredMark = props.requiredMark;
|
|
31
|
+
if (resolvedRequiredMark === void 0) if (props.asterisk !== void 0) resolvedRequiredMark = Boolean(props.asterisk);
|
|
32
|
+
else if (schema.parent && Array.isArray(schema.parent.required) && schema.parent.required.includes(schema.name)) resolvedRequiredMark = true;
|
|
33
|
+
else resolvedRequiredMark = field.required && field.pattern !== "readPretty";
|
|
36
34
|
return {
|
|
37
35
|
label: props.label ?? field.title,
|
|
38
36
|
description: props.description ?? field.description,
|
|
39
37
|
feedbackStatus: takeFeedbackStatus(),
|
|
40
38
|
feedbackText: takeFeedbackText(),
|
|
41
|
-
|
|
39
|
+
requiredMark: resolvedRequiredMark
|
|
42
40
|
};
|
|
43
41
|
}));
|
|
44
42
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DescriptionPlacement } from "../../types/form-item.cjs";
|
|
2
|
-
import { FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement } from "./form-item-types.cjs";
|
|
2
|
+
import { FormItemDescriptionProps, FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement } from "./form-item-types.cjs";
|
|
3
3
|
import "./BaseFormItem.cjs";
|
|
4
4
|
import { FormItem } from "./ConnectedFormItem.cjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DescriptionPlacement } from "../../types/form-item.js";
|
|
2
|
-
import { FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement } from "./form-item-types.js";
|
|
2
|
+
import { FormItemDescriptionProps, FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement } from "./form-item-types.js";
|
|
3
3
|
import "./BaseFormItem.js";
|
|
4
4
|
import { FormItem } from "./ConnectedFormItem.js";
|
|
@@ -6,8 +6,9 @@ let __pixpilot_shadcn = require("@pixpilot/shadcn");
|
|
|
6
6
|
__pixpilot_shadcn = require_rolldown_runtime.__toESM(__pixpilot_shadcn);
|
|
7
7
|
|
|
8
8
|
//#region src/components/form-item/FormItemLabel.tsx
|
|
9
|
-
function FormItemLabel({ id, label, asterisk, error, shrink, labelProps, description, descriptionInPopover }) {
|
|
9
|
+
function FormItemLabel({ id, label, requiredMark, asterisk, error, shrink, labelProps, description, descriptionInPopover }) {
|
|
10
10
|
const { className, placement: _placement,...restLabelProps } = labelProps ?? {};
|
|
11
|
+
const resolvedRequiredMark = requiredMark !== void 0 ? requiredMark : asterisk;
|
|
11
12
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
12
13
|
htmlFor: id,
|
|
13
14
|
"data-slot": "form-item-label",
|
|
@@ -21,11 +22,11 @@ function FormItemLabel({ id, label, asterisk, error, shrink, labelProps, descrip
|
|
|
21
22
|
"data-slot": "form-item-label-text",
|
|
22
23
|
children: label
|
|
23
24
|
}), descriptionInPopover && description != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FormItemDescriptionPopover.FormItemDescriptionPopover, { description })]
|
|
24
|
-
}),
|
|
25
|
-
"data-slot": "form-item-label-
|
|
25
|
+
}), resolvedRequiredMark !== false && resolvedRequiredMark != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
26
|
+
"data-slot": "form-item-label-required-mark",
|
|
26
27
|
className: "text-destructive ml-1",
|
|
27
28
|
"aria-label": "required",
|
|
28
|
-
children: "*"
|
|
29
|
+
children: resolvedRequiredMark === true ? "*" : resolvedRequiredMark
|
|
29
30
|
})]
|
|
30
31
|
});
|
|
31
32
|
}
|
|
@@ -3,8 +3,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { cn } from "@pixpilot/shadcn";
|
|
4
4
|
|
|
5
5
|
//#region src/components/form-item/FormItemLabel.tsx
|
|
6
|
-
function FormItemLabel({ id, label, asterisk, error, shrink, labelProps, description, descriptionInPopover }) {
|
|
6
|
+
function FormItemLabel({ id, label, requiredMark, asterisk, error, shrink, labelProps, description, descriptionInPopover }) {
|
|
7
7
|
const { className, placement: _placement,...restLabelProps } = labelProps ?? {};
|
|
8
|
+
const resolvedRequiredMark = requiredMark !== void 0 ? requiredMark : asterisk;
|
|
8
9
|
return /* @__PURE__ */ jsxs("label", {
|
|
9
10
|
htmlFor: id,
|
|
10
11
|
"data-slot": "form-item-label",
|
|
@@ -18,11 +19,11 @@ function FormItemLabel({ id, label, asterisk, error, shrink, labelProps, descrip
|
|
|
18
19
|
"data-slot": "form-item-label-text",
|
|
19
20
|
children: label
|
|
20
21
|
}), descriptionInPopover && description != null && /* @__PURE__ */ jsx(FormItemDescriptionPopover, { description })]
|
|
21
|
-
}),
|
|
22
|
-
"data-slot": "form-item-label-
|
|
22
|
+
}), resolvedRequiredMark !== false && resolvedRequiredMark != null && /* @__PURE__ */ jsx("span", {
|
|
23
|
+
"data-slot": "form-item-label-required-mark",
|
|
23
24
|
className: "text-destructive ml-1",
|
|
24
25
|
"aria-label": "required",
|
|
25
|
-
children: "*"
|
|
26
|
+
children: resolvedRequiredMark === true ? "*" : resolvedRequiredMark
|
|
26
27
|
})]
|
|
27
28
|
});
|
|
28
29
|
}
|
|
@@ -7,6 +7,9 @@ type LabelPlacement = 'top' | 'bottom' | 'start' | 'end';
|
|
|
7
7
|
type FormItemLabelProps = Omit<React.ComponentPropsWithoutRef<'label'>, 'children' | 'htmlFor'> & {
|
|
8
8
|
placement?: LabelPlacement;
|
|
9
9
|
};
|
|
10
|
+
type FormItemDescriptionProps = React.HTMLAttributes<HTMLParagraphElement> & {
|
|
11
|
+
placement?: DescriptionPlacement;
|
|
12
|
+
};
|
|
10
13
|
interface FormItemSlots {
|
|
11
14
|
label?: FormItemLabelProps;
|
|
12
15
|
description?: React.HTMLAttributes<HTMLParagraphElement>;
|
|
@@ -25,9 +28,13 @@ interface FormItemProps extends React.ComponentProps<'div'> {
|
|
|
25
28
|
* - `popover`: show a help icon before the label and render the description in a hover popover
|
|
26
29
|
*/
|
|
27
30
|
descriptionPlacement?: DescriptionPlacement;
|
|
31
|
+
requiredMark?: boolean | React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use `requiredMark` instead.
|
|
34
|
+
*/
|
|
28
35
|
asterisk?: boolean;
|
|
29
36
|
feedbackStatus?: 'error' | 'warning' | 'success';
|
|
30
37
|
feedbackText?: SyncReactNode;
|
|
31
38
|
}
|
|
32
39
|
//#endregion
|
|
33
|
-
export { FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement };
|
|
40
|
+
export { FormItemDescriptionProps, FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement };
|
|
@@ -7,6 +7,9 @@ type LabelPlacement = 'top' | 'bottom' | 'start' | 'end';
|
|
|
7
7
|
type FormItemLabelProps = Omit<React.ComponentPropsWithoutRef<'label'>, 'children' | 'htmlFor'> & {
|
|
8
8
|
placement?: LabelPlacement;
|
|
9
9
|
};
|
|
10
|
+
type FormItemDescriptionProps = React.HTMLAttributes<HTMLParagraphElement> & {
|
|
11
|
+
placement?: DescriptionPlacement;
|
|
12
|
+
};
|
|
10
13
|
interface FormItemSlots {
|
|
11
14
|
label?: FormItemLabelProps;
|
|
12
15
|
description?: React.HTMLAttributes<HTMLParagraphElement>;
|
|
@@ -25,9 +28,13 @@ interface FormItemProps extends React.ComponentProps<'div'> {
|
|
|
25
28
|
* - `popover`: show a help icon before the label and render the description in a hover popover
|
|
26
29
|
*/
|
|
27
30
|
descriptionPlacement?: DescriptionPlacement;
|
|
31
|
+
requiredMark?: boolean | React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use `requiredMark` instead.
|
|
34
|
+
*/
|
|
28
35
|
asterisk?: boolean;
|
|
29
36
|
feedbackStatus?: 'error' | 'warning' | 'success';
|
|
30
37
|
feedbackText?: SyncReactNode;
|
|
31
38
|
}
|
|
32
39
|
//#endregion
|
|
33
|
-
export { FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement };
|
|
40
|
+
export { FormItemDescriptionProps, FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DescriptionPlacement } from "../../types/form-item.cjs";
|
|
2
|
-
import { FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement } from "./form-item-types.cjs";
|
|
2
|
+
import { FormItemDescriptionProps, FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement } from "./form-item-types.cjs";
|
|
3
3
|
import { FormItem } from "./ConnectedFormItem.cjs";
|
|
4
4
|
import "./FormItem.cjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DescriptionPlacement } from "../../types/form-item.js";
|
|
2
|
-
import { FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement } from "./form-item-types.js";
|
|
2
|
+
import { FormItemDescriptionProps, FormItemLabelProps, FormItemProps, FormItemSlots, LabelPlacement } from "./form-item-types.js";
|
|
3
3
|
import { FormItem } from "./ConnectedFormItem.js";
|
|
4
4
|
import "./FormItem.js";
|
package/dist/index.d.cts
CHANGED
|
@@ -30,11 +30,11 @@ import { FileUploadInline, FileUploadInlineProps } from "./components/file-uploa
|
|
|
30
30
|
import { FormFileUploadOptions } from "./components/file-upload/types.cjs";
|
|
31
31
|
import { useFileUploadFeedback } from "./components/file-upload/use-file-upload-feedback.cjs";
|
|
32
32
|
import "./components/file-upload/index.cjs";
|
|
33
|
+
import { FormItem } from "./components/form-item/ConnectedFormItem.cjs";
|
|
34
|
+
import "./components/form-item/index.cjs";
|
|
33
35
|
import { FomFileUpload, FormLayoutOptions, FormSettings } from "./components/context/types.cjs";
|
|
34
36
|
import { DatePicker } from "./components/DatePicker.cjs";
|
|
35
37
|
import { Form } from "./components/Form.cjs";
|
|
36
|
-
import { FormItem } from "./components/form-item/ConnectedFormItem.cjs";
|
|
37
|
-
import "./components/form-item/index.cjs";
|
|
38
38
|
import { FormGrid } from "./components/FormGrid.cjs";
|
|
39
39
|
import { IconPicker } from "./components/IconPicker.cjs";
|
|
40
40
|
import { IconToggle } from "./components/IconToggle.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -30,11 +30,11 @@ import { FileUploadInline, FileUploadInlineProps } from "./components/file-uploa
|
|
|
30
30
|
import { FormFileUploadOptions } from "./components/file-upload/types.js";
|
|
31
31
|
import { useFileUploadFeedback } from "./components/file-upload/use-file-upload-feedback.js";
|
|
32
32
|
import "./components/file-upload/index.js";
|
|
33
|
+
import { FormItem } from "./components/form-item/ConnectedFormItem.js";
|
|
34
|
+
import "./components/form-item/index.js";
|
|
33
35
|
import { FomFileUpload, FormLayoutOptions, FormSettings } from "./components/context/types.js";
|
|
34
36
|
import { DatePicker } from "./components/DatePicker.js";
|
|
35
37
|
import { Form } from "./components/Form.js";
|
|
36
|
-
import { FormItem } from "./components/form-item/ConnectedFormItem.js";
|
|
37
|
-
import "./components/form-item/index.js";
|
|
38
38
|
import { FormGrid } from "./components/FormGrid.js";
|
|
39
39
|
import { IconPicker } from "./components/IconPicker.js";
|
|
40
40
|
import { IconToggle } from "./components/IconToggle.js";
|
|
@@ -10,16 +10,16 @@ const densitySpaceMap = {
|
|
|
10
10
|
comfortable: "lg"
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* gap-y spacing configuration
|
|
14
14
|
* Controls vertical spacing between form items
|
|
15
15
|
*/
|
|
16
16
|
const spaceYConfig = {
|
|
17
17
|
fixed: {
|
|
18
|
-
sm: "
|
|
19
|
-
md: "
|
|
20
|
-
lg: "
|
|
18
|
+
sm: "gap-y-3",
|
|
19
|
+
md: "gap-y-4",
|
|
20
|
+
lg: "gap-y-6"
|
|
21
21
|
},
|
|
22
|
-
responsive: "
|
|
22
|
+
responsive: "gap-y-3 md:gap-y-4 lg:gap-y-6"
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* Gap-Y spacing configuration
|
|
@@ -47,7 +47,7 @@ function resolveSpacingClass(density, config) {
|
|
|
47
47
|
return config.fixed[space];
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Resolves responsive space and returns the Tailwind
|
|
50
|
+
* Resolves responsive space and returns the Tailwind gap-y class(es)
|
|
51
51
|
* For responsive density, returns responsive breakpoint classes
|
|
52
52
|
* For fixed density, returns single space class
|
|
53
53
|
*
|
|
@@ -9,16 +9,16 @@ const densitySpaceMap = {
|
|
|
9
9
|
comfortable: "lg"
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* gap-y spacing configuration
|
|
13
13
|
* Controls vertical spacing between form items
|
|
14
14
|
*/
|
|
15
15
|
const spaceYConfig = {
|
|
16
16
|
fixed: {
|
|
17
|
-
sm: "
|
|
18
|
-
md: "
|
|
19
|
-
lg: "
|
|
17
|
+
sm: "gap-y-3",
|
|
18
|
+
md: "gap-y-4",
|
|
19
|
+
lg: "gap-y-6"
|
|
20
20
|
},
|
|
21
|
-
responsive: "
|
|
21
|
+
responsive: "gap-y-3 md:gap-y-4 lg:gap-y-6"
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Gap-Y spacing configuration
|
|
@@ -46,7 +46,7 @@ function resolveSpacingClass(density, config) {
|
|
|
46
46
|
return config.fixed[space];
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* Resolves responsive space and returns the Tailwind
|
|
49
|
+
* Resolves responsive space and returns the Tailwind gap-y class(es)
|
|
50
50
|
* For responsive density, returns responsive breakpoint classes
|
|
51
51
|
* For fixed density, returns single space class
|
|
52
52
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixpilot/formily-shadcn",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.13.0",
|
|
5
5
|
"description": "Formily integration for shadcn/ui components",
|
|
6
6
|
"author": "m.doaie <m.doaie@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"react-dom": "19.2.0",
|
|
59
59
|
"tsdown": "^0.15.12",
|
|
60
60
|
"typescript": "^5.9.3",
|
|
61
|
-
"@internal/prettier-config": "0.0.1",
|
|
62
61
|
"@internal/tsconfig": "0.1.0",
|
|
63
62
|
"@internal/eslint-config": "0.3.0",
|
|
63
|
+
"@internal/prettier-config": "0.0.1",
|
|
64
64
|
"@internal/tsdown-config": "0.1.0",
|
|
65
65
|
"@internal/vitest-config": "0.1.0"
|
|
66
66
|
},
|