@mystravil/hardpoint 0.1.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 (67) hide show
  1. package/CHANGELOG.md +42 -18
  2. package/LICENSE +25 -25
  3. package/README.md +67 -64
  4. package/dist/base.css +625 -346
  5. package/dist/components/AppShell.svelte +698 -698
  6. package/dist/components/Button.svelte +174 -174
  7. package/dist/components/Checkbox.svelte +235 -198
  8. package/dist/components/Checkbox.svelte.d.ts +9 -2
  9. package/dist/components/CheckboxGroup.svelte +207 -99
  10. package/dist/components/CheckboxGroup.svelte.d.ts +23 -4
  11. package/dist/components/Combobox.svelte +901 -824
  12. package/dist/components/Combobox.svelte.d.ts +10 -1
  13. package/dist/components/Dialog.svelte +359 -356
  14. package/dist/components/Disclosure.svelte +201 -201
  15. package/dist/components/EmptyState.svelte +88 -88
  16. package/dist/components/ErrorState.svelte +135 -135
  17. package/dist/components/ImageViewer.svelte +764 -0
  18. package/dist/components/ImageViewer.svelte.d.ts +55 -0
  19. package/dist/components/KeyValueList.svelte +114 -114
  20. package/dist/components/ListDetail.svelte +218 -0
  21. package/dist/components/ListDetail.svelte.d.ts +37 -0
  22. package/dist/components/LoadRegion.svelte +219 -219
  23. package/dist/components/MediaFrame.svelte +110 -110
  24. package/dist/components/MediaImage.svelte +256 -256
  25. package/dist/components/Menu.svelte +258 -258
  26. package/dist/components/MenuCheckboxItem.svelte +119 -119
  27. package/dist/components/MenuGroup.svelte +50 -50
  28. package/dist/components/MenuItem.svelte +94 -94
  29. package/dist/components/MenuRadioGroup.svelte +62 -62
  30. package/dist/components/MenuRadioItem.svelte +110 -110
  31. package/dist/components/MenuSeparator.svelte +28 -28
  32. package/dist/components/Meter.svelte +283 -0
  33. package/dist/components/Meter.svelte.d.ts +66 -0
  34. package/dist/components/NativeSelect.svelte +18 -2
  35. package/dist/components/NativeSelect.svelte.d.ts +6 -0
  36. package/dist/components/Notice.svelte +262 -0
  37. package/dist/components/Notice.svelte.d.ts +30 -0
  38. package/dist/components/Popover.svelte +222 -222
  39. package/dist/components/Progress.svelte +157 -157
  40. package/dist/components/RadioGroup.svelte +440 -0
  41. package/dist/components/RadioGroup.svelte.d.ts +50 -0
  42. package/dist/components/Select.svelte +471 -405
  43. package/dist/components/Select.svelte.d.ts +6 -0
  44. package/dist/components/Skeleton.svelte +149 -149
  45. package/dist/components/Spinner.svelte +118 -117
  46. package/dist/components/Stat.svelte +253 -253
  47. package/dist/components/Steps.svelte +189 -189
  48. package/dist/components/Switch.svelte +222 -222
  49. package/dist/components/Table.svelte +504 -504
  50. package/dist/components/Tabs.svelte +246 -246
  51. package/dist/components/Tag.svelte +40 -40
  52. package/dist/components/TextArea.svelte +272 -0
  53. package/dist/components/TextArea.svelte.d.ts +28 -0
  54. package/dist/components/TextField.svelte +256 -256
  55. package/dist/components/Timeline.svelte +156 -156
  56. package/dist/components/Toaster.svelte +411 -411
  57. package/dist/components/Tooltip.svelte +200 -200
  58. package/dist/components/TooltipGroup.svelte +46 -46
  59. package/dist/components/internal/Scrim.svelte +52 -52
  60. package/dist/components/internal/Sheet.svelte +263 -263
  61. package/dist/components/internal/groups.d.ts +14 -0
  62. package/dist/components/internal/groups.js +23 -0
  63. package/dist/fonts.css +71 -71
  64. package/dist/index.d.ts +6 -0
  65. package/dist/index.js +6 -0
  66. package/dist/tokens.css +283 -279
  67. package/package.json +81 -76
