@pixpilot/formily-shadcn 1.8.0 → 1.9.1
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/IconPicker.d.cts +3 -3
- package/dist/components/IconToggle.d.cts +2 -2
- package/dist/components/file-upload/AvatarUpload.cjs +3 -2
- package/dist/components/file-upload/AvatarUpload.d.cts +4 -3
- package/dist/components/file-upload/AvatarUpload.d.ts +4 -3
- package/dist/components/file-upload/AvatarUpload.js +3 -2
- package/dist/components/file-upload/FileUpload.cjs +3 -2
- package/dist/components/file-upload/FileUpload.d.cts +5 -12
- package/dist/components/file-upload/FileUpload.d.ts +5 -12
- package/dist/components/file-upload/FileUpload.js +3 -2
- package/dist/components/file-upload/FileUploadInline.cjs +3 -2
- package/dist/components/file-upload/FileUploadInline.d.cts +5 -12
- package/dist/components/file-upload/FileUploadInline.d.ts +5 -12
- package/dist/components/file-upload/FileUploadInline.js +3 -2
- package/dist/components/file-upload/index.d.cts +3 -3
- package/dist/components/file-upload/index.d.ts +3 -3
- package/dist/components/file-upload/map-upload-props.cjs +40 -22
- package/dist/components/file-upload/map-upload-props.d.cts +16 -0
- package/dist/components/file-upload/map-upload-props.d.ts +16 -0
- package/dist/components/file-upload/map-upload-props.js +40 -22
- package/dist/components/form-item/ConnectedFormItem.d.cts +4 -4
- package/dist/components/form-item/ConnectedFormItem.d.ts +4 -4
- package/dist/components/schema-field/schema-field-basics.d.cts +303 -303
- package/dist/components/schema-field/schema-field-basics.d.ts +303 -303
- package/dist/components/schema-field/schema-field-extended.d.cts +179 -351
- package/dist/components/schema-field/schema-field-extended.d.ts +505 -677
- package/dist/components/schema-field/schema-field.d.cts +413 -413
- package/dist/components/schema-field/schema-field.d.ts +412 -412
- 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/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/package.json +3 -3
|
@@ -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:
|
|
11
|
+
declare const IconPicker: react4.ForwardRefExoticComponent<Partial<Omit<IconPickerProps, "providers"> & {
|
|
12
12
|
providers?: IconProviderProps[];
|
|
13
|
-
}> &
|
|
13
|
+
}> & react4.RefAttributes<unknown>>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { IconPicker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react6 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:
|
|
9
|
+
declare const IconToggle: react6.ForwardRefExoticComponent<Omit<Partial<Omit<_pixpilot_shadcn_ui0.IconToggleProps, "ref"> & react6.RefAttributes<HTMLButtonElement>>, "ref"> & react6.RefAttributes<unknown>>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { IconToggle };
|
|
@@ -12,9 +12,10 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
|
12
12
|
|
|
13
13
|
//#region src/components/file-upload/AvatarUpload.tsx
|
|
14
14
|
const BaseAvatarUpload = (props) => {
|
|
15
|
-
const {
|
|
15
|
+
const { mapValue: _mapValue,...uploadProps } = props;
|
|
16
|
+
const { onUpload, maxSize, handleFilesRejection, handleFileValidate } = require_use_file_upload_feedback.useFileUploadFeedback(uploadProps);
|
|
16
17
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.AvatarUpload, {
|
|
17
|
-
...
|
|
18
|
+
...uploadProps,
|
|
18
19
|
maxSize,
|
|
19
20
|
onFilesReject: handleFilesRejection,
|
|
20
21
|
onFileValidate: handleFileValidate,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { FormilyUploadProps } from "./map-upload-props.cjs";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { AvatarUploadProps } from "@pixpilot/shadcn-ui";
|
|
3
4
|
|
|
4
5
|
//#region src/components/file-upload/AvatarUpload.d.ts
|
|
5
|
-
|
|
6
|
+
type AvatarUploadProps$1 = FormilyUploadProps<AvatarUploadProps>;
|
|
6
7
|
/**
|
|
7
8
|
* Formily-connected AvatarUpload component
|
|
8
9
|
* Automatically connects shadcn AvatarUpload to Formily field state
|
|
9
10
|
*/
|
|
10
|
-
declare const AvatarUpload: React.
|
|
11
|
+
declare const AvatarUpload: React.FC<AvatarUploadProps$1>;
|
|
11
12
|
//#endregion
|
|
12
|
-
export { AvatarUpload };
|
|
13
|
+
export { AvatarUpload, AvatarUploadProps$1 as AvatarUploadProps };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { FormilyUploadProps } from "./map-upload-props.js";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { AvatarUploadProps } from "@pixpilot/shadcn-ui";
|
|
3
4
|
|
|
4
5
|
//#region src/components/file-upload/AvatarUpload.d.ts
|
|
5
|
-
|
|
6
|
+
type AvatarUploadProps$1 = FormilyUploadProps<AvatarUploadProps>;
|
|
6
7
|
/**
|
|
7
8
|
* Formily-connected AvatarUpload component
|
|
8
9
|
* Automatically connects shadcn AvatarUpload to Formily field state
|
|
9
10
|
*/
|
|
10
|
-
declare const AvatarUpload$1: React.
|
|
11
|
+
declare const AvatarUpload$1: React.FC<AvatarUploadProps$1>;
|
|
11
12
|
//#endregion
|
|
12
|
-
export { AvatarUpload$1 as AvatarUpload };
|
|
13
|
+
export { AvatarUpload$1 as AvatarUpload, AvatarUploadProps$1 as AvatarUploadProps };
|
|
@@ -7,9 +7,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
|
|
8
8
|
//#region src/components/file-upload/AvatarUpload.tsx
|
|
9
9
|
const BaseAvatarUpload = (props) => {
|
|
10
|
-
const {
|
|
10
|
+
const { mapValue: _mapValue,...uploadProps } = props;
|
|
11
|
+
const { onUpload, maxSize, handleFilesRejection, handleFileValidate } = useFileUploadFeedback(uploadProps);
|
|
11
12
|
return /* @__PURE__ */ jsx(AvatarUpload, {
|
|
12
|
-
...
|
|
13
|
+
...uploadProps,
|
|
13
14
|
maxSize,
|
|
14
15
|
onFilesReject: handleFilesRejection,
|
|
15
16
|
onFileValidate: handleFileValidate,
|
|
@@ -12,9 +12,10 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
|
12
12
|
|
|
13
13
|
//#region src/components/file-upload/FileUpload.tsx
|
|
14
14
|
const BaseFileUpload = (props) => {
|
|
15
|
-
const {
|
|
15
|
+
const { mapValue: _mapValue,...uploadProps } = props;
|
|
16
|
+
const { onUpload, maxSize, handleFilesRejection, handleFileValidate } = require_use_file_upload_feedback.useFileUploadFeedback(uploadProps);
|
|
16
17
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.FileUpload, {
|
|
17
|
-
...
|
|
18
|
+
...uploadProps,
|
|
18
19
|
maxSize,
|
|
19
20
|
onFilesReject: handleFilesRejection,
|
|
20
21
|
onFileValidate: handleFileValidate,
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
+
import { FormilyUploadProps } from "./map-upload-props.cjs";
|
|
1
2
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
+
import { FileUploadProps } from "@pixpilot/shadcn-ui";
|
|
3
4
|
|
|
4
5
|
//#region src/components/file-upload/FileUpload.d.ts
|
|
5
|
-
|
|
6
|
+
type FileUploadProps$1 = FormilyUploadProps<FileUploadProps>;
|
|
6
7
|
/**
|
|
7
8
|
* Formily-connected FileUpload component
|
|
8
9
|
* Automatically connects shadcn FileUpload to Formily field state
|
|
9
10
|
*/
|
|
10
|
-
declare const FileUpload: React.
|
|
11
|
-
multiple: true;
|
|
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
|
-
multiple?: false;
|
|
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>>;
|
|
11
|
+
declare const FileUpload: React.FC<FileUploadProps$1>;
|
|
19
12
|
//#endregion
|
|
20
|
-
export { FileUpload };
|
|
13
|
+
export { FileUpload, FileUploadProps$1 as FileUploadProps };
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
+
import { FormilyUploadProps } from "./map-upload-props.js";
|
|
1
2
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
+
import { FileUploadProps } from "@pixpilot/shadcn-ui";
|
|
3
4
|
|
|
4
5
|
//#region src/components/file-upload/FileUpload.d.ts
|
|
5
|
-
|
|
6
|
+
type FileUploadProps$1 = FormilyUploadProps<FileUploadProps>;
|
|
6
7
|
/**
|
|
7
8
|
* Formily-connected FileUpload component
|
|
8
9
|
* Automatically connects shadcn FileUpload to Formily field state
|
|
9
10
|
*/
|
|
10
|
-
declare const FileUpload$1: React.
|
|
11
|
-
multiple: true;
|
|
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
|
-
multiple?: false;
|
|
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>>;
|
|
11
|
+
declare const FileUpload$1: React.FC<FileUploadProps$1>;
|
|
19
12
|
//#endregion
|
|
20
|
-
export { FileUpload$1 as FileUpload };
|
|
13
|
+
export { FileUpload$1 as FileUpload, FileUploadProps$1 as FileUploadProps };
|
|
@@ -7,9 +7,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
|
|
8
8
|
//#region src/components/file-upload/FileUpload.tsx
|
|
9
9
|
const BaseFileUpload = (props) => {
|
|
10
|
-
const {
|
|
10
|
+
const { mapValue: _mapValue,...uploadProps } = props;
|
|
11
|
+
const { onUpload, maxSize, handleFilesRejection, handleFileValidate } = useFileUploadFeedback(uploadProps);
|
|
11
12
|
return /* @__PURE__ */ jsx(FileUpload, {
|
|
12
|
-
...
|
|
13
|
+
...uploadProps,
|
|
13
14
|
maxSize,
|
|
14
15
|
onFilesReject: handleFilesRejection,
|
|
15
16
|
onFileValidate: handleFileValidate,
|
|
@@ -12,9 +12,10 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
|
12
12
|
|
|
13
13
|
//#region src/components/file-upload/FileUploadInline.tsx
|
|
14
14
|
const BaseFileUploadInline = (props) => {
|
|
15
|
-
const {
|
|
15
|
+
const { mapValue: _mapValue,...uploadProps } = props;
|
|
16
|
+
const { onUpload, maxSize, handleFilesRejection, handleFileValidate } = require_use_file_upload_feedback.useFileUploadFeedback(uploadProps);
|
|
16
17
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.FileUploadInline, {
|
|
17
|
-
...
|
|
18
|
+
...uploadProps,
|
|
18
19
|
maxSize,
|
|
19
20
|
onFilesReject: handleFilesRejection,
|
|
20
21
|
onFileValidate: handleFileValidate,
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
+
import { FormilyUploadProps } from "./map-upload-props.cjs";
|
|
1
2
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
+
import { FileUploadInlineProps } from "@pixpilot/shadcn-ui";
|
|
3
4
|
|
|
4
5
|
//#region src/components/file-upload/FileUploadInline.d.ts
|
|
5
|
-
|
|
6
|
+
type FileUploadInlineProps$1 = FormilyUploadProps<FileUploadInlineProps>;
|
|
6
7
|
/**
|
|
7
8
|
* Formily-connected FileUploadInline component
|
|
8
9
|
* Automatically connects shadcn FileUploadInline to Formily field state
|
|
9
10
|
*/
|
|
10
|
-
declare const FileUploadInline: React.
|
|
11
|
-
multiple: true;
|
|
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
|
-
multiple?: false;
|
|
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>>;
|
|
11
|
+
declare const FileUploadInline: React.FC<FileUploadInlineProps$1>;
|
|
19
12
|
//#endregion
|
|
20
|
-
export { FileUploadInline };
|
|
13
|
+
export { FileUploadInline, FileUploadInlineProps$1 as FileUploadInlineProps };
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
+
import { FormilyUploadProps } from "./map-upload-props.js";
|
|
1
2
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
+
import { FileUploadInlineProps } from "@pixpilot/shadcn-ui";
|
|
3
4
|
|
|
4
5
|
//#region src/components/file-upload/FileUploadInline.d.ts
|
|
5
|
-
|
|
6
|
+
type FileUploadInlineProps$1 = FormilyUploadProps<FileUploadInlineProps>;
|
|
6
7
|
/**
|
|
7
8
|
* Formily-connected FileUploadInline component
|
|
8
9
|
* Automatically connects shadcn FileUploadInline to Formily field state
|
|
9
10
|
*/
|
|
10
|
-
declare const FileUploadInline$1: React.
|
|
11
|
-
multiple: true;
|
|
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
|
-
multiple?: false;
|
|
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>>;
|
|
11
|
+
declare const FileUploadInline$1: React.FC<FileUploadInlineProps$1>;
|
|
19
12
|
//#endregion
|
|
20
|
-
export { FileUploadInline$1 as FileUploadInline };
|
|
13
|
+
export { FileUploadInline$1 as FileUploadInline, FileUploadInlineProps$1 as FileUploadInlineProps };
|
|
@@ -7,9 +7,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
|
|
8
8
|
//#region src/components/file-upload/FileUploadInline.tsx
|
|
9
9
|
const BaseFileUploadInline = (props) => {
|
|
10
|
-
const {
|
|
10
|
+
const { mapValue: _mapValue,...uploadProps } = props;
|
|
11
|
+
const { onUpload, maxSize, handleFilesRejection, handleFileValidate } = useFileUploadFeedback(uploadProps);
|
|
11
12
|
return /* @__PURE__ */ jsx(FileUploadInline, {
|
|
12
|
-
...
|
|
13
|
+
...uploadProps,
|
|
13
14
|
maxSize,
|
|
14
15
|
onFilesReject: handleFilesRejection,
|
|
15
16
|
onFileValidate: handleFileValidate,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AvatarUpload } from "./AvatarUpload.cjs";
|
|
2
|
-
import { FileUpload } from "./FileUpload.cjs";
|
|
3
|
-
import { FileUploadInline } from "./FileUploadInline.cjs";
|
|
1
|
+
import { AvatarUpload, AvatarUploadProps as AvatarUploadProps$1 } from "./AvatarUpload.cjs";
|
|
2
|
+
import { FileUpload, FileUploadProps as FileUploadProps$1 } from "./FileUpload.cjs";
|
|
3
|
+
import { FileUploadInline, FileUploadInlineProps as FileUploadInlineProps$1 } from "./FileUploadInline.cjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AvatarUpload as AvatarUpload$1 } from "./AvatarUpload.js";
|
|
2
|
-
import { FileUpload as FileUpload$1 } from "./FileUpload.js";
|
|
3
|
-
import { FileUploadInline as FileUploadInline$1 } from "./FileUploadInline.js";
|
|
1
|
+
import { AvatarUpload as AvatarUpload$1, AvatarUploadProps as AvatarUploadProps$1 } from "./AvatarUpload.js";
|
|
2
|
+
import { FileUpload as FileUpload$1, FileUploadProps as FileUploadProps$1 } from "./FileUpload.js";
|
|
3
|
+
import { FileUploadInline as FileUploadInline$1, FileUploadInlineProps as FileUploadInlineProps$1 } from "./FileUploadInline.js";
|
|
4
4
|
import "@pixpilot/shadcn-ui";
|
|
@@ -5,39 +5,57 @@
|
|
|
5
5
|
*
|
|
6
6
|
* - Forwards `field.value` (defaulting to `null`) as the `value` prop so the
|
|
7
7
|
* component displays the currently stored file metadata.
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
8
|
+
* - Applies `mapValue` to the field value before forwarding it so callers can
|
|
9
|
+
* derive a display-ready file object without mutating the stored form value.
|
|
10
|
+
* - Provides a guarded `onChange` that only writes to the field on deletions
|
|
11
|
+
* (value becomes `null` for single-file, or the array shrinks for
|
|
12
|
+
* multi-file). New-file accepts fire `onChange` before the upload
|
|
13
|
+
* completes with incomplete metadata (no `url`), so those calls are
|
|
14
|
+
* intentionally ignored here — `onFileSuccess` handles the final write
|
|
15
|
+
* once the upload finishes.
|
|
16
|
+
* - Wraps `onFileSuccess` so that `field.setValue(fileMeta)` is called only
|
|
17
|
+
* after a successful upload, followed by the original `onFileSuccess`
|
|
18
|
+
* callback if one was supplied. When the field value is an array (multiple
|
|
19
|
+
* mode), the new file is appended to the existing array rather than
|
|
20
|
+
* replacing it.
|
|
21
|
+
* - Wraps `onFileError` so that `field.setFeedback({ type: 'error', … })` is
|
|
22
|
+
* set on upload failure, followed by the original `onFileError` callback if
|
|
23
|
+
* one was supplied.
|
|
17
24
|
*
|
|
18
25
|
* The generic `P extends object` constraint keeps the return type identical to
|
|
19
26
|
* the input type so that the mapper satisfies Formily's `IStateMapper<T>`.
|
|
20
27
|
* Internally the props are cast to `UploadFieldCallbacks` to access the
|
|
21
|
-
* upload-specific callbacks;
|
|
22
|
-
*
|
|
23
|
-
* because this function only overrides `onSuccess` and `onError`.
|
|
28
|
+
* upload-specific callbacks; both single-file and multiple-file modes share
|
|
29
|
+
* the same `onFileSuccess`/`onFileError` callbacks that fire per file.
|
|
24
30
|
*/
|
|
25
|
-
function mapUploadProps(props, field) {
|
|
26
|
-
const {
|
|
31
|
+
function mapUploadProps(props, field, options) {
|
|
32
|
+
const { onFileSuccess, onFileError, mapValue,...restProps } = props;
|
|
33
|
+
const isSingle = options?.forceSingle === true || props.multiple === false;
|
|
34
|
+
const baseValue = field.value ?? null;
|
|
35
|
+
const value = mapValue ? mapValue(baseValue) : baseValue;
|
|
27
36
|
return {
|
|
28
|
-
...
|
|
29
|
-
value
|
|
30
|
-
onChange:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
...restProps,
|
|
38
|
+
value,
|
|
39
|
+
onChange: (newValue) => {
|
|
40
|
+
if (newValue === null) field.setValue(null);
|
|
41
|
+
else if (Array.isArray(newValue)) {
|
|
42
|
+
const currentLen = (field.value ?? []).length;
|
|
43
|
+
if (newValue.length <= currentLen) field.setValue(newValue);
|
|
44
|
+
}
|
|
34
45
|
},
|
|
35
|
-
|
|
46
|
+
onFileSuccess: (fileMeta) => {
|
|
47
|
+
if (!isSingle) {
|
|
48
|
+
const current = field.value ?? [];
|
|
49
|
+
field.setValue([...current, fileMeta]);
|
|
50
|
+
} else field.setValue(fileMeta);
|
|
51
|
+
onFileSuccess?.(fileMeta);
|
|
52
|
+
},
|
|
53
|
+
onFileError: (file, error) => {
|
|
36
54
|
field.setFeedback({
|
|
37
55
|
type: "error",
|
|
38
56
|
messages: [error]
|
|
39
57
|
});
|
|
40
|
-
|
|
58
|
+
onFileError?.(file, error);
|
|
41
59
|
}
|
|
42
60
|
};
|
|
43
61
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "@formily/core";
|
|
2
|
+
import { FileMetadata } from "@pixpilot/shadcn-ui";
|
|
3
|
+
|
|
4
|
+
//#region src/components/file-upload/map-upload-props.d.ts
|
|
5
|
+
type SingleFileUploadValue = FileMetadata | null;
|
|
6
|
+
type ExtractSingleFileValue<P> = P extends {
|
|
7
|
+
value?: infer TValue;
|
|
8
|
+
} ? Extract<TValue, SingleFileUploadValue> extends never ? SingleFileUploadValue : Extract<TValue, SingleFileUploadValue> : SingleFileUploadValue;
|
|
9
|
+
interface UploadValueMapper<TValue$1 extends SingleFileUploadValue = SingleFileUploadValue> {
|
|
10
|
+
mapValue?: (value: TValue$1) => TValue$1;
|
|
11
|
+
}
|
|
12
|
+
type FormilyUploadProps<P> = P extends {
|
|
13
|
+
multiple: true;
|
|
14
|
+
} ? P : P & UploadValueMapper<ExtractSingleFileValue<P>>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { FormilyUploadProps, UploadValueMapper };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FileMetadata } from "@pixpilot/shadcn-ui";
|
|
2
|
+
import "@formily/core";
|
|
3
|
+
|
|
4
|
+
//#region src/components/file-upload/map-upload-props.d.ts
|
|
5
|
+
type SingleFileUploadValue = FileMetadata | null;
|
|
6
|
+
type ExtractSingleFileValue<P> = P extends {
|
|
7
|
+
value?: infer TValue;
|
|
8
|
+
} ? Extract<TValue, SingleFileUploadValue> extends never ? SingleFileUploadValue : Extract<TValue, SingleFileUploadValue> : SingleFileUploadValue;
|
|
9
|
+
interface UploadValueMapper<TValue$1 extends SingleFileUploadValue = SingleFileUploadValue> {
|
|
10
|
+
mapValue?: (value: TValue$1) => TValue$1;
|
|
11
|
+
}
|
|
12
|
+
type FormilyUploadProps<P> = P extends {
|
|
13
|
+
multiple: true;
|
|
14
|
+
} ? P : P & UploadValueMapper<ExtractSingleFileValue<P>>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { FormilyUploadProps, UploadValueMapper };
|
|
@@ -4,39 +4,57 @@
|
|
|
4
4
|
*
|
|
5
5
|
* - Forwards `field.value` (defaulting to `null`) as the `value` prop so the
|
|
6
6
|
* component displays the currently stored file metadata.
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
7
|
+
* - Applies `mapValue` to the field value before forwarding it so callers can
|
|
8
|
+
* derive a display-ready file object without mutating the stored form value.
|
|
9
|
+
* - Provides a guarded `onChange` that only writes to the field on deletions
|
|
10
|
+
* (value becomes `null` for single-file, or the array shrinks for
|
|
11
|
+
* multi-file). New-file accepts fire `onChange` before the upload
|
|
12
|
+
* completes with incomplete metadata (no `url`), so those calls are
|
|
13
|
+
* intentionally ignored here — `onFileSuccess` handles the final write
|
|
14
|
+
* once the upload finishes.
|
|
15
|
+
* - Wraps `onFileSuccess` so that `field.setValue(fileMeta)` is called only
|
|
16
|
+
* after a successful upload, followed by the original `onFileSuccess`
|
|
17
|
+
* callback if one was supplied. When the field value is an array (multiple
|
|
18
|
+
* mode), the new file is appended to the existing array rather than
|
|
19
|
+
* replacing it.
|
|
20
|
+
* - Wraps `onFileError` so that `field.setFeedback({ type: 'error', … })` is
|
|
21
|
+
* set on upload failure, followed by the original `onFileError` callback if
|
|
22
|
+
* one was supplied.
|
|
16
23
|
*
|
|
17
24
|
* The generic `P extends object` constraint keeps the return type identical to
|
|
18
25
|
* the input type so that the mapper satisfies Formily's `IStateMapper<T>`.
|
|
19
26
|
* Internally the props are cast to `UploadFieldCallbacks` to access the
|
|
20
|
-
* upload-specific callbacks;
|
|
21
|
-
*
|
|
22
|
-
* because this function only overrides `onSuccess` and `onError`.
|
|
27
|
+
* upload-specific callbacks; both single-file and multiple-file modes share
|
|
28
|
+
* the same `onFileSuccess`/`onFileError` callbacks that fire per file.
|
|
23
29
|
*/
|
|
24
|
-
function mapUploadProps(props, field) {
|
|
25
|
-
const {
|
|
30
|
+
function mapUploadProps(props, field, options) {
|
|
31
|
+
const { onFileSuccess, onFileError, mapValue,...restProps } = props;
|
|
32
|
+
const isSingle = options?.forceSingle === true || props.multiple === false;
|
|
33
|
+
const baseValue = field.value ?? null;
|
|
34
|
+
const value = mapValue ? mapValue(baseValue) : baseValue;
|
|
26
35
|
return {
|
|
27
|
-
...
|
|
28
|
-
value
|
|
29
|
-
onChange:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
...restProps,
|
|
37
|
+
value,
|
|
38
|
+
onChange: (newValue) => {
|
|
39
|
+
if (newValue === null) field.setValue(null);
|
|
40
|
+
else if (Array.isArray(newValue)) {
|
|
41
|
+
const currentLen = (field.value ?? []).length;
|
|
42
|
+
if (newValue.length <= currentLen) field.setValue(newValue);
|
|
43
|
+
}
|
|
33
44
|
},
|
|
34
|
-
|
|
45
|
+
onFileSuccess: (fileMeta) => {
|
|
46
|
+
if (!isSingle) {
|
|
47
|
+
const current = field.value ?? [];
|
|
48
|
+
field.setValue([...current, fileMeta]);
|
|
49
|
+
} else field.setValue(fileMeta);
|
|
50
|
+
onFileSuccess?.(fileMeta);
|
|
51
|
+
},
|
|
52
|
+
onFileError: (file, error) => {
|
|
35
53
|
field.setFeedback({
|
|
36
54
|
type: "error",
|
|
37
55
|
messages: [error]
|
|
38
56
|
});
|
|
39
|
-
|
|
57
|
+
onFileError?.(file, error);
|
|
40
58
|
}
|
|
41
59
|
};
|
|
42
60
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FormItemProps } from "./form-item-types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react1891 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:
|
|
10
|
-
children?:
|
|
11
|
-
}>, "ref"> &
|
|
9
|
+
declare const FormItem: react1891.ForwardRefExoticComponent<Omit<Partial<FormItemProps & {
|
|
10
|
+
children?: react1891.ReactNode | undefined;
|
|
11
|
+
}>, "ref"> & react1891.RefAttributes<unknown>>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { FormItem };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FormItemProps } from "./form-item-types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react1891 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:
|
|
10
|
-
children?:
|
|
11
|
-
}>, "ref"> &
|
|
9
|
+
declare const FormItem: react1891.ForwardRefExoticComponent<Omit<Partial<FormItemProps & {
|
|
10
|
+
children?: react1891.ReactNode | undefined;
|
|
11
|
+
}>, "ref"> & react1891.RefAttributes<unknown>>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { FormItem };
|