@pixpilot/formily-shadcn 1.9.1 → 1.10.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.
@@ -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 react_jsx_runtime0 from "react/jsx-runtime";
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.d.ts
@@ -25,6 +25,6 @@ declare function Form$1({
25
25
  onAutoSubmit,
26
26
  layout,
27
27
  settings
28
- }: IFormProps): react_jsx_runtime0.JSX.Element;
28
+ }: IFormProps): react_jsx_runtime1.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_runtime1 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime2 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_runtime1.JSX.Element;
10
+ }: IFormGridProps): react_jsx_runtime2.JSX.Element;
11
11
  //#endregion
12
12
  export { FormGrid };
@@ -1,4 +1,4 @@
1
- import * as react4 from "react";
1
+ import * as react7 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: react4.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
11
+ declare const IconPicker$1: react7.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
12
12
  providers?: IconProviderProps[];
13
- }> & react4.RefAttributes<unknown>>;
13
+ }> & react7.RefAttributes<unknown>>;
14
14
  //#endregion
15
15
  export { IconPicker$1 as IconPicker };
@@ -1,4 +1,4 @@
1
- import * as react6 from "react";
1
+ import * as react9 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: react6.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui0.IconToggleProps, "ref"> & react6.RefAttributes<HTMLButtonElement>>, "ref"> & react6.RefAttributes<unknown>>;
9
+ declare const IconToggle$1: react9.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui0.IconToggleProps, "ref"> & react9.RefAttributes<HTMLButtonElement>>, "ref"> & react9.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { IconToggle$1 as IconToggle };
@@ -1,4 +1,4 @@
1
- import * as react9 from "react";
1
+ import * as react12 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: react12.ForwardRefExoticComponent<Omit<Partial<react12.ClassAttributes<HTMLInputElement> & react12.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"> & react12.RefAttributes<unknown>>;
16
16
  //#endregion
17
17
  export { Input };
@@ -1,5 +1,5 @@
1
1
  import { FC } from "react";
2
- import * as react_jsx_runtime2 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime0 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): react_jsx_runtime2.JSX.Element;
18
+ declare function Radio(props: RadioProps): react_jsx_runtime0.JSX.Element;
19
19
  declare namespace Radio {
20
20
  var displayName: string;
21
21
  }
@@ -1,4 +1,4 @@
1
- import * as react13 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/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: react13.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui0.RatingProps & {
10
- children?: react13.ReactNode | undefined;
11
- }> & react13.RefAttributes<unknown>>;
9
+ declare const Rating$1: react4.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui0.RatingProps & {
10
+ children?: react4.ReactNode | undefined;
11
+ }> & react4.RefAttributes<unknown>>;
12
12
  //#endregion
13
13
  export { Rating$1 as Rating };
@@ -1,5 +1,5 @@
1
- import * as react22 from "react";
2
- import * as _pixpilot_shadcn_ui1 from "@pixpilot/shadcn-ui";
1
+ import * as react29 from "react";
2
+ import * as _pixpilot_shadcn_ui2 from "@pixpilot/shadcn-ui";
3
3
 
4
4
  //#region src/components/TagsInputInline.d.ts
5
5
 
