@pixpilot/formily-shadcn 1.7.5 → 1.8.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/Switch.d.cts +2 -2
- package/dist/components/TagsInputInline.d.cts +3 -3
- package/dist/components/Textarea.d.cts +2 -2
- package/dist/components/ToggleButton.d.cts +3 -3
- package/dist/components/file-upload/AvatarUpload.cjs +2 -6
- package/dist/components/file-upload/AvatarUpload.js +2 -6
- package/dist/components/file-upload/FileUpload.cjs +4 -8
- package/dist/components/file-upload/FileUpload.d.cts +10 -10
- package/dist/components/file-upload/FileUpload.d.ts +10 -10
- package/dist/components/file-upload/FileUpload.js +4 -8
- package/dist/components/file-upload/FileUploadInline.cjs +2 -6
- package/dist/components/file-upload/FileUploadInline.d.cts +8 -8
- package/dist/components/file-upload/FileUploadInline.d.ts +8 -8
- package/dist/components/file-upload/FileUploadInline.js +2 -6
- package/dist/components/file-upload/map-upload-props.cjs +46 -0
- package/dist/components/file-upload/map-upload-props.js +45 -0
- package/dist/components/number/NumberInput.d.cts +3 -3
- package/dist/components/schema-field/schema-field-basics.d.cts +303 -303
- package/dist/components/schema-field/schema-field-extended.d.cts +485 -485
- package/dist/components/schema-field/schema-field.d.cts +413 -413
- package/dist/components/slider/Slider.d.cts +3 -3
- package/dist/components/slider/Slider.d.ts +3 -3
- package/dist/components/slider/SliderInput.d.cts +3 -3
- package/dist/components/slider/SliderInput.d.ts +3 -3
- package/dist/components/slider/SliderSelect.d.cts +3 -3
- package/dist/components/slider/SliderSelect.d.ts +3 -3
- package/package.json +4 -4
|
@@ -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 react22 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: react22.ForwardRefExoticComponent<Partial<_pixpilot_shadcn_ui1.TagsInputProps> & react22.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,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,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_map_upload_props = require('./map-upload-props.cjs');
|
|
2
3
|
const require_use_file_upload_feedback = require('./use-file-upload-feedback.cjs');
|
|
3
4
|
let __formily_react = require("@formily/react");
|
|
4
5
|
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
@@ -24,12 +25,7 @@ const BaseAvatarUpload = (props) => {
|
|
|
24
25
|
* Formily-connected AvatarUpload component
|
|
25
26
|
* Automatically connects shadcn AvatarUpload to Formily field state
|
|
26
27
|
*/
|
|
27
|
-
const AvatarUpload = (0, __formily_react.connect)(BaseAvatarUpload, (0, __formily_react.mapProps)((props, field) =>
|
|
28
|
-
return {
|
|
29
|
-
...props,
|
|
30
|
-
value: field.value ?? null
|
|
31
|
-
};
|
|
32
|
-
}));
|
|
28
|
+
const AvatarUpload = (0, __formily_react.connect)(BaseAvatarUpload, (0, __formily_react.mapProps)((props, field) => require_map_upload_props.mapUploadProps(props, field)));
|
|
33
29
|
|
|
34
30
|
//#endregion
|
|
35
31
|
exports.AvatarUpload = AvatarUpload;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mapUploadProps } from "./map-upload-props.js";
|
|
1
2
|
import { useFileUploadFeedback } from "./use-file-upload-feedback.js";
|
|
2
3
|
import { connect, mapProps } from "@formily/react";
|
|
3
4
|
import React from "react";
|
|
@@ -19,12 +20,7 @@ const BaseAvatarUpload = (props) => {
|
|
|
19
20
|
* Formily-connected AvatarUpload component
|
|
20
21
|
* Automatically connects shadcn AvatarUpload to Formily field state
|
|
21
22
|
*/
|
|
22
|
-
const AvatarUpload$1 = connect(BaseAvatarUpload, mapProps((props, field) =>
|
|
23
|
-
return {
|
|
24
|
-
...props,
|
|
25
|
-
value: field.value ?? null
|
|
26
|
-
};
|
|
27
|
-
}));
|
|
23
|
+
const AvatarUpload$1 = connect(BaseAvatarUpload, mapProps((props, field) => mapUploadProps(props, field)));
|
|
28
24
|
|
|
29
25
|
//#endregion
|
|
30
26
|
export { AvatarUpload$1 as AvatarUpload };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_map_upload_props = require('./map-upload-props.cjs');
|
|
2
3
|
const require_use_file_upload_feedback = require('./use-file-upload-feedback.cjs');
|
|
3
4
|
let __formily_react = require("@formily/react");
|
|
4
5
|
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
@@ -21,15 +22,10 @@ const BaseFileUpload = (props) => {
|
|
|
21
22
|
});
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
24
|
-
* Formily-connected
|
|
25
|
-
* Automatically connects shadcn
|
|
25
|
+
* Formily-connected FileUpload component
|
|
26
|
+
* Automatically connects shadcn FileUpload to Formily field state
|
|
26
27
|
*/
|
|
27
|
-
const FileUpload = (0, __formily_react.connect)(BaseFileUpload, (0, __formily_react.mapProps)((props, field) =>
|
|
28
|
-
return {
|
|
29
|
-
...props,
|
|
30
|
-
value: field.value ?? null
|
|
31
|
-
};
|
|
32
|
-
}));
|
|
28
|
+
const FileUpload = (0, __formily_react.connect)(BaseFileUpload, (0, __formily_react.mapProps)((props, field) => require_map_upload_props.mapUploadProps(props, field)));
|
|
33
29
|
|
|
34
30
|
//#endregion
|
|
35
31
|
exports.FileUpload = FileUpload;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _pixpilot_shadcn_ui15 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/file-upload/FileUpload.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Formily-connected
|
|
8
|
-
* Automatically connects shadcn
|
|
7
|
+
* Formily-connected FileUpload component
|
|
8
|
+
* Automatically connects shadcn FileUpload to Formily field state
|
|
9
9
|
*/
|
|
10
|
-
declare const FileUpload: React.ForwardRefExoticComponent<(Omit<Partial<
|
|
10
|
+
declare const FileUpload: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui15.FileUploadInlineBaseProps & _pixpilot_shadcn_ui15.FileUploadRootPropsBaseProps & {
|
|
11
11
|
multiple: true;
|
|
12
|
-
value?:
|
|
13
|
-
onChange?:
|
|
14
|
-
} &
|
|
12
|
+
value?: _pixpilot_shadcn_ui15.FileMetadata[];
|
|
13
|
+
onChange?: _pixpilot_shadcn_ui15.OnChangeMultipleFiles;
|
|
14
|
+
} & _pixpilot_shadcn_ui15.FileUploadBaseProps & _pixpilot_shadcn_ui15.MultiFileCallbacks>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui15.FileUploadInlineBaseProps & _pixpilot_shadcn_ui15.FileUploadRootPropsBaseProps & {
|
|
15
15
|
multiple?: false;
|
|
16
|
-
value?:
|
|
17
|
-
onChange?:
|
|
18
|
-
} &
|
|
16
|
+
value?: _pixpilot_shadcn_ui15.FileMetadata | null;
|
|
17
|
+
onChange?: _pixpilot_shadcn_ui15.OnChangeSingleFile;
|
|
18
|
+
} & _pixpilot_shadcn_ui15.FileUploadBaseProps & _pixpilot_shadcn_ui15.UseFileCallbacks>, "ref">) & React.RefAttributes<unknown>>;
|
|
19
19
|
//#endregion
|
|
20
20
|
export { FileUpload };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _pixpilot_shadcn_ui15 from "@pixpilot/shadcn-ui";
|
|
3
3
|
|
|
4
4
|
//#region src/components/file-upload/FileUpload.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Formily-connected
|
|
8
|
-
* Automatically connects shadcn
|
|
7
|
+
* Formily-connected FileUpload component
|
|
8
|
+
* Automatically connects shadcn FileUpload to Formily field state
|
|
9
9
|
*/
|
|
10
|
-
declare const FileUpload$1: React.ForwardRefExoticComponent<(Omit<Partial<
|
|
10
|
+
declare const FileUpload$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui15.FileUploadInlineBaseProps & _pixpilot_shadcn_ui15.FileUploadRootPropsBaseProps & {
|
|
11
11
|
multiple: true;
|
|
12
|
-
value?:
|
|
13
|
-
onChange?:
|
|
14
|
-
} &
|
|
12
|
+
value?: _pixpilot_shadcn_ui15.FileMetadata[];
|
|
13
|
+
onChange?: _pixpilot_shadcn_ui15.OnChangeMultipleFiles;
|
|
14
|
+
} & _pixpilot_shadcn_ui15.FileUploadBaseProps & _pixpilot_shadcn_ui15.MultiFileCallbacks>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui15.FileUploadInlineBaseProps & _pixpilot_shadcn_ui15.FileUploadRootPropsBaseProps & {
|
|
15
15
|
multiple?: false;
|
|
16
|
-
value?:
|
|
17
|
-
onChange?:
|
|
18
|
-
} &
|
|
16
|
+
value?: _pixpilot_shadcn_ui15.FileMetadata | null;
|
|
17
|
+
onChange?: _pixpilot_shadcn_ui15.OnChangeSingleFile;
|
|
18
|
+
} & _pixpilot_shadcn_ui15.FileUploadBaseProps & _pixpilot_shadcn_ui15.UseFileCallbacks>, "ref">) & React.RefAttributes<unknown>>;
|
|
19
19
|
//#endregion
|
|
20
20
|
export { FileUpload$1 as FileUpload };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mapUploadProps } from "./map-upload-props.js";
|
|
1
2
|
import { useFileUploadFeedback } from "./use-file-upload-feedback.js";
|
|
2
3
|
import { connect, mapProps } from "@formily/react";
|
|
3
4
|
import React from "react";
|
|
@@ -16,15 +17,10 @@ const BaseFileUpload = (props) => {
|
|
|
16
17
|
});
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
|
-
* Formily-connected
|
|
20
|
-
* Automatically connects shadcn
|
|
20
|
+
* Formily-connected FileUpload component
|
|
21
|
+
* Automatically connects shadcn FileUpload to Formily field state
|
|
21
22
|
*/
|
|
22
|
-
const FileUpload$1 = connect(BaseFileUpload, mapProps((props, field) =>
|
|
23
|
-
return {
|
|
24
|
-
...props,
|
|
25
|
-
value: field.value ?? null
|
|
26
|
-
};
|
|
27
|
-
}));
|
|
23
|
+
const FileUpload$1 = connect(BaseFileUpload, mapProps((props, field) => mapUploadProps(props, field)));
|
|
28
24
|
|
|
29
25
|
//#endregion
|
|
30
26
|
export { FileUpload$1 as FileUpload };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_map_upload_props = require('./map-upload-props.cjs');
|
|
2
3
|
const require_use_file_upload_feedback = require('./use-file-upload-feedback.cjs');
|
|
3
4
|
let __formily_react = require("@formily/react");
|
|
4
5
|
__formily_react = require_rolldown_runtime.__toESM(__formily_react);
|
|
@@ -24,12 +25,7 @@ const BaseFileUploadInline = (props) => {
|
|
|
24
25
|
* Formily-connected FileUploadInline component
|
|
25
26
|
* Automatically connects shadcn FileUploadInline to Formily field state
|
|
26
27
|
*/
|
|
27
|
-
const FileUploadInline = (0, __formily_react.connect)(BaseFileUploadInline, (0, __formily_react.mapProps)((props, field) =>
|
|
28
|
-
return {
|
|
29
|
-
...props,
|
|
30
|
-
value: field.value ?? null
|
|
31
|
-
};
|
|
32
|
-
}));
|
|
28
|
+
const FileUploadInline = (0, __formily_react.connect)(BaseFileUploadInline, (0, __formily_react.mapProps)((props, field) => require_map_upload_props.mapUploadProps(props, field)));
|
|
33
29
|
|
|
34
30
|
//#endregion
|
|
35
31
|
exports.FileUploadInline = FileUploadInline;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
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_ui15 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: React.ForwardRefExoticComponent<(Omit<Partial<
|
|
10
|
+
declare const FileUploadInline: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui3.FileUploadInlineBaseProps & _pixpilot_shadcn_ui3.FileUploadRootPropsBaseProps & {
|
|
11
11
|
multiple: true;
|
|
12
|
-
value?:
|
|
13
|
-
onChange?:
|
|
14
|
-
} &
|
|
12
|
+
value?: _pixpilot_shadcn_ui3.FileMetadata[];
|
|
13
|
+
onChange?: _pixpilot_shadcn_ui3.OnChangeMultipleFiles;
|
|
14
|
+
} & _pixpilot_shadcn_ui3.FileUploadBaseProps & _pixpilot_shadcn_ui3.MultiFileCallbacks>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui3.FileUploadInlineBaseProps & _pixpilot_shadcn_ui3.FileUploadRootPropsBaseProps & {
|
|
15
15
|
multiple?: false;
|
|
16
|
-
value?:
|
|
17
|
-
onChange?:
|
|
18
|
-
} &
|
|
16
|
+
value?: _pixpilot_shadcn_ui3.FileMetadata | null;
|
|
17
|
+
onChange?: _pixpilot_shadcn_ui3.OnChangeSingleFile;
|
|
18
|
+
} & _pixpilot_shadcn_ui3.FileUploadBaseProps & _pixpilot_shadcn_ui3.UseFileCallbacks>, "ref">) & React.RefAttributes<unknown>>;
|
|
19
19
|
//#endregion
|
|
20
20
|
export { FileUploadInline };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
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_ui15 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<
|
|
10
|
+
declare const FileUploadInline$1: React.ForwardRefExoticComponent<(Omit<Partial<_pixpilot_shadcn_ui3.FileUploadInlineBaseProps & _pixpilot_shadcn_ui3.FileUploadRootPropsBaseProps & {
|
|
11
11
|
multiple: true;
|
|
12
|
-
value?:
|
|
13
|
-
onChange?:
|
|
14
|
-
} &
|
|
12
|
+
value?: _pixpilot_shadcn_ui3.FileMetadata[];
|
|
13
|
+
onChange?: _pixpilot_shadcn_ui3.OnChangeMultipleFiles;
|
|
14
|
+
} & _pixpilot_shadcn_ui3.FileUploadBaseProps & _pixpilot_shadcn_ui3.MultiFileCallbacks>, "ref"> | Omit<Partial<_pixpilot_shadcn_ui3.FileUploadInlineBaseProps & _pixpilot_shadcn_ui3.FileUploadRootPropsBaseProps & {
|
|
15
15
|
multiple?: false;
|
|
16
|
-
value?:
|
|
17
|
-
onChange?:
|
|
18
|
-
} &
|
|
16
|
+
value?: _pixpilot_shadcn_ui3.FileMetadata | null;
|
|
17
|
+
onChange?: _pixpilot_shadcn_ui3.OnChangeSingleFile;
|
|
18
|
+
} & _pixpilot_shadcn_ui3.FileUploadBaseProps & _pixpilot_shadcn_ui3.UseFileCallbacks>, "ref">) & React.RefAttributes<unknown>>;
|
|
19
19
|
//#endregion
|
|
20
20
|
export { FileUploadInline$1 as FileUploadInline };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mapUploadProps } from "./map-upload-props.js";
|
|
1
2
|
import { useFileUploadFeedback } from "./use-file-upload-feedback.js";
|
|
2
3
|
import { connect, mapProps } from "@formily/react";
|
|
3
4
|
import React from "react";
|
|
@@ -19,12 +20,7 @@ const BaseFileUploadInline = (props) => {
|
|
|
19
20
|
* Formily-connected FileUploadInline component
|
|
20
21
|
* Automatically connects shadcn FileUploadInline to Formily field state
|
|
21
22
|
*/
|
|
22
|
-
const FileUploadInline$1 = connect(BaseFileUploadInline, mapProps((props, field) =>
|
|
23
|
-
return {
|
|
24
|
-
...props,
|
|
25
|
-
value: field.value ?? null
|
|
26
|
-
};
|
|
27
|
-
}));
|
|
23
|
+
const FileUploadInline$1 = connect(BaseFileUploadInline, mapProps((props, field) => mapUploadProps(props, field)));
|
|
28
24
|
|
|
29
25
|
//#endregion
|
|
30
26
|
export { FileUploadInline$1 as FileUploadInline };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/file-upload/map-upload-props.ts
|
|
3
|
+
/**
|
|
4
|
+
* Shared `mapProps` mapper for all Formily-connected upload components.
|
|
5
|
+
*
|
|
6
|
+
* - Forwards `field.value` (defaulting to `null`) as the `value` prop so the
|
|
7
|
+
* component displays the currently stored file metadata.
|
|
8
|
+
* - Sets `onChange` to `undefined` to prevent Formily's default wiring from
|
|
9
|
+
* calling `field.setValue()` the moment a file is selected (i.e. before the
|
|
10
|
+
* upload completes).
|
|
11
|
+
* - Wraps `onSuccess` so that `field.setValue(fileMeta)` is called only after a
|
|
12
|
+
* successful upload, followed by the original `onSuccess` callback if one was
|
|
13
|
+
* supplied.
|
|
14
|
+
* - Wraps `onError` so that `field.setFeedback({ type: 'error', … })` is set on
|
|
15
|
+
* upload failure, followed by the original `onError` callback if one was
|
|
16
|
+
* supplied.
|
|
17
|
+
*
|
|
18
|
+
* The generic `P extends object` constraint keeps the return type identical to
|
|
19
|
+
* the input type so that the mapper satisfies Formily's `IStateMapper<T>`.
|
|
20
|
+
* Internally the props are cast to `UploadFieldCallbacks` to access the
|
|
21
|
+
* upload-specific callbacks; the multiple-file variant of `FileUploadProps`
|
|
22
|
+
* uses `onFileSuccess`/`onFileError` instead, which are simply left untouched
|
|
23
|
+
* because this function only overrides `onSuccess` and `onError`.
|
|
24
|
+
*/
|
|
25
|
+
function mapUploadProps(props, field) {
|
|
26
|
+
const { onSuccess, onError } = props;
|
|
27
|
+
return {
|
|
28
|
+
...props,
|
|
29
|
+
value: field.value ?? null,
|
|
30
|
+
onChange: void 0,
|
|
31
|
+
onSuccess: (fileMeta) => {
|
|
32
|
+
field.setValue(fileMeta);
|
|
33
|
+
onSuccess?.(fileMeta);
|
|
34
|
+
},
|
|
35
|
+
onError: (file, error) => {
|
|
36
|
+
field.setFeedback({
|
|
37
|
+
type: "error",
|
|
38
|
+
messages: [error]
|
|
39
|
+
});
|
|
40
|
+
onError?.(file, error);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.mapUploadProps = mapUploadProps;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/components/file-upload/map-upload-props.ts
|
|
2
|
+
/**
|
|
3
|
+
* Shared `mapProps` mapper for all Formily-connected upload components.
|
|
4
|
+
*
|
|
5
|
+
* - Forwards `field.value` (defaulting to `null`) as the `value` prop so the
|
|
6
|
+
* component displays the currently stored file metadata.
|
|
7
|
+
* - Sets `onChange` to `undefined` to prevent Formily's default wiring from
|
|
8
|
+
* calling `field.setValue()` the moment a file is selected (i.e. before the
|
|
9
|
+
* upload completes).
|
|
10
|
+
* - Wraps `onSuccess` so that `field.setValue(fileMeta)` is called only after a
|
|
11
|
+
* successful upload, followed by the original `onSuccess` callback if one was
|
|
12
|
+
* supplied.
|
|
13
|
+
* - Wraps `onError` so that `field.setFeedback({ type: 'error', … })` is set on
|
|
14
|
+
* upload failure, followed by the original `onError` callback if one was
|
|
15
|
+
* supplied.
|
|
16
|
+
*
|
|
17
|
+
* The generic `P extends object` constraint keeps the return type identical to
|
|
18
|
+
* the input type so that the mapper satisfies Formily's `IStateMapper<T>`.
|
|
19
|
+
* Internally the props are cast to `UploadFieldCallbacks` to access the
|
|
20
|
+
* upload-specific callbacks; the multiple-file variant of `FileUploadProps`
|
|
21
|
+
* uses `onFileSuccess`/`onFileError` instead, which are simply left untouched
|
|
22
|
+
* because this function only overrides `onSuccess` and `onError`.
|
|
23
|
+
*/
|
|
24
|
+
function mapUploadProps(props, field) {
|
|
25
|
+
const { onSuccess, onError } = props;
|
|
26
|
+
return {
|
|
27
|
+
...props,
|
|
28
|
+
value: field.value ?? null,
|
|
29
|
+
onChange: void 0,
|
|
30
|
+
onSuccess: (fileMeta) => {
|
|
31
|
+
field.setValue(fileMeta);
|
|
32
|
+
onSuccess?.(fileMeta);
|
|
33
|
+
},
|
|
34
|
+
onError: (file, error) => {
|
|
35
|
+
field.setFeedback({
|
|
36
|
+
type: "error",
|
|
37
|
+
messages: [error]
|
|
38
|
+
});
|
|
39
|
+
onError?.(file, error);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { mapUploadProps };
|
|
@@ -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 };
|