@poodle64/ui 2026.11.9 → 2026.11.10
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 +16 -1
- package/dist/components/ui/ledger/ledger-columns.svelte +60 -54
- package/dist/components/ui/ledger/ledger-columns.svelte.d.ts +24 -28
- package/dist/components/ui/ledger/ledger.svelte +24 -3
- package/dist/components/ui/record-list/index.d.ts +1 -1
- package/dist/components/ui/record-list/record-list.svelte +72 -16
- package/dist/components/ui/record-list/record-list.svelte.d.ts +11 -2
- package/dist/components/ui/record-list/types.d.ts +22 -0
- package/package.json +1 -1
- package/registry/component-map.json +2 -2
- package/registry/component-map.md +2 -2
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,44 @@
|
|
|
1
|
-
<script lang="ts" generics="
|
|
1
|
+
<script lang="ts" generics="G extends string">
|
|
2
2
|
/**
|
|
3
|
-
* The
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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. 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 { Segmented, type SegmentedOption } from '../segmented/index.js';
|
|
13
14
|
import * as Tooltip from '../tooltip/index.js';
|
|
14
15
|
import { cn } from '../../../utils.js';
|
|
15
|
-
import { LEDGER_PERIODS } from './ledger.js';
|
|
16
|
-
import type { LedgerPeriod } from './types.js';
|
|
17
16
|
|
|
18
17
|
let {
|
|
19
18
|
offered,
|
|
20
|
-
|
|
19
|
+
columns,
|
|
20
|
+
grouping,
|
|
21
|
+
name,
|
|
21
22
|
note,
|
|
22
|
-
|
|
23
|
+
oncolumns,
|
|
23
24
|
onreset,
|
|
24
25
|
owner = 'ledger'
|
|
25
26
|
}: {
|
|
27
|
+
/** The columns to tick; none, and the menu holds only the grouping. */
|
|
26
28
|
offered: { key: string; label: string; locked: boolean }[];
|
|
27
|
-
|
|
29
|
+
/** The ticked columns' keys. */
|
|
30
|
+
columns: string[];
|
|
31
|
+
/** How the rows group: the choices, the one in force, and what it does. */
|
|
32
|
+
grouping?: {
|
|
33
|
+
options: readonly SegmentedOption<G>[];
|
|
34
|
+
value: G;
|
|
35
|
+
hint?: string;
|
|
36
|
+
onchange: (value: G) => void;
|
|
37
|
+
};
|
|
38
|
+
/** The trigger's tooltip and accessible name. */
|
|
39
|
+
name: string;
|
|
28
40
|
note?: string;
|
|
29
|
-
|
|
41
|
+
oncolumns: (columns: string[]) => void;
|
|
30
42
|
onreset: () => void;
|
|
31
43
|
/** The `data-slot` prefix: the list that owns the menu. */
|
|
32
44
|
owner?: string;
|
|
@@ -34,26 +46,14 @@
|
|
|
34
46
|
|
|
35
47
|
let open = $state(false);
|
|
36
48
|
|
|
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
49
|
function tick(key: string, on: boolean) {
|
|
47
|
-
const next = on ? [...
|
|
48
|
-
|
|
49
|
-
...preferences,
|
|
50
|
-
columns: offered.map((c) => c.key).filter((k) => next.includes(k))
|
|
51
|
-
});
|
|
50
|
+
const next = on ? [...columns, key] : columns.filter((k) => k !== key);
|
|
51
|
+
oncolumns(offered.map((c) => c.key).filter((k) => next.includes(k)));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const eyebrow = 'text-muted-foreground text-2xs tracking-eyebrow font-semibold uppercase';
|
|
55
|
-
/**
|
|
56
|
-
const
|
|
55
|
+
/** Two to a row past three choices, so a label never truncates in the menu's width. */
|
|
56
|
+
const COLS = ['grid-cols-1', 'grid-cols-2', 'grid-cols-3'];
|
|
57
57
|
</script>
|
|
58
58
|
|
|
59
59
|
<Popover.Root bind:open>
|
|
@@ -75,36 +75,42 @@
|
|
|
75
75
|
</Tooltip.Root>
|
|
76
76
|
</Tooltip.Provider>
|
|
77
77
|
<Popover.Content align="end" class="w-80 p-0" data-slot="{owner}-columns">
|
|
78
|
-
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
78
|
+
{#if offered.length}
|
|
79
|
+
<div class="flex flex-col px-2 pt-2.5 pb-2">
|
|
80
|
+
<span class={cn(eyebrow, 'px-1.5 pb-1.5')}>Columns</span>
|
|
81
|
+
{#each offered as c (c.key)}
|
|
82
|
+
{@const on = c.locked || columns.includes(c.key)}
|
|
83
|
+
<label
|
|
84
|
+
class={cn(
|
|
85
|
+
'flex min-h-8 items-center gap-2.5 rounded-md px-1.5 text-sm',
|
|
86
|
+
c.locked ? 'text-muted-foreground' : 'hover:bg-accent/50 cursor-pointer'
|
|
87
|
+
)}
|
|
88
|
+
>
|
|
89
|
+
<Checkbox
|
|
90
|
+
checked={on}
|
|
91
|
+
disabled={c.locked}
|
|
92
|
+
onCheckedChange={(v) => tick(c.key, v === true)}
|
|
93
|
+
/>
|
|
94
|
+
<span class="min-w-0 flex-1">{c.label}</span>
|
|
95
|
+
{#if c.locked}<span class="text-xs">Always shown</span>{/if}
|
|
96
|
+
</label>
|
|
97
|
+
{/each}
|
|
98
|
+
</div>
|
|
99
|
+
{/if}
|
|
100
|
+
{#if grouping}
|
|
101
|
+
{@const g = grouping}
|
|
102
|
+
<div
|
|
103
|
+
class={cn('flex flex-col gap-2 px-3.5 pt-2.5 pb-3', offered.length && 'border-border border-t')}
|
|
104
|
+
data-slot="{owner}-grouping"
|
|
105
|
+
>
|
|
100
106
|
<span class={eyebrow}>Group by</span>
|
|
101
107
|
<Segmented
|
|
102
108
|
label="Group by"
|
|
103
|
-
options={
|
|
104
|
-
bind:value={() =>
|
|
105
|
-
class=
|
|
109
|
+
options={g.options}
|
|
110
|
+
bind:value={() => g.value, (value) => g.onchange(value)}
|
|
111
|
+
class={cn('grid w-full', COLS[g.options.length - 1] ?? 'grid-cols-2')}
|
|
106
112
|
/>
|
|
107
|
-
<span class="text-muted-foreground text-xs">{
|
|
113
|
+
{#if g.hint}<span class="text-muted-foreground text-xs">{g.hint}</span>{/if}
|
|
108
114
|
</div>
|
|
109
115
|
{/if}
|
|
110
116
|
<div class="bg-surface-2 border-border flex items-center gap-2 border-t py-2 pr-2 pl-3.5">
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import type
|
|
2
|
-
declare function $$render<
|
|
3
|
-
columns: string[];
|
|
4
|
-
period?: LedgerPeriod;
|
|
5
|
-
}>(): {
|
|
1
|
+
import { type SegmentedOption } from '../segmented/index.js';
|
|
2
|
+
declare function $$render<G extends string>(): {
|
|
6
3
|
props: {
|
|
4
|
+
/** The columns to tick; none, and the menu holds only the grouping. */
|
|
7
5
|
offered: {
|
|
8
6
|
key: string;
|
|
9
7
|
label: string;
|
|
10
8
|
locked: boolean;
|
|
11
9
|
}[];
|
|
12
|
-
|
|
10
|
+
/** The ticked columns' keys. */
|
|
11
|
+
columns: string[];
|
|
12
|
+
/** How the rows group: the choices, the one in force, and what it does. */
|
|
13
|
+
grouping?: {
|
|
14
|
+
options: readonly SegmentedOption<G>[];
|
|
15
|
+
value: G;
|
|
16
|
+
hint?: string;
|
|
17
|
+
onchange: (value: G) => void;
|
|
18
|
+
};
|
|
19
|
+
/** The trigger's tooltip and accessible name. */
|
|
20
|
+
name: string;
|
|
13
21
|
note?: string;
|
|
14
|
-
|
|
22
|
+
oncolumns: (columns: string[]) => void;
|
|
15
23
|
onreset: () => void;
|
|
16
24
|
/** The `data-slot` prefix: the list that owns the menu. */
|
|
17
25
|
owner?: string;
|
|
@@ -21,32 +29,20 @@ declare function $$render<P extends {
|
|
|
21
29
|
slots: {};
|
|
22
30
|
events: {};
|
|
23
31
|
};
|
|
24
|
-
declare class __sveltets_Render<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
props(): ReturnType<typeof $$render<P>>['props'];
|
|
29
|
-
events(): ReturnType<typeof $$render<P>>['events'];
|
|
30
|
-
slots(): ReturnType<typeof $$render<P>>['slots'];
|
|
32
|
+
declare class __sveltets_Render<G extends string> {
|
|
33
|
+
props(): ReturnType<typeof $$render<G>>['props'];
|
|
34
|
+
events(): ReturnType<typeof $$render<G>>['events'];
|
|
35
|
+
slots(): ReturnType<typeof $$render<G>>['slots'];
|
|
31
36
|
bindings(): "";
|
|
32
37
|
exports(): {};
|
|
33
38
|
}
|
|
34
39
|
interface $$IsomorphicComponent {
|
|
35
|
-
new <
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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']>;
|
|
40
|
+
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']>> & {
|
|
41
|
+
$$bindings?: ReturnType<__sveltets_Render<G>['bindings']>;
|
|
42
|
+
} & ReturnType<__sveltets_Render<G>['exports']>;
|
|
43
|
+
<G extends string>(internal: unknown, props: ReturnType<__sveltets_Render<G>['props']> & {}): ReturnType<__sveltets_Render<G>['exports']>;
|
|
45
44
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
46
45
|
}
|
|
47
46
|
declare const LedgerColumns: $$IsomorphicComponent;
|
|
48
|
-
type LedgerColumns<
|
|
49
|
-
columns: string[];
|
|
50
|
-
period?: LedgerPeriod;
|
|
51
|
-
}> = InstanceType<typeof LedgerColumns<P>>;
|
|
47
|
+
type LedgerColumns<G extends string> = InstanceType<typeof LedgerColumns<G>>;
|
|
52
48
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
161
|
-
|
|
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
|
|
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 =
|
|
207
|
-
const g =
|
|
208
|
-
if (g) g.
|
|
209
|
-
else
|
|
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={
|
|
387
|
-
|
|
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
|
-
|
|
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
|
|
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.
|
|
3
|
+
"version": "2026.11.10",
|
|
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.
|
|
4
|
+
"version": "2026.11.10",
|
|
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.
|
|
4
|
+
Generated from `@poodle64/ui@2026.11.10`. 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 |
|