@oslokommune/punkt-react 19.15.5 → 19.16.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 (298) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/_virtual/_rolldown/runtime.js +13 -0
  3. package/dist/components/accordion/Accordion.js +28 -0
  4. package/dist/components/accordion/AccordionItem.js +60 -0
  5. package/dist/components/alert/Alert.js +76 -0
  6. package/dist/components/backlink/BackLink.js +35 -0
  7. package/dist/components/breadcrumbs/Breadcrumbs.js +67 -0
  8. package/dist/components/button/Button.js +54 -0
  9. package/dist/components/calendar/Calendar.js +49 -0
  10. package/dist/components/calendar/CalendarGrid.js +99 -0
  11. package/dist/components/calendar/CalendarNav.js +89 -0
  12. package/dist/components/calendar/calendar-utils.js +44 -0
  13. package/dist/components/calendar/useCalendarState.js +214 -0
  14. package/dist/components/card/Card.js +99 -0
  15. package/dist/components/checkbox/Checkbox.js +101 -0
  16. package/dist/components/checkboxgroup/CheckboxGroup.js +88 -0
  17. package/dist/components/checkboxgroup/CheckboxGroupContext.js +5 -0
  18. package/dist/components/combobox/Combobox.js +65 -0
  19. package/dist/components/combobox/ComboboxInput.js +87 -0
  20. package/dist/components/combobox/ComboboxTags.js +82 -0
  21. package/dist/components/combobox/Listbox.js +136 -0
  22. package/dist/components/combobox/useComboboxState.js +577 -0
  23. package/dist/components/consent/Consent.js +110 -0
  24. package/dist/components/datepicker/DateTags.js +28 -0
  25. package/dist/components/datepicker/Datepicker.js +79 -0
  26. package/dist/components/datepicker/DatepickerInputs.js +149 -0
  27. package/dist/components/datepicker/DatepickerPopup.js +41 -0
  28. package/dist/components/datepicker/useDatepickerState.js +243 -0
  29. package/dist/components/fileupload/DropZone.js +131 -0
  30. package/dist/components/fileupload/FileUpload.js +223 -0
  31. package/dist/components/fileupload/FileUploadContext.d.ts +2 -0
  32. package/dist/components/fileupload/FileUploadContext.js +6 -0
  33. package/dist/components/fileupload/QueueDisplay.js +67 -0
  34. package/dist/components/fileupload/QueueItemContent.js +88 -0
  35. package/dist/components/fileupload/Subcomponents.js +265 -0
  36. package/dist/components/fileupload/Truncate.js +22 -0
  37. package/dist/components/fileupload/extensions/Comments.js +128 -0
  38. package/dist/components/fileupload/extensions/Remove.js +9 -0
  39. package/dist/components/fileupload/extensions/Rename.js +66 -0
  40. package/dist/components/fileupload/hooks/useFileAttributes.js +25 -0
  41. package/dist/components/fileupload/hooks/useImageObjectUrl.js +15 -0
  42. package/dist/components/fileupload/hooks/useImagePreview.js +24 -0
  43. package/dist/components/fileupload/hooks/useOperationState.js +31 -0
  44. package/dist/components/fileupload/hooks/useRequiredFormValidation.js +23 -0
  45. package/dist/components/fileupload/types.d.ts +0 -1
  46. package/dist/components/fileupload/types.js +12 -0
  47. package/dist/components/footer/Footer.js +134 -0
  48. package/dist/components/footer/FooterGlobal.js +105 -0
  49. package/dist/components/footerSimple/FooterSimple.js +87 -0
  50. package/dist/components/header/Header.js +15 -0
  51. package/dist/components/header/HeaderGlobal.js +286 -0
  52. package/dist/components/header/HeaderService.js +281 -0
  53. package/dist/components/header-menu/HeaderMenu.js +197 -0
  54. package/dist/components/headerUserMenu/UserMenu.js +134 -0
  55. package/dist/components/heading/Heading.js +37 -0
  56. package/dist/components/helptext/Helptext.js +50 -0
  57. package/dist/components/icon/Icon.d.ts +6 -0
  58. package/dist/components/icon/Icon.js +69 -0
  59. package/dist/components/input/Input.js +23 -0
  60. package/dist/components/inputwrapper/InputWrapper.js +128 -0
  61. package/dist/components/link/Link.js +34 -0
  62. package/dist/components/linkcard/LinkCard.js +38 -0
  63. package/dist/components/loader/Loader.js +47 -0
  64. package/dist/components/messagebox/Messagebox.js +50 -0
  65. package/dist/components/modal/Modal.js +89 -0
  66. package/dist/components/progressbar/Progressbar.d.ts +1 -1
  67. package/dist/components/progressbar/Progressbar.js +62 -0
  68. package/dist/components/radio/RadioButton.js +85 -0
  69. package/dist/components/radiogroup/RadioGroup.js +70 -0
  70. package/dist/components/radiogroup/RadioGroupContext.js +5 -0
  71. package/dist/components/searchinput/SearchInput.js +102 -0
  72. package/dist/components/select/Select.js +56 -0
  73. package/dist/components/stepper/Step.js +78 -0
  74. package/dist/components/stepper/Stepper.js +21 -0
  75. package/dist/components/strings/PktStringsProvider.js +21 -0
  76. package/dist/components/table/Table.js +19 -0
  77. package/dist/components/table/TableBody.js +13 -0
  78. package/dist/components/table/TableDataCell.js +14 -0
  79. package/dist/components/table/TableHeader.js +12 -0
  80. package/dist/components/table/TableHeaderCell.js +12 -0
  81. package/dist/components/table/TableRow.js +12 -0
  82. package/dist/components/tabs/TabItem.js +60 -0
  83. package/dist/components/tabs/Tabs.js +90 -0
  84. package/dist/components/tag/Tag.js +76 -0
  85. package/dist/components/textarea/Textarea.js +74 -0
  86. package/dist/components/textinput/Textinput.js +106 -0
  87. package/dist/components/timepicker/Timepicker.js +224 -0
  88. package/dist/components/timepicker/useTimepickerState.js +483 -0
  89. package/dist/hooks/useElementWidth.js +23 -0
  90. package/dist/hooks/useFocusModality.js +28 -0
  91. package/dist/hooks/useGeneratedId.js +8 -0
  92. package/dist/hooks/useHeaderChrome.js +36 -0
  93. package/dist/hooks/useOptionGroupField.js +70 -0
  94. package/dist/hooks/useOwnerForm.js +15 -0
  95. package/dist/hooks/usePktStrings.js +16 -0
  96. package/dist/hooks/useScrollLock.js +12 -0
  97. package/dist/node_modules/@date-fns/tz/date/index.js +57 -0
  98. package/dist/node_modules/@date-fns/tz/date/mini.js +75 -0
  99. package/dist/node_modules/@date-fns/tz/index.js +6 -0
  100. package/dist/node_modules/@date-fns/tz/tz/index.js +1 -0
  101. package/dist/node_modules/@date-fns/tz/tzName/index.js +10 -0
  102. package/dist/node_modules/@date-fns/tz/tzOffset/index.js +22 -0
  103. package/dist/node_modules/classnames/index.js +32 -0
  104. package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +6 -0
  105. package/dist/node_modules/date-fns/_lib/defaultOptions.js +7 -0
  106. package/dist/node_modules/date-fns/_lib/format/formatters.js +389 -0
  107. package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +43 -0
  108. package/dist/node_modules/date-fns/_lib/format/longFormatters.js +38 -0
  109. package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +8 -0
  110. package/dist/node_modules/date-fns/_lib/normalizeDates.js +8 -0
  111. package/dist/node_modules/date-fns/_lib/normalizeInterval.js +11 -0
  112. package/dist/node_modules/date-fns/_lib/protectedTokens.js +23 -0
  113. package/dist/node_modules/date-fns/addDays.js +9 -0
  114. package/dist/node_modules/date-fns/constants.js +10 -0
  115. package/dist/node_modules/date-fns/constructFrom.js +7 -0
  116. package/dist/node_modules/date-fns/differenceInCalendarDays.js +11 -0
  117. package/dist/node_modules/date-fns/eachDayOfInterval.js +15 -0
  118. package/dist/node_modules/date-fns/endOfDay.js +8 -0
  119. package/dist/node_modules/date-fns/format.js +59 -0
  120. package/dist/node_modules/date-fns/getDayOfYear.js +10 -0
  121. package/dist/node_modules/date-fns/getISODay.js +8 -0
  122. package/dist/node_modules/date-fns/getISOWeek.js +11 -0
  123. package/dist/node_modules/date-fns/getISOWeekYear.js +14 -0
  124. package/dist/node_modules/date-fns/getWeek.js +11 -0
  125. package/dist/node_modules/date-fns/getWeekYear.js +15 -0
  126. package/dist/node_modules/date-fns/isDate.js +6 -0
  127. package/dist/node_modules/date-fns/isValid.js +8 -0
  128. package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +9 -0
  129. package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +17 -0
  130. package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +22 -0
  131. package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +18 -0
  132. package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +69 -0
  133. package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +32 -0
  134. package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +11 -0
  135. package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +202 -0
  136. package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +124 -0
  137. package/dist/node_modules/date-fns/locale/en-US.js +20 -0
  138. package/dist/node_modules/date-fns/startOfDay.js +8 -0
  139. package/dist/node_modules/date-fns/startOfISOWeek.js +10 -0
  140. package/dist/node_modules/date-fns/startOfISOWeekYear.js +10 -0
  141. package/dist/node_modules/date-fns/startOfWeek.js +9 -0
  142. package/dist/node_modules/date-fns/startOfWeekYear.js +11 -0
  143. package/dist/node_modules/date-fns/startOfYear.js +8 -0
  144. package/dist/node_modules/date-fns/toDate.js +7 -0
  145. package/dist/punkt-react.cjs +1 -1
  146. package/dist/punkt-react.js +55 -9394
  147. package/dist/shared-strings/consent.js +113 -0
  148. package/dist/shared-strings/format.js +18 -0
  149. package/dist/shared-strings/nb.js +201 -0
  150. package/dist/shared-strings/resolve.js +40 -0
  151. package/dist/shared-strings/store.js +35 -0
  152. package/dist/shared-types/accordion.js +4 -0
  153. package/dist/shared-types/calendar.js +12 -0
  154. package/dist/shared-types/card.js +15 -0
  155. package/dist/shared-types/checkbox.js +15 -0
  156. package/dist/shared-types/combobox.js +19 -0
  157. package/dist/shared-types/consent.js +8 -0
  158. package/dist/shared-types/footer.js +4 -0
  159. package/dist/shared-types/header-footer.js +4 -0
  160. package/dist/shared-types/icon.js +7 -0
  161. package/dist/shared-types/messagebox.js +8 -0
  162. package/dist/shared-types/option-group.js +14 -0
  163. package/dist/shared-types/radiobutton.js +11 -0
  164. package/dist/shared-types/select.js +14 -0
  165. package/dist/shared-types/table.js +8 -0
  166. package/dist/shared-utils/calendar/calendar-grid.js +19 -0
  167. package/dist/shared-utils/calendar/date-validation.js +19 -0
  168. package/dist/shared-utils/calendar/keyboard-navigation.js +26 -0
  169. package/dist/shared-utils/calendar/selection-manager.js +52 -0
  170. package/dist/shared-utils/combobox/input-utils.js +39 -0
  171. package/dist/shared-utils/combobox/keyboard-navigation.js +41 -0
  172. package/dist/shared-utils/combobox/option-utils.js +48 -0
  173. package/dist/shared-utils/date-utils.js +71 -0
  174. package/dist/shared-utils/datepicker-utils.js +32 -0
  175. package/dist/shared-utils/device-utils.js +7 -0
  176. package/dist/shared-utils/fileupload/announcements.js +21 -0
  177. package/dist/shared-utils/fileupload/filename.js +8 -0
  178. package/dist/shared-utils/fileupload/focus-trap.js +2 -0
  179. package/dist/shared-utils/fileupload/formats.js +29 -0
  180. package/dist/shared-utils/fileupload/index.js +11 -0
  181. package/dist/shared-utils/fileupload/navigation.js +6 -0
  182. package/dist/shared-utils/fileupload/size.js +25 -0
  183. package/dist/shared-utils/fileupload/transfers.js +23 -0
  184. package/dist/shared-utils/fileupload/truncate.js +9 -0
  185. package/dist/shared-utils/fileupload/validation.js +32 -0
  186. package/dist/shared-utils/focus-trap/index.js +60 -0
  187. package/dist/shared-utils/forms/described-by.js +7 -0
  188. package/dist/shared-utils/header-footer/external-domain.js +30 -0
  189. package/dist/shared-utils/header-footer/fetch-header-footer-data.js +29 -0
  190. package/dist/shared-utils/header-footer/icon-map.js +55 -0
  191. package/dist/shared-utils/header-footer/select-megamenu.js +7 -0
  192. package/dist/shared-utils/scroll-lock/index.js +21 -0
  193. package/dist/shared-utils/timepicker/options.js +10 -0
  194. package/dist/shared-utils/timepicker/stepper.js +10 -0
  195. package/dist/shared-utils/timepicker/time-utils.js +7 -0
  196. package/dist/shared-utils/value-utils.js +12 -0
  197. package/dist/utils/nativeInputValue.js +6 -0
  198. package/dist/utils/stableKeys.js +13 -0
  199. package/dist/utils/stringutils.js +7 -0
  200. package/package.json +3 -2
  201. package/src/components/checkbox/Checkbox.tsx +2 -0
  202. package/src/components/combobox/types.ts +0 -2
  203. package/src/components/fileupload/FileUpload.tsx +3 -1
  204. package/src/components/fileupload/FileUploadContext.ts +7 -0
  205. package/src/components/fileupload/QueueDisplay.tsx +3 -3
  206. package/src/components/fileupload/Subcomponents.tsx +2 -7
  207. package/src/components/fileupload/extensions/Comments.tsx +2 -1
  208. package/src/components/fileupload/extensions/Rename.tsx +2 -1
  209. package/src/components/fileupload/types.ts +1 -2
  210. package/src/components/header/Header.test.tsx +0 -7
  211. package/src/components/header/Header.tsx +0 -2
  212. package/src/components/heading/Heading.tsx +0 -2
  213. package/src/components/helptext/Helptext.tsx +3 -4
  214. package/src/components/hydration.test.tsx +32 -0
  215. package/src/components/icon/Icon.test.tsx +0 -7
  216. package/src/components/icon/Icon.tsx +7 -0
  217. package/src/components/input/Input.tsx +0 -2
  218. package/src/components/inputwrapper/InputWrapper.tsx +3 -4
  219. package/src/components/link/Link.tsx +0 -2
  220. package/src/components/progressbar/Progressbar.test.tsx +8 -29
  221. package/src/components/progressbar/Progressbar.tsx +17 -12
  222. package/src/components/radio/RadioButton.tsx +2 -0
  223. package/src/components/searchinput/SearchInput.tsx +3 -4
  224. package/src/components/server-components.test.ts +69 -0
  225. package/src/components/ssr.test.tsx +3 -35
  226. package/src/components/stepper/Step.tsx +0 -2
  227. package/src/components/stepper/Stepper.tsx +0 -2
  228. package/src/components/strings/PktStringsProvider.tsx +2 -0
  229. package/src/components/table/Table.tsx +0 -2
  230. package/src/components/table/TableBody.tsx +1 -3
  231. package/src/components/table/TableDataCell.tsx +0 -2
  232. package/src/components/table/TableHeader.tsx +0 -2
  233. package/src/components/table/TableHeaderCell.tsx +0 -2
  234. package/src/components/table/TableRow.tsx +0 -2
  235. package/dist/components/accordion/Accordion.test.d.ts +0 -0
  236. package/dist/components/alert/Alert.test.d.ts +0 -0
  237. package/dist/components/backlink/BackLink.test.d.ts +0 -0
  238. package/dist/components/breadcrumbs/Breadcrumbs.test.d.ts +0 -1
  239. package/dist/components/button/Button.test.d.ts +0 -0
  240. package/dist/components/calendar/Calendar.accessibility.test.d.ts +0 -0
  241. package/dist/components/calendar/Calendar.constraints.test.d.ts +0 -0
  242. package/dist/components/calendar/Calendar.core.test.d.ts +0 -0
  243. package/dist/components/calendar/Calendar.interaction.test.d.ts +0 -0
  244. package/dist/components/calendar/Calendar.selection.test.d.ts +0 -0
  245. package/dist/components/card/Card.test.d.ts +0 -0
  246. package/dist/components/checkbox/Checkbox.test.d.ts +0 -0
  247. package/dist/components/checkboxgroup/CheckboxGroup.forms.test.d.ts +0 -0
  248. package/dist/components/checkboxgroup/CheckboxGroup.test.d.ts +0 -0
  249. package/dist/components/combobox/Combobox.accessibility.test.d.ts +0 -0
  250. package/dist/components/combobox/Combobox.core.test.d.ts +0 -0
  251. package/dist/components/combobox/Combobox.interaction.test.d.ts +0 -0
  252. package/dist/components/combobox/Combobox.preselection.test.d.ts +0 -0
  253. package/dist/components/combobox/Combobox.selection.test.d.ts +0 -0
  254. package/dist/components/consent/Consent.test.d.ts +0 -0
  255. package/dist/components/datepicker/Datepicker.accessibility.test.d.ts +0 -0
  256. package/dist/components/datepicker/Datepicker.core.test.d.ts +0 -0
  257. package/dist/components/datepicker/Datepicker.input.test.d.ts +0 -0
  258. package/dist/components/datepicker/Datepicker.selection.test.d.ts +0 -0
  259. package/dist/components/datepicker/Datepicker.validation.test.d.ts +0 -0
  260. package/dist/components/fileupload/FileUpload.test.d.ts +0 -0
  261. package/dist/components/fileupload/QueueDisplay.test.d.ts +0 -0
  262. package/dist/components/fileupload/Truncate.test.d.ts +0 -0
  263. package/dist/components/footer/Footer.accessibility.test.d.ts +0 -0
  264. package/dist/components/footer/Footer.test.d.ts +0 -1
  265. package/dist/components/footerSimple/FooterSimple.test.d.ts +0 -1
  266. package/dist/components/formAttribute.test.d.ts +0 -1
  267. package/dist/components/header/Header.test.d.ts +0 -0
  268. package/dist/components/header/HeaderGlobal.accessibility.test.d.ts +0 -0
  269. package/dist/components/header/HeaderGlobal.test.d.ts +0 -0
  270. package/dist/components/header/HeaderService.accessibility.test.d.ts +0 -0
  271. package/dist/components/header/HeaderService.test.d.ts +0 -0
  272. package/dist/components/header-menu/HeaderMenu.test.d.ts +0 -0
  273. package/dist/components/headerUserMenu/UserMenu.test.d.ts +0 -0
  274. package/dist/components/heading/Heading.test.d.ts +0 -0
  275. package/dist/components/helptext/Helptext.test.d.ts +0 -0
  276. package/dist/components/helptext/helptextAssociation.test.d.ts +0 -1
  277. package/dist/components/icon/Icon.test.d.ts +0 -9
  278. package/dist/components/inputwrapper/InputWrapper.test.d.ts +0 -0
  279. package/dist/components/link/Link.test.d.ts +0 -1
  280. package/dist/components/linkcard/LinkCard.test.d.ts +0 -0
  281. package/dist/components/loader/Loader.test.d.ts +0 -0
  282. package/dist/components/messagebox/Messagebox.test.d.ts +0 -1
  283. package/dist/components/modal/Modal.test.d.ts +0 -0
  284. package/dist/components/progressbar/Progressbar.test.d.ts +0 -0
  285. package/dist/components/radio/RadioButton.test.d.ts +0 -0
  286. package/dist/components/radiogroup/RadioGroup.forms.test.d.ts +0 -0
  287. package/dist/components/radiogroup/RadioGroup.test.d.ts +0 -0
  288. package/dist/components/searchinput/SearchInput.test.d.ts +0 -0
  289. package/dist/components/select/Select.test.d.ts +0 -0
  290. package/dist/components/ssr.test.d.ts +0 -1
  291. package/dist/components/stepper/Stepper.test.d.ts +0 -0
  292. package/dist/components/strings/strings-override.test.d.ts +0 -1
  293. package/dist/components/table/Table.test.d.ts +0 -0
  294. package/dist/components/tabs/Tabs.test.d.ts +0 -0
  295. package/dist/components/tag/Tag.test.d.ts +0 -0
  296. package/dist/components/textarea/Textarea.test.d.ts +0 -0
  297. package/dist/components/textinput/Textinput.test.d.ts +0 -0
  298. package/dist/components/timepicker/Timepicker.test.d.ts +0 -0
