@oslokommune/punkt-react 19.15.6 → 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.
- package/CHANGELOG.md +19 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/accordion/Accordion.js +28 -0
- package/dist/components/accordion/AccordionItem.js +60 -0
- package/dist/components/alert/Alert.js +76 -0
- package/dist/components/backlink/BackLink.js +35 -0
- package/dist/components/breadcrumbs/Breadcrumbs.js +67 -0
- package/dist/components/button/Button.js +54 -0
- package/dist/components/calendar/Calendar.js +49 -0
- package/dist/components/calendar/CalendarGrid.js +99 -0
- package/dist/components/calendar/CalendarNav.js +89 -0
- package/dist/components/calendar/calendar-utils.js +44 -0
- package/dist/components/calendar/useCalendarState.js +214 -0
- package/dist/components/card/Card.js +99 -0
- package/dist/components/checkbox/Checkbox.js +101 -0
- package/dist/components/checkboxgroup/CheckboxGroup.js +88 -0
- package/dist/components/checkboxgroup/CheckboxGroupContext.js +5 -0
- package/dist/components/combobox/Combobox.js +65 -0
- package/dist/components/combobox/ComboboxInput.js +87 -0
- package/dist/components/combobox/ComboboxTags.js +82 -0
- package/dist/components/combobox/Listbox.js +136 -0
- package/dist/components/combobox/useComboboxState.js +577 -0
- package/dist/components/consent/Consent.js +110 -0
- package/dist/components/datepicker/DateTags.js +28 -0
- package/dist/components/datepicker/Datepicker.js +79 -0
- package/dist/components/datepicker/DatepickerInputs.js +149 -0
- package/dist/components/datepicker/DatepickerPopup.js +41 -0
- package/dist/components/datepicker/useDatepickerState.js +243 -0
- package/dist/components/fileupload/DropZone.js +131 -0
- package/dist/components/fileupload/FileUpload.js +223 -0
- package/dist/components/fileupload/FileUploadContext.d.ts +2 -0
- package/dist/components/fileupload/FileUploadContext.js +6 -0
- package/dist/components/fileupload/QueueDisplay.js +67 -0
- package/dist/components/fileupload/QueueItemContent.js +88 -0
- package/dist/components/fileupload/Subcomponents.js +265 -0
- package/dist/components/fileupload/Truncate.js +22 -0
- package/dist/components/fileupload/extensions/Comments.js +128 -0
- package/dist/components/fileupload/extensions/Remove.js +9 -0
- package/dist/components/fileupload/extensions/Rename.js +66 -0
- package/dist/components/fileupload/hooks/useFileAttributes.js +25 -0
- package/dist/components/fileupload/hooks/useImageObjectUrl.js +15 -0
- package/dist/components/fileupload/hooks/useImagePreview.js +24 -0
- package/dist/components/fileupload/hooks/useOperationState.js +31 -0
- package/dist/components/fileupload/hooks/useRequiredFormValidation.js +23 -0
- package/dist/components/fileupload/types.d.ts +0 -1
- package/dist/components/fileupload/types.js +12 -0
- package/dist/components/footer/Footer.js +134 -0
- package/dist/components/footer/FooterGlobal.js +105 -0
- package/dist/components/footerSimple/FooterSimple.js +87 -0
- package/dist/components/header/Header.js +15 -0
- package/dist/components/header/HeaderGlobal.js +286 -0
- package/dist/components/header/HeaderService.js +281 -0
- package/dist/components/header-menu/HeaderMenu.js +197 -0
- package/dist/components/headerUserMenu/UserMenu.js +134 -0
- package/dist/components/heading/Heading.js +37 -0
- package/dist/components/helptext/Helptext.js +50 -0
- package/dist/components/icon/Icon.d.ts +6 -0
- package/dist/components/icon/Icon.js +69 -0
- package/dist/components/input/Input.js +23 -0
- package/dist/components/inputwrapper/InputWrapper.js +128 -0
- package/dist/components/link/Link.js +34 -0
- package/dist/components/linkcard/LinkCard.js +38 -0
- package/dist/components/loader/Loader.js +47 -0
- package/dist/components/messagebox/Messagebox.js +50 -0
- package/dist/components/modal/Modal.js +89 -0
- package/dist/components/progressbar/Progressbar.js +62 -0
- package/dist/components/radio/RadioButton.js +85 -0
- package/dist/components/radiogroup/RadioGroup.js +70 -0
- package/dist/components/radiogroup/RadioGroupContext.js +5 -0
- package/dist/components/searchinput/SearchInput.js +102 -0
- package/dist/components/select/Select.js +56 -0
- package/dist/components/stepper/Step.js +78 -0
- package/dist/components/stepper/Stepper.js +21 -0
- package/dist/components/strings/PktStringsProvider.js +21 -0
- package/dist/components/table/Table.js +19 -0
- package/dist/components/table/TableBody.js +13 -0
- package/dist/components/table/TableDataCell.js +14 -0
- package/dist/components/table/TableHeader.js +12 -0
- package/dist/components/table/TableHeaderCell.js +12 -0
- package/dist/components/table/TableRow.js +12 -0
- package/dist/components/tabs/TabItem.js +60 -0
- package/dist/components/tabs/Tabs.js +90 -0
- package/dist/components/tag/Tag.js +76 -0
- package/dist/components/textarea/Textarea.js +74 -0
- package/dist/components/textinput/Textinput.js +106 -0
- package/dist/components/timepicker/Timepicker.js +224 -0
- package/dist/components/timepicker/useTimepickerState.js +483 -0
- package/dist/hooks/useElementWidth.js +23 -0
- package/dist/hooks/useFocusModality.js +28 -0
- package/dist/hooks/useGeneratedId.js +8 -0
- package/dist/hooks/useHeaderChrome.js +36 -0
- package/dist/hooks/useOptionGroupField.js +70 -0
- package/dist/hooks/useOwnerForm.js +15 -0
- package/dist/hooks/usePktStrings.js +16 -0
- package/dist/hooks/useScrollLock.js +12 -0
- package/dist/node_modules/@date-fns/tz/date/index.js +57 -0
- package/dist/node_modules/@date-fns/tz/date/mini.js +75 -0
- package/dist/node_modules/@date-fns/tz/index.js +6 -0
- package/dist/node_modules/@date-fns/tz/tz/index.js +1 -0
- package/dist/node_modules/@date-fns/tz/tzName/index.js +10 -0
- package/dist/node_modules/@date-fns/tz/tzOffset/index.js +22 -0
- package/dist/node_modules/classnames/index.js +32 -0
- package/dist/node_modules/date-fns/_lib/addLeadingZeros.js +6 -0
- package/dist/node_modules/date-fns/_lib/defaultOptions.js +7 -0
- package/dist/node_modules/date-fns/_lib/format/formatters.js +389 -0
- package/dist/node_modules/date-fns/_lib/format/lightFormatters.js +43 -0
- package/dist/node_modules/date-fns/_lib/format/longFormatters.js +38 -0
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +8 -0
- package/dist/node_modules/date-fns/_lib/normalizeDates.js +8 -0
- package/dist/node_modules/date-fns/_lib/normalizeInterval.js +11 -0
- package/dist/node_modules/date-fns/_lib/protectedTokens.js +23 -0
- package/dist/node_modules/date-fns/addDays.js +9 -0
- package/dist/node_modules/date-fns/constants.js +10 -0
- package/dist/node_modules/date-fns/constructFrom.js +7 -0
- package/dist/node_modules/date-fns/differenceInCalendarDays.js +11 -0
- package/dist/node_modules/date-fns/eachDayOfInterval.js +15 -0
- package/dist/node_modules/date-fns/endOfDay.js +8 -0
- package/dist/node_modules/date-fns/format.js +59 -0
- package/dist/node_modules/date-fns/getDayOfYear.js +10 -0
- package/dist/node_modules/date-fns/getISODay.js +8 -0
- package/dist/node_modules/date-fns/getISOWeek.js +11 -0
- package/dist/node_modules/date-fns/getISOWeekYear.js +14 -0
- package/dist/node_modules/date-fns/getWeek.js +11 -0
- package/dist/node_modules/date-fns/getWeekYear.js +15 -0
- package/dist/node_modules/date-fns/isDate.js +6 -0
- package/dist/node_modules/date-fns/isValid.js +8 -0
- package/dist/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +9 -0
- package/dist/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +17 -0
- package/dist/node_modules/date-fns/locale/_lib/buildMatchFn.js +22 -0
- package/dist/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +18 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +69 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatLong.js +32 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +11 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/localize.js +202 -0
- package/dist/node_modules/date-fns/locale/en-US/_lib/match.js +124 -0
- package/dist/node_modules/date-fns/locale/en-US.js +20 -0
- package/dist/node_modules/date-fns/startOfDay.js +8 -0
- package/dist/node_modules/date-fns/startOfISOWeek.js +10 -0
- package/dist/node_modules/date-fns/startOfISOWeekYear.js +10 -0
- package/dist/node_modules/date-fns/startOfWeek.js +9 -0
- package/dist/node_modules/date-fns/startOfWeekYear.js +11 -0
- package/dist/node_modules/date-fns/startOfYear.js +8 -0
- package/dist/node_modules/date-fns/toDate.js +7 -0
- package/dist/punkt-react.cjs +1 -1
- package/dist/punkt-react.js +55 -9388
- package/dist/shared-strings/consent.js +113 -0
- package/dist/shared-strings/format.js +18 -0
- package/dist/shared-strings/nb.js +201 -0
- package/dist/shared-strings/resolve.js +40 -0
- package/dist/shared-strings/store.js +35 -0
- package/dist/shared-types/accordion.js +4 -0
- package/dist/shared-types/calendar.js +12 -0
- package/dist/shared-types/card.js +15 -0
- package/dist/shared-types/checkbox.js +15 -0
- package/dist/shared-types/combobox.js +19 -0
- package/dist/shared-types/consent.js +8 -0
- package/dist/shared-types/footer.js +4 -0
- package/dist/shared-types/header-footer.js +4 -0
- package/dist/shared-types/icon.js +7 -0
- package/dist/shared-types/messagebox.js +8 -0
- package/dist/shared-types/option-group.js +14 -0
- package/dist/shared-types/radiobutton.js +11 -0
- package/dist/shared-types/select.js +14 -0
- package/dist/shared-types/table.js +8 -0
- package/dist/shared-utils/calendar/calendar-grid.js +19 -0
- package/dist/shared-utils/calendar/date-validation.js +19 -0
- package/dist/shared-utils/calendar/keyboard-navigation.js +26 -0
- package/dist/shared-utils/calendar/selection-manager.js +52 -0
- package/dist/shared-utils/combobox/input-utils.js +39 -0
- package/dist/shared-utils/combobox/keyboard-navigation.js +41 -0
- package/dist/shared-utils/combobox/option-utils.js +48 -0
- package/dist/shared-utils/date-utils.js +71 -0
- package/dist/shared-utils/datepicker-utils.js +32 -0
- package/dist/shared-utils/device-utils.js +7 -0
- package/dist/shared-utils/fileupload/announcements.js +21 -0
- package/dist/shared-utils/fileupload/filename.js +8 -0
- package/dist/shared-utils/fileupload/focus-trap.js +2 -0
- package/dist/shared-utils/fileupload/formats.js +29 -0
- package/dist/shared-utils/fileupload/index.js +11 -0
- package/dist/shared-utils/fileupload/navigation.js +6 -0
- package/dist/shared-utils/fileupload/size.js +25 -0
- package/dist/shared-utils/fileupload/transfers.js +23 -0
- package/dist/shared-utils/fileupload/truncate.js +9 -0
- package/dist/shared-utils/fileupload/validation.js +32 -0
- package/dist/shared-utils/focus-trap/index.js +60 -0
- package/dist/shared-utils/forms/described-by.js +7 -0
- package/dist/shared-utils/header-footer/external-domain.js +30 -0
- package/dist/shared-utils/header-footer/fetch-header-footer-data.js +29 -0
- package/dist/shared-utils/header-footer/icon-map.js +55 -0
- package/dist/shared-utils/header-footer/select-megamenu.js +7 -0
- package/dist/shared-utils/scroll-lock/index.js +21 -0
- package/dist/shared-utils/timepicker/options.js +10 -0
- package/dist/shared-utils/timepicker/stepper.js +10 -0
- package/dist/shared-utils/timepicker/time-utils.js +7 -0
- package/dist/shared-utils/value-utils.js +12 -0
- package/dist/utils/nativeInputValue.js +6 -0
- package/dist/utils/stableKeys.js +13 -0
- package/dist/utils/stringutils.js +7 -0
- package/package.json +3 -2
- package/src/components/checkbox/Checkbox.tsx +2 -0
- package/src/components/combobox/types.ts +0 -2
- package/src/components/fileupload/FileUpload.tsx +3 -1
- package/src/components/fileupload/FileUploadContext.ts +7 -0
- package/src/components/fileupload/QueueDisplay.tsx +3 -3
- package/src/components/fileupload/Subcomponents.tsx +2 -7
- package/src/components/fileupload/extensions/Comments.tsx +2 -1
- package/src/components/fileupload/extensions/Rename.tsx +2 -1
- package/src/components/fileupload/types.ts +1 -2
- package/src/components/header/Header.test.tsx +0 -7
- package/src/components/header/Header.tsx +0 -2
- package/src/components/heading/Heading.tsx +0 -2
- package/src/components/icon/Icon.test.tsx +0 -7
- package/src/components/icon/Icon.tsx +7 -0
- package/src/components/input/Input.tsx +0 -2
- package/src/components/link/Link.tsx +0 -2
- package/src/components/radio/RadioButton.tsx +2 -0
- package/src/components/server-components.test.ts +69 -0
- package/src/components/stepper/Step.tsx +0 -2
- package/src/components/stepper/Stepper.tsx +0 -2
- package/src/components/strings/PktStringsProvider.tsx +2 -0
- package/src/components/table/Table.tsx +0 -2
- package/src/components/table/TableBody.tsx +1 -3
- package/src/components/table/TableDataCell.tsx +0 -2
- package/src/components/table/TableHeader.tsx +0 -2
- package/src/components/table/TableHeaderCell.tsx +0 -2
- package/src/components/table/TableRow.tsx +0 -2
- package/dist/components/accordion/Accordion.test.d.ts +0 -0
- package/dist/components/alert/Alert.test.d.ts +0 -0
- package/dist/components/backlink/BackLink.test.d.ts +0 -0
- package/dist/components/breadcrumbs/Breadcrumbs.test.d.ts +0 -1
- package/dist/components/button/Button.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.accessibility.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.constraints.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.core.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.interaction.test.d.ts +0 -0
- package/dist/components/calendar/Calendar.selection.test.d.ts +0 -0
- package/dist/components/card/Card.test.d.ts +0 -0
- package/dist/components/checkbox/Checkbox.test.d.ts +0 -0
- package/dist/components/checkboxgroup/CheckboxGroup.forms.test.d.ts +0 -0
- package/dist/components/checkboxgroup/CheckboxGroup.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.accessibility.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.core.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.interaction.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.preselection.test.d.ts +0 -0
- package/dist/components/combobox/Combobox.selection.test.d.ts +0 -0
- package/dist/components/consent/Consent.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.accessibility.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.core.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.input.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.selection.test.d.ts +0 -0
- package/dist/components/datepicker/Datepicker.validation.test.d.ts +0 -0
- package/dist/components/fileupload/FileUpload.test.d.ts +0 -0
- package/dist/components/fileupload/QueueDisplay.test.d.ts +0 -0
- package/dist/components/fileupload/Truncate.test.d.ts +0 -0
- package/dist/components/footer/Footer.accessibility.test.d.ts +0 -0
- package/dist/components/footer/Footer.test.d.ts +0 -1
- package/dist/components/footerSimple/FooterSimple.test.d.ts +0 -1
- package/dist/components/formAttribute.test.d.ts +0 -1
- package/dist/components/header/Header.test.d.ts +0 -0
- package/dist/components/header/HeaderGlobal.accessibility.test.d.ts +0 -0
- package/dist/components/header/HeaderGlobal.test.d.ts +0 -0
- package/dist/components/header/HeaderService.accessibility.test.d.ts +0 -0
- package/dist/components/header/HeaderService.test.d.ts +0 -0
- package/dist/components/header-menu/HeaderMenu.test.d.ts +0 -0
- package/dist/components/headerUserMenu/UserMenu.test.d.ts +0 -0
- package/dist/components/heading/Heading.test.d.ts +0 -0
- package/dist/components/helptext/Helptext.test.d.ts +0 -0
- package/dist/components/helptext/helptextAssociation.test.d.ts +0 -1
- package/dist/components/hydration.test.d.ts +0 -1
- package/dist/components/icon/Icon.test.d.ts +0 -9
- package/dist/components/inputwrapper/InputWrapper.test.d.ts +0 -0
- package/dist/components/link/Link.test.d.ts +0 -1
- package/dist/components/linkcard/LinkCard.test.d.ts +0 -0
- package/dist/components/loader/Loader.test.d.ts +0 -0
- package/dist/components/messagebox/Messagebox.test.d.ts +0 -1
- package/dist/components/modal/Modal.test.d.ts +0 -0
- package/dist/components/progressbar/Progressbar.test.d.ts +0 -0
- package/dist/components/radio/RadioButton.test.d.ts +0 -0
- package/dist/components/radiogroup/RadioGroup.forms.test.d.ts +0 -0
- package/dist/components/radiogroup/RadioGroup.test.d.ts +0 -0
- package/dist/components/searchinput/SearchInput.test.d.ts +0 -0
- package/dist/components/select/Select.test.d.ts +0 -0
- package/dist/components/ssr.test.d.ts +0 -1
- package/dist/components/stepper/Stepper.test.d.ts +0 -0
- package/dist/components/strings/strings-override.test.d.ts +0 -1
- package/dist/components/table/Table.test.d.ts +0 -0
- package/dist/components/tabs/Tabs.test.d.ts +0 -0
- package/dist/components/tag/Tag.test.d.ts +0 -0
- package/dist/components/textarea/Textarea.test.d.ts +0 -0
- package/dist/components/textinput/Textinput.test.d.ts +0 -0
- package/dist/components/timepicker/Timepicker.test.d.ts +0 -0
|
@@ -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,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.
|
|
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": "
|
|
105
|
+
"gitHead": "dc04d631131be873574d55919198f719cc0e2d09"
|
|
105
106
|
}
|
|
@@ -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
|
|
|
@@ -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
|
-
|
|
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 {
|
|
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
|
|
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 {
|
|
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
|
|
|
@@ -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
|
|
@@ -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 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
|
)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
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
|