@purpur/library 9.7.5 → 9.8.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.json +27 -0
- package/CHANGELOG.md +13 -1
- package/dist/LICENSE.txt +7 -7
- package/dist/{ThemeProvider-DiDBfyFA.mjs → ThemeProvider-BJ25_asg.mjs} +13 -13
- package/dist/{ThemeProvider-DiDBfyFA.mjs.map → ThemeProvider-BJ25_asg.mjs.map} +1 -1
- package/dist/{ThemeProvider-D7oXcAde.js → ThemeProvider-BJGm3zai.js} +2 -2
- package/dist/{ThemeProvider-D7oXcAde.js.map → ThemeProvider-BJGm3zai.js.map} +1 -1
- package/dist/{autocomplete-BEGRn-Wh.mjs → autocomplete-A9-Ni60G.mjs} +2 -2
- package/dist/{autocomplete-BEGRn-Wh.mjs.map → autocomplete-A9-Ni60G.mjs.map} +1 -1
- package/dist/{autocomplete-3kV1btuI.js → autocomplete-Bbth0nDG.js} +2 -2
- package/dist/{autocomplete-3kV1btuI.js.map → autocomplete-Bbth0nDG.js.map} +1 -1
- package/dist/autocomplete.cjs.js +1 -1
- package/dist/autocomplete.es.js +1 -1
- package/dist/components/accordion/src/accordion.visual.fixtures.d.ts +13 -0
- package/dist/components/accordion/src/accordion.visual.fixtures.d.ts.map +1 -0
- package/dist/components/badge/src/badge.visual.fixtures.d.ts +13 -0
- package/dist/components/badge/src/badge.visual.fixtures.d.ts.map +1 -0
- package/dist/components/footer/src/telia-logo.d.ts.map +1 -1
- package/dist/components/hero-banner/src/hero-banner-types.d.ts +48 -0
- package/dist/components/hero-banner/src/hero-banner-types.d.ts.map +1 -0
- package/dist/components/hero-banner/src/hero-banner.d.ts +5 -48
- package/dist/components/hero-banner/src/hero-banner.d.ts.map +1 -1
- package/dist/components/hero-banner/src/hero-banner.visual.fixtures.d.ts +1 -1
- package/dist/components/hero-banner/src/hero-banner.visual.fixtures.d.ts.map +1 -1
- package/dist/components-metadata.js +2 -2
- package/dist/{date-field-BKKty89_.js → date-field-CKxEWHG3.js} +2 -2
- package/dist/{date-field-BKKty89_.js.map → date-field-CKxEWHG3.js.map} +1 -1
- package/dist/{date-field-Cv5CKR1y.mjs → date-field-HEFdHIxk.mjs} +2 -2
- package/dist/{date-field-Cv5CKR1y.mjs.map → date-field-HEFdHIxk.mjs.map} +1 -1
- package/dist/date-field.cjs.js +1 -1
- package/dist/date-field.es.js +1 -1
- package/dist/{date-picker-CIizn3Pv.js → date-picker-CDBwkAJI.js} +2 -2
- package/dist/{date-picker-CIizn3Pv.js.map → date-picker-CDBwkAJI.js.map} +1 -1
- package/dist/{date-picker-DixxW60s.mjs → date-picker-cQewKIMN.mjs} +6 -6
- package/dist/{date-picker-DixxW60s.mjs.map → date-picker-cQewKIMN.mjs.map} +1 -1
- package/dist/date-picker.cjs.js +1 -1
- package/dist/date-picker.es.js +1 -1
- package/dist/{date-range-field-D8vLeSwp.js → date-range-field-D7Hn9FGN.js} +2 -2
- package/dist/{date-range-field-D8vLeSwp.js.map → date-range-field-D7Hn9FGN.js.map} +1 -1
- package/dist/{date-range-field-CFcjprIl.mjs → date-range-field-_WctWD29.mjs} +2 -2
- package/dist/{date-range-field-CFcjprIl.mjs.map → date-range-field-_WctWD29.mjs.map} +1 -1
- package/dist/date-range-field.cjs.js +1 -1
- package/dist/date-range-field.es.js +1 -1
- package/dist/{drawer-DyhsP34o.js → drawer-DyLQfvEh.js} +2 -2
- package/dist/{drawer-DyhsP34o.js.map → drawer-DyLQfvEh.js.map} +1 -1
- package/dist/{drawer-BzkRd9F0.mjs → drawer-cIUx6WSZ.mjs} +3 -3
- package/dist/{drawer-BzkRd9F0.mjs.map → drawer-cIUx6WSZ.mjs.map} +1 -1
- package/dist/drawer.cjs.js +1 -1
- package/dist/drawer.es.js +1 -1
- package/dist/{footer-DenAcikt.mjs → footer-BMlXRro2.mjs} +86 -96
- package/dist/footer-BMlXRro2.mjs.map +1 -0
- package/dist/footer-cet787Iq.js +2 -0
- package/dist/footer-cet787Iq.js.map +1 -0
- package/dist/footer.cjs.js +1 -1
- package/dist/footer.es.js +1 -1
- package/dist/{hero-banner-B7xrDfzN.mjs → hero-banner-B08jC0Sf.mjs} +77 -77
- package/dist/hero-banner-B08jC0Sf.mjs.map +1 -0
- package/dist/hero-banner-D__doaU7.js +2 -0
- package/dist/hero-banner-D__doaU7.js.map +1 -0
- package/dist/hero-banner.cjs.js +1 -1
- package/dist/hero-banner.es.js +1 -1
- package/dist/library.cjs.js +1 -1
- package/dist/library.es.js +21 -21
- package/dist/{modal-DJn9idcw.js → modal-CmPPxJ7Y.js} +2 -2
- package/dist/{modal-DJn9idcw.js.map → modal-CmPPxJ7Y.js.map} +1 -1
- package/dist/{modal-EIP36327.mjs → modal-Evh8sCBO.mjs} +3 -3
- package/dist/{modal-EIP36327.mjs.map → modal-Evh8sCBO.mjs.map} +1 -1
- package/dist/modal.cjs.js +1 -1
- package/dist/modal.es.js +1 -1
- package/dist/{popover-DERrvReO.mjs → popover-BSUdf0Ae.mjs} +3 -3
- package/dist/{popover-DERrvReO.mjs.map → popover-BSUdf0Ae.mjs.map} +1 -1
- package/dist/{popover-DnGgzfQr.js → popover-XJqF5DHT.js} +2 -2
- package/dist/{popover-DnGgzfQr.js.map → popover-XJqF5DHT.js.map} +1 -1
- package/dist/popover.cjs.js +1 -1
- package/dist/popover.es.js +1 -1
- package/dist/{promotion-card-DKc2Cx1h.js → promotion-card-BnXD2mkp.js} +2 -2
- package/dist/{promotion-card-DKc2Cx1h.js.map → promotion-card-BnXD2mkp.js.map} +1 -1
- package/dist/{promotion-card-BnzIVNQ4.mjs → promotion-card-DOO0VCI8.mjs} +2 -2
- package/dist/{promotion-card-BnzIVNQ4.mjs.map → promotion-card-DOO0VCI8.mjs.map} +1 -1
- package/dist/promotion-card.cjs.js +1 -1
- package/dist/promotion-card.es.js +1 -1
- package/dist/purpur.css +1 -1
- package/dist/{quantity-selector-CvBvnMeB.mjs → quantity-selector-B4YnfmNb.mjs} +2 -2
- package/dist/{quantity-selector-CvBvnMeB.mjs.map → quantity-selector-B4YnfmNb.mjs.map} +1 -1
- package/dist/{quantity-selector-CDSfcTb1.js → quantity-selector-CTBoxiPO.js} +2 -2
- package/dist/{quantity-selector-CDSfcTb1.js.map → quantity-selector-CTBoxiPO.js.map} +1 -1
- package/dist/quantity-selector.cjs.js +1 -1
- package/dist/quantity-selector.es.js +1 -1
- package/dist/{search-field-DKyNh7pE.mjs → search-field-_h8xn-sj.mjs} +2 -2
- package/dist/{search-field-DKyNh7pE.mjs.map → search-field-_h8xn-sj.mjs.map} +1 -1
- package/dist/{search-field-2vdDbiT0.js → search-field-vh6uz5KV.js} +2 -2
- package/dist/{search-field-2vdDbiT0.js.map → search-field-vh6uz5KV.js.map} +1 -1
- package/dist/search-field.cjs.js +1 -1
- package/dist/search-field.es.js +1 -1
- package/dist/{stepper-e0qicwqd.mjs → stepper-B-nCLs2D.mjs} +2 -2
- package/dist/{stepper-e0qicwqd.mjs.map → stepper-B-nCLs2D.mjs.map} +1 -1
- package/dist/{stepper-5qMo_shq.js → stepper-CTKlnH0q.js} +2 -2
- package/dist/{stepper-5qMo_shq.js.map → stepper-CTKlnH0q.js.map} +1 -1
- package/dist/stepper.cjs.js +1 -1
- package/dist/stepper.es.js +1 -1
- package/dist/{table-i1Gs9e0e.mjs → table-DOPXfD-s.mjs} +6 -6
- package/dist/{table-i1Gs9e0e.mjs.map → table-DOPXfD-s.mjs.map} +1 -1
- package/dist/{table-BOCcBzSO.js → table-DTQe4nN8.js} +2 -2
- package/dist/{table-BOCcBzSO.js.map → table-DTQe4nN8.js.map} +1 -1
- package/dist/table.cjs.js +1 -1
- package/dist/table.es.js +1 -1
- package/dist/{text-area-D0truMT1.js → text-area-9RUldq6W.js} +2 -2
- package/dist/{text-area-D0truMT1.js.map → text-area-9RUldq6W.js.map} +1 -1
- package/dist/{text-area-IVH-k4MM.mjs → text-area-C58aZEPa.mjs} +3 -3
- package/dist/{text-area-IVH-k4MM.mjs.map → text-area-C58aZEPa.mjs.map} +1 -1
- package/dist/text-area.cjs.js +1 -1
- package/dist/text-area.es.js +1 -1
- package/dist/text-field-C2W13n15.js +2 -0
- package/dist/{text-field-CYJzQG3h.js.map → text-field-C2W13n15.js.map} +1 -1
- package/dist/{text-field-BQfxJobW.mjs → text-field-D8MMa6ij.mjs} +114 -114
- package/dist/{text-field-BQfxJobW.mjs.map → text-field-D8MMa6ij.mjs.map} +1 -1
- package/dist/text-field.cjs.js +1 -1
- package/dist/text-field.es.js +1 -1
- package/dist/theme.cjs.js +1 -1
- package/dist/theme.es.js +3 -3
- package/dist/tokens/color/variables.css +1 -1
- package/dist/tokens/color/variables.dark.css +1 -1
- package/dist/tokens/color/variables.dark.js +1 -1
- package/dist/tokens/color/variables.dark.json +1 -1
- package/dist/tokens/color/variables.dark.scss +1 -1
- package/dist/tokens/color/variables.js +1 -1
- package/dist/tokens/color/variables.json +1 -1
- package/dist/tokens/color/variables.scss +1 -1
- package/dist/tokens.cjs.js +1 -1
- package/dist/tokens.es.js +1 -1
- package/dist/{tooltip-CJGmJDFQ.js → tooltip-CDnJKoIA.js} +2 -2
- package/dist/{tooltip-CJGmJDFQ.js.map → tooltip-CDnJKoIA.js.map} +1 -1
- package/dist/{tooltip-RA-03bKs.mjs → tooltip-pwJMEBBP.mjs} +3 -3
- package/dist/{tooltip-RA-03bKs.mjs.map → tooltip-pwJMEBBP.mjs.map} +1 -1
- package/dist/tooltip.cjs.js +1 -1
- package/dist/tooltip.es.js +1 -1
- package/dist/{useColorScheme-B9DWd-LN.mjs → useColorScheme-B7lGBSe4.mjs} +2 -2
- package/dist/{useColorScheme-B9DWd-LN.mjs.map → useColorScheme-B7lGBSe4.mjs.map} +1 -1
- package/dist/useColorScheme-BHhPgv9q.js +2 -0
- package/dist/{useColorScheme-DbTQjxNB.js.map → useColorScheme-BHhPgv9q.js.map} +1 -1
- package/dist/useThemePortalContainer-CUcqV327.js +2 -0
- package/dist/{useThemePortalContainer-D9BYjEvT.js.map → useThemePortalContainer-CUcqV327.js.map} +1 -1
- package/dist/useThemePortalContainer-D13Xx24N.mjs +9 -0
- package/dist/{useThemePortalContainer-tFLTaYKN.mjs.map → useThemePortalContainer-D13Xx24N.mjs.map} +1 -1
- package/dist/{variables-B5hbV0Uy.mjs → variables-BrsAsWIF.mjs} +2 -2
- package/dist/{variables-B5hbV0Uy.mjs.map → variables-BrsAsWIF.mjs.map} +1 -1
- package/dist/{variables-DoI78zZc.js → variables-D1vNo1lO.js} +2 -2
- package/dist/{variables-DoI78zZc.js.map → variables-D1vNo1lO.js.map} +1 -1
- package/package.json +23 -23
- package/tokens/color/variables.css +1 -1
- package/tokens/color/variables.dark.css +1 -1
- package/tokens/color/variables.dark.js +1 -1
- package/tokens/color/variables.dark.json +1 -1
- package/tokens/color/variables.dark.scss +1 -1
- package/tokens/color/variables.js +1 -1
- package/tokens/color/variables.json +1 -1
- package/tokens/color/variables.scss +1 -1
- package/dist/footer-3Y-664-8.js +0 -2
- package/dist/footer-3Y-664-8.js.map +0 -1
- package/dist/footer-DenAcikt.mjs.map +0 -1
- package/dist/hero-banner-B7xrDfzN.mjs.map +0 -1
- package/dist/hero-banner-DthITuQ7.js +0 -2
- package/dist/hero-banner-DthITuQ7.js.map +0 -1
- package/dist/text-field-CYJzQG3h.js +0 -2
- package/dist/useColorScheme-DbTQjxNB.js +0 -2
- package/dist/useThemePortalContainer-D9BYjEvT.js +0 -2
- package/dist/useThemePortalContainer-tFLTaYKN.mjs +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-3kV1btuI.js","sources":["../../../components/autocomplete/src/utils.ts","../../../components/autocomplete/src/useAutocomplete.ts","../../../components/autocomplete/src/autocomplete.tsx"],"sourcesContent":["import { type RefObject, useCallback, useEffect, useRef } from \"react\";\n\n// Used to \"merge\" \"intersection types\". Used to get comments on the props to the docs.\nexport type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport const useRefObject = <T>(value: T): RefObject<T> => {\n return useRef<T>(value) as RefObject<T>;\n};\n\nexport const useOnClickOutside = (element: HTMLElement | null, callback: () => void) => {\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (element && !element.contains(event.target as Node)) {\n callback();\n }\n },\n [callback, element]\n );\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [handleClickOutside]);\n};\n","import type { CSSProperties, ReactNode } from \"react\";\nimport { useRef, useState } from \"react\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport type { ListboxItemProps, ListboxProps } from \"@purpur/listbox\";\n\nimport { useOnClickOutside, useRefObject } from \"./utils\";\n\nexport type AutocompleteOption = {\n label: string;\n id: string;\n value?: string;\n disabled?: boolean;\n};\n\nexport type InputProps = Omit<BaseProps<\"input\">, \"onFocus\" | \"onMouseDown\"> & {\n onFocus: (event: React.FocusEvent<HTMLInputElement> | undefined) => void;\n onMouseDown: (event: React.MouseEvent<HTMLInputElement> | undefined) => void;\n};\n\ntype ComboboxProps = {\n /*\n * Set to get combobox features. Use in combination with `noOptionsText`, `comboboxButtonAriaLabel` and Purpur TextField.\n */\n combobox: true;\n /**\n * An accessible label for the button that toggles the list of options for a combobox.\n * */\n comboboxButtonAriaLabel: string;\n /*\n * Shown when there are no options to show. Will be displayed inside a listbox item.\n */\n noOptionsText: ReactNode;\n};\n\ntype NoComboboxProps = {\n combobox?: never;\n comboboxButtonAriaLabel?: never;\n /*\n * Shown when there are no options to show. Will be displayed inside a listbox item.\n */\n noOptionsText?: ReactNode;\n};\n\nexport type UseAutocompleteResult<T extends AutocompleteOption> = {\n /*\n * Set to highlight the first option in the listbox when the input is focused.\n */\n highlightFirstOption?: boolean;\n /*\n * The default input value. Only to use when the input is uncontrolled.\n */\n defaultInputValue?: string;\n /*\n * The input value. Use this to control the input value.\n */\n inputValue?: string;\n /*\n * Invoked for each option. Use to control which options are shown.\n */\n filterOption?: (inputValue: string | undefined, option: T) => boolean;\n /*\n * Id will be used to prefix id:s of all elements.\n */\n id: string;\n /*\n * The label of the listbox (dropdown) displaying the options.\n */\n listboxLabel: string;\n /*\n * The height of the listbox. Number will be interpreted as px value. defaults to `calc(2 * var(--purpur-spacing-1200))`.\n */\n listboxMaxHeight?: string | number;\n /*\n * NOTE! Always use this instead of onBlur directly on the input element. Event handler invoked on input blur.\n */\n onInputBlur?: React.FocusEventHandler<HTMLInputElement>;\n /*\n * NOTE! Always use this instead of onChange directly on the input element. Event handler invoked when the input value changes.\n */\n onInputChange?: (value: string) => void;\n /*\n * NOTE! Always use this instead of onFocus directly on the input element. Event handler invoked on input focus.\n */\n onInputFocus?: (event: React.FocusEvent<HTMLInputElement> | undefined) => undefined;\n /*\n * NOTE! Always use this instead of onKeyDown directly on the input element. Event handler invoked on input key down.\n */\n onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /*\n * NOTE! Always use this instead of onMouseDown directly on the input element. Event handler invoked on input mouse down.\n */\n onInputMouseDown?: (event: React.MouseEvent<HTMLInputElement> | undefined) => undefined;\n /*\n * Set to open the listbox when input gets focus.\n */\n openOnFocus?: boolean;\n /*\n * Event handler invoked when an option is selected.\n */\n onSelect?: (option: T | undefined) => void;\n /*\n * The list of options. Could include custom props.\n */\n options: T[];\n /*\n * The selected option.\n */\n selectedOption?: T;\n [\"data-testid\"]?: string;\n} & (ComboboxProps | NoComboboxProps);\n\nexport const useAutocomplete = <T extends AutocompleteOption>({\n combobox,\n comboboxButtonAriaLabel,\n highlightFirstOption,\n defaultInputValue,\n inputValue,\n filterOption,\n id,\n listboxLabel,\n listboxMaxHeight,\n onInputBlur,\n onInputChange,\n onInputFocus,\n onInputKeyDown,\n onInputMouseDown,\n openOnFocus,\n noOptionsText,\n onSelect,\n options,\n selectedOption,\n [\"data-testid\"]: dataTestid,\n}: UseAutocompleteResult<T>) => {\n const [internalInputValue, setInternalInputValue] = useState(\n ((typeof inputValue === \"string\" ? inputValue : defaultInputValue) || selectedOption?.label) ??\n \"\"\n );\n const definiteInputValue = typeof inputValue === \"string\" ? inputValue : internalInputValue;\n const [highlightedOption, setHighlightedOption] = useState<\n (T & { isSetByClickEvent?: false }) | undefined\n >(highlightFirstOption ? options[0] : undefined);\n const inputRef = useRef<HTMLInputElement>(null);\n const internalRef = useRefObject<HTMLDivElement | null>(null);\n const listboxRef = useRef<HTMLUListElement>(null);\n const optionRefs = useRef<Record<string, HTMLLIElement>>({});\n const [listboxIsOpen, setListboxIsOpen] = useState(false);\n\n function getTestId(name: string) {\n return dataTestid ? `${dataTestid}-${name}` : undefined;\n }\n\n const closeListbox = () => {\n setListboxIsOpen(false);\n setHighlightedOption(undefined);\n };\n\n useOnClickOutside(internalRef.current, closeListbox);\n\n const openListbox = ({ eventType }: { eventType: \"CLICK\" | \"KEYBOARD\" }) => {\n setListboxIsOpen(true);\n if (selectedOption) {\n requestAnimationFrame(() => {\n const isSetByClickEvent = eventType === \"CLICK\";\n setHighlightedOption({ ...selectedOption, isSetByClickEvent });\n scrollOptionIntoView(optionRefs.current[selectedOption.id]);\n });\n }\n };\n\n const filterOptions = (searchTerm: string | undefined) => {\n if (filterOption) {\n return options.filter((option) => filterOption(searchTerm, option));\n }\n\n if (!searchTerm) {\n return options;\n }\n\n const searchTermChunks = searchTerm.toUpperCase().split(\" \") || [];\n return options.filter((option) =>\n searchTermChunks.every((chunk) =>\n (option.value || option.label).toUpperCase().includes(chunk)\n )\n );\n };\n\n const getOptionsToShow = (searchTerm: string | undefined): (T | undefined)[] => {\n return selectedOption && selectedOption?.label === searchTerm\n ? options\n : filterOptions(searchTerm);\n };\n\n const optionsToShow = getOptionsToShow(definiteInputValue);\n\n const populateInputField = (value: string) => {\n onInputChange?.(value);\n setInternalInputValue(value);\n };\n\n const scrollOptionIntoView = (option: HTMLLIElement | undefined) => {\n if (option) {\n const optionRect = option.getBoundingClientRect();\n const listboxRect = listboxRef.current?.getBoundingClientRect() || { top: 0, bottom: 0 };\n const isOptionOutsideView =\n optionRect.top < listboxRect.top || optionRect.bottom > listboxRect.bottom;\n if (isOptionOutsideView) {\n option.scrollIntoView({ block: \"nearest\" });\n }\n }\n };\n\n const selectOption = (option: T | undefined) => {\n if (option) {\n inputRef.current?.focus();\n populateInputField(option.label);\n onSelect?.(option);\n }\n closeListbox();\n };\n\n const findNextOption = (key: \"ArrowUp\" | \"ArrowDown\"): T | undefined => {\n const index =\n highlightFirstOption && !highlightedOption\n ? 0\n : optionsToShow.findIndex((option) => option && highlightedOption?.id === option.id);\n\n const optionsLength = optionsToShow.length;\n\n return key === \"ArrowDown\"\n ? optionsToShow[(index ?? -1) + 1] || optionsToShow[0]\n : optionsToShow[(index ?? optionsLength) - 1] || optionsToShow[optionsLength - 1];\n };\n\n const showListbox = listboxIsOpen && (!!optionsToShow.length || !!noOptionsText);\n\n const highlightNextOption = (key: \"ArrowUp\" | \"ArrowDown\") => {\n !showListbox && openListbox({ eventType: \"KEYBOARD\" });\n const nextOption = findNextOption(key);\n\n setHighlightedOption(nextOption);\n nextOption && scrollOptionIntoView(optionRefs.current[nextOption.id]);\n };\n\n const handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n onInputKeyDown?.(event);\n switch (event.key) {\n case \"ArrowUp\":\n case \"ArrowDown\":\n event.preventDefault(); // Preventing default to not move cursor in input\n highlightNextOption(event.key);\n break;\n case \"Enter\": {\n const optionToSelect = highlightedOption || (highlightFirstOption ? options[0] : undefined);\n showListbox && selectOption(optionToSelect);\n !showListbox && openListbox({ eventType: \"KEYBOARD\" });\n break;\n }\n case \"Escape\":\n case \"Tab\":\n closeListbox();\n break;\n }\n };\n\n const handleOnChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n const nextOptionsToShow = getOptionsToShow(e.target.value);\n populateInputField(e.target.value);\n setHighlightedOption(undefined);\n !showListbox && openListbox({ eventType: \"KEYBOARD\" });\n highlightFirstOption &&\n nextOptionsToShow[0] &&\n scrollOptionIntoView(optionRefs.current[nextOptionsToShow[0].id]);\n };\n\n const handleOnMouseDown = (event: React.MouseEvent<HTMLInputElement> | undefined) => {\n onInputMouseDown?.(event);\n showListbox ? closeListbox() : openListbox({ eventType: \"CLICK\" });\n };\n\n const handleOnFocus = (event: React.FocusEvent<HTMLInputElement> | undefined) => {\n onInputFocus?.(event);\n !listboxIsOpen && openOnFocus && openListbox({ eventType: \"KEYBOARD\" });\n inputRef.current?.select();\n };\n\n const handleOnBlur: React.FocusEventHandler<HTMLInputElement> = (event) => {\n onInputBlur?.(event);\n // Use a timeout to allow click events on the listbox to fire before this check\n setTimeout(() => {\n if (\n !inputRef.current?.contains(document.activeElement) &&\n !listboxRef.current?.contains(document.activeElement)\n ) {\n closeListbox();\n\n // If the blur happened due to a click inside the listbox for a combobox, don't reset the value\n if (combobox) {\n populateInputField(selectedOption ? selectedOption.label : \"\");\n }\n }\n });\n };\n\n const listboxStyle: CSSProperties = {\n maxHeight: typeof listboxMaxHeight === \"number\" ? `${listboxMaxHeight}px` : listboxMaxHeight,\n };\n\n const listboxProps: ListboxProps = {\n \"aria-label\": listboxLabel,\n \"aria-expanded\": showListbox,\n \"data-testid\": getTestId(\"listbox\"),\n id: `${id}-listbox`,\n ref: listboxRef,\n onMouseLeave: () => setHighlightedOption(undefined),\n style: listboxMaxHeight ? listboxStyle : undefined,\n };\n\n const createListboxItemId = (option: T) => `${id}-listbox-item-${option.id}`;\n\n const getListBoxItemProps = (option: T, index: number): ListboxItemProps => {\n const handleOnMouseMove = () =>\n option.id !== highlightedOption?.id &&\n setHighlightedOption({ ...option, isSetByClickEvent: true });\n\n const highlighted =\n (option.id === highlightedOption?.id ||\n (!!highlightFirstOption && !highlightedOption && index === 0)) &&\n !highlightedOption?.isSetByClickEvent;\n\n return {\n \"data-testid\": getTestId(`listbox-item-${option.id}`),\n id: createListboxItemId(option),\n key: option.id,\n onMouseMove: handleOnMouseMove,\n onMouseUp: () => selectOption(option),\n ref: (el) => {\n if (el) {\n optionRefs.current[option.id] = el;\n }\n },\n tabIndex: -1,\n selected: option.id === selectedOption?.id,\n disabled: option.disabled,\n highlighted,\n hovered: option.id === highlightedOption?.id && !!highlightedOption?.isSetByClickEvent,\n };\n };\n\n const inputProps: InputProps = {\n \"aria-activedescendant\": highlightedOption ? createListboxItemId(highlightedOption) : undefined,\n \"aria-autocomplete\": \"list\",\n \"aria-controls\": listboxProps.id,\n \"data-testid\": getTestId(\"input\"),\n autoComplete: \"off\",\n id: `${id}-input`,\n onChange: handleOnChange,\n onMouseDown: handleOnMouseDown,\n onFocus: handleOnFocus,\n onKeyDown: handleOnKeyDown,\n onBlur: handleOnBlur,\n ref: inputRef,\n role: \"combobox\",\n value: definiteInputValue,\n };\n\n return {\n id,\n inputProps,\n internalRef,\n optionsToShow,\n showListbox,\n noOptionsText,\n combobox,\n comboboxButtonAriaLabel,\n getListBoxItemProps,\n listboxProps,\n };\n};\n","import type { ComponentPropsWithRef, ForwardedRef, ReactNode } from \"react\";\nimport React, { cloneElement, forwardRef } from \"react\";\nimport { IconChevronDown } from \"@purpur/icon/chevron-down\";\nimport { Listbox } from \"@purpur/listbox\";\nimport { isTextField } from \"@purpur/text-field\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./autocomplete.module.scss\";\nimport type { AutocompleteOption, UseAutocompleteResult } from \"./useAutocomplete\";\nimport { useAutocomplete } from \"./useAutocomplete\";\nimport type { Prettify } from \"./utils\";\n\nconst cx = c.bind(styles);\n\ntype AutocompleteProps<T extends AutocompleteOption> = Prettify<\n UseAutocompleteResult<T> & {\n className?: string;\n /**\n * Render the input. `props` are native input props\n */\n renderInput: (props: ComponentPropsWithRef<\"input\">) => ReactNode;\n /**\n * Invoked for each given option. Use to customize the rendering of the options\n */\n renderOption?: (option: T) => ReactNode;\n }\n>;\n\nconst rootClassName = \"purpur-autocomplete\";\n\nconst AutocompleteComponent = <T extends AutocompleteOption>(\n { className, renderInput, renderOption, ...useAutocompleteProps }: AutocompleteProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) => {\n const {\n id,\n inputProps,\n internalRef,\n optionsToShow,\n showListbox,\n noOptionsText,\n combobox,\n comboboxButtonAriaLabel,\n getListBoxItemProps,\n listboxProps,\n } = useAutocomplete(useAutocompleteProps);\n\n const renderListboxItem = (option: T, index: number) => {\n const { key, ...listboxItemProps } = getListBoxItemProps(option, index);\n\n return (\n <Listbox.Item key={key} {...listboxItemProps}>\n {renderOption ? renderOption?.(option) : option.label}\n </Listbox.Item>\n );\n };\n\n const setRootRef = (node: HTMLDivElement | null) => {\n internalRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n };\n\n const getInputComponent = () => {\n const input = renderInput(inputProps);\n const isCombobox =\n combobox && comboboxButtonAriaLabel && noOptionsText && input && isTextField(input);\n\n if (isCombobox) {\n const endAdornment = (\n <>\n {input.props.endAdornment}\n <button\n data-testid=\"chevron button\"\n type=\"button\"\n className={cx(`${rootClassName}__chevron-button`)}\n onClick={() => {\n inputProps.onFocus(undefined);\n inputProps.onMouseDown(undefined);\n }}\n aria-label={comboboxButtonAriaLabel}\n aria-expanded={showListbox}\n aria-controls={listboxProps.id}\n >\n <IconChevronDown\n size=\"sm\"\n className={cx(`${rootClassName}__chevron-icon`, {\n [`${rootClassName}__chevron-icon--up`]: showListbox,\n })}\n />\n </button>\n </>\n );\n\n return cloneElement(input, { endAdornment });\n }\n\n return input;\n };\n\n return (\n <div id={id} ref={setRootRef} className={cx([rootClassName, className])}>\n {getInputComponent()}\n {showListbox && (\n <Listbox {...listboxProps} className={cx(`${rootClassName}__listbox`)}>\n {!optionsToShow.length ? (\n <Listbox.Item noninteractive>{noOptionsText}</Listbox.Item>\n ) : (\n optionsToShow.filter((option): option is T => !!option).map(renderListboxItem)\n )}\n </Listbox>\n )}\n </div>\n );\n};\n\n/* @deprecated use `Dropdown` or `SearchField` instead, this is only exported for backwards compatibility and will be removed in a future release */\nexport const Autocomplete = forwardRef(AutocompleteComponent);\nAutocomplete.displayName = \"Autocomplete\";\n\nexport type {\n AutocompleteOption,\n UseAutocompleteResult as UseAutocompleteOptions,\n} from \"./useAutocomplete\";\nexport { useAutocomplete } from \"./useAutocomplete\";\n"],"names":["useRefObject","value","useRef","useOnClickOutside","element","callback","handleClickOutside","useCallback","event","useEffect","useAutocomplete","combobox","comboboxButtonAriaLabel","highlightFirstOption","defaultInputValue","inputValue","filterOption","id","listboxLabel","listboxMaxHeight","onInputBlur","onInputChange","onInputFocus","onInputKeyDown","onInputMouseDown","openOnFocus","noOptionsText","onSelect","options","selectedOption","dataTestid","internalInputValue","setInternalInputValue","useState","definiteInputValue","highlightedOption","setHighlightedOption","inputRef","internalRef","listboxRef","optionRefs","listboxIsOpen","setListboxIsOpen","getTestId","name","closeListbox","openListbox","eventType","scrollOptionIntoView","filterOptions","searchTerm","option","searchTermChunks","chunk","getOptionsToShow","optionsToShow","populateInputField","optionRect","listboxRect","selectOption","findNextOption","key","index","optionsLength","showListbox","highlightNextOption","nextOption","handleOnKeyDown","optionToSelect","handleOnChange","nextOptionsToShow","handleOnMouseDown","handleOnFocus","handleOnBlur","listboxStyle","listboxProps","createListboxItemId","getListBoxItemProps","handleOnMouseMove","highlighted","el","inputProps","cx","c","styles","rootClassName","AutocompleteComponent","className","renderInput","renderOption","useAutocompleteProps","ref","renderListboxItem","listboxItemProps","jsx","Listbox","setRootRef","node","getInputComponent","input","isTextField","endAdornment","jsxs","Fragment","IconChevronDown","cloneElement","Autocomplete","forwardRef"],"mappings":"8lBAOaA,GAAmBC,GACvBC,EAAAA,OAAUD,CAAK,EAGXE,GAAoB,CAACC,EAA6BC,IAAyB,CACtF,MAAMC,EAAqBC,EAAAA,YACxBC,GAAsB,CACjBJ,GAAW,CAACA,EAAQ,SAASI,EAAM,MAAc,GACnDH,EAAA,CAEJ,EACA,CAACA,EAAUD,CAAO,CAAA,EAGpBK,EAAAA,UAAU,KACR,SAAS,iBAAiB,YAAaH,CAAkB,EAClD,IAAM,CACX,SAAS,oBAAoB,YAAaA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EAC5BA,EAAW,YAAY,MAAS,CAClC,EACA,aAAYrE,EACZ,gBAAeoD,EACf,gBAAeW,EAAa,GAE5B,SAAAmB,EAAAA,IAACU,GAAAA,EAAA,CACC,KAAK,KACL,UAAWtB,EAAG,GAAGG,CAAa,iBAAkB,CAC9C,CAAC,GAAGA,CAAa,oBAAoB,EAAGrB,CAAA,CACzC,CAAA,CAAA,CACH,CAAA,CACF,EACF,EAGF,OAAOyC,eAAaN,EAAO,CAAE,aAAAE,EAAc,CAC7C,CAEA,OAAOF,CACT,EAEA,OACEG,EAAAA,KAAC,MAAA,CAAI,GAAArF,EAAQ,IAAK+E,EAAY,UAAWd,EAAG,CAACG,EAAeE,CAAS,CAAC,EACnE,SAAA,CAAAW,EAAA,EACAlC,GACC8B,EAAAA,IAACC,EAAAA,QAAA,CAAS,GAAGpB,EAAc,UAAWO,EAAG,GAAGG,CAAa,WAAW,EACjE,SAAC9B,EAAc,OAGdA,EAAc,OAAQJ,GAAwB,CAAC,CAACA,CAAM,EAAE,IAAIyC,CAAiB,EAF7EE,EAAAA,IAACC,EAAAA,QAAQ,KAAR,CAAa,eAAc,GAAE,SAAArE,CAAA,CAAc,CAEiC,CAEjF,CAAA,EAEJ,CAEJ,EAGagF,EAAeC,EAAAA,WAAWrB,EAAqB,EAC5DoB,EAAa,YAAc"}
|
|
1
|
+
{"version":3,"file":"autocomplete-Bbth0nDG.js","sources":["../../../components/autocomplete/src/utils.ts","../../../components/autocomplete/src/useAutocomplete.ts","../../../components/autocomplete/src/autocomplete.tsx"],"sourcesContent":["import { type RefObject, useCallback, useEffect, useRef } from \"react\";\n\n// Used to \"merge\" \"intersection types\". Used to get comments on the props to the docs.\nexport type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport const useRefObject = <T>(value: T): RefObject<T> => {\n return useRef<T>(value) as RefObject<T>;\n};\n\nexport const useOnClickOutside = (element: HTMLElement | null, callback: () => void) => {\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (element && !element.contains(event.target as Node)) {\n callback();\n }\n },\n [callback, element]\n );\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [handleClickOutside]);\n};\n","import type { CSSProperties, ReactNode } from \"react\";\nimport { useRef, useState } from \"react\";\nimport type { BaseProps } from \"@purpur/common-types\";\nimport type { ListboxItemProps, ListboxProps } from \"@purpur/listbox\";\n\nimport { useOnClickOutside, useRefObject } from \"./utils\";\n\nexport type AutocompleteOption = {\n label: string;\n id: string;\n value?: string;\n disabled?: boolean;\n};\n\nexport type InputProps = Omit<BaseProps<\"input\">, \"onFocus\" | \"onMouseDown\"> & {\n onFocus: (event: React.FocusEvent<HTMLInputElement> | undefined) => void;\n onMouseDown: (event: React.MouseEvent<HTMLInputElement> | undefined) => void;\n};\n\ntype ComboboxProps = {\n /*\n * Set to get combobox features. Use in combination with `noOptionsText`, `comboboxButtonAriaLabel` and Purpur TextField.\n */\n combobox: true;\n /**\n * An accessible label for the button that toggles the list of options for a combobox.\n * */\n comboboxButtonAriaLabel: string;\n /*\n * Shown when there are no options to show. Will be displayed inside a listbox item.\n */\n noOptionsText: ReactNode;\n};\n\ntype NoComboboxProps = {\n combobox?: never;\n comboboxButtonAriaLabel?: never;\n /*\n * Shown when there are no options to show. Will be displayed inside a listbox item.\n */\n noOptionsText?: ReactNode;\n};\n\nexport type UseAutocompleteResult<T extends AutocompleteOption> = {\n /*\n * Set to highlight the first option in the listbox when the input is focused.\n */\n highlightFirstOption?: boolean;\n /*\n * The default input value. Only to use when the input is uncontrolled.\n */\n defaultInputValue?: string;\n /*\n * The input value. Use this to control the input value.\n */\n inputValue?: string;\n /*\n * Invoked for each option. Use to control which options are shown.\n */\n filterOption?: (inputValue: string | undefined, option: T) => boolean;\n /*\n * Id will be used to prefix id:s of all elements.\n */\n id: string;\n /*\n * The label of the listbox (dropdown) displaying the options.\n */\n listboxLabel: string;\n /*\n * The height of the listbox. Number will be interpreted as px value. defaults to `calc(2 * var(--purpur-spacing-1200))`.\n */\n listboxMaxHeight?: string | number;\n /*\n * NOTE! Always use this instead of onBlur directly on the input element. Event handler invoked on input blur.\n */\n onInputBlur?: React.FocusEventHandler<HTMLInputElement>;\n /*\n * NOTE! Always use this instead of onChange directly on the input element. Event handler invoked when the input value changes.\n */\n onInputChange?: (value: string) => void;\n /*\n * NOTE! Always use this instead of onFocus directly on the input element. Event handler invoked on input focus.\n */\n onInputFocus?: (event: React.FocusEvent<HTMLInputElement> | undefined) => undefined;\n /*\n * NOTE! Always use this instead of onKeyDown directly on the input element. Event handler invoked on input key down.\n */\n onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /*\n * NOTE! Always use this instead of onMouseDown directly on the input element. Event handler invoked on input mouse down.\n */\n onInputMouseDown?: (event: React.MouseEvent<HTMLInputElement> | undefined) => undefined;\n /*\n * Set to open the listbox when input gets focus.\n */\n openOnFocus?: boolean;\n /*\n * Event handler invoked when an option is selected.\n */\n onSelect?: (option: T | undefined) => void;\n /*\n * The list of options. Could include custom props.\n */\n options: T[];\n /*\n * The selected option.\n */\n selectedOption?: T;\n [\"data-testid\"]?: string;\n} & (ComboboxProps | NoComboboxProps);\n\nexport const useAutocomplete = <T extends AutocompleteOption>({\n combobox,\n comboboxButtonAriaLabel,\n highlightFirstOption,\n defaultInputValue,\n inputValue,\n filterOption,\n id,\n listboxLabel,\n listboxMaxHeight,\n onInputBlur,\n onInputChange,\n onInputFocus,\n onInputKeyDown,\n onInputMouseDown,\n openOnFocus,\n noOptionsText,\n onSelect,\n options,\n selectedOption,\n [\"data-testid\"]: dataTestid,\n}: UseAutocompleteResult<T>) => {\n const [internalInputValue, setInternalInputValue] = useState(\n ((typeof inputValue === \"string\" ? inputValue : defaultInputValue) || selectedOption?.label) ??\n \"\"\n );\n const definiteInputValue = typeof inputValue === \"string\" ? inputValue : internalInputValue;\n const [highlightedOption, setHighlightedOption] = useState<\n (T & { isSetByClickEvent?: false }) | undefined\n >(highlightFirstOption ? options[0] : undefined);\n const inputRef = useRef<HTMLInputElement>(null);\n const internalRef = useRefObject<HTMLDivElement | null>(null);\n const listboxRef = useRef<HTMLUListElement>(null);\n const optionRefs = useRef<Record<string, HTMLLIElement>>({});\n const [listboxIsOpen, setListboxIsOpen] = useState(false);\n\n function getTestId(name: string) {\n return dataTestid ? `${dataTestid}-${name}` : undefined;\n }\n\n const closeListbox = () => {\n setListboxIsOpen(false);\n setHighlightedOption(undefined);\n };\n\n useOnClickOutside(internalRef.current, closeListbox);\n\n const openListbox = ({ eventType }: { eventType: \"CLICK\" | \"KEYBOARD\" }) => {\n setListboxIsOpen(true);\n if (selectedOption) {\n requestAnimationFrame(() => {\n const isSetByClickEvent = eventType === \"CLICK\";\n setHighlightedOption({ ...selectedOption, isSetByClickEvent });\n scrollOptionIntoView(optionRefs.current[selectedOption.id]);\n });\n }\n };\n\n const filterOptions = (searchTerm: string | undefined) => {\n if (filterOption) {\n return options.filter((option) => filterOption(searchTerm, option));\n }\n\n if (!searchTerm) {\n return options;\n }\n\n const searchTermChunks = searchTerm.toUpperCase().split(\" \") || [];\n return options.filter((option) =>\n searchTermChunks.every((chunk) =>\n (option.value || option.label).toUpperCase().includes(chunk)\n )\n );\n };\n\n const getOptionsToShow = (searchTerm: string | undefined): (T | undefined)[] => {\n return selectedOption && selectedOption?.label === searchTerm\n ? options\n : filterOptions(searchTerm);\n };\n\n const optionsToShow = getOptionsToShow(definiteInputValue);\n\n const populateInputField = (value: string) => {\n onInputChange?.(value);\n setInternalInputValue(value);\n };\n\n const scrollOptionIntoView = (option: HTMLLIElement | undefined) => {\n if (option) {\n const optionRect = option.getBoundingClientRect();\n const listboxRect = listboxRef.current?.getBoundingClientRect() || { top: 0, bottom: 0 };\n const isOptionOutsideView =\n optionRect.top < listboxRect.top || optionRect.bottom > listboxRect.bottom;\n if (isOptionOutsideView) {\n option.scrollIntoView({ block: \"nearest\" });\n }\n }\n };\n\n const selectOption = (option: T | undefined) => {\n if (option) {\n inputRef.current?.focus();\n populateInputField(option.label);\n onSelect?.(option);\n }\n closeListbox();\n };\n\n const findNextOption = (key: \"ArrowUp\" | \"ArrowDown\"): T | undefined => {\n const index =\n highlightFirstOption && !highlightedOption\n ? 0\n : optionsToShow.findIndex((option) => option && highlightedOption?.id === option.id);\n\n const optionsLength = optionsToShow.length;\n\n return key === \"ArrowDown\"\n ? optionsToShow[(index ?? -1) + 1] || optionsToShow[0]\n : optionsToShow[(index ?? optionsLength) - 1] || optionsToShow[optionsLength - 1];\n };\n\n const showListbox = listboxIsOpen && (!!optionsToShow.length || !!noOptionsText);\n\n const highlightNextOption = (key: \"ArrowUp\" | \"ArrowDown\") => {\n !showListbox && openListbox({ eventType: \"KEYBOARD\" });\n const nextOption = findNextOption(key);\n\n setHighlightedOption(nextOption);\n nextOption && scrollOptionIntoView(optionRefs.current[nextOption.id]);\n };\n\n const handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n onInputKeyDown?.(event);\n switch (event.key) {\n case \"ArrowUp\":\n case \"ArrowDown\":\n event.preventDefault(); // Preventing default to not move cursor in input\n highlightNextOption(event.key);\n break;\n case \"Enter\": {\n const optionToSelect = highlightedOption || (highlightFirstOption ? options[0] : undefined);\n showListbox && selectOption(optionToSelect);\n !showListbox && openListbox({ eventType: \"KEYBOARD\" });\n break;\n }\n case \"Escape\":\n case \"Tab\":\n closeListbox();\n break;\n }\n };\n\n const handleOnChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {\n const nextOptionsToShow = getOptionsToShow(e.target.value);\n populateInputField(e.target.value);\n setHighlightedOption(undefined);\n !showListbox && openListbox({ eventType: \"KEYBOARD\" });\n highlightFirstOption &&\n nextOptionsToShow[0] &&\n scrollOptionIntoView(optionRefs.current[nextOptionsToShow[0].id]);\n };\n\n const handleOnMouseDown = (event: React.MouseEvent<HTMLInputElement> | undefined) => {\n onInputMouseDown?.(event);\n showListbox ? closeListbox() : openListbox({ eventType: \"CLICK\" });\n };\n\n const handleOnFocus = (event: React.FocusEvent<HTMLInputElement> | undefined) => {\n onInputFocus?.(event);\n !listboxIsOpen && openOnFocus && openListbox({ eventType: \"KEYBOARD\" });\n inputRef.current?.select();\n };\n\n const handleOnBlur: React.FocusEventHandler<HTMLInputElement> = (event) => {\n onInputBlur?.(event);\n // Use a timeout to allow click events on the listbox to fire before this check\n setTimeout(() => {\n if (\n !inputRef.current?.contains(document.activeElement) &&\n !listboxRef.current?.contains(document.activeElement)\n ) {\n closeListbox();\n\n // If the blur happened due to a click inside the listbox for a combobox, don't reset the value\n if (combobox) {\n populateInputField(selectedOption ? selectedOption.label : \"\");\n }\n }\n });\n };\n\n const listboxStyle: CSSProperties = {\n maxHeight: typeof listboxMaxHeight === \"number\" ? `${listboxMaxHeight}px` : listboxMaxHeight,\n };\n\n const listboxProps: ListboxProps = {\n \"aria-label\": listboxLabel,\n \"aria-expanded\": showListbox,\n \"data-testid\": getTestId(\"listbox\"),\n id: `${id}-listbox`,\n ref: listboxRef,\n onMouseLeave: () => setHighlightedOption(undefined),\n style: listboxMaxHeight ? listboxStyle : undefined,\n };\n\n const createListboxItemId = (option: T) => `${id}-listbox-item-${option.id}`;\n\n const getListBoxItemProps = (option: T, index: number): ListboxItemProps => {\n const handleOnMouseMove = () =>\n option.id !== highlightedOption?.id &&\n setHighlightedOption({ ...option, isSetByClickEvent: true });\n\n const highlighted =\n (option.id === highlightedOption?.id ||\n (!!highlightFirstOption && !highlightedOption && index === 0)) &&\n !highlightedOption?.isSetByClickEvent;\n\n return {\n \"data-testid\": getTestId(`listbox-item-${option.id}`),\n id: createListboxItemId(option),\n key: option.id,\n onMouseMove: handleOnMouseMove,\n onMouseUp: () => selectOption(option),\n ref: (el) => {\n if (el) {\n optionRefs.current[option.id] = el;\n }\n },\n tabIndex: -1,\n selected: option.id === selectedOption?.id,\n disabled: option.disabled,\n highlighted,\n hovered: option.id === highlightedOption?.id && !!highlightedOption?.isSetByClickEvent,\n };\n };\n\n const inputProps: InputProps = {\n \"aria-activedescendant\": highlightedOption ? createListboxItemId(highlightedOption) : undefined,\n \"aria-autocomplete\": \"list\",\n \"aria-controls\": listboxProps.id,\n \"data-testid\": getTestId(\"input\"),\n autoComplete: \"off\",\n id: `${id}-input`,\n onChange: handleOnChange,\n onMouseDown: handleOnMouseDown,\n onFocus: handleOnFocus,\n onKeyDown: handleOnKeyDown,\n onBlur: handleOnBlur,\n ref: inputRef,\n role: \"combobox\",\n value: definiteInputValue,\n };\n\n return {\n id,\n inputProps,\n internalRef,\n optionsToShow,\n showListbox,\n noOptionsText,\n combobox,\n comboboxButtonAriaLabel,\n getListBoxItemProps,\n listboxProps,\n };\n};\n","import type { ComponentPropsWithRef, ForwardedRef, ReactNode } from \"react\";\nimport React, { cloneElement, forwardRef } from \"react\";\nimport { IconChevronDown } from \"@purpur/icon/chevron-down\";\nimport { Listbox } from \"@purpur/listbox\";\nimport { isTextField } from \"@purpur/text-field\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./autocomplete.module.scss\";\nimport type { AutocompleteOption, UseAutocompleteResult } from \"./useAutocomplete\";\nimport { useAutocomplete } from \"./useAutocomplete\";\nimport type { Prettify } from \"./utils\";\n\nconst cx = c.bind(styles);\n\ntype AutocompleteProps<T extends AutocompleteOption> = Prettify<\n UseAutocompleteResult<T> & {\n className?: string;\n /**\n * Render the input. `props` are native input props\n */\n renderInput: (props: ComponentPropsWithRef<\"input\">) => ReactNode;\n /**\n * Invoked for each given option. Use to customize the rendering of the options\n */\n renderOption?: (option: T) => ReactNode;\n }\n>;\n\nconst rootClassName = \"purpur-autocomplete\";\n\nconst AutocompleteComponent = <T extends AutocompleteOption>(\n { className, renderInput, renderOption, ...useAutocompleteProps }: AutocompleteProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) => {\n const {\n id,\n inputProps,\n internalRef,\n optionsToShow,\n showListbox,\n noOptionsText,\n combobox,\n comboboxButtonAriaLabel,\n getListBoxItemProps,\n listboxProps,\n } = useAutocomplete(useAutocompleteProps);\n\n const renderListboxItem = (option: T, index: number) => {\n const { key, ...listboxItemProps } = getListBoxItemProps(option, index);\n\n return (\n <Listbox.Item key={key} {...listboxItemProps}>\n {renderOption ? renderOption?.(option) : option.label}\n </Listbox.Item>\n );\n };\n\n const setRootRef = (node: HTMLDivElement | null) => {\n internalRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n };\n\n const getInputComponent = () => {\n const input = renderInput(inputProps);\n const isCombobox =\n combobox && comboboxButtonAriaLabel && noOptionsText && input && isTextField(input);\n\n if (isCombobox) {\n const endAdornment = (\n <>\n {input.props.endAdornment}\n <button\n data-testid=\"chevron button\"\n type=\"button\"\n className={cx(`${rootClassName}__chevron-button`)}\n onClick={() => {\n inputProps.onFocus(undefined);\n inputProps.onMouseDown(undefined);\n }}\n aria-label={comboboxButtonAriaLabel}\n aria-expanded={showListbox}\n aria-controls={listboxProps.id}\n >\n <IconChevronDown\n size=\"sm\"\n className={cx(`${rootClassName}__chevron-icon`, {\n [`${rootClassName}__chevron-icon--up`]: showListbox,\n })}\n />\n </button>\n </>\n );\n\n return cloneElement(input, { endAdornment });\n }\n\n return input;\n };\n\n return (\n <div id={id} ref={setRootRef} className={cx([rootClassName, className])}>\n {getInputComponent()}\n {showListbox && (\n <Listbox {...listboxProps} className={cx(`${rootClassName}__listbox`)}>\n {!optionsToShow.length ? (\n <Listbox.Item noninteractive>{noOptionsText}</Listbox.Item>\n ) : (\n optionsToShow.filter((option): option is T => !!option).map(renderListboxItem)\n )}\n </Listbox>\n )}\n </div>\n );\n};\n\n/* @deprecated use `Dropdown` or `SearchField` instead, this is only exported for backwards compatibility and will be removed in a future release */\nexport const Autocomplete = forwardRef(AutocompleteComponent);\nAutocomplete.displayName = \"Autocomplete\";\n\nexport type {\n AutocompleteOption,\n UseAutocompleteResult as UseAutocompleteOptions,\n} from \"./useAutocomplete\";\nexport { useAutocomplete } from \"./useAutocomplete\";\n"],"names":["useRefObject","value","useRef","useOnClickOutside","element","callback","handleClickOutside","useCallback","event","useEffect","useAutocomplete","combobox","comboboxButtonAriaLabel","highlightFirstOption","defaultInputValue","inputValue","filterOption","id","listboxLabel","listboxMaxHeight","onInputBlur","onInputChange","onInputFocus","onInputKeyDown","onInputMouseDown","openOnFocus","noOptionsText","onSelect","options","selectedOption","dataTestid","internalInputValue","setInternalInputValue","useState","definiteInputValue","highlightedOption","setHighlightedOption","inputRef","internalRef","listboxRef","optionRefs","listboxIsOpen","setListboxIsOpen","getTestId","name","closeListbox","openListbox","eventType","scrollOptionIntoView","filterOptions","searchTerm","option","searchTermChunks","chunk","getOptionsToShow","optionsToShow","populateInputField","optionRect","listboxRect","selectOption","findNextOption","key","index","optionsLength","showListbox","highlightNextOption","nextOption","handleOnKeyDown","optionToSelect","handleOnChange","nextOptionsToShow","handleOnMouseDown","handleOnFocus","handleOnBlur","listboxStyle","listboxProps","createListboxItemId","getListBoxItemProps","handleOnMouseMove","highlighted","el","inputProps","cx","c","styles","rootClassName","AutocompleteComponent","className","renderInput","renderOption","useAutocompleteProps","ref","renderListboxItem","listboxItemProps","jsx","Listbox","setRootRef","node","getInputComponent","input","isTextField","endAdornment","jsxs","Fragment","IconChevronDown","cloneElement","Autocomplete","forwardRef"],"mappings":"8lBAOaA,GAAmBC,GACvBC,EAAAA,OAAUD,CAAK,EAGXE,GAAoB,CAACC,EAA6BC,IAAyB,CACtF,MAAMC,EAAqBC,EAAAA,YACxBC,GAAsB,CACjBJ,GAAW,CAACA,EAAQ,SAASI,EAAM,MAAc,GACnDH,EAAA,CAEJ,EACA,CAACA,EAAUD,CAAO,CAAA,EAGpBK,EAAAA,UAAU,KACR,SAAS,iBAAiB,YAAaH,CAAkB,EAClD,IAAM,CACX,SAAS,oBAAoB,YAAaA,CAAkB,CAC9D,GACC,CAACA,CAAkB,CAAC,CACzB,ECoFaI,EAAkB,CAA+B,CAC5D,SAAAC,EACA,wBAAAC,EACA,qBAAAC,EACA,kBAAAC,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CACC,KAAK,KACL,UAAWtB,EAAG,GAAGG,CAAa,iBAAkB,CAC9C,CAAC,GAAGA,CAAa,oBAAoB,EAAGrB,CAAA,CACzC,CAAA,CAAA,CACH,CAAA,CACF,EACF,EAGF,OAAOyC,eAAaN,EAAO,CAAE,aAAAE,EAAc,CAC7C,CAEA,OAAOF,CACT,EAEA,OACEG,EAAAA,KAAC,MAAA,CAAI,GAAArF,EAAQ,IAAK+E,EAAY,UAAWd,EAAG,CAACG,EAAeE,CAAS,CAAC,EACnE,SAAA,CAAAW,EAAA,EACAlC,GACC8B,EAAAA,IAACC,EAAAA,QAAA,CAAS,GAAGpB,EAAc,UAAWO,EAAG,GAAGG,CAAa,WAAW,EACjE,SAAC9B,EAAc,OAGdA,EAAc,OAAQJ,GAAwB,CAAC,CAACA,CAAM,EAAE,IAAIyC,CAAiB,EAF7EE,EAAAA,IAACC,EAAAA,QAAQ,KAAR,CAAa,eAAc,GAAE,SAAArE,CAAA,CAAc,CAEiC,CAEjF,CAAA,EAEJ,CAEJ,EAGagF,EAAeC,EAAAA,WAAWrB,EAAqB,EAC5DoB,EAAa,YAAc"}
|
package/dist/autocomplete.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./autocomplete-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./autocomplete-Bbth0nDG.js");exports.Autocomplete=e.Autocomplete;exports.useAutocomplete=e.useAutocomplete;
|
|
2
2
|
//# sourceMappingURL=autocomplete.cjs.js.map
|
package/dist/autocomplete.es.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AccordionProps } from './accordion';
|
|
3
|
+
export type AccordionVisualScenario = {
|
|
4
|
+
key: string;
|
|
5
|
+
title: string;
|
|
6
|
+
createProps: () => AccordionProps;
|
|
7
|
+
};
|
|
8
|
+
export declare const accordionVisualScenarios: AccordionVisualScenario[];
|
|
9
|
+
export declare const getAccordionVisualTestId: (scenarioKey: string) => string;
|
|
10
|
+
export declare const AccordionVisualScenarioRoot: ({ scenarioKey }: {
|
|
11
|
+
scenarioKey: string;
|
|
12
|
+
}) => React.JSX.Element;
|
|
13
|
+
//# sourceMappingURL=accordion.visual.fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.visual.fixtures.d.ts","sourceRoot":"","sources":["../../../../../../components/accordion/src/accordion.visual.fixtures.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,cAAc,CAAC;CACnC,CAAC;AAuBF,eAAO,MAAM,wBAAwB,EAAE,uBAAuB,EAuC7D,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,aAAa,MAAM,WAAsC,CAAC;AAEnG,eAAO,MAAM,2BAA2B,GAAI,iBAAiB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,sBAYnF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { BadgeProps } from './badge';
|
|
3
|
+
export type BadgeVisualScenario = {
|
|
4
|
+
key: string;
|
|
5
|
+
title: string;
|
|
6
|
+
createProps: () => BadgeProps;
|
|
7
|
+
};
|
|
8
|
+
export declare const badgeVisualScenarios: BadgeVisualScenario[];
|
|
9
|
+
export declare const getBadgeVisualTestId: (scenarioKey: string) => string;
|
|
10
|
+
export declare const BadgeVisualScenarioRoot: ({ scenarioKey }: {
|
|
11
|
+
scenarioKey: string;
|
|
12
|
+
}) => React.JSX.Element;
|
|
13
|
+
//# sourceMappingURL=badge.visual.fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.visual.fixtures.d.ts","sourceRoot":"","sources":["../../../../../../components/badge/src/badge.visual.fixtures.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAwB,KAAK,UAAU,EAAqB,MAAM,SAAS,CAAC;AAEnF,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,UAAU,CAAC;CAC/B,CAAC;AAcF,eAAO,MAAM,oBAAoB,EAAE,mBAAmB,EA0CrD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,aAAa,MAAM,WACzB,CAAC;AAEhC,eAAO,MAAM,uBAAuB,GAAI,iBAAiB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,sBAY/E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telia-logo.d.ts","sourceRoot":"","sources":["../../../../../../components/footer/src/telia-logo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"telia-logo.d.ts","sourceRoot":"","sources":["../../../../../../components/footer/src/telia-logo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,SAAS,yBA2CrB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BaseProps } from '../../../libraries/common-types/src/common-types';
|
|
3
|
+
import { ColorScheme } from '../../../libraries/theme/src/theme';
|
|
4
|
+
export declare const TitleHyphenVariant: {
|
|
5
|
+
readonly default: "default";
|
|
6
|
+
readonly enabled: "enabled";
|
|
7
|
+
readonly disabled: "disabled";
|
|
8
|
+
};
|
|
9
|
+
export type TitleHyphens = (typeof TitleHyphenVariant)[keyof typeof TitleHyphenVariant];
|
|
10
|
+
export type HeroBannerProps = BaseProps & {
|
|
11
|
+
/**
|
|
12
|
+
* Custom content slot
|
|
13
|
+
* Add your CTAs here with <HeroBanner.CTAs> component
|
|
14
|
+
*/
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Breadcrumbs: <br/>
|
|
18
|
+
* - Slot for your Breadcrumbs component
|
|
19
|
+
*/
|
|
20
|
+
breadcrumbs?: ReactNode;
|
|
21
|
+
forceColorScheme?: ColorScheme;
|
|
22
|
+
/**
|
|
23
|
+
* Content to display before the main heading
|
|
24
|
+
*/
|
|
25
|
+
beforeTitle?: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Main heading of the component
|
|
28
|
+
*/
|
|
29
|
+
title: string;
|
|
30
|
+
/**
|
|
31
|
+
* Main heading tag
|
|
32
|
+
*/
|
|
33
|
+
titleTag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
34
|
+
titleHyphens?: TitleHyphens;
|
|
35
|
+
/**
|
|
36
|
+
* Preamble text
|
|
37
|
+
*/
|
|
38
|
+
preamble?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Additional text under the CTAs, recommended to limit element to simple text with text decorations
|
|
41
|
+
*/
|
|
42
|
+
additionalText?: ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* <HeroBanner.Media /> component (images and videos)
|
|
45
|
+
*/
|
|
46
|
+
media?: ReactNode;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=hero-banner-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hero-banner-types.d.ts","sourceRoot":"","sources":["../../../../../../components/hero-banner/src/hero-banner-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAExF,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACnD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC"}
|
|
@@ -1,51 +1,8 @@
|
|
|
1
|
-
import { default as React
|
|
2
|
-
import {
|
|
3
|
-
import { ColorScheme } from '../../../libraries/theme/src/theme';
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { HeroBannerProps } from './hero-banner-types';
|
|
4
3
|
export type { HeroBannerMediaProps } from './hero-banner-media';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
readonly enabled: "enabled";
|
|
8
|
-
readonly disabled: "disabled";
|
|
9
|
-
};
|
|
10
|
-
export type TitleHyphens = (typeof TitleHyphenVariant)[keyof typeof TitleHyphenVariant];
|
|
11
|
-
export type HeroBannerProps = BaseProps & {
|
|
12
|
-
/**
|
|
13
|
-
* Custom content slot
|
|
14
|
-
* Add your CTAs here with <HeroBanner.CTAs> component
|
|
15
|
-
*/
|
|
16
|
-
children?: ReactNode;
|
|
17
|
-
/**
|
|
18
|
-
* Breadcrumbs: <br/>
|
|
19
|
-
* - Slot for your Breadcrumbs component
|
|
20
|
-
*/
|
|
21
|
-
breadcrumbs?: ReactNode;
|
|
22
|
-
forceColorScheme?: ColorScheme;
|
|
23
|
-
/**
|
|
24
|
-
* Content to display before the main heading
|
|
25
|
-
*/
|
|
26
|
-
beforeTitle?: ReactNode;
|
|
27
|
-
/**
|
|
28
|
-
* Main heading of the component
|
|
29
|
-
*/
|
|
30
|
-
title: string;
|
|
31
|
-
/**
|
|
32
|
-
* Main heading tag
|
|
33
|
-
*/
|
|
34
|
-
titleTag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
35
|
-
titleHyphens?: TitleHyphens;
|
|
36
|
-
/**
|
|
37
|
-
* Preamble text
|
|
38
|
-
*/
|
|
39
|
-
preamble?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Additional text under the CTAs, recommended to limit element to simple text with text decorations
|
|
42
|
-
*/
|
|
43
|
-
additionalText?: ReactNode;
|
|
44
|
-
/**
|
|
45
|
-
* <HeroBanner.Media /> component (images and videos)
|
|
46
|
-
*/
|
|
47
|
-
media?: ReactNode;
|
|
48
|
-
};
|
|
4
|
+
export type { HeroBannerProps, TitleHyphens } from './hero-banner-types';
|
|
5
|
+
export { TitleHyphenVariant } from './hero-banner-types';
|
|
49
6
|
export declare const HeroBanner: {
|
|
50
7
|
({ children, className, breadcrumbs, forceColorScheme, beforeTitle, title, titleTag, titleHyphens, preamble, additionalText, media, ...props }: HeroBannerProps): React.JSX.Element;
|
|
51
8
|
displayName: string;
|
|
@@ -53,7 +10,7 @@ export declare const HeroBanner: {
|
|
|
53
10
|
Actions: ({ children, className, ...props }: Omit<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement> & {
|
|
54
11
|
[key: `data-${string}`]: string | undefined;
|
|
55
12
|
}, "children"> & {
|
|
56
|
-
children: ReactNode;
|
|
13
|
+
children: React.ReactNode;
|
|
57
14
|
}) => React.JSX.Element;
|
|
58
15
|
};
|
|
59
16
|
//# sourceMappingURL=hero-banner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hero-banner.d.ts","sourceRoot":"","sources":["../../../../../../components/hero-banner/src/hero-banner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"hero-banner.d.ts","sourceRoot":"","sources":["../../../../../../components/hero-banner/src/hero-banner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAMzD,eAAO,MAAM,UAAU;oJAapB,eAAe;;;;;;;;CA0FjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hero-banner.visual.fixtures.d.ts","sourceRoot":"","sources":["../../../../../../components/hero-banner/src/hero-banner.visual.fixtures.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"hero-banner.visual.fixtures.d.ts","sourceRoot":"","sources":["../../../../../../components/hero-banner/src/hero-banner.visual.fixtures.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,qBAAqB,CAAC;AAE/E,KAAK,wBAAwB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,eAAe,CAAC;CACpC,CAAC;AAuEF,eAAO,MAAM,yBAAyB,EAAE,wBAAwB,EAkE/D,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,aAAa,MAAM,WACxB,CAAC;AAEtC,eAAO,MAAM,4BAA4B,GAAI,iBAAiB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,sBAUpF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const q=require("react/jsx-runtime"),T=require("react"),Z=require("./text-field-CYJzQG3h.js"),V=require("./bind-DeUYJ6m9.js"),a=require("./format-CFKKBdIQ.js");function U(){return Object.assign({},a.getDefaultOptions())}function J(n,e){const r=a.toDate(n,e?.in).getDay();return r===0?7:r}function S(n,e){const r=ee(e)?new e(0):a.constructFrom(e,0);return r.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),r.setHours(n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),r}function ee(n){return typeof n=="function"&&n.prototype?.constructor===n}const te=10;class A{subPriority=0;validate(e,r){return!0}}class re extends A{constructor(e,r,t,s,o){super(),this.value=e,this.validateValue=r,this.setValue=t,this.priority=s,o&&(this.subPriority=o)}validate(e,r){return this.validateValue(e,this.value,r)}set(e,r,t){return this.setValue(e,r,this.value,t)}}class ne extends A{priority=te;subPriority=-1;constructor(e,r){super(),this.context=e||(t=>a.constructFrom(r,t))}set(e,r){return r.timestampIsSet?e:a.constructFrom(e,S(e,this.context))}}class c{run(e,r,t,s){const o=this.parse(e,r,t,s);return o?{setter:new re(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(e,r,t){return!0}}class se extends c{priority=140;parse(e,r,t){switch(r){case"G":case"GG":case"GGG":return t.era(e,{width:"abbreviated"})||t.era(e,{width:"narrow"});case"GGGGG":return t.era(e,{width:"narrow"});default:return t.era(e,{width:"wide"})||t.era(e,{width:"abbreviated"})||t.era(e,{width:"narrow"})}}set(e,r,t){return r.era=t,e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["R","u","t","T"]}const w={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},D={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function h(n,e){return n&&{value:e(n.value),rest:n.rest}}function d(n,e){const r=e.match(n);return r?{value:parseInt(r[0],10),rest:e.slice(r[0].length)}:null}function _(n,e){const r=e.match(n);if(!r)return null;if(r[0]==="Z")return{value:0,rest:e.slice(1)};const t=r[1]==="+"?1:-1,s=r[2]?parseInt(r[2],10):0,o=r[3]?parseInt(r[3],10):0,u=r[5]?parseInt(r[5],10):0;return{value:t*(s*a.millisecondsInHour+o*a.millisecondsInMinute+u*a.millisecondsInSecond),rest:e.slice(r[0].length)}}function z(n){return d(w.anyDigitsSigned,n)}function f(n,e){switch(n){case 1:return d(w.singleDigit,e);case 2:return d(w.twoDigits,e);case 3:return d(w.threeDigits,e);case 4:return d(w.fourDigits,e);default:return d(new RegExp("^\\d{1,"+n+"}"),e)}}function L(n,e){switch(n){case 1:return d(w.singleDigitSigned,e);case 2:return d(w.twoDigitsSigned,e);case 3:return d(w.threeDigitsSigned,e);case 4:return d(w.fourDigitsSigned,e);default:return d(new RegExp("^-?\\d{1,"+n+"}"),e)}}function W(n){switch(n){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;default:return 0}}function $(n,e){const r=e>0,t=r?e:1-e;let s;if(t<=50)s=n||100;else{const o=t+50,u=Math.trunc(o/100)*100,b=n>=o%100;s=n+u-(b?100:0)}return r?s:1-s}function j(n){return n%400===0||n%4===0&&n%100!==0}class oe extends c{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,r,t){const s=o=>({year:o,isTwoDigitYear:r==="yy"});switch(r){case"y":return h(f(4,e),s);case"yo":return h(t.ordinalNumber(e,{unit:"year"}),s);default:return h(f(r.length,e),s)}}validate(e,r){return r.isTwoDigitYear||r.year>0}set(e,r,t){const s=e.getFullYear();if(t.isTwoDigitYear){const u=$(t.year,s);return e.setFullYear(u,0,1),e.setHours(0,0,0,0),e}const o=!("era"in r)||r.era===1?t.year:1-t.year;return e.setFullYear(o,0,1),e.setHours(0,0,0,0),e}}class ae extends c{priority=130;parse(e,r,t){const s=o=>({year:o,isTwoDigitYear:r==="YY"});switch(r){case"Y":return h(f(4,e),s);case"Yo":return h(t.ordinalNumber(e,{unit:"year"}),s);default:return h(f(r.length,e),s)}}validate(e,r){return r.isTwoDigitYear||r.year>0}set(e,r,t,s){const o=a.getWeekYear(e,s);if(t.isTwoDigitYear){const b=$(t.year,o);return e.setFullYear(b,0,s.firstWeekContainsDate),e.setHours(0,0,0,0),a.startOfWeek(e,s)}const u=!("era"in r)||r.era===1?t.year:1-t.year;return e.setFullYear(u,0,s.firstWeekContainsDate),e.setHours(0,0,0,0),a.startOfWeek(e,s)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]}class ie extends c{priority=130;parse(e,r){return L(r==="R"?4:r.length,e)}set(e,r,t){const s=a.constructFrom(e,0);return s.setFullYear(t,0,4),s.setHours(0,0,0,0),a.startOfISOWeek(s)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]}class ce extends c{priority=130;parse(e,r){return L(r==="u"?4:r.length,e)}set(e,r,t){return e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]}class ue extends c{priority=120;parse(e,r,t){switch(r){case"Q":case"QQ":return f(r.length,e);case"Qo":return t.ordinalNumber(e,{unit:"quarter"});case"QQQ":return t.quarter(e,{width:"abbreviated",context:"formatting"})||t.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return t.quarter(e,{width:"narrow",context:"formatting"});default:return t.quarter(e,{width:"wide",context:"formatting"})||t.quarter(e,{width:"abbreviated",context:"formatting"})||t.quarter(e,{width:"narrow",context:"formatting"})}}validate(e,r){return r>=1&&r<=4}set(e,r,t){return e.setMonth((t-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]}class le extends c{priority=120;parse(e,r,t){switch(r){case"q":case"qq":return f(r.length,e);case"qo":return t.ordinalNumber(e,{unit:"quarter"});case"qqq":return t.quarter(e,{width:"abbreviated",context:"standalone"})||t.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return t.quarter(e,{width:"narrow",context:"standalone"});default:return t.quarter(e,{width:"wide",context:"standalone"})||t.quarter(e,{width:"abbreviated",context:"standalone"})||t.quarter(e,{width:"narrow",context:"standalone"})}}validate(e,r){return r>=1&&r<=4}set(e,r,t){return e.setMonth((t-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]}class de extends c{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,r,t){const s=o=>o-1;switch(r){case"M":return h(d(w.month,e),s);case"MM":return h(f(2,e),s);case"Mo":return h(t.ordinalNumber(e,{unit:"month"}),s);case"MMM":return t.month(e,{width:"abbreviated",context:"formatting"})||t.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return t.month(e,{width:"narrow",context:"formatting"});default:return t.month(e,{width:"wide",context:"formatting"})||t.month(e,{width:"abbreviated",context:"formatting"})||t.month(e,{width:"narrow",context:"formatting"})}}validate(e,r){return r>=0&&r<=11}set(e,r,t){return e.setMonth(t,1),e.setHours(0,0,0,0),e}}class fe extends c{priority=110;parse(e,r,t){const s=o=>o-1;switch(r){case"L":return h(d(w.month,e),s);case"LL":return h(f(2,e),s);case"Lo":return h(t.ordinalNumber(e,{unit:"month"}),s);case"LLL":return t.month(e,{width:"abbreviated",context:"standalone"})||t.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return t.month(e,{width:"narrow",context:"standalone"});default:return t.month(e,{width:"wide",context:"standalone"})||t.month(e,{width:"abbreviated",context:"standalone"})||t.month(e,{width:"narrow",context:"standalone"})}}validate(e,r){return r>=0&&r<=11}set(e,r,t){return e.setMonth(t,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]}function we(n,e,r){const t=a.toDate(n,r?.in),s=a.getWeek(t,r)-e;return t.setDate(t.getDate()-s*7),a.toDate(t,r?.in)}class he extends c{priority=100;parse(e,r,t){switch(r){case"w":return d(w.week,e);case"wo":return t.ordinalNumber(e,{unit:"week"});default:return f(r.length,e)}}validate(e,r){return r>=1&&r<=53}set(e,r,t,s){return a.startOfWeek(we(e,t,s),s)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]}function pe(n,e,r){const t=a.toDate(n,r?.in),s=a.getISOWeek(t,r)-e;return t.setDate(t.getDate()-s*7),t}class ye extends c{priority=100;parse(e,r,t){switch(r){case"I":return d(w.week,e);case"Io":return t.ordinalNumber(e,{unit:"week"});default:return f(r.length,e)}}validate(e,r){return r>=1&&r<=53}set(e,r,t){return a.startOfISOWeek(pe(e,t))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]}const xe=[31,28,31,30,31,30,31,31,30,31,30,31],be=[31,29,31,30,31,30,31,31,30,31,30,31];class me extends c{priority=90;subPriority=1;parse(e,r,t){switch(r){case"d":return d(w.date,e);case"do":return t.ordinalNumber(e,{unit:"date"});default:return f(r.length,e)}}validate(e,r){const t=e.getFullYear(),s=j(t),o=e.getMonth();return s?r>=1&&r<=be[o]:r>=1&&r<=xe[o]}set(e,r,t){return e.setDate(t),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]}class ge extends c{priority=90;subpriority=1;parse(e,r,t){switch(r){case"D":case"DD":return d(w.dayOfYear,e);case"Do":return t.ordinalNumber(e,{unit:"date"});default:return f(r.length,e)}}validate(e,r){const t=e.getFullYear();return j(t)?r>=1&&r<=366:r>=1&&r<=365}set(e,r,t){return e.setMonth(0,t),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]}function B(n,e,r){const t=a.getDefaultOptions(),s=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,o=a.toDate(n,r?.in),u=o.getDay(),y=(e%7+7)%7,k=7-s,E=e<0||e>6?e-(u+k)%7:(y+k)%7-(u+k)%7;return a.addDays(o,E,r)}class Te extends c{priority=90;parse(e,r,t){switch(r){case"E":case"EE":case"EEE":return t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return t.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"});default:return t.day(e,{width:"wide",context:"formatting"})||t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"})}}validate(e,r){return r>=0&&r<=6}set(e,r,t,s){return e=B(e,t,s),e.setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]}class De extends c{priority=90;parse(e,r,t,s){const o=u=>{const b=Math.floor((u-1)/7)*7;return(u+s.weekStartsOn+6)%7+b};switch(r){case"e":case"ee":return h(f(r.length,e),o);case"eo":return h(t.ordinalNumber(e,{unit:"day"}),o);case"eee":return t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"});case"eeeee":return t.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"});default:return t.day(e,{width:"wide",context:"formatting"})||t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"})}}validate(e,r){return r>=0&&r<=6}set(e,r,t,s){return e=B(e,t,s),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]}class _e extends c{priority=90;parse(e,r,t,s){const o=u=>{const b=Math.floor((u-1)/7)*7;return(u+s.weekStartsOn+6)%7+b};switch(r){case"c":case"cc":return h(f(r.length,e),o);case"co":return h(t.ordinalNumber(e,{unit:"day"}),o);case"ccc":return t.day(e,{width:"abbreviated",context:"standalone"})||t.day(e,{width:"short",context:"standalone"})||t.day(e,{width:"narrow",context:"standalone"});case"ccccc":return t.day(e,{width:"narrow",context:"standalone"});case"cccccc":return t.day(e,{width:"short",context:"standalone"})||t.day(e,{width:"narrow",context:"standalone"});default:return t.day(e,{width:"wide",context:"standalone"})||t.day(e,{width:"abbreviated",context:"standalone"})||t.day(e,{width:"short",context:"standalone"})||t.day(e,{width:"narrow",context:"standalone"})}}validate(e,r){return r>=0&&r<=6}set(e,r,t,s){return e=B(e,t,s),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]}function ke(n,e,r){const t=a.toDate(n,r?.in),s=J(t,r),o=e-s;return a.addDays(t,o,r)}class Pe extends c{priority=90;parse(e,r,t){const s=o=>o===0?7:o;switch(r){case"i":case"ii":return f(r.length,e);case"io":return t.ordinalNumber(e,{unit:"day"});case"iii":return h(t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"}),s);case"iiiii":return h(t.day(e,{width:"narrow",context:"formatting"}),s);case"iiiiii":return h(t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"}),s);default:return h(t.day(e,{width:"wide",context:"formatting"})||t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"}),s)}}validate(e,r){return r>=1&&r<=7}set(e,r,t){return e=ke(e,t),e.setHours(0,0,0,0),e}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]}class Me extends c{priority=80;parse(e,r,t){switch(r){case"a":case"aa":case"aaa":return t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return t.dayPeriod(e,{width:"narrow",context:"formatting"});default:return t.dayPeriod(e,{width:"wide",context:"formatting"})||t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,r,t){return e.setHours(W(t),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]}class Oe extends c{priority=80;parse(e,r,t){switch(r){case"b":case"bb":case"bbb":return t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return t.dayPeriod(e,{width:"narrow",context:"formatting"});default:return t.dayPeriod(e,{width:"wide",context:"formatting"})||t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,r,t){return e.setHours(W(t),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]}class Ye extends c{priority=80;parse(e,r,t){switch(r){case"B":case"BB":case"BBB":return t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return t.dayPeriod(e,{width:"narrow",context:"formatting"});default:return t.dayPeriod(e,{width:"wide",context:"formatting"})||t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,r,t){return e.setHours(W(t),0,0,0),e}incompatibleTokens=["a","b","t","T"]}class Ee extends c{priority=70;parse(e,r,t){switch(r){case"h":return d(w.hour12h,e);case"ho":return t.ordinalNumber(e,{unit:"hour"});default:return f(r.length,e)}}validate(e,r){return r>=1&&r<=12}set(e,r,t){const s=e.getHours()>=12;return s&&t<12?e.setHours(t+12,0,0,0):!s&&t===12?e.setHours(0,0,0,0):e.setHours(t,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]}class He extends c{priority=70;parse(e,r,t){switch(r){case"H":return d(w.hour23h,e);case"Ho":return t.ordinalNumber(e,{unit:"hour"});default:return f(r.length,e)}}validate(e,r){return r>=0&&r<=23}set(e,r,t){return e.setHours(t,0,0,0),e}incompatibleTokens=["a","b","h","K","k","t","T"]}class Ie extends c{priority=70;parse(e,r,t){switch(r){case"K":return d(w.hour11h,e);case"Ko":return t.ordinalNumber(e,{unit:"hour"});default:return f(r.length,e)}}validate(e,r){return r>=0&&r<=11}set(e,r,t){return e.getHours()>=12&&t<12?e.setHours(t+12,0,0,0):e.setHours(t,0,0,0),e}incompatibleTokens=["h","H","k","t","T"]}class qe extends c{priority=70;parse(e,r,t){switch(r){case"k":return d(w.hour24h,e);case"ko":return t.ordinalNumber(e,{unit:"hour"});default:return f(r.length,e)}}validate(e,r){return r>=1&&r<=24}set(e,r,t){const s=t<=24?t%24:t;return e.setHours(s,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]}class Re extends c{priority=60;parse(e,r,t){switch(r){case"m":return d(w.minute,e);case"mo":return t.ordinalNumber(e,{unit:"minute"});default:return f(r.length,e)}}validate(e,r){return r>=0&&r<=59}set(e,r,t){return e.setMinutes(t,0,0),e}incompatibleTokens=["t","T"]}class Le extends c{priority=50;parse(e,r,t){switch(r){case"s":return d(w.second,e);case"so":return t.ordinalNumber(e,{unit:"second"});default:return f(r.length,e)}}validate(e,r){return r>=0&&r<=59}set(e,r,t){return e.setSeconds(t,0),e}incompatibleTokens=["t","T"]}class ve extends c{priority=30;parse(e,r){const t=s=>Math.trunc(s*Math.pow(10,-r.length+3));return h(f(r.length,e),t)}set(e,r,t){return e.setMilliseconds(t),e}incompatibleTokens=["t","T"]}class Ne extends c{priority=10;parse(e,r){switch(r){case"X":return _(D.basicOptionalMinutes,e);case"XX":return _(D.basic,e);case"XXXX":return _(D.basicOptionalSeconds,e);case"XXXXX":return _(D.extendedOptionalSeconds,e);default:return _(D.extended,e)}}set(e,r,t){return r.timestampIsSet?e:a.constructFrom(e,e.getTime()-a.getTimezoneOffsetInMilliseconds(e)-t)}incompatibleTokens=["t","T","x"]}class Qe extends c{priority=10;parse(e,r){switch(r){case"x":return _(D.basicOptionalMinutes,e);case"xx":return _(D.basic,e);case"xxxx":return _(D.basicOptionalSeconds,e);case"xxxxx":return _(D.extendedOptionalSeconds,e);default:return _(D.extended,e)}}set(e,r,t){return r.timestampIsSet?e:a.constructFrom(e,e.getTime()-a.getTimezoneOffsetInMilliseconds(e)-t)}incompatibleTokens=["t","T","X"]}class Ce extends c{priority=40;parse(e){return z(e)}set(e,r,t){return[a.constructFrom(e,t*1e3),{timestampIsSet:!0}]}incompatibleTokens="*"}class Fe extends c{priority=20;parse(e){return z(e)}set(e,r,t){return[a.constructFrom(e,t),{timestampIsSet:!0}]}incompatibleTokens="*"}const We={G:new se,y:new oe,Y:new ae,R:new ie,u:new ce,Q:new ue,q:new le,M:new de,L:new fe,w:new he,I:new ye,d:new me,D:new ge,E:new Te,e:new De,c:new _e,i:new Pe,a:new Me,b:new Oe,B:new Ye,h:new Ee,H:new He,K:new Ie,k:new qe,m:new Re,s:new Le,S:new ve,X:new Ne,x:new Qe,t:new Ce,T:new Fe},Be=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ge=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Xe=/^'([^]*?)'?$/,Ae=/''/g,ze=/\S/,$e=/[a-zA-Z]/;function je(n,e,r,t){const s=()=>a.constructFrom(r,NaN),o=U(),u=o.locale??a.enUS,b=o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,y=o.weekStartsOn??o.locale?.options?.weekStartsOn??0,k={firstWeekContainsDate:b,weekStartsOn:y,locale:u},E=[new ne(t?.in,r)],v=e.match(Ge).map(i=>{const l=i[0];if(l in a.longFormatters){const m=a.longFormatters[l];return m(i,u.formatLong)}return i}).join("").match(Be),P=[];for(let i of v){a.isProtectedWeekYearToken(i)&&a.warnOrThrowProtectedError(i,e,n),a.isProtectedDayOfYearToken(i)&&a.warnOrThrowProtectedError(i,e,n);const l=i[0],m=We[l];if(m){const{incompatibleTokens:p}=m;if(Array.isArray(p)){const O=P.find(Y=>p.includes(Y.token)||Y.token===l);if(O)throw new RangeError(`The format string mustn't contain \`${O.fullToken}\` and \`${i}\` at the same time`)}else if(m.incompatibleTokens==="*"&&P.length>0)throw new RangeError(`The format string mustn't contain \`${i}\` and any other token at the same time`);P.push({token:l,fullToken:i});const x=m.run(n,i,u.match,k);if(!x)return s();E.push(x.setter),n=x.rest}else{if(l.match($e))throw new RangeError("Format string contains an unescaped latin alphabet character `"+l+"`");if(i==="''"?i="'":l==="'"&&(i=Ke(i)),n.indexOf(i)===0)n=n.slice(i.length);else return s()}}if(n.length>0&&ze.test(n))return s();const I=E.map(i=>i.priority).sort((i,l)=>l-i).filter((i,l,m)=>m.indexOf(i)===l).map(i=>E.filter(l=>l.priority===i).sort((l,m)=>m.subPriority-l.subPriority)).map(i=>i[0]);let M=a.toDate(r,t?.in);if(isNaN(+M))return s();const R={};for(const i of I){if(!i.validate(M,k))return s();const l=i.set(M,R,k);Array.isArray(l)?(M=l[0],Object.assign(R,l[1])):M=l}return M}function Ke(n){return n.match(Xe)[1].replace(Ae,"'")}const Ze={"purpur-date-field__container":"_purpur-date-field__container_ci2f4_1","purpur-date-field__overlay":"_purpur-date-field__overlay_ci2f4_5","purpur-date-field__start-adornment":"_purpur-date-field__start-adornment_ci2f4_16"},Ve=n=>je(n,"yyyy-MM-dd",new Date),X=n=>n?a.format(n,"yyyy-MM-dd"):"",Ue=(...n)=>{const e=n.filter(Boolean);return e.length<=1?e[0]||null:r=>{for(const t of e)typeof t=="function"?t(r):t&&(t.current=r)}},Q=V.c.bind(Ze),C="purpur-date-field",F="YYYY-MM-DD",Je=(n,e)=>{let r=n;return e.length>4&&n>=4&&(r+=1),e.length>7&&n>=6&&(r+=1),Math.min(r,e.length)},K=T.forwardRef(({value:n,label:e,onChange:r,startAdornment:t,...s},o)=>{const[u,b]=T.useState(X(n));T.useEffect(()=>{b(n?X(n):"")},[n]);const y=T.useRef(null),k=Ue(o,y),[E,v]=T.useState({}),P=T.useRef(null),I=T.useRef(null),M=()=>{if(y.current){const p=window.document.querySelector(`label[for="${y.current.id}"]`),x=p?p.offsetHeight+4:0,O=window.getComputedStyle(y.current);v({position:"absolute",top:y.current.offsetTop+x,left:y.current.offsetLeft,padding:O.padding,width:y.current.offsetWidth,height:y.current.offsetHeight})}};T.useLayoutEffect(()=>{M()},[u,e,y]),T.useEffect(()=>{if(!y.current)return;const p=new ResizeObserver(()=>{M()});return p.observe(y.current),()=>p.disconnect()},[]),T.useLayoutEffect(()=>{P.current!==null&&y.current&&(y.current.setSelectionRange(P.current,P.current),P.current=null)},[u]);const R=p=>{if(p.length===0&&r?.(void 0),p.length!==F.length)return;const x=Ve(p);a.isValid(x)&&r?.(x)},i=p=>{const x=p.currentTarget.selectionStart??0;I.current=u.slice(0,x).replace(/\D/g,"").length},l=p=>{const x=p.target.value,O=p.target.selectionStart??0,Y=u.replace(/\D/g,""),g=x.replace(/\D/g,"");let H="";g.length>0&&(H+=g.slice(0,4)),g.length>4&&(H+="-"+g.slice(4,6)),g.length>6&&(H+="-"+g.slice(6,8));let N;const G=I.current;G!==null&&g.length>Y.length?N=Math.min(G+(g.length-Y.length),g.length):N=Math.min(x.slice(0,O).replace(/\D/g,"").length,g.length),I.current=null,P.current=Je(N,H),b(H),R(H)},m=()=>F.split("").map((x,O)=>{const Y=u[O];return q.jsx("span",{style:{color:Y?"transparent":"var(--purpur-color-text-weak)"},children:Y||x},O)});return q.jsxs("div",{className:Q(`${C}__container`),children:[q.jsx(Z.TextField,{...s,startAdornment:t&&q.jsx("span",{className:Q(`${C}__start-adornment`),children:t}),ref:k,value:u,onChange:l,onKeyDown:i,type:"text",maxLength:F.length,inputMode:"numeric",label:e}),q.jsx("div",{role:"presentation",style:E,className:Q(`${C}__overlay`),children:m()})]})});K.displayName="DateField";exports.DateField=K;
|
|
2
|
-
//# sourceMappingURL=date-field-
|
|
1
|
+
"use strict";const q=require("react/jsx-runtime"),T=require("react"),Z=require("./text-field-C2W13n15.js"),V=require("./bind-DeUYJ6m9.js"),a=require("./format-CFKKBdIQ.js");function U(){return Object.assign({},a.getDefaultOptions())}function J(n,e){const r=a.toDate(n,e?.in).getDay();return r===0?7:r}function S(n,e){const r=ee(e)?new e(0):a.constructFrom(e,0);return r.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),r.setHours(n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),r}function ee(n){return typeof n=="function"&&n.prototype?.constructor===n}const te=10;class A{subPriority=0;validate(e,r){return!0}}class re extends A{constructor(e,r,t,s,o){super(),this.value=e,this.validateValue=r,this.setValue=t,this.priority=s,o&&(this.subPriority=o)}validate(e,r){return this.validateValue(e,this.value,r)}set(e,r,t){return this.setValue(e,r,this.value,t)}}class ne extends A{priority=te;subPriority=-1;constructor(e,r){super(),this.context=e||(t=>a.constructFrom(r,t))}set(e,r){return r.timestampIsSet?e:a.constructFrom(e,S(e,this.context))}}class c{run(e,r,t,s){const o=this.parse(e,r,t,s);return o?{setter:new re(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(e,r,t){return!0}}class se extends c{priority=140;parse(e,r,t){switch(r){case"G":case"GG":case"GGG":return t.era(e,{width:"abbreviated"})||t.era(e,{width:"narrow"});case"GGGGG":return t.era(e,{width:"narrow"});default:return t.era(e,{width:"wide"})||t.era(e,{width:"abbreviated"})||t.era(e,{width:"narrow"})}}set(e,r,t){return r.era=t,e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["R","u","t","T"]}const w={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},D={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function h(n,e){return n&&{value:e(n.value),rest:n.rest}}function d(n,e){const r=e.match(n);return r?{value:parseInt(r[0],10),rest:e.slice(r[0].length)}:null}function _(n,e){const r=e.match(n);if(!r)return null;if(r[0]==="Z")return{value:0,rest:e.slice(1)};const t=r[1]==="+"?1:-1,s=r[2]?parseInt(r[2],10):0,o=r[3]?parseInt(r[3],10):0,u=r[5]?parseInt(r[5],10):0;return{value:t*(s*a.millisecondsInHour+o*a.millisecondsInMinute+u*a.millisecondsInSecond),rest:e.slice(r[0].length)}}function z(n){return d(w.anyDigitsSigned,n)}function f(n,e){switch(n){case 1:return d(w.singleDigit,e);case 2:return d(w.twoDigits,e);case 3:return d(w.threeDigits,e);case 4:return d(w.fourDigits,e);default:return d(new RegExp("^\\d{1,"+n+"}"),e)}}function L(n,e){switch(n){case 1:return d(w.singleDigitSigned,e);case 2:return d(w.twoDigitsSigned,e);case 3:return d(w.threeDigitsSigned,e);case 4:return d(w.fourDigitsSigned,e);default:return d(new RegExp("^-?\\d{1,"+n+"}"),e)}}function W(n){switch(n){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;default:return 0}}function $(n,e){const r=e>0,t=r?e:1-e;let s;if(t<=50)s=n||100;else{const o=t+50,u=Math.trunc(o/100)*100,b=n>=o%100;s=n+u-(b?100:0)}return r?s:1-s}function j(n){return n%400===0||n%4===0&&n%100!==0}class oe extends c{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,r,t){const s=o=>({year:o,isTwoDigitYear:r==="yy"});switch(r){case"y":return h(f(4,e),s);case"yo":return h(t.ordinalNumber(e,{unit:"year"}),s);default:return h(f(r.length,e),s)}}validate(e,r){return r.isTwoDigitYear||r.year>0}set(e,r,t){const s=e.getFullYear();if(t.isTwoDigitYear){const u=$(t.year,s);return e.setFullYear(u,0,1),e.setHours(0,0,0,0),e}const o=!("era"in r)||r.era===1?t.year:1-t.year;return e.setFullYear(o,0,1),e.setHours(0,0,0,0),e}}class ae extends c{priority=130;parse(e,r,t){const s=o=>({year:o,isTwoDigitYear:r==="YY"});switch(r){case"Y":return h(f(4,e),s);case"Yo":return h(t.ordinalNumber(e,{unit:"year"}),s);default:return h(f(r.length,e),s)}}validate(e,r){return r.isTwoDigitYear||r.year>0}set(e,r,t,s){const o=a.getWeekYear(e,s);if(t.isTwoDigitYear){const b=$(t.year,o);return e.setFullYear(b,0,s.firstWeekContainsDate),e.setHours(0,0,0,0),a.startOfWeek(e,s)}const u=!("era"in r)||r.era===1?t.year:1-t.year;return e.setFullYear(u,0,s.firstWeekContainsDate),e.setHours(0,0,0,0),a.startOfWeek(e,s)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]}class ie extends c{priority=130;parse(e,r){return L(r==="R"?4:r.length,e)}set(e,r,t){const s=a.constructFrom(e,0);return s.setFullYear(t,0,4),s.setHours(0,0,0,0),a.startOfISOWeek(s)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]}class ce extends c{priority=130;parse(e,r){return L(r==="u"?4:r.length,e)}set(e,r,t){return e.setFullYear(t,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]}class ue extends c{priority=120;parse(e,r,t){switch(r){case"Q":case"QQ":return f(r.length,e);case"Qo":return t.ordinalNumber(e,{unit:"quarter"});case"QQQ":return t.quarter(e,{width:"abbreviated",context:"formatting"})||t.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return t.quarter(e,{width:"narrow",context:"formatting"});default:return t.quarter(e,{width:"wide",context:"formatting"})||t.quarter(e,{width:"abbreviated",context:"formatting"})||t.quarter(e,{width:"narrow",context:"formatting"})}}validate(e,r){return r>=1&&r<=4}set(e,r,t){return e.setMonth((t-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]}class le extends c{priority=120;parse(e,r,t){switch(r){case"q":case"qq":return f(r.length,e);case"qo":return t.ordinalNumber(e,{unit:"quarter"});case"qqq":return t.quarter(e,{width:"abbreviated",context:"standalone"})||t.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return t.quarter(e,{width:"narrow",context:"standalone"});default:return t.quarter(e,{width:"wide",context:"standalone"})||t.quarter(e,{width:"abbreviated",context:"standalone"})||t.quarter(e,{width:"narrow",context:"standalone"})}}validate(e,r){return r>=1&&r<=4}set(e,r,t){return e.setMonth((t-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]}class de extends c{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,r,t){const s=o=>o-1;switch(r){case"M":return h(d(w.month,e),s);case"MM":return h(f(2,e),s);case"Mo":return h(t.ordinalNumber(e,{unit:"month"}),s);case"MMM":return t.month(e,{width:"abbreviated",context:"formatting"})||t.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return t.month(e,{width:"narrow",context:"formatting"});default:return t.month(e,{width:"wide",context:"formatting"})||t.month(e,{width:"abbreviated",context:"formatting"})||t.month(e,{width:"narrow",context:"formatting"})}}validate(e,r){return r>=0&&r<=11}set(e,r,t){return e.setMonth(t,1),e.setHours(0,0,0,0),e}}class fe extends c{priority=110;parse(e,r,t){const s=o=>o-1;switch(r){case"L":return h(d(w.month,e),s);case"LL":return h(f(2,e),s);case"Lo":return h(t.ordinalNumber(e,{unit:"month"}),s);case"LLL":return t.month(e,{width:"abbreviated",context:"standalone"})||t.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return t.month(e,{width:"narrow",context:"standalone"});default:return t.month(e,{width:"wide",context:"standalone"})||t.month(e,{width:"abbreviated",context:"standalone"})||t.month(e,{width:"narrow",context:"standalone"})}}validate(e,r){return r>=0&&r<=11}set(e,r,t){return e.setMonth(t,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]}function we(n,e,r){const t=a.toDate(n,r?.in),s=a.getWeek(t,r)-e;return t.setDate(t.getDate()-s*7),a.toDate(t,r?.in)}class he extends c{priority=100;parse(e,r,t){switch(r){case"w":return d(w.week,e);case"wo":return t.ordinalNumber(e,{unit:"week"});default:return f(r.length,e)}}validate(e,r){return r>=1&&r<=53}set(e,r,t,s){return a.startOfWeek(we(e,t,s),s)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]}function pe(n,e,r){const t=a.toDate(n,r?.in),s=a.getISOWeek(t,r)-e;return t.setDate(t.getDate()-s*7),t}class ye extends c{priority=100;parse(e,r,t){switch(r){case"I":return d(w.week,e);case"Io":return t.ordinalNumber(e,{unit:"week"});default:return f(r.length,e)}}validate(e,r){return r>=1&&r<=53}set(e,r,t){return a.startOfISOWeek(pe(e,t))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]}const xe=[31,28,31,30,31,30,31,31,30,31,30,31],be=[31,29,31,30,31,30,31,31,30,31,30,31];class me extends c{priority=90;subPriority=1;parse(e,r,t){switch(r){case"d":return d(w.date,e);case"do":return t.ordinalNumber(e,{unit:"date"});default:return f(r.length,e)}}validate(e,r){const t=e.getFullYear(),s=j(t),o=e.getMonth();return s?r>=1&&r<=be[o]:r>=1&&r<=xe[o]}set(e,r,t){return e.setDate(t),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]}class ge extends c{priority=90;subpriority=1;parse(e,r,t){switch(r){case"D":case"DD":return d(w.dayOfYear,e);case"Do":return t.ordinalNumber(e,{unit:"date"});default:return f(r.length,e)}}validate(e,r){const t=e.getFullYear();return j(t)?r>=1&&r<=366:r>=1&&r<=365}set(e,r,t){return e.setMonth(0,t),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]}function B(n,e,r){const t=a.getDefaultOptions(),s=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??t.weekStartsOn??t.locale?.options?.weekStartsOn??0,o=a.toDate(n,r?.in),u=o.getDay(),y=(e%7+7)%7,k=7-s,E=e<0||e>6?e-(u+k)%7:(y+k)%7-(u+k)%7;return a.addDays(o,E,r)}class Te extends c{priority=90;parse(e,r,t){switch(r){case"E":case"EE":case"EEE":return t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return t.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"});default:return t.day(e,{width:"wide",context:"formatting"})||t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"})}}validate(e,r){return r>=0&&r<=6}set(e,r,t,s){return e=B(e,t,s),e.setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]}class De extends c{priority=90;parse(e,r,t,s){const o=u=>{const b=Math.floor((u-1)/7)*7;return(u+s.weekStartsOn+6)%7+b};switch(r){case"e":case"ee":return h(f(r.length,e),o);case"eo":return h(t.ordinalNumber(e,{unit:"day"}),o);case"eee":return t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"});case"eeeee":return t.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"});default:return t.day(e,{width:"wide",context:"formatting"})||t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"})}}validate(e,r){return r>=0&&r<=6}set(e,r,t,s){return e=B(e,t,s),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]}class _e extends c{priority=90;parse(e,r,t,s){const o=u=>{const b=Math.floor((u-1)/7)*7;return(u+s.weekStartsOn+6)%7+b};switch(r){case"c":case"cc":return h(f(r.length,e),o);case"co":return h(t.ordinalNumber(e,{unit:"day"}),o);case"ccc":return t.day(e,{width:"abbreviated",context:"standalone"})||t.day(e,{width:"short",context:"standalone"})||t.day(e,{width:"narrow",context:"standalone"});case"ccccc":return t.day(e,{width:"narrow",context:"standalone"});case"cccccc":return t.day(e,{width:"short",context:"standalone"})||t.day(e,{width:"narrow",context:"standalone"});default:return t.day(e,{width:"wide",context:"standalone"})||t.day(e,{width:"abbreviated",context:"standalone"})||t.day(e,{width:"short",context:"standalone"})||t.day(e,{width:"narrow",context:"standalone"})}}validate(e,r){return r>=0&&r<=6}set(e,r,t,s){return e=B(e,t,s),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]}function ke(n,e,r){const t=a.toDate(n,r?.in),s=J(t,r),o=e-s;return a.addDays(t,o,r)}class Pe extends c{priority=90;parse(e,r,t){const s=o=>o===0?7:o;switch(r){case"i":case"ii":return f(r.length,e);case"io":return t.ordinalNumber(e,{unit:"day"});case"iii":return h(t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"}),s);case"iiiii":return h(t.day(e,{width:"narrow",context:"formatting"}),s);case"iiiiii":return h(t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"}),s);default:return h(t.day(e,{width:"wide",context:"formatting"})||t.day(e,{width:"abbreviated",context:"formatting"})||t.day(e,{width:"short",context:"formatting"})||t.day(e,{width:"narrow",context:"formatting"}),s)}}validate(e,r){return r>=1&&r<=7}set(e,r,t){return e=ke(e,t),e.setHours(0,0,0,0),e}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]}class Me extends c{priority=80;parse(e,r,t){switch(r){case"a":case"aa":case"aaa":return t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return t.dayPeriod(e,{width:"narrow",context:"formatting"});default:return t.dayPeriod(e,{width:"wide",context:"formatting"})||t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,r,t){return e.setHours(W(t),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]}class Oe extends c{priority=80;parse(e,r,t){switch(r){case"b":case"bb":case"bbb":return t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return t.dayPeriod(e,{width:"narrow",context:"formatting"});default:return t.dayPeriod(e,{width:"wide",context:"formatting"})||t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,r,t){return e.setHours(W(t),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]}class Ye extends c{priority=80;parse(e,r,t){switch(r){case"B":case"BB":case"BBB":return t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return t.dayPeriod(e,{width:"narrow",context:"formatting"});default:return t.dayPeriod(e,{width:"wide",context:"formatting"})||t.dayPeriod(e,{width:"abbreviated",context:"formatting"})||t.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,r,t){return e.setHours(W(t),0,0,0),e}incompatibleTokens=["a","b","t","T"]}class Ee extends c{priority=70;parse(e,r,t){switch(r){case"h":return d(w.hour12h,e);case"ho":return t.ordinalNumber(e,{unit:"hour"});default:return f(r.length,e)}}validate(e,r){return r>=1&&r<=12}set(e,r,t){const s=e.getHours()>=12;return s&&t<12?e.setHours(t+12,0,0,0):!s&&t===12?e.setHours(0,0,0,0):e.setHours(t,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]}class He extends c{priority=70;parse(e,r,t){switch(r){case"H":return d(w.hour23h,e);case"Ho":return t.ordinalNumber(e,{unit:"hour"});default:return f(r.length,e)}}validate(e,r){return r>=0&&r<=23}set(e,r,t){return e.setHours(t,0,0,0),e}incompatibleTokens=["a","b","h","K","k","t","T"]}class Ie extends c{priority=70;parse(e,r,t){switch(r){case"K":return d(w.hour11h,e);case"Ko":return t.ordinalNumber(e,{unit:"hour"});default:return f(r.length,e)}}validate(e,r){return r>=0&&r<=11}set(e,r,t){return e.getHours()>=12&&t<12?e.setHours(t+12,0,0,0):e.setHours(t,0,0,0),e}incompatibleTokens=["h","H","k","t","T"]}class qe extends c{priority=70;parse(e,r,t){switch(r){case"k":return d(w.hour24h,e);case"ko":return t.ordinalNumber(e,{unit:"hour"});default:return f(r.length,e)}}validate(e,r){return r>=1&&r<=24}set(e,r,t){const s=t<=24?t%24:t;return e.setHours(s,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]}class Re extends c{priority=60;parse(e,r,t){switch(r){case"m":return d(w.minute,e);case"mo":return t.ordinalNumber(e,{unit:"minute"});default:return f(r.length,e)}}validate(e,r){return r>=0&&r<=59}set(e,r,t){return e.setMinutes(t,0,0),e}incompatibleTokens=["t","T"]}class Le extends c{priority=50;parse(e,r,t){switch(r){case"s":return d(w.second,e);case"so":return t.ordinalNumber(e,{unit:"second"});default:return f(r.length,e)}}validate(e,r){return r>=0&&r<=59}set(e,r,t){return e.setSeconds(t,0),e}incompatibleTokens=["t","T"]}class ve extends c{priority=30;parse(e,r){const t=s=>Math.trunc(s*Math.pow(10,-r.length+3));return h(f(r.length,e),t)}set(e,r,t){return e.setMilliseconds(t),e}incompatibleTokens=["t","T"]}class Ne extends c{priority=10;parse(e,r){switch(r){case"X":return _(D.basicOptionalMinutes,e);case"XX":return _(D.basic,e);case"XXXX":return _(D.basicOptionalSeconds,e);case"XXXXX":return _(D.extendedOptionalSeconds,e);default:return _(D.extended,e)}}set(e,r,t){return r.timestampIsSet?e:a.constructFrom(e,e.getTime()-a.getTimezoneOffsetInMilliseconds(e)-t)}incompatibleTokens=["t","T","x"]}class Qe extends c{priority=10;parse(e,r){switch(r){case"x":return _(D.basicOptionalMinutes,e);case"xx":return _(D.basic,e);case"xxxx":return _(D.basicOptionalSeconds,e);case"xxxxx":return _(D.extendedOptionalSeconds,e);default:return _(D.extended,e)}}set(e,r,t){return r.timestampIsSet?e:a.constructFrom(e,e.getTime()-a.getTimezoneOffsetInMilliseconds(e)-t)}incompatibleTokens=["t","T","X"]}class Ce extends c{priority=40;parse(e){return z(e)}set(e,r,t){return[a.constructFrom(e,t*1e3),{timestampIsSet:!0}]}incompatibleTokens="*"}class Fe extends c{priority=20;parse(e){return z(e)}set(e,r,t){return[a.constructFrom(e,t),{timestampIsSet:!0}]}incompatibleTokens="*"}const We={G:new se,y:new oe,Y:new ae,R:new ie,u:new ce,Q:new ue,q:new le,M:new de,L:new fe,w:new he,I:new ye,d:new me,D:new ge,E:new Te,e:new De,c:new _e,i:new Pe,a:new Me,b:new Oe,B:new Ye,h:new Ee,H:new He,K:new Ie,k:new qe,m:new Re,s:new Le,S:new ve,X:new Ne,x:new Qe,t:new Ce,T:new Fe},Be=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ge=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Xe=/^'([^]*?)'?$/,Ae=/''/g,ze=/\S/,$e=/[a-zA-Z]/;function je(n,e,r,t){const s=()=>a.constructFrom(r,NaN),o=U(),u=o.locale??a.enUS,b=o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,y=o.weekStartsOn??o.locale?.options?.weekStartsOn??0,k={firstWeekContainsDate:b,weekStartsOn:y,locale:u},E=[new ne(t?.in,r)],v=e.match(Ge).map(i=>{const l=i[0];if(l in a.longFormatters){const m=a.longFormatters[l];return m(i,u.formatLong)}return i}).join("").match(Be),P=[];for(let i of v){a.isProtectedWeekYearToken(i)&&a.warnOrThrowProtectedError(i,e,n),a.isProtectedDayOfYearToken(i)&&a.warnOrThrowProtectedError(i,e,n);const l=i[0],m=We[l];if(m){const{incompatibleTokens:p}=m;if(Array.isArray(p)){const O=P.find(Y=>p.includes(Y.token)||Y.token===l);if(O)throw new RangeError(`The format string mustn't contain \`${O.fullToken}\` and \`${i}\` at the same time`)}else if(m.incompatibleTokens==="*"&&P.length>0)throw new RangeError(`The format string mustn't contain \`${i}\` and any other token at the same time`);P.push({token:l,fullToken:i});const x=m.run(n,i,u.match,k);if(!x)return s();E.push(x.setter),n=x.rest}else{if(l.match($e))throw new RangeError("Format string contains an unescaped latin alphabet character `"+l+"`");if(i==="''"?i="'":l==="'"&&(i=Ke(i)),n.indexOf(i)===0)n=n.slice(i.length);else return s()}}if(n.length>0&&ze.test(n))return s();const I=E.map(i=>i.priority).sort((i,l)=>l-i).filter((i,l,m)=>m.indexOf(i)===l).map(i=>E.filter(l=>l.priority===i).sort((l,m)=>m.subPriority-l.subPriority)).map(i=>i[0]);let M=a.toDate(r,t?.in);if(isNaN(+M))return s();const R={};for(const i of I){if(!i.validate(M,k))return s();const l=i.set(M,R,k);Array.isArray(l)?(M=l[0],Object.assign(R,l[1])):M=l}return M}function Ke(n){return n.match(Xe)[1].replace(Ae,"'")}const Ze={"purpur-date-field__container":"_purpur-date-field__container_ci2f4_1","purpur-date-field__overlay":"_purpur-date-field__overlay_ci2f4_5","purpur-date-field__start-adornment":"_purpur-date-field__start-adornment_ci2f4_16"},Ve=n=>je(n,"yyyy-MM-dd",new Date),X=n=>n?a.format(n,"yyyy-MM-dd"):"",Ue=(...n)=>{const e=n.filter(Boolean);return e.length<=1?e[0]||null:r=>{for(const t of e)typeof t=="function"?t(r):t&&(t.current=r)}},Q=V.c.bind(Ze),C="purpur-date-field",F="YYYY-MM-DD",Je=(n,e)=>{let r=n;return e.length>4&&n>=4&&(r+=1),e.length>7&&n>=6&&(r+=1),Math.min(r,e.length)},K=T.forwardRef(({value:n,label:e,onChange:r,startAdornment:t,...s},o)=>{const[u,b]=T.useState(X(n));T.useEffect(()=>{b(n?X(n):"")},[n]);const y=T.useRef(null),k=Ue(o,y),[E,v]=T.useState({}),P=T.useRef(null),I=T.useRef(null),M=()=>{if(y.current){const p=window.document.querySelector(`label[for="${y.current.id}"]`),x=p?p.offsetHeight+4:0,O=window.getComputedStyle(y.current);v({position:"absolute",top:y.current.offsetTop+x,left:y.current.offsetLeft,padding:O.padding,width:y.current.offsetWidth,height:y.current.offsetHeight})}};T.useLayoutEffect(()=>{M()},[u,e,y]),T.useEffect(()=>{if(!y.current)return;const p=new ResizeObserver(()=>{M()});return p.observe(y.current),()=>p.disconnect()},[]),T.useLayoutEffect(()=>{P.current!==null&&y.current&&(y.current.setSelectionRange(P.current,P.current),P.current=null)},[u]);const R=p=>{if(p.length===0&&r?.(void 0),p.length!==F.length)return;const x=Ve(p);a.isValid(x)&&r?.(x)},i=p=>{const x=p.currentTarget.selectionStart??0;I.current=u.slice(0,x).replace(/\D/g,"").length},l=p=>{const x=p.target.value,O=p.target.selectionStart??0,Y=u.replace(/\D/g,""),g=x.replace(/\D/g,"");let H="";g.length>0&&(H+=g.slice(0,4)),g.length>4&&(H+="-"+g.slice(4,6)),g.length>6&&(H+="-"+g.slice(6,8));let N;const G=I.current;G!==null&&g.length>Y.length?N=Math.min(G+(g.length-Y.length),g.length):N=Math.min(x.slice(0,O).replace(/\D/g,"").length,g.length),I.current=null,P.current=Je(N,H),b(H),R(H)},m=()=>F.split("").map((x,O)=>{const Y=u[O];return q.jsx("span",{style:{color:Y?"transparent":"var(--purpur-color-text-weak)"},children:Y||x},O)});return q.jsxs("div",{className:Q(`${C}__container`),children:[q.jsx(Z.TextField,{...s,startAdornment:t&&q.jsx("span",{className:Q(`${C}__start-adornment`),children:t}),ref:k,value:u,onChange:l,onKeyDown:i,type:"text",maxLength:F.length,inputMode:"numeric",label:e}),q.jsx("div",{role:"presentation",style:E,className:Q(`${C}__overlay`),children:m()})]})});K.displayName="DateField";exports.DateField=K;
|
|
2
|
+
//# sourceMappingURL=date-field-CKxEWHG3.js.map
|