@salutejs/plasma-new-hope 0.76.2-canary.1184.8705168480.0 → 0.76.3-canary.1178.8720542914.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 +11 -11
- 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
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useKeyNavigation.js","sources":["../../../../src/components/TextField/hooks/useKeyNavigation.ts"],"sourcesContent":["import { useState } from 'react';\nimport type { ChangeEvent, KeyboardEvent } from 'react';\n\nimport type { UseKeyNavigationProps } from '../TextField.types';\n\nexport const Keys = {\n Enter: 'Enter',\n Tab: 'Tab',\n Escape: 'Escape',\n ArrowLeft: 'ArrowLeft',\n ArrowRight: 'ArrowRight',\n Backspace: 'Backspace',\n};\n\nexport const useKeyNavigation = ({\n controlledRefs: { chipsRefs, contentRef, inputRef },\n disabled,\n readOnly,\n chips,\n enumerationType,\n updateChips,\n onChange,\n onSearch,\n}: UseKeyNavigationProps) => {\n const [activeChipIndex, setActiveChipIndex] = useState(-1);\n\n const handleInputKeydown = (event: ChangeEvent<HTMLInputElement> & KeyboardEvent<HTMLInputElement>) => {\n const { value } = event.target as HTMLInputElement;\n\n if (disabled || readOnly) {\n return;\n }\n\n if (event.key === Keys.Enter && enumerationType === 'chip' && value) {\n const nextIndex = chips?.length || 0;\n\n const newChips = [...chips, { id: `${nextIndex}_${value}`, text: value }];\n const newValues = newChips.map(({ text }) => text);\n\n updateChips(newChips, newValues);\n event.target.value = '';\n onChange?.(event);\n }\n\n if (event.key === Keys.Enter && onSearch) {\n onSearch(value, event);\n }\n\n if (event.key === Keys.Backspace && chips.length && inputRef?.current?.selectionStart === 0) {\n const newChips = [...chips];\n newChips?.pop();\n chipsRefs?.current.pop();\n\n const newValues = newChips.map(({ text }) => text);\n\n updateChips(newChips, newValues);\n }\n };\n\n const onChipClear = (clearId: string, index: number) => {\n if (!chips.length) {\n return;\n }\n\n const newChips = chips?.filter(({ id: chipId }) => chipId !== clearId) || [];\n const newValues = newChips.map(({ text }) => text);\n chipsRefs?.current.splice(index, 1);\n\n updateChips(newChips, newValues);\n };\n\n const handleChipKeyDown = (event: KeyboardEvent<HTMLButtonElement>, chipId: string, chipIndex: number) => {\n if (event.key === Keys.Tab) {\n event.preventDefault();\n }\n\n if (event.key === Keys.Backspace) {\n onChipClear(chipId, chipIndex);\n }\n };\n\n const handleContentKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const chipsRefsCount = chipsRefs.current.length;\n const currentCaretPosition = inputRef?.current?.selectionStart || 0;\n\n let newActiveChipIndex = activeChipIndex;\n let focusedItem: HTMLButtonElement | HTMLInputElement | null = null;\n\n if (event.key === Keys.ArrowLeft && enumerationType === 'chip' && currentCaretPosition <= 0) {\n const index = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;\n\n newActiveChipIndex = document.activeElement === inputRef?.current ? chipsRefsCount - 1 : index;\n\n focusedItem = chipsRefs.current?.[newActiveChipIndex];\n }\n\n if (\n event.key === Keys.ArrowRight &&\n enumerationType === 'chip' &&\n document.activeElement !== inputRef?.current\n ) {\n const index = activeChipIndex + 1 >= chipsRefsCount ? activeChipIndex : activeChipIndex + 1;\n\n newActiveChipIndex = document.activeElement === contentRef?.current ? 0 : index;\n focusedItem =\n index === activeChipIndex\n ? (inputRef?.current as HTMLInputElement)\n : chipsRefs.current?.[newActiveChipIndex];\n }\n\n if (event.key === Keys.Backspace && document.activeElement !== inputRef?.current) {\n const index = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;\n\n newActiveChipIndex = chipsRefsCount === 0 ? -1 : index;\n focusedItem =\n chipsRefsCount === 0\n ? (inputRef?.current as HTMLInputElement)\n : chipsRefs?.current?.[newActiveChipIndex];\n }\n\n focusedItem?.focus();\n focusedItem?.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center',\n });\n\n setActiveChipIndex(newActiveChipIndex);\n };\n\n return { handleInputKeydown, handleChipKeyDown, onChipClear, handleContentKeyDown } as const;\n};\n"],"names":["Keys","Enter","Tab","Escape","ArrowLeft","ArrowRight","Backspace","useKeyNavigation","_ref","_ref$controlledRefs","controlledRefs","chipsRefs","contentRef","inputRef","disabled","readOnly","chips","enumerationType","updateChips","onChange","onSearch","_useState","useState","_useState2","_slicedToArray","activeChipIndex","setActiveChipIndex","handleInputKeydown","event","_inputRef$current","_ref2","target","value","key","nextIndex","length","newChips","concat","_toConsumableArray","id","text","newValues","map","_ref3","current","selectionStart","pop","_ref4","onChipClear","clearId","index","filter","_ref5","chipId","_ref6","splice","handleChipKeyDown","chipIndex","preventDefault","handleContentKeyDown","_inputRef$current2","_focusedItem","_focusedItem2","chipsRefsCount","currentCaretPosition","newActiveChipIndex","focusedItem","_chipsRefs$current","document","activ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AAJ,YAAA,GAAAK,WAAW,MAAAL,IAAAA,IAAAA,YAAA,eAAXA,YAAA,CAAaW,KAAK,EAAE,CAAA;IACpB,CAAAV,aAAA,GAAAI,WAAW,MAAA,IAAA,IAAAJ,aAAA,KAAXA,KAAAA,CAAAA,IAAAA,aAAA,CAAaW,cAAc,CAAC;AACxBC,MAAAA,QAAQ,EAAE,QAAQ;AAClBC,MAAAA,KAAK,EAAE,QAAQ;AACfC,MAAAA,MAAM,EAAE,QAAA;AACZ,KAAC,CAAC,CAAA;IAEFlD,kBAAkB,CAACuC,kBAAkB,CAAC,CAAA;GACzC,CAAA;EAED,OAAO;AAAEtC,IAAAA,kBAAkB,EAAlBA,kBAAkB;AAAE6B,IAAAA,iBAAiB,EAAjBA,iBAAiB;AAAER,IAAAA,WAAW,EAAXA,WAAW;AAAEW,IAAAA,oBAAoB,EAApBA,oBAAAA;GAAsB,CAAA;AACvF;;;;;"}
|
1
|
+
{"version":3,"file":"useKeyNavigation.js","sources":["../../../../src/components/TextField/hooks/useKeyNavigation.ts"],"sourcesContent":["import { useState } from 'react';\nimport type { ChangeEvent, KeyboardEvent } from 'react';\n\nimport type { UseKeyNavigationProps } from '../TextField.types';\n\nexport const Keys = {\n Enter: 'Enter',\n Tab: 'Tab',\n Escape: 'Escape',\n ArrowLeft: 'ArrowLeft',\n ArrowRight: 'ArrowRight',\n Backspace: 'Backspace',\n};\n\nexport const useKeyNavigation = ({\n controlledRefs: { chipsRefs, contentRef, inputRef },\n disabled,\n readOnly,\n chips,\n enumerationType,\n updateChips,\n onChange,\n onSearch,\n}: UseKeyNavigationProps) => {\n const [activeChipIndex, setActiveChipIndex] = useState(-1);\n\n const handleInputKeydown = (event: ChangeEvent<HTMLInputElement> & KeyboardEvent<HTMLInputElement>) => {\n const { value } = event.target as HTMLInputElement;\n\n if (disabled || readOnly) {\n return;\n }\n\n if (event.key === Keys.Enter && enumerationType === 'chip' && value) {\n const nextIndex = chips?.length || 0;\n\n const newChips = [...chips, { id: `${nextIndex}_${value}`, text: value }];\n const newValues = newChips.map(({ text }) => text);\n\n updateChips(newChips, newValues);\n event.target.value = '';\n onChange?.(event);\n }\n\n if (event.key === Keys.Enter && onSearch) {\n onSearch(value, event);\n }\n\n if (event.key === Keys.Backspace && chips.length && inputRef?.current?.selectionStart === 0) {\n const newChips = [...chips];\n newChips?.pop();\n chipsRefs?.current.pop();\n\n const newValues = newChips.map(({ text }) => text);\n\n updateChips(newChips, newValues);\n }\n };\n\n const onChipClear = (clearId: string, index: number) => {\n if (!chips.length) {\n return;\n }\n\n const newChips = chips?.filter(({ id: chipId }) => chipId !== clearId) || [];\n const newValues = newChips.map(({ text }) => text);\n chipsRefs?.current.splice(index, 1);\n\n updateChips(newChips, newValues);\n };\n\n const handleChipKeyDown = (event: KeyboardEvent<HTMLButtonElement>, chipId: string, chipIndex: number) => {\n if (event.key === Keys.Tab) {\n event.preventDefault();\n }\n\n if (event.key === Keys.Backspace) {\n onChipClear(chipId, chipIndex);\n }\n };\n\n const handleContentKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const chipsRefsCount = chipsRefs.current.length;\n const currentCaretPosition = inputRef?.current?.selectionStart || 0;\n\n let newActiveChipIndex = activeChipIndex;\n let focusedItem: HTMLButtonElement | HTMLInputElement | null = null;\n\n if (event.key === Keys.ArrowLeft && enumerationType === 'chip' && currentCaretPosition <= 0) {\n const index = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;\n\n newActiveChipIndex = document.activeElement === inputRef?.current ? chipsRefsCount - 1 : index;\n\n focusedItem = chipsRefs.current?.[newActiveChipIndex];\n }\n\n if (\n event.key === Keys.ArrowRight &&\n enumerationType === 'chip' &&\n document.activeElement !== inputRef?.current\n ) {\n const index = activeChipIndex + 1 >= chipsRefsCount ? activeChipIndex : activeChipIndex + 1;\n\n newActiveChipIndex = document.activeElement === contentRef?.current ? 0 : index;\n focusedItem =\n index === activeChipIndex\n ? (inputRef?.current as HTMLInputElement)\n : chipsRefs.current?.[newActiveChipIndex];\n }\n\n if (event.key === Keys.Backspace && document.activeElement !== inputRef?.current) {\n const index = activeChipIndex - 1 <= 0 ? 0 : activeChipIndex - 1;\n\n newActiveChipIndex = chipsRefsCount === 0 ? -1 : index;\n focusedItem =\n chipsRefsCount === 0\n ? (inputRef?.current as HTMLInputElement)\n : chipsRefs?.current?.[newActiveChipIndex];\n }\n\n focusedItem?.focus();\n focusedItem?.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center',\n });\n\n setActiveChipIndex(newActiveChipIndex);\n };\n\n return { handleInputKeydown, handleChipKeyDown, onChipClear, handleContentKeyDown } as const;\n};\n"],"names":["Keys","Enter","Tab","Escape","ArrowLeft","ArrowRight","Backspace","useKeyNavigation","_ref","_ref$controlledRefs","controlledRefs","chipsRefs","contentRef","inputRef","disabled","readOnly","chips","enumerationType","updateChips","onChange","onSearch","_useState","useState","_useState2","_slicedToArray","activeChipIndex","setActiveChipIndex","handleInputKeydown","event","_inputRef$current","_ref2","target","value","key","nextIndex","length","newChips","concat","_toConsumableArray","id","text","newValues","map","_ref3","current","selectionStart","pop","_ref4","onChipClear","clearId","index","filter","_ref5","chipId","_ref6","splice","handleChipKeyDown","chipIndex","preventDefault","handleContentKeyDown","_inputRef$current2","_focusedItem","_focusedItem2","chipsRefsCount","currentCaretPosition","newActiveChipIndex","focusedItem","_chipsRefs$current","document","activeElement","_chipsRefs$current2","_chipsRefs$current3","focus","scrollIntoView","behavior","block","inline"],"mappings":";;;;;;;AAKO,IAAMA,IAAI,GAAG;AAChBC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,SAAS,EAAE,WAAW;AACtBC,EAAAA,UAAU,EAAE,YAAY;AACxBC,EAAAA,SAAS,EAAE,WAAA;AACf,EAAC;IAEYC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAAC,IAAA,EASA;AAAA,EAAA,IAAA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AAQ;AAClBC,MAAAA,KAAK,EAAE,QAAQ;AACfC,MAAAA,MAAM,EAAE,QAAA;AACZ,KAAC,CAAC,CAAA;IAEFlD,kBAAkB,CAACuC,kBAAkB,CAAC,CAAA;GACzC,CAAA;EAED,OAAO;AAAEtC,IAAAA,kBAAkB,EAAlBA,kBAAkB;AAAE6B,IAAAA,iBAAiB,EAAjBA,iBAAiB;AAAER,IAAAA,WAAW,EAAXA,WAAW;AAAEW,IAAAA,oBAAoB,EAApBA,oBAAAA;GAAsB,CAAA;AACvF;;;;;"}
|
@@ -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;}
|
@@ -20,7 +20,7 @@ var TextFieldChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
20
20
|
return onClear(id);
|
21
21
|
};
|
22
22
|
var onKeyDownHandle = function onKeyDownHandle(event) {
|
23
|
-
onKeyDown === null || onKeyDown === void 0
|
23
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event, id);
|
24
24
|
};
|
25
25
|
return /*#__PURE__*/React.createElement(TextFieldChip_styles.StyledChip, {
|
26
26
|
ref: ref,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TextFieldChip.js","sources":["../../../../../src/components/TextField/ui/TextFieldChip/TextFieldChip.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { StyledChip } from './TextFieldChip.styles';\nimport type { TextFieldChipProps } from './TextFieldChip.types';\n\n/**\n * Чип, отображающий выбранный элемент\n */\nexport const TextFieldChip = forwardRef<HTMLButtonElement, TextFieldChipProps>(\n ({ id, text, disabled, readOnly, onClick, onClear, onKeyDown }, ref) => {\n const onClearHandle = () => onClear(id);\n\n const onKeyDownHandle = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event, id);\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":["TextFieldChip","forwardRef","_ref","ref","id","text","disabled","readOnly","onClick","onClear","onKeyDown","onClearHandle","onKeyDownHandle","event","React","createElement","StyledChip","tabIndex","concat"],"mappings":";;;;;;;AAKA;AACA;AACA;AACO,IAAMA,aAAa,gBAAGC,gBAAU,CACnC,UAAAC,IAAA,EAAgEC,GAAG,EAAK;AAAA,EAAA,IAArEC,EAAE,GAAAF,IAAA,CAAFE,EAAE;IAAEC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IAAEC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,OAAO,GAAAN,IAAA,CAAPM,OAAO;IAAEC,OAAO,GAAAP,IAAA,CAAPO,OAAO;IAAEC,SAAS,GAAAR,IAAA,CAATQ,SAAS,CAAA;AACxD,EAAA,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,GAAA;IAAA,OAASF,OAAO,CAACL,EAAE,CAAC,CAAA;AAAA,GAAA,CAAA;AAEvC,EAAA,IAAMQ,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,KAA6C,EAAK;IACvEH,SAAS,KAAA,IAAA,IAATA,SAAS,KAATA,KAAAA,CAAAA,
|
1
|
+
{"version":3,"file":"TextFieldChip.js","sources":["../../../../../src/components/TextField/ui/TextFieldChip/TextFieldChip.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { StyledChip } from './TextFieldChip.styles';\nimport type { TextFieldChipProps } from './TextFieldChip.types';\n\n/**\n * Чип, отображающий выбранный элемент\n */\nexport const TextFieldChip = forwardRef<HTMLButtonElement, TextFieldChipProps>(\n ({ id, text, disabled, readOnly, onClick, onClear, onKeyDown }, ref) => {\n const onClearHandle = () => onClear(id);\n\n const onKeyDownHandle = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event, id);\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":["TextFieldChip","forwardRef","_ref","ref","id","text","disabled","readOnly","onClick","onClear","onKeyDown","onClearHandle","onKeyDownHandle","event","React","createElement","StyledChip","tabIndex","concat"],"mappings":";;;;;;;AAKA;AACA;AACA;AACO,IAAMA,aAAa,gBAAGC,gBAAU,CACnC,UAAAC,IAAA,EAAgEC,GAAG,EAAK;AAAA,EAAA,IAArEC,EAAE,GAAAF,IAAA,CAAFE,EAAE;IAAEC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IAAEC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,OAAO,GAAAN,IAAA,CAAPM,OAAO;IAAEC,OAAO,GAAAP,IAAA,CAAPO,OAAO;IAAEC,SAAS,GAAAR,IAAA,CAATQ,SAAS,CAAA;AACxD,EAAA,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,GAAA;IAAA,OAASF,OAAO,CAACL,EAAE,CAAC,CAAA;AAAA,GAAA,CAAA;AAEvC,EAAA,IAAMQ,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,KAA6C,EAAK;IACvEH,SAAS,KAAA,IAAA,IAATA,SAAS,KAATA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,SAAS,CAAGG,KAAK,EAAET,EAAE,CAAC,CAAA;GACzB,CAAA;AAED,EAAA,oBACIU,KAAA,CAAAC,aAAA,CAACC,+BAAU,EAAA;AACPb,IAAAA,GAAG,EAAEA,GAAI;IACTc,QAAQ,EAAE,CAAC,CAAE;AACbX,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,OAAO,EAAEA,OAAQ;AACjBC,IAAAA,OAAO,EAAEE,aAAc;AACvBD,IAAAA,SAAS,EAAEE,eAAgB;IAC3BP,IAAI,EAAA,EAAA,CAAAa,MAAA,CAAKb,IAAI,CAAA;AAAG,GACnB,CAAC,CAAA;AAEV,CACJ;;;;"}
|
@@ -138,7 +138,7 @@ var ToastProviderHoc = function ToastProviderHoc(ToastComponent) {
|
|
138
138
|
});
|
139
139
|
setIsHidden(false);
|
140
140
|
setIsVisible(true);
|
141
|
-
onShow === null || onShow === void 0
|
141
|
+
onShow === null || onShow === void 0 ? void 0 : onShow();
|
142
142
|
};
|
143
143
|
var showToast = React.useCallback(showToastCallback, []);
|
144
144
|
var onHide = toastInfo.onHide,
|
@@ -151,7 +151,7 @@ var ToastProviderHoc = function ToastProviderHoc(ToastComponent) {
|
|
151
151
|
clearTimeout(hideTimeout.current);
|
152
152
|
hideTimeout.current = null;
|
153
153
|
}
|
154
|
-
onHide === null || onHide === void 0
|
154
|
+
onHide === null || onHide === void 0 ? void 0 : onHide();
|
155
155
|
setIsVisible(false);
|
156
156
|
animationRunTimeout.current = setTimeout(function () {
|
157
157
|
setIsHidden(true);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ToastProvider.js","sources":["../../../../src/components/Toast/ToastProvider/ToastProvider.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport type { ReactNode, FC } from 'react';\n\nimport type { CustomToastProps, ToastControllerProps, ToastProps } from '../Toast.types';\nimport { DEFAULT_FADE, DEFAULT_POSITION, TIMER_DELAY } from '../utils';\n\nimport type { ShowToast, ShowToastArgs, ShowToastCallSignature, ToastContextType } from './ToastProvider.types';\n\nexport const ToastContext = createContext<ToastContextType | null>(null);\n\nexport const useToastInner = () => {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error('useToast must be used within a ToastProvider');\n }\n return context;\n};\n\nexport const useToast = () => {\n const { showToast, hideToast } = useToastInner();\n return { showToast, hideToast };\n};\n\nconst initialToastData = {\n text: undefined,\n offset: undefined,\n position: DEFAULT_POSITION,\n fade: DEFAULT_FADE,\n timeout: undefined,\n contentLeft: undefined,\n role: undefined,\n pilled: undefined,\n hasClose: undefined,\n width: undefined,\n size: 'm',\n view: 'primary',\n} as CustomToastProps;\n\nconst getShowToastCallSignature = (args: ShowToastCallSignature) => {\n if (typeof args[0] === 'object' && 'text' in args[0]) {\n return args[0];\n }\n\n // TODO: issue https://github.com/salute-developers/plasma/issues/333\n const [text, position, timeout, fade, contentLeft, role, offset, pilled, width, hasClose, size, view] = args;\n\n return { text, position, timeout, fade, contentLeft, role, offset, pilled, width, hasClose, size, view };\n};\n\nexport const ToastProviderHoc = <T extends ToastProps>(ToastComponent: FC<T>) =>\n function ToastProvider({ children }: { children: ReactNode }) {\n const [isVisible, setIsVisible] = useState(false);\n const [isHidden, setIsHidden] = useState(true);\n const hideTimeout = useRef<number | null>(null);\n const animationRunTimeout = useRef<number | null>(null);\n\n const [toastProps, setToastProps] = useState<ToastControllerProps>(initialToastData);\n const [toastInfo, setToastInfo] = useState<Pick<ShowToastArgs, 'timeout' | 'onHide'>>({\n timeout: undefined,\n onHide: undefined,\n });\n\n const showToastCallback: ShowToast = (...args: ShowToastCallSignature) => {\n if (isVisible) {\n return;\n }\n\n const {\n text,\n offset,\n position = DEFAULT_POSITION,\n fade = DEFAULT_FADE,\n timeout,\n contentLeft,\n role,\n pilled,\n hasClose,\n size,\n view,\n width,\n onHide,\n onShow,\n } = getShowToastCallSignature(args);\n\n setToastProps({\n text,\n width,\n position,\n offset,\n fade,\n contentLeft,\n role,\n pilled,\n hasClose,\n size,\n view,\n });\n\n setToastInfo({ timeout, onHide });\n\n setIsHidden(false);\n setIsVisible(true);\n onShow?.();\n };\n\n const showToast = useCallback(showToastCallback, []);\n\n const { onHide, timeout } = toastInfo;\n\n const hideToast = useCallback(() => {\n if (!isVisible) {\n return;\n }\n\n if (hideTimeout?.current) {\n clearTimeout(hideTimeout.current);\n hideTimeout.current = null;\n }\n\n onHide?.();\n setIsVisible(false);\n\n animationRunTimeout.current = setTimeout(() => {\n setIsHidden(true);\n setToastProps(initialToastData);\n }, TIMER_DELAY);\n }, [onHide, isVisible, isHidden]);\n\n useEffect(() => {\n if (timeout === null && animationRunTimeout.current !== null) {\n clearTimeout(animationRunTimeout.current);\n animationRunTimeout.current = null;\n }\n }, [timeout]);\n\n useEffect(() => {\n if (timeout && isVisible) {\n hideTimeout.current = setTimeout(() => {\n hideToast();\n }, timeout);\n }\n }, [isVisible, timeout]);\n\n return (\n <ToastContext.Provider value={{ showToast, hideToast, isVisible, hideTimeout, animationRunTimeout }}>\n {children}\n {!isHidden && <ToastComponent {...(toastProps as T)} />}\n </ToastContext.Provider>\n );\n };\n"],"names":["ToastContext","createContext","useToastInner","context","useContext","Error","useToast","_useToastInner","showToast","hideToast","initialToastData","text","undefined","offset","position","DEFAULT_POSITION","fade","DEFAULT_FADE","timeout","contentLeft","role","pilled","hasClose","width","size","view","getShowToastCallSignature","args","_typeof","_args","_slicedToArray","ToastProviderHoc","ToastComponent","ToastProvider","_ref","children","_useState","useState","_useState2","isVisible","setIsVisible","_useState3","_useState4","isHidden","setIsHidden","hideTimeout","useRef","animationRunTimeout","_useState5","_useState6","toastProps","setToastProps","_useState7","onHide","_useState8","toastInfo","setToastInfo","showToastCallback","_len","arguments","length","Array","_key","_getShowToastCallSign","_getShowToastCallSign2","_getShowToastCallSign3","onShow","useCallback","current","clearTimeout","setTimeout","TIMER_DELAY","useEffect","React","createElement","Provider","value"],"mappings":";;;;;;;;IAQaA,YAAY,gBAAGC,mBAAa,CAA0B,IAAI,EAAC;IAE3DC,aAAa,GAAG,SAAhBA,aAAaA,GAAS;AAC/B,EAAA,IAAMC,OAAO,GAAGC,gBAAU,CAACJ,YAAY,CAAC,CAAA;EACxC,IAAI,CAACG,OAAO,EAAE;AACV,IAAA,MAAM,IAAIE,KAAK,CAAC,8CAA8C,CAAC,CAAA;AACnE,GAAA;AACA,EAAA,OAAOF,OAAO,CAAA;AAClB,EAAC;IAEYG,QAAQ,GAAG,SAAXA,QAAQA,GAAS;AAC1B,EAAA,IAAAC,cAAA,G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MAAM,EAAEd,SAAS,EAAEI,QAAQ,CAAC,CAAC,CAAA;AAEjC6B,IAAAA,eAAS,CAAC,YAAM;MACZ,IAAItD,OAAO,KAAK,IAAI,IAAI6B,mBAAmB,CAACqB,OAAO,KAAK,IAAI,EAAE;AAC1DC,QAAAA,YAAY,CAACtB,mBAAmB,CAACqB,OAAO,CAAC,CAAA;QACzCrB,mBAAmB,CAACqB,OAAO,GAAG,IAAI,CAAA;AACtC,OAAA;AACJ,KAAC,EAAE,CAAClD,OAAO,CAAC,CAAC,CAAA;AAEbsD,IAAAA,eAAS,CAAC,YAAM;MACZ,IAAItD,OAAO,IAAIqB,SAAS,EAAE;AACtBM,QAAAA,WAAW,CAACuB,OAAO,GAAGE,UAAU,CAAC,YAAM;AACnC7D,UAAAA,SAAS,EAAE,CAAA;SACd,EAAES,OAAO,CAAC,CAAA;AACf,OAAA;AACJ,KAAC,EAAE,CAACqB,SAAS,EAAErB,OAAO,CAAC,CAAC,CAAA;AAExB,IAAA,oBACIuD,KAAA,CAAAC,aAAA,CAAC1E,YAAY,CAAC2E,QAAQ,EAAA;AAACC,MAAAA,KAAK,EAAE;AAAEpE,QAAAA,SAAS,EAATA,SAAS;AAAEC,QAAAA,SAAS,EAATA,SAAS;AAAE8B,QAAAA,SAAS,EAATA,SAAS;AAAEM,QAAAA,WAAW,EAAXA,WAAW;AAAEE,QAAAA,mBAAmB,EAAnBA,mBAAAA;AAAoB,OAAA;AAAE,KAAA,EAC/FZ,QAAQ,EACR,CAACQ,QAAQ,iBAAI8B,KAAA,CAAAC,aAAA,CAAC1C,cAAc,EAAMkB,UAAmB,CACnC,CAAC,CAAA;GAE/B,CAAA;AAAA;;;;;;;"}
|
1
|
+
{"version":3,"file":"ToastProvider.js","sources":["../../../../src/components/Toast/ToastProvider/ToastProvider.tsx"],"sourcesContent":["import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport type { ReactNode, FC } from 'react';\n\nimport type { CustomToastProps, ToastControllerProps, ToastProps } from '../Toast.types';\nimport { DEFAULT_FADE, DEFAULT_POSITION, TIMER_DELAY } from '../utils';\n\nimport type { ShowToast, ShowToastArgs, ShowToastCallSignature, ToastContextType } from './ToastProvider.types';\n\nexport const ToastContext = createContext<ToastContextType | null>(null);\n\nexport const useToastInner = () => {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error('useToast must be used within a ToastProvider');\n }\n return context;\n};\n\nexport const useToast = () => {\n const { showToast, hideToast } = useToastInner();\n return { showToast, hideToast };\n};\n\nconst initialToastData = {\n text: undefined,\n offset: undefined,\n position: DEFAULT_POSITION,\n fade: DEFAULT_FADE,\n timeout: undefined,\n contentLeft: undefined,\n role: undefined,\n pilled: undefined,\n hasClose: undefined,\n width: undefined,\n size: 'm',\n view: 'primary',\n} as CustomToastProps;\n\nconst getShowToastCallSignature = (args: ShowToastCallSignature) => {\n if (typeof args[0] === 'object' && 'text' in args[0]) {\n return args[0];\n }\n\n // TODO: issue https://github.com/salute-developers/plasma/issues/333\n const [text, position, timeout, fade, contentLeft, role, offset, pilled, width, hasClose, size, view] = args;\n\n return { text, position, timeout, fade, contentLeft, role, offset, pilled, width, hasClose, size, view };\n};\n\nexport const ToastProviderHoc = <T extends ToastProps>(ToastComponent: FC<T>) =>\n function ToastProvider({ children }: { children: ReactNode }) {\n const [isVisible, setIsVisible] = useState(false);\n const [isHidden, setIsHidden] = useState(true);\n const hideTimeout = useRef<number | null>(null);\n const animationRunTimeout = useRef<number | null>(null);\n\n const [toastProps, setToastProps] = useState<ToastControllerProps>(initialToastData);\n const [toastInfo, setToastInfo] = useState<Pick<ShowToastArgs, 'timeout' | 'onHide'>>({\n timeout: undefined,\n onHide: undefined,\n });\n\n const showToastCallback: ShowToast = (...args: ShowToastCallSignature) => {\n if (isVisible) {\n return;\n }\n\n const {\n text,\n offset,\n position = DEFAULT_POSITION,\n fade = DEFAULT_FADE,\n timeout,\n contentLeft,\n role,\n pilled,\n hasClose,\n size,\n view,\n width,\n onHide,\n onShow,\n } = getShowToastCallSignature(args);\n\n setToastProps({\n text,\n width,\n position,\n offset,\n fade,\n contentLeft,\n role,\n pilled,\n hasClose,\n size,\n view,\n });\n\n setToastInfo({ timeout, onHide });\n\n setIsHidden(false);\n setIsVisible(true);\n onShow?.();\n };\n\n const showToast = useCallback(showToastCallback, []);\n\n const { onHide, timeout } = toastInfo;\n\n const hideToast = useCallback(() => {\n if (!isVisible) {\n return;\n }\n\n if (hideTimeout?.current) {\n clearTimeout(hideTimeout.current);\n hideTimeout.current = null;\n }\n\n onHide?.();\n setIsVisible(false);\n\n animationRunTimeout.current = setTimeout(() => {\n setIsHidden(true);\n setToastProps(initialToastData);\n }, TIMER_DELAY);\n }, [onHide, isVisible, isHidden]);\n\n useEffect(() => {\n if (timeout === null && animationRunTimeout.current !== null) {\n clearTimeout(animationRunTimeout.current);\n animationRunTimeout.current = null;\n }\n }, [timeout]);\n\n useEffect(() => {\n if (timeout && isVisible) {\n hideTimeout.current = setTimeout(() => {\n hideToast();\n }, timeout);\n }\n }, [isVisible, timeout]);\n\n return (\n <ToastContext.Provider value={{ showToast, hideToast, isVisible, hideTimeout, animationRunTimeout }}>\n {children}\n {!isHidden && <ToastComponent {...(toastProps as T)} />}\n </ToastContext.Provider>\n );\n };\n"],"names":["ToastContext","createContext","useToastInner","context","useContext","Error","useToast","_useToastInner","showToast","hideToast","initialToastData","text","undefined","offset","position","DEFAULT_POSITION","fade","DEFAULT_FADE","timeout","contentLeft","role","pilled","hasClose","width","size","view","getShowToastCallSignature","args","_typeof","_args","_slicedToArray","ToastProviderHoc","ToastComponent","ToastProvider","_ref","children","_useState","useState","_useState2","isVisible","setIsVisible","_useState3","_useState4","isHidden","setIsHidden","hideTimeout","useRef","animationRunTimeout","_useState5","_useState6","toastProps","setToastProps","_useState7","onHide","_useState8","toastInfo","setToastInfo","showToastCallback","_len","arguments","length","Array","_key","_getShowToastCallSign","_getShowToastCallSign2","_getShowToastCallSign3","onShow","useCallback","current","clearTimeout","setTimeout","TI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AE8B,QAAAA,SAAS,EAATA,SAAS;AAAEM,QAAAA,WAAW,EAAXA,WAAW;AAAEE,QAAAA,mBAAmB,EAAnBA,mBAAAA;AAAoB,OAAA;AAAE,KAAA,EAC/FZ,QAAQ,EACR,CAACQ,QAAQ,iBAAI8B,KAAA,CAAAC,aAAA,CAAC1C,cAAc,EAAMkB,UAAmB,CACnC,CAAC,CAAA;GAE/B,CAAA;AAAA;;;;;;;"}
|
@@ -75,7 +75,7 @@ var tooltipRoot = function tooltipRoot(Root) {
|
|
75
75
|
React.useEffect(function () {
|
76
76
|
var onKeyDown = function onKeyDown(event) {
|
77
77
|
if (event.keyCode === ESCAPE_KEYCODE) {
|
78
|
-
onDismiss === null || onDismiss === void 0
|
78
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
79
79
|
}
|
80
80
|
};
|
81
81
|
window.addEventListener('keydown', onKeyDown);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, { useEffect, forwardRef, useState } from 'react';\nimport { styled } from '@linaria/react';\n\nimport { RootProps, component } from '../../engines';\nimport { popoverClasses, popoverConfig, popoverTokens } from '../Popover';\nimport { cx } from '../../utils';\n\nimport { TooltipProps } from './Tooltip.types';\nimport { StyledContentLeft, TooltipRoot } from './Tooltip.styles';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { classes, tokens } from './Tooltip.tokens';\n\nconst ESCAPE_KEYCODE = 27;\n\nconst getStringValue = (value?: number | string) => {\n return typeof value === 'number' ? `${value}rem` : value;\n};\n\nconst Popover = component(popoverConfig);\n\nconst StyledPopover = styled(Popover)`\n ${popoverTokens.arrowMaskWidth}: var(${tokens.arrowMaskWidth});\n ${popoverTokens.arrowMaskHeight}: var(${tokens.arrowMaskHeight});\n ${popoverTokens.arrowMaskImage}: var(${tokens.arrowMaskImage});\n ${popoverTokens.arrowBackground}: var(${tokens.arrowBackground});\n ${popoverTokens.arrowHeight}: var(${tokens.arrowHeight});\n ${popoverTokens.arrowEdgeMargin}: var(${tokens.arrowEdgeMargin});\n\n &.${classes.animated} .${popoverClasses.root} {\n transition: opacity 200ms ease-in-out, visibility 200ms ease-in-out;\n }\n`;\n\n/**\n * Компонент для текстовых подсказок. Основное предназначение — подписи к блокам.\n */\n\nexport const tooltipRoot = (Root: RootProps<HTMLDivElement, Omit<TooltipProps, 'isOpen' | 'text'>>) =>\n forwardRef<HTMLDivElement, TooltipProps>(\n (\n {\n id,\n text,\n isOpen,\n isVisible,\n hasArrow = true,\n arrow,\n animated,\n offset = [0, 8],\n minWidth,\n maxWidth,\n placement = 'bottom',\n usePortal = true,\n target,\n children,\n onDismiss,\n view,\n size,\n contentLeft,\n zIndex = '9200',\n className,\n ...rest\n },\n outerRef,\n ) => {\n const [ref, setRef] = useState<HTMLDivElement | null>(null);\n\n // TODO убрать после отказа от старого API\n const innerIsOpen = isVisible || isOpen;\n const innerHasArrow = arrow || hasArrow;\n const showTooltip = innerIsOpen && Boolean(text?.length);\n\n const animatedClass = animated ? classes.animated : undefined;\n\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.keyCode === ESCAPE_KEYCODE) {\n onDismiss?.();\n }\n };\n\n window.addEventListener('keydown', onKeyDown);\n\n return () => {\n window.removeEventListener('keydown', onKeyDown);\n };\n }, []);\n\n const withContentLeft = contentLeft ? classes.hasContentLeft : undefined;\n\n return (\n <StyledPopover\n isOpen={showTooltip}\n placement={placement}\n offset={offset}\n zIndex={zIndex}\n target={target || children}\n usePortal={usePortal}\n hasArrow={innerHasArrow}\n aria-hidden={!innerIsOpen}\n aria-live=\"polite\"\n role=\"tooltip\"\n className={cx(ref?.classList.toString(), animatedClass, className)}\n // INFO: Прокидываем стили для Popover из Root Tooltip-а\n\n {...rest}\n >\n <Root view={view} size={size} ref={setRef}>\n <TooltipRoot\n ref={outerRef}\n id={id}\n className={cx(withContentLeft)}\n maxWidth={getStringValue(maxWidth)}\n minWidth={getStringValue(minWidth)}\n >\n {contentLeft && <StyledContentLeft>{contentLeft}</StyledContentLeft>}\n {text}\n </TooltipRoot>\n </Root>\n </StyledPopover>\n );\n },\n );\n\nexport const tooltipConfig = {\n name: 'Tooltip',\n tag: 'div',\n layout: tooltipRoot,\n base: '',\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n },\n defaults: {\n view: 'default',\n size: 'm',\n },\n};\n"],"names":["ESCAPE_KEYCODE","getStringValue","value","concat","Popover","component","popoverConfig","_exp","StyledPopover","styled","name","class","propsAsIs","tooltipRoot","Root","forwardRef","_ref","outerRef","id","text","isOpen","isVisible","_ref$hasArrow","hasArrow","arrow","animated","_ref$offset","offset","minWidth","maxWidth","_ref$placement","placement","_ref$usePortal","usePortal","target","children","onDismiss","view","size","contentLeft","_ref$zIndex","zIndex","className","rest","_useState","useState","_useState2","_slicedToArray","ref","setRef","innerIsOpen","innerHasArrow","showTooltip","Boolean","length","animatedClass","classes","undefined","useEffect","onKeyDown","event","keyCode","window","addEventListener","removeEventListener","withContentLeft","hasContentLeft","React","createElement","_extends","role","cx","classList","toString","TooltipRoot","StyledContentLeft","tooltipConfig","tag","layout","base","variations","css","viewCSS","sizeCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;AAaA,IAAMA,cAAc,GAAG,EAAE,CAAA;AAEzB,IAAMC,cAAc,GAAGA,SAAjBA,cAAcA,CAAIC,KAAuB,EAAK;EAChD,OAAO,OAAOA,KAAK,KAAK,QAAQ,MAAAC,MAAA,CAAMD,KAAM,EAAA,KAAA,CAAA,GAAOA,KAAK,CAAA;AAC5D,CAAC,CAAA;AAED,IAAME,OAAO,gBAAGC,gBAAS,CAACC,uBAAa,CAAC,CAAA;AAAC,IAAAC,IAAA,GAlBvBA,SAkBuBA,IAAAA,GAAA;AAAA,EAAA,OAEZH,OAAO,CAAA;AAAA,CAAA,CAAA;AAApC,IAAMI,aAAa,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AG;AACPwB,MAAAA,SAAS,EAAE6B,QAAE,CAACN,eAAe,CAAE;AAC/BpC,MAAAA,QAAQ,EAAE5B,cAAc,CAAC4B,QAAQ,CAAE;MACnCD,QAAQ,EAAE3B,cAAc,CAAC2B,QAAQ,CAAA;AAAE,KAAA,EAElCW,WAAW,iBAAI4B,KAAA,CAAAC,aAAA,CAACO,gCAAiB,EAAEpC,IAAAA,EAAAA,WAA+B,CAAC,EACnEpB,IACQ,CACX,CACK,CAAC,CAAA;AAExB,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMyD,aAAa,GAAG;AACzBlE,EAAAA,IAAI,EAAE,SAAS;AACfmE,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEjE,WAAW;AACnBkE,EAAAA,IAAI,EAAE,EAAE;AACRC,EAAAA,UAAU,EAAE;AACR3C,IAAAA,IAAI,EAAE;AACF4C,MAAAA,GAAG,EAAEC,SAAAA;KACR;AACD5C,IAAAA,IAAI,EAAE;AACF2C,MAAAA,GAAG,EAAEE,WAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN/C,IAAAA,IAAI,EAAE,SAAS;AACfC,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;;"}
|
1
|
+
{"version":3,"file":"Tooltip.js","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, { useEffect, forwardRef, useState } from 'react';\nimport { styled } from '@linaria/react';\n\nimport { RootProps, component } from '../../engines';\nimport { popoverClasses, popoverConfig, popoverTokens } from '../Popover';\nimport { cx } from '../../utils';\n\nimport { TooltipProps } from './Tooltip.types';\nimport { StyledContentLeft, TooltipRoot } from './Tooltip.styles';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { classes, tokens } from './Tooltip.tokens';\n\nconst ESCAPE_KEYCODE = 27;\n\nconst getStringValue = (value?: number | string) => {\n return typeof value === 'number' ? `${value}rem` : value;\n};\n\nconst Popover = component(popoverConfig);\n\nconst StyledPopover = styled(Popover)`\n ${popoverTokens.arrowMaskWidth}: var(${tokens.arrowMaskWidth});\n ${popoverTokens.arrowMaskHeight}: var(${tokens.arrowMaskHeight});\n ${popoverTokens.arrowMaskImage}: var(${tokens.arrowMaskImage});\n ${popoverTokens.arrowBackground}: var(${tokens.arrowBackground});\n ${popoverTokens.arrowHeight}: var(${tokens.arrowHeight});\n ${popoverTokens.arrowEdgeMargin}: var(${tokens.arrowEdgeMargin});\n\n &.${classes.animated} .${popoverClasses.root} {\n transition: opacity 200ms ease-in-out, visibility 200ms ease-in-out;\n }\n`;\n\n/**\n * Компонент для текстовых подсказок. Основное предназначение — подписи к блокам.\n */\n\nexport const tooltipRoot = (Root: RootProps<HTMLDivElement, Omit<TooltipProps, 'isOpen' | 'text'>>) =>\n forwardRef<HTMLDivElement, TooltipProps>(\n (\n {\n id,\n text,\n isOpen,\n isVisible,\n hasArrow = true,\n arrow,\n animated,\n offset = [0, 8],\n minWidth,\n maxWidth,\n placement = 'bottom',\n usePortal = true,\n target,\n children,\n onDismiss,\n view,\n size,\n contentLeft,\n zIndex = '9200',\n className,\n ...rest\n },\n outerRef,\n ) => {\n const [ref, setRef] = useState<HTMLDivElement | null>(null);\n\n // TODO убрать после отказа от старого API\n const innerIsOpen = isVisible || isOpen;\n const innerHasArrow = arrow || hasArrow;\n const showTooltip = innerIsOpen && Boolean(text?.length);\n\n const animatedClass = animated ? classes.animated : undefined;\n\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.keyCode === ESCAPE_KEYCODE) {\n onDismiss?.();\n }\n };\n\n window.addEventListener('keydown', onKeyDown);\n\n return () => {\n window.removeEventListener('keydown', onKeyDown);\n };\n }, []);\n\n const withContentLeft = contentLeft ? classes.hasContentLeft : undefined;\n\n return (\n <StyledPopover\n isOpen={showTooltip}\n placement={placement}\n offset={offset}\n zIndex={zIndex}\n target={target || children}\n usePortal={usePortal}\n hasArrow={innerHasArrow}\n aria-hidden={!innerIsOpen}\n aria-live=\"polite\"\n role=\"tooltip\"\n className={cx(ref?.classList.toString(), animatedClass, className)}\n // INFO: Прокидываем стили для Popover из Root Tooltip-а\n\n {...rest}\n >\n <Root view={view} size={size} ref={setRef}>\n <TooltipRoot\n ref={outerRef}\n id={id}\n className={cx(withContentLeft)}\n maxWidth={getStringValue(maxWidth)}\n minWidth={getStringValue(minWidth)}\n >\n {contentLeft && <StyledContentLeft>{contentLeft}</StyledContentLeft>}\n {text}\n </TooltipRoot>\n </Root>\n </StyledPopover>\n );\n },\n );\n\nexport const tooltipConfig = {\n name: 'Tooltip',\n tag: 'div',\n layout: tooltipRoot,\n base: '',\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n },\n defaults: {\n view: 'default',\n size: 'm',\n },\n};\n"],"names":["ESCAPE_KEYCODE","getStringValue","value","concat","Popover","component","popoverConfig","_exp","StyledPopover","styled","name","class","propsAsIs","tooltipRoot","Root","forwardRef","_ref","outerRef","id","text","isOpen","isVisible","_ref$hasArrow","hasArrow","arrow","animated","_ref$offset","offset","minWidth","maxWidth","_ref$placement","placement","_ref$usePortal","usePortal","target","children","onDismiss","view","size","contentLeft","_ref$zIndex","zIndex","className","rest","_useState","useState","_useState2","_slicedToArray","ref","setRef","innerIsOpen","innerHasArrow","showTooltip","Boolean","length","animatedClass","classes","undefined","useEffect","onKeyDown","event","keyCode","window","addEventListener","removeEventListener","withContentLeft","hasContentLeft","React","createElement","_extends","role","cx","classList","toString","TooltipRoot","StyledContentLeft","tooltipConfig","tag","layout","base","variations","css","viewCSS","sizeCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;AAaA,IAAMA,cAAc,GAAG,EAAE,CAAA;AAEzB,IAAMC,cAAc,GAAGA,SAAjBA,cAAcA,CAAIC,KAAuB,EAAK;EAChD,OAAO,OAAOA,KAAK,KAAK,QAAQ,MAAAC,MAAA,CAAMD,KAAM,EAAA,KAAA,CAAA,GAAOA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AI,EAAA;AAACuB,MAAAA,IAAI,EAAEA,IAAK;AAACC,MAAAA,IAAI,EAAEA,IAAK;AAACU,MAAAA,GAAG,EAAEC,MAAAA;AAAO,KAAA,eACtCkB,KAAA,CAAAC,aAAA,CAACM,0BAAW,EAAA;AACR1B,MAAAA,GAAG,EAAE/B,QAAS;AACdC,MAAAA,EAAE,EAAEA,EAAG;AACPwB,MAAAA,SAAS,EAAE6B,QAAE,CAACN,eAAe,CAAE;AAC/BpC,MAAAA,QAAQ,EAAE5B,cAAc,CAAC4B,QAAQ,CAAE;MACnCD,QAAQ,EAAE3B,cAAc,CAAC2B,QAAQ,CAAA;AAAE,KAAA,EAElCW,WAAW,iBAAI4B,KAAA,CAAAC,aAAA,CAACO,gCAAiB,EAAEpC,IAAAA,EAAAA,WAA+B,CAAC,EACnEpB,IACQ,CACX,CACK,CAAC,CAAA;AAExB,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMyD,aAAa,GAAG;AACzBlE,EAAAA,IAAI,EAAE,SAAS;AACfmE,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEjE,WAAW;AACnBkE,EAAAA,IAAI,EAAE,EAAE;AACRC,EAAAA,UAAU,EAAE;AACR3C,IAAAA,IAAI,EAAE;AACF4C,MAAAA,GAAG,EAAEC,SAAAA;KACR;AACD5C,IAAAA,IAAI,EAAE;AACF2C,MAAAA,GAAG,EAAEE,WAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN/C,IAAAA,IAAI,EAAE,SAAS;AACfC,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;;"}
|
package/cjs/index.css
CHANGED
@@ -40,6 +40,8 @@
|
|
40
40
|
|
41
41
|
.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);}
|
42
42
|
|
43
|
+
.base_3kce4h_bvcavwi__c6ad5ca5.base_3kce4h_chipPilled__c6ad5ca5{border-radius:var(--plasma-chip-pilled-border-radius);}
|
44
|
+
|
43
45
|
.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);}
|
44
46
|
.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);}
|
45
47
|
.Chip_styles_1mwwhiw_s1ror4o9__07da4d18{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
@@ -149,7 +149,7 @@ var calendarBaseRoot = function calendarBaseRoot(Root) {
|
|
149
149
|
isOutOfRange = _useKeyNavigation2[4];
|
150
150
|
var handleOnChangeDay = useCallback(function (newDate, coord) {
|
151
151
|
var newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);
|
152
|
-
onChangeValue === null || onChangeValue === void 0
|
152
|
+
onChangeValue === null || onChangeValue === void 0 ? void 0 : onChangeValue(newDay);
|
153
153
|
onSelectIndexes(coord);
|
154
154
|
}, [onChangeValue, onSelectIndexes]);
|
155
155
|
var handleOnChangeMonth = useCallback(function (monthIndex) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CalendarBase.js","sources":["../../../../src/components/Calendar/CalendarBase/CalendarBase.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useReducer, useState, KeyboardEvent, HTMLAttributes, forwardRef } from 'react';\n\nimport type { Calendar, DateObject, UseKeyNavigationProps } from '../Calendar.types';\nimport type { CalendarStateType } from '../store/types';\nimport { getInitialState, reducer } from '../store/reducer';\nimport { ActionType, CalendarState } from '../store/types';\nimport { isValueUpdate, YEAR_RENDER_COUNT } from '../utils';\nimport { useKeyNavigation } from '../hooks';\nimport { CalendarDays, CalendarHeader, CalendarMonths, CalendarYears } from '../ui';\nimport { RootProps } from '../../../engines';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { IsOutOfRange, StyledCalendar } from './CalendarBase.styles';\n\nexport type CalendarBaseProps = HTMLAttributes<HTMLDivElement> &\n Calendar & {\n /**\n * Тип отображения календаря: дни, месяца, года.\n */\n type?: CalendarStateType;\n };\n\n/**\n * Компонент календаря.\n */\nexport const calendarBaseRoot = (Root: RootProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>>) =>\n forwardRef<HTMLDivElement, CalendarBaseProps>(\n (\n { value: externalValue, min, max, type = 'Days', eventList, disabledList, onChangeValue, ...rest },\n outerRootRef,\n ) => {\n const [firstValue, secondValue] = useMemo(\n () => (Array.isArray(externalValue) ? externalValue : [externalValue]),\n [externalValue],\n );\n const value = secondValue || firstValue;\n const [hoveredDay, setHoveredDay] = useState<DateObject | undefined>();\n const [prevType, setPrevType] = useState(type);\n const [prevValue, setPrevValue] = useState(value);\n const [outOfRangeKey, setOutOfRangeKey] = useState<number>(0);\n\n const [state, dispatch] = useReducer(reducer, getInitialState(value, [5, 6], type));\n\n const { date, calendarState, startYear, size } = state;\n\n const handlePrev = useCallback<UseKeyNavigationProps['onPrev']>(\n (withShift = false) => {\n if (calendarState === CalendarState.Days) {\n if (withShift) {\n dispatch({\n type: ActionType.PREVIOUS_YEAR,\n payload: { step: 1 },\n });\n\n return;\n }\n\n dispatch({\n type: ActionType.PREVIOUS_MONTH,\n payload: { monthIndex: date.monthIndex, year: date.year },\n });\n\n return;\n }\n\n if (calendarState === CalendarState.Months) {\n dispatch({ type: ActionType.PREVIOUS_YEAR, payload: { step: 1 } });\n\n return;\n }\n\n if (calendarState === CalendarState.Years) {\n dispatch({ type: ActionType.PREVIOUS_START_YEAR, payload: { yearsCount: YEAR_RENDER_COUNT } });\n }\n },\n [date, calendarState],\n );\n\n const handleNext = useCallback<UseKeyNavigationProps['onNext']>(\n (withShift = false) => {\n if (calendarState === CalendarState.Days) {\n if (withShift) {\n dispatch({\n type: ActionType.NEXT_YEAR,\n payload: { step: 1 },\n });\n\n return;\n }\n\n dispatch({\n type: ActionType.NEXT_MONTH,\n payload: { monthIndex: date.monthIndex, year: date.year },\n });\n\n return;\n }\n\n if (calendarState === CalendarState.Months) {\n dispatch({ type: ActionType.NEXT_YEAR, payload: { step: 1 } });\n\n return;\n }\n\n if (calendarState === CalendarState.Years) {\n dispatch({ type: ActionType.NEXT_START_YEAR, payload: { yearsCount: YEAR_RENDER_COUNT } });\n }\n },\n [date, calendarState],\n );\n\n const [selectIndexes, onKeyDown, onSelectIndexes, outerRefs, isOutOfRange] = useKeyNavigation({\n size,\n onNext: handleNext,\n onPrev: handlePrev,\n });\n\n const handleOnChangeDay = useCallback(\n (newDate: DateObject, coord: number[]) => {\n const newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);\n onChangeValue?.(newDay);\n\n onSelectIndexes(coord);\n },\n [onChangeValue, onSelectIndexes],\n );\n\n const handleOnChangeMonth = useCallback((monthIndex: number) => {\n dispatch({\n type: ActionType.UPDATE_MONTH,\n payload: { calendarState: CalendarState.Days, monthIndex, size: [5, 6] },\n });\n }, []);\n\n const handleOnChangeYear = useCallback((year: number) => {\n dispatch({\n type: ActionType.UPDATE_YEAR,\n payload: { calendarState: CalendarState.Months, year },\n });\n }, []);\n\n const handleUpdateCalendarState = useCallback(\n (newCalendarState: CalendarStateType, newSize: [number, number]) => {\n dispatch({\n type: ActionType.UPDATE_CALENDAR_STATE,\n payload: { calendarState: newCalendarState, size: newSize },\n });\n },\n [],\n );\n\n if (value && prevValue && isValueUpdate(value, prevValue)) {\n dispatch({\n type: ActionType.UPDATE_DATE,\n payload: { value },\n });\n\n setPrevValue(value);\n }\n\n if (prevType !== type) {\n dispatch({\n type: ActionType.UPDATE_CALENDAR_STATE,\n payload: { calendarState: type },\n });\n\n setPrevType(type);\n }\n\n // Изменяем ключ каждый раз как пытаемся перейти на даты которые находятся за пределами min/max ограничений.\n // Это необходимо для того чтобы screen-reader корректно озвучивал уведомление aria-live=\"assertive\"\n // о том что нет доступных дат\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n setOutOfRangeKey((previousState) => Number(!previousState));\n\n onKeyDown(event);\n },\n [onKeyDown],\n );\n\n return (\n <Root ref={outerRootRef} aria-label=\"Выбор даты\" {...rest}>\n {isOutOfRange && (\n <IsOutOfRange\n key={outOfRangeKey}\n aria-atomic=\"true\"\n role=\"alert\"\n aria-live=\"assertive\"\n aria-relevant=\"additions\"\n >\n Далее нет доступных дат.\n </IsOutOfRange>\n )}\n <CalendarHeader\n firstDate={date}\n startYear={startYear}\n type={calendarState}\n onPrev={handlePrev}\n onNext={handleNext}\n onUpdateCalendarState={handleUpdateCalendarState}\n />\n {calendarState === CalendarState.Days && (\n <CalendarDays\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n value={externalValue}\n date={date}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={handleKeyDown}\n outerRefs={outerRefs}\n />\n )}\n {calendarState === CalendarState.Months && (\n <CalendarMonths\n date={date}\n selectIndexes={selectIndexes}\n onChangeMonth={handleOnChangeMonth}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n )}\n {calendarState === CalendarState.Years && (\n <CalendarYears\n date={date}\n startYear={startYear}\n selectIndexes={selectIndexes}\n onChangeYear={handleOnChangeYear}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n )}\n </Root>\n );\n },\n );\n\nexport const calendarBaseConfig = {\n name: 'CalendarBase',\n tag: 'div',\n layout: calendarBaseRoot,\n base: StyledCalendar,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n },\n defaults: {\n view: 'primary',\n size: 'm',\n },\n};\n"],"names":["calendarBaseRoot","Root","forwardRef","_ref","outerRootRef","externalValue","value","min","max","_ref$type","type","eventList","disabledList","onChangeValue","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","Array","isArray","_useMemo2","_slicedToArray","firstValue","secondValue","_useState","useState","_useState2","hoveredDay","setHoveredDay","_useState3","_useState4","prevType","setPrevType","_useState5","_useState6","prevValue","setPrevValue","_useState7","_useState8","outOfRangeKey","setOutOfRangeKey","_useReducer","useReducer","reducer","getInitialState","_useReducer2","state","dispatch","date","calendarState","startYear","size","handlePrev","useCallback","withShift","arguments","length","undefined","CalendarState","Days","ActionType","PREVIOUS_YEAR","payload","step","PREVIOUS_MONTH","monthIndex","year","Months","Years","PREVIOUS_START_YEAR","yearsCount","YEAR_RENDER_COUNT","handleNext","NEXT_YEAR","NEXT_MONTH","NEXT_START_YEAR","_useKeyNavigation","useKeyNavigation","onNext","onPrev","_useKeyNavigation2","selectIndexes","onKeyDown","onSelectIndexes","outerRefs","isOutOfRange","handleOnChangeDay","newDate","coord","newDay","Date","day","handleOnChangeMonth","UPDATE_MONTH","handleOnChangeYear","UPDATE_YEAR","handleUpdateCalendarState","newCalendarState","newSize","UPDATE_CALENDAR_STATE","isValueUpdate","UPDATE_DATE","handleKeyDown","event","previousState","Number","React","createElement","_extends","ref","IsOutOfRange","key","role","CalendarHeader","firstDate","onUpdateCalendarState","CalendarDays","onChangeDay","onHoverDay","onSetSelected","CalendarMonths","onChangeMonth","CalendarYears","onChangeYear","calendarBaseConfig","name","tag","layout","base","StyledCalendar","variations","view","css","viewCSS","sizeCSS","defaults"],"mappings":";;;;;;;;;;;;;;;AAuBA;AACA;AACA;IACaA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,IAA+D,EAAA;AAAA,EAAA,oBAC5FC,UAAU,CACN,UAAAC,IAAA,EAEIC,YAAY,EACX;AAAA,IAAA,IAFQC,aAAa,GAAAF,IAAA,CAApBG,KAAK;MAAiBC,GAAG,GAAAJ,IAAA,CAAHI,GAAG;MAAEC,GAAG,GAAAL,IAAA,CAAHK,GAAG;MAAAC,SAAA,GAAAN,IAAA,CAAEO,IAAI;AAAJA,MAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,MAAM,GAAAA,SAAA;MAAEE,SAAS,GAAAR,IAAA,CAATQ,SAAS;MAAEC,YAAY,GAAAT,IAAA,CAAZS,YAAY;MAAEC,aAAa,GAAAV,IAAA,CAAbU,aAAa;AAAKC,MAAAA,IAAI,GAAAC,wBAAA,CAAAZ,IAAA,EAAAa,SAAA,CAAA,CAAA;IAGhG,IAAAC,QAAA,GAAkCC,OAAO,CACrC,YAAA;QAAA,OAAOC,KAAK,CAACC,OAAO,CAACf,aAAa,CAAC,GAAGA,aAAa,GAAG,CAACA,aAAa,CAAC,CAAA;AAAA,OAAC,EACtE,CAACA,aAAa,CAClB,CAAC;MAAAgB,SAAA,GAAAC,cAAA,CAAAL,QAAA,EAAA,CAAA,CAAA;AAHMM,MAAAA,UAAU,GAAAF,SAA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EA,aAAc;AAC7B0C,MAAAA,YAAY,EAAE7B,kBAAmB;AACjCyB,MAAAA,aAAa,EAAEpC,eAAgB;AAC/BD,MAAAA,SAAS,EAAEA,SAAU;AACrBE,MAAAA,SAAS,EAAEA,SAAAA;AAAU,KACxB,CAEH,CAAC,CAAA;AAEf,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMwC,kBAAkB,GAAG;AAC9BC,EAAAA,IAAI,EAAE,cAAc;AACpBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEhI,gBAAgB;AACxBiI,EAAAA,IAAI,EAAEC,cAAc;AACpBC,EAAAA,UAAU,EAAE;AACRC,IAAAA,IAAI,EAAE;AACFC,MAAAA,GAAG,EAAEC,IAAAA;KACR;AACDlF,IAAAA,IAAI,EAAE;AACFiF,MAAAA,GAAG,EAAEE,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNJ,IAAAA,IAAI,EAAE,SAAS;AACfhF,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"CalendarBase.js","sources":["../../../../src/components/Calendar/CalendarBase/CalendarBase.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useReducer, useState, KeyboardEvent, HTMLAttributes, forwardRef } from 'react';\n\nimport type { Calendar, DateObject, UseKeyNavigationProps } from '../Calendar.types';\nimport type { CalendarStateType } from '../store/types';\nimport { getInitialState, reducer } from '../store/reducer';\nimport { ActionType, CalendarState } from '../store/types';\nimport { isValueUpdate, YEAR_RENDER_COUNT } from '../utils';\nimport { useKeyNavigation } from '../hooks';\nimport { CalendarDays, CalendarHeader, CalendarMonths, CalendarYears } from '../ui';\nimport { RootProps } from '../../../engines';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { IsOutOfRange, StyledCalendar } from './CalendarBase.styles';\n\nexport type CalendarBaseProps = HTMLAttributes<HTMLDivElement> &\n Calendar & {\n /**\n * Тип отображения календаря: дни, месяца, года.\n */\n type?: CalendarStateType;\n };\n\n/**\n * Компонент календаря.\n */\nexport const calendarBaseRoot = (Root: RootProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>>) =>\n forwardRef<HTMLDivElement, CalendarBaseProps>(\n (\n { value: externalValue, min, max, type = 'Days', eventList, disabledList, onChangeValue, ...rest },\n outerRootRef,\n ) => {\n const [firstValue, secondValue] = useMemo(\n () => (Array.isArray(externalValue) ? externalValue : [externalValue]),\n [externalValue],\n );\n const value = secondValue || firstValue;\n const [hoveredDay, setHoveredDay] = useState<DateObject | undefined>();\n const [prevType, setPrevType] = useState(type);\n const [prevValue, setPrevValue] = useState(value);\n const [outOfRangeKey, setOutOfRangeKey] = useState<number>(0);\n\n const [state, dispatch] = useReducer(reducer, getInitialState(value, [5, 6], type));\n\n const { date, calendarState, startYear, size } = state;\n\n const handlePrev = useCallback<UseKeyNavigationProps['onPrev']>(\n (withShift = false) => {\n if (calendarState === CalendarState.Days) {\n if (withShift) {\n dispatch({\n type: ActionType.PREVIOUS_YEAR,\n payload: { step: 1 },\n });\n\n return;\n }\n\n dispatch({\n type: ActionType.PREVIOUS_MONTH,\n payload: { monthIndex: date.monthIndex, year: date.year },\n });\n\n return;\n }\n\n if (calendarState === CalendarState.Months) {\n dispatch({ type: ActionType.PREVIOUS_YEAR, payload: { step: 1 } });\n\n return;\n }\n\n if (calendarState === CalendarState.Years) {\n dispatch({ type: ActionType.PREVIOUS_START_YEAR, payload: { yearsCount: YEAR_RENDER_COUNT } });\n }\n },\n [date, calendarState],\n );\n\n const handleNext = useCallback<UseKeyNavigationProps['onNext']>(\n (withShift = false) => {\n if (calendarState === CalendarState.Days) {\n if (withShift) {\n dispatch({\n type: ActionType.NEXT_YEAR,\n payload: { step: 1 },\n });\n\n return;\n }\n\n dispatch({\n type: ActionType.NEXT_MONTH,\n payload: { monthIndex: date.monthIndex, year: date.year },\n });\n\n return;\n }\n\n if (calendarState === CalendarState.Months) {\n dispatch({ type: ActionType.NEXT_YEAR, payload: { step: 1 } });\n\n return;\n }\n\n if (calendarState === CalendarState.Years) {\n dispatch({ type: ActionType.NEXT_START_YEAR, payload: { yearsCount: YEAR_RENDER_COUNT } });\n }\n },\n [date, calendarState],\n );\n\n const [selectIndexes, onKeyDown, onSelectIndexes, outerRefs, isOutOfRange] = useKeyNavigation({\n size,\n onNext: handleNext,\n onPrev: handlePrev,\n });\n\n const handleOnChangeDay = useCallback(\n (newDate: DateObject, coord: number[]) => {\n const newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);\n onChangeValue?.(newDay);\n\n onSelectIndexes(coord);\n },\n [onChangeValue, onSelectIndexes],\n );\n\n const handleOnChangeMonth = useCallback((monthIndex: number) => {\n dispatch({\n type: ActionType.UPDATE_MONTH,\n payload: { calendarState: CalendarState.Days, monthIndex, size: [5, 6] },\n });\n }, []);\n\n const handleOnChangeYear = useCallback((year: number) => {\n dispatch({\n type: ActionType.UPDATE_YEAR,\n payload: { calendarState: CalendarState.Months, year },\n });\n }, []);\n\n const handleUpdateCalendarState = useCallback(\n (newCalendarState: CalendarStateType, newSize: [number, number]) => {\n dispatch({\n type: ActionType.UPDATE_CALENDAR_STATE,\n payload: { calendarState: newCalendarState, size: newSize },\n });\n },\n [],\n );\n\n if (value && prevValue && isValueUpdate(value, prevValue)) {\n dispatch({\n type: ActionType.UPDATE_DATE,\n payload: { value },\n });\n\n setPrevValue(value);\n }\n\n if (prevType !== type) {\n dispatch({\n type: ActionType.UPDATE_CALENDAR_STATE,\n payload: { calendarState: type },\n });\n\n setPrevType(type);\n }\n\n // Изменяем ключ каждый раз как пытаемся перейти на даты которые находятся за пределами min/max ограничений.\n // Это необходимо для того чтобы screen-reader корректно озвучивал уведомление aria-live=\"assertive\"\n // о том что нет доступных дат\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n setOutOfRangeKey((previousState) => Number(!previousState));\n\n onKeyDown(event);\n },\n [onKeyDown],\n );\n\n return (\n <Root ref={outerRootRef} aria-label=\"Выбор даты\" {...rest}>\n {isOutOfRange && (\n <IsOutOfRange\n key={outOfRangeKey}\n aria-atomic=\"true\"\n role=\"alert\"\n aria-live=\"assertive\"\n aria-relevant=\"additions\"\n >\n Далее нет доступных дат.\n </IsOutOfRange>\n )}\n <CalendarHeader\n firstDate={date}\n startYear={startYear}\n type={calendarState}\n onPrev={handlePrev}\n onNext={handleNext}\n onUpdateCalendarState={handleUpdateCalendarState}\n />\n {calendarState === CalendarState.Days && (\n <CalendarDays\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n value={externalValue}\n date={date}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={handleKeyDown}\n outerRefs={outerRefs}\n />\n )}\n {calendarState === CalendarState.Months && (\n <CalendarMonths\n date={date}\n selectIndexes={selectIndexes}\n onChangeMonth={handleOnChangeMonth}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n )}\n {calendarState === CalendarState.Years && (\n <CalendarYears\n date={date}\n startYear={startYear}\n selectIndexes={selectIndexes}\n onChangeYear={handleOnChangeYear}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n )}\n </Root>\n );\n },\n );\n\nexport const calendarBaseConfig = {\n name: 'CalendarBase',\n tag: 'div',\n layout: calendarBaseRoot,\n base: StyledCalendar,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n },\n defaults: {\n view: 'primary',\n size: 'm',\n },\n};\n"],"names":["calendarBaseRoot","Root","forwardRef","_ref","outerRootRef","externalValue","value","min","max","_ref$type","type","eventList","disabledList","onChangeValue","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","Array","isArray","_useMemo2","_slicedToArray","firstValue","secondValue","_useState","useState","_useState2","hoveredDay","setHoveredDay","_useState3","_useState4","prevType","setPrevType","_useState5","_useState6","prevValue","setPrevValue","_useState7","_useState8","outOfRangeKey","setOutOfRangeKey","_useReducer","useReducer","reducer","getInitialState","_useReducer2","state","dispatch","date","calendarState","startYear","size","handlePrev","useCallback","withShift","arguments","length","undefined","CalendarState","Days","ActionType","PREVIOUS_YEAR","payload","step","PREVIOUS_MONTH","monthIndex","year","Months","Years","PREVIOUS_START_YEAR","yearsCount","YEAR_RENDER_COUNT","handleNext","NEXT_YEAR","NEXT_MONTH","NEXT_START_YEAR","_useKeyNavigation","useKeyNavigation","onNext","onPrev","_useKeyNavigation2","selectIndexes","onKeyDown","onSelectIndexes","outerRefs","isOutOfRange","handleOnChangeDay","newDate","coord","newDay","Date","day","handleOnChangeMonth","UPDATE_MONTH","handleOnChangeYear","UPDATE_YEAR","handleUpdateCalendarState","newCalendarState","newSize","UPDATE_CALENDAR_STATE","isValueUpdate","UPDATE_DATE","handleKeyDown","event","previousState","Number","React","createElement","_extends","ref","IsOutOfRange","key","role","CalendarHeader","firstDate","onUpdateCalendarState","CalendarDays","onChangeDay","onHoverDay","onSetSelected","CalendarMonths","onChangeMonth","CalendarYears","onChangeYear","calendarBaseConfig","name","tag","layout","base","StyledCalendar","variations","view","css","viewCSS","sizeCSS","defaults"],"mappings":";;;;;;;;;;;;;;;AAuBA;AACA;AACA;IACaA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,IAA+D,EAAA;AAAA,EAAA,oBAC5FC,UAAU,CACN,UAAAC,IAAA,EAEIC,YAAY,EACX;AAAA,IAAA,IAFQC,aAAa,GAAAF,IAAA,CAApBG,KAAK;MAAiBC,GAAG,GAAAJ,IAAA,CAAHI,GAAG;MAAEC,GAAG,GAAAL,IAAA,CAAHK,GAAG;MAAAC,SAAA,GAAAN,IAAA,CAAEO,IAAI;AAAJA,MAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,MAAM,GAAAA,SAAA;MAAEE,SAAS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3];
|
90
90
|
var handleOnChangeDay = useCallback(function (newDate, coord) {
|
91
91
|
var newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);
|
92
|
-
onChangeValue === null || onChangeValue === void 0
|
92
|
+
onChangeValue === null || onChangeValue === void 0 ? void 0 : onChangeValue(newDay);
|
93
93
|
onSelectIndexes(coord);
|
94
94
|
}, [onChangeValue, onSelectIndexes]);
|
95
95
|
var firstDate = useMemo(function () {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CalendarDouble.js","sources":["../../../../src/components/Calendar/CalendarDouble/CalendarDouble.tsx"],"sourcesContent":["import React, { useState, useCallback, useMemo, forwardRef, HTMLAttributes } from 'react';\n\nimport type { Calendar, DateObject } from '../Calendar.types';\nimport { getDateFromValue, getNextDate, getPrevDate, isValueUpdate } from '../utils';\nimport { useKeyNavigation } from '../hooks';\nimport { CalendarDays, CalendarHeader } from '../ui';\nimport { RootProps } from '../../../engines/types';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { StyledCalendar, StyledSeparator, StyledWrapper } from './CalendarDouble.styles';\n\nexport type CalendarDoubleProps = HTMLAttributes<HTMLDivElement> & Calendar;\n\n/**\n * Компонент двойного календаря.\n */\nexport const calendarDoubleRoot = (Root: RootProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>>) =>\n forwardRef<HTMLDivElement, CalendarDoubleProps>(\n ({ value: externalValue, min, max, eventList, disabledList, onChangeValue, ...rest }, outerRootRef) => {\n const [firstValue, secondValue] = useMemo(\n () => (Array.isArray(externalValue) ? externalValue : [externalValue]),\n [externalValue],\n );\n const value = secondValue || firstValue;\n const [hoveredDay, setHoveredDay] = useState<DateObject | undefined>();\n\n const [date, setDate] = useState<DateObject>(getDateFromValue(value));\n const [prevValue, setPrevValue] = useState(value);\n const [doubleDate, setMonths] = useState(() => {\n const nextDate = getDateFromValue(firstValue);\n const [initialYear, initialMonth] = getNextDate(nextDate.year, nextDate.monthIndex);\n\n return {\n monthIndex: [nextDate.monthIndex, initialMonth],\n year: [nextDate.year, initialYear],\n };\n });\n\n const handleMonth = useCallback(\n (getDate: (currentYear: number, currentMonth: number) => number[]) => {\n const [newCurrentYear, newCurrentMonth] = getDate(doubleDate.year[0], doubleDate.monthIndex[0]);\n const [newNextYear, newNextMonth] = getDate(doubleDate.year[1], doubleDate.monthIndex[1]);\n\n setMonths({\n monthIndex: [newCurrentMonth, newNextMonth],\n year: [newCurrentYear, newNextYear],\n });\n },\n [doubleDate],\n );\n\n const handlePrev = useCallback(() => {\n handleMonth(getPrevDate);\n }, [handleMonth]);\n\n const handleNext = useCallback(() => {\n handleMonth(getNextDate);\n }, [handleMonth]);\n\n const [selectIndexes, onKeyDown, onSelectIndexes, outerRefs] = useKeyNavigation({\n isDouble: true,\n size: [11, 6],\n onNext: handleNext,\n onPrev: handlePrev,\n });\n\n const handleOnChangeDay = useCallback(\n (newDate: DateObject, coord: number[]) => {\n const newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);\n onChangeValue?.(newDay);\n\n onSelectIndexes(coord);\n },\n [onChangeValue, onSelectIndexes],\n );\n\n const firstDate = useMemo(\n () => ({\n day: date.day,\n year: doubleDate.year[0],\n monthIndex: doubleDate.monthIndex[0],\n }),\n [date, doubleDate],\n );\n\n const secondDate = useMemo(\n () => ({\n day: date.day,\n year: doubleDate.year[1],\n monthIndex: doubleDate.monthIndex[1],\n }),\n [date, doubleDate],\n );\n\n if (value && prevValue && isValueUpdate(value, prevValue)) {\n const newDate = getDateFromValue(value);\n\n const { year, monthIndex } = newDate;\n\n const {\n monthIndex: [, prevMonthIndex],\n year: [, prevYear],\n } = doubleDate;\n\n if (prevMonthIndex !== monthIndex || prevYear !== year) {\n const [nextYear, nextMonthIndex] = getNextDate(year, monthIndex);\n\n setDate(newDate);\n\n setMonths({\n monthIndex: [monthIndex, nextMonthIndex],\n year: [year, nextYear],\n });\n }\n\n setPrevValue(value);\n }\n\n return (\n <Root ref={outerRootRef} aria-label=\"Выбор даты\" {...rest}>\n <CalendarHeader\n isDouble\n firstDate={firstDate}\n secondDate={secondDate}\n onPrev={handlePrev}\n onNext={handleNext}\n />\n\n <StyledWrapper>\n <CalendarDays\n isDouble\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n value={externalValue}\n date={firstDate}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n <StyledSeparator />\n <CalendarDays\n isDouble\n isSecond\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n value={externalValue}\n date={secondDate}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n </StyledWrapper>\n </Root>\n );\n },\n );\n\nexport const calendarDoubleConfig = {\n name: 'CalendarDouble',\n tag: 'div',\n layout: calendarDoubleRoot,\n base: StyledCalendar,\n variations: {\n view: {\n css: viewCSS,\n },\n },\n defaults: {\n view: 'primary',\n size: 'm',\n },\n};\n"],"names":["calendarDoubleRoot","Root","forwardRef","_ref","outerRootRef","externalValue","value","min","max","eventList","disabledList","onChangeValue","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","Array","isArray","_useMemo2","_slicedToArray","firstValue","secondValue","_useState","useState","_useState2","hoveredDay","setHoveredDay","_useState3","getDateFromValue","_useState4","date","setDate","_useState5","_useState6","prevValue","setPrevValue","_useState7","nextDate","_getNextDate","getNextDate","year","monthIndex","_getNextDate2","initialYear","initialMonth","_useState8","doubleDate","setMonths","handleMonth","useCallback","getDate","_getDate","_getDate2","newCurrentYear","newCurrentMonth","_getDate3","_getDate4","newNextYear","newNextMonth","handlePrev","getPrevDate","handleNext","_useKeyNavigation","useKeyNavigation","isDouble","size","onNext","onPrev","_useKeyNavigation2","selectIndexes","onKeyDown","onSelectIndexes","outerRefs","handleOnChangeDay","newDate","coord","newDay","Date","day","firstDate","secondDate","isValueUpdate","_doubleDate$monthInde","prevMonthIndex","_doubleDate$year","prevYear","_getNextDate3","_getNextDate4","nextYear","nextMonthIndex","React","createElement","_extends","ref","CalendarHeader","StyledWrapper","CalendarDays","onChangeDay","onHoverDay","onSetSelected","_StyledSeparator","StyledSeparator","isSecond","calendarDoubleConfig","name","tag","layout","base","StyledCalendar","variations","view","css","viewCSS","defaults"],"mappings":";;;;;;;;;;;;;AAaA;AACA;AACA;IACaA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,IAA+D,EAAA;AAAA,EAAA,oBAC9FC,UAAU,CACN,UAAAC,IAAA,EAAsFC,YAAY,EAAK;AAAA,IAAA,IAA7FC,aAAa,GAAAF,IAAA,CAApBG,KAAK;MAAiBC,GAAG,GAAAJ,IAAA,CAAHI,GAAG;MAAEC,GAAG,GAAAL,IAAA,CAAHK,GAAG;MAAEC,SAAS,GAAAN,IAAA,CAATM,SAAS;MAAEC,YAAY,GAAAP,IAAA,CAAZO,YAAY;MAAEC,aAAa,GAAAR,IAAA,CAAbQ,aAAa;AAAKC,MAAAA,IAAI,GAAAC,wBAAA,CAAAV,IAAA,EAAAW,SAAA,CAAA,CAAA;IAC9E,IAAAC,QAAA,GAAkCC,OAAO,CACrC,YAAA;QAAA,OAAOC,KAAK,CAACC,OAAO,CAACb,aAAa,CAAC,GAAGA,aAAa,GAAG,CAACA,aAAa,CAAC,CAAA;AAAA,OAAC,EACtE,CAACA,aAAa,CAClB,CAAC;MAAAc,SAAA,GAAAC,cAAA,CAAAL,QAAA,EAAA,CAAA,CAAA;AAHMM,MAAAA,UAAU,GAAAF,SAAA,CAAA,CAAA,CAAA;AAAEG,MAAAA,WAAW,GAAAH,SAAA,CAAA,CAAA,CAAA,CAAA;AAI9B,IAAA,IAAMb,KAAK,GAAGgB,WAAW,IAAID,UAAU,CAAA;AACvC,IAAA,IAAAE,SAAA,G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rBE,MAAAA,SAAS,EAAEA,SAAAA;AAAU,KACxB,CAAC,EAAA4B,gBAAA,KAAAA,gBAAA,gBACFV,KAAA,CAAAC,aAAA,CAACU,eAAe,MAAE,CAAC,CAAA,eACnBX,KAAA,CAAAC,aAAA,CAACK,YAAY,EAAA;MACThC,QAAQ,EAAA,IAAA;MACRsC,QAAQ,EAAA,IAAA;AACR9F,MAAAA,SAAS,EAAEA,SAAU;AACrBC,MAAAA,YAAY,EAAEA,YAAa;AAC3BH,MAAAA,GAAG,EAAEA,GAAI;AACTC,MAAAA,GAAG,EAAEA,GAAI;AACTF,MAAAA,KAAK,EAAED,aAAc;AACrB0B,MAAAA,IAAI,EAAEkD,UAAW;AACjBvD,MAAAA,UAAU,EAAEA,UAAW;AACvB4C,MAAAA,aAAa,EAAEA,aAAc;AAC7B4B,MAAAA,WAAW,EAAExB,iBAAkB;AAC/ByB,MAAAA,UAAU,EAAExE,aAAc;AAC1ByE,MAAAA,aAAa,EAAE5B,eAAgB;AAC/BD,MAAAA,SAAS,EAAEA,SAAU;AACrBE,MAAAA,SAAS,EAAEA,SAAAA;KACd,CACU,CACb,CAAC,CAAA;AAEf,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAM+B,oBAAoB,GAAG;AAChCC,EAAAA,IAAI,EAAE,gBAAgB;AACtBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE3G,kBAAkB;AAC1B4G,EAAAA,IAAI,EAAEC,cAAc;AACpBC,EAAAA,UAAU,EAAE;AACRC,IAAAA,IAAI,EAAE;AACFC,MAAAA,GAAG,EAAEC,IAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNH,IAAAA,IAAI,EAAE,SAAS;AACf7C,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"CalendarDouble.js","sources":["../../../../src/components/Calendar/CalendarDouble/CalendarDouble.tsx"],"sourcesContent":["import React, { useState, useCallback, useMemo, forwardRef, HTMLAttributes } from 'react';\n\nimport type { Calendar, DateObject } from '../Calendar.types';\nimport { getDateFromValue, getNextDate, getPrevDate, isValueUpdate } from '../utils';\nimport { useKeyNavigation } from '../hooks';\nimport { CalendarDays, CalendarHeader } from '../ui';\nimport { RootProps } from '../../../engines/types';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { StyledCalendar, StyledSeparator, StyledWrapper } from './CalendarDouble.styles';\n\nexport type CalendarDoubleProps = HTMLAttributes<HTMLDivElement> & Calendar;\n\n/**\n * Компонент двойного календаря.\n */\nexport const calendarDoubleRoot = (Root: RootProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>>) =>\n forwardRef<HTMLDivElement, CalendarDoubleProps>(\n ({ value: externalValue, min, max, eventList, disabledList, onChangeValue, ...rest }, outerRootRef) => {\n const [firstValue, secondValue] = useMemo(\n () => (Array.isArray(externalValue) ? externalValue : [externalValue]),\n [externalValue],\n );\n const value = secondValue || firstValue;\n const [hoveredDay, setHoveredDay] = useState<DateObject | undefined>();\n\n const [date, setDate] = useState<DateObject>(getDateFromValue(value));\n const [prevValue, setPrevValue] = useState(value);\n const [doubleDate, setMonths] = useState(() => {\n const nextDate = getDateFromValue(firstValue);\n const [initialYear, initialMonth] = getNextDate(nextDate.year, nextDate.monthIndex);\n\n return {\n monthIndex: [nextDate.monthIndex, initialMonth],\n year: [nextDate.year, initialYear],\n };\n });\n\n const handleMonth = useCallback(\n (getDate: (currentYear: number, currentMonth: number) => number[]) => {\n const [newCurrentYear, newCurrentMonth] = getDate(doubleDate.year[0], doubleDate.monthIndex[0]);\n const [newNextYear, newNextMonth] = getDate(doubleDate.year[1], doubleDate.monthIndex[1]);\n\n setMonths({\n monthIndex: [newCurrentMonth, newNextMonth],\n year: [newCurrentYear, newNextYear],\n });\n },\n [doubleDate],\n );\n\n const handlePrev = useCallback(() => {\n handleMonth(getPrevDate);\n }, [handleMonth]);\n\n const handleNext = useCallback(() => {\n handleMonth(getNextDate);\n }, [handleMonth]);\n\n const [selectIndexes, onKeyDown, onSelectIndexes, outerRefs] = useKeyNavigation({\n isDouble: true,\n size: [11, 6],\n onNext: handleNext,\n onPrev: handlePrev,\n });\n\n const handleOnChangeDay = useCallback(\n (newDate: DateObject, coord: number[]) => {\n const newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);\n onChangeValue?.(newDay);\n\n onSelectIndexes(coord);\n },\n [onChangeValue, onSelectIndexes],\n );\n\n const firstDate = useMemo(\n () => ({\n day: date.day,\n year: doubleDate.year[0],\n monthIndex: doubleDate.monthIndex[0],\n }),\n [date, doubleDate],\n );\n\n const secondDate = useMemo(\n () => ({\n day: date.day,\n year: doubleDate.year[1],\n monthIndex: doubleDate.monthIndex[1],\n }),\n [date, doubleDate],\n );\n\n if (value && prevValue && isValueUpdate(value, prevValue)) {\n const newDate = getDateFromValue(value);\n\n const { year, monthIndex } = newDate;\n\n const {\n monthIndex: [, prevMonthIndex],\n year: [, prevYear],\n } = doubleDate;\n\n if (prevMonthIndex !== monthIndex || prevYear !== year) {\n const [nextYear, nextMonthIndex] = getNextDate(year, monthIndex);\n\n setDate(newDate);\n\n setMonths({\n monthIndex: [monthIndex, nextMonthIndex],\n year: [year, nextYear],\n });\n }\n\n setPrevValue(value);\n }\n\n return (\n <Root ref={outerRootRef} aria-label=\"Выбор даты\" {...rest}>\n <CalendarHeader\n isDouble\n firstDate={firstDate}\n secondDate={secondDate}\n onPrev={handlePrev}\n onNext={handleNext}\n />\n\n <StyledWrapper>\n <CalendarDays\n isDouble\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n value={externalValue}\n date={firstDate}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n <StyledSeparator />\n <CalendarDays\n isDouble\n isSecond\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n value={externalValue}\n date={secondDate}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n </StyledWrapper>\n </Root>\n );\n },\n );\n\nexport const calendarDoubleConfig = {\n name: 'CalendarDouble',\n tag: 'div',\n layout: calendarDoubleRoot,\n base: StyledCalendar,\n variations: {\n view: {\n css: viewCSS,\n },\n },\n defaults: {\n view: 'primary',\n size: 'm',\n },\n};\n"],"names":["calendarDoubleRoot","Root","forwardRef","_ref","outerRootRef","externalValue","value","min","max","eventList","disabledList","onChangeValue","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","Array","isArray","_useMemo2","_slicedToArray","firstValue","secondValue","_useState","useState","_useState2","hoveredDay","setHoveredDay","_useState3","getDateFromValue","_useState4","date","setDate","_useState5","_useState6","prevValue","setPrevValue","_useState7","nextDate","_getNextDate","getNextDate","year","monthIndex","_getNextDate2","initialYear","initialMonth","_useState8","doubleDate","setMonths","handleMonth","useCallback","getDate","_getDate","_getDate2","newCurrentYear","newCurrentMonth","_getDate3","_getDate4","newNextYear","newNextMonth","handlePrev","getPrevDate","handleNext","_useKeyNavigation","useKeyNavigation","isDouble","size","onNext","onPrev","_useKeyNavigation2","selectIndexes","onKeyDown","onSelectIndexes","outerRefs","handleOnChangeDay","newDate","coord","newDay","Date","day","firstDate","secondDate","isValueUpdate","_doubleDate$monthInde","prevMonthIndex","_doubleDate$year","prevYear","_getNextDate3","_getNextDate4","nextYear","nextMonthIndex","React","createElement","_extends","ref","CalendarHeader","StyledWrapper","CalendarDays","onChangeDay","onHoverDay","onSetSelected","_StyledSeparator","StyledSeparator","isSecond","calendarDoubleConfig","name","tag","layout","base","StyledCalendar","variations","view","css","viewCSS","defaults"],"mappings":";;;;;;;;;;;;;AAaA;AACA;AACA;IACaA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAI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TF,MAAAA,KAAK,EAAED,aAAc;AACrB0B,MAAAA,IAAI,EAAEkD,UAAW;AACjBvD,MAAAA,UAAU,EAAEA,UAAW;AACvB4C,MAAAA,aAAa,EAAEA,aAAc;AAC7B4B,MAAAA,WAAW,EAAExB,iBAAkB;AAC/ByB,MAAAA,UAAU,EAAExE,aAAc;AAC1ByE,MAAAA,aAAa,EAAE5B,eAAgB;AAC/BD,MAAAA,SAAS,EAAEA,SAAU;AACrBE,MAAAA,SAAS,EAAEA,SAAAA;KACd,CACU,CACb,CAAC,CAAA;AAEf,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAM+B,oBAAoB,GAAG;AAChCC,EAAAA,IAAI,EAAE,gBAAgB;AACtBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE3G,kBAAkB;AAC1B4G,EAAAA,IAAI,EAAEC,cAAc;AACpBC,EAAAA,UAAU,EAAE;AACRC,IAAAA,IAAI,EAAE;AACFC,MAAAA,GAAG,EAAEC,IAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNH,IAAAA,IAAI,EAAE,SAAS;AACf7C,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
|
@@ -40,7 +40,7 @@ var withRange = function withRange(Component) {
|
|
40
40
|
var handleOnChangeDay = useCallback(function (newDay) {
|
41
41
|
if (endValue) {
|
42
42
|
setValues([newDay, undefined]);
|
43
|
-
onChangeStartOfRange === null || onChangeStartOfRange === void 0
|
43
|
+
onChangeStartOfRange === null || onChangeStartOfRange === void 0 ? void 0 : onChangeStartOfRange(newDay);
|
44
44
|
return;
|
45
45
|
}
|
46
46
|
setValues([startValue, newDay]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"withRange.js","sources":["../../../../src/components/Calendar/hoc/withRange.tsx"],"sourcesContent":["import React, { useMemo, useState, useCallback, ReactElement } from 'react';\n\nimport type { Calendar, CalendarRange } from '../Calendar.types';\nimport { getSortedValues, isValueUpdate } from '../utils';\n\n/**\n * HOC для календаря, дающий возможность выбора диапазона даты\n */\nexport const withRange = <T extends Calendar>(Component: React.FC<Calendar>) => ({\n value,\n disabledList,\n eventList,\n min,\n max,\n onChangeValue,\n onChangeStartOfRange,\n ...rest\n}: CalendarRange<T>): ReactElement<T> => {\n const [startExternalValue, endExternalValue] = useMemo(() => value, [value]);\n const [[startValue, endValue], setValues] = useState<[Date, Date?]>([startExternalValue, endExternalValue]);\n const [prevValue, setPrevValue] = useState(value);\n\n if (isValueUpdate(value, prevValue)) {\n setValues([startExternalValue, endExternalValue]);\n\n setPrevValue(value);\n }\n\n const handleOnChangeDay = useCallback(\n (newDay: Date) => {\n if (endValue) {\n setValues([newDay, undefined]);\n\n onChangeStartOfRange?.(newDay);\n\n return;\n }\n\n setValues([startValue, newDay]);\n\n const [first, second] = getSortedValues([startValue, newDay]);\n\n if (first) {\n onChangeValue([first, second]);\n }\n },\n [onChangeValue, onChangeStartOfRange, startValue, endValue],\n );\n\n return (\n <Component\n value={[startValue, endValue]}\n onChangeValue={handleOnChangeDay}\n disabledList={disabledList}\n eventList={eventList}\n min={min}\n max={max}\n {...rest}\n />\n );\n};\n"],"names":["withRange","Component","_ref","value","disabledList","eventList","min","max","onChangeValue","onChangeStartOfRange","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","_useMemo2","_slicedToArray","startExternalValue","endExternalValue","_useState","useState","_useState2","_useState2$","startValue","endValue","setValues","_useState3","_useState4","prevValue","setPrevValue","isValueUpdate","handleOnChangeDay","useCallback","newDay","undefined","_getSortedValues","getSortedValues","_getSortedValues2","first","second","React","createElement","_extends"],"mappings":";;;;;;AAKA;AACA;AACA;IACaA,SAAS,GAAG,SAAZA,SAASA,CAAwBC,SAA6B,EAAA;EAAA,OAAK,UAAAC,IAAA,EASvC;AAAA,IAAA,IARrCC,KAAK,GAAAD,IAAA,CAALC,KAAK;MACLC,YAAY,GAAAF,IAAA,CAAZE,YAAY;MACZC,SAAS,GAA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AA,SAAS,CAAC,CAACR,kBAAkB,EAAEC,gBAAgB,CAAC,CAAC,CAAA;MAEjDW,YAAY,CAAC1B,KAAK,CAAC,CAAA;AACvB,KAAA;AAEA,IAAA,IAAM4B,iBAAiB,GAAGC,WAAW,CACjC,UAACC,MAAY,EAAK;AACd,MAAA,IAAIT,QAAQ,EAAE;AACVC,QAAAA,SAAS,CAAC,CAACQ,MAAM,EAAEC,SAAS,CAAC,CAAC,CAAA;AAE9BzB,QAAAA,oBAAoB,aAApBA,oBAAoB,KAAA,KAAA,CAAA,
|
1
|
+
{"version":3,"file":"withRange.js","sources":["../../../../src/components/Calendar/hoc/withRange.tsx"],"sourcesContent":["import React, { useMemo, useState, useCallback, ReactElement } from 'react';\n\nimport type { Calendar, CalendarRange } from '../Calendar.types';\nimport { getSortedValues, isValueUpdate } from '../utils';\n\n/**\n * HOC для календаря, дающий возможность выбора диапазона даты\n */\nexport const withRange = <T extends Calendar>(Component: React.FC<Calendar>) => ({\n value,\n disabledList,\n eventList,\n min,\n max,\n onChangeValue,\n onChangeStartOfRange,\n ...rest\n}: CalendarRange<T>): ReactElement<T> => {\n const [startExternalValue, endExternalValue] = useMemo(() => value, [value]);\n const [[startValue, endValue], setValues] = useState<[Date, Date?]>([startExternalValue, endExternalValue]);\n const [prevValue, setPrevValue] = useState(value);\n\n if (isValueUpdate(value, prevValue)) {\n setValues([startExternalValue, endExternalValue]);\n\n setPrevValue(value);\n }\n\n const handleOnChangeDay = useCallback(\n (newDay: Date) => {\n if (endValue) {\n setValues([newDay, undefined]);\n\n onChangeStartOfRange?.(newDay);\n\n return;\n }\n\n setValues([startValue, newDay]);\n\n const [first, second] = getSortedValues([startValue, newDay]);\n\n if (first) {\n onChangeValue([first, second]);\n }\n },\n [onChangeValue, onChangeStartOfRange, startValue, endValue],\n );\n\n return (\n <Component\n value={[startValue, endValue]}\n onChangeValue={handleOnChangeDay}\n disabledList={disabledList}\n eventList={eventList}\n min={min}\n max={max}\n {...rest}\n />\n );\n};\n"],"names":["withRange","Component","_ref","value","disabledList","eventList","min","max","onChangeValue","onChangeStartOfRange","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","_useMemo2","_slicedToArray","startExternalValue","endExternalValue","_useState","useState","_useState2","_useState2$","startValue","endValue","setValues","_useState3","_useState4","prevValue","setPrevValue","isValueUpdate","handleOnChangeDay","useCallback","newDay","undefined","_getSortedValues","getSortedValues","_getSortedValues2","first","second","React","createElement","_extends"],"mappings":";;;;;;AAKA;AACA;AACA;IACaA,SAAS,GAAG,SAAZA,SAASA,CAAwBC,SAA6B,EAAA;EAAA,OAAK,UAAAC,IAAA,EASvC;AAAA,IAAA,IARrCC,KAAK,GAAAD,IAAA,CAALC,KAAK;MACLC,YAAY,GAAAF,IAAA,CAAZE,YAAY;MACZC,SAAS,GAAAH,IAAA,CAATG,SAAS;MACTC,GAAG,GAAAJ,IAAA,CAAHI,GAAG;MACHC,GAAG,GAAAL,IAAA,CAAHK,GAAG;MACHC,aAAa,GAAAN,IAAA,CAAbM,aAAa;MACbC,oBAAoB,GAAAP,IAAA,CAApBO,oBAAoB;AACjBC,MAAAA,IAAI,GAAAC,wBAAA,CAAAT,IAAA,EAAAU,SAAA,CAAA,CAAA;IAEP,IAAAC,QAAA,GAA+CC,OAAO,CAAC,YAAA;AAAA,QAAA,OAAMX,KAAK,CAAA;OAAE,EAAA,CAACA,KAAK,CAAC,CAAC;MAAAY,SAAA,GAAAC,cAAA,CAAAH,QAAA,EAAA,CAAA,CAAA;AAArEI,MAAAA,kBAAkB,GAAAF,SAAA,CAAA,CAAA,CAAA;AAAEG,MAAAA,gBAAgB,GAAAH,SAAA,CAAA,CAAA,CAAA,CAAA;IAC3C,IAAAI,SAAA,GAA4CC,QAAQ,CAAgB,CAACH,kBAAkB,EAAEC,gBAAgB,CAAC,CAAC;MAAAG,UAAA,GAAAL,cAAA,CAAAG,SAAA,EAAA,CAAA,CAAA;MAAAG,WAAA,GAAAN,cAAA,CAAAK,UAAA,CAAA,CA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