@mystravil/hardpoint 0.0.0-stage → 0.2.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +25 -0
  3. package/README.md +64 -3
  4. package/dist/base.css +625 -0
  5. package/dist/components/AppShell.svelte +698 -0
  6. package/dist/components/AppShell.svelte.d.ts +77 -0
  7. package/dist/components/Button.svelte +174 -0
  8. package/dist/components/Button.svelte.d.ts +20 -0
  9. package/dist/components/Checkbox.svelte +235 -0
  10. package/dist/components/Checkbox.svelte.d.ts +23 -0
  11. package/dist/components/CheckboxGroup.svelte +207 -0
  12. package/dist/components/CheckboxGroup.svelte.d.ts +44 -0
  13. package/dist/components/Combobox.svelte +901 -0
  14. package/dist/components/Combobox.svelte.d.ts +72 -0
  15. package/dist/components/Dialog.svelte +359 -0
  16. package/dist/components/Dialog.svelte.d.ts +43 -0
  17. package/dist/components/Disclosure.svelte +201 -0
  18. package/dist/components/Disclosure.svelte.d.ts +27 -0
  19. package/dist/components/EmptyState.svelte +88 -0
  20. package/dist/components/EmptyState.svelte.d.ts +22 -0
  21. package/dist/components/ErrorState.svelte +135 -0
  22. package/dist/components/ErrorState.svelte.d.ts +26 -0
  23. package/dist/components/ImageViewer.svelte +764 -0
  24. package/dist/components/ImageViewer.svelte.d.ts +55 -0
  25. package/dist/components/KeyValueList.svelte +114 -0
  26. package/dist/components/KeyValueList.svelte.d.ts +43 -0
  27. package/dist/components/ListDetail.svelte +218 -0
  28. package/dist/components/ListDetail.svelte.d.ts +37 -0
  29. package/dist/components/LoadRegion.svelte +219 -0
  30. package/dist/components/LoadRegion.svelte.d.ts +27 -0
  31. package/dist/components/MediaFrame.svelte +110 -0
  32. package/dist/components/MediaFrame.svelte.d.ts +20 -0
  33. package/dist/components/MediaImage.svelte +256 -0
  34. package/dist/components/MediaImage.svelte.d.ts +16 -0
  35. package/dist/components/Menu.svelte +258 -0
  36. package/dist/components/Menu.svelte.d.ts +36 -0
  37. package/dist/components/MenuCheckboxItem.svelte +119 -0
  38. package/dist/components/MenuCheckboxItem.svelte.d.ts +15 -0
  39. package/dist/components/MenuGroup.svelte +50 -0
  40. package/dist/components/MenuGroup.svelte.d.ts +15 -0
  41. package/dist/components/MenuItem.svelte +94 -0
  42. package/dist/components/MenuItem.svelte.d.ts +19 -0
  43. package/dist/components/MenuRadioGroup.svelte +62 -0
  44. package/dist/components/MenuRadioGroup.svelte.d.ts +20 -0
  45. package/dist/components/MenuRadioItem.svelte +110 -0
  46. package/dist/components/MenuRadioItem.svelte.d.ts +17 -0
  47. package/dist/components/MenuSeparator.svelte +28 -0
  48. package/dist/components/MenuSeparator.svelte.d.ts +6 -0
  49. package/dist/components/Meter.svelte +283 -0
  50. package/dist/components/Meter.svelte.d.ts +66 -0
  51. package/dist/components/NativeSelect.svelte +135 -0
  52. package/dist/components/NativeSelect.svelte.d.ts +52 -0
  53. package/dist/components/Notice.svelte +262 -0
  54. package/dist/components/Notice.svelte.d.ts +30 -0
  55. package/dist/components/Pagination.svelte +132 -0
  56. package/dist/components/Pagination.svelte.d.ts +18 -0
  57. package/dist/components/Popover.svelte +222 -0
  58. package/dist/components/Popover.svelte.d.ts +35 -0
  59. package/dist/components/Progress.svelte +157 -0
  60. package/dist/components/Progress.svelte.d.ts +34 -0
  61. package/dist/components/RadioGroup.svelte +440 -0
  62. package/dist/components/RadioGroup.svelte.d.ts +50 -0
  63. package/dist/components/Select.svelte +471 -0
  64. package/dist/components/Select.svelte.d.ts +48 -0
  65. package/dist/components/Skeleton.svelte +149 -0
  66. package/dist/components/Skeleton.svelte.d.ts +24 -0
  67. package/dist/components/Spinner.svelte +118 -0
  68. package/dist/components/Spinner.svelte.d.ts +13 -0
  69. package/dist/components/Stat.svelte +253 -0
  70. package/dist/components/Stat.svelte.d.ts +46 -0
  71. package/dist/components/Steps.svelte +189 -0
  72. package/dist/components/Steps.svelte.d.ts +31 -0
  73. package/dist/components/Switch.svelte +222 -0
  74. package/dist/components/Switch.svelte.d.ts +18 -0
  75. package/dist/components/Table.svelte +504 -0
  76. package/dist/components/Table.svelte.d.ts +92 -0
  77. package/dist/components/Tabs.svelte +246 -0
  78. package/dist/components/Tabs.svelte.d.ts +44 -0
  79. package/dist/components/Tag.svelte +40 -0
  80. package/dist/components/Tag.svelte.d.ts +15 -0
  81. package/dist/components/TextArea.svelte +272 -0
  82. package/dist/components/TextArea.svelte.d.ts +28 -0
  83. package/dist/components/TextField.svelte +256 -0
  84. package/dist/components/TextField.svelte.d.ts +32 -0
  85. package/dist/components/Timeline.svelte +156 -0
  86. package/dist/components/Timeline.svelte.d.ts +30 -0
  87. package/dist/components/Toaster.svelte +411 -0
  88. package/dist/components/Toaster.svelte.d.ts +11 -0
  89. package/dist/components/Tooltip.svelte +200 -0
  90. package/dist/components/Tooltip.svelte.d.ts +38 -0
  91. package/dist/components/TooltipGroup.svelte +46 -0
  92. package/dist/components/TooltipGroup.svelte.d.ts +29 -0
  93. package/dist/components/internal/Scrim.svelte +52 -0
  94. package/dist/components/internal/Scrim.svelte.d.ts +15 -0
  95. package/dist/components/internal/Sheet.svelte +263 -0
  96. package/dist/components/internal/Sheet.svelte.d.ts +36 -0
  97. package/dist/components/internal/fade-in.d.ts +10 -0
  98. package/dist/components/internal/fade-in.js +20 -0
  99. package/dist/components/internal/groups.d.ts +14 -0
  100. package/dist/components/internal/groups.js +23 -0
  101. package/dist/components/internal/resolve.d.ts +8 -0
  102. package/dist/components/internal/resolve.js +247 -0
  103. package/dist/components/internal/swipe-dismiss.d.ts +47 -0
  104. package/dist/components/internal/swipe-dismiss.js +220 -0
  105. package/dist/components/internal/visual-viewport.svelte.d.ts +35 -0
  106. package/dist/components/internal/visual-viewport.svelte.js +79 -0
  107. package/dist/components/toast.svelte.d.ts +57 -0
  108. package/dist/components/toast.svelte.js +84 -0
  109. package/dist/fonts/OFL-geist-pixel.txt +92 -0
  110. package/dist/fonts/OFL.txt +93 -0
  111. package/dist/fonts/geist-latin-variable.woff2 +0 -0
  112. package/dist/fonts/geist-mono-latin-variable.woff2 +0 -0
  113. package/dist/fonts/geist-pixel-square.woff2 +0 -0
  114. package/dist/fonts.css +71 -0
  115. package/dist/index.d.ts +45 -0
  116. package/dist/index.js +45 -0
  117. package/dist/motion/Motion.svelte +15 -0
  118. package/dist/motion/Motion.svelte.d.ts +9 -0
  119. package/dist/motion/context.d.ts +18 -0
  120. package/dist/motion/context.js +26 -0
  121. package/dist/motion/index.d.ts +3 -0
  122. package/dist/motion/index.js +3 -0
  123. package/dist/motion/transitions.d.ts +31 -0
  124. package/dist/motion/transitions.js +112 -0
  125. package/dist/tokens.css +283 -0
  126. package/package.json +76 -6
