@glimstone/svelte 4.9.1 → 5.0.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.
- package/dist/AngleSlider.svelte +33 -9
- package/dist/AngleSlider.svelte.d.ts +1 -1
- package/dist/Avatar.svelte +1 -1
- package/dist/Badge.svelte +3 -7
- package/dist/Badge.svelte.d.ts +2 -5
- package/dist/Card.svelte +5 -1
- package/dist/Card.svelte.d.ts +3 -0
- package/dist/Chart.svelte +84 -0
- package/dist/Chart.svelte.d.ts +19 -0
- package/dist/ChartLegend.svelte +19 -0
- package/dist/ChartLegend.svelte.d.ts +7 -0
- package/dist/Checkbox.svelte +16 -3
- package/dist/ColorPicker.svelte +49 -4
- package/dist/ColorPicker.svelte.d.ts +2 -0
- package/dist/Combobox.svelte +12 -4
- package/dist/ConfirmDialog.svelte +8 -2
- package/dist/ConnectionRow.svelte +4 -1
- package/dist/ConnectionRow.svelte.d.ts +2 -0
- package/dist/ContextMenu.svelte +4 -2
- package/dist/ContextMenu.svelte.d.ts +2 -0
- package/dist/DatePicker.svelte +21 -11
- package/dist/FieldErrorLine.svelte +24 -0
- package/dist/FieldErrorLine.svelte.d.ts +7 -0
- package/dist/FieldRow.svelte +16 -4
- package/dist/FileUpload.svelte +14 -4
- package/dist/FileUpload.svelte.d.ts +2 -0
- package/dist/FortressPermissions.svelte +3 -1
- package/dist/HoverCard.svelte +34 -5
- package/dist/HoverCard.svelte.d.ts +12 -2
- package/dist/IconTipButton.svelte +6 -2
- package/dist/IconTipButton.svelte.d.ts +3 -0
- package/dist/InfoBubble.svelte +1 -1
- package/dist/ListRow.svelte +71 -6
- package/dist/ListRow.svelte.d.ts +17 -2
- package/dist/ListSelect.svelte +7 -2
- package/dist/ListTable.svelte +36 -16
- package/dist/ListTable.svelte.d.ts +5 -0
- package/dist/MenuSelect.svelte +11 -3
- package/dist/Meter.svelte +21 -3
- package/dist/Meter.svelte.d.ts +4 -0
- package/dist/MultiSelect.svelte +156 -0
- package/dist/MultiSelect.svelte.d.ts +20 -0
- package/dist/NotifyCard.svelte +1 -1
- package/dist/NumberField.svelte +2 -2
- package/dist/Pagination.svelte +15 -5
- package/dist/PasswordField.svelte +7 -6
- package/dist/PinInput.svelte +4 -2
- package/dist/Rating.svelte +10 -1
- package/dist/RevealEye.svelte +17 -0
- package/dist/RevealEye.svelte.d.ts +6 -0
- package/dist/SearchHit.svelte +10 -0
- package/dist/SearchHit.svelte.d.ts +7 -0
- package/dist/Selector.svelte +28 -4
- package/dist/Selector.svelte.d.ts +4 -3
- package/dist/SettingsNav.svelte +152 -0
- package/dist/SettingsNav.svelte.d.ts +46 -0
- package/dist/SignInTile.svelte +124 -114
- package/dist/SkeletonRow.svelte +8 -2
- package/dist/SkeletonRow.svelte.d.ts +4 -0
- package/dist/Slider.svelte +1 -0
- package/dist/Sparkline.svelte +24 -0
- package/dist/Sparkline.svelte.d.ts +11 -0
- package/dist/StatusSummary.svelte +55 -0
- package/dist/StatusSummary.svelte.d.ts +18 -0
- package/dist/SubCard.svelte +16 -16
- package/dist/SubCard.svelte.d.ts +3 -3
- package/dist/TextArea.svelte +13 -3
- package/dist/TextField.svelte +2 -2
- package/dist/TimeDial.svelte +74 -0
- package/dist/TimeDial.svelte.d.ts +13 -0
- package/dist/TimePicker.svelte +57 -0
- package/dist/TimePicker.svelte.d.ts +19 -0
- package/dist/TimeRangePicker.svelte +52 -0
- package/dist/TimeRangePicker.svelte.d.ts +16 -0
- package/dist/TimeShell.svelte +145 -0
- package/dist/TimeShell.svelte.d.ts +16 -0
- package/dist/Timer.svelte +6 -1
- package/dist/TipBubble.svelte +1 -1
- package/dist/ToastCard.svelte +7 -3
- package/dist/ToastCard.svelte.d.ts +2 -0
- package/dist/ToastViewport.svelte +6 -3
- package/dist/Toggle.svelte +3 -1
- package/dist/Tour.svelte +8 -2
- package/dist/Window.svelte +5 -3
- package/dist/Window.svelte.d.ts +3 -1
- package/dist/bubble.svelte.d.ts +12 -1
- package/dist/bubble.svelte.js +13 -5
- package/dist/engines.svelte.d.ts +7 -1
- package/dist/engines.svelte.js +13 -1
- package/dist/entries/multiselect.d.ts +1 -0
- package/dist/entries/multiselect.js +2 -0
- package/dist/glyphs.d.ts +3 -0
- package/dist/glyphs.js +3 -0
- package/dist/index.d.ts +13 -7
- package/dist/index.js +9 -4
- package/package.json +7 -2
- package/dist/AboutCard.svelte +0 -116
- package/dist/AboutCard.svelte.d.ts +0 -40
- package/dist/DropdownListbox.svelte +0 -178
- package/dist/DropdownListbox.svelte.d.ts +0 -23
|
@@ -17,6 +17,11 @@ export interface ListTableProps<T extends object> {
|
|
|
17
17
|
onOpen?: (row: T) => void;
|
|
18
18
|
/** The picked rows, in the list's order, after every change. */
|
|
19
19
|
onSelect?: (rows: T[]) => void;
|
|
20
|
+
/** Puts the rows in sections, one per value, such as the instance a row
|
|
21
|
+
* comes from, each under that value as a plain title in the one card. */
|
|
22
|
+
section?: (row: T) => string;
|
|
23
|
+
/** Draws every row on one line, leaving out the columns' `sub` lines. */
|
|
24
|
+
oneLine?: boolean;
|
|
20
25
|
}
|
|
21
26
|
declare function $$render<T extends object>(): {
|
|
22
27
|
props: ListTableProps<T>;
|
package/dist/MenuSelect.svelte
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { untrack } from "svelte";
|
|
3
3
|
import * as menu from "@zag-js/menu";
|
|
4
4
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
|
|
5
|
-
import { closeOnPageMove, faceLabels, flattenRuns, homeRow, isSubmenu, pageDir, SELECT_POSITIONING, selectRootClass, selectRowParts } from "@glimstone/core";
|
|
5
|
+
import { alignOverTrigger, closeOnPageMove, faceLabels, flattenRuns, homeRow, isSubmenu, pageDir, SELECT_POSITIONING, selectRootClass, selectRowParts } from "@glimstone/core";
|
|
6
6
|
import { useTipBubble } from "./bubble.svelte.js";
|
|
7
7
|
import { IconExpand } from "./glyphs.js";
|
|
8
8
|
import { lift } from "./lift.js";
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
count: () => shake ?? 0,
|
|
66
66
|
});
|
|
67
67
|
const hue = usePortalHue(() => open, () => ref);
|
|
68
|
+
let content: HTMLDivElement;
|
|
68
69
|
|
|
69
70
|
$effect(() => {
|
|
70
71
|
if (!open) return;
|
|
@@ -72,13 +73,20 @@
|
|
|
72
73
|
// Zag highlights on the frame after the list opens, so the home row goes
|
|
73
74
|
// one frame later still.
|
|
74
75
|
const home = untrack(() => homeRow(groups, value, subId));
|
|
75
|
-
|
|
76
|
+
const unalign = untrack(() => alignOverTrigger(content, ref!, home));
|
|
77
|
+
if (home === null) {
|
|
78
|
+
return () => {
|
|
79
|
+
stop();
|
|
80
|
+
unalign();
|
|
81
|
+
};
|
|
82
|
+
}
|
|
76
83
|
let inner = 0;
|
|
77
84
|
const outer = requestAnimationFrame(() => {
|
|
78
85
|
inner = requestAnimationFrame(() => api.setHighlightedValue(home));
|
|
79
86
|
});
|
|
80
87
|
return () => {
|
|
81
88
|
stop();
|
|
89
|
+
unalign();
|
|
82
90
|
cancelAnimationFrame(outer);
|
|
83
91
|
cancelAnimationFrame(inner);
|
|
84
92
|
};
|
|
@@ -123,7 +131,7 @@
|
|
|
123
131
|
</div>
|
|
124
132
|
<TipBubble state={bubble} />
|
|
125
133
|
<div {@attach lift} {...mergeProps(api.getPositionerProps(), { style: hue.style })} class={`glim-select-positioner ${hue.className}`.trim()}>
|
|
126
|
-
<div {...api.getContentProps()} class={parts.content}>
|
|
134
|
+
<div {...api.getContentProps()} bind:this={content} class={parts.content}>
|
|
127
135
|
{#each groups as g, gi (gi)}
|
|
128
136
|
{#if g.entries.length > 0}
|
|
129
137
|
<div {...g.heading ? api.getItemGroupProps({ id: `g${gi}` }) : {}} class="glim-select-group">
|
package/dist/Meter.svelte
CHANGED
|
@@ -16,23 +16,29 @@
|
|
|
16
16
|
quiet?: boolean;
|
|
17
17
|
/** The level in words, such as "120 GB free of 4 TB": read out, and shown in the bubble. */
|
|
18
18
|
valueText?: string;
|
|
19
|
+
/** The figure beside the track, such as "1.4 / 2 TB". The percentage when left out. */
|
|
20
|
+
figure?: string;
|
|
21
|
+
/** Shows the figure beside the track. On by default for `medium`, off for `small` and `quiet`. */
|
|
22
|
+
showValue?: boolean;
|
|
19
23
|
class?: string;
|
|
20
24
|
}
|
|
21
25
|
</script>
|
|
22
26
|
|
|
23
27
|
<script lang="ts">
|
|
24
|
-
import { meterView } from "@glimstone/core";
|
|
28
|
+
import { meterFigure, meterShowsValue, meterView } from "@glimstone/core";
|
|
25
29
|
import { useTipBubble } from "./bubble.svelte.js";
|
|
26
30
|
import TipBubble from "./TipBubble.svelte";
|
|
27
31
|
|
|
28
32
|
// A level that stands, such as how full a disk is. meterView() in the core
|
|
29
33
|
// decides when it turns red and how it runs without a value.
|
|
30
|
-
let { value, label, size = "medium", threshold = 0.9, quiet, valueText, class: className }: MeterProps = $props();
|
|
34
|
+
let { value, label, size = "medium", threshold = 0.9, quiet, valueText, figure, showValue, class: className }: MeterProps = $props();
|
|
31
35
|
const view = $derived(meterView(value, { size, threshold, quiet }));
|
|
32
36
|
const tip = useTipBubble(() => valueText);
|
|
33
37
|
const busy = $derived(view.percent === null);
|
|
38
|
+
const shown = $derived(meterShowsValue(size, quiet, showValue));
|
|
34
39
|
</script>
|
|
35
40
|
|
|
41
|
+
{#snippet meter()}
|
|
36
42
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
37
43
|
<span
|
|
38
44
|
data-glim="Meter"
|
|
@@ -52,4 +58,16 @@
|
|
|
52
58
|
>
|
|
53
59
|
<span class="glim-meter-fill" style={view.width ? `width: ${view.width}` : undefined}></span>
|
|
54
60
|
</span>
|
|
55
|
-
|
|
61
|
+
{/snippet}
|
|
62
|
+
|
|
63
|
+
<!-- The figure repeats what the meter already says, so a screen reader hears it once. -->
|
|
64
|
+
{#if shown}
|
|
65
|
+
<span class="glim-meter-row glim-meter-row--{size}">
|
|
66
|
+
{@render meter()}
|
|
67
|
+
<span class="glim-meter-value glim-num" aria-hidden="true">{meterFigure(view.percent, figure)}</span>
|
|
68
|
+
<TipBubble state={tip} />
|
|
69
|
+
</span>
|
|
70
|
+
{:else}
|
|
71
|
+
{@render meter()}
|
|
72
|
+
<TipBubble state={tip} />
|
|
73
|
+
{/if}
|
package/dist/Meter.svelte.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export interface MeterProps {
|
|
|
13
13
|
quiet?: boolean;
|
|
14
14
|
/** The level in words, such as "120 GB free of 4 TB": read out, and shown in the bubble. */
|
|
15
15
|
valueText?: string;
|
|
16
|
+
/** The figure beside the track, such as "1.4 / 2 TB". The percentage when left out. */
|
|
17
|
+
figure?: string;
|
|
18
|
+
/** Shows the figure beside the track. On by default for `medium`, off for `small` and `quiet`. */
|
|
19
|
+
showValue?: boolean;
|
|
16
20
|
class?: string;
|
|
17
21
|
}
|
|
18
22
|
declare const Meter: import("svelte").Component<MeterProps, {}, "">;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { MultiSelectText } from "@glimstone/core";
|
|
3
|
+
import type { SelectOption } from "./selectParts.svelte.js";
|
|
4
|
+
|
|
5
|
+
export type { MultiSelectText } from "@glimstone/core";
|
|
6
|
+
|
|
7
|
+
export interface MultiSelectProps {
|
|
8
|
+
label?: string;
|
|
9
|
+
hideLabel?: boolean;
|
|
10
|
+
options: SelectOption[];
|
|
11
|
+
/** The picked values, bound with `bind:value`, in the order they were picked. */
|
|
12
|
+
value: string[];
|
|
13
|
+
onChange?: (value: string[]) => void;
|
|
14
|
+
/** Shown while nothing is picked. */
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
/** How many choices the list shows before the field takes a search, seven unless given. */
|
|
17
|
+
searchAfter?: number;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
text?: Partial<MultiSelectText>;
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
import * as combobox from "@zag-js/combobox";
|
|
25
|
+
import { normalizeProps, useMachine } from "@zag-js/svelte";
|
|
26
|
+
import {
|
|
27
|
+
MULTI_SELECT_SEARCH_AFTER,
|
|
28
|
+
MULTI_SELECT_TEXT,
|
|
29
|
+
multiSelectMatches,
|
|
30
|
+
multiSelectSearches,
|
|
31
|
+
multiSelectWithout,
|
|
32
|
+
pageDir,
|
|
33
|
+
} from "@glimstone/core";
|
|
34
|
+
import { useFieldName } from "./fieldName.js";
|
|
35
|
+
import { IconCheck, IconClose, IconExpand } from "./glyphs.js";
|
|
36
|
+
import { lift } from "./lift.js";
|
|
37
|
+
import SearchHit from "./SearchHit.svelte";
|
|
38
|
+
|
|
39
|
+
// A field that picks several choices from a list and keeps them as tags,
|
|
40
|
+
// each with its own remove mark. It is Zag's combobox in multiple mode, so
|
|
41
|
+
// focus stays in the field while the arrows move through the list, and a
|
|
42
|
+
// pick keeps the list open for the next. A short list takes no typing and
|
|
43
|
+
// answers Space the way a Select does; a long one filters as somebody types.
|
|
44
|
+
let {
|
|
45
|
+
label,
|
|
46
|
+
hideLabel,
|
|
47
|
+
options,
|
|
48
|
+
value = $bindable(),
|
|
49
|
+
onChange,
|
|
50
|
+
placeholder,
|
|
51
|
+
searchAfter,
|
|
52
|
+
disabled = false,
|
|
53
|
+
text,
|
|
54
|
+
}: MultiSelectProps = $props();
|
|
55
|
+
|
|
56
|
+
const name = useFieldName(() => label);
|
|
57
|
+
const words = $derived({ ...MULTI_SELECT_TEXT, ...text });
|
|
58
|
+
const searches = $derived(multiSelectSearches(options.length, searchAfter ?? MULTI_SELECT_SEARCH_AFTER));
|
|
59
|
+
let query = $state("");
|
|
60
|
+
const shown = $derived(searches ? multiSelectMatches(options, query) : options);
|
|
61
|
+
let field: HTMLInputElement | undefined = $state();
|
|
62
|
+
const id = $props.id();
|
|
63
|
+
|
|
64
|
+
function pick(next: string[]) {
|
|
65
|
+
value = next;
|
|
66
|
+
onChange?.(next);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const service = useMachine(combobox.machine, () => ({
|
|
70
|
+
id,
|
|
71
|
+
dir: pageDir(),
|
|
72
|
+
collection: combobox.collection({
|
|
73
|
+
items: shown,
|
|
74
|
+
itemToValue: (o: SelectOption) => o.value,
|
|
75
|
+
itemToString: (o: SelectOption) => o.label,
|
|
76
|
+
isItemDisabled: (o: SelectOption) => !!o.disabled,
|
|
77
|
+
}),
|
|
78
|
+
value,
|
|
79
|
+
multiple: true,
|
|
80
|
+
disabled,
|
|
81
|
+
openOnClick: true,
|
|
82
|
+
selectionBehavior: "clear" as const,
|
|
83
|
+
positioning: { sameWidth: true, gutter: 6 },
|
|
84
|
+
onOpenChange: ({ open }: { open: boolean }) => {
|
|
85
|
+
if (!open) query = "";
|
|
86
|
+
},
|
|
87
|
+
onInputValueChange: ({ inputValue }: { inputValue: string }) => (query = inputValue),
|
|
88
|
+
onValueChange: (d: { value: string[] }) => pick(d.value),
|
|
89
|
+
}));
|
|
90
|
+
const api = $derived(combobox.connect(service, normalizeProps));
|
|
91
|
+
const labelOf = (v: string) => options.find((o) => o.value === v)?.label ?? v;
|
|
92
|
+
const input = $derived.by(() => {
|
|
93
|
+
const { onkeydown, ...rest } = api.getInputProps() as Record<string, unknown> & { onkeydown?: (e: KeyboardEvent) => void };
|
|
94
|
+
return { rest, onkeydown };
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
function onkeydown(e: KeyboardEvent) {
|
|
98
|
+
if (e.key === "Backspace" && api.inputValue === "" && value.length > 0) {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
pick(value.slice(0, -1));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (!searches && e.key === " ") {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
if (!api.open) api.setOpen(true);
|
|
106
|
+
else if (api.highlightedValue) api.selectValue(api.highlightedValue);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
input.onkeydown?.(e);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function remove(v: string) {
|
|
113
|
+
pick(multiSelectWithout(value, v));
|
|
114
|
+
field?.focus();
|
|
115
|
+
}
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<div data-glim="MultiSelect" {...api.getRootProps()} class="glim-tags">
|
|
119
|
+
<label {...api.getLabelProps()} class={hideLabel || label === undefined ? "glim-sr-only" : "glim-field-label"}>{name()}</label>
|
|
120
|
+
<div {...api.getControlProps()} class={searches ? "glim-tags-control" : "glim-tags-control glim-tags-control--pick"}>
|
|
121
|
+
{#each value as v (v)}
|
|
122
|
+
<span class="glim-tag-item">
|
|
123
|
+
<span class="glim-tag">
|
|
124
|
+
<span class="glim-tag-text">{labelOf(v)}</span>
|
|
125
|
+
<button type="button" {disabled} aria-label={words.remove(labelOf(v))} onclick={() => remove(v)} class="glim-tag-remove">
|
|
126
|
+
{@render IconClose()}
|
|
127
|
+
</button>
|
|
128
|
+
</span>
|
|
129
|
+
</span>
|
|
130
|
+
{/each}
|
|
131
|
+
<input
|
|
132
|
+
{...input.rest}
|
|
133
|
+
bind:this={field}
|
|
134
|
+
readonly={!searches}
|
|
135
|
+
placeholder={value.length === 0 ? placeholder : searches ? words.search : undefined}
|
|
136
|
+
{onkeydown}
|
|
137
|
+
class="glim-tags-input"
|
|
138
|
+
/>
|
|
139
|
+
<button {...api.getTriggerProps()} aria-label={words.toggle} class="glim-combobox-toggle">
|
|
140
|
+
<span class="glim-select-indicator" data-state={api.open ? "open" : "closed"}>{@render IconExpand()}</span>
|
|
141
|
+
</button>
|
|
142
|
+
</div>
|
|
143
|
+
<div {@attach lift} {...api.getPositionerProps()} class="glim-select-positioner">
|
|
144
|
+
<ul {...api.getContentProps()} class="glim-select-content">
|
|
145
|
+
{#if shown.length === 0}
|
|
146
|
+
<li class="glim-select-empty">{words.empty}</li>
|
|
147
|
+
{/if}
|
|
148
|
+
{#each shown as item (item.value)}
|
|
149
|
+
<li {...api.getItemProps({ item })} class="glim-select-item">
|
|
150
|
+
<span {...api.getItemTextProps({ item })} data-search={searches && query ? "" : undefined}><SearchHit label={item.label} query={searches ? query : ""} /></span>
|
|
151
|
+
<span {...api.getItemIndicatorProps({ item })} class="glim-select-check">{@render IconCheck()}</span>
|
|
152
|
+
</li>
|
|
153
|
+
{/each}
|
|
154
|
+
</ul>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MultiSelectText } from "@glimstone/core";
|
|
2
|
+
import type { SelectOption } from "./selectParts.svelte.js";
|
|
3
|
+
export type { MultiSelectText } from "@glimstone/core";
|
|
4
|
+
export interface MultiSelectProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
hideLabel?: boolean;
|
|
7
|
+
options: SelectOption[];
|
|
8
|
+
/** The picked values, bound with `bind:value`, in the order they were picked. */
|
|
9
|
+
value: string[];
|
|
10
|
+
onChange?: (value: string[]) => void;
|
|
11
|
+
/** Shown while nothing is picked. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** How many choices the list shows before the field takes a search, seven unless given. */
|
|
14
|
+
searchAfter?: number;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
text?: Partial<MultiSelectText>;
|
|
17
|
+
}
|
|
18
|
+
declare const MultiSelect: import("svelte").Component<MultiSelectProps, {}, "value">;
|
|
19
|
+
type MultiSelect = ReturnType<typeof MultiSelect>;
|
|
20
|
+
export default MultiSelect;
|
package/dist/NotifyCard.svelte
CHANGED
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
{/each}
|
|
134
134
|
</div>
|
|
135
135
|
{:else if s.loaded}
|
|
136
|
-
<EmptyState nested title={fill(text.empty, { app })} />
|
|
136
|
+
<EmptyState nested glyph={glyphFor(keys.notifications)} title={fill(text.empty, { app })} />
|
|
137
137
|
{/if}
|
|
138
138
|
<div class="glim-notify-foot">
|
|
139
139
|
<Button label={text.add} labelKey={keys.add} disabled={!s.loaded} data-notify="add" onClick={flow.pick} />
|
package/dist/NumberField.svelte
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
<script lang="ts">
|
|
24
24
|
import { attachNumberSteppers, fieldErrorView, syncNumberSteppers } from "@glimstone/core";
|
|
25
|
-
import
|
|
25
|
+
import FieldErrorLine from "./FieldErrorLine.svelte";
|
|
26
26
|
import { useFieldName } from "./fieldName.js";
|
|
27
27
|
|
|
28
28
|
// A number input with its two steppers inside the field; the steppers, the
|
|
@@ -67,4 +67,4 @@
|
|
|
67
67
|
class={`glim-num-input glim-num-field glim-num ${className}`.trim()}
|
|
68
68
|
/>
|
|
69
69
|
</span>
|
|
70
|
-
|
|
70
|
+
<FieldErrorLine id={err.errorId} {error} />
|
package/dist/Pagination.svelte
CHANGED
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
<script lang="ts">
|
|
20
20
|
import * as pagination from "@zag-js/pagination";
|
|
21
21
|
import { normalizeProps, useMachine } from "@zag-js/svelte";
|
|
22
|
-
import { PAGINATION_TEXT, pageDir } from "@glimstone/core";
|
|
22
|
+
import { PAGINATION_TEXT, pageDir, watchPaginationFit } from "@glimstone/core";
|
|
23
23
|
import Button from "./Button.svelte";
|
|
24
24
|
import { IconBack, IconForward } from "./glyphs.js";
|
|
25
25
|
|
|
26
26
|
// The pages of a long list, for the place a list cannot show every row at once.
|
|
27
27
|
// The page in force is filled with the accent, as anything chosen is, and the
|
|
28
|
-
// two steps follow the label mode like every other button.
|
|
28
|
+
// two steps follow the label mode like every other button. Where the row has
|
|
29
|
+
// no room, the steps stand as glyphs around "3 / 20" (watchPaginationFit).
|
|
29
30
|
let { count, pageSize = 10, page = $bindable(), onPageChange, siblingCount = 1, text }: PaginationProps = $props();
|
|
30
31
|
|
|
31
32
|
const words = $derived({ ...PAGINATION_TEXT, ...text });
|
|
@@ -47,10 +48,14 @@
|
|
|
47
48
|
},
|
|
48
49
|
}));
|
|
49
50
|
const api = $derived(pagination.connect(service, normalizeProps));
|
|
51
|
+
|
|
52
|
+
let nav: HTMLElement;
|
|
53
|
+
$effect(() => watchPaginationFit(nav));
|
|
50
54
|
</script>
|
|
51
55
|
|
|
52
|
-
<nav data-glim="Pagination" {...api.getRootProps()} class="glim-pagination">
|
|
53
|
-
<Button label={words.previous} labelKey={null} glyph={IconBack} variant="icon" disabled={api.previousPage === null} onClick={() => api.goToPrevPage()} />
|
|
56
|
+
<nav bind:this={nav} data-glim="Pagination" {...api.getRootProps()} class="glim-pagination">
|
|
57
|
+
<Button class="glim-page-step" label={words.previous} labelKey={null} glyph={IconBack} variant="icon" disabled={api.previousPage === null} onClick={() => api.goToPrevPage()} />
|
|
58
|
+
<Button class="glim-page-step-short" label={words.previous} labelKey={null} glyph={IconBack} compact disabled={api.previousPage === null} onClick={() => api.goToPrevPage()} />
|
|
54
59
|
{#each api.pages as p, index (p.type === "page" ? p.value : `gap-${index}`)}
|
|
55
60
|
{#if p.type === "page"}
|
|
56
61
|
<button {...api.getItemProps(p)} class="glim-page glim-num">{p.value}</button>
|
|
@@ -58,5 +63,10 @@
|
|
|
58
63
|
<span {...api.getEllipsisProps({ index })} class="glim-page-gap">…</span>
|
|
59
64
|
{/if}
|
|
60
65
|
{/each}
|
|
61
|
-
<
|
|
66
|
+
<span class="glim-page-status glim-num">
|
|
67
|
+
<span aria-hidden="true">{words.status(api.page, api.totalPages)}</span>
|
|
68
|
+
<span class="glim-sr-only">{words.page(api.page, api.totalPages)}</span>
|
|
69
|
+
</span>
|
|
70
|
+
<Button class="glim-page-step" label={words.next} labelKey={null} glyph={IconForward} variant="icon" disabled={api.nextPage === null} onClick={() => api.goToNextPage()} />
|
|
71
|
+
<Button class="glim-page-step-short" label={words.next} labelKey={null} glyph={IconForward} compact disabled={api.nextPage === null} onClick={() => api.goToNextPage()} />
|
|
62
72
|
</nav>
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
|
|
26
26
|
<script lang="ts">
|
|
27
27
|
import { fieldErrorView, fieldNoteView, fieldWidthClass, PASSWORD_FIELD_TEXT, passwordConfirmView } from "@glimstone/core";
|
|
28
|
-
import
|
|
28
|
+
import FieldErrorLine from "./FieldErrorLine.svelte";
|
|
29
29
|
import { useFieldName } from "./fieldName.js";
|
|
30
|
-
import { IconEye, IconEyeOff } from "./glyphs.js";
|
|
31
30
|
import IconTipButton from "./IconTipButton.svelte";
|
|
31
|
+
import RevealEye from "./RevealEye.svelte";
|
|
32
32
|
|
|
33
33
|
// A field for a secret with the reveal eye inside it ("The reveal eye" in the
|
|
34
34
|
// design language). The props are a native <input>'s, so a call site swaps
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
class="glim-input"
|
|
86
86
|
/>
|
|
87
87
|
<IconTipButton {...eyeAttrs} tip={shown ? words.hide : words.show} class="glim-secret-eye" disabled={!!disabled} onclick={() => (shown = !shown)}>
|
|
88
|
-
{
|
|
88
|
+
<RevealEye struck={shown} />
|
|
89
89
|
</IconTipButton>
|
|
90
90
|
</span>
|
|
91
|
-
|
|
91
|
+
<FieldErrorLine id={err.errorId} {error} />
|
|
92
92
|
{#if quiet.noteId}<span id={quiet.noteId} class="glim-field-note">{note}</span>{/if}
|
|
93
93
|
{#if confirm && view.shown}
|
|
94
94
|
<span class="glim-secret-confirm">
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
autocomplete="new-password"
|
|
101
101
|
spellcheck={false}
|
|
102
102
|
bind:value={repeat}
|
|
103
|
+
placeholder={words.again}
|
|
103
104
|
aria-invalid={mismatch.invalid}
|
|
104
105
|
aria-describedby={mismatch.describedBy}
|
|
105
106
|
{disabled}
|
|
@@ -107,11 +108,11 @@
|
|
|
107
108
|
class="glim-input"
|
|
108
109
|
/>
|
|
109
110
|
<IconTipButton tip={repeatShown ? words.hide : words.show} class="glim-secret-eye" disabled={!!disabled} onclick={() => (repeatShown = !repeatShown)}>
|
|
110
|
-
{
|
|
111
|
+
<RevealEye struck={repeatShown} />
|
|
111
112
|
</IconTipButton>
|
|
112
113
|
</span>
|
|
113
114
|
<span aria-live="polite" class="glim-secret-confirm-live">
|
|
114
|
-
|
|
115
|
+
<FieldErrorLine id={mismatch.errorId} error={view.mismatch ? words.mismatch : undefined} />
|
|
115
116
|
</span>
|
|
116
117
|
</span>
|
|
117
118
|
</span>
|
package/dist/PinInput.svelte
CHANGED
|
@@ -26,12 +26,13 @@
|
|
|
26
26
|
<script lang="ts">
|
|
27
27
|
import * as pinInput from "@zag-js/pin-input";
|
|
28
28
|
import { normalizeProps, useMachine } from "@zag-js/svelte";
|
|
29
|
-
import { PIN_INPUT_TEXT, pinCells } from "@glimstone/core";
|
|
29
|
+
import { PIN_INPUT_TEXT, pinCells, pinGroupStarts } from "@glimstone/core";
|
|
30
30
|
import { useFieldName } from "./fieldName.js";
|
|
31
31
|
|
|
32
32
|
// A short code typed one character to a box, such as the six digits of a
|
|
33
33
|
// second factor. A code is data, so the boxes run left to right in every
|
|
34
|
-
// language
|
|
34
|
+
// language, and a code of six or nine stands in groups of three. Inside a
|
|
35
|
+
// FieldRow the row names it.
|
|
35
36
|
let {
|
|
36
37
|
label,
|
|
37
38
|
value = $bindable(),
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
<label {...api.getLabelProps()} class={label === undefined ? "glim-sr-only" : "glim-field-label"}>{name()}</label>
|
|
75
76
|
<div {...api.getControlProps()} class="glim-pin-control">
|
|
76
77
|
{#each api.items as index (index)}
|
|
78
|
+
{#if pinGroupStarts(index, length)}<span class="glim-pin-sep" aria-hidden="true"></span>{/if}
|
|
77
79
|
<input {...api.getInputProps({ index })} class="glim-input glim-pin-cell glim-num" />
|
|
78
80
|
{/each}
|
|
79
81
|
</div>
|
package/dist/Rating.svelte
CHANGED
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
|
|
34
34
|
const name = useFieldName(() => label);
|
|
35
35
|
const words = $derived({ ...RATING_TEXT, ...text });
|
|
36
|
+
// Counts the picks: the stylesheet names one spring per parity, so a second
|
|
37
|
+
// pick of the same star springs again.
|
|
38
|
+
let picks = $state(0);
|
|
36
39
|
const id = $props.id();
|
|
37
40
|
const service = useMachine(ratingGroup.machine, () => ({
|
|
38
41
|
id,
|
|
@@ -43,6 +46,7 @@
|
|
|
43
46
|
readOnly,
|
|
44
47
|
disabled,
|
|
45
48
|
onValueChange: (d: { value: number }) => {
|
|
49
|
+
picks += 1;
|
|
46
50
|
value = d.value;
|
|
47
51
|
onChange?.(d.value);
|
|
48
52
|
},
|
|
@@ -55,7 +59,12 @@
|
|
|
55
59
|
<label {...api.getLabelProps()} class={label === undefined ? "glim-sr-only" : "glim-field-label"}>{name()}</label>
|
|
56
60
|
<div {...api.getControlProps()} class="glim-rating-control">
|
|
57
61
|
{#each api.items as index (index)}
|
|
58
|
-
<span
|
|
62
|
+
<span
|
|
63
|
+
{...api.getItemProps({ index })}
|
|
64
|
+
data-pop={picks > 0 && index === Math.ceil(api.value) ? (picks % 2 ? "odd" : "even") : undefined}
|
|
65
|
+
style:--i={index - 1}
|
|
66
|
+
class="glim-rating-star"
|
|
67
|
+
>
|
|
59
68
|
{@render IconStar()}
|
|
60
69
|
<span class="glim-rating-fill" aria-hidden="true">{@render IconStar()}</span>
|
|
61
70
|
</span>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { MARKS } from "@glimstone/core";
|
|
3
|
+
|
|
4
|
+
// The eye, with a stroke that draws itself through it once the secret shows.
|
|
5
|
+
// The stroke cuts a gap into the eye behind it, so it reads on the filled glyph.
|
|
6
|
+
let { struck }: { struck: boolean } = $props();
|
|
7
|
+
const cut = $props.id();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<svg width="16" height="16" viewBox="0 0 14 14" fill="currentColor" aria-hidden="true" data-struck={struck ? "" : undefined} class="glim-mark">
|
|
11
|
+
<mask id={cut} maskUnits="userSpaceOnUse" x="0" y="0" width="14" height="14">
|
|
12
|
+
<rect width="14" height="14" fill="white" />
|
|
13
|
+
<path d="M1.6 1.6 12.4 12.4" stroke="black" stroke-width="3.4" pathLength="1" stroke-dasharray="1" stroke-dashoffset={struck ? 0 : 1} stroke-linecap="round" fill="none" class="glim-secret-slash" />
|
|
14
|
+
</mask>
|
|
15
|
+
<g mask="url(#{cut})">{@html MARKS.eye.body}</g>
|
|
16
|
+
<path d="M1.6 1.6 12.4 12.4" stroke="currentColor" stroke-width="1.5" pathLength="1" stroke-dasharray="1" stroke-dashoffset={struck ? 0 : 1} stroke-linecap="round" fill="none" class="glim-secret-slash" />
|
|
17
|
+
</svg>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { searchParts } from "@glimstone/core";
|
|
3
|
+
|
|
4
|
+
// A row's label in a list that filters as somebody types, with the part
|
|
5
|
+
// that matches the search set apart.
|
|
6
|
+
let { label, query }: { label: string; query: string } = $props();
|
|
7
|
+
const parts = $derived(searchParts(label, query));
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{#if parts}{parts.before}<span class="glim-combobox-hit">{parts.hit}</span>{parts.after}{:else}{label}{/if}
|
package/dist/Selector.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
2
|
+
import type { LabelMode, SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
3
3
|
import type { SelectorItem } from "./selectorItem.js";
|
|
4
4
|
|
|
5
5
|
export type { SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
onPress?: (id: V) => void;
|
|
21
21
|
/** `vertical` is the column of tiles beside a settings area's pages. */
|
|
22
22
|
orientation?: SelectorOrientation;
|
|
23
|
+
/** The label mode of this strip alone, in place of the app's setting, for a
|
|
24
|
+
* strip that has to speak in glyphs, words or both whatever the rest does. */
|
|
25
|
+
labels?: LabelMode;
|
|
26
|
+
|
|
23
27
|
size?: SelectorSize;
|
|
24
28
|
variant?: SelectorVariant;
|
|
25
29
|
/** "manual" moves the focus with the arrows and chooses on Space, Enter or a
|
|
@@ -37,8 +41,6 @@
|
|
|
37
41
|
* alone where every segment has one, a strip of one turns into a dropdown
|
|
38
42
|
* otherwise, and a `many` strip cuts its labels short. */
|
|
39
43
|
fit?: boolean;
|
|
40
|
-
/** Has no effect: every strip keeps to one row. */
|
|
41
|
-
pairsOnPhone?: boolean;
|
|
42
44
|
/** The button height for every segment, for a strip beside a Button. */
|
|
43
45
|
buttonHeight?: boolean;
|
|
44
46
|
/** Take a colour under rainbow. Turn it off where the colour means nothing,
|
|
@@ -67,8 +69,11 @@
|
|
|
67
69
|
selectorFlex,
|
|
68
70
|
selectorView,
|
|
69
71
|
subscribeMedia,
|
|
72
|
+
slideTabPanel,
|
|
73
|
+
tabSlideDir,
|
|
70
74
|
toggleSelection,
|
|
71
75
|
watchSelectorFit,
|
|
76
|
+
watchSelectorThumb,
|
|
72
77
|
WIDE_QUERY,
|
|
73
78
|
type SelectorLayout,
|
|
74
79
|
} from "@glimstone/core";
|
|
@@ -94,6 +99,7 @@
|
|
|
94
99
|
onChange,
|
|
95
100
|
onPress,
|
|
96
101
|
orientation = "horizontal",
|
|
102
|
+
labels,
|
|
97
103
|
size = "md",
|
|
98
104
|
variant = "well",
|
|
99
105
|
activation = "auto",
|
|
@@ -118,7 +124,7 @@
|
|
|
118
124
|
$effect(() => subscribeMedia(WIDE_QUERY, () => (wide = mediaMatches(WIDE_QUERY))));
|
|
119
125
|
const strip = $derived(
|
|
120
126
|
selectorView({
|
|
121
|
-
mode: mode.current,
|
|
127
|
+
mode: labels ?? mode.current,
|
|
122
128
|
select: many ? "many" : "one",
|
|
123
129
|
activation,
|
|
124
130
|
orientation,
|
|
@@ -171,6 +177,23 @@
|
|
|
171
177
|
|
|
172
178
|
const flex = $derived(selectorFlex({ layout, inline, fit }));
|
|
173
179
|
|
|
180
|
+
// One value glides: a thumb under the segments carries the fill from the
|
|
181
|
+
// old choice to the new one. Toggles in a `many` strip each keep their own.
|
|
182
|
+
const gliding = $derived(!vertical && !many);
|
|
183
|
+
$effect(() => {
|
|
184
|
+
if (gliding) return watchSelectorThumb(track);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// A tab strip moves its panel in from the side of the tab it came from.
|
|
188
|
+
const chosenIndex = $derived(many ? -1 : items.findIndex((it) => it.id === value));
|
|
189
|
+
let lastIndex = -1;
|
|
190
|
+
$effect(() => {
|
|
191
|
+
const to = chosenIndex;
|
|
192
|
+
const dir = tabSlideDir(lastIndex, to);
|
|
193
|
+
lastIndex = to;
|
|
194
|
+
if (dir && panelId && strip.kind === "tab") slideTabPanel(document.getElementById(panelId), dir);
|
|
195
|
+
});
|
|
196
|
+
|
|
174
197
|
// countSelector writes the strip's colour onto the track's style itself, so
|
|
175
198
|
// the layout's properties go on one by one rather than as style text.
|
|
176
199
|
$effect(() => {
|
|
@@ -220,6 +243,7 @@
|
|
|
220
243
|
onkeydown={onKeyDown}
|
|
221
244
|
class={`${strip.className}${listed ? " glim-sel--listed" : ""} ${className}`.trim()}
|
|
222
245
|
>
|
|
246
|
+
{#if gliding}<span class="glim-sel-thumb" aria-hidden="true"></span>{/if}
|
|
223
247
|
{#each items as item, i (item.id)}
|
|
224
248
|
<SelectorSegment
|
|
225
249
|
{item}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
1
|
+
import type { LabelMode, SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
2
2
|
import type { SelectorItem } from "./selectorItem.js";
|
|
3
3
|
export type { SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
4
4
|
export type { SelectorItem } from "./selectorItem.js";
|
|
@@ -17,6 +17,9 @@ export interface SelectorProps<M extends SelectMode = "one", V extends string |
|
|
|
17
17
|
onPress?: (id: V) => void;
|
|
18
18
|
/** `vertical` is the column of tiles beside a settings area's pages. */
|
|
19
19
|
orientation?: SelectorOrientation;
|
|
20
|
+
/** The label mode of this strip alone, in place of the app's setting, for a
|
|
21
|
+
* strip that has to speak in glyphs, words or both whatever the rest does. */
|
|
22
|
+
labels?: LabelMode;
|
|
20
23
|
size?: SelectorSize;
|
|
21
24
|
variant?: SelectorVariant;
|
|
22
25
|
/** "manual" moves the focus with the arrows and chooses on Space, Enter or a
|
|
@@ -34,8 +37,6 @@ export interface SelectorProps<M extends SelectMode = "one", V extends string |
|
|
|
34
37
|
* alone where every segment has one, a strip of one turns into a dropdown
|
|
35
38
|
* otherwise, and a `many` strip cuts its labels short. */
|
|
36
39
|
fit?: boolean;
|
|
37
|
-
/** Has no effect: every strip keeps to one row. */
|
|
38
|
-
pairsOnPhone?: boolean;
|
|
39
40
|
/** The button height for every segment, for a strip beside a Button. */
|
|
40
41
|
buttonHeight?: boolean;
|
|
41
42
|
/** Take a colour under rainbow. Turn it off where the colour means nothing,
|