@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,577 @@
|
|
|
1
|
+
import { COMBOBOX_DEFAULTS as e } from "../../shared-types/combobox.js";
|
|
2
|
+
import { formatString as t } from "../../shared-strings/format.js";
|
|
3
|
+
import { usePktStrings as n } from "../../hooks/usePktStrings.js";
|
|
4
|
+
import { buildFulltext as r, filterOptionsBySearch as ee, findOptionByValue as i, findTypeaheadMatches as te, getOptionDisplayText as ne, getSearchInfoMessage as a, isMaxSelectionReached as o, parseValueToArray as s } from "../../shared-utils/combobox/option-utils.js";
|
|
5
|
+
import { getInputKeyAction as re, getInputValueAction as c, getSingleValueForInput as l } from "../../shared-utils/combobox/input-utils.js";
|
|
6
|
+
import { focusFirstOption as u, focusFirstOrSelectedOption as d, focusNextOption as ie, focusPreviousOption as f } from "../../shared-utils/combobox/keyboard-navigation.js";
|
|
7
|
+
import { useOwnerForm as p } from "../../hooks/useOwnerForm.js";
|
|
8
|
+
import { setNativeInputValue as ae } from "../../utils/nativeInputValue.js";
|
|
9
|
+
import { Children as oe, isValidElement as se, useCallback as m, useEffect as h, useImperativeHandle as ce, useMemo as g, useRef as _, useState as v } from "react";
|
|
10
|
+
//#region src/components/combobox/useComboboxState.ts
|
|
11
|
+
function le(e, t) {
|
|
12
|
+
return e.map((e) => ({
|
|
13
|
+
...e,
|
|
14
|
+
label: e.label || e.value,
|
|
15
|
+
fulltext: r(e),
|
|
16
|
+
selected: t.includes(e.value)
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
function ue(ue, de) {
|
|
20
|
+
let { id: fe = "", label: pe, value: y, defaultValue: me, options: he, defaultOptions: ge, multiple: b = e.multiple, maxlength: x, typeahead: S = e.typeahead, includeSearch: C = e.includeSearch, allowUserInput: w = e.allowUserInput, displayValueAs: T = e.displayValueAs, tagPlacement: _e, searchPlaceholder: ve, placeholder: ye, disabled: E = e.disabled, required: be = e.required, fullwidth: xe = e.fullwidth, hasError: Se = e.hasError, errorMessage: Ce, helptext: we, helptextDropdown: Te, helptextDropdownButton: Ee, optionalTag: De = e.optionalTag, optionalText: Oe, requiredTag: ke = e.requiredTag, requiredText: Ae, tagText: je, useWrapper: Me = e.useWrapper, inline: Ne = e.inline, counter: Pe, inputSize: Fe = e.inputSize, name: Ie, form: Le, ariaDescribedby: Re, className: ze, onChange: Be, onValueChange: Ve, children: He, strings: Ue } = ue, We = `${fe}-input`, Ge = `${fe}-listbox`, D = S || w, O = _(null), k = _(null), A = _(null), j = _(null), M = _(null), Ke = p(M, Le), N = m(() => {
|
|
21
|
+
D ? O.current?.focus() : A.current?.focus();
|
|
22
|
+
}, [D]), qe = m(() => {
|
|
23
|
+
lt(!0);
|
|
24
|
+
let e = O.current;
|
|
25
|
+
e && e.type !== "hidden" && e.setAttribute("tabindex", "-1"), A.current?.focus();
|
|
26
|
+
}, []), Je = g(() => {
|
|
27
|
+
let e = [];
|
|
28
|
+
return oe.forEach(He, (t) => {
|
|
29
|
+
if (se(t) && t.type === "option") {
|
|
30
|
+
let n = t.props;
|
|
31
|
+
e.push({
|
|
32
|
+
value: n.value ?? n.children ?? "",
|
|
33
|
+
label: n.children ?? n.value ?? "",
|
|
34
|
+
selected: n.selected,
|
|
35
|
+
disabled: n.disabled
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}), e;
|
|
39
|
+
}, [He]), Ye = g(() => ge && ge.length > 0 ? ge.map((e) => ({
|
|
40
|
+
...e,
|
|
41
|
+
fulltext: r(e)
|
|
42
|
+
})) : he && he.length > 0 ? he.map((e) => ({
|
|
43
|
+
...e,
|
|
44
|
+
fulltext: r(e)
|
|
45
|
+
})) : Je.length > 0 ? Je.map((e) => ({
|
|
46
|
+
...e,
|
|
47
|
+
fulltext: r(e)
|
|
48
|
+
})) : [], [
|
|
49
|
+
ge,
|
|
50
|
+
he,
|
|
51
|
+
Je
|
|
52
|
+
]), P = y !== void 0, [Xe, F] = v(() => {
|
|
53
|
+
let e = s(y ?? me, b), t = Ye.filter((t) => t.selected && !e.includes(t.value)).map((e) => e.value);
|
|
54
|
+
return t.length ? b ? [...e, ...t] : e.length ? e : [t[0]] : e;
|
|
55
|
+
}), Ze = _(Xe), [Qe, $e] = v(y);
|
|
56
|
+
P && y !== Qe && ($e(y), F(s(y, b)));
|
|
57
|
+
let I = P ? s(y, b) : Xe, [et, tt] = v([]), L = g(() => le([...et.filter((e) => !Ye.some((t) => t.value === e.value)), ...Ye], I), [
|
|
58
|
+
Ye,
|
|
59
|
+
et,
|
|
60
|
+
I
|
|
61
|
+
]), [R, z] = v(!1), [B, V] = v(""), [nt, rt] = v(""), [it, H] = v(""), [at, ot] = v(null), [U, W] = v(null), [st, G] = v(!1), [ct, lt] = v(!1), K = _(!1), [ut, dt] = v(!1), [ft, q] = v(-1), pt = n(["combobox"], Ue), mt = it ? t(pt.combobox[it], { value: at ?? "" }) : "", ht = o(I.length, x ?? null), gt = Pe ?? (b && x != null), _t = g(() => B ? S ? te(L, B).filtered : ee(L, B) : L, [
|
|
62
|
+
L,
|
|
63
|
+
B,
|
|
64
|
+
S
|
|
65
|
+
]), vt = m((e) => {
|
|
66
|
+
let t = k.current;
|
|
67
|
+
if (!t) return;
|
|
68
|
+
let n = b ? e.join(",") : e[0] || "";
|
|
69
|
+
ae(t, n), t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
70
|
+
}, [b]), yt = b ? I.join(",") : I[0] || "";
|
|
71
|
+
h(() => {
|
|
72
|
+
k.current && (k.current.value = yt);
|
|
73
|
+
}, [yt]), h(() => {
|
|
74
|
+
if (R || !O.current) return;
|
|
75
|
+
let e = !b && I[0] ? l(I[0], L, T) : "";
|
|
76
|
+
O.current.value !== e && (O.current.value = e);
|
|
77
|
+
}, [
|
|
78
|
+
I,
|
|
79
|
+
L,
|
|
80
|
+
T,
|
|
81
|
+
b,
|
|
82
|
+
R
|
|
83
|
+
]);
|
|
84
|
+
let J = m((e, t = !0) => {
|
|
85
|
+
P || F(e), t && (Ve?.(e), vt(e));
|
|
86
|
+
}, [
|
|
87
|
+
P,
|
|
88
|
+
Ve,
|
|
89
|
+
vt
|
|
90
|
+
]), Y = m((e) => {
|
|
91
|
+
if (!e || I.includes(e)) return;
|
|
92
|
+
if (b && o(I.length, x ?? null)) {
|
|
93
|
+
H("maxSelected");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
let t = b ? [...I, e] : [e];
|
|
97
|
+
J(t);
|
|
98
|
+
}, [
|
|
99
|
+
I,
|
|
100
|
+
b,
|
|
101
|
+
x,
|
|
102
|
+
J
|
|
103
|
+
]), X = m((e) => {
|
|
104
|
+
if (!e) return;
|
|
105
|
+
let t = I.filter((t) => t !== e);
|
|
106
|
+
i(L, e)?.userAdded && tt((t) => t.filter((t) => t.value !== e)), J(t);
|
|
107
|
+
}, [
|
|
108
|
+
I,
|
|
109
|
+
L,
|
|
110
|
+
J
|
|
111
|
+
]), bt = m(() => {
|
|
112
|
+
tt([]), J([]);
|
|
113
|
+
}, [J]), Z = m((e) => {
|
|
114
|
+
if (!e || e.trim() === "") return;
|
|
115
|
+
let t;
|
|
116
|
+
if (!b) t = [e];
|
|
117
|
+
else {
|
|
118
|
+
if (i(L, e) || o(I.length, x ?? null)) return;
|
|
119
|
+
t = [...I, e];
|
|
120
|
+
}
|
|
121
|
+
let n = {
|
|
122
|
+
value: e,
|
|
123
|
+
label: e,
|
|
124
|
+
userAdded: !0,
|
|
125
|
+
selected: !0
|
|
126
|
+
};
|
|
127
|
+
tt((t) => [n, ...t.filter((t) => t.value !== e)]), J(t);
|
|
128
|
+
}, [
|
|
129
|
+
b,
|
|
130
|
+
L,
|
|
131
|
+
I,
|
|
132
|
+
x,
|
|
133
|
+
J
|
|
134
|
+
]), xt = m((e = !0, t) => {
|
|
135
|
+
if (W(null), e && O.current && O.current.type !== "hidden") {
|
|
136
|
+
V(""), rt("");
|
|
137
|
+
let e = t === void 0 ? I[0] : t;
|
|
138
|
+
!b && e ? O.current.value = l(e, L, T) : O.current.value = "", b || (dt(!1), H(""));
|
|
139
|
+
}
|
|
140
|
+
}, [
|
|
141
|
+
b,
|
|
142
|
+
I,
|
|
143
|
+
L,
|
|
144
|
+
T
|
|
145
|
+
]), Q = m((e) => {
|
|
146
|
+
if (E) return;
|
|
147
|
+
H(""), W(null);
|
|
148
|
+
let t = i(L, e)?.value || null, n = I.includes(e || t || ""), r = !!t, ee = L.find((t) => t.value === e)?.disabled || !1, te = !e?.trim(), a = !b, s = b, re = o(I.length, x ?? null), c = !1, u = !0, d = "", ie = null, f = "", p;
|
|
149
|
+
ee || (!r && w && !te ? (Z(e), d = "valueAdded", c = s, a && (p = e || "")) : !r && !w ? (a && I[0] && X(I[0]), u = !1, c = !0, d = "noResults") : n ? (X(t), c = !0, p = "", a && D && O.current && O.current.type !== "hidden" && (O.current.value = "")) : te && a ? (bt(), c = !0, p = "") : a ? (I[0] && X(I[0]), Y(t), c = !1, p = t || "", d = "valueSelected", ie = D ? l(t || "", L, T) : ne(i(L, t), T)) : s && !re ? (Y(t), c = !0) : s && re ? (d = "maxSelected", u = !1, f = e || "") : (a && bt(), d = "noValidValue", u = !1, c = !0, f = e || "", p = ""), z(c), V(f), xt(u, p), H(d), ot(ie), c || window.setTimeout(() => {
|
|
150
|
+
qe();
|
|
151
|
+
}, 0));
|
|
152
|
+
}, [
|
|
153
|
+
E,
|
|
154
|
+
L,
|
|
155
|
+
I,
|
|
156
|
+
b,
|
|
157
|
+
x,
|
|
158
|
+
w,
|
|
159
|
+
Z,
|
|
160
|
+
X,
|
|
161
|
+
bt,
|
|
162
|
+
Y,
|
|
163
|
+
xt,
|
|
164
|
+
qe,
|
|
165
|
+
D,
|
|
166
|
+
T
|
|
167
|
+
]), $ = m(() => {
|
|
168
|
+
if (G(!1), W(null), H(""), V(""), O.current && O.current.type !== "hidden") {
|
|
169
|
+
let e = O.current.value, t = I[0];
|
|
170
|
+
if (!b) {
|
|
171
|
+
if (!e) I[0] && X(I[0]), t = void 0;
|
|
172
|
+
else {
|
|
173
|
+
let n = i(L, e);
|
|
174
|
+
n && n.value !== I[0] ? (I[0] && X(I[0]), Y(n.value), t = n.value) : !n && w && (I[0] && X(I[0]), Z(e), t = e);
|
|
175
|
+
}
|
|
176
|
+
} else if (e !== "") {
|
|
177
|
+
let { action: t, value: n } = c(e, I, L, w, b);
|
|
178
|
+
switch (t) {
|
|
179
|
+
case "addUserValue":
|
|
180
|
+
Z(n);
|
|
181
|
+
break;
|
|
182
|
+
case "selectOption":
|
|
183
|
+
Y(n);
|
|
184
|
+
break;
|
|
185
|
+
case "removeValue": X(n);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
!b && t ? O.current.value = l(t, L, T) : O.current.value = "";
|
|
189
|
+
}
|
|
190
|
+
z(!1), dt(!1);
|
|
191
|
+
}, [
|
|
192
|
+
I,
|
|
193
|
+
L,
|
|
194
|
+
w,
|
|
195
|
+
b,
|
|
196
|
+
T,
|
|
197
|
+
Z,
|
|
198
|
+
Y,
|
|
199
|
+
X
|
|
200
|
+
]), St = m((e) => {
|
|
201
|
+
if (!e.trim().toLowerCase()) {
|
|
202
|
+
W(null), H(""), !b && I[0] && X(I[0]);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
let t = a(e, I, L, w);
|
|
206
|
+
W(t.addValueText), H(t.userInfoMessage);
|
|
207
|
+
}, [
|
|
208
|
+
I,
|
|
209
|
+
L,
|
|
210
|
+
w,
|
|
211
|
+
b,
|
|
212
|
+
X
|
|
213
|
+
]), Ct = m((e) => {
|
|
214
|
+
if (E) return;
|
|
215
|
+
let t = e.target.value;
|
|
216
|
+
if (rt(t), V(t), St(t), S && t) {
|
|
217
|
+
let { suggestion: n } = te(L, t);
|
|
218
|
+
n?.label && O.current && !e.nativeEvent.inputType?.includes("deleteContent") && (O.current.value = n.label, window.setTimeout(() => O.current?.setSelectionRange(t.length, n.label.length), 0));
|
|
219
|
+
}
|
|
220
|
+
}, [
|
|
221
|
+
E,
|
|
222
|
+
S,
|
|
223
|
+
L,
|
|
224
|
+
St
|
|
225
|
+
]), wt = m((e) => {
|
|
226
|
+
if (e.key === "Backspace") {
|
|
227
|
+
let t = !O.current?.value;
|
|
228
|
+
if (!B && t && b && I.length > 0) {
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
let t = I[I.length - 1];
|
|
231
|
+
X(t);
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (e.key === "ArrowLeft" && b && I.length > 0 && (O.current?.selectionStart ?? 0) === 0 && !O.current?.value) {
|
|
236
|
+
e.preventDefault(), q(I.length - 1);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
let t = re(e.key, e.shiftKey, b);
|
|
240
|
+
if (t && !(e.key === "Tab" && !R)) {
|
|
241
|
+
if (t === "focusListbox" && e.key === "Tab" && !j.current?.querySelector("[role=\"option\"]:not([data-disabled]), [data-type=\"new-option\"]")) {
|
|
242
|
+
$();
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
switch (e.preventDefault(), t) {
|
|
246
|
+
case "addValue": {
|
|
247
|
+
let e = O.current?.value.trim() || "";
|
|
248
|
+
if (V(e), e && I.includes(e)) {
|
|
249
|
+
xt(!0), H("alreadySelected");
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
Q(e);
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
case "focusListbox":
|
|
256
|
+
j.current && (R || z(!0), d(j.current, {
|
|
257
|
+
disabled: E,
|
|
258
|
+
allowUserInput: w,
|
|
259
|
+
customUserInput: U,
|
|
260
|
+
includeSearch: C
|
|
261
|
+
}));
|
|
262
|
+
break;
|
|
263
|
+
case "closeOptions": z(!1);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}, [
|
|
267
|
+
B,
|
|
268
|
+
I,
|
|
269
|
+
b,
|
|
270
|
+
E,
|
|
271
|
+
w,
|
|
272
|
+
U,
|
|
273
|
+
C,
|
|
274
|
+
R,
|
|
275
|
+
X,
|
|
276
|
+
Q,
|
|
277
|
+
N
|
|
278
|
+
]), Tt = m(() => {
|
|
279
|
+
if (!E) {
|
|
280
|
+
if (lt(!1), K.current) {
|
|
281
|
+
K.current = !1, G(!0);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
!b && I[0] && O.current && O.current.type !== "hidden" && (dt(!0), O.current.value = l(I[0], L, T)), G(!0), V(""), z(!0);
|
|
285
|
+
}
|
|
286
|
+
}, [
|
|
287
|
+
E,
|
|
288
|
+
b,
|
|
289
|
+
I,
|
|
290
|
+
L,
|
|
291
|
+
T
|
|
292
|
+
]), Et = m(() => {
|
|
293
|
+
G(!1), dt(!1);
|
|
294
|
+
}, []), Dt = m((e) => {
|
|
295
|
+
if (E || !R) return;
|
|
296
|
+
let t = e.relatedTarget, n = M.current;
|
|
297
|
+
n && t && n.contains(t) || $();
|
|
298
|
+
}, [
|
|
299
|
+
E,
|
|
300
|
+
R,
|
|
301
|
+
$
|
|
302
|
+
]), Ot = m((e) => {
|
|
303
|
+
if (E) {
|
|
304
|
+
e.preventDefault(), e.stopPropagation();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (D) O.current?.focus();
|
|
308
|
+
else {
|
|
309
|
+
e.stopPropagation(), e.preventDefault();
|
|
310
|
+
let t = !R;
|
|
311
|
+
z(t), t && j.current && d(j.current, {
|
|
312
|
+
disabled: E,
|
|
313
|
+
allowUserInput: w,
|
|
314
|
+
customUserInput: U,
|
|
315
|
+
includeSearch: C
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}, [
|
|
319
|
+
E,
|
|
320
|
+
D,
|
|
321
|
+
R,
|
|
322
|
+
w,
|
|
323
|
+
U,
|
|
324
|
+
C
|
|
325
|
+
]), kt = m((e) => {
|
|
326
|
+
E || (e.stopPropagation(), D && O.current ? (O.current.focus(), G(!0)) : z((e) => !e));
|
|
327
|
+
}, [E, D]), At = m((e) => {
|
|
328
|
+
if (!E) switch (e.key) {
|
|
329
|
+
case "Enter":
|
|
330
|
+
case " ":
|
|
331
|
+
case "ArrowDown":
|
|
332
|
+
case "ArrowUp":
|
|
333
|
+
e.preventDefault(), R ? z(!1) : (z(!0), j.current && window.setTimeout(() => {
|
|
334
|
+
j.current && d(j.current, {
|
|
335
|
+
disabled: E,
|
|
336
|
+
allowUserInput: w && !ht,
|
|
337
|
+
customUserInput: U,
|
|
338
|
+
includeSearch: C
|
|
339
|
+
});
|
|
340
|
+
}, 0));
|
|
341
|
+
break;
|
|
342
|
+
case "Escape":
|
|
343
|
+
R && (e.preventDefault(), z(!1));
|
|
344
|
+
break;
|
|
345
|
+
case "Home":
|
|
346
|
+
case "End":
|
|
347
|
+
e.preventDefault(), R || z(!0), j.current && window.setTimeout(() => {
|
|
348
|
+
j.current && d(j.current, {
|
|
349
|
+
disabled: E,
|
|
350
|
+
allowUserInput: w && !ht,
|
|
351
|
+
customUserInput: U,
|
|
352
|
+
includeSearch: C
|
|
353
|
+
});
|
|
354
|
+
}, 0);
|
|
355
|
+
break;
|
|
356
|
+
case "ArrowLeft":
|
|
357
|
+
b && I.length > 0 && (e.preventDefault(), q(I.length - 1));
|
|
358
|
+
break;
|
|
359
|
+
case "Backspace":
|
|
360
|
+
case "Delete": if (b && I.length > 0) {
|
|
361
|
+
e.preventDefault();
|
|
362
|
+
let t = I[I.length - 1];
|
|
363
|
+
X(t);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}, [
|
|
367
|
+
E,
|
|
368
|
+
R,
|
|
369
|
+
w,
|
|
370
|
+
ht,
|
|
371
|
+
U,
|
|
372
|
+
C,
|
|
373
|
+
b,
|
|
374
|
+
I,
|
|
375
|
+
X
|
|
376
|
+
]), jt = m((e) => {
|
|
377
|
+
Q(e);
|
|
378
|
+
}, [Q]), Mt = m((e, t) => {
|
|
379
|
+
switch (e.key) {
|
|
380
|
+
case "Enter":
|
|
381
|
+
case " ":
|
|
382
|
+
e.preventDefault(), Q(t);
|
|
383
|
+
break;
|
|
384
|
+
case "ArrowDown":
|
|
385
|
+
e.preventDefault(), ie(e.currentTarget);
|
|
386
|
+
break;
|
|
387
|
+
case "ArrowUp":
|
|
388
|
+
e.preventDefault(), j.current && f(e.currentTarget, j.current, C);
|
|
389
|
+
break;
|
|
390
|
+
case "Escape":
|
|
391
|
+
e.preventDefault(), z(!1), D && (K.current = !0), N();
|
|
392
|
+
break;
|
|
393
|
+
case "Tab": $();
|
|
394
|
+
}
|
|
395
|
+
}, [
|
|
396
|
+
Q,
|
|
397
|
+
C,
|
|
398
|
+
N,
|
|
399
|
+
$,
|
|
400
|
+
D
|
|
401
|
+
]), Nt = m((e) => {
|
|
402
|
+
X(e), q(-1), D && O.current && (G(!0), O.current.focus());
|
|
403
|
+
}, [X, D]), Pt = m((e, t) => {
|
|
404
|
+
switch (e.stopPropagation(), e.key) {
|
|
405
|
+
case "ArrowLeft":
|
|
406
|
+
e.preventDefault(), t > 0 && q(t - 1);
|
|
407
|
+
break;
|
|
408
|
+
case "ArrowRight":
|
|
409
|
+
e.preventDefault(), t < I.length - 1 ? q(t + 1) : (q(-1), D && O.current ? O.current.focus() : A.current?.focus());
|
|
410
|
+
break;
|
|
411
|
+
case "Backspace":
|
|
412
|
+
case "Delete":
|
|
413
|
+
e.preventDefault();
|
|
414
|
+
{
|
|
415
|
+
let e = I[t], n = t >= I.length - 1 ? t - 1 : t;
|
|
416
|
+
X(e), n >= 0 ? q(n) : (q(-1), D && O.current ? O.current.focus() : A.current?.focus());
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
case "Tab":
|
|
420
|
+
q(-1);
|
|
421
|
+
break;
|
|
422
|
+
case "Escape": e.preventDefault(), q(-1), D && O.current ? O.current.focus() : A.current?.focus();
|
|
423
|
+
}
|
|
424
|
+
}, [
|
|
425
|
+
I,
|
|
426
|
+
D,
|
|
427
|
+
X
|
|
428
|
+
]), Ft = m((e) => {
|
|
429
|
+
V(e.target.value), St(e.target.value);
|
|
430
|
+
}, [St]), It = m((e) => {
|
|
431
|
+
switch (e.key) {
|
|
432
|
+
case "ArrowDown":
|
|
433
|
+
e.preventDefault(), j.current && j.current.querySelector("[role=\"option\"]:not([data-disabled]), [data-type=\"new-option\"]")?.focus();
|
|
434
|
+
break;
|
|
435
|
+
case "Tab":
|
|
436
|
+
$();
|
|
437
|
+
break;
|
|
438
|
+
case "Escape": e.preventDefault(), z(!1), D && (K.current = !0), N();
|
|
439
|
+
}
|
|
440
|
+
}, [
|
|
441
|
+
N,
|
|
442
|
+
$,
|
|
443
|
+
D
|
|
444
|
+
]), Lt = m((e) => {
|
|
445
|
+
Q(e);
|
|
446
|
+
}, [Q]), Rt = m((e) => {
|
|
447
|
+
switch (e.key) {
|
|
448
|
+
case "Enter":
|
|
449
|
+
case " ":
|
|
450
|
+
e.preventDefault(), Q(e.currentTarget.dataset.value || "");
|
|
451
|
+
break;
|
|
452
|
+
case "ArrowDown":
|
|
453
|
+
e.preventDefault(), j.current && u(j.current);
|
|
454
|
+
break;
|
|
455
|
+
case "ArrowUp":
|
|
456
|
+
e.preventDefault(), j.current && f(e.currentTarget, j.current, C);
|
|
457
|
+
break;
|
|
458
|
+
case "Escape": e.preventDefault(), z(!1), D && (K.current = !0), N();
|
|
459
|
+
}
|
|
460
|
+
}, [
|
|
461
|
+
Q,
|
|
462
|
+
C,
|
|
463
|
+
N,
|
|
464
|
+
D
|
|
465
|
+
]);
|
|
466
|
+
return h(() => {
|
|
467
|
+
if (!R) return;
|
|
468
|
+
let e = (e) => {
|
|
469
|
+
let t = e.target;
|
|
470
|
+
M.current && !M.current.contains(t) && $();
|
|
471
|
+
};
|
|
472
|
+
return document.addEventListener("click", e, !0), () => {
|
|
473
|
+
document.removeEventListener("click", e, !0);
|
|
474
|
+
};
|
|
475
|
+
}, [R, $]), h(() => {
|
|
476
|
+
if (!Ke) return;
|
|
477
|
+
let e, t = () => {
|
|
478
|
+
window.clearTimeout(e), e = window.setTimeout(() => {
|
|
479
|
+
if (F(Ze.current), tt([]), rt(""), V(""), W(null), H(""), k.current) {
|
|
480
|
+
let e = b ? Ze.current.join(",") : Ze.current[0] || "";
|
|
481
|
+
k.current.value = e;
|
|
482
|
+
}
|
|
483
|
+
}, 0);
|
|
484
|
+
};
|
|
485
|
+
return Ke.addEventListener("reset", t), () => {
|
|
486
|
+
Ke.removeEventListener("reset", t), window.clearTimeout(e);
|
|
487
|
+
};
|
|
488
|
+
}, [b, Ke]), ce(de, () => ({
|
|
489
|
+
get value() {
|
|
490
|
+
return k.current?.value ?? "";
|
|
491
|
+
},
|
|
492
|
+
set value(e) {
|
|
493
|
+
let t = Array.isArray(e) ? e : e ? String(e).split(",").filter(Boolean) : [];
|
|
494
|
+
P || F(t), k.current && (k.current.value = t.join(","));
|
|
495
|
+
},
|
|
496
|
+
focus() {
|
|
497
|
+
D ? O.current?.focus() : A.current?.focus();
|
|
498
|
+
},
|
|
499
|
+
blur() {
|
|
500
|
+
D ? O.current?.blur() : A.current?.blur();
|
|
501
|
+
}
|
|
502
|
+
}), [P]), {
|
|
503
|
+
id: fe,
|
|
504
|
+
inputId: We,
|
|
505
|
+
listboxId: Ge,
|
|
506
|
+
values: I,
|
|
507
|
+
inputValue: nt,
|
|
508
|
+
searchValue: B,
|
|
509
|
+
options: L,
|
|
510
|
+
filteredOptions: _t,
|
|
511
|
+
isOpen: R,
|
|
512
|
+
userInfoMessage: mt,
|
|
513
|
+
skipInputTab: ct,
|
|
514
|
+
restoreInputTab: () => lt(!1),
|
|
515
|
+
strings: Ue,
|
|
516
|
+
addValueText: U,
|
|
517
|
+
maxIsReached: ht,
|
|
518
|
+
editingSingleValue: ut,
|
|
519
|
+
inputFocus: st,
|
|
520
|
+
focusedTagIndex: ft,
|
|
521
|
+
label: pe,
|
|
522
|
+
multiple: b,
|
|
523
|
+
maxlength: x,
|
|
524
|
+
typeahead: S,
|
|
525
|
+
includeSearch: C,
|
|
526
|
+
allowUserInput: w,
|
|
527
|
+
displayValueAs: T,
|
|
528
|
+
tagPlacement: _e,
|
|
529
|
+
searchPlaceholder: ve,
|
|
530
|
+
placeholder: ye,
|
|
531
|
+
disabled: E,
|
|
532
|
+
required: be,
|
|
533
|
+
fullwidth: xe,
|
|
534
|
+
hasError: Se,
|
|
535
|
+
errorMessage: Ce,
|
|
536
|
+
helptext: we,
|
|
537
|
+
helptextDropdown: Te,
|
|
538
|
+
helptextDropdownButton: Ee,
|
|
539
|
+
optionalTag: De,
|
|
540
|
+
optionalText: Oe,
|
|
541
|
+
requiredTag: ke,
|
|
542
|
+
requiredText: Ae,
|
|
543
|
+
tagText: je,
|
|
544
|
+
useWrapper: Me,
|
|
545
|
+
inline: Ne,
|
|
546
|
+
inputSize: Fe,
|
|
547
|
+
name: Ie,
|
|
548
|
+
form: Le,
|
|
549
|
+
ariaDescribedby: Re,
|
|
550
|
+
className: ze,
|
|
551
|
+
hasCounter: gt,
|
|
552
|
+
inputRef: O,
|
|
553
|
+
changeInputRef: k,
|
|
554
|
+
triggerRef: A,
|
|
555
|
+
listboxRef: j,
|
|
556
|
+
wrapperRef: M,
|
|
557
|
+
handleInputChange: Ct,
|
|
558
|
+
handleInputKeydown: wt,
|
|
559
|
+
handleInputFocus: Tt,
|
|
560
|
+
handleInputBlur: Et,
|
|
561
|
+
handleFocusOut: Dt,
|
|
562
|
+
handleInputClick: Ot,
|
|
563
|
+
handlePlaceholderClick: kt,
|
|
564
|
+
handleSelectOnlyKeydown: At,
|
|
565
|
+
handleOptionClick: jt,
|
|
566
|
+
handleOptionKeydown: Mt,
|
|
567
|
+
handleTagRemove: Nt,
|
|
568
|
+
handleTagKeydown: Pt,
|
|
569
|
+
handleSearchInput: Ft,
|
|
570
|
+
handleSearchKeydown: It,
|
|
571
|
+
handleNewOptionClick: Lt,
|
|
572
|
+
handleNewOptionKeydown: Rt,
|
|
573
|
+
onChange: Be
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
//#endregion
|
|
577
|
+
export { ue as useComboboxState };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CONSENT_DEFAULTS as e } from "../../shared-types/consent.js";
|
|
3
|
+
import { consentStrings as t } from "../../shared-strings/consent.js";
|
|
4
|
+
import { PktButton as n } from "../button/Button.js";
|
|
5
|
+
import { forwardRef as r, useEffect as i, useRef as a } from "react";
|
|
6
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/consent/Consent.tsx
|
|
8
|
+
var s = null, c = () => s || (s = new Promise((e, t) => {
|
|
9
|
+
if (document.querySelector("#oslo-consent-script")) {
|
|
10
|
+
e();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
let n = document.createElement("script");
|
|
14
|
+
n.src = "https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js", n.id = "oslo-consent-script", n.onload = () => e(), n.onerror = t, document.head.appendChild(n);
|
|
15
|
+
let r = document.createElement("link");
|
|
16
|
+
r.href = "https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css", r.type = "text/css", r.rel = "stylesheet", r.id = "oslo-consent-styles", document.head.appendChild(r);
|
|
17
|
+
}), s), l = (e) => {
|
|
18
|
+
if (typeof e != "string") return e;
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(e);
|
|
21
|
+
} catch {
|
|
22
|
+
return e;
|
|
23
|
+
}
|
|
24
|
+
}, u = (e) => l(e.value).items.reduce((e, t) => (e[t.name] = t.consent, e), {}), d = r(function({ devMode: r = e.devMode, cookieDomain: s = null, cookieSecure: l = null, cookieExpiryDays: d = null, hotjarId: f = null, googleAnalyticsId: p = null, i18nLanguage: m = e.i18nLanguage, triggerType: h = e.triggerType, triggerText: g, onToggleConsent: _, ...v }, y) {
|
|
25
|
+
let b = a(_);
|
|
26
|
+
b.current = _;
|
|
27
|
+
let x = a({
|
|
28
|
+
devMode: r,
|
|
29
|
+
cookieDomain: s,
|
|
30
|
+
cookieSecure: l,
|
|
31
|
+
cookieExpiryDays: d,
|
|
32
|
+
hotjarId: f,
|
|
33
|
+
googleAnalyticsId: p
|
|
34
|
+
});
|
|
35
|
+
x.current = {
|
|
36
|
+
devMode: r,
|
|
37
|
+
cookieDomain: s,
|
|
38
|
+
cookieSecure: l,
|
|
39
|
+
cookieExpiryDays: d,
|
|
40
|
+
hotjarId: f,
|
|
41
|
+
googleAnalyticsId: p
|
|
42
|
+
};
|
|
43
|
+
let S = a(() => {}), C = Object.prototype.hasOwnProperty.call(t.i18n, m) ? m : "nb", w = g ?? t.i18n[C].contentPresentation.buttons.settings;
|
|
44
|
+
i(() => {
|
|
45
|
+
let e = !1, t, n, r = x.current;
|
|
46
|
+
window.cookieBanner_googleAnalyticsId = r.googleAnalyticsId, window.cookieBanner_hotjarId = r.hotjarId, r.cookieDomain && (window.cookieBanner_cookieDomain = r.cookieDomain), r.cookieSecure && (window.cookieBanner_cookieSecure = r.cookieSecure), r.cookieExpiryDays && (window.cookieBanner_cookieExpiryDays = r.cookieExpiryDays), r.devMode && (window.cookieBanner_devMode = r.devMode);
|
|
47
|
+
let i = (e) => {
|
|
48
|
+
let t = b.current;
|
|
49
|
+
t && t(new CustomEvent("toggle-consent", {
|
|
50
|
+
detail: u(e),
|
|
51
|
+
bubbles: !0,
|
|
52
|
+
cancelable: !1
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
return S.current = () => {
|
|
56
|
+
window.document.dispatchEvent(new Event("CookieBannerReady", {
|
|
57
|
+
bubbles: !0,
|
|
58
|
+
cancelable: !0
|
|
59
|
+
}));
|
|
60
|
+
let r = window.cookieBanner, a = window.__cookieEvents;
|
|
61
|
+
!r || !a || r.cookieConsent.validateConsentCookie().then((o) => {
|
|
62
|
+
if (e || !o) return;
|
|
63
|
+
let s = r.cookieConsent.getConsentCookie();
|
|
64
|
+
window.clearTimeout(n), n = window.setTimeout(() => {
|
|
65
|
+
e || i({ value: s });
|
|
66
|
+
}, 0), t && a.off("CookieManager.setCookie", t), t = (e) => i(e), a.on("CookieManager.setCookie", t);
|
|
67
|
+
});
|
|
68
|
+
}, c().then(() => {
|
|
69
|
+
e || S.current();
|
|
70
|
+
}), () => {
|
|
71
|
+
e = !0, window.clearTimeout(n), t && window.__cookieEvents?.off("CookieManager.setCookie", t);
|
|
72
|
+
};
|
|
73
|
+
}, []);
|
|
74
|
+
let T = (e) => {
|
|
75
|
+
e.preventDefault(), window.cookieBanner?.cookieConsent || S.current(), setTimeout(() => window.cookieBanner?.openCookieModal());
|
|
76
|
+
};
|
|
77
|
+
return h === "link" ? /* @__PURE__ */ o("a", {
|
|
78
|
+
...v,
|
|
79
|
+
ref: y,
|
|
80
|
+
href: "#",
|
|
81
|
+
className: "pkt-link",
|
|
82
|
+
"aria-haspopup": "dialog",
|
|
83
|
+
onClick: T,
|
|
84
|
+
children: w
|
|
85
|
+
}) : h === "footerlink" ? /* @__PURE__ */ o("a", {
|
|
86
|
+
...v,
|
|
87
|
+
ref: y,
|
|
88
|
+
href: "#",
|
|
89
|
+
className: "pkt-footer__link",
|
|
90
|
+
"aria-haspopup": "dialog",
|
|
91
|
+
onClick: T,
|
|
92
|
+
children: w
|
|
93
|
+
}) : h === "icon" ? /* @__PURE__ */ o(n, {
|
|
94
|
+
ref: y,
|
|
95
|
+
skin: "tertiary",
|
|
96
|
+
variant: "icon-only",
|
|
97
|
+
iconName: "cookie",
|
|
98
|
+
"aria-haspopup": "dialog",
|
|
99
|
+
onClick: T,
|
|
100
|
+
children: w
|
|
101
|
+
}) : /* @__PURE__ */ o(n, {
|
|
102
|
+
ref: y,
|
|
103
|
+
"aria-haspopup": "dialog",
|
|
104
|
+
onClick: T,
|
|
105
|
+
children: w
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
d.displayName = "PktConsent";
|
|
109
|
+
//#endregion
|
|
110
|
+
export { d as PktConsent };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePktStrings as e } from "../../hooks/usePktStrings.js";
|
|
3
|
+
import { fromISOtoLocal as t, sortDateStrings as n } from "../../shared-utils/date-utils.js";
|
|
4
|
+
import { PktTag as r } from "../tag/Tag.js";
|
|
5
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/datepicker/DateTags.tsx
|
|
7
|
+
var a = ({ dates: a, dateformat: o, idBase: s, strings: c, onDateRemoved: l }) => {
|
|
8
|
+
let u = n(a), d = e(["datepicker"], c).datepicker.deleteDate;
|
|
9
|
+
return /* @__PURE__ */ i("div", {
|
|
10
|
+
className: "pkt-date-tags pkt-datepicker__tags",
|
|
11
|
+
"aria-live": "polite",
|
|
12
|
+
children: u.map((e) => {
|
|
13
|
+
let n = t(e, o);
|
|
14
|
+
return /* @__PURE__ */ i(r, {
|
|
15
|
+
id: `${s}${e}-tag`,
|
|
16
|
+
closeTag: !0,
|
|
17
|
+
ariaLabel: `${d} ${n}`,
|
|
18
|
+
onClose: () => l(e),
|
|
19
|
+
children: /* @__PURE__ */ i("time", {
|
|
20
|
+
dateTime: e,
|
|
21
|
+
children: n
|
|
22
|
+
})
|
|
23
|
+
}, e);
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { a as DateTags };
|