@@ -0,0 +1,36 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
3
+ export type MenuTriggerSnippetProps = {
4
+ /** Spread onto the button that opens the menu. */
5
+ props: Record<string, unknown>;
6
+ };
7
+ /**
8
+ * Attributes and handlers not listed here go to the menu element (Bits UI
9
+ * `DropdownMenu.Content`), among them `side` (default `bottom`), `align`
10
+ * (default `start`), `sideOffset` (default 8), `collisionPadding`
11
+ * (default 8), `loop`, `onCloseAutoFocus`, `onEscapeKeydown` and
12
+ * `onInteractOutside`. The placement props apply from 600px only; below it
13
+ * the menu is a bottom sheet.
14
+ */
15
+ export type MenuProps = Omit<BitsDropdownMenu.ContentProps, 'child' | 'children' | 'forceMount' | 'ref'> & {
16
+ open?: boolean;
17
+ /**
18
+ * The menu's accessible name, and the sheet's title below 600px. Use the
19
+ * trigger's accessible name: its text, or an icon button's `aria-label`.
20
+ * A fixed string the app defines, set in caps as the sheet's title, so it
21
+ * never carries user data; name a row's item through the trigger's
22
+ * `aria-describedby`.
23
+ */
24
+ label: string;
25
+ /** The button the menu opens from: spread `props` onto it. */
26
+ trigger: Snippet<[MenuTriggerSnippetProps]>;
27
+ /** The items: MenuItem, MenuCheckboxItem, MenuRadioGroup, MenuGroup and MenuSeparator. */
28
+ children: Snippet;
29
+ /** The sheet's close button's accessible name (below 600px). */
30
+ closeLabel?: string;
31
+ /** The menu element, `role="menu"`. */
32
+ ref?: HTMLElement | null;
33
+ };
34
+ declare const Menu: import("svelte").Component<MenuProps, {}, "ref" | "open">;
35
+ type Menu = ReturnType<typeof Menu>;
36
+ export default Menu;
@@ -0,0 +1,119 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
4
+
5
+ /**
6
+ * Attributes and handlers not listed here go to the item element (Bits UI
7
+ * `DropdownMenu.CheckboxItem`), among them `disabled`, `onCheckedChange`,
8
+ * `onSelect` and `closeOnSelect` (default true; pass false to keep the
9
+ * menu open, so the change shows).
10
+ */
11
+ export type MenuCheckboxItemProps = Omit<
12
+ BitsDropdownMenu.CheckboxItemProps,
13
+ 'child' | 'children' | 'indeterminate' | 'onIndeterminateChange' | 'value'
14
+ > & {
15
+ /** The label, as written (never caps). */
16
+ children: Snippet;
17
+ };
18
+ </script>
19
+
20
+ <script lang="ts">
21
+ import { DropdownMenu } from 'bits-ui';
22
+
23
+ let {
24
+ checked = $bindable(false),
25
+ ref = $bindable(null),
26
+ class: className,
27
+ children,
28
+ ...rest
29
+ }: MenuCheckboxItemProps = $props();
30
+ </script>
31
+
32
+ <!--
33
+ A Bits UI checkbox item, role="menuitemcheckbox", with aria-checked and
34
+ data-state (checked, unchecked). A press, Enter or Space toggles it.
35
+ -->
36
+ <DropdownMenu.CheckboxItem bind:checked bind:ref {...rest}>
37
+ {#snippet child({ props })}
38
+ <div {...props} class={['hp-menu-checkbox-item', className]}>
39
+ <span class="hp-menu-box" aria-hidden="true">
40
+ <svg class="hp-menu-check" viewBox="0 0 12 12"><path d="M1.5 6.5l3 3 6-6" /></svg>
41
+ </span>
42
+ <span class="hp-menu-item-label">{@render children()}</span>
43
+ </div>
44
+ {/snippet}
45
+ </DropdownMenu.CheckboxItem>
46
+
47
+ <style>
48
+ /* The row: the same as MenuItem's. Only the mark fades (below). */
49
+ .hp-menu-checkbox-item {
50
+ display: flex;
51
+ align-items: center;
52
+ gap: var(--space-3);
53
+ box-sizing: border-box;
54
+ min-height: var(--control-height);
55
+ padding: var(--space-1) var(--menu-inset, var(--space-3));
56
+ font: var(--type-body) / 24px var(--sans);
57
+ overflow-wrap: anywhere;
58
+ cursor: pointer;
59
+ user-select: none;
60
+ touch-action: manipulation;
61
+ -webkit-tap-highlight-color: transparent;
62
+ outline: none;
63
+ }
64
+ .hp-menu-item-label {
65
+ flex: 1 1 auto;
66
+ min-width: 0;
67
+ }
68
+ .hp-menu-checkbox-item[data-highlighted] {
69
+ background: var(--surface-hover);
70
+ outline: var(--menu-contour, none);
71
+ outline-offset: -2px;
72
+ }
73
+ .hp-menu-checkbox-item:active:not([data-disabled]) {
74
+ background: var(--surface-raised);
75
+ }
76
+ .hp-menu-checkbox-item[data-disabled] {
77
+ color: var(--muted);
78
+ cursor: not-allowed;
79
+ }
80
+
81
+ /* Checkbox's black box with a 3:1 boundary. Checked, the edge and the
82
+ mark turn titanium and the box stays black: selection is never a fill.
83
+ The row's tint is the hover feedback. */
84
+ .hp-menu-box {
85
+ flex: none;
86
+ display: grid;
87
+ place-items: center;
88
+ box-sizing: border-box;
89
+ width: 20px;
90
+ height: 20px;
91
+ border: 1px solid var(--border-control);
92
+ background: var(--canvas);
93
+ color: var(--accent);
94
+ }
95
+ .hp-menu-checkbox-item[data-state='checked'] .hp-menu-box {
96
+ border-color: var(--accent);
97
+ }
98
+ .hp-menu-checkbox-item[data-disabled] .hp-menu-box {
99
+ border-color: var(--border);
100
+ color: var(--muted);
101
+ }
102
+ /* The check is always there, at opacity 0 until the item is checked.
103
+ Checking fades it in from 0 over --dur-mark (BRIEF, short motion);
104
+ unchecking takes it away at once. A CSS transition never runs on an
105
+ element's first style, so a menu that opens shows its marks at once.
106
+ 0ms is a snap. Opacity only, so reduced motion keeps it. */
107
+ .hp-menu-check {
108
+ width: 12px;
109
+ height: 12px;
110
+ fill: none;
111
+ stroke: currentColor;
112
+ stroke-width: 2px;
113
+ opacity: 0;
114
+ }
115
+ .hp-menu-checkbox-item[data-state='checked'] .hp-menu-check {
116
+ opacity: 1;
117
+ transition: opacity var(--dur-mark) var(--settle);
118
+ }
119
+ </style>
@@ -0,0 +1,15 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
3
+ /**
4
+ * Attributes and handlers not listed here go to the item element (Bits UI
5
+ * `DropdownMenu.CheckboxItem`), among them `disabled`, `onCheckedChange`,
6
+ * `onSelect` and `closeOnSelect` (default true; pass false to keep the
7
+ * menu open, so the change shows).
8
+ */
9
+ export type MenuCheckboxItemProps = Omit<BitsDropdownMenu.CheckboxItemProps, 'child' | 'children' | 'indeterminate' | 'onIndeterminateChange' | 'value'> & {
10
+ /** The label, as written (never caps). */
11
+ children: Snippet;
12
+ };
13
+ declare const MenuCheckboxItem: import("svelte").Component<MenuCheckboxItemProps, {}, "ref" | "checked">;
14
+ type MenuCheckboxItem = ReturnType<typeof MenuCheckboxItem>;
15
+ export default MenuCheckboxItem;
@@ -0,0 +1,50 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
4
+
5
+ /** Attributes not listed here go to the group element (Bits UI `DropdownMenu.Group`). */
6
+ export type MenuGroupProps = Omit<BitsDropdownMenu.GroupProps, 'child' | 'children'> & {
7
+ /**
8
+ * The caps heading over the items, and the group's accessible name. A
9
+ * fixed string the app defines, set in caps; never user data.
10
+ */
11
+ label?: string;
12
+ /** The items. */
13
+ children: Snippet;
14
+ };
15
+ </script>
16
+
17
+ <script lang="ts">
18
+ import { DropdownMenu } from 'bits-ui';
19
+
20
+ let { label, ref = $bindable(null), class: className, children, ...rest }: MenuGroupProps = $props();
21
+ </script>
22
+
23
+ <!--
24
+ A Bits UI group, role="group", named by its heading through
25
+ aria-labelledby. Separate groups with a MenuSeparator.
26
+ -->
27
+ <DropdownMenu.Group bind:ref {...rest}>
28
+ {#snippet child({ props })}
29
+ <div {...props} class={['hp-menu-group', className]}>
30
+ {#if label}
31
+ <DropdownMenu.GroupHeading>
32
+ {#snippet child({ props: headingProps })}
33
+ <div {...headingProps} class="hp-menu-group-heading hp-label">{label}</div>
34
+ {/snippet}
35
+ </DropdownMenu.GroupHeading>
36
+ {/if}
37
+ {@render children()}
38
+ </div>
39
+ {/snippet}
40
+ </DropdownMenu.Group>
41
+
42
+ <style>
43
+ /* A muted caps label over the items, its text on the items' text edge.
44
+ The same heading as MenuRadioGroup's. */
45
+ .hp-menu-group-heading {
46
+ padding: var(--space-2) var(--menu-inset, var(--space-3)) var(--space-1);
47
+ color: var(--muted);
48
+ user-select: none;
49
+ }
50
+ </style>
@@ -0,0 +1,15 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
3
+ /** Attributes not listed here go to the group element (Bits UI `DropdownMenu.Group`). */
4
+ export type MenuGroupProps = Omit<BitsDropdownMenu.GroupProps, 'child' | 'children'> & {
5
+ /**
6
+ * The caps heading over the items, and the group's accessible name. A
7
+ * fixed string the app defines, set in caps; never user data.
8
+ */
9
+ label?: string;
10
+ /** The items. */
11
+ children: Snippet;
12
+ };
13
+ declare const MenuGroup: import("svelte").Component<MenuGroupProps, {}, "ref">;
14
+ type MenuGroup = ReturnType<typeof MenuGroup>;
15
+ export default MenuGroup;
@@ -0,0 +1,94 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
4
+
5
+ export type MenuItemVariant = 'default' | 'danger';
6
+
7
+ /**
8
+ * Attributes and handlers not listed here go to the item element (Bits UI
9
+ * `DropdownMenu.Item`), among them `disabled`, `onSelect` (call
10
+ * `preventDefault()` on its event to keep the menu open), `closeOnSelect`
11
+ * (default true) and `textValue`. Typeahead matches the label's text:
12
+ * Bits UI 2.20.6 declares `textValue` but does not read it yet.
13
+ */
14
+ export type MenuItemProps = Omit<BitsDropdownMenu.ItemProps, 'child' | 'children'> & {
15
+ /** `danger` (status red) for an action that destroys or removes something. */
16
+ variant?: MenuItemVariant;
17
+ /** The label, as written (never caps). */
18
+ children: Snippet;
19
+ };
20
+ </script>
21
+
22
+ <script lang="ts">
23
+ import { DropdownMenu } from 'bits-ui';
24
+
25
+ let {
26
+ variant = 'default',
27
+ ref = $bindable(null),
28
+ class: className,
29
+ children,
30
+ ...rest
31
+ }: MenuItemProps = $props();
32
+ </script>
33
+
34
+ <!--
35
+ A Bits UI menu item, role="menuitem", with Bits UI's data-highlighted,
36
+ data-disabled and aria-disabled. A press, Enter or Space runs `onSelect`
37
+ and closes the menu.
38
+ -->
39
+ <DropdownMenu.Item bind:ref {...rest}>
40
+ {#snippet child({ props })}
41
+ <div {...props} class={['hp-menu-item', className]} data-variant={variant}>
42
+ <span class="hp-menu-item-label">{@render children()}</span>
43
+ </div>
44
+ {/snippet}
45
+ </DropdownMenu.Item>
46
+
47
+ <style>
48
+ /* A Geist row, sentence case: 36px on fine pointers, 44px on coarse.
49
+ The label is one flex item, so inline markup inside it stays inline.
50
+ Highlight moves snap, so nothing on a row transitions (BRIEF, motion
51
+ rule 3). Same row as MenuCheckboxItem and MenuRadioItem. */
52
+ .hp-menu-item {
53
+ display: flex;
54
+ align-items: center;
55
+ gap: var(--space-3);
56
+ box-sizing: border-box;
57
+ min-height: var(--control-height);
58
+ padding: var(--space-1) var(--menu-inset, var(--space-3));
59
+ font: var(--type-body) / 24px var(--sans);
60
+ overflow-wrap: anywhere;
61
+ cursor: pointer;
62
+ user-select: none;
63
+ touch-action: manipulation;
64
+ -webkit-tap-highlight-color: transparent;
65
+ outline: none;
66
+ }
67
+ .hp-menu-item-label {
68
+ flex: 1 1 auto;
69
+ min-width: 0;
70
+ }
71
+
72
+ /* Highlighted, by keys or a pointer: the hover tint. A highlight the keys
73
+ moved also draws the focus contour inside the row (Menu sets
74
+ --menu-contour). */
75
+ .hp-menu-item[data-highlighted] {
76
+ background: var(--surface-hover);
77
+ outline: var(--menu-contour, none);
78
+ outline-offset: -2px;
79
+ }
80
+ /* Press: one step past the tint, so it reads on a phone too. */
81
+ .hp-menu-item:active:not([data-disabled]) {
82
+ background: var(--surface-raised);
83
+ }
84
+
85
+ .hp-menu-item[data-variant='danger'] {
86
+ color: var(--danger);
87
+ }
88
+ /* Disabled: muted, even a danger item; keys skip it and a pointer does
89
+ not highlight it. */
90
+ .hp-menu-item[data-disabled] {
91
+ color: var(--muted);
92
+ cursor: not-allowed;
93
+ }
94
+ </style>
@@ -0,0 +1,19 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
3
+ export type MenuItemVariant = 'default' | 'danger';
4
+ /**
5
+ * Attributes and handlers not listed here go to the item element (Bits UI
6
+ * `DropdownMenu.Item`), among them `disabled`, `onSelect` (call
7
+ * `preventDefault()` on its event to keep the menu open), `closeOnSelect`
8
+ * (default true) and `textValue`. Typeahead matches the label's text:
9
+ * Bits UI 2.20.6 declares `textValue` but does not read it yet.
10
+ */
11
+ export type MenuItemProps = Omit<BitsDropdownMenu.ItemProps, 'child' | 'children'> & {
12
+ /** `danger` (status red) for an action that destroys or removes something. */
13
+ variant?: MenuItemVariant;
14
+ /** The label, as written (never caps). */
15
+ children: Snippet;
16
+ };
17
+ declare const MenuItem: import("svelte").Component<MenuItemProps, {}, "ref">;
18
+ type MenuItem = ReturnType<typeof MenuItem>;
19
+ export default MenuItem;
@@ -0,0 +1,62 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
4
+
5
+ /**
6
+ * Attributes and handlers not listed here go to the group element (Bits
7
+ * UI `DropdownMenu.RadioGroup`), among them `onValueChange`.
8
+ */
9
+ export type MenuRadioGroupProps = Omit<BitsDropdownMenu.RadioGroupProps, 'child' | 'children'> & {
10
+ /** The chosen MenuRadioItem's `value`; `''` for none. */
11
+ value?: string;
12
+ /**
13
+ * The caps heading over the items, and the group's accessible name. A
14
+ * fixed string the app defines, set in caps; never user data.
15
+ */
16
+ label?: string;
17
+ /** The MenuRadioItems. */
18
+ children: Snippet;
19
+ };
20
+ </script>
21
+
22
+ <script lang="ts">
23
+ import { DropdownMenu } from 'bits-ui';
24
+
25
+ let {
26
+ value = $bindable(''),
27
+ label,
28
+ ref = $bindable(null),
29
+ class: className,
30
+ children,
31
+ ...rest
32
+ }: MenuRadioGroupProps = $props();
33
+ </script>
34
+
35
+ <!--
36
+ A Bits UI radio group, role="group", named by its heading through
37
+ aria-labelledby. One of its MenuRadioItems is chosen at a time.
38
+ -->
39
+ <DropdownMenu.RadioGroup bind:value bind:ref {...rest}>
40
+ {#snippet child({ props })}
41
+ <div {...props} class={['hp-menu-radio-group', className]}>
42
+ {#if label}
43
+ <DropdownMenu.GroupHeading>
44
+ {#snippet child({ props: headingProps })}
45
+ <div {...headingProps} class="hp-menu-group-heading hp-label">{label}</div>
46
+ {/snippet}
47
+ </DropdownMenu.GroupHeading>
48
+ {/if}
49
+ {@render children()}
50
+ </div>
51
+ {/snippet}
52
+ </DropdownMenu.RadioGroup>
53
+
54
+ <style>
55
+ /* MenuGroup's heading: a muted caps label over the items, its text on
56
+ the items' text edge. */
57
+ .hp-menu-group-heading {
58
+ padding: var(--space-2) var(--menu-inset, var(--space-3)) var(--space-1);
59
+ color: var(--muted);
60
+ user-select: none;
61
+ }
62
+ </style>
@@ -0,0 +1,20 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
3
+ /**
4
+ * Attributes and handlers not listed here go to the group element (Bits
5
+ * UI `DropdownMenu.RadioGroup`), among them `onValueChange`.
6
+ */
7
+ export type MenuRadioGroupProps = Omit<BitsDropdownMenu.RadioGroupProps, 'child' | 'children'> & {
8
+ /** The chosen MenuRadioItem's `value`; `''` for none. */
9
+ value?: string;
10
+ /**
11
+ * The caps heading over the items, and the group's accessible name. A
12
+ * fixed string the app defines, set in caps; never user data.
13
+ */
14
+ label?: string;
15
+ /** The MenuRadioItems. */
16
+ children: Snippet;
17
+ };
18
+ declare const MenuRadioGroup: import("svelte").Component<MenuRadioGroupProps, {}, "value" | "ref">;
19
+ type MenuRadioGroup = ReturnType<typeof MenuRadioGroup>;
20
+ export default MenuRadioGroup;
@@ -0,0 +1,110 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
4
+
5
+ /**
6
+ * Attributes and handlers not listed here go to the item element (Bits UI
7
+ * `DropdownMenu.RadioItem`), among them `disabled`, `onSelect` and
8
+ * `closeOnSelect` (default true; pass false to keep the menu open, so the
9
+ * change shows). Place it inside a MenuRadioGroup.
10
+ */
11
+ export type MenuRadioItemProps = Omit<BitsDropdownMenu.RadioItemProps, 'child' | 'children'> & {
12
+ /** Chosen when the group's `value` equals it. */
13
+ value: string;
14
+ /** The label, as written (never caps). */
15
+ children: Snippet;
16
+ };
17
+ </script>
18
+
19
+ <script lang="ts">
20
+ import { DropdownMenu } from 'bits-ui';
21
+
22
+ let { ref = $bindable(null), class: className, children, ...rest }: MenuRadioItemProps = $props();
23
+ </script>
24
+
25
+ <!--
26
+ A Bits UI radio item, role="menuitemradio", with aria-checked and
27
+ data-state (checked, unchecked). A press, Enter or Space chooses it.
28
+ -->
29
+ <DropdownMenu.RadioItem bind:ref {...rest}>
30
+ {#snippet child({ props })}
31
+ <div {...props} class={['hp-menu-radio-item', className]}>
32
+ <span class="hp-menu-box" aria-hidden="true">
33
+ <span class="hp-menu-radio-mark"></span>
34
+ </span>
35
+ <span class="hp-menu-item-label">{@render children()}</span>
36
+ </div>
37
+ {/snippet}
38
+ </DropdownMenu.RadioItem>
39
+
40
+ <style>
41
+ /* The row: the same as MenuItem's. Only the mark fades (below). */
42
+ .hp-menu-radio-item {
43
+ display: flex;
44
+ align-items: center;
45
+ gap: var(--space-3);
46
+ box-sizing: border-box;
47
+ min-height: var(--control-height);
48
+ padding: var(--space-1) var(--menu-inset, var(--space-3));
49
+ font: var(--type-body) / 24px var(--sans);
50
+ overflow-wrap: anywhere;
51
+ cursor: pointer;
52
+ user-select: none;
53
+ touch-action: manipulation;
54
+ -webkit-tap-highlight-color: transparent;
55
+ outline: none;
56
+ }
57
+ .hp-menu-item-label {
58
+ flex: 1 1 auto;
59
+ min-width: 0;
60
+ }
61
+ .hp-menu-radio-item[data-highlighted] {
62
+ background: var(--surface-hover);
63
+ outline: var(--menu-contour, none);
64
+ outline-offset: -2px;
65
+ }
66
+ .hp-menu-radio-item:active:not([data-disabled]) {
67
+ background: var(--surface-raised);
68
+ }
69
+ .hp-menu-radio-item[data-disabled] {
70
+ color: var(--muted);
71
+ cursor: not-allowed;
72
+ }
73
+
74
+ /* The checkbox item's black box; chosen, a titanium edge and a solid
75
+ 8px titanium square, square like every other mark. */
76
+ .hp-menu-box {
77
+ flex: none;
78
+ display: grid;
79
+ place-items: center;
80
+ box-sizing: border-box;
81
+ width: 20px;
82
+ height: 20px;
83
+ border: 1px solid var(--border-control);
84
+ background: var(--canvas);
85
+ color: var(--accent);
86
+ }
87
+ .hp-menu-radio-item[data-state='checked'] .hp-menu-box {
88
+ border-color: var(--accent);
89
+ }
90
+ .hp-menu-radio-item[data-disabled] .hp-menu-box {
91
+ border-color: var(--border);
92
+ color: var(--muted);
93
+ }
94
+ /* The mark is always there, at opacity 0 until the item is chosen.
95
+ Choosing fades it in from 0 over --dur-mark (BRIEF, short motion);
96
+ the item that loses the choice drops its mark at once. A CSS
97
+ transition never runs on an element's first style, so a menu that
98
+ opens shows its mark at once. 0ms is a snap. Opacity only, so reduced
99
+ motion keeps it. */
100
+ .hp-menu-radio-mark {
101
+ width: 8px;
102
+ height: 8px;
103
+ background: currentColor;
104
+ opacity: 0;
105
+ }
106
+ .hp-menu-radio-item[data-state='checked'] .hp-menu-radio-mark {
107
+ opacity: 1;
108
+ transition: opacity var(--dur-mark) var(--settle);
109
+ }
110
+ </style>
@@ -0,0 +1,17 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
3
+ /**
4
+ * Attributes and handlers not listed here go to the item element (Bits UI
5
+ * `DropdownMenu.RadioItem`), among them `disabled`, `onSelect` and
6
+ * `closeOnSelect` (default true; pass false to keep the menu open, so the
7
+ * change shows). Place it inside a MenuRadioGroup.
8
+ */
9
+ export type MenuRadioItemProps = Omit<BitsDropdownMenu.RadioItemProps, 'child' | 'children'> & {
10
+ /** Chosen when the group's `value` equals it. */
11
+ value: string;
12
+ /** The label, as written (never caps). */
13
+ children: Snippet;
14
+ };
15
+ declare const MenuRadioItem: import("svelte").Component<MenuRadioItemProps, {}, "ref">;
16
+ type MenuRadioItem = ReturnType<typeof MenuRadioItem>;
17
+ export default MenuRadioItem;
@@ -0,0 +1,28 @@
1
+ <script lang="ts" module>
2
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
3
+
4
+ /** Attributes go to the separator element (Bits UI `DropdownMenu.Separator`). */
5
+ export type MenuSeparatorProps = Omit<BitsDropdownMenu.SeparatorProps, 'child' | 'children'>;
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ import { DropdownMenu } from 'bits-ui';
10
+
11
+ let { ref = $bindable(null), class: className, ...rest }: MenuSeparatorProps = $props();
12
+ </script>
13
+
14
+ <!-- A Bits UI separator, role="separator", between groups of items. -->
15
+ <DropdownMenu.Separator bind:ref {...rest}>
16
+ {#snippet child({ props })}
17
+ <div {...props} class={['hp-menu-separator', className]}></div>
18
+ {/snippet}
19
+ </DropdownMenu.Separator>
20
+
21
+ <style>
22
+ /* A 1px divider across the whole menu, in the decorative line colour. */
23
+ .hp-menu-separator {
24
+ height: 1px;
25
+ margin-block: var(--space-1);
26
+ background: var(--border);
27
+ }
28
+ </style>
@@ -0,0 +1,6 @@
1
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
2
+ /** Attributes go to the separator element (Bits UI `DropdownMenu.Separator`). */
3
+ export type MenuSeparatorProps = Omit<BitsDropdownMenu.SeparatorProps, 'child' | 'children'>;
4
+ declare const MenuSeparator: import("svelte").Component<MenuSeparatorProps, {}, "ref">;
5
+ type MenuSeparator = ReturnType<typeof MenuSeparator>;
6
+ export default MenuSeparator;