@pixpilot/formily-shadcn 1.10.5 → 1.10.7

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.
Files changed (31) hide show
  1. package/dist/components/Checkbox.d.ts +2 -2
  2. package/dist/components/DatePicker.d.ts +3 -3
  3. package/dist/components/IconPicker.d.cts +3 -3
  4. package/dist/components/IconPicker.d.ts +3 -3
  5. package/dist/components/IconToggle.d.cts +2 -2
  6. package/dist/components/Input.d.cts +3 -3
  7. package/dist/components/Radio.d.ts +2 -2
  8. package/dist/components/Row.d.ts +2 -2
  9. package/dist/components/Separator.d.ts +2 -2
  10. package/dist/components/Switch.d.ts +2 -2
  11. package/dist/components/TagsInputInline.d.cts +2 -2
  12. package/dist/components/TagsInputInline.d.ts +2 -2
  13. package/dist/components/Textarea.d.cts +2 -2
  14. package/dist/components/Textarea.d.ts +2 -2
  15. package/dist/components/array-tags/ArrayTags.d.cts +2 -2
  16. package/dist/components/context/types.d.cts +2 -2
  17. package/dist/components/context/types.d.ts +2 -2
  18. package/dist/components/file-upload/map-upload-props.cjs +7 -2
  19. package/dist/components/file-upload/map-upload-props.js +7 -2
  20. package/dist/components/file-upload/use-file-upload-feedback.cjs +43 -29
  21. package/dist/components/file-upload/use-file-upload-feedback.js +43 -29
  22. package/dist/components/form-item/ConnectedFormItem.d.cts +4 -4
  23. package/dist/components/number/NumberInput.d.cts +3 -3
  24. package/dist/components/schema-field/schema-field-basics.d.cts +303 -303
  25. package/dist/components/schema-field/schema-field-extended.d.cts +501 -501
  26. package/dist/components/schema-field/schema-field.d.cts +412 -412
  27. package/dist/components/slider/Slider.d.ts +3 -3
  28. package/dist/components/slider/SliderInput.d.ts +3 -3
  29. package/dist/components/slider/SliderSelect.d.cts +3 -3
  30. package/dist/components/slider/SliderSelect.d.ts +3 -3
  31. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- import * as react0 from "react";
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: react0.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_checkbox0.CheckboxProps & react0.RefAttributes<HTMLButtonElement>>, "ref"> & react0.RefAttributes<unknown>>;
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 react2 from "react";
1
+ import * as react4 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: react2.ForwardRefExoticComponent<Partial<{
5
+ declare const DatePicker$1: react4.ForwardRefExoticComponent<Partial<{
6
6
  value?: Date;
7
7
  onChange?: (date: Date | undefined) => void;
8
8
  placeholder?: string;
9
- } & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react2.RefAttributes<unknown>>;
9
+ } & Omit<DatePickerProps, "onSelect" | "selected" | "mode">> & react4.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { DatePicker$1 as DatePicker };
@@ -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: react4.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
11
+ declare const IconPicker: 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,4 +1,4 @@
1
- import * as react4 from "react";
1
+ import * as react0 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: react0.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
12
12
  providers?: IconProviderProps[];
13
- }> & react4.RefAttributes<unknown>>;
13
+ }> & react0.RefAttributes<unknown>>;
14
14
  //#endregion
15
15
  export { IconPicker$1 as IconPicker };
@@ -1,4 +1,4 @@
1
- import * as react10 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: react10.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui0.IconToggleProps, "ref"> & react10.RefAttributes<HTMLButtonElement>>, "ref"> & react10.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 react6 from "react";
1
+ import * as react9 from "react";
2
2
 
3
3
  //#region src/components/Input.d.ts
4
4
 
@@ -6,12 +6,12 @@ import * as react6 from "react";
6
6
  * Formily-connected Input component
7
7
  * Automatically connects shadcn Input to Formily field state
