@pixpilot/formily-shadcn 1.4.0 → 1.4.2
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.ts +2 -2
- package/dist/components/DatePicker.d.cts +1 -1
- package/dist/components/DatePicker.d.ts +3 -3
- package/dist/components/Form.d.cts +2 -2
- package/dist/components/FormGrid.d.cts +2 -2
- package/dist/components/IconPicker.d.cts +3 -3
- package/dist/components/IconPicker.d.ts +3 -3
- package/dist/components/Input.d.cts +3 -3
- package/dist/components/Radio.d.ts +2 -2
- package/dist/components/Rating.d.cts +4 -4
- package/dist/components/Rating.d.ts +4 -4
- package/dist/components/Row.d.ts +2 -2
- package/dist/components/Separator.d.ts +2 -2
- package/dist/components/Switch.d.cts +2 -2
- package/dist/components/Switch.d.ts +2 -2
- package/dist/components/TagsInputInline.d.cts +3 -3
- package/dist/components/Textarea.d.cts +2 -2
- package/dist/components/Textarea.d.ts +2 -2
- package/dist/components/ToggleButton.d.cts +3 -3
- package/dist/components/ToggleButton.d.ts +2 -2
- package/dist/components/ToggleGroup.cjs +42 -16
- package/dist/components/ToggleGroup.d.cts +4 -3
- package/dist/components/ToggleGroup.d.ts +4 -3
- package/dist/components/ToggleGroup.js +42 -16
- package/dist/components/number/NumberInput.d.ts +3 -3
- package/dist/components/schema-field/schema-field-basics.d.cts +303 -303
- package/dist/components/schema-field/schema-field-basics.d.ts +287 -287
- package/dist/components/schema-field/schema-field-extended.d.cts +633 -633
- package/dist/components/schema-field/schema-field-extended.d.ts +485 -485
- package/dist/components/schema-field/schema-field.d.cts +398 -398
- package/dist/components/schema-field/schema-field.d.ts +397 -397
- package/dist/components/slider/Slider.d.cts +3 -3
- package/dist/components/slider/SliderSelect.d.cts +3 -3
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react0 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: react0.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_checkbox0.CheckboxProps & react0.RefAttributes<HTMLButtonElement>>, "ref"> & react0.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Checkbox };
|
|
@@ -6,6 +6,6 @@ declare const DatePicker: react2.ForwardRefExoticComponent<Partial<{
|
|
|
6
6
|
value?: Date;
|
|
7
7
|
onChange?: (date: Date | undefined) => void;
|
|
8
8
|
placeholder?: string;
|
|
9
|
-
} & Omit<DatePickerProps, "
|
|
9
|
+
} & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react2.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { DatePicker };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react2 from "react";
|
|
2
2
|
import { DatePickerProps } from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/DatePicker.d.ts
|
|
5
|
-
declare const DatePicker$1:
|
|
5
|
+
declare const DatePicker$1: react2.ForwardRefExoticComponent<Partial<{
|
|
6
6
|
value?: Date;
|
|
7
7
|
onChange?: (date: Date | undefined) => void;
|
|
8
8
|
placeholder?: string;
|
|
9
|
-
} & Omit<DatePickerProps, "
|
|
9
|
+
} & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react2.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { DatePicker$1 as DatePicker };
|
|
@@ -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_runtime0 from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Form.d.ts
|
|
8
8
|
interface IFormProps extends FormContextStates {
|
|
@@ -25,6 +25,6 @@ declare function Form$1({
|
|
|
25
25
|
onAutoSubmit,
|
|
26
26
|
layout,
|
|
27
27
|
settings
|
|
28
|
-
}: IFormProps):
|
|
28
|
+
}: IFormProps): react_jsx_runtime0.JSX.Element;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { Form$1 as Form };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/FormGrid.d.ts
|
|
5
5
|
interface IFormGridProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
@@ -7,6 +7,6 @@ declare function FormGrid({
|
|
|
7
7
|
className,
|
|
8
8
|
children,
|
|
9
9
|
...rest
|
|
10
|
-
}: IFormGridProps):
|
|
10
|
+
}: IFormGridProps): react_jsx_runtime1.JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { FormGrid };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as 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:
|
|
11
|
+
declare const IconPicker: react11.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
|
|
12
12
|
providers?: IconProviderProps[];
|
|
13
|
-
}> &
|
|
13
|
+
}> & react11.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { IconPicker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react4 from "react";
|
|
2
2
|
import { IconPickerProps, IconProviderProps } from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/IconPicker.d.ts
|
|
@@ -8,8 +8,8 @@ import { IconPickerProps, IconProviderProps } from "@pixpilot/shadcn-ui";
|
|
|
8
8
|
* Automatically connects to Formily field state
|
|
9
9
|
* Supports both static and async icon providers
|
|
10
10
|
*/
|
|
11
|
-
declare const IconPicker$1:
|
|
11
|
+
declare const IconPicker$1: react4.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
|
|
12
12
|
providers?: IconProviderProps[];
|
|
13
|
-
}> &
|
|
13
|
+
}> & react4.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { IconPicker$1 as IconPicker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react7 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: react7.ForwardRefExoticComponent<Omit<Partial<react7.ClassAttributes<HTMLInputElement> & react7.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"> & react7.RefAttributes<unknown>>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { Input };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
3
3
|
import { RadioGroup } from "@pixpilot/shadcn";
|
|
4
4
|
|
|
5
5
|
//#region src/components/Radio.d.ts
|
|
@@ -15,7 +15,7 @@ type RadioProps = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Radio component with options rendering
|
|
17
17
|
*/
|
|
18
|
-
declare function Radio(props: RadioProps):
|
|
18
|
+
declare function Radio(props: RadioProps): react_jsx_runtime2.JSX.Element;
|
|
19
19
|
declare namespace Radio {
|
|
20
20
|
var displayName: string;
|
|
21
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react13 from "react";
|
|
2
2
|
import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Rating.d.ts
|
|
@@ -6,8 +6,8 @@ import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
|
6
6
|
* Formily-connected Rating component
|
|
7
7
|
* Automatically connects shadcn-ui Rating to Formily field state
|
|
8
8
|
*/
|
|
9
|
-
declare const Rating:
|
|
10
|
-
children?:
|
|
11
|
-
}> &
|
|
9
|
+
declare const Rating: react13.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui0.RatingProps & {
|
|
10
|
+
children?: react13.ReactNode | undefined;
|
|
11
|
+
}> & react13.RefAttributes<unknown>>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { Rating };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react13 from "react";
|
|
2
2
|
import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Rating.d.ts
|
|
@@ -6,8 +6,8 @@ import * as _pixpilot_shadcn_ui0 from "@pixpilot/shadcn-ui";
|
|
|
6
6
|
* Formily-connected Rating component
|
|
7
7
|
* Automatically connects shadcn-ui Rating to Formily field state
|
|
8
8
|
*/
|
|
9
|
-
declare const Rating$1:
|
|
10
|
-
children?:
|
|
11
|
-
}> &
|
|
9
|
+
declare const Rating$1: react13.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui0.RatingProps & {
|
|
10
|
+
children?: react13.ReactNode | undefined;
|
|
11
|
+
}> & react13.RefAttributes<unknown>>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { Rating$1 as Rating };
|
package/dist/components/Row.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Row.d.ts
|
|
5
5
|
interface IRowProps {
|
|
@@ -36,6 +36,6 @@ interface IRowProps {
|
|
|
36
36
|
declare function Row({
|
|
37
37
|
className,
|
|
38
38
|
children
|
|
39
|
-
}: IRowProps):
|
|
39
|
+
}: IRowProps): react_jsx_runtime3.JSX.Element;
|
|
40
40
|
//#endregion
|
|
41
41
|
export { Row };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react16 from "react";
|
|
2
2
|
import * as _radix_ui_react_separator0 from "@radix-ui/react-separator";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Separator.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _radix_ui_react_separator0 from "@radix-ui/react-separator";
|
|
|
6
6
|
* Formily-connected Separator component
|
|
7
7
|
* A visual divider for content sections
|
|
8
8
|
*/
|
|
9
|
-
declare const Separator:
|
|
9
|
+
declare const Separator: react16.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_separator0.SeparatorProps & react16.RefAttributes<HTMLDivElement>>, "ref"> & react16.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Separator };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react21 from "react";
|
|
2
2
|
import * as _radix_ui_react_switch0 from "@radix-ui/react-switch";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Switch.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _radix_ui_react_switch0 from "@radix-ui/react-switch";
|
|
|
6
6
|
* Formily-connected Switch component
|
|
7
7
|
* Toggle switch for boolean values
|
|
8
8
|
*/
|
|
9
|
-
declare const Switch:
|
|
9
|
+
declare const Switch: react21.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_switch0.SwitchProps & react21.RefAttributes<HTMLButtonElement>>, "ref"> & react21.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Switch };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react19 from "react";
|
|
2
2
|
import * as _radix_ui_react_switch0 from "@radix-ui/react-switch";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Switch.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _radix_ui_react_switch0 from "@radix-ui/react-switch";
|
|
|
6
6
|
* Formily-connected Switch component
|
|
7
7
|
* Toggle switch for boolean values
|
|
8
8
|
*/
|
|
9
|
-
declare const Switch:
|
|
9
|
+
declare const Switch: react19.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_switch0.SwitchProps & react19.RefAttributes<HTMLButtonElement>>, "ref"> & react19.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Switch };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react19 from "react";
|
|
2
|
+
import * as _pixpilot_shadcn_ui1 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/TagsInputInline.d.ts
|
|
5
5
|
|
|
@@ -10,6 +10,6 @@ import * as _pixpilot_shadcn_ui2 from "@pixpilot/shadcn-ui";
|
|
|
10
10
|
* Based on DiceUI's tags-input for inline tag editing with keyboard navigation
|
|
11
11
|
* and validation support.
|
|
12
12
|
*/
|
|
13
|
-
declare const TagsInputInLine:
|
|
13
|
+
declare const TagsInputInLine: react19.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui1.TagsInputProps> & react19.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { TagsInputInLine };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react24 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/Textarea.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Formily-connected Textarea component
|
|
6
6
|
*/
|
|
7
|
-
declare const Textarea:
|
|
7
|
+
declare const Textarea: react24.ForwardRefExoticComponent<Omit<Partial<react24.ClassAttributes<HTMLTextAreaElement> & react24.TextareaHTMLAttributes<HTMLTextAreaElement>>, "ref"> & react24.RefAttributes<unknown>>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { Textarea };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react24 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/Textarea.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Formily-connected Textarea component
|
|
6
6
|
*/
|
|
7
|
-
declare const Textarea:
|
|
7
|
+
declare const Textarea: react24.ForwardRefExoticComponent<Omit<Partial<react24.ClassAttributes<HTMLTextAreaElement> & react24.TextareaHTMLAttributes<HTMLTextAreaElement>>, "ref"> & react24.RefAttributes<unknown>>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { Textarea };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react28 from "react";
|
|
2
|
+
import * as _pixpilot_shadcn_ui2 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ToggleButton.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Formily-connected IconToggle component
|
|
7
7
|
* Toggle button with customizable icons for boolean values
|
|
8
8
|
*/
|
|
9
|
-
declare const ToggleButton:
|
|
9
|
+
declare const ToggleButton: react28.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui2.ToggleButtonProps, "ref"> & react28.RefAttributes<HTMLButtonElement>>, "ref"> & react28.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { ToggleButton };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react28 from "react";
|
|
2
2
|
import * as _pixpilot_shadcn_ui2 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ToggleButton.d.ts
|
|
@@ -6,6 +6,6 @@ import * as _pixpilot_shadcn_ui2 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 ToggleButton$1:
|
|
9
|
+
declare const ToggleButton$1: react28.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui2.ToggleButtonProps, "ref"> & react28.RefAttributes<HTMLButtonElement>>, "ref"> & react28.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { ToggleButton$1 as ToggleButton };
|
|
@@ -31,23 +31,53 @@ function coerceOptions(options) {
|
|
|
31
31
|
};
|
|
32
32
|
}).filter((v) => v !== null);
|
|
33
33
|
}
|
|
34
|
-
function ToggleGroupBase({ options, value, defaultValue, onValueChange, allowEmptySelection = false, variant = "outline", size, fullWidth = true, slots, ref,...props }) {
|
|
35
|
-
const valueString = value === void 0 ? void 0 : String(value);
|
|
36
|
-
const defaultValueString = defaultValue === void 0 ? void 0 : String(defaultValue);
|
|
34
|
+
function ToggleGroupBase({ type = "single", options, value, defaultValue, onValueChange, allowEmptySelection = false, variant = "outline", size, fullWidth = true, slots, ref,...props }) {
|
|
37
35
|
const valueByString = react.useMemo(() => {
|
|
38
36
|
const map = /* @__PURE__ */ new Map();
|
|
39
37
|
for (const option of options) map.set(String(option.value), option.value);
|
|
40
38
|
return map;
|
|
41
39
|
}, [options]);
|
|
42
|
-
|
|
43
|
-
type: "single",
|
|
40
|
+
const sharedProps = {
|
|
44
41
|
...props,
|
|
45
42
|
className: (0, __pixpilot_shadcn_ui.cn)({ "w-full": fullWidth }, props.className),
|
|
46
43
|
ref,
|
|
44
|
+
variant: toVariant(variant),
|
|
45
|
+
size: toSize(size)
|
|
46
|
+
};
|
|
47
|
+
const itemNodes = options.map((option) => /* @__PURE__ */ (0, react.createElement)(__pixpilot_shadcn_ui.ToggleGroupItem, {
|
|
48
|
+
...slots?.item,
|
|
49
|
+
key: String(option.value),
|
|
50
|
+
value: String(option.value),
|
|
51
|
+
"aria-label": String(option.value),
|
|
52
|
+
disabled: option.disabled,
|
|
53
|
+
className: (0, __pixpilot_shadcn_ui.cn)({ "flex-1": fullWidth }, slots?.item?.className)
|
|
54
|
+
}, option.label));
|
|
55
|
+
if (type === "multiple") {
|
|
56
|
+
let valueStrings;
|
|
57
|
+
if (Array.isArray(value)) valueStrings = value.map(String);
|
|
58
|
+
else if (value !== void 0) valueStrings = [String(value)];
|
|
59
|
+
let defaultValueStrings;
|
|
60
|
+
if (Array.isArray(defaultValue)) defaultValueStrings = defaultValue.map(String);
|
|
61
|
+
else if (defaultValue !== void 0) defaultValueStrings = [String(defaultValue)];
|
|
62
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.ToggleGroup, {
|
|
63
|
+
type: "multiple",
|
|
64
|
+
...sharedProps,
|
|
65
|
+
value: valueStrings,
|
|
66
|
+
defaultValue: defaultValueStrings,
|
|
67
|
+
onValueChange: (nextValues) => {
|
|
68
|
+
const mapped = nextValues.map((v) => valueByString.get(v) ?? v);
|
|
69
|
+
onValueChange?.(mapped);
|
|
70
|
+
},
|
|
71
|
+
children: itemNodes
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const valueString = value === void 0 || Array.isArray(value) ? void 0 : String(value);
|
|
75
|
+
const defaultValueString = defaultValue === void 0 || Array.isArray(defaultValue) ? void 0 : String(defaultValue);
|
|
76
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.ToggleGroup, {
|
|
77
|
+
type: "single",
|
|
78
|
+
...sharedProps,
|
|
47
79
|
value: valueString,
|
|
48
80
|
defaultValue: defaultValueString,
|
|
49
|
-
variant: toVariant(variant),
|
|
50
|
-
size: toSize(size),
|
|
51
81
|
onValueChange: (nextValue) => {
|
|
52
82
|
if (nextValue === "") {
|
|
53
83
|
if (allowEmptySelection !== true) return;
|
|
@@ -56,14 +86,7 @@ function ToggleGroupBase({ options, value, defaultValue, onValueChange, allowEmp
|
|
|
56
86
|
}
|
|
57
87
|
onValueChange?.(valueByString.get(nextValue) ?? nextValue);
|
|
58
88
|
},
|
|
59
|
-
children:
|
|
60
|
-
...slots?.item,
|
|
61
|
-
key: String(option.value),
|
|
62
|
-
value: String(option.value),
|
|
63
|
-
"aria-label": String(option.value),
|
|
64
|
-
disabled: option.disabled,
|
|
65
|
-
className: (0, __pixpilot_shadcn_ui.cn)({ "flex-1": fullWidth }, slots?.item?.className)
|
|
66
|
-
}, option.label))
|
|
89
|
+
children: itemNodes
|
|
67
90
|
});
|
|
68
91
|
}
|
|
69
92
|
/**
|
|
@@ -105,7 +128,10 @@ const ToggleGroup = (0, __formily_react.connect)(ToggleGroupBase, (0, __formily_
|
|
|
105
128
|
field,
|
|
106
129
|
options: props.options
|
|
107
130
|
}));
|
|
108
|
-
const
|
|
131
|
+
const isMultiple = toggleGroupProps.type === "multiple";
|
|
132
|
+
let value;
|
|
133
|
+
if (isMultiple) value = Array.isArray(fieldValue) ? fieldValue.filter(isToggleGroupValue) : [];
|
|
134
|
+
else if (isToggleGroupValue(fieldValue)) value = fieldValue;
|
|
109
135
|
return {
|
|
110
136
|
...toggleGroupProps,
|
|
111
137
|
options: resolvedOptions,
|
|
@@ -12,10 +12,11 @@ interface ToggleGroupOption {
|
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
}
|
|
14
14
|
interface ToggleGroupBaseProps extends Omit<ToggleGroupProps, 'type' | 'value' | 'defaultValue' | 'onValueChange' | 'children' | 'variant' | 'size'> {
|
|
15
|
+
type?: 'single' | 'multiple';
|
|
15
16
|
options: readonly ToggleGroupOption[];
|
|
16
|
-
value?: ToggleGroupValue;
|
|
17
|
-
defaultValue?: ToggleGroupValue;
|
|
18
|
-
onValueChange?: (value: ToggleGroupValue | undefined) => void;
|
|
17
|
+
value?: ToggleGroupValue | ToggleGroupValue[];
|
|
18
|
+
defaultValue?: ToggleGroupValue | ToggleGroupValue[];
|
|
19
|
+
onValueChange?: (value: ToggleGroupValue | undefined | ToggleGroupValue[]) => void;
|
|
19
20
|
allowEmptySelection?: boolean;
|
|
20
21
|
variant?: ToggleGroupVariant;
|
|
21
22
|
size?: ToggleGroupSize;
|
|
@@ -12,10 +12,11 @@ interface ToggleGroupOption {
|
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
}
|
|
14
14
|
interface ToggleGroupBaseProps extends Omit<ToggleGroupProps, 'type' | 'value' | 'defaultValue' | 'onValueChange' | 'children' | 'variant' | 'size'> {
|
|
15
|
+
type?: 'single' | 'multiple';
|
|
15
16
|
options: readonly ToggleGroupOption[];
|
|
16
|
-
value?: ToggleGroupValue;
|
|
17
|
-
defaultValue?: ToggleGroupValue;
|
|
18
|
-
onValueChange?: (value: ToggleGroupValue | undefined) => void;
|
|
17
|
+
value?: ToggleGroupValue | ToggleGroupValue[];
|
|
18
|
+
defaultValue?: ToggleGroupValue | ToggleGroupValue[];
|
|
19
|
+
onValueChange?: (value: ToggleGroupValue | undefined | ToggleGroupValue[]) => void;
|
|
19
20
|
allowEmptySelection?: boolean;
|
|
20
21
|
variant?: ToggleGroupVariant;
|
|
21
22
|
size?: ToggleGroupSize;
|
|
@@ -27,23 +27,53 @@ function coerceOptions(options) {
|
|
|
27
27
|
};
|
|
28
28
|
}).filter((v) => v !== null);
|
|
29
29
|
}
|
|
30
|
-
function ToggleGroupBase({ options, value, defaultValue, onValueChange, allowEmptySelection = false, variant = "outline", size, fullWidth = true, slots, ref,...props }) {
|
|
31
|
-
const valueString = value === void 0 ? void 0 : String(value);
|
|
32
|
-
const defaultValueString = defaultValue === void 0 ? void 0 : String(defaultValue);
|
|
30
|
+
function ToggleGroupBase({ type = "single", options, value, defaultValue, onValueChange, allowEmptySelection = false, variant = "outline", size, fullWidth = true, slots, ref,...props }) {
|
|
33
31
|
const valueByString = React$1.useMemo(() => {
|
|
34
32
|
const map = /* @__PURE__ */ new Map();
|
|
35
33
|
for (const option of options) map.set(String(option.value), option.value);
|
|
36
34
|
return map;
|
|
37
35
|
}, [options]);
|
|
38
|
-
|
|
39
|
-
type: "single",
|
|
36
|
+
const sharedProps = {
|
|
40
37
|
...props,
|
|
41
38
|
className: cn({ "w-full": fullWidth }, props.className),
|
|
42
39
|
ref,
|
|
40
|
+
variant: toVariant(variant),
|
|
41
|
+
size: toSize(size)
|
|
42
|
+
};
|
|
43
|
+
const itemNodes = options.map((option) => /* @__PURE__ */ createElement(ToggleGroupItem, {
|
|
44
|
+
...slots?.item,
|
|
45
|
+
key: String(option.value),
|
|
46
|
+
value: String(option.value),
|
|
47
|
+
"aria-label": String(option.value),
|
|
48
|
+
disabled: option.disabled,
|
|
49
|
+
className: cn({ "flex-1": fullWidth }, slots?.item?.className)
|
|
50
|
+
}, option.label));
|
|
51
|
+
if (type === "multiple") {
|
|
52
|
+
let valueStrings;
|
|
53
|
+
if (Array.isArray(value)) valueStrings = value.map(String);
|
|
54
|
+
else if (value !== void 0) valueStrings = [String(value)];
|
|
55
|
+
let defaultValueStrings;
|
|
56
|
+
if (Array.isArray(defaultValue)) defaultValueStrings = defaultValue.map(String);
|
|
57
|
+
else if (defaultValue !== void 0) defaultValueStrings = [String(defaultValue)];
|
|
58
|
+
return /* @__PURE__ */ jsx(ToggleGroup, {
|
|
59
|
+
type: "multiple",
|
|
60
|
+
...sharedProps,
|
|
61
|
+
value: valueStrings,
|
|
62
|
+
defaultValue: defaultValueStrings,
|
|
63
|
+
onValueChange: (nextValues) => {
|
|
64
|
+
const mapped = nextValues.map((v) => valueByString.get(v) ?? v);
|
|
65
|
+
onValueChange?.(mapped);
|
|
66
|
+
},
|
|
67
|
+
children: itemNodes
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const valueString = value === void 0 || Array.isArray(value) ? void 0 : String(value);
|
|
71
|
+
const defaultValueString = defaultValue === void 0 || Array.isArray(defaultValue) ? void 0 : String(defaultValue);
|
|
72
|
+
return /* @__PURE__ */ jsx(ToggleGroup, {
|
|
73
|
+
type: "single",
|
|
74
|
+
...sharedProps,
|
|
43
75
|
value: valueString,
|
|
44
76
|
defaultValue: defaultValueString,
|
|
45
|
-
variant: toVariant(variant),
|
|
46
|
-
size: toSize(size),
|
|
47
77
|
onValueChange: (nextValue) => {
|
|
48
78
|
if (nextValue === "") {
|
|
49
79
|
if (allowEmptySelection !== true) return;
|
|
@@ -52,14 +82,7 @@ function ToggleGroupBase({ options, value, defaultValue, onValueChange, allowEmp
|
|
|
52
82
|
}
|
|
53
83
|
onValueChange?.(valueByString.get(nextValue) ?? nextValue);
|
|
54
84
|
},
|
|
55
|
-
children:
|
|
56
|
-
...slots?.item,
|
|
57
|
-
key: String(option.value),
|
|
58
|
-
value: String(option.value),
|
|
59
|
-
"aria-label": String(option.value),
|
|
60
|
-
disabled: option.disabled,
|
|
61
|
-
className: cn({ "flex-1": fullWidth }, slots?.item?.className)
|
|
62
|
-
}, option.label))
|
|
85
|
+
children: itemNodes
|
|
63
86
|
});
|
|
64
87
|
}
|
|
65
88
|
/**
|
|
@@ -101,7 +124,10 @@ const ToggleGroup$1 = connect(ToggleGroupBase, mapProps({
|
|
|
101
124
|
field,
|
|
102
125
|
options: props.options
|
|
103
126
|
}));
|
|
104
|
-
const
|
|
127
|
+
const isMultiple = toggleGroupProps.type === "multiple";
|
|
128
|
+
let value;
|
|
129
|
+
if (isMultiple) value = Array.isArray(fieldValue) ? fieldValue.filter(isToggleGroupValue) : [];
|
|
130
|
+
else if (isToggleGroupValue(fieldValue)) value = fieldValue;
|
|
105
131
|
return {
|
|
106
132
|
...toggleGroupProps,
|
|
107
133
|
options: resolvedOptions,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react31 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/number/NumberInput.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Formily-connected Number Input component
|
|
6
6
|
*/
|
|
7
|
-
declare const NumberInput:
|
|
7
|
+
declare const NumberInput: react31.ForwardRefExoticComponent<Omit<Partial<react31.ClassAttributes<HTMLInputElement> & react31.InputHTMLAttributes<HTMLInputElement> & {
|
|
8
8
|
prefix?: React.ReactNode;
|
|
9
9
|
suffix?: React.ReactNode;
|
|
10
10
|
groupClassName?: string;
|
|
11
11
|
prefixClassName?: string;
|
|
12
12
|
suffixClassName?: string;
|
|
13
|
-
}>, "ref"> &
|
|
13
|
+
}>, "ref"> & react31.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { NumberInput };
|