@doist/reactist 9.2.0-beta.8 → 10.0.0-beta.12
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/README.md +12 -2
- package/dist/reactist.cjs.development.js +1499 -866
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/_virtual/_rollupPluginBabelHelpers.js +34 -20
- package/es/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/es/components/color-picker/color-picker.js +1 -1
- package/es/components/color-picker/color-picker.js.map +1 -1
- package/es/components/{button/button.js → deprecated-button/deprecated-button.js} +9 -4
- package/es/components/deprecated-button/deprecated-button.js.map +1 -0
- package/es/components/{button → deprecated-button}/index.js +1 -1
- package/es/components/{button → deprecated-button}/index.js.map +0 -0
- package/es/components/{loading/loading.js → deprecated-loading/deprecated-loading.js} +3 -1
- package/es/components/deprecated-loading/deprecated-loading.js.map +1 -0
- package/es/components/{modal/modal.js → deprecated-modal/deprecated-modal.js} +9 -2
- package/es/components/deprecated-modal/deprecated-modal.js.map +1 -0
- package/es/components/{modal → deprecated-modal}/index.js +1 -1
- package/es/components/deprecated-modal/index.js.map +1 -0
- package/es/components/dropdown/dropdown.js +8 -4
- package/es/components/dropdown/dropdown.js.map +1 -1
- package/es/components/error-message/error-message.js +4 -2
- package/es/components/error-message/error-message.js.map +1 -1
- package/es/components/icon/icon.js.map +1 -1
- package/es/components/key-capturer/key-capturer.js.map +1 -1
- package/es/components/keyboard-shortcut/keyboard-shortcut.js +6 -3
- package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/es/components/menu/menu.js +40 -27
- package/es/components/menu/menu.js.map +1 -1
- package/es/components/notification/notification.js +3 -1
- package/es/components/notification/notification.js.map +1 -1
- package/es/components/popover/popover.js.map +1 -1
- package/es/components/popover/positioning-utils.js.map +1 -1
- package/es/components/range-input/range-input.js +1 -1
- package/es/components/range-input/range-input.js.map +1 -1
- package/es/components/select/select.js +4 -2
- package/es/components/select/select.js.map +1 -1
- package/es/components/time/time-utils.js.map +1 -1
- package/es/components/time/time.js.map +1 -1
- package/es/components/tooltip/tooltip.js +3 -1
- package/es/components/tooltip/tooltip.js.map +1 -1
- package/es/hooks/use-previous/use-previous.js +26 -0
- package/es/hooks/use-previous/use-previous.js.map +1 -0
- package/es/index.js +11 -6
- package/es/index.js.map +1 -1
- package/es/new-components/base-button/base-button.js +72 -0
- package/es/new-components/base-button/base-button.js.map +1 -0
- package/es/new-components/base-button/base-button.module.css.js +4 -0
- package/es/new-components/base-button/base-button.module.css.js.map +1 -0
- package/es/new-components/base-field/base-field.js +29 -29
- package/es/new-components/base-field/base-field.js.map +1 -1
- package/es/new-components/base-field/base-field.module.css.js +1 -1
- package/es/new-components/box/box.js +29 -10
- package/es/new-components/box/box.js.map +1 -1
- package/es/new-components/box/box.module.css.js +1 -1
- package/es/new-components/box/margin.module.css.js +4 -0
- package/es/new-components/box/margin.module.css.js.map +1 -0
- package/es/new-components/box/padding.module.css.js +4 -0
- package/es/new-components/box/padding.module.css.js.map +1 -0
- package/es/new-components/button/button.js +41 -0
- package/es/new-components/button/button.js.map +1 -0
- package/es/new-components/button-link/button-link.js +26 -14
- package/es/new-components/button-link/button-link.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-field.js +46 -23
- package/es/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-field.module.css.js +1 -1
- package/es/new-components/checkbox-field/checkbox-icon.js +2 -1
- package/es/new-components/checkbox-field/checkbox-icon.js.map +1 -1
- package/es/new-components/columns/columns.js +28 -14
- package/es/new-components/columns/columns.js.map +1 -1
- package/es/new-components/columns/columns.module.css.js +1 -1
- package/es/new-components/divider/divider.js +6 -4
- package/es/new-components/divider/divider.js.map +1 -1
- package/es/new-components/divider/divider.module.css.js +1 -1
- package/es/new-components/heading/heading.js +10 -3
- package/es/new-components/heading/heading.js.map +1 -1
- package/es/new-components/heading/heading.module.css.js +1 -1
- package/es/new-components/hidden/hidden.js +55 -0
- package/es/new-components/hidden/hidden.js.map +1 -0
- package/es/new-components/hidden/hidden.module.css.js +4 -0
- package/es/new-components/hidden/hidden.module.css.js.map +1 -0
- package/es/new-components/hidden-visually/hidden-visually.js +22 -0
- package/es/new-components/hidden-visually/hidden-visually.js.map +1 -0
- package/es/new-components/hidden-visually/hidden-visually.module.css.js +4 -0
- package/es/new-components/hidden-visually/hidden-visually.module.css.js.map +1 -0
- package/es/new-components/icons/alert-icon.js +2 -1
- package/es/new-components/icons/alert-icon.js.map +1 -1
- package/es/new-components/inline/inline.js +10 -8
- package/es/new-components/inline/inline.js.map +1 -1
- package/es/new-components/loading/loading.js +34 -0
- package/es/new-components/loading/loading.js.map +1 -0
- package/es/new-components/modal/modal.js +206 -0
- package/es/new-components/modal/modal.js.map +1 -0
- package/es/new-components/modal/modal.module.css.js +4 -0
- package/es/new-components/modal/modal.module.css.js.map +1 -0
- package/es/new-components/password-field/password-field.js +8 -4
- package/es/new-components/password-field/password-field.js.map +1 -1
- package/es/new-components/responsive-props.js +21 -11
- package/es/new-components/responsive-props.js.map +1 -1
- package/es/new-components/select-field/select-field.js +13 -6
- package/es/new-components/select-field/select-field.js.map +1 -1
- package/es/new-components/select-field/select-field.module.css.js +1 -1
- package/es/new-components/spinner/spinner.js +26 -0
- package/es/new-components/spinner/spinner.js.map +1 -0
- package/es/new-components/spinner/spinner.module.css.js +4 -0
- package/es/new-components/spinner/spinner.module.css.js.map +1 -0
- package/es/new-components/stack/stack.js +23 -12
- package/es/new-components/stack/stack.js.map +1 -1
- package/es/new-components/switch-field/switch-field.js +48 -28
- package/es/new-components/switch-field/switch-field.js.map +1 -1
- package/es/new-components/switch-field/switch-field.module.css.js +1 -1
- package/es/new-components/tabs/tabs.js +147 -0
- package/es/new-components/tabs/tabs.js.map +1 -0
- package/es/new-components/tabs/tabs.module.css.js +4 -0
- package/es/new-components/tabs/tabs.module.css.js.map +1 -0
- package/es/new-components/text/text.js +16 -10
- package/es/new-components/text/text.js.map +1 -1
- package/es/new-components/text/text.module.css.js +1 -1
- package/es/new-components/text-area/text-area.js +3 -1
- package/es/new-components/text-area/text-area.js.map +1 -1
- package/es/new-components/text-area/text-area.module.css.js +1 -1
- package/es/new-components/text-field/text-field.js +5 -2
- package/es/new-components/text-field/text-field.js.map +1 -1
- package/es/new-components/text-field/text-field.module.css.js +1 -1
- package/es/new-components/text-link/text-link.js +9 -7
- package/es/new-components/text-link/text-link.js.map +1 -1
- package/es/utils/polymorphism.js +17 -0
- package/es/utils/polymorphism.js.map +1 -0
- package/lib/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/lib/components/color-picker/color-picker.js +1 -1
- package/lib/components/color-picker/color-picker.js.map +1 -1
- package/lib/components/{button/button.d.ts → deprecated-button/deprecated-button.d.ts} +7 -1
- package/lib/components/deprecated-button/deprecated-button.js +2 -0
- package/lib/components/deprecated-button/deprecated-button.js.map +1 -0
- package/lib/components/{button/button.test.d.ts → deprecated-button/deprecated-button.test.d.ts} +0 -0
- package/lib/components/deprecated-button/index.d.ts +4 -0
- package/lib/components/{loading → deprecated-button}/index.js +1 -1
- package/lib/components/{button → deprecated-button}/index.js.map +0 -0
- package/lib/components/{loading/loading.d.ts → deprecated-loading/deprecated-loading.d.ts} +2 -1
- package/lib/components/{loading/loading.js → deprecated-loading/deprecated-loading.js} +1 -1
- package/lib/components/deprecated-loading/deprecated-loading.js.map +1 -0
- package/lib/components/{loading/Loading.test.d.ts → deprecated-loading/deprecated-loading.test.d.ts} +0 -0
- package/lib/components/deprecated-loading/index.d.ts +1 -0
- package/lib/components/{modal/modal.d.ts → deprecated-modal/deprecated-modal.d.ts} +6 -1
- package/lib/components/{modal/modal.js → deprecated-modal/deprecated-modal.js} +2 -2
- package/lib/components/deprecated-modal/deprecated-modal.js.map +1 -0
- package/lib/components/{modal/modal.test.d.ts → deprecated-modal/deprecated-modal.test.d.ts} +0 -0
- package/lib/components/{modal → deprecated-modal}/index.d.ts +3 -3
- package/lib/components/deprecated-modal/index.js +2 -0
- package/lib/components/deprecated-modal/index.js.map +1 -0
- package/lib/components/dropdown/dropdown.js +1 -1
- package/lib/components/dropdown/dropdown.js.map +1 -1
- package/lib/components/error-message/error-message.js +1 -1
- package/lib/components/error-message/error-message.js.map +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/lib/components/menu/index.d.ts +1 -1
- package/lib/components/menu/menu.d.ts +8 -10
- package/lib/components/menu/menu.js +1 -1
- package/lib/components/menu/menu.js.map +1 -1
- package/lib/components/notification/notification.js +1 -1
- package/lib/components/notification/notification.js.map +1 -1
- package/lib/components/range-input/range-input.js +1 -1
- package/lib/components/range-input/range-input.js.map +1 -1
- package/lib/components/select/select.js +1 -1
- package/lib/components/select/select.js.map +1 -1
- package/lib/components/tooltip/index.d.ts +1 -1
- package/lib/components/tooltip/tooltip.js +1 -1
- package/lib/components/tooltip/tooltip.js.map +1 -1
- package/lib/hooks/use-previous/index.d.ts +1 -0
- package/lib/hooks/use-previous/use-previous.d.ts +15 -0
- package/lib/hooks/use-previous/use-previous.js +2 -0
- package/lib/hooks/use-previous/use-previous.js.map +1 -0
- package/lib/index.d.ts +10 -5
- package/lib/index.js +1 -1
- package/lib/new-components/base-button/base-button.d.ts +65 -0
- package/lib/new-components/base-button/base-button.js +2 -0
- package/lib/new-components/base-button/base-button.js.map +1 -0
- package/lib/new-components/base-button/base-button.module.css.js +2 -0
- package/lib/new-components/base-button/base-button.module.css.js.map +1 -0
- package/lib/new-components/base-button/index.d.ts +1 -0
- package/lib/new-components/base-field/base-field.d.ts +53 -13
- package/lib/new-components/base-field/base-field.js +1 -1
- package/lib/new-components/base-field/base-field.js.map +1 -1
- package/lib/new-components/base-field/base-field.module.css.js +1 -1
- package/lib/new-components/box/box.d.ts +24 -13
- package/lib/new-components/box/box.js +1 -1
- package/lib/new-components/box/box.js.map +1 -1
- package/lib/new-components/box/box.module.css.js +1 -1
- package/lib/{components/tabs/tabs.test.d.ts → new-components/box/box.test.d.ts} +0 -0
- package/lib/new-components/box/margin.module.css.js +2 -0
- package/lib/new-components/box/margin.module.css.js.map +1 -0
- package/lib/new-components/box/padding.module.css.js +2 -0
- package/lib/new-components/box/padding.module.css.js.map +1 -0
- package/lib/new-components/button/button.d.ts +48 -0
- package/lib/new-components/button/button.js +2 -0
- package/lib/new-components/button/button.js.map +1 -0
- package/lib/new-components/button/button.test.d.ts +1 -0
- package/lib/new-components/button/index.d.ts +1 -0
- package/lib/new-components/button-link/button-link-story-wrapper.d.ts +7 -0
- package/lib/new-components/button-link/button-link.d.ts +14 -8
- package/lib/new-components/button-link/button-link.js +1 -1
- package/lib/new-components/button-link/button-link.js.map +1 -1
- package/lib/new-components/button-link/button-link.test.d.ts +1 -0
- package/lib/new-components/checkbox-field/checkbox-field.d.ts +3 -3
- package/lib/new-components/checkbox-field/checkbox-field.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.module.css.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.test.d.ts +1 -0
- package/lib/new-components/checkbox-field/checkbox-icon.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-icon.js.map +1 -1
- package/lib/new-components/columns/columns.d.ts +4 -5
- package/lib/new-components/columns/columns.js +1 -1
- package/lib/new-components/columns/columns.js.map +1 -1
- package/lib/new-components/columns/columns.module.css.js +1 -1
- package/lib/new-components/columns/columns.test.d.ts +1 -0
- package/lib/new-components/common-types.d.ts +2 -0
- package/lib/new-components/divider/divider.d.ts +2 -2
- package/lib/new-components/divider/divider.js +1 -1
- package/lib/new-components/divider/divider.js.map +1 -1
- package/lib/new-components/divider/divider.module.css.js +1 -1
- package/lib/new-components/heading/heading.d.ts +101 -2
- package/lib/new-components/heading/heading.js +1 -1
- package/lib/new-components/heading/heading.js.map +1 -1
- package/lib/new-components/heading/heading.module.css.js +1 -1
- package/lib/new-components/heading/heading.test.d.ts +1 -0
- package/lib/new-components/hidden/hidden.d.ts +49 -0
- package/lib/new-components/hidden/hidden.js +2 -0
- package/lib/new-components/hidden/hidden.js.map +1 -0
- package/lib/new-components/hidden/hidden.module.css.js +2 -0
- package/lib/new-components/hidden/hidden.module.css.js.map +1 -0
- package/lib/new-components/hidden/hidden.test.d.ts +1 -0
- package/lib/new-components/hidden/index.d.ts +1 -0
- package/lib/new-components/hidden-visually/hidden-visually.d.ts +11 -0
- package/lib/new-components/hidden-visually/hidden-visually.js +2 -0
- package/lib/new-components/hidden-visually/hidden-visually.js.map +1 -0
- package/lib/new-components/hidden-visually/hidden-visually.module.css.js +2 -0
- package/lib/new-components/hidden-visually/hidden-visually.module.css.js.map +1 -0
- package/lib/new-components/hidden-visually/hidden-visually.test.d.ts +1 -0
- package/lib/new-components/hidden-visually/index.d.ts +1 -0
- package/lib/new-components/icons/alert-icon.js +1 -1
- package/lib/new-components/icons/alert-icon.js.map +1 -1
- package/lib/new-components/inline/inline.d.ts +1 -2
- package/lib/new-components/inline/inline.js +1 -1
- package/lib/new-components/inline/inline.js.map +1 -1
- package/lib/new-components/inline/inline.test.d.ts +1 -0
- package/lib/new-components/loading/index.d.ts +1 -0
- package/lib/new-components/loading/loading.d.ts +26 -0
- package/lib/new-components/loading/loading.js +2 -0
- package/lib/new-components/loading/loading.js.map +1 -0
- package/lib/new-components/loading/loading.test.d.ts +1 -0
- package/lib/new-components/modal/index.d.ts +1 -0
- package/lib/new-components/modal/modal-stories-components.d.ts +35 -0
- package/lib/new-components/modal/modal.d.ts +151 -0
- package/lib/new-components/modal/modal.js +2 -0
- package/lib/new-components/modal/modal.js.map +1 -0
- package/lib/new-components/modal/modal.module.css.js +2 -0
- package/lib/new-components/modal/modal.module.css.js.map +1 -0
- package/lib/new-components/modal/modal.test.d.ts +1 -0
- package/lib/new-components/password-field/password-field.d.ts +2 -2
- package/lib/new-components/password-field/password-field.js +1 -1
- package/lib/new-components/password-field/password-field.js.map +1 -1
- package/lib/new-components/password-field/password-field.test.d.ts +1 -0
- package/lib/new-components/responsive-props.d.ts +12 -14
- package/lib/new-components/responsive-props.js +1 -1
- package/lib/new-components/responsive-props.js.map +1 -1
- package/lib/new-components/select-field/select-field.d.ts +4 -4
- package/lib/new-components/select-field/select-field.js +1 -1
- package/lib/new-components/select-field/select-field.js.map +1 -1
- package/lib/new-components/select-field/select-field.module.css.js +1 -1
- package/lib/new-components/select-field/select-field.test.d.ts +1 -0
- package/lib/new-components/spinner/index.d.ts +1 -0
- package/lib/new-components/spinner/spinner.d.ts +5 -0
- package/lib/new-components/spinner/spinner.js +2 -0
- package/lib/new-components/spinner/spinner.js.map +1 -0
- package/lib/new-components/spinner/spinner.module.css.js +2 -0
- package/lib/new-components/spinner/spinner.module.css.js.map +1 -0
- package/lib/new-components/stack/stack.d.ts +8 -5
- package/lib/new-components/stack/stack.js +1 -1
- package/lib/new-components/stack/stack.js.map +1 -1
- package/lib/new-components/stack/stack.test.d.ts +1 -0
- package/lib/new-components/switch-field/switch-field.d.ts +4 -4
- package/lib/new-components/switch-field/switch-field.js +1 -1
- package/lib/new-components/switch-field/switch-field.js.map +1 -1
- package/lib/new-components/switch-field/switch-field.module.css.js +1 -1
- package/lib/new-components/switch-field/switch-field.test.d.ts +1 -0
- package/lib/new-components/tabs/index.d.ts +1 -0
- package/lib/new-components/tabs/tabs.d.ts +92 -0
- package/lib/new-components/tabs/tabs.js +2 -0
- package/lib/new-components/tabs/tabs.js.map +1 -0
- package/lib/new-components/tabs/tabs.module.css.js +2 -0
- package/lib/new-components/tabs/tabs.module.css.js.map +1 -0
- package/lib/new-components/tabs/tabs.test.d.ts +1 -0
- package/lib/new-components/test-helpers.d.ts +9 -0
- package/lib/new-components/text/text.d.ts +38 -5
- package/lib/new-components/text/text.js +1 -1
- package/lib/new-components/text/text.js.map +1 -1
- package/lib/new-components/text/text.module.css.js +1 -1
- package/lib/new-components/text/text.test.d.ts +1 -0
- package/lib/new-components/text-area/text-area.d.ts +2 -2
- package/lib/new-components/text-area/text-area.js +1 -1
- package/lib/new-components/text-area/text-area.js.map +1 -1
- package/lib/new-components/text-area/text-area.module.css.js +1 -1
- package/lib/new-components/text-field/text-field.d.ts +7 -4
- package/lib/new-components/text-field/text-field.js +1 -1
- package/lib/new-components/text-field/text-field.js.map +1 -1
- package/lib/new-components/text-field/text-field.module.css.js +1 -1
- package/lib/new-components/text-field/text-field.test.d.ts +1 -0
- package/lib/new-components/text-link/text-link.d.ts +1 -2
- package/lib/new-components/text-link/text-link.js +1 -1
- package/lib/new-components/text-link/text-link.js.map +1 -1
- package/lib/utils/polymorphism.d.ts +151 -0
- package/lib/utils/polymorphism.js +2 -0
- package/lib/utils/polymorphism.js.map +1 -0
- package/package.json +27 -23
- package/styles/alert.css +4 -2
- package/styles/base-button.css +6 -0
- package/styles/base-button.module.css.css +1 -0
- package/styles/base-field.css +7 -3
- package/styles/base-field.module.css.css +1 -1
- package/styles/box.css +3 -0
- package/styles/box.module.css.css +1 -1
- package/styles/checkbox-field.css +6 -2
- package/styles/checkbox-field.module.css.css +1 -1
- package/styles/color-picker.css +1 -1
- package/styles/columns.css +4 -2
- package/styles/columns.module.css.css +1 -1
- package/styles/deprecated-button.css +2 -0
- package/styles/deprecated-loading.css +1 -0
- package/styles/deprecated-modal.css +1 -0
- package/styles/divider.css +4 -2
- package/styles/divider.module.css.css +1 -1
- package/styles/dropdown.css +1 -1
- package/styles/heading.css +4 -2
- package/styles/heading.module.css.css +1 -1
- package/styles/hidden-visually.css +4 -0
- package/styles/hidden-visually.module.css.css +1 -0
- package/styles/hidden.css +4 -0
- package/styles/hidden.module.css.css +1 -0
- package/styles/inline.css +3 -1
- package/styles/loading.css +4 -1
- package/styles/margin.module.css.css +1 -0
- package/styles/menu.css +1 -1
- package/styles/modal.css +10 -1
- package/styles/modal.module.css.css +1 -0
- package/styles/notice.css +4 -2
- package/styles/padding.module.css.css +1 -0
- package/styles/password-field.css +8 -4
- package/styles/reactist.css +24 -19
- package/styles/select-field.css +8 -4
- package/styles/select-field.module.css.css +1 -1
- package/styles/spinner.module.css.css +1 -0
- package/styles/stack.css +4 -2
- package/styles/switch-field.css +9 -4
- package/styles/switch-field.module.css.css +1 -1
- package/styles/tabs.css +5 -1
- package/styles/tabs.module.css.css +1 -0
- package/styles/text-area.css +8 -4
- package/styles/text-area.module.css.css +1 -1
- package/styles/text-field.css +8 -4
- package/styles/text-field.module.css.css +1 -1
- package/styles/text-link.css +3 -1
- package/styles/text.css +4 -2
- package/styles/text.module.css.css +1 -1
- package/styles/tip.css +1 -1
- package/CHANGELOG.md +0 -496
- package/es/components/button/button.js.map +0 -1
- package/es/components/loading/index.js +0 -6
- package/es/components/loading/index.js.map +0 -1
- package/es/components/loading/loading.js.map +0 -1
- package/es/components/menu/type-helpers.js +0 -9
- package/es/components/menu/type-helpers.js.map +0 -1
- package/es/components/modal/index.js.map +0 -1
- package/es/components/modal/modal.js.map +0 -1
- package/es/components/tabs/tabs.js +0 -123
- package/es/components/tabs/tabs.js.map +0 -1
- package/es/new-components/button-link/button-link.module.css.js +0 -4
- package/es/new-components/button-link/button-link.module.css.js.map +0 -1
- package/es/new-components/loading-spinner/loading-spinner.js +0 -37
- package/es/new-components/loading-spinner/loading-spinner.js.map +0 -1
- package/es/new-components/loading-spinner/loading-spinner.module.css.js +0 -4
- package/es/new-components/loading-spinner/loading-spinner.module.css.js.map +0 -1
- package/es/new-components/type-helpers.js +0 -10
- package/es/new-components/type-helpers.js.map +0 -1
- package/lib/components/button/button.js +0 -2
- package/lib/components/button/button.js.map +0 -1
- package/lib/components/button/index.d.ts +0 -4
- package/lib/components/button/index.js +0 -2
- package/lib/components/loading/index.d.ts +0 -2
- package/lib/components/loading/index.js.map +0 -1
- package/lib/components/loading/loading.js.map +0 -1
- package/lib/components/menu/type-helpers.d.ts +0 -25
- package/lib/components/menu/type-helpers.js +0 -2
- package/lib/components/menu/type-helpers.js.map +0 -1
- package/lib/components/modal/index.js +0 -2
- package/lib/components/modal/index.js.map +0 -1
- package/lib/components/modal/modal.js.map +0 -1
- package/lib/components/tabs/index.d.ts +0 -1
- package/lib/components/tabs/tabs.d.ts +0 -33
- package/lib/components/tabs/tabs.js +0 -2
- package/lib/components/tabs/tabs.js.map +0 -1
- package/lib/new-components/button-link/button-link.module.css.js +0 -2
- package/lib/new-components/button-link/button-link.module.css.js.map +0 -1
- package/lib/new-components/loading-spinner/index.d.ts +0 -1
- package/lib/new-components/loading-spinner/loading-spinner.d.ts +0 -8
- package/lib/new-components/loading-spinner/loading-spinner.js +0 -2
- package/lib/new-components/loading-spinner/loading-spinner.js.map +0 -1
- package/lib/new-components/loading-spinner/loading-spinner.module.css.js +0 -2
- package/lib/new-components/loading-spinner/loading-spinner.module.css.js.map +0 -1
- package/lib/new-components/type-helpers.d.ts +0 -26
- package/lib/new-components/type-helpers.js +0 -2
- package/lib/new-components/type-helpers.js.map +0 -1
- package/styles/button-link.css +0 -2
- package/styles/button-link.module.css.css +0 -1
- package/styles/button.css +0 -2
- package/styles/loading-spinner.module.css.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard-shortcut.js","sources":["../../../src/components/keyboard-shortcut/keyboard-shortcut.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\n//\n// Support for setting up how to translate modifiers globally.\n//\n\nlet globalTranslateKey = (key: string) => key\n\ntype TranslateKey = typeof globalTranslateKey\n\nKeyboardShortcut.setTranslateKey = (tr: TranslateKey) => {\n globalTranslateKey = tr\n}\n\nfunction translateKeyMac(key: string) {\n switch (key.toLowerCase()) {\n case 'cmd':\n case 'mod':\n return '⌘'\n case 'control':\n case 'ctrl':\n return '⌃'\n case 'alt':\n return '⌥'\n case 'shift':\n return '⇧'\n case 'space':\n return '␣'\n default:\n return key\n }\n}\n\n//\n// Some helpers\n//\n\nfunction capitalize(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()\n}\n\nfunction hasModifiers(str: string) {\n return /\\b(mod|cmd|ctrl|control|alt|shift)\\b/i.test(str)\n}\n\nfunction isSpecialKey(str: string) {\n return /^(mod|cmd|ctrl|control|alt|shift|space)$/i.test(str)\n}\n\nfunction parseKeys(shortcut: string, isMac: boolean, translateKey: TranslateKey) {\n const t = isMac ? translateKeyMac : translateKey\n const _hasModifiers = hasModifiers(shortcut)\n\n function mapIndividualKey(str: string) {\n if (isSpecialKey(str)) {\n return capitalize(t(str))\n }\n if (_hasModifiers && str.length === 1) {\n return str.toUpperCase()\n }\n return str\n }\n\n if (!isMac) {\n shortcut = shortcut.replace(/\\b(mod|cmd)\\b/i, 'ctrl')\n }\n\n return shortcut.split(/\\s*\\+\\s*/).map(mapIndividualKey)\n}\n\n//\n// The KeyboardShortcut component\n//\n\ntype NativeSpanProps = React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLSpanElement>,\n HTMLSpanElement\n>\n\ntype Props = Omit<NativeSpanProps, 'children'> & {\n /**\n * The shortcut to be represented as markup. It supports an intuitive syntax where you can\n * combine modifiers (cmd, ctrl, shift, alt) with single keys all concatenated with plus signs.\n * You can also pass various shortcuts as an array, which will be depicted separated by commas.\n */\n children: string | string[]\n /**\n * A function that allows you to change how some key names are represented. This may be useful,\n * for instance, to translate modifier names that are expressed differently in other languages\n * (e.g. `Ctrl` is named `Strg` in German).\n *\n * It defaults to a global version that leaves the key as is. You can pass your version as a\n * prop, or you can also set your own version of this global default one, so you don't need to\n * pass your own on each invocation of this component.\n *\n * ```js\n * import { KeyboardShortcut } from '@doist/reactist'\n * KeyboardShortcut.setTranslateKey = key => { ... }\n * ```\n *\n * Note: When the component detects the macOS operating system it bypasses key translation for\n * most modifiers and uses macOS-specific symbols. See the `isMac` prop for details.\n */\n translateKey?: TranslateKey\n /**\n * This prop is not meant to be passed. The component will automatically initialize it to `true`\n * if it detects that the current browser / operating system is on macOS, in which case modifier\n * keys are represented using macOS' notation (e.g. ⌘ ⌃ ⌥ ⇧).\n *\n * Though it is discouraged, if you don't want this special treatment in macOS, you can pass\n * `isMac={false}` in all invocations of this component.\n */\n isMac?: boolean\n}\n\nfunction KeyboardShortcut({\n children,\n className,\n translateKey = globalTranslateKey,\n isMac = navigator.platform
|
|
1
|
+
{"version":3,"file":"keyboard-shortcut.js","sources":["../../../src/components/keyboard-shortcut/keyboard-shortcut.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\n//\n// Support for setting up how to translate modifiers globally.\n//\n\nlet globalTranslateKey = (key: string) => key\n\ntype TranslateKey = typeof globalTranslateKey\n\nKeyboardShortcut.setTranslateKey = (tr: TranslateKey) => {\n globalTranslateKey = tr\n}\n\nfunction translateKeyMac(key: string) {\n switch (key.toLowerCase()) {\n case 'cmd':\n case 'mod':\n return '⌘'\n case 'control':\n case 'ctrl':\n return '⌃'\n case 'alt':\n return '⌥'\n case 'shift':\n return '⇧'\n case 'space':\n return '␣'\n default:\n return key\n }\n}\n\n//\n// Some helpers\n//\n\nfunction capitalize(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()\n}\n\nfunction hasModifiers(str: string) {\n return /\\b(mod|cmd|ctrl|control|alt|shift)\\b/i.test(str)\n}\n\nfunction isSpecialKey(str: string) {\n return /^(mod|cmd|ctrl|control|alt|shift|space|super)$/i.test(str)\n}\n\nfunction parseKeys(shortcut: string, isMac: boolean, translateKey: TranslateKey) {\n const t = isMac ? translateKeyMac : translateKey\n const _hasModifiers = hasModifiers(shortcut)\n\n function mapIndividualKey(str: string) {\n if (isSpecialKey(str)) {\n return capitalize(t(str))\n }\n if (_hasModifiers && str.length === 1) {\n return str.toUpperCase()\n }\n return str\n }\n\n if (!isMac) {\n shortcut = shortcut.replace(/\\b(mod|cmd)\\b/i, 'ctrl')\n }\n\n return shortcut.split(/\\s*\\+\\s*/).map(mapIndividualKey)\n}\n\n//\n// The KeyboardShortcut component\n//\n\ntype NativeSpanProps = React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLSpanElement>,\n HTMLSpanElement\n>\n\ntype Props = Omit<NativeSpanProps, 'children'> & {\n /**\n * The shortcut to be represented as markup. It supports an intuitive syntax where you can\n * combine modifiers (cmd, ctrl, shift, alt) with single keys all concatenated with plus signs.\n * You can also pass various shortcuts as an array, which will be depicted separated by commas.\n */\n children: string | string[]\n /**\n * A function that allows you to change how some key names are represented. This may be useful,\n * for instance, to translate modifier names that are expressed differently in other languages\n * (e.g. `Ctrl` is named `Strg` in German).\n *\n * It defaults to a global version that leaves the key as is. You can pass your version as a\n * prop, or you can also set your own version of this global default one, so you don't need to\n * pass your own on each invocation of this component.\n *\n * ```js\n * import { KeyboardShortcut } from '@doist/reactist'\n * KeyboardShortcut.setTranslateKey = key => { ... }\n * ```\n *\n * Note: When the component detects the macOS operating system it bypasses key translation for\n * most modifiers and uses macOS-specific symbols. See the `isMac` prop for details.\n */\n translateKey?: TranslateKey\n /**\n * This prop is not meant to be passed. The component will automatically initialize it to `true`\n * if it detects that the current browser / operating system is on macOS, in which case modifier\n * keys are represented using macOS' notation (e.g. ⌘ ⌃ ⌥ ⇧).\n *\n * Though it is discouraged, if you don't want this special treatment in macOS, you can pass\n * `isMac={false}` in all invocations of this component.\n */\n isMac?: boolean\n}\n\nfunction KeyboardShortcut({\n children,\n className,\n translateKey = globalTranslateKey,\n isMac = navigator.platform?.toUpperCase().includes('MAC') ?? false,\n ...props\n}: Props) {\n const shortcuts = typeof children === 'string' ? [children] : children\n return (\n <span\n className={classNames('reactist_keyboard_shortcut', className, {\n 'reactist_keyboard_shortcut--macos': isMac,\n })}\n {...props}\n >\n {shortcuts.map((shortcut, i) => (\n <React.Fragment key={i}>\n {i === 0 ? null : ', '}\n <kbd>\n {parseKeys(shortcut, isMac, translateKey).map((key, j) => (\n <kbd key={j}>{key}</kbd>\n ))}\n </kbd>\n </React.Fragment>\n ))}\n </span>\n )\n}\n\nexport { KeyboardShortcut }\n"],"names":["globalTranslateKey","key","KeyboardShortcut","setTranslateKey","tr","translateKeyMac","toLowerCase","capitalize","str","charAt","toUpperCase","slice","hasModifiers","test","isSpecialKey","parseKeys","shortcut","isMac","translateKey","t","_hasModifiers","mapIndividualKey","length","replace","split","map","children","className","navigator","platform","includes","props","shortcuts","React","classNames","i","j"],"mappings":";;;;;AAIA;AACA;;AAEA,IAAIA,kBAAkB,GAAG,4BAACC,GAAD;AAAA,SAAiBA,GAAjB;AAAA,CAAzB;;AAIAC,gBAAgB,CAACC,eAAjB,GAAmC,UAACC,EAAD;AAC/BJ,EAAAA,kBAAkB,GAAGI,EAArB;AACH,CAFD;;AAIA,SAASC,eAAT,CAAyBJ,GAAzB;AACI,UAAQA,GAAG,CAACK,WAAJ,EAAR;AACI,SAAK,KAAL;AACA,SAAK,KAAL;AACI,aAAO,GAAP;;AACJ,SAAK,SAAL;AACA,SAAK,MAAL;AACI,aAAO,GAAP;;AACJ,SAAK,KAAL;AACI,aAAO,GAAP;;AACJ,SAAK,OAAL;AACI,aAAO,GAAP;;AACJ,SAAK,OAAL;AACI,aAAO,GAAP;;AACJ;AACI,aAAOL,GAAP;AAdR;AAgBH;AAGD;AACA;;;AAEA,SAASM,UAAT,CAAoBC,GAApB;AACI,SAAOA,GAAG,CAACC,MAAJ,CAAW,CAAX,EAAcC,WAAd,KAA8BF,GAAG,CAACG,KAAJ,CAAU,CAAV,EAAaL,WAAb,EAArC;AACH;;AAED,SAASM,YAAT,CAAsBJ,GAAtB;AACI,SAAO,wCAAwCK,IAAxC,CAA6CL,GAA7C,CAAP;AACH;;AAED,SAASM,YAAT,CAAsBN,GAAtB;AACI,SAAO,kDAAkDK,IAAlD,CAAuDL,GAAvD,CAAP;AACH;;AAED,SAASO,SAAT,CAAmBC,QAAnB,EAAqCC,KAArC,EAAqDC,YAArD;AACI,MAAMC,CAAC,GAAGF,KAAK,GAAGZ,eAAH,GAAqBa,YAApC;;AACA,MAAME,aAAa,GAAGR,YAAY,CAACI,QAAD,CAAlC;;AAEA,WAASK,gBAA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QAAAA,GAAG,EAAEmC;OAAV,EAAcnC,GAAd,CAD0C;AAAA,KAA7C,CADL,CAFJ,CADW;AAAA,GAAd,CANL,CADJ;AAmBH;;;;"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { useCallback, useMemo, createElement, useContext, forwardRef, Children, cloneElement, createContext } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import {
|
|
5
|
-
import { useMenuState,
|
|
4
|
+
import { polymorphicComponent } from '../../utils/polymorphism.js';
|
|
5
|
+
import { useMenuState, MenuButton as MenuButton$1, Menu as Menu$1, MenuItem as MenuItem$1, MenuGroup as MenuGroup$1 } from 'reakit/Menu';
|
|
6
6
|
import { PopoverBackdrop } from 'reakit/Popover';
|
|
7
7
|
|
|
8
|
+
var _excluded = ["children", "onItemSelect"],
|
|
9
|
+
_excluded2 = ["exceptionallySetClassName"],
|
|
10
|
+
_excluded3 = ["handleItemSelect"],
|
|
11
|
+
_excluded4 = ["exceptionallySetClassName"],
|
|
12
|
+
_excluded5 = ["handleItemSelect"],
|
|
13
|
+
_excluded6 = ["value", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName"],
|
|
14
|
+
_excluded7 = ["handleItemSelect"],
|
|
15
|
+
_excluded8 = ["children", "onItemSelect"],
|
|
16
|
+
_excluded9 = ["handleItemSelect"],
|
|
17
|
+
_excluded10 = ["label", "children", "exceptionallySetClassName"],
|
|
18
|
+
_excluded11 = ["handleItemSelect"];
|
|
8
19
|
var MenuContext = /*#__PURE__*/createContext( // Reakit gives us no means to obtain a valid initial/default value of type MenuStateReturn
|
|
9
20
|
// (it is normally obtained by calling useMenuState but we can't call hooks outside components).
|
|
10
21
|
// This is however of little consequence since this value is only used if some of the components
|
|
@@ -19,7 +30,7 @@ var MenuContext = /*#__PURE__*/createContext( // Reakit gives us no means to obt
|
|
|
19
30
|
function Menu(_ref) {
|
|
20
31
|
var children = _ref.children,
|
|
21
32
|
onItemSelect = _ref.onItemSelect,
|
|
22
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
33
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
23
34
|
|
|
24
35
|
var state = useMenuState(_objectSpread2({
|
|
25
36
|
loop: true
|
|
@@ -35,25 +46,22 @@ function Menu(_ref) {
|
|
|
35
46
|
return /*#__PURE__*/createElement(MenuContext.Provider, {
|
|
36
47
|
value: value
|
|
37
48
|
}, children);
|
|
38
|
-
}
|
|
39
|
-
// MenuButton
|
|
40
|
-
//
|
|
41
|
-
|
|
49
|
+
}
|
|
42
50
|
/**
|
|
43
51
|
* A button to toggle a dropdown menu open or closed.
|
|
44
52
|
*/
|
|
45
53
|
|
|
46
54
|
|
|
47
|
-
var MenuButton = /*#__PURE__*/
|
|
48
|
-
var
|
|
49
|
-
props = _objectWithoutPropertiesLoose(_ref2,
|
|
55
|
+
var MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2, ref) {
|
|
56
|
+
var exceptionallySetClassName = _ref2.exceptionallySetClassName,
|
|
57
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
50
58
|
|
|
51
59
|
var _React$useContext = useContext(MenuContext),
|
|
52
|
-
state = _objectWithoutPropertiesLoose(_React$useContext,
|
|
60
|
+
state = _objectWithoutPropertiesLoose(_React$useContext, _excluded3);
|
|
53
61
|
|
|
54
62
|
return /*#__PURE__*/createElement(MenuButton$1, Object.assign({}, props, state, {
|
|
55
63
|
ref: ref,
|
|
56
|
-
className: classNames('reactist_menubutton',
|
|
64
|
+
className: classNames('reactist_menubutton', exceptionallySetClassName)
|
|
57
65
|
}));
|
|
58
66
|
});
|
|
59
67
|
var BACKDROP_STYLE = {
|
|
@@ -91,16 +99,16 @@ function MenuBackdrop(_ref3) {
|
|
|
91
99
|
*/
|
|
92
100
|
|
|
93
101
|
|
|
94
|
-
var MenuList = /*#__PURE__*/
|
|
95
|
-
var
|
|
96
|
-
props = _objectWithoutPropertiesLoose(_ref4,
|
|
102
|
+
var MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref) {
|
|
103
|
+
var exceptionallySetClassName = _ref4.exceptionallySetClassName,
|
|
104
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded4);
|
|
97
105
|
|
|
98
106
|
var _React$useContext2 = useContext(MenuContext),
|
|
99
|
-
state = _objectWithoutPropertiesLoose(_React$useContext2,
|
|
107
|
+
state = _objectWithoutPropertiesLoose(_React$useContext2, _excluded5);
|
|
100
108
|
|
|
101
109
|
return state.visible ? /*#__PURE__*/createElement(MenuBackdrop, Object.assign({}, state), /*#__PURE__*/createElement(Menu$1, Object.assign({}, props, state, {
|
|
102
110
|
ref: ref,
|
|
103
|
-
className: classNames('reactist_menulist',
|
|
111
|
+
className: classNames('reactist_menulist', exceptionallySetClassName)
|
|
104
112
|
}))) : null;
|
|
105
113
|
});
|
|
106
114
|
/**
|
|
@@ -108,18 +116,19 @@ var MenuList = /*#__PURE__*/forwardRefWithAs(function MenuList(_ref4, ref) {
|
|
|
108
116
|
* callback.
|
|
109
117
|
*/
|
|
110
118
|
|
|
111
|
-
var MenuItem = /*#__PURE__*/
|
|
119
|
+
var MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref) {
|
|
112
120
|
var value = _ref5.value,
|
|
113
121
|
children = _ref5.children,
|
|
114
122
|
onSelect = _ref5.onSelect,
|
|
115
123
|
_ref5$hideOnSelect = _ref5.hideOnSelect,
|
|
116
124
|
hideOnSelect = _ref5$hideOnSelect === void 0 ? true : _ref5$hideOnSelect,
|
|
117
125
|
onClick = _ref5.onClick,
|
|
118
|
-
|
|
126
|
+
exceptionallySetClassName = _ref5.exceptionallySetClassName,
|
|
127
|
+
props = _objectWithoutPropertiesLoose(_ref5, _excluded6);
|
|
119
128
|
|
|
120
129
|
var _React$useContext3 = useContext(MenuContext),
|
|
121
130
|
handleItemSelect = _React$useContext3.handleItemSelect,
|
|
122
|
-
state = _objectWithoutPropertiesLoose(_React$useContext3,
|
|
131
|
+
state = _objectWithoutPropertiesLoose(_React$useContext3, _excluded7);
|
|
123
132
|
|
|
124
133
|
var hide = state.hide;
|
|
125
134
|
var handleClick = useCallback(function handleClick(event) {
|
|
@@ -131,7 +140,8 @@ var MenuItem = /*#__PURE__*/forwardRefWithAs(function MenuItem(_ref5, ref) {
|
|
|
131
140
|
}, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
|
|
132
141
|
return /*#__PURE__*/createElement(MenuItem$1, Object.assign({}, props, state, {
|
|
133
142
|
ref: ref,
|
|
134
|
-
onClick: handleClick
|
|
143
|
+
onClick: handleClick,
|
|
144
|
+
className: exceptionallySetClassName
|
|
135
145
|
}), children);
|
|
136
146
|
});
|
|
137
147
|
/**
|
|
@@ -159,11 +169,11 @@ var MenuItem = /*#__PURE__*/forwardRefWithAs(function MenuItem(_ref5, ref) {
|
|
|
159
169
|
var SubMenu = /*#__PURE__*/forwardRef(function SubMenu(_ref6, ref) {
|
|
160
170
|
var children = _ref6.children,
|
|
161
171
|
onItemSelect = _ref6.onItemSelect,
|
|
162
|
-
props = _objectWithoutPropertiesLoose(_ref6,
|
|
172
|
+
props = _objectWithoutPropertiesLoose(_ref6, _excluded8);
|
|
163
173
|
|
|
164
174
|
var _React$useContext4 = useContext(MenuContext),
|
|
165
175
|
parentMenuItemSelect = _React$useContext4.handleItemSelect,
|
|
166
|
-
state = _objectWithoutPropertiesLoose(_React$useContext4,
|
|
176
|
+
state = _objectWithoutPropertiesLoose(_React$useContext4, _excluded9);
|
|
167
177
|
|
|
168
178
|
var parentMenuHide = state.hide;
|
|
169
179
|
var handleSubItemSelect = useCallback(function handleSubItemSelect(value) {
|
|
@@ -193,17 +203,20 @@ var SubMenu = /*#__PURE__*/forwardRef(function SubMenu(_ref6, ref) {
|
|
|
193
203
|
* before and/or after the group if you so wish.
|
|
194
204
|
*/
|
|
195
205
|
|
|
196
|
-
var MenuGroup = /*#__PURE__*/
|
|
206
|
+
var MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroud(_ref7, ref) {
|
|
197
207
|
var label = _ref7.label,
|
|
198
208
|
children = _ref7.children,
|
|
199
|
-
|
|
209
|
+
exceptionallySetClassName = _ref7.exceptionallySetClassName,
|
|
210
|
+
props = _objectWithoutPropertiesLoose(_ref7, _excluded10);
|
|
200
211
|
|
|
201
212
|
var _React$useContext5 = useContext(MenuContext),
|
|
202
|
-
state = _objectWithoutPropertiesLoose(_React$useContext5,
|
|
213
|
+
state = _objectWithoutPropertiesLoose(_React$useContext5, _excluded11);
|
|
203
214
|
|
|
204
215
|
return /*#__PURE__*/createElement(MenuGroup$1, Object.assign({
|
|
205
216
|
ref: ref
|
|
206
|
-
}, props, state
|
|
217
|
+
}, props, state, {
|
|
218
|
+
className: exceptionallySetClassName
|
|
219
|
+
}), label ? /*#__PURE__*/createElement("div", {
|
|
207
220
|
role: "presentation",
|
|
208
221
|
className: "reactist_menugroup__label"
|
|
209
222
|
}, label) : null, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sources":["../../../src/components/menu/menu.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { forwardRefWithAs } from './type-helpers'\n\n//\n// Reactist menu is a thin wrapper around Reakit's menu components. This may or may not be\n// temporary. Our goal is to make it transparent for the users of Reactist of this implementation\n// detail. We may change in the future the external lib we use, or even implement it all internally,\n// as long as we keep the same outer interface as intact as possible.\n//\n// Around the heavy lifting of the external lib we just add some features to better integrate the\n// menu to Reactist's more opinionated approach (e.g. using our button with its custom variants and\n// other features, easily show keyboard shortcuts in menu items, etc.)\n//\nimport * as Reakit from 'reakit/Menu'\nimport { PopoverBackdrop } from 'reakit/Popover'\n\nimport './menu.less'\n\ntype NativeProps<E extends HTMLElement> = React.DetailedHTMLProps<React.HTMLAttributes<E>, E>\n\ntype MenuContextState = Reakit.MenuStateReturn & {\n handleItemSelect: (value: string | null | undefined) => void\n}\n\nconst MenuContext = React.createContext<MenuContextState>(\n // Reakit gives us no means to obtain a valid initial/default value of type MenuStateReturn\n // (it is normally obtained by calling useMenuState but we can't call hooks outside components).\n // This is however of little consequence since this value is only used if some of the components\n // are used outside Menu, something that should not happen and we do not support.\n // @ts-expect-error\n {},\n)\n\n//\n// Menu\n//\n\ntype MenuProps = Omit<Reakit.MenuInitialState, 'visible'> & {\n /**\n * The `Menu` must contain a `MenuList` that defines the menu options. It must also contain a\n * `MenuButton` that triggers the menu to be opened or closed.\n */\n children: React.ReactNode\n\n /**\n * An optional callback that will be called back whenever a menu item is selected. It receives\n * the `value` of the selected `MenuItem`.\n *\n * If you pass down this callback, it is recommended that you properly memoize it so it does not\n * change on every render.\n */\n onItemSelect?: (value: string | null | undefined) => void\n}\n\n/**\n * Wrapper component to control a menu. It does not render anything, only providing the state\n * management for the menu components inside it.\n */\nfunction Menu({ children, onItemSelect, ...props }: MenuProps) {\n const state = Reakit.useMenuState({ loop: true, ...props })\n\n const handleItemSelect = React.useCallback(\n function handleItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n },\n [onItemSelect],\n )\n\n const value: MenuContextState = React.useMemo(\n () => ({\n ...state,\n handleItemSelect,\n }),\n [state, handleItemSelect],\n )\n\n return <MenuContext.Provider value={value}>{children}</MenuContext.Provider>\n}\n\n//\n// MenuButton\n//\n\n/**\n * A button to toggle a dropdown menu open or closed.\n */\nconst MenuButton = forwardRefWithAs<'button'>(function MenuButton({ className, ...props }, ref) {\n const { handleItemSelect, ...state } = React.useContext(MenuContext)\n return (\n <Reakit.MenuButton\n {...props}\n {...state}\n ref={ref}\n className={classNames('reactist_menubutton', className)}\n />\n )\n})\n\n//\n// MenuList\n//\n\ntype MenuBackdropProps = Reakit.MenuStateReturn & {\n children: React.ReactNode\n}\n\nconst BACKDROP_STYLE: React.CSSProperties = {\n width: '100%',\n height: '100%',\n position: 'fixed',\n top: 0,\n left: 0,\n}\n\n/**\n * Internal component to provide a backdrop/overlay to all menus. This is needed because reakit's\n * menus do not show an overlay by default.\n */\nfunction MenuBackdrop({\n baseId,\n visible,\n animated,\n animating,\n stopAnimation,\n modal,\n children,\n}: MenuBackdropProps) {\n return (\n <PopoverBackdrop\n baseId={baseId}\n visible={visible}\n animated={animated}\n animating={animating}\n stopAnimation={stopAnimation}\n modal={modal}\n style={BACKDROP_STYLE}\n >\n {children}\n </PopoverBackdrop>\n )\n}\n\n/**\n * The dropdown menu itself, containing a list of menu items.\n */\nconst MenuList = forwardRefWithAs<'div'>(function MenuList({ className, ...props }, ref) {\n const { handleItemSelect, ...state } = React.useContext(MenuContext)\n return state.visible ? (\n <MenuBackdrop {...state}>\n <Reakit.Menu\n {...props}\n {...state}\n ref={ref}\n className={classNames('reactist_menulist', className)}\n />\n </MenuBackdrop>\n ) : null\n})\n\n//\n// MenuItem\n//\n\ntype MenuItemProps = {\n /**\n * An optional value given to this menu item. It is passed on to the parent `Menu`'s\n * `onItemSelect` when you provide that instead of (or alongside) providing individual\n * `onSelect` callbacks to each menu item.\n */\n value?: string\n /**\n * The content inside the menu item.\n */\n children: React.ReactNode\n /**\n * When `true` the menu item is disabled and won't be selectable or be part of the keyboard\n * navigation across the menu options.\n *\n * @default true\n */\n disabled?: boolean\n /**\n * A class name to apply to the menu item element.\n */\n className?: string\n /**\n * When `true` the menu will close when the menu item is selected, in addition to performing the\n * action that the menu item is set out to do.\n *\n * Set this to `false` to make sure that a given menu item does not auto-closes the menu when\n * selected. This should be the exception and not the norm, as the default is to auto-close.\n *\n * @default true\n */\n hideOnSelect?: boolean\n /**\n * The action to perform when the menu item is selected.\n *\n * If you return `false` from this function, the menu will not auto-close when this menu item\n * is selected. Though you should use `hideOnSelect` for this purpose, this allows you to\n * achieve the same effect conditionally and dynamically deciding at run time.\n */\n onSelect?: () => unknown\n /**\n * The event handler called when the menu item is clicked.\n *\n * This is similar to `onSelect`, but a bit different. You can certainly use it to trigger the\n * action that the menu item represents. But in general you should prefer `onSelect` for that.\n *\n * The main use for this handler is to get access to the click event. This can be used, for\n * example, to call `event.preventDefault()`, which will effectively prevent the rest of the\n * consequences of the click, including preventing `onSelect` from being called. In particular,\n * this is useful in menu items that are links, and you want the click to not trigger navigation\n * under some circumstances.\n */\n onClick?: (event: React.MouseEvent) => void\n}\n\n/**\n * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`\n * callback.\n */\nconst MenuItem = forwardRefWithAs<'button', MenuItemProps>(function MenuItem(\n { value, children, onSelect, hideOnSelect = true, onClick, ...props },\n ref,\n) {\n const { handleItemSelect, ...state } = React.useContext(MenuContext)\n const { hide } = state\n\n const handleClick = React.useCallback(\n function handleClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event)\n const onSelectResult: unknown =\n onSelect && !event.defaultPrevented ? onSelect() : undefined\n const shouldClose = onSelectResult !== false && hideOnSelect\n handleItemSelect(value)\n if (shouldClose) hide()\n },\n [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value],\n )\n\n return (\n <Reakit.MenuItem {...props} {...state} ref={ref} onClick={handleClick}>\n {children}\n </Reakit.MenuItem>\n )\n})\n\n//\n// SubMenu\n//\n\ntype SubMenuProps = Pick<MenuProps, 'children' | 'onItemSelect'>\n\n/**\n * This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have\n * a sub-menu.\n *\n * Its children are expected to have the structure of a first level menu (a `MenuButton` and a\n * `MenuList`).\n *\n * ```jsx\n * <MenuItem label=\"Edit profile\" />\n * <SubMenu>\n * <MenuButton>More options</MenuButton>\n * <MenuList>\n * <MenuItem label=\"Preferences\" />\n * <MenuItem label=\"Sign out\" />\n * </MenuList>\n * </SubMenu>\n * ```\n *\n * The `MenuButton` will become a menu item in the current menu items list, and it will lead to\n * opening a sub-menu with the menu items list below it.\n */\nconst SubMenu = React.forwardRef<HTMLButtonElement, SubMenuProps>(function SubMenu(\n { children, onItemSelect, ...props },\n ref,\n) {\n const { handleItemSelect: parentMenuItemSelect, ...state } = React.useContext(MenuContext)\n const { hide: parentMenuHide } = state\n\n const handleSubItemSelect = React.useCallback(\n function handleSubItemSelect(value) {\n if (onItemSelect) onItemSelect(value)\n parentMenuItemSelect(value)\n parentMenuHide()\n },\n [parentMenuHide, parentMenuItemSelect, onItemSelect],\n )\n\n const [button, list] = React.Children.toArray(children)\n\n return (\n <Reakit.MenuItem {...state} {...props} ref={ref}>\n {(buttonProps) => (\n <Menu onItemSelect={handleSubItemSelect}>\n {React.cloneElement(button as React.ReactElement, {\n ...buttonProps,\n className: classNames(buttonProps.className, 'reactist_submenu_button'),\n })}\n {list}\n </Menu>\n )}\n </Reakit.MenuItem>\n )\n})\n\n//\n// MenuGroup\n//\n\ntype MenuGroupProps = NativeProps<HTMLDivElement> & {\n /**\n * A label to be shown visually and also used to semantically label the group.\n */\n label: string\n}\n\n/**\n * A way to semantically group some menu items.\n *\n * This group does not add any visual separator. You can do that yourself adding `<hr />` elements\n * before and/or after the group if you so wish.\n */\nconst MenuGroup = forwardRefWithAs<'div', MenuGroupProps>(function MenuGroud(\n { label, children, ...props },\n ref,\n) {\n const { handleItemSelect, ...state } = React.useContext(MenuContext)\n return (\n <Reakit.MenuGroup ref={ref} {...props} {...state}>\n {label ? (\n <div role=\"presentation\" className=\"reactist_menugroup__label\">\n {label}\n </div>\n ) : null}\n {children}\n </Reakit.MenuGroup>\n )\n})\n\nexport { Menu, MenuButton, MenuList, MenuItem, SubMenu, MenuGroup }\nexport type { MenuItemProps, SubMenuProps, MenuGroupProps }\n"],"names":["MenuContext","React","Menu","children","onItemSelect","props","state","Reakit","loop","handleItemSelect","value","Provider","MenuButton","forwardRefWithAs","ref","className","classNames","BACKDROP_STYLE","width","height","position","top","left","MenuBackdrop","baseId","visible","animated","animating","stopAnimation","modal","PopoverBackdrop","style","MenuList","MenuItem","onSelect","hideOnSelect","onClick","hide","handleClick","event","onSelectResult","defaultPrevented","undefined","shouldClose","SubMenu","parentMenuItemSelect","parentMenuHide","handleSubItemSelect","toArray","button","list","buttonProps","MenuGroup","MenuGroud","label","role"],"mappings":";;;;;;;AAyBA,IAAMA,WAAW,gBAAGC,aAAA;AAEhB;AACA;AACA;AACA;AACA,EANgB,CAApB;AA8BA;;;;;AAIA,SAASC,IAAT;MAAgBC,gBAAAA;MAAUC,oBAAAA;MAAiBC;;AACvC,MAAMC,KAAK,GAAGC,YAAA;AAAsBC,IAAAA,IAAI,EAAE;AAA5B,KAAqCH,KAArC,EAAd;AAEA,MAAMI,gBAAgB,GAAGR,WAAA,CACrB,SAASQ,gBAAT,CAA0BC,KAA1B;AACI,QAAIN,YAAJ,EAAkBA,YAAY,CAACM,KAAD,CAAZ;AACrB,GAHoB,EAIrB,CAACN,YAAD,CAJqB,CAAzB;AAOA,MAAMM,KAAK,GAAqBT,OAAA,CAC5B;AAAA,6CACOK,KADP;AAEIG,MAAAA,gBAAgB,EAAhBA;AAFJ;AAAA,GAD4B,EAK5B,CAACH,KAAD,EAAQG,gBAAR,CAL4B,CAAhC;AAQA,sBAAOR,aAAA,CAACD,WAAW,CAACW,QAAb;AAAsBD,IAAAA,KAAK,EAAEA;GAA7B,EAAqCP,QAArC,CAAP;AACH;AAGD;AACA;;AAEA;;;;;IAGMS,UAAU,gBAAGC,gBAAgB,CAAW,SAASD,UAAT,QAA6CE,GAA7C;MAAsBC,kBAAAA;MAAcV;;0BACvCJ,UAAA,CAAiBD,WAAjB;MAAVM;;AAC7B,sBACIL,aAAA,CAACM,YAAD,oBACQF,OACAC;AACJQ,IAAAA,GAAG,EAAEA;AACLC,IAAAA,SAAS,EAAEC,UAAU,CAAC,qBAAD,EAAwBD,SAAxB;IAJzB,CADJ;AAQH,CAVkC;AAoBnC,IAAME,cAAc,GAAwB;AACxCC,EAAAA,KAAK,EAAE,MADiC;AAExCC,EAAAA,MAAM,EAAE,MAFgC;AAGxCC,EAAAA,QAAQ,EAAE,OAH8B;AAIxCC,EAAAA,GAAG,EAAE,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C;KAApB,eACK9C,YAAA,CAAmBgD,MAAnB,oCACME,WADN;AAEGpC,MAAAA,SAAS,EAAEC,UAAU,CAACmC,WAAW,CAACpC,SAAb,EAAwB,yBAAxB;AAFxB,OADL,EAKKmC,IALL,CADH;AAAA,GADL,CADJ;AAaH,CA/Be;AA4ChB;;;;;;;IAMME,SAAS,gBAAGvC,gBAAgB,CAAwB,SAASwC,SAAT,QAEtDvC,GAFsD;MACpDwC,cAAAA;MAAOnD,iBAAAA;MAAaE;;2BAGiBJ,UAAA,CAAiBD,WAAjB;MAAVM;;AAC7B,sBACIL,aAAA,CAACM,WAAD;AAAkBO,IAAAA,GAAG,EAAEA;KAAST,OAAWC,MAA3C,EACKgD,KAAK,gBACFrD,aAAA,MAAA;AAAKsD,IAAAA,IAAI,EAAC;AAAexC,IAAAA,SAAS,EAAC;GAAnC,EACKuC,KADL,CADE,GAIF,IALR,EAMKnD,QANL,CADJ;AAUH,CAfiC;;;;"}
|
|
1
|
+
{"version":3,"file":"menu.js","sources":["../../../src/components/menu/menu.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { polymorphicComponent } from '../../utils/polymorphism'\n\n//\n// Reactist menu is a thin wrapper around Reakit's menu components. This may or may not be\n// temporary. Our goal is to make it transparent for the users of Reactist of this implementation\n// detail. We may change in the future the external lib we use, or even implement it all internally,\n// as long as we keep the same outer interface as intact as possible.\n//\n// Around the heavy lifting of the external lib we just add some features to better integrate the\n// menu to Reactist's more opinionated approach (e.g. using our button with its custom variants and\n// other features, easily show keyboard shortcuts in menu items, etc.)\n//\nimport * as Reakit from 'reakit/Menu'\nimport { PopoverBackdrop } from 'reakit/Popover'\n\nimport './menu.less'\n\ntype NativeProps<E extends HTMLElement> = React.DetailedHTMLProps<React.HTMLAttributes<E>, E>\n\ntype MenuContextState = Reakit.MenuStateReturn & {\n handleItemSelect: (value: string | null | undefined) => void\n}\n\nconst MenuContext = React.createContext<MenuContextState>(\n // Reakit gives us no means to obtain a valid initial/default value of type MenuStateReturn\n // (it is normally obtained by calling useMenuState but we can't call hooks outside components).\n // This is however of little consequence since this value is only used if some of the components\n // are used outside Menu, something that should not happen and we do not support.\n // @ts-expect-error\n {},\n)\n\n//\n// Menu\n//\n\ntype MenuProps = Omit<Reakit.MenuInitialState, 'visible'> & {\n /**\n * The `Menu` must contain a `MenuList` that defines the menu options. It must also contain a\n * `MenuButton` that triggers the menu to be opened or closed.\n */\n children: React.ReactNode\n\n /**\n * An optional callback that will be called back whenever a menu item is selected. It receives\n * the `value` of the selected `MenuItem`.\n *\n * If you pass down this callback, it is recommended that you properly memoize it so it does not\n * change on every render.\n */\n onItemSelect?: (value: string | null | undefined) => void\n}\n\n/**\n * Wrapper component to control a menu. It does not render anything, only providing the state\n * management for the menu components inside it.\n */\nfunction Menu({ children, onItemSelect, ...props }: MenuProps) {\n const state = Reakit.useMenuState({ loop: true, ...props })\n\n const handleItemSelect = React.useCallback(\n function handleItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n },\n [onItemSelect],\n )\n\n const value: MenuContextState = React.useMemo(\n () => ({\n ...state,\n handleItemSelect,\n }),\n [state, handleItemSelect],\n )\n\n return <MenuContext.Provider value={value}>{children}</MenuContext.Provider>\n}\n\n//\n// MenuButton\n//\n\ntype MenuButtonProps = Omit<Reakit.MenuButtonProps, keyof Reakit.MenuStateReturn | 'className'>\n\n/**\n * A button to toggle a dropdown menu open or closed.\n */\nconst MenuButton = polymorphicComponent<'button', MenuButtonProps>(function MenuButton(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { handleItemSelect, ...state } = React.useContext(MenuContext)\n return (\n <Reakit.MenuButton\n {...props}\n {...state}\n ref={ref}\n className={classNames('reactist_menubutton', exceptionallySetClassName)}\n />\n )\n})\n\n//\n// MenuList\n//\n\ntype MenuBackdropProps = Reakit.MenuStateReturn & {\n children: React.ReactNode\n}\n\nconst BACKDROP_STYLE: React.CSSProperties = {\n width: '100%',\n height: '100%',\n position: 'fixed',\n top: 0,\n left: 0,\n}\n\n/**\n * Internal component to provide a backdrop/overlay to all menus. This is needed because reakit's\n * menus do not show an overlay by default.\n */\nfunction MenuBackdrop({\n baseId,\n visible,\n animated,\n animating,\n stopAnimation,\n modal,\n children,\n}: MenuBackdropProps) {\n return (\n <PopoverBackdrop\n baseId={baseId}\n visible={visible}\n animated={animated}\n animating={animating}\n stopAnimation={stopAnimation}\n modal={modal}\n style={BACKDROP_STYLE}\n >\n {children}\n </PopoverBackdrop>\n )\n}\n\ntype MenuListProps = Omit<Reakit.MenuProps, keyof Reakit.MenuStateReturn | 'className'>\n\n/**\n * The dropdown menu itself, containing a list of menu items.\n */\nconst MenuList = polymorphicComponent<'div', MenuListProps>(function MenuList(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { handleItemSelect, ...state } = React.useContext(MenuContext)\n return state.visible ? (\n <MenuBackdrop {...state}>\n <Reakit.Menu\n {...props}\n {...state}\n ref={ref}\n className={classNames('reactist_menulist', exceptionallySetClassName)}\n />\n </MenuBackdrop>\n ) : null\n})\n\n//\n// MenuItem\n//\n\ntype MenuItemProps = {\n /**\n * An optional value given to this menu item. It is passed on to the parent `Menu`'s\n * `onItemSelect` when you provide that instead of (or alongside) providing individual\n * `onSelect` callbacks to each menu item.\n */\n value?: string\n /**\n * The content inside the menu item.\n */\n children: React.ReactNode\n /**\n * When `true` the menu item is disabled and won't be selectable or be part of the keyboard\n * navigation across the menu options.\n *\n * @default true\n */\n disabled?: boolean\n /**\n * When `true` the menu will close when the menu item is selected, in addition to performing the\n * action that the menu item is set out to do.\n *\n * Set this to `false` to make sure that a given menu item does not auto-closes the menu when\n * selected. This should be the exception and not the norm, as the default is to auto-close.\n *\n * @default true\n */\n hideOnSelect?: boolean\n /**\n * The action to perform when the menu item is selected.\n *\n * If you return `false` from this function, the menu will not auto-close when this menu item\n * is selected. Though you should use `hideOnSelect` for this purpose, this allows you to\n * achieve the same effect conditionally and dynamically deciding at run time.\n */\n onSelect?: () => unknown\n /**\n * The event handler called when the menu item is clicked.\n *\n * This is similar to `onSelect`, but a bit different. You can certainly use it to trigger the\n * action that the menu item represents. But in general you should prefer `onSelect` for that.\n *\n * The main use for this handler is to get access to the click event. This can be used, for\n * example, to call `event.preventDefault()`, which will effectively prevent the rest of the\n * consequences of the click, including preventing `onSelect` from being called. In particular,\n * this is useful in menu items that are links, and you want the click to not trigger navigation\n * under some circumstances.\n */\n onClick?: (event: React.MouseEvent) => void\n}\n\n/**\n * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`\n * callback.\n */\nconst MenuItem = polymorphicComponent<'button', MenuItemProps>(function MenuItem(\n {\n value,\n children,\n onSelect,\n hideOnSelect = true,\n onClick,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const { handleItemSelect, ...state } = React.useContext(MenuContext)\n const { hide } = state\n\n const handleClick = React.useCallback(\n function handleClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event)\n const onSelectResult: unknown =\n onSelect && !event.defaultPrevented ? onSelect() : undefined\n const shouldClose = onSelectResult !== false && hideOnSelect\n handleItemSelect(value)\n if (shouldClose) hide()\n },\n [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value],\n )\n\n return (\n <Reakit.MenuItem\n {...props}\n {...state}\n ref={ref}\n onClick={handleClick}\n className={exceptionallySetClassName}\n >\n {children}\n </Reakit.MenuItem>\n )\n})\n\n//\n// SubMenu\n//\n\ntype SubMenuProps = Pick<MenuProps, 'children' | 'onItemSelect'>\n\n/**\n * This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have\n * a sub-menu.\n *\n * Its children are expected to have the structure of a first level menu (a `MenuButton` and a\n * `MenuList`).\n *\n * ```jsx\n * <MenuItem label=\"Edit profile\" />\n * <SubMenu>\n * <MenuButton>More options</MenuButton>\n * <MenuList>\n * <MenuItem label=\"Preferences\" />\n * <MenuItem label=\"Sign out\" />\n * </MenuList>\n * </SubMenu>\n * ```\n *\n * The `MenuButton` will become a menu item in the current menu items list, and it will lead to\n * opening a sub-menu with the menu items list below it.\n */\nconst SubMenu = React.forwardRef<HTMLButtonElement, SubMenuProps>(function SubMenu(\n { children, onItemSelect, ...props },\n ref,\n) {\n const { handleItemSelect: parentMenuItemSelect, ...state } = React.useContext(MenuContext)\n const { hide: parentMenuHide } = state\n\n const handleSubItemSelect = React.useCallback(\n function handleSubItemSelect(value) {\n if (onItemSelect) onItemSelect(value)\n parentMenuItemSelect(value)\n parentMenuHide()\n },\n [parentMenuHide, parentMenuItemSelect, onItemSelect],\n )\n\n const [button, list] = React.Children.toArray(children)\n\n return (\n <Reakit.MenuItem {...state} {...props} ref={ref}>\n {(buttonProps) => (\n <Menu onItemSelect={handleSubItemSelect}>\n {React.cloneElement(button as React.ReactElement, {\n ...buttonProps,\n className: classNames(buttonProps.className, 'reactist_submenu_button'),\n })}\n {list}\n </Menu>\n )}\n </Reakit.MenuItem>\n )\n})\n\n//\n// MenuGroup\n//\n\ntype MenuGroupProps = Omit<NativeProps<HTMLDivElement>, 'className'> & {\n /**\n * A label to be shown visually and also used to semantically label the group.\n */\n label: string\n}\n\n/**\n * A way to semantically group some menu items.\n *\n * This group does not add any visual separator. You can do that yourself adding `<hr />` elements\n * before and/or after the group if you so wish.\n */\nconst MenuGroup = polymorphicComponent<'div', MenuGroupProps>(function MenuGroud(\n { label, children, exceptionallySetClassName, ...props },\n ref,\n) {\n const { handleItemSelect, ...state } = React.useContext(MenuContext)\n return (\n <Reakit.MenuGroup ref={ref} {...props} {...state} className={exceptionallySetClassName}>\n {label ? (\n <div role=\"presentation\" className=\"reactist_menugroup__label\">\n {label}\n </div>\n ) : null}\n {children}\n </Reakit.MenuGroup>\n )\n})\n\nexport { Menu, MenuButton, MenuList, MenuItem, SubMenu, MenuGroup }\nexport type { MenuButtonProps, MenuListProps, MenuItemProps, SubMenuProps, MenuGroupProps }\n"],"names":["MenuContext","React","Menu","children","onItemSelect","props","state","Reakit","loop","handleItemSelect","value","Provider","MenuButton","polymorphicComponent","ref","exceptionallySetClassName","className","classNames","BACKDROP_STYLE","width","height","position","top","left","MenuBackdrop","baseId","visible","animated","animating","stopAnimation","modal","PopoverBackdrop","style","MenuList","MenuItem","onSelect","hideOnSelect","onClick","hide","handleClick","event","onSelectResult","defaultPrevented","undefined","shouldClose","SubMenu","parentMenuItemSelect","parentMenuHide","handleSubItemSelect","toArray","button","list","buttonProps","MenuGroup","MenuGroud","label","role"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,IAAMA,WAAW,gBAAGC,aAAA;AAEhB;AACA;AACA;AACA;AACA,EANgB,CAApB;AA8BA;;;;;AAIA,SAASC,IAAT;MAAgBC,gBAAAA;MAAUC,oBAAAA;MAAiBC;;AACvC,MAAMC,KAAK,GAAGC,YAAA;AAAsBC,IAAAA,IAAI,EAAE;AAA5B,KAAqCH,KAArC,EAAd;AAEA,MAAMI,gBAAgB,GAAGR,WAAA,CACrB,SAASQ,gBAAT,CAA0BC,KAA1B;AACI,QAAIN,YAAJ,EAAkBA,YAAY,CAACM,KAAD,CAAZ;AACrB,GAHoB,EAIrB,CAACN,YAAD,CAJqB,CAAzB;AAOA,MAAMM,KAAK,GAAqBT,OAAA,CAC5B;AAAA,6CACOK,KADP;AAEIG,MAAAA,gBAAgB,EAAhBA;AAFJ;AAAA,GAD4B,EAK5B,CAACH,KAAD,EAAQG,gBAAR,CAL4B,CAAhC;AAQA,sBAAOR,aAAA,CAACD,WAAW,CAACW,QAAb;AAAsBD,IAAAA,KAAK,EAAEA;GAA7B,EAAqCP,QAArC,CAAP;AACH;AAQD;;;;;IAGMS,UAAU,gBAAGC,oBAAoB,CAA4B,SAASD,UAAT,QAE/DE,GAF+D;MAC7DC,kCAAAA;MAA8BV;;AAGhC,0BAAuCJ,UAAA,CAAiBD,WAAjB,CAAvC;AAAA,MAA6BM,KAA7B;;AACA,sBACIL,aAAA,CAACM,YAAD,oBACQF,OACAC;AACJQ,IAAAA,GAAG,EAAEA;AACLE,IAAAA,SAAS,EAAEC,UAAU,CAAC,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,YAAJ,EAAkBA,YAAY,CAACM,KAAD,CAAZ;AAClBoC,IAAAA,oBAAoB,CAACpC,KAAD,CAApB;AACAqC,IAAAA,cAAc;AACjB,GALuB,EAMxB,CAACA,cAAD,EAAiBD,oBAAjB,EAAuC1C,YAAvC,CANwB,CAA5B;;AASA,8BAAuBH,QAAA,CAAegD,OAAf,CAAuB9C,QAAvB,CAAvB;AAAA,MAAO+C,MAAP;AAAA,MAAeC,IAAf;;AAEA,sBACIlD,aAAA,CAACM,UAAD,oBAAqBD,OAAWD;AAAOS,IAAAA,GAAG,EAAEA;IAA5C,EACK,UAACsC,WAAD;AAAA,wBACGnD,aAAA,CAACC,IAAD;AAAME,MAAAA,YAAY,EAAE4C;KAApB,eACK/C,YAAA,CAAmBiD,MAAnB,oCACME,WADN;AAEGpC,MAAAA,SAAS,EAAEC,UAAU,CAACmC,WAAW,CAACpC,SAAb,EAAwB,yBAAxB;AAFxB,OADL,EAKKmC,IALL,CADH;AAAA,GADL,CADJ;AAaH,CA/Be;AA4ChB;;;;;;;IAMME,SAAS,gBAAGxC,oBAAoB,CAAwB,SAASyC,SAAT,QAE1DxC,GAF0D;MACxDyC,cAAAA;MAAOpD,iBAAAA;MAAUY,kCAAAA;MAA8BV;;AAGjD,2BAAuCJ,UAAA,CAAiBD,WAAjB,CAAvC;AAAA,MAA6BM,KAA7B;;AACA,sBACIL,aAAA,CAACM,WAAD;AAAkBO,IAAAA,GAAG,EAAEA;KAAST,OAAWC;AAAOU,IAAAA,SAAS,EAAED;IAA7D,EACKwC,KAAK,gBACFtD,aAAA,MAAA;AAAKuD,IAAAA,IAAI,EAAC;AAAexC,IAAAA,SAAS,EAAC;GAAnC,EACKuC,KADL,CADE,GAIF,IALR,EAMKpD,QANL,CADJ;AAUH,CAfqC;;;;"}
|
|
@@ -3,6 +3,8 @@ import React__default from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import CloseIcon from '../icons/CloseIcon.svg.js';
|
|
5
5
|
|
|
6
|
+
var _excluded = ["id", "icon", "title", "subtitle", "children", "customCloseButton", "onClick", "onClose", "closeAltText", "className"];
|
|
7
|
+
|
|
6
8
|
function Notification(_ref) {
|
|
7
9
|
var id = _ref.id,
|
|
8
10
|
icon = _ref.icon,
|
|
@@ -15,7 +17,7 @@ function Notification(_ref) {
|
|
|
15
17
|
_ref$closeAltText = _ref.closeAltText,
|
|
16
18
|
closeAltText = _ref$closeAltText === void 0 ? 'Close' : _ref$closeAltText,
|
|
17
19
|
className = _ref.className,
|
|
18
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
20
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
19
21
|
|
|
20
22
|
var titleId = title ? id + "-title" : null;
|
|
21
23
|
var titleIdAttribute = titleId ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.js","sources":["../../../src/components/notification/notification.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\nimport CloseIcon from '../icons/CloseIcon.svg'\nimport './notification.less'\n\ntype NotificationProps = {\n id: string\n icon?: React.ReactNode\n title?: React.ReactNode\n subtitle?: React.ReactNode\n children?: React.ReactNode\n customCloseButton?: React.ReactNode\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n onClose?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n closeAltText?: string\n className?: string\n} & JSX.IntrinsicElements['div']\n\nfunction Notification({\n id,\n icon,\n title,\n subtitle,\n children,\n customCloseButton,\n onClick,\n onClose,\n closeAltText = 'Close',\n className,\n ...rest\n}: NotificationProps) {\n const titleId = title ? `${id}-title` : null\n const titleIdAttribute = titleId ? { id: titleId } : null\n const subtitleId = subtitle ? `${id}-subtitle` : null\n const subtitleIdAttribute = subtitleId ? { id: subtitleId } : null\n const contentId = children ? `${id}-content` : null\n const contentIdAttribute = children ? { id: `${id}-content` } : null\n const ariaLabelledBy = contentId\n ? { 'aria-labelledby': contentId }\n : titleId\n ? { 'aria-labelledby': titleId }\n : null\n const ariaDescribedBy = subtitleId && !children ? { 'aria-describedby': subtitleId } : null\n\n const notificationContent = (\n <div className=\"reactist-notification__content\" {...contentIdAttribute}>\n {children ?? (\n <>\n {title ? (\n <h3 className=\"reactist-notification__title\" {...titleIdAttribute}>\n {title}\n </h3>\n ) : null}\n {subtitle ? (\n <p className=\"reactist-notification__subtitle\" {...subtitleIdAttribute}>\n {subtitle}\n </p>\n ) : null}\n </>\n )}\n </div>\n )\n const notificationBody = (\n <div className=\"reactist-notification__icon-content-group\">\n {icon ?? null}\n {notificationContent}\n </div>\n )\n\n return (\n <div\n id={id}\n role=\"dialog\"\n className={classNames('reactist-notification', className, {\n 'reactist-notification--with-button': Boolean(onClick),\n 'reactist-notification--with-close-button': Boolean(onClose),\n })}\n {...ariaLabelledBy}\n {...ariaDescribedBy}\n {...rest}\n >\n {onClick ? (\n <button className=\"reactist-notification__button\" onClick={onClick}>\n {notificationBody}\n </button>\n ) : (\n notificationBody\n )}\n\n {onClose ? (\n <button\n className=\"reactist-notification__close-button\"\n onClick={onClose}\n aria-label={closeAltText}\n >\n {customCloseButton ?? <CloseIcon />}\n </button>\n ) : null}\n </div>\n )\n}\n\nexport { Notification }\n"],"names":["Notification","id","icon","title","subtitle","children","customCloseButton","onClick","onClose","closeAltText","className","rest","titleId","titleIdAttribute","subtitleId","subtitleIdAttribute","contentId","contentIdAttribute","ariaLabelledBy","ariaDescribedBy","notificationContent","React","notificationBody","role","classNames","Boolean","CloseIcon"],"mappings":"
|
|
1
|
+
{"version":3,"file":"notification.js","sources":["../../../src/components/notification/notification.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\nimport CloseIcon from '../icons/CloseIcon.svg'\nimport './notification.less'\n\ntype NotificationProps = {\n id: string\n icon?: React.ReactNode\n title?: React.ReactNode\n subtitle?: React.ReactNode\n children?: React.ReactNode\n customCloseButton?: React.ReactNode\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n onClose?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n closeAltText?: string\n className?: string\n} & JSX.IntrinsicElements['div']\n\nfunction Notification({\n id,\n icon,\n title,\n subtitle,\n children,\n customCloseButton,\n onClick,\n onClose,\n closeAltText = 'Close',\n className,\n ...rest\n}: NotificationProps) {\n const titleId = title ? `${id}-title` : null\n const titleIdAttribute = titleId ? { id: titleId } : null\n const subtitleId = subtitle ? `${id}-subtitle` : null\n const subtitleIdAttribute = subtitleId ? { id: subtitleId } : null\n const contentId = children ? `${id}-content` : null\n const contentIdAttribute = children ? { id: `${id}-content` } : null\n const ariaLabelledBy = contentId\n ? { 'aria-labelledby': contentId }\n : titleId\n ? { 'aria-labelledby': titleId }\n : null\n const ariaDescribedBy = subtitleId && !children ? { 'aria-describedby': subtitleId } : null\n\n const notificationContent = (\n <div className=\"reactist-notification__content\" {...contentIdAttribute}>\n {children ?? (\n <>\n {title ? (\n <h3 className=\"reactist-notification__title\" {...titleIdAttribute}>\n {title}\n </h3>\n ) : null}\n {subtitle ? (\n <p className=\"reactist-notification__subtitle\" {...subtitleIdAttribute}>\n {subtitle}\n </p>\n ) : null}\n </>\n )}\n </div>\n )\n const notificationBody = (\n <div className=\"reactist-notification__icon-content-group\">\n {icon ?? null}\n {notificationContent}\n </div>\n )\n\n return (\n <div\n id={id}\n role=\"dialog\"\n className={classNames('reactist-notification', className, {\n 'reactist-notification--with-button': Boolean(onClick),\n 'reactist-notification--with-close-button': Boolean(onClose),\n })}\n {...ariaLabelledBy}\n {...ariaDescribedBy}\n {...rest}\n >\n {onClick ? (\n <button className=\"reactist-notification__button\" onClick={onClick}>\n {notificationBody}\n </button>\n ) : (\n notificationBody\n )}\n\n {onClose ? (\n <button\n className=\"reactist-notification__close-button\"\n onClick={onClose}\n aria-label={closeAltText}\n >\n {customCloseButton ?? <CloseIcon />}\n </button>\n ) : null}\n </div>\n )\n}\n\nexport { Notification }\n"],"names":["Notification","id","icon","title","subtitle","children","customCloseButton","onClick","onClose","closeAltText","className","rest","titleId","titleIdAttribute","subtitleId","subtitleIdAttribute","contentId","contentIdAttribute","ariaLabelledBy","ariaDescribedBy","notificationContent","React","notificationBody","role","classNames","Boolean","CloseIcon"],"mappings":";;;;;;;AAkBA,SAASA,YAAT;MACIC,UAAAA;MACAC,YAAAA;MACAC,aAAAA;MACAC,gBAAAA;MACAC,gBAAAA;MACAC,yBAAAA;MACAC,eAAAA;MACAC,eAAAA;+BACAC;MAAAA,8CAAe;MACfC,iBAAAA;MACGC;;AAEH,MAAMC,OAAO,GAAGT,KAAK,GAAMF,EAAN,cAAmB,IAAxC;AACA,MAAMY,gBAAgB,GAAGD,OAAO,GAAG;AAAEX,IAAAA,EAAE,EAAEW;AAAN,GAAH,GAAqB,IAArD;AACA,MAAME,UAAU,GAAGV,QAAQ,GAAMH,EAAN,iBAAsB,IAAjD;AACA,MAAMc,mBAAmB,GAAGD,UAAU,GAAG;AAAEb,IAAAA,EAAE,EAAEa;AAAN,GAAH,GAAwB,IAA9D;AACA,MAAME,SAAS,GAAGX,QAAQ,GAAMJ,EAAN,gBAAqB,IAA/C;AACA,MAAMgB,kBAAkB,GAAGZ,QAAQ,GAAG;AAAEJ,IAAAA,EAAE,EAAKA,EAAL;AAAJ,GAAH,GAA6B,IAAhE;AACA,MAAMiB,cAAc,GAAGF,SAAS,GAC1B;AAAE,uBAAmBA;AAArB,GAD0B,GAE1BJ,OAAO,GACP;AAAE,uBAAmBA;AAArB,GADO,GAEP,IAJN;AAKA,MAAMO,eAAe,GAAGL,UAAU,IAAI,CAACT,QAAf,GAA0B;AAAE,wBAAoBS;AAAtB,GAA1B,GAA+D,IAAvF;AAEA,MAAMM,mBAAmB,gBACrBC,4BAAA,MAAA;AAAKX,IAAAA,SAAS,EAAC;KAAqCO,mBAApD,EACKZ,QADL,aACKA,QADL,cACKA,QADL,gBAEQgB,4BAAA,wBAAA,MAAA,EACKlB,KAAK,gBACFkB,4BAAA,KAAA;AAAIX,IAAAA,SAAS,EAAC;KAAmCG,iBAAjD,EACKV,KADL,CADE,GAIF,IALR,EAMKC,QAAQ,gBACLiB,4BAAA,IAAA;AAAGX,IAAAA,SAAS,EAAC;KAAsCK,oBAAnD,EACKX,QADL,CADK,GAIL,IAVR,CAFR,CADJ;AAkBA,MAAMkB,gBAAgB,gBAClBD,4BAAA,MAAA;AAAKX,IAAAA,SAAS,EAAC;GAAf,EACKR,IADL,aACKA,IADL,cACKA,IADL,GACa,IADb,EAEKkB,mBAFL,CADJ;AAOA,sBACIC,4BAAA,MAAA;AACIpB,IAAAA,EAAE,EAAEA;AACJsB,IAAAA,IAAI,EAAC;AACLb,IAAAA,SAAS,EAAEc,UAAU,CAAC,uBAAD,EAA0Bd,SAA1B,EAAqC;AACtD,4CAAsCe,OAAO,CAAClB,OAAD,CADS;AAEtD,kDAA4CkB,OAAO,CAACjB,OAAD;AAFG,KAArC;KAIjBU,gBACAC,iBACAR,KATR,EAWKJ,OAAO,gBACJc,4BAAA,SAAA;AAAQX,IAAAA,SAAS,EAAC;AAAgCH,IAAAA,OAAO,EAAEA;GAA3D,EACKe,gBADL,CADI,GAKJA,gBAhBR,EAmBKd,OAAO,gBACJa,4BAAA,SAAA;AACIX,IAAAA,SAAS,EAAC;AACVH,IAAAA,OAAO,EAAEC;kBACGC;GAHhB,EAKKH,iBALL,aAKKA,iBALL,cAKKA,iBALL,gBAK0Be,4BAAA,CAACK,SAAD,MAAA,CAL1B,CADI,GAQJ,IA3BR,CADJ;AA+BH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport { hasEnoughSpace, calculatePosition, RelativePosition } from './positioning-utils'\n\nimport './popover.less'\n\n/**\n * Position of the popover. Defaults to `auto`.\n * `auto` tries to position the tooltip to the top,\n * if there's not enough space it tries to position the tooltip clockwise (right, bottom, left).\n * Setting a distinct value like `right` will always position the popover right, regardless of available space.\n * Specifying `horizontal` will only try to position the tooltip left and right in that order.\n * Specifying `vertical` will only try to position the tooltip top and bottom in that order.\n */\ntype Position = 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal' | 'auto'\n\ntype Props = {\n visible?: boolean\n /** ref of the popover in case you need to manipulate it. */\n popoverRef?: React.Ref<HTMLElement>\n /** ref of the wrapper in case you need to manipulate it. */\n wrapperRef?: React.Ref<HTMLElement>\n /** Function to be called when the mouse enters the trigger. */\n onMouseEnter?: React.MouseEventHandler\n /** Function to be called when the mouse leaves the trigger. */\n onMouseLeave?: React.MouseEventHandler\n onClick?: React.MouseEventHandler\n /** Additional css class that is applied to the wrapper element. */\n wrapperClassName?: string\n /** Additional css class that is applied to the popover element. */\n popoverClassName?: string\n /** Additional css class that is applied to style the arrow. Not applied when `withArrow` is false. */\n arrowClassName?: string\n /** Content prop of the popover. */\n content?: (() => React.ReactNode) | React.ReactNode\n trigger?: React.ReactNode\n position: Position\n withArrow?: boolean\n /**\n * Whether vague positioning is allowed. When set to true the popover prefers to be fully visible over being correctly centered.\n */\n allowVaguePositioning?: boolean\n /** Gap between the popover wrapper and the arrow. */\n gapSize: number\n}\n\nclass Popover extends React.Component<Props> {\n public static displayName: string\n public static defaultProps: Props\n\n componentDidMount() {\n if (this.props.visible) {\n this._updatePopoverPosition()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (this.wrapper && this.props.visible) {\n const positionChanged = prevProps.position !== this.props.position\n const vaguePositioningChanged =\n prevProps.allowVaguePositioning !== this.props.allowVaguePositioning\n const visibilityChanged = prevProps.visible !== this.props.visible\n const arrowChanged = prevProps.withArrow !== this.props.withArrow\n const gapSizeChanged = prevProps.gapSize !== this.props.gapSize\n const contentChanged = prevProps.content !== this.props.content\n if (\n positionChanged ||\n vaguePositioningChanged ||\n visibilityChanged ||\n arrowChanged ||\n gapSizeChanged ||\n contentChanged\n ) {\n this._updatePopoverPosition()\n }\n }\n }\n\n popover!: HTMLElement\n wrapper!: HTMLElement\n\n _updatePopoverPosition = () => {\n const { position, allowVaguePositioning, gapSize } = this.props\n const wrapperRect = this.wrapper.getBoundingClientRect()\n const popoverRect = this.popover.getBoundingClientRect()\n\n // Instead of using the documentElement find the nearest absolutely positioned element\n const documentEl = document.documentElement\n let node = this.wrapper\n let foundParent = false\n while (!foundParent) {\n const styles = getComputedStyle(node)\n const position = styles.getPropertyValue('position')\n if (position === 'absolute' || node === documentEl || !node.parentElement) {\n foundParent = true\n } else {\n node = node.parentElement\n }\n }\n const nodeRect = node.getBoundingClientRect()\n const windowDimensions = {\n height: nodeRect.height,\n width: nodeRect.width,\n }\n\n const popoverDimensions = {\n height: popoverRect.height,\n width: popoverRect.width,\n }\n const wrapperDimensions = {\n height: wrapperRect.height,\n width: wrapperRect.width,\n }\n const wrapperPositionRelative = {\n x: wrapperRect.left - nodeRect.left,\n y: wrapperRect.top - nodeRect.top,\n }\n const wrapperPositionAbsolute = {\n x: wrapperRect.left,\n y: wrapperRect.top,\n }\n\n const positionsToTry: RelativePosition[] =\n position === 'auto'\n ? ['top', 'right', 'bottom', 'left', 'top']\n : position === 'vertical'\n ? ['top', 'bottom']\n : position === 'horizontal'\n ? ['left', 'right']\n : [position]\n\n for (let index = 0; index < positionsToTry.length; index++) {\n const currentPosition = positionsToTry[index]\n const enoughSpaceAtPosition = hasEnoughSpace(\n windowDimensions,\n popoverDimensions,\n wrapperDimensions,\n wrapperPositionRelative,\n currentPosition,\n gapSize,\n )\n\n if (enoughSpaceAtPosition || index === positionsToTry.length - 1) {\n const popoverPosition = calculatePosition(\n currentPosition,\n wrapperDimensions,\n wrapperPositionAbsolute,\n popoverDimensions,\n gapSize,\n )\n this.popover.style.top = `${popoverPosition.y}px`\n this.popover.style.left = `${popoverPosition.x}px`\n\n /**\n * Correct placement if vague positioning is allowed.\n * When it's not allowed we \"cut off\" popovers and display them\n * out of the viewport to maintain their centered position.\n */\n if (allowVaguePositioning) {\n // correct horizontally\n if (popoverPosition.x < 0) {\n this.popover.style.left = `${2 * gapSize}px`\n }\n // correct vertically\n if (popoverPosition.y + popoverDimensions.height > windowDimensions.height) {\n this.popover.style.top = `${\n windowDimensions.height - popoverDimensions.height - 2 * gapSize\n }px`\n }\n }\n\n if (currentPosition !== position) {\n this.popover.className = this._getClassNameForPosition(currentPosition)\n }\n break\n }\n }\n }\n\n _getClassNameForPosition = (position: Position) => {\n const { visible, withArrow, arrowClassName } = this.props\n const className = classNames('reactist_popover', { visible })\n\n if (visible && withArrow) {\n return classNames(className, arrowClassName, {\n arrow_top: position === 'bottom',\n arrow_right: position === 'left',\n arrow_bottom: position === 'auto' || position === 'top',\n arrow_left: position === 'right',\n })\n }\n return className\n }\n\n _updatePopoverRef = (popover: HTMLElement) => {\n this.popover = popover\n if (typeof this.props.popoverRef === 'function') {\n this.props.popoverRef(popover)\n }\n }\n\n _updateWrapperRef = (wrapper: HTMLElement) => {\n this.wrapper = wrapper\n if (typeof this.props.wrapperRef === 'function') {\n this.props.wrapperRef(wrapper)\n }\n }\n\n render() {\n const {\n position,\n wrapperClassName,\n popoverClassName,\n onMouseEnter,\n onMouseLeave,\n onClick,\n trigger,\n content,\n } = this.props\n const popoverClass = position ? this._getClassNameForPosition(position) : ''\n const popoverContentClass = classNames('reactist_popover__content', popoverClassName)\n const wrapperClass = classNames('reactist_popover__wrapper', wrapperClassName)\n const triggerElement = React.Children.only<React.ReactElement>(\n trigger as React.ReactElement,\n )\n\n function handleTriggerClick(event: React.SyntheticEvent) {\n // @ts-expect-error This is temporary while we revisit the Popover interface\n if (onClick) onClick(event)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (typeof triggerElement.props.onClick === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n triggerElement.props.onClick(event)\n }\n }\n\n return (\n <span\n className={wrapperClass}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={this._updateWrapperRef}\n >\n {React.cloneElement(triggerElement, { onClick: handleTriggerClick })}\n <span className={popoverClass} ref={this._updatePopoverRef}>\n {this.props.visible ? (\n <span className={popoverContentClass}>\n {typeof content === 'function' ? content() : content}\n </span>\n ) : null}\n </span>\n </span>\n )\n }\n}\nPopover.displayName = 'Popover'\nPopover.defaultProps = {\n position: 'auto',\n gapSize: 5, // default size of the arrow (see `tooltip.less`)\n}\n\nexport { Popover }\n"],"names":["Popover","props","position","allowVaguePositioning","gapSize","wrapperRect","wrapper","getBoundingClientRect","popoverRect","popover","documentEl","document","documentElement","node","foundParent","styles","getComputedStyle","getPropertyValue","parentElement","nodeRect","windowDimensions","height","width","popoverDimensions","wrapperDimensions","wrapperPositionRelative","x","left","y","top","wrapperPositionAbsolute","positionsToTry","index","length","currentPosition","enoughSpaceAtPosition","hasEnoughSpace","popoverPosition","calculatePosition","style","className","_getClassNameForPosition","visible","withArrow","arrowClassName","classNames","arrow_top","arrow_right","arrow_bottom","arrow_left","popoverRef","wrapperRef","componentDidMount","_updatePopoverPosition","componentDidUpdate","prevProps","positionChanged","vaguePositioningChanged","visibilityChanged","arrowChanged","gapSizeChanged","contentChanged","content","render","wrapperClassName","popoverClassName","onMouseEnter","onMouseLeave","onClick","trigger","popoverClass","popoverContentClass","wrapperClass","triggerElement","React","Children","only","handleTriggerClick","event","ref","_updateWrapperRef","cloneElement","_updatePopoverRef","Component","displayName","defaultProps"],"mappings":";;;;;IA+CMA;;;AAAN;;;;;AAmCI,gCAAA,GAAyB;wBACgC,MAAKC;UAAlDC,uBAAAA;UAAUC,oCAAAA;UAAuBC,sBAAAA;;AACzC,UAAMC,WAAW,GAAG,MAAKC,OAAL,CAAaC,qBAAb,EAApB;;AACA,UAAMC,WAAW,GAAG,MAAKC,OAAL,CAAaF,qBAAb,EAApB;;;AAGA,UAAMG,UAAU,GAAGC,QAAQ,CAACC,eAA5B;AACA,UAAIC,IAAI,GAAG,MAAKP,OAAhB;AACA,UAAIQ,WAAW,GAAG,KAAlB;;AACA,aAAO,CAAC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,kBAAT,CAA4BC,KAA5B;AACI;AACA,UAAIV,OAAJ,EAAaA,OAAO,CAACU,KAAD,CAAP;;AAEb,UAAI,OAAOL,cAAc,CAACxE,KAAf,CAAqBmE,OAA5B,KAAwC,UAA5C,EAAwD;AACpD;AACAK,QAAAA,cAAc,CAACxE,KAAf,CAAqBmE,OAArB,CAA6BU,KAA7B;AACH;AACJ;;AAED,wBACIJ,4BAAA,OAAA;AACIlC,MAAAA,SAAS,EAAEgC;AACXN,MAAAA,YAAY,EAAEA;AACdC,MAAAA,YAAY,EAAEA;AACdY,MAAAA,GAAG,EAAE,KAAKC;KAJd,eAMKN,cAAK,CAACO,YAAN,CAAmBR,cAAnB,EAAmC;AAAEL,MAAAA,OAAO,EAAES;AAAX,KAAnC,CANL,eAOIH,4BAAA,OAAA;AAAMlC,MAAAA,SAAS,EAAE8B;AAAcS,MAAAA,GAAG,EAAE,KAAKG;KAAzC,EACK,KAAKjF,KAAL,CAAWyC,OAAX,gBACGgC,4BAAA,OAAA;AAAMlC,MAAAA,SAAS,EAAE+B;KAAjB,EACK,OAAOT,OAAP,KAAmB,UAAnB,GAAgCA,OAAO,EAAvC,GAA4CA,OADjD,CADH,GAIG,IALR,CAPJ,CADJ;AAiBH;;;EA/MiBY,cAAK,CAACS;;AAiN5BnF,OAAO,CAACoF,WAAR,GAAsB,SAAtB;AACApF,OAAO,CAACqF,YAAR,GAAuB;AACnBnF,EAAAA,QAAQ,EAAE,MADS;AAEnBE,EAAAA,OAAO,EAAE;AAFU,CAAvB;;;;"}
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport { hasEnoughSpace, calculatePosition, RelativePosition } from './positioning-utils'\n\nimport './popover.less'\n\n/**\n * Position of the popover. Defaults to `auto`.\n * `auto` tries to position the tooltip to the top,\n * if there's not enough space it tries to position the tooltip clockwise (right, bottom, left).\n * Setting a distinct value like `right` will always position the popover right, regardless of available space.\n * Specifying `horizontal` will only try to position the tooltip left and right in that order.\n * Specifying `vertical` will only try to position the tooltip top and bottom in that order.\n */\ntype Position = 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal' | 'auto'\n\ntype Props = {\n visible?: boolean\n /** ref of the popover in case you need to manipulate it. */\n popoverRef?: React.Ref<HTMLElement>\n /** ref of the wrapper in case you need to manipulate it. */\n wrapperRef?: React.Ref<HTMLElement>\n /** Function to be called when the mouse enters the trigger. */\n onMouseEnter?: React.MouseEventHandler\n /** Function to be called when the mouse leaves the trigger. */\n onMouseLeave?: React.MouseEventHandler\n onClick?: React.MouseEventHandler\n /** Additional css class that is applied to the wrapper element. */\n wrapperClassName?: string\n /** Additional css class that is applied to the popover element. */\n popoverClassName?: string\n /** Additional css class that is applied to style the arrow. Not applied when `withArrow` is false. */\n arrowClassName?: string\n /** Content prop of the popover. */\n content?: (() => React.ReactNode) | React.ReactNode\n trigger?: React.ReactNode\n position: Position\n withArrow?: boolean\n /**\n * Whether vague positioning is allowed. When set to true the popover prefers to be fully visible over being correctly centered.\n */\n allowVaguePositioning?: boolean\n /** Gap between the popover wrapper and the arrow. */\n gapSize: number\n}\n\nclass Popover extends React.Component<Props> {\n public static displayName: string\n public static defaultProps: Props\n\n componentDidMount() {\n if (this.props.visible) {\n this._updatePopoverPosition()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (this.wrapper && this.props.visible) {\n const positionChanged = prevProps.position !== this.props.position\n const vaguePositioningChanged =\n prevProps.allowVaguePositioning !== this.props.allowVaguePositioning\n const visibilityChanged = prevProps.visible !== this.props.visible\n const arrowChanged = prevProps.withArrow !== this.props.withArrow\n const gapSizeChanged = prevProps.gapSize !== this.props.gapSize\n const contentChanged = prevProps.content !== this.props.content\n if (\n positionChanged ||\n vaguePositioningChanged ||\n visibilityChanged ||\n arrowChanged ||\n gapSizeChanged ||\n contentChanged\n ) {\n this._updatePopoverPosition()\n }\n }\n }\n\n popover!: HTMLElement\n wrapper!: HTMLElement\n\n _updatePopoverPosition = () => {\n const { position, allowVaguePositioning, gapSize } = this.props\n const wrapperRect = this.wrapper.getBoundingClientRect()\n const popoverRect = this.popover.getBoundingClientRect()\n\n // Instead of using the documentElement find the nearest absolutely positioned element\n const documentEl = document.documentElement\n let node = this.wrapper\n let foundParent = false\n while (!foundParent) {\n const styles = getComputedStyle(node)\n const position = styles.getPropertyValue('position')\n if (position === 'absolute' || node === documentEl || !node.parentElement) {\n foundParent = true\n } else {\n node = node.parentElement\n }\n }\n const nodeRect = node.getBoundingClientRect()\n const windowDimensions = {\n height: nodeRect.height,\n width: nodeRect.width,\n }\n\n const popoverDimensions = {\n height: popoverRect.height,\n width: popoverRect.width,\n }\n const wrapperDimensions = {\n height: wrapperRect.height,\n width: wrapperRect.width,\n }\n const wrapperPositionRelative = {\n x: wrapperRect.left - nodeRect.left,\n y: wrapperRect.top - nodeRect.top,\n }\n const wrapperPositionAbsolute = {\n x: wrapperRect.left,\n y: wrapperRect.top,\n }\n\n const positionsToTry: RelativePosition[] =\n position === 'auto'\n ? ['top', 'right', 'bottom', 'left', 'top']\n : position === 'vertical'\n ? ['top', 'bottom']\n : position === 'horizontal'\n ? ['left', 'right']\n : [position]\n\n for (let index = 0; index < positionsToTry.length; index++) {\n const currentPosition = positionsToTry[index]\n const enoughSpaceAtPosition = hasEnoughSpace(\n windowDimensions,\n popoverDimensions,\n wrapperDimensions,\n wrapperPositionRelative,\n currentPosition,\n gapSize,\n )\n\n if (enoughSpaceAtPosition || index === positionsToTry.length - 1) {\n const popoverPosition = calculatePosition(\n currentPosition,\n wrapperDimensions,\n wrapperPositionAbsolute,\n popoverDimensions,\n gapSize,\n )\n this.popover.style.top = `${popoverPosition.y}px`\n this.popover.style.left = `${popoverPosition.x}px`\n\n /**\n * Correct placement if vague positioning is allowed.\n * When it's not allowed we \"cut off\" popovers and display them\n * out of the viewport to maintain their centered position.\n */\n if (allowVaguePositioning) {\n // correct horizontally\n if (popoverPosition.x < 0) {\n this.popover.style.left = `${2 * gapSize}px`\n }\n // correct vertically\n if (popoverPosition.y + popoverDimensions.height > windowDimensions.height) {\n this.popover.style.top = `${\n windowDimensions.height - popoverDimensions.height - 2 * gapSize\n }px`\n }\n }\n\n if (currentPosition !== position) {\n this.popover.className = this._getClassNameForPosition(currentPosition)\n }\n break\n }\n }\n }\n\n _getClassNameForPosition = (position: Position) => {\n const { visible, withArrow, arrowClassName } = this.props\n const className = classNames('reactist_popover', { visible })\n\n if (visible && withArrow) {\n return classNames(className, arrowClassName, {\n arrow_top: position === 'bottom',\n arrow_right: position === 'left',\n arrow_bottom: position === 'auto' || position === 'top',\n arrow_left: position === 'right',\n })\n }\n return className\n }\n\n _updatePopoverRef = (popover: HTMLElement) => {\n this.popover = popover\n if (typeof this.props.popoverRef === 'function') {\n this.props.popoverRef(popover)\n }\n }\n\n _updateWrapperRef = (wrapper: HTMLElement) => {\n this.wrapper = wrapper\n if (typeof this.props.wrapperRef === 'function') {\n this.props.wrapperRef(wrapper)\n }\n }\n\n render() {\n const {\n position,\n wrapperClassName,\n popoverClassName,\n onMouseEnter,\n onMouseLeave,\n onClick,\n trigger,\n content,\n } = this.props\n const popoverClass = position ? this._getClassNameForPosition(position) : ''\n const popoverContentClass = classNames('reactist_popover__content', popoverClassName)\n const wrapperClass = classNames('reactist_popover__wrapper', wrapperClassName)\n const triggerElement = React.Children.only<React.ReactElement>(\n trigger as React.ReactElement,\n )\n\n function handleTriggerClick(event: React.SyntheticEvent) {\n // @ts-expect-error This is temporary while we revisit the Popover interface\n if (onClick) onClick(event)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (typeof triggerElement.props.onClick === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n triggerElement.props.onClick(event)\n }\n }\n\n return (\n <span\n className={wrapperClass}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={this._updateWrapperRef}\n >\n {React.cloneElement(triggerElement, { onClick: handleTriggerClick })}\n <span className={popoverClass} ref={this._updatePopoverRef}>\n {this.props.visible ? (\n <span className={popoverContentClass}>\n {typeof content === 'function' ? content() : content}\n </span>\n ) : null}\n </span>\n </span>\n )\n }\n}\nPopover.displayName = 'Popover'\nPopover.defaultProps = {\n position: 'auto',\n gapSize: 5, // default size of the arrow (see `tooltip.less`)\n}\n\nexport { Popover }\n"],"names":["Popover","props","position","allowVaguePositioning","gapSize","wrapperRect","wrapper","getBoundingClientRect","popoverRect","popover","documentEl","document","documentElement","node","foundParent","styles","getComputedStyle","getPropertyValue","parentElement","nodeRect","windowDimensions","height","width","popoverDimensions","wrapperDimensions","wrapperPositionRelative","x","left","y","top","wrapperPositionAbsolute","positionsToTry","index","length","currentPosition","enoughSpaceAtPosition","hasEnoughSpace","popoverPosition","calculatePosition","style","className","_getClassNameForPosition","visible","withArrow","arrowClassName","classNames","arrow_top","arrow_right","arrow_bottom","arrow_left","popoverRef","wrapperRef","componentDidMount","_updatePopoverPosition","componentDidUpdate","prevProps","positionChanged","vaguePositioningChanged","visibilityChanged","arrowChanged","gapSizeChanged","contentChanged","content","render","wrapperClassName","popoverClassName","onMouseEnter","onMouseLeave","onClick","trigger","popoverClass","popoverContentClass","wrapperClass","triggerElement","React","Children","only","handleTriggerClick","event","ref","_updateWrapperRef","cloneElement","_updatePopoverRef","Component","displayName","defaultProps"],"mappings":";;;;;IA+CMA;;;AAAN;;;;;AAmCI,gCAAA,GAAyB;AACrB,wBAAqD,MAAKC,KAA1D;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,qBAAlB,eAAkBA,qBAAlB;AAAA,UAAyCC,OAAzC,eAAyCA,OAAzC;;AACA,UAAMC,WAAW,GAAG,MAAKC,OAAL,CAAaC,qBAAb,EAApB;;AACA,UAAMC,WAAW,GAAG,MAAKC,OAAL,CAAaF,qBAAb,EAApB;;;AAGA,UAAMG,UAAU,GAAGC,QAAQ,CAACC,eAA5B;AACA,UAAIC,IAAI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AA,OAAO,EAAE;AAFU,CAAvB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positioning-utils.js","sources":["../../../src/components/popover/positioning-utils.ts"],"sourcesContent":["type Dimensions = { width: number; height: number }\ntype AbsolutePosition = { x: number; y: number }\ntype RelativePosition = 'top' | 'right' | 'bottom' | 'left'\n\ntype HasEnoughSpaceFn = (\n windowDimensions: Dimensions,\n elementDimensions: Dimensions,\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n position: RelativePosition,\n gap: number,\n) => boolean\n\nconst hasEnoughSpace: HasEnoughSpaceFn = (\n windowDimensions,\n elementDimensions,\n wrapperDimensions,\n wrapperPosition,\n position,\n gap = 0,\n) => {\n const { height: windowHeight, width: windowWidth } = windowDimensions\n const { height: elementHeight, width: elementWidth } = elementDimensions\n const { height: wrapperHeight, width: wrapperWidth } = wrapperDimensions\n const { x: wrapperX, y: wrapperY } = wrapperPosition\n\n const verticalPosition = _calculateVerticalPosition(\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n )\n const horizontalPosition = _calculateHorizontalPosition(\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n )\n const canPlaceVertically =\n verticalPosition >= 0 && verticalPosition + elementWidth <= windowWidth\n const canPlaceHorizontally =\n horizontalPosition >= 0 && horizontalPosition + elementHeight <= windowHeight\n\n if (position === 'top') {\n return canPlaceVertically && wrapperY - elementHeight - gap >= 0\n } else if (position === 'right') {\n return canPlaceHorizontally && wrapperX + wrapperWidth + elementWidth + gap <= windowWidth\n } else if (position === 'left') {\n return canPlaceHorizontally && wrapperX - elementWidth - gap >= 0\n } else if (position === 'bottom') {\n return canPlaceVertically && wrapperY + wrapperHeight + elementHeight + gap <= windowHeight\n }\n return false\n}\n\ntype VerticalHorizontalPositionFn = (\n wrapperPosition: AbsolutePosition,\n wrapperDimensions: Dimensions,\n elementDimensions: Dimensions,\n) => number\n\nconst _calculateVerticalPosition: VerticalHorizontalPositionFn = (\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n) => {\n return wrapperPosition.x + (wrapperDimensions.width - elementDimensions.width) / 2\n}\n\nconst _calculateHorizontalPosition: VerticalHorizontalPositionFn = (\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n) => {\n return wrapperPosition.y + (wrapperDimensions.height - elementDimensions.height) / 2\n}\n\ntype CenterPositionFn = (\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n elementDimensions: Dimensions,\n gap?: number,\n) => AbsolutePosition\n\nconst calculateTopCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = _calculateVerticalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n const y = wrapperPosition.y - elementDimensions.height - gap\n return { x, y }\n}\n\nconst calculateBottomCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = _calculateVerticalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n const y = wrapperPosition.y + wrapperDimensions.height + gap\n return { x, y }\n}\n\nconst calculateRightCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = wrapperPosition.x + wrapperDimensions.width + gap\n const y = _calculateHorizontalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n return { x, y }\n}\n\nconst calculateLeftCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = wrapperPosition.x - elementDimensions.width - gap\n const y = _calculateHorizontalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n return { x, y }\n}\n\ntype PositionFn = (\n position: 'top' | 'right' | 'bottom' | 'left',\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n elementDimensions: Dimensions,\n gap?: number,\n) => AbsolutePosition\n\nconst calculatePosition: PositionFn = (\n position,\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n if (position === 'top') {\n return calculateTopCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'right') {\n return calculateRightCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'bottom') {\n return calculateBottomCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'left') {\n return calculateLeftCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n }\n return wrapperPosition\n}\n\nexport {\n hasEnoughSpace,\n calculatePosition,\n calculateTopCenterPosition,\n calculateBottomCenterPosition,\n calculateRightCenterPosition,\n calculateLeftCenterPosition,\n RelativePosition,\n}\n"],"names":["hasEnoughSpace","windowDimensions","elementDimensions","wrapperDimensions","wrapperPosition","position","gap","windowHeight","height","windowWidth","width","elementHeight","elementWidth","wrapperHeight","wrapperWidth","wrapperX","x","wrapperY","y","verticalPosition","_calculateVerticalPosition","horizontalPosition","_calculateHorizontalPosition","canPlaceVertically","canPlaceHorizontally","calculateTopCenterPosition","calculateBottomCenterPosition","calculateRightCenterPosition","calculateLeftCenterPosition","calculatePosition"],"mappings":"IAaMA,cAAc,GAAqB,SAAnCA,cAAmC,CACrCC,gBADqC,EAErCC,iBAFqC,EAGrCC,iBAHqC,EAIrCC,eAJqC,EAKrCC,QALqC,EAMrCC,GANqC;MAMrCA;AAAAA,IAAAA,MAAM;;;
|
|
1
|
+
{"version":3,"file":"positioning-utils.js","sources":["../../../src/components/popover/positioning-utils.ts"],"sourcesContent":["type Dimensions = { width: number; height: number }\ntype AbsolutePosition = { x: number; y: number }\ntype RelativePosition = 'top' | 'right' | 'bottom' | 'left'\n\ntype HasEnoughSpaceFn = (\n windowDimensions: Dimensions,\n elementDimensions: Dimensions,\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n position: RelativePosition,\n gap: number,\n) => boolean\n\nconst hasEnoughSpace: HasEnoughSpaceFn = (\n windowDimensions,\n elementDimensions,\n wrapperDimensions,\n wrapperPosition,\n position,\n gap = 0,\n) => {\n const { height: windowHeight, width: windowWidth } = windowDimensions\n const { height: elementHeight, width: elementWidth } = elementDimensions\n const { height: wrapperHeight, width: wrapperWidth } = wrapperDimensions\n const { x: wrapperX, y: wrapperY } = wrapperPosition\n\n const verticalPosition = _calculateVerticalPosition(\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n )\n const horizontalPosition = _calculateHorizontalPosition(\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n )\n const canPlaceVertically =\n verticalPosition >= 0 && verticalPosition + elementWidth <= windowWidth\n const canPlaceHorizontally =\n horizontalPosition >= 0 && horizontalPosition + elementHeight <= windowHeight\n\n if (position === 'top') {\n return canPlaceVertically && wrapperY - elementHeight - gap >= 0\n } else if (position === 'right') {\n return canPlaceHorizontally && wrapperX + wrapperWidth + elementWidth + gap <= windowWidth\n } else if (position === 'left') {\n return canPlaceHorizontally && wrapperX - elementWidth - gap >= 0\n } else if (position === 'bottom') {\n return canPlaceVertically && wrapperY + wrapperHeight + elementHeight + gap <= windowHeight\n }\n return false\n}\n\ntype VerticalHorizontalPositionFn = (\n wrapperPosition: AbsolutePosition,\n wrapperDimensions: Dimensions,\n elementDimensions: Dimensions,\n) => number\n\nconst _calculateVerticalPosition: VerticalHorizontalPositionFn = (\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n) => {\n return wrapperPosition.x + (wrapperDimensions.width - elementDimensions.width) / 2\n}\n\nconst _calculateHorizontalPosition: VerticalHorizontalPositionFn = (\n wrapperPosition,\n wrapperDimensions,\n elementDimensions,\n) => {\n return wrapperPosition.y + (wrapperDimensions.height - elementDimensions.height) / 2\n}\n\ntype CenterPositionFn = (\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n elementDimensions: Dimensions,\n gap?: number,\n) => AbsolutePosition\n\nconst calculateTopCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = _calculateVerticalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n const y = wrapperPosition.y - elementDimensions.height - gap\n return { x, y }\n}\n\nconst calculateBottomCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = _calculateVerticalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n const y = wrapperPosition.y + wrapperDimensions.height + gap\n return { x, y }\n}\n\nconst calculateRightCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = wrapperPosition.x + wrapperDimensions.width + gap\n const y = _calculateHorizontalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n return { x, y }\n}\n\nconst calculateLeftCenterPosition: CenterPositionFn = (\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n const x = wrapperPosition.x - elementDimensions.width - gap\n const y = _calculateHorizontalPosition(wrapperPosition, wrapperDimensions, elementDimensions)\n return { x, y }\n}\n\ntype PositionFn = (\n position: 'top' | 'right' | 'bottom' | 'left',\n wrapperDimensions: Dimensions,\n wrapperPosition: AbsolutePosition,\n elementDimensions: Dimensions,\n gap?: number,\n) => AbsolutePosition\n\nconst calculatePosition: PositionFn = (\n position,\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap = 0,\n) => {\n if (position === 'top') {\n return calculateTopCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'right') {\n return calculateRightCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'bottom') {\n return calculateBottomCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n } else if (position === 'left') {\n return calculateLeftCenterPosition(\n wrapperDimensions,\n wrapperPosition,\n elementDimensions,\n gap,\n )\n }\n return wrapperPosition\n}\n\nexport {\n hasEnoughSpace,\n calculatePosition,\n calculateTopCenterPosition,\n calculateBottomCenterPosition,\n calculateRightCenterPosition,\n calculateLeftCenterPosition,\n RelativePosition,\n}\n"],"names":["hasEnoughSpace","windowDimensions","elementDimensions","wrapperDimensions","wrapperPosition","position","gap","windowHeight","height","windowWidth","width","elementHeight","elementWidth","wrapperHeight","wrapperWidth","wrapperX","x","wrapperY","y","verticalPosition","_calculateVerticalPosition","horizontalPosition","_calculateHorizontalPosition","canPlaceVertically","canPlaceHorizontally","calculateTopCenterPosition","calculateBottomCenterPosition","calculateRightCenterPosition","calculateLeftCenterPosition","calculatePosition"],"mappings":"IAaMA,cAAc,GAAqB,SAAnCA,cAAmC,CACrCC,gBADqC,EAErCC,iBAFqC,EAGrCC,iBAHqC,EAIrCC,eAJqC,EAKrCC,QALqC,EAMrCC,GANqC;MAMrCA;AAAAA,IAAAA,MAAM;;;AAEN,MAAgBC,YAAhB,GAAqDN,gBAArD,CAAQO,MAAR;AAAA,MAAqCC,WAArC,GAAqDR,gBAArD,CAA8BS,KAA9B;AACA,MAAgBC,aAAhB,GAAuDT,iBAAvD,CAAQM,MAAR;AAAA,MAAsCI,YAAtC,GAAuDV,iBAAvD,CAA+BQ,KAA/B;AACA,MAAgBG,aAAhB,GAAuDV,iBAAvD,CAAQK,MAAR;AAAA,MAAsCM,YAAtC,GAAuDX,iBAAvD,CAA+BO,KAA/B;AACA,MAAWK,QAAX,GAAqCX,eAArC,CAAQY,CAAR;AAAA,MAAwBC,QAAxB,GAAqCb,eAArC,CAAqBc,CAArB;;AAEA,MAAMC,gBAAgB,GAAGC,0BAA0B,CAC/ChB,eAD+C,EAE/CD,iBAF+C,EAG/CD,iBAH+C,CAAnD;;AAKA,MAAMmB,kBAAkB,GAAGC,4BAA4B,CACnDlB,eADmD,EAEnDD,iBAFmD,EAGnDD,iBAHmD,CAAvD;;AAKA,MAAMqB,kBAAkB,GACpBJ,gBAAgB,IAAI,CAAp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return _onChange === null || _onChange === void 0 ? void 0 : _onChange(parseInt(event.target.value));
|
|
43
43
|
}
|
|
44
44
|
}), /*#__PURE__*/React__default.createElement("span", {
|
|
45
45
|
className: "range_btn plus",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range-input.js","sources":["../../../src/components/range-input/range-input.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport './range-input.less'\n\ntype Props = {\n /** Optional css class that is applied to the range input. */\n className?: string\n /** Current value of the range input. */\n value?: number\n /** Minimum value of the range input. */\n min?: number\n /** Maximum value of the range input. */\n max?: number\n /** Step size of the range input and the plus/minus buttons. */\n stepSize?: number\n /** Optional function that is called when plus button is clicked. If not supplied onChange will be called with the next value. */\n onPlus?: (value: number) => void\n /** Optional function that is called when minus button is clicked. If not supplied onChange will be called with the next value. */\n onMinus?: (value: number) => void\n /** Callback function that is called whenever the range input value changes. When onPlus or onMinus is supplied this will not be called for button clicks. */\n onChange?: (value: number) => void\n}\n\nfunction RangeInput({\n value = 0,\n min = 0,\n max = 100,\n stepSize = 1,\n onPlus,\n onMinus,\n onChange,\n className,\n}: Props) {\n if (typeof onPlus !== 'function') {\n onPlus = onChange\n }\n if (typeof onMinus !== 'function') {\n onMinus = onChange\n }\n const rangeInputClassName = classNames('reactist_range_input', className)\n return (\n <div className={rangeInputClassName}>\n <span\n className=\"range_btn minus\"\n onClick={() => value > min && onMinus && onMinus(value - stepSize)}\n />\n <input\n value={value}\n className=\"range_slider\"\n type=\"range\"\n min={min}\n max={max}\n step={stepSize}\n onChange={(event) => onChange
|
|
1
|
+
{"version":3,"file":"range-input.js","sources":["../../../src/components/range-input/range-input.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport './range-input.less'\n\ntype Props = {\n /** Optional css class that is applied to the range input. */\n className?: string\n /** Current value of the range input. */\n value?: number\n /** Minimum value of the range input. */\n min?: number\n /** Maximum value of the range input. */\n max?: number\n /** Step size of the range input and the plus/minus buttons. */\n stepSize?: number\n /** Optional function that is called when plus button is clicked. If not supplied onChange will be called with the next value. */\n onPlus?: (value: number) => void\n /** Optional function that is called when minus button is clicked. If not supplied onChange will be called with the next value. */\n onMinus?: (value: number) => void\n /** Callback function that is called whenever the range input value changes. When onPlus or onMinus is supplied this will not be called for button clicks. */\n onChange?: (value: number) => void\n}\n\nfunction RangeInput({\n value = 0,\n min = 0,\n max = 100,\n stepSize = 1,\n onPlus,\n onMinus,\n onChange,\n className,\n}: Props) {\n if (typeof onPlus !== 'function') {\n onPlus = onChange\n }\n if (typeof onMinus !== 'function') {\n onMinus = onChange\n }\n const rangeInputClassName = classNames('reactist_range_input', className)\n return (\n <div className={rangeInputClassName}>\n <span\n className=\"range_btn minus\"\n onClick={() => value > min && onMinus && onMinus(value - stepSize)}\n />\n <input\n value={value}\n className=\"range_slider\"\n type=\"range\"\n min={min}\n max={max}\n step={stepSize}\n onChange={(event) => onChange?.(parseInt(event.target.value))}\n />\n <span\n className=\"range_btn plus\"\n onClick={() => value < max && onPlus && onPlus(value + stepSize)}\n />\n </div>\n )\n}\nRangeInput.displayName = 'RangeInput'\n\nexport { RangeInput }\n"],"names":["RangeInput","value","min","max","stepSize","onPlus","onMinus","onChange","className","rangeInputClassName","classNames","React","onClick","type","step","event","parseInt","target","displayName"],"mappings":";;;AAwBA,SAASA,UAAT;wBACIC;MAAAA,gCAAQ;sBACRC;MAAAA,4BAAM;sBACNC;MAAAA,4BAAM;2BACNC;MAAAA,sCAAW;MACXC,cAAAA;MACAC,eAAAA;MACAC,iBAAAA;MACAC,iBAAAA;;AAEA,MAAI,OAAOH,MAAP,KAAkB,UAAtB,EAAkC;AAC9BA,IAAAA,MAAM,GAAGE,SAAT;AACH;;AACD,MAAI,OAAOD,OAAP,KAAmB,UAAvB,EAAmC;AAC/BA,IAAAA,OAAO,GAAGC,SAAV;AACH;;AACD,MAAME,mBAAmB,GAAGC,UAAU,CAAC,sBAAD,EAAyBF,SAAzB,CAAtC;AACA,sBACIG,4BAAA,MAAA;AAAKH,IAAAA,SAAS,EAAEC;GAAhB,eACIE,4BAAA,OAAA;AACIH,IAAAA,SAAS,EAAC;AACVI,IAAAA,OAAO,EAAE;AAAA,aAAMX,KAAK,GAAGC,GAAR,IAAeI,OAAf,IAA0BA,OAAO,CAACL,KAAK,GAAGG,QAAT,CAAvC;AAAA;GAFb,CADJ,eAKIO,4BAAA,QAAA;AACIV,IAAAA,KAAK,EAAEA;AACPO,IAAAA,SAAS,EAAC;AACVK,IAAAA,IAAI,EAAC;AACLX,IAAAA,GAAG,EAAEA;AACLC,IAAAA,GAAG,EAAEA;AACLW,IAAAA,IAAI,EAAEV;AACNG,IAAAA,QAAQ,EAAE,kBAACQ,KAAD;AAAA,aAAWR,SAAX,aAAWA,SAAX,uBAAWA,SAAQ,CAAGS,QAAQ,CAACD,KAAK,CAACE,MAAN,CAAahB,KAAd,CAAX,CAAnB;AAAA;GAPd,CALJ,eAcIU,4BAAA,OAAA;AACIH,IAAAA,SAAS,EAAC;AACVI,IAAAA,OAAO,EAAE;AAAA,aAAMX,KAAK,GAAGE,GAAR,IAAeE,MAAf,IAAyBA,MAAM,CAACJ,KAAK,GAAGG,QAAT,CAArC;AAAA;GAFb,CAdJ,CADJ;AAqBH;;AACDJ,UAAU,CAACkB,WAAX,GAAyB,YAAzB;;;;"}
|
|
@@ -2,6 +2,8 @@ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '.
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
+
var _excluded = ["value", "options", "onChange", "disabled", "className", "defaultValue"];
|
|
6
|
+
|
|
5
7
|
function Select(_ref) {
|
|
6
8
|
var value = _ref.value,
|
|
7
9
|
_ref$options = _ref.options,
|
|
@@ -12,7 +14,7 @@ function Select(_ref) {
|
|
|
12
14
|
_ref$className = _ref.className,
|
|
13
15
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
14
16
|
defaultValue = _ref.defaultValue,
|
|
15
|
-
otherProps = _objectWithoutPropertiesLoose(_ref,
|
|
17
|
+
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
16
18
|
|
|
17
19
|
var selectClassName = classNames('reactist_select', {
|
|
18
20
|
disabled: disabled
|
|
@@ -25,7 +27,7 @@ function Select(_ref) {
|
|
|
25
27
|
},
|
|
26
28
|
disabled: disabled,
|
|
27
29
|
defaultValue: defaultValue
|
|
28
|
-
}, otherProps), options
|
|
30
|
+
}, otherProps), options === null || options === void 0 ? void 0 : options.map(function (option) {
|
|
29
31
|
return /*#__PURE__*/React__default.createElement("option", {
|
|
30
32
|
key: option.key || option.value,
|
|
31
33
|
value: option.value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sources":["../../../src/components/select/select.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport './select.less'\n\ntype Option = {\n /** Optional key for each option. If not provided `value` is used. */\n key?: string | number\n /** Value of the option. */\n value: string | number\n /** Text to display for the option. */\n text?: string | number\n /** Whether the options is disabled or not. */\n disabled?: boolean\n}\n\ntype Props = {\n className?: string\n disabled?: boolean\n /** Currently selected value. */\n value?: string | number\n /** Callback for the change event. Will be called with the next value (not the full event). */\n onChange?: (value: string) => void\n /** Options that are rendered in the select. */\n options?: Option[]\n /** Value to initially be set */\n defaultValue?: string | number\n}\n\nfunction Select({\n value,\n options = [],\n onChange,\n disabled = true,\n className = '',\n defaultValue,\n ...otherProps\n}: Props) {\n const selectClassName = classNames('reactist_select', { disabled }, className)\n return (\n <select\n className={selectClassName}\n value={value}\n onChange={(event) => (onChange ? onChange(event.target.value) : undefined)}\n disabled={disabled}\n defaultValue={defaultValue}\n {...otherProps}\n >\n {options
|
|
1
|
+
{"version":3,"file":"select.js","sources":["../../../src/components/select/select.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport './select.less'\n\ntype Option = {\n /** Optional key for each option. If not provided `value` is used. */\n key?: string | number\n /** Value of the option. */\n value: string | number\n /** Text to display for the option. */\n text?: string | number\n /** Whether the options is disabled or not. */\n disabled?: boolean\n}\n\ntype Props = {\n className?: string\n disabled?: boolean\n /** Currently selected value. */\n value?: string | number\n /** Callback for the change event. Will be called with the next value (not the full event). */\n onChange?: (value: string) => void\n /** Options that are rendered in the select. */\n options?: Option[]\n /** Value to initially be set */\n defaultValue?: string | number\n}\n\nfunction Select({\n value,\n options = [],\n onChange,\n disabled = true,\n className = '',\n defaultValue,\n ...otherProps\n}: Props) {\n const selectClassName = classNames('reactist_select', { disabled }, className)\n return (\n <select\n className={selectClassName}\n value={value}\n onChange={(event) => (onChange ? onChange(event.target.value) : undefined)}\n disabled={disabled}\n defaultValue={defaultValue}\n {...otherProps}\n >\n {options?.map((option) => (\n <option\n key={option.key || option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.text}\n </option>\n ))}\n </select>\n )\n}\nSelect.displayName = 'Select'\nSelect.defaultProps = {\n options: [],\n disabled: false,\n}\n\nexport { Select }\n"],"names":["Select","value","options","onChange","disabled","className","defaultValue","otherProps","selectClassName","classNames","React","event","target","undefined","map","option","key","text","displayName","defaultProps"],"mappings":";;;;;;AA6BA,SAASA,MAAT;MACIC,aAAAA;0BACAC;MAAAA,oCAAU;MACVC,iBAAAA;2BACAC;MAAAA,sCAAW;4BACXC;MAAAA,wCAAY;MACZC,oBAAAA;MACGC;;AAEH,MAAMC,eAAe,GAAGC,UAAU,CAAC,iBAAD,EAAoB;AAAEL,IAAAA,QAAQ,EAARA;AAAF,GAApB,EAAkCC,SAAlC,CAAlC;AACA,sBACIK,4BAAA,SAAA;AACIL,IAAAA,SAAS,EAAEG;AACXP,IAAAA,KAAK,EAAEA;AACPE,IAAAA,QAAQ,EAAE,kBAACQ,KAAD;AAAA,aAAYR,SAAQ,GAAGA,SAAQ,CAACQ,KAAK,CAACC,MAAN,CAAaX,KAAd,CAAX,GAAkCY,SAAtD;AAAA;AACVT,IAAAA,QAAQ,EAAEA;AACVE,IAAAA,YAAY,EAAEA;KACVC,WANR,EAQKL,OARL,aAQKA,OARL,uBAQKA,OAAO,CAAEY,GAAT,CAAa,UAACC,MAAD;AAAA,wBACVL,4BAAA,SAAA;AACIM,MAAAA,GAAG,EAAED,MAAM,CAACC,GAAP,IAAcD,MAAM,CAACd;AAC1BA,MAAAA,KAAK,EAAEc,MAAM,CAACd;AACdG,MAAAA,QAAQ,EAAEW,MAAM,CAACX;KAHrB,EAKKW,MAAM,CAACE,IALZ,CADU;AAAA,GAAb,CARL,CADJ;AAoBH;;AACDjB,MAAM,CAACkB,WAAP,GAAqB,QAArB;AACAlB,MAAM,CAACmB,YAAP,GAAsB;AAClBjB,EAAAA,OAAO,EAAE,EADS;AAElBE,EAAAA,QAAQ,EAAE;AAFQ,CAAtB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-utils.js","sources":["../../../src/components/time/time-utils.ts"],"sourcesContent":["import dayjs from 'dayjs'\n/**\n * There's a problem with our setup where the default export from\n * localizedFormat (and likely every other dayjs plugin) isn't properly\n * recognized. The proposed workarounds (importing with `.js` ending, or adding\n * `allowSyntheticDefaultImports` to the tsconfig) either broke linting or type\n * checking. After spending some time on this it was decided that further\n * investigations are not worth it, the code works and the eslint ignore is fine.\n * ref: https://github.com/iamkun/dayjs/issues/593\n * ref: https://day.js.org/docs/en/installation/typescript\n */\n// eslint-disable-next-line import/default\nimport LocalizedFormat from 'dayjs/plugin/localizedFormat'\n\ndayjs.extend(LocalizedFormat)\n\ntype TimeConfig = {\n locale?: string\n longFormat?: string\n shortFormatCurrentYear?: string\n shortFormatPastYear?: string\n daysSuffix?: string\n hoursSuffix?: string\n minutesSuffix?: string\n momentsAgo?: string\n}\n\nconst TimeUtils = {\n SHORT_FORMAT_CURRENT_YEAR: 'L',\n SHORT_FORMAT_PAST_YEAR: 'LL',\n LONG_FORMAT: 'LL, LT',\n\n timeAgo(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n daysSuffix = 'd',\n hoursSuffix = 'h',\n minutesSuffix = 'm',\n momentsAgo = 'moments ago',\n } = config\n const now = dayjs()\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n const diffMinutes = now.diff(date, 'minute')\n const diffHours = now.diff(date, 'hour')\n const diffDays = now.diff(date, 'day')\n\n if (diffDays > 1) {\n if (date.isSame(now, 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n } else if (diffDays === 1) {\n return `${diffDays}${daysSuffix}`\n } else if (diffHours > 0 && diffHours <= 23) {\n return `${diffHours}${hoursSuffix}`\n } else if (diffMinutes > 0 && diffMinutes <= 59) {\n return `${diffMinutes}${minutesSuffix}`\n } else {\n return momentsAgo\n }\n },\n\n formatTime(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n if (date.isSame(dayjs(), 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n },\n\n formatTimeLong(timestamp: number, config: TimeConfig = {}) {\n const { locale = 'en', longFormat = this.LONG_FORMAT } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n return date.format(longFormat)\n },\n}\n\nexport { TimeUtils, TimeConfig }\n"],"names":["dayjs","extend","LocalizedFormat","TimeUtils","SHORT_FORMAT_CURRENT_YEAR","SHORT_FORMAT_PAST_YEAR","LONG_FORMAT","timeAgo","timestamp","config","locale","shortFormatCurrentYear","shortFormatPastYear","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo","now","date","diffMinutes","diff","diffHours","diffDays","isSame","format","formatTime","formatTimeLong","longFormat"],"mappings":";;;AAcAA,KAAK,CAACC,MAAN,CAAaC,eAAb;IAaMC,SAAS,GAAG;AACdC,EAAAA,yBAAyB,EAAE,GADb;AAEdC,EAAAA,sBAAsB,EAAE,IAFV;AAGdC,EAAAA,WAAW,EAAE,QAHC;AAKdC,EAAAA,OALc,mBAKNC,SALM,EAKaC,MALb;QAKaA;AAAAA,MAAAA,SAAqB;;;
|
|
1
|
+
{"version":3,"file":"time-utils.js","sources":["../../../src/components/time/time-utils.ts"],"sourcesContent":["import dayjs from 'dayjs'\n/**\n * There's a problem with our setup where the default export from\n * localizedFormat (and likely every other dayjs plugin) isn't properly\n * recognized. The proposed workarounds (importing with `.js` ending, or adding\n * `allowSyntheticDefaultImports` to the tsconfig) either broke linting or type\n * checking. After spending some time on this it was decided that further\n * investigations are not worth it, the code works and the eslint ignore is fine.\n * ref: https://github.com/iamkun/dayjs/issues/593\n * ref: https://day.js.org/docs/en/installation/typescript\n */\n// eslint-disable-next-line import/default\nimport LocalizedFormat from 'dayjs/plugin/localizedFormat'\n\ndayjs.extend(LocalizedFormat)\n\ntype TimeConfig = {\n locale?: string\n longFormat?: string\n shortFormatCurrentYear?: string\n shortFormatPastYear?: string\n daysSuffix?: string\n hoursSuffix?: string\n minutesSuffix?: string\n momentsAgo?: string\n}\n\nconst TimeUtils = {\n SHORT_FORMAT_CURRENT_YEAR: 'L',\n SHORT_FORMAT_PAST_YEAR: 'LL',\n LONG_FORMAT: 'LL, LT',\n\n timeAgo(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n daysSuffix = 'd',\n hoursSuffix = 'h',\n minutesSuffix = 'm',\n momentsAgo = 'moments ago',\n } = config\n const now = dayjs()\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n const diffMinutes = now.diff(date, 'minute')\n const diffHours = now.diff(date, 'hour')\n const diffDays = now.diff(date, 'day')\n\n if (diffDays > 1) {\n if (date.isSame(now, 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n } else if (diffDays === 1) {\n return `${diffDays}${daysSuffix}`\n } else if (diffHours > 0 && diffHours <= 23) {\n return `${diffHours}${hoursSuffix}`\n } else if (diffMinutes > 0 && diffMinutes <= 59) {\n return `${diffMinutes}${minutesSuffix}`\n } else {\n return momentsAgo\n }\n },\n\n formatTime(timestamp: number, config: TimeConfig = {}) {\n const {\n locale = 'en',\n shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,\n shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,\n } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n if (date.isSame(dayjs(), 'year')) {\n return date.format(shortFormatCurrentYear)\n } else {\n return date.format(shortFormatPastYear)\n }\n },\n\n formatTimeLong(timestamp: number, config: TimeConfig = {}) {\n const { locale = 'en', longFormat = this.LONG_FORMAT } = config\n const date = dayjs(timestamp * 1000)\n date.locale(locale)\n return date.format(longFormat)\n },\n}\n\nexport { TimeUtils, TimeConfig }\n"],"names":["dayjs","extend","LocalizedFormat","TimeUtils","SHORT_FORMAT_CURRENT_YEAR","SHORT_FORMAT_PAST_YEAR","LONG_FORMAT","timeAgo","timestamp","config","locale","shortFormatCurrentYear","shortFormatPastYear","daysSuffix","hoursSuffix","minutesSuffix","momentsAgo","now","date","diffMinutes","diff","diffHours","diffDays","isSame","format","formatTime","formatTimeLong","longFormat"],"mappings":";;;AAcAA,KAAK,CAACC,MAAN,CAAaC,eAAb;IAaMC,SAAS,GAAG;AACdC,EAAAA,yBAAyB,EAAE,GADb;AAEdC,EAAAA,sBAAsB,EAAE,IAFV;AAGdC,EAAAA,WAAW,EAAE,QAHC;AAKdC,EAAAA,OALc,mBAKNC,SALM,EAKaC,MALb;QAKaA;AAAAA,MAAAA,SAAqB;;;AAC5C,kBAQIA,MARJ;AAAA,iCACIC,MADJ;AAAA,QACIA,MADJ,+BACa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