@yamada-ui/file-button 1.1.7-next-20241005235555 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,10 +3,10 @@
3
3
  // src/file-button.tsx
4
4
  import { Button } from "@yamada-ui/button";
5
5
  import {
6
- ui,
7
6
  forwardRef,
8
- useComponentStyle,
9
- omitThemeProps
7
+ omitThemeProps,
8
+ ui,
9
+ useComponentStyle
10
10
  } from "@yamada-ui/core";
11
11
  import {
12
12
  formControlProperties,
@@ -27,29 +27,29 @@ var FileButton = forwardRef((props, ref) => {
27
27
  const [styles, mergedProps] = useComponentStyle("FileButton", props);
28
28
  const computedProps = omitThemeProps(mergedProps);
29
29
  let {
30
- className,
31
- resetRef,
32
- as: As,
33
- children,
34
30
  id,
31
+ as: As,
32
+ form,
35
33
  name,
34
+ className,
36
35
  accept,
36
+ children,
37
37
  multiple,
38
- form,
39
- onClick: onClickProp,
38
+ resetRef,
40
39
  onChange: onChangeProp,
40
+ onClick: onClickProp,
41
41
  ...rest
42
42
  } = useFormControlProps(computedProps);
43
43
  const {
44
- onFocus: _onFocus,
45
44
  onBlur: _onBlur,
45
+ onFocus: _onFocus,
46
46
  ...formControlProps
47
47
  } = pickObject(rest, formControlProperties);
48
48
  const {
49
+ "aria-invalid": isInvalid,
49
50
  disabled,
50
51
  readOnly,
51
- required,
52
- "aria-invalid": isInvalid
52
+ required
53
53
  } = formControlProps;
54
54
  const inputRef = useRef(null);
55
55
  const onClick = useCallback(() => {
@@ -86,44 +86,46 @@ var FileButton = forwardRef((props, ref) => {
86
86
  /* @__PURE__ */ jsx(
87
87
  ui.input,
88
88
  {
89
+ id,
89
90
  ref: mergeRefs(inputRef, ref),
91
+ form,
90
92
  type: "file",
91
- "aria-hidden": true,
92
- tabIndex: -1,
93
- id,
94
93
  name,
95
- form,
96
- accept,
97
- multiple,
98
94
  style: {
99
95
  border: "0px",
100
96
  clip: "rect(0px, 0px, 0px, 0px)",
101
97
  height: "1px",
102
- width: "1px",
103
98
  margin: "-1px",
104
- padding: "0px",
105
99
  overflow: "hidden",
100
+ padding: "0px",
101
+ position: "absolute",
106
102
  whiteSpace: "nowrap",
107
- position: "absolute"
103
+ width: "1px"
108
104
  },
105
+ "aria-hidden": true,
106
+ accept,
107
+ multiple,
108
+ tabIndex: -1,
109
109
  onChange,
110
110
  ...formControlProps
111
111
  }
112
112
  ),
113
113
  isFunction(children) ? children({
114
- onClick,
115
114
  disabled,
116
- readOnly,
117
- required,
118
115
  isDisabled: disabled,
116
+ isInvalid,
119
117
  isReadOnly: readOnly,
120
118
  isRequired: required,
121
- isInvalid
119
+ readOnly,
120
+ required,
121
+ onClick
122
122
  }) : children
123
123
  ] });
124
124
  });
125
+ FileButton.displayName = "FileButton";
126
+ FileButton.__ui__ = "FileButton";
125
127
 
126
128
  export {
127
129
  FileButton
128
130
  };
129
- //# sourceMappingURL=chunk-ZC23JUXH.mjs.map
131
+ //# sourceMappingURL=chunk-5WHD36CE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/file-button.tsx"],"sourcesContent":["import type { ButtonProps } from \"@yamada-ui/button\"\nimport type { ColorModeToken, CSS, ThemeProps } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { ChangeEvent, ForwardedRef, ReactNode } from \"react\"\nimport { Button } from \"@yamada-ui/button\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport {\n assignRef,\n cx,\n handlerAll,\n isFunction,\n isNull,\n mergeRefs,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useRef } from \"react\"\n\ninterface Props extends FormControlOptions {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n}\n\ninterface FileButtonOptions {\n children?: ((props: Props) => ReactNode) | ReactNode\n /**\n * The border color when the button is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * Ref to a reset function.\n */\n resetRef?: ForwardedRef<() => void>\n /**\n * Function to be called when a file change event occurs.\n */\n onChange?: (files: File[] | undefined) => void\n}\n\ninterface InputProps\n extends Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">> {}\n\nexport interface FileButtonProps\n extends Omit<ButtonProps, \"children\" | \"onChange\">,\n ThemeProps<\"FileButton\">,\n InputProps,\n FileButtonOptions,\n FormControlOptions {}\n\n/**\n * `FileButton` is a button component used for users to select files.\n *\n * @see Docs https://yamada-ui.com/components/forms/file-button\n */\nexport const FileButton = forwardRef<FileButtonProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentStyle(\"FileButton\", props)\n const computedProps = omitThemeProps(mergedProps)\n let {\n id,\n as: As,\n form,\n name,\n className,\n accept,\n children,\n multiple,\n resetRef,\n onChange: onChangeProp,\n onClick: onClickProp,\n ...rest\n } = useFormControlProps(computedProps)\n const {\n onBlur: _onBlur,\n onFocus: _onFocus,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const {\n \"aria-invalid\": isInvalid,\n disabled,\n readOnly,\n required,\n } = formControlProps\n const inputRef = useRef<HTMLInputElement>(null)\n\n const onClick = useCallback(() => {\n if (disabled || readOnly) return\n\n inputRef.current?.click()\n }, [disabled, readOnly])\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n const files = !isNull(ev.currentTarget.files)\n ? Array.from(ev.currentTarget.files)\n : undefined\n\n onChangeProp?.(files)\n },\n [onChangeProp],\n )\n\n const onReset = useCallback(() => {\n if (inputRef.current) inputRef.current.value = \"\"\n }, [])\n\n if (!isFunction(children)) {\n const Component = As || Button\n\n children = (\n <Component\n className={cx(\"ui-file-button\", className)}\n __isProcessSkip={!As}\n __styles={styles}\n {...rest}\n onClick={handlerAll(onClickProp, onClick)}\n >\n {children}\n </Component>\n )\n }\n\n assignRef(resetRef, onReset)\n\n return (\n <>\n <ui.input\n id={id}\n ref={mergeRefs(inputRef, ref)}\n form={form}\n type=\"file\"\n name={name}\n style={{\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }}\n aria-hidden\n accept={accept}\n multiple={multiple}\n tabIndex={-1}\n onChange={onChange}\n {...formControlProps}\n />\n\n {isFunction(children)\n ? children({\n disabled,\n isDisabled: disabled,\n isInvalid,\n isReadOnly: readOnly,\n isRequired: required,\n readOnly,\n required,\n onClick,\n })\n : children}\n </>\n )\n})\n\nFileButton.displayName = \"FileButton\"\nFileButton.__ui__ = \"FileButton\"\n"],"mappings":";;;AAIA,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,cAAc;AA+F9B,SAeF,UAfE,KAeF,YAfE;AAvDC,IAAM,aAAa,WAAqC,CAAC,OAAO,QAAQ;AAC7E,QAAM,CAAC,QAAQ,WAAW,IAAI,kBAAkB,cAAc,KAAK;AACnE,QAAM,gBAAgB,eAAe,WAAW;AAChD,MAAI;AAAA,IACF;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,SAAS;AAAA,IACT,GAAG;AAAA,EACL,IAAI,oBAAoB,aAAa;AACrC,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,GAAG;AAAA,EACL,IAAI,WAAW,MAAM,qBAAqB;AAC1C,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ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AA,MACA,YAAY;AAAA,MACZ;AAAA,MACA,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,IACD;AAAA,KACN;AAEJ,CAAC;AAED,WAAW,cAAc;AACzB,WAAW,SAAS;","names":[]}
@@ -11,23 +11,23 @@ interface Props extends FormControlOptions {
11
11
  required?: boolean;
12
12
  }
13
13
  interface FileButtonOptions {
14
+ children?: ((props: Props) => ReactNode) | ReactNode;
14
15
  /**
15
16
  * The border color when the button is invalid.
16
17
  */
17
18
  errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, "colors">;
18
- /**
19
- * Function to be called when a file change event occurs.
20
- */
21
- onChange?: (files: File[] | undefined) => void;
22
- children?: ReactNode | ((props: Props) => ReactNode);
23
19
  /**
24
20
  * Ref to a reset function.
25
21
  */
26
22
  resetRef?: ForwardedRef<() => void>;
23
+ /**
24
+ * Function to be called when a file change event occurs.
25
+ */
26
+ onChange?: (files: File[] | undefined) => void;
27
27
  }
28
28
  interface InputProps extends Partial<Pick<HTMLInputElement, "accept" | "multiple">> {
29
29
  }
30
- interface FileButtonProps extends Omit<ButtonProps, "onChange" | "children">, ThemeProps<"FileButton">, InputProps, FileButtonOptions, FormControlOptions {
30
+ interface FileButtonProps extends Omit<ButtonProps, "children" | "onChange">, ThemeProps<"FileButton">, InputProps, FileButtonOptions, FormControlOptions {
31
31
  }
32
32
  /**
33
33
  * `FileButton` is a button component used for users to select files.
@@ -11,23 +11,23 @@ interface Props extends FormControlOptions {
11
11
  required?: boolean;
12
12
  }
13
13
  interface FileButtonOptions {
14
+ children?: ((props: Props) => ReactNode) | ReactNode;
14
15
  /**
15
16
  * The border color when the button is invalid.
16
17
  */
17
18
  errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, "colors">;
18
- /**
19
- * Function to be called when a file change event occurs.
20
- */
21
- onChange?: (files: File[] | undefined) => void;
22
- children?: ReactNode | ((props: Props) => ReactNode);
23
19
  /**
24
20
  * Ref to a reset function.
25
21
  */
26
22
  resetRef?: ForwardedRef<() => void>;
23
+ /**
24
+ * Function to be called when a file change event occurs.
25
+ */
26
+ onChange?: (files: File[] | undefined) => void;
27
27
  }
28
28
  interface InputProps extends Partial<Pick<HTMLInputElement, "accept" | "multiple">> {
29
29
  }
30
- interface FileButtonProps extends Omit<ButtonProps, "onChange" | "children">, ThemeProps<"FileButton">, InputProps, FileButtonOptions, FormControlOptions {
30
+ interface FileButtonProps extends Omit<ButtonProps, "children" | "onChange">, ThemeProps<"FileButton">, InputProps, FileButtonOptions, FormControlOptions {
31
31
  }
32
32
  /**
33
33
  * `FileButton` is a button component used for users to select files.
@@ -34,29 +34,29 @@ var FileButton = (0, import_core.forwardRef)((props, ref) => {
34
34
  const [styles, mergedProps] = (0, import_core.useComponentStyle)("FileButton", props);
35
35
  const computedProps = (0, import_core.omitThemeProps)(mergedProps);
36
36
  let {
37
- className,
38
- resetRef,
39
- as: As,
40
- children,
41
37
  id,
38
+ as: As,
39
+ form,
42
40
  name,
41
+ className,
43
42
  accept,
43
+ children,
44
44
  multiple,
45
- form,
46
- onClick: onClickProp,
45
+ resetRef,
47
46
  onChange: onChangeProp,
47
+ onClick: onClickProp,
48
48
  ...rest
49
49
  } = (0, import_form_control.useFormControlProps)(computedProps);
50
50
  const {
51
- onFocus: _onFocus,
52
51
  onBlur: _onBlur,
52
+ onFocus: _onFocus,
53
53
  ...formControlProps
54
54
  } = (0, import_utils.pickObject)(rest, import_form_control.formControlProperties);
55
55
  const {
56
+ "aria-invalid": isInvalid,
56
57
  disabled,
57
58
  readOnly,
58
- required,
59
- "aria-invalid": isInvalid
59
+ required
60
60
  } = formControlProps;
61
61
  const inputRef = (0, import_react.useRef)(null);
62
62
  const onClick = (0, import_react.useCallback)(() => {
@@ -93,42 +93,44 @@ var FileButton = (0, import_core.forwardRef)((props, ref) => {
93
93
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
94
  import_core.ui.input,
95
95
  {
96
+ id,
96
97
  ref: (0, import_utils.mergeRefs)(inputRef, ref),
98
+ form,
97
99
  type: "file",
98
- "aria-hidden": true,
99
- tabIndex: -1,
100
- id,
101
100
  name,
102
- form,
103
- accept,
104
- multiple,
105
101
  style: {
106
102
  border: "0px",
107
103
  clip: "rect(0px, 0px, 0px, 0px)",
108
104
  height: "1px",
109
- width: "1px",
110
105
  margin: "-1px",
111
- padding: "0px",
112
106
  overflow: "hidden",
107
+ padding: "0px",
108
+ position: "absolute",
113
109
  whiteSpace: "nowrap",
114
- position: "absolute"
110
+ width: "1px"
115
111
  },
112
+ "aria-hidden": true,
113
+ accept,
114
+ multiple,
115
+ tabIndex: -1,
116
116
  onChange,
117
117
  ...formControlProps
118
118
  }
119
119
  ),
120
120
  (0, import_utils.isFunction)(children) ? children({
121
- onClick,
122
121
  disabled,
123
- readOnly,
124
- required,
125
122
  isDisabled: disabled,
123
+ isInvalid,
126
124
  isReadOnly: readOnly,
127
125
  isRequired: required,
128
- isInvalid
126
+ readOnly,
127
+ required,
128
+ onClick
129
129
  }) : children
130
130
  ] });
131
131
  });
132
+ FileButton.displayName = "FileButton";
133
+ FileButton.__ui__ = "FileButton";
132
134
  // Annotate the CommonJS export names for ESM import in node:
133
135
  0 && (module.exports = {
134
136
  FileButton
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/file-button.tsx"],"sourcesContent":["import type { ButtonProps } from \"@yamada-ui/button\"\nimport { Button } from \"@yamada-ui/button\"\nimport type { ColorModeToken, CSS, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useComponentStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport {\n assignRef,\n cx,\n handlerAll,\n isFunction,\n isNull,\n mergeRefs,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent, ForwardedRef, ReactNode } from \"react\"\nimport { useCallback, useRef } from \"react\"\n\ninterface Props extends FormControlOptions {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n}\n\ninterface FileButtonOptions {\n /**\n * The border color when the button is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * Function to be called when a file change event occurs.\n */\n onChange?: (files: File[] | undefined) => void\n children?: ReactNode | ((props: Props) => ReactNode)\n /**\n * Ref to a reset function.\n */\n resetRef?: ForwardedRef<() => void>\n}\n\ninterface InputProps\n extends Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">> {}\n\nexport interface FileButtonProps\n extends Omit<ButtonProps, \"onChange\" | \"children\">,\n ThemeProps<\"FileButton\">,\n InputProps,\n FileButtonOptions,\n FormControlOptions {}\n\n/**\n * `FileButton` is a button component used for users to select files.\n *\n * @see Docs https://yamada-ui.com/components/forms/file-button\n */\nexport const FileButton = forwardRef<FileButtonProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentStyle(\"FileButton\", props)\n const computedProps = omitThemeProps(mergedProps)\n let {\n className,\n resetRef,\n as: As,\n children,\n id,\n name,\n accept,\n multiple,\n form,\n onClick: onClickProp,\n onChange: onChangeProp,\n ...rest\n } = useFormControlProps(computedProps)\n const {\n onFocus: _onFocus,\n onBlur: _onBlur,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const {\n disabled,\n readOnly,\n required,\n \"aria-invalid\": isInvalid,\n } = formControlProps\n const inputRef = useRef<HTMLInputElement>(null)\n\n const onClick = useCallback(() => {\n if (disabled || readOnly) return\n\n inputRef.current?.click()\n }, [disabled, readOnly])\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n const files = !isNull(ev.currentTarget.files)\n ? Array.from(ev.currentTarget.files)\n : undefined\n\n onChangeProp?.(files)\n },\n [onChangeProp],\n )\n\n const onReset = useCallback(() => {\n if (inputRef.current) inputRef.current.value = \"\"\n }, [])\n\n if (!isFunction(children)) {\n const Component = As || Button\n\n children = (\n <Component\n className={cx(\"ui-file-button\", className)}\n __isProcessSkip={!As}\n __styles={styles}\n {...rest}\n onClick={handlerAll(onClickProp, onClick)}\n >\n {children}\n </Component>\n )\n }\n\n assignRef(resetRef, onReset)\n\n return (\n <>\n <ui.input\n ref={mergeRefs(inputRef, ref)}\n type=\"file\"\n aria-hidden\n tabIndex={-1}\n id={id}\n name={name}\n form={form}\n accept={accept}\n multiple={multiple}\n style={{\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n width: \"1px\",\n margin: \"-1px\",\n padding: \"0px\",\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n position: \"absolute\",\n }}\n onChange={onChange}\n {...formControlProps}\n />\n\n {isFunction(children)\n ? children({\n onClick,\n disabled,\n readOnly,\n required,\n isDisabled: disabled,\n isReadOnly: readOnly,\n isRequired: required,\n isInvalid,\n })\n : children}\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AAEvB,kBAKO;AAEP,0BAGO;AACP,mBAQO;AAEP,mBAAoC;AA+F9B;AAvDC,IAAM,iBAAa,wBAAqC,CAAC,OAAO,QAAQ;AAC7E,QAAM,CAAC,QAAQ,WAAW,QAAI,+BAAkB,cAAc,KAAK;AACnE,QAAM,oBAAgB,4BAAe,WAAW;AAChD,MAAI;AAAA,IACF;AAAA,IACA;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,GAAG;AAAA,EACL,QAAI,yCAAoB,aAAa;AACrC,QAAM;AAAA,IACJ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,GAAG;AAAA,EACL,QAAI,yBAAW,MAAM,yCAAqB;AAC1C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AA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QAAQ,IAChB,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ;AAAA,IACF,CAAC,IACD;AAAA,KACN;AAEJ,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/file-button.tsx"],"sourcesContent":["import type { ButtonProps } from \"@yamada-ui/button\"\nimport type { ColorModeToken, CSS, ThemeProps } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { ChangeEvent, ForwardedRef, ReactNode } from \"react\"\nimport { Button } from \"@yamada-ui/button\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport {\n assignRef,\n cx,\n handlerAll,\n isFunction,\n isNull,\n mergeRefs,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useRef } from \"react\"\n\ninterface Props extends FormControlOptions {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n}\n\ninterface FileButtonOptions {\n children?: ((props: Props) => ReactNode) | ReactNode\n /**\n * The border color when the button is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * Ref to a reset function.\n */\n resetRef?: ForwardedRef<() => void>\n /**\n * Function to be called when a file change event occurs.\n */\n onChange?: (files: File[] | undefined) => void\n}\n\ninterface InputProps\n extends Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">> {}\n\nexport interface FileButtonProps\n extends Omit<ButtonProps, \"children\" | \"onChange\">,\n ThemeProps<\"FileButton\">,\n InputProps,\n FileButtonOptions,\n FormControlOptions {}\n\n/**\n * `FileButton` is a button component used for users to select files.\n *\n * @see Docs https://yamada-ui.com/components/forms/file-button\n */\nexport const FileButton = forwardRef<FileButtonProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentStyle(\"FileButton\", props)\n const computedProps = omitThemeProps(mergedProps)\n let {\n id,\n as: As,\n form,\n name,\n className,\n accept,\n children,\n multiple,\n resetRef,\n onChange: onChangeProp,\n onClick: onClickProp,\n ...rest\n } = useFormControlProps(computedProps)\n const {\n onBlur: _onBlur,\n onFocus: _onFocus,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const {\n \"aria-invalid\": isInvalid,\n disabled,\n readOnly,\n required,\n } = formControlProps\n const inputRef = useRef<HTMLInputElement>(null)\n\n const onClick = useCallback(() => {\n if (disabled || readOnly) return\n\n inputRef.current?.click()\n }, [disabled, readOnly])\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n const files = !isNull(ev.currentTarget.files)\n ? Array.from(ev.currentTarget.files)\n : undefined\n\n onChangeProp?.(files)\n },\n [onChangeProp],\n )\n\n const onReset = useCallback(() => {\n if (inputRef.current) inputRef.current.value = \"\"\n }, [])\n\n if (!isFunction(children)) {\n const Component = As || Button\n\n children = (\n <Component\n className={cx(\"ui-file-button\", className)}\n __isProcessSkip={!As}\n __styles={styles}\n {...rest}\n onClick={handlerAll(onClickProp, onClick)}\n >\n {children}\n </Component>\n )\n }\n\n assignRef(resetRef, onReset)\n\n return (\n <>\n <ui.input\n id={id}\n ref={mergeRefs(inputRef, ref)}\n form={form}\n type=\"file\"\n name={name}\n style={{\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }}\n aria-hidden\n accept={accept}\n multiple={multiple}\n tabIndex={-1}\n onChange={onChange}\n {...formControlProps}\n />\n\n {isFunction(children)\n ? children({\n disabled,\n isDisabled: disabled,\n isInvalid,\n isReadOnly: readOnly,\n isRequired: required,\n readOnly,\n required,\n onClick,\n })\n : children}\n </>\n )\n})\n\nFileButton.displayName = \"FileButton\"\nFileButton.__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,MAAC;AAAA;AAAA,QACC,eAAW,iBAAG,kBAAkB,SAAS;AAAA,QACzC,iBAAiB,CAAC;AAAA,QAClB,UAAU;AAAA,QACT,GAAG;AAAA,QACJ,aAAS,yBAAW,aAAa,OAAO;AAAA,QAEvC;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,8BAAU,UAAU,OAAO;AAE3B,SACE,4EACE;AAAA;AAAA,MAAC,eAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,SAAK,wBAAU,UAAU,GAAG;AAAA,QAC5B;AAAA,QACA,MAAK;AAAA,QACL;AAAA,QACA,OAAO;AAAA,UACL,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,QAAQ;AAAA,UACR,UAAU;AAAA,UACV,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,OAAO;AAAA,QACT;AAAA,QACA,eAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA,UAAU;AAAA,QACV;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,QAEC,yBAAW,QAAQ,IAChB,SAAS;AAAA,MACP;AAAA,MACA,YAAY;AAAA,MACZ;AAAA,MACA,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,IACD;AAAA,KACN;AAEJ,CAAC;AAED,WAAW,cAAc;AACzB,WAAW,SAAS;","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  FileButton
4
- } from "./chunk-ZC23JUXH.mjs";
4
+ } from "./chunk-5WHD36CE.mjs";
5
5
  export {
6
6
  FileButton
7
7
  };
