@mystravil/hardpoint 0.2.0 → 0.3.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 (54) hide show
  1. package/CHANGELOG.md +51 -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 +221 -174
  7. package/dist/components/Button.svelte.d.ts +18 -2
  8. package/dist/components/Checkbox.svelte +235 -235
  9. package/dist/components/CheckboxGroup.svelte +207 -207
  10. package/dist/components/Combobox.svelte +901 -901
  11. package/dist/components/Dialog.svelte +359 -359
  12. package/dist/components/Disclosure.svelte +201 -201
  13. package/dist/components/EmptyState.svelte +88 -88
  14. package/dist/components/ErrorState.svelte +135 -135
  15. package/dist/components/ImageViewer.svelte +764 -764
  16. package/dist/components/KeyValueList.svelte +114 -114
  17. package/dist/components/ListDetail.svelte +218 -218
  18. package/dist/components/LoadRegion.svelte +219 -219
  19. package/dist/components/MediaFrame.svelte +110 -110
  20. package/dist/components/MediaImage.svelte +256 -256
  21. package/dist/components/Menu.svelte +275 -258
  22. package/dist/components/MenuCheckboxItem.svelte +119 -119
  23. package/dist/components/MenuGroup.svelte +50 -50
  24. package/dist/components/MenuItem.svelte +94 -94
  25. package/dist/components/MenuRadioGroup.svelte +62 -62
  26. package/dist/components/MenuRadioItem.svelte +110 -110
  27. package/dist/components/MenuSeparator.svelte +28 -28
  28. package/dist/components/Meter.svelte +283 -283
  29. package/dist/components/NativeSelect.svelte +135 -135
  30. package/dist/components/Notice.svelte +262 -262
  31. package/dist/components/Popover.svelte +222 -222
  32. package/dist/components/Progress.svelte +157 -157
  33. package/dist/components/RadioGroup.svelte +440 -440
  34. package/dist/components/Select.svelte +471 -471
  35. package/dist/components/Skeleton.svelte +149 -149
  36. package/dist/components/Spinner.svelte +118 -118
  37. package/dist/components/Stat.svelte +253 -253
  38. package/dist/components/Steps.svelte +189 -189
  39. package/dist/components/Switch.svelte +222 -222
  40. package/dist/components/Table.svelte +504 -504
  41. package/dist/components/Tabs.svelte +246 -246
  42. package/dist/components/Tag.svelte +40 -40
  43. package/dist/components/TextArea.svelte +272 -272
  44. package/dist/components/TextField.svelte +396 -256
  45. package/dist/components/TextField.svelte.d.ts +16 -1
  46. package/dist/components/Timeline.svelte +156 -156
  47. package/dist/components/Toaster.svelte +411 -411
  48. package/dist/components/Tooltip.svelte +200 -200
  49. package/dist/components/TooltipGroup.svelte +46 -46
  50. package/dist/components/internal/Scrim.svelte +52 -52
  51. package/dist/components/internal/Sheet.svelte +263 -263
  52. package/dist/fonts.css +71 -71
  53. package/dist/tokens.css +283 -283
  54. package/package.json +81 -76
