@salutejs/plasma-new-hope 0.76.2-canary.1184.8705168480.0 → 0.76.2-dev.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/cjs/components/Calendar/CalendarBase/CalendarBase.js +1 -1
- package/cjs/components/Calendar/CalendarBase/CalendarBase.js.map +1 -1
- package/cjs/components/Calendar/CalendarDouble/CalendarDouble.js +1 -1
- package/cjs/components/Calendar/CalendarDouble/CalendarDouble.js.map +1 -1
- package/cjs/components/Calendar/hoc/withRange.js +1 -1
- package/cjs/components/Calendar/hoc/withRange.js.map +1 -1
- package/cjs/components/Calendar/hooks/useKeyNavigation.js +19 -19
- package/cjs/components/Calendar/hooks/useKeyNavigation.js.map +1 -1
- package/cjs/components/Calendar/ui/CalendarDays/CalendarDays.js +3 -3
- package/cjs/components/Calendar/ui/CalendarDays/CalendarDays.js.map +1 -1
- package/cjs/components/Calendar/ui/CalendarHeader/CalendarHeader.js +2 -2
- package/cjs/components/Calendar/ui/CalendarHeader/CalendarHeader.js.map +1 -1
- package/cjs/components/Calendar/ui/CalendarMonths/CalendarMonths.js +1 -1
- package/cjs/components/Calendar/ui/CalendarMonths/CalendarMonths.js.map +1 -1
- package/cjs/components/Calendar/ui/CalendarYears/CalendarYears.js +1 -1
- package/cjs/components/Calendar/ui/CalendarYears/CalendarYears.js.map +1 -1
- package/cjs/components/Chip/Chip.css +2 -0
- package/cjs/components/Chip/Chip.js +16 -4
- package/cjs/components/Chip/Chip.js.map +1 -1
- package/cjs/components/Chip/Chip.tokens.js +5 -0
- package/cjs/components/Chip/Chip.tokens.js.map +1 -1
- package/cjs/components/Chip/variations/_pilled/base.js +9 -0
- package/cjs/components/Chip/variations/_pilled/base.js.map +1 -0
- package/cjs/components/Chip/variations/_pilled/base_3kce4h.css +1 -0
- package/cjs/components/Combobox/Combobox.css +2 -0
- package/cjs/components/Combobox/Combobox.js +5 -5
- package/cjs/components/Combobox/Combobox.js.map +1 -1
- package/cjs/components/Combobox/hooks/useFocusController.js +9 -9
- package/cjs/components/Combobox/hooks/useFocusController.js.map +1 -1
- package/cjs/components/Combobox/ui/ComboboxChip/ComboboxChip.css +2 -0
- package/cjs/components/Combobox/ui/ComboboxChip/ComboboxChip.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxChip/ComboboxChip.js.map +1 -1
- package/cjs/components/Combobox/ui/ComboboxTarget/ComboboxTarget.css +2 -0
- package/cjs/components/Combobox/ui/ComboboxTarget/ComboboxTarget.js +6 -6
- package/cjs/components/Combobox/ui/ComboboxTarget/ComboboxTarget.js.map +1 -1
- package/cjs/components/Drawer/DrawerContext.js +1 -1
- package/cjs/components/Drawer/DrawerContext.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -2
- package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
- package/cjs/components/Modal/ModalContext.js +1 -1
- package/cjs/components/Modal/ModalContext.js.map +1 -1
- package/cjs/components/Overlay/Overlay.js +1 -1
- package/cjs/components/Overlay/Overlay.js.map +1 -1
- package/cjs/components/Pagination/Pagination.css +2 -0
- package/cjs/components/Pagination/Pagination.js +2 -2
- package/cjs/components/Pagination/Pagination.js.map +1 -1
- package/cjs/components/Pagination/ui/PaginationQuickJumpToPage/PaginationQuickJumpToPage.js +1 -1
- package/cjs/components/Pagination/ui/PaginationQuickJumpToPage/PaginationQuickJumpToPage.js.map +1 -1
- package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.css +2 -0
- package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +1 -1
- package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js.map +1 -1
- package/cjs/components/Popover/Popover.js +7 -7
- package/cjs/components/Popover/Popover.js.map +1 -1
- package/cjs/components/Popup/Popup.js +1 -1
- package/cjs/components/Popup/Popup.js.map +1 -1
- package/cjs/components/Segment/ui/SegmentItem/SegmentItem.js +2 -2
- package/cjs/components/Segment/ui/SegmentItem/SegmentItem.js.map +1 -1
- package/cjs/components/Select/Select.css +2 -0
- package/cjs/components/Select/Select.js +5 -5
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/Select/hooks/useKeyNavigation.js +12 -12
- package/cjs/components/Select/hooks/useKeyNavigation.js.map +1 -1
- package/cjs/components/Select/ui/SelectChip/SelectChip.css +2 -0
- package/cjs/components/Select/ui/SelectChip/SelectChip.js +1 -1
- package/cjs/components/Select/ui/SelectChip/SelectChip.js.map +1 -1
- package/cjs/components/Select/ui/SelectTarget/SelectTarget.css +2 -0
- package/cjs/components/Select/ui/SelectTarget/SelectTarget.js +2 -2
- package/cjs/components/Select/ui/SelectTarget/SelectTarget.js.map +1 -1
- package/cjs/components/Select/utils/index.js +2 -2
- package/cjs/components/Select/utils/index.js.map +1 -1
- package/cjs/components/Tabs/TabsContext.js +2 -1
- package/cjs/components/Tabs/TabsContext.js.map +1 -1
- package/cjs/components/Tabs/ui/TabItem/TabItem.js +1 -1
- package/cjs/components/Tabs/ui/TabItem/TabItem.js.map +1 -1
- package/cjs/components/Tabs/ui/Tabs/Tabs.js +2 -2
- package/cjs/components/Tabs/ui/Tabs/Tabs.js.map +1 -1
- package/cjs/components/TextArea/TextArea.js +1 -1
- package/cjs/components/TextArea/TextArea.js.map +1 -1
- package/cjs/components/TextField/TextField.js +2 -2
- package/cjs/components/TextField/TextField.js.map +1 -1
- package/cjs/components/TextField/hooks/useKeyNavigation.js +9 -9
- package/cjs/components/TextField/hooks/useKeyNavigation.js.map +1 -1
- package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.css +2 -0
- package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.js +1 -1
- package/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.js.map +1 -1
- package/cjs/components/Toast/ToastProvider/ToastProvider.js +2 -2
- package/cjs/components/Toast/ToastProvider/ToastProvider.js.map +1 -1
- package/cjs/components/Tooltip/Tooltip.js +1 -1
- package/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/cjs/index.css +2 -0
- package/es/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/es/components/Calendar/CalendarBase/CalendarBase.js +1 -1
- package/es/components/Calendar/CalendarBase/CalendarBase.js.map +1 -1
- package/es/components/Calendar/CalendarDouble/CalendarDouble.js +1 -1
- package/es/components/Calendar/CalendarDouble/CalendarDouble.js.map +1 -1
- package/es/components/Calendar/hoc/withRange.js +1 -1
- package/es/components/Calendar/hoc/withRange.js.map +1 -1
- package/es/components/Calendar/hooks/useKeyNavigation.js +19 -19
- package/es/components/Calendar/hooks/useKeyNavigation.js.map +1 -1
- package/es/components/Calendar/ui/CalendarDays/CalendarDays.js +3 -3
- package/es/components/Calendar/ui/CalendarDays/CalendarDays.js.map +1 -1
- package/es/components/Calendar/ui/CalendarHeader/CalendarHeader.js +2 -2
- package/es/components/Calendar/ui/CalendarHeader/CalendarHeader.js.map +1 -1
- package/es/components/Calendar/ui/CalendarMonths/CalendarMonths.js +1 -1
- package/es/components/Calendar/ui/CalendarMonths/CalendarMonths.js.map +1 -1
- package/es/components/Calendar/ui/CalendarYears/CalendarYears.js +1 -1
- package/es/components/Calendar/ui/CalendarYears/CalendarYears.js.map +1 -1
- package/es/components/Chip/Chip.css +2 -0
- package/es/components/Chip/Chip.js +17 -5
- package/es/components/Chip/Chip.js.map +1 -1
- package/es/components/Chip/Chip.tokens.js +5 -1
- package/es/components/Chip/Chip.tokens.js.map +1 -1
- package/es/components/Chip/variations/_pilled/base.js +5 -0
- package/es/components/Chip/variations/_pilled/base.js.map +1 -0
- package/es/components/Chip/variations/_pilled/base_3kce4h.css +1 -0
- package/es/components/Combobox/Combobox.css +2 -0
- package/es/components/Combobox/Combobox.js +5 -5
- package/es/components/Combobox/Combobox.js.map +1 -1
- package/es/components/Combobox/hooks/useFocusController.js +9 -9
- package/es/components/Combobox/hooks/useFocusController.js.map +1 -1
- package/es/components/Combobox/ui/ComboboxChip/ComboboxChip.css +2 -0
- package/es/components/Combobox/ui/ComboboxChip/ComboboxChip.js +1 -1
- package/es/components/Combobox/ui/ComboboxChip/ComboboxChip.js.map +1 -1
- package/es/components/Combobox/ui/ComboboxTarget/ComboboxTarget.css +2 -0
- package/es/components/Combobox/ui/ComboboxTarget/ComboboxTarget.js +6 -6
- package/es/components/Combobox/ui/ComboboxTarget/ComboboxTarget.js.map +1 -1
- package/es/components/Drawer/DrawerContext.js +1 -1
- package/es/components/Drawer/DrawerContext.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -2
- package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
- package/es/components/Modal/ModalContext.js +1 -1
- package/es/components/Modal/ModalContext.js.map +1 -1
- package/es/components/Overlay/Overlay.js +1 -1
- package/es/components/Overlay/Overlay.js.map +1 -1
- package/es/components/Pagination/Pagination.css +2 -0
- package/es/components/Pagination/Pagination.js +2 -2
- package/es/components/Pagination/Pagination.js.map +1 -1
- package/es/components/Pagination/ui/PaginationQuickJumpToPage/PaginationQuickJumpToPage.js +1 -1
- package/es/components/Pagination/ui/PaginationQuickJumpToPage/PaginationQuickJumpToPage.js.map +1 -1
- package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.css +2 -0
- package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +1 -1
- package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js.map +1 -1
- package/es/components/Popover/Popover.js +7 -7
- package/es/components/Popover/Popover.js.map +1 -1
- package/es/components/Popup/Popup.js +1 -1
- package/es/components/Popup/Popup.js.map +1 -1
- package/es/components/Segment/ui/SegmentItem/SegmentItem.js +2 -2
- package/es/components/Segment/ui/SegmentItem/SegmentItem.js.map +1 -1
- package/es/components/Select/Select.css +2 -0
- package/es/components/Select/Select.js +5 -5
- package/es/components/Select/Select.js.map +1 -1
- package/es/components/Select/hooks/useKeyNavigation.js +12 -12
- package/es/components/Select/hooks/useKeyNavigation.js.map +1 -1
- package/es/components/Select/ui/SelectChip/SelectChip.css +2 -0
- package/es/components/Select/ui/SelectChip/SelectChip.js +1 -1
- package/es/components/Select/ui/SelectChip/SelectChip.js.map +1 -1
- package/es/components/Select/ui/SelectTarget/SelectTarget.css +2 -0
- package/es/components/Select/ui/SelectTarget/SelectTarget.js +2 -2
- package/es/components/Select/ui/SelectTarget/SelectTarget.js.map +1 -1
- package/es/components/Select/utils/index.js +2 -2
- package/es/components/Select/utils/index.js.map +1 -1
- package/es/components/Tabs/TabsContext.js +2 -1
- package/es/components/Tabs/TabsContext.js.map +1 -1
- package/es/components/Tabs/ui/TabItem/TabItem.js +1 -1
- package/es/components/Tabs/ui/TabItem/TabItem.js.map +1 -1
- package/es/components/Tabs/ui/Tabs/Tabs.js +2 -2
- package/es/components/Tabs/ui/Tabs/Tabs.js.map +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextArea/TextArea.js.map +1 -1
- package/es/components/TextField/TextField.js +2 -2
- package/es/components/TextField/TextField.js.map +1 -1
- package/es/components/TextField/hooks/useKeyNavigation.js +9 -9
- package/es/components/TextField/hooks/useKeyNavigation.js.map +1 -1
- package/es/components/TextField/ui/TextFieldChip/TextFieldChip.css +2 -0
- package/es/components/TextField/ui/TextFieldChip/TextFieldChip.js +1 -1
- package/es/components/TextField/ui/TextFieldChip/TextFieldChip.js.map +1 -1
- package/es/components/Toast/ToastProvider/ToastProvider.js +2 -2
- package/es/components/Toast/ToastProvider/ToastProvider.js.map +1 -1
- package/es/components/Tooltip/Tooltip.js +1 -1
- package/es/components/Tooltip/Tooltip.js.map +1 -1
- package/es/index.css +2 -0
- package/package.json +10 -10
- package/styled-components/cjs/components/Avatar/Avatar.js +1 -1
- package/styled-components/cjs/components/Avatar/Avatar.styles.js +1 -1
- package/styled-components/cjs/components/AvatarGroup/AvatarGroup.js +1 -1
- package/styled-components/cjs/components/Badge/Badge.js +1 -1
- package/styled-components/cjs/components/Badge/Badge.styles.js +1 -1
- package/styled-components/cjs/components/Button/Button.js +2 -2
- package/styled-components/cjs/components/Button/Button.styles.js +1 -1
- package/styled-components/cjs/components/ButtonGroup/ButtonGroup.js +1 -1
- package/styled-components/cjs/components/Calendar/CalendarBase/CalendarBase.js +2 -2
- package/styled-components/cjs/components/Calendar/CalendarBase/CalendarBase.styles.js +1 -1
- package/styled-components/cjs/components/Calendar/CalendarDouble/CalendarDouble.js +2 -2
- package/styled-components/cjs/components/Calendar/CalendarDouble/CalendarDouble.styles.js +1 -1
- package/styled-components/cjs/components/Calendar/hoc/withRange.js +2 -2
- package/styled-components/cjs/components/Calendar/hooks/useKeyNavigation.js +20 -20
- package/styled-components/cjs/components/Calendar/store/reducer.js +1 -1
- package/styled-components/cjs/components/Calendar/ui/CalendarDayItem/CalendarDayItem.js +1 -1
- package/styled-components/cjs/components/Calendar/ui/CalendarDays/CalendarDays.js +4 -4
- package/styled-components/cjs/components/Calendar/ui/CalendarHeader/CalendarHeader.js +3 -3
- package/styled-components/cjs/components/Calendar/ui/CalendarMonths/CalendarMonths.js +2 -2
- package/styled-components/cjs/components/Calendar/ui/CalendarYears/CalendarYears.js +2 -2
- package/styled-components/cjs/components/Cell/Cell.js +1 -1
- package/styled-components/cjs/components/Cell/Cell.styles.js +1 -1
- package/styled-components/cjs/components/Checkbox/Checkbox.js +1 -1
- package/styled-components/cjs/components/Chip/Chip.js +17 -5
- package/styled-components/cjs/components/Chip/Chip.styles.js +1 -1
- package/styled-components/cjs/components/Chip/Chip.template-doc.mdx +2 -2
- package/styled-components/cjs/components/Chip/Chip.tokens.js +5 -1
- package/styled-components/cjs/components/Chip/variations/_pilled/base.js +9 -0
- package/styled-components/cjs/components/Chip/variations/_pilled/tokens.json +4 -0
- package/styled-components/cjs/components/Combobox/Combobox.js +6 -6
- package/styled-components/cjs/components/Combobox/hooks/useFocusController.js +9 -9
- package/styled-components/cjs/components/Combobox/ui/ComboboxChip/ComboboxChip.js +2 -2
- package/styled-components/cjs/components/Combobox/ui/ComboboxTarget/ComboboxTarget.js +7 -7
- package/styled-components/cjs/components/Counter/Counter.js +1 -1
- package/styled-components/cjs/components/Divider/Divider.js +2 -2
- package/styled-components/cjs/components/Drawer/Drawer.js +1 -1
- package/styled-components/cjs/components/Drawer/DrawerContext.js +1 -1
- package/styled-components/cjs/components/Drawer/hooks/useDrawer.js +1 -1
- package/styled-components/cjs/components/Drawer/ui/DrawerContent/DrawerContent.js +1 -1
- package/styled-components/cjs/components/Drawer/ui/DrawerFooter/DrawerFooter.js +1 -1
- package/styled-components/cjs/components/Drawer/ui/DrawerHeader/DrawerHeader.js +1 -1
- package/styled-components/cjs/components/Dropdown/Dropdown.js +1 -1
- package/styled-components/cjs/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +1 -1
- package/styled-components/cjs/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +1 -1
- package/styled-components/cjs/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +1 -1
- package/styled-components/cjs/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +1 -1
- package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +4 -4
- package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +1 -1
- package/styled-components/cjs/components/Dropdown/utils/index.js +1 -1
- package/styled-components/cjs/components/Grid/Grid.js +2 -2
- package/styled-components/cjs/components/Grid/ui/Col/Col.js +2 -2
- package/styled-components/cjs/components/Grid/ui/Row/Row.js +1 -1
- package/styled-components/cjs/components/Grid/utils/index.js +1 -1
- package/styled-components/cjs/components/Header/HeaderRoot/HeaderRoot.js +1 -1
- package/styled-components/cjs/components/Header/ui/HeaderArrow/HeaderArrow.js +1 -1
- package/styled-components/cjs/components/Header/ui/HeaderLogo/HeaderLogo.js +1 -1
- package/styled-components/cjs/components/Header/ui/HeaderTitleWrapper/HeaderTitleWrapper.js +1 -1
- package/styled-components/cjs/components/Image/Image.js +2 -2
- package/styled-components/cjs/components/Image/Image.styles.js +1 -1
- package/styled-components/cjs/components/Indicator/Indicator.js +1 -1
- package/styled-components/cjs/components/Link/Link.js +1 -1
- package/styled-components/cjs/components/Modal/Modal.js +1 -1
- package/styled-components/cjs/components/Modal/ModalContext.js +1 -1
- package/styled-components/cjs/components/Modal/hooks/useModal.js +1 -1
- package/styled-components/cjs/components/Notification/Notification.js +1 -1
- package/styled-components/cjs/components/Notification/Notification.styles.js +1 -1
- package/styled-components/cjs/components/Notification/NotificationsPortal.js +1 -1
- package/styled-components/cjs/components/Notification/NotificationsStore.js +1 -1
- package/styled-components/cjs/components/Overlay/Overlay.js +2 -2
- package/styled-components/cjs/components/Pagination/Pagination.js +3 -3
- package/styled-components/cjs/components/Pagination/ui/PaginationQuickJumpToPage/PaginationQuickJumpToPage.js +2 -2
- package/styled-components/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +2 -2
- package/styled-components/cjs/components/Panel/Panel.js +2 -2
- package/styled-components/cjs/components/Panel/ui/PanelContent/PanelContent.js +1 -1
- package/styled-components/cjs/components/Panel/ui/PanelFooter/PanelFooter.js +1 -1
- package/styled-components/cjs/components/Panel/ui/PanelHeader/PanelHeader.js +1 -1
- package/styled-components/cjs/components/Popover/Popover.js +9 -9
- package/styled-components/cjs/components/Popup/Popup.js +2 -2
- package/styled-components/cjs/components/Popup/PopupContext.js +1 -1
- package/styled-components/cjs/components/Popup/PopupRoot.js +1 -1
- package/styled-components/cjs/components/Popup/hooks/usePopup.js +1 -1
- package/styled-components/cjs/components/Progress/Progress.js +1 -1
- package/styled-components/cjs/components/Progress/Progress.styles.js +1 -1
- package/styled-components/cjs/components/Radiobox/Radiobox.js +1 -1
- package/styled-components/cjs/components/SSRProvider/SSRProvider.js +1 -1
- package/styled-components/cjs/components/Segment/SegmentProvider/SegmentProvider.js +1 -1
- package/styled-components/cjs/components/Segment/ui/SegmentGroup/SegmentGroup.js +1 -1
- package/styled-components/cjs/components/Segment/ui/SegmentGroup/SegmentGroup.styles.js +1 -1
- package/styled-components/cjs/components/Segment/ui/SegmentItem/SegmentItem.js +3 -3
- package/styled-components/cjs/components/Segment/ui/SegmentItem/SegmentItem.styles.js +1 -1
- package/styled-components/cjs/components/Select/Select.js +6 -6
- package/styled-components/cjs/components/Select/hooks/useKeyNavigation.js +12 -12
- package/styled-components/cjs/components/Select/ui/SelectChip/SelectChip.js +2 -2
- package/styled-components/cjs/components/Select/ui/SelectTarget/SelectTarget.js +3 -3
- package/styled-components/cjs/components/Select/utils/index.js +3 -3
- package/styled-components/cjs/components/Skeleton/LineSkeleton/LineSkeleton.js +1 -1
- package/styled-components/cjs/components/Skeleton/LineSkeleton/LineSkeleton.styles.js +1 -1
- package/styled-components/cjs/components/Skeleton/RectSkeleton/RectSkeleton.js +1 -1
- package/styled-components/cjs/components/Skeleton/TextSkeleton/TextSkeleton.js +2 -2
- package/styled-components/cjs/components/Skeleton/hoc/withSkeleton.js +1 -1
- package/styled-components/cjs/components/Spinner/Spinner.js +1 -1
- package/styled-components/cjs/components/Spinner/Spinner.styles.js +1 -1
- package/styled-components/cjs/components/Spinner/utils/index.js +1 -1
- package/styled-components/cjs/components/Switch/Switch.js +1 -1
- package/styled-components/cjs/components/Tabs/TabsContext.js +3 -2
- package/styled-components/cjs/components/Tabs/createTabsController.js +1 -1
- package/styled-components/cjs/components/Tabs/ui/TabItem/TabItem.js +2 -2
- package/styled-components/cjs/components/Tabs/ui/TabItem/TabItem.styles.js +1 -1
- package/styled-components/cjs/components/Tabs/ui/Tabs/Tabs.js +3 -3
- package/styled-components/cjs/components/Tabs/ui/Tabs/Tabs.styles.js +1 -1
- package/styled-components/cjs/components/TextArea/TextArea.js +2 -2
- package/styled-components/cjs/components/TextField/TextField.js +3 -3
- package/styled-components/cjs/components/TextField/hooks/useKeyNavigation.js +9 -9
- package/styled-components/cjs/components/TextField/ui/TextFieldChip/TextFieldChip.js +2 -2
- package/styled-components/cjs/components/Toast/Toast.js +2 -2
- package/styled-components/cjs/components/Toast/Toast.styles.js +1 -1
- package/styled-components/cjs/components/Toast/ToastController.js +2 -2
- package/styled-components/cjs/components/Toast/ToastProvider/ToastProvider.js +3 -3
- package/styled-components/cjs/components/Toolbar/Toolbar.js +1 -1
- package/styled-components/cjs/components/Toolbar/ui/ToolbarDivider/ToolbarDivider.js +1 -1
- package/styled-components/cjs/components/Tooltip/Tooltip.js +2 -2
- package/styled-components/cjs/components/Typography/Old/Subtitle/Subtitle.js +2 -2
- package/styled-components/cjs/components/Typography/Old/TypographyOld.js +2 -2
- package/styled-components/cjs/components/Typography/Typography.js +2 -2
- package/styled-components/cjs/engines/common.js +1 -1
- package/styled-components/cjs/engines/styled-components.js +1 -1
- package/styled-components/cjs/examples/_helpers.js +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Chip/Chip.config.js +10 -7
- package/styled-components/cjs/examples/plasma_b2c/components/Chip/Chip.stories.tsx +18 -2
- package/styled-components/cjs/examples/plasma_b2c/components/Grid/Grid.config.js +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Chip/Chip.config.js +10 -7
- package/styled-components/cjs/examples/plasma_web/components/Chip/Chip.stories.tsx +18 -2
- package/styled-components/cjs/examples/plasma_web/components/Grid/Grid.config.js +1 -1
- package/styled-components/cjs/examples/sds_engineer/components/Grid/Grid.config.js +1 -1
- package/styled-components/cjs/mixins/applySpacing.js +1 -1
- package/styled-components/cjs/mixins/typography.js +1 -1
- package/styled-components/es/components/Button/Button.js +1 -1
- package/styled-components/es/components/Calendar/CalendarBase/CalendarBase.js +1 -1
- package/styled-components/es/components/Calendar/CalendarDouble/CalendarDouble.js +1 -1
- package/styled-components/es/components/Calendar/hoc/withRange.js +1 -1
- package/styled-components/es/components/Calendar/hooks/useKeyNavigation.js +20 -20
- package/styled-components/es/components/Calendar/store/reducer.js +1 -1
- package/styled-components/es/components/Calendar/ui/CalendarDays/CalendarDays.js +3 -3
- package/styled-components/es/components/Calendar/ui/CalendarHeader/CalendarHeader.js +2 -2
- package/styled-components/es/components/Calendar/ui/CalendarMonths/CalendarMonths.js +1 -1
- package/styled-components/es/components/Calendar/ui/CalendarYears/CalendarYears.js +1 -1
- package/styled-components/es/components/Chip/Chip.js +17 -5
- package/styled-components/es/components/Chip/Chip.template-doc.mdx +2 -2
- package/styled-components/es/components/Chip/Chip.tokens.js +4 -0
- package/styled-components/es/components/Chip/variations/_pilled/base.js +3 -0
- package/styled-components/es/components/Chip/variations/_pilled/tokens.json +4 -0
- package/styled-components/es/components/Combobox/Combobox.js +5 -5
- package/styled-components/es/components/Combobox/hooks/useFocusController.js +9 -9
- package/styled-components/es/components/Combobox/ui/ComboboxChip/ComboboxChip.js +1 -1
- package/styled-components/es/components/Combobox/ui/ComboboxTarget/ComboboxTarget.js +6 -6
- package/styled-components/es/components/Divider/Divider.js +1 -1
- package/styled-components/es/components/Drawer/DrawerContext.js +1 -1
- package/styled-components/es/components/Drawer/hooks/useDrawer.js +1 -1
- package/styled-components/es/components/Drawer/ui/DrawerContent/DrawerContent.js +1 -1
- package/styled-components/es/components/Drawer/ui/DrawerFooter/DrawerFooter.js +1 -1
- package/styled-components/es/components/Drawer/ui/DrawerHeader/DrawerHeader.js +1 -1
- package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -3
- package/styled-components/es/components/Grid/Grid.js +1 -1
- package/styled-components/es/components/Grid/ui/Col/Col.js +1 -1
- package/styled-components/es/components/Grid/utils/index.js +1 -1
- package/styled-components/es/components/Image/Image.js +1 -1
- package/styled-components/es/components/Modal/ModalContext.js +1 -1
- package/styled-components/es/components/Modal/hooks/useModal.js +1 -1
- package/styled-components/es/components/Notification/NotificationsStore.js +1 -1
- package/styled-components/es/components/Overlay/Overlay.js +1 -1
- package/styled-components/es/components/Pagination/Pagination.js +2 -2
- package/styled-components/es/components/Pagination/ui/PaginationQuickJumpToPage/PaginationQuickJumpToPage.js +1 -1
- package/styled-components/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.js +1 -1
- package/styled-components/es/components/Panel/Panel.js +1 -1
- package/styled-components/es/components/Popover/Popover.js +8 -8
- package/styled-components/es/components/Popup/Popup.js +1 -1
- package/styled-components/es/components/Popup/hooks/usePopup.js +1 -1
- package/styled-components/es/components/Segment/ui/SegmentItem/SegmentItem.js +2 -2
- package/styled-components/es/components/Select/Select.js +5 -5
- package/styled-components/es/components/Select/hooks/useKeyNavigation.js +12 -12
- package/styled-components/es/components/Select/ui/SelectChip/SelectChip.js +1 -1
- package/styled-components/es/components/Select/ui/SelectTarget/SelectTarget.js +2 -2
- package/styled-components/es/components/Select/utils/index.js +3 -3
- package/styled-components/es/components/Skeleton/TextSkeleton/TextSkeleton.js +1 -1
- package/styled-components/es/components/Skeleton/hoc/withSkeleton.js +1 -1
- package/styled-components/es/components/Spinner/utils/index.js +1 -1
- package/styled-components/es/components/Tabs/TabsContext.js +3 -2
- package/styled-components/es/components/Tabs/ui/TabItem/TabItem.js +1 -1
- package/styled-components/es/components/Tabs/ui/Tabs/Tabs.js +2 -2
- package/styled-components/es/components/TextArea/TextArea.js +1 -1
- package/styled-components/es/components/TextField/TextField.js +2 -2
- package/styled-components/es/components/TextField/hooks/useKeyNavigation.js +9 -9
- package/styled-components/es/components/TextField/ui/TextFieldChip/TextFieldChip.js +1 -1
- package/styled-components/es/components/Toast/Toast.js +1 -1
- package/styled-components/es/components/Toast/ToastController.js +1 -1
- package/styled-components/es/components/Toast/ToastProvider/ToastProvider.js +2 -2
- package/styled-components/es/components/Toolbar/ui/ToolbarDivider/ToolbarDivider.js +1 -1
- package/styled-components/es/components/Tooltip/Tooltip.js +1 -1
- package/styled-components/es/components/Typography/Old/Subtitle/Subtitle.js +1 -1
- package/styled-components/es/components/Typography/Old/TypographyOld.js +1 -1
- package/styled-components/es/components/Typography/Typography.js +1 -1
- package/styled-components/es/engines/common.js +1 -1
- package/styled-components/es/examples/_helpers.js +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Chip/Chip.config.js +10 -7
- package/styled-components/es/examples/plasma_b2c/components/Chip/Chip.stories.tsx +18 -2
- package/styled-components/es/examples/plasma_b2c/components/Grid/Grid.config.js +1 -1
- package/styled-components/es/examples/plasma_web/components/Chip/Chip.config.js +10 -7
- package/styled-components/es/examples/plasma_web/components/Chip/Chip.stories.tsx +18 -2
- package/styled-components/es/examples/plasma_web/components/Grid/Grid.config.js +1 -1
- package/styled-components/es/examples/sds_engineer/components/Grid/Grid.config.js +1 -1
- package/styled-components/es/mixins/applySpacing.js +1 -1
- package/styled-components/es/mixins/typography.js +1 -1
- package/types/components/Chip/Chip.d.ts +4 -0
- package/types/components/Chip/Chip.d.ts.map +1 -1
- package/types/components/Chip/Chip.tokens.d.ts +4 -0
- package/types/components/Chip/Chip.tokens.d.ts.map +1 -1
- package/types/components/Chip/Chip.types.d.ts +6 -0
- package/types/components/Chip/Chip.types.d.ts.map +1 -1
- package/types/components/Chip/variations/_pilled/base.d.ts +2 -0
- package/types/components/Chip/variations/_pilled/base.d.ts.map +1 -0
- package/types/examples/plasma_b2c/components/Chip/Chip.config.d.ts +4 -1
- package/types/examples/plasma_b2c/components/Chip/Chip.config.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Chip/Chip.d.ts +4 -1
- package/types/examples/plasma_b2c/components/Chip/Chip.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Chip/Chip.config.d.ts +4 -1
- package/types/examples/plasma_web/components/Chip/Chip.config.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Chip/Chip.d.ts +4 -1
- package/types/examples/plasma_web/components/Chip/Chip.d.ts.map +1 -1
@@ -10,6 +10,8 @@
|
|
10
10
|
|
11
11
|
.base_kgtz8x_b16hf96__46a206b1{--plasma_private-chip-outline-size:var(--plasma-chip-outline-size,0.125rem);position:relative;}.base_kgtz8x_b16hf96__46a206b1:focus{outline:none;}.base_kgtz8x_b16hf96__46a206b1::before{content:'';position:absolute;top:calc(-1 * var(--plasma_private-chip-outline-size));left:calc(-1 * var(--plasma_private-chip-outline-size));right:calc(-1 * var(--plasma_private-chip-outline-size));bottom:calc(-1 * var(--plasma_private-chip-outline-size));z-index:1;display:block;box-sizing:content-box;border:var(--plasma_private-chip-outline-size) solid transparent;border-radius:calc(var(--plasma-chip-border-radius) + var(--plasma_private-chip-outline-size));-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.base_kgtz8x_b16hf96__46a206b1.base_kgtz8x_focusVisible__46a206b1:focus::before,.base_kgtz8x_b16hf96__46a206b1[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 var(--plasma_private-chip-outline-size) var(--plasma-chip-focus-color);}
|
12
12
|
|
13
|
+
.base_3kce4h_bvcavwi__c6ad5ca5.base_3kce4h_chipPilled__c6ad5ca5{border-radius:var(--plasma-chip-pilled-border-radius);}
|
14
|
+
|
13
15
|
.Chip_styles_1mwwhiw_bol5daj__07da4d18{position:relative;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0);}
|
14
16
|
.Chip_styles_1mwwhiw_sj20on5__07da4d18{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin-left:var(--plasma-chip-left-content-margin-left);margin-right:var(--plasma-chip-left-content-margin-right);}
|
15
17
|
.Chip_styles_1mwwhiw_s1ror4o9__07da4d18{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
@@ -17,7 +17,7 @@ var SelectChip = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
17
17
|
onClear(value, text);
|
18
18
|
}, [onClear, value, text]);
|
19
19
|
var onKeyDownHandle = useCallback(function (event) {
|
20
|
-
onKeyDown === null || onKeyDown === void 0
|
20
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(value, text, index, event);
|
21
21
|
}, [onKeyDown]);
|
22
22
|
return /*#__PURE__*/React.createElement(StyledChip, {
|
23
23
|
ref: ref,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SelectChip.js","sources":["../../../../../src/components/Select/ui/SelectChip/SelectChip.tsx"],"sourcesContent":["import React, { forwardRef, useCallback } from 'react';\n\nimport { StyledChip } from './SelectChip.styles';\nimport type { SelectChipProps } from './SelectChip.types';\n\n/**\n * Чип, отображающий выбранный элемент\n */\nexport const SelectChip = forwardRef<HTMLButtonElement, SelectChipProps>(\n ({ value, text, index, disabled, readOnly, onClick, onClear, onKeyDown }, ref) => {\n const onClearHandle = useCallback(() => {\n onClear(value, text);\n }, [onClear, value, text]);\n\n const onKeyDownHandle = useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(value, text, index, event);\n },\n [onKeyDown],\n );\n\n return (\n <StyledChip\n ref={ref}\n tabIndex={-1}\n disabled={disabled}\n readOnly={readOnly}\n onClick={onClick}\n onClear={onClearHandle}\n onKeyDown={onKeyDownHandle}\n text={`${text}`}\n />\n );\n },\n);\n"],"names":["SelectChip","forwardRef","_ref","ref","value","text","index","disabled","readOnly","onClick","onClear","onKeyDown","onClearHandle","useCallback","onKeyDownHandle","event","React","createElement","StyledChip","tabIndex","concat"],"mappings":";;;AAKA;AACA;AACA;AACO,IAAMA,UAAU,gBAAGC,UAAU,CAChC,UAAAC,IAAA,EAA0EC,GAAG,EAAK;AAAA,EAAA,IAA/EC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IAAEC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;IAAEC,OAAO,GAAAP,IAAA,CAAPO,OAAO;IAAEC,OAAO,GAAAR,IAAA,CAAPQ,OAAO;IAAEC,SAAS,GAAAT,IAAA,CAATS,SAAS,CAAA;AAClE,EAAA,IAAMC,aAAa,GAAGC,WAAW,CAAC,YAAM;AACpCH,IAAAA,OAAO,CAACN,KAAK,EAAEC,IAAI,CAAC,CAAA;GACvB,EAAE,CAACK,OAAO,EAAEN,KAAK,EAAEC,IAAI,CAAC,CAAC,CAAA;AAE1B,EAAA,IAAMS,eAAe,GAAGD,WAAW,CAC/B,UAACE,KAA6C,EAAK;AAC/CJ,IAAAA,SAAS,KAATA,IAAAA,IAAAA,SAAS,KAATA,KAAAA,CAAAA,
|
1
|
+
{"version":3,"file":"SelectChip.js","sources":["../../../../../src/components/Select/ui/SelectChip/SelectChip.tsx"],"sourcesContent":["import React, { forwardRef, useCallback } from 'react';\n\nimport { StyledChip } from './SelectChip.styles';\nimport type { SelectChipProps } from './SelectChip.types';\n\n/**\n * Чип, отображающий выбранный элемент\n */\nexport const SelectChip = forwardRef<HTMLButtonElement, SelectChipProps>(\n ({ value, text, index, disabled, readOnly, onClick, onClear, onKeyDown }, ref) => {\n const onClearHandle = useCallback(() => {\n onClear(value, text);\n }, [onClear, value, text]);\n\n const onKeyDownHandle = useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(value, text, index, event);\n },\n [onKeyDown],\n );\n\n return (\n <StyledChip\n ref={ref}\n tabIndex={-1}\n disabled={disabled}\n readOnly={readOnly}\n onClick={onClick}\n onClear={onClearHandle}\n onKeyDown={onKeyDownHandle}\n text={`${text}`}\n />\n );\n },\n);\n"],"names":["SelectChip","forwardRef","_ref","ref","value","text","index","disabled","readOnly","onClick","onClear","onKeyDown","onClearHandle","useCallback","onKeyDownHandle","event","React","createElement","StyledChip","tabIndex","concat"],"mappings":";;;AAKA;AACA;AACA;AACO,IAAMA,UAAU,gBAAGC,UAAU,CAChC,UAAAC,IAAA,EAA0EC,GAAG,EAAK;AAAA,EAAA,IAA/EC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IAAEC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;IAAEC,OAAO,GAAAP,IAAA,CAAPO,OAAO;IAAEC,OAAO,GAAAR,IAAA,CAAPQ,OAAO;IAAEC,SAAS,GAAAT,IAAA,CAATS,SAAS,CAAA;AAClE,EAAA,IAAMC,aAAa,GAAGC,WAAW,CAAC,YAAM;AACpCH,IAAAA,OAAO,CAACN,KAAK,EAAEC,IAAI,CAAC,CAAA;GACvB,EAAE,CAACK,OAAO,EAAEN,KAAK,EAAEC,IAAI,CAAC,CAAC,CAAA;AAE1B,EAAA,IAAMS,eAAe,GAAGD,WAAW,CAC/B,UAACE,KAA6C,EAAK;AAC/CJ,IAAAA,SAAS,KAATA,IAAAA,IAAAA,SAAS,KAATA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,SAAS,CAAGP,KAAK,EAAEC,IAAI,EAAEC,KAAK,EAAES,KAAK,CAAC,CAAA;AAC1C,GAAC,EACD,CAACJ,SAAS,CACd,CAAC,CAAA;AAED,EAAA,oBACIK,KAAA,CAAAC,aAAA,CAACC,UAAU,EAAA;AACPf,IAAAA,GAAG,EAAEA,GAAI;IACTgB,QAAQ,EAAE,CAAC,CAAE;AACbZ,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,OAAO,EAAEA,OAAQ;AACjBC,IAAAA,OAAO,EAAEE,aAAc;AACvBD,IAAAA,SAAS,EAAEG,eAAgB;IAC3BT,IAAI,EAAA,EAAA,CAAAe,MAAA,CAAKf,IAAI,CAAA;AAAG,GACnB,CAAC,CAAA;AAEV,CACJ;;;;"}
|
@@ -8,6 +8,8 @@
|
|
8
8
|
|
9
9
|
.base_kgtz8x_b16hf96__46a206b1{--plasma_private-chip-outline-size:var(--plasma-chip-outline-size,0.125rem);position:relative;}.base_kgtz8x_b16hf96__46a206b1:focus{outline:none;}.base_kgtz8x_b16hf96__46a206b1::before{content:'';position:absolute;top:calc(-1 * var(--plasma_private-chip-outline-size));left:calc(-1 * var(--plasma_private-chip-outline-size));right:calc(-1 * var(--plasma_private-chip-outline-size));bottom:calc(-1 * var(--plasma_private-chip-outline-size));z-index:1;display:block;box-sizing:content-box;border:var(--plasma_private-chip-outline-size) solid transparent;border-radius:calc(var(--plasma-chip-border-radius) + var(--plasma_private-chip-outline-size));-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.base_kgtz8x_b16hf96__46a206b1.base_kgtz8x_focusVisible__46a206b1:focus::before,.base_kgtz8x_b16hf96__46a206b1[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 var(--plasma_private-chip-outline-size) var(--plasma-chip-focus-color);}
|
10
10
|
|
11
|
+
.base_3kce4h_bvcavwi__c6ad5ca5.base_3kce4h_chipPilled__c6ad5ca5{border-radius:var(--plasma-chip-pilled-border-radius);}
|
12
|
+
|
11
13
|
.Chip_styles_1mwwhiw_bol5daj__07da4d18{position:relative;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0);}
|
12
14
|
.Chip_styles_1mwwhiw_sj20on5__07da4d18{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin-left:var(--plasma-chip-left-content-margin-left);margin-right:var(--plasma-chip-left-content-margin-right);}
|
13
15
|
.Chip_styles_1mwwhiw_s1ror4o9__07da4d18{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
@@ -65,8 +65,8 @@ var SelectTarget = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
65
65
|
itemValue = _ref9[0];
|
66
66
|
return itemValue;
|
67
67
|
});
|
68
|
-
chipsRefs === null || chipsRefs === void 0
|
69
|
-
onChange === null || onChange === void 0
|
68
|
+
chipsRefs === null || chipsRefs === void 0 ? void 0 : chipsRefs.current.splice(index, 1);
|
69
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
70
70
|
}, [values, onChange]);
|
71
71
|
var onChipKeyDown = useCallback(function (value, text, index, event) {
|
72
72
|
var code = event.code,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SelectTarget.js","sources":["../../../../../src/components/Select/ui/SelectTarget/SelectTarget.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useRef } from 'react';\n\nimport { classes } from '../../Select.tokens';\nimport { cx } from '../../../../utils';\nimport { SelectChip } from '../SelectChip/SelectChip';\nimport type { SelectPrimitiveValue } from '../../Select.types';\nimport { Keys } from '../../hooks/useKeyNavigation';\n\nimport {\n StyledArrow,\n StyledChips,\n StyledChipsWrapper,\n StyledLabel,\n StyledSelectTarget,\n StyledText,\n} from './SelectTarget.styles';\nimport type { SelectTargetProps } from './SelectTarget.types';\n\nconst {\n hasNoFocus,\n hasChips,\n innerLabelUp,\n arrowInverse,\n selectTarget,\n selectTargetArrow,\n selectTargeText,\n selectTargetLabel,\n} = classes;\n\n/**\n * Элемент для выпадающего списка\n */\nexport const SelectTarget = forwardRef<HTMLButtonElement, SelectTargetProps>(\n (\n {\n values,\n target = 'textField-like',\n label,\n opened,\n readOnly,\n disabled,\n enumerationType,\n size,\n id,\n chipsRefs,\n onChange,\n onKeyDown,\n ...rest\n },\n ref,\n ) => {\n const hasText = Boolean(values?.some(([value]) => value));\n\n const hasLabel = label && size !== 'xs' && target === 'textField-like';\n const textContent = values?.map(([, text]) => text).join(', ');\n const contentRef = useRef<HTMLDivElement>(null);\n\n const withArrowInverse = opened ? arrowInverse : undefined;\n const withInnerLabelUp = hasLabel && hasText ? innerLabelUp : undefined;\n const withHasChips =\n hasText && enumerationType === 'chip' && target === 'textField-like' ? hasChips : undefined;\n\n const withNoFocus = target === 'textField-like' ? hasNoFocus : undefined;\n\n const isLabelVisible = !hasText || (hasLabel && enumerationType === 'comma');\n\n const onChipClick = useCallback((event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n }, []);\n\n const onChipClear = useCallback(\n (value: SelectPrimitiveValue, text: SelectPrimitiveValue, index: number) => {\n const newValue = values\n ?.filter(([itemValue, itemText]) => !(itemValue === value && itemText === text))\n .map(([itemValue]) => itemValue);\n\n chipsRefs?.current.splice(index, 1);\n onChange?.(newValue);\n },\n [values, onChange],\n );\n\n const onChipKeyDown = useCallback(\n (\n value: SelectPrimitiveValue,\n text: SelectPrimitiveValue,\n index: number,\n event: React.KeyboardEvent<HTMLButtonElement>,\n ) => {\n const { code, shiftKey } = event;\n\n if (code === Keys.Tab || (code === Keys.Tab && shiftKey)) {\n event.preventDefault();\n }\n\n if (code === Keys.Backspace) {\n onChipClear(value, text, index);\n }\n },\n [onChipClear],\n );\n\n const onWheel = useCallback((event: React.WheelEvent<HTMLButtonElement>) => {\n const { deltaY } = event;\n\n if (contentRef.current) {\n contentRef.current.scrollLeft += Math.round(deltaY);\n }\n }, []);\n\n const getRef = useCallback((element: HTMLButtonElement | null, index: number) => {\n if (element && chipsRefs && chipsRefs.current) {\n chipsRefs.current[index] = element;\n }\n }, []);\n\n // INFO: Нужно очищать на каждый ререндер компонента для актуализации состояния рефов\n if (chipsRefs) {\n chipsRefs.current = [];\n }\n\n return (\n <StyledSelectTarget\n {...rest}\n ref={ref}\n opened={opened}\n target={target}\n readOnly={readOnly}\n disabled={disabled}\n title={textContent}\n aria-label={label}\n className={cx(withInnerLabelUp, withHasChips, withNoFocus, selectTarget)}\n onWheel={onWheel}\n onKeyDown={onKeyDown}\n stretching=\"filled\"\n >\n {hasText &&\n (enumerationType === 'comma' || target === 'button-like' ? (\n <StyledText className={selectTargeText}>{textContent}</StyledText>\n ) : (\n <StyledChipsWrapper ref={contentRef}>\n <StyledChips>\n {values?.map(([value, text], index) => (\n <SelectChip\n index={index}\n ref={(element) => getRef(element, index)}\n key={`${value}_${text}`}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n text={text}\n onClear={(v, t) => onChipClear(v, t, index)}\n onClick={onChipClick}\n onKeyDown={onChipKeyDown}\n />\n ))}\n </StyledChips>\n </StyledChipsWrapper>\n ))}\n {isLabelVisible && (\n <StyledLabel className={selectTargetLabel} htmlFor={id}>\n {label}\n </StyledLabel>\n )}\n <StyledArrow size=\"s\" color=\"inherit\" className={cx(selectTargetArrow, withArrowInverse)} />\n </StyledSelectTarget>\n );\n },\n);\n"],"names":["hasNoFocus","classes","hasChips","innerLabelUp","arrowInverse","selectTarget","selectTargetArrow","selectTargeText","selectTargetLabel","SelectTarget","forwardRef","_ref","ref","values","_ref$target","target","label","opened","readOnly","disabled","enumerationType","size","id","chipsRefs","onChange","onKeyDown","rest","_objectWithoutProperties","_excluded","hasText","Boolean","some","_ref2","_ref3","_slicedToArray","value","hasLabel","textContent","map","_ref4","_ref5","text","join","contentRef","useRef","withArrowInverse","undefined","withInnerLabelUp","withHasChips","withNoFocus","isLabelVisible","onChipClick","useCallback","event","stopPropagation","onChipClear","index","newValue","filter","_ref6","_ref7","itemValue","itemText","_ref8","_ref9","current","splice","onChipKeyDown","code","shiftKey","Keys","Tab","preventDefault","Backspace","onWheel","deltaY","scrollLeft","Math","round","getRef","element","React","createElement","StyledSelectTarget","_extends","title","className","cx","stretching","StyledText","StyledChipsWrapper","StyledChips","_ref10","_ref11","SelectChip","key","concat","onClear","v","t","onClick","StyledLabel","htmlFor","StyledArrow","color"],"mappings":";;;;;;;;;AAkBA,IACIA,UAAU,GAQVC,OAAO,CARPD,UAAU;EACVE,QAAQ,GAORD,OAAO,CAPPC,QAAQ;EACRC,YAAY,GAMZF,OAAO,CANPE,YAAY;EACZC,YAAY,GAKZH,OAAO,CALPG,YAAY;EACZC,YAAY,GAIZJ,OAAO,CAJPI,YAAY;EACZC,iBAAiB,GAGjBL,OAAO,CAHPK,iBAAiB;EACjBC,eAAe,GAEfN,OAAO,CAFPM,eAAe;EACfC,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AAA,OAACC,CAAAA,CAAC,EAAEC,CAAC,EAAA;AAAA,QAAA,OAAK5C,WAAW,CAAC2C,CAAC,EAAEC,CAAC,EAAE3C,KAAK,CAAC,CAAA;OAAC;AAC5C4C,MAAAA,OAAO,EAAEjD,WAAY;AACrB1B,MAAAA,SAAS,EAAE0C,aAAAA;AAAc,KAC5B,CAAC,CAAA;GACL,CACQ,CACG,CACvB,CAAC,EACLjB,cAAc,iBACX+B,KAAA,CAAAC,aAAA,CAACmB,WAAW,EAAA;AAACf,IAAAA,SAAS,EAAE9E,iBAAkB;AAAC8F,IAAAA,OAAO,EAAEhF,EAAAA;AAAG,GAAA,EAClDN,KACQ,CAChB,eACDiE,KAAA,CAAAC,aAAA,CAACqB,WAAW,EAAA;AAAClF,IAAAA,IAAI,EAAC,GAAG;AAACmF,IAAAA,KAAK,EAAC,SAAS;AAAClB,IAAAA,SAAS,EAAEC,EAAE,CAACjF,iBAAiB,EAAEuC,gBAAgB,CAAA;AAAE,GAAE,CAC3E,CAAC,CAAA;AAE7B,CACJ;;;;"}
|
1
|
+
{"version":3,"file":"SelectTarget.js","sources":["../../../../../src/components/Select/ui/SelectTarget/SelectTarget.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useRef } from 'react';\n\nimport { classes } from '../../Select.tokens';\nimport { cx } from '../../../../utils';\nimport { SelectChip } from '../SelectChip/SelectChip';\nimport type { SelectPrimitiveValue } from '../../Select.types';\nimport { Keys } from '../../hooks/useKeyNavigation';\n\nimport {\n StyledArrow,\n StyledChips,\n StyledChipsWrapper,\n StyledLabel,\n StyledSelectTarget,\n StyledText,\n} from './SelectTarget.styles';\nimport type { SelectTargetProps } from './SelectTarget.types';\n\nconst {\n hasNoFocus,\n hasChips,\n innerLabelUp,\n arrowInverse,\n selectTarget,\n selectTargetArrow,\n selectTargeText,\n selectTargetLabel,\n} = classes;\n\n/**\n * Элемент для выпадающего списка\n */\nexport const SelectTarget = forwardRef<HTMLButtonElement, SelectTargetProps>(\n (\n {\n values,\n target = 'textField-like',\n label,\n opened,\n readOnly,\n disabled,\n enumerationType,\n size,\n id,\n chipsRefs,\n onChange,\n onKeyDown,\n ...rest\n },\n ref,\n ) => {\n const hasText = Boolean(values?.some(([value]) => value));\n\n const hasLabel = label && size !== 'xs' && target === 'textField-like';\n const textContent = values?.map(([, text]) => text).join(', ');\n const contentRef = useRef<HTMLDivElement>(null);\n\n const withArrowInverse = opened ? arrowInverse : undefined;\n const withInnerLabelUp = hasLabel && hasText ? innerLabelUp : undefined;\n const withHasChips =\n hasText && enumerationType === 'chip' && target === 'textField-like' ? hasChips : undefined;\n\n const withNoFocus = target === 'textField-like' ? hasNoFocus : undefined;\n\n const isLabelVisible = !hasText || (hasLabel && enumerationType === 'comma');\n\n const onChipClick = useCallback((event: React.MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n }, []);\n\n const onChipClear = useCallback(\n (value: SelectPrimitiveValue, text: SelectPrimitiveValue, index: number) => {\n const newValue = values\n ?.filter(([itemValue, itemText]) => !(itemValue === value && itemText === text))\n .map(([itemValue]) => itemValue);\n\n chipsRefs?.current.splice(index, 1);\n onChange?.(newValue);\n },\n [values, onChange],\n );\n\n const onChipKeyDown = useCallback(\n (\n value: SelectPrimitiveValue,\n text: SelectPrimitiveValue,\n index: number,\n event: React.KeyboardEvent<HTMLButtonElement>,\n ) => {\n const { code, shiftKey } = event;\n\n if (code === Keys.Tab || (code === Keys.Tab && shiftKey)) {\n event.preventDefault();\n }\n\n if (code === Keys.Backspace) {\n onChipClear(value, text, index);\n }\n },\n [onChipClear],\n );\n\n const onWheel = useCallback((event: React.WheelEvent<HTMLButtonElement>) => {\n const { deltaY } = event;\n\n if (contentRef.current) {\n contentRef.current.scrollLeft += Math.round(deltaY);\n }\n }, []);\n\n const getRef = useCallback((element: HTMLButtonElement | null, index: number) => {\n if (element && chipsRefs && chipsRefs.current) {\n chipsRefs.current[index] = element;\n }\n }, []);\n\n // INFO: Нужно очищать на каждый ререндер компонента для актуализации состояния рефов\n if (chipsRefs) {\n chipsRefs.current = [];\n }\n\n return (\n <StyledSelectTarget\n {...rest}\n ref={ref}\n opened={opened}\n target={target}\n readOnly={readOnly}\n disabled={disabled}\n title={textContent}\n aria-label={label}\n className={cx(withInnerLabelUp, withHasChips, withNoFocus, selectTarget)}\n onWheel={onWheel}\n onKeyDown={onKeyDown}\n stretching=\"filled\"\n >\n {hasText &&\n (enumerationType === 'comma' || target === 'button-like' ? (\n <StyledText className={selectTargeText}>{textContent}</StyledText>\n ) : (\n <StyledChipsWrapper ref={contentRef}>\n <StyledChips>\n {values?.map(([value, text], index) => (\n <SelectChip\n index={index}\n ref={(element) => getRef(element, index)}\n key={`${value}_${text}`}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n text={text}\n onClear={(v, t) => onChipClear(v, t, index)}\n onClick={onChipClick}\n onKeyDown={onChipKeyDown}\n />\n ))}\n </StyledChips>\n </StyledChipsWrapper>\n ))}\n {isLabelVisible && (\n <StyledLabel className={selectTargetLabel} htmlFor={id}>\n {label}\n </StyledLabel>\n )}\n <StyledArrow size=\"s\" color=\"inherit\" className={cx(selectTargetArrow, withArrowInverse)} />\n </StyledSelectTarget>\n );\n },\n);\n"],"names":["hasNoFocus","classes","hasChips","innerLabelUp","arrowInverse","selectTarget","selectTargetArrow","selectTargeText","selectTargetLabel","SelectTarget","forwardRef","_ref","ref","values","_ref$target","target","label","opened","readOnly","disabled","enumerationType","size","id","chipsRefs","onChange","onKeyDown","rest","_objectWithoutProperties","_excluded","hasText","Boolean","some","_ref2","_ref3","_slicedToArray","value","hasLabel","textContent","map","_ref4","_ref5","text","join","contentRef","useRef","withArrowInverse","undefined","withInnerLabelUp","withHasChips","withNoFocus","isLabelVisible","onChipClick","useCallback","event","stopPropagation","onChipClear","index","newValue","filter","_ref6","_ref7","itemValue","itemText","_ref8","_ref9","current","splice","onChipKeyDown","code","shiftKey","Keys","Tab","preventDefault","Backspace","onWheel","deltaY","scrollLeft","Math","round","getRef","element","React","createElement","StyledSelectTarget","_extends","title","className","cx","stretching","StyledText","StyledChipsWrapper","StyledChips","_ref10","_ref11","SelectChip","key","concat","onClear","v","t","onClick","StyledLabel","htmlFor","StyledArrow","color"],"mappings":";;;;;;;;;AAkBA,IACIA,UAAU,GAQVC,OAAO,CARPD,UAAU;EACVE,QAAQ,GAORD,OAAO,CAPPC,QAAQ;EACRC,YAAY,GAMZF,OAAO,CANPE,YAAY;EACZC,YAAY,GAKZH,OAAO,CALPG,YAAY;EACZC,YAAY,GAIZJ,OAAO,CAJPI,YAAY;EACZC,iBAAiB,GAGjBL,OAAO,CAHPK,iBAAiB;EACjBC,eAAe,GAEfN,OAAO,CAFPM,eAAe;EACfC,iBAAiB,GACjBP,OAAO,CADPO,iBAAiB,CAAA;;AAGrB;AACA;AACA;AACO,IAAMC,YAAY,gBAAGC,UAAU,CAClC,UAAAC,IAAA,EAgBIC,GAAG,EACF;AAAA,EAAA,IAfGC,MAAM,GAAAF,IAAA,CAANE,MAAM;IAAAC,WAAA,GAAAH,IAAA,CACNI,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAG,KAAA,CAAA,GAAA,gBAAgB,GAAAA,WAAA;IACzBE,KAAK,GAAAL,IAAA,CAALK,KAAK;IACLC,MAAM,GAAAN,IAAA,CAANM,MAAM;IACNC,QAAQ,GAAAP,IAAA,CAARO,QAAQ;IACRC,QAAQ,GAAAR,IAAA,CAARQ,QAAQ;IACRC,eAAe,GAAAT,IAAA,CAAfS,eAAe;IACfC,IAAI,GAAAV,IAAA,CAAJU,IAAI;IACJC,EAAE,GAAAX,IAAA,CAAFW,EAAE;IACFC,SAAS,GAAAZ,IAAA,CAATY,SAAS;IACTC,QAAQ,GAAAb,IAAA,CAARa,QAAQ;IACRC,SAAS,GAAAd,IAAA,CAATc,SAAS;AACNC,IAAAA,IAAI,GAAAC,wBAAA,CAAAhB,IAAA,EAAAiB,SAAA,CAAA,CAAA;AAIX,EAAA,IAAMC,OAAO,GAAGC,OAAO,CA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AAAA,IAAA,oBACtBZ,KAAA,CAAAC,aAAA,CAACY,UAAU,EAAA;AACPtC,MAAAA,KAAK,EAAEA,KAAM;MACb5C,GAAG,EAAE,SAAAA,GAAAA,CAACoE,OAAO,EAAA;AAAA,QAAA,OAAKD,MAAM,CAACC,OAAO,EAAExB,KAAK,CAAC,CAAA;OAAC;MACzCuC,GAAG,EAAA,EAAA,CAAAC,MAAA,CAAK7D,KAAK,OAAA6D,MAAA,CAAIvD,IAAI,CAAG;AACxBtB,MAAAA,QAAQ,EAAEA,QAAS;AACnBD,MAAAA,QAAQ,EAAEA,QAAS;AACnBiB,MAAAA,KAAK,EAAEA,KAAM;AACbM,MAAAA,IAAI,EAAEA,IAAK;AACXwD,MAAAA,OAAO,EAAE,SAAAA,OAACC,CAAAA,CAAC,EAAEC,CAAC,EAAA;AAAA,QAAA,OAAK5C,WAAW,CAAC2C,CAAC,EAAEC,CAAC,EAAE3C,KAAK,CAAC,CAAA;OAAC;AAC5C4C,MAAAA,OAAO,EAAEjD,WAAY;AACrB1B,MAAAA,SAAS,EAAE0C,aAAAA;AAAc,KAC5B,CAAC,CAAA;GACL,CACQ,CACG,CACvB,CAAC,EACLjB,cAAc,iBACX+B,KAAA,CAAAC,aAAA,CAACmB,WAAW,EAAA;AAACf,IAAAA,SAAS,EAAE9E,iBAAkB;AAAC8F,IAAAA,OAAO,EAAEhF,EAAAA;AAAG,GAAA,EAClDN,KACQ,CAChB,eACDiE,KAAA,CAAAC,aAAA,CAACqB,WAAW,EAAA;AAAClF,IAAAA,IAAI,EAAC,GAAG;AAACmF,IAAAA,KAAK,EAAC,SAAS;AAAClB,IAAAA,SAAS,EAAEC,EAAE,CAACjF,iBAAiB,EAAEuC,gBAAgB,CAAA;AAAE,GAAE,CAC3E,CAAC,CAAA;AAE7B,CACJ;;;;"}
|
@@ -76,8 +76,8 @@ var updatePropsRecursively = function updatePropsRecursively(children, externalP
|
|
76
76
|
},
|
77
77
|
onClick: function onClick(event) {
|
78
78
|
var _child$props$onClick, _child$props, _externalProps$onClic;
|
79
|
-
(_child$props$onClick = (_child$props = child.props).onClick) === null || _child$props$onClick === void 0
|
80
|
-
externalProps === null || externalProps === void 0
|
79
|
+
(_child$props$onClick = (_child$props = child.props).onClick) === null || _child$props$onClick === void 0 ? void 0 : _child$props$onClick.call(_child$props, event);
|
80
|
+
externalProps === null || externalProps === void 0 ? void 0 : (_externalProps$onClic = externalProps.onClick) === null || _externalProps$onClic === void 0 ? void 0 : _externalProps$onClic.call(externalProps, event);
|
81
81
|
}
|
82
82
|
});
|
83
83
|
var updatedChild = updatePropsRecursively(child.props.children, externalProps, value, search, filterFunction);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Select/utils/index.ts"],"sourcesContent":["import { Children, MouseEvent, ReactElement, ReactNode, cloneElement, isValidElement } from 'react';\n\nimport { SelectPrimitiveValue, ValueType, SelectValue } from '../Select.types';\nimport { SelectItemProps } from '../ui/SelectItem/SelectItem.type';\n\ntype NewSelectedFunc = {\n (selected?: undefined | null, newValue?: undefined | null, type?: undefined | null): undefined;\n (selected?: SelectPrimitiveValue, newValue?: SelectPrimitiveValue, type?: ValueType): SelectPrimitiveValue;\n (selected?: Array<SelectPrimitiveValue>, newValue?: SelectPrimitiveValue, type?: ValueType): Array<\n SelectPrimitiveValue\n >;\n};\n\nexport const getNewSelected: NewSelectedFunc = (selected: any, newValue: any, type: any) => {\n if (newValue === undefined || newValue === null) {\n return newValue;\n }\n\n if (\n (type === 'single' || type === 'native') &&\n (typeof newValue === 'string' || typeof newValue === 'number' || typeof newValue === 'boolean')\n ) {\n return newValue;\n }\n\n const newSelected = selected || [];\n\n const set = new Set(newSelected);\n\n if (set.has(newValue)) {\n set.delete(newValue);\n } else {\n set.add(newValue);\n }\n\n return Array.from(set);\n};\n\nconst getChildrenInnerText = (children: ReactElement): string => {\n if (!children || typeof children === 'string') {\n return children;\n }\n\n return getChildrenInnerText(children.props.children);\n};\n\nexport const getValues = (items: ReactElement[], value?: SelectValue, result: Array<Array<string>> = []) => {\n items.forEach((item) => {\n if (item.props === undefined) {\n return result;\n }\n\n const { value: newValue } = item.props;\n\n if (item.props.children && Array.isArray(item.props.children)) {\n return getValues(item.props.children, value, result);\n }\n\n if (\n (!Array.isArray(value) && newValue === value) ||\n (Array.isArray(value) && value?.find((v) => newValue === v))\n ) {\n const index = (Array.isArray(value) && value?.findIndex((v) => newValue === v)) || 0;\n\n if (item.props.text) {\n const { text: newText } = item.props;\n result[index] = [newValue, newText];\n\n return;\n }\n\n const newText = getChildrenInnerText(item.props.children);\n result[index] = [newValue, newText];\n }\n\n return result;\n });\n\n return result;\n};\n\nconst getChildrenItemChecked = (value?: SelectValue, child?: ReactElement<SelectItemProps>) =>\n (!Array.isArray(value) && child?.props.value === value) ||\n (Array.isArray(value) && Boolean(value?.find((v) => child?.props.value === v)));\n\n// INFO: Функция для рекурсивного обновления пропсов\nexport const updatePropsRecursively = (\n children?: ReactElement<SelectItemProps>[],\n externalProps?: Record<string, any>,\n value?: SelectValue,\n search?: string,\n filterFunction?: (childText: string, filterValue?: string) => boolean,\n): ReactNode[] =>\n Children.map(children || [], (child) => {\n if (!isValidElement(child)) {\n return child;\n }\n\n const hasValue = 'value' in child?.props;\n\n const props = {\n key: `${value}$`,\n checked: getChildrenItemChecked(value, child),\n ...(hasValue && {\n ref: (element: HTMLDivElement) => {\n if (externalProps?.childrenRefs?.current && element) {\n externalProps.childrenRefs.current.push(element);\n }\n },\n onClick: (event: MouseEvent<HTMLDivElement>) => {\n child.props.onClick?.(event);\n externalProps?.onClick?.(event);\n },\n }),\n };\n\n const updatedChild = updatePropsRecursively(\n child.props.children as ReactElement<SelectItemProps>[],\n externalProps,\n value,\n search,\n filterFunction,\n );\n\n if (filterFunction) {\n const text = child.props?.text || '';\n\n return filterFunction(text, search) ? cloneElement(child, props, updatedChild) : null;\n }\n\n return cloneElement(child, props, updatedChild);\n });\n\nconst defaultFilterFunction = (text: string, filterValue = '') => text.includes(filterValue);\n\nexport const getChildren = (\n children: ReactElement<SelectItemProps>[],\n externalProps: Record<string, any>,\n value?: SelectValue,\n search?: string,\n filterFunction = defaultFilterFunction,\n) => {\n if (externalProps.childrenRefs) {\n externalProps.childrenRefs.current = [];\n }\n\n return updatePropsRecursively(children, externalProps, value, search, filterFunction);\n};\n"],"names":["getNewSelected","selected","newValue","type","undefined","newSelected","set","Set","has","add","Array","from","getChildrenInnerText","children","props","getValues","items","value","result","arguments","length","forEach","item","isArray","find","v","index","findIndex","text","newText","getChildrenItemChecked","child","Boolean","updatePropsRecursively","externalProps","search","filterFunction","Children","map","isValidElement","hasValue","_objectSpread","key","concat","checked","ref","element","_externalProps$childr","childrenRefs","current","push","onClick","event","_child$props$onClick","_child$props","_externalProps$onClic","call","updatedChild","_child$props2","cloneElement","defaultFilterFunction","filterValue","includes","getChildren"],"mappings":";;;AAaO,IAAMA,cAA+B,GAAG,SAAlCA,cAA+BA,CAAIC,QAAa,EAAEC,QAAa,EAAEC,IAAS,EAAK;AACxF,EAAA,IAAID,QAAQ,KAAKE,SAAS,IAAIF,QAAQ,KAAK,IAAI,EAAE;AAC7C,IAAA,OAAOA,QAAQ,CAAA;AACnB,GAAA;EAEA,IACI,CAACC,IAAI,KAAK,QAAQ,IAAIA,IAAI,KAAK,QAAQ,MACtC,OAAOD,QAAQ,KAAK,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,IAAI,OAAOA,QAAQ,KAAK,SAAS,CAAC,EACjG;AACE,IAAA,OAAOA,QAAQ,CAAA;AACnB,GAAA;AAEA,EAAA,IAAMG,WAAW,GAAGJ,QAAQ,IAAI,EAAE,CAAA;AAElC,EAAA,IAAMK,GAAG,GAAG,IAAIC,GAAG,CAACF,WAAW,CAAC,CAAA;AAEhC,EAAA,IAAIC,GAAG,CAACE,GAAG,CAACN,QAAQ,CAAC,EAAE;IACnBI,GAAG,CAAA,QAAA,CAAO,CAACJ,QAAQ,CAAC,CAAA;AACxB,GAAC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MAAA,OAAOQ,cAAc,CAACR,IAAI,EAAEO,MAAM,CAAC,gBAAGwB,YAAY,CAAC5B,KAAK,EAAEjB,KAAK,EAAE2C,YAAY,CAAC,GAAG,IAAI,CAAA;AACzF,KAAA;AAEA,IAAA,oBAAOE,YAAY,CAAC5B,KAAK,EAAEjB,KAAK,EAAE2C,YAAY,CAAC,CAAA;AACnD,GAAC,CAAC,CAAA;AAAA,EAAA;AAEN,IAAMG,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAIhC,IAAY,EAAA;AAAA,EAAA,IAAEiC,WAAW,GAAA1C,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAf,SAAA,GAAAe,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;AAAA,EAAA,OAAKS,IAAI,CAACkC,QAAQ,CAACD,WAAW,CAAC,CAAA;AAAA,CAAA,CAAA;AAE/EE,IAAAA,WAAW,GAAG,SAAdA,WAAWA,CACpBlD,QAAyC,EACzCqB,aAAkC,EAClCjB,KAAmB,EACnBkB,MAAe,EAEd;AAAA,EAAA,IADDC,cAAc,GAAAjB,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAf,SAAA,GAAAe,SAAA,CAAA,CAAA,CAAA,GAAGyC,qBAAqB,CAAA;EAEtC,IAAI1B,aAAa,CAACc,YAAY,EAAE;AAC5Bd,IAAAA,aAAa,CAACc,YAAY,CAACC,OAAO,GAAG,EAAE,CAAA;AAC3C,GAAA;EAEA,OAAOhB,sBAAsB,CAACpB,QAAQ,EAAEqB,aAAa,EAAEjB,KAAK,EAAEkB,MAAM,EAAEC,cAAc,CAAC,CAAA;AACzF;;;;"}
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Select/utils/index.ts"],"sourcesContent":["import { Children, MouseEvent, ReactElement, ReactNode, cloneElement, isValidElement } from 'react';\n\nimport { SelectPrimitiveValue, ValueType, SelectValue } from '../Select.types';\nimport { SelectItemProps } from '../ui/SelectItem/SelectItem.type';\n\ntype NewSelectedFunc = {\n (selected?: undefined | null, newValue?: undefined | null, type?: undefined | null): undefined;\n (selected?: SelectPrimitiveValue, newValue?: SelectPrimitiveValue, type?: ValueType): SelectPrimitiveValue;\n (selected?: Array<SelectPrimitiveValue>, newValue?: SelectPrimitiveValue, type?: ValueType): Array<\n SelectPrimitiveValue\n >;\n};\n\nexport const getNewSelected: NewSelectedFunc = (selected: any, newValue: any, type: any) => {\n if (newValue === undefined || newValue === null) {\n return newValue;\n }\n\n if (\n (type === 'single' || type === 'native') &&\n (typeof newValue === 'string' || typeof newValue === 'number' || typeof newValue === 'boolean')\n ) {\n return newValue;\n }\n\n const newSelected = selected || [];\n\n const set = new Set(newSelected);\n\n if (set.has(newValue)) {\n set.delete(newValue);\n } else {\n set.add(newValue);\n }\n\n return Array.from(set);\n};\n\nconst getChildrenInnerText = (children: ReactElement): string => {\n if (!children || typeof children === 'string') {\n return children;\n }\n\n return getChildrenInnerText(children.props.children);\n};\n\nexport const getValues = (items: ReactElement[], value?: SelectValue, result: Array<Array<string>> = []) => {\n items.forEach((item) => {\n if (item.props === undefined) {\n return result;\n }\n\n const { value: newValue } = item.props;\n\n if (item.props.children && Array.isArray(item.props.children)) {\n return getValues(item.props.children, value, result);\n }\n\n if (\n (!Array.isArray(value) && newValue === value) ||\n (Array.isArray(value) && value?.find((v) => newValue === v))\n ) {\n const index = (Array.isArray(value) && value?.findIndex((v) => newValue === v)) || 0;\n\n if (item.props.text) {\n const { text: newText } = item.props;\n result[index] = [newValue, newText];\n\n return;\n }\n\n const newText = getChildrenInnerText(item.props.children);\n result[index] = [newValue, newText];\n }\n\n return result;\n });\n\n return result;\n};\n\nconst getChildrenItemChecked = (value?: SelectValue, child?: ReactElement<SelectItemProps>) =>\n (!Array.isArray(value) && child?.props.value === value) ||\n (Array.isArray(value) && Boolean(value?.find((v) => child?.props.value === v)));\n\n// INFO: Функция для рекурсивного обновления пропсов\nexport const updatePropsRecursively = (\n children?: ReactElement<SelectItemProps>[],\n externalProps?: Record<string, any>,\n value?: SelectValue,\n search?: string,\n filterFunction?: (childText: string, filterValue?: string) => boolean,\n): ReactNode[] =>\n Children.map(children || [], (child) => {\n if (!isValidElement(child)) {\n return child;\n }\n\n const hasValue = 'value' in child?.props;\n\n const props = {\n key: `${value}$`,\n checked: getChildrenItemChecked(value, child),\n ...(hasValue && {\n ref: (element: HTMLDivElement) => {\n if (externalProps?.childrenRefs?.current && element) {\n externalProps.childrenRefs.current.push(element);\n }\n },\n onClick: (event: MouseEvent<HTMLDivElement>) => {\n child.props.onClick?.(event);\n externalProps?.onClick?.(event);\n },\n }),\n };\n\n const updatedChild = updatePropsRecursively(\n child.props.children as ReactElement<SelectItemProps>[],\n externalProps,\n value,\n search,\n filterFunction,\n );\n\n if (filterFunction) {\n const text = child.props?.text || '';\n\n return filterFunction(text, search) ? cloneElement(child, props, updatedChild) : null;\n }\n\n return cloneElement(child, props, updatedChild);\n });\n\nconst defaultFilterFunction = (text: string, filterValue = '') => text.includes(filterValue);\n\nexport const getChildren = (\n children: ReactElement<SelectItemProps>[],\n externalProps: Record<string, any>,\n value?: SelectValue,\n search?: string,\n filterFunction = defaultFilterFunction,\n) => {\n if (externalProps.childrenRefs) {\n externalProps.childrenRefs.current = [];\n }\n\n return updatePropsRecursively(children, externalProps, value, search, filterFunction);\n};\n"],"names":["getNewSelected","selected","newValue","type","undefined","newSelected","set","Set","has","add","Array","from","getChildrenInnerText","children","props","getValues","items","value","result","arguments","length","forEach","item","isArray","find","v","index","findIndex","text","newText","getChildrenItemChecked","child","Boolean","updatePropsRecursively","externalProps","search","filterFunction","Children","map","isValidElement","hasValue","_objectSpread","key","concat","checked","ref","element","_externalProps$childr","childrenRefs","current","push","onClick","event","_child$props$onClick","_child$props","_externalProps$onClic","call","updatedChild","_child$props2","cloneElement","defaultFilterFunction","filterValue","includes","getChildren"],"mappings":";;;AAaO,IAAMA,cAA+B,GA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AACkC,QAAQ,CAACD,WAAW,CAAC,CAAA;AAAA,CAAA,CAAA;AAE/EE,IAAAA,WAAW,GAAG,SAAdA,WAAWA,CACpBlD,QAAyC,EACzCqB,aAAkC,EAClCjB,KAAmB,EACnBkB,MAAe,EAEd;AAAA,EAAA,IADDC,cAAc,GAAAjB,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAf,SAAA,GAAAe,SAAA,CAAA,CAAA,CAAA,GAAGyC,qBAAqB,CAAA;EAEtC,IAAI1B,aAAa,CAACc,YAAY,EAAE;AAC5Bd,IAAAA,aAAa,CAACc,YAAY,CAACC,OAAO,GAAG,EAAE,CAAA;AAC3C,GAAA;EAEA,OAAOhB,sBAAsB,CAACpB,QAAQ,EAAEqB,aAAa,EAAEjB,KAAK,EAAEkB,MAAM,EAAEC,cAAc,CAAC,CAAA;AACzF;;;;"}
|
@@ -8,7 +8,7 @@ var TabItemRefs = /*#__PURE__*/function () {
|
|
8
8
|
_defineProperty(this, "current", 0);
|
9
9
|
this.current = value || 0;
|
10
10
|
}
|
11
|
-
|
11
|
+
_createClass(TabItemRefs, [{
|
12
12
|
key: "register",
|
13
13
|
value: function register(ref) {
|
14
14
|
this.items.push(ref);
|
@@ -25,6 +25,7 @@ var TabItemRefs = /*#__PURE__*/function () {
|
|
25
25
|
this.current = value;
|
26
26
|
}
|
27
27
|
}]);
|
28
|
+
return TabItemRefs;
|
28
29
|
}();
|
29
30
|
var TabsContext = /*#__PURE__*/createContext(null);
|
30
31
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TabsContext.js","sources":["../../../src/components/Tabs/TabsContext.tsx"],"sourcesContent":["import { MutableRefObject, createContext } from 'react';\n\nexport class TabItemRefs {\n public items: MutableRefObject<HTMLElement | null>[] = [];\n\n public current = 0;\n\n constructor(value?: number) {\n this.current = value || 0;\n }\n\n public register(ref: MutableRefObject<HTMLElement | null>): number {\n this.items.push(ref);\n return this.items.length - 1;\n }\n\n public unregister(ref: MutableRefObject<HTMLElement | null>) {\n this.items.splice(this.items.indexOf(ref), 1);\n }\n\n public setCurrent(value: number) {\n this.current = value;\n }\n}\n\nexport const TabsContext = createContext<TabItemRefs | null>(null);\n"],"names":["TabItemRefs","value","_classCallCheck","_defineProperty","current","_createClass","key","register","ref","items","push","length","unregister","splice","indexOf","setCurrent","TabsContext","createContext"],"mappings":";;;AAEA,IAAaA,WAAW,gBAAA,YAAA;EAKpB,SAAAA,WAAAA,CAAYC,KAAc,EAAE;AAAAC,IAAAA,eAAA,OAAAF,WAAA,CAAA,CAAA;AAAAG,IAAAA,eAAA,gBAJ2B,EAAE,CAAA,CAAA;AAAAA,IAAAA,eAAA,kBAExC,CAAC,CAAA,CAAA;AAGd,IAAA,IAAI,CAACC,OAAO,GAAGH,KAAK,IAAI,CAAC,CAAA;AAC7B,GAAA;
|
1
|
+
{"version":3,"file":"TabsContext.js","sources":["../../../src/components/Tabs/TabsContext.tsx"],"sourcesContent":["import { MutableRefObject, createContext } from 'react';\n\nexport class TabItemRefs {\n public items: MutableRefObject<HTMLElement | null>[] = [];\n\n public current = 0;\n\n constructor(value?: number) {\n this.current = value || 0;\n }\n\n public register(ref: MutableRefObject<HTMLElement | null>): number {\n this.items.push(ref);\n return this.items.length - 1;\n }\n\n public unregister(ref: MutableRefObject<HTMLElement | null>) {\n this.items.splice(this.items.indexOf(ref), 1);\n }\n\n public setCurrent(value: number) {\n this.current = value;\n }\n}\n\nexport const TabsContext = createContext<TabItemRefs | null>(null);\n"],"names":["TabItemRefs","value","_classCallCheck","_defineProperty","current","_createClass","key","register","ref","items","push","length","unregister","splice","indexOf","setCurrent","TabsContext","createContext"],"mappings":";;;AAEA,IAAaA,WAAW,gBAAA,YAAA;EAKpB,SAAAA,WAAAA,CAAYC,KAAc,EAAE;AAAAC,IAAAA,eAAA,OAAAF,WAAA,CAAA,CAAA;AAAAG,IAAAA,eAAA,gBAJ2B,EAAE,CAAA,CAAA;AAAAA,IAAAA,eAAA,kBAExC,CAAC,CAAA,CAAA;AAGd,IAAA,IAAI,CAACC,OAAO,GAAGH,KAAK,IAAI,CAAC,CAAA;AAC7B,GAAA;AAACI,EAAAA,YAAA,CAAAL,WAAA,EAAA,CAAA;IAAAM,GAAA,EAAA,UAAA;AAAAL,IAAAA,KAAA,EAED,SAAAM,QAAgBC,CAAAA,GAAyC,EAAU;AAC/D,MAAA,IAAI,CAACC,KAAK,CAACC,IAAI,CAACF,GAAG,CAAC,CAAA;AACpB,MAAA,OAAO,IAAI,CAACC,KAAK,CAACE,MAAM,GAAG,CAAC,CAAA;AAChC,KAAA;AAAC,GAAA,EAAA;IAAAL,GAAA,EAAA,YAAA;AAAAL,IAAAA,KAAA,EAED,SAAAW,UAAkBJ,CAAAA,GAAyC,EAAE;AACzD,MAAA,IAAI,CAACC,KAAK,CAACI,MAAM,CAAC,IAAI,CAACJ,KAAK,CAACK,OAAO,CAACN,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;AACjD,KAAA;AAAC,GAAA,EAAA;IAAAF,GAAA,EAAA,YAAA;AAAAL,IAAAA,KAAA,EAED,SAAAc,UAAkBd,CAAAA,KAAa,EAAE;MAC7B,IAAI,CAACG,OAAO,GAAGH,KAAK,CAAA;AACxB,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,EAAA,OAAAD,WAAA,CAAA;AAAA,CAAA,GAAA;IAGQgB,WAAW,gBAAGC,aAAa,CAAqB,IAAI;;;;"}
|
@@ -67,7 +67,7 @@ var tabItemRoot = function tabItemRoot(Root) {
|
|
67
67
|
if (focusIndex === refs.current) {
|
68
68
|
return;
|
69
69
|
}
|
70
|
-
onIndexChange === null || onIndexChange === void 0
|
70
|
+
onIndexChange === null || onIndexChange === void 0 ? void 0 : onIndexChange(focusIndex);
|
71
71
|
refs.setCurrent(focusIndex);
|
72
72
|
}, [refs, innerRef, onIndexChange, disabled]);
|
73
73
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TabItem.js","sources":["../../../../../src/components/Tabs/ui/TabItem/TabItem.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useContext, useEffect, useCallback } from 'react';\nimport { useForkRef } from '@salutejs/plasma-core';\n\nimport { ComponentConfig, RootProps } from '../../../../engines';\nimport { classes } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabsContext } from '../../TabsContext';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { TabItemProps } from './TabItem.types';\nimport { LeftContent, RightContent, StyledContent, base } from './TabItem.styles';\n\nexport const tabItemRoot = (Root: RootProps<HTMLDivElement, TabItemProps>) =>\n forwardRef<HTMLDivElement, TabItemProps>((props, outerRef) => {\n const {\n size,\n view,\n isActive,\n selected,\n disabled = false,\n pilled = false,\n children,\n contentLeft,\n contentRight,\n animated = true,\n onIndexChange,\n itemIndex,\n tabIndex,\n ...rest\n } = props;\n\n const innerRef = useRef<HTMLDivElement>(null);\n const ref = useForkRef(outerRef, innerRef);\n const refs = useContext(TabsContext);\n\n const role = 'tab';\n\n const pilledAttr = view !== 'clear' && pilled;\n const animatedClass = animated ? classes.tabItemAnimated : undefined;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n const selectedClass = isActive || selected ? classes.selectedTabsItem : undefined;\n const hasKeyNavigation = itemIndex !== undefined && onIndexChange !== undefined;\n const navigationTabIndex = !disabled && refs?.current === itemIndex ? 0 : -1;\n\n useEffect(() => {\n if (!refs) {\n return;\n }\n\n refs.register(innerRef);\n\n return () => refs.unregister(innerRef);\n }, [refs]);\n\n const onItemFocus = useCallback<React.FocusEventHandler>(\n (event) => {\n if (!hasKeyNavigation) {\n event.target.scrollIntoView({\n block: 'center',\n inline: 'center',\n behavior: 'smooth',\n });\n\n return;\n }\n\n if (disabled || !refs) {\n return;\n }\n\n const focusIndex = refs.items.findIndex((itemRef) => itemRef.current === event.target);\n\n if (focusIndex === refs.current) {\n return;\n }\n\n onIndexChange?.(focusIndex);\n refs.setCurrent(focusIndex);\n },\n [refs, innerRef, onIndexChange, disabled],\n );\n\n return (\n <Root\n ref={ref}\n disabled={disabled}\n pilled={pilled}\n role={role}\n view={view}\n size={size}\n onFocus={onItemFocus}\n tabIndex={hasKeyNavigation ? navigationTabIndex : tabIndex}\n className={cx(pilledClass, selectedClass, animatedClass)}\n {...rest}\n >\n <>\n {contentLeft && <LeftContent className={classes.tabLeftContent}>{contentLeft}</LeftContent>}\n <StyledContent className={classes.tabContent}>{children}</StyledContent>\n {contentRight && <RightContent className={classes.tabRightContent}>{contentRight}</RightContent>}\n </>\n </Root>\n );\n });\n\nexport const tabItemConfig: ComponentConfig = {\n name: 'TabItem',\n tag: 'button',\n layout: tabItemRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'default',\n },\n};\n"],"names":["tabItemRoot","Root","forwardRef","props","outerRef","size","view","isActive","selected","_props$disabled","disabled","_props$pilled","pilled","children","contentLeft","contentRight","_props$animated","animated","onIndexChange","itemIndex","tabIndex","rest","_objectWithoutProperties","_excluded","innerRef","useRef","ref","useForkRef","refs","useContext","TabsContext","role","pilledAttr","animatedClass","classes","tabItemAnimated","undefined","pilledClass","tabsPilled","selectedClass","selectedTabsItem","hasKeyNavigation","navigationTabIndex","current","useEffect","register","unregister","onItemFocus","useCallback","event","target","scrollIntoView","block","inline","behavior","focusIndex","items","findIndex","itemRef","setCurrent","React","createElement","_extends","onFocus","className","cx","Fragment","LeftContent","tabLeftContent","StyledContent","tabContent","RightContent","tabRightContent","tabItemConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;IAeaA,WAA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ACJ,OAAA;MAEA,IAAM2B,UAAU,GAAG3B,IAAI,CAAC4B,KAAK,CAACC,SAAS,CAAC,UAACC,OAAO,EAAA;AAAA,QAAA,OAAKA,OAAO,CAACf,OAAO,KAAKM,KAAK,CAACC,MAAM,CAAA;OAAC,CAAA,CAAA;AAEtF,MAAA,IAAIK,UAAU,KAAK3B,IAAI,CAACe,OAAO,EAAE;AAC7B,QAAA,OAAA;AACJ,OAAA;AAEAzB,MAAAA,aAAa,aAAbA,aAAa,KAAA,KAAA,CAAA,
|
1
|
+
{"version":3,"file":"TabItem.js","sources":["../../../../../src/components/Tabs/ui/TabItem/TabItem.tsx"],"sourcesContent":["import React, { forwardRef, useRef, useContext, useEffect, useCallback } from 'react';\nimport { useForkRef } from '@salutejs/plasma-core';\n\nimport { ComponentConfig, RootProps } from '../../../../engines';\nimport { classes } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabsContext } from '../../TabsContext';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { TabItemProps } from './TabItem.types';\nimport { LeftContent, RightContent, StyledContent, base } from './TabItem.styles';\n\nexport const tabItemRoot = (Root: RootProps<HTMLDivElement, TabItemProps>) =>\n forwardRef<HTMLDivElement, TabItemProps>((props, outerRef) => {\n const {\n size,\n view,\n isActive,\n selected,\n disabled = false,\n pilled = false,\n children,\n contentLeft,\n contentRight,\n animated = true,\n onIndexChange,\n itemIndex,\n tabIndex,\n ...rest\n } = props;\n\n const innerRef = useRef<HTMLDivElement>(null);\n const ref = useForkRef(outerRef, innerRef);\n const refs = useContext(TabsContext);\n\n const role = 'tab';\n\n const pilledAttr = view !== 'clear' && pilled;\n const animatedClass = animated ? classes.tabItemAnimated : undefined;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n const selectedClass = isActive || selected ? classes.selectedTabsItem : undefined;\n const hasKeyNavigation = itemIndex !== undefined && onIndexChange !== undefined;\n const navigationTabIndex = !disabled && refs?.current === itemIndex ? 0 : -1;\n\n useEffect(() => {\n if (!refs) {\n return;\n }\n\n refs.register(innerRef);\n\n return () => refs.unregister(innerRef);\n }, [refs]);\n\n const onItemFocus = useCallback<React.FocusEventHandler>(\n (event) => {\n if (!hasKeyNavigation) {\n event.target.scrollIntoView({\n block: 'center',\n inline: 'center',\n behavior: 'smooth',\n });\n\n return;\n }\n\n if (disabled || !refs) {\n return;\n }\n\n const focusIndex = refs.items.findIndex((itemRef) => itemRef.current === event.target);\n\n if (focusIndex === refs.current) {\n return;\n }\n\n onIndexChange?.(focusIndex);\n refs.setCurrent(focusIndex);\n },\n [refs, innerRef, onIndexChange, disabled],\n );\n\n return (\n <Root\n ref={ref}\n disabled={disabled}\n pilled={pilled}\n role={role}\n view={view}\n size={size}\n onFocus={onItemFocus}\n tabIndex={hasKeyNavigation ? navigationTabIndex : tabIndex}\n className={cx(pilledClass, selectedClass, animatedClass)}\n {...rest}\n >\n <>\n {contentLeft && <LeftContent className={classes.tabLeftContent}>{contentLeft}</LeftContent>}\n <StyledContent className={classes.tabContent}>{children}</StyledContent>\n {contentRight && <RightContent className={classes.tabRightContent}>{contentRight}</RightContent>}\n </>\n </Root>\n );\n });\n\nexport const tabItemConfig: ComponentConfig = {\n name: 'TabItem',\n tag: 'button',\n layout: tabItemRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'default',\n },\n};\n"],"names":["tabItemRoot","Root","forwardRef","props","outerRef","size","view","isActive","selected","_props$disabled","disabled","_props$pilled","pilled","children","contentLeft","contentRight","_props$animated","animated","onIndexChange","itemIndex","tabIndex","rest","_objectWithoutProperties","_excluded","innerRef","useRef","ref","useForkRef","refs","useContext","TabsContext","role","pilledAttr","animatedClass","classes","tabItemAnimated","undefined","pilledClass","tabsPilled","selectedClass","selectedTabsItem","hasKeyNavigation","navigationTabIndex","current","useEffect","register","unregister","onItemFocus","useCallback","event","target","scrollIntoView","block","inline","behavior","focusIndex","items","findIndex","itemRef","setCurrent","React","createElement","_extends","onFocus","className","cx","Fragment","LeftContent","tabLeftContent","StyledContent","tabContent","RightContent","tabRightContent","tabItemConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;IAeaA,WAAW,GAAG,SAAdA,WAAWA,CAAIC,IAA6C,EAAA;AAAA,EAAA,oBACrEC,UAAU,CAA+B,UAACC,KAAK,EAAEC,QAAQ,EAAK;AAC1D,IAAA,IACIC,IAAI,GAcJF,KAAK,CAdLE,IAAI;MACJC,IAAI,GAaJH,KAAK,CAbLG,IAAI;MACJC,QAAQ,GAYRJ,KAAK,CAZLI,QAAQ;MACRC,QAAQ,GAWRL,KAAK,CAXLK,QAAQ;MAAAC,eAAA,GAWRN,KAAK,CAVLO,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,eAAA;MAAAE,aAAA,GAUhBR,KAAK,CATLS,MAAM;AAANA,MAAAA,MAAM,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,aAAA;MACdE,QAAQ,GAQRV,KAAK,CARLU,QAAQ;MACRC,WAAW,GAOXX,KAAK,CAPLW,WAAW;MACXC,YAAY,GAMZZ,KAAK,CANLY,YAAY;MAAAC,eAAA,GAMZb,KAAK,CALLc,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,eAAA;MACfE,aAAa,GAIbf,KAAK,CAJLe,aAAa;MACbC,SAAS,GAGThB,KAAK,CAHLgB,SAAS;MACTC,QAAQ,GAERjB,KAAK,CAFLiB,QAAQ;AACLC,MAAAA,IAAI,GAAAC,wBAAA,CACPnB,K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sRoot(Root) {
|
|
119
119
|
if (nextIndex !== index) {
|
120
120
|
var _refs$items$nextIndex, _refs$items$nextIndex2;
|
121
121
|
event.preventDefault();
|
122
|
-
(_refs$items$nextIndex = refs.items[nextIndex].current) === null || _refs$items$nextIndex === void 0
|
123
|
-
(_refs$items$nextIndex2 = refs.items[nextIndex].current) === null || _refs$items$nextIndex2 === void 0
|
122
|
+
(_refs$items$nextIndex = refs.items[nextIndex].current) === null || _refs$items$nextIndex === void 0 ? void 0 : _refs$items$nextIndex.focus();
|
123
|
+
(_refs$items$nextIndex2 = refs.items[nextIndex].current) === null || _refs$items$nextIndex2 === void 0 ? void 0 : _refs$items$nextIndex2.scrollIntoView({
|
124
124
|
block: 'center',
|
125
125
|
inline: 'center',
|
126
126
|
behavior: 'smooth'
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.js","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, useEffect, useRef, KeyboardEvent } from 'react';\nimport type { MutableRefObject } from 'react';\nimport { animatedScrollToX, safeUseId } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabItemRefs, TabsContext } from '../../TabsContext';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './Tabs.styles';\nimport type { TabsProps } from './Tabs.types';\n\nenum Keys {\n end = 35,\n home = 36,\n left = 37,\n right = 39,\n}\n\nexport const tabsRoot = (Root: RootProps<HTMLDivElement, TabsProps>) =>\n forwardRef<HTMLDivElement, TabsProps>((props, outerRef) => {\n const { id, stretch = false, disabled = false, size, view, children, pilled, index, ...rest } = props;\n\n const [firstItemVisible, setFirstItemVisible] = useState(true);\n const [lastItemVisible, setLastItemVisible] = useState(true);\n\n const refs = useMemo(() => new TabItemRefs(index), []);\n\n const uniqId = safeUseId();\n const tabsId = id || uniqId;\n\n const isFilled = view === 'filled'; // outer padding is only for filled view\n const pilledAttr = view !== 'clear' && pilled;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.tabsStretch : undefined;\n const hasLeftArrowClass = !firstItemVisible ? classes.tabsHasLeftArrow : undefined;\n const hasRightArrowClass = !lastItemVisible ? classes.tabsHasRightArrow : undefined;\n\n const scrollRef = useRef<HTMLElement | null>(null);\n const trackRef = useRef<HTMLElement | null>(null);\n\n const onPrev = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft - scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const onNext = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft + scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий таб\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n isLeftArrow\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev, disabled, isFilled],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий таб\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext, disabled, isFilled],\n );\n\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLElement>): void => {\n event.stopPropagation();\n const maxScrollLeft = event.currentTarget.scrollWidth - event.currentTarget.clientWidth;\n\n setFirstItemVisible(event.currentTarget.scrollLeft <= 0);\n setLastItemVisible(event.currentTarget.scrollLeft >= maxScrollLeft);\n },\n [setFirstItemVisible, setLastItemVisible],\n );\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (index === undefined) {\n return;\n }\n\n const minIndex = 0;\n const maxIndex = refs.items.length - 1;\n let nextIndex: number;\n\n switch (event.keyCode) {\n case Keys.end:\n nextIndex = maxIndex;\n break;\n case Keys.left:\n nextIndex = index > minIndex ? index - 1 : index;\n break;\n case Keys.right:\n nextIndex = index < maxIndex ? index + 1 : index;\n break;\n case Keys.home:\n nextIndex = minIndex;\n break;\n default:\n return;\n }\n\n if (nextIndex !== index) {\n event.preventDefault();\n refs.items[nextIndex].current?.focus();\n refs.items[nextIndex].current?.scrollIntoView({\n block: 'center',\n inline: 'center',\n behavior: 'smooth',\n });\n }\n },\n [index],\n );\n\n useEffect(() => {\n setLastItemVisible(scrollRef.current?.scrollWidth === scrollRef.current?.clientWidth);\n }, []);\n\n return (\n <TabsContext.Provider value={refs}>\n <Root\n view={view}\n role=\"tablist\"\n size={size}\n pilled={pilled}\n id={tabsId}\n ref={outerRef}\n disabled={disabled}\n className={cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass)}\n onKeyDown={onKeyDown}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper\n ref={scrollRef as MutableRefObject<HTMLDivElement | null>}\n onScroll={handleScroll}\n >\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>\n {children}\n </StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n </TabsContext.Provider>\n );\n });\n\nexport const tabsConfig = {\n name: 'Tabs',\n tag: 'div',\n layout: tabsRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["Keys","tabsRoot","Root","forwardRef","props","outerRef","id","_props$stretch","stretch","_props$disabled","disabled","size","view","children","pilled","index","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","firstItemVisible","setFirstItemVisible","_useState3","_useState4","lastItemVisible","setLastItemVisible","refs","useMemo","TabItemRefs","uniqId","safeUseId","tabsId","isFilled","pilledAttr","pilledClass","classes","tabsPilled","undefined","stretchClass","tabsStretch","hasLeftArrowClass","tabsHasLeftArrow","hasRightArrowClass","tabsHasRightArrow","scrollRef","useRef","trackRef","onPrev","useCallback","current","animatedScrollToX","scrollLeft","offsetWidth","onNext","PreviousButton","React","createElement","StyledArrow","type","onClick","tabIndex","isLeftArrow","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","handleScroll","event","stopPropagation","maxScrollLeft","currentTarget","scrollWidth","clientWidth","onKeyDown","minIndex","maxIndex","items","length","nextIndex","keyCode","end","left","right","home","_refs$items$nextIndex","_refs$items$nextIndex2","preventDefault","focus","scrollIntoView","block","inline","behavior","useEffect","_scrollRef$current","_scrollRef$current2","TabsContext","Provider","value","_extends","role","ref","className","cx","StyledContentWrapper","onScroll","StyledContent","tabsConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","stretchCSS","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;AAeuF,IAGlFA,IAAI,0BAAJA,IAAI,EAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,KAAA,CAAA,GAAA,EAAA,CAAA,GAAA,KAAA,CAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,MAAA,CAAA,GAAA,EAAA,CAAA,GAAA,MAAA,CAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,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tBC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElH,QAAQ;AAChBmH,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACR1G,IAAAA,IAAI,EAAE;AACF2G,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACD3G,IAAAA,IAAI,EAAE;AACF0G,MAAAA,GAAG,EAAEE,MAAAA;KACR;AACD9G,IAAAA,QAAQ,EAAE;AACN4G,MAAAA,GAAG,EAAEG,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDlH,IAAAA,OAAO,EAAE;AACL8G,MAAAA,GAAG,EAAEK,MAAU;AACfD,MAAAA,KAAK,EAAE,IAAA;KACV;AACD5G,IAAAA,MAAM,EAAE;AACJwG,MAAAA,GAAG,EAAEM,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNjH,IAAAA,IAAI,EAAE,OAAO;AACbD,IAAAA,IAAI,EAAE,IAAA;AACV,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../../../../src/components/Tabs/ui/Tabs/Tabs.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState, useEffect, useRef, KeyboardEvent } from 'react';\nimport type { MutableRefObject } from 'react';\nimport { animatedScrollToX, safeUseId } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../../../engines/types';\nimport { IconDisclosureLeft, IconDisclosureRight } from '../../../_Icon';\nimport { classes, tokens } from '../../tokens';\nimport { cx } from '../../../../utils';\nimport { TabItemRefs, TabsContext } from '../../TabsContext';\n\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { base as pilledCSS } from './variations/_pilled/base';\nimport { base as stretchCSS } from './variations/_stretch/base';\nimport { StyledArrow, StyledContent, StyledContentWrapper, base } from './Tabs.styles';\nimport type { TabsProps } from './Tabs.types';\n\nenum Keys {\n end = 35,\n home = 36,\n left = 37,\n right = 39,\n}\n\nexport const tabsRoot = (Root: RootProps<HTMLDivElement, TabsProps>) =>\n forwardRef<HTMLDivElement, TabsProps>((props, outerRef) => {\n const { id, stretch = false, disabled = false, size, view, children, pilled, index, ...rest } = props;\n\n const [firstItemVisible, setFirstItemVisible] = useState(true);\n const [lastItemVisible, setLastItemVisible] = useState(true);\n\n const refs = useMemo(() => new TabItemRefs(index), []);\n\n const uniqId = safeUseId();\n const tabsId = id || uniqId;\n\n const isFilled = view === 'filled'; // outer padding is only for filled view\n const pilledAttr = view !== 'clear' && pilled;\n const pilledClass = pilledAttr ? classes.tabsPilled : undefined;\n\n const stretchClass = firstItemVisible && lastItemVisible && stretch ? classes.tabsStretch : undefined;\n const hasLeftArrowClass = !firstItemVisible ? classes.tabsHasLeftArrow : undefined;\n const hasRightArrowClass = !lastItemVisible ? classes.tabsHasRightArrow : undefined;\n\n const scrollRef = useRef<HTMLElement | null>(null);\n const trackRef = useRef<HTMLElement | null>(null);\n\n const onPrev = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft - scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const onNext = useCallback(() => {\n !disabled &&\n scrollRef.current &&\n animatedScrollToX(scrollRef.current, scrollRef.current.scrollLeft + scrollRef.current.offsetWidth / 2);\n }, [disabled, scrollRef]);\n\n const PreviousButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Предыдущий таб\"\n onClick={onPrev}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n isLeftArrow\n >\n <IconDisclosureLeft color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onPrev, disabled, isFilled],\n );\n\n const NextButton = useMemo(\n () => (\n <StyledArrow\n type=\"button\"\n aria-label=\"Следующий таб\"\n onClick={onNext}\n tabIndex={disabled ? -1 : 0}\n disabled={disabled}\n isFilled={isFilled}\n >\n <IconDisclosureRight color={`var(${tokens.arrowColor})`} />\n </StyledArrow>\n ),\n [onNext, disabled, isFilled],\n );\n\n const handleScroll = useCallback(\n (event: React.UIEvent<HTMLElement>): void => {\n event.stopPropagation();\n const maxScrollLeft = event.currentTarget.scrollWidth - event.currentTarget.clientWidth;\n\n setFirstItemVisible(event.currentTarget.scrollLeft <= 0);\n setLastItemVisible(event.currentTarget.scrollLeft >= maxScrollLeft);\n },\n [setFirstItemVisible, setLastItemVisible],\n );\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (index === undefined) {\n return;\n }\n\n const minIndex = 0;\n const maxIndex = refs.items.length - 1;\n let nextIndex: number;\n\n switch (event.keyCode) {\n case Keys.end:\n nextIndex = maxIndex;\n break;\n case Keys.left:\n nextIndex = index > minIndex ? index - 1 : index;\n break;\n case Keys.right:\n nextIndex = index < maxIndex ? index + 1 : index;\n break;\n case Keys.home:\n nextIndex = minIndex;\n break;\n default:\n return;\n }\n\n if (nextIndex !== index) {\n event.preventDefault();\n refs.items[nextIndex].current?.focus();\n refs.items[nextIndex].current?.scrollIntoView({\n block: 'center',\n inline: 'center',\n behavior: 'smooth',\n });\n }\n },\n [index],\n );\n\n useEffect(() => {\n setLastItemVisible(scrollRef.current?.scrollWidth === scrollRef.current?.clientWidth);\n }, []);\n\n return (\n <TabsContext.Provider value={refs}>\n <Root\n view={view}\n role=\"tablist\"\n size={size}\n pilled={pilled}\n id={tabsId}\n ref={outerRef}\n disabled={disabled}\n className={cx(pilledClass, stretchClass, hasLeftArrowClass, hasRightArrowClass)}\n onKeyDown={onKeyDown}\n {...rest}\n >\n {!firstItemVisible && PreviousButton}\n <StyledContentWrapper\n ref={scrollRef as MutableRefObject<HTMLDivElement | null>}\n onScroll={handleScroll}\n >\n <StyledContent ref={trackRef as MutableRefObject<HTMLDivElement | null>}>\n {children}\n </StyledContent>\n </StyledContentWrapper>\n {!lastItemVisible && NextButton}\n </Root>\n </TabsContext.Provider>\n );\n });\n\nexport const tabsConfig = {\n name: 'Tabs',\n tag: 'div',\n layout: tabsRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n stretch: {\n css: stretchCSS,\n attrs: true,\n },\n pilled: {\n css: pilledCSS,\n },\n },\n defaults: {\n view: 'clear',\n size: 'xs',\n },\n};\n"],"names":["Keys","tabsRoot","Root","forwardRef","props","outerRef","id","_props$stretch","stretch","_props$disabled","disabled","size","view","children","pilled","index","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","firstItemVisible","setFirstItemVisible","_useState3","_useState4","lastItemVisible","setLastItemVisible","refs","useMemo","TabItemRefs","uniqId","safeUseId","tabsId","isFilled","pilledAttr","pilledClass","classes","tabsPilled","undefined","stretchClass","tabsStretch","hasLeftArrowClass","tabsHasLeftArrow","hasRightArrowClass","tabsHasRightArrow","scrollRef","useRef","trackRef","onPrev","useCallback","current","animatedScrollToX","scrollLeft","offsetWidth","onNext","PreviousButton","React","createElement","StyledArrow","type","onClick","tabIndex","isLeftArrow","IconDisclosureLeft","color","concat","tokens","arrowColor","NextButton","IconDisclosureRight","handleScroll","event","stopPropagation","maxScrollLeft","currentTarget","scrollWidth","clientWidth","onKeyDown","minIndex","maxIndex","items","length","nextIndex","keyCode","end","left","right","home","_refs$items$nextIndex","_refs$items$nextIndex2","preventDefault","focus","scrollIntoView","block","inline","behavior","useEffect","_scrollRef$current","_scrollRef$current2","TabsContext","Provider","value","_extends","role","ref","className","cx","StyledContentWrapper","onScroll","StyledContent","tabsConfig","name","tag","layout","base","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","stretchCSS","pilledCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;AAeuF,IAGlFA,IAAI,0BAAJA,IAAI,EAAA;AAAJA,EAAAA,IAAI,CAAJA,IAAI,CAAA,KAAA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,CAACoD,aAAa,EAAA;AAACL,MAAAA,GAAG,EAAEzD,QAAAA;KACfpC,EAAAA,QACU,CACG,CAAC,EACtB,CAACc,eAAe,IAAI2C,UACnB,CACY,CAAC,CAAA;AAE/B,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAM0C,UAAU,GAAG;AACtBC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElH,QAAQ;AAChBmH,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACR1G,IAAAA,IAAI,EAAE;AACF2G,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACD3G,IAAAA,IAAI,EAAE;AACF0G,MAAAA,GAAG,EAAEE,MAAAA;KACR;AACD9G,IAAAA,QAAQ,EAAE;AACN4G,MAAAA,GAAG,EAAEG,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACDlH,IAAAA,OAAO,EAAE;AACL8G,MAAAA,GAAG,EAAEK,MAAU;AACfD,MAAAA,KAAK,EAAE,IAAA;KACV;AACD5G,IAAAA,MAAM,EAAE;AACJwG,MAAAA,GAAG,EAAEM,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNjH,IAAAA,IAAI,EAAE,OAAO;AACbD,IAAAA,IAAI,EAAE,IAAA;AACV,GAAA;AACJ;;;;"}
|
@@ -120,7 +120,7 @@ var textAreaRoot = function textAreaRoot(Root) {
|
|
120
120
|
if (value === undefined) {
|
121
121
|
setUncontrolledValue(event === null || event === void 0 ? void 0 : event.target.value);
|
122
122
|
}
|
123
|
-
onChange === null || onChange === void 0
|
123
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
124
124
|
}, [value, onChange]);
|
125
125
|
var dynamicLabelClasses = getDynamicLabelClasses({
|
126
126
|
readOnly: readOnly,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextArea.js","sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import React, { forwardRef, useState, createRef, useCallback } from 'react';\nimport { css } from '@linaria/core';\nimport { useResizeObserver } from '@salutejs/plasma-core';\n\nimport { cx } from '../../utils';\nimport type { RootProps } from '../../engines/types';\n\nimport { applyDynamicLabel } from './mixins';\nimport { useAutoResize, ROOT_FONT_SIZE } from './hooks';\nimport {\n StyledContent,\n StyledHelpers,\n StyledLeftHelper,\n StyledRightHelper,\n StyledLabel,\n StyledPlaceholder,\n StyledTextArea,\n StyledTextAreaWrapper,\n StyledContainer,\n} from './TextArea.styles';\nimport { classes } from './TextArea.tokens';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport type { TextAreaProps } from './TextArea.types';\n\nconst {\n innerPlaceholderUp,\n focusedOuterPlaceholderColor,\n hidePlaceHolder,\n styledContainer,\n styledTextArea,\n styledTextAreaWrapper,\n styledPlaceholder,\n styledHelpers,\n} = classes;\n\nconst base = css`\n ${applyDynamicLabel};\n\n position: relative;\n box-sizing: border-box;\n`;\n\n// TODO: Удалить после отказа от старых библиотек plasma-web / plasma-b2c\nconst fallbackStatusMap = {\n '': 'primary',\n success: 'positive',\n warning: 'warning',\n error: 'negative',\n};\n\n// TODO: Перенести этот метод в файл applyDynamicLabel.ts\nexport const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) => {\n const { readOnly, label, labelPlacement, autoResize, rows, value } = props;\n\n // Добавить класс отвечающий за изменение цвета плейсхолдера при фокусе\n const withFocusedOuterUpPlaceholder =\n !readOnly && focused && (!label || labelPlacement === 'outer') ? focusedOuterPlaceholderColor : undefined;\n\n // Добавить класс отвечающий за поднятие и уменьшение плейсхолдера\n const withInnerPlaceholderUp =\n labelPlacement === 'inner' &&\n label &&\n !autoResize &&\n !rows &&\n ((!readOnly && (value || focused)) || (readOnly && value))\n ? innerPlaceholderUp\n : undefined;\n\n // Добавить класс отвечающий за скрытие плейсхолдера\n const withHidePlaceholder =\n (value && !label) ||\n (labelPlacement === 'inner' && ((focused && !readOnly) || value) && label && (rows || autoResize)) ||\n (labelPlacement === 'outer' && value)\n ? hidePlaceHolder\n : undefined;\n\n return [withFocusedOuterUpPlaceholder, withInnerPlaceholderUp, withHidePlaceholder];\n};\n\nexport const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) =>\n forwardRef<HTMLTextAreaElement, TextAreaProps>((props, innerRef) => {\n const {\n helperText,\n status,\n resize,\n rightHelper,\n leftHelper,\n contentRight,\n autoResize = false,\n minAuto = 0,\n maxAuto,\n label,\n labelPlacement = 'inner',\n placeholder,\n defaultValue,\n height,\n width,\n value,\n disabled,\n size,\n view,\n id,\n style,\n className,\n readOnly,\n rows,\n cols,\n onChange,\n ...rest\n } = props;\n\n const [helperWidth, setHelperWidth] = useState<string>(width ? `${width}rem` : '100%');\n const [focused, setFocused] = useState(false);\n const [uncontrolledValue, setUncontrolledValue] = useState<string | undefined>();\n\n const outerRef = innerRef && 'current' in innerRef ? innerRef : createRef<HTMLTextAreaElement>();\n const hasHelper = Boolean(leftHelper || rightHelper || helperText);\n const overriddenView = status !== undefined ? fallbackStatusMap[status] : view;\n const textareaHelperId = id ? `${id}-helper` : undefined;\n const applyCustomWidth = resize !== 'horizontal' && resize !== 'both' && !cols;\n const placeLabel = labelPlacement === 'inner' && label ? label : placeholder;\n\n useResizeObserver(outerRef, (currentElement) => {\n const { width: inlineWidth, height: inlineHeight } = currentElement.style;\n\n if (inlineWidth || inlineHeight || cols) {\n const { width: elementWidth } = currentElement.getBoundingClientRect();\n setHelperWidth(`${elementWidth / ROOT_FONT_SIZE}rem`);\n }\n });\n\n useAutoResize(autoResize, outerRef, value, minAuto, maxAuto);\n\n const onFocusHandler = useCallback(() => {\n setFocused(true);\n }, []);\n const onBlurHandler = useCallback(() => {\n setFocused(false);\n }, []);\n\n const onChangeHandler = useCallback(\n (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n // INFO: Для крайне редких кейсов, когда value снаружи не контролируется\n if (value === undefined) {\n setUncontrolledValue(event?.target.value);\n }\n\n onChange?.(event);\n },\n [value, onChange],\n );\n\n const dynamicLabelClasses = getDynamicLabelClasses(\n { readOnly, label, labelPlacement, autoResize, rows, value: value || uncontrolledValue || defaultValue },\n focused,\n );\n\n return (\n <Root\n view={overriddenView}\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n style={style}\n className={className}\n >\n {label && labelPlacement === 'outer' && <StyledLabel>{label}</StyledLabel>}\n <StyledContainer\n className={cx(styledContainer, ...dynamicLabelClasses)}\n width={helperWidth}\n onFocus={onFocusHandler}\n onBlur={onBlurHandler}\n >\n {contentRight && <StyledContent>{contentRight}</StyledContent>}\n <StyledTextAreaWrapper className={styledTextAreaWrapper} hasHelper={hasHelper}>\n <StyledTextArea\n className={styledTextArea}\n id={id}\n hasContentRight={Boolean(contentRight)}\n hasHelper={hasHelper}\n applyCustomWidth={applyCustomWidth}\n ref={outerRef}\n disabled={disabled}\n height={autoResize ? minAuto : height}\n width={width}\n placeholder={placeLabel}\n aria-describedby={textareaHelperId}\n value={value}\n readOnly={readOnly}\n rows={rows}\n cols={cols}\n resize={resize}\n defaultValue={defaultValue}\n onChange={onChangeHandler}\n {...rest}\n />\n </StyledTextAreaWrapper>\n {hasHelper && (\n <StyledHelpers className={styledHelpers} id={textareaHelperId}>\n {(leftHelper || helperText) && (\n <StyledLeftHelper>{leftHelper || helperText}</StyledLeftHelper>\n )}\n {rightHelper && <StyledRightHelper>{rightHelper}</StyledRightHelper>}\n </StyledHelpers>\n )}\n {placeLabel && (\n <StyledPlaceholder\n hasContentRight={Boolean(contentRight)}\n className={styledPlaceholder}\n htmlFor={id}\n >\n {placeLabel}\n </StyledPlaceholder>\n )}\n </StyledContainer>\n </Root>\n );\n });\n\nexport const textAreaConfig = {\n name: 'TextArea',\n tag: 'div',\n layout: textAreaRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n readOnly: {\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'primary',\n },\n};\n"],"names":["innerPlaceholderUp","classes","focusedOuterPlaceholderColor","hidePlaceHolder","styledContainer","styledTextArea","styledTextAreaWrapper","styledPlaceholder","styledHelpers","base","fallbackStatusMap","success","warning","error","getDynamicLabelClasses","props","focused","readOnly","label","labelPlacement","autoResize","rows","value","withFocusedOuterUpPlaceholder","undefined","withInnerPlaceholderUp","withHidePlaceholder","textAreaRoot","Root","forwardRef","innerRef","helperText","status","resize","rightHelper","leftHelper","contentRight","_props$autoResize","_props$minAuto","minAuto","maxAuto","_props$labelPlacement","placeholder","defaultValue","height","width","disabled","size","view","id","style","className","cols","onChange","rest","_excluded","_useState","useState","concat","_useState2","_slicedToArray","helperWidth","setHelperWidth","_useState3","_useState4","setFocused","_useState5","_useState6","uncontrolledValue","setUncontrolledValue","outerRef","createRef","hasHelper","Boolean","overriddenView","textareaHelperId","applyCustomWidth","placeLabel","useResizeObserver","currentElement","_currentElement$style","inlineWidth","inlineHeight","_currentElement$getBo","getBoundingClientRect","elementWidth","ROOT_FONT_SIZE","useAutoResize","onFocusHandler","useCallback","onBlurHandler","onChangeHandler","event","target","dynamicLabelClasses","React","createElement","StyledLabel","StyledContainer","cx","apply","_toConsumableArray","onFocus","onBlur","StyledContent","StyledTextAreaWrapper","StyledTextArea","_extends","hasContentRight","ref","StyledHelpers","StyledLeftHelper","StyledRightHelper","StyledPlaceholder","htmlFor","textAreaConfig","name","tag","layout","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;AA0BA,IACIA,kBAAkB,GAQlBC,OAAO,CARPD,kBAAkB;EAClBE,4BAA4B,GAO5BD,OAAO,CAPPC,4BAA4B;EAC5BC,eAAe,GAMfF,OAAO,CANPE,eAAe;EACfC,eAAe,GAKfH,OAAO,CALPG,eAAe;EACfC,cAAc,GAIdJ,OAAO,CAJ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0E,MAAAA,GAAG,EAAEG,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACD3G,IAAAA,QAAQ,EAAE;AACN2G,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN9E,IAAAA,IAAI,EAAE,GAAG;AACTC,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"TextArea.js","sources":["../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import React, { forwardRef, useState, createRef, useCallback } from 'react';\nimport { css } from '@linaria/core';\nimport { useResizeObserver } from '@salutejs/plasma-core';\n\nimport { cx } from '../../utils';\nimport type { RootProps } from '../../engines/types';\n\nimport { applyDynamicLabel } from './mixins';\nimport { useAutoResize, ROOT_FONT_SIZE } from './hooks';\nimport {\n StyledContent,\n StyledHelpers,\n StyledLeftHelper,\n StyledRightHelper,\n StyledLabel,\n StyledPlaceholder,\n StyledTextArea,\n StyledTextAreaWrapper,\n StyledContainer,\n} from './TextArea.styles';\nimport { classes } from './TextArea.tokens';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport type { TextAreaProps } from './TextArea.types';\n\nconst {\n innerPlaceholderUp,\n focusedOuterPlaceholderColor,\n hidePlaceHolder,\n styledContainer,\n styledTextArea,\n styledTextAreaWrapper,\n styledPlaceholder,\n styledHelpers,\n} = classes;\n\nconst base = css`\n ${applyDynamicLabel};\n\n position: relative;\n box-sizing: border-box;\n`;\n\n// TODO: Удалить после отказа от старых библиотек plasma-web / plasma-b2c\nconst fallbackStatusMap = {\n '': 'primary',\n success: 'positive',\n warning: 'warning',\n error: 'negative',\n};\n\n// TODO: Перенести этот метод в файл applyDynamicLabel.ts\nexport const getDynamicLabelClasses = (props: TextAreaProps, focused: boolean) => {\n const { readOnly, label, labelPlacement, autoResize, rows, value } = props;\n\n // Добавить класс отвечающий за изменение цвета плейсхолдера при фокусе\n const withFocusedOuterUpPlaceholder =\n !readOnly && focused && (!label || labelPlacement === 'outer') ? focusedOuterPlaceholderColor : undefined;\n\n // Добавить класс отвечающий за поднятие и уменьшение плейсхолдера\n const withInnerPlaceholderUp =\n labelPlacement === 'inner' &&\n label &&\n !autoResize &&\n !rows &&\n ((!readOnly && (value || focused)) || (readOnly && value))\n ? innerPlaceholderUp\n : undefined;\n\n // Добавить класс отвечающий за скрытие плейсхолдера\n const withHidePlaceholder =\n (value && !label) ||\n (labelPlacement === 'inner' && ((focused && !readOnly) || value) && label && (rows || autoResize)) ||\n (labelPlacement === 'outer' && value)\n ? hidePlaceHolder\n : undefined;\n\n return [withFocusedOuterUpPlaceholder, withInnerPlaceholderUp, withHidePlaceholder];\n};\n\nexport const textAreaRoot = (Root: RootProps<HTMLTextAreaElement, TextAreaProps>) =>\n forwardRef<HTMLTextAreaElement, TextAreaProps>((props, innerRef) => {\n const {\n helperText,\n status,\n resize,\n rightHelper,\n leftHelper,\n contentRight,\n autoResize = false,\n minAuto = 0,\n maxAuto,\n label,\n labelPlacement = 'inner',\n placeholder,\n defaultValue,\n height,\n width,\n value,\n disabled,\n size,\n view,\n id,\n style,\n className,\n readOnly,\n rows,\n cols,\n onChange,\n ...rest\n } = props;\n\n const [helperWidth, setHelperWidth] = useState<string>(width ? `${width}rem` : '100%');\n const [focused, setFocused] = useState(false);\n const [uncontrolledValue, setUncontrolledValue] = useState<string | undefined>();\n\n const outerRef = innerRef && 'current' in innerRef ? innerRef : createRef<HTMLTextAreaElement>();\n const hasHelper = Boolean(leftHelper || rightHelper || helperText);\n const overriddenView = status !== undefined ? fallbackStatusMap[status] : view;\n const textareaHelperId = id ? `${id}-helper` : undefined;\n const applyCustomWidth = resize !== 'horizontal' && resize !== 'both' && !cols;\n const placeLabel = labelPlacement === 'inner' && label ? label : placeholder;\n\n useResizeObserver(outerRef, (currentElement) => {\n const { width: inlineWidth, height: inlineHeight } = currentElement.style;\n\n if (inlineWidth || inlineHeight || cols) {\n const { width: elementWidth } = currentElement.getBoundingClientRect();\n setHelperWidth(`${elementWidth / ROOT_FONT_SIZE}rem`);\n }\n });\n\n useAutoResize(autoResize, outerRef, value, minAuto, maxAuto);\n\n const onFocusHandler = useCallback(() => {\n setFocused(true);\n }, []);\n const onBlurHandler = useCallback(() => {\n setFocused(false);\n }, []);\n\n const onChangeHandler = useCallback(\n (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n // INFO: Для крайне редких кейсов, когда value снаружи не контролируется\n if (value === undefined) {\n setUncontrolledValue(event?.target.value);\n }\n\n onChange?.(event);\n },\n [value, onChange],\n );\n\n const dynamicLabelClasses = getDynamicLabelClasses(\n { readOnly, label, labelPlacement, autoResize, rows, value: value || uncontrolledValue || defaultValue },\n focused,\n );\n\n return (\n <Root\n view={overriddenView}\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n style={style}\n className={className}\n >\n {label && labelPlacement === 'outer' && <StyledLabel>{label}</StyledLabel>}\n <StyledContainer\n className={cx(styledContainer, ...dynamicLabelClasses)}\n width={helperWidth}\n onFocus={onFocusHandler}\n onBlur={onBlurHandler}\n >\n {contentRight && <StyledContent>{contentRight}</StyledContent>}\n <StyledTextAreaWrapper className={styledTextAreaWrapper} hasHelper={hasHelper}>\n <StyledTextArea\n className={styledTextArea}\n id={id}\n hasContentRight={Boolean(contentRight)}\n hasHelper={hasHelper}\n applyCustomWidth={applyCustomWidth}\n ref={outerRef}\n disabled={disabled}\n height={autoResize ? minAuto : height}\n width={width}\n placeholder={placeLabel}\n aria-describedby={textareaHelperId}\n value={value}\n readOnly={readOnly}\n rows={rows}\n cols={cols}\n resize={resize}\n defaultValue={defaultValue}\n onChange={onChangeHandler}\n {...rest}\n />\n </StyledTextAreaWrapper>\n {hasHelper && (\n <StyledHelpers className={styledHelpers} id={textareaHelperId}>\n {(leftHelper || helperText) && (\n <StyledLeftHelper>{leftHelper || helperText}</StyledLeftHelper>\n )}\n {rightHelper && <StyledRightHelper>{rightHelper}</StyledRightHelper>}\n </StyledHelpers>\n )}\n {placeLabel && (\n <StyledPlaceholder\n hasContentRight={Boolean(contentRight)}\n className={styledPlaceholder}\n htmlFor={id}\n >\n {placeLabel}\n </StyledPlaceholder>\n )}\n </StyledContainer>\n </Root>\n );\n });\n\nexport const textAreaConfig = {\n name: 'TextArea',\n tag: 'div',\n layout: textAreaRoot,\n base,\n variations: {\n size: {\n css: sizeCSS,\n },\n view: {\n css: viewCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n readOnly: {\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'primary',\n },\n};\n"],"names":["innerPlaceholderUp","classes","focusedOuterPlaceholderColor","hidePlaceHolder","styledContainer","styledTextArea","styledTextAreaWrapper","styledPlaceholder","styledHelpers","base","fallbackStatusMap","success","warning","error","getDynamicLabelClasses","props","focused","readOnly","label","labelPlacement","autoResize","rows","value","withFocusedOuterUpPlaceholder","undefined","withInnerPlaceholderUp","withHidePlaceholder","textAreaRoot","Root","forwardRef","innerRef","helperText","status","resize","rightHelper","leftHelper","contentRight","_props$autoResize","_props$minAuto","minAuto","maxAuto","_props$labelPlacement","placeholder","defaultValue","height","width","disabled","size","view","id","style","className","cols","onChange","rest","_excluded","_useState","useState","concat","_useState2","_slicedToArray","helperWidth","setHelperWidth","_useState3","_useState4","setFocused","_useState5","_useState6","uncontrolledValue","setUncontrolledValue","outerRef","createRef","hasHelper","Boolean","overriddenView","textareaHelperId","applyCustomWidth","placeLabel","useResizeObserver","currentElement","_currentElement$style","inlineWidth","inlineHeight","_currentElement$getBo","getBoundingClientRect","elementWidth","ROOT_FONT_SIZE","useAutoResize","onFocusHandler","useCallback","onBlurHandler","onChangeHandler","event","target","dynamicLabelClasses","React","createElement","StyledLabel","StyledContainer","cx","apply","_toConsumableArray","onFocus","onBlur","StyledContent","StyledTextAreaWrapper","StyledTextArea","_extends","hasContentRight","ref","StyledHelpers","StyledLeftHelper","StyledRightHelper","StyledPlaceholder","htmlFor","textAreaConfig","name","tag","layout","variations","css","sizeCSS","viewCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;AA0BA,IACIA,kBAAkB,GAQlBC,OAAO,CARPD,kBAAkB;EAClBE,4BAA4B,GAO5BD,OAAO,CAPPC,4BAA4B;EAC5BC,eAAe,GAMfF,OAAO,CANPE,eAAe;EACfC,eAAe,GAKfH,OAAO,CALPG,eAAe;EACfC,cAAc,GAIdJ,OAAO,CAJPI,cAAc;EACdC,qBAAqB,GAGrBL,OAAO,CAHPK,qBAAqB;EACrBC,iBAAiB,GAEjBN,OAAO,CAFPM,iBAAiB;EACjBC,aAAAA,GACAP,OAAO,CADPO,aAAAA,CAAAA;AAGJ,IAAMC,IAAI,GAKT,SAAA,CAAA;;AAED;AACA,IAAMC,iBAAiB,GAAG;AACtB,EAAA,EAAE,EAAE,SAAS;AACbC,EAAAA,OAAO,EAAE,UAAU;AACnBC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,KAAK,EAAE,UAAA;AACX,CAAC,CAAA;;AAED;AACO,IAAMC,sBAAsB,GAAGA,SAAzBA,sBAAsBA,CAAIC,KAAoB,EAAEC,OAAgB,EAAK;AAC9E,EAAA,IAAQC,QAAQ,GAAqDF,KAAK,CAAlEE,QAAQ;IAAEC,KAAK,GAA8CH,KAAK,CAAxDG,KAAK;IAAEC,cAAc,GAA8BJ,KAAK,CAAjDI,cAAc;IAAEC,UAAU,GAAkBL,KAAK,CAAjCK,UAAU;IAAEC,IAAI,GAAYN,KAAK,CAArBM,IAAI;IAAEC,KAAAA,GAAUP,KAAK,CAAfO,KAAAA,CAAAA;;AAE3D;AACA,EAAA,IAAMC,6BAA6B,GAC/B,CAACN,QAAQ,IAAID,OAAO,KAAK,CAACE,KAAK,IAAIC,cAAc,KAAK,OAAO,CAAC,GAAGjB,4BAA4B,GAAGsB,SAAS,CAAA;;AAE7G;AACA,EAAA,IAAMC,sBAAsB,GACxBN,cAAc,KAA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1BC,EAAAA,IAAI,EAAE,UAAU;AAChBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE3F,YAAY;AACpBlB,EAAAA,IAAI,EAAJA,IAAI;AACJ8G,EAAAA,UAAU,EAAE;AACRxE,IAAAA,IAAI,EAAE;AACFyE,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACDzE,IAAAA,IAAI,EAAE;AACFwE,MAAAA,GAAG,EAAEE,MAAAA;KACR;AACD5E,IAAAA,QAAQ,EAAE;AACN0E,MAAAA,GAAG,EAAEG,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;KACV;AACD3G,IAAAA,QAAQ,EAAE;AACN2G,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN9E,IAAAA,IAAI,EAAE,GAAG;AACTC,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;"}
|
@@ -73,11 +73,11 @@ var textFieldRoot = function textFieldRoot(Root) {
|
|
73
73
|
if (maxLength !== -1 && value.length > maxLength) {
|
74
74
|
return;
|
75
75
|
}
|
76
|
-
onChange === null || onChange === void 0
|
76
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
77
77
|
};
|
78
78
|
var updateChips = function updateChips(newChips, newValues) {
|
79
79
|
setChips(newChips);
|
80
|
-
onChangeChips === null || onChangeChips === void 0
|
80
|
+
onChangeChips === null || onChangeChips === void 0 ? void 0 : onChangeChips(newValues);
|
81
81
|
};
|
82
82
|
var _useKeyNavigation = useKeyNavigation({
|
83
83
|
controlledRefs: controlledRefs,
|