@nanisoft/prism-ui 0.10.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/dist/.tsbuildinfo +1 -1
- package/dist/blocks/app-shell-01/app-shell.js +4 -4
- package/dist/blocks/app-shell-01/index.d.ts +2 -2
- package/dist/blocks/app-shell-01/index.js +1 -1
- package/dist/blocks/auth-form-01/auth-form.d.ts +11 -1
- package/dist/blocks/auth-form-01/auth-form.d.ts.map +1 -1
- package/dist/blocks/auth-form-01/auth-form.js +11 -8
- package/dist/blocks/auth-form-01/index.d.ts +2 -2
- package/dist/blocks/auth-form-01/index.js +1 -1
- package/dist/blocks/cta-01/cta.d.ts +26 -21
- package/dist/blocks/cta-01/cta.d.ts.map +1 -1
- package/dist/blocks/cta-01/cta.js +2 -2
- package/dist/blocks/cta-01/index.d.ts +2 -2
- package/dist/blocks/cta-01/index.js +1 -1
- package/dist/blocks/data-table-01/data-table.js +7 -7
- package/dist/blocks/data-table-01/index.d.ts +2 -2
- package/dist/blocks/data-table-01/index.js +1 -1
- package/dist/blocks/empty-state-01/empty-state.d.ts +143 -0
- package/dist/blocks/empty-state-01/empty-state.d.ts.map +1 -0
- package/dist/blocks/empty-state-01/empty-state.js +104 -0
- package/dist/blocks/empty-state-01/index.d.ts +3 -0
- package/dist/blocks/empty-state-01/index.d.ts.map +1 -0
- package/dist/blocks/empty-state-01/index.js +1 -0
- package/dist/blocks/feature-grid-01/feature-grid.d.ts +28 -1
- package/dist/blocks/feature-grid-01/feature-grid.d.ts.map +1 -1
- package/dist/blocks/feature-grid-01/feature-grid.js +34 -3
- package/dist/blocks/feature-grid-01/index.d.ts +2 -2
- package/dist/blocks/feature-grid-01/index.js +1 -1
- package/dist/blocks/hero-01/hero.d.ts +35 -15
- package/dist/blocks/hero-01/hero.d.ts.map +1 -1
- package/dist/blocks/hero-01/hero.js +14 -9
- package/dist/blocks/hero-01/index.d.ts +2 -1
- package/dist/blocks/hero-01/index.d.ts.map +1 -1
- package/dist/blocks/hero-01/index.js +1 -1
- package/dist/blocks/index.d.ts +20 -20
- package/dist/blocks/index.js +19 -19
- package/dist/blocks/instrument-panel-01/index.d.ts +2 -2
- package/dist/blocks/instrument-panel-01/index.js +1 -1
- package/dist/blocks/instrument-panel-01/instrument-panel.js +1 -1
- package/dist/blocks/logo-strip-01/index.d.ts +2 -2
- package/dist/blocks/logo-strip-01/index.js +1 -1
- package/dist/blocks/logo-strip-01/logo-strip.d.ts +1 -1
- package/dist/blocks/logo-strip-01/logo-strip.js +2 -2
- package/dist/blocks/note-grid-01/index.d.ts +2 -2
- package/dist/blocks/note-grid-01/index.js +1 -1
- package/dist/blocks/note-grid-01/note-grid.d.ts +1 -1
- package/dist/blocks/note-grid-01/note-grid.js +1 -1
- package/dist/blocks/page-header-01/index.d.ts +2 -2
- package/dist/blocks/page-header-01/index.js +1 -1
- package/dist/blocks/page-header-01/page-header.d.ts +1 -1
- package/dist/blocks/page-header-01/page-header.js +4 -4
- package/dist/blocks/pricing-01/index.d.ts +1 -1
- package/dist/blocks/pricing-01/index.js +1 -1
- package/dist/blocks/pricing-01/pricing.d.ts +8 -1
- package/dist/blocks/pricing-01/pricing.d.ts.map +1 -1
- package/dist/blocks/pricing-01/pricing.js +15 -5
- package/dist/blocks/process-flow-01/index.d.ts +3 -0
- package/dist/blocks/process-flow-01/index.d.ts.map +1 -0
- package/dist/blocks/process-flow-01/index.js +1 -0
- package/dist/blocks/process-flow-01/process-flow.d.ts +118 -0
- package/dist/blocks/process-flow-01/process-flow.d.ts.map +1 -0
- package/dist/blocks/process-flow-01/process-flow.js +71 -0
- package/dist/blocks/process-rail-01/index.d.ts +2 -2
- package/dist/blocks/process-rail-01/index.js +1 -1
- package/dist/blocks/process-rail-01/process-rail.d.ts +1 -1
- package/dist/blocks/process-rail-01/process-rail.js +2 -2
- package/dist/blocks/product-grid-01/index.d.ts +2 -2
- package/dist/blocks/product-grid-01/index.js +1 -1
- package/dist/blocks/product-grid-01/product-grid.d.ts +37 -5
- package/dist/blocks/product-grid-01/product-grid.d.ts.map +1 -1
- package/dist/blocks/product-grid-01/product-grid.js +20 -6
- package/dist/blocks/run-console-01/index.d.ts +3 -0
- package/dist/blocks/run-console-01/index.d.ts.map +1 -0
- package/dist/blocks/run-console-01/index.js +1 -0
- package/dist/blocks/run-console-01/run-console.d.ts +111 -0
- package/dist/blocks/run-console-01/run-console.d.ts.map +1 -0
- package/dist/blocks/run-console-01/run-console.js +48 -0
- package/dist/blocks/settings-panel-01/index.d.ts +2 -2
- package/dist/blocks/settings-panel-01/index.js +1 -1
- package/dist/blocks/settings-panel-01/settings-panel.d.ts +11 -1
- package/dist/blocks/settings-panel-01/settings-panel.d.ts.map +1 -1
- package/dist/blocks/settings-panel-01/settings-panel.js +15 -10
- package/dist/blocks/site-footer/index.d.ts +2 -2
- package/dist/blocks/site-footer/index.js +1 -1
- package/dist/blocks/site-footer/site-footer.d.ts +1 -1
- package/dist/blocks/site-footer/site-footer.js +2 -2
- package/dist/blocks/site-header/index.d.ts +2 -2
- package/dist/blocks/site-header/index.js +1 -1
- package/dist/blocks/site-header/site-header.d.ts +2 -2
- package/dist/blocks/site-header/site-header.js +3 -3
- package/dist/blocks/site-navbar/index.d.ts +3 -0
- package/dist/blocks/site-navbar/index.d.ts.map +1 -0
- package/dist/blocks/site-navbar/index.js +1 -0
- package/dist/blocks/site-navbar/mobile-nav.d.ts +48 -0
- package/dist/blocks/site-navbar/mobile-nav.d.ts.map +1 -0
- package/dist/blocks/site-navbar/mobile-nav.js +35 -0
- package/dist/blocks/site-navbar/mode-toggle.d.ts +39 -0
- package/dist/blocks/site-navbar/mode-toggle.d.ts.map +1 -0
- package/dist/blocks/site-navbar/mode-toggle.js +39 -0
- package/dist/blocks/site-navbar/navbar-controls.d.ts +79 -0
- package/dist/blocks/site-navbar/navbar-controls.d.ts.map +1 -0
- package/dist/blocks/site-navbar/navbar-controls.js +40 -0
- package/dist/blocks/site-navbar/search-entry.d.ts +29 -0
- package/dist/blocks/site-navbar/search-entry.d.ts.map +1 -0
- package/dist/blocks/site-navbar/search-entry.js +52 -0
- package/dist/blocks/site-navbar/site-navbar.d.ts +212 -0
- package/dist/blocks/site-navbar/site-navbar.d.ts.map +1 -0
- package/dist/blocks/site-navbar/site-navbar.js +61 -0
- package/dist/blocks/site-navbar/sites-menu.d.ts +40 -0
- package/dist/blocks/site-navbar/sites-menu.d.ts.map +1 -0
- package/dist/blocks/site-navbar/sites-menu.js +48 -0
- package/dist/blocks/site-navbar/theme-menu.d.ts +47 -0
- package/dist/blocks/site-navbar/theme-menu.d.ts.map +1 -0
- package/dist/blocks/site-navbar/theme-menu.js +55 -0
- package/dist/blocks/stack-grid-01/index.d.ts +2 -2
- package/dist/blocks/stack-grid-01/index.js +1 -1
- package/dist/blocks/stack-grid-01/stack-grid.d.ts +42 -11
- package/dist/blocks/stack-grid-01/stack-grid.d.ts.map +1 -1
- package/dist/blocks/stack-grid-01/stack-grid.js +15 -7
- package/dist/blocks/stats-01/index.d.ts +9 -1
- package/dist/blocks/stats-01/index.d.ts.map +1 -1
- package/dist/blocks/stats-01/index.js +8 -1
- package/dist/blocks/stats-01/stats.d.ts +1 -1
- package/dist/blocks/stats-01/stats.js +2 -2
- package/dist/blocks/status-ledger-01/index.d.ts +2 -2
- package/dist/blocks/status-ledger-01/index.js +1 -1
- package/dist/blocks/status-ledger-01/status-ledger.d.ts +1 -1
- package/dist/blocks/status-ledger-01/status-ledger.js +2 -2
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +473 -1
- package/dist/components/index.d.ts +104 -66
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +74 -40
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/alert-dialog.d.ts +119 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +82 -0
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/aspect-ratio.d.ts +60 -0
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -0
- package/dist/components/ui/aspect-ratio.js +61 -0
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/button-group.d.ts +68 -0
- package/dist/components/ui/button-group.d.ts.map +1 -0
- package/dist/components/ui/button-group.js +54 -0
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/calendar.d.ts +158 -0
- package/dist/components/ui/calendar.d.ts.map +1 -0
- package/dist/components/ui/calendar.js +216 -0
- package/dist/components/ui/card.d.ts +18 -6
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +23 -8
- package/dist/components/ui/carousel.d.ts +118 -0
- package/dist/components/ui/carousel.d.ts.map +1 -0
- package/dist/components/ui/carousel.js +152 -0
- package/dist/components/ui/chart-frame.d.ts +216 -0
- package/dist/components/ui/chart-frame.d.ts.map +1 -0
- package/dist/components/ui/chart-frame.js +286 -0
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/collapsible.d.ts +97 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +54 -0
- package/dist/components/ui/combobox.d.ts +141 -0
- package/dist/components/ui/combobox.d.ts.map +1 -0
- package/dist/components/ui/combobox.js +243 -0
- package/dist/components/ui/command-palette.d.ts +106 -0
- package/dist/components/ui/command-palette.d.ts.map +1 -0
- package/dist/components/ui/command-palette.js +176 -0
- package/dist/components/ui/command.d.ts +82 -0
- package/dist/components/ui/command.d.ts.map +1 -0
- package/dist/components/ui/command.js +37 -0
- package/dist/components/ui/context-menu.d.ts +151 -0
- package/dist/components/ui/context-menu.d.ts.map +1 -0
- package/dist/components/ui/context-menu.js +97 -0
- package/dist/components/ui/cta-link.js +1 -1
- package/dist/components/ui/date-picker.d.ts +111 -0
- package/dist/components/ui/date-picker.d.ts.map +1 -0
- package/dist/components/ui/date-picker.js +74 -0
- package/dist/components/ui/diagram.d.ts +84 -15
- package/dist/components/ui/diagram.d.ts.map +1 -1
- package/dist/components/ui/diagram.js +77 -7
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/diff.d.ts +105 -0
- package/dist/components/ui/diff.d.ts.map +1 -0
- package/dist/components/ui/diff.js +113 -0
- package/dist/components/ui/dropdown-menu.d.ts +18 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/fact-list.js +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/form.d.ts +151 -0
- package/dist/components/ui/form.d.ts.map +1 -0
- package/dist/components/ui/form.js +73 -0
- package/dist/components/ui/hover-card.d.ts +105 -0
- package/dist/components/ui/hover-card.d.ts.map +1 -0
- package/dist/components/ui/hover-card.js +49 -0
- package/dist/components/ui/input-group.d.ts +99 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input-group.js +83 -0
- package/dist/components/ui/input.js +1 -1
- package/dist/components/ui/item.d.ts +113 -0
- package/dist/components/ui/item.d.ts.map +1 -0
- package/dist/components/ui/item.js +61 -0
- package/dist/components/ui/kbd.js +1 -1
- package/dist/components/ui/label.d.ts +58 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +29 -0
- package/dist/components/ui/live-region.d.ts +9 -0
- package/dist/components/ui/live-region.d.ts.map +1 -1
- package/dist/components/ui/live-region.js +10 -2
- package/dist/components/ui/mark.js +1 -1
- package/dist/components/ui/menubar.d.ts +197 -0
- package/dist/components/ui/menubar.d.ts.map +1 -0
- package/dist/components/ui/menubar.js +109 -0
- package/dist/components/ui/meter.d.ts +121 -0
- package/dist/components/ui/meter.d.ts.map +1 -0
- package/dist/components/ui/meter.js +82 -0
- package/dist/components/ui/native-select.d.ts +72 -0
- package/dist/components/ui/native-select.d.ts.map +1 -0
- package/dist/components/ui/native-select.js +55 -0
- package/dist/components/ui/navigation-menu.d.ts +186 -0
- package/dist/components/ui/navigation-menu.d.ts.map +1 -0
- package/dist/components/ui/navigation-menu.js +94 -0
- package/dist/components/ui/number-field.d.ts +111 -0
- package/dist/components/ui/number-field.d.ts.map +1 -0
- package/dist/components/ui/number-field.js +84 -0
- package/dist/components/ui/one-time-code.d.ts +127 -0
- package/dist/components/ui/one-time-code.d.ts.map +1 -0
- package/dist/components/ui/one-time-code.js +57 -0
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/product-mark.d.ts +1 -1
- package/dist/components/ui/product-mark.js +1 -1
- package/dist/components/ui/product-switcher.d.ts +1 -1
- package/dist/components/ui/product-switcher.js +2 -2
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/prose.js +1 -1
- package/dist/components/ui/pulse-graph.js +1 -1
- package/dist/components/ui/pulse-series.js +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/resizable.d.ts +129 -0
- package/dist/components/ui/resizable.d.ts.map +1 -0
- package/dist/components/ui/resizable.js +205 -0
- package/dist/components/ui/scroll-area.d.ts +97 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +68 -0
- package/dist/components/ui/search-dialog.d.ts +139 -0
- package/dist/components/ui/search-dialog.d.ts.map +1 -0
- package/dist/components/ui/search-dialog.js +178 -0
- package/dist/components/ui/section.d.ts +26 -0
- package/dist/components/ui/section.d.ts.map +1 -1
- package/dist/components/ui/section.js +32 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/sheet.d.ts +103 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +58 -0
- package/dist/components/ui/sidebar.d.ts +228 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +172 -0
- package/dist/components/ui/signal-field.js +1 -1
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/slider.js +1 -1
- package/dist/components/ui/spinner.d.ts +79 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +79 -0
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/table-sort.d.ts +97 -0
- package/dist/components/ui/table-sort.d.ts.map +1 -0
- package/dist/components/ui/table-sort.js +102 -0
- package/dist/components/ui/table.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/timeline.d.ts +106 -0
- package/dist/components/ui/timeline.d.ts.map +1 -0
- package/dist/components/ui/timeline.js +111 -0
- package/dist/components/ui/toast.d.ts +219 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +270 -0
- package/dist/components/ui/toggle-group.d.ts +118 -0
- package/dist/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/components/ui/toggle-group.js +194 -0
- package/dist/components/ui/toggle.d.ts +73 -0
- package/dist/components/ui/toggle.d.ts.map +1 -0
- package/dist/components/ui/toggle.js +44 -0
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/ui/tree.js +1 -1
- package/dist/components/ui/typography.js +1 -1
- package/dist/fonts/Inter-OFL.txt +93 -93
- package/dist/index.d.ts +72 -70
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -60
- package/dist/lib/rank.d.ts +69 -0
- package/dist/lib/rank.d.ts.map +1 -0
- package/dist/lib/rank.js +77 -0
- package/dist/live/index.d.ts +22 -0
- package/dist/live/index.d.ts.map +1 -0
- package/dist/live/index.js +20 -0
- package/dist/live/run-stream-01/index.d.ts +3 -0
- package/dist/live/run-stream-01/index.d.ts.map +1 -0
- package/dist/live/run-stream-01/index.js +1 -0
- package/dist/live/run-stream-01/run-stream.d.ts +125 -0
- package/dist/live/run-stream-01/run-stream.d.ts.map +1 -0
- package/dist/live/run-stream-01/run-stream.js +111 -0
- package/dist/pages/auth-page/index.d.ts +15 -2
- package/dist/pages/auth-page/index.d.ts.map +1 -1
- package/dist/pages/auth-page/index.js +8 -4
- package/dist/pages/blog-post-page/index.js +5 -5
- package/dist/pages/dashboard-page/index.d.ts +4 -4
- package/dist/pages/dashboard-page/index.js +4 -4
- package/dist/pages/docs-shell/docs-shell.d.ts +37 -4
- package/dist/pages/docs-shell/docs-shell.d.ts.map +1 -1
- package/dist/pages/docs-shell/docs-shell.js +107 -16
- package/dist/pages/docs-shell/index.d.ts +2 -2
- package/dist/pages/docs-shell/index.js +1 -1
- package/dist/pages/index.d.ts +14 -14
- package/dist/pages/index.js +7 -7
- package/dist/pages/marketing-page/index.d.ts +6 -6
- package/dist/pages/marketing-page/index.js +5 -5
- package/dist/pages/not-found-page/index.js +4 -4
- package/dist/pages/settings-page/index.d.ts +3 -3
- package/dist/pages/settings-page/index.js +4 -4
- package/dist/provider/index.d.ts +4 -4
- package/dist/provider/index.js +2 -2
- package/dist/provider/provider.d.ts +1 -1
- package/dist/provider/provider.js +1 -1
- package/dist/provider/theme-script.d.ts +1 -1
- package/dist/provider/theme-script.js +1 -1
- package/dist/styles.css +689 -0
- package/package.json +9 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
/** The props the Sheet root forwards to the Dialog. */
|
|
3
|
+
export interface SheetProps {
|
|
4
|
+
/** The controlled open state. */
|
|
5
|
+
open?: boolean;
|
|
6
|
+
/** The initially open state, for an uncontrolled sheet. */
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
/** Called when the open state changes. */
|
|
9
|
+
onOpenChange?: (open: boolean) => void;
|
|
10
|
+
/** The trigger and the panel. */
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** The props SheetTrigger forwards to the Dialog trigger. */
|
|
14
|
+
export interface SheetTriggerProps extends ComponentProps<'button'> {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The props SheetContent forwards to the Dialog.
|
|
18
|
+
*
|
|
19
|
+
* `side` is not defaulted here even though the Dialog defaults it to `center`,
|
|
20
|
+
* because a sheet with no declared edge is a centred dialog wearing a different
|
|
21
|
+
* name. The four edges are the whole of what separates a sheet from a modal
|
|
22
|
+
* card, and making the caller name one is what stops the Component from quietly
|
|
23
|
+
* rendering a centred card in a product that believes it shipped a panel.
|
|
24
|
+
*/
|
|
25
|
+
export interface SheetContentProps extends Omit<ComponentProps<'div'>, 'children'> {
|
|
26
|
+
/** Which edge of the viewport the panel is anchored to. */
|
|
27
|
+
side: 'top' | 'bottom' | 'left' | 'right';
|
|
28
|
+
/**
|
|
29
|
+
* Whether the built-in close control is rendered. @defaultValue true
|
|
30
|
+
*
|
|
31
|
+
* A sheet is expected to be dismissible, so the control is on by default and
|
|
32
|
+
* turning it off is a decision the caller has to make rather than inherit.
|
|
33
|
+
*/
|
|
34
|
+
showCloseButton?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The accessible name of the built-in close control, when it is rendered.
|
|
37
|
+
*
|
|
38
|
+
* A prop for the same reason the Dialog's is: a consumer that localises its
|
|
39
|
+
* product cannot otherwise localise the one control that dismisses the panel,
|
|
40
|
+
* and a panel that announces an English word in a product that never uses that
|
|
41
|
+
* word is a control the consumer cannot fix.
|
|
42
|
+
*
|
|
43
|
+
* @defaultValue 'Close'
|
|
44
|
+
*/
|
|
45
|
+
closeLabel?: string;
|
|
46
|
+
/** The panel's own contents. */
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
}
|
|
49
|
+
/** The props SheetHeader forwards to a plain container. */
|
|
50
|
+
export interface SheetHeaderProps extends ComponentProps<'div'> {
|
|
51
|
+
}
|
|
52
|
+
/** The props SheetFooter forwards to a plain container. */
|
|
53
|
+
export interface SheetFooterProps extends ComponentProps<'div'> {
|
|
54
|
+
}
|
|
55
|
+
/** The props SheetTitle forwards to the Dialog. */
|
|
56
|
+
export interface SheetTitleProps extends ComponentProps<'h2'> {
|
|
57
|
+
}
|
|
58
|
+
/** The props SheetDescription forwards to the Dialog. */
|
|
59
|
+
export interface SheetDescriptionProps extends ComponentProps<'p'> {
|
|
60
|
+
}
|
|
61
|
+
/** The props SheetClose forwards to the Dialog. */
|
|
62
|
+
export interface SheetCloseProps extends ComponentProps<'button'> {
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A panel anchored to an edge of the viewport.
|
|
66
|
+
*
|
|
67
|
+
* **It is the Dialog with an edge, and it inherits the Dialog's behaviour rather
|
|
68
|
+
* than reimplementing it.** Focus trapping, Escape, the portal, the scroll lock,
|
|
69
|
+
* the backdrop and the return of focus to the trigger are six behaviours that are
|
|
70
|
+
* already correct in the Dialog, and a panel that rolled its own overlay would
|
|
71
|
+
* be a second answer to all six questions, with the second answer being the one
|
|
72
|
+
* that ships the bug. What the sheet adds is the decision a consumer would
|
|
73
|
+
* otherwise get wrong: a panel has a side, and the side is named here rather
|
|
74
|
+
* than defaulted, so a drawer cannot arrive as a centred card with a different
|
|
75
|
+
* name on it.
|
|
76
|
+
*
|
|
77
|
+
* **A sheet dismisses on an outside press, and that is the difference from an
|
|
78
|
+
* alert dialog.** A sheet holds navigation, filters, a detail view: a reader who
|
|
79
|
+
* clicks away from it has said "not now", and the content behind is still there
|
|
80
|
+
* when they come back. If the answer to the sheet cannot safely be deferred, use
|
|
81
|
+
* an AlertDialog, which will not dismiss on a stray press.
|
|
82
|
+
*
|
|
83
|
+
* Always give it a `SheetTitle`, which names the panel for every reader. Use a
|
|
84
|
+
* Dialog for a short task that belongs in the middle of the page, and a Menubar
|
|
85
|
+
* or a NavigationMenu for the top of an application.
|
|
86
|
+
*/
|
|
87
|
+
declare function Sheet({ ...props }: SheetProps): import("react").JSX.Element;
|
|
88
|
+
/** The element that opens the sheet. */
|
|
89
|
+
declare function SheetTrigger({ className, ...props }: SheetTriggerProps): import("react").JSX.Element;
|
|
90
|
+
/** The anchored panel, its backdrop and its portal, over the Dialog's overlay. */
|
|
91
|
+
declare function SheetContent({ className, side, showCloseButton, closeLabel, ...props }: SheetContentProps): import("react").JSX.Element;
|
|
92
|
+
/** The sheet's heading area, above the body. */
|
|
93
|
+
declare function SheetHeader({ className, ...props }: SheetHeaderProps): import("react").JSX.Element;
|
|
94
|
+
/** The sheet's action area, below the body. */
|
|
95
|
+
declare function SheetFooter({ className, ...props }: SheetFooterProps): import("react").JSX.Element;
|
|
96
|
+
/** The sheet's heading. It names the panel for assistive technology. */
|
|
97
|
+
declare function SheetTitle({ className, ...props }: SheetTitleProps): import("react").JSX.Element;
|
|
98
|
+
/** A supporting line under the title. */
|
|
99
|
+
declare function SheetDescription({ className, ...props }: SheetDescriptionProps): import("react").JSX.Element;
|
|
100
|
+
/** A control that closes the sheet from inside its content. */
|
|
101
|
+
declare function SheetClose({ className, ...props }: SheetCloseProps): import("react").JSX.Element;
|
|
102
|
+
export { Sheet, SheetTrigger, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, SheetClose, };
|
|
103
|
+
//# sourceMappingURL=sheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../../src/components/ui/sheet.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAW3C,uDAAuD;AACvD,MAAM,WAAW,UAAU;IACzB,iCAAiC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,2DAA2D;IAC3D,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,iCAAiC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,6DAA6D;AAC7D,MAAM,WAAW,iBAAkB,SAAQ,cAAc,CAAC,QAAQ,CAAC;CAAG;AAEtE;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAChF,2DAA2D;IAC3D,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;IACzC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,2DAA2D;AAC3D,MAAM,WAAW,gBAAiB,SAAQ,cAAc,CAAC,KAAK,CAAC;CAAG;AAElE,2DAA2D;AAC3D,MAAM,WAAW,gBAAiB,SAAQ,cAAc,CAAC,KAAK,CAAC;CAAG;AAElE,mDAAmD;AACnD,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,IAAI,CAAC;CAAG;AAEhE,yDAAyD;AACzD,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,GAAG,CAAC;CAAG;AAErE,mDAAmD;AACnD,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,QAAQ,CAAC;CAAG;AAEpE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,+BAEtC;AAED,wCAAwC;AACxC,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,+BAE/D;AAED,kFAAkF;AAClF,iBAAS,YAAY,CAAC,EACpB,SAAS,EACT,IAAI,EACJ,eAAsB,EACtB,UAAoB,EACpB,GAAG,KAAK,EACT,EAAE,iBAAiB,+BAWnB;AAED,gDAAgD;AAChD,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,+BAE7D;AAED,+CAA+C;AAC/C,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,+BAE7D;AAED,wEAAwE;AACxE,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,+BAE3D;AAED,yCAAyC;AACzC,iBAAS,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,+BAEvE;AAED,+DAA+D;AAC/D,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,+BAE3D;AAED,OAAO,EACL,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,UAAU,GACX,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle, DialogTrigger, } from './dialog.js';
|
|
4
|
+
/**
|
|
5
|
+
* A panel anchored to an edge of the viewport.
|
|
6
|
+
*
|
|
7
|
+
* **It is the Dialog with an edge, and it inherits the Dialog's behaviour rather
|
|
8
|
+
* than reimplementing it.** Focus trapping, Escape, the portal, the scroll lock,
|
|
9
|
+
* the backdrop and the return of focus to the trigger are six behaviours that are
|
|
10
|
+
* already correct in the Dialog, and a panel that rolled its own overlay would
|
|
11
|
+
* be a second answer to all six questions, with the second answer being the one
|
|
12
|
+
* that ships the bug. What the sheet adds is the decision a consumer would
|
|
13
|
+
* otherwise get wrong: a panel has a side, and the side is named here rather
|
|
14
|
+
* than defaulted, so a drawer cannot arrive as a centred card with a different
|
|
15
|
+
* name on it.
|
|
16
|
+
*
|
|
17
|
+
* **A sheet dismisses on an outside press, and that is the difference from an
|
|
18
|
+
* alert dialog.** A sheet holds navigation, filters, a detail view: a reader who
|
|
19
|
+
* clicks away from it has said "not now", and the content behind is still there
|
|
20
|
+
* when they come back. If the answer to the sheet cannot safely be deferred, use
|
|
21
|
+
* an AlertDialog, which will not dismiss on a stray press.
|
|
22
|
+
*
|
|
23
|
+
* Always give it a `SheetTitle`, which names the panel for every reader. Use a
|
|
24
|
+
* Dialog for a short task that belongs in the middle of the page, and a Menubar
|
|
25
|
+
* or a NavigationMenu for the top of an application.
|
|
26
|
+
*/
|
|
27
|
+
function Sheet({ ...props }) {
|
|
28
|
+
return _jsx(Dialog, { ...props });
|
|
29
|
+
}
|
|
30
|
+
/** The element that opens the sheet. */
|
|
31
|
+
function SheetTrigger({ className, ...props }) {
|
|
32
|
+
return _jsx(DialogTrigger, { "data-slot": "sheet-trigger", className: className, ...props });
|
|
33
|
+
}
|
|
34
|
+
/** The anchored panel, its backdrop and its portal, over the Dialog's overlay. */
|
|
35
|
+
function SheetContent({ className, side, showCloseButton = true, closeLabel = 'Close', ...props }) {
|
|
36
|
+
return (_jsx(DialogContent, { "data-slot": "sheet-content", side: side, showCloseButton: showCloseButton, closeLabel: closeLabel, className: className, ...props }));
|
|
37
|
+
}
|
|
38
|
+
/** The sheet's heading area, above the body. */
|
|
39
|
+
function SheetHeader({ className, ...props }) {
|
|
40
|
+
return _jsx("div", { "data-slot": "sheet-header", className: className, ...props });
|
|
41
|
+
}
|
|
42
|
+
/** The sheet's action area, below the body. */
|
|
43
|
+
function SheetFooter({ className, ...props }) {
|
|
44
|
+
return _jsx("div", { "data-slot": "sheet-footer", className: className, ...props });
|
|
45
|
+
}
|
|
46
|
+
/** The sheet's heading. It names the panel for assistive technology. */
|
|
47
|
+
function SheetTitle({ className, ...props }) {
|
|
48
|
+
return _jsx(DialogTitle, { "data-slot": "sheet-title", className: className, ...props });
|
|
49
|
+
}
|
|
50
|
+
/** A supporting line under the title. */
|
|
51
|
+
function SheetDescription({ className, ...props }) {
|
|
52
|
+
return _jsx(DialogDescription, { "data-slot": "sheet-description", className: className, ...props });
|
|
53
|
+
}
|
|
54
|
+
/** A control that closes the sheet from inside its content. */
|
|
55
|
+
function SheetClose({ className, ...props }) {
|
|
56
|
+
return _jsx(DialogClose, { "data-slot": "sheet-close", className: className, ...props });
|
|
57
|
+
}
|
|
58
|
+
export { Sheet, SheetTrigger, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, SheetClose, };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
/** The props the Sidebar accepts. */
|
|
3
|
+
export interface SidebarProps extends Omit<ComponentProps<'div'>, 'children'> {
|
|
4
|
+
/**
|
|
5
|
+
* The controlled collapsed state.
|
|
6
|
+
*
|
|
7
|
+
* Pass it with `onCollapsedChange` when the rail's state has to survive a
|
|
8
|
+
* reload, which is the common case: a product that forgets the rail on every
|
|
9
|
+
* page load teaches a reader that collapsing it was a mistake.
|
|
10
|
+
*/
|
|
11
|
+
collapsed?: boolean;
|
|
12
|
+
/** Whether the rail starts collapsed, for a rail nobody controls. @defaultValue false */
|
|
13
|
+
defaultCollapsed?: boolean;
|
|
14
|
+
/** Called with the state the rail is moving to, for a rail nobody controls. */
|
|
15
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* The rail's id, for a consumer that has to name it.
|
|
18
|
+
*
|
|
19
|
+
* A prop and not a generated one where it matters, for the reason
|
|
20
|
+
* `Collapsible`'s is: a rail a consumer cannot name from their own stylesheet
|
|
21
|
+
* or their own test is a rail they have to reach into the DOM to find. Omit it
|
|
22
|
+
* and one is generated, which is what the toggle points `aria-controls` at.
|
|
23
|
+
*/
|
|
24
|
+
id?: string;
|
|
25
|
+
/** The rail's header, its navigation, its footer, and any control of its own. */
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
/** The props the SidebarHeader accepts. */
|
|
29
|
+
export interface SidebarHeaderProps extends ComponentProps<'div'> {
|
|
30
|
+
}
|
|
31
|
+
/** The props the SidebarNav accepts. */
|
|
32
|
+
export interface SidebarNavProps extends Omit<ComponentProps<'nav'>, 'children'> {
|
|
33
|
+
/**
|
|
34
|
+
* The accessible name of the navigation landmark.
|
|
35
|
+
*
|
|
36
|
+
* Required rather than defaulted, and it sits on the navigation rather than on
|
|
37
|
+
* the rail because a rail can hold more than one set of links: a product rail
|
|
38
|
+
* with a workspace switcher above the navigation and an account menu below it
|
|
39
|
+
* has two things a reader would otherwise hear as one list. The name is the
|
|
40
|
+
* caller's word, because a shared library cannot know whether the answer is
|
|
41
|
+
* "Sections", "Main" or "Navigation".
|
|
42
|
+
*/
|
|
43
|
+
label: string;
|
|
44
|
+
/** The items, in the order a reader should meet them. */
|
|
45
|
+
children?: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The props the SidebarItem accepts.
|
|
49
|
+
*
|
|
50
|
+
* Deliberately not a pass-through of an element's props. An item is a link when
|
|
51
|
+
* it has an `href` and a button when it does not, and one interface that claimed
|
|
52
|
+
* to be both would let a consumer pass `target` to an element that is not a link
|
|
53
|
+
* and type-check it. The item takes the props below and nothing else; a consumer
|
|
54
|
+
* who needs a `data-*` attribute or a click handler on the element itself has an
|
|
55
|
+
* element of their own and does not need this one.
|
|
56
|
+
*/
|
|
57
|
+
export interface SidebarItemProps {
|
|
58
|
+
/**
|
|
59
|
+
* The name of the item: the words beside the icon, and the item's accessible
|
|
60
|
+
* name in every state.
|
|
61
|
+
*
|
|
62
|
+
* Required, and it is the whole answer to the collapsed rail. A rail collapses
|
|
63
|
+
* to icons, and an icon is not a name: a screen reader announces "link" once
|
|
64
|
+
* for each of them, and a sighted reader who cannot tell the marks apart has
|
|
65
|
+
* nothing to go on. So the words are always in the document, shown beside the
|
|
66
|
+
* icon while the rail is open and moved to `sr-only` while it is closed, and
|
|
67
|
+
* the name a reader hears is the same string in both states.
|
|
68
|
+
*/
|
|
69
|
+
label: string;
|
|
70
|
+
/**
|
|
71
|
+
* Where the item goes.
|
|
72
|
+
*
|
|
73
|
+
* Omit it for an item that acts rather than navigates, and the item renders a
|
|
74
|
+
* button. A navigation rail in a real product holds both kinds: a "Billing"
|
|
75
|
+
* link and a "New project" that opens something. A Component that only drew
|
|
76
|
+
* anchors would leave the second kind to be hand-built, which is the gap this
|
|
77
|
+
* rail exists to close.
|
|
78
|
+
*/
|
|
79
|
+
href?: string;
|
|
80
|
+
/**
|
|
81
|
+
* What the item does when it is activated.
|
|
82
|
+
*
|
|
83
|
+
* Required for an item with no `href`, because an item that acts rather than
|
|
84
|
+
* navigates renders a real button and a button that does nothing is a control
|
|
85
|
+
* a reader can find and press with no result, which is the same defect as a
|
|
86
|
+
* list that renders an empty item. On an item that has an `href` it runs
|
|
87
|
+
* alongside the navigation.
|
|
88
|
+
*/
|
|
89
|
+
onClick?: () => void;
|
|
90
|
+
/**
|
|
91
|
+
* The mark at the leading edge. It is never the name.
|
|
92
|
+
*
|
|
93
|
+
* Pass a `ProductMark`, a `lucide-react` icon, or a node of your own. Whatever
|
|
94
|
+
* is passed is drawn in the item's own ink, so it takes the item's state
|
|
95
|
+
* rather than keeping a colour of its own.
|
|
96
|
+
*/
|
|
97
|
+
icon?: ReactNode;
|
|
98
|
+
/**
|
|
99
|
+
* Whether this is the page the reader is on. @defaultValue false
|
|
100
|
+
*
|
|
101
|
+
* Marking the current item is the one thing a rail cannot leave to inference,
|
|
102
|
+
* and it is not a colour. The item is given `aria-current="page"`, which is
|
|
103
|
+
* what a reader is told and what a browser's find-in-page uses to find the
|
|
104
|
+
* current page, and it is given a rail down its leading edge, which is a shape
|
|
105
|
+
* a reader who cannot separate two surfaces can still see. Colour is the third
|
|
106
|
+
* signal and never the only one.
|
|
107
|
+
*/
|
|
108
|
+
current?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* A trailing slot: a count, a status, a badge.
|
|
111
|
+
*
|
|
112
|
+
* It is `aria-hidden` and it is not drawn while the rail is collapsed. Both
|
|
113
|
+
* decisions are the same one: the item's accessible name is its `label` and
|
|
114
|
+
* nothing else, which is what makes the name in a collapsed rail the same name
|
|
115
|
+
* as the name in an open one. A 4rem rail has room for one mark and a badge
|
|
116
|
+
* beside it is a badge at four pixels, and a count a reader has to have is the
|
|
117
|
+
* count on the page the item leads to. A caller whose count is part of the
|
|
118
|
+
* item's meaning puts it in the `label`.
|
|
119
|
+
*/
|
|
120
|
+
children?: ReactNode;
|
|
121
|
+
/**
|
|
122
|
+
* Opens the destination in a new browsing context, which defaults the link
|
|
123
|
+
* relationship to `noopener noreferrer`. Prism does not decide what counts as
|
|
124
|
+
* external: a cross-origin destination is not by itself a reason for a new tab.
|
|
125
|
+
*/
|
|
126
|
+
newTab?: boolean;
|
|
127
|
+
/** Layout only. */
|
|
128
|
+
className?: string;
|
|
129
|
+
}
|
|
130
|
+
/** The props the SidebarToggle accepts. */
|
|
131
|
+
export interface SidebarToggleProps extends Omit<ComponentProps<'button'>, 'children'> {
|
|
132
|
+
/**
|
|
133
|
+
* The words for the control while the rail is open.
|
|
134
|
+
*
|
|
135
|
+
* Required, and it names the action rather than the control: a button a reader
|
|
136
|
+
* is told is called "Collapse sidebar" is a button that collapses the sidebar.
|
|
137
|
+
* The state is on `aria-expanded` as well, so a reader who meets the control
|
|
138
|
+
* without its words still learns whether the rail is open.
|
|
139
|
+
*/
|
|
140
|
+
collapseLabel: string;
|
|
141
|
+
/** The words for the same control while the rail is collapsed. */
|
|
142
|
+
expandLabel: string;
|
|
143
|
+
}
|
|
144
|
+
/** The props the SidebarFooter accepts. */
|
|
145
|
+
export interface SidebarFooterProps extends ComponentProps<'div'> {
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A navigation rail with its own ink, its own focus ring, and a collapsed state.
|
|
149
|
+
*
|
|
150
|
+
* **It exists because the sidebar tokens were the one family in the contract
|
|
151
|
+
* with no consumer.** `sidebar` through `sidebar-ring` were published, gated in
|
|
152
|
+
* both modes and in every pack, and nothing in the package used them: the one
|
|
153
|
+
* rail the package had drew its surface from `border` and left its focus ring to
|
|
154
|
+
* `ring`, which is a different token on a different step. Those two are not
|
|
155
|
+
* interchangeable and the contract says why. `ring` is pinned to a step that
|
|
156
|
+
* clears 3:1 against the page ground, and the sidebar ground is one step off the
|
|
157
|
+
* page ground in either mode, so on Mint in light mode the page ring measures
|
|
158
|
+
* 2.86:1 against the rail while `sidebar-ring` measures 4.11:1. A rail that
|
|
159
|
+
* inherited the page ring was a focus indicator a reader could not see in one
|
|
160
|
+
* pack out of six, and it looked correct in the other five.
|
|
161
|
+
*
|
|
162
|
+
* **The collapsed state is the same rail at a smaller width, not a second
|
|
163
|
+
* Component.** An icon-only rail that dropped the hover surface, the focus ring
|
|
164
|
+
* or the current marking would be a worse version of the thing rather than a
|
|
165
|
+
* smaller one, and the reader who paid for the density paid for a rail that is
|
|
166
|
+
* harder to use. So the hover surface, the ring, the current rail and the
|
|
167
|
+
* accessible name are all present in both states, and only the words and the
|
|
168
|
+
* padding change. The name in particular: the words move to `sr-only` rather than
|
|
169
|
+
* leaving the document, so a collapsed rail is still six links a reader can hear
|
|
170
|
+
* and still six links a browser's find-in-page can find.
|
|
171
|
+
*
|
|
172
|
+
* **The ring is `sidebar-ring`, and this Component does not suppress the
|
|
173
|
+
* browser's own outline.** Every other focusable Component here suppresses it and
|
|
174
|
+
* draws `ring-ring` in its place. This one does not, for two reasons that point
|
|
175
|
+
* the same way. The ring it draws is a different role, and
|
|
176
|
+
* `check-focus-indicators.mjs` recognises exactly one ring role in the pattern it
|
|
177
|
+
* reads a full-strength ring from, so a Component that claimed to replace the
|
|
178
|
+
* outline here would be claiming a replacement the repository cannot currently
|
|
179
|
+
* verify. A wide navigation item is also the one place in this package where a
|
|
180
|
+
* second indicator costs nothing, and WCAG 2.4.11 asks that the focused control
|
|
181
|
+
* be identifiable rather than that exactly one thing identify it.
|
|
182
|
+
*
|
|
183
|
+
* **It is a client Component**, because the collapsed state is a state, and a
|
|
184
|
+
* state with no owner in this Component means every consumer writes the same
|
|
185
|
+
* `useState` and the same context around it. The toggle is a part rather than a
|
|
186
|
+
* built-in control, so a product puts it in the rail's header or its footer
|
|
187
|
+
* without the Component deciding where a rail's controls belong.
|
|
188
|
+
*/
|
|
189
|
+
declare function Sidebar({ collapsed: controlled, defaultCollapsed, onCollapsedChange, id, children, className, ...props }: SidebarProps): import("react").JSX.Element;
|
|
190
|
+
/**
|
|
191
|
+
* The space at the top of the rail, for a brand or a workspace switcher.
|
|
192
|
+
*
|
|
193
|
+
* A slot and nothing more, because what sits in it is the product's: a mark, a
|
|
194
|
+
* switcher, a search field. The padding follows the rail's state, so a collapsed
|
|
195
|
+
* rail's mark is centred rather than hanging off the left edge of a 4rem column.
|
|
196
|
+
*/
|
|
197
|
+
declare function SidebarHeader({ className, ...props }: SidebarHeaderProps): import("react").JSX.Element;
|
|
198
|
+
/** The navigation, as a named landmark, and the part of the rail that scrolls. */
|
|
199
|
+
declare function SidebarNav({ label, className, children, ...props }: SidebarNavProps): import("react").JSX.Element;
|
|
200
|
+
/**
|
|
201
|
+
* The space at the foot of the rail, for an account menu or a version.
|
|
202
|
+
*
|
|
203
|
+
* A slot above a rail's own border, and the border is the sidebar's, so the
|
|
204
|
+
* divider reads as part of the rail rather than as a rule drawn on the page.
|
|
205
|
+
*/
|
|
206
|
+
declare function SidebarFooter({ className, ...props }: SidebarFooterProps): import("react").JSX.Element;
|
|
207
|
+
/**
|
|
208
|
+
* One item: an icon, its name, and the marking of the page the reader is on.
|
|
209
|
+
*
|
|
210
|
+
* An item is a link when it has an `href` and a button when it does not, because
|
|
211
|
+
* a rail holds both and a reader meets them the same way either way. The two
|
|
212
|
+
* renderings take the same class string, so an item that is a link on one route
|
|
213
|
+
* and a button on another does not change its hover surface, its ring or its
|
|
214
|
+
* current marking.
|
|
215
|
+
*/
|
|
216
|
+
declare function SidebarItem({ label, href, onClick, icon, current, children, newTab, className, }: SidebarItemProps): import("react").JSX.Element;
|
|
217
|
+
/**
|
|
218
|
+
* The control that collapses and expands the rail.
|
|
219
|
+
*
|
|
220
|
+
* A part rather than something the rail draws, because where a rail's controls
|
|
221
|
+
* belong is the product's decision: a rail whose toggle is in its header fights
|
|
222
|
+
* a workspace switcher for the same row. It points at the rail by id, so the
|
|
223
|
+
* region it controls is the element the rail actually rendered rather than a name
|
|
224
|
+
* that has drifted from it.
|
|
225
|
+
*/
|
|
226
|
+
declare function SidebarToggle({ collapseLabel, expandLabel, className, ...props }: SidebarToggleProps): import("react").JSX.Element;
|
|
227
|
+
export { Sidebar, SidebarHeader, SidebarNav, SidebarItem, SidebarFooter, SidebarToggle };
|
|
228
|
+
//# sourceMappingURL=sidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../../src/components/ui/sidebar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAmCd,qCAAqC;AACrC,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC3E;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,yFAAyF;IACzF,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;IAChD;;;;;;;OAOG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,iFAAiF;IACjF,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAmB,SAAQ,cAAc,CAAC,KAAK,CAAC;CAAG;AAEpE,wCAAwC;AACxC,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC9E;;;;;;;;;OASG;IACH,KAAK,EAAE,MAAM,CAAA;IACb,yDAAyD;IACzD,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,mBAAmB;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IACpF;;;;;;;OAOG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAmB,SAAQ,cAAc,CAAC,KAAK,CAAC;CAAG;AAkBpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,iBAAS,OAAO,CAAC,EACf,SAAS,EAAE,UAAU,EACrB,gBAAwB,EACxB,iBAAiB,EACjB,EAAE,EACF,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,YAAY,+BA+Cd;AAED;;;;;;GAMG;AACH,iBAAS,aAAa,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,+BASjE;AAED,kFAAkF;AAClF,iBAAS,UAAU,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,+BAgB5E;AAED;;;;;GAKG;AACH,iBAAS,aAAa,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,+BASjE;AAED;;;;;;;;GAQG;AACH,iBAAS,WAAW,CAAC,EACnB,KAAK,EACL,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,OAAe,EACf,QAAQ,EACR,MAAM,EACN,SAAS,GACV,EAAE,gBAAgB,+BAgGlB;AAED;;;;;;;;GAQG;AACH,iBAAS,aAAa,CAAC,EACrB,aAAa,EACb,WAAW,EACX,SAAS,EACT,GAAG,KAAK,EACT,EAAE,kBAAkB,+BA0BpB;AAED,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { PanelLeftClose, PanelLeftOpen } from 'lucide-react';
|
|
4
|
+
import { createContext, useContext, useId, useMemo, useState, } from 'react';
|
|
5
|
+
import { cn } from '../../lib/utils.js';
|
|
6
|
+
/**
|
|
7
|
+
* The default, for a part rendered outside a rail.
|
|
8
|
+
*
|
|
9
|
+
* Expanded, because a part outside a rail has no rail to be collapsed against,
|
|
10
|
+
* and a rail that starts collapsed because nobody said otherwise is a rail whose
|
|
11
|
+
* content a reader cannot see. The empty id means a toggle outside a rail points
|
|
12
|
+
* at nothing, which is honest: there is nothing there to point at.
|
|
13
|
+
*/
|
|
14
|
+
const SIDEBAR_STATE = {
|
|
15
|
+
collapsed: false,
|
|
16
|
+
id: '',
|
|
17
|
+
toggle: () => undefined,
|
|
18
|
+
};
|
|
19
|
+
const SidebarStateContext = createContext(SIDEBAR_STATE);
|
|
20
|
+
/** The rail's state, from the rail above it. */
|
|
21
|
+
function useSidebarState() {
|
|
22
|
+
return useContext(SidebarStateContext);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The fill and the ink an item takes, from the state it is in.
|
|
26
|
+
*
|
|
27
|
+
* Both halves are here because a fill and an inheritance are the same control on
|
|
28
|
+
* the page ground and a different one here. A `bg-sidebar-primary` with the rail's
|
|
29
|
+
* inherited ink would be `sidebar-primary` behind `sidebar-foreground`, which is
|
|
30
|
+
* neutral 900 behind neutral 900 in light mode. The token gate measures the pair
|
|
31
|
+
* it was given and cannot see which ink a class string failed to state.
|
|
32
|
+
*/
|
|
33
|
+
const ITEM_FILL = {
|
|
34
|
+
current: 'bg-sidebar-primary text-sidebar-primary-foreground',
|
|
35
|
+
// No fill at all rather than a transparent one: the rail's own surface is the
|
|
36
|
+
// surface here, and a `bg-transparent` would be a second statement of it.
|
|
37
|
+
rest: '',
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* A navigation rail with its own ink, its own focus ring, and a collapsed state.
|
|
41
|
+
*
|
|
42
|
+
* **It exists because the sidebar tokens were the one family in the contract
|
|
43
|
+
* with no consumer.** `sidebar` through `sidebar-ring` were published, gated in
|
|
44
|
+
* both modes and in every pack, and nothing in the package used them: the one
|
|
45
|
+
* rail the package had drew its surface from `border` and left its focus ring to
|
|
46
|
+
* `ring`, which is a different token on a different step. Those two are not
|
|
47
|
+
* interchangeable and the contract says why. `ring` is pinned to a step that
|
|
48
|
+
* clears 3:1 against the page ground, and the sidebar ground is one step off the
|
|
49
|
+
* page ground in either mode, so on Mint in light mode the page ring measures
|
|
50
|
+
* 2.86:1 against the rail while `sidebar-ring` measures 4.11:1. A rail that
|
|
51
|
+
* inherited the page ring was a focus indicator a reader could not see in one
|
|
52
|
+
* pack out of six, and it looked correct in the other five.
|
|
53
|
+
*
|
|
54
|
+
* **The collapsed state is the same rail at a smaller width, not a second
|
|
55
|
+
* Component.** An icon-only rail that dropped the hover surface, the focus ring
|
|
56
|
+
* or the current marking would be a worse version of the thing rather than a
|
|
57
|
+
* smaller one, and the reader who paid for the density paid for a rail that is
|
|
58
|
+
* harder to use. So the hover surface, the ring, the current rail and the
|
|
59
|
+
* accessible name are all present in both states, and only the words and the
|
|
60
|
+
* padding change. The name in particular: the words move to `sr-only` rather than
|
|
61
|
+
* leaving the document, so a collapsed rail is still six links a reader can hear
|
|
62
|
+
* and still six links a browser's find-in-page can find.
|
|
63
|
+
*
|
|
64
|
+
* **The ring is `sidebar-ring`, and this Component does not suppress the
|
|
65
|
+
* browser's own outline.** Every other focusable Component here suppresses it and
|
|
66
|
+
* draws `ring-ring` in its place. This one does not, for two reasons that point
|
|
67
|
+
* the same way. The ring it draws is a different role, and
|
|
68
|
+
* `check-focus-indicators.mjs` recognises exactly one ring role in the pattern it
|
|
69
|
+
* reads a full-strength ring from, so a Component that claimed to replace the
|
|
70
|
+
* outline here would be claiming a replacement the repository cannot currently
|
|
71
|
+
* verify. A wide navigation item is also the one place in this package where a
|
|
72
|
+
* second indicator costs nothing, and WCAG 2.4.11 asks that the focused control
|
|
73
|
+
* be identifiable rather than that exactly one thing identify it.
|
|
74
|
+
*
|
|
75
|
+
* **It is a client Component**, because the collapsed state is a state, and a
|
|
76
|
+
* state with no owner in this Component means every consumer writes the same
|
|
77
|
+
* `useState` and the same context around it. The toggle is a part rather than a
|
|
78
|
+
* built-in control, so a product puts it in the rail's header or its footer
|
|
79
|
+
* without the Component deciding where a rail's controls belong.
|
|
80
|
+
*/
|
|
81
|
+
function Sidebar({ collapsed: controlled, defaultCollapsed = false, onCollapsedChange, id, children, className, ...props }) {
|
|
82
|
+
const [internal, setInternal] = useState(defaultCollapsed);
|
|
83
|
+
const generated = useId();
|
|
84
|
+
// The controlled prop is the whole truth when there is one. A rail that wrote
|
|
85
|
+
// only its own state would show a state its parent had already overridden, and
|
|
86
|
+
// a rail whose parent later stops controlling it would jump to a state nobody
|
|
87
|
+
// chose.
|
|
88
|
+
const collapsed = controlled ?? internal;
|
|
89
|
+
const railId = id ?? generated;
|
|
90
|
+
const state = useMemo(() => ({
|
|
91
|
+
collapsed,
|
|
92
|
+
id: railId,
|
|
93
|
+
toggle: () => {
|
|
94
|
+
const following = !collapsed;
|
|
95
|
+
setInternal(following);
|
|
96
|
+
onCollapsedChange?.(following);
|
|
97
|
+
},
|
|
98
|
+
}), [collapsed, railId, onCollapsedChange]);
|
|
99
|
+
return (_jsx(SidebarStateContext.Provider, { value: state, children: _jsx("div", { "data-slot": "sidebar", id: railId, "data-collapsed": collapsed, className: cn('bg-sidebar text-sidebar-foreground border-sidebar-border flex shrink-0 flex-col self-stretch border-r',
|
|
100
|
+
// The width is the state feedback, and it is the only motion on the
|
|
101
|
+
// rail: a rail that collapsed and looked identical teaches a reader
|
|
102
|
+
// that the control did nothing.
|
|
103
|
+
'transition-[width] duration-base ease-out', collapsed ? 'w-16' : 'w-64', className), ...props, children: children }) }));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The space at the top of the rail, for a brand or a workspace switcher.
|
|
107
|
+
*
|
|
108
|
+
* A slot and nothing more, because what sits in it is the product's: a mark, a
|
|
109
|
+
* switcher, a search field. The padding follows the rail's state, so a collapsed
|
|
110
|
+
* rail's mark is centred rather than hanging off the left edge of a 4rem column.
|
|
111
|
+
*/
|
|
112
|
+
function SidebarHeader({ className, ...props }) {
|
|
113
|
+
const { collapsed } = useSidebarState();
|
|
114
|
+
return (_jsx("div", { "data-slot": "sidebar-header", className: cn(collapsed ? 'p-2' : 'p-3', className), ...props }));
|
|
115
|
+
}
|
|
116
|
+
/** The navigation, as a named landmark, and the part of the rail that scrolls. */
|
|
117
|
+
function SidebarNav({ label, className, children, ...props }) {
|
|
118
|
+
const { collapsed } = useSidebarState();
|
|
119
|
+
return (_jsx("nav", { "data-slot": "sidebar-nav", "aria-label": label, className: cn('flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto', collapsed ? 'px-2' : 'px-3', className), ...props, children: children }));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The space at the foot of the rail, for an account menu or a version.
|
|
123
|
+
*
|
|
124
|
+
* A slot above a rail's own border, and the border is the sidebar's, so the
|
|
125
|
+
* divider reads as part of the rail rather than as a rule drawn on the page.
|
|
126
|
+
*/
|
|
127
|
+
function SidebarFooter({ className, ...props }) {
|
|
128
|
+
const { collapsed } = useSidebarState();
|
|
129
|
+
return (_jsx("div", { "data-slot": "sidebar-footer", className: cn('border-sidebar-border border-t', collapsed ? 'p-2' : 'p-3', className), ...props }));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* One item: an icon, its name, and the marking of the page the reader is on.
|
|
133
|
+
*
|
|
134
|
+
* An item is a link when it has an `href` and a button when it does not, because
|
|
135
|
+
* a rail holds both and a reader meets them the same way either way. The two
|
|
136
|
+
* renderings take the same class string, so an item that is a link on one route
|
|
137
|
+
* and a button on another does not change its hover surface, its ring or its
|
|
138
|
+
* current marking.
|
|
139
|
+
*/
|
|
140
|
+
function SidebarItem({ label, href, onClick, icon, current = false, children, newTab, className, }) {
|
|
141
|
+
const { collapsed } = useSidebarState();
|
|
142
|
+
const classes = cn('text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative flex h-9 items-center rounded-md text-sm', 'transition-colors duration-fast ease-out',
|
|
143
|
+
// The sidebar's own ring, on the sidebar's own ground. See the rail's own
|
|
144
|
+
// note: this is the one focusable surface in the package where the page ring
|
|
145
|
+
// measures below 3:1 in a real pack.
|
|
146
|
+
'focus-visible:ring-sidebar-ring focus-visible:ring-[3px]', collapsed ? 'justify-center px-0' : 'gap-2 px-3', ITEM_FILL[current ? 'current' : 'rest'],
|
|
147
|
+
// Weight as the second channel for "current", so the marking survives a
|
|
148
|
+
// reader who cannot see the rail down the item's leading edge.
|
|
149
|
+
current && 'font-medium', className);
|
|
150
|
+
const content = (_jsxs(_Fragment, { children: [current ? (_jsx("span", { "data-slot": "sidebar-item-mark", "aria-hidden": "true", className: "bg-sidebar-primary absolute inset-y-1.5 left-0 w-0.5 rounded-full" })) : null, icon === undefined ? null : (_jsx("span", { "data-slot": "sidebar-item-icon", className: "flex size-4 shrink-0 items-center justify-center [&_svg]:size-4", children: icon })), _jsx("span", { "data-slot": "sidebar-item-label", className: cn(collapsed ? 'sr-only' : 'min-w-0 truncate'), children: label }), children === undefined || collapsed ? null : (_jsx("span", { "data-slot": "sidebar-item-trailing", "aria-hidden": "true", className: "ml-auto shrink-0 text-xs tabular-nums", children: children }))] }));
|
|
151
|
+
// An anchor with no `href` is not a link: it has no role and it is not
|
|
152
|
+
// focusable, so an item that acts rather than navigates has to be a real
|
|
153
|
+
// button or it is an element a keyboard cannot reach.
|
|
154
|
+
if (href === undefined) {
|
|
155
|
+
return (_jsx("button", { type: "button", "data-slot": "sidebar-item", "data-current": current ? 'true' : undefined, "aria-current": current ? 'page' : undefined, onClick: onClick, className: classes, children: content }));
|
|
156
|
+
}
|
|
157
|
+
return (_jsx("a", { "data-slot": "sidebar-item", "data-current": current ? 'true' : undefined, "aria-current": current ? 'page' : undefined, href: href, target: newTab ? '_blank' : undefined, rel: newTab ? 'noopener noreferrer' : undefined, onClick: onClick, className: classes, children: content }));
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The control that collapses and expands the rail.
|
|
161
|
+
*
|
|
162
|
+
* A part rather than something the rail draws, because where a rail's controls
|
|
163
|
+
* belong is the product's decision: a rail whose toggle is in its header fights
|
|
164
|
+
* a workspace switcher for the same row. It points at the rail by id, so the
|
|
165
|
+
* region it controls is the element the rail actually rendered rather than a name
|
|
166
|
+
* that has drifted from it.
|
|
167
|
+
*/
|
|
168
|
+
function SidebarToggle({ collapseLabel, expandLabel, className, ...props }) {
|
|
169
|
+
const { collapsed, id, toggle } = useSidebarState();
|
|
170
|
+
return (_jsx("button", { type: "button", "data-slot": "sidebar-toggle", "data-collapsed": collapsed, "aria-expanded": !collapsed, "aria-controls": id, "aria-label": collapsed ? expandLabel : collapseLabel, onClick: toggle, className: cn('text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-sidebar-ring focus-visible:ring-[3px] flex size-8 shrink-0 items-center justify-center rounded-md', 'transition-colors duration-fast ease-out', collapsed && 'mx-auto', className), ...props, children: collapsed ? (_jsx(PanelLeftOpen, { className: "size-4", "aria-hidden": "true" })) : (_jsx(PanelLeftClose, { className: "size-4", "aria-hidden": "true" })) }));
|
|
171
|
+
}
|
|
172
|
+
export { Sidebar, SidebarHeader, SidebarNav, SidebarItem, SidebarFooter, SidebarToggle };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Slider as SliderPrimitive } from '@base-ui/react/slider';
|
|
4
|
-
import { cn } from '../../lib/utils';
|
|
4
|
+
import { cn } from '../../lib/utils.js';
|
|
5
5
|
/**
|
|
6
6
|
* A control for choosing a number along a range.
|
|
7
7
|
*
|