@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.
Files changed (282) hide show
  1. package/README.md +53 -2
  2. package/dist/AboutCard.svelte +87 -0
  3. package/dist/AboutCard.svelte.d.ts +37 -0
  4. package/dist/Accordion.svelte +60 -0
  5. package/dist/Accordion.svelte.d.ts +38 -0
  6. package/dist/AngleSlider.svelte +56 -0
  7. package/dist/AngleSlider.svelte.d.ts +13 -0
  8. package/dist/Avatar.svelte +37 -0
  9. package/dist/Avatar.svelte.d.ts +13 -0
  10. package/dist/Badge.svelte +119 -0
  11. package/dist/Badge.svelte.d.ts +54 -0
  12. package/dist/BrandMark.svelte +12 -0
  13. package/dist/BrandMark.svelte.d.ts +6 -0
  14. package/dist/BusyRing.svelte +39 -0
  15. package/dist/BusyRing.svelte.d.ts +15 -0
  16. package/dist/Button.svelte +172 -0
  17. package/dist/Button.svelte.d.ts +57 -0
  18. package/dist/Card.svelte +61 -0
  19. package/dist/Card.svelte.d.ts +23 -0
  20. package/dist/Carousel.svelte +72 -0
  21. package/dist/Carousel.svelte.d.ts +41 -0
  22. package/dist/Checkbox.svelte +48 -0
  23. package/dist/Checkbox.svelte.d.ts +17 -0
  24. package/dist/CoffeeDialog.svelte +70 -0
  25. package/dist/CoffeeDialog.svelte.d.ts +18 -0
  26. package/dist/Collapsible.svelte +49 -0
  27. package/dist/Collapsible.svelte.d.ts +14 -0
  28. package/dist/ColorPicker.svelte +122 -0
  29. package/dist/ColorPicker.svelte.d.ts +23 -0
  30. package/dist/Combobox.svelte +87 -0
  31. package/dist/Combobox.svelte.d.ts +18 -0
  32. package/dist/ConfirmDialog.svelte +106 -0
  33. package/dist/ConfirmDialog.svelte.d.ts +31 -0
  34. package/dist/ConfirmHost.svelte +41 -0
  35. package/dist/ConfirmHost.svelte.d.ts +7 -0
  36. package/dist/ContextMenu.svelte +213 -0
  37. package/dist/ContextMenu.svelte.d.ts +29 -0
  38. package/dist/CopyField.svelte +60 -0
  39. package/dist/CopyField.svelte.d.ts +19 -0
  40. package/dist/CryptoDonateDialog.svelte +162 -0
  41. package/dist/CryptoDonateDialog.svelte.d.ts +37 -0
  42. package/dist/DatePicker.svelte +149 -0
  43. package/dist/DatePicker.svelte.d.ts +18 -0
  44. package/dist/DropdownListbox.svelte +178 -0
  45. package/dist/DropdownListbox.svelte.d.ts +23 -0
  46. package/dist/EmptyState.svelte +31 -0
  47. package/dist/EmptyState.svelte.d.ts +16 -0
  48. package/dist/FieldError.svelte +20 -0
  49. package/dist/FieldError.svelte.d.ts +8 -0
  50. package/dist/FieldRow.svelte +52 -0
  51. package/dist/FieldRow.svelte.d.ts +23 -0
  52. package/dist/FieldRowGroup.svelte +33 -0
  53. package/dist/FieldRowGroup.svelte.d.ts +13 -0
  54. package/dist/FileUpload.svelte +74 -0
  55. package/dist/FileUpload.svelte.d.ts +18 -0
  56. package/dist/FloatingPanel.svelte +89 -0
  57. package/dist/FloatingPanel.svelte.d.ts +17 -0
  58. package/dist/Fortress.svelte +222 -0
  59. package/dist/Fortress.svelte.d.ts +62 -0
  60. package/dist/FortressAppCard.svelte +115 -0
  61. package/dist/FortressAppCard.svelte.d.ts +18 -0
  62. package/dist/FortressDoubtWindow.svelte +37 -0
  63. package/dist/FortressDoubtWindow.svelte.d.ts +12 -0
  64. package/dist/FortressPairing.svelte +85 -0
  65. package/dist/FortressPairing.svelte.d.ts +32 -0
  66. package/dist/FortressPermissions.svelte +93 -0
  67. package/dist/FortressPermissions.svelte.d.ts +24 -0
  68. package/dist/FortressStatusWindow.svelte +128 -0
  69. package/dist/FortressStatusWindow.svelte.d.ts +20 -0
  70. package/dist/FortressWindow.svelte +271 -0
  71. package/dist/FortressWindow.svelte.d.ts +18 -0
  72. package/dist/GlyphField.svelte +52 -0
  73. package/dist/GlyphField.svelte.d.ts +20 -0
  74. package/dist/GlyphTile.svelte +25 -0
  75. package/dist/GlyphTile.svelte.d.ts +14 -0
  76. package/dist/HoverCard.svelte +47 -0
  77. package/dist/HoverCard.svelte.d.ts +14 -0
  78. package/dist/IconButton.svelte +49 -0
  79. package/dist/IconButton.svelte.d.ts +20 -0
  80. package/dist/IconTipButton.svelte +67 -0
  81. package/dist/IconTipButton.svelte.d.ts +23 -0
  82. package/dist/InfoAboutCard.svelte +65 -0
  83. package/dist/InfoAboutCard.svelte.d.ts +35 -0
  84. package/dist/InfoBubble.svelte +50 -0
  85. package/dist/InfoBubble.svelte.d.ts +7 -0
  86. package/dist/InfoHelpCard.svelte +93 -0
  87. package/dist/InfoHelpCard.svelte.d.ts +44 -0
  88. package/dist/InfoTile.svelte +31 -0
  89. package/dist/InfoTile.svelte.d.ts +15 -0
  90. package/dist/InfoVersionCard.svelte +99 -0
  91. package/dist/InfoVersionCard.svelte.d.ts +29 -0
  92. package/dist/InstanceCard.svelte +85 -0
  93. package/dist/InstanceCard.svelte.d.ts +27 -0
  94. package/dist/Kbd.svelte +16 -0
  95. package/dist/Kbd.svelte.d.ts +8 -0
  96. package/dist/ListRow.svelte +51 -0
  97. package/dist/ListRow.svelte.d.ts +19 -0
  98. package/dist/ListSelect.svelte +135 -0
  99. package/dist/ListSelect.svelte.d.ts +25 -0
  100. package/dist/ListTable.svelte +183 -0
  101. package/dist/ListTable.svelte.d.ts +44 -0
  102. package/dist/MarkSvg.svelte +9 -0
  103. package/dist/MarkSvg.svelte.d.ts +8 -0
  104. package/dist/Marquee.svelte +63 -0
  105. package/dist/Marquee.svelte.d.ts +39 -0
  106. package/dist/MenuBar.svelte +98 -0
  107. package/dist/MenuBar.svelte.d.ts +19 -0
  108. package/dist/MenuChoice.svelte +30 -0
  109. package/dist/MenuChoice.svelte.d.ts +33 -0
  110. package/dist/MenuHeadEdit.svelte +29 -0
  111. package/dist/MenuHeadEdit.svelte.d.ts +10 -0
  112. package/dist/MenuRows.svelte +57 -0
  113. package/dist/MenuRows.svelte.d.ts +9 -0
  114. package/dist/MenuSelect.svelte +145 -0
  115. package/dist/MenuSelect.svelte.d.ts +25 -0
  116. package/dist/MenuSubmenu.svelte +64 -0
  117. package/dist/MenuSubmenu.svelte.d.ts +37 -0
  118. package/dist/Meter.svelte +55 -0
  119. package/dist/Meter.svelte.d.ts +20 -0
  120. package/dist/NumberField.svelte +70 -0
  121. package/dist/NumberField.svelte.d.ts +23 -0
  122. package/dist/Pagination.svelte +62 -0
  123. package/dist/Pagination.svelte.d.ts +16 -0
  124. package/dist/PasswordField.svelte +69 -0
  125. package/dist/PasswordField.svelte.d.ts +21 -0
  126. package/dist/PathField.svelte +111 -0
  127. package/dist/PathField.svelte.d.ts +33 -0
  128. package/dist/PaypalDialog.svelte +174 -0
  129. package/dist/PaypalDialog.svelte.d.ts +54 -0
  130. package/dist/Pill.svelte +25 -0
  131. package/dist/Pill.svelte.d.ts +14 -0
  132. package/dist/PinInput.svelte +81 -0
  133. package/dist/PinInput.svelte.d.ts +23 -0
  134. package/dist/Popover.svelte +38 -0
  135. package/dist/Popover.svelte.d.ts +16 -0
  136. package/dist/PresenceBadges.svelte +22 -0
  137. package/dist/PresenceBadges.svelte.d.ts +8 -0
  138. package/dist/ProgressBar.svelte +37 -0
  139. package/dist/ProgressBar.svelte.d.ts +16 -0
  140. package/dist/Rating.svelte +65 -0
  141. package/dist/Rating.svelte.d.ts +18 -0
  142. package/dist/ReadmeButton.svelte +82 -0
  143. package/dist/ReadmeButton.svelte.d.ts +27 -0
  144. package/dist/RowMark.svelte +16 -0
  145. package/dist/RowMark.svelte.d.ts +7 -0
  146. package/dist/ScrollArea.svelte +46 -0
  147. package/dist/ScrollArea.svelte.d.ts +11 -0
  148. package/dist/Select.svelte +97 -0
  149. package/dist/Select.svelte.d.ts +67 -0
  150. package/dist/SelectFace.svelte +18 -0
  151. package/dist/SelectFace.svelte.d.ts +32 -0
  152. package/dist/Selector.svelte +264 -0
  153. package/dist/Selector.svelte.d.ts +77 -0
  154. package/dist/SelectorSegment.svelte +159 -0
  155. package/dist/SelectorSegment.svelte.d.ts +27 -0
  156. package/dist/Sheet.svelte +51 -0
  157. package/dist/Sheet.svelte.d.ts +23 -0
  158. package/dist/SidebarRow.svelte +91 -0
  159. package/dist/SidebarRow.svelte.d.ts +31 -0
  160. package/dist/SignInCard.svelte +251 -0
  161. package/dist/SignInCard.svelte.d.ts +34 -0
  162. package/dist/SignInField.svelte +32 -0
  163. package/dist/SignInField.svelte.d.ts +11 -0
  164. package/dist/SignaturePad.svelte +72 -0
  165. package/dist/SignaturePad.svelte.d.ts +13 -0
  166. package/dist/SkeletonRow.svelte +29 -0
  167. package/dist/SkeletonRow.svelte.d.ts +12 -0
  168. package/dist/Slider.svelte +60 -0
  169. package/dist/Slider.svelte.d.ts +15 -0
  170. package/dist/Splitter.svelte +59 -0
  171. package/dist/Splitter.svelte.d.ts +37 -0
  172. package/dist/Steps.svelte +90 -0
  173. package/dist/Steps.svelte.d.ts +40 -0
  174. package/dist/SubCard.svelte +45 -0
  175. package/dist/SubCard.svelte.d.ts +14 -0
  176. package/dist/Table.svelte +48 -0
  177. package/dist/Table.svelte.d.ts +37 -0
  178. package/dist/TagsInput.svelte +77 -0
  179. package/dist/TagsInput.svelte.d.ts +18 -0
  180. package/dist/TextArea.svelte +55 -0
  181. package/dist/TextArea.svelte.d.ts +17 -0
  182. package/dist/TextField.svelte +61 -0
  183. package/dist/TextField.svelte.d.ts +18 -0
  184. package/dist/Timer.svelte +62 -0
  185. package/dist/Timer.svelte.d.ts +17 -0
  186. package/dist/TipBubble.svelte +11 -0
  187. package/dist/TipBubble.svelte.d.ts +7 -0
  188. package/dist/TipWrap.svelte +15 -0
  189. package/dist/TipWrap.svelte.d.ts +10 -0
  190. package/dist/ToastCard.svelte +68 -0
  191. package/dist/ToastCard.svelte.d.ts +18 -0
  192. package/dist/ToastViewport.svelte +65 -0
  193. package/dist/ToastViewport.svelte.d.ts +14 -0
  194. package/dist/Toggle.svelte +84 -0
  195. package/dist/Toggle.svelte.d.ts +25 -0
  196. package/dist/Tour.svelte +75 -0
  197. package/dist/Tour.svelte.d.ts +12 -0
  198. package/dist/Tree.svelte +122 -0
  199. package/dist/Tree.svelte.d.ts +22 -0
  200. package/dist/UnavailableNotice.svelte +36 -0
  201. package/dist/UnavailableNotice.svelte.d.ts +18 -0
  202. package/dist/Window.svelte +108 -0
  203. package/dist/Window.svelte.d.ts +33 -0
  204. package/dist/WindowBar.svelte +76 -0
  205. package/dist/WindowBar.svelte.d.ts +26 -0
  206. package/dist/WindowFootRow.svelte +67 -0
  207. package/dist/WindowFootRow.svelte.d.ts +28 -0
  208. package/dist/bubble.svelte.d.ts +15 -0
  209. package/dist/bubble.svelte.js +66 -0
  210. package/dist/confirm.svelte.d.ts +37 -0
  211. package/dist/confirm.svelte.js +62 -0
  212. package/dist/engines.svelte.d.ts +18 -0
  213. package/dist/engines.svelte.js +57 -0
  214. package/dist/entries/accordion.d.ts +1 -0
  215. package/dist/entries/accordion.js +2 -0
  216. package/dist/entries/angleslider.d.ts +1 -0
  217. package/dist/entries/angleslider.js +2 -0
  218. package/dist/entries/avatar.d.ts +1 -0
  219. package/dist/entries/avatar.js +2 -0
  220. package/dist/entries/carousel.d.ts +1 -0
  221. package/dist/entries/carousel.js +2 -0
  222. package/dist/entries/collapsible.d.ts +1 -0
  223. package/dist/entries/collapsible.js +2 -0
  224. package/dist/entries/combobox.d.ts +1 -0
  225. package/dist/entries/combobox.js +2 -0
  226. package/dist/entries/datepicker.d.ts +1 -0
  227. package/dist/entries/datepicker.js +2 -0
  228. package/dist/entries/fileupload.d.ts +1 -0
  229. package/dist/entries/fileupload.js +2 -0
  230. package/dist/entries/floatingpanel.d.ts +1 -0
  231. package/dist/entries/floatingpanel.js +2 -0
  232. package/dist/entries/hovercard.d.ts +1 -0
  233. package/dist/entries/hovercard.js +2 -0
  234. package/dist/entries/marquee.d.ts +1 -0
  235. package/dist/entries/marquee.js +2 -0
  236. package/dist/entries/pagination.d.ts +1 -0
  237. package/dist/entries/pagination.js +2 -0
  238. package/dist/entries/pininput.d.ts +1 -0
  239. package/dist/entries/pininput.js +2 -0
  240. package/dist/entries/rating.d.ts +1 -0
  241. package/dist/entries/rating.js +2 -0
  242. package/dist/entries/scrollarea.d.ts +1 -0
  243. package/dist/entries/scrollarea.js +2 -0
  244. package/dist/entries/select.d.ts +1 -0
  245. package/dist/entries/select.js +2 -0
  246. package/dist/entries/signaturepad.d.ts +1 -0
  247. package/dist/entries/signaturepad.js +2 -0
  248. package/dist/entries/slider.d.ts +1 -0
  249. package/dist/entries/slider.js +2 -0
  250. package/dist/entries/splitter.d.ts +1 -0
  251. package/dist/entries/splitter.js +2 -0
  252. package/dist/entries/steps.d.ts +1 -0
  253. package/dist/entries/steps.js +2 -0
  254. package/dist/entries/tagsinput.d.ts +1 -0
  255. package/dist/entries/tagsinput.js +2 -0
  256. package/dist/entries/timer.d.ts +1 -0
  257. package/dist/entries/timer.js +2 -0
  258. package/dist/entries/tour.d.ts +1 -0
  259. package/dist/entries/tour.js +2 -0
  260. package/dist/fieldName.d.ts +4 -0
  261. package/dist/fieldName.js +9 -0
  262. package/dist/fortressParts.d.ts +5 -0
  263. package/dist/fortressParts.js +16 -0
  264. package/dist/glyphs.d.ts +32 -0
  265. package/dist/glyphs.js +47 -0
  266. package/dist/index.d.ts +78 -0
  267. package/dist/index.js +77 -0
  268. package/dist/lift.d.ts +5 -0
  269. package/dist/lift.js +9 -0
  270. package/dist/portalHue.svelte.d.ts +9 -0
  271. package/dist/portalHue.svelte.js +16 -0
  272. package/dist/selectParts.svelte.d.ts +39 -0
  273. package/dist/selectParts.svelte.js +28 -0
  274. package/dist/selectorItem.d.ts +22 -0
  275. package/dist/selectorItem.js +1 -0
  276. package/dist/style.d.ts +5 -0
  277. package/dist/style.js +12 -0
  278. package/dist/useDragArmed.svelte.d.ts +6 -0
  279. package/dist/useDragArmed.svelte.js +24 -0
  280. package/dist/usePaypalButtons.svelte.d.ts +18 -0
  281. package/dist/usePaypalButtons.svelte.js +41 -0
  282. package/package.json +173 -4
