@xerios/design-system 0.0.0-stage → 0.1.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 (214) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +403 -2
  3. package/dist/components/AnchorHeading.svelte +79 -0
  4. package/dist/components/AnchorHeading.svelte.d.ts +28 -0
  5. package/dist/components/Breadcrumbs.svelte +216 -0
  6. package/dist/components/Breadcrumbs.svelte.d.ts +37 -0
  7. package/dist/components/Button.svelte +178 -0
  8. package/dist/components/Button.svelte.d.ts +58 -0
  9. package/dist/components/Canvas.svelte +248 -0
  10. package/dist/components/Canvas.svelte.d.ts +91 -0
  11. package/dist/components/Collapsible.svelte +139 -0
  12. package/dist/components/Collapsible.svelte.d.ts +52 -0
  13. package/dist/components/CollapsibleAdvanced.svelte +174 -0
  14. package/dist/components/CollapsibleAdvanced.svelte.d.ts +43 -0
  15. package/dist/components/DashOutline.svelte +47 -0
  16. package/dist/components/DashOutline.svelte.d.ts +6 -0
  17. package/dist/components/Dialogs.svelte +123 -0
  18. package/dist/components/Dialogs.svelte.d.ts +6 -0
  19. package/dist/components/Drawer.svelte +231 -0
  20. package/dist/components/Drawer.svelte.d.ts +62 -0
  21. package/dist/components/ErrorMessage.svelte +140 -0
  22. package/dist/components/ErrorMessage.svelte.d.ts +41 -0
  23. package/dist/components/Icon.svelte +94 -0
  24. package/dist/components/Icon.svelte.d.ts +33 -0
  25. package/dist/components/InfoTip.svelte +183 -0
  26. package/dist/components/InfoTip.svelte.d.ts +28 -0
  27. package/dist/components/Md.svelte +28 -0
  28. package/dist/components/Md.svelte.d.ts +11 -0
  29. package/dist/components/Modal.svelte +91 -0
  30. package/dist/components/Modal.svelte.d.ts +41 -0
  31. package/dist/components/Notice.svelte +50 -0
  32. package/dist/components/Notice.svelte.d.ts +30 -0
  33. package/dist/components/Popover.svelte +212 -0
  34. package/dist/components/Popover.svelte.d.ts +70 -0
  35. package/dist/components/Shimmer.svelte +27 -0
  36. package/dist/components/Shimmer.svelte.d.ts +22 -0
  37. package/dist/components/Splitter.svelte +152 -0
  38. package/dist/components/Splitter.svelte.d.ts +41 -0
  39. package/dist/components/Table.svelte +448 -0
  40. package/dist/components/Table.svelte.d.ts +268 -0
  41. package/dist/components/Toast.svelte +273 -0
  42. package/dist/components/Toast.svelte.d.ts +31 -0
  43. package/dist/components/Tooltip.svelte +97 -0
  44. package/dist/components/Tooltip.svelte.d.ts +19 -0
  45. package/dist/components/WorkingBorder.svelte +105 -0
  46. package/dist/components/WorkingBorder.svelte.d.ts +26 -0
  47. package/dist/components/empty/Empty.svelte +55 -0
  48. package/dist/components/empty/Empty.svelte.d.ts +39 -0
  49. package/dist/components/empty/EmptyError.svelte +47 -0
  50. package/dist/components/empty/EmptyError.svelte.d.ts +28 -0
  51. package/dist/components/empty/index.d.ts +18 -0
  52. package/dist/components/empty/index.js +10 -0
  53. package/dist/components/filters/DateFilter.svelte +59 -0
  54. package/dist/components/filters/DateFilter.svelte.d.ts +23 -0
  55. package/dist/components/filters/FilterBar.svelte +342 -0
  56. package/dist/components/filters/FilterBar.svelte.d.ts +283 -0
  57. package/dist/components/filters/FilterChip.svelte +235 -0
  58. package/dist/components/filters/FilterChip.svelte.d.ts +68 -0
  59. package/dist/components/filters/OptionList.svelte +352 -0
  60. package/dist/components/filters/OptionList.svelte.d.ts +91 -0
  61. package/dist/components/filters/Panel.svelte +123 -0
  62. package/dist/components/filters/Panel.svelte.d.ts +25 -0
  63. package/dist/components/filters/index.d.ts +288 -0
  64. package/dist/components/filters/index.js +12 -0
  65. package/dist/components/icons.d.ts +54 -0
  66. package/dist/components/icons.js +58 -0
  67. package/dist/components/inputs/ButtonGroup.svelte +104 -0
  68. package/dist/components/inputs/ButtonGroup.svelte.d.ts +40 -0
  69. package/dist/components/inputs/Calendar.svelte +535 -0
  70. package/dist/components/inputs/Calendar.svelte.d.ts +45 -0
  71. package/dist/components/inputs/DateField.svelte +247 -0
  72. package/dist/components/inputs/DateField.svelte.d.ts +74 -0
  73. package/dist/components/inputs/DateInput.svelte +118 -0
  74. package/dist/components/inputs/DateInput.svelte.d.ts +43 -0
  75. package/dist/components/inputs/DatePicker.svelte +102 -0
  76. package/dist/components/inputs/DatePicker.svelte.d.ts +67 -0
  77. package/dist/components/inputs/DateRangePicker.svelte +208 -0
  78. package/dist/components/inputs/DateRangePicker.svelte.d.ts +76 -0
  79. package/dist/components/inputs/DateRangeSelect.svelte +548 -0
  80. package/dist/components/inputs/DateRangeSelect.svelte.d.ts +70 -0
  81. package/dist/components/inputs/FieldLabel.svelte +43 -0
  82. package/dist/components/inputs/FieldLabel.svelte.d.ts +28 -0
  83. package/dist/components/inputs/ListSearch.svelte +142 -0
  84. package/dist/components/inputs/ListSearch.svelte.d.ts +35 -0
  85. package/dist/components/inputs/RadioGroup.svelte +153 -0
  86. package/dist/components/inputs/RadioGroup.svelte.d.ts +49 -0
  87. package/dist/components/inputs/RangeShortcuts.svelte +90 -0
  88. package/dist/components/inputs/RangeShortcuts.svelte.d.ts +31 -0
  89. package/dist/components/inputs/RangeSlider.svelte +225 -0
  90. package/dist/components/inputs/RangeSlider.svelte.d.ts +37 -0
  91. package/dist/components/inputs/SearchField.svelte +24 -0
  92. package/dist/components/inputs/SearchField.svelte.d.ts +41 -0
  93. package/dist/components/inputs/Segmented.svelte +76 -0
  94. package/dist/components/inputs/Segmented.svelte.d.ts +43 -0
  95. package/dist/components/inputs/Select.svelte +552 -0
  96. package/dist/components/inputs/Select.svelte.d.ts +100 -0
  97. package/dist/components/inputs/Slider.svelte +177 -0
  98. package/dist/components/inputs/Slider.svelte.d.ts +33 -0
  99. package/dist/components/inputs/SliderTicks.svelte +62 -0
  100. package/dist/components/inputs/SliderTicks.svelte.d.ts +23 -0
  101. package/dist/components/inputs/Switch.svelte +120 -0
  102. package/dist/components/inputs/Switch.svelte.d.ts +31 -0
  103. package/dist/components/inputs/TagInput.svelte +296 -0
  104. package/dist/components/inputs/TagInput.svelte.d.ts +61 -0
  105. package/dist/components/inputs/TextArea.svelte +86 -0
  106. package/dist/components/inputs/TextArea.svelte.d.ts +56 -0
  107. package/dist/components/inputs/TextField.svelte +170 -0
  108. package/dist/components/inputs/TextField.svelte.d.ts +80 -0
  109. package/dist/components/menu/ContextMenu.svelte +25 -0
  110. package/dist/components/menu/ContextMenu.svelte.d.ts +26 -0
  111. package/dist/components/menu/MenuButton.svelte +46 -0
  112. package/dist/components/menu/MenuButton.svelte.d.ts +16 -0
  113. package/dist/components/menu/MenuList.svelte +319 -0
  114. package/dist/components/menu/MenuList.svelte.d.ts +30 -0
  115. package/dist/components/metadata/Metadata.svelte +38 -0
  116. package/dist/components/metadata/Metadata.svelte.d.ts +31 -0
  117. package/dist/components/metadata/MetadataRow.svelte +84 -0
  118. package/dist/components/metadata/MetadataRow.svelte.d.ts +26 -0
  119. package/dist/components/metadata/index.d.ts +8 -0
  120. package/dist/components/metadata/index.js +13 -0
  121. package/dist/components/side-menu/SideMenu.svelte +138 -0
  122. package/dist/components/side-menu/SideMenu.svelte.d.ts +25 -0
  123. package/dist/components/side-menu/SideMenuGroup.svelte +108 -0
  124. package/dist/components/side-menu/SideMenuGroup.svelte.d.ts +31 -0
  125. package/dist/components/side-menu/SideMenuItem.svelte +221 -0
  126. package/dist/components/side-menu/SideMenuItem.svelte.d.ts +46 -0
  127. package/dist/components/side-menu/context.d.ts +1 -0
  128. package/dist/components/side-menu/context.js +3 -0
  129. package/dist/components/side-menu/index.d.ts +62 -0
  130. package/dist/components/side-menu/index.js +15 -0
  131. package/dist/components/tiles/Tile.svelte +419 -0
  132. package/dist/components/tiles/Tile.svelte.d.ts +58 -0
  133. package/dist/components/tiles/TileGroup.svelte +135 -0
  134. package/dist/components/tiles/TileGroup.svelte.d.ts +45 -0
  135. package/dist/components/tiles/context.d.ts +35 -0
  136. package/dist/components/tiles/context.js +14 -0
  137. package/dist/components/tiles/index.d.ts +6 -0
  138. package/dist/components/tiles/index.js +13 -0
  139. package/dist/components/upload/FileCard.svelte +301 -0
  140. package/dist/components/upload/FileCard.svelte.d.ts +127 -0
  141. package/dist/components/upload/Thumb.svelte +274 -0
  142. package/dist/components/upload/Thumb.svelte.d.ts +101 -0
  143. package/dist/components/upload/UploadFile.svelte +123 -0
  144. package/dist/components/upload/UploadFile.svelte.d.ts +48 -0
  145. package/dist/components/upload/UploadFiles.svelte +177 -0
  146. package/dist/components/upload/UploadFiles.svelte.d.ts +50 -0
  147. package/dist/components/upload/UploadFolder.svelte +153 -0
  148. package/dist/components/upload/UploadFolder.svelte.d.ts +63 -0
  149. package/dist/components/upload/UploadImage.svelte +137 -0
  150. package/dist/components/upload/UploadImage.svelte.d.ts +52 -0
  151. package/dist/components/upload/UploadImages.svelte +172 -0
  152. package/dist/components/upload/UploadImages.svelte.d.ts +52 -0
  153. package/dist/components/upload/UploadZone.svelte +130 -0
  154. package/dist/components/upload/UploadZone.svelte.d.ts +41 -0
  155. package/dist/components/upload/common.d.ts +31 -0
  156. package/dist/components/upload/common.js +103 -0
  157. package/dist/components/upload/context.d.ts +18 -0
  158. package/dist/components/upload/context.js +10 -0
  159. package/dist/components/upload/index.d.ts +16 -0
  160. package/dist/components/upload/index.js +18 -0
  161. package/dist/css/atoms.css +892 -0
  162. package/dist/css/base.css +333 -0
  163. package/dist/css/effects.css +430 -0
  164. package/dist/css/index.css +10 -0
  165. package/dist/css/tokens.css +296 -0
  166. package/dist/fonts.d.ts +1 -0
  167. package/dist/fonts.js +7 -0
  168. package/dist/index.d.ts +68 -0
  169. package/dist/index.js +77 -0
  170. package/dist/lib/announce.d.ts +8 -0
  171. package/dist/lib/announce.js +48 -0
  172. package/dist/lib/controls.d.ts +10 -0
  173. package/dist/lib/controls.js +42 -0
  174. package/dist/lib/dates.d.ts +104 -0
  175. package/dist/lib/dates.js +235 -0
  176. package/dist/lib/dialogs.svelte.d.ts +8 -0
  177. package/dist/lib/dialogs.svelte.js +45 -0
  178. package/dist/lib/dom.d.ts +34 -0
  179. package/dist/lib/dom.js +90 -0
  180. package/dist/lib/field-errors.svelte.d.ts +40 -0
  181. package/dist/lib/field-errors.svelte.js +89 -0
  182. package/dist/lib/files.d.ts +74 -0
  183. package/dist/lib/files.js +215 -0
  184. package/dist/lib/inline-md.d.ts +1 -0
  185. package/dist/lib/inline-md.js +36 -0
  186. package/dist/lib/invalid.d.ts +4 -0
  187. package/dist/lib/invalid.js +35 -0
  188. package/dist/lib/list-search.d.ts +9 -0
  189. package/dist/lib/list-search.js +27 -0
  190. package/dist/lib/menu.svelte.d.ts +39 -0
  191. package/dist/lib/menu.svelte.js +98 -0
  192. package/dist/lib/morph.svelte.d.ts +17 -0
  193. package/dist/lib/morph.svelte.js +46 -0
  194. package/dist/lib/motion.d.ts +115 -0
  195. package/dist/lib/motion.js +174 -0
  196. package/dist/lib/observe.d.ts +36 -0
  197. package/dist/lib/observe.js +142 -0
  198. package/dist/lib/reveal.d.ts +7 -0
  199. package/dist/lib/reveal.js +28 -0
  200. package/dist/lib/roving.d.ts +16 -0
  201. package/dist/lib/roving.js +35 -0
  202. package/dist/lib/runs.d.ts +18 -0
  203. package/dist/lib/runs.js +25 -0
  204. package/dist/lib/scroll-fade.d.ts +4 -0
  205. package/dist/lib/scroll-fade.js +71 -0
  206. package/dist/lib/spotlight.d.ts +4 -0
  207. package/dist/lib/spotlight.js +109 -0
  208. package/dist/lib/ticks.d.ts +12 -0
  209. package/dist/lib/ticks.js +24 -0
  210. package/dist/lib/tooltip.d.ts +4 -0
  211. package/dist/lib/tooltip.js +110 -0
  212. package/dist/lib/validity.d.ts +16 -0
  213. package/dist/lib/validity.js +36 -0
  214. package/package.json +69 -3