@@ -0,0 +1,7 @@
1
+ //#region ../../shared-utils/header-footer/select-megamenu.ts
2
+ var e = "nb-NO";
3
+ function t(t, n = e) {
4
+ if (t) return t[n] ?? t[e];
5
+ }
6
+ //#endregion
7
+ export { t as selectLocaleData };
@@ -0,0 +1,21 @@
1
+ //#region ../../shared-utils/scroll-lock/index.ts
2
+ var e = "is-scroll-locked", t = 0, n = 0, r = () => typeof document < "u" && typeof window < "u", i = () => {
3
+ let t = document.body, r = document.documentElement;
4
+ n = window.scrollY || window.pageYOffset;
5
+ let i = window.innerWidth - r.clientWidth;
6
+ i > 0 && (t.style.paddingRight = `${i}px`), t.style.position = "fixed", t.style.top = `-${n}px`, t.style.left = "0", t.style.right = "0", t.style.width = "100%", t.style.overflow = "hidden", r.classList.add(e);
7
+ }, a = () => {
8
+ let t = document.body, r = document.documentElement;
9
+ t.style.removeProperty("position"), t.style.removeProperty("top"), t.style.removeProperty("left"), t.style.removeProperty("right"), t.style.removeProperty("width"), t.style.removeProperty("overflow"), t.style.removeProperty("padding-right"), r.classList.remove(e), typeof window.scrollTo == "function" && window.scrollTo({
10
+ top: n,
11
+ behavior: "instant"
12
+ });
13
+ }, o = () => {
14
+ r() && (t += 1, t === 1 && i());
15
+ }, s = () => {
16
+ !r() || t === 0 || (--t, t === 0 && a());
17
+ }, c = () => ({ locked: !1 }), l = (e, t) => {
18
+ e.locked !== t && (e.locked = t, t ? o() : s());
19
+ };
20
+ //#endregion
21
+ export { c as createScrollLockToken, l as setScrollLock };
@@ -0,0 +1,10 @@
1
+ //#region ../../shared-utils/timepicker/options.ts
2
+ var e = (e) => e ? Math.max(1, Math.round(e / 60)) : 1, t = (e, t) => {
3
+ let n = e ? parseInt(String(e).split(":")[0], 10) : 0, r = t ? parseInt(String(t).split(":")[0], 10) : 23;
4
+ return Array.from({ length: r - n + 1 }, (e, t) => t + n);
5
+ }, n = (t) => {
6
+ let n = e(t);
7
+ return Array.from({ length: Math.floor(60 / n) }, (e, t) => t * n);
8
+ };
9
+ //#endregion
10
+ export { t as getHourOptions, n as getMinuteOptions, e as getMinuteStep };
@@ -0,0 +1,10 @@
1
+ //#region ../../shared-utils/timepicker/stepper.ts
2
+ var e = (e, t, n, r) => {
3
+ let i = e === "" ? n === 1 ? 0 : 23 : parseInt(e, 10), a = t === "" ? n === 1 ? 0 : Math.floor(59 / r) * r : parseInt(t, 10);
4
+ return a += n * r, a > 59 ? (a = 0, i = (i + 1) % 24) : a < 0 && (a = Math.floor(59 / r) * r, i = (i - 1 + 24) % 24), {
5
+ hours: String(i).padStart(2, "0"),
6
+ minutes: String(a).padStart(2, "0")
7
+ };
8
+ };
9
+ //#endregion
10
+ export { e as stepTime };
@@ -0,0 +1,7 @@
1
+ //#region ../../shared-utils/timepicker/time-utils.ts
2
+ var e = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && parseInt(e.slice(3), 10) <= 59, t = (e) => {
3
+ let [t, n] = e.split(":").map(Number);
4
+ return t * 60 + n;
5
+ };
6
+ //#endregion
7
+ export { e as isValidTimeString, t as timeToMinutes };
@@ -0,0 +1,12 @@
1
+ //#region ../../shared-utils/value-utils.ts
2
+ var e = (e) => {
3
+ if (!e) return [];
4
+ if (Array.isArray(e)) return e.filter(Boolean);
5
+ if (typeof e == "string" && e.trimStart().startsWith("[")) try {
6
+ let t = JSON.parse(e);
7
+ if (Array.isArray(t)) return t.filter(Boolean);
8
+ } catch {}
9
+ return String(e).split(",").map((e) => e.trim()).filter(Boolean);
10
+ };
11
+ //#endregion
12
+ export { e as valueToArray };
@@ -0,0 +1,6 @@
1
+ //#region src/utils/nativeInputValue.ts
2
+ var e = (e, t) => {
3
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(e, t);
4
+ };
5
+ //#endregion
6
+ export { e as setNativeInputValue };
@@ -0,0 +1,13 @@
1
+ //#region src/utils/stableKeys.ts
2
+ var e = (e, t) => {
3
+ let n = /* @__PURE__ */ new Map();
4
+ return e.map((e) => {
5
+ let r = t(e), i = (n.get(r) ?? 0) + 1;
6
+ return n.set(r, i), {
7
+ item: e,
8
+ key: i === 1 ? r : `${r}~${i}`
9
+ };
10
+ });
11
+ }, t = (e) => typeof e == "string" ? e : "";
12
+ //#endregion
13
+ export { t as textKey, e as withStableKeys };
@@ -0,0 +1,7 @@
1
+ //#region src/utils/stringutils.ts
2
+ var e = () => ("00000000000000000" + (Math.random() * 0x10000000000000000).toString(16)).slice(-16), t = () => {
3
+ let t = e(), n = e();
4
+ return t.slice(0, 8) + "-" + t.slice(8, 12) + "-4" + t.slice(13) + "-a" + n.slice(1, 4) + "-" + n.slice(4);
5
+ };
6
+ //#endregion
7
+ export { t as uuidish };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "19.15.5",
3
+ "version": "19.16.0",
4
4
  "description": "React komponentbibliotek til Punkt, designsystem for Oslo kommune",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo kommune",
