@doist/reactist 9.2.0-beta.7 → 10.0.0-beta.10
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 +1405 -842
- 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/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} +7 -3
- 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 +5 -3
- package/es/components/dropdown/dropdown.js.map +1 -1
- package/es/components/error-message/error-message.js +3 -1
- package/es/components/error-message/error-message.js.map +1 -1
- package/es/components/keyboard-shortcut/keyboard-shortcut.js +4 -2
- package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/es/components/menu/menu.js +22 -20
- package/es/components/menu/menu.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 +1 -1
- package/es/components/select/select.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 +70 -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 +28 -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 +40 -0
- package/es/new-components/button/button.js.map +1 -0
- package/es/new-components/button-link/button-link.js +25 -14
- package/es/new-components/button-link/button-link.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-field.js +45 -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/columns/columns.js +28 -17
- 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 +3 -3
- 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 +9 -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 +54 -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/inline/inline.js +9 -8
- package/es/new-components/inline/inline.js.map +1 -1
- package/es/new-components/loading/loading.js +33 -0
- package/es/new-components/loading/loading.js.map +1 -0
- package/es/new-components/modal/modal.js +201 -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 +7 -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 +12 -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 -13
- package/es/new-components/stack/stack.js.map +1 -1
- package/es/new-components/switch-field/switch-field.js +47 -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 +142 -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 +15 -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.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 +4 -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 +8 -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/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/{button/button.js → deprecated-button/deprecated-button.js} +2 -2
- 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/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/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/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/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.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 -3
- 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 -3
- 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 -3
- 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 -492
- 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.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":"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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C,IAAAA,oBAAoB,CAACnC,KAAD,CAApB;AACAoC,IAAAA,cAAc;AACjB,GALuB,EAMxB,CAACA,cAAD,EAAiBD,oBAAjB,EAAuCzC,YAAvC,CANwB,CAA5B;;8BASuBH,QAAA,CAAe+C,OAAf,CAAuB7C,QAAvB;MAAhB8C;MAAQC;;AAEf,sBACIjD,aAAA,CAACM,UAAD,oBAAqBD,OAAWD;AAAOS,IAAAA,GAAG,EAAEA;IAA5C,EACK,UAACqC,WAAD;AAAA,wBACGlD,aAAA,CAACC,IAAD;AAAME,MAAAA,YAAY,EAAE2C;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,Q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|
|
|
39
39
|
max: max,
|
|
40
40
|
step: stepSize,
|
|
41
41
|
onChange: function onChange(event) {
|
|
42
|
-
return _onChange
|
|
42
|
+
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;;;;"}
|
|
@@ -25,7 +25,7 @@ function Select(_ref) {
|
|
|
25
25
|
},
|
|
26
26
|
disabled: disabled,
|
|
27
27
|
defaultValue: defaultValue
|
|
28
|
-
}, otherProps), options
|
|
28
|
+
}, otherProps), options === null || options === void 0 ? void 0 : options.map(function (option) {
|
|
29
29
|
return /*#__PURE__*/React__default.createElement("option", {
|
|
30
30
|
key: option.key || option.value,
|
|
31
31
|
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;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* usePrevious tracks the change of the given value -
|
|
5
|
+
* when a given value has been changed from a previous call,
|
|
6
|
+
* it will return the value prior to the change.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
*
|
|
10
|
+
* const [x, setX] = useState(1)
|
|
11
|
+
* const prevX = usePrevious(x)
|
|
12
|
+
*
|
|
13
|
+
* Suppose `setX(2)` is called, then in the next component render
|
|
14
|
+
* x = 2 and prevX = 1
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
function usePrevious(value) {
|
|
18
|
+
var ref = useRef(null);
|
|
19
|
+
useEffect(function () {
|
|
20
|
+
ref.current = value;
|
|
21
|
+
}, [value]);
|
|
22
|
+
return ref.current;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { usePrevious };
|
|
26
|
+
//# sourceMappingURL=use-previous.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-previous.js","sources":["../../../src/hooks/use-previous/use-previous.ts"],"sourcesContent":["import * as React from 'react'\n\n/**\n * usePrevious tracks the change of the given value -\n * when a given value has been changed from a previous call,\n * it will return the value prior to the change.\n *\n * Example:\n *\n * const [x, setX] = useState(1)\n * const prevX = usePrevious(x)\n *\n * Suppose `setX(2)` is called, then in the next component render\n * x = 2 and prevX = 1\n */\nfunction usePrevious<T>(value: T): T | null {\n const ref = React.useRef<T | null>(null)\n\n React.useEffect(() => {\n ref.current = value\n }, [value])\n\n return ref.current\n}\n\nexport { usePrevious }\n"],"names":["usePrevious","value","ref","React","current"],"mappings":";;AAEA;;;;;;;;;;;;;;AAaA,SAASA,WAAT,CAAwBC,KAAxB;AACI,MAAMC,GAAG,GAAGC,MAAA,CAAuB,IAAvB,CAAZ;AAEAA,EAAAA,SAAA,CAAgB;AACZD,IAAAA,GAAG,CAACE,OAAJ,GAAcH,KAAd;AACH,GAFD,EAEG,CAACA,KAAD,CAFH;AAIA,SAAOC,GAAG,CAACE,OAAX;AACH;;;;"}
|
package/es/index.js
CHANGED
|
@@ -3,23 +3,29 @@ export { Column, Columns } from './new-components/columns/columns.js';
|
|
|
3
3
|
export { Divider } from './new-components/divider/divider.js';
|
|
4
4
|
export { Inline } from './new-components/inline/inline.js';
|
|
5
5
|
export { Stack } from './new-components/stack/stack.js';
|
|
6
|
+
export { Hidden } from './new-components/hidden/hidden.js';
|
|
7
|
+
export { HiddenVisually } from './new-components/hidden-visually/hidden-visually.js';
|
|
6
8
|
export { Alert } from './new-components/alert/alert.js';
|
|
7
|
-
export {
|
|
9
|
+
export { Loading } from './new-components/loading/loading.js';
|
|
8
10
|
export { Notice } from './new-components/notice/notice.js';
|
|
9
11
|
export { Heading } from './new-components/heading/heading.js';
|
|
10
12
|
export { Text } from './new-components/text/text.js';
|
|
13
|
+
export { Tooltip } from './components/tooltip/tooltip.js';
|
|
14
|
+
export { Button } from './new-components/button/button.js';
|
|
11
15
|
export { ButtonLink } from './new-components/button-link/button-link.js';
|
|
12
16
|
export { TextLink } from './new-components/text-link/text-link.js';
|
|
13
17
|
export { CheckboxField } from './new-components/checkbox-field/checkbox-field.js';
|
|
14
|
-
export { Tooltip } from './components/tooltip/tooltip.js';
|
|
15
18
|
export { PasswordField } from './new-components/password-field/password-field.js';
|
|
16
19
|
export { SelectField } from './new-components/select-field/select-field.js';
|
|
17
20
|
export { SwitchField } from './new-components/switch-field/switch-field.js';
|
|
18
21
|
export { TextArea } from './new-components/text-area/text-area.js';
|
|
19
22
|
export { TextField } from './new-components/text-field/text-field.js';
|
|
23
|
+
export { usePrevious } from './hooks/use-previous/use-previous.js';
|
|
24
|
+
export { Tab, TabAwareSlot, TabList, TabPanel, Tabs } from './new-components/tabs/tabs.js';
|
|
25
|
+
export { Modal, ModalActions, ModalBody, ModalCloseButton, ModalFooter, ModalHeader } from './new-components/modal/modal.js';
|
|
20
26
|
export { default as Avatar } from './components/avatar/index.js';
|
|
21
|
-
export { default as Button } from './components/button/index.js';
|
|
22
27
|
export { default as Checkbox } from './components/checkbox/index.js';
|
|
28
|
+
export { default as DeprecatedButton } from './components/deprecated-button/index.js';
|
|
23
29
|
export { default as Dropdown } from './components/dropdown/index.js';
|
|
24
30
|
export { COLORS } from './components/color-picker/color-picker.js';
|
|
25
31
|
export { default as ColorPicker } from './components/color-picker/index.js';
|
|
@@ -29,8 +35,6 @@ export { default as Input } from './components/input/index.js';
|
|
|
29
35
|
export { default as KeyboardShortcut } from './components/keyboard-shortcut/index.js';
|
|
30
36
|
export { SUPPORTED_KEYS } from './components/key-capturer/key-capturer.js';
|
|
31
37
|
export { default as KeyCapturer } from './components/key-capturer/index.js';
|
|
32
|
-
export { default as Loading } from './components/loading/index.js';
|
|
33
|
-
export { default as Modal } from './components/modal/index.js';
|
|
34
38
|
export { default as Popover } from './components/popover/index.js';
|
|
35
39
|
export { default as ProgressBar } from './components/progress-bar/index.js';
|
|
36
40
|
export { default as RangeInput } from './components/range-input/index.js';
|
|
@@ -38,6 +42,7 @@ export { default as Select } from './components/select/index.js';
|
|
|
38
42
|
export { default as Time } from './components/time/index.js';
|
|
39
43
|
export { default as Tip } from './components/tip/index.js';
|
|
40
44
|
export { Notification } from './components/notification/notification.js';
|
|
41
|
-
export { Tab, Tabs } from './components/tabs/tabs.js';
|
|
42
45
|
export { Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu } from './components/menu/menu.js';
|
|
46
|
+
export { default as DeprecatedModal } from './components/deprecated-modal/index.js';
|
|
47
|
+
export { Loading as DeprecatedLoading } from './components/deprecated-loading/deprecated-loading.js';
|
|
43
48
|
//# sourceMappingURL=index.js.map
|
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { createElement, Fragment } from 'react';
|
|
3
|
+
import { polymorphicComponent } from '../../utils/polymorphism.js';
|
|
4
|
+
import { Box } from '../box/box.js';
|
|
5
|
+
import { Spinner } from '../spinner/spinner.js';
|
|
6
|
+
import { Tooltip } from '../../components/tooltip/tooltip.js';
|
|
7
|
+
import styles from './base-button.module.css.js';
|
|
8
|
+
|
|
9
|
+
function preventDefault(event) {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The component that powers `Button` and `ButtonLink`, where the button styling logic and some
|
|
14
|
+
* common functionality resides. This component is internal to Reactist.
|
|
15
|
+
*
|
|
16
|
+
* 🎨 [Figma](https://www.figma.com/file/LYlWNzvhMDh907l07mPPQk/Product-Web?node-id=4693%3A175143)
|
|
17
|
+
*
|
|
18
|
+
* @see Button
|
|
19
|
+
* @see ButtonLink
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var BaseButton = /*#__PURE__*/polymorphicComponent(function BaseButton(_ref, ref) {
|
|
24
|
+
var _ref$as = _ref.as,
|
|
25
|
+
as = _ref$as === void 0 ? 'div' : _ref$as,
|
|
26
|
+
variant = _ref.variant,
|
|
27
|
+
_ref$tone = _ref.tone,
|
|
28
|
+
tone = _ref$tone === void 0 ? 'normal' : _ref$tone,
|
|
29
|
+
_ref$size = _ref.size,
|
|
30
|
+
size = _ref$size === void 0 ? 'normal' : _ref$size,
|
|
31
|
+
_ref$disabled = _ref.disabled,
|
|
32
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
33
|
+
_ref$loading = _ref.loading,
|
|
34
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
35
|
+
tooltip = _ref.tooltip,
|
|
36
|
+
onClick = _ref.onClick,
|
|
37
|
+
exceptionallySetClassName = _ref.exceptionallySetClassName,
|
|
38
|
+
children = _ref.children,
|
|
39
|
+
startIcon = _ref.startIcon,
|
|
40
|
+
endIcon = _ref.endIcon,
|
|
41
|
+
icon = _ref.icon,
|
|
42
|
+
props = _objectWithoutPropertiesLoose(_ref, ["as", "variant", "tone", "size", "disabled", "loading", "tooltip", "onClick", "exceptionallySetClassName", "children", "startIcon", "endIcon", "icon"]);
|
|
43
|
+
|
|
44
|
+
var isDisabled = loading || disabled;
|
|
45
|
+
var buttonElement = /*#__PURE__*/createElement(Box, Object.assign({}, props, {
|
|
46
|
+
as: as,
|
|
47
|
+
ref: ref,
|
|
48
|
+
"aria-disabled": isDisabled,
|
|
49
|
+
onClick: isDisabled ? preventDefault : onClick,
|
|
50
|
+
className: [exceptionallySetClassName, styles.baseButton, styles["variant-" + variant], styles["tone-" + tone], styles["size-" + size], icon ? styles.iconButton : null, disabled ? styles.disabled : null]
|
|
51
|
+
}), icon ? loading && /*#__PURE__*/createElement(Spinner, null) || icon : /*#__PURE__*/createElement(Fragment, null, startIcon ? /*#__PURE__*/createElement(Box, {
|
|
52
|
+
display: "flex",
|
|
53
|
+
className: styles.startIcon,
|
|
54
|
+
"aria-hidden": true
|
|
55
|
+
}, loading && !endIcon ? /*#__PURE__*/createElement(Spinner, null) : startIcon) : null, children ? /*#__PURE__*/createElement("span", {
|
|
56
|
+
className: styles.label
|
|
57
|
+
}, children) : null, endIcon || loading && !startIcon ? /*#__PURE__*/createElement(Box, {
|
|
58
|
+
display: "flex",
|
|
59
|
+
className: styles.endIcon,
|
|
60
|
+
"aria-hidden": true
|
|
61
|
+
}, loading ? /*#__PURE__*/createElement(Spinner, null) : endIcon) : null)); // If it's an icon-only button, make sure it uses the aria-label as tooltip if no tooltip was provided
|
|
62
|
+
|
|
63
|
+
var tooltipContent = icon ? tooltip !== null && tooltip !== void 0 ? tooltip : props['aria-label'] : tooltip;
|
|
64
|
+
return tooltipContent ? /*#__PURE__*/createElement(Tooltip, {
|
|
65
|
+
content: tooltipContent
|
|
66
|
+
}, buttonElement) : buttonElement;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export { BaseButton };
|
|
70
|
+
//# sourceMappingURL=base-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-button.js","sources":["../../../src/new-components/base-button/base-button.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Tooltip, TooltipProps } from '../../components/tooltip'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport { Box } from '../box'\nimport { Spinner } from '../spinner'\nimport styles from './base-button.module.css'\n\nfunction preventDefault(event: React.SyntheticEvent) {\n event.preventDefault()\n}\n\ntype ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'quaternary'\ntype ButtonTone = 'normal' | 'destructive'\ntype ButtonSize = 'small' | 'normal' | 'large'\ntype IconElement = React.ReactChild\n\ntype CommonProps = {\n /**\n * The button's variant.\n */\n variant: ButtonVariant\n /**\n * The button's tone.\n * @default 'normal'\n */\n tone?: ButtonTone\n /**\n * The button's size.\n * @default 'normal'\n */\n size?: ButtonSize\n /**\n * Whether the button is disabled or not.\n * @default false\n */\n disabled?: boolean\n /**\n * Whether the button is busy/loading.\n *\n * A button in this state is functionally and semantically disabled. Visually is does not look\n * dimmed (as disabled buttons normally do), but it shows a loading spinner instead.\n *\n * @default false\n */\n loading?: boolean\n /**\n * A tooltip linked to the button element.\n */\n tooltip?: TooltipProps['content']\n}\n\ntype IconButtonProps = {\n icon: IconElement\n 'aria-label': string\n children?: never\n startIcon?: never\n endIcon?: never\n}\n\ntype LabelledButtonProps = {\n children: NonNullable<React.ReactNode>\n startIcon?: IconElement\n endIcon?: IconElement\n icon?: never\n}\n\nexport type BaseButtonProps = CommonProps & (IconButtonProps | LabelledButtonProps)\n\n/**\n * The component that powers `Button` and `ButtonLink`, where the button styling logic and some\n * common functionality resides. This component is internal to Reactist.\n *\n * 🎨 [Figma](https://www.figma.com/file/LYlWNzvhMDh907l07mPPQk/Product-Web?node-id=4693%3A175143)\n *\n * @see Button\n * @see ButtonLink\n */\nexport const BaseButton = polymorphicComponent<'div', BaseButtonProps>(function BaseButton(\n {\n as = 'div',\n variant,\n tone = 'normal',\n size = 'normal',\n disabled = false,\n loading = false,\n tooltip,\n onClick,\n exceptionallySetClassName,\n children,\n startIcon,\n endIcon,\n icon,\n ...props\n },\n ref,\n) {\n const isDisabled = loading || disabled\n const buttonElement = (\n <Box\n {...props}\n as={as}\n ref={ref}\n aria-disabled={isDisabled}\n onClick={isDisabled ? preventDefault : onClick}\n className={[\n exceptionallySetClassName,\n styles.baseButton,\n styles[`variant-${variant}`],\n styles[`tone-${tone}`],\n styles[`size-${size}`],\n icon ? styles.iconButton : null,\n disabled ? styles.disabled : null,\n ]}\n >\n {icon ? (\n (loading && <Spinner />) || icon\n ) : (\n <>\n {startIcon ? (\n <Box display=\"flex\" className={styles.startIcon} aria-hidden>\n {loading && !endIcon ? <Spinner /> : startIcon}\n </Box>\n ) : null}\n {children ? <span className={styles.label}>{children}</span> : null}\n {endIcon || (loading && !startIcon) ? (\n <Box display=\"flex\" className={styles.endIcon} aria-hidden>\n {loading ? <Spinner /> : endIcon}\n </Box>\n ) : null}\n </>\n )}\n </Box>\n )\n\n // If it's an icon-only button, make sure it uses the aria-label as tooltip if no tooltip was provided\n const tooltipContent = icon ? tooltip ?? props['aria-label'] : tooltip\n return tooltipContent ? (\n <Tooltip content={tooltipContent}>{buttonElement}</Tooltip>\n ) : (\n buttonElement\n )\n})\n"],"names":["preventDefault","event","BaseButton","polymorphicComponent","ref","as","variant","tone","size","disabled","loading","tooltip","onClick","exceptionallySetClassName","children","startIcon","endIcon","icon","props","isDisabled","buttonElement","React","Box","className","styles","baseButton","iconButton","Spinner","display","label","tooltipContent","Tooltip","content"],"mappings":";;;;;;;;AAOA,SAASA,cAAT,CAAwBC,KAAxB;A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ACK;GAAxB,EAAgCf,QAAhC,CAAH,GAAsD,IANnE,EAOKE,OAAO,IAAKN,OAAO,IAAI,CAACK,SAAxB,gBACGM,aAAA,CAACC,GAAD;AAAKM,IAAAA,OAAO,EAAC;AAAOL,IAAAA,SAAS,EAAEC,MAAM,CAACR;;GAAtC,EACKN,OAAO,gBAAGW,aAAA,CAACM,OAAD,MAAA,CAAH,GAAiBX,OAD7B,CADH,GAIG,IAXR,CAnBR,CADJ;;AAsCA,MAAMc,cAAc,GAAGb,IAAI,GAAGN,OAAH,aAAGA,OAAH,cAAGA,OAAH,GAAcO,KAAK,CAAC,YAAD,CAAnB,GAAoCP,OAA/D;AACA,SAAOmB,cAAc,gBACjBT,aAAA,CAACU,OAAD;AAASC,IAAAA,OAAO,EAAEF;GAAlB,EAAmCV,aAAnC,CADiB,GAGjBA,aAHJ;AAKH,CAhE6C;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var modules_b9569bce = {"label":"_1f20c88a","baseButton":"_623015f3","size-small":"_062de645","size-normal":"_55e2a6a9","size-large":"cab32a7c","disabled":"e71c191a","iconButton":"_368efc16","startIcon":"d35389c1","endIcon":"_900d41d8","variant-primary":"_7c95e162","variant-secondary":"_9cb889aa","variant-tertiary":"_611b5b28","variant-quaternary":"_80c2bb84","tone-destructive":"ee13c455"};
|
|
2
|
+
|
|
3
|
+
export default modules_b9569bce;
|
|
4
|
+
//# sourceMappingURL=base-button.module.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-button.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
1
|
import { createElement } from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
2
|
import { Box } from '../box/box.js';
|
|
3
|
+
import { Stack } from '../stack/stack.js';
|
|
5
4
|
import { Text } from '../text/text.js';
|
|
6
5
|
import { useId } from '../common-helpers.js';
|
|
7
6
|
import styles from './base-field.module.css.js';
|
|
8
7
|
|
|
9
|
-
function FieldHint(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return /*#__PURE__*/createElement(Text, {
|
|
13
|
-
component: "p",
|
|
8
|
+
function FieldHint(props) {
|
|
9
|
+
return /*#__PURE__*/createElement(Text, Object.assign({
|
|
10
|
+
as: "p",
|
|
14
11
|
tone: "secondary",
|
|
15
|
-
size: "
|
|
16
|
-
|
|
17
|
-
className: styles.fieldHint
|
|
18
|
-
}, children);
|
|
12
|
+
size: "copy"
|
|
13
|
+
}, props));
|
|
19
14
|
}
|
|
20
15
|
|
|
21
|
-
function BaseField(
|
|
22
|
-
var label =
|
|
23
|
-
secondaryLabel =
|
|
24
|
-
auxiliaryLabel =
|
|
25
|
-
hint =
|
|
26
|
-
className =
|
|
27
|
-
children =
|
|
28
|
-
maxWidth =
|
|
29
|
-
hidden =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var id = useId(
|
|
16
|
+
function BaseField(_ref) {
|
|
17
|
+
var label = _ref.label,
|
|
18
|
+
secondaryLabel = _ref.secondaryLabel,
|
|
19
|
+
auxiliaryLabel = _ref.auxiliaryLabel,
|
|
20
|
+
hint = _ref.hint,
|
|
21
|
+
className = _ref.className,
|
|
22
|
+
children = _ref.children,
|
|
23
|
+
maxWidth = _ref.maxWidth,
|
|
24
|
+
hidden = _ref.hidden,
|
|
25
|
+
originalAriaDescribedBy = _ref['aria-describedby'],
|
|
26
|
+
originalId = _ref.id;
|
|
27
|
+
var id = useId(originalId);
|
|
33
28
|
var hintId = useId();
|
|
34
|
-
var ariaDescribedBy = hint ?
|
|
35
|
-
return /*#__PURE__*/createElement(
|
|
29
|
+
var ariaDescribedBy = originalAriaDescribedBy !== null && originalAriaDescribedBy !== void 0 ? originalAriaDescribedBy : hint ? hintId : undefined;
|
|
30
|
+
return /*#__PURE__*/createElement(Stack, {
|
|
31
|
+
space: "small"
|
|
32
|
+
}, /*#__PURE__*/createElement(Box, {
|
|
36
33
|
className: [className, styles.container],
|
|
37
34
|
maxWidth: maxWidth,
|
|
38
35
|
hidden: hidden
|
|
39
36
|
}, /*#__PURE__*/createElement(Box, {
|
|
40
|
-
|
|
37
|
+
as: "span",
|
|
41
38
|
display: "flex",
|
|
42
39
|
justifyContent: "spaceBetween",
|
|
43
40
|
alignItems: "flexEnd",
|
|
44
41
|
paddingBottom: "small"
|
|
45
42
|
}, /*#__PURE__*/createElement(Text, {
|
|
46
|
-
|
|
43
|
+
size: "body",
|
|
44
|
+
as: "label",
|
|
47
45
|
htmlFor: id
|
|
48
46
|
}, label ? /*#__PURE__*/createElement("span", {
|
|
49
47
|
className: styles.primaryLabel
|
|
50
48
|
}, label) : null, secondaryLabel ? /*#__PURE__*/createElement("span", {
|
|
51
49
|
className: styles.secondaryLabel
|
|
52
50
|
}, "\xA0(", secondaryLabel, ")") : null), auxiliaryLabel ? /*#__PURE__*/createElement(Box, {
|
|
53
|
-
className: styles.auxiliaryLabel
|
|
51
|
+
className: styles.auxiliaryLabel,
|
|
52
|
+
paddingLeft: "small"
|
|
54
53
|
}, auxiliaryLabel) : null), children(ariaDescribedBy ? {
|
|
55
54
|
id: id,
|
|
56
55
|
'aria-describedby': ariaDescribedBy
|
|
57
56
|
} : {
|
|
58
57
|
id: id
|
|
59
|
-
}), hint ? /*#__PURE__*/createElement(FieldHint, {
|
|
58
|
+
})), hint ? /*#__PURE__*/createElement(FieldHint, {
|
|
59
|
+
hidden: hidden,
|
|
60
60
|
id: hintId
|
|
61
61
|
}, hint) : null);
|
|
62
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-field.js","sources":["../../../src/new-components/base-field/base-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport
|
|
1
|
+
{"version":3,"file":"base-field.js","sources":["../../../src/new-components/base-field/base-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box, BoxProps } from '../box'\nimport { useId } from '../common-helpers'\nimport { Text } from '../text'\nimport { WithEnhancedClassName } from '../common-types'\nimport styles from './base-field.module.css'\nimport { Stack } from '../stack'\n\ntype FieldHintProps = {\n id: string\n children: React.ReactNode\n hidden?: boolean\n}\n\nfunction FieldHint(props: FieldHintProps) {\n return <Text as=\"p\" tone=\"secondary\" size=\"copy\" {...props} />\n}\n\n//\n// BaseField\n//\n\ntype HtmlInputProps<T extends HTMLElement> = React.DetailedHTMLProps<\n React.InputHTMLAttributes<T>,\n T\n>\n\ntype BaseFieldProps = WithEnhancedClassName &\n Pick<HtmlInputProps<HTMLInputElement>, 'id' | 'hidden' | 'aria-describedby'> & {\n /**\n * The main label for this field element.\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see secondaryLabel\n * @see auxiliaryLabel\n */\n label: React.ReactNode\n /**\n * An optional secondary label for this field element. It is combined with the `label` to\n * form the field's entire accessible name (unless the field label is overriden by using\n * `aria-label` or `aria-labelledby`).\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see label\n * @see auxiliaryLabel\n */\n secondaryLabel?: React.ReactNode\n /**\n * An optional extra element to be placed to the right of the main and secondary labels.\n *\n * This extra element is not included in the accessible name of the field element. Its only\n * purpose is either visual, or functional (if you include interactive elements in it).\n *\n * @see label\n * @see secondaryLabel\n */\n auxiliaryLabel?: React.ReactNode\n /**\n * A hint or help-like content associated as the accessible description of the field. It is\n * generally rendered below it, and with a visual style that reduces its prominence (i.e.\n * as secondary text).\n */\n hint?: React.ReactNode\n /**\n * The maximum width that the input field can expand to.\n */\n maxWidth?: BoxProps['maxWidth']\n /**\n * Used internally by components composed using `BaseField`. It is not exposed as part of\n * the public props of such components.\n */\n children: (props: { id: string; 'aria-describedby'?: string }) => React.ReactNode\n }\n\ntype FieldComponentProps<T extends HTMLElement> = Omit<BaseFieldProps, 'children' | 'className'> &\n Omit<HtmlInputProps<T>, 'className' | 'style'>\n\nfunction BaseField({\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n className,\n children,\n maxWidth,\n hidden,\n 'aria-describedby': originalAriaDescribedBy,\n id: originalId,\n}: BaseFieldProps & WithEnhancedClassName) {\n const id = useId(originalId)\n const hintId = useId()\n\n const ariaDescribedBy = originalAriaDescribedBy ?? (hint ? hintId : undefined)\n\n return (\n <Stack space=\"small\">\n <Box className={[className, styles.container]} maxWidth={maxWidth} hidden={hidden}>\n <Box\n as=\"span\"\n display=\"flex\"\n justifyContent=\"spaceBetween\"\n alignItems=\"flexEnd\"\n paddingBottom=\"small\"\n >\n <Text size=\"body\" as=\"label\" htmlFor={id}>\n {label ? <span className={styles.primaryLabel}>{label}</span> : null}\n {secondaryLabel ? (\n <span className={styles.secondaryLabel}> ({secondaryLabel})</span>\n ) : null}\n </Text>\n {auxiliaryLabel ? (\n <Box className={styles.auxiliaryLabel} paddingLeft=\"small\">\n {auxiliaryLabel}\n </Box>\n ) : null}\n </Box>\n {children(ariaDescribedBy ? { id, 'aria-describedby': ariaDescribedBy } : { id })}\n </Box>\n {hint ? (\n <FieldHint hidden={hidden} id={hintId}>\n {hint}\n </FieldHint>\n ) : null}\n </Stack>\n )\n}\n\nexport { BaseField, FieldHint }\nexport type { FieldComponentProps }\n"],"names":["FieldHint","props","React","Text","as","tone","size","BaseField","label","secondaryLabel","auxiliaryLabel","hint","className","children","maxWidth","hidden","originalAriaDescribedBy","originalId","id","useId","hintId","ariaDescribedBy","undefined","Stack","space","Box","styles","container","display","justifyContent","alignItems","paddingBottom","htmlFor","primaryLabel","paddingLeft"],"mappings":";;;;;;;AAcA,SAASA,SAAT,CAAmBC,KAAnB;AACI,sBAAOC,aAAA,CAACC,IAAD;AAAMC,IAAAA,EAAE,EAAC;AAAIC,IAAAA,IAAI,EAAC;AAAYC,IAAAA,IAAI,EAAC;KAAWL,MAA9C,CAAP;AACH;;AA+DD,SAASM,SAAT;MACIC,aAAAA;MACAC,sBAAAA;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,GAAG;AAAEH,IAAAA,EAAE,EAAFA,EAAF;AAAM,wBAAoBG;AAA1B,GAAH,GAAiD;AAAEH,IAAAA,EAAE,EAAFA;AAAF,GAAjE,CApBb,CADJ,EAuBKP,IAAI,gBACDT,aAAA,CAACF,SAAD;AAAWe,IAAAA,MAAM,EAAEA;AAAQG,IAAAA,EAAE,EAAEE;GAA/B,EACKT,IADL,CADC,GAID,IA3BR,CADJ;AA+BH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var modules_540a88ff = {"container":"
|
|
1
|
+
var modules_540a88ff = {"container":"ed7d894c","primaryLabel":"_22213081","secondaryLabel":"be8637dd","auxiliaryLabel":"_72b46ad5"};
|
|
2
2
|
|
|
3
3
|
export default modules_540a88ff;
|
|
4
4
|
//# sourceMappingURL=base-field.module.css.js.map
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { createElement } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import {
|
|
4
|
+
import { polymorphicComponent } from '../../utils/polymorphism.js';
|
|
5
5
|
import { getClassNames } from '../responsive-props.js';
|
|
6
6
|
import styles from './box.module.css.js';
|
|
7
|
+
import paddingStyles from './padding.module.css.js';
|
|
8
|
+
import marginStyles from './margin.module.css.js';
|
|
7
9
|
|
|
8
|
-
var Box = /*#__PURE__*/
|
|
9
|
-
var _ref2, _ref3, _ref4, _ref5;
|
|
10
|
+
var Box = /*#__PURE__*/polymorphicComponent(function Box(_ref, ref) {
|
|
11
|
+
var _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
|
|
10
12
|
|
|
11
|
-
var _ref$
|
|
12
|
-
component = _ref$
|
|
13
|
+
var _ref$as = _ref.as,
|
|
14
|
+
component = _ref$as === void 0 ? 'div' : _ref$as,
|
|
13
15
|
_ref$position = _ref.position,
|
|
14
16
|
position = _ref$position === void 0 ? 'static' : _ref$position,
|
|
15
|
-
|
|
16
|
-
display = _ref$display === void 0 ? 'block' : _ref$display,
|
|
17
|
+
display = _ref.display,
|
|
17
18
|
_ref$flexDirection = _ref.flexDirection,
|
|
18
19
|
flexDirection = _ref$flexDirection === void 0 ? 'row' : _ref$flexDirection,
|
|
19
20
|
flexWrap = _ref.flexWrap,
|
|
@@ -29,6 +30,8 @@ var Box = /*#__PURE__*/forwardRefWithAs(function Box(_ref, ref) {
|
|
|
29
30
|
borderRadius = _ref.borderRadius,
|
|
30
31
|
minWidth = _ref.minWidth,
|
|
31
32
|
maxWidth = _ref.maxWidth,
|
|
33
|
+
_ref$textAlign = _ref.textAlign,
|
|
34
|
+
textAlign = _ref$textAlign === void 0 ? 'start' : _ref$textAlign,
|
|
32
35
|
padding = _ref.padding,
|
|
33
36
|
paddingY = _ref.paddingY,
|
|
34
37
|
paddingX = _ref.paddingX,
|
|
@@ -36,17 +39,32 @@ var Box = /*#__PURE__*/forwardRefWithAs(function Box(_ref, ref) {
|
|
|
36
39
|
paddingRight = _ref.paddingRight,
|
|
37
40
|
paddingBottom = _ref.paddingBottom,
|
|
38
41
|
paddingLeft = _ref.paddingLeft,
|
|
42
|
+
margin = _ref.margin,
|
|
43
|
+
marginY = _ref.marginY,
|
|
44
|
+
marginX = _ref.marginX,
|
|
45
|
+
marginTop = _ref.marginTop,
|
|
46
|
+
marginRight = _ref.marginRight,
|
|
47
|
+
marginBottom = _ref.marginBottom,
|
|
48
|
+
marginLeft = _ref.marginLeft,
|
|
39
49
|
className = _ref.className,
|
|
40
50
|
children = _ref.children,
|
|
41
|
-
props = _objectWithoutPropertiesLoose(_ref, ["
|
|
51
|
+
props = _objectWithoutPropertiesLoose(_ref, ["as", "position", "display", "flexDirection", "flexWrap", "flexGrow", "flexShrink", "alignItems", "justifyContent", "overflow", "width", "height", "background", "border", "borderRadius", "minWidth", "maxWidth", "textAlign", "padding", "paddingY", "paddingX", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "margin", "marginY", "marginX", "marginTop", "marginRight", "marginBottom", "marginLeft", "className", "children"]);
|
|
42
52
|
|
|
43
53
|
var resolvedPaddingTop = (_ref2 = paddingTop !== null && paddingTop !== void 0 ? paddingTop : paddingY) !== null && _ref2 !== void 0 ? _ref2 : padding;
|
|
44
54
|
var resolvedPaddingRight = (_ref3 = paddingRight !== null && paddingRight !== void 0 ? paddingRight : paddingX) !== null && _ref3 !== void 0 ? _ref3 : padding;
|
|
45
55
|
var resolvedPaddingBottom = (_ref4 = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : paddingY) !== null && _ref4 !== void 0 ? _ref4 : padding;
|
|
46
56
|
var resolvedPaddingLeft = (_ref5 = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : paddingX) !== null && _ref5 !== void 0 ? _ref5 : padding;
|
|
47
|
-
var
|
|
57
|
+
var resolvedMarginTop = (_ref6 = marginTop !== null && marginTop !== void 0 ? marginTop : marginY) !== null && _ref6 !== void 0 ? _ref6 : margin;
|
|
58
|
+
var resolvedMarginRight = (_ref7 = marginRight !== null && marginRight !== void 0 ? marginRight : marginX) !== null && _ref7 !== void 0 ? _ref7 : margin;
|
|
59
|
+
var resolvedMarginBottom = (_ref8 = marginBottom !== null && marginBottom !== void 0 ? marginBottom : marginY) !== null && _ref8 !== void 0 ? _ref8 : margin;
|
|
60
|
+
var resolvedMarginLeft = (_ref9 = marginLeft !== null && marginLeft !== void 0 ? marginLeft : marginX) !== null && _ref9 !== void 0 ? _ref9 : margin;
|
|
61
|
+
var omitFlex = !display || typeof display === 'string' && display !== 'flex' && display !== 'inlineFlex';
|
|
48
62
|
return /*#__PURE__*/createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
49
|
-
className: classNames(className, styles.box, getClassNames(styles, 'display', display), position !== 'static' ? getClassNames(styles, 'position', position) : null, minWidth != null ? getClassNames(styles, 'minWidth', String(minWidth)) : null, getClassNames(styles, 'maxWidth', maxWidth),
|
|
63
|
+
className: classNames(className, styles.box, display ? getClassNames(styles, 'display', display) : null, position !== 'static' ? getClassNames(styles, 'position', position) : null, minWidth != null ? getClassNames(styles, 'minWidth', String(minWidth)) : null, getClassNames(styles, 'maxWidth', maxWidth), textAlign !== 'start' ? getClassNames(styles, 'textAlign', textAlign) : null, // padding
|
|
64
|
+
getClassNames(paddingStyles, 'paddingTop', resolvedPaddingTop), getClassNames(paddingStyles, 'paddingRight', resolvedPaddingRight), getClassNames(paddingStyles, 'paddingBottom', resolvedPaddingBottom), getClassNames(paddingStyles, 'paddingLeft', resolvedPaddingLeft), // margin
|
|
65
|
+
getClassNames(marginStyles, 'marginTop', resolvedMarginTop), getClassNames(marginStyles, 'marginRight', resolvedMarginRight), getClassNames(marginStyles, 'marginBottom', resolvedMarginBottom), getClassNames(marginStyles, 'marginLeft', resolvedMarginLeft), // flex props
|
|
66
|
+
omitFlex ? null : getClassNames(styles, 'flexDirection', flexDirection), omitFlex ? null : getClassNames(styles, 'flexWrap', flexWrap), omitFlex ? null : getClassNames(styles, 'alignItems', alignItems), omitFlex ? null : getClassNames(styles, 'justifyContent', justifyContent), flexShrink != null ? getClassNames(styles, 'flexShrink', String(flexShrink)) : null, flexGrow != null ? getClassNames(styles, 'flexGrow', String(flexGrow)) : null, // other props
|
|
67
|
+
getClassNames(styles, 'overflow', overflow), getClassNames(styles, 'width', width), getClassNames(styles, 'height', height), getClassNames(styles, 'bg', background), borderRadius !== 'none' ? getClassNames(styles, 'borderRadius', borderRadius) : null, border !== 'none' ? getClassNames(styles, 'border', border) : null) || undefined,
|
|
50
68
|
ref: ref
|
|
51
69
|
}), children);
|
|
52
70
|
});
|