@mystravil/hardpoint 0.2.0 → 0.2.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +42 -38
  2. package/LICENSE +25 -25
  3. package/README.md +67 -64
  4. package/dist/base.css +625 -625
  5. package/dist/components/AppShell.svelte +698 -698
  6. package/dist/components/Button.svelte +174 -174
  7. package/dist/components/Checkbox.svelte +235 -235
  8. package/dist/components/CheckboxGroup.svelte +207 -207
  9. package/dist/components/Combobox.svelte +901 -901
  10. package/dist/components/Dialog.svelte +359 -359
  11. package/dist/components/Disclosure.svelte +201 -201
  12. package/dist/components/EmptyState.svelte +88 -88
  13. package/dist/components/ErrorState.svelte +135 -135
  14. package/dist/components/ImageViewer.svelte +764 -764
  15. package/dist/components/KeyValueList.svelte +114 -114
  16. package/dist/components/ListDetail.svelte +218 -218
  17. package/dist/components/LoadRegion.svelte +219 -219
  18. package/dist/components/MediaFrame.svelte +110 -110
  19. package/dist/components/MediaImage.svelte +256 -256
  20. package/dist/components/Menu.svelte +258 -258
  21. package/dist/components/MenuCheckboxItem.svelte +119 -119
  22. package/dist/components/MenuGroup.svelte +50 -50
  23. package/dist/components/MenuItem.svelte +94 -94
  24. package/dist/components/MenuRadioGroup.svelte +62 -62
  25. package/dist/components/MenuRadioItem.svelte +110 -110
  26. package/dist/components/MenuSeparator.svelte +28 -28
  27. package/dist/components/Meter.svelte +283 -283
  28. package/dist/components/NativeSelect.svelte +135 -135
  29. package/dist/components/Notice.svelte +262 -262
  30. package/dist/components/Popover.svelte +222 -222
  31. package/dist/components/Progress.svelte +157 -157
  32. package/dist/components/RadioGroup.svelte +440 -440
  33. package/dist/components/Select.svelte +471 -471
  34. package/dist/components/Skeleton.svelte +149 -149
  35. package/dist/components/Spinner.svelte +118 -118
  36. package/dist/components/Stat.svelte +253 -253
  37. package/dist/components/Steps.svelte +189 -189
  38. package/dist/components/Switch.svelte +222 -222
  39. package/dist/components/Table.svelte +504 -504
  40. package/dist/components/Tabs.svelte +246 -246
  41. package/dist/components/Tag.svelte +40 -40
  42. package/dist/components/TextArea.svelte +272 -272
  43. package/dist/components/TextField.svelte +256 -256
  44. package/dist/components/Timeline.svelte +156 -156
  45. package/dist/components/Toaster.svelte +411 -411
  46. package/dist/components/Tooltip.svelte +200 -200
  47. package/dist/components/TooltipGroup.svelte +46 -46
  48. package/dist/components/internal/Scrim.svelte +52 -52
  49. package/dist/components/internal/Sheet.svelte +263 -263
  50. package/dist/fonts.css +71 -71
  51. package/dist/tokens.css +283 -283
  52. package/package.json +81 -76