package/dist/index.js CHANGED
@@ -36,29 +36,29 @@ var FileButton = (0, import_core.forwardRef)((props, ref) => {
36
36
  const [styles, mergedProps] = (0, import_core.useComponentStyle)("FileButton", props);
37
37
  const computedProps = (0, import_core.omitThemeProps)(mergedProps);
38
38
  let {
39
- className,
40
- resetRef,
41
- as: As,
42
- children,
43
39
  id,
40
+ as: As,
41
+ form,
44
42
  name,
43
+ className,
45
44
  accept,
45
+ children,
46
46
  multiple,
47
- form,
48
- onClick: onClickProp,
47
+ resetRef,
49
48
  onChange: onChangeProp,
49
+ onClick: onClickProp,
50
50
  ...rest
51
51
  } = (0, import_form_control.useFormControlProps)(computedProps);
52
52
  const {
53
- onFocus: _onFocus,
54
53
  onBlur: _onBlur,
54
+ onFocus: _onFocus,
55
55
  ...formControlProps
56
56
  } = (0, import_utils.pickObject)(rest, import_form_control.formControlProperties);
57
57
  const {
58
+ "aria-invalid": isInvalid,
58
59
  disabled,
59
60
  readOnly,
60
- required,
61
- "aria-invalid": isInvalid
61
+ required
62
62
  } = formControlProps;
63
63
  const inputRef = (0, import_react.useRef)(null);
64
64
  const onClick = (0, import_react.useCallback)(() => {
@@ -95,42 +95,44 @@ var FileButton = (0, import_core.forwardRef)((props, ref) => {
95
95
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
96
96
  import_core.ui.input,
97
97
  {
98
+ id,
98
99
  ref: (0, import_utils.mergeRefs)(inputRef, ref),
100
+ form,
99
101
  type: "file",
100
- "aria-hidden": true,
101
- tabIndex: -1,
102
- id,
103
102
  name,
104
- form,
105
- accept,
106
- multiple,
107
103
  style: {
108
104
  border: "0px",
109
105
  clip: "rect(0px, 0px, 0px, 0px)",
110
106
  height: "1px",
111
- width: "1px",
112
107
  margin: "-1px",
113
- padding: "0px",
114
108
  overflow: "hidden",
109
+ padding: "0px",
110
+ position: "absolute",
115
111
  whiteSpace: "nowrap",
116
- position: "absolute"
112
+ width: "1px"
117
113
  },
114
+ "aria-hidden": true,
115
+ accept,
116
+ multiple,
117
+ tabIndex: -1,
118
118
  onChange,
119
119
  ...formControlProps
120
120
  }
121
121
  ),
122
122
  (0, import_utils.isFunction)(children) ? children({
123
- onClick,
124
123
  disabled,
125
- readOnly,
126
- required,
127
124
  isDisabled: disabled,
125
+ isInvalid,
128
126
  isReadOnly: readOnly,
129
127
  isRequired: required,
130
- isInvalid
128
+ readOnly,
129
+ required,
130
+ onClick
131
131
  }) : children
132
132
  ] });
133
133
  });