@@ -26,6 +26,7 @@
26
26
  "dev": "vite",
27
27
  "build": "tsc && vite build && node scripts/bundle-shared-types.js",
28
28
  "build-app": "tsc && vite build --config vite.config-app.ts",
29
+ "check-tree-shaking": "node scripts/check-tree-shaking.mjs",
29
30
  "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
30
31
  "lint:fix": "eslint --fix 'src/**/*.{jsx,ts,tsx}'",
31
32
  "format": "prettier --write src//**/*.{ts,tsx,css} --config ./.prettierrc",
@@ -101,5 +102,5 @@
101
102
  "url": "https://github.com/oslokommune/punkt/issues"
102
103
  },
103
104
  "license": "MIT",
104
- "gitHead": "0baab53f4a1bd33c07a73d24eacbd66087c98738"
105
+ "gitHead": "dc04d631131be873574d55919198f719cc0e2d09"
105
106
  }
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import {
2
4
  ChangeEvent,
3
5
  ChangeEventHandler,
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import type { IPktStringsProps, TPktStringsOverride } from 'shared-strings'
4
2
 
5
3
  import type {
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  /*
2
4
  Prinsipper:
3
5
  - Fileupload-komponenten er stateless. All state må håndteres utenfor.
@@ -50,9 +52,9 @@ import {
50
52
  TFileTransfer,
51
53
  TFileValidateDetail,
52
54
  TItemRenderer,
53
- PktFileUploadContext,
54
55
  TQueueItemOperation,
55
56
  } from './types'
57
+ import { PktFileUploadContext } from './FileUploadContext'
56
58
  import { usePktStrings } from '../../hooks/usePktStrings'
57
59
  import { formatString, plural } from 'shared-strings'
58
60
 
@@ -0,0 +1,7 @@
1
+ 'use client'
2
+
3
+ import { createContext } from 'react'
4
+
5
+ import type { TPktFileUploadContext } from './types'
6
+
7
+ export const PktFileUploadContext = createContext<TPktFileUploadContext>({} as TPktFileUploadContext)
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import classNames from 'classnames'
2
4
  import { FC, useMemo } from 'react'
3
5
 
@@ -98,9 +100,7 @@ export const QueueDisplay: FC<IQueueDisplay> = ({
98
100
  .filter((op) => op.renderHidden)
99
101
  .map((operation) => (
100
102
  <span key={`${operation.id}-${transferItem.fileId}`}>
101
- {operation.renderHidden!(
102
- buildOperationContext({ operation, ...commonContentProps }),
103
- )}
103
+ {operation.renderHidden!(buildOperationContext({ operation, ...commonContentProps }))}
104
104
  </span>
105
105
  ))}
106
106
 
@@ -8,13 +8,8 @@ import { PktIcon } from '../icon/Icon'
8
8
  import { PktProgressbar } from '../progressbar/Progressbar'
9
9
  import { PktModal } from '../modal/Modal'
10
10
  import { Truncate } from './Truncate'
11
- import {
12
- PktFileUploadContext,
13
- TFileAndTransfer,
14
- TQueueItemOperation,
15
- TQueueOperationContext,
16
- TTransferItemInProgress,
17
- } from './types'
11
+ import { PktFileUploadContext } from './FileUploadContext'
12
+ import { TFileAndTransfer, TQueueItemOperation, TQueueOperationContext, TTransferItemInProgress } from './types'
18
13
  import { useImageObjectUrl } from './hooks'
19
14
  import { formatFileSize } from './utils'
20
15
 
@@ -5,7 +5,8 @@ import { formatString, type TPktStrings } from 'shared-strings'
5
5
  import { PktButton } from '../../button/Button'
6
6
  import { PktIcon } from '../../icon/Icon'
7
7
  import { PktTextarea } from '../../textarea/Textarea'
8
- import { FileItem, PktFileUploadContext, TQueueItemOperation, TQueueOperationContext } from '../types'
8
+ import { PktFileUploadContext } from '../FileUploadContext'
9
+ import { FileItem, TQueueItemOperation, TQueueOperationContext } from '../types'
9
10
 
10
11
  const COMMENTS_ATTRIBUTE = 'comments'
11
12
 
@@ -4,7 +4,8 @@ import type { TPktStrings } from 'shared-strings'
4
4
  import { getDisplayFilename } from 'shared-utils/fileupload'
5
5
 
6
6
  import { PktButton } from '../../button/Button'
7
- import { PktFileUploadContext, TQueueItemOperation, TQueueOperationContext } from '../types'
7
+ import { PktFileUploadContext } from '../FileUploadContext'
8
+ import { TQueueItemOperation, TQueueOperationContext } from '../types'
8
9
 
9
10
  interface IRenameFileProps {
10
11
  initialValue: string
@@ -1,4 +1,4 @@
1
- import { createContext, ReactElement, ReactNode } from 'react'
1
+ import type { ReactElement, ReactNode } from 'react'
2
2
 
3
3
  import type {
4
4
  IFileItem,
@@ -44,7 +44,6 @@ export type TPktFileUploadContext = {
44
44
  id?: string
45
45
  strings: TPktStrings['fileupload']
46
46
  }
47
- export const PktFileUploadContext = createContext<TPktFileUploadContext>({} as TPktFileUploadContext)
48
47
 
49
48
  /** The value type for `PktFileUpload` (`value` / `defaultValue`). */
50
49
  export type TFileItemList = Array<FileItem>
@@ -8,12 +8,6 @@ import { PktHeader } from './Header'
8
8
 
9
9
  expect.extend(toHaveNoViolations)
10
10
 
11
- // Mock useWindowWidth hook to control viewport size
12
- let mockedWidth = 1400
13
- vi.mock('../../hooks/useWindowWidth', () => ({
14
- useWindowWidth: () => mockedWidth,
15
- }))
16
-
17
11
  describe('PktHeader', () => {
18
12
  beforeAll(() => {
19
13
  // jsdom does not implement scrollTo; our scroll lock hook uses it
@@ -21,7 +15,6 @@ describe('PktHeader', () => {
21
15
  })
22
16
 
23
17
  beforeEach(() => {
24
- mockedWidth = 1400 // Reset to desktop by default
25
18
  vi.clearAllMocks()
26
19
  })
27
20
 
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import { ForwardedRef, forwardRef } from 'react'
4
2
 
5
3
  import { PktHeaderGlobal } from './HeaderGlobal'
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import classNames from 'classnames'
4
2
  import { forwardRef, HTMLAttributes, ReactNode } from 'react'
5
3
  import type { THeadingLevel, THeadingSize, THeadingWeight } from 'shared-types'
@@ -1,9 +1,9 @@
1
1
  'use client'
2
2
 
3
3
  import classNames from 'classnames'
4
- import { forwardRef, HTMLAttributes, ReactNode, useMemo, useState } from 'react'
5
- import { uuidish } from 'shared-utils/utils'
4
+ import { forwardRef, HTMLAttributes, ReactNode, useState } from 'react'
6
5
 
6
+ import { useGeneratedId } from '../../hooks/useGeneratedId'
7
7
  import { PktIcon } from '../icon/Icon'
8
8
 
9
9
  const defaultDropdownButton = "Les mer <span class='pkt-sr-only'>om feltet</span>"
@@ -40,8 +40,7 @@ export const PktHelptext = forwardRef<HTMLDivElement, IPktHelptextProps>(functio
40
40
  ) {
41
41
  const [isOpen, setIsOpen] = useState(false)
42
42
 
43
- const generatedId = useMemo(() => uuidish(), [])
44
- const forId = forIdProp || generatedId
43
+ const forId = useGeneratedId(forIdProp)
45
44
 
46
45
  const toggle = () => {
47
46
  const next = !isOpen
@@ -0,0 +1,32 @@
1
+ import { act } from '@testing-library/react'
2
+ import { hydrateRoot, type Root } from 'react-dom/client'
3
+ import { renderToString } from 'react-dom/server'
4
+ import { vi } from 'vitest'
5
+
6
+ import { serverRenderCases } from '../utils/serverRenderCases'
7
+
8
+ describe('hydration', () => {
9
+ test.each(serverRenderCases)('%s hydrates without mismatches', async (_name, element) => {
10
+ const container = document.createElement('div')
11
+ container.innerHTML = renderToString(element())
12
+ document.body.append(container)
13
+
14
+ const errors: string[] = []
15
+ const consoleError = vi.spyOn(console, 'error').mockImplementation((...args: unknown[]) => {
16
+ errors.push(args.map(String).join(' '))
17
+ })
18
+
19
+ let root: Root | undefined
20
+ await act(async () => {
21
+ root = hydrateRoot(container, element(), {
22
+ onRecoverableError: (error) => errors.push(String(error)),
23
+ })
24
+ })
25
+
26
+ consoleError.mockRestore()
27
+ act(() => root?.unmount())
28
+ container.remove()
29
+
30
+ expect(errors).toEqual([])
31
+ })
32
+ })
@@ -3,13 +3,6 @@ import '@testing-library/jest-dom'
3
3
  import { render, screen, waitFor } from '../../utils/test-utils'
4
4
  import { PktIcon } from './Icon'
5
5
 
6
- declare global {
7
- interface Window {
8
- pktFetch: () => Promise<{ ok: boolean; text: () => Promise<string> }>
9
- pktIconPath: string
10
- }
11
- }
12
-
13
6
  describe('PktIcon', () => {
14
7
  window.pktFetch = (file = 'filnavn.svg') =>
15
8
  Promise.resolve({
@@ -5,6 +5,13 @@ import { forwardRef, HTMLAttributes, MutableRefObject, useEffect, useLayoutEffec
5
5
  import type { PktIconName } from '@oslokommune/punkt-assets/dist/icons/icon'
6
6
  import { ICON_DEFAULTS, type Booleanish, type IPktIconBase } from 'shared-types'
7
7
 
8
+ declare global {
9
+ interface Window {
10
+ pktFetch?: (url: string) => Promise<Pick<Response, 'ok' | 'text'>>
11
+ pktIconPath?: string
12
+ }
13
+ }
14
+
8
15
  if (typeof window !== 'undefined') {
9
16
  window.pktFetch = window.pktFetch === undefined ? (fetch as unknown as typeof window.pktFetch) : window.pktFetch
10
17
  window.pktIconPath = window.pktIconPath || ICON_DEFAULTS.path
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import { ForwardedRef, forwardRef, type InputHTMLAttributes, type ReactElement } from 'react'
4
2
 
5
3
  interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
@@ -1,12 +1,12 @@
1
1
  'use client'
2
2
 
3
- import { type FocusEventHandler, ForwardedRef, forwardRef, type ReactNode, RefAttributes, useMemo } from 'react'
3
+ import { type FocusEventHandler, ForwardedRef, forwardRef, type ReactNode, RefAttributes } from 'react'
4
4
 
5
5
  import { useFocusModality } from '../../hooks/useFocusModality'
6
+ import { useGeneratedId } from '../../hooks/useGeneratedId'
6
7
  import { usePktStrings } from '../../hooks/usePktStrings'
7
8
  import { formatString, type IPktStringsProps } from 'shared-strings'
8
9
  import { counterStatusId, isCounterExceeded } from 'shared-utils/forms/described-by'
9
- import { uuidish } from 'shared-utils/utils'
10
10
  import type { TLayout } from 'shared-types'
11
11
  import { PktAlert } from '../alert/Alert'
12
12
  import { PktHelptext } from '../helptext/Helptext'
@@ -85,8 +85,7 @@ export const PktInputWrapper = forwardRef(
85
85
  const focusModality = useFocusModality<HTMLDivElement>(ref)
86
86
  const s = usePktStrings(['forms', 'validation'], strings)
87
87
 
88
- const generatedId = useMemo(() => uuidish(), [])
89
- const forId = forIdProp || generatedId
88
+ const forId = useGeneratedId(forIdProp)
90
89
 
91
90
  const describedBy =
92
91
  [
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import classNames from 'classnames'
4
2
  import { AnchorHTMLAttributes, FC, LinkHTMLAttributes, ReactNode } from 'react'
5
3
  import type { TRenderLink } from 'shared-types'
@@ -34,9 +34,7 @@ describe('PktProgressbar', () => {
34
34
  })
35
35
 
36
36
  test('renders title correctly', () => {
37
- const { container, getByText } = render(
38
- <PktProgressbar id="progress3" valueCurrent={50} title="Progress" />,
39
- )
37
+ const { container, getByText } = render(<PktProgressbar id="progress3" valueCurrent={50} title="Progress" />)
40
38
 
41
39
  const progressbar = container.firstChild as HTMLElement
42
40
 
@@ -56,9 +54,7 @@ describe('PktProgressbar', () => {
56
54
  })
57
55
 
58
56
  test('renders status as percentage', () => {
59
- const { container } = render(
60
- <PktProgressbar id="progress5" valueCurrent={50} statusType="percentage" />,
61
- )
57
+ const { container } = render(<PktProgressbar id="progress5" valueCurrent={50} statusType="percentage" />)
62
58
  const status = container.querySelector('.pkt-progressbar__status')
63
59
  expect(status).toBeInTheDocument()
64
60
  expect(status).toHaveTextContent('50%')
@@ -75,12 +71,7 @@ describe('PktProgressbar', () => {
75
71
 
76
72
  test('renders status with center placement', () => {
77
73
  const { container } = render(
78
- <PktProgressbar
79
- id="progress7"
80
- valueCurrent={50}
81
- statusType="percentage"
82
- statusPlacement="center"
83
- />,
74
+ <PktProgressbar id="progress7" valueCurrent={50} statusType="percentage" statusPlacement="center" />,
84
75
  )
85
76
  const status = container.querySelector('.pkt-progressbar__status--center')
86
77
  expect(status).toBeInTheDocument()
@@ -88,21 +79,14 @@ describe('PktProgressbar', () => {
88
79
 
89
80
  test('renders status with following placement', () => {
90
81
  const { container } = render(
91
- <PktProgressbar
92
- id="progress8"
93
- valueCurrent={50}
94
- statusType="percentage"
95
- statusPlacement="following"
96
- />,
82
+ <PktProgressbar id="progress8" valueCurrent={50} statusType="percentage" statusPlacement="following" />,
97
83
  )
98
84
  const status = container.querySelector('.pkt-progressbar__status-placement--following')
99
85
  expect(status).toBeInTheDocument()
100
86
  })
101
87
 
102
88
  test('handles aria-label correctly', () => {
103
- const { container } = render(
104
- <PktProgressbar id="progress9" valueCurrent={50} ariaLabel="Progress bar" />,
105
- )
89
+ const { container } = render(<PktProgressbar id="progress9" valueCurrent={50} ariaLabel="Progress bar" />)
106
90
  const progressbar = container.firstChild as HTMLElement
107
91
  expect(progressbar).toHaveAttribute('aria-label', 'Progress bar')
108
92
  expect(progressbar).not.toHaveAttribute('aria-labelledby')
@@ -117,9 +101,7 @@ describe('PktProgressbar', () => {
117
101
  })
118
102
 
119
103
  test('handles id for title and aria-labelledby correctly', () => {
120
- const { container } = render(
121
- <PktProgressbar valueCurrent={50} title="Progress" id="progressId" />,
122
- )
104
+ const { container } = render(<PktProgressbar valueCurrent={50} title="Progress" id="progressId" />)
123
105
 
124
106
  const progressbar = container.firstChild as HTMLElement
125
107
 
@@ -132,15 +114,12 @@ describe('PktProgressbar', () => {
132
114
 
133
115
  const progressbar = container.firstChild as HTMLElement
134
116
 
135
- const id = progressbar?.getAttribute('id')
136
- expect(id).toHaveLength(36)
117
+ expect(progressbar.id).toMatch(/^[\w-]+$/)
137
118
  })
138
119
 
139
120
  test('sets ref correctly', () => {
140
121
  const ref = createRef<HTMLDivElement>()
141
- const { unmount } = render(
142
- <PktProgressbar ref={ref} id="progress-ref" valueCurrent={50} title="Ref bar" />,
143
- )
122
+ const { unmount } = render(<PktProgressbar ref={ref} id="progress-ref" valueCurrent={50} title="Ref bar" />)
144
123
 
145
124
  expect(ref.current).toBeInstanceOf(HTMLDivElement)
146
125
  unmount()
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
 
3
3
  import classNames from 'classnames'
4
- import { forwardRef, HTMLAttributes, Ref, useEffect, useMemo, useRef, useState } from 'react'
4
+ import { forwardRef, HTMLAttributes, Ref, useEffect, useRef, useState } from 'react'
5
5
  import type {
6
6
  TAriaLive,
7
7
  TProgressbarRole,
@@ -10,9 +10,15 @@ import type {
10
10
  TProgressbarStatusType,
11
11
  TProgressbarTitlePosition,
12
12
  } from 'shared-types'
13
- import { uuidish } from 'shared-utils/utils'
13
+ import { useGeneratedId } from '../../hooks/useGeneratedId'
14
14
 
15
- export type { TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition }
15
+ export type {
16
+ TProgressbarRole,
17
+ TProgressbarSkin,
18
+ TProgressbarStatusPlacement,
19
+ TProgressbarStatusType,
20
+ TProgressbarTitlePosition,
21
+ }
16
22
 
17
23
  export interface IPktProgressbar extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'title'> {
18
24
  ariaLabel?: string | null
@@ -54,8 +60,7 @@ export const PktProgressbar = forwardRef<HTMLDivElement, IPktProgressbar>(
54
60
  },
55
61
  ref,
56
62
  ) => {
57
- const generatedId = useMemo(() => uuidish(), [])
58
- const progressbarId = id || generatedId
63
+ const progressbarId = useGeneratedId(id)
59
64
 
60
65
  const labelRef = useRef<HTMLSpanElement>(null)
61
66
  const [labelWidth, setLabelWidth] = useState(0)
@@ -79,9 +84,7 @@ export const PktProgressbar = forwardRef<HTMLDivElement, IPktProgressbar>(
79
84
  ? `${valueCurrent} av ${valueMax - valueMin}`
80
85
  : ariaValueText || undefined
81
86
 
82
- const computedAriaLabelledby = !ariaLabel
83
- ? ariaLabelledby || `${progressbarId}-title`
84
- : undefined
87
+ const computedAriaLabelledby = !ariaLabel ? ariaLabelledby || `${progressbarId}-title` : undefined
85
88
 
86
89
  return (
87
90
  <div
@@ -101,10 +104,12 @@ export const PktProgressbar = forwardRef<HTMLDivElement, IPktProgressbar>(
101
104
  >
102
105
  <div
103
106
  className="pkt-progressbar__container"
104
- style={{
105
- '--pkt-progress-label-width': `${labelWidth}px`,
106
- '--pkt-progress-width': `${currentPercentage}%`,
107
- } as React.CSSProperties}
107
+ style={
108
+ {
109
+ '--pkt-progress-label-width': `${labelWidth}px`,
110
+ '--pkt-progress-width': `${currentPercentage}%`,
111
+ } as React.CSSProperties
112
+ }
108
113
  >
109
114
  {title && (
110
115
  <p
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import {
2
4
  ChangeEvent,
3
5
  ChangeEventHandler,
@@ -1,11 +1,11 @@
1
1
  'use client'
2
2
 
3
- import { ChangeEvent, forwardRef, HTMLProps, ReactNode, useMemo } from 'react'
4
- import { uuidish } from 'shared-utils/utils'
3
+ import { ChangeEvent, forwardRef, HTMLProps, ReactNode } from 'react'
5
4
 
6
5
  import type { IPktSearchInputSuggestion } from 'shared-types/searchinput'
7
6
 
8
7
  import { useFocusModality } from '../../hooks/useFocusModality'
8
+ import { useGeneratedId } from '../../hooks/useGeneratedId'
9
9
  import { PktButton } from '../button/Button'
10
10
  import { usePktStrings } from '../../hooks/usePktStrings'
11
11
  import type { IPktStringsProps } from 'shared-strings'
@@ -96,8 +96,7 @@ export const PktSearchInput = forwardRef<HTMLInputElement, ISearchInput | ISearc
96
96
  .filter(Boolean)
97
97
  .join(' ')
98
98
 
99
- const generatedId = useMemo(() => uuidish(), [])
100
- const id = idProp || generatedId
99
+ const id = useGeneratedId(idProp)
101
100
 
102
101
  const focusModality = useFocusModality()
103
102