@pixpilot/formily-shadcn 1.9.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.
@@ -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_runtime1 from "react/jsx-runtime";
4
+ import * as react_jsx_runtime0 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_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,5 +1,5 @@
1
1
  import { FC } from "react";
2
- import * as react_jsx_runtime3 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime2 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_runtime3.JSX.Element;
18
+ declare function Radio(props: RadioProps): react_jsx_runtime2.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_runtime2 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime3 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_runtime2.JSX.Element;
39
+ }: IRowProps): react_jsx_runtime3.JSX.Element;
40
40
  //#endregion
41
41
  export { Row };
@@ -1,4 +1,4 @@
1
- import * as react19 from "react";
1
+ import * as react16 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: react19.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_separator0.SeparatorProps & react19.RefAttributes<HTMLDivElement>>, "ref"> & react19.RefAttributes<unknown>>;
9
+ declare const Separator: react16.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_separator0.SeparatorProps & react16.RefAttributes<HTMLDivElement>>, "ref"> & react16.RefAttributes<unknown>>;
10
10
  //#endregion
11
11
  export { Separator };
@@ -1,4 +1,4 @@
1
- import * as react16 from "react";
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: react16.ForwardRefExoticComponent<Omit<Partial<_radix_ui_react_switch0.SwitchProps & react16.RefAttributes<HTMLButtonElement>>, "ref"> & react16.RefAttributes<unknown>>;
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,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,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 };
@@ -7,41 +7,55 @@
7
7
  * component displays the currently stored file metadata.
8
8
  * - Applies `mapValue` to the field value before forwarding it so callers can
9
9
  * derive a display-ready file object without mutating the stored form value.
10
- * - Sets `onChange` to `undefined` to prevent Formily's default wiring from
11
- * calling `field.setValue()` the moment a file is selected (i.e. before the
12
- * upload completes).
13
- * - Wraps `onSuccess` so that `field.setValue(fileMeta)` is called only after a
14
- * successful upload, followed by the original `onSuccess` callback if one was
15
- * supplied.
16
- * - Wraps `onError` so that `field.setFeedback({ type: 'error', … })` is set on
17
- * upload failure, followed by the original `onError` callback if one was
18
- * supplied.
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.
19
24
  *
20
25
  * The generic `P extends object` constraint keeps the return type identical to
21
26
  * the input type so that the mapper satisfies Formily's `IStateMapper<T>`.
22
27
  * Internally the props are cast to `UploadFieldCallbacks` to access the
23
- * upload-specific callbacks; the multiple-file variant of `FileUploadProps`
24
- * uses `onFileSuccess`/`onFileError` instead, which are simply left untouched
25
- * 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.
26
30
  */
27
- function mapUploadProps(props, field) {
28
- const { onSuccess, onError, mapValue,...restProps } = props;
31
+ function mapUploadProps(props, field, options) {
32
+ const { onFileSuccess, onFileError, mapValue,...restProps } = props;
33
+ const isSingle = options?.forceSingle === true || props.multiple === false;
29
34
  const baseValue = field.value ?? null;
30
35
  const value = mapValue ? mapValue(baseValue) : baseValue;
31
36
  return {
32
37
  ...restProps,
33
38
  value,
34
- onChange: void 0,
35
- onSuccess: (fileMeta) => {
36
- field.setValue(fileMeta);
37
- onSuccess?.(fileMeta);
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
+ }
38
45
  },
39
- onError: (file, error) => {
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) => {
40
54
  field.setFeedback({
41
55
  type: "error",
42
56
  messages: [error]
43
57
  });
44
- onError?.(file, error);
58
+ onFileError?.(file, error);
45
59
  }
46
60
  };
47
61
  }
@@ -6,41 +6,55 @@
6
6
  * component displays the currently stored file metadata.
7
7
  * - Applies `mapValue` to the field value before forwarding it so callers can
8
8
  * derive a display-ready file object without mutating the stored form value.
9
- * - Sets `onChange` to `undefined` to prevent Formily's default wiring from
10
- * calling `field.setValue()` the moment a file is selected (i.e. before the
11
- * upload completes).
12
- * - Wraps `onSuccess` so that `field.setValue(fileMeta)` is called only after a
13
- * successful upload, followed by the original `onSuccess` callback if one was
14
- * supplied.
15
- * - Wraps `onError` so that `field.setFeedback({ type: 'error', … })` is set on
16
- * upload failure, followed by the original `onError` callback if one was
17
- * supplied.
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.
18
23
  *
19
24
  * The generic `P extends object` constraint keeps the return type identical to
20
25
  * the input type so that the mapper satisfies Formily's `IStateMapper<T>`.
21
26
  * Internally the props are cast to `UploadFieldCallbacks` to access the
22
- * upload-specific callbacks; the multiple-file variant of `FileUploadProps`
23
- * uses `onFileSuccess`/`onFileError` instead, which are simply left untouched
24
- * 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.
25
29
  */
26
- function mapUploadProps(props, field) {
27
- const { onSuccess, onError, mapValue,...restProps } = props;
30
+ function mapUploadProps(props, field, options) {
31
+ const { onFileSuccess, onFileError, mapValue,...restProps } = props;
32
+ const isSingle = options?.forceSingle === true || props.multiple === false;
28
33
  const baseValue = field.value ?? null;
29
34
  const value = mapValue ? mapValue(baseValue) : baseValue;
30
35
  return {
31
36
  ...restProps,
32
37
  value,
33
- onChange: void 0,
34
- onSuccess: (fileMeta) => {
35
- field.setValue(fileMeta);
36
- onSuccess?.(fileMeta);
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
+ }
37
44
  },
38
- onError: (file, error) => {
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) => {
39
53
  field.setFeedback({
40
54
  type: "error",
41
55
  messages: [error]
42
56
  });
43
- onError?.(file, error);
57
+ onFileError?.(file, error);
44
58
  }
45
59
  };
46
60
  }