@poodle64/ui 2026.11.9 → 2026.11.11

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/README.md CHANGED
@@ -1076,15 +1076,30 @@ stays for a dense grid of data; a module's own records are a RecordList.
1076
1076
  | --- | --- |
1077
1077
  | `rows` | `RecordListRow`s: `id`, `title`, `note`, `image` (a thumbnail), `icon` (a row's own tile, for a tool), `flags` (what wants the viewer: the first a chip on line two with "+N more" naming the rest, every one on a phone). |
1078
1078
  | `columns` | The module's columns after the title, the Ledger's `ListColumn` shape plus `total`. List `title` to rename, resize or draw it with `cell`. `on: 'wide'` ticks a column only on a wide list (1200px of list), so extra width shows more columns and the viewer can tick it back. |
1079
- | `preferences`, `onPreferencesChange`, `preferencesNote` | The viewer's `{ columns }` from the Columns menu, which the bar carries while the list has heads. The list stores nothing. |
1079
+ | `preferences`, `onPreferencesChange`, `preferencesNote` | The viewer's `{ columns, group }` from the Columns menu, which the bar carries while the list has heads or offers groupings. Missing or stale fields take the module's defaults; `group` exists only where the list offers `groupings`. The list stores nothing. |
1080
1080
  | `title`, `meta`, `leading`, `toolbar`, `tools`, `action` | The `ListToolbar`. No title, no bar. |
1081
1081
  | `group` | A row's group label: groups show in the order their first rows come, each label on the ground with its count and each column's `total` over its rows. |
1082
+ | `groupings` | The ways the viewer may group, in place of `group`: `{ key, label, group, order, hint }`, offered in the Columns menu's Group by with None after the last, the first the default. `order: 'label'` lists the groups A to Z (numerals as numbers) rather than in the order their first rows come; `hint` says what it does under the choice. |
1082
1083
  | `totalLabel` | A card after the rows with each column's `total` over every row: "All three". |
1083
1084
  | `head` | `false` drops the head card (and the Columns menu): a tools list. |
1084
1085
  | `icon` | The quiet tile a row without a photo or its own `icon` shows; with it every row has a thumbnail. |
1085
1086
  | `href`, `onOpen`, `open` | A row is a link, or a button that opens a detail beside the list; `open` marks that row. A control in a `cell` takes its own click. |
1086
1087
  | `noun`, `empty`, `footer`, `layout` | As the Ledger's. |
1087
1088
 
1089
+ **The Columns menu is the one place a list is reshaped**, the same in the Ledger
1090
+ and the RecordList: the columns to tick, then Group by (the Ledger's periods, a
1091
+ RecordList's `groupings`), then Reset and where the choice is kept. Sort is the
1092
+ heads'; Find (search, filters, views) stays the module's.
1093
+
1094
+ ```svelte
1095
+ <RecordList rows={words} {columns} title="Words" bind:preferences
1096
+ groupings={[
1097
+ { key: 'letter', label: 'Letter', group: (r) => letterOf(r.title) },
1098
+ { key: 'becomes', label: 'Replacement', group: (r) => r.value, order: 'label',
1099
+ hint: 'Every word that becomes the same replacement, under it.' }
1100
+ ]} />
1101
+ ```
1102
+
1088
1103
  A sort orders rows inside their groups, largest first (words from A), then
1089
1104
  reversed, then the list's own order. On a phone (below 480px of list) a row is its thumbnail, title
1090
1105
  and lines, with the first end-aligned column's value beside the title. Measured
@@ -1,32 +1,45 @@
1
- <script lang="ts" generics="P extends { columns: string[]; period?: LedgerPeriod }">
1
+ <script lang="ts" generics="G extends string">
2
2
  /**
3
- * The viewer's Columns menu: every column the module offers as a tick (the
4
- * ledger's running balance one more, always last), then, where the list
5
- * groups by a period, the period. An icon button named by its tooltip.
6
- * The RecordList's menu is this one without the period.
3
+ * The list's Columns menu, the one place a viewer reshapes a list: every
4
+ * column it offers as a tick, then how its rows group, one choice a row as the ticks above are, so no label truncates or overlaps. A choice is named for what it groups by ("Letter"): the heading says "Group by". The Ledger's groups
5
+ * are periods (and its running balance one more column, always last); a
6
+ * RecordList's are the groupings its module offers. Sort is the heads'. An
7
+ * icon button named by its tooltip.
7
8
  */
8
9
  import Columns3 from '@lucide/svelte/icons/columns-3';
9
10
  import { Button, buttonVariants } from '../button/index.js';
10
11
  import { Checkbox } from '../checkbox/index.js';
11
12
  import * as Popover from '../popover/index.js';
12
- import { Segmented } from '../segmented/index.js';
13
+ import { RadioGroup } from 'bits-ui';
14
+ import Check from '@lucide/svelte/icons/check';
13
15
  import * as Tooltip from '../tooltip/index.js';
14
16
  import { cn } from '../../../utils.js';
15
- import { LEDGER_PERIODS } from './ledger.js';
16
- import type { LedgerPeriod } from './types.js';
17
17
 
18
18
  let {
19
19
  offered,
20
- preferences,
20
+ columns,
21
+ grouping,
22
+ name,
21
23
  note,
22
- onchange,
24
+ oncolumns,
23
25
  onreset,
24
26
  owner = 'ledger'
25
27
  }: {
28
+ /** The columns to tick; none, and the menu holds only the grouping. */
26
29
  offered: { key: string; label: string; locked: boolean }[];
27
- preferences: P;
30
+ /** The ticked columns' keys. */
31
+ columns: string[];
32
+ /** How the rows group: the choices, the one in force, and what it does. */
33
+ grouping?: {
34
+ options: readonly { value: G; label: string }[];
35
+ value: G;
36
+ hint?: string;
37
+ onchange: (value: G) => void;
38
+ };
39
+ /** The trigger's tooltip and accessible name. */
40
+ name: string;
28
41
  note?: string;
29
- onchange: (next: P) => void;
42
+ oncolumns: (columns: string[]) => void;
30
43
  onreset: () => void;
31
44
  /** The `data-slot` prefix: the list that owns the menu. */
32
45
  owner?: string;
@@ -34,26 +47,19 @@
34
47
 
35
48
  let open = $state(false);
36
49
 
37
- const HINT: Record<LedgerPeriod, string> = {
38
- fy: 'Each financial year sits under its own header, which opens and closes.',
39
- cy: 'Each calendar year sits under its own header, which opens and closes.',
40
- month: 'Each month sits under its own header, which opens and closes.',
41
- week: 'Each week sits under its own header, which opens and closes.',
42
- day: 'The date heads each day’s rows, so the Date column goes.',
43
- none: 'One list, newest first, under the column head.'
44
- };
45
-
46
50
  function tick(key: string, on: boolean) {
47
- const next = on ? [...preferences.columns, key] : preferences.columns.filter((k) => k !== key);
48
- onchange({
49
- ...preferences,
50
- columns: offered.map((c) => c.key).filter((k) => next.includes(k))
51
- });
51
+ const next = on ? [...columns, key] : columns.filter((k) => k !== key);
52
+ oncolumns(offered.map((c) => c.key).filter((k) => next.includes(k)));
52
53
  }
53
54
 
54
55
  const eyebrow = 'text-muted-foreground text-2xs tracking-eyebrow font-semibold uppercase';
55
- /** The ledger's menu also holds its running balance and its grouping. */
56
- const name = $derived(preferences.period ? 'Columns, balance and grouping' : 'Columns');
56
+ // The heading says "Group by", so a choice that repeats it reads twice.
57
+ $effect(() => {
58
+ if (grouping?.options.some((o) => /^group by\b/i.test(o.label)))
59
+ console.warn(
60
+ 'Columns menu: grouping labels sit under a "Group by" heading; name the grouping ("Letter"), not "Group by letter".'
61
+ );
62
+ });
57
63
  </script>
58
64
 
59
65
  <Popover.Root bind:open>
@@ -75,36 +81,53 @@
75
81
  </Tooltip.Root>
76
82
  </Tooltip.Provider>
77
83
  <Popover.Content align="end" class="w-80 p-0" data-slot="{owner}-columns">
78
- <div class="flex flex-col px-2 pt-2.5 pb-2">
79
- <span class={cn(eyebrow, 'px-1.5 pb-1.5')}>Columns</span>
80
- {#each offered as c (c.key)}
81
- {@const on = c.locked || preferences.columns.includes(c.key)}
82
- <label
83
- class={cn(
84
- 'flex min-h-8 items-center gap-2.5 rounded-md px-1.5 text-sm',
85
- c.locked ? 'text-muted-foreground' : 'hover:bg-accent/50 cursor-pointer'
86
- )}
87
- >
88
- <Checkbox
89
- checked={on}
90
- disabled={c.locked}
91
- onCheckedChange={(v) => tick(c.key, v === true)}
92
- />
93
- <span class="min-w-0 flex-1">{c.label}</span>
94
- {#if c.locked}<span class="text-xs">Always shown</span>{/if}
95
- </label>
96
- {/each}
97
- </div>
98
- {#if preferences.period}
99
- <div class="border-border flex flex-col gap-2 border-t px-3.5 pt-2.5 pb-3">
84
+ {#if offered.length}
85
+ <div class="flex flex-col px-2 pt-2.5 pb-2">
86
+ <span class={cn(eyebrow, 'px-1.5 pb-1.5')}>Columns</span>
87
+ {#each offered as c (c.key)}
88
+ {@const on = c.locked || columns.includes(c.key)}
89
+ <label
90
+ class={cn(
91
+ 'flex min-h-8 items-center gap-2.5 rounded-md px-1.5 text-sm',
92
+ c.locked ? 'text-muted-foreground' : 'hover:bg-accent/50 cursor-pointer'
93
+ )}
94
+ >
95
+ <Checkbox
96
+ checked={on}
97
+ disabled={c.locked}
98
+ onCheckedChange={(v) => tick(c.key, v === true)}
99
+ />
100
+ <span class="min-w-0 flex-1">{c.label}</span>
101
+ {#if c.locked}<span class="text-xs">Always shown</span>{/if}
102
+ </label>
103
+ {/each}
104
+ </div>
105
+ {/if}
106
+ {#if grouping}
107
+ {@const g = grouping}
108
+ <div
109
+ class={cn('flex flex-col gap-2 px-3.5 pt-2.5 pb-3', offered.length && 'border-border border-t')}
110
+ data-slot="{owner}-grouping"
111
+ >
100
112
  <span class={eyebrow}>Group by</span>
101
- <Segmented
102
- label="Group by"
103
- options={LEDGER_PERIODS}
104
- bind:value={() => preferences.period!, (period) => onchange({ ...preferences, period })}
105
- class="grid w-full grid-cols-2"
106
- />
107
- <span class="text-muted-foreground text-xs">{HINT[preferences.period]}</span>
113
+ <RadioGroup.Root
114
+ aria-label="Group by"
115
+ class="-mx-1.5 flex flex-col"
116
+ bind:value={() => g.value, (value) => g.onchange(value as G)}
117
+ >
118
+ {#each g.options as o (o.value)}
119
+ <RadioGroup.Item
120
+ value={o.value}
121
+ class="hover:bg-accent/50 data-[state=checked]:text-foreground text-muted-foreground flex min-h-8 cursor-pointer items-center gap-2.5 rounded-md px-1.5 py-1 text-left text-sm break-words data-[state=checked]:font-medium"
122
+ >
123
+ <span class="flex size-4 shrink-0 items-center justify-center">
124
+ {#if g.value === o.value}<Check class="size-4" />{/if}
125
+ </span>
126
+ <span class="min-w-0 flex-1">{o.label}</span>
127
+ </RadioGroup.Item>
128
+ {/each}
129
+ </RadioGroup.Root>
130
+ {#if g.hint}<span class="text-muted-foreground text-xs">{g.hint}</span>{/if}
108
131
  </div>
109
132
  {/if}
110
133
  <div class="bg-surface-2 border-border flex items-center gap-2 border-t py-2 pr-2 pl-3.5">
@@ -1,17 +1,27 @@
1
- import type { LedgerPeriod } from './types.js';
2
- declare function $$render<P extends {
3
- columns: string[];
4
- period?: LedgerPeriod;
5
- }>(): {
1
+ declare function $$render<G extends string>(): {
6
2
  props: {
3
+ /** The columns to tick; none, and the menu holds only the grouping. */
7
4
  offered: {
8
5
  key: string;
9
6
  label: string;
10
7
  locked: boolean;
11
8
  }[];
12
- preferences: P;
9
+ /** The ticked columns' keys. */
10
+ columns: string[];
11
+ /** How the rows group: the choices, the one in force, and what it does. */
12
+ grouping?: {
13
+ options: readonly {
14
+ value: G;
15
+ label: string;
16
+ }[];
17
+ value: G;
18
+ hint?: string;
19
+ onchange: (value: G) => void;
20
+ };
21
+ /** The trigger's tooltip and accessible name. */
22
+ name: string;
13
23
  note?: string;
14
- onchange: (next: P) => void;
24
+ oncolumns: (columns: string[]) => void;
15
25
  onreset: () => void;
16
26
  /** The `data-slot` prefix: the list that owns the menu. */
17
27
  owner?: string;
@@ -21,32 +31,20 @@ declare function $$render<P extends {
21
31
  slots: {};
22
32
  events: {};
23
33
  };
24
- declare class __sveltets_Render<P extends {
25
- columns: string[];
26
- period?: LedgerPeriod;
27
- }> {
28
- props(): ReturnType<typeof $$render<P>>['props'];
29
- events(): ReturnType<typeof $$render<P>>['events'];
30
- slots(): ReturnType<typeof $$render<P>>['slots'];
34
+ declare class __sveltets_Render<G extends string> {
35
+ props(): ReturnType<typeof $$render<G>>['props'];
36
+ events(): ReturnType<typeof $$render<G>>['events'];
37
+ slots(): ReturnType<typeof $$render<G>>['slots'];
31
38
  bindings(): "";
32
39
  exports(): {};
33
40
  }
34
41
  interface $$IsomorphicComponent {
35
- new <P extends {
36
- columns: string[];
37
- period?: LedgerPeriod;
38
- }>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<P>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<P>['props']>, ReturnType<__sveltets_Render<P>['events']>, ReturnType<__sveltets_Render<P>['slots']>> & {
39
- $$bindings?: ReturnType<__sveltets_Render<P>['bindings']>;
40
- } & ReturnType<__sveltets_Render<P>['exports']>;
41
- <P extends {
42
- columns: string[];
43
- period?: LedgerPeriod;
44
- }>(internal: unknown, props: ReturnType<__sveltets_Render<P>['props']> & {}): ReturnType<__sveltets_Render<P>['exports']>;
42
+ new <G extends string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<G>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<G>['props']>, ReturnType<__sveltets_Render<G>['events']>, ReturnType<__sveltets_Render<G>['slots']>> & {
43
+ $$bindings?: ReturnType<__sveltets_Render<G>['bindings']>;
44
+ } & ReturnType<__sveltets_Render<G>['exports']>;
45
+ <G extends string>(internal: unknown, props: ReturnType<__sveltets_Render<G>['props']> & {}): ReturnType<__sveltets_Render<G>['exports']>;
45
46
  z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
46
47
  }
47
48
  declare const LedgerColumns: $$IsomorphicComponent;
48
- type LedgerColumns<P extends {
49
- columns: string[];
50
- period?: LedgerPeriod;
51
- }> = InstanceType<typeof LedgerColumns<P>>;
49
+ type LedgerColumns<G extends string> = InstanceType<typeof LedgerColumns<G>>;
52
50
  export default LedgerColumns;
@@ -61,7 +61,13 @@
61
61
  windowOf
62
62
  } from './ledger.js';
63
63
  import type { LedgerDateFormat } from './ledger.js';
64
- import type { LedgerColumn, LedgerOpenContext, LedgerPreferences, LedgerRow } from './types.js';
64
+ import type {
65
+ LedgerColumn,
66
+ LedgerOpenContext,
67
+ LedgerPeriod,
68
+ LedgerPreferences,
69
+ LedgerRow
70
+ } from './types.js';
65
71
 
66
72
  type Id = R['id'];
67
73
 
@@ -215,6 +221,14 @@
215
221
  preferences = next;
216
222
  onPreferencesChange?.(next);
217
223
  }
224
+ const PERIOD_HINT: Record<LedgerPeriod, string> = {
225
+ fy: 'Each financial year sits under its own header, which opens and closes.',
226
+ cy: 'Each calendar year sits under its own header, which opens and closes.',
227
+ month: 'Each month sits under its own header, which opens and closes.',
228
+ week: 'Each week sits under its own header, which opens and closes.',
229
+ day: 'The date heads each day’s rows, so the Date column goes.',
230
+ none: 'One list, newest first, under the column head.'
231
+ };
218
232
 
219
233
  // ── Layout ──
220
234
  let width = $state(0);
@@ -872,9 +886,16 @@
872
886
  >
873
887
  <LedgerColumns
874
888
  offered={resolved.map((c) => ({ key: c.key, label: c.label, locked: c.locked }))}
875
- preferences={prefs}
889
+ columns={prefs.columns}
890
+ grouping={{
891
+ options: LEDGER_PERIODS,
892
+ value: prefs.period,
893
+ hint: PERIOD_HINT[prefs.period],
894
+ onchange: (period) => setPreferences({ ...prefs, period })
895
+ }}
896
+ name="Columns, balance and grouping"
876
897
  note={preferencesNote}
877
- onchange={setPreferences}
898
+ oncolumns={(columns) => setPreferences({ ...prefs, columns })}
878
899
  onreset={() => setPreferences(defaults)}
879
900
  />
880
901
  {@render actions?.()}
@@ -1,3 +1,3 @@
1
1
  export { default as RecordList } from './record-list.svelte';
2
2
  export { default } from './record-list.svelte';
3
- export type { RecordFlag, RecordListColumn, RecordListPreferences, RecordListRow } from './types.js';
3
+ export type { RecordFlag, RecordListColumn, RecordListGrouping, RecordListPreferences, RecordListRow } from './types.js';
@@ -11,6 +11,10 @@
11
11
  * then the module's columns. It opens by its link (`href`) or by `onOpen`,
12
12
  * which marks the row `open` names, for a detail beside the list.
13
13
  *
14
+ * The module groups the rows one way (`group`), or offers the viewer ways
15
+ * to (`groupings`), chosen in the Columns menu beside the columns, as the
16
+ * Ledger's periods are.
17
+ *
14
18
  * It fills its parent's height and scrolls its own rows, so the head card
15
19
  * stays at the top: give it a bounded parent (`flex-1 min-h-0`). Width picks
16
20
  * the layout, as the Ledger's does: a phone's list below 480px, the wide
@@ -46,7 +50,12 @@
46
50
  import type { IconComponent } from '../app-shell/types.js';
47
51
  import Thumbnail from './thumbnail.svelte';
48
52
  import { cn } from '../../../utils.js';
49
- import type { RecordListColumn, RecordListPreferences, RecordListRow } from './types.js';
53
+ import type {
54
+ RecordListColumn,
55
+ RecordListGrouping,
56
+ RecordListPreferences,
57
+ RecordListRow
58
+ } from './types.js';
50
59
 
51
60
  type Id = R['id'];
52
61
 
@@ -64,6 +73,7 @@
64
73
  tools = [],
65
74
  action,
66
75
  group,
76
+ groupings = [],
67
77
  totalLabel,
68
78
  head = true,
69
79
  icon,
@@ -79,7 +89,7 @@
79
89
  rows: readonly R[];
80
90
  /** The module's columns, in order after the title. See `RecordListColumn`. */
81
91
  columns?: RecordListColumn<R>[];
82
- /** The viewer's columns. Missing, the module's defaults. */
92
+ /** The viewer's columns and grouping. Missing, the module's defaults. */
83
93
  preferences?: Partial<RecordListPreferences>;
84
94
  onPreferencesChange?: (next: RecordListPreferences) => void;
85
95
  /** The Columns menu's footnote: where the choice is kept. */
@@ -99,6 +109,11 @@
99
109
  action?: ListAction;
100
110
  /** A row's group, by its label: groups show in the order their first rows come. */
101
111
  group?: (row: R) => string;
112
+ /**
113
+ * The ways the viewer can group, in the Columns menu with None after
114
+ * them; the first is the default. In place of `group`.
115
+ */
116
+ groupings?: RecordListGrouping<R>[];
102
117
  /** Names a card after the rows with each column's total over every row: "All three". */
103
118
  totalLabel?: string;
104
119
  /** The head card. A list whose columns need no heads drops it. */
@@ -152,20 +167,43 @@
152
167
  const WIDE = $derived(mode === 'wide');
153
168
  const PHONE = $derived(mode === 'phone');
154
169
 
170
+ const NONE = 'none';
155
171
  const defaults = $derived<RecordListPreferences>({
156
172
  columns: resolved
157
173
  .filter((c) => !c.locked && (c.on === true || (c.on === 'wide' && WIDE)))
158
- .map((c) => c.key)
174
+ .map((c) => c.key),
175
+ ...(groupings[0] ? { group: groupings[0].key } : {})
159
176
  });
160
- const prefs = $derived<RecordListPreferences>({
161
- columns: preferences?.columns ?? defaults.columns
177
+ /** What the consumer kept, read field by field: a stale or foreign key falls back. */
178
+ const prefs = $derived.by<RecordListPreferences>(() => {
179
+ const columns = preferences?.columns ?? defaults.columns;
180
+ if (!groupings.length) return { columns };
181
+ const kept = preferences?.group;
182
+ const known = kept === NONE || groupings.some((g) => g.key === kept);
183
+ return { columns, group: known && kept ? kept : defaults.group };
162
184
  });
163
185
  function setPreferences(next: RecordListPreferences) {
164
186
  preferences = next;
165
187
  onPreferencesChange?.(next);
166
188
  }
167
- /** The Columns menu, in the bar, when the heads name a column the viewer can choose. */
189
+ /** The grouping in force: the viewer's, else the module's one way. */
190
+ const grouping = $derived<Pick<RecordListGrouping<R>, 'group' | 'order'> | undefined>(
191
+ groupings.length ? groupings.find((g) => g.key === prefs.group) : group && { group }
192
+ );
193
+ /** Columns to tick, while the heads name a column the viewer can choose. */
168
194
  const choosable = $derived(head && resolved.some((c) => !c.locked));
195
+ const menuName = $derived(
196
+ groupings.length ? (choosable ? 'Columns and grouping' : 'Grouping') : 'Columns'
197
+ );
198
+ const groupingOptions = $derived([
199
+ ...groupings.map((g) => ({ value: g.key, label: g.label })),
200
+ { value: NONE, label: 'None' }
201
+ ]);
202
+ const groupingHint = $derived(
203
+ prefs.group === NONE
204
+ ? 'One list, without groups.'
205
+ : groupings.find((g) => g.key === prefs.group)?.hint
206
+ );
169
207
 
170
208
  const shown = $derived(resolved.filter((c) => c.locked || prefs.columns.includes(c.key)));
171
209
  const template = $derived(shown.map((c) => (WIDE ? c.track.wide : c.track.narrow)).join(' '));
@@ -199,15 +237,22 @@
199
237
  return sort && col && sorter(col) ? sort : null;
200
238
  });
201
239
 
202
- // ── Groups, in the order their first rows come; a sort orders rows inside them ──
240
+ // ── Groups, in the order their first rows come or by label; a sort orders rows inside them ──
203
241
  const groups = $derived.by(() => {
204
242
  const out: { key: string; rows: R[] }[] = [];
243
+ const byKey = new Map<string, R[]>();
205
244
  for (const r of rows) {
206
- const key = group ? group(r) : '';
207
- const g = out.find((x) => x.key === key);
208
- if (g) g.rows.push(r);
209
- else out.push({ key, rows: [r] });
245
+ const key = grouping ? grouping.group(r) : '';
246
+ const g = byKey.get(key);
247
+ if (g) g.push(r);
248
+ else {
249
+ const fresh = [r];
250
+ byKey.set(key, fresh);
251
+ out.push({ key, rows: fresh });
252
+ }
210
253
  }
254
+ if (grouping?.order === 'label')
255
+ out.sort((a, b) => a.key.localeCompare(b.key, undefined, { numeric: true, sensitivity: 'base' }));
211
256
  const col = activeSort && shown.find((c) => c.key === activeSort.key);
212
257
  const by = col && sorter(col);
213
258
  return by ? out.map((g) => ({ key: g.key, rows: orderBy(g.rows, by, activeSort!.dir) })) : out;
@@ -381,12 +426,23 @@
381
426
  {action}
382
427
  style="padding-right: {edge};"
383
428
  >
384
- {#if choosable}
429
+ {#if choosable || groupings.length}
385
430
  <LedgerColumns
386
- offered={resolved.map((c) => ({ key: c.key, label: c.label, locked: c.locked }))}
387
- preferences={prefs}
431
+ offered={choosable
432
+ ? resolved.map((c) => ({ key: c.key, label: c.label, locked: c.locked }))
433
+ : []}
434
+ columns={prefs.columns}
435
+ grouping={groupings.length
436
+ ? {
437
+ options: groupingOptions,
438
+ value: prefs.group ?? NONE,
439
+ hint: groupingHint,
440
+ onchange: (group) => setPreferences({ ...prefs, group })
441
+ }
442
+ : undefined}
443
+ name={menuName}
388
444
  note={preferencesNote}
389
- onchange={setPreferences}
445
+ oncolumns={(columns) => setPreferences({ ...prefs, columns })}
390
446
  onreset={() => setPreferences(defaults)}
391
447
  owner="record"
392
448
  />
@@ -427,7 +483,7 @@
427
483
  {#if empty}{@render empty()}{:else}<EmptyState title="No {noun[1]}" />{/if}
428
484
  {:else}
429
485
  {#each groups as g, gi (g.key)}
430
- {#if group}
486
+ {#if grouping}
431
487
  <div class={groupSpacing(gi)}>
432
488
  <div
433
489
  class={cn(GROUP, PHONE ? 'flex items-center gap-2 px-0.5' : 'grid items-center')}
@@ -10,6 +10,10 @@
10
10
  * then the module's columns. It opens by its link (`href`) or by `onOpen`,
11
11
  * which marks the row `open` names, for a detail beside the list.
12
12
  *
13
+ * The module groups the rows one way (`group`), or offers the viewer ways
14
+ * to (`groupings`), chosen in the Columns menu beside the columns, as the
15
+ * Ledger's periods are.
16
+ *
13
17
  * It fills its parent's height and scrolls its own rows, so the head card
14
18
  * stays at the top: give it a bounded parent (`flex-1 min-h-0`). Width picks
15
19
  * the layout, as the Ledger's does: a phone's list below 480px, the wide
@@ -21,13 +25,13 @@ import type { Snippet } from 'svelte';
21
25
  import type { HTMLAttributes } from 'svelte/elements';
22
26
  import type { ListAction, ListIconAction } from '../list-toolbar/types.js';
23
27
  import type { IconComponent } from '../app-shell/types.js';
24
- import type { RecordListColumn, RecordListPreferences, RecordListRow } from './types.js';
28
+ import type { RecordListColumn, RecordListGrouping, RecordListPreferences, RecordListRow } from './types.js';
25
29
  declare function $$render<R extends RecordListRow>(): {
26
30
  props: Omit<HTMLAttributes<HTMLDivElement>, "title"> & {
27
31
  rows: readonly R[];
28
32
  /** The module's columns, in order after the title. See `RecordListColumn`. */
29
33
  columns?: RecordListColumn<R>[];
30
- /** The viewer's columns. Missing, the module's defaults. */
34
+ /** The viewer's columns and grouping. Missing, the module's defaults. */
31
35
  preferences?: Partial<RecordListPreferences>;
32
36
  onPreferencesChange?: (next: RecordListPreferences) => void;
33
37
  /** The Columns menu's footnote: where the choice is kept. */
@@ -47,6 +51,11 @@ declare function $$render<R extends RecordListRow>(): {
47
51
  action?: ListAction;
48
52
  /** A row's group, by its label: groups show in the order their first rows come. */
49
53
  group?: (row: R) => string;
54
+ /**
55
+ * The ways the viewer can group, in the Columns menu with None after
56
+ * them; the first is the default. In place of `group`.
57
+ */
58
+ groupings?: RecordListGrouping<R>[];
50
59
  /** Names a card after the rows with each column's total over every row: "All three". */
51
60
  totalLabel?: string;
52
61
  /** The head card. A list whose columns need no heads drops it. */
@@ -33,8 +33,30 @@ export interface RecordListColumn<R extends RecordListRow = RecordListRow> exten
33
33
  /** The column's total over some rows: each group's on its label, all rows' in the total card. */
34
34
  total?: (rows: readonly R[]) => string;
35
35
  }
36
+ /**
37
+ * A way the viewer can group the list, offered in its Columns menu with None
38
+ * after the last: the first letter, a status, every word that becomes the same
39
+ * replacement.
40
+ */
41
+ export interface RecordListGrouping<R extends RecordListRow = RecordListRow> {
42
+ /** What the viewer's choice keeps. `none` is the list's own and never a grouping's. */
43
+ key: string;
44
+ /** Its name in the menu. */
45
+ label: string;
46
+ /** A row's group, by its label. */
47
+ group: (row: R) => string;
48
+ /**
49
+ * The groups' order: `rows`, the order their first rows come (the
50
+ * default); `label`, A to Z by label, numerals as numbers.
51
+ */
52
+ order?: 'rows' | 'label';
53
+ /** Under the menu's choice: what the grouping does. */
54
+ hint?: string;
55
+ }
36
56
  /** The viewer's own choices, which the consumer persists. */
37
57
  export interface RecordListPreferences {
38
58
  /** The ticked columns' keys. */
39
59
  columns: string[];
60
+ /** The chosen grouping's key, or `none`; only on a list that offers groupings. */
61
+ group?: string;
40
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poodle64/ui",
3
- "version": "2026.11.9",
3
+ "version": "2026.11.11",
4
4
  "description": "Household shared component layer: shadcn-svelte primitives (bits-ui) plus the composed page chrome every app builds its routes from, restyled by each app's @poodle64/design-tokens alias layer. One fix reaches every app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "package": "@poodle64/ui",
4
- "version": "2026.11.9",
4
+ "version": "2026.11.11",
5
5
  "generatedBy": "scripts/generate-registry.mjs",
6
6
  "source": "scripts/situations.json + package source (DO NOT EDIT the outputs by hand)",
7
7
  "componentCount": 76,
@@ -143,7 +143,7 @@
143
143
  "name": "RecordList",
144
144
  "dir": "record-list",
145
145
  "import": "@poodle64/ui/record-list",
146
- "props": "rows, columns?, preferences?, onPreferencesChange?, title?, tools?, action?, group?, totalLabel?, icon?, href?, onOpen?, open?",
146
+ "props": "rows, columns?, preferences?, onPreferencesChange?, title?, tools?, action?, group?, groupings?, totalLabel?, icon?, href?, onOpen?, open?",
147
147
  "insteadOf": "a DataTableTanstack, or a boxed Table, for a module's own records (properties, managers, tools, a P&L's lines): the ledger's look (head card, row cards, group labels on the ground) for rows that are not money, so every list in an app reads one way"
148
148
  },
149
149
  {
@@ -1,7 +1,7 @@
1
1
  # @poodle64/ui — situation → component map
2
2
 
3
3
  <!-- GENERATED by scripts/generate-registry.mjs from scripts/situations.json + package source. DO NOT EDIT. -->
4
- Generated from `@poodle64/ui@2026.11.9`. 76 components, 20 situations.
4
+ Generated from `@poodle64/ui@2026.11.11`. 76 components, 20 situations.
5
5
 
6
6
  **Read this before writing a `<div>`.** Find the SITUATION you are in below, then compose the component named for it — do not hand-build it from raw `Card` or utility classes. Import is `import { Name } from '<import path>'`. Props marked `?` are optional. This map is the retrieval step the [`design-frontend` skill] makes mandatory; the [CHI 2026 study] measured composing-from-a-registry at 95% design-system compliance against 71% for writing the CSS from a prose style guide.
7
7
 
@@ -80,7 +80,7 @@ _An index of many peer items — a responsive tile wall, or a sortable/filterabl
80
80
 
81
81
  | Component | Import | Key props | Reach for it instead of |
82
82
  | --- | --- | --- | --- |
83
- | `RecordList` | `@poodle64/ui/record-list` | `rows, columns?, preferences?, onPreferencesChange?, title?, tools?, action?, group?, totalLabel?, icon?, href?, onOpen?, open?` | a DataTableTanstack, or a boxed Table, for a module's own records (properties, managers, tools, a P&L's lines): the ledger's look (head card, row cards, group labels on the ground) for rows that are not money, so every list in an app reads one way |
83
+ | `RecordList` | `@poodle64/ui/record-list` | `rows, columns?, preferences?, onPreferencesChange?, title?, tools?, action?, group?, groupings?, totalLabel?, icon?, href?, onOpen?, open?` | a DataTableTanstack, or a boxed Table, for a module's own records (properties, managers, tools, a P&L's lines): the ledger's look (head card, row cards, group labels on the ground) for rows that are not money, so every list in an app reads one way |
84
84
  | `ListToolbar` | `@poodle64/ui/list-toolbar` | `title?, meta?, leading?, children?, tools?, action?` | a hand-built title, count and button row above a list; the Ledger and the RecordList draw theirs with it |
85
85
  | `TileGrid` | `@poodle64/ui/tile-grid` | `children, min?, gap?, tag?` | a grid with fixed sm:grid-cols-* breakpoints you maintain per page |
86
86
  | `DataTableTanstack` | `@poodle64/ui/data-table-tanstack` | `table, selectable?, selectedId?, onSelect?, emptyMessage?` | a hand-built <table>, or the raw Table primitive wired to TanStack by hand |