@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,198 +1,235 @@
1
- <script lang="ts" module>
2
- import { Checkbox as BitsCheckbox } from 'bits-ui';
3
-
4
- /** Attributes and handlers not listed here go to the checkbox button. */
5
- export type CheckboxProps = Omit<BitsCheckbox.RootProps, 'child' | 'children' | 'ref'> & {
6
- /**
7
- * The text beside the box, as written (never caps). Pressing it toggles
8
- * the box. Without it, give the box an accessible name with `aria-label`.
9
- */
10
- label?: string;
11
- /** A second line in `--muted` under the label, read out as the box's description. */
12
- hint?: string;
13
- /** The checkbox button. */
14
- ref?: HTMLElement | null;
15
- };
16
- </script>
17
-
18
- <script lang="ts">
19
- const uid = $props.id();
20
-
21
- let {
22
- checked = $bindable(false),
23
- indeterminate = $bindable(false),
24
- label,
25
- hint,
26
- id = uid,
27
- ref = $bindable(null),
28
- class: className,
29
- 'aria-describedby': describedBy,
30
- ...rest
31
- }: CheckboxProps = $props();
32
-
33
- const hintId = $derived(`${id}-hint`);
34
- const describedByIds = $derived([hint ? hintId : null, describedBy].filter(Boolean).join(' ') || undefined);
35
- </script>
36
-
37
- <!--
38
- A Bits UI Checkbox: a <button role="checkbox"> with aria-checked true,
39
- false or mixed, and its state in data-state (checked, unchecked,
40
- indeterminate) and data-disabled. Pressing the box or its label toggles it;
41
- an indeterminate box becomes checked. Inside a CheckboxGroup, give it a
42
- `value`. Attributes, handlers and `class` go to the button.
43
- -->
44
- <div class="hp-checkbox">
45
- <span class="control">
46
- <BitsCheckbox.Root bind:checked bind:indeterminate bind:ref {id} aria-describedby={describedByIds} {...rest}>
47
- {#snippet child({ props })}
48
- <button {...props} class={['box', className]}>
49
- <svg class="mark mixed" viewBox="0 0 12 12" aria-hidden="true"><path d="M2 6h8" /></svg>
50
- <svg class="mark check" viewBox="0 0 12 12" aria-hidden="true"><path d="M1.5 6.5l3 3 6-6" /></svg>
51
- </button>
52
- {/snippet}
53
- </BitsCheckbox.Root>
54
- </span>
55
- {#if label}
56
- <label class="hp-dense" for={id}>{label}</label>
57
- {/if}
58
- {#if hint}
59
- <p class="hint hp-caption" id={hintId}>{hint}</p>
60
- {/if}
61
- </div>
62
-
63
- <style>
64
- /* The box, then the label as written. The first line is one hit-target
65
- band (24px fine, 44px coarse): the box sits centred in it and the
66
- label's first line too, so a label that wraps keeps the box beside its
67
- first line. The hint runs under the label, aligned with its text.
68
- Without a label the root is as wide as the box. */
69
- .hp-checkbox {
70
- /* The label's line height, as .hp-dense sets it. */
71
- --_line: 24px;
72
- display: grid;
73
- grid-template-columns: auto;
74
- justify-content: start;
75
- align-items: start;
76
- }
77
- .hp-checkbox:has(> label) {
78
- grid-template-columns: auto minmax(0, 1fr);
79
- column-gap: var(--space-3);
80
- }
81
- @media (pointer: fine) {
82
- .hp-checkbox {
83
- --_line: 20px;
84
- }
85
- }
86
-
87
- .control {
88
- position: relative;
89
- display: flex;
90
- align-items: center;
91
- height: var(--hit-target);
92
- }
93
-
94
- /* A black box with a 3:1 boundary. Checked or indeterminate, the edge and
95
- the mark turn titanium; the box stays black, because selection is never
96
- a fill. Focus is base.css's contour 4px outside, so it never looks like
97
- the checked edge. */
98
- .box {
99
- position: relative;
100
- display: grid;
101
- place-items: center;
102
- box-sizing: border-box;
103
- width: 20px;
104
- height: 20px;
105
- margin: 0;
106
- padding: 0;
107
- border: 1px solid var(--border-control);
108
- background: var(--canvas);
109
- color: var(--accent);
110
- cursor: pointer;
111
- -webkit-tap-highlight-color: transparent;
112
- }
113
- /* The hit area: at least --hit-target square, centred on the box. */
114
- .box::before {
115
- content: '';
116
- position: absolute;
117
- top: 50%;
118
- left: 50%;
119
- width: max(100%, var(--hit-target));
120
- height: max(100%, var(--hit-target));
121
- translate: -50% -50%;
122
- }
123
- .box[data-state='checked'],
124
- .box[data-state='indeterminate'] {
125
- border-color: var(--accent);
126
- }
127
-
128
- /* Both marks are always there, each at opacity 0 until its state comes.
129
- The mark a change brings fades in from 0 at its place over --dur-mark
130
- (BRIEF, short motion); the mark it takes away goes at once. A CSS
131
- transition never runs on an element's first style, so a box that
132
- renders checked or mixed shows its mark at once. 0ms is a snap.
133
- Opacity only: nothing moves, so reduced motion keeps it. */
134
- .mark {
135
- grid-area: 1 / 1;
136
- width: 12px;
137
- height: 12px;
138
- fill: none;
139
- stroke: currentColor;
140
- stroke-width: 2px;
141
- opacity: 0;
142
- }
143
- .box[data-state='indeterminate'] .mixed,
144
- .box[data-state='checked'] .check {
145
- opacity: 1;
146
- transition: opacity var(--dur-mark) var(--settle);
147
- }
148
-
149
- label {
150
- justify-self: start;
151
- padding: calc((var(--hit-target) - var(--_line)) / 2) 0;
152
- cursor: pointer;
153
- -webkit-tap-highlight-color: transparent;
154
- }
155
-
156
- /* Under the label's text; without a label, under the box. */
157
- .hint {
158
- grid-column: -2;
159
- color: var(--muted);
160
- }
161
-
162
- /* ---- Hover: fine pointers only, over the box or its label ---------- */
163
-
164
- @media (hover: hover) and (pointer: fine) {
165
- .box {
166
- transition:
167
- background-color var(--dur-hover) var(--settle),
168
- border-color var(--dur-hover) var(--settle);
169
- }
170
- .hp-checkbox:has(> label:hover, .box:hover) .box:not(:disabled) {
171
- background-color: var(--surface-hover);
172
- }
173
- .hp-checkbox:has(> label:hover, .box:hover) .box[data-state='unchecked']:not(:disabled) {
174
- border-color: var(--muted);
175
- }
176
- .hp-checkbox:has(> label:active, .box:active) .box:not(:disabled) {
177
- transition-duration: var(--dur-press);
178
- }
179
- }
180
-
181
- /* ---- Press: one step past hover, so it reads on a phone too -------- */
182
-
183
- .hp-checkbox:has(> label:active, .box:active) .box:not(:disabled) {
184
- background-color: var(--surface-raised);
185
- }
186
-
187
- /* ---- Disabled: the quieter --border and muted ink ------------------ */
188
-
189
- .box:disabled {
190
- border-color: var(--border);
191
- color: var(--muted);
192
- cursor: not-allowed;
193
- }
194
- .hp-checkbox:has(.box:disabled) label {
195
- color: var(--muted);
196
- cursor: not-allowed;
197
- }
198
- </style>
1
+ <script lang="ts" module>
2
+ import { Checkbox as BitsCheckbox } from 'bits-ui';
3
+
4
+ /** Attributes and handlers not listed here go to the checkbox button. */
5
+ export type CheckboxProps = Omit<BitsCheckbox.RootProps, 'child' | 'children' | 'ref'> & {
6
+ /**
7
+ * The text beside the box, as written (never caps). Pressing it, or
8
+ * anywhere on the box's row, toggles the box. Without it, give the box
9
+ * an accessible name with `aria-label`.
10
+ */
11
+ label?: string;
12
+ /**
13
+ * A Tag after the label, such as "Recommended": a short fixed string the
14
+ * app defines, set in caps. It is part of the box's accessible name and
15
+ * shows only with a `label`.
16
+ */
17
+ tag?: string;
18
+ /** A second line in `--muted` under the label, read out as the box's description. */
19
+ hint?: string;
20
+ /** The checkbox button. */
21
+ ref?: HTMLElement | null;
22
+ };
23
+ </script>
24
+
25
+ <script lang="ts">
26
+ import Tag from './Tag.svelte';
27
+
28
+ const uid = $props.id();
29
+
30
+ let {
31
+ checked = $bindable(false),
32
+ indeterminate = $bindable(false),
33
+ label,
34
+ tag,
35
+ hint,
36
+ id = uid,
37
+ ref = $bindable(null),
38
+ class: className,
39
+ 'aria-describedby': describedBy,
40
+ ...rest
41
+ }: CheckboxProps = $props();
42
+
43
+ const hintId = $derived(`${id}-hint`);
44
+ const describedByIds = $derived([hint ? hintId : null, describedBy].filter(Boolean).join(' ') || undefined);
45
+ </script>
46
+
47
+ <!--
48
+ A Bits UI Checkbox: a <button role="checkbox"> with aria-checked true,
49
+ false or mixed, and its state in data-state (checked, unchecked,
50
+ indeterminate) and data-disabled. Pressing the box or anywhere on its row
51
+ (the label, the tag, the hint) toggles it; an indeterminate box becomes
52
+ checked. Inside a CheckboxGroup, give it a `value`. Attributes, handlers
53
+ and `class` go to the button.
54
+ -->
55
+ <div class="hp-checkbox">
56
+ <span class="control">
57
+ <BitsCheckbox.Root bind:checked bind:indeterminate bind:ref {id} aria-describedby={describedByIds} {...rest}>
58
+ {#snippet child({ props })}
59
+ <button {...props} class={['box', className]}>
60
+ <svg class="mark mixed" viewBox="0 0 12 12" aria-hidden="true"><path d="M2 6h8" /></svg>
61
+ <svg class="mark check" viewBox="0 0 12 12" aria-hidden="true"><path d="M1.5 6.5l3 3 6-6" /></svg>
62
+ </button>
63
+ {/snippet}
64
+ </BitsCheckbox.Root>
65
+ </span>
66
+ {#if label}
67
+ <label class="hp-dense" class:tagged={!!tag} for={id}
68
+ >{label}{#if tag}{' '}<Tag as="span">{tag}</Tag>{/if}</label
69
+ >
70
+ {/if}
71
+ {#if hint}
72
+ <p class="hint hp-caption" id={hintId}>{hint}</p>
73
+ {/if}
74
+ </div>
75
+
76
+ <style>
77
+ /* The box, then the label as written. The first line is one hit-target
78
+ band (24px fine, 44px coarse): the box sits centred in it and the
79
+ label's first line too, so a label that wraps keeps the box beside its
80
+ first line. The hint runs under the label, aligned with its text.
81
+ The root is as wide as its content (without a label, as the box), and
82
+ with a label all of it is the target: the label's ::after covers the
83
+ root, so a press on the hint, the tag or the space between them is a
84
+ press on the label. The box sits above that cover with its own hit
85
+ area. */
86
+ .hp-checkbox {
87
+ /* The label's line height, as .hp-dense sets it. */
88
+ --_line: 24px;
89
+ position: relative;
90
+ display: grid;
91
+ grid-template-columns: auto;
92
+ justify-content: start;
93
+ align-items: start;
94
+ width: fit-content;
95
+ max-width: 100%;
96
+ }
97
+ .hp-checkbox:has(> label) {
98
+ grid-template-columns: auto minmax(0, 1fr);
99
+ column-gap: var(--space-3);
100
+ }
101
+ @media (pointer: fine) {
102
+ .hp-checkbox {
103
+ --_line: 20px;
104
+ }
105
+ }
106
+
107
+ .control {
108
+ position: relative;
109
+ z-index: 1;
110
+ display: flex;
111
+ align-items: center;
112
+ height: var(--hit-target);
113
+ }
114
+
115
+ /* A black box with a 3:1 boundary. Checked or indeterminate, the edge and
116
+ the mark turn titanium; the box stays black, because selection is never
117
+ a fill. Focus is base.css's contour 4px outside, so it never looks like
118
+ the checked edge. */
119
+ .box {
120
+ position: relative;
121
+ display: grid;
122
+ place-items: center;
123
+ box-sizing: border-box;
124
+ width: 20px;
125
+ height: 20px;
126
+ margin: 0;
127
+ padding: 0;
128
+ border: 1px solid var(--border-control);
129
+ background: var(--canvas);
130
+ color: var(--accent);
131
+ cursor: pointer;
132
+ -webkit-tap-highlight-color: transparent;
133
+ }
134
+ /* The hit area: at least --hit-target square, centred on the box. */
135
+ .box::before {
136
+ content: '';
137
+ position: absolute;
138
+ top: 50%;
139
+ left: 50%;
140
+ width: max(100%, var(--hit-target));
141
+ height: max(100%, var(--hit-target));
142
+ translate: -50% -50%;
143
+ }
144
+ .box[data-state='checked'],
145
+ .box[data-state='indeterminate'] {
146
+ border-color: var(--accent);
147
+ }
148
+
149
+ /* Both marks are always there, each at opacity 0 until its state comes.
150
+ The mark a change brings fades in from 0 at its place over --dur-mark
151
+ (BRIEF, short motion); the mark it takes away goes at once. A CSS
152
+ transition never runs on an element's first style, so a box that
153
+ renders checked or mixed shows its mark at once. 0ms is a snap.
154
+ Opacity only: nothing moves, so reduced motion keeps it. */
155
+ .mark {
156
+ grid-area: 1 / 1;
157
+ width: 12px;
158
+ height: 12px;
159
+ fill: none;
160
+ stroke: currentColor;
161
+ stroke-width: 2px;
162
+ opacity: 0;
163
+ }
164
+ .box[data-state='indeterminate'] .mixed,
165
+ .box[data-state='checked'] .check {
166
+ opacity: 1;
167
+ transition: opacity var(--dur-mark) var(--settle);
168
+ }
169
+
170
+ label {
171
+ justify-self: start;
172
+ padding: calc((var(--hit-target) - var(--_line)) / 2) 0;
173
+ cursor: pointer;
174
+ -webkit-tap-highlight-color: transparent;
175
+ }
176
+ label::after {
177
+ content: '';
178
+ position: absolute;
179
+ inset: 0;
180
+ }
181
+ /* The tag sits after the label when both fit on one line; otherwise it
182
+ wraps under the label whole. */
183
+ .tagged {
184
+ display: flex;
185
+ flex-wrap: wrap;
186
+ align-items: center;
187
+ gap: var(--space-1) var(--space-2);
188
+ }
189
+
190
+ /* Under the label's text; without a label, under the box. */
191
+ .hint {
192
+ grid-column: -2;
193
+ color: var(--muted);
194
+ }
195
+
196
+ /* ---- Hover: fine pointers only, over any part of the row ----------- */
197
+
198
+ @media (hover: hover) and (pointer: fine) {
199
+ .box {
200
+ transition:
201
+ background-color var(--dur-hover) var(--settle),
202
+ border-color var(--dur-hover) var(--settle);
203
+ }
204
+ .hp-checkbox:has(> label:hover, .box:hover) .box:not(:disabled) {
205
+ background-color: var(--surface-hover);
206
+ }
207
+ .hp-checkbox:has(> label:hover, .box:hover) .box[data-state='unchecked']:not(:disabled) {
208
+ border-color: var(--muted);
209
+ }
210
+ .hp-checkbox:has(> label:active, .box:active) .box:not(:disabled) {
211
+ transition-duration: var(--dur-press);
212
+ }
213
+ }
214
+
215
+ /* ---- Press: one step past hover, so it reads on a phone too -------- */
216
+
217
+ .hp-checkbox:has(> label:active, .box:active) .box:not(:disabled) {
218
+ background-color: var(--surface-raised);
219
+ }
220
+
221
+ /* ---- Disabled: the quieter --border and muted ink, the tag too ----- */
222
+
223
+ .box:disabled {
224
+ border-color: var(--border);
225
+ color: var(--muted);
226
+ cursor: not-allowed;
227
+ }
228
+ .hp-checkbox:has(.box:disabled) label {
229
+ color: var(--muted);
230
+ cursor: not-allowed;
231
+ }
232
+ .hp-checkbox:has(.box:disabled) label > :global(.hp-tag) {
233
+ background: var(--muted);
234
+ }
235
+ </style>
@@ -2,10 +2,17 @@ import { Checkbox as BitsCheckbox } from 'bits-ui';
2
2
  /** Attributes and handlers not listed here go to the checkbox button. */
3
3
  export type CheckboxProps = Omit<BitsCheckbox.RootProps, 'child' | 'children' | 'ref'> & {
4
4
  /**
5
- * The text beside the box, as written (never caps). Pressing it toggles
6
- * the box. Without it, give the box an accessible name with `aria-label`.
5
+ * The text beside the box, as written (never caps). Pressing it, or
6
+ * anywhere on the box's row, toggles the box. Without it, give the box
7
+ * an accessible name with `aria-label`.
7
8
  */
8
9
  label?: string;
10
+ /**
11
+ * A Tag after the label, such as "Recommended": a short fixed string the
12
+ * app defines, set in caps. It is part of the box's accessible name and
13
+ * shows only with a `label`.
14
+ */
15
+ tag?: string;
9
16
  /** A second line in `--muted` under the label, read out as the box's description. */
10
17
  hint?: string;
11
18
  /** The checkbox button. */