@pixpilot/formily-shadcn 1.0.5 → 1.1.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.
@@ -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 react_jsx_runtime1 from "react/jsx-runtime";
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): react_jsx_runtime1.JSX.Element;
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 react_jsx_runtime0 from "react/jsx-runtime";
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): react_jsx_runtime0.JSX.Element;
10
+ }: IFormGridProps): react_jsx_runtime1.JSX.Element;
11
11
  //#endregion
12
12
  export { FormGrid };
@@ -1,4 +1,4 @@
1
- import * as react4 from "react";
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: react4.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
11
+ declare const IconPicker: react11.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
12
12
  providers?: IconProviderProps[];
13
- }> & react4.RefAttributes<unknown>>;
13
+ }> & react11.RefAttributes<unknown>>;
14
14
  //#endregion
15
15
  export { IconPicker };
@@ -1,4 +1,4 @@
1
- import * as react6 from "react";
1
+ import * as react4 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: react6.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui0.IconToggleProps, "ref"> & react6.RefAttributes<HTMLButtonElement>>, "ref"> & react6.RefAttributes<unknown>>;
9
+ declare const IconToggle: react4.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui0.IconToggleProps, "ref"> & react4.RefAttributes<HTMLButtonElement>>, "ref"> & react4.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { IconToggle };
@@ -1,4 +1,4 @@
1
- import * as react9 from "react";
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: react9.ForwardRefExoticComponent<Omit<Partial<react9.ClassAttributes<HTMLInputElement> & react9.InputHTMLAttributes<HTMLInputElement> & {
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"> & react9.RefAttributes<unknown>>;
15
+ }>, "ref"> & react7.RefAttributes<unknown>>;
16
16
  //#endregion
17
17
  export { Input };
@@ -1,4 +1,4 @@
1
- import * as react22 from "react";
1
+ import * as react26 from "react";
2
2
  import * as _pixpilot_shadcn_ui1 from "@pixpilot/shadcn-ui";
3
3
 
4
4
  //#region src/components/TagsInputInline.d.ts
@@ -10,6 +10,6 @@ import * as _pixpilot_shadcn_ui1 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: react22.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui1.TagsInputProps> & react22.RefAttributes<unknown>>;
13
+ declare const TagsInputInLine: react26.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui1.TagsInputProps> & react26.RefAttributes<unknown>>;
14
14
  //#endregion
15
15
  export { TagsInputInLine };
@@ -1,9 +1,9 @@
1
- import * as react24 from "react";
1
+ import * as react22 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: react24.ForwardRefExoticComponent<Omit<Partial<react24.ClassAttributes<HTMLTextAreaElement> & react24.TextareaHTMLAttributes<HTMLTextAreaElement>>, "ref"> & react24.RefAttributes<unknown>>;
7
+ declare const Textarea: react22.ForwardRefExoticComponent<Omit<Partial<react22.ClassAttributes<HTMLTextAreaElement> & react22.TextareaHTMLAttributes<HTMLTextAreaElement>>, "ref"> & react22.RefAttributes<unknown>>;
8
8
  //#endregion
9
9
  export { Textarea };
@@ -31,14 +31,37 @@ 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, buttonClassName, 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, buttonClassName, 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]);
40
+ const items = options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.ToggleGroupItem, {
41
+ value: String(option.value),
42
+ "aria-label": String(option.value),
43
+ disabled: option.disabled,
44
+ className: buttonClassName,
45
+ children: option.label
46
+ }, String(option.value)));
47
+ if (type === "multiple") {
48
+ const multiValue = Array.isArray(value) ? value.map(String) : [];
49
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.ToggleGroup, {
50
+ ...props,
51
+ ref,
52
+ type: "multiple",
53
+ value: multiValue,
54
+ variant: toVariant(variant),
55
+ size: toSize(size),
56
+ onValueChange: (nextValues) => {
57
+ const mappedValues = nextValues.map((v) => valueByString.get(v) ?? v);
58
+ onValueChange?.(mappedValues);
59
+ },
60
+ children: items
61
+ });
62
+ }
63
+ const valueString = value === void 0 || Array.isArray(value) ? void 0 : String(value);
64
+ const defaultValueString = defaultValue === void 0 || Array.isArray(defaultValue) ? void 0 : String(defaultValue);
42
65
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.ToggleGroup, {
43
66
  ...props,
44
67
  ref,
@@ -55,13 +78,7 @@ function ToggleGroupBase({ options, value, defaultValue, onValueChange, allowEmp
55
78
  }
56
79
  onValueChange?.(valueByString.get(nextValue) ?? nextValue);
57
80
  },
58
- children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.ToggleGroupItem, {
59
- value: String(option.value),
60
- "aria-label": String(option.value),
61
- disabled: option.disabled,
62
- className: buttonClassName,
63
- children: option.label
64
- }, String(option.value)))
81
+ children: items
65
82
  });
66
83
  }
