@oslokommune/punkt-react 19.15.6 → 19.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/CHANGELOG.md +30 -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.js +62 -0
  67. package/dist/components/radio/RadioButton.js +85 -0
  68. package/dist/components/radiogroup/RadioGroup.js +70 -0
  69. package/dist/components/radiogroup/RadioGroupContext.js +5 -0
  70. package/dist/components/searchinput/SearchInput.js +102 -0
  71. package/dist/components/select/Select.js +56 -0
  72. package/dist/components/stepper/Step.js +78 -0
  73. package/dist/components/stepper/Stepper.js +21 -0
  74. package/dist/components/strings/PktStringsProvider.js +21 -0
  75. package/dist/components/table/Table.js +19 -0
  76. package/dist/components/table/TableBody.js +13 -0
  77. package/dist/components/table/TableDataCell.js +14 -0
  78. package/dist/components/table/TableHeader.js +12 -0
  79. package/dist/components/table/TableHeaderCell.js +12 -0
  80. package/dist/components/table/TableRow.js +12 -0
  81. package/dist/components/tabs/TabItem.js +60 -0
  82. package/dist/components/tabs/Tabs.js +90 -0
  83. package/dist/components/tag/Tag.js +76 -0
  84. package/dist/components/textarea/Textarea.js +74 -0
  85. package/dist/components/textinput/Textinput.js +106 -0
  86. package/dist/components/timepicker/Timepicker.js +224 -0
  87. package/dist/components/timepicker/useTimepickerState.js +483 -0
  88. package/dist/hooks/useElementWidth.js +23 -0
  89. package/dist/hooks/useFocusModality.js +28 -0
  90. package/dist/hooks/useGeneratedId.js +8 -0
  91. package/dist/hooks/useHeaderChrome.js +36 -0
  92. package/dist/hooks/useOptionGroupField.js +70 -0
  93. package/dist/hooks/useOwnerForm.js +15 -0
  94. package/dist/hooks/usePktStrings.js +16 -0
  95. package/dist/hooks/useScrollLock.js +12 -0
  96. package/dist/node_modules/@date-fns/tz/date/index.js +57 -0
  97. package/dist/node_modules/@date-fns/tz/date/mini.js +75 -0
  98. package/dist/node_modules/@date-fns/tz/index.js +6 -0
  99. package/dist/node_modules/@date-fns/tz/tz/index.js +1 -0
  100. package/dist/node_modules/@date-fns/tz/tzName/index.js +10 -0
  101. package/dist/node_modules/@date-fns/tz/tzOffset/index.js +22 -0
  102. package/dist/node_modules/classnames/index.js +32 -0
  103. package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +6 -0
  104. package/dist/node_modules/date-fns/_lib/defaultOptions.js +7 -0
  105. package/dist/node_modules/date-fns/_lib/format/formatters.js +389 -0
  106. package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +43 -0
  107. package/dist/node_modules/date-fns/_lib/format/longFormatters.js +38 -0
  108. package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +8 -0
  109. package/dist/node_modules/date-fns/_lib/normalizeDates.js +8 -0
  110. package/dist/node_modules/date-fns/_lib/normalizeInterval.js +11 -0
  111. package/dist/node_modules/date-fns/_lib/protectedTokens.js +23 -0
  112. package/dist/node_modules/date-fns/addDays.js +9 -0
  113. package/dist/node_modules/date-fns/constants.js +10 -0
  114. package/dist/node_modules/date-fns/constructFrom.js +7 -0
  115. package/dist/node_modules/date-fns/differenceInCalendarDays.js +11 -0
  116. package/dist/node_modules/date-fns/eachDayOfInterval.js +15 -0
  117. package/dist/node_modules/date-fns/endOfDay.js +8 -0
  118. package/dist/node_modules/date-fns/format.js +59 -0
  119. package/dist/node_modules/date-fns/getDayOfYear.js +10 -0
  120. package/dist/node_modules/date-fns/getISODay.js +8 -0
  121. package/dist/node_modules/date-fns/getISOWeek.js +11 -0
  122. package/dist/node_modules/date-fns/getISOWeekYear.js +14 -0
  123. package/dist/node_modules/date-fns/getWeek.js +11 -0
  124. package/dist/node_modules/date-fns/getWeekYear.js +15 -0
  125. package/dist/node_modules/date-fns/isDate.js +6 -0
  126. package/dist/node_modules/date-fns/isValid.js +8 -0
  127. package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +9 -0
  128. package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +17 -0
  129. package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +22 -0
  130. package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +18 -0
  131. package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +69 -0
  132. package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +32 -0
  133. package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +11 -0
  134. package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +202 -0
  135. package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +124 -0
  136. package/dist/node_modules/date-fns/locale/en-US.js +20 -0
  137. package/dist/node_modules/date-fns/startOfDay.js +8 -0
  138. package/dist/node_modules/date-fns/startOfISOWeek.js +10 -0
  139. package/dist/node_modules/date-fns/startOfISOWeekYear.js +10 -0
  140. package/dist/node_modules/date-fns/startOfWeek.js +9 -0
  141. package/dist/node_modules/date-fns/startOfWeekYear.js +11 -0
  142. package/dist/node_modules/date-fns/startOfYear.js +8 -0
  143. package/dist/node_modules/date-fns/toDate.js +7 -0
  144. package/dist/punkt-react.cjs +1 -1
  145. package/dist/punkt-react.js +55 -9388
  146. package/dist/shared-strings/consent.js +113 -0
  147. package/dist/shared-strings/format.js +18 -0
  148. package/dist/shared-strings/nb.js +201 -0
  149. package/dist/shared-strings/resolve.js +40 -0
  150. package/dist/shared-strings/store.js +35 -0
  151. package/dist/shared-types/accordion.js +4 -0
  152. package/dist/shared-types/calendar.js +12 -0
  153. package/dist/shared-types/card.js +15 -0
  154. package/dist/shared-types/checkbox.js +15 -0
  155. package/dist/shared-types/combobox.js +19 -0
  156. package/dist/shared-types/consent.js +8 -0
  157. package/dist/shared-types/footer.js +4 -0
  158. package/dist/shared-types/header-footer.js +4 -0
  159. package/dist/shared-types/icon.js +7 -0
  160. package/dist/shared-types/messagebox.js +8 -0
  161. package/dist/shared-types/option-group.js +14 -0
  162. package/dist/shared-types/radiobutton.js +11 -0
  163. package/dist/shared-types/select.js +14 -0
  164. package/dist/shared-types/table.js +8 -0
  165. package/dist/shared-utils/calendar/calendar-grid.js +19 -0
  166. package/dist/shared-utils/calendar/date-validation.js +19 -0
  167. package/dist/shared-utils/calendar/keyboard-navigation.js +26 -0
  168. package/dist/shared-utils/calendar/selection-manager.js +52 -0
  169. package/dist/shared-utils/combobox/input-utils.js +39 -0
  170. package/dist/shared-utils/combobox/keyboard-navigation.js +41 -0
  171. package/dist/shared-utils/combobox/option-utils.js +48 -0
  172. package/dist/shared-utils/date-utils.js +71 -0
  173. package/dist/shared-utils/datepicker-utils.js +32 -0
  174. package/dist/shared-utils/device-utils.js +7 -0
  175. package/dist/shared-utils/fileupload/announcements.js +21 -0
  176. package/dist/shared-utils/fileupload/filename.js +8 -0
  177. package/dist/shared-utils/fileupload/focus-trap.js +2 -0
  178. package/dist/shared-utils/fileupload/formats.js +29 -0
  179. package/dist/shared-utils/fileupload/index.js +11 -0
  180. package/dist/shared-utils/fileupload/navigation.js +6 -0
  181. package/dist/shared-utils/fileupload/size.js +25 -0
  182. package/dist/shared-utils/fileupload/transfers.js +23 -0
  183. package/dist/shared-utils/fileupload/truncate.js +9 -0
  184. package/dist/shared-utils/fileupload/validation.js +32 -0
  185. package/dist/shared-utils/focus-trap/index.js +60 -0
  186. package/dist/shared-utils/forms/described-by.js +7 -0
  187. package/dist/shared-utils/header-footer/external-domain.js +30 -0
  188. package/dist/shared-utils/header-footer/fetch-header-footer-data.js +29 -0
  189. package/dist/shared-utils/header-footer/icon-map.js +55 -0
  190. package/dist/shared-utils/header-footer/select-megamenu.js +7 -0
  191. package/dist/shared-utils/scroll-lock/index.js +21 -0
  192. package/dist/shared-utils/timepicker/options.js +10 -0
  193. package/dist/shared-utils/timepicker/stepper.js +10 -0
  194. package/dist/shared-utils/timepicker/time-utils.js +7 -0
  195. package/dist/shared-utils/value-utils.js +12 -0
  196. package/dist/utils/nativeInputValue.js +6 -0
  197. package/dist/utils/stableKeys.js +13 -0
  198. package/dist/utils/stringutils.js +7 -0
  199. package/package.json +3 -2
  200. package/src/components/checkbox/Checkbox.tsx +2 -0
  201. package/src/components/combobox/types.ts +0 -2
  202. package/src/components/fileupload/FileUpload.tsx +3 -1
  203. package/src/components/fileupload/FileUploadContext.ts +7 -0
  204. package/src/components/fileupload/QueueDisplay.tsx +3 -3
  205. package/src/components/fileupload/Subcomponents.tsx +2 -7
  206. package/src/components/fileupload/extensions/Comments.tsx +2 -1
  207. package/src/components/fileupload/extensions/Rename.tsx +2 -1
  208. package/src/components/fileupload/types.ts +1 -2
  209. package/src/components/header/Header.test.tsx +0 -7
  210. package/src/components/header/Header.tsx +0 -2
  211. package/src/components/heading/Heading.tsx +0 -2
  212. package/src/components/hydration.test.tsx +61 -15
  213. package/src/components/icon/Icon.test.tsx +0 -7
  214. package/src/components/icon/Icon.tsx +7 -0
  215. package/src/components/input/Input.tsx +0 -2
  216. package/src/components/link/Link.tsx +0 -2
  217. package/src/components/radio/RadioButton.tsx +2 -0
  218. package/src/components/server-components.test.ts +69 -0
  219. package/src/components/stepper/Step.tsx +0 -2
  220. package/src/components/stepper/Stepper.tsx +0 -2
  221. package/src/components/strings/PktStringsProvider.tsx +2 -0
  222. package/src/components/table/Table.tsx +0 -2
  223. package/src/components/table/TableBody.tsx +1 -3
  224. package/src/components/table/TableDataCell.tsx +0 -2
  225. package/src/components/table/TableHeader.tsx +0 -2
  226. package/src/components/table/TableHeaderCell.tsx +0 -2
  227. package/src/components/table/TableRow.tsx +0 -2
  228. package/dist/components/accordion/Accordion.test.d.ts +0 -0
  229. package/dist/components/alert/Alert.test.d.ts +0 -0
  230. package/dist/components/backlink/BackLink.test.d.ts +0 -0
  231. package/dist/components/breadcrumbs/Breadcrumbs.test.d.ts +0 -1
  232. package/dist/components/button/Button.test.d.ts +0 -0
  233. package/dist/components/calendar/Calendar.accessibility.test.d.ts +0 -0
  234. package/dist/components/calendar/Calendar.constraints.test.d.ts +0 -0
  235. package/dist/components/calendar/Calendar.core.test.d.ts +0 -0
  236. package/dist/components/calendar/Calendar.interaction.test.d.ts +0 -0
  237. package/dist/components/calendar/Calendar.selection.test.d.ts +0 -0
  238. package/dist/components/card/Card.test.d.ts +0 -0
  239. package/dist/components/checkbox/Checkbox.test.d.ts +0 -0
  240. package/dist/components/checkboxgroup/CheckboxGroup.forms.test.d.ts +0 -0
  241. package/dist/components/checkboxgroup/CheckboxGroup.test.d.ts +0 -0
  242. package/dist/components/combobox/Combobox.accessibility.test.d.ts +0 -0
  243. package/dist/components/combobox/Combobox.core.test.d.ts +0 -0
  244. package/dist/components/combobox/Combobox.interaction.test.d.ts +0 -0
  245. package/dist/components/combobox/Combobox.preselection.test.d.ts +0 -0
  246. package/dist/components/combobox/Combobox.selection.test.d.ts +0 -0
  247. package/dist/components/consent/Consent.test.d.ts +0 -0
  248. package/dist/components/datepicker/Datepicker.accessibility.test.d.ts +0 -0
  249. package/dist/components/datepicker/Datepicker.core.test.d.ts +0 -0
  250. package/dist/components/datepicker/Datepicker.input.test.d.ts +0 -0
  251. package/dist/components/datepicker/Datepicker.selection.test.d.ts +0 -0
  252. package/dist/components/datepicker/Datepicker.validation.test.d.ts +0 -0
  253. package/dist/components/fileupload/FileUpload.test.d.ts +0 -0
  254. package/dist/components/fileupload/QueueDisplay.test.d.ts +0 -0
  255. package/dist/components/fileupload/Truncate.test.d.ts +0 -0
  256. package/dist/components/footer/Footer.accessibility.test.d.ts +0 -0
  257. package/dist/components/footer/Footer.test.d.ts +0 -1
  258. package/dist/components/footerSimple/FooterSimple.test.d.ts +0 -1
  259. package/dist/components/formAttribute.test.d.ts +0 -1
  260. package/dist/components/header/Header.test.d.ts +0 -0
  261. package/dist/components/header/HeaderGlobal.accessibility.test.d.ts +0 -0
  262. package/dist/components/header/HeaderGlobal.test.d.ts +0 -0
  263. package/dist/components/header/HeaderService.accessibility.test.d.ts +0 -0
  264. package/dist/components/header/HeaderService.test.d.ts +0 -0
  265. package/dist/components/header-menu/HeaderMenu.test.d.ts +0 -0
  266. package/dist/components/headerUserMenu/UserMenu.test.d.ts +0 -0
  267. package/dist/components/heading/Heading.test.d.ts +0 -0
  268. package/dist/components/helptext/Helptext.test.d.ts +0 -0
  269. package/dist/components/helptext/helptextAssociation.test.d.ts +0 -1
  270. package/dist/components/hydration.test.d.ts +0 -1
  271. package/dist/components/icon/Icon.test.d.ts +0 -9
  272. package/dist/components/inputwrapper/InputWrapper.test.d.ts +0 -0
  273. package/dist/components/link/Link.test.d.ts +0 -1
  274. package/dist/components/linkcard/LinkCard.test.d.ts +0 -0
  275. package/dist/components/loader/Loader.test.d.ts +0 -0
  276. package/dist/components/messagebox/Messagebox.test.d.ts +0 -1
  277. package/dist/components/modal/Modal.test.d.ts +0 -0
  278. package/dist/components/progressbar/Progressbar.test.d.ts +0 -0
  279. package/dist/components/radio/RadioButton.test.d.ts +0 -0
  280. package/dist/components/radiogroup/RadioGroup.forms.test.d.ts +0 -0
  281. package/dist/components/radiogroup/RadioGroup.test.d.ts +0 -0
  282. package/dist/components/searchinput/SearchInput.test.d.ts +0 -0
  283. package/dist/components/select/Select.test.d.ts +0 -0
  284. package/dist/components/ssr.test.d.ts +0 -1
  285. package/dist/components/stepper/Stepper.test.d.ts +0 -0
  286. package/dist/components/strings/strings-override.test.d.ts +0 -1
  287. package/dist/components/table/Table.test.d.ts +0 -0
  288. package/dist/components/tabs/Tabs.test.d.ts +0 -0
  289. package/dist/components/tag/Tag.test.d.ts +0 -0
  290. package/dist/components/textarea/Textarea.test.d.ts +0 -0
  291. package/dist/components/textinput/Textinput.test.d.ts +0 -0
  292. 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.6",