@@ -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: react29.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui2.TagsInputProps> & react29.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 };
@@ -1,11 +1,11 @@
1
- import * as react28 from "react";
2
- import * as _pixpilot_shadcn_ui2 from "@pixpilot/shadcn-ui";
1
+ import * as react26 from "react";
2
+ import * as _pixpilot_shadcn_ui1 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$1: react28.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui2.ToggleButtonProps, "ref"> & react28.RefAttributes<HTMLButtonElement>>, "ref"> & react28.RefAttributes<unknown>>;
9
+ declare const ToggleButton$1: react26.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui1.ToggleButtonProps, "ref"> & react26.RefAttributes<HTMLButtonElement>>, "ref"> & react26.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { ToggleButton$1 as ToggleButton };
@@ -26,7 +26,7 @@ const BaseAvatarUpload = (props) => {
26
26
  * Formily-connected AvatarUpload component
27
27
  * Automatically connects shadcn AvatarUpload to Formily field state
28
28
  */
29
- const AvatarUpload = (0, __formily_react.connect)(BaseAvatarUpload, (0, __formily_react.mapProps)((props, field) => require_map_upload_props.mapUploadProps(props, field)));
29
+ const AvatarUpload = (0, __formily_react.connect)(BaseAvatarUpload, (0, __formily_react.mapProps)((props, field) => require_map_upload_props.mapUploadProps(props, field, { forceSingle: true })));
30
30
 
31
31
  //#endregion
32
32
  exports.AvatarUpload = AvatarUpload;
@@ -21,7 +21,7 @@ const BaseAvatarUpload = (props) => {
21
21
  * Formily-connected AvatarUpload component
22
22
  * Automatically connects shadcn AvatarUpload to Formily field state
23
23
  */
24
- const AvatarUpload$1 = connect(BaseAvatarUpload, mapProps((props, field) => mapUploadProps(props, field)));
24
+ const AvatarUpload$1 = connect(BaseAvatarUpload, mapProps((props, field) => mapUploadProps(props, field, { forceSingle: true })));
25
25
 
26
26
  //#endregion
27
27
  export { AvatarUpload$1 as AvatarUpload };
@@ -26,7 +26,7 @@ const BaseFileUploadInline = (props) => {
26
26
  * Formily-connected FileUploadInline component
27
27
  * Automatically connects shadcn FileUploadInline to Formily field state
28
28
  */
29
- const FileUploadInline = (0, __formily_react.connect)(BaseFileUploadInline, (0, __formily_react.mapProps)((props, field) => require_map_upload_props.mapUploadProps(props, field)));
29
+ const FileUploadInline = (0, __formily_react.connect)(BaseFileUploadInline, (0, __formily_react.mapProps)((props, field) => require_map_upload_props.mapUploadProps(props, field, { forceSingle: props.multiple !== true })));
30
30
 
31
31
  //#endregion
32
32
  exports.FileUploadInline = FileUploadInline;
@@ -21,7 +21,7 @@ const BaseFileUploadInline = (props) => {
21
21
  * Formily-connected FileUploadInline component
22
22
  * Automatically connects shadcn FileUploadInline to Formily field state
23
23
  */
24
- const FileUploadInline$1 = connect(BaseFileUploadInline, mapProps((props, field) => mapUploadProps(props, field)));
24
+ const FileUploadInline$1 = connect(BaseFileUploadInline, mapProps((props, field) => mapUploadProps(props, field, { forceSingle: props.multiple !== true })));
25
25
 
26
26
  //#endregion
27
27
  export { FileUploadInline$1 as FileUploadInline };
@@ -30,24 +30,29 @@
30
30
  */
31
31
  function mapUploadProps(props, field, options) {
32
32
  const { onFileSuccess, onFileError, mapValue,...restProps } = props;
33
- const isSingle = options?.forceSingle === true || props.multiple === false;
33
+ const { multiple } = props;
34
+ const isSingle = multiple !== true && (options?.forceSingle === true || multiple === false);
34
35
  const baseValue = field.value ?? null;
35
36
  const value = mapValue ? mapValue(baseValue) : baseValue;
37
+ const currentMultipleFiles = (() => {
38
+ const currentValue = field.value;
39
+ if (Array.isArray(currentValue)) return currentValue;
40
+ if (currentValue == null) return [];
41
+ return [currentValue];
42
+ })();
36
43
  return {
37
44
  ...restProps,
38
45
  value,
39
46
  onChange: (newValue) => {
40
47
  if (newValue === null) field.setValue(null);
41
48
  else if (Array.isArray(newValue)) {
42
- const currentLen = (field.value ?? []).length;
49
+ const currentLen = currentMultipleFiles.length;
43
50
  if (newValue.length <= currentLen) field.setValue(newValue);
44
51
  }
45
52
  },
46
53
  onFileSuccess: (fileMeta) => {
47
- if (!isSingle) {
48
- const current = field.value ?? [];
49
- field.setValue([...current, fileMeta]);
50
- } else field.setValue(fileMeta);
54
+ if (!isSingle) field.setValue([...currentMultipleFiles, fileMeta]);
55
+ else field.setValue(fileMeta);
51
56
  onFileSuccess?.(fileMeta);
52
57
  },
53
58
  onFileError: (file, error) => {
@@ -29,24 +29,29 @@
29
29
  */
30
30
  function mapUploadProps(props, field, options) {
31
31
  const { onFileSuccess, onFileError, mapValue,...restProps } = props;
32
- const isSingle = options?.forceSingle === true || props.multiple === false;
32
+ const { multiple } = props;
33
+ const isSingle = multiple !== true && (options?.forceSingle === true || multiple === false);
33
34
  const baseValue = field.value ?? null;
34
35
  const value = mapValue ? mapValue(baseValue) : baseValue;
36
+ const currentMultipleFiles = (() => {
37
+ const currentValue = field.value;
38
+ if (Array.isArray(currentValue)) return currentValue;
39
+ if (currentValue == null) return [];
40
+ return [currentValue];
41
+ })();
35
42
  return {
36
43
  ...restProps,
37
44
  value,
38
45
  onChange: (newValue) => {
39
46
  if (newValue === null) field.setValue(null);
40
47
  else if (Array.isArray(newValue)) {
41
- const currentLen = (field.value ?? []).length;
48
+ const currentLen = currentMultipleFiles.length;
42
49
  if (newValue.length <= currentLen) field.setValue(newValue);
43
50
  }
44
51
  },
45
52
  onFileSuccess: (fileMeta) => {
46
- if (!isSingle) {
47
- const current = field.value ?? [];
48
- field.setValue([...current, fileMeta]);
49
- } else field.setValue(fileMeta);
53
+ if (!isSingle) field.setValue([...currentMultipleFiles, fileMeta]);
54
+ else field.setValue(fileMeta);
50
55
  onFileSuccess?.(fileMeta);
51
56
  },
52
57
  onFileError: (file, error) => {
@@ -1,15 +1,15 @@
1
- import * as react31 from "react";
1
+ import * as react1879 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: react31.ForwardRefExoticComponent<Omit<Partial<react31.ClassAttributes<HTMLInputElement> & react31.InputHTMLAttributes<HTMLInputElement> & {
7
+ declare const NumberInput: react1879.ForwardRefExoticComponent<Omit<Partial<react1879.ClassAttributes<HTMLInputElement> & react1879.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"> & react31.RefAttributes<unknown>>;
13
+ }>, "ref"> & react1879.RefAttributes<unknown>>;
14
14
  //#endregion
15
15
  export { NumberInput };