67
84
  /**
@@ -99,10 +116,22 @@ const ToggleGroup = (0, __formily_react.connect)(ToggleGroupBase, (0, __formily_
99
116
  }, (props, field) => {
100
117
  const toggleGroupProps = props;
101
118
  const fieldValue = field.value;
119
+ const isMultiple = props.type === "multiple";
102
120
  const resolvedOptions = coerceOptions(require_resolve_field_options.resolveFieldOptions({
103
121
  field,
104
122
  options: props.options
105
123
  }));
124
+ if (isMultiple) {
125
+ const value$1 = Array.isArray(fieldValue) ? fieldValue.filter(isToggleGroupValue) : [];
126
+ return {
127
+ ...toggleGroupProps,
128
+ options: resolvedOptions,
129
+ value: value$1,
130
+ onValueChange: (nextValue) => {
131
+ field.onInput(nextValue).catch(() => {});
132
+ }
133
+ };
134
+ }
106
135
  const value = isToggleGroupValue(fieldValue) ? fieldValue : void 0;
107
136
  return {
108
137
  ...toggleGroupProps,
@@ -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) => void) | ((value: 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) => void) | ((value: ToggleGroupValue[]) => void);
19
20
  allowEmptySelection?: boolean;
20
21
  variant?: ToggleGroupVariant;
21
22
  size?: ToggleGroupSize;
@@ -26,14 +26,37 @@ function coerceOptions(options) {
26
26
  };
27
27
  }).filter((v) => v !== null);
28
28
  }
29
- function ToggleGroupBase({ options, value, defaultValue, onValueChange, allowEmptySelection = false, variant = "outline", size, buttonClassName, ref,...props }) {
30
- const valueString = value === void 0 ? void 0 : String(value);
31
- const defaultValueString = defaultValue === void 0 ? void 0 : String(defaultValue);
29
+ function ToggleGroupBase({ type = "single", options, value, defaultValue, onValueChange, allowEmptySelection = false, variant = "outline", size, buttonClassName, ref,...props }) {
32
30
  const valueByString = React$1.useMemo(() => {
33
31
  const map = /* @__PURE__ */ new Map();
34
32
  for (const option of options) map.set(String(option.value), option.value);
35
33
  return map;
36
34
  }, [options]);
35
+ const items = options.map((option) => /* @__PURE__ */ jsx(ToggleGroupItem, {
36
+ value: String(option.value),
37
+ "aria-label": String(option.value),
38
+ disabled: option.disabled,
39
+ className: buttonClassName,
40
+ children: option.label
41
+ }, String(option.value)));
42
+ if (type === "multiple") {
43
+ const multiValue = Array.isArray(value) ? value.map(String) : [];
44
+ return /* @__PURE__ */ jsx(ToggleGroup, {
45
+ ...props,
46
+ ref,
47
+ type: "multiple",
48
+ value: multiValue,
49
+ variant: toVariant(variant),
50
+ size: toSize(size),
51
+ onValueChange: (nextValues) => {
52
+ const mappedValues = nextValues.map((v) => valueByString.get(v) ?? v);
53
+ onValueChange?.(mappedValues);
54
+ },
55
+ children: items
56
+ });
57
+ }
58
+ const valueString = value === void 0 || Array.isArray(value) ? void 0 : String(value);
59
+ const defaultValueString = defaultValue === void 0 || Array.isArray(defaultValue) ? void 0 : String(defaultValue);
37
60
  return /* @__PURE__ */ jsx(ToggleGroup, {
38
61
  ...props,
39
62
  ref,
@@ -50,13 +73,7 @@ function ToggleGroupBase({ options, value, defaultValue, onValueChange, allowEmp
50
73
  }
51
74
  onValueChange?.(valueByString.get(nextValue) ?? nextValue);
52
75
  },
53
- children: options.map((option) => /* @__PURE__ */ jsx(ToggleGroupItem, {
54
- value: String(option.value),
55
- "aria-label": String(option.value),
56
- disabled: option.disabled,
57
- className: buttonClassName,
58
- children: option.label
59
- }, String(option.value)))
76
+ children: items
60
77
  });
61
78
  }
62
79
  /**
@@ -94,10 +111,22 @@ const ToggleGroup$1 = connect(ToggleGroupBase, mapProps({
94
111
  }, (props, field) => {
95
112
  const toggleGroupProps = props;
96
113
  const fieldValue = field.value;
114
+ const isMultiple = props.type === "multiple";
97
115
  const resolvedOptions = coerceOptions(resolveFieldOptions({
98
116
  field,
99
117
  options: props.options
100
118
  }));
119
+ if (isMultiple) {
120
+ const value$1 = Array.isArray(fieldValue) ? fieldValue.filter(isToggleGroupValue) : [];
121
+ return {
122
+ ...toggleGroupProps,
123
+ options: resolvedOptions,
124
+ value: value$1,
125
+ onValueChange: (nextValue) => {
126
+ field.onInput(nextValue).catch(() => {});
127
+ }
128
+ };
129
+ }
101
130
  const value = isToggleGroupValue(fieldValue) ? fieldValue : void 0;
102
131
  return {
103
132
  ...toggleGroupProps,
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as _pixpilot_shadcn_ui3 from "@pixpilot/shadcn-ui";
2
+ import * as _pixpilot_shadcn_ui13 from "@pixpilot/shadcn-ui";
3
3
 
4
4
  //#region src/components/file-upload/FileUpload.d.ts
5
5
 
@@ -7,14 +7,14 @@ import * as _pixpilot_shadcn_ui3 from "@pixpilot/shadcn-ui";
7
7
  * Formily-connected FileUploadInline component
8
8
  * Automatically connects shadcn FileUploadInline to Formily field state
9
9
  */
