@skbkontur/react-ui 4.0.4 → 4.1.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 +49 -0
- package/cjs/components/Autocomplete/Autocomplete.d.ts +0 -1
- package/cjs/components/Autocomplete/Autocomplete.js +2 -9
- package/cjs/components/Autocomplete/Autocomplete.js.map +1 -1
- package/cjs/components/Button/Button.styles.js +1 -1
- package/cjs/components/Button/Button.styles.js.map +1 -1
- package/cjs/components/DateInput/DateInput.styles.js +2 -2
- package/cjs/components/DateInput/DateInput.styles.js.map +1 -1
- package/cjs/components/DatePicker/DatePicker.d.ts +1 -1
- package/cjs/components/DatePicker/DatePicker.js.map +1 -1
- package/cjs/components/FileUploader/FileUploader.js +5 -4
- package/cjs/components/FileUploader/FileUploader.js.map +1 -1
- package/cjs/components/FileUploader/FileUploader.styles.d.ts +3 -2
- package/cjs/components/FileUploader/FileUploader.styles.js +21 -15
- package/cjs/components/FileUploader/FileUploader.styles.js.map +1 -1
- package/cjs/components/Hint/Hint.d.ts +5 -1
- package/cjs/components/Hint/Hint.js +9 -1
- package/cjs/components/Hint/Hint.js.map +1 -1
- package/cjs/components/Input/Input.d.ts +1 -5
- package/cjs/components/Input/Input.js +14 -21
- package/cjs/components/Input/Input.js.map +1 -1
- package/cjs/components/Loader/Loader.js +7 -7
- package/cjs/components/Loader/Loader.js.map +1 -1
- package/cjs/components/MenuItem/MenuItem.styles.js +3 -2
- package/cjs/components/MenuItem/MenuItem.styles.js.map +1 -1
- package/cjs/components/Modal/Modal.js.map +1 -1
- package/cjs/components/Modal/Modal.styles.js +10 -6
- package/cjs/components/Modal/Modal.styles.js.map +1 -1
- package/cjs/components/Modal/ModalFooter.js +0 -1
- package/cjs/components/Modal/ModalFooter.js.map +1 -1
- package/cjs/components/Modal/ModalHeader.js +0 -1
- package/cjs/components/Modal/ModalHeader.js.map +1 -1
- package/cjs/components/Paging/Paging.d.ts +12 -2
- package/cjs/components/Paging/Paging.js +14 -3
- package/cjs/components/Paging/Paging.js.map +1 -1
- package/cjs/components/Paging/PagingDefaultComponent.d.ts +9 -0
- package/cjs/components/Paging/PagingDefaultComponent.js +21 -0
- package/cjs/components/Paging/PagingDefaultComponent.js.map +1 -0
- package/cjs/components/PasswordInput/PasswordInput.d.ts +2 -0
- package/cjs/components/PasswordInput/PasswordInput.js +22 -4
- package/cjs/components/PasswordInput/PasswordInput.js.map +1 -1
- package/cjs/components/PasswordInput/PasswordInputIcon.d.ts +3 -0
- package/cjs/components/PasswordInput/PasswordInputIcon.js +11 -0
- package/cjs/components/PasswordInput/PasswordInputIcon.js.map +1 -0
- package/cjs/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/cjs/components/RadioGroup/RadioGroup.js.map +1 -1
- package/cjs/components/ResponsiveLayout/ResponsiveLayout.js +7 -2
- package/cjs/components/ResponsiveLayout/ResponsiveLayout.js.map +1 -1
- package/cjs/components/ResponsiveLayout/ResponsiveLayoutEvents.d.ts +1 -1
- package/cjs/components/ResponsiveLayout/ResponsiveLayoutEvents.js.map +1 -1
- package/cjs/components/ScrollContainer/ScrollContainer.js +3 -2
- package/cjs/components/ScrollContainer/ScrollContainer.js.map +1 -1
- package/cjs/components/Select/Select.d.ts +7 -5
- package/cjs/components/Select/Select.js +12 -2
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/SidePage/SidePage.d.ts +0 -1
- package/cjs/components/SidePage/SidePage.js +1 -15
- package/cjs/components/SidePage/SidePage.js.map +1 -1
- package/cjs/components/SidePage/SidePageFooter.js +4 -3
- package/cjs/components/SidePage/SidePageFooter.js.map +1 -1
- package/cjs/components/SidePage/SidePageHeader.js +3 -2
- package/cjs/components/SidePage/SidePageHeader.js.map +1 -1
- package/cjs/components/Sticky/Sticky.js +4 -3
- package/cjs/components/Sticky/Sticky.js.map +1 -1
- package/cjs/components/Switcher/Switcher.d.ts +2 -1
- package/cjs/components/Switcher/Switcher.js +1 -0
- package/cjs/components/Switcher/Switcher.js.map +1 -1
- package/cjs/components/Switcher/Switcher.styles.js +2 -2
- package/cjs/components/Switcher/Switcher.styles.js.map +1 -1
- package/cjs/components/Tabs/Indicator.js +2 -1
- package/cjs/components/Tabs/Indicator.js.map +1 -1
- package/cjs/components/Tabs/Tabs.d.ts +3 -1
- package/cjs/components/Tabs/Tabs.js +8 -4
- package/cjs/components/Tabs/Tabs.js.map +1 -1
- package/cjs/components/Textarea/Textarea.d.ts +2 -2
- package/cjs/components/Textarea/Textarea.js +6 -6
- package/cjs/components/Textarea/Textarea.js.map +1 -1
- package/cjs/components/Textarea/TextareaCounter.js +10 -2
- package/cjs/components/Textarea/TextareaCounter.js.map +1 -1
- package/cjs/components/Toast/ToastView.js +1 -1
- package/cjs/components/Toast/ToastView.js.map +1 -1
- package/cjs/components/Toast/ToastView.styles.d.ts +1 -1
- package/cjs/components/Toast/ToastView.styles.js +3 -2
- package/cjs/components/Toast/ToastView.styles.js.map +1 -1
- package/cjs/components/Toggle/Toggle.styles.js +12 -10
- package/cjs/components/Toggle/Toggle.styles.js.map +1 -1
- package/cjs/components/TokenInput/TextWidthHelper.js +2 -1
- package/cjs/components/TokenInput/TextWidthHelper.js.map +1 -1
- package/cjs/components/TokenInput/TokenInput.styles.js +3 -2
- package/cjs/components/TokenInput/TokenInput.styles.js.map +1 -1
- package/cjs/components/TokenInput/TokenInputMenu.js.map +1 -1
- package/cjs/components/Tooltip/Tooltip.d.ts +4 -2
- package/cjs/components/Tooltip/Tooltip.js +10 -7
- package/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/cjs/components/TooltipMenu/TooltipMenu.js.map +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/cjs/internal/BGRuler.js +3 -1
- package/cjs/internal/BGRuler.js.map +1 -1
- package/cjs/internal/CommonWrapper/CommonWrapper.d.ts +1 -0
- package/cjs/internal/CommonWrapper/CommonWrapper.js +15 -1
- package/cjs/internal/CommonWrapper/CommonWrapper.js.map +1 -1
- package/cjs/internal/ComponentTable.d.ts +4 -2
- package/cjs/internal/ComponentTable.js +1 -0
- package/cjs/internal/ComponentTable.js.map +1 -1
- package/cjs/internal/DateSelect/DateSelect.js +2 -1
- package/cjs/internal/DateSelect/DateSelect.js.map +1 -1
- package/cjs/internal/DropdownContainer/DropdownContainer.js +5 -10
- package/cjs/internal/DropdownContainer/DropdownContainer.js.map +1 -1
- package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.js +3 -2
- package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.js.map +1 -1
- package/cjs/internal/FileUploaderControl/withFileUploaderControlProvider.js +14 -10
- package/cjs/internal/FileUploaderControl/withFileUploaderControlProvider.js.map +1 -1
- package/cjs/internal/InputLikeText/InputLikeText.d.ts +1 -1
- package/cjs/internal/InputLikeText/InputLikeText.js.map +1 -1
- package/cjs/internal/InternalMenu/InternalMenu.js +3 -2
- package/cjs/internal/InternalMenu/InternalMenu.js.map +1 -1
- package/cjs/internal/InternalMenu/InternalMenu.styles.js +2 -2
- package/cjs/internal/InternalMenu/InternalMenu.styles.js.map +1 -1
- package/cjs/internal/Menu/Menu.styles.js +5 -3
- package/cjs/internal/Menu/Menu.styles.js.map +1 -1
- package/cjs/internal/MobilePopup/MobilePopup.js.map +1 -1
- package/cjs/internal/Popup/Popup.d.ts +1 -2
- package/cjs/internal/Popup/Popup.js +16 -13
- package/cjs/internal/Popup/Popup.js.map +1 -1
- package/cjs/internal/Popup/PopupHelper.js +4 -2
- package/cjs/internal/Popup/PopupHelper.js.map +1 -1
- package/cjs/internal/RenderContainer/RenderContainer.js +9 -0
- package/cjs/internal/RenderContainer/RenderContainer.js.map +1 -1
- package/cjs/internal/RenderContainer/RenderContainerTypes.d.ts +2 -0
- package/cjs/internal/RenderContainer/RenderInnerContainer.d.ts +9 -1
- package/cjs/internal/RenderContainer/RenderInnerContainer.js +8 -1
- package/cjs/internal/RenderContainer/RenderInnerContainer.js.map +1 -1
- package/cjs/internal/TextWidthHelper/TextWidthHelper.js +3 -1
- package/cjs/internal/TextWidthHelper/TextWidthHelper.js.map +1 -1
- package/cjs/internal/ThemePlayground/CheckboxPlayground.js +1 -0
- package/cjs/internal/ThemePlayground/CheckboxPlayground.js.map +1 -1
- package/cjs/internal/ThemePlayground/Playground.js +11 -19
- package/cjs/internal/ThemePlayground/Playground.js.map +1 -1
- package/cjs/internal/ThemePlayground/RadioPlayground.js.map +1 -1
- package/cjs/internal/ThemePlayground/SizesGroup.d.ts +4 -0
- package/cjs/internal/ThemePlayground/SizesGroup.js +20 -0
- package/cjs/internal/ThemePlayground/SizesGroup.js.map +1 -0
- package/cjs/internal/ThemePlayground/ThemeContextPlayground.d.ts +4 -0
- package/cjs/internal/ThemePlayground/ThemeContextPlayground.js +14 -2
- package/cjs/internal/ThemePlayground/ThemeContextPlayground.js.map +1 -1
- package/cjs/internal/ThemePlayground/ThemeEditor.js +2 -0
- package/cjs/internal/ThemePlayground/ThemeEditor.js.map +1 -1
- package/cjs/internal/ThemePlayground/constants.d.ts +3 -1
- package/cjs/internal/ThemePlayground/constants.js +3 -1
- package/cjs/internal/ThemePlayground/constants.js.map +1 -1
- package/cjs/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
- package/cjs/internal/icons/16px/index.js +8 -0
- package/cjs/internal/icons/16px/index.js.map +1 -1
- package/cjs/internal/icons/20px/svg.js +6 -0
- package/cjs/internal/icons/20px/svg.js.map +1 -1
- package/cjs/internal/themes/DefaultTheme.d.ts +21 -1
- package/cjs/internal/themes/DefaultTheme.js +43 -5
- package/cjs/internal/themes/DefaultTheme.js.map +1 -1
- package/cjs/internal/themes/NotFlat.d.ts +6 -0
- package/cjs/internal/themes/NotFlat.js +12 -2
- package/cjs/internal/themes/NotFlat.js.map +1 -1
- package/cjs/internal/themes/Theme2022.d.ts +66 -0
- package/cjs/internal/themes/Theme2022.js +100 -0
- package/cjs/internal/themes/Theme2022.js.map +1 -0
- package/cjs/internal/themes/Theme2022Dark.d.ts +5 -0
- package/cjs/internal/themes/Theme2022Dark.js +9 -0
- package/cjs/internal/themes/Theme2022Dark.js.map +1 -0
- package/cjs/lib/ConditionalHandler.d.ts +3 -2
- package/cjs/lib/ConditionalHandler.js +5 -3
- package/cjs/lib/ConditionalHandler.js.map +1 -1
- package/cjs/lib/InstanceWithAnchorElement.d.ts +5 -0
- package/cjs/lib/InstanceWithAnchorElement.js +9 -0
- package/cjs/lib/InstanceWithAnchorElement.js.map +1 -0
- package/cjs/lib/ModalStack.d.ts +1 -1
- package/cjs/lib/ModalStack.js.map +1 -1
- package/cjs/lib/SSRSafe.d.ts +1 -0
- package/cjs/lib/SSRSafe.js +9 -1
- package/cjs/lib/SSRSafe.js.map +1 -1
- package/cjs/lib/dom/getDOMRect.d.ts +5 -2
- package/cjs/lib/dom/getDOMRect.js +30 -18
- package/cjs/lib/dom/getDOMRect.js.map +1 -1
- package/cjs/lib/events/keyboard/KeyboardMapKeys.d.ts +2 -1
- package/cjs/lib/events/keyboard/KeyboardMapKeys.js +1 -0
- package/cjs/lib/events/keyboard/KeyboardMapKeys.js.map +1 -1
- package/cjs/lib/events/keyboard/extractCode.js.map +1 -1
- package/cjs/lib/needsPolyfillPlaceholder.d.ts +6 -0
- package/cjs/lib/needsPolyfillPlaceholder.js +19 -0
- package/cjs/lib/needsPolyfillPlaceholder.js.map +1 -0
- package/cjs/lib/rootNode/getRootNode.js +14 -10
- package/cjs/lib/rootNode/getRootNode.js.map +1 -1
- package/cjs/lib/rootNode/rootNodeDecorator.d.ts +11 -0
- package/cjs/lib/rootNode/rootNodeDecorator.js +34 -5
- package/cjs/lib/rootNode/rootNodeDecorator.js.map +1 -1
- package/cjs/lib/theming/ThemeFactory.js.map +1 -1
- package/cjs/lib/theming/themes/Theme2022.d.ts +1 -0
- package/cjs/lib/theming/themes/Theme2022.js +6 -0
- package/cjs/lib/theming/themes/Theme2022.js.map +1 -0
- package/cjs/lib/theming/themes/Theme2022Dark.d.ts +1 -0
- package/cjs/lib/theming/themes/Theme2022Dark.js +9 -0
- package/cjs/lib/theming/themes/Theme2022Dark.js.map +1 -0
- package/components/Autocomplete/Autocomplete/Autocomplete.js +2 -9
- package/components/Autocomplete/Autocomplete/Autocomplete.js.map +1 -1
- package/components/Autocomplete/Autocomplete.d.ts +0 -1
- package/components/Button/Button.styles/Button.styles.js +1 -1
- package/components/Button/Button.styles/Button.styles.js.map +1 -1
- package/components/DateInput/DateInput.styles/DateInput.styles.js +2 -2
- package/components/DateInput/DateInput.styles/DateInput.styles.js.map +1 -1
- package/components/DatePicker/DatePicker/DatePicker.js.map +1 -1
- package/components/DatePicker/DatePicker.d.ts +1 -1
- package/components/FileUploader/FileUploader/FileUploader.js +5 -6
- package/components/FileUploader/FileUploader/FileUploader.js.map +1 -1
- package/components/FileUploader/FileUploader.styles/FileUploader.styles.js +15 -12
- package/components/FileUploader/FileUploader.styles/FileUploader.styles.js.map +1 -1
- package/components/FileUploader/FileUploader.styles.d.ts +3 -2
- package/components/Hint/Hint/Hint.js +9 -1
- package/components/Hint/Hint/Hint.js.map +1 -1
- package/components/Hint/Hint.d.ts +5 -1
- package/components/Input/Input/Input.js +7 -25
- package/components/Input/Input/Input.js.map +1 -1
- package/components/Input/Input.d.ts +1 -5
- package/components/Loader/Loader/Loader.js +11 -12
- package/components/Loader/Loader/Loader.js.map +1 -1
- package/components/MenuItem/MenuItem.styles/MenuItem.styles.js +1 -1
- package/components/MenuItem/MenuItem.styles/MenuItem.styles.js.map +1 -1
- package/components/Modal/Modal/Modal.js.map +1 -1
- package/components/Modal/Modal.styles/Modal.styles.js +4 -4
- package/components/Modal/Modal.styles/Modal.styles.js.map +1 -1
- package/components/Modal/ModalFooter/ModalFooter.js +1 -1
- package/components/Modal/ModalFooter/ModalFooter.js.map +1 -1
- package/components/Modal/ModalHeader/ModalHeader.js +1 -1
- package/components/Modal/ModalHeader/ModalHeader.js.map +1 -1
- package/components/Paging/Paging/Paging.js +7 -9
- package/components/Paging/Paging/Paging.js.map +1 -1
- package/components/Paging/Paging.d.ts +12 -2
- package/components/Paging/PagingDefaultComponent/PagingDefaultComponent.js +19 -0
- package/components/Paging/PagingDefaultComponent/PagingDefaultComponent.js.map +1 -0
- package/components/Paging/PagingDefaultComponent/package.json +6 -0
- package/components/Paging/PagingDefaultComponent.d.ts +9 -0
- package/components/PasswordInput/PasswordInput/PasswordInput.js +24 -5
- package/components/PasswordInput/PasswordInput/PasswordInput.js.map +1 -1
- package/components/PasswordInput/PasswordInput.d.ts +2 -0
- package/components/PasswordInput/PasswordInputIcon/PasswordInputIcon.js +10 -0
- package/components/PasswordInput/PasswordInputIcon/PasswordInputIcon.js.map +1 -0
- package/components/PasswordInput/PasswordInputIcon/package.json +6 -0
- package/components/PasswordInput/PasswordInputIcon.d.ts +3 -0
- package/components/RadioGroup/RadioGroup/RadioGroup.js.map +1 -1
- package/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/components/ResponsiveLayout/ResponsiveLayout/ResponsiveLayout.js +5 -0
- package/components/ResponsiveLayout/ResponsiveLayout/ResponsiveLayout.js.map +1 -1
- package/components/ResponsiveLayout/ResponsiveLayoutEvents/ResponsiveLayoutEvents.js.map +1 -1
- package/components/ResponsiveLayout/ResponsiveLayoutEvents.d.ts +1 -1
- package/components/ScrollContainer/ScrollContainer/ScrollContainer.js +3 -2
- package/components/ScrollContainer/ScrollContainer/ScrollContainer.js.map +1 -1
- package/components/Select/Select/Select.js +12 -6
- package/components/Select/Select/Select.js.map +1 -1
- package/components/Select/Select.d.ts +7 -5
- package/components/SidePage/SidePage/SidePage.js +0 -19
- package/components/SidePage/SidePage/SidePage.js.map +1 -1
- package/components/SidePage/SidePage.d.ts +0 -1
- package/components/SidePage/SidePageFooter/SidePageFooter.js +4 -4
- package/components/SidePage/SidePageFooter/SidePageFooter.js.map +1 -1
- package/components/SidePage/SidePageHeader/SidePageHeader.js +3 -3
- package/components/SidePage/SidePageHeader/SidePageHeader.js.map +1 -1
- package/components/Sticky/Sticky/Sticky.js +9 -8
- package/components/Sticky/Sticky/Sticky.js.map +1 -1
- package/components/Switcher/Switcher/Switcher.js.map +1 -1
- package/components/Switcher/Switcher.d.ts +2 -1
- package/components/Switcher/Switcher.styles/Switcher.styles.js +1 -1
- package/components/Switcher/Switcher.styles/Switcher.styles.js.map +1 -1
- package/components/Tabs/Indicator/Indicator.js +2 -1
- package/components/Tabs/Indicator/Indicator.js.map +1 -1
- package/components/Tabs/Tabs/Tabs.js.map +1 -1
- package/components/Tabs/Tabs.d.ts +3 -1
- package/components/Textarea/Textarea/Textarea.js +6 -6
- package/components/Textarea/Textarea/Textarea.js.map +1 -1
- package/components/Textarea/Textarea.d.ts +2 -2
- package/components/Textarea/TextareaCounter/TextareaCounter.js +9 -1
- package/components/Textarea/TextareaCounter/TextareaCounter.js.map +1 -1
- package/components/Toast/ToastView/ToastView.js +1 -1
- package/components/Toast/ToastView/ToastView.js.map +1 -1
- package/components/Toast/ToastView.styles/ToastView.styles.js +2 -2
- package/components/Toast/ToastView.styles/ToastView.styles.js.map +1 -1
- package/components/Toast/ToastView.styles.d.ts +1 -1
- package/components/Toggle/Toggle.styles/Toggle.styles.js +3 -4
- package/components/Toggle/Toggle.styles/Toggle.styles.js.map +1 -1
- package/components/TokenInput/TextWidthHelper/TextWidthHelper.js +3 -2
- package/components/TokenInput/TextWidthHelper/TextWidthHelper.js.map +1 -1
- package/components/TokenInput/TokenInput.styles/TokenInput.styles.js +1 -1
- package/components/TokenInput/TokenInput.styles/TokenInput.styles.js.map +1 -1
- package/components/TokenInput/TokenInputMenu/TokenInputMenu.js.map +1 -1
- package/components/Tooltip/Tooltip/Tooltip.js +11 -8
- package/components/Tooltip/Tooltip/Tooltip.js.map +1 -1
- package/components/Tooltip/Tooltip.d.ts +4 -2
- package/components/TooltipMenu/TooltipMenu/TooltipMenu.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/internal/BGRuler/BGRuler.js +2 -1
- package/internal/BGRuler/BGRuler.js.map +1 -1
- package/internal/CommonWrapper/CommonWrapper/CommonWrapper.js +17 -3
- package/internal/CommonWrapper/CommonWrapper/CommonWrapper.js.map +1 -1
- package/internal/CommonWrapper/CommonWrapper.d.ts +1 -0
- package/internal/ComponentTable/ComponentTable.js.map +1 -1
- package/internal/ComponentTable.d.ts +4 -2
- package/internal/DateSelect/DateSelect/DateSelect.js +2 -1
- package/internal/DateSelect/DateSelect/DateSelect.js.map +1 -1
- package/internal/DropdownContainer/DropdownContainer/DropdownContainer.js +5 -12
- package/internal/DropdownContainer/DropdownContainer/DropdownContainer.js.map +1 -1
- package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile/FileUploaderFile.js +3 -2
- package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile/FileUploaderFile.js.map +1 -1
- package/internal/FileUploaderControl/withFileUploaderControlProvider/withFileUploaderControlProvider.js +2 -0
- package/internal/FileUploaderControl/withFileUploaderControlProvider/withFileUploaderControlProvider.js.map +1 -1
- package/internal/InputLikeText/InputLikeText/InputLikeText.js.map +1 -1
- package/internal/InputLikeText/InputLikeText.d.ts +1 -1
- package/internal/InternalMenu/InternalMenu/InternalMenu.js +2 -1
- package/internal/InternalMenu/InternalMenu/InternalMenu.js.map +1 -1
- package/internal/InternalMenu/InternalMenu.styles/InternalMenu.styles.js +1 -1
- package/internal/InternalMenu/InternalMenu.styles/InternalMenu.styles.js.map +1 -1
- package/internal/Menu/Menu.styles/Menu.styles.js +1 -1
- package/internal/Menu/Menu.styles/Menu.styles.js.map +1 -1
- package/internal/MobilePopup/MobilePopup/MobilePopup.js.map +1 -1
- package/internal/Popup/Popup/Popup.js +21 -20
- package/internal/Popup/Popup/Popup.js.map +1 -1
- package/internal/Popup/Popup.d.ts +1 -2
- package/internal/Popup/PopupHelper/PopupHelper.js +3 -1
- package/internal/Popup/PopupHelper/PopupHelper.js.map +1 -1
- package/internal/RenderContainer/RenderContainer/RenderContainer.js +9 -0
- package/internal/RenderContainer/RenderContainer/RenderContainer.js.map +1 -1
- package/internal/RenderContainer/RenderContainerTypes.d.ts +2 -0
- package/internal/RenderContainer/RenderInnerContainer/RenderInnerContainer.js +8 -2
- package/internal/RenderContainer/RenderInnerContainer/RenderInnerContainer.js.map +1 -1
- package/internal/RenderContainer/RenderInnerContainer.d.ts +9 -1
- package/internal/TextWidthHelper/TextWidthHelper/TextWidthHelper.js +3 -4
- package/internal/TextWidthHelper/TextWidthHelper/TextWidthHelper.js.map +1 -1
- package/internal/ThemePlayground/CheckboxPlayground/CheckboxPlayground.js.map +1 -1
- package/internal/ThemePlayground/Playground/Playground.js +15 -29
- package/internal/ThemePlayground/Playground/Playground.js.map +1 -1
- package/internal/ThemePlayground/RadioPlayground/RadioPlayground.js.map +1 -1
- package/internal/ThemePlayground/SizesGroup/SizesGroup.js +29 -0
- package/internal/ThemePlayground/SizesGroup/SizesGroup.js.map +1 -0
- package/internal/ThemePlayground/SizesGroup/package.json +6 -0
- package/internal/ThemePlayground/SizesGroup.d.ts +4 -0
- package/internal/ThemePlayground/ThemeContextPlayground/ThemeContextPlayground.js +14 -2
- package/internal/ThemePlayground/ThemeContextPlayground/ThemeContextPlayground.js.map +1 -1
- package/internal/ThemePlayground/ThemeContextPlayground.d.ts +4 -0
- package/internal/ThemePlayground/ThemeEditor/ThemeEditor.js.map +1 -1
- package/internal/ThemePlayground/constants/constants.js +2 -0
- package/internal/ThemePlayground/constants/constants.js.map +1 -1
- package/internal/ThemePlayground/constants.d.ts +3 -1
- package/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
- package/internal/icons/16px/index/index.js +7 -0
- package/internal/icons/16px/index/index.js.map +1 -1
- package/internal/icons/20px/svg/svg.js +5 -0
- package/internal/icons/20px/svg/svg.js.map +1 -1
- package/internal/themes/DefaultTheme/DefaultTheme.js +53 -4
- package/internal/themes/DefaultTheme/DefaultTheme.js.map +1 -1
- package/internal/themes/DefaultTheme.d.ts +21 -1
- package/internal/themes/NotFlat/NotFlat.js +15 -0
- package/internal/themes/NotFlat/NotFlat.js.map +1 -1
- package/internal/themes/NotFlat.d.ts +6 -0
- package/internal/themes/Theme2022/Theme2022.js +78 -0
- package/internal/themes/Theme2022/Theme2022.js.map +1 -0
- package/internal/themes/Theme2022/package.json +6 -0
- package/internal/themes/Theme2022.d.ts +66 -0
- package/internal/themes/Theme2022Dark/Theme2022Dark.js +17 -0
- package/internal/themes/Theme2022Dark/Theme2022Dark.js.map +1 -0
- package/internal/themes/Theme2022Dark/package.json +6 -0
- package/internal/themes/Theme2022Dark.d.ts +5 -0
- package/lib/ConditionalHandler/ConditionalHandler.js.map +1 -1
- package/lib/ConditionalHandler.d.ts +3 -2
- package/lib/InstanceWithAnchorElement/InstanceWithAnchorElement.js +3 -0
- package/lib/InstanceWithAnchorElement/InstanceWithAnchorElement.js.map +1 -0
- package/lib/InstanceWithAnchorElement/package.json +6 -0
- package/lib/InstanceWithAnchorElement.d.ts +5 -0
- package/lib/ModalStack/ModalStack.js.map +1 -1
- package/lib/ModalStack.d.ts +1 -1
- package/lib/SSRSafe/SSRSafe.js +7 -0
- package/lib/SSRSafe/SSRSafe.js.map +1 -1
- package/lib/SSRSafe.d.ts +1 -0
- package/lib/dom/getDOMRect/getDOMRect.js +32 -15
- package/lib/dom/getDOMRect/getDOMRect.js.map +1 -1
- package/lib/dom/getDOMRect.d.ts +5 -2
- package/lib/events/keyboard/KeyboardMapKeys/KeyboardMapKeys.js.map +1 -1
- package/lib/events/keyboard/KeyboardMapKeys.d.ts +2 -1
- package/lib/events/keyboard/extractCode/extractCode.js.map +1 -1
- package/lib/needsPolyfillPlaceholder/needsPolyfillPlaceholder.js +21 -0
- package/lib/needsPolyfillPlaceholder/needsPolyfillPlaceholder.js.map +1 -0
- package/lib/needsPolyfillPlaceholder/package.json +6 -0
- package/lib/needsPolyfillPlaceholder.d.ts +6 -0
- package/lib/rootNode/getRootNode/getRootNode.js +11 -10
- package/lib/rootNode/getRootNode/getRootNode.js.map +1 -1
- package/lib/rootNode/rootNodeDecorator/rootNodeDecorator.js +26 -2
- package/lib/rootNode/rootNodeDecorator/rootNodeDecorator.js.map +1 -1
- package/lib/rootNode/rootNodeDecorator.d.ts +11 -0
- package/lib/theming/ThemeFactory/ThemeFactory.js.map +1 -1
- package/lib/theming/themes/Theme2022/Theme2022.js +4 -0
- package/lib/theming/themes/Theme2022/Theme2022.js.map +1 -0
- package/lib/theming/themes/Theme2022/package.json +6 -0
- package/lib/theming/themes/Theme2022.d.ts +1 -0
- package/lib/theming/themes/Theme2022Dark/Theme2022Dark.js +5 -0
- package/lib/theming/themes/Theme2022Dark/Theme2022Dark.js.map +1 -0
- package/lib/theming/themes/Theme2022Dark/package.json +6 -0
- package/lib/theming/themes/Theme2022Dark.d.ts +1 -0
- package/package.json +4 -2
- package/cjs/lib/polyfillPlaceholder.d.ts +0 -1
- package/cjs/lib/polyfillPlaceholder.js +0 -17
- package/cjs/lib/polyfillPlaceholder.js.map +0 -1
- package/lib/polyfillPlaceholder/package.json +0 -6
- package/lib/polyfillPlaceholder/polyfillPlaceholder.js +0 -12
- package/lib/polyfillPlaceholder/polyfillPlaceholder.js.map +0 -1
- package/lib/polyfillPlaceholder.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FileUploader.tsx"],"names":["stopPropagation","e","defaultRenderFile","file","fileNode","_FileUploader","React","forwardRef","props","ref","theme","ThemeContext","disabled","error","warning","multiple","width","fileUploaderWidth","hideFiles","onBlur","onFocus","onChange","request","validateBeforeUpload","onRequestSuccess","onRequestError","renderFile","inputProps","FileUploaderControlContext","files","setFiles","removeFile","reset","setFileValidationResult","locale","inputRef","isAsync","isSingleMode","upload","tryValidateAndUpload","forEach","validationMessage","id","FileUploaderFileValidationResult","handleChange","newFiles","filesArray","Array","from","attachedFiles","map","getAttachedFile","length","handleDrop","event","dataTransfer","clearData","onDrop","isDraggable","labelRef","isWindowDraggable","windowRef","isBrowser","current","window","document","focus","keyListener","isTabPressed","blur","focusedByTab","setFocusedByTab","handleInputChange","target","handleFocus","requestAnimationFrame","handleBlur","uploadButtonClassNames","jsStyles","uploadButton","uploadButtonFocus","dragOver","uploadButtonWrapperClassNames","windowDragOver","uploadButtonIconClassNames","icon","iconDisabled","hasOneFile","hasOneFileForSingle","hovered","setHovered","linkClassNames","link","linkHovered","linkDisabled","root","content","choosedFile","chooseFile","afterLinkText","singleFile","orDragHere","fileInput","FileUploader","memo","displayName"],"mappings":"6hBAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,sD;;AAEA,IAAMA,eAAwC,GAAG,SAA3CA,eAA2C,CAACC,CAAD,UAAOA,CAAC,CAACD,eAAF,EAAP,EAAjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAME,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,IAAD,EAAiCC,QAAjC,UAAkEA,QAAlE,EAA1B;;AAEA,IAAMC,aAAa,gBAAGC,eAAMC,UAAN,CAAsD,UAACC,KAAD,EAA4BC,GAA5B,EAAoC;AAC9G,MAAMC,KAAK,GAAG,uBAAWC,0BAAX,CAAd;;AAEA;AACEC,EAAAA,QADF;;;;;;;;;;;;;;;AAgBIJ,EAAAA,KAhBJ,CACEI,QADF,CAEEC,KAFF,GAgBIL,KAhBJ,CAEEK,KAFF,CAGEC,OAHF,GAgBIN,KAhBJ,CAGEM,OAHF,mBAgBIN,KAhBJ,CAIEO,QAJF,CAIEA,QAJF,gCAIa,KAJb,kCAgBIP,KAhBJ,CAKEQ,KALF,CAKEA,KALF,6BAKUN,KAAK,CAACO,iBALhB,mCAgBIT,KAhBJ,CAMEU,SANF,CAMEA,SANF,iCAMc,KANd,oBAOEC,MAPF,GAgBIX,KAhBJ,CAOEW,MAPF,CAQEC,OARF,GAgBIZ,KAhBJ,CAQEY,OARF,CASEC,QATF,GAgBIb,KAhBJ,CASEa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QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAH5B;AAIE,MAAA,IAAI,EAAC,MAJP;AAKE,MAAA,QAAQ,EAAEA,QALZ;AAME,MAAA,QAAQ,EAAEG,QANZ;AAOE,MAAA,SAAS,EAAE+D,wBAASwB,SAAT,EAPb;AAQE,MAAA,OAAO,EAAEtG,eARX;AASE,MAAA,QAAQ,EAAEwE,iBATZ;AAUE,MAAA,OAAO,EAAEE,WAVX;AAWE,MAAA,MAAM,EAAEE;AACR;AAZF,QAaE,KAAK,EAAE,EAbT,IA1BF,CADF,CAFF,CADF,CADF;;;;;;;AAmDD,CAlNqB,CAAtB;;;;AAsNO,IAAM2B,YAAY,GAAG;AAC1BjG,eAAMkG,IAAN,CAAWnG,aAAX,CAD0B,CAArB,C;;AAGPkG,YAAY,CAACE,WAAb,GAA2B,cAA3B","sourcesContent":["import React, { useCallback, useContext, useImperativeHandle, useRef, useState } from 'react';\n\nimport { FileUploaderAttachedFile, getAttachedFile } from '../../internal/FileUploaderControl/fileUtils';\nimport { cx } from '../../lib/theming/Emotion';\nimport { useMemoObject } from '../../hooks/useMemoObject';\nimport { FileUploaderControlContext } from '../../internal/FileUploaderControl/FileUploaderControlContext';\nimport { useControlLocale } from '../../internal/FileUploaderControl/hooks/useControlLocale';\nimport { useUpload } from '../../internal/FileUploaderControl/hooks/useUpload';\nimport { useDrop } from '../../hooks/useDrop';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { UploadIcon } from '../../internal/icons/16px';\nimport { FileUploaderControlProviderProps } from '../../internal/FileUploaderControl/FileUploaderControlProvider';\nimport { withFileUploaderControlProvider } from '../../internal/FileUploaderControl/withFileUploaderControlProvider';\nimport { keyListener } from '../../lib/events/keyListener';\nimport { FileUploaderFile } from '../../internal/FileUploaderControl/FileUploaderFile/FileUploaderFile';\nimport { FileUploaderFileList } from '../../internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList';\nimport { isBrowser } from '../../lib/client';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { Nullable } from '../../typings/utility-types';\nimport { FileUploaderFileValidationResult } from '../../internal/FileUploaderControl/FileUploaderFileValidationResult';\n\nimport { jsStyles } from './FileUploader.styles';\n\nconst stopPropagation: React.ReactEventHandler = (e) => e.stopPropagation();\n\ninterface _FileUploaderProps extends CommonProps, React.InputHTMLAttributes<HTMLInputElement> {\n /** Состояние ошибки всего контрола */\n error?: boolean;\n /** Состояние предупреждения всего контрола */\n warning?: boolean;\n /** Свойство ширины. */\n width?: React.CSSProperties['width'];\n /** Свойство, скрывающее отображение файлов. */\n hideFiles?: boolean;\n\n /** Функция, через которую отправляем файлы. Используется для отслеживания статуса загрузки файла. */\n request?: (file: FileUploaderAttachedFile) => Promise<void>;\n /** Срабатывает при удачной попытке отправки через request */\n onRequestSuccess?: (fileId: string) => void;\n /** Срабатывает при неудачной попытке отправки через request */\n onRequestError?: (fileId: string) => void;\n\n /**\n * Функция валидации каждого файла.\n * Срабатывает после выбора файлов и перед попыткой отправить в request.\n * Чтобы вывести валидацию ошибки, промис должен вернуть строку.\n * */\n validateBeforeUpload?: (file: FileUploaderAttachedFile) => Promise<Nullable<string>>;\n\n /**\n * Функция, позволяющая кастомизировать файлы.\n * Через нее можно вешать кастомные валидации на каждый файл.\n * */\n renderFile?: (file: FileUploaderAttachedFile, fileNode: React.ReactElement) => React.ReactNode;\n}\n\nexport interface FileUploaderRef {\n focus: () => void;\n blur: () => void;\n /** Сбрасывает выбранные файлы */\n reset: () => void;\n}\n\nconst defaultRenderFile = (file: FileUploaderAttachedFile, fileNode: React.ReactElement) => fileNode;\n\nconst _FileUploader = React.forwardRef<FileUploaderRef, _FileUploaderProps>((props: _FileUploaderProps, ref) => {\n const theme = useContext(ThemeContext);\n\n const {\n disabled,\n error,\n warning,\n multiple = false,\n width = theme.fileUploaderWidth,\n hideFiles = false,\n onBlur,\n onFocus,\n onChange,\n request,\n validateBeforeUpload,\n onRequestSuccess,\n onRequestError,\n renderFile = defaultRenderFile,\n ...inputProps\n } = props;\n\n const { files, setFiles, removeFile, reset, setFileValidationResult } = useContext(FileUploaderControlContext);\n\n const locale = useControlLocale();\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const isAsync = !!request;\n const isSingleMode = !multiple;\n\n const upload = useUpload(request, onRequestSuccess, onRequestError);\n\n const tryValidateAndUpload = useCallback(\n (files: FileUploaderAttachedFile[]) => {\n files.forEach(async (file) => {\n const validationMessage = validateBeforeUpload && (await validateBeforeUpload(file));\n\n if (!validationMessage) {\n isAsync && upload(file);\n } else {\n setFileValidationResult(file.id, FileUploaderFileValidationResult.error(validationMessage));\n }\n });\n },\n [upload, validateBeforeUpload, isAsync],\n );\n\n /** common part **/\n const handleChange = useCallback(\n (newFiles: FileList | null) => {\n if (!newFiles) return;\n\n let filesArray = Array.from(newFiles);\n\n if (isSingleMode) {\n filesArray = [filesArray[0]];\n }\n\n const attachedFiles = filesArray.map(getAttachedFile);\n\n if (isSingleMode && attachedFiles.length && files.length) {\n removeFile(files[0].id);\n }\n\n if (attachedFiles.length) {\n setFiles(attachedFiles);\n tryValidateAndUpload(attachedFiles);\n }\n },\n [tryValidateAndUpload, setFiles, isSingleMode, files, removeFile],\n );\n\n const handleDrop = useCallback(\n (event) => {\n if (disabled) {\n return;\n }\n\n const { dataTransfer } = event;\n const { files } = dataTransfer;\n\n if (files?.length > 0) {\n handleChange(files);\n dataTransfer.clearData();\n }\n },\n [handleChange, disabled],\n );\n\n const { isDraggable, ref: labelRef } = useDrop<HTMLLabelElement>({ onDrop: handleDrop });\n const { isDraggable: isWindowDraggable, ref: windowRef } = useDrop<Document>();\n\n if (isBrowser) {\n windowRef.current = window.document;\n }\n\n const focus = useCallback(() => {\n keyListener.isTabPressed = true;\n inputRef.current?.focus();\n }, []);\n\n const blur = useCallback(() => {\n inputRef.current?.blur();\n }, []);\n\n useImperativeHandle(ref, () => ({ focus, blur, reset }), [ref]);\n\n const [focusedByTab, setFocusedByTab] = useState(false);\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n handleChange(event.target.files);\n };\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n if (!disabled) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n requestAnimationFrame(() => {\n if (keyListener.isTabPressed) {\n setFocusedByTab(true);\n }\n });\n onFocus?.(e);\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocusedByTab(false);\n if (!disabled) {\n onBlur?.(e);\n }\n };\n\n const uploadButtonClassNames = cx(jsStyles.uploadButton(theme), {\n [jsStyles.uploadButtonFocus(theme)]: focusedByTab,\n [jsStyles.disabled(theme)]: disabled,\n [jsStyles.warning(theme)]: !!warning,\n [jsStyles.error(theme)]: !!error,\n [jsStyles.dragOver()]: isDraggable && !disabled,\n });\n\n const uploadButtonWrapperClassNames = cx({\n [jsStyles.windowDragOver()]: isWindowDraggable && !disabled,\n });\n\n const uploadButtonIconClassNames = cx(jsStyles.icon(theme), {\n [jsStyles.iconDisabled(theme)]: disabled,\n });\n\n const hasOneFile = files.length === 1;\n const hasOneFileForSingle = isSingleMode && hasOneFile && !hideFiles;\n\n const [hovered, setHovered] = useState(false);\n\n const linkClassNames = cx(jsStyles.link(theme), {\n [jsStyles.linkHovered(theme)]: !disabled && hovered,\n [jsStyles.linkDisabled(theme)]: disabled,\n });\n\n return (\n <CommonWrapper {...props}>\n <div className={jsStyles.root(theme)} style={useMemoObject({ width })}>\n {!hideFiles && !isSingleMode && !!files.length && <FileUploaderFileList renderFile={renderFile} />}\n <div className={uploadButtonWrapperClassNames}>\n <label\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n ref={labelRef}\n className={uploadButtonClassNames}\n >\n <div data-tid={'FileUploader__content'} className={jsStyles.content()}>\n <span data-tid={'FileUploader__link'} className={linkClassNames}>\n {hasOneFileForSingle ? locale.choosedFile : locale.chooseFile}\n </span>\n \n <div className={jsStyles.afterLinkText()}>\n {hasOneFileForSingle ? (\n <div className={jsStyles.singleFile()}>\n {renderFile(files[0], <FileUploaderFile file={files[0]} />)}\n </div>\n ) : (\n <>\n {locale.orDragHere} \n <div className={uploadButtonIconClassNames}>\n <UploadIcon />\n </div>\n </>\n )}\n </div>\n </div>\n <input\n {...inputProps}\n ref={inputRef}\n tabIndex={disabled ? -1 : 0}\n type=\"file\"\n disabled={disabled}\n multiple={multiple}\n className={jsStyles.fileInput()}\n onClick={stopPropagation}\n onChange={handleInputChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n // для того, чтобы срабатывало событие change при выборе одного и того же файла подряд\n value={''}\n />\n </label>\n </div>\n </div>\n </CommonWrapper>\n );\n});\n\nexport interface FileUploaderProps extends _FileUploaderProps, FileUploaderControlProviderProps {}\n\nexport const FileUploader = withFileUploaderControlProvider<FileUploaderProps, FileUploaderRef>(\n React.memo(_FileUploader),\n);\nFileUploader.displayName = 'FileUploader';\n"]}
|
|
1
|
+
{"version":3,"sources":["FileUploader.tsx"],"names":["stopPropagation","e","defaultRenderFile","file","fileNode","_FileUploader","React","forwardRef","props","ref","theme","ThemeContext","disabled","error","warning","multiple","width","fileUploaderWidth","hideFiles","onBlur","onFocus","onChange","request","validateBeforeUpload","onRequestSuccess","onRequestError","renderFile","inputProps","FileUploaderControlContext","files","setFiles","removeFile","reset","setFileValidationResult","locale","inputRef","isAsync","isSingleMode","upload","tryValidateAndUpload","forEach","validationMessage","id","FileUploaderFileValidationResult","handleChange","newFiles","filesArray","Array","from","attachedFiles","map","getAttachedFile","length","handleDrop","event","dataTransfer","clearData","onDrop","isDraggable","labelRef","isWindowDraggable","windowRef","isBrowser","current","window","document","focus","keyListener","isTabPressed","blur","focusedByTab","setFocusedByTab","handleInputChange","target","handleFocus","requestAnimationFrame","handleBlur","hovered","setHovered","uploadButtonClassNames","jsStyles","uploadButton","uploadButtonFocus","dragOver","uploadButtonWrapperClassNames","windowDragOver","uploadButtonIconClassNames","icon","iconDisabled","hasOneFile","hasOneFileForSingle","linkClassNames","link","linkHovered","linkDisabled","root","content","choosedFile","chooseFile","afterLinkText","singleFile","orDragHere","fileInput","FileUploader","memo","displayName"],"mappings":"6hBAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,sD;;AAEA,IAAMA,eAAwC,GAAG,SAA3CA,eAA2C,CAACC,CAAD,UAAOA,CAAC,CAACD,eAAF,EAAP,EAAjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAME,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,IAAD,EAAiCC,QAAjC,UAAkEA,QAAlE,EAA1B;;AAEA,IAAMC,aAAa,gBAAGC,eAAMC,UAAN,CAAsD,UAACC,KAAD,EAA4BC,GAA5B,EAAoC;AAC9G,MAAMC,KAAK,GAAG,uBAAWC,0BAAX,CAAd;;AAEA;AACEC,EAAAA,QADF;;;;;;;;;;;;;;;AAgBIJ,EAAAA,KAhBJ,CACEI,QADF,CAEEC,KAFF,GAgBIL,KAhBJ,CAEEK,KAFF,CAGEC,OAHF,GAgBIN,KAhBJ,CAGEM,OAHF,mBAgBIN,KAhBJ,CAIEO,QAJF,CAIEA,QAJF,gCAIa,KAJb,kCAgBIP,KAhBJ,CAKEQ,KALF,CAKEA,KALF,6BAKUN,KAAK,CAACO,iBALhB,mCAgBIT,KAhBJ,CAMEU,SANF,CAMEA,SANF,iCAMc,KANd,oBAOEC,MAPF,GAgBIX,KAhBJ,CAOEW,MAPF,CAQEC,OARF,GAgBIZ,KAhBJ,CAQEY,OARF,CASEC,QATF,GAgBIb,KAhBJ,CASEa,QATF,CAUEC,OAVF,GAgBId,KAhBJ,CAUEc,OAVF,CAWEC,oBAXF,GAgBIf,KAhBJ,CAWEe,oBAXF,CAYEC,gBAZF,GAgBIhB,KAhBJ,CAYEgB,gBAZF,CAaEC,cAbF,GAgBIjB,KAhBJ,CAaEiB,cAb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,QAAQ,EAAEA,QALZ;AAME,MAAA,QAAQ,EAAEG,QANZ;AAOE,MAAA,SAAS,EAAEiE,wBAASsB,SAAT,EAPb;AAQE,MAAA,OAAO,EAAEtG,eARX;AASE,MAAA,QAAQ,EAAEwE,iBATZ;AAUE,MAAA,OAAO,EAAEE,WAVX;AAWE,MAAA,MAAM,EAAEE;AACR;AAZF,QAaE,KAAK,EAAE,EAbT,IA1BF,CADF,CAFF,CADF,CADF;;;;;;;AAmDD,CAnNqB,CAAtB;;;;AAuNO,IAAM2B,YAAY,GAAG;AAC1BjG,eAAMkG,IAAN,CAAWnG,aAAX,CAD0B,CAArB,C;;AAGPkG,YAAY,CAACE,WAAb,GAA2B,cAA3B","sourcesContent":["import React, { useCallback, useContext, useImperativeHandle, useRef, useState } from 'react';\n\nimport { FileUploaderAttachedFile, getAttachedFile } from '../../internal/FileUploaderControl/fileUtils';\nimport { cx } from '../../lib/theming/Emotion';\nimport { useMemoObject } from '../../hooks/useMemoObject';\nimport { FileUploaderControlContext } from '../../internal/FileUploaderControl/FileUploaderControlContext';\nimport { useControlLocale } from '../../internal/FileUploaderControl/hooks/useControlLocale';\nimport { useUpload } from '../../internal/FileUploaderControl/hooks/useUpload';\nimport { useDrop } from '../../hooks/useDrop';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { UploadIcon } from '../../internal/icons/16px';\nimport { FileUploaderControlProviderProps } from '../../internal/FileUploaderControl/FileUploaderControlProvider';\nimport { withFileUploaderControlProvider } from '../../internal/FileUploaderControl/withFileUploaderControlProvider';\nimport { keyListener } from '../../lib/events/keyListener';\nimport { FileUploaderFile } from '../../internal/FileUploaderControl/FileUploaderFile/FileUploaderFile';\nimport { FileUploaderFileList } from '../../internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList';\nimport { isBrowser } from '../../lib/client';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { Nullable } from '../../typings/utility-types';\nimport { FileUploaderFileValidationResult } from '../../internal/FileUploaderControl/FileUploaderFileValidationResult';\n\nimport { jsStyles } from './FileUploader.styles';\n\nconst stopPropagation: React.ReactEventHandler = (e) => e.stopPropagation();\n\ninterface _FileUploaderProps extends CommonProps, React.InputHTMLAttributes<HTMLInputElement> {\n /** Состояние ошибки всего контрола */\n error?: boolean;\n /** Состояние предупреждения всего контрола */\n warning?: boolean;\n /** Свойство ширины. */\n width?: React.CSSProperties['width'];\n /** Свойство, скрывающее отображение файлов. */\n hideFiles?: boolean;\n\n /** Функция, через которую отправляем файлы. Используется для отслеживания статуса загрузки файла. */\n request?: (file: FileUploaderAttachedFile) => Promise<void>;\n /** Срабатывает при удачной попытке отправки через request */\n onRequestSuccess?: (fileId: string) => void;\n /** Срабатывает при неудачной попытке отправки через request */\n onRequestError?: (fileId: string) => void;\n\n /**\n * Функция валидации каждого файла.\n * Срабатывает после выбора файлов и перед попыткой отправить в request.\n * Чтобы вывести валидацию ошибки, промис должен вернуть строку.\n * */\n validateBeforeUpload?: (file: FileUploaderAttachedFile) => Promise<Nullable<string>>;\n\n /**\n * Функция, позволяющая кастомизировать файлы.\n * Через нее можно вешать кастомные валидации на каждый файл.\n * */\n renderFile?: (file: FileUploaderAttachedFile, fileNode: React.ReactElement) => React.ReactNode;\n}\n\nexport interface FileUploaderRef {\n focus: () => void;\n blur: () => void;\n /** Сбрасывает выбранные файлы */\n reset: () => void;\n}\n\nconst defaultRenderFile = (file: FileUploaderAttachedFile, fileNode: React.ReactElement) => fileNode;\n\nconst _FileUploader = React.forwardRef<FileUploaderRef, _FileUploaderProps>((props: _FileUploaderProps, ref) => {\n const theme = useContext(ThemeContext);\n\n const {\n disabled,\n error,\n warning,\n multiple = false,\n width = theme.fileUploaderWidth,\n hideFiles = false,\n onBlur,\n onFocus,\n onChange,\n request,\n validateBeforeUpload,\n onRequestSuccess,\n onRequestError,\n renderFile = defaultRenderFile,\n ...inputProps\n } = props;\n\n const { files, setFiles, removeFile, reset, setFileValidationResult } = useContext(FileUploaderControlContext);\n\n const locale = useControlLocale();\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const isAsync = !!request;\n const isSingleMode = !multiple;\n\n const upload = useUpload(request, onRequestSuccess, onRequestError);\n\n const tryValidateAndUpload = useCallback(\n (files: FileUploaderAttachedFile[]) => {\n files.forEach(async (file) => {\n const validationMessage = validateBeforeUpload && (await validateBeforeUpload(file));\n\n if (!validationMessage) {\n isAsync && upload(file);\n } else {\n setFileValidationResult(file.id, FileUploaderFileValidationResult.error(validationMessage));\n }\n });\n },\n [upload, validateBeforeUpload, isAsync],\n );\n\n /** common part **/\n const handleChange = useCallback(\n (newFiles: FileList | null) => {\n if (!newFiles) return;\n\n let filesArray = Array.from(newFiles);\n\n if (isSingleMode) {\n filesArray = [filesArray[0]];\n }\n\n const attachedFiles = filesArray.map(getAttachedFile);\n\n if (isSingleMode && attachedFiles.length && files.length) {\n removeFile(files[0].id);\n }\n\n if (attachedFiles.length) {\n setFiles(attachedFiles);\n tryValidateAndUpload(attachedFiles);\n }\n },\n [tryValidateAndUpload, setFiles, isSingleMode, files, removeFile],\n );\n\n const handleDrop = useCallback(\n (event) => {\n if (disabled) {\n return;\n }\n\n const { dataTransfer } = event;\n const { files } = dataTransfer;\n\n if (files?.length > 0) {\n handleChange(files);\n dataTransfer.clearData();\n }\n },\n [handleChange, disabled],\n );\n\n const { isDraggable, ref: labelRef } = useDrop<HTMLLabelElement>({ onDrop: handleDrop });\n const { isDraggable: isWindowDraggable, ref: windowRef } = useDrop<Document>();\n\n if (isBrowser) {\n windowRef.current = window.document;\n }\n\n const focus = useCallback(() => {\n keyListener.isTabPressed = true;\n inputRef.current?.focus();\n }, []);\n\n const blur = useCallback(() => {\n inputRef.current?.blur();\n }, []);\n\n useImperativeHandle(ref, () => ({ focus, blur, reset }), [ref]);\n\n const [focusedByTab, setFocusedByTab] = useState(false);\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n handleChange(event.target.files);\n };\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n if (!disabled) {\n // focus event fires before keyDown eventlistener\n // so we should check tabPressed in async way\n requestAnimationFrame(() => {\n if (keyListener.isTabPressed) {\n setFocusedByTab(true);\n }\n });\n onFocus?.(e);\n }\n };\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocusedByTab(false);\n if (!disabled) {\n onBlur?.(e);\n }\n };\n\n const [hovered, setHovered] = useState(false);\n\n const uploadButtonClassNames = cx(jsStyles.uploadButton(theme), {\n [jsStyles.uploadButtonFocus(theme)]: focusedByTab,\n [jsStyles.disabled(theme)]: disabled,\n [jsStyles.hovered(theme)]: !disabled && hovered,\n [jsStyles.warning(theme)]: !!warning,\n [jsStyles.error(theme)]: !!error,\n [jsStyles.dragOver(theme)]: isDraggable && !disabled,\n });\n\n const uploadButtonWrapperClassNames = cx({\n [jsStyles.windowDragOver(theme)]: isWindowDraggable && !disabled,\n });\n\n const uploadButtonIconClassNames = cx(jsStyles.icon(theme), {\n [jsStyles.iconDisabled(theme)]: disabled,\n });\n\n const hasOneFile = files.length === 1;\n const hasOneFileForSingle = isSingleMode && hasOneFile && !hideFiles;\n\n const linkClassNames = cx(jsStyles.link(theme), {\n [jsStyles.linkHovered(theme)]: !disabled && hovered,\n [jsStyles.linkDisabled(theme)]: disabled,\n });\n\n return (\n <CommonWrapper {...props}>\n <div className={jsStyles.root(theme)} style={useMemoObject({ width })}>\n {!hideFiles && !isSingleMode && !!files.length && <FileUploaderFileList renderFile={renderFile} />}\n <div className={uploadButtonWrapperClassNames}>\n <label\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n ref={labelRef}\n className={uploadButtonClassNames}\n >\n <div data-tid={'FileUploader__content'} className={jsStyles.content()}>\n <span data-tid={'FileUploader__link'} className={linkClassNames}>\n {hasOneFileForSingle ? locale.choosedFile : locale.chooseFile}\n </span>\n \n <div className={jsStyles.afterLinkText()}>\n {hasOneFileForSingle ? (\n <div className={jsStyles.singleFile()}>\n {renderFile(files[0], <FileUploaderFile file={files[0]} />)}\n </div>\n ) : (\n <>\n {locale.orDragHere} \n <div className={uploadButtonIconClassNames}>\n <UploadIcon />\n </div>\n </>\n )}\n </div>\n </div>\n <input\n {...inputProps}\n ref={inputRef}\n tabIndex={disabled ? -1 : 0}\n type=\"file\"\n disabled={disabled}\n multiple={multiple}\n className={jsStyles.fileInput()}\n onClick={stopPropagation}\n onChange={handleInputChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n // для того, чтобы срабатывало событие change при выборе одного и того же файла подряд\n value={''}\n />\n </label>\n </div>\n </div>\n </CommonWrapper>\n );\n});\n\nexport interface FileUploaderProps extends _FileUploaderProps, FileUploaderControlProviderProps {}\n\nexport const FileUploader = withFileUploaderControlProvider<FileUploaderProps, FileUploaderRef>(\n React.memo(_FileUploader),\n);\nFileUploader.displayName = 'FileUploader';\n"]}
|
|
@@ -4,13 +4,14 @@ export declare const jsStyles: {
|
|
|
4
4
|
root(t: Theme): string;
|
|
5
5
|
uploadButton(t: Theme): string;
|
|
6
6
|
uploadButtonFocus(t: Theme): string;
|
|
7
|
-
dragOver(): string;
|
|
8
|
-
windowDragOver(): string;
|
|
7
|
+
dragOver(t: Theme): string;
|
|
8
|
+
windowDragOver(t: Theme): string;
|
|
9
9
|
content(): string;
|
|
10
10
|
fileInput(): string;
|
|
11
11
|
afterLinkText(): string;
|
|
12
12
|
warning(t: Theme): string;
|
|
13
13
|
error(t: Theme): string;
|
|
14
|
+
hovered(t: Theme): string;
|
|
14
15
|
disabled(t: Theme): string;
|
|
15
16
|
icon(t: Theme): string;
|
|
16
17
|
iconDisabled(t: Theme): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.jsStyles = void 0;var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));var _Emotion = require("../../lib/theming/Emotion");var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.jsStyles = void 0;var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));var _Emotion = require("../../lib/theming/Emotion");var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
var styles = {
|
|
@@ -57,17 +57,17 @@ var styles = {
|
|
|
57
57
|
|
|
58
58
|
},
|
|
59
59
|
|
|
60
|
-
dragOver: function dragOver() {
|
|
61
|
-
return (0, _Emotion.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteralLoose2.default)(["\n border: 1px solid #2da4f9;\n border-radius:
|
|
62
|
-
|
|
60
|
+
dragOver: function dragOver(t) {
|
|
61
|
+
return (0, _Emotion.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteralLoose2.default)(["\n border: 1px solid #2da4f9;\n border-radius: ", ";\n box-shadow: 0px 0px 0px 3px #2da4f9, 0px 0px 0px 8px rgba(45, 164, 249, 0.35);\n "])),
|
|
63
62
|
|
|
63
|
+
t.fileUploaderBorderRadius);
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
-
windowDragOver: function windowDragOver() {
|
|
69
|
-
return (0, _Emotion.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteralLoose2.default)(["\n border-radius:
|
|
70
|
-
|
|
68
|
+
windowDragOver: function windowDragOver(t) {
|
|
69
|
+
return (0, _Emotion.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteralLoose2.default)(["\n border-radius: ", ";\n animation: ", " 1.5s infinite;\n "])),
|
|
70
|
+
t.fileUploaderBorderRadius,
|
|
71
71
|
styles.pulse());
|
|
72
72
|
|
|
73
73
|
},
|
|
@@ -110,8 +110,14 @@ var styles = {
|
|
|
110
110
|
|
|
111
111
|
},
|
|
112
112
|
|
|
113
|
+
hovered: function hovered(t) {
|
|
114
|
+
return (0, _Emotion.css)(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteralLoose2.default)(["\n background: ", ";\n "])),
|
|
115
|
+
t.fileUploaderHoveredBg);
|
|
116
|
+
|
|
117
|
+
},
|
|
118
|
+
|
|
113
119
|
disabled: function disabled(t) {
|
|
114
|
-
return (0, _Emotion.css)(
|
|
120
|
+
return (0, _Emotion.css)(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteralLoose2.default)(["\n cursor: default;\n background: ", ";\n border: ", " solid ", ";\n color: ", ";\n box-shadow: none;\n "])),
|
|
115
121
|
|
|
116
122
|
t.fileUploaderDisabledBg,
|
|
117
123
|
t.fileUploaderBorderWidth, t.fileUploaderDisabledBorderColor,
|
|
@@ -121,7 +127,7 @@ var styles = {
|
|
|
121
127
|
},
|
|
122
128
|
|
|
123
129
|
icon: function icon(t) {
|
|
124
|
-
return (0, _Emotion.css)(
|
|
130
|
+
return (0, _Emotion.css)(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteralLoose2.default)(["\n display: inline-block;\n font-size: ", ";\n color: ", ";\n "])),
|
|
125
131
|
|
|
126
132
|
t.fileUploaderIconSize,
|
|
127
133
|
t.fileUploaderIconColor);
|
|
@@ -129,13 +135,13 @@ var styles = {
|
|
|
129
135
|
},
|
|
130
136
|
|
|
131
137
|
iconDisabled: function iconDisabled(t) {
|
|
132
|
-
return (0, _Emotion.css)(
|
|
138
|
+
return (0, _Emotion.css)(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteralLoose2.default)(["\n color: ", ";\n "])),
|
|
133
139
|
t.fileUploaderDisabledIconColor);
|
|
134
140
|
|
|
135
141
|
},
|
|
136
142
|
|
|
137
143
|
link: function link(t) {
|
|
138
|
-
return (0, _Emotion.css)(
|
|
144
|
+
return (0, _Emotion.css)(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteralLoose2.default)(["\n outline: none;\n text-decoration: none;\n color: ", ";\n "])),
|
|
139
145
|
|
|
140
146
|
|
|
141
147
|
t.fileUploaderLinkColor);
|
|
@@ -143,13 +149,13 @@ var styles = {
|
|
|
143
149
|
},
|
|
144
150
|
|
|
145
151
|
linkHovered: function linkHovered(t) {
|
|
146
|
-
return (0, _Emotion.css)(
|
|
147
|
-
t.
|
|
152
|
+
return (0, _Emotion.css)(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteralLoose2.default)(["\n text-decoration: ", ";\n "])),
|
|
153
|
+
t.fileUploaderLinkHoverTextDecoration);
|
|
148
154
|
|
|
149
155
|
},
|
|
150
156
|
|
|
151
157
|
linkDisabled: function linkDisabled(t) {
|
|
152
|
-
return (0, _Emotion.css)(
|
|
158
|
+
return (0, _Emotion.css)(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteralLoose2.default)(["\n color: ", ";\n &:hover {\n text-decoration: none;\n }\n "])),
|
|
153
159
|
t.fileUploaderDisabledLinkColor);
|
|
154
160
|
|
|
155
161
|
|
|
@@ -158,7 +164,7 @@ var styles = {
|
|
|
158
164
|
},
|
|
159
165
|
|
|
160
166
|
singleFile: function singleFile() {
|
|
161
|
-
return (0, _Emotion.css)(
|
|
167
|
+
return (0, _Emotion.css)(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteralLoose2.default)(["\n width: 100%;\n "])));
|
|
162
168
|
|
|
163
169
|
|
|
164
170
|
} };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FileUploader.styles.ts"],"names":["styles","pulse","keyframes","root","t","css","fileUploaderBg","fileUploaderLineHeight","fileUploaderFontSize","fileUploaderTextColorDefault","uploadButton","fileUploaderBorderWidth","fileUploaderBorderStyle","fileUploaderBorderColor","fileUploaderBorderRadius","fileUploaderPaddingY","fileUploaderPaddingX","uploadButtonFocus","fileUploaderBorderColorFocus","dragOver","windowDragOver","content","fileInput","afterLinkText","warning","fileUploaderBorderColorWarning","error","fileUploaderBorderColorError","disabled","fileUploaderDisabledBg","fileUploaderDisabledBorderColor","fileUploaderDisabledTextColor","icon","fileUploaderIconSize","fileUploaderIconColor","iconDisabled","fileUploaderDisabledIconColor","link","fileUploaderLinkColor","linkHovered","
|
|
1
|
+
{"version":3,"sources":["FileUploader.styles.ts"],"names":["styles","pulse","keyframes","root","t","css","fileUploaderBg","fileUploaderLineHeight","fileUploaderFontSize","fileUploaderTextColorDefault","uploadButton","fileUploaderBorderWidth","fileUploaderBorderStyle","fileUploaderBorderColor","fileUploaderBorderRadius","fileUploaderPaddingY","fileUploaderPaddingX","uploadButtonFocus","fileUploaderBorderColorFocus","dragOver","windowDragOver","content","fileInput","afterLinkText","warning","fileUploaderBorderColorWarning","error","fileUploaderBorderColorError","hovered","fileUploaderHoveredBg","disabled","fileUploaderDisabledBg","fileUploaderDisabledBorderColor","fileUploaderDisabledTextColor","icon","fileUploaderIconSize","fileUploaderIconColor","iconDisabled","fileUploaderDisabledIconColor","link","fileUploaderLinkColor","linkHovered","fileUploaderLinkHoverTextDecoration","linkDisabled","fileUploaderDisabledLinkColor","singleFile","jsStyles"],"mappings":"8QAAA,oD;;;AAGA,IAAMA,MAAM,GAAG;AACbC,EAAAA,KADa,mBACL;AACN,eAAOC,kBAAP;;;;;;;;;;;;;;;;;AAiBD,GAnBY;;AAqBbC,EAAAA,IArBa,gBAqBRC,CArBQ,EAqBE;AACb,eAAOC,YAAP;;;;AAIsBD,IAAAA,CAAC,CAACE,cAJxB;AAKiBF,IAAAA,CAAC,CAACG,sBALnB;AAMeH,IAAAA,CAAC,CAACI,oBANjB;AAOW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, keyframes, memoizeStyle } from '../../lib/theming/Emotion';\nimport { Theme } from '../../lib/theming/Theme';\n\nconst styles = {\n pulse() {\n return keyframes`\n 0% {\n box-shadow:\n 0px 0px 0px 0px #2DA4F9,\n 0px 0px 0px 1px rgba(45,164,249,0.7);\n }\n 95% {\n box-shadow:\n 0px 0px 0px 0px #2DA4F9,\n 0px 0px 0px 10px rgba(45,164,249,0);\n }\n 100% {\n box-shadow:\n 0px 0px 0px 0px #2DA4F9,\n 0px 0px 0px 1px rgba(45,164,249,0);\n }\n `;\n },\n\n root(t: Theme) {\n return css`\n display: inline-block;\n min-width: 285px;\n position: relative;\n background-color: ${t.fileUploaderBg};\n line-height: ${t.fileUploaderLineHeight};\n font-size: ${t.fileUploaderFontSize};\n color: ${t.fileUploaderTextColorDefault};\n `;\n },\n\n uploadButton(t: Theme) {\n return css`\n width: 100%;\n display: inline-flex;\n align-items: center;\n justify-content: space-between;\n border: ${t.fileUploaderBorderWidth} ${t.fileUploaderBorderStyle} ${t.fileUploaderBorderColor};\n box-sizing: border-box;\n border-radius: ${t.fileUploaderBorderRadius};\n outline: none;\n cursor: pointer;\n padding: ${t.fileUploaderPaddingY} ${t.fileUploaderPaddingX};\n transition: box-shadow 0.3s ease;\n `;\n },\n\n uploadButtonFocus(t: Theme) {\n return css`\n border: ${t.fileUploaderBorderWidth} solid ${t.fileUploaderBorderColorFocus};\n box-shadow: 0px 0px 0px 1px ${t.fileUploaderBorderColorFocus};\n `;\n },\n\n dragOver(t: Theme) {\n return css`\n border: 1px solid #2da4f9;\n border-radius: ${t.fileUploaderBorderRadius};\n box-shadow: 0px 0px 0px 3px #2da4f9, 0px 0px 0px 8px rgba(45, 164, 249, 0.35);\n `;\n },\n\n windowDragOver(t: Theme) {\n return css`\n border-radius: ${t.fileUploaderBorderRadius};\n animation: ${styles.pulse()} 1.5s infinite;\n `;\n },\n\n content() {\n return css`\n display: flex;\n width: 100%;\n align-items: center;\n height: 100%;\n `;\n },\n\n fileInput() {\n return css`\n width: 0;\n height: 0;\n `;\n },\n\n afterLinkText() {\n return css`\n display: flex;\n justify-content: space-between;\n flex: 1 1 auto;\n `;\n },\n\n warning(t: Theme) {\n return css`\n border: ${t.fileUploaderBorderWidth} solid ${t.fileUploaderBorderColorWarning};\n box-shadow: 0px 0px 0px 1px ${t.fileUploaderBorderColorWarning};\n `;\n },\n\n error(t: Theme) {\n return css`\n border: ${t.fileUploaderBorderWidth} solid ${t.fileUploaderBorderColorError};\n box-shadow: 0px 0px 0px 1px ${t.fileUploaderBorderColorError};\n `;\n },\n\n hovered(t: Theme) {\n return css`\n background: ${t.fileUploaderHoveredBg};\n `;\n },\n\n disabled(t: Theme) {\n return css`\n cursor: default;\n background: ${t.fileUploaderDisabledBg};\n border: ${t.fileUploaderBorderWidth} solid ${t.fileUploaderDisabledBorderColor};\n color: ${t.fileUploaderDisabledTextColor};\n box-shadow: none;\n `;\n },\n\n icon(t: Theme) {\n return css`\n display: inline-block;\n font-size: ${t.fileUploaderIconSize};\n color: ${t.fileUploaderIconColor};\n `;\n },\n\n iconDisabled(t: Theme) {\n return css`\n color: ${t.fileUploaderDisabledIconColor};\n `;\n },\n\n link(t: Theme) {\n return css`\n outline: none;\n text-decoration: none;\n color: ${t.fileUploaderLinkColor};\n `;\n },\n\n linkHovered(t: Theme) {\n return css`\n text-decoration: ${t.fileUploaderLinkHoverTextDecoration};\n `;\n },\n\n linkDisabled(t: Theme) {\n return css`\n color: ${t.fileUploaderDisabledLinkColor};\n &:hover {\n text-decoration: none;\n }\n `;\n },\n\n singleFile() {\n return css`\n width: 100%;\n `;\n },\n};\n\nexport const jsStyles = memoizeStyle(styles);\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PopupPositionsType } from '../../internal/Popup';
|
|
3
|
+
import { Nullable } from '../../typings/utility-types';
|
|
3
4
|
import { MouseEventType } from '../../typings/event-types';
|
|
4
5
|
import { CommonProps } from '../../internal/CommonWrapper';
|
|
6
|
+
import { InstanceWithAnchorElement } from '../../lib/InstanceWithAnchorElement';
|
|
5
7
|
export interface HintProps extends CommonProps {
|
|
6
8
|
children?: React.ReactNode;
|
|
7
9
|
/**
|
|
@@ -55,7 +57,7 @@ export interface HintState {
|
|
|
55
57
|
/**
|
|
56
58
|
* Всплывающая подсказка, которая по умолчанию отображается при наведении на элемент. <br/> Можно задать другие условия отображения.
|
|
57
59
|
*/
|
|
58
|
-
export declare class Hint extends React.PureComponent<HintProps, HintState> {
|
|
60
|
+
export declare class Hint extends React.PureComponent<HintProps, HintState> implements InstanceWithAnchorElement {
|
|
59
61
|
static __KONTUR_REACT_UI__: string;
|
|
60
62
|
private isMobileLayout;
|
|
61
63
|
static defaultProps: {
|
|
@@ -70,11 +72,13 @@ export declare class Hint extends React.PureComponent<HintProps, HintState> {
|
|
|
70
72
|
private timer;
|
|
71
73
|
private theme;
|
|
72
74
|
private setRootNode;
|
|
75
|
+
private popupRef;
|
|
73
76
|
componentDidUpdate(prevProps: HintProps): void;
|
|
74
77
|
componentWillUnmount(): void;
|
|
75
78
|
render(): JSX.Element;
|
|
76
79
|
renderMobile(): JSX.Element;
|
|
77
80
|
renderMain(): JSX.Element;
|
|
81
|
+
getAnchorElement: () => Nullable<HTMLElement>;
|
|
78
82
|
private renderContent;
|
|
79
83
|
private getPositions;
|
|
80
84
|
private handleMouseEnter;
|
|
@@ -12,6 +12,7 @@ var _Emotion = require("../../lib/theming/Emotion");
|
|
|
12
12
|
var _decorator = require("../ResponsiveLayout/decorator");
|
|
13
13
|
var _rootNode = require("../../lib/rootNode");
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
var _Hint = require("./Hint.styles");var _class, _class2, _temp;
|
|
16
17
|
|
|
17
18
|
var HINT_BORDER_COLOR = 'transparent';
|
|
@@ -110,6 +111,9 @@ Hint = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)(_class
|
|
|
110
111
|
|
|
111
112
|
|
|
112
113
|
|
|
114
|
+
popupRef = /*#__PURE__*/_react.default.createRef();_this.
|
|
115
|
+
|
|
116
|
+
|
|
113
117
|
|
|
114
118
|
|
|
115
119
|
|
|
@@ -191,6 +195,10 @@ Hint = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)(_class
|
|
|
191
195
|
|
|
192
196
|
|
|
193
197
|
|
|
198
|
+
|
|
199
|
+
getAnchorElement = function () {var _this$popupRef$curren;
|
|
200
|
+
return (_this$popupRef$curren = _this.popupRef.current) == null ? void 0 : _this$popupRef$curren.anchorElement;
|
|
201
|
+
};_this.
|
|
194
202
|
|
|
195
203
|
|
|
196
204
|
|
|
@@ -242,4 +250,4 @@ Hint = (0, _decorator.responsiveLayout)(_class = (0, _rootNode.rootNode)(_class
|
|
|
242
250
|
|
|
243
251
|
open = function () {
|
|
244
252
|
_this.setState({ opened: true });
|
|
245
|
-
};return _this;}var _proto = Hint.prototype;_proto.componentDidUpdate = function componentDidUpdate(prevProps) {if (!this.props.manual) {return;}if (this.timer) {clearTimeout(this.timer);this.timer = null;}if (this.props.opened !== prevProps.opened) {this.setState({ opened: !!this.props.opened });}};_proto.componentWillUnmount = function componentWillUnmount() {if (this.timer) {clearTimeout(this.timer);this.timer = null;}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value: _ThemeFactory.ThemeFactory.create({ popupPinOffset: theme.hintPinOffset, popupMargin: theme.hintMargin, popupBorder: theme.hintBorder, popupBorderRadius: theme.hintBorderRadius }, _this2.theme) }, _this2.isMobileLayout ? _this2.renderMobile() : _this2.renderMain());});};_proto.renderMobile = function renderMobile() {return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, this.props, /*#__PURE__*/_react.default.createElement(_Popup.Popup, { opened: this.state.opened, anchorElement: this.props.children, positions: [], onClick: !this.props.manual ? this.open : undefined, mobileOnCloseRequest: !this.props.manual ? this.close : undefined }, this.renderContent()));};_proto.renderMain = function renderMain() {return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), /*#__PURE__*/_react.default.createElement(_Popup.Popup, { hasPin: true, opened: this.state.opened, anchorElement: this.props.children, positions: this.getPositions(), backgroundColor: this.theme.hintBgColor, borderColor: HINT_BORDER_COLOR, disableAnimations: this.props.disableAnimations, onMouseEnter: this.handleMouseEnter, onMouseLeave: this.handleMouseLeave, useWrapper: this.props.useWrapper }, this.renderContent()));};_proto.renderContent = function renderContent() {var _cx;if (!this.props.text) {return null;}var _this$props = this.props,pos = _this$props.pos,maxWidth = _this$props.maxWidth;var className = (0, _Emotion.cx)((_cx = {}, _cx[_Hint.styles.content(this.theme)] = true, _cx[_Hint.styles.contentCenter(this.theme)] = pos === 'top' || pos === 'bottom', _cx[_Hint.styles.mobileContent(this.theme)] = this.isMobileLayout, _cx));return /*#__PURE__*/_react.default.createElement("div", { className: className, style: { maxWidth: this.isMobileLayout ? '100%' : maxWidth } }, this.props.text);};return Hint;}(_react.default.PureComponent), _class2.__KONTUR_REACT_UI__ = 'Hint', _class2.defaultProps = { pos: 'top', manual: false, opened: false, maxWidth: 200, disableAnimations: _currentEnvironment.isTestEnv, useWrapper: false }, _temp)) || _class) || _class;exports.Hint = Hint;
|
|
253
|
+
};return _this;}var _proto = Hint.prototype;_proto.componentDidUpdate = function componentDidUpdate(prevProps) {if (!this.props.manual) {return;}if (this.timer) {clearTimeout(this.timer);this.timer = null;}if (this.props.opened !== prevProps.opened) {this.setState({ opened: !!this.props.opened });}};_proto.componentWillUnmount = function componentWillUnmount() {if (this.timer) {clearTimeout(this.timer);this.timer = null;}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value: _ThemeFactory.ThemeFactory.create({ popupPinOffset: theme.hintPinOffset, popupMargin: theme.hintMargin, popupBorder: theme.hintBorder, popupBorderRadius: theme.hintBorderRadius }, _this2.theme) }, _this2.isMobileLayout ? _this2.renderMobile() : _this2.renderMain());});};_proto.renderMobile = function renderMobile() {return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, this.props, /*#__PURE__*/_react.default.createElement(_Popup.Popup, { opened: this.state.opened, anchorElement: this.props.children, positions: [], onClick: !this.props.manual ? this.open : undefined, mobileOnCloseRequest: !this.props.manual ? this.close : undefined }, this.renderContent()));};_proto.renderMain = function renderMain() {return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), /*#__PURE__*/_react.default.createElement(_Popup.Popup, { hasPin: true, opened: this.state.opened, anchorElement: this.props.children, positions: this.getPositions(), backgroundColor: this.theme.hintBgColor, borderColor: HINT_BORDER_COLOR, disableAnimations: this.props.disableAnimations, onMouseEnter: this.handleMouseEnter, onMouseLeave: this.handleMouseLeave, useWrapper: this.props.useWrapper, ref: this.popupRef }, this.renderContent()));};_proto.renderContent = function renderContent() {var _cx;if (!this.props.text) {return null;}var _this$props = this.props,pos = _this$props.pos,maxWidth = _this$props.maxWidth;var className = (0, _Emotion.cx)((_cx = {}, _cx[_Hint.styles.content(this.theme)] = true, _cx[_Hint.styles.contentCenter(this.theme)] = pos === 'top' || pos === 'bottom', _cx[_Hint.styles.mobileContent(this.theme)] = this.isMobileLayout, _cx));return /*#__PURE__*/_react.default.createElement("div", { className: className, style: { maxWidth: this.isMobileLayout ? '100%' : maxWidth } }, this.props.text);};return Hint;}(_react.default.PureComponent), _class2.__KONTUR_REACT_UI__ = 'Hint', _class2.defaultProps = { pos: 'top', manual: false, opened: false, maxWidth: 200, disableAnimations: _currentEnvironment.isTestEnv, useWrapper: false }, _temp)) || _class) || _class;exports.Hint = Hint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Hint.tsx"],"names":["HINT_BORDER_COLOR","Positions","Hint","responsiveLayout","rootNode","state","opened","props","manual","timer","getPositions","filter","x","startsWith","pos","handleMouseEnter","e","window","setTimeout","open","onMouseEnter","handleMouseLeave","clearTimeout","setState","onMouseLeave","close","componentDidUpdate","prevProps","componentWillUnmount","render","theme","ThemeFactory","create","popupPinOffset","hintPinOffset","popupMargin","hintMargin","popupBorder","hintBorder","popupBorderRadius","hintBorderRadius","isMobileLayout","renderMobile","renderMain","children","undefined","renderContent","setRootNode","hintBgColor","disableAnimations","useWrapper","text","maxWidth","className","styles","content","contentCenter","mobileContent","React","PureComponent","__KONTUR_REACT_UI__","defaultProps","isTestEnv"],"mappings":"kUAAA;;AAEA;AACA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA,qC;;AAEA,IAAMA,iBAAiB,GAAG,aAA1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,IAAMC,SAA+B,GAAG;AACtC,YADsC;AAEtC,UAFsC;AAGtC,WAHsC;AAItC,eAJsC;AAKtC,aALsC;AAMtC,cANsC;AAOtC,aAPsC;AAQtC,UARsC;AAStC,aATsC;AAUtC,cAVsC;AAWtC,WAXsC;AAYtC,cAZsC,CAAxC;;;AAeA;AACA;AACA,G;;;AAGaC,I,OAFZC,2B,eACAC,kB;;;;;;;;;;;;;;AAeQC,IAAAA,K,GAAmB;AACxBC,MAAAA,MAAM,EAAE,MAAKC,KAAL,CAAWC,MAAX,GAAoB,CAAC,CAAC,MAAKD,KAAL,CAAWD,MAAjC,GAA0C,KAD1B,E;;;AAIlBG,IAAAA,K,GAA0B,I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwG1BC,IAAAA,Y,GAAe,YAA4B;AACjD,aAAOT,SAAS,CAACU,MAAV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,UAItBC,Y,GAAe,EAC3B/C,GAAG,EAAE,KADsB,EAE3BN,MAAM,EAAE,KAFmB,EAG3BF,MAAM,EAAE,KAHmB,EAI3B8C,QAAQ,EAAE,GAJiB,EAK3BH,iBAAiB,EAAEa,6BALQ,EAM3BZ,UAAU,EAAE,KANe,E","sourcesContent":["import React from 'react';\n\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { ThemeFactory } from '../../lib/theming/ThemeFactory';\nimport { Theme } from '../../lib/theming/Theme';\nimport { Popup, PopupPositionsType } from '../../internal/Popup';\nimport { Nullable } from '../../typings/utility-types';\nimport { MouseEventType } from '../../typings/event-types';\nimport { isTestEnv } from '../../lib/currentEnvironment';\nimport { CommonWrapper, CommonProps } from '../../internal/CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { responsiveLayout } from '../ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\n\nimport { styles } from './Hint.styles';\n\nconst HINT_BORDER_COLOR = 'transparent';\n\nexport interface HintProps extends CommonProps {\n children?: React.ReactNode;\n /**\n * Переводит отображение подсказки в _\"ручной режим\"_.\n *\n * В _\"ручном режиме\"_ подсказку можно активировать только задав значение пропу `opened`.\n */\n manual?: boolean;\n /**\n * Задаёт максимальную ширину подсказки.\n */\n maxWidth?: React.CSSProperties['maxWidth'];\n /**\n * HTML-событие `mouseenter`.\n */\n onMouseEnter?: (event: MouseEventType) => void;\n /**\n * HTML-событие `mouseleave`.\n */\n onMouseLeave?: (event: MouseEventType) => void;\n /**\n * Если `true` - подсказка будет открыта.\n *\n * _Примечание_: работает только при `manual=true`.\n */\n opened?: boolean;\n /**\n * Расположение подсказки относительно текста.\n *\n * **Допустимые значения**: `\"top\"`, `\"right\"`, `\"bottom\"`, `\"left\"`, `\"top left\"`, `\"top center\"`, `\"top right\"`, `\"right top\"`, `\"right middle\"`, `\"right bottom\"`, `\"bottom left\"`, `\"bottom center\"`, `\"bottom right\"`, `\"left top\"`, `\"left middle\"`, `\"left bottom\"`.\n */\n pos: 'top' | 'right' | 'bottom' | 'left' | PopupPositionsType;\n /**\n * Текст подсказки.\n */\n text: React.ReactNode;\n /**\n * Отключает анимацию.\n */\n disableAnimations: boolean;\n /**\n * Явно указывает, что вложенные элементы должны быть обёрнуты в `<span/>`. <br/> Используется для корректного позиционирования тултипа при двух и более вложенных элементах.\n *\n * _Примечание_: при **двух и более** вложенных элементах обёртка будет добавлена автоматически.\n */\n useWrapper: boolean;\n}\n\nexport interface HintState {\n opened: boolean;\n}\n\nconst Positions: PopupPositionsType[] = [\n 'top center',\n 'top left',\n 'top right',\n 'bottom center',\n 'bottom left',\n 'bottom right',\n 'left middle',\n 'left top',\n 'left bottom',\n 'right middle',\n 'right top',\n 'right bottom',\n];\n\n/**\n * Всплывающая подсказка, которая по умолчанию отображается при наведении на элемент. <br/> Можно задать другие условия отображения.\n */\n@responsiveLayout\n@rootNode\nexport class Hint extends React.PureComponent<HintProps, HintState> {\n public static __KONTUR_REACT_UI__ = 'Hint';\n\n private isMobileLayout!: boolean;\n\n public static defaultProps = {\n pos: 'top',\n manual: false,\n opened: false,\n maxWidth: 200,\n disableAnimations: isTestEnv,\n useWrapper: false,\n };\n\n public state: HintState = {\n opened: this.props.manual ? !!this.props.opened : false,\n };\n\n private timer: Nullable<number> = null;\n private theme!: Theme;\n private setRootNode!: TSetRootNode;\n\n public componentDidUpdate(prevProps: HintProps) {\n if (!this.props.manual) {\n return;\n }\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n if (this.props.opened !== prevProps.opened) {\n this.setState({ opened: !!this.props.opened });\n }\n }\n\n public componentWillUnmount() {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <ThemeContext.Provider\n value={ThemeFactory.create(\n {\n popupPinOffset: theme.hintPinOffset,\n popupMargin: theme.hintMargin,\n popupBorder: theme.hintBorder,\n popupBorderRadius: theme.hintBorderRadius,\n },\n this.theme,\n )}\n >\n {this.isMobileLayout ? this.renderMobile() : this.renderMain()}\n </ThemeContext.Provider>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMobile() {\n return (\n <CommonWrapper {...this.props}>\n <Popup\n opened={this.state.opened}\n anchorElement={this.props.children}\n positions={[]}\n onClick={!this.props.manual ? this.open : undefined}\n mobileOnCloseRequest={!this.props.manual ? this.close : undefined}\n >\n {this.renderContent()}\n </Popup>\n </CommonWrapper>\n );\n }\n\n public renderMain() {\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <Popup\n hasPin\n opened={this.state.opened}\n anchorElement={this.props.children}\n positions={this.getPositions()}\n backgroundColor={this.theme.hintBgColor}\n borderColor={HINT_BORDER_COLOR}\n disableAnimations={this.props.disableAnimations}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n useWrapper={this.props.useWrapper}\n >\n {this.renderContent()}\n </Popup>\n </CommonWrapper>\n );\n }\n\n private renderContent() {\n if (!this.props.text) {\n return null;\n }\n\n const { pos, maxWidth } = this.props;\n const className = cx({\n [styles.content(this.theme)]: true,\n [styles.contentCenter(this.theme)]: pos === 'top' || pos === 'bottom',\n [styles.mobileContent(this.theme)]: this.isMobileLayout,\n });\n return (\n <div className={className} style={{ maxWidth: this.isMobileLayout ? '100%' : maxWidth }}>\n {this.props.text}\n </div>\n );\n }\n\n private getPositions = (): PopupPositionsType[] => {\n return Positions.filter((x) => x.startsWith(this.props.pos));\n };\n\n private handleMouseEnter = (e: MouseEventType) => {\n if (!this.props.manual && !this.timer) {\n this.timer = window.setTimeout(this.open, 400);\n }\n\n if (this.props.onMouseEnter) {\n this.props.onMouseEnter(e);\n }\n };\n\n private handleMouseLeave = (e: MouseEventType) => {\n if (!this.props.manual && this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n this.setState({ opened: false });\n }\n\n if (this.props.onMouseLeave) {\n this.props.onMouseLeave(e);\n }\n };\n\n private close = () => {\n this.setState({ opened: false });\n };\n\n private open = () => {\n this.setState({ opened: true });\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["Hint.tsx"],"names":["HINT_BORDER_COLOR","Positions","Hint","responsiveLayout","rootNode","state","opened","props","manual","timer","popupRef","React","createRef","getAnchorElement","current","anchorElement","getPositions","filter","x","startsWith","pos","handleMouseEnter","e","window","setTimeout","open","onMouseEnter","handleMouseLeave","clearTimeout","setState","onMouseLeave","close","componentDidUpdate","prevProps","componentWillUnmount","render","theme","ThemeFactory","create","popupPinOffset","hintPinOffset","popupMargin","hintMargin","popupBorder","hintBorder","popupBorderRadius","hintBorderRadius","isMobileLayout","renderMobile","renderMain","children","undefined","renderContent","setRootNode","hintBgColor","disableAnimations","useWrapper","text","maxWidth","className","styles","content","contentCenter","mobileContent","PureComponent","__KONTUR_REACT_UI__","defaultProps","isTestEnv"],"mappings":"kUAAA;;AAEA;AACA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;;;AAGA,qC;;AAEA,IAAMA,iBAAiB,GAAG,aAA1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,IAAMC,SAA+B,GAAG;AACtC,YADsC;AAEtC,UAFsC;AAGtC,WAHsC;AAItC,eAJsC;AAKtC,aALsC;AAMtC,cANsC;AAOtC,aAPsC;AAQtC,UARsC;AAStC,aATsC;AAUtC,cAVsC;AAWtC,WAXsC;AAYtC,cAZsC,CAAxC;;;AAeA;AACA;AACA,G;;;AAGaC,I,OAFZC,2B,eACAC,kB;;;;;;;;;;;;;;AAeQC,IAAAA,K,GAAmB;AACxBC,MAAAA,MAAM,EAAE,MAAKC,KAAL,CAAWC,MAAX,GAAoB,CAAC,CAAC,MAAKD,KAAL,CAAWD,MAAjC,GAA0C,KAD1B,E;;;AAIlBG,IAAAA,K,GAA0B,I;;;;AAI1BC,IAAAA,Q,gBAAWC,eAAMC,SAAN,E;;;;;;;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GAAG,KAAK,KAAR,IAAiBA,GAAG,KAAK,QAF7C,MAGfwC,aAAOG,aAAP,CAAqB,KAAK3B,KAA1B,CAHe,IAGoB,KAAKW,cAHzB,OAAlB,CAKA,oBACE,sCAAK,SAAS,EAAEY,SAAhB,EAA2B,KAAK,EAAE,EAAED,QAAQ,EAAE,KAAKX,cAAL,GAAsB,MAAtB,GAA+BW,QAA3C,EAAlC,IACG,KAAKnD,KAAL,CAAWkD,IADd,CADF,CAKD,C,eA/HuB9C,eAAMqD,a,WAChBC,mB,GAAsB,M,UAItBC,Y,GAAe,EAC3B9C,GAAG,EAAE,KADsB,EAE3BZ,MAAM,EAAE,KAFmB,EAG3BF,MAAM,EAAE,KAHmB,EAI3BoD,QAAQ,EAAE,GAJiB,EAK3BH,iBAAiB,EAAEY,6BALQ,EAM3BX,UAAU,EAAE,KANe,E","sourcesContent":["import React from 'react';\n\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { ThemeFactory } from '../../lib/theming/ThemeFactory';\nimport { Theme } from '../../lib/theming/Theme';\nimport { Popup, PopupPositionsType } from '../../internal/Popup';\nimport { Nullable } from '../../typings/utility-types';\nimport { MouseEventType } from '../../typings/event-types';\nimport { isTestEnv } from '../../lib/currentEnvironment';\nimport { CommonWrapper, CommonProps } from '../../internal/CommonWrapper';\nimport { cx } from '../../lib/theming/Emotion';\nimport { responsiveLayout } from '../ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { InstanceWithAnchorElement } from '../../lib/InstanceWithAnchorElement';\n\nimport { styles } from './Hint.styles';\n\nconst HINT_BORDER_COLOR = 'transparent';\n\nexport interface HintProps extends CommonProps {\n children?: React.ReactNode;\n /**\n * Переводит отображение подсказки в _\"ручной режим\"_.\n *\n * В _\"ручном режиме\"_ подсказку можно активировать только задав значение пропу `opened`.\n */\n manual?: boolean;\n /**\n * Задаёт максимальную ширину подсказки.\n */\n maxWidth?: React.CSSProperties['maxWidth'];\n /**\n * HTML-событие `mouseenter`.\n */\n onMouseEnter?: (event: MouseEventType) => void;\n /**\n * HTML-событие `mouseleave`.\n */\n onMouseLeave?: (event: MouseEventType) => void;\n /**\n * Если `true` - подсказка будет открыта.\n *\n * _Примечание_: работает только при `manual=true`.\n */\n opened?: boolean;\n /**\n * Расположение подсказки относительно текста.\n *\n * **Допустимые значения**: `\"top\"`, `\"right\"`, `\"bottom\"`, `\"left\"`, `\"top left\"`, `\"top center\"`, `\"top right\"`, `\"right top\"`, `\"right middle\"`, `\"right bottom\"`, `\"bottom left\"`, `\"bottom center\"`, `\"bottom right\"`, `\"left top\"`, `\"left middle\"`, `\"left bottom\"`.\n */\n pos: 'top' | 'right' | 'bottom' | 'left' | PopupPositionsType;\n /**\n * Текст подсказки.\n */\n text: React.ReactNode;\n /**\n * Отключает анимацию.\n */\n disableAnimations: boolean;\n /**\n * Явно указывает, что вложенные элементы должны быть обёрнуты в `<span/>`. <br/> Используется для корректного позиционирования тултипа при двух и более вложенных элементах.\n *\n * _Примечание_: при **двух и более** вложенных элементах обёртка будет добавлена автоматически.\n */\n useWrapper: boolean;\n}\n\nexport interface HintState {\n opened: boolean;\n}\n\nconst Positions: PopupPositionsType[] = [\n 'top center',\n 'top left',\n 'top right',\n 'bottom center',\n 'bottom left',\n 'bottom right',\n 'left middle',\n 'left top',\n 'left bottom',\n 'right middle',\n 'right top',\n 'right bottom',\n];\n\n/**\n * Всплывающая подсказка, которая по умолчанию отображается при наведении на элемент. <br/> Можно задать другие условия отображения.\n */\n@responsiveLayout\n@rootNode\nexport class Hint extends React.PureComponent<HintProps, HintState> implements InstanceWithAnchorElement {\n public static __KONTUR_REACT_UI__ = 'Hint';\n\n private isMobileLayout!: boolean;\n\n public static defaultProps = {\n pos: 'top',\n manual: false,\n opened: false,\n maxWidth: 200,\n disableAnimations: isTestEnv,\n useWrapper: false,\n };\n\n public state: HintState = {\n opened: this.props.manual ? !!this.props.opened : false,\n };\n\n private timer: Nullable<number> = null;\n private theme!: Theme;\n private setRootNode!: TSetRootNode;\n\n private popupRef = React.createRef<Popup>();\n\n public componentDidUpdate(prevProps: HintProps) {\n if (!this.props.manual) {\n return;\n }\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n if (this.props.opened !== prevProps.opened) {\n this.setState({ opened: !!this.props.opened });\n }\n }\n\n public componentWillUnmount() {\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <ThemeContext.Provider\n value={ThemeFactory.create(\n {\n popupPinOffset: theme.hintPinOffset,\n popupMargin: theme.hintMargin,\n popupBorder: theme.hintBorder,\n popupBorderRadius: theme.hintBorderRadius,\n },\n this.theme,\n )}\n >\n {this.isMobileLayout ? this.renderMobile() : this.renderMain()}\n </ThemeContext.Provider>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMobile() {\n return (\n <CommonWrapper {...this.props}>\n <Popup\n opened={this.state.opened}\n anchorElement={this.props.children}\n positions={[]}\n onClick={!this.props.manual ? this.open : undefined}\n mobileOnCloseRequest={!this.props.manual ? this.close : undefined}\n >\n {this.renderContent()}\n </Popup>\n </CommonWrapper>\n );\n }\n\n public renderMain() {\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <Popup\n hasPin\n opened={this.state.opened}\n anchorElement={this.props.children}\n positions={this.getPositions()}\n backgroundColor={this.theme.hintBgColor}\n borderColor={HINT_BORDER_COLOR}\n disableAnimations={this.props.disableAnimations}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n useWrapper={this.props.useWrapper}\n ref={this.popupRef}\n >\n {this.renderContent()}\n </Popup>\n </CommonWrapper>\n );\n }\n\n public getAnchorElement = (): Nullable<HTMLElement> => {\n return this.popupRef.current?.anchorElement;\n };\n\n private renderContent() {\n if (!this.props.text) {\n return null;\n }\n\n const { pos, maxWidth } = this.props;\n const className = cx({\n [styles.content(this.theme)]: true,\n [styles.contentCenter(this.theme)]: pos === 'top' || pos === 'bottom',\n [styles.mobileContent(this.theme)]: this.isMobileLayout,\n });\n return (\n <div className={className} style={{ maxWidth: this.isMobileLayout ? '100%' : maxWidth }}>\n {this.props.text}\n </div>\n );\n }\n\n private getPositions = (): PopupPositionsType[] => {\n return Positions.filter((x) => x.startsWith(this.props.pos));\n };\n\n private handleMouseEnter = (e: MouseEventType) => {\n if (!this.props.manual && !this.timer) {\n this.timer = window.setTimeout(this.open, 400);\n }\n\n if (this.props.onMouseEnter) {\n this.props.onMouseEnter(e);\n }\n };\n\n private handleMouseLeave = (e: MouseEventType) => {\n if (!this.props.manual && this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n this.setState({ opened: false });\n }\n\n if (this.props.onMouseLeave) {\n this.props.onMouseLeave(e);\n }\n };\n\n private close = () => {\n this.setState({ opened: false });\n };\n\n private open = () => {\n this.setState({ opened: true });\n };\n}\n"]}
|
|
@@ -83,7 +83,7 @@ export interface InputProps extends CommonProps, Override<React.InputHTMLAttribu
|
|
|
83
83
|
export interface InputState {
|
|
84
84
|
blinking: boolean;
|
|
85
85
|
focused: boolean;
|
|
86
|
-
|
|
86
|
+
needsPolyfillPlaceholder: boolean;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Интерфейс пропсов наследуется от `React.InputHTMLAttributes<HTMLInputElement>`.
|
|
@@ -100,11 +100,7 @@ export declare class Input extends React.Component<InputProps, InputState> {
|
|
|
100
100
|
private blinkTimeout;
|
|
101
101
|
private input;
|
|
102
102
|
private setRootNode;
|
|
103
|
-
componentDidMount(): void;
|
|
104
103
|
componentWillUnmount(): void;
|
|
105
|
-
static getDerivedStateFromProps(props: InputProps, state: InputState): InputState | {
|
|
106
|
-
polyfillPlaceholder: boolean;
|
|
107
|
-
};
|
|
108
104
|
/**
|
|
109
105
|
* @public
|
|
110
106
|
*/
|
|
@@ -4,7 +4,7 @@ var _raf = _interopRequireDefault(require("raf"));
|
|
|
4
4
|
|
|
5
5
|
var _client = require("../../lib/client");
|
|
6
6
|
var _identifiers = require("../../lib/events/keyboard/identifiers");
|
|
7
|
-
var
|
|
7
|
+
var _needsPolyfillPlaceholder = require("../../lib/needsPolyfillPlaceholder");
|
|
8
8
|
|
|
9
9
|
var _MaskedInput = require("../../internal/MaskedInput");
|
|
10
10
|
var _ThemeContext = require("../../lib/theming/ThemeContext");
|
|
@@ -122,7 +122,7 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
state = {
|
|
125
|
-
|
|
125
|
+
needsPolyfillPlaceholder: _needsPolyfillPlaceholder.needsPolyfillPlaceholder,
|
|
126
126
|
blinking: false,
|
|
127
127
|
focused: false };_this.
|
|
128
128
|
|
|
@@ -208,19 +208,6 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
208
208
|
|
|
209
209
|
|
|
210
210
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
211
|
|
|
225
212
|
|
|
226
213
|
|
|
@@ -330,7 +317,7 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
330
317
|
style: { textAlign: align },
|
|
331
318
|
ref: _this.refInput,
|
|
332
319
|
type: 'text',
|
|
333
|
-
placeholder: !_this.isMaskVisible && !
|
|
320
|
+
placeholder: !_this.isMaskVisible && !_needsPolyfillPlaceholder.needsPolyfillPlaceholder ? placeholder : undefined,
|
|
334
321
|
disabled: disabled });
|
|
335
322
|
|
|
336
323
|
|
|
@@ -452,6 +439,12 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
452
439
|
|
|
453
440
|
|
|
454
441
|
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
|
|
455
448
|
|
|
456
449
|
|
|
457
450
|
|
|
@@ -468,10 +461,10 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
468
461
|
};_this.
|
|
469
462
|
|
|
470
463
|
handleChange = function (event) {
|
|
471
|
-
if (
|
|
464
|
+
if (_needsPolyfillPlaceholder.needsPolyfillPlaceholder) {
|
|
472
465
|
var fieldIsEmpty = event.target.value === '';
|
|
473
|
-
if (_this.state.
|
|
474
|
-
_this.setState({
|
|
466
|
+
if (_this.state.needsPolyfillPlaceholder !== fieldIsEmpty) {
|
|
467
|
+
_this.setState({ needsPolyfillPlaceholder: fieldIsEmpty });
|
|
475
468
|
}
|
|
476
469
|
}
|
|
477
470
|
|
|
@@ -565,7 +558,7 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
565
558
|
return /*#__PURE__*/(
|
|
566
559
|
_react.default.createElement("span", { className: (0, _Emotion.cx)(_Input.styles.suffix(_this.theme), (_cx4 = {}, _cx4[_Input.styles.suffixDisabled(_this.theme)] = disabled, _cx4)) }, suffix));
|
|
567
560
|
|
|
568
|
-
};return _this;}var _proto = Input.prototype;_proto.
|
|
561
|
+
};return _this;}var _proto = Input.prototype;_proto.componentWillUnmount = function componentWillUnmount() {if (this.blinkTimeout) {clearTimeout(this.blinkTimeout);}this.cancelDelayedSelectAll();} /**
|
|
569
562
|
* @public
|
|
570
563
|
*/;_proto.focus = function focus() {(0, _invariant.default)(this.input, 'Cannot call "focus" because Input is not mounted');this.input.focus();} /**
|
|
571
564
|
* @public
|
|
@@ -581,4 +574,4 @@ Input = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functio
|
|
|
581
574
|
* @param {number} end
|
|
582
575
|
*/;_proto.setSelectionRange = function setSelectionRange(start, end) {if (!this.input) {throw new Error('Cannot call "setSelectionRange" on unmounted Input');}if (document.activeElement !== this.input) {this.focus();}this.input.setSelectionRange(start, end);};_proto.render = function render() {var _this3 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this3.theme = theme;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: _this3.setRootNode }, _this3.props), _this3.renderMain);});} /**
|
|
583
576
|
* @public
|
|
584
|
-
*/;_proto.renderMaskedInput = function renderMaskedInput(inputProps, mask) {return /*#__PURE__*/_react.default.createElement(_MaskedInput.MaskedInput, (0, _extends2.default)({}, inputProps, { mask: mask, maskChar: this.props.maskChar, alwaysShowMask: this.props.alwaysShowMask, formatChars: this.props.formatChars, onChange: this.props.onChange, onValueChange: this.handleMaskedValueChange, onUnexpectedInput: this.handleUnexpectedInput }));};_proto.getIconSizeClassname = function getIconSizeClassname(right) {if (right === void 0) {right = false;}switch (this.props.size) {case 'large':return right ? _Input.styles.rightIconLarge(this.theme) : _Input.styles.leftIconLarge(this.theme);case 'medium':return right ? _Input.styles.rightIconMedium(this.theme) : _Input.styles.leftIconMedium(this.theme);case 'small':default:return right ? _Input.styles.rightIconSmall(this.theme) : _Input.styles.leftIconSmall(this.theme);}};_proto.renderLeftIcon = function renderLeftIcon() {return this.renderIcon(this.props.leftIcon, this.getIconSizeClassname());};_proto.renderRightIcon = function renderRightIcon() {return this.renderIcon(this.props.rightIcon, this.getIconSizeClassname(true));};_proto.renderIcon = function renderIcon(icon, sizeClassName) {var _cx5;if (!icon) {return null;}var disabled = this.props.disabled;var iconNode = icon instanceof Function ? icon() : icon;return /*#__PURE__*/_react.default.createElement("span", { className: (0, _Emotion.cx)(_Input.styles.icon(), sizeClassName, _Input.styles.useDefaultColor(this.theme), (_cx5 = {}, _cx5[_Input.styles.iconDisabled()] = disabled, _cx5)) }, iconNode);};_proto.renderPlaceholder = function renderPlaceholder() {var disabled = this.props.disabled;var focused = this.state.focused;var placeholder = null;if (this.state.
|
|
577
|
+
*/;_proto.renderMaskedInput = function renderMaskedInput(inputProps, mask) {return /*#__PURE__*/_react.default.createElement(_MaskedInput.MaskedInput, (0, _extends2.default)({}, inputProps, { mask: mask, maskChar: this.props.maskChar, alwaysShowMask: this.props.alwaysShowMask, formatChars: this.props.formatChars, onChange: this.props.onChange, onValueChange: this.handleMaskedValueChange, onUnexpectedInput: this.handleUnexpectedInput }));};_proto.getIconSizeClassname = function getIconSizeClassname(right) {if (right === void 0) {right = false;}switch (this.props.size) {case 'large':return right ? _Input.styles.rightIconLarge(this.theme) : _Input.styles.leftIconLarge(this.theme);case 'medium':return right ? _Input.styles.rightIconMedium(this.theme) : _Input.styles.leftIconMedium(this.theme);case 'small':default:return right ? _Input.styles.rightIconSmall(this.theme) : _Input.styles.leftIconSmall(this.theme);}};_proto.renderLeftIcon = function renderLeftIcon() {return this.renderIcon(this.props.leftIcon, this.getIconSizeClassname());};_proto.renderRightIcon = function renderRightIcon() {return this.renderIcon(this.props.rightIcon, this.getIconSizeClassname(true));};_proto.renderIcon = function renderIcon(icon, sizeClassName) {var _cx5;if (!icon) {return null;}var disabled = this.props.disabled;var iconNode = icon instanceof Function ? icon() : icon;return /*#__PURE__*/_react.default.createElement("span", { className: (0, _Emotion.cx)(_Input.styles.icon(), sizeClassName, _Input.styles.useDefaultColor(this.theme), (_cx5 = {}, _cx5[_Input.styles.iconDisabled()] = disabled, _cx5)) }, iconNode);};_proto.renderPlaceholder = function renderPlaceholder() {var disabled = this.props.disabled;var focused = this.state.focused;var placeholder = null;if (this.state.needsPolyfillPlaceholder && this.props.placeholder && !this.isMaskVisible && !this.props.value && !this.props.defaultValue) {var _cx6;placeholder = /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)(_Input.styles.placeholder(this.theme), (_cx6 = {}, _cx6[_Input.styles.placeholderDisabled(this.theme)] = disabled, _cx6[_Input.styles.placeholderFocus(this.theme)] = focused, _cx6)), style: { textAlign: this.props.align || 'inherit' } }, this.props.placeholder);}return placeholder;};_proto.getSizeClassName = function getSizeClassName() {var _cx7, _cx8, _cx9;switch (this.props.size) {case 'large':return (0, _Emotion.cx)((_cx7 = {}, _cx7[_Input.styles.sizeLarge(this.theme)] = true, _cx7[_Input.styles.sizeLargeFallback(this.theme)] = _client.isIE11 || _client.isEdge, _cx7));case 'medium':return (0, _Emotion.cx)((_cx8 = {}, _cx8[_Input.styles.sizeMedium(this.theme)] = true, _cx8[_Input.styles.sizeMediumFallback(this.theme)] = _client.isIE11 || _client.isEdge, _cx8));case 'small':default:return (0, _Emotion.cx)((_cx9 = {}, _cx9[_Input.styles.sizeSmall(this.theme)] = true, _cx9[_Input.styles.sizeSmallFallback(this.theme)] = _client.isIE11 || _client.isEdge, _cx9));}};(0, _createClass2.default)(Input, [{ key: "isMaskVisible", get: function get() {var _this$props3 = this.props,mask = _this$props3.mask,alwaysShowMask = _this$props3.alwaysShowMask;var focused = this.state.focused;return Boolean(mask && (focused || alwaysShowMask));} }]);return Input;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Input', _class2.defaultProps = { size: 'small' }, _temp)) || _class;exports.Input = Input;
|