@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.
- package/CHANGELOG.md +30 -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/hydration.test.tsx +61 -15
- 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,214 @@
|
|
|
1
|
+
import { CALENDAR_DEFAULTS as e } from "../../shared-types/calendar.js";
|
|
2
|
+
import { usePktStrings as t } from "../../hooks/usePktStrings.js";
|
|
3
|
+
import { formatISODate as n, newDate as r, newDateFromDate as i, parseISODateString as a, todayInTz as o } from "../../shared-utils/date-utils.js";
|
|
4
|
+
import { isDateExcluded as ee, isDayDisabled as te } from "../../shared-utils/calendar/date-validation.js";
|
|
5
|
+
import { addToSelection as ne, convertSelectedToDates as re, handleRangeSelection as ie, isRangeAllowed as ae, removeFromSelection as oe, toggleSelection as s, updateRangeMap as c } from "../../shared-utils/calendar/selection-manager.js";
|
|
6
|
+
import { findNextSelectableDate as se, getKeyDirection as ce, shouldIgnoreKeyboardEvent as le } from "../../shared-utils/calendar/keyboard-navigation.js";
|
|
7
|
+
import { useCallback as l, useId as ue, useMemo as u, useRef as d, useState as f } from "react";
|
|
8
|
+
//#region src/components/calendar/useCalendarState.ts
|
|
9
|
+
function p(p) {
|
|
10
|
+
let { selected: m, multiple: h = e.multiple, maxMultiple: g = e.maxMultiple, range: _ = e.range, earliest: v = e.earliest, latest: y = e.latest, excludedates: b, excludeweekdays: x = [], weeknumbers: de = e.weeknumbers, withcontrols: fe = e.withcontrols, currentmonth: S, today: C, strings: pe, onDateSelected: w, onClose: T, id: me, className: he } = p, ge = ue(), _e = me ?? ge, E = t(["dates", "calendar"], pe), ve = u(() => ({
|
|
11
|
+
month: E.dates.month,
|
|
12
|
+
year: E.dates.year,
|
|
13
|
+
week: E.dates.week,
|
|
14
|
+
days: E.dates.days,
|
|
15
|
+
daysShort: E.dates.daysShort,
|
|
16
|
+
months: E.dates.months,
|
|
17
|
+
prevMonth: E.calendar.prevMonth,
|
|
18
|
+
nextMonth: E.calendar.nextMonth
|
|
19
|
+
}), [E]), D = u(() => C ? a(C) : o(), [C]), O = u(() => b ? b.map((e) => typeof e == "string" ? a(e) : e) : [], [b]), k = m !== void 0, [ye, A] = f([]), j = k ? m : ye, M = u(() => re(j), [j]), N = () => {
|
|
20
|
+
let e = j.length > 0 && j[0] !== "" ? a(j[j.length - 1]) : null;
|
|
21
|
+
if (e && !isNaN(e.getTime())) return e;
|
|
22
|
+
let t = null;
|
|
23
|
+
if (S instanceof Date ? t = i(S) : typeof S == "string" && (t = a(S)), (!t || isNaN(t.getTime())) && (t = i(D)), y) {
|
|
24
|
+
let e = typeof y == "string" ? a(y) : y;
|
|
25
|
+
!isNaN(e.getTime()) && t > e && (t = e);
|
|
26
|
+
}
|
|
27
|
+
if (v) {
|
|
28
|
+
let e = typeof v == "string" ? a(v) : v;
|
|
29
|
+
!isNaN(e.getTime()) && t < e && (t = e);
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
}, [P, F] = f(() => N().getFullYear()), [I, L] = f(() => N().getMonth()), [R, z] = f(() => _ && M.length === 2 ? c(M[0], M[1]) : {}), [be, B] = f(null), [V, H] = f(null), U = d(null), W = d([]), G = d(0), [xe, Se] = f(!1), [Ce, we] = f(j);
|
|
33
|
+
if (j !== Ce && (we(j), !xe && j.length > 0 && j[0] !== "")) {
|
|
34
|
+
let e = a(j[j.length - 1]);
|
|
35
|
+
isNaN(e.getTime()) || (F(e.getFullYear()), L(e.getMonth()));
|
|
36
|
+
}
|
|
37
|
+
let [K, Te] = f({
|
|
38
|
+
range: _,
|
|
39
|
+
_selected: M
|
|
40
|
+
});
|
|
41
|
+
(_ !== K.range || M !== K._selected) && (Te({
|
|
42
|
+
range: _,
|
|
43
|
+
_selected: M
|
|
44
|
+
}), _ && M.length === 2 ? z(c(M[0], M[1])) : (!_ || M.length < 2) && z({}));
|
|
45
|
+
let q = u(() => ({
|
|
46
|
+
earliest: v,
|
|
47
|
+
latest: y,
|
|
48
|
+
excludedates: O,
|
|
49
|
+
excludeweekdays: x
|
|
50
|
+
}), [
|
|
51
|
+
v,
|
|
52
|
+
y,
|
|
53
|
+
O,
|
|
54
|
+
x
|
|
55
|
+
]), J = l((e) => {
|
|
56
|
+
k || A(e), w?.(e);
|
|
57
|
+
}, [k, w]), Y = l(() => {
|
|
58
|
+
T?.();
|
|
59
|
+
}, [T]), X = l((e, t) => {
|
|
60
|
+
F(typeof e == "string" ? parseInt(e) : e), L(typeof t == "string" ? parseInt(t) : t), G.current = 0, H(null), W.current = [], Se(!0);
|
|
61
|
+
}, []), Ee = l(() => {
|
|
62
|
+
let e = I === 0 ? 11 : I - 1, t = I === 0 ? P - 1 : P;
|
|
63
|
+
X(t, e);
|
|
64
|
+
}, [
|
|
65
|
+
P,
|
|
66
|
+
I,
|
|
67
|
+
X
|
|
68
|
+
]), De = l(() => {
|
|
69
|
+
let e = I === 11 ? 0 : I + 1, t = I === 11 ? P + 1 : P;
|
|
70
|
+
X(t, e);
|
|
71
|
+
}, [
|
|
72
|
+
P,
|
|
73
|
+
I,
|
|
74
|
+
X
|
|
75
|
+
]), Oe = l((e) => ee(e, q), [q]), ke = l((e, t) => te(e, t, q, {
|
|
76
|
+
multiple: h,
|
|
77
|
+
maxMultiple: g,
|
|
78
|
+
selectedCount: j.length
|
|
79
|
+
}), [
|
|
80
|
+
q,
|
|
81
|
+
h,
|
|
82
|
+
g,
|
|
83
|
+
j.length
|
|
84
|
+
]), Z = l(() => typeof j == "string" ? j.split(",") : j, [j]), Ae = l((e) => {
|
|
85
|
+
if (!_ || M.length !== 1 || !ae(e, M, O, x) || M[0] >= e) {
|
|
86
|
+
B(null);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
B(e), z(c(M[0], e));
|
|
90
|
+
}, [
|
|
91
|
+
_,
|
|
92
|
+
M,
|
|
93
|
+
O,
|
|
94
|
+
x
|
|
95
|
+
]), je = l((e) => {
|
|
96
|
+
if (!e) return;
|
|
97
|
+
let t;
|
|
98
|
+
if (_) t = ie(e, Z(), {
|
|
99
|
+
excludedates: O,
|
|
100
|
+
excludeweekdays: x
|
|
101
|
+
}), k || A(t), t.length === 2 ? (w?.(t), Y()) : (t.length === 1 && z({}), w?.(t));
|
|
102
|
+
else if (h) t = s(e, Z(), g), J(t);
|
|
103
|
+
else {
|
|
104
|
+
let r = n(e);
|
|
105
|
+
t = j.includes(r) ? [] : [r], J(t), Y();
|
|
106
|
+
}
|
|
107
|
+
}, [
|
|
108
|
+
_,
|
|
109
|
+
h,
|
|
110
|
+
g,
|
|
111
|
+
Z,
|
|
112
|
+
j,
|
|
113
|
+
O,
|
|
114
|
+
x,
|
|
115
|
+
k,
|
|
116
|
+
J,
|
|
117
|
+
Y,
|
|
118
|
+
w
|
|
119
|
+
]), Me = l((e) => {
|
|
120
|
+
let t = ne(e, Z());
|
|
121
|
+
k || A(t), _ && t.length === 2 && (w?.(t), Y());
|
|
122
|
+
}, [
|
|
123
|
+
Z,
|
|
124
|
+
k,
|
|
125
|
+
_,
|
|
126
|
+
w,
|
|
127
|
+
Y
|
|
128
|
+
]), Ne = l((e) => {
|
|
129
|
+
let t = oe(e, Z());
|
|
130
|
+
k || A(t);
|
|
131
|
+
}, [Z, k]), Pe = l((e) => {
|
|
132
|
+
let t = s(e, Z(), g);
|
|
133
|
+
k || A(t);
|
|
134
|
+
}, [
|
|
135
|
+
Z,
|
|
136
|
+
g,
|
|
137
|
+
k
|
|
138
|
+
]), Q = l(() => {
|
|
139
|
+
let e = n(i(D)), t = U.current?.querySelector(`button[data-date="${e}"]`);
|
|
140
|
+
if (t instanceof HTMLButtonElement) {
|
|
141
|
+
H(e), t.focus();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
let r = W.current.find((e) => !e.isDisabled);
|
|
145
|
+
if (r) {
|
|
146
|
+
let e = U.current?.querySelector(`button[data-date="${r.currentDateISO}"]`);
|
|
147
|
+
e instanceof HTMLButtonElement && (H(r.currentDateISO), e.focus());
|
|
148
|
+
}
|
|
149
|
+
}, []), $ = l((e, t) => {
|
|
150
|
+
let i = e.target;
|
|
151
|
+
if (le(i)) return;
|
|
152
|
+
if (e.preventDefault(), !V) {
|
|
153
|
+
Q();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
let a = r(V), o = se(a, t, U.current.querySelector.bind(U.current));
|
|
157
|
+
if (o) {
|
|
158
|
+
let e = U.current.querySelector(`button[data-date="${n(o)}"]`);
|
|
159
|
+
e instanceof HTMLButtonElement && !e.dataset.disabled && (H(n(o)), e.focus());
|
|
160
|
+
}
|
|
161
|
+
}, [V, Q]);
|
|
162
|
+
return {
|
|
163
|
+
componentId: _e,
|
|
164
|
+
strings: ve,
|
|
165
|
+
todayDate: D,
|
|
166
|
+
year: P,
|
|
167
|
+
month: I,
|
|
168
|
+
activeSelected: j,
|
|
169
|
+
_selected: M,
|
|
170
|
+
inRange: R,
|
|
171
|
+
rangeHovered: be,
|
|
172
|
+
focusedDate: V,
|
|
173
|
+
range: _,
|
|
174
|
+
multiple: h,
|
|
175
|
+
weeknumbers: de,
|
|
176
|
+
withcontrols: fe,
|
|
177
|
+
earliest: v,
|
|
178
|
+
latest: y,
|
|
179
|
+
excludedates: O,
|
|
180
|
+
excludeweekdays: x,
|
|
181
|
+
className: he,
|
|
182
|
+
dateConstraints: q,
|
|
183
|
+
calendarRef: U,
|
|
184
|
+
selectableDatesRef: W,
|
|
185
|
+
tabIndexSetRef: G,
|
|
186
|
+
prevMonth: Ee,
|
|
187
|
+
nextMonth: De,
|
|
188
|
+
changeMonth: X,
|
|
189
|
+
handleDateSelect: je,
|
|
190
|
+
addToSelected: Me,
|
|
191
|
+
removeFromSelected: Ne,
|
|
192
|
+
toggleSelectedDate: Pe,
|
|
193
|
+
handleRangeHover: Ae,
|
|
194
|
+
isExcluded: Oe,
|
|
195
|
+
isDayDisabled: ke,
|
|
196
|
+
focusOnCurrentDate: Q,
|
|
197
|
+
handleKeydown: l((e) => {
|
|
198
|
+
if (e.key === "Escape") {
|
|
199
|
+
e.preventDefault(), Y();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
let t = ce(e.key);
|
|
203
|
+
t !== null && $(e.nativeEvent, t);
|
|
204
|
+
}, [Y, $]),
|
|
205
|
+
handleFocusOut: l((e) => {
|
|
206
|
+
let t = e.target, n = e.relatedTarget;
|
|
207
|
+
U.current && U.current.contains(n) || t.classList.contains("pkt-hide") || t.closest(".pkt-cal-month-picker") || Y();
|
|
208
|
+
}, [Y]),
|
|
209
|
+
close: Y,
|
|
210
|
+
setFocusedDate: H
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
//#endregion
|
|
214
|
+
export { p as useCalendarState };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __toESM as e } from "../../_virtual/_rolldown/runtime.js";
|
|
3
|
+
import { CARD_DEFAULTS as t } from "../../shared-types/card.js";
|
|
4
|
+
import { require_classnames as n } from "../../node_modules/classnames/index.js";
|
|
5
|
+
import { plural as r } from "../../shared-strings/format.js";
|
|
6
|
+
import { usePktStrings as i } from "../../hooks/usePktStrings.js";
|
|
7
|
+
import { withStableKeys as a } from "../../utils/stableKeys.js";
|
|
8
|
+
import { PktHeading as o } from "../heading/Heading.js";
|
|
9
|
+
import { PktTag as s } from "../tag/Tag.js";
|
|
10
|
+
import { forwardRef as c } from "react";
|
|
11
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
12
|
+
//#region src/components/card/Card.tsx
|
|
13
|
+
var d = /* @__PURE__ */ e(n(), 1), f = c(({ children: e, className: n, ariaLabel: c, metaLead: f, borderOnHover: p = t.borderOnHover, metaTrail: m, layout: h = t.layout, heading: g = "", headingLevel: _ = t.headingLevel, image: v, imageShape: y = t.imageShape, imageAspect: b, restrictImageHeight: x = t.restrictImageHeight, clickCardLink: S, padding: C = t.padding, openLinkInNewTab: w = t.openLinkInNewTab, skin: T = t.skin, subheading: E = "", tagPosition: D = t.tagPosition, zoom: O = t.zoom, tags: k = [], strings: A, ...j }, M) => {
|
|
14
|
+
let N = i(["card"], A), P = (0, d.default)({
|
|
15
|
+
"pkt-card": !0,
|
|
16
|
+
[`pkt-card--${T}`]: T,
|
|
17
|
+
[`pkt-card--${h}`]: h,
|
|
18
|
+
[`pkt-card--padding-${C}`]: C,
|
|
19
|
+
"pkt-card--border-on-hover": p,
|
|
20
|
+
"pkt-card--zoom": O
|
|
21
|
+
}), F = c?.trim() || (g ? `${g} lenkekort` : "lenkekort"), I = c?.trim() || g || "kort", L = () => v?.src ? /* @__PURE__ */ l("div", {
|
|
22
|
+
className: (0, d.default)("pkt-card__image", `pkt-card__image-${y}`, b && `pkt-card__image-aspect-${b}`, x && "pkt-card__image-restricted"),
|
|
23
|
+
children: /* @__PURE__ */ l("img", {
|
|
24
|
+
src: v.src,
|
|
25
|
+
alt: v.alt || ""
|
|
26
|
+
})
|
|
27
|
+
}) : null, R = () => k.length === 0 ? null : /* @__PURE__ */ l("div", {
|
|
28
|
+
className: (0, d.default)("pkt-card__tags", `pkt-card__tags-${D}`),
|
|
29
|
+
role: "list",
|
|
30
|
+
"aria-label": r(k.length, N.card.tagsLabelOne, N.card.tagsLabelOther),
|
|
31
|
+
children: a(k, (e) => e.text).map(({ item: e, key: t }) => /* @__PURE__ */ l(s, {
|
|
32
|
+
role: "listitem",
|
|
33
|
+
textStyle: "normal-text",
|
|
34
|
+
size: "medium",
|
|
35
|
+
skin: e.skin,
|
|
36
|
+
iconName: e.iconName,
|
|
37
|
+
children: /* @__PURE__ */ l("span", { children: e.text })
|
|
38
|
+
}, t))
|
|
39
|
+
}), z = () => !g || S ? null : /* @__PURE__ */ l(o, {
|
|
40
|
+
className: "pkt-card__heading",
|
|
41
|
+
level: _,
|
|
42
|
+
size: "medium",
|
|
43
|
+
weight: "regular",
|
|
44
|
+
children: g
|
|
45
|
+
}), B = () => S ? /* @__PURE__ */ l(o, {
|
|
46
|
+
className: "pkt-card__link-heading pkt-card__heading",
|
|
47
|
+
level: _,
|
|
48
|
+
size: "medium",
|
|
49
|
+
weight: "regular",
|
|
50
|
+
children: /* @__PURE__ */ l("a", {
|
|
51
|
+
className: "pkt-card__link",
|
|
52
|
+
href: S,
|
|
53
|
+
target: w ? "_blank" : "_self",
|
|
54
|
+
rel: w ? "noopener noreferrer" : void 0,
|
|
55
|
+
children: g
|
|
56
|
+
})
|
|
57
|
+
}) : null, V = () => E ? /* @__PURE__ */ l("p", {
|
|
58
|
+
className: "pkt-card__subheading",
|
|
59
|
+
children: E
|
|
60
|
+
}) : null, H = () => !g && !E ? null : /* @__PURE__ */ u("header", {
|
|
61
|
+
className: "pkt-card__header",
|
|
62
|
+
children: [
|
|
63
|
+
z(),
|
|
64
|
+
B(),
|
|
65
|
+
V()
|
|
66
|
+
]
|
|
67
|
+
}), U = () => !f && !m ? null : /* @__PURE__ */ u("footer", {
|
|
68
|
+
className: "pkt-card__metadata",
|
|
69
|
+
children: [f && /* @__PURE__ */ l("span", {
|
|
70
|
+
className: "pkt-card__metadata-lead",
|
|
71
|
+
children: f
|
|
72
|
+
}), m && /* @__PURE__ */ l("span", {
|
|
73
|
+
className: "pkt-card__metadata-trail",
|
|
74
|
+
children: m
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
|
+
return /* @__PURE__ */ u("article", {
|
|
78
|
+
...j,
|
|
79
|
+
ref: M,
|
|
80
|
+
className: (0, d.default)(P, n),
|
|
81
|
+
"aria-label": S ? F : I,
|
|
82
|
+
children: [L(), /* @__PURE__ */ u("div", {
|
|
83
|
+
className: "pkt-card__wrapper",
|
|
84
|
+
children: [
|
|
85
|
+
D === "top" && R(),
|
|
86
|
+
H(),
|
|
87
|
+
/* @__PURE__ */ l("section", {
|
|
88
|
+
className: "pkt-card__content",
|
|
89
|
+
children: e
|
|
90
|
+
}),
|
|
91
|
+
D === "bottom" && R(),
|
|
92
|
+
U()
|
|
93
|
+
]
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
f.displayName = "PktCard";
|
|
98
|
+
//#endregion
|
|
99
|
+
export { f as PktCard };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CHECKBOX_DEFAULTS as e } from "../../shared-types/checkbox.js";
|
|
3
|
+
import { usePktStrings as t } from "../../hooks/usePktStrings.js";
|
|
4
|
+
import { useGeneratedId as n } from "../../hooks/useGeneratedId.js";
|
|
5
|
+
import { useCheckboxGroupContext as ee } from "../checkboxgroup/CheckboxGroupContext.js";
|
|
6
|
+
import { forwardRef as r, useEffect as i, useRef as a } from "react";
|
|
7
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/checkbox/Checkbox.tsx
|
|
9
|
+
var l = r(({ id: r, hasTile: l = e.hasTile, disabled: u = e.disabled, label: d, checkHelptext: f, hasError: p = e.hasError, className: m, isSwitch: h = e.isSwitch, hideLabel: g = e.hideLabel, labelPosition: _ = e.labelPosition, inputSize: v, defaultChecked: te, checked: y, indeterminate: b, optionalTag: x, optionalText: S, requiredTag: C, requiredText: w, strings: T, tagText: E, name: D, value: O, onChange: k, "aria-describedby": A, ...j }, M) => {
|
|
10
|
+
let N = t(["forms"], T), P = n(r), F = a(null), I = ee(), L = O ?? "on", R = I?.value, z = R !== void 0, B = z ? R.includes(L) : y, V = te ?? (I?.defaultValue === void 0 ? void 0 : I.defaultValue.includes(L)), H = l || !!I?.hasTile, U = p || !!I?.hasError, W = u || !!I?.disabled;
|
|
11
|
+
i(() => {
|
|
12
|
+
z && y !== void 0 && console.warn(`PktCheckbox (${P}): checked ignoreres når PktCheckboxGroup har value. Styr valget med value på gruppen.`);
|
|
13
|
+
}, [
|
|
14
|
+
z,
|
|
15
|
+
y,
|
|
16
|
+
P
|
|
17
|
+
]);
|
|
18
|
+
let G = (e) => {
|
|
19
|
+
k?.(e), I?.onOptionChange(e);
|
|
20
|
+
};
|
|
21
|
+
i(() => {
|
|
22
|
+
F.current && b !== void 0 && (F.current.indeterminate = b);
|
|
23
|
+
}, [b]), i(() => {
|
|
24
|
+
typeof M == "function" ? M(F.current) : M && (M.current = F.current);
|
|
25
|
+
}, [M]);
|
|
26
|
+
let K = [
|
|
27
|
+
m,
|
|
28
|
+
"pkt-input-check",
|
|
29
|
+
v ? `pkt-input-check--${v}` : ""
|
|
30
|
+
].filter(Boolean).join(" "), q = [
|
|
31
|
+
"pkt-input-check__input-label",
|
|
32
|
+
_ === "left" ? "pkt-input-check__input-label--left" : "",
|
|
33
|
+
W ? "pkt-input-check__input-label--disabled" : "",
|
|
34
|
+
`pkt-input-check__input-label--${_}`,
|
|
35
|
+
g ? "pkt-sr-only" : ""
|
|
36
|
+
].filter(Boolean).join(" "), J = [
|
|
37
|
+
"pkt-input-check__input",
|
|
38
|
+
H ? "pkt-input-check__input--tile" : "",
|
|
39
|
+
W && H ? "pkt-input-check__input--tile-disabled" : ""
|
|
40
|
+
].filter(Boolean).join(" "), Y = [
|
|
41
|
+
"pkt-tag",
|
|
42
|
+
"pkt-tag--small",
|
|
43
|
+
"pkt-tag--thin-text"
|
|
44
|
+
].join(" "), X = () => /* @__PURE__ */ c(o, { children: [
|
|
45
|
+
E && /* @__PURE__ */ s("span", {
|
|
46
|
+
className: Y + " pkt-tag--gray",
|
|
47
|
+
children: E
|
|
48
|
+
}),
|
|
49
|
+
x && /* @__PURE__ */ s("span", {
|
|
50
|
+
className: Y + " pkt-tag--blue-light",
|
|
51
|
+
children: S ?? N.forms.optional
|
|
52
|
+
}),
|
|
53
|
+
C && /* @__PURE__ */ s("span", {
|
|
54
|
+
className: Y + " pkt-tag--beige",
|
|
55
|
+
children: w ?? N.forms.required
|
|
56
|
+
})
|
|
57
|
+
] }), Z = `${P}-check-label`, Q = `${P}-check-helptext`, ne = [f ? Q : void 0, A].filter(Boolean).join(" ") || void 0, $ = () => /* @__PURE__ */ c("label", {
|
|
58
|
+
className: q,
|
|
59
|
+
htmlFor: P,
|
|
60
|
+
children: [/* @__PURE__ */ c("span", {
|
|
61
|
+
id: Z,
|
|
62
|
+
children: [
|
|
63
|
+
d,
|
|
64
|
+
" ",
|
|
65
|
+
X()
|
|
66
|
+
]
|
|
67
|
+
}), f && /* @__PURE__ */ s("div", {
|
|
68
|
+
id: Q,
|
|
69
|
+
className: "pkt-input-check__input-helptext",
|
|
70
|
+
children: f
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
return /* @__PURE__ */ s("div", {
|
|
74
|
+
className: K,
|
|
75
|
+
children: /* @__PURE__ */ c("div", {
|
|
76
|
+
className: J,
|
|
77
|
+
children: [
|
|
78
|
+
_ === "left" && $(),
|
|
79
|
+
/* @__PURE__ */ s("input", {
|
|
80
|
+
role: h ? "switch" : "checkbox",
|
|
81
|
+
ref: F,
|
|
82
|
+
className: `pkt-input-check__input-checkbox ${U ? "pkt-input-check__input-checkbox--error" : ""}`,
|
|
83
|
+
type: "checkbox",
|
|
84
|
+
id: P,
|
|
85
|
+
name: D ?? I?.name,
|
|
86
|
+
value: O,
|
|
87
|
+
disabled: W,
|
|
88
|
+
"aria-labelledby": d ? Z : void 0,
|
|
89
|
+
"aria-describedby": ne,
|
|
90
|
+
...B === void 0 ? { defaultChecked: V } : { checked: B },
|
|
91
|
+
onChange: I ? G : k,
|
|
92
|
+
...j
|
|
93
|
+
}),
|
|
94
|
+
_ === "right" && $()
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
l.displayName = "PktCheckbox";
|
|
100
|
+
//#endregion
|
|
101
|
+
export { l as PktCheckbox };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { OPTION_GROUP_DEFAULTS as e } from "../../shared-types/option-group.js";
|
|
3
|
+
import { usePktStrings as t } from "../../hooks/usePktStrings.js";
|
|
4
|
+
import { useGeneratedId as n } from "../../hooks/useGeneratedId.js";
|
|
5
|
+
import { CheckboxGroupContext as r } from "./CheckboxGroupContext.js";
|
|
6
|
+
import { isActiveOption as i, useOptionGroupField as a } from "../../hooks/useOptionGroupField.js";
|
|
7
|
+
import { PktInputWrapper as o } from "../inputwrapper/InputWrapper.js";
|
|
8
|
+
import { forwardRef as s, useEffect as c, useMemo as l, useRef as u } from "react";
|
|
9
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/checkboxgroup/CheckboxGroup.tsx
|
|
11
|
+
var f = s(({ id: s, name: f, label: p, helptext: m, helptextDropdown: h, helptextDropdownButton: g, value: _, defaultValue: v, layout: y = e.layout, inputSize: b = e.inputSize, hasTile: x = e.hasTile, required: S = e.required, disabled: C = e.disabled, hasError: w = e.hasError, errorMessage: T, useWrapper: E = e.useWrapper, optionalTag: D = e.optionalTag, optionalText: O, requiredTag: k = e.requiredTag, requiredText: A, tagText: j, strings: M, className: N, children: P, onChange: F, onValueChange: I, onFocus: L, onBlur: R }, z) => {
|
|
12
|
+
let B = n(s), V = f || B, H = t(["validation"], M).validation.checkboxGroupValueMissing, U = u(!1), W = a({
|
|
13
|
+
type: "checkbox",
|
|
14
|
+
name: V,
|
|
15
|
+
forwardedRef: z,
|
|
16
|
+
onChange: F,
|
|
17
|
+
onValueChange: I,
|
|
18
|
+
onFocus: L,
|
|
19
|
+
onBlur: R,
|
|
20
|
+
onValueSet: () => G()
|
|
21
|
+
}), G = () => {
|
|
22
|
+
if (!S && !U.current) return;
|
|
23
|
+
U.current = S;
|
|
24
|
+
let e = W.options(), t = S && !e.some((e) => e.checked && i(e));
|
|
25
|
+
e.forEach((e) => e.setCustomValidity(t ? H : ""));
|
|
26
|
+
};
|
|
27
|
+
c(() => {
|
|
28
|
+
G();
|
|
29
|
+
}), c(() => {
|
|
30
|
+
let e = W.options()[0]?.form;
|
|
31
|
+
if (!e) return;
|
|
32
|
+
let t, n = () => {
|
|
33
|
+
t = setTimeout(G);
|
|
34
|
+
};
|
|
35
|
+
return e.addEventListener("reset", n), () => {
|
|
36
|
+
clearTimeout(t), e.removeEventListener("reset", n);
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
let K = l(() => ({
|
|
40
|
+
name: V,
|
|
41
|
+
hasTile: x,
|
|
42
|
+
hasError: w,
|
|
43
|
+
disabled: C,
|
|
44
|
+
value: _,
|
|
45
|
+
defaultValue: v,
|
|
46
|
+
onOptionChange: W.onOptionChange
|
|
47
|
+
}), [
|
|
48
|
+
V,
|
|
49
|
+
x,
|
|
50
|
+
w,
|
|
51
|
+
C,
|
|
52
|
+
_,
|
|
53
|
+
v,
|
|
54
|
+
W
|
|
55
|
+
]);
|
|
56
|
+
return /* @__PURE__ */ d(r.Provider, {
|
|
57
|
+
value: K,
|
|
58
|
+
children: /* @__PURE__ */ d(o, {
|
|
59
|
+
ref: W.mergedRef,
|
|
60
|
+
onFocus: W.onRootFocus,
|
|
61
|
+
onBlur: W.onRootBlur,
|
|
62
|
+
id: s,
|
|
63
|
+
forId: B,
|
|
64
|
+
className: N,
|
|
65
|
+
label: p,
|
|
66
|
+
helptext: m,
|
|
67
|
+
helptextDropdown: h,
|
|
68
|
+
helptextDropdownButton: g,
|
|
69
|
+
hasError: w,
|
|
70
|
+
errorMessage: T,
|
|
71
|
+
disabled: C,
|
|
72
|
+
optionalTag: D,
|
|
73
|
+
optionalText: O,
|
|
74
|
+
requiredTag: k,
|
|
75
|
+
requiredText: A,
|
|
76
|
+
tagText: j,
|
|
77
|
+
useWrapper: E,
|
|
78
|
+
hasFieldset: !0,
|
|
79
|
+
layout: y,
|
|
80
|
+
size: b,
|
|
81
|
+
strings: M,
|
|
82
|
+
children: P
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
f.displayName = "PktCheckboxGroup";
|
|
87
|
+
//#endregion
|
|
88
|
+
export { f as PktCheckboxGroup };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { PktInputWrapper as e } from "../inputwrapper/InputWrapper.js";
|
|
3
|
+
import { ComboboxTags as t } from "./ComboboxTags.js";
|
|
4
|
+
import { ComboboxInput as n } from "./ComboboxInput.js";
|
|
5
|
+
import { Listbox as r } from "./Listbox.js";
|
|
6
|
+
import { useComboboxState as i } from "./useComboboxState.js";
|
|
7
|
+
import { forwardRef as a } from "react";
|
|
8
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/combobox/Combobox.tsx
|
|
10
|
+
var c = a((a, c) => {
|
|
11
|
+
let l = i(a, c), u = [
|
|
12
|
+
"pkt-combobox-component",
|
|
13
|
+
l.fullwidth && "pkt-combobox-component--fullwidth",
|
|
14
|
+
l.className
|
|
15
|
+
].filter(Boolean).join(" "), d = l.allowUserInput || l.typeahead, f = d ? l.inputId : `${l.id}-combobox`;
|
|
16
|
+
return /* @__PURE__ */ s("div", {
|
|
17
|
+
className: u,
|
|
18
|
+
ref: l.wrapperRef,
|
|
19
|
+
id: l.id || void 0,
|
|
20
|
+
children: [/* @__PURE__ */ s(e, {
|
|
21
|
+
strings: l.strings,
|
|
22
|
+
forId: f,
|
|
23
|
+
hasFieldset: a.hasFieldset ?? !d,
|
|
24
|
+
label: l.label || "",
|
|
25
|
+
helptext: l.helptext,
|
|
26
|
+
helptextDropdown: l.helptextDropdown,
|
|
27
|
+
helptextDropdownButton: l.helptextDropdownButton,
|
|
28
|
+
hasError: l.hasError,
|
|
29
|
+
errorMessage: l.errorMessage,
|
|
30
|
+
disabled: l.disabled,
|
|
31
|
+
optionalTag: l.optionalTag,
|
|
32
|
+
optionalText: l.optionalText,
|
|
33
|
+
requiredTag: l.requiredTag,
|
|
34
|
+
requiredText: l.requiredText,
|
|
35
|
+
tagText: l.tagText,
|
|
36
|
+
useWrapper: l.useWrapper,
|
|
37
|
+
inline: l.inline,
|
|
38
|
+
size: l.inputSize,
|
|
39
|
+
counter: l.hasCounter,
|
|
40
|
+
counterCurrent: l.values.length,
|
|
41
|
+
counterMaxLength: l.maxlength,
|
|
42
|
+
className: "pkt-combobox__wrapper",
|
|
43
|
+
children: [/* @__PURE__ */ s("div", {
|
|
44
|
+
className: "pkt-combobox",
|
|
45
|
+
onBlur: l.handleFocusOut,
|
|
46
|
+
children: [/* @__PURE__ */ o(n, { state: l }), /* @__PURE__ */ o(r, { state: l })]
|
|
47
|
+
}), l.tagPlacement === "outside" && l.multiple && /* @__PURE__ */ o(t, {
|
|
48
|
+
state: l,
|
|
49
|
+
outside: !0
|
|
50
|
+
})]
|
|
51
|
+
}), /* @__PURE__ */ o("input", {
|
|
52
|
+
ref: l.changeInputRef,
|
|
53
|
+
type: "text",
|
|
54
|
+
name: l.name || l.id,
|
|
55
|
+
form: l.form,
|
|
56
|
+
onChange: l.onChange,
|
|
57
|
+
tabIndex: -1,
|
|
58
|
+
"aria-hidden": "true",
|
|
59
|
+
className: "pkt-visually-hidden"
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
c.displayName = "PktCombobox";
|
|
64
|
+
//#endregion
|
|
65
|
+
export { c as PktCombobox };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { PktIcon as e } from "../icon/Icon.js";
|
|
3
|
+
import { describedByIds as t } from "../../shared-utils/forms/described-by.js";
|
|
4
|
+
import { findOptionByValue as n, findOptionIndex as r } from "../../shared-utils/combobox/option-utils.js";
|
|
5
|
+
import { ComboboxTags as i, SingleValueDisplay as a } from "./ComboboxTags.js";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/combobox/ComboboxInput.tsx
|
|
8
|
+
var c = ({ state: c }) => {
|
|
9
|
+
let { id: l, inputId: u, listboxId: d, values: f, options: p, isOpen: m, multiple: h, typeahead: g, allowUserInput: _, tagPlacement: v, placeholder: y, disabled: b, fullwidth: x, hasError: S, label: C, inputFocus: w, skipInputTab: T, restoreInputTab: E, inputRef: D, triggerRef: O, handleInputChange: k, handleInputKeydown: A, handleInputFocus: j, handleInputBlur: M, handleInputClick: N, handlePlaceholderClick: P, handleSelectOnlyKeydown: F, name: I, inputSize: L } = c, R = [
|
|
10
|
+
"pkt-combobox__input",
|
|
11
|
+
`pkt-combobox__input--${L}`,
|
|
12
|
+
x && "pkt-combobox__input--fullwidth",
|
|
13
|
+
m && "pkt-combobox__input--open",
|
|
14
|
+
S && "pkt-combobox__input--error",
|
|
15
|
+
b && "pkt-combobox__input--disabled"
|
|
16
|
+
].filter(Boolean).join(" "), z = ["pkt-combobox__arrow-icon", m && "pkt-combobox__arrow-icon--open"].filter(Boolean).join(" "), B = g || _, V = !B && y && (!f.length || h && v === "outside") && !w, H = v !== "outside", U = m && f[0] && n(p, f[0]) ? `${d}-${r(p, f[0])}` : void 0, W = h && f.length > 0 ? `${f.length} valgt` : void 0, G = t({
|
|
17
|
+
id: B ? u : `${l}-combobox`,
|
|
18
|
+
hasHelptext: !!c.helptext,
|
|
19
|
+
ariaDescribedby: c.ariaDescribedby
|
|
20
|
+
}), K = B ? { tabIndex: -1 } : {
|
|
21
|
+
id: `${l}-combobox`,
|
|
22
|
+
"aria-describedby": G,
|
|
23
|
+
role: "combobox",
|
|
24
|
+
"aria-expanded": m ? "true" : "false",
|
|
25
|
+
"aria-controls": d,
|
|
26
|
+
"aria-haspopup": "listbox",
|
|
27
|
+
"aria-labelledby": `${l}-combobox-label`,
|
|
28
|
+
"aria-activedescendant": U,
|
|
29
|
+
"aria-description": W,
|
|
30
|
+
tabIndex: b ? -1 : 0,
|
|
31
|
+
onKeyDown: F
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ s("div", {
|
|
34
|
+
ref: O,
|
|
35
|
+
className: R,
|
|
36
|
+
onClick: N,
|
|
37
|
+
onBlur: (e) => {
|
|
38
|
+
e.target === e.currentTarget && E();
|
|
39
|
+
},
|
|
40
|
+
...K,
|
|
41
|
+
children: [
|
|
42
|
+
V ? /* @__PURE__ */ o("span", {
|
|
43
|
+
className: "pkt-combobox__placeholder",
|
|
44
|
+
onClick: P,
|
|
45
|
+
children: y
|
|
46
|
+
}) : H ? h ? /* @__PURE__ */ o(i, { state: c }) : B ? null : /* @__PURE__ */ o(a, { state: c }) : null,
|
|
47
|
+
B ? /* @__PURE__ */ o("div", {
|
|
48
|
+
className: "pkt-combobox__input-div combobox__input",
|
|
49
|
+
children: /* @__PURE__ */ o("input", {
|
|
50
|
+
ref: D,
|
|
51
|
+
type: "text",
|
|
52
|
+
id: u,
|
|
53
|
+
name: `${I || l}-input`,
|
|
54
|
+
onChange: k,
|
|
55
|
+
onKeyDown: A,
|
|
56
|
+
onFocus: j,
|
|
57
|
+
onBlur: M,
|
|
58
|
+
tabIndex: T ? -1 : void 0,
|
|
59
|
+
placeholder: !f.length || h && v === "outside" ? y : void 0,
|
|
60
|
+
autoComplete: "off",
|
|
61
|
+
role: "combobox",
|
|
62
|
+
"aria-expanded": m ? "true" : "false",
|
|
63
|
+
"aria-label": C,
|
|
64
|
+
"aria-autocomplete": g ? "both" : _ ? "list" : "none",
|
|
65
|
+
"aria-controls": d,
|
|
66
|
+
"aria-activedescendant": U,
|
|
67
|
+
"aria-description": W,
|
|
68
|
+
"aria-describedby": G,
|
|
69
|
+
disabled: b
|
|
70
|
+
})
|
|
71
|
+
}) : /* @__PURE__ */ o("input", {
|
|
72
|
+
ref: D,
|
|
73
|
+
type: "hidden",
|
|
74
|
+
id: u,
|
|
75
|
+
name: `${I || l}-input`,
|
|
76
|
+
value: f.join(",")
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ o(e, {
|
|
79
|
+
className: z,
|
|
80
|
+
name: "chevron-thin-down",
|
|
81
|
+
"aria-hidden": "true"
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { c as ComboboxInput };
|