8
8
  */
9
- declare const Input: react6.ForwardRefExoticComponent<Omit<Partial<react6.ClassAttributes<HTMLInputElement> & react6.InputHTMLAttributes<HTMLInputElement> & {
9
+ declare const Input: react9.ForwardRefExoticComponent<Omit<Partial<react9.ClassAttributes<HTMLInputElement> & react9.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"> & react6.RefAttributes<unknown>>;
15
+ }>, "ref"> & react9.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_runtime3 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_runtime3.JSX.Element;
19
19
  declare namespace Radio {
20
20
  var displayName: string;
21
21
  }
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as react_jsx_runtime3 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime2 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): react_jsx_runtime3.JSX.Element;
39
+ }: IRowProps): react_jsx_runtime2.JSX.Element;
40
40
  //#endregion
41
41
  export { Row };
@@ -1,4 +1,4 @@
1
- import * as react16 from "react";
1
+ import * as react19 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: react16.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_separator0.SeparatorProps & react16.RefAttributes<HTMLDivElement>>, "ref"> & react16.RefAttributes<unknown>>;
9
+ declare const Separator: react19.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_separator0.SeparatorProps & react19.RefAttributes<HTMLDivElement>>, "ref"> & react19.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { Separator };
@@ -1,4 +1,4 @@
1
- import * as react19 from "react";
1
+ import * as react16 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: react19.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_switch0.SwitchProps & react19.RefAttributes<HTMLButtonElement>>, "ref"> & react19.RefAttributes<unknown>>;
9
+ declare const Switch: react16.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_switch0.SwitchProps & react16.RefAttributes<HTMLButtonElement>>, "ref"> & react16.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { Switch };
@@ -1,4 +1,4 @@
1
- import * as react26 from "react";
1
+ import * as react22 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: react26.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui1.TagsInputProps> & react26.RefAttributes<unknown>>;
13
+ declare const TagsInputInLine: react22.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui1.TagsInputProps> & react22.RefAttributes<unknown>>;
14
14
  //#endregion
15
15
  export { TagsInputInLine };
@@ -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 react22 from "react";
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: react22.ForwardRefExoticComponent<Omit<Partial<react22.ClassAttributes<HTMLTextAreaElement> & react22.TextareaHTMLAttributes<HTMLTextAreaElement>>, "ref"> & react22.RefAttributes<unknown>>;
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 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,4 +1,4 @@
1
- import * as _formily_react0 from "@formily/react";
1
+ import * as _formily_react102 from "@formily/react";
2
2
  import React from "react";
3
3
  import { TagsInputProps } from "@pixpilot/shadcn-ui";
4
4
 
@@ -54,6 +54,6 @@ interface ArrayTagsProps extends TagsInputProps {
54
54
  * };
