@xerios/design-system 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +403 -2
- package/dist/components/AnchorHeading.svelte +79 -0
- package/dist/components/AnchorHeading.svelte.d.ts +28 -0
- package/dist/components/Breadcrumbs.svelte +216 -0
- package/dist/components/Breadcrumbs.svelte.d.ts +37 -0
- package/dist/components/Button.svelte +185 -0
- package/dist/components/Button.svelte.d.ts +70 -0
- package/dist/components/Canvas.svelte +248 -0
- package/dist/components/Canvas.svelte.d.ts +91 -0
- package/dist/components/Collapsible.svelte +139 -0
- package/dist/components/Collapsible.svelte.d.ts +52 -0
- package/dist/components/CollapsibleAdvanced.svelte +174 -0
- package/dist/components/CollapsibleAdvanced.svelte.d.ts +43 -0
- package/dist/components/DashOutline.svelte +47 -0
- package/dist/components/DashOutline.svelte.d.ts +6 -0
- package/dist/components/Dialogs.svelte +123 -0
- package/dist/components/Dialogs.svelte.d.ts +6 -0
- package/dist/components/Drawer.svelte +231 -0
- package/dist/components/Drawer.svelte.d.ts +62 -0
- package/dist/components/ErrorMessage.svelte +140 -0
- package/dist/components/ErrorMessage.svelte.d.ts +41 -0
- package/dist/components/Icon.svelte +94 -0
- package/dist/components/Icon.svelte.d.ts +33 -0
- package/dist/components/InfoTip.svelte +183 -0
- package/dist/components/InfoTip.svelte.d.ts +28 -0
- package/dist/components/Md.svelte +28 -0
- package/dist/components/Md.svelte.d.ts +11 -0
- package/dist/components/Modal.svelte +91 -0
- package/dist/components/Modal.svelte.d.ts +41 -0
- package/dist/components/Notice.svelte +50 -0
- package/dist/components/Notice.svelte.d.ts +30 -0
- package/dist/components/Popover.svelte +212 -0
- package/dist/components/Popover.svelte.d.ts +70 -0
- package/dist/components/Shimmer.svelte +27 -0
- package/dist/components/Shimmer.svelte.d.ts +22 -0
- package/dist/components/Splitter.svelte +152 -0
- package/dist/components/Splitter.svelte.d.ts +41 -0
- package/dist/components/Table.svelte +448 -0
- package/dist/components/Table.svelte.d.ts +268 -0
- package/dist/components/Toast.svelte +273 -0
- package/dist/components/Toast.svelte.d.ts +31 -0
- package/dist/components/Tooltip.svelte +97 -0
- package/dist/components/Tooltip.svelte.d.ts +19 -0
- package/dist/components/WorkingBorder.svelte +105 -0
- package/dist/components/WorkingBorder.svelte.d.ts +26 -0
- package/dist/components/empty/Empty.svelte +55 -0
- package/dist/components/empty/Empty.svelte.d.ts +39 -0
- package/dist/components/empty/EmptyError.svelte +47 -0
- package/dist/components/empty/EmptyError.svelte.d.ts +28 -0
- package/dist/components/empty/index.d.ts +18 -0
- package/dist/components/empty/index.js +10 -0
- package/dist/components/filters/DateFilter.svelte +59 -0
- package/dist/components/filters/DateFilter.svelte.d.ts +23 -0
- package/dist/components/filters/FilterBar.svelte +401 -0
- package/dist/components/filters/FilterBar.svelte.d.ts +283 -0
- package/dist/components/filters/FilterChip.svelte +235 -0
- package/dist/components/filters/FilterChip.svelte.d.ts +68 -0
- package/dist/components/filters/OptionList.svelte +352 -0
- package/dist/components/filters/OptionList.svelte.d.ts +91 -0
- package/dist/components/filters/Panel.svelte +123 -0
- package/dist/components/filters/Panel.svelte.d.ts +25 -0
- package/dist/components/filters/index.d.ts +288 -0
- package/dist/components/filters/index.js +12 -0
- package/dist/components/icons.d.ts +54 -0
- package/dist/components/icons.js +58 -0
- package/dist/components/inputs/ButtonGroup.svelte +110 -0
- package/dist/components/inputs/ButtonGroup.svelte.d.ts +40 -0
- package/dist/components/inputs/Calendar.svelte +535 -0
- package/dist/components/inputs/Calendar.svelte.d.ts +45 -0
- package/dist/components/inputs/DateField.svelte +247 -0
- package/dist/components/inputs/DateField.svelte.d.ts +74 -0
- package/dist/components/inputs/DateInput.svelte +118 -0
- package/dist/components/inputs/DateInput.svelte.d.ts +43 -0
- package/dist/components/inputs/DatePicker.svelte +102 -0
- package/dist/components/inputs/DatePicker.svelte.d.ts +67 -0
- package/dist/components/inputs/DateRangePicker.svelte +208 -0
- package/dist/components/inputs/DateRangePicker.svelte.d.ts +76 -0
- package/dist/components/inputs/DateRangeSelect.svelte +548 -0
- package/dist/components/inputs/DateRangeSelect.svelte.d.ts +70 -0
- package/dist/components/inputs/FieldLabel.svelte +43 -0
- package/dist/components/inputs/FieldLabel.svelte.d.ts +28 -0
- package/dist/components/inputs/ListSearch.svelte +142 -0
- package/dist/components/inputs/ListSearch.svelte.d.ts +35 -0
- package/dist/components/inputs/RadioGroup.svelte +151 -0
- package/dist/components/inputs/RadioGroup.svelte.d.ts +49 -0
- package/dist/components/inputs/RangeShortcuts.svelte +90 -0
- package/dist/components/inputs/RangeShortcuts.svelte.d.ts +31 -0
- package/dist/components/inputs/RangeSlider.svelte +225 -0
- package/dist/components/inputs/RangeSlider.svelte.d.ts +37 -0
- package/dist/components/inputs/SearchField.svelte +24 -0
- package/dist/components/inputs/SearchField.svelte.d.ts +41 -0
- package/dist/components/inputs/Segmented.svelte +79 -0
- package/dist/components/inputs/Segmented.svelte.d.ts +43 -0
- package/dist/components/inputs/Select.svelte +552 -0
- package/dist/components/inputs/Select.svelte.d.ts +100 -0
- package/dist/components/inputs/Slider.svelte +177 -0
- package/dist/components/inputs/Slider.svelte.d.ts +33 -0
- package/dist/components/inputs/SliderTicks.svelte +62 -0
- package/dist/components/inputs/SliderTicks.svelte.d.ts +23 -0
- package/dist/components/inputs/Switch.svelte +120 -0
- package/dist/components/inputs/Switch.svelte.d.ts +31 -0
- package/dist/components/inputs/TagInput.svelte +296 -0
- package/dist/components/inputs/TagInput.svelte.d.ts +61 -0
- package/dist/components/inputs/TextArea.svelte +86 -0
- package/dist/components/inputs/TextArea.svelte.d.ts +56 -0
- package/dist/components/inputs/TextField.svelte +170 -0
- package/dist/components/inputs/TextField.svelte.d.ts +80 -0
- package/dist/components/menu/ContextMenu.svelte +25 -0
- package/dist/components/menu/ContextMenu.svelte.d.ts +26 -0
- package/dist/components/menu/MenuButton.svelte +46 -0
- package/dist/components/menu/MenuButton.svelte.d.ts +16 -0
- package/dist/components/menu/MenuList.svelte +319 -0
- package/dist/components/menu/MenuList.svelte.d.ts +30 -0
- package/dist/components/metadata/Metadata.svelte +38 -0
- package/dist/components/metadata/Metadata.svelte.d.ts +31 -0
- package/dist/components/metadata/MetadataRow.svelte +84 -0
- package/dist/components/metadata/MetadataRow.svelte.d.ts +26 -0
- package/dist/components/metadata/index.d.ts +8 -0
- package/dist/components/metadata/index.js +13 -0
- package/dist/components/side-menu/SideMenu.svelte +138 -0
- package/dist/components/side-menu/SideMenu.svelte.d.ts +25 -0
- package/dist/components/side-menu/SideMenuGroup.svelte +108 -0
- package/dist/components/side-menu/SideMenuGroup.svelte.d.ts +31 -0
- package/dist/components/side-menu/SideMenuItem.svelte +221 -0
- package/dist/components/side-menu/SideMenuItem.svelte.d.ts +46 -0
- package/dist/components/side-menu/context.d.ts +1 -0
- package/dist/components/side-menu/context.js +3 -0
- package/dist/components/side-menu/index.d.ts +62 -0
- package/dist/components/side-menu/index.js +15 -0
- package/dist/components/tiles/Tile.svelte +419 -0
- package/dist/components/tiles/Tile.svelte.d.ts +58 -0
- package/dist/components/tiles/TileGroup.svelte +135 -0
- package/dist/components/tiles/TileGroup.svelte.d.ts +45 -0
- package/dist/components/tiles/context.d.ts +35 -0
- package/dist/components/tiles/context.js +14 -0
- package/dist/components/tiles/index.d.ts +6 -0
- package/dist/components/tiles/index.js +13 -0
- package/dist/components/upload/FileCard.svelte +301 -0
- package/dist/components/upload/FileCard.svelte.d.ts +127 -0
- package/dist/components/upload/Thumb.svelte +274 -0
- package/dist/components/upload/Thumb.svelte.d.ts +101 -0
- package/dist/components/upload/UploadFile.svelte +123 -0
- package/dist/components/upload/UploadFile.svelte.d.ts +48 -0
- package/dist/components/upload/UploadFiles.svelte +177 -0
- package/dist/components/upload/UploadFiles.svelte.d.ts +50 -0
- package/dist/components/upload/UploadFolder.svelte +153 -0
- package/dist/components/upload/UploadFolder.svelte.d.ts +63 -0
- package/dist/components/upload/UploadImage.svelte +137 -0
- package/dist/components/upload/UploadImage.svelte.d.ts +52 -0
- package/dist/components/upload/UploadImages.svelte +172 -0
- package/dist/components/upload/UploadImages.svelte.d.ts +52 -0
- package/dist/components/upload/UploadZone.svelte +130 -0
- package/dist/components/upload/UploadZone.svelte.d.ts +41 -0
- package/dist/components/upload/common.d.ts +31 -0
- package/dist/components/upload/common.js +103 -0
- package/dist/components/upload/context.d.ts +18 -0
- package/dist/components/upload/context.js +10 -0
- package/dist/components/upload/index.d.ts +16 -0
- package/dist/components/upload/index.js +18 -0
- package/dist/css/atoms.css +899 -0
- package/dist/css/base.css +334 -0
- package/dist/css/effects.css +430 -0
- package/dist/css/index.css +10 -0
- package/dist/css/tokens.css +296 -0
- package/dist/fonts.d.ts +1 -0
- package/dist/fonts.js +7 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +77 -0
- package/dist/lib/announce.d.ts +8 -0
- package/dist/lib/announce.js +48 -0
- package/dist/lib/controls.d.ts +10 -0
- package/dist/lib/controls.js +42 -0
- package/dist/lib/dates.d.ts +104 -0
- package/dist/lib/dates.js +235 -0
- package/dist/lib/dialogs.svelte.d.ts +8 -0
- package/dist/lib/dialogs.svelte.js +45 -0
- package/dist/lib/dom.d.ts +34 -0
- package/dist/lib/dom.js +90 -0
- package/dist/lib/field-errors.svelte.d.ts +40 -0
- package/dist/lib/field-errors.svelte.js +89 -0
- package/dist/lib/files.d.ts +74 -0
- package/dist/lib/files.js +215 -0
- package/dist/lib/inline-md.d.ts +1 -0
- package/dist/lib/inline-md.js +36 -0
- package/dist/lib/invalid.d.ts +4 -0
- package/dist/lib/invalid.js +35 -0
- package/dist/lib/list-search.d.ts +9 -0
- package/dist/lib/list-search.js +27 -0
- package/dist/lib/menu.svelte.d.ts +39 -0
- package/dist/lib/menu.svelte.js +98 -0
- package/dist/lib/morph.svelte.d.ts +17 -0
- package/dist/lib/morph.svelte.js +46 -0
- package/dist/lib/motion.d.ts +115 -0
- package/dist/lib/motion.js +174 -0
- package/dist/lib/observe.d.ts +36 -0
- package/dist/lib/observe.js +142 -0
- package/dist/lib/reveal.d.ts +7 -0
- package/dist/lib/reveal.js +28 -0
- package/dist/lib/roving.d.ts +16 -0
- package/dist/lib/roving.js +35 -0
- package/dist/lib/runs.d.ts +18 -0
- package/dist/lib/runs.js +25 -0
- package/dist/lib/scroll-fade.d.ts +4 -0
- package/dist/lib/scroll-fade.js +71 -0
- package/dist/lib/spotlight.d.ts +4 -0
- package/dist/lib/spotlight.js +109 -0
- package/dist/lib/ticks.d.ts +12 -0
- package/dist/lib/ticks.js +24 -0
- package/dist/lib/tooltip.d.ts +4 -0
- package/dist/lib/tooltip.js +110 -0
- package/dist/lib/validity.d.ts +16 -0
- package/dist/lib/validity.js +36 -0
- package/package.json +69 -3
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* A range on one track: two thumbs, from and to, that can't cross. Slider's look, two values.
|
|
4
|
+
*
|
|
5
|
+
* <RangeSlider bind:value={price} min={0} max={500} step={10} id="price" label="Price" format={(v) => `€${v}`} />
|
|
6
|
+
*
|
|
7
|
+
* value (bindable): [from, to]. gap: the least distance kept between them (default 0, they may meet).
|
|
8
|
+
* format: how a value reads, beside the track (on the right, "from – to") and to screen readers.
|
|
9
|
+
* ticks: a mark under the track at each stop, as Slider's ('auto' by default: when there are 3 to 11 stops).
|
|
10
|
+
* note, info, hideLabel: as on the other fields (see FieldLabel).
|
|
11
|
+
* Keyboard, on each thumb (each is its own slider, as the ARIA pattern has it): arrows step, PageUp / PageDown take a
|
|
12
|
+
* tenth of the range, Home / End go as far as the other thumb allows. Pointer: drag a thumb, or press the track to
|
|
13
|
+
* move the nearer thumb there.
|
|
14
|
+
* Other attributes (class…) and attachments go to the group around the thumbs.
|
|
15
|
+
*
|
|
16
|
+
* @typedef {object} Props
|
|
17
|
+
* @property {[number, number]} [value] bindable
|
|
18
|
+
* @property {number} [min]
|
|
19
|
+
* @property {number} [max]
|
|
20
|
+
* @property {number} [step]
|
|
21
|
+
* @property {number} [gap]
|
|
22
|
+
* @property {string} id
|
|
23
|
+
* @property {string} label
|
|
24
|
+
* @property {(value: number) => string} [format]
|
|
25
|
+
* @property {string} [note]
|
|
26
|
+
* @property {string} [info]
|
|
27
|
+
* @property {boolean} [hideLabel]
|
|
28
|
+
* @property {'auto' | boolean} [ticks]
|
|
29
|
+
*/
|
|
30
|
+
import FieldLabel from './FieldLabel.svelte'
|
|
31
|
+
import SliderTicks from './SliderTicks.svelte'
|
|
32
|
+
|
|
33
|
+
/** @type {Props & Omit<import('svelte/elements').HTMLAttributes<HTMLDivElement>, keyof Props>} */
|
|
34
|
+
let {
|
|
35
|
+
value = $bindable([0, 100]),
|
|
36
|
+
min = 0,
|
|
37
|
+
max = 100,
|
|
38
|
+
step = 1,
|
|
39
|
+
gap = 0,
|
|
40
|
+
id,
|
|
41
|
+
label,
|
|
42
|
+
format = (v) => String(v),
|
|
43
|
+
note = '',
|
|
44
|
+
info = '',
|
|
45
|
+
hideLabel = false,
|
|
46
|
+
ticks = 'auto',
|
|
47
|
+
class: className,
|
|
48
|
+
...rest
|
|
49
|
+
} = $props()
|
|
50
|
+
|
|
51
|
+
/** @type {HTMLDivElement | undefined} */
|
|
52
|
+
let track = $state()
|
|
53
|
+
/** @type {HTMLDivElement[]} */
|
|
54
|
+
const thumbs = []
|
|
55
|
+
/** Which thumb is being dragged: 0 (from), 1 (to) or null. */
|
|
56
|
+
let dragging = $state(/** @type {0 | 1 | null} */ (null))
|
|
57
|
+
|
|
58
|
+
const pct = (v) => ((v - min) / (max - min)) * 100
|
|
59
|
+
const snap = (v) => Math.round((v - min) / step) * step + min
|
|
60
|
+
/** The limits of one thumb: the range's ends, and the other thumb (less the gap). */
|
|
61
|
+
const lowest = (i) => (i === 0 ? min : value[0] + gap)
|
|
62
|
+
const highest = (i) => (i === 0 ? value[1] - gap : max)
|
|
63
|
+
|
|
64
|
+
/** @param {0 | 1} i @param {number} v */
|
|
65
|
+
function set(i, v) {
|
|
66
|
+
const next = Math.min(highest(i), Math.max(lowest(i), snap(v)))
|
|
67
|
+
if (next === value[i]) return
|
|
68
|
+
value = i === 0 ? [next, value[1]] : [value[0], next]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @param {PointerEvent} e */
|
|
72
|
+
const at = (e) => {
|
|
73
|
+
const r = /** @type {HTMLDivElement} */ (track).getBoundingClientRect()
|
|
74
|
+
return min + ((e.clientX - r.left) / r.width) * (max - min)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** A press on the track (or a thumb): the nearer thumb takes over and follows the pointer. */
|
|
78
|
+
function down(e) {
|
|
79
|
+
if (e.button !== 0) return
|
|
80
|
+
const v = at(e)
|
|
81
|
+
// Equal distances (thumbs together) go to the side the press is on.
|
|
82
|
+
/** @type {0 | 1} */
|
|
83
|
+
const i = Math.abs(v - value[0]) < Math.abs(v - value[1]) || (value[0] === value[1] && v < value[0]) ? 0 : 1
|
|
84
|
+
dragging = i
|
|
85
|
+
e.currentTarget.setPointerCapture(e.pointerId)
|
|
86
|
+
e.preventDefault()
|
|
87
|
+
thumbs[i]?.focus()
|
|
88
|
+
set(i, v)
|
|
89
|
+
}
|
|
90
|
+
const move = (e) => dragging !== null && set(dragging, at(e))
|
|
91
|
+
const up = () => (dragging = null)
|
|
92
|
+
|
|
93
|
+
/** @param {KeyboardEvent} e @param {0 | 1} i */
|
|
94
|
+
function onkeydown(e, i) {
|
|
95
|
+
const big = step * Math.max(1, Math.round((max - min) / step / 10))
|
|
96
|
+
const v = value[i]
|
|
97
|
+
const next = {
|
|
98
|
+
ArrowRight: v + step,
|
|
99
|
+
ArrowUp: v + step,
|
|
100
|
+
ArrowLeft: v - step,
|
|
101
|
+
ArrowDown: v - step,
|
|
102
|
+
PageUp: v + big,
|
|
103
|
+
PageDown: v - big,
|
|
104
|
+
Home: lowest(i),
|
|
105
|
+
End: highest(i),
|
|
106
|
+
}[e.key]
|
|
107
|
+
if (next === undefined) return
|
|
108
|
+
e.preventDefault()
|
|
109
|
+
set(i, next)
|
|
110
|
+
}
|
|
111
|
+
</script>
|
|
112
|
+
|
|
113
|
+
<div class="field">
|
|
114
|
+
<FieldLabel id="{id}-label" {label} {note} {info} {hideLabel} />
|
|
115
|
+
<span id="{id}-from-name" class="sr-only">from</span>
|
|
116
|
+
<span id="{id}-to-name" class="sr-only">to</span>
|
|
117
|
+
<div class="row">
|
|
118
|
+
<!-- Pointer only: the thumbs inside are the keyboard's way in. -->
|
|
119
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
120
|
+
<div
|
|
121
|
+
class={['range', className]}
|
|
122
|
+
{...rest}
|
|
123
|
+
role="group"
|
|
124
|
+
aria-labelledby="{id}-label"
|
|
125
|
+
class:dragging={dragging !== null}
|
|
126
|
+
style:--from="{pct(value[0])}%"
|
|
127
|
+
style:--to="{pct(value[1])}%"
|
|
128
|
+
onpointerdown={down}
|
|
129
|
+
onpointermove={move}
|
|
130
|
+
onpointerup={up}
|
|
131
|
+
onpointercancel={up}
|
|
132
|
+
>
|
|
133
|
+
<div class="track" bind:this={track}><div class="fill"></div></div>
|
|
134
|
+
<SliderTicks {min} {max} {step} {ticks} on={(v) => v >= value[0] && v <= value[1]} />
|
|
135
|
+
{#each [0, 1] as i (i)}
|
|
136
|
+
<div
|
|
137
|
+
bind:this={thumbs[i]}
|
|
138
|
+
id="{id}-{i === 0 ? 'from' : 'to'}"
|
|
139
|
+
class="thumb"
|
|
140
|
+
class:active={dragging === i}
|
|
141
|
+
style:left="var(--{i === 0 ? 'from' : 'to'})"
|
|
142
|
+
role="slider"
|
|
143
|
+
tabindex="0"
|
|
144
|
+
aria-labelledby="{id}-label {id}-{i === 0 ? 'from' : 'to'}-name"
|
|
145
|
+
aria-valuemin={lowest(i)}
|
|
146
|
+
aria-valuemax={highest(i)}
|
|
147
|
+
aria-valuenow={value[i]}
|
|
148
|
+
aria-valuetext={format(value[i])}
|
|
149
|
+
onkeydown={(e) => onkeydown(e, /** @type {0 | 1} */ (i))}
|
|
150
|
+
></div>
|
|
151
|
+
{/each}
|
|
152
|
+
</div>
|
|
153
|
+
<output for="{id}-from {id}-to">{format(value[0])} – {format(value[1])}</output>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<style>
|
|
158
|
+
.field {
|
|
159
|
+
display: flex;
|
|
160
|
+
flex-direction: column;
|
|
161
|
+
gap: 3px;
|
|
162
|
+
}
|
|
163
|
+
/* The track, then the value on its right. The gap clears the thumb, which overhangs the track's end by half its width. */
|
|
164
|
+
.row {
|
|
165
|
+
display: flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
gap: var(--space-3);
|
|
168
|
+
}
|
|
169
|
+
output {
|
|
170
|
+
font: var(--w-medium) 12px var(--font-data);
|
|
171
|
+
font-variant-numeric: tabular-nums;
|
|
172
|
+
color: var(--fg-2);
|
|
173
|
+
white-space: nowrap;
|
|
174
|
+
}
|
|
175
|
+
.range {
|
|
176
|
+
position: relative;
|
|
177
|
+
width: 180px;
|
|
178
|
+
height: 32px;
|
|
179
|
+
display: flex;
|
|
180
|
+
align-items: center;
|
|
181
|
+
cursor: pointer;
|
|
182
|
+
/* Horizontal drags are the slider's; vertical ones still scroll the page. */
|
|
183
|
+
touch-action: pan-y;
|
|
184
|
+
}
|
|
185
|
+
.track {
|
|
186
|
+
position: relative;
|
|
187
|
+
width: 100%;
|
|
188
|
+
height: 4px;
|
|
189
|
+
border-radius: var(--r-pill);
|
|
190
|
+
background: var(--control-4);
|
|
191
|
+
overflow: clip;
|
|
192
|
+
}
|
|
193
|
+
.fill {
|
|
194
|
+
position: absolute;
|
|
195
|
+
inset: 0 auto 0 var(--from);
|
|
196
|
+
width: calc(var(--to) - var(--from));
|
|
197
|
+
background: var(--brand);
|
|
198
|
+
}
|
|
199
|
+
.thumb {
|
|
200
|
+
position: absolute;
|
|
201
|
+
top: 50%;
|
|
202
|
+
width: 14px;
|
|
203
|
+
height: 14px;
|
|
204
|
+
translate: -50% -50%;
|
|
205
|
+
scale: 1;
|
|
206
|
+
border-radius: 50%;
|
|
207
|
+
background: var(--knob);
|
|
208
|
+
box-shadow:
|
|
209
|
+
0 0 0 1px var(--knob-ring),
|
|
210
|
+
var(--knob-shadow);
|
|
211
|
+
transition: scale var(--dur-fast) var(--ease-out);
|
|
212
|
+
}
|
|
213
|
+
.thumb:hover,
|
|
214
|
+
.thumb.active {
|
|
215
|
+
scale: 1.12;
|
|
216
|
+
}
|
|
217
|
+
.thumb:focus-visible {
|
|
218
|
+
outline: 2px solid var(--accent);
|
|
219
|
+
outline-offset: 2px;
|
|
220
|
+
}
|
|
221
|
+
/* The one in use draws above the other where they meet. */
|
|
222
|
+
.thumb:is(:focus, .active) {
|
|
223
|
+
z-index: 1;
|
|
224
|
+
}
|
|
225
|
+
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default RangeSlider;
|
|
2
|
+
/**
|
|
3
|
+
* A range on one track: two thumbs, from and to, that can't cross. Slider's look, two values.
|
|
4
|
+
*
|
|
5
|
+
* <RangeSlider bind:value={price} min={0} max={500} step={10} id="price" label="Price" format={(v) => `€${v}`} />
|
|
6
|
+
*
|
|
7
|
+
* value (bindable): [from, to]. gap: the least distance kept between them (default 0, they may meet).
|
|
8
|
+
* format: how a value reads, beside the track (on the right, "from – to") and to screen readers.
|
|
9
|
+
* ticks: a mark under the track at each stop, as Slider's ('auto' by default: when there are 3 to 11 stops).
|
|
10
|
+
* note, info, hideLabel: as on the other fields (see FieldLabel).
|
|
11
|
+
* Keyboard, on each thumb (each is its own slider, as the ARIA pattern has it): arrows step, PageUp / PageDown take a
|
|
12
|
+
* tenth of the range, Home / End go as far as the other thumb allows. Pointer: drag a thumb, or press the track to
|
|
13
|
+
* move the nearer thumb there.
|
|
14
|
+
* Other attributes (class…) and attachments go to the group around the thumbs.
|
|
15
|
+
*/
|
|
16
|
+
export type Props = {
|
|
17
|
+
/**
|
|
18
|
+
* bindable
|
|
19
|
+
*/
|
|
20
|
+
value?: [number, number] | undefined;
|
|
21
|
+
min?: number | undefined;
|
|
22
|
+
max?: number | undefined;
|
|
23
|
+
step?: number | undefined;
|
|
24
|
+
gap?: number | undefined;
|
|
25
|
+
id: string;
|
|
26
|
+
label: string;
|
|
27
|
+
format?: ((value: number) => string) | undefined;
|
|
28
|
+
note?: string | undefined;
|
|
29
|
+
info?: string | undefined;
|
|
30
|
+
hideLabel?: boolean | undefined;
|
|
31
|
+
ticks?: boolean | "auto" | undefined;
|
|
32
|
+
};
|
|
33
|
+
type RangeSlider = {
|
|
34
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
35
|
+
$set?(props: Partial<Props & Omit<HTMLAttributes<HTMLDivElement>, keyof Props>>): void;
|
|
36
|
+
};
|
|
37
|
+
declare const RangeSlider: import("svelte").Component<Props & Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, keyof Props>, {}, "value">;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* Compact search box for toolbars: search icon, clear button, optional shortcut hint (e.g. "/"), Esc clears.
|
|
4
|
+
* A TextField in its compact size; the label is for screen readers only. Call focus() to jump into it.
|
|
5
|
+
* Other attributes and attachments go to the <input>, as with TextField.
|
|
6
|
+
*/
|
|
7
|
+
import TextField from './TextField.svelte'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {object} Props
|
|
11
|
+
* @property {string} [value] bindable
|
|
12
|
+
* @property {string} id
|
|
13
|
+
* @property {string} label
|
|
14
|
+
* @property {string} [placeholder]
|
|
15
|
+
* @property {string | null} [shortcut]
|
|
16
|
+
* @property {((value: string) => void) | null} [onenter]
|
|
17
|
+
*/
|
|
18
|
+
/** @type {Props & Omit<import('svelte/elements').HTMLInputAttributes, keyof Props>} */
|
|
19
|
+
let { value = $bindable(''), id, label, placeholder = '', shortcut = null, onenter = null, ...rest } = $props()
|
|
20
|
+
let field = $state()
|
|
21
|
+
export const focus = () => field?.focus()
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<TextField {...rest} {id} {label} {placeholder} {shortcut} {onenter} hideLabel compact bind:value bind:this={field} />
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export default SearchField;
|
|
2
|
+
type SearchField = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props & Omit<HTMLInputAttributes, keyof Props>>): void;
|
|
5
|
+
} & {
|
|
6
|
+
focus: () => any;
|
|
7
|
+
};
|
|
8
|
+
declare const SearchField: import("svelte").Component<{
|
|
9
|
+
/**
|
|
10
|
+
* bindable
|
|
11
|
+
*/
|
|
12
|
+
value?: string | undefined;
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
placeholder?: string | undefined;
|
|
16
|
+
shortcut?: string | null | undefined;
|
|
17
|
+
onenter?: ((value: string) => void) | null | undefined;
|
|
18
|
+
} & Omit<import("svelte/elements").HTMLInputAttributes, keyof {
|
|
19
|
+
/**
|
|
20
|
+
* bindable
|
|
21
|
+
*/
|
|
22
|
+
value?: string | undefined;
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
placeholder?: string | undefined;
|
|
26
|
+
shortcut?: string | null | undefined;
|
|
27
|
+
onenter?: ((value: string) => void) | null | undefined;
|
|
28
|
+
}>, {
|
|
29
|
+
focus: () => any;
|
|
30
|
+
}, "value">;
|
|
31
|
+
type Props = {
|
|
32
|
+
/**
|
|
33
|
+
* bindable
|
|
34
|
+
*/
|
|
35
|
+
value?: string | undefined;
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
placeholder?: string | undefined;
|
|
39
|
+
shortcut?: string | null | undefined;
|
|
40
|
+
onenter?: ((value: string) => void) | null | undefined;
|
|
41
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Icon from '../Icon.svelte'
|
|
3
|
+
import { tooltip } from '../../lib/tooltip.js'
|
|
4
|
+
import { radioKeys } from '../../lib/roving.js'
|
|
5
|
+
/** Single choice shown as a row of pills (radio group with roving focus). An option with `done` gets a green icon; `hint` becomes its tooltip. */
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {{ value: any, label: string, icon?: string, hint?: string, done?: boolean }} Option
|
|
8
|
+
* @typedef {object} Props
|
|
9
|
+
* @property {any} value
|
|
10
|
+
* @property {Option[]} options
|
|
11
|
+
* @property {string} label
|
|
12
|
+
* @property {(value: any) => void} onchange
|
|
13
|
+
* @property {boolean} [iconOnly]
|
|
14
|
+
*/
|
|
15
|
+
/** @type {Props & Omit<import('svelte/elements').HTMLAttributes<HTMLDivElement>, keyof Props>} */
|
|
16
|
+
let { value, options, label, onchange, iconOnly = false, class: className, ...rest } = $props()
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class={['seg', className]} role="radiogroup" aria-label={label} {...rest} {@attach radioKeys}>
|
|
20
|
+
{#each options as o (o.value)}
|
|
21
|
+
<button
|
|
22
|
+
type="button"
|
|
23
|
+
role="radio"
|
|
24
|
+
aria-checked={o.value === value}
|
|
25
|
+
data-done={o.done || undefined}
|
|
26
|
+
tabindex={o.value === value ? 0 : -1}
|
|
27
|
+
onclick={() => onchange(o.value)}
|
|
28
|
+
{@attach tooltip(iconOnly ? o.label + (o.hint ? ` (${o.hint})` : '') : o.hint)}
|
|
29
|
+
aria-label={iconOnly ? o.label : undefined}
|
|
30
|
+
>{#if o.icon}<Icon name={o.icon} />{/if}{#if !iconOnly}<span>{o.label}</span>{/if}</button
|
|
31
|
+
>
|
|
32
|
+
{/each}
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
/* One track, the chosen option raised on it (same shape as the layout tabs in the header). */
|
|
37
|
+
.seg {
|
|
38
|
+
display: inline-flex;
|
|
39
|
+
flex-wrap: wrap;
|
|
40
|
+
gap: 4px;
|
|
41
|
+
/* As wide as its options: a grid or column-flex parent would otherwise stretch the track past them. */
|
|
42
|
+
width: fit-content;
|
|
43
|
+
max-width: 100%;
|
|
44
|
+
}
|
|
45
|
+
button {
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: 6px;
|
|
49
|
+
min-height: 28px;
|
|
50
|
+
border: 0;
|
|
51
|
+
border-radius: var(--r-pill);
|
|
52
|
+
padding: 0 10px;
|
|
53
|
+
/* Flat at rest; only the chosen option is raised. */
|
|
54
|
+
background: var(--control-1);
|
|
55
|
+
box-shadow: inset 0 0 0 1px var(--line);
|
|
56
|
+
font-size: 12px;
|
|
57
|
+
line-height: 14px;
|
|
58
|
+
font-weight: var(--w-medium);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
color: var(--fg);
|
|
61
|
+
transition:
|
|
62
|
+
color var(--dur) var(--ease-out),
|
|
63
|
+
background-color var(--dur) var(--ease-out),
|
|
64
|
+
box-shadow var(--dur) var(--ease-out);
|
|
65
|
+
}
|
|
66
|
+
button:not([aria-checked='true']):hover {
|
|
67
|
+
background: var(--control-2);
|
|
68
|
+
}
|
|
69
|
+
[aria-checked='true'] {
|
|
70
|
+
background: var(--control-4);
|
|
71
|
+
box-shadow:
|
|
72
|
+
inset 0 0 0 1px var(--line),
|
|
73
|
+
var(--shadow-btn);
|
|
74
|
+
}
|
|
75
|
+
/* Something finished behind this option (e.g. research done): its icon turns green. */
|
|
76
|
+
[data-done] :global(.icon) {
|
|
77
|
+
color: var(--success);
|
|
78
|
+
}
|
|
79
|
+
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export default Segmented;
|
|
2
|
+
type Segmented = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props & Omit<HTMLAttributes<HTMLDivElement>, keyof Props>>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Segmented: import("svelte").Component<{
|
|
7
|
+
value: any;
|
|
8
|
+
options: {
|
|
9
|
+
value: any;
|
|
10
|
+
label: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
hint?: string;
|
|
13
|
+
done?: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
label: string;
|
|
16
|
+
onchange: (value: any) => void;
|
|
17
|
+
iconOnly?: boolean | undefined;
|
|
18
|
+
} & Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, keyof {
|
|
19
|
+
value: any;
|
|
20
|
+
options: {
|
|
21
|
+
value: any;
|
|
22
|
+
label: string;
|
|
23
|
+
icon?: string;
|
|
24
|
+
hint?: string;
|
|
25
|
+
done?: boolean;
|
|
26
|
+
}[];
|
|
27
|
+
label: string;
|
|
28
|
+
onchange: (value: any) => void;
|
|
29
|
+
iconOnly?: boolean | undefined;
|
|
30
|
+
}>, {}, "">;
|
|
31
|
+
type Props = {
|
|
32
|
+
value: any;
|
|
33
|
+
options: {
|
|
34
|
+
value: any;
|
|
35
|
+
label: string;
|
|
36
|
+
icon?: string;
|
|
37
|
+
hint?: string;
|
|
38
|
+
done?: boolean;
|
|
39
|
+
}[];
|
|
40
|
+
label: string;
|
|
41
|
+
onchange: (value: any) => void;
|
|
42
|
+
iconOnly?: boolean | undefined;
|
|
43
|
+
};
|