@skbkontur/react-ui 0.0.0-95a1dbe516 → 0.0.0-9ab4f802f3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +120 -0
- package/README.md +41 -13
- package/cjs/components/Autocomplete/Autocomplete.js +12 -6
- package/cjs/components/Autocomplete/Autocomplete.js.map +1 -1
- package/cjs/components/Autocomplete/Autocomplete.md +76 -3
- package/cjs/components/Autocomplete/Autocomplete.styles.d.ts +1 -0
- package/cjs/components/Autocomplete/Autocomplete.styles.js +7 -1
- package/cjs/components/Autocomplete/Autocomplete.styles.js.map +1 -1
- package/cjs/components/Button/Button.js +2 -2
- package/cjs/components/Button/Button.js.map +1 -1
- package/cjs/components/Button/Button.md +38 -11
- package/cjs/components/Calendar/Calendar.d.ts +28 -5
- package/cjs/components/Calendar/Calendar.js +80 -36
- package/cjs/components/Calendar/Calendar.js.map +1 -1
- package/cjs/components/Calendar/Calendar.md +82 -1
- package/cjs/components/Calendar/Calendar.styles.js +1 -1
- package/cjs/components/Calendar/Calendar.styles.js.map +1 -1
- package/cjs/components/Calendar/CalendarContext.d.ts +12 -0
- package/cjs/components/Calendar/CalendarContext.js +16 -0
- package/cjs/components/Calendar/CalendarContext.js.map +1 -0
- package/cjs/components/Calendar/CalendarDateShape.d.ts +4 -2
- package/cjs/components/Calendar/CalendarDateShape.js +13 -3
- package/cjs/components/Calendar/CalendarDateShape.js.map +1 -1
- package/cjs/components/Calendar/CalendarDay.d.ts +12 -0
- package/cjs/components/Calendar/CalendarDay.js +79 -0
- package/cjs/components/Calendar/CalendarDay.js.map +1 -0
- package/cjs/components/Calendar/CalendarDay.md +70 -0
- package/cjs/components/Calendar/CalendarUtils.d.ts +2 -1
- package/cjs/components/Calendar/CalendarUtils.js +4 -6
- package/cjs/components/Calendar/CalendarUtils.js.map +1 -1
- package/cjs/components/Calendar/DayCellView.d.ts +4 -12
- package/cjs/components/Calendar/DayCellView.js +20 -42
- package/cjs/components/Calendar/DayCellView.js.map +1 -1
- package/cjs/components/Calendar/DayCellView.styles.d.ts +2 -5
- package/cjs/components/Calendar/DayCellView.styles.js +37 -43
- package/cjs/components/Calendar/DayCellView.styles.js.map +1 -1
- package/cjs/components/Calendar/Month.d.ts +0 -10
- package/cjs/components/Calendar/Month.js +36 -88
- package/cjs/components/Calendar/Month.js.map +1 -1
- package/cjs/components/Calendar/MonthView.d.ts +3 -2
- package/cjs/components/Calendar/MonthView.js +47 -37
- package/cjs/components/Calendar/MonthView.js.map +1 -1
- package/cjs/components/Calendar/MonthView.styles.d.ts +3 -0
- package/cjs/components/Calendar/MonthView.styles.js +45 -7
- package/cjs/components/Calendar/MonthView.styles.js.map +1 -1
- package/cjs/components/Calendar/MonthViewModel.js +24 -6
- package/cjs/components/Calendar/MonthViewModel.js.map +1 -1
- package/cjs/components/Calendar/config.js +12 -6
- package/cjs/components/Calendar/config.js.map +1 -1
- package/cjs/components/Calendar/index.d.ts +1 -0
- package/cjs/components/Calendar/index.js +2 -1
- package/cjs/components/Calendar/index.js.map +1 -1
- package/cjs/components/Checkbox/Checkbox.js +1 -1
- package/cjs/components/Checkbox/Checkbox.js.map +1 -1
- package/cjs/components/DateInput/DateFragmentsView.js +1 -1
- package/cjs/components/DateInput/DateFragmentsView.js.map +1 -1
- package/cjs/components/DateInput/DateInput.js +1 -1
- package/cjs/components/DateInput/DateInput.js.map +1 -1
- package/cjs/components/DatePicker/DatePicker.d.ts +4 -1
- package/cjs/components/DatePicker/DatePicker.js +72 -45
- package/cjs/components/DatePicker/DatePicker.js.map +1 -1
- package/cjs/components/DatePicker/DatePicker.md +29 -1
- package/cjs/components/DatePicker/DatePickerHelpers.js +2 -1
- package/cjs/components/DatePicker/DatePickerHelpers.js.map +1 -1
- package/cjs/components/DatePicker/MobilePicker.d.ts +10 -0
- package/cjs/components/DatePicker/MobilePicker.js +118 -0
- package/cjs/components/DatePicker/MobilePicker.js.map +1 -0
- package/cjs/components/DatePicker/MobilePicker.styles.d.ts +3 -0
- package/cjs/components/DatePicker/MobilePicker.styles.js +8 -0
- package/cjs/components/DatePicker/MobilePicker.styles.js.map +1 -0
- package/cjs/components/DatePicker/Picker.js +1 -1
- package/cjs/components/DatePicker/Picker.js.map +1 -1
- package/cjs/components/DatePicker/getMobilePickerTheme.d.ts +2 -0
- package/cjs/components/DatePicker/getMobilePickerTheme.js +19 -0
- package/cjs/components/DatePicker/getMobilePickerTheme.js.map +1 -0
- package/cjs/components/Dropdown/Dropdown.js +1 -1
- package/cjs/components/Dropdown/Dropdown.js.map +1 -1
- package/cjs/components/DropdownMenu/DropdownMenu.js +1 -1
- package/cjs/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/cjs/components/DropdownMenu/DropdownMenu.md +39 -0
- package/cjs/components/FileUploader/FileUploader.d.ts +2 -0
- package/cjs/components/FileUploader/FileUploader.js +32 -9
- package/cjs/components/FileUploader/FileUploader.js.map +1 -1
- package/cjs/components/FileUploader/FileUploader.md +29 -0
- package/cjs/components/FxInput/FxInput.js +1 -1
- package/cjs/components/FxInput/FxInput.js.map +1 -1
- package/cjs/components/Group/Group.js +1 -1
- package/cjs/components/Group/Group.js.map +1 -1
- package/cjs/components/Hint/Hint.d.ts +4 -3
- package/cjs/components/Hint/Hint.js +9 -8
- package/cjs/components/Hint/Hint.js.map +1 -1
- package/cjs/components/Input/Input.js +1 -1
- package/cjs/components/Input/Input.js.map +1 -1
- package/cjs/components/Input/Input.styles.d.ts +1 -1
- package/cjs/components/Input/Input.styles.js +3 -2
- package/cjs/components/Input/Input.styles.js.map +1 -1
- package/cjs/components/Input/InputLayout/InputLayout.styles.d.ts +1 -1
- package/cjs/components/Input/InputLayout/InputLayout.styles.js +3 -2
- package/cjs/components/Input/InputLayout/InputLayout.styles.js.map +1 -1
- package/cjs/components/Input/InputLayout/InputLayoutAsideIcon.js +1 -1
- package/cjs/components/Input/InputLayout/InputLayoutAsideIcon.js.map +1 -1
- package/cjs/components/Kebab/Kebab.js +6 -1
- package/cjs/components/Kebab/Kebab.js.map +1 -1
- package/cjs/components/Link/Link.js +3 -2
- package/cjs/components/Link/Link.js.map +1 -1
- package/cjs/components/Loader/Loader.js +1 -1
- package/cjs/components/Loader/Loader.js.map +1 -1
- package/cjs/components/MenuItem/MenuItem.js +2 -2
- package/cjs/components/MenuItem/MenuItem.js.map +1 -1
- package/cjs/components/MiniModal/MiniModal.js +1 -1
- package/cjs/components/MiniModal/MiniModal.js.map +1 -1
- package/cjs/components/Modal/Modal.js +1 -1
- package/cjs/components/Modal/Modal.js.map +1 -1
- package/cjs/components/Modal/ModalBody.js +1 -1
- package/cjs/components/Modal/ModalBody.js.map +1 -1
- package/cjs/components/Paging/Paging.js +8 -3
- package/cjs/components/Paging/Paging.js.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.js +1 -1
- package/cjs/components/PasswordInput/PasswordInput.js.map +1 -1
- package/cjs/components/Radio/Radio.js +1 -1
- package/cjs/components/Radio/Radio.js.map +1 -1
- package/cjs/components/RadioGroup/RadioGroup.js +10 -1
- package/cjs/components/RadioGroup/RadioGroup.js.map +1 -1
- package/cjs/components/ScrollContainer/ScrollBar.js +1 -1
- package/cjs/components/ScrollContainer/ScrollBar.js.map +1 -1
- package/cjs/components/ScrollContainer/ScrollContainer.d.ts +1 -0
- package/cjs/components/ScrollContainer/ScrollContainer.js +6 -0
- package/cjs/components/ScrollContainer/ScrollContainer.js.map +1 -1
- package/cjs/components/Select/Select.js +6 -3
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/SidePage/SidePage.js +1 -1
- package/cjs/components/SidePage/SidePage.js.map +1 -1
- package/cjs/components/SidePage/SidePageBody.js +1 -1
- package/cjs/components/SidePage/SidePageBody.js.map +1 -1
- package/cjs/components/SidePage/SidePageContainer.js +1 -1
- package/cjs/components/SidePage/SidePageContainer.js.map +1 -1
- package/cjs/components/SidePage/SidePageFooter.js +1 -1
- package/cjs/components/SidePage/SidePageFooter.js.map +1 -1
- package/cjs/components/SidePage/SidePageHeader.js +1 -1
- package/cjs/components/SidePage/SidePageHeader.js.map +1 -1
- package/cjs/components/Spinner/Spinner.js +1 -1
- package/cjs/components/Spinner/Spinner.js.map +1 -1
- package/cjs/components/Switcher/Switcher.js +1 -1
- package/cjs/components/Switcher/Switcher.js.map +1 -1
- package/cjs/components/Tabs/Indicator.js +1 -1
- package/cjs/components/Tabs/Indicator.js.map +1 -1
- package/cjs/components/Tabs/Tab.js +2 -2
- package/cjs/components/Tabs/Tab.js.map +1 -1
- package/cjs/components/Tabs/Tabs.js +1 -1
- package/cjs/components/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/Toast/Toast.js +1 -1
- package/cjs/components/Toast/Toast.js.map +1 -1
- package/cjs/components/Toast/ToastView.js +1 -1
- package/cjs/components/Toast/ToastView.js.map +1 -1
- package/cjs/components/Toggle/Toggle.js +1 -1
- package/cjs/components/Toggle/Toggle.js.map +1 -1
- package/cjs/components/Token/Token.js +2 -1
- package/cjs/components/Token/Token.js.map +1 -1
- package/cjs/components/TokenInput/TokenInput.js +1 -1
- package/cjs/components/TokenInput/TokenInput.js.map +1 -1
- package/cjs/components/TokenInput/TokenInputMenu.js +2 -2
- package/cjs/components/TokenInput/TokenInputMenu.js.map +1 -1
- package/cjs/components/Tooltip/Tooltip.d.ts +10 -5
- package/cjs/components/Tooltip/Tooltip.js +59 -20
- package/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/cjs/components/TooltipMenu/TooltipMenu.js +4 -4
- package/cjs/components/TooltipMenu/TooltipMenu.js.map +1 -1
- package/cjs/hooks/useDrop.d.ts +1 -1
- package/cjs/hooks/useDrop.js.map +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/cjs/internal/CommonWrapper/CommonWrapper.js +2 -2
- package/cjs/internal/CommonWrapper/CommonWrapper.js.map +1 -1
- package/cjs/internal/CommonWrapper/{extractCommonProps.d.ts → utils/extractCommonProps.d.ts} +2 -2
- package/cjs/internal/CommonWrapper/utils/extractCommonProps.js.map +1 -0
- package/cjs/internal/CommonWrapper/{getCommonVisualStateDataAttributes.js → utils/getCommonVisualStateDataAttributes.js} +3 -4
- package/cjs/internal/CommonWrapper/utils/getCommonVisualStateDataAttributes.js.map +1 -0
- package/cjs/internal/CommonWrapper/{getVisualStateDataAttributes.d.ts → utils/getVisualStateDataAttributes.d.ts} +1 -1
- package/cjs/internal/CommonWrapper/{getVisualStateDataAttributes.js → utils/getVisualStateDataAttributes.js} +3 -3
- package/cjs/internal/CommonWrapper/utils/getVisualStateDataAttributes.js.map +1 -0
- package/cjs/internal/CommonWrapper/utils/tryGetBoolean.d.ts +1 -0
- package/cjs/internal/CommonWrapper/utils/tryGetBoolean.js +1 -0
- package/cjs/internal/CommonWrapper/utils/tryGetBoolean.js.map +1 -0
- package/cjs/internal/CustomComboBox/ComboBoxMenu.js +2 -3
- package/cjs/internal/CustomComboBox/ComboBoxMenu.js.map +1 -1
- package/cjs/internal/CustomComboBox/ComboBoxView.js +3 -1
- package/cjs/internal/CustomComboBox/ComboBoxView.js.map +1 -1
- package/cjs/internal/DateSelect/DateSelect.d.ts +2 -0
- package/cjs/internal/DateSelect/DateSelect.js +51 -4
- package/cjs/internal/DateSelect/DateSelect.js.map +1 -1
- package/cjs/internal/DateSelect/DateSelect.styles.d.ts +1 -0
- package/cjs/internal/DateSelect/DateSelect.styles.js +15 -1
- package/cjs/internal/DateSelect/DateSelect.styles.js.map +1 -1
- package/cjs/internal/DateSelect/locale/locales/en.js +2 -1
- package/cjs/internal/DateSelect/locale/locales/en.js.map +1 -1
- package/cjs/internal/DateSelect/locale/locales/ru.js +2 -1
- package/cjs/internal/DateSelect/locale/locales/ru.js.map +1 -1
- package/cjs/internal/DateSelect/locale/types.d.ts +1 -0
- package/cjs/internal/FileUploaderControl/FileUploaderControlProvider.d.ts +5 -2
- package/cjs/internal/FileUploaderControl/FileUploaderControlProvider.js +16 -3
- package/cjs/internal/FileUploaderControl/FileUploaderControlProvider.js.map +1 -1
- package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.d.ts +1 -0
- package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.js +4 -2
- package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.js.map +1 -1
- package/cjs/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.d.ts +1 -0
- package/cjs/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.js +3 -2
- package/cjs/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.js.map +1 -1
- package/cjs/internal/InputLikeText/InputLikeText.js +2 -2
- package/cjs/internal/InputLikeText/InputLikeText.js.map +1 -1
- package/cjs/internal/InternalMaskedInput/InternalMaskedInput.js +1 -1
- package/cjs/internal/InternalMaskedInput/InternalMaskedInput.js.map +1 -1
- package/cjs/internal/InternalMenu/InternalMenu.js +2 -2
- package/cjs/internal/InternalMenu/InternalMenu.js.map +1 -1
- package/cjs/internal/Menu/Menu.js +2 -2
- package/cjs/internal/Menu/Menu.js.map +1 -1
- package/cjs/internal/MobilePopup/MobilePopup.d.ts +4 -0
- package/cjs/internal/MobilePopup/MobilePopup.js +7 -1
- package/cjs/internal/MobilePopup/MobilePopup.js.map +1 -1
- package/cjs/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.d.ts +7 -0
- package/cjs/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.js +32 -0
- package/cjs/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.js.map +1 -0
- package/cjs/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles.d.ts +4 -0
- package/cjs/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles.js +15 -0
- package/cjs/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles.js.map +1 -0
- package/cjs/internal/MobilePopup/MobilePopupFooter/index.d.ts +1 -0
- package/cjs/internal/MobilePopup/MobilePopupFooter/index.js +1 -0
- package/cjs/internal/MobilePopup/MobilePopupFooter/index.js.map +1 -0
- package/cjs/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.js +1 -1
- package/cjs/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.js.map +1 -1
- package/cjs/internal/NativeDateInput/utils.js +3 -2
- package/cjs/internal/NativeDateInput/utils.js.map +1 -1
- package/cjs/internal/Popup/Popup.d.ts +15 -4
- package/cjs/internal/Popup/Popup.js +67 -4
- package/cjs/internal/Popup/Popup.js.map +1 -1
- package/cjs/internal/PopupMenu/PopupMenu.js +1 -1
- package/cjs/internal/PopupMenu/PopupMenu.js.map +1 -1
- package/cjs/internal/RenderContainer/RenderContainer.d.ts +3 -0
- package/cjs/internal/RenderContainer/RenderContainer.js +34 -24
- package/cjs/internal/RenderContainer/RenderContainer.js.map +1 -1
- package/cjs/internal/RenderContainer/RenderInnerContainer.js +8 -4
- package/cjs/internal/RenderContainer/RenderInnerContainer.js.map +1 -1
- package/cjs/internal/RenderLayer/RenderLayer.js +5 -1
- package/cjs/internal/RenderLayer/RenderLayer.js.map +1 -1
- package/cjs/internal/ThemePlayground/Playground.js +1 -1
- package/cjs/internal/ThemePlayground/Playground.js.map +1 -1
- package/cjs/internal/ThemePlayground/ThemeContextPlayground.js +9 -6
- package/cjs/internal/ThemePlayground/ThemeContextPlayground.js.map +1 -1
- package/cjs/internal/ThemePlayground/constants.js +2 -1
- package/cjs/internal/ThemePlayground/constants.js.map +1 -1
- package/cjs/internal/ThemeShowcase/ThemeShowcase.js +1 -1
- package/cjs/internal/ThemeShowcase/ThemeShowcase.js.map +1 -1
- package/cjs/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
- package/cjs/internal/ZIndex/ZIndex.d.ts +7 -3
- package/cjs/internal/ZIndex/ZIndex.js +41 -3
- package/cjs/internal/ZIndex/ZIndex.js.map +1 -1
- package/cjs/internal/themes/DarkTheme.d.ts +2 -0
- package/cjs/internal/themes/DarkTheme.js +6 -1
- package/cjs/internal/themes/DarkTheme.js.map +1 -1
- package/cjs/internal/themes/DefaultTheme.d.ts +18 -0
- package/cjs/internal/themes/DefaultTheme.js +32 -4
- package/cjs/internal/themes/DefaultTheme.js.map +1 -1
- package/cjs/lib/date/InternalDate.d.ts +2 -0
- package/cjs/lib/date/InternalDate.js +8 -1
- package/cjs/lib/date/InternalDate.js.map +1 -1
- package/cjs/lib/date/InternalDateTransformer.d.ts +3 -0
- package/cjs/lib/date/InternalDateTransformer.js +23 -0
- package/cjs/lib/date/InternalDateTransformer.js.map +1 -1
- package/cjs/lib/date/InternalDateValidator.js +2 -1
- package/cjs/lib/date/InternalDateValidator.js.map +1 -1
- package/cjs/lib/date/comparison.d.ts +6 -0
- package/cjs/lib/date/comparison.js +44 -0
- package/cjs/lib/date/comparison.js.map +1 -0
- package/cjs/lib/featureFlagsContext/FEATUREFLAGSCONTEXT.md +24 -0
- package/cjs/lib/featureFlagsContext/FeatureFlagsHelpers.d.ts +1 -0
- package/cjs/lib/featureFlagsContext/ReactUIFeatureFlagsContext.d.ts +1 -0
- package/cjs/lib/featureFlagsContext/ReactUIFeatureFlagsContext.js +3 -1
- package/cjs/lib/featureFlagsContext/ReactUIFeatureFlagsContext.js.map +1 -1
- package/cjs/lib/listenFocusOutside.js +4 -2
- package/cjs/lib/listenFocusOutside.js.map +1 -1
- package/cjs/lib/locale/constants.d.ts +3 -0
- package/cjs/lib/locale/constants.js +6 -2
- package/cjs/lib/locale/constants.js.map +1 -1
- package/cjs/lib/taskWithDelayAndMinimalDuration.js +1 -0
- package/cjs/lib/taskWithDelayAndMinimalDuration.js.map +1 -1
- package/cjs/lib/theming/Emotion.d.ts +7 -1
- package/cjs/lib/theming/Emotion.js +6 -3
- package/cjs/lib/theming/Emotion.js.map +1 -1
- package/cjs/lib/theming/ThemeContext.d.ts +0 -2
- package/cjs/lib/theming/ThemeContext.js +1 -3
- package/cjs/lib/theming/ThemeContext.js.map +1 -1
- package/cjs/lib/theming/ThemeContext.md +3 -1
- package/cjs/lib/theming/themes/Theme2022DarkUpdate2024.d.ts +30 -0
- package/cjs/lib/theming/themes/Theme2022DarkUpdate2024.js +50 -0
- package/cjs/lib/theming/themes/Theme2022DarkUpdate2024.js.map +1 -0
- package/cjs/lib/theming/themes/Theme2022Update2024.d.ts +46 -0
- package/cjs/lib/theming/themes/Theme2022Update2024.js +75 -0
- package/cjs/lib/theming/themes/Theme2022Update2024.js.map +1 -0
- package/cjs/lib/widgets/StylesContainer.d.ts +13 -0
- package/cjs/lib/widgets/StylesContainer.js +70 -0
- package/cjs/lib/widgets/StylesContainer.js.map +1 -0
- package/cjs/lib/widgets/index.d.ts +1 -0
- package/cjs/lib/widgets/index.js +1 -0
- package/cjs/lib/widgets/index.js.map +1 -0
- package/components/Autocomplete/Autocomplete/Autocomplete.js +11 -5
- package/components/Autocomplete/Autocomplete/Autocomplete.js.map +1 -1
- package/components/Autocomplete/Autocomplete.md +76 -3
- package/components/Autocomplete/Autocomplete.styles/Autocomplete.styles.js +4 -1
- package/components/Autocomplete/Autocomplete.styles/Autocomplete.styles.js.map +1 -1
- package/components/Autocomplete/Autocomplete.styles.d.ts +1 -0
- package/components/Button/Button/Button.js +3 -3
- package/components/Button/Button/Button.js.map +1 -1
- package/components/Button/Button.md +38 -11
- package/components/Calendar/Calendar/Calendar.js +83 -66
- package/components/Calendar/Calendar/Calendar.js.map +1 -1
- package/components/Calendar/Calendar.d.ts +28 -5
- package/components/Calendar/Calendar.md +82 -1
- package/components/Calendar/Calendar.styles/Calendar.styles.js +1 -1
- package/components/Calendar/Calendar.styles/Calendar.styles.js.map +1 -1
- package/components/Calendar/CalendarContext/CalendarContext.js +2 -0
- package/components/Calendar/CalendarContext/CalendarContext.js.map +1 -0
- package/components/Calendar/CalendarContext/package.json +6 -0
- package/components/Calendar/CalendarContext.d.ts +12 -0
- package/components/Calendar/CalendarDateShape/CalendarDateShape.js +23 -1
- package/components/Calendar/CalendarDateShape/CalendarDateShape.js.map +1 -1
- package/components/Calendar/CalendarDateShape.d.ts +4 -2
- package/components/Calendar/CalendarDay/CalendarDay.js +64 -0
- package/components/Calendar/CalendarDay/CalendarDay.js.map +1 -0
- package/components/Calendar/CalendarDay/package.json +6 -0
- package/components/Calendar/CalendarDay.d.ts +12 -0
- package/components/Calendar/CalendarDay.md +70 -0
- package/components/Calendar/CalendarUtils/CalendarUtils.js +5 -4
- package/components/Calendar/CalendarUtils/CalendarUtils.js.map +1 -1
- package/components/Calendar/CalendarUtils.d.ts +2 -1
- package/components/Calendar/DayCellView/DayCellView.js +33 -46
- package/components/Calendar/DayCellView/DayCellView.js.map +1 -1
- package/components/Calendar/DayCellView.d.ts +4 -12
- package/components/Calendar/DayCellView.styles/DayCellView.styles.js +10 -14
- package/components/Calendar/DayCellView.styles/DayCellView.styles.js.map +1 -1
- package/components/Calendar/DayCellView.styles.d.ts +2 -5
- package/components/Calendar/Month/Month.js +50 -84
- package/components/Calendar/Month/Month.js.map +1 -1
- package/components/Calendar/Month.d.ts +0 -10
- package/components/Calendar/MonthView/MonthView.js +50 -45
- package/components/Calendar/MonthView/MonthView.js.map +1 -1
- package/components/Calendar/MonthView.d.ts +3 -2
- package/components/Calendar/MonthView.styles/MonthView.styles.js +20 -6
- package/components/Calendar/MonthView.styles/MonthView.styles.js.map +1 -1
- package/components/Calendar/MonthView.styles.d.ts +3 -0
- package/components/Calendar/MonthViewModel/MonthViewModel.js +9 -6
- package/components/Calendar/MonthViewModel/MonthViewModel.js.map +1 -1
- package/components/Calendar/config/config.js +6 -4
- package/components/Calendar/config/config.js.map +1 -1
- package/components/Calendar/index/index.js +2 -1
- package/components/Calendar/index/index.js.map +1 -1
- package/components/Calendar/index.d.ts +1 -0
- package/components/Checkbox/Checkbox/Checkbox.js +2 -2
- package/components/Checkbox/Checkbox/Checkbox.js.map +1 -1
- package/components/DateInput/DateFragmentsView/DateFragmentsView.js +2 -2
- package/components/DateInput/DateFragmentsView/DateFragmentsView.js.map +1 -1
- package/components/DateInput/DateInput/DateInput.js +2 -2
- package/components/DateInput/DateInput/DateInput.js.map +1 -1
- package/components/DatePicker/DatePicker/DatePicker.js +62 -41
- package/components/DatePicker/DatePicker/DatePicker.js.map +1 -1
- package/components/DatePicker/DatePicker.d.ts +4 -1
- package/components/DatePicker/DatePicker.md +29 -1
- package/components/DatePicker/DatePickerHelpers/DatePickerHelpers.js +2 -1
- package/components/DatePicker/DatePickerHelpers/DatePickerHelpers.js.map +1 -1
- package/components/DatePicker/MobilePicker/MobilePicker.js +91 -0
- package/components/DatePicker/MobilePicker/MobilePicker.js.map +1 -0
- package/components/DatePicker/MobilePicker/package.json +6 -0
- package/components/DatePicker/MobilePicker.d.ts +10 -0
- package/components/DatePicker/MobilePicker.styles/MobilePicker.styles.js +10 -0
- package/components/DatePicker/MobilePicker.styles/MobilePicker.styles.js.map +1 -0
- package/components/DatePicker/MobilePicker.styles/package.json +6 -0
- package/components/DatePicker/MobilePicker.styles.d.ts +3 -0
- package/components/DatePicker/Picker/Picker.js +3 -3
- package/components/DatePicker/Picker/Picker.js.map +1 -1
- package/components/DatePicker/getMobilePickerTheme/getMobilePickerTheme.js +14 -0
- package/components/DatePicker/getMobilePickerTheme/getMobilePickerTheme.js.map +1 -0
- package/components/DatePicker/getMobilePickerTheme/package.json +6 -0
- package/components/DatePicker/getMobilePickerTheme.d.ts +2 -0
- package/components/Dropdown/Dropdown/Dropdown.js +3 -3
- package/components/Dropdown/Dropdown/Dropdown.js.map +1 -1
- package/components/DropdownMenu/DropdownMenu/DropdownMenu.js +3 -3
- package/components/DropdownMenu/DropdownMenu/DropdownMenu.js.map +1 -1
- package/components/DropdownMenu/DropdownMenu.md +39 -0
- package/components/FileUploader/FileUploader/FileUploader.js +30 -8
- package/components/FileUploader/FileUploader/FileUploader.js.map +1 -1
- package/components/FileUploader/FileUploader.d.ts +2 -0
- package/components/FileUploader/FileUploader.md +29 -0
- package/components/FxInput/FxInput/FxInput.js +2 -2
- package/components/FxInput/FxInput/FxInput.js.map +1 -1
- package/components/Group/Group/Group.js +2 -2
- package/components/Group/Group/Group.js.map +1 -1
- package/components/Hint/Hint/Hint.js +53 -48
- package/components/Hint/Hint/Hint.js.map +1 -1
- package/components/Hint/Hint.d.ts +4 -3
- package/components/Input/Input/Input.js +3 -3
- package/components/Input/Input/Input.js.map +1 -1
- package/components/Input/Input.styles/Input.styles.js +2 -2
- package/components/Input/Input.styles/Input.styles.js.map +1 -1
- package/components/Input/Input.styles.d.ts +1 -1
- package/components/Input/InputLayout/InputLayout.styles/InputLayout.styles.js +2 -2
- package/components/Input/InputLayout/InputLayout.styles/InputLayout.styles.js.map +1 -1
- package/components/Input/InputLayout/InputLayout.styles.d.ts +1 -1
- package/components/Input/InputLayout/InputLayoutAsideIcon/InputLayoutAsideIcon.js +1 -1
- package/components/Input/InputLayout/InputLayoutAsideIcon/InputLayoutAsideIcon.js.map +1 -1
- package/components/Kebab/Kebab/Kebab.js +7 -4
- package/components/Kebab/Kebab/Kebab.js.map +1 -1
- package/components/Link/Link/Link.js +6 -3
- package/components/Link/Link/Link.js.map +1 -1
- package/components/Loader/Loader/Loader.js +2 -2
- package/components/Loader/Loader/Loader.js.map +1 -1
- package/components/MenuItem/MenuItem/MenuItem.js +3 -3
- package/components/MenuItem/MenuItem/MenuItem.js.map +1 -1
- package/components/MiniModal/MiniModal/MiniModal.js +2 -2
- package/components/MiniModal/MiniModal/MiniModal.js.map +1 -1
- package/components/Modal/Modal/Modal.js +3 -3
- package/components/Modal/Modal/Modal.js.map +1 -1
- package/components/Modal/ModalBody/ModalBody.js +3 -3
- package/components/Modal/ModalBody/ModalBody.js.map +1 -1
- package/components/Paging/Paging/Paging.js +10 -6
- package/components/Paging/Paging/Paging.js.map +1 -1
- package/components/PasswordInput/PasswordInput/PasswordInput.js +2 -2
- package/components/PasswordInput/PasswordInput/PasswordInput.js.map +1 -1
- package/components/Radio/Radio/Radio.js +2 -2
- package/components/Radio/Radio/Radio.js.map +1 -1
- package/components/RadioGroup/RadioGroup/RadioGroup.js +8 -4
- package/components/RadioGroup/RadioGroup/RadioGroup.js.map +1 -1
- package/components/ScrollContainer/ScrollBar/ScrollBar.js +2 -2
- package/components/ScrollContainer/ScrollBar/ScrollBar.js.map +1 -1
- package/components/ScrollContainer/ScrollContainer/ScrollContainer.js +5 -0
- package/components/ScrollContainer/ScrollContainer/ScrollContainer.js.map +1 -1
- package/components/ScrollContainer/ScrollContainer.d.ts +1 -0
- package/components/Select/Select/Select.js +6 -5
- package/components/Select/Select/Select.js.map +1 -1
- package/components/SidePage/SidePage/SidePage.js +2 -2
- package/components/SidePage/SidePage/SidePage.js.map +1 -1
- package/components/SidePage/SidePageBody/SidePageBody.js +2 -2
- package/components/SidePage/SidePageBody/SidePageBody.js.map +1 -1
- package/components/SidePage/SidePageContainer/SidePageContainer.js +2 -2
- package/components/SidePage/SidePageContainer/SidePageContainer.js.map +1 -1
- package/components/SidePage/SidePageFooter/SidePageFooter.js +2 -2
- package/components/SidePage/SidePageFooter/SidePageFooter.js.map +1 -1
- package/components/SidePage/SidePageHeader/SidePageHeader.js +2 -2
- package/components/SidePage/SidePageHeader/SidePageHeader.js.map +1 -1
- package/components/Spinner/Spinner/Spinner.js +2 -2
- package/components/Spinner/Spinner/Spinner.js.map +1 -1
- package/components/Switcher/Switcher/Switcher.js +3 -3
- package/components/Switcher/Switcher/Switcher.js.map +1 -1
- package/components/Tabs/Indicator/Indicator.js +2 -2
- package/components/Tabs/Indicator/Indicator.js.map +1 -1
- package/components/Tabs/Tab/Tab.js +3 -3
- package/components/Tabs/Tab/Tab.js.map +1 -1
- package/components/Tabs/Tabs/Tabs.js +2 -2
- package/components/Tabs/Tabs/Tabs.js.map +1 -1
- package/components/Textarea/Textarea/Textarea.js +2 -2
- package/components/Textarea/Textarea/Textarea.js.map +1 -1
- package/components/Toast/Toast/Toast.js +3 -3
- package/components/Toast/Toast/Toast.js.map +1 -1
- package/components/Toast/ToastView/ToastView.js +2 -2
- package/components/Toast/ToastView/ToastView.js.map +1 -1
- package/components/Toggle/Toggle/Toggle.js +2 -2
- package/components/Toggle/Toggle/Toggle.js.map +1 -1
- package/components/Token/Token/Token.js +6 -3
- package/components/Token/Token/Token.js.map +1 -1
- package/components/TokenInput/TokenInput/TokenInput.js +2 -2
- package/components/TokenInput/TokenInput/TokenInput.js.map +1 -1
- package/components/TokenInput/TokenInputMenu/TokenInputMenu.js +3 -3
- package/components/TokenInput/TokenInputMenu/TokenInputMenu.js.map +1 -1
- package/components/Tooltip/Tooltip/Tooltip.js +67 -46
- package/components/Tooltip/Tooltip/Tooltip.js.map +1 -1
- package/components/Tooltip/Tooltip.d.ts +10 -5
- package/components/TooltipMenu/TooltipMenu/TooltipMenu.js +3 -3
- package/components/TooltipMenu/TooltipMenu/TooltipMenu.js.map +1 -1
- package/hooks/useDrop/useDrop.js.map +1 -1
- package/hooks/useDrop.d.ts +1 -1
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/internal/CommonWrapper/CommonWrapper/CommonWrapper.js +2 -2
- package/internal/CommonWrapper/CommonWrapper/CommonWrapper.js.map +1 -1
- package/internal/CommonWrapper/utils/extractCommonProps/extractCommonProps.js.map +1 -0
- package/internal/CommonWrapper/{extractCommonProps → utils/extractCommonProps}/package.json +1 -1
- package/internal/CommonWrapper/{extractCommonProps.d.ts → utils/extractCommonProps.d.ts} +2 -2
- package/internal/CommonWrapper/{getCommonVisualStateDataAttributes → utils/getCommonVisualStateDataAttributes}/getCommonVisualStateDataAttributes.js +1 -5
- package/internal/CommonWrapper/utils/getCommonVisualStateDataAttributes/getCommonVisualStateDataAttributes.js.map +1 -0
- package/internal/CommonWrapper/{getCommonVisualStateDataAttributes → utils/getCommonVisualStateDataAttributes}/package.json +1 -1
- package/internal/CommonWrapper/{getVisualStateDataAttributes → utils/getVisualStateDataAttributes}/getVisualStateDataAttributes.js +3 -3
- package/internal/CommonWrapper/utils/getVisualStateDataAttributes/getVisualStateDataAttributes.js.map +1 -0
- package/internal/CommonWrapper/{getVisualStateDataAttributes → utils/getVisualStateDataAttributes}/package.json +1 -1
- package/internal/CommonWrapper/{getVisualStateDataAttributes.d.ts → utils/getVisualStateDataAttributes.d.ts} +1 -1
- package/internal/CommonWrapper/utils/tryGetBoolean/package.json +6 -0
- package/internal/CommonWrapper/utils/tryGetBoolean/tryGetBoolean.js +3 -0
- package/internal/CommonWrapper/utils/tryGetBoolean/tryGetBoolean.js.map +1 -0
- package/internal/CommonWrapper/utils/tryGetBoolean.d.ts +1 -0
- package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js +3 -3
- package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js.map +1 -1
- package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js +5 -3
- package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js.map +1 -1
- package/internal/DateSelect/DateSelect/DateSelect.js +59 -6
- package/internal/DateSelect/DateSelect/DateSelect.js.map +1 -1
- package/internal/DateSelect/DateSelect.d.ts +2 -0
- package/internal/DateSelect/DateSelect.styles/DateSelect.styles.js +4 -1
- package/internal/DateSelect/DateSelect.styles/DateSelect.styles.js.map +1 -1
- package/internal/DateSelect/DateSelect.styles.d.ts +1 -0
- package/internal/DateSelect/locale/locales/en/en.js +2 -1
- package/internal/DateSelect/locale/locales/en/en.js.map +1 -1
- package/internal/DateSelect/locale/locales/ru/ru.js +2 -1
- package/internal/DateSelect/locale/locales/ru/ru.js.map +1 -1
- package/internal/DateSelect/locale/types.d.ts +1 -0
- package/internal/FileUploaderControl/FileUploaderControlProvider/FileUploaderControlProvider.js +12 -3
- package/internal/FileUploaderControl/FileUploaderControlProvider/FileUploaderControlProvider.js.map +1 -1
- package/internal/FileUploaderControl/FileUploaderControlProvider.d.ts +5 -2
- package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile/FileUploaderFile.js +4 -2
- package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile/FileUploaderFile.js.map +1 -1
- package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.d.ts +1 -0
- package/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList/FileUploaderFileList.js +4 -2
- package/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList/FileUploaderFileList.js.map +1 -1
- package/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.d.ts +1 -0
- package/internal/InputLikeText/InputLikeText/InputLikeText.js +3 -3
- package/internal/InputLikeText/InputLikeText/InputLikeText.js.map +1 -1
- package/internal/InternalMaskedInput/InternalMaskedInput/InternalMaskedInput.js +2 -2
- package/internal/InternalMaskedInput/InternalMaskedInput/InternalMaskedInput.js.map +1 -1
- package/internal/InternalMenu/InternalMenu/InternalMenu.js +3 -3
- package/internal/InternalMenu/InternalMenu/InternalMenu.js.map +1 -1
- package/internal/Menu/Menu/Menu.js +3 -3
- package/internal/Menu/Menu/Menu.js.map +1 -1
- package/internal/MobilePopup/MobilePopup/MobilePopup.js +4 -3
- package/internal/MobilePopup/MobilePopup/MobilePopup.js.map +1 -1
- package/internal/MobilePopup/MobilePopup.d.ts +4 -0
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter/MobilePopupFooter.js +37 -0
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter/MobilePopupFooter.js.map +1 -0
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter/package.json +6 -0
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.d.ts +7 -0
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles/MobilePopupFooter.styles.js +11 -0
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles/MobilePopupFooter.styles.js.map +1 -0
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles/package.json +6 -0
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles.d.ts +4 -0
- package/internal/MobilePopup/MobilePopupFooter/index/index.js +1 -0
- package/internal/MobilePopup/MobilePopupFooter/index/index.js.map +1 -0
- package/internal/MobilePopup/MobilePopupFooter/index/package.json +6 -0
- package/internal/MobilePopup/MobilePopupFooter/index.d.ts +1 -0
- package/internal/MobilePopup/MobilePopupFooter/package.json +6 -0
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader/MobilePopupHeader.js +2 -2
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader/MobilePopupHeader.js.map +1 -1
- package/internal/NativeDateInput/utils/utils.js +2 -1
- package/internal/NativeDateInput/utils/utils.js.map +1 -1
- package/internal/Popup/Popup/Popup.js +53 -10
- package/internal/Popup/Popup/Popup.js.map +1 -1
- package/internal/Popup/Popup.d.ts +15 -4
- package/internal/PopupMenu/PopupMenu/PopupMenu.js +3 -3
- package/internal/PopupMenu/PopupMenu/PopupMenu.js.map +1 -1
- package/internal/RenderContainer/RenderContainer/RenderContainer.js +19 -12
- package/internal/RenderContainer/RenderContainer/RenderContainer.js.map +1 -1
- package/internal/RenderContainer/RenderContainer.d.ts +3 -0
- package/internal/RenderContainer/RenderInnerContainer/RenderInnerContainer.js +11 -5
- package/internal/RenderContainer/RenderInnerContainer/RenderInnerContainer.js.map +1 -1
- package/internal/RenderLayer/RenderLayer/RenderLayer.js +2 -2
- package/internal/RenderLayer/RenderLayer/RenderLayer.js.map +1 -1
- package/internal/ThemePlayground/Playground/Playground.js +2 -2
- package/internal/ThemePlayground/Playground/Playground.js.map +1 -1
- package/internal/ThemePlayground/ThemeContextPlayground/ThemeContextPlayground.js +10 -7
- package/internal/ThemePlayground/ThemeContextPlayground/ThemeContextPlayground.js.map +1 -1
- package/internal/ThemePlayground/constants/constants.js +3 -0
- package/internal/ThemePlayground/constants/constants.js.map +1 -1
- package/internal/ThemeShowcase/ThemeShowcase/ThemeShowcase.js +2 -2
- package/internal/ThemeShowcase/ThemeShowcase/ThemeShowcase.js.map +1 -1
- package/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
- package/internal/ZIndex/ZIndex/ZIndex.js +55 -7
- package/internal/ZIndex/ZIndex/ZIndex.js.map +1 -1
- package/internal/ZIndex/ZIndex.d.ts +7 -3
- package/internal/themes/DarkTheme/DarkTheme.js +2 -0
- package/internal/themes/DarkTheme/DarkTheme.js.map +1 -1
- package/internal/themes/DarkTheme.d.ts +2 -0
- package/internal/themes/DefaultTheme/DefaultTheme.js +32 -1
- package/internal/themes/DefaultTheme/DefaultTheme.js.map +1 -1
- package/internal/themes/DefaultTheme.d.ts +18 -0
- package/lib/date/InternalDate/InternalDate.js +7 -1
- package/lib/date/InternalDate/InternalDate.js.map +1 -1
- package/lib/date/InternalDate.d.ts +2 -0
- package/lib/date/InternalDateTransformer/InternalDateTransformer.js +30 -0
- package/lib/date/InternalDateTransformer/InternalDateTransformer.js.map +1 -1
- package/lib/date/InternalDateTransformer.d.ts +3 -0
- package/lib/date/InternalDateValidator/InternalDateValidator.js +6 -1
- package/lib/date/InternalDateValidator/InternalDateValidator.js.map +1 -1
- package/lib/date/comparison/comparison.js +45 -0
- package/lib/date/comparison/comparison.js.map +1 -0
- package/lib/date/comparison/package.json +6 -0
- package/lib/date/comparison.d.ts +6 -0
- package/lib/featureFlagsContext/FEATUREFLAGSCONTEXT.md +24 -0
- package/lib/featureFlagsContext/FeatureFlagsHelpers.d.ts +1 -0
- package/lib/featureFlagsContext/ReactUIFeatureFlagsContext/ReactUIFeatureFlagsContext.js +2 -1
- package/lib/featureFlagsContext/ReactUIFeatureFlagsContext/ReactUIFeatureFlagsContext.js.map +1 -1
- package/lib/featureFlagsContext/ReactUIFeatureFlagsContext.d.ts +1 -0
- package/lib/listenFocusOutside/listenFocusOutside.js +3 -2
- package/lib/listenFocusOutside/listenFocusOutside.js.map +1 -1
- package/lib/locale/constants/constants.js +4 -1
- package/lib/locale/constants/constants.js.map +1 -1
- package/lib/locale/constants.d.ts +3 -0
- package/lib/taskWithDelayAndMinimalDuration/taskWithDelayAndMinimalDuration.js +2 -0
- package/lib/taskWithDelayAndMinimalDuration/taskWithDelayAndMinimalDuration.js.map +1 -1
- package/lib/theming/Emotion/Emotion.js +12 -3
- package/lib/theming/Emotion/Emotion.js.map +1 -1
- package/lib/theming/Emotion.d.ts +7 -1
- package/lib/theming/ThemeContext/ThemeContext.js +0 -2
- package/lib/theming/ThemeContext/ThemeContext.js.map +1 -1
- package/lib/theming/ThemeContext.d.ts +0 -2
- package/lib/theming/ThemeContext.md +3 -1
- package/lib/theming/themes/Theme2022DarkUpdate2024/Theme2022DarkUpdate2024.js +33 -0
- package/lib/theming/themes/Theme2022DarkUpdate2024/Theme2022DarkUpdate2024.js.map +1 -0
- package/lib/theming/themes/Theme2022DarkUpdate2024/package.json +6 -0
- package/lib/theming/themes/Theme2022DarkUpdate2024.d.ts +30 -0
- package/lib/theming/themes/Theme2022Update2024/Theme2022Update2024.js +50 -0
- package/lib/theming/themes/Theme2022Update2024/Theme2022Update2024.js.map +1 -0
- package/lib/theming/themes/Theme2022Update2024/package.json +6 -0
- package/lib/theming/themes/Theme2022Update2024.d.ts +46 -0
- package/lib/widgets/StylesContainer/StylesContainer.js +65 -0
- package/lib/widgets/StylesContainer/StylesContainer.js.map +1 -0
- package/lib/widgets/StylesContainer/package.json +6 -0
- package/lib/widgets/StylesContainer.d.ts +13 -0
- package/lib/widgets/index/index.js +1 -0
- package/lib/widgets/index/index.js.map +1 -0
- package/lib/widgets/index/package.json +6 -0
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/package.json +6 -0
- package/package.json +3 -2
- package/cjs/internal/CommonWrapper/extractCommonProps.js.map +0 -1
- package/cjs/internal/CommonWrapper/getCommonVisualStateDataAttributes.js.map +0 -1
- package/cjs/internal/CommonWrapper/getVisualStateDataAttributes.js.map +0 -1
- package/cjs/lib/theming/StyleContainer.d.ts +0 -4
- package/cjs/lib/theming/StyleContainer.js +0 -21
- package/cjs/lib/theming/StyleContainer.js.map +0 -1
- package/internal/CommonWrapper/extractCommonProps/extractCommonProps.js.map +0 -1
- package/internal/CommonWrapper/getCommonVisualStateDataAttributes/getCommonVisualStateDataAttributes.js.map +0 -1
- package/internal/CommonWrapper/getVisualStateDataAttributes/getVisualStateDataAttributes.js.map +0 -1
- package/lib/theming/StyleContainer/StyleContainer.js +0 -21
- package/lib/theming/StyleContainer/StyleContainer.js.map +0 -1
- package/lib/theming/StyleContainer/package.json +0 -6
- package/lib/theming/StyleContainer.d.ts +0 -4
- /package/cjs/internal/CommonWrapper/{extractCommonProps.js → utils/extractCommonProps.js} +0 -0
- /package/cjs/internal/CommonWrapper/{getCommonVisualStateDataAttributes.d.ts → utils/getCommonVisualStateDataAttributes.d.ts} +0 -0
- /package/internal/CommonWrapper/{extractCommonProps → utils/extractCommonProps}/extractCommonProps.js +0 -0
- /package/internal/CommonWrapper/{getCommonVisualStateDataAttributes.d.ts → utils/getCommonVisualStateDataAttributes.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["SidePageHeader.tsx"],"names":["SidePageHeaderDataTids","root","close","SidePageHeader","responsiveLayout","rootNode","context","state","isReadyToFix","wrapper","sticky","lastRegularHeight","closeIcon","componentDidMount","globalObject","addEventListener","update","setHasHeader","headerRef","componentWillUnmount","removeEventListener","reflow","updateReadyToFix","renderHeader","fixed","styles","emotion","cx","header","theme","headerFixed","mobileHeader","isMobileLayout","renderClose","title","mobileTitle","titleFixed","props","children","renderHeader2022","isDisplayed","hasSeparator","stickyOffset","parseInt","sidePageHeaderStickyOffset","wrapperClose","wrapperCloseFixed","mobileWrapperClose","wrapperScrolledUp","top","regularHeight","fixedHeaderHeight","setState","wrapperRef","el","stickyRef","render","renderMain","getStickyProp","isStickyDesktop","isStickyMobile","setRootNode","headerWrapper","height","sidePageHeaderFixedLineHeight","sidePageHeaderFixedPaddingY","React","Component","__KONTUR_REACT_UI__","displayName","contextType","SidePageContext","defaultProps"],"mappings":"6jBAAA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,6C;;;;;;;;;;;;AAYO,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KAAR,GAAkB,IAAlB,CAAQA,KAAR,CACA,OAAOc,QAAQ,CAACd,KAAK,CAACmC,6BAAP,CAAR,GAAgDrB,QAAQ,CAACd,KAAK,CAACoC,2BAAP,CAAR,GAA8C,CAArG,CACD,C,6BAvCiCC,eAAMC,S,WAC1BC,mB,GAAsB,gB,UACtBC,W,GAAc,gB,UAEdC,W,GAAcC,gC,UASdC,Y,GAA6C,EACzD/B,YAAY,EAAE,KAD2C,E","sourcesContent":["import React from 'react';\nimport { globalObject } from '@skbkontur/global-object';\nimport type { Emotion } from '@emotion/css/create-instance';\n\nimport { Sticky } from '../Sticky';\nimport { isFunction } from '../../lib/utils';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { responsiveLayout } from '../ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { getDOMRect } from '../../lib/dom/getDOMRect';\nimport { ModalSeparator } from '../Modal/ModalSeparator';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { ThemeConsumer } from '../../lib/theming/ThemeContext';\n\nimport { SidePageContext, SidePageContextType } from './SidePageContext';\nimport { SidePageCloseButton } from './SidePageCloseButton';\nimport { getStyles } from './SidePage.styles';\n\nexport interface SidePageHeaderProps extends Omit<CommonProps, 'children'> {\n children?: React.ReactNode | ((fixed: boolean) => React.ReactNode);\n sticky?: boolean;\n hasSeparator?: boolean;\n}\n\nexport interface SidePageHeaderState {\n isReadyToFix: boolean;\n}\n\nexport const SidePageHeaderDataTids = {\n root: 'SidePageHeader__root',\n close: 'SidePage__close',\n} as const;\n\n/**\n * Шапка сайдпейджа\n *\n * @visibleName SidePage.Header\n */\n@responsiveLayout\n@rootNode\nexport class SidePageHeader extends React.Component<SidePageHeaderProps, SidePageHeaderState> {\n public static __KONTUR_REACT_UI__ = 'SidePageHeader';\n public static displayName = 'SidePageHeader';\n\n public static contextType = SidePageContext;\n public context: SidePageContextType = this.context;\n\n private isMobileLayout!: boolean;\n\n public state: SidePageHeaderState = {\n isReadyToFix: false,\n };\n\n public static defaultProps: Partial<SidePageHeaderProps> = {\n hasSeparator: false,\n };\n\n private theme!: Theme;\n private emotion!: Emotion;\n private wrapper: HTMLElement | null = null;\n private sticky: Sticky | null = null;\n private lastRegularHeight = 0;\n private setRootNode!: TSetRootNode;\n private closeIcon = (<SidePageCloseButton />);\n\n public get regularHeight(): number {\n const { isReadyToFix } = this.state;\n if (!this.wrapper) {\n return 0;\n }\n if (!isReadyToFix) {\n this.lastRegularHeight = getDOMRect(this.wrapper).height;\n }\n return this.lastRegularHeight;\n }\n\n public get fixedHeaderHeight(): number {\n const { theme } = this;\n return parseInt(theme.sidePageHeaderFixedLineHeight) + parseInt(theme.sidePageHeaderFixedPaddingY) * 2;\n }\n\n public componentDidMount = () => {\n globalObject.addEventListener?.('scroll', this.update, true);\n this.context.setHasHeader?.();\n this.context.headerRef(this);\n };\n\n public componentWillUnmount = () => {\n globalObject.removeEventListener?.('scroll', this.update, true);\n this.context.setHasHeader?.(false);\n this.context.headerRef(null);\n };\n\n public update = () => {\n this.sticky?.reflow();\n this.updateReadyToFix();\n };\n\n public render(): JSX.Element {\n return (\n <EmotionConsumer>\n {(emotion) => {\n this.emotion = emotion;\n return (\n <ThemeConsumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeConsumer>\n );\n }}\n </EmotionConsumer>\n );\n }\n\n public getStickyProp() {\n if (typeof this.props.sticky !== 'undefined') {\n return this.props.sticky;\n }\n\n if (this.isMobileLayout) {\n return false;\n }\n\n return true;\n }\n\n private renderMain() {\n const { isReadyToFix } = this.state;\n\n const isStickyDesktop = !this.isMobileLayout && this.getStickyProp() && isReadyToFix;\n const isStickyMobile = this.isMobileLayout && this.getStickyProp();\n\n const header = isTheme2022(this.theme) ? this.renderHeader2022 : this.renderHeader;\n const styles = getStyles(this.emotion);\n\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <div data-tid={SidePageHeaderDataTids.root} ref={this.wrapperRef} className={styles.headerWrapper()}>\n {isStickyDesktop || isStickyMobile ? (\n <Sticky ref={this.stickyRef} side=\"top\">\n {header}\n </Sticky>\n ) : (\n header()\n )}\n </div>\n </CommonWrapper>\n );\n }\n\n private renderHeader = (fixed = false) => {\n const styles = getStyles(this.emotion);\n\n return (\n <div\n className={this.emotion.cx(styles.header(this.theme), {\n [styles.headerFixed(this.theme)]: fixed,\n [styles.mobileHeader(this.theme)]: this.isMobileLayout,\n })}\n >\n {this.renderClose(fixed)}\n <div\n className={this.emotion.cx(styles.title(this.theme), {\n [styles.mobileTitle(this.theme)]: this.isMobileLayout,\n [styles.titleFixed()]: fixed,\n })}\n >\n {isFunction(this.props.children) ? this.props.children(fixed) : this.props.children}\n </div>\n </div>\n );\n };\n\n private renderHeader2022 = (fixed = false) => {\n const isDisplayed = this.props.hasSeparator || fixed;\n return (\n <div>\n {this.renderHeader(fixed)}\n {isDisplayed && <ModalSeparator fixed={fixed} />}\n </div>\n );\n };\n\n private renderClose = (fixed: boolean) => {\n const stickyOffset = parseInt(this.theme.sidePageHeaderStickyOffset);\n const styles = getStyles(this.emotion);\n\n return (\n <div\n className={this.emotion.cx(styles.wrapperClose(this.theme), {\n [styles.wrapperCloseFixed(this.theme)]: fixed,\n [styles.mobileWrapperClose(this.theme)]: this.isMobileLayout,\n })}\n >\n {this.isMobileLayout ? (\n this.closeIcon\n ) : (\n <Sticky side=\"top\" offset={stickyOffset}>\n {this.closeIcon}\n </Sticky>\n )}\n </div>\n );\n };\n\n private updateReadyToFix = () => {\n if (this.wrapper) {\n const wrapperScrolledUp = getDOMRect(this.wrapper).top;\n const isReadyToFix = this.regularHeight + wrapperScrolledUp <= this.fixedHeaderHeight;\n this.setState((state) => (state.isReadyToFix !== isReadyToFix ? { ...state, isReadyToFix } : state));\n }\n };\n\n private wrapperRef = (el: HTMLElement | null) => {\n this.wrapper = el;\n };\n\n private stickyRef = (el: Sticky | null) => {\n this.sticky = el;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["SidePageHeader.tsx"],"names":["SidePageHeaderDataTids","root","close","SidePageHeader","responsiveLayout","rootNode","context","state","isReadyToFix","wrapper","sticky","lastRegularHeight","closeIcon","componentDidMount","globalObject","addEventListener","update","setHasHeader","headerRef","componentWillUnmount","removeEventListener","reflow","updateReadyToFix","renderHeader","fixed","styles","emotion","cx","header","theme","headerFixed","mobileHeader","isMobileLayout","renderClose","title","mobileTitle","titleFixed","props","children","renderHeader2022","isDisplayed","hasSeparator","stickyOffset","parseInt","sidePageHeaderStickyOffset","wrapperClose","wrapperCloseFixed","mobileWrapperClose","wrapperScrolledUp","top","regularHeight","fixedHeaderHeight","setState","wrapperRef","el","stickyRef","render","renderMain","getStickyProp","isStickyDesktop","isStickyMobile","setRootNode","headerWrapper","height","sidePageHeaderFixedLineHeight","sidePageHeaderFixedPaddingY","React","Component","__KONTUR_REACT_UI__","displayName","contextType","SidePageContext","defaultProps"],"mappings":"6jBAAA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,6C;;;;;;;;;;;;AAYO,IAAMA,sBAAsB,GAAG;AACpCC,EAAAA,IAAI,EAAE,sBAD8B;AAEpCC,EAAAA,KAAK,EAAE,iBAF6B,EAA/B;;;AAKP;AACA;AACA;AACA;AACA,G;;;AAGaC,c,OAFZC,2B,eACAC,kB;;;;;AAMQC,IAAAA,O,GAA+B,MAAKA,O;;;;AAIpCC,IAAAA,K,GAA6B;AAClCC,MAAAA,YAAY,EAAE,KADoB,E;;;;;;;;;AAU5BC,IAAAA,O,GAA8B,I;AAC9BC,IAAAA,M,GAAwB,I;AACxBC,IAAAA,iB,GAAoB,C;;AAEpBC,IAAAA,S,gBAAa,6BAAC,wCAAD,O;;;;;;;;;;;;;;;;;;AAkBdC,IAAAA,iB,GAAoB,YAAM;AAC/BC,iCAA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AAY,KAAKC,KAAjB,IAA0B,KAAKU,gBAA/B,GAAkD,KAAKhB,YAAtE,CACA,IAAME,MAAM,GAAG,yBAAU,KAAKC,OAAf,CAAf,CAEA,oBACE,6BAAC,4BAAD,2BAAe,WAAW,EAAE,KAAKmC,WAAjC,IAAkD,KAAKxB,KAAvD,gBACE,sCAAK,YAAUrC,sBAAsB,CAACC,IAAtC,EAA4C,GAAG,EAAE,KAAKoD,UAAtD,EAAkE,SAAS,EAAE5B,MAAM,CAACqC,aAAP,EAA7E,IACGH,eAAe,IAAIC,cAAnB,gBACC,6BAAC,cAAD,IAAQ,GAAG,EAAE,KAAKL,SAAlB,EAA6B,IAAI,EAAC,KAAlC,IACG3B,MADH,CADD,GAKCA,MAAM,EANV,CADF,CADF,CAaD,C,0EArFD,eAAmC,CACjC,IAAQpB,YAAR,GAAyB,KAAKD,KAA9B,CAAQC,YAAR,CACA,IAAI,CAAC,KAAKC,OAAV,EAAmB,CACjB,OAAO,CAAP,CACD,CACD,IAAI,CAACD,YAAL,EAAmB,CACjB,KAAKG,iBAAL,GAAyB,4BAAW,KAAKF,OAAhB,EAAyBsD,MAAlD,CACD,CACD,OAAO,KAAKpD,iBAAZ,CACD,C,qCAED,eAAuC,CACrC,IAAQkB,KAAR,GAAkB,IAAlB,CAAQA,KAAR,CACA,OAAOc,QAAQ,CAACd,KAAK,CAACmC,6BAAP,CAAR,GAAgDrB,QAAQ,CAACd,KAAK,CAACoC,2BAAP,CAAR,GAA8C,CAArG,CACD,C,6BAvCiCC,eAAMC,S,WAC1BC,mB,GAAsB,gB,UACtBC,W,GAAc,gB,UAEdC,W,GAAcC,gC,UASdC,Y,GAA6C,EACzD/B,YAAY,EAAE,KAD2C,E","sourcesContent":["import React from 'react';\nimport { globalObject } from '@skbkontur/global-object';\nimport type { Emotion } from '@emotion/css/create-instance';\n\nimport { Sticky } from '../Sticky';\nimport { isFunction } from '../../lib/utils';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { responsiveLayout } from '../ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { getDOMRect } from '../../lib/dom/getDOMRect';\nimport { ModalSeparator } from '../Modal/ModalSeparator';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\n\nimport { SidePageContext, SidePageContextType } from './SidePageContext';\nimport { SidePageCloseButton } from './SidePageCloseButton';\nimport { getStyles } from './SidePage.styles';\n\nexport interface SidePageHeaderProps extends Omit<CommonProps, 'children'> {\n children?: React.ReactNode | ((fixed: boolean) => React.ReactNode);\n sticky?: boolean;\n hasSeparator?: boolean;\n}\n\nexport interface SidePageHeaderState {\n isReadyToFix: boolean;\n}\n\nexport const SidePageHeaderDataTids = {\n root: 'SidePageHeader__root',\n close: 'SidePage__close',\n} as const;\n\n/**\n * Шапка сайдпейджа\n *\n * @visibleName SidePage.Header\n */\n@responsiveLayout\n@rootNode\nexport class SidePageHeader extends React.Component<SidePageHeaderProps, SidePageHeaderState> {\n public static __KONTUR_REACT_UI__ = 'SidePageHeader';\n public static displayName = 'SidePageHeader';\n\n public static contextType = SidePageContext;\n public context: SidePageContextType = this.context;\n\n private isMobileLayout!: boolean;\n\n public state: SidePageHeaderState = {\n isReadyToFix: false,\n };\n\n public static defaultProps: Partial<SidePageHeaderProps> = {\n hasSeparator: false,\n };\n\n private theme!: Theme;\n private emotion!: Emotion;\n private wrapper: HTMLElement | null = null;\n private sticky: Sticky | null = null;\n private lastRegularHeight = 0;\n private setRootNode!: TSetRootNode;\n private closeIcon = (<SidePageCloseButton />);\n\n public get regularHeight(): number {\n const { isReadyToFix } = this.state;\n if (!this.wrapper) {\n return 0;\n }\n if (!isReadyToFix) {\n this.lastRegularHeight = getDOMRect(this.wrapper).height;\n }\n return this.lastRegularHeight;\n }\n\n public get fixedHeaderHeight(): number {\n const { theme } = this;\n return parseInt(theme.sidePageHeaderFixedLineHeight) + parseInt(theme.sidePageHeaderFixedPaddingY) * 2;\n }\n\n public componentDidMount = () => {\n globalObject.addEventListener?.('scroll', this.update, true);\n this.context.setHasHeader?.();\n this.context.headerRef(this);\n };\n\n public componentWillUnmount = () => {\n globalObject.removeEventListener?.('scroll', this.update, true);\n this.context.setHasHeader?.(false);\n this.context.headerRef(null);\n };\n\n public update = () => {\n this.sticky?.reflow();\n this.updateReadyToFix();\n };\n\n public render(): JSX.Element {\n return (\n <EmotionConsumer>\n {(emotion) => {\n this.emotion = emotion;\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }}\n </EmotionConsumer>\n );\n }\n\n public getStickyProp() {\n if (typeof this.props.sticky !== 'undefined') {\n return this.props.sticky;\n }\n\n if (this.isMobileLayout) {\n return false;\n }\n\n return true;\n }\n\n private renderMain() {\n const { isReadyToFix } = this.state;\n\n const isStickyDesktop = !this.isMobileLayout && this.getStickyProp() && isReadyToFix;\n const isStickyMobile = this.isMobileLayout && this.getStickyProp();\n\n const header = isTheme2022(this.theme) ? this.renderHeader2022 : this.renderHeader;\n const styles = getStyles(this.emotion);\n\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <div data-tid={SidePageHeaderDataTids.root} ref={this.wrapperRef} className={styles.headerWrapper()}>\n {isStickyDesktop || isStickyMobile ? (\n <Sticky ref={this.stickyRef} side=\"top\">\n {header}\n </Sticky>\n ) : (\n header()\n )}\n </div>\n </CommonWrapper>\n );\n }\n\n private renderHeader = (fixed = false) => {\n const styles = getStyles(this.emotion);\n\n return (\n <div\n className={this.emotion.cx(styles.header(this.theme), {\n [styles.headerFixed(this.theme)]: fixed,\n [styles.mobileHeader(this.theme)]: this.isMobileLayout,\n })}\n >\n {this.renderClose(fixed)}\n <div\n className={this.emotion.cx(styles.title(this.theme), {\n [styles.mobileTitle(this.theme)]: this.isMobileLayout,\n [styles.titleFixed()]: fixed,\n })}\n >\n {isFunction(this.props.children) ? this.props.children(fixed) : this.props.children}\n </div>\n </div>\n );\n };\n\n private renderHeader2022 = (fixed = false) => {\n const isDisplayed = this.props.hasSeparator || fixed;\n return (\n <div>\n {this.renderHeader(fixed)}\n {isDisplayed && <ModalSeparator fixed={fixed} />}\n </div>\n );\n };\n\n private renderClose = (fixed: boolean) => {\n const stickyOffset = parseInt(this.theme.sidePageHeaderStickyOffset);\n const styles = getStyles(this.emotion);\n\n return (\n <div\n className={this.emotion.cx(styles.wrapperClose(this.theme), {\n [styles.wrapperCloseFixed(this.theme)]: fixed,\n [styles.mobileWrapperClose(this.theme)]: this.isMobileLayout,\n })}\n >\n {this.isMobileLayout ? (\n this.closeIcon\n ) : (\n <Sticky side=\"top\" offset={stickyOffset}>\n {this.closeIcon}\n </Sticky>\n )}\n </div>\n );\n };\n\n private updateReadyToFix = () => {\n if (this.wrapper) {\n const wrapperScrolledUp = getDOMRect(this.wrapper).top;\n const isReadyToFix = this.regularHeight + wrapperScrolledUp <= this.fixedHeaderHeight;\n this.setState((state) => (state.isReadyToFix !== isReadyToFix ? { ...state, isReadyToFix } : state));\n }\n };\n\n private wrapperRef = (el: HTMLElement | null) => {\n this.wrapper = el;\n };\n\n private stickyRef = (el: Sticky | null) => {\n this.sticky = el;\n };\n}\n"]}
|
|
@@ -166,7 +166,7 @@ Spinner = (_dec = (0, _decorators.locale)('Spinner', _locale.SpinnerLocaleHelper
|
|
|
166
166
|
return /*#__PURE__*/(
|
|
167
167
|
_react.default.createElement("span", { className: _this.emotion.cx(styles[type](_this.theme), styles.captionColor(_this.theme)) }, caption));
|
|
168
168
|
|
|
169
|
-
};return _this;}var _proto = Spinner.prototype;_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_featureFlagsContext.ReactUIFeatureFlagsContext.Consumer, null, function (flags) {_this2.featureFlags = (0, _featureFlagsContext.getFullReactUIFlagsContext)(flags);return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.
|
|
169
|
+
};return _this;}var _proto = Spinner.prototype;_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_featureFlagsContext.ReactUIFeatureFlagsContext.Consumer, null, function (flags) {_this2.featureFlags = (0, _featureFlagsContext.getFullReactUIFlagsContext)(flags);return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return _this2.renderMain();});});});};_proto.renderMain = function renderMain() {var canDefaultCaptionBeRemoved = this.featureFlags.spinnerLoaderRemoveDefaultCaption;var defaultCaption = canDefaultCaptionBeRemoved ? null : this.locale.loading;var _this$props = this.props,_this$props$caption = _this$props.caption,caption = _this$props$caption === void 0 ? defaultCaption : _this$props$caption,dimmed = _this$props.dimmed,inline = _this$props.inline;var type = this.getProps().type;var styles = (0, _Spinner.getStyles)(this.emotion);return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), /*#__PURE__*/_react.default.createElement("div", { "data-tid": SpinnerDataTids.root, className: styles.spinner() }, /*#__PURE__*/_react.default.createElement("span", { className: styles.inner() }, this.renderSpinner(type, dimmed, inline)), caption && this.renderCaption(type, caption)));};return Spinner;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Spinner', _class2.displayName = 'Spinner', _class2.propTypes = { /**
|
|
170
170
|
* Текст рядом с мини-лоадером.
|
|
171
171
|
*
|
|
172
172
|
* 'Загрузка' - значение по-умолчанию
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Spinner.tsx"],"names":["types","SpinnerDataTids","root","Spinner","SpinnerLocaleHelper","rootNode","getProps","defaultProps","renderSpinner","type","dimmed","inline","styles","emotion","cx","circle","theme","props","color","circleDimmedColor","circleWithoutColorAnimation","width","renderCaption","caption","captionColor","render","flags","featureFlags","renderMain","canDefaultCaptionBeRemoved","spinnerLoaderRemoveDefaultCaption","defaultCaption","locale","loading","setRootNode","spinner","inner","React","Component","__KONTUR_REACT_UI__","displayName","propTypes","PropTypes","node","bool","oneOf","Types","Object","assign","map"],"mappings":"uWAAA;AACA;;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;AAKA;;AAEA;AACA,kC;;AAEA,IAAMA,KAAK,GAAG,CAAC,KAAD,EAAQ,MAAR,EAAgB,QAAhB,CAAd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCO,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,IAAI,EAAE,eADuB,EAAxB,C;;;;;AAMP;AACA;AACA,G;;;;AAIaC,O,WADZ,wBAAO,SAAP,EAAkBC,2BAAlB,C,MADAC,kB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BSC,IAAAA,Q,GAAW,0CAAkBH,OAAO,CAACI,YAA1B,C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDXC,IAAAA,a,GAAgB,UAACC,IAAD,EAAoBC,MAApB,EAAsCC,MAAtC,EAA2D;AACjF,UAAMC,MAAM,GAAG,wBAAU,MAAKC,OAAf,CAAf;;AAEA;AACE,qCAAC,wBAAD;AACE,UAAA,IAAI,EAAEJ,IADR;AAEE,UAAA,SAAS,EAAE,MAAKI,OAAL,CAAaC,EAAb;AACRF,UAAAA,MAAM,CAACG,MAAP,CAAc,MAAKC,KAAnB,CADQ,IACoB,CAACN,MAAD,IAAW,CAAC,MAAKO,KAAL,CAAWC,KAD3C;AAERN,UAAAA,MAAM,CAACO,iBAAP,CAAyB,MAAKH,KAA9B,CAFQ,IAE+BN,MAF/B;AAGRE,UAAAA,MAAM,CAACQ,2BAAP,EAHQ,IAG+BV,MAAM,IAAI,CAAC,CAAC,MAAKO,KAAL,CAAWC,KAHtD,oBAFb;;AAOE,UAAA,MAAM,EAAER,MAPV;AAQE,UAAA,KAAK,EAAE,MAAKO,KAAL,CAAWI,KARpB;AASE,UAAA,KAAK,EAAE,MAAKJ,KAAL,CAAWC,KATpB;AAUE,UAAA,MAAM,EAAEP,MAVV,GADF;;;AAcD,K;;AAEOW,IAAAA,a,GAAgB,UAACb,IAAD,EAAoBc,OAApB,EAAiD;AACvE,UAAMX,MAAM,GAAG,wBAAU,MAAKC,OAAf,CAAf;AACA;AACE,+CAAM,SAAS,EAAE,MAAKA,OAAL,CAAaC,EAAb,CAAgBF,MAAM,CAACH,IAAD,CAAN,CAAa,MAAKO,KAAlB,CAAhB,EAA0CJ,MAAM,CAACY,YAAP,CAAoB,MAAKR,KAAzB,CAA1C,CAAjB,IAA8FO,OAA9F,CADF;;AAGD,K,qDAlEME,M,GAAP,kBAAgB,mBACd,oBACE,6BAAC,+CAAD,CAA4B,QAA5B,QACG,UAACC,KAAD,EAAW,CACV,MAAI,CAACC,YAAL,GAAoB,qDAA2BD,KAA3B,CAApB,CACA,oBACE,6BAAC,wBAAD,QACG,UAACb,OAAD,EAAa,CACZ,MAAI,CAACA,OAAL,GAAeA,OAAf,CACA,oBACE,6BAAC,
|
|
1
|
+
{"version":3,"sources":["Spinner.tsx"],"names":["types","SpinnerDataTids","root","Spinner","SpinnerLocaleHelper","rootNode","getProps","defaultProps","renderSpinner","type","dimmed","inline","styles","emotion","cx","circle","theme","props","color","circleDimmedColor","circleWithoutColorAnimation","width","renderCaption","caption","captionColor","render","flags","featureFlags","renderMain","canDefaultCaptionBeRemoved","spinnerLoaderRemoveDefaultCaption","defaultCaption","locale","loading","setRootNode","spinner","inner","React","Component","__KONTUR_REACT_UI__","displayName","propTypes","PropTypes","node","bool","oneOf","Types","Object","assign","map"],"mappings":"uWAAA;AACA;;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;AAKA;;AAEA;AACA,kC;;AAEA,IAAMA,KAAK,GAAG,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AjB,IAAkC,KAAK5B,aAAL,CAAmBC,IAAnB,EAAyBC,MAAzB,EAAiCC,MAAjC,CAAlC,CADF,EAEGY,OAAO,IAAI,KAAKD,aAAL,CAAmBb,IAAnB,EAAyBc,OAAzB,CAFd,CADF,CADF,CAQD,C,kBA7E0Bc,eAAMC,S,WACnBC,mB,GAAsB,S,UACtBC,W,GAAc,S,UAEdC,S,GAAY,EACxB;AACJ;AACA;AACA;AACA,KACIlB,OAAO,EAAEmB,mBAAUC,IANK,EAQxBjC,MAAM,EAAEgC,mBAAUE,IARM,EAUxB;AACJ;AACA;AACA;AACA;AACA;AACA,KACInC,IAAI,EAAEiC,mBAAUG,KAAV,CAAgB7C,KAAhB,CAjBkB,E,UAoBZO,Y,GAA6B,EACzCE,IAAI,EAAE,QADmC,E,UAM7BqC,K,GAA0CC,MAAM,CAACC,MAAP,OAAAD,MAAM,GAAQ,EAAR,SAAe/C,KAAK,CAACiD,GAAN,CAAU,UAACxC,IAAD,mCAAcA,IAAd,IAAqBA,IAArB,QAAV,CAAf,E","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport type { Emotion } from '@emotion/css/create-instance';\n\nimport { locale } from '../../lib/locale/decorators';\nimport { Theme } from '../../lib/theming/Theme';\nimport { SpinnerIcon } from '../../internal/icons/SpinnerIcon';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport {\n getFullReactUIFlagsContext,\n ReactUIFeatureFlags,\n ReactUIFeatureFlagsContext,\n} from '../../lib/featureFlagsContext';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\n\nimport { getStyles } from './Spinner.styles';\nimport { SpinnerLocale, SpinnerLocaleHelper } from './locale';\n\nconst types = ['big', 'mini', 'normal'] as const;\n\nexport type SpinnerType = typeof types[number];\n\nexport interface SpinnerProps extends CommonProps {\n /**\n * Подпись под спиннером\n */\n caption?: React.ReactNode;\n /**\n * Переводит спиннер в \"затемнённый режим\"\n *\n * Цвет спиннера в \"затемнённом режиме\" определяется переменной `spinnerDimmedColor`\n */\n dimmed?: boolean;\n /**\n * Размер спиннера и текста\n *\n * @default normal\n */\n type?: SpinnerType;\n inline?: boolean;\n /**\n * Толщина спиннера\n */\n width?: number;\n /**\n * Цвет спиннера\n */\n color?: React.CSSProperties['color'];\n}\n\nexport const SpinnerDataTids = {\n root: 'Spinner__root',\n} as const;\n\ntype DefaultProps = Required<Pick<SpinnerProps, 'type'>>;\n\n/**\n * Используйте компонент `Spinner`, если вам нужен спиннер, без дополнительного функционала, который предоставляет компонент [Loader](https://tech.skbkontur.ru/react-ui/#/Components/Loader)\n */\n\n@rootNode\n@locale('Spinner', SpinnerLocaleHelper)\nexport class Spinner extends React.Component<SpinnerProps> {\n public static __KONTUR_REACT_UI__ = 'Spinner';\n public static displayName = 'Spinner';\n\n public static propTypes = {\n /**\n * Текст рядом с мини-лоадером.\n *\n * 'Загрузка' - значение по-умолчанию\n */\n caption: PropTypes.node,\n\n dimmed: PropTypes.bool,\n\n /**\n * Тип спиннера: mini, normal, big\n *\n * Значение по-умолчанию - normal\n *\n * Spinner.types - все доступные типы\n */\n type: PropTypes.oneOf(types),\n };\n\n public static defaultProps: DefaultProps = {\n type: 'normal',\n };\n\n private getProps = createPropsGetter(Spinner.defaultProps);\n\n public static Types: Record<SpinnerType, SpinnerType> = Object.assign({}, ...types.map((type) => ({ [type]: type })));\n private theme!: Theme;\n private emotion!: Emotion;\n private readonly locale!: SpinnerLocale;\n private setRootNode!: TSetRootNode;\n private featureFlags!: ReactUIFeatureFlags;\n\n public render() {\n return (\n <ReactUIFeatureFlagsContext.Consumer>\n {(flags) => {\n this.featureFlags = getFullReactUIFlagsContext(flags);\n return (\n <EmotionConsumer>\n {(emotion) => {\n this.emotion = emotion;\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }}\n </EmotionConsumer>\n );\n }}\n </ReactUIFeatureFlagsContext.Consumer>\n );\n }\n\n private renderMain() {\n const canDefaultCaptionBeRemoved = this.featureFlags.spinnerLoaderRemoveDefaultCaption;\n const defaultCaption = canDefaultCaptionBeRemoved ? null : this.locale.loading;\n const { caption = defaultCaption, dimmed, inline } = this.props;\n const type = this.getProps().type;\n const styles = getStyles(this.emotion);\n\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <div data-tid={SpinnerDataTids.root} className={styles.spinner()}>\n <span className={styles.inner()}>{this.renderSpinner(type, dimmed, inline)}</span>\n {caption && this.renderCaption(type, caption)}\n </div>\n </CommonWrapper>\n );\n }\n\n private renderSpinner = (type: SpinnerType, dimmed?: boolean, inline?: boolean) => {\n const styles = getStyles(this.emotion);\n\n return (\n <SpinnerIcon\n size={type}\n className={this.emotion.cx({\n [styles.circle(this.theme)]: !dimmed && !this.props.color,\n [styles.circleDimmedColor(this.theme)]: dimmed,\n [styles.circleWithoutColorAnimation()]: dimmed || !!this.props.color,\n })}\n dimmed={dimmed}\n width={this.props.width}\n color={this.props.color}\n inline={inline}\n />\n );\n };\n\n private renderCaption = (type: SpinnerType, caption: React.ReactNode) => {\n const styles = getStyles(this.emotion);\n return (\n <span className={this.emotion.cx(styles[type](this.theme), styles.captionColor(this.theme))}>{caption}</span>\n );\n };\n}\n"]}
|
|
@@ -292,4 +292,4 @@ Switcher = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/func
|
|
|
292
292
|
default:
|
|
293
293
|
return styles.captionSmall(_this.theme);}
|
|
294
294
|
|
|
295
|
-
};return _this;}var _proto = Switcher.prototype;_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.
|
|
295
|
+
};return _this;}var _proto = Switcher.prototype;_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = (0, _switcherTheme.getSwitcherTheme)(theme);return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value: _this2.theme }, _this2.renderMain());});});};_proto.renderMain = function renderMain() {var _this$emotion$cx;var styles = (0, _Switcher.getStyles)(this.emotion);var listClassName = this.emotion.cx((_this$emotion$cx = {}, _this$emotion$cx[styles.error(this.theme)] = !!this.props.error, _this$emotion$cx));var inputProps = { type: 'checkbox', onKeyDown: this.handleKey, onFocus: this._handleFocus, onBlur: this._handleBlur, className: styles.input() };var captionClassName = this.emotion.cx(styles.caption(this.theme), this.getLabelSizeClassName());return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), /*#__PURE__*/_react.default.createElement("div", { "data-tid": SwitcherDataTids.root, className: styles.root() }, this.props.caption ? /*#__PURE__*/_react.default.createElement("div", { className: captionClassName }, this.props.caption) : null, /*#__PURE__*/_react.default.createElement("div", { className: styles.wrap() }, /*#__PURE__*/_react.default.createElement("input", inputProps), /*#__PURE__*/_react.default.createElement("div", { className: listClassName }, /*#__PURE__*/_react.default.createElement(_Group.Group, null, this._renderItems())))));};return Switcher;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Switcher', _class2.displayName = 'Switcher', _class2.defaultProps = { role: 'switch' }, _class2.propTypes = { error: _propTypes.default.bool, disabled: _propTypes.default.bool, items: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.arrayOf(_propTypes.default.shape({ label: _propTypes.default.string, value: _propTypes.default.string }))]).isRequired, caption: _propTypes.default.string, value: _propTypes.default.string, onValueChange: _propTypes.default.func, renderItem: _propTypes.default.func }, _temp)) || _class;exports.Switcher = Switcher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Switcher.tsx"],"names":["SwitcherDataTids","root","Switcher","rootNode","state","focusedIndex","selectItem","value","props","onValueChange","_extractPropsFromItem","item","label","_extractValuesFromItems","items","map","_focus","index","setState","handleKey","e","buttonProps","disabled","preventDefault","move","left","selectedIndex","newFocusedIndex","_getNextFocusedIndex","i","length","_handleFocus","currentIndex","indexOf","_handleBlur","_renderItems","size","role","renderItem","ariaLabel","itemValue","customButtonProps","isChecked","commonButtonProps","checked","visuallyFocused","onClick","disableFocus","corners","renderDefault","renderDefaultItem","getLabelSizeClassName","styles","emotion","captionLarge","theme","captionMedium","captionSmall","render","renderMain","listClassName","cx","error","inputProps","type","onKeyDown","onFocus","onBlur","className","input","captionClassName","caption","setRootNode","wrap","React","Component","__KONTUR_REACT_UI__","displayName","defaultProps","propTypes","PropTypes","bool","oneOfType","arrayOf","string","shape","isRequired","func"],"mappings":"yWAAA;AACA;;;AAGA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,6C;;;;;;;;AAQO,IAAMA,gBAAgB,GAAG;AAC9BC,EAAAA,IAAI,EAAE,gBADwB,EAAzB,C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDMC,Q,OADZC,kB;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BQC,IAAAA,K,GAAuB;AAC5BC,MAAAA,YAAY,EAAE,IADc,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDtBC,IAAAA,U,GAAa,UAACC,KAAD,EAAmB;AACtC,UAAI,MAAKC,KAAL,CAAWC,aAAf,EAA8B;AAC5B,cAAKD,KAAL,CAAWC,aAAX,CAAyBF,KAAzB;AACD;AACF,K;;AAEOG,IAAAA,qB,GAAwB,UAACC,IAAD,EAA+C;AAC7E,aAAO,OAAOA,IAAP,KAAgB,QAAhB,GAA2BA,IAA3B,G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AAoB,CACzBF,mBAAUG,OAAV,CAAkBH,mBAAUI,MAA5B,CADyB,EAEzBJ,mBAAUG,OAAV,CACEH,mBAAUK,KAAV,CAAgB,EACdzE,KAAK,EAAEoE,mBAAUI,MADH,EAEd7E,KAAK,EAAEyE,mBAAUI,MAFH,EAAhB,CADF,CAFyB,CAApB,EAQJE,UAXqB,EAYxBf,OAAO,EAAES,mBAAUI,MAZK,EAaxB7E,KAAK,EAAEyE,mBAAUI,MAbO,EAcxB3E,aAAa,EAAEuE,mBAAUO,IAdD,EAexBjD,UAAU,EAAE0C,mBAAUO,IAfE,E","sourcesContent":["import React, { HTMLAttributes } from 'react';\nimport PropTypes from 'prop-types';\nimport type { Emotion } from '@emotion/css/create-instance';\n\nimport { isKeyArrowHorizontal, isKeyArrowLeft, isKeyEnter } from '../../lib/events/keyboard/identifiers';\nimport { getButtonCorners, Group } from '../Group';\nimport { Button, ButtonProps } from '../Button';\nimport { Nullable } from '../../typings/utility-types';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { SizeProp } from '../../lib/types/props';\nimport { ThemeConsumer, ThemeProvider } from '../../lib/theming/ThemeContext';\n\nimport { getSwitcherTheme } from './switcherTheme';\nimport { mod } from './helpers';\nimport { getStyles } from './Switcher.styles';\n\n/**\n * @deprecated use SizeProp\n */\nexport type SwitcherSize = SizeProp;\nexport type SwitcherItems = string | SwitcherItem;\n\nexport const SwitcherDataTids = {\n root: 'Switcher__root',\n} as const;\n\nexport interface SwitcherProps extends Pick<HTMLAttributes<unknown>, 'role'>, CommonProps {\n /**\n * Список строк или список элементов типа `{ label: string, value: string, buttonProps?: Partial<ButtonProps> }`\n */\n items: SwitcherItems[];\n\n value?: string;\n\n onValueChange?: (value: string) => void;\n\n caption?: string;\n\n error?: boolean;\n\n /** Размер */\n size?: SizeProp;\n\n disabled?: boolean;\n\n /**\n * Функция для отрисовки элемента. Аргументы — `label`,\n * `value`, `buttonProps`, `renderDefault`, `ariaLabel`\n */\n renderItem?: (\n label: string,\n value: string,\n buttonProps: ButtonProps,\n renderDefault: () => React.ReactNode,\n ariaLabel?: string,\n ) => React.ReactNode;\n}\n\ntype DefaultProps = Required<Pick<SwitcherProps, 'role'>>;\n\nexport interface SwitcherState {\n focusedIndex: Nullable<number>;\n}\n\ninterface SwitcherItem {\n value: string;\n label: string;\n 'aria-label'?: string;\n buttonProps?: Partial<ButtonProps>;\n}\n\n@rootNode\nexport class Switcher extends React.Component<SwitcherProps, SwitcherState> {\n public static __KONTUR_REACT_UI__ = 'Switcher';\n public static displayName = 'Switcher';\n\n public static defaultProps: DefaultProps = {\n role: 'switch',\n };\n\n public static propTypes = {\n error: PropTypes.bool,\n disabled: PropTypes.bool,\n items: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.string),\n PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string,\n value: PropTypes.string,\n }),\n ),\n ]).isRequired,\n caption: PropTypes.string,\n value: PropTypes.string,\n onValueChange: PropTypes.func,\n renderItem: PropTypes.func,\n };\n\n public state: SwitcherState = {\n focusedIndex: null,\n };\n\n private theme!: Theme;\n private emotion!: Emotion;\n private setRootNode!: TSetRootNode;\n\n public render() {\n return (\n <EmotionConsumer>\n {(emotion) => {\n this.emotion = emotion;\n return (\n <ThemeConsumer>\n {(theme) => {\n this.theme = getSwitcherTheme(theme);\n return <ThemeProvider value={this.theme}>{this.renderMain()}</ThemeProvider>;\n }}\n </ThemeConsumer>\n );\n }}\n </EmotionConsumer>\n );\n }\n\n private renderMain() {\n const styles = getStyles(this.emotion);\n const listClassName = this.emotion.cx({\n [styles.error(this.theme)]: !!this.props.error,\n });\n\n const inputProps = {\n type: 'checkbox',\n onKeyDown: this.handleKey,\n onFocus: this._handleFocus,\n onBlur: this._handleBlur,\n className: styles.input(),\n };\n\n const captionClassName = this.emotion.cx(styles.caption(this.theme), this.getLabelSizeClassName());\n\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <div data-tid={SwitcherDataTids.root} className={styles.root()}>\n {this.props.caption ? <div className={captionClassName}>{this.props.caption}</div> : null}\n <div className={styles.wrap()}>\n <input {...inputProps} />\n <div className={listClassName}>\n <Group>{this._renderItems()}</Group>\n </div>\n </div>\n </div>\n </CommonWrapper>\n );\n }\n\n private selectItem = (value: string) => {\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n };\n\n private _extractPropsFromItem = (item: string | SwitcherItem): SwitcherItem => {\n return typeof item === 'object' ? item : { label: item, value: item };\n };\n\n private _extractValuesFromItems = (): string[] => {\n return this.props.items.map((item) => {\n const { value } = this._extractPropsFromItem(item);\n return value;\n });\n };\n\n private _focus = (index: number) => {\n this.setState({ focusedIndex: index });\n };\n\n private handleKey = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const focusedIndex = this.state.focusedIndex;\n if (typeof focusedIndex !== 'number') {\n return;\n }\n\n if (isKeyEnter(e)) {\n if (this.props.onValueChange) {\n const { value, buttonProps } = this._extractPropsFromItem(this.props.items[focusedIndex]);\n if (!buttonProps?.disabled) {\n this.selectItem(value);\n }\n }\n return;\n }\n\n if (isKeyArrowHorizontal(e)) {\n e.preventDefault();\n this.move(isKeyArrowLeft(e));\n }\n };\n\n private move = (left: boolean) => {\n const selectedIndex = this.state.focusedIndex;\n\n if (typeof selectedIndex !== 'number') {\n return;\n }\n const newFocusedIndex = this._getNextFocusedIndex(left, selectedIndex);\n this._focus(newFocusedIndex);\n };\n\n private _getNextFocusedIndex = (left: boolean, focusedIndex: number): number => {\n const { items, disabled } = this.props;\n if (disabled) {\n return focusedIndex;\n }\n\n for (let i = 1; i < items.length; i++) {\n const index = mod(focusedIndex + (left ? -i : i), items.length);\n const { buttonProps } = this._extractPropsFromItem(items[index]);\n if (!buttonProps?.disabled) {\n return index;\n }\n }\n return focusedIndex;\n };\n\n private _handleFocus = () => {\n const { value } = this.props;\n\n const items = this._extractValuesFromItems();\n const currentIndex = [...items].indexOf(value as string);\n const index = currentIndex > -1 ? currentIndex : 0;\n\n this.setState({ focusedIndex: index });\n };\n\n private _handleBlur = () => {\n this.setState({ focusedIndex: null });\n };\n\n private _renderItems = () => {\n const { items, value, size, disabled, role, renderItem } = this.props;\n return items.map((item, i) => {\n const {\n 'aria-label': ariaLabel,\n label,\n value: itemValue,\n buttonProps: customButtonProps,\n } = this._extractPropsFromItem(item);\n\n const isChecked = value === itemValue;\n const commonButtonProps = {\n 'aria-checked': isChecked,\n role,\n checked: isChecked,\n visuallyFocused: this.state.focusedIndex === i,\n onClick: () => {\n this.selectItem(itemValue);\n },\n disableFocus: true,\n size,\n disabled,\n corners: getButtonCorners(i === 0, i === items.length - 1),\n };\n\n const buttonProps = {\n ...commonButtonProps,\n ...customButtonProps,\n };\n\n const renderDefault = () => this.renderDefaultItem(label, itemValue, buttonProps, ariaLabel);\n\n return renderItem ? renderItem(label, itemValue, buttonProps, renderDefault, ariaLabel) : renderDefault();\n });\n };\n\n private renderDefaultItem = (label: string, value: string, buttonProps: ButtonProps, ariaLabel?: string) => (\n <Button aria-label={ariaLabel} key={value} {...buttonProps}>\n {label}\n </Button>\n );\n\n private getLabelSizeClassName = (): string => {\n const styles = getStyles(this.emotion);\n switch (this.props.size) {\n case 'large':\n return styles.captionLarge(this.theme);\n case 'medium':\n return styles.captionMedium(this.theme);\n case 'small':\n default:\n return styles.captionSmall(this.theme);\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["Switcher.tsx"],"names":["SwitcherDataTids","root","Switcher","rootNode","state","focusedIndex","selectItem","value","props","onValueChange","_extractPropsFromItem","item","label","_extractValuesFromItems","items","map","_focus","index","setState","handleKey","e","buttonProps","disabled","preventDefault","move","left","selectedIndex","newFocusedIndex","_getNextFocusedIndex","i","length","_handleFocus","currentIndex","indexOf","_handleBlur","_renderItems","size","role","renderItem","ariaLabel","itemValue","customButtonProps","isChecked","commonButtonProps","checked","visuallyFocused","onClick","disableFocus","corners","renderDefault","renderDefaultItem","getLabelSizeClassName","styles","emotion","captionLarge","theme","captionMedium","captionSmall","render","renderMain","listClassName","cx","error","inputProps","type","onKeyDown","onFocus","onBlur","className","input","captionClassName","caption","setRootNode","wrap","React","Component","__KONTUR_REACT_UI__","displayName","defaultProps","propTypes","PropTypes","bool","oneOfType","arrayOf","string","shape","isRequired","func"],"mappings":"yWAAA;AACA;;;AAGA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,6C;;;;;;;;AAQO,IAAMA,gBAAgB,GAAG;AAC9BC,EAAAA,IAAI,EAAE,gBADwB,EAAzB,C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDMC,Q,OADZC,kB;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BQC,IAAAA,K,GAAuB;AAC5BC,MAAAA,YAAY,EAAE,IADc,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDtBC,IAAAA,U,GAAa,UAACC,KAAD,EAAmB;AACtC,UAAI,MAAKC,KAAL,CAAWC,aAAf,EAA8B;AAC5B,cAAKD,KAAL,CAAWC,aAAX,CAAyBF,KAAzB;AACD;AACF,K;;AAEOG,IAAAA,qB,GAAwB,UAACC,IAAD,EAA+C;AAC7E,aAAO,OAAOA,IAAP,KAAgB,QAAhB,GAA2BA,IAA3B,GAAkC,EAAEC,KAAK,EAAED,IAAT,EAAeJ,KAAK,EAAEI,IAAtB,EAAzC;AACD,K;;AAEOE,IAAAA,uB,GAA0B,YAAgB;AAChD,aAAO,MAAKL,KAAL,CAAWM,KAAX,CAAiBC,GAAjB,CAAqB,UAACJ,IAAD,EAAU;AACpC,oCAAkB,MAAKD,qBAAL,CAA2BC,IAA3B,CAAlB,CAAQJ,KAAR,yBAAQA,KAAR;AACA,eAAOA,KAAP;AACD,OAHM,CAAP;AAID,K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UI,MAbO,EAcxB3E,aAAa,EAAEuE,mBAAUO,IAdD,EAexBjD,UAAU,EAAE0C,mBAAUO,IAfE,E","sourcesContent":["import React, { HTMLAttributes } from 'react';\nimport PropTypes from 'prop-types';\nimport type { Emotion } from '@emotion/css/create-instance';\n\nimport { isKeyArrowHorizontal, isKeyArrowLeft, isKeyEnter } from '../../lib/events/keyboard/identifiers';\nimport { getButtonCorners, Group } from '../Group';\nimport { Button, ButtonProps } from '../Button';\nimport { Nullable } from '../../typings/utility-types';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { SizeProp } from '../../lib/types/props';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\n\nimport { getSwitcherTheme } from './switcherTheme';\nimport { mod } from './helpers';\nimport { getStyles } from './Switcher.styles';\n\n/**\n * @deprecated use SizeProp\n */\nexport type SwitcherSize = SizeProp;\nexport type SwitcherItems = string | SwitcherItem;\n\nexport const SwitcherDataTids = {\n root: 'Switcher__root',\n} as const;\n\nexport interface SwitcherProps extends Pick<HTMLAttributes<unknown>, 'role'>, CommonProps {\n /**\n * Список строк или список элементов типа `{ label: string, value: string, buttonProps?: Partial<ButtonProps> }`\n */\n items: SwitcherItems[];\n\n value?: string;\n\n onValueChange?: (value: string) => void;\n\n caption?: string;\n\n error?: boolean;\n\n /** Размер */\n size?: SizeProp;\n\n disabled?: boolean;\n\n /**\n * Функция для отрисовки элемента. Аргументы — `label`,\n * `value`, `buttonProps`, `renderDefault`, `ariaLabel`\n */\n renderItem?: (\n label: string,\n value: string,\n buttonProps: ButtonProps,\n renderDefault: () => React.ReactNode,\n ariaLabel?: string,\n ) => React.ReactNode;\n}\n\ntype DefaultProps = Required<Pick<SwitcherProps, 'role'>>;\n\nexport interface SwitcherState {\n focusedIndex: Nullable<number>;\n}\n\ninterface SwitcherItem {\n value: string;\n label: string;\n 'aria-label'?: string;\n buttonProps?: Partial<ButtonProps>;\n}\n\n@rootNode\nexport class Switcher extends React.Component<SwitcherProps, SwitcherState> {\n public static __KONTUR_REACT_UI__ = 'Switcher';\n public static displayName = 'Switcher';\n\n public static defaultProps: DefaultProps = {\n role: 'switch',\n };\n\n public static propTypes = {\n error: PropTypes.bool,\n disabled: PropTypes.bool,\n items: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.string),\n PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string,\n value: PropTypes.string,\n }),\n ),\n ]).isRequired,\n caption: PropTypes.string,\n value: PropTypes.string,\n onValueChange: PropTypes.func,\n renderItem: PropTypes.func,\n };\n\n public state: SwitcherState = {\n focusedIndex: null,\n };\n\n private theme!: Theme;\n private emotion!: Emotion;\n private setRootNode!: TSetRootNode;\n\n public render() {\n return (\n <EmotionConsumer>\n {(emotion) => {\n this.emotion = emotion;\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = getSwitcherTheme(theme);\n return <ThemeContext.Provider value={this.theme}>{this.renderMain()}</ThemeContext.Provider>;\n }}\n </ThemeContext.Consumer>\n );\n }}\n </EmotionConsumer>\n );\n }\n\n private renderMain() {\n const styles = getStyles(this.emotion);\n const listClassName = this.emotion.cx({\n [styles.error(this.theme)]: !!this.props.error,\n });\n\n const inputProps = {\n type: 'checkbox',\n onKeyDown: this.handleKey,\n onFocus: this._handleFocus,\n onBlur: this._handleBlur,\n className: styles.input(),\n };\n\n const captionClassName = this.emotion.cx(styles.caption(this.theme), this.getLabelSizeClassName());\n\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <div data-tid={SwitcherDataTids.root} className={styles.root()}>\n {this.props.caption ? <div className={captionClassName}>{this.props.caption}</div> : null}\n <div className={styles.wrap()}>\n <input {...inputProps} />\n <div className={listClassName}>\n <Group>{this._renderItems()}</Group>\n </div>\n </div>\n </div>\n </CommonWrapper>\n );\n }\n\n private selectItem = (value: string) => {\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n };\n\n private _extractPropsFromItem = (item: string | SwitcherItem): SwitcherItem => {\n return typeof item === 'object' ? item : { label: item, value: item };\n };\n\n private _extractValuesFromItems = (): string[] => {\n return this.props.items.map((item) => {\n const { value } = this._extractPropsFromItem(item);\n return value;\n });\n };\n\n private _focus = (index: number) => {\n this.setState({ focusedIndex: index });\n };\n\n private handleKey = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const focusedIndex = this.state.focusedIndex;\n if (typeof focusedIndex !== 'number') {\n return;\n }\n\n if (isKeyEnter(e)) {\n if (this.props.onValueChange) {\n const { value, buttonProps } = this._extractPropsFromItem(this.props.items[focusedIndex]);\n if (!buttonProps?.disabled) {\n this.selectItem(value);\n }\n }\n return;\n }\n\n if (isKeyArrowHorizontal(e)) {\n e.preventDefault();\n this.move(isKeyArrowLeft(e));\n }\n };\n\n private move = (left: boolean) => {\n const selectedIndex = this.state.focusedIndex;\n\n if (typeof selectedIndex !== 'number') {\n return;\n }\n const newFocusedIndex = this._getNextFocusedIndex(left, selectedIndex);\n this._focus(newFocusedIndex);\n };\n\n private _getNextFocusedIndex = (left: boolean, focusedIndex: number): number => {\n const { items, disabled } = this.props;\n if (disabled) {\n return focusedIndex;\n }\n\n for (let i = 1; i < items.length; i++) {\n const index = mod(focusedIndex + (left ? -i : i), items.length);\n const { buttonProps } = this._extractPropsFromItem(items[index]);\n if (!buttonProps?.disabled) {\n return index;\n }\n }\n return focusedIndex;\n };\n\n private _handleFocus = () => {\n const { value } = this.props;\n\n const items = this._extractValuesFromItems();\n const currentIndex = [...items].indexOf(value as string);\n const index = currentIndex > -1 ? currentIndex : 0;\n\n this.setState({ focusedIndex: index });\n };\n\n private _handleBlur = () => {\n this.setState({ focusedIndex: null });\n };\n\n private _renderItems = () => {\n const { items, value, size, disabled, role, renderItem } = this.props;\n return items.map((item, i) => {\n const {\n 'aria-label': ariaLabel,\n label,\n value: itemValue,\n buttonProps: customButtonProps,\n } = this._extractPropsFromItem(item);\n\n const isChecked = value === itemValue;\n const commonButtonProps = {\n 'aria-checked': isChecked,\n role,\n checked: isChecked,\n visuallyFocused: this.state.focusedIndex === i,\n onClick: () => {\n this.selectItem(itemValue);\n },\n disableFocus: true,\n size,\n disabled,\n corners: getButtonCorners(i === 0, i === items.length - 1),\n };\n\n const buttonProps = {\n ...commonButtonProps,\n ...customButtonProps,\n };\n\n const renderDefault = () => this.renderDefaultItem(label, itemValue, buttonProps, ariaLabel);\n\n return renderItem ? renderItem(label, itemValue, buttonProps, renderDefault, ariaLabel) : renderDefault();\n });\n };\n\n private renderDefaultItem = (label: string, value: string, buttonProps: ButtonProps, ariaLabel?: string) => (\n <Button aria-label={ariaLabel} key={value} {...buttonProps}>\n {label}\n </Button>\n );\n\n private getLabelSizeClassName = (): string => {\n const styles = getStyles(this.emotion);\n switch (this.props.size) {\n case 'large':\n return styles.captionLarge(this.theme);\n case 'medium':\n return styles.captionMedium(this.theme);\n case 'small':\n default:\n return styles.captionSmall(this.theme);\n }\n };\n}\n"]}
|
|
@@ -125,7 +125,7 @@ Indicator = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/fun
|
|
|
125
125
|
if (stylesUpdated) {
|
|
126
126
|
_this.setState({ styles: nodeStyles });
|
|
127
127
|
}
|
|
128
|
-
}, 100);return _this;}var _proto = Indicator.prototype;_proto.componentDidMount = function componentDidMount() {this.eventListener = LayoutEvents.addListener(this.reflow);this.removeTabUpdatesListener = this.props.tabUpdates.on(this.reflow);this.reflow();};_proto.componentWillUnmount = function componentWillUnmount() {this.reflow.cancel();if (this.eventListener) {this.eventListener.remove();}if (this.removeTabUpdatesListener) {this.removeTabUpdatesListener();}};_proto.componentDidUpdate = function componentDidUpdate() {this.reflow();};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.
|
|
128
|
+
}, 100);return _this;}var _proto = Indicator.prototype;_proto.componentDidMount = function componentDidMount() {this.eventListener = LayoutEvents.addListener(this.reflow);this.removeTabUpdatesListener = this.props.tabUpdates.on(this.reflow);this.reflow();};_proto.componentWillUnmount = function componentWillUnmount() {this.reflow.cancel();if (this.eventListener) {this.eventListener.remove();}if (this.removeTabUpdatesListener) {this.removeTabUpdatesListener();}};_proto.componentDidUpdate = function componentDidUpdate() {this.reflow();};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return _this2.renderMain();});});};_proto.renderMain = function renderMain() {var _this$context2 = this.context,getTab = _this$context2.getTab,activeTab = _this$context2.activeTab;var node = getTab(activeTab);var indicators = node && node.getIndicators && node.getIndicators() || { error: false, warning: false, success: false, primary: false, disabled: false };var styles = (0, _Indicator.getStyles)(this.emotion);return /*#__PURE__*/_react.default.createElement("div", { "data-tid": _Tabs.TabsDataTids.indicatorRoot, className: this.emotion.cx(styles.root(this.theme), indicators.primary && styles.primary(this.theme), indicators.success && styles.success(this.theme), indicators.warning && styles.warning(this.theme), indicators.error && styles.error(this.theme), this.props.className), style: this.state.styles, ref: this.setRootNode });};_proto.
|
|
129
129
|
|
|
130
130
|
getStyles = function getStyles(node) {
|
|
131
131
|
var htmlNode = (0, _rootNode.getRootNode)(node);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Indicator.tsx"],"names":["Indicator","rootNode","context","state","styles","eventListener","removeTabUpdatesListener","reflow","getTab","activeTab","node","nodeStyles","getStyles","stylesUpdated","some","prop","setState","componentDidMount","LayoutEvents","addListener","props","tabUpdates","on","componentWillUnmount","cancel","remove","componentDidUpdate","render","emotion","theme","renderMain","indicators","getIndicators","error","warning","success","primary","disabled","TabsDataTids","indicatorRoot","cx","root","className","setRootNode","htmlNode","globalObject","HTMLElement","rect","vertical","width","tabBorderWidth","left","offsetLeft","top","offsetTop","height","bottom","parseInt","offsetHeight","right","React","Component","contextType","TabsContext"],"mappings":"4VAAA;AACA;AACA;;;AAGA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,8B;;;;;;;;;;;;;;;AAeaA,S,OADZC,kB;;AAGQC,IAAAA,O,GAA2B,MAAKA,O;;AAEhCC,IAAAA,K,GAAwB;AAC7BC,MAAAA,MAAM,EAAE,EADqB,E;;;;;;AAOvBC,IAAAA,a;;AAEH,Q;;AAEGC,IAAAA,wB,GAAiD,I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEjDC,IAAAA,M,GAAS,qBAAS,YAAM;AAC9B,0BAA8B,MAAKL,OAAnC,CAAQM,MAAR,iBAAQA,MAAR,CAAgBC,SAAhB,iBAAgBA,SAAhB;AACA,UAAMC,IAAI,GAAGF,MAAM,CAACC,SAAD,CAAnB;AACA,UAAME,UAAU,GAAG,MAAKC,SAAL,CAAeF,IAAf,CAAnB;AACA,UAAMG,aAAa,GAAG,CAAC,MAAD,EAAS,KAAT,EAAgB,OAAhB,EAAyB,QAAzB,EAAmCC,IAAnC;AACpB,gBAACC,IAAD,UAAUJ,UAAU,CAACI,IAAD,CAAV,KAAkD,MAAKZ,KAAL,CAAWC,MAAX,CAAkBW,IAAlB,CAA5D,EADoB,CAAtB;;AAGA,UAAIF,aAAJ,EAAmB;AACjB,cAAKG,QAAL,CAAc,EAAEZ,MAAM,EAAEO,UAAV,EAAd;AACD;AACF,KAVgB,EAUd,GAVc,C,uDAnEVM,iB,GAAP,6BAA2B,CACzB,KAAKZ,aAAL,GAAqBa,YAAY,CAACC,WAAb,CAAyB,KAAKZ,MAA9B,CAArB,CACA,KAAKD,wBAAL,GAAgC,KAAKc,KAAL,CAAWC,UAAX,CAAsBC,EAAtB,CAAyB,KAAKf,MAA9B,CAAhC,CACA,KAAKA,MAAL,GACD,C,QAEMgB,oB,GAAP,gCAA8B,CAC5B,KAAKhB,MAAL,CAAYiB,MAAZ,GAEA,IAAI,KAAKnB,aAAT,EAAwB,CACtB,KAAKA,aAAL,CAAmBoB,MAAnB,GACD,CACD,IAAI,KAAKnB,wBAAT,EAAmC,CACjC,KAAKA,wBAAL,GACD,CACF,C,QAEMoB,kB,GAAP,8BAA4B,CAC1B,KAAKnB,MAAL,GACD,C,QAEMoB,M,GAAP,kBAAgB,mBACd,oBACE,6BAAC,wBAAD,QACG,UAACC,OAAD,EAAa,CACZ,MAAI,CAACA,OAAL,GAAeA,OAAf,CACA,oBACE,6BAAC,
|
|
1
|
+
{"version":3,"sources":["Indicator.tsx"],"names":["Indicator","rootNode","context","state","styles","eventListener","removeTabUpdatesListener","reflow","getTab","activeTab","node","nodeStyles","getStyles","stylesUpdated","some","prop","setState","componentDidMount","LayoutEvents","addListener","props","tabUpdates","on","componentWillUnmount","cancel","remove","componentDidUpdate","render","emotion","theme","renderMain","indicators","getIndicators","error","warning","success","primary","disabled","TabsDataTids","indicatorRoot","cx","root","className","setRootNode","htmlNode","globalObject","HTMLElement","rect","vertical","width","tabBorderWidth","left","offsetLeft","top","offsetTop","height","bottom","parseInt","offsetHeight","right","React","Component","contextType","TabsContext"],"mappings":"4VAAA;AACA;AACA;;;AAGA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,8B;;;;;;;;;;;;;;;AAeaA,S,OADZC,kB;;AAGQC,IAAAA,O,GAA2B,MAAKA,O;;AAEhCC,IAAAA,K,GAAwB;AAC7BC,MAAAA,MAAM,EAAE,EADqB,E;;;;;;AAOvBC,IAAAA,a;;AAEH,Q;;AAEGC,IAAAA,wB,GAAiD,I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEjDC,IAAAA,M,GAAS,qBAAS,YAAM;AAC9B,0BAA8B,MAAKL,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EAAuBC,2BAAaC,WAApC,CAAJ,EAAsD;AACpD,UAAMC,IAAI,GAAG,4BAAWH,QAAX,CAAb;AACA,UAAI,KAAKxB,KAAL,CAAW4B,QAAf,EAAyB;AACvB,eAAO;AACLC,UAAAA,KAAK,EAAE,KAAKpB,KAAL,CAAWqB,cADb;AAELC,UAAAA,IAAI,EAAEP,QAAQ,CAACQ,UAFV;AAGLC,UAAAA,GAAG,EAAET,QAAQ,CAACU,SAHT;AAILC,UAAAA,MAAM,EAAER,IAAI,CAACS,MAAL,GAAcT,IAAI,CAACM,GAJtB,EAAP;;AAMD;;AAED,UAAMH,cAAc,GAAGO,QAAQ,CAAC,KAAK5B,KAAL,CAAWqB,cAAZ,EAA4B,EAA5B,CAAR,IAA2C,CAAlE;AACA,aAAO;AACLC,QAAAA,IAAI,EAAEP,QAAQ,CAACQ,UADV;AAELC,QAAAA,GAAG,EAAET,QAAQ,CAACc,YAAT,GAAwBd,QAAQ,CAACU,SAAjC,GAA6CJ,cAF7C;AAGLD,QAAAA,KAAK,EAAEF,IAAI,CAACY,KAAL,GAAaZ,IAAI,CAACI,IAHpB,EAAP;;AAKD;;AAED,WAAO,EAAP;AACD,G,oBAxH4BS,eAAMC,S,WACrBC,W,GAAcC,wB","sourcesContent":["import React from 'react';\nimport throttle from 'lodash.throttle';\nimport { globalObject } from '@skbkontur/global-object';\nimport type { Emotion } from '@emotion/css/create-instance';\n\nimport { isInstanceOf } from '../../lib/isInstanceOf';\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { Nullable } from '../../typings/utility-types';\nimport { Theme } from '../../lib/theming/Theme';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { getDOMRect } from '../../lib/dom/getDOMRect';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\n\nimport { getStyles } from './Indicator.styles';\nimport { TabsContext, TabsContextType } from './TabsContext';\nimport { TabIndicators } from './Tab';\nimport { TabsDataTids } from './Tabs';\n\nexport interface IndicatorProps {\n className?: string;\n tabUpdates: {\n on: (x0: () => void) => () => void;\n };\n vertical: boolean;\n}\n\nexport interface IndicatorState {\n styles: React.CSSProperties;\n}\n\n@rootNode\nexport class Indicator extends React.Component<IndicatorProps, IndicatorState> {\n public static contextType = TabsContext;\n public context: TabsContextType = this.context;\n\n public state: IndicatorState = {\n styles: {},\n };\n\n private theme!: Theme;\n private emotion!: Emotion;\n\n private eventListener: Nullable<{\n remove: () => void;\n }> = null;\n\n private removeTabUpdatesListener: Nullable<() => void> = null;\n private setRootNode!: TSetRootNode;\n\n public componentDidMount() {\n this.eventListener = LayoutEvents.addListener(this.reflow);\n this.removeTabUpdatesListener = this.props.tabUpdates.on(this.reflow);\n this.reflow();\n }\n\n public componentWillUnmount() {\n this.reflow.cancel();\n\n if (this.eventListener) {\n this.eventListener.remove();\n }\n if (this.removeTabUpdatesListener) {\n this.removeTabUpdatesListener();\n }\n }\n\n public componentDidUpdate() {\n this.reflow();\n }\n\n public render() {\n return (\n <EmotionConsumer>\n {(emotion) => {\n this.emotion = emotion;\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }}\n </EmotionConsumer>\n );\n }\n\n private renderMain() {\n const { getTab, activeTab } = this.context;\n const node = getTab(activeTab);\n const indicators: TabIndicators = (node && node.getIndicators && node.getIndicators()) || {\n error: false,\n warning: false,\n success: false,\n primary: false,\n disabled: false,\n };\n const styles = getStyles(this.emotion);\n return (\n <div\n data-tid={TabsDataTids.indicatorRoot}\n className={this.emotion.cx(\n styles.root(this.theme),\n indicators.primary && styles.primary(this.theme),\n indicators.success && styles.success(this.theme),\n indicators.warning && styles.warning(this.theme),\n indicators.error && styles.error(this.theme),\n this.props.className,\n )}\n style={this.state.styles}\n ref={this.setRootNode}\n />\n );\n }\n\n private reflow = throttle(() => {\n const { getTab, activeTab } = this.context;\n const node = getTab(activeTab);\n const nodeStyles = this.getStyles(node);\n const stylesUpdated = ['left', 'top', 'width', 'height'].some(\n (prop) => nodeStyles[prop as keyof React.CSSProperties] !== this.state.styles[prop as keyof React.CSSProperties],\n );\n if (stylesUpdated) {\n this.setState({ styles: nodeStyles });\n }\n }, 100);\n\n private getStyles(node: any): React.CSSProperties {\n const htmlNode = getRootNode(node);\n\n if (isInstanceOf(htmlNode, globalObject.HTMLElement)) {\n const rect = getDOMRect(htmlNode);\n if (this.props.vertical) {\n return {\n width: this.theme.tabBorderWidth,\n left: htmlNode.offsetLeft,\n top: htmlNode.offsetTop,\n height: rect.bottom - rect.top,\n };\n }\n\n const tabBorderWidth = parseInt(this.theme.tabBorderWidth, 10) || 0;\n return {\n left: htmlNode.offsetLeft,\n top: htmlNode.offsetHeight + htmlNode.offsetTop - tabBorderWidth,\n width: rect.right - rect.left,\n };\n }\n\n return {};\n }\n}\n"]}
|
|
@@ -14,7 +14,7 @@ var _Emotion = require("../../lib/theming/Emotion");
|
|
|
14
14
|
var _rootNode = require("../../lib/rootNode");
|
|
15
15
|
var _createPropsGetter = require("../../lib/createPropsGetter");
|
|
16
16
|
|
|
17
|
-
var _getVisualStateDataAttributes = require("../../internal/CommonWrapper/getVisualStateDataAttributes");
|
|
17
|
+
var _getVisualStateDataAttributes = require("../../internal/CommonWrapper/utils/getVisualStateDataAttributes");
|
|
18
18
|
var _ThemeContext = require("../../lib/theming/ThemeContext");
|
|
19
19
|
|
|
20
20
|
var _TabsContext = require("./TabsContext");
|
|
@@ -324,4 +324,4 @@ Tab = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/function
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
_this.setState({ focusedByKeyboard: false });
|
|
327
|
-
};(0, _invariant.default)(_this.context !== _TabsContext.TabsContextDefaultValue, 'Tab should be placed inside Tabs component');return _this;}var _proto = Tab.prototype;_proto.componentDidMount = function componentDidMount() {var id = this.getId();if (typeof id === 'string') {this.context.addTab(id, this.getTabInstance);}};_proto.componentDidUpdate = function componentDidUpdate() {if (this.context.activeTab === this.props.id) {this.context.notifyUpdate();}};_proto.componentWillUnmount = function componentWillUnmount() {var id = this.getId();if (typeof id === 'string') {this.context.removeTab(id);}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.
|
|
327
|
+
};(0, _invariant.default)(_this.context !== _TabsContext.TabsContextDefaultValue, 'Tab should be placed inside Tabs component');return _this;}var _proto = Tab.prototype;_proto.componentDidMount = function componentDidMount() {var id = this.getId();if (typeof id === 'string') {this.context.addTab(id, this.getTabInstance);}};_proto.componentDidUpdate = function componentDidUpdate() {if (this.context.activeTab === this.props.id) {this.context.notifyUpdate();}};_proto.componentWillUnmount = function componentWillUnmount() {var id = this.getId();if (typeof id === 'string') {this.context.removeTab(id);}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return _this2.renderMain();});});};_proto.getIndicators = function getIndicators() {return { error: Boolean(this.props.error), warning: Boolean(this.props.warning), success: Boolean(this.props.success), primary: Boolean(this.props.primary), disabled: Boolean(this.props.disabled) };};_proto.renderMain = function renderMain() {var _this$emotion$cx, _this$emotion$cx2;var _this$props = this.props,children = _this$props.children,disabled = _this$props.disabled,error = _this$props.error,warning = _this$props.warning,success = _this$props.success,primary = _this$props.primary,ariaDescribedby = _this$props['aria-describedby'],ariaLabel = _this$props['aria-label'];var _this$getProps2 = this.getProps(),Component = _this$getProps2.component,href = _this$getProps2.href;var isActive = false;var isVertical = false;var id = this.getId();if (typeof id === 'string') {isActive = this.context.activeTab === this.getId();isVertical = this.context.vertical;}var orientationStyles = isVertical ? (0, _Tab.getVerticalStyles)(this.emotion) : (0, _Tab.getHorizontalStyles)(this.emotion);var styles = (0, _Tab.getStyles)(this.emotion);return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, (0, _getVisualStateDataAttributes.getVisualStateDataAttributes)({ active: isActive, disabled: disabled }), this.props), /*#__PURE__*/_react.default.createElement(Component, { "data-tid": TabDataTids.root, className: this.emotion.cx((_this$emotion$cx = {}, _this$emotion$cx[styles.rootSmall(this.theme)] = this.context.size === 'small', _this$emotion$cx[styles.rootMedium(this.theme)] = this.context.size === 'medium', _this$emotion$cx[styles.rootLarge(this.theme)] = this.context.size === 'large', _this$emotion$cx[styles.verticalSmall(this.theme)] = !!isVertical && this.context.size === 'small', _this$emotion$cx[styles.verticalMedium(this.theme)] = !!isVertical && this.context.size === 'medium', _this$emotion$cx[styles.verticalLarge(this.theme)] = !!isVertical && this.context.size === 'large', _this$emotion$cx[orientationStyles.primary(this.theme)] = !!primary, _this$emotion$cx[orientationStyles.success(this.theme)] = !!success, _this$emotion$cx[orientationStyles.warning(this.theme)] = !!warning, _this$emotion$cx[orientationStyles.error(this.theme)] = !!error, _this$emotion$cx[styles.active()] = !!isActive, _this$emotion$cx[orientationStyles.active(this.theme)] = !!isActive, _this$emotion$cx[styles.disabled(this.theme)] = !!disabled, _this$emotion$cx[orientationStyles.disabled()] = !!disabled, _this$emotion$cx)), onBlur: this.handleBlur, onClick: this.switchTab, onFocus: this.handleFocus, onKeyDown: this.handleKeyDown, tabIndex: disabled ? -1 : 0, ref: (0, _utils.isFunctionalComponent)(Component) ? null : this.refTabComponent, href: href, "aria-describedby": ariaDescribedby, "aria-label": ariaLabel }, /*#__PURE__*/_react.default.createElement(_ResizeDetector.ResizeDetector, { onResize: this.context.notifyUpdate }, children), this.state.focusedByKeyboard && /*#__PURE__*/_react.default.createElement("div", { className: this.emotion.cx(_Tab.globalClasses.focus, (_this$emotion$cx2 = {}, _this$emotion$cx2[styles.focusSmall(this.theme)] = this.context.size === 'small', _this$emotion$cx2[styles.focusMedium(this.theme)] = this.context.size === 'medium', _this$emotion$cx2[styles.focusLarge(this.theme)] = this.context.size === 'large', _this$emotion$cx2)) })));};return Tab;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Tab', _class2.displayName = 'Tab', _class2.contextType = _TabsContext.TabsContext, _class2.defaultProps = { component: 'a', href: '' }, _temp)) || _class;exports.Tab = Tab;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Tab.tsx"],"names":["TabDataTids","root","Tab","rootNode","props","context","getProps","defaultProps","state","focusedByKeyboard","tabComponent","getUnderlyingNode","getId","id","href","refTabComponent","instance","getTabInstance","switchTab","event","disabled","preventDefault","component","onClick","defaultPrevented","handleKeyDown","e","onKeyDown","delta","shiftFocus","handleFocus","globalObject","requestAnimationFrame","keyListener","isTabPressed","isArrowPressed","setState","handleBlur","TabsContextDefaultValue","componentDidMount","addTab","componentDidUpdate","activeTab","notifyUpdate","componentWillUnmount","removeTab","render","emotion","theme","renderMain","getIndicators","error","Boolean","warning","success","primary","children","ariaDescribedby","ariaLabel","Component","isActive","isVertical","vertical","orientationStyles","styles","setRootNode","active","cx","rootSmall","size","rootMedium","rootLarge","verticalSmall","verticalMedium","verticalLarge","globalClasses","focus","focusSmall","focusMedium","focusLarge","React","__KONTUR_REACT_UI__","displayName","contextType","TabsContext"],"mappings":"6cAAA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,mC;;;;;;;;;;AAUO,IAAMA,WAAW,GAAG;AACzBC,EAAAA,IAAI,EAAE,WADmB,EAApB;;;AAIP;AACA;AACA,G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA;AACA;AACA,G;;AAEaC,G,OADZC,kB;;;;;;;;;;;;;;;;;;;;;;;AAwBC,eAAYC,KAAZ,EAAgC;AAC9B,wCAAMA,KAAN,UA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,EAAE,KAAKnB,SAnBhB,EAoBE,OAAO,EAAE,KAAKY,WApBhB,EAqBE,SAAS,EAAE,KAAKL,aArBlB,EAsBE,QAAQ,EAAEL,QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAtB5B,EAuBE,GAAG,EAAE,kCAAsBuC,SAAtB,IAAmC,IAAnC,GAA0C,KAAK5C,eAvBtD,EAwBE,IAAI,EAAED,IAxBR,EAyBE,oBAAkB2C,eAzBpB,EA0BE,cAAYC,SA1Bd,iBA4BE,6BAAC,8BAAD,IAAgB,QAAQ,EAAE,KAAKrD,OAAL,CAAasC,YAAvC,IAAsDa,QAAtD,CA5BF,EA6BG,KAAKhD,KAAL,CAAWC,iBAAX,iBACC,sCACE,SAAS,EAAE,KAAKsC,OAAL,CAAaoB,EAAb,CAAgBQ,mBAAcC,KAA9B,6CACRZ,MAAM,CAACa,UAAP,CAAkB,KAAK7B,KAAvB,CADQ,IACwB,KAAK3C,OAAL,CAAagE,IAAb,KAAsB,OAD9C,oBAERL,MAAM,CAACc,WAAP,CAAmB,KAAK9B,KAAxB,CAFQ,IAEyB,KAAK3C,OAAL,CAAagE,IAAb,KAAsB,QAF/C,oBAGRL,MAAM,CAACe,UAAP,CAAkB,KAAK/B,KAAvB,CAHQ,IAGwB,KAAK3C,OAAL,CAAagE,IAAb,KAAsB,OAH9C,qBADb,GA9BJ,CALF,CADF,CA+CD,C,cApJiDW,eAAMrB,S,WAC1CsB,mB,GAAsB,K,UACtBC,W,GAAc,K,UAEdC,W,GAAcC,wB,UAGd7E,Y,GAA6B,EACzCe,SAAS,EAAE,GAD8B,EAEzCR,IAAI,EAAE,EAFmC,E","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport invariant from 'invariant';\nimport { globalObject } from '@skbkontur/global-object';\nimport type { Emotion } from '@emotion/css/create-instance';\n\nimport { ResizeDetector } from '../../internal/ResizeDetector';\nimport { isKeyArrow, isKeyArrowLeft, isKeyArrowUp } from '../../lib/events/keyboard/identifiers';\nimport { keyListener } from '../../lib/events/keyListener';\nimport { Nullable } from '../../typings/utility-types';\nimport { isFunctionalComponent } from '../../lib/utils';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { SizeProp } from '../../lib/types/props';\nimport { getVisualStateDataAttributes } from '../../internal/CommonWrapper/getVisualStateDataAttributes';\nimport { ThemeConsumer } from '../../lib/theming/ThemeContext';\n\nimport { TabsContext, TabsContextDefaultValue, TabsContextType } from './TabsContext';\nimport { getHorizontalStyles, getStyles, getVerticalStyles, globalClasses } from './Tab.styles';\n\nexport interface TabIndicators {\n error: boolean;\n warning: boolean;\n success: boolean;\n primary: boolean;\n disabled: boolean;\n}\n\nexport const TabDataTids = {\n root: 'Tab__root',\n} as const;\n\n/**\n * @deprecated use SizeProp\n */\nexport type TabSize = SizeProp;\n\nexport interface TabProps<T extends string = string>\n extends Pick<AriaAttributes, 'aria-label' | 'aria-describedby'>,\n CommonProps {\n /**\n * Позволяет передавать свой компонент, строку или функцию, которая заменит собой элемент используемый в компоненте по умолчанию. Реализует паттерн [render prop](https://www.patterns.dev/posts/render-props-pattern).\n */\n component?: React.ComponentType<any> | string;\n\n /**\n * `HTML`-аттрибут `href`.\n */\n href?: string;\n\n /**\n * Уникальный идентификатор таба. По нему компонент `<Tabs />` определяет какой `<Tab />` сейчас выбран.\n */\n id?: T;\n\n /**\n * `HTML`-событие `onclick`.\n */\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n\n /**\n * `HTML`-событие `onkeydown`.\n */\n onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void;\n\n /**\n * Переводит компонент в отключенное состояние.\n */\n disabled?: boolean;\n\n /**\n * Визуальное состояние ошибки.\n */\n error?: boolean;\n\n /**\n * Визуальное состояние предупреждения.\n */\n warning?: boolean;\n\n /**\n * Визуальное состояние успеха.\n */\n success?: boolean;\n\n /**\n * Визуальное состояние главного элемента.\n */\n primary?: boolean;\n}\n\nexport interface TabState {\n focusedByKeyboard: boolean;\n}\n\ntype DefaultProps = Required<Pick<TabProps, 'component' | 'href'>>;\n\n/**\n * Вложенный элемент компонента `<Tabs />`.\n */\n@rootNode\nexport class Tab<T extends string = string> extends React.Component<TabProps<T>, TabState> {\n public static __KONTUR_REACT_UI__ = 'Tab';\n public static displayName = 'Tab';\n\n public static contextType = TabsContext;\n public context: TabsContextType = this.context;\n\n public static defaultProps: DefaultProps = {\n component: 'a',\n href: '',\n };\n\n private getProps = createPropsGetter(Tab.defaultProps);\n\n public state: TabState = {\n focusedByKeyboard: false,\n };\n\n private theme!: Theme;\n private emotion!: Emotion;\n private tabComponent: Nullable<React.ReactElement<Tab<T>>> = null;\n private setRootNode!: TSetRootNode;\n\n constructor(props: TabProps<T>) {\n super(props);\n invariant(this.context !== TabsContextDefaultValue, 'Tab should be placed inside Tabs component');\n }\n\n public componentDidMount() {\n const id = this.getId();\n if (typeof id === 'string') {\n this.context.addTab(id, this.getTabInstance);\n }\n }\n\n public componentDidUpdate() {\n if (this.context.activeTab === this.props.id) {\n this.context.notifyUpdate();\n }\n }\n\n public componentWillUnmount() {\n const id = this.getId();\n if (typeof id === 'string') {\n this.context.removeTab(id);\n }\n }\n\n public render() {\n return (\n <EmotionConsumer>\n {(emotion) => {\n this.emotion = emotion;\n return (\n <ThemeConsumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeConsumer>\n );\n }}\n </EmotionConsumer>\n );\n }\n\n public getIndicators() {\n return {\n error: Boolean(this.props.error),\n warning: Boolean(this.props.warning),\n success: Boolean(this.props.success),\n primary: Boolean(this.props.primary),\n disabled: Boolean(this.props.disabled),\n };\n }\n\n public getUnderlyingNode = () => this.tabComponent;\n\n private renderMain() {\n const {\n children,\n disabled,\n error,\n warning,\n success,\n primary,\n 'aria-describedby': ariaDescribedby,\n 'aria-label': ariaLabel,\n } = this.props;\n const { component: Component, href } = this.getProps();\n\n let isActive = false;\n let isVertical = false;\n\n const id = this.getId();\n if (typeof id === 'string') {\n isActive = this.context.activeTab === this.getId();\n isVertical = this.context.vertical;\n }\n const orientationStyles = isVertical ? getVerticalStyles(this.emotion) : getHorizontalStyles(this.emotion);\n const styles = getStyles(this.emotion);\n return (\n <CommonWrapper\n rootNodeRef={this.setRootNode}\n {...getVisualStateDataAttributes({ active: isActive, disabled })}\n {...this.props}\n >\n <Component\n data-tid={TabDataTids.root}\n className={this.emotion.cx({\n [styles.rootSmall(this.theme)]: this.context.size === 'small',\n [styles.rootMedium(this.theme)]: this.context.size === 'medium',\n [styles.rootLarge(this.theme)]: this.context.size === 'large',\n [styles.verticalSmall(this.theme)]: !!isVertical && this.context.size === 'small',\n [styles.verticalMedium(this.theme)]: !!isVertical && this.context.size === 'medium',\n [styles.verticalLarge(this.theme)]: !!isVertical && this.context.size === 'large',\n [orientationStyles.primary(this.theme)]: !!primary,\n [orientationStyles.success(this.theme)]: !!success,\n [orientationStyles.warning(this.theme)]: !!warning,\n [orientationStyles.error(this.theme)]: !!error,\n [styles.active()]: !!isActive,\n [orientationStyles.active(this.theme)]: !!isActive,\n [styles.disabled(this.theme)]: !!disabled,\n [orientationStyles.disabled()]: !!disabled,\n })}\n onBlur={this.handleBlur}\n onClick={this.switchTab}\n onFocus={this.handleFocus}\n onKeyDown={this.handleKeyDown}\n tabIndex={disabled ? -1 : 0}\n ref={isFunctionalComponent(Component) ? null : this.refTabComponent}\n href={href}\n aria-describedby={ariaDescribedby}\n aria-label={ariaLabel}\n >\n <ResizeDetector onResize={this.context.notifyUpdate}>{children}</ResizeDetector>\n {this.state.focusedByKeyboard && (\n <div\n className={this.emotion.cx(globalClasses.focus, {\n [styles.focusSmall(this.theme)]: this.context.size === 'small',\n [styles.focusMedium(this.theme)]: this.context.size === 'medium',\n [styles.focusLarge(this.theme)]: this.context.size === 'large',\n })}\n />\n )}\n </Component>\n </CommonWrapper>\n );\n }\n\n private getId = () => this.props.id || this.getProps().href;\n\n private refTabComponent = (instance: React.ReactElement<any>) => {\n this.tabComponent = instance;\n };\n\n private getTabInstance = () => this;\n\n private switchTab = (event: React.MouseEvent<HTMLElement>) => {\n if (this.props.disabled) {\n event.preventDefault();\n return;\n }\n const { href, component } = this.getProps();\n\n const id = this.props.id || href;\n if (this.props.onClick) {\n this.props.onClick(event);\n if (event.defaultPrevented) {\n return;\n }\n }\n if (typeof id === 'string') {\n this.context.switchTab(id);\n }\n if (component === 'a' && !href) {\n event.preventDefault();\n }\n };\n\n private handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.props.onKeyDown) {\n this.props.onKeyDown(e);\n if (e.defaultPrevented) {\n return;\n }\n }\n const id = this.getId();\n if (typeof id !== 'string') {\n return;\n }\n if (!isKeyArrow(e)) {\n return;\n }\n e.preventDefault();\n const delta = isKeyArrowLeft(e) || isKeyArrowUp(e) ? -1 : 1;\n this.context.shiftFocus(id, delta);\n };\n\n private handleFocus = () => {\n if (this.props.disabled) {\n return;\n }\n\n // focus event fires before keyDown eventlistener\n // so we should check focusKeyPressed in async way\n globalObject.requestAnimationFrame?.(() => {\n if (keyListener.isTabPressed || keyListener.isArrowPressed) {\n this.setState({ focusedByKeyboard: true });\n }\n });\n };\n\n private handleBlur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.setState({ focusedByKeyboard: false });\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["Tab.tsx"],"names":["TabDataTids","root","Tab","rootNode","props","context","getProps","defaultProps","state","focusedByKeyboard","tabComponent","getUnderlyingNode","getId","id","href","refTabComponent","instance","getTabInstance","switchTab","event","disabled","preventDefault","component","onClick","defaultPrevented","handleKeyDown","e","onKeyDown","delta","shiftFocus","handleFocus","globalObject","requestAnimationFrame","keyListener","isTabPressed","isArrowPressed","setState","handleBlur","TabsContextDefaultValue","componentDidMount","addTab","componentDidUpdate","activeTab","notifyUpdate","componentWillUnmount","removeTab","render","emotion","theme","renderMain","getIndicators","error","Boolean","warning","success","primary","children","ariaDescribedby","ariaLabel","Component","isActive","isVertical","vertical","orientationStyles","styles","setRootNode","active","cx","rootSmall","size","rootMedium","rootLarge","verticalSmall","verticalMedium","verticalLarge","globalClasses","focus","focusSmall","focusMedium","focusLarge","React","__KONTUR_REACT_UI__","displayName","contextType","TabsContext"],"mappings":"6cAAA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,mC;;;;;;;;;;AAUO,IAAMA,WAAW,GAAG;AACzBC,EAAAA,IAAI,EAAE,WADmB,EAApB;;;AAIP;AACA;AACA,G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA;AACA;AACA,G;;AAEaC,G,OADZC,kB;;;;;;;;;;;;;;;;;;;;;;;AAwBC,eAAYC,KAAZ,EAAgC;AAC9B,wCAAMA,KAAN,UAD8B,MAlBzBC,OAkByB,GAlBE,MAAKA,OAkBP,OAXxBC,QAWwB,GAXb,0CAAkBJ,GAAG,CAACK,YAAtB,CAWa,OATzBC,KASyB,GATP,EACvBC,iBAAiB,EAAE,KADI,EASO,OAHxBC,YAGwB,GAH6B,IAG7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDzBC,IAAAA,iBArDyB,GAqDL,oBAAM,MAAKD,YAAX,EArDK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HxBE,IAAAA,KA/HwB,GA+HhB,oBAAM,MAAKR,KAAL,CAAWS,EAAX,IAAiB,MAAKP,QAAL,GAAgBQ,IAAvC,EA/HgB;;AAiIxBC,IAAAA,eAjIwB,GAiIN,UAACC,QAAD,EAAuC;AAC/D,YAAKN,Y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KAAvB,CADQ,IACwB,KAAK3C,OAAL,CAAagE,IAAb,KAAsB,OAD9C,oBAERL,MAAM,CAACc,WAAP,CAAmB,KAAK9B,KAAxB,CAFQ,IAEyB,KAAK3C,OAAL,CAAagE,IAAb,KAAsB,QAF/C,oBAGRL,MAAM,CAACe,UAAP,CAAkB,KAAK/B,KAAvB,CAHQ,IAGwB,KAAK3C,OAAL,CAAagE,IAAb,KAAsB,OAH9C,qBADb,GA9BJ,CALF,CADF,CA+CD,C,cApJiDW,eAAMrB,S,WAC1CsB,mB,GAAsB,K,UACtBC,W,GAAc,K,UAEdC,W,GAAcC,wB,UAGd7E,Y,GAA6B,EACzCe,SAAS,EAAE,GAD8B,EAEzCR,IAAI,EAAE,EAFmC,E","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport invariant from 'invariant';\nimport { globalObject } from '@skbkontur/global-object';\nimport type { Emotion } from '@emotion/css/create-instance';\n\nimport { ResizeDetector } from '../../internal/ResizeDetector';\nimport { isKeyArrow, isKeyArrowLeft, isKeyArrowUp } from '../../lib/events/keyboard/identifiers';\nimport { keyListener } from '../../lib/events/keyListener';\nimport { Nullable } from '../../typings/utility-types';\nimport { isFunctionalComponent } from '../../lib/utils';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { SizeProp } from '../../lib/types/props';\nimport { getVisualStateDataAttributes } from '../../internal/CommonWrapper/utils/getVisualStateDataAttributes';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\n\nimport { TabsContext, TabsContextDefaultValue, TabsContextType } from './TabsContext';\nimport { getHorizontalStyles, getStyles, getVerticalStyles, globalClasses } from './Tab.styles';\n\nexport interface TabIndicators {\n error: boolean;\n warning: boolean;\n success: boolean;\n primary: boolean;\n disabled: boolean;\n}\n\nexport const TabDataTids = {\n root: 'Tab__root',\n} as const;\n\n/**\n * @deprecated use SizeProp\n */\nexport type TabSize = SizeProp;\n\nexport interface TabProps<T extends string = string>\n extends Pick<AriaAttributes, 'aria-label' | 'aria-describedby'>,\n CommonProps {\n /**\n * Позволяет передавать свой компонент, строку или функцию, которая заменит собой элемент используемый в компоненте по умолчанию. Реализует паттерн [render prop](https://www.patterns.dev/posts/render-props-pattern).\n */\n component?: React.ComponentType<any> | string;\n\n /**\n * `HTML`-аттрибут `href`.\n */\n href?: string;\n\n /**\n * Уникальный идентификатор таба. По нему компонент `<Tabs />` определяет какой `<Tab />` сейчас выбран.\n */\n id?: T;\n\n /**\n * `HTML`-событие `onclick`.\n */\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n\n /**\n * `HTML`-событие `onkeydown`.\n */\n onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void;\n\n /**\n * Переводит компонент в отключенное состояние.\n */\n disabled?: boolean;\n\n /**\n * Визуальное состояние ошибки.\n */\n error?: boolean;\n\n /**\n * Визуальное состояние предупреждения.\n */\n warning?: boolean;\n\n /**\n * Визуальное состояние успеха.\n */\n success?: boolean;\n\n /**\n * Визуальное состояние главного элемента.\n */\n primary?: boolean;\n}\n\nexport interface TabState {\n focusedByKeyboard: boolean;\n}\n\ntype DefaultProps = Required<Pick<TabProps, 'component' | 'href'>>;\n\n/**\n * Вложенный элемент компонента `<Tabs />`.\n */\n@rootNode\nexport class Tab<T extends string = string> extends React.Component<TabProps<T>, TabState> {\n public static __KONTUR_REACT_UI__ = 'Tab';\n public static displayName = 'Tab';\n\n public static contextType = TabsContext;\n public context: TabsContextType = this.context;\n\n public static defaultProps: DefaultProps = {\n component: 'a',\n href: '',\n };\n\n private getProps = createPropsGetter(Tab.defaultProps);\n\n public state: TabState = {\n focusedByKeyboard: false,\n };\n\n private theme!: Theme;\n private emotion!: Emotion;\n private tabComponent: Nullable<React.ReactElement<Tab<T>>> = null;\n private setRootNode!: TSetRootNode;\n\n constructor(props: TabProps<T>) {\n super(props);\n invariant(this.context !== TabsContextDefaultValue, 'Tab should be placed inside Tabs component');\n }\n\n public componentDidMount() {\n const id = this.getId();\n if (typeof id === 'string') {\n this.context.addTab(id, this.getTabInstance);\n }\n }\n\n public componentDidUpdate() {\n if (this.context.activeTab === this.props.id) {\n this.context.notifyUpdate();\n }\n }\n\n public componentWillUnmount() {\n const id = this.getId();\n if (typeof id === 'string') {\n this.context.removeTab(id);\n }\n }\n\n public render() {\n return (\n <EmotionConsumer>\n {(emotion) => {\n this.emotion = emotion;\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }}\n </EmotionConsumer>\n );\n }\n\n public getIndicators() {\n return {\n error: Boolean(this.props.error),\n warning: Boolean(this.props.warning),\n success: Boolean(this.props.success),\n primary: Boolean(this.props.primary),\n disabled: Boolean(this.props.disabled),\n };\n }\n\n public getUnderlyingNode = () => this.tabComponent;\n\n private renderMain() {\n const {\n children,\n disabled,\n error,\n warning,\n success,\n primary,\n 'aria-describedby': ariaDescribedby,\n 'aria-label': ariaLabel,\n } = this.props;\n const { component: Component, href } = this.getProps();\n\n let isActive = false;\n let isVertical = false;\n\n const id = this.getId();\n if (typeof id === 'string') {\n isActive = this.context.activeTab === this.getId();\n isVertical = this.context.vertical;\n }\n const orientationStyles = isVertical ? getVerticalStyles(this.emotion) : getHorizontalStyles(this.emotion);\n const styles = getStyles(this.emotion);\n return (\n <CommonWrapper\n rootNodeRef={this.setRootNode}\n {...getVisualStateDataAttributes({ active: isActive, disabled })}\n {...this.props}\n >\n <Component\n data-tid={TabDataTids.root}\n className={this.emotion.cx({\n [styles.rootSmall(this.theme)]: this.context.size === 'small',\n [styles.rootMedium(this.theme)]: this.context.size === 'medium',\n [styles.rootLarge(this.theme)]: this.context.size === 'large',\n [styles.verticalSmall(this.theme)]: !!isVertical && this.context.size === 'small',\n [styles.verticalMedium(this.theme)]: !!isVertical && this.context.size === 'medium',\n [styles.verticalLarge(this.theme)]: !!isVertical && this.context.size === 'large',\n [orientationStyles.primary(this.theme)]: !!primary,\n [orientationStyles.success(this.theme)]: !!success,\n [orientationStyles.warning(this.theme)]: !!warning,\n [orientationStyles.error(this.theme)]: !!error,\n [styles.active()]: !!isActive,\n [orientationStyles.active(this.theme)]: !!isActive,\n [styles.disabled(this.theme)]: !!disabled,\n [orientationStyles.disabled()]: !!disabled,\n })}\n onBlur={this.handleBlur}\n onClick={this.switchTab}\n onFocus={this.handleFocus}\n onKeyDown={this.handleKeyDown}\n tabIndex={disabled ? -1 : 0}\n ref={isFunctionalComponent(Component) ? null : this.refTabComponent}\n href={href}\n aria-describedby={ariaDescribedby}\n aria-label={ariaLabel}\n >\n <ResizeDetector onResize={this.context.notifyUpdate}>{children}</ResizeDetector>\n {this.state.focusedByKeyboard && (\n <div\n className={this.emotion.cx(globalClasses.focus, {\n [styles.focusSmall(this.theme)]: this.context.size === 'small',\n [styles.focusMedium(this.theme)]: this.context.size === 'medium',\n [styles.focusLarge(this.theme)]: this.context.size === 'large',\n })}\n />\n )}\n </Component>\n </CommonWrapper>\n );\n }\n\n private getId = () => this.props.id || this.getProps().href;\n\n private refTabComponent = (instance: React.ReactElement<any>) => {\n this.tabComponent = instance;\n };\n\n private getTabInstance = () => this;\n\n private switchTab = (event: React.MouseEvent<HTMLElement>) => {\n if (this.props.disabled) {\n event.preventDefault();\n return;\n }\n const { href, component } = this.getProps();\n\n const id = this.props.id || href;\n if (this.props.onClick) {\n this.props.onClick(event);\n if (event.defaultPrevented) {\n return;\n }\n }\n if (typeof id === 'string') {\n this.context.switchTab(id);\n }\n if (component === 'a' && !href) {\n event.preventDefault();\n }\n };\n\n private handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.props.onKeyDown) {\n this.props.onKeyDown(e);\n if (e.defaultPrevented) {\n return;\n }\n }\n const id = this.getId();\n if (typeof id !== 'string') {\n return;\n }\n if (!isKeyArrow(e)) {\n return;\n }\n e.preventDefault();\n const delta = isKeyArrowLeft(e) || isKeyArrowUp(e) ? -1 : 1;\n this.context.shiftFocus(id, delta);\n };\n\n private handleFocus = () => {\n if (this.props.disabled) {\n return;\n }\n\n // focus event fires before keyDown eventlistener\n // so we should check focusKeyPressed in async way\n globalObject.requestAnimationFrame?.(() => {\n if (keyListener.isTabPressed || keyListener.isArrowPressed) {\n this.setState({ focusedByKeyboard: true });\n }\n });\n };\n\n private handleBlur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.setState({ focusedByKeyboard: false });\n };\n}\n"]}
|
|
@@ -194,4 +194,4 @@ Tabs = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/function
|
|
|
194
194
|
|
|
195
195
|
removeTab = function (id) {
|
|
196
196
|
_this.tabs = _this.tabs.filter(function (tab) {return tab.id !== id;});
|
|
197
|
-
};return _this;}var _proto = Tabs.prototype;_proto.render = function render() {var _this2 = this;var _this$props2 = this.props,value = _this$props2.value,width = _this$props2.width,children = _this$props2.children,indicatorClassName = _this$props2.indicatorClassName,ariaDescribedby = _this$props2['aria-describedby'];var _this$getProps = this.getProps(),vertical = _this$getProps.vertical,size = _this$getProps.size;return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {var styles = (0, _Tabs.getStyles)(emotion);return /*#__PURE__*/_react.default.createElement(_ThemeContext.
|
|
197
|
+
};return _this;}var _proto = Tabs.prototype;_proto.render = function render() {var _this2 = this;var _this$props2 = this.props,value = _this$props2.value,width = _this$props2.width,children = _this$props2.children,indicatorClassName = _this$props2.indicatorClassName,ariaDescribedby = _this$props2['aria-describedby'];var _this$getProps = this.getProps(),vertical = _this$getProps.vertical,size = _this$getProps.size;return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {var styles = (0, _Tabs.getStyles)(emotion);return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {var _emotion$cx;_this2.theme = theme;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: _this2.setRootNode }, _this2.props), /*#__PURE__*/_react.default.createElement("div", { "data-tid": TabsDataTids.root, className: emotion.cx((_emotion$cx = {}, _emotion$cx[styles.rootSmall(_this2.theme)] = size === 'small', _emotion$cx[styles.rootMedium(_this2.theme)] = size === 'medium', _emotion$cx[styles.rootLarge(_this2.theme)] = size === 'large', _emotion$cx[styles.vertical()] = vertical, _emotion$cx)), style: { width: width }, "aria-describedby": ariaDescribedby }, /*#__PURE__*/_react.default.createElement(_TabsContext.TabsContext.Provider, { value: { vertical: vertical, activeTab: value, size: size, getTab: _this2.getTab, addTab: _this2.addTab, removeTab: _this2.removeTab, notifyUpdate: _this2.notifyUpdate, shiftFocus: _this2.shiftFocus, switchTab: _this2.switchTab } }, children, /*#__PURE__*/_react.default.createElement(_Indicator.Indicator, { className: indicatorClassName, tabUpdates: _this2.tabUpdates, vertical: _this2.getProps().vertical }))));});});};return Tabs;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Tabs', _class2.displayName = 'Tabs', _class2.defaultProps = { vertical: false, size: 'large' }, _class2.Tab = _Tab.Tab, _temp)) || _class;exports.Tabs = Tabs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Tabs.tsx"],"names":["TabsDataTids","root","indicatorRoot","Tabs","rootNode","getProps","defaultProps","tabs","tabUpdates","on","cb","index","listeners","push","splice","shiftFocus","fromTab","delta","findIndex","x","id","newIndex","Math","max","min","length","tab","tabNode","getNode","htmlNode","globalObject","HTMLElement","focus","notifyUpdate","forEach","switchTab","props","onValueChange","value","getTab","find","addTab","concat","removeTab","filter","render","width","children","indicatorClassName","ariaDescribedby","vertical","size","emotion","styles","theme","setRootNode","cx","rootSmall","rootMedium","rootLarge","activeTab","React","Component","__KONTUR_REACT_UI__","displayName","Tab"],"mappings":"+cAAA;AACA;;;;AAIA;AAC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lB,UAAU,EAAE,MAAI,CAACA,UARZ,EASLoB,SAAS,EAAE,MAAI,CAACA,SATX,EADT,IAaGY,QAbH,eAcE,6BAAC,oBAAD,IACE,SAAS,EAAEC,kBADb,EAEE,UAAU,EAAE,MAAI,CAACxC,UAFnB,EAGE,QAAQ,EAAE,MAAI,CAACH,QAAL,GAAgB6C,QAH5B,GAdF,CAXF,CADF,CADF,CAoCD,CAvCH,CADF,CA2CD,CA9CH,CADF,CAkDD,C,eAlFkDW,eAAMC,S,WAC3CC,mB,GAAsB,M,UACtBC,W,GAAc,M,UAEd1D,Y,GAA6B,EACzC4C,QAAQ,EAAE,KAD+B,EAEzCC,IAAI,EAAE,OAFmC,E,UAO7Bc,G,GAAMA,Q","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport { globalObject } from '@skbkontur/global-object';\n\nimport { emptyHandler } from '../../lib/utils';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { getRootNode } from '../../lib/rootNode/getRootNode';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { SizeProp } from '../../lib/types/props';\nimport { isInstanceOf } from '../../lib/isInstanceOf';\nimport { ThemeConsumer } from '../../lib/theming/ThemeContext';\n\nimport { Indicator } from './Indicator';\nimport { getStyles } from './Tabs.styles';\nimport { TabsContext, TabsContextType } from './TabsContext';\nimport { Tab } from './Tab';\n\ntype ValueBaseType = string;\ninterface TabType<T extends ValueBaseType> {\n getNode: () => Tab<T> | null;\n id: T;\n}\n\nexport interface TabsProps<T extends ValueBaseType = string> extends CommonProps {\n /**\n * Позволяет задать кастомный класс подчёркиванию таба.\n */\n indicatorClassName?: string;\n\n /**\n * Задаёт размер контрола.\n *\n * **Допустимые значения**: `\"small\"`, `\"medium\"`, `\"large\"`.\n */\n size?: SizeProp;\n\n /**\n * Задаёт текущий активный `<Tab />`. Принимает `id` таба.\n */\n value: T;\n\n /**\n * Функция, позволяющая изменить текущий активный `<Tab />`.\n */\n onValueChange?: (value: T) => void;\n\n /**\n * Переводит компонент в режим вертикального отображения.\n * @default false\n */\n vertical?: boolean;\n\n /**\n * `CSS`-свойство `width`.\n */\n width?: number | string;\n\n /**\n * Атрибут для указания id элемента(-ов), описывающих его.\n */\n 'aria-describedby'?: AriaAttributes['aria-describedby'];\n}\n\nexport const TabsDataTids = {\n root: 'Tabs__root',\n indicatorRoot: 'Indicator__root',\n} as const;\n\ntype DefaultProps = Required<Pick<TabsProps, 'vertical' | 'size'>>;\n\n/**\n * Родитель компонента `<Tab />`. Связывает `Tab`'ы в группу и позволяет управлять их состоянием.\n */\n@rootNode\nexport class Tabs<T extends string = string> extends React.Component<TabsProps<T>> {\n public static __KONTUR_REACT_UI__ = 'Tabs';\n public static displayName = 'Tabs';\n\n public static defaultProps: DefaultProps = {\n vertical: false,\n size: 'large',\n };\n\n private getProps = createPropsGetter(Tabs.defaultProps);\n\n public static Tab = Tab;\n\n private theme!: Theme;\n\n private tabs: Array<TabType<T>> = [];\n\n private tabUpdates = {\n on: (cb: () => void) => {\n const index = this.listeners.push(cb);\n return () => {\n this.listeners.splice(index, 1);\n };\n },\n };\n\n private listeners: Array<typeof emptyHandler> = [];\n private setRootNode!: TSetRootNode;\n\n public render(): JSX.Element {\n const { value, width, children, indicatorClassName, 'aria-describedby': ariaDescribedby } = this.props;\n const { vertical, size } = this.getProps();\n return (\n <EmotionConsumer>\n {(emotion) => {\n const styles = getStyles(emotion);\n return (\n <ThemeConsumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <div\n data-tid={TabsDataTids.root}\n className={emotion.cx({\n [styles.rootSmall(this.theme)]: size === 'small',\n [styles.rootMedium(this.theme)]: size === 'medium',\n [styles.rootLarge(this.theme)]: size === 'large',\n [styles.vertical()]: vertical,\n })}\n style={{ width }}\n aria-describedby={ariaDescribedby}\n >\n <TabsContext.Provider\n value={{\n vertical,\n activeTab: value,\n size,\n getTab: this.getTab,\n addTab: this.addTab,\n removeTab: this.removeTab,\n notifyUpdate: this.notifyUpdate,\n shiftFocus: this.shiftFocus,\n switchTab: this.switchTab,\n }}\n >\n {children}\n <Indicator\n className={indicatorClassName}\n tabUpdates={this.tabUpdates}\n vertical={this.getProps().vertical}\n />\n </TabsContext.Provider>\n </div>\n </CommonWrapper>\n );\n }}\n </ThemeConsumer>\n );\n }}\n </EmotionConsumer>\n );\n }\n\n private shiftFocus: TabsContextType<T>['shiftFocus'] = (fromTab, delta) => {\n const { tabs } = this;\n const index = tabs.findIndex((x) => x.id === fromTab);\n const newIndex = Math.max(0, Math.min(index + delta, tabs.length - 1));\n const tab = tabs[newIndex];\n\n const tabNode = tab.getNode();\n const htmlNode = getRootNode(tabNode);\n\n if (isInstanceOf(htmlNode, globalObject.HTMLElement) && typeof htmlNode.focus === 'function') {\n htmlNode.focus();\n }\n };\n\n private notifyUpdate: TabsContextType<T>['notifyUpdate'] = () => {\n this.listeners.forEach((cb) => cb());\n };\n\n private switchTab: TabsContextType<T>['switchTab'] = (id) => {\n const { onValueChange, value } = this.props;\n if (id !== value && onValueChange) {\n onValueChange(id);\n }\n };\n\n private getTab: TabsContextType<T>['getTab'] = (id) => {\n const { getNode = null } = this.tabs.find((x) => x.id === id) || {};\n return getNode && getNode();\n };\n\n private addTab: TabsContextType<T>['addTab'] = (id, getNode) => {\n this.tabs = this.tabs.concat({ id, getNode });\n };\n\n private removeTab: TabsContextType<T>['removeTab'] = (id) => {\n this.tabs = this.tabs.filter((tab) => tab.id !== id);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["Tabs.tsx"],"names":["TabsDataTids","root","indicatorRoot","Tabs","rootNode","getProps","defaultProps","tabs","tabUpdates","on","cb","index","listeners","push","splice","shiftFocus","fromTab","delta","findIndex","x","id","newIndex","Math","max","min","length","tab","tabNode","getNode","htmlNode","globalObject","HTMLElement","focus","notifyUpdate","forEach","switchTab","props","onValueChange","value","getTab","find","addTab","concat","removeTab","filter","render","width","children","indicatorClassName","ariaDescribedby","vertical","size","emotion","styles","theme","setRootNode","cx","rootSmall","rootMedium","rootLarge","activeTab","React","Component","__KONTUR_REACT_UI__","displayName","Tab"],"mappings":"+cAAA;AACA;;;;AAIA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDO,IAAMA,YAAY,GAAG;AAC1BC,EAAAA,IAAI,EAAE,YADoB;AAE1BC,EAAAA,aAAa,EAAE,iBAFW,EAArB,C;;;;;AAOP;AACA;AACA,G;;AAEaC,I,OADZC,kB;;;;;;;;;AAUSC,IAAAA,Q,GAAW,0CAAkBF,IAAI,CAACG,YAAvB,C;;;;;;AAMXC,IAAAA,I,GAA0B,E;;AAE1BC,IAAAA,U,GAAa;AACnBC,MAAAA,EAAE,EAAE,YAACC,EAAD,EAAoB;AACtB,YAAMC,KAAK,GAAG,MAAKC,SAAL,CAAeC,IAAf,CAAoBH,EAApB,CAAd;AACA,eAAO,YAAM;AACX,gBAAKE,SAAL,CAAeE,MAAf,CAAsBH,KAAtB,EAA6B,CAA7B;AACD,SAFD;AAGD,OANkB,E;;;AASbC,IAAAA,S,GAAwC,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DxCG,IAAAA,U,GAA+C,UAACC,OAAD,EAAUC,KAAV,EAAoB;AACzE,8EAAQV,IAAR,yBAAQA,IAAR;AACA,UAAMI,KAAK,GAAGJ,IAAI,CAACW,SAAL,CAAe,UAACC,CAAD,UAAOA,CAAC,CAACC,EAAF,KAASJ,OAAhB,EAAf,CAAd;AACA,UAAMK,QAAQ,GAAGC,IAAI,CAACC,GAAL,CAAS,CAAT,EAAYD,IAAI,CAACE,GAAL,CAASb,KAAK,GAAGM,KAAjB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,EACLC,QAAQ,EAARA,QADK,EAELU,SAAS,EAAEtB,KAFN,EAGLa,IAAI,EAAJA,IAHK,EAILZ,MAAM,EAAE,MAAI,CAACA,MAJR,EAKLE,MAAM,EAAE,MAAI,CAACA,MALR,EAMLE,SAAS,EAAE,MAAI,CAACA,SANX,EAOLV,YAAY,EAAE,MAAI,CAACA,YAPd,EAQLlB,UAAU,EAAE,MAAI,CAACA,UARZ,EASLoB,SAAS,EAAE,MAAI,CAACA,SATX,EADT,IAaGY,QAbH,eAcE,6BAAC,oBAAD,IACE,SAAS,EAAEC,kBADb,EAEE,UAAU,EAAE,MAAI,CAACxC,UAFnB,EAGE,QAAQ,EAAE,MAAI,CAACH,QAAL,GAAgB6C,QAH5B,GAdF,CAXF,CADF,CADF,CAoCD,CAvCH,CADF,CA2CD,CA9CH,CADF,CAkDD,C,eAlFkDW,eAAMC,S,WAC3CC,mB,GAAsB,M,UACtBC,W,GAAc,M,UAEd1D,Y,GAA6B,EACzC4C,QAAQ,EAAE,KAD+B,EAEzCC,IAAI,EAAE,OAFmC,E,UAO7Bc,G,GAAMA,Q","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport { globalObject } from '@skbkontur/global-object';\n\nimport { emptyHandler } from '../../lib/utils';\nimport { Theme } from '../../lib/theming/Theme';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { EmotionConsumer } from '../../lib/theming/Emotion';\nimport { getRootNode } from '../../lib/rootNode/getRootNode';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { SizeProp } from '../../lib/types/props';\nimport { isInstanceOf } from '../../lib/isInstanceOf';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\n\nimport { Indicator } from './Indicator';\nimport { getStyles } from './Tabs.styles';\nimport { TabsContext, TabsContextType } from './TabsContext';\nimport { Tab } from './Tab';\n\ntype ValueBaseType = string;\ninterface TabType<T extends ValueBaseType> {\n getNode: () => Tab<T> | null;\n id: T;\n}\n\nexport interface TabsProps<T extends ValueBaseType = string> extends CommonProps {\n /**\n * Позволяет задать кастомный класс подчёркиванию таба.\n */\n indicatorClassName?: string;\n\n /**\n * Задаёт размер контрола.\n *\n * **Допустимые значения**: `\"small\"`, `\"medium\"`, `\"large\"`.\n */\n size?: SizeProp;\n\n /**\n * Задаёт текущий активный `<Tab />`. Принимает `id` таба.\n */\n value: T;\n\n /**\n * Функция, позволяющая изменить текущий активный `<Tab />`.\n */\n onValueChange?: (value: T) => void;\n\n /**\n * Переводит компонент в режим вертикального отображения.\n * @default false\n */\n vertical?: boolean;\n\n /**\n * `CSS`-свойство `width`.\n */\n width?: number | string;\n\n /**\n * Атрибут для указания id элемента(-ов), описывающих его.\n */\n 'aria-describedby'?: AriaAttributes['aria-describedby'];\n}\n\nexport const TabsDataTids = {\n root: 'Tabs__root',\n indicatorRoot: 'Indicator__root',\n} as const;\n\ntype DefaultProps = Required<Pick<TabsProps, 'vertical' | 'size'>>;\n\n/**\n * Родитель компонента `<Tab />`. Связывает `Tab`'ы в группу и позволяет управлять их состоянием.\n */\n@rootNode\nexport class Tabs<T extends string = string> extends React.Component<TabsProps<T>> {\n public static __KONTUR_REACT_UI__ = 'Tabs';\n public static displayName = 'Tabs';\n\n public static defaultProps: DefaultProps = {\n vertical: false,\n size: 'large',\n };\n\n private getProps = createPropsGetter(Tabs.defaultProps);\n\n public static Tab = Tab;\n\n private theme!: Theme;\n\n private tabs: Array<TabType<T>> = [];\n\n private tabUpdates = {\n on: (cb: () => void) => {\n const index = this.listeners.push(cb);\n return () => {\n this.listeners.splice(index, 1);\n };\n },\n };\n\n private listeners: Array<typeof emptyHandler> = [];\n private setRootNode!: TSetRootNode;\n\n public render(): JSX.Element {\n const { value, width, children, indicatorClassName, 'aria-describedby': ariaDescribedby } = this.props;\n const { vertical, size } = this.getProps();\n return (\n <EmotionConsumer>\n {(emotion) => {\n const styles = getStyles(emotion);\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <div\n data-tid={TabsDataTids.root}\n className={emotion.cx({\n [styles.rootSmall(this.theme)]: size === 'small',\n [styles.rootMedium(this.theme)]: size === 'medium',\n [styles.rootLarge(this.theme)]: size === 'large',\n [styles.vertical()]: vertical,\n })}\n style={{ width }}\n aria-describedby={ariaDescribedby}\n >\n <TabsContext.Provider\n value={{\n vertical,\n activeTab: value,\n size,\n getTab: this.getTab,\n addTab: this.addTab,\n removeTab: this.removeTab,\n notifyUpdate: this.notifyUpdate,\n shiftFocus: this.shiftFocus,\n switchTab: this.switchTab,\n }}\n >\n {children}\n <Indicator\n className={indicatorClassName}\n tabUpdates={this.tabUpdates}\n vertical={this.getProps().vertical}\n />\n </TabsContext.Provider>\n </div>\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }}\n </EmotionConsumer>\n );\n }\n\n private shiftFocus: TabsContextType<T>['shiftFocus'] = (fromTab, delta) => {\n const { tabs } = this;\n const index = tabs.findIndex((x) => x.id === fromTab);\n const newIndex = Math.max(0, Math.min(index + delta, tabs.length - 1));\n const tab = tabs[newIndex];\n\n const tabNode = tab.getNode();\n const htmlNode = getRootNode(tabNode);\n\n if (isInstanceOf(htmlNode, globalObject.HTMLElement) && typeof htmlNode.focus === 'function') {\n htmlNode.focus();\n }\n };\n\n private notifyUpdate: TabsContextType<T>['notifyUpdate'] = () => {\n this.listeners.forEach((cb) => cb());\n };\n\n private switchTab: TabsContextType<T>['switchTab'] = (id) => {\n const { onValueChange, value } = this.props;\n if (id !== value && onValueChange) {\n onValueChange(id);\n }\n };\n\n private getTab: TabsContextType<T>['getTab'] = (id) => {\n const { getNode = null } = this.tabs.find((x) => x.id === id) || {};\n return getNode && getNode();\n };\n\n private addTab: TabsContextType<T>['addTab'] = (id, getNode) => {\n this.tabs = this.tabs.concat({ id, getNode });\n };\n\n private removeTab: TabsContextType<T>['removeTab'] = (id) => {\n this.tabs = this.tabs.filter((tab) => tab.id !== id);\n };\n}\n"]}
|
|
@@ -631,7 +631,7 @@ Textarea = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/func
|
|
|
631
631
|
}
|
|
632
632
|
};return _this;}var _proto = Textarea.prototype;_proto.getRootSizeClassName = function getRootSizeClassName() {var styles = (0, _Textarea.getStyles)(this.emotion);switch (this.getProps().size) {case 'large':return styles.rootLarge(this.theme);case 'medium':return styles.rootMedium(this.theme);case 'small':default:return styles.rootSmall(this.theme);}};_proto.getTextareaSizeClassName = function getTextareaSizeClassName() {var styles = (0, _Textarea.getStyles)(this.emotion);switch (this.getProps().size) {case 'large':return styles.textareaLarge(this.theme);case 'medium':return styles.textareaMedium(this.theme);case 'small':default:return styles.textareaSmall(this.theme);}};_proto.getAutoResizeThrottleWait = function getAutoResizeThrottleWait(props) {if (props === void 0) {props = this.props;} // NOTE: При отключении анимации остается эффект дергания при авто-ресайзе из-за троттлинга расчета высоты
|
|
633
633
|
// Поэтому выставляем таймаут троттла в ноль. Подробности - https://github.com/skbkontur/retail-ui/issues/2120
|
|
634
|
-
return this.isAnimationsDisabled(props) ? 0 : AUTORESIZE_THROTTLE_DEFAULT_WAIT;};_proto.isAnimationsDisabled = function isAnimationsDisabled(_temp2) {var _ref3 = _temp2 === void 0 ? this.props : _temp2,disableAnimations = _ref3.disableAnimations,extraRow = _ref3.extraRow;return disableAnimations || !extraRow;};_proto.componentDidMount = function componentDidMount() {if (this.props.autoResize) {this.autoResize();this.layoutEvents = LayoutEvents.addListener(this.autoResize);}if (this.node && this.props.showLengthCounter && this.textareaObserver) {this.textareaObserver.observe(this.node, { attributes: true });}};_proto.componentWillUnmount = function componentWillUnmount() {if (this.layoutEvents) {this.layoutEvents.remove();}if (this.props.showLengthCounter && this.textareaObserver) {this.textareaObserver.disconnect();}this.cancelDelayedSelectAll();};_proto.componentDidUpdate = function componentDidUpdate(prevProps) {if (this.getAutoResizeThrottleWait() !== this.getAutoResizeThrottleWait(prevProps)) {this.autoResize.cancel();this.autoResize = (0, _lodash.default)(this.autoResizeHandler, this.getAutoResizeThrottleWait());}var _this$getProps2 = this.getProps(),rows = _this$getProps2.rows,maxRows = _this$getProps2.maxRows;if (this.props.autoResize && (rows !== prevProps.rows || maxRows !== prevProps.maxRows || this.props.value !== prevProps.value)) {this.autoResize();}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_featureFlagsContext.ReactUIFeatureFlagsContext.Consumer, null, function (flags) {_this2.featureFlags = (0, _featureFlagsContext.getFullReactUIFlagsContext)(flags);return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.
|
|
634
|
+
return this.isAnimationsDisabled(props) ? 0 : AUTORESIZE_THROTTLE_DEFAULT_WAIT;};_proto.isAnimationsDisabled = function isAnimationsDisabled(_temp2) {var _ref3 = _temp2 === void 0 ? this.props : _temp2,disableAnimations = _ref3.disableAnimations,extraRow = _ref3.extraRow;return disableAnimations || !extraRow;};_proto.componentDidMount = function componentDidMount() {if (this.props.autoResize) {this.autoResize();this.layoutEvents = LayoutEvents.addListener(this.autoResize);}if (this.node && this.props.showLengthCounter && this.textareaObserver) {this.textareaObserver.observe(this.node, { attributes: true });}};_proto.componentWillUnmount = function componentWillUnmount() {if (this.layoutEvents) {this.layoutEvents.remove();}if (this.props.showLengthCounter && this.textareaObserver) {this.textareaObserver.disconnect();}this.cancelDelayedSelectAll();};_proto.componentDidUpdate = function componentDidUpdate(prevProps) {if (this.getAutoResizeThrottleWait() !== this.getAutoResizeThrottleWait(prevProps)) {this.autoResize.cancel();this.autoResize = (0, _lodash.default)(this.autoResizeHandler, this.getAutoResizeThrottleWait());}var _this$getProps2 = this.getProps(),rows = _this$getProps2.rows,maxRows = _this$getProps2.maxRows;if (this.props.autoResize && (rows !== prevProps.rows || maxRows !== prevProps.maxRows || this.props.value !== prevProps.value)) {this.autoResize();}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_featureFlagsContext.ReactUIFeatureFlagsContext.Consumer, null, function (flags) {_this2.featureFlags = (0, _featureFlagsContext.getFullReactUIFlagsContext)(flags);return /*#__PURE__*/_react.default.createElement(_Emotion.EmotionConsumer, null, function (emotion) {_this2.emotion = emotion;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: _this2.setRootNode }, _this2.props), _this2.renderMain);});});});} /**
|
|
635
635
|
* @public
|
|
636
636
|
*/;_proto.focus = function focus() {if (this.node) {this.node.focus();}} /**
|
|
637
637
|
* @public
|