@economic/taco 2.39.2 → 2.40.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/OverflowGroup/OverflowGroup.d.ts +0 -1
- package/dist/components/Table/hooks/useRowCreation.d.ts +4 -4
- package/dist/components/Table/types.d.ts +19 -19
- package/dist/components/Tabs/Tabs.d.ts +0 -5
- package/dist/esm/packages/taco/src/components/Alert/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Badge/Badge.js.map +1 -1
- package/dist/esm/packages/taco/src/components/BadgeIcon/BadgeIcon.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Banner/Banner.js +1 -1
- package/dist/esm/packages/taco/src/components/Banner/Banner.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Calendar/Calendar.js +4 -4
- package/dist/esm/packages/taco/src/components/Calendar/Calendar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js +2 -2
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +2 -2
- package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Combobox/Combobox.js +2 -2
- package/dist/esm/packages/taco/src/components/Combobox/Combobox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js +6 -6
- package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js +2 -2
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Drawer/Drawer.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +5 -5
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Field/Field.js +1 -1
- package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Hanger/Hanger.js +1 -1
- package/dist/esm/packages/taco/src/components/Hanger/Hanger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/Agreement/Display.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/Agreement/Item.js +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/Agreement/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +2 -2
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/Link.js +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/Link.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Icon/Icon.js +1 -1
- package/dist/esm/packages/taco/src/components/Icon/Icon.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Input/Input.js +1 -1
- package/dist/esm/packages/taco/src/components/Input/Input.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js +1 -1
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/List/components/Item.js +1 -1
- package/dist/esm/packages/taco/src/components/List/components/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js +4 -4
- package/dist/esm/packages/taco/src/components/Listbox/ScrollableList.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/useMultiListbox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js +2 -2
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Navigation/Navigation.js +1 -1
- package/dist/esm/packages/taco/src/components/Navigation/Navigation.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js +2 -2
- package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js +1 -1
- package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js.map +1 -1
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js +1 -4
- package/dist/esm/packages/taco/src/components/OverflowGroup/OverflowGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Pagination/PageNumbers.js +1 -1
- package/dist/esm/packages/taco/src/components/Pagination/PageNumbers.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Pagination/Pagination.js +3 -3
- package/dist/esm/packages/taco/src/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Popover/Popover.js +2 -2
- package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Progress/Progress.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js +1 -1
- package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +5 -5
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select/Select.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select/useSelect.js +1 -1
- package/dist/esm/packages/taco/src/components/Select/useSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +7 -7
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Create.js +2 -2
- package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +5 -5
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +4 -4
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +5 -5
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js +1 -1
- package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/components/BaseTable.js +2 -2
- package/dist/esm/packages/taco/src/components/Table/components/BaseTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/components/PaginatedTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/components/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js +1 -1
- package/dist/esm/packages/taco/src/components/Table/components/WindowedTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +8 -8
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/useRowCreation.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/util/renderColumn.js +1 -1
- package/dist/esm/packages/taco/src/components/Table/util/renderColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/util/renderRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/util/rowIndexPath.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +3 -3
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/RowMoveIndicator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/TextareaWithAutosizing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/SaveStatus.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tabs/Tabs.js +2 -11
- package/dist/esm/packages/taco/src/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tag/Tag.js +3 -3
- package/dist/esm/packages/taco/src/components/Tag/Tag.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Toast/Toaster.js +1 -1
- package/dist/esm/packages/taco/src/components/Toast/Toaster.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Toast/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tour/Tour.js +2 -2
- package/dist/esm/packages/taco/src/components/Tour/Tour.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Treeview/Treeview.js +1 -1
- package/dist/esm/packages/taco/src/components/Treeview/Treeview.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useIntersectionObserver.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/BubbleSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +4 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/Header.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Goto.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +9 -9
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/Filters.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/util.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/util.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/PrintDialog.js +4 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/PrintDialog.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.js +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.js +6 -6
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Settings/Settings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleColumnFreezing.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleGrid.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTablePrinting.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSettings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/date.js +1 -1
- package/dist/esm/packages/taco/src/utils/date.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/taco.cjs.development.js +160 -170
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AgreementSelector.js","sources":["../../../../../../../../src/components/Header/components/AgreementSelector.tsx"],"sourcesContent":["import React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as CollectionPrimitive from '../../../primitives/Collection/Collection';\nimport { AgreementItem } from './Agreement/Item';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Icon } from '../../Icon/Icon';\nimport { SearchInput } from '../../SearchInput/SearchInput';\nimport { Button } from '../../Button/Button';\nimport { useLocalization } from '../../Provider/Localization';\nimport { Agreement } from './Agreement/types';\nimport { AgreementDisplay as Display } from './Agreement/Display';\n\nconst Container = props => {\n return (\n <div\n className=\"-ml-2 flex flex-shrink-0 flex-grow-0 items-center gap-2 pr-2 xl:ml-auto xl:w-64\"\n data-taco=\"header-agreements\">\n <span className=\"hidden h-8 w-px flex-shrink-0 flex-grow-0 bg-white/[0.3] xl:flex\" />\n {props.children}\n </div>\n );\n};\n\nexport type AgreementSelectorProps = {\n agreements: Agreement[];\n currentAgreement: Agreement;\n fallbackImageSrc: string;\n filterAgreement: (agreement: Agreement, filter: (agreement: Agreement) => boolean) => void;\n filterClientAgreement: (agreement: Agreement, searchValue: string, filter: (agreement: Agreement) => boolean) => void;\n onAddAgreement?: () => void;\n onChangeAgreement: (agreement: Agreement) => void;\n onLogout: () => void;\n open?: boolean;\n setOpen?: (open: boolean) => void;\n};\n\nexport function AgreementSelector(props: AgreementSelectorProps) {\n const {\n agreements,\n currentAgreement,\n fallbackImageSrc,\n filterAgreement = () => true,\n filterClientAgreement = () => true,\n onAddAgreement: handleAddAgreement,\n onChangeAgreement,\n onLogout: handleLogout,\n open: prop,\n setOpen: onChange,\n } = props;\n const { texts } = useLocalization();\n const collectionRef = React.useRef<CollectionPrimitive.CollectionRef | null>(null);\n const [open, setOpen] = useControllableState<boolean>({\n onChange,\n prop,\n });\n const [search, setSearch] = React.useState('');\n\n React.useEffect(() => {\n setSearch('');\n }, [open]);\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter') {\n event.preventDefault();\n collectionRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n };\n\n const handleChangeAgreement = (agreement: Agreement) => {\n onChangeAgreement(agreement);\n setOpen(false);\n };\n\n return (\n <Container>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PopoverPrimitive.Trigger className=\"xl:focus-visible:yt-focus-dark [&:focus-visible_img]:yt-focus-dark w-full rounded outline-none xl:[&:focus-visible_img]:shadow-none\">\n <Display currentAgreement={currentAgreement} fallbackImageSrc={fallbackImageSrc}>\n {agreements ? (\n <Icon\n className=\"ml-auto hidden flex-shrink-0 flex-grow-0 text-white xl:flex\"\n name={open ? 'chevron-up' : 'chevron-down'}\n />\n ) : null}\n </Display>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Content className=\"z-[996] mt-2 flex h-[calc(100vh_-_theme(spacing.16))] w-64 flex-col gap-1 bg-blue-900\">\n <SearchInput\n autoFocus\n className=\"focus-visible:!yt-focus-dark mx-2 !border-transparent !bg-white/[0.08] !text-white hover:!bg-white/[0.16] hover:!shadow-none focus:!bg-white/[0.16] active:!bg-white/[0.16] [&+div>button]:!text-white\"\n onChange={event => setSearch(event.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={texts.header.search}\n />\n <CollectionPrimitive.Root\n querySelector=\"button\"\n className=\"-my-1 flex w-full flex-grow flex-col gap-1 overflow-auto px-2 py-1 outline-none\"\n ref={collectionRef}\n tabIndex={-1}>\n {agreements\n ?.filter(agreement => filterAgreement(agreement, filterBySearchValue(search)))\n .map(agreement => {\n const button = createAgreementButton(\n agreement,\n fallbackImageSrc,\n handleChangeAgreement,\n isCurrentAgreement(agreement, currentAgreement)\n );\n\n if (agreement.clients) {\n return (\n <span\n className=\"flex flex-col gap-px [&>*:first-child>span]:!rounded-t [&>*:last-child>span]:!rounded-b [&>*>span]:!rounded-none\"\n key={`${agreement.number}_${agreement.userId}_clients`}>\n {filterBySearchValue(search)(agreement) ? button : null}\n {agreement.clients\n .filter(agreement =>\n filterClientAgreement(agreement, search, filterBySearchValue(search))\n )\n .map(clientAgreement =>\n createAgreementButton(\n clientAgreement,\n fallbackImageSrc,\n handleChangeAgreement,\n isCurrentAgreement(clientAgreement, currentAgreement)\n )\n )}\n </span>\n );\n }\n\n return button;\n })}\n </CollectionPrimitive.Root>\n {handleAddAgreement ? (\n <Button\n className=\"focus-visible:!yt-focus-dark my-1 mx-2 !h-9 shrink-0 !bg-white/[0.08] !text-white hover:!bg-white/[0.16]\"\n onClick={handleAddAgreement}>\n {texts.header.addAgreement}\n </Button>\n ) : null}\n <hr className=\"my-0 h-px w-full bg-white/[0.08]\" />\n <a\n className=\"focus-visible:yt-focus-dark mx-2 mb-2 flex h-8 shrink-0 items-center justify-center rounded text-white hover:cursor-pointer hover:text-white hover:underline focus-visible:outline-none\"\n onClick={handleLogout}\n tabIndex={0}>\n {texts.header.logout}\n </a>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Root>\n </Container>\n );\n}\n\nconst filterBySearchValue = (search: string) => (agreement: Agreement) => {\n if (!search || !search.length) {\n return true;\n }\n\n const matchesAgreementNumber = String(agreement.number).indexOf(search) > -1;\n const matchesCompanyName = agreement.name.toLowerCase().indexOf(search.toLowerCase()) > -1;\n\n return matchesAgreementNumber || matchesCompanyName;\n};\n\nconst isCurrentAgreement = (agreement: Agreement, currentAgreement: Agreement) => {\n return agreement.number === currentAgreement.number && agreement.userId === currentAgreement.userId;\n};\n\nconst createAgreementButton = (\n agreement: Agreement,\n fallbackImageSrc: string,\n onChangeAgreement: (agreement: Agreement) => void,\n isCurrentAgreement = false\n) => {\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === 'Enter') {\n onChangeAgreement(agreement);\n }\n };\n\n return (\n <button\n aria-current={isCurrentAgreement ? 'true' : undefined}\n className=\"focus:yt-focus-dark w-full rounded outline-none\"\n data-taco=\"header-agreements-agreement\"\n key={`${agreement.number}_${agreement.userId}`}\n onClick={() => onChangeAgreement(agreement)}\n onKeyDown={handleKeyDown}\n tabIndex={0}>\n <AgreementItem\n {...agreement}\n className=\"h-14 bg-white/[0.08] xl:hover:bg-white/[0.16] [[aria-current='true']>&]:bg-white/[0.16]\"\n fallbackImageSrc={fallbackImageSrc}\n />\n </button>\n );\n};\n\nexport type AgreementDisplayProps = React.HTMLAttributes<HTMLDivElement> & {\n currentAgreement: Agreement;\n fallbackImageSrc: string;\n};\n\nexport function AgreementDisplay(props: AgreementDisplayProps) {\n const { currentAgreement, fallbackImageSrc } = props;\n\n return (\n <Container>\n <Display currentAgreement={currentAgreement} fallbackImageSrc={fallbackImageSrc} />\n </Container>\n );\n}\n"],"names":["Container","props","React","className","children","AgreementSelector","agreements","currentAgreement","fallbackImageSrc","filterAgreement","filterClientAgreement","onAddAgreement","handleAddAgreement","onChangeAgreement","onLogout","handleLogout","open","prop","setOpen","onChange","texts","useLocalization","collectionRef","useRef","useControllableState","search","setSearch","useState","useEffect","handleKeyDown","event","key","_collectionRef$curren","preventDefault","current","dispatchEvent","createCustomKeyboardEvent","handleChangeAgreement","agreement","PopoverPrimitive","onOpenChange","Display","Icon","name","SearchInput","autoFocus","target","value","onKeyDown","placeholder","header","CollectionPrimitive","querySelector","ref","tabIndex","filter","filterBySearchValue","map","button","createAgreementButton","isCurrentAgreement","clients","number","userId","clientAgreement","Button","onClick","addAgreement","logout","length","matchesAgreementNumber","String","indexOf","matchesCompanyName","toLowerCase","undefined","AgreementItem","AgreementDisplay"],"mappings":";;;;;;;;;;;;;AAaA,MAAMA,SAAS,GAAGC,KAAK;EACnB,oBACIC;IACIC,SAAS,EAAC,iFAAiF;iBACjF;kBACVD;IAAMC,SAAS,EAAC;IAAqE,EACpFF,KAAK,CAACG,QAAQ,CACb;AAEd,CAAC;SAeeC,iBAAiBA,CAACJ,KAA6B;EAC3D,MAAM;IACFK,UAAU;IACVC,gBAAgB;IAChBC,gBAAgB;IAChBC,eAAe,GAAGA,MAAM,IAAI;IAC5BC,qBAAqB,GAAGA,MAAM,IAAI;IAClCC,cAAc,EAAEC,kBAAkB;IAClCC,iBAAiB;IACjBC,QAAQ,EAAEC,YAAY;IACtBC,IAAI,EAAEC,IAAI;IACVC,OAAO,EAAEC;GACZ,GAAGlB,KAAK;EACT,MAAM;IAAEmB;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,aAAa,GAAGpB,cAAK,CAACqB,MAAM,CAA2C,IAAI,CAAC;EAClF,MAAM,CAACP,IAAI,EAAEE,OAAO,CAAC,GAAGM,oBAAoB,CAAU;IAClDL,QAAQ;IACRF;GACH,CAAC;EACF,MAAM,CAACQ,MAAM,EAAEC,SAAS,CAAC,GAAGxB,cAAK,CAACyB,QAAQ,CAAC,EAAE,CAAC;EAE9CzB,cAAK,CAAC0B,SAAS,CAAC;IACZF,SAAS,CAAC,EAAE,CAAC;GAChB,EAAE,CAACV,IAAI,CAAC,CAAC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;AAEjB,CAAC;SAOeqE,gBAAgBA,CAAC5E,KAA4B;EACzD,MAAM;IAAEM,gBAAgB;IAAEC;GAAkB,GAAGP,KAAK;EAEpD,oBACIC,6BAACF,SAAS,qBACNE,6BAACuC,kBAAO;IAAClC,gBAAgB,EAAEA,gBAAgB;IAAEC,gBAAgB,EAAEA;IAAoB,CAC3E;AAEpB;;;;"}
|
1
|
+
{"version":3,"file":"AgreementSelector.js","sources":["../../../../../../../../src/components/Header/components/AgreementSelector.tsx"],"sourcesContent":["import React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as CollectionPrimitive from '../../../primitives/Collection/Collection';\nimport { AgreementItem } from './Agreement/Item';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Icon } from '../../Icon/Icon';\nimport { SearchInput } from '../../SearchInput/SearchInput';\nimport { Button } from '../../Button/Button';\nimport { useLocalization } from '../../Provider/Localization';\nimport { Agreement } from './Agreement/types';\nimport { AgreementDisplay as Display } from './Agreement/Display';\n\nconst Container = props => {\n return (\n <div\n className=\"-ml-2 flex flex-shrink-0 flex-grow-0 items-center gap-2 pr-2 xl:ml-auto xl:w-64\"\n data-taco=\"header-agreements\">\n <span className=\"hidden h-8 w-px flex-shrink-0 flex-grow-0 bg-white/[0.3] xl:flex\" />\n {props.children}\n </div>\n );\n};\n\nexport type AgreementSelectorProps = {\n agreements: Agreement[];\n currentAgreement: Agreement;\n fallbackImageSrc: string;\n filterAgreement: (agreement: Agreement, filter: (agreement: Agreement) => boolean) => void;\n filterClientAgreement: (agreement: Agreement, searchValue: string, filter: (agreement: Agreement) => boolean) => void;\n onAddAgreement?: () => void;\n onChangeAgreement: (agreement: Agreement) => void;\n onLogout: () => void;\n open?: boolean;\n setOpen?: (open: boolean) => void;\n};\n\nexport function AgreementSelector(props: AgreementSelectorProps) {\n const {\n agreements,\n currentAgreement,\n fallbackImageSrc,\n filterAgreement = () => true,\n filterClientAgreement = () => true,\n onAddAgreement: handleAddAgreement,\n onChangeAgreement,\n onLogout: handleLogout,\n open: prop,\n setOpen: onChange,\n } = props;\n const { texts } = useLocalization();\n const collectionRef = React.useRef<CollectionPrimitive.CollectionRef | null>(null);\n const [open, setOpen] = useControllableState<boolean>({\n onChange,\n prop,\n });\n const [search, setSearch] = React.useState('');\n\n React.useEffect(() => {\n setSearch('');\n }, [open]);\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter') {\n event.preventDefault();\n collectionRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n };\n\n const handleChangeAgreement = (agreement: Agreement) => {\n onChangeAgreement(agreement);\n setOpen(false);\n };\n\n return (\n <Container>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PopoverPrimitive.Trigger className=\"xl:focus-visible:yt-focus-dark [&:focus-visible_img]:yt-focus-dark w-full rounded outline-none xl:[&:focus-visible_img]:shadow-none\">\n <Display currentAgreement={currentAgreement} fallbackImageSrc={fallbackImageSrc}>\n {agreements ? (\n <Icon\n className=\"ml-auto hidden flex-shrink-0 flex-grow-0 text-white xl:flex\"\n name={open ? 'chevron-up' : 'chevron-down'}\n />\n ) : null}\n </Display>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Content className=\"z-[996] mt-2 flex h-[calc(100vh_-_theme(spacing.16))] w-64 flex-col gap-1 bg-blue-900\">\n <SearchInput\n autoFocus\n className=\"focus-visible:!yt-focus-dark mx-2 !border-transparent !bg-white/[0.08] !text-white hover:!bg-white/[0.16] hover:!shadow-none focus:!bg-white/[0.16] active:!bg-white/[0.16] [&+div>button]:!text-white\"\n onChange={event => setSearch(event.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={texts.header.search}\n />\n <CollectionPrimitive.Root\n querySelector=\"button\"\n className=\"-my-1 flex w-full flex-grow flex-col gap-1 overflow-auto px-2 py-1 outline-none\"\n ref={collectionRef}\n tabIndex={-1}>\n {agreements\n ?.filter(agreement => filterAgreement(agreement, filterBySearchValue(search)))\n .map(agreement => {\n const button = createAgreementButton(\n agreement,\n fallbackImageSrc,\n handleChangeAgreement,\n isCurrentAgreement(agreement, currentAgreement)\n );\n\n if (agreement.clients) {\n return (\n <span\n className=\"flex flex-col gap-px [&>*:first-child>span]:!rounded-t [&>*:last-child>span]:!rounded-b [&>*>span]:!rounded-none\"\n key={`${agreement.number}_${agreement.userId}_clients`}>\n {filterBySearchValue(search)(agreement) ? button : null}\n {agreement.clients\n .filter(agreement =>\n filterClientAgreement(agreement, search, filterBySearchValue(search))\n )\n .map(clientAgreement =>\n createAgreementButton(\n clientAgreement,\n fallbackImageSrc,\n handleChangeAgreement,\n isCurrentAgreement(clientAgreement, currentAgreement)\n )\n )}\n </span>\n );\n }\n\n return button;\n })}\n </CollectionPrimitive.Root>\n {handleAddAgreement ? (\n <Button\n className=\"focus-visible:!yt-focus-dark my-1 mx-2 !h-9 shrink-0 !bg-white/[0.08] !text-white hover:!bg-white/[0.16]\"\n onClick={handleAddAgreement}>\n {texts.header.addAgreement}\n </Button>\n ) : null}\n <hr className=\"my-0 h-px w-full bg-white/[0.08]\" />\n <a\n className=\"focus-visible:yt-focus-dark mx-2 mb-2 flex h-8 shrink-0 items-center justify-center rounded text-white hover:cursor-pointer hover:text-white hover:underline focus-visible:outline-none\"\n onClick={handleLogout}\n tabIndex={0}>\n {texts.header.logout}\n </a>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Root>\n </Container>\n );\n}\n\nconst filterBySearchValue = (search: string) => (agreement: Agreement) => {\n if (!search || !search.length) {\n return true;\n }\n\n const matchesAgreementNumber = String(agreement.number).indexOf(search) > -1;\n const matchesCompanyName = agreement.name.toLowerCase().indexOf(search.toLowerCase()) > -1;\n\n return matchesAgreementNumber || matchesCompanyName;\n};\n\nconst isCurrentAgreement = (agreement: Agreement, currentAgreement: Agreement) => {\n return agreement.number === currentAgreement.number && agreement.userId === currentAgreement.userId;\n};\n\nconst createAgreementButton = (\n agreement: Agreement,\n fallbackImageSrc: string,\n onChangeAgreement: (agreement: Agreement) => void,\n isCurrentAgreement = false\n) => {\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === 'Enter') {\n onChangeAgreement(agreement);\n }\n };\n\n return (\n <button\n aria-current={isCurrentAgreement ? 'true' : undefined}\n className=\"focus:yt-focus-dark w-full rounded outline-none\"\n data-taco=\"header-agreements-agreement\"\n key={`${agreement.number}_${agreement.userId}`}\n onClick={() => onChangeAgreement(agreement)}\n onKeyDown={handleKeyDown}\n tabIndex={0}>\n <AgreementItem\n {...agreement}\n className=\"h-14 bg-white/[0.08] xl:hover:bg-white/[0.16] [[aria-current='true']>&]:bg-white/[0.16]\"\n fallbackImageSrc={fallbackImageSrc}\n />\n </button>\n );\n};\n\nexport type AgreementDisplayProps = React.HTMLAttributes<HTMLDivElement> & {\n currentAgreement: Agreement;\n fallbackImageSrc: string;\n};\n\nexport function AgreementDisplay(props: AgreementDisplayProps) {\n const { currentAgreement, fallbackImageSrc } = props;\n\n return (\n <Container>\n <Display currentAgreement={currentAgreement} fallbackImageSrc={fallbackImageSrc} />\n </Container>\n );\n}\n"],"names":["Container","props","React","className","children","AgreementSelector","agreements","currentAgreement","fallbackImageSrc","filterAgreement","filterClientAgreement","onAddAgreement","handleAddAgreement","onChangeAgreement","onLogout","handleLogout","open","prop","setOpen","onChange","texts","useLocalization","collectionRef","useRef","useControllableState","search","setSearch","useState","useEffect","handleKeyDown","event","key","_collectionRef$curren","preventDefault","current","dispatchEvent","createCustomKeyboardEvent","handleChangeAgreement","agreement","PopoverPrimitive","onOpenChange","Display","Icon","name","SearchInput","autoFocus","target","value","onKeyDown","placeholder","header","CollectionPrimitive","querySelector","ref","tabIndex","filter","filterBySearchValue","map","button","createAgreementButton","isCurrentAgreement","clients","number","userId","clientAgreement","Button","onClick","addAgreement","logout","length","matchesAgreementNumber","String","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React__default.forwardRef(function Link(props, ref) {
|
|
24
24
|
tabIndex: 0
|
25
25
|
}), icon ? /*#__PURE__*/React__default.createElement(Icon, {
|
26
26
|
name: icon
|
27
|
-
}) : null, children, isNew ? (
|
27
|
+
}) : null, children, isNew ? (/*#__PURE__*/React__default.createElement(Badge, {
|
28
28
|
color: "blue",
|
29
29
|
small: true,
|
30
30
|
className: "absolute right-0 top-0 -mr-2.5 -mt-1.5 !h-3 !px-0.5 text-[0.55rem] font-normal"
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Link.js","sources":["../../../../../../../../src/components/Header/components/Link.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Icon, IconName } from '../../Icon/Icon';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Badge } from '../../Badge/Badge';\nimport { useLocalization } from '../../Provider/Localization';\n\nexport type BaseLinkProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & {\n tooltip?: string;\n};\n\ninterface LinkPropsWithoutIcon extends BaseLinkProps {\n children: JSX.Element | string;\n icon?: never;\n isNew?: never;\n}\n\ninterface LinkPropsWithIcon extends Omit<BaseLinkProps, 'aria-label'> {\n 'aria-label': string;\n children?: never;\n icon: IconName;\n isNew?: boolean;\n}\n\nexport type LinkProps = LinkPropsWithoutIcon | LinkPropsWithIcon;\n\nexport const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link(props, ref) {\n const { children, icon, isNew, tooltip, ...otherProps } = props;\n const { texts } = useLocalization();\n const className = cn(getLinkClasses(icon), 'relative', props.className);\n\n const link = (\n <a {...otherProps} className={className} data-taco=\"header-link\" ref={ref} tabIndex={0}>\n {icon ? <Icon name={icon} /> : null}\n {children}\n {isNew ? (\n <Badge\n color=\"blue\"\n small\n className=\"absolute right-0 top-0 -mr-2.5 -mt-1.5 !h-3 !px-0.5 text-[0.55rem] font-normal\">\n {texts.header.new}\n </Badge>\n ) : null}\n </a>\n );\n\n if (tooltip) {\n return <Tooltip title={tooltip}>{link}</Tooltip>;\n }\n\n return link;\n});\n\nexport const getLinkClasses = (icon: IconName | undefined = undefined) =>\n cn(\n 'flex h-8 flex-shrink-0 flex-grow-0 cursor-pointer items-center justify-center ',\n 'focus:!shadow-none focus:!outline-none focus-visible:!yt-focus-dark',\n 'bg-transparent hover:bg-white/[.08] focus:bg-white/[.08] aria-current-page:bg-white/[.08]',\n 'text-white hover:text-white focus:text-white',\n {\n '!rounded-full !h-9 !w-9': icon,\n 'whitespace-nowrap px-3 rounded text-sm hidden lg:flex': !icon,\n }\n );\n"],"names":["Link","React","forwardRef","props","ref","children","icon","isNew","tooltip","otherProps","texts","useLocalization","className","cn","getLinkClasses","link","tabIndex","Icon","name","Badge","color","small","header","new","Tooltip","title","undefined"],"mappings":";;;;;;;MA0BaA,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAA+B,SAASF,IAAIA,CAACG,KAAK,EAAEC,GAAG;EACvF,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,KAAK;IAAEC,OAAO;IAAE,GAAGC;GAAY,GAAGN,KAAK;EAC/D,MAAM;IAAEO;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,SAAS,GAAGC,EAAE,CAACC,cAAc,CAACR,IAAI,CAAC,EAAE,UAAU,EAAEH,KAAK,CAACS,SAAS,CAAC;EAEvE,MAAMG,IAAI,gBACNd,oDAAOQ,UAAU;IAAEG,SAAS,EAAEA,SAAS;iBAAY,aAAa;IAACR,GAAG,EAAEA,GAAG;IAAEY,QAAQ,EAAE;MAChFV,IAAI,gBAAGL,6BAACgB,IAAI;IAACC,IAAI,EAAEZ;IAAQ,GAAG,IAAI,EAClCD,QAAQ,EACRE,KAAK,
|
1
|
+
{"version":3,"file":"Link.js","sources":["../../../../../../../../src/components/Header/components/Link.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { Icon, IconName } from '../../Icon/Icon';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Badge } from '../../Badge/Badge';\nimport { useLocalization } from '../../Provider/Localization';\n\nexport type BaseLinkProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & {\n tooltip?: string;\n};\n\ninterface LinkPropsWithoutIcon extends BaseLinkProps {\n children: JSX.Element | string;\n icon?: never;\n isNew?: never;\n}\n\ninterface LinkPropsWithIcon extends Omit<BaseLinkProps, 'aria-label'> {\n 'aria-label': string;\n children?: never;\n icon: IconName;\n isNew?: boolean;\n}\n\nexport type LinkProps = LinkPropsWithoutIcon | LinkPropsWithIcon;\n\nexport const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link(props, ref) {\n const { children, icon, isNew, tooltip, ...otherProps } = props;\n const { texts } = useLocalization();\n const className = cn(getLinkClasses(icon), 'relative', props.className);\n\n const link = (\n <a {...otherProps} className={className} data-taco=\"header-link\" ref={ref} tabIndex={0}>\n {icon ? <Icon name={icon} /> : null}\n {children}\n {isNew ? (\n <Badge\n color=\"blue\"\n small\n className=\"absolute right-0 top-0 -mr-2.5 -mt-1.5 !h-3 !px-0.5 text-[0.55rem] font-normal\">\n {texts.header.new}\n </Badge>\n ) : null}\n </a>\n );\n\n if (tooltip) {\n return <Tooltip title={tooltip}>{link}</Tooltip>;\n }\n\n return link;\n});\n\nexport const getLinkClasses = (icon: IconName | undefined = undefined) =>\n cn(\n 'flex h-8 flex-shrink-0 flex-grow-0 cursor-pointer items-center justify-center ',\n 'focus:!shadow-none focus:!outline-none focus-visible:!yt-focus-dark',\n 'bg-transparent hover:bg-white/[.08] focus:bg-white/[.08] aria-current-page:bg-white/[.08]',\n 'text-white hover:text-white focus:text-white',\n {\n '!rounded-full !h-9 !w-9': icon,\n 'whitespace-nowrap px-3 rounded text-sm hidden lg:flex': !icon,\n }\n );\n"],"names":["Link","React","forwardRef","props","ref","children","icon","isNew","tooltip","otherProps","texts","useLocalization","className","cn","getLinkClasses","link","tabIndex","Icon","name","Badge","color","small","header","new","Tooltip","title","undefined"],"mappings":";;;;;;;MA0BaA,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAA+B,SAASF,IAAIA,CAACG,KAAK,EAAEC,GAAG;EACvF,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,KAAK;IAAEC,OAAO;IAAE,GAAGC;GAAY,GAAGN,KAAK;EAC/D,MAAM;IAAEO;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,SAAS,GAAGC,EAAE,CAACC,cAAc,CAACR,IAAI,CAAC,EAAE,UAAU,EAAEH,KAAK,CAACS,SAAS,CAAC;EAEvE,MAAMG,IAAI,gBACNd,oDAAOQ,UAAU;IAAEG,SAAS,EAAEA,SAAS;iBAAY,aAAa;IAACR,GAAG,EAAEA,GAAG;IAAEY,QAAQ,EAAE;MAChFV,IAAI,gBAAGL,6BAACgB,IAAI;IAACC,IAAI,EAAEZ;IAAQ,GAAG,IAAI,EAClCD,QAAQ,EACRE,KAAK,iBACFN,6BAACkB,KAAK;IACFC,KAAK,EAAC,MAAM;IACZC,KAAK;IACLT,SAAS,EAAC;KACTF,KAAK,CAACY,MAAM,CAACC,GAAG,CACb,IACR,IAAI,CAEf;EAED,IAAIf,OAAO,EAAE;IACT,oBAAOP,6BAACuB,OAAO;MAACC,KAAK,EAAEjB;OAAUO,IAAI,CAAW;;EAGpD,OAAOA,IAAI;AACf,CAAC;MAEYD,cAAc,GAAGA,CAACR,OAA6BoB,SAAS,KACjEb,EAAE,CACE,gFAAgF,EAChF,qEAAqE,EACrE,2FAA2F,EAC3F,8CAA8C,EAC9C;EACI,yBAAyB,EAAEP,IAAI;EAC/B,uDAAuD,EAAE,CAACA;CAC7D;;;;"}
|
@@ -12,7 +12,7 @@ const PrimaryNavigation = /*#__PURE__*/React__default.forwardRef(function Primar
|
|
12
12
|
} = useLocalization();
|
13
13
|
const internalRef = useMergedRef(ref);
|
14
14
|
const className = cn('flex h-full w-full flex-grow items-center overflow-hidden active:outline-none relative', props.className);
|
15
|
-
const moreButton = () => (
|
15
|
+
const moreButton = () => (/*#__PURE__*/React__default.createElement(Button, {
|
16
16
|
className: cn(getLinkClasses(), '!bg-transparent aria-expanded:!bg-white/[.08]')
|
17
17
|
}, texts.header.more));
|
18
18
|
return /*#__PURE__*/React__default.createElement("nav", Object.assign({}, props, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PrimaryNavigation.js","sources":["../../../../../../../../src/components/Header/components/PrimaryNavigation.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { getLinkClasses } from './Link';\nimport { useLocalization } from '../../Provider/Localization';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { Button } from '../../Button/Button';\nimport { OverflowGroup } from '../../OverflowGroup/OverflowGroup';\n\nexport type PrimaryNavigationProps = React.HTMLAttributes<HTMLElement>;\n\nexport const PrimaryNavigation = React.forwardRef<HTMLElement, PrimaryNavigationProps>(function PrimaryNavigation(props, ref) {\n const { texts } = useLocalization();\n const internalRef = useMergedRef<HTMLDivElement>(ref);\n\n const className = cn(\n 'flex h-full w-full flex-grow items-center overflow-hidden active:outline-none relative',\n props.className\n );\n\n const moreButton = () => (\n <Button className={cn(getLinkClasses(), '!bg-transparent aria-expanded:!bg-white/[.08]')}>{texts.header.more}</Button>\n );\n return (\n <nav {...props} className={className} ref={internalRef}>\n <OverflowGroup className=\"h-full flex-grow items-center gap-1 px-1\" moreButton={moreButton}>\n {props.children}\n </OverflowGroup>\n </nav>\n );\n});\n"],"names":["PrimaryNavigation","React","forwardRef","props","ref","texts","useLocalization","internalRef","useMergedRef","className","cn","moreButton","Button","getLinkClasses","header","more","OverflowGroup","children"],"mappings":";;;;;;;;MAUaA,iBAAiB,gBAAGC,cAAK,CAACC,UAAU,CAAsC,SAASF,iBAAiBA,CAACG,KAAK,EAAEC,GAAG;EACxH,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,WAAW,GAAGC,YAAY,CAAiBJ,GAAG,CAAC;EAErD,MAAMK,SAAS,GAAGC,EAAE,CAChB,wFAAwF,EACxFP,KAAK,CAACM,SAAS,CAClB;EAED,MAAME,UAAU,GAAGA,
|
1
|
+
{"version":3,"file":"PrimaryNavigation.js","sources":["../../../../../../../../src/components/Header/components/PrimaryNavigation.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { getLinkClasses } from './Link';\nimport { useLocalization } from '../../Provider/Localization';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { Button } from '../../Button/Button';\nimport { OverflowGroup } from '../../OverflowGroup/OverflowGroup';\n\nexport type PrimaryNavigationProps = React.HTMLAttributes<HTMLElement>;\n\nexport const PrimaryNavigation = React.forwardRef<HTMLElement, PrimaryNavigationProps>(function PrimaryNavigation(props, ref) {\n const { texts } = useLocalization();\n const internalRef = useMergedRef<HTMLDivElement>(ref);\n\n const className = cn(\n 'flex h-full w-full flex-grow items-center overflow-hidden active:outline-none relative',\n props.className\n );\n\n const moreButton = () => (\n <Button className={cn(getLinkClasses(), '!bg-transparent aria-expanded:!bg-white/[.08]')}>{texts.header.more}</Button>\n );\n return (\n <nav {...props} className={className} ref={internalRef}>\n <OverflowGroup className=\"h-full flex-grow items-center gap-1 px-1\" moreButton={moreButton}>\n {props.children}\n </OverflowGroup>\n </nav>\n );\n});\n"],"names":["PrimaryNavigation","React","forwardRef","props","ref","texts","useLocalization","internalRef","useMergedRef","className","cn","moreButton","Button","getLinkClasses","header","more","OverflowGroup","children"],"mappings":";;;;;;;;MAUaA,iBAAiB,gBAAGC,cAAK,CAACC,UAAU,CAAsC,SAASF,iBAAiBA,CAACG,KAAK,EAAEC,GAAG;EACxH,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,WAAW,GAAGC,YAAY,CAAiBJ,GAAG,CAAC;EAErD,MAAMK,SAAS,GAAGC,EAAE,CAChB,wFAAwF,EACxFP,KAAK,CAACM,SAAS,CAClB;EAED,MAAME,UAAU,GAAGA,oBACfV,6BAACW,MAAM;IAACH,SAAS,EAAEC,EAAE,CAACG,cAAc,EAAE,EAAE,+CAA+C;KAAIR,KAAK,CAACS,MAAM,CAACC,IAAI,CAAU,CACzH;EACD,oBACId,sDAASE,KAAK;IAAEM,SAAS,EAAEA,SAAS;IAAEL,GAAG,EAAEG;mBACvCN,6BAACe,aAAa;IAACP,SAAS,EAAC,0CAA0C;IAACE,UAAU,EAAEA;KAC3ER,KAAK,CAACc,QAAQ,CACH,CACd;AAEd,CAAC;;;;"}
|
@@ -14,7 +14,7 @@ const Icon = /*#__PURE__*/React__default.forwardRef(function Icon(props, ref) {
|
|
14
14
|
const className = cn('inline-flex h-[1.715em] w-[1.715em] flex-shrink-0', props.className, {
|
15
15
|
'p-[3px]': (_props$className = props.className) === null || _props$className === void 0 ? void 0 : _props$className.includes('rounded-full')
|
16
16
|
});
|
17
|
-
return Component ? (
|
17
|
+
return Component ? (/*#__PURE__*/React__default.createElement(Component, Object.assign({}, otherProps, {
|
18
18
|
className: className,
|
19
19
|
"data-taco": "icon",
|
20
20
|
"data-icon-name": name,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Icon.js","sources":["../../../../../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { IconName, icons } from './components/index';\n\nexport { icons } from './components/index';\nexport type { IconName } from './components/index';\n\nexport type IconProps = React.SVGAttributes<SVGSVGElement> & {\n /** Set what svg icon should be rendered */\n name: IconName; // this dynamic type causes the type extraction for props to fail\n};\n\nexport const Icon = React.forwardRef(function Icon(props: IconProps, ref: React.Ref<SVGSVGElement>) {\n const { name, ...otherProps } = props;\n const Component = icons[name];\n /* 24x24 _at the base body font_ - must be em so that they scale with font size - tailwind spacing uses rem */\n const className = cn('inline-flex h-[1.715em] w-[1.715em] flex-shrink-0', props.className, {\n 'p-[3px]': props.className?.includes('rounded-full'),\n });\n\n return Component ? (\n <Component\n {...otherProps}\n className={className}\n data-taco=\"icon\"\n data-icon-name={name}\n focusable=\"false\"\n ref={ref}\n role=\"img\"\n />\n ) : null;\n});\n"],"names":["Icon","React","forwardRef","props","ref","name","otherProps","Component","icons","className","cn","_props$className","includes","focusable","role"],"mappings":";;;;;MAYaA,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,IAAIA,CAACG,KAAgB,EAAEC,GAA6B;;EAC9F,MAAM;IAAEC,IAAI;IAAE,GAAGC;GAAY,GAAGH,KAAK;EACrC,MAAMI,SAAS,GAAGC,KAAK,CAACH,IAAI,CAAC;;EAE7B,MAAMI,SAAS,GAAGC,EAAE,CAAC,mDAAmD,EAAEP,KAAK,CAACM,SAAS,EAAE;IACvF,SAAS,GAAAE,gBAAA,GAAER,KAAK,CAACM,SAAS,cAAAE,gBAAA,uBAAfA,gBAAA,CAAiBC,QAAQ,CAAC,cAAc;GACtD,CAAC;EAEF,OAAOL,SAAS,
|
1
|
+
{"version":3,"file":"Icon.js","sources":["../../../../../../../src/components/Icon/Icon.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { IconName, icons } from './components/index';\n\nexport { icons } from './components/index';\nexport type { IconName } from './components/index';\n\nexport type IconProps = React.SVGAttributes<SVGSVGElement> & {\n /** Set what svg icon should be rendered */\n name: IconName; // this dynamic type causes the type extraction for props to fail\n};\n\nexport const Icon = React.forwardRef(function Icon(props: IconProps, ref: React.Ref<SVGSVGElement>) {\n const { name, ...otherProps } = props;\n const Component = icons[name];\n /* 24x24 _at the base body font_ - must be em so that they scale with font size - tailwind spacing uses rem */\n const className = cn('inline-flex h-[1.715em] w-[1.715em] flex-shrink-0', props.className, {\n 'p-[3px]': props.className?.includes('rounded-full'),\n });\n\n return Component ? (\n <Component\n {...otherProps}\n className={className}\n data-taco=\"icon\"\n data-icon-name={name}\n focusable=\"false\"\n ref={ref}\n role=\"img\"\n />\n ) : null;\n});\n"],"names":["Icon","React","forwardRef","props","ref","name","otherProps","Component","icons","className","cn","_props$className","includes","focusable","role"],"mappings":";;;;;MAYaA,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAC,SAASF,IAAIA,CAACG,KAAgB,EAAEC,GAA6B;;EAC9F,MAAM;IAAEC,IAAI;IAAE,GAAGC;GAAY,GAAGH,KAAK;EACrC,MAAMI,SAAS,GAAGC,KAAK,CAACH,IAAI,CAAC;;EAE7B,MAAMI,SAAS,GAAGC,EAAE,CAAC,mDAAmD,EAAEP,KAAK,CAACM,SAAS,EAAE;IACvF,SAAS,GAAAE,gBAAA,GAAER,KAAK,CAACM,SAAS,cAAAE,gBAAA,uBAAfA,gBAAA,CAAiBC,QAAQ,CAAC,cAAc;GACtD,CAAC;EAEF,OAAOL,SAAS,iBACZN,6BAACM,SAAS,oBACFD,UAAU;IACdG,SAAS,EAAEA,SAAS;iBACV,MAAM;sBACAJ,IAAI;IACpBQ,SAAS,EAAC,OAAO;IACjBT,GAAG,EAAEA,GAAG;IACRU,IAAI,EAAC;KACP,IACF,IAAI;AACZ,CAAC;;;;"}
|
@@ -111,7 +111,7 @@ const InputWithoutDeprecatedFeatures = /*#__PURE__*/forwardRef(function InputWit
|
|
111
111
|
ref: postfixRef
|
112
112
|
}) : null);
|
113
113
|
});
|
114
|
-
const Affix = /*#__PURE__*/memo(
|
114
|
+
const Affix = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Affix(props, ref) {
|
115
115
|
const {
|
116
116
|
children,
|
117
117
|
disabled,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Input.js","sources":["../../../../../../../src/components/Input/Input.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getButtonStateClasses, getInputClasses } from './util';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { isPressingMetaKey } from '../../utils/keyboard';\n\nexport type InputWithoutDeprecatedFeaturesProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'prefix'> & {\n /** Draws attention to the input by changing its style and making it visually prominent */\n highlighted?: boolean;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n postfix?: string | JSX.Element;\n prefix?: string | JSX.Element;\n};\n\nconst validSetSelectionRangeTypes = ['text', 'search', 'url', 'tel', 'password'];\n\nconst InputWithoutDeprecatedFeatures = React.forwardRef(function InputWithoutDeprecatedFeatures(\n props: InputWithoutDeprecatedFeaturesProps,\n ref: React.Ref<HTMLInputElement>\n) {\n const { highlighted, invalid, onKeyDown, postfix, prefix, type = 'text', ...attributes } = props;\n const internalRef = useMergedRef<HTMLInputElement>(ref);\n\n // input[type=number] does not support setSelectionRange by default, this adds support\n React.useLayoutEffect(() => {\n if (internalRef.current && type === 'number') {\n (function (fn) {\n internalRef.current.setSelectionRange = function (...args) {\n if (this.type === 'number') {\n this.type = 'text';\n fn.apply(this, args);\n this.type = 'number';\n } else {\n fn.apply(this, args);\n }\n };\n })(internalRef.current.setSelectionRange);\n }\n }, []);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n // prevent any external keyboard shortcuts from executing while typing single characters in input\n if (event.key.length === 1 && !isPressingMetaKey(event)) {\n event.stopPropagation();\n }\n\n // home and end keys only navigate to the start/end of input value if the input container does not scroll\n // if it has scroll height then the browser reverts to native scrolling behaviour only\n // so we manually override it to ensure _our_ desired behaviour remains intact\n // only the 'text', 'search', 'url', 'tel', 'password' input types support setSelectionRange\n if (validSetSelectionRangeTypes.includes(type)) {\n if (!event.shiftKey && (event.key === 'Home' || event.key === 'End')) {\n event.preventDefault();\n const position = event.key === 'End' ? event.currentTarget.value.length : 0;\n event.currentTarget.setSelectionRange(position, position);\n\n // Necessary for ensuring the cursor is scrolled into view when using Home/End keys on Windows\n if (internalRef.current) {\n const scrollPosition = event.key === 'End' ? internalRef.current.scrollWidth : 0;\n internalRef.current.scrollLeft = scrollPosition;\n }\n }\n }\n\n if (typeof onKeyDown === 'function') {\n onKeyDown(event);\n }\n };\n\n const prefixRef = React.useRef<HTMLDivElement>(null);\n const prefixRect = useBoundingClientRectListener(prefixRef);\n const postfixRef = React.useRef<HTMLDivElement>(null);\n const postfixRect = useBoundingClientRectListener(postfixRef, [postfix]);\n\n const className = cn(\n getInputClasses(props),\n {\n 'pl-8': !!prefix,\n 'pr-8': !!postfix,\n },\n attributes.className\n );\n\n const typeAttributes: Partial<React.InputHTMLAttributes<HTMLInputElement>> = {\n type,\n };\n\n if (type === 'number') {\n typeAttributes.onWheelCapture = (event: React.WheelEvent<HTMLInputElement>) => {\n // blur is the only way to prevent scroll, so restore focus if it had it\n if (document.activeElement === event.currentTarget) {\n requestAnimationFrame(() => {\n (event.target as HTMLInputElement).focus();\n });\n }\n // blur the field on scroll - only way to prevent scroll\n event.currentTarget.blur();\n };\n }\n\n return (\n <div className=\"relative inline-flex h-fit w-full\" data-taco=\"input-container\" style={{ opacity: 0.999 }}>\n <input\n {...attributes}\n {...typeAttributes}\n aria-invalid={invalid}\n className={className}\n data-highlighted={highlighted}\n data-taco=\"input\"\n onKeyDown={handleKeyDown}\n ref={internalRef}\n style={{\n paddingLeft: prefixRect ? `${prefixRect.width - 1}px` : undefined,\n paddingRight: postfixRect ? `${postfixRect.width - 1}px` : undefined,\n }}\n />\n {prefix ? <Affix type=\"prefix\" children={prefix} disabled={attributes.disabled} ref={prefixRef} /> : null}\n {postfix ? <Affix type=\"postfix\" children={postfix} disabled={attributes.disabled} ref={postfixRef} /> : null}\n </div>\n );\n});\n\ntype AffixProps = {\n children: string | JSX.Element;\n disabled?: boolean;\n type: 'prefix' | 'postfix';\n};\nconst Affix = React.memo(\n React.forwardRef(function Affix(props: AffixProps, ref: React.Ref<HTMLDivElement>) {\n const { children, disabled, type } = props;\n\n return (\n <div\n className={cn(\n 'group absolute top-0 flex h-full items-center justify-center px-2',\n // icon\n '[&_[data-taco=\"icon\"]]:!h-5 [&_[data-taco=\"icon\"]]:!w-5',\n {\n 'text-grey-300': disabled,\n 'text-grey-700': !disabled,\n 'left-0 [&>button]:!-ml-2': type === 'prefix',\n 'right-0 [&>button]:!-mr-2': type === 'postfix',\n }\n )}\n data-affix-type={type}\n ref={ref}>\n {children}\n </div>\n );\n })\n);\n\nexport type InputProps = InputWithoutDeprecatedFeaturesProps & {\n /** Shows a button within the input field */\n button?: React.ReactElement;\n /** Shows an icon within the input field */\n icon?: IconName | JSX.Element;\n};\n\nexport const Input = React.forwardRef(function LegacyInput(props: InputProps, ref: React.Ref<HTMLInputElement>) {\n const { button, icon, ...attributes } = props;\n\n let postfix;\n\n if (button) {\n const disabled = button.props.disabled || attributes.disabled;\n const buttonClassName = cn(\n 'items-center focus:z-10 flex justify-center rounded-l-none rounded-r h-full focus:rounded focus:outline-none',\n getButtonStateClasses(attributes.invalid, disabled),\n button.props.className\n );\n postfix = React.cloneElement(button, {\n className: buttonClassName,\n disabled,\n });\n } else if (icon) {\n postfix = typeof icon === 'string' ? <Icon name={icon} /> : icon;\n }\n\n return <InputWithoutDeprecatedFeatures {...attributes} postfix={attributes.postfix ?? postfix} ref={ref} />;\n});\n"],"names":["validSetSelectionRangeTypes","InputWithoutDeprecatedFeatures","React","props","ref","highlighted","invalid","onKeyDown","postfix","prefix","type","attributes","internalRef","useMergedRef","current","fn","setSelectionRange","args","apply","handleKeyDown","event","key","length","isPressingMetaKey","stopPropagation","includes","shiftKey","preventDefault","position","currentTarget","value","scrollPosition","scrollWidth","scrollLeft","prefixRef","prefixRect","useBoundingClientRectListener","postfixRef","postfixRect","className","cn","getInputClasses","typeAttributes","onWheelCapture","document","activeElement","requestAnimationFrame","target","focus","blur","style","opacity","paddingLeft","width","undefined","paddingRight","Affix","children","disabled","Input","LegacyInput","button","icon","buttonClassName","getButtonStateClasses","Icon","name","_attributes$postfix"],"mappings":";;;;;;;;AAiBA,MAAMA,2BAA2B,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC;AAEhF,MAAMC,8BAA8B,gBAAGC,UAAgB,CAAC,SAASD,8BAA8BA,CAC3FE,KAA0C,EAC1CC,GAAgC;EAEhC,MAA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EyD,MAAM;IAAEC,IAAI;IAAE,GAAGnD;GAAY,GAAGR,KAAK;EAE7C,IAAIK,OAAO;EAEX,IAAIqD,MAAM,EAAE;IACR,MAAMH,QAAQ,GAAGG,MAAM,CAAC1D,KAAK,CAACuD,QAAQ,IAAI/C,UAAU,CAAC+C,QAAQ;IAC7D,MAAMK,eAAe,GAAGvB,EAAE,CACtB,8GAA8G,EAC9GwB,qBAAqB,CAACrD,UAAU,CAACL,OAAO,EAAEoD,QAAQ,CAAC,EACnDG,MAAM,CAAC1D,KAAK,CAACoC,SAAS,CACzB;IACD/B,OAAO,gBAAGN,YAAkB,CAAC2D,MAAM,EAAE;MACjCtB,SAAS,EAAEwB,eAAe;MAC1BL;KACH,CAAC;GACL,MAAM,IAAII,IAAI,EAAE;IACbtD,OAAO,GAAG,OAAOsD,IAAI,KAAK,QAAQ,gBAAG5D,cAAC+D,IAAI;MAACC,IAAI,EAAEJ;MAAQ,GAAGA,IAAI;;EAGpE,oBAAO5D,cAACD,8BAA8B,oBAAKU,UAAU;IAAEH,OAAO,GAAA2D,mBAAA,GAAExD,UAAU,CAACH,OAAO,cAAA2D,mBAAA,cAAAA,mBAAA,GAAI3D,OAAO;IAAEJ,GAAG,EAAEA;KAAO;AAC/G,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../../../../../../src/components/Input/Input.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getButtonStateClasses, getInputClasses } from './util';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { isPressingMetaKey } from '../../utils/keyboard';\n\nexport type InputWithoutDeprecatedFeaturesProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'prefix'> & {\n /** Draws attention to the input by changing its style and making it visually prominent */\n highlighted?: boolean;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n postfix?: string | JSX.Element;\n prefix?: string | JSX.Element;\n};\n\nconst validSetSelectionRangeTypes = ['text', 'search', 'url', 'tel', 'password'];\n\nconst InputWithoutDeprecatedFeatures = React.forwardRef(function InputWithoutDeprecatedFeatures(\n props: InputWithoutDeprecatedFeaturesProps,\n ref: React.Ref<HTMLInputElement>\n) {\n const { highlighted, invalid, onKeyDown, postfix, prefix, type = 'text', ...attributes } = props;\n const internalRef = useMergedRef<HTMLInputElement>(ref);\n\n // input[type=number] does not support setSelectionRange by default, this adds support\n React.useLayoutEffect(() => {\n if (internalRef.current && type === 'number') {\n (function (fn) {\n internalRef.current.setSelectionRange = function (...args) {\n if (this.type === 'number') {\n this.type = 'text';\n fn.apply(this, args);\n this.type = 'number';\n } else {\n fn.apply(this, args);\n }\n };\n })(internalRef.current.setSelectionRange);\n }\n }, []);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n // prevent any external keyboard shortcuts from executing while typing single characters in input\n if (event.key.length === 1 && !isPressingMetaKey(event)) {\n event.stopPropagation();\n }\n\n // home and end keys only navigate to the start/end of input value if the input container does not scroll\n // if it has scroll height then the browser reverts to native scrolling behaviour only\n // so we manually override it to ensure _our_ desired behaviour remains intact\n // only the 'text', 'search', 'url', 'tel', 'password' input types support setSelectionRange\n if (validSetSelectionRangeTypes.includes(type)) {\n if (!event.shiftKey && (event.key === 'Home' || event.key === 'End')) {\n event.preventDefault();\n const position = event.key === 'End' ? event.currentTarget.value.length : 0;\n event.currentTarget.setSelectionRange(position, position);\n\n // Necessary for ensuring the cursor is scrolled into view when using Home/End keys on Windows\n if (internalRef.current) {\n const scrollPosition = event.key === 'End' ? internalRef.current.scrollWidth : 0;\n internalRef.current.scrollLeft = scrollPosition;\n }\n }\n }\n\n if (typeof onKeyDown === 'function') {\n onKeyDown(event);\n }\n };\n\n const prefixRef = React.useRef<HTMLDivElement>(null);\n const prefixRect = useBoundingClientRectListener(prefixRef);\n const postfixRef = React.useRef<HTMLDivElement>(null);\n const postfixRect = useBoundingClientRectListener(postfixRef, [postfix]);\n\n const className = cn(\n getInputClasses(props),\n {\n 'pl-8': !!prefix,\n 'pr-8': !!postfix,\n },\n attributes.className\n );\n\n const typeAttributes: Partial<React.InputHTMLAttributes<HTMLInputElement>> = {\n type,\n };\n\n if (type === 'number') {\n typeAttributes.onWheelCapture = (event: React.WheelEvent<HTMLInputElement>) => {\n // blur is the only way to prevent scroll, so restore focus if it had it\n if (document.activeElement === event.currentTarget) {\n requestAnimationFrame(() => {\n (event.target as HTMLInputElement).focus();\n });\n }\n // blur the field on scroll - only way to prevent scroll\n event.currentTarget.blur();\n };\n }\n\n return (\n <div className=\"relative inline-flex h-fit w-full\" data-taco=\"input-container\" style={{ opacity: 0.999 }}>\n <input\n {...attributes}\n {...typeAttributes}\n aria-invalid={invalid}\n className={className}\n data-highlighted={highlighted}\n data-taco=\"input\"\n onKeyDown={handleKeyDown}\n ref={internalRef}\n style={{\n paddingLeft: prefixRect ? `${prefixRect.width - 1}px` : undefined,\n paddingRight: postfixRect ? `${postfixRect.width - 1}px` : undefined,\n }}\n />\n {prefix ? <Affix type=\"prefix\" children={prefix} disabled={attributes.disabled} ref={prefixRef} /> : null}\n {postfix ? <Affix type=\"postfix\" children={postfix} disabled={attributes.disabled} ref={postfixRef} /> : null}\n </div>\n );\n});\n\ntype AffixProps = {\n children: string | JSX.Element;\n disabled?: boolean;\n type: 'prefix' | 'postfix';\n};\nconst Affix = React.memo(\n React.forwardRef(function Affix(props: AffixProps, ref: React.Ref<HTMLDivElement>) {\n const { children, disabled, type } = props;\n\n return (\n <div\n className={cn(\n 'group absolute top-0 flex h-full items-center justify-center px-2',\n // icon\n '[&_[data-taco=\"icon\"]]:!h-5 [&_[data-taco=\"icon\"]]:!w-5',\n {\n 'text-grey-300': disabled,\n 'text-grey-700': !disabled,\n 'left-0 [&>button]:!-ml-2': type === 'prefix',\n 'right-0 [&>button]:!-mr-2': type === 'postfix',\n }\n )}\n data-affix-type={type}\n ref={ref}>\n {children}\n </div>\n );\n })\n);\n\nexport type InputProps = InputWithoutDeprecatedFeaturesProps & {\n /** Shows a button within the input field */\n button?: React.ReactElement;\n /** Shows an icon within the input field */\n icon?: IconName | JSX.Element;\n};\n\nexport const Input = React.forwardRef(function LegacyInput(props: InputProps, ref: React.Ref<HTMLInputElement>) {\n const { button, icon, ...attributes } = props;\n\n let postfix;\n\n if (button) {\n const disabled = button.props.disabled || attributes.disabled;\n const buttonClassName = cn(\n 'items-center focus:z-10 flex justify-center rounded-l-none rounded-r h-full focus:rounded focus:outline-none',\n getButtonStateClasses(attributes.invalid, disabled),\n button.props.className\n );\n postfix = React.cloneElement(button, {\n className: buttonClassName,\n disabled,\n });\n } else if (icon) {\n postfix = typeof icon === 'string' ? <Icon name={icon} /> : icon;\n }\n\n return <InputWithoutDeprecatedFeatures {...attributes} postfix={attributes.postfix ?? postfix} ref={ref} />;\n});\n"],"names":["validSetSelectionRangeTypes","InputWithoutDeprecatedFeatures","React","props","ref","highlighted","invalid","onKeyDown","postfix","prefix","type","attributes","internalRef","useMergedRef","current","fn","setSelectionRange","args","apply","handleKeyDown","event","key","length","isPressingMetaKey","stopPropagation","includes","shiftKey","preventDefault","position","currentTarget","value","scrollPosition","scrollWidth","scrollLeft","prefixRef","prefixRect","useBoundingClientRectListener","postfixRef","postfixRect","className","cn","getInputClasses","typeAttributes","onWheelCapture","document","activeElement","requestAnimationFrame","target","focus","blur","style","opacity","paddingLeft","width","undefined","paddingRight","Affix","children","disabled","Input","LegacyInput","button","icon","buttonClassName","getButtonStateClasses","Icon","name","_attributes$postfix"],"mappings":";;;;;;;;AAiBA,MAAMA,2BAA2B,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC;AAEhF,MAAMC,8BAA8B,gBAAGC,UAAgB,CAAC,SAASD,8BAA8BA,CAC3FE,KAA0C,EAC1CC,GAAgC;EAEhC,MAAM;IAAEC,WAAW;IAAEC,OAAO;IAAEC,SAAS;IAAEC,O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AE,GAAGnD;GAAY,GAAGR,KAAK;EAE7C,IAAIK,OAAO;EAEX,IAAIqD,MAAM,EAAE;IACR,MAAMH,QAAQ,GAAGG,MAAM,CAAC1D,KAAK,CAACuD,QAAQ,IAAI/C,UAAU,CAAC+C,QAAQ;IAC7D,MAAMK,eAAe,GAAGvB,EAAE,CACtB,8GAA8G,EAC9GwB,qBAAqB,CAACrD,UAAU,CAACL,OAAO,EAAEoD,QAAQ,CAAC,EACnDG,MAAM,CAAC1D,KAAK,CAACoC,SAAS,CACzB;IACD/B,OAAO,gBAAGN,YAAkB,CAAC2D,MAAM,EAAE;MACjCtB,SAAS,EAAEwB,eAAe;MAC1BL;KACH,CAAC;GACL,MAAM,IAAII,IAAI,EAAE;IACbtD,OAAO,GAAG,OAAOsD,IAAI,KAAK,QAAQ,gBAAG5D,cAAC+D,IAAI;MAACC,IAAI,EAAEJ;MAAQ,GAAGA,IAAI;;EAGpE,oBAAO5D,cAACD,8BAA8B,oBAAKU,UAAU;IAAEH,OAAO,GAAA2D,mBAAA,GAAExD,UAAU,CAACH,OAAO,cAAA2D,mBAAA,cAAAA,mBAAA,GAAI3D,OAAO;IAAEJ,GAAG,EAAEA;KAAO;AAC/G,CAAC;;;;"}
|
@@ -68,7 +68,7 @@ const Sidebar = /*#__PURE__*/React__default.forwardRef(function LayoutSidebar(pr
|
|
68
68
|
"aria-hidden": !isVisible,
|
69
69
|
className: className,
|
70
70
|
ref: ref
|
71
|
-
}), content), /*#__PURE__*/React__default.createElement(AnimatePresence, null, showBackdrop && (
|
71
|
+
}), content), /*#__PURE__*/React__default.createElement(AnimatePresence, null, showBackdrop && (/*#__PURE__*/React__default.createElement(SidebarBackdrop, {
|
72
72
|
initial: {
|
73
73
|
opacity: 0
|
74
74
|
},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Sidebar.js","sources":["../../../../../../../../src/components/Layout/components/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { LayoutContext } from './Context';\nimport { useIsLargeScreen } from '../../../hooks/useIsLargeScreen';\nimport { Backdrop, BackdropProps } from '../../Backdrop/Backdrop';\n\nconst SidebarBackdrop = motion<BackdropProps>(Backdrop);\n\nexport type LayoutSidebarProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const Sidebar = React.forwardRef<HTMLDivElement, LayoutSidebarProps>(function LayoutSidebar(props, ref) {\n const { children, ...attributes } = props;\n const { sidebarOpen, setSidebarOpen } = React.useContext(LayoutContext);\n const isLargeScreen = useIsLargeScreen();\n const isSmallScreen = !isLargeScreen;\n\n // if it's a large screen we override the open state and make it always visible\n const isVisible = isLargeScreen || sidebarOpen;\n\n // ensures the menu is always closed by default when resizing to a smaller window size\n React.useEffect(() => {\n setSidebarOpen(isLargeScreen);\n }, [isLargeScreen]);\n\n React.useEffect(() => {\n const handleEscapeKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n setSidebarOpen(false);\n }\n };\n\n if (isSmallScreen && sidebarOpen) {\n window.addEventListener('keydown', handleEscapeKey);\n }\n\n return () => {\n window.removeEventListener('keydown', handleEscapeKey);\n };\n }, [isSmallScreen, sidebarOpen]);\n\n const showBackdrop = isSmallScreen && sidebarOpen === true;\n\n const [ready, setReady] = React.useState(isSmallScreen);\n\n const className = cn(\n 'bg-grey-50 h-full w-64 flex-shrink-0 flex-grow-0 print:hidden',\n {\n 'absolute z-10 aria-hidden:-translate-x-64 ': isSmallScreen,\n // prevent animation when crossing the boundary from large to small screen,\n // this prevents awkward animation in the edge case (resizing the browser, instead of starting at a given size)\n invisible: isSmallScreen && !ready,\n 'transition-[transform] duration-300 visible': isSmallScreen && ready,\n 'border-r-2 border-black/[.08] ': !showBackdrop,\n },\n props.className\n );\n\n React.useEffect(() => {\n // ensure state is updated in the next cpu tick so that the animation definitely doesn't run\n setTimeout(() => {\n setReady(isSmallScreen);\n }, 1);\n }, [isSmallScreen]);\n\n const toggleSidebar = () => setSidebarOpen(open => !open);\n const content = typeof children === 'function' ? children({ isLargeScreen, open: sidebarOpen, toggleSidebar }) : children;\n\n if (!content) {\n return null;\n }\n\n return (\n <>\n <nav {...attributes} data-responsive={isSmallScreen} aria-hidden={!isVisible} className={className} ref={ref}>\n {content}\n </nav>\n <AnimatePresence>\n {showBackdrop && (\n <SidebarBackdrop\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n className=\"z-[1]\"\n onClick={() => setSidebarOpen(false)}\n />\n )}\n </AnimatePresence>\n </>\n );\n});\n"],"names":["SidebarBackdrop","motion","Backdrop","Sidebar","React","forwardRef","LayoutSidebar","props","ref","children","attributes","sidebarOpen","setSidebarOpen","useContext","LayoutContext","isLargeScreen","useIsLargeScreen","isSmallScreen","isVisible","useEffect","handleEscapeKey","event","key","preventDefault","stopPropagation","window","addEventListener","removeEventListener","showBackdrop","ready","setReady","useState","className","cn","invisible","setTimeout","toggleSidebar","open","content","AnimatePresence","initial","opacity","animate","exit","onClick"],"mappings":";;;;;;;AAOA,MAAMA,eAAe,gBAAGC,MAAM,CAAgBC,QAAQ,CAAC;MAI1CC,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;EACzG,MAAM;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGH,KAAK;EACzC,MAAM;IAAEI,WAAW;IAAEC;GAAgB,GAAGR,cAAK,CAACS,UAAU,CAACC,aAAa,CAAC;EACvE,MAAMC,aAAa,GAAGC,gBAAgB,EAAE;EACxC,MAAMC,aAAa,GAAG,CAACF,aAAa;;EAGpC,MAAMG,SAAS,GAAGH,aAAa,IAAIJ,WAAW;;EAG9CP,cAAK,CAACe,SAAS,CAAC;IACZP,cAAc,CAACG,aAAa,CAAC;GAChC,EAAE,CAACA,aAAa,CAAC,CAAC;EAEnBX,cAAK,CAACe,SAAS,CAAC;IACZ,MAAMC,eAA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lC,yEACIA,sDAASM,UAAU;uBAAmBO,aAAa;mBAAe,CAACC,SAAS;IAAEc,SAAS,EAAEA,SAAS;IAAExB,GAAG,EAAEA;MACpG8B,OAAO,CACN,eACNlC,6BAACmC,eAAe,QACXX,YAAY,
|
1
|
+
{"version":3,"file":"Sidebar.js","sources":["../../../../../../../../src/components/Layout/components/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'clsx';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { LayoutContext } from './Context';\nimport { useIsLargeScreen } from '../../../hooks/useIsLargeScreen';\nimport { Backdrop, BackdropProps } from '../../Backdrop/Backdrop';\n\nconst SidebarBackdrop = motion<BackdropProps>(Backdrop);\n\nexport type LayoutSidebarProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const Sidebar = React.forwardRef<HTMLDivElement, LayoutSidebarProps>(function LayoutSidebar(props, ref) {\n const { children, ...attributes } = props;\n const { sidebarOpen, setSidebarOpen } = React.useContext(LayoutContext);\n const isLargeScreen = useIsLargeScreen();\n const isSmallScreen = !isLargeScreen;\n\n // if it's a large screen we override the open state and make it always visible\n const isVisible = isLargeScreen || sidebarOpen;\n\n // ensures the menu is always closed by default when resizing to a smaller window size\n React.useEffect(() => {\n setSidebarOpen(isLargeScreen);\n }, [isLargeScreen]);\n\n React.useEffect(() => {\n const handleEscapeKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n setSidebarOpen(false);\n }\n };\n\n if (isSmallScreen && sidebarOpen) {\n window.addEventListener('keydown', handleEscapeKey);\n }\n\n return () => {\n window.removeEventListener('keydown', handleEscapeKey);\n };\n }, [isSmallScreen, sidebarOpen]);\n\n const showBackdrop = isSmallScreen && sidebarOpen === true;\n\n const [ready, setReady] = React.useState(isSmallScreen);\n\n const className = cn(\n 'bg-grey-50 h-full w-64 flex-shrink-0 flex-grow-0 print:hidden',\n {\n 'absolute z-10 aria-hidden:-translate-x-64 ': isSmallScreen,\n // prevent animation when crossing the boundary from large to small screen,\n // this prevents awkward animation in the edge case (resizing the browser, instead of starting at a given size)\n invisible: isSmallScreen && !ready,\n 'transition-[transform] duration-300 visible': isSmallScreen && ready,\n 'border-r-2 border-black/[.08] ': !showBackdrop,\n },\n props.className\n );\n\n React.useEffect(() => {\n // ensure state is updated in the next cpu tick so that the animation definitely doesn't run\n setTimeout(() => {\n setReady(isSmallScreen);\n }, 1);\n }, [isSmallScreen]);\n\n const toggleSidebar = () => setSidebarOpen(open => !open);\n const content = typeof children === 'function' ? children({ isLargeScreen, open: sidebarOpen, toggleSidebar }) : children;\n\n if (!content) {\n return null;\n }\n\n return (\n <>\n <nav {...attributes} data-responsive={isSmallScreen} aria-hidden={!isVisible} className={className} ref={ref}>\n {content}\n </nav>\n <AnimatePresence>\n {showBackdrop && (\n <SidebarBackdrop\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n className=\"z-[1]\"\n onClick={() => setSidebarOpen(false)}\n />\n )}\n </AnimatePresence>\n </>\n );\n});\n"],"names":["SidebarBackdrop","motion","Backdrop","Sidebar","React","forwardRef","LayoutSidebar","props","ref","children","attributes","sidebarOpen","setSidebarOpen","useContext","LayoutContext","isLargeScreen","useIsLargeScreen","isSmallScreen","isVisible","useEffect","handleEscapeKey","event","key","preventDefault","stopPropagation","window","addEventListener","removeEventListener","showBackdrop","ready","setReady","useState","className","cn","invisible","setTimeout","toggleSidebar","open","content","AnimatePresence","initial","opacity","animate","exit","onClick"],"mappings":";;;;;;;AAOA,MAAMA,eAAe,gBAAGC,MAAM,CAAgBC,QAAQ,CAAC;MAI1CC,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAaA,CAACC,KAAK,EAAEC,GAAG;EACzG,MAAM;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGH,KAAK;EACzC,MAAM;IAAEI,WAAW;IAAEC;GAAgB,GAAGR,cAAK,CAACS,UAAU,CAACC,aAAa,CAA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aAAa,GAAGA,MAAMxB,cAAc,CAACyB,IAAI,IAAI,CAACA,IAAI,CAAC;EACzD,MAAMC,OAAO,GAAG,OAAO7B,QAAQ,KAAK,UAAU,GAAGA,QAAQ,CAAC;IAAEM,aAAa;IAAEsB,IAAI,EAAE1B,WAAW;IAAEyB;GAAe,CAAC,GAAG3B,QAAQ;EAEzH,IAAI,CAAC6B,OAAO,EAAE;IACV,OAAO,IAAI;;EAGf,oBACIlC,yEACIA,sDAASM,UAAU;uBAAmBO,aAAa;mBAAe,CAACC,SAAS;IAAEc,SAAS,EAAEA,SAAS;IAAExB,GAAG,EAAEA;MACpG8B,OAAO,CACN,eACNlC,6BAACmC,eAAe,QACXX,YAAY,kBACTxB,6BAACJ,eAAe;IACZwC,OAAO,EAAE;MAAEC,OAAO,EAAE;KAAG;IACvBC,OAAO,EAAE;MAAED,OAAO,EAAE;KAAG;IACvBE,IAAI,EAAE;MAAEF,OAAO,EAAE;KAAG;IACpBT,SAAS,EAAC,OAAO;IACjBY,OAAO,EAAEA,MAAMhC,cAAc,CAAC,KAAK;IACrC,CACL,CACa,CACnB;AAEX,CAAC;;;;"}
|
@@ -21,7 +21,7 @@ const Item = /*#__PURE__*/React__default.forwardRef(function Item(props, ref) {
|
|
21
21
|
"data-taco": "list-item",
|
22
22
|
ref: ref,
|
23
23
|
tabIndex: disabled ? -1 : tabIndex
|
24
|
-
}), icon ? (
|
24
|
+
}), icon ? (/*#__PURE__*/React__default.createElement("span", {
|
25
25
|
className: iconClassName
|
26
26
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
27
27
|
name: icon
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Item.js","sources":["../../../../../../../../src/components/List/components/Item.tsx"],"sourcesContent":["import React from 'react';\nimport clsx from 'clsx';\nimport { Icon, IconName } from '../../Icon/Icon';\nimport { Color } from '../../../types';\nimport { getSubtleColorShadeClasses } from '../../../utils/tailwind';\n\nexport type ListItemProps<ElementType extends React.ElementType> = Omit<React.ComponentPropsWithoutRef<ElementType>, 'title'> & {\n as?: ElementType;\n color?: Color;\n control?: JSX.Element;\n description?: string | JSX.Element;\n disabled?: boolean;\n icon?: IconName;\n title: string | JSX.Element;\n};\n\nexport type ComposableListItemProps<ElementType extends React.ElementType> = Omit<\n ListItemProps<ElementType>,\n 'as' | 'control' | 'onChange'\n>;\n\nexport const Item = React.forwardRef<HTMLElement, ListItemProps<React.ElementType>>(function Item(props, ref) {\n const { as: Tag = 'div', control, description, disabled, icon, color, tabIndex = 0, title, ...attributes } = props;\n const iconClassName = clsx(\n 'flex shrink-0 h-10 w-10 items-center justify-center rounded-md border border-black/10',\n getSubtleColorShadeClasses(color ?? 'transparent')\n );\n\n return (\n <Tag\n {...attributes}\n aria-disabled={disabled ? true : undefined}\n data-taco=\"list-item\"\n ref={ref as any}\n tabIndex={disabled ? -1 : tabIndex}>\n {icon ? (\n <span className={iconClassName}>\n <Icon name={icon} />\n </span>\n ) : null}\n <div className=\"flex grow flex-col justify-center\">\n <span className=\"font-bold text-black\">{title}</span>\n {description ? <span className=\"text-grey-700\">{description}</span> : null}\n </div>\n <div className=\"text-grey-700 flex shrink-0 items-center\">{control}</div>\n </Tag>\n );\n});\n"],"names":["Item","React","forwardRef","props","ref","as","Tag","control","description","disabled","icon","color","tabIndex","title","attributes","iconClassName","clsx","getSubtleColorShadeClasses","undefined","className","Icon","name"],"mappings":";;;;;MAqBaA,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAgD,SAASF,IAAIA,CAACG,KAAK,EAAEC,GAAG;EACxG,MAAM;IAAEC,EAAE,EAAEC,GAAG,GAAG,KAAK;IAAEC,OAAO;IAAEC,WAAW;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,KAAK;IAAEC,QAAQ,GAAG,CAAC;IAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGX,KAAK;EAClH,MAAMY,aAAa,GAAGC,EAAI,CACtB,uFAAuF,EACvFC,0BAA0B,CAACN,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,aAAa,CAAC,CACrD;EAED,oBACIV,6BAACK,GAAG,oBACIQ,UAAU;qBACCL,QAAQ,GAAG,IAAI,GAAGS,SAAS;iBAChC,WAAW;IACrBd,GAAG,EAAEA,GAAU;IACfQ,QAAQ,EAAEH,QAAQ,GAAG,CAAC,CAAC,GAAGG;MACzBF,IAAI,
|
1
|
+
{"version":3,"file":"Item.js","sources":["../../../../../../../../src/components/List/components/Item.tsx"],"sourcesContent":["import React from 'react';\nimport clsx from 'clsx';\nimport { Icon, IconName } from '../../Icon/Icon';\nimport { Color } from '../../../types';\nimport { getSubtleColorShadeClasses } from '../../../utils/tailwind';\n\nexport type ListItemProps<ElementType extends React.ElementType> = Omit<React.ComponentPropsWithoutRef<ElementType>, 'title'> & {\n as?: ElementType;\n color?: Color;\n control?: JSX.Element;\n description?: string | JSX.Element;\n disabled?: boolean;\n icon?: IconName;\n title: string | JSX.Element;\n};\n\nexport type ComposableListItemProps<ElementType extends React.ElementType> = Omit<\n ListItemProps<ElementType>,\n 'as' | 'control' | 'onChange'\n>;\n\nexport const Item = React.forwardRef<HTMLElement, ListItemProps<React.ElementType>>(function Item(props, ref) {\n const { as: Tag = 'div', control, description, disabled, icon, color, tabIndex = 0, title, ...attributes } = props;\n const iconClassName = clsx(\n 'flex shrink-0 h-10 w-10 items-center justify-center rounded-md border border-black/10',\n getSubtleColorShadeClasses(color ?? 'transparent')\n );\n\n return (\n <Tag\n {...attributes}\n aria-disabled={disabled ? true : undefined}\n data-taco=\"list-item\"\n ref={ref as any}\n tabIndex={disabled ? -1 : tabIndex}>\n {icon ? (\n <span className={iconClassName}>\n <Icon name={icon} />\n </span>\n ) : null}\n <div className=\"flex grow flex-col justify-center\">\n <span className=\"font-bold text-black\">{title}</span>\n {description ? <span className=\"text-grey-700\">{description}</span> : null}\n </div>\n <div className=\"text-grey-700 flex shrink-0 items-center\">{control}</div>\n </Tag>\n );\n});\n"],"names":["Item","React","forwardRef","props","ref","as","Tag","control","description","disabled","icon","color","tabIndex","title","attributes","iconClassName","clsx","getSubtleColorShadeClasses","undefined","className","Icon","name"],"mappings":";;;;;MAqBaA,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAgD,SAASF,IAAIA,CAACG,KAAK,EAAEC,GAAG;EACxG,MAAM;IAAEC,EAAE,EAAEC,GAAG,GAAG,KAAK;IAAEC,OAAO;IAAEC,WAAW;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,KAAK;IAAEC,QAAQ,GAAG,CAAC;IAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGX,KAAK;EAClH,MAAMY,aAAa,GAAGC,EAAI,CACtB,uFAAuF,EACvFC,0BAA0B,CAACN,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,aAAa,CAAC,CACrD;EAED,oBACIV,6BAACK,GAAG,oBACIQ,UAAU;qBACCL,QAAQ,GAAG,IAAI,GAAGS,SAAS;iBAChC,WAAW;IACrBd,GAAG,EAAEA,GAAU;IACfQ,QAAQ,EAAEH,QAAQ,GAAG,CAAC,CAAC,GAAGG;MACzBF,IAAI,iBACDT;IAAMkB,SAAS,EAAEJ;kBACbd,6BAACmB,IAAI;IAACC,IAAI,EAAEX;IAAQ,CACjB,IACP,IAAI,eACRT;IAAKkB,SAAS,EAAC;kBACXlB;IAAMkB,SAAS,EAAC;KAAwBN,KAAK,CAAQ,EACpDL,WAAW,gBAAGP;IAAMkB,SAAS,EAAC;KAAiBX,WAAW,CAAQ,GAAG,IAAI,CACxE,eACNP;IAAKkB,SAAS,EAAC;KAA4CZ,OAAO,CAAO,CACvE;AAEd,CAAC;;;;"}
|
@@ -140,7 +140,7 @@ const ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, re
|
|
140
140
|
};
|
141
141
|
return /*#__PURE__*/createElement("ul", Object.assign({}, list, {
|
142
142
|
"data-taco": "scrollable-list"
|
143
|
-
}), loading ? (
|
143
|
+
}), loading ? (/*#__PURE__*/createElement("li", {
|
144
144
|
className: "yt-list__empty"
|
145
145
|
}, /*#__PURE__*/createElement("span", null, /*#__PURE__*/createElement(Spinner, {
|
146
146
|
delay: 0
|
@@ -148,9 +148,9 @@ const ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, re
|
|
148
148
|
children,
|
149
149
|
icon,
|
150
150
|
...optionProps
|
151
|
-
}) => (
|
151
|
+
}) => (/*#__PURE__*/createElement("li", Object.assign({}, optionProps), icon, /*#__PURE__*/createElement("span", {
|
152
152
|
className: "flex-grow truncate text-left"
|
153
|
-
}, children), multiselect && (
|
153
|
+
}, children), multiselect && (/*#__PURE__*/createElement(Checkbox
|
154
154
|
// In multiselect variant, this checkbox only acts as visual representation of item being selected,
|
155
155
|
// so need to be taken out of screen reader scope.
|
156
156
|
, {
|
@@ -159,7 +159,7 @@ const ScrollableList = /*#__PURE__*/forwardRef(function ScrollableList(props, re
|
|
159
159
|
checked: optionProps['aria-selected'],
|
160
160
|
onChange: () => null,
|
161
161
|
className: "pointer-events-none ml-2 self-center p-px"
|
162
|
-
}))))) : (
|
162
|
+
}))))) : (/*#__PURE__*/createElement("li", {
|
163
163
|
className: "yt-list__empty"
|
164
164
|
}, /*#__PURE__*/createElement("span", null, texts.listbox.empty))));
|
165
165
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ScrollableList.js","sources":["../../../../../../../src/components/Listbox/ScrollableList.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { getNextIndexFromKey } from '../../utils/hooks/useListKeyboardNavigation';\nimport { useListScrollTo } from '../../utils/hooks/useListScrollTo';\nimport './ScrollableList.css';\nimport { Spinner } from '../Spinner/Spinner';\nimport { useLocalization } from '../Provider/Localization';\nimport { Checkbox } from '../Checkbox/Checkbox';\nimport { getInputClasses } from '../Input/util';\n\nexport type ScrollableListItemValue = string | number | boolean | null;\n\nexport type ScrollableListItem = {\n /**\n * Set whether the item is disabled.\n * This will both change the style and make the item unselectable\n */\n disabled?: boolean;\n /* Specifies whether the item has child items -- intended for internal use only */\n hasChildren?: boolean;\n /** Place an icon before the item's text */\n icon?: React.ReactElement;\n /* The index path to the item -- intended for internal use only */\n path?: string;\n /** Text describing the item */\n text: string | JSX.Element;\n /** Value of the item */\n value: ScrollableListItemValue;\n /** Child items to show hierarchical data */\n children?: ScrollableListItem[];\n};\n\n/** @internal */\nexport type ScrollableListProps = Omit<\n React.HTMLAttributes<HTMLUListElement>,\n 'defaultValue' | 'id' | 'onChange' | 'onClick' | 'onKeyDown'\n> & {\n /** Data indicating the options in scrollable list */\n data: ScrollableListItem[];\n /** Sets the list to be disabled */\n disabled?: boolean;\n /** Draws attention to the scrollable list by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Set an id for the scrollable list */\n id: string;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in `Provider` component.\n */\n loading?: boolean;\n /**\n * Handler called when current active/selected option changes in a scrollable list.\n * @param index indicates the index of the current active option\n */\n onChange: (index: number) => void;\n /** Handler called when option is clicked */\n onClick?: (event: React.MouseEvent<HTMLLIElement>, index: number) => void;\n /**\n * Set whether the selected item should be scrolled into view when listbox is focused.\n * Default value is `false`\n */\n scrollOnFocus?: boolean;\n /** Handler called when a key is pressed */\n onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>, index: number | undefined) => void;\n /* Sets the list to read only mode */\n readOnly?: boolean;\n /**\n * Value of the scrollable list representing the selected item.\n * It needs to be an existing value from the provided data.\n */\n value: number | undefined;\n /**\n * Allows to select multiple items from the list\n */\n multiselect?: boolean;\n /**\n * Contains the currently selected values when multiselect mode is ON.\n */\n selectedIndexes?: number[];\n /**\n * True when all available (not disabled) options are selected\n */\n allOptionsSelected?: boolean;\n};\n\n/** @internal */\nexport type ScrollableListPropsWithRef = ScrollableListProps & React.RefAttributes<HTMLUListElement>;\n\nexport const getId = (id: string, value: ScrollableListItemValue): string => `${id}_${value}`;\n\nconst getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n data: ScrollableListItem[],\n index: number | undefined\n): number | undefined => {\n const nextIndex = getNextIndexFromKey(event.key, data.length, index);\n\n if (nextIndex) {\n if (nextIndex === index) {\n return index;\n } else if (data[nextIndex] && data[nextIndex].disabled) {\n return getNextEnabledItem(event, data, nextIndex);\n }\n }\n\n return nextIndex;\n};\n\nexport const ScrollableList = React.forwardRef(function ScrollableList(\n props: ScrollableListProps,\n ref: React.Ref<HTMLUListElement>\n) {\n const {\n data,\n disabled,\n highlighted,\n id,\n invalid: _,\n loading,\n onChange: setCurrentIndex,\n onClick,\n onFocus,\n onKeyDown,\n readOnly,\n scrollOnFocus = false,\n value: currentIndex,\n multiselect,\n selectedIndexes = [],\n allOptionsSelected = false,\n ...otherProps\n } = props;\n const listRef = useMergedRef<HTMLUListElement>(ref);\n const itemRefs = React.useMemo(() => data.map(() => React.createRef<HTMLLIElement>()), [data]);\n const { texts } = useLocalization();\n const { scrollTo } = useListScrollTo(listRef, itemRefs);\n\n React.useEffect(() => {\n if (currentIndex && itemRefs[currentIndex]?.current) {\n itemRefs[currentIndex].current?.scrollIntoView({\n block: 'center',\n });\n }\n }, []);\n\n React.useEffect(() => {\n scrollTo(currentIndex);\n }, [currentIndex]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>): void => {\n const nextIndex = getNextEnabledItem(event, data, currentIndex);\n\n if (nextIndex !== undefined && nextIndex !== currentIndex) {\n event.preventDefault();\n scrollTo(nextIndex);\n setCurrentIndex(nextIndex);\n }\n\n if (onKeyDown) {\n event.persist();\n const index = nextIndex !== undefined ? nextIndex : currentIndex;\n onKeyDown(event, index);\n }\n\n // Stops the keyboard event from propagating so that keyboard event on other components outside the scrollable\n // list are not executed.\n event.stopPropagation();\n };\n\n const handleClick = (index: number) => (event: React.MouseEvent<HTMLLIElement>) => {\n setCurrentIndex(index);\n\n if (onClick) {\n event.persist();\n onClick(event, index);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLUListElement>): void => {\n if (scrollOnFocus) {\n scrollTo(currentIndex);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const getOptionCheckedState = (optionValue: string, index: number): boolean => {\n if (optionValue === '#ALL-OPTIONS#') {\n return allOptionsSelected;\n } else if (!optionValue || !selectedIndexes) {\n return false;\n } else {\n return selectedIndexes.findIndex(i => i === index) !== -1;\n }\n };\n\n const options = data.map((option, index) => {\n const depth = option.path ? option.path.split('.').length - 1 : 0;\n\n return {\n 'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,\n 'data-focused': currentIndex === index,\n children: option.text,\n className: cn(\n 'flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue-500 focus:border-blue-500',\n {\n 'sticky top-0 font-bold': depth === 0 && !!option.hasChildren,\n }\n ),\n disabled: option.disabled,\n icon: option.icon,\n id: getId(id, option.value),\n key: getId(id, option.value),\n onClick: !disabled && !readOnly ? handleClick(index) : undefined,\n ref: itemRefs[index],\n role: 'option',\n style:\n depth > 0\n ? {\n paddingLeft: `${depth + 1}rem`,\n }\n : undefined,\n };\n });\n\n const list: React.HTMLAttributes<HTMLUListElement> &\n React.RefAttributes<HTMLUListElement> & { disabled?: boolean; readOnly?: boolean } = {\n ...otherProps,\n className: cn(\n 'inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto',\n getInputClasses(props),\n {\n 'yt-list--multiselect': multiselect,\n 'pointer-events-none': disabled,\n 'cursor-not-allowed': disabled || readOnly,\n },\n otherProps.className\n ),\n disabled,\n id,\n onFocus: !disabled && !readOnly ? handleFocus : undefined,\n onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,\n readOnly,\n ref: listRef,\n role: options.length <= 0 || loading ? 'presentation' : 'listbox',\n tabIndex: otherProps.tabIndex || 0,\n };\n\n return (\n <ul {...list} data-taco=\"scrollable-list\">\n {loading ? (\n <li className=\"yt-list__empty\">\n <span>\n <Spinner delay={0} />\n </span>\n <span>{texts.listbox.loading}</span>\n </li>\n ) : options.length ? (\n options.map(({ children, icon, ...optionProps }) => (\n <li {...optionProps}>\n {icon}\n <span className=\"flex-grow truncate text-left\">{children}</span>\n {multiselect && (\n <Checkbox\n // In multiselect variant, this checkbox only acts as visual representation of item being selected,\n // so need to be taken out of screen reader scope.\n aria-hidden\n tabIndex={-1}\n checked={optionProps['aria-selected']}\n onChange={() => null}\n className=\"pointer-events-none ml-2 self-center p-px\"\n />\n )}\n </li>\n ))\n ) : (\n <li className=\"yt-list__empty\">\n <span>{texts.listbox.empty}</span>\n </li>\n )}\n </ul>\n );\n});\n"],"names":["getId","id","value","getNextEnabledItem","event","data","index","nextIndex","getNextIndexFromKey","key","length","disabled","ScrollableList","React","props","ref","highlighted","invalid","_","loading","onChange","setCurrentIndex","onClick","onFocus","onKeyDown","readOnly","scrollOnFocus","currentIndex","multiselect","selectedIndexes","allOptionsSelected","otherProps","listRef","useMergedRef","itemRefs","map","texts","useLocalization","scrollTo","useListScrollTo","_itemRefs$currentInde","current","_itemRefs$currentInde2","scrollIntoView","block","handleKeyDown","undefined","preventDefault","persist","stopPropagation","handleClick","handleFocus","getOptionCheckedState","optionValue","findIndex","i","options","option","depth","path","split","String","children","text","className","cn","hasChildren","icon","role","style","paddingLeft","list","getInputClasses","tabIndex","Spinner","delay","listbox","optionProps","Checkbox","checked","empty"],"mappings":";;;;;;;;;;MA2FaA,KAAK,GAAGA,CAACC,EAAU,EAAEC,KAA8B,QAAgBD,MAAMC;AAEtF,MAAMC,kBAAkB,GAAGA,CACvBC,KAAuC,EACvCC,IAA0B,EAC1BC,KAAyB;EAEzB,MAAMC,SAAS,GAAGC,mBAAmB,CAACJ,KAAK,CAACK,GAAG,EAAEJ,IAAI,CAACK,MAAM,EAAEJ,KAAK,CAAC;EAEpE,IAAIC,SAAS,EAAE;IACX,IAAIA,SAAS,KAAKD,KAAK,EAAE;MACrB,OAAOA,KAAK;KACf,MAAM,IAAID,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CAACI,KAAK,CAAQ,CACjC,CACR,CACA;AAEb,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"ScrollableList.js","sources":["../../../../../../../src/components/Listbox/ScrollableList.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'clsx';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { getNextIndexFromKey } from '../../utils/hooks/useListKeyboardNavigation';\nimport { useListScrollTo } from '../../utils/hooks/useListScrollTo';\nimport './ScrollableList.css';\nimport { Spinner } from '../Spinner/Spinner';\nimport { useLocalization } from '../Provider/Localization';\nimport { Checkbox } from '../Checkbox/Checkbox';\nimport { getInputClasses } from '../Input/util';\n\nexport type ScrollableListItemValue = string | number | boolean | null;\n\nexport type ScrollableListItem = {\n /**\n * Set whether the item is disabled.\n * This will both change the style and make the item unselectable\n */\n disabled?: boolean;\n /* Specifies whether the item has child items -- intended for internal use only */\n hasChildren?: boolean;\n /** Place an icon before the item's text */\n icon?: React.ReactElement;\n /* The index path to the item -- intended for internal use only */\n path?: string;\n /** Text describing the item */\n text: string | JSX.Element;\n /** Value of the item */\n value: ScrollableListItemValue;\n /** Child items to show hierarchical data */\n children?: ScrollableListItem[];\n};\n\n/** @internal */\nexport type ScrollableListProps = Omit<\n React.HTMLAttributes<HTMLUListElement>,\n 'defaultValue' | 'id' | 'onChange' | 'onClick' | 'onKeyDown'\n> & {\n /** Data indicating the options in scrollable list */\n data: ScrollableListItem[];\n /** Sets the list to be disabled */\n disabled?: boolean;\n /** Draws attention to the scrollable list by changing its style and making it visually prominent */\n highlighted?: boolean;\n /** Set an id for the scrollable list */\n id: string;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n /**\n * Shows a loading indicator with a text next to it.\n * Read more about how to provide the text in `Provider` component.\n */\n loading?: boolean;\n /**\n * Handler called when current active/selected option changes in a scrollable list.\n * @param index indicates the index of the current active option\n */\n onChange: (index: number) => void;\n /** Handler called when option is clicked */\n onClick?: (event: React.MouseEvent<HTMLLIElement>, index: number) => void;\n /**\n * Set whether the selected item should be scrolled into view when listbox is focused.\n * Default value is `false`\n */\n scrollOnFocus?: boolean;\n /** Handler called when a key is pressed */\n onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>, index: number | undefined) => void;\n /* Sets the list to read only mode */\n readOnly?: boolean;\n /**\n * Value of the scrollable list representing the selected item.\n * It needs to be an existing value from the provided data.\n */\n value: number | undefined;\n /**\n * Allows to select multiple items from the list\n */\n multiselect?: boolean;\n /**\n * Contains the currently selected values when multiselect mode is ON.\n */\n selectedIndexes?: number[];\n /**\n * True when all available (not disabled) options are selected\n */\n allOptionsSelected?: boolean;\n};\n\n/** @internal */\nexport type ScrollableListPropsWithRef = ScrollableListProps & React.RefAttributes<HTMLUListElement>;\n\nexport const getId = (id: string, value: ScrollableListItemValue): string => `${id}_${value}`;\n\nconst getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n data: ScrollableListItem[],\n index: number | undefined\n): number | undefined => {\n const nextIndex = getNextIndexFromKey(event.key, data.length, index);\n\n if (nextIndex) {\n if (nextIndex === index) {\n return index;\n } else if (data[nextIndex] && data[nextIndex].disabled) {\n return getNextEnabledItem(event, data, nextIndex);\n }\n }\n\n return nextIndex;\n};\n\nexport const ScrollableList = React.forwardRef(function ScrollableList(\n props: ScrollableListProps,\n ref: React.Ref<HTMLUListElement>\n) {\n const {\n data,\n disabled,\n highlighted,\n id,\n invalid: _,\n loading,\n onChange: setCurrentIndex,\n onClick,\n onFocus,\n onKeyDown,\n readOnly,\n scrollOnFocus = false,\n value: currentIndex,\n multiselect,\n selectedIndexes = [],\n allOptionsSelected = false,\n ...otherProps\n } = props;\n const listRef = useMergedRef<HTMLUListElement>(ref);\n const itemRefs = React.useMemo(() => data.map(() => React.createRef<HTMLLIElement>()), [data]);\n const { texts } = useLocalization();\n const { scrollTo } = useListScrollTo(listRef, itemRefs);\n\n React.useEffect(() => {\n if (currentIndex && itemRefs[currentIndex]?.current) {\n itemRefs[currentIndex].current?.scrollIntoView({\n block: 'center',\n });\n }\n }, []);\n\n React.useEffect(() => {\n scrollTo(currentIndex);\n }, [currentIndex]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLUListElement>): void => {\n const nextIndex = getNextEnabledItem(event, data, currentIndex);\n\n if (nextIndex !== undefined && nextIndex !== currentIndex) {\n event.preventDefault();\n scrollTo(nextIndex);\n setCurrentIndex(nextIndex);\n }\n\n if (onKeyDown) {\n event.persist();\n const index = nextIndex !== undefined ? nextIndex : currentIndex;\n onKeyDown(event, index);\n }\n\n // Stops the keyboard event from propagating so that keyboard event on other components outside the scrollable\n // list are not executed.\n event.stopPropagation();\n };\n\n const handleClick = (index: number) => (event: React.MouseEvent<HTMLLIElement>) => {\n setCurrentIndex(index);\n\n if (onClick) {\n event.persist();\n onClick(event, index);\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLUListElement>): void => {\n if (scrollOnFocus) {\n scrollTo(currentIndex);\n }\n\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const getOptionCheckedState = (optionValue: string, index: number): boolean => {\n if (optionValue === '#ALL-OPTIONS#') {\n return allOptionsSelected;\n } else if (!optionValue || !selectedIndexes) {\n return false;\n } else {\n return selectedIndexes.findIndex(i => i === index) !== -1;\n }\n };\n\n const options = data.map((option, index) => {\n const depth = option.path ? option.path.split('.').length - 1 : 0;\n\n return {\n 'aria-selected': multiselect ? getOptionCheckedState(String(option.value), index) : currentIndex === index,\n 'data-focused': currentIndex === index,\n children: option.text,\n className: cn(\n 'flex items-center px-3 w-full cursor-pointer bg-white flex-[0_0_2rem] focus:wcag-blue-500 focus:border-blue-500',\n {\n 'sticky top-0 font-bold': depth === 0 && !!option.hasChildren,\n }\n ),\n disabled: option.disabled,\n icon: option.icon,\n id: getId(id, option.value),\n key: getId(id, option.value),\n onClick: !disabled && !readOnly ? handleClick(index) : undefined,\n ref: itemRefs[index],\n role: 'option',\n style:\n depth > 0\n ? {\n paddingLeft: `${depth + 1}rem`,\n }\n : undefined,\n };\n });\n\n const list: React.HTMLAttributes<HTMLUListElement> &\n React.RefAttributes<HTMLUListElement> & { disabled?: boolean; readOnly?: boolean } = {\n ...otherProps,\n className: cn(\n 'inline-flex flex-col list-none !p-0 m-0 overflow-y-auto h-auto',\n getInputClasses(props),\n {\n 'yt-list--multiselect': multiselect,\n 'pointer-events-none': disabled,\n 'cursor-not-allowed': disabled || readOnly,\n },\n otherProps.className\n ),\n disabled,\n id,\n onFocus: !disabled && !readOnly ? handleFocus : undefined,\n onKeyDown: !disabled && !readOnly ? handleKeyDown : undefined,\n readOnly,\n ref: listRef,\n role: options.length <= 0 || loading ? 'presentation' : 'listbox',\n tabIndex: otherProps.tabIndex || 0,\n };\n\n return (\n <ul {...list} data-taco=\"scrollable-list\">\n {loading ? (\n <li className=\"yt-list__empty\">\n <span>\n <Spinner delay={0} />\n </span>\n <span>{texts.listbox.loading}</span>\n </li>\n ) : options.length ? (\n options.map(({ children, icon, ...optionProps }) => (\n <li {...optionProps}>\n {icon}\n <span className=\"flex-grow truncate text-left\">{children}</span>\n {multiselect && (\n <Checkbox\n // In multiselect variant, this checkbox only acts as visual representation of item being selected,\n // so need to be taken out of screen reader scope.\n aria-hidden\n tabIndex={-1}\n checked={optionProps['aria-selected']}\n onChange={() => null}\n className=\"pointer-events-none ml-2 self-center p-px\"\n />\n )}\n </li>\n ))\n ) : (\n <li className=\"yt-list__empty\">\n <span>{texts.listbox.empty}</span>\n </li>\n )}\n </ul>\n );\n});\n"],"names":["getId","id","value","getNextEnabledItem","event","data","index","nextIndex","getNextIndexFromKey","key","length","disabled","ScrollableList","React","props","ref","highlighted","invalid","_","loading","onChange","setCurrentIndex","onClick","onFocus","onKeyDown","readOnly","scrollOnFocus","currentIndex","multiselect","selectedIndexes","allOptionsSelected","otherProps","listRef","useMergedRef","itemRefs","map","texts","useLocalization","scrollTo","useListScrollTo","_itemRefs$currentInde","current","_itemRefs$currentInde2","scrollIntoView","block","handleKeyDown","undefined","preventDefault","persist","stopPropagation","handleClick","handleFocus","getOptionCheckedState","optionValue","findIndex","i","options","option","depth","path","split","String","children","text","className","cn","hasChildren","icon","role","style","paddingLeft","list","getInputClasses","tabIndex","Spinner","delay","listbox","optionProps","Checkbox","checked","empty"],"mappings":";;;;;;;;;;MA2FaA,KAAK,GAAGA,CAACC,EAAU,EAAEC,KAA8B,KAAa,GAAGD,EAAE,IAAIC,KAAK;AAE3F,MAAMC,kBAAkB,GAAGA,CACvBC,KAAuC,EACvCC,IAA0B,EAC1BC,KAAyB;EAEzB,MAAMC,SAAS,GAAGC,mBAAmB,CAACJ,KAAK,CAACK,GAAG,EAAEJ,IAAI,CAACK,MAAM,EAAEJ,KAAK,CAAC;EAEpE,IAAIC,SAAS,EAAE;IACX,IAAIA,SAAS,KAAKD,KAAK,EAAE;MACrB,OAAOA,KAAK;KACf,MAAM,IAAID,IAAI,CAACE,SAAS,CAAC,IAAIF,IAAI,CAACE,SAAS,CAAC,CAACI,QAAQ,EAAE;MACpD,OAAOR,kBAAkB,CAACC,KAAK,EAAEC,IAAI,EAAEE,SAAS,CAAC;;;EAIzD,OAAOA,SAAS;AACpB,CAAC;MAEYK,cAAc,gBAAGC,UAAgB,CAAC,SAASD,cAAcA,CAClEE,KAA0B,EAC1BC,GAAgC;EAEhC,MAAM;IACFV,IAAI;IACJM,QAAQ;IACRK,WAAW;IACXf,EAAE;IACFgB,OAAO,EAAEC,CAAC;IACVC,OAAO;IACPC,QAAQ,EAAEC,eAAe;IACzBC,OAAO;IACPC,OAAO;IACPC,SAAS;IACTC,QAAQ;IACRC,aAAa,GAAG,KAAK;IACrBxB,KAAK,EAAEyB,YAAY;IACnBC,WAAW;IACXC,eAAe,GAAG,EAAE;IACpBC,kBAAkB,GAAG,KAAK;IAC1B,GAAGC;GACN,GAAGjB,KAAK;EACT,MAAMkB,OAAO,GAAGC,YAAY,CAAmBlB,GAAG,CAAC;EACnD,MAAMmB,QAAQ,GAAGrB,OAAa,CAAC,MAAMR,IAAI,CAAC8B,GAA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E;IAAK,CAClB,eACP9D,4BAAOuB,KAAK,CAACwC,OAAO,CAACzD,OAAO,CAAQ,CACnC,IACLqC,OAAO,CAAC9C,MAAM,GACd8C,OAAO,CAACrB,GAAG,CAAC,CAAC;IAAE2B,QAAQ;IAAEK,IAAI;IAAE,GAAGU;GAAa,mBAC3ChE,sCAAQgE,WAAW,GACdV,IAAI,eACLtD;IAAMmD,SAAS,EAAC;KAAgCF,QAAQ,CAAQ,EAC/DlC,WAAW,kBACRf,cAACiE;;;;;IAIGL,QAAQ,EAAE,CAAC,CAAC;IACZM,OAAO,EAAEF,WAAW,CAAC,eAAe,CAAC;IACrCzD,QAAQ,EAAEA,MAAM,IAAI;IACpB4C,SAAS,EAAC;IACZ,CACL,CACA,CACR,CAAC,iBAEFnD;IAAImD,SAAS,EAAC;kBACVnD,4BAAOuB,KAAK,CAACwC,OAAO,CAACI,KAAK,CAAQ,CACjC,CACR,CACA;AAEb,CAAC;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useMultiListbox.js","sources":["../../../../../../../src/components/Listbox/useMultiListbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport { useLocalization } from '../Provider/Localization';\nimport { ListboxProps } from './Listbox';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef, getIndexFromValue, getSelectedIndexesFromValue, findByValue, getActiveDescendant } from './util';\nimport { ScrollableListProps, ScrollableListItem, ScrollableListItemValue } from './ScrollableList';\nimport { useTypeahead } from './useTypeahead';\n\ntype useListbox = {\n list: ScrollableListProps;\n input: Omit<React.HTMLAttributes<HTMLInputElement>, 'defaultValue'>;\n};\n\nexport const useMultiListbox = (\n {\n data: externalData = [],\n defaultValue,\n disabled,\n emptyValue: _,\n id: nativeId,\n name,\n onClick,\n onChange,\n onFocus,\n onKeyDown,\n value,\n ...otherProps\n }: ListboxProps,\n ref: React.Ref<HTMLInputElement>\n): useListbox => {\n const { texts } = useLocalization();\n const id = React.useMemo(() => nativeId || uuid(), [nativeId]);\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const data = React.useMemo(() => {\n return [{ text: texts.listbox.allOption, value: '#ALL-OPTIONS#' }, ...externalData];\n }, [externalData]);\n const [currentIndex, setCurrentIndex] = React.useState(getIndexFromValue(data, value) || 0);\n const [allOptionsSelected, setAllOptionsSelected] = React.useState(false);\n const { getNextIndex } = useTypeahead({ data, currentIndex });\n const [selectedIndexes, setSelectedIndexes] = React.useState(getSelectedIndexesFromValue(data, value));\n\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByRef(inputRef.current, defaultValue.toString());\n }\n }, []);\n\n React.useEffect(() => {\n const selectableItemsCount = data.filter(item => !item.disabled).length - 1;\n\n if (selectableItemsCount === selectedIndexes.length) {\n setAllOptionsSelected(true);\n } else {\n setAllOptionsSelected(false);\n }\n }, [selectedIndexes, data]);\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n let newInputValue: ScrollableListItemValue = '';\n const currentInputValue = inputRef.current?.value;\n const currentValuesArray = currentInputValue?.split(',') || [];\n const optionAlreadySelected = currentValuesArray.findIndex(val => val === String(option.value)) !== -1;\n\n // Handling the select_all option\n if (option.value === '#ALL-OPTIONS#') {\n if (!allOptionsSelected) {\n newInputValue = data\n .filter((option, index) => index !== 0 && !option.disabled)\n .map(option => option.value)\n .join(',');\n } else {\n newInputValue = '';\n }\n } else {\n // Handling rest options\n if (optionAlreadySelected) {\n newInputValue = currentValuesArray.filter(val => val !== String(option.value)).join(',');\n } else {\n newInputValue = currentInputValue ? `${currentInputValue},${option.value}` : option.value;\n }\n }\n\n setInputValueByRef(inputRef.current, newInputValue);\n }\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n\n if (!data[index].disabled) {\n setCurrentIndex(index);\n setInputValueByIndex(index);\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>, index?: number): void => {\n const charKey = event.key;\n\n // event.key always returns the whole string (String.fromCharCode(event.keyCode) does not)\n // We need to filter out only alphabetical or numeric letters, that's why that condition has been changed\n if (charKey.length === 1 && /(\\w)/g.test(charKey)) {\n const nextIndex = getNextIndex(charKey);\n\n if (nextIndex > -1 && nextIndex !== currentIndex) {\n setCurrentIndex(nextIndex);\n }\n return;\n }\n\n switch (event.key) {\n case ' ': {\n event.preventDefault();\n setInputValueByIndex(index);\n break;\n }\n\n case 'Enter': {\n setInputValueByIndex(index);\n break;\n }\n\n default:\n }\n setCurrentIndex(index !== undefined ? index : 0);\n\n if (onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxFocus = (event: React.FocusEvent<HTMLElement>): void => {\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n setSelectedIndexes(getSelectedIndexesFromValue(data, event.target.value));\n\n if (onChange) {\n const detail: ScrollableListItem[] = [];\n const valuesArray = event.target.value.split(',');\n\n valuesArray.forEach(val => {\n const item = findByValue(data, val);\n if (item) {\n detail.push(item);\n }\n });\n (event as any).detail = detail;\n\n onChange(event);\n }\n };\n\n const list = {\n ...otherProps,\n 'aria-activedescendant': getActiveDescendant(data, currentIndex, id),\n 'aria-multiselectable': true,\n data,\n disabled,\n id,\n onChange: () => null,\n onClick: handleListboxClick,\n onFocus: handleListboxFocus,\n onKeyDown: handleListboxKeyDown,\n scrollOnFocus: false,\n tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,\n value: currentIndex,\n selectedIndexes,\n multiselect: true,\n allOptionsSelected,\n };\n\n const input = {\n name,\n onChange: handleInputChange,\n ref: inputRef,\n tabIndex: -1,\n value: value ?? '',\n };\n\n return { list, input };\n};\n"],"names":["useMultiListbox","data","externalData","defaultValue","disabled","emptyValue","_","id","nativeId","name","onClick","onChange","onFocus","onKeyDown","value","otherProps","ref","texts","useLocalization","React","uuid","inputRef","useMergedRef","text","listbox","allOption","currentIndex","setCurrentIndex","getIndexFromValue","allOptionsSelected","setAllOptionsSelected","getNextIndex","useTypeahead","selectedIndexes","setSelectedIndexes","getSelectedIndexesFromValue","setInputValueByRef","current","toString","selectableItemsCount","filter","item","length","setInputValueByIndex","index","undefined","option","_inputRef$current","newInputValue","currentInputValue","currentValuesArray","split","optionAlreadySelected","findIndex","val","String","map","join","handleListboxClick","event","preventDefault","handleListboxKeyDown","charKey","key","test","nextIndex","persist","handleListboxFocus","handleInputChange","target","detail","valuesArray","forEach","findByValue","push","list","getActiveDescendant","scrollOnFocus","tabIndex","multiselect","input"],"mappings":";;;;;;;MAcaA,eAAe,GAAGA,CAC3B;EACIC,IAAI,EAAEC,YAAY,GAAG,EAAE;EACvBC,YAAY;EACZC,QAAQ;EACRC,UAAU,EAAEC,CAAC;EACbC,EAAE,EAAEC,QAAQ;EACZC,IAAI;EACJC,OAAO;EACPC,QAAQ;EACRC,OAAO;EACPC,SAAS;EACTC,KAAK;EACL,GAAGC;CACQ,EACfC,GAAgC;EAEhC,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMX,EAAE,GAAGY,OAAa,CAAC,MAAMX,QAAQ,IAAIY,EAAI,EAAE,EAAE,CAACZ,QAAQ,CAAC,CAAC;EAC9D,MAAMa,QAAQ,GAAGC,YAAY,CAAmBN,GAAG,CAAC;EACpD,MAAMf,IAAI,GAAGkB,OAAa,CAAC;IACvB,OAAO,CAAC;MAAEI,IAAI,EAAEN,KAAK,CAACO,OAAO,CAACC,SAAS;MAAEX,KAAK,EAAE;KAAiB,EAAE,GAAGZ,YAAY,CAAC;GACtF,EAAE,CAACA,YAAY,CAAC,CAAC;EAClB,MAAM,CAACwB,YAAY,EAAEC,eAAe,CAAC,GAAGR,QAAc,CAACS,iBAAiB,CAAC3B,IAAI,EAAEa,KAAK,CAAC,IAAI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AW,CAACxE,IAAI,EAAEqD,GAAG,CAAC;QACnC,IAAIb,IAAI,EAAE;UACN6B,MAAM,CAACI,IAAI,CAACjC,IAAI,CAAC;;OAExB,CAAC;MACDkB,KAAa,CAACW,MAAM,GAAGA,MAAM;MAE9B3D,QAAQ,CAACgD,KAAK,CAAC;;GAEtB;EAED,MAAMgB,IAAI,GAAG;IACT,GAAG5D,UAAU;IACb,uBAAuB,EAAE6D,mBAAmB,CAAC3E,IAAI,EAAEyB,YAAY,EAAEnB,EAAE,CAAC;IACpE,sBAAsB,EAAE,IAAI;IAC5BN,IAAI;IACJG,QAAQ;IACRG,EAAE;IACFI,QAAQ,EAAEA,MAAM,IAAI;IACpBD,OAAO,EAAEgD,kBAAkB;IAC3B9C,OAAO,EAAEuD,kBAAkB;IAC3BtD,SAAS,EAAEgD,oBAAoB;IAC/BgB,aAAa,EAAE,KAAK;IACpBC,QAAQ,EAAE1E,QAAQ,GAAG,CAAC,CAAC,GAAGW,UAAU,CAAC+D,QAAQ,GAAG/D,UAAU,CAAC+D,QAAQ,GAAG,CAAC;IACvEhE,KAAK,EAAEY,YAAY;IACnBO,eAAe;IACf8C,WAAW,EAAE,IAAI;IACjBlD;GACH;EAED,MAAMmD,KAAK,GAAG;IACVvE,IAAI;IACJE,QAAQ,EAAEyD,iBAAiB;IAC3BpD,GAAG,EAAEK,QAAQ;IACbyD,QAAQ,EAAE,CAAC,CAAC;IACZhE,KAAK,EAAEA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI;GACnB;EAED,OAAO;IAAE6D,IAAI;IAAEK;GAAO;AAC1B;;;;"}
|
1
|
+
{"version":3,"file":"useMultiListbox.js","sources":["../../../../../../../src/components/Listbox/useMultiListbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { v4 as uuid } from 'uuid';\nimport { useLocalization } from '../Provider/Localization';\nimport { ListboxProps } from './Listbox';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef, getIndexFromValue, getSelectedIndexesFromValue, findByValue, getActiveDescendant } from './util';\nimport { ScrollableListProps, ScrollableListItem, ScrollableListItemValue } from './ScrollableList';\nimport { useTypeahead } from './useTypeahead';\n\ntype useListbox = {\n list: ScrollableListProps;\n input: Omit<React.HTMLAttributes<HTMLInputElement>, 'defaultValue'>;\n};\n\nexport const useMultiListbox = (\n {\n data: externalData = [],\n defaultValue,\n disabled,\n emptyValue: _,\n id: nativeId,\n name,\n onClick,\n onChange,\n onFocus,\n onKeyDown,\n value,\n ...otherProps\n }: ListboxProps,\n ref: React.Ref<HTMLInputElement>\n): useListbox => {\n const { texts } = useLocalization();\n const id = React.useMemo(() => nativeId || uuid(), [nativeId]);\n const inputRef = useMergedRef<HTMLInputElement>(ref);\n const data = React.useMemo(() => {\n return [{ text: texts.listbox.allOption, value: '#ALL-OPTIONS#' }, ...externalData];\n }, [externalData]);\n const [currentIndex, setCurrentIndex] = React.useState(getIndexFromValue(data, value) || 0);\n const [allOptionsSelected, setAllOptionsSelected] = React.useState(false);\n const { getNextIndex } = useTypeahead({ data, currentIndex });\n const [selectedIndexes, setSelectedIndexes] = React.useState(getSelectedIndexesFromValue(data, value));\n\n React.useEffect(() => {\n if (defaultValue && !value) {\n setInputValueByRef(inputRef.current, defaultValue.toString());\n }\n }, []);\n\n React.useEffect(() => {\n const selectableItemsCount = data.filter(item => !item.disabled).length - 1;\n\n if (selectableItemsCount === selectedIndexes.length) {\n setAllOptionsSelected(true);\n } else {\n setAllOptionsSelected(false);\n }\n }, [selectedIndexes, data]);\n\n const setInputValueByIndex = (index: number | undefined): void => {\n if (index !== undefined) {\n const option = data[index];\n\n if (option && !option.disabled) {\n let newInputValue: ScrollableListItemValue = '';\n const currentInputValue = inputRef.current?.value;\n const currentValuesArray = currentInputValue?.split(',') || [];\n const optionAlreadySelected = currentValuesArray.findIndex(val => val === String(option.value)) !== -1;\n\n // Handling the select_all option\n if (option.value === '#ALL-OPTIONS#') {\n if (!allOptionsSelected) {\n newInputValue = data\n .filter((option, index) => index !== 0 && !option.disabled)\n .map(option => option.value)\n .join(',');\n } else {\n newInputValue = '';\n }\n } else {\n // Handling rest options\n if (optionAlreadySelected) {\n newInputValue = currentValuesArray.filter(val => val !== String(option.value)).join(',');\n } else {\n newInputValue = currentInputValue ? `${currentInputValue},${option.value}` : option.value;\n }\n }\n\n setInputValueByRef(inputRef.current, newInputValue);\n }\n }\n };\n\n const handleListboxClick = (event: React.MouseEvent<HTMLLIElement>, index: number): void => {\n event.preventDefault();\n\n if (!data[index].disabled) {\n setCurrentIndex(index);\n setInputValueByIndex(index);\n }\n\n if (onClick) {\n onClick(event);\n }\n };\n\n const handleListboxKeyDown = (event: React.KeyboardEvent<HTMLElement>, index?: number): void => {\n const charKey = event.key;\n\n // event.key always returns the whole string (String.fromCharCode(event.keyCode) does not)\n // We need to filter out only alphabetical or numeric letters, that's why that condition has been changed\n if (charKey.length === 1 && /(\\w)/g.test(charKey)) {\n const nextIndex = getNextIndex(charKey);\n\n if (nextIndex > -1 && nextIndex !== currentIndex) {\n setCurrentIndex(nextIndex);\n }\n return;\n }\n\n switch (event.key) {\n case ' ': {\n event.preventDefault();\n setInputValueByIndex(index);\n break;\n }\n\n case 'Enter': {\n setInputValueByIndex(index);\n break;\n }\n\n default:\n }\n setCurrentIndex(index !== undefined ? index : 0);\n\n if (onKeyDown) {\n event.persist();\n onKeyDown(event);\n }\n };\n\n const handleListboxFocus = (event: React.FocusEvent<HTMLElement>): void => {\n if (onFocus) {\n event.persist();\n onFocus(event);\n }\n };\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {\n event.persist();\n\n setSelectedIndexes(getSelectedIndexesFromValue(data, event.target.value));\n\n if (onChange) {\n const detail: ScrollableListItem[] = [];\n const valuesArray = event.target.value.split(',');\n\n valuesArray.forEach(val => {\n const item = findByValue(data, val);\n if (item) {\n detail.push(item);\n }\n });\n (event as any).detail = detail;\n\n onChange(event);\n }\n };\n\n const list = {\n ...otherProps,\n 'aria-activedescendant': getActiveDescendant(data, currentIndex, id),\n 'aria-multiselectable': true,\n data,\n disabled,\n id,\n onChange: () => null,\n onClick: handleListboxClick,\n onFocus: handleListboxFocus,\n onKeyDown: handleListboxKeyDown,\n scrollOnFocus: false,\n tabIndex: disabled ? -1 : otherProps.tabIndex ? otherProps.tabIndex : 0,\n value: currentIndex,\n selectedIndexes,\n multiselect: true,\n allOptionsSelected,\n };\n\n const input = {\n name,\n onChange: handleInputChange,\n ref: inputRef,\n tabIndex: -1,\n value: value ?? '',\n };\n\n return { list, input };\n};\n"],"names":["useMultiListbox","data","externalData","defaultValue","disabled","emptyValue","_","id","nativeId","name","onClick","onChange","onFocus","onKeyDown","value","otherProps","ref","texts","useLocalization","React","uuid","inputRef","useMergedRef","text","listbox","allOption","currentIndex","setCurrentIndex","getIndexFromValue","allOptionsSelected","setAllOptionsSelected","getNextIndex","useTypeahead","selectedIndexes","setSelectedIndexes","getSelectedIndexesFromValue","setInputValueByRef","current","toString","selectableItemsCount","filter","item","length","setInputValueByIndex","index","undefined","option","_inputRef$current","newInputValue","currentInputValue","currentValuesArray","split","optionAlreadySelected","findIndex","val","String","map","join","handleListboxClick","event","preventDefault","handleListboxKeyDown","charKey","key","test","nextIndex","persist","handleListboxFocus","handleInputChange","target","detail","valuesArray","forEach","findByValue","push","list","getActiveDescendant","scrollOnFocus","tabIndex","multiselect","input"],"mappings":";;;;;;;MAcaA,eAAe,GAAGA,CAC3B;EACIC,IAAI,EAAEC,YAAY,GAAG,EAAE;EACvBC,YAAY;EACZC,QAAQ;EACRC,UAAU,EAAEC,CAAC;EACbC,EAAE,EAAEC,QAAQ;EACZC,IAAI;EACJC,OAAO;EACPC,QAAQ;EACRC,OAAO;EACPC,SAAS;EACTC,KAAK;EACL,GAAGC;CACQ,EACfC,GAAgC;EAEhC,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMX,EAAE,GAAGY,OAAa,CAAC,MAAMX,QAAQ,IAAIY,EAAI,EAAE,EAAE,CAACZ,Q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AAEK,QAAQ;IACbyD,QAAQ,EAAE,CAAC,CAAC;IACZhE,KAAK,EAAEA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI;GACnB;EAED,OAAO;IAAE6D,IAAI;IAAEK;GAAO;AAC1B;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../../../../../../../src/components/Listbox/util.ts"],"sourcesContent":["import React from 'react';\nimport { ScrollableListItem, ScrollableListItemValue, getId } from './ScrollableList';\nimport { setInputValueByRef as setInputValueByRefBase } from '../../utils/input';\n\nconst getValue = (value: ScrollableListItemValue | undefined): string => String(value ?? '');\n\nexport const setInputValueByRef = (input: HTMLInputElement | null, value: ScrollableListItemValue, event = 'change'): void => {\n setInputValueByRefBase(input, getValue(value), event);\n};\n\nexport const getIndexFromValue = (data: ScrollableListItem[], value: ScrollableListItemValue | undefined): number | undefined => {\n const index = data.findIndex(option => getValue(option.value) === getValue(value));\n return index > -1 ? index : undefined;\n};\n\nexport const getSelectedIndexesFromValue = (data: ScrollableListItem[], value: ScrollableListItemValue | undefined): number[] => {\n if (typeof value !== 'string') return [];\n\n return value\n .split(',')\n .map(v => data.findIndex(o => String(o.value) === v))\n .filter(v => v !== -1);\n};\n\nexport const findByValue = (data: ScrollableListItem[], value: ScrollableListItemValue): ScrollableListItem | undefined => {\n return data.find(option => getValue(option.value) === getValue(value));\n};\n\nexport const searchForString = (child: JSX.Element | string, value: string, strategy = 'includes'): boolean => {\n try {\n if (typeof child !== 'string' && child.props?.children) {\n if (Array.isArray(child.props?.children)) {\n return !!child.props.children.find((subChild: JSX.Element | string) =>\n searchForString(subChild, value, strategy)\n );\n }\n\n return searchForString(child.props?.children, value, strategy);\n } else {\n return child.toString().toLowerCase()[strategy](String(value).toLowerCase());\n }\n } catch {\n return false;\n }\n};\n\nconst getIndexInRangeByValue = (\n data: ScrollableListItem[],\n query: string,\n firstIndex: number,\n lastIndex: number = data.length\n): number => {\n const index = data.slice(firstIndex, lastIndex).findIndex(option => {\n if (option.disabled) {\n return false;\n }\n\n return searchForString(option.text, query, 'startsWith');\n });\n\n return index > -1 ? index + firstIndex : -1;\n};\n\nexport const findNextIndexByValue = (data: ScrollableListItem[], query: string, activeIndex: number | undefined): number => {\n const firstIndex = activeIndex === undefined ? 0 : activeIndex + 1;\n let index = getIndexInRangeByValue(data, query, firstIndex);\n\n if (index === -1) {\n index = getIndexInRangeByValue(data, query, 0, activeIndex);\n }\n\n return index;\n};\n\nexport const getActiveDescendant = (data: ScrollableListItem[], currentIndex: number | undefined, id: string): any => {\n return currentIndex !== undefined && data[currentIndex] ? getId(id, data[currentIndex].value) : undefined;\n};\n\nexport const useFlattenedData = (data: ScrollableListItem[]): ScrollableListItem[] => {\n return React.useMemo(() => {\n const items: ScrollableListItem[] = [];\n\n const flatten = (item: ScrollableListItem, path: number, parentPath?: string, parentDisabled?: boolean) => {\n const currentPath = parentPath ? `${parentPath}.${path}` : `${path}`;\n const isItemDisabled = parentDisabled || item.disabled;\n\n items.push({\n ...item,\n disabled: isItemDisabled,\n path: currentPath,\n hasChildren: !!item.children,\n });\n\n if (item.children) {\n item.children.forEach((childItem: ScrollableListItem, childPath: number) =>\n flatten(childItem, childPath, currentPath, isItemDisabled)\n );\n }\n };\n\n data.forEach((item, index) => {\n flatten(item, index);\n });\n\n return items;\n }, [data]);\n};\n\nexport const sanitizeItem = (item: ScrollableListItem | undefined) => {\n if (item) {\n const { hasChildren: _1, path: _2, ...rest } = item;\n return rest;\n }\n\n return undefined;\n};\n\nexport const getOptionParents = (data: ScrollableListItem[], path?: string) => {\n const indexes = path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n return indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(data.find((i: ScrollableListItem) => i.path === lastPath));\n });\n }\n\n return null;\n};\n\nexport const filterData = (data: ScrollableListItem[], value: ScrollableListItemValue = ''): ScrollableListItem[] => {\n if (value === '' || value === null) {\n return data;\n }\n\n const filteredOptionValues = new Set();\n const shouldFilterOption = (option: ScrollableListItem): boolean => {\n if (option.disabled) {\n return false;\n }\n\n return searchForString(option.text, String(value));\n };\n\n data.forEach(option => {\n if (shouldFilterOption(option)) {\n const parents = getOptionParents(data, option.path);\n\n filteredOptionValues.add(option.value);\n\n if (parents !== null) {\n parents.forEach(option => filteredOptionValues.add(option?.value));\n }\n }\n });\n\n return data.filter(({ value }) => filteredOptionValues.has(value));\n};\n"],"names":["getValue","value","String","setInputValueByRef","input","event","setInputValueByRefBase","getIndexFromValue","data","index","findIndex","option","undefined","getSelectedIndexesFromValue","split","map","v","o","filter","findByValue","find","searchForString","child","strategy","_child$props","props","children","_child$props2","_child$props3","Array","isArray","subChild","toString","toLowerCase","getIndexInRangeByValue","query","firstIndex","lastIndex","length","slice","disabled","text","findNextIndexByValue","activeIndex","getActiveDescendant","currentIndex","id","getId","useFlattenedData","React","useMemo","items","flatten","item","path","parentPath","parentDisabled","currentPath","isItemDisabled","push","hasChildren","forEach","childItem","childPath","sanitizeItem","_1","_2","rest","getOptionParents","indexes","_path$split","pop","lastPath","i","join","filterData","filteredOptionValues","Set","shouldFilterOption","parents","add","has"],"mappings":";;;;AAIA,MAAMA,QAAQ,GAAIC,KAA0C,IAAaC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE,CAAC;MAE/EE,kBAAkB,GAAGA,CAACC,KAA8B,EAAEH,KAA8B,EAAEI,KAAK,GAAG,QAAQ;EAC/GC,oBAAsB,CAACF,KAAK,EAAEJ,QAAQ,CAACC,KAAK,CAAC,EAAEI,KAAK,CAAC;AACzD;MAEaE,iBAAiB,GAAGA,CAACC,IAA0B,EAAEP,KAA0C;EACpG,MAAMQ,KAAK,GAAGD,IAAI,CAACE,SAAS,CAACC,MAAM,IAAIX,QAAQ,CAACW,MAAM,CAACV,KAAK,CAAC,KAAKD,QAAQ,CAACC,KAAK,CAA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,CAAClB,OAAO,CAAClD,MAAM,IAAIiE,oBAAoB,CAACI,GAAG,CAACrE,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEV,KAAK,CAAC,CAAC;;;GAG7E,CAAC;EAEF,OAAOO,IAAI,CAACU,MAAM,CAAC,CAAC;IAAEjB;GAAO,KAAK2E,oBAAoB,CAACK,GAAG,CAAChF,KAAK,CAAC,CAAC;AACtE;;;;"}
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../../../../../src/components/Listbox/util.ts"],"sourcesContent":["import React from 'react';\nimport { ScrollableListItem, ScrollableListItemValue, getId } from './ScrollableList';\nimport { setInputValueByRef as setInputValueByRefBase } from '../../utils/input';\n\nconst getValue = (value: ScrollableListItemValue | undefined): string => String(value ?? '');\n\nexport const setInputValueByRef = (input: HTMLInputElement | null, value: ScrollableListItemValue, event = 'change'): void => {\n setInputValueByRefBase(input, getValue(value), event);\n};\n\nexport const getIndexFromValue = (data: ScrollableListItem[], value: ScrollableListItemValue | undefined): number | undefined => {\n const index = data.findIndex(option => getValue(option.value) === getValue(value));\n return index > -1 ? index : undefined;\n};\n\nexport const getSelectedIndexesFromValue = (data: ScrollableListItem[], value: ScrollableListItemValue | undefined): number[] => {\n if (typeof value !== 'string') return [];\n\n return value\n .split(',')\n .map(v => data.findIndex(o => String(o.value) === v))\n .filter(v => v !== -1);\n};\n\nexport const findByValue = (data: ScrollableListItem[], value: ScrollableListItemValue): ScrollableListItem | undefined => {\n return data.find(option => getValue(option.value) === getValue(value));\n};\n\nexport const searchForString = (child: JSX.Element | string, value: string, strategy = 'includes'): boolean => {\n try {\n if (typeof child !== 'string' && child.props?.children) {\n if (Array.isArray(child.props?.children)) {\n return !!child.props.children.find((subChild: JSX.Element | string) =>\n searchForString(subChild, value, strategy)\n );\n }\n\n return searchForString(child.props?.children, value, strategy);\n } else {\n return child.toString().toLowerCase()[strategy](String(value).toLowerCase());\n }\n } catch {\n return false;\n }\n};\n\nconst getIndexInRangeByValue = (\n data: ScrollableListItem[],\n query: string,\n firstIndex: number,\n lastIndex: number = data.length\n): number => {\n const index = data.slice(firstIndex, lastIndex).findIndex(option => {\n if (option.disabled) {\n return false;\n }\n\n return searchForString(option.text, query, 'startsWith');\n });\n\n return index > -1 ? index + firstIndex : -1;\n};\n\nexport const findNextIndexByValue = (data: ScrollableListItem[], query: string, activeIndex: number | undefined): number => {\n const firstIndex = activeIndex === undefined ? 0 : activeIndex + 1;\n let index = getIndexInRangeByValue(data, query, firstIndex);\n\n if (index === -1) {\n index = getIndexInRangeByValue(data, query, 0, activeIndex);\n }\n\n return index;\n};\n\nexport const getActiveDescendant = (data: ScrollableListItem[], currentIndex: number | undefined, id: string): any => {\n return currentIndex !== undefined && data[currentIndex] ? getId(id, data[currentIndex].value) : undefined;\n};\n\nexport const useFlattenedData = (data: ScrollableListItem[]): ScrollableListItem[] => {\n return React.useMemo(() => {\n const items: ScrollableListItem[] = [];\n\n const flatten = (item: ScrollableListItem, path: number, parentPath?: string, parentDisabled?: boolean) => {\n const currentPath = parentPath ? `${parentPath}.${path}` : `${path}`;\n const isItemDisabled = parentDisabled || item.disabled;\n\n items.push({\n ...item,\n disabled: isItemDisabled,\n path: currentPath,\n hasChildren: !!item.children,\n });\n\n if (item.children) {\n item.children.forEach((childItem: ScrollableListItem, childPath: number) =>\n flatten(childItem, childPath, currentPath, isItemDisabled)\n );\n }\n };\n\n data.forEach((item, index) => {\n flatten(item, index);\n });\n\n return items;\n }, [data]);\n};\n\nexport const sanitizeItem = (item: ScrollableListItem | undefined) => {\n if (item) {\n const { hasChildren: _1, path: _2, ...rest } = item;\n return rest;\n }\n\n return undefined;\n};\n\nexport const getOptionParents = (data: ScrollableListItem[], path?: string) => {\n const indexes = path?.split('.') ?? [];\n\n if (indexes.length > 1) {\n // we don't want to map the current item\n indexes.pop();\n // we need to rebuild the path as we map\n let lastPath: string;\n\n return indexes.map(i => {\n lastPath = lastPath ? [lastPath, i].join('.') : i;\n return sanitizeItem(data.find((i: ScrollableListItem) => i.path === lastPath));\n });\n }\n\n return null;\n};\n\nexport const filterData = (data: ScrollableListItem[], value: ScrollableListItemValue = ''): ScrollableListItem[] => {\n if (value === '' || value === null) {\n return data;\n }\n\n const filteredOptionValues = new Set();\n const shouldFilterOption = (option: ScrollableListItem): boolean => {\n if (option.disabled) {\n return false;\n }\n\n return searchForString(option.text, String(value));\n };\n\n data.forEach(option => {\n if (shouldFilterOption(option)) {\n const parents = getOptionParents(data, option.path);\n\n filteredOptionValues.add(option.value);\n\n if (parents !== null) {\n parents.forEach(option => filteredOptionValues.add(option?.value));\n }\n }\n });\n\n return data.filter(({ value }) => filteredOptionValues.has(value));\n};\n"],"names":["getValue","value","String","setInputValueByRef","input","event","setInputValueByRefBase","getIndexFromValue","data","index","findIndex","option","undefined","getSelectedIndexesFromValue","split","map","v","o","filter","findByValue","find","searchForString","child","strategy","_child$props","props","children","_child$props2","_child$props3","Array","isArray","subChild","toString","toLowerCase","getIndexInRangeByValue","query","firstIndex","lastIndex","length","slice","disabled","text","findNextIndexByValue","activeIndex","getActiveDescendant","currentIndex","id","getId","useFlattenedData","React","useMemo","items","flatten","item","path","parentPath","parentDisabled","currentPath","isItemDisabled","push","hasChildren","forEach","childItem","childPath","sanitizeItem","_1","_2","rest","getOptionParents","indexes","_path$split","pop","lastPath","i","join","filterData","filteredOptionValues","Set","shouldFilterOption","parents","add","has"],"mappings":";;;;AAIA,MAAMA,QAAQ,GAAIC,KAA0C,IAAaC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE,CAAC;MAE/EE,kBAAkB,GAAGA,CAACC,KAA8B,EAAEH,KAA8B,EAAEI,KAAK,GAAG,QAAQ;EAC/GC,oBAAsB,CAACF,KAAK,EAAEJ,QAAQ,CAACC,KAAK,CAAC,EAAEI,KAAK,CAAC;AACzD;MAEaE,iBAAiB,GAAGA,CAACC,IAA0B,EAAEP,KAA0C;EACpG,MAAMQ,KAAK,GAAGD,IAAI,CAACE,SAAS,CAACC,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