@glimstone/svelte 0.0.0-stage → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,70 @@
1
+ <script lang="ts" module>
2
+ import type { HTMLInputAttributes } from "svelte/elements";
3
+
4
+ export interface NumberFieldProps extends Omit<HTMLInputAttributes, "type" | "class"> {
5
+ /** The bounds and the step. The steppers, the arrow keys and the wheel all
6
+ * go through the input's own stepUp(), so the range lives here alone. */
7
+ min?: number | string;
8
+ max?: number | string;
9
+ step?: number | string;
10
+ /** Called alike for typing, the arrow keys, the steppers and the wheel,
11
+ * which steps the value only while the field has focus. */
12
+ onChange?: (e: Event & { currentTarget: EventTarget & HTMLInputElement }) => void;
13
+ /** Why the value cannot stand, as a line under the field until it is fixed. */
14
+ error?: string;
15
+ /** Classes for the input. A width set here has to be definite, since the
16
+ * arrows sit against the input's end. */
17
+ class?: string;
18
+ /** The <input>, bound with `bind:ref`. */
19
+ ref?: HTMLInputElement | null;
20
+ }
21
+ </script>
22
+
23
+ <script lang="ts">
24
+ import { attachNumberSteppers, fieldErrorView, syncNumberSteppers } from "@glimstone/core";
25
+ import FieldError from "./FieldError.svelte";
26
+ import { useFieldName } from "./fieldName.js";
27
+
28
+ // A number input with its two steppers inside the field; the steppers, the
29
+ // wheel and the greying at the ends come from numberField.ts in the core. The
30
+ // props are a native <input>'s, so a call site swaps `<input type="number"`
31
+ // for `<NumberField`; the number is bound with `bind:value`, null while the
32
+ // field is empty. Inside a FieldRow the row names it.
33
+ let {
34
+ value = $bindable(),
35
+ class: className = "",
36
+ ref = $bindable(null),
37
+ error,
38
+ onChange,
39
+ "aria-label": ariaLabel,
40
+ "aria-describedby": describedBy,
41
+ ...rest
42
+ }: NumberFieldProps = $props();
43
+
44
+ const name = useFieldName(() => ariaLabel ?? undefined);
45
+ const own = $props.id();
46
+ const err = $derived(fieldErrorView(error, rest.id ?? own, describedBy ?? undefined));
47
+
48
+ $effect(() => attachNumberSteppers(ref!));
49
+
50
+ // A value the app sets fires no input event, so the arrows look again.
51
+ $effect(() => {
52
+ void [value, rest.min, rest.max, rest.step, rest.disabled, rest.readonly];
53
+ syncNumberSteppers(ref!);
54
+ });
55
+ </script>
56
+
57
+ <span data-glim="NumberField" class="glim-num-wrap">
58
+ <input
59
+ {...rest}
60
+ aria-label={name()}
61
+ aria-invalid={err.invalid}
62
+ aria-describedby={err.describedBy}
63
+ bind:this={ref}
64
+ bind:value
65
+ oninput={(e) => onChange?.(e)}
66
+ type="number"
67
+ class={`glim-num-input glim-num-field glim-num ${className}`.trim()}
68
+ />
69
+ </span>
70
+ {#if err.errorId}<FieldError id={err.errorId}>{error}</FieldError>{/if}
@@ -0,0 +1,23 @@
1
+ import type { HTMLInputAttributes } from "svelte/elements";
2
+ export interface NumberFieldProps extends Omit<HTMLInputAttributes, "type" | "class"> {
3
+ /** The bounds and the step. The steppers, the arrow keys and the wheel all
4
+ * go through the input's own stepUp(), so the range lives here alone. */
5
+ min?: number | string;
6
+ max?: number | string;
7
+ step?: number | string;
8
+ /** Called alike for typing, the arrow keys, the steppers and the wheel,
9
+ * which steps the value only while the field has focus. */
10
+ onChange?: (e: Event & {
11
+ currentTarget: EventTarget & HTMLInputElement;
12
+ }) => void;
13
+ /** Why the value cannot stand, as a line under the field until it is fixed. */
14
+ error?: string;
15
+ /** Classes for the input. A width set here has to be definite, since the
16
+ * arrows sit against the input's end. */
17
+ class?: string;
18
+ /** The <input>, bound with `bind:ref`. */
19
+ ref?: HTMLInputElement | null;
20
+ }
21
+ declare const NumberField: import("svelte").Component<NumberFieldProps, {}, "value" | "ref">;
22
+ type NumberField = ReturnType<typeof NumberField>;
23
+ export default NumberField;
@@ -0,0 +1,62 @@
1
+ <script lang="ts" module>
2
+ import type { PaginationText } from "@glimstone/core";
3
+
4
+ export type { PaginationText } from "@glimstone/core";
5
+
6
+ export interface PaginationProps {
7
+ /** How many items the pages hold between them. */
8
+ count: number;
9
+ pageSize?: number;
10
+ /** The page in force, counted from 1, bound with `bind:page`. Left out, it keeps its own. */
11
+ page?: number;
12
+ onPageChange?: (page: number) => void;
13
+ /** How many pages stand on each side of the one in force before a gap. */
14
+ siblingCount?: number;
15
+ text?: Partial<PaginationText>;
16
+ }
17
+ </script>
18
+
19
+ <script lang="ts">
20
+ import * as pagination from "@zag-js/pagination";
21
+ import { normalizeProps, useMachine } from "@zag-js/svelte";
22
+ import { PAGINATION_TEXT, pageDir } from "@glimstone/core";
23
+ import Button from "./Button.svelte";
24
+ import { IconBack, IconForward } from "./glyphs.js";
25
+
26
+ // The pages of a long list, for the place a list cannot show every row at once.
27
+ // The page in force is filled with the accent, as anything chosen is, and the
28
+ // two steps follow the label mode like every other button.
29
+ let { count, pageSize = 10, page = $bindable(), onPageChange, siblingCount = 1, text }: PaginationProps = $props();
30
+
31
+ const words = $derived({ ...PAGINATION_TEXT, ...text });
32
+ const id = $props.id();
33
+ const service = useMachine(pagination.machine, () => ({
34
+ id,
35
+ dir: pageDir(),
36
+ count,
37
+ pageSize,
38
+ siblingCount,
39
+ page: page ?? 1,
40
+ onPageChange: (d: { page: number }) => {
41
+ page = d.page;
42
+ onPageChange?.(d.page);
43
+ },
44
+ translations: {
45
+ rootLabel: words.label,
46
+ itemLabel: (d: { page: number; totalPages: number }) => words.page(d.page, d.totalPages),
47
+ },
48
+ }));
49
+ const api = $derived(pagination.connect(service, normalizeProps));
50
+ </script>
51
+
52
+ <nav data-glim="Pagination" {...api.getRootProps()} class="glim-pagination">
53
+ <Button label={words.previous} labelKey={null} glyph={IconBack} variant="icon" disabled={api.previousPage === null} onClick={() => api.goToPrevPage()} />
54
+ {#each api.pages as p, index (p.type === "page" ? p.value : `gap-${index}`)}
55
+ {#if p.type === "page"}
56
+ <button {...api.getItemProps(p)} class="glim-page glim-num">{p.value}</button>
57
+ {:else}
58
+ <span {...api.getEllipsisProps({ index })} class="glim-page-gap">…</span>
59
+ {/if}
60
+ {/each}
61
+ <Button label={words.next} labelKey={null} glyph={IconForward} variant="icon" disabled={api.nextPage === null} onClick={() => api.goToNextPage()} />
62
+ </nav>
@@ -0,0 +1,16 @@
1
+ import type { PaginationText } from "@glimstone/core";
2
+ export type { PaginationText } from "@glimstone/core";
3
+ export interface PaginationProps {
4
+ /** How many items the pages hold between them. */
5
+ count: number;
6
+ pageSize?: number;
7
+ /** The page in force, counted from 1, bound with `bind:page`. Left out, it keeps its own. */
8
+ page?: number;
9
+ onPageChange?: (page: number) => void;
10
+ /** How many pages stand on each side of the one in force before a gap. */
11
+ siblingCount?: number;
12
+ text?: Partial<PaginationText>;
13
+ }
14
+ declare const Pagination: import("svelte").Component<PaginationProps, {}, "page">;
15
+ type Pagination = ReturnType<typeof Pagination>;
16
+ export default Pagination;
@@ -0,0 +1,69 @@
1
+ <script lang="ts" module>
2
+ import type { HTMLInputAttributes } from "svelte/elements";
3
+ import type { FieldWidth } from "@glimstone/core";
4
+
5
+ export interface PasswordFieldProps extends Omit<HTMLInputAttributes, "type" | "width" | "class"> {
6
+ width?: FieldWidth;
7
+ /** Attributes for the eye, such as a data hook. */
8
+ eyeAttrs?: Record<string, string>;
9
+ /** The eye's name and bubble while the secret is hidden, and once it shows. */
10
+ text?: { show: string; hide: string };
11
+ /** Why the value cannot stand, as a line under the field until it is fixed. */
12
+ error?: string;
13
+ /** Classes for the wrapper, which carries the field's width. */
14
+ class?: string;
15
+ /** The <input>, bound with `bind:ref`. */
16
+ ref?: HTMLInputElement | null;
17
+ }
18
+ </script>
19
+
20
+ <script lang="ts">
21
+ import { fieldErrorView, fieldWidthClass } from "@glimstone/core";
22
+ import FieldError from "./FieldError.svelte";
23
+ import { useFieldName } from "./fieldName.js";
24
+ import { IconEye, IconEyeOff } from "./glyphs.js";
25
+ import IconTipButton from "./IconTipButton.svelte";
26
+
27
+ // A field for a secret with the reveal eye inside it ("The reveal eye" in the
28
+ // design language). The props are a native <input>'s, so a call site swaps
29
+ // `<input type="password"` for `<PasswordField` and keeps its own listeners;
30
+ // the secret is bound with `bind:value`. Inside a FieldRow the row names it.
31
+ let {
32
+ width,
33
+ eyeAttrs,
34
+ text = { show: "Show", hide: "Hide" },
35
+ error,
36
+ class: className,
37
+ ref = $bindable(null),
38
+ disabled,
39
+ value = $bindable(),
40
+ "aria-label": ariaLabel,
41
+ "aria-describedby": describedBy,
42
+ ...rest
43
+ }: PasswordFieldProps = $props();
44
+
45
+ let shown = $state(false);
46
+ const name = useFieldName(() => ariaLabel ?? undefined);
47
+ const own = $props.id();
48
+ const err = $derived(fieldErrorView(error, rest.id ?? own, describedBy ?? undefined));
49
+ </script>
50
+
51
+ <span data-glim="PasswordField" class={["glim-secret", fieldWidthClass(width), className].filter(Boolean).join(" ")}>
52
+ <input
53
+ autocomplete="current-password"
54
+ spellcheck={false}
55
+ {...rest}
56
+ aria-label={name()}
57
+ aria-invalid={err.invalid}
58
+ aria-describedby={err.describedBy}
59
+ bind:this={ref}
60
+ bind:value
61
+ {disabled}
62
+ type={shown ? "text" : "password"}
63
+ class="glim-input"
64
+ />
65
+ <IconTipButton {...eyeAttrs} tip={shown ? text.hide : text.show} class="glim-secret-eye" disabled={!!disabled} onclick={() => (shown = !shown)}>
66
+ {#if shown}{@render IconEyeOff()}{:else}{@render IconEye()}{/if}
67
+ </IconTipButton>
68
+ </span>
69
+ {#if err.errorId}<FieldError id={err.errorId}>{error}</FieldError>{/if}
@@ -0,0 +1,21 @@
1
+ import type { HTMLInputAttributes } from "svelte/elements";
2
+ import type { FieldWidth } from "@glimstone/core";
3
+ export interface PasswordFieldProps extends Omit<HTMLInputAttributes, "type" | "width" | "class"> {
4
+ width?: FieldWidth;
5
+ /** Attributes for the eye, such as a data hook. */
6
+ eyeAttrs?: Record<string, string>;
7
+ /** The eye's name and bubble while the secret is hidden, and once it shows. */
8
+ text?: {
9
+ show: string;
10
+ hide: string;
11
+ };
12
+ /** Why the value cannot stand, as a line under the field until it is fixed. */
13
+ error?: string;
14
+ /** Classes for the wrapper, which carries the field's width. */
15
+ class?: string;
16
+ /** The <input>, bound with `bind:ref`. */
17
+ ref?: HTMLInputElement | null;
18
+ }
19
+ declare const PasswordField: import("svelte").Component<PasswordFieldProps, {}, "value" | "ref">;
20
+ type PasswordField = ReturnType<typeof PasswordField>;
21
+ export default PasswordField;
@@ -0,0 +1,111 @@
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 PathFieldProps extends Omit<HTMLInputAttributes, "value" | "type" | "width" | "class"> {
7
+ /** The path, bound with `bind:value`. */
8
+ value: string;
9
+ /** Called with the path as it is typed and as the picker answers. */
10
+ onChange?: (path: string) => void;
11
+ /** Handed the path in the field. Answers with a path, or with nothing when the person left. */
12
+ pick: (current: string) => string | null | undefined | Promise<string | null | undefined>;
13
+ /** Called with a path the picker answered with, after onChange. */
14
+ onPicked?: (path: string) => void;
15
+ /** The accessible name. Inside a FieldRow the row gives it. */
16
+ label?: string;
17
+ width?: FieldWidth;
18
+ /** The button's words. */
19
+ text?: { pick: string };
20
+ /** The button's glyph, an open folder unless set, such as a file for a picker of files. */
21
+ glyph?: Snippet;
22
+ /** Shows the button's glyph alone, as it does by itself with less than 20rem of room. */
23
+ compact?: boolean;
24
+ /** Attributes for the button, such as a data hook. */
25
+ buttonAttrs?: Record<string, string>;
26
+ /** Classes for the wrapper, which carries the width. */
27
+ class?: string;
28
+ /** The <input>, bound with `bind:ref`. */
29
+ ref?: HTMLInputElement | null;
30
+ }
31
+ </script>
32
+
33
+ <script lang="ts">
34
+ import { tick } from "svelte";
35
+ import { fieldWidthClass, PATH_ROOM_PX } from "@glimstone/core";
36
+ import Button from "./Button.svelte";
37
+ import { useFieldName } from "./fieldName.js";
38
+ import { IconFolderOpen } from "./glyphs.js";
39
+
40
+ // A path to type and a button that asks the app for one. GlimStone does not
41
+ // know where an app's folders come from, so `pick` is the app's own: it opens
42
+ // whatever it opens and answers with a path. The other props of an <input> go
43
+ // to the field.
44
+ let {
45
+ value = $bindable(),
46
+ onChange,
47
+ pick,
48
+ onPicked,
49
+ label,
50
+ width,
51
+ text = { pick: "Choose" },
52
+ glyph,
53
+ compact = false,
54
+ buttonAttrs,
55
+ class: className,
56
+ style,
57
+ disabled,
58
+ ref = $bindable(null),
59
+ ...rest
60
+ }: PathFieldProps = $props();
61
+
62
+ const name = useFieldName(() => label);
63
+ let box: HTMLSpanElement;
64
+ let tight = $state(false);
65
+ $effect(() => {
66
+ const watcher = new ResizeObserver(([entry]) => (tight = entry!.contentRect.width < PATH_ROOM_PX));
67
+ watcher.observe(box);
68
+ return () => watcher.disconnect();
69
+ });
70
+
71
+ function set(path: string) {
72
+ value = path;
73
+ onChange?.(path);
74
+ }
75
+
76
+ async function ask() {
77
+ const answer = await pick(value);
78
+ // The picker's window gives the focus back to the button as it leaves,
79
+ // which in Svelte happens after the answer arrives, so the field waits for it.
80
+ await tick();
81
+ ref?.focus();
82
+ if (!answer) return;
83
+ set(answer);
84
+ onPicked?.(answer);
85
+ }
86
+ </script>
87
+
88
+ <span data-glim="PathField" bind:this={box} class={["glim-path", fieldWidthClass(width), className].filter(Boolean).join(" ")} {style}>
89
+ <input
90
+ spellcheck={false}
91
+ autocomplete="off"
92
+ aria-label={name()}
93
+ {...rest}
94
+ bind:this={ref}
95
+ type="text"
96
+ {value}
97
+ {disabled}
98
+ oninput={(e) => set(e.currentTarget.value)}
99
+ class="glim-input glim-input--mono"
100
+ />
101
+ <Button
102
+ {...buttonAttrs}
103
+ variant="icon"
104
+ label={text.pick}
105
+ labelKey={null}
106
+ glyph={glyph ?? IconFolderOpen}
107
+ compact={compact || tight}
108
+ disabled={!!disabled}
109
+ onClick={ask}
110
+ />
111
+ </span>
@@ -0,0 +1,33 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLInputAttributes } from "svelte/elements";
3
+ import type { FieldWidth } from "@glimstone/core";
4
+ export interface PathFieldProps extends Omit<HTMLInputAttributes, "value" | "type" | "width" | "class"> {
5
+ /** The path, bound with `bind:value`. */
6
+ value: string;
7
+ /** Called with the path as it is typed and as the picker answers. */
8
+ onChange?: (path: string) => void;
9
+ /** Handed the path in the field. Answers with a path, or with nothing when the person left. */
10
+ pick: (current: string) => string | null | undefined | Promise<string | null | undefined>;
11
+ /** Called with a path the picker answered with, after onChange. */
12
+ onPicked?: (path: string) => void;
13
+ /** The accessible name. Inside a FieldRow the row gives it. */
14
+ label?: string;
15
+ width?: FieldWidth;
16
+ /** The button's words. */
17
+ text?: {
18
+ pick: string;
19
+ };
20
+ /** The button's glyph, an open folder unless set, such as a file for a picker of files. */
21
+ glyph?: Snippet;
22
+ /** Shows the button's glyph alone, as it does by itself with less than 20rem of room. */
23
+ compact?: boolean;
24
+ /** Attributes for the button, such as a data hook. */
25
+ buttonAttrs?: Record<string, string>;
26
+ /** Classes for the wrapper, which carries the width. */
27
+ class?: string;
28
+ /** The <input>, bound with `bind:ref`. */
29
+ ref?: HTMLInputElement | null;
30
+ }
31
+ declare const PathField: import("svelte").Component<PathFieldProps, {}, "value" | "ref">;
32
+ type PathField = ReturnType<typeof PathField>;
33
+ export default PathField;
@@ -0,0 +1,174 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { Attachment } from "svelte/attachments";
4
+ import type { GiveFrequency } from "@glimstone/core";
5
+
6
+ export interface PaypalSelectorProps {
7
+ labelledBy: string;
8
+ options: { value: string; label: string }[];
9
+ /** Null when no segment is picked, as while a typed amount applies. */
10
+ value: string | null;
11
+ onChange: (value: string) => void;
12
+ }
13
+
14
+ export interface PaypalDialogProps {
15
+ text: {
16
+ title: string;
17
+ /** The app's appeal, the same in every giving window. */
18
+ appeal: string;
19
+ /** One sentence: the payment happens at PayPal, by account or by card. */
20
+ intro: string;
21
+ frequencyLabel: string;
22
+ frequencies: Record<GiveFrequency, string>;
23
+ amountLabel: string;
24
+ /** Placeholder and accessible name of the free amount. */
25
+ otherAmount: string;
26
+ loading: string;
27
+ thanks: string;
28
+ failed: string;
29
+ closeLabel: string;
30
+ };
31
+ frequency: GiveFrequency;
32
+ onFrequency?: (frequency: GiveFrequency) => void;
33
+ /** The preset amounts, as whole numbers in the currency. */
34
+ amounts: string[];
35
+ currencySymbol: string;
36
+ /** The picked preset, or null while the free amount is in use. */
37
+ preset: string | null;
38
+ onPreset?: (amount: string) => void;
39
+ typed: string;
40
+ /** Whether `typed` parses as an amount PayPal accepts. */
41
+ typedValid: boolean;
42
+ onTyped?: (text: string) => void;
43
+ /** The app's own horizontal selector. */
44
+ renderSelector: Snippet<[PaypalSelectorProps]>;
45
+ /** From usePaypalButtons. */
46
+ buttonsRef: Attachment<HTMLDivElement>;
47
+ status: "idle" | "done" | "failed";
48
+ onClose: () => void;
49
+ /** The window's own card, bound with `bind:ref`, for the app's Escape handling and focus trap. */
50
+ ref?: HTMLDivElement | null;
51
+ }
52
+ </script>
53
+
54
+ <script lang="ts">
55
+ import Badge from "./Badge.svelte";
56
+ import Button from "./Button.svelte";
57
+
58
+ // The window for PayPal: how often and how much in the house's own controls,
59
+ // then PayPal's two buttons. The PayPal button opens PayPal's login popup; the
60
+ // card button opens a card form inside this window, for somebody without a
61
+ // PayPal account.
62
+ //
63
+ // PayPal draws its buttons itself and allows no more than a colour, a radius
64
+ // and a height, so the window keeps them apart from the house controls above
65
+ // them. Like the other give windows it holds no state of its own: the app
66
+ // binds the selection or follows the callbacks, owns Escape and the portal,
67
+ // and passes its own horizontal selector in.
68
+ let {
69
+ text,
70
+ frequency = $bindable(),
71
+ onFrequency,
72
+ amounts,
73
+ currencySymbol,
74
+ preset = $bindable(),
75
+ onPreset,
76
+ typed = $bindable(),
77
+ typedValid,
78
+ onTyped,
79
+ renderSelector,
80
+ buttonsRef,
81
+ status,
82
+ onClose,
83
+ ref = $bindable(null),
84
+ }: PaypalDialogProps = $props();
85
+
86
+ const frequencies: GiveFrequency[] = ["once", "month", "year"];
87
+ </script>
88
+
89
+ <!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
90
+ <div
91
+ class="glim-modal-backdrop"
92
+ onclick={(e) => {
93
+ if (e.target === e.currentTarget) onClose();
94
+ }}
95
+ >
96
+ <div
97
+ data-glim="PaypalDialog"
98
+ data-glim-title={text.title}
99
+ bind:this={ref}
100
+ tabindex={-1}
101
+ role="dialog"
102
+ aria-modal="true"
103
+ aria-labelledby="paypal-window-title"
104
+ class="glim-modal-card glim-modal-card--wide"
105
+ >
106
+ <div class="glim-modal-head">
107
+ <h2 id="paypal-window-title" class="glim-modal-title">
108
+ <Badge tone="heading" size="heading" wrap>{text.title}</Badge>
109
+ </h2>
110
+ </div>
111
+
112
+ <div class="glim-give-body glim-give-body--scroll">
113
+ <p class="glim-give-appeal">{text.appeal}</p>
114
+ <p class="glim-give-intro">{text.intro}</p>
115
+
116
+ <div class="glim-give-group">
117
+ <span id="paypal-frequency" class="glim-eyebrow">{text.frequencyLabel}</span>
118
+ {@render renderSelector({
119
+ labelledBy: "paypal-frequency",
120
+ options: frequencies.map((f) => ({ value: f, label: text.frequencies[f] })),
121
+ value: frequency,
122
+ onChange: (v) => {
123
+ frequency = v as GiveFrequency;
124
+ onFrequency?.(frequency);
125
+ },
126
+ })}
127
+ </div>
128
+
129
+ <div class="glim-give-group">
130
+ <span id="paypal-amount" class="glim-eyebrow">{text.amountLabel}</span>
131
+ <!-- The presets keep the window's width, and the free amount stands at
132
+ the end of the row under them. A valid entry takes the selection
133
+ away from the presets. -->
134
+ <div class="glim-give-amounts">
135
+ <div>
136
+ {@render renderSelector({
137
+ labelledBy: "paypal-amount",
138
+ options: amounts.map((a) => ({ value: a, label: `${a} ${currencySymbol}` })),
139
+ value: preset,
140
+ onChange: (v) => {
141
+ preset = v;
142
+ onPreset?.(v);
143
+ },
144
+ })}
145
+ </div>
146
+ <input
147
+ type="text"
148
+ inputmode="decimal"
149
+ value={typed}
150
+ placeholder={text.otherAmount}
151
+ aria-label={text.otherAmount}
152
+ aria-invalid={typed !== "" && !typedValid}
153
+ oninput={(e) => {
154
+ typed = e.currentTarget.value;
155
+ onTyped?.(typed);
156
+ }}
157
+ class={`glim-give-amount${typedValid ? " glim-give-amount--valid" : ""}`}
158
+ />
159
+ </div>
160
+ </div>
161
+
162
+ <div {@attach buttonsRef} class="glim-give-wallet">
163
+ <p class="glim-give-loading">{text.loading}</p>
164
+ </div>
165
+
166
+ {#if status === "done"}<p class="glim-give-status glim-give-status--ok">{text.thanks}</p>{/if}
167
+ {#if status === "failed"}<p class="glim-give-status glim-give-status--fail">{text.failed}</p>{/if}
168
+ </div>
169
+
170
+ <div class="glim-give-foot">
171
+ <Button label={text.closeLabel} labelKey="common.close" tone="neutral" onClick={onClose} />
172
+ </div>
173
+ </div>
174
+ </div>
@@ -0,0 +1,54 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { Attachment } from "svelte/attachments";
3
+ import type { GiveFrequency } from "@glimstone/core";
4
+ export interface PaypalSelectorProps {
5
+ labelledBy: string;
6
+ options: {
7
+ value: string;
8
+ label: string;
9
+ }[];
10
+ /** Null when no segment is picked, as while a typed amount applies. */
11
+ value: string | null;
12
+ onChange: (value: string) => void;
13
+ }
14
+ export interface PaypalDialogProps {
15
+ text: {
16
+ title: string;
17
+ /** The app's appeal, the same in every giving window. */
18
+ appeal: string;
19
+ /** One sentence: the payment happens at PayPal, by account or by card. */
20
+ intro: string;
21
+ frequencyLabel: string;
22
+ frequencies: Record<GiveFrequency, string>;
23
+ amountLabel: string;
24
+ /** Placeholder and accessible name of the free amount. */
25
+ otherAmount: string;
26
+ loading: string;
27
+ thanks: string;
28
+ failed: string;
29
+ closeLabel: string;
30
+ };
31
+ frequency: GiveFrequency;
32
+ onFrequency?: (frequency: GiveFrequency) => void;
33
+ /** The preset amounts, as whole numbers in the currency. */
34
+ amounts: string[];
35
+ currencySymbol: string;
36
+ /** The picked preset, or null while the free amount is in use. */
37
+ preset: string | null;
38
+ onPreset?: (amount: string) => void;
39
+ typed: string;
40
+ /** Whether `typed` parses as an amount PayPal accepts. */
41
+ typedValid: boolean;
42
+ onTyped?: (text: string) => void;
43
+ /** The app's own horizontal selector. */
44
+ renderSelector: Snippet<[PaypalSelectorProps]>;
45
+ /** From usePaypalButtons. */
46
+ buttonsRef: Attachment<HTMLDivElement>;
47
+ status: "idle" | "done" | "failed";
48
+ onClose: () => void;
49
+ /** The window's own card, bound with `bind:ref`, for the app's Escape handling and focus trap. */
50
+ ref?: HTMLDivElement | null;
51
+ }
52
+ declare const PaypalDialog: import("svelte").Component<PaypalDialogProps, {}, "ref" | "frequency" | "preset" | "typed">;
53
+ type PaypalDialog = ReturnType<typeof PaypalDialog>;
54
+ export default PaypalDialog;
@@ -0,0 +1,25 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from "svelte";
3
+ import type { PillTone } from "@glimstone/core";
4
+
5
+ export type { PillTone } from "@glimstone/core";
6
+
7
+ export interface PillProps {
8
+ children: Snippet;
9
+ /** `state` lifts a word that says what the row is doing; the other three
10
+ * wash the pill in their state colour. */
11
+ tone?: PillTone;
12
+ /** Extra classes, such as `glim-num` for figures that line up in a column. */
13
+ class?: string;
14
+ }
15
+ </script>
16
+
17
+ <script lang="ts">
18
+ import { pillClassName } from "@glimstone/core";
19
+
20
+ // One value of a list row, such as a size, a date or a state; pillClassName()
21
+ // in the core says why it is not a Badge.
22
+ let { children, tone = "neutral", class: className }: PillProps = $props();
23
+ </script>
24
+
25
+ <span data-glim="Pill" class={className ? `${pillClassName(tone)} ${className}` : pillClassName(tone)}>{@render children()}</span>