@askrjs/themes 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -13
- package/THEMING.md +24 -18
- package/dist/components/_internal/block-layout.d.ts +49 -0
- package/dist/components/_internal/block-layout.js +210 -0
- package/dist/components/_internal/block-layout.js.map +1 -0
- package/dist/components/_internal/jsx.js.map +1 -1
- package/dist/components/_internal/style.js +25 -1
- package/dist/components/_internal/style.js.map +1 -1
- package/dist/components/alert/alert.js +2 -2
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert/alert.types.d.ts +0 -1
- package/dist/components/aside/aside.d.ts +7 -0
- package/dist/components/aside/aside.js +16 -0
- package/dist/components/aside/aside.js.map +1 -0
- package/dist/components/aside/aside.types.d.ts +6 -0
- package/dist/components/aside/index.d.ts +2 -0
- package/dist/components/aspect-ratio/aspect-ratio.js +1 -1
- package/dist/components/aspect-ratio/aspect-ratio.js.map +1 -1
- package/dist/components/badge/index.d.ts +1 -2
- package/dist/components/block/block.d.ts +2 -3
- package/dist/components/block/block.js +16 -46
- package/dist/components/block/block.js.map +1 -1
- package/dist/components/block/block.types.d.ts +13 -23
- package/dist/components/block/index.d.ts +3 -3
- package/dist/components/brand/brand.d.ts +9 -0
- package/dist/components/brand/brand.js +49 -0
- package/dist/components/brand/brand.js.map +1 -0
- package/dist/components/brand/brand.types.d.ts +31 -0
- package/dist/components/brand/index.d.ts +2 -0
- package/dist/components/card/card.d.ts +3 -3
- package/dist/components/card/card.js +6 -11
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/card/card.types.d.ts +10 -12
- package/dist/components/card/index.d.ts +2 -2
- package/dist/components/catalog.d.ts +156 -0
- package/dist/components/catalog.js +723 -0
- package/dist/components/catalog.js.map +1 -0
- package/dist/components/container/container.d.ts +2 -3
- package/dist/components/container/container.js +8 -71
- package/dist/components/container/container.js.map +1 -1
- package/dist/components/container/container.types.d.ts +5 -24
- package/dist/components/container/index.d.ts +2 -3
- package/dist/components/empty-state/empty-state.js +34 -28
- package/dist/components/empty-state/empty-state.js.map +1 -1
- package/dist/components/empty-state/empty-state.types.d.ts +3 -6
- package/dist/components/field/field.js +4 -2
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/field/field.types.d.ts +1 -0
- package/dist/components/footer/footer.d.ts +13 -0
- package/dist/components/footer/footer.js +86 -0
- package/dist/components/footer/footer.js.map +1 -0
- package/dist/components/footer/footer.types.d.ts +37 -0
- package/dist/components/footer/index.d.ts +2 -0
- package/dist/components/grid/grid.d.ts +7 -0
- package/dist/components/grid/grid.js +76 -0
- package/dist/components/grid/grid.js.map +1 -0
- package/dist/components/grid/grid.types.d.ts +19 -0
- package/dist/components/grid/index.d.ts +2 -0
- package/dist/components/header/header.js +9 -6
- package/dist/components/header/header.js.map +1 -1
- package/dist/components/header/header.types.d.ts +5 -5
- package/dist/components/header/index.d.ts +2 -0
- package/dist/components/main/index.d.ts +2 -0
- package/dist/components/main/main.d.ts +7 -0
- package/dist/components/main/main.js +17 -0
- package/dist/components/main/main.js.map +1 -0
- package/dist/components/main/main.types.d.ts +6 -0
- package/dist/components/nav/index.d.ts +2 -2
- package/dist/components/nav/nav.d.ts +8 -6
- package/dist/components/nav/nav.js +93 -58
- package/dist/components/nav/nav.js.map +1 -1
- package/dist/components/nav/nav.types.d.ts +16 -20
- package/dist/components/navbar/index.d.ts +4 -5
- package/dist/components/navbar/navbar.d.ts +3 -38
- package/dist/components/navbar/navbar.js +102 -198
- package/dist/components/navbar/navbar.js.map +1 -1
- package/dist/components/navbar/navbar.types.d.ts +14 -24
- package/dist/components/page/index.d.ts +2 -0
- package/dist/components/page/page.d.ts +7 -0
- package/dist/components/page/page.js +22 -0
- package/dist/components/page/page.js.map +1 -0
- package/dist/components/page/page.types.d.ts +6 -0
- package/dist/components/page-header/index.d.ts +2 -0
- package/dist/components/page-header/page-header.d.ts +7 -0
- package/dist/components/page-header/page-header.js +37 -0
- package/dist/components/page-header/page-header.js.map +1 -0
- package/dist/components/page-header/page-header.types.d.ts +10 -0
- package/dist/components/section/index.d.ts +2 -3
- package/dist/components/section/section.d.ts +2 -3
- package/dist/components/section/section.js +7 -30
- package/dist/components/section/section.js.map +1 -1
- package/dist/components/section/section.types.d.ts +3 -20
- package/dist/components/separator/index.d.ts +1 -2
- package/dist/components/sidebar/index.d.ts +2 -0
- package/dist/components/sidebar/sidebar.d.ts +17 -2
- package/dist/components/sidebar/sidebar.js +115 -211
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/sidebar/sidebar.types.d.ts +21 -23
- package/dist/components/skeleton/index.d.ts +1 -2
- package/dist/components/skeleton/skeleton.js +12 -1
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/skeleton/skeleton.types.d.ts +2 -0
- package/dist/components/spinner/index.d.ts +1 -1
- package/dist/components/spinner/spinner.js +6 -3
- package/dist/components/spinner/spinner.js.map +1 -1
- package/dist/components/spinner/spinner.types.d.ts +3 -1
- package/dist/components/stat/index.d.ts +2 -0
- package/dist/components/stat/stat.d.ts +10 -0
- package/dist/components/stat/stat.js +52 -0
- package/dist/components/stat/stat.js.map +1 -0
- package/dist/components/stat/stat.types.d.ts +24 -0
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/text.d.ts +7 -0
- package/dist/components/text/text.js +28 -0
- package/dist/components/text/text.js.map +1 -0
- package/dist/components/text/text.types.d.ts +26 -0
- package/dist/components/theme/theme.js +97 -18
- package/dist/components/theme/theme.js.map +1 -1
- package/dist/components/toolbar/index.d.ts +2 -0
- package/dist/components/toolbar/toolbar.d.ts +7 -0
- package/dist/components/toolbar/toolbar.js +30 -0
- package/dist/components/toolbar/toolbar.js.map +1 -0
- package/dist/components/toolbar/toolbar.types.d.ts +9 -0
- package/dist/components.d.ts +60 -0
- package/dist/components.js +35 -0
- package/dist/controls.d.ts +2 -2
- package/dist/controls.js +3 -3
- package/dist/core.d.ts +36 -0
- package/dist/core.js +19 -0
- package/dist/navs.d.ts +3 -15
- package/dist/navs.js +2 -8
- package/dist/overlays.d.ts +2 -2
- package/dist/overlays.js +2 -2
- package/dist/surfaces.d.ts +10 -8
- package/dist/surfaces.js +6 -4
- package/dist/themes/default/index.css +3691 -3959
- package/package.json +239 -73
- package/src/components/_internal/block-layout.ts +354 -0
- package/src/components/_internal/jsx.ts +18 -6
- package/src/components/_internal/style.ts +42 -4
- package/src/components/alert/alert.tsx +1 -2
- package/src/components/alert/alert.types.ts +0 -1
- package/src/components/aside/aside.tsx +12 -0
- package/src/components/aside/aside.types.ts +3 -0
- package/src/components/aside/index.ts +2 -0
- package/src/components/aspect-ratio/aspect-ratio.tsx +1 -1
- package/src/components/badge/index.ts +0 -1
- package/src/components/block/block.a11y.ts +0 -6
- package/src/components/block/block.tsx +40 -56
- package/src/components/block/block.types.ts +59 -41
- package/src/components/block/index.ts +1 -10
- package/src/components/brand/brand.tsx +61 -0
- package/src/components/brand/brand.types.ts +39 -0
- package/src/components/brand/index.ts +2 -0
- package/src/components/card/card.tsx +6 -18
- package/src/components/card/card.types.ts +9 -11
- package/src/components/card/index.ts +2 -3
- package/src/components/catalog.tsx +713 -0
- package/src/components/container/container.a11y.ts +0 -5
- package/src/components/container/container.tsx +18 -128
- package/src/components/container/container.types.ts +3 -32
- package/src/components/container/index.ts +1 -8
- package/src/components/empty-state/empty-state.tsx +17 -35
- package/src/components/empty-state/empty-state.types.ts +3 -5
- package/src/components/field/field.tsx +3 -1
- package/src/components/field/field.types.ts +1 -0
- package/src/components/footer/footer.tsx +88 -0
- package/src/components/footer/footer.types.ts +40 -0
- package/src/components/footer/index.ts +10 -0
- package/src/components/grid/grid.tsx +113 -0
- package/src/components/grid/grid.types.ts +20 -0
- package/src/components/grid/index.ts +2 -0
- package/src/components/header/header.tsx +10 -7
- package/src/components/header/header.types.ts +4 -4
- package/src/components/header/index.ts +1 -2
- package/src/components/main/index.ts +2 -0
- package/src/components/main/main.tsx +12 -0
- package/src/components/main/main.types.ts +3 -0
- package/src/components/nav/index.ts +7 -9
- package/src/components/nav/nav.tsx +153 -110
- package/src/components/nav/nav.types.ts +26 -27
- package/src/components/navbar/index.ts +4 -11
- package/src/components/navbar/navbar.tsx +104 -251
- package/src/components/navbar/navbar.types.ts +16 -42
- package/src/components/page/index.ts +2 -0
- package/src/components/page/page.tsx +17 -0
- package/src/components/page/page.types.ts +3 -0
- package/src/components/page-header/index.ts +2 -0
- package/src/components/page-header/page-header.tsx +29 -0
- package/src/components/page-header/page-header.types.ts +7 -0
- package/src/components/section/index.ts +1 -7
- package/src/components/section/section.a11y.ts +0 -1
- package/src/components/section/section.tsx +9 -35
- package/src/components/section/section.types.ts +2 -22
- package/src/components/separator/index.ts +4 -9
- package/src/components/sidebar/index.ts +27 -5
- package/src/components/sidebar/sidebar.tsx +145 -317
- package/src/components/sidebar/sidebar.types.ts +21 -28
- package/src/components/skeleton/index.ts +1 -2
- package/src/components/skeleton/skeleton.tsx +33 -1
- package/src/components/skeleton/skeleton.types.ts +2 -0
- package/src/components/spinner/index.ts +1 -1
- package/src/components/spinner/spinner.tsx +7 -2
- package/src/components/spinner/spinner.types.ts +3 -0
- package/src/components/stat/index.ts +2 -0
- package/src/components/stat/stat.tsx +47 -0
- package/src/components/stat/stat.types.ts +24 -0
- package/src/components/text/index.ts +2 -0
- package/src/components/text/text.tsx +39 -0
- package/src/components/text/text.types.ts +35 -0
- package/src/components/theme/theme.tsx +163 -21
- package/src/components/toolbar/index.ts +2 -0
- package/src/components/toolbar/toolbar.tsx +24 -0
- package/src/components/toolbar/toolbar.types.ts +6 -0
- package/src/components.ts +289 -0
- package/src/controls.ts +69 -2
- package/src/core.ts +42 -0
- package/src/navs.ts +9 -24
- package/src/overlays.ts +101 -59
- package/src/parity.ts +125 -0
- package/src/surfaces.ts +60 -13
- package/src/themes/default/index.css +11 -14
- package/src/themes/default/styles/actions/button-group.css +6 -6
- package/src/themes/default/styles/actions/button.css +98 -60
- package/src/themes/default/styles/actions/toggle-group.css +61 -25
- package/src/themes/default/styles/base/text.css +87 -0
- package/src/themes/default/styles/base/typography.css +24 -117
- package/src/themes/default/styles/base/utilities.css +0 -250
- package/src/themes/default/styles/disclosure/accordion.css +35 -28
- package/src/themes/default/styles/display/alert.css +7 -7
- package/src/themes/default/styles/display/avatar.css +7 -1
- package/src/themes/default/styles/display/badge.css +10 -10
- package/src/themes/default/styles/display/card.css +10 -47
- package/src/themes/default/styles/display/catalog.css +753 -0
- package/src/themes/default/styles/display/coverage.css +30 -305
- package/src/themes/default/styles/display/progress-circle.css +2 -0
- package/src/themes/default/styles/display/scroll-area.css +29 -24
- package/src/themes/default/styles/display/spinner.css +38 -1
- package/src/themes/default/styles/display/stat.css +21 -0
- package/src/themes/default/styles/display/table.css +39 -12
- package/src/themes/default/styles/display/virtual-list.css +24 -13
- package/src/themes/default/styles/display/virtual-table.css +58 -36
- package/src/themes/default/styles/forms/checkbox.css +12 -21
- package/src/themes/default/styles/forms/input-group.css +2 -1
- package/src/themes/default/styles/forms/input.css +11 -12
- package/src/themes/default/styles/forms/radio-group.css +44 -27
- package/src/themes/default/styles/forms/select.css +33 -35
- package/src/themes/default/styles/forms/slider.css +61 -47
- package/src/themes/default/styles/forms/switch.css +18 -23
- package/src/themes/default/styles/forms/textarea.css +12 -12
- package/src/themes/default/styles/layout/block.css +96 -12
- package/src/themes/default/styles/layout/grid.css +78 -0
- package/src/themes/default/styles/layout/layout.css +502 -772
- package/src/themes/default/styles/layout/patterns.css +0 -155
- package/src/themes/default/styles/navigation/nav.css +104 -154
- package/src/themes/default/styles/overlays/alert-dialog.css +2 -2
- package/src/themes/default/styles/overlays/dialog.css +76 -22
- package/src/themes/default/styles/overlays/dropdown.css +108 -31
- package/src/themes/default/styles/overlays/hover-card.css +39 -17
- package/src/themes/default/styles/overlays/menubar.css +223 -0
- package/src/themes/default/styles/overlays/popover.css +69 -23
- package/src/themes/default/styles/overlays/toast.css +91 -33
- package/src/themes/default/styles/overlays/tooltip.css +88 -14
- package/src/themes/default/styles/shell/brand.css +48 -0
- package/src/themes/default/styles/shell/footer.css +72 -0
- package/src/themes/default/styles/shell/header.css +7 -50
- package/src/themes/default/styles/shell/navbar.css +226 -453
- package/src/themes/default/styles/shell/sidebar.css +243 -829
- package/src/themes/default/tokens.css +145 -98
- package/templates/theme/index.css +11 -14
- package/templates/theme/styles/actions/button-group.css +6 -6
- package/templates/theme/styles/actions/button.css +98 -60
- package/templates/theme/styles/actions/toggle-group.css +61 -25
- package/templates/theme/styles/base/text.css +87 -0
- package/templates/theme/styles/base/typography.css +24 -117
- package/templates/theme/styles/disclosure/accordion.css +35 -28
- package/templates/theme/styles/display/alert.css +7 -7
- package/templates/theme/styles/display/avatar.css +7 -1
- package/templates/theme/styles/display/badge.css +10 -10
- package/templates/theme/styles/display/card.css +10 -47
- package/templates/theme/styles/display/catalog.css +753 -0
- package/templates/theme/styles/display/coverage.css +30 -305
- package/templates/theme/styles/display/scroll-area.css +29 -24
- package/templates/theme/styles/display/spinner.css +38 -1
- package/templates/theme/styles/display/stat.css +21 -0
- package/templates/theme/styles/display/table.css +39 -12
- package/templates/theme/styles/display/virtual-list.css +24 -13
- package/templates/theme/styles/display/virtual-table.css +58 -36
- package/templates/theme/styles/forms/checkbox.css +12 -21
- package/templates/theme/styles/forms/input.css +11 -12
- package/templates/theme/styles/forms/radio-group.css +44 -27
- package/templates/theme/styles/forms/select.css +33 -35
- package/templates/theme/styles/forms/slider.css +61 -47
- package/templates/theme/styles/forms/switch.css +18 -23
- package/templates/theme/styles/forms/textarea.css +12 -12
- package/templates/theme/styles/layout/block.css +96 -12
- package/templates/theme/styles/layout/grid.css +78 -0
- package/templates/theme/styles/layout/layout.css +676 -1
- package/templates/theme/styles/layout/patterns.css +0 -155
- package/templates/theme/styles/navigation/nav.css +104 -154
- package/templates/theme/styles/overlays/alert-dialog.css +2 -2
- package/templates/theme/styles/overlays/dialog.css +76 -22
- package/templates/theme/styles/overlays/dropdown.css +108 -31
- package/templates/theme/styles/overlays/hover-card.css +39 -17
- package/templates/theme/styles/overlays/menubar.css +223 -0
- package/templates/theme/styles/overlays/popover.css +69 -23
- package/templates/theme/styles/overlays/toast.css +80 -33
- package/templates/theme/styles/overlays/tooltip.css +88 -14
- package/templates/theme/styles/shell/brand.css +48 -0
- package/templates/theme/styles/shell/footer.css +72 -0
- package/templates/theme/styles/shell/header.css +7 -50
- package/templates/theme/styles/shell/navbar.css +226 -453
- package/templates/theme/styles/shell/sidebar.css +197 -779
- package/templates/theme/tokens.css +145 -98
- package/dist/components/_internal/box-layout.js +0 -116
- package/dist/components/_internal/box-layout.js.map +0 -1
- package/dist/components/_internal/layout.d.ts +0 -9
- package/dist/components/_internal/layout.js +0 -147
- package/dist/components/_internal/layout.js.map +0 -1
- package/dist/components/badge/badge.a11y.d.ts +0 -17
- package/dist/components/block/block.a11y.d.ts +0 -20
- package/dist/components/box/box.a11y.d.ts +0 -14
- package/dist/components/box/box.d.ts +0 -9
- package/dist/components/box/box.js +0 -36
- package/dist/components/box/box.js.map +0 -1
- package/dist/components/box/box.types.d.ts +0 -72
- package/dist/components/box/index.d.ts +0 -3
- package/dist/components/breadcrumb/breadcrumb.a11y.d.ts +0 -17
- package/dist/components/breadcrumb/breadcrumb.a11y.js +0 -15
- package/dist/components/breadcrumb/breadcrumb.a11y.js.map +0 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts +0 -18
- package/dist/components/breadcrumb/breadcrumb.js +0 -113
- package/dist/components/breadcrumb/breadcrumb.js.map +0 -1
- package/dist/components/breadcrumb/breadcrumb.types.d.ts +0 -65
- package/dist/components/breadcrumb/index.d.ts +0 -3
- package/dist/components/container/container.a11y.d.ts +0 -19
- package/dist/components/flex/flex.a11y.d.ts +0 -22
- package/dist/components/flex/flex.d.ts +0 -9
- package/dist/components/flex/flex.js +0 -115
- package/dist/components/flex/flex.js.map +0 -1
- package/dist/components/flex/flex.types.d.ts +0 -42
- package/dist/components/flex/index.d.ts +0 -3
- package/dist/components/header/header.a11y.d.ts +0 -14
- package/dist/components/header/header.a11y.js +0 -12
- package/dist/components/header/header.a11y.js.map +0 -1
- package/dist/components/inline/index.d.ts +0 -8
- package/dist/components/inline/index.js +0 -13
- package/dist/components/inline/index.js.map +0 -1
- package/dist/components/list-group/index.d.ts +0 -2
- package/dist/components/list-group/list-group.d.ts +0 -9
- package/dist/components/list-group/list-group.js +0 -43
- package/dist/components/list-group/list-group.js.map +0 -1
- package/dist/components/list-group/list-group.types.d.ts +0 -32
- package/dist/components/navbar/navbar-panel.js +0 -42
- package/dist/components/navbar/navbar-panel.js.map +0 -1
- package/dist/components/navbar/navbar.context.js +0 -13
- package/dist/components/navbar/navbar.context.js.map +0 -1
- package/dist/components/navbar/navbar.render.js +0 -26
- package/dist/components/navbar/navbar.render.js.map +0 -1
- package/dist/components/navbar/navbar.shared.js +0 -18
- package/dist/components/navbar/navbar.shared.js.map +0 -1
- package/dist/components/pagination/index.d.ts +0 -2
- package/dist/components/pagination/pagination.d.ts +0 -11
- package/dist/components/pagination/pagination.js +0 -95
- package/dist/components/pagination/pagination.js.map +0 -1
- package/dist/components/pagination/pagination.types.d.ts +0 -40
- package/dist/components/section/section.a11y.d.ts +0 -15
- package/dist/components/separator/separator.a11y.d.ts +0 -17
- package/dist/components/separator/separator.a11y.js +0 -15
- package/dist/components/separator/separator.a11y.js.map +0 -1
- package/dist/components/shell/index.d.ts +0 -3
- package/dist/components/shell/shell-nav.types.d.ts +0 -7
- package/dist/components/shell/shell-panel.js +0 -54
- package/dist/components/shell/shell-panel.js.map +0 -1
- package/dist/components/shell/shell-responsive.js +0 -118
- package/dist/components/shell/shell-responsive.js.map +0 -1
- package/dist/components/shell/shell.a11y.d.ts +0 -23
- package/dist/components/shell/shell.a11y.js +0 -23
- package/dist/components/shell/shell.a11y.js.map +0 -1
- package/dist/components/shell/shell.d.ts +0 -13
- package/dist/components/shell/shell.js +0 -69
- package/dist/components/shell/shell.js.map +0 -1
- package/dist/components/shell/shell.types.d.ts +0 -58
- package/dist/components/sidebar/sidebar-panel.d.ts +0 -7
- package/dist/components/sidebar/sidebar-panel.js +0 -49
- package/dist/components/sidebar/sidebar-panel.js.map +0 -1
- package/dist/components/sidebar/sidebar-toggle.d.ts +0 -7
- package/dist/components/sidebar/sidebar-toggle.js +0 -8
- package/dist/components/sidebar/sidebar-toggle.js.map +0 -1
- package/dist/components/sidebar/sidebar.context.js +0 -21
- package/dist/components/sidebar/sidebar.context.js.map +0 -1
- package/dist/components/sidebar/sidebar.shared.js +0 -12
- package/dist/components/sidebar/sidebar.shared.js.map +0 -1
- package/dist/components/skeleton/skeleton.a11y.d.ts +0 -16
- package/dist/components/spacer/index.d.ts +0 -3
- package/dist/components/spacer/spacer.a11y.d.ts +0 -17
- package/dist/components/spacer/spacer.d.ts +0 -8
- package/dist/components/spacer/spacer.js +0 -49
- package/dist/components/spacer/spacer.js.map +0 -1
- package/dist/components/spacer/spacer.types.d.ts +0 -26
- package/dist/components/stack/index.d.ts +0 -3
- package/dist/components/stack/stack.a11y.d.ts +0 -18
- package/dist/components/stack/stack.d.ts +0 -8
- package/dist/components/stack/stack.js +0 -16
- package/dist/components/stack/stack.js.map +0 -1
- package/dist/components/stack/stack.types.d.ts +0 -22
- package/dist/feedback.d.ts +0 -5
- package/dist/feedback.js +0 -4
- package/dist/layouts.d.ts +0 -25
- package/dist/layouts.js +0 -11
- package/dist/shells.d.ts +0 -16
- package/dist/shells.js +0 -11
- package/src/components/_internal/box-layout.ts +0 -164
- package/src/components/_internal/layout.ts +0 -211
- package/src/components/box/box.a11y.ts +0 -11
- package/src/components/box/box.tsx +0 -38
- package/src/components/box/box.types.ts +0 -76
- package/src/components/box/index.ts +0 -11
- package/src/components/breadcrumb/breadcrumb.a11y.ts +0 -15
- package/src/components/breadcrumb/breadcrumb.tsx +0 -123
- package/src/components/breadcrumb/breadcrumb.types.ts +0 -74
- package/src/components/breadcrumb/index.ts +0 -24
- package/src/components/flex/flex.a11y.ts +0 -19
- package/src/components/flex/flex.tsx +0 -162
- package/src/components/flex/flex.types.ts +0 -51
- package/src/components/flex/index.ts +0 -16
- package/src/components/inline/index.tsx +0 -28
- package/src/components/list-group/index.ts +0 -7
- package/src/components/list-group/list-group.tsx +0 -74
- package/src/components/list-group/list-group.types.ts +0 -32
- package/src/components/navbar/navbar-panel.tsx +0 -62
- package/src/components/navbar/navbar.context.ts +0 -22
- package/src/components/navbar/navbar.render.tsx +0 -32
- package/src/components/navbar/navbar.shared.ts +0 -21
- package/src/components/pagination/index.ts +0 -8
- package/src/components/pagination/pagination.tsx +0 -158
- package/src/components/pagination/pagination.types.ts +0 -41
- package/src/components/shell/index.ts +0 -16
- package/src/components/shell/shell-nav.types.ts +0 -3
- package/src/components/shell/shell-panel.tsx +0 -85
- package/src/components/shell/shell-responsive.tsx +0 -246
- package/src/components/shell/shell.a11y.ts +0 -20
- package/src/components/shell/shell.tsx +0 -74
- package/src/components/shell/shell.types.ts +0 -71
- package/src/components/sidebar/sidebar-panel.tsx +0 -67
- package/src/components/sidebar/sidebar-toggle.tsx +0 -5
- package/src/components/sidebar/sidebar.context.ts +0 -40
- package/src/components/sidebar/sidebar.shared.ts +0 -12
- package/src/components/spacer/index.ts +0 -9
- package/src/components/spacer/spacer.a11y.ts +0 -14
- package/src/components/spacer/spacer.tsx +0 -61
- package/src/components/spacer/spacer.types.ts +0 -31
- package/src/components/stack/index.ts +0 -3
- package/src/components/stack/stack.a11y.ts +0 -15
- package/src/components/stack/stack.tsx +0 -13
- package/src/components/stack/stack.types.ts +0 -22
- package/src/feedback.ts +0 -6
- package/src/layouts.ts +0 -19
- package/src/shells.ts +0 -13
- package/src/themes/default/styles/actions/toggle.css +0 -50
- package/src/themes/default/styles/disclosure/collapsible.css +0 -58
- package/src/themes/default/styles/display/list-group.css +0 -84
- package/src/themes/default/styles/forms/form.css +0 -5
- package/src/themes/default/styles/layout/responsive-layout.css +0 -230
- package/src/themes/default/styles/navigation/breadcrumb.css +0 -45
- package/src/themes/default/styles/navigation/menu.css +0 -203
- package/src/themes/default/styles/navigation/menubar.css +0 -255
- package/src/themes/default/styles/navigation/pagination.css +0 -91
- package/src/themes/default/styles/shell/theme.css +0 -37
- package/templates/theme/styles/actions/toggle.css +0 -50
- package/templates/theme/styles/disclosure/collapsible.css +0 -58
- package/templates/theme/styles/display/list-group.css +0 -84
- package/templates/theme/styles/forms/form.css +0 -5
- package/templates/theme/styles/layout/responsive-layout.css +0 -230
- package/templates/theme/styles/navigation/breadcrumb.css +0 -45
- package/templates/theme/styles/navigation/menu.css +0 -203
- package/templates/theme/styles/navigation/menubar.css +0 -255
- package/templates/theme/styles/navigation/pagination.css +0 -91
- package/templates/theme/styles/shell/theme.css +0 -37
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ProgressCircleProps } from "@askrjs/ui";
|
|
2
2
|
|
|
3
3
|
//#region src/components/spinner/spinner.types.d.ts
|
|
4
|
+
type SpinnerSize = "sm" | "md" | "lg";
|
|
4
5
|
type SpinnerOwnProps = Omit<ProgressCircleProps, "value" | "getValueLabel"> & {
|
|
5
6
|
label?: string;
|
|
7
|
+
size?: SpinnerSize;
|
|
6
8
|
};
|
|
7
9
|
type SpinnerProps = SpinnerOwnProps;
|
|
8
10
|
//#endregion
|
|
9
|
-
export { SpinnerOwnProps, SpinnerProps };
|
|
11
|
+
export { SpinnerOwnProps, SpinnerProps, SpinnerSize };
|
|
10
12
|
//# sourceMappingURL=spinner.types.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StatDescriptionProps, StatLabelProps, StatProps, StatValueProps } from "./stat.types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/stat/stat.d.ts
|
|
4
|
+
declare function Stat(props: StatProps): JSX.Element;
|
|
5
|
+
declare function StatLabel(props: StatLabelProps): JSX.Element;
|
|
6
|
+
declare function StatValue(props: StatValueProps): JSX.Element;
|
|
7
|
+
declare function StatDescription(props: StatDescriptionProps): JSX.Element;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { Stat, StatDescription, StatLabel, StatValue };
|
|
10
|
+
//# sourceMappingURL=stat.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { classes } from "../_internal/classes.js";
|
|
2
|
+
import { mergeProps } from "../_internal/merge-props.js";
|
|
3
|
+
import { jsx } from "@askrjs/askr/jsx-runtime";
|
|
4
|
+
//#region src/components/stat/stat.tsx
|
|
5
|
+
function Stat(props) {
|
|
6
|
+
const { children, class: className, ref, ...rest } = props;
|
|
7
|
+
return /* @__PURE__ */ jsx("div", {
|
|
8
|
+
...mergeProps(rest, {
|
|
9
|
+
ref,
|
|
10
|
+
class: classes("stat", className),
|
|
11
|
+
"data-slot": "stat"
|
|
12
|
+
}),
|
|
13
|
+
children
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function StatLabel(props) {
|
|
17
|
+
const { children, class: className, ref, ...rest } = props;
|
|
18
|
+
return /* @__PURE__ */ jsx("p", {
|
|
19
|
+
...mergeProps(rest, {
|
|
20
|
+
ref,
|
|
21
|
+
class: classes("stat-label", className),
|
|
22
|
+
"data-slot": "stat-label"
|
|
23
|
+
}),
|
|
24
|
+
children
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function StatValue(props) {
|
|
28
|
+
const { children, class: className, ref, ...rest } = props;
|
|
29
|
+
return /* @__PURE__ */ jsx("p", {
|
|
30
|
+
...mergeProps(rest, {
|
|
31
|
+
ref,
|
|
32
|
+
class: classes("stat-value", className),
|
|
33
|
+
"data-slot": "stat-value"
|
|
34
|
+
}),
|
|
35
|
+
children
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function StatDescription(props) {
|
|
39
|
+
const { children, class: className, ref, ...rest } = props;
|
|
40
|
+
return /* @__PURE__ */ jsx("p", {
|
|
41
|
+
...mergeProps(rest, {
|
|
42
|
+
ref,
|
|
43
|
+
class: classes("stat-description", className),
|
|
44
|
+
"data-slot": "stat-description"
|
|
45
|
+
}),
|
|
46
|
+
children
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { Stat, StatDescription, StatLabel, StatValue };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=stat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stat.js","names":[],"sources":["../../../src/components/stat/stat.tsx"],"sourcesContent":["import { classes } from \"../_internal/classes\";\nimport { mergeProps } from \"../_internal/merge-props\";\nimport type { StatDescriptionProps, StatLabelProps, StatProps, StatValueProps } from \"./stat.types\";\n\nexport function Stat(props: StatProps): JSX.Element {\n const { children, class: className, ref, ...rest } = props;\n const finalProps = mergeProps(rest, {\n ref,\n class: classes(\"stat\", className),\n \"data-slot\": \"stat\",\n });\n\n return <div {...finalProps}>{children}</div>;\n}\n\nexport function StatLabel(props: StatLabelProps): JSX.Element {\n const { children, class: className, ref, ...rest } = props;\n const finalProps = mergeProps(rest, {\n ref,\n class: classes(\"stat-label\", className),\n \"data-slot\": \"stat-label\",\n });\n\n return <p {...finalProps}>{children}</p>;\n}\n\nexport function StatValue(props: StatValueProps): JSX.Element {\n const { children, class: className, ref, ...rest } = props;\n const finalProps = mergeProps(rest, {\n ref,\n class: classes(\"stat-value\", className),\n \"data-slot\": \"stat-value\",\n });\n\n return <p {...finalProps}>{children}</p>;\n}\n\nexport function StatDescription(props: StatDescriptionProps): JSX.Element {\n const { children, class: className, ref, ...rest } = props;\n const finalProps = mergeProps(rest, {\n ref,\n class: classes(\"stat-description\", className),\n \"data-slot\": \"stat-description\",\n });\n\n return <p {...finalProps}>{children}</p>;\n}\n"],"mappings":";;;;AAIA,SAAgB,KAAK,OAA+B;CAClD,MAAM,EAAE,UAAU,OAAO,WAAW,KAAK,GAAG,SAAS;CAOrD,OAAO,oBAAC,OAAD;EAAK,GANO,WAAW,MAAM;GAClC;GACA,OAAO,QAAQ,QAAQ,SAAS;GAChC,aAAa;EACf,CAEyB;EAAI;CAAc,CAAA;AAC7C;AAEA,SAAgB,UAAU,OAAoC;CAC5D,MAAM,EAAE,UAAU,OAAO,WAAW,KAAK,GAAG,SAAS;CAOrD,OAAO,oBAAC,KAAD;EAAG,GANS,WAAW,MAAM;GAClC;GACA,OAAO,QAAQ,cAAc,SAAS;GACtC,aAAa;EACf,CAEuB;EAAI;CAAY,CAAA;AACzC;AAEA,SAAgB,UAAU,OAAoC;CAC5D,MAAM,EAAE,UAAU,OAAO,WAAW,KAAK,GAAG,SAAS;CAOrD,OAAO,oBAAC,KAAD;EAAG,GANS,WAAW,MAAM;GAClC;GACA,OAAO,QAAQ,cAAc,SAAS;GACtC,aAAa;EACf,CAEuB;EAAI;CAAY,CAAA;AACzC;AAEA,SAAgB,gBAAgB,OAA0C;CACxE,MAAM,EAAE,UAAU,OAAO,WAAW,KAAK,GAAG,SAAS;CAOrD,OAAO,oBAAC,KAAD;EAAG,GANS,WAAW,MAAM;GAClC;GACA,OAAO,QAAQ,oBAAoB,SAAS;GAC5C,aAAa;EACf,CAEuB;EAAI;CAAY,CAAA;AACzC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Ref } from "@askrjs/askr/foundations/utilities";
|
|
2
|
+
|
|
3
|
+
//#region src/components/stat/stat.types.d.ts
|
|
4
|
+
type DivProps = Omit<JSX.IntrinsicElements["div"], "children" | "ref">;
|
|
5
|
+
type ParagraphProps = Omit<JSX.IntrinsicElements["p"], "children" | "ref">;
|
|
6
|
+
type StatProps = DivProps & {
|
|
7
|
+
children?: unknown;
|
|
8
|
+
ref?: Ref<HTMLDivElement>;
|
|
9
|
+
};
|
|
10
|
+
type StatLabelProps = ParagraphProps & {
|
|
11
|
+
children?: unknown;
|
|
12
|
+
ref?: Ref<HTMLParagraphElement>;
|
|
13
|
+
};
|
|
14
|
+
type StatValueProps = ParagraphProps & {
|
|
15
|
+
children?: unknown;
|
|
16
|
+
ref?: Ref<HTMLParagraphElement>;
|
|
17
|
+
};
|
|
18
|
+
type StatDescriptionProps = ParagraphProps & {
|
|
19
|
+
children?: unknown;
|
|
20
|
+
ref?: Ref<HTMLParagraphElement>;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { StatDescriptionProps, StatLabelProps, StatProps, StatValueProps };
|
|
24
|
+
//# sourceMappingURL=stat.types.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TextElement, TextProps } from "./text.types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/text/text.d.ts
|
|
4
|
+
declare function Text<TElement extends TextElement = "p">(props: TextProps<TElement>): JSX.Element;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { Text };
|
|
7
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { classes } from "../_internal/classes.js";
|
|
2
|
+
import { mergeProps } from "../_internal/merge-props.js";
|
|
3
|
+
import { jsx } from "@askrjs/askr/jsx-runtime";
|
|
4
|
+
//#region src/components/text/text.tsx
|
|
5
|
+
const DEFAULT_ELEMENT = "p";
|
|
6
|
+
function Text(props) {
|
|
7
|
+
const { as, size = "md", tone = "default", weight, font, numeric, wrap, truncate, children, class: classProp, className, ref, ...rest } = props;
|
|
8
|
+
const finalProps = mergeProps(rest, {
|
|
9
|
+
ref,
|
|
10
|
+
class: classes("text", classProp, className),
|
|
11
|
+
"data-slot": "text",
|
|
12
|
+
"data-size": size,
|
|
13
|
+
"data-tone": tone,
|
|
14
|
+
"data-weight": weight,
|
|
15
|
+
"data-font": font && font !== "body" ? font : void 0,
|
|
16
|
+
"data-numeric": numeric && numeric !== "normal" ? numeric : void 0,
|
|
17
|
+
"data-wrap": wrap,
|
|
18
|
+
"data-truncate": truncate ? "true" : void 0
|
|
19
|
+
});
|
|
20
|
+
return /* @__PURE__ */ jsx(as ?? DEFAULT_ELEMENT, {
|
|
21
|
+
...finalProps,
|
|
22
|
+
children
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Text };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../../src/components/text/text.tsx"],"sourcesContent":["import { classes } from \"../_internal/classes\";\nimport { mergeProps } from \"../_internal/merge-props\";\nimport type { TextElement, TextProps } from \"./text.types\";\n\nconst DEFAULT_ELEMENT = \"p\";\n\nexport function Text<TElement extends TextElement = \"p\">(props: TextProps<TElement>): JSX.Element {\n const {\n as,\n size = \"md\",\n tone = \"default\",\n weight,\n font,\n numeric,\n wrap,\n truncate,\n children,\n class: classProp,\n className,\n ref,\n ...rest\n } = props as TextProps<TextElement> & { class?: unknown; className?: unknown };\n\n const finalProps = mergeProps(rest, {\n ref,\n class: classes(\"text\", classProp, className),\n \"data-slot\": \"text\",\n \"data-size\": size,\n \"data-tone\": tone,\n \"data-weight\": weight,\n \"data-font\": font && font !== \"body\" ? font : undefined,\n \"data-numeric\": numeric && numeric !== \"normal\" ? numeric : undefined,\n \"data-wrap\": wrap,\n \"data-truncate\": truncate ? \"true\" : undefined,\n });\n\n const Element = (as ?? DEFAULT_ELEMENT) as keyof JSX.IntrinsicElements;\n return <Element {...finalProps}>{children}</Element>;\n}\n"],"mappings":";;;;AAIA,MAAM,kBAAkB;AAExB,SAAgB,KAAyC,OAAyC;CAChG,MAAM,EACJ,IACA,OAAO,MACP,OAAO,WACP,QACA,MACA,SACA,MACA,UACA,UACA,OAAO,WACP,WACA,KACA,GAAG,SACD;CAEJ,MAAM,aAAa,WAAW,MAAM;EAClC;EACA,OAAO,QAAQ,QAAQ,WAAW,SAAS;EAC3C,aAAa;EACb,aAAa;EACb,aAAa;EACb,eAAe;EACf,aAAa,QAAQ,SAAS,SAAS,OAAO,KAAA;EAC9C,gBAAgB,WAAW,YAAY,WAAW,UAAU,KAAA;EAC5D,aAAa;EACb,iBAAiB,WAAW,SAAS,KAAA;CACvC,CAAC;CAGD,OAAO,oBADU,MAAM,iBAChB;EAAS,GAAI;EAAa;CAAkB,CAAA;AACrD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Ref } from "@askrjs/askr/foundations/utilities";
|
|
2
|
+
|
|
3
|
+
//#region src/components/text/text.types.d.ts
|
|
4
|
+
type TextElement = "p" | "span" | "div" | "strong";
|
|
5
|
+
type TextSize = "sm" | "md" | "lg";
|
|
6
|
+
type TextTone = "default" | "muted" | "subtle" | "inverse" | "success" | "warning" | "danger" | "info";
|
|
7
|
+
type TextWeight = "normal" | "medium" | "semibold" | "bold";
|
|
8
|
+
type TextFont = "body" | "mono";
|
|
9
|
+
type TextNumeric = "normal" | "tabular";
|
|
10
|
+
type TextWrap = "normal" | "nowrap" | "anywhere";
|
|
11
|
+
type TextIntrinsicProps<TElement extends TextElement> = Omit<JSX.IntrinsicElements[TElement], "children" | "ref">;
|
|
12
|
+
type TextProps<TElement extends TextElement = "p"> = TextIntrinsicProps<TElement> & {
|
|
13
|
+
as?: TElement;
|
|
14
|
+
size?: TextSize;
|
|
15
|
+
tone?: TextTone;
|
|
16
|
+
weight?: TextWeight;
|
|
17
|
+
font?: TextFont;
|
|
18
|
+
numeric?: TextNumeric;
|
|
19
|
+
wrap?: TextWrap;
|
|
20
|
+
truncate?: boolean;
|
|
21
|
+
children?: unknown;
|
|
22
|
+
ref?: Ref<HTMLElement>;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { TextElement, TextFont, TextNumeric, TextProps, TextSize, TextTone, TextWeight, TextWrap };
|
|
26
|
+
//# sourceMappingURL=text.types.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Button } from "@askrjs/ui";
|
|
2
2
|
import { jsx, jsxs } from "@askrjs/askr/jsx-runtime";
|
|
3
|
-
import { defineContext, readContext, state } from "@askrjs/askr";
|
|
3
|
+
import { defineContext, getSignal, readContext, state } from "@askrjs/askr";
|
|
4
4
|
import { resource } from "@askrjs/askr/resources";
|
|
5
5
|
//#region src/components/theme/theme.tsx
|
|
6
6
|
const CAT_THEME_NAMES = [
|
|
@@ -47,6 +47,11 @@ const CAT_THEME_OPTIONS = [
|
|
|
47
47
|
}
|
|
48
48
|
];
|
|
49
49
|
const DEFAULT_STORAGE_KEY = "askr-theme";
|
|
50
|
+
const STATIC_CHILDREN = Symbol.for("askr.static-children");
|
|
51
|
+
const STATIC_CHILD_SLOTS_CACHE = Symbol.for("__askrStaticChildSlots");
|
|
52
|
+
let rootThemeRevision = 0;
|
|
53
|
+
let explicitRootThemeOwner;
|
|
54
|
+
const registeredProviderSignals = /* @__PURE__ */ new WeakSet();
|
|
50
55
|
const ThemeContext = defineContext({
|
|
51
56
|
theme: () => "system",
|
|
52
57
|
setTheme: () => void 0,
|
|
@@ -58,11 +63,21 @@ function useTheme() {
|
|
|
58
63
|
}
|
|
59
64
|
function ThemeProvider(props) {
|
|
60
65
|
const { children, defaultTheme = "system", themes = DEFAULT_THEME_OPTIONS, storageKey = DEFAULT_STORAGE_KEY } = props;
|
|
66
|
+
const providerId = state(Symbol("ThemeProvider"))();
|
|
67
|
+
const providerSignal = getSignal();
|
|
61
68
|
const themeState = state(readStoredTheme(storageKey) ?? defaultTheme);
|
|
62
69
|
const currentTheme = themeState();
|
|
70
|
+
if (!registeredProviderSignals.has(providerSignal)) {
|
|
71
|
+
registeredProviderSignals.add(providerSignal);
|
|
72
|
+
providerSignal.addEventListener("abort", () => {
|
|
73
|
+
if (explicitRootThemeOwner === providerId) explicitRootThemeOwner = void 0;
|
|
74
|
+
}, { once: true });
|
|
75
|
+
}
|
|
63
76
|
const setTheme = (nextTheme) => {
|
|
64
77
|
themeState.set(nextTheme);
|
|
65
78
|
writeStoredTheme(storageKey, nextTheme);
|
|
79
|
+
explicitRootThemeOwner = providerId;
|
|
80
|
+
rootThemeRevision += 1;
|
|
66
81
|
syncThemeRoot(nextTheme);
|
|
67
82
|
};
|
|
68
83
|
const value = {
|
|
@@ -73,21 +88,29 @@ function ThemeProvider(props) {
|
|
|
73
88
|
};
|
|
74
89
|
return /* @__PURE__ */ jsxs(ThemeContext.Scope, {
|
|
75
90
|
value,
|
|
76
|
-
children: [/* @__PURE__ */ jsx(ThemeRootSync, {
|
|
91
|
+
children: [/* @__PURE__ */ jsx(ThemeRootSync, {
|
|
92
|
+
providerId,
|
|
93
|
+
theme: currentTheme
|
|
94
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
77
95
|
"data-slot": "theme-provider",
|
|
78
96
|
children
|
|
79
97
|
})]
|
|
80
98
|
});
|
|
81
99
|
}
|
|
82
100
|
function ThemeRootSync(props) {
|
|
83
|
-
const { theme } = props;
|
|
101
|
+
const { providerId, theme } = props;
|
|
102
|
+
const expectedRootThemeRevision = rootThemeRevision;
|
|
84
103
|
resource(({ signal }) => {
|
|
85
104
|
if (typeof window === "undefined") {
|
|
86
105
|
syncThemeRoot(theme);
|
|
87
106
|
return null;
|
|
88
107
|
}
|
|
89
108
|
const timeoutId = window.setTimeout(() => {
|
|
90
|
-
if (!signal.aborted) syncThemeRoot(theme
|
|
109
|
+
if (!signal.aborted) syncThemeRoot(theme, {
|
|
110
|
+
expectedRevision: expectedRootThemeRevision,
|
|
111
|
+
passive: true,
|
|
112
|
+
providerId
|
|
113
|
+
});
|
|
91
114
|
}, 0);
|
|
92
115
|
signal.addEventListener("abort", () => {
|
|
93
116
|
window.clearTimeout(timeoutId);
|
|
@@ -99,26 +122,39 @@ function ThemeRootSync(props) {
|
|
|
99
122
|
function ThemePicker(props) {
|
|
100
123
|
const theme = useTheme();
|
|
101
124
|
const { themes = theme.themes, label = "Theme", ...rest } = props;
|
|
125
|
+
const currentTheme = theme.theme();
|
|
102
126
|
return /* @__PURE__ */ jsx("select", {
|
|
103
127
|
...rest,
|
|
104
128
|
"aria-label": rest["aria-label"] ?? label,
|
|
105
129
|
"data-slot": "theme-picker",
|
|
106
|
-
value:
|
|
130
|
+
value: currentTheme,
|
|
107
131
|
onChange: (event) => {
|
|
108
|
-
const target = event
|
|
109
|
-
theme.setTheme(target.value);
|
|
132
|
+
const target = getThemePickerTarget(event);
|
|
133
|
+
if (target) theme.setTheme(target.value);
|
|
110
134
|
},
|
|
111
135
|
children: themes.map((option) => /* @__PURE__ */ jsx("option", {
|
|
112
136
|
value: option.value,
|
|
137
|
+
selected: option.value === currentTheme,
|
|
113
138
|
children: option.label
|
|
114
139
|
}, option.value))
|
|
115
140
|
});
|
|
116
141
|
}
|
|
142
|
+
function getThemePickerTarget(event) {
|
|
143
|
+
if (typeof HTMLSelectElement === "undefined") return null;
|
|
144
|
+
const path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
145
|
+
const candidates = [
|
|
146
|
+
event.target,
|
|
147
|
+
event.currentTarget,
|
|
148
|
+
...path
|
|
149
|
+
];
|
|
150
|
+
for (const candidate of candidates) if (candidate instanceof HTMLSelectElement) return candidate;
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
117
153
|
function ThemeToggle(props) {
|
|
118
154
|
const theme = useTheme();
|
|
119
155
|
const { children, lightIcon, darkIcon, systemIcon, themes = ["light", "dark"], onPress, ...rest } = props;
|
|
120
156
|
const currentTheme = theme.theme();
|
|
121
|
-
const nextTheme = getNextTheme(currentTheme, themes);
|
|
157
|
+
const nextTheme = getNextTheme(currentTheme, themes, getResolvedSystemTheme());
|
|
122
158
|
const renderContext = {
|
|
123
159
|
theme: currentTheme,
|
|
124
160
|
nextTheme
|
|
@@ -128,8 +164,13 @@ function ThemeToggle(props) {
|
|
|
128
164
|
lightIcon,
|
|
129
165
|
darkIcon,
|
|
130
166
|
systemIcon
|
|
131
|
-
}));
|
|
132
|
-
const
|
|
167
|
+
}), currentTheme);
|
|
168
|
+
const renderedIconSlots = renderThemeToggleIconSlots(currentTheme, {
|
|
169
|
+
lightIcon,
|
|
170
|
+
darkIcon,
|
|
171
|
+
systemIcon
|
|
172
|
+
}) ?? renderedIcon;
|
|
173
|
+
const content = typeof children === "function" ? children(renderContext) : children ?? renderedIconSlots;
|
|
133
174
|
return /* @__PURE__ */ jsx(Button, {
|
|
134
175
|
...rest,
|
|
135
176
|
"aria-label": typeof ariaLabel === "string" ? ariaLabel : `Switch to ${nextTheme} theme`,
|
|
@@ -138,7 +179,7 @@ function ThemeToggle(props) {
|
|
|
138
179
|
"data-next-theme": nextTheme,
|
|
139
180
|
onPress: (event) => {
|
|
140
181
|
onPress?.(event);
|
|
141
|
-
if (!event.defaultPrevented) theme.setTheme(nextTheme);
|
|
182
|
+
if (!event.defaultPrevented && !Object.is(nextTheme, currentTheme)) theme.setTheme(nextTheme);
|
|
142
183
|
},
|
|
143
184
|
children: /* @__PURE__ */ jsx("span", {
|
|
144
185
|
"data-slot": "theme-toggle-content",
|
|
@@ -146,11 +187,18 @@ function ThemeToggle(props) {
|
|
|
146
187
|
})
|
|
147
188
|
});
|
|
148
189
|
}
|
|
149
|
-
function getNextTheme(currentTheme, themes) {
|
|
190
|
+
function getNextTheme(currentTheme, themes, resolvedSystemTheme = "light") {
|
|
150
191
|
if (themes.length === 0) return currentTheme;
|
|
151
192
|
const index = themes.indexOf(currentTheme);
|
|
193
|
+
if (index < 0 && currentTheme === "system") {
|
|
194
|
+
if (themes.includes("light") && themes.includes("dark")) return resolvedSystemTheme === "dark" ? "light" : "dark";
|
|
195
|
+
}
|
|
152
196
|
return themes[index >= 0 && index < themes.length - 1 ? index + 1 : 0];
|
|
153
197
|
}
|
|
198
|
+
function getResolvedSystemTheme() {
|
|
199
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return "light";
|
|
200
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
201
|
+
}
|
|
154
202
|
function getThemeIcon(theme, icons) {
|
|
155
203
|
if (theme === "light") return icons.lightIcon;
|
|
156
204
|
if (theme === "dark") return icons.darkIcon;
|
|
@@ -159,21 +207,51 @@ function getThemeIcon(theme, icons) {
|
|
|
159
207
|
function resolveThemeToggleIcon(theme, nextTheme, icons) {
|
|
160
208
|
return getThemeIcon(theme, icons) ?? getThemeIcon(nextTheme, icons);
|
|
161
209
|
}
|
|
210
|
+
function renderThemeToggleIconSlots(theme, icons) {
|
|
211
|
+
if (getThemeIcon(theme, icons) === void 0) return;
|
|
212
|
+
const availableSlots = [
|
|
213
|
+
["light", icons.lightIcon],
|
|
214
|
+
["dark", icons.darkIcon],
|
|
215
|
+
["system", icons.systemIcon]
|
|
216
|
+
].filter(([, icon]) => icon !== void 0 && icon !== null);
|
|
217
|
+
if (availableSlots.length <= 1) return;
|
|
218
|
+
return availableSlots.map(([slotTheme, icon]) => /* @__PURE__ */ jsx("span", {
|
|
219
|
+
"data-slot": "theme-toggle-icon",
|
|
220
|
+
"data-theme-toggle-icon": slotTheme,
|
|
221
|
+
hidden: slotTheme === theme ? void 0 : true,
|
|
222
|
+
children: cloneThemeToggleIcon(icon, slotTheme)
|
|
223
|
+
}, slotTheme));
|
|
224
|
+
}
|
|
162
225
|
function isJSXElement(value) {
|
|
163
226
|
return typeof value === "object" && value !== null && "$$typeof" in value && "type" in value && "props" in value;
|
|
164
227
|
}
|
|
165
|
-
function cloneThemeToggleIcon(icon) {
|
|
228
|
+
function cloneThemeToggleIcon(icon, key) {
|
|
229
|
+
if (Array.isArray(icon)) {
|
|
230
|
+
const clonedChildren = icon.map((child) => cloneThemeToggleIcon(child));
|
|
231
|
+
if (icon[STATIC_CHILDREN] === true) Object.defineProperty(clonedChildren, STATIC_CHILDREN, {
|
|
232
|
+
value: true,
|
|
233
|
+
configurable: true
|
|
234
|
+
});
|
|
235
|
+
return clonedChildren;
|
|
236
|
+
}
|
|
166
237
|
if (!isJSXElement(icon)) return icon;
|
|
167
238
|
const props = icon.props;
|
|
168
|
-
|
|
169
|
-
|
|
239
|
+
const clonedProps = props ? { ...props } : {};
|
|
240
|
+
if ("children" in clonedProps) clonedProps.children = cloneThemeToggleIcon(clonedProps.children);
|
|
241
|
+
const iconKey = icon.key ?? key ?? null;
|
|
242
|
+
const clonedIcon = {
|
|
170
243
|
...icon,
|
|
171
|
-
|
|
244
|
+
key: iconKey,
|
|
245
|
+
props: clonedProps
|
|
172
246
|
};
|
|
247
|
+
delete clonedIcon[STATIC_CHILD_SLOTS_CACHE];
|
|
248
|
+
return clonedIcon;
|
|
173
249
|
}
|
|
174
|
-
function syncThemeRoot(themeChoice) {
|
|
250
|
+
function syncThemeRoot(themeChoice, options) {
|
|
175
251
|
if (typeof document === "undefined") return;
|
|
176
252
|
const html = document.documentElement;
|
|
253
|
+
if (options?.passive && options.expectedRevision !== void 0 && options.expectedRevision !== rootThemeRevision) return;
|
|
254
|
+
if (options?.passive && explicitRootThemeOwner !== void 0 && explicitRootThemeOwner !== options.providerId) return;
|
|
177
255
|
if (themeChoice == null) {
|
|
178
256
|
html.removeAttribute("data-theme");
|
|
179
257
|
html.removeAttribute("data-theme-choice");
|
|
@@ -186,7 +264,8 @@ function syncThemeRoot(themeChoice) {
|
|
|
186
264
|
function readStoredTheme(storageKey) {
|
|
187
265
|
if (typeof window === "undefined") return void 0;
|
|
188
266
|
try {
|
|
189
|
-
|
|
267
|
+
const storedTheme = window.localStorage.getItem(storageKey);
|
|
268
|
+
return storedTheme ? storedTheme : void 0;
|
|
190
269
|
} catch {
|
|
191
270
|
return;
|
|
192
271
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":[],"sources":["../../../src/components/theme/theme.tsx"],"sourcesContent":["import { defineContext, readContext, state } from \"@askrjs/askr\";\nimport type { JSXElement } from \"@askrjs/askr/foundations/structures\";\nimport { resource } from \"@askrjs/askr/resources\";\nimport { Button } from \"@askrjs/ui\";\nimport type { ButtonNativeProps, PressEvent } from \"@askrjs/ui\";\n\nexport const CAT_THEME_NAMES = [\"tabby\", \"ginger\", \"tuxedo\", \"calico\", \"torty\"] as const;\n\nexport type CatThemeName = (typeof CAT_THEME_NAMES)[number];\nexport type ThemeName = \"light\" | \"dark\" | \"system\" | CatThemeName | (string & {});\n\nexport type ThemeOption = {\n value: ThemeName;\n label: string;\n};\n\nexport type ThemeContextValue = {\n theme: () => ThemeName;\n setTheme: (theme: ThemeName) => void;\n themes: readonly ThemeOption[];\n storageKey: string;\n};\n\nexport type ThemeProviderProps = {\n children?: unknown;\n defaultTheme?: ThemeName;\n themes?: readonly ThemeOption[];\n storageKey?: string;\n};\n\nexport type ThemePickerProps = Omit<\n JSX.IntrinsicElements[\"select\"],\n \"children\" | \"value\" | \"defaultValue\" | \"onChange\"\n> & {\n themes?: readonly ThemeOption[];\n label?: string;\n};\n\nexport type ThemeToggleRenderContext = {\n theme: ThemeName;\n nextTheme: ThemeName;\n};\n\nexport type ThemeToggleProps = Omit<ButtonNativeProps, \"children\" | \"onPress\"> & {\n children?: unknown | ((context: ThemeToggleRenderContext) => unknown);\n lightIcon?: unknown;\n darkIcon?: unknown;\n systemIcon?: unknown;\n themes?: readonly ThemeName[];\n onPress?: (event: PressEvent) => void;\n};\n\nexport const DEFAULT_THEME_OPTIONS: readonly ThemeOption[] = [\n { value: \"system\", label: \"System\" },\n { value: \"light\", label: \"Light\" },\n { value: \"dark\", label: \"Dark\" },\n];\n\nexport const CAT_THEME_OPTIONS: readonly ThemeOption[] = [\n { value: \"tabby\", label: \"Tabby\" },\n { value: \"ginger\", label: \"Ginger\" },\n { value: \"tuxedo\", label: \"Tuxedo\" },\n { value: \"calico\", label: \"Calico\" },\n { value: \"torty\", label: \"Torty\" },\n];\n\nconst DEFAULT_STORAGE_KEY = \"askr-theme\";\n\nconst ThemeContext = defineContext<ThemeContextValue>({\n theme: () => \"system\",\n setTheme: () => undefined,\n themes: DEFAULT_THEME_OPTIONS,\n storageKey: DEFAULT_STORAGE_KEY,\n});\n\nexport function useTheme(): ThemeContextValue {\n return readContext(ThemeContext);\n}\n\nexport function ThemeProvider(props: ThemeProviderProps): JSX.Element {\n const {\n children,\n defaultTheme = \"system\",\n themes = DEFAULT_THEME_OPTIONS,\n storageKey = DEFAULT_STORAGE_KEY,\n } = props;\n\n const themeState = state<ThemeName>(readStoredTheme(storageKey) ?? defaultTheme);\n const currentTheme = themeState();\n\n const setTheme = (nextTheme: ThemeName) => {\n themeState.set(nextTheme);\n writeStoredTheme(storageKey, nextTheme);\n syncThemeRoot(nextTheme);\n };\n\n const value: ThemeContextValue = {\n theme: themeState,\n setTheme,\n themes,\n storageKey,\n };\n\n return (\n <ThemeContext.Scope value={value}>\n <ThemeRootSync theme={currentTheme} />\n <div data-slot=\"theme-provider\">{children}</div>\n </ThemeContext.Scope>\n );\n}\n\nfunction ThemeRootSync(props: { theme: ThemeName }): JSX.Element | null {\n const { theme } = props;\n\n resource(\n ({ signal }: { signal: AbortSignal }) => {\n if (typeof window === \"undefined\") {\n syncThemeRoot(theme);\n return null;\n }\n\n const timeoutId = window.setTimeout(() => {\n if (!signal.aborted) {\n syncThemeRoot(theme);\n }\n }, 0);\n\n signal.addEventListener(\n \"abort\",\n () => {\n window.clearTimeout(timeoutId);\n },\n { once: true },\n );\n\n return null;\n },\n [theme],\n );\n\n return null;\n}\n\nexport function ThemePicker(props: ThemePickerProps): JSX.Element {\n const theme = useTheme();\n const { themes = theme.themes, label = \"Theme\", ...rest } = props;\n\n return (\n <select\n {...rest}\n aria-label={rest[\"aria-label\"] ?? label}\n data-slot=\"theme-picker\"\n value={theme.theme()}\n onChange={(event: Event) => {\n const target = event.currentTarget as HTMLSelectElement;\n theme.setTheme(target.value as ThemeName);\n }}\n >\n {themes.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n );\n}\n\nexport function ThemeToggle(props: ThemeToggleProps): JSX.Element {\n const theme = useTheme();\n const {\n children,\n lightIcon,\n darkIcon,\n systemIcon,\n themes = [\"light\", \"dark\"],\n onPress,\n ...rest\n } = props;\n\n const currentTheme = theme.theme();\n const nextTheme = getNextTheme(currentTheme, themes);\n const renderContext = { theme: currentTheme, nextTheme };\n const ariaLabel = (rest as Record<string, unknown>)[\"aria-label\"];\n const themedIcon = resolveThemeToggleIcon(currentTheme, nextTheme, {\n lightIcon,\n darkIcon,\n systemIcon,\n });\n const renderedIcon = cloneThemeToggleIcon(themedIcon);\n const content =\n typeof children === \"function\" ? children(renderContext) : (children ?? renderedIcon);\n\n return (\n <Button\n {...(rest as ButtonNativeProps)}\n aria-label={typeof ariaLabel === \"string\" ? ariaLabel : `Switch to ${nextTheme} theme`}\n data-theme-control=\"toggle\"\n data-theme-choice={currentTheme}\n data-next-theme={nextTheme}\n onPress={(event) => {\n onPress?.(event);\n if (!event.defaultPrevented) theme.setTheme(nextTheme);\n }}\n >\n <span data-slot=\"theme-toggle-content\">{content}</span>\n </Button>\n );\n}\n\nfunction getNextTheme(currentTheme: ThemeName, themes: readonly ThemeName[]): ThemeName {\n if (themes.length === 0) return currentTheme;\n const index = themes.indexOf(currentTheme);\n return themes[index >= 0 && index < themes.length - 1 ? index + 1 : 0]!;\n}\n\nfunction getThemeIcon(\n theme: ThemeName,\n icons: Pick<ThemeToggleProps, \"lightIcon\" | \"darkIcon\" | \"systemIcon\">,\n): unknown {\n if (theme === \"light\") return icons.lightIcon;\n if (theme === \"dark\") return icons.darkIcon;\n if (theme === \"system\") return icons.systemIcon;\n return undefined;\n}\n\nexport function resolveThemeToggleIcon(\n theme: ThemeName,\n nextTheme: ThemeName,\n icons: Pick<ThemeToggleProps, \"lightIcon\" | \"darkIcon\" | \"systemIcon\">,\n): unknown {\n return getThemeIcon(theme, icons) ?? getThemeIcon(nextTheme, icons);\n}\n\nfunction isJSXElement(value: unknown): value is JSXElement {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"$$typeof\" in value &&\n \"type\" in value &&\n \"props\" in value\n );\n}\n\nfunction cloneThemeToggleIcon(icon: unknown): unknown {\n if (!isJSXElement(icon)) return icon;\n\n const props = icon.props as Record<string, unknown> | undefined;\n if (!props || Object.keys(props).length === 0) {\n return icon;\n }\n\n return {\n ...icon,\n props: { ...props },\n };\n}\n\nfunction syncThemeRoot(themeChoice: ThemeName | null | undefined): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const html = document.documentElement;\n\n if (themeChoice == null) {\n html.removeAttribute(\"data-theme\");\n html.removeAttribute(\"data-theme-choice\");\n return;\n }\n\n html.setAttribute(\"data-theme-choice\", themeChoice);\n\n if (themeChoice === \"system\") {\n html.removeAttribute(\"data-theme\");\n } else {\n html.setAttribute(\"data-theme\", themeChoice);\n }\n}\n\nfunction readStoredTheme(storageKey: string): ThemeName | undefined {\n if (typeof window === \"undefined\") return undefined;\n try {\n return (window.localStorage.getItem(storageKey) as ThemeName | null) ?? undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction writeStoredTheme(storageKey: string, theme: ThemeName): void {\n if (typeof window === \"undefined\") return;\n try {\n window.localStorage.setItem(storageKey, theme);\n } catch {\n // Storage can be unavailable in private or locked-down browser contexts.\n }\n}\n"],"mappings":";;;;;AAMA,MAAa,kBAAkB;CAAC;CAAS;CAAU;CAAU;CAAU;AAAO;AA8C9E,MAAa,wBAAgD;CAC3D;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAS,OAAO;CAAQ;CACjC;EAAE,OAAO;EAAQ,OAAO;CAAO;AACjC;AAEA,MAAa,oBAA4C;CACvD;EAAE,OAAO;EAAS,OAAO;CAAQ;CACjC;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAS,OAAO;CAAQ;AACnC;AAEA,MAAM,sBAAsB;AAE5B,MAAM,eAAe,cAAiC;CACpD,aAAa;CACb,gBAAgB,KAAA;CAChB,QAAQ;CACR,YAAY;AACd,CAAC;AAED,SAAgB,WAA8B;CAC5C,OAAO,YAAY,YAAY;AACjC;AAEA,SAAgB,cAAc,OAAwC;CACpE,MAAM,EACJ,UACA,eAAe,UACf,SAAS,uBACT,aAAa,wBACX;CAEJ,MAAM,aAAa,MAAiB,gBAAgB,UAAU,KAAK,YAAY;CAC/E,MAAM,eAAe,WAAW;CAEhC,MAAM,YAAY,cAAyB;EACzC,WAAW,IAAI,SAAS;EACxB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ACpB;AACF;AAEA,SAAS,cAAc,aAAiD;CACtE,IAAI,OAAO,aAAa,aACtB;CAGF,MAAM,OAAO,SAAS;CAEtB,IAAI,eAAe,MAAM;EACvB,KAAK,gBAAgB,YAAY;EACjC,KAAK,gBAAgB,mBAAmB;EACxC;CACF;CAEA,KAAK,aAAa,qBAAqB,WAAW;CAElD,IAAI,gBAAgB,UAClB,KAAK,gBAAgB,YAAY;MAEjC,KAAK,aAAa,cAAc,WAAW;AAE/C;AAEA,SAAS,gBAAgB,YAA2C;CAClE,IAAI,OAAO,WAAW,aAAa,OAAO,KAAA;CAC1C,IAAI;EACF,OAAQ,OAAO,aAAa,QAAQ,UAAU,KAA0B,KAAA;CAC1E,QAAQ;EACN;CACF;AACF;AAEA,SAAS,iBAAiB,YAAoB,OAAwB;CACpE,IAAI,OAAO,WAAW,aAAa;CACnC,IAAI;EACF,OAAO,aAAa,QAAQ,YAAY,KAAK;CAC/C,QAAQ,CAER;AACF"}
|
|
1
|
+
{"version":3,"file":"theme.js","names":[],"sources":["../../../src/components/theme/theme.tsx"],"sourcesContent":["import { defineContext, getSignal, readContext, state } from \"@askrjs/askr\";\nimport type { JSXElement } from \"@askrjs/askr/foundations/structures\";\nimport { resource } from \"@askrjs/askr/resources\";\nimport { Button } from \"@askrjs/ui\";\nimport type { ButtonNativeProps, PressEvent } from \"@askrjs/ui\";\n\nexport const CAT_THEME_NAMES = [\"tabby\", \"ginger\", \"tuxedo\", \"calico\", \"torty\"] as const;\n\nexport type CatThemeName = (typeof CAT_THEME_NAMES)[number];\nexport type ThemeName = \"light\" | \"dark\" | \"system\" | CatThemeName | (string & {});\n\nexport type ThemeOption = {\n value: ThemeName;\n label: string;\n};\n\nexport type ThemeContextValue = {\n theme: () => ThemeName;\n setTheme: (theme: ThemeName) => void;\n themes: readonly ThemeOption[];\n storageKey: string;\n};\n\nexport type ThemeProviderProps = {\n children?: unknown;\n defaultTheme?: ThemeName;\n themes?: readonly ThemeOption[];\n storageKey?: string;\n};\n\nexport type ThemePickerProps = Omit<\n JSX.IntrinsicElements[\"select\"],\n \"children\" | \"value\" | \"defaultValue\" | \"onChange\"\n> & {\n themes?: readonly ThemeOption[];\n label?: string;\n};\n\nexport type ThemeToggleRenderContext = {\n theme: ThemeName;\n nextTheme: ThemeName;\n};\n\nexport type ThemeToggleProps = Omit<ButtonNativeProps, \"children\" | \"onPress\"> & {\n children?: unknown | ((context: ThemeToggleRenderContext) => unknown);\n lightIcon?: unknown;\n darkIcon?: unknown;\n systemIcon?: unknown;\n themes?: readonly ThemeName[];\n onPress?: (event: PressEvent) => void;\n};\n\nexport const DEFAULT_THEME_OPTIONS: readonly ThemeOption[] = [\n { value: \"system\", label: \"System\" },\n { value: \"light\", label: \"Light\" },\n { value: \"dark\", label: \"Dark\" },\n];\n\nexport const CAT_THEME_OPTIONS: readonly ThemeOption[] = [\n { value: \"tabby\", label: \"Tabby\" },\n { value: \"ginger\", label: \"Ginger\" },\n { value: \"tuxedo\", label: \"Tuxedo\" },\n { value: \"calico\", label: \"Calico\" },\n { value: \"torty\", label: \"Torty\" },\n];\n\nconst DEFAULT_STORAGE_KEY = \"askr-theme\";\nconst STATIC_CHILDREN = Symbol.for(\"askr.static-children\");\nconst STATIC_CHILD_SLOTS_CACHE = Symbol.for(\"__askrStaticChildSlots\");\n// Passive mount sync should not overwrite a newer user/provider-initiated change.\nlet rootThemeRevision = 0;\nlet explicitRootThemeOwner: symbol | undefined;\nconst registeredProviderSignals = new WeakSet<AbortSignal>();\n\nconst ThemeContext = defineContext<ThemeContextValue>({\n theme: () => \"system\",\n setTheme: () => undefined,\n themes: DEFAULT_THEME_OPTIONS,\n storageKey: DEFAULT_STORAGE_KEY,\n});\n\nexport function useTheme(): ThemeContextValue {\n return readContext(ThemeContext);\n}\n\nexport function ThemeProvider(props: ThemeProviderProps): JSX.Element {\n const {\n children,\n defaultTheme = \"system\",\n themes = DEFAULT_THEME_OPTIONS,\n storageKey = DEFAULT_STORAGE_KEY,\n } = props;\n\n const providerId = state<symbol>(Symbol(\"ThemeProvider\"))();\n const providerSignal = getSignal();\n const themeState = state<ThemeName>(readStoredTheme(storageKey) ?? defaultTheme);\n const currentTheme = themeState();\n\n if (!registeredProviderSignals.has(providerSignal)) {\n registeredProviderSignals.add(providerSignal);\n providerSignal.addEventListener(\n \"abort\",\n () => {\n if (explicitRootThemeOwner === providerId) {\n explicitRootThemeOwner = undefined;\n }\n },\n { once: true },\n );\n }\n\n const setTheme = (nextTheme: ThemeName) => {\n themeState.set(nextTheme);\n writeStoredTheme(storageKey, nextTheme);\n explicitRootThemeOwner = providerId;\n rootThemeRevision += 1;\n syncThemeRoot(nextTheme);\n };\n\n const value: ThemeContextValue = {\n theme: themeState,\n setTheme,\n themes,\n storageKey,\n };\n\n return (\n <ThemeContext.Scope value={value}>\n <ThemeRootSync providerId={providerId} theme={currentTheme} />\n <div data-slot=\"theme-provider\">{children}</div>\n </ThemeContext.Scope>\n );\n}\n\nfunction ThemeRootSync(props: { providerId: symbol; theme: ThemeName }): JSX.Element | null {\n const { providerId, theme } = props;\n const expectedRootThemeRevision = rootThemeRevision;\n\n resource(\n ({ signal }: { signal: AbortSignal }) => {\n if (typeof window === \"undefined\") {\n syncThemeRoot(theme);\n return null;\n }\n\n const timeoutId = window.setTimeout(() => {\n if (!signal.aborted) {\n syncThemeRoot(theme, {\n expectedRevision: expectedRootThemeRevision,\n passive: true,\n providerId,\n });\n }\n }, 0);\n\n signal.addEventListener(\n \"abort\",\n () => {\n window.clearTimeout(timeoutId);\n },\n { once: true },\n );\n\n return null;\n },\n [theme],\n );\n\n return null;\n}\n\nexport function ThemePicker(props: ThemePickerProps): JSX.Element {\n const theme = useTheme();\n const { themes = theme.themes, label = \"Theme\", ...rest } = props;\n const currentTheme = theme.theme();\n\n return (\n <select\n {...rest}\n aria-label={rest[\"aria-label\"] ?? label}\n data-slot=\"theme-picker\"\n value={currentTheme}\n onChange={(event: Event) => {\n const target = getThemePickerTarget(event);\n if (target) {\n theme.setTheme(target.value as ThemeName);\n }\n }}\n >\n {themes.map((option) => (\n <option key={option.value} value={option.value} selected={option.value === currentTheme}>\n {option.label}\n </option>\n ))}\n </select>\n );\n}\n\nfunction getThemePickerTarget(event: Event): HTMLSelectElement | null {\n if (typeof HTMLSelectElement === \"undefined\") {\n return null;\n }\n\n const path = typeof event.composedPath === \"function\" ? event.composedPath() : [];\n const candidates = [event.target, event.currentTarget, ...path];\n\n for (const candidate of candidates) {\n if (candidate instanceof HTMLSelectElement) {\n return candidate;\n }\n }\n\n return null;\n}\n\nexport function ThemeToggle(props: ThemeToggleProps): JSX.Element {\n const theme = useTheme();\n const {\n children,\n lightIcon,\n darkIcon,\n systemIcon,\n themes = [\"light\", \"dark\"],\n onPress,\n ...rest\n } = props;\n\n const currentTheme = theme.theme();\n const nextTheme = getNextTheme(currentTheme, themes, getResolvedSystemTheme());\n const renderContext = { theme: currentTheme, nextTheme };\n const ariaLabel = (rest as Record<string, unknown>)[\"aria-label\"];\n const themedIcon = resolveThemeToggleIcon(currentTheme, nextTheme, {\n lightIcon,\n darkIcon,\n systemIcon,\n });\n const renderedIcon = cloneThemeToggleIcon(themedIcon, currentTheme);\n const renderedIconSlots =\n renderThemeToggleIconSlots(currentTheme, {\n lightIcon,\n darkIcon,\n systemIcon,\n }) ?? renderedIcon;\n const content =\n typeof children === \"function\" ? children(renderContext) : (children ?? renderedIconSlots);\n\n return (\n <Button\n {...(rest as ButtonNativeProps)}\n aria-label={typeof ariaLabel === \"string\" ? ariaLabel : `Switch to ${nextTheme} theme`}\n data-theme-control=\"toggle\"\n data-theme-choice={currentTheme}\n data-next-theme={nextTheme}\n onPress={(event) => {\n onPress?.(event);\n if (!event.defaultPrevented && !Object.is(nextTheme, currentTheme)) {\n theme.setTheme(nextTheme);\n }\n }}\n >\n <span data-slot=\"theme-toggle-content\">{content}</span>\n </Button>\n );\n}\n\nfunction getNextTheme(\n currentTheme: ThemeName,\n themes: readonly ThemeName[],\n resolvedSystemTheme: \"light\" | \"dark\" = \"light\",\n): ThemeName {\n if (themes.length === 0) return currentTheme;\n const index = themes.indexOf(currentTheme);\n if (index < 0 && currentTheme === \"system\") {\n if (themes.includes(\"light\") && themes.includes(\"dark\")) {\n return resolvedSystemTheme === \"dark\" ? \"light\" : \"dark\";\n }\n }\n return themes[index >= 0 && index < themes.length - 1 ? index + 1 : 0]!;\n}\n\nfunction getResolvedSystemTheme(): \"light\" | \"dark\" {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n return \"light\";\n }\n\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches ? \"dark\" : \"light\";\n}\n\nfunction getThemeIcon(\n theme: ThemeName,\n icons: Pick<ThemeToggleProps, \"lightIcon\" | \"darkIcon\" | \"systemIcon\">,\n): unknown {\n if (theme === \"light\") return icons.lightIcon;\n if (theme === \"dark\") return icons.darkIcon;\n if (theme === \"system\") return icons.systemIcon;\n return undefined;\n}\n\nexport function resolveThemeToggleIcon(\n theme: ThemeName,\n nextTheme: ThemeName,\n icons: Pick<ThemeToggleProps, \"lightIcon\" | \"darkIcon\" | \"systemIcon\">,\n): unknown {\n return getThemeIcon(theme, icons) ?? getThemeIcon(nextTheme, icons);\n}\n\nfunction renderThemeToggleIconSlots(\n theme: ThemeName,\n icons: Pick<ThemeToggleProps, \"lightIcon\" | \"darkIcon\" | \"systemIcon\">,\n): unknown {\n if (getThemeIcon(theme, icons) === undefined) {\n return undefined;\n }\n\n const slots = [\n [\"light\", icons.lightIcon],\n [\"dark\", icons.darkIcon],\n [\"system\", icons.systemIcon],\n ] as const;\n const availableSlots = slots.filter(([, icon]) => icon !== undefined && icon !== null);\n\n if (availableSlots.length <= 1) {\n return undefined;\n }\n\n return availableSlots.map(([slotTheme, icon]) => (\n <span\n key={slotTheme}\n data-slot=\"theme-toggle-icon\"\n data-theme-toggle-icon={slotTheme}\n hidden={slotTheme === theme ? undefined : true}\n >\n {cloneThemeToggleIcon(icon, slotTheme)}\n </span>\n ));\n}\n\nfunction isJSXElement(value: unknown): value is JSXElement {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"$$typeof\" in value &&\n \"type\" in value &&\n \"props\" in value\n );\n}\n\nfunction cloneThemeToggleIcon(icon: unknown, key?: string): unknown {\n if (Array.isArray(icon)) {\n const clonedChildren = icon.map((child) => cloneThemeToggleIcon(child));\n if ((icon as Record<symbol, unknown>)[STATIC_CHILDREN] === true) {\n Object.defineProperty(clonedChildren, STATIC_CHILDREN, {\n value: true,\n configurable: true,\n });\n }\n return clonedChildren;\n }\n\n if (!isJSXElement(icon)) return icon;\n\n const props = icon.props as Record<string, unknown> | undefined;\n const clonedProps = props ? { ...props } : {};\n\n if (\"children\" in clonedProps) {\n clonedProps.children = cloneThemeToggleIcon(clonedProps.children);\n }\n\n const iconKey = (icon.key ?? key ?? null) as string | number | null;\n const clonedIcon = {\n ...icon,\n key: iconKey,\n props: clonedProps,\n };\n\n delete (clonedIcon as Record<symbol, unknown>)[STATIC_CHILD_SLOTS_CACHE];\n return clonedIcon;\n}\n\nfunction syncThemeRoot(\n themeChoice: ThemeName | null | undefined,\n options?: { expectedRevision?: number; passive?: boolean; providerId?: symbol },\n): void {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const html = document.documentElement;\n\n if (\n options?.passive &&\n options.expectedRevision !== undefined &&\n options.expectedRevision !== rootThemeRevision\n ) {\n return;\n }\n\n if (\n options?.passive &&\n explicitRootThemeOwner !== undefined &&\n explicitRootThemeOwner !== options.providerId\n ) {\n return;\n }\n\n if (themeChoice == null) {\n html.removeAttribute(\"data-theme\");\n html.removeAttribute(\"data-theme-choice\");\n return;\n }\n\n html.setAttribute(\"data-theme-choice\", themeChoice);\n\n if (themeChoice === \"system\") {\n html.removeAttribute(\"data-theme\");\n } else {\n html.setAttribute(\"data-theme\", themeChoice);\n }\n}\n\nfunction readStoredTheme(storageKey: string): ThemeName | undefined {\n if (typeof window === \"undefined\") return undefined;\n try {\n const storedTheme = window.localStorage.getItem(storageKey);\n return storedTheme ? (storedTheme as ThemeName) : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction writeStoredTheme(storageKey: string, theme: ThemeName): void {\n if (typeof window === \"undefined\") return;\n try {\n window.localStorage.setItem(storageKey, theme);\n } catch {\n // Storage can be unavailable in private or locked-down browser contexts.\n }\n}\n"],"mappings":";;;;;AAMA,MAAa,kBAAkB;CAAC;CAAS;CAAU;CAAU;CAAU;AAAO;AA8C9E,MAAa,wBAAgD;CAC3D;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAS,OAAO;CAAQ;CACjC;EAAE,OAAO;EAAQ,OAAO;CAAO;AACjC;AAEA,MAAa,oBAA4C;CACvD;EAAE,OAAO;EAAS,OAAO;CAAQ;CACjC;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAS,OAAO;CAAQ;AACnC;AAEA,MAAM,sBAAsB;AAC5B,MAAM,kBAAkB,OAAO,IAAI,sBAAsB;AACzD,MAAM,2BAA2B,OAAO,IAAI,wBAAwB;AAEpE,IAAI,oBAAoB;AACxB,IAAI;AACJ,MAAM,4CAA4B,IAAI,QAAqB;AAE3D,MAAM,eAAe,cAAiC;CACpD,aAAa;CACb,gBAAgB,KAAA;CAChB,QAAQ;CACR,YAAY;AACd,CAAC;AAED,SAAgB,WAA8B;CAC5C,OAAO,YAAY,YAAY;AACjC;AAEA,SAAgB,cAAc,OAAwC;CACpE,MAAM,EACJ,UACA,eAAe,UACf,SAAS,uBACT,aAAa,wBACX;CAEJ,MAAM,aAAa,MAAc,OAAO,eAAe,CAAC,CAAC,CAAC;CAC1D,MAAM,iBAAiB,UAAU;CACjC,MAAM,aAAa,MAAiB,gBAAgB,UAAU,KAAK,YAAY;CAC/E,MAAM,eAAe,WAAW;CAEhC,IAAI,CAAC,0BAA0B,IAAI,cAAc,GAAG;EAClD,0BAA0B,IAAI,cAA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,OAAO,WAAW,aAAa;CACnC,IAAI;EACF,OAAO,aAAa,QAAQ,YAAY,KAAK;CAC/C,QAAQ,CAER;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Block } from "../block/block.js";
|
|
2
|
+
import { jsx, jsxs } from "@askrjs/askr/jsx-runtime";
|
|
3
|
+
//#region src/components/toolbar/toolbar.tsx
|
|
4
|
+
function Toolbar(props) {
|
|
5
|
+
const { title, actions, ...rest } = props;
|
|
6
|
+
return /* @__PURE__ */ jsxs(Block, {
|
|
7
|
+
rowFrom: "md",
|
|
8
|
+
align: {
|
|
9
|
+
base: "start",
|
|
10
|
+
md: "center"
|
|
11
|
+
},
|
|
12
|
+
justify: "between",
|
|
13
|
+
gap: "md",
|
|
14
|
+
...rest,
|
|
15
|
+
"data-slot": "toolbar",
|
|
16
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
17
|
+
"data-slot": "toolbar-title",
|
|
18
|
+
children: title
|
|
19
|
+
}), actions !== void 0 ? /* @__PURE__ */ jsx(Block, {
|
|
20
|
+
direction: "row",
|
|
21
|
+
gap: "sm",
|
|
22
|
+
"data-slot": "toolbar-actions",
|
|
23
|
+
children: actions
|
|
24
|
+
}) : null]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Toolbar };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=toolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar.js","names":[],"sources":["../../../src/components/toolbar/toolbar.tsx"],"sourcesContent":["import { Block } from \"../block\";\nimport type { ToolbarProps } from \"./toolbar.types\";\n\nexport function Toolbar(props: ToolbarProps): JSX.Element {\n const { title, actions, ...rest } = props;\n\n return (\n <Block\n rowFrom=\"md\"\n align={{ base: \"start\", md: \"center\" }}\n justify=\"between\"\n gap=\"md\"\n {...rest}\n data-slot=\"toolbar\"\n >\n <h2 data-slot=\"toolbar-title\">{title}</h2>\n {actions !== undefined ? (\n <Block direction=\"row\" gap=\"sm\" data-slot=\"toolbar-actions\">\n {actions}\n </Block>\n ) : null}\n </Block>\n );\n}\n"],"mappings":";;;AAGA,SAAgB,QAAQ,OAAkC;CACxD,MAAM,EAAE,OAAO,SAAS,GAAG,SAAS;CAEpC,OACE,qBAAC,OAAD;EACE,SAAQ;EACR,OAAO;GAAE,MAAM;GAAS,IAAI;EAAS;EACrC,SAAQ;EACR,KAAI;EACJ,GAAI;EACJ,aAAU;YANZ,CAQE,oBAAC,MAAD;GAAI,aAAU;aAAiB;EAAU,CAAA,GACxC,YAAY,KAAA,IACX,oBAAC,OAAD;GAAO,WAAU;GAAM,KAAI;GAAK,aAAU;aACvC;EACI,CAAA,IACL,IACC;;AAEX"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BlockDivProps } from "../block/block.types.js";
|
|
2
|
+
//#region src/components/toolbar/toolbar.types.d.ts
|
|
3
|
+
type ToolbarProps = BlockDivProps & {
|
|
4
|
+
title: unknown;
|
|
5
|
+
actions?: unknown;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ToolbarProps };
|
|
9
|
+
//# sourceMappingURL=toolbar.types.d.ts.map
|