@askrjs/themes 0.0.2 → 0.0.4
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 +78 -0
- package/THEMING.md +50 -8
- package/dist/{_internal → components/_internal}/box-layout.js +4 -3
- package/dist/components/_internal/box-layout.js.map +1 -0
- package/dist/components/_internal/classes.js.map +1 -0
- package/dist/components/_internal/jsx.js.map +1 -0
- package/dist/components/_internal/layout.d.ts +6 -28
- package/dist/{_internal → components/_internal}/layout.js +5 -15
- package/dist/components/_internal/layout.js.map +1 -0
- package/dist/{_internal → components/_internal}/merge-props.js +5 -0
- package/dist/components/_internal/merge-props.js.map +1 -0
- package/dist/components/_internal/pathname.js +39 -0
- package/dist/components/_internal/pathname.js.map +1 -0
- package/dist/components/_internal/style.js +41 -0
- package/dist/components/_internal/style.js.map +1 -0
- package/dist/components/alert/alert.d.ts +7 -0
- package/dist/components/alert/alert.js +65 -0
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/alert/alert.types.d.ts +22 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/aspect-ratio/aspect-ratio.d.ts +8 -3
- package/dist/components/aspect-ratio/aspect-ratio.js +33 -0
- package/dist/components/aspect-ratio/aspect-ratio.js.map +1 -0
- package/dist/components/aspect-ratio/aspect-ratio.types.d.ts +18 -12
- package/dist/components/aspect-ratio/index.d.ts +2 -2
- package/dist/components/badge/badge.a11y.d.ts +13 -9
- package/dist/components/badge/badge.d.ts +8 -3
- package/dist/{badge → components/badge}/badge.js +5 -0
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/badge/badge.types.d.ts +18 -12
- package/dist/components/badge/index.d.ts +3 -3
- package/dist/components/block/block.a11y.d.ts +20 -0
- package/dist/components/block/block.d.ts +9 -0
- package/dist/components/block/block.js +66 -0
- package/dist/components/block/block.js.map +1 -0
- package/dist/components/block/block.types.d.ts +38 -0
- package/dist/components/block/index.d.ts +3 -0
- package/dist/components/box/box.a11y.d.ts +13 -9
- package/dist/components/box/box.d.ts +9 -4
- package/dist/{box → components/box}/box.js +3 -2
- package/dist/components/box/box.js.map +1 -0
- package/dist/components/box/box.types.d.ts +67 -61
- package/dist/components/box/index.d.ts +3 -3
- package/dist/components/breadcrumb/breadcrumb.a11y.d.ts +13 -9
- package/dist/components/breadcrumb/breadcrumb.a11y.js +15 -0
- package/dist/components/breadcrumb/breadcrumb.a11y.js.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +18 -13
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.types.d.ts +64 -58
- package/dist/components/breadcrumb/index.d.ts +3 -3
- package/dist/components/button-group/button-group.d.ts +7 -0
- package/dist/components/button-group/button-group.js +20 -0
- package/dist/components/button-group/button-group.js.map +1 -0
- package/dist/components/button-group/button-group.types.d.ts +14 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/card/card.d.ts +13 -7
- package/dist/components/card/card.js +95 -0
- package/dist/components/card/card.js.map +1 -0
- package/dist/components/card/card.types.d.ts +32 -24
- package/dist/components/card/index.d.ts +2 -2
- package/dist/components/close/close.d.ts +7 -0
- package/dist/components/close/close.js +22 -0
- package/dist/components/close/close.js.map +1 -0
- package/dist/components/close/close.types.d.ts +10 -0
- package/dist/components/close/index.d.ts +2 -0
- package/dist/components/container/container.a11y.d.ts +19 -15
- package/dist/components/container/container.d.ts +8 -3
- package/dist/{container → components/container}/container.js +3 -3
- package/dist/components/container/container.js.map +1 -0
- package/dist/components/container/container.types.d.ts +26 -26
- package/dist/components/container/index.d.ts +3 -3
- package/dist/components/empty-state/empty-state.d.ts +7 -2
- package/dist/components/empty-state/empty-state.js.map +1 -0
- package/dist/components/empty-state/empty-state.types.d.ts +15 -8
- package/dist/components/empty-state/index.d.ts +2 -2
- package/dist/components/field/field.d.ts +9 -0
- package/dist/components/field/field.js +41 -0
- package/dist/components/field/field.js.map +1 -0
- package/dist/components/field/field.types.d.ts +20 -0
- package/dist/components/field/index.d.ts +2 -0
- package/dist/components/flex/flex.a11y.d.ts +21 -17
- package/dist/components/flex/flex.d.ts +9 -4
- package/dist/{flex → components/flex}/flex.js +3 -2
- package/dist/components/flex/flex.js.map +1 -0
- package/dist/components/flex/flex.types.d.ts +38 -37
- package/dist/components/flex/index.d.ts +3 -3
- package/dist/components/header/header.a11y.d.ts +13 -9
- package/dist/components/header/header.a11y.js +12 -0
- package/dist/components/header/header.a11y.js.map +1 -0
- package/dist/components/header/header.d.ts +7 -2
- package/dist/components/header/header.js.map +1 -0
- package/dist/components/header/header.types.d.ts +8 -4
- package/dist/components/inline/index.d.ts +8 -6
- package/dist/components/inline/index.js.map +1 -0
- package/dist/components/input-group/index.d.ts +2 -0
- package/dist/components/input-group/input-group.d.ts +9 -0
- package/dist/components/input-group/input-group.js +39 -0
- package/dist/components/input-group/input-group.js.map +1 -0
- package/dist/components/input-group/input-group.types.d.ts +26 -0
- package/dist/components/list-group/index.d.ts +2 -0
- package/dist/components/list-group/list-group.d.ts +9 -0
- package/dist/components/list-group/list-group.js +43 -0
- package/dist/components/list-group/list-group.js.map +1 -0
- package/dist/components/list-group/list-group.types.d.ts +32 -0
- package/dist/components/nav/index.d.ts +2 -0
- package/dist/components/nav/nav.d.ts +13 -0
- package/dist/components/nav/nav.js +113 -0
- package/dist/components/nav/nav.js.map +1 -0
- package/dist/components/nav/nav.types.d.ts +56 -0
- package/dist/components/navbar/index.d.ts +5 -2
- package/dist/components/navbar/navbar-panel.js +48 -0
- package/dist/components/navbar/navbar-panel.js.map +1 -0
- package/dist/components/navbar/navbar.context.js +13 -0
- package/dist/components/navbar/navbar.context.js.map +1 -0
- package/dist/components/navbar/navbar.d.ts +45 -7
- package/dist/components/navbar/navbar.js +221 -0
- package/dist/components/navbar/navbar.js.map +1 -0
- package/dist/components/navbar/navbar.render.js +26 -0
- package/dist/components/navbar/navbar.render.js.map +1 -0
- package/dist/components/navbar/navbar.shared.js +18 -0
- package/dist/components/navbar/navbar.shared.js.map +1 -0
- package/dist/components/navbar/navbar.types.d.ts +29 -22
- package/dist/components/overlays/dropdown-content.d.ts +8 -0
- package/dist/components/overlays/dropdown-content.js +18 -0
- package/dist/components/overlays/dropdown-content.js.map +1 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/pagination.d.ts +11 -0
- package/dist/components/pagination/pagination.js +95 -0
- package/dist/components/pagination/pagination.js.map +1 -0
- package/dist/components/pagination/pagination.types.d.ts +40 -0
- package/dist/components/section/index.d.ts +3 -3
- package/dist/components/section/section.a11y.d.ts +14 -10
- package/dist/components/section/section.d.ts +8 -3
- package/dist/{section → components/section}/section.js +3 -2
- package/dist/components/section/section.js.map +1 -0
- package/dist/components/section/section.types.d.ts +20 -14
- package/dist/components/separator/index.d.ts +3 -3
- package/dist/components/separator/separator.a11y.d.ts +13 -9
- package/dist/components/separator/separator.a11y.js +15 -0
- package/dist/components/separator/separator.a11y.js.map +1 -0
- package/dist/components/separator/separator.d.ts +8 -3
- package/dist/components/separator/separator.js.map +1 -0
- package/dist/components/separator/separator.types.d.ts +19 -13
- package/dist/components/shell/index.d.ts +3 -0
- package/dist/components/shell/shell-nav.types.d.ts +7 -0
- package/dist/components/shell/shell-panel.js +54 -0
- package/dist/components/shell/shell-panel.js.map +1 -0
- package/dist/components/shell/shell-responsive.js +110 -0
- package/dist/components/shell/shell-responsive.js.map +1 -0
- package/dist/components/shell/shell.a11y.d.ts +23 -0
- package/dist/components/shell/shell.a11y.js +23 -0
- package/dist/components/shell/shell.a11y.js.map +1 -0
- package/dist/components/shell/shell.d.ts +13 -0
- package/dist/components/shell/shell.js +69 -0
- package/dist/components/shell/shell.js.map +1 -0
- package/dist/components/shell/shell.types.d.ts +58 -0
- package/dist/components/sidebar/sidebar-panel.d.ts +7 -0
- package/dist/components/sidebar/sidebar-panel.js +59 -0
- package/dist/components/sidebar/sidebar-panel.js.map +1 -0
- package/dist/components/sidebar/sidebar-toggle.d.ts +7 -0
- package/dist/components/sidebar/sidebar-toggle.js +8 -0
- package/dist/components/sidebar/sidebar-toggle.js.map +1 -0
- package/dist/components/sidebar/sidebar.context.js +21 -0
- package/dist/components/sidebar/sidebar.context.js.map +1 -0
- package/dist/components/sidebar/sidebar.d.ts +7 -0
- package/dist/components/sidebar/sidebar.js +228 -0
- package/dist/components/sidebar/sidebar.js.map +1 -0
- package/dist/components/sidebar/sidebar.shared.js +12 -0
- package/dist/components/sidebar/sidebar.shared.js.map +1 -0
- package/dist/components/sidebar/sidebar.types.d.ts +30 -0
- package/dist/components/skeleton/index.d.ts +3 -3
- package/dist/components/skeleton/skeleton.a11y.d.ts +12 -8
- package/dist/components/skeleton/skeleton.d.ts +8 -3
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/skeleton/skeleton.types.d.ts +16 -10
- package/dist/components/spacer/index.d.ts +3 -3
- package/dist/components/spacer/spacer.a11y.d.ts +16 -12
- package/dist/components/spacer/spacer.d.ts +8 -3
- package/dist/{spacer → components/spacer}/spacer.js +3 -1
- package/dist/components/spacer/spacer.js.map +1 -0
- package/dist/components/spacer/spacer.types.d.ts +23 -21
- package/dist/components/spinner/index.d.ts +2 -2
- package/dist/components/spinner/spinner.d.ts +7 -2
- package/dist/components/spinner/spinner.js.map +1 -0
- package/dist/components/spinner/spinner.types.d.ts +9 -4
- package/dist/components/stack/index.d.ts +3 -3
- package/dist/components/stack/stack.a11y.d.ts +17 -13
- package/dist/components/stack/stack.d.ts +8 -3
- package/dist/components/stack/stack.js.map +1 -0
- package/dist/components/stack/stack.types.d.ts +19 -13
- package/dist/components/theme/index.d.ts +1 -2
- package/dist/components/theme/theme.d.ts +41 -34
- package/dist/{theme → components/theme}/theme.js +33 -4
- package/dist/components/theme/theme.js.map +1 -0
- package/dist/controls.d.ts +10 -0
- package/dist/controls.js +7 -0
- package/dist/feedback.d.ts +5 -0
- package/dist/feedback.js +4 -0
- package/dist/layouts.d.ts +25 -0
- package/dist/layouts.js +11 -0
- package/dist/navs.d.ts +15 -0
- package/dist/navs.js +9 -0
- package/dist/overlays.d.ts +3 -0
- package/dist/overlays.js +4 -0
- package/dist/shells.d.ts +16 -0
- package/dist/shells.js +11 -0
- package/dist/surfaces.d.ts +16 -0
- package/dist/surfaces.js +9 -0
- package/dist/theme.d.ts +2 -0
- package/dist/theme.js +3 -0
- package/dist/themes/default/index.css +3132 -832
- package/package.json +65 -25
- package/src/components/_internal/box-layout.ts +8 -0
- package/src/components/_internal/jsx.ts +91 -16
- package/src/components/_internal/layout.ts +4 -17
- package/src/components/_internal/merge-props.ts +9 -0
- package/src/components/_internal/pathname.ts +67 -0
- package/src/components/_internal/style.ts +51 -0
- package/src/components/alert/alert.tsx +84 -0
- package/src/components/alert/alert.types.ts +20 -0
- package/src/components/alert/index.ts +2 -0
- package/src/components/aspect-ratio/aspect-ratio.tsx +10 -24
- package/src/components/aspect-ratio/aspect-ratio.types.ts +2 -1
- package/src/components/badge/badge.tsx +6 -0
- package/src/components/badge/badge.types.ts +2 -1
- package/src/components/block/block.a11y.ts +17 -0
- package/src/components/block/block.tsx +71 -0
- package/src/components/block/block.types.ts +60 -0
- package/src/components/block/index.ts +11 -0
- package/src/components/box/box.tsx +3 -2
- package/src/components/box/box.types.ts +2 -1
- package/src/components/breadcrumb/breadcrumb.types.ts +2 -1
- package/src/components/button-group/button-group.tsx +32 -0
- package/src/components/button-group/button-group.types.ts +12 -0
- package/src/components/button-group/index.ts +2 -0
- package/src/components/card/card.tsx +72 -43
- package/src/components/card/card.types.ts +6 -1
- package/src/components/card/index.ts +10 -1
- package/src/components/close/close.tsx +19 -0
- package/src/components/close/close.types.ts +7 -0
- package/src/components/close/index.ts +2 -0
- package/src/components/container/container.tsx +4 -4
- package/src/components/container/container.types.ts +2 -1
- package/src/components/empty-state/empty-state.types.ts +3 -0
- package/src/components/field/field.tsx +36 -0
- package/src/components/field/field.types.ts +19 -0
- package/src/components/field/index.ts +2 -0
- package/src/components/flex/flex.tsx +4 -2
- package/src/components/flex/flex.types.ts +2 -1
- package/src/components/input-group/index.ts +7 -0
- package/src/components/input-group/input-group.tsx +57 -0
- package/src/components/input-group/input-group.types.ts +26 -0
- package/src/components/list-group/index.ts +7 -0
- package/src/components/list-group/list-group.tsx +74 -0
- package/src/components/list-group/list-group.types.ts +32 -0
- package/src/components/nav/index.ts +14 -0
- package/src/components/nav/nav.tsx +203 -0
- package/src/components/nav/nav.types.ts +68 -0
- package/src/components/navbar/index.ts +9 -2
- package/src/components/navbar/navbar-panel.tsx +67 -0
- package/src/components/navbar/navbar.context.ts +22 -0
- package/src/components/navbar/navbar.render.tsx +32 -0
- package/src/components/navbar/navbar.shared.ts +21 -0
- package/src/components/navbar/navbar.tsx +262 -53
- package/src/components/navbar/navbar.types.ts +36 -22
- package/src/components/overlays/dropdown-content.tsx +28 -0
- package/src/components/pagination/index.ts +8 -0
- package/src/components/pagination/pagination.tsx +158 -0
- package/src/components/pagination/pagination.types.ts +41 -0
- package/src/components/section/section.tsx +3 -2
- package/src/components/section/section.types.ts +2 -1
- package/src/components/separator/separator.types.ts +2 -1
- package/src/components/shell/index.ts +16 -0
- package/src/components/shell/shell-nav.types.ts +3 -0
- package/src/components/shell/shell-panel.tsx +85 -0
- package/src/components/shell/shell-responsive.tsx +212 -0
- package/src/components/shell/shell.a11y.ts +20 -0
- package/src/components/shell/shell.tsx +74 -0
- package/src/components/shell/shell.types.ts +71 -0
- package/src/components/sidebar/index.ts +5 -0
- package/src/components/sidebar/sidebar-panel.tsx +76 -0
- package/src/components/sidebar/sidebar-toggle.tsx +5 -0
- package/src/components/sidebar/sidebar.context.ts +40 -0
- package/src/components/sidebar/sidebar.shared.ts +12 -0
- package/src/components/sidebar/sidebar.tsx +355 -0
- package/src/components/sidebar/sidebar.types.ts +35 -0
- package/src/components/skeleton/skeleton.types.ts +2 -1
- package/src/components/spacer/spacer.tsx +4 -1
- package/src/components/spacer/spacer.types.ts +3 -2
- package/src/components/stack/stack.types.ts +2 -1
- package/src/components/theme/index.ts +10 -1
- package/src/components/theme/theme.tsx +15 -4
- package/src/controls.ts +18 -0
- package/src/feedback.ts +6 -0
- package/src/layouts.ts +19 -0
- package/src/navs.ts +26 -0
- package/src/overlays.ts +90 -0
- package/src/shells.ts +13 -0
- package/src/surfaces.ts +23 -0
- package/src/theme.ts +21 -0
- package/src/themes/default/index.css +13 -3
- package/src/themes/default/styles/actions/button-group.css +74 -0
- package/src/themes/default/styles/actions/button.css +48 -8
- package/src/themes/default/styles/actions/toggle-group.css +19 -12
- package/src/themes/default/styles/actions/toggle.css +16 -10
- package/src/themes/default/styles/base/icon.css +2 -0
- package/src/themes/default/styles/base/reset.css +28 -0
- package/src/themes/default/styles/base/typography.css +37 -17
- package/src/themes/default/styles/base/utilities.css +56 -39
- package/src/themes/default/styles/disclosure/accordion.css +22 -14
- package/src/themes/default/styles/disclosure/collapsible.css +22 -11
- package/src/themes/default/styles/display/alert.css +109 -0
- package/src/themes/default/styles/display/avatar.css +9 -4
- package/src/themes/default/styles/display/badge.css +12 -3
- package/src/themes/default/styles/display/card.css +16 -4
- package/src/themes/default/styles/display/coverage.css +2 -14
- package/src/themes/default/styles/display/list-group.css +84 -0
- package/src/themes/default/styles/display/progress-circle.css +3 -2
- package/src/themes/default/styles/display/progress.css +8 -5
- package/src/themes/default/styles/display/scroll-area.css +15 -0
- package/src/themes/default/styles/display/separator.css +4 -4
- package/src/themes/default/styles/display/skeleton.css +25 -2
- package/src/themes/default/styles/display/spinner.css +1 -1
- package/src/themes/default/styles/display/table.css +7 -4
- package/src/themes/default/styles/display/virtual-list.css +29 -0
- package/src/themes/default/styles/display/virtual-table.css +68 -0
- package/src/themes/default/styles/forms/checkbox.css +2 -1
- package/src/themes/default/styles/forms/field.css +22 -0
- package/src/themes/default/styles/forms/form.css +1 -1
- package/src/themes/default/styles/forms/input-group.css +202 -0
- package/src/themes/default/styles/forms/input.css +22 -6
- package/src/themes/default/styles/forms/label.css +2 -0
- package/src/themes/default/styles/forms/radio-group.css +22 -13
- package/src/themes/default/styles/forms/select.css +71 -26
- package/src/themes/default/styles/forms/slider.css +32 -16
- package/src/themes/default/styles/forms/switch.css +2 -1
- package/src/themes/default/styles/forms/textarea.css +35 -6
- package/src/themes/default/styles/layout/aspect-ratio.css +3 -1
- package/src/themes/default/styles/layout/block.css +23 -0
- package/src/themes/default/styles/layout/patterns.css +155 -3
- package/src/themes/default/styles/layout/responsive-layout.css +140 -121
- package/src/themes/default/styles/navigation/breadcrumb.css +7 -1
- package/src/themes/default/styles/navigation/menu.css +150 -7
- package/src/themes/default/styles/navigation/menubar.css +194 -28
- package/src/themes/default/styles/navigation/nav.css +231 -0
- package/src/themes/default/styles/navigation/pagination.css +91 -0
- package/src/themes/default/styles/overlays/alert-dialog.css +1 -1
- package/src/themes/default/styles/overlays/dialog.css +42 -10
- package/src/themes/default/styles/overlays/dropdown.css +160 -0
- package/src/themes/default/styles/overlays/hover-card.css +28 -3
- package/src/themes/default/styles/overlays/popover.css +50 -6
- package/src/themes/default/styles/overlays/toast.css +66 -17
- package/src/themes/default/styles/overlays/tooltip.css +45 -18
- package/src/themes/default/styles/shell/header.css +18 -3
- package/src/themes/default/styles/shell/navbar.css +434 -73
- package/src/themes/default/styles/shell/sidebar.css +809 -0
- package/src/themes/default/styles/shell/theme.css +7 -5
- package/src/themes/default/tokens.css +186 -123
- package/src/themes/presets/calico.css +46 -0
- package/src/themes/presets/ginger.css +46 -0
- package/src/themes/presets/index.css +5 -0
- package/src/themes/presets/tabby.css +46 -0
- package/src/themes/presets/torty.css +49 -0
- package/src/themes/presets/tuxedo.css +49 -0
- package/templates/theme/index.css +14 -4
- package/templates/theme/styles/actions/button-group.css +74 -0
- package/templates/theme/styles/actions/button.css +48 -8
- package/templates/theme/styles/actions/toggle-group.css +19 -12
- package/templates/theme/styles/actions/toggle.css +16 -10
- package/templates/theme/styles/base/icon.css +2 -0
- package/templates/theme/styles/base/reset.css +28 -0
- package/templates/theme/styles/base/typography.css +37 -17
- package/templates/theme/styles/disclosure/accordion.css +22 -14
- package/templates/theme/styles/disclosure/collapsible.css +22 -11
- package/templates/theme/styles/display/alert.css +109 -0
- package/templates/theme/styles/display/avatar.css +9 -4
- package/templates/theme/styles/display/badge.css +12 -3
- package/templates/theme/styles/display/card.css +16 -4
- package/templates/theme/styles/display/coverage.css +105 -15
- package/templates/theme/styles/display/list-group.css +84 -0
- package/templates/theme/styles/display/progress-circle.css +3 -2
- package/templates/theme/styles/display/progress.css +8 -5
- package/templates/theme/styles/display/scroll-area.css +15 -0
- package/templates/theme/styles/display/separator.css +4 -4
- package/templates/theme/styles/display/skeleton.css +25 -2
- package/templates/theme/styles/display/spinner.css +1 -1
- package/templates/theme/styles/display/table.css +7 -4
- package/templates/theme/styles/display/virtual-list.css +29 -0
- package/templates/theme/styles/display/virtual-table.css +68 -0
- package/templates/theme/styles/forms/checkbox.css +2 -1
- package/templates/theme/styles/forms/field.css +22 -0
- package/templates/theme/styles/forms/form.css +1 -1
- package/templates/theme/styles/forms/input-group.css +202 -0
- package/templates/theme/styles/forms/input.css +22 -6
- package/templates/theme/styles/forms/label.css +2 -0
- package/templates/theme/styles/forms/radio-group.css +22 -13
- package/templates/theme/styles/forms/select.css +71 -26
- package/templates/theme/styles/forms/slider.css +32 -16
- package/templates/theme/styles/forms/switch.css +2 -1
- package/templates/theme/styles/forms/textarea.css +35 -6
- package/templates/theme/styles/layout/aspect-ratio.css +3 -1
- package/templates/theme/styles/layout/block.css +23 -0
- package/templates/theme/styles/layout/patterns.css +155 -3
- package/templates/theme/styles/layout/responsive-layout.css +140 -121
- package/templates/theme/styles/navigation/breadcrumb.css +22 -8
- package/templates/theme/styles/navigation/menu.css +150 -7
- package/templates/theme/styles/navigation/menubar.css +194 -28
- package/templates/theme/styles/navigation/nav.css +231 -0
- package/templates/theme/styles/navigation/pagination.css +91 -0
- package/templates/theme/styles/overlays/alert-dialog.css +1 -1
- package/templates/theme/styles/overlays/dialog.css +42 -10
- package/templates/theme/styles/overlays/dropdown.css +160 -0
- package/templates/theme/styles/overlays/hover-card.css +28 -3
- package/templates/theme/styles/overlays/popover.css +50 -6
- package/templates/theme/styles/overlays/toast.css +66 -17
- package/templates/theme/styles/overlays/tooltip.css +45 -18
- package/templates/theme/styles/shell/header.css +18 -3
- package/templates/theme/styles/shell/navbar.css +434 -73
- package/templates/theme/styles/shell/sidebar.css +809 -0
- package/templates/theme/styles/shell/theme.css +7 -5
- package/templates/theme/tokens.css +186 -123
- package/dist/_internal/box-layout.js.map +0 -1
- package/dist/_internal/classes.js.map +0 -1
- package/dist/_internal/jsx.js.map +0 -1
- package/dist/_internal/layout.d.ts +0 -9
- package/dist/_internal/layout.js.map +0 -1
- package/dist/_internal/merge-props.js.map +0 -1
- package/dist/accessible-icon/accessible-icon.d.ts +0 -7
- package/dist/accessible-icon/accessible-icon.js +0 -20
- package/dist/accessible-icon/accessible-icon.js.map +0 -1
- package/dist/accessible-icon/accessible-icon.types.d.ts +0 -9
- package/dist/aspect-ratio/aspect-ratio.d.ts +0 -8
- package/dist/aspect-ratio/aspect-ratio.js +0 -36
- package/dist/aspect-ratio/aspect-ratio.js.map +0 -1
- package/dist/aspect-ratio/aspect-ratio.types.d.ts +0 -20
- package/dist/aspect-ratio/index.d.ts +0 -2
- package/dist/badge/badge.d.ts +0 -8
- package/dist/badge/badge.js.map +0 -1
- package/dist/badge/badge.types.d.ts +0 -20
- package/dist/badge/index.d.ts +0 -2
- package/dist/box/box.d.ts +0 -9
- package/dist/box/box.js.map +0 -1
- package/dist/box/box.types.d.ts +0 -71
- package/dist/box/index.d.ts +0 -2
- package/dist/breadcrumb/breadcrumb.d.ts +0 -18
- package/dist/breadcrumb/breadcrumb.js.map +0 -1
- package/dist/breadcrumb/breadcrumb.types.d.ts +0 -64
- package/dist/breadcrumb/index.d.ts +0 -2
- package/dist/card/card.d.ts +0 -12
- package/dist/card/card.js +0 -68
- package/dist/card/card.js.map +0 -1
- package/dist/card/card.types.d.ts +0 -37
- package/dist/card/index.d.ts +0 -2
- package/dist/components/_internal/box-layout.d.ts +0 -7
- package/dist/components/_internal/classes.d.ts +0 -1
- package/dist/components/_internal/jsx.d.ts +0 -8
- package/dist/components/_internal/merge-props.d.ts +0 -1
- package/dist/components/_internal/style.d.ts +0 -1
- package/dist/components/accessible-icon/accessible-icon.d.ts +0 -2
- package/dist/components/accessible-icon/accessible-icon.types.d.ts +0 -5
- package/dist/components/accessible-icon/index.d.ts +0 -2
- package/dist/components/grid/grid.a11y.d.ts +0 -21
- package/dist/components/grid/grid.d.ts +0 -4
- package/dist/components/grid/grid.types.d.ts +0 -37
- package/dist/components/grid/index.d.ts +0 -3
- package/dist/components/header/index.d.ts +0 -3
- package/dist/components/index.d.ts +0 -49
- package/dist/components/index.js +0 -28
- package/dist/components/logos/create-logo.d.ts +0 -5
- package/dist/components/logos/github-logo.d.ts +0 -4
- package/dist/components/logos/google-logo.d.ts +0 -4
- package/dist/components/logos/index.d.ts +0 -5
- package/dist/components/logos/microsoft-logo.d.ts +0 -4
- package/dist/components/logos/types.d.ts +0 -14
- package/dist/components/sidebar-layout/index.d.ts +0 -3
- package/dist/components/sidebar-layout/sidebar-layout.a11y.d.ts +0 -15
- package/dist/components/sidebar-layout/sidebar-layout.d.ts +0 -2
- package/dist/components/sidebar-layout/sidebar-layout.types.d.ts +0 -20
- package/dist/components/topbar-layout/index.d.ts +0 -3
- package/dist/components/topbar-layout/topbar-layout.a11y.d.ts +0 -13
- package/dist/components/topbar-layout/topbar-layout.d.ts +0 -2
- package/dist/components/topbar-layout/topbar-layout.types.d.ts +0 -12
- package/dist/container/container.d.ts +0 -8
- package/dist/container/container.js.map +0 -1
- package/dist/container/container.types.d.ts +0 -28
- package/dist/container/index.d.ts +0 -2
- package/dist/empty-state/empty-state.d.ts +0 -7
- package/dist/empty-state/empty-state.js.map +0 -1
- package/dist/empty-state/empty-state.types.d.ts +0 -13
- package/dist/flex/flex.d.ts +0 -9
- package/dist/flex/flex.js.map +0 -1
- package/dist/flex/flex.types.d.ts +0 -41
- package/dist/flex/index.d.ts +0 -2
- package/dist/grid/grid.d.ts +0 -9
- package/dist/grid/grid.js +0 -115
- package/dist/grid/grid.js.map +0 -1
- package/dist/grid/grid.types.d.ts +0 -40
- package/dist/grid/index.d.ts +0 -2
- package/dist/header/header.d.ts +0 -7
- package/dist/header/header.js.map +0 -1
- package/dist/header/header.types.d.ts +0 -9
- package/dist/inline/index.d.ts +0 -7
- package/dist/inline/index.js.map +0 -1
- package/dist/logos/create-logo.d.ts +0 -1
- package/dist/logos/create-logo.js +0 -75
- package/dist/logos/create-logo.js.map +0 -1
- package/dist/logos/github-logo.d.ts +0 -18
- package/dist/logos/github-logo.js +0 -9
- package/dist/logos/github-logo.js.map +0 -1
- package/dist/logos/google-logo.d.ts +0 -18
- package/dist/logos/google-logo.js +0 -23
- package/dist/logos/google-logo.js.map +0 -1
- package/dist/logos/index.d.ts +0 -4
- package/dist/logos/microsoft-logo.d.ts +0 -18
- package/dist/logos/microsoft-logo.js +0 -35
- package/dist/logos/microsoft-logo.js.map +0 -1
- package/dist/logos/types.d.ts +0 -16
- package/dist/navbar/index.d.ts +0 -2
- package/dist/navbar/navbar.d.ts +0 -12
- package/dist/navbar/navbar.js +0 -73
- package/dist/navbar/navbar.js.map +0 -1
- package/dist/navbar/navbar.types.d.ts +0 -31
- package/dist/section/index.d.ts +0 -2
- package/dist/section/section.d.ts +0 -8
- package/dist/section/section.js.map +0 -1
- package/dist/section/section.types.d.ts +0 -22
- package/dist/separator/index.d.ts +0 -2
- package/dist/separator/separator.d.ts +0 -8
- package/dist/separator/separator.js.map +0 -1
- package/dist/separator/separator.types.d.ts +0 -21
- package/dist/sidebar-layout/index.d.ts +0 -2
- package/dist/sidebar-layout/sidebar-layout.d.ts +0 -7
- package/dist/sidebar-layout/sidebar-layout.js +0 -51
- package/dist/sidebar-layout/sidebar-layout.js.map +0 -1
- package/dist/sidebar-layout/sidebar-layout.types.d.ts +0 -20
- package/dist/skeleton/index.d.ts +0 -2
- package/dist/skeleton/skeleton.d.ts +0 -8
- package/dist/skeleton/skeleton.js.map +0 -1
- package/dist/skeleton/skeleton.types.d.ts +0 -18
- package/dist/spacer/index.d.ts +0 -2
- package/dist/spacer/spacer.d.ts +0 -8
- package/dist/spacer/spacer.js.map +0 -1
- package/dist/spacer/spacer.types.d.ts +0 -25
- package/dist/spinner/index.d.ts +0 -2
- package/dist/spinner/spinner.d.ts +0 -7
- package/dist/spinner/spinner.js.map +0 -1
- package/dist/spinner/spinner.types.d.ts +0 -10
- package/dist/stack/index.d.ts +0 -2
- package/dist/stack/stack.d.ts +0 -8
- package/dist/stack/stack.js.map +0 -1
- package/dist/stack/stack.types.d.ts +0 -21
- package/dist/theme/index.d.ts +0 -1
- package/dist/theme/theme.d.ts +0 -44
- package/dist/theme/theme.js.map +0 -1
- package/dist/topbar-layout/index.d.ts +0 -2
- package/dist/topbar-layout/topbar-layout.d.ts +0 -7
- package/dist/topbar-layout/topbar-layout.js +0 -37
- package/dist/topbar-layout/topbar-layout.js.map +0 -1
- package/dist/topbar-layout/topbar-layout.types.d.ts +0 -13
- package/src/askr-compat.d.ts +0 -110
- package/src/askr-router.d.ts +0 -16
- package/src/components/accessible-icon/accessible-icon.tsx +0 -18
- package/src/components/accessible-icon/accessible-icon.types.ts +0 -5
- package/src/components/accessible-icon/index.ts +0 -2
- package/src/components/grid/grid.a11y.ts +0 -22
- package/src/components/grid/grid.tsx +0 -172
- package/src/components/grid/grid.types.ts +0 -45
- package/src/components/grid/index.ts +0 -10
- package/src/components/index.ts +0 -108
- package/src/components/logos/create-logo.tsx +0 -103
- package/src/components/logos/github-logo.tsx +0 -13
- package/src/components/logos/google-logo.tsx +0 -34
- package/src/components/logos/index.ts +0 -5
- package/src/components/logos/microsoft-logo.tsx +0 -10
- package/src/components/logos/types.ts +0 -24
- package/src/components/sidebar-layout/index.ts +0 -6
- package/src/components/sidebar-layout/sidebar-layout.a11y.ts +0 -16
- package/src/components/sidebar-layout/sidebar-layout.tsx +0 -59
- package/src/components/sidebar-layout/sidebar-layout.types.ts +0 -22
- package/src/components/topbar-layout/index.ts +0 -3
- package/src/components/topbar-layout/topbar-layout.a11y.ts +0 -14
- package/src/components/topbar-layout/topbar-layout.tsx +0 -39
- package/src/components/topbar-layout/topbar-layout.types.ts +0 -13
- package/src/themes/default/styles/layout/dashboard-layout.css +0 -15
- package/src/themes/default/styles/layout/docs-layout.css +0 -10
- package/src/themes/default/styles/layout/sidebar.css +0 -10
- package/src/themes/default/styles/navigation/navigation-menu.css +0 -90
- package/src/themes/default/styles/navigation/tabs.css +0 -61
- package/src/themes/default/styles/overlays/dropdown-menu.css +0 -109
- package/templates/theme/styles/layout/dashboard-layout.css +0 -16
- package/templates/theme/styles/layout/docs-layout.css +0 -11
- package/templates/theme/styles/layout/sidebar.css +0 -11
- package/templates/theme/styles/navigation/navigation-menu.css +0 -90
- package/templates/theme/styles/navigation/tabs.css +0 -61
- package/templates/theme/styles/overlays/dropdown-menu.css +0 -109
- /package/dist/{_internal → components/_internal}/classes.js +0 -0
- /package/dist/{_internal → components/_internal}/jsx.js +0 -0
- /package/dist/{breadcrumb → components/breadcrumb}/breadcrumb.js +0 -0
- /package/dist/{empty-state → components/empty-state}/empty-state.js +0 -0
- /package/dist/{header → components/header}/header.js +0 -0
- /package/dist/{inline → components/inline}/index.js +0 -0
- /package/dist/{separator → components/separator}/separator.js +0 -0
- /package/dist/{skeleton → components/skeleton}/skeleton.js +0 -0
- /package/dist/{spinner → components/spinner}/spinner.js +0 -0
- /package/dist/{stack → components/stack}/stack.js +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @askrjs/themes
|
|
2
|
+
|
|
3
|
+
CSS tokens, shell chrome, and styled composition helpers for Askr apps.
|
|
4
|
+
|
|
5
|
+
`@askrjs/themes` is the visual companion to `@askrjs/ui` and
|
|
6
|
+
`@askrjs/charts`. It owns the default theme, shared layout wrappers, and
|
|
7
|
+
theme-aware component styling while behavior and data contracts stay in the
|
|
8
|
+
other packages.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @askrjs/themes @askrjs/ui
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
Import the default theme CSS in your app stylesheet:
|
|
19
|
+
|
|
20
|
+
```css
|
|
21
|
+
@import "@askrjs/themes/default";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Add the optional cat preset layer after the default theme when you want the
|
|
25
|
+
curated preset family:
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
@import "@askrjs/themes/default";
|
|
29
|
+
@import "@askrjs/themes/presets";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then set `data-theme` to `tabby`, `ginger`, `tuxedo`, `calico`, or `torty`.
|
|
33
|
+
For picker/toggle composition, import `CAT_THEME_OPTIONS` and `CAT_THEME_NAMES`
|
|
34
|
+
from `@askrjs/themes/theme`.
|
|
35
|
+
|
|
36
|
+
Then use the theme helpers and curated component surfaces:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { ThemeProvider, ThemeToggle } from "@askrjs/themes/theme";
|
|
40
|
+
import { Button, ButtonGroup, Field, InputGroup } from "@askrjs/themes/controls";
|
|
41
|
+
|
|
42
|
+
export function AppShell() {
|
|
43
|
+
return (
|
|
44
|
+
<ThemeProvider>
|
|
45
|
+
<ButtonGroup>
|
|
46
|
+
<Button variant="primary">Save</Button>
|
|
47
|
+
<ThemeToggle>{({ nextTheme }) => nextTheme}</ThemeToggle>
|
|
48
|
+
</ButtonGroup>
|
|
49
|
+
|
|
50
|
+
<Field>
|
|
51
|
+
<InputGroup>
|
|
52
|
+
<input />
|
|
53
|
+
</InputGroup>
|
|
54
|
+
</Field>
|
|
55
|
+
</ThemeProvider>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## What To Import
|
|
61
|
+
|
|
62
|
+
- `@askrjs/themes/theme` for `ThemeProvider`, `ThemePicker`, `ThemeToggle`,
|
|
63
|
+
and `useTheme`
|
|
64
|
+
- `@askrjs/themes/controls` for theme-styled controls such as `Button`,
|
|
65
|
+
`ButtonGroup`, `Close`, `Field`, and `InputGroup`
|
|
66
|
+
- `@askrjs/themes/layouts`, `@askrjs/themes/shells`, `@askrjs/themes/navs`,
|
|
67
|
+
`@askrjs/themes/surfaces`, `@askrjs/themes/feedback`, and
|
|
68
|
+
`@askrjs/themes/overlays` for the curated visual composition surfaces
|
|
69
|
+
|
|
70
|
+
## Theme Contract
|
|
71
|
+
|
|
72
|
+
- Style public `data-*` hooks and token variables, not internal DOM structure.
|
|
73
|
+
- Prefer token overrides before component overrides.
|
|
74
|
+
- Keep selectors low specificity so downstream apps can customize them cleanly.
|
|
75
|
+
- Use [THEMING.md](./THEMING.md) and [docs/architecture.md](./docs/architecture.md)
|
|
76
|
+
for the full contract and package boundaries.
|
|
77
|
+
|
|
78
|
+
- Use `visual-check.html` for manual QA across light and dark modes.
|
package/THEMING.md
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
`@askrjs/charts`. It owns the app frame and shared visual language, while chart
|
|
5
5
|
rendering stays in the chart package.
|
|
6
6
|
|
|
7
|
+
See [docs/architecture.md](./docs/architecture.md) for the package boundary
|
|
8
|
+
between `@askrjs/askr`, `@askrjs/ui`, and `@askrjs/themes`.
|
|
9
|
+
|
|
7
10
|
Import a theme:
|
|
8
11
|
|
|
9
12
|
```css
|
|
@@ -45,6 +48,38 @@ Icon override:
|
|
|
45
48
|
|
|
46
49
|
Rules: style only public data-\* hooks, never internal DOM, no deep selectors, no !important.
|
|
47
50
|
|
|
51
|
+
## Visual Quality Standard
|
|
52
|
+
|
|
53
|
+
The default theme is optimized for quiet SaaS products: dense enough for repeated daily use,
|
|
54
|
+
restrained enough for application chrome, and polished enough that downstream apps should not
|
|
55
|
+
need to fix basic spacing or type rhythm.
|
|
56
|
+
|
|
57
|
+
Use `visual-check.html` as the manual audit surface before shipping theme changes. Review every
|
|
58
|
+
component family in light and dark mode at desktop, tablet, and mobile widths.
|
|
59
|
+
Use `320`, `390`, `768`, `1024`, and desktop widths as the standard responsive
|
|
60
|
+
manual pass.
|
|
61
|
+
|
|
62
|
+
Manual acceptance criteria:
|
|
63
|
+
|
|
64
|
+
- No clipped text, awkward wrapping, accidental overflow, collapsed gaps, or misaligned icons.
|
|
65
|
+
- Interactive controls share height, padding, radius, typography, and focus treatment.
|
|
66
|
+
- Headings and body text use deliberate hierarchy, readable line lengths, and calm letter spacing.
|
|
67
|
+
- Dark mode has equal polish and contrast, not just inverted colors.
|
|
68
|
+
- Dense SaaS compositions scan cleanly without feeling cramped.
|
|
69
|
+
- Overlays, menus, and popups use the shared elevated surface language.
|
|
70
|
+
- Long labels and realistic enterprise copy remain legible without breaking layout.
|
|
71
|
+
|
|
72
|
+
## Template Sync
|
|
73
|
+
|
|
74
|
+
- When changing `src/themes/default/styles/**`, update the matching
|
|
75
|
+
`templates/theme/styles/**` file in the same change unless a test documents
|
|
76
|
+
an intentional template difference.
|
|
77
|
+
- Keep generated theme templates visually aligned with the default theme so
|
|
78
|
+
scaffolded themes inherit the same density, spacing, typography, and
|
|
79
|
+
responsive behavior.
|
|
80
|
+
- `visual-check.html` is the primary manual audit surface; browser tests should
|
|
81
|
+
assert stable computed-style contracts and no page-level overflow.
|
|
82
|
+
|
|
48
83
|
Selector contract:
|
|
49
84
|
|
|
50
85
|
- Tokens keep the `--ak-*` prefix because they are global.
|
|
@@ -53,6 +88,7 @@ Selector contract:
|
|
|
53
88
|
- Alias selectors must be grouped with canonical selectors in the same low-specificity rule. Classes are convenience API, not a replacement source of truth.
|
|
54
89
|
- Theme-owned pattern components use plain kebab-case classes such as `.page-header`, and public pattern parts should emit matching `data-slot` hooks so the same grouped selector pattern applies there as well.
|
|
55
90
|
- Semantic `askr-ui` table primitives are styled from `styles/display/table.css` using their `data-slot` hooks only; keep the surface semantic and avoid restoring data-grid behavior in themes.
|
|
91
|
+
- `Button` comes from `@askrjs/ui`; `@askrjs/themes` re-exports and styles it. `ButtonGroup`, `Close`, `Field`, and `InputGroup` stay in themes because they are visual composition wrappers.
|
|
56
92
|
|
|
57
93
|
Example:
|
|
58
94
|
|
|
@@ -73,24 +109,30 @@ Package boundaries:
|
|
|
73
109
|
- `@askrjs/themes` owns visual-only components, layout composition, and
|
|
74
110
|
default styling.
|
|
75
111
|
|
|
76
|
-
Use
|
|
77
|
-
|
|
78
|
-
|
|
112
|
+
Use the curated theme entrypoints such as `@askrjs/themes/controls`,
|
|
113
|
+
`@askrjs/themes/surfaces`, `@askrjs/themes/navs`, and `@askrjs/themes/shells`
|
|
114
|
+
for styled components such as Button, ButtonGroup, Close, InputGroup, Alert,
|
|
115
|
+
Badge, Box, Block, ListGroup, Pagination, Skeleton, Separator/Divider, Shell,
|
|
116
|
+
ShellNav, ShellMain, and EmptyState.
|
|
79
117
|
|
|
80
118
|
Theme state helpers also live there: `ThemeProvider`, `ThemePicker`,
|
|
81
119
|
`ThemeToggle`, and `useTheme`. `ThemeToggle` intentionally has no built-in
|
|
82
120
|
icons; applications pass their own icon/content props.
|
|
121
|
+
The common wrapper components also emit familiar alias classes such as
|
|
122
|
+
`alert`, `btn-group`, `btn-close`, `input-group`, `list-group`, and
|
|
123
|
+
`pagination` so app-level CSS can stay close to the Bootstrap mental model
|
|
124
|
+
without giving up the canonical `data-slot` contract.
|
|
83
125
|
|
|
84
126
|
Responsive rules:
|
|
85
127
|
|
|
86
128
|
- Build mobile first. Base selectors must work on narrow screens; larger layouts are additive via `min-width` media queries.
|
|
87
129
|
- The default theme uses semantic breakpoints `sm`, `md`, `lg`, and `xl` for `data-collapse-below`.
|
|
88
130
|
- Keep breakpoint values centralized in theme tokens so the default theme and generated themes stay aligned.
|
|
89
|
-
- Responsive behavior must target only public hooks such as `data-collapse-below`, `data-columns`, `data-min-item-width`, `data-gap`, `data-
|
|
131
|
+
- Responsive behavior must target only public hooks such as `data-collapse-below`, `data-columns`, `data-min-item-width`, `data-gap`, `data-size`, and `data-variant`.
|
|
90
132
|
- Prefer token overrides first. Reach for component CSS overrides only when tokens are insufficient.
|
|
91
133
|
- Keep selectors low-specificity so a custom theme can override a rule with one equally specific selector. `:where(...)` is preferred for the default theme baseline.
|
|
92
|
-
- Broad layout slots like `main`, `sidebar`, and `navbar` must always be anchored to a public layout root such as `
|
|
93
|
-
- Named layout hooks such as `data-size`, `data-max-width`, `data-padding`,
|
|
134
|
+
- Broad layout slots like `main`, `sidebar`, and `navbar` must always be anchored to a public layout root such as `shell`.
|
|
135
|
+
- Named layout hooks such as `data-size`, `data-max-width`, `data-padding`, and `data-gap` are part of the public theme contract and should resolve through theme tokens rather than hard-coded values.
|
|
94
136
|
- Icons are part of the public theme contract. `@askrjs/ui` owns the canonical icon hooks, and official icon wrappers should implement that contract by emitting `data-slot="icon"`, `data-icon`, semantic `data-size`, and `data-decorative` so themes can style them uniformly across icon sets.
|
|
95
137
|
- Icon size and stroke defaults should resolve through the shared icon tokens: `--ak-icon-size-sm|md|lg|xl` and `--ak-icon-stroke-width-sm|md|lg|xl`.
|
|
96
138
|
- Product SaaS scaffolds should compose broad visual primitives first. Keep first-class pattern exports general; put narrow dashboard, auth, or table-page recipes in docs/examples unless they prove reusable across apps. Recipe shells such as product-style or marketing-style page wrappers belong in userland composition, not the shipped theme package.
|
|
@@ -563,7 +605,7 @@ Generic interaction overlays for neutral interactive surfaces.
|
|
|
563
605
|
|
|
564
606
|
### Selected
|
|
565
607
|
|
|
566
|
-
Selection state for
|
|
608
|
+
Selection state for nav items, rows, or toggles.
|
|
567
609
|
|
|
568
610
|
### Disabled
|
|
569
611
|
|
|
@@ -925,7 +967,7 @@ All official themes are tested for WCAG AA compliance:
|
|
|
925
967
|
- Status ink on soft backgrounds: 3:1 minimum
|
|
926
968
|
- Inverse text on primary: 4.5:1 minimum
|
|
927
969
|
|
|
928
|
-
The automated test suite (`tests/contrast.test.ts`) validates these pairs across all themes in both light and dark modes.
|
|
970
|
+
The automated test suite (`tests/unit/contrast.test.ts`) validates these pairs across all themes in both light and dark modes.
|
|
929
971
|
|
|
930
972
|
---
|
|
931
973
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mergeLayoutStyles, resolveSpaceValue, setResponsiveStyleVar } from "./layout.js";
|
|
2
|
+
import { styleDeclarationsToClass } from "./style.js";
|
|
2
3
|
//#region src/components/_internal/box-layout.ts
|
|
3
4
|
const SPACE_PROP_KEYS = new Set([
|
|
4
5
|
"m",
|
|
@@ -106,10 +107,10 @@ function applyBoxLayoutStyles(styles, boxProps) {
|
|
|
106
107
|
setResponsiveStyleVar(styles, variable, value, (input) => input);
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
-
return mergeLayoutStyles(styles, userStyle);
|
|
110
|
+
function withBoxLayoutClass(styles, userStyle) {
|
|
111
|
+
return styleDeclarationsToClass(mergeLayoutStyles(styles, userStyle));
|
|
111
112
|
}
|
|
112
113
|
//#endregion
|
|
113
|
-
export { applyBoxLayoutStyles, splitBoxLayoutProps,
|
|
114
|
+
export { applyBoxLayoutStyles, splitBoxLayoutProps, withBoxLayoutClass };
|
|
114
115
|
|
|
115
116
|
//# sourceMappingURL=box-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box-layout.js","names":[],"sources":["../../../src/components/_internal/box-layout.ts"],"sourcesContent":["import { mergeLayoutStyles, resolveSpaceValue, setResponsiveStyleVar } from \"./layout\";\nimport { styleDeclarationsToClass } from \"./style\";\nimport type { BoxLayoutOwnProps } from \"../box/box.types\";\n\nconst SPACE_PROP_KEYS = new Set([\n \"m\",\n \"mx\",\n \"my\",\n \"mt\",\n \"mr\",\n \"mb\",\n \"ml\",\n \"p\",\n \"px\",\n \"py\",\n \"pt\",\n \"pr\",\n \"pb\",\n \"pl\",\n \"inset\",\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n]);\n\nconst BOX_PROP_KEYS = new Set<keyof BoxLayoutOwnProps>([\n \"display\",\n \"m\",\n \"mx\",\n \"my\",\n \"mt\",\n \"mr\",\n \"mb\",\n \"ml\",\n \"p\",\n \"px\",\n \"py\",\n \"pt\",\n \"pr\",\n \"pb\",\n \"pl\",\n \"width\",\n \"minWidth\",\n \"maxWidth\",\n \"height\",\n \"minHeight\",\n \"maxHeight\",\n \"position\",\n \"inset\",\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n \"overflow\",\n \"overflowX\",\n \"overflowY\",\n \"flexBasis\",\n \"flexGrow\",\n \"flexShrink\",\n \"gridArea\",\n \"gridColumn\",\n \"gridColumnStart\",\n \"gridColumnEnd\",\n \"gridRow\",\n \"gridRowStart\",\n \"gridRowEnd\",\n]);\n\nfunction variableNameForProp(prop: keyof BoxLayoutOwnProps): string {\n switch (prop) {\n case \"overflowX\":\n return \"overflow-x\";\n case \"overflowY\":\n return \"overflow-y\";\n case \"minWidth\":\n return \"min-width\";\n case \"maxWidth\":\n return \"max-width\";\n case \"minHeight\":\n return \"min-height\";\n case \"maxHeight\":\n return \"max-height\";\n case \"flexBasis\":\n return \"flex-basis\";\n case \"flexGrow\":\n return \"flex-grow\";\n case \"flexShrink\":\n return \"flex-shrink\";\n case \"gridArea\":\n return \"grid-area\";\n case \"gridColumn\":\n return \"grid-column\";\n case \"gridColumnStart\":\n return \"grid-column-start\";\n case \"gridColumnEnd\":\n return \"grid-column-end\";\n case \"gridRow\":\n return \"grid-row\";\n case \"gridRowStart\":\n return \"grid-row-start\";\n case \"gridRowEnd\":\n return \"grid-row-end\";\n default:\n return prop;\n }\n}\n\nexport function splitBoxLayoutProps<T extends Record<string, unknown>>(\n props: T,\n): {\n boxProps: Partial<BoxLayoutOwnProps>;\n rest: Omit<T, keyof BoxLayoutOwnProps>;\n} {\n const boxProps: Partial<BoxLayoutOwnProps> = {};\n const rest: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(props)) {\n if (BOX_PROP_KEYS.has(key as keyof BoxLayoutOwnProps)) {\n (boxProps as Record<string, unknown>)[key] = value;\n } else {\n rest[key] = value;\n }\n }\n\n return { boxProps, rest: rest as Omit<T, keyof BoxLayoutOwnProps> };\n}\n\nexport function applyBoxLayoutStyles(\n styles: Record<string, string | number>,\n boxProps: Partial<BoxLayoutOwnProps>,\n) {\n for (const key of BOX_PROP_KEYS) {\n const value = boxProps[key];\n if (value === undefined) continue;\n\n const variable = variableNameForProp(key);\n if (SPACE_PROP_KEYS.has(key)) {\n setResponsiveStyleVar(styles, variable, value as string | number, resolveSpaceValue);\n continue;\n }\n\n setResponsiveStyleVar(\n styles,\n variable,\n value as string | number,\n (input) => input as string | number,\n );\n }\n}\n\nexport function withBoxLayoutStyle(\n styles: Record<string, string | number>,\n userStyle: unknown,\n): string | undefined {\n return mergeLayoutStyles(styles, userStyle);\n}\n\nexport function withBoxLayoutClass(\n styles: Record<string, string | number>,\n userStyle: unknown,\n): string | undefined {\n return styleDeclarationsToClass(mergeLayoutStyles(styles, userStyle));\n}\n"],"mappings":";;;AAIA,MAAM,kBAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,gBAAgB,IAAI,IAA6B;CACrD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,oBAAoB,MAAuC;CAClE,QAAQ,MAAR;EACE,KAAK,aACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,mBACH,OAAO;EACT,KAAK,iBACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,SACE,OAAO;;;AAIb,SAAgB,oBACd,OAIA;CACA,MAAM,WAAuC,EAAE;CAC/C,MAAM,OAAgC,EAAE;CAExC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,EAC9C,IAAI,cAAc,IAAI,IAA+B,EACnD,SAAsC,OAAO;MAE7C,KAAK,OAAO;CAIhB,OAAO;EAAE;EAAgB;EAA0C;;AAGrE,SAAgB,qBACd,QACA,UACA;CACA,KAAK,MAAM,OAAO,eAAe;EAC/B,MAAM,QAAQ,SAAS;EACvB,IAAI,UAAU,KAAA,GAAW;EAEzB,MAAM,WAAW,oBAAoB,IAAI;EACzC,IAAI,gBAAgB,IAAI,IAAI,EAAE;GAC5B,sBAAsB,QAAQ,UAAU,OAA0B,kBAAkB;GACpF;;EAGF,sBACE,QACA,UACA,QACC,UAAU,MACZ;;;AAWL,SAAgB,mBACd,QACA,WACoB;CACpB,OAAO,yBAAyB,kBAAkB,QAAQ,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classes.js","names":[],"sources":["../../../src/components/_internal/classes.ts"],"sourcesContent":["export function classes(...values: Array<unknown>): string | undefined {\n const value = values.filter((item) => typeof item === \"string\" && item.trim()).join(\" \");\n\n return value || undefined;\n}\n"],"mappings":";AAAA,SAAgB,QAAQ,GAAG,QAA4C;CAGrE,OAFc,OAAO,QAAQ,SAAS,OAAO,SAAS,YAAY,KAAK,MAAM,CAAC,CAAC,KAAK,IAExE,IAAI,KAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.js","names":[],"sources":["../../../src/components/_internal/jsx.ts"],"sourcesContent":["import type { JSXElement } from \"@askrjs/askr/foundations\";\n\nexport function isJsxElement(value: unknown): value is JSXElement {\n return typeof value === \"object\" && value !== null && \"$$typeof\" in value && \"props\" in value;\n}\n\nexport function hasJsxIntrinsicType(value: unknown, expectedType: string): value is JSXElement {\n return isJsxElement(value) && value.type === expectedType;\n}\n\nexport function toChildArray(children: unknown): unknown[] {\n if (Array.isArray(children)) {\n return children;\n }\n\n return children === undefined || children === null ? [] : [children];\n}\n\nexport function mapJsxTree(children: unknown, mapper: (element: JSXElement) => unknown): unknown {\n if (Array.isArray(children)) {\n return children.map((child) => mapJsxTree(child, mapper));\n }\n\n if (!isJsxElement(children)) {\n return children;\n }\n\n const mapped = mapper(children);\n\n if (!isJsxElement(mapped)) {\n return mapped;\n }\n\n const currentChildren = mapped.props?.children;\n const nextChildren = mapJsxTree(currentChildren, mapper);\n\n if (nextChildren === currentChildren) {\n return mapped;\n }\n\n return {\n ...mapped,\n props: {\n ...mapped.props,\n children: nextChildren,\n },\n };\n}\n\nexport function collectJsxElements(\n children: unknown,\n predicate?: (element: JSXElement) => boolean,\n): JSXElement[] {\n const result: JSXElement[] = [];\n\n const visit = (value: unknown) => {\n if (Array.isArray(value)) {\n value.forEach(visit);\n return;\n }\n\n if (!isJsxElement(value)) {\n return;\n }\n\n if (!predicate || predicate(value)) {\n result.push(value);\n }\n\n visit(value.props?.children);\n };\n\n visit(children);\n\n return result;\n}\n\nfunction serializeArray(value: readonly unknown[]): string {\n if (value.length === 0) {\n return \"\";\n }\n\n if (value.length === 1) {\n return serializeForId(value[0]);\n }\n\n if (value.length === 2) {\n return `${serializeForId(value[0])}|${serializeForId(value[1])}`;\n }\n\n let result = serializeForId(value[0]);\n\n for (let index = 1; index < value.length; index += 1) {\n result += `|${serializeForId(value[index])}`;\n }\n\n return result;\n}\n\nfunction serializeSerializableProps(props: Record<string, unknown>): string {\n const keys: string[] = [];\n\n for (const key of Object.keys(props)) {\n if (key === \"children\" || key === \"ref\" || key.startsWith(\"on\")) {\n continue;\n }\n\n const entryValue = props[key];\n\n if (\n typeof entryValue === \"string\" ||\n typeof entryValue === \"number\" ||\n typeof entryValue === \"boolean\"\n ) {\n keys.push(key);\n }\n }\n\n if (keys.length === 0) {\n return \"\";\n }\n\n if (keys.length === 1) {\n const key = keys[0];\n\n return `${key}:${String(props[key])}`;\n }\n\n if (keys.length === 2) {\n if (keys[1].localeCompare(keys[0]) < 0) {\n [keys[0], keys[1]] = [keys[1], keys[0]];\n }\n\n return `${keys[0]}:${String(props[keys[0]])},${keys[1]}:${String(props[keys[1]])}`;\n }\n\n keys.sort((left, right) => left.localeCompare(right));\n\n let result = `${keys[0]}:${String(props[keys[0]])}`;\n\n for (let index = 1; index < keys.length; index += 1) {\n const key = keys[index];\n result += `,${key}:${String(props[key])}`;\n }\n\n return result;\n}\n\nfunction hasEmptyJsxChildren(children: unknown): boolean {\n return (\n children === undefined ||\n children === null ||\n typeof children === \"boolean\" ||\n (Array.isArray(children) && children.length === 0)\n );\n}\n\nexport function extractTextContent(value: unknown): string {\n if (Array.isArray(value)) {\n return value.map((entry) => extractTextContent(entry)).join(\"\");\n }\n\n if (\n value === undefined ||\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"function\"\n ) {\n return \"\";\n }\n\n if (typeof value === \"string\" || typeof value === \"number\") {\n return String(value);\n }\n\n if (isJsxElement(value)) {\n return extractTextContent(value.props?.children);\n }\n\n return \"\";\n}\n\nexport function serializeForId(value: unknown): string {\n if (Array.isArray(value)) {\n return serializeArray(value);\n }\n\n if (value === undefined || value === null || typeof value === \"boolean\") {\n return \"\";\n }\n\n if (typeof value === \"string\" || typeof value === \"number\") {\n return String(value);\n }\n\n if (isJsxElement(value)) {\n const typeName =\n typeof value.type === \"string\"\n ? value.type\n : typeof value.type === \"function\"\n ? value.type.name || \"component\"\n : \"component\";\n const props = (value.props ?? {}) as Record<string, unknown>;\n const propEntries = serializeSerializableProps(props);\n const children = props.children;\n const propsPrefix = propEntries === \"\" ? `${typeName}[]` : `${typeName}[${propEntries}]`;\n\n if (hasEmptyJsxChildren(children)) {\n return `${propsPrefix}()`;\n }\n\n return `${propsPrefix}(${serializeForId(children)})`;\n }\n\n return typeof value;\n}\n"],"mappings":";AAEA,SAAgB,aAAa,OAAqC;CAChE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,cAAc,SAAS,WAAW;;AAO1F,SAAgB,aAAa,UAA8B;CACzD,IAAI,MAAM,QAAQ,SAAS,EACzB,OAAO;CAGT,OAAO,aAAa,KAAA,KAAa,aAAa,OAAO,EAAE,GAAG,CAAC,SAAS"}
|
|
@@ -1,31 +1,9 @@
|
|
|
1
|
+
//#region src/components/_internal/layout.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Layout helpers shared by headless layout primitives.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
export declare function isCssLength(value: unknown): value is string;
|
|
11
|
-
export declare function isResponsiveValue<T>(value: ResponsiveValue<T> | undefined): value is Partial<Record<LayoutBreakpoint, T>>;
|
|
12
|
-
export declare function normalizeResponsiveValue<T>(value: ResponsiveValue<T> | undefined): Partial<Record<LayoutBreakpoint, T>> | undefined;
|
|
13
|
-
export declare function serializeResponsiveValue<T>(value: ResponsiveValue<T> | undefined): string | undefined;
|
|
14
|
-
export declare function serializeResponsiveValueIf<T>(value: ResponsiveValue<T> | undefined, predicate: (value: T) => boolean): string | undefined;
|
|
15
|
-
export declare function serializeValueIf<T>(value: T | undefined, predicate: (value: T) => boolean): string | undefined;
|
|
16
|
-
export declare function setResponsiveStyleVar<T>(styles: Record<string, string | number>, variable: string, value: ResponsiveValue<T> | undefined, resolve?: (value: T) => string | number | undefined): void;
|
|
17
|
-
export declare function resolveSpaceValue(value: string | number): string | number;
|
|
18
|
-
export declare function resolveContainerSizeValue(value: string): string;
|
|
19
|
-
export declare function resolveSectionSizeValue(value: string): string;
|
|
20
|
-
export declare function resolveGridTrackValue(value: string | number): string;
|
|
21
|
-
export declare function resolveJustifyValue(value: string): string;
|
|
22
|
-
export declare function resolveAlignValue(value: string): string;
|
|
23
|
-
export declare function resolveInlineAlignValue(value: "left" | "center" | "right"): {
|
|
24
|
-
marginLeft?: string;
|
|
25
|
-
marginRight?: string;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Merges a record of computed layout styles with a user-supplied `style` prop.
|
|
29
|
-
* The user's styles take precedence for conflicting keys.
|
|
30
|
-
*/
|
|
31
|
-
export declare function mergeLayoutStyles(layout: Record<string, string | number>, user: unknown): string | undefined;
|
|
5
|
+
type LayoutBreakpoint = "initial" | "sm" | "md" | "lg" | "xl";
|
|
6
|
+
type ResponsiveValue<T> = T | Partial<Record<LayoutBreakpoint, T>>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ResponsiveValue };
|
|
9
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -37,8 +37,8 @@ const CONTAINER_SIZE_MAP = {
|
|
|
37
37
|
xl: "var(--ak-container-4)"
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
|
-
* Returns true when `value` is a concrete CSS length/size that can be
|
|
41
|
-
*
|
|
40
|
+
* Returns true when `value` is a concrete CSS length/size that can be serialized
|
|
41
|
+
* into a CSS declaration without token translation.
|
|
42
42
|
*/
|
|
43
43
|
function isCssLength(value) {
|
|
44
44
|
if (typeof value !== "string") return false;
|
|
@@ -76,10 +76,6 @@ function serializeResponsiveValueIf(value, predicate) {
|
|
|
76
76
|
}
|
|
77
77
|
return serializeResponsiveValue(value);
|
|
78
78
|
}
|
|
79
|
-
function serializeValueIf(value, predicate) {
|
|
80
|
-
if (value === void 0 || !predicate(value)) return void 0;
|
|
81
|
-
return String(value);
|
|
82
|
-
}
|
|
83
79
|
function setResponsiveStyleVar(styles, variable, value, resolve = (input) => input) {
|
|
84
80
|
const normalized = normalizeResponsiveValue(value);
|
|
85
81
|
if (!normalized) return;
|
|
@@ -100,12 +96,6 @@ function resolveContainerSizeValue(value) {
|
|
|
100
96
|
const trimmed = value.trim();
|
|
101
97
|
return CONTAINER_SIZE_MAP[trimmed] ?? trimmed;
|
|
102
98
|
}
|
|
103
|
-
function resolveGridTrackValue(value) {
|
|
104
|
-
if (typeof value === "number") return `repeat(${value}, minmax(0, 1fr))`;
|
|
105
|
-
const trimmed = value.trim();
|
|
106
|
-
if (/^\d+$/.test(trimmed)) return `repeat(${trimmed}, minmax(0, 1fr))`;
|
|
107
|
-
return trimmed;
|
|
108
|
-
}
|
|
109
99
|
function resolveJustifyValue(value) {
|
|
110
100
|
const trimmed = value.trim();
|
|
111
101
|
if (trimmed === "between") return "space-between";
|
|
@@ -134,8 +124,8 @@ function resolveInlineAlignValue(value) {
|
|
|
134
124
|
};
|
|
135
125
|
}
|
|
136
126
|
/**
|
|
137
|
-
* Merges a record of computed layout
|
|
138
|
-
* The user's
|
|
127
|
+
* Merges a record of computed layout declarations with a user-supplied style
|
|
128
|
+
* value. The user's declarations take precedence for conflicting keys.
|
|
139
129
|
*/
|
|
140
130
|
function mergeLayoutStyles(layout, user) {
|
|
141
131
|
const merged = { ...layout };
|
|
@@ -151,6 +141,6 @@ function objectToCssString(styles) {
|
|
|
151
141
|
return Object.entries(styles).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => `${camelToKebab(key)}:${String(value)}`).join(";");
|
|
152
142
|
}
|
|
153
143
|
//#endregion
|
|
154
|
-
export { isCssLength, isResponsiveValue, mergeLayoutStyles, resolveAlignValue, resolveContainerSizeValue,
|
|
144
|
+
export { isCssLength, isResponsiveValue, mergeLayoutStyles, resolveAlignValue, resolveContainerSizeValue, resolveInlineAlignValue, resolveJustifyValue, resolveSpaceValue, serializeResponsiveValueIf, setResponsiveStyleVar };
|
|
155
145
|
|
|
156
146
|
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../../../src/components/_internal/layout.ts"],"sourcesContent":["/**\n * Layout helpers shared by headless layout primitives.\n */\n\nexport type LayoutBreakpoint = \"initial\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type ResponsiveValue<T> = T | Partial<Record<LayoutBreakpoint, T>>;\n\nconst BREAKPOINTS: readonly LayoutBreakpoint[] = [\"initial\", \"sm\", \"md\", \"lg\", \"xl\"];\n\n/** Units and patterns that identify a concrete CSS length value. */\nconst CSS_UNIT_RE =\n /^-?[\\d.]+(%|px|em|rem|ex|ch|ic|lh|rlh|vw|vh|vmin|vmax|svw|svh|dvw|dvh|cqw|cqh|cqi|cqb|fr|cm|mm|in|pt|pc|Q)$/;\n\nconst SPACE_TOKEN_MAP: Record<string, string> = {\n \"1\": \"var(--ak-space-1)\",\n \"2\": \"var(--ak-space-2)\",\n \"3\": \"var(--ak-space-3)\",\n \"4\": \"var(--ak-space-4)\",\n \"5\": \"var(--ak-space-5)\",\n \"6\": \"var(--ak-space-6)\",\n \"7\": \"var(--ak-space-7)\",\n \"8\": \"var(--ak-space-8)\",\n \"9\": \"var(--ak-space-9)\",\n xs: \"var(--ak-space-xs)\",\n sm: \"var(--ak-space-sm)\",\n md: \"var(--ak-space-md)\",\n lg: \"var(--ak-space-lg)\",\n xl: \"var(--ak-space-xl)\",\n \"2xl\": \"var(--ak-space-2xl)\",\n \"3xl\": \"var(--ak-space-3xl)\",\n};\n\nconst CONTAINER_SIZE_MAP: Record<string, string> = {\n \"1\": \"var(--ak-container-1)\",\n \"2\": \"var(--ak-container-2)\",\n \"3\": \"var(--ak-container-3)\",\n \"4\": \"var(--ak-container-4)\",\n sm: \"var(--ak-container-1)\",\n md: \"var(--ak-container-2)\",\n lg: \"var(--ak-container-3)\",\n xl: \"var(--ak-container-4)\",\n};\n\nconst SECTION_SIZE_MAP: Record<string, string> = {\n \"1\": \"var(--ak-section-1)\",\n \"2\": \"var(--ak-section-2)\",\n \"3\": \"var(--ak-section-3)\",\n \"4\": \"var(--ak-section-4)\",\n};\n\n/**\n * Returns true when `value` is a concrete CSS length/size that can be serialized\n * into a CSS declaration without token translation.\n */\nexport function isCssLength(value: unknown): value is string {\n if (typeof value !== \"string\") return false;\n const v = value.trim();\n if (v === \"0\") return true;\n if (CSS_UNIT_RE.test(v)) return true;\n // CSS functions: calc(), min(), max(), clamp(), fit-content(), env(), var()\n if (/^[a-z][a-z-]*\\(/.test(v)) return true;\n return false;\n}\n\nexport function isResponsiveValue<T>(\n value: ResponsiveValue<T> | undefined,\n): value is Partial<Record<LayoutBreakpoint, T>> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n return BREAKPOINTS.some((breakpoint) => breakpoint in value);\n}\n\nexport function normalizeResponsiveValue<T>(\n value: ResponsiveValue<T> | undefined,\n): Partial<Record<LayoutBreakpoint, T>> | undefined {\n if (value === undefined) return undefined;\n if (isResponsiveValue(value)) return value;\n return { initial: value };\n}\n\nexport function serializeResponsiveValue<T>(\n value: ResponsiveValue<T> | undefined,\n): string | undefined {\n const normalized = normalizeResponsiveValue(value);\n if (!normalized) return undefined;\n\n return BREAKPOINTS.map((breakpoint) => {\n const breakpointValue = normalized[breakpoint];\n if (breakpointValue === undefined) return \"\";\n return `${breakpoint}:${String(breakpointValue)}`;\n })\n .filter(Boolean)\n .join(\"|\");\n}\n\nexport function serializeResponsiveValueIf<T>(\n value: ResponsiveValue<T> | undefined,\n predicate: (value: T) => boolean,\n): string | undefined {\n const normalized = normalizeResponsiveValue(value);\n if (!normalized) return undefined;\n\n for (const breakpoint of BREAKPOINTS) {\n const breakpointValue = normalized[breakpoint];\n if (breakpointValue === undefined) continue;\n if (!predicate(breakpointValue)) return undefined;\n }\n\n return serializeResponsiveValue(value);\n}\n\nexport function serializeValueIf<T>(\n value: T | undefined,\n predicate: (value: T) => boolean,\n): string | undefined {\n if (value === undefined || !predicate(value)) return undefined;\n return String(value);\n}\n\nexport function setResponsiveStyleVar<T>(\n styles: Record<string, string | number>,\n variable: string,\n value: ResponsiveValue<T> | undefined,\n resolve: (value: T) => string | number | undefined = (input) =>\n input as string | number | undefined,\n) {\n const normalized = normalizeResponsiveValue(value);\n if (!normalized) return;\n\n for (const breakpoint of BREAKPOINTS) {\n const breakpointValue = normalized[breakpoint];\n if (breakpointValue === undefined) continue;\n const resolved = resolve(breakpointValue);\n if (resolved === undefined || resolved === null || resolved === \"\") continue;\n styles[`--ak-${variable}-${breakpoint}`] = resolved;\n }\n}\n\nexport function resolveSpaceValue(value: string | number): string | number {\n if (typeof value === \"number\") return String(value);\n const trimmed = value.trim();\n return SPACE_TOKEN_MAP[trimmed] ?? trimmed;\n}\n\nexport function resolveContainerSizeValue(value: string): string {\n const trimmed = value.trim();\n return CONTAINER_SIZE_MAP[trimmed] ?? trimmed;\n}\n\nexport function resolveSectionSizeValue(value: string): string {\n const trimmed = value.trim();\n return SECTION_SIZE_MAP[trimmed] ?? trimmed;\n}\n\nexport function resolveJustifyValue(value: string): string {\n const trimmed = value.trim();\n if (trimmed === \"between\") return \"space-between\";\n if (trimmed === \"start\") return \"flex-start\";\n if (trimmed === \"end\") return \"flex-end\";\n return trimmed;\n}\n\nexport function resolveAlignValue(value: string): string {\n const trimmed = value.trim();\n if (trimmed === \"start\") return \"flex-start\";\n if (trimmed === \"end\") return \"flex-end\";\n return trimmed;\n}\n\nexport function resolveInlineAlignValue(value: \"left\" | \"center\" | \"right\"): {\n marginLeft?: string;\n marginRight?: string;\n} {\n if (value === \"left\") return { marginLeft: \"0\", marginRight: \"auto\" };\n if (value === \"right\") return { marginLeft: \"auto\", marginRight: \"0\" };\n return { marginLeft: \"auto\", marginRight: \"auto\" };\n}\n\n/**\n * Merges a record of computed layout declarations with a user-supplied style\n * value. The user's declarations take precedence for conflicting keys.\n */\nexport function mergeLayoutStyles(\n layout: Record<string, string | number>,\n user: unknown,\n): string | undefined {\n const merged: Record<string, unknown> = { ...layout };\n\n if (user !== null && user !== undefined && typeof user === \"object\") {\n Object.assign(merged, user as Record<string, unknown>);\n }\n\n const mergedString = objectToCssString(merged);\n\n if (typeof user === \"string\" && user.trim()) {\n return mergedString ? `${mergedString};${user.trim()}` : user.trim();\n }\n\n return mergedString || undefined;\n}\n\nfunction camelToKebab(s: string): string {\n return s.replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`);\n}\n\nfunction objectToCssString(styles: Record<string, unknown>): string {\n return Object.entries(styles)\n .filter(([, value]) => value !== undefined && value !== null)\n .map(([key, value]) => `${camelToKebab(key)}:${String(value)}`)\n .join(\";\");\n}\n"],"mappings":";AAOA,MAAM,cAA2C;CAAC;CAAW;CAAM;CAAM;CAAM;CAAK;;AAGpF,MAAM,cACJ;AAEF,MAAM,kBAA0C;CAC9C,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,OAAO;CACP,OAAO;CACR;AAED,MAAM,qBAA6C;CACjD,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;;;;;AAaD,SAAgB,YAAY,OAAiC;CAC3D,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,MAAM,IAAI,MAAM,MAAM;CACtB,IAAI,MAAM,KAAK,OAAO;CACtB,IAAI,YAAY,KAAK,EAAE,EAAE,OAAO;CAEhC,IAAI,kBAAkB,KAAK,EAAE,EAAE,OAAO;CACtC,OAAO;;AAGT,SAAgB,kBACd,OAC+C;CAC/C,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,MAAM,EAAE,OAAO;CACxE,OAAO,YAAY,MAAM,eAAe,cAAc,MAAM;;AAG9D,SAAgB,yBACd,OACkD;CAClD,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,IAAI,kBAAkB,MAAM,EAAE,OAAO;CACrC,OAAO,EAAE,SAAS,OAAO;;AAG3B,SAAgB,yBACd,OACoB;CACpB,MAAM,aAAa,yBAAyB,MAAM;CAClD,IAAI,CAAC,YAAY,OAAO,KAAA;CAExB,OAAO,YAAY,KAAK,eAAe;EACrC,MAAM,kBAAkB,WAAW;EACnC,IAAI,oBAAoB,KAAA,GAAW,OAAO;EAC1C,OAAO,GAAG,WAAW,GAAG,OAAO,gBAAgB;GAC/C,CACC,OAAO,QAAQ,CACf,KAAK,IAAI;;AAGd,SAAgB,2BACd,OACA,WACoB;CACpB,MAAM,aAAa,yBAAyB,MAAM;CAClD,IAAI,CAAC,YAAY,OAAO,KAAA;CAExB,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,kBAAkB,WAAW;EACnC,IAAI,oBAAoB,KAAA,GAAW;EACnC,IAAI,CAAC,UAAU,gBAAgB,EAAE,OAAO,KAAA;;CAG1C,OAAO,yBAAyB,MAAM;;AAWxC,SAAgB,sBACd,QACA,UACA,OACA,WAAsD,UACpD,OACF;CACA,MAAM,aAAa,yBAAyB,MAAM;CAClD,IAAI,CAAC,YAAY;CAEjB,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,kBAAkB,WAAW;EACnC,IAAI,oBAAoB,KAAA,GAAW;EACnC,MAAM,WAAW,QAAQ,gBAAgB;EACzC,IAAI,aAAa,KAAA,KAAa,aAAa,QAAQ,aAAa,IAAI;EACpE,OAAO,QAAQ,SAAS,GAAG,gBAAgB;;;AAI/C,SAAgB,kBAAkB,OAAyC;CACzE,IAAI,OAAO,UAAU,UAAU,OAAO,OAAO,MAAM;CACnD,MAAM,UAAU,MAAM,MAAM;CAC5B,OAAO,gBAAgB,YAAY;;AAGrC,SAAgB,0BAA0B,OAAuB;CAC/D,MAAM,UAAU,MAAM,MAAM;CAC5B,OAAO,mBAAmB,YAAY;;AAQxC,SAAgB,oBAAoB,OAAuB;CACzD,MAAM,UAAU,MAAM,MAAM;CAC5B,IAAI,YAAY,WAAW,OAAO;CAClC,IAAI,YAAY,SAAS,OAAO;CAChC,IAAI,YAAY,OAAO,OAAO;CAC9B,OAAO;;AAGT,SAAgB,kBAAkB,OAAuB;CACvD,MAAM,UAAU,MAAM,MAAM;CAC5B,IAAI,YAAY,SAAS,OAAO;CAChC,IAAI,YAAY,OAAO,OAAO;CAC9B,OAAO;;AAGT,SAAgB,wBAAwB,OAGtC;CACA,IAAI,UAAU,QAAQ,OAAO;EAAE,YAAY;EAAK,aAAa;EAAQ;CACrE,IAAI,UAAU,SAAS,OAAO;EAAE,YAAY;EAAQ,aAAa;EAAK;CACtE,OAAO;EAAE,YAAY;EAAQ,aAAa;EAAQ;;;;;;AAOpD,SAAgB,kBACd,QACA,MACoB;CACpB,MAAM,SAAkC,EAAE,GAAG,QAAQ;CAErD,IAAI,SAAS,QAAQ,SAAS,KAAA,KAAa,OAAO,SAAS,UACzD,OAAO,OAAO,QAAQ,KAAgC;CAGxD,MAAM,eAAe,kBAAkB,OAAO;CAE9C,IAAI,OAAO,SAAS,YAAY,KAAK,MAAM,EACzC,OAAO,eAAe,GAAG,aAAa,GAAG,KAAK,MAAM,KAAK,KAAK,MAAM;CAGtE,OAAO,gBAAgB,KAAA;;AAGzB,SAAS,aAAa,GAAmB;CACvC,OAAO,EAAE,QAAQ,aAAa,MAAM,IAAI,EAAE,aAAa,GAAG;;AAG5D,SAAS,kBAAkB,QAAyC;CAClE,OAAO,OAAO,QAAQ,OAAO,CAC1B,QAAQ,GAAG,WAAW,UAAU,KAAA,KAAa,UAAU,KAAK,CAC5D,KAAK,CAAC,KAAK,WAAW,GAAG,aAAa,IAAI,CAAC,GAAG,OAAO,MAAM,GAAG,CAC9D,KAAK,IAAI"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classes } from "./classes.js";
|
|
1
2
|
//#region src/components/_internal/merge-props.ts
|
|
2
3
|
function isEventHandlerKey(key) {
|
|
3
4
|
return key.startsWith("on");
|
|
@@ -40,6 +41,10 @@ function mergeProps(base, injected) {
|
|
|
40
41
|
out[key] = composeHandlers(injectedValue, baseValue);
|
|
41
42
|
continue;
|
|
42
43
|
}
|
|
44
|
+
if (key === "class") {
|
|
45
|
+
out[key] = classes(injectedValue, baseValue);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
43
48
|
out[key] = baseValue;
|
|
44
49
|
}
|
|
45
50
|
return out;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-props.js","names":[],"sources":["../../../src/components/_internal/merge-props.ts"],"sourcesContent":["import { classes } from \"./classes\";\n\ntype Handler = (...args: readonly unknown[]) => void;\ntype Ref<T> = { current: T | null } | ((value: T | null) => void) | null | undefined;\n\nfunction isEventHandlerKey(key: string): boolean {\n return key.startsWith(\"on\");\n}\n\nfunction isDefaultPrevented(value: unknown): value is { defaultPrevented: true } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"defaultPrevented\" in value &&\n (value as { defaultPrevented?: boolean }).defaultPrevented === true\n );\n}\n\nfunction composeHandlers(first: Handler, second: Handler): Handler {\n return (...args) => {\n // Internal composition runs first so wrappers can normalize state or stop\n // follow-on handlers when the event has already been consumed.\n first(...args);\n\n if (isDefaultPrevented(args[0])) {\n return;\n }\n\n second(...args);\n };\n}\n\nfunction setRef<T>(ref: Ref<T>, value: T | null): void {\n if (!ref) return;\n\n if (typeof ref === \"function\") {\n ref(value);\n return;\n }\n\n if (Object.isExtensible(ref)) {\n (ref as { current: T | null }).current = value;\n }\n}\n\nfunction composeRefs<T>(...refs: Array<Ref<T>>): (value: T | null) => void {\n return (value: T | null) => {\n for (const ref of refs) {\n setRef(ref, value);\n }\n };\n}\n\nexport function mergeProps<TBase extends object, TInjected extends object>(\n base: TBase,\n injected: TInjected,\n): TInjected & TBase {\n const baseKeys = Object.keys(base);\n if (baseKeys.length === 0) {\n return injected as TInjected & TBase;\n }\n\n const out = { ...(injected as object) } as TInjected & TBase;\n\n for (const key of baseKeys as Array<Extract<keyof TBase, string>>) {\n const baseValue = (base as Record<string, unknown>)[key];\n const injectedValue = (injected as Record<string, unknown>)[key];\n\n if (key === \"ref\") {\n (out as Record<string, unknown>)[key] = composeRefs(\n injectedValue as Ref<unknown>,\n baseValue as Ref<unknown>,\n );\n continue;\n }\n\n if (\n isEventHandlerKey(key) &&\n typeof baseValue === \"function\" &&\n typeof injectedValue === \"function\"\n ) {\n (out as Record<string, unknown>)[key] = composeHandlers(\n injectedValue as Handler,\n baseValue as Handler,\n );\n continue;\n }\n\n if (key === \"class\") {\n (out as Record<string, unknown>)[key] = classes(injectedValue, baseValue);\n continue;\n }\n\n (out as Record<string, unknown>)[key] = baseValue;\n }\n\n return out;\n}\n"],"mappings":";;AAKA,SAAS,kBAAkB,KAAsB;CAC/C,OAAO,IAAI,WAAW,KAAK;;AAG7B,SAAS,mBAAmB,OAAqD;CAC/E,OACE,OAAO,UAAU,YACjB,UAAU,QACV,sBAAsB,SACrB,MAAyC,qBAAqB;;AAInE,SAAS,gBAAgB,OAAgB,QAA0B;CACjE,QAAQ,GAAG,SAAS;EAGlB,MAAM,GAAG,KAAK;EAEd,IAAI,mBAAmB,KAAK,GAAG,EAC7B;EAGF,OAAO,GAAG,KAAK;;;AAInB,SAAS,OAAU,KAAa,OAAuB;CACrD,IAAI,CAAC,KAAK;CAEV,IAAI,OAAO,QAAQ,YAAY;EAC7B,IAAI,MAAM;EACV;;CAGF,IAAI,OAAO,aAAa,IAAI,EAC1B,IAA+B,UAAU;;AAI7C,SAAS,YAAe,GAAG,MAAgD;CACzE,QAAQ,UAAoB;EAC1B,KAAK,MAAM,OAAO,MAChB,OAAO,KAAK,MAAM;;;AAKxB,SAAgB,WACd,MACA,UACmB;CACnB,MAAM,WAAW,OAAO,KAAK,KAAK;CAClC,IAAI,SAAS,WAAW,GACtB,OAAO;CAGT,MAAM,MAAM,EAAE,GAAI,UAAqB;CAEvC,KAAK,MAAM,OAAO,UAAiD;EACjE,MAAM,YAAa,KAAiC;EACpD,MAAM,gBAAiB,SAAqC;EAE5D,IAAI,QAAQ,OAAO;GACjB,IAAiC,OAAO,YACtC,eACA,UACD;GACD;;EAGF,IACE,kBAAkB,IAAI,IACtB,OAAO,cAAc,cACrB,OAAO,kBAAkB,YACzB;GACA,IAAiC,OAAO,gBACtC,eACA,UACD;GACD;;EAGF,IAAI,QAAQ,SAAS;GACnB,IAAiC,OAAO,QAAQ,eAAe,UAAU;GACzE;;EAGF,IAAiC,OAAO;;CAG1C,OAAO"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/components/_internal/pathname.ts
|
|
2
|
+
function normalizePathname(pathname) {
|
|
3
|
+
return pathname.endsWith("/") && pathname !== "/" ? pathname.slice(0, -1) : pathname;
|
|
4
|
+
}
|
|
5
|
+
function getWindowLocation() {
|
|
6
|
+
return typeof window === "undefined" ? null : window.location;
|
|
7
|
+
}
|
|
8
|
+
function resolvePathname(href) {
|
|
9
|
+
if (href.startsWith("#")) return null;
|
|
10
|
+
const location = getWindowLocation();
|
|
11
|
+
if (href.startsWith("/") && !href.startsWith("//")) {
|
|
12
|
+
const queryIndex = href.indexOf("?");
|
|
13
|
+
const hashIndex = href.indexOf("#");
|
|
14
|
+
let pathEnd = href.length;
|
|
15
|
+
if (queryIndex !== -1) pathEnd = Math.min(pathEnd, queryIndex);
|
|
16
|
+
if (hashIndex !== -1) pathEnd = Math.min(pathEnd, hashIndex);
|
|
17
|
+
const pathname = normalizePathname(href.slice(0, pathEnd));
|
|
18
|
+
if (location && hashIndex !== -1) {
|
|
19
|
+
const searchEnd = hashIndex === -1 ? href.length : hashIndex;
|
|
20
|
+
const search = queryIndex === -1 ? "" : href.slice(queryIndex, searchEnd);
|
|
21
|
+
if (pathname === normalizePathname(location.pathname || "/") && search === location.search) return null;
|
|
22
|
+
}
|
|
23
|
+
return pathname;
|
|
24
|
+
}
|
|
25
|
+
const baseHref = location?.href ?? "http://localhost/";
|
|
26
|
+
const baseOrigin = location?.origin ?? "http://localhost";
|
|
27
|
+
try {
|
|
28
|
+
const target = new URL(href, baseHref);
|
|
29
|
+
if (target.origin !== baseOrigin) return null;
|
|
30
|
+
if (location && target.hash && normalizePathname(target.pathname) === normalizePathname(location.pathname || "/") && target.search === location.search) return null;
|
|
31
|
+
return normalizePathname(target.pathname);
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { resolvePathname };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=pathname.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathname.js","names":[],"sources":["../../../src/components/_internal/pathname.ts"],"sourcesContent":["function normalizePathname(pathname: string): string {\n return pathname.endsWith(\"/\") && pathname !== \"/\" ? pathname.slice(0, -1) : pathname;\n}\n\nfunction getWindowLocation(): Location | null {\n return typeof window === \"undefined\" ? null : window.location;\n}\n\nexport function resolvePathname(href: string): string | null {\n if (href.startsWith(\"#\")) {\n return null;\n }\n\n const location = getWindowLocation();\n\n if (href.startsWith(\"/\") && !href.startsWith(\"//\")) {\n const queryIndex = href.indexOf(\"?\");\n const hashIndex = href.indexOf(\"#\");\n let pathEnd = href.length;\n\n if (queryIndex !== -1) {\n pathEnd = Math.min(pathEnd, queryIndex);\n }\n\n if (hashIndex !== -1) {\n pathEnd = Math.min(pathEnd, hashIndex);\n }\n\n const pathname = normalizePathname(href.slice(0, pathEnd));\n\n if (location && hashIndex !== -1) {\n const searchEnd = hashIndex === -1 ? href.length : hashIndex;\n const search = queryIndex === -1 ? \"\" : href.slice(queryIndex, searchEnd);\n const locationPathname = normalizePathname(location.pathname || \"/\");\n\n if (pathname === locationPathname && search === location.search) {\n return null;\n }\n }\n\n return pathname;\n }\n\n const baseHref = location?.href ?? \"http://localhost/\";\n const baseOrigin = location?.origin ?? \"http://localhost\";\n\n try {\n const target = new URL(href, baseHref);\n\n if (target.origin !== baseOrigin) {\n return null;\n }\n\n if (\n location &&\n target.hash &&\n normalizePathname(target.pathname) === normalizePathname(location.pathname || \"/\") &&\n target.search === location.search\n ) {\n return null;\n }\n\n return normalizePathname(target.pathname);\n } catch {\n return null;\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB,UAA0B;CACnD,OAAO,SAAS,SAAS,IAAI,IAAI,aAAa,MAAM,SAAS,MAAM,GAAG,GAAG,GAAG;;AAG9E,SAAS,oBAAqC;CAC5C,OAAO,OAAO,WAAW,cAAc,OAAO,OAAO;;AAGvD,SAAgB,gBAAgB,MAA6B;CAC3D,IAAI,KAAK,WAAW,IAAI,EACtB,OAAO;CAGT,MAAM,WAAW,mBAAmB;CAEpC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,KAAK,WAAW,KAAK,EAAE;EAClD,MAAM,aAAa,KAAK,QAAQ,IAAI;EACpC,MAAM,YAAY,KAAK,QAAQ,IAAI;EACnC,IAAI,UAAU,KAAK;EAEnB,IAAI,eAAe,IACjB,UAAU,KAAK,IAAI,SAAS,WAAW;EAGzC,IAAI,cAAc,IAChB,UAAU,KAAK,IAAI,SAAS,UAAU;EAGxC,MAAM,WAAW,kBAAkB,KAAK,MAAM,GAAG,QAAQ,CAAC;EAE1D,IAAI,YAAY,cAAc,IAAI;GAChC,MAAM,YAAY,cAAc,KAAK,KAAK,SAAS;GACnD,MAAM,SAAS,eAAe,KAAK,KAAK,KAAK,MAAM,YAAY,UAAU;GAGzE,IAAI,aAFqB,kBAAkB,SAAS,YAAY,IAE/B,IAAI,WAAW,SAAS,QACvD,OAAO;;EAIX,OAAO;;CAGT,MAAM,WAAW,UAAU,QAAQ;CACnC,MAAM,aAAa,UAAU,UAAU;CAEvC,IAAI;EACF,MAAM,SAAS,IAAI,IAAI,MAAM,SAAS;EAEtC,IAAI,OAAO,WAAW,YACpB,OAAO;EAGT,IACE,YACA,OAAO,QACP,kBAAkB,OAAO,SAAS,KAAK,kBAAkB,SAAS,YAAY,IAAI,IAClF,OAAO,WAAW,SAAS,QAE3B,OAAO;EAGT,OAAO,kBAAkB,OAAO,SAAS;SACnC;EACN,OAAO"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/components/_internal/style.ts
|
|
2
|
+
const STYLE_REGISTRY_ATTR = "data-askr-style-registry";
|
|
3
|
+
const STYLE_CLASS_PREFIX = "ak-style-";
|
|
4
|
+
const styleClassCache = /* @__PURE__ */ new Map();
|
|
5
|
+
const registeredDeclarations = /* @__PURE__ */ new Set();
|
|
6
|
+
let nextStyleClassId = 0;
|
|
7
|
+
function ensureStyleElement() {
|
|
8
|
+
if (typeof document === "undefined") return null;
|
|
9
|
+
const existing = document.querySelector(`style[${STYLE_REGISTRY_ATTR}]`);
|
|
10
|
+
if (existing instanceof HTMLStyleElement) return existing;
|
|
11
|
+
const styleElement = document.createElement("style");
|
|
12
|
+
styleElement.setAttribute(STYLE_REGISTRY_ATTR, "true");
|
|
13
|
+
(document.head ?? document.documentElement).append(styleElement);
|
|
14
|
+
return styleElement;
|
|
15
|
+
}
|
|
16
|
+
function normalizeDeclarations(declarations) {
|
|
17
|
+
return declarations.trim().replace(/;+\s*$/, "");
|
|
18
|
+
}
|
|
19
|
+
function styleDeclarationsToClass(declarations) {
|
|
20
|
+
if (typeof declarations !== "string") return void 0;
|
|
21
|
+
const normalized = normalizeDeclarations(declarations);
|
|
22
|
+
if (!normalized) return void 0;
|
|
23
|
+
let className = styleClassCache.get(normalized);
|
|
24
|
+
if (className === void 0) {
|
|
25
|
+
className = `${STYLE_CLASS_PREFIX}${++nextStyleClassId}`;
|
|
26
|
+
styleClassCache.set(normalized, className);
|
|
27
|
+
}
|
|
28
|
+
if (!registeredDeclarations.has(normalized)) {
|
|
29
|
+
const styleElement = ensureStyleElement();
|
|
30
|
+
if (styleElement) {
|
|
31
|
+
const rule = `.${className}{${normalized}}`;
|
|
32
|
+
styleElement.textContent = `${styleElement.textContent ?? ""}\n${rule}`;
|
|
33
|
+
registeredDeclarations.add(normalized);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return className;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { styleDeclarationsToClass };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/_internal/style.ts"],"sourcesContent":["export function mergeCssVar(style: unknown, name: string, value: string): string {\n const decl = `${name}:${value}`;\n\n if (typeof style === \"string\") {\n const trimmed = style.trim();\n return trimmed ? `${trimmed};${decl}` : decl;\n }\n\n if (style && typeof style === \"object\") {\n const entries = Object.entries(style as Record<string, unknown>)\n .filter(([, v]) => v !== undefined && v !== null)\n .map(([k, v]) => `${k.replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`)}:${String(v)}`)\n .join(\";\");\n return entries ? `${entries};${decl}` : decl;\n }\n\n return decl;\n}\n\nconst STYLE_REGISTRY_ATTR = \"data-askr-style-registry\";\nconst STYLE_CLASS_PREFIX = \"ak-style-\";\n\nconst styleClassCache = new Map<string, string>();\nconst registeredDeclarations = new Set<string>();\n\nlet nextStyleClassId = 0;\n\nfunction ensureStyleElement(): HTMLStyleElement | null {\n if (typeof document === \"undefined\") return null;\n\n const existing = document.querySelector(`style[${STYLE_REGISTRY_ATTR}]`);\n if (existing instanceof HTMLStyleElement) {\n return existing;\n }\n\n const styleElement = document.createElement(\"style\");\n styleElement.setAttribute(STYLE_REGISTRY_ATTR, \"true\");\n (document.head ?? document.documentElement).append(styleElement);\n\n return styleElement;\n}\n\nfunction normalizeDeclarations(declarations: string): string {\n return declarations.trim().replace(/;+\\s*$/, \"\");\n}\n\nexport function styleDeclarationsToClass(declarations: string | undefined): string | undefined {\n if (typeof declarations !== \"string\") return undefined;\n\n const normalized = normalizeDeclarations(declarations);\n if (!normalized) return undefined;\n\n let className = styleClassCache.get(normalized);\n if (className === undefined) {\n className = `${STYLE_CLASS_PREFIX}${++nextStyleClassId}`;\n styleClassCache.set(normalized, className);\n }\n\n if (!registeredDeclarations.has(normalized)) {\n const styleElement = ensureStyleElement();\n if (styleElement) {\n const rule = `.${className}{${normalized}}`;\n styleElement.textContent = `${styleElement.textContent ?? \"\"}\\n${rule}`;\n registeredDeclarations.add(normalized);\n }\n }\n\n return className;\n}\n"],"mappings":";AAmBA,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAE3B,MAAM,kCAAkB,IAAI,KAAqB;AACjD,MAAM,yCAAyB,IAAI,KAAa;AAEhD,IAAI,mBAAmB;AAEvB,SAAS,qBAA8C;CACrD,IAAI,OAAO,aAAa,aAAa,OAAO;CAE5C,MAAM,WAAW,SAAS,cAAc,SAAS,oBAAoB,GAAG;CACxE,IAAI,oBAAoB,kBACtB,OAAO;CAGT,MAAM,eAAe,SAAS,cAAc,QAAQ;CACpD,aAAa,aAAa,qBAAqB,OAAO;CACtD,CAAC,SAAS,QAAQ,SAAS,iBAAiB,OAAO,aAAa;CAEhE,OAAO;;AAGT,SAAS,sBAAsB,cAA8B;CAC3D,OAAO,aAAa,MAAM,CAAC,QAAQ,UAAU,GAAG;;AAGlD,SAAgB,yBAAyB,cAAsD;CAC7F,IAAI,OAAO,iBAAiB,UAAU,OAAO,KAAA;CAE7C,MAAM,aAAa,sBAAsB,aAAa;CACtD,IAAI,CAAC,YAAY,OAAO,KAAA;CAExB,IAAI,YAAY,gBAAgB,IAAI,WAAW;CAC/C,IAAI,cAAc,KAAA,GAAW;EAC3B,YAAY,GAAG,qBAAqB,EAAE;EACtC,gBAAgB,IAAI,YAAY,UAAU;;CAG5C,IAAI,CAAC,uBAAuB,IAAI,WAAW,EAAE;EAC3C,MAAM,eAAe,oBAAoB;EACzC,IAAI,cAAc;GAChB,MAAM,OAAO,IAAI,UAAU,GAAG,WAAW;GACzC,aAAa,cAAc,GAAG,aAAa,eAAe,GAAG,IAAI;GACjE,uBAAuB,IAAI,WAAW;;;CAI1C,OAAO"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { classes } from "../_internal/classes.js";
|
|
2
|
+
import { Close } from "../close/close.js";
|
|
3
|
+
import { jsx, jsxs } from "@askrjs/askr/jsx-runtime";
|
|
4
|
+
//#region src/components/alert/alert.tsx
|
|
5
|
+
function resolveAlertRole(variant) {
|
|
6
|
+
if (variant === "danger" || variant === "warning") return "alert";
|
|
7
|
+
return "status";
|
|
8
|
+
}
|
|
9
|
+
function Alert(props) {
|
|
10
|
+
const { actions, children, class: className, description, dismissLabel = "Dismiss alert", dismissible = false, icon, onDismiss, ref, title, titleAs: TitleTag = "h3", variant = "default", role, ...rest } = props;
|
|
11
|
+
const shouldRenderDismiss = dismissible && onDismiss !== void 0;
|
|
12
|
+
const resolvedRole = role ?? resolveAlertRole(variant);
|
|
13
|
+
const hasVariant = variant !== "default";
|
|
14
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
15
|
+
...rest,
|
|
16
|
+
ref,
|
|
17
|
+
class: classes("alert", hasVariant ? `alert-${variant}` : void 0, shouldRenderDismiss ? "alert-dismissible" : void 0, className),
|
|
18
|
+
"data-dismissible": shouldRenderDismiss ? "true" : void 0,
|
|
19
|
+
"data-slot": "alert",
|
|
20
|
+
"data-variant": hasVariant ? variant : void 0,
|
|
21
|
+
role: resolvedRole,
|
|
22
|
+
children: [
|
|
23
|
+
icon !== void 0 ? /* @__PURE__ */ jsx("div", {
|
|
24
|
+
"aria-hidden": "true",
|
|
25
|
+
class: "alert-icon",
|
|
26
|
+
"data-slot": "alert-icon",
|
|
27
|
+
children: icon
|
|
28
|
+
}) : null,
|
|
29
|
+
/* @__PURE__ */ jsxs("div", {
|
|
30
|
+
class: "alert-content",
|
|
31
|
+
"data-slot": "alert-content",
|
|
32
|
+
children: [
|
|
33
|
+
title !== void 0 ? /* @__PURE__ */ jsx(TitleTag, {
|
|
34
|
+
class: "alert-title",
|
|
35
|
+
"data-slot": "alert-title",
|
|
36
|
+
children: title
|
|
37
|
+
}) : null,
|
|
38
|
+
description !== void 0 ? /* @__PURE__ */ jsx("p", {
|
|
39
|
+
class: "alert-description",
|
|
40
|
+
"data-slot": "alert-description",
|
|
41
|
+
children: description
|
|
42
|
+
}) : null,
|
|
43
|
+
children,
|
|
44
|
+
actions !== void 0 ? /* @__PURE__ */ jsx("div", {
|
|
45
|
+
class: "alert-actions",
|
|
46
|
+
"data-slot": "alert-actions",
|
|
47
|
+
children: actions
|
|
48
|
+
}) : null
|
|
49
|
+
]
|
|
50
|
+
}),
|
|
51
|
+
shouldRenderDismiss ? /* @__PURE__ */ jsx("div", {
|
|
52
|
+
class: "alert-close",
|
|
53
|
+
"data-slot": "alert-close",
|
|
54
|
+
children: /* @__PURE__ */ jsx(Close, {
|
|
55
|
+
label: dismissLabel,
|
|
56
|
+
onPress: onDismiss
|
|
57
|
+
})
|
|
58
|
+
}) : null
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { Alert };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=alert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.js","names":[],"sources":["../../../src/components/alert/alert.tsx"],"sourcesContent":["import { classes } from \"../_internal/classes\";\nimport { Close } from \"../close\";\nimport type { AlertProps } from \"./alert.types\";\n\nfunction resolveAlertRole(variant: AlertProps[\"variant\"] | undefined): \"alert\" | \"status\" {\n if (variant === \"danger\" || variant === \"warning\") {\n return \"alert\";\n }\n\n return \"status\";\n}\n\nexport function Alert(props: AlertProps): JSX.Element {\n const {\n actions,\n children,\n class: className,\n description,\n dismissLabel = \"Dismiss alert\",\n dismissible = false,\n icon,\n onDismiss,\n ref,\n title,\n titleAs: TitleTag = \"h3\",\n variant = \"default\",\n role,\n ...rest\n } = props;\n const shouldRenderDismiss = dismissible && onDismiss !== undefined;\n const resolvedRole = role ?? resolveAlertRole(variant);\n const hasVariant = variant !== \"default\";\n\n return (\n <div\n {...rest}\n ref={ref}\n class={classes(\n \"alert\",\n hasVariant ? `alert-${variant}` : undefined,\n shouldRenderDismiss ? \"alert-dismissible\" : undefined,\n className,\n )}\n data-dismissible={shouldRenderDismiss ? \"true\" : undefined}\n data-slot=\"alert\"\n data-variant={hasVariant ? variant : undefined}\n role={resolvedRole}\n >\n {icon !== undefined ? (\n <div aria-hidden=\"true\" class=\"alert-icon\" data-slot=\"alert-icon\">\n {icon}\n </div>\n ) : null}\n\n <div class=\"alert-content\" data-slot=\"alert-content\">\n {title !== undefined ? (\n <TitleTag class=\"alert-title\" data-slot=\"alert-title\">\n {title}\n </TitleTag>\n ) : null}\n\n {description !== undefined ? (\n <p class=\"alert-description\" data-slot=\"alert-description\">\n {description}\n </p>\n ) : null}\n\n {children}\n\n {actions !== undefined ? (\n <div class=\"alert-actions\" data-slot=\"alert-actions\">\n {actions}\n </div>\n ) : null}\n </div>\n\n {shouldRenderDismiss ? (\n <div class=\"alert-close\" data-slot=\"alert-close\">\n <Close label={dismissLabel} onPress={onDismiss} />\n </div>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;AAIA,SAAS,iBAAiB,SAAgE;CACxF,IAAI,YAAY,YAAY,YAAY,WACtC,OAAO;CAGT,OAAO;;AAGT,SAAgB,MAAM,OAAgC;CACpD,MAAM,EACJ,SACA,UACA,OAAO,WACP,aACA,eAAe,iBACf,cAAc,OACd,MACA,WACA,KACA,OACA,SAAS,WAAW,MACpB,UAAU,WACV,MACA,GAAG,SACD;CACJ,MAAM,sBAAsB,eAAe,cAAc,KAAA;CACzD,MAAM,eAAe,QAAQ,iBAAiB,QAAQ;CACtD,MAAM,aAAa,YAAY;CAE/B,OACE,qBAAC,OAAD;EACE,GAAI;EACC;EACL,OAAO,QACL,SACA,aAAa,SAAS,YAAY,KAAA,GAClC,sBAAsB,sBAAsB,KAAA,GAC5C,UACD;EACD,oBAAkB,sBAAsB,SAAS,KAAA;EACjD,aAAU;EACV,gBAAc,aAAa,UAAU,KAAA;EACrC,MAAM;YAZR;GAcG,SAAS,KAAA,IACR,oBAAC,OAAD;IAAK,eAAY;IAAO,OAAM;IAAa,aAAU;cAClD;IACG,CAAA,GACJ;GAEJ,qBAAC,OAAD;IAAK,OAAM;IAAgB,aAAU;cAArC;KACG,UAAU,KAAA,IACT,oBAAC,UAAD;MAAU,OAAM;MAAc,aAAU;gBACrC;MACQ,CAAA,GACT;KAEH,gBAAgB,KAAA,IACf,oBAAC,KAAD;MAAG,OAAM;MAAoB,aAAU;gBACpC;MACC,CAAA,GACF;KAEH;KAEA,YAAY,KAAA,IACX,oBAAC,OAAD;MAAK,OAAM;MAAgB,aAAU;gBAClC;MACG,CAAA,GACJ;KACA;;GAEL,sBACC,oBAAC,OAAD;IAAK,OAAM;IAAc,aAAU;cACjC,oBAAC,OAAD;KAAO,OAAO;KAAc,SAAS;KAAa,CAAA;IAC9C,CAAA,GACJ;GACA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Ref } from "@askrjs/askr/foundations/utilities";
|
|
2
|
+
|
|
3
|
+
//#region src/components/alert/alert.types.d.ts
|
|
4
|
+
type AlertVariant = "default" | "info" | "success" | "warning" | "danger";
|
|
5
|
+
type AlertHeadingTag = "h2" | "h3" | "h4" | "h5" | "h6";
|
|
6
|
+
type DivProps = Omit<JSX.IntrinsicElements["div"], "children" | "ref">;
|
|
7
|
+
type AlertProps = DivProps & {
|
|
8
|
+
actions?: unknown;
|
|
9
|
+
children?: unknown;
|
|
10
|
+
description?: unknown;
|
|
11
|
+
dismissLabel?: string;
|
|
12
|
+
dismissible?: boolean;
|
|
13
|
+
icon?: unknown;
|
|
14
|
+
onDismiss?: () => void;
|
|
15
|
+
title?: unknown;
|
|
16
|
+
titleAs?: AlertHeadingTag;
|
|
17
|
+
variant?: AlertVariant;
|
|
18
|
+
ref?: Ref<HTMLDivElement>;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { AlertHeadingTag, AlertProps, AlertVariant };
|
|
22
|
+
//# sourceMappingURL=alert.types.d.ts.map
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { AspectRatioAsChildProps, AspectRatioProps } from "./aspect-ratio.types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/aspect-ratio/aspect-ratio.d.ts
|
|
4
|
+
declare function AspectRatio(props: AspectRatioProps): JSX.Element;
|
|
5
|
+
declare function AspectRatio(props: AspectRatioAsChildProps): JSX.Element;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { AspectRatio };
|
|
8
|
+
//# sourceMappingURL=aspect-ratio.d.ts.map
|