@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.
- package/CHANGELOG.md +42 -18
- package/LICENSE +25 -25
- package/README.md +67 -64
- package/dist/base.css +625 -346
- package/dist/components/AppShell.svelte +698 -698
- package/dist/components/Button.svelte +174 -174
- package/dist/components/Checkbox.svelte +235 -198
- package/dist/components/Checkbox.svelte.d.ts +9 -2
- package/dist/components/CheckboxGroup.svelte +207 -99
- package/dist/components/CheckboxGroup.svelte.d.ts +23 -4
- package/dist/components/Combobox.svelte +901 -824
- package/dist/components/Combobox.svelte.d.ts +10 -1
- package/dist/components/Dialog.svelte +359 -356
- package/dist/components/Disclosure.svelte +201 -201
- package/dist/components/EmptyState.svelte +88 -88
- package/dist/components/ErrorState.svelte +135 -135
- package/dist/components/ImageViewer.svelte +764 -0
- package/dist/components/ImageViewer.svelte.d.ts +55 -0
- package/dist/components/KeyValueList.svelte +114 -114
- package/dist/components/ListDetail.svelte +218 -0
- package/dist/components/ListDetail.svelte.d.ts +37 -0
- package/dist/components/LoadRegion.svelte +219 -219
- package/dist/components/MediaFrame.svelte +110 -110
- package/dist/components/MediaImage.svelte +256 -256
- package/dist/components/Menu.svelte +258 -258
- package/dist/components/MenuCheckboxItem.svelte +119 -119
- package/dist/components/MenuGroup.svelte +50 -50
- package/dist/components/MenuItem.svelte +94 -94
- package/dist/components/MenuRadioGroup.svelte +62 -62
- package/dist/components/MenuRadioItem.svelte +110 -110
- package/dist/components/MenuSeparator.svelte +28 -28
- package/dist/components/Meter.svelte +283 -0
- package/dist/components/Meter.svelte.d.ts +66 -0
- package/dist/components/NativeSelect.svelte +18 -2
- package/dist/components/NativeSelect.svelte.d.ts +6 -0
- package/dist/components/Notice.svelte +262 -0
- package/dist/components/Notice.svelte.d.ts +30 -0
- package/dist/components/Popover.svelte +222 -222
- package/dist/components/Progress.svelte +157 -157
- package/dist/components/RadioGroup.svelte +440 -0
- package/dist/components/RadioGroup.svelte.d.ts +50 -0
- package/dist/components/Select.svelte +471 -405
- package/dist/components/Select.svelte.d.ts +6 -0
- package/dist/components/Skeleton.svelte +149 -149
- package/dist/components/Spinner.svelte +118 -117
- package/dist/components/Stat.svelte +253 -253
- package/dist/components/Steps.svelte +189 -189
- package/dist/components/Switch.svelte +222 -222
- package/dist/components/Table.svelte +504 -504
- package/dist/components/Tabs.svelte +246 -246
- package/dist/components/Tag.svelte +40 -40
- package/dist/components/TextArea.svelte +272 -0
- package/dist/components/TextArea.svelte.d.ts +28 -0
- package/dist/components/TextField.svelte +256 -256
- package/dist/components/Timeline.svelte +156 -156
- package/dist/components/Toaster.svelte +411 -411
- package/dist/components/Tooltip.svelte +200 -200
- package/dist/components/TooltipGroup.svelte +46 -46
- package/dist/components/internal/Scrim.svelte +52 -52
- package/dist/components/internal/Sheet.svelte +263 -263
- package/dist/components/internal/groups.d.ts +14 -0
- package/dist/components/internal/groups.js +23 -0
- package/dist/fonts.css +71 -71
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/tokens.css +283 -279
- 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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
/**
|
|
12
|
-
|
|
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
|
-
|
|
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;
|