@scaleflex/ui-tw 0.0.1
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/LICENSE +33 -0
- package/README.md +28 -0
- package/core/accordion/accordion.component.d.ts +3 -0
- package/core/accordion/accordion.component.js +50 -0
- package/core/accordion/accordion.props.d.ts +13 -0
- package/core/accordion/accordion.props.js +1 -0
- package/core/accordion/accordion.styles.d.ts +6 -0
- package/core/accordion/accordion.styles.js +12 -0
- package/core/accordion/index.d.ts +2 -0
- package/core/accordion/index.js +1 -0
- package/core/accordion-details/accordion-details.component.d.ts +3 -0
- package/core/accordion-details/accordion-details.component.js +16 -0
- package/core/accordion-details/accordion-details.props.d.ts +4 -0
- package/core/accordion-details/accordion-details.props.js +1 -0
- package/core/accordion-details/accordion-details.styles.d.ts +6 -0
- package/core/accordion-details/accordion-details.styles.js +12 -0
- package/core/accordion-details/index.d.ts +2 -0
- package/core/accordion-details/index.js +1 -0
- package/core/accordion-header/accordion-header.component.d.ts +3 -0
- package/core/accordion-header/accordion-header.component.js +48 -0
- package/core/accordion-header/accordion-header.props.d.ts +11 -0
- package/core/accordion-header/accordion-header.props.js +1 -0
- package/core/accordion-header/accordion-header.styles.d.ts +19 -0
- package/core/accordion-header/accordion-header.styles.js +44 -0
- package/core/accordion-header/index.d.ts +2 -0
- package/core/accordion-header/index.js +1 -0
- package/core/arrow/arrow.component.d.ts +3 -0
- package/core/arrow/arrow.component.js +23 -0
- package/core/arrow/arrow.mixin.d.ts +6 -0
- package/core/arrow/arrow.mixin.js +4 -0
- package/core/arrow/arrow.props.d.ts +14 -0
- package/core/arrow/arrow.props.js +6 -0
- package/core/arrow/arrow.styles.d.ts +9 -0
- package/core/arrow/arrow.styles.js +18 -0
- package/core/arrow/index.d.ts +2 -0
- package/core/arrow/index.js +1 -0
- package/core/arrow-tick/arrow-tick.component.d.ts +3 -0
- package/core/arrow-tick/arrow-tick.component.js +28 -0
- package/core/arrow-tick/arrow-tick.mixin.d.ts +6 -0
- package/core/arrow-tick/arrow-tick.mixin.js +4 -0
- package/core/arrow-tick/arrow-tick.props.d.ts +14 -0
- package/core/arrow-tick/arrow-tick.props.js +6 -0
- package/core/arrow-tick/arrow-tick.styles.d.ts +7 -0
- package/core/arrow-tick/arrow-tick.styles.js +18 -0
- package/core/arrow-tick/index.d.ts +2 -0
- package/core/arrow-tick/index.js +1 -0
- package/core/button/button.component.d.ts +9 -0
- package/core/button/button.component.js +71 -0
- package/core/button/button.types.d.ts +34 -0
- package/core/button/button.types.js +21 -0
- package/core/button/button.utils.d.ts +3 -0
- package/core/button/button.utils.js +18 -0
- package/core/button/components/end-icon.d.ts +12 -0
- package/core/button/components/end-icon.js +33 -0
- package/core/button/components/start-icon.d.ts +14 -0
- package/core/button/components/start-icon.js +40 -0
- package/core/button/index.d.ts +4 -0
- package/core/button/index.js +3 -0
- package/core/check-box/check-box.component.d.ts +3 -0
- package/core/check-box/check-box.component.js +62 -0
- package/core/check-box/check-box.mixin.d.ts +4 -0
- package/core/check-box/check-box.mixin.js +8 -0
- package/core/check-box/check-box.props.d.ts +15 -0
- package/core/check-box/check-box.props.js +1 -0
- package/core/check-box/check-box.styles.d.ts +19 -0
- package/core/check-box/check-box.styles.js +42 -0
- package/core/check-box/check-box.utils.d.ts +3 -0
- package/core/check-box/check-box.utils.js +21 -0
- package/core/check-box/index.d.ts +2 -0
- package/core/check-box/index.js +1 -0
- package/core/check-box/types/index.d.ts +2 -0
- package/core/check-box/types/index.js +2 -0
- package/core/check-box/types/size.d.ts +4 -0
- package/core/check-box/types/size.js +4 -0
- package/core/check-box/types/type.d.ts +4 -0
- package/core/check-box/types/type.js +4 -0
- package/core/check-box-group/check-box-group.component.d.ts +3 -0
- package/core/check-box-group/check-box-group.component.js +74 -0
- package/core/check-box-group/check-box-group.mixin.d.ts +5 -0
- package/core/check-box-group/check-box-group.mixin.js +10 -0
- package/core/check-box-group/check-box-group.props.d.ts +19 -0
- package/core/check-box-group/check-box-group.props.js +1 -0
- package/core/check-box-group/check-box-group.styles.d.ts +19 -0
- package/core/check-box-group/check-box-group.styles.js +33 -0
- package/core/check-box-group/index.d.ts +2 -0
- package/core/check-box-group/index.js +1 -0
- package/core/check-box-group/types/index.d.ts +1 -0
- package/core/check-box-group/types/index.js +1 -0
- package/core/check-box-group/types/label-position.d.ts +4 -0
- package/core/check-box-group/types/label-position.js +4 -0
- package/core/cross-button/cross-button.component.d.ts +3 -0
- package/core/cross-button/cross-button.component.js +35 -0
- package/core/cross-button/cross-button.props.d.ts +8 -0
- package/core/cross-button/cross-button.props.js +1 -0
- package/core/cross-button/cross-button.styles.d.ts +9 -0
- package/core/cross-button/cross-button.styles.js +21 -0
- package/core/cross-button/index.d.ts +2 -0
- package/core/cross-button/index.js +1 -0
- package/core/cross-button/types/index.d.ts +1 -0
- package/core/cross-button/types/index.js +1 -0
- package/core/cross-button/types/size.d.ts +6 -0
- package/core/cross-button/types/size.js +6 -0
- package/core/dot/dot.component.d.ts +3 -0
- package/core/dot/dot.component.js +17 -0
- package/core/dot/dot.props.d.ts +4 -0
- package/core/dot/dot.props.js +1 -0
- package/core/dot/dot.styles.d.ts +18 -0
- package/core/dot/dot.styles.js +32 -0
- package/core/dot/index.d.ts +2 -0
- package/core/dot/index.js +1 -0
- package/core/dots-navigation/dots-navigation.component.d.ts +3 -0
- package/core/dots-navigation/dots-navigation.component.js +24 -0
- package/core/dots-navigation/dots-navigation.props.d.ts +5 -0
- package/core/dots-navigation/dots-navigation.props.js +1 -0
- package/core/dots-navigation/dots-navigation.styles.d.ts +6 -0
- package/core/dots-navigation/dots-navigation.styles.js +15 -0
- package/core/dots-navigation/index.d.ts +2 -0
- package/core/dots-navigation/index.js +1 -0
- package/core/input/index.d.ts +2 -0
- package/core/input/index.js +1 -0
- package/core/input/input.component.d.ts +3 -0
- package/core/input/input.component.js +293 -0
- package/core/input/input.mixin.d.ts +18 -0
- package/core/input/input.mixin.js +25 -0
- package/core/input/input.props.d.ts +40 -0
- package/core/input/input.props.js +1 -0
- package/core/input/input.styles.d.ts +78 -0
- package/core/input/input.styles.js +148 -0
- package/core/input/input.utils.d.ts +4 -0
- package/core/input/input.utils.js +30 -0
- package/core/input/types/index.d.ts +1 -0
- package/core/input/types/index.js +1 -0
- package/core/input/types/type.d.ts +4 -0
- package/core/input/types/type.js +4 -0
- package/core/modal/index.d.ts +2 -0
- package/core/modal/index.js +1 -0
- package/core/modal/modal-menu-context.d.ts +5 -0
- package/core/modal/modal-menu-context.js +10 -0
- package/core/modal/modal.component.d.ts +3 -0
- package/core/modal/modal.component.js +97 -0
- package/core/modal/modal.mixin.d.ts +7 -0
- package/core/modal/modal.mixin.js +4 -0
- package/core/modal/modal.props.d.ts +16 -0
- package/core/modal/modal.props.js +1 -0
- package/core/modal/modal.styles.d.ts +22 -0
- package/core/modal/modal.styles.js +51 -0
- package/core/modal/modal.utils.d.ts +1 -0
- package/core/modal/modal.utils.js +4 -0
- package/core/modal/types/index.d.ts +1 -0
- package/core/modal/types/index.js +1 -0
- package/core/modal/types/size.d.ts +7 -0
- package/core/modal/types/size.js +7 -0
- package/core/modal-actions/index.d.ts +2 -0
- package/core/modal-actions/index.js +1 -0
- package/core/modal-actions/modal-actions.component.d.ts +3 -0
- package/core/modal-actions/modal-actions.component.js +18 -0
- package/core/modal-actions/modal-actions.props.d.ts +8 -0
- package/core/modal-actions/modal-actions.props.js +1 -0
- package/core/modal-actions/modal-actions.styles.d.ts +7 -0
- package/core/modal-actions/modal-actions.styles.js +17 -0
- package/core/modal-actions/types/align.d.ts +5 -0
- package/core/modal-actions/types/align.js +5 -0
- package/core/modal-actions/types/index.d.ts +1 -0
- package/core/modal-actions/types/index.js +1 -0
- package/core/modal-content/index.d.ts +2 -0
- package/core/modal-content/index.js +1 -0
- package/core/modal-content/modal-content.component.d.ts +3 -0
- package/core/modal-content/modal-content.component.js +15 -0
- package/core/modal-content/modal-content.props.d.ts +4 -0
- package/core/modal-content/modal-content.props.js +1 -0
- package/core/modal-content/modal-content.styles.d.ts +6 -0
- package/core/modal-content/modal-content.styles.js +12 -0
- package/core/modal-title/index.d.ts +2 -0
- package/core/modal-title/index.js +1 -0
- package/core/modal-title/modal-title.component.d.ts +6 -0
- package/core/modal-title/modal-title.component.js +37 -0
- package/core/modal-title/modal-title.props.d.ts +14 -0
- package/core/modal-title/modal-title.props.js +1 -0
- package/core/modal-title/modal-title.styles.d.ts +31 -0
- package/core/modal-title/modal-title.styles.js +64 -0
- package/core/modal-title/types/index.d.ts +1 -0
- package/core/modal-title/types/index.js +1 -0
- package/core/modal-title/types/variant.d.ts +4 -0
- package/core/modal-title/types/variant.js +4 -0
- package/core/pagination/index.d.ts +2 -0
- package/core/pagination/index.js +1 -0
- package/core/pagination/pagination.component.d.ts +3 -0
- package/core/pagination/pagination.component.js +81 -0
- package/core/pagination/pagination.props.d.ts +11 -0
- package/core/pagination/pagination.props.js +1 -0
- package/core/pagination/pagination.styles.d.ts +19 -0
- package/core/pagination/pagination.styles.js +36 -0
- package/core/popper/index.d.ts +2 -0
- package/core/popper/index.js +1 -0
- package/core/popper/popper.component.d.ts +3 -0
- package/core/popper/popper.component.js +150 -0
- package/core/popper/popper.mixin.d.ts +17 -0
- package/core/popper/popper.mixin.js +5 -0
- package/core/popper/popper.props.d.ts +41 -0
- package/core/popper/popper.props.js +1 -0
- package/core/popper/popper.styles.d.ts +25 -0
- package/core/popper/popper.styles.js +48 -0
- package/core/popper/popper.utils.d.ts +1 -0
- package/core/popper/popper.utils.js +10 -0
- package/core/popper/types/index.d.ts +3 -0
- package/core/popper/types/index.js +3 -0
- package/core/popper/types/phases.d.ts +11 -0
- package/core/popper/types/phases.js +11 -0
- package/core/popper/types/position.d.ts +17 -0
- package/core/popper/types/position.js +17 -0
- package/core/popper/types/strategy.d.ts +4 -0
- package/core/popper/types/strategy.js +4 -0
- package/core/radio/index.d.ts +3 -0
- package/core/radio/index.js +2 -0
- package/core/radio/radio.component.d.ts +3 -0
- package/core/radio/radio.component.js +38 -0
- package/core/radio/radio.mixin.d.ts +13 -0
- package/core/radio/radio.mixin.js +13 -0
- package/core/radio/radio.props.d.ts +13 -0
- package/core/radio/radio.props.js +1 -0
- package/core/radio/radio.styles.d.ts +19 -0
- package/core/radio/radio.styles.js +44 -0
- package/core/radio/size.d.ts +4 -0
- package/core/radio/size.js +4 -0
- package/core/radio-group/index.d.ts +2 -0
- package/core/radio-group/index.js +1 -0
- package/core/radio-group/radio-group.component.d.ts +3 -0
- package/core/radio-group/radio-group.component.js +48 -0
- package/core/radio-group/radio-group.props.d.ts +15 -0
- package/core/radio-group/radio-group.props.js +1 -0
- package/core/radio-group/radio-group.styles.d.ts +14 -0
- package/core/radio-group/radio-group.styles.js +30 -0
- package/core/switcher/index.d.ts +3 -0
- package/core/switcher/index.js +2 -0
- package/core/switcher/switcher-size.d.ts +5 -0
- package/core/switcher/switcher-size.js +5 -0
- package/core/switcher/switcher.component.d.ts +3 -0
- package/core/switcher/switcher.component.js +54 -0
- package/core/switcher/switcher.mixin.d.ts +21 -0
- package/core/switcher/switcher.mixin.js +17 -0
- package/core/switcher/switcher.props.d.ts +14 -0
- package/core/switcher/switcher.props.js +1 -0
- package/core/switcher/switcher.styles.d.ts +27 -0
- package/core/switcher/switcher.styles.js +54 -0
- package/core/switcher/switcher.utils.d.ts +4 -0
- package/core/switcher/switcher.utils.js +37 -0
- package/core/switcher-group/index.d.ts +2 -0
- package/core/switcher-group/index.js +1 -0
- package/core/switcher-group/switcher-group.component.d.ts +3 -0
- package/core/switcher-group/switcher-group.component.js +41 -0
- package/core/switcher-group/switcher-group.props.d.ts +13 -0
- package/core/switcher-group/switcher-group.props.js +1 -0
- package/core/switcher-group/switcher-group.styles.d.ts +10 -0
- package/core/switcher-group/switcher-group.styles.js +30 -0
- package/core/tab/index.d.ts +2 -0
- package/core/tab/index.js +1 -0
- package/core/tab/tab.component.d.ts +6 -0
- package/core/tab/tab.component.js +52 -0
- package/core/tab/tab.mixin.d.ts +11 -0
- package/core/tab/tab.mixin.js +15 -0
- package/core/tab/tab.props.d.ts +15 -0
- package/core/tab/tab.props.js +1 -0
- package/core/tab/tab.styles.d.ts +26 -0
- package/core/tab/tab.styles.js +61 -0
- package/core/tab/types/index.d.ts +1 -0
- package/core/tab/types/index.js +1 -0
- package/core/tab/types/size.d.ts +5 -0
- package/core/tab/types/size.js +5 -0
- package/core/tab-panel/index.d.ts +2 -0
- package/core/tab-panel/index.js +1 -0
- package/core/tab-panel/tab-panel.component.d.ts +3 -0
- package/core/tab-panel/tab-panel.component.js +18 -0
- package/core/tab-panel/tab-panel.props.d.ts +6 -0
- package/core/tab-panel/tab-panel.props.js +1 -0
- package/core/tab-panel/tab-panel.styles.d.ts +6 -0
- package/core/tab-panel/tab-panel.styles.js +12 -0
- package/core/upload-input/index.d.ts +2 -0
- package/core/upload-input/index.js +1 -0
- package/core/upload-input/upload-input.component.d.ts +3 -0
- package/core/upload-input/upload-input.component.js +68 -0
- package/core/upload-input/upload-input.props.d.ts +9 -0
- package/core/upload-input/upload-input.props.js +1 -0
- package/core/upload-input/upload-input.styles.d.ts +11 -0
- package/core/upload-input/upload-input.styles.js +53 -0
- package/hooks/README.md +26 -0
- package/hooks/use-controlled.d.ts +1 -0
- package/hooks/use-controlled.js +20 -0
- package/hooks/use-debounce.d.ts +2 -0
- package/hooks/use-debounce.js +19 -0
- package/hooks/use-drag.d.ts +5 -0
- package/hooks/use-drag.js +37 -0
- package/hooks/use-enhanced-effect.d.ts +3 -0
- package/hooks/use-enhanced-effect.js +3 -0
- package/hooks/use-event-callback.d.ts +4 -0
- package/hooks/use-event-callback.js +19 -0
- package/hooks/use-pagination.d.ts +3 -0
- package/hooks/use-pagination.js +106 -0
- package/hooks/use-portal.d.ts +14 -0
- package/hooks/use-portal.js +75 -0
- package/package.json +63 -0
- package/theme/README.md +46 -0
- package/theme/entity/index.d.ts +1 -0
- package/theme/entity/index.js +1 -0
- package/theme/entity/theme.d.ts +34 -0
- package/theme/hooks/index.d.ts +2 -0
- package/theme/hooks/index.js +2 -0
- package/theme/hooks/use-media-query.d.ts +1 -0
- package/theme/hooks/use-media-query.js +27 -0
- package/theme/hooks/use-theme.d.ts +2 -0
- package/theme/hooks/use-theme.js +4 -0
- package/theme/index.d.ts +3 -0
- package/theme/index.js +1 -0
- package/theme/roots/breakpoints/entity/breakpoints-map.d.ts +8 -0
- package/theme/roots/breakpoints/entity/breakpoints.d.ts +73 -0
- package/theme/roots/breakpoints/entity/create-breakpoints.d.ts +3 -0
- package/theme/roots/breakpoints/entity/create-breakpoints.js +65 -0
- package/theme/roots/breakpoints/entity/default-breakpoints.d.ts +26 -0
- package/theme/roots/breakpoints/entity/default-breakpoints.js +22 -0
- package/theme/roots/breakpoints/entity/index.d.ts +3 -0
- package/theme/roots/breakpoints/entity/index.js +2 -0
- package/theme/roots/breakpoints/index.d.ts +3 -0
- package/theme/roots/breakpoints/index.js +1 -0
- package/theme/roots/common-styles.d.ts +2 -0
- package/theme/roots/common-styles.js +6 -0
- package/theme/roots/index.d.ts +2 -0
- package/theme/roots/index.js +2 -0
- package/theme/roots/palette/entity/colors-map.d.ts +4 -0
- package/theme/roots/palette/entity/default-palette.d.ts +282 -0
- package/theme/roots/palette/entity/default-palette.js +22 -0
- package/theme/roots/palette/entity/index.d.ts +2 -0
- package/theme/roots/palette/entity/index.js +2 -0
- package/theme/roots/palette/index.d.ts +2 -0
- package/theme/roots/palette/index.js +1 -0
- package/theme/roots/shadows/entity/default-shadows.d.ts +16 -0
- package/theme/roots/shadows/entity/default-shadows.js +5 -0
- package/theme/roots/shadows/entity/index.d.ts +2 -0
- package/theme/roots/shadows/entity/index.js +2 -0
- package/theme/roots/shadows/entity/shadows-map.d.ts +4 -0
- package/theme/roots/shadows/index.d.ts +2 -0
- package/theme/roots/shadows/index.js +1 -0
- package/theme/roots/shape/index.d.ts +1 -0
- package/theme/roots/shape/index.js +1 -0
- package/theme/roots/shape/shape.props.d.ts +5 -0
- package/theme/roots/shape/shape.props.js +1 -0
- package/theme/roots/typography/entity/default-typography.d.ts +398 -0
- package/theme/roots/typography/entity/default-typography.js +237 -0
- package/theme/roots/typography/entity/index.d.ts +1 -0
- package/theme/roots/typography/entity/index.js +1 -0
- package/theme/roots/typography/index.d.ts +3 -0
- package/theme/roots/typography/index.js +2 -0
- package/theme/roots/typography/typography.component.d.ts +2 -0
- package/theme/roots/typography/typography.component.js +7 -0
- package/theme/roots/typography/typography.props.d.ts +15 -0
- package/theme/roots/typography/typography.props.js +1 -0
- package/theme/theme-provider/index.d.ts +2 -0
- package/theme/theme-provider/index.js +1 -0
- package/theme/theme-provider/theme-provider.context.d.ts +4 -0
- package/theme/theme-provider/theme-provider.context.js +48 -0
- package/theme/theme-provider/theme-provider.props.d.ts +6 -0
- package/theme/theme-provider/theme-provider.props.js +1 -0
- package/theme/theme.css +100 -0
- package/tsconfig.json +22 -0
- package/utils/README.md +11 -0
- package/utils/functions/apply-display-names.d.ts +6 -0
- package/utils/functions/apply-display-names.js +12 -0
- package/utils/functions/apply-polymorphic-function-prop.d.ts +6 -0
- package/utils/functions/apply-polymorphic-function-prop.js +11 -0
- package/utils/functions/color-picker/color-converters.d.ts +11 -0
- package/utils/functions/color-picker/color-converters.js +159 -0
- package/utils/functions/color-picker/map-number.d.ts +1 -0
- package/utils/functions/color-picker/map-number.js +3 -0
- package/utils/functions/color-picker/restrict-number.d.ts +1 -0
- package/utils/functions/color-picker/restrict-number.js +8 -0
- package/utils/functions/convert-to-string.d.ts +1 -0
- package/utils/functions/convert-to-string.js +3 -0
- package/utils/functions/escape-regexp.d.ts +1 -0
- package/utils/functions/escape-regexp.js +3 -0
- package/utils/functions/generate-class-names.d.ts +1 -0
- package/utils/functions/generate-class-names.js +22 -0
- package/utils/functions/get-elem-document-coords.d.ts +6 -0
- package/utils/functions/get-elem-document-coords.js +21 -0
- package/utils/functions/ignore-event.d.ts +1 -0
- package/utils/functions/ignore-event.js +9 -0
- package/utils/functions/index.d.ts +14 -0
- package/utils/functions/index.js +15 -0
- package/utils/functions/intrinsic-component.d.ts +0 -0
- package/utils/functions/intrinsic-component.js +28 -0
- package/utils/functions/object-keys.d.ts +6 -0
- package/utils/functions/object-keys.js +6 -0
- package/utils/functions/object-values.d.ts +7 -0
- package/utils/functions/object-values.js +6 -0
- package/utils/functions/on-click-by-mouse-down.d.ts +2 -0
- package/utils/functions/on-click-by-mouse-down.js +9 -0
- package/utils/functions/scrollbar.d.ts +2 -0
- package/utils/functions/scrollbar.js +6 -0
- package/utils/functions/set-ref.d.ts +8 -0
- package/utils/functions/set-ref.js +13 -0
- package/utils/functions/shadcn-utils.d.ts +2 -0
- package/utils/functions/shadcn-utils.js +8 -0
- package/utils/functions/slider/utils.d.ts +47 -0
- package/utils/functions/slider/utils.js +124 -0
- package/utils/functions/use-fork-ref.d.ts +2 -0
- package/utils/functions/use-fork-ref.js +18 -0
- package/utils/types/color/icon-button-color.d.ts +5 -0
- package/utils/types/color/icon-button-color.js +5 -0
- package/utils/types/color/index.d.ts +2 -0
- package/utils/types/color/index.js +2 -0
- package/utils/types/color/input-background-color.d.ts +4 -0
- package/utils/types/color/input-background-color.js +4 -0
- package/utils/types/css/align.d.ts +11 -0
- package/utils/types/css/align.js +11 -0
- package/utils/types/css/breakpoint.d.ts +18 -0
- package/utils/types/css/breakpoint.js +18 -0
- package/utils/types/css/direction.d.ts +8 -0
- package/utils/types/css/direction.js +4 -0
- package/utils/types/css/index.d.ts +4 -0
- package/utils/types/css/index.js +4 -0
- package/utils/types/css/position.d.ts +6 -0
- package/utils/types/css/position.js +6 -0
- package/utils/types/index.d.ts +8 -0
- package/utils/types/index.js +3 -0
- package/utils/types/intrinsic-component.d.ts +1 -0
- package/utils/types/keys.d.ts +4 -0
- package/utils/types/palette/color.d.ts +133 -0
- package/utils/types/palette/color.js +133 -0
- package/utils/types/palette/index.d.ts +1 -0
- package/utils/types/palette/index.js +1 -0
- package/utils/types/position/index.d.ts +1 -0
- package/utils/types/position/index.js +1 -0
- package/utils/types/position/position.d.ts +6 -0
- package/utils/types/position/position.js +6 -0
- package/utils/types/prop-types/index.d.ts +1 -0
- package/utils/types/prop-types/index.js +1 -0
- package/utils/types/prop-types/record.d.ts +1 -0
- package/utils/types/prop-types/record.js +6 -0
- package/utils/types/shadows/index.d.ts +1 -0
- package/utils/types/shadows/index.js +1 -0
- package/utils/types/shadows/shadows.d.ts +14 -0
- package/utils/types/shadows/shadows.js +14 -0
- package/utils/types/shape/border-radius-size.d.ts +5 -0
- package/utils/types/shape/border-radius-size.js +5 -0
- package/utils/types/shape/index.d.ts +1 -0
- package/utils/types/shape/index.js +1 -0
- package/utils/types/size/index.d.ts +1 -0
- package/utils/types/size/index.js +1 -0
- package/utils/types/size/input-size.d.ts +4 -0
- package/utils/types/size/input-size.js +4 -0
- package/utils/types/stylable-component.d.ts +7 -0
- package/utils/types/typography/font-variant.d.ts +58 -0
- package/utils/types/typography/font-variant.js +58 -0
- package/utils/types/typography/font-weight.d.ts +11 -0
- package/utils/types/typography/font-weight.js +11 -0
- package/utils/types/typography/index.d.ts +4 -0
- package/utils/types/typography/index.js +4 -0
- package/utils/types/typography/text-align.d.ts +5 -0
- package/utils/types/typography/text-align.js +5 -0
- package/utils/types/typography/text-decoration.d.ts +5 -0
- package/utils/types/typography/text-decoration.js +5 -0
- package/utils/types/values.d.ts +4 -0
- package/utils/types/with.d.ts +4 -0
package/hooks/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @scaleflex/ui-tw/hooks
|
|
2
|
+
|
|
3
|
+
Batch of useful UI-related React hooks.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Every hook functions is exported by default and should be used inside React components with respect to the
|
|
10
|
+
[rules of hooks](https://reactjs.org/docs/hooks-rules.html).
|
|
11
|
+
|
|
12
|
+
```typescript jsx
|
|
13
|
+
import useMediaQuery from '@scaleflex/ui-tw/hooks/use-portal'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @example
|
|
17
|
+
* <PortalComponent>
|
|
18
|
+
* <p>Portal content</p>
|
|
19
|
+
* </PortalComponent>
|
|
20
|
+
*/
|
|
21
|
+
const PortalComponent = ({ id, children }) => {
|
|
22
|
+
const target = usePortal(id)
|
|
23
|
+
|
|
24
|
+
return createPortal(children, target)
|
|
25
|
+
}
|
|
26
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useControlled({ controlled, default: defaultProp }: any): any;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useCallback, useRef, useState } from 'react';
|
|
3
|
+
export default function useControlled(_ref) {
|
|
4
|
+
var controlled = _ref.controlled,
|
|
5
|
+
defaultProp = _ref["default"];
|
|
6
|
+
// isControlled is ignored in the hook dependency lists as it should never change.
|
|
7
|
+
var _useRef = useRef(controlled !== undefined),
|
|
8
|
+
isControlled = _useRef.current;
|
|
9
|
+
var _useState = useState(defaultProp),
|
|
10
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
11
|
+
valueState = _useState2[0],
|
|
12
|
+
setValue = _useState2[1];
|
|
13
|
+
var value = isControlled ? controlled : valueState;
|
|
14
|
+
var setValueIfUncontrolled = useCallback(function (newValue) {
|
|
15
|
+
if (!isControlled) {
|
|
16
|
+
setValue(newValue);
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
return [value, setValueIfUncontrolled];
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
function useDebounce(value) {
|
|
4
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
|
|
5
|
+
var _useState = useState(value),
|
|
6
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
7
|
+
debouncedValue = _useState2[0],
|
|
8
|
+
setDebouncedValue = _useState2[1];
|
|
9
|
+
useEffect(function () {
|
|
10
|
+
var handler = setTimeout(function () {
|
|
11
|
+
setDebouncedValue(value);
|
|
12
|
+
}, delay);
|
|
13
|
+
return function () {
|
|
14
|
+
clearTimeout(handler);
|
|
15
|
+
};
|
|
16
|
+
}, [value]);
|
|
17
|
+
return debouncedValue;
|
|
18
|
+
}
|
|
19
|
+
export { useDebounce };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function useDrag(onMove, onStart, onEnd) {
|
|
2
|
+
var onDragging = function onDragging(e) {
|
|
3
|
+
if (typeof onMove === 'function') {
|
|
4
|
+
var _e$touches;
|
|
5
|
+
onMove(((_e$touches = e.touches) === null || _e$touches === void 0 ? void 0 : _e$touches[0]) || e);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
var _disableSliding = function disableSliding(e) {
|
|
9
|
+
document.removeEventListener('mousemove', onDragging);
|
|
10
|
+
document.removeEventListener('mouseup', _disableSliding);
|
|
11
|
+
document.removeEventListener('mouseleave', _disableSliding);
|
|
12
|
+
document.removeEventListener('touchmove', onDragging);
|
|
13
|
+
document.removeEventListener('touchend', _disableSliding);
|
|
14
|
+
document.removeEventListener('touchcancel', _disableSliding);
|
|
15
|
+
if (typeof onEnd === 'function') {
|
|
16
|
+
var _e$touches2;
|
|
17
|
+
onEnd(((_e$touches2 = e.touches) === null || _e$touches2 === void 0 ? void 0 : _e$touches2[0]) || e);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var enableDrag = function enableDrag(e) {
|
|
21
|
+
document.addEventListener('mousemove', onDragging);
|
|
22
|
+
document.addEventListener('mouseup', _disableSliding);
|
|
23
|
+
document.addEventListener('mouseleave', _disableSliding);
|
|
24
|
+
document.addEventListener('touchmove', onDragging);
|
|
25
|
+
document.addEventListener('touchend', _disableSliding);
|
|
26
|
+
document.addEventListener('touchcancel', _disableSliding);
|
|
27
|
+
if (typeof onStart === 'function') {
|
|
28
|
+
var _e$touches3;
|
|
29
|
+
onStart(((_e$touches3 = e.touches) === null || _e$touches3 === void 0 ? void 0 : _e$touches3[0]) || e);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
onMouseDown: enableDrag,
|
|
34
|
+
onTouchStart: enableDrag
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export default useDrag;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import useEnhancedEffect from './use-enhanced-effect';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* https://github.com/facebook/react/issues/14099#issuecomment-440013892
|
|
6
|
+
*/
|
|
7
|
+
export default function useEventCallback(fn) {
|
|
8
|
+
var ref = React.useRef(fn);
|
|
9
|
+
useEnhancedEffect(function () {
|
|
10
|
+
ref.current = fn;
|
|
11
|
+
});
|
|
12
|
+
return React.useCallback(function () {
|
|
13
|
+
return (
|
|
14
|
+
// @ts-expect-error hide `this`
|
|
15
|
+
// tslint:disable-next-line:ban-comma-operator
|
|
16
|
+
(0, ref.current).apply(void 0, arguments)
|
|
17
|
+
);
|
|
18
|
+
}, []);
|
|
19
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["boundaryCount", "count", "defaultPage", "disabled", "onChange", "page", "siblingCount"];
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
/**
|
|
9
|
+
* Borrows heavily from and inspired by material-ui https://github.com/mui-org/material-ui
|
|
10
|
+
* basically a stripped-down version of it. Uing only the core functionalities and using what we need from it
|
|
11
|
+
*/
|
|
12
|
+
import useControlled from './use-controlled';
|
|
13
|
+
function usePagination(_ref) {
|
|
14
|
+
var _ref$boundaryCount = _ref.boundaryCount,
|
|
15
|
+
boundaryCount = _ref$boundaryCount === void 0 ? 1 : _ref$boundaryCount,
|
|
16
|
+
_ref$count = _ref.count,
|
|
17
|
+
count = _ref$count === void 0 ? 1 : _ref$count,
|
|
18
|
+
_ref$defaultPage = _ref.defaultPage,
|
|
19
|
+
defaultPage = _ref$defaultPage === void 0 ? 1 : _ref$defaultPage,
|
|
20
|
+
_ref$disabled = _ref.disabled,
|
|
21
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
22
|
+
handleChange = _ref.onChange,
|
|
23
|
+
pageProp = _ref.page,
|
|
24
|
+
_ref$siblingCount = _ref.siblingCount,
|
|
25
|
+
siblingCount = _ref$siblingCount === void 0 ? 1 : _ref$siblingCount,
|
|
26
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
var _useControlled = useControlled({
|
|
28
|
+
controlled: pageProp,
|
|
29
|
+
"default": defaultPage
|
|
30
|
+
}),
|
|
31
|
+
_useControlled2 = _slicedToArray(_useControlled, 2),
|
|
32
|
+
page = _useControlled2[0],
|
|
33
|
+
setPageState = _useControlled2[1];
|
|
34
|
+
var handleClick = function handleClick(event, value) {
|
|
35
|
+
if (!pageProp) {
|
|
36
|
+
setPageState(value);
|
|
37
|
+
}
|
|
38
|
+
if (handleChange) {
|
|
39
|
+
handleChange(event, value);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var range = function range(start, end) {
|
|
43
|
+
var length = end - start + 1;
|
|
44
|
+
return Array.from({
|
|
45
|
+
length: length
|
|
46
|
+
}, function (_, i) {
|
|
47
|
+
return start + i;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var startPages = range(1, Math.min(boundaryCount, count));
|
|
51
|
+
var endPages = range(Math.max(count - boundaryCount + 1, boundaryCount + 1), count);
|
|
52
|
+
var siblingsStart = Math.max(Math.min(
|
|
53
|
+
// Natural start
|
|
54
|
+
page - siblingCount,
|
|
55
|
+
// Lower boundary when page is high
|
|
56
|
+
count - boundaryCount - siblingCount * 2 - 1),
|
|
57
|
+
// Greater than startPages
|
|
58
|
+
boundaryCount + 2);
|
|
59
|
+
var siblingsEnd = Math.min(Math.max(
|
|
60
|
+
// Natural end
|
|
61
|
+
page + siblingCount,
|
|
62
|
+
// Upper boundary when page is low
|
|
63
|
+
boundaryCount + siblingCount * 2 + 2),
|
|
64
|
+
// Less than endPages
|
|
65
|
+
endPages.length > 0 ? endPages[0] - 2 : count - 1);
|
|
66
|
+
var itemList = ['first'].concat(['previous'], _toConsumableArray(startPages), _toConsumableArray(siblingsStart > boundaryCount + 2 ? ['start-ellipsis'] : boundaryCount + 1 < count - boundaryCount ? [boundaryCount + 1] : []), _toConsumableArray(range(siblingsStart, siblingsEnd)), _toConsumableArray(siblingsEnd < count - boundaryCount - 1 ? ['end-ellipsis'] : count - boundaryCount > boundaryCount ? [count - boundaryCount] : []), _toConsumableArray(endPages), ['next'], ['last']);
|
|
67
|
+
var buttonPage = function buttonPage(type) {
|
|
68
|
+
switch (type) {
|
|
69
|
+
case 'first':
|
|
70
|
+
return 1;
|
|
71
|
+
case 'previous':
|
|
72
|
+
return page - 1;
|
|
73
|
+
case 'next':
|
|
74
|
+
return page + 1;
|
|
75
|
+
case 'last':
|
|
76
|
+
return count;
|
|
77
|
+
default:
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var items = itemList.map(function (item) {
|
|
82
|
+
return typeof item === 'number' ? {
|
|
83
|
+
onClick: function onClick(event) {
|
|
84
|
+
handleClick(event, item);
|
|
85
|
+
},
|
|
86
|
+
type: 'page',
|
|
87
|
+
page: item,
|
|
88
|
+
selected: item === page,
|
|
89
|
+
disabled: disabled,
|
|
90
|
+
'aria-current': item === page ? 'true' : undefined
|
|
91
|
+
} : {
|
|
92
|
+
onClick: function onClick(event) {
|
|
93
|
+
handleClick(event, buttonPage(item));
|
|
94
|
+
},
|
|
95
|
+
type: item,
|
|
96
|
+
page: buttonPage(item),
|
|
97
|
+
selected: false,
|
|
98
|
+
disabled: disabled || !item.includes('ellipsis') && (item === 'next' || item === 'last' ? page >= count : page <= 1)
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
return _objectSpread({
|
|
102
|
+
items: items
|
|
103
|
+
}, other);
|
|
104
|
+
}
|
|
105
|
+
export default usePagination;
|
|
106
|
+
export { usePagination };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to create a React Portal.
|
|
3
|
+
* Automatically handles creating and tearing-down the root elements (no SRR
|
|
4
|
+
* makes this trivial), so there is no need to ensure the parent target already
|
|
5
|
+
* exists.
|
|
6
|
+
* @example
|
|
7
|
+
* const target = usePortal(id, [id]);
|
|
8
|
+
* return createPortal(children, target);
|
|
9
|
+
* @param {String} id The id of the target container, e.g 'modal' or 'spotlight'
|
|
10
|
+
* @returns {HTMLElement} The DOM node to use as the Portal target.
|
|
11
|
+
*/
|
|
12
|
+
declare function usePortal(id: string): HTMLElement;
|
|
13
|
+
export default usePortal;
|
|
14
|
+
export { usePortal };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Creates DOM element to be used as React root.
|
|
4
|
+
*/
|
|
5
|
+
function createRootElement(id) {
|
|
6
|
+
var rootContainer = document.createElement('div');
|
|
7
|
+
rootContainer.setAttribute('id', id);
|
|
8
|
+
return rootContainer;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Appends element as last child of body.
|
|
13
|
+
*/
|
|
14
|
+
function addRootElement(rootElem) {
|
|
15
|
+
document.body.append(rootElem);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Hook to create a React Portal.
|
|
20
|
+
* Automatically handles creating and tearing-down the root elements (no SRR
|
|
21
|
+
* makes this trivial), so there is no need to ensure the parent target already
|
|
22
|
+
* exists.
|
|
23
|
+
* @example
|
|
24
|
+
* const target = usePortal(id, [id]);
|
|
25
|
+
* return createPortal(children, target);
|
|
26
|
+
* @param {String} id The id of the target container, e.g 'modal' or 'spotlight'
|
|
27
|
+
* @returns {HTMLElement} The DOM node to use as the Portal target.
|
|
28
|
+
*/
|
|
29
|
+
function usePortal(id) {
|
|
30
|
+
var rootElemRef = useRef(null);
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
// Look for existing target dom element to append to
|
|
33
|
+
var existingParent = document.querySelector("#".concat(id));
|
|
34
|
+
// Parent is either a new root or the existing dom element
|
|
35
|
+
var parentElem = existingParent || createRootElement(id);
|
|
36
|
+
|
|
37
|
+
// If there is no existing DOM element, add a new one.
|
|
38
|
+
if (!existingParent) {
|
|
39
|
+
addRootElement(parentElem);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Add the detached element to the parent
|
|
43
|
+
if (rootElemRef.current) {
|
|
44
|
+
parentElem.append(rootElemRef.current);
|
|
45
|
+
}
|
|
46
|
+
return function removeElement() {
|
|
47
|
+
if (rootElemRef.current) {
|
|
48
|
+
rootElemRef.current.remove();
|
|
49
|
+
}
|
|
50
|
+
if (parentElem.childNodes.length === -1) {
|
|
51
|
+
parentElem.remove();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* It's important we evaluate this lazily:
|
|
58
|
+
* - We need first render to contain the DOM element, so it shouldn't happen
|
|
59
|
+
* in useEffect. We would normally put this in the constructor().
|
|
60
|
+
* - We can't do 'const rootElemRef = useRef(document.createElement('div))',
|
|
61
|
+
* since this will run every single render (that's a lot).
|
|
62
|
+
* - We want the ref to consistently point to the same DOM element and only
|
|
63
|
+
* ever run once.
|
|
64
|
+
* @link https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
|
|
65
|
+
*/
|
|
66
|
+
function getRootElem() {
|
|
67
|
+
if (!rootElemRef.current) {
|
|
68
|
+
rootElemRef.current = document.createElement('div');
|
|
69
|
+
}
|
|
70
|
+
return rootElemRef.current;
|
|
71
|
+
}
|
|
72
|
+
return getRootElem();
|
|
73
|
+
}
|
|
74
|
+
export default usePortal;
|
|
75
|
+
export { usePortal };
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scaleflex/ui-tw",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"author": "scaleflex",
|
|
5
|
+
"repository": "github:scaleflex/ui",
|
|
6
|
+
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"react",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"description": "React UI components library based on Tailwind and ShadCN by Scaleflex Company",
|
|
13
|
+
"main": "lib/index.js",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@popperjs/core": "^2.6.0",
|
|
16
|
+
"@radix-ui/react-slot": "^1.1.2",
|
|
17
|
+
"@scaleflex/icons-tw": "^0.0.1",
|
|
18
|
+
"@types/lodash.merge": "^4.6.9",
|
|
19
|
+
"class-variance-authority": "^0.7.1",
|
|
20
|
+
"lodash.merge": "^4.6.2",
|
|
21
|
+
"lucide-react": "^0.487.0",
|
|
22
|
+
"prop-types": "^15.7.2",
|
|
23
|
+
"tw-animate-css": "^1.2.5"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/prop-types": "^15.7.3",
|
|
27
|
+
"postcss": "^8.5.3",
|
|
28
|
+
"typescript": "^5.2.2"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@types/react": ">=19.0.0",
|
|
32
|
+
"@types/react-dom": ">=19.0.0",
|
|
33
|
+
"clsx": ">=2.0.0",
|
|
34
|
+
"react": ">=19.0.0",
|
|
35
|
+
"react-dom": ">=19.0.0",
|
|
36
|
+
"styled-components": ">=6.0.0",
|
|
37
|
+
"tailwind-merge": ">=1.14.0",
|
|
38
|
+
"tailwindcss": ">=4.0.0"
|
|
39
|
+
},
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"browserslist": {
|
|
42
|
+
"production": [
|
|
43
|
+
"edge >= 14",
|
|
44
|
+
"firefox >= 52",
|
|
45
|
+
"chrome >= 49",
|
|
46
|
+
"safari >= 10"
|
|
47
|
+
],
|
|
48
|
+
"development": [
|
|
49
|
+
"last 1 chrome version",
|
|
50
|
+
"last 1 firefox version",
|
|
51
|
+
"last 1 safari version"
|
|
52
|
+
],
|
|
53
|
+
"ssr": [
|
|
54
|
+
"node >= 12"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=12"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/theme/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @scaleflex/ui-tw/theme
|
|
2
|
+
|
|
3
|
+
Theme package.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Along with `<ThemeProvider />` component, which has to be wrapper around you application, we export hook – `useTheme`.
|
|
10
|
+
|
|
11
|
+
```typescript jsx
|
|
12
|
+
<ThemeProvider>
|
|
13
|
+
<App />
|
|
14
|
+
</ThemeProvider>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Then, use all the features of our theme inside any part of your React application:
|
|
18
|
+
|
|
19
|
+
### styled-components
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
const Button = styled.button(
|
|
23
|
+
({ theme }) => css`
|
|
24
|
+
color: ${theme.palette['accent-strong']};
|
|
25
|
+
`,
|
|
26
|
+
)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Fonts
|
|
30
|
+
|
|
31
|
+
Out of the box we provide **no default fonts**.
|
|
32
|
+
|
|
33
|
+
To connect the fonts defined as default in our design system you have an option to create your own `@font-face`
|
|
34
|
+
rules.
|
|
35
|
+
|
|
36
|
+
To override predefined `font-family` you can pass them into the `theme` prop of the `ThemeProvider` component:
|
|
37
|
+
|
|
38
|
+
```typescript jsx
|
|
39
|
+
<ThemeProvider
|
|
40
|
+
theme={{
|
|
41
|
+
typography: {
|
|
42
|
+
fontFamily: 'Roboto, sans-serif'
|
|
43
|
+
},
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { Theme, ThemeOverride, WithTheme } from './theme';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DefaultTheme } from 'styled-components'
|
|
2
|
+
|
|
3
|
+
import type { With } from '../../utils/types'
|
|
4
|
+
import type { Breakpoints } from '../roots/breakpoints'
|
|
5
|
+
import type { ColorsMap } from '../roots/palette'
|
|
6
|
+
import { ShadowsMap } from '../roots/shadows'
|
|
7
|
+
import type { ShapeProps } from '../roots/shape'
|
|
8
|
+
import type { TypographyProps } from '../roots/typography'
|
|
9
|
+
|
|
10
|
+
export interface Theme {
|
|
11
|
+
readonly breakpoints: Breakpoints
|
|
12
|
+
|
|
13
|
+
readonly palette: ColorsMap
|
|
14
|
+
|
|
15
|
+
readonly typography: TypographyProps
|
|
16
|
+
|
|
17
|
+
readonly shape: ShapeProps
|
|
18
|
+
|
|
19
|
+
readonly shadows: ShadowsMap
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ThemeOverride extends Omit<Partial<Theme>> {
|
|
23
|
+
readonly breakpoints?: Theme['breakpoints']
|
|
24
|
+
|
|
25
|
+
readonly palette?: Partial<Record<Partial<Theme['palette']>>>
|
|
26
|
+
|
|
27
|
+
readonly typography?: TypographyProps
|
|
28
|
+
|
|
29
|
+
readonly shape?: ShapeProps
|
|
30
|
+
|
|
31
|
+
readonly shadows?: ShadowsMap
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type WithTheme<T = undefined> = With<T, { theme: DefaultTheme }>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMediaQuery(queryInput: string): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
export function useMediaQuery(queryInput) {
|
|
4
|
+
var query = queryInput.replace(/^@media( ?)/m, '');
|
|
5
|
+
var _useState = useState(function () {
|
|
6
|
+
return window.matchMedia(query).matches;
|
|
7
|
+
}),
|
|
8
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
9
|
+
match = _useState2[0],
|
|
10
|
+
setMatch = _useState2[1];
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
var active = true;
|
|
13
|
+
var queryList = window.matchMedia(query);
|
|
14
|
+
var updateMatch = function updateMatch() {
|
|
15
|
+
if (active) {
|
|
16
|
+
setMatch(queryList.matches);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
updateMatch();
|
|
20
|
+
queryList.addEventListener('change', updateMatch);
|
|
21
|
+
return function () {
|
|
22
|
+
active = false;
|
|
23
|
+
queryList.removeEventListener('change', updateMatch);
|
|
24
|
+
};
|
|
25
|
+
}, [query, matchMedia]);
|
|
26
|
+
return match;
|
|
27
|
+
}
|
package/theme/index.d.ts
ADDED
package/theme/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './theme-provider';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Values } from '../../../../utils/types'
|
|
2
|
+
import { Breakpoint, BreakpointClass } from '../../../../utils/types/css'
|
|
3
|
+
|
|
4
|
+
export type BreakpointsMap = Record<Values<typeof Breakpoint>, number>
|
|
5
|
+
|
|
6
|
+
export type Breakpoint = Values<typeof Breakpoint>
|
|
7
|
+
|
|
8
|
+
export type BreakpointClass = Values<typeof BreakpointClass>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Breakpoint, BreakpointClass } from './breakpoints-map'
|
|
2
|
+
|
|
3
|
+
export interface Breakpoints {
|
|
4
|
+
keys: Breakpoint[]
|
|
5
|
+
/**
|
|
6
|
+
* Each breakpoint (a key) matches with a fixed screen width (a value).
|
|
7
|
+
* @default {
|
|
8
|
+
* // extra-small
|
|
9
|
+
* xs: 0,
|
|
10
|
+
* // small
|
|
11
|
+
* sm: 600,
|
|
12
|
+
* // medium
|
|
13
|
+
* md: 900,
|
|
14
|
+
* // large
|
|
15
|
+
* lg: 1200,
|
|
16
|
+
* // extra-large
|
|
17
|
+
* xl: 1536,
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
values: { [key in Breakpoint]: number }
|
|
21
|
+
/**
|
|
22
|
+
* // extra-small
|
|
23
|
+
* xs: '.sfx-breakpoint-xs',
|
|
24
|
+
* // small
|
|
25
|
+
* sm:'.sfx-breakpoint-sm',
|
|
26
|
+
* // medium
|
|
27
|
+
* md:'.sfx-breakpoint-md',
|
|
28
|
+
* // large
|
|
29
|
+
* lg:'.sfx-breakpoint-lg',
|
|
30
|
+
* // extra-large
|
|
31
|
+
* xl: '.sfx-breakpoint-xl',
|
|
32
|
+
* // extra-extra-large
|
|
33
|
+
* xxl: '.sfx-breakpoint-xxl',
|
|
34
|
+
* // extra-extra-extra-large
|
|
35
|
+
* xxxl: '.sfx-breakpoint-xxxl',
|
|
36
|
+
* }
|
|
37
|
+
*/
|
|
38
|
+
classes: { [key in Breakpoint]: BreakpointClass }
|
|
39
|
+
/**
|
|
40
|
+
* @param width - A breakpoint width..
|
|
41
|
+
* @returns A breakpoint class ready to be used with styled components, it will be applied when it matches the nearest breakpoint intialized in the theme.
|
|
42
|
+
*/
|
|
43
|
+
getBreakpointClass: (width: number, hideSelector?: boolean) => BreakpointClass
|
|
44
|
+
/**
|
|
45
|
+
* @param width - A breakpoint width.
|
|
46
|
+
* @returns A media query string ready to be used with styled components, which matches screen width greater than the screen size given by the breakpoint key.
|
|
47
|
+
*/
|
|
48
|
+
up: (key: Breakpoint) => string
|
|
49
|
+
/**
|
|
50
|
+
* @param key - A breakpoint key (`xs`, `sm`, etc).
|
|
51
|
+
* @returns A media query string ready to be used with styled components, which matches screen width less than the screen size given by the breakpoint key.
|
|
52
|
+
*/
|
|
53
|
+
down: (key: Breakpoint) => string
|
|
54
|
+
/**
|
|
55
|
+
* @param start - A breakpoint key (`xs`, `sm`, etc).
|
|
56
|
+
* @param end - A breakpoint key (`xs`, `sm`, etc).
|
|
57
|
+
* @returns A media query string ready to be used with styled components, which matches screen width greater than the screen size given by the breakpoint key in the first argument and less than the screen size given by the breakpoint key in the second argument.
|
|
58
|
+
*/
|
|
59
|
+
between: (start: Breakpoint, end: Breakpoint) => string
|
|
60
|
+
/**
|
|
61
|
+
* @param key - A breakpoint key (`xs`, `sm`, etc).
|
|
62
|
+
* @returns A media query string ready to be used with styled components, which matches screen width starting from the screen size given by the breakpoint key and stopping at the screen size given by the next breakpoint key.
|
|
63
|
+
*/
|
|
64
|
+
only: (key: Breakpoint) => string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// export interface BreakpointsOptions extends Partial<Breakpoints> {
|
|
68
|
+
// /**
|
|
69
|
+
// * The unit used for the breakpoint's values.
|
|
70
|
+
// * @default 'px'
|
|
71
|
+
// */
|
|
72
|
+
// unit?: string | undefined;
|
|
73
|
+
// }
|