10
- declare const FileUpload$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui3.FileUploadInlineBaseProps & _pixpilot_shadcn_ui3.FileUploadRootPropsBaseProps & {
10
+ declare const FileUpload$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui13.FileUploadInlineBaseProps & _pixpilot_shadcn_ui13.FileUploadRootPropsBaseProps & {
11
11
  multiple: true;
12
- value?: _pixpilot_shadcn_ui3.FileMetadata[];
13
- onChange?: _pixpilot_shadcn_ui3.OnChangeMultipleFiles;
14
- } & _pixpilot_shadcn_ui3.FileUploadBaseProps>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui3.FileUploadInlineBaseProps & _pixpilot_shadcn_ui3.FileUploadRootPropsBaseProps & {
12
+ value?: _pixpilot_shadcn_ui13.FileMetadata[];
13
+ onChange?: _pixpilot_shadcn_ui13.OnChangeMultipleFiles;
14
+ } & _pixpilot_shadcn_ui13.FileUploadBaseProps>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui13.FileUploadInlineBaseProps & _pixpilot_shadcn_ui13.FileUploadRootPropsBaseProps & {
15
15
  multiple?: false;
16
- value?: _pixpilot_shadcn_ui3.FileMetadata | null;
17
- onChange?: _pixpilot_shadcn_ui3.OnChangeSingleFile;
18
- } & _pixpilot_shadcn_ui3.FileUploadBaseProps>, "ref">) & React.RefAttributes<unknown>>;
16
+ value?: _pixpilot_shadcn_ui13.FileMetadata | null;
17
+ onChange?: _pixpilot_shadcn_ui13.OnChangeSingleFile;
18
+ } & _pixpilot_shadcn_ui13.FileUploadBaseProps>, "ref">) & React.RefAttributes<unknown>>;
19
19
  //#endregion
20
20
  export { FileUpload$1 as FileUpload };
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as _pixpilot_shadcn_ui13 from "@pixpilot/shadcn-ui";
2
+ import * as _pixpilot_shadcn_ui3 from "@pixpilot/shadcn-ui";
3
3
 
4
4
  //#region src/components/file-upload/FileUploadInline.d.ts
5
5
 
@@ -7,14 +7,14 @@ import * as _pixpilot_shadcn_ui13 from "@pixpilot/shadcn-ui";
7
7
  * Formily-connected FileUploadInline component
8
8
  * Automatically connects shadcn FileUploadInline to Formily field state
9
9
  */
10
- declare const FileUploadInline$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui13.FileUploadInlineBaseProps & _pixpilot_shadcn_ui13.FileUploadRootPropsBaseProps & {
10
+ declare const FileUploadInline$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui3.FileUploadInlineBaseProps & _pixpilot_shadcn_ui3.FileUploadRootPropsBaseProps & {
11
11
  multiple: true;
12
- value?: _pixpilot_shadcn_ui13.FileMetadata[];
13
- onChange?: _pixpilot_shadcn_ui13.OnChangeMultipleFiles;
14
- } & _pixpilot_shadcn_ui13.FileUploadBaseProps>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui13.FileUploadInlineBaseProps & _pixpilot_shadcn_ui13.FileUploadRootPropsBaseProps & {
12
+ value?: _pixpilot_shadcn_ui3.FileMetadata[];
13
+ onChange?: _pixpilot_shadcn_ui3.OnChangeMultipleFiles;
14
+ } & _pixpilot_shadcn_ui3.FileUploadBaseProps>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui3.FileUploadInlineBaseProps & _pixpilot_shadcn_ui3.FileUploadRootPropsBaseProps & {
15
15
  multiple?: false;
16
- value?: _pixpilot_shadcn_ui13.FileMetadata | null;
17
- onChange?: _pixpilot_shadcn_ui13.OnChangeSingleFile;
18
- } & _pixpilot_shadcn_ui13.FileUploadBaseProps>, "ref">) & React.RefAttributes<unknown>>;
16
+ value?: _pixpilot_shadcn_ui3.FileMetadata | null;
17
+ onChange?: _pixpilot_shadcn_ui3.OnChangeSingleFile;
18
+ } & _pixpilot_shadcn_ui3.FileUploadBaseProps>, "ref">) & React.RefAttributes<unknown>>;
19
19
  //#endregion
20
20
  export { FileUploadInline$1 as FileUploadInline };