@15gifts/back-office-kit 0.1.0-alpha.0 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/dist/browser/back-office-kit.js +6649 -5932
- package/dist/components/Alert/Alert.css.d.ts +1 -0
- package/dist/components/Alert/Alert.d.ts +12 -2
- package/dist/components/Alert/Alert.js +33 -29
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/Alert/Alert.styles.js +2 -2
- package/dist/components/Alert/Alert.styles.js.map +1 -1
- package/dist/components/AppShell/AppShell.css.d.ts +2 -0
- package/dist/components/AppShell/AppShell.d.ts +3 -1
- package/dist/components/AppShell/AppShell.js +42 -26
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/AppShell/AppShell.styles.js +3 -2
- package/dist/components/AppShell/AppShell.styles.js.map +1 -1
- package/dist/components/Avatar/Avatar.d.ts +1 -0
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Badge/Badge.css.d.ts +5 -0
- package/dist/components/Badge/Badge.d.ts +4 -1
- package/dist/components/Badge/Badge.js +6 -5
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Badge/Badge.styles.js +16 -15
- package/dist/components/Badge/Badge.styles.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.css.d.ts +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +27 -27
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.styles.js +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.styles.js.map +1 -1
- package/dist/components/Button/Button.css.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +5 -4
- package/dist/components/Button/Button.js +21 -21
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.styles.js.map +1 -1
- package/dist/components/Card/Card.css.d.ts +2 -0
- package/dist/components/Card/Card.d.ts +7 -1
- package/dist/components/Card/Card.js +33 -22
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Card/Card.styles.js +2 -2
- package/dist/components/Card/Card.styles.js.map +1 -1
- package/dist/components/ChatTranscript/ChatTranscript.d.ts +2 -2
- package/dist/components/ChatTranscript/ChatTranscript.js +74 -71
- package/dist/components/ChatTranscript/ChatTranscript.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +2 -1
- package/dist/components/Checkbox/Checkbox.js +30 -34
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.styles.js.map +1 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.css.d.ts +2 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +28 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.js +66 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.js.map +1 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.styles.js +10 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.styles.js.map +1 -0
- package/dist/components/CheckboxGroup/index.d.ts +2 -0
- package/dist/components/Chip/Chip.css.d.ts +2 -0
- package/dist/components/Chip/Chip.d.ts +15 -3
- package/dist/components/Chip/Chip.js +35 -16
- package/dist/components/Chip/Chip.js.map +1 -1
- package/dist/components/Chip/Chip.styles.js +2 -2
- package/dist/components/Chip/Chip.styles.js.map +1 -1
- package/dist/components/Chip/index.d.ts +1 -1
- package/dist/components/ColorPicker/ColorPicker.d.ts +3 -1
- package/dist/components/ColorPicker/ColorPicker.js +46 -47
- package/dist/components/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/components/ColorPicker/ColorPicker.styles.js.map +1 -1
- package/dist/components/Combobox/Combobox.d.ts +28 -4
- package/dist/components/Combobox/Combobox.js +130 -109
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.d.ts +11 -0
- package/dist/components/CopyButton/CopyButton.js +40 -0
- package/dist/components/CopyButton/CopyButton.js.map +1 -0
- package/dist/components/CopyButton/index.d.ts +2 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +10 -3
- package/dist/components/DateRangePicker/DateRangePicker.js +107 -110
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.styles.js +2 -2
- package/dist/components/DateRangePicker/DateRangePicker.styles.js.map +1 -1
- package/dist/components/DateTimeInput/DateTimeInput.d.ts +1 -1
- package/dist/components/DateTimeInput/DateTimeInput.js +20 -28
- package/dist/components/DateTimeInput/DateTimeInput.js.map +1 -1
- package/dist/components/DateTimeInput/DateTimeInput.styles.js +1 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts +8 -0
- package/dist/components/DescriptionList/DescriptionList.js +2 -1
- package/dist/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/components/DetailsSummary/DetailsSummary.css.d.ts +1 -0
- package/dist/components/DetailsSummary/DetailsSummary.d.ts +5 -1
- package/dist/components/DetailsSummary/DetailsSummary.js +15 -15
- package/dist/components/DetailsSummary/DetailsSummary.js.map +1 -1
- package/dist/components/DetailsSummary/DetailsSummary.styles.js +10 -2
- package/dist/components/DetailsSummary/DetailsSummary.styles.js.map +1 -1
- package/dist/components/DetailsSummary/index.d.ts +1 -1
- package/dist/components/Drawer/Drawer.css.d.ts +3 -0
- package/dist/components/Drawer/Drawer.d.ts +24 -3
- package/dist/components/Drawer/Drawer.js +55 -46
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/Drawer/Drawer.styles.js +7 -2
- package/dist/components/Drawer/Drawer.styles.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.css.d.ts +16 -0
- package/dist/components/EmptyState/EmptyState.d.ts +15 -0
- package/dist/components/EmptyState/EmptyState.js +37 -0
- package/dist/components/EmptyState/EmptyState.js.map +1 -0
- package/dist/components/EmptyState/EmptyState.styles.js +15 -0
- package/dist/components/EmptyState/EmptyState.styles.js.map +1 -0
- package/dist/components/EmptyState/index.d.ts +2 -0
- package/dist/components/EnvironmentChip/EnvironmentChip.css.d.ts +5 -0
- package/dist/components/EnvironmentChip/EnvironmentChip.d.ts +13 -5
- package/dist/components/EnvironmentChip/EnvironmentChip.js +14 -3
- package/dist/components/EnvironmentChip/EnvironmentChip.js.map +1 -1
- package/dist/components/EnvironmentChip/EnvironmentChip.styles.js +3 -2
- package/dist/components/EnvironmentChip/EnvironmentChip.styles.js.map +1 -1
- package/dist/components/EnvironmentChip/index.d.ts +2 -2
- package/dist/components/Field/Field.css.d.ts +0 -1
- package/dist/components/Field/Field.d.ts +11 -28
- package/dist/components/Field/Field.js +25 -36
- package/dist/components/Field/Field.js.map +1 -1
- package/dist/components/Field/Field.styles.js +2 -2
- package/dist/components/Field/Field.styles.js.map +1 -1
- package/dist/components/Field/index.d.ts +1 -1
- package/dist/components/Fieldset/Fieldset.d.ts +1 -0
- package/dist/components/Fieldset/Fieldset.js.map +1 -1
- package/dist/components/Fieldset/Fieldset.styles.js.map +1 -1
- package/dist/components/Grid/Grid.css.d.ts +22 -0
- package/dist/components/Grid/Grid.d.ts +21 -0
- package/dist/components/Grid/Grid.js +23 -0
- package/dist/components/Grid/Grid.js.map +1 -0
- package/dist/components/Grid/Grid.styles.js +28 -0
- package/dist/components/Grid/Grid.styles.js.map +1 -0
- package/dist/components/Grid/index.d.ts +2 -0
- package/dist/components/List/List.d.ts +1 -0
- package/dist/components/List/List.js.map +1 -1
- package/dist/components/Loader/Loader.d.ts +1 -1
- package/dist/components/Loader/Loader.js +6 -2
- package/dist/components/Loader/Loader.js.map +1 -1
- package/dist/components/Menu/Menu.d.ts +25 -1
- package/dist/components/Menu/Menu.js +1 -1
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Menu/Menu.styles.js.map +1 -1
- package/dist/components/MetricBar/MetricBar.css.d.ts +5 -0
- package/dist/components/MetricBar/MetricBar.d.ts +9 -1
- package/dist/components/MetricBar/MetricBar.js +38 -22
- package/dist/components/MetricBar/MetricBar.js.map +1 -1
- package/dist/components/MetricBar/MetricBar.styles.js +15 -10
- package/dist/components/MetricBar/MetricBar.styles.js.map +1 -1
- package/dist/components/Modal/Modal.d.ts +6 -0
- package/dist/components/Modal/Modal.js +25 -28
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Modal/Modal.styles.js +2 -1
- package/dist/components/Modal/Modal.styles.js.map +1 -1
- package/dist/components/NavRail/NavRail.css.d.ts +2 -0
- package/dist/components/NavRail/NavRail.d.ts +22 -7
- package/dist/components/NavRail/NavRail.js +79 -58
- package/dist/components/NavRail/NavRail.js.map +1 -1
- package/dist/components/NavRail/NavRail.styles.js +3 -2
- package/dist/components/NavRail/NavRail.styles.js.map +1 -1
- package/dist/components/NavRail/index.d.ts +1 -1
- package/dist/components/NumberInput/NumberInput.d.ts +9 -1
- package/dist/components/NumberInput/NumberInput.js +37 -31
- package/dist/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/components/PageHeader/PageHeader.css.d.ts +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts +3 -1
- package/dist/components/PageHeader/PageHeader.js +21 -23
- package/dist/components/PageHeader/PageHeader.js.map +1 -1
- package/dist/components/PageHeader/PageHeader.styles.js +1 -1
- package/dist/components/PageHeader/PageHeader.styles.js.map +1 -1
- package/dist/components/Pagination/Pagination.d.ts +5 -0
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/Popover/Popover.d.ts +9 -1
- package/dist/components/Popover/Popover.js +7 -6
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Popover/Popover.styles.js.map +1 -1
- package/dist/components/PortalContainer/PortalContainer.d.ts +1 -0
- package/dist/components/PortalContainer/PortalContainer.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.css.d.ts +3 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +5 -1
- package/dist/components/ProgressBar/ProgressBar.js +21 -7
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.styles.js +6 -6
- package/dist/components/ProgressBar/ProgressBar.styles.js.map +1 -1
- package/dist/components/RadioCards/RadioCards.d.ts +8 -2
- package/dist/components/RadioCards/RadioCards.js +40 -44
- package/dist/components/RadioCards/RadioCards.js.map +1 -1
- package/dist/components/SaveBar/SaveBar.d.ts +6 -1
- package/dist/components/SaveBar/SaveBar.js +1 -2
- package/dist/components/SaveBar/SaveBar.js.map +1 -1
- package/dist/components/SaveBar/SaveBar.styles.js.map +1 -1
- package/dist/components/Select/Select.css.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +32 -5
- package/dist/components/Select/Select.js +91 -62
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/Select.styles.js +3 -2
- package/dist/components/Select/Select.styles.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.d.ts +2 -0
- package/dist/components/Skeleton/Skeleton.js +20 -19
- package/dist/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/components/Stack/Stack.css.d.ts +4 -1
- package/dist/components/Stack/Stack.d.ts +7 -3
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/Stack.styles.js +16 -23
- package/dist/components/Stack/Stack.styles.js.map +1 -1
- package/dist/components/StatCard/StatCard.d.ts +3 -0
- package/dist/components/StatCard/StatCard.js.map +1 -1
- package/dist/components/StatCard/StatCard.styles.js.map +1 -1
- package/dist/components/StatsGrid/StatsGrid.d.ts +3 -6
- package/dist/components/StatsGrid/StatsGrid.js +3 -7
- package/dist/components/StatsGrid/StatsGrid.js.map +1 -1
- package/dist/components/StatusBadge/StatusBadge.d.ts +3 -2
- package/dist/components/StatusBadge/StatusBadge.js.map +1 -1
- package/dist/components/Switch/Switch.d.ts +2 -1
- package/dist/components/Switch/Switch.js +27 -31
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Switcher/Switcher.css.d.ts +0 -1
- package/dist/components/Switcher/Switcher.d.ts +13 -1
- package/dist/components/Switcher/Switcher.js +35 -35
- package/dist/components/Switcher/Switcher.js.map +1 -1
- package/dist/components/Switcher/Switcher.styles.js +2 -2
- package/dist/components/Switcher/Switcher.styles.js.map +1 -1
- package/dist/components/Table/Table.css.d.ts +16 -1
- package/dist/components/Table/Table.d.ts +110 -13
- package/dist/components/Table/Table.js +214 -102
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Table/Table.styles.js +7 -6
- package/dist/components/Table/Table.styles.js.map +1 -1
- package/dist/components/Table/index.d.ts +1 -1
- package/dist/components/Tabs/Tabs.d.ts +23 -8
- package/dist/components/Tabs/Tabs.js +1 -1
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tabs/Tabs.styles.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +1 -1
- package/dist/components/Tag/Tag.css.d.ts +33 -0
- package/dist/components/Tag/Tag.d.ts +5 -2
- package/dist/components/Tag/Tag.js +23 -6
- package/dist/components/Tag/Tag.js.map +1 -1
- package/dist/components/Tag/Tag.styles.js +12 -1
- package/dist/components/Tag/Tag.styles.js.map +1 -1
- package/dist/components/Tag/index.d.ts +1 -1
- package/dist/components/TextInput/TextInput.d.ts +13 -2
- package/dist/components/TextInput/TextInput.js +45 -48
- package/dist/components/TextInput/TextInput.js.map +1 -1
- package/dist/components/Textarea/Textarea.css.d.ts +2 -0
- package/dist/components/Textarea/Textarea.d.ts +5 -2
- package/dist/components/Textarea/Textarea.js +37 -37
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/Textarea/Textarea.styles.js +3 -2
- package/dist/components/Textarea/Textarea.styles.js.map +1 -1
- package/dist/components/ThemeMenu/ThemeMenu.d.ts +13 -0
- package/dist/components/ThemeMenu/ThemeMenu.js +52 -0
- package/dist/components/ThemeMenu/ThemeMenu.js.map +1 -0
- package/dist/components/ThemeMenu/index.d.ts +2 -0
- package/dist/components/ThemePicker/ThemePicker.d.ts +9 -1
- package/dist/components/ThemePicker/ThemePicker.js +3 -1
- package/dist/components/ThemePicker/ThemePicker.js.map +1 -1
- package/dist/components/TimeInput/TimeInput.d.ts +10 -0
- package/dist/components/TimeInput/TimeInput.js +29 -0
- package/dist/components/TimeInput/TimeInput.js.map +1 -0
- package/dist/components/TimeInput/index.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +30 -10
- package/dist/components/ToggleGroup/ToggleGroup.js +60 -59
- package/dist/components/ToggleGroup/ToggleGroup.js.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.styles.js.map +1 -1
- package/dist/components/ToggleGroup/index.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.css.d.ts +0 -1
- package/dist/components/Tooltip/Tooltip.d.ts +9 -5
- package/dist/components/Tooltip/Tooltip.js +9 -9
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.styles.js +2 -2
- package/dist/components/Tooltip/Tooltip.styles.js.map +1 -1
- package/dist/components/TopBar/TopBar.styles.js.map +1 -1
- package/dist/components/UserMenu/UserMenu.d.ts +4 -3
- package/dist/components/UserMenu/UserMenu.js.map +1 -1
- package/dist/examples/Crm.css.d.ts +3 -0
- package/dist/examples/ExampleShell.d.ts +28 -0
- package/dist/examples/Expenses.css.d.ts +2 -0
- package/dist/examples/HiringTracker.css.d.ts +13 -0
- package/dist/examples/SalesPipeline.css.d.ts +11 -0
- package/dist/foundations/Foundations.css.d.ts +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +51 -45
- package/dist/styles/input.css.d.ts +8 -0
- package/dist/styles/input.styles.js +3 -2
- package/dist/styles/input.styles.js.map +1 -1
- package/dist/styles/shared.css.d.ts +5 -0
- package/dist/styles/shared.styles.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme/fontSize.d.ts +4 -4
- package/dist/theme/fontSize.js +8 -23
- package/dist/theme/fontSize.js.map +1 -1
- package/dist/theme/htmlSetting.d.ts +14 -0
- package/dist/theme/htmlSetting.js +33 -0
- package/dist/theme/htmlSetting.js.map +1 -0
- package/dist/theme/theme.d.ts +4 -4
- package/dist/theme/theme.js +18 -33
- package/dist/theme/theme.js.map +1 -1
- package/dist/tokens/index.d.ts +0 -2
- package/dist/tokens.js +1 -2
- package/package.json +6 -2
- package/skills/back-office-kit/SKILL.md +27 -14
- package/skills/back-office-kit/references/artifact-template.html +1 -0
- package/skills/back-office-kit/references/components.md +482 -251
- package/skills/back-office-kit/references/install.md +27 -4
- package/skills/back-office-kit/references/migrate.md +58 -2
- package/skills/back-office-kit/references/patterns.md +129 -33
- package/skills/back-office-kit/references/testing.md +26 -22
- package/dist/tokens/sprinkles.css.d.ts +0 -38
- package/dist/tokens/sprinkles.styles.js +0 -349
- package/dist/tokens/sprinkles.styles.js.map +0 -1
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import { ComponentProps, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { DataAttributes } from '../Field/Field';
|
|
3
3
|
export interface NavRailItem {
|
|
4
|
+
/** Shown beside the icon when expanded, and as the tooltip and accessible name when collapsed. */
|
|
4
5
|
label: string;
|
|
5
6
|
/** Icon element, e.g. `<Settings size="1.43em" aria-hidden />` (em keeps it scaling with text). */
|
|
6
7
|
icon: ReactNode;
|
|
8
|
+
/** Link target. Use `render` instead for a router link. */
|
|
7
9
|
href?: string;
|
|
8
10
|
/** Router link element, e.g. `<Link to="/settings" />`. Takes precedence over `href`. */
|
|
9
11
|
render?: ReactElement;
|
|
12
|
+
/** Marks the current section (`aria-current="page"`). */
|
|
10
13
|
active?: boolean;
|
|
11
14
|
/** Props for the item's link, e.g. `{ 'data-testid': 'nav-settings' }`. */
|
|
12
15
|
itemProps?: ComponentProps<'a'> & DataAttributes;
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
/** A titled group of items, e.g. "Set up". Shows its title when expanded and a divider when collapsed. */
|
|
18
|
+
export interface NavRailGroup {
|
|
19
|
+
/** Group heading, e.g. "Results". Short: one or two words. */
|
|
20
|
+
group: string;
|
|
15
21
|
items: NavRailItem[];
|
|
22
|
+
}
|
|
23
|
+
export interface NavRailProps extends Omit<ComponentProps<'nav'>, 'children'> {
|
|
24
|
+
/**
|
|
25
|
+
* Top-level sections, in order. Use groups (`{ group: 'Set up', items: [...] }`) when there are
|
|
26
|
+
* more than about six; don't mix groups and loose items.
|
|
27
|
+
*/
|
|
28
|
+
items: (NavRailItem | NavRailGroup)[];
|
|
16
29
|
/**
|
|
17
30
|
* The app's name, shown under the Humara wordmark when the rail is expanded, e.g. "Back Office".
|
|
18
31
|
* The logo itself is built in: the wordmark when expanded, the fan mark when collapsed.
|
|
@@ -20,25 +33,26 @@ export interface NavRailProps extends Omit<ComponentProps<'nav'>, 'children'> {
|
|
|
20
33
|
appName?: string;
|
|
21
34
|
/** Accessible name of the logo link. Defaults to "<appName> home", or "Home". */
|
|
22
35
|
brandLabel?: string;
|
|
36
|
+
/** Where the logo links to. Use `brandRender` instead for a router link. */
|
|
23
37
|
brandHref?: string;
|
|
24
38
|
/** Router link element for the logo, e.g. `<Link to="/" />`. */
|
|
25
39
|
brandRender?: ReactElement;
|
|
26
40
|
/**
|
|
27
41
|
* Shows labels next to icons. When collapsed, each item's label shows in a `Tooltip`. Pass it to
|
|
28
|
-
* control the rail yourself (nothing is stored); omit it and the rail manages its own state
|
|
29
|
-
*
|
|
42
|
+
* control the rail yourself (nothing is stored); omit it and the rail manages its own state,
|
|
43
|
+
* collapsing in windows narrower than 48em. Without `onExpandedChange` the toggle is hidden, so
|
|
44
|
+
* `expanded={false}` gives a fixed icon rail.
|
|
30
45
|
*/
|
|
31
46
|
expanded?: boolean;
|
|
32
47
|
/** Starting state when uncontrolled and nothing is stored. */
|
|
33
48
|
defaultExpanded?: boolean;
|
|
49
|
+
/** Called with the new state when the user toggles the rail. */
|
|
34
50
|
onExpandedChange?: (expanded: boolean) => void;
|
|
35
51
|
/**
|
|
36
52
|
* localStorage key that remembers the user's choice when uncontrolled. `null` disables it.
|
|
37
53
|
* Use different keys for rails in different apps on one origin.
|
|
38
54
|
*/
|
|
39
55
|
persistKey?: string | null;
|
|
40
|
-
/** Show the expand/collapse toggle. */
|
|
41
|
-
collapsible?: boolean;
|
|
42
56
|
/**
|
|
43
57
|
* Pinned to the bottom, e.g. a `UserMenu`. Pass a function to vary it with `expanded`, e.g.
|
|
44
58
|
* `(expanded) => <UserMenu name={name} showName={expanded} />`.
|
|
@@ -48,6 +62,7 @@ export interface NavRailProps extends Omit<ComponentProps<'nav'>, 'children'> {
|
|
|
48
62
|
export declare const NAV_RAIL_STORAGE_KEY = "bok-rail-expanded";
|
|
49
63
|
/**
|
|
50
64
|
* Primary app navigation: a slim icon rail that can expand to show labels. Collapsed by default;
|
|
51
|
-
* uncontrolled rails remember the user's choice in localStorage.
|
|
65
|
+
* uncontrolled rails remember the user's choice in localStorage. In a narrow window an uncontrolled
|
|
66
|
+
* rail collapses; expanding it there lasts until the window widens and isn't stored.
|
|
52
67
|
*/
|
|
53
|
-
export declare function NavRail({ items, appName, brandLabel, brandHref, brandRender, expanded: expandedProp, defaultExpanded, onExpandedChange, persistKey,
|
|
68
|
+
export declare function NavRail({ items, appName, brandLabel, brandHref, brandRender, expanded: expandedProp, defaultExpanded, onExpandedChange, persistKey, footer, className, 'aria-label': ariaLabel, ...props }: NavRailProps): import('react').JSX.Element;
|
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { visuallyHidden as e } from "../../styles/shared.styles.js";
|
|
2
|
+
import { Tooltip as t } from "../Tooltip/Tooltip.js";
|
|
3
|
+
import { HumaraMark as n, HumaraWordmark as r } from "./HumaraLogo.js";
|
|
4
|
+
import { brand as i, fill as a, group as o, groupLabel as s, item as c, mark as l, rail as u, wordmark as d } from "./NavRail.styles.js";
|
|
5
|
+
import { useId as f, useState as p, useSyncExternalStore as m } from "react";
|
|
6
|
+
import { clsx as h } from "clsx";
|
|
7
|
+
import { PanelLeftClose as g, PanelLeftOpen as _ } from "lucide-react";
|
|
8
|
+
import { mergeProps as v } from "@base-ui/react/merge-props";
|
|
9
|
+
import { useRender as y } from "@base-ui/react/use-render";
|
|
10
|
+
import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
10
11
|
// src/components/NavRail/NavRail.tsx
|
|
11
|
-
function
|
|
12
|
-
return
|
|
12
|
+
function C({ item: e, expanded: t, ref: n, ...r }) {
|
|
13
|
+
return y({
|
|
13
14
|
defaultTagName: "a",
|
|
14
15
|
render: e.render,
|
|
15
16
|
ref: n,
|
|
16
|
-
props:
|
|
17
|
+
props: v({
|
|
17
18
|
href: e.render ? void 0 : e.href,
|
|
18
|
-
className:
|
|
19
|
+
className: c,
|
|
19
20
|
"aria-current": e.active ? "page" : void 0,
|
|
20
21
|
"aria-label": t ? void 0 : e.label,
|
|
21
|
-
children: /* @__PURE__ */
|
|
22
|
+
children: /* @__PURE__ */ S(b, { children: [e.icon, t && /* @__PURE__ */ x("span", {
|
|
22
23
|
className: "bhfx7j7",
|
|
23
24
|
children: e.label
|
|
24
25
|
})] })
|
|
25
26
|
}, e.itemProps, r)
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
return /* @__PURE__ */
|
|
30
|
-
label:
|
|
29
|
+
function w({ label: e, expanded: n, children: r }) {
|
|
30
|
+
return /* @__PURE__ */ x(t, {
|
|
31
|
+
label: e,
|
|
31
32
|
side: "right",
|
|
32
|
-
withArrow: !1,
|
|
33
33
|
disabled: n,
|
|
34
34
|
children: r
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
var
|
|
38
|
-
|
|
37
|
+
var T = "bok-rail-expanded", E = () => () => {}, D = "(min-width: 48em)", O = () => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia(D) : null, ee = (e) => {
|
|
38
|
+
let t = O();
|
|
39
|
+
return t?.addEventListener("change", e), () => t?.removeEventListener("change", e);
|
|
40
|
+
};
|
|
41
|
+
function k(e) {
|
|
39
42
|
if (e) try {
|
|
40
43
|
let t = localStorage.getItem(e);
|
|
41
44
|
return t === "true" || t !== "false" && void 0;
|
|
@@ -43,66 +46,84 @@ function x(e) {
|
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
|
-
function
|
|
49
|
+
function A(e, t) {
|
|
47
50
|
if (e) try {
|
|
48
51
|
localStorage.setItem(e, String(t));
|
|
49
52
|
} catch {}
|
|
50
53
|
}
|
|
51
|
-
function
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
function j({ items: t, appName: c, brandLabel: v = c ? `${c} home` : "Home", brandHref: D = "/", brandRender: j, expanded: M, defaultExpanded: N = !1, onExpandedChange: P, persistKey: F = T, footer: I, className: L, "aria-label": R = "Main", ...z }) {
|
|
55
|
+
let B = f(), V = M !== void 0, H = m(E, () => k(F), () => void 0), U = m(ee, () => O()?.matches ?? !0, () => !0), [W, G] = p(), [K, q] = p(!1), [J, Y] = p(U);
|
|
56
|
+
J !== U && (Y(U), q(!1));
|
|
57
|
+
let X = V ? M : U ? W ?? H ?? N : K, Z = (e) => {
|
|
58
|
+
V || (U ? (G(e), A(F, e)) : q(e)), P?.(e);
|
|
59
|
+
}, Q = !V || !!P, te = y({
|
|
55
60
|
defaultTagName: "a",
|
|
56
|
-
render:
|
|
61
|
+
render: j,
|
|
57
62
|
props: {
|
|
58
|
-
href:
|
|
59
|
-
"aria-label":
|
|
60
|
-
className:
|
|
61
|
-
children:
|
|
63
|
+
href: j ? void 0 : D,
|
|
64
|
+
"aria-label": v,
|
|
65
|
+
className: i,
|
|
66
|
+
children: X ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(r, { className: d }), c && /* @__PURE__ */ x("span", {
|
|
62
67
|
className: "bhfx7j5",
|
|
63
|
-
children:
|
|
64
|
-
})] }) : /* @__PURE__ */
|
|
68
|
+
children: c
|
|
69
|
+
})] }) : /* @__PURE__ */ x(n, { className: l })
|
|
65
70
|
}
|
|
66
|
-
}),
|
|
67
|
-
return /* @__PURE__ */
|
|
68
|
-
"aria-label":
|
|
71
|
+
}), $ = X ? "Collapse navigation" : "Expand navigation";
|
|
72
|
+
return /* @__PURE__ */ S("nav", {
|
|
73
|
+
"aria-label": R,
|
|
69
74
|
"data-nav-rail": "",
|
|
70
|
-
"data-expanded":
|
|
71
|
-
className: u
|
|
72
|
-
...
|
|
75
|
+
"data-expanded": X || void 0,
|
|
76
|
+
className: h(u, X && "bhfx7j1", L),
|
|
77
|
+
...z,
|
|
73
78
|
children: [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
te,
|
|
80
|
+
t.map((t, n) => "group" in t ? /* @__PURE__ */ S("div", {
|
|
81
|
+
role: "group",
|
|
82
|
+
"aria-labelledby": `${B}-group-${n}`,
|
|
83
|
+
className: o,
|
|
84
|
+
children: [/* @__PURE__ */ x("span", {
|
|
85
|
+
id: `${B}-group-${n}`,
|
|
86
|
+
className: X ? s : e,
|
|
87
|
+
children: t.group
|
|
88
|
+
}), t.items.map((e) => /* @__PURE__ */ x(w, {
|
|
89
|
+
label: e.label,
|
|
90
|
+
expanded: X,
|
|
91
|
+
children: /* @__PURE__ */ x(C, {
|
|
92
|
+
item: e,
|
|
93
|
+
expanded: X
|
|
94
|
+
})
|
|
95
|
+
}, e.label))]
|
|
96
|
+
}, t.group) : /* @__PURE__ */ x(w, {
|
|
97
|
+
label: t.label,
|
|
98
|
+
expanded: X,
|
|
99
|
+
children: /* @__PURE__ */ x(C, {
|
|
100
|
+
item: t,
|
|
101
|
+
expanded: X
|
|
81
102
|
})
|
|
82
|
-
},
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
85
|
-
label:
|
|
86
|
-
expanded:
|
|
87
|
-
children: /* @__PURE__ */
|
|
103
|
+
}, t.label)),
|
|
104
|
+
/* @__PURE__ */ x("div", { className: a }),
|
|
105
|
+
Q && /* @__PURE__ */ x(w, {
|
|
106
|
+
label: $,
|
|
107
|
+
expanded: X,
|
|
108
|
+
children: /* @__PURE__ */ S("button", {
|
|
88
109
|
type: "button",
|
|
89
110
|
className: "bhfx7j6 tyvs8e0",
|
|
90
|
-
"aria-label":
|
|
91
|
-
"aria-expanded":
|
|
92
|
-
onClick: () =>
|
|
93
|
-
children: [
|
|
111
|
+
"aria-label": $,
|
|
112
|
+
"aria-expanded": X,
|
|
113
|
+
onClick: () => Z(!X),
|
|
114
|
+
children: [x(X ? g : _, {
|
|
94
115
|
size: "1.43em",
|
|
95
116
|
"aria-hidden": !0
|
|
96
|
-
}),
|
|
117
|
+
}), X && /* @__PURE__ */ x("span", {
|
|
97
118
|
className: "bhfx7j7",
|
|
98
119
|
children: "Collapse"
|
|
99
120
|
})]
|
|
100
121
|
})
|
|
101
122
|
}),
|
|
102
|
-
typeof
|
|
123
|
+
typeof I == "function" ? I(X) : I
|
|
103
124
|
]
|
|
104
125
|
});
|
|
105
126
|
}
|
|
106
|
-
export {
|
|
127
|
+
export { T as NAV_RAIL_STORAGE_KEY, j as NavRail };
|
|
107
128
|
|
|
108
129
|
//# sourceMappingURL=NavRail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavRail.js","names":["item","styles.item","_Fragment","appName","expanded","styles.brand","styles.wordmark","styles.mark","styles.rail","styles.fill","Fragment$1","NavLink","item$1","props","useRender","mergeProps","item","expanded","RailTooltip","Tooltip","NAV_RAIL_STORAGE_KEY","readStored","key","value","writeStored","NavRail","appName$1","expandedProp","ariaLabel","controlled","ownExpanded","setOwnExpanded","useState","persistKey","defaultExpanded","expanded$1","setExpanded","next","onExpandedChange","showToggle","collapsible","brandLink","brandRender","brandHref","brandLabel","brand","HumaraWordmark","wordmark","HumaraMark","mark","toggleLabel","clsx","rail","className","items","fill","jsx","PanelLeftClose","PanelLeftOpen","footer"],"sources":["../../../src/components/NavRail/NavRail.tsx"],"sourcesContent":["import { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { clsx } from 'clsx'\nimport { PanelLeftClose, PanelLeftOpen } from 'lucide-react'\nimport { useState, type ComponentProps, type ReactElement, type ReactNode } from 'react'\n\nimport type { DataAttributes } from '../Field/Field'\nimport { Tooltip } from '../Tooltip'\nimport { HumaraMark, HumaraWordmark } from './HumaraLogo'\nimport * as styles from './NavRail.css'\n\nexport interface NavRailItem {\n label: string\n /** Icon element, e.g. `<Settings size=\"1.43em\" aria-hidden />` (em keeps it scaling with text). */\n icon: ReactNode\n href?: string\n /** Router link element, e.g. `<Link to=\"/settings\" />`. Takes precedence over `href`. */\n render?: ReactElement\n active?: boolean\n /** Props for the item's link, e.g. `{ 'data-testid': 'nav-settings' }`. */\n itemProps?: ComponentProps<'a'> & DataAttributes\n}\n\nexport interface NavRailProps extends Omit<ComponentProps<'nav'>, 'children'> {\n items: NavRailItem[]\n /**\n * The app's name, shown under the Humara wordmark when the rail is expanded, e.g. \"Back Office\".\n * The logo itself is built in: the wordmark when expanded, the fan mark when collapsed.\n */\n appName?: string\n /** Accessible name of the logo link. Defaults to \"<appName> home\", or \"Home\". */\n brandLabel?: string\n brandHref?: string\n /** Router link element for the logo, e.g. `<Link to=\"/\" />`. */\n brandRender?: ReactElement\n /**\n * Shows labels next to icons. When collapsed, each item's label shows in a `Tooltip`. Pass it to\n * control the rail yourself (nothing is stored); omit it and the rail manages its own state.\n * A controlled rail without `onExpandedChange` hides the toggle.\n */\n expanded?: boolean\n /** Starting state when uncontrolled and nothing is stored. */\n defaultExpanded?: boolean\n onExpandedChange?: (expanded: boolean) => void\n /**\n * localStorage key that remembers the user's choice when uncontrolled. `null` disables it.\n * Use different keys for rails in different apps on one origin.\n */\n persistKey?: string | null\n /** Show the expand/collapse toggle. */\n collapsible?: boolean\n /**\n * Pinned to the bottom, e.g. a `UserMenu`. Pass a function to vary it with `expanded`, e.g.\n * `(expanded) => <UserMenu name={name} showName={expanded} />`.\n */\n footer?: ReactNode | ((expanded: boolean) => ReactNode)\n}\n\nfunction NavLink({\n item,\n expanded,\n ref,\n ...props\n}: { item: NavRailItem; expanded: boolean } & ComponentProps<'a'>) {\n return useRender({\n defaultTagName: 'a',\n render: item.render,\n ref,\n props: mergeProps<'a'>(\n {\n href: item.render ? undefined : item.href,\n className: styles.item,\n 'aria-current': item.active ? 'page' : undefined,\n 'aria-label': expanded ? undefined : item.label,\n children: (\n <>\n {item.icon}\n {expanded && <span className={styles.label}>{item.label}</span>}\n </>\n ),\n },\n item.itemProps,\n props,\n ),\n })\n}\n\n/** Shows `label` beside a collapsed rail item. Always mounted so items keep focus on toggle. */\nfunction RailTooltip({\n label,\n expanded,\n children,\n}: {\n label: string\n expanded: boolean\n children: ReactElement\n}) {\n return (\n <Tooltip label={label} side=\"right\" withArrow={false} disabled={expanded}>\n {children}\n </Tooltip>\n )\n}\n\nexport const NAV_RAIL_STORAGE_KEY = 'bok-rail-expanded'\n\nfunction readStored(key: string | null): boolean | undefined {\n if (!key) return undefined\n try {\n const value = localStorage.getItem(key)\n return value === 'true' ? true : value === 'false' ? false : undefined\n } catch {\n return undefined // no storage (SSR, private mode, sandboxed iframes)\n }\n}\n\nfunction writeStored(key: string | null, value: boolean) {\n if (!key) return\n try {\n localStorage.setItem(key, String(value))\n } catch {\n // ignore: the rail still toggles, it just won't be remembered\n }\n}\n\n/**\n * Primary app navigation: a slim icon rail that can expand to show labels. Collapsed by default;\n * uncontrolled rails remember the user's choice in localStorage.\n */\nexport function NavRail({\n items,\n appName,\n brandLabel = appName ? `${appName} home` : 'Home',\n brandHref = '/',\n brandRender,\n expanded: expandedProp,\n defaultExpanded = false,\n onExpandedChange,\n persistKey = NAV_RAIL_STORAGE_KEY,\n collapsible = true,\n footer,\n className,\n 'aria-label': ariaLabel = 'Main',\n ...props\n}: NavRailProps) {\n const controlled = expandedProp !== undefined\n const [ownExpanded, setOwnExpanded] = useState(\n () => (controlled ? undefined : readStored(persistKey)) ?? defaultExpanded,\n )\n const expanded = controlled ? expandedProp : ownExpanded\n const setExpanded = (next: boolean) => {\n if (!controlled) {\n setOwnExpanded(next)\n writeStored(persistKey, next)\n }\n onExpandedChange?.(next)\n }\n const showToggle = collapsible && (!controlled || !!onExpandedChange)\n const brandLink = useRender({\n defaultTagName: 'a',\n render: brandRender,\n props: {\n href: brandRender ? undefined : brandHref,\n 'aria-label': brandLabel,\n className: styles.brand,\n children: expanded ? (\n <>\n <HumaraWordmark className={styles.wordmark} />\n {appName && <span className={styles.appName}>{appName}</span>}\n </>\n ) : (\n <HumaraMark className={styles.mark} />\n ),\n },\n })\n const toggleLabel = expanded ? 'Collapse navigation' : 'Expand navigation'\n\n return (\n <nav\n aria-label={ariaLabel}\n data-nav-rail=\"\"\n data-expanded={expanded || undefined}\n className={clsx(styles.rail, expanded && styles.expanded, className)}\n {...props}\n >\n {brandLink}\n {items.map((item) => (\n <RailTooltip key={item.label} label={item.label} expanded={expanded}>\n <NavLink item={item} expanded={expanded} />\n </RailTooltip>\n ))}\n <div className={styles.fill} />\n {showToggle && (\n <RailTooltip label={toggleLabel} expanded={expanded}>\n <button\n type=\"button\"\n className={styles.item}\n aria-label={toggleLabel}\n aria-expanded={expanded}\n onClick={() => setExpanded(!expanded)}\n >\n {expanded ? (\n <PanelLeftClose size=\"1.43em\" aria-hidden />\n ) : (\n <PanelLeftOpen size=\"1.43em\" aria-hidden />\n )}\n {expanded && <span className={styles.label}>Collapse</span>}\n </button>\n </RailTooltip>\n )}\n {typeof footer === 'function' ? footer(expanded) : footer}\n </nav>\n )\n}\n"],"mappings":";;;;;;;;;;AA0DA,SAASW,EAAQ,EACf,MAAAC,GACA,aACA,QACA,GAAGC,KAC8D;CACjE,OAAOC,EAAU;EACf,gBAAgB;EAChB,QAAQd,EAAK;EACb;EACA,OAAOe,EACL;GACE,MAAMf,EAAK,SAAS,KAAA,IAAYA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styles.brand","styles.wordmark","styles.mark","styles.rail","styles.group","styles.groupLabel","styles.fill","NavLink","item$1","props","useRender","mergeProps","item","expanded","Fragment","RailTooltip","Tooltip","NAV_RAIL_STORAGE_KEY","noSubscribe","WIDE","wideQuery","subscribeWide","query","notify","readStored","key","value","writeStored","NavRail","appName$1","expandedProp","ariaLabel","id","useId","controlled","stored","useSyncExternalStore","persistKey","wide","ownExpanded","setOwnExpanded","useState","narrowExpanded","setNarrowExpanded","wasWide","setWasWide","expanded$1","defaultExpanded","setExpanded","next","onExpandedChange","showToggle","brandLink","brandRender","brandHref","brandLabel","brand","HumaraWordmark","wordmark","HumaraMark","mark","toggleLabel","clsx","rail","className","items","entry","index","group","groupLabel","visuallyHidden","fill","jsx","PanelLeftClose","PanelLeftOpen","footer"],"sources":["../../../src/components/NavRail/NavRail.tsx"],"sourcesContent":["import { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { clsx } from 'clsx'\nimport { PanelLeftClose, PanelLeftOpen } from 'lucide-react'\nimport {\n useId,\n useState,\n useSyncExternalStore,\n type ComponentProps,\n type ReactElement,\n type ReactNode,\n} from 'react'\n\nimport { visuallyHidden } from '../../styles/shared.css'\nimport type { DataAttributes } from '../Field/Field'\nimport { Tooltip } from '../Tooltip'\nimport { HumaraMark, HumaraWordmark } from './HumaraLogo'\nimport * as styles from './NavRail.css'\n\nexport interface NavRailItem {\n /** Shown beside the icon when expanded, and as the tooltip and accessible name when collapsed. */\n label: string\n /** Icon element, e.g. `<Settings size=\"1.43em\" aria-hidden />` (em keeps it scaling with text). */\n icon: ReactNode\n /** Link target. Use `render` instead for a router link. */\n href?: string\n /** Router link element, e.g. `<Link to=\"/settings\" />`. Takes precedence over `href`. */\n render?: ReactElement\n /** Marks the current section (`aria-current=\"page\"`). */\n active?: boolean\n /** Props for the item's link, e.g. `{ 'data-testid': 'nav-settings' }`. */\n itemProps?: ComponentProps<'a'> & DataAttributes\n}\n\n/** A titled group of items, e.g. \"Set up\". Shows its title when expanded and a divider when collapsed. */\nexport interface NavRailGroup {\n /** Group heading, e.g. \"Results\". Short: one or two words. */\n group: string\n items: NavRailItem[]\n}\n\nexport interface NavRailProps extends Omit<ComponentProps<'nav'>, 'children'> {\n /**\n * Top-level sections, in order. Use groups (`{ group: 'Set up', items: [...] }`) when there are\n * more than about six; don't mix groups and loose items.\n */\n items: (NavRailItem | NavRailGroup)[]\n /**\n * The app's name, shown under the Humara wordmark when the rail is expanded, e.g. \"Back Office\".\n * The logo itself is built in: the wordmark when expanded, the fan mark when collapsed.\n */\n appName?: string\n /** Accessible name of the logo link. Defaults to \"<appName> home\", or \"Home\". */\n brandLabel?: string\n /** Where the logo links to. Use `brandRender` instead for a router link. */\n brandHref?: string\n /** Router link element for the logo, e.g. `<Link to=\"/\" />`. */\n brandRender?: ReactElement\n /**\n * Shows labels next to icons. When collapsed, each item's label shows in a `Tooltip`. Pass it to\n * control the rail yourself (nothing is stored); omit it and the rail manages its own state,\n * collapsing in windows narrower than 48em. Without `onExpandedChange` the toggle is hidden, so\n * `expanded={false}` gives a fixed icon rail.\n */\n expanded?: boolean\n /** Starting state when uncontrolled and nothing is stored. */\n defaultExpanded?: boolean\n /** Called with the new state when the user toggles the rail. */\n onExpandedChange?: (expanded: boolean) => void\n /**\n * localStorage key that remembers the user's choice when uncontrolled. `null` disables it.\n * Use different keys for rails in different apps on one origin.\n */\n persistKey?: string | null\n /**\n * Pinned to the bottom, e.g. a `UserMenu`. Pass a function to vary it with `expanded`, e.g.\n * `(expanded) => <UserMenu name={name} showName={expanded} />`.\n */\n footer?: ReactNode | ((expanded: boolean) => ReactNode)\n}\n\nfunction NavLink({\n item,\n expanded,\n ref,\n ...props\n}: { item: NavRailItem; expanded: boolean } & ComponentProps<'a'>) {\n return useRender({\n defaultTagName: 'a',\n render: item.render,\n ref,\n props: mergeProps<'a'>(\n {\n href: item.render ? undefined : item.href,\n className: styles.item,\n 'aria-current': item.active ? 'page' : undefined,\n 'aria-label': expanded ? undefined : item.label,\n children: (\n <>\n {item.icon}\n {expanded && <span className={styles.label}>{item.label}</span>}\n </>\n ),\n },\n item.itemProps,\n props,\n ),\n })\n}\n\n/** Shows `label` beside a collapsed rail item. Always mounted so items keep focus on toggle. */\nfunction RailTooltip({\n label,\n expanded,\n children,\n}: {\n label: string\n expanded: boolean\n children: ReactElement\n}) {\n return (\n <Tooltip label={label} side=\"right\" disabled={expanded}>\n {children}\n </Tooltip>\n )\n}\n\nexport const NAV_RAIL_STORAGE_KEY = 'bok-rail-expanded'\n\nconst noSubscribe = () => () => {}\n\n// Below this width an uncontrolled rail collapses, leaving room for the page.\nconst WIDE = '(min-width: 48em)'\n// matchMedia is missing in jsdom (and SSR), where the window counts as wide.\nconst wideQuery = () =>\n typeof window !== 'undefined' && typeof window.matchMedia === 'function'\n ? window.matchMedia(WIDE)\n : null\nconst subscribeWide = (notify: () => void) => {\n const query = wideQuery()\n query?.addEventListener('change', notify)\n return () => query?.removeEventListener('change', notify)\n}\n\nfunction readStored(key: string | null): boolean | undefined {\n if (!key) return undefined\n try {\n const value = localStorage.getItem(key)\n return value === 'true' ? true : value === 'false' ? false : undefined\n } catch {\n return undefined // no storage (SSR, private mode, sandboxed iframes)\n }\n}\n\nfunction writeStored(key: string | null, value: boolean) {\n if (!key) return\n try {\n localStorage.setItem(key, String(value))\n } catch {\n // ignore: the rail still toggles, it just won't be remembered\n }\n}\n\n/**\n * Primary app navigation: a slim icon rail that can expand to show labels. Collapsed by default;\n * uncontrolled rails remember the user's choice in localStorage. In a narrow window an uncontrolled\n * rail collapses; expanding it there lasts until the window widens and isn't stored.\n */\nexport function NavRail({\n items,\n appName,\n brandLabel = appName ? `${appName} home` : 'Home',\n brandHref = '/',\n brandRender,\n expanded: expandedProp,\n defaultExpanded = false,\n onExpandedChange,\n persistKey = NAV_RAIL_STORAGE_KEY,\n footer,\n className,\n 'aria-label': ariaLabel = 'Main',\n ...props\n}: NavRailProps) {\n const id = useId()\n const controlled = expandedProp !== undefined\n // The server can't see storage, so it renders `defaultExpanded`; the stored choice applies on\n // hydration (no mismatch) and on the first render of client-only apps (no flash).\n const stored = useSyncExternalStore(\n noSubscribe,\n () => readStored(persistKey),\n () => undefined,\n )\n const wide = useSyncExternalStore(\n subscribeWide,\n () => wideQuery()?.matches ?? true,\n () => true,\n )\n const [ownExpanded, setOwnExpanded] = useState<boolean>()\n // Expanded in a narrow window: temporary, so it resets when the width crosses the breakpoint.\n const [narrowExpanded, setNarrowExpanded] = useState(false)\n const [wasWide, setWasWide] = useState(wide)\n if (wasWide !== wide) {\n setWasWide(wide)\n setNarrowExpanded(false)\n }\n const expanded = controlled\n ? expandedProp\n : wide\n ? (ownExpanded ?? stored ?? defaultExpanded)\n : narrowExpanded\n const setExpanded = (next: boolean) => {\n if (!controlled) {\n if (wide) {\n setOwnExpanded(next)\n writeStored(persistKey, next)\n } else {\n setNarrowExpanded(next)\n }\n }\n onExpandedChange?.(next)\n }\n const showToggle = !controlled || !!onExpandedChange\n const brandLink = useRender({\n defaultTagName: 'a',\n render: brandRender,\n props: {\n href: brandRender ? undefined : brandHref,\n 'aria-label': brandLabel,\n className: styles.brand,\n children: expanded ? (\n <>\n <HumaraWordmark className={styles.wordmark} />\n {appName && <span className={styles.appName}>{appName}</span>}\n </>\n ) : (\n <HumaraMark className={styles.mark} />\n ),\n },\n })\n const toggleLabel = expanded ? 'Collapse navigation' : 'Expand navigation'\n\n return (\n <nav\n aria-label={ariaLabel}\n data-nav-rail=\"\"\n data-expanded={expanded || undefined}\n className={clsx(styles.rail, expanded && styles.expanded, className)}\n {...props}\n >\n {brandLink}\n {items.map((entry, index) =>\n 'group' in entry ? (\n <div\n key={entry.group}\n role=\"group\"\n aria-labelledby={`${id}-group-${index}`}\n className={styles.group}\n >\n <span\n id={`${id}-group-${index}`}\n className={expanded ? styles.groupLabel : visuallyHidden}\n >\n {entry.group}\n </span>\n {entry.items.map((item) => (\n <RailTooltip key={item.label} label={item.label} expanded={expanded}>\n <NavLink item={item} expanded={expanded} />\n </RailTooltip>\n ))}\n </div>\n ) : (\n <RailTooltip key={entry.label} label={entry.label} expanded={expanded}>\n <NavLink item={entry} expanded={expanded} />\n </RailTooltip>\n ),\n )}\n <div className={styles.fill} />\n {showToggle && (\n <RailTooltip label={toggleLabel} expanded={expanded}>\n <button\n type=\"button\"\n className={styles.item}\n aria-label={toggleLabel}\n aria-expanded={expanded}\n onClick={() => setExpanded(!expanded)}\n >\n {expanded ? (\n <PanelLeftClose size=\"1.43em\" aria-hidden />\n ) : (\n <PanelLeftOpen size=\"1.43em\" aria-hidden />\n )}\n {expanded && <span className={styles.label}>Collapse</span>}\n </button>\n </RailTooltip>\n )}\n {typeof footer === 'function' ? footer(expanded) : footer}\n </nav>\n )\n}\n"],"mappings":";;;;;;;;;;;AAiFA,SAASY,EAAQ,EACf,MAAAC,GACA,aACA,QACA,GAAGC,KAC8D;CACjE,OAAOC,EAAU;EACf,gBAAgB;EAChB,QAAQf,EAAK;EACb;EACA,OAAOgB,EACL;GACE,MAAMhB,EAAK,SAAS,KAAA,IAAYA,EAAK;GACrC,WAAWC;GACX,gBAAgBD,EAAK,SAAS,SAAS,KAAA;GACvC,cAAckB,IAAW,KAAA,IAAYlB,EAAK;GAC1C,UACE,kBAAAE,GAAA,EAAA,UAAA,CACGF,EAAK,MACLkB,KAAY,kBAAC,QAAD;IAAM,WAAW;IAAe,UAAAlB,EAAK;GAAY,CAAA,CAC9D,EAAA,CAAA;EAEN,GACAA,EAAK,WACLc,CACF;CACF,CAAC;AACH;AAGA,SAASM,EAAY,EACnB,UACA,aACA,eAKC;CACD,OACE,kBAACC,GAAD;EAAgB;EAAO,MAAK;EAAQ,UAAUH;EAC3C;CACM,CAAA;AAEb;AAEA,IAAaI,IAAuB,qBAE9BC,gBAA0B,CAAC,GAG3BC,IAAO,qBAEPC,UACJ,OAAO,SAAW,OAAe,OAAO,OAAO,cAAe,aAC1D,OAAO,WAAWD,CAAI,IACtB,MACAE,MAAiB,MAA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UAAA,kBAAC,UAAD;KACE,MAAK;KACL,WAAW;KACX,cAAYe;KACZ,iBAAe9D;KACf,eAAeiD,EAAY,CAACjD,CAAQ;KALtC,UAAA,CAQIyE,EADDzE,IACE0E,IAEAC,GAFD;MAAgB,MAAK;MAAS,eAAA;KAAa,CAED,GAE3C3E,KAAY,kBAAC,QAAD;MAAM,WAAW;MAAc,UAAA;KAAc,CAAA,CACpD;;GACG,CAAA;GAEd,OAAO4E,KAAW,aAAaA,EAAO5E,CAAQ,IAAI4E;EAChD;;AAET"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
+
/* empty css */
|
|
2
3
|
/* empty css */
|
|
3
4
|
// src/components/NavRail/NavRail.css.ts
|
|
4
|
-
var e = "bhfx7j0", t = "bhfx7j1", n = "bhfx7j2 tyvs8e0", r = "bhfx7j3", i = "bhfx7j4", a = "bhfx7j5", o = "bhfx7j6 tyvs8e0", s = "bhfx7j7", c = "bhfx7j8";
|
|
5
|
-
export { a as appName, n as brand, t as expanded,
|
|
5
|
+
var e = "bhfx7j0", t = "bhfx7j1", n = "bhfx7j2 tyvs8e0", r = "bhfx7j3", i = "bhfx7j4", a = "bhfx7j5", o = "bhfx7j6 tyvs8e0", s = "bhfx7j7", c = "bhfx7j8", l = "bhfx7j9", u = "bhfx7ja";
|
|
6
|
+
export { a as appName, n as brand, t as expanded, u as fill, c as group, l as groupLabel, o as item, s as label, i as mark, e as rail, r as wordmark };
|
|
6
7
|
|
|
7
8
|
//# sourceMappingURL=NavRail.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavRail.styles.js","names":["rail","expanded","brand","wordmark","mark","appName","item","label","fill"],"sources":["../../../src/components/NavRail/NavRail.css.ts"],"sourcesContent":["import { globalStyle, style } from '@vanilla-extract/css'\n\nimport { focusRing } from '../../styles/shared.css'\nimport { vars } from '../../tokens/contract.css'\nimport { fontSize, fontWeight, radius, space, zIndex } from '../../tokens/scale'\n\nexport const rail = style({\n // Children (a footer UserMenu, custom links) get a ring that shows on the dark rail.\n vars: { [vars.color.focusRing]: vars.color.railActiveInk },\n width: '4rem',\n flexShrink: 0,\n position: 'sticky',\n top: 0,\n height: '100vh',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n gap: space['1'],\n paddingBottom: space['4'],\n backgroundColor: vars.color.railBg,\n borderRight: `1px solid ${vars.color.railBorder}`,\n color: vars.color.railInk,\n fontFamily: vars.font.sans,\n zIndex: zIndex.rail,\n})\nexport const expanded = style({ width: '14rem', alignItems: 'stretch', paddingInline: space['3'] })\n\nexport const brand = style([\n focusRing,\n {\n minHeight: '4rem',\n flexShrink: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: space['1'],\n marginBottom: space['2'],\n borderRadius: radius.lg,\n color: vars.color.railInk,\n fontWeight: fontWeight.semibold,\n fontSize: fontSize.lg,\n textDecoration: 'none',\n selectors: { [`${expanded} &`]: { alignItems: 'flex-start', paddingInline: space['2'] } },\n },\n])\n\nexport const wordmark = style({ display: 'block', width: '6.5rem', height: 'auto' })\nexport const mark = style({ display: 'block', width: '1.75rem', height: '1.75rem' })\nexport const appName = style({\n color: vars.color.railInkMuted,\n fontSize: fontSize.sm,\n fontWeight: fontWeight.medium,\n lineHeight: 1.2,\n})\n\nexport const item = style([\n focusRing,\n {\n width: '2.75rem',\n height: '2.75rem',\n flexShrink: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: space['3'],\n border: 0,\n borderRadius: radius.lg,\n background: 'transparent',\n color: vars.color.railInkMuted,\n fontFamily: 'inherit',\n fontSize: fontSize.md,\n textDecoration: 'none',\n cursor: 'pointer',\n selectors: {\n '&:hover': { backgroundColor: vars.color.railHover, color: vars.color.railInk },\n // Mint pill (icon below); the label stays railInk because mint text misses 4.5:1 on the pill.\n '&[aria-current=\"page\"]': {\n backgroundColor: vars.color.railActiveBg,\n color: vars.color.railInk,\n fontWeight: fontWeight.medium,\n },\n [`${expanded} &`]: { width: 'auto', justifyContent: 'flex-start', paddingInline: space['3'] },\n },\n },\n])\nglobalStyle(`${item}[aria-current=\"page\"] > svg`, { color: vars.color.railActiveInk })\n\nexport const label = style({ whiteSpace: 'nowrap' })\nexport const fill = style({ flex: 1 })\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NavRail.styles.js","names":["rail","expanded","brand","wordmark","mark","appName","item","label","group","groupLabel","fill"],"sources":["../../../src/components/NavRail/NavRail.css.ts"],"sourcesContent":["import { globalStyle, style } from '@vanilla-extract/css'\n\nimport { focusRing } from '../../styles/shared.css'\nimport { vars } from '../../tokens/contract.css'\nimport { fontSize, fontWeight, radius, space, zIndex } from '../../tokens/scale'\nimport { button } from '../Button/Button.css'\n\nexport const rail = style({\n // Children (a footer UserMenu, custom links) get a ring that shows on the dark rail.\n vars: { [vars.color.focusRing]: vars.color.railActiveInk },\n width: '4rem',\n flexShrink: 0,\n position: 'sticky',\n top: 0,\n height: '100vh',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n gap: space['1'],\n paddingBottom: space['4'],\n backgroundColor: vars.color.railBg,\n borderRight: `1px solid ${vars.color.railBorder}`,\n color: vars.color.railInk,\n fontFamily: vars.font.sans,\n zIndex: zIndex.rail,\n})\nexport const expanded = style({ width: '14rem', alignItems: 'stretch', paddingInline: space['3'] })\n\nexport const brand = style([\n focusRing,\n {\n minHeight: '4rem',\n flexShrink: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: space['1'],\n marginBottom: space['2'],\n borderRadius: radius.lg,\n color: vars.color.railInk,\n fontWeight: fontWeight.semibold,\n fontSize: fontSize.lg,\n textDecoration: 'none',\n selectors: { [`${expanded} &`]: { alignItems: 'flex-start', paddingInline: space['2'] } },\n },\n])\n\nexport const wordmark = style({ display: 'block', width: '6.5rem', height: 'auto' })\nexport const mark = style({ display: 'block', width: '1.75rem', height: '1.75rem' })\nexport const appName = style({\n color: vars.color.railInkMuted,\n fontSize: fontSize.sm,\n fontWeight: fontWeight.medium,\n lineHeight: 1.2,\n})\n\nexport const item = style([\n focusRing,\n {\n width: '2.75rem',\n height: '2.75rem',\n flexShrink: 0,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: space['3'],\n border: 0,\n borderRadius: radius.lg,\n background: 'transparent',\n color: vars.color.railInkMuted,\n fontFamily: 'inherit',\n fontSize: fontSize.md,\n textDecoration: 'none',\n cursor: 'pointer',\n selectors: {\n '&:hover': { backgroundColor: vars.color.railHover, color: vars.color.railInk },\n // Mint pill (icon below); the label stays railInk because mint text misses 4.5:1 on the pill.\n '&[aria-current=\"page\"]': {\n backgroundColor: vars.color.railActiveBg,\n color: vars.color.railInk,\n fontWeight: fontWeight.medium,\n },\n [`${expanded} &`]: { width: 'auto', justifyContent: 'flex-start', paddingInline: space['3'] },\n },\n },\n])\nglobalStyle(`${item}[aria-current=\"page\"] > svg`, { color: vars.color.railActiveInk })\n\nexport const label = style({ whiteSpace: 'nowrap' })\n\nexport const group = style({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'inherit',\n gap: space['1'],\n selectors: {\n // Collapsed: a short divider between groups stands in for the headings.\n '& + &': {\n marginBlockStart: space['2'],\n paddingBlockStart: space['3'],\n borderBlockStart: `1px solid color-mix(in srgb, ${vars.color.railInk} 25%, transparent)`,\n },\n [`${expanded} & + &`]: { borderBlockStart: 0, paddingBlockStart: 0 },\n },\n})\nexport const groupLabel = style({\n paddingInline: space['3'],\n paddingBlock: `${space['2']} ${space['1']}`,\n color: vars.color.railInkMuted,\n fontSize: fontSize.xs,\n fontWeight: fontWeight.medium,\n})\nexport const fill = style({ flex: 1 })\n\n// A ghost `Button` in the rail (e.g. in the footer) takes the rail's ink and hover.\nconst railGhost = `${rail} .${button.classNames.variants.variant.ghost}`\nglobalStyle(railGhost, { color: vars.color.railInk })\nglobalStyle(`${railGhost}:hover:not([aria-disabled=\"true\"])`, {\n backgroundColor: vars.color.railHover,\n})\nglobalStyle(`${railGhost}[aria-disabled=\"true\"]`, { color: vars.color.railInkMuted })\n"],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NAV_RAIL_STORAGE_KEY, NavRail } from './NavRail';
|
|
2
|
-
export type { NavRailProps, NavRailItem } from './NavRail';
|
|
2
|
+
export type { NavRailProps, NavRailItem, NavRailGroup } from './NavRail';
|
|
@@ -2,12 +2,20 @@ import { NumberField } from '@base-ui/react/number-field';
|
|
|
2
2
|
import { Ref } from 'react';
|
|
3
3
|
import { FieldBaseProps, FieldOptionProps } from '../Field/Field';
|
|
4
4
|
export interface NumberInputProps extends FieldBaseProps, FieldOptionProps, Omit<NumberField.Root.Props, 'className' | 'render' | 'children'> {
|
|
5
|
+
/** Shown in the empty input. */
|
|
5
6
|
placeholder?: string;
|
|
6
7
|
/** Forwarded to the visible text input. */
|
|
7
8
|
ref?: Ref<HTMLInputElement>;
|
|
9
|
+
/** Class for the field's root element. */
|
|
8
10
|
className?: string;
|
|
9
11
|
/** Hides the − and + buttons. */
|
|
10
12
|
hideControls?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whole numbers only: typed decimals round (on blur, and in `onValueChange` straight away), and
|
|
15
|
+
* Alt+Arrow steps by 1. Emptying the field reverts it to the last value on blur, so once it has
|
|
16
|
+
* a value `onValueChange` never gets `null`.
|
|
17
|
+
*/
|
|
18
|
+
integer?: boolean;
|
|
11
19
|
}
|
|
12
20
|
/** Numeric input with step buttons. Arrow keys step by `step`, Shift+Arrow by `largeStep`. */
|
|
13
|
-
export declare function NumberInput({ label, description, error, required,
|
|
21
|
+
export declare function NumberInput({ label, description, error, required, hideLabel, fieldProps, disabled, className, placeholder, hideControls, integer, ref, format, smallStep, onValueChange, ...props }: NumberInputProps): import('react').JSX.Element;
|
|
@@ -1,45 +1,51 @@
|
|
|
1
1
|
import { frame as e, frameInput as t } from "../../styles/input.styles.js";
|
|
2
|
-
import { Field as n
|
|
3
|
-
import { clsx as
|
|
4
|
-
import { Minus as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { NumberField as
|
|
2
|
+
import { Field as n } from "../Field/Field.js";
|
|
3
|
+
import { clsx as r } from "clsx";
|
|
4
|
+
import { Minus as i, Plus as a } from "lucide-react";
|
|
5
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
import { NumberField as l } from "@base-ui/react/number-field";
|
|
7
7
|
// src/components/NumberInput/NumberInput.tsx
|
|
8
|
-
function
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
...
|
|
11
|
-
label:
|
|
12
|
-
description:
|
|
13
|
-
error:
|
|
14
|
-
required:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
disabled: b,
|
|
20
|
-
className: i(y?.className, x),
|
|
21
|
-
children: /* @__PURE__ */ c(u.Root, {
|
|
8
|
+
function u({ label: u, description: d, error: f, required: p, hideLabel: m, fieldProps: h, disabled: g, className: _, placeholder: v, hideControls: y = !1, integer: b = !1, ref: x, format: S, smallStep: C, onValueChange: w, ...T }) {
|
|
9
|
+
return /* @__PURE__ */ s(n, {
|
|
10
|
+
...h,
|
|
11
|
+
label: u,
|
|
12
|
+
description: d,
|
|
13
|
+
error: f,
|
|
14
|
+
required: p,
|
|
15
|
+
hideLabel: m,
|
|
16
|
+
disabled: g,
|
|
17
|
+
className: r(h?.className, _),
|
|
18
|
+
children: /* @__PURE__ */ s(l.Root, {
|
|
22
19
|
...T,
|
|
23
|
-
required:
|
|
24
|
-
disabled:
|
|
25
|
-
|
|
20
|
+
required: p,
|
|
21
|
+
disabled: g,
|
|
22
|
+
format: b ? {
|
|
23
|
+
...S,
|
|
24
|
+
maximumFractionDigits: 0
|
|
25
|
+
} : S,
|
|
26
|
+
smallStep: C ?? (b ? 1 : void 0),
|
|
27
|
+
onValueChange: (e, t) => {
|
|
28
|
+
if (!b) return w?.(e, t);
|
|
29
|
+
if (e === null) return t.cancel();
|
|
30
|
+
w?.(Math.round(e), t);
|
|
31
|
+
},
|
|
32
|
+
children: /* @__PURE__ */ c(l.Group, {
|
|
26
33
|
className: e,
|
|
27
|
-
children: [/* @__PURE__ */
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
placeholder: S,
|
|
34
|
+
children: [/* @__PURE__ */ s(l.Input, {
|
|
35
|
+
ref: x,
|
|
36
|
+
placeholder: v,
|
|
31
37
|
className: t
|
|
32
|
-
}), !
|
|
38
|
+
}), !y && /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s(l.Decrement, {
|
|
33
39
|
className: "_12aoxdm4",
|
|
34
40
|
"aria-label": "Decrease",
|
|
35
|
-
children: /* @__PURE__ */
|
|
41
|
+
children: /* @__PURE__ */ s(i, {
|
|
36
42
|
size: "1em",
|
|
37
43
|
"aria-hidden": !0
|
|
38
44
|
})
|
|
39
|
-
}), /* @__PURE__ */
|
|
45
|
+
}), /* @__PURE__ */ s(l.Increment, {
|
|
40
46
|
className: "_12aoxdm4",
|
|
41
47
|
"aria-label": "Increase",
|
|
42
|
-
children: /* @__PURE__ */
|
|
48
|
+
children: /* @__PURE__ */ s(a, {
|
|
43
49
|
size: "1em",
|
|
44
50
|
"aria-hidden": !0
|
|
45
51
|
})
|
|
@@ -48,6 +54,6 @@ function d({ label: d, description: f, error: p, required: m, showRequired: h, r
|
|
|
48
54
|
})
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
|
-
export {
|
|
57
|
+
export { u as NumberInput };
|
|
52
58
|
|
|
53
59
|
//# sourceMappingURL=NumberInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.js","names":["input.frame","input.frameInput","_Fragment","NumberInput","props","Field","fieldProps","clsx","className","NumberField","
|
|
1
|
+
{"version":3,"file":"NumberInput.js","names":["input.frame","input.frameInput","_Fragment","NumberInput","props","Field","fieldProps","clsx","className","NumberField","integer","format","smallStep","onValueChange","value","details","frame","frameInput","hideControls","Fragment","Minus","Plus"],"sources":["../../../src/components/NumberInput/NumberInput.tsx"],"sourcesContent":["import { NumberField } from '@base-ui/react/number-field'\nimport { clsx } from 'clsx'\nimport { Minus, Plus } from 'lucide-react'\nimport type { Ref } from 'react'\n\nimport * as input from '../../styles/input.css'\nimport { Field, type FieldBaseProps, type FieldOptionProps } from '../Field/Field'\n\nexport interface NumberInputProps\n extends\n FieldBaseProps,\n FieldOptionProps,\n Omit<NumberField.Root.Props, 'className' | 'render' | 'children'> {\n /** Shown in the empty input. */\n placeholder?: string\n /** Forwarded to the visible text input. */\n ref?: Ref<HTMLInputElement>\n /** Class for the field's root element. */\n className?: string\n /** Hides the − and + buttons. */\n hideControls?: boolean\n /**\n * Whole numbers only: typed decimals round (on blur, and in `onValueChange` straight away), and\n * Alt+Arrow steps by 1. Emptying the field reverts it to the last value on blur, so once it has\n * a value `onValueChange` never gets `null`.\n */\n integer?: boolean\n}\n\n/** Numeric input with step buttons. Arrow keys step by `step`, Shift+Arrow by `largeStep`. */\nexport function NumberInput({\n label,\n description,\n error,\n required,\n hideLabel,\n fieldProps,\n disabled,\n className,\n placeholder,\n hideControls = false,\n integer = false,\n ref,\n format,\n smallStep,\n onValueChange,\n ...props\n}: NumberInputProps) {\n return (\n <Field\n {...fieldProps}\n label={label}\n description={description}\n error={error}\n required={required}\n hideLabel={hideLabel}\n disabled={disabled}\n className={clsx(fieldProps?.className, className)}\n >\n <NumberField.Root\n {...props}\n required={required}\n disabled={disabled}\n format={integer ? { ...format, maximumFractionDigits: 0 } : format}\n smallStep={smallStep ?? (integer ? 1 : undefined)}\n onValueChange={(value, details) => {\n if (!integer) return onValueChange?.(value, details)\n // Keep the last value; Base UI restores the text on blur.\n if (value === null) return details.cancel()\n onValueChange?.(Math.round(value), details)\n }}\n >\n <NumberField.Group className={input.frame}>\n <NumberField.Input ref={ref} placeholder={placeholder} className={input.frameInput} />\n {!hideControls && (\n <>\n <NumberField.Decrement className={input.frameButton} aria-label=\"Decrease\">\n <Minus size=\"1em\" aria-hidden />\n </NumberField.Decrement>\n <NumberField.Increment className={input.frameButton} aria-label=\"Increase\">\n <Plus size=\"1em\" aria-hidden />\n </NumberField.Increment>\n </>\n )}\n </NumberField.Group>\n </NumberField.Root>\n </Field>\n )\n}\n"],"mappings":";;;;;;;AA8BA,SAAgBG,EAAY,EAC1B,UACA,gBACA,UACA,aACA,cACA,eACA,aACA,cACA,gBACA,kBAAe,IACf,aAAU,IACV,QACA,WACA,cACA,kBACA,GAAGC,KACgB;CACnB,OACE,kBAACC,GAAD;EACE,GAAIC;EACG;EACM;EACN;EACG;EACC;EACD;EACV,WAAWC,EAAKD,GAAY,WAAWE,CAAS;EAEhD,UAAA,kBAACC,EAAY,MAAb;GACE,GAAIL;GACM;GACA;GACV,QAAQM,IAAU;IAAE,GAAGC;IAAQ,uBAAuB;GAAE,IAAIA;GAC5D,WAAWC,MAAcF,IAAU,IAAI,KAAA;GACvC,gBAAgB,GAAO,MAAY;IACjC,IAAI,CAACA,GAAS,OAAOG,IAAgBC,GAAOC,CAAO;IAEnD,IAAID,MAAU,MAAM,OAAOC,EAAQ,OAAO;IAC1C,IAAgB,KAAK,MAAMD,CAAK,GAAGC,CAAO;GAC5C;GAEA,UAAA,kBAACN,EAAY,OAAb;IAAmB,WAAWT;IAA9B,UAAA,CACE,kBAACS,EAAY,OAAb;KAAwB;KAAkB;KAAa,WAAWR;IAAmB,CAAA,GACpF,CAACiB,KACA,kBAAAhB,GAAA,EAAA,UAAA,CACE,kBAACO,EAAY,WAAb;KAAuB,WAAW;KAAmB,cAAW;KAC9D,UAAA,kBAACW,GAAD;MAAO,MAAK;MAAM,eAAA;KAAa,CAAA;IACV,CAAA,GACvB,kBAACX,EAAY,WAAb;KAAuB,WAAW;KAAmB,cAAW;KAC9D,UAAA,kBAACY,GAAD;MAAM,MAAK;MAAM,eAAA;KAAa,CAAA;IACT,CAAA,CACvB,EAAA,CAAA,CAEa;;EACH,CAAA;CACb,CAAA;AAEX"}
|
|
@@ -3,6 +3,6 @@ export declare const text: string;
|
|
|
3
3
|
export declare const titleRow: string;
|
|
4
4
|
export declare const title: string;
|
|
5
5
|
export declare const facts: string;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const leadFact: string;
|
|
7
7
|
export declare const description: string;
|
|
8
8
|
export declare const actions: string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode } from 'react';
|
|
2
2
|
export interface PageHeaderProps extends Omit<ComponentProps<'header'>, 'title'> {
|
|
3
|
+
/** The page's `<h1>`. */
|
|
3
4
|
title: ReactNode;
|
|
4
5
|
/** Shown before the title, e.g. a logo or avatar. */
|
|
5
6
|
logo?: ReactNode;
|
|
6
|
-
/** Short facts on one line under the title
|
|
7
|
+
/** Short facts on one line under the title. Put the one people act on first: it leads and the rest are muted. `null`, `undefined`, `false` and `''` are skipped (`0` is kept). */
|
|
7
8
|
facts?: ReactNode[];
|
|
9
|
+
/** A sentence or two under the title. */
|
|
8
10
|
description?: ReactNode;
|
|
9
11
|
/** Controls at the top right, e.g. the page's primary Button. */
|
|
10
12
|
actions?: ReactNode;
|
|
@@ -1,42 +1,40 @@
|
|
|
1
1
|
import { header as e, text as t, title as n, titleRow as r } from "./PageHeader.styles.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { clsx as i } from "clsx";
|
|
3
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
5
4
|
// src/components/PageHeader/PageHeader.tsx
|
|
6
|
-
function
|
|
7
|
-
let
|
|
8
|
-
return /* @__PURE__ */
|
|
9
|
-
className:
|
|
10
|
-
...
|
|
11
|
-
children: [/* @__PURE__ */
|
|
5
|
+
function s({ title: s, logo: c, facts: l = [], description: u, actions: d, className: f, ...p }) {
|
|
6
|
+
let m = l.filter((e) => e != null && e !== !1 && e !== "");
|
|
7
|
+
return /* @__PURE__ */ o("header", {
|
|
8
|
+
className: i(e, f),
|
|
9
|
+
...p,
|
|
10
|
+
children: [/* @__PURE__ */ o("div", {
|
|
12
11
|
className: t,
|
|
13
12
|
children: [
|
|
14
|
-
/* @__PURE__ */
|
|
13
|
+
/* @__PURE__ */ o("div", {
|
|
15
14
|
className: r,
|
|
16
|
-
children: [
|
|
15
|
+
children: [c, /* @__PURE__ */ a("h1", {
|
|
17
16
|
className: n,
|
|
18
|
-
children:
|
|
17
|
+
children: s
|
|
19
18
|
})]
|
|
20
19
|
}),
|
|
21
|
-
|
|
20
|
+
m.length > 0 && /* @__PURE__ */ a("p", {
|
|
22
21
|
className: "_1l8jgo54",
|
|
23
|
-
children:
|
|
24
|
-
className: "_1l8jgo55",
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}), /* @__PURE__ */ o("span", { children: e })] }, t))
|
|
22
|
+
children: m.map((e, t) => /* @__PURE__ */ a("span", {
|
|
23
|
+
className: t === 0 ? "_1l8jgo55" : void 0,
|
|
24
|
+
children: e
|
|
25
|
+
}, t))
|
|
28
26
|
}),
|
|
29
|
-
|
|
27
|
+
u != null && /* @__PURE__ */ a("p", {
|
|
30
28
|
className: "_1l8jgo56",
|
|
31
|
-
children:
|
|
29
|
+
children: u
|
|
32
30
|
})
|
|
33
31
|
]
|
|
34
|
-
}),
|
|
32
|
+
}), d && /* @__PURE__ */ a("div", {
|
|
35
33
|
className: "_1l8jgo57",
|
|
36
|
-
children:
|
|
34
|
+
children: d
|
|
37
35
|
})]
|
|
38
36
|
});
|
|
39
37
|
}
|
|
40
|
-
export {
|
|
38
|
+
export { s as PageHeader };
|
|
41
39
|
|
|
42
40
|
//# sourceMappingURL=PageHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageHeader.js","names":["facts","styles.header","styles.text","styles.titleRow","styles.title","title","description","actions","PageHeader","title$1","facts$1","description$1","actions$1","props","shownFacts","clsx","header","className","text","titleRow","logo","title","
|
|
1
|
+
{"version":3,"file":"PageHeader.js","names":["facts","styles.header","styles.text","styles.titleRow","styles.title","title","description","actions","PageHeader","title$1","facts$1","description$1","actions$1","props","shownFacts","fact","clsx","header","className","text","titleRow","logo","title","index"],"sources":["../../../src/components/PageHeader/PageHeader.tsx"],"sourcesContent":["import { clsx } from 'clsx'\nimport type { ComponentProps, ReactNode } from 'react'\n\nimport * as styles from './PageHeader.css'\n\nexport interface PageHeaderProps extends Omit<ComponentProps<'header'>, 'title'> {\n /** The page's `<h1>`. */\n title: ReactNode\n /** Shown before the title, e.g. a logo or avatar. */\n logo?: ReactNode\n /** Short facts on one line under the title. Put the one people act on first: it leads and the rest are muted. `null`, `undefined`, `false` and `''` are skipped (`0` is kept). */\n facts?: ReactNode[]\n /** A sentence or two under the title. */\n description?: ReactNode\n /** Controls at the top right, e.g. the page's primary Button. */\n actions?: ReactNode\n}\n\n/** The page's h1, with an optional facts line, description, and actions at the top right. */\nexport function PageHeader({\n title,\n logo,\n facts = [],\n description,\n actions,\n className,\n ...props\n}: PageHeaderProps) {\n const shownFacts = facts.filter((fact) => fact != null && fact !== false && fact !== '')\n return (\n <header className={clsx(styles.header, className)} {...props}>\n <div className={styles.text}>\n <div className={styles.titleRow}>\n {logo}\n <h1 className={styles.title}>{title}</h1>\n </div>\n {shownFacts.length > 0 && (\n <p className={styles.facts}>\n {shownFacts.map((fact, index) => (\n <span key={index} className={index === 0 ? styles.leadFact : undefined}>\n {fact}\n </span>\n ))}\n </p>\n )}\n {description != null && <p className={styles.description}>{description}</p>}\n </div>\n {actions && <div className={styles.actions}>{actions}</div>}\n </header>\n )\n}\n"],"mappings":";;;;AAmBA,SAAgBQ,EAAW,EACzB,OAAAC,GACA,SACA,OAAAC,IAAQ,CAAC,GACT,aAAAC,GACA,SAAAC,GACA,cACA,GAAGC,KACe;CAClB,IAAMC,IAAad,EAAM,QAAQ,MAASe,KAAQ,QAAQA,MAAS,MAASA,MAAS,EAAE;CACvF,OACE,kBAAC,UAAD;EAAQ,WAAWC,EAAKf,GAAeiB,CAAS;EAAG,GAAIL;EAAvD,UAAA,CACE,kBAAC,OAAD;GAAK,WAAWX;GAAhB,UAAA;IACE,kBAAC,OAAD;KAAK,WAAWC;KAAhB,UAAA,CACGkB,GACD,kBAAC,MAAD;MAAI,WAAWjB;MAAe,UAAAC;KAAU,CAAA,CACrC;;IACJS,EAAW,SAAS,KACnB,kBAAC,KAAD;KAAG,WAAW;KACX,UAAAA,EAAW,KAAK,GAAM,MACrB,kBAAC,QAAD;MAAkB,WAAWS,MAAU,IAAI,cAAkB,KAAA;MAC1D,UAAAR;KACG,GAFKQ,CAEL,CACP;IACA,CAAA;IAEJjB,KAAe,QAAQ,kBAAC,KAAD;KAAG,WAAW;KAAqB,UAAAA;IAAe,CAAA;GACvE;EACJ,CAAA,GAAAC,KAAW,kBAAC,OAAD;GAAK,WAAW;GAAiB,UAAAA;EAAa,CAAA,CACpD;;AAEZ"}
|