@economic/taco 1.23.1 → 1.25.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Button/Button.d.ts +13 -0
- package/dist/components/Dialog/Dialog.d.ts +1 -1
- package/dist/components/Dialog/components/DialogDrawer.d.ts +10 -0
- package/dist/components/Drawer/Context.d.ts +18 -0
- package/dist/components/Drawer/Drawer.d.ts +51 -0
- package/dist/components/Drawer/components/Content.d.ts +53 -0
- package/dist/components/Drawer/components/Trigger.d.ts +3 -0
- package/dist/components/Drawer/images.d.ts +1 -0
- package/dist/components/Drawer/types.d.ts +2 -0
- package/dist/components/Drawer/util.d.ts +7 -0
- package/dist/components/Header/Header.d.ts +28 -0
- package/dist/components/Header/components/AgreementSelector.d.ts +18 -0
- package/dist/components/Header/components/Agreements/AgreementDetails.d.ts +20 -0
- package/dist/components/Header/components/Button.d.ts +11 -0
- package/dist/components/Header/components/Link.d.ts +21 -0
- package/dist/components/Header/components/Logo.d.ts +3 -0
- package/dist/components/Header/components/MenuButton.d.ts +5 -0
- package/dist/components/Header/components/PrimaryNavigation.d.ts +3 -0
- package/dist/components/Header/components/SecondaryNavigation.d.ts +3 -0
- package/dist/components/Layout/Layout.d.ts +16 -0
- package/dist/components/Layout/components/Content.d.ts +3 -0
- package/dist/components/Layout/components/Context.d.ts +6 -0
- package/dist/components/Layout/components/Page.d.ts +3 -0
- package/dist/components/Layout/components/Sidebar.d.ts +3 -0
- package/dist/components/Layout/components/Top.d.ts +7 -0
- package/dist/components/Navigation2/Navigation2.d.ts +17 -0
- package/dist/components/Navigation2/components/Content.d.ts +3 -0
- package/dist/components/Navigation2/components/Group.d.ts +9 -0
- package/dist/components/Navigation2/components/Link.d.ts +24 -0
- package/dist/components/Navigation2/components/Section.d.ts +7 -0
- package/dist/components/Navigation2/components/util.d.ts +1 -0
- package/dist/components/Provider/Localization.d.ts +32 -16
- package/dist/esm/packages/taco/src/components/Button/Button.js +2 -0
- package/dist/esm/packages/taco/src/components/Button/Button.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Button/util.js +5 -0
- package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/Dialog.js +3 -3
- package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/{Drawer.js → DialogDrawer.js} +4 -4
- package/dist/esm/packages/taco/src/components/Dialog/components/DialogDrawer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/Context.js +19 -0
- package/dist/esm/packages/taco/src/components/Drawer/Context.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/Drawer.js +102 -0
- package/dist/esm/packages/taco/src/components/Drawer/Drawer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +292 -0
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/components/Trigger.js +12 -0
- package/dist/esm/packages/taco/src/components/Drawer/components/Trigger.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Drawer/util.js +37 -0
- package/dist/esm/packages/taco/src/components/Drawer/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/Header.js +30 -0
- package/dist/esm/packages/taco/src/components/Header/Header.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +136 -0
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/Agreements/AgreementDetails.js +73 -0
- package/dist/esm/packages/taco/src/components/Header/components/Agreements/AgreementDetails.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/Button.js +24 -0
- package/dist/esm/packages/taco/src/components/Header/components/Button.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/Link.js +49 -0
- package/dist/esm/packages/taco/src/components/Header/components/Link.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/Logo.js +73 -0
- package/dist/esm/packages/taco/src/components/Header/components/Logo.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/MenuButton.js +17 -0
- package/dist/esm/packages/taco/src/components/Header/components/MenuButton.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js +134 -0
- package/dist/esm/packages/taco/src/components/Header/components/PrimaryNavigation.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Header/components/SecondaryNavigation.js +13 -0
- package/dist/esm/packages/taco/src/components/Header/components/SecondaryNavigation.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/Layout.js +28 -0
- package/dist/esm/packages/taco/src/components/Layout/Layout.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Content.js +13 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Content.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Context.js +9 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Context.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Page.js +13 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Page.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js +83 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Top.js +15 -0
- package/dist/esm/packages/taco/src/components/Layout/components/Top.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Menu/Menu.js +2 -2
- package/dist/esm/packages/taco/src/components/Menu/components/Content.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Header.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Link.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Trigger.js +1 -1
- package/dist/esm/packages/taco/src/components/Navigation2/Navigation2.js +31 -0
- package/dist/esm/packages/taco/src/components/Navigation2/Navigation2.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Content.js +20 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Content.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Group.js +46 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Group.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js +72 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Link.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js +25 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/Section.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/util.js +12 -0
- package/dist/esm/packages/taco/src/components/Navigation2/components/util.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +20 -10
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js +4 -1
- package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +1 -1
- package/dist/esm/packages/taco/src/components/Table/util/renderRow.js +1 -1
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +1 -1
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js +1 -1
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +1 -1
- package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js +3 -1
- package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useIsLargeScreen.js +6 -0
- package/dist/esm/packages/taco/src/hooks/useIsLargeScreen.js.map +1 -0
- package/dist/esm/packages/taco/src/hooks/useMatchMedia.js +18 -0
- package/dist/esm/packages/taco/src/hooks/useMatchMedia.js.map +1 -0
- package/dist/esm/packages/taco/src/index.js +11 -1
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Collection/Collection.js +3 -0
- package/dist/esm/packages/taco/src/primitives/Collection/Collection.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +4 -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 +1 -0
- package/dist/esm/packages/taco/src/primitives/Listbox2/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/hooks/useDraggable.js +8 -1
- package/dist/esm/packages/taco/src/utils/hooks/useDraggable.js.map +1 -1
- package/dist/hooks/useIsLargeScreen.d.ts +1 -0
- package/dist/hooks/useMatchMedia.d.ts +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/taco.cjs.development.js +1981 -737
- 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 +3 -2
- package/tailwind.config.js +1 -0
- package/types.json +936 -182
- package/dist/components/Accordion/Accordion.stories.d.ts +0 -26
- package/dist/components/Alert/Alert.stories.d.ts +0 -36
- package/dist/components/AlertDialog/AlertDialog.stories.d.ts +0 -10
- package/dist/components/Backdrop/Backdrop.stories.d.ts +0 -7
- package/dist/components/BadgeIcon/BadgeIcon.stories.d.ts +0 -12
- package/dist/components/Banner/Banner.stories.d.ts +0 -5
- package/dist/components/Button/Button.stories.d.ts +0 -77
- package/dist/components/Calendar/Calendar.stories.d.ts +0 -13
- package/dist/components/Card/Card.stories.d.ts +0 -12
- package/dist/components/Datepicker/Datepicker.stories.d.ts +0 -43
- package/dist/components/Dialog/Dialog.stories.d.ts +0 -57
- package/dist/components/Dialog/components/Drawer.d.ts +0 -10
- package/dist/components/Field/Field.stories.d.ts +0 -14
- package/dist/components/Form/Form.stories.d.ts +0 -14
- package/dist/components/Group/Group.stories.d.ts +0 -23
- package/dist/components/Hanger/Hanger.stories.d.ts +0 -11
- package/dist/components/HoverCard/HoverCard.stories.d.ts +0 -16
- package/dist/components/Icon/Icon.stories.d.ts +0 -8
- package/dist/components/IconButton/IconButton.stories.d.ts +0 -12
- package/dist/components/Input/Input.stories.d.ts +0 -17
- package/dist/components/Listbox/Listbox.stories.d.ts +0 -44
- package/dist/components/Menu/Menu.stories.d.ts +0 -73
- package/dist/components/Navigation/Navigation.stories.d.ts +0 -7
- package/dist/components/Pagination/Pagination.stories.d.ts +0 -28
- package/dist/components/Popover/Popover.stories.d.ts +0 -29
- package/dist/components/Progress/Progress.stories.d.ts +0 -9
- package/dist/components/RadioGroup/RadioGroup.stories.d.ts +0 -49
- package/dist/components/ScrollArea/ScrollArea.stories.d.ts +0 -8
- package/dist/components/SearchInput/SearchInput.stories.d.ts +0 -38
- package/dist/components/Select/Select.stories.d.ts +0 -35
- package/dist/components/Select2/Select2.stories.d.ts +0 -57
- package/dist/components/Spinner/Spinner.stories.d.ts +0 -15
- package/dist/components/Table/Table.stories.d.ts +0 -32
- package/dist/components/Table2/Table2.stories.d.ts +0 -48
- package/dist/components/Tabs/Tabs.stories.d.ts +0 -19
- package/dist/components/Tag/Tag.stories.d.ts +0 -9
- package/dist/components/Textarea/Textarea.stories.d.ts +0 -40
- package/dist/components/Toast/Toast.stories.d.ts +0 -12
- package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -26
- package/dist/components/Tour/Tour.stories.d.ts +0 -11
- package/dist/css/Typography.stories.d.ts +0 -6
- package/dist/esm/packages/taco/src/components/Dialog/components/Drawer.js.map +0 -1
- package/dist/hooks/useIsRefOverflowing.d.ts +0 -2
- package/dist/primitives/Collection/Collection.stories.d.ts +0 -8
- package/dist/primitives/Listbox2/Listbox2.stories.d.ts +0 -16
- package/dist/primitives/Sortable/Sortable.stories.d.ts +0 -14
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SearchInput.js","sources":["../../../../../../../src/components/SearchInput/SearchInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Input, InputProps } from '../Input/Input';\nimport { useLocalization } from '../Provider/Localization';\nimport { IconButton } from '../IconButton/IconButton';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef } from '../../utils/input';\n\nexport type SearchInputTexts = {\n button: string;\n clear: string;\n placeholder: string;\n};\n\nexport type SearchInputProps = Omit<InputProps, 'button' | 'icon' | 'prefix' | 'postfix'> & {\n /** Current input value will be passed to the method. In order to get the value, the component must be controlled otherwise value will always be undefined */\n onSearch?: (value: string | number | readonly string[] | undefined) => void;\n};\n\nexport const SearchInput = React.forwardRef(function SearchInput(\n { onSearch, ...props }: SearchInputProps,\n ref: React.Ref<HTMLInputElement>\n) {\n const internalRef = useMergedRef<HTMLInputElement>(ref);\n const { texts } = useLocalization();\n\n const handleClick = (): void => {\n onSearch?.(internalRef.current?.value ?? '');\n };\n\n const handleCancelClick = (): void => {\n setInputValueByRef(internalRef.current, '');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n if (event.key === 'Enter') {\n event.preventDefault();\n handleClick();\n return;\n }\n
|
1
|
+
{"version":3,"file":"SearchInput.js","sources":["../../../../../../../src/components/SearchInput/SearchInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Input, InputProps } from '../Input/Input';\nimport { useLocalization } from '../Provider/Localization';\nimport { IconButton } from '../IconButton/IconButton';\nimport { useMergedRef } from '../../hooks/useMergedRef';\nimport { setInputValueByRef } from '../../utils/input';\n\nexport type SearchInputTexts = {\n button: string;\n clear: string;\n placeholder: string;\n};\n\nexport type SearchInputProps = Omit<InputProps, 'button' | 'icon' | 'prefix' | 'postfix'> & {\n /** Current input value will be passed to the method. In order to get the value, the component must be controlled otherwise value will always be undefined */\n onSearch?: (value: string | number | readonly string[] | undefined) => void;\n};\n\nexport const SearchInput = React.forwardRef(function SearchInput(\n { onSearch, ...props }: SearchInputProps,\n ref: React.Ref<HTMLInputElement>\n) {\n const internalRef = useMergedRef<HTMLInputElement>(ref);\n const { texts } = useLocalization();\n\n const handleClick = (): void => {\n onSearch?.(internalRef.current?.value ?? '');\n };\n\n const handleCancelClick = (): void => {\n setInputValueByRef(internalRef.current, '');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>): void => {\n props.onKeyDown?.(event);\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n if (event.key === 'Enter') {\n event.preventDefault();\n handleClick();\n return;\n }\n };\n\n return (\n <Input\n aria-label={texts.searchInput.placeholder}\n placeholder={texts.searchInput.placeholder}\n {...props}\n onKeyDown={handleKeyDown}\n postfix={\n <>\n {props.disabled || props.readOnly || !props.value ? null : (\n <IconButton\n aria-hidden\n className=\"group-peer-focus:visible group-peer-hover:visible !text-grey-700 invisible mr-0.5 !h-5 !min-h-[theme(spacing.4)] !w-5 !min-w-[theme(spacing.4)] text-xs hover:visible group-hover:visible\"\n icon=\"close\"\n onClick={handleCancelClick}\n rounded\n tabIndex={-1}\n tooltip={texts.searchInput.clear}\n />\n )}\n <IconButton\n aria-label={texts.searchInput.button}\n icon=\"search\"\n className=\"group-peer-focus:!border-transparent group-peer-focus:group-peer-active:!border-transparent -mr-2 !border-transparent !bg-transparent focus:!border-transparent\"\n disabled={props.disabled || props.readOnly}\n onClick={handleClick}\n tabIndex={-1}\n tooltip={texts.searchInput.button}\n />\n </>\n }\n ref={internalRef}\n type=\"search\"\n />\n );\n});\n"],"names":["SearchInput","React","onSearch","props","ref","internalRef","useMergedRef","texts","useLocalization","handleClick","current","value","handleCancelClick","setInputValueByRef","handleKeyDown","event","onKeyDown","isDefaultPrevented","key","preventDefault","Input","searchInput","placeholder","postfix","disabled","readOnly","IconButton","className","icon","onClick","rounded","tabIndex","tooltip","clear","button","type"],"mappings":";;;;;;;MAkBaA,WAAW,gBAAGC,UAAgB,CAAC,SAASD,WAAW,CAC5D;EAAEE,QAAQ;EAAE,GAAGC;CAAyB,EACxCC,GAAgC;EAEhC,MAAMC,WAAW,GAAGC,YAAY,CAAm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AC1CI,OAAO,EAAEpB,WAAW;MACpBsB,QAAQ,EAAE,CAAC,CAAC;MACZC,OAAO,EAAEzB,KAAK,CAACc,WAAW,CAACa;MAC7B,CACH;IAEP9B,GAAG,EAAEC,WAAW;IAChB8B,IAAI,EAAC;KACP;AAEV,CAAC;;;;"}
|
@@ -6,8 +6,8 @@ import { useLocalization } from '../../Provider/Localization.js';
|
|
6
6
|
import { Button } from '../../Button/Button.js';
|
7
7
|
import { Input } from '../../Input/Input.js';
|
8
8
|
import { Popover } from '../../Popover/Popover.js';
|
9
|
-
import { Field } from '../../Field/Field.js';
|
10
9
|
import { Group } from '../../Group/Group.js';
|
10
|
+
import { Field } from '../../Field/Field.js';
|
11
11
|
import { Root, Item, Indicator } from '@radix-ui/react-radio-group';
|
12
12
|
import { useSelect2Context } from './Context.js';
|
13
13
|
import { _catch } from '../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
|
@@ -5,10 +5,10 @@ import { Badge } from '../../Badge/Badge.js';
|
|
5
5
|
import { Tooltip } from '../../Tooltip/Tooltip.js';
|
6
6
|
import { getInputClasses } from '../../Input/util.js';
|
7
7
|
import { useMergedRef } from '../../../hooks/useMergedRef.js';
|
8
|
+
import { ScrollArea } from '../../ScrollArea/ScrollArea.js';
|
8
9
|
import { Tag } from '../../Tag/Tag.js';
|
9
10
|
import { useSelect2Context } from './Context.js';
|
10
11
|
import { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom.js';
|
11
|
-
import { ScrollArea } from '../../ScrollArea/ScrollArea.js';
|
12
12
|
|
13
13
|
const Trigger = /*#__PURE__*/React__default.forwardRef(function Select2Trigger(props, ref) {
|
14
14
|
const {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import cn from 'classnames';
|
3
|
-
import { sanitizeRowProps } from '../util.js';
|
4
3
|
import { FocusScope } from '@react-aria/focus';
|
4
|
+
import { sanitizeRowProps } from '../util.js';
|
5
5
|
|
6
6
|
const renderCell = (cell, row) => {
|
7
7
|
const props = {
|
@@ -4,8 +4,8 @@ import { Icon } from '../../Icon/Icon.js';
|
|
4
4
|
import { useLocalization } from '../../Provider/Localization.js';
|
5
5
|
import { Button } from '../../Button/Button.js';
|
6
6
|
import { useMergedRef } from '../../../hooks/useMergedRef.js';
|
7
|
-
import { Shortcut } from '../../Shortcut/Shortcut.js';
|
8
7
|
import { useGlobalKeyboardShortcut } from '../../../hooks/useGlobalKeyboardShortcut.js';
|
8
|
+
import { Shortcut } from '../../Shortcut/Shortcut.js';
|
9
9
|
|
10
10
|
const EditModeButton = /*#__PURE__*/React__default.forwardRef(function EditModeButton(props, ref) {
|
11
11
|
const {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import cn from 'classnames';
|
3
3
|
import { useLocalization } from '../../Provider/Localization.js';
|
4
|
-
import { SearchInput } from '../../SearchInput/SearchInput.js';
|
5
4
|
import { useGlobalKeyboardShortcut } from '../../../hooks/useGlobalKeyboardShortcut.js';
|
5
|
+
import { SearchInput } from '../../SearchInput/SearchInput.js';
|
6
6
|
|
7
7
|
const Search = props => {
|
8
8
|
const {
|
@@ -5,10 +5,10 @@ import { useLocalization } from '../../../Provider/Localization.js';
|
|
5
5
|
import { Button } from '../../../Button/Button.js';
|
6
6
|
import { Popover } from '../../../Popover/Popover.js';
|
7
7
|
import { Group } from '../../../Group/Group.js';
|
8
|
+
import { useGlobalKeyboardShortcut } from '../../../../hooks/useGlobalKeyboardShortcut.js';
|
8
9
|
import { Shortcut } from '../../../Shortcut/Shortcut.js';
|
9
10
|
import { isInternalColumn } from '../../utilities/columns.js';
|
10
11
|
import { ColumnFilter } from './components/ColumnFilter.js';
|
11
|
-
import { useGlobalKeyboardShortcut } from '../../../../hooks/useGlobalKeyboardShortcut.js';
|
12
12
|
|
13
13
|
const FiltersButton = ({
|
14
14
|
length,
|
@@ -1,14 +1,16 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
+
import { useBoundingClientRectListener } from './useBoundingClientRectListener.js';
|
2
3
|
import { getIndexOfFirstChildOverflowingParent } from '../utils/dom.js';
|
3
4
|
|
4
5
|
const useBoundaryOverflowDetection = (ref, dependencies = []) => {
|
5
6
|
const [boundaryIndex, setBoundaryIndex] = React__default.useState();
|
7
|
+
const dimensions = useBoundingClientRectListener(ref, dependencies);
|
6
8
|
React__default.useEffect(() => {
|
7
9
|
if (ref.current) {
|
8
10
|
const boundaryChildIndex = getIndexOfFirstChildOverflowingParent(ref.current);
|
9
11
|
setBoundaryIndex(boundaryChildIndex);
|
10
12
|
}
|
11
|
-
}, [ref, ...dependencies]);
|
13
|
+
}, [ref, dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, ...dependencies]);
|
12
14
|
return boundaryIndex;
|
13
15
|
};
|
14
16
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useBoundaryOverflowDetection.js","sources":["../../../../../../src/hooks/useBoundaryOverflowDetection.ts"],"sourcesContent":["import React from 'react';\nimport { getIndexOfFirstChildOverflowingParent } from '../utils/dom';\n\nexport const useBoundaryOverflowDetection = (\n ref: React.RefObject<HTMLElement>,\n dependencies: any[] = []\n): number | null | undefined => {\n const [boundaryIndex, setBoundaryIndex] = React.useState<number | null>();\n\n React.useEffect(() => {\n if (ref.current) {\n const boundaryChildIndex = getIndexOfFirstChildOverflowingParent(ref.current);\n setBoundaryIndex(boundaryChildIndex);\n }\n }, [ref, ...dependencies]);\n\n return boundaryIndex;\n};\n"],"names":["useBoundaryOverflowDetection","ref","dependencies","boundaryIndex","setBoundaryIndex","React","useState","useEffect","current","boundaryChildIndex","getIndexOfFirstChildOverflowingParent"],"mappings":"
|
1
|
+
{"version":3,"file":"useBoundaryOverflowDetection.js","sources":["../../../../../../src/hooks/useBoundaryOverflowDetection.ts"],"sourcesContent":["import React from 'react';\nimport { getIndexOfFirstChildOverflowingParent } from '../utils/dom';\nimport { useBoundingClientRectListener } from './useBoundingClientRectListener';\n\nexport const useBoundaryOverflowDetection = (\n ref: React.RefObject<HTMLElement>,\n dependencies: any[] = []\n): number | null | undefined => {\n const [boundaryIndex, setBoundaryIndex] = React.useState<number | null>();\n const dimensions = useBoundingClientRectListener(ref, dependencies);\n\n React.useEffect(() => {\n if (ref.current) {\n const boundaryChildIndex = getIndexOfFirstChildOverflowingParent(ref.current);\n setBoundaryIndex(boundaryChildIndex);\n }\n }, [ref, dimensions?.width, ...dependencies]);\n\n return boundaryIndex;\n};\n"],"names":["useBoundaryOverflowDetection","ref","dependencies","boundaryIndex","setBoundaryIndex","React","useState","dimensions","useBoundingClientRectListener","useEffect","current","boundaryChildIndex","getIndexOfFirstChildOverflowingParent","width"],"mappings":";;;;MAIaA,4BAA4B,GAAG,CACxCC,GAAiC,EACjCC,eAAsB,EAAE;EAExB,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGC,cAAK,CAACC,QAAQ,EAAiB;EACzE,MAAMC,UAAU,GAAGC,6BAA6B,CAACP,GAAG,EAAEC,YAAY,CAAC;EAEnEG,cAAK,CAACI,SAAS,CAAC;IACZ,IAAIR,GAAG,CAACS,OAAO,EAAE;MACb,MAAMC,kBAAkB,GAAGC,qCAAqC,CAACX,GAAG,CAACS,OAAO,CAAC;MAC7EN,gBAAgB,CAACO,kBAAkB,CAAC;;GAE3C,EAAE,CAACV,GAAG,EAAEM,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEM,KAAK,EAAE,GAAGX,YAAY,CAAC,CAAC;EAE7C,OAAOC,aAAa;AACxB;;;;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useIsLargeScreen.js","sources":["../../../../../../src/hooks/useIsLargeScreen.ts"],"sourcesContent":["import { useMatchMedia } from './useMatchMedia';\n\nexport const useIsLargeScreen = () => useMatchMedia('(min-width: 1024px)', window.innerWidth > 1024);\n"],"names":["useIsLargeScreen","useMatchMedia","window","innerWidth"],"mappings":";;MAEaA,gBAAgB,GAAG,MAAMC,aAAa,CAAC,qBAAqB,EAAEC,MAAM,CAACC,UAAU,GAAG,IAAI;;;;"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
|
3
|
+
const useMatchMedia = (query, defaultMatches = false) => {
|
4
|
+
const [matches, setMatches] = React__default.useState(defaultMatches);
|
5
|
+
const handleChange = React__default.useCallback(event => setMatches(event.matches), []);
|
6
|
+
React__default.useEffect(() => {
|
7
|
+
const mediaQuery = window.matchMedia(query);
|
8
|
+
setMatches(mediaQuery.matches);
|
9
|
+
mediaQuery.addEventListener('change', handleChange);
|
10
|
+
return () => {
|
11
|
+
mediaQuery.removeEventListener('change', handleChange);
|
12
|
+
};
|
13
|
+
}, []);
|
14
|
+
return matches;
|
15
|
+
};
|
16
|
+
|
17
|
+
export { useMatchMedia };
|
18
|
+
//# sourceMappingURL=useMatchMedia.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useMatchMedia.js","sources":["../../../../../../src/hooks/useMatchMedia.ts"],"sourcesContent":["import React from 'react';\n\nexport const useMatchMedia = (query: string, defaultMatches = false): boolean => {\n const [matches, setMatches] = React.useState<boolean>(defaultMatches);\n\n const handleChange = React.useCallback((event: MediaQueryList | MediaQueryListEvent) => setMatches(event.matches), []);\n\n React.useEffect(() => {\n const mediaQuery = window.matchMedia(query);\n setMatches(mediaQuery.matches);\n mediaQuery.addEventListener('change', handleChange);\n\n return () => {\n mediaQuery.removeEventListener('change', handleChange);\n };\n }, []);\n\n return matches;\n};\n"],"names":["useMatchMedia","query","defaultMatches","matches","setMatches","React","useState","handleChange","useCallback","event","useEffect","mediaQuery","window","matchMedia","addEventListener","removeEventListener"],"mappings":";;MAEaA,aAAa,GAAG,CAACC,KAAa,EAAEC,cAAc,GAAG,KAAK;EAC/D,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAUJ,cAAc,CAAC;EAErE,MAAMK,YAAY,GAAGF,cAAK,CAACG,WAAW,CAAEC,KAA2C,IAAKL,UAAU,CAACK,KAAK,CAACN,OAAO,CAAC,EAAE,EAAE,CAAC;EAEtHE,cAAK,CAACK,SAAS,CAAC;IACZ,MAAMC,UAAU,GAAGC,MAAM,CAACC,UAAU,CAACZ,KAAK,CAAC;IAC3CG,UAAU,CAACO,UAAU,CAACR,OAAO,CAAC;IAC9BQ,UAAU,CAACG,gBAAgB,CAAC,QAAQ,EAAEP,YAAY,CAAC;IAEnD,OAAO;MACHI,UAAU,CAACI,mBAAmB,CAAC,QAAQ,EAAER,YAAY,CAAC;KACzD;GACJ,EAAE,EAAE,CAAC;EAEN,OAAOJ,OAAO;AAClB;;;;"}
|
@@ -27,9 +27,10 @@ export { format, isWeakEqual, parseFromCustomString, parseFromISOString } from '
|
|
27
27
|
export { Popover } from './components/Popover/Popover.js';
|
28
28
|
export { Datepicker } from './components/Datepicker/Datepicker.js';
|
29
29
|
export { Dialog } from './components/Dialog/Dialog.js';
|
30
|
+
export { Group } from './components/Group/Group.js';
|
31
|
+
export { Drawer } from './components/Drawer/Drawer.js';
|
30
32
|
export { Field } from './components/Field/Field.js';
|
31
33
|
export { Form } from './components/Form/Form.js';
|
32
|
-
export { Group } from './components/Group/Group.js';
|
33
34
|
export { Hanger, Title } from './components/Hanger/Hanger.js';
|
34
35
|
export { HoverCard } from './components/HoverCard/HoverCard.js';
|
35
36
|
export { SearchInput } from './components/SearchInput/SearchInput.js';
|
@@ -45,6 +46,8 @@ export { Pagination } from './components/Pagination/Pagination.js';
|
|
45
46
|
export { Progress } from './components/Progress/Progress.js';
|
46
47
|
export { ToastProvider, useToast } from './components/Toast/Toaster.js';
|
47
48
|
export { Provider } from './components/Provider/Provider.js';
|
49
|
+
import * as Collection from './primitives/Collection/Collection.js';
|
50
|
+
export { Collection as CollectionPrimitive };
|
48
51
|
export { Tag } from './components/Tag/Tag.js';
|
49
52
|
export { Select2 } from './components/Select2/Select2.js';
|
50
53
|
export { Shortcut } from './components/Shortcut/Shortcut.js';
|
@@ -54,9 +57,16 @@ export { WindowedTable } from './components/Table/components/WindowedTable.js';
|
|
54
57
|
export { convertRowIndexPathToNumberArray, getByRowIndexPath, getParentRowIndexPath, setByRowIndexPath } from './components/Table/util/rowIndexPath.js';
|
55
58
|
export { insertChildTableRow, removeChildTableRow, useTableRowCreation } from './components/Table/hooks/useRowCreation.js';
|
56
59
|
export { Switch } from './components/Switch/Switch.js';
|
60
|
+
export { useBoundaryOverflowDetection } from './hooks/useBoundaryOverflowDetection.js';
|
57
61
|
export { Table2 } from './components/Table2/Table2.js';
|
58
62
|
export { Tabs } from './components/Tabs/Tabs.js';
|
59
63
|
export { Textarea } from './components/Textarea/Textarea.js';
|
60
64
|
export { Tour, TourStep } from './components/Tour/Tour.js';
|
65
|
+
export { Header } from './components/Header/Header.js';
|
66
|
+
export { useMatchMedia } from './hooks/useMatchMedia.js';
|
67
|
+
export { useIsLargeScreen } from './hooks/useIsLargeScreen.js';
|
68
|
+
export { Layout } from './components/Layout/Layout.js';
|
69
|
+
export { getNavigationLinkClasses } from './components/Navigation2/components/Link.js';
|
70
|
+
export { Navigation2 } from './components/Navigation2/Navigation2.js';
|
61
71
|
export { useOnClickOutside } from './utils/hooks/useOnClickOutside.js';
|
62
72
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Collection.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
@@ -45,7 +45,10 @@ const Root = /*#__PURE__*/React__default.forwardRef(function CollectionRoot(prop
|
|
45
45
|
if (internalRef.current) {
|
46
46
|
const options = getOptionsFromCollection(internalRef.current, querySelector);
|
47
47
|
if (options.length && options.length !== lastLengthRef.current) {
|
48
|
-
|
48
|
+
let selected = internalRef.current.querySelectorAll(`[aria-current="true"]`);
|
49
|
+
if (selected.length === 0) {
|
50
|
+
selected = internalRef.current.querySelectorAll(`[aria-selected]`);
|
51
|
+
}
|
49
52
|
if (selected.length === 1) {
|
50
53
|
if (options) {
|
51
54
|
const firstSelected = selected.item(0);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Collection/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { isAriaDirectionKey } from '../../../utils/aria';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\n\n/* This component provides a keyboard navigable collection primitive for use in lists\n * It is unlikely you need to edit this component\n */\n\nexport type CollectionProps = React.HTMLAttributes<HTMLDivElement> & {\n querySelector: string;\n};\n\nexport type CollectionRef = HTMLDivElement & {\n setActiveIndex: (option: HTMLDivElement) => void;\n};\n\nconst getOptionsFromCollection = (collection: HTMLDivElement, selector: string): NodeListOf<Element> =>\n collection.querySelectorAll(selector);\n\n// we use javascript to set attributes (rather than cloning children and adding them)\n// so that we can support nesting (e.g. groups) - child elements that aren't options.\n// without doing this we would have to unwrap and flatten all groups\nexport const Root = React.forwardRef<CollectionRef, CollectionProps>(function CollectionRoot(props, ref) {\n const { querySelector, tabIndex = 0, ...otherProps } = props;\n const internalRef = useMergedRef<CollectionRef>(ref);\n const [activeIndex, setActiveIndex] = React.useState<number | undefined>();\n const lastLengthRef = React.useRef(0);\n\n const setActiveOption = (index: number, collection: HTMLDivElement, option: Element) => {\n collection.querySelector(`[aria-current]`)?.removeAttribute('aria-current');\n option.setAttribute('aria-current', 'true');\n option.scrollIntoView({ block: 'nearest' });\n setActiveIndex(index);\n };\n\n const setActiveIndexByElement = React.useCallback(\n (option: HTMLDivElement) => {\n if (internalRef.current) {\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, internalRef.current, option);\n }\n }\n }\n },\n [internalRef.current, querySelector]\n );\n\n React.useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setActiveIndex = setActiveIndexByElement;\n }\n }, [internalRef.current]);\n\n React.useEffect(() => {\n if (internalRef.current) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n\n if (options.length && options.length !== lastLengthRef.current) {\n const selected = internalRef.current.querySelectorAll(`[aria-selected]`);\n\n if (selected.length === 1) {\n if (options) {\n const firstSelected = selected.item(0);\n const selectedIndex = Array.from(options).indexOf(firstSelected);\n\n if (selectedIndex > -1) {\n setActiveOption(selectedIndex, internalRef.current, firstSelected);\n }\n }\n } else {\n // multiple selected or none selected should go to 0\n setActiveOption(0, internalRef.current, options.item(0));\n }\n }\n\n lastLengthRef.current = options.length;\n }\n }, [props.children]);\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const option = event.target as HTMLElement;\n\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, event.currentTarget, option);\n }\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // this stops the event dispatched to the option rebounding back and starting an infinite loop\n if (event.target !== event.currentTarget) {\n return;\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n\n if (options) {\n if (isAriaDirectionKey(event)) {\n event.preventDefault();\n event.stopPropagation();\n const nextActiveIndex = getNextEnabledItem(event, options, activeIndex);\n\n if (nextActiveIndex !== undefined && nextActiveIndex !== activeIndex) {\n setActiveOption(nextActiveIndex, event.currentTarget, options.item(nextActiveIndex));\n }\n } else if (activeIndex !== undefined) {\n // forward events onto the underlying option - this lets consumers place onKeyDown handlers on their own components\n options\n .item(activeIndex)\n .dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n }\n };\n\n return <div {...otherProps} onClick={handleClick} onKeyDown={handleKeyDown} ref={internalRef} tabIndex={tabIndex} />;\n});\n\nexport const getNextIndexFromKeycode = (\n event: React.KeyboardEvent,\n length: number,\n activeIndex: number | undefined\n): number | undefined => {\n switch (event.key) {\n case 'ArrowUp':\n return activeIndex === undefined ? length - 1 : activeIndex > 0 ? activeIndex - 1 : activeIndex;\n\n case 'ArrowDown':\n return activeIndex === undefined ? 0 : activeIndex < length - 1 ? activeIndex + 1 : activeIndex;\n\n case 'Home':\n return 0;\n\n case 'End':\n return length - 1;\n\n default:\n return;\n }\n};\n\nexport const getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n options: NodeListOf<Element>,\n activeIndex: number | undefined,\n recurse = true\n): number | undefined => {\n const nextIndex = getNextIndexFromKeycode(event, options.length, activeIndex);\n\n if (nextIndex !== undefined) {\n if (nextIndex === activeIndex) {\n return activeIndex;\n } else if (options.item(nextIndex) && isSkippableItem(options.item(nextIndex))) {\n // check in the other direction if the first or last item is disabled,\n // but prevent infinite loops if all elements are disabled by disabling recursion\n if (recurse) {\n if (nextIndex === 0) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowDown' }) as any,\n options,\n nextIndex,\n false\n );\n } else if (nextIndex === options.length - 1) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowUp' }) as any,\n options,\n nextIndex,\n false\n );\n }\n }\n\n return getNextEnabledItem(event, options, nextIndex, recurse);\n }\n }\n\n return nextIndex;\n};\n\nconst isSkippableItem = (element: Element) => {\n return (\n element.getAttribute('role') === 'presentation' ||\n !!element.hasAttribute('disabled') ||\n !!element.getAttribute('aria-disabled') ||\n !!element.getAttribute('aria-hidden')\n );\n};\n"],"names":["getOptionsFromCollection","collection","selector","querySelectorAll","Root","React","forwardRef","CollectionRoot","props","ref","querySelector","tabIndex","otherProps","internalRef","useMergedRef","activeIndex","setActiveIndex","useState","lastLengthRef","useRef","setActiveOption","index","option","removeAttribute","setAttribute","scrollIntoView","block","setActiveIndexByElement","useCallback","current","matches","options","nextActiveIndex","Array","from","indexOf","useEffect","length","selected","firstSelected","item","selectedIndex","children","handleClick","event","target","currentTarget","handleKeyDown","onKeyDown","isDefaultPrevented","isAriaDirectionKey","preventDefault","stopPropagation","getNextEnabledItem","undefined","dispatchEvent","createCustomKeyboardEvent","onClick","getNextIndexFromKeycode","key","recurse","nextIndex","isSkippableItem","KeyboardEvent","type","element","getAttribute","hasAttribute"],"mappings":";;;;;AAiBA,MAAMA,wBAAwB,GAAG,CAACC,UAA0B,EAAEC,QAAgB,KAC1ED,UAAU,CAACE,gBAAgB,CAACD,QAAQ,CAAC;AAEzC;AACA;AACA;MACaE,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAiC,SAASC,cAAc,CAACC,KAAK,EAAEC,GAAG;EACnG,MAAM;IAAEC,aAAa;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAC5D,MAAMK,WAAW,GAAGC,YAAY,CAAgBL,GAAG,CAAC;EACpD,MAAM,CAACM,WAAW,EAAEC,cAAc,CAAC,GAAGX,cAAK,CAACY,QAAQ,EAAsB;EAC1E,MAAMC,aAAa,GAAGb,cAAK,CAACc,MAAM,CAAC,CAAC,CAAC;EAErC,MAAMC,eAAe,GAAG,CAACC,KAAa,EAAEpB,UAA0B,EAAEqB,MAAe;;IAC/E,yBAAArB,UAAU,CAACS,aAAa,iBAAiB,CAAC,0DAA1C,sBAA4Ca,eAAe,CAAC,cAAc,CAAC;IAC3ED,MAAM,CAACE,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC;IAC3CF,MAAM,CAACG,cAAc,CAAC;MAAEC,KAAK,EAAE;KAAW,CAAC;IAC3C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":"Root.js","sources":["../../../../../../../../src/primitives/Collection/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { isAriaDirectionKey } from '../../../utils/aria';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\n\n/* This component provides a keyboard navigable collection primitive for use in lists\n * It is unlikely you need to edit this component\n */\n\nexport type CollectionProps = React.HTMLAttributes<HTMLDivElement> & {\n querySelector: string;\n};\n\nexport type CollectionRef = HTMLDivElement & {\n setActiveIndex: (option: HTMLDivElement) => void;\n};\n\nconst getOptionsFromCollection = (collection: HTMLDivElement, selector: string): NodeListOf<Element> =>\n collection.querySelectorAll(selector);\n\n// we use javascript to set attributes (rather than cloning children and adding them)\n// so that we can support nesting (e.g. groups) - child elements that aren't options.\n// without doing this we would have to unwrap and flatten all groups\nexport const Root = React.forwardRef<CollectionRef, CollectionProps>(function CollectionRoot(props, ref) {\n const { querySelector, tabIndex = 0, ...otherProps } = props;\n const internalRef = useMergedRef<CollectionRef>(ref);\n const [activeIndex, setActiveIndex] = React.useState<number | undefined>();\n const lastLengthRef = React.useRef(0);\n\n const setActiveOption = (index: number, collection: HTMLDivElement, option: Element) => {\n collection.querySelector(`[aria-current]`)?.removeAttribute('aria-current');\n option.setAttribute('aria-current', 'true');\n option.scrollIntoView({ block: 'nearest' });\n setActiveIndex(index);\n };\n\n const setActiveIndexByElement = React.useCallback(\n (option: HTMLDivElement) => {\n if (internalRef.current) {\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, internalRef.current, option);\n }\n }\n }\n },\n [internalRef.current, querySelector]\n );\n\n React.useEffect(() => {\n if (internalRef.current) {\n internalRef.current.setActiveIndex = setActiveIndexByElement;\n }\n }, [internalRef.current]);\n\n React.useEffect(() => {\n if (internalRef.current) {\n const options = getOptionsFromCollection(internalRef.current, querySelector);\n\n if (options.length && options.length !== lastLengthRef.current) {\n let selected = internalRef.current.querySelectorAll(`[aria-current=\"true\"]`);\n\n if (selected.length === 0) {\n selected = internalRef.current.querySelectorAll(`[aria-selected]`);\n }\n\n if (selected.length === 1) {\n if (options) {\n const firstSelected = selected.item(0);\n const selectedIndex = Array.from(options).indexOf(firstSelected);\n\n if (selectedIndex > -1) {\n setActiveOption(selectedIndex, internalRef.current, firstSelected);\n }\n }\n } else {\n // multiple selected or none selected should go to 0\n setActiveOption(0, internalRef.current, options.item(0));\n }\n }\n\n lastLengthRef.current = options.length;\n }\n }, [props.children]);\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const option = event.target as HTMLElement;\n\n if (option.matches(querySelector)) {\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n const nextActiveIndex = Array.from(options).indexOf(option);\n\n if (nextActiveIndex > -1) {\n setActiveOption(nextActiveIndex, event.currentTarget, option);\n }\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // this stops the event dispatched to the option rebounding back and starting an infinite loop\n if (event.target !== event.currentTarget) {\n return;\n }\n\n if (otherProps.onKeyDown) {\n otherProps.onKeyDown(event);\n }\n\n if (event.isDefaultPrevented()) {\n return;\n }\n\n const options = getOptionsFromCollection(event.currentTarget, querySelector);\n\n if (options) {\n if (isAriaDirectionKey(event)) {\n event.preventDefault();\n event.stopPropagation();\n const nextActiveIndex = getNextEnabledItem(event, options, activeIndex);\n\n if (nextActiveIndex !== undefined && nextActiveIndex !== activeIndex) {\n setActiveOption(nextActiveIndex, event.currentTarget, options.item(nextActiveIndex));\n }\n } else if (activeIndex !== undefined) {\n // forward events onto the underlying option - this lets consumers place onKeyDown handlers on their own components\n options\n .item(activeIndex)\n .dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n }\n };\n\n return <div {...otherProps} onClick={handleClick} onKeyDown={handleKeyDown} ref={internalRef} tabIndex={tabIndex} />;\n});\n\nexport const getNextIndexFromKeycode = (\n event: React.KeyboardEvent,\n length: number,\n activeIndex: number | undefined\n): number | undefined => {\n switch (event.key) {\n case 'ArrowUp':\n return activeIndex === undefined ? length - 1 : activeIndex > 0 ? activeIndex - 1 : activeIndex;\n\n case 'ArrowDown':\n return activeIndex === undefined ? 0 : activeIndex < length - 1 ? activeIndex + 1 : activeIndex;\n\n case 'Home':\n return 0;\n\n case 'End':\n return length - 1;\n\n default:\n return;\n }\n};\n\nexport const getNextEnabledItem = (\n event: React.KeyboardEvent<HTMLElement>,\n options: NodeListOf<Element>,\n activeIndex: number | undefined,\n recurse = true\n): number | undefined => {\n const nextIndex = getNextIndexFromKeycode(event, options.length, activeIndex);\n\n if (nextIndex !== undefined) {\n if (nextIndex === activeIndex) {\n return activeIndex;\n } else if (options.item(nextIndex) && isSkippableItem(options.item(nextIndex))) {\n // check in the other direction if the first or last item is disabled,\n // but prevent infinite loops if all elements are disabled by disabling recursion\n if (recurse) {\n if (nextIndex === 0) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowDown' }) as any,\n options,\n nextIndex,\n false\n );\n } else if (nextIndex === options.length - 1) {\n return getNextEnabledItem(\n new KeyboardEvent(event.type, { ...(event as any), key: 'ArrowUp' }) as any,\n options,\n nextIndex,\n false\n );\n }\n }\n\n return getNextEnabledItem(event, options, nextIndex, recurse);\n }\n }\n\n return nextIndex;\n};\n\nconst isSkippableItem = (element: Element) => {\n return (\n element.getAttribute('role') === 'presentation' ||\n !!element.hasAttribute('disabled') ||\n !!element.getAttribute('aria-disabled') ||\n !!element.getAttribute('aria-hidden')\n );\n};\n"],"names":["getOptionsFromCollection","collection","selector","querySelectorAll","Root","React","forwardRef","CollectionRoot","props","ref","querySelector","tabIndex","otherProps","internalRef","useMergedRef","activeIndex","setActiveIndex","useState","lastLengthRef","useRef","setActiveOption","index","option","removeAttribute","setAttribute","scrollIntoView","block","setActiveIndexByElement","useCallback","current","matches","options","nextActiveIndex","Array","from","indexOf","useEffect","length","selected","firstSelected","item","selectedIndex","children","handleClick","event","target","currentTarget","handleKeyDown","onKeyDown","isDefaultPrevented","isAriaDirectionKey","preventDefault","stopPropagation","getNextEnabledItem","undefined","dispatchEvent","createCustomKeyboardEvent","onClick","getNextIndexFromKeycode","key","recurse","nextIndex","isSkippableItem","KeyboardEvent","type","element","getAttribute","hasAttribute"],"mappings":";;;;;AAiBA,MAAMA,wBAAwB,GAAG,CAACC,UAA0B,EAAEC,QAAgB,KAC1ED,UAAU,CAACE,gBAAgB,CAACD,QAAQ,CAAC;AAEzC;AACA;AACA;MACaE,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAiC,SAASC,cAAc,CAACC,KAAK,EAAEC,GAAG;EACnG,MAAM;IAAEC,aAAa;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAC5D,MAAMK,WAAW,GAAGC,YAAY,CAAgBL,GAAG,CAAC;EACpD,MAAM,CAACM,WAAW,EAAEC,cAAc,CAAC,GAAGX,cAAK,CAACY,QAAQ,EAAsB;EAC1E,MAAMC,aAAa,GAAGb,cAAK,CAACc,MAAM,CAAC,CAAC,CAAC;EAErC,MAAMC,eAAe,GAAG,CAACC,KAAa,EAAEpB,UAA0B,EAAEqB,MAAe;;IAC/E,yBAAArB,UAAU,CAACS,aAAa,iBAAiB,CAAC,0DAA1C,sBAA4Ca,eAAe,CAAC,cAAc,CAAC;IAC3ED,MAAM,CAACE,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC;IAC3CF,MAAM,CAACG,cAAc,CAAC;MAAEC,KAAK,EAAE;KAAW,CAAC;IAC3CV,cAAc,CAACK,KAAK,CAAC;GACxB;EAED,MAAMM,uBAAuB,GAAGtB,cAAK,CAACuB,WAAW,CAC5CN,MAAsB;IACnB,IAAIT,WAAW,CAACgB,OAAO,EAAE;MACrB,IAAIP,MAAM,CAACQ,OAAO,CAACpB,aAAa,CAAC,EAAE;QAC/B,MAAMqB,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AAO,CAACM,MAAM,EAAEtB,WAAW,CAAC;EAE7E,IAAI8C,SAAS,KAAKP,SAAS,EAAE;IACzB,IAAIO,SAAS,KAAK9C,WAAW,EAAE;MAC3B,OAAOA,WAAW;KACrB,MAAM,IAAIgB,OAAO,CAACS,IAAI,CAACqB,SAAS,CAAC,IAAIC,eAAe,CAAC/B,OAAO,CAACS,IAAI,CAACqB,SAAS,CAAC,CAAC,EAAE;;;MAG5E,IAAID,OAAO,EAAE;QACT,IAAIC,SAAS,KAAK,CAAC,EAAE;UACjB,OAAOR,kBAAkB,CACrB,IAAIU,aAAa,CAACnB,KAAK,CAACoB,IAAI,EAAE;YAAE,GAAIpB,KAAa;YAAEe,GAAG,EAAE;WAAa,CAAQ,EAC7E5B,OAAO,EACP8B,SAAS,EACT,KAAK,CACR;SACJ,MAAM,IAAIA,SAAS,KAAK9B,OAAO,CAACM,MAAM,GAAG,CAAC,EAAE;UACzC,OAAOgB,kBAAkB,CACrB,IAAIU,aAAa,CAACnB,KAAK,CAACoB,IAAI,EAAE;YAAE,GAAIpB,KAAa;YAAEe,GAAG,EAAE;WAAW,CAAQ,EAC3E5B,OAAO,EACP8B,SAAS,EACT,KAAK,CACR;;;MAIT,OAAOR,kBAAkB,CAACT,KAAK,EAAEb,OAAO,EAAE8B,SAAS,EAAED,OAAO,CAAC;;;EAIrE,OAAOC,SAAS;AACpB;AAEA,MAAMC,eAAe,GAAIG,OAAgB;EACrC,OACIA,OAAO,CAACC,YAAY,CAAC,MAAM,CAAC,KAAK,cAAc,IAC/C,CAAC,CAACD,OAAO,CAACE,YAAY,CAAC,UAAU,CAAC,IAClC,CAAC,CAACF,OAAO,CAACC,YAAY,CAAC,eAAe,CAAC,IACvC,CAAC,CAACD,OAAO,CAACC,YAAY,CAAC,aAAa,CAAC;AAE7C,CAAC;;;;"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { useId } from '../../../hooks/useId.js';
|
3
3
|
import { Root as Root$1 } from '../../Collection/components/Root.js';
|
4
|
+
import '../../Collection/Collection.js';
|
4
5
|
import { Listbox2Context } from './Context.js';
|
5
6
|
|
6
7
|
const DEFAULT_SELECTOR = '[role="option"]';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Listbox2/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useId } from '../../../hooks/useId';\nimport * as CollectionPrimitive from '../../Collection/Collection';\nimport { Listbox2Value } from '../types';\nimport { Listbox2Context } from './Context';\n\nexport type Listbox2Props = React.HTMLAttributes<HTMLDivElement> & {\n customSelector?: string;\n disabled?: boolean;\n multiple?: boolean;\n readOnly?: boolean;\n setValue: (value: Listbox2Value) => void;\n value?: Listbox2Value;\n};\n\nconst DEFAULT_SELECTOR = '[role=\"option\"]';\n\nexport const Root = React.forwardRef<CollectionPrimitive.CollectionRef, Listbox2Props>(function Listbox2(props, ref) {\n const {\n children,\n customSelector,\n disabled = false,\n id: nativeId,\n multiple,\n readOnly = false,\n setValue,\n title,\n value,\n ...otherProps\n } = props;\n const id = useId(nativeId);\n\n const context = React.useMemo(\n () => ({\n disabled,\n readOnly,\n setValue,\n value,\n }),\n [disabled, readOnly, value]\n );\n\n return (\n <Listbox2Context.Provider value={context}>\n <div data-taco=\"listbox2\">\n <CollectionPrimitive.Root\n {...otherProps}\n aria-multiselectable={multiple ? true : undefined}\n id={id}\n querySelector={customSelector ? `${DEFAULT_SELECTOR}, ${customSelector}` : DEFAULT_SELECTOR}\n ref={ref}\n role=\"listbox\">\n {children}\n </CollectionPrimitive.Root>\n </div>\n </Listbox2Context.Provider>\n );\n});\n\nexport const createListboxValueSetter =\n (multiple: boolean, setValue: React.Dispatch<React.SetStateAction<Listbox2Value | undefined>>) =>\n (nextValue: Listbox2Value) => {\n setValue(value => {\n if (Array.isArray(nextValue)) {\n return nextValue;\n }\n\n if (multiple) {\n if (value === undefined) {\n return [nextValue];\n } else if (Array.isArray(value)) {\n if (value.includes(nextValue)) {\n return value.filter(v => v !== nextValue);\n }\n\n return [...value, nextValue];\n } else if (value === nextValue) {\n return [];\n }\n\n return [value, nextValue];\n }\n\n return nextValue;\n });\n };\n"],"names":["DEFAULT_SELECTOR","Root","React","forwardRef","Listbox2","props","ref","children","customSelector","disabled","id","nativeId","multiple","readOnly","setValue","title","value","otherProps","useId","context","useMemo","Listbox2Context","Provider","CollectionPrimitive","undefined","querySelector","role","createListboxValueSetter","nextValue","Array","isArray","includes","filter","v"],"mappings":"
|
1
|
+
{"version":3,"file":"Root.js","sources":["../../../../../../../../src/primitives/Listbox2/components/Root.tsx"],"sourcesContent":["import React from 'react';\nimport { useId } from '../../../hooks/useId';\nimport * as CollectionPrimitive from '../../Collection/Collection';\nimport { Listbox2Value } from '../types';\nimport { Listbox2Context } from './Context';\n\nexport type Listbox2Props = React.HTMLAttributes<HTMLDivElement> & {\n customSelector?: string;\n disabled?: boolean;\n multiple?: boolean;\n readOnly?: boolean;\n setValue: (value: Listbox2Value) => void;\n value?: Listbox2Value;\n};\n\nconst DEFAULT_SELECTOR = '[role=\"option\"]';\n\nexport const Root = React.forwardRef<CollectionPrimitive.CollectionRef, Listbox2Props>(function Listbox2(props, ref) {\n const {\n children,\n customSelector,\n disabled = false,\n id: nativeId,\n multiple,\n readOnly = false,\n setValue,\n title,\n value,\n ...otherProps\n } = props;\n const id = useId(nativeId);\n\n const context = React.useMemo(\n () => ({\n disabled,\n readOnly,\n setValue,\n value,\n }),\n [disabled, readOnly, value]\n );\n\n return (\n <Listbox2Context.Provider value={context}>\n <div data-taco=\"listbox2\">\n <CollectionPrimitive.Root\n {...otherProps}\n aria-multiselectable={multiple ? true : undefined}\n id={id}\n querySelector={customSelector ? `${DEFAULT_SELECTOR}, ${customSelector}` : DEFAULT_SELECTOR}\n ref={ref}\n role=\"listbox\">\n {children}\n </CollectionPrimitive.Root>\n </div>\n </Listbox2Context.Provider>\n );\n});\n\nexport const createListboxValueSetter =\n (multiple: boolean, setValue: React.Dispatch<React.SetStateAction<Listbox2Value | undefined>>) =>\n (nextValue: Listbox2Value) => {\n setValue(value => {\n if (Array.isArray(nextValue)) {\n return nextValue;\n }\n\n if (multiple) {\n if (value === undefined) {\n return [nextValue];\n } else if (Array.isArray(value)) {\n if (value.includes(nextValue)) {\n return value.filter(v => v !== nextValue);\n }\n\n return [...value, nextValue];\n } else if (value === nextValue) {\n return [];\n }\n\n return [value, nextValue];\n }\n\n return nextValue;\n });\n };\n"],"names":["DEFAULT_SELECTOR","Root","React","forwardRef","Listbox2","props","ref","children","customSelector","disabled","id","nativeId","multiple","readOnly","setValue","title","value","otherProps","useId","context","useMemo","Listbox2Context","Provider","CollectionPrimitive","undefined","querySelector","role","createListboxValueSetter","nextValue","Array","isArray","includes","filter","v"],"mappings":";;;;;;AAeA,MAAMA,gBAAgB,GAAG,iBAAiB;MAE7BC,IAAI,gBAAGC,cAAK,CAACC,UAAU,CAAmD,SAASC,QAAQ,CAACC,KAAK,EAAEC,GAAG;EAC/G,MAAM;IACFC,QAAQ;IACRC,cAAc;IACdC,QAAQ,GAAG,KAAK;IAChBC,EAAE,EAAEC,QAAQ;IACZC,QAAQ;IACRC,QAAQ,GAAG,KAAK;IAChBC,QAAQ;IACRC,KAAK;IACLC,KAAK;IACL,GAAGC;GACN,GAAGZ,KAAK;EACT,MAAMK,EAAE,GAAGQ,KAAK,CAACP,QAAQ,CAAC;EAE1B,MAAMQ,OAAO,GAAGjB,cAAK,CAACkB,OAAO,CACzB,OAAO;IACHX,QAAQ;IACRI,QAAQ;IACRC,QAAQ;IACRE;GACH,CAAC,EACF,CAACP,QAAQ,EAAEI,QAAQ,EAAEG,KAAK,CAAC,CAC9B;EAED,oBACId,6BAACmB,eAAe,CAACC,QAAQ;IAACN,KAAK,EAAEG;kBAC7BjB;iBAAe;kBACXA,6BAACqB,MAAwB,oBACjBN,UAAU;4BACQL,QAAQ,GAAG,IAAI,GAAGY,SAAS;IACjDd,EAAE,EAAEA,EAAE;IACNe,aAAa,EAAEjB,cAAc,MAAMR,qBAAqBQ,gBAAgB,GAAGR,gBAAgB;IAC3FM,GAAG,EAAEA,GAAG;IACRoB,IAAI,EAAC;MACJnB,QAAQ,CACc,CACzB,CACiB;AAEnC,CAAC;MAEYoB,wBAAwB,GACjC,CAACf,QAAiB,EAAEE,QAAyE,KAC5Fc,SAAwB;EACrBd,QAAQ,CAACE,KAAK;IACV,IAAIa,KAAK,CAACC,OAAO,CAACF,SAAS,CAAC,EAAE;MAC1B,OAAOA,SAAS;;IAGpB,IAAIhB,QAAQ,EAAE;MACV,IAAII,KAAK,KAAKQ,SAAS,EAAE;QACrB,OAAO,CAACI,SAAS,CAAC;OACrB,MAAM,IAAIC,KAAK,CAACC,OAAO,CAACd,KAAK,CAAC,EAAE;QAC7B,IAAIA,KAAK,CAACe,QAAQ,CAACH,SAAS,CAAC,EAAE;UAC3B,OAAOZ,KAAK,CAACgB,MAAM,CAACC,CAAC,IAAIA,CAAC,KAAKL,SAAS,CAAC;;QAG7C,OAAO,CAAC,GAAGZ,KAAK,EAAEY,SAAS,CAAC;OAC/B,MAAM,IAAIZ,KAAK,KAAKY,SAAS,EAAE;QAC5B,OAAO,EAAE;;MAGb,OAAO,CAACZ,KAAK,EAAEY,SAAS,CAAC;;IAG7B,OAAOA,SAAS;GACnB,CAAC;AACN;;;;"}
|
@@ -36,10 +36,17 @@ const useDraggable = ref => {
|
|
36
36
|
setDragging(false);
|
37
37
|
}
|
38
38
|
});
|
39
|
+
const resetPosition = () => {
|
40
|
+
setPosition({
|
41
|
+
x: 0,
|
42
|
+
y: 0
|
43
|
+
});
|
44
|
+
};
|
39
45
|
return {
|
40
46
|
position,
|
41
47
|
dragging,
|
42
|
-
handleProps: moveProps
|
48
|
+
handleProps: moveProps,
|
49
|
+
resetPosition
|
43
50
|
};
|
44
51
|
};
|
45
52
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDraggable.js","sources":["../../../../../../../src/utils/hooks/useDraggable.tsx"],"sourcesContent":["import React from 'react';\nimport { useMove } from '@react-aria/interactions';\n\nexport const useDraggable = (ref: React.MutableRefObject<HTMLDivElement | null>): any => {\n const [position, setPosition] = React.useState({\n x: 0,\n y: 0,\n });\n\n const [dragging, setDragging] = React.useState(false);\n\n const { moveProps } = useMove({\n onMoveStart() {\n setDragging(true);\n },\n onMove(event) {\n const rect = ref.current?.getBoundingClientRect();\n\n // Prevent dragging out of bounds\n if (\n rect &&\n (rect.left + event.deltaX < 0 ||\n rect.right + event.deltaX > window.innerWidth ||\n rect.top + event.deltaY < 0 ||\n rect.bottom + event.deltaY > window.innerHeight)\n ) {\n return;\n }\n\n setPosition(({ x, y }) => {\n x += event.deltaX;\n y += event.deltaY;\n return { x, y };\n });\n },\n onMoveEnd() {\n setDragging(false);\n },\n });\n\n return {\n position,\n dragging,\n handleProps: moveProps,\n };\n};\n"],"names":["useDraggable","ref","position","setPosition","React","useState","x","y","dragging","setDragging","moveProps","useMove","onMoveStart","onMove","event","rect","current","getBoundingClientRect","left","deltaX","right","window","innerWidth","top","deltaY","bottom","innerHeight","onMoveEnd","handleProps"],"mappings":";;;MAGaA,YAAY,GAAIC,GAAkD;EAC3E,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC;IAC3CC,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE;GACN,CAAC;EAEF,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGL,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EAErD,MAAM;IAAEK;GAAW,GAAGC,OAAO,CAAC;IAC1BC,WAAW;MACPH,WAAW,CAAC,IAAI,CAAC;KACpB;IACDI,MAAM,CAACC,KAAK;;MACR,MAAMC,IAAI,mBAAGd,GAAG,CAACe,OAAO,iDAAX,aAAaC,qBAAqB,EAAE;;MAGjD,IACIF,IAAI,KACHA,IAAI,CAACG,IAAI,GAAGJ,KAAK,CAACK,MAAM,GAAG,CAAC,IACzBJ,IAAI,CAACK,KAAK,GAAGN,KAAK,CAACK,MAAM,GAAGE,MAAM,CAACC,UAAU,IAC7CP,IAAI,CAACQ,GAAG,GAAGT,KAAK,CAACU,MAAM,GAAG,CAAC,IAC3BT,IAAI,CAACU,MAAM,GAAGX,KAAK,CAACU,MAAM,GAAGH,MAAM,CAACK,WAAW,CAAC,EACtD;QACE;;MAGJvB,WAAW,CAAC,CAAC;QAAEG,CAAC;QAAEC;OAAG;QACjBD,CAAC,IAAIQ,KAAK,CAACK,MAAM;QACjBZ,CAAC,IAAIO,KAAK,CAACU,MAAM;QACjB,OAAO;UAAElB,CAAC;UAAEC;SAAG;OAClB,CAAC;KACL;IACDoB,SAAS;MACLlB,WAAW,CAAC,KAAK,CAAC;;GAEzB,CAAC;EAEF,OAAO;
|
1
|
+
{"version":3,"file":"useDraggable.js","sources":["../../../../../../../src/utils/hooks/useDraggable.tsx"],"sourcesContent":["import React from 'react';\nimport { useMove } from '@react-aria/interactions';\n\nexport const useDraggable = (ref: React.MutableRefObject<HTMLDivElement | null>): any => {\n const [position, setPosition] = React.useState({\n x: 0,\n y: 0,\n });\n\n const [dragging, setDragging] = React.useState(false);\n\n const { moveProps } = useMove({\n onMoveStart() {\n setDragging(true);\n },\n onMove(event) {\n const rect = ref.current?.getBoundingClientRect();\n\n // Prevent dragging out of bounds\n if (\n rect &&\n (rect.left + event.deltaX < 0 ||\n rect.right + event.deltaX > window.innerWidth ||\n rect.top + event.deltaY < 0 ||\n rect.bottom + event.deltaY > window.innerHeight)\n ) {\n return;\n }\n\n setPosition(({ x, y }) => {\n x += event.deltaX;\n y += event.deltaY;\n return { x, y };\n });\n },\n onMoveEnd() {\n setDragging(false);\n },\n });\n\n const resetPosition = () => {\n setPosition({\n x: 0,\n y: 0,\n });\n };\n\n return {\n position,\n dragging,\n handleProps: moveProps,\n resetPosition,\n };\n};\n"],"names":["useDraggable","ref","position","setPosition","React","useState","x","y","dragging","setDragging","moveProps","useMove","onMoveStart","onMove","event","rect","current","getBoundingClientRect","left","deltaX","right","window","innerWidth","top","deltaY","bottom","innerHeight","onMoveEnd","resetPosition","handleProps"],"mappings":";;;MAGaA,YAAY,GAAIC,GAAkD;EAC3E,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC;IAC3CC,CAAC,EAAE,CAAC;IACJC,CAAC,EAAE;GACN,CAAC;EAEF,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGL,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EAErD,MAAM;IAAEK;GAAW,GAAGC,OAAO,CAAC;IAC1BC,WAAW;MACPH,WAAW,CAAC,IAAI,CAAC;KACpB;IACDI,MAAM,CAACC,KAAK;;MACR,MAAMC,IAAI,mBAAGd,GAAG,CAACe,OAAO,iDAAX,aAAaC,qBAAqB,EAAE;;MAGjD,IACIF,IAAI,KACHA,IAAI,CAACG,IAAI,GAAGJ,KAAK,CAACK,MAAM,GAAG,CAAC,IACzBJ,IAAI,CAACK,KAAK,GAAGN,KAAK,CAACK,MAAM,GAAGE,MAAM,CAACC,UAAU,IAC7CP,IAAI,CAACQ,GAAG,GAAGT,KAAK,CAACU,MAAM,GAAG,CAAC,IAC3BT,IAAI,CAACU,MAAM,GAAGX,KAAK,CAACU,MAAM,GAAGH,MAAM,CAACK,WAAW,CAAC,EACtD;QACE;;MAGJvB,WAAW,CAAC,CAAC;QAAEG,CAAC;QAAEC;OAAG;QACjBD,CAAC,IAAIQ,KAAK,CAACK,MAAM;QACjBZ,CAAC,IAAIO,KAAK,CAACU,MAAM;QACjB,OAAO;UAAElB,CAAC;UAAEC;SAAG;OAClB,CAAC;KACL;IACDoB,SAAS;MACLlB,WAAW,CAAC,KAAK,CAAC;;GAEzB,CAAC;EAEF,MAAMmB,aAAa,GAAG;IAClBzB,WAAW,CAAC;MACRG,CAAC,EAAE,CAAC;MACJC,CAAC,EAAE;KACN,CAAC;GACL;EAED,OAAO;IACHL,QAAQ;IACRM,QAAQ;IACRqB,WAAW,EAAEnB,SAAS;IACtBkB;GACH;AACL;;;;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const useIsLargeScreen: () => boolean;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const useMatchMedia: (query: string, defaultMatches?: boolean) => boolean;
|
package/dist/index.d.ts
CHANGED
@@ -13,6 +13,7 @@ export * from './components/Checkbox/Checkbox';
|
|
13
13
|
export * from './components/Combobox/Combobox';
|
14
14
|
export * from './components/Datepicker/Datepicker';
|
15
15
|
export * from './components/Dialog/Dialog';
|
16
|
+
export * from './components/Drawer/Drawer';
|
16
17
|
export * from './components/Field/Field';
|
17
18
|
export * from './components/Form/Form';
|
18
19
|
export * from './components/Group/Group';
|
@@ -46,9 +47,16 @@ export * from './components/Tooltip/Tooltip';
|
|
46
47
|
export * from './components/Tour/Tour';
|
47
48
|
export * from './components/Treeview/Treeview';
|
48
49
|
export * from './components/VisuallyHidden/VisuallyHidden';
|
50
|
+
export * from './components/Header/Header';
|
51
|
+
export * from './components/Layout/Layout';
|
52
|
+
export * from './components/Navigation2/Navigation2';
|
53
|
+
export * as CollectionPrimitive from './primitives/Collection/Collection';
|
49
54
|
export * from './utils/date';
|
50
55
|
export * from './utils/mergeRefs';
|
56
|
+
export * from './hooks/useBoundaryOverflowDetection';
|
51
57
|
export * from './hooks/useBoundingClientRectListener';
|
58
|
+
export * from './hooks/useIsLargeScreen';
|
59
|
+
export * from './hooks/useMatchMedia';
|
52
60
|
export * from './hooks/useMergedRef';
|
53
61
|
export * from './utils/hooks/useDropTarget';
|
54
62
|
export * from './utils/hooks/useListKeyboardNavigation';
|