55
55
  * ```
56
56
  */
57
- declare const ArrayTags: React.MemoExoticComponent<_formily_react0.ReactFC<ArrayTagsProps>>;
57
+ declare const ArrayTags: React.MemoExoticComponent<_formily_react102.ReactFC<ArrayTagsProps>>;
58
58
  //#endregion
59
59
  export { ArrayTags, ArrayTagsProps };
@@ -2,11 +2,11 @@ import { ActionItem } from "../array-base/types.cjs";
2
2
  import "../array-base/index.cjs";
3
3
  import { FormSpace } from "../../types/form.cjs";
4
4
  import { DescriptionPlacement, LabelPlacement } from "../../types/form-item.cjs";
5
- import { DialogContentProps, FileUploadProgressCallBacks, IconProvider, PopoverContentProps, RichTextEditorProps } from "@pixpilot/shadcn-ui";
5
+ import { DialogContentProps, FormFileUploadOptions, IconProvider, PopoverContentProps, RichTextEditorProps } from "@pixpilot/shadcn-ui";
6
6
 
7
7
  //#region src/components/context/types.d.ts
8
8
  interface FomFileUpload {
9
- onUpload?: (files: File[], options: FileUploadProgressCallBacks) => void;
9
+ onUpload?: (files: File[], options: FormFileUploadOptions) => void;
10
10
  maxSize?: number;
11
11
  }
12
12
  interface FormSettings {
@@ -2,11 +2,11 @@ import { ActionItem } from "../array-base/types.js";
2
2
  import "../array-base/index.js";
3
3
  import { FormSpace } from "../../types/form.js";
4
4
  import { DescriptionPlacement, LabelPlacement } from "../../types/form-item.js";
5
- import { DialogContentProps, FileUploadProgressCallBacks, IconProvider, PopoverContentProps, RichTextEditorProps } from "@pixpilot/shadcn-ui";
5
+ import { DialogContentProps, FormFileUploadOptions, IconProvider, PopoverContentProps, RichTextEditorProps } from "@pixpilot/shadcn-ui";
6
6
 
7
7
  //#region src/components/context/types.d.ts
8
8
  interface FomFileUpload {
9
- onUpload?: (files: File[], options: FileUploadProgressCallBacks) => void;
9
+ onUpload?: (files: File[], options: FormFileUploadOptions) => void;
10
10
  maxSize?: number;
11
11
  }
12
12
  interface FormSettings {
@@ -44,8 +44,13 @@ function mapUploadProps(props, field, options) {
44
44
  ...restProps,
45
45
  value,
46
46
  onChange: (newValue) => {
47
- if (newValue === null) field.setValue(null);
48
- else if (Array.isArray(newValue)) {
47
+ if (newValue === null) {
48
+ field.setValue(null);
49
+ if (isSingle) field.setFeedback({
50
+ type: "warning",
51
+ messages: []
52
+ });
53
+ } else if (Array.isArray(newValue)) {
49
54
  const currentLen = currentMultipleFiles.length;
50
55
  if (newValue.length <= currentLen) field.setValue(newValue);
51
56
  }
@@ -43,8 +43,13 @@ function mapUploadProps(props, field, options) {
43
43
  ...restProps,
44
44
  value,
45
45
  onChange: (newValue) => {
46
- if (newValue === null) field.setValue(null);
47
- else if (Array.isArray(newValue)) {
46
+ if (newValue === null) {
47
+ field.setValue(null);
48
+ if (isSingle) field.setFeedback({
49
+ type: "warning",
50
+ messages: []
51
+ });
52
+ } else if (Array.isArray(newValue)) {
48
53
  const currentLen = currentMultipleFiles.length;
49
54
  if (newValue.length <= currentLen) field.setValue(newValue);
50
55
  }
@@ -19,39 +19,53 @@ function useFileUploadFeedback(props) {
19
19
  if (onUpload == null) {
20
20
  if (process.env.NODE_ENV !== "production") throw new Error("onUpload prop required for FileUploadInline. Provide handler on form or field props.");
21
21
  }
22
- return {
23
- onUpload,
22
+ const handleFilesRejection = react.default.useCallback((files) => {
23
+ onFilesReject?.(files);
24
+ const maximumError = files.filter((f) => f.message.startsWith("Maximum"));
25
+ const withFileSizeError = files.filter((f) => f.message.startsWith("File too large"));
26
+ const otherErrors = files.filter((f) => !withFileSizeError.includes(f) && !maximumError.includes(f));
27
+ const messages = [];
28
+ if (maximumError.length > 0) messages.push(maximumError[0].message);
29
+ if (maxSize != null && withFileSizeError.length > 0) {
30
+ const fileList = withFileSizeError.map((f) => `${f.file.name} (${(0, pretty_bytes.default)(f.file.size)})`).join("\n");
31
+ messages.push(`Files exceed ${(0, pretty_bytes.default)(maxSize)} limit:\n${fileList}`);
32
+ }
33
+ if (otherErrors.length > 0) otherErrors.forEach((f) => {
34
+ messages.push(`${f.message}: ${f.file.name}`);
35
+ });
36
+ field.setFeedback({
37
+ type: "warning",
38
+ messages: [messages.join("\n")]
39
+ });
40
+ }, [
41
+ field,
24
42
  maxSize,
25
- handleFilesRejection: react.default.useCallback((files) => {
26
- onFilesReject?.(files);
27
- const maximumError = files.filter((f) => f.message.startsWith("Maximum"));
28
- const withFileSizeError = files.filter((f) => f.message.startsWith("File too large"));
29
- const otherErrors = files.filter((f) => !withFileSizeError.includes(f) && !maximumError.includes(f));
30
- const messages = [];
31
- if (maximumError.length > 0) messages.push(maximumError[0].message);
32
- if (maxSize != null && withFileSizeError.length > 0) {
33
- const fileList = withFileSizeError.map((f) => `${f.file.name} (${(0, pretty_bytes.default)(f.file.size)})`).join("\n");
34
- messages.push(`Files exceed ${(0, pretty_bytes.default)(maxSize)} limit:\n${fileList}`);
35
- }
36
- if (otherErrors.length > 0) otherErrors.forEach((f) => {
37
- messages.push(`${f.message}: ${f.file.name}`);
38
- });
39
- field.setFeedback({
40
- type: "warning",
41
- messages: [messages.join("\n")]
43
+ onFilesReject
44
+ ]);
45
+ const handleFileValidate = react.default.useCallback((file) => {
46
+ field.setFeedback({
47
+ type: "warning",
48
+ messages: []
49
+ });
50
+ return onFileValidate?.(file);
51
+ }, [field, onFileValidate]);
52
+ return {
53
+ onUpload: react.default.useCallback(async (files, options) => {
54
+ if (onUploadProp) return onUploadProp(files, options);
55
+ return onUpload?.(files, {
56
+ ...options,
57
+ component: field.componentType,
58
+ componentProps: { ...field.componentProps }
42
59
  });
43
60
  }, [
44
- field,
45
- maxSize,
46
- onFilesReject
61
+ field.componentProps,
62
+ field.componentType,
63
+ onUpload,
64
+ onUploadProp
47
65
  ]),
48
- handleFileValidate: react.default.useCallback((file) => {
49
- field.setFeedback({
50
- type: "warning",
51
- messages: []
52
- });
53
- return onFileValidate?.(file);
54
- }, [field, onFileValidate])
66
+ maxSize,
67
+ handleFilesRejection,
68
+ handleFileValidate
55
69
  };
56
70
  }
57
71
 
@@ -13,39 +13,53 @@ function useFileUploadFeedback(props) {
13
13
  const onUpload = onUploadProp ?? fileUpload?.onUpload;
14
14
  const maxSize = maxSizeProp ?? fileUpload?.maxSize;
15
15
  if (onUpload == null) throw new Error("onUpload prop required for FileUploadInline. Provide handler on form or field props.");
16
- return {
17
- onUpload,
16
+ const handleFilesRejection = React.useCallback((files) => {
17
+ onFilesReject?.(files);
18
+ const maximumError = files.filter((f) => f.message.startsWith("Maximum"));
19
+ const withFileSizeError = files.filter((f) => f.message.startsWith("File too large"));
20
+ const otherErrors = files.filter((f) => !withFileSizeError.includes(f) && !maximumError.includes(f));
21
+ const messages = [];
22
+ if (maximumError.length > 0) messages.push(maximumError[0].message);
23
+ if (maxSize != null && withFileSizeError.length > 0) {
24
+ const fileList = withFileSizeError.map((f) => `${f.file.name} (${prettyBytes(f.file.size)})`).join("\n");
25
+ messages.push(`Files exceed ${prettyBytes(maxSize)} limit:\n${fileList}`);
26
+ }
27
+ if (otherErrors.length > 0) otherErrors.forEach((f) => {
28
+ messages.push(`${f.message}: ${f.file.name}`);
29
+ });
30
+ field.setFeedback({
31
+ type: "warning",
32
+ messages: [messages.join("\n")]
33
+ });
34
+ }, [
35
+ field,
18
36
  maxSize,
19
- handleFilesRejection: React.useCallback((files) => {
20
- onFilesReject?.(files);
21
- const maximumError = files.filter((f) => f.message.startsWith("Maximum"));
22
- const withFileSizeError = files.filter((f) => f.message.startsWith("File too large"));
23
- const otherErrors = files.filter((f) => !withFileSizeError.includes(f) && !maximumError.includes(f));
24
- const messages = [];
25
- if (maximumError.length > 0) messages.push(maximumError[0].message);
26
- if (maxSize != null && withFileSizeError.length > 0) {
27
- const fileList = withFileSizeError.map((f) => `${f.file.name} (${prettyBytes(f.file.size)})`).join("\n");
28
- messages.push(`Files exceed ${prettyBytes(maxSize)} limit:\n${fileList}`);
29
- }
30
- if (otherErrors.length > 0) otherErrors.forEach((f) => {
31
- messages.push(`${f.message}: ${f.file.name}`);
32
- });
33
- field.setFeedback({
34
- type: "warning",
35
- messages: [messages.join("\n")]
37
+ onFilesReject
38
+ ]);
39
+ const handleFileValidate = React.useCallback((file) => {
40
+ field.setFeedback({
41
+ type: "warning",
42
+ messages: []
43
+ });
44
+ return onFileValidate?.(file);
45
+ }, [field, onFileValidate]);
46
+ return {
47
+ onUpload: React.useCallback(async (files, options) => {
48
+ if (onUploadProp) return onUploadProp(files, options);
49
+ return onUpload?.(files, {
50
+ ...options,
51
+ component: field.componentType,
52
+ componentProps: { ...field.componentProps }
36
53
  });
37
54
  }, [
38
- field,
39
- maxSize,
40
- onFilesReject
55
+ field.componentProps,
56
+ field.componentType,
57
+ onUpload,
58
+ onUploadProp
41
59
  ]),
42
- handleFileValidate: React.useCallback((file) => {
43
- field.setFeedback({
44
- type: "warning",
45
- messages: []
46
- });
47
- return onFileValidate?.(file);
48
- }, [field, onFileValidate])
60
+ maxSize,
61
+ handleFilesRejection,
62
+ handleFileValidate
49
63
  };
50
64
  }
51
65
 
@@ -1,13 +1,13 @@
1
1
  import { FormItemProps } from "./form-item-types.cjs";
2
- import * as react1891 from "react";
2
+ import * as react1889 from "react";
3
3
 
4
4
  //#region src/components/form-item/ConnectedFormItem.d.ts
5
5
  /**
6
6
  * FormItem component connected to Formily field state.
7
7
  * Automatically maps field validation state to component props.
8
8
  */
9
- declare const FormItem: react1891.ForwardRefExoticComponent<Omit<Partial<FormItemProps & {
10
- children?: react1891.ReactNode | undefined;
11
- }>, "ref"> & react1891.RefAttributes<unknown>>;
9
+ declare const FormItem: react1889.ForwardRefExoticComponent<Omit<Partial<FormItemProps & {
10
+ children?: react1889.ReactNode | undefined;
11
+ }>, "ref"> & react1889.RefAttributes<unknown>>;
12
12
  //#endregion
13
13
  export { FormItem };
@@ -1,15 +1,15 @@
1
- import * as react31 from "react";
1
+ import * as react33 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: react33.ForwardRefExoticComponent<Omit<Partial<react33.ClassAttributes<HTMLInputElement> & react33.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"> & react33.RefAttributes<unknown>>;
14
14
  //#endregion
15
15
  export { NumberInput };