@@ -1,258 +1,258 @@
1
- <script lang="ts" module>
2
- import type { Snippet } from 'svelte';
3
- import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
4
-
5
- export type MenuTriggerSnippetProps = {
6
- /** Spread onto the button that opens the menu. */
7
- props: Record<string, unknown>;
8
- };
9
-
10
- /**
11
- * Attributes and handlers not listed here go to the menu element (Bits UI
12
- * `DropdownMenu.Content`), among them `side` (default `bottom`), `align`
13
- * (default `start`), `sideOffset` (default 8), `collisionPadding`
14
- * (default 8), `loop`, `onCloseAutoFocus`, `onEscapeKeydown` and
15
- * `onInteractOutside`. The placement props apply from 600px only; below it
16
- * the menu is a bottom sheet.
17
- */
18
- export type MenuProps = Omit<BitsDropdownMenu.ContentProps, 'child' | 'children' | 'forceMount' | 'ref'> & {
19
- open?: boolean;
20
- /**
21
- * The menu's accessible name, and the sheet's title below 600px. Use the
22
- * trigger's accessible name: its text, or an icon button's `aria-label`.
23
- * A fixed string the app defines, set in caps as the sheet's title, so it
24
- * never carries user data; name a row's item through the trigger's
25
- * `aria-describedby`.
26
- */
27
- label: string;
28
- /** The button the menu opens from: spread `props` onto it. */
29
- trigger: Snippet<[MenuTriggerSnippetProps]>;
30
- /** The items: MenuItem, MenuCheckboxItem, MenuRadioGroup, MenuGroup and MenuSeparator. */
31
- children: Snippet;
32
- /** The sheet's close button's accessible name (below 600px). */
33
- closeLabel?: string;
34
- /** The menu element, `role="menu"`. */
35
- ref?: HTMLElement | null;
36
- };
37
- </script>
38
-
39
- <script lang="ts">
40
- import { DropdownMenu } from 'bits-ui';
41
- import { MediaQuery } from 'svelte/reactivity';
42
- import { pop } from '../motion/index.js';
43
- import Sheet from './internal/Sheet.svelte';
44
-
45
- let {
46
- open = $bindable(false),
47
- label,
48
- trigger,
49
- children,
50
- closeLabel = 'Close',
51
- ref = $bindable(null),
52
- class: className,
53
- onInteractOutside,
54
- onCloseAutoFocus,
55
- side = 'bottom',
56
- align = 'start',
57
- sideOffset = 8,
58
- collisionPadding = 8,
59
- alignOffset,
60
- arrowPadding,
61
- avoidCollisions,
62
- collisionBoundary,
63
- sticky,
64
- hideWhenDetached,
65
- updatePositionStrategy,
66
- strategy,
67
- customAnchor,
68
- ...rest
69
- }: MenuProps = $props();
70
-
71
- // Placement belongs to the menu under the trigger; the sheet always sits
72
- // at the bottom edge, so ContentStatic never receives these.
73
- const placement = $derived({
74
- side,
75
- align,
76
- sideOffset,
77
- collisionPadding,
78
- alignOffset,
79
- arrowPadding,
80
- avoidCollisions,
81
- collisionBoundary,
82
- sticky,
83
- hideWhenDetached,
84
- updatePositionStrategy,
85
- strategy,
86
- customAnchor
87
- });
88
-
89
- // The form follows the width (BRIEF, Apps and phones: Overlays): a menu
90
- // under its trigger from 600px, the shared bottom sheet below it.
91
- const wide = new MediaQuery('min-width: 600px', true);
92
-
93
- // Bits UI moves real focus to the highlighted item, whether keys or a
94
- // pointer moved it. Only a highlight the keys moved draws the focus
95
- // contour; a pointer's draws the tint alone. The items read the contour
96
- // from --menu-contour, which .hp-menu[data-keyboard] sets.
97
- let keyboard = $state(false);
98
-
99
- let sheetNode = $state<HTMLElement | null>(null);
100
- let triggerNode = $state<HTMLElement | null>(null);
101
-
102
- function close() {
103
- open = false;
104
- }
105
-
106
- // The sheet's title row and handle sit outside the menu element; pressing
107
- // them is not an outside press.
108
- function insideSheet(e: PointerEvent) {
109
- if (sheetNode && e.target instanceof Node && sheetNode.contains(e.target)) {
110
- e.preventDefault();
111
- return;
112
- }
113
- onInteractOutside?.(e);
114
- }
115
-
116
- // Bits UI leaves focus where an outside press put it, so a click on
117
- // another control keeps it. Below 600px the only thing outside is the
118
- // scrim, and a press there is a dismiss like the close button, so focus
119
- // returns to the trigger as it does after the close button.
120
- function returnFocus(e: Event) {
121
- onCloseAutoFocus?.(e);
122
- if (e.defaultPrevented) return;
123
- e.preventDefault();
124
- triggerNode?.focus();
125
- }
126
-
127
- // Listens on the menu element without replacing Bits UI's own handlers
128
- // in `props`.
129
- function trackInput(node: HTMLElement) {
130
- const keys = () => (keyboard = true);
131
- const pointer = () => (keyboard = false);
132
- node.addEventListener('keydown', keys, true);
133
- node.addEventListener('pointerdown', pointer, true);
134
- node.addEventListener('pointermove', pointer, true);
135
- return () => {
136
- node.removeEventListener('keydown', keys, true);
137
- node.removeEventListener('pointerdown', pointer, true);
138
- node.removeEventListener('pointermove', pointer, true);
139
- };
140
- }
141
- </script>
142
-
143
- <!--
144
- Bits UI gives the trigger aria-haspopup="menu", aria-expanded and
145
- aria-controls; the menu element takes role="menu" and `label` as its
146
- name. Opened by keys, focus moves to the first item; opened by a pointer,
147
- to the menu itself. Arrow keys move the highlight and loop, letters jump
148
- by typeahead, Enter or Space runs the item. Escape, choosing an item and,
149
- below 600px, the close button, a swipe down or a press on the scrim close
150
- it and return focus to the trigger. From 600px a press outside closes it
151
- and leaves focus where the press put it; Tab closes it and moves on.
152
- -->
153
- <DropdownMenu.Root bind:open>
154
- <DropdownMenu.Trigger
155
- bind:ref={triggerNode}
156
- onkeydowncapture={() => (keyboard = true)}
157
- onpointerdowncapture={() => (keyboard = false)}
158
- >
159
- {#snippet child({ props })}
160
- {@render trigger({ props })}
161
- {/snippet}
162
- </DropdownMenu.Trigger>
163
-
164
- <DropdownMenu.Portal>
165
- {#if wide.current}
166
- <DropdownMenu.Content forceMount bind:ref {...placement} {onInteractOutside} {onCloseAutoFocus} {...rest}>
167
- {#snippet child({ wrapperProps, props, open: shown })}
168
- {#if shown}
169
- <div {...wrapperProps}>
170
- <div
171
- {...props}
172
- class={['hp-menu', className]}
173
- data-form="popover"
174
- data-keyboard={keyboard || undefined}
175
- aria-label={label}
176
- transition:pop
177
- {@attach trackInput}
178
- >
179
- {@render children()}
180
- </div>
181
- </div>
182
- {/if}
183
- {/snippet}
184
- </DropdownMenu.Content>
185
- {:else}
186
- <DropdownMenu.ContentStatic
187
- forceMount
188
- bind:ref
189
- {...rest}
190
- preventScroll
191
- onInteractOutside={insideSheet}
192
- onCloseAutoFocus={returnFocus}
193
- >
194
- {#snippet child({ props, open: shown })}
195
- <Sheet open={shown} layer="popover" title={label} {closeLabel} onclose={close} bind:ref={sheetNode}>
196
- <div
197
- {...props}
198
- class={['hp-menu', className]}
199
- data-form="sheet"
200
- data-keyboard={keyboard || undefined}
201
- aria-label={label}
202
- {@attach trackInput}
203
- >
204
- {@render children()}
205
- </div>
206
- </Sheet>
207
- {/snippet}
208
- </DropdownMenu.ContentStatic>
209
- {/if}
210
- </DropdownMenu.Portal>
211
- </DropdownMenu.Root>
212
-
213
- <style>
214
- /* The list in both forms. Items read two inherited properties:
215
- --menu-inset, the row's side padding, so item text lines up with the
216
- menu's edge here and with the sheet's title there; and --menu-contour,
217
- the outline a highlighted row draws, which only keys turn on. The menu
218
- element takes focus when a pointer opens it; the rows show where focus
219
- is, so the menu itself draws no contour. */
220
- .hp-menu {
221
- --menu-inset: var(--space-3);
222
- --menu-contour: none;
223
-
224
- box-sizing: border-box;
225
- padding-block: var(--space-1);
226
- background: var(--canvas);
227
- color: var(--text);
228
- font-family: var(--sans);
229
- outline: none;
230
- }
231
- .hp-menu[data-keyboard] {
232
- --menu-contour: 2px solid var(--focus);
233
- }
234
-
235
- /* ---- Popover (600px and up): a black panel under its trigger --------- */
236
-
237
- /* On the popover layer (tokens.css), over the shell and over an open
238
- dialog; Bits UI copies the z-index to the positioned wrapper. At least
239
- as wide as the trigger and 192px, at most 320px, and as tall as the
240
- space beside the trigger; a longer list scrolls inside. */
241
- .hp-menu[data-form='popover'] {
242
- position: relative;
243
- z-index: var(--layer-popover);
244
- width: max-content;
245
- min-width: max(var(--bits-dropdown-menu-anchor-width), 192px);
246
- max-width: min(320px, var(--bits-dropdown-menu-content-available-width));
247
- max-height: var(--bits-dropdown-menu-content-available-height);
248
- overflow-y: auto;
249
- overscroll-behavior: contain;
250
- border: 1px solid var(--border-control);
251
- }
252
-
253
- /* ---- Sheet (compact): the list is the sheet's body, which scrolls ---- */
254
-
255
- .hp-menu[data-form='sheet'] {
256
- --menu-inset: var(--gutter);
257
- }
258
- </style>
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { DropdownMenu as BitsDropdownMenu } from 'bits-ui';
4
+
5
+ export type MenuTriggerSnippetProps = {
6
+ /** Spread onto the button that opens the menu. */
7
+ props: Record<string, unknown>;
8
+ };
9
+
10
+ /**
11
+ * Attributes and handlers not listed here go to the menu element (Bits UI
12
+ * `DropdownMenu.Content`), among them `side` (default `bottom`), `align`
13
+ * (default `start`), `sideOffset` (default 8), `collisionPadding`
14
+ * (default 8), `loop`, `onCloseAutoFocus`, `onEscapeKeydown` and
15
+ * `onInteractOutside`. The placement props apply from 600px only; below it
16
+ * the menu is a bottom sheet.
17
+ */
18
+ export type MenuProps = Omit<BitsDropdownMenu.ContentProps, 'child' | 'children' | 'forceMount' | 'ref'> & {
19
+ open?: boolean;
20
+ /**
21
+ * The menu's accessible name, and the sheet's title below 600px. Use the
22
+ * trigger's accessible name: its text, or an icon button's `aria-label`.
23
+ * A fixed string the app defines, set in caps as the sheet's title, so it
24
+ * never carries user data; name a row's item through the trigger's
25
+ * `aria-describedby`.
26
+ */
27
+ label: string;
28
+ /** The button the menu opens from: spread `props` onto it. */
29
+ trigger: Snippet<[MenuTriggerSnippetProps]>;
30
+ /** The items: MenuItem, MenuCheckboxItem, MenuRadioGroup, MenuGroup and MenuSeparator. */
31
+ children: Snippet;
32
+ /** The sheet's close button's accessible name (below 600px). */
33
+ closeLabel?: string;
34
+ /** The menu element, `role="menu"`. */
35
+ ref?: HTMLElement | null;
36
+ };
37
+ </script>
38
+
39
+ <script lang="ts">
40
+ import { DropdownMenu } from 'bits-ui';
41
+ import { MediaQuery } from 'svelte/reactivity';
42
+ import { pop } from '../motion/index.js';
43
+ import Sheet from './internal/Sheet.svelte';
44
+
45
+ let {
46
+ open = $bindable(false),
47
+ label,
48
+ trigger,
49
+ children,
50
+ closeLabel = 'Close',
51
+ ref = $bindable(null),
52
+ class: className,
53
+ onInteractOutside,
54
+ onCloseAutoFocus,
55
+ side = 'bottom',
56
+ align = 'start',
57
+ sideOffset = 8,
58
+ collisionPadding = 8,
59
+ alignOffset,
60
+ arrowPadding,
61
+ avoidCollisions,
62
+ collisionBoundary,
63
+ sticky,
64
+ hideWhenDetached,
65
+ updatePositionStrategy,
66
+ strategy,
67
+ customAnchor,
68
+ ...rest
69
+ }: MenuProps = $props();
70
+
71
+ // Placement belongs to the menu under the trigger; the sheet always sits
72
+ // at the bottom edge, so ContentStatic never receives these.
73
+ const placement = $derived({
74
+ side,
75
+ align,
76
+ sideOffset,
77
+ collisionPadding,
78
+ alignOffset,
79
+ arrowPadding,
80
+ avoidCollisions,
81
+ collisionBoundary,
82
+ sticky,
83
+ hideWhenDetached,
84
+ updatePositionStrategy,
85
+ strategy,
86
+ customAnchor
87
+ });
88
+
89
+ // The form follows the width (BRIEF, Apps and phones: Overlays): a menu
90
+ // under its trigger from 600px, the shared bottom sheet below it.
91
+ const wide = new MediaQuery('min-width: 600px', true);
92
+
93
+ // Bits UI moves real focus to the highlighted item, whether keys or a
94
+ // pointer moved it. Only a highlight the keys moved draws the focus
95
+ // contour; a pointer's draws the tint alone. The items read the contour
96
+ // from --menu-contour, which .hp-menu[data-keyboard] sets.
97
+ let keyboard = $state(false);
98
+
99
+ let sheetNode = $state<HTMLElement | null>(null);
100
+ let triggerNode = $state<HTMLElement | null>(null);
101
+
102
+ function close() {
103
+ open = false;
104
+ }
105
+
106
+ // The sheet's title row and handle sit outside the menu element; pressing
107
+ // them is not an outside press.
108
+ function insideSheet(e: PointerEvent) {
109
+ if (sheetNode && e.target instanceof Node && sheetNode.contains(e.target)) {
110
+ e.preventDefault();
111
+ return;
112
+ }
113
+ onInteractOutside?.(e);
114
+ }
115
+
116
+ // Bits UI leaves focus where an outside press put it, so a click on
117
+ // another control keeps it. Below 600px the only thing outside is the
118
+ // scrim, and a press there is a dismiss like the close button, so focus
119
+ // returns to the trigger as it does after the close button.
120
+ function returnFocus(e: Event) {
121
+ onCloseAutoFocus?.(e);
122
+ if (e.defaultPrevented) return;
123
+ e.preventDefault();
124
+ triggerNode?.focus();
125
+ }
126
+
127
+ // Listens on the menu element without replacing Bits UI's own handlers
128
+ // in `props`.
129
+ function trackInput(node: HTMLElement) {
130
+ const keys = () => (keyboard = true);
131
+ const pointer = () => (keyboard = false);
132
+ node.addEventListener('keydown', keys, true);
133
+ node.addEventListener('pointerdown', pointer, true);
134
+ node.addEventListener('pointermove', pointer, true);
135
+ return () => {
136
+ node.removeEventListener('keydown', keys, true);
137
+ node.removeEventListener('pointerdown', pointer, true);
138
+ node.removeEventListener('pointermove', pointer, true);
139
+ };
140
+ }
141
+ </script>
142
+
143
+ <!--
144
+ Bits UI gives the trigger aria-haspopup="menu", aria-expanded and
145
+ aria-controls; the menu element takes role="menu" and `label` as its
146
+ name. Opened by keys, focus moves to the first item; opened by a pointer,
147
+ to the menu itself. Arrow keys move the highlight and loop, letters jump
148
+ by typeahead, Enter or Space runs the item. Escape, choosing an item and,
149
+ below 600px, the close button, a swipe down or a press on the scrim close
150
+ it and return focus to the trigger. From 600px a press outside closes it
151
+ and leaves focus where the press put it; Tab closes it and moves on.
152
+ -->
153
+ <DropdownMenu.Root bind:open>
154
+ <DropdownMenu.Trigger
155
+ bind:ref={triggerNode}
156
+ onkeydowncapture={() => (keyboard = true)}
157
+ onpointerdowncapture={() => (keyboard = false)}
158
+ >
159
+ {#snippet child({ props })}
160
+ {@render trigger({ props })}
161
+ {/snippet}
162
+ </DropdownMenu.Trigger>
163
+
164
+ <DropdownMenu.Portal>
165
+ {#if wide.current}
166
+ <DropdownMenu.Content forceMount bind:ref {...placement} {onInteractOutside} {onCloseAutoFocus} {...rest}>
167
+ {#snippet child({ wrapperProps, props, open: shown })}
168
+ {#if shown}
169
+ <div {...wrapperProps}>
170
+ <div
171
+ {...props}
172
+ class={['hp-menu', className]}
173
+ data-form="popover"
174
+ data-keyboard={keyboard || undefined}
175
+ aria-label={label}
176
+ transition:pop
177
+ {@attach trackInput}
178
+ >
179
+ {@render children()}
180
+ </div>
181
+ </div>
182
+ {/if}
183
+ {/snippet}
184
+ </DropdownMenu.Content>
185
+ {:else}
186
+ <DropdownMenu.ContentStatic
187
+ forceMount
188
+ bind:ref
189
+ {...rest}
190
+ preventScroll
191
+ onInteractOutside={insideSheet}
192
+ onCloseAutoFocus={returnFocus}
193
+ >
194
+ {#snippet child({ props, open: shown })}
195
+ <Sheet open={shown} layer="popover" title={label} {closeLabel} onclose={close} bind:ref={sheetNode}>
196
+ <div
197
+ {...props}
198
+ class={['hp-menu', className]}
199
+ data-form="sheet"
200
+ data-keyboard={keyboard || undefined}
201
+ aria-label={label}
202
+ {@attach trackInput}
203
+ >
204
+ {@render children()}
205
+ </div>
206
+ </Sheet>
207
+ {/snippet}
208
+ </DropdownMenu.ContentStatic>
209
+ {/if}
210
+ </DropdownMenu.Portal>
211
+ </DropdownMenu.Root>
212
+
213
+ <style>
214
+ /* The list in both forms. Items read two inherited properties:
215
+ --menu-inset, the row's side padding, so item text lines up with the
216
+ menu's edge here and with the sheet's title there; and --menu-contour,
217
+ the outline a highlighted row draws, which only keys turn on. The menu
218
+ element takes focus when a pointer opens it; the rows show where focus
219
+ is, so the menu itself draws no contour. */
220
+ .hp-menu {
221
+ --menu-inset: var(--space-3);
222
+ --menu-contour: none;
223
+
224
+ box-sizing: border-box;
225
+ padding-block: var(--space-1);
226
+ background: var(--canvas);
227
+ color: var(--text);
228
+ font-family: var(--sans);
229
+ outline: none;
230
+ }
231
+ .hp-menu[data-keyboard] {
232
+ --menu-contour: 2px solid var(--focus);
233
+ }
234
+
235
+ /* ---- Popover (600px and up): a black panel under its trigger --------- */
236
+
237
+ /* On the popover layer (tokens.css), over the shell and over an open
238
+ dialog; Bits UI copies the z-index to the positioned wrapper. At least
239
+ as wide as the trigger and 192px, at most 320px, and as tall as the
240
+ space beside the trigger; a longer list scrolls inside. */
241
+ .hp-menu[data-form='popover'] {
242
+ position: relative;
243
+ z-index: var(--layer-popover);
244
+ width: max-content;
245
+ min-width: max(var(--bits-dropdown-menu-anchor-width), 192px);
246
+ max-width: min(320px, var(--bits-dropdown-menu-content-available-width));
247
+ max-height: var(--bits-dropdown-menu-content-available-height);
248
+ overflow-y: auto;
249
+ overscroll-behavior: contain;
250
+ border: 1px solid var(--border-control);
251
+ }
252
+
253
+ /* ---- Sheet (compact): the list is the sheet's body, which scrolls ---- */
254
+
255
+ .hp-menu[data-form='sheet'] {
256
+ --menu-inset: var(--gutter);
257
+ }
258
+ </style>