@xerios/design-system 0.1.0 → 0.1.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,48 @@
1
+ # Changelog
2
+
3
+ What changed in each release of `@xerios/design-system`, newest first. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and versions follow [semver](https://semver.org/): while on
5
+ 0.x, a breaking change (a renamed or removed token, class, prop or export) bumps the minor version, anything else the
6
+ patch. Breaking entries are marked **Breaking** and say what to change in an app.
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.2] - 2026-11-20
11
+
12
+ ### Changed
13
+
14
+ - `Dialogs` (`alertDialog`, `confirmDialog`, `promptDialog`): under 860px the dialog sits at the bottom of the screen with its buttons sharing the row; cancel and confirm are spaced further apart.
15
+ - `.dialog`: its backdrop can't be selected.
16
+ - `--ease-spring` (a modal dialog's scale-in): a softer bounce, overshooting by about 8% instead of 20%.
17
+ - `ButtonGroup`, `Segmented`, `RadioGroup`: unchosen options have muted text until hovered; the chosen one stays clear.
18
+ - `FilterChip` (and `FilterBar`'s filters): resting fill a step stronger (`--control-2`), so a filter stands out more.
19
+
20
+ ### Removed
21
+
22
+ - **Breaking** `Button`: the `pressed` prop and the flat look of a toggled `.btn[aria-pressed="true"]` are gone. Drop
23
+ `bind:pressed` from your buttons; for an on/off choice use a `Switch`, `Segmented` or `ButtonGroup`.
24
+
25
+ ## [0.1.1] - 2026-11-20
26
+
27
+ ### Added
28
+
29
+ - `Button`: `pressed` (bindable) makes it a toggle button (`aria-pressed`), flipped on each press. Toggled on, a
30
+ secondary `.btn` drops its fill and shadow and keeps its hairline; any `.btn[aria-pressed="true"]` gets the same look.
31
+
32
+ ### Changed
33
+
34
+ - `ButtonGroup`, `Segmented`, `RadioGroup`: flat at rest; only the chosen option is filled and raised.
35
+ - `FilterBar`: a filter left with no value leaves `filters` at once; its chip stays on the row until its panel closes,
36
+ and picking a value again puts it back in its place.
37
+ - `FilterBar`: Backspace in the add panel's value step goes back to the field list from any editor, unless it deletes
38
+ something there (typed text, a word).
39
+
40
+ ## [0.1.0] - 2026-11-20
41
+
42
+ First release: theme tokens, global CSS (`base`, `effects`, `atoms`), the components listed in the README and the
43
+ `lib/` helpers.
44
+
45
+ [Unreleased]: https://github.com/Xerios/design-system/compare/v0.1.2...HEAD
46
+ [0.1.2]: https://github.com/Xerios/design-system/compare/v0.1.1...v0.1.2
47
+ [0.1.1]: https://github.com/Xerios/design-system/compare/v0.1.0...v0.1.1
48
+ [0.1.0]: https://github.com/Xerios/design-system/releases/tag/v0.1.0
@@ -116,6 +116,18 @@
116
116
  .dialog-form {
117
117
  display: contents;
118
118
  }
119
+ /* Cancel and confirm held apart, so a quick tap can't land on the wrong one. On a phone they share the row equally. */
120
+ .dialog-foot {
121
+ gap: var(--space-4);
122
+ }
123
+ @media (max-width: 860px) {
124
+ .spacer {
125
+ display: none;
126
+ }
127
+ .dialog-foot > :global(.btn) {
128
+ flex: 1;
129
+ }
130
+ }
119
131
  .body {
120
132
  overflow-wrap: anywhere;
121
133
  white-space: pre-line;
@@ -3,7 +3,9 @@
3
3
  * A row of filters drawn from data (Linear's view filters): one FilterChip per filter, then a funnel button that adds
4
4
  * one. The button lists the fields (with a search field when there are many); picking one shows its value editor in
5
5
  * the same panel, and the filter joins the row as soon as it has a value. A field already filtered opens its chip
6
- * instead, so each field has one filter. Unticking every value of a filter removes it as its panel closes.
6
+ * instead, so each field has one filter. A filter left with no value (every value unticked, every word removed) leaves
7
+ * `filters` at once, so nothing filters by it; its chip stays on the row until its panel closes, and picking a value
8
+ * again puts it back in its place.
7
9
  *
8
10
  * <FilterBar bind:filters fields={[
9
11
  * { key: 'status', label: 'Status', icon: 'circleDashed', options: [{ value: 'open', label: 'Open', icon: 'checkCircle', tone: 'success', hint: '12 items' }, …], plural: 'statuses' },
@@ -28,8 +30,9 @@
28
30
  * onchange(filters): after every edit. label: the row's accessible name ("Filters"). addLabel: the button's ("Add filter").
29
31
  * panel: snippet ({ filter, field, set, close }) for a custom field's editor: set(value) stores a value, close() closes.
30
32
  * summary: snippet ({ filter, field }) drawing a custom field's value on its chip (default: the value as text).
31
- * Keyboard: the chips' parts and the add button are in the tab order. In the add panel, Backspace in an empty search
32
- * goes from a field's values back to the field list. Removing a filter moves the focus to the next one, else the button.
33
+ * Keyboard: the chips' parts and the add button are in the tab order. In the add panel, Backspace on a field's values
34
+ * goes back to the field list, unless it deletes something there (typed text, a word). Removing a filter moves the focus
35
+ * to the next one, else the button.
33
36
  * Other attributes (class…) and attachments go to the row.
34
37
  */
35
38
  import { tick } from 'svelte'
@@ -40,6 +43,7 @@
40
43
  import TagInput from '../inputs/TagInput.svelte'
41
44
  import Panel from './Panel.svelte'
42
45
  import { tooltip } from '../../lib/tooltip.js'
46
+ import { composing } from '../../lib/dom.js'
43
47
  import { datePresets, formatDay, relativeDay } from '../../lib/dates.js'
44
48
 
45
49
  /**
@@ -78,6 +82,14 @@
78
82
  let openKey = $state(/** @type {string | null} */ (null))
79
83
  /** The add panel: closed, listing the fields, or showing one field's values. */
80
84
  let adding = $state(/** @type {null | { key: string | null }} */ (null))
85
+ /** A filter emptied while its panel is open: out of `filters`, but its chip stays on the row (at `at`) until it closes. */
86
+ let held = $state(/** @type {null | { at: number, filter: Filter }} */ (null))
87
+ /** The chips on the row: the filters, with the held one back in its place. */
88
+ const rows = $derived.by(() => {
89
+ if (!held || filters.some((x) => x.field === held?.filter.field)) return filters
90
+ const at = Math.min(held.at, filters.length)
91
+ return [...filters.slice(0, at), held.filter, ...filters.slice(at)]
92
+ })
81
93
 
82
94
  const byKey = $derived(new Map(fields.map((f) => [f.key, f])))
83
95
  /** @param {Field} f */
@@ -91,7 +103,9 @@
91
103
  /** @param {any} v */
92
104
  const isEmpty = (v) => v == null || v === '' || (Array.isArray(v) && !v.length)
93
105
  /** @param {string} key */
94
- const find = (key) => filters.find((x) => x.field === key)
106
+ const find = (key) => rows.find((x) => x.field === key)
107
+ /** @param {string} key */
108
+ const isHeld = (key) => held?.filter.field === key
95
109
 
96
110
  /** @param {Filter[]} next */
97
111
  function commitAll(next) {
@@ -100,7 +114,24 @@
100
114
  }
101
115
  /** @param {string} key @param {Partial<Filter>} patch */
102
116
  function update(key, patch) {
103
- commitAll(filters.map((x) => (x.field === key ? { ...x, ...patch } : x)))
117
+ if (held && isHeld(key)) {
118
+ const filter = { ...held.filter, ...patch }
119
+ if (isEmpty(filter.value)) held = { ...held, filter }
120
+ else {
121
+ const at = Math.min(held.at, filters.length)
122
+ held = null
123
+ commitAll([...filters.slice(0, at), filter, ...filters.slice(at)])
124
+ }
125
+ return
126
+ }
127
+ const at = filters.findIndex((x) => x.field === key)
128
+ if (at < 0) return
129
+ const filter = { ...filters[at], ...patch }
130
+ if (isEmpty(filter.value)) {
131
+ // Nothing to filter by: out of `filters` now, its chip held on the row until its panel closes.
132
+ held = { at, filter }
133
+ commitAll(filters.filter((_, i) => i !== at))
134
+ } else commitAll(filters.map((x, i) => (i === at ? filter : x)))
104
135
  }
105
136
  /** Stores a value for a field: on its filter, or as a new one once there is something to filter by. @param {string} key @param {any} value */
106
137
  function put(key, value) {
@@ -109,19 +140,21 @@
109
140
  if (find(key)) update(key, { value })
110
141
  else if (!isEmpty(value)) commitAll([...filters, { field: key, op: operatorsOf(field)[0], value }])
111
142
  }
112
- /** Drops a field's filter if it has nothing left to filter by. @param {string} key */
143
+ /** Drops a field's chip if it has nothing left to filter by. @param {string} key */
113
144
  function prune(key) {
114
- const f = find(key)
145
+ if (isHeld(key)) held = null
146
+ const f = filters.find((x) => x.field === key)
115
147
  if (f && isEmpty(f.value)) commitAll(filters.filter((x) => x !== f))
116
148
  }
117
149
  /** @param {string} key */
118
150
  async function remove(key) {
119
- const at = filters.findIndex((x) => x.field === key)
151
+ const at = rows.findIndex((x) => x.field === key)
120
152
  if (at < 0) return
121
153
  if (openKey === key) openKey = null
154
+ if (isHeld(key)) held = null
122
155
  commitAll(filters.filter((x) => x.field !== key))
123
156
  await tick()
124
- const next = filters[at] ?? filters[at - 1]
157
+ const next = rows[at] ?? rows[at - 1]
125
158
  if (next) chips[next.field]?.focus()
126
159
  else addButton?.focus()
127
160
  }
@@ -150,6 +183,26 @@
150
183
  })
151
184
  }
152
185
 
186
+ /** Attachment on the add panel's value step: Backspace goes back to the field list, whichever editor has the focus,
187
+ * unless the editor used it (a TagInput removing a word) or it deletes text where it was pressed.
188
+ * @param {() => void} back */
189
+ const NOT_TYPED = new Set(['checkbox', 'radio', 'button', 'submit', 'reset', 'range', 'color', 'file', 'image'])
190
+ const backOnBackspace = (back) => (/** @type {HTMLElement} */ node) => {
191
+ /** @param {KeyboardEvent} e */
192
+ const onkeydown = (e) => {
193
+ if (e.key !== 'Backspace' || e.defaultPrevented || composing(e) || e.ctrlKey || e.metaKey || e.altKey) return
194
+ const t = /** @type {HTMLElement} */ (e.target)
195
+ if (t.isContentEditable && t.textContent) return
196
+ // Text a Backspace would delete (a checkbox's or a button-like input's value isn't).
197
+ if (t instanceof HTMLTextAreaElement && t.value && !t.readOnly) return
198
+ if (t instanceof HTMLInputElement && t.value && !t.readOnly && !NOT_TYPED.has(t.type)) return
199
+ e.preventDefault()
200
+ back()
201
+ }
202
+ node.addEventListener('keydown', onkeydown)
203
+ return () => node.removeEventListener('keydown', onkeydown)
204
+ }
205
+
153
206
  /** @param {Filter} filter @param {Field} field */
154
207
  const presetOf = (filter, field) => (field.presets ?? datePresets()).find((p) => p.value === filter.value)
155
208
  /** @param {Filter} filter @param {Field} field */
@@ -164,7 +217,7 @@
164
217
  }
165
218
  </script>
166
219
 
167
- {#snippet editor(/** @type {Field} */ field, /** @type {Filter} */ current, /** @type {() => void} */ close, /** @type {(() => void) | undefined} */ back)}
220
+ {#snippet editor(/** @type {Field} */ field, /** @type {Filter} */ current, /** @type {() => void} */ close)}
168
221
  {#if kindOf(field) === 'options'}
169
222
  <OptionList
170
223
  value={current.value ?? []}
@@ -172,7 +225,6 @@
172
225
  label={field.label}
173
226
  search={field.search ?? 'auto'}
174
227
  onchange={(v) => put(field.key, v)}
175
- onback={back}
176
228
  />
177
229
  {:else if kindOf(field) === 'date'}
178
230
  <DateFilter
@@ -227,10 +279,10 @@
227
279
  {/snippet}
228
280
 
229
281
  <div class={['filter-bar', className]} role="group" aria-label={label} {...rest}>
230
- {#each filters as filter (filter.field)}
282
+ {#each rows as filter (filter.field)}
231
283
  {@const field = byKey.get(filter.field)}
232
284
  {#if field}
233
- {#snippet editPanel(/** @type {{ close: () => void }} */ { close })}{@render editor(field, filter, close, undefined)}{/snippet}
285
+ {#snippet editPanel(/** @type {{ close: () => void }} */ { close })}{@render editor(field, filter, close)}{/snippet}
234
286
  <FilterChip
235
287
  bind:this={chips[filter.field]}
236
288
  field={{ label: field.label, icon: field.icon }}
@@ -266,8 +318,15 @@
266
318
  <Panel anchor={addButton} name={anchor} label={field ? field.label : addLabel} onclose={closeAdding}>
267
319
  {#if field}
268
320
  {#key field.key}
269
- <div class="step" {@attach focusIn}>
270
- {@render editor(field, find(field.key) ?? { field: field.key, op: operatorsOf(field)[0], value: null }, () => closeAdding(true), () => (adding = { key: null }))}
321
+ <div
322
+ class="step"
323
+ {@attach focusIn}
324
+ {@attach backOnBackspace(() => {
325
+ prune(field.key)
326
+ adding = { key: null }
327
+ })}
328
+ >
329
+ {@render editor(field, find(field.key) ?? { field: field.key, op: operatorsOf(field)[0], value: null }, () => closeAdding(true))}
271
330
  </div>
272
331
  {/key}
273
332
  {:else}
@@ -141,7 +141,7 @@
141
141
  {/if}
142
142
 
143
143
  <style>
144
- /* Segments on one faint control fill, split by hairlines that run the pill's full height. */
144
+ /* Segments on one light control fill, split by hairlines that run the pill's full height. */
145
145
  /* Chrome, not content: its field name and condition are plain spans, which base.css doesn't cover. */
146
146
  .filter-chip {
147
147
  user-select: none;
@@ -151,7 +151,7 @@
151
151
  max-width: 100%;
152
152
  min-height: 26px;
153
153
  border-radius: var(--r-sm);
154
- background: var(--control-1);
154
+ background: var(--control-2);
155
155
  font: var(--w-medium) 12px/14px var(--font-body);
156
156
  white-space: nowrap;
157
157
  }
@@ -48,10 +48,9 @@
48
48
  width: fit-content;
49
49
  max-width: 100%;
50
50
  border-radius: var(--r-pill);
51
- background: var(--control-2);
52
- box-shadow:
53
- inset 0 0 0 1px var(--line),
54
- var(--shadow-btn);
51
+ /* Flat at rest; only the chosen option is raised. */
52
+ background: var(--control-1);
53
+ box-shadow: inset 0 0 0 1px var(--line);
55
54
  }
56
55
  button {
57
56
  display: inline-flex;
@@ -64,7 +63,8 @@
64
63
  border: 0;
65
64
  border-radius: 0;
66
65
  background: none;
67
- color: var(--fg);
66
+ /* Unchosen options are dimmed until hovered; the chosen one is clear. */
67
+ color: var(--muted);
68
68
  font-size: 12px;
69
69
  line-height: 14px;
70
70
  font-weight: var(--w-medium);
@@ -72,7 +72,8 @@
72
72
  white-space: nowrap;
73
73
  transition:
74
74
  color var(--dur) var(--ease-out),
75
- background-color var(--dur) var(--ease-out);
75
+ background-color var(--dur) var(--ease-out),
76
+ box-shadow var(--dur) var(--ease-out);
76
77
  }
77
78
  button + button {
78
79
  box-shadow: inset 1px 0 0 var(--line);
@@ -89,9 +90,17 @@
89
90
  }
90
91
  button:not([aria-checked='true']):hover {
91
92
  background: var(--control-2);
93
+ color: var(--fg);
92
94
  }
93
95
  [aria-checked='true'] {
96
+ color: var(--fg);
94
97
  background: var(--control-4);
98
+ box-shadow: var(--shadow-btn);
99
+ }
100
+ button + [aria-checked='true'] {
101
+ box-shadow:
102
+ inset 1px 0 0 var(--line),
103
+ var(--shadow-btn);
95
104
  }
96
105
  button :global(.icon) {
97
106
  flex: none;
@@ -78,12 +78,10 @@
78
78
  width: fit-content;
79
79
  max-width: 100%;
80
80
  padding: 2px;
81
- /* Sunken like a field (--sunken-*), so the raised thumb reads as sitting in a track. */
81
+ /* A clear track under a hairline, so only the raised thumb is filled and casts a shadow. */
82
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);
83
+ background: transparent;
84
+ box-shadow: inset 0 0 0 1px var(--line);
87
85
  /* The thumb sits at z-index -1 in here: under every segment's content, even while it slides across them. */
88
86
  isolation: isolate;
89
87
  }
@@ -108,7 +106,8 @@
108
106
  border: 0;
109
107
  border-radius: calc(var(--r) - 2px);
110
108
  background: none;
111
- color: var(--fg);
109
+ /* Unchosen options are dimmed until hovered; the chosen one is clear. */
110
+ color: var(--muted);
112
111
  font-size: 12px;
113
112
  line-height: 14px;
114
113
  font-weight: var(--w-medium);
@@ -120,7 +119,8 @@
120
119
  box-shadow var(--dur) var(--ease-out);
121
120
  }
122
121
  button:not([aria-checked='true']):hover {
123
- background: var(--control-3);
122
+ background: var(--control-2);
123
+ color: var(--fg);
124
124
  }
125
125
  [aria-checked='true'] {
126
126
  color: var(--fg);
@@ -132,8 +132,8 @@
132
132
  z-index: -1;
133
133
  border-radius: inherit;
134
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);
135
+ /* Filled like ButtonGroup's chosen option (--control-4) and raised (--shadow-btn), with a hairline for an edge. */
136
+ background: var(--control-4);
137
137
  box-shadow:
138
138
  inset 0 0 0 1px var(--line),
139
139
  var(--shadow-btn);
@@ -50,24 +50,30 @@
50
50
  border: 0;
51
51
  border-radius: var(--r-pill);
52
52
  padding: 0 10px;
53
- background: var(--control-2);
54
- box-shadow:
55
- inset 0 0 0 1px var(--line),
56
- var(--shadow-btn);
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);
57
56
  font-size: 12px;
58
57
  line-height: 14px;
59
58
  font-weight: var(--w-medium);
60
59
  cursor: pointer;
61
- color: var(--fg);
60
+ /* Unchosen options are dimmed until hovered; the chosen one is clear. */
61
+ color: var(--muted);
62
62
  transition:
63
63
  color var(--dur) var(--ease-out),
64
- background-color var(--dur) var(--ease-out);
64
+ background-color var(--dur) var(--ease-out),
65
+ box-shadow var(--dur) var(--ease-out);
65
66
  }
66
67
  button:not([aria-checked='true']):hover {
67
- background: var(--control-3);
68
+ background: var(--control-2);
69
+ color: var(--fg);
68
70
  }
69
71
  [aria-checked='true'] {
72
+ color: var(--fg);
70
73
  background: var(--control-4);
74
+ box-shadow:
75
+ inset 0 0 0 1px var(--line),
76
+ var(--shadow-btn);
71
77
  }
72
78
  /* Something finished behind this option (e.g. research done): its icon turns green. */
73
79
  [data-done] :global(.icon) {
@@ -584,6 +584,15 @@
584
584
  width: min(var(--dialog-width, 420px), calc(100% - var(--space-8)));
585
585
  }
586
586
 
587
+ /* On a phone a question sits at the bottom of the screen, within the thumb's reach, and the full width less the gutters. */
588
+ @media (max-width: 860px) {
589
+ .dialog.confirm {
590
+ width: calc(100% - var(--space-8));
591
+ max-height: calc(100dvh - var(--space-8));
592
+ margin: auto auto var(--space-4);
593
+ }
594
+ }
595
+
587
596
  /* Only `display` depends on [open]: it is held through the closing transition, so the layout can't change mid-fade. */
588
597
  .dialog[open] {
589
598
  display: flex;
@@ -595,6 +604,8 @@
595
604
  var(--grain) 0 0 / 256px 256px,
596
605
  var(--scrim);
597
606
  backdrop-filter: blur(2px);
607
+ -webkit-user-select: none;
608
+ user-select: none;
598
609
  }
599
610
 
600
611
  .dialog-head {
@@ -165,50 +165,50 @@
165
165
  --dur-enter: 120ms;
166
166
  --ease-exit: cubic-bezier(0.3, 0, 1, 1);
167
167
  --dur-exit: 80ms;
168
- /* Modal dialogs' own motion. Spring: a damped spring that overshoots by a fifth and settles back (the bounce a dialog
168
+ /* Modal dialogs' own motion. Spring: a damped spring that overshoots by about 8% and settles back (the bounce a dialog
169
169
  scales in with). Dip: sinks to a third of the way below the start by 30%, then accelerates to the end (the small
170
170
  drop before a dialog lifts away). Both are sampled curves, so they go past 0 and 1 where cubic-bezier() can't shape them. */
171
171
  --ease-spring: linear(
172
172
  0,
173
- 0.047,
174
- 0.167,
175
- 0.332,
176
- 0.515,
177
- 0.695,
178
- 0.857,
179
- 0.991,
180
- 1.092,
181
- 1.16,
182
- 1.196,
183
- 1.205,
184
- 1.194,
185
- 1.168,
186
- 1.134,
187
- 1.096,
188
- 1.059,
189
- 1.027,
190
- 1,
191
- 0.979,
192
- 0.966,
193
- 0.959,
194
- 0.958,
195
- 0.961,
196
- 0.966,
197
- 0.973,
198
- 0.981,
199
- 0.988,
200
- 0.995,
201
- 1.001,
202
- 1.005,
203
- 1.007,
204
- 1.008,
173
+ 0.049,
174
+ 0.168,
175
+ 0.322,
176
+ 0.485,
177
+ 0.639,
178
+ 0.773,
179
+ 0.881,
180
+ 0.963,
181
+ 1.021,
182
+ 1.056,
183
+ 1.075,
184
+ 1.08,
185
+ 1.076,
186
+ 1.066,
187
+ 1.054,
188
+ 1.041,
189
+ 1.029,
190
+ 1.018,
205
191
  1.009,
206
- 1.008,
207
- 1.007,
208
- 1.005,
209
- 1.004,
210
- 1.002,
192
+ 1.003,
193
+ 0.998,
194
+ 0.996,
195
+ 0.994,
196
+ 0.994,
197
+ 0.994,
198
+ 0.995,
199
+ 0.996,
200
+ 0.997,
201
+ 0.998,
202
+ 0.999,
203
+ 0.999,
204
+ 1.0,
205
+ 1.0,
206
+ 1.0,
207
+ 1.0,
211
208
  1.001,
209
+ 1.0,
210
+ 1.0,
211
+ 1.0,
212
212
  1
213
213
  );
214
214
  --dur-spring: 400ms;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xerios/design-system",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Linear-style design system for Svelte 5: theme tokens, global CSS and generic components",
5
5
  "keywords": [
6
6
  "svelte",
@@ -19,7 +19,8 @@
19
19
  "bugs": "https://github.com/Xerios/design-system/issues",
20
20
  "type": "module",
21
21
  "files": [
22
- "dist"
22
+ "dist",
23
+ "CHANGELOG.md"
23
24
  ],
24
25
  "sideEffects": [
25
26
  "./dist/fonts.js",