@danske/sapphire-react-lab 0.87.5 → 0.87.6

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.
@@ -34,7 +34,13 @@ var __objRest = (source, exclude) => {
34
34
  return target;
35
35
  };
36
36
  const HiddenFileInput = React.forwardRef(function InputWrapper(props, ref) {
37
+ const { onChange } = props;
38
+ const onFileInputChange = (inputElement) => {
39
+ onChange == null ? void 0 : onChange(inputElement);
40
+ inputElement.target.value = "";
41
+ };
37
42
  return /* @__PURE__ */ React.createElement("input", __spreadProps(__spreadValues({}, props), {
43
+ onChange: onFileInputChange,
38
44
  ref,
39
45
  type: "file",
40
46
  style: { display: "none" }
@@ -1 +1 @@
1
- {"version":3,"file":"FileTrigger.js","sources":["../../../../src/FileDropzone/src/FileTrigger.tsx"],"sourcesContent":["import React, { ForwardedRef } from 'react';\nimport { filterDOMProps, useObjectRef } from '@react-aria/utils';\nimport { PressResponder } from '@react-aria/interactions';\n\nexport interface FileSelectProps {\n /**\n * List of file types that are allowed to be selected using the file select.\n * When no list is passed, all file types will be allowed to be selected.\n * @default \"\"\n */\n acceptedFileTypes?: string[];\n /**\n * Whether multiple files are allowed to be selected using the file select.\n * @default \"false\"\n */\n allowsMultiple?: boolean;\n}\n\nexport interface FileTriggerProps extends FileSelectProps {\n /**\n * Callback for file selection.\n * @param files - the list of selected files\n * @default \"() => null\"\n */\n onSelect?: (files: FileList | null) => void;\n isDisabled?: boolean;\n children?: React.ReactNode;\n}\n\nconst HiddenFileInput = React.forwardRef(function InputWrapper(\n props: React.HTMLProps<HTMLInputElement>,\n ref: ForwardedRef<HTMLInputElement>\n) {\n return <input {...props} ref={ref} type=\"file\" style={{ display: 'none' }} />;\n});\n\nexport const FileTrigger = React.forwardRef(function FileTriggerWrapper(\n props: FileTriggerProps,\n ref: ForwardedRef<HTMLInputElement>\n) {\n const {\n acceptedFileTypes,\n allowsMultiple = false,\n onSelect = () => null,\n children,\n isDisabled = false,\n ...rest\n } = props;\n const inputRef = useObjectRef(ref);\n const domProps = filterDOMProps(rest);\n\n return (\n <>\n <PressResponder\n onPress={() => {\n inputRef.current?.click();\n }}\n >\n {children}\n </PressResponder>\n <HiddenFileInput\n {...domProps}\n disabled={isDisabled}\n ref={inputRef}\n accept={acceptedFileTypes?.toString()}\n onChange={(e) => onSelect?.((e.target as HTMLInputElement).files)}\n multiple={allowsMultiple}\n />\n </>\n );\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,eAAkB,GAAA,KAAA,CAAM,UAAW,CAAA,SAAA,YAAA,CACvC,OACA,GACA,EAAA;AACA,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,OAAD,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EAAW,KAAX,CAAA,EAAA;AAAA,IAAkB,GAAA;AAAA,IAAU,IAAK,EAAA,MAAA;AAAA,IAAO,KAAA,EAAO,EAAE,OAAS,EAAA,MAAA,EAAA;AAAA,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA;AAG5D,MAAM,WAAc,GAAA,KAAA,CAAM,UAAW,CAAA,SAAA,kBAAA,CAC1C,OACA,GACA,EAAA;AACA,EAAA,MAOI,EANF,GAAA,KAAA,EAAA;AAAA,IAAA,iBAAA;AAAA,IACA,cAAiB,GAAA,KAAA;AAAA,IACjB,WAAW,MAAM,IAAA;AAAA,IACjB,QAAA;AAAA,IACA,UAAa,GAAA,KAAA;AAAA,GAEX,GAAA,EAAA,EADC,iBACD,EADC,EAAA;AAAA,IALH,mBAAA;AAAA,IACA,gBAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,YAAA;AAAA,GAAA,CAAA,CAAA;AAGF,EAAA,MAAM,WAAW,YAAa,CAAA,GAAA,CAAA,CAAA;AAC9B,EAAA,MAAM,WAAW,cAAe,CAAA,IAAA,CAAA,CAAA;AAEhC,EACE,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,sCACG,cAAD,EAAA;AAAA,IACE,SAAS,MAAM;AAtDvB,MAAA,IAAA,GAAA,CAAA;AAuDU,MAAA,CAAA,GAAA,GAAA,QAAA,CAAS,YAAT,IAAkB,GAAA,KAAA,CAAA,GAAA,GAAA,CAAA,KAAA,EAAA,CAAA;AAAA,KAAA;AAAA,GAAA,EAGnB,QAEH,CAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,eAAD,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACM,QADN,CAAA,EAAA;AAAA,IAEE,QAAU,EAAA,UAAA;AAAA,IACV,GAAK,EAAA,QAAA;AAAA,IACL,QAAQ,iBAAmB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,iBAAA,CAAA,QAAA,EAAA;AAAA,IAC3B,QAAU,EAAA,CAAC,CAAM,KAAA,QAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAY,EAAE,MAA4B,CAAA,KAAA,CAAA;AAAA,IAC3D,QAAU,EAAA,cAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
1
+ {"version":3,"file":"FileTrigger.js","sources":["../../../../src/FileDropzone/src/FileTrigger.tsx"],"sourcesContent":["import React, { ChangeEvent, ForwardedRef } from 'react';\nimport { filterDOMProps, useObjectRef } from '@react-aria/utils';\nimport { PressResponder } from '@react-aria/interactions';\n\nexport interface FileSelectProps {\n /**\n * List of file types that are allowed to be selected using the file select.\n * When no list is passed, all file types will be allowed to be selected.\n * @default \"\"\n */\n acceptedFileTypes?: string[];\n /**\n * Whether multiple files are allowed to be selected using the file select.\n * @default \"false\"\n */\n allowsMultiple?: boolean;\n}\n\nexport interface FileTriggerProps extends FileSelectProps {\n /**\n * Callback for file selection.\n * @param files - the list of selected files\n * @default \"() => null\"\n */\n onSelect?: (files: FileList | null) => void;\n isDisabled?: boolean;\n children?: React.ReactNode;\n}\n\nconst HiddenFileInput = React.forwardRef(function InputWrapper(\n props: React.HTMLProps<HTMLInputElement>,\n ref: ForwardedRef<HTMLInputElement>\n) {\n const { onChange } = props;\n\n /**\n * This is a \"hacky\" fix for the native input, because it does not trigger a change if the same content is selected in the file picker.\n */\n const onFileInputChange = (inputElement: ChangeEvent<HTMLInputElement>) => {\n onChange?.(inputElement);\n inputElement.target.value = '';\n };\n\n return (\n <input\n {...props}\n onChange={onFileInputChange}\n ref={ref}\n type=\"file\"\n style={{ display: 'none' }}\n />\n );\n});\n\nexport const FileTrigger = React.forwardRef(function FileTriggerWrapper(\n props: FileTriggerProps,\n ref: ForwardedRef<HTMLInputElement>\n) {\n const {\n acceptedFileTypes,\n allowsMultiple = false,\n onSelect = () => null,\n children,\n isDisabled = false,\n ...rest\n } = props;\n const inputRef = useObjectRef(ref);\n const domProps = filterDOMProps(rest);\n\n return (\n <>\n <PressResponder\n onPress={() => {\n inputRef.current?.click();\n }}\n >\n {children}\n </PressResponder>\n <HiddenFileInput\n {...domProps}\n disabled={isDisabled}\n ref={inputRef}\n accept={acceptedFileTypes?.toString()}\n onChange={(e) => onSelect?.((e.target as HTMLInputElement).files)}\n multiple={allowsMultiple}\n />\n </>\n );\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,eAAkB,GAAA,KAAA,CAAM,UAAW,CAAA,SAAA,YAAA,CACvC,OACA,GACA,EAAA;AACA,EAAA,MAAM,EAAE,QAAa,EAAA,GAAA,KAAA,CAAA;AAKrB,EAAM,MAAA,iBAAA,GAAoB,CAAC,YAAgD,KAAA;AACzE,IAAW,QAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAA,YAAA,CAAA,CAAA;AACX,IAAA,YAAA,CAAa,OAAO,KAAQ,GAAA,EAAA,CAAA;AAAA,GAAA,CAAA;AAG9B,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,OAAD,EAAA,aAAA,CAAA,cAAA,CAAA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AA,CAAA,GAAA,iBAAA,CAAA,QAAA,EAAA;AAAA,IAC3B,QAAU,EAAA,CAAC,CAAM,KAAA,QAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAY,EAAE,MAA4B,CAAA,KAAA,CAAA;AAAA,IAC3D,QAAU,EAAA,cAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danske/sapphire-react-lab",
3
- "version": "0.87.5",
3
+ "version": "0.87.6",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "Experimental React components of the Sapphire Design System from Danske Bank A/S",
6
6
  "exports": {
@@ -74,5 +74,5 @@
74
74
  "clsx": "^1.1.1",
75
75
  "react-transition-group": "^4.4.5"
76
76
  },
77
- "gitHead": "f697803e6f03705b063ff5d4c89debde608208db"
77
+ "gitHead": "bb1beabd5c10b8c2bfc4cfc769cdc27c93df9712"
78
78
  }