@lumx/react 3.0.2 → 3.0.3-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{esm/_internal/_rollupPluginBabelHelpers.js → _internal/ClickAwayProvider.js} +107 -2
- package/_internal/ClickAwayProvider.js.map +1 -0
- package/_internal/types.d.ts +271 -0
- package/index.d.ts +2686 -0
- package/index.js +12533 -0
- package/index.js.map +1 -0
- package/package.json +7 -6
- package/src/components/alert-dialog/AlertDialog.tsx +2 -1
- package/src/components/autocomplete/Autocomplete.tsx +2 -2
- package/src/components/autocomplete/AutocompleteMultiple.tsx +2 -1
- package/src/components/avatar/Avatar.tsx +2 -1
- package/src/components/badge/Badge.test.tsx +1 -1
- package/src/components/badge/Badge.tsx +2 -1
- package/src/components/button/Button.test.tsx +1 -1
- package/src/components/button/Button.tsx +2 -1
- package/src/components/button/ButtonGroup.tsx +2 -1
- package/src/components/button/ButtonRoot.test.tsx +1 -1
- package/src/components/button/ButtonRoot.tsx +2 -1
- package/src/components/button/IconButton.tsx +2 -1
- package/src/components/checkbox/Checkbox.test.tsx +1 -1
- package/src/components/checkbox/Checkbox.tsx +2 -1
- package/src/components/chip/Chip.test.tsx +1 -1
- package/src/components/chip/Chip.tsx +3 -1
- package/src/components/chip/ChipGroup.tsx +2 -1
- package/src/components/comment-block/CommentBlock.tsx +2 -1
- package/src/components/date-picker/DatePicker.tsx +1 -1
- package/src/components/date-picker/DatePickerControlled.tsx +1 -1
- package/src/components/date-picker/DatePickerField.tsx +1 -1
- package/src/components/date-picker/constants.ts +1 -1
- package/src/components/date-picker/types.ts +1 -1
- package/src/components/dialog/Dialog.tsx +4 -8
- package/src/components/divider/Divider.test.tsx +1 -1
- package/src/components/divider/Divider.tsx +3 -2
- package/src/components/drag-handle/DragHandle.tsx +2 -1
- package/src/components/dropdown/Dropdown.tsx +2 -1
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +1 -1
- package/src/components/expansion-panel/ExpansionPanel.tsx +3 -10
- package/src/components/flag/Flag.test.tsx +1 -1
- package/src/components/flag/Flag.tsx +2 -1
- package/src/components/flex-box/FlexBox.stories.tsx +8 -0
- package/src/components/flex-box/FlexBox.tsx +7 -3
- package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +16 -0
- package/src/components/generic-block/GenericBlock.stories.jsx +23 -1
- package/src/components/generic-block/GenericBlock.tsx +18 -4
- package/src/components/generic-block/constants.ts +9 -0
- package/src/components/generic-block/index.ts +1 -0
- package/src/components/grid/Grid.tsx +2 -1
- package/src/components/grid/GridItem.tsx +2 -1
- package/src/components/heading/Heading.tsx +2 -1
- package/src/components/heading/HeadingLevelProvider.tsx +1 -1
- package/src/components/heading/context.tsx +1 -1
- package/src/components/icon/Icon.test.tsx +1 -1
- package/src/components/icon/Icon.tsx +2 -1
- package/src/components/image-block/ImageBlock.tsx +2 -1
- package/src/components/index.ts +1 -1
- package/src/components/inline-list/InlineList.stories.tsx +40 -0
- package/src/components/inline-list/InlineList.test.tsx +41 -0
- package/src/components/inline-list/InlineList.tsx +80 -0
- package/src/components/inline-list/index.ts +1 -0
- package/src/components/input-helper/InputHelper.tsx +2 -1
- package/src/components/input-label/InputLabel.tsx +2 -1
- package/src/components/lightbox/Lightbox.tsx +2 -1
- package/src/components/link/Link.tsx +2 -1
- package/src/components/link-preview/LinkPreview.test.tsx +1 -1
- package/src/components/link-preview/LinkPreview.tsx +2 -1
- package/src/components/list/List.tsx +2 -1
- package/src/components/list/ListDivider.tsx +2 -1
- package/src/components/list/ListItem.tsx +3 -8
- package/src/components/list/ListSubheader.tsx +2 -1
- package/src/components/list/useInteractiveList.tsx +1 -1
- package/src/components/message/Message.test.tsx +1 -1
- package/src/components/message/Message.tsx +2 -1
- package/src/components/mosaic/Mosaic.tsx +2 -1
- package/src/components/notification/Notification.tsx +2 -1
- package/src/components/popover/Popover.tsx +2 -1
- package/src/components/post-block/PostBlock.tsx +2 -1
- package/src/components/progress/Progress.tsx +2 -1
- package/src/components/progress-tracker/ProgressTracker.tsx +2 -1
- package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStep.tsx +2 -1
- package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +2 -1
- package/src/components/radio-button/RadioButton.test.tsx +1 -1
- package/src/components/radio-button/RadioButton.tsx +2 -1
- package/src/components/radio-button/RadioGroup.tsx +2 -1
- package/src/components/select/Select.test.tsx +1 -1
- package/src/components/select/Select.tsx +2 -1
- package/src/components/select/SelectMultiple.test.tsx +1 -1
- package/src/components/select/SelectMultiple.tsx +2 -1
- package/src/components/select/WithSelectContext.tsx +1 -1
- package/src/components/select/constants.ts +1 -1
- package/src/components/side-navigation/SideNavigation.tsx +2 -1
- package/src/components/side-navigation/SideNavigationItem.test.tsx +1 -1
- package/src/components/side-navigation/SideNavigationItem.tsx +3 -9
- package/src/components/skeleton/SkeletonCircle.tsx +2 -1
- package/src/components/skeleton/SkeletonRectangle.tsx +2 -1
- package/src/components/skeleton/SkeletonTypography.tsx +2 -1
- package/src/components/slider/Slider.tsx +2 -1
- package/src/components/slideshow/Slides.tsx +2 -1
- package/src/components/slideshow/Slideshow.tsx +1 -1
- package/src/components/slideshow/SlideshowControls.tsx +2 -1
- package/src/components/slideshow/SlideshowItem.tsx +2 -1
- package/src/components/slideshow/SlideshowItemGroup.tsx +2 -1
- package/src/components/switch/Switch.test.tsx +1 -1
- package/src/components/switch/Switch.tsx +2 -1
- package/src/components/table/Table.tsx +2 -1
- package/src/components/table/TableBody.tsx +2 -1
- package/src/components/table/TableCell.tsx +3 -1
- package/src/components/table/TableHeader.tsx +2 -1
- package/src/components/table/TableRow.tsx +2 -1
- package/src/components/tabs/Tab.test.tsx +1 -1
- package/src/components/tabs/Tab.tsx +2 -1
- package/src/components/tabs/TabList.test.tsx +1 -1
- package/src/components/tabs/TabList.tsx +2 -1
- package/src/components/tabs/TabPanel.tsx +2 -1
- package/src/components/text/{Text.stories.tsx → Text.stories.jsx} +23 -28
- package/src/components/text/Text.test.tsx +15 -1
- package/src/components/text/Text.tsx +38 -12
- package/src/components/text-field/TextField.test.tsx +1 -1
- package/src/components/text-field/TextField.tsx +2 -1
- package/src/components/thumbnail/Thumbnail.tsx +2 -1
- package/src/components/thumbnail/types.ts +1 -1
- package/src/components/toolbar/Toolbar.tsx +2 -1
- package/src/components/tooltip/Tooltip.tsx +2 -1
- package/src/components/tooltip/useTooltipOpen.tsx +1 -1
- package/src/components/uploader/Uploader.test.tsx +1 -1
- package/src/components/uploader/Uploader.tsx +2 -1
- package/src/components/user-block/UserBlock.tsx +2 -1
- package/src/hooks/useCallbackOnEscape.ts +2 -1
- package/src/hooks/useClickAway.tsx +1 -1
- package/src/hooks/useDisableBodyScroll.ts +1 -1
- package/src/hooks/useFocusTrap.ts +1 -1
- package/src/hooks/useInterval.tsx +1 -1
- package/src/hooks/useOnResize.ts +1 -1
- package/src/index.ts +5 -0
- package/src/stories/generated/GenericBlock/Demos.stories.tsx +3 -1
- package/src/stories/generated/Heading/Demos.stories.tsx +6 -0
- package/src/stories/withResizableBox.tsx +18 -0
- package/src/testing/utils/commonTestsSuite.ts +1 -1
- package/src/utils/{getRootClassName.ts → className.ts} +19 -0
- package/src/utils/event.ts +1 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/type.ts +3 -0
- package/src/utils/utils.test.ts +1 -1
- package/types.d.ts +68 -11
- package/utils/index.d.ts +29 -0
- package/utils/index.js +2 -0
- package/utils/index.js.map +1 -0
- package/esm/_internal/AlertDialog.js +0 -141
- package/esm/_internal/AlertDialog.js.map +0 -1
- package/esm/_internal/AutocompleteMultiple.js +0 -257
- package/esm/_internal/AutocompleteMultiple.js.map +0 -1
- package/esm/_internal/Avatar2.js +0 -82
- package/esm/_internal/Avatar2.js.map +0 -1
- package/esm/_internal/Badge2.js +0 -54
- package/esm/_internal/Badge2.js.map +0 -1
- package/esm/_internal/Button2.js +0 -84
- package/esm/_internal/Button2.js.map +0 -1
- package/esm/_internal/ButtonGroup.js +0 -51
- package/esm/_internal/ButtonGroup.js.map +0 -1
- package/esm/_internal/ButtonRoot.js +0 -135
- package/esm/_internal/ButtonRoot.js.map +0 -1
- package/esm/_internal/Checkbox2.js +0 -116
- package/esm/_internal/Checkbox2.js.map +0 -1
- package/esm/_internal/Chip2.js +0 -118
- package/esm/_internal/Chip2.js.map +0 -1
- package/esm/_internal/ChipGroup.js +0 -122
- package/esm/_internal/ChipGroup.js.map +0 -1
- package/esm/_internal/ClickAwayProvider.js +0 -217
- package/esm/_internal/ClickAwayProvider.js.map +0 -1
- package/esm/_internal/CommentBlock.js +0 -124
- package/esm/_internal/CommentBlock.js.map +0 -1
- package/esm/_internal/DatePickerField.js +0 -347
- package/esm/_internal/DatePickerField.js.map +0 -1
- package/esm/_internal/Dialog2.js +0 -274
- package/esm/_internal/Dialog2.js.map +0 -1
- package/esm/_internal/Divider2.js +0 -53
- package/esm/_internal/Divider2.js.map +0 -1
- package/esm/_internal/DragHandle.js +0 -50
- package/esm/_internal/DragHandle.js.map +0 -1
- package/esm/_internal/Dropdown2.js +0 -157
- package/esm/_internal/Dropdown2.js.map +0 -1
- package/esm/_internal/ExpansionPanel.js +0 -156
- package/esm/_internal/ExpansionPanel.js.map +0 -1
- package/esm/_internal/Flag2.js +0 -48
- package/esm/_internal/Flag2.js.map +0 -1
- package/esm/_internal/FlexBox.js +0 -55
- package/esm/_internal/FlexBox.js.map +0 -1
- package/esm/_internal/GenericBlock.js +0 -125
- package/esm/_internal/GenericBlock.js.map +0 -1
- package/esm/_internal/GridItem.js +0 -96
- package/esm/_internal/GridItem.js.map +0 -1
- package/esm/_internal/HeadingLevelProvider.js +0 -112
- package/esm/_internal/HeadingLevelProvider.js.map +0 -1
- package/esm/_internal/Icon2.js +0 -120
- package/esm/_internal/Icon2.js.map +0 -1
- package/esm/_internal/IconButton.js +0 -74
- package/esm/_internal/IconButton.js.map +0 -1
- package/esm/_internal/ImageBlock.js +0 -101
- package/esm/_internal/ImageBlock.js.map +0 -1
- package/esm/_internal/InputHelper.js +0 -72
- package/esm/_internal/InputHelper.js.map +0 -1
- package/esm/_internal/InputLabel.js +0 -58
- package/esm/_internal/InputLabel.js.map +0 -1
- package/esm/_internal/Lightbox2.js +0 -123
- package/esm/_internal/Lightbox2.js.map +0 -1
- package/esm/_internal/Link2.js +0 -122
- package/esm/_internal/Link2.js.map +0 -1
- package/esm/_internal/LinkPreview.js +0 -105
- package/esm/_internal/LinkPreview.js.map +0 -1
- package/esm/_internal/List2.js +0 -799
- package/esm/_internal/List2.js.map +0 -1
- package/esm/_internal/ListSubheader.js +0 -79
- package/esm/_internal/ListSubheader.js.map +0 -1
- package/esm/_internal/Message2.js +0 -78
- package/esm/_internal/Message2.js.map +0 -1
- package/esm/_internal/Mosaic2.js +0 -89
- package/esm/_internal/Mosaic2.js.map +0 -1
- package/esm/_internal/Notification2.js +0 -133
- package/esm/_internal/Notification2.js.map +0 -1
- package/esm/_internal/Popover2.js +0 -2473
- package/esm/_internal/Popover2.js.map +0 -1
- package/esm/_internal/PostBlock.js +0 -96
- package/esm/_internal/PostBlock.js.map +0 -1
- package/esm/_internal/Progress2.js +0 -81
- package/esm/_internal/Progress2.js.map +0 -1
- package/esm/_internal/ProgressTrackerStepPanel.js +0 -313
- package/esm/_internal/ProgressTrackerStepPanel.js.map +0 -1
- package/esm/_internal/RadioGroup.js +0 -147
- package/esm/_internal/RadioGroup.js.map +0 -1
- package/esm/_internal/SelectMultiple.js +0 -424
- package/esm/_internal/SelectMultiple.js.map +0 -1
- package/esm/_internal/SideNavigationItem.js +0 -151
- package/esm/_internal/SideNavigationItem.js.map +0 -1
- package/esm/_internal/SkeletonTypography.js +0 -168
- package/esm/_internal/SkeletonTypography.js.map +0 -1
- package/esm/_internal/Slider2.js +0 -327
- package/esm/_internal/Slider2.js.map +0 -1
- package/esm/_internal/Slides.js +0 -864
- package/esm/_internal/Slides.js.map +0 -1
- package/esm/_internal/Switch2.js +0 -116
- package/esm/_internal/Switch2.js.map +0 -1
- package/esm/_internal/TabPanel.js +0 -280
- package/esm/_internal/TabPanel.js.map +0 -1
- package/esm/_internal/TableRow.js +0 -291
- package/esm/_internal/TableRow.js.map +0 -1
- package/esm/_internal/Text2.js +0 -63
- package/esm/_internal/Text2.js.map +0 -1
- package/esm/_internal/TextField.js +0 -322
- package/esm/_internal/TextField.js.map +0 -1
- package/esm/_internal/Thumbnail2.js +0 -301
- package/esm/_internal/Thumbnail2.js.map +0 -1
- package/esm/_internal/Toolbar2.js +0 -60
- package/esm/_internal/Toolbar2.js.map +0 -1
- package/esm/_internal/Tooltip2.js +0 -282
- package/esm/_internal/Tooltip2.js.map +0 -1
- package/esm/_internal/Uploader2.js +0 -84
- package/esm/_internal/Uploader2.js.map +0 -1
- package/esm/_internal/UserBlock.js +0 -132
- package/esm/_internal/UserBlock.js.map +0 -1
- package/esm/_internal/_rollupPluginBabelHelpers.js.map +0 -1
- package/esm/_internal/alert-dialog.js +0 -34
- package/esm/_internal/alert-dialog.js.map +0 -1
- package/esm/_internal/autocomplete.js +0 -32
- package/esm/_internal/autocomplete.js.map +0 -1
- package/esm/_internal/avatar.js +0 -13
- package/esm/_internal/avatar.js.map +0 -1
- package/esm/_internal/badge.js +0 -10
- package/esm/_internal/badge.js.map +0 -1
- package/esm/_internal/button.js +0 -25
- package/esm/_internal/button.js.map +0 -1
- package/esm/_internal/checkbox.js +0 -14
- package/esm/_internal/checkbox.js.map +0 -1
- package/esm/_internal/chip.js +0 -12
- package/esm/_internal/chip.js.map +0 -1
- package/esm/_internal/comment-block.js +0 -24
- package/esm/_internal/comment-block.js.map +0 -1
- package/esm/_internal/components.js +0 -156
- package/esm/_internal/components.js.map +0 -1
- package/esm/_internal/constants.js +0 -13
- package/esm/_internal/constants.js.map +0 -1
- package/esm/_internal/date-picker.js +0 -32
- package/esm/_internal/date-picker.js.map +0 -1
- package/esm/_internal/dialog.js +0 -27
- package/esm/_internal/dialog.js.map +0 -1
- package/esm/_internal/divider.js +0 -10
- package/esm/_internal/divider.js.map +0 -1
- package/esm/_internal/drag-handle.js +0 -11
- package/esm/_internal/drag-handle.js.map +0 -1
- package/esm/_internal/dropdown.js +0 -21
- package/esm/_internal/dropdown.js.map +0 -1
- package/esm/_internal/expansion-panel.js +0 -32
- package/esm/_internal/expansion-panel.js.map +0 -1
- package/esm/_internal/flag.js +0 -11
- package/esm/_internal/flag.js.map +0 -1
- package/esm/_internal/flex-box.js +0 -11
- package/esm/_internal/flex-box.js.map +0 -1
- package/esm/_internal/generic-block.js +0 -20
- package/esm/_internal/generic-block.js.map +0 -1
- package/esm/_internal/getRootClassName.js +0 -346
- package/esm/_internal/getRootClassName.js.map +0 -1
- package/esm/_internal/grid.js +0 -10
- package/esm/_internal/grid.js.map +0 -1
- package/esm/_internal/heading.js +0 -11
- package/esm/_internal/heading.js.map +0 -1
- package/esm/_internal/icon.js +0 -10
- package/esm/_internal/icon.js.map +0 -1
- package/esm/_internal/image-block.js +0 -14
- package/esm/_internal/image-block.js.map +0 -1
- package/esm/_internal/input-helper.js +0 -10
- package/esm/_internal/input-helper.js.map +0 -1
- package/esm/_internal/input-label.js +0 -10
- package/esm/_internal/input-label.js.map +0 -1
- package/esm/_internal/lightbox.js +0 -27
- package/esm/_internal/lightbox.js.map +0 -1
- package/esm/_internal/link-preview.js +0 -15
- package/esm/_internal/link-preview.js.map +0 -1
- package/esm/_internal/link.js +0 -12
- package/esm/_internal/link.js.map +0 -1
- package/esm/_internal/list.js +0 -15
- package/esm/_internal/list.js.map +0 -1
- package/esm/_internal/mergeRefs.js +0 -25
- package/esm/_internal/mergeRefs.js.map +0 -1
- package/esm/_internal/message.js +0 -11
- package/esm/_internal/message.js.map +0 -1
- package/esm/_internal/mosaic.js +0 -14
- package/esm/_internal/mosaic.js.map +0 -1
- package/esm/_internal/notification.js +0 -18
- package/esm/_internal/notification.js.map +0 -1
- package/esm/_internal/partitionMulti.js +0 -27
- package/esm/_internal/partitionMulti.js.map +0 -1
- package/esm/_internal/popover.js +0 -15
- package/esm/_internal/popover.js.map +0 -1
- package/esm/_internal/post-block.js +0 -15
- package/esm/_internal/post-block.js.map +0 -1
- package/esm/_internal/progress-tracker.js +0 -17
- package/esm/_internal/progress-tracker.js.map +0 -1
- package/esm/_internal/progress.js +0 -10
- package/esm/_internal/progress.js.map +0 -1
- package/esm/_internal/radio-button.js +0 -13
- package/esm/_internal/radio-button.js.map +0 -1
- package/esm/_internal/renderLink.js +0 -25
- package/esm/_internal/renderLink.js.map +0 -1
- package/esm/_internal/select.js +0 -31
- package/esm/_internal/select.js.map +0 -1
- package/esm/_internal/side-navigation.js +0 -25
- package/esm/_internal/side-navigation.js.map +0 -1
- package/esm/_internal/skeleton.js +0 -10
- package/esm/_internal/skeleton.js.map +0 -1
- package/esm/_internal/slider.js +0 -13
- package/esm/_internal/slider.js.map +0 -1
- package/esm/_internal/slideshow.js +0 -29
- package/esm/_internal/slideshow.js.map +0 -1
- package/esm/_internal/state.js +0 -145
- package/esm/_internal/state.js.map +0 -1
- package/esm/_internal/switch.js +0 -13
- package/esm/_internal/switch.js.map +0 -1
- package/esm/_internal/table.js +0 -12
- package/esm/_internal/table.js.map +0 -1
- package/esm/_internal/tabs.js +0 -15
- package/esm/_internal/tabs.js.map +0 -1
- package/esm/_internal/text-field.js +0 -26
- package/esm/_internal/text-field.js.map +0 -1
- package/esm/_internal/text.js +0 -10
- package/esm/_internal/text.js.map +0 -1
- package/esm/_internal/thumbnail.js +0 -13
- package/esm/_internal/thumbnail.js.map +0 -1
- package/esm/_internal/toolbar.js +0 -9
- package/esm/_internal/toolbar.js.map +0 -1
- package/esm/_internal/tooltip.js +0 -18
- package/esm/_internal/tooltip.js.map +0 -1
- package/esm/_internal/type.js +0 -40
- package/esm/_internal/type.js.map +0 -1
- package/esm/_internal/types.js +0 -23
- package/esm/_internal/types.js.map +0 -1
- package/esm/_internal/uploader.js +0 -11
- package/esm/_internal/uploader.js.map +0 -1
- package/esm/_internal/useDelayedVisibility.js +0 -47
- package/esm/_internal/useDelayedVisibility.js.map +0 -1
- package/esm/_internal/useDisableBodyScroll.js +0 -220
- package/esm/_internal/useDisableBodyScroll.js.map +0 -1
- package/esm/_internal/useFocusTrap.js +0 -86
- package/esm/_internal/useFocusTrap.js.map +0 -1
- package/esm/_internal/useRovingTabIndex.js +0 -87
- package/esm/_internal/useRovingTabIndex.js.map +0 -1
- package/esm/_internal/user-block.js +0 -17
- package/esm/_internal/user-block.js.map +0 -1
- package/esm/index.js +0 -95
- package/esm/index.js.map +0 -1
- package/esm/index2.js +0 -16
- package/esm/index2.js.map +0 -1
- package/src/utils/index.tsx +0 -7
package/esm/_internal/List2.js
DELETED
|
@@ -1,799 +0,0 @@
|
|
|
1
|
-
import { d as _slicedToArray, b as _objectWithoutProperties, c as _extends, _ as _objectSpread2, e as _toConsumableArray } from './_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { Size } from './components.js';
|
|
3
|
-
import React, { useState, useEffect, forwardRef, useMemo, Children, isValidElement, cloneElement, useRef } from 'react';
|
|
4
|
-
import { g as getRootClassName, o as onEnterPressed, b as onButtonPressed, c as classnames, h as handleBasicClasses, d as createCommonjsModule } from './getRootClassName.js';
|
|
5
|
-
import 'lodash/isBoolean';
|
|
6
|
-
import isEmpty from 'lodash/isEmpty';
|
|
7
|
-
import 'lodash/kebabCase';
|
|
8
|
-
import 'lodash/noop';
|
|
9
|
-
import get from 'lodash/get';
|
|
10
|
-
import { i as isComponent } from './type.js';
|
|
11
|
-
import { m as mergeRefs } from './mergeRefs.js';
|
|
12
|
-
import { r as renderLink } from './renderLink.js';
|
|
13
|
-
|
|
14
|
-
var INITIAL_INDEX = -1;
|
|
15
|
-
/**
|
|
16
|
-
* This custom hook provides the necessary set of functions and values to properly navigate
|
|
17
|
-
* a list using the keyboard.
|
|
18
|
-
*
|
|
19
|
-
* @param items the list of items that will be navigated using the keyboard.
|
|
20
|
-
* @param ref A reference to the element that is controlling the navigation.
|
|
21
|
-
* @param onListItemSelected callback to be executed when the ENTER key is pressed on an item.
|
|
22
|
-
* @param onListItemNavigated callback to be executed when the Arrow keys are pressed.
|
|
23
|
-
* @param onEnterPressed callback to be executed when the ENTER key is pressed.
|
|
24
|
-
* @param onBackspacePressed callback to be executed when the BACKSPACE key is pressed.
|
|
25
|
-
* @param keepFocusAfterSelection determines whether after selecting an item, the focus should be maintained on the current target or not.
|
|
26
|
-
* @param initialIndex where should the navigation start from. it defaults to `-1`, so the first item navigated is the item on position `0`.
|
|
27
|
-
* @param preventTabOnEnteredValue determines whether upon TAB, if there is a value entered, the event is prevented or not.
|
|
28
|
-
* @return useKeyboardListNavigation helpers.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
var useKeyboardListNavigation = function useKeyboardListNavigation(items, ref, onListItemSelected, onListItemNavigated, onEnterPressed, onBackspacePressed) {
|
|
32
|
-
var keepFocusAfterSelection = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
33
|
-
var initialIndex = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : INITIAL_INDEX;
|
|
34
|
-
var preventTabOnEnteredValue = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : true;
|
|
35
|
-
|
|
36
|
-
var _useState = useState(initialIndex),
|
|
37
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
-
activeItemIndex = _useState2[0],
|
|
39
|
-
setActiveItemIndex = _useState2[1];
|
|
40
|
-
/**
|
|
41
|
-
* This function calculates the next index in the list to be highlighted
|
|
42
|
-
* @param key - key code pressed
|
|
43
|
-
* @return next active index
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var calculateActiveIndex = function calculateActiveIndex(key) {
|
|
48
|
-
switch (key) {
|
|
49
|
-
case 'ArrowDown':
|
|
50
|
-
return activeItemIndex + 1 < items.length ? activeItemIndex + 1 : 0;
|
|
51
|
-
|
|
52
|
-
case 'ArrowUp':
|
|
53
|
-
return activeItemIndex - 1 >= 0 ? activeItemIndex - 1 : items.length - 1;
|
|
54
|
-
|
|
55
|
-
default:
|
|
56
|
-
return initialIndex;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Resets the active index to the initial state
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var resetActiveIndex = function resetActiveIndex() {
|
|
65
|
-
setActiveItemIndex(initialIndex);
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Prevents the default event and stops the propagation of said event
|
|
69
|
-
* @param evt - key pressed event
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var preventDefaultAndStopPropagation = function preventDefaultAndStopPropagation(evt) {
|
|
74
|
-
evt.preventDefault();
|
|
75
|
-
evt.stopPropagation();
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Handles navigation with the arrows using the keyboard
|
|
79
|
-
* @param evt - key pressed event
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var onArrowPressed = function onArrowPressed(evt) {
|
|
84
|
-
var key = evt.key;
|
|
85
|
-
var nextActiveIndex = calculateActiveIndex(key);
|
|
86
|
-
setActiveItemIndex(nextActiveIndex);
|
|
87
|
-
preventDefaultAndStopPropagation(evt);
|
|
88
|
-
|
|
89
|
-
if (onListItemNavigated) {
|
|
90
|
-
var selectedItem = items[nextActiveIndex];
|
|
91
|
-
onListItemNavigated(selectedItem);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Handles the event when the backspace key is pressed
|
|
96
|
-
* @param evt - key pressed event
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var onBackspaceKeyPressed = function onBackspaceKeyPressed(evt) {
|
|
101
|
-
if (onBackspacePressed) {
|
|
102
|
-
onBackspacePressed(evt);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Handles when the ENTER key is pressed
|
|
107
|
-
* @param evt - key pressed event
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var onEnterKeyPressed = function onEnterKeyPressed(evt) {
|
|
112
|
-
if (!onListItemSelected) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
preventDefaultAndStopPropagation(evt);
|
|
117
|
-
|
|
118
|
-
if (!keepFocusAfterSelection) {
|
|
119
|
-
evt.currentTarget.blur();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
var selectedItem = items[activeItemIndex];
|
|
123
|
-
|
|
124
|
-
if (selectedItem) {
|
|
125
|
-
onListItemSelected(selectedItem);
|
|
126
|
-
resetActiveIndex();
|
|
127
|
-
} else if (activeItemIndex === initialIndex && onEnterPressed) {
|
|
128
|
-
var _value = get(evt, 'target.value');
|
|
129
|
-
|
|
130
|
-
onEnterPressed(_value);
|
|
131
|
-
resetActiveIndex();
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Handles when the TAB key is pressed
|
|
136
|
-
* @param evt - key pressed event
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var onTabKeyPressed = function onTabKeyPressed(evt) {
|
|
141
|
-
var value = get(evt, 'target.value');
|
|
142
|
-
|
|
143
|
-
if (preventTabOnEnteredValue && value && value.length > 0) {
|
|
144
|
-
preventDefaultAndStopPropagation(evt);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* In order to make it easier in the future to add new events depending on the key
|
|
149
|
-
* a map was created to add these handlers. In the future, if there is another event
|
|
150
|
-
* that we need to manage depending on a specific key, we just need to add the key code
|
|
151
|
-
* here, and as a value, the handler for said key.
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
var eventsForKeyPressed = {
|
|
156
|
-
ArrowDown: onArrowPressed,
|
|
157
|
-
Tab: onTabKeyPressed,
|
|
158
|
-
ArrowUp: onArrowPressed,
|
|
159
|
-
Enter: onEnterKeyPressed,
|
|
160
|
-
Backspace: onBackspaceKeyPressed
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Calculates the next active item index depending on the key pressed.
|
|
164
|
-
* If the key pressed was ENTER, the function executes the callback `onListItemSelected`
|
|
165
|
-
* and resets the active index, since an item was selected.
|
|
166
|
-
* @param evt - key pressed or key down event
|
|
167
|
-
*/
|
|
168
|
-
|
|
169
|
-
var onKeyboardNavigation = function onKeyboardNavigation(evt) {
|
|
170
|
-
var key = evt.key;
|
|
171
|
-
var handler = eventsForKeyPressed[key];
|
|
172
|
-
|
|
173
|
-
if (handler) {
|
|
174
|
-
handler(evt);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
useEffect(function () {
|
|
179
|
-
var currentElement = ref.current;
|
|
180
|
-
|
|
181
|
-
if (!currentElement) {
|
|
182
|
-
return undefined;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
currentElement.addEventListener('focus', resetActiveIndex);
|
|
186
|
-
currentElement.addEventListener('keydown', onKeyboardNavigation);
|
|
187
|
-
return function () {
|
|
188
|
-
currentElement.removeEventListener('focus', resetActiveIndex);
|
|
189
|
-
currentElement.removeEventListener('keydown', onKeyboardNavigation);
|
|
190
|
-
};
|
|
191
|
-
});
|
|
192
|
-
return {
|
|
193
|
-
activeItemIndex: activeItemIndex,
|
|
194
|
-
onKeyboardNavigation: onKeyboardNavigation,
|
|
195
|
-
resetActiveIndex: resetActiveIndex,
|
|
196
|
-
setActiveItemIndex: setActiveItemIndex
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Component display name.
|
|
202
|
-
*/
|
|
203
|
-
var COMPONENT_NAME = 'ListItem';
|
|
204
|
-
/**
|
|
205
|
-
* Component default class name and class prefix.
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
var CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
209
|
-
/**
|
|
210
|
-
* Component default props.
|
|
211
|
-
*/
|
|
212
|
-
|
|
213
|
-
var DEFAULT_PROPS = {
|
|
214
|
-
size: Size.regular
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Check if the list item is clickable.
|
|
218
|
-
* @return `true` if the list item is clickable; `false` otherwise.
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
function isClickable(_ref) {
|
|
222
|
-
var linkProps = _ref.linkProps,
|
|
223
|
-
onItemSelected = _ref.onItemSelected;
|
|
224
|
-
return !isEmpty(linkProps === null || linkProps === void 0 ? void 0 : linkProps.href) || !!onItemSelected;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* ListItem component.
|
|
228
|
-
*
|
|
229
|
-
* @param props Component props.
|
|
230
|
-
* @param ref Component ref.
|
|
231
|
-
* @return React element.
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
var ListItem = forwardRef(function (props, ref) {
|
|
235
|
-
var after = props.after,
|
|
236
|
-
before = props.before,
|
|
237
|
-
children = props.children,
|
|
238
|
-
className = props.className,
|
|
239
|
-
isHighlighted = props.isHighlighted,
|
|
240
|
-
isSelected = props.isSelected,
|
|
241
|
-
isDisabled = props.isDisabled,
|
|
242
|
-
linkAs = props.linkAs,
|
|
243
|
-
_props$linkProps = props.linkProps,
|
|
244
|
-
linkProps = _props$linkProps === void 0 ? {} : _props$linkProps,
|
|
245
|
-
linkRef = props.linkRef,
|
|
246
|
-
onItemSelected = props.onItemSelected,
|
|
247
|
-
size = props.size,
|
|
248
|
-
forwardedProps = _objectWithoutProperties(props, ["after", "before", "children", "className", "isHighlighted", "isSelected", "isDisabled", "linkAs", "linkProps", "linkRef", "onItemSelected", "size"]);
|
|
249
|
-
|
|
250
|
-
var role = linkAs || linkProps.href ? 'link' : 'button';
|
|
251
|
-
var onKeyDown = useMemo(function () {
|
|
252
|
-
if (onItemSelected && role === 'link') return onEnterPressed(onItemSelected);
|
|
253
|
-
if (onItemSelected && role === 'button') return onButtonPressed(onItemSelected);
|
|
254
|
-
return undefined;
|
|
255
|
-
}, [role, onItemSelected]);
|
|
256
|
-
var content = React.createElement(React.Fragment, null, before && React.createElement("div", {
|
|
257
|
-
className: "".concat(CLASSNAME, "__before")
|
|
258
|
-
}, before), React.createElement("div", {
|
|
259
|
-
className: "".concat(CLASSNAME, "__content")
|
|
260
|
-
}, children), after && React.createElement("div", {
|
|
261
|
-
className: "".concat(CLASSNAME, "__after")
|
|
262
|
-
}, after));
|
|
263
|
-
return React.createElement("li", _extends({
|
|
264
|
-
ref: ref
|
|
265
|
-
}, forwardedProps, {
|
|
266
|
-
className: classnames(className, handleBasicClasses({
|
|
267
|
-
prefix: CLASSNAME,
|
|
268
|
-
size: size
|
|
269
|
-
}))
|
|
270
|
-
}), isClickable({
|
|
271
|
-
linkProps: linkProps,
|
|
272
|
-
onItemSelected: onItemSelected
|
|
273
|
-
}) ?
|
|
274
|
-
/* Clickable list item */
|
|
275
|
-
renderLink(_objectSpread2({
|
|
276
|
-
linkAs: linkAs,
|
|
277
|
-
tabIndex: !isDisabled && role === 'button' ? 0 : undefined,
|
|
278
|
-
role: role,
|
|
279
|
-
'aria-disabled': isDisabled
|
|
280
|
-
}, linkProps, {
|
|
281
|
-
href: isDisabled ? undefined : linkProps.href,
|
|
282
|
-
className: classnames(handleBasicClasses({
|
|
283
|
-
prefix: "".concat(CLASSNAME, "__link"),
|
|
284
|
-
isHighlighted: isHighlighted,
|
|
285
|
-
isSelected: isSelected,
|
|
286
|
-
isDisabled: isDisabled
|
|
287
|
-
})),
|
|
288
|
-
onClick: isDisabled ? undefined : onItemSelected,
|
|
289
|
-
onKeyDown: onKeyDown,
|
|
290
|
-
ref: linkRef
|
|
291
|
-
}), content) :
|
|
292
|
-
/* Non clickable list item */
|
|
293
|
-
React.createElement("div", {
|
|
294
|
-
className: "".concat(CLASSNAME, "__wrapper")
|
|
295
|
-
}, content));
|
|
296
|
-
});
|
|
297
|
-
ListItem.displayName = COMPONENT_NAME;
|
|
298
|
-
ListItem.className = CLASSNAME;
|
|
299
|
-
ListItem.defaultProps = DEFAULT_PROPS;
|
|
300
|
-
|
|
301
|
-
/** @license React v16.13.1
|
|
302
|
-
* react-is.production.min.js
|
|
303
|
-
*
|
|
304
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
305
|
-
*
|
|
306
|
-
* This source code is licensed under the MIT license found in the
|
|
307
|
-
* LICENSE file in the root directory of this source tree.
|
|
308
|
-
*/
|
|
309
|
-
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
|
|
310
|
-
Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
|
|
311
|
-
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}var AsyncMode=l;var ConcurrentMode=m;var ContextConsumer=k;var ContextProvider=h;var Element=c;var ForwardRef=n;var Fragment=e;var Lazy=t;var Memo=r;var Portal=d;
|
|
312
|
-
var Profiler=g;var StrictMode=f;var Suspense=p;var isAsyncMode=function(a){return A(a)||z(a)===l};var isConcurrentMode=A;var isContextConsumer=function(a){return z(a)===k};var isContextProvider=function(a){return z(a)===h};var isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};var isForwardRef=function(a){return z(a)===n};var isFragment=function(a){return z(a)===e};var isLazy=function(a){return z(a)===t};
|
|
313
|
-
var isMemo=function(a){return z(a)===r};var isPortal=function(a){return z(a)===d};var isProfiler=function(a){return z(a)===g};var isStrictMode=function(a){return z(a)===f};var isSuspense=function(a){return z(a)===p};
|
|
314
|
-
var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};var typeOf=z;
|
|
315
|
-
|
|
316
|
-
var reactIs_production_min = {
|
|
317
|
-
AsyncMode: AsyncMode,
|
|
318
|
-
ConcurrentMode: ConcurrentMode,
|
|
319
|
-
ContextConsumer: ContextConsumer,
|
|
320
|
-
ContextProvider: ContextProvider,
|
|
321
|
-
Element: Element,
|
|
322
|
-
ForwardRef: ForwardRef,
|
|
323
|
-
Fragment: Fragment,
|
|
324
|
-
Lazy: Lazy,
|
|
325
|
-
Memo: Memo,
|
|
326
|
-
Portal: Portal,
|
|
327
|
-
Profiler: Profiler,
|
|
328
|
-
StrictMode: StrictMode,
|
|
329
|
-
Suspense: Suspense,
|
|
330
|
-
isAsyncMode: isAsyncMode,
|
|
331
|
-
isConcurrentMode: isConcurrentMode,
|
|
332
|
-
isContextConsumer: isContextConsumer,
|
|
333
|
-
isContextProvider: isContextProvider,
|
|
334
|
-
isElement: isElement,
|
|
335
|
-
isForwardRef: isForwardRef,
|
|
336
|
-
isFragment: isFragment,
|
|
337
|
-
isLazy: isLazy,
|
|
338
|
-
isMemo: isMemo,
|
|
339
|
-
isPortal: isPortal,
|
|
340
|
-
isProfiler: isProfiler,
|
|
341
|
-
isStrictMode: isStrictMode,
|
|
342
|
-
isSuspense: isSuspense,
|
|
343
|
-
isValidElementType: isValidElementType,
|
|
344
|
-
typeOf: typeOf
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
var reactIs_development = createCommonjsModule(function (module, exports) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
if (process.env.NODE_ENV !== "production") {
|
|
352
|
-
(function() {
|
|
353
|
-
|
|
354
|
-
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
355
|
-
// nor polyfill, then a plain number is used for performance.
|
|
356
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
357
|
-
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
358
|
-
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
359
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
360
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
361
|
-
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
362
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
363
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
364
|
-
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
365
|
-
|
|
366
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
367
|
-
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
368
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
369
|
-
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
370
|
-
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
371
|
-
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
372
|
-
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
373
|
-
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
374
|
-
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
375
|
-
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
376
|
-
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
377
|
-
|
|
378
|
-
function isValidElementType(type) {
|
|
379
|
-
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
380
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function typeOf(object) {
|
|
384
|
-
if (typeof object === 'object' && object !== null) {
|
|
385
|
-
var $$typeof = object.$$typeof;
|
|
386
|
-
|
|
387
|
-
switch ($$typeof) {
|
|
388
|
-
case REACT_ELEMENT_TYPE:
|
|
389
|
-
var type = object.type;
|
|
390
|
-
|
|
391
|
-
switch (type) {
|
|
392
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
393
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
394
|
-
case REACT_FRAGMENT_TYPE:
|
|
395
|
-
case REACT_PROFILER_TYPE:
|
|
396
|
-
case REACT_STRICT_MODE_TYPE:
|
|
397
|
-
case REACT_SUSPENSE_TYPE:
|
|
398
|
-
return type;
|
|
399
|
-
|
|
400
|
-
default:
|
|
401
|
-
var $$typeofType = type && type.$$typeof;
|
|
402
|
-
|
|
403
|
-
switch ($$typeofType) {
|
|
404
|
-
case REACT_CONTEXT_TYPE:
|
|
405
|
-
case REACT_FORWARD_REF_TYPE:
|
|
406
|
-
case REACT_LAZY_TYPE:
|
|
407
|
-
case REACT_MEMO_TYPE:
|
|
408
|
-
case REACT_PROVIDER_TYPE:
|
|
409
|
-
return $$typeofType;
|
|
410
|
-
|
|
411
|
-
default:
|
|
412
|
-
return $$typeof;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
case REACT_PORTAL_TYPE:
|
|
418
|
-
return $$typeof;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
return undefined;
|
|
423
|
-
} // AsyncMode is deprecated along with isAsyncMode
|
|
424
|
-
|
|
425
|
-
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
426
|
-
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
427
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
428
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
429
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
430
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
431
|
-
var Fragment = REACT_FRAGMENT_TYPE;
|
|
432
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
433
|
-
var Memo = REACT_MEMO_TYPE;
|
|
434
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
435
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
436
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
437
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
438
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
439
|
-
|
|
440
|
-
function isAsyncMode(object) {
|
|
441
|
-
{
|
|
442
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
443
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
444
|
-
|
|
445
|
-
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
450
|
-
}
|
|
451
|
-
function isConcurrentMode(object) {
|
|
452
|
-
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
453
|
-
}
|
|
454
|
-
function isContextConsumer(object) {
|
|
455
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
456
|
-
}
|
|
457
|
-
function isContextProvider(object) {
|
|
458
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
459
|
-
}
|
|
460
|
-
function isElement(object) {
|
|
461
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
462
|
-
}
|
|
463
|
-
function isForwardRef(object) {
|
|
464
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
465
|
-
}
|
|
466
|
-
function isFragment(object) {
|
|
467
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
468
|
-
}
|
|
469
|
-
function isLazy(object) {
|
|
470
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
471
|
-
}
|
|
472
|
-
function isMemo(object) {
|
|
473
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
474
|
-
}
|
|
475
|
-
function isPortal(object) {
|
|
476
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
477
|
-
}
|
|
478
|
-
function isProfiler(object) {
|
|
479
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
480
|
-
}
|
|
481
|
-
function isStrictMode(object) {
|
|
482
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
483
|
-
}
|
|
484
|
-
function isSuspense(object) {
|
|
485
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
exports.AsyncMode = AsyncMode;
|
|
489
|
-
exports.ConcurrentMode = ConcurrentMode;
|
|
490
|
-
exports.ContextConsumer = ContextConsumer;
|
|
491
|
-
exports.ContextProvider = ContextProvider;
|
|
492
|
-
exports.Element = Element;
|
|
493
|
-
exports.ForwardRef = ForwardRef;
|
|
494
|
-
exports.Fragment = Fragment;
|
|
495
|
-
exports.Lazy = Lazy;
|
|
496
|
-
exports.Memo = Memo;
|
|
497
|
-
exports.Portal = Portal;
|
|
498
|
-
exports.Profiler = Profiler;
|
|
499
|
-
exports.StrictMode = StrictMode;
|
|
500
|
-
exports.Suspense = Suspense;
|
|
501
|
-
exports.isAsyncMode = isAsyncMode;
|
|
502
|
-
exports.isConcurrentMode = isConcurrentMode;
|
|
503
|
-
exports.isContextConsumer = isContextConsumer;
|
|
504
|
-
exports.isContextProvider = isContextProvider;
|
|
505
|
-
exports.isElement = isElement;
|
|
506
|
-
exports.isForwardRef = isForwardRef;
|
|
507
|
-
exports.isFragment = isFragment;
|
|
508
|
-
exports.isLazy = isLazy;
|
|
509
|
-
exports.isMemo = isMemo;
|
|
510
|
-
exports.isPortal = isPortal;
|
|
511
|
-
exports.isProfiler = isProfiler;
|
|
512
|
-
exports.isStrictMode = isStrictMode;
|
|
513
|
-
exports.isSuspense = isSuspense;
|
|
514
|
-
exports.isValidElementType = isValidElementType;
|
|
515
|
-
exports.typeOf = typeOf;
|
|
516
|
-
})();
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
var reactIs = createCommonjsModule(function (module) {
|
|
521
|
-
|
|
522
|
-
if (process.env.NODE_ENV === 'production') {
|
|
523
|
-
module.exports = reactIs_production_min;
|
|
524
|
-
} else {
|
|
525
|
-
module.exports = reactIs_development;
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* Flatten list of react nodes removing fragments and adding keys.
|
|
531
|
-
* based on: https://github.com/grrowl/react-keyed-flatten-children/blob/5d421644a449765ddd62b659946196b4b5d7b135/index.ts
|
|
532
|
-
*
|
|
533
|
-
* @param children React nodes to flatten.
|
|
534
|
-
* @return Flattened react nodes.
|
|
535
|
-
*/
|
|
536
|
-
|
|
537
|
-
function flattenChildren(children) {
|
|
538
|
-
function recur(nodes) {
|
|
539
|
-
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
540
|
-
return Children.toArray(nodes).reduce(function (acc, node, index) {
|
|
541
|
-
var _get;
|
|
542
|
-
|
|
543
|
-
var nodeKeys = keys.concat((_get = get(node, 'key')) !== null && _get !== void 0 ? _get : index);
|
|
544
|
-
|
|
545
|
-
if (reactIs.isFragment(node)) {
|
|
546
|
-
acc.push.apply(acc, _toConsumableArray(recur(node.props.children, nodeKeys)));
|
|
547
|
-
} else if (isValidElement(node)) {
|
|
548
|
-
acc.push(cloneElement(node, {
|
|
549
|
-
key: nodeKeys.join('.')
|
|
550
|
-
}));
|
|
551
|
-
} else if (typeof node === 'string' || typeof node === 'number') {
|
|
552
|
-
acc.push(node);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
return acc;
|
|
556
|
-
}, []);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
return recur(children);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
var INITIAL_INDEX$1 = -1;
|
|
563
|
-
|
|
564
|
-
function onKeyboardFocus(props, handler) {
|
|
565
|
-
var isMouseDown = false;
|
|
566
|
-
return {
|
|
567
|
-
onFocus: function onFocus(evt) {
|
|
568
|
-
var _props$onFocus;
|
|
569
|
-
|
|
570
|
-
(_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 ? void 0 : _props$onFocus.call(props, evt);
|
|
571
|
-
|
|
572
|
-
if (!isMouseDown) {
|
|
573
|
-
handler(evt);
|
|
574
|
-
}
|
|
575
|
-
},
|
|
576
|
-
onMouseDown: function onMouseDown(evt) {
|
|
577
|
-
var _props$onMouseDown;
|
|
578
|
-
|
|
579
|
-
(_props$onMouseDown = props.onMouseDown) === null || _props$onMouseDown === void 0 ? void 0 : _props$onMouseDown.call(props, evt);
|
|
580
|
-
isMouseDown = true;
|
|
581
|
-
},
|
|
582
|
-
onMouseUp: function onMouseUp(evt) {
|
|
583
|
-
var _props$onMouseUp;
|
|
584
|
-
|
|
585
|
-
(_props$onMouseUp = props.onMouseUp) === null || _props$onMouseUp === void 0 ? void 0 : _props$onMouseUp.call(props, evt);
|
|
586
|
-
isMouseDown = false;
|
|
587
|
-
}
|
|
588
|
-
};
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
var isNavigableItem = function isNavigableItem(node) {
|
|
592
|
-
return isComponent('ListItem')(node) && isClickable(node.props) && !node.props.isDisabled;
|
|
593
|
-
};
|
|
594
|
-
/**
|
|
595
|
-
* This custom hook detects clickable list item in a list and make them navigable with the keyboard.
|
|
596
|
-
*
|
|
597
|
-
* @param options See {@link Options}
|
|
598
|
-
* @return See {@link Output}
|
|
599
|
-
*/
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
var useInteractiveList = function useInteractiveList(options) {
|
|
603
|
-
var ref = options.ref,
|
|
604
|
-
onListItemSelected = options.onListItemSelected,
|
|
605
|
-
onListItemNavigated = options.onListItemNavigated;
|
|
606
|
-
var items = useMemo(function () {
|
|
607
|
-
return flattenChildren(options.items);
|
|
608
|
-
}, [options.items]);
|
|
609
|
-
|
|
610
|
-
var _useState = useState(INITIAL_INDEX$1),
|
|
611
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
612
|
-
activeItemIndex = _useState2[0],
|
|
613
|
-
setActiveItemIndex = _useState2[1]; // Attach listeners to the list.
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
useEffect(function () {
|
|
617
|
-
var listElement = ref.current;
|
|
618
|
-
|
|
619
|
-
if (!listElement) {
|
|
620
|
-
return undefined;
|
|
621
|
-
}
|
|
622
|
-
/**
|
|
623
|
-
* This function calculates the next index in the list to be active
|
|
624
|
-
* @param index current index
|
|
625
|
-
* @param code key code pressed
|
|
626
|
-
* @return next index
|
|
627
|
-
*/
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
var getNextIndex = function getNextIndex(index, key) {
|
|
631
|
-
switch (key) {
|
|
632
|
-
case 'ArrowDown':
|
|
633
|
-
return index + 1 < items.length ? index + 1 : 0;
|
|
634
|
-
|
|
635
|
-
case 'ArrowUp':
|
|
636
|
-
return index - 1 >= 0 ? index - 1 : items.length - 1;
|
|
637
|
-
|
|
638
|
-
default:
|
|
639
|
-
return INITIAL_INDEX$1;
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
/**
|
|
643
|
-
* Resets the active index to the initial state
|
|
644
|
-
*/
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
var resetActiveIndex = function resetActiveIndex() {
|
|
648
|
-
setActiveItemIndex(INITIAL_INDEX$1);
|
|
649
|
-
};
|
|
650
|
-
/**
|
|
651
|
-
* Handles navigation with the arrows using the keyboard
|
|
652
|
-
* @param evt Key event
|
|
653
|
-
*/
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
var onArrowPressed = function onArrowPressed(evt) {
|
|
657
|
-
var key = evt.key;
|
|
658
|
-
|
|
659
|
-
if (key !== 'ArrowUp' && key !== 'ArrowDown') {
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
var nextIndex = activeItemIndex;
|
|
664
|
-
var iterations = 0; // Move to next navigable item.
|
|
665
|
-
|
|
666
|
-
do {
|
|
667
|
-
nextIndex = getNextIndex(nextIndex, key);
|
|
668
|
-
iterations += 1;
|
|
669
|
-
} while (nextIndex !== INITIAL_INDEX$1 && nextIndex !== activeItemIndex && !isNavigableItem(items[nextIndex]) && iterations < items.length);
|
|
670
|
-
|
|
671
|
-
setActiveItemIndex(nextIndex);
|
|
672
|
-
evt.preventDefault();
|
|
673
|
-
evt.stopPropagation();
|
|
674
|
-
onListItemNavigated === null || onListItemNavigated === void 0 ? void 0 : onListItemNavigated(nextIndex, get(items, [nextIndex, 'key']));
|
|
675
|
-
};
|
|
676
|
-
/**
|
|
677
|
-
* Reset active list item index when focusing outside the list.
|
|
678
|
-
* @param evt Focus out event
|
|
679
|
-
*/
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
var onFocusOut = function onFocusOut(evt) {
|
|
683
|
-
if (!evt.relatedTarget || !listElement.contains(evt.relatedTarget)) {
|
|
684
|
-
resetActiveIndex();
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
listElement.addEventListener('focusout', onFocusOut);
|
|
689
|
-
listElement.addEventListener('keydown', onArrowPressed);
|
|
690
|
-
return function () {
|
|
691
|
-
listElement.removeEventListener('focusout', onFocusOut);
|
|
692
|
-
listElement.removeEventListener('keydown', onArrowPressed);
|
|
693
|
-
};
|
|
694
|
-
}, [ref, activeItemIndex, items, onListItemNavigated]);
|
|
695
|
-
return useMemo(function () {
|
|
696
|
-
var hasClickableItem = false;
|
|
697
|
-
var transformedItems = items.map(function (item, index) {
|
|
698
|
-
var _item$props$isHighlig;
|
|
699
|
-
|
|
700
|
-
// Ignore if list not clickable or item is not a simple list item.
|
|
701
|
-
if (!isNavigableItem(item)) {
|
|
702
|
-
return item;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
hasClickableItem = true;
|
|
706
|
-
var isHighlighted = index === activeItemIndex; // Clone list item: inject ref, add tab index and active state.
|
|
707
|
-
|
|
708
|
-
return cloneElement(item, _objectSpread2({}, item.props, {
|
|
709
|
-
isHighlighted: (_item$props$isHighlig = item.props.isHighlighted) !== null && _item$props$isHighlig !== void 0 ? _item$props$isHighlig : isHighlighted,
|
|
710
|
-
linkRef: mergeRefs(item.props.linkRef, function (element) {
|
|
711
|
-
if (isHighlighted) {
|
|
712
|
-
element === null || element === void 0 ? void 0 : element.focus();
|
|
713
|
-
}
|
|
714
|
-
}),
|
|
715
|
-
onItemSelected: function onItemSelected(evt) {
|
|
716
|
-
var _item$props$onItemSel, _item$props;
|
|
717
|
-
|
|
718
|
-
(_item$props$onItemSel = (_item$props = item.props).onItemSelected) === null || _item$props$onItemSel === void 0 ? void 0 : _item$props$onItemSel.call(_item$props);
|
|
719
|
-
onListItemSelected === null || onListItemSelected === void 0 ? void 0 : onListItemSelected(index, item.key, evt);
|
|
720
|
-
}
|
|
721
|
-
}, onKeyboardFocus(item.props, function () {
|
|
722
|
-
setActiveItemIndex(index);
|
|
723
|
-
})));
|
|
724
|
-
});
|
|
725
|
-
return {
|
|
726
|
-
items: transformedItems,
|
|
727
|
-
hasClickableItem: hasClickableItem
|
|
728
|
-
};
|
|
729
|
-
}, [items, activeItemIndex, onListItemSelected]);
|
|
730
|
-
};
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* Defines the props of the component.
|
|
734
|
-
*/
|
|
735
|
-
|
|
736
|
-
/**
|
|
737
|
-
* Component display name.
|
|
738
|
-
*/
|
|
739
|
-
var COMPONENT_NAME$1 = 'List';
|
|
740
|
-
/**
|
|
741
|
-
* Component default class name and class prefix.
|
|
742
|
-
*/
|
|
743
|
-
|
|
744
|
-
var CLASSNAME$1 = getRootClassName(COMPONENT_NAME$1);
|
|
745
|
-
/**
|
|
746
|
-
* Component default props.
|
|
747
|
-
*/
|
|
748
|
-
|
|
749
|
-
var DEFAULT_PROPS$1 = {
|
|
750
|
-
tabIndex: -1
|
|
751
|
-
};
|
|
752
|
-
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */
|
|
753
|
-
|
|
754
|
-
/**
|
|
755
|
-
* List component.
|
|
756
|
-
*
|
|
757
|
-
* @param props Component props.
|
|
758
|
-
* @param ref Component ref.
|
|
759
|
-
* @return React element.
|
|
760
|
-
*/
|
|
761
|
-
|
|
762
|
-
var InternalList = forwardRef(function (props, ref) {
|
|
763
|
-
var children = props.children,
|
|
764
|
-
className = props.className,
|
|
765
|
-
isClickable = props.isClickable,
|
|
766
|
-
itemPadding = props.itemPadding,
|
|
767
|
-
onListItemSelected = props.onListItemSelected,
|
|
768
|
-
tabIndex = props.tabIndex,
|
|
769
|
-
forwardedProps = _objectWithoutProperties(props, ["children", "className", "isClickable", "itemPadding", "onListItemSelected", "tabIndex"]);
|
|
770
|
-
|
|
771
|
-
var listElementRef = useRef(null);
|
|
772
|
-
|
|
773
|
-
var _useInteractiveList = useInteractiveList({
|
|
774
|
-
items: children,
|
|
775
|
-
ref: listElementRef,
|
|
776
|
-
onListItemSelected: onListItemSelected
|
|
777
|
-
}),
|
|
778
|
-
items = _useInteractiveList.items,
|
|
779
|
-
hasClickableItem = _useInteractiveList.hasClickableItem;
|
|
780
|
-
|
|
781
|
-
var clickable = hasClickableItem || isClickable;
|
|
782
|
-
return React.createElement("ul", _extends({}, forwardedProps, {
|
|
783
|
-
className: classnames(className, handleBasicClasses({
|
|
784
|
-
prefix: CLASSNAME$1,
|
|
785
|
-
itemPadding: itemPadding !== null && itemPadding !== void 0 ? itemPadding : clickable ? Size.big : undefined
|
|
786
|
-
})),
|
|
787
|
-
tabIndex: tabIndex,
|
|
788
|
-
ref: mergeRefs(ref, listElementRef)
|
|
789
|
-
}), items);
|
|
790
|
-
});
|
|
791
|
-
InternalList.displayName = COMPONENT_NAME$1;
|
|
792
|
-
InternalList.className = CLASSNAME$1;
|
|
793
|
-
InternalList.defaultProps = DEFAULT_PROPS$1;
|
|
794
|
-
var List = Object.assign(InternalList, {
|
|
795
|
-
useKeyboardListNavigation: useKeyboardListNavigation
|
|
796
|
-
});
|
|
797
|
-
|
|
798
|
-
export { List as L, ListItem as a, isClickable as i };
|
|
799
|
-
//# sourceMappingURL=List2.js.map
|