@fremtind/jokul 4.6.1 → 4.7.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/build/build-stats.html +1 -1
- package/build/cjs/components/expander/Expander.cjs +1 -1
- package/build/cjs/components/expander/Expander.cjs.map +1 -1
- package/build/cjs/components/popover/Popover.cjs +1 -1
- package/build/cjs/components/popover/Popover.cjs.map +1 -1
- package/build/cjs/components/popover/types.d.cts +8 -1
- package/build/cjs/components/select/Select.cjs +1 -1
- package/build/cjs/components/select/Select.cjs.map +1 -1
- package/build/cjs/components/system-message/types.d.cts +7 -2
- package/build/cjs/components/typography/Text.cjs +2 -0
- package/build/cjs/components/typography/Text.cjs.map +1 -0
- package/build/cjs/components/typography/Text.d.cts +5 -0
- package/build/cjs/components/typography/Title.cjs +2 -0
- package/build/cjs/components/typography/Title.cjs.map +1 -0
- package/build/cjs/components/typography/Title.d.cts +5 -0
- package/build/cjs/components/typography/index.cjs +2 -0
- package/build/cjs/components/typography/index.cjs.map +1 -0
- package/build/cjs/components/typography/index.d.cts +3 -0
- package/build/cjs/components/typography/types.cjs +2 -0
- package/build/cjs/components/typography/types.cjs.map +1 -0
- package/build/cjs/components/typography/types.d.cts +48 -0
- package/build/cjs/hooks/useListNavigation/useListNavigation.cjs +1 -1
- package/build/cjs/hooks/useListNavigation/useListNavigation.cjs.map +1 -1
- package/build/cjs/hooks/useListNavigation/useListNavigation.d.cts +11 -2
- package/build/es/components/datepicker/DatePicker.js +1 -1
- package/build/es/components/datepicker/internal/Calendar.js +1 -1
- package/build/es/components/datepicker/internal/useCalendar.js +1 -1
- package/build/es/components/datepicker/internal/utils.js +1 -1
- package/build/es/components/expander/Expander.js +1 -1
- package/build/es/components/expander/Expander.js.map +1 -1
- package/build/es/components/menu/Menu.js +1 -1
- package/build/es/components/popover/Popover.js +1 -1
- package/build/es/components/popover/Popover.js.map +1 -1
- package/build/es/components/popover/types.d.ts +8 -1
- package/build/es/components/select/Select.js +1 -1
- package/build/es/components/select/Select.js.map +1 -1
- package/build/es/components/system-message/types.d.ts +7 -2
- package/build/es/components/toast/toastContext.js +1 -1
- package/build/es/components/tooltip/Tooltip.js +1 -1
- package/build/es/components/typography/Text.d.ts +5 -0
- package/build/es/components/typography/Text.js +2 -0
- package/build/es/components/typography/Text.js.map +1 -0
- package/build/es/components/typography/Title.d.ts +5 -0
- package/build/es/components/typography/Title.js +2 -0
- package/build/es/components/typography/Title.js.map +1 -0
- package/build/es/components/typography/index.d.ts +3 -0
- package/build/es/components/typography/index.js +2 -0
- package/build/es/components/typography/index.js.map +1 -0
- package/build/es/components/typography/types.d.ts +48 -0
- package/build/es/components/typography/types.js +2 -0
- package/build/es/components/typography/types.js.map +1 -0
- package/build/es/hooks/stories/content.js +1 -1
- package/build/es/hooks/useListNavigation/useListNavigation.d.ts +11 -2
- package/build/es/hooks/useListNavigation/useListNavigation.js +1 -1
- package/build/es/hooks/useListNavigation/useListNavigation.js.map +1 -1
- package/build/es/index.js +1 -1
- package/build/es/utilities/constants/index.js +1 -1
- package/build/es/utilities/constants/unicode.js +1 -1
- package/build/es/utilities/formatters/bytes/formatBytes.js +1 -1
- package/build/es/utilities/formatters/fodselsnummer/formatFodselsnummer.js +1 -1
- package/build/es/utilities/formatters/kontonummer/formatKontonummer.js +1 -1
- package/build/es/utilities/formatters/kortnummer/formatKortnummer.js +1 -1
- package/build/es/utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.js +1 -1
- package/build/es/utilities/formatters/telefonnummer/formatTelefonnummer.js +1 -1
- package/build/es/utilities/formatters/valuta/formatValuta.js +1 -1
- package/build/es/utilities/index.js +1 -1
- package/build/{index-CWRMnfcx.js → index-C1iqmqvT.js} +2 -2
- package/build/{index-CWRMnfcx.js.map → index-C1iqmqvT.js.map} +1 -1
- package/build/{utils-CcE6HjQp.js → utils-CtwpNW4I.js} +2 -2
- package/build/{utils-CcE6HjQp.js.map → utils-CtwpNW4I.js.map} +1 -1
- package/package.json +18 -4
- package/styles/components/countdown/countdown.css +2 -2
- package/styles/components/countdown/countdown.min.css +1 -1
- package/styles/components/expander/expandable.css +12 -10
- package/styles/components/expander/expandable.min.css +1 -1
- package/styles/components/expander/expandable.scss +15 -12
- package/styles/components/feedback/feedback.css +2 -2
- package/styles/components/feedback/feedback.min.css +1 -1
- package/styles/components/file-input/file-input.css +9 -9
- package/styles/components/file-input/file-input.min.css +1 -1
- package/styles/components/input-group/input-group.css +2 -2
- package/styles/components/input-group/input-group.min.css +1 -1
- package/styles/components/loader/loader.css +6 -6
- package/styles/components/loader/loader.min.css +1 -1
- package/styles/components/loader/skeleton-loader.css +3 -3
- package/styles/components/loader/skeleton-loader.min.css +1 -1
- package/styles/components/message/message.css +2 -2
- package/styles/components/message/message.min.css +1 -1
- package/styles/components/progress-bar/progress-bar.css +1 -1
- package/styles/components/progress-bar/progress-bar.min.css +1 -1
- package/styles/components/segmented-control/segmented-control.css +2 -2
- package/styles/components/segmented-control/segmented-control.min.css +1 -1
- package/styles/components/select/select.css +63 -14
- package/styles/components/select/select.min.css +1 -1
- package/styles/components/select/select.scss +120 -22
- package/styles/components/system-message/system-message.css +7 -16
- package/styles/components/system-message/system-message.min.css +1 -1
- package/styles/components/system-message/system-message.scss +2 -10
- package/styles/components/toast/toast.css +4 -4
- package/styles/components/toast/toast.min.css +1 -1
- package/styles/components/typography/_index.scss +2 -0
- package/styles/components/typography/text.css +52 -0
- package/styles/components/typography/text.min.css +1 -0
- package/styles/components/typography/text.scss +55 -0
- package/styles/components/typography/title.css +70 -0
- package/styles/components/typography/title.min.css +1 -0
- package/styles/components/typography/title.scss +58 -0
- package/styles/core/core.css +1 -1
- package/styles/core/core.min.css +1 -1
- package/styles/core/utility/_paragraphs.scss +11 -1
- package/styles/styles.css +220 -62
- package/styles/styles.min.css +2 -2
- package/styles/styles.scss +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../../src/components/select/Select.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n type CSSProperties,\n type FocusEvent,\n forwardRef,\n type KeyboardEvent,\n type MouseEvent,\n type RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useAnimatedHeight } from \"../../hooks/useAnimatedHeight/useAnimatedHeight.js\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { useListNavigation } from \"../../hooks/useListNavigation/useListNavigation.js\";\nimport { usePreviousValue } from \"../../hooks/usePreviousValue/usePreviousValue.js\";\nimport { type ValuePair, getValuePair } from \"../../utilities/valuePair.js\";\nimport { ArrowVerticalAnimated } from \"../icon/icons/animated/ArrowVerticalAnimated.js\";\nimport { InputGroup } from \"../input-group/InputGroup.js\";\nimport type { PopupTipProps } from \"../tooltip/types.js\";\nimport { focusSelected, toLower } from \"./select-utils.js\";\nimport type { SelectProps } from \"./types.js\";\n\nconst noop = () => {\n return;\n};\n\ninterface Option extends ValuePair {\n visible: boolean;\n}\n\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(\n (props, forwardedSelectRef) => {\n const {\n id,\n name,\n items,\n value,\n label,\n labelProps,\n onChange,\n onBlur,\n onFocus,\n className,\n helpLabel,\n errorLabel,\n invalid,\n searchable = false,\n inline = false,\n defaultPrompt = \"Velg\",\n width,\n maxShownOptions = 5,\n style,\n tooltip,\n ...rest\n } = props;\n\n const listId = useId(id || \"jkl-select\", { generateSuffix: !id });\n const labelId = `${listId}_label`;\n const buttonId = `${listId}_button`;\n const searchInputId = `${listId}_search-input`;\n\n const [dropdownIsShown, setShown] = useState(false);\n const toggleListVisibility = useCallback(() => {\n setShown((previousValue) => !previousValue);\n }, []);\n\n /// Søk\n\n const isSearchable = Boolean(searchable);\n const showSearchInputField = isSearchable && dropdownIsShown;\n const [searchValue, setSearchValue] = useState(\"\");\n const searchFn = useCallback(\n (item: ValuePair) => {\n if (\n item.label.toLowerCase().includes(searchValue.toLowerCase())\n ) {\n return true;\n }\n\n if (typeof searchable === \"function\") {\n return searchable(searchValue, item);\n }\n\n return false;\n },\n [searchable, searchValue],\n );\n const visibleItems: Option[] = useMemo(\n () =>\n items.map(getValuePair).map((item) => {\n const visible =\n !isSearchable || searchValue === \"\" || searchFn(item);\n return { ...item, visible };\n }),\n [items, isSearchable, searchValue, searchFn],\n );\n const valueIsInItems: boolean = useMemo(() => {\n if (typeof value === \"undefined\") {\n return false;\n }\n return items.some((item) =>\n typeof item === \"string\"\n ? item === value\n : item.value === value,\n );\n }, [value, items]);\n\n /// Valg av <option>\n\n const [selectedValue, setSelectedValue] = useState<string>(\n valueIsInItems && value !== undefined ? value : \"\",\n );\n const hasSelectedValue = selectedValue !== \"\";\n const selectedValueLabel = useMemo(\n () =>\n visibleItems.find((item) => item.value === selectedValue)\n ?.label || defaultPrompt,\n [visibleItems, selectedValue, defaultPrompt],\n );\n\n const selectRef = useRef<HTMLSelectElement | null>(null);\n // Hjelpefunksjon som gjør det enklere å forwarde refen og å bruke den selv internt\n const unifiedSelectRef = useCallback(\n (instance: HTMLSelectElement | null) => {\n selectRef.current = instance;\n if (forwardedSelectRef) {\n if (typeof forwardedSelectRef === \"function\") {\n forwardedSelectRef(instance);\n } else {\n forwardedSelectRef.current = instance;\n }\n }\n if (instance) {\n setSelectedValue(instance.value);\n }\n },\n [forwardedSelectRef],\n );\n\n const previousValue = usePreviousValue(value);\n useEffect(() => {\n if (value === previousValue) {\n return;\n }\n if (typeof value === \"undefined\" || !valueIsInItems) {\n setSelectedValue(\"\");\n } else {\n setSelectedValue(value);\n }\n }, [value, previousValue, valueIsInItems]);\n\n const selectOption = useCallback(\n (item: Option) => {\n const nextValue = item.value;\n setSearchValue(\"\");\n setSelectedValue(nextValue);\n toggleListVisibility();\n buttonRef.current?.focus();\n },\n [toggleListVisibility],\n );\n\n // La komponenten rendre <select> med den valgte verdien før onChange trigges, slik at\n // react-hook-form@>7.41.1 behandler feltet som at det har en verdi.\n const previousSelectedValue = usePreviousValue(selectedValue);\n useEffect(() => {\n // previousSelectedValue er undefined på første render, men da vil vi ikke ha en onChange uansett\n if (\n typeof previousSelectedValue === \"undefined\" ||\n previousSelectedValue === selectedValue ||\n selectedValue === value\n ) {\n return;\n }\n if (onChange) {\n onChange({\n type: \"change\",\n target: { name, value: selectedValue },\n });\n }\n if (selectRef.current) {\n selectRef.current.dispatchEvent(\n new Event(\"change\", { bubbles: true }),\n );\n }\n }, [onChange, name, value, selectedValue, previousSelectedValue]);\n\n /// Fokushåndtering\n\n const componentRootElementRef = useRef<HTMLDivElement>(null);\n const focusInsideRef = useRef(false);\n const searchFieldRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n const handleFocusPlacement = useCallback(\n (isOpen: boolean, ref: RefObject<HTMLElement | null>) => {\n if (isOpen && !isSearchable) {\n const listElement = ref.current;\n if (listElement) {\n focusSelected(listElement, selectedValue);\n }\n } else if (isOpen) {\n if (searchFieldRef.current) {\n searchFieldRef.current.focus();\n }\n } else {\n if (focusInsideRef.current && buttonRef.current) {\n buttonRef.current.focus();\n }\n }\n },\n [isSearchable, selectedValue],\n );\n\n const [dropdownRef] = useAnimatedHeight<HTMLDivElement>(\n dropdownIsShown,\n {\n onFirstVisible: handleFocusPlacement,\n onTransitionEnd: handleFocusPlacement,\n },\n );\n\n useListNavigation({ ref: dropdownRef });\n\n const close = useCallback(() => {\n if (isSearchable) {\n setSearchValue(\"\");\n }\n if (onBlur) {\n onBlur({\n type: \"blur\",\n target: { name, value: selectedValue },\n });\n selectRef.current?.dispatchEvent(\n new Event(\"focusout\", { bubbles: true }),\n );\n }\n focusInsideRef.current = false;\n setShown(false);\n }, [onBlur, isSearchable, name, selectedValue]);\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLButtonElement | HTMLInputElement>) => {\n const componentRootElement = componentRootElementRef.current;\n // There are known issues in Firefox when using \"relatedTarget\" in onBlur events:\n // https://github.com/facebook/react/issues/2011\n // This might be fixed in react 17. Se issue above.\n const nextFocusIsInsideComponent =\n componentRootElement?.contains(e.relatedTarget as Node);\n if (!nextFocusIsInsideComponent) {\n close();\n }\n },\n [close],\n );\n\n const handleFocus = useCallback(() => {\n if (!focusInsideRef.current) {\n if (onFocus) {\n onFocus({\n type: \"change\",\n target: { name, value: selectedValue },\n });\n }\n focusInsideRef.current = true;\n }\n }, [onFocus, selectedValue, name]);\n\n const handleMouseOver = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n // Ved mouseOver på options flytter vi fokus til dem for å unngå \"dobbel fokus\"\n // der det ser ut som to forskjellige elementer er fokusert/hovered samtidig\n (e.target as HTMLButtonElement).focus({ preventScroll: true });\n },\n [],\n );\n\n // Handle focus and blur of hidden select element\n useEffect(() => {\n const select = selectRef.current;\n const searchField = searchFieldRef.current;\n const button = buttonRef.current;\n const componentRootElement = componentRootElementRef.current;\n\n select?.addEventListener(\"focus\", () => {\n showSearchInputField ? searchField?.focus() : button?.focus();\n });\n select?.addEventListener(\"blur\", function (this, ev) {\n componentRootElement?.contains(ev.relatedTarget as Node) &&\n ev.preventDefault();\n });\n\n return () => {\n select?.removeEventListener(\"focus\", () => {\n showSearchInputField\n ? searchField?.focus()\n : button?.focus();\n });\n select?.removeEventListener(\"blur\", function (this, ev) {\n componentRootElement?.contains(ev.relatedTarget as Node) &&\n ev.preventDefault();\n });\n };\n }, [showSearchInputField]);\n\n /// Tastaturnavigasjon\n\n // Add support for opening dropdown with arrowkey down as expected from native select\n // onKeyDown to stop ArrowDown from scrolling the page\n const handleOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (\n (e.key === \"ArrowDown\" || e.key === \" \") &&\n !dropdownIsShown\n ) {\n e.preventDefault();\n e.stopPropagation();\n setShown(true);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n setShown(false);\n }\n },\n [dropdownIsShown],\n );\n\n // onKeyDown to stop ArrowDown from scrolling the page\n const handleSearchOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n e.stopPropagation();\n\n const listElement = dropdownRef.current;\n if (listElement) {\n if (isSearchable) {\n // Flytt fokus til det første elementet i listen, ikke det forrige valgte.\n // Ved endring i filter er det ikke gitt at vi ønsker å ta utgangspunkt i\n // den valgte verdien.\n focusSelected(listElement, undefined);\n } else {\n focusSelected(listElement, selectedValue);\n }\n }\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n setShown(false);\n } else if (e.key === \"Tab\" && !e.shiftKey) {\n const listElement = dropdownRef.current;\n if (listElement) {\n e.preventDefault();\n e.stopPropagation();\n focusSelected(listElement, selectedValue);\n }\n } else if (e.key === \"Enter\" && dropdownIsShown) {\n // Should not propagate Enter keyevent because form might submit\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [dropdownRef, selectedValue, isSearchable, dropdownIsShown],\n );\n\n // onKeyDown so this Tab listener isn't triggered by tabbing from search field to option\n const handleOptionOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === \"Tab\") {\n e.preventDefault();\n e.stopPropagation();\n\n if (e.shiftKey && searchFieldRef.current) {\n searchFieldRef.current.focus();\n } else if (buttonRef.current) {\n // Mimic behaviour of Firefox and native select, where Tab selects the current item and closes the menu\n setSelectedValue(e.currentTarget.value);\n setShown(false);\n buttonRef.current.focus();\n }\n } else if (e.key === \"ArrowUp\") {\n if (dropdownRef.current && searchFieldRef.current) {\n // Can't be based on index since the first item might be filtered out\n const firstVisible = dropdownRef.current.querySelector(\n '[role=\"option\"]:not([hidden])',\n );\n if (\n e.currentTarget.id === firstVisible?.id &&\n searchFieldRef.current\n ) {\n searchFieldRef.current.focus();\n }\n }\n }\n },\n [dropdownRef],\n );\n\n // Add support for closing the dropdown with Escape like native select. Unfortunately, Escape does not trigger the button onKeyDown.\n useEffect(() => {\n const handleEscape = (e: globalThis.KeyboardEvent) => {\n if (e.key === \"Escape\" && dropdownIsShown) {\n setShown(false);\n }\n };\n if (typeof window !== \"undefined\" && dropdownIsShown) {\n window.addEventListener(\"keydown\", handleEscape);\n }\n return () => {\n if (typeof window !== \"undefined\") {\n window.removeEventListener(\"keydown\", handleEscape);\n }\n };\n }, [dropdownIsShown]);\n\n return (\n <>\n <select\n name={name}\n tabIndex={-1}\n data-testid=\"jkl-native-select\"\n className=\"jkl-sr-only\"\n aria-hidden\n ref={unifiedSelectRef}\n value={selectedValue}\n onChange={noop} // React complains unless we give an onChange handler. This is technically a read-only field, but readOnly isn't an option here.\n >\n <option value=\"\" />{\" \"}\n {/* Tom option må være et valg, ellers vil <select> alltid ha en value */}\n {visibleItems.map((item) => (\n <option\n key={`${listId}-opt-${item.value}`}\n hidden={!item.visible}\n value={item.value}\n >\n {item.label}\n </option>\n ))}\n </select>\n <InputGroup\n ref={componentRootElementRef}\n data-testid=\"jkl-select\"\n className={clsx(\"jkl-select\", className, {\n \"jkl-select--inline\": inline,\n \"jkl-select--open\":\n dropdownIsShown &&\n visibleItems.some((item) => item.visible),\n \"jkl-select--no-value\": !hasSelectedValue,\n \"jkl-select--invalid\": !!errorLabel || invalid,\n })}\n tooltip={\n tooltip && React.isValidElement<PopupTipProps>(tooltip)\n ? React.cloneElement(tooltip, {\n triggerProps: {\n ...tooltip.props.triggerProps,\n onFocus: (\n e: FocusEvent<HTMLButtonElement>,\n ) => {\n tooltip.props.triggerProps?.onFocus?.(\n e,\n );\n close();\n },\n },\n })\n : null\n }\n {...rest}\n id={isSearchable ? searchInputId : buttonId}\n style={\n {\n \"--jkl-select-max-shown-options\": maxShownOptions,\n ...style,\n } as CSSProperties\n }\n label={label}\n labelProps={{\n id: labelId,\n srOnly: inline,\n ...labelProps,\n htmlFor: isSearchable ? searchInputId : buttonId,\n }}\n helpLabel={helpLabel}\n errorLabel={errorLabel}\n render={({\n \"aria-invalid\": ariaInvalid,\n ...inputProps\n }) => (\n <div\n className=\"jkl-select__outer-wrapper\"\n style={{ width }}\n >\n {isSearchable && (\n <input\n {...inputProps}\n aria-invalid={ariaInvalid}\n id={searchInputId}\n hidden={!showSearchInputField}\n ref={searchFieldRef}\n placeholder=\"Søk\"\n value={searchValue}\n onChange={(e) =>\n setSearchValue(e.target.value)\n }\n data-testid=\"jkl-select__search-input\"\n className=\"jkl-select__search-input\"\n aria-autocomplete=\"list\"\n aria-activedescendant={\n hasSelectedValue\n ? `${listId}__${toLower(\n selectedValue,\n )}`\n : undefined\n }\n aria-controls={listId}\n aria-expanded={dropdownIsShown}\n role=\"combobox\"\n onKeyDown={handleSearchOnKeyDown}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onClick={(e) => {\n e.stopPropagation();\n }}\n />\n )}\n {/* eslint-disable-next-line jsx-a11y/role-supports-aria-props */}\n <button\n // Nei dette er ikke i henhold til speccen, men VoiceOver leser den likevel og det er oppførselen vi ønsker\n aria-invalid={ariaInvalid}\n {...inputProps}\n id={buttonId}\n ref={buttonRef}\n hidden={showSearchInputField}\n type=\"button\"\n name={`${name}-btn`}\n className={clsx(\"jkl-select__button\", {\n \"jkl-select__button--active-value\":\n !!selectedValue,\n })}\n data-testid=\"jkl-select__button\"\n aria-label={`${\n selectedValueLabel || \"Velg\"\n },${label}`}\n aria-expanded={dropdownIsShown}\n aria-controls={listId}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleOnKeyDown}\n onClick={toggleListVisibility}\n onMouseDown={(e) => {\n // Workaround for en Safari-bug hvor e.relatedTarget er null i onBlur\n // https://twitter.com/MilesSorce/status/1278762360669265925\n e.preventDefault();\n buttonRef.current?.focus();\n }}\n >\n {selectedValueLabel}\n </button>\n <div\n id={listId}\n ref={dropdownRef}\n // biome-ignore lint/a11y/useSemanticElements: Vi reimplementerer select\n role=\"listbox\"\n className=\"jkl-select__options-menu\"\n hidden={\n !dropdownIsShown ||\n visibleItems.every((item) => !item.visible)\n }\n aria-labelledby={labelId}\n tabIndex={-1}\n data-focus=\"controlled\" // lar oss styre markering av valg vha focus\n >\n {visibleItems.map((item, i) =>\n // Det er viktig at vi _fjerner_ elementer som ikke er synlige fra DOMen for at tastaturnavigasjon skal fungere.\n // For eksempel, hvis vi har elementene Apple, Samsung og LG i den rekkefølgen og søker etter \"l\"\n // vil Samsung ikke synes. Om vi bare setter hidden-attributtet på Samsung vil ArrowDown fra Apple ikke fungere.\n // Dette lar seg ikke gjenskape i en enhetstest med JSDOM + user-events, og Cypress lukker Select\n // ved første {downArrow} ¯\\_(ツ)_/¯. Så please test scenariet over manuelt om dette skaper trøbbel for deg.\n item.visible ? (\n <button\n key={`${listId}-${item.value}`}\n hidden={!item.visible}\n type=\"button\"\n id={`${listId}__${toLower(\n item.value,\n )}`}\n className=\"jkl-select__option\"\n data-testid=\"jkl-select__option\"\n aria-selected={\n item.value === selectedValue\n }\n // biome-ignore lint/a11y/useSemanticElements: Vi reimplementerer select\n role=\"option\"\n value={item.value}\n data-testautoid={`jkl-select__option-${i}`}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleOptionOnKeyDown}\n onClick={(e) => {\n e.preventDefault();\n selectOption(item);\n }}\n onMouseOver={handleMouseOver}\n >\n {item.label}\n {item.description ? (\n <span className=\"jkl-select__option-description\">\n {item.description}\n </span>\n ) : null}\n </button>\n ) : null,\n )}\n </div>\n <ArrowVerticalAnimated\n variant=\"medium\"\n pointingDown={!dropdownIsShown}\n className=\"jkl-select__arrow\"\n />\n </div>\n )}\n />\n </>\n );\n },\n);\n\nSelect.displayName = \"Select\";\n"],"names":["noop","Select","forwardRef","props","forwardedSelectRef","id","name","items","value","label","labelProps","onChange","onBlur","onFocus","className","helpLabel","errorLabel","invalid","searchable","inline","defaultPrompt","width","maxShownOptions","style","tooltip","rest","listId","useId","generateSuffix","labelId","buttonId","searchInputId","dropdownIsShown","setShown","useState","toggleListVisibility","useCallback","previousValue","isSearchable","showSearchInputField","searchValue","setSearchValue","searchFn","item","toLowerCase","includes","visibleItems","useMemo","map","getValuePair","visible","valueIsInItems","some","selectedValue","setSelectedValue","hasSelectedValue","selectedValueLabel","find","selectRef","useRef","unifiedSelectRef","instance","current","usePreviousValue","useEffect","selectOption","nextValue","buttonRef","focus","previousSelectedValue","type","target","dispatchEvent","Event","bubbles","componentRootElementRef","focusInsideRef","searchFieldRef","handleFocusPlacement","isOpen","ref","listElement","focusSelected","dropdownRef","useAnimatedHeight","onFirstVisible","onTransitionEnd","useListNavigation","close","handleBlur","e","contains","relatedTarget","handleFocus","handleMouseOver","preventScroll","select","searchField","button","componentRootElement","addEventListener","ev","preventDefault","removeEventListener","handleOnKeyDown","key","stopPropagation","handleSearchOnKeyDown","shiftKey","handleOptionOnKeyDown","currentTarget","firstVisible","querySelector","handleEscape","window","jsxs","Fragment","children","tabIndex","jsx","hidden","InputGroup","clsx","React","isValidElement","cloneElement","triggerProps","srOnly","htmlFor","render","ariaInvalid","inputProps","placeholder","toLower","role","onKeyDown","onClick","onMouseDown","every","i","onMouseOver","description","ArrowVerticalAnimated","variant","pointingDown","displayName"],"mappings":"6xBAyBA,MAAMA,EAAO,OAQAC,EAASC,EAClB,CAACC,EAAOC,KACJ,MACIC,GAAAA,EACAC,KAAAA,EACAC,MAAAA,EACAC,MAAAA,EACAC,MAAAA,EACAC,WAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,WAAAA,GAAa,EACbC,OAAAA,GAAS,EACTC,cAAAA,EAAgB,OAChBC,MAAAA,EACAC,gBAAAA,EAAkB,EAClBC,MAAAA,EACAC,QAAAA,KACGC,GACHtB,EAEEuB,EAASC,EAAMtB,GAAM,aAAc,CAAEuB,gBAAiBvB,IACtDwB,EAAU,GAAGH,UACbI,EAAW,GAAGJ,WACdK,EAAgB,GAAGL,kBAElBM,EAAiBC,GAAYC,GAAS,GACvCC,EAAuBC,EAAY,KACrCH,EAAUI,IAAmBA,IAC9B,IAIGC,IAAuBpB,EACvBqB,EAAuBD,GAAgBN,GACtCQ,EAAa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EvC,kBAAiBrB,EACjByF,UAAU,EACV,aAAW,aAEVD,SAAAvE,GAAaE,IAAI,CAACL,EAAMgG,IAMrBhG,EAAKO,QACDiE,EAAC,SAAA,CAEGK,QAAS7E,EAAKO,QACdoB,KAAK,SACLjE,GAAI,GAAGqB,MAAW2G,EACd1F,EAAKnC,SAETM,UAAU,qBACV,cAAY,qBACZ,gBACI6B,EAAKnC,QAAU6C,GAGnBiF,KAAK,SACL9H,MAAOmC,EAAKnC,MACZ,kBAAiB,sBAAsBmI,IACvC/H,OAAQ6E,GACR5E,QAASgF,GACT0C,UAAW1B,GACX2B,QAAU9C,IACNA,EAAEY,iBACFrC,GAAatB,IAEjBiG,YAAa9C,GAEZuB,SAAA,CAAA1E,EAAKlC,MACLkC,EAAKkG,YACFtB,EAAC,OAAA,CAAKzG,UAAU,iCACXuG,SAAA1E,EAAKkG,cAEV,OA7BC,GAAGnH,KAAUiB,EAAKnC,SA+B3B,QAGZ+G,EAACuB,EAAA,CACGC,QAAQ,SACRC,cAAehH,EACflB,UAAU,gCAU1Cb,EAAOgJ,YAAc"}
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../src/components/select/Select.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, {\n type CSSProperties,\n type FocusEvent,\n forwardRef,\n type KeyboardEvent,\n type MouseEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useId } from \"../../hooks/useId/useId.js\";\nimport { useListNavigation } from \"../../hooks/useListNavigation/useListNavigation.js\";\nimport { usePreviousValue } from \"../../hooks/usePreviousValue/usePreviousValue.js\";\nimport { type ValuePair, getValuePair } from \"../../utilities/valuePair.js\";\nimport { ArrowVerticalAnimated } from \"../icon/icons/animated/ArrowVerticalAnimated.js\";\nimport { InputGroup } from \"../input-group/InputGroup.js\";\nimport Popover from \"../popover/Popover.js\";\nimport type { PopupTipProps } from \"../tooltip/types.js\";\nimport { focusSelected, toLower } from \"./select-utils.js\";\nimport type { SelectProps } from \"./types.js\";\n\nconst noop = () => {\n return;\n};\n\ninterface Option extends ValuePair {\n visible: boolean;\n}\n\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(\n (props, forwardedSelectRef) => {\n const {\n id,\n name,\n items,\n value,\n label,\n labelProps,\n onChange,\n onBlur,\n onFocus,\n className,\n helpLabel,\n errorLabel,\n invalid,\n searchable = false,\n inline = false,\n defaultPrompt = \"Velg\",\n width,\n maxShownOptions = 5,\n style,\n tooltip,\n ...rest\n } = props;\n\n const listId = useId(id || \"jkl-select\", { generateSuffix: !id });\n const labelId = `${listId}_label`;\n const buttonId = `${listId}_button`;\n const searchInputId = `${listId}_search-input`;\n // Unik anchor-name som CSS anchor positioning bruker for å la\n // dropdown-listen matche bredden til triggeren.\n const anchorName = `--${listId.replace(/[^a-zA-Z0-9-]/g, \"-\")}-anchor`;\n\n const [dropdownIsShown, setShown] = useState(false);\n const toggleListVisibility = useCallback(() => {\n setShown((previousValue) => !previousValue);\n }, []);\n\n // Lagrer faktisk placement etter at floating-ui har kjørt `flip`,\n // slik at vi kan bytte hvilken side av lista og knappen som er\n // flat når lista snus over triggeren.\n const [popoverPlacement, setPopoverPlacement] = useState<\n \"top\" | \"bottom\"\n >(\"bottom\");\n const handlePlacementChange = useCallback((p: string) => {\n setPopoverPlacement(p.startsWith(\"top\") ? \"top\" : \"bottom\");\n }, []);\n\n /// Søk\n\n const isSearchable = Boolean(searchable);\n const showSearchInputField = isSearchable && dropdownIsShown;\n const [searchValue, setSearchValue] = useState(\"\");\n const searchFn = useCallback(\n (item: ValuePair) => {\n if (\n item.label.toLowerCase().includes(searchValue.toLowerCase())\n ) {\n return true;\n }\n\n if (typeof searchable === \"function\") {\n return searchable(searchValue, item);\n }\n\n return false;\n },\n [searchable, searchValue],\n );\n const visibleItems: Option[] = useMemo(\n () =>\n items.map(getValuePair).map((item) => {\n const visible =\n !isSearchable || searchValue === \"\" || searchFn(item);\n return { ...item, visible };\n }),\n [items, isSearchable, searchValue, searchFn],\n );\n const valueIsInItems: boolean = useMemo(() => {\n if (typeof value === \"undefined\") {\n return false;\n }\n return items.some((item) =>\n typeof item === \"string\"\n ? item === value\n : item.value === value,\n );\n }, [value, items]);\n\n /// Valg av <option>\n\n const [selectedValue, setSelectedValue] = useState<string>(\n valueIsInItems && value !== undefined ? value : \"\",\n );\n const hasSelectedValue = selectedValue !== \"\";\n const selectedValueLabel = useMemo(\n () =>\n visibleItems.find((item) => item.value === selectedValue)\n ?.label || defaultPrompt,\n [visibleItems, selectedValue, defaultPrompt],\n );\n\n const selectRef = useRef<HTMLSelectElement | null>(null);\n // Hjelpefunksjon som gjør det enklere å forwarde refen og å bruke den selv internt\n const unifiedSelectRef = useCallback(\n (instance: HTMLSelectElement | null) => {\n selectRef.current = instance;\n if (forwardedSelectRef) {\n if (typeof forwardedSelectRef === \"function\") {\n forwardedSelectRef(instance);\n } else {\n forwardedSelectRef.current = instance;\n }\n }\n if (instance) {\n setSelectedValue(instance.value);\n }\n },\n [forwardedSelectRef],\n );\n\n const previousValue = usePreviousValue(value);\n useEffect(() => {\n if (value === previousValue) {\n return;\n }\n if (typeof value === \"undefined\" || !valueIsInItems) {\n setSelectedValue(\"\");\n } else {\n setSelectedValue(value);\n }\n }, [value, previousValue, valueIsInItems]);\n\n const selectOption = useCallback(\n (item: Option) => {\n const nextValue = item.value;\n setSearchValue(\"\");\n setSelectedValue(nextValue);\n toggleListVisibility();\n buttonRef.current?.focus();\n },\n [toggleListVisibility],\n );\n\n // La komponenten rendre <select> med den valgte verdien før onChange trigges, slik at\n // react-hook-form@>7.41.1 behandler feltet som at det har en verdi.\n const previousSelectedValue = usePreviousValue(selectedValue);\n useEffect(() => {\n // previousSelectedValue er undefined på første render, men da vil vi ikke ha en onChange uansett\n if (\n typeof previousSelectedValue === \"undefined\" ||\n previousSelectedValue === selectedValue ||\n selectedValue === value\n ) {\n return;\n }\n if (onChange) {\n onChange({\n type: \"change\",\n target: { name, value: selectedValue },\n });\n }\n if (selectRef.current) {\n selectRef.current.dispatchEvent(\n new Event(\"change\", { bubbles: true }),\n );\n }\n }, [onChange, name, value, selectedValue, previousSelectedValue]);\n\n /// Fokushåndtering\n\n const componentRootElementRef = useRef<HTMLDivElement>(null);\n const focusInsideRef = useRef(false);\n const searchFieldRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n // Lagrer listbox-elementet i state slik at downstream-hooks\n // (f.eks. `useListNavigation`) kan re-feste listeneren idet\n // `FloatingPortal` mounter listen.\n const [listboxEl, setListboxEl] = useState<HTMLDivElement | null>(null);\n\n // Listen rendres i en `FloatingPortal` som monteres via en\n // `useLayoutEffect` + `setState` i floating-ui. Refen er derfor\n // ikke tilgjengelig før i en senere render. Vi bruker en\n // callback-ref for å plassere fokus på valgt option idet listen\n // faktisk er i DOM-en. Refen holdes stabil (tom dependency-list)\n // slik at en endring i `selectedValue`/`isSearchable` ikke får\n // React til å avmontere/remontere refen og dermed flytte fokus\n // mens menyen er åpen — vi leser siste verdier via refs.\n const isSearchableRef = useRef(isSearchable);\n const selectedValueRef = useRef(selectedValue);\n useEffect(() => {\n isSearchableRef.current = isSearchable;\n selectedValueRef.current = selectedValue;\n });\n\n const setDropdownRef = useCallback((node: HTMLDivElement | null) => {\n dropdownRef.current = node;\n setListboxEl(node);\n if (node && !isSearchableRef.current) {\n // Popover skjules med `visibility: hidden` til\n // floating-ui har regnet ut første posisjon. Defer\n // fokus til etter neste paint, slik at vi ikke flytter\n // fokus til et usynlig element (kan gi manglende\n // fokusindikator i enkelte nettlesere).\n requestAnimationFrame(() => {\n if (dropdownRef.current === node) {\n focusSelected(node, selectedValueRef.current);\n }\n });\n }\n }, []);\n\n // Søkbart felt og knappen som får fokus ved lukking lever i hoved-\n // DOM-en, så for de tilfellene holder en useEffect.\n const wasShown = usePreviousValue(dropdownIsShown);\n useEffect(() => {\n if (dropdownIsShown === wasShown) return;\n if (dropdownIsShown && isSearchable) {\n searchFieldRef.current?.focus();\n } else if (\n !dropdownIsShown &&\n focusInsideRef.current &&\n buttonRef.current\n ) {\n buttonRef.current.focus();\n }\n }, [dropdownIsShown, wasShown, isSearchable]);\n\n useListNavigation({ element: listboxEl });\n\n const close = useCallback(() => {\n if (isSearchable) {\n setSearchValue(\"\");\n }\n if (onBlur) {\n onBlur({\n type: \"blur\",\n target: { name, value: selectedValue },\n });\n selectRef.current?.dispatchEvent(\n new Event(\"focusout\", { bubbles: true }),\n );\n }\n focusInsideRef.current = false;\n setShown(false);\n }, [onBlur, isSearchable, name, selectedValue]);\n\n const handleBlur = useCallback(\n (e: FocusEvent<HTMLButtonElement | HTMLInputElement>) => {\n const componentRootElement = componentRootElementRef.current;\n const dropdownElement = dropdownRef.current;\n // There are known issues in Firefox when using \"relatedTarget\" in onBlur events:\n // https://github.com/facebook/react/issues/2011\n // This might be fixed in react 17. Se issue above.\n // Dropdown rendres i en portal, så vi må sjekke begge trærne\n // for å avgjøre om fokus blir værende inne i komponenten.\n const nextFocusIsInsideComponent =\n componentRootElement?.contains(e.relatedTarget as Node) ||\n dropdownElement?.contains(e.relatedTarget as Node);\n if (!nextFocusIsInsideComponent) {\n close();\n }\n },\n [close],\n );\n\n const handleFocus = useCallback(() => {\n if (!focusInsideRef.current) {\n if (onFocus) {\n onFocus({\n type: \"change\",\n target: { name, value: selectedValue },\n });\n }\n focusInsideRef.current = true;\n }\n }, [onFocus, selectedValue, name]);\n\n const handleMouseOver = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n // Ved mouseOver på options flytter vi fokus til dem for å unngå \"dobbel fokus\"\n // der det ser ut som to forskjellige elementer er fokusert/hovered samtidig\n (e.target as HTMLButtonElement).focus({ preventScroll: true });\n },\n [],\n );\n\n // Handle focus and blur of hidden select element\n useEffect(() => {\n const select = selectRef.current;\n if (!select) return;\n\n const onSelectFocus = () => {\n if (showSearchInputField) {\n searchFieldRef.current?.focus();\n } else {\n buttonRef.current?.focus();\n }\n };\n const onSelectBlur = (ev: globalThis.FocusEvent) => {\n // Les refs ved hvert kall slik at vi alltid sjekker mot\n // siste listbox-element — den portalerte listen kan ha\n // mountet etter at denne effekten ble satt opp.\n const target = ev.relatedTarget as Node | null;\n const insideComponent =\n componentRootElementRef.current?.contains(target);\n const insideDropdown = dropdownRef.current?.contains(target);\n if (insideComponent || insideDropdown) {\n ev.preventDefault();\n }\n };\n\n select.addEventListener(\"focus\", onSelectFocus);\n select.addEventListener(\"blur\", onSelectBlur);\n return () => {\n select.removeEventListener(\"focus\", onSelectFocus);\n select.removeEventListener(\"blur\", onSelectBlur);\n };\n }, [showSearchInputField]);\n\n /// Tastaturnavigasjon\n\n // Add support for opening dropdown with arrowkey down as expected from native select\n // onKeyDown to stop ArrowDown from scrolling the page\n const handleOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (\n (e.key === \"ArrowDown\" || e.key === \" \") &&\n !dropdownIsShown\n ) {\n e.preventDefault();\n e.stopPropagation();\n setShown(true);\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n setShown(false);\n }\n },\n [dropdownIsShown],\n );\n\n // onKeyDown to stop ArrowDown from scrolling the page\n const handleSearchOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n e.stopPropagation();\n\n const listElement = dropdownRef.current;\n if (listElement) {\n if (isSearchable) {\n // Flytt fokus til det første elementet i listen, ikke det forrige valgte.\n // Ved endring i filter er det ikke gitt at vi ønsker å ta utgangspunkt i\n // den valgte verdien.\n focusSelected(listElement, undefined);\n } else {\n focusSelected(listElement, selectedValue);\n }\n }\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n setShown(false);\n } else if (e.key === \"Tab\" && !e.shiftKey) {\n const listElement = dropdownRef.current;\n if (listElement) {\n e.preventDefault();\n e.stopPropagation();\n focusSelected(listElement, selectedValue);\n }\n } else if (e.key === \"Enter\" && dropdownIsShown) {\n // Should not propagate Enter keyevent because form might submit\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [selectedValue, isSearchable, dropdownIsShown],\n );\n\n // onKeyDown so this Tab listener isn't triggered by tabbing from search field to option\n const handleOptionOnKeyDown = useCallback(\n (e: KeyboardEvent<HTMLButtonElement>) => {\n if (e.key === \"Tab\") {\n e.preventDefault();\n e.stopPropagation();\n\n if (e.shiftKey && searchFieldRef.current) {\n searchFieldRef.current.focus();\n } else if (buttonRef.current) {\n // Mimic behaviour of Firefox and native select, where Tab selects the current item and closes the menu\n setSelectedValue(e.currentTarget.value);\n setShown(false);\n buttonRef.current.focus();\n }\n } else if (e.key === \"ArrowUp\") {\n if (dropdownRef.current && searchFieldRef.current) {\n // Can't be based on index since the first item might be filtered out\n const firstVisible = dropdownRef.current.querySelector(\n '[role=\"option\"]:not([hidden])',\n );\n if (\n e.currentTarget.id === firstVisible?.id &&\n searchFieldRef.current\n ) {\n searchFieldRef.current.focus();\n }\n }\n }\n },\n [],\n );\n\n // Add support for closing the dropdown with Escape like native select. Unfortunately, Escape does not trigger the button onKeyDown.\n useEffect(() => {\n const handleEscape = (e: globalThis.KeyboardEvent) => {\n if (e.key === \"Escape\" && dropdownIsShown) {\n setShown(false);\n }\n };\n if (typeof window !== \"undefined\" && dropdownIsShown) {\n window.addEventListener(\"keydown\", handleEscape);\n }\n return () => {\n if (typeof window !== \"undefined\") {\n window.removeEventListener(\"keydown\", handleEscape);\n }\n };\n }, [dropdownIsShown]);\n\n return (\n <>\n <select\n name={name}\n tabIndex={-1}\n data-testid=\"jkl-native-select\"\n className=\"jkl-sr-only\"\n aria-hidden\n ref={unifiedSelectRef}\n value={selectedValue}\n onChange={noop} // React complains unless we give an onChange handler. This is technically a read-only field, but readOnly isn't an option here.\n >\n <option value=\"\" />{\" \"}\n {/* Tom option må være et valg, ellers vil <select> alltid ha en value */}\n {visibleItems.map((item) => (\n <option\n key={`${listId}-opt-${item.value}`}\n hidden={!item.visible}\n value={item.value}\n >\n {item.label}\n </option>\n ))}\n </select>\n <InputGroup\n ref={componentRootElementRef}\n data-testid=\"jkl-select\"\n className={clsx(\"jkl-select\", className, {\n \"jkl-select--inline\": inline,\n \"jkl-select--open\":\n dropdownIsShown &&\n visibleItems.some((item) => item.visible),\n \"jkl-select--no-value\": !hasSelectedValue,\n \"jkl-select--invalid\": !!errorLabel || invalid,\n })}\n tooltip={\n tooltip && React.isValidElement<PopupTipProps>(tooltip)\n ? React.cloneElement(tooltip, {\n triggerProps: {\n ...tooltip.props.triggerProps,\n onFocus: (\n e: FocusEvent<HTMLButtonElement>,\n ) => {\n tooltip.props.triggerProps?.onFocus?.(\n e,\n );\n close();\n },\n },\n })\n : null\n }\n {...rest}\n id={isSearchable ? searchInputId : buttonId}\n style={style}\n label={label}\n labelProps={{\n id: labelId,\n srOnly: inline,\n ...labelProps,\n htmlFor: isSearchable ? searchInputId : buttonId,\n }}\n helpLabel={helpLabel}\n errorLabel={errorLabel}\n render={({\n \"aria-invalid\": ariaInvalid,\n ...inputProps\n }) => {\n // Lista vises kun når dropdown er åpnet *og* det\n // finnes minst ett synlig valg. `aria-expanded` på\n // trigger og combobox må følge samme boolean for\n // ikke å lyve om popoverens tilstand.\n const isPopoverOpen =\n dropdownIsShown &&\n visibleItems.some((item) => item.visible);\n return (\n <Popover\n open={isPopoverOpen}\n placement=\"bottom-start\"\n offset={0}\n modal={false}\n onPlacementChange={handlePlacementChange}\n clickOptions={{ enabled: false }}\n dismissOptions={{ enabled: false }}\n roleOptions={{ enabled: false }}\n >\n <Popover.Trigger asChild>\n <div\n className=\"jkl-select__outer-wrapper\"\n data-popover-placement={\n popoverPlacement\n }\n style={\n {\n width,\n anchorName,\n } as CSSProperties\n }\n >\n {isSearchable && (\n <input\n {...inputProps}\n aria-invalid={ariaInvalid}\n id={searchInputId}\n hidden={!showSearchInputField}\n ref={searchFieldRef}\n placeholder=\"Søk\"\n value={searchValue}\n onChange={(e) =>\n setSearchValue(\n e.target.value,\n )\n }\n data-testid=\"jkl-select__search-input\"\n className=\"jkl-select__search-input\"\n aria-autocomplete=\"list\"\n aria-activedescendant={\n isPopoverOpen &&\n hasSelectedValue\n ? `${listId}__${toLower(\n selectedValue,\n )}`\n : undefined\n }\n aria-controls={\n isPopoverOpen\n ? listId\n : undefined\n }\n aria-expanded={isPopoverOpen}\n role=\"combobox\"\n onKeyDown={\n handleSearchOnKeyDown\n }\n onBlur={handleBlur}\n onFocus={handleFocus}\n onClick={(e) => {\n e.stopPropagation();\n }}\n />\n )}\n {/* eslint-disable-next-line jsx-a11y/role-supports-aria-props */}\n <button\n // Nei dette er ikke i henhold til speccen, men VoiceOver leser den likevel og det er oppførselen vi ønsker\n aria-invalid={ariaInvalid}\n {...inputProps}\n id={buttonId}\n ref={buttonRef}\n hidden={showSearchInputField}\n type=\"button\"\n name={`${name}-btn`}\n className={clsx(\n \"jkl-select__button\",\n {\n \"jkl-select__button--active-value\":\n !!selectedValue,\n },\n )}\n data-testid=\"jkl-select__button\"\n aria-label={`${\n selectedValueLabel || \"Velg\"\n },${label}`}\n aria-expanded={isPopoverOpen}\n aria-controls={\n isPopoverOpen\n ? listId\n : undefined\n }\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleOnKeyDown}\n onClick={toggleListVisibility}\n onMouseDown={(e) => {\n // Workaround for en Safari-bug hvor e.relatedTarget er null i onBlur\n // https://twitter.com/MilesSorce/status/1278762360669265925\n e.preventDefault();\n buttonRef.current?.focus();\n }}\n >\n {selectedValueLabel}\n </button>\n <ArrowVerticalAnimated\n variant=\"medium\"\n pointingDown={!isPopoverOpen}\n className=\"jkl-select__arrow\"\n />\n </div>\n </Popover.Trigger>\n <Popover.Content\n initialFocus={-1}\n returnFocus={false}\n className=\"jkl-select__popover\"\n style={{\n width: `anchor-size(${anchorName} width)`,\n }}\n >\n <div\n id={listId}\n ref={setDropdownRef}\n // biome-ignore lint/a11y/useSemanticElements: Vi reimplementerer select\n role=\"listbox\"\n className=\"jkl-select__options-menu\"\n data-popover-placement={\n popoverPlacement\n }\n aria-labelledby={labelId}\n tabIndex={-1}\n data-focus=\"controlled\" // lar oss styre markering av valg vha focus\n style={\n {\n \"--jkl-select-max-shown-options\":\n maxShownOptions,\n } as CSSProperties\n }\n >\n {visibleItems.map((item, i) =>\n // Det er viktig at vi _fjerner_ elementer som ikke er synlige fra DOMen for at tastaturnavigasjon skal fungere.\n // For eksempel, hvis vi har elementene Apple, Samsung og LG i den rekkefølgen og søker etter \"l\"\n // vil Samsung ikke synes. Om vi bare setter hidden-attributtet på Samsung vil ArrowDown fra Apple ikke fungere.\n // Dette lar seg ikke gjenskape i en enhetstest med JSDOM + user-events, og Cypress lukker Select\n // ved første {downArrow} ¯\\_(ツ)_/¯. Så please test scenariet over manuelt om dette skaper trøbbel for deg.\n item.visible ? (\n <button\n key={`${listId}-${item.value}`}\n hidden={!item.visible}\n type=\"button\"\n id={`${listId}__${toLower(\n item.value,\n )}`}\n className=\"jkl-select__option\"\n data-testid=\"jkl-select__option\"\n aria-selected={\n item.value ===\n selectedValue\n }\n // biome-ignore lint/a11y/useSemanticElements: Vi reimplementerer select\n role=\"option\"\n value={item.value}\n data-testautoid={`jkl-select__option-${i}`}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={\n handleOptionOnKeyDown\n }\n onClick={(e) => {\n e.preventDefault();\n selectOption(item);\n }}\n onMouseOver={\n handleMouseOver\n }\n >\n {item.label}\n {item.description ? (\n <span className=\"jkl-select__option-description\">\n {item.description}\n </span>\n ) : null}\n </button>\n ) : null,\n )}\n </div>\n </Popover.Content>\n </Popover>\n );\n }}\n />\n </>\n );\n },\n);\n\nSelect.displayName = \"Select\";\n"],"names":["noop","Select","forwardRef","props","forwardedSelectRef","id","name","items","value","label","labelProps","onChange","onBlur","onFocus","className","helpLabel","errorLabel","invalid","searchable","inline","defaultPrompt","width","maxShownOptions","style","tooltip","rest","listId","useId","generateSuffix","labelId","buttonId","searchInputId","anchorName","replace","dropdownIsShown","setShown","useState","toggleListVisibility","useCallback","previousValue","popoverPlacement","setPopoverPlacement","handlePlacementChange","p","startsWith","isSearchable","showSearchInputField","searchValue","setSearchValue","searchFn","item","toLowerCase","includes","visibleItems","useMemo","map","getValuePair","visible","valueIsInItems","some","selectedValue","setSelectedValue","hasSelectedValue","selectedValueLabel","find","selectRef","useRef","unifiedSelectRef","instance","current","usePreviousValue","useEffect","selectOption","nextValue","buttonRef","focus","previousSelectedValue","type","target","dispatchEvent","Event","bubbles","componentRootElementRef","focusInsideRef","searchFieldRef","dropdownRef","listboxEl","setListboxEl","isSearchableRef","selectedValueRef","setDropdownRef","node","requestAnimationFrame","focusSelected","wasShown","useListNavigation","element","close","handleBlur","e","componentRootElement","dropdownElement","contains","relatedTarget","handleFocus","handleMouseOver","preventScroll","select","onSelectFocus","onSelectBlur","ev","insideComponent","insideDropdown","preventDefault","addEventListener","removeEventListener","handleOnKeyDown","key","stopPropagation","handleSearchOnKeyDown","listElement","shiftKey","handleOptionOnKeyDown","currentTarget","firstVisible","querySelector","handleEscape","window","jsxs","Fragment","children","tabIndex","ref","jsx","hidden","InputGroup","clsx","React","isValidElement","cloneElement","triggerProps","srOnly","htmlFor","render","ariaInvalid","inputProps","isPopoverOpen","Popover","open","placement","offset","modal","onPlacementChange","clickOptions","enabled","dismissOptions","roleOptions","Trigger","asChild","placeholder","toLower","role","onKeyDown","onClick","onMouseDown","ArrowVerticalAnimated","variant","pointingDown","Content","initialFocus","returnFocus","i","onMouseOver","description","displayName"],"mappings":"svBAwBA,MAAMA,EAAO,OAQAC,EAASC,EAClB,CAACC,EAAOC,KACJ,MACIC,GAAAA,EACAC,KAAAA,EACAC,MAAAA,EACAC,MAAAA,EACAC,MAAAA,EACAC,WAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,QAAAA,EACAC,UAAAA,EACAC,UAAAA,EACAC,WAAAA,EACAC,QAAAA,EACAC,WAAAA,GAAa,EACbC,OAAAA,GAAS,EACTC,cAA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EACV,aAAW,aACX5G,MACI,CACI,iCACID,GAIX4G,SAAA7E,GAAaE,IAAI,CAACL,EAAMyH,IAMrBzH,EAAKO,QACDuE,EAAC,SAAA,CAEGM,QAASpF,EAAKO,QACdoB,KAAK,SACLxE,GAAI,GAAGqB,MAAWsI,EACd9G,EAAK1C,SAETM,UAAU,qBACV,cAAY,qBACZ,gBACIoC,EAAK1C,QACLoD,GAGJqG,KAAK,SACLzJ,MAAO0C,EAAK1C,MACZ,kBAAiB,sBAAsBmK,IACvC/J,OAAQsF,GACRrF,QAAS2F,GACT0D,UACIxC,GAEJyC,QAAUhE,IACNA,EAAEc,iBACFzC,GAAatB,IAEjB0H,YACInE,GAGHyB,SAAA,CAAAhF,EAAKzC,MACLyC,EAAK2H,YACFxC,EAAC,OAAA,CAAKvH,UAAU,iCACXoH,SAAAhF,EAAK2H,cAEV,OAlCC,GAAGnJ,KAAUwB,EAAK1C,SAoC3B,qBAahDP,EAAO6K,YAAc"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { AriaRole } from 'react';
|
|
1
2
|
import { WithChildren } from '../../core/types.js';
|
|
2
3
|
export interface SystemMessageProps extends WithChildren {
|
|
3
4
|
id?: string;
|
|
4
5
|
className?: string;
|
|
5
6
|
maxContentWidth?: string;
|
|
6
7
|
paddingLeft?: string;
|
|
7
|
-
/**
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Overstyr standardrollen til meldingen. Om du ønsker å "skru av" rollen kan du bruke verdien `none` eller `presentation`.
|
|
10
|
+
*
|
|
11
|
+
* @see https://www.w3.org/TR/wai-aria-1.2/#role_definitions
|
|
12
|
+
*/
|
|
13
|
+
role?: AriaRole | string;
|
|
9
14
|
dismissed?: boolean;
|
|
10
15
|
dismissAction?: {
|
|
11
16
|
handleDismiss: () => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{ToastQueue as o}from"@react-stately/toast";import{createContext as s,
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{ToastQueue as o}from"@react-stately/toast";import{createContext as s,useState as a,useContext as i}from"react";import{ToastRegion as r}from"./ToastRegion.js";const m=s({add:()=>"missing-provider",close:()=>{}}),n=()=>i(m),u=({children:s,maxVisibleToasts:i=5,placement:n="center"})=>{const[u]=a(new o({maxVisibleToasts:i,hasExitAnimation:!0}));return e(m.Provider,{value:{close:u.close.bind(u),add:(e,t)=>{let o=5e3;return"number"==typeof t?.timeout?o=t.timeout:(null===t?.timeout||"off"===t?.timeout)&&(o=void 0),u.add(e,{...t,timeout:o})}},children:[s,t(r,{queue:u,placement:n})]})};export{u as ToastProvider,n as useToast};
|
|
2
2
|
//# sourceMappingURL=toastContext.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useFloating as t,
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useFloating as t,autoUpdate as n,offset as o,flip as s,shift as r,arrow as a,useRole as i,useDismiss as l,useClick as u,useHover as p,useFocus as c,useInteractions as d}from"@floating-ui/react";import{createContext as m,useContext as f,useState as x,useRef as g}from"react";const h=m(null),v=h.Provider,O=()=>{const e=f(h);if(null===e)throw new Error("Tooltip-komponentene kan kun brukes inne i <Tooltip />");return e},k=({children:m,...f})=>{const h=(({initialOpen:e=!1,placement:m="top",delay:f=250,triggerOn:h="hover",onOpenChange:v})=>{const[O,k]=x(e),w=g(null),C=g(null),T=t({open:O,onOpenChange:e=>{v?.(e),k(e)},placement:m,whileElementsMounted:n,middleware:[o(16),s(),r({padding:16}),a({element:w,padding:8})]}),b=i(T.context,{role:"tooltip"}),E=l(T.context),j=u(T.context,{enabled:"click"===h}),y=p(T.context,{enabled:"hover"===h,delay:O?0:f}),D=c(T.context,{enabled:"hover"===h}),F=d([E,D,b,j,y]);return{triggerOn:h,isOpen:O,setOpen:k,arrowElement:w,...T,refs:{...T.refs,description:C,setDescription:e=>{C.current=e}},...F}})(f);return e(v,{value:h,children:m})};export{k as Tooltip,v as TooltipProvider,O as useTooltipContext};
|
|
2
2
|
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import{c as t}from"../../../clsx-BeLtu-UY.js";import{forwardRef as r}from"react";const a=r(function({as:r,className:a,size:o="m",bold:e,short:m,srOnly:i,...l},c){return s(r||"p",{className:t("jkl-text",i&&"jkl-sr-only",a),"data-text-size":o,"data-bold":e||void 0,"data-short":m||void 0,ref:c,...l})});export{a as Text};
|
|
2
|
+
//# sourceMappingURL=Text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.js","sources":["../../../../src/components/typography/Text.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef } from \"react\";\nimport type { PolymorphicRef } from \"../../utilities/index.js\";\nimport type { TextElement, TextProps } from \"./types.js\";\n\ntype TextComponent = <As extends TextElement = \"p\">(\n props: TextProps<As>,\n) => React.ReactElement | null;\n\nexport const Text: TextComponent = forwardRef(function Text<\n As extends TextElement = \"p\",\n>(\n {\n as,\n className,\n size = \"m\",\n bold,\n short,\n srOnly,\n ...rest\n }: TextProps<As>,\n ref?: PolymorphicRef<As>,\n) {\n const Component = (as || \"p\") as React.ElementType;\n return (\n <Component\n className={clsx(\"jkl-text\", srOnly && \"jkl-sr-only\", className)}\n data-text-size={size}\n data-bold={bold || undefined}\n data-short={short || undefined}\n ref={ref}\n {...rest}\n />\n );\n}) as TextComponent;\n"],"names":["Text","forwardRef","as","className","size","bold","short","srOnly","rest","ref","jsx","clsx"],"mappings":"yHASO,MAAMA,EAAsBC,EAAW,UAItCC,GAAAA,EACAC,UAAAA,EACAC,KAAAA,EAAO,IACPC,KAAAA,EACAC,MAAAA,EACAC,OAAAA,KACGC,GAEPC,GAGA,OACIC,EAFeR,GAAM,IAEpB,CACGC,UAAWQ,EAAK,WAAYJ,GAAU,cAAeJ,GACrD,iBAAgBC,EAChB,YAAWC,QAAQ,EACnB,aAAYC,QAAS,EACrBG,IAAAA,KACID,GAGhB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as s}from"react/jsx-runtime";import{c as r}from"../../../clsx-BeLtu-UY.js";import{forwardRef as t}from"react";const a=t(function({className:t,size:a="l",as:e,srOnly:o,...l},i){return s(e||"h2",{className:r("jkl-title",o&&"jkl-sr-only",t),"data-text-size":a,ref:i,...l})});export{a as Title};
|
|
2
|
+
//# sourceMappingURL=Title.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Title.js","sources":["../../../../src/components/typography/Title.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport React, { forwardRef } from \"react\";\nimport type { PolymorphicRef } from \"../../utilities/index.js\";\nimport type { TitleElement, TitleProps } from \"./types.js\";\n\ntype TitleComponent = <As extends TitleElement = \"h2\">(\n props: TitleProps<As>,\n) => React.ReactElement | null;\n\nexport const Title: TitleComponent = forwardRef(function Title<\n As extends TitleElement = \"h2\",\n>(\n { className, size = \"l\", as, srOnly, ...rest }: TitleProps<As>,\n ref?: PolymorphicRef<As>,\n) {\n const Tag = (as || \"h2\") as React.ElementType;\n return (\n <Tag\n className={clsx(\"jkl-title\", srOnly && \"jkl-sr-only\", className)}\n data-text-size={size}\n ref={ref}\n {...rest}\n />\n );\n}) as TitleComponent;\n"],"names":["Title","forwardRef","className","size","as","srOnly","rest","ref","jsx","clsx"],"mappings":"yHASO,MAAMA,EAAwBC,EAAW,UAG1CC,UAAAA,EAAWC,KAAAA,EAAO,IAAKC,GAAAA,EAAIC,OAAAA,KAAWC,GACxCC,GAGA,OACIC,EAFSJ,GAAM,KAEd,CACGF,UAAWO,EAAK,YAAaJ,GAAU,cAAeH,GACtD,iBAAgBC,EAChBI,IAAAA,KACID,GAGhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { PolymorphicPropsWithRef } from '../../utilities/index.js';
|
|
2
|
+
export type TextElement = "p" | "span" | "label" | "legend" | "small" | "strong" | "em" | "code" | "kbd" | "samp" | "var";
|
|
3
|
+
export type TitleElement = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "label" | "legend";
|
|
4
|
+
export type TextSize = "xs" | "s" | "m" | "l";
|
|
5
|
+
export type TitleSize = "xs" | "s" | "m" | "l" | "xl";
|
|
6
|
+
type TextOwnProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Visuell størrelse på teksten. Tilsvarer font-size-tokens i Jøkul.
|
|
9
|
+
* @default "m"
|
|
10
|
+
*/
|
|
11
|
+
size?: TextSize;
|
|
12
|
+
/**
|
|
13
|
+
* Uthever teksten (font-weight: bold).
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
bold?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Setter mindre linjehøyde — bruk når teksten i all hovedsak går over
|
|
19
|
+
* én linje (f.eks. i tabellceller eller knapper).
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
short?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Skjuler elementet visuelt, men beholder det for skjermlesere.
|
|
25
|
+
* Bruk for å gi ekstra kontekst til assistive teknologier uten å
|
|
26
|
+
* påvirke det visuelle.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
srOnly?: boolean;
|
|
30
|
+
};
|
|
31
|
+
type TitleOwnProps = {
|
|
32
|
+
/**
|
|
33
|
+
* Visuell størrelse på tittelen. Frakoblet fra `as` — velg semantisk
|
|
34
|
+
* nivå via `as`, og visuell størrelse via `size`.
|
|
35
|
+
* @default "l"
|
|
36
|
+
*/
|
|
37
|
+
size?: TitleSize;
|
|
38
|
+
/**
|
|
39
|
+
* Skjuler elementet visuelt, men beholder det for skjermlesere.
|
|
40
|
+
* Bruk for å beholde riktig overskrifts-hierarki i skjermlesere
|
|
41
|
+
* uten å vise tittelen visuelt.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
srOnly?: boolean;
|
|
45
|
+
};
|
|
46
|
+
export type TextProps<As extends TextElement = "p"> = PolymorphicPropsWithRef<As, TextOwnProps>;
|
|
47
|
+
export type TitleProps<As extends TitleElement = "h2"> = PolymorphicPropsWithRef<As, TitleOwnProps>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,
|
|
1
|
+
import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import"react";const s=[e(t,{children:e("p",{className:"jkl-body",children:"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."})}),n(t,{children:[e("p",{className:"jkl-body",children:"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."}),e("p",{className:"jkl-body",children:"It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged."})]}),n(t,{children:[e("p",{className:"jkl-body",children:"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."}),e("p",{className:"jkl-body",children:"It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged."}),e("p",{className:"jkl-body",children:"It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."})]}),n(t,{children:[e("p",{className:"jkl-body",children:"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."}),e("p",{className:"jkl-body",children:"It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged."}),e("p",{className:"jkl-body",children:"It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."}),e("p",{className:"jkl-body",children:"Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old."})]})];function a(e){let t=s[Math.floor(Math.random()*s.length)];return t===e&&(t=a(e)),t}export{a as randomContentBlock};
|
|
2
2
|
//# sourceMappingURL=content.js.map
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Enten `ref` eller `element` må gis. `ref` brukes når listen alltid
|
|
4
|
+
* er i DOM-en; `element` foretrekkes når elementet mountes/unmountes
|
|
5
|
+
* dynamisk (f.eks. portalert via floating-ui), slik at listeneren
|
|
6
|
+
* re-festes når elementet faktisk er tilgjengelig.
|
|
7
|
+
*/
|
|
2
8
|
type UseListNavigationProps<T> = {
|
|
3
|
-
/** Ref til et element med rollen `listbox` */
|
|
4
9
|
ref: RefObject<T | null>;
|
|
10
|
+
element?: never;
|
|
11
|
+
} | {
|
|
12
|
+
ref?: never;
|
|
13
|
+
element: T | null;
|
|
5
14
|
};
|
|
6
|
-
export declare function useListNavigation<T extends HTMLElement>({ ref, }: UseListNavigationProps<T>): void;
|
|
15
|
+
export declare function useListNavigation<T extends HTMLElement>({ ref, element, }: UseListNavigationProps<T>): void;
|
|
7
16
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useLayoutEffect as e}from"react";function t({ref:t,element:n}){e(()=>{const e=n??t?.current??null;if(!e)return;const s={id:void 0},o={keys:""},c=t=>{!function({list:e,event:t,search:n,searchResetTimer:s}){const{key:o,target:c}=t,i={event:t,list:e,currentFocus:c};switch(o){case"ArrowUp":case"PageUp":r("prev",i);break;case"ArrowDown":case"PageDown":r("next",i);break;case"Home":r("first",i);break;case"End":r("last",i);break;case"Tab":t.preventDefault();break;case"Enter":case" ":break;default:if(void 0!==n){const t=function({list:e,key:t,search:r,searchResetTimer:n}){const s=e.querySelectorAll('[role="option"]');if(!s.length)return null;if(r){r.keys=r.keys.concat(t),function(e,t){void 0!==t.id&&(clearTimeout(t.id),t.id=void 0),t.id=window.setTimeout(()=>{e&&(e.keys=""),t.id=void 0},500)}(r,n);for(let e=0;e<s.length;e++){const t=s[e].innerText;if(t&&0===t.toLowerCase().indexOf(r.keys))return s[e]}}return null}({list:e,key:o,search:n,searchResetTimer:s});t&&t.focus()}}}({list:e,event:t,search:o,searchResetTimer:s})};return e.addEventListener("keydown",c),()=>{e.removeEventListener("keydown",c),void 0!==s.id&&clearTimeout(s.id)}},[n,t])}function r(e,{event:t,list:r,currentFocus:n}){t.preventDefault(),function(e,t,r){const n=r;switch(e){case"prev":{const e=n&&n.previousElementSibling;e&&e.focus();break}case"next":{const e=n&&n.nextElementSibling;e&&e.focus();break}case"first":{const e=t.querySelector('[role="option"]');e&&e.focus();break}case"last":{const e=t.querySelectorAll('[role="option"]');e.length&&e[e.length-1].focus();break}}}(e,r,n)}export{t as useListNavigation};
|
|
2
2
|
//# sourceMappingURL=useListNavigation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useListNavigation.js","sources":["../../../../src/hooks/useListNavigation/useListNavigation.ts"],"sourcesContent":["import { type RefObject,
|
|
1
|
+
{"version":3,"file":"useListNavigation.js","sources":["../../../../src/hooks/useListNavigation/useListNavigation.ts"],"sourcesContent":["import { type RefObject, useLayoutEffect } from \"react\";\n\ntype TimerHandle = { id: number | undefined };\ntype KeyBuffer = { keys: string } | undefined;\ntype Direction = \"prev\" | \"next\" | \"first\" | \"last\";\ninterface MoveDetails {\n event: KeyboardEvent;\n list: HTMLElement;\n currentFocus: HTMLButtonElement;\n}\ninterface ListDetails {\n list: HTMLElement;\n search: KeyBuffer;\n searchResetTimer: TimerHandle;\n}\ninterface SearchDetails extends ListDetails {\n key: string;\n}\ninterface EventDetails extends ListDetails {\n event: KeyboardEvent;\n}\n/**\n * Enten `ref` eller `element` må gis. `ref` brukes når listen alltid\n * er i DOM-en; `element` foretrekkes når elementet mountes/unmountes\n * dynamisk (f.eks. portalert via floating-ui), slik at listeneren\n * re-festes når elementet faktisk er tilgjengelig.\n */\ntype UseListNavigationProps<T> =\n | {\n ref: RefObject<T | null>;\n element?: never;\n }\n | {\n ref?: never;\n element: T | null;\n };\n\nexport function useListNavigation<T extends HTMLElement>({\n ref,\n element,\n}: UseListNavigationProps<T>): void {\n // Bruker `useLayoutEffect` slik at keydown-listeneren er på plass før\n // browseren maler neste frame. Det er viktig for konsumenter som\n // flytter fokus inn i lista i en `requestAnimationFrame`-callback\n // (som Select), ellers kan første tastetrykk gå tapt.\n useLayoutEffect(() => {\n // `ref?.current` leses inne i effekten — refen er fylt i commit-\n // fasen, og var `null` i render-tid for callere som passerer\n // `ref` (som Combobox).\n const list = element ?? ref?.current ?? null;\n if (!list) return;\n\n // `TimerHandle` er et muterbart objekt slik at `resetWhenIdle`\n // kan oppdatere `id` på samme referanse — `setTimeout`-handlen må\n // være delt på tvers av tastetrykk for at `clearTimeout` skal\n // kunne avbryte forrige timeout.\n const searchResetTimer: TimerHandle = { id: undefined };\n const search: KeyBuffer = { keys: \"\" }; // keypress buffer is an object to preserve state\n const handler = (event: KeyboardEvent) => {\n handleListKeyNav({ list, event, search, searchResetTimer });\n };\n\n list.addEventListener(\"keydown\", handler);\n return () => {\n list.removeEventListener(\"keydown\", handler);\n if (searchResetTimer.id !== undefined) {\n clearTimeout(searchResetTimer.id);\n }\n };\n }, [element, ref]);\n}\n\nfunction handleMoveTo(\n direction: Direction,\n { event, list, currentFocus }: MoveDetails,\n) {\n event.preventDefault();\n moveFocusTo(direction, list, currentFocus);\n}\n\nfunction handleListKeyNav({\n list,\n event,\n search,\n searchResetTimer,\n}: EventDetails) {\n const { key, target } = event;\n const currentFocus = target as HTMLButtonElement;\n\n const moveDetails = {\n event,\n list,\n currentFocus,\n };\n\n switch (key) {\n case \"ArrowUp\":\n case \"PageUp\":\n handleMoveTo(\"prev\", moveDetails);\n break;\n case \"ArrowDown\":\n case \"PageDown\":\n handleMoveTo(\"next\", moveDetails);\n break;\n case \"Home\":\n handleMoveTo(\"first\", moveDetails);\n break;\n case \"End\":\n handleMoveTo(\"last\", moveDetails);\n break;\n case \"Tab\":\n // in a standard select, tab does nothing in-menu\n event.preventDefault();\n break;\n case \"Enter\":\n case \" \":\n break;\n\n default:\n if (search !== undefined) {\n const searchResult = findItem({\n list,\n key,\n search,\n searchResetTimer,\n });\n if (searchResult) {\n searchResult.focus();\n }\n }\n break;\n }\n}\n\nfunction moveFocusTo(\n direction: Direction,\n list: HTMLElement,\n current: HTMLButtonElement,\n) {\n const thisOption = current;\n switch (direction) {\n case \"prev\": {\n const prevOption: HTMLButtonElement | null =\n thisOption &&\n (thisOption.previousElementSibling as HTMLButtonElement);\n if (prevOption) {\n prevOption.focus();\n }\n break;\n }\n case \"next\": {\n const nextOption: HTMLButtonElement | null =\n thisOption &&\n (thisOption.nextElementSibling as HTMLButtonElement);\n if (nextOption) {\n nextOption.focus();\n }\n break;\n }\n case \"first\": {\n const firstItem =\n list.querySelector<HTMLButtonElement>(`[role=\"option\"]`);\n if (firstItem) {\n firstItem.focus();\n }\n break;\n }\n case \"last\": {\n const listItems =\n list.querySelectorAll<HTMLButtonElement>(`[role=\"option\"]`);\n if (listItems.length) {\n listItems[listItems.length - 1].focus();\n }\n break;\n }\n }\n}\n\nfunction findItem({\n list,\n key,\n search,\n searchResetTimer,\n}: SearchDetails): HTMLButtonElement | null {\n const listItems = list.querySelectorAll(`[role=\"option\"]`);\n if (!listItems.length) return null;\n\n if (search) {\n search.keys = search.keys.concat(key);\n resetWhenIdle(search, searchResetTimer);\n\n for (let n = 0; n < listItems.length; n++) {\n const label = (listItems[n] as HTMLButtonElement).innerText;\n if (label && label.toLowerCase().indexOf(search.keys) === 0) {\n return listItems[n] as HTMLButtonElement;\n }\n }\n }\n\n return null;\n}\n\nfunction resetWhenIdle(search: KeyBuffer, timer: TimerHandle) {\n if (timer.id !== undefined) {\n clearTimeout(timer.id);\n timer.id = undefined;\n }\n timer.id = window.setTimeout(() => {\n if (search) {\n search.keys = \"\";\n }\n timer.id = undefined;\n }, 500);\n}\n"],"names":["useListNavigation","ref","element","useLayoutEffect","list","current","searchResetTimer","id","search","keys","handler","event","key","target","moveDetails","currentFocus","handleMoveTo","preventDefault","searchResult","listItems","querySelectorAll","length","concat","timer","clearTimeout","window","setTimeout","resetWhenIdle","n","label","innerText","toLowerCase","indexOf","findItem","focus","handleListKeyNav","addEventListener","removeEventListener","direction","thisOption","prevOption","previousElementSibling","nextOption","nextElementSibling","firstItem","querySelector","moveFocusTo"],"mappings":"wCAqCO,SAASA,GACZC,IAAAA,EACAC,QAAAA,IAMAC,EAAgB,KAIZ,MAAMC,EAAOF,GAAWD,GAAKI,SAAW,KACxC,IAAKD,EAAM,OAMX,MAAME,EAAgC,CAAEC,QAAI,GACtCC,EAAoB,CAAEC,KAAM,IAC5BC,EAAWC,KAsBzB,UACIP,KAAAA,EACAO,MAAAA,EACAH,OAAAA,EACAF,iBAAAA,IAEA,MAAQM,IAAAA,EAAKC,OAAAA,GAAWF,EAGlBG,EAAc,CAChBH,MAAAA,EACAP,KAAAA,EACAW,aALiBF,GAQrB,OAAQD,GACJ,IAAK,UACL,IAAK,SACDI,EAAa,OAAQF,GACrB,MACJ,IAAK,YACL,IAAK,WACDE,EAAa,OAAQF,GACrB,MACJ,IAAK,OACDE,EAAa,QAASF,GACtB,MACJ,IAAK,MACDE,EAAa,OAAQF,GACrB,MACJ,IAAK,MAEDH,EAAMM,iBACN,MACJ,IAAK,QACL,IAAK,IACD,MAEJ,QACI,QAAe,IAAXT,EAAsB,CACtB,MAAMU,EA0DtB,UACId,KAAA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,QAEf,KACJ,CACA,IAAK,QAAS,CACV,MAAMU,EACFxC,EAAKyC,cAAiC,mBACtCD,GACAA,EAAUV,QAEd,KACJ,CACA,IAAK,OAAQ,CACT,MAAMf,EACFf,EAAKgB,iBAAoC,mBACzCD,EAAUE,QACVF,EAAUA,EAAUE,OAAS,GAAGa,QAEpC,KACJ,EAER,CAnGIY,CAAYR,EAAWlC,EAAMW,EACjC"}
|
package/build/es/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{default as s}from"./core/tokens.js";import{useAnimatedDetails as e}from"./hooks/useAnimatedDetails/useAnimatedDetails.js";import{useAnimatedHeight as i}from"./hooks/useAnimatedHeight/useAnimatedHeight.js";import{useAnimatedHeightBetween as r}from"./hooks/useAnimatedHeight/useAnimatedHeightBetween.js";import{useAutoAnimatedHeight as t}from"./hooks/useAnimatedHeight/useAutoAnimateHeight.js";import{useBrowserPreferences as a}from"./hooks/useBrowserPreferences/useBrowserPreferences.js";import{useIntersectionObserver as o}from"./hooks/useIntersectionObserver/useIntersectionObserver.js";import{useLocalStorage as m}from"./hooks/useLocalStorage/useLocalStorage.js";import{useMutationObserver as u}from"./hooks/useMutationObserver/useMutationObserver.js";import{usePreviousValue as n}from"./hooks/usePreviousValue/usePreviousValue.js";import{useProgressiveImg as l}from"./hooks/useProgressiveImg/useProgressiveImg.js";import{useScreen as f}from"./hooks/useScreen/useScreen.js";import{useScrollIntoView as d}from"./hooks/useScrollIntoView/useScrollIntoView.js";import{useAriaLiveRegion as g}from"./hooks/useAriaLiveRegion/useAriaLiveRegion.js";import{useClickOutside as p}from"./hooks/useClickOutside/useClickOutside.js";import{useFocusOutside as h}from"./hooks/useFocusOutside/useFocusOutside.js";import{useElementDimensions as j}from"./hooks/useElementDimensions/useElementDimensions.js";import{useId as E}from"./hooks/useId/useId.js";import{useKeyListener as V}from"./hooks/useKeyListener/useKeyListener.js";import{useListNavigation as v}from"./hooks/useListNavigation/useListNavigation.js";import{useSwipeGesture as M}from"./hooks/useSwipeGesture/useSwipeGesture.js";import{u as k}from"../index-
|
|
1
|
+
import{default as s}from"./core/tokens.js";import{useAnimatedDetails as e}from"./hooks/useAnimatedDetails/useAnimatedDetails.js";import{useAnimatedHeight as i}from"./hooks/useAnimatedHeight/useAnimatedHeight.js";import{useAnimatedHeightBetween as r}from"./hooks/useAnimatedHeight/useAnimatedHeightBetween.js";import{useAutoAnimatedHeight as t}from"./hooks/useAnimatedHeight/useAutoAnimateHeight.js";import{useBrowserPreferences as a}from"./hooks/useBrowserPreferences/useBrowserPreferences.js";import{useIntersectionObserver as o}from"./hooks/useIntersectionObserver/useIntersectionObserver.js";import{useLocalStorage as m}from"./hooks/useLocalStorage/useLocalStorage.js";import{useMutationObserver as u}from"./hooks/useMutationObserver/useMutationObserver.js";import{usePreviousValue as n}from"./hooks/usePreviousValue/usePreviousValue.js";import{useProgressiveImg as l}from"./hooks/useProgressiveImg/useProgressiveImg.js";import{useScreen as f}from"./hooks/useScreen/useScreen.js";import{useScrollIntoView as d}from"./hooks/useScrollIntoView/useScrollIntoView.js";import{useAriaLiveRegion as g}from"./hooks/useAriaLiveRegion/useAriaLiveRegion.js";import{useClickOutside as p}from"./hooks/useClickOutside/useClickOutside.js";import{useFocusOutside as h}from"./hooks/useFocusOutside/useFocusOutside.js";import{useElementDimensions as j}from"./hooks/useElementDimensions/useElementDimensions.js";import{useId as E}from"./hooks/useId/useId.js";import{useKeyListener as V}from"./hooks/useKeyListener/useKeyListener.js";import{useListNavigation as v}from"./hooks/useListNavigation/useListNavigation.js";import{useSwipeGesture as M}from"./hooks/useSwipeGesture/useSwipeGesture.js";import{u as k}from"../index-C1iqmqvT.js";import{formatNumber as c}from"./utilities/formatters/util/formatNumber.js";import{parseNumber as O}from"./utilities/formatters/util/parseNumber.js";import{registerWithFodselsnummerMask as R,registerWithKontonummerMask as N,registerWithKortnummerMask as A,registerWithMasks as S,registerWithTelefonnummerMask as I}from"./utilities/formatters/util/registerWithMask.js";import{formatAvstand as L}from"./utilities/formatters/avstand/formatAvstand.js";import{formatBytes as T}from"./utilities/formatters/bytes/formatBytes.js";import{formatDate as b}from"./utilities/formatters/date/formatDate.js";import{FODSELSNUMMER_REGEX as K,formatFodselsnummer as P}from"./utilities/formatters/fodselsnummer/formatFodselsnummer.js";import{ORGANISASJONSNUMMER_REGEX as D,formatOrganisasjonsnummer as F}from"./utilities/formatters/organisasjonsnummer/formatOrganisasjonsnummer.js";import{KONTONUMMER_REGEX as G,formatKontonummer as w}from"./utilities/formatters/kontonummer/formatKontonummer.js";import{KORTNUMMER_REGEX as C,formatKortnummer as W}from"./utilities/formatters/kortnummer/formatKortnummer.js";import{TELEFONNUMMER_REGEX as H,formatTelefonnummer as y}from"./utilities/formatters/telefonnummer/formatTelefonnummer.js";import{formatValuta as B}from"./utilities/formatters/valuta/formatValuta.js";import{getThemeAndSize as U}from"./utilities/getThemeAndSize.js";import{mergeRefs as X,useMergeRefs as _}from"./utilities/mergeRefs.js";import{mergeProps as x}from"./utilities/polymorphism/mergeProps.js";import{SlotComponent as z}from"./utilities/polymorphism/SlotComponent.js";import{initTabListener as J}from"./utilities/tabListener.js";import{isValidEpost as q}from"./utilities/validators/isValidEpost/isValidEpost.js";import{isValidTelefonnummer as Q}from"./utilities/validators/isValidTelefonnummer/isValidTelefonnummer.js";import{isValidRegistreringsnummer as Y}from"./utilities/validators/isValidRegistreringsnummer/isValidRegistreringsnummer.js";import{isValidChassisnummer as Z}from"./utilities/validators/isValidChassisnummer/isValidChassisnummer.js";import{isValidDogId as $}from"./utilities/validators/isValidDogId/isValidDogId.js";import{isExactLength as ss}from"./utilities/validators/isExactLength/isExactLength.js";import{isInteger as es}from"./utilities/validators/isInteger/isInteger.js";import{isValidFodselsnummer as is}from"./utilities/validators/isValidFodselsnummer/isValidFodselsnummer.js";import{isValidOrganisasjonsnummer as rs}from"./utilities/validators/isValidOrganisasjonsnummer/isValidOrganisasjonsnummer.js";import{isValidName as ts}from"./utilities/validators/isValidName/isValidName.js";import{hasMinimumWords as as}from"./utilities/validators/hasMinimumWords/hasMinimumWords.js";import{hasNoIllegalCharacters as os}from"./utilities/validators/hasNoIllegalCharacters/hasNoIllegalCharacters.js";import{getValuePair as ms}from"./utilities/valuePair.js";export{K as FODSELSNUMMER_REGEX,G as KONTONUMMER_REGEX,C as KORTNUMMER_REGEX,D as ORGANISASJONSNUMMER_REGEX,z as SlotComponent,H as TELEFONNUMMER_REGEX,L as formatAvstand,T as formatBytes,b as formatDate,P as formatFodselsnummer,w as formatKontonummer,W as formatKortnummer,c as formatNumber,F as formatOrganisasjonsnummer,y as formatTelefonnummer,B as formatValuta,U as getThemeAndSize,ms as getValuePair,as as hasMinimumWords,os as hasNoIllegalCharacters,J as initTabListener,ss as isExactLength,es as isInteger,Z as isValidChassisnummer,$ as isValidDogId,q as isValidEpost,is as isValidFodselsnummer,ts as isValidName,rs as isValidOrganisasjonsnummer,Y as isValidRegistreringsnummer,Q as isValidTelefonnummer,x as mergeProps,X as mergeRefs,O as parseNumber,R as registerWithFodselsnummerMask,N as registerWithKontonummerMask,A as registerWithKortnummerMask,S as registerWithMasks,I as registerWithTelefonnummerMask,s as tokens,k as unicode,e as useAnimatedDetails,i as useAnimatedHeight,r as useAnimatedHeightBetween,g as useAriaLiveRegion,t as useAutoAnimatedHeight,a as useBrowserPreferences,p as useClickOutside,j as useElementDimensions,h as useFocusOutside,E as useId,o as useIntersectionObserver,V as useKeyListener,v as useListNavigation,m as useLocalStorage,_ as useMergeRefs,u as useMutationObserver,n as usePreviousValue,l as useProgressiveImg,f as useScreen,d as useScrollIntoView,M as useSwipeGesture};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as o}from"../../../index-
|
|
1
|
+
import{u as o}from"../../../index-C1iqmqvT.js";export{o as unicode};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as s,C as a,D as R,L as A,a as _,N as O,
|
|
1
|
+
import{B as s,C as a,D as R,L as A,a as _,N as O,b as N,R as W,S as E,U as S,Z as H,c as T,n as D,s as P}from"../../../index-C1iqmqvT.js";export{s as BULLET,a as COPYRIGHT,R as DOWNWARDS_ARROW,A as LEFTWARDS_ARROW,_ as NON_BREAKING_HYPHEN,O as NON_BREAKING_SPACE,N as NORTH_EAST_ARROW,W as RIGHTWARDS_ARROW,E as SOFT_HYPHEN,S as UPWARDS_ARROW,H as ZERO_WIDTH_SPACE,T as nbhy,D as nbsp,P as shy};
|
|
2
2
|
//# sourceMappingURL=unicode.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as m}from"../../../../index-
|
|
1
|
+
import{n as m}from"../../../../index-C1iqmqvT.js";import{formatNumber as r}from"../util/formatNumber.js";function t(t,i){return t>=1e5?`${r(Number(t/1e3/1e3),{maximumFractionDigits:1,...i})}${m}MB`:`${r(t/1e3,{maximumFractionDigits:2,...i})}${m}KB`}export{t as formatBytes};
|
|
2
2
|
//# sourceMappingURL=formatBytes.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{N as a}from"../../../../index-
|
|
1
|
+
import{N as a}from"../../../../index-C1iqmqvT.js";const l={full:/^(\d{6})(\d{5})$/,partial:/^(\d{6})(\d{1,5})?$/};function r(r,t){const o=r.replace(/\W/g,""),e=t?.partial?l.partial:l.full,i=o.match(e);return i?i.slice(1).filter(Boolean).join(a):r}export{l as FODSELSNUMMER_REGEX,r as formatFodselsnummer};
|
|
2
2
|
//# sourceMappingURL=formatFodselsnummer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{N as a}from"../../../../index-
|
|
1
|
+
import{N as a}from"../../../../index-C1iqmqvT.js";const r={full:/^(\d{4})(\d{2})(\d{5})$/,partial:/^(\d{4})(\d{1,2})?(\d{1,5})?$/};function t(t,o){const l=t.replace(/\W/g,""),e=o?.partial?r.partial:r.full,n=l.match(e);return n?n.slice(1).filter(Boolean).join(o?.separator||a):t}export{r as KONTONUMMER_REGEX,t as formatKontonummer};
|
|
2
2
|
//# sourceMappingURL=formatKontonummer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{N as a}from"../../../../index-
|
|
1
|
+
import{N as a}from"../../../../index-C1iqmqvT.js";const r={full:/^(\d{4})(\d{4})(\d{4})(\d{4})$/,partial:/^(\d{4})(\d{1,4})?(\d{1,4})?(\d{1,4})?$/};function t(t,l){const o=t.replace(/[\s-.]/g,""),d=l?.partial?r.partial:r.full,e=o.match(d);return e?e.slice(1).filter(Boolean).join(a):t}export{r as KORTNUMMER_REGEX,t as formatKortnummer};
|
|
2
2
|
//# sourceMappingURL=formatKortnummer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{N as a}from"../../../../index-
|
|
1
|
+
import{N as a}from"../../../../index-C1iqmqvT.js";const r={full:/^(\d{3})(\d{3})(\d{3})$/,partial:/^(\d{3})(\d{1,3})?(\d{1,5})?$/};function t(t,l){const n=t.replace(/[\s-.]/g,""),o=l?.partial?r.partial:r.full,s=n.match(o);return s?s.slice(1).filter(Boolean).join(a):t}export{r as ORGANISASJONSNUMMER_REGEX,t as formatOrganisasjonsnummer};
|
|
2
2
|
//# sourceMappingURL=formatOrganisasjonsnummer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{N as a}from"../../../../index-
|
|
1
|
+
import{N as a}from"../../../../index-C1iqmqvT.js";const t={mobil:/^([8]\d{2})(\d{2})(\d{3})$/,fast:/^([2-9]\d)(\d{2})(\d{2})(\d{2})$/,mobilPartial:/^([8]\d{2})(\d{1,2})?(\d{1,3})?$/,fastPartial:/^([2-9]\d)(\d{1,2})?(\d{1,2})?(\d{1,2})?$/};function o(o,d){const i=o.replace(/\W/g,""),r=d?.partial?t.mobilPartial:t.mobil,l=d?.partial?t.fastPartial:t.fast,e=i.match(r)||i.match(l);return e?[d?.countryCode?`+${d.countryCode}`:void 0,...e.slice(1)].filter(Boolean).join(a):o}export{t as TELEFONNUMMER_REGEX,o as formatTelefonnummer};
|
|
2
2
|
//# sourceMappingURL=formatTelefonnummer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as i}from"../../../../index-
|
|
1
|
+
import{n as i}from"../../../../index-C1iqmqvT.js";import{formatNumber as r}from"../util/formatNumber.js";import{parseNumber as t}from"../util/parseNumber.js";const m={locale:"no-NB",minimumFractionDigits:0,maximumFractionDigits:2,suffix:"kr"};function o(o,s){const n=t(o);if(Number.isNaN(n))return o.toString();const u=Number.isInteger(n)?{}:{minimumFractionDigits:2,maximumFractionDigits:2},a=void 0!==s?.suffix?s.suffix:m.suffix,{prefix:e,...f}={...m,...u,...s},c=e?.length?`${e}${i}`:"",x=a?.length?`${i}${a}`:"";return`${c}${r(n,f)}${x}`}export{o as formatValuta};
|
|
2
2
|
//# sourceMappingURL=formatValuta.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as s}from"../../index-
|
|
1
|
+
import{u as s}from"../../index-C1iqmqvT.js";import{formatNumber as a}from"./formatters/util/formatNumber.js";import{parseNumber as r}from"./formatters/util/parseNumber.js";import{registerWithFodselsnummerMask as m,registerWithKontonummerMask as e,registerWithKortnummerMask as o,registerWithMasks as t,registerWithTelefonnummerMask as i}from"./formatters/util/registerWithMask.js";import{formatAvstand as n}from"./formatters/avstand/formatAvstand.js";import{formatBytes as l}from"./formatters/bytes/formatBytes.js";import{formatDate as f}from"./formatters/date/formatDate.js";import{FODSELSNUMMER_REGEX as d,formatFodselsnummer as u}from"./formatters/fodselsnummer/formatFodselsnummer.js";import{ORGANISASJONSNUMMER_REGEX as g,formatOrganisasjonsnummer as p}from"./formatters/organisasjonsnummer/formatOrganisasjonsnummer.js";import{KONTONUMMER_REGEX as E,formatKontonummer as j}from"./formatters/kontonummer/formatKontonummer.js";import{KORTNUMMER_REGEX as M,formatKortnummer as V}from"./formatters/kortnummer/formatKortnummer.js";import{TELEFONNUMMER_REGEX as h,formatTelefonnummer as R}from"./formatters/telefonnummer/formatTelefonnummer.js";import{formatValuta as N}from"./formatters/valuta/formatValuta.js";import{getThemeAndSize as O}from"./getThemeAndSize.js";import{mergeRefs as T,useMergeRefs as v}from"./mergeRefs.js";import{mergeProps as S}from"./polymorphism/mergeProps.js";import{SlotComponent as W}from"./polymorphism/SlotComponent.js";import{initTabListener as I}from"./tabListener.js";import{isValidEpost as K}from"./validators/isValidEpost/isValidEpost.js";import{isValidTelefonnummer as k}from"./validators/isValidTelefonnummer/isValidTelefonnummer.js";import{isValidRegistreringsnummer as F}from"./validators/isValidRegistreringsnummer/isValidRegistreringsnummer.js";import{isValidChassisnummer as G}from"./validators/isValidChassisnummer/isValidChassisnummer.js";import{isValidDogId as C}from"./validators/isValidDogId/isValidDogId.js";import{isExactLength as L}from"./validators/isExactLength/isExactLength.js";import{isInteger as b}from"./validators/isInteger/isInteger.js";import{isValidFodselsnummer as A}from"./validators/isValidFodselsnummer/isValidFodselsnummer.js";import{isValidOrganisasjonsnummer as U}from"./validators/isValidOrganisasjonsnummer/isValidOrganisasjonsnummer.js";import{isValidName as X}from"./validators/isValidName/isValidName.js";import{hasMinimumWords as _}from"./validators/hasMinimumWords/hasMinimumWords.js";import{hasNoIllegalCharacters as c}from"./validators/hasNoIllegalCharacters/hasNoIllegalCharacters.js";import{getValuePair as D}from"./valuePair.js";export{d as FODSELSNUMMER_REGEX,E as KONTONUMMER_REGEX,M as KORTNUMMER_REGEX,g as ORGANISASJONSNUMMER_REGEX,W as SlotComponent,h as TELEFONNUMMER_REGEX,n as formatAvstand,l as formatBytes,f as formatDate,u as formatFodselsnummer,j as formatKontonummer,V as formatKortnummer,a as formatNumber,p as formatOrganisasjonsnummer,R as formatTelefonnummer,N as formatValuta,O as getThemeAndSize,D as getValuePair,_ as hasMinimumWords,c as hasNoIllegalCharacters,I as initTabListener,L as isExactLength,b as isInteger,G as isValidChassisnummer,C as isValidDogId,K as isValidEpost,A as isValidFodselsnummer,X as isValidName,U as isValidOrganisasjonsnummer,F as isValidRegistreringsnummer,k as isValidTelefonnummer,S as mergeProps,T as mergeRefs,r as parseNumber,m as registerWithFodselsnummerMask,e as registerWithKontonummerMask,o as registerWithKortnummerMask,t as registerWithMasks,i as registerWithTelefonnummerMask,s as unicode,v as useMergeRefs};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|