@yamada-ui/file-button 1.1.4-dev-20240907122824 → 1.1.4-dev-20240908075149
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-SFHQYLKL.mjs → chunk-W57Z2PYW.mjs} +13 -5
- package/dist/chunk-W57Z2PYW.mjs.map +1 -0
- package/dist/file-button.js +12 -4
- package/dist/file-button.js.map +1 -1
- package/dist/file-button.mjs +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +5 -5
- package/dist/chunk-SFHQYLKL.mjs.map +0 -1
@@ -36,12 +36,21 @@ var FileButton = forwardRef((props, ref) => {
|
|
36
36
|
accept,
|
37
37
|
multiple,
|
38
38
|
form,
|
39
|
-
"aria-readonly": ariaReadonly,
|
40
39
|
onClick: onClickProp,
|
41
40
|
onChange: onChangeProp,
|
42
41
|
...rest
|
43
42
|
} = useFormControlProps(computedProps);
|
44
|
-
const {
|
43
|
+
const {
|
44
|
+
onFocus: _onFocus,
|
45
|
+
onBlur: _onBlur,
|
46
|
+
...formControlProps
|
47
|
+
} = pickObject(rest, formControlProperties);
|
48
|
+
const {
|
49
|
+
disabled,
|
50
|
+
readOnly,
|
51
|
+
required,
|
52
|
+
"aria-invalid": isInvalid
|
53
|
+
} = formControlProps;
|
45
54
|
const inputRef = useRef(null);
|
46
55
|
const onClick = useCallback(() => {
|
47
56
|
var _a;
|
@@ -98,8 +107,7 @@ var FileButton = forwardRef((props, ref) => {
|
|
98
107
|
position: "absolute"
|
99
108
|
},
|
100
109
|
onChange,
|
101
|
-
|
102
|
-
...pickObject(rest, formControlProperties)
|
110
|
+
...formControlProps
|
103
111
|
}
|
104
112
|
),
|
105
113
|
isFunction(children) ? children({
|
@@ -118,4 +126,4 @@ var FileButton = forwardRef((props, ref) => {
|
|
118
126
|
export {
|
119
127
|
FileButton
|
120
128
|
};
|
121
|
-
//# sourceMappingURL=chunk-
|
129
|
+
//# sourceMappingURL=chunk-W57Z2PYW.mjs.map
|
@@ -0,0 +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\ntype Props = {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n} & FormControlOptions\n\ntype 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\ntype InputProps = Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">>\n\nexport type FileButtonProps = 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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ACT,GAAG;AAAA,QACJ,SAAS,WAAW,aAAa,OAAO;AAAA,QAEvC;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,YAAU,UAAU,OAAO;AAE3B,SACE,iCACE;AAAA;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACC,KAAK,UAAU,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,IAEC,WAAW,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":[]}
|
package/dist/file-button.js
CHANGED
@@ -43,12 +43,21 @@ var FileButton = (0, import_core.forwardRef)((props, ref) => {
|
|
43
43
|
accept,
|
44
44
|
multiple,
|
45
45
|
form,
|
46
|
-
"aria-readonly": ariaReadonly,
|
47
46
|
onClick: onClickProp,
|
48
47
|
onChange: onChangeProp,
|
49
48
|
...rest
|
50
49
|
} = (0, import_form_control.useFormControlProps)(computedProps);
|
51
|
-
const {
|
50
|
+
const {
|
51
|
+
onFocus: _onFocus,
|
52
|
+
onBlur: _onBlur,
|
53
|
+
...formControlProps
|
54
|
+
} = (0, import_utils.pickObject)(rest, import_form_control.formControlProperties);
|
55
|
+
const {
|
56
|
+
disabled,
|
57
|
+
readOnly,
|
58
|
+
required,
|
59
|
+
"aria-invalid": isInvalid
|
60
|
+
} = formControlProps;
|
52
61
|
const inputRef = (0, import_react.useRef)(null);
|
53
62
|
const onClick = (0, import_react.useCallback)(() => {
|
54
63
|
var _a;
|
@@ -105,8 +114,7 @@ var FileButton = (0, import_core.forwardRef)((props, ref) => {
|
|
105
114
|
position: "absolute"
|
106
115
|
},
|
107
116
|
onChange,
|
108
|
-
|
109
|
-
...(0, import_utils.pickObject)(rest, import_form_control.formControlProperties)
|
117
|
+
...formControlProps
|
110
118
|
}
|
111
119
|
),
|
112
120
|
(0, import_utils.isFunction)(children) ? children({
|
package/dist/file-button.js.map
CHANGED
@@ -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\ntype Props = {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n} & FormControlOptions\n\ntype 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\ntype InputProps = Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">>\n\nexport type FileButtonProps = 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
|
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\ntype Props = {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n} & FormControlOptions\n\ntype 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\ntype InputProps = Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">>\n\nexport type FileButtonProps = 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 isDis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W,QAAQ,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":[]}
|
package/dist/file-button.mjs
CHANGED
package/dist/index.js
CHANGED
@@ -45,12 +45,21 @@ var FileButton = (0, import_core.forwardRef)((props, ref) => {
|
|
45
45
|
accept,
|
46
46
|
multiple,
|
47
47
|
form,
|
48
|
-
"aria-readonly": ariaReadonly,
|
49
48
|
onClick: onClickProp,
|
50
49
|
onChange: onChangeProp,
|
51
50
|
...rest
|
52
51
|
} = (0, import_form_control.useFormControlProps)(computedProps);
|
53
|
-
const {
|
52
|
+
const {
|
53
|
+
onFocus: _onFocus,
|
54
|
+
onBlur: _onBlur,
|
55
|
+
...formControlProps
|
56
|
+
} = (0, import_utils.pickObject)(rest, import_form_control.formControlProperties);
|
57
|
+
const {
|
58
|
+
disabled,
|
59
|
+
readOnly,
|
60
|
+
required,
|
61
|
+
"aria-invalid": isInvalid
|
62
|
+
} = formControlProps;
|
54
63
|
const inputRef = (0, import_react.useRef)(null);
|
55
64
|
const onClick = (0, import_react.useCallback)(() => {
|
56
65
|
var _a;
|
@@ -107,8 +116,7 @@ var FileButton = (0, import_core.forwardRef)((props, ref) => {
|
|
107
116
|
position: "absolute"
|
108
117
|
},
|
109
118
|
onChange,
|
110
|
-
|
111
|
-
...(0, import_utils.pickObject)(rest, import_form_control.formControlProperties)
|
119
|
+
...formControlProps
|
112
120
|
}
|
113
121
|
),
|
114
122
|
(0, import_utils.isFunction)(children) ? children({
|
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\ntype Props = {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n} & FormControlOptions\n\ntype 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\ntype InputProps = Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">>\n\nexport type FileButtonProps = 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
|
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\ntype Props = {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n} & FormControlOptions\n\ntype 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\ntype InputProps = Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">>\n\nexport type FileButtonProps = 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;;;ACCA,oBAAuB;AAEvB,kBAKO;AAEP,0BAGO;AACP,mBAQO;AAEP,mBAAoC;AA6F9B;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;AAAA,EAClB,IAAI;AACJ,QAAM,eAAW,qBAAyB,IAAI;AAE9C,QAAM,cAAU,0BAAY,MAAM;AA5FpC;AA6FI,QAAI,YAAY,SAAU;AAE1B,mBAAS,YAAT,mBAAkB;AAAA,EACpB,GAAG,CAAC,UAAU,QAAQ,CAAC;AAEvB,QAAM,eAAW;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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@yamada-ui/file-button",
|
3
|
-
"version": "1.1.4-dev-
|
3
|
+
"version": "1.1.4-dev-20240908075149",
|
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": "1.0.41-dev-
|
40
|
-
"@yamada-ui/core": "1.
|
41
|
-
"@yamada-ui/form-control": "2.1.1-dev-
|
42
|
-
"@yamada-ui/utils": "1.4.
|
39
|
+
"@yamada-ui/button": "1.0.41-dev-20240908075149",
|
40
|
+
"@yamada-ui/core": "1.14.0-dev-20240908075149",
|
41
|
+
"@yamada-ui/form-control": "2.1.1-dev-20240908075149",
|
42
|
+
"@yamada-ui/utils": "1.4.1-dev-20240908075149"
|
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\ntype Props = {\n onClick: () => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n} & FormControlOptions\n\ntype 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\ntype InputProps = Partial<Pick<HTMLInputElement, \"accept\" | \"multiple\">>\n\nexport type FileButtonProps = 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 \"aria-readonly\": ariaReadonly,\n onClick: onClickProp,\n onChange: onChangeProp,\n ...rest\n } = useFormControlProps(computedProps)\n const { disabled, readOnly, required, \"aria-invalid\": isInvalid } = rest\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 aria-readonly={ariaReadonly}\n {...pickObject(rest, formControlProperties)}\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;AAoF9B,SAeF,UAfE,KAeF,YAfE;AA9CC,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;AAAA,IACA,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,GAAG;AAAA,EACL,IAAI,oBAAoB,aAAa;AACrC,QAAM,EAAE,UAAU,UAAU,UAAU,gBAAgB,UAAU,IAAI;AACpE,QAAM,WAAW,OAAyB,IAAI;AAE9C,QAAM,UAAU,YAAY,MAAM;AAnFpC;AAoFI,QAAI,YAAY,SAAU;AAE1B,mBA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