@@ -1,99 +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
- disabled?: boolean;
12
- };
13
-
14
- /** Attributes and handlers not listed here go to the group element. */
15
- export type CheckboxGroupProps = Omit<CheckboxPrimitive.GroupProps, 'child' | 'children' | 'ref'> & {
16
- /** The caps label that names the group. */
17
- label: string;
18
- /** A line in `--muted` under the label, read out as the group's description. */
19
- hint?: string;
20
- /** The choices. Without it, pass `Checkbox` components with a `value` as children. */
21
- items?: CheckboxGroupItem[];
22
- children?: Snippet;
23
- /** The group element. */
24
- ref?: HTMLElement | null;
25
- };
26
- </script>
27
-
28
- <script lang="ts">
29
- import { Checkbox as BitsCheckbox } from 'bits-ui';
30
- import Checkbox from './Checkbox.svelte';
31
-
32
- const uid = $props.id();
33
-
34
- let {
35
- value = $bindable([]),
36
- label,
37
- hint,
38
- items,
39
- id = uid,
40
- ref = $bindable(null),
41
- class: className,
42
- 'aria-describedby': describedBy,
43
- children,
44
- ...rest
45
- }: CheckboxGroupProps = $props();
46
-
47
- const hintId = $derived(`${id}-hint`);
48
- const describedByIds = $derived([hint ? hintId : null, describedBy].filter(Boolean).join(' ') || undefined);
49
- </script>
50
-
51
- <!--
52
- Several independent choices under one caps label: a Bits UI Checkbox.Group,
53
- a role="group" element named by the label. `bind:value` holds the values of
54
- the checked boxes. `disabled`, `required`, `readonly` and `name` apply to
55
- every box. Attributes, handlers and `class` go to the group element.
56
- -->
57
- <BitsCheckbox.Group bind:value bind:ref {id} aria-describedby={describedByIds} {...rest}>
58
- {#snippet child({ props })}
59
- <div {...props} class={['hp-checkbox-group', className]}>
60
- <BitsCheckbox.GroupLabel>
61
- {#snippet child({ props: labelProps })}
62
- <span {...labelProps} class="hp-label group-label">{label}</span>
63
- {/snippet}
64
- </BitsCheckbox.GroupLabel>
65
- {#if hint}
66
- <p class="hint hp-caption" id={hintId}>{hint}</p>
67
- {/if}
68
- <div class="items">
69
- {#if items}
70
- {#each items as item (item.value)}
71
- <Checkbox value={item.value} label={item.label} hint={item.hint} disabled={item.disabled} />
72
- {/each}
73
- {:else}
74
- {@render children?.()}
75
- {/if}
76
- </div>
77
- </div>
78
- {/snippet}
79
- </BitsCheckbox.Group>
80
-
81
- <style>
82
- /* The caps label, its hint, then the boxes, 8px apart so neighbouring
83
- targets never touch. Rows keep their own height when a layout makes
84
- the group taller. */
85
- .hp-checkbox-group {
86
- display: grid;
87
- align-content: start;
88
- gap: var(--space-1);
89
- min-width: 0;
90
- }
91
- .group-label,
92
- .hint {
93
- color: var(--muted);
94
- }
95
- .items {
96
- display: grid;
97
- gap: var(--space-2);
98
- }
99
- </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>
@@ -6,14 +6,33 @@ export type CheckboxGroupItem = {
6
6
  label: string;
7
7
  /** A second line in `--muted` under the label. */
8
8
  hint?: string;
9
+ /** A Tag after the label, such as "Recommended": a short fixed string, set in caps. */
10
+ tag?: string;
9
11
  disabled?: boolean;
10
12
  };
11
- /** Attributes and handlers not listed here go to the group element. */
12
- export type CheckboxGroupProps = Omit<CheckboxPrimitive.GroupProps, 'child' | 'children' | 'ref'> & {
13
- /** The caps label that names the group. */
13
+ /** The group's name: a fixed caps `label`, or a `legend` set as written. Exactly one. */
14
+ type CheckboxGroupName = {
15
+ /** The caps label that names the group: a fixed string the app defines. */
14
16
  label: string;
15
- /** A line in `--muted` under the label, read out as the group's description. */
17
+ legend?: never;
18
+ } | {
19
+ label?: never;
20
+ /**
21
+ * The group's name as content, set as written in 16px at weight 500:
22
+ * a question, or a name with a counter before it.
23
+ */
24
+ legend: Snippet;
25
+ };
26
+ /** Attributes and handlers not listed here go to the group element. */
27
+ export type CheckboxGroupProps = Omit<CheckboxPrimitive.GroupProps, 'child' | 'children' | 'ref'> & CheckboxGroupName & {
28
+ /** A line in `--muted` under the name, read out as the group's description. */
16
29
  hint?: string;
30
+ /**
31
+ * The error to show under the boxes, with an icon, linked by
32
+ * `aria-describedby`; it sets `aria-invalid` on the group. Say how to
33
+ * fix the problem. The app validates; the group shows what it is given.
34
+ */
35
+ error?: string;
17
36
  /** The choices. Without it, pass `Checkbox` components with a `value` as children. */
18
37
  items?: CheckboxGroupItem[];
19
38
  children?: Snippet;