@glimstone/svelte 0.0.0-stage → 4.5.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/README.md +53 -2
- package/dist/AboutCard.svelte +87 -0
- package/dist/AboutCard.svelte.d.ts +37 -0
- package/dist/Accordion.svelte +60 -0
- package/dist/Accordion.svelte.d.ts +38 -0
- package/dist/AngleSlider.svelte +56 -0
- package/dist/AngleSlider.svelte.d.ts +13 -0
- package/dist/Avatar.svelte +37 -0
- package/dist/Avatar.svelte.d.ts +13 -0
- package/dist/Badge.svelte +119 -0
- package/dist/Badge.svelte.d.ts +54 -0
- package/dist/BrandMark.svelte +12 -0
- package/dist/BrandMark.svelte.d.ts +6 -0
- package/dist/BusyRing.svelte +39 -0
- package/dist/BusyRing.svelte.d.ts +15 -0
- package/dist/Button.svelte +172 -0
- package/dist/Button.svelte.d.ts +57 -0
- package/dist/Card.svelte +61 -0
- package/dist/Card.svelte.d.ts +23 -0
- package/dist/Carousel.svelte +72 -0
- package/dist/Carousel.svelte.d.ts +41 -0
- package/dist/Checkbox.svelte +48 -0
- package/dist/Checkbox.svelte.d.ts +17 -0
- package/dist/CoffeeDialog.svelte +70 -0
- package/dist/CoffeeDialog.svelte.d.ts +18 -0
- package/dist/Collapsible.svelte +49 -0
- package/dist/Collapsible.svelte.d.ts +14 -0
- package/dist/ColorPicker.svelte +122 -0
- package/dist/ColorPicker.svelte.d.ts +23 -0
- package/dist/Combobox.svelte +87 -0
- package/dist/Combobox.svelte.d.ts +18 -0
- package/dist/ConfirmDialog.svelte +106 -0
- package/dist/ConfirmDialog.svelte.d.ts +31 -0
- package/dist/ConfirmHost.svelte +41 -0
- package/dist/ConfirmHost.svelte.d.ts +7 -0
- package/dist/ContextMenu.svelte +213 -0
- package/dist/ContextMenu.svelte.d.ts +29 -0
- package/dist/CopyField.svelte +60 -0
- package/dist/CopyField.svelte.d.ts +19 -0
- package/dist/CryptoDonateDialog.svelte +162 -0
- package/dist/CryptoDonateDialog.svelte.d.ts +37 -0
- package/dist/DatePicker.svelte +149 -0
- package/dist/DatePicker.svelte.d.ts +18 -0
- package/dist/DropdownListbox.svelte +178 -0
- package/dist/DropdownListbox.svelte.d.ts +23 -0
- package/dist/EmptyState.svelte +31 -0
- package/dist/EmptyState.svelte.d.ts +16 -0
- package/dist/FieldError.svelte +20 -0
- package/dist/FieldError.svelte.d.ts +8 -0
- package/dist/FieldRow.svelte +52 -0
- package/dist/FieldRow.svelte.d.ts +23 -0
- package/dist/FieldRowGroup.svelte +33 -0
- package/dist/FieldRowGroup.svelte.d.ts +13 -0
- package/dist/FileUpload.svelte +74 -0
- package/dist/FileUpload.svelte.d.ts +18 -0
- package/dist/FloatingPanel.svelte +89 -0
- package/dist/FloatingPanel.svelte.d.ts +17 -0
- package/dist/Fortress.svelte +222 -0
- package/dist/Fortress.svelte.d.ts +62 -0
- package/dist/FortressAppCard.svelte +115 -0
- package/dist/FortressAppCard.svelte.d.ts +18 -0
- package/dist/FortressDoubtWindow.svelte +37 -0
- package/dist/FortressDoubtWindow.svelte.d.ts +12 -0
- package/dist/FortressPairing.svelte +85 -0
- package/dist/FortressPairing.svelte.d.ts +32 -0
- package/dist/FortressPermissions.svelte +93 -0
- package/dist/FortressPermissions.svelte.d.ts +24 -0
- package/dist/FortressStatusWindow.svelte +128 -0
- package/dist/FortressStatusWindow.svelte.d.ts +20 -0
- package/dist/FortressWindow.svelte +271 -0
- package/dist/FortressWindow.svelte.d.ts +18 -0
- package/dist/GlyphField.svelte +52 -0
- package/dist/GlyphField.svelte.d.ts +20 -0
- package/dist/GlyphTile.svelte +25 -0
- package/dist/GlyphTile.svelte.d.ts +14 -0
- package/dist/HoverCard.svelte +47 -0
- package/dist/HoverCard.svelte.d.ts +14 -0
- package/dist/IconButton.svelte +49 -0
- package/dist/IconButton.svelte.d.ts +20 -0
- package/dist/IconTipButton.svelte +67 -0
- package/dist/IconTipButton.svelte.d.ts +23 -0
- package/dist/InfoAboutCard.svelte +65 -0
- package/dist/InfoAboutCard.svelte.d.ts +35 -0
- package/dist/InfoBubble.svelte +50 -0
- package/dist/InfoBubble.svelte.d.ts +7 -0
- package/dist/InfoHelpCard.svelte +93 -0
- package/dist/InfoHelpCard.svelte.d.ts +44 -0
- package/dist/InfoTile.svelte +31 -0
- package/dist/InfoTile.svelte.d.ts +15 -0
- package/dist/InfoVersionCard.svelte +99 -0
- package/dist/InfoVersionCard.svelte.d.ts +29 -0
- package/dist/InstanceCard.svelte +85 -0
- package/dist/InstanceCard.svelte.d.ts +27 -0
- package/dist/Kbd.svelte +16 -0
- package/dist/Kbd.svelte.d.ts +8 -0
- package/dist/ListRow.svelte +51 -0
- package/dist/ListRow.svelte.d.ts +19 -0
- package/dist/ListSelect.svelte +135 -0
- package/dist/ListSelect.svelte.d.ts +25 -0
- package/dist/ListTable.svelte +183 -0
- package/dist/ListTable.svelte.d.ts +44 -0
- package/dist/MarkSvg.svelte +9 -0
- package/dist/MarkSvg.svelte.d.ts +8 -0
- package/dist/Marquee.svelte +63 -0
- package/dist/Marquee.svelte.d.ts +39 -0
- package/dist/MenuBar.svelte +98 -0
- package/dist/MenuBar.svelte.d.ts +19 -0
- package/dist/MenuChoice.svelte +30 -0
- package/dist/MenuChoice.svelte.d.ts +33 -0
- package/dist/MenuHeadEdit.svelte +29 -0
- package/dist/MenuHeadEdit.svelte.d.ts +10 -0
- package/dist/MenuRows.svelte +57 -0
- package/dist/MenuRows.svelte.d.ts +9 -0
- package/dist/MenuSelect.svelte +145 -0
- package/dist/MenuSelect.svelte.d.ts +25 -0
- package/dist/MenuSubmenu.svelte +64 -0
- package/dist/MenuSubmenu.svelte.d.ts +37 -0
- package/dist/Meter.svelte +55 -0
- package/dist/Meter.svelte.d.ts +20 -0
- package/dist/NumberField.svelte +70 -0
- package/dist/NumberField.svelte.d.ts +23 -0
- package/dist/Pagination.svelte +62 -0
- package/dist/Pagination.svelte.d.ts +16 -0
- package/dist/PasswordField.svelte +69 -0
- package/dist/PasswordField.svelte.d.ts +21 -0
- package/dist/PathField.svelte +111 -0
- package/dist/PathField.svelte.d.ts +33 -0
- package/dist/PaypalDialog.svelte +174 -0
- package/dist/PaypalDialog.svelte.d.ts +54 -0
- package/dist/Pill.svelte +25 -0
- package/dist/Pill.svelte.d.ts +14 -0
- package/dist/PinInput.svelte +81 -0
- package/dist/PinInput.svelte.d.ts +23 -0
- package/dist/Popover.svelte +38 -0
- package/dist/Popover.svelte.d.ts +16 -0
- package/dist/PresenceBadges.svelte +22 -0
- package/dist/PresenceBadges.svelte.d.ts +8 -0
- package/dist/ProgressBar.svelte +37 -0
- package/dist/ProgressBar.svelte.d.ts +16 -0
- package/dist/Rating.svelte +65 -0
- package/dist/Rating.svelte.d.ts +18 -0
- package/dist/ReadmeButton.svelte +82 -0
- package/dist/ReadmeButton.svelte.d.ts +27 -0
- package/dist/RowMark.svelte +16 -0
- package/dist/RowMark.svelte.d.ts +7 -0
- package/dist/ScrollArea.svelte +46 -0
- package/dist/ScrollArea.svelte.d.ts +11 -0
- package/dist/Select.svelte +97 -0
- package/dist/Select.svelte.d.ts +67 -0
- package/dist/SelectFace.svelte +18 -0
- package/dist/SelectFace.svelte.d.ts +32 -0
- package/dist/Selector.svelte +264 -0
- package/dist/Selector.svelte.d.ts +77 -0
- package/dist/SelectorSegment.svelte +159 -0
- package/dist/SelectorSegment.svelte.d.ts +27 -0
- package/dist/Sheet.svelte +51 -0
- package/dist/Sheet.svelte.d.ts +23 -0
- package/dist/SidebarRow.svelte +91 -0
- package/dist/SidebarRow.svelte.d.ts +31 -0
- package/dist/SignInCard.svelte +251 -0
- package/dist/SignInCard.svelte.d.ts +34 -0
- package/dist/SignInField.svelte +32 -0
- package/dist/SignInField.svelte.d.ts +11 -0
- package/dist/SignaturePad.svelte +72 -0
- package/dist/SignaturePad.svelte.d.ts +13 -0
- package/dist/SkeletonRow.svelte +29 -0
- package/dist/SkeletonRow.svelte.d.ts +12 -0
- package/dist/Slider.svelte +60 -0
- package/dist/Slider.svelte.d.ts +15 -0
- package/dist/Splitter.svelte +59 -0
- package/dist/Splitter.svelte.d.ts +37 -0
- package/dist/Steps.svelte +90 -0
- package/dist/Steps.svelte.d.ts +40 -0
- package/dist/SubCard.svelte +45 -0
- package/dist/SubCard.svelte.d.ts +14 -0
- package/dist/Table.svelte +48 -0
- package/dist/Table.svelte.d.ts +37 -0
- package/dist/TagsInput.svelte +77 -0
- package/dist/TagsInput.svelte.d.ts +18 -0
- package/dist/TextArea.svelte +55 -0
- package/dist/TextArea.svelte.d.ts +17 -0
- package/dist/TextField.svelte +61 -0
- package/dist/TextField.svelte.d.ts +18 -0
- package/dist/Timer.svelte +62 -0
- package/dist/Timer.svelte.d.ts +17 -0
- package/dist/TipBubble.svelte +11 -0
- package/dist/TipBubble.svelte.d.ts +7 -0
- package/dist/TipWrap.svelte +15 -0
- package/dist/TipWrap.svelte.d.ts +10 -0
- package/dist/ToastCard.svelte +68 -0
- package/dist/ToastCard.svelte.d.ts +18 -0
- package/dist/ToastViewport.svelte +65 -0
- package/dist/ToastViewport.svelte.d.ts +14 -0
- package/dist/Toggle.svelte +84 -0
- package/dist/Toggle.svelte.d.ts +25 -0
- package/dist/Tour.svelte +75 -0
- package/dist/Tour.svelte.d.ts +12 -0
- package/dist/Tree.svelte +122 -0
- package/dist/Tree.svelte.d.ts +22 -0
- package/dist/UnavailableNotice.svelte +36 -0
- package/dist/UnavailableNotice.svelte.d.ts +18 -0
- package/dist/Window.svelte +108 -0
- package/dist/Window.svelte.d.ts +33 -0
- package/dist/WindowBar.svelte +76 -0
- package/dist/WindowBar.svelte.d.ts +26 -0
- package/dist/WindowFootRow.svelte +67 -0
- package/dist/WindowFootRow.svelte.d.ts +28 -0
- package/dist/bubble.svelte.d.ts +15 -0
- package/dist/bubble.svelte.js +66 -0
- package/dist/confirm.svelte.d.ts +37 -0
- package/dist/confirm.svelte.js +62 -0
- package/dist/engines.svelte.d.ts +18 -0
- package/dist/engines.svelte.js +57 -0
- package/dist/entries/accordion.d.ts +1 -0
- package/dist/entries/accordion.js +2 -0
- package/dist/entries/angleslider.d.ts +1 -0
- package/dist/entries/angleslider.js +2 -0
- package/dist/entries/avatar.d.ts +1 -0
- package/dist/entries/avatar.js +2 -0
- package/dist/entries/carousel.d.ts +1 -0
- package/dist/entries/carousel.js +2 -0
- package/dist/entries/collapsible.d.ts +1 -0
- package/dist/entries/collapsible.js +2 -0
- package/dist/entries/combobox.d.ts +1 -0
- package/dist/entries/combobox.js +2 -0
- package/dist/entries/datepicker.d.ts +1 -0
- package/dist/entries/datepicker.js +2 -0
- package/dist/entries/fileupload.d.ts +1 -0
- package/dist/entries/fileupload.js +2 -0
- package/dist/entries/floatingpanel.d.ts +1 -0
- package/dist/entries/floatingpanel.js +2 -0
- package/dist/entries/hovercard.d.ts +1 -0
- package/dist/entries/hovercard.js +2 -0
- package/dist/entries/marquee.d.ts +1 -0
- package/dist/entries/marquee.js +2 -0
- package/dist/entries/pagination.d.ts +1 -0
- package/dist/entries/pagination.js +2 -0
- package/dist/entries/pininput.d.ts +1 -0
- package/dist/entries/pininput.js +2 -0
- package/dist/entries/rating.d.ts +1 -0
- package/dist/entries/rating.js +2 -0
- package/dist/entries/scrollarea.d.ts +1 -0
- package/dist/entries/scrollarea.js +2 -0
- package/dist/entries/select.d.ts +1 -0
- package/dist/entries/select.js +2 -0
- package/dist/entries/signaturepad.d.ts +1 -0
- package/dist/entries/signaturepad.js +2 -0
- package/dist/entries/slider.d.ts +1 -0
- package/dist/entries/slider.js +2 -0
- package/dist/entries/splitter.d.ts +1 -0
- package/dist/entries/splitter.js +2 -0
- package/dist/entries/steps.d.ts +1 -0
- package/dist/entries/steps.js +2 -0
- package/dist/entries/tagsinput.d.ts +1 -0
- package/dist/entries/tagsinput.js +2 -0
- package/dist/entries/timer.d.ts +1 -0
- package/dist/entries/timer.js +2 -0
- package/dist/entries/tour.d.ts +1 -0
- package/dist/entries/tour.js +2 -0
- package/dist/fieldName.d.ts +4 -0
- package/dist/fieldName.js +9 -0
- package/dist/fortressParts.d.ts +5 -0
- package/dist/fortressParts.js +16 -0
- package/dist/glyphs.d.ts +32 -0
- package/dist/glyphs.js +47 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +77 -0
- package/dist/lift.d.ts +5 -0
- package/dist/lift.js +9 -0
- package/dist/portalHue.svelte.d.ts +9 -0
- package/dist/portalHue.svelte.js +16 -0
- package/dist/selectParts.svelte.d.ts +39 -0
- package/dist/selectParts.svelte.js +28 -0
- package/dist/selectorItem.d.ts +22 -0
- package/dist/selectorItem.js +1 -0
- package/dist/style.d.ts +5 -0
- package/dist/style.js +12 -0
- package/dist/useDragArmed.svelte.d.ts +6 -0
- package/dist/useDragArmed.svelte.js +24 -0
- package/dist/usePaypalButtons.svelte.d.ts +18 -0
- package/dist/usePaypalButtons.svelte.js +41 -0
- package/package.json +173 -4
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { SelectRows, SelectSize, SelectWidth } from "@glimstone/core";
|
|
2
|
+
import type { SelectGroup, SelectOption } from "./selectParts.svelte.js";
|
|
3
|
+
export type { SelectEntry, SelectGroup, SelectOption, SelectSubmenu } from "./selectParts.svelte.js";
|
|
4
|
+
export type { SelectRows, SelectSize, SelectWidth } from "@glimstone/core";
|
|
5
|
+
export interface SelectProps<T extends string = string> {
|
|
6
|
+
/** The field's name, always the accessible name. Inside a FieldRow the row gives it and draws the words. */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** Draw the label off screen, for a settings row that names the field at its start. */
|
|
9
|
+
hideLabel?: boolean;
|
|
10
|
+
/** Every choice, in list order, for a list without groups. */
|
|
11
|
+
options?: SelectOption<T>[];
|
|
12
|
+
/** The list in runs, with headings and submenus. The wheel steps through every option in list order. */
|
|
13
|
+
groups?: SelectGroup<T>[];
|
|
14
|
+
/** Bound with `bind:value`. Null when there is no one value, such as over a selection whose rows disagree. */
|
|
15
|
+
value: T | null;
|
|
16
|
+
onChange?: (value: T) => void;
|
|
17
|
+
/** Shown while the value is null. */
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
/** Defaults to `fill` for a field and to `steady` for the smaller sizes and inside a FieldRow. */
|
|
20
|
+
width?: SelectWidth;
|
|
21
|
+
size?: SelectSize;
|
|
22
|
+
/** `menu` draws the open list with a context menu's rows, so an app with both shows one kind of menu row. */
|
|
23
|
+
rows?: SelectRows;
|
|
24
|
+
/** Lets a long value run onto a second line instead of ending in an ellipsis, for one whose end says as much as its start, such as a path. */
|
|
25
|
+
wrap?: boolean;
|
|
26
|
+
/** The trigger's id, for a `<label for>` outside the select. */
|
|
27
|
+
id?: string;
|
|
28
|
+
/** Attributes for the trigger, such as a data hook that says the value. */
|
|
29
|
+
triggerAttrs?: Record<string, string>;
|
|
30
|
+
/** The open list's id. */
|
|
31
|
+
listId?: string;
|
|
32
|
+
/** The trigger's own node, bound with `bind:ref`, for a caller that hands it the focus. */
|
|
33
|
+
ref?: HTMLButtonElement | null;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/** A choice is out and its answer not back yet: the trigger keeps its focus but takes no input. */
|
|
36
|
+
busy?: boolean;
|
|
37
|
+
/** A hover bubble, for a trigger with no label beside it whose value does not say what it picks. */
|
|
38
|
+
tip?: string;
|
|
39
|
+
/** The caller's failure counter. Each bump shakes the trigger once, as the value snaps back. */
|
|
40
|
+
shake?: number;
|
|
41
|
+
/** Classes for the trigger, for a size the call site needs. */
|
|
42
|
+
class?: string;
|
|
43
|
+
}
|
|
44
|
+
declare function $$render<T extends string>(): {
|
|
45
|
+
props: SelectProps<T>;
|
|
46
|
+
exports: {};
|
|
47
|
+
bindings: "value" | "ref";
|
|
48
|
+
slots: {};
|
|
49
|
+
events: {};
|
|
50
|
+
};
|
|
51
|
+
declare class __sveltets_Render<T extends string> {
|
|
52
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
53
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
54
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
55
|
+
bindings(): "value" | "ref";
|
|
56
|
+
exports(): {};
|
|
57
|
+
}
|
|
58
|
+
interface $$IsomorphicComponent {
|
|
59
|
+
new <T extends string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
60
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
61
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
62
|
+
<T extends string>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
63
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
64
|
+
}
|
|
65
|
+
declare const Select: $$IsomorphicComponent;
|
|
66
|
+
type Select<T extends string> = InstanceType<typeof Select<T>>;
|
|
67
|
+
export default Select;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts" generics="T extends string">
|
|
2
|
+
import { faceLabels, type SelectWidth } from "@glimstone/core";
|
|
3
|
+
import type { SelectOption } from "./selectParts.svelte.js";
|
|
4
|
+
|
|
5
|
+
// The value on the trigger; see faceLabels in the core.
|
|
6
|
+
let { all, value, placeholder, width, glyphs }: { all: SelectOption<T>[]; value: T | null; placeholder?: string; width: SelectWidth; glyphs: boolean } = $props();
|
|
7
|
+
const face = $derived(faceLabels(all, value, placeholder, width));
|
|
8
|
+
const glyph = $derived(all.find((o) => o.value === value)?.glyph);
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
{#if glyphs}
|
|
12
|
+
<span class="glim-select-glyph">{@render glyph?.()}</span>
|
|
13
|
+
{/if}
|
|
14
|
+
<span class="glim-select-value">
|
|
15
|
+
{#each face.labels as l (l)}
|
|
16
|
+
<span aria-hidden={l !== face.text || undefined} class={l === face.text ? undefined : "glim-select-ghost"}>{l}</span>
|
|
17
|
+
{/each}
|
|
18
|
+
</span>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type SelectWidth } from "@glimstone/core";
|
|
2
|
+
import type { SelectOption } from "./selectParts.svelte.js";
|
|
3
|
+
declare function $$render<T extends string>(): {
|
|
4
|
+
props: {
|
|
5
|
+
all: SelectOption<T>[];
|
|
6
|
+
value: T | null;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
width: SelectWidth;
|
|
9
|
+
glyphs: boolean;
|
|
10
|
+
};
|
|
11
|
+
exports: {};
|
|
12
|
+
bindings: "";
|
|
13
|
+
slots: {};
|
|
14
|
+
events: {};
|
|
15
|
+
};
|
|
16
|
+
declare class __sveltets_Render<T extends string> {
|
|
17
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
18
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
19
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
20
|
+
bindings(): "";
|
|
21
|
+
exports(): {};
|
|
22
|
+
}
|
|
23
|
+
interface $$IsomorphicComponent {
|
|
24
|
+
new <T extends string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
25
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
26
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
27
|
+
<T extends string>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
28
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
29
|
+
}
|
|
30
|
+
declare const SelectFace: $$IsomorphicComponent;
|
|
31
|
+
type SelectFace<T extends string> = InstanceType<typeof SelectFace<T>>;
|
|
32
|
+
export default SelectFace;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
3
|
+
import type { SelectorItem } from "./selectorItem.js";
|
|
4
|
+
|
|
5
|
+
export type { SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
6
|
+
export type { SelectorItem } from "./selectorItem.js";
|
|
7
|
+
export { selectorTabId } from "@glimstone/core";
|
|
8
|
+
|
|
9
|
+
export interface SelectorProps<M extends SelectMode = "one", V extends string | number = string> {
|
|
10
|
+
items: SelectorItem<V>[];
|
|
11
|
+
/** The accessible name of the strip, such as "Sort" or "Settings pages". Inside a FieldRow the row gives it. */
|
|
12
|
+
label?: string;
|
|
13
|
+
/** `one` picks a value, `many` toggles any number of them. Default `one`. */
|
|
14
|
+
select?: M;
|
|
15
|
+
/** The chosen id, or the chosen ids for `many`, bound with `bind:value`. */
|
|
16
|
+
value: M extends "many" ? readonly V[] : V | null;
|
|
17
|
+
/** Called with the new id, or the new list for `many`. */
|
|
18
|
+
onChange?: (next: M extends "many" ? V[] : V) => void;
|
|
19
|
+
/** Called on every press and every arrow key that chooses, before the choice changes, also one on the segment already chosen. */
|
|
20
|
+
onPress?: (id: V) => void;
|
|
21
|
+
/** `vertical` is the column of tiles beside a settings area's pages. */
|
|
22
|
+
orientation?: SelectorOrientation;
|
|
23
|
+
size?: SelectorSize;
|
|
24
|
+
variant?: SelectorVariant;
|
|
25
|
+
/** "manual" moves the focus with the arrows and chooses on Space, Enter or a
|
|
26
|
+
* click, as a radio group; for a strip that saves a setting. */
|
|
27
|
+
activation?: SelectorActivation;
|
|
28
|
+
/** Pin every segment to the widest one's measured width, at least the shared
|
|
29
|
+
* floor where the row has room; the page-level picker. Where the pinned
|
|
30
|
+
* widths do not fit the row, the segments share it by their labels. */
|
|
31
|
+
equalWidth?: boolean;
|
|
32
|
+
/** Hug the segments instead of spanning the box, for a strip that shares a
|
|
33
|
+
* toolbar row, as it does inside a FieldRow. */
|
|
34
|
+
inline?: boolean;
|
|
35
|
+
/** Share the row evenly without a pinned width, for page tabs. Every strip
|
|
36
|
+
* keeps to one row; once its labels do not fit together it shows glyphs
|
|
37
|
+
* alone where every segment has one, a strip of one turns into a dropdown
|
|
38
|
+
* otherwise, and a `many` strip cuts its labels short. */
|
|
39
|
+
fit?: boolean;
|
|
40
|
+
/** Has no effect: every strip keeps to one row. */
|
|
41
|
+
pairsOnPhone?: boolean;
|
|
42
|
+
/** The button height for every segment, for a strip beside a Button. */
|
|
43
|
+
buttonHeight?: boolean;
|
|
44
|
+
/** Take a colour under rainbow. Turn it off where the colour means nothing,
|
|
45
|
+
* such as a strip of one, not for looks. */
|
|
46
|
+
hue?: boolean;
|
|
47
|
+
/** Makes the strip a tab strip for colour: each segment keeps its own
|
|
48
|
+
* palette position, counting from here. */
|
|
49
|
+
hueOffset?: number;
|
|
50
|
+
/** Disables every item; an item's own `disabled` applies on top. */
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
/** The id of the panel a tab strip switches. The chosen tab controls it, and
|
|
53
|
+
* the panel names itself with `aria-labelledby={selectorTabId(panelId, id)}`. */
|
|
54
|
+
panelId?: string;
|
|
55
|
+
class?: string;
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script lang="ts" generics="M extends SelectMode = 'one', V extends string | number = string">
|
|
60
|
+
import { untrack } from "svelte";
|
|
61
|
+
import {
|
|
62
|
+
countSelector,
|
|
63
|
+
mediaMatches,
|
|
64
|
+
roveSelector,
|
|
65
|
+
rovedIndex,
|
|
66
|
+
selectorAxis,
|
|
67
|
+
selectorFlex,
|
|
68
|
+
selectorView,
|
|
69
|
+
subscribeMedia,
|
|
70
|
+
toggleSelection,
|
|
71
|
+
watchSelectorFit,
|
|
72
|
+
WIDE_QUERY,
|
|
73
|
+
type SelectorLayout,
|
|
74
|
+
} from "@glimstone/core";
|
|
75
|
+
import { useLabelMode } from "./engines.svelte.js";
|
|
76
|
+
import { useFieldName } from "./fieldName.js";
|
|
77
|
+
import Select from "./Select.svelte";
|
|
78
|
+
import SelectorSegment from "./SelectorSegment.svelte";
|
|
79
|
+
|
|
80
|
+
// The one horizontal selector and its vertical form; roles, classes, layout
|
|
81
|
+
// and keys come from selector.ts in the core.
|
|
82
|
+
//
|
|
83
|
+
// A caption such as "Sort by:" belongs in a plain <span> outside it, not a
|
|
84
|
+
// <label> around the row: a label around several segments hands its clicks to
|
|
85
|
+
// the first one and gives a screen reader that segment's name.
|
|
86
|
+
//
|
|
87
|
+
// A strip of one whose labels do not fit its row shows the one dropdown in
|
|
88
|
+
// their place, inside the track, so the track keeps the box it measures.
|
|
89
|
+
let {
|
|
90
|
+
items,
|
|
91
|
+
label,
|
|
92
|
+
select,
|
|
93
|
+
value = $bindable(),
|
|
94
|
+
onChange,
|
|
95
|
+
onPress,
|
|
96
|
+
orientation = "horizontal",
|
|
97
|
+
size = "md",
|
|
98
|
+
variant = "well",
|
|
99
|
+
activation = "auto",
|
|
100
|
+
equalWidth = false,
|
|
101
|
+
inline: ownInline = false,
|
|
102
|
+
fit = false,
|
|
103
|
+
buttonHeight = false,
|
|
104
|
+
hue = true,
|
|
105
|
+
hueOffset,
|
|
106
|
+
disabled = false,
|
|
107
|
+
panelId,
|
|
108
|
+
class: className = "",
|
|
109
|
+
}: SelectorProps<M, V> = $props();
|
|
110
|
+
|
|
111
|
+
const name = useFieldName(() => label);
|
|
112
|
+
const inline = $derived(ownInline || (label === undefined && name() !== undefined));
|
|
113
|
+
const vertical = $derived(orientation === "vertical");
|
|
114
|
+
const many = $derived(select === "many");
|
|
115
|
+
// svelte-ignore state_referenced_locally
|
|
116
|
+
const mode = useLabelMode(selectorAxis(size, orientation));
|
|
117
|
+
let wide = $state(mediaMatches(WIDE_QUERY));
|
|
118
|
+
$effect(() => subscribeMedia(WIDE_QUERY, () => (wide = mediaMatches(WIDE_QUERY))));
|
|
119
|
+
const strip = $derived(
|
|
120
|
+
selectorView({
|
|
121
|
+
mode: mode.current,
|
|
122
|
+
select: many ? "many" : "one",
|
|
123
|
+
activation,
|
|
124
|
+
orientation,
|
|
125
|
+
size,
|
|
126
|
+
variant,
|
|
127
|
+
equalWidth,
|
|
128
|
+
inline,
|
|
129
|
+
fit,
|
|
130
|
+
hue,
|
|
131
|
+
hueOffset,
|
|
132
|
+
wide,
|
|
133
|
+
items: items.map((it) => ({ hasGlyph: !!it.glyph, iconOnly: !!it.iconOnly })),
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
let track: HTMLDivElement;
|
|
137
|
+
|
|
138
|
+
$effect(() => {
|
|
139
|
+
if (strip.counted) return countSelector(track);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Measured again only when something it measures changes, not on every
|
|
143
|
+
// choice. A segment that turns disabled with a tip is mounted afresh inside
|
|
144
|
+
// the bubble's box, so the watch moves to it through the disabled flags.
|
|
145
|
+
let layout = $state<SelectorLayout | null>(null);
|
|
146
|
+
const fitKey = $derived(
|
|
147
|
+
[
|
|
148
|
+
vertical,
|
|
149
|
+
strip.pinWidth,
|
|
150
|
+
fit,
|
|
151
|
+
strip.canSqueeze,
|
|
152
|
+
strip.canList,
|
|
153
|
+
inline,
|
|
154
|
+
items.map((it) => it.label).join("\n"),
|
|
155
|
+
items.map((it) => (disabled || it.disabled ? "1" : "0")).join(""),
|
|
156
|
+
size,
|
|
157
|
+
strip.mode,
|
|
158
|
+
].join("|"),
|
|
159
|
+
);
|
|
160
|
+
$effect(() => {
|
|
161
|
+
void fitKey;
|
|
162
|
+
return untrack(() => {
|
|
163
|
+
if (vertical) {
|
|
164
|
+
layout = null;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const { pinWidth, canSqueeze, canList } = strip;
|
|
168
|
+
return watchSelectorFit(track, { pinWidth, fit, canSqueeze, canList }, (next) => (layout = next));
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const flex = $derived(selectorFlex({ layout, inline, fit }));
|
|
173
|
+
|
|
174
|
+
// countSelector writes the strip's colour onto the track's style itself, so
|
|
175
|
+
// the layout's properties go on one by one rather than as style text.
|
|
176
|
+
$effect(() => {
|
|
177
|
+
const props = Object.entries(flex.track).map(([key, v]) => [key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`), v] as const);
|
|
178
|
+
for (const [key, v] of props) track.style.setProperty(key, v);
|
|
179
|
+
return () => props.forEach(([key]) => track.style.removeProperty(key));
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const listed = $derived(layout?.fit === "list");
|
|
183
|
+
const chosen = $derived(many ? (value as readonly V[]) : null);
|
|
184
|
+
const isOn = (id: V) => (chosen ? chosen.includes(id) : value === id);
|
|
185
|
+
const disabledFlags = $derived(items.map((it) => disabled || !!it.disabled));
|
|
186
|
+
const roved = $derived(rovedIndex(disabledFlags, items.findIndex((it) => isOn(it.id))));
|
|
187
|
+
|
|
188
|
+
function choose(id: V) {
|
|
189
|
+
onPress?.(id);
|
|
190
|
+
const next = (chosen ? toggleSelection(chosen, id, items.map((it) => it.id)) : id) as M extends "many" ? V[] : V;
|
|
191
|
+
value = next;
|
|
192
|
+
onChange?.(next);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function onKeyDown(e: KeyboardEvent) {
|
|
196
|
+
// The dropdown's keys reach the track through the portal too.
|
|
197
|
+
if (listed) return;
|
|
198
|
+
const target = e.target as HTMLElement;
|
|
199
|
+
// A tile is a link, and Space does not follow a link on its own.
|
|
200
|
+
if (vertical && e.key === " " && target.dataset.selId) {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
target.click();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const node = roveSelector(track, e.key, orientation);
|
|
206
|
+
if (!node) return;
|
|
207
|
+
e.preventDefault();
|
|
208
|
+
const item = items.find((it) => String(it.id) === node.dataset.selId);
|
|
209
|
+
if (strip.autoSelect && item) choose(item.id);
|
|
210
|
+
}
|
|
211
|
+
</script>
|
|
212
|
+
|
|
213
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
214
|
+
<div
|
|
215
|
+
data-glim="Selector"
|
|
216
|
+
bind:this={track}
|
|
217
|
+
role={listed ? undefined : strip.role}
|
|
218
|
+
aria-label={listed ? undefined : name()}
|
|
219
|
+
aria-orientation={listed || strip.role === "group" ? undefined : orientation}
|
|
220
|
+
onkeydown={onKeyDown}
|
|
221
|
+
class={`${strip.className}${listed ? " glim-sel--listed" : ""} ${className}`.trim()}
|
|
222
|
+
>
|
|
223
|
+
{#each items as item, i (item.id)}
|
|
224
|
+
<SelectorSegment
|
|
225
|
+
{item}
|
|
226
|
+
index={i}
|
|
227
|
+
{strip}
|
|
228
|
+
on={isOn(item.id)}
|
|
229
|
+
disabled={disabledFlags[i]!}
|
|
230
|
+
roved={i === roved}
|
|
231
|
+
{listed}
|
|
232
|
+
share={vertical ? undefined : flex.segment}
|
|
233
|
+
squeezed={layout?.fit === "squeezed"}
|
|
234
|
+
cut={!!layout?.cut[i]}
|
|
235
|
+
{orientation}
|
|
236
|
+
{size}
|
|
237
|
+
{variant}
|
|
238
|
+
{equalWidth}
|
|
239
|
+
{buttonHeight}
|
|
240
|
+
{hue}
|
|
241
|
+
{hueOffset}
|
|
242
|
+
{panelId}
|
|
243
|
+
onSelect={() => choose(item.id)}
|
|
244
|
+
/>
|
|
245
|
+
{/each}
|
|
246
|
+
{#if listed}
|
|
247
|
+
<div class="glim-sel-list">
|
|
248
|
+
<Select
|
|
249
|
+
label={name() ?? ""}
|
|
250
|
+
hideLabel
|
|
251
|
+
wrap
|
|
252
|
+
width="fill"
|
|
253
|
+
size={size === "sm" ? "row" : "field"}
|
|
254
|
+
options={items.map((it, i) => ({ value: String(it.id), label: it.label, glyph: it.glyph, disabled: disabledFlags[i] }))}
|
|
255
|
+
value={value === null ? null : String(value)}
|
|
256
|
+
onChange={(next) => {
|
|
257
|
+
const item = items.find((it) => String(it.id) === next);
|
|
258
|
+
if (item) choose(item.id);
|
|
259
|
+
}}
|
|
260
|
+
disabled={disabledFlags.every(Boolean)}
|
|
261
|
+
/>
|
|
262
|
+
</div>
|
|
263
|
+
{/if}
|
|
264
|
+
</div>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
2
|
+
import type { SelectorItem } from "./selectorItem.js";
|
|
3
|
+
export type { SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
4
|
+
export type { SelectorItem } from "./selectorItem.js";
|
|
5
|
+
export { selectorTabId } from "@glimstone/core";
|
|
6
|
+
export interface SelectorProps<M extends SelectMode = "one", V extends string | number = string> {
|
|
7
|
+
items: SelectorItem<V>[];
|
|
8
|
+
/** The accessible name of the strip, such as "Sort" or "Settings pages". Inside a FieldRow the row gives it. */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** `one` picks a value, `many` toggles any number of them. Default `one`. */
|
|
11
|
+
select?: M;
|
|
12
|
+
/** The chosen id, or the chosen ids for `many`, bound with `bind:value`. */
|
|
13
|
+
value: M extends "many" ? readonly V[] : V | null;
|
|
14
|
+
/** Called with the new id, or the new list for `many`. */
|
|
15
|
+
onChange?: (next: M extends "many" ? V[] : V) => void;
|
|
16
|
+
/** Called on every press and every arrow key that chooses, before the choice changes, also one on the segment already chosen. */
|
|
17
|
+
onPress?: (id: V) => void;
|
|
18
|
+
/** `vertical` is the column of tiles beside a settings area's pages. */
|
|
19
|
+
orientation?: SelectorOrientation;
|
|
20
|
+
size?: SelectorSize;
|
|
21
|
+
variant?: SelectorVariant;
|
|
22
|
+
/** "manual" moves the focus with the arrows and chooses on Space, Enter or a
|
|
23
|
+
* click, as a radio group; for a strip that saves a setting. */
|
|
24
|
+
activation?: SelectorActivation;
|
|
25
|
+
/** Pin every segment to the widest one's measured width, at least the shared
|
|
26
|
+
* floor where the row has room; the page-level picker. Where the pinned
|
|
27
|
+
* widths do not fit the row, the segments share it by their labels. */
|
|
28
|
+
equalWidth?: boolean;
|
|
29
|
+
/** Hug the segments instead of spanning the box, for a strip that shares a
|
|
30
|
+
* toolbar row, as it does inside a FieldRow. */
|
|
31
|
+
inline?: boolean;
|
|
32
|
+
/** Share the row evenly without a pinned width, for page tabs. Every strip
|
|
33
|
+
* keeps to one row; once its labels do not fit together it shows glyphs
|
|
34
|
+
* alone where every segment has one, a strip of one turns into a dropdown
|
|
35
|
+
* otherwise, and a `many` strip cuts its labels short. */
|
|
36
|
+
fit?: boolean;
|
|
37
|
+
/** Has no effect: every strip keeps to one row. */
|
|
38
|
+
pairsOnPhone?: boolean;
|
|
39
|
+
/** The button height for every segment, for a strip beside a Button. */
|
|
40
|
+
buttonHeight?: boolean;
|
|
41
|
+
/** Take a colour under rainbow. Turn it off where the colour means nothing,
|
|
42
|
+
* such as a strip of one, not for looks. */
|
|
43
|
+
hue?: boolean;
|
|
44
|
+
/** Makes the strip a tab strip for colour: each segment keeps its own
|
|
45
|
+
* palette position, counting from here. */
|
|
46
|
+
hueOffset?: number;
|
|
47
|
+
/** Disables every item; an item's own `disabled` applies on top. */
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
/** The id of the panel a tab strip switches. The chosen tab controls it, and
|
|
50
|
+
* the panel names itself with `aria-labelledby={selectorTabId(panelId, id)}`. */
|
|
51
|
+
panelId?: string;
|
|
52
|
+
class?: string;
|
|
53
|
+
}
|
|
54
|
+
declare function $$render<M extends SelectMode = 'one', V extends string | number = string>(): {
|
|
55
|
+
props: SelectorProps<M, V>;
|
|
56
|
+
exports: {};
|
|
57
|
+
bindings: "value";
|
|
58
|
+
slots: {};
|
|
59
|
+
events: {};
|
|
60
|
+
};
|
|
61
|
+
declare class __sveltets_Render<M extends SelectMode = 'one', V extends string | number = string> {
|
|
62
|
+
props(): ReturnType<typeof $$render<M, V>>['props'];
|
|
63
|
+
events(): ReturnType<typeof $$render<M, V>>['events'];
|
|
64
|
+
slots(): ReturnType<typeof $$render<M, V>>['slots'];
|
|
65
|
+
bindings(): "value";
|
|
66
|
+
exports(): {};
|
|
67
|
+
}
|
|
68
|
+
interface $$IsomorphicComponent {
|
|
69
|
+
new <M extends SelectMode = 'one', V extends string | number = string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<M, V>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<M, V>['props']>, ReturnType<__sveltets_Render<M, V>['events']>, ReturnType<__sveltets_Render<M, V>['slots']>> & {
|
|
70
|
+
$$bindings?: ReturnType<__sveltets_Render<M, V>['bindings']>;
|
|
71
|
+
} & ReturnType<__sveltets_Render<M, V>['exports']>;
|
|
72
|
+
<M extends SelectMode = 'one', V extends string | number = string>(internal: unknown, props: ReturnType<__sveltets_Render<M, V>['props']> & {}): ReturnType<__sveltets_Render<M, V>['exports']>;
|
|
73
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
74
|
+
}
|
|
75
|
+
declare const Selector: $$IsomorphicComponent;
|
|
76
|
+
type Selector<M extends SelectMode = 'one', V extends string | number = string> = InstanceType<typeof Selector<M, V>>;
|
|
77
|
+
export default Selector;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { segmentView, selectorTabId, type SelectorOrientation, type SelectorSize, type SelectorVariant, type SelectorView } from "@glimstone/core";
|
|
3
|
+
import { useTipBubble } from "./bubble.svelte.js";
|
|
4
|
+
import type { SelectorItem } from "./selectorItem.js";
|
|
5
|
+
import { css } from "./style.js";
|
|
6
|
+
import TipBubble from "./TipBubble.svelte";
|
|
7
|
+
|
|
8
|
+
// One segment or tile of Selector, a component of its own so each holds its
|
|
9
|
+
// own bubble.
|
|
10
|
+
let {
|
|
11
|
+
item,
|
|
12
|
+
index,
|
|
13
|
+
strip,
|
|
14
|
+
on,
|
|
15
|
+
disabled,
|
|
16
|
+
roved,
|
|
17
|
+
listed,
|
|
18
|
+
share,
|
|
19
|
+
squeezed,
|
|
20
|
+
cut,
|
|
21
|
+
orientation,
|
|
22
|
+
size,
|
|
23
|
+
variant,
|
|
24
|
+
equalWidth,
|
|
25
|
+
buttonHeight,
|
|
26
|
+
hue,
|
|
27
|
+
hueOffset,
|
|
28
|
+
panelId,
|
|
29
|
+
onSelect,
|
|
30
|
+
}: {
|
|
31
|
+
item: SelectorItem<string | number>;
|
|
32
|
+
index: number;
|
|
33
|
+
strip: SelectorView;
|
|
34
|
+
on: boolean;
|
|
35
|
+
disabled: boolean;
|
|
36
|
+
roved: boolean;
|
|
37
|
+
/** The strip shows its dropdown, and the segment is only there to be measured. */
|
|
38
|
+
listed: boolean;
|
|
39
|
+
share: Record<string, string> | undefined;
|
|
40
|
+
squeezed: boolean;
|
|
41
|
+
cut: boolean;
|
|
42
|
+
orientation: SelectorOrientation;
|
|
43
|
+
size: SelectorSize;
|
|
44
|
+
variant: SelectorVariant;
|
|
45
|
+
equalWidth: boolean;
|
|
46
|
+
buttonHeight: boolean;
|
|
47
|
+
hue: boolean;
|
|
48
|
+
hueOffset?: number;
|
|
49
|
+
panelId?: string;
|
|
50
|
+
onSelect: () => void;
|
|
51
|
+
} = $props();
|
|
52
|
+
|
|
53
|
+
const view = $derived(
|
|
54
|
+
segmentView({
|
|
55
|
+
strip,
|
|
56
|
+
orientation,
|
|
57
|
+
size,
|
|
58
|
+
variant,
|
|
59
|
+
equalWidth,
|
|
60
|
+
buttonHeight,
|
|
61
|
+
hue,
|
|
62
|
+
hueOffset,
|
|
63
|
+
index,
|
|
64
|
+
label: item.label,
|
|
65
|
+
hasGlyph: !!item.glyph,
|
|
66
|
+
iconOnly: !!item.iconOnly,
|
|
67
|
+
tip: item.tip,
|
|
68
|
+
title: item.title,
|
|
69
|
+
on,
|
|
70
|
+
disabled,
|
|
71
|
+
dim: item.dim,
|
|
72
|
+
squeezed,
|
|
73
|
+
cut,
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
const tooltip = useTipBubble(() => view.tip, () => disabled);
|
|
77
|
+
// A disabled segment takes no hover or focus, so its reason is a description
|
|
78
|
+
// from the start rather than one that exists only while the bubble is open.
|
|
79
|
+
const descId = $props.id();
|
|
80
|
+
const hiddenTip = $derived(disabled && !!view.tip);
|
|
81
|
+
const described = $derived(hiddenTip ? descId : tooltip.describedBy);
|
|
82
|
+
const tab = $derived(strip.kind === "tab");
|
|
83
|
+
const style = $derived(css({ ...view.style, ...share }));
|
|
84
|
+
|
|
85
|
+
// A plain click stays in the app; a modified one opens the address beside
|
|
86
|
+
// it, as a link does.
|
|
87
|
+
function open(e: MouseEvent) {
|
|
88
|
+
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || e.button !== 0) return;
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
onSelect();
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
{#snippet content()}
|
|
95
|
+
{#if view.showGlyph}{@render item.glyph?.()}{/if}
|
|
96
|
+
{#if view.labelClass !== null}<span data-sel-label class={view.labelClass}>{item.label}</span>{/if}
|
|
97
|
+
{/snippet}
|
|
98
|
+
|
|
99
|
+
{#snippet button()}
|
|
100
|
+
<!-- svelte-ignore a11y_role_supports_aria_props_implicit, a11y_role_has_required_aria_props -->
|
|
101
|
+
<button
|
|
102
|
+
{...item.attrs}
|
|
103
|
+
bind:this={tooltip.trigger}
|
|
104
|
+
type="button"
|
|
105
|
+
data-sel-id={item.id}
|
|
106
|
+
id={panelId && tab ? selectorTabId(panelId, item.id) : undefined}
|
|
107
|
+
role={strip.kind === "toggle" ? undefined : strip.kind}
|
|
108
|
+
aria-selected={tab ? on : undefined}
|
|
109
|
+
aria-controls={panelId && tab && on ? panelId : undefined}
|
|
110
|
+
aria-checked={strip.kind === "radio" ? on : undefined}
|
|
111
|
+
aria-pressed={strip.kind === "toggle" ? on : undefined}
|
|
112
|
+
aria-label={view.ariaLabel}
|
|
113
|
+
aria-describedby={described}
|
|
114
|
+
aria-hidden={listed || undefined}
|
|
115
|
+
{disabled}
|
|
116
|
+
tabindex={roved && !listed ? 0 : -1}
|
|
117
|
+
class={view.className}
|
|
118
|
+
{style}
|
|
119
|
+
onclick={onSelect}
|
|
120
|
+
onmouseenter={tooltip.show}
|
|
121
|
+
onmouseleave={tooltip.hide}
|
|
122
|
+
onfocus={tooltip.showOnFocus}
|
|
123
|
+
onblur={tooltip.hide}
|
|
124
|
+
>
|
|
125
|
+
{@render content()}
|
|
126
|
+
</button>
|
|
127
|
+
{/snippet}
|
|
128
|
+
|
|
129
|
+
{#if orientation === "vertical"}
|
|
130
|
+
<a
|
|
131
|
+
{...item.attrs}
|
|
132
|
+
bind:this={tooltip.trigger}
|
|
133
|
+
href={item.href}
|
|
134
|
+
data-sel-id={item.id}
|
|
135
|
+
role="tab"
|
|
136
|
+
aria-selected={on}
|
|
137
|
+
aria-current={on ? "page" : undefined}
|
|
138
|
+
aria-describedby={described}
|
|
139
|
+
tabindex={roved ? 0 : -1}
|
|
140
|
+
class={view.className}
|
|
141
|
+
{style}
|
|
142
|
+
onclick={open}
|
|
143
|
+
onmouseenter={tooltip.show}
|
|
144
|
+
onmouseleave={tooltip.hide}
|
|
145
|
+
onfocus={tooltip.showOnFocus}
|
|
146
|
+
onblur={tooltip.hide}
|
|
147
|
+
>
|
|
148
|
+
{@render content()}
|
|
149
|
+
</a>
|
|
150
|
+
{:else}
|
|
151
|
+
{#if hiddenTip}
|
|
152
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
153
|
+
<span class="glim-tip-wrap" style={css(share)} onmouseenter={tooltip.show} onmouseleave={tooltip.hide}>{@render button()}</span>
|
|
154
|
+
{:else}
|
|
155
|
+
{@render button()}
|
|
156
|
+
{/if}
|
|
157
|
+
{#if hiddenTip}<span id={descId} hidden>{view.tip}</span>{/if}
|
|
158
|
+
{/if}
|
|
159
|
+
<TipBubble state={tooltip} />
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type SelectorOrientation, type SelectorSize, type SelectorVariant, type SelectorView } from "@glimstone/core";
|
|
2
|
+
import type { SelectorItem } from "./selectorItem.js";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
item: SelectorItem<string | number>;
|
|
5
|
+
index: number;
|
|
6
|
+
strip: SelectorView;
|
|
7
|
+
on: boolean;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
roved: boolean;
|
|
10
|
+
/** The strip shows its dropdown, and the segment is only there to be measured. */
|
|
11
|
+
listed: boolean;
|
|
12
|
+
share: Record<string, string> | undefined;
|
|
13
|
+
squeezed: boolean;
|
|
14
|
+
cut: boolean;
|
|
15
|
+
orientation: SelectorOrientation;
|
|
16
|
+
size: SelectorSize;
|
|
17
|
+
variant: SelectorVariant;
|
|
18
|
+
equalWidth: boolean;
|
|
19
|
+
buttonHeight: boolean;
|
|
20
|
+
hue: boolean;
|
|
21
|
+
hueOffset?: number;
|
|
22
|
+
panelId?: string;
|
|
23
|
+
onSelect: () => void;
|
|
24
|
+
};
|
|
25
|
+
declare const SelectorSegment: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
26
|
+
type SelectorSegment = ReturnType<typeof SelectorSegment>;
|
|
27
|
+
export default SelectorSegment;
|