@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,262 +1,262 @@
1
- <script lang="ts" module>
2
- import type { Snippet } from 'svelte';
3
- import type { HTMLAttributes } from 'svelte/elements';
4
-
5
- /** `ok`, `warn` or `danger`; absent means neutral information. The tone sets the mark's glyph and colour, never the text's. */
6
- export type NoticeTone = 'ok' | 'warn' | 'danger';
7
-
8
- /** The title's element: `p` by default, a heading where the notice names a region of the page. */
9
- export type NoticeTitleElement = 'p' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
10
-
11
- export type NoticeProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'> & {
12
- tone?: NoticeTone;
13
- /** A short line, as written, never transformed. A notice has a title, text, or both. */
14
- title?: string;
15
- /** The title's element. Defaults to `p`. */
16
- titleAs?: NoticeTitleElement;
17
- /** The text, in the muted ink. It may hold links and inline code. */
18
- children?: Snippet;
19
- /**
20
- * The app's `Button`s: at most two, the primary one last, and at most one
21
- * primary. A notice in a view that already shows its solid group uses
22
- * secondary or tertiary buttons.
23
- */
24
- actions?: Snippet;
25
- /** Adds a close button that calls this. The app removes the notice. */
26
- onclose?: () => void;
27
- /** The close button's accessible name. Defaults to `Dismiss`. */
28
- closeLabel?: string;
29
- /** The root `div`. */
30
- ref?: HTMLDivElement | null;
31
- };
32
- </script>
33
-
34
- <script lang="ts">
35
- import Button from './Button.svelte';
36
-
37
- let {
38
- tone,
39
- title,
40
- titleAs = 'p',
41
- children,
42
- actions,
43
- onclose,
44
- closeLabel = 'Dismiss',
45
- ref = $bindable(null),
46
- class: className,
47
- ...rest
48
- }: NoticeProps = $props();
49
- </script>
50
-
51
- <!--
52
- A persistent message in the page flow: something the user should know or
53
- act on, which stays until the app removes it (the app renders it while
54
- it applies and gives it `onclose` when the user may dismiss it). A
55
- confirmation is a Toast and a failed view is an ErrorState.
56
-
57
- The Toaster's box in the flow: black, the control boundary, square, as
58
- wide as its container. A 16px outlined square before the first line
59
- carries the tone: "i" (neutral, muted), a check (ok), "!" (warn, danger).
60
- It is decorative, so the words carry the status. The title is 16px
61
- weight 500 in the text ink, never caps; the text below it is muted, 16px
62
- on touch and 14px with a mouse. The actions sit 12px under the text. A
63
- notice with a title and actions but no text puts the actions at the end
64
- of the title row, and wraps them under it when they do not fit. The close
65
- button is at the top end.
66
-
67
- It is not a live region. Pass `role="status"` for a notice that appears
68
- while the user is on the page, `role="alert"` for an urgent one and
69
- `role="note"` for supplementary content present from the start. It has
70
- no motion: it appears and goes at once. Extra attributes and `class` go
71
- to the root `div.hp-notice`.
72
- -->
73
- <div
74
- bind:this={ref}
75
- {...rest}
76
- class={['hp-notice', className]}
77
- data-tone={tone}
78
- data-titled={title ? '' : undefined}
79
- data-row={title && !children && actions ? '' : undefined}
80
- >
81
- <span class="hp-notice-mark" aria-hidden="true">
82
- <svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor">
83
- <path d="M1.5 1.5h13v13h-13z" />
84
- {#if tone === 'ok'}
85
- <path d="M4.5 8.2l2.7 2.7 4.3-5" stroke-width="2" />
86
- {:else if tone}
87
- <path d="M8 4v4M8 10v2" stroke-width="2" />
88
- {:else}
89
- <path d="M8 4v2M8 8v4" stroke-width="2" />
90
- {/if}
91
- </svg>
92
- </span>
93
- <div class="hp-notice-main">
94
- {#if title || children}
95
- <div class="hp-notice-content">
96
- {#if title}
97
- <svelte:element this={titleAs} class="hp-notice-title">{title}</svelte:element>
98
- {/if}
99
- {#if children}
100
- <div class="hp-notice-body">{@render children()}</div>
101
- {/if}
102
- </div>
103
- {/if}
104
- {#if actions}
105
- <div class="hp-notice-actions" data-after={children ? '' : undefined}>{@render actions()}</div>
106
- {/if}
107
- </div>
108
- {#if onclose}
109
- <Button
110
- type="button"
111
- variant="tertiary"
112
- icon
113
- class="hp-notice-close"
114
- aria-label={closeLabel}
115
- onclick={() => onclose()}
116
- >
117
- <svg
118
- viewBox="0 0 16 16"
119
- fill="none"
120
- stroke="currentColor"
121
- stroke-width="1.5"
122
- stroke-linecap="square"
123
- aria-hidden="true"
124
- >
125
- <path d="M3 3l10 10M13 3L3 13" />
126
- </svg>
127
- </Button>
128
- {/if}
129
- </div>
130
-
131
- <style>
132
- /* The Toaster's box in the flow: black, the control boundary, square.
133
- --notice-line is the first line's height (the title's 24px, or the
134
- text's line when there is no title); --notice-lift is how far a
135
- control is taller than that line, halved. */
136
- .hp-notice {
137
- --notice-line: 24px;
138
- --notice-text-line: 24px;
139
- --notice-lift: calc((var(--control-height) - var(--notice-line)) / 2);
140
-
141
- display: flex;
142
- align-items: flex-start;
143
- gap: var(--space-2);
144
- box-sizing: border-box;
145
- min-width: 0;
146
- padding: var(--space-3);
147
- border: 1px solid var(--border-control);
148
- background: var(--canvas);
149
- color: var(--text);
150
- font-family: var(--sans);
151
- font-size: var(--type-body);
152
- line-height: var(--notice-text-line);
153
- }
154
-
155
- /* 16px where a coarse pointer reads it, the dense 14px on fine pointers. */
156
- @media (pointer: fine) {
157
- .hp-notice {
158
- --notice-text-line: 20px;
159
-
160
- font-size: var(--type-dense);
161
- }
162
- }
163
-
164
- .hp-notice:not([data-titled]) {
165
- --notice-line: var(--notice-text-line);
166
- }
167
-
168
- /* ---- The mark: an outlined square on the first line --------------- */
169
-
170
- .hp-notice-mark {
171
- display: flex;
172
- flex: none;
173
- align-items: center;
174
- height: var(--notice-line);
175
- color: var(--muted);
176
- }
177
- .hp-notice-mark svg {
178
- display: block;
179
- }
180
- .hp-notice[data-tone='ok'] .hp-notice-mark {
181
- color: var(--ok);
182
- }
183
- .hp-notice[data-tone='warn'] .hp-notice-mark {
184
- color: var(--warn);
185
- }
186
- .hp-notice[data-tone='danger'] .hp-notice-mark {
187
- color: var(--danger);
188
- }
189
-
190
- /* ---- Title, text and actions -------------------------------------- */
191
-
192
- /* Wraps the actions under the content when they do not fit beside it. */
193
- .hp-notice-main {
194
- display: flex;
195
- flex: 1 1 auto;
196
- flex-wrap: wrap;
197
- align-items: flex-start;
198
- gap: var(--space-3) var(--space-4);
199
- min-width: 0;
200
- }
201
-
202
- .hp-notice-content {
203
- display: grid;
204
- flex: 1 1 auto;
205
- gap: var(--space-1);
206
- min-width: 0;
207
- }
208
-
209
- .hp-notice-title {
210
- max-width: 100%;
211
- color: var(--text);
212
- font-size: var(--type-body);
213
- font-weight: 500;
214
- line-height: 24px;
215
- overflow-wrap: anywhere;
216
- }
217
-
218
- .hp-notice-body {
219
- max-width: var(--measure);
220
- color: var(--muted);
221
- overflow-wrap: anywhere;
222
- }
223
- .hp-notice-body :global(a) {
224
- color: var(--text);
225
- }
226
- .hp-notice-body :global(p + p) {
227
- margin-top: var(--space-2);
228
- }
229
-
230
- .hp-notice-actions {
231
- display: flex;
232
- flex: none;
233
- flex-wrap: wrap;
234
- gap: var(--space-2);
235
- max-width: 100%;
236
- }
237
- /* Text above them: they take their own row. */
238
- .hp-notice-actions[data-after] {
239
- flex-basis: 100%;
240
- }
241
-
242
- /* ---- The close button: the Toaster's, at the top end -------------- */
243
-
244
- /* Centred on the first line; the tertiary button has no edge, so it
245
- reaches into the padding. */
246
- .hp-notice :global(.hp-notice-close) {
247
- flex: none;
248
- margin: calc(-1 * var(--notice-lift)) calc(-1 * var(--space-2)) 0 0;
249
- }
250
-
251
- /* A title row with actions is a control high, so the mark, the title and
252
- the close button centre on it. */
253
- .hp-notice[data-row] .hp-notice-mark {
254
- margin-top: var(--notice-lift);
255
- }
256
- .hp-notice[data-row] .hp-notice-content {
257
- padding-top: var(--notice-lift);
258
- }
259
- .hp-notice[data-row] :global(.hp-notice-close) {
260
- margin-top: 0;
261
- }
262
- </style>
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+
5
+ /** `ok`, `warn` or `danger`; absent means neutral information. The tone sets the mark's glyph and colour, never the text's. */
6
+ export type NoticeTone = 'ok' | 'warn' | 'danger';
7
+
8
+ /** The title's element: `p` by default, a heading where the notice names a region of the page. */
9
+ export type NoticeTitleElement = 'p' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
10
+
11
+ export type NoticeProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'title'> & {
12
+ tone?: NoticeTone;
13
+ /** A short line, as written, never transformed. A notice has a title, text, or both. */
14
+ title?: string;
15
+ /** The title's element. Defaults to `p`. */
16
+ titleAs?: NoticeTitleElement;
17
+ /** The text, in the muted ink. It may hold links and inline code. */
18
+ children?: Snippet;
19
+ /**
20
+ * The app's `Button`s: at most two, the primary one last, and at most one
21
+ * primary. A notice in a view that already shows its solid group uses
22
+ * secondary or tertiary buttons.
23
+ */
24
+ actions?: Snippet;
25
+ /** Adds a close button that calls this. The app removes the notice. */
26
+ onclose?: () => void;
27
+ /** The close button's accessible name. Defaults to `Dismiss`. */
28
+ closeLabel?: string;
29
+ /** The root `div`. */
30
+ ref?: HTMLDivElement | null;
31
+ };
32
+ </script>
33
+
34
+ <script lang="ts">
35
+ import Button from './Button.svelte';
36
+
37
+ let {
38
+ tone,
39
+ title,
40
+ titleAs = 'p',
41
+ children,
42
+ actions,
43
+ onclose,
44
+ closeLabel = 'Dismiss',
45
+ ref = $bindable(null),
46
+ class: className,
47
+ ...rest
48
+ }: NoticeProps = $props();
49
+ </script>
50
+
51
+ <!--
52
+ A persistent message in the page flow: something the user should know or
53
+ act on, which stays until the app removes it (the app renders it while
54
+ it applies and gives it `onclose` when the user may dismiss it). A
55
+ confirmation is a Toast and a failed view is an ErrorState.
56
+
57
+ The Toaster's box in the flow: black, the control boundary, square, as
58
+ wide as its container. A 16px outlined square before the first line
59
+ carries the tone: "i" (neutral, muted), a check (ok), "!" (warn, danger).
60
+ It is decorative, so the words carry the status. The title is 16px
61
+ weight 500 in the text ink, never caps; the text below it is muted, 16px
62
+ on touch and 14px with a mouse. The actions sit 12px under the text. A
63
+ notice with a title and actions but no text puts the actions at the end
64
+ of the title row, and wraps them under it when they do not fit. The close
65
+ button is at the top end.
66
+
67
+ It is not a live region. Pass `role="status"` for a notice that appears
68
+ while the user is on the page, `role="alert"` for an urgent one and
69
+ `role="note"` for supplementary content present from the start. It has
70
+ no motion: it appears and goes at once. Extra attributes and `class` go
71
+ to the root `div.hp-notice`.
72
+ -->
73
+ <div
74
+ bind:this={ref}
75
+ {...rest}
76
+ class={['hp-notice', className]}
77
+ data-tone={tone}
78
+ data-titled={title ? '' : undefined}
79
+ data-row={title && !children && actions ? '' : undefined}
80
+ >
81
+ <span class="hp-notice-mark" aria-hidden="true">
82
+ <svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor">
83
+ <path d="M1.5 1.5h13v13h-13z" />
84
+ {#if tone === 'ok'}
85
+ <path d="M4.5 8.2l2.7 2.7 4.3-5" stroke-width="2" />
86
+ {:else if tone}
87
+ <path d="M8 4v4M8 10v2" stroke-width="2" />
88
+ {:else}
89
+ <path d="M8 4v2M8 8v4" stroke-width="2" />
90
+ {/if}
91
+ </svg>
92
+ </span>
93
+ <div class="hp-notice-main">
94
+ {#if title || children}
95
+ <div class="hp-notice-content">
96
+ {#if title}
97
+ <svelte:element this={titleAs} class="hp-notice-title">{title}</svelte:element>
98
+ {/if}
99
+ {#if children}
100
+ <div class="hp-notice-body">{@render children()}</div>
101
+ {/if}
102
+ </div>
103
+ {/if}
104
+ {#if actions}
105
+ <div class="hp-notice-actions" data-after={children ? '' : undefined}>{@render actions()}</div>
106
+ {/if}
107
+ </div>
108
+ {#if onclose}
109
+ <Button
110
+ type="button"
111
+ variant="tertiary"
112
+ icon
113
+ class="hp-notice-close"
114
+ aria-label={closeLabel}
115
+ onclick={() => onclose()}
116
+ >
117
+ <svg
118
+ viewBox="0 0 16 16"
119
+ fill="none"
120
+ stroke="currentColor"
121
+ stroke-width="1.5"
122
+ stroke-linecap="square"
123
+ aria-hidden="true"
124
+ >
125
+ <path d="M3 3l10 10M13 3L3 13" />
126
+ </svg>
127
+ </Button>
128
+ {/if}
129
+ </div>
130
+
131
+ <style>
132
+ /* The Toaster's box in the flow: black, the control boundary, square.
133
+ --notice-line is the first line's height (the title's 24px, or the
134
+ text's line when there is no title); --notice-lift is how far a
135
+ control is taller than that line, halved. */
136
+ .hp-notice {
137
+ --notice-line: 24px;
138
+ --notice-text-line: 24px;
139
+ --notice-lift: calc((var(--control-height) - var(--notice-line)) / 2);
140
+
141
+ display: flex;
142
+ align-items: flex-start;
143
+ gap: var(--space-2);
144
+ box-sizing: border-box;
145
+ min-width: 0;
146
+ padding: var(--space-3);
147
+ border: 1px solid var(--border-control);
148
+ background: var(--canvas);
149
+ color: var(--text);
150
+ font-family: var(--sans);
151
+ font-size: var(--type-body);
152
+ line-height: var(--notice-text-line);
153
+ }
154
+
155
+ /* 16px where a coarse pointer reads it, the dense 14px on fine pointers. */
156
+ @media (pointer: fine) {
157
+ .hp-notice {
158
+ --notice-text-line: 20px;
159
+
160
+ font-size: var(--type-dense);
161
+ }
162
+ }
163
+
164
+ .hp-notice:not([data-titled]) {
165
+ --notice-line: var(--notice-text-line);
166
+ }
167
+
168
+ /* ---- The mark: an outlined square on the first line --------------- */
169
+
170
+ .hp-notice-mark {
171
+ display: flex;
172
+ flex: none;
173
+ align-items: center;
174
+ height: var(--notice-line);
175
+ color: var(--muted);
176
+ }
177
+ .hp-notice-mark svg {
178
+ display: block;
179
+ }
180
+ .hp-notice[data-tone='ok'] .hp-notice-mark {
181
+ color: var(--ok);
182
+ }
183
+ .hp-notice[data-tone='warn'] .hp-notice-mark {
184
+ color: var(--warn);
185
+ }
186
+ .hp-notice[data-tone='danger'] .hp-notice-mark {
187
+ color: var(--danger);
188
+ }
189
+
190
+ /* ---- Title, text and actions -------------------------------------- */
191
+
192
+ /* Wraps the actions under the content when they do not fit beside it. */
193
+ .hp-notice-main {
194
+ display: flex;
195
+ flex: 1 1 auto;
196
+ flex-wrap: wrap;
197
+ align-items: flex-start;
198
+ gap: var(--space-3) var(--space-4);
199
+ min-width: 0;
200
+ }
201
+
202
+ .hp-notice-content {
203
+ display: grid;
204
+ flex: 1 1 auto;
205
+ gap: var(--space-1);
206
+ min-width: 0;
207
+ }
208
+
209
+ .hp-notice-title {
210
+ max-width: 100%;
211
+ color: var(--text);
212
+ font-size: var(--type-body);
213
+ font-weight: 500;
214
+ line-height: 24px;
215
+ overflow-wrap: anywhere;
216
+ }
217
+
218
+ .hp-notice-body {
219
+ max-width: var(--measure);
220
+ color: var(--muted);
221
+ overflow-wrap: anywhere;
222
+ }
223
+ .hp-notice-body :global(a) {
224
+ color: var(--text);
225
+ }
226
+ .hp-notice-body :global(p + p) {
227
+ margin-top: var(--space-2);
228
+ }
229
+
230
+ .hp-notice-actions {
231
+ display: flex;
232
+ flex: none;
233
+ flex-wrap: wrap;
234
+ gap: var(--space-2);
235
+ max-width: 100%;
236
+ }
237
+ /* Text above them: they take their own row. */
238
+ .hp-notice-actions[data-after] {
239
+ flex-basis: 100%;
240
+ }
241
+
242
+ /* ---- The close button: the Toaster's, at the top end -------------- */
243
+
244
+ /* Centred on the first line; the tertiary button has no edge, so it
245
+ reaches into the padding. */
246
+ .hp-notice :global(.hp-notice-close) {
247
+ flex: none;
248
+ margin: calc(-1 * var(--notice-lift)) calc(-1 * var(--space-2)) 0 0;
249
+ }
250
+
251
+ /* A title row with actions is a control high, so the mark, the title and
252
+ the close button centre on it. */
253
+ .hp-notice[data-row] .hp-notice-mark {
254
+ margin-top: var(--notice-lift);
255
+ }
256
+ .hp-notice[data-row] .hp-notice-content {
257
+ padding-top: var(--notice-lift);
258
+ }
259
+ .hp-notice[data-row] :global(.hp-notice-close) {
260
+ margin-top: 0;
261
+ }
262
+ </style>