3
+ "version": "19.16.1",
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": "573e87674ae6282cb3c4b0d4954a944aa3027899"
105
+ "gitHead": "1993393adcd70a3f8ee48c7645e546dd78f127e6"
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,32 +1,78 @@
1
1
  import { act } from '@testing-library/react'
2
+ import type { ReactElement } from 'react'
2
3
  import { hydrateRoot, type Root } from 'react-dom/client'
3
4
  import { renderToString } from 'react-dom/server'
4
5
  import { vi } from 'vitest'
5
6
 
6
7
  import { serverRenderCases } from '../utils/serverRenderCases'
8
+ import { PktHeaderGlobal, PktHeaderService } from './index'
7
9
 
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)
10
+ const hydrate = async (element: () => ReactElement, { serverWithoutWindow = false } = {}) => {
11
+ if (serverWithoutWindow) vi.stubGlobal('window', undefined)
12
+ const html = renderToString(element())
13
+ vi.unstubAllGlobals()
13
14
 
14
- const errors: string[] = []
15
- const consoleError = vi.spyOn(console, 'error').mockImplementation((...args: unknown[]) => {
16
- errors.push(args.map(String).join(' '))
17
- })
15
+ const container = document.createElement('div')
16
+ container.innerHTML = html
17
+ document.body.append(container)
18
+
19
+ const errors: string[] = []
20
+ const consoleError = vi.spyOn(console, 'error').mockImplementation((...args: unknown[]) => {
21
+ errors.push(args.map(String).join(' '))
22
+ })
18
23
 
19
- let root: Root | undefined
20
- await act(async () => {
21
- root = hydrateRoot(container, element(), {
22
- onRecoverableError: (error) => errors.push(String(error)),
23
- })
24
+ let root: Root | undefined
25
+ await act(async () => {
26
+ root = hydrateRoot(container, element(), {
27
+ onRecoverableError: (error) => errors.push(String(error)),
24
28
  })
29
+ })
30
+ consoleError.mockRestore()
25
31
 
26
- consoleError.mockRestore()
32
+ const cleanup = () => {
27
33
  act(() => root?.unmount())
28
34
  container.remove()
35
+ }
36
+ return { container, errors, cleanup }
37
+ }
38
+
39
+ describe('hydration', () => {
40
+ test.each(serverRenderCases)('%s hydrates without mismatches', async (_name, element) => {
41
+ const { errors, cleanup } = await hydrate(element)
42
+ cleanup()
29
43
 
30
44
  expect(errors).toEqual([])
31
45
  })
32
46
  })
47
+
48
+ describe('hydration at phone width', () => {
49
+ let innerWidth: number
50
+
51
+ beforeEach(() => {
52
+ innerWidth = window.innerWidth
53
+ Object.defineProperty(window, 'innerWidth', { value: 375, configurable: true })
54
+ })
55
+
56
+ afterEach(() => {
57
+ Object.defineProperty(window, 'innerWidth', { value: innerWidth, configurable: true })
58
+ })
59
+
60
+ test.each([
61
+ [
62
+ 'PktHeaderService',
63
+ () => <PktHeaderService serviceName="Service" user={{ name: 'Test User' }} logOut={() => {}} />,
64
+ 'pkt-header-service--mobile',
65
+ ],
66
+ ['PktHeaderGlobal', () => <PktHeaderGlobal />, 'pkt-header-global--mobile'],
67
+ ] as const)(
68
+ '%s hydrates the server markup and then switches to the mobile layout',
69
+ async (_name, element, mobileClass) => {
70
+ const { container, errors, cleanup } = await hydrate(element, { serverWithoutWindow: true })
71
+ const headerClasses = container.querySelector('header')?.className.split(' ') ?? []
72
+ cleanup()
73
+
74
+ expect(errors).toEqual([])
75
+ expect(headerClasses).toContain(mobileClass)
76
+ },
77
+ )
78
+ })
@@ -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,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'
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import {
2
4
  ChangeEvent,
3
5
  ChangeEventHandler,
@@ -0,0 +1,69 @@
1
+ // @vitest-environment node
2
+ import { existsSync, readFileSync } from 'node:fs'
3
+ import { createRequire } from 'node:module'
4
+ import { dirname, join, relative, resolve } from 'node:path'
5
+
6
+ const require = createRequire(import.meta.url)
7
+ const reactDir = dirname(require.resolve('react/package.json'))
8
+ const clientReactApis = new Set(Object.keys(require('react')))
9
+ const serverReactApis = new Set(Object.keys(require(join(reactDir, 'react.react-server.js'))))
10
+
11
+ const srcDir = resolve(import.meta.dirname, '..')
12
+ const IMPORT = /(?:^|\n)\s*(?:import|export)(\s+type)?\s+([^;]*?)\s*from\s*['"]([^'"]+)['"]/g
13
+
14
+ const isClientModule = (source: string) => /^\s*['"]use client['"]/.test(source)
15
+
16
+ const resolveModule = (from: string, specifier: string): string | null => {
17
+ if (!specifier.startsWith('.') && !specifier.startsWith('@/')) return null
18
+ const base = specifier.startsWith('@/') ? join(srcDir, specifier.slice(2)) : resolve(dirname(from), specifier)
19
+ const candidates = [`${base}.ts`, `${base}.tsx`, join(base, 'index.ts'), join(base, 'index.tsx'), base]
20
+ const found = candidates.find((candidate) => /\.tsx?$/.test(candidate) && existsSync(candidate))
21
+ if (!found) throw new Error(`Cannot resolve ${specifier} from ${from}`)
22
+ return found
23
+ }
24
+
25
+ const reactRuntimeImports = (clause: string) =>
26
+ (clause.match(/\{([\s\S]*)\}/)?.[1] ?? '')
27
+ .split(',')
28
+ .map((name) => name.trim())
29
+ .filter((name) => name && !name.startsWith('type '))
30
+ .map((name) => name.split(/\s+as\s+/)[0])
31
+ .filter((name) => clientReactApis.has(name))
32
+
33
+ const findServerModules = () => {
34
+ const modules = new Map<string, string>()
35
+ const queue = [join(srcDir, 'index.ts')]
36
+ while (queue.length) {
37
+ const file = queue.shift()!
38
+ if (modules.has(file)) continue
39
+ const source = readFileSync(file, 'utf8')
40
+ if (isClientModule(source)) continue
41
+ modules.set(file, source)
42
+ for (const [, typeOnly, , specifier] of source.matchAll(IMPORT)) {
43
+ const target = !typeOnly && resolveModule(file, specifier)
44
+ if (target) queue.push(target)
45
+ }
46
+ }
47
+ return modules
48
+ }
49
+
50
+ const serverModules = [...findServerModules()].map(
51
+ ([file, source]) => [relative(srcDir, file), source] as [string, string],
52
+ )
53
+
54
+ describe('server components', () => {
55
+ test('the package entry is a server module', () => {
56
+ expect(serverModules.map(([file]) => file)).toContain('index.ts')
57
+ })
58
+
59
+ test.each(serverModules)('%s works without the client runtime', (_file, source) => {
60
+ const clientOnlyReactApis = [...source.matchAll(IMPORT)]
61
+ .filter(([, typeOnly, , specifier]) => !typeOnly && specifier === 'react')
62
+ .flatMap(([, , clause]) => reactRuntimeImports(clause))
63
+ .filter((name) => !serverReactApis.has(name))
64
+
65
+ expect(clientOnlyReactApis).toEqual([])
66
+ expect(source).not.toMatch(/\son[A-Z]\w*=\{/)
67
+ expect(source).not.toMatch(/\b(window|document)\./)
68
+ })
69
+ })
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import cn from 'classnames'
4
2
  import type { ReactNode } from 'react'
5
3
 
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import classNames from 'classnames'
4
2
  import { Children, cloneElement, forwardRef, type HTMLAttributes, isValidElement, ReactElement, Ref } from 'react'
5
3
 
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import { createContext, useContext, useMemo, type ReactNode } from 'react'
2
4
  import type { TPktStringsOverride } from 'shared-strings'
3
5
 
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import classNames from 'classnames'
4
2
  import type { HTMLAttributes, ReactNode } from 'react'
5
3
  import { TABLE_DEFAULTS, type IPktTableBase, type TPktTableSkin } from 'shared-types'
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import classNames from 'classnames'
4
2
  import type { HTMLAttributes, ReactNode } from 'react'
5
3
 
@@ -9,7 +7,7 @@ interface ITableBodyProps extends HTMLAttributes<HTMLTableSectionElement> {
9
7
  }
10
8
 
11
9
  export const PktTableBody = ({ id, children, className, ...props }: ITableBodyProps) => (
12
- <tbody id={id} className={classNames(className, 'pkt-table__body', {})} role="rowgroup" {...props} >
10
+ <tbody id={id} className={classNames(className, 'pkt-table__body', {})} role="rowgroup" {...props}>
13
11
  {children}
14
12
  </tbody>
15
13
  )
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import classNames from 'classnames'
4
2
  import type { HTMLAttributes, ReactNode } from 'react'
5
3
  import type { IPktTableDataCellBase } from 'shared-types'
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import classNames from 'classnames'
4
2
  import type { HTMLAttributes, ReactNode } from 'react'
5
3
 
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import classNames from 'classnames'
4
2
  import type { HTMLAttributes, ReactNode } from 'react'
5
3
 
@@ -1,5 +1,3 @@
1
- 'use client'
2
-
3
1
  import classNames from 'classnames'
4
2
  import type { HTMLAttributes, ReactNode } from 'react'
5
3
 
File without changes
File without changes
File without changes
@@ -1 +0,0 @@
1
- export {};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes