@navikt/ds-react 6.2.0 → 6.3.0

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.
Files changed (271) hide show
  1. package/cjs/form/combobox/ComboboxProvider.js +5 -1
  2. package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
  3. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +14 -12
  4. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  5. package/cjs/form/combobox/FilteredOptions/filtered-options-util.d.ts +3 -3
  6. package/cjs/form/combobox/FilteredOptions/filtered-options-util.js +1 -3
  7. package/cjs/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
  8. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +8 -5
  9. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +8 -13
  10. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  11. package/cjs/form/combobox/Input/Input.js +9 -7
  12. package/cjs/form/combobox/Input/Input.js.map +1 -1
  13. package/cjs/form/combobox/SelectedOptions/SelectedOptions.d.ts +2 -1
  14. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +3 -3
  15. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  16. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +10 -7
  17. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +6 -8
  18. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  19. package/cjs/form/combobox/combobox-utils.d.ts +10 -0
  20. package/cjs/form/combobox/combobox-utils.js +27 -0
  21. package/cjs/form/combobox/combobox-utils.js.map +1 -0
  22. package/cjs/form/combobox/customOptionsContext.d.ts +5 -4
  23. package/cjs/form/combobox/customOptionsContext.js +1 -1
  24. package/cjs/form/combobox/customOptionsContext.js.map +1 -1
  25. package/cjs/form/combobox/types.d.ts +22 -11
  26. package/cjs/form/file-upload/FileUpload.context.d.ts +8 -0
  27. package/cjs/form/file-upload/FileUpload.context.js +7 -0
  28. package/cjs/form/file-upload/FileUpload.context.js.map +1 -0
  29. package/cjs/form/file-upload/FileUpload.d.ts +118 -0
  30. package/cjs/form/file-upload/FileUpload.js +73 -0
  31. package/cjs/form/file-upload/FileUpload.js.map +1 -0
  32. package/cjs/form/file-upload/FileUpload.types.d.ts +55 -0
  33. package/cjs/form/file-upload/FileUpload.types.js +8 -0
  34. package/cjs/form/file-upload/FileUpload.types.js.map +1 -0
  35. package/cjs/form/file-upload/i18n/get.d.ts +2 -0
  36. package/cjs/form/file-upload/i18n/get.js +38 -0
  37. package/cjs/form/file-upload/i18n/get.js.map +1 -0
  38. package/cjs/form/file-upload/i18n/i18n.context.d.ts +11 -0
  39. package/cjs/form/file-upload/i18n/i18n.context.js +39 -0
  40. package/cjs/form/file-upload/i18n/i18n.context.js.map +1 -0
  41. package/cjs/form/file-upload/i18n/i18n.types.d.ts +13 -0
  42. package/cjs/form/file-upload/i18n/i18n.types.js +3 -0
  43. package/cjs/form/file-upload/i18n/i18n.types.js.map +1 -0
  44. package/cjs/form/file-upload/i18n/locales/nb.json +20 -0
  45. package/cjs/form/file-upload/i18n/merge.d.ts +2 -0
  46. package/cjs/form/file-upload/i18n/merge.js +29 -0
  47. package/cjs/form/file-upload/i18n/merge.js.map +1 -0
  48. package/cjs/form/file-upload/index.d.ts +7 -0
  49. package/cjs/form/file-upload/index.js +16 -0
  50. package/cjs/form/file-upload/index.js.map +1 -0
  51. package/cjs/form/file-upload/parts/Trigger.d.ts +7 -0
  52. package/cjs/form/file-upload/parts/Trigger.js +43 -0
  53. package/cjs/form/file-upload/parts/Trigger.js.map +1 -0
  54. package/cjs/form/file-upload/parts/dropzone/Dropzone.d.ts +4 -0
  55. package/cjs/form/file-upload/parts/dropzone/Dropzone.js +106 -0
  56. package/cjs/form/file-upload/parts/dropzone/Dropzone.js.map +1 -0
  57. package/cjs/form/file-upload/parts/dropzone/dropzone.types.d.ts +18 -0
  58. package/cjs/form/file-upload/parts/dropzone/dropzone.types.js +3 -0
  59. package/cjs/form/file-upload/parts/dropzone/dropzone.types.js.map +1 -0
  60. package/cjs/form/file-upload/parts/dropzone/useDropzone.d.ts +13 -0
  61. package/cjs/form/file-upload/parts/dropzone/useDropzone.js +34 -0
  62. package/cjs/form/file-upload/parts/dropzone/useDropzone.js.map +1 -0
  63. package/cjs/form/file-upload/parts/item/Item.d.ts +55 -0
  64. package/cjs/form/file-upload/parts/item/Item.js +79 -0
  65. package/cjs/form/file-upload/parts/item/Item.js.map +1 -0
  66. package/cjs/form/file-upload/parts/item/Item.types.d.ts +5 -0
  67. package/cjs/form/file-upload/parts/item/Item.types.js +3 -0
  68. package/cjs/form/file-upload/parts/item/Item.types.js.map +1 -0
  69. package/cjs/form/file-upload/parts/item/ItemButton.d.ts +12 -0
  70. package/cjs/form/file-upload/parts/item/ItemButton.js +22 -0
  71. package/cjs/form/file-upload/parts/item/ItemButton.js.map +1 -0
  72. package/cjs/form/file-upload/parts/item/ItemIcon.d.ts +9 -0
  73. package/cjs/form/file-upload/parts/item/ItemIcon.js +51 -0
  74. package/cjs/form/file-upload/parts/item/ItemIcon.js.map +1 -0
  75. package/cjs/form/file-upload/parts/item/ItemName.d.ts +9 -0
  76. package/cjs/form/file-upload/parts/item/ItemName.js +32 -0
  77. package/cjs/form/file-upload/parts/item/ItemName.js.map +1 -0
  78. package/cjs/form/file-upload/parts/item/utils/download-file.d.ts +1 -0
  79. package/cjs/form/file-upload/parts/item/utils/download-file.js +13 -0
  80. package/cjs/form/file-upload/parts/item/utils/download-file.js.map +1 -0
  81. package/cjs/form/file-upload/parts/item/utils/file-type-checker.d.ts +2 -0
  82. package/cjs/form/file-upload/parts/item/utils/file-type-checker.js +6 -0
  83. package/cjs/form/file-upload/parts/item/utils/file-type-checker.js.map +1 -0
  84. package/cjs/form/file-upload/parts/item/utils/format-file-size.d.ts +2 -0
  85. package/cjs/form/file-upload/parts/item/utils/format-file-size.js +24 -0
  86. package/cjs/form/file-upload/parts/item/utils/format-file-size.js.map +1 -0
  87. package/cjs/form/file-upload/useFileUpload.d.ts +12 -0
  88. package/cjs/form/file-upload/useFileUpload.js +33 -0
  89. package/cjs/form/file-upload/useFileUpload.js.map +1 -0
  90. package/cjs/form/file-upload/utils/is-accepted-file-type.d.ts +1 -0
  91. package/cjs/form/file-upload/utils/is-accepted-file-type.js +26 -0
  92. package/cjs/form/file-upload/utils/is-accepted-file-type.js.map +1 -0
  93. package/cjs/form/file-upload/utils/is-accepted-size.d.ts +1 -0
  94. package/cjs/form/file-upload/utils/is-accepted-size.js +11 -0
  95. package/cjs/form/file-upload/utils/is-accepted-size.js.map +1 -0
  96. package/cjs/form/file-upload/utils/validate-files.d.ts +8 -0
  97. package/cjs/form/file-upload/utils/validate-files.js +48 -0
  98. package/cjs/form/file-upload/utils/validate-files.js.map +1 -0
  99. package/cjs/index.d.ts +1 -0
  100. package/cjs/index.js +3 -1
  101. package/cjs/index.js.map +1 -1
  102. package/cjs/loader/Loader.d.ts +0 -7
  103. package/cjs/loader/Loader.js.map +1 -1
  104. package/cjs/table/DataCell.d.ts +1 -3
  105. package/cjs/table/DataCell.js.map +1 -1
  106. package/cjs/util/create-context.d.ts +1 -0
  107. package/cjs/util/create-context.js.map +1 -1
  108. package/cjs/util/hooks/useEventListener.d.ts +1 -1
  109. package/cjs/util/hooks/useMergeRefs.d.ts +1 -1
  110. package/esm/form/combobox/ComboboxProvider.js +5 -1
  111. package/esm/form/combobox/ComboboxProvider.js.map +1 -1
  112. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +14 -12
  113. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  114. package/esm/form/combobox/FilteredOptions/filtered-options-util.d.ts +3 -3
  115. package/esm/form/combobox/FilteredOptions/filtered-options-util.js +1 -3
  116. package/esm/form/combobox/FilteredOptions/filtered-options-util.js.map +1 -1
  117. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +8 -5
  118. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +8 -13
  119. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  120. package/esm/form/combobox/Input/Input.js +9 -7
  121. package/esm/form/combobox/Input/Input.js.map +1 -1
  122. package/esm/form/combobox/SelectedOptions/SelectedOptions.d.ts +2 -1
  123. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +3 -3
  124. package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  125. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +10 -7
  126. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +6 -8
  127. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  128. package/esm/form/combobox/combobox-utils.d.ts +10 -0
  129. package/esm/form/combobox/combobox-utils.js +22 -0
  130. package/esm/form/combobox/combobox-utils.js.map +1 -0
  131. package/esm/form/combobox/customOptionsContext.d.ts +5 -4
  132. package/esm/form/combobox/customOptionsContext.js +1 -1
  133. package/esm/form/combobox/customOptionsContext.js.map +1 -1
  134. package/esm/form/combobox/types.d.ts +22 -11
  135. package/esm/form/file-upload/FileUpload.context.d.ts +8 -0
  136. package/esm/form/file-upload/FileUpload.context.js +3 -0
  137. package/esm/form/file-upload/FileUpload.context.js.map +1 -0
  138. package/esm/form/file-upload/FileUpload.d.ts +118 -0
  139. package/esm/form/file-upload/FileUpload.js +44 -0
  140. package/esm/form/file-upload/FileUpload.js.map +1 -0
  141. package/esm/form/file-upload/FileUpload.types.d.ts +55 -0
  142. package/esm/form/file-upload/FileUpload.types.js +5 -0
  143. package/esm/form/file-upload/FileUpload.types.js.map +1 -0
  144. package/esm/form/file-upload/i18n/get.d.ts +2 -0
  145. package/esm/form/file-upload/i18n/get.js +34 -0
  146. package/esm/form/file-upload/i18n/get.js.map +1 -0
  147. package/esm/form/file-upload/i18n/i18n.context.d.ts +11 -0
  148. package/esm/form/file-upload/i18n/i18n.context.js +32 -0
  149. package/esm/form/file-upload/i18n/i18n.context.js.map +1 -0
  150. package/esm/form/file-upload/i18n/i18n.types.d.ts +13 -0
  151. package/esm/form/file-upload/i18n/i18n.types.js +2 -0
  152. package/esm/form/file-upload/i18n/i18n.types.js.map +1 -0
  153. package/esm/form/file-upload/i18n/locales/nb.json +20 -0
  154. package/esm/form/file-upload/i18n/merge.d.ts +2 -0
  155. package/esm/form/file-upload/i18n/merge.js +25 -0
  156. package/esm/form/file-upload/i18n/merge.js.map +1 -0
  157. package/esm/form/file-upload/index.d.ts +7 -0
  158. package/esm/form/file-upload/index.js +6 -0
  159. package/esm/form/file-upload/index.js.map +1 -0
  160. package/esm/form/file-upload/parts/Trigger.d.ts +7 -0
  161. package/esm/form/file-upload/parts/Trigger.js +18 -0
  162. package/esm/form/file-upload/parts/Trigger.js.map +1 -0
  163. package/esm/form/file-upload/parts/dropzone/Dropzone.d.ts +4 -0
  164. package/esm/form/file-upload/parts/dropzone/Dropzone.js +78 -0
  165. package/esm/form/file-upload/parts/dropzone/Dropzone.js.map +1 -0
  166. package/esm/form/file-upload/parts/dropzone/dropzone.types.d.ts +18 -0
  167. package/esm/form/file-upload/parts/dropzone/dropzone.types.js +2 -0
  168. package/esm/form/file-upload/parts/dropzone/dropzone.types.js.map +1 -0
  169. package/esm/form/file-upload/parts/dropzone/useDropzone.d.ts +13 -0
  170. package/esm/form/file-upload/parts/dropzone/useDropzone.js +30 -0
  171. package/esm/form/file-upload/parts/dropzone/useDropzone.js.map +1 -0
  172. package/esm/form/file-upload/parts/item/Item.d.ts +55 -0
  173. package/esm/form/file-upload/parts/item/Item.js +50 -0
  174. package/esm/form/file-upload/parts/item/Item.js.map +1 -0
  175. package/esm/form/file-upload/parts/item/Item.types.d.ts +5 -0
  176. package/esm/form/file-upload/parts/item/Item.types.js +2 -0
  177. package/esm/form/file-upload/parts/item/Item.types.js.map +1 -0
  178. package/esm/form/file-upload/parts/item/ItemButton.d.ts +12 -0
  179. package/esm/form/file-upload/parts/item/ItemButton.js +17 -0
  180. package/esm/form/file-upload/parts/item/ItemButton.js.map +1 -0
  181. package/esm/form/file-upload/parts/item/ItemIcon.d.ts +9 -0
  182. package/esm/form/file-upload/parts/item/ItemIcon.js +46 -0
  183. package/esm/form/file-upload/parts/item/ItemIcon.js.map +1 -0
  184. package/esm/form/file-upload/parts/item/ItemName.d.ts +9 -0
  185. package/esm/form/file-upload/parts/item/ItemName.js +27 -0
  186. package/esm/form/file-upload/parts/item/ItemName.js.map +1 -0
  187. package/esm/form/file-upload/parts/item/utils/download-file.d.ts +1 -0
  188. package/esm/form/file-upload/parts/item/utils/download-file.js +9 -0
  189. package/esm/form/file-upload/parts/item/utils/download-file.js.map +1 -0
  190. package/esm/form/file-upload/parts/item/utils/file-type-checker.d.ts +2 -0
  191. package/esm/form/file-upload/parts/item/utils/file-type-checker.js +2 -0
  192. package/esm/form/file-upload/parts/item/utils/file-type-checker.js.map +1 -0
  193. package/esm/form/file-upload/parts/item/utils/format-file-size.d.ts +2 -0
  194. package/esm/form/file-upload/parts/item/utils/format-file-size.js +20 -0
  195. package/esm/form/file-upload/parts/item/utils/format-file-size.js.map +1 -0
  196. package/esm/form/file-upload/useFileUpload.d.ts +12 -0
  197. package/esm/form/file-upload/useFileUpload.js +29 -0
  198. package/esm/form/file-upload/useFileUpload.js.map +1 -0
  199. package/esm/form/file-upload/utils/is-accepted-file-type.d.ts +1 -0
  200. package/esm/form/file-upload/utils/is-accepted-file-type.js +22 -0
  201. package/esm/form/file-upload/utils/is-accepted-file-type.js.map +1 -0
  202. package/esm/form/file-upload/utils/is-accepted-size.d.ts +1 -0
  203. package/esm/form/file-upload/utils/is-accepted-size.js +7 -0
  204. package/esm/form/file-upload/utils/is-accepted-size.js.map +1 -0
  205. package/esm/form/file-upload/utils/validate-files.d.ts +8 -0
  206. package/esm/form/file-upload/utils/validate-files.js +44 -0
  207. package/esm/form/file-upload/utils/validate-files.js.map +1 -0
  208. package/esm/index.d.ts +1 -0
  209. package/esm/index.js +1 -0
  210. package/esm/index.js.map +1 -1
  211. package/esm/loader/Loader.d.ts +0 -7
  212. package/esm/loader/Loader.js.map +1 -1
  213. package/esm/table/DataCell.d.ts +1 -3
  214. package/esm/table/DataCell.js.map +1 -1
  215. package/esm/util/create-context.d.ts +1 -0
  216. package/esm/util/create-context.js.map +1 -1
  217. package/esm/util/hooks/useEventListener.d.ts +1 -1
  218. package/esm/util/hooks/useMergeRefs.d.ts +1 -1
  219. package/package.json +13 -3
  220. package/src/form/combobox/ComboboxProvider.tsx +7 -3
  221. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +22 -15
  222. package/src/form/combobox/FilteredOptions/filtered-options-util.ts +5 -10
  223. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +19 -29
  224. package/src/form/combobox/Input/Input.tsx +14 -8
  225. package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +8 -5
  226. package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +24 -25
  227. package/src/form/combobox/combobox-utils.test.ts +67 -0
  228. package/src/form/combobox/combobox-utils.ts +32 -0
  229. package/src/form/combobox/combobox.stories.tsx +67 -32
  230. package/src/form/combobox/combobox.test.tsx +32 -1
  231. package/src/form/combobox/customOptionsContext.tsx +9 -8
  232. package/src/form/combobox/types.ts +23 -11
  233. package/src/form/file-upload/FileUpload.context.tsx +9 -0
  234. package/src/form/file-upload/FileUpload.tsx +142 -0
  235. package/src/form/file-upload/FileUpload.types.ts +57 -0
  236. package/src/form/file-upload/file-upload-dropzone.stories.tsx +123 -0
  237. package/src/form/file-upload/file-upload-item.stories.tsx +136 -0
  238. package/src/form/file-upload/file-upload.stories.tsx +236 -0
  239. package/src/form/file-upload/i18n/get.ts +48 -0
  240. package/src/form/file-upload/i18n/i18n.context.test.tsx +92 -0
  241. package/src/form/file-upload/i18n/i18n.context.ts +67 -0
  242. package/src/form/file-upload/i18n/i18n.types.ts +20 -0
  243. package/src/form/file-upload/i18n/locales/nb.json +20 -0
  244. package/src/form/file-upload/i18n/merge.ts +35 -0
  245. package/src/form/file-upload/index.ts +21 -0
  246. package/src/form/file-upload/parts/Trigger.tsx +48 -0
  247. package/src/form/file-upload/parts/dropzone/Dropzone.tsx +180 -0
  248. package/src/form/file-upload/parts/dropzone/dropzone.types.ts +22 -0
  249. package/src/form/file-upload/parts/dropzone/useDropzone.ts +43 -0
  250. package/src/form/file-upload/parts/item/Item.tsx +165 -0
  251. package/src/form/file-upload/parts/item/Item.types.ts +6 -0
  252. package/src/form/file-upload/parts/item/ItemButton.tsx +52 -0
  253. package/src/form/file-upload/parts/item/ItemIcon.tsx +74 -0
  254. package/src/form/file-upload/parts/item/ItemName.tsx +58 -0
  255. package/src/form/file-upload/parts/item/utils/download-file.ts +9 -0
  256. package/src/form/file-upload/parts/item/utils/file-type-checker.ts +4 -0
  257. package/src/form/file-upload/parts/item/utils/format-file-size.test.ts +76 -0
  258. package/src/form/file-upload/parts/item/utils/format-file-size.ts +25 -0
  259. package/src/form/file-upload/useFileUpload.ts +54 -0
  260. package/src/form/file-upload/utils/is-accepted-file-type.test.ts +69 -0
  261. package/src/form/file-upload/utils/is-accepted-file-type.ts +25 -0
  262. package/src/form/file-upload/utils/is-accepted-size.test.ts +26 -0
  263. package/src/form/file-upload/utils/is-accepted-size.ts +7 -0
  264. package/src/form/file-upload/utils/validate-files.test.ts +132 -0
  265. package/src/form/file-upload/utils/validate-files.ts +62 -0
  266. package/src/index.ts +14 -0
  267. package/src/internal-header/header.stories.tsx +8 -5
  268. package/src/loader/Loader.tsx +0 -7
  269. package/src/table/DataCell.tsx +1 -6
  270. package/src/util/create-context.tsx +1 -0
  271. package/src/util/hooks/useMergeRefs.ts +1 -1