@@ -0,0 +1,172 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { HTMLButtonAttributes } from "svelte/elements";
4
+ import type { ButtonSize, ButtonTone, ButtonVariant, WidthStage } from "@glimstone/core";
5
+
6
+ export type { ButtonSize, ButtonTone, ButtonVariant } from "@glimstone/core";
7
+
8
+ export interface ButtonProps extends Omit<HTMLButtonAttributes, "children" | "class" | "disabled" | "onclick" | "title" | "type" | "autofocus"> {
9
+ /** The button's words, present in every mode: visible, or hidden but
10
+ * announced and shown as the tooltip. Keep it stable, since a label that
11
+ * changes while the button works would resize it; put changing state in
12
+ * `title`. */
13
+ label: string;
14
+ /** The translation key behind `label`, or `null` when the label is data such
15
+ * as a path. It picks the glyph by meaning (glyphFor), so the same verb
16
+ * wears the same symbol everywhere; an explicit `glyph` wins. */
17
+ labelKey: string | null;
18
+ /** Optional icon, overriding whatever `labelKey` would have chosen. */
19
+ glyph?: Snippet;
20
+ onClick?: () => void;
21
+ tone?: ButtonTone;
22
+ /** "chip" inside a pill, "icon" for a row action; see ButtonVariant. */
23
+ variant?: ButtonVariant;
24
+ disabled?: boolean;
25
+ /** Makes it a link with the button's look. A disabled one stays a disabled button. */
26
+ href?: string;
27
+ /** What stands before the glyph, such as a count. */
28
+ before?: Snippet;
29
+ /** What stands after the words, such as a key cap. */
30
+ after?: Snippet;
31
+ type?: "button" | "submit";
32
+ /** Extra explanation, and the place for anything that changes: the running
33
+ * state, or why the button is unavailable. It shows in the hover and focus
34
+ * bubble, joined with the label where the label is hidden, and still
35
+ * reaches a disabled button. */
36
+ title?: string;
37
+ /** This button's own rainbow position, for a colour different from its card's. */
38
+ hueIndex?: number;
39
+ /** The underlying element, bound with `bind:ref`, so a dialog can move focus to it. */
40
+ ref?: HTMLElement | null;
41
+ /** Shows the busy ring in place of the glyph, at once. Separate from `disabled`. */
42
+ busy?: boolean;
43
+ /** For a dialog that opens with focus on one of its buttons. */
44
+ autofocus?: boolean;
45
+ /** Forces a width stage, for two buttons in different components that should
46
+ * match: pass `groupStage([labelA, labelB])` to both. */
47
+ stage?: WidthStage;
48
+ /** Its glyph alone in a square in every label mode, where the words have no
49
+ * room. The label stays the name and the bubble. */
50
+ compact?: boolean;
51
+ /** Turns compact while the window is narrower than this many pixels. */
52
+ compactBelow?: number;
53
+ size?: ButtonSize;
54
+ /** Keeps the label visible in every mode, for a label that is content rather than a verb. */
55
+ keepLabel?: boolean;
56
+ class?: string;
57
+ }
58
+ </script>
59
+
60
+ <script lang="ts">
61
+ import { buttonView, mediaMatches, narrowerThan, subscribeMedia, takePageHue } from "@glimstone/core";
62
+ import { useLabelMode } from "./engines.svelte.js";
63
+ import { glyphFor, IconClose } from "./glyphs.js";
64
+ import { css } from "./style.js";
65
+ import { useTipBubble } from "./bubble.svelte.js";
66
+ import BusyRing from "./BusyRing.svelte";
67
+ import TipBubble from "./TipBubble.svelte";
68
+ import TipWrap from "./TipWrap.svelte";
69
+
70
+ // The one clickable control; what it shows and how wide it is come from
71
+ // buttonView() in the core. The other props of a <button> go to the element.
72
+ let {
73
+ label,
74
+ labelKey,
75
+ glyph,
76
+ onClick,
77
+ tone = "neutral",
78
+ variant = "default",
79
+ disabled = false,
80
+ type = "button",
81
+ class: className = "",
82
+ title,
83
+ hueIndex,
84
+ busy = false,
85
+ autofocus = false,
86
+ stage,
87
+ keepLabel = false,
88
+ compact = false,
89
+ compactBelow,
90
+ size,
91
+ href,
92
+ before,
93
+ after,
94
+ ref = $bindable(null),
95
+ ...rest
96
+ }: ButtonProps = $props();
97
+
98
+ const mode = useLabelMode("buttons");
99
+ let narrow = $state(false);
100
+ $effect.pre(() => {
101
+ if (compactBelow === undefined) return void (narrow = false);
102
+ const query = narrowerThan(compactBelow);
103
+ narrow = mediaMatches(query);
104
+ return subscribeMedia(query, () => (narrow = mediaMatches(query)));
105
+ });
106
+ // A chip always closes, so it has a glyph even when no call site passes one.
107
+ const resolved = $derived(glyph ?? (labelKey ? glyphFor(labelKey) : undefined) ?? (variant === "chip" ? IconClose : undefined));
108
+ const view = $derived(
109
+ buttonView({
110
+ mode: mode.current,
111
+ label,
112
+ hasGlyph: !!resolved || busy,
113
+ tone,
114
+ variant,
115
+ disabled,
116
+ keepLabel,
117
+ compact: compact || narrow,
118
+ size,
119
+ title,
120
+ hueIndex,
121
+ stage,
122
+ }),
123
+ );
124
+ const link = $derived(!!href && !disabled);
125
+ const bubble = useTipBubble(() => view.tip, () => disabled);
126
+
127
+ $effect.pre(() => {
128
+ bubble.trigger = ref;
129
+ });
130
+
131
+ function enter(e: MouseEvent) {
132
+ if (view.pageHue) takePageHue(e.currentTarget as HTMLElement);
133
+ bubble.show();
134
+ }
135
+ function focus(e: FocusEvent) {
136
+ if (view.pageHue) takePageHue(e.currentTarget as HTMLElement);
137
+ bubble.showOnFocus();
138
+ }
139
+ </script>
140
+
141
+ <TipWrap on={disabled && !!view.tip} show={bubble.show} hide={bubble.hide}>
142
+ <!-- svelte-ignore a11y_no_static_element_interactions, a11y_autofocus -->
143
+ <svelte:element
144
+ this={link ? "a" : "button"}
145
+ data-glim="Button"
146
+ {...rest}
147
+ bind:this={ref}
148
+ href={link ? href : undefined}
149
+ type={link ? undefined : type}
150
+ disabled={link ? undefined : disabled}
151
+ autofocus={link ? undefined : autofocus}
152
+ aria-busy={busy || undefined}
153
+ aria-describedby={bubble.describedBy}
154
+ style={css(view.style)}
155
+ class={`${view.className} ${className}`.trim()}
156
+ onclick={() => onClick?.()}
157
+ onmouseenter={enter}
158
+ onmouseleave={bubble.hide}
159
+ onfocus={focus}
160
+ onblur={bubble.hide}
161
+ >
162
+ {@render before?.()}
163
+ {#if view.showGlyph}
164
+ <span class="glim-btn-glyph">
165
+ {#if busy}<BusyRing size="small" delay={0} />{:else}{@render resolved?.()}{/if}
166
+ </span>
167
+ {/if}
168
+ <span class={view.labelClass}>{label}</span>
169
+ {@render after?.()}
170
+ </svelte:element>
171
+ </TipWrap>
172
+ <TipBubble state={bubble} />
@@ -0,0 +1,57 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLButtonAttributes } from "svelte/elements";
3
+ import type { ButtonSize, ButtonTone, ButtonVariant, WidthStage } from "@glimstone/core";
4
+ export type { ButtonSize, ButtonTone, ButtonVariant } from "@glimstone/core";
5
+ export interface ButtonProps extends Omit<HTMLButtonAttributes, "children" | "class" | "disabled" | "onclick" | "title" | "type" | "autofocus"> {
6
+ /** The button's words, present in every mode: visible, or hidden but
7
+ * announced and shown as the tooltip. Keep it stable, since a label that
8
+ * changes while the button works would resize it; put changing state in
9
+ * `title`. */
10
+ label: string;
11
+ /** The translation key behind `label`, or `null` when the label is data such
12
+ * as a path. It picks the glyph by meaning (glyphFor), so the same verb
13
+ * wears the same symbol everywhere; an explicit `glyph` wins. */
14
+ labelKey: string | null;
15
+ /** Optional icon, overriding whatever `labelKey` would have chosen. */
16
+ glyph?: Snippet;
17
+ onClick?: () => void;
18
+ tone?: ButtonTone;
19
+ /** "chip" inside a pill, "icon" for a row action; see ButtonVariant. */
20
+ variant?: ButtonVariant;
21
+ disabled?: boolean;
22
+ /** Makes it a link with the button's look. A disabled one stays a disabled button. */
23
+ href?: string;
24
+ /** What stands before the glyph, such as a count. */
25
+ before?: Snippet;
26
+ /** What stands after the words, such as a key cap. */
27
+ after?: Snippet;
28
+ type?: "button" | "submit";
29
+ /** Extra explanation, and the place for anything that changes: the running
30
+ * state, or why the button is unavailable. It shows in the hover and focus
31
+ * bubble, joined with the label where the label is hidden, and still
32
+ * reaches a disabled button. */
33
+ title?: string;
34
+ /** This button's own rainbow position, for a colour different from its card's. */
35
+ hueIndex?: number;
36
+ /** The underlying element, bound with `bind:ref`, so a dialog can move focus to it. */
37
+ ref?: HTMLElement | null;
38
+ /** Shows the busy ring in place of the glyph, at once. Separate from `disabled`. */
39
+ busy?: boolean;
40
+ /** For a dialog that opens with focus on one of its buttons. */
41
+ autofocus?: boolean;
42
+ /** Forces a width stage, for two buttons in different components that should
43
+ * match: pass `groupStage([labelA, labelB])` to both. */
44
+ stage?: WidthStage;
45
+ /** Its glyph alone in a square in every label mode, where the words have no
46
+ * room. The label stays the name and the bubble. */
47
+ compact?: boolean;
48
+ /** Turns compact while the window is narrower than this many pixels. */
49
+ compactBelow?: number;
50
+ size?: ButtonSize;
51
+ /** Keeps the label visible in every mode, for a label that is content rather than a verb. */
52
+ keepLabel?: boolean;
53
+ class?: string;
54
+ }
55
+ declare const Button: import("svelte").Component<ButtonProps, {}, "ref">;
56
+ type Button = ReturnType<typeof Button>;
57
+ export default Button;
@@ -0,0 +1,61 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+
4
+ export interface CardProps {
5
+ /** The section name. Omit it where a control inside already carries the same
6
+ * name; the badge still renders to keep the card's hue notch. */
7
+ title?: string;
8
+ /** Takes the title's place in the notch with markup, such as an unsaved dot. */
9
+ drawn?: Snippet;
10
+ /** One line saying what this whole card does, drawn as an "(i)" beside the
11
+ * title. */
12
+ hint?: string;
13
+ children: Snippet;
14
+ /** This card's position in the rainbow, counted across the cards visible on
15
+ * the active tab. Omit it for a tab's only card. */
16
+ hueIndex?: number;
17
+ /** This card sits inside another card that already provides the surface and
18
+ * the padding. */
19
+ nested?: boolean;
20
+ /** Data attributes for the box, so a component built on the card can name itself. */
21
+ [data: `data-${string}`]: string | undefined;
22
+ }
23
+ </script>
24
+
25
+ <script lang="ts">
26
+ import { hueVars } from "@glimstone/core";
27
+ import { css } from "./style.js";
28
+ import Badge from "./Badge.svelte";
29
+ import InfoBubble from "./InfoBubble.svelte";
30
+
31
+ // The surface everything else sits on, and the one place a section heading is
32
+ // drawn.
33
+ //
34
+ // The <h2> holds a filled badge that straddles the card's top edge, so the box
35
+ // is `relative` for the notch to resolve against this card. The `hint` bubble
36
+ // rides inside the badge because the badge is out of normal flow. With a
37
+ // `hueIndex` the card sets `--accent` once for everything inside it, so no button
38
+ // has to derive the hue itself. A nested card drops its surface and side padding
39
+ // but keeps its top padding, which the heading notch pokes into.
40
+ //
41
+ // A card with neither `title` nor `hint` draws no heading.
42
+ let { title, drawn, hint, children, hueIndex, nested, ...data }: CardProps = $props();
43
+ </script>
44
+
45
+ <div
46
+ data-glim="Card"
47
+ data-glim-title={title}
48
+ {...data}
49
+ class={`glim-panel glim-notch-card${nested ? " glim-panel--nested" : ""}${hueIndex !== undefined ? " glim-hue" : ""}`}
50
+ style={hueIndex !== undefined ? css(hueVars(hueIndex)) : undefined}
51
+ >
52
+ {#if title || drawn || hint}
53
+ <h2 class="glim-panel-heading">
54
+ <Badge tone="heading" size="heading" wrap {hueIndex}>
55
+ {#if drawn}{@render drawn()}{:else}{title}{/if}
56
+ {#if hint}<InfoBubble tip={hint} onAccent />{/if}
57
+ </Badge>
58
+ </h2>
59
+ {/if}
60
+ {@render children()}
61
+ </div>
@@ -0,0 +1,23 @@
1
+ import type { Snippet } from "svelte";
2
+ export interface CardProps {
3
+ /** The section name. Omit it where a control inside already carries the same
4
+ * name; the badge still renders to keep the card's hue notch. */
5
+ title?: string;
6
+ /** Takes the title's place in the notch with markup, such as an unsaved dot. */
7
+ drawn?: Snippet;
8
+ /** One line saying what this whole card does, drawn as an "(i)" beside the
9
+ * title. */
10
+ hint?: string;
11
+ children: Snippet;
12
+ /** This card's position in the rainbow, counted across the cards visible on
13
+ * the active tab. Omit it for a tab's only card. */
14
+ hueIndex?: number;
15
+ /** This card sits inside another card that already provides the surface and
16
+ * the padding. */
17
+ nested?: boolean;
18
+ /** Data attributes for the box, so a component built on the card can name itself. */
19
+ [data: `data-${string}`]: string | undefined;
20
+ }
21
+ declare const Card: import("svelte").Component<CardProps, {}, "">;
22
+ type Card = ReturnType<typeof Card>;
23
+ export default Card;
@@ -0,0 +1,72 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { CarouselText } from "@glimstone/core";
4
+
5
+ export type { CarouselText } from "@glimstone/core";
6
+
7
+ export interface CarouselProps<T> {
8
+ /** The carousel's accessible name. */
9
+ label: string;
10
+ items: readonly T[];
11
+ /** The page in force, counted from 0, bound with `bind:page`. Left out, it keeps its own. */
12
+ page?: number;
13
+ onPageChange?: (page: number) => void;
14
+ slidesPerPage?: number;
15
+ /** Goes from the last page on to the first. */
16
+ loop?: boolean;
17
+ /** Draws a slide. */
18
+ slide: Snippet<[T, number]>;
19
+ text?: Partial<CarouselText>;
20
+ }
21
+ </script>
22
+
23
+ <script lang="ts" generics="T">
24
+ import * as carousel from "@zag-js/carousel";
25
+ import { normalizeProps, useMachine } from "@zag-js/svelte";
26
+ import { CAROUSEL_TEXT, pageDir, stillMotion } from "@glimstone/core";
27
+ import Button from "./Button.svelte";
28
+ import { IconBack, IconForward } from "./glyphs.js";
29
+
30
+ // A row of slides seen one page at a time, such as the screenshots of a
31
+ // release. It never moves by itself, since a settled page does not
32
+ // idle-animate, and a move glides only where the motion level allows it.
33
+ let { label, items, page = $bindable(), onPageChange, slidesPerPage = 1, loop = false, slide, text }: CarouselProps<T> = $props();
34
+
35
+ const words = $derived({ ...CAROUSEL_TEXT, ...text });
36
+ const id = $props.id();
37
+ const service = useMachine(carousel.machine, () => ({
38
+ id,
39
+ dir: pageDir(),
40
+ slideCount: items.length,
41
+ slidesPerPage,
42
+ loop,
43
+ page: page ?? 0,
44
+ spacing: "var(--space-6)",
45
+ onPageChange: (d: { page: number }) => {
46
+ page = d.page;
47
+ onPageChange?.(d.page);
48
+ },
49
+ translations: {
50
+ item: (index: number, count: number) => words.slide(index + 1, count),
51
+ indicator: (index: number) => words.goTo(index + 1),
52
+ },
53
+ }));
54
+ const api = $derived(carousel.connect(service, normalizeProps));
55
+ </script>
56
+
57
+ <section data-glim="Carousel" {...api.getRootProps()} aria-label={label} class="glim-carousel">
58
+ <div {...api.getItemGroupProps()} class="glim-carousel-slides">
59
+ {#each items as item, index (index)}
60
+ <div {...api.getItemProps({ index })} class="glim-carousel-slide">{@render slide(item, index)}</div>
61
+ {/each}
62
+ </div>
63
+ <div {...api.getControlProps()} class="glim-carousel-control">
64
+ <Button label={words.previous} labelKey={null} glyph={IconBack} variant="icon" disabled={!api.canScrollPrev} onClick={() => api.scrollPrev(stillMotion())} />
65
+ <div {...api.getIndicatorGroupProps()} class="glim-carousel-dots">
66
+ {#each api.pageSnapPoints as _, index (index)}
67
+ <button {...api.getIndicatorProps({ index })} onclick={() => api.scrollTo(index, stillMotion())} class="glim-carousel-dot"></button>
68
+ {/each}
69
+ </div>
70
+ <Button label={words.next} labelKey={null} glyph={IconForward} variant="icon" disabled={!api.canScrollNext} onClick={() => api.scrollNext(stillMotion())} />
71
+ </div>
72
+ </section>
@@ -0,0 +1,41 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { CarouselText } from "@glimstone/core";
3
+ export type { CarouselText } from "@glimstone/core";
4
+ export interface CarouselProps<T> {
5
+ /** The carousel's accessible name. */
6
+ label: string;
7
+ items: readonly T[];
8
+ /** The page in force, counted from 0, bound with `bind:page`. Left out, it keeps its own. */
9
+ page?: number;
10
+ onPageChange?: (page: number) => void;
11
+ slidesPerPage?: number;
12
+ /** Goes from the last page on to the first. */
13
+ loop?: boolean;
14
+ /** Draws a slide. */
15
+ slide: Snippet<[T, number]>;
16
+ text?: Partial<CarouselText>;
17
+ }
18
+ declare function $$render<T>(): {
19
+ props: CarouselProps<T>;
20
+ exports: {};
21
+ bindings: "page";
22
+ slots: {};
23
+ events: {};
24
+ };
25
+ declare class __sveltets_Render<T> {
26
+ props(): ReturnType<typeof $$render<T>>['props'];
27
+ events(): ReturnType<typeof $$render<T>>['events'];
28
+ slots(): ReturnType<typeof $$render<T>>['slots'];
29
+ bindings(): "page";
30
+ exports(): {};
31
+ }
32
+ interface $$IsomorphicComponent {
33
+ new <T>(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']>> & {
34
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
35
+ } & ReturnType<__sveltets_Render<T>['exports']>;
36
+ <T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
37
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
38
+ }
39
+ declare const Carousel: $$IsomorphicComponent;
40
+ type Carousel<T> = InstanceType<typeof Carousel<T>>;
41
+ export default Carousel;
@@ -0,0 +1,48 @@
1
+ <script lang="ts" module>
2
+ export interface CheckboxProps {
3
+ /** The state, bound with `bind:checked`. */
4
+ checked: boolean;
5
+ /** Called with the flipped value when the box is activated. */
6
+ onChange?: (next: boolean) => void;
7
+ /** Always the accessible name; shown beside the box unless hideLabel. */
8
+ label: string;
9
+ /** For a grid whose row and column headings already say it, such as permissions. */
10
+ hideLabel?: boolean;
11
+ /** The box alone, without the frame and its hover ground, for a row or a cell of a dense list. Hides the label. */
12
+ slim?: boolean;
13
+ disabled?: boolean;
14
+ class?: string;
15
+ }
16
+ </script>
17
+
18
+ <script lang="ts">
19
+ import { IconCheck } from "./glyphs.js";
20
+
21
+ // The checkbox, for the places a box stands instead of a switch (rule 39):
22
+ // "Don't show again" under a notice, and choices that are applied together,
23
+ // such as which columns a list shows. Every setting is a Toggle. It is a
24
+ // button for its look, and like a native checkbox only Space flips it.
25
+ let { checked = $bindable(), onChange, label, hideLabel = false, slim = false, disabled, class: className }: CheckboxProps = $props();
26
+
27
+ const bare = $derived(hideLabel || slim);
28
+
29
+ function flip() {
30
+ checked = !checked;
31
+ onChange?.(checked);
32
+ }
33
+ </script>
34
+
35
+ <button
36
+ data-glim="Checkbox"
37
+ type="button"
38
+ role="checkbox"
39
+ aria-checked={checked}
40
+ aria-label={bare ? label : undefined}
41
+ {disabled}
42
+ onclick={flip}
43
+ onkeydown={(e) => e.key === "Enter" && e.preventDefault()}
44
+ class={["glim-checkbox", slim && "glim-checkbox--slim", className].filter(Boolean).join(" ")}
45
+ >
46
+ <span class="glim-checkbox-box" aria-hidden="true">{@render IconCheck()}</span>
47
+ {#if !bare}<span>{label}</span>{/if}
48
+ </button>
@@ -0,0 +1,17 @@
1
+ export interface CheckboxProps {
2
+ /** The state, bound with `bind:checked`. */
3
+ checked: boolean;
4
+ /** Called with the flipped value when the box is activated. */
5
+ onChange?: (next: boolean) => void;
6
+ /** Always the accessible name; shown beside the box unless hideLabel. */
7
+ label: string;
8
+ /** For a grid whose row and column headings already say it, such as permissions. */
9
+ hideLabel?: boolean;
10
+ /** The box alone, without the frame and its hover ground, for a row or a cell of a dense list. Hides the label. */
11
+ slim?: boolean;
12
+ disabled?: boolean;
13
+ class?: string;
14
+ }
15
+ declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "checked">;
16
+ type Checkbox = ReturnType<typeof Checkbox>;
17
+ export default Checkbox;
@@ -0,0 +1,70 @@
1
+ <script lang="ts" module>
2
+ export interface CoffeeDialogProps {
3
+ /** `https://buymeacoffee.com/widget/page/<handle>` with its query. */
4
+ widgetUrl: string;
5
+ text: {
6
+ title: string;
7
+ /** The app's appeal, the same in every giving window. */
8
+ appeal: string;
9
+ /** One sentence: the payment happens at BMAC, and no account is needed. */
10
+ intro: string;
11
+ closeLabel: string;
12
+ };
13
+ onClose: () => void;
14
+ /** The window's own card, bound with `bind:ref`, for the app's Escape handling and focus trap. */
15
+ ref?: HTMLDivElement | null;
16
+ }
17
+ </script>
18
+
19
+ <script lang="ts">
20
+ import Badge from "./Badge.svelte";
21
+ import Button from "./Button.svelte";
22
+
23
+ // The window for Buy Me a Coffee: the maker's own BMAC widget inside a house
24
+ // window, so a donor pays without leaving the app.
25
+ //
26
+ // The widget page is the one BMAC page that allows framing; the profile page
27
+ // answers X-Frame-Options: SAMEORIGIN. It keeps BMAC's look and every feature
28
+ // BMAC offers there, card and wallet payments included. Mount the window only
29
+ // while it is open, so nothing from BMAC loads before somebody asks for it.
30
+ let { widgetUrl, text, onClose, ref = $bindable(null) }: CoffeeDialogProps = $props();
31
+ </script>
32
+
33
+ <!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
34
+ <div
35
+ class="glim-modal-backdrop"
36
+ onclick={(e) => {
37
+ if (e.target === e.currentTarget) onClose();
38
+ }}
39
+ >
40
+ <!-- As tall as the screen allows less a margin: BMAC's payment step is about
41
+ 1200px, and every pixel here is scrolling a donor is spared. -->
42
+ <div
43
+ data-glim="CoffeeDialog"
44
+ data-glim-title={text.title}
45
+ bind:this={ref}
46
+ tabindex={-1}
47
+ role="dialog"
48
+ aria-modal="true"
49
+ aria-labelledby="coffee-title"
50
+ class="glim-modal-card glim-modal-card--wide glim-modal-card--tall"
51
+ >
52
+ <div class="glim-modal-head">
53
+ <h2 id="coffee-title" class="glim-modal-title">
54
+ <Badge tone="heading" size="heading" wrap>{text.title}</Badge>
55
+ </h2>
56
+ </div>
57
+
58
+ <div class="glim-give-body">
59
+ <p class="glim-give-appeal">{text.appeal}</p>
60
+ <p class="glim-give-intro">{text.intro}</p>
61
+ <div class="glim-give-frame">
62
+ <iframe src={widgetUrl} title={text.title} allow="payment" class="glim-give-iframe"></iframe>
63
+ </div>
64
+ </div>
65
+
66
+ <div class="glim-give-foot">
67
+ <Button label={text.closeLabel} labelKey="common.close" tone="neutral" onClick={onClose} />
68
+ </div>
69
+ </div>
70
+ </div>
@@ -0,0 +1,18 @@
1
+ export interface CoffeeDialogProps {
2
+ /** `https://buymeacoffee.com/widget/page/<handle>` with its query. */
3
+ widgetUrl: string;
4
+ text: {
5
+ title: string;
6
+ /** The app's appeal, the same in every giving window. */
7
+ appeal: string;
8
+ /** One sentence: the payment happens at BMAC, and no account is needed. */
9
+ intro: string;
10
+ closeLabel: string;
11
+ };
12
+ onClose: () => void;
13
+ /** The window's own card, bound with `bind:ref`, for the app's Escape handling and focus trap. */
14
+ ref?: HTMLDivElement | null;
15
+ }
16
+ declare const CoffeeDialog: import("svelte").Component<CoffeeDialogProps, {}, "ref">;
17
+ type CoffeeDialog = ReturnType<typeof CoffeeDialog>;
18
+ export default CoffeeDialog;
@@ -0,0 +1,49 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+
4
+ export interface CollapsibleProps {
5
+ /** The words on the row that opens it, which are also its accessible name. */
6
+ label: string;
7
+ /** Whether it is open, bound with `bind:open`. Left out, it keeps its own state from `defaultOpen`. */
8
+ open?: boolean;
9
+ onOpenChange?: (open: boolean) => void;
10
+ defaultOpen?: boolean;
11
+ disabled?: boolean;
12
+ children: Snippet;
13
+ }
14
+ </script>
15
+
16
+ <script lang="ts">
17
+ import * as collapsible from "@zag-js/collapsible";
18
+ import { normalizeProps, useMachine } from "@zag-js/svelte";
19
+ import { pageDir } from "@glimstone/core";
20
+ import { IconExpand } from "./glyphs.js";
21
+
22
+ // A row that opens the text under it, for reading matter such as the answer
23
+ // under a question on a help page. A settings page keeps rule 26: what would
24
+ // hide under it goes on a sub-card or a page of its own.
25
+ let { label, open = $bindable(), onOpenChange, defaultOpen = false, disabled = false, children }: CollapsibleProps = $props();
26
+
27
+ const id = $props.id();
28
+ const service = useMachine(collapsible.machine, () => ({
29
+ id,
30
+ dir: pageDir(),
31
+ open: open ?? defaultOpen,
32
+ disabled,
33
+ onOpenChange: (d: { open: boolean }) => {
34
+ open = d.open;
35
+ onOpenChange?.(d.open);
36
+ },
37
+ }));
38
+ const api = $derived(collapsible.connect(service, normalizeProps));
39
+ </script>
40
+
41
+ <div data-glim="Collapsible" {...api.getRootProps()} class="glim-collapsible">
42
+ <button {...api.getTriggerProps()} class="glim-disclosure-trigger">
43
+ <span class="glim-disclosure-label">{label}</span>
44
+ <span {...api.getIndicatorProps()} class="glim-disclosure-indicator">{@render IconExpand()}</span>
45
+ </button>
46
+ <div {...api.getContentProps()} class="glim-disclosure-content">
47
+ <div class="glim-disclosure-body">{@render children()}</div>
48
+ </div>
49
+ </div>
@@ -0,0 +1,14 @@
1
+ import type { Snippet } from "svelte";
2
+ export interface CollapsibleProps {
3
+ /** The words on the row that opens it, which are also its accessible name. */
4
+ label: string;
5
+ /** Whether it is open, bound with `bind:open`. Left out, it keeps its own state from `defaultOpen`. */
6
+ open?: boolean;
7
+ onOpenChange?: (open: boolean) => void;
8
+ defaultOpen?: boolean;
9
+ disabled?: boolean;
10
+ children: Snippet;
11
+ }
12
+ declare const Collapsible: import("svelte").Component<CollapsibleProps, {}, "open">;
13
+ type Collapsible = ReturnType<typeof Collapsible>;
14
+ export default Collapsible;