134
+ FileButton.displayName = "FileButton";
135
+ FileButton.__ui__ = "FileButton";
134
136
  // Annotate the CommonJS export names for ESM import in node:
135
137
  0 && (module.exports = {
136
138
  FileButton
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/file-button.tsx"],"sourcesContent":["export { FileButton } from \"./file-button\"\nexport type { FileButtonProps } from \"./file-button\"\n","import type { ButtonProps } from \"@yamada-ui/button\"\nimport { Button } from \"@yamada-ui/button\"\nimport type { ColorModeToken, CSS, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useComponentStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport {\n assignRef,\n cx,\n handlerAll,\n isFunction,\n isNull,\n mergeRefs,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent, ForwardedRef, ReactNode } from \"react\"\nimport { useCallback, useRef } from \"react\"\n\ninterface Props extends FormControlOptions {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n}\n\ninterface FileButtonOptions {\n /**\n * The border color when the button is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * Function to be called when a file change event occurs.\n */\n onChange?: (files: File[] | undefined) => void\n children?: ReactNode | ((props: Props) => ReactNode)\n /**\n * Ref to a reset function.\n */\n resetRef?: ForwardedRef<() => void>\n}\n\ninterface InputProps\n extends Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">> {}\n\nexport interface FileButtonProps\n extends Omit<ButtonProps, \"onChange\" | \"children\">,\n ThemeProps<\"FileButton\">,\n InputProps,\n FileButtonOptions,\n FormControlOptions {}\n\n/**\n * `FileButton` is a button component used for users to select files.\n *\n * @see Docs https://yamada-ui.com/components/forms/file-button\n */\nexport const FileButton = forwardRef<FileButtonProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentStyle(\"FileButton\", props)\n const computedProps = omitThemeProps(mergedProps)\n let {\n className,\n resetRef,\n as: As,\n children,\n id,\n name,\n accept,\n multiple,\n form,\n onClick: onClickProp,\n onChange: onChangeProp,\n ...rest\n } = useFormControlProps(computedProps)\n const {\n onFocus: _onFocus,\n onBlur: _onBlur,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const {\n disabled,\n readOnly,\n required,\n \"aria-invalid\": isInvalid,\n } = formControlProps\n const inputRef = useRef<HTMLInputElement>(null)\n\n const onClick = useCallback(() => {\n if (disabled || readOnly) return\n\n inputRef.current?.click()\n }, [disabled, readOnly])\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n const files = !isNull(ev.currentTarget.files)\n ? Array.from(ev.currentTarget.files)\n : undefined\n\n onChangeProp?.(files)\n },\n [onChangeProp],\n )\n\n const onReset = useCallback(() => {\n if (inputRef.current) inputRef.current.value = \"\"\n }, [])\n\n if (!isFunction(children)) {\n const Component = As || Button\n\n children = (\n <Component\n className={cx(\"ui-file-button\", className)}\n __isProcessSkip={!As}\n __styles={styles}\n {...rest}\n onClick={handlerAll(onClickProp, onClick)}\n >\n {children}\n </Component>\n )\n }\n\n assignRef(resetRef, onReset)\n\n return (\n <>\n <ui.input\n ref={mergeRefs(inputRef, ref)}\n type=\"file\"\n aria-hidden\n tabIndex={-1}\n id={id}\n name={name}\n form={form}\n accept={accept}\n multiple={multiple}\n style={{\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n width: \"1px\",\n margin: \"-1px\",\n padding: \"0px\",\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n position: \"absolute\",\n }}\n onChange={onChange}\n {...formControlProps}\n />\n\n {isFunction(children)\n ? children({\n onClick,\n disabled,\n readOnly,\n required,\n isDisabled: disabled,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AQ,GAAG;AACzB,UAAM,YAAY,MAAM;AAExB,eACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,iBAAG,kBAAkB,SAAS;AAAA,QACzC,iBAAiB,CAAC;AAAA,QAClB,UAAU;AAAA,QACT,GAAG;AAAA,QACJ,aAAS,yBAAW,aAAa,OAAO;AAAA,QAEvC;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,8BAAU,UAAU,OAAO;AAE3B,SACE,4EACE;AAAA;AAAA,MAAC,eAAG;AAAA,MAAH;AAAA,QACC,SAAK,wBAAU,UAAU,GAAG;AAAA,QAC5B,MAAK;AAAA,QACL,eAAW;AAAA,QACX,UAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,UACL,QAAQ;AAAA,UACR,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,UAAU;AAAA,QACZ;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,QAEC,yBAAW,QAAQ,IAChB,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ;AAAA,IACF,CAAC,IACD;AAAA,KACN;AAEJ,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/file-button.tsx"],"sourcesContent":["export { FileButton } from \"./file-button\"\nexport type { FileButtonProps } from \"./file-button\"\n","import type { ButtonProps } from \"@yamada-ui/button\"\nimport type { ColorModeToken, CSS, ThemeProps } from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport type { ChangeEvent, ForwardedRef, ReactNode } from \"react\"\nimport { Button } from \"@yamada-ui/button\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentStyle,\n} from \"@yamada-ui/core\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport {\n assignRef,\n cx,\n handlerAll,\n isFunction,\n isNull,\n mergeRefs,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useRef } from \"react\"\n\ninterface Props extends FormControlOptions {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n}\n\ninterface FileButtonOptions {\n children?: ((props: Props) => ReactNode) | ReactNode\n /**\n * The border color when the button is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * Ref to a reset function.\n */\n resetRef?: ForwardedRef<() => void>\n /**\n * Function to be called when a file change event occurs.\n */\n onChange?: (files: File[] | undefined) => void\n}\n\ninterface InputProps\n extends Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">> {}\n\nexport interface FileButtonProps\n extends Omit<ButtonProps, \"children\" | \"onChange\">,\n ThemeProps<\"FileButton\">,\n InputProps,\n FileButtonOptions,\n FormControlOptions {}\n\n/**\n * `FileButton` is a button component used for users to select files.\n *\n * @see Docs https://yamada-ui.com/components/forms/file-button\n */\nexport const FileButton = forwardRef<FileButtonProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentStyle(\"FileButton\", props)\n const computedProps = omitThemeProps(mergedProps)\n let {\n id,\n as: As,\n form,\n name,\n className,\n accept,\n children,\n multiple,\n resetRef,\n onChange: onChangeProp,\n onClick: onClickProp,\n ...rest\n } = useFormControlProps(computedProps)\n const {\n onBlur: _onBlur,\n onFocus: _onFocus,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const {\n \"aria-invalid\": isInvalid,\n disabled,\n readOnly,\n required,\n } = formControlProps\n const inputRef = useRef<HTMLInputElement>(null)\n\n const onClick = useCallback(() => {\n if (disabled || readOnly) return\n\n inputRef.current?.click()\n }, [disabled, readOnly])\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n const files = !isNull(ev.currentTarget.files)\n ? Array.from(ev.currentTarget.files)\n : undefined\n\n onChangeProp?.(files)\n },\n [onChangeProp],\n )\n\n const onReset = useCallback(() => {\n if (inputRef.current) inputRef.current.value = \"\"\n }, [])\n\n if (!isFunction(children)) {\n const Component = As || Button\n\n children = (\n <Component\n className={cx(\"ui-file-button\", className)}\n __isProcessSkip={!As}\n __styles={styles}\n {...rest}\n onClick={handlerAll(onClickProp, onClick)}\n >\n {children}\n </Component>\n )\n }\n\n assignRef(resetRef, onReset)\n\n return (\n <>\n <ui.input\n id={id}\n ref={mergeRefs(inputRef, ref)}\n form={form}\n type=\"file\"\n name={name}\n style={{\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n }}\n aria-hidden\n accept={accept}\n multiple={multiple}\n tabIndex={-1}\n onChange={onChange}\n {...formControlProps}\n />\n\n {isFunction(children)\n ? children({\n disabled,\n isDisabled: disabled,\n isInvalid,\n isReadOnly: readOnly,\n isRequired: required,\n readOnly,\n required,\n onClick,\n })\n : children}\n </>\n )\n})\n\nFileButton.displayName = \"FileButton\"\nFileButton.__ui__ = \"FileButton\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,oBAAuB;AACvB,kBAKO;AACP,0BAGO;AACP,mBAQO;AACP,mBAAoC;AA+F9B;AAvDC,IAAM,iBAAa,wBAAqC,CAAC,OAAO,QAAQ;AAC7E,QAAM,CAAC,QAAQ,WAAW,QAAI,+BAAkB,cAAc,KAAK;AACnE,QAAM,oBAAgB,4BAAe,WAAW;AAChD,MAAI;AAAA,IACF;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,SAAS;AAAA,IAC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,UACR,UAAU;AAAA,UACV,SAAS;AAAA,UACT,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,OAAO;AAAA,QACT;AAAA,QACA,eAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA,UAAU;AAAA,QACV;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,QAEC,yBAAW,QAAQ,IAChB,SAAS;AAAA,MACP;AAAA,MACA,YAAY;AAAA,MACZ;AAAA,MACA,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,IACD;AAAA,KACN;AAEJ,CAAC;AAED,WAAW,cAAc;AACzB,WAAW,SAAS;","names":[]}
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  FileButton
4
- } from "./chunk-ZC23JUXH.mjs";
4
+ } from "./chunk-5WHD36CE.mjs";
5
5
  export {
6
6
  FileButton
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/file-button",
3
- "version": "1.1.7-next-20241005235555",
3
+ "version": "1.1.7",
4
4
  "description": "Yamada UI file button component",
5
5
  "keywords": [
6
6
  "yamada",
@@ -36,10 +36,10 @@
36
36
  "url": "https://github.com/yamada-ui/yamada-ui/issues"
37
37
  },
38
38
  "dependencies": {
39
- "@yamada-ui/button": "2.0.0-next-20241005235555",
40
- "@yamada-ui/core": "1.15.2-next-20241005235555",
41
- "@yamada-ui/form-control": "3.0.0-next-20241005235555",
42
- "@yamada-ui/utils": "1.5.2"
39
+ "@yamada-ui/button": "1.0.44",
40
+ "@yamada-ui/core": "1.15.2",
41
+ "@yamada-ui/form-control": "2.1.4",
42
+ "@yamada-ui/utils": "1.5.3"
43
43
  },
44
44
  "devDependencies": {
45
45
  "clean-package": "2.2.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/file-button.tsx"],"sourcesContent":["import type { ButtonProps } from \"@yamada-ui/button\"\nimport { Button } from \"@yamada-ui/button\"\nimport type { ColorModeToken, CSS, ThemeProps } from \"@yamada-ui/core\"\nimport {\n ui,\n forwardRef,\n useComponentStyle,\n omitThemeProps,\n} from \"@yamada-ui/core\"\nimport type { FormControlOptions } from \"@yamada-ui/form-control\"\nimport {\n formControlProperties,\n useFormControlProps,\n} from \"@yamada-ui/form-control\"\nimport {\n assignRef,\n cx,\n handlerAll,\n isFunction,\n isNull,\n mergeRefs,\n pickObject,\n} from \"@yamada-ui/utils\"\nimport type { ChangeEvent, ForwardedRef, ReactNode } from \"react\"\nimport { useCallback, useRef } from \"react\"\n\ninterface Props extends FormControlOptions {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n}\n\ninterface FileButtonOptions {\n /**\n * The border color when the button is invalid.\n */\n errorBorderColor?: ColorModeToken<CSS.Property.BorderColor, \"colors\">\n /**\n * Function to be called when a file change event occurs.\n */\n onChange?: (files: File[] | undefined) => void\n children?: ReactNode | ((props: Props) => ReactNode)\n /**\n * Ref to a reset function.\n */\n resetRef?: ForwardedRef<() => void>\n}\n\ninterface InputProps\n extends Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">> {}\n\nexport interface FileButtonProps\n extends Omit<ButtonProps, \"onChange\" | \"children\">,\n ThemeProps<\"FileButton\">,\n InputProps,\n FileButtonOptions,\n FormControlOptions {}\n\n/**\n * `FileButton` is a button component used for users to select files.\n *\n * @see Docs https://yamada-ui.com/components/forms/file-button\n */\nexport const FileButton = forwardRef<FileButtonProps, \"input\">((props, ref) => {\n const [styles, mergedProps] = useComponentStyle(\"FileButton\", props)\n const computedProps = omitThemeProps(mergedProps)\n let {\n className,\n resetRef,\n as: As,\n children,\n id,\n name,\n accept,\n multiple,\n form,\n onClick: onClickProp,\n onChange: onChangeProp,\n ...rest\n } = useFormControlProps(computedProps)\n const {\n onFocus: _onFocus,\n onBlur: _onBlur,\n ...formControlProps\n } = pickObject(rest, formControlProperties)\n const {\n disabled,\n readOnly,\n required,\n \"aria-invalid\": isInvalid,\n } = formControlProps\n const inputRef = useRef<HTMLInputElement>(null)\n\n const onClick = useCallback(() => {\n if (disabled || readOnly) return\n\n inputRef.current?.click()\n }, [disabled, readOnly])\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n const files = !isNull(ev.currentTarget.files)\n ? Array.from(ev.currentTarget.files)\n : undefined\n\n onChangeProp?.(files)\n },\n [onChangeProp],\n )\n\n const onReset = useCallback(() => {\n if (inputRef.current) inputRef.current.value = \"\"\n }, [])\n\n if (!isFunction(children)) {\n const Component = As || Button\n\n children = (\n <Component\n className={cx(\"ui-file-button\", className)}\n __isProcessSkip={!As}\n __styles={styles}\n {...rest}\n onClick={handlerAll(onClickProp, onClick)}\n >\n {children}\n </Component>\n )\n }\n\n assignRef(resetRef, onReset)\n\n return (\n <>\n <ui.input\n ref={mergeRefs(inputRef, ref)}\n type=\"file\"\n aria-hidden\n tabIndex={-1}\n id={id}\n name={name}\n form={form}\n accept={accept}\n multiple={multiple}\n style={{\n border: \"0px\",\n clip: \"rect(0px, 0px, 0px, 0px)\",\n height: \"1px\",\n width: \"1px\",\n margin: \"-1px\",\n padding: \"0px\",\n overflow: \"hidden\",\n whiteSpace: \"nowrap\",\n position: \"absolute\",\n }}\n onChange={onChange}\n {...formControlProps}\n />\n\n {isFunction(children)\n ? children({\n onClick,\n disabled,\n readOnly,\n required,\n isDisabled: disabled,\n isReadOnly: readOnly,\n isRequired: required,\n isInvalid,\n })\n : children}\n </>\n )\n})\n"],"mappings":";;;AACA,SAAS,cAAc;AAEvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,aAAa,cAAc;AA+F9B,SAeF,UAfE,KAeF,YAfE;AAvDC,IAAM,aAAa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