@@ -0,0 +1,142 @@
1
+ <script>
2
+ /**
3
+ * The search field at the top of a floating list (Select's, OptionList's): flat on the list's surface, with a hairline
4
+ * under it from edge to edge. A combobox that keeps the focus while the arrow keys move through the list it controls,
5
+ * so the list's own key handler goes in `onkeydown`. lib/list-search.js decides when a list gets one and what matches.
6
+ *
7
+ * <ListSearch bind:this={field} value={query} oninput={(q) => (query = q)} label="Region" controls="{id}-list"
8
+ * active="{id}-opt-{active}" onkeydown={onListKey} />
9
+ *
10
+ * value: the text. oninput(text): as it is typed or cleared. label: the accessible name (the list's).
11
+ * controls: the listbox's id. active: the id of the option the keyboard is on (aria-activedescendant), if any.
12
+ * placeholder: default "Filter…". onkeydown: the list's keys (arrows, Enter…); keys that edit text are the field's.
13
+ * focus(): puts the focus in it.
14
+ * With text in it, a ✕ at its end clears it (as a search TextField's does) and keeps the focus in the field; it is
15
+ * left out of the tab order, since Tab belongs to the list around it, and Esc does the same from the keyboard.
16
+ * Keyboard: Esc with text clears it (and goes no further); with none, Esc is left to the list around it.
17
+ * Other attributes and attachments go to the <input>.
18
+ */
19
+ import Icon from '../Icon.svelte'
20
+ import { composing } from '../../lib/dom.js'
21
+ import { tooltip } from '../../lib/tooltip.js'
22
+
23
+ /**
24
+ * @typedef {object} Props
25
+ * @property {string} value
26
+ * @property {(text: string) => void} oninput
27
+ * @property {string} label
28
+ * @property {string} controls
29
+ * @property {string} [active]
30
+ * @property {string} [placeholder]
31
+ * @property {(e: KeyboardEvent) => void} [onkeydown]
32
+ */
33
+ /** @type {Props & Omit<import('svelte/elements').HTMLInputAttributes, keyof Props>} */
34
+ let { value, oninput, label, controls, active, placeholder = 'Filter…', onkeydown, class: className, ...rest } = $props()
35
+ /** @type {HTMLInputElement | undefined} */
36
+ let input = $state()
37
+
38
+ export function focus() {
39
+ input?.focus({ preventScroll: true })
40
+ }
41
+
42
+ /** @param {KeyboardEvent} e */
43
+ function keydown(e) {
44
+ if (composing(e)) return
45
+ if (e.key === 'Escape' && value) {
46
+ e.preventDefault()
47
+ e.stopPropagation()
48
+ oninput('')
49
+ return
50
+ }
51
+ onkeydown?.(e)
52
+ }
53
+ </script>
54
+
55
+ <div class="list-search">
56
+ <input
57
+ bind:this={input}
58
+ class={['list-search-input', className]}
59
+ type="text"
60
+ role="combobox"
61
+ aria-label={label}
62
+ aria-expanded="true"
63
+ aria-controls={controls}
64
+ aria-autocomplete="list"
65
+ aria-activedescendant={active}
66
+ autocomplete="off"
67
+ spellcheck="false"
68
+ {placeholder}
69
+ {...rest}
70
+ {value}
71
+ oninput={(e) => oninput(e.currentTarget.value)}
72
+ onkeydown={keydown}
73
+ />
74
+ <!-- Pointer only: mousedown would take the focus out of the field. Esc clears from the keyboard. Kept in place while
75
+ there is nothing to clear (hidden), so a list sized to its content doesn't widen as the first letter is typed. -->
76
+ <button
77
+ type="button"
78
+ class="clear"
79
+ class:hidden={!value}
80
+ disabled={!value}
81
+ tabindex="-1"
82
+ aria-label="Clear {label} filter"
83
+ {@attach tooltip('Clear')}
84
+ onmousedown={(e) => e.preventDefault()}
85
+ onclick={() => {
86
+ oninput('')
87
+ input?.focus({ preventScroll: true })
88
+ }}><Icon name="x" size="sm" /></button
89
+ >
90
+ </div>
91
+
92
+ <style>
93
+ /* Flat on the list's surface, with a hairline under it from edge to edge. */
94
+ .list-search {
95
+ flex: none;
96
+ display: flex;
97
+ align-items: center;
98
+ gap: var(--space-1);
99
+ min-height: 36px;
100
+ padding: 0 6px 0 var(--space-3);
101
+ border-bottom: 1px solid var(--line);
102
+ }
103
+ .list-search-input {
104
+ flex: 1;
105
+ min-width: 0;
106
+ align-self: stretch;
107
+ padding: 0;
108
+ border: 0;
109
+ border-radius: 0;
110
+ background: none;
111
+ color: var(--fg);
112
+ font: inherit;
113
+ font-size: 13px;
114
+ user-select: text;
115
+ }
116
+ .list-search-input::placeholder {
117
+ color: var(--muted);
118
+ }
119
+ .list-search-input:focus {
120
+ outline: none;
121
+ }
122
+ .clear {
123
+ display: inline-grid;
124
+ place-items: center;
125
+ flex: none;
126
+ width: 24px;
127
+ height: 24px;
128
+ padding: 0;
129
+ border: 0;
130
+ border-radius: 50%;
131
+ background: none;
132
+ color: var(--muted);
133
+ cursor: pointer;
134
+ }
135
+ .clear.hidden {
136
+ visibility: hidden;
137
+ }
138
+ .clear:hover {
139
+ color: var(--fg);
140
+ background: var(--control-3);
141
+ }
142
+ </style>
@@ -0,0 +1,35 @@
1
+ export default ListSearch;
2
+ type ListSearch = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props & Omit<HTMLInputAttributes, keyof Props>>): void;
5
+ } & {
6
+ focus: () => void;
7
+ };
8
+ declare const ListSearch: import("svelte").Component<{
9
+ value: string;
10
+ oninput: (text: string) => void;
11
+ label: string;
12
+ controls: string;
13
+ active?: string | undefined;
14
+ placeholder?: string | undefined;
15
+ onkeydown?: ((e: KeyboardEvent) => void) | undefined;
16
+ } & Omit<import("svelte/elements").HTMLInputAttributes, keyof {
17
+ value: string;
18
+ oninput: (text: string) => void;
19
+ label: string;
20
+ controls: string;
21
+ active?: string | undefined;
22
+ placeholder?: string | undefined;
23
+ onkeydown?: ((e: KeyboardEvent) => void) | undefined;
24
+ }>, {
25
+ focus: () => void;
26
+ }, "">;
27
+ type Props = {
28
+ value: string;
29
+ oninput: (text: string) => void;
30
+ label: string;
31
+ controls: string;
32
+ active?: string | undefined;
33
+ placeholder?: string | undefined;
34
+ onkeydown?: ((e: KeyboardEvent) => void) | undefined;
35
+ };
@@ -0,0 +1,153 @@
1
+ <script>
2
+ import Icon from '../Icon.svelte'
3
+ import { tooltip } from '../../lib/tooltip.js'
4
+ import { radioKeys } from '../../lib/roving.js'
5
+ import Tooltip from '../Tooltip.svelte'
6
+ import { motion, durations, easings } from '../../lib/motion.js'
7
+ /**
8
+ * Single choice shown as a joined switch: one track, the chosen segment raised on it (radio group with roving
9
+ * focus). Same options shape as Segmented ({ value, label, icon?, hint?, info? }; `info` adds an ⓘ with that text as a hover tooltip). `fill` stretches it to its container
10
+ * with equal-width segments. `pill` rounds the track and segments fully (toolbar view switchers).
11
+ * When the choice changes, the raised thumb slides from the old segment to the new one (instantly under reduced motion).
12
+ */
13
+ /**
14
+ * @typedef {{ value: any, label: string, icon?: string, hint?: string, info?: string }} Option
15
+ * @typedef {object} Props
16
+ * @property {any} value
17
+ * @property {Option[]} options
18
+ * @property {string} label
19
+ * @property {(value: any) => void} onchange
20
+ * @property {boolean} [iconOnly]
21
+ * @property {boolean} [fill]
22
+ * @property {boolean} [pill]
23
+ */
24
+ /** @type {Props & Omit<import('svelte/elements').HTMLAttributes<HTMLDivElement>, keyof Props>} */
25
+ let { value, options, label, onchange, fill = false, iconOnly = false, pill = false, class: className, ...rest } = $props()
26
+ const uid = $props.id()
27
+ let group
28
+
29
+ // Where the thumb sat before this change: read before the DOM updates, so the new thumb can slide in from there.
30
+ let from = null
31
+ $effect.pre(() => {
32
+ void value
33
+ from = group?.querySelector('.thumb')?.getBoundingClientRect() ?? null
34
+ })
35
+
36
+ /** Intro for the new thumb: starts on the old thumb's box and eases its edges onto its own (no scaling, so radii hold). */
37
+ function slide(node) {
38
+ const to = node.getBoundingClientRect()
39
+ if (!from || !to.width) return { duration: 0 }
40
+ const l = from.left - to.left,
41
+ t = from.top - to.top,
42
+ r = to.right - from.right,
43
+ b = to.bottom - from.bottom
44
+ return { duration: motion(durations.short4), easing: easings.standard.standard, css: (_, u) => `inset: ${u * t}px ${u * r}px ${u * b}px ${u * l}px;` }
45
+ }
46
+ </script>
47
+
48
+ <div bind:this={group} class={['group', className]} class:fill class:pill role="radiogroup" aria-label={label} {...rest} {@attach radioKeys}>
49
+ {#each options as o, i (o.value)}
50
+ <button
51
+ type="button"
52
+ role="radio"
53
+ aria-checked={o.value === value}
54
+ tabindex={o.value === value ? 0 : -1}
55
+ onclick={() => onchange(o.value)}
56
+ {@attach tooltip(iconOnly ? o.label + (o.hint ? ` (${o.hint})` : '') : o.hint)}
57
+ aria-label={iconOnly ? o.label : undefined}
58
+ aria-describedby={o.info ? `${uid}-info-${i}` : undefined}
59
+ >{#if o.value === value}<span class="thumb" aria-hidden="true" in:slide></span>{/if}{#if o.icon}<Icon name={o.icon} size="sm" />{/if}{#if !iconOnly}<span
60
+ class="text">{o.label}</span
61
+ >{/if}{#if o.info}<Tooltip focusable={false}>{#snippet tip()}{o.info}{/snippet}<span class="info"><Icon name="infoCircle" size="sm" /></span></Tooltip
62
+ >{/if}</button
63
+ >
64
+ {/each}
65
+ <!-- The ⓘ's text, as each option's description: the tooltip only opens on hover. -->
66
+ {#each options as o, i (o.value)}
67
+ {#if o.info}<span id="{uid}-info-{i}" class="sr-only">{o.info}</span>{/if}
68
+ {/each}
69
+ </div>
70
+
71
+ <style>
72
+ .group {
73
+ display: inline-grid;
74
+ grid-auto-flow: column;
75
+ grid-auto-columns: auto;
76
+ gap: 2px;
77
+ /* As wide as its options: a grid or column-flex parent would otherwise stretch the track past them (`fill` stretches it on purpose). */
78
+ width: fit-content;
79
+ max-width: 100%;
80
+ padding: 2px;
81
+ /* Sunken like a field (--sunken-*), so the raised thumb reads as sitting in a track. */
82
+ border-radius: var(--r);
83
+ background: var(--control-2);
84
+ box-shadow:
85
+ inset 0 0 0 1px var(--line),
86
+ var(--shadow-sm);
87
+ /* The thumb sits at z-index -1 in here: under every segment's content, even while it slides across them. */
88
+ isolation: isolate;
89
+ }
90
+ .group.fill {
91
+ display: grid;
92
+ grid-auto-columns: minmax(0, 1fr);
93
+ width: 100%;
94
+ }
95
+ .group.pill,
96
+ .pill button {
97
+ border-radius: var(--r-pill);
98
+ }
99
+ button {
100
+ position: relative;
101
+ display: inline-flex;
102
+ align-items: center;
103
+ justify-content: center;
104
+ gap: 6px;
105
+ min-width: 0;
106
+ min-height: 26px;
107
+ padding: 0 10px;
108
+ border: 0;
109
+ border-radius: calc(var(--r) - 2px);
110
+ background: none;
111
+ color: var(--fg);
112
+ font-size: 12px;
113
+ line-height: 14px;
114
+ font-weight: var(--w-medium);
115
+ cursor: pointer;
116
+ white-space: nowrap;
117
+ transition:
118
+ color var(--dur) var(--ease-out),
119
+ background-color var(--dur) var(--ease-out),
120
+ box-shadow var(--dur) var(--ease-out);
121
+ }
122
+ button:not([aria-checked='true']):hover {
123
+ background: var(--control-3);
124
+ }
125
+ [aria-checked='true'] {
126
+ color: var(--fg);
127
+ }
128
+ /* The raised surface behind the chosen segment; its own element so it can slide between segments. */
129
+ .thumb {
130
+ position: absolute;
131
+ inset: 0;
132
+ z-index: -1;
133
+ border-radius: inherit;
134
+ pointer-events: none;
135
+ /* Raised (--shadow-btn) out of the sunken track, with a hairline so light's white thumb has an edge. */
136
+ background: var(--elevated);
137
+ box-shadow:
138
+ inset 0 0 0 1px var(--line),
139
+ var(--shadow-btn);
140
+ }
141
+ button :global(.icon) {
142
+ flex: none;
143
+ }
144
+ .info {
145
+ display: inline-flex;
146
+ color: var(--muted);
147
+ }
148
+ .text {
149
+ min-width: 0;
150
+ overflow: clip;
151
+ text-overflow: ellipsis;
152
+ }
153
+ </style>
@@ -0,0 +1,49 @@
1
+ export default RadioGroup;
2
+ type RadioGroup = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props & Omit<HTMLAttributes<HTMLDivElement>, keyof Props>>): void;
5
+ };
6
+ declare const RadioGroup: import("svelte").Component<{
7
+ value: any;
8
+ options: {
9
+ value: any;
10
+ label: string;
11
+ icon?: string;
12
+ hint?: string;
13
+ info?: string;
14
+ }[];
15
+ label: string;
16
+ onchange: (value: any) => void;
17
+ iconOnly?: boolean | undefined;
18
+ fill?: boolean | undefined;
19
+ pill?: boolean | undefined;
20
+ } & Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, keyof {
21
+ value: any;
22
+ options: {
23
+ value: any;
24
+ label: string;
25
+ icon?: string;
26
+ hint?: string;
27
+ info?: string;
28
+ }[];
29
+ label: string;
30
+ onchange: (value: any) => void;
31
+ iconOnly?: boolean | undefined;
32
+ fill?: boolean | undefined;
33
+ pill?: boolean | undefined;
34
+ }>, {}, "">;
35
+ type Props = {
36
+ value: any;
37
+ options: {
38
+ value: any;
39
+ label: string;
40
+ icon?: string;
41
+ hint?: string;
42
+ info?: string;
43
+ }[];
44
+ label: string;
45
+ onchange: (value: any) => void;
46
+ iconOnly?: boolean | undefined;
47
+ fill?: boolean | undefined;
48
+ pill?: boolean | undefined;
49
+ };
@@ -0,0 +1,90 @@
1
+ <script>
2
+ /**
3
+ * The ready-made spans of the range pickers, as quiet buttons (part of DateRangePicker and DateRangeSelect; use those).
4
+ *
5
+ * <RangeShortcuts items={[{ label: 'Last 7 days', range: [from, to] }]} {value} onpick={(range) => (value = range)} />
6
+ *
7
+ * items: [{ label, range }], range [from, to], or null to show it disabled (the span isn't available).
8
+ * value: the current [from, to]; the shortcut giving it is marked current. onpick(range).
9
+ * vertical: a column (a wrapping row from 480px down); otherwise a wrapping row.
10
+ * Keyboard: each is a button in the tab order. Other attributes go to the group.
11
+ */
12
+
13
+ /**
14
+ * @typedef {object} Props
15
+ * @property {{ label: string, range: [string, string] | null }[]} items
16
+ * @property {[string, string]} value
17
+ * @property {(range: [string, string]) => void} onpick
18
+ * @property {boolean} [vertical]
19
+ */
20
+ /** @type {Props & Omit<import('svelte/elements').HTMLAttributes<HTMLDivElement>, keyof Props>} */
21
+ let { items, value, onpick, vertical = false, class: className, ...rest } = $props()
22
+ </script>
23
+
24
+ <div class={['shortcuts', className]} class:vertical role="group" aria-label="Shortcuts" {...rest}>
25
+ {#each items as item (item.label)}
26
+ {@const range = item.range}
27
+ <button
28
+ type="button"
29
+ class="shortcut"
30
+ disabled={!range}
31
+ aria-current={range && range[0] === value[0] && range[1] === value[1] ? 'true' : undefined}
32
+ onclick={() => range && onpick(range)}>{item.label}</button
33
+ >
34
+ {/each}
35
+ </div>
36
+
37
+ <style>
38
+ .shortcuts {
39
+ display: flex;
40
+ flex-wrap: wrap;
41
+ gap: 2px;
42
+ }
43
+ .vertical {
44
+ flex-direction: column;
45
+ flex-wrap: nowrap;
46
+ }
47
+ .shortcut {
48
+ min-height: 24px;
49
+ padding: 0 var(--space-2);
50
+ border: 0;
51
+ border-radius: var(--r);
52
+ background: none;
53
+ color: var(--fg);
54
+ font: var(--w-medium) 12px var(--font-body);
55
+ text-align: start;
56
+ white-space: nowrap;
57
+ transition: background-color var(--dur-fast) var(--ease-out);
58
+ }
59
+ .shortcut:hover:not(:disabled) {
60
+ background: var(--control-3);
61
+ }
62
+ .shortcut[aria-current='true'] {
63
+ background: var(--accent-soft);
64
+ }
65
+ .shortcut:disabled {
66
+ color: var(--faint);
67
+ cursor: default;
68
+ }
69
+ .shortcut:focus-visible {
70
+ outline: 2px solid var(--accent);
71
+ outline-offset: -2px;
72
+ }
73
+ @media (pointer: coarse) {
74
+ .shortcut {
75
+ min-height: 44px;
76
+ }
77
+ }
78
+ @media (max-width: 480px) {
79
+ .vertical {
80
+ flex-direction: row;
81
+ flex-wrap: wrap;
82
+ }
83
+ }
84
+ @media (forced-colors: active) {
85
+ .shortcut[aria-current='true'] {
86
+ outline: 1px solid Highlight;
87
+ outline-offset: -1px;
88
+ }
89
+ }
90
+ </style>
@@ -0,0 +1,31 @@
1
+ export default RangeShortcuts;
2
+ type RangeShortcuts = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props & Omit<HTMLAttributes<HTMLDivElement>, keyof Props>>): void;
5
+ };
6
+ declare const RangeShortcuts: import("svelte").Component<{
7
+ items: {
8
+ label: string;
9
+ range: [string, string] | null;
10
+ }[];
11
+ value: [string, string];
12
+ onpick: (range: [string, string]) => void;
13
+ vertical?: boolean | undefined;
14
+ } & Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, keyof {
15
+ items: {
16
+ label: string;
17
+ range: [string, string] | null;
18
+ }[];
19
+ value: [string, string];
20
+ onpick: (range: [string, string]) => void;
21
+ vertical?: boolean | undefined;
22
+ }>, {}, "">;
23
+ type Props = {
24
+ items: {
25
+ label: string;
26
+ range: [string, string] | null;
27
+ }[];
28
+ value: [string, string];
29
+ onpick: (range: [string, string]) => void;
30
+ vertical?: boolean | undefined;
31
+ };