@skbkontur/react-ui 3.9.4 → 3.10.0
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 +21 -0
- package/README.md +57 -0
- package/cjs/components/Autocomplete/Autocomplete.d.ts +1 -0
- package/cjs/components/Autocomplete/Autocomplete.js +11 -5
- package/cjs/components/Autocomplete/Autocomplete.js.map +1 -1
- package/cjs/components/Button/Button.d.ts +1 -0
- package/cjs/components/Button/Button.js +7 -3
- package/cjs/components/Button/Button.js.map +1 -1
- package/cjs/components/Center/Center.d.ts +1 -0
- package/cjs/components/Center/Center.js +10 -3
- package/cjs/components/Center/Center.js.map +1 -1
- package/cjs/components/Checkbox/Checkbox.d.ts +3 -2
- package/cjs/components/Checkbox/Checkbox.js +10 -4
- package/cjs/components/Checkbox/Checkbox.js.map +1 -1
- package/cjs/components/ComboBox/ComboBox.d.ts +2 -0
- package/cjs/components/ComboBox/ComboBox.js +100 -70
- package/cjs/components/ComboBox/ComboBox.js.map +1 -1
- package/cjs/components/CurrencyInput/CurrencyInput.d.ts +3 -3
- package/cjs/components/CurrencyInput/CurrencyInput.js +7 -4
- package/cjs/components/CurrencyInput/CurrencyInput.js.map +1 -1
- package/cjs/components/DateInput/DateInput.d.ts +1 -0
- package/cjs/components/DateInput/DateInput.js +6 -3
- package/cjs/components/DateInput/DateInput.js.map +1 -1
- package/cjs/components/DatePicker/DatePicker.d.ts +4 -2
- package/cjs/components/DatePicker/DatePicker.js +17 -7
- package/cjs/components/DatePicker/DatePicker.js.map +1 -1
- package/cjs/components/Dropdown/Dropdown.d.ts +1 -0
- package/cjs/components/Dropdown/Dropdown.js +11 -4
- package/cjs/components/Dropdown/Dropdown.js.map +1 -1
- package/cjs/components/DropdownMenu/DropdownMenu.d.ts +1 -0
- package/cjs/components/DropdownMenu/DropdownMenu.js +7 -4
- package/cjs/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/cjs/components/FxInput/FxInput.d.ts +1 -0
- package/cjs/components/FxInput/FxInput.js +9 -2
- package/cjs/components/FxInput/FxInput.js.map +1 -1
- package/cjs/components/Gapped/Gapped.d.ts +1 -0
- package/cjs/components/Gapped/Gapped.js +8 -5
- package/cjs/components/Gapped/Gapped.js.map +1 -1
- package/cjs/components/Group/Group.d.ts +1 -0
- package/cjs/components/Group/Group.js +10 -7
- package/cjs/components/Group/Group.js.map +1 -1
- package/cjs/components/Hint/Hint.d.ts +3 -2
- package/cjs/components/Hint/Hint.js +7 -4
- package/cjs/components/Hint/Hint.js.map +1 -1
- package/cjs/components/Input/Input.d.ts +4 -1
- package/cjs/components/Input/Input.js +13 -5
- package/cjs/components/Input/Input.js.map +1 -1
- package/cjs/components/Kebab/Kebab.d.ts +1 -0
- package/cjs/components/Kebab/Kebab.js +8 -5
- package/cjs/components/Kebab/Kebab.js.map +1 -1
- package/cjs/components/Link/Link.d.ts +1 -0
- package/cjs/components/Link/Link.js +11 -3
- package/cjs/components/Link/Link.js.map +1 -1
- package/cjs/components/Loader/Loader.d.ts +1 -0
- package/cjs/components/Loader/Loader.js +9 -6
- package/cjs/components/Loader/Loader.js.map +1 -1
- package/cjs/components/MenuItem/MenuItem.d.ts +1 -0
- package/cjs/components/MenuItem/MenuItem.js +13 -7
- package/cjs/components/MenuItem/MenuItem.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.d.ts +1 -0
- package/cjs/components/Modal/ModalBody.js +9 -6
- package/cjs/components/Modal/ModalBody.js.map +1 -1
- package/cjs/components/Paging/Paging.d.ts +2 -2
- package/cjs/components/Paging/Paging.js +6 -5
- package/cjs/components/Paging/Paging.js.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.d.ts +3 -2
- package/cjs/components/PasswordInput/PasswordInput.js +13 -6
- package/cjs/components/PasswordInput/PasswordInput.js.map +1 -1
- package/cjs/components/Radio/Radio.d.ts +5 -10
- package/cjs/components/Radio/Radio.js +11 -10
- package/cjs/components/Radio/Radio.js.map +1 -1
- package/cjs/components/RadioGroup/RadioGroup.d.ts +2 -16
- package/cjs/components/RadioGroup/RadioGroup.js +16 -19
- package/cjs/components/RadioGroup/RadioGroup.js.map +1 -1
- package/cjs/components/RadioGroup/RadioGroupContext.d.ts +10 -0
- package/cjs/components/RadioGroup/RadioGroupContext.js +21 -0
- package/cjs/components/RadioGroup/RadioGroupContext.js.map +1 -0
- package/cjs/components/ScrollContainer/ScrollContainer.d.ts +1 -0
- package/cjs/components/ScrollContainer/ScrollContainer.js +8 -5
- package/cjs/components/ScrollContainer/ScrollContainer.js.map +1 -1
- package/cjs/components/Select/Select.d.ts +1 -0
- package/cjs/components/Select/Select.js +6 -4
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/SidePage/SidePage.d.ts +1 -0
- package/cjs/components/SidePage/SidePage.js +4 -1
- package/cjs/components/SidePage/SidePage.js.map +1 -1
- package/cjs/components/SidePage/SidePageBody.d.ts +1 -0
- package/cjs/components/SidePage/SidePageBody.js +9 -6
- package/cjs/components/SidePage/SidePageBody.js.map +1 -1
- package/cjs/components/SidePage/SidePageContainer.d.ts +1 -0
- package/cjs/components/SidePage/SidePageContainer.js +9 -6
- package/cjs/components/SidePage/SidePageContainer.js.map +1 -1
- package/cjs/components/SidePage/SidePageFooter.d.ts +1 -2
- package/cjs/components/SidePage/SidePageFooter.js +11 -12
- package/cjs/components/SidePage/SidePageFooter.js.map +1 -1
- package/cjs/components/SidePage/SidePageHeader.d.ts +1 -0
- package/cjs/components/SidePage/SidePageHeader.js +6 -3
- package/cjs/components/SidePage/SidePageHeader.js.map +1 -1
- package/cjs/components/Spinner/Spinner.d.ts +1 -0
- package/cjs/components/Spinner/Spinner.js +8 -5
- package/cjs/components/Spinner/Spinner.js.map +1 -1
- package/cjs/components/Sticky/Sticky.d.ts +1 -0
- package/cjs/components/Sticky/Sticky.js +8 -5
- package/cjs/components/Sticky/Sticky.js.map +1 -1
- package/cjs/components/Switcher/Switcher.d.ts +1 -0
- package/cjs/components/Switcher/Switcher.js +6 -3
- package/cjs/components/Switcher/Switcher.js.map +1 -1
- package/cjs/components/Tabs/Indicator.d.ts +1 -0
- package/cjs/components/Tabs/Indicator.js +16 -15
- package/cjs/components/Tabs/Indicator.js.map +1 -1
- package/cjs/components/Tabs/Tab.d.ts +2 -1
- package/cjs/components/Tabs/Tab.js +13 -9
- package/cjs/components/Tabs/Tab.js.map +1 -1
- package/cjs/components/Tabs/Tabs.d.ts +1 -0
- package/cjs/components/Tabs/Tabs.js +9 -9
- package/cjs/components/Tabs/Tabs.js.map +1 -1
- package/cjs/components/Textarea/Textarea.d.ts +1 -0
- package/cjs/components/Textarea/Textarea.js +12 -5
- package/cjs/components/Textarea/Textarea.js.map +1 -1
- package/cjs/components/Toast/Toast.d.ts +3 -0
- package/cjs/components/Toast/Toast.js +15 -4
- package/cjs/components/Toast/Toast.js.map +1 -1
- package/cjs/components/Toast/ToastView.d.ts +1 -0
- package/cjs/components/Toast/ToastView.js +8 -5
- package/cjs/components/Toast/ToastView.js.map +1 -1
- package/cjs/components/Toggle/Toggle.d.ts +1 -0
- package/cjs/components/Toggle/Toggle.js +9 -6
- package/cjs/components/Toggle/Toggle.js.map +1 -1
- package/cjs/components/Token/Token.d.ts +1 -0
- package/cjs/components/Token/Token.js +7 -4
- package/cjs/components/Token/Token.js.map +1 -1
- package/cjs/components/TokenInput/TokenInput.d.ts +1 -0
- package/cjs/components/TokenInput/TokenInput.js +11 -8
- package/cjs/components/TokenInput/TokenInput.js.map +1 -1
- package/cjs/components/Tooltip/Tooltip.d.ts +3 -1
- package/cjs/components/Tooltip/Tooltip.js +16 -5
- package/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/cjs/components/TooltipMenu/TooltipMenu.d.ts +1 -0
- package/cjs/components/TooltipMenu/TooltipMenu.js +8 -5
- package/cjs/components/TooltipMenu/TooltipMenu.js.map +1 -1
- package/cjs/internal/CommonWrapper/CommonWrapper.d.ts +9 -1
- package/cjs/internal/CommonWrapper/CommonWrapper.js +38 -15
- package/cjs/internal/CommonWrapper/CommonWrapper.js.map +1 -1
- package/cjs/internal/CustomComboBox/ComboBoxMenu.js +3 -2
- package/cjs/internal/CustomComboBox/ComboBoxMenu.js.map +1 -1
- package/cjs/internal/CustomComboBox/ComboBoxView.d.ts +4 -1
- package/cjs/internal/CustomComboBox/ComboBoxView.js +15 -5
- package/cjs/internal/CustomComboBox/ComboBoxView.js.map +1 -1
- package/cjs/internal/CustomComboBox/CustomComboBox.d.ts +1 -0
- package/cjs/internal/CustomComboBox/CustomComboBox.js +8 -5
- package/cjs/internal/CustomComboBox/CustomComboBox.js.map +1 -1
- package/cjs/internal/DateSelect/DateSelect.d.ts +2 -2
- package/cjs/internal/DateSelect/DateSelect.js +3 -3
- package/cjs/internal/DateSelect/DateSelect.js.map +1 -1
- package/cjs/internal/DropdownContainer/DropdownContainer.d.ts +4 -7
- package/cjs/internal/DropdownContainer/DropdownContainer.js +8 -13
- package/cjs/internal/DropdownContainer/DropdownContainer.js.map +1 -1
- package/cjs/internal/FocusTrap/FocusTrap.d.ts +1 -0
- package/cjs/internal/FocusTrap/FocusTrap.js +12 -9
- package/cjs/internal/FocusTrap/FocusTrap.js.map +1 -1
- package/cjs/internal/IgnoreLayerClick/IgnoreLayerClick.js +12 -4
- package/cjs/internal/IgnoreLayerClick/IgnoreLayerClick.js.map +1 -1
- package/cjs/internal/InputLikeText/InputLikeText.d.ts +1 -0
- package/cjs/internal/InputLikeText/InputLikeText.js +10 -3
- package/cjs/internal/InputLikeText/InputLikeText.js.map +1 -1
- package/cjs/internal/InternalMenu/InternalMenu.d.ts +2 -3
- package/cjs/internal/InternalMenu/InternalMenu.js +16 -22
- package/cjs/internal/InternalMenu/InternalMenu.js.map +1 -1
- package/cjs/internal/MaskedInput/MaskedInput.d.ts +2 -2
- package/cjs/internal/MaskedInput/MaskedInput.js +3 -3
- package/cjs/internal/MaskedInput/MaskedInput.js.map +1 -1
- package/cjs/internal/Menu/Menu.d.ts +1 -0
- package/cjs/internal/Menu/Menu.js +9 -6
- package/cjs/internal/Menu/Menu.js.map +1 -1
- package/cjs/internal/Popup/Popup.d.ts +4 -4
- package/cjs/internal/Popup/Popup.js +50 -27
- package/cjs/internal/Popup/Popup.js.map +1 -1
- package/cjs/internal/PopupMenu/PopupMenu.d.ts +1 -0
- package/cjs/internal/PopupMenu/PopupMenu.js +7 -4
- package/cjs/internal/PopupMenu/PopupMenu.js.map +1 -1
- package/cjs/internal/RenderContainer/RenderContainer.d.ts +1 -1
- package/cjs/internal/RenderContainer/RenderContainer.js +2 -1
- package/cjs/internal/RenderContainer/RenderContainer.js.map +1 -1
- package/cjs/internal/RenderContainer/RenderInnerContainer.js +2 -3
- package/cjs/internal/RenderContainer/RenderInnerContainer.js.map +1 -1
- package/cjs/internal/RenderLayer/RenderLayer.d.ts +3 -1
- package/cjs/internal/RenderLayer/RenderLayer.js +13 -7
- package/cjs/internal/RenderLayer/RenderLayer.js.map +1 -1
- package/cjs/internal/ThemeShowcase/ThemeShowcase.d.ts +1 -1
- package/cjs/internal/ThemeShowcase/ThemeShowcase.js +20 -19
- package/cjs/internal/ThemeShowcase/ThemeShowcase.js.map +1 -1
- package/cjs/internal/ZIndex/ZIndex.d.ts +2 -0
- package/cjs/internal/ZIndex/ZIndex.js +45 -34
- package/cjs/internal/ZIndex/ZIndex.js.map +1 -1
- package/cjs/internal/icons/16px/index.d.ts +17 -16
- package/cjs/internal/icons/16px/index.js +108 -51
- package/cjs/internal/icons/16px/index.js.map +1 -1
- package/cjs/lib/callChildRef/callChildRef.d.ts +3 -0
- package/cjs/lib/callChildRef/callChildRef.js +19 -0
- package/cjs/lib/callChildRef/callChildRef.js.map +1 -0
- package/cjs/lib/rootNode/getRootNode.d.ts +3 -0
- package/cjs/lib/rootNode/getRootNode.js +27 -0
- package/cjs/lib/rootNode/getRootNode.js.map +1 -0
- package/cjs/lib/rootNode/index.d.ts +2 -0
- package/cjs/lib/rootNode/index.js +2 -0
- package/cjs/lib/rootNode/index.js.map +1 -0
- package/cjs/lib/rootNode/rootNodeDecorator.d.ts +33 -0
- package/cjs/lib/rootNode/rootNodeDecorator.js +31 -0
- package/cjs/lib/rootNode/rootNodeDecorator.js.map +1 -0
- package/cjs/lib/theming/Emotion.js +1 -0
- package/cjs/lib/theming/Emotion.js.map +1 -1
- package/cjs/lib/utils.d.ts +3 -0
- package/cjs/lib/utils.js +15 -2
- package/cjs/lib/utils.js.map +1 -1
- package/components/Autocomplete/Autocomplete/Autocomplete.js +19 -16
- package/components/Autocomplete/Autocomplete/Autocomplete.js.map +1 -1
- package/components/Autocomplete/Autocomplete.d.ts +1 -0
- package/components/Button/Button/Button.js +15 -12
- package/components/Button/Button/Button.js.map +1 -1
- package/components/Button/Button.d.ts +1 -0
- package/components/Center/Center/Center.js +14 -9
- package/components/Center/Center/Center.js.map +1 -1
- package/components/Center/Center.d.ts +1 -0
- package/components/Checkbox/Checkbox/Checkbox.js +16 -10
- package/components/Checkbox/Checkbox/Checkbox.js.map +1 -1
- package/components/Checkbox/Checkbox.d.ts +3 -2
- package/components/ComboBox/ComboBox/ComboBox.js +38 -32
- package/components/ComboBox/ComboBox/ComboBox.js.map +1 -1
- package/components/ComboBox/ComboBox.d.ts +2 -0
- package/components/CurrencyInput/CurrencyInput/CurrencyInput.js +29 -27
- package/components/CurrencyInput/CurrencyInput/CurrencyInput.js.map +1 -1
- package/components/CurrencyInput/CurrencyInput.d.ts +3 -3
- package/components/DateInput/DateInput/DateInput.js +7 -3
- package/components/DateInput/DateInput/DateInput.js.map +1 -1
- package/components/DateInput/DateInput.d.ts +1 -0
- package/components/DatePicker/DatePicker/DatePicker.js +29 -22
- package/components/DatePicker/DatePicker/DatePicker.js.map +1 -1
- package/components/DatePicker/DatePicker.d.ts +4 -2
- package/components/Dropdown/Dropdown/Dropdown.js +15 -13
- package/components/Dropdown/Dropdown/Dropdown.js.map +1 -1
- package/components/Dropdown/Dropdown.d.ts +1 -0
- package/components/DropdownMenu/DropdownMenu/DropdownMenu.js +15 -9
- package/components/DropdownMenu/DropdownMenu/DropdownMenu.js.map +1 -1
- package/components/DropdownMenu/DropdownMenu.d.ts +1 -0
- package/components/FxInput/FxInput/FxInput.js +13 -9
- package/components/FxInput/FxInput/FxInput.js.map +1 -1
- package/components/FxInput/FxInput.d.ts +1 -0
- package/components/Gapped/Gapped/Gapped.js +15 -11
- package/components/Gapped/Gapped/Gapped.js.map +1 -1
- package/components/Gapped/Gapped.d.ts +1 -0
- package/components/Group/Group/Group.js +22 -9
- package/components/Group/Group/Group.js.map +1 -1
- package/components/Group/Group.d.ts +1 -0
- package/components/Hint/Hint/Hint.js +18 -12
- package/components/Hint/Hint/Hint.js.map +1 -1
- package/components/Hint/Hint.d.ts +3 -2
- package/components/Input/Input/Input.js +21 -14
- package/components/Input/Input/Input.js.map +1 -1
- package/components/Input/Input.d.ts +4 -1
- package/components/Kebab/Kebab/Kebab.js +12 -7
- package/components/Kebab/Kebab/Kebab.js.map +1 -1
- package/components/Kebab/Kebab.d.ts +1 -0
- package/components/Link/Link/Link.js +15 -11
- package/components/Link/Link/Link.js.map +1 -1
- package/components/Link/Link.d.ts +1 -0
- package/components/Loader/Loader/Loader.js +16 -11
- package/components/Loader/Loader/Loader.js.map +1 -1
- package/components/Loader/Loader.d.ts +1 -0
- package/components/MenuItem/MenuItem/MenuItem.js +21 -14
- package/components/MenuItem/MenuItem/MenuItem.js.map +1 -1
- package/components/MenuItem/MenuItem.d.ts +1 -0
- package/components/Modal/Modal/Modal.js +1 -1
- package/components/Modal/Modal/Modal.js.map +1 -1
- package/components/Modal/ModalBody/ModalBody.js +16 -10
- package/components/Modal/ModalBody/ModalBody.js.map +1 -1
- package/components/Modal/ModalBody.d.ts +1 -0
- package/components/Paging/Paging/Paging.js +17 -14
- package/components/Paging/Paging/Paging.js.map +1 -1
- package/components/Paging/Paging.d.ts +2 -2
- package/components/PasswordInput/PasswordInput/PasswordInput.js +18 -14
- package/components/PasswordInput/PasswordInput/PasswordInput.js.map +1 -1
- package/components/PasswordInput/PasswordInput.d.ts +3 -2
- package/components/Radio/Radio/Radio.js +17 -19
- package/components/Radio/Radio/Radio.js.map +1 -1
- package/components/Radio/Radio.d.ts +5 -10
- package/components/RadioGroup/RadioGroup/RadioGroup.js +35 -38
- package/components/RadioGroup/RadioGroup/RadioGroup.js.map +1 -1
- package/components/RadioGroup/RadioGroup.d.ts +2 -16
- package/components/RadioGroup/RadioGroupContext/RadioGroupContext.js +12 -0
- package/components/RadioGroup/RadioGroupContext/RadioGroupContext.js.map +1 -0
- package/components/RadioGroup/RadioGroupContext/package.json +6 -0
- package/components/RadioGroup/RadioGroupContext.d.ts +10 -0
- package/components/ScrollContainer/ScrollContainer/ScrollContainer.js +13 -8
- package/components/ScrollContainer/ScrollContainer/ScrollContainer.js.map +1 -1
- package/components/ScrollContainer/ScrollContainer.d.ts +1 -0
- package/components/Select/Select/Select.js +8 -5
- package/components/Select/Select/Select.js.map +1 -1
- package/components/Select/Select.d.ts +1 -0
- package/components/SidePage/SidePage/SidePage.js +6 -3
- package/components/SidePage/SidePage/SidePage.js.map +1 -1
- package/components/SidePage/SidePage.d.ts +1 -0
- package/components/SidePage/SidePageBody/SidePageBody.js +16 -10
- package/components/SidePage/SidePageBody/SidePageBody.js.map +1 -1
- package/components/SidePage/SidePageBody.d.ts +1 -0
- package/components/SidePage/SidePageContainer/SidePageContainer.js +16 -9
- package/components/SidePage/SidePageContainer/SidePageContainer.js.map +1 -1
- package/components/SidePage/SidePageContainer.d.ts +1 -0
- package/components/SidePage/SidePageFooter/SidePageFooter.js +22 -19
- package/components/SidePage/SidePageFooter/SidePageFooter.js.map +1 -1
- package/components/SidePage/SidePageFooter.d.ts +1 -2
- package/components/SidePage/SidePageHeader/SidePageHeader.js +15 -10
- package/components/SidePage/SidePageHeader/SidePageHeader.js.map +1 -1
- package/components/SidePage/SidePageHeader.d.ts +1 -0
- package/components/Spinner/Spinner/Spinner.js +8 -3
- package/components/Spinner/Spinner/Spinner.js.map +1 -1
- package/components/Spinner/Spinner.d.ts +1 -0
- package/components/Sticky/Sticky/Sticky.js +13 -8
- package/components/Sticky/Sticky/Sticky.js.map +1 -1
- package/components/Sticky/Sticky.d.ts +1 -0
- package/components/Switcher/Switcher/Switcher.js +11 -6
- package/components/Switcher/Switcher/Switcher.js.map +1 -1
- package/components/Switcher/Switcher.d.ts +1 -0
- package/components/Tabs/Indicator/Indicator.js +16 -14
- package/components/Tabs/Indicator/Indicator.js.map +1 -1
- package/components/Tabs/Indicator.d.ts +1 -0
- package/components/Tabs/Tab/Tab.js +31 -34
- package/components/Tabs/Tab/Tab.js.map +1 -1
- package/components/Tabs/Tab.d.ts +2 -1
- package/components/Tabs/Tabs/Tabs.js +20 -20
- package/components/Tabs/Tabs/Tabs.js.map +1 -1
- package/components/Tabs/Tabs.d.ts +1 -0
- package/components/Textarea/Textarea/Textarea.js +21 -17
- package/components/Textarea/Textarea/Textarea.js.map +1 -1
- package/components/Textarea/Textarea.d.ts +1 -0
- package/components/Toast/Toast/Toast.js +29 -14
- package/components/Toast/Toast/Toast.js.map +1 -1
- package/components/Toast/Toast.d.ts +3 -0
- package/components/Toast/ToastView/ToastView.js +10 -5
- package/components/Toast/ToastView/ToastView.js.map +1 -1
- package/components/Toast/ToastView.d.ts +1 -0
- package/components/Toggle/Toggle/Toggle.js +16 -11
- package/components/Toggle/Toggle/Toggle.js.map +1 -1
- package/components/Toggle/Toggle.d.ts +1 -0
- package/components/Token/Token/Token.js +11 -4
- package/components/Token/Token/Token.js.map +1 -1
- package/components/Token/Token.d.ts +1 -0
- package/components/TokenInput/TokenInput/TokenInput.js +12 -6
- package/components/TokenInput/TokenInput/TokenInput.js.map +1 -1
- package/components/TokenInput/TokenInput.d.ts +1 -0
- package/components/Tooltip/Tooltip/Tooltip.js +24 -15
- package/components/Tooltip/Tooltip/Tooltip.js.map +1 -1
- package/components/Tooltip/Tooltip.d.ts +3 -1
- package/components/TooltipMenu/TooltipMenu/TooltipMenu.js +23 -17
- package/components/TooltipMenu/TooltipMenu/TooltipMenu.js.map +1 -1
- package/components/TooltipMenu/TooltipMenu.d.ts +1 -0
- package/internal/CommonWrapper/CommonWrapper/CommonWrapper.js +37 -10
- package/internal/CommonWrapper/CommonWrapper/CommonWrapper.js.map +1 -1
- package/internal/CommonWrapper/CommonWrapper.d.ts +9 -1
- package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js +5 -3
- package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js.map +1 -1
- package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js +23 -13
- package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js.map +1 -1
- package/internal/CustomComboBox/ComboBoxView.d.ts +4 -1
- package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js +12 -4
- package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js.map +1 -1
- package/internal/CustomComboBox/CustomComboBox.d.ts +1 -0
- package/internal/DateSelect/DateSelect/DateSelect.js +5 -5
- package/internal/DateSelect/DateSelect/DateSelect.js.map +1 -1
- package/internal/DateSelect/DateSelect.d.ts +2 -2
- package/internal/DropdownContainer/DropdownContainer/DropdownContainer.js +11 -15
- package/internal/DropdownContainer/DropdownContainer/DropdownContainer.js.map +1 -1
- package/internal/DropdownContainer/DropdownContainer.d.ts +4 -7
- package/internal/FocusTrap/FocusTrap/FocusTrap.js +17 -9
- package/internal/FocusTrap/FocusTrap/FocusTrap.js.map +1 -1
- package/internal/FocusTrap/FocusTrap.d.ts +1 -0
- package/internal/IgnoreLayerClick/IgnoreLayerClick/IgnoreLayerClick.js +13 -7
- package/internal/IgnoreLayerClick/IgnoreLayerClick/IgnoreLayerClick.js.map +1 -1
- package/internal/InputLikeText/InputLikeText/InputLikeText.js +11 -6
- package/internal/InputLikeText/InputLikeText/InputLikeText.js.map +1 -1
- package/internal/InputLikeText/InputLikeText.d.ts +1 -0
- package/internal/InternalMenu/InternalMenu/InternalMenu.js +24 -25
- package/internal/InternalMenu/InternalMenu/InternalMenu.js.map +1 -1
- package/internal/InternalMenu/InternalMenu.d.ts +2 -3
- package/internal/MaskedInput/MaskedInput/MaskedInput.js +7 -7
- package/internal/MaskedInput/MaskedInput/MaskedInput.js.map +1 -1
- package/internal/MaskedInput/MaskedInput.d.ts +2 -2
- package/internal/Menu/Menu/Menu.js +11 -8
- package/internal/Menu/Menu/Menu.js.map +1 -1
- package/internal/Menu/Menu.d.ts +1 -0
- package/internal/Popup/Popup/Popup.js +79 -68
- package/internal/Popup/Popup/Popup.js.map +1 -1
- package/internal/Popup/Popup.d.ts +4 -4
- package/internal/PopupMenu/PopupMenu/PopupMenu.js +12 -7
- package/internal/PopupMenu/PopupMenu/PopupMenu.js.map +1 -1
- package/internal/PopupMenu/PopupMenu.d.ts +1 -0
- package/internal/RenderContainer/RenderContainer/RenderContainer.js +3 -1
- package/internal/RenderContainer/RenderContainer/RenderContainer.js.map +1 -1
- package/internal/RenderContainer/RenderContainer.d.ts +1 -1
- package/internal/RenderContainer/RenderInnerContainer/RenderInnerContainer.js +2 -3
- package/internal/RenderContainer/RenderInnerContainer/RenderInnerContainer.js.map +1 -1
- package/internal/RenderLayer/RenderLayer/RenderLayer.js +20 -18
- package/internal/RenderLayer/RenderLayer/RenderLayer.js.map +1 -1
- package/internal/RenderLayer/RenderLayer.d.ts +3 -1
- package/internal/ThemeShowcase/ThemeShowcase/ThemeShowcase.js +35 -43
- package/internal/ThemeShowcase/ThemeShowcase/ThemeShowcase.js.map +1 -1
- package/internal/ThemeShowcase/ThemeShowcase.d.ts +1 -1
- package/internal/ZIndex/ZIndex/ZIndex.js +20 -8
- package/internal/ZIndex/ZIndex/ZIndex.js.map +1 -1
- package/internal/ZIndex/ZIndex.d.ts +2 -0
- package/internal/icons/16px/index/index.js +83 -51
- package/internal/icons/16px/index/index.js.map +1 -1
- package/internal/icons/16px/index.d.ts +17 -16
- package/lib/callChildRef/callChildRef/callChildRef.js +14 -0
- package/lib/callChildRef/callChildRef/callChildRef.js.map +1 -0
- package/lib/callChildRef/callChildRef/package.json +6 -0
- package/lib/callChildRef/callChildRef.d.ts +3 -0
- package/lib/rootNode/getRootNode/getRootNode.js +25 -0
- package/lib/rootNode/getRootNode/getRootNode.js.map +1 -0
- package/lib/rootNode/getRootNode/package.json +6 -0
- package/lib/rootNode/getRootNode.d.ts +3 -0
- package/lib/rootNode/index/index.js +2 -0
- package/lib/rootNode/index/index.js.map +1 -0
- package/lib/rootNode/index/package.json +6 -0
- package/lib/rootNode/index.d.ts +2 -0
- package/lib/rootNode/package.json +6 -0
- package/lib/rootNode/rootNodeDecorator/package.json +6 -0
- package/lib/rootNode/rootNodeDecorator/rootNodeDecorator.js +37 -0
- package/lib/rootNode/rootNodeDecorator/rootNodeDecorator.js.map +1 -0
- package/lib/rootNode/rootNodeDecorator.d.ts +33 -0
- package/lib/theming/Emotion/Emotion.js +1 -0
- package/lib/theming/Emotion/Emotion.js.map +1 -1
- package/lib/utils/utils.js +11 -1
- package/lib/utils/utils.js.map +1 -1
- package/lib/utils.d.ts +3 -0
- package/package.json +8 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ComboBoxView.tsx"],"names":["ComboBoxView","input","renderAddButton","props","textValue","handleItemSelect","item","onValueChange","refInput","renderSpinner","styles","spinnerWrapper","getRightIcon","loading","items","drawArrow","rightIcon","length","rightIconWrapper","componentDidMount","autoFocus","onFocus","componentDidUpdate","prevProps","editing","focus","render","menuAlign","onClickOutside","onFocusOutside","onMouseEnter","onMouseLeave","onMouseOver","opened","refMenu","maxMenuHeight","renderTotalCount","renderItem","renderNotFound","repeatRequest","requestStatus","totalCount","size","width","renderInput","topOffsets","spinner","arrow","root","disablePortal","align","borderless","disabled","error","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","placeholder","renderValue","value","warning","refInputLikeText","leftIcon","inputMode","maxLength","React","Component","__KONTUR_REACT_UI__","defaultProps","undefined","ComboBoxRequestStat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E,KAAK,EAAEZ,SAAS,IAAI,EAZtB,EAaE,SAAS,EAAEsD,cAbb,EAcE,WAAW,EAAEC,WAdf,EAeE,KAAK,EAAC,MAfR,EAgBE,IAAI,EAAEjB,IAhBR,EAiBE,GAAG,EAAE,KAAKlC,QAjBZ,EAkBE,OAAO,EAAEsD,OAlBX,EAmBE,SAAS,EAAEG,SAnBb,GADF,CAuBD,CAED,oBACE,6BAAC,4BAAD,IACE,KAAK,EAAEf,KADT,EAEE,UAAU,EAAEC,UAFd,EAGE,KAAK,EAAEE,KAHT,EAIE,OAAO,EAAEhC,OAJX,EAKE,QAAQ,EAAE2C,QALZ,EAME,SAAS,EAAEhD,SANb,EAOE,QAAQ,EAAEoC,QAPZ,EAQE,OAAO,EAAEU,OARX,EASE,WAAW,EAAEH,WATf,EAUE,IAAI,EAAEjB,IAVR,EAWE,KAAK,EAAC,MAXR,EAYE,GAAG,EAAEqB,gBAZP,IAcG,0BAAcF,KAAd,KAAwBD,WAAxB,GAAsCA,WAAW,CAACC,KAAD,CAAjD,GAA2D,IAd9D,CADF,CAkBD,C,uBA3LkCM,eAAMC,S,sCAA9BpE,Y,CACGqE,mB,GAAsB,c,CADzBrE,Y,CAGGsE,Y,GAAe,EAC3BjC,UAAU,EAAE,oBAAC/B,IAAD,UAAeA,IAAf,EADe,EAE3BsD,WAAW,EAAE,qBAACtD,IAAD,UAAeA,IAAf,EAFc,EAG3BJ,eAAe,EAAE,mCAAM,IAAN,EAHU,EAI3BqC,aAAa,EAAE,iCAAMgC,SAAN,EAJY,EAK3B/B,aAAa,EAAEgC,2CAAsBC,OALV,EAM3B7C,cAAc,EAAE,0BAAM,CACpB,IACD,CAR0B,EAS3BC,cAAc,EAAE,0BAAM,CACpB,IACD,CAX0B,EAY3Ba,IAAI,EAAE,OAZqB,EAa3BC,KAAK,EAAE,GAboB,E","sourcesContent":["import React from 'react';\nimport { findDOMNode } from 'react-dom';\n\nimport { isNonNullable } from '../../lib/utils';\nimport { DropdownContainer } from '../DropdownContainer';\nimport { Input, InputIconType } from '../../components/Input';\nimport { InputLikeText } from '../InputLikeText';\nimport { Menu } from '../Menu';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { RenderLayer } from '../RenderLayer';\nimport { Spinner } from '../../components/Spinner';\nimport { Nullable } from '../../typings/utility-types';\nimport { ArrowChevronDownIcon } from '../icons/16px';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\n\nimport { ComboBoxMenu } from './ComboBoxMenu';\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { styles } from './CustomComboBox.styles';\n\ninterface ComboBoxViewProps<T> extends CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n editing?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n items?: Nullable<T[]>;\n loading?: boolean;\n menuAlign?: 'left' | 'right';\n opened?: boolean;\n drawArrow?: boolean;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n textValue?: string;\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxLength?: number;\n maxMenuHeight?: number | string;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n\n onValueChange?: (value: T) => void;\n onClickOutside?: (e: Event) => void;\n onFocus?: () => void;\n onFocusOutside?: () => void;\n onInputBlur?: () => void;\n onInputValueChange?: (value: string) => void;\n onInputFocus?: () => void;\n onInputClick?: () => void;\n onInputKeyDown?: (e: React.KeyboardEvent) => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n renderItem?: (item: T, state: MenuItemState) => React.ReactNode;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderValue?: (item: T) => React.ReactNode;\n renderAddButton: (query?: string) => React.ReactNode;\n repeatRequest?: () => void;\n requestStatus?: ComboBoxRequestStatus;\n refInput?: (input: Nullable<Input>) => void;\n refMenu?: (menu: Nullable<Menu>) => void;\n refInputLikeText?: (inputLikeText: Nullable<InputLikeText>) => void;\n}\n\nexport class ComboBoxView<T> extends React.Component<ComboBoxViewProps<T>> {\n public static __KONTUR_REACT_UI__ = 'ComboBoxView';\n\n public static defaultProps = {\n renderItem: (item: any) => item,\n renderValue: (item: any) => item,\n renderAddButton: () => null,\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n onClickOutside: () => {\n /**/\n },\n onFocusOutside: () => {\n /**/\n },\n size: 'small',\n width: 250,\n };\n\n private input: Nullable<Input>;\n\n public componentDidMount() {\n if (this.props.autoFocus && this.props.onFocus) {\n this.props.onFocus();\n }\n }\n\n public componentDidUpdate(prevProps: ComboBoxViewProps<T>) {\n const { input, props } = this;\n if (props.editing && !prevProps.editing && input) {\n input.focus();\n }\n }\n\n public render() {\n const {\n items,\n loading,\n menuAlign,\n onClickOutside,\n onFocusOutside,\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n opened,\n refMenu,\n maxMenuHeight,\n renderTotalCount,\n renderItem,\n renderNotFound,\n repeatRequest,\n requestStatus,\n totalCount,\n size,\n width,\n } = this.props;\n\n const input = this.renderInput();\n\n const topOffsets = {\n spinner: 6,\n arrow: 15,\n };\n if (size === 'medium') {\n topOffsets.spinner += 4;\n topOffsets.arrow += 4;\n }\n if (size === 'large') {\n topOffsets.spinner += 6;\n topOffsets.arrow += 6;\n }\n\n return (\n <CommonWrapper {...this.props}>\n <RenderLayer onClickOutside={onClickOutside} onFocusOutside={onFocusOutside} active={opened}>\n <span\n style={{ width }}\n className={styles.root()}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onMouseOver={onMouseOver}\n >\n {input}\n {opened && (\n <DropdownContainer\n align={menuAlign}\n getParent={() => findDOMNode(this)}\n offsetY={1}\n disablePortal={this.props.disablePortal}\n >\n <ComboBoxMenu\n items={items}\n loading={loading}\n maxMenuHeight={maxMenuHeight}\n onValueChange={this.handleItemSelect}\n opened={opened}\n refMenu={refMenu}\n renderTotalCount={renderTotalCount}\n renderItem={renderItem!}\n renderNotFound={renderNotFound}\n renderAddButton={this.renderAddButton}\n repeatRequest={repeatRequest}\n requestStatus={requestStatus}\n totalCount={totalCount}\n />\n </DropdownContainer>\n )}\n </span>\n </RenderLayer>\n </CommonWrapper>\n );\n }\n\n private renderAddButton = (): React.ReactNode => {\n return this.props.renderAddButton(this.props.textValue);\n };\n\n private renderInput(): React.ReactNode {\n const {\n align,\n borderless,\n disabled,\n editing,\n error,\n onFocus,\n onInputBlur,\n onInputValueChange,\n onInputFocus,\n onInputClick,\n onInputKeyDown,\n placeholder,\n renderValue,\n size,\n textValue,\n value,\n warning,\n refInputLikeText,\n leftIcon,\n inputMode,\n } = this.props;\n\n const rightIcon = this.getRightIcon();\n\n if (editing) {\n return (\n <Input\n align={align}\n borderless={borderless}\n disabled={disabled}\n error={error}\n maxLength={this.props.maxLength}\n onBlur={onInputBlur}\n onValueChange={onInputValueChange}\n onFocus={onInputFocus}\n onClick={onInputClick}\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n value={textValue || ''}\n onKeyDown={onInputKeyDown}\n placeholder={placeholder}\n width=\"100%\"\n size={size}\n ref={this.refInput}\n warning={warning}\n inputMode={inputMode}\n />\n );\n }\n\n return (\n <InputLikeText\n align={align}\n borderless={borderless}\n error={error}\n onFocus={onFocus}\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n disabled={disabled}\n warning={warning}\n placeholder={placeholder}\n size={size}\n width=\"100%\"\n ref={refInputLikeText}\n >\n {isNonNullable(value) && renderValue ? renderValue(value) : null}\n </InputLikeText>\n );\n }\n\n private handleItemSelect = (item: T) => {\n if (this.props.onValueChange) {\n this.props.onValueChange(item);\n }\n };\n\n private refInput = (input: Nullable<Input>) => {\n if (this.props.refInput) {\n this.props.refInput(input);\n }\n this.input = input;\n };\n\n private renderSpinner = () => (\n <span className={styles.spinnerWrapper()}>\n <Spinner type=\"mini\" caption=\"\" dimmed />\n </span>\n );\n\n private getRightIcon = () => {\n const { loading, items, drawArrow, rightIcon } = this.props;\n\n if (loading && items && !!items.length) {\n return this.renderSpinner();\n }\n\n if (rightIcon || drawArrow) {\n return <span className={styles.rightIconWrapper()}>{rightIcon ?? <ArrowChevronDownIcon />}</span>;\n }\n\n return null;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["ComboBoxView.tsx"],"names":["ComboBoxView","rootNode","input","setRootNode","dropdownContainerRef","React","createRef","getParent","renderAddButton","props","textValue","handleItemSelect","item","onValueChange","refInput","renderSpinner","styles","spinnerWrapper","getRightIcon","loading","items","drawArrow","rightIcon","length","rightIconWrapper","componentDidMount","autoFocus","onFocus","opened","current","position","componentDidUpdate","prevProps","editing","focus","render","menuAlign","onClickOutside","onFocusOutside","onMouseEnter","onMouseLeave","onMouseOver","refMenu","maxMenuHeight","renderTotalCount","renderItem","renderNotFound","repeatRequest","requestStatus","totalCount","size","width","renderInput","topOffsets","spinner","arrow","root","disablePortal","align","borderless","disabled","error","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","placeholder","renderValue","value","warning","refInputLikeText","leftIcon","inputMode","maxLength","Component","__KONTUR_REACT_UI__","defaultProps","undefined","ComboBoxRequestStatus","Unknown"],"mappings":"sWAAA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,yD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DaA,Y,OADZC,kB;;;;;;;;;;;;;;;;;;;AAoBSC,IAAAA,K;AACAC,IAAAA,W;AACAC,IAAAA,oB,gBAAuBC,eAAMC,SAAN,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,cAbb,EAcE,WAAW,EAAEC,WAdf,EAeE,KAAK,EAAC,MAfR,EAgBE,IAAI,EAAEjB,IAhBR,EAiBE,GAAG,EAAE,KAAKpC,QAjBZ,EAkBE,OAAO,EAAEwD,OAlBX,EAmBE,SAAS,EAAEG,SAnBb,GADF,CAuBD,CAED,oBACE,6BAAC,4BAAD,IACE,KAAK,EAAEf,KADT,EAEE,UAAU,EAAEC,UAFd,EAGE,KAAK,EAAEE,KAHT,EAIE,OAAO,EAAElC,OAJX,EAKE,QAAQ,EAAE6C,QALZ,EAME,SAAS,EAAElD,SANb,EAOE,QAAQ,EAAEsC,QAPZ,EAQE,OAAO,EAAEU,OARX,EASE,WAAW,EAAEH,WATf,EAUE,IAAI,EAAEjB,IAVR,EAWE,KAAK,EAAC,MAXR,EAYE,GAAG,EAAEqB,gBAZP,IAcG,0BAAcF,KAAd,KAAwBD,WAAxB,GAAsCA,WAAW,CAACC,KAAD,CAAjD,GAA2D,IAd9D,CADF,CAkBD,C,uBApMkChE,eAAMsE,S,WAC3BC,mB,GAAsB,c,UAEtBC,Y,GAAe,EAC3BhC,UAAU,EAAE,oBAACjC,IAAD,UAAeA,IAAf,EADe,EAE3BwD,WAAW,EAAE,qBAACxD,IAAD,UAAeA,IAAf,EAFc,EAG3BJ,eAAe,EAAE,mCAAM,IAAN,EAHU,EAI3BuC,aAAa,EAAE,iCAAM+B,SAAN,EAJY,EAK3B9B,aAAa,EAAE+B,2CAAsBC,OALV,EAM3B3C,cAAc,EAAE,0BAAM,CACpB,IACD,CAR0B,EAS3BC,cAAc,EAAE,0BAAM,CACpB,IACD,CAX0B,EAY3BY,IAAI,EAAE,OAZqB,EAa3BC,KAAK,EAAE,GAboB,E","sourcesContent":["import React from 'react';\n\nimport { isNonNullable } from '../../lib/utils';\nimport { DropdownContainer } from '../DropdownContainer';\nimport { Input, InputIconType } from '../../components/Input';\nimport { InputLikeText } from '../InputLikeText';\nimport { Menu } from '../Menu';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { RenderLayer } from '../RenderLayer';\nimport { Spinner } from '../../components/Spinner';\nimport { Nullable } from '../../typings/utility-types';\nimport { ArrowChevronDownIcon } from '../icons/16px';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { rootNode, getRootNode, TSetRootNode } from '../../lib/rootNode';\n\nimport { ComboBoxMenu } from './ComboBoxMenu';\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { styles } from './CustomComboBox.styles';\n\ninterface ComboBoxViewProps<T> extends CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n editing?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n items?: Nullable<T[]>;\n loading?: boolean;\n menuAlign?: 'left' | 'right';\n opened?: boolean;\n drawArrow?: boolean;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n textValue?: string;\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxLength?: number;\n maxMenuHeight?: number | string;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n\n onValueChange?: (value: T) => void;\n onClickOutside?: (e: Event) => void;\n onFocus?: () => void;\n onFocusOutside?: () => void;\n onInputBlur?: () => void;\n onInputValueChange?: (value: string) => void;\n onInputFocus?: () => void;\n onInputClick?: () => void;\n onInputKeyDown?: (e: React.KeyboardEvent) => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n renderItem?: (item: T, state: MenuItemState) => React.ReactNode;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderValue?: (item: T) => React.ReactNode;\n renderAddButton: (query?: string) => React.ReactNode;\n repeatRequest?: () => void;\n requestStatus?: ComboBoxRequestStatus;\n refInput?: (input: Nullable<Input>) => void;\n refMenu?: (menu: Nullable<Menu>) => void;\n refInputLikeText?: (inputLikeText: Nullable<InputLikeText>) => void;\n}\n\n@rootNode\nexport class ComboBoxView<T> extends React.Component<ComboBoxViewProps<T>, {}> {\n public static __KONTUR_REACT_UI__ = 'ComboBoxView';\n\n public static defaultProps = {\n renderItem: (item: any) => item,\n renderValue: (item: any) => item,\n renderAddButton: () => null,\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n onClickOutside: () => {\n /**/\n },\n onFocusOutside: () => {\n /**/\n },\n size: 'small',\n width: 250,\n };\n\n private input: Nullable<Input>;\n private setRootNode!: TSetRootNode;\n private dropdownContainerRef = React.createRef<DropdownContainer>();\n\n public componentDidMount() {\n if (this.props.autoFocus && this.props.onFocus) {\n this.props.onFocus();\n }\n this.props.opened && this.dropdownContainerRef.current?.position();\n }\n\n public componentDidUpdate(prevProps: ComboBoxViewProps<T>) {\n const { input, props } = this;\n if (props.editing && !prevProps.editing && input) {\n input.focus();\n }\n }\n\n public render() {\n const {\n items,\n loading,\n menuAlign,\n onClickOutside,\n onFocusOutside,\n onMouseEnter,\n onMouseLeave,\n onMouseOver,\n opened,\n refMenu,\n maxMenuHeight,\n renderTotalCount,\n renderItem,\n renderNotFound,\n repeatRequest,\n requestStatus,\n totalCount,\n size,\n width,\n } = this.props;\n\n const input = this.renderInput();\n\n const topOffsets = {\n spinner: 6,\n arrow: 15,\n };\n if (size === 'medium') {\n topOffsets.spinner += 4;\n topOffsets.arrow += 4;\n }\n if (size === 'large') {\n topOffsets.spinner += 6;\n topOffsets.arrow += 6;\n }\n\n return (\n <CommonWrapper {...this.props}>\n <RenderLayer onClickOutside={onClickOutside} onFocusOutside={onFocusOutside} active={opened}>\n <span\n style={{ width }}\n className={styles.root()}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onMouseOver={onMouseOver}\n ref={this.setRootNode}\n >\n {input}\n {opened && (\n <DropdownContainer\n align={menuAlign}\n getParent={this.getParent}\n offsetY={1}\n disablePortal={this.props.disablePortal}\n ref={this.dropdownContainerRef}\n >\n <ComboBoxMenu\n items={items}\n loading={loading}\n maxMenuHeight={maxMenuHeight}\n onValueChange={this.handleItemSelect}\n opened={opened}\n refMenu={refMenu}\n renderTotalCount={renderTotalCount}\n renderItem={renderItem!}\n renderNotFound={renderNotFound}\n renderAddButton={this.renderAddButton}\n repeatRequest={repeatRequest}\n requestStatus={requestStatus}\n totalCount={totalCount}\n />\n </DropdownContainer>\n )}\n </span>\n </RenderLayer>\n </CommonWrapper>\n );\n }\n\n private getParent = () => {\n return getRootNode(this);\n };\n\n private renderAddButton = (): React.ReactNode => {\n return this.props.renderAddButton(this.props.textValue);\n };\n\n private renderInput(): React.ReactNode {\n const {\n align,\n borderless,\n disabled,\n editing,\n error,\n onFocus,\n onInputBlur,\n onInputValueChange,\n onInputFocus,\n onInputClick,\n onInputKeyDown,\n placeholder,\n renderValue,\n size,\n textValue,\n value,\n warning,\n refInputLikeText,\n leftIcon,\n inputMode,\n } = this.props;\n\n const rightIcon = this.getRightIcon();\n\n if (editing) {\n return (\n <Input\n align={align}\n borderless={borderless}\n disabled={disabled}\n error={error}\n maxLength={this.props.maxLength}\n onBlur={onInputBlur}\n onValueChange={onInputValueChange}\n onFocus={onInputFocus}\n onClick={onInputClick}\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n value={textValue || ''}\n onKeyDown={onInputKeyDown}\n placeholder={placeholder}\n width=\"100%\"\n size={size}\n ref={this.refInput}\n warning={warning}\n inputMode={inputMode}\n />\n );\n }\n\n return (\n <InputLikeText\n align={align}\n borderless={borderless}\n error={error}\n onFocus={onFocus}\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n disabled={disabled}\n warning={warning}\n placeholder={placeholder}\n size={size}\n width=\"100%\"\n ref={refInputLikeText}\n >\n {isNonNullable(value) && renderValue ? renderValue(value) : null}\n </InputLikeText>\n );\n }\n\n private handleItemSelect = (item: T) => {\n if (this.props.onValueChange) {\n this.props.onValueChange(item);\n }\n };\n\n private refInput = (input: Nullable<Input>) => {\n if (this.props.refInput) {\n this.props.refInput(input);\n }\n this.input = input;\n };\n\n private renderSpinner = () => (\n <span className={styles.spinnerWrapper()}>\n <Spinner type=\"mini\" caption=\"\" dimmed />\n </span>\n );\n\n private getRightIcon = () => {\n const { loading, items, drawArrow, rightIcon } = this.props;\n\n if (loading && items && !!items.length) {\n return this.renderSpinner();\n }\n\n if (rightIcon || drawArrow) {\n return <span className={styles.rightIconWrapper()}>{rightIcon ?? <ArrowChevronDownIcon />}</span>;\n }\n\n return null;\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.CustomComboBox = exports.DefaultState = exports.LOADER_SHOW_TIME = exports.DELAY_BEFORE_SHOW_LOADER = void 0;var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.CustomComboBox = exports.DefaultState = exports.LOADER_SHOW_TIME = exports.DELAY_BEFORE_SHOW_LOADER = void 0;var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
var _utils = require("../../lib/utils");
|
|
9
9
|
var _fixClickFocusIE = require("../../lib/events/fixClickFocusIE");
|
|
10
10
|
var _CommonWrapper = require("../../internal/CommonWrapper");
|
|
11
|
+
var _rootNode = require("../../lib/rootNode");
|
|
11
12
|
|
|
12
13
|
var _CustomComboBoxTypes = require("./CustomComboBoxTypes");
|
|
13
14
|
var _CustomComboBoxReducer = require("./CustomComboBoxReducer");
|
|
14
|
-
var _ComboBoxView = require("./ComboBoxView");
|
|
15
|
+
var _ComboBoxView = require("./ComboBoxView");var _class, _class2, _temp;
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
@@ -86,7 +87,8 @@ var DefaultState = {
|
|
|
86
87
|
requestStatus: _CustomComboBoxTypes.ComboBoxRequestStatus.Unknown };exports.DefaultState = DefaultState;var
|
|
87
88
|
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
|
|
91
|
+
CustomComboBox = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/function (_React$PureComponent) {(0, _inheritsLoose2.default)(CustomComboBox, _React$PureComponent);function CustomComboBox() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;_this.
|
|
90
92
|
|
|
91
93
|
|
|
92
94
|
state = DefaultState;_this.
|
|
@@ -138,6 +140,7 @@ CustomComboBox = /*#__PURE__*/function (_React$PureComponent) {(0, _inheritsLoos
|
|
|
138
140
|
|
|
139
141
|
_this.handleBlur();
|
|
140
142
|
};_this.
|
|
143
|
+
setRootNode = void 0;_this.
|
|
141
144
|
|
|
142
145
|
|
|
143
146
|
|
|
@@ -396,6 +399,6 @@ CustomComboBox = /*#__PURE__*/function (_React$PureComponent) {(0, _inheritsLoos
|
|
|
396
399
|
* @public
|
|
397
400
|
*/;_proto.open = function open() {this.dispatch({ type: 'Open' });} /**
|
|
398
401
|
* @public
|
|
399
|
-
*/;_proto.close = function close() {this.dispatch({ type: 'Close' });};_proto.render = function render() {var _this3 = this;var viewProps = { align: this.props.align, borderless: this.props.borderless, disabled: this.props.disabled, disablePortal: this.props.disablePortal, editing: this.state.editing, error: this.props.error, items: this.state.items, loading: this.state.loading, menuAlign: this.props.menuAlign, opened: this.state.opened, drawArrow: this.props.drawArrow, placeholder: this.props.placeholder, size: this.props.size, textValue: this.state.textValue, totalCount: this.props.totalCount, value: this.props.value, warning: this.props.warning, width: this.props.width, maxLength: this.props.maxLength, maxMenuHeight: this.props.maxMenuHeight, leftIcon: this.props.leftIcon, rightIcon: this.props.rightIcon, inputMode: this.props.inputMode, onValueChange: this.handleValueChange, onClickOutside: this.handleClickOutside, onFocus: this.handleFocus, onFocusOutside: this.handleBlur, onInputBlur: this.handleInputBlur, onInputValueChange: function onInputValueChange(value) {return _this3.dispatch({ type: 'TextChange', value: value });}, onInputFocus: this.handleFocus, onInputClick: this.handleInputClick, onInputKeyDown: function onInputKeyDown(event) {event.persist();_this3.dispatch({ type: 'KeyPress', event: event });}, onMouseEnter: this.props.onMouseEnter, onMouseOver: this.props.onMouseOver, onMouseLeave: this.props.onMouseLeave, renderItem: this.props.renderItem, renderNotFound: this.props.renderNotFound, renderValue: this.props.renderValue, renderTotalCount: this.props.renderTotalCount, renderAddButton: this.props.renderAddButton, repeatRequest: this.state.repeatRequest, requestStatus: this.state.requestStatus, refInput: function refInput(input) {_this3.input = input;}, refMenu: function refMenu(menu) {_this3.menu = menu;}, refInputLikeText: function refInputLikeText(inputLikeText) {_this3.inputLikeText = inputLikeText;} };return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, this.props, /*#__PURE__*/_react.default.createElement(_ComboBoxView.ComboBoxView, viewProps));};_proto.componentDidMount = function componentDidMount() {this.dispatch({ type: 'Mount' });if (this.props.autoFocus) {this.focus();}};_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {if (prevState.editing && !this.state.editing) {this.handleBlur();}this.dispatch({ type: 'DidUpdate', prevProps: prevProps, prevState: prevState });} /**
|
|
402
|
+
*/;_proto.close = function close() {this.dispatch({ type: 'Close' });};_proto.render = function render() {var _this3 = this;var viewProps = { align: this.props.align, borderless: this.props.borderless, disabled: this.props.disabled, disablePortal: this.props.disablePortal, editing: this.state.editing, error: this.props.error, items: this.state.items, loading: this.state.loading, menuAlign: this.props.menuAlign, opened: this.state.opened, drawArrow: this.props.drawArrow, placeholder: this.props.placeholder, size: this.props.size, textValue: this.state.textValue, totalCount: this.props.totalCount, value: this.props.value, warning: this.props.warning, width: this.props.width, maxLength: this.props.maxLength, maxMenuHeight: this.props.maxMenuHeight, leftIcon: this.props.leftIcon, rightIcon: this.props.rightIcon, inputMode: this.props.inputMode, onValueChange: this.handleValueChange, onClickOutside: this.handleClickOutside, onFocus: this.handleFocus, onFocusOutside: this.handleBlur, onInputBlur: this.handleInputBlur, onInputValueChange: function onInputValueChange(value) {return _this3.dispatch({ type: 'TextChange', value: value });}, onInputFocus: this.handleFocus, onInputClick: this.handleInputClick, onInputKeyDown: function onInputKeyDown(event) {event.persist();_this3.dispatch({ type: 'KeyPress', event: event });}, onMouseEnter: this.props.onMouseEnter, onMouseOver: this.props.onMouseOver, onMouseLeave: this.props.onMouseLeave, renderItem: this.props.renderItem, renderNotFound: this.props.renderNotFound, renderValue: this.props.renderValue, renderTotalCount: this.props.renderTotalCount, renderAddButton: this.props.renderAddButton, repeatRequest: this.state.repeatRequest, requestStatus: this.state.requestStatus, refInput: function refInput(input) {_this3.input = input;}, refMenu: function refMenu(menu) {_this3.menu = menu;}, refInputLikeText: function refInputLikeText(inputLikeText) {_this3.inputLikeText = inputLikeText;} };return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, this.props, /*#__PURE__*/_react.default.createElement(_ComboBoxView.ComboBoxView, (0, _extends2.default)({}, viewProps, { ref: this.setRootNode })));};_proto.componentDidMount = function componentDidMount() {this.dispatch({ type: 'Mount' });if (this.props.autoFocus) {this.focus();}};_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {if (prevState.editing && !this.state.editing) {this.handleBlur();}this.dispatch({ type: 'DidUpdate', prevProps: prevProps, prevState: prevState });} /**
|
|
400
403
|
* @public
|
|
401
|
-
*/;_proto.reset = function reset() {this.dispatch({ type: 'Reset' });};return CustomComboBox;}(_react.default.PureComponent)
|
|
404
|
+
*/;_proto.reset = function reset() {this.dispatch({ type: 'Reset' });};return CustomComboBox;}(_react.default.PureComponent), _class2.__KONTUR_REACT_UI__ = 'CustomComboBox', _temp)) || _class;exports.CustomComboBox = CustomComboBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CustomComboBox.tsx"],"names":["DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","ComboBoxRequestStatus","Unknown","CustomComboBox","state","input","menu","inputLikeText","requestId","loaderShowDelay","cancelationToken","reducer","cancelLoaderDelay","focus","props","disabled","selectInputText","selectAll","blur","handleBlur","dispatch","action","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","effect","getState","getProps","handleValueChange","value","type","keepFocus","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","search","query","getItems","cancelPromise","Promise","_","reject","expectingId","resolve","cancelLoader","catch","race","code","cancelSearch","CancelationError","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","placeholder","size","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","refInputLikeText","componentDidMount","autoFocus","componentDidUpdate","prevProps","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AhC,EAAd,EACD,C,CAED;AACF;AACA,K,QACSC,K,GAAP,iBAAe,CACb,KAAKpF,QAAL,CAAc,EAAEc,IAAI,EAAE,OAAR,EAAd,EACD,C,yBA/NoCuE,eAAMC,a,0CAAhCvG,c,CACGwG,mB,GAAsB,gB","sourcesContent":["import React from 'react';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T> extends CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<T[]>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<T[]>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n};\n\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n const expectingId = (this.requestId += 1);\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' });\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState });\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: true,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["CustomComboBox.tsx"],"names":["DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","ComboBoxRequestStatus","Unknown","CustomComboBox","rootNode","state","input","menu","inputLikeText","requestId","loaderShowDelay","cancelationToken","reducer","cancelLoaderDelay","focus","props","disabled","selectInputText","selectAll","blur","handleBlur","setRootNode","dispatch","action","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","effect","getState","getProps","handleValueChange","value","type","keepFocus","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","search","query","getItems","cancelPromise","Promise","_","reject","expectingId","resolve","cancelLoader","catch","race","code","cancelSearch","CancelationError","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","placeholder","size","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","refInputLikeText","componentDidMount","autoFocus","componentDidUpdate","prevProps","prevState","reset","React","PureComponent","__KONTUR_REACT_UI__"],"mappings":"osBAAA;;;;;;;AAOA;AACA;AACA;AACA;;AAEA;AACA;AACA,8C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DO,IAAMA,wBAAwB,GAAG,GAAjC,C;AACA,IAAMC,gBAAgB,GAAG,IAAzB,C;;AAEA,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,YAAY,EAAE,KADY;AAE1BC,EAAAA,OAAO,EAAE,KAFiB;AAG1BC,EAAAA,KAAK,EAAE,IAHmB;AAI1BC,EAAAA,OAAO,EAAE,KAJiB;AAK1BC,EAAAA,MAAM,EAAE,KALkB;AAM1BC,EAAAA,OAAO,EAAE,KANiB;AAO1BC,EAAAA,SAAS,EAAE,EAPe;AAQ1BC,EAAAA,aAAa,EAAE,iCAAMC,SAAN,EARW;AAS1BC,EAAAA,aAAa,EAAEC,2CAAsBC,OATX,EAArB,C;;;;AAaMC,c,OADZC,kB;;;AAIQC,IAAAA,K,GAAgCf,Y;AAChCgB,IAAAA,K;AACAC,IAAAA,I;AACAC,IAAAA,a;AACAC,IAAAA,S,GAAY,C;AACZC,IAAAA,e;AACCd,IAAAA,O,GAAU,K;AACVe,IAAAA,gB,GAAuD,I;;AAEvDC,IAAAA,O,GAAUA,8B;AACXC,IAAAA,iB,GA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,IADF,CADF,CAKD,C,QAEMgF,iB,GAAP,6BAA2B,CACzB,KAAK/E,QAAL,CAAc,EAAEc,IAAI,EAAE,OAAR,EAAd,EACA,IAAI,KAAKrB,KAAL,CAAWuF,SAAf,EAA0B,CACxB,KAAKxF,KAAL,GACD,CACF,C,QAEMyF,kB,GAAP,4BAA0BC,SAA1B,EAA6DC,SAA7D,EAAgG,CAC9F,IAAIA,SAAS,CAACjH,OAAV,IAAqB,CAAC,KAAKa,KAAL,CAAWb,OAArC,EAA8C,CAC5C,KAAK4B,UAAL,GACD,CACD,KAAKE,QAAL,CAAc,EAAEc,IAAI,EAAE,WAAR,EAAqBoE,SAAS,EAATA,SAArB,EAAgCC,SAAS,EAATA,SAAhC,EAAd,EACD,C,CAED;AACF;AACA,K,QACSC,K,GAAP,iBAAe,CACb,KAAKpF,QAAL,CAAc,EAAEc,IAAI,EAAE,OAAR,EAAd,EACD,C,yBAhOoCuE,eAAMC,a,WAC7BC,mB,GAAsB,gB","sourcesContent":["import React from 'react';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T> extends CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<T[]>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<T[]>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n};\n\n@rootNode\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n const expectingId = (this.requestId += 1);\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} ref={this.setRootNode} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' });\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState });\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: true,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export interface DateSelectState {
|
|
|
20
20
|
topCapped: boolean;
|
|
21
21
|
nodeTop: number;
|
|
22
22
|
}
|
|
23
|
-
export declare class DateSelect extends React.
|
|
23
|
+
export declare class DateSelect extends React.PureComponent<DateSelectProps, DateSelectState> {
|
|
24
24
|
static __KONTUR_REACT_UI__: string;
|
|
25
25
|
static propTypes: {
|
|
26
26
|
disabled: PropTypes.Requireable<boolean>;
|
|
@@ -57,7 +57,7 @@ export declare class DateSelect extends React.Component<DateSelectProps, DateSel
|
|
|
57
57
|
private setPositionRepeatTimer;
|
|
58
58
|
private yearStep;
|
|
59
59
|
private touchStartY;
|
|
60
|
-
|
|
60
|
+
componentDidUpdate(): void;
|
|
61
61
|
componentDidMount(): void;
|
|
62
62
|
componentWillUnmount(): void;
|
|
63
63
|
/**
|
|
@@ -45,7 +45,7 @@ var defaultMaxYear = 2100;var
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
DateSelect = (_dec = (0, _decorators.locale)('DatePicker', _locale.DatePickerLocaleHelper), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_React$
|
|
48
|
+
DateSelect = (_dec = (0, _decorators.locale)('DatePicker', _locale.DatePickerLocaleHelper), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_React$PureComponent) {(0, _inheritsLoose2.default)(DateSelect, _React$PureComponent);function DateSelect() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;_this.
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
|
|
@@ -443,7 +443,7 @@ DateSelect = (_dec = (0, _decorators.locale)('DatePicker', _locale.DatePickerLoc
|
|
|
443
443
|
handleDown = function (event) {
|
|
444
444
|
event.preventDefault();
|
|
445
445
|
_this.setPosition(_this.state.pos + itemHeight * _this.yearStep);
|
|
446
|
-
};return _this;}var _proto = DateSelect.prototype;_proto.
|
|
446
|
+
};return _this;}var _proto = DateSelect.prototype;_proto.componentDidUpdate = function componentDidUpdate() {this.setNodeTop();};_proto.componentDidMount = function componentDidMount() {this.listener = LayoutEvents.addListener(this.setNodeTop);this.setNodeTop();window.addEventListener('keydown', this.handleKey);};_proto.componentWillUnmount = function componentWillUnmount() {if (this.listener) {this.listener.remove();}if (this.timeout) {clearTimeout(this.timeout);}if (this.longClickTimer) {clearTimeout(this.longClickTimer);}if (this.setPositionRepeatTimer) {clearTimeout(this.setPositionRepeatTimer);}window.removeEventListener('keydown', this.handleKey);} /**
|
|
447
447
|
* @public
|
|
448
448
|
*/;_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return _this2.renderMain();});};_proto.renderMain = function renderMain() {var _cx, _cx2;var _this$props = this.props,width = _this$props.width,disabled = _this$props.disabled;var rootProps = { className: (0, _Emotion.cx)((_cx = {}, _cx[_DateSelect.styles.root(this.theme)] = true, _cx[_DateSelect.styles.disabled()] = Boolean(disabled), _cx)), style: { width: width }, ref: this.refRoot };return /*#__PURE__*/_react.default.createElement("span", rootProps, /*#__PURE__*/_react.default.createElement("div", { "data-tid": "DateSelect__caption", className: _DateSelect.styles.caption(), onClick: this.open }, this.getItem(0), /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)((_cx2 = {}, _cx2[_DateSelect.styles.arrow(this.theme)] = true, _cx2[_DateSelect.styles.arrowDisabled()] = Boolean(disabled), _cx2)) }, /*#__PURE__*/_react.default.createElement(_px.ArrowTriangleUpDownIcon, { size: 12 }))), this.state.opened && this.renderMenu());};_proto.disableItems = function disableItems(index) {var value = this.props.value + index;if (this.props.maxValue != null && this.props.minValue != null) {return value > this.props.maxValue || value < this.props.minValue;}if (this.props.minValue != null) {return value < this.props.minValue;}if (this.props.maxValue != null) {return value > this.props.maxValue;}};_proto.renderMenu = function renderMenu() {var _this3 = this,_cx3;var _this$state = this.state,top = _this$state.top,height = _this$state.height,nodeTop = _this$state.nodeTop;var shift = this.state.pos % itemHeight;if (shift < 0) {shift += itemHeight;}var from = (this.state.pos - shift + top) / itemHeight;var to = from + Math.ceil((height + shift) / itemHeight);var items = [];var _loop = function _loop(i) {var _cx4;var disableItems = _this3.disableItems(i) || false;var className = (0, _Emotion.cx)((_cx4 = {}, _cx4[_DateSelect.styles.menuItem(_this3.theme)] = true, _cx4[_DateSelect.styles.menuItemSelected(_this3.theme)] = i === 0, _cx4[_DateSelect.styles.menuItemActive(_this3.theme)] = i === _this3.state.current, _cx4[_DateSelect.styles.menuItemDisabled(_this3.theme)] = disableItems, _cx4));var clickHandler = { onMouseDown: preventDefault, onClick: _this3.handleItemClick(i) };items.push( /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({ "data-tid": "DateSelect__menuItem", "data-prop-disabled": disableItems, key: i, className: className, onMouseEnter: function onMouseEnter() {return _this3.setState({ current: i });}, onMouseLeave: function onMouseLeave() {return _this3.setState({ current: null });} }, clickHandler), _this3.getItem(i)));};for (var i = from; i < to; ++i) {_loop(i);}var style = { top: top - 5, left: 0, right: 0 };var shiftStyle = { position: 'relative', top: -shift };var holderClass = (0, _Emotion.cx)((_cx3 = {}, _cx3[_DateSelect.styles.menuHolder(this.theme)] = true, _cx3[_DateSelect.styles.isTopCapped()] = this.state.topCapped, _cx3[_DateSelect.styles.isBotCapped()] = this.state.botCapped, _cx3));var dropdownOffset = -itemHeight;if (nodeTop < -top) {var overflowOffsetDelta = this.state.topCapped ? 6 : 17;dropdownOffset -= nodeTop + top - overflowOffsetDelta;}return /*#__PURE__*/_react.default.createElement(_RenderLayer.RenderLayer, { onClickOutside: this.close, onFocusOutside: this.close, active: true }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_DropdownContainer.DropdownContainer, { getParent: this.getAnchor, offsetY: dropdownOffset, offsetX: -10 }, /*#__PURE__*/_react.default.createElement("div", { className: holderClass, style: style }, !this.state.topCapped && /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)(_DateSelect.styles.menu(this.theme), _DateSelect.styles.menuUp()), onClick: this.handleUp, onMouseDown: this.handleLongClickUp, onMouseUp: this.handleLongClickStop, onMouseLeave: this.handleLongClickStop, onTouchStart: this.handleLongClickUp, onTouchEnd: this.handleLongClickStop }, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_px.ArrowChevronUpIcon, null))), /*#__PURE__*/_react.default.createElement("div", { className: _DateSelect.styles.itemsHolder(), style: { height: height } }, /*#__PURE__*/_react.default.createElement("div", { ref: this.refItemsContainer, style: shiftStyle }, items)), !this.state.botCapped && /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)(_DateSelect.styles.menu(this.theme), _DateSelect.styles.menuDown()), onClick: this.handleDown, onMouseDown: this.handleLongClickDown, onMouseUp: this.handleLongClickStop, onMouseLeave: this.handleLongClickStop, onTouchStart: this.handleLongClickDown, onTouchEnd: this.handleLongClickStop }, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_px.ArrowChevronDownIcon, null)))))));};_proto.getItem = function getItem(index) {
|
|
449
449
|
var value = this.props.value + index;
|
|
@@ -491,7 +491,7 @@ DateSelect = (_dec = (0, _decorators.locale)('DatePicker', _locale.DatePickerLoc
|
|
|
491
491
|
return ((this.props.maxValue || defaultMaxYear) - this.props.value) * itemHeight;
|
|
492
492
|
}
|
|
493
493
|
return Infinity; // Be defensive.
|
|
494
|
-
};return DateSelect;}(_react.default.
|
|
494
|
+
};return DateSelect;}(_react.default.PureComponent), _class2.__KONTUR_REACT_UI__ = 'DateSelect', _class2.propTypes = { disabled: _propTypes.default.bool, type: _propTypes.default.string, value: _propTypes.default.number.isRequired, width: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), onValueChange: _propTypes.default.func, minValue: _propTypes.default.number, maxValue: _propTypes.default.number }, _class2.defaultProps = { type: 'year', minMonth: 0, maxMonth: 11, width: 'auto' }, _temp)) || _class);exports.DateSelect = DateSelect;
|
|
495
495
|
|
|
496
496
|
|
|
497
497
|
function preventDefault(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DateSelect.tsx"],"names":["itemHeight","visibleYearsCount","itemsToMoveCount","monthsCount","defaultMinYear","defaultMaxYear","DateSelect","DatePickerLocaleHelper","state","botCapped","current","height","opened","pos","top","topCapped","nodeTop","Infinity","theme","locale","root","itemsContainer","listener","timeout","longClickTimer","setPositionRepeatTimer","yearStep","touchStartY","open","props","disabled","setPosition","setState","close","refRoot","element","setNodeTop","clearTimeout","setTimeout","getBoundingClientRect","refItemsContainer","addEventListener","handleWheel","passive","removeEventListener","isMobile","handleTouchStart","handleTouchMove","handleLongClickUp","event","preventDefault","window","setInterval","handleLongClickDown","handleLongClickStop","getAnchor","WheelEvent","stopPropagation","deltaY","deltaMode","TouchEvent","targetTouches","clientY","changedTouches","pixelRatio","devicePixelRatio","handleItemClick","shift","e","value","onValueChange","handleKey","handleUp","handleDown","UNSAFE_componentWillReceiveProps","componentDidMount","LayoutEvents","addListener","componentWillUnmount","remove","render","renderMain","width","rootProps","className","styles","Boolean","style","ref","caption","getItem","arrow","arrowDisabled","renderMenu","disableItems","index","maxValue","minValue","from","to","Math","ceil","items","i","menuItem","menuItemSelected","menuItemActive","menuItemDisabled","clickHandler","onMouseDown","onClick","push","left","right","shiftStyle","position","holderClass","menuHolder","isTopCapped","isBotCapped","dropdownOffset","overflowOffsetDelta","menu","menuUp","itemsHolder","menuDown","type","months","minPos","getMinPos","maxPos","getMaxPos","React","Component","__KONTUR_REACT_UI__","propTypes","PropTypes","bool","string","number","isRequired","oneOfType","func","defaultProps","minMonth","maxMonth"],"mappings":"+ZAAA;AACA;;AAEA;AACA;AACA;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,KAAK6B,KAAL,CAAWiG,IAAX,KAAoB,MAAxB,EAAgC;AACrC,aAAO,CAAC,CAAC,KAAKjG,KAAL,CAAWmE,QAAX,IAAuB3F,cAAxB,IAA0C,KAAKwB,KAAL,CAAWwC,KAAtD,IAA+DrE,UAAtE;AACD;AACD,WAAOiB,QAAP,CANkB,CAMD;AAClB,G,qBA9b6BmH,eAAMC,S,WACtBC,mB,GAAsB,Y,UAEtBC,S,GAAY,EACxBzG,QAAQ,EAAE0G,mBAAUC,IADI,EAGxBX,IAAI,EAAEU,mBAAUE,MAHQ,EAKxBrE,KAAK,EAAEmE,mBAAUG,MAAV,CAAiBC,UALA,EAOxB1D,KAAK,EAAEsD,mBAAUK,SAAV,CAAoB,CAACL,mBAAUG,MAAX,EAAmBH,mBAAUE,MAA7B,CAApB,CAPiB,EASxBpE,aAAa,EAAEkE,mBAAUM,IATD,EAWxB7C,QAAQ,EAAEuC,mBAAUG,MAXI,EAaxB3C,QAAQ,EAAEwC,mBAAUG,MAbI,E,UAgBZI,Y,GAAe,EAC3BjB,IAAI,EAAE,MADqB,EAE3BkB,QAAQ,EAAE,CAFiB,EAG3BC,QAAQ,EAAE,EAHiB,EAI3B/D,KAAK,EAAE,MAJoB,E;;;AA8a/B,SAAShC,cAAT,CAAwBkB,CAAxB,EAAiD;AAC/CA,EAAAA,CAAC,CAAClB,cAAF;AACD","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { isKeyEscape } from '../../lib/events/keyboard/identifiers';\nimport { DatePickerLocale, DatePickerLocaleHelper } from '../../components/DatePicker/locale';\nimport { locale } from '../../lib/locale/decorators';\nimport { RenderLayer } from '../RenderLayer';\nimport { DropdownContainer } from '../DropdownContainer';\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { Nullable } from '../../typings/utility-types';\nimport { Theme } from '../../lib/theming/Theme';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { ArrowTriangleUpDownIcon, ArrowChevronDownIcon, ArrowChevronUpIcon } from '../icons/16px';\nimport { isMobile } from '../../lib/client';\nimport { cx } from '../../lib/theming/Emotion';\n\nimport { styles } from './DateSelect.styles';\n\nconst itemHeight = 24;\nconst visibleYearsCount = 11;\nconst itemsToMoveCount = -5;\nconst monthsCount = 12;\nconst defaultMinYear = 1900;\nconst defaultMaxYear = 2100;\n\nexport interface DateSelectProps {\n disabled?: boolean | null;\n onValueChange: (value: number) => void;\n type?: 'month' | 'year';\n value: number;\n width?: number | string;\n minValue?: number;\n maxValue?: number;\n}\n\nexport interface DateSelectState {\n botCapped: boolean;\n current: Nullable<number>;\n height: number;\n opened: boolean;\n pos: number;\n top: number;\n topCapped: boolean;\n nodeTop: number;\n}\n\n@locale('DatePicker', DatePickerLocaleHelper)\nexport class DateSelect extends React.Component<DateSelectProps, DateSelectState> {\n public static __KONTUR_REACT_UI__ = 'DateSelect';\n\n public static propTypes = {\n disabled: PropTypes.bool,\n\n type: PropTypes.string,\n\n value: PropTypes.number.isRequired,\n\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\n onValueChange: PropTypes.func,\n\n minValue: PropTypes.number,\n\n maxValue: PropTypes.number,\n };\n\n public static defaultProps = {\n type: 'year',\n minMonth: 0,\n maxMonth: 11,\n width: 'auto',\n };\n\n public state = {\n botCapped: false,\n current: 0,\n height: 0,\n opened: false,\n pos: 0,\n top: 0,\n topCapped: false,\n nodeTop: Infinity,\n };\n\n private theme!: Theme;\n private readonly locale!: DatePickerLocale;\n private root: HTMLElement | null = null;\n private itemsContainer: HTMLElement | null = null;\n private listener: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n private timeout: NodeJS.Timeout | undefined;\n private longClickTimer = 0;\n private setPositionRepeatTimer = 0;\n private yearStep = 3;\n private touchStartY: Nullable<number> = null;\n\n public UNSAFE_componentWillReceiveProps() {\n this.setNodeTop();\n }\n\n public componentDidMount() {\n this.listener = LayoutEvents.addListener(this.setNodeTop);\n this.setNodeTop();\n window.addEventListener('keydown', this.handleKey);\n }\n\n public componentWillUnmount() {\n if (this.listener) {\n this.listener.remove();\n }\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n if (this.longClickTimer) {\n clearTimeout(this.longClickTimer);\n }\n if (this.setPositionRepeatTimer) {\n clearTimeout(this.setPositionRepeatTimer);\n }\n window.removeEventListener('keydown', this.handleKey);\n }\n\n /**\n * @public\n */\n public open = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.state.opened) {\n return;\n }\n\n this.setPosition(0);\n this.setState({\n opened: true,\n current: 0,\n });\n };\n\n /**\n * @public\n */\n public close = () => {\n if (!this.state.opened) {\n return;\n }\n\n this.setState({ opened: false });\n };\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderMain() {\n const { width, disabled } = this.props;\n const rootProps = {\n className: cx({\n [styles.root(this.theme)]: true,\n [styles.disabled()]: Boolean(disabled),\n }),\n style: { width },\n ref: this.refRoot,\n };\n return (\n <span {...rootProps}>\n <div data-tid=\"DateSelect__caption\" className={styles.caption()} onClick={this.open}>\n {this.getItem(0)}\n <div\n className={cx({\n [styles.arrow(this.theme)]: true,\n [styles.arrowDisabled()]: Boolean(disabled),\n })}\n >\n <ArrowTriangleUpDownIcon size={12} />\n </div>\n </div>\n {this.state.opened && this.renderMenu()}\n </span>\n );\n }\n\n private refRoot = (element: HTMLElement | null) => {\n this.root = element;\n };\n\n private setNodeTop = () => {\n const root = this.root;\n if (!root) {\n return;\n }\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = setTimeout(() =>\n this.setState({\n nodeTop: root.getBoundingClientRect().top,\n }),\n );\n };\n\n private disableItems(index: number) {\n const value = this.props.value + index;\n if (this.props.maxValue != null && this.props.minValue != null) {\n return value > this.props.maxValue || value < this.props.minValue;\n }\n if (this.props.minValue != null) {\n return value < this.props.minValue;\n }\n if (this.props.maxValue != null) {\n return value > this.props.maxValue;\n }\n }\n\n private renderMenu(): React.ReactNode {\n const { top, height, nodeTop } = this.state;\n\n let shift = this.state.pos % itemHeight;\n if (shift < 0) {\n shift += itemHeight;\n }\n\n const from = (this.state.pos - shift + top) / itemHeight;\n const to = from + Math.ceil((height + shift) / itemHeight);\n const items = [];\n\n for (let i = from; i < to; ++i) {\n const disableItems = this.disableItems(i) || false;\n const className = cx({\n [styles.menuItem(this.theme)]: true,\n [styles.menuItemSelected(this.theme)]: i === 0,\n [styles.menuItemActive(this.theme)]: i === this.state.current,\n [styles.menuItemDisabled(this.theme)]: disableItems,\n });\n const clickHandler = {\n onMouseDown: preventDefault,\n onClick: this.handleItemClick(i),\n };\n items.push(\n <div\n data-tid=\"DateSelect__menuItem\"\n data-prop-disabled={disableItems}\n key={i}\n className={className}\n onMouseEnter={() => this.setState({ current: i })}\n onMouseLeave={() => this.setState({ current: null })}\n {...clickHandler}\n >\n {this.getItem(i)}\n </div>,\n );\n }\n const style: {\n left?: number | string;\n right?: number | string;\n top: number;\n width?: number | string;\n } = {\n top: top - 5,\n left: 0,\n right: 0,\n };\n\n const shiftStyle: React.CSSProperties = {\n position: 'relative',\n top: -shift,\n };\n\n const holderClass = cx({\n [styles.menuHolder(this.theme)]: true,\n [styles.isTopCapped()]: this.state.topCapped,\n [styles.isBotCapped()]: this.state.botCapped,\n });\n\n let dropdownOffset = -itemHeight;\n if (nodeTop < -top) {\n const overflowOffsetDelta = this.state.topCapped ? 6 : 17;\n dropdownOffset -= nodeTop + top - overflowOffsetDelta;\n }\n\n return (\n <RenderLayer onClickOutside={this.close} onFocusOutside={this.close} active>\n <div>\n <DropdownContainer getParent={this.getAnchor} offsetY={dropdownOffset} offsetX={-10}>\n <div className={holderClass} style={style}>\n {!this.state.topCapped && (\n <div\n className={cx(styles.menu(this.theme), styles.menuUp())}\n onClick={this.handleUp}\n onMouseDown={this.handleLongClickUp}\n onMouseUp={this.handleLongClickStop}\n onMouseLeave={this.handleLongClickStop}\n onTouchStart={this.handleLongClickUp}\n onTouchEnd={this.handleLongClickStop}\n >\n <span>\n <ArrowChevronUpIcon />\n </span>\n </div>\n )}\n <div className={styles.itemsHolder()} style={{ height }}>\n <div ref={this.refItemsContainer} style={shiftStyle}>\n {items}\n </div>\n </div>\n {!this.state.botCapped && (\n <div\n className={cx(styles.menu(this.theme), styles.menuDown())}\n onClick={this.handleDown}\n onMouseDown={this.handleLongClickDown}\n onMouseUp={this.handleLongClickStop}\n onMouseLeave={this.handleLongClickStop}\n onTouchStart={this.handleLongClickDown}\n onTouchEnd={this.handleLongClickStop}\n >\n <span>\n <ArrowChevronDownIcon />\n </span>\n </div>\n )}\n </div>\n </DropdownContainer>\n </div>\n </RenderLayer>\n );\n }\n\n private refItemsContainer = (element: HTMLElement | null) => {\n if (!this.itemsContainer && element) {\n element.addEventListener('wheel', this.handleWheel, { passive: false });\n }\n if (this.itemsContainer && !element) {\n this.itemsContainer.removeEventListener('wheel', this.handleWheel);\n }\n\n if (isMobile) {\n if (!this.itemsContainer && element) {\n element.addEventListener('touchstart', this.handleTouchStart);\n element.addEventListener('touchmove', this.handleTouchMove);\n }\n if (this.itemsContainer && !element) {\n this.itemsContainer.removeEventListener('touchstart', this.handleTouchStart);\n this.itemsContainer.removeEventListener('touchmove', this.handleTouchMove);\n }\n }\n\n this.itemsContainer = element;\n };\n\n private handleLongClickUp = (event: React.MouseEvent | React.TouchEvent) => {\n event.preventDefault();\n this.longClickTimer = window.setTimeout(() => {\n this.setPositionRepeatTimer = window.setInterval(() => this.setPosition(this.state.pos - itemHeight), 100);\n }, 200);\n };\n\n private handleLongClickDown = (event: React.MouseEvent | React.TouchEvent) => {\n event.preventDefault();\n this.longClickTimer = window.setTimeout(() => {\n this.setPositionRepeatTimer = window.setInterval(() => this.setPosition(this.state.pos + itemHeight), 100);\n }, 200);\n };\n\n private handleLongClickStop = () => {\n clearTimeout(this.longClickTimer);\n clearTimeout(this.setPositionRepeatTimer);\n };\n\n private getAnchor = () => this.root;\n\n private handleWheel = (event: Event) => {\n if (!(event instanceof WheelEvent)) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n\n let deltaY = event.deltaY;\n if (event.deltaMode === 1) {\n deltaY *= itemHeight;\n } else if (event.deltaMode === 2) {\n deltaY *= itemHeight * 4;\n }\n const pos = this.state.pos + deltaY;\n this.setPosition(pos);\n };\n\n private handleTouchStart = (event: Event) => {\n if (!(event instanceof TouchEvent)) {\n return;\n }\n\n this.touchStartY = event.targetTouches[0].clientY;\n };\n\n private handleTouchMove = (event: Event) => {\n if (!(event instanceof TouchEvent)) {\n return;\n }\n\n const { clientY } = event.changedTouches[0];\n const pixelRatio = window.devicePixelRatio;\n\n const deltaY = ((this.touchStartY || 0) - clientY) / pixelRatio;\n const pos = this.state.pos + deltaY + deltaY / itemHeight;\n\n this.touchStartY = clientY;\n\n this.setPosition(pos);\n };\n\n private handleItemClick = (shift: number) => {\n return (e: React.MouseEvent<HTMLElement>) => {\n const value = this.props.value + shift;\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n this.setState({ opened: false });\n };\n };\n\n private handleKey = (e: KeyboardEvent) => {\n if (this.state.opened && isKeyEscape(e)) {\n e.preventDefault();\n this.close();\n e.stopPropagation();\n }\n };\n\n private handleUp = (event: React.MouseEvent) => {\n event.preventDefault();\n this.setPosition(this.state.pos - itemHeight * this.yearStep);\n };\n\n private handleDown = (event: React.MouseEvent) => {\n event.preventDefault();\n this.setPosition(this.state.pos + itemHeight * this.yearStep);\n };\n\n private getItem(index: number) {\n const value = this.props.value + index;\n if (this.props.type === 'month') {\n return this.locale.months[value];\n }\n return value;\n }\n\n private setPosition(pos: number) {\n let top = itemsToMoveCount * itemHeight;\n let height = visibleYearsCount * itemHeight;\n if (this.props.type === 'month') {\n top = -this.props.value * itemHeight;\n height = monthsCount * itemHeight;\n }\n\n const minPos = this.getMinPos() - top;\n const maxPos = this.getMaxPos() - top - height + itemHeight;\n if (minPos >= pos) {\n pos = minPos;\n }\n if (maxPos <= pos) {\n pos = maxPos;\n }\n const topCapped = pos <= minPos;\n const botCapped = pos >= maxPos;\n\n this.setState({ pos, top, height, topCapped, botCapped });\n }\n\n private getMinPos() {\n if (this.props.type === 'month') {\n return -this.props.value * itemHeight;\n } else if (this.props.type === 'year') {\n return ((this.props.minValue || defaultMinYear) - this.props.value) * itemHeight;\n }\n return -Infinity; // Be defensive.\n }\n\n private getMaxPos() {\n if (this.props.type === 'month') {\n return (visibleYearsCount - this.props.value) * itemHeight;\n } else if (this.props.type === 'year') {\n return ((this.props.maxValue || defaultMaxYear) - this.props.value) * itemHeight;\n }\n return Infinity; // Be defensive.\n }\n}\n\nfunction preventDefault(e: React.SyntheticEvent) {\n e.preventDefault();\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DateSelect.tsx"],"names":["itemHeight","visibleYearsCount","itemsToMoveCount","monthsCount","defaultMinYear","defaultMaxYear","DateSelect","DatePickerLocaleHelper","state","botCapped","current","height","opened","pos","top","topCapped","nodeTop","Infinity","theme","locale","root","itemsContainer","listener","timeout","longClickTimer","setPositionRepeatTimer","yearStep","touchStartY","open","props","disabled","setPosition","setState","close","refRoot","element","setNodeTop","clearTimeout","setTimeout","getBoundingClientRect","refItemsContainer","addEventListener","handleWheel","passive","removeEventListener","isMobile","handleTouchStart","handleTouchMove","handleLongClickUp","event","preventDefault","window","setInterval","handleLongClickDown","handleLongClickStop","getAnchor","WheelEvent","stopPropagation","deltaY","deltaMode","TouchEvent","targetTouches","clientY","changedTouches","pixelRatio","devicePixelRatio","handleItemClick","shift","e","value","onValueChange","handleKey","handleUp","handleDown","componentDidUpdate","componentDidMount","LayoutEvents","addListener","componentWillUnmount","remove","render","renderMain","width","rootProps","className","styles","Boolean","style","ref","caption","getItem","arrow","arrowDisabled","renderMenu","disableItems","index","maxValue","minValue","from","to","Math","ceil","items","i","menuItem","menuItemSelected","menuItemActive","menuItemDisabled","clickHandler","onMouseDown","onClick","push","left","right","shiftStyle","position","holderClass","menuHolder","isTopCapped","isBotCapped","dropdownOffset","overflowOffsetDelta","menu","menuUp","itemsHolder","menuDown","type","months","minPos","getMinPos","maxPos","getMaxPos","React","PureComponent","__KONTUR_REACT_UI__","propTypes","PropTypes","bool","string","number","isRequired","oneOfType","func","defaultProps","minMonth","maxMonth"],"mappings":"+ZAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA,iD;;AAEA,IAAMA,UAAU,GAAG,EAAnB;AACA,IAAMC,iBAAiB,GAAG,EAA1B;AACA,IAAMC,gBAAgB,GAAG,CAAC,CAA1B;AACA,IAAMC,WAAW,GAAG,EAApB;AACA,IAAMC,cAAc,GAAG,IAAvB;AACA,IAAMC,cAAc,GAAG,IAAvB,C;;;;;;;;;;;;;;;;;;;;;;;;AAwBaC,U,WADZ,wBAAO,YAAP,EAAqBC,8BAArB,C;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BQC,IAAAA,K,GAAQ;AACbC,MAAAA,SAAS,EAAE,KADE;AAEbC,MAAAA,OAAO,EAAE,CAFI;AAGbC,MAAAA,MAAM,EAAE,CAHK;AAIbC,MAAAA,MAAM,EAAE,KAJK;AAKbC,MAAAA,GAAG,EAAE,CALQ;AAMbC,MAAAA,GAAG,EAAE,CANQ;AAObC,MAAAA,SAAS,EAAE,KAPE;AAQbC,MAAAA,OAAO,EAAEC,QARI,E;;;AAWPC,IAAAA,K;AACSC,IAAAA,M;AACTC,IAAAA,I,GAA2B,I;AAC3BC,IAAAA,c,GAAqC,I;AACrCC,IAAAA,Q;AACAC,IAAAA,O;AACAC,IAAAA,c,GAAiB,C;AACjBC,IAAAA,sB,GAAyB,C;AACzBC,IAAAA,Q,GAAW,C;AACXC,IAAAA,W,GAAgC,I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BjCC,IAAAA,I,GAAO,YAAM;AAClB,UAAI,MAAKC,KAAL,CAAWC,QAAf,EAAyB;AACvB;AACD;;AAED,UAAI,MAAKtB,KAAL,CAAWI,MAAf,EAAuB;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OkH,EAAAA,S,GAAR,qBAAoB;AAClB,QAAI,KAAKtG,KAAL,CAAWiG,IAAX,KAAoB,OAAxB,EAAiC;AAC/B,aAAO,CAAC7H,iBAAiB,GAAG,KAAK4B,KAAL,CAAWwC,KAAhC,IAAyCrE,UAAhD;AACD,KAFD,MAEO,IAAI,KAAK6B,KAAL,CAAWiG,IAAX,KAAoB,MAAxB,EAAgC;AACrC,aAAO,CAAC,CAAC,KAAKjG,KAAL,CAAWmE,QAAX,IAAuB3F,cAAxB,IAA0C,KAAKwB,KAAL,CAAWwC,KAAtD,IAA+DrE,UAAtE;AACD;AACD,WAAOiB,QAAP,CANkB,CAMD;AAClB,G,qBA9b6BmH,eAAMC,a,WACtBC,mB,GAAsB,Y,UAEtBC,S,GAAY,EACxBzG,QAAQ,EAAE0G,mBAAUC,IADI,EAGxBX,IAAI,EAAEU,mBAAUE,MAHQ,EAKxBrE,KAAK,EAAEmE,mBAAUG,MAAV,CAAiBC,UALA,EAOxB1D,KAAK,EAAEsD,mBAAUK,SAAV,CAAoB,CAACL,mBAAUG,MAAX,EAAmBH,mBAAUE,MAA7B,CAApB,CAPiB,EASxBpE,aAAa,EAAEkE,mBAAUM,IATD,EAWxB7C,QAAQ,EAAEuC,mBAAUG,MAXI,EAaxB3C,QAAQ,EAAEwC,mBAAUG,MAbI,E,UAgBZI,Y,GAAe,EAC3BjB,IAAI,EAAE,MADqB,EAE3BkB,QAAQ,EAAE,CAFiB,EAG3BC,QAAQ,EAAE,EAHiB,EAI3B/D,KAAK,EAAE,MAJoB,E;;;AA8a/B,SAAShC,cAAT,CAAwBkB,CAAxB,EAAiD;AAC/CA,EAAAA,CAAC,CAAClB,cAAF;AACD","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { isKeyEscape } from '../../lib/events/keyboard/identifiers';\nimport { DatePickerLocale, DatePickerLocaleHelper } from '../../components/DatePicker/locale';\nimport { locale } from '../../lib/locale/decorators';\nimport { RenderLayer } from '../RenderLayer';\nimport { DropdownContainer } from '../DropdownContainer';\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { Nullable } from '../../typings/utility-types';\nimport { Theme } from '../../lib/theming/Theme';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { ArrowTriangleUpDownIcon, ArrowChevronDownIcon, ArrowChevronUpIcon } from '../icons/16px';\nimport { isMobile } from '../../lib/client';\nimport { cx } from '../../lib/theming/Emotion';\n\nimport { styles } from './DateSelect.styles';\n\nconst itemHeight = 24;\nconst visibleYearsCount = 11;\nconst itemsToMoveCount = -5;\nconst monthsCount = 12;\nconst defaultMinYear = 1900;\nconst defaultMaxYear = 2100;\n\nexport interface DateSelectProps {\n disabled?: boolean | null;\n onValueChange: (value: number) => void;\n type?: 'month' | 'year';\n value: number;\n width?: number | string;\n minValue?: number;\n maxValue?: number;\n}\n\nexport interface DateSelectState {\n botCapped: boolean;\n current: Nullable<number>;\n height: number;\n opened: boolean;\n pos: number;\n top: number;\n topCapped: boolean;\n nodeTop: number;\n}\n\n@locale('DatePicker', DatePickerLocaleHelper)\nexport class DateSelect extends React.PureComponent<DateSelectProps, DateSelectState> {\n public static __KONTUR_REACT_UI__ = 'DateSelect';\n\n public static propTypes = {\n disabled: PropTypes.bool,\n\n type: PropTypes.string,\n\n value: PropTypes.number.isRequired,\n\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\n onValueChange: PropTypes.func,\n\n minValue: PropTypes.number,\n\n maxValue: PropTypes.number,\n };\n\n public static defaultProps = {\n type: 'year',\n minMonth: 0,\n maxMonth: 11,\n width: 'auto',\n };\n\n public state = {\n botCapped: false,\n current: 0,\n height: 0,\n opened: false,\n pos: 0,\n top: 0,\n topCapped: false,\n nodeTop: Infinity,\n };\n\n private theme!: Theme;\n private readonly locale!: DatePickerLocale;\n private root: HTMLElement | null = null;\n private itemsContainer: HTMLElement | null = null;\n private listener: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n private timeout: NodeJS.Timeout | undefined;\n private longClickTimer = 0;\n private setPositionRepeatTimer = 0;\n private yearStep = 3;\n private touchStartY: Nullable<number> = null;\n\n public componentDidUpdate() {\n this.setNodeTop();\n }\n\n public componentDidMount() {\n this.listener = LayoutEvents.addListener(this.setNodeTop);\n this.setNodeTop();\n window.addEventListener('keydown', this.handleKey);\n }\n\n public componentWillUnmount() {\n if (this.listener) {\n this.listener.remove();\n }\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n if (this.longClickTimer) {\n clearTimeout(this.longClickTimer);\n }\n if (this.setPositionRepeatTimer) {\n clearTimeout(this.setPositionRepeatTimer);\n }\n window.removeEventListener('keydown', this.handleKey);\n }\n\n /**\n * @public\n */\n public open = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.state.opened) {\n return;\n }\n\n this.setPosition(0);\n this.setState({\n opened: true,\n current: 0,\n });\n };\n\n /**\n * @public\n */\n public close = () => {\n if (!this.state.opened) {\n return;\n }\n\n this.setState({ opened: false });\n };\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderMain() {\n const { width, disabled } = this.props;\n const rootProps = {\n className: cx({\n [styles.root(this.theme)]: true,\n [styles.disabled()]: Boolean(disabled),\n }),\n style: { width },\n ref: this.refRoot,\n };\n return (\n <span {...rootProps}>\n <div data-tid=\"DateSelect__caption\" className={styles.caption()} onClick={this.open}>\n {this.getItem(0)}\n <div\n className={cx({\n [styles.arrow(this.theme)]: true,\n [styles.arrowDisabled()]: Boolean(disabled),\n })}\n >\n <ArrowTriangleUpDownIcon size={12} />\n </div>\n </div>\n {this.state.opened && this.renderMenu()}\n </span>\n );\n }\n\n private refRoot = (element: HTMLElement | null) => {\n this.root = element;\n };\n\n private setNodeTop = () => {\n const root = this.root;\n if (!root) {\n return;\n }\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = setTimeout(() =>\n this.setState({\n nodeTop: root.getBoundingClientRect().top,\n }),\n );\n };\n\n private disableItems(index: number) {\n const value = this.props.value + index;\n if (this.props.maxValue != null && this.props.minValue != null) {\n return value > this.props.maxValue || value < this.props.minValue;\n }\n if (this.props.minValue != null) {\n return value < this.props.minValue;\n }\n if (this.props.maxValue != null) {\n return value > this.props.maxValue;\n }\n }\n\n private renderMenu(): React.ReactNode {\n const { top, height, nodeTop } = this.state;\n\n let shift = this.state.pos % itemHeight;\n if (shift < 0) {\n shift += itemHeight;\n }\n\n const from = (this.state.pos - shift + top) / itemHeight;\n const to = from + Math.ceil((height + shift) / itemHeight);\n const items = [];\n\n for (let i = from; i < to; ++i) {\n const disableItems = this.disableItems(i) || false;\n const className = cx({\n [styles.menuItem(this.theme)]: true,\n [styles.menuItemSelected(this.theme)]: i === 0,\n [styles.menuItemActive(this.theme)]: i === this.state.current,\n [styles.menuItemDisabled(this.theme)]: disableItems,\n });\n const clickHandler = {\n onMouseDown: preventDefault,\n onClick: this.handleItemClick(i),\n };\n items.push(\n <div\n data-tid=\"DateSelect__menuItem\"\n data-prop-disabled={disableItems}\n key={i}\n className={className}\n onMouseEnter={() => this.setState({ current: i })}\n onMouseLeave={() => this.setState({ current: null })}\n {...clickHandler}\n >\n {this.getItem(i)}\n </div>,\n );\n }\n const style: {\n left?: number | string;\n right?: number | string;\n top: number;\n width?: number | string;\n } = {\n top: top - 5,\n left: 0,\n right: 0,\n };\n\n const shiftStyle: React.CSSProperties = {\n position: 'relative',\n top: -shift,\n };\n\n const holderClass = cx({\n [styles.menuHolder(this.theme)]: true,\n [styles.isTopCapped()]: this.state.topCapped,\n [styles.isBotCapped()]: this.state.botCapped,\n });\n\n let dropdownOffset = -itemHeight;\n if (nodeTop < -top) {\n const overflowOffsetDelta = this.state.topCapped ? 6 : 17;\n dropdownOffset -= nodeTop + top - overflowOffsetDelta;\n }\n\n return (\n <RenderLayer onClickOutside={this.close} onFocusOutside={this.close} active>\n <div>\n <DropdownContainer getParent={this.getAnchor} offsetY={dropdownOffset} offsetX={-10}>\n <div className={holderClass} style={style}>\n {!this.state.topCapped && (\n <div\n className={cx(styles.menu(this.theme), styles.menuUp())}\n onClick={this.handleUp}\n onMouseDown={this.handleLongClickUp}\n onMouseUp={this.handleLongClickStop}\n onMouseLeave={this.handleLongClickStop}\n onTouchStart={this.handleLongClickUp}\n onTouchEnd={this.handleLongClickStop}\n >\n <span>\n <ArrowChevronUpIcon />\n </span>\n </div>\n )}\n <div className={styles.itemsHolder()} style={{ height }}>\n <div ref={this.refItemsContainer} style={shiftStyle}>\n {items}\n </div>\n </div>\n {!this.state.botCapped && (\n <div\n className={cx(styles.menu(this.theme), styles.menuDown())}\n onClick={this.handleDown}\n onMouseDown={this.handleLongClickDown}\n onMouseUp={this.handleLongClickStop}\n onMouseLeave={this.handleLongClickStop}\n onTouchStart={this.handleLongClickDown}\n onTouchEnd={this.handleLongClickStop}\n >\n <span>\n <ArrowChevronDownIcon />\n </span>\n </div>\n )}\n </div>\n </DropdownContainer>\n </div>\n </RenderLayer>\n );\n }\n\n private refItemsContainer = (element: HTMLElement | null) => {\n if (!this.itemsContainer && element) {\n element.addEventListener('wheel', this.handleWheel, { passive: false });\n }\n if (this.itemsContainer && !element) {\n this.itemsContainer.removeEventListener('wheel', this.handleWheel);\n }\n\n if (isMobile) {\n if (!this.itemsContainer && element) {\n element.addEventListener('touchstart', this.handleTouchStart);\n element.addEventListener('touchmove', this.handleTouchMove);\n }\n if (this.itemsContainer && !element) {\n this.itemsContainer.removeEventListener('touchstart', this.handleTouchStart);\n this.itemsContainer.removeEventListener('touchmove', this.handleTouchMove);\n }\n }\n\n this.itemsContainer = element;\n };\n\n private handleLongClickUp = (event: React.MouseEvent | React.TouchEvent) => {\n event.preventDefault();\n this.longClickTimer = window.setTimeout(() => {\n this.setPositionRepeatTimer = window.setInterval(() => this.setPosition(this.state.pos - itemHeight), 100);\n }, 200);\n };\n\n private handleLongClickDown = (event: React.MouseEvent | React.TouchEvent) => {\n event.preventDefault();\n this.longClickTimer = window.setTimeout(() => {\n this.setPositionRepeatTimer = window.setInterval(() => this.setPosition(this.state.pos + itemHeight), 100);\n }, 200);\n };\n\n private handleLongClickStop = () => {\n clearTimeout(this.longClickTimer);\n clearTimeout(this.setPositionRepeatTimer);\n };\n\n private getAnchor = () => this.root;\n\n private handleWheel = (event: Event) => {\n if (!(event instanceof WheelEvent)) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n\n let deltaY = event.deltaY;\n if (event.deltaMode === 1) {\n deltaY *= itemHeight;\n } else if (event.deltaMode === 2) {\n deltaY *= itemHeight * 4;\n }\n const pos = this.state.pos + deltaY;\n this.setPosition(pos);\n };\n\n private handleTouchStart = (event: Event) => {\n if (!(event instanceof TouchEvent)) {\n return;\n }\n\n this.touchStartY = event.targetTouches[0].clientY;\n };\n\n private handleTouchMove = (event: Event) => {\n if (!(event instanceof TouchEvent)) {\n return;\n }\n\n const { clientY } = event.changedTouches[0];\n const pixelRatio = window.devicePixelRatio;\n\n const deltaY = ((this.touchStartY || 0) - clientY) / pixelRatio;\n const pos = this.state.pos + deltaY + deltaY / itemHeight;\n\n this.touchStartY = clientY;\n\n this.setPosition(pos);\n };\n\n private handleItemClick = (shift: number) => {\n return (e: React.MouseEvent<HTMLElement>) => {\n const value = this.props.value + shift;\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n this.setState({ opened: false });\n };\n };\n\n private handleKey = (e: KeyboardEvent) => {\n if (this.state.opened && isKeyEscape(e)) {\n e.preventDefault();\n this.close();\n e.stopPropagation();\n }\n };\n\n private handleUp = (event: React.MouseEvent) => {\n event.preventDefault();\n this.setPosition(this.state.pos - itemHeight * this.yearStep);\n };\n\n private handleDown = (event: React.MouseEvent) => {\n event.preventDefault();\n this.setPosition(this.state.pos + itemHeight * this.yearStep);\n };\n\n private getItem(index: number) {\n const value = this.props.value + index;\n if (this.props.type === 'month') {\n return this.locale.months[value];\n }\n return value;\n }\n\n private setPosition(pos: number) {\n let top = itemsToMoveCount * itemHeight;\n let height = visibleYearsCount * itemHeight;\n if (this.props.type === 'month') {\n top = -this.props.value * itemHeight;\n height = monthsCount * itemHeight;\n }\n\n const minPos = this.getMinPos() - top;\n const maxPos = this.getMaxPos() - top - height + itemHeight;\n if (minPos >= pos) {\n pos = minPos;\n }\n if (maxPos <= pos) {\n pos = maxPos;\n }\n const topCapped = pos <= minPos;\n const botCapped = pos >= maxPos;\n\n this.setState({ pos, top, height, topCapped, botCapped });\n }\n\n private getMinPos() {\n if (this.props.type === 'month') {\n return -this.props.value * itemHeight;\n } else if (this.props.type === 'year') {\n return ((this.props.minValue || defaultMinYear) - this.props.value) * itemHeight;\n }\n return -Infinity; // Be defensive.\n }\n\n private getMaxPos() {\n if (this.props.type === 'month') {\n return (visibleYearsCount - this.props.value) * itemHeight;\n } else if (this.props.type === 'year') {\n return ((this.props.maxValue || defaultMaxYear) - this.props.value) * itemHeight;\n }\n return Infinity; // Be defensive.\n }\n}\n\nfunction preventDefault(e: React.SyntheticEvent) {\n e.preventDefault();\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Nullable } from '../../typings/utility-types';
|
|
3
|
-
declare type DOMNode = Element | Text | null;
|
|
4
3
|
export interface DropdownContainerPosition {
|
|
5
4
|
top: Nullable<number>;
|
|
6
5
|
bottom: Nullable<number>;
|
|
@@ -9,7 +8,7 @@ export interface DropdownContainerPosition {
|
|
|
9
8
|
}
|
|
10
9
|
export interface DropdownContainerProps {
|
|
11
10
|
align?: 'left' | 'right';
|
|
12
|
-
getParent: () =>
|
|
11
|
+
getParent: () => Nullable<HTMLElement>;
|
|
13
12
|
children?: React.ReactNode;
|
|
14
13
|
disablePortal?: boolean;
|
|
15
14
|
offsetY?: number;
|
|
@@ -20,7 +19,7 @@ export interface DropdownContainerState {
|
|
|
20
19
|
minWidth: number;
|
|
21
20
|
isDocumentElementRoot?: boolean;
|
|
22
21
|
}
|
|
23
|
-
export declare class DropdownContainer extends React.
|
|
22
|
+
export declare class DropdownContainer extends React.PureComponent<DropdownContainerProps, DropdownContainerState> {
|
|
24
23
|
static __KONTUR_REACT_UI__: string;
|
|
25
24
|
static defaultProps: {
|
|
26
25
|
align: string;
|
|
@@ -33,14 +32,12 @@ export declare class DropdownContainer extends React.Component<DropdownContainer
|
|
|
33
32
|
private dom;
|
|
34
33
|
private layoutSub;
|
|
35
34
|
componentDidMount(): void;
|
|
36
|
-
UNSAFE_componentWillMount(): void;
|
|
37
35
|
componentWillUnmount(): void;
|
|
38
36
|
render(): JSX.Element;
|
|
39
|
-
private
|
|
37
|
+
private ZIndexRef;
|
|
40
38
|
private isElement;
|
|
41
|
-
|
|
39
|
+
position: () => void;
|
|
42
40
|
private getHeight;
|
|
43
41
|
private getMinWidth;
|
|
44
42
|
private convertToRelativePosition;
|
|
45
43
|
}
|
|
46
|
-
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.DropdownContainer = void 0;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));
|
|
2
|
-
var _reactDom = require("react-dom");
|
|
3
2
|
|
|
4
3
|
var LayoutEvents = _interopRequireWildcard(require("../../lib/LayoutEvents"));
|
|
5
4
|
var _RenderContainer = require("../RenderContainer");
|
|
@@ -29,9 +28,7 @@ var _createPropsGetter = require("../../lib/createPropsGetter");var
|
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
DropdownContainer = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default)(DropdownContainer, _React$Component);function DropdownContainer() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;_this.
|
|
31
|
+
DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {(0, _inheritsLoose2.default)(DropdownContainer, _React$PureComponent);function DropdownContainer() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;_this.
|
|
35
32
|
|
|
36
33
|
|
|
37
34
|
|
|
@@ -49,7 +46,7 @@ DropdownContainer = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose
|
|
|
49
46
|
|
|
50
47
|
getProps = (0, _createPropsGetter.createPropsGetter)(DropdownContainer.defaultProps);_this.
|
|
51
48
|
|
|
52
|
-
dom =
|
|
49
|
+
dom = void 0;_this.
|
|
53
50
|
layoutSub = void 0;_this.
|
|
54
51
|
|
|
55
52
|
|
|
@@ -98,10 +95,8 @@ DropdownContainer = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose
|
|
|
98
95
|
|
|
99
96
|
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ref = function (e) {
|
|
104
|
-
_this.dom = e && (0, _reactDom.findDOMNode)(e);
|
|
98
|
+
ZIndexRef = function (element) {
|
|
99
|
+
_this.dom = element;
|
|
105
100
|
};_this.
|
|
106
101
|
|
|
107
102
|
isElement = function (node) {
|
|
@@ -112,7 +107,7 @@ DropdownContainer = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose
|
|
|
112
107
|
var target = _this.props.getParent();
|
|
113
108
|
var dom = _this.dom;
|
|
114
109
|
|
|
115
|
-
if (_this.isElement(target) && dom) {
|
|
110
|
+
if (target && _this.isElement(target) && dom) {
|
|
116
111
|
var targetRect = target.getBoundingClientRect();var _document =
|
|
117
112
|
document,body = _document.body,docEl = _document.documentElement;
|
|
118
113
|
|
|
@@ -174,7 +169,7 @@ DropdownContainer = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose
|
|
|
174
169
|
|
|
175
170
|
getMinWidth = function () {
|
|
176
171
|
var target = _this.props.getParent();
|
|
177
|
-
if (!_this.isElement(target)) {
|
|
172
|
+
if (!target || !_this.isElement(target)) {
|
|
178
173
|
return 0;
|
|
179
174
|
}
|
|
180
175
|
return target.getBoundingClientRect().width;
|
|
@@ -184,7 +179,7 @@ DropdownContainer = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose
|
|
|
184
179
|
var target = _this.props.getParent();var _this$props =
|
|
185
180
|
_this.props,_this$props$offsetX = _this$props.offsetX,offsetX = _this$props$offsetX === void 0 ? 0 : _this$props$offsetX,_this$props$offsetY2 = _this$props.offsetY,offsetY = _this$props$offsetY2 === void 0 ? 0 : _this$props$offsetY2;var
|
|
186
181
|
top = position.top,bottom = position.bottom,left = position.left,right = position.right;
|
|
187
|
-
if (_this.isElement(target)) {
|
|
182
|
+
if (target && _this.isElement(target)) {
|
|
188
183
|
var targetHeight = target.getBoundingClientRect().height;
|
|
189
184
|
return {
|
|
190
185
|
top: top !== null ? targetHeight + offsetY : null,
|
|
@@ -199,4 +194,4 @@ DropdownContainer = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose
|
|
|
199
194
|
left: offsetX,
|
|
200
195
|
right: null };
|
|
201
196
|
|
|
202
|
-
};return _this;}var _proto = DropdownContainer.prototype;_proto.componentDidMount = function componentDidMount() {this.position();this.layoutSub = LayoutEvents.addListener(this.position);
|
|
197
|
+
};return _this;}var _proto = DropdownContainer.prototype;_proto.componentDidMount = function componentDidMount() {this.position();this.layoutSub = LayoutEvents.addListener(this.position);var _document2 = document,body = _document2.body,docEl = _document2.documentElement;var htmlPosition = getComputedStyle(docEl).position;var bodyPosition = getComputedStyle(body).position;var hasLimitedHeightRoot = body.scrollHeight > body.clientHeight;var hasStaticRoot = htmlPosition === 'static' && bodyPosition === 'static';this.setState({ isDocumentElementRoot: hasLimitedHeightRoot || hasStaticRoot });};_proto.componentWillUnmount = function componentWillUnmount() {if (this.layoutSub) {this.layoutSub.remove();}};_proto.render = function render() {var style = { position: 'absolute', top: '0' };if (this.state.position) {var _this$state$position = this.state.position,top = _this$state$position.top,bottom = _this$state$position.bottom,left = _this$state$position.left,right = _this$state$position.right;style = (0, _extends2.default)({}, style, { top: top !== null ? top : undefined, bottom: bottom !== null ? bottom : undefined, left: left !== null ? left : undefined, right: right !== null ? right : undefined, minWidth: this.state.minWidth });}var content = /*#__PURE__*/_react.default.createElement(_ZIndex.ZIndex, { priority: 'DropdownContainer', wrapperRef: this.ZIndexRef, style: style }, this.props.children);return this.props.disablePortal ? content : /*#__PURE__*/_react.default.createElement(_RenderContainer.RenderContainer, null, content);};return DropdownContainer;}(_react.default.PureComponent);exports.DropdownContainer = DropdownContainer;DropdownContainer.__KONTUR_REACT_UI__ = 'DropdownContainer';DropdownContainer.defaultProps = { align: 'left', disablePortal: false, offsetX: 0, offsetY: -1 };
|