@@ -1,207 +1,207 @@
1
- <script lang="ts" module>
2
- import type { Snippet } from 'svelte';
3
- import type { Checkbox as CheckboxPrimitive } from 'bits-ui';
4
-
5
- export type CheckboxGroupItem = {
6
- value: string;
7
- /** The text beside the box, as written. */
8
- label: string;
9
- /** A second line in `--muted` under the label. */
10
- hint?: string;
11
- /** A Tag after the label, such as "Recommended": a short fixed string, set in caps. */
12
- tag?: string;
13
- disabled?: boolean;
14
- };
15
-
16
- /** The group's name: a fixed caps `label`, or a `legend` set as written. Exactly one. */
17
- type CheckboxGroupName =
18
- | {
19
- /** The caps label that names the group: a fixed string the app defines. */
20
- label: string;
21
- legend?: never;
22
- }
23
- | {
24
- label?: never;
25
- /**
26
- * The group's name as content, set as written in 16px at weight 500:
27
- * a question, or a name with a counter before it.
28
- */
29
- legend: Snippet;
30
- };
31
-
32
- /** Attributes and handlers not listed here go to the group element. */
33
- export type CheckboxGroupProps = Omit<CheckboxPrimitive.GroupProps, 'child' | 'children' | 'ref'> &
34
- CheckboxGroupName & {
35
- /** A line in `--muted` under the name, read out as the group's description. */
36
- hint?: string;
37
- /**
38
- * The error to show under the boxes, with an icon, linked by
39
- * `aria-describedby`; it sets `aria-invalid` on the group. Say how to
40
- * fix the problem. The app validates; the group shows what it is given.
41
- */
42
- error?: string;
43
- /** The choices. Without it, pass `Checkbox` components with a `value` as children. */
44
- items?: CheckboxGroupItem[];
45
- children?: Snippet;
46
- /** The group element. */
47
- ref?: HTMLElement | null;
48
- };
49
- </script>
50
-
51
- <script lang="ts">
52
- import { untrack } from 'svelte';
53
- import { Checkbox as BitsCheckbox } from 'bits-ui';
54
- import Checkbox from './Checkbox.svelte';
55
- import { fadeIn } from './internal/fade-in.js';
56
-
57
- const uid = $props.id();
58
-
59
- let {
60
- value = $bindable([]),
61
- label,
62
- legend,
63
- hint,
64
- error,
65
- items,
66
- id = uid,
67
- ref = $bindable(null),
68
- class: className,
69
- 'aria-describedby': describedBy,
70
- 'aria-invalid': ariaInvalid,
71
- children,
72
- ...rest
73
- }: CheckboxGroupProps = $props();
74
-
75
- const hintId = $derived(`${id}-hint`);
76
- const errorId = $derived(`${id}-error`);
77
- // The error first, so a screen reader reads it before the hint.
78
- const describedByIds = $derived(
79
- [error ? errorId : undefined, hint ? hintId : undefined, describedBy].filter(Boolean).join(' ') ||
80
- undefined
81
- );
82
-
83
- // ---- Short motion: the error (BRIEF, --dur-message) ---------------------
84
-
85
- // As in TextField: an error that appears after the first render fades in
86
- // from 0 over --dur-message; one that clears goes at once; a group that
87
- // renders with an error shows it at once.
88
- let errorShown = untrack(() => !!error);
89
- $effect(() => {
90
- const shown = !!error;
91
- untrack(() => {
92
- const appeared = shown && !errorShown;
93
- errorShown = shown;
94
- const message = appeared ? ref?.querySelector(':scope > .error') : null;
95
- if (message) fadeIn(message, '--dur-message');
96
- });
97
- });
98
- </script>
99
-
100
- <!--
101
- Several independent choices under one name: a Bits UI Checkbox.Group, a
102
- role="group" element named by its caps `label` or its `legend`.
103
- `bind:value` holds the values of the checked boxes. `disabled`,
104
- `required`, `readonly` and `name` apply to every box. Attributes, handlers
105
- and `class` go to the group element.
106
- -->
107
- <BitsCheckbox.Group
108
- bind:value
109
- bind:ref
110
- {id}
111
- aria-describedby={describedByIds}
112
- aria-invalid={error ? true : ariaInvalid}
113
- {...rest}
114
- >
115
- {#snippet child({ props })}
116
- <div {...props} class={['hp-checkbox-group', className]} data-invalid={error ? '' : undefined}>
117
- <BitsCheckbox.GroupLabel>
118
- {#snippet child({ props: labelProps })}
119
- {#if legend}
120
- <div {...labelProps} class="legend">{@render legend()}</div>
121
- {:else}
122
- <span {...labelProps} class="hp-label group-label">{label}</span>
123
- {/if}
124
- {/snippet}
125
- </BitsCheckbox.GroupLabel>
126
- {#if hint}
127
- <p class="hint hp-caption" id={hintId}>{hint}</p>
128
- {/if}
129
- <div class="items">
130
- {#if items}
131
- {#each items as item (item.value)}
132
- <Checkbox
133
- value={item.value}
134
- label={item.label}
135
- tag={item.tag}
136
- hint={item.hint}
137
- disabled={item.disabled}
138
- />
139
- {/each}
140
- {:else}
141
- {@render children?.()}
142
- {/if}
143
- </div>
144
- {#if error}
145
- <p class="error hp-caption" id={errorId}>
146
- <span class="icon" aria-hidden="true">
147
- <svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor">
148
- <path d="M1.5 1.5h13v13h-13z" />
149
- <path d="M8 4v4M8 10v2" stroke-width="2" />
150
- </svg>
151
- </span>
152
- <span>{error}</span>
153
- </p>
154
- {/if}
155
- </div>
156
- {/snippet}
157
- </BitsCheckbox.Group>
158
-
159
- <style>
160
- /* The name, its hint, then the boxes, 8px apart so neighbouring targets
161
- never touch, then the error. Rows keep their own height when a layout
162
- makes the group taller. */
163
- .hp-checkbox-group {
164
- display: grid;
165
- align-content: start;
166
- gap: var(--space-1);
167
- min-width: 0;
168
- }
169
- .group-label,
170
- .hint {
171
- color: var(--muted);
172
- }
173
- /* A name set as written: a question, or a name with a counter. */
174
- .legend {
175
- font-size: var(--type-body);
176
- font-weight: 500;
177
- line-height: 24px;
178
- }
179
- [data-disabled] > .legend {
180
- color: var(--muted);
181
- }
182
- .items {
183
- display: grid;
184
- gap: var(--space-2);
185
- }
186
-
187
- /* ---- The error: TextField's ------------------------------------------- */
188
-
189
- /* It starts 8px under the last box's row, clear of its focus contour. */
190
- .error {
191
- display: flex;
192
- gap: var(--space-2);
193
- margin-top: var(--space-1);
194
- color: var(--danger);
195
- }
196
- /* One line box high, so the icon centres on the first line of the
197
- message however it wraps. */
198
- .icon {
199
- display: flex;
200
- flex: none;
201
- align-items: center;
202
- height: 1lh;
203
- }
204
- .icon svg {
205
- display: block;
206
- }
207
- </style>
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { Checkbox as CheckboxPrimitive } from 'bits-ui';
4
+
5
+ export type CheckboxGroupItem = {
6
+ value: string;
7
+ /** The text beside the box, as written. */
8
+ label: string;
9
+ /** A second line in `--muted` under the label. */
10
+ hint?: string;
11
+ /** A Tag after the label, such as "Recommended": a short fixed string, set in caps. */
12
+ tag?: string;
13
+ disabled?: boolean;
14
+ };
15
+
16
+ /** The group's name: a fixed caps `label`, or a `legend` set as written. Exactly one. */
17
+ type CheckboxGroupName =
18
+ | {
19
+ /** The caps label that names the group: a fixed string the app defines. */
20
+ label: string;
21
+ legend?: never;
22
+ }
23
+ | {
24
+ label?: never;
25
+ /**
26
+ * The group's name as content, set as written in 16px at weight 500:
27
+ * a question, or a name with a counter before it.
28
+ */
29
+ legend: Snippet;
30
+ };
31
+
32
+ /** Attributes and handlers not listed here go to the group element. */
33
+ export type CheckboxGroupProps = Omit<CheckboxPrimitive.GroupProps, 'child' | 'children' | 'ref'> &
34
+ CheckboxGroupName & {
35
+ /** A line in `--muted` under the name, read out as the group's description. */
36
+ hint?: string;
37
+ /**
38
+ * The error to show under the boxes, with an icon, linked by
39
+ * `aria-describedby`; it sets `aria-invalid` on the group. Say how to
40
+ * fix the problem. The app validates; the group shows what it is given.
41
+ */
42
+ error?: string;
43
+ /** The choices. Without it, pass `Checkbox` components with a `value` as children. */
44
+ items?: CheckboxGroupItem[];
45
+ children?: Snippet;
46
+ /** The group element. */
47
+ ref?: HTMLElement | null;
48
+ };
49
+ </script>
50
+
51
+ <script lang="ts">
52
+ import { untrack } from 'svelte';
53
+ import { Checkbox as BitsCheckbox } from 'bits-ui';
54
+ import Checkbox from './Checkbox.svelte';
55
+ import { fadeIn } from './internal/fade-in.js';
56
+
57
+ const uid = $props.id();
58
+
59
+ let {
60
+ value = $bindable([]),
61
+ label,
62
+ legend,
63
+ hint,
64
+ error,
65
+ items,
66
+ id = uid,
67
+ ref = $bindable(null),
68
+ class: className,
69
+ 'aria-describedby': describedBy,
70
+ 'aria-invalid': ariaInvalid,
71
+ children,
72
+ ...rest
73
+ }: CheckboxGroupProps = $props();
74
+
75
+ const hintId = $derived(`${id}-hint`);
76
+ const errorId = $derived(`${id}-error`);
77
+ // The error first, so a screen reader reads it before the hint.
78
+ const describedByIds = $derived(
79
+ [error ? errorId : undefined, hint ? hintId : undefined, describedBy].filter(Boolean).join(' ') ||
80
+ undefined
81
+ );
82
+
83
+ // ---- Short motion: the error (BRIEF, --dur-message) ---------------------
84
+
85
+ // As in TextField: an error that appears after the first render fades in
86
+ // from 0 over --dur-message; one that clears goes at once; a group that
87
+ // renders with an error shows it at once.
88
+ let errorShown = untrack(() => !!error);
89
+ $effect(() => {
90
+ const shown = !!error;
91
+ untrack(() => {
92
+ const appeared = shown && !errorShown;
93
+ errorShown = shown;
94
+ const message = appeared ? ref?.querySelector(':scope > .error') : null;
95
+ if (message) fadeIn(message, '--dur-message');
96
+ });
97
+ });
98
+ </script>
99
+
100
+ <!--
101
+ Several independent choices under one name: a Bits UI Checkbox.Group, a
102
+ role="group" element named by its caps `label` or its `legend`.
103
+ `bind:value` holds the values of the checked boxes. `disabled`,
104
+ `required`, `readonly` and `name` apply to every box. Attributes, handlers
105
+ and `class` go to the group element.
106
+ -->
107
+ <BitsCheckbox.Group
108
+ bind:value
109
+ bind:ref
110
+ {id}
111
+ aria-describedby={describedByIds}
112
+ aria-invalid={error ? true : ariaInvalid}
113
+ {...rest}
114
+ >
115
+ {#snippet child({ props })}
116
+ <div {...props} class={['hp-checkbox-group', className]} data-invalid={error ? '' : undefined}>
117
+ <BitsCheckbox.GroupLabel>
118
+ {#snippet child({ props: labelProps })}
119
+ {#if legend}
120
+ <div {...labelProps} class="legend">{@render legend()}</div>
121
+ {:else}
122
+ <span {...labelProps} class="hp-label group-label">{label}</span>
123
+ {/if}
124
+ {/snippet}
125
+ </BitsCheckbox.GroupLabel>
126
+ {#if hint}
127
+ <p class="hint hp-caption" id={hintId}>{hint}</p>
128
+ {/if}
129
+ <div class="items">
130
+ {#if items}
131
+ {#each items as item (item.value)}
132
+ <Checkbox
133
+ value={item.value}
134
+ label={item.label}
135
+ tag={item.tag}
136
+ hint={item.hint}
137
+ disabled={item.disabled}
138
+ />
139
+ {/each}
140
+ {:else}
141
+ {@render children?.()}
142
+ {/if}
143
+ </div>
144
+ {#if error}
145
+ <p class="error hp-caption" id={errorId}>
146
+ <span class="icon" aria-hidden="true">
147
+ <svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor">
148
+ <path d="M1.5 1.5h13v13h-13z" />
149
+ <path d="M8 4v4M8 10v2" stroke-width="2" />
150
+ </svg>
151
+ </span>
152
+ <span>{error}</span>
153
+ </p>
154
+ {/if}
155
+ </div>
156
+ {/snippet}
157
+ </BitsCheckbox.Group>
158
+
159
+ <style>
160
+ /* The name, its hint, then the boxes, 8px apart so neighbouring targets
161
+ never touch, then the error. Rows keep their own height when a layout
162
+ makes the group taller. */
163
+ .hp-checkbox-group {
164
+ display: grid;
165
+ align-content: start;
166
+ gap: var(--space-1);
167
+ min-width: 0;
168
+ }
169
+ .group-label,
170
+ .hint {
171
+ color: var(--muted);
172
+ }
173
+ /* A name set as written: a question, or a name with a counter. */
174
+ .legend {
175
+ font-size: var(--type-body);
176
+ font-weight: 500;
177
+ line-height: 24px;
178
+ }
179
+ [data-disabled] > .legend {
180
+ color: var(--muted);
181
+ }
182
+ .items {
183
+ display: grid;
184
+ gap: var(--space-2);
185
+ }
186
+
187
+ /* ---- The error: TextField's ------------------------------------------- */
188
+
189
+ /* It starts 8px under the last box's row, clear of its focus contour. */
190
+ .error {
191
+ display: flex;
192
+ gap: var(--space-2);
193
+ margin-top: var(--space-1);
194
+ color: var(--danger);
195
+ }
196
+ /* One line box high, so the icon centres on the first line of the
197
+ message however it wraps. */
198
+ .icon {
199
+ display: flex;
200
+ flex: none;
201
+ align-items: center;
202
+ height: 1lh;
203
+ }
204
+ .icon svg {
205
+ display: block;
206
+ }
207
+ </style>