@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,271 @@
1
+ <script lang="ts">
2
+ import { untrack } from "svelte";
3
+ import {
4
+ COPIED_MS,
5
+ copyText,
6
+ fill,
7
+ listOf,
8
+ MARKS,
9
+ phraseReady,
10
+ qrCode,
11
+ shake,
12
+ windowFocusTarget,
13
+ type FortressFlow,
14
+ type FortressLabelKeys,
15
+ type FortressState,
16
+ type FortressText,
17
+ type WindowSize,
18
+ } from "@glimstone/core";
19
+ import MarkSvg from "./MarkSvg.svelte";
20
+ import PasswordField from "./PasswordField.svelte";
21
+ import Window, { type WindowAction } from "./Window.svelte";
22
+ import { glyphFor, IconClose } from "./glyphs.js";
23
+
24
+ // The window in front of the fortress, drawn from the flow's state: join,
25
+ // joined, leave, remove, the phrase and its change.
26
+ let {
27
+ flow,
28
+ flowState,
29
+ text,
30
+ lang,
31
+ app,
32
+ pairedWith,
33
+ leaveNote,
34
+ phraseQr,
35
+ keys,
36
+ }: {
37
+ flow: FortressFlow;
38
+ flowState: FortressState;
39
+ text: FortressText;
40
+ lang: string;
41
+ app: { id: string; name: string };
42
+ pairedWith?: string[];
43
+ leaveNote?: string;
44
+ phraseQr?: (words: string[]) => string;
45
+ keys: FortressLabelKeys;
46
+ } = $props();
47
+
48
+ let card = $state<HTMLElement | null>(null);
49
+ let copied = $state(false);
50
+ const w = $derived(flowState.window!);
51
+ const paired = $derived(pairedWith?.length ? listOf(lang, pairedWith) : null);
52
+ const busy = $derived(flowState.busy !== null);
53
+ const info = $derived(glyphFor("info"));
54
+
55
+ const refusal = $derived(flowState.refusal);
56
+ $effect(() => {
57
+ const button = refusal && card?.querySelector<HTMLElement>(`[data-fortress="${refusal.button}"]`);
58
+ if (button) return shake(button);
59
+ });
60
+ const focus = $derived(w.kind === "join" ? w.focus : -1);
61
+ $effect(() => {
62
+ if (focus >= 0) card?.querySelector<HTMLInputElement>(`[data-word="${focus}"]`)?.focus();
63
+ });
64
+ // The window stays mounted from one step to the next, so the focus it takes
65
+ // on opening does not come again, and the button that was pressed may be gone.
66
+ const kind = $derived(w.kind);
67
+ let opened = false;
68
+ $effect(() => {
69
+ void kind;
70
+ if (!opened) {
71
+ opened = true;
72
+ return;
73
+ }
74
+ const c = untrack(() => card);
75
+ if (c) windowFocusTarget(c)?.focus();
76
+ });
77
+ $effect(() => {
78
+ if (!copied) return;
79
+ const t = setTimeout(() => (copied = false), COPIED_MS);
80
+ return () => clearTimeout(t);
81
+ });
82
+
83
+ function send(button: string, run: () => Promise<void>, label: string, key: string, disabled = false): WindowAction {
84
+ return {
85
+ label,
86
+ labelKey: key,
87
+ primary: true,
88
+ disabled: disabled || busy,
89
+ attrs: { "data-fortress": button },
90
+ onClick: () => {
91
+ void run();
92
+ return false;
93
+ },
94
+ };
95
+ }
96
+ // A space or a paste leaves other words in the field than the ones the flow keeps there.
97
+ function enter(i: number, field: HTMLInputElement) {
98
+ flow.enter(i, field.value);
99
+ const held = w.kind === "join" ? w.words[i] : undefined;
100
+ if (held !== undefined && field.value !== held) field.value = held;
101
+ }
102
+ function copy(words: string[]): WindowAction {
103
+ return {
104
+ label: text.copy,
105
+ labelKey: keys.copy,
106
+ attrs: { "data-fortress": "copy" },
107
+ onClick: () => {
108
+ void copyText(words.join(" ")).then((ok) => (copied = ok));
109
+ return false;
110
+ },
111
+ };
112
+ }
113
+ const frame = $derived.by((): { title: string; size?: WindowSize; actions: WindowAction[] } => {
114
+ switch (w.kind) {
115
+ case "join":
116
+ return { title: text.joinTitle, size: "wide", actions: [send("join", flow.join, text.join, keys.join, !phraseReady(w.words))] };
117
+ case "joined":
118
+ // Window adds Close only to a foot with something in it, so a window that only says something brings its own.
119
+ return { title: text.joinTitle, actions: [{ label: text.close, labelKey: "common.close", glyph: IconClose, wayOut: true }] };
120
+ case "leave":
121
+ return { title: text.leaveTitle, actions: [send("leave", flow.leave, text.leaveConfirm, keys.leave)] };
122
+ case "remove":
123
+ return { title: fill(text.removeTitle, { device: w.device }), actions: [send("remove", flow.remove, text.remove, keys.remove)] };
124
+ case "removed":
125
+ return {
126
+ title: text.removedTitle,
127
+ actions: [{ label: text.later, labelKey: keys.later, wayOut: true, attrs: { "data-fortress": "later" } }, send("change", flow.change, text.changeConfirm, keys.changePhrase)],
128
+ };
129
+ case "phrase":
130
+ return w.step === "password"
131
+ ? { title: text.phraseTitle, actions: [send("unlock", flow.unlock, text.unlock, keys.unlock, w.password === "")] }
132
+ : { title: text.phraseTitle, size: "wide", actions: [copy(w.words)] };
133
+ case "change":
134
+ return { title: text.changeTitle, actions: [send("change", flow.change, text.changeConfirm, keys.changePhrase)] };
135
+ case "changed":
136
+ return { title: text.changedTitle, size: "wide", actions: [copy(w.words)] };
137
+ }
138
+ });
139
+ </script>
140
+
141
+ {#snippet error()}
142
+ {#if flowState.error}<p class="glim-fortress-error" role="alert">{flowState.error}</p>{/if}
143
+ {/snippet}
144
+
145
+ {#snippet words(list: string[])}
146
+ {@const code = qrCode(phraseQr ? phraseQr(list) : list.join(" "))}
147
+ {@const side = code.size + 8}
148
+ <div class="glim-phrase-show">
149
+ <ol class="glim-phrase-words" data-fortress="words">
150
+ {#each list as word, i (i)}
151
+ <li><span class="glim-phrase-number glim-num">{i + 1}</span>{word}</li>
152
+ {/each}
153
+ </ol>
154
+ <!-- A camera reads dark modules on a light ground, so these two colours stay put in every theme. -->
155
+ <svg class="glim-phrase-qr" data-fortress="qr" role="img" aria-label={text.qrName} viewBox={`-4 -4 ${side} ${side}`} shape-rendering="crispEdges">
156
+ <rect x={-4} y={-4} width={side} height={side} fill="#ffffff" />
157
+ <path d={code.path} fill="#161616" />
158
+ </svg>
159
+ <p class="glim-phrase-scan">{text.scanHint}</p>
160
+ </div>
161
+ {/snippet}
162
+
163
+ <Window
164
+ bind:ref={card}
165
+ title={frame.title}
166
+ size={frame.size}
167
+ actions={frame.actions}
168
+ start={copied ? text.copied : undefined}
169
+ text={{ cancel: text.cancel, close: text.close }}
170
+ onClose={flow.close}
171
+ >
172
+ {#if w.kind === "join"}
173
+ <form
174
+ class="glim-fortress-text"
175
+ onsubmit={(e) => {
176
+ e.preventDefault();
177
+ void flow.join();
178
+ }}
179
+ >
180
+ <p>{text.about}</p>
181
+ <div class="glim-phrase-fields">
182
+ {#each w.words as word, i (i)}
183
+ <label class="glim-phrase-field">
184
+ <span class="glim-phrase-number glim-num">{i + 1}</span>
185
+ <input
186
+ class="glim-input"
187
+ data-word={i}
188
+ value={word}
189
+ aria-label={fill(text.word, { n: i + 1 })}
190
+ autocomplete="off"
191
+ autocapitalize="none"
192
+ autocorrect="off"
193
+ spellcheck={false}
194
+ oninput={(e) => enter(i, e.currentTarget)}
195
+ />
196
+ </label>
197
+ {/each}
198
+ </div>
199
+ <!-- svelte-ignore a11y_consider_explicit_label -->
200
+ <button type="submit" hidden></button>
201
+ <p class="glim-fortress-sub">{text.phraseWhere}</p>
202
+ {#if paired}
203
+ <p class="glim-fortress-note" data-fortress="moves">
204
+ {#if info}{@render info()}{/if}
205
+ <span>{fill(text.moves, { app: app.name, devices: paired })}</span>
206
+ </p>
207
+ {/if}
208
+ {@render error()}
209
+ </form>
210
+ {:else if w.kind === "joined"}
211
+ <div class="glim-fortress-result">
212
+ <span class="glim-fortress-result-mark" aria-hidden="true"><MarkSvg mark={MARKS.check} /></span>
213
+ <div class="glim-fortress-text">
214
+ <p class="glim-fortress-result-title">{fill(text.joinedTitle, { app: app.name })}</p>
215
+ <p class="glim-fortress-sub">{paired ? `${fill(text.joinedMoved, { devices: paired })} ` : ""}{text.joinedNext}</p>
216
+ </div>
217
+ </div>
218
+ {:else if w.kind === "leave"}
219
+ <div class="glim-fortress-text">
220
+ <p>{fill(text.leaveBody, { app: app.name })}{paired ? ` ${fill(text.leavePairing, { devices: paired })}` : ""}{leaveNote ? ` ${leaveNote}` : ""}</p>
221
+ <p class="glim-fortress-sub">{text.leaveBack}</p>
222
+ {@render error()}
223
+ </div>
224
+ {:else if w.kind === "remove"}
225
+ <div class="glim-fortress-text">
226
+ <p>{fill(text.removeBody, { device: w.device })}</p>
227
+ <p class="glim-fortress-sub">{text.removeBack}</p>
228
+ {@render error()}
229
+ </div>
230
+ {:else if w.kind === "removed"}
231
+ <div class="glim-fortress-text">
232
+ <p>{fill(text.removedBody, { device: w.device })}</p>
233
+ {@render error()}
234
+ </div>
235
+ {:else if w.kind === "phrase" && w.step === "password"}
236
+ <form
237
+ class="glim-fortress-text"
238
+ onsubmit={(e) => {
239
+ e.preventDefault();
240
+ void flow.unlock();
241
+ }}
242
+ >
243
+ <p>{fill(text.phrasePassword, { app: app.name })}</p>
244
+ <PasswordField
245
+ aria-label={fill(text.password, { app: app.name })}
246
+ placeholder={fill(text.password, { app: app.name })}
247
+ value={w.password}
248
+ oninput={(e) => flow.setPassword(e.currentTarget.value)}
249
+ text={{ show: text.showPassword, hide: text.hidePassword }}
250
+ />
251
+ {@render error()}
252
+ </form>
253
+ {:else if w.kind === "phrase"}
254
+ <div class="glim-fortress-text">
255
+ <p>{text.phraseBody}</p>
256
+ {@render words(w.words)}
257
+ </div>
258
+ {:else if w.kind === "change"}
259
+ <div class="glim-fortress-text">
260
+ <p>{text.changeBody}</p>
261
+ <p class="glim-fortress-sub">{text.changeAway}</p>
262
+ {@render error()}
263
+ </div>
264
+ {:else if w.kind === "changed"}
265
+ <div class="glim-fortress-text">
266
+ <p>{text.phraseBody}</p>
267
+ {@render words(w.words)}
268
+ {#if w.left.length > 0}<p class="glim-fortress-sub">{fill(text.changedLeft, { devices: listOf(lang, w.left) })}</p>{/if}
269
+ </div>
270
+ {/if}
271
+ </Window>
@@ -0,0 +1,18 @@
1
+ import { type FortressFlow, type FortressLabelKeys, type FortressState, type FortressText } from "@glimstone/core";
2
+ type $$ComponentProps = {
3
+ flow: FortressFlow;
4
+ flowState: FortressState;
5
+ text: FortressText;
6
+ lang: string;
7
+ app: {
8
+ id: string;
9
+ name: string;
10
+ };
11
+ pairedWith?: string[];
12
+ leaveNote?: string;
13
+ phraseQr?: (words: string[]) => string;
14
+ keys: FortressLabelKeys;
15
+ };
16
+ declare const FortressWindow: import("svelte").Component<$$ComponentProps, {}, "">;
17
+ type FortressWindow = ReturnType<typeof FortressWindow>;
18
+ export default FortressWindow;
@@ -0,0 +1,52 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { HTMLInputAttributes } from "svelte/elements";
4
+ import type { FieldWidth } from "@glimstone/core";
5
+
6
+ export interface GlyphFieldProps extends Omit<HTMLInputAttributes, "width" | "class"> {
7
+ glyph: Snippet;
8
+ /** The accessible name. Inside a FieldRow the row gives it. */
9
+ label?: string;
10
+ /** Controls inside the box, after the field, such as a clear button. */
11
+ after?: Snippet;
12
+ /** Sets a path or a token in monospace. */
13
+ mono?: boolean;
14
+ width?: FieldWidth;
15
+ /** Classes for the box, which carries the width. */
16
+ class?: string;
17
+ /** The input, bound with `bind:ref`. */
18
+ ref?: HTMLInputElement | null;
19
+ }
20
+ </script>
21
+
22
+ <script lang="ts">
23
+ import { fieldWidthClass } from "@glimstone/core";
24
+ import { useFieldName } from "./fieldName.js";
25
+
26
+ // A field with a glyph inside it, such as a filter or a search, bound with
27
+ // `bind:value`. The box is the field: it steps up the ramp while the input has
28
+ // focus (rule 14), and being a <label> it hands a click on the glyph to the
29
+ // input. The other props of an <input> go to the input.
30
+ let {
31
+ glyph,
32
+ label,
33
+ after,
34
+ mono,
35
+ width,
36
+ class: className,
37
+ style,
38
+ type = "text",
39
+ value = $bindable(),
40
+ ref = $bindable(null),
41
+ ...rest
42
+ }: GlyphFieldProps = $props();
43
+
44
+ const name = useFieldName(() => label);
45
+ const classes = $derived(["glim-input", "glim-glyph-field", fieldWidthClass(width), mono && "glim-input--mono", className].filter(Boolean).join(" "));
46
+ </script>
47
+
48
+ <label data-glim="GlyphField" class={classes} {style}>
49
+ <span class="glim-glyph-field-glyph" aria-hidden="true">{@render glyph()}</span>
50
+ <input aria-label={name()} {...rest} bind:value bind:this={ref} {type} class="glim-glyph-field-input" />
51
+ {@render after?.()}
52
+ </label>
@@ -0,0 +1,20 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLInputAttributes } from "svelte/elements";
3
+ import type { FieldWidth } from "@glimstone/core";
4
+ export interface GlyphFieldProps extends Omit<HTMLInputAttributes, "width" | "class"> {
5
+ glyph: Snippet;
6
+ /** The accessible name. Inside a FieldRow the row gives it. */
7
+ label?: string;
8
+ /** Controls inside the box, after the field, such as a clear button. */
9
+ after?: Snippet;
10
+ /** Sets a path or a token in monospace. */
11
+ mono?: boolean;
12
+ width?: FieldWidth;
13
+ /** Classes for the box, which carries the width. */
14
+ class?: string;
15
+ /** The input, bound with `bind:ref`. */
16
+ ref?: HTMLInputElement | null;
17
+ }
18
+ declare const GlyphField: import("svelte").Component<GlyphFieldProps, {}, "value" | "ref">;
19
+ type GlyphField = ReturnType<typeof GlyphField>;
20
+ export default GlyphField;
@@ -0,0 +1,25 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+
4
+ export interface GlyphTileProps {
5
+ glyph: Snippet;
6
+ /** Takes the accent off the glyph, such as for a file among folders. */
7
+ quiet?: boolean;
8
+ /** Sets it on the third surface, for a place where a bare glyph gets lost. */
9
+ ground?: boolean;
10
+ /** Fills it with the accent, as a row around it being reached does. */
11
+ active?: boolean;
12
+ class?: string;
13
+ }
14
+ </script>
15
+
16
+ <script lang="ts">
17
+ // A small holder for a glyph at the start of a row or beside a name. It is a
18
+ // picture: the words beside it name the row.
19
+ let { glyph, quiet, ground, active, class: className }: GlyphTileProps = $props();
20
+ const classes = $derived(
21
+ ["glim-tile", quiet && "glim-tile--quiet", ground && "glim-tile--ground", active && "glim-tile--active", className].filter(Boolean).join(" "),
22
+ );
23
+ </script>
24
+
25
+ <span data-glim="GlyphTile" class={classes} aria-hidden="true">{@render glyph()}</span>
@@ -0,0 +1,14 @@
1
+ import type { Snippet } from "svelte";
2
+ export interface GlyphTileProps {
3
+ glyph: Snippet;
4
+ /** Takes the accent off the glyph, such as for a file among folders. */
5
+ quiet?: boolean;
6
+ /** Sets it on the third surface, for a place where a bare glyph gets lost. */
7
+ ground?: boolean;
8
+ /** Fills it with the accent, as a row around it being reached does. */
9
+ active?: boolean;
10
+ class?: string;
11
+ }
12
+ declare const GlyphTile: import("svelte").Component<GlyphTileProps, {}, "">;
13
+ type GlyphTile = ReturnType<typeof GlyphTile>;
14
+ export default GlyphTile;
@@ -0,0 +1,47 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+
4
+ export interface HoverCardProps {
5
+ /** The link's words. */
6
+ label: string;
7
+ href: string;
8
+ /** How long the pointer rests before the card opens, and after it leaves before it closes, in ms. */
9
+ openDelay?: number;
10
+ closeDelay?: number;
11
+ /** Draws the card. */
12
+ content: Snippet;
13
+ }
14
+ </script>
15
+
16
+ <script lang="ts">
17
+ import * as hoverCard from "@zag-js/hover-card";
18
+ import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
19
+ import { pageDir } from "@glimstone/core";
20
+ import { lift } from "./lift.js";
21
+ import { usePortalHue } from "./portalHue.svelte.js";
22
+
23
+ // A card that shows what a link leads to while the pointer rests on it or the
24
+ // keyboard reaches it, such as the details of a server named in a sentence.
25
+ // It only previews: everything in it is also behind the link, so a touch
26
+ // screen, which has no hover, loses nothing.
27
+ let { label, href, openDelay = 600, closeDelay = 300, content }: HoverCardProps = $props();
28
+
29
+ const id = $props.id();
30
+ const service = useMachine(hoverCard.machine, () => ({
31
+ id,
32
+ dir: pageDir(),
33
+ openDelay,
34
+ closeDelay,
35
+ positioning: { placement: "bottom" as const, gutter: 8 },
36
+ }));
37
+ const api = $derived(hoverCard.connect(service, normalizeProps));
38
+ let trigger = $state<HTMLAnchorElement | null>(null);
39
+ const hue = usePortalHue(() => api.open, () => trigger);
40
+ </script>
41
+
42
+ <a data-glim="HoverCard" {...api.getTriggerProps()} bind:this={trigger} {href} class="glim-hovercard-link">{label}</a>
43
+ {#if api.open}
44
+ <div {@attach lift} {...mergeProps(api.getPositionerProps(), { style: hue.style })} class={`glim-hovercard-positioner ${hue.className}`.trim()}>
45
+ <div {...api.getContentProps()} class="glim-hovercard">{@render content()}</div>
46
+ </div>
47
+ {/if}
@@ -0,0 +1,14 @@
1
+ import type { Snippet } from "svelte";
2
+ export interface HoverCardProps {
3
+ /** The link's words. */
4
+ label: string;
5
+ href: string;
6
+ /** How long the pointer rests before the card opens, and after it leaves before it closes, in ms. */
7
+ openDelay?: number;
8
+ closeDelay?: number;
9
+ /** Draws the card. */
10
+ content: Snippet;
11
+ }
12
+ declare const HoverCard: import("svelte").Component<HoverCardProps, {}, "">;
13
+ type HoverCard = ReturnType<typeof HoverCard>;
14
+ export default HoverCard;
@@ -0,0 +1,49 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { HTMLButtonAttributes } from "svelte/elements";
4
+
5
+ export interface IconButtonProps extends Omit<HTMLButtonAttributes, "children" | "type" | "class" | "disabled" | "style"> {
6
+ /** The hover and focus explanation, and the button's accessible name. */
7
+ tip: string;
8
+ glyph: Snippet;
9
+ /** Makes it a link in the same square. */
10
+ href?: string;
11
+ /** Set for a button that stays on or off: it says so, and the accent washes it while it is on. */
12
+ pressed?: boolean;
13
+ /** Draws no button and keeps its square, so the others of a row stay where they are. */
14
+ absent?: boolean;
15
+ disabled?: boolean;
16
+ type?: "button" | "submit";
17
+ class?: string;
18
+ style?: string;
19
+ }
20
+ </script>
21
+
22
+ <script lang="ts">
23
+ import { takePageHue } from "@glimstone/core";
24
+ import IconTipButton from "./IconTipButton.svelte";
25
+
26
+ // A glyph in a square in every label mode, for a row or a dense toolbar that
27
+ // keeps its text. Everything else with one action is a Button with
28
+ // variant="icon", which follows the label mode. The other props of a <button>
29
+ // go to the button.
30
+ let { tip, glyph, pressed, absent, class: className, ...rest }: IconButtonProps = $props();
31
+
32
+ const reach = (e: Event) => takePageHue(e.currentTarget as HTMLElement);
33
+ </script>
34
+
35
+ {#if absent}
36
+ <span data-glim="IconButton" class="glim-icon-btn-gap" aria-hidden="true"></span>
37
+ {:else}
38
+ <IconTipButton
39
+ data-glim="IconButton"
40
+ {...rest}
41
+ {tip}
42
+ ariaPressed={pressed}
43
+ class={`glim-btn-bare glim-icon-btn ${className ?? ""}`.trim()}
44
+ onpointerenter={reach}
45
+ onfocusin={reach}
46
+ >
47
+ {@render glyph()}
48
+ </IconTipButton>
49
+ {/if}
@@ -0,0 +1,20 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLButtonAttributes } from "svelte/elements";
3
+ export interface IconButtonProps extends Omit<HTMLButtonAttributes, "children" | "type" | "class" | "disabled" | "style"> {
4
+ /** The hover and focus explanation, and the button's accessible name. */
5
+ tip: string;
6
+ glyph: Snippet;
7
+ /** Makes it a link in the same square. */
8
+ href?: string;
9
+ /** Set for a button that stays on or off: it says so, and the accent washes it while it is on. */
10
+ pressed?: boolean;
11
+ /** Draws no button and keeps its square, so the others of a row stay where they are. */
12
+ absent?: boolean;
13
+ disabled?: boolean;
14
+ type?: "button" | "submit";
15
+ class?: string;
16
+ style?: string;
17
+ }
18
+ declare const IconButton: import("svelte").Component<IconButtonProps, {}, "">;
19
+ type IconButton = ReturnType<typeof IconButton>;
20
+ export default IconButton;
@@ -0,0 +1,67 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { HTMLButtonAttributes } from "svelte/elements";
4
+
5
+ export interface IconTipButtonProps extends Omit<HTMLButtonAttributes, "children" | "type" | "class" | "disabled" | "style"> {
6
+ /** The hover and focus explanation, and the button's `aria-label`. */
7
+ tip: string;
8
+ disabled?: boolean;
9
+ class?: string;
10
+ /** `aria-pressed` for a trigger that toggles rather than acts once. Omitted,
11
+ * no attribute is rendered. */
12
+ ariaPressed?: boolean;
13
+ /** `aria-expanded` for a trigger that opens a disclosure panel. Omitted, no
14
+ * attribute is rendered. */
15
+ ariaExpanded?: boolean;
16
+ /** Inline style, so a hued Badge can set its `--item-hue*` properties. */
17
+ style?: string;
18
+ children: Snippet;
19
+ /** Makes it a link. A disabled one stays a disabled button. */
20
+ href?: string;
21
+ type?: "button" | "submit";
22
+ }
23
+ </script>
24
+
25
+ <script lang="ts">
26
+ import { useTipBubble } from "./bubble.svelte.js";
27
+ import TipBubble from "./TipBubble.svelte";
28
+ import TipWrap from "./TipWrap.svelte";
29
+
30
+ // An icon-only <button> whose accessible name and hover or focus explanation is
31
+ // a `.glim-bubble` tooltip rather than the native `title=` balloon. `tip` is
32
+ // required because an icon-only button has no other way to say what it does.
33
+ //
34
+ // Unlike Button, this control has no label to hide: a bare glyph in a box the
35
+ // caller sizes, with no width stage, no tone fill and no place in the label
36
+ // mode engine. The other props of a <button> go to the button.
37
+ let { tip, disabled, class: className, style, children, href, type = "button", ariaPressed, ariaExpanded, ...rest }: IconTipButtonProps = $props();
38
+
39
+ const tooltip = useTipBubble(() => tip, () => !!disabled);
40
+ const link = $derived(!!href && !disabled);
41
+ </script>
42
+
43
+ <TipWrap on={!!disabled && !!tip} show={tooltip.show} hide={tooltip.hide}>
44
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
45
+ <svelte:element
46
+ this={link ? "a" : "button"}
47
+ data-glim="IconTipButton"
48
+ {...rest}
49
+ href={link ? href : undefined}
50
+ type={link ? undefined : type}
51
+ disabled={link ? undefined : disabled}
52
+ bind:this={tooltip.trigger}
53
+ aria-label={tip}
54
+ aria-pressed={ariaPressed}
55
+ aria-expanded={ariaExpanded}
56
+ aria-describedby={tooltip.describedBy}
57
+ onmouseenter={tooltip.show}
58
+ onmouseleave={tooltip.hide}
59
+ onfocus={tooltip.showOnFocus}
60
+ onblur={tooltip.hide}
61
+ class={className}
62
+ {style}
63
+ >
64
+ {@render children()}
65
+ </svelte:element>
66
+ </TipWrap>
67
+ <TipBubble state={tooltip} />
@@ -0,0 +1,23 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLButtonAttributes } from "svelte/elements";
3
+ export interface IconTipButtonProps extends Omit<HTMLButtonAttributes, "children" | "type" | "class" | "disabled" | "style"> {
4
+ /** The hover and focus explanation, and the button's `aria-label`. */
5
+ tip: string;
6
+ disabled?: boolean;
7
+ class?: string;
8
+ /** `aria-pressed` for a trigger that toggles rather than acts once. Omitted,
9
+ * no attribute is rendered. */
10
+ ariaPressed?: boolean;
11
+ /** `aria-expanded` for a trigger that opens a disclosure panel. Omitted, no
12
+ * attribute is rendered. */
13
+ ariaExpanded?: boolean;
14
+ /** Inline style, so a hued Badge can set its `--item-hue*` properties. */
15
+ style?: string;
16
+ children: Snippet;
17
+ /** Makes it a link. A disabled one stays a disabled button. */
18
+ href?: string;
19
+ type?: "button" | "submit";
20
+ }
21
+ declare const IconTipButton: import("svelte").Component<IconTipButtonProps, {}, "">;
22
+ type IconTipButton = ReturnType<typeof IconTipButton>;
23
+ export default IconTipButton;