deepsea-components 5.10.0 → 5.10.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/cjs/components/InputFileButton.d.ts +2 -1
- package/dist/cjs/components/InputFileButton.js +2 -0
- package/dist/cjs/components/InputFileButton.js.map +2 -2
- package/dist/esm/components/InputFileButton.d.ts +2 -1
- package/dist/esm/components/InputFileButton.js +2 -0
- package/dist/esm/components/InputFileButton.js.map +1 -1
- package/package.json +1 -1
- package/src/components/InputFileButton.tsx +4 -2
|
@@ -2,7 +2,8 @@ import { ComponentProps, JSX } from "react";
|
|
|
2
2
|
import { InputFileBaseProps, InputFileDataType, InputFileExtraProps } from "./InputFile";
|
|
3
3
|
export type InputFileButtonProps<Multiple extends boolean = false, Type extends InputFileDataType = "file", AS extends keyof JSX.IntrinsicElements = "button"> = Omit<ComponentProps<AS>, "type" | "disabled"> & InputFileExtraProps<Multiple, Type> & {
|
|
4
4
|
disabled?: boolean;
|
|
5
|
-
inputProps?: InputFileBaseProps
|
|
5
|
+
inputProps?: Omit<InputFileBaseProps, "accept">;
|
|
6
|
+
accept?: string;
|
|
6
7
|
dragFile?: boolean;
|
|
7
8
|
as?: AS;
|
|
8
9
|
};
|
|
@@ -30,6 +30,7 @@ function InputFileButton(props) {
|
|
|
30
30
|
as = "button",
|
|
31
31
|
onClick: _onClick,
|
|
32
32
|
inputProps = {},
|
|
33
|
+
accept,
|
|
33
34
|
onDrop: _onDrop,
|
|
34
35
|
onDragOver: _onDragOver,
|
|
35
36
|
dragFile,
|
|
@@ -88,6 +89,7 @@ function InputFileButton(props) {
|
|
|
88
89
|
disabled: disabled || _disabled || __disabled,
|
|
89
90
|
style: { display: "none", ...style },
|
|
90
91
|
multiple,
|
|
92
|
+
accept,
|
|
91
93
|
type,
|
|
92
94
|
onValueChange,
|
|
93
95
|
onFileChange,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/InputFileButton.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\r\n\r\nimport { ComponentProps, ComponentRef, createElement, DragEvent, Fragment, JSX, MouseEvent as ReactMouseEvent, useRef, useState } from \"react\"\r\nimport { FileType, getFileData, InputFile, InputFileBaseProps, InputFileDataType, InputFileDataTypeMap, InputFileExtraProps, ValueType } from \"./InputFile\"\r\n\r\nexport type InputFileButtonProps<\r\n Multiple extends boolean = false,\r\n Type extends InputFileDataType = \"file\",\r\n AS extends keyof JSX.IntrinsicElements = \"button\",\r\n> = Omit<ComponentProps<AS>, \"type\" | \"disabled\"> &\r\n InputFileExtraProps<Multiple, Type> & {\r\n disabled?: boolean\r\n inputProps?: InputFileBaseProps\r\n dragFile?: boolean\r\n as?: AS\r\n }\r\n\r\n/** 专用于读取文件的 button 组件 */\r\nexport function InputFileButton<Multiple extends boolean = false, Type extends InputFileDataType = \"file\", AS extends keyof JSX.IntrinsicElements = \"button\">(\r\n props: InputFileButtonProps<Multiple, Type, AS>,\r\n) {\r\n const {\r\n as = \"button\",\r\n onClick: _onClick,\r\n inputProps = {},\r\n onDrop: _onDrop,\r\n onDragOver: _onDragOver,\r\n dragFile,\r\n disabled: _disabled,\r\n type = \"file\",\r\n multiple,\r\n onValueChange,\r\n onFileChange,\r\n clearAfterChange,\r\n ...rest\r\n } = props\r\n\r\n const { style, disabled: __disabled, ...restInputProps } = inputProps\r\n const [disabled, setDisabled] = useState(false)\r\n const input = useRef<HTMLInputElement>(null)\r\n\r\n function onClick(e: ReactMouseEvent<ComponentRef<AS>, MouseEvent>) {\r\n input.current?.click()\r\n _onClick?.(e as any)\r\n }\r\n\r\n async function onDrop(e: DragEvent<ComponentRef<AS>>) {\r\n _onDrop?.(e as any)\r\n if (disabled || !dragFile) return\r\n e.preventDefault()\r\n const { files } = e.dataTransfer\r\n if (!files || files.length === 0) return\r\n setDisabled(true)\r\n try {\r\n if (multiple) {\r\n const files2: File[] = Array.from(files)\r\n const values: InputFileDataTypeMap[Type][] = []\r\n for (const file of files2) {\r\n const value = (await getFileData(file, type)) as InputFileDataTypeMap[Type]\r\n values.push(value)\r\n }\r\n onFileChange?.(files2 as FileType<Multiple>)\r\n onValueChange?.(values as ValueType<Multiple, Type>)\r\n } else {\r\n const file = files[0]\r\n onFileChange?.(file as FileType<Multiple>)\r\n onValueChange?.((await getFileData(file, type)) as ValueType<Multiple, Type>)\r\n }\r\n } finally {\r\n setDisabled(false)\r\n }\r\n }\r\n\r\n function onDragOver(e: DragEvent<ComponentRef<AS>>) {\r\n _onDragOver?.(e as any)\r\n if (disabled || !dragFile) return\r\n e.preventDefault()\r\n }\r\n\r\n return (\r\n <Fragment>\r\n <InputFile<Multiple, Type>\r\n disabled={disabled || _disabled || __disabled}\r\n style={{ display: \"none\", ...style }}\r\n multiple={multiple}\r\n type={type as Type}\r\n onValueChange={onValueChange}\r\n onFileChange={onFileChange}\r\n clearAfterChange={clearAfterChange}\r\n {...restInputProps}\r\n />\r\n {createElement(as, {\r\n disabled: disabled || _disabled,\r\n onClick,\r\n onDrop,\r\n onDragOver,\r\n ...rest,\r\n })}\r\n </Fragment>\r\n )\r\n}\r\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAuI;AACvI,uBAA8I;
|
|
4
|
+
"sourcesContent": ["\"use client\"\r\n\r\nimport { ComponentProps, ComponentRef, createElement, DragEvent, Fragment, JSX, MouseEvent as ReactMouseEvent, useRef, useState } from \"react\"\r\nimport { FileType, getFileData, InputFile, InputFileBaseProps, InputFileDataType, InputFileDataTypeMap, InputFileExtraProps, ValueType } from \"./InputFile\"\r\n\r\nexport type InputFileButtonProps<\r\n Multiple extends boolean = false,\r\n Type extends InputFileDataType = \"file\",\r\n AS extends keyof JSX.IntrinsicElements = \"button\",\r\n> = Omit<ComponentProps<AS>, \"type\" | \"disabled\"> &\r\n InputFileExtraProps<Multiple, Type> & {\r\n disabled?: boolean\r\n inputProps?: Omit<InputFileBaseProps, \"accept\">\r\n accept?: string\r\n dragFile?: boolean\r\n as?: AS\r\n }\r\n\r\n/** 专用于读取文件的 button 组件 */\r\nexport function InputFileButton<Multiple extends boolean = false, Type extends InputFileDataType = \"file\", AS extends keyof JSX.IntrinsicElements = \"button\">(\r\n props: InputFileButtonProps<Multiple, Type, AS>,\r\n) {\r\n const {\r\n as = \"button\",\r\n onClick: _onClick,\r\n inputProps = {},\r\n accept,\r\n onDrop: _onDrop,\r\n onDragOver: _onDragOver,\r\n dragFile,\r\n disabled: _disabled,\r\n type = \"file\",\r\n multiple,\r\n onValueChange,\r\n onFileChange,\r\n clearAfterChange,\r\n ...rest\r\n } = props\r\n\r\n const { style, disabled: __disabled, ...restInputProps } = inputProps\r\n const [disabled, setDisabled] = useState(false)\r\n const input = useRef<HTMLInputElement>(null)\r\n\r\n function onClick(e: ReactMouseEvent<ComponentRef<AS>, MouseEvent>) {\r\n input.current?.click()\r\n _onClick?.(e as any)\r\n }\r\n\r\n async function onDrop(e: DragEvent<ComponentRef<AS>>) {\r\n _onDrop?.(e as any)\r\n if (disabled || !dragFile) return\r\n e.preventDefault()\r\n const { files } = e.dataTransfer\r\n if (!files || files.length === 0) return\r\n setDisabled(true)\r\n try {\r\n if (multiple) {\r\n const files2: File[] = Array.from(files)\r\n const values: InputFileDataTypeMap[Type][] = []\r\n for (const file of files2) {\r\n const value = (await getFileData(file, type)) as InputFileDataTypeMap[Type]\r\n values.push(value)\r\n }\r\n onFileChange?.(files2 as FileType<Multiple>)\r\n onValueChange?.(values as ValueType<Multiple, Type>)\r\n } else {\r\n const file = files[0]\r\n onFileChange?.(file as FileType<Multiple>)\r\n onValueChange?.((await getFileData(file, type)) as ValueType<Multiple, Type>)\r\n }\r\n } finally {\r\n setDisabled(false)\r\n }\r\n }\r\n\r\n function onDragOver(e: DragEvent<ComponentRef<AS>>) {\r\n _onDragOver?.(e as any)\r\n if (disabled || !dragFile) return\r\n e.preventDefault()\r\n }\r\n\r\n return (\r\n <Fragment>\r\n <InputFile<Multiple, Type>\r\n disabled={disabled || _disabled || __disabled}\r\n style={{ display: \"none\", ...style }}\r\n multiple={multiple}\r\n accept={accept}\r\n type={type as Type}\r\n onValueChange={onValueChange}\r\n onFileChange={onFileChange}\r\n clearAfterChange={clearAfterChange}\r\n {...restInputProps}\r\n />\r\n {createElement(as, {\r\n disabled: disabled || _disabled,\r\n onClick,\r\n onDrop,\r\n onDragOver,\r\n ...rest,\r\n })}\r\n </Fragment>\r\n )\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAuI;AACvI,uBAA8I;AAgBvI,SAAS,gBACZ,OACF;AACE,QAAM;AAAA,IACF,KAAK;AAAA,IACL,SAAS;AAAA,IACT,aAAa,CAAC;AAAA,IACd;AAAA,IACA,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,IACV,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACP,IAAI;AAEJ,QAAM,EAAE,OAAO,UAAU,YAAY,GAAG,eAAe,IAAI;AAC3D,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,KAAK;AAC9C,QAAM,YAAQ,qBAAyB,IAAI;AAE3C,WAAS,QAAQ,GAAkD;AAC/D,UAAM,SAAS,MAAM;AACrB,eAAW,CAAQ;AAAA,EACvB;AAEA,iBAAe,OAAO,GAAgC;AAClD,cAAU,CAAQ;AAClB,QAAI,YAAY,CAAC;AAAU;AAC3B,MAAE,eAAe;AACjB,UAAM,EAAE,MAAM,IAAI,EAAE;AACpB,QAAI,CAAC,SAAS,MAAM,WAAW;AAAG;AAClC,gBAAY,IAAI;AAChB,QAAI;AACA,UAAI,UAAU;AACV,cAAM,SAAiB,MAAM,KAAK,KAAK;AACvC,cAAM,SAAuC,CAAC;AAC9C,mBAAW,QAAQ,QAAQ;AACvB,gBAAM,QAAS,UAAM,8BAAY,MAAM,IAAI;AAC3C,iBAAO,KAAK,KAAK;AAAA,QACrB;AACA,uBAAe,MAA4B;AAC3C,wBAAgB,MAAmC;AAAA,MACvD,OAAO;AACH,cAAM,OAAO,MAAM,CAAC;AACpB,uBAAe,IAA0B;AACzC,wBAAiB,UAAM,8BAAY,MAAM,IAAI,CAA+B;AAAA,MAChF;AAAA,IACJ,UAAE;AACE,kBAAY,KAAK;AAAA,IACrB;AAAA,EACJ;AAEA,WAAS,WAAW,GAAgC;AAChD,kBAAc,CAAQ;AACtB,QAAI,YAAY,CAAC;AAAU;AAC3B,MAAE,eAAe;AAAA,EACrB;AAEA,SACI,oCAAC,6BACG;AAAA,IAAC;AAAA;AAAA,MACG,UAAU,YAAY,aAAa;AAAA,MACnC,OAAO,EAAE,SAAS,QAAQ,GAAG,MAAM;AAAA,MACnC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACC,GAAG;AAAA;AAAA,EACR,OACC,4BAAc,IAAI;AAAA,IACf,UAAU,YAAY;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACP,CAAC,CACL;AAER;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,7 +2,8 @@ import { ComponentProps, JSX } from "react";
|
|
|
2
2
|
import { InputFileBaseProps, InputFileDataType, InputFileExtraProps } from "./InputFile";
|
|
3
3
|
export type InputFileButtonProps<Multiple extends boolean = false, Type extends InputFileDataType = "file", AS extends keyof JSX.IntrinsicElements = "button"> = Omit<ComponentProps<AS>, "type" | "disabled"> & InputFileExtraProps<Multiple, Type> & {
|
|
4
4
|
disabled?: boolean;
|
|
5
|
-
inputProps?: InputFileBaseProps
|
|
5
|
+
inputProps?: Omit<InputFileBaseProps, "accept">;
|
|
6
|
+
accept?: string;
|
|
6
7
|
dragFile?: boolean;
|
|
7
8
|
as?: AS;
|
|
8
9
|
};
|
|
@@ -10,6 +10,7 @@ export function InputFileButton(props) {
|
|
|
10
10
|
as = "button",
|
|
11
11
|
onClick: _onClick,
|
|
12
12
|
inputProps = {},
|
|
13
|
+
accept,
|
|
13
14
|
onDrop: _onDrop,
|
|
14
15
|
onDragOver: _onDragOver,
|
|
15
16
|
dragFile,
|
|
@@ -73,6 +74,7 @@ export function InputFileButton(props) {
|
|
|
73
74
|
...style
|
|
74
75
|
},
|
|
75
76
|
multiple: multiple,
|
|
77
|
+
accept: accept,
|
|
76
78
|
type: type,
|
|
77
79
|
onValueChange: onValueChange,
|
|
78
80
|
onFileChange: onFileChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createElement","Fragment","useRef","useState","getFileData","InputFile","jsx","_jsx","jsxs","_jsxs","InputFileButton","props","as","onClick","_onClick","inputProps","onDrop","_onDrop","onDragOver","_onDragOver","dragFile","disabled","_disabled","type","multiple","onValueChange","onFileChange","clearAfterChange","rest","style","__disabled","restInputProps","setDisabled","input","e","current","click","preventDefault","files","dataTransfer","length","files2","Array","from","values","file","value","push","children","display"],"sources":["../../../src/components/InputFileButton.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport { ComponentProps, ComponentRef, createElement, DragEvent, Fragment, JSX, MouseEvent as ReactMouseEvent, useRef, useState } from \"react\"\r\nimport { FileType, getFileData, InputFile, InputFileBaseProps, InputFileDataType, InputFileDataTypeMap, InputFileExtraProps, ValueType } from \"./InputFile\"\r\n\r\nexport type InputFileButtonProps<\r\n Multiple extends boolean = false,\r\n Type extends InputFileDataType = \"file\",\r\n AS extends keyof JSX.IntrinsicElements = \"button\",\r\n> = Omit<ComponentProps<AS>, \"type\" | \"disabled\"> &\r\n InputFileExtraProps<Multiple, Type> & {\r\n disabled?: boolean\r\n inputProps?: InputFileBaseProps\r\n dragFile?: boolean\r\n as?: AS\r\n }\r\n\r\n/** 专用于读取文件的 button 组件 */\r\nexport function InputFileButton<Multiple extends boolean = false, Type extends InputFileDataType = \"file\", AS extends keyof JSX.IntrinsicElements = \"button\">(\r\n props: InputFileButtonProps<Multiple, Type, AS>,\r\n) {\r\n const {\r\n as = \"button\",\r\n onClick: _onClick,\r\n inputProps = {},\r\n onDrop: _onDrop,\r\n onDragOver: _onDragOver,\r\n dragFile,\r\n disabled: _disabled,\r\n type = \"file\",\r\n multiple,\r\n onValueChange,\r\n onFileChange,\r\n clearAfterChange,\r\n ...rest\r\n } = props\r\n\r\n const { style, disabled: __disabled, ...restInputProps } = inputProps\r\n const [disabled, setDisabled] = useState(false)\r\n const input = useRef<HTMLInputElement>(null)\r\n\r\n function onClick(e: ReactMouseEvent<ComponentRef<AS>, MouseEvent>) {\r\n input.current?.click()\r\n _onClick?.(e as any)\r\n }\r\n\r\n async function onDrop(e: DragEvent<ComponentRef<AS>>) {\r\n _onDrop?.(e as any)\r\n if (disabled || !dragFile) return\r\n e.preventDefault()\r\n const { files } = e.dataTransfer\r\n if (!files || files.length === 0) return\r\n setDisabled(true)\r\n try {\r\n if (multiple) {\r\n const files2: File[] = Array.from(files)\r\n const values: InputFileDataTypeMap[Type][] = []\r\n for (const file of files2) {\r\n const value = (await getFileData(file, type)) as InputFileDataTypeMap[Type]\r\n values.push(value)\r\n }\r\n onFileChange?.(files2 as FileType<Multiple>)\r\n onValueChange?.(values as ValueType<Multiple, Type>)\r\n } else {\r\n const file = files[0]\r\n onFileChange?.(file as FileType<Multiple>)\r\n onValueChange?.((await getFileData(file, type)) as ValueType<Multiple, Type>)\r\n }\r\n } finally {\r\n setDisabled(false)\r\n }\r\n }\r\n\r\n function onDragOver(e: DragEvent<ComponentRef<AS>>) {\r\n _onDragOver?.(e as any)\r\n if (disabled || !dragFile) return\r\n e.preventDefault()\r\n }\r\n\r\n return (\r\n <Fragment>\r\n <InputFile<Multiple, Type>\r\n disabled={disabled || _disabled || __disabled}\r\n style={{ display: \"none\", ...style }}\r\n multiple={multiple}\r\n type={type as Type}\r\n onValueChange={onValueChange}\r\n onFileChange={onFileChange}\r\n clearAfterChange={clearAfterChange}\r\n {...restInputProps}\r\n />\r\n {createElement(as, {\r\n disabled: disabled || _disabled,\r\n onClick,\r\n onDrop,\r\n onDragOver,\r\n ...rest,\r\n })}\r\n </Fragment>\r\n )\r\n}\r\n
|
|
1
|
+
{"version":3,"names":["createElement","Fragment","useRef","useState","getFileData","InputFile","jsx","_jsx","jsxs","_jsxs","InputFileButton","props","as","onClick","_onClick","inputProps","accept","onDrop","_onDrop","onDragOver","_onDragOver","dragFile","disabled","_disabled","type","multiple","onValueChange","onFileChange","clearAfterChange","rest","style","__disabled","restInputProps","setDisabled","input","e","current","click","preventDefault","files","dataTransfer","length","files2","Array","from","values","file","value","push","children","display"],"sources":["../../../src/components/InputFileButton.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport { ComponentProps, ComponentRef, createElement, DragEvent, Fragment, JSX, MouseEvent as ReactMouseEvent, useRef, useState } from \"react\"\r\nimport { FileType, getFileData, InputFile, InputFileBaseProps, InputFileDataType, InputFileDataTypeMap, InputFileExtraProps, ValueType } from \"./InputFile\"\r\n\r\nexport type InputFileButtonProps<\r\n Multiple extends boolean = false,\r\n Type extends InputFileDataType = \"file\",\r\n AS extends keyof JSX.IntrinsicElements = \"button\",\r\n> = Omit<ComponentProps<AS>, \"type\" | \"disabled\"> &\r\n InputFileExtraProps<Multiple, Type> & {\r\n disabled?: boolean\r\n inputProps?: Omit<InputFileBaseProps, \"accept\">\r\n accept?: string\r\n dragFile?: boolean\r\n as?: AS\r\n }\r\n\r\n/** 专用于读取文件的 button 组件 */\r\nexport function InputFileButton<Multiple extends boolean = false, Type extends InputFileDataType = \"file\", AS extends keyof JSX.IntrinsicElements = \"button\">(\r\n props: InputFileButtonProps<Multiple, Type, AS>,\r\n) {\r\n const {\r\n as = \"button\",\r\n onClick: _onClick,\r\n inputProps = {},\r\n accept,\r\n onDrop: _onDrop,\r\n onDragOver: _onDragOver,\r\n dragFile,\r\n disabled: _disabled,\r\n type = \"file\",\r\n multiple,\r\n onValueChange,\r\n onFileChange,\r\n clearAfterChange,\r\n ...rest\r\n } = props\r\n\r\n const { style, disabled: __disabled, ...restInputProps } = inputProps\r\n const [disabled, setDisabled] = useState(false)\r\n const input = useRef<HTMLInputElement>(null)\r\n\r\n function onClick(e: ReactMouseEvent<ComponentRef<AS>, MouseEvent>) {\r\n input.current?.click()\r\n _onClick?.(e as any)\r\n }\r\n\r\n async function onDrop(e: DragEvent<ComponentRef<AS>>) {\r\n _onDrop?.(e as any)\r\n if (disabled || !dragFile) return\r\n e.preventDefault()\r\n const { files } = e.dataTransfer\r\n if (!files || files.length === 0) return\r\n setDisabled(true)\r\n try {\r\n if (multiple) {\r\n const files2: File[] = Array.from(files)\r\n const values: InputFileDataTypeMap[Type][] = []\r\n for (const file of files2) {\r\n const value = (await getFileData(file, type)) as InputFileDataTypeMap[Type]\r\n values.push(value)\r\n }\r\n onFileChange?.(files2 as FileType<Multiple>)\r\n onValueChange?.(values as ValueType<Multiple, Type>)\r\n } else {\r\n const file = files[0]\r\n onFileChange?.(file as FileType<Multiple>)\r\n onValueChange?.((await getFileData(file, type)) as ValueType<Multiple, Type>)\r\n }\r\n } finally {\r\n setDisabled(false)\r\n }\r\n }\r\n\r\n function onDragOver(e: DragEvent<ComponentRef<AS>>) {\r\n _onDragOver?.(e as any)\r\n if (disabled || !dragFile) return\r\n e.preventDefault()\r\n }\r\n\r\n return (\r\n <Fragment>\r\n <InputFile<Multiple, Type>\r\n disabled={disabled || _disabled || __disabled}\r\n style={{ display: \"none\", ...style }}\r\n multiple={multiple}\r\n accept={accept}\r\n type={type as Type}\r\n onValueChange={onValueChange}\r\n onFileChange={onFileChange}\r\n clearAfterChange={clearAfterChange}\r\n {...restInputProps}\r\n />\r\n {createElement(as, {\r\n disabled: disabled || _disabled,\r\n onClick,\r\n onDrop,\r\n onDragOver,\r\n ...rest,\r\n })}\r\n </Fragment>\r\n )\r\n}\r\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAuCA,aAAa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AAS;MAC/BV,OAAO;MACPI,MAAM;MACNE,UAAU;MACV,GAAGU;IACP,CAAC,CAAC;EAAA,CACI,CAAC;AAEnB"}
|
package/package.json
CHANGED
|
@@ -10,7 +10,8 @@ export type InputFileButtonProps<
|
|
|
10
10
|
> = Omit<ComponentProps<AS>, "type" | "disabled"> &
|
|
11
11
|
InputFileExtraProps<Multiple, Type> & {
|
|
12
12
|
disabled?: boolean
|
|
13
|
-
inputProps?: InputFileBaseProps
|
|
13
|
+
inputProps?: Omit<InputFileBaseProps, "accept">
|
|
14
|
+
accept?: string
|
|
14
15
|
dragFile?: boolean
|
|
15
16
|
as?: AS
|
|
16
17
|
}
|
|
@@ -23,6 +24,7 @@ export function InputFileButton<Multiple extends boolean = false, Type extends I
|
|
|
23
24
|
as = "button",
|
|
24
25
|
onClick: _onClick,
|
|
25
26
|
inputProps = {},
|
|
27
|
+
accept,
|
|
26
28
|
onDrop: _onDrop,
|
|
27
29
|
onDragOver: _onDragOver,
|
|
28
30
|
dragFile,
|
|
@@ -83,6 +85,7 @@ export function InputFileButton<Multiple extends boolean = false, Type extends I
|
|
|
83
85
|
disabled={disabled || _disabled || __disabled}
|
|
84
86
|
style={{ display: "none", ...style }}
|
|
85
87
|
multiple={multiple}
|
|
88
|
+
accept={accept}
|
|
86
89
|
type={type as Type}
|
|
87
90
|
onValueChange={onValueChange}
|
|
88
91
|
onFileChange={onFileChange}
|
|
@@ -99,4 +102,3 @@ export function InputFileButton<Multiple extends boolean = false, Type extends I
|
|
|
99
102
|
</Fragment>
|
|
100
103
|
)
|
|
101
104
|
}
|
|
102
|
-
|