@@ -1,5 +1,19 @@
1
1
  import React, { ChangeEvent, InputHTMLAttributes } from "react";
2
2
  import { FormFieldProps } from "../useFormField";
3
+ /**
4
+ * A more complex version of options for the Combobox.
5
+ * Used for separating the label and the value of the option.
6
+ */
7
+ export type ComboboxOption = {
8
+ /**
9
+ * The label to display in the dropdown list
10
+ */
11
+ label: string;
12
+ /**
13
+ * The programmatic value of the option, for use internally. Will be returned from onToggleSelected.
14
+ */
15
+ value: string;
16
+ };
3
17
  export type MaxSelected = {
4
18
  /**
5
19
  * The limit for maximum selected options
@@ -16,9 +30,9 @@ export interface ComboboxProps extends FormFieldProps, Omit<InputHTMLAttributes<
16
30
  */
17
31
  label: React.ReactNode;
18
32
  /**
19
- * List of options to use for autocompletion.
33
+ * List of options
20
34
  */
21
- options: string[];
35
+ options: string[] | ComboboxOption[];
22
36
  /**
23
37
  * If enabled, adds an option to add the value of the input as an option whenever there are no options matching the value.
24
38
  */
@@ -38,7 +52,7 @@ export interface ComboboxProps extends FormFieldProps, Omit<InputHTMLAttributes<
38
52
  * If provided, this overrides the internal search logic in the component.
39
53
  * Useful for e.g. searching on a server or when overriding the search algorithm to search for synonyms or similar.
40
54
  */
41
- filteredOptions?: string[];
55
+ filteredOptions?: string[] | ComboboxOption[];
42
56
  /**
43
57
  * Optionally hide the label visually.
44
58
  * Not recommended, but can be considered for e.g. search fields in the top menu.
@@ -71,32 +85,29 @@ export interface ComboboxProps extends FormFieldProps, Omit<InputHTMLAttributes<
71
85
  * Callback function triggered whenever the value of the input field is triggered.
72
86
  *
73
87
  * @param event
74
- * @returns
75
88
  */
76
89
  onChange?: (event: ChangeEvent<HTMLInputElement> | null, value?: string) => void;
77
90
  /**
78
91
  * Callback function triggered whenever the input field is cleared.
79
92
  *
80
93
  * @param event
81
- * @returns
82
94
  */
83
95
  onClear?: (event: React.PointerEvent | React.KeyboardEvent) => void;
84
96
  /**
85
97
  * Callback function triggered whenever an option is selected or de-selected.
86
98
  *
87
- * @param option The selected option.
88
- * @param isSelected Whether the option has been selected or unselected.
89
- * @param isCustomOption Whether the option comes from user input, instead of from the list.
90
- * @returns
99
+ * @param option The option value
100
+ * @param isSelected Whether the option has been selected or unselected
101
+ * @param isCustomOption Whether the option comes from user input, instead of from the list
91
102
  */
92
- onToggleSelected?: (option: string, isSelected: boolean, isCustomOption: boolean) => void;
103
+ onToggleSelected?: (option: ComboboxOption["value"], isSelected: boolean, isCustomOption: boolean) => void;
93
104
  /**
94
105
  * List of selected options.
95
106
  *
96
107
  * Use this prop when controlling the selected state outside for the component,
97
108
  * e.g. for a filter, where options can be toggled elsewhere/programmatically.
98
109
  */
99
- selectedOptions?: string[];
110
+ selectedOptions?: string[] | ComboboxOption[];
100
111
  /**
101
112
  * Options for the maximum number of selected options.
102
113
  */
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { ComponentTranslation } from "./i18n/i18n.types";
3
+ export type FileUploadLocaleContextProps = {
4
+ translations?: ComponentTranslation<"FileUpload">;
5
+ };
6
+ export declare const FileUploadLocaleContextProvider: import("react").ForwardRefExoticComponent<FileUploadLocaleContextProps & {
7
+ children: import("react").ReactNode;
8
+ } & import("react").RefAttributes<unknown>>, useFileUploadTranslation: <S extends boolean = true>(strict?: S) => S extends true ? FileUploadLocaleContextProps : FileUploadLocaleContextProps | undefined;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useFileUploadTranslation = exports.FileUploadLocaleContextProvider = void 0;
5
+ const create_context_1 = require("../../util/create-context");
6
+ _a = (0, create_context_1.createContext)(), exports.FileUploadLocaleContextProvider = _a[0], exports.useFileUploadTranslation = _a[1];
7
+ //# sourceMappingURL=FileUpload.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileUpload.context.js","sourceRoot":"","sources":["../../../src/form/file-upload/FileUpload.context.tsx"],"names":[],"mappings":";;;;AAAA,8DAA0D;AAO7C,KACX,IAAA,8BAAa,GAAgC,EADjC,uCAA+B,UAAE,gCAAwB,SACvB"}
@@ -0,0 +1,118 @@
1
+ import React, { HTMLAttributes } from "react";
2
+ import { ComponentTranslation } from "./i18n/i18n.types";
3
+ import Trigger from "./parts/Trigger";
4
+ import Dropzone from "./parts/dropzone/Dropzone";
5
+ import Item from "./parts/item/Item";
6
+ interface FileUploadProps extends HTMLAttributes<HTMLDivElement> {
7
+ children: React.ReactNode;
8
+ /**
9
+ * i18n-API for customizing texts and labels
10
+ */
11
+ translations?: ComponentTranslation<"FileUpload">;
12
+ }
13
+ interface FileUploadComponent extends React.ForwardRefExoticComponent<FileUploadProps & React.RefAttributes<HTMLDivElement>> {
14
+ /**
15
+ * Framed area to drag-n-drop files, upload files with button-click or copy-paste.
16
+ * @example
17
+ * Single file
18
+ * ```jsx
19
+ * <FileUpload.Dropzone
20
+ * label="Last opp fil"
21
+ * multiple={false}
22
+ * onSelect={onSelect}
23
+ * />
24
+ * ```
25
+ *
26
+ * @example
27
+ * Multiple files
28
+ * ```jsx
29
+ * <FileUpload.Dropzone
30
+ * label="Last opp fil"
31
+ * multiple={true}
32
+ * onSelect={onSelect}
33
+ * />
34
+ * ```
35
+ *
36
+ * @example
37
+ * Error
38
+ * ```jsx
39
+ * <FileUpload.Dropzone
40
+ * label="Last opp filer"
41
+ * onSelect={onSelect}
42
+ * error={error}
43
+ * />
44
+ * ```
45
+ */
46
+ Dropzone: typeof Dropzone;
47
+ /**
48
+ * Displays a file with status, file size, action and error message.
49
+ * @example
50
+ * Single
51
+ * ```jsx
52
+ * <FileUpload.Item file={file} status="uploading" />
53
+ * ```
54
+ *
55
+ * @example
56
+ * Multiple items can be semantically grouped as a list.
57
+ * ```jsx
58
+ * <FileUpload>
59
+ * <VStack gap="4" as="ul">
60
+ * <FileUpload.Item as="li" file={file} />
61
+ * <FileUpload.Item as="li" file={file2} />
62
+ * <FileUpload.Item as="li" file={file3} status="uploading" />
63
+ * </VStack>
64
+ * </FileUpload>
65
+ * ```
66
+ *
67
+ * @example
68
+ * Custom file object
69
+ * ```jsx
70
+ * <FileUpload.Item file={{ name: "fileName.pdf", size: 1_048_576 }} />
71
+ * ```
72
+ *
73
+ * @example
74
+ * Error
75
+ * ```jsx
76
+ * <FileUpload.Item file={file} error="Something went wrong" />
77
+ * ```
78
+ *
79
+ * @example
80
+ * Status & actions
81
+ * ```jsx
82
+ * <FileUpload.Item file={file} status="uploading" />
83
+ * <FileUpload.Item file={file} status="downloading" />
84
+ * <FileUpload.Item file={file} itemAction="retry" onRetry={...} />
85
+ * <FileUpload.Item file={file} itemAction="delete" onDelete={...} />
86
+ * ```
87
+ */
88
+ Item: typeof Item;
89
+ /**
90
+ * Wrapper for a button to trigger file select.
91
+ * @example
92
+ * ```jsx
93
+ * <FileUpload.Trigger onSelect={...}>
94
+ * <Button variant="secondary">Last opp filer</Button>
95
+ * </FileUpload.Trigger>
96
+ * ```
97
+ */
98
+ Trigger: typeof Trigger;
99
+ }
100
+ /**
101
+ * A set of components used to upload and display files.
102
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/fileupload)
103
+ * @example Dropzone
104
+ * ```jsx
105
+ * <FileUpload.Dropzone />
106
+ * ```
107
+ *
108
+ * @example
109
+ * Items
110
+ * ```jsx
111
+ * <VStack gap="4" as="ul">
112
+ * <FileUpload.Item as="li" file={myFile} />
113
+ * <FileUpload.Item as="li" file={mySecondFile} />
114
+ * </VStack>
115
+ * ```
116
+ */
117
+ export declare const FileUpload: FileUploadComponent;
118
+ export default FileUpload;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.FileUpload = void 0;
41
+ const clsx_1 = __importDefault(require("clsx"));
42
+ const react_1 = __importStar(require("react"));
43
+ const FileUpload_context_1 = require("./FileUpload.context");
44
+ const Trigger_1 = __importDefault(require("./parts/Trigger"));
45
+ const Dropzone_1 = __importDefault(require("./parts/dropzone/Dropzone"));
46
+ const Item_1 = __importDefault(require("./parts/item/Item"));
47
+ /**
48
+ * A set of components used to upload and display files.
49
+ * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/fileupload)
50
+ * @example Dropzone
51
+ * ```jsx
52
+ * <FileUpload.Dropzone />
53
+ * ```
54
+ *
55
+ * @example
56
+ * Items
57
+ * ```jsx
58
+ * <VStack gap="4" as="ul">
59
+ * <FileUpload.Item as="li" file={myFile} />
60
+ * <FileUpload.Item as="li" file={mySecondFile} />
61
+ * </VStack>
62
+ * ```
63
+ */
64
+ exports.FileUpload = (0, react_1.forwardRef)((_a, ref) => {
65
+ var { children, className, translations } = _a, rest = __rest(_a, ["children", "className", "translations"]);
66
+ return (react_1.default.createElement(FileUpload_context_1.FileUploadLocaleContextProvider, { translations: translations },
67
+ react_1.default.createElement("div", Object.assign({ ref: ref }, rest, { className: (0, clsx_1.default)("navds-file-upload", className) }), children)));
68
+ });
69
+ exports.FileUpload.Dropzone = Dropzone_1.default;
70
+ exports.FileUpload.Item = Item_1.default;
71
+ exports.FileUpload.Trigger = Trigger_1.default;
72
+ exports.default = exports.FileUpload;
73
+ //# sourceMappingURL=FileUpload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileUpload.js","sourceRoot":"","sources":["../../../src/form/file-upload/FileUpload.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAsB;AACtB,+CAA0D;AAC1D,6DAAuE;AAEvE,8DAAsC;AACtC,yEAAiD;AACjD,6DAAqC;AAsGrC;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,UAAU,GAAG,IAAA,kBAAU,EAClC,CAAC,EAA+D,EAAE,GAAG,EAAE,EAAE;QAAxE,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,OAA4B,EAAvB,IAAI,cAA5C,yCAA8C,CAAF;IAC3C,OAAO,CACL,8BAAC,oDAA+B,IAAC,YAAY,EAAE,YAAY;QACzD,qDAAK,GAAG,EAAE,GAAG,IAAM,IAAI,IAAE,SAAS,EAAE,IAAA,cAAE,EAAC,mBAAmB,EAAE,SAAS,CAAC,KACnE,QAAQ,CACL,CAC0B,CACnC,CAAC;AACJ,CAAC,CACqB,CAAC;AAEzB,kBAAU,CAAC,QAAQ,GAAG,kBAAQ,CAAC;AAC/B,kBAAU,CAAC,IAAI,GAAG,cAAI,CAAC;AACvB,kBAAU,CAAC,OAAO,GAAG,iBAAO,CAAC;AAE7B,kBAAe,kBAAU,CAAC"}
@@ -0,0 +1,55 @@
1
+ export declare const fileRejectionReason: {
2
+ FileType: "fileType";
3
+ FileSize: "fileSize";
4
+ };
5
+ export type FileRejectionReason = (typeof fileRejectionReason)[keyof typeof fileRejectionReason];
6
+ export type FileRejected = {
7
+ file: File;
8
+ error: true;
9
+ reasons: string[];
10
+ };
11
+ export type FileAccepted = {
12
+ file: File;
13
+ error: false;
14
+ };
15
+ export type FileObject = FileRejected | FileAccepted;
16
+ export type FileRejectedPartitioned = {
17
+ file: File;
18
+ reasons: string[];
19
+ };
20
+ export type FilesPartitioned = {
21
+ accepted: File[];
22
+ rejected: FileRejectedPartitioned[];
23
+ };
24
+ export interface FileUploadBaseProps {
25
+ /**
26
+ * Indicates if it is possible to select multiple files at once.
27
+ * @default true
28
+ */
29
+ multiple?: boolean;
30
+ /**
31
+ * Indicates which file types to accept.
32
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept
33
+ */
34
+ accept?: string;
35
+ /**
36
+ * Maximum size of a file to accept
37
+ */
38
+ maxSizeInBytes?: number;
39
+ /**
40
+ * Custom validator that is used to decide if a file is accepted or rejected.
41
+ * @return true if the file is accepted, otherwise a string with the reason for rejection
42
+ */
43
+ validator?: (file: File) => true | string;
44
+ /**
45
+ * Callback triggered on file select
46
+ */
47
+ onSelect: (files: FileObject[], partitionedFiles: FilesPartitioned) => void;
48
+ /**
49
+ * Disables the dropzone when current >= max, unless `disabled` prop is set to `false`.
50
+ */
51
+ fileLimit?: {
52
+ max: number;
53
+ current: number;
54
+ };
55
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fileRejectionReason = void 0;
4
+ exports.fileRejectionReason = {
5
+ FileType: "fileType",
6
+ FileSize: "fileSize",
7
+ };
8
+ //# sourceMappingURL=FileUpload.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileUpload.types.js","sourceRoot":"","sources":["../../../src/form/file-upload/FileUpload.types.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG;IACjC,QAAQ,EAAE,UAAmB;IAC7B,QAAQ,EAAE,UAAmB;CAC9B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { TranslationObject } from "./i18n.types";
2
+ export declare function get(keypath: string | string[], ...objs: (TranslationObject | undefined)[]): string;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.get = void 0;
4
+ /**
5
+ * https://github.com/Shopify/polaris/blob/main/polaris-react/src/utilities/get.ts#L3
6
+ */
7
+ const OBJECT_NOTATION_MATCHER = /(\w+)/g;
8
+ function get(keypath, ...objs) {
9
+ const keys = Array.isArray(keypath) ? keypath : getKeypath(keypath);
10
+ for (const obj of objs) {
11
+ if (!obj) {
12
+ continue;
13
+ }
14
+ let acc = obj;
15
+ for (let i = 0; i < keys.length; i++) {
16
+ const val = acc[keys[i]];
17
+ if (val === undefined) {
18
+ continue;
19
+ }
20
+ acc = val;
21
+ }
22
+ if (typeof acc === "string") {
23
+ return acc;
24
+ }
25
+ }
26
+ throw new Error("Error translating key. The keypath does not resolve to a string.");
27
+ }
28
+ exports.get = get;
29
+ function getKeypath(str) {
30
+ const path = [];
31
+ let result;
32
+ while ((result = OBJECT_NOTATION_MATCHER.exec(str))) {
33
+ const [, first, second] = result;
34
+ path.push(first || second);
35
+ }
36
+ return path;
37
+ }
38
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../src/form/file-upload/i18n/get.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAM,uBAAuB,GAAG,QAAQ,CAAC;AAEzC,SAAgB,GAAG,CACjB,OAA0B,EAC1B,GAAG,IAAuC;IAE1C,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAEpE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,SAAS;QACX,CAAC;QAED,IAAI,GAAG,GAA+B,GAAG,CAAC;QAE1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,SAAS;YACX,CAAC;YACD,GAAG,GAAG,GAAG,CAAC;QACZ,CAAC;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;AACJ,CAAC;AA7BD,kBA6BC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,MAA8B,CAAC;IACnC,OAAO,CAAC,MAAM,GAAG,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACpD,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { Component, ComponentTranslation, TranslationDictionary } from "./i18n.types";
3
+ import nb from "./locales/nb.json";
4
+ export declare const I18nContext: import("react").Context<TranslationDictionary | TranslationDictionary[]>;
5
+ type NestedKeyOf<ObjectType extends object> = {
6
+ [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}.${NestedKeyOf<ObjectType[Key]>}` : `${Key}`;
7
+ }[keyof ObjectType & (string | number)];
8
+ export declare function useI18n<T extends Component>(componentName: T, ...local: (ComponentTranslation<T> | undefined)[]): (keypath: NestedKeyOf<(typeof nb)[T]>, options?: {
9
+ replacements: Record<string, string | number>;
10
+ }) => string;
11
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useI18n = exports.I18nContext = void 0;
7
+ const react_1 = require("react");
8
+ const get_1 = require("./get");
9
+ const nb_json_1 = __importDefault(require("./locales/nb.json"));
10
+ /**
11
+ * https://regex101.com/r/LYKWi3/1
12
+ */
13
+ const REPLACE_REGEX = /{[^}]*}/g;
14
+ exports.I18nContext = (0, react_1.createContext)(nb_json_1.default);
15
+ function useI18n(componentName, ...local) {
16
+ const i18n = (0, react_1.useContext)(exports.I18nContext);
17
+ /**
18
+ * https://github.com/Shopify/polaris/blob/2115f9ba2f5bcbf2ad15745233501bff2db81ecf/polaris-react/src/utilities/i18n/I18n.ts#L24
19
+ */
20
+ const translate = (keypath, options) => {
21
+ const text = (0, get_1.get)(keypath, ...local, ...(Array.isArray(i18n)
22
+ ? i18n.map((t) => t[componentName])
23
+ : [i18n[componentName]]));
24
+ if (options === null || options === void 0 ? void 0 : options.replacements) {
25
+ return text.replace(REPLACE_REGEX, (match) => {
26
+ const replacement = match.substring(1, match.length - 1);
27
+ if (options.replacements[replacement] === undefined) {
28
+ const replacementData = JSON.stringify(options.replacements);
29
+ throw new Error(`Error translating key '${keypath}'. No replacement syntax ({}) found for key '${replacement}'. The following replacements were passed: '${replacementData}'`);
30
+ }
31
+ return options.replacements[replacement]; // can also be a number, but JS doesn't mind...
32
+ });
33
+ }
34
+ return text;
35
+ };
36
+ return translate;
37
+ }
38
+ exports.useI18n = useI18n;
39
+ //# sourceMappingURL=i18n.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.context.js","sourceRoot":"","sources":["../../../../src/form/file-upload/i18n/i18n.context.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAkD;AAClD,+BAA4B;AAM5B,gEAAmC;AAEnC;;GAEG;AACH,MAAM,aAAa,GAAG,UAAU,CAAC;AAEpB,QAAA,WAAW,GAAG,IAAA,qBAAa,EAEtC,iBAAE,CAAC,CAAC;AASN,SAAgB,OAAO,CACrB,aAAgB,EAChB,GAAG,KAA8C;IAEjD,MAAM,IAAI,GAAG,IAAA,kBAAU,EAAC,mBAAW,CAAC,CAAC;IAErC;;OAEG;IACH,MAAM,SAAS,GAAG,CAChB,OAAoC,EACpC,OAA2D,EAC3D,EAAE;QACF,MAAM,IAAI,GAAG,IAAA,SAAG,EACd,OAAO,EACP,GAAG,KAAK,EACR,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAC3B,CAAC;QAEF,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC3C,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAEzD,IAAI,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,SAAS,EAAE,CAAC;oBACpD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;oBAE7D,MAAM,IAAI,KAAK,CACb,0BAA0B,OAAO,gDAAgD,WAAW,+CAA+C,eAAe,GAAG,CAC9J,CAAC;gBACJ,CAAC;gBAED,OAAO,OAAO,CAAC,YAAY,CAAC,WAAW,CAAW,CAAC,CAAC,+CAA+C;YACrG,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAzCD,0BAyCC"}
@@ -0,0 +1,13 @@
1
+ import nb from "./locales/nb.json";
2
+ export interface TranslationObject {
3
+ [key: string]: string | TranslationObject | undefined;
4
+ }
5
+ export interface TranslationDictionary {
6
+ [key: string]: TranslationObject | undefined;
7
+ }
8
+ type RecursivePartial<T> = {
9
+ [P in keyof T]?: RecursivePartial<T[P]>;
10
+ };
11
+ export type Component = keyof typeof nb;
12
+ export type ComponentTranslation<T extends Component> = RecursivePartial<(typeof nb)[T]>;
13
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=i18n.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.types.js","sourceRoot":"","sources":["../../../../src/form/file-upload/i18n/i18n.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ {
2
+ "FileUpload": {
3
+ "dropzone": {
4
+ "button": "Velg fil",
5
+ "buttonMultiple": "Velg filer",
6
+ "dragAndDrop": "Dra og slipp filen her",
7
+ "dragAndDropMultiple": "Dra og slipp filer her",
8
+ "drop": "Slipp",
9
+ "or": "eller",
10
+ "disabled": "Filopplasting er deaktivert",
11
+ "disabledFilelimit": "Du kan ikke laste opp flere filer"
12
+ },
13
+ "item": {
14
+ "retryButtonTitle": "Prøv å laste opp filen på nytt",
15
+ "deleteButtonTitle": "Slett filen",
16
+ "uploading": "Laster opp…",
17
+ "downloading": "Laster ned…"
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,2 @@
1
+ import { TranslationDictionary } from "./i18n.types";
2
+ export declare function merge(...objs: TranslationDictionary[]): TranslationDictionary;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.merge = void 0;
4
+ function merge(...objs) {
5
+ let final = {};
6
+ for (const obj of objs) {
7
+ final = mergeRecursively(final, obj);
8
+ }
9
+ return final;
10
+ }
11
+ exports.merge = merge;
12
+ function mergeRecursively(objA, objB) {
13
+ const objARes = Object.assign({}, objA);
14
+ for (const key in objB) {
15
+ if (!(key in objB)) {
16
+ continue;
17
+ }
18
+ const a = objARes[key];
19
+ const b = objB[key];
20
+ if (b && typeof b !== "string" && typeof a !== "string") {
21
+ objARes[key] = mergeRecursively(a, b);
22
+ }
23
+ else {
24
+ objARes[key] = b;
25
+ }
26
+ }
27
+ return objARes;
28
+ }
29
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../../src/form/file-upload/i18n/merge.ts"],"names":[],"mappings":";;;AAEA,SAAgB,KAAK,CAAC,GAAG,IAA6B;IACpD,IAAI,KAAK,GAA0B,EAAE,CAAC;IAEtC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AARD,sBAQC;AAED,SAAS,gBAAgB,CACvB,IAAO,EACP,IAA+C;IAE/C,MAAM,OAAO,qBAAQ,IAAI,CAAE,CAAC;IAE5B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;YACnB,SAAS;QACX,CAAC;QAED,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QAEpB,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { default as UNSAFE_FileUpload } from "./FileUpload";
2
+ export { default as UNSAFE_FileUploadDropzone } from "./parts/dropzone/Dropzone";
3
+ export { type FileUploadDropzoneProps } from "./parts/dropzone/dropzone.types";
4
+ export { default as UNSAFE_FileUploadTrigger, type FileUploadTriggerProps, } from "./parts/Trigger";
5
+ export { type FileObject, type FileRejected, type FileAccepted, type FileRejectedPartitioned, type FilesPartitioned, type FileRejectionReason, } from "./FileUpload.types";
6
+ export { default as UNSAFE_FileUploadItem, type FileUploadItemProps, } from "./parts/item/Item";
7
+ export { type FileItem, type FileMetadata } from "./parts/item/Item.types";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ "use client";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.UNSAFE_FileUploadItem = exports.UNSAFE_FileUploadTrigger = exports.UNSAFE_FileUploadDropzone = exports.UNSAFE_FileUpload = void 0;
8
+ var FileUpload_1 = require("./FileUpload");
9
+ Object.defineProperty(exports, "UNSAFE_FileUpload", { enumerable: true, get: function () { return __importDefault(FileUpload_1).default; } });
10
+ var Dropzone_1 = require("./parts/dropzone/Dropzone");
11
+ Object.defineProperty(exports, "UNSAFE_FileUploadDropzone", { enumerable: true, get: function () { return __importDefault(Dropzone_1).default; } });
12
+ var Trigger_1 = require("./parts/Trigger");
13
+ Object.defineProperty(exports, "UNSAFE_FileUploadTrigger", { enumerable: true, get: function () { return __importDefault(Trigger_1).default; } });
14
+ var Item_1 = require("./parts/item/Item");
15
+ Object.defineProperty(exports, "UNSAFE_FileUploadItem", { enumerable: true, get: function () { return __importDefault(Item_1).default; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/form/file-upload/index.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AACb,2CAA4D;AAAnD,gIAAA,OAAO,OAAqB;AACrC,sDAAiF;AAAxE,sIAAA,OAAO,OAA6B;AAE7C,2CAGyB;AAFvB,oIAAA,OAAO,OAA4B;AAWrC,0CAG2B;AAFzB,8HAAA,OAAO,OAAyB"}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { FileUploadBaseProps } from "../FileUpload.types";
3
+ export interface FileUploadTriggerProps extends Omit<FileUploadBaseProps, "fileLimit"> {
4
+ children: React.ReactNode;
5
+ }
6
+ declare const Trigger: React.ForwardRefExoticComponent<FileUploadTriggerProps & React.RefAttributes<HTMLInputElement>>;
7
+ export default Trigger;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = __importStar(require("react"));
27
+ const Slot_1 = require("../../../util/Slot");
28
+ const useFileUpload_1 = require("../useFileUpload");
29
+ const Trigger = (0, react_1.forwardRef)(({ children, multiple = true, accept, onSelect, validator, maxSizeInBytes, }, ref) => {
30
+ const { onChange, inputRef, mergedRef } = (0, useFileUpload_1.useFileUpload)({
31
+ ref,
32
+ onSelect,
33
+ validator,
34
+ accept,
35
+ maxSizeInBytes,
36
+ disabled: false,
37
+ });
38
+ return (react_1.default.createElement(react_1.default.Fragment, null,
39
+ react_1.default.createElement(Slot_1.Slot, { onClick: () => { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click(); } }, children),
40
+ react_1.default.createElement("input", { ref: mergedRef, type: "file", style: { display: "none" }, multiple: multiple, accept: accept, onChange: onChange })));
41
+ });
42
+ exports.default = Trigger;
43
+ //# sourceMappingURL=Trigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Trigger.js","sourceRoot":"","sources":["../../../../src/form/file-upload/parts/Trigger.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAC1C,6CAA0C;AAE1C,oDAAiD;AAOjD,MAAM,OAAO,GAAG,IAAA,kBAAU,EACxB,CACE,EACE,QAAQ,EACR,QAAQ,GAAG,IAAI,EACf,MAAM,EACN,QAAQ,EACR,SAAS,EACT,cAAc,GACS,EACzB,GAAG,EACH,EAAE;IACF,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAA,6BAAa,EAAC;QACtD,GAAG;QACH,QAAQ;QACR,SAAS;QACT,MAAM;QACN,cAAc;QACd,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,OAAO,CACL;QACE,8BAAC,WAAI,IAAC,OAAO,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAA,EAAA,IAAG,QAAQ,CAAQ;QACjE,yCACE,GAAG,EAAE,SAAS,EACd,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GAClB,CACD,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { FileUploadDropzoneProps } from "./dropzone.types";
3
+ declare const Dropzone: React.ForwardRefExoticComponent<FileUploadDropzoneProps & React.RefAttributes<HTMLInputElement>>;
4
+ export default Dropzone;