@tristan2828/ui-foundation 4.133.0 → 4.135.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,10 +41,10 @@
41
41
  - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1935–2011
42
42
  - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 2013–2099
43
43
  - [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 2038–2099
44
- - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 2101–2347
45
- - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2276–2347
46
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2349–2385
47
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2387–2436
44
+ - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 2101–2351
45
+ - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2280–2351
46
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2353–2389
47
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2391–2440
48
48
 
49
49
  <!-- /index -->
50
50
 
@@ -2267,8 +2267,12 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
2267
2267
  or a modified click works as a link's does. `title` is plain text (the
2268
2268
  row is already the link). Row actions sit at the row's end; headings,
2269
2269
  paging and every state hold. A card layout, when picked, wins.
2270
- - The fixtures' `app/DataTable tools` ListTools, ListToolsFiltered and
2271
- OneRowAction stories hold all of it, under axe and the token check in
2270
+ - **`lead`** (4.134) puts one control at the row's start, outside the
2271
+ link, in a 44px-wide column: the tick that completes a to-do from its
2272
+ row. Its clicks never open the record, so it carries its own label
2273
+ (`Complete <title>`), as the table's tick column does.
2274
+ - The fixtures' `app/DataTable tools` ListTools, ListToolsFiltered,
2275
+ OneRowAction and PhoneRowLead stories hold all of it, under axe and the token check in
2272
2276
  both themes; `e2e/data-table-tools.spec.ts` checks the pills, the stored
2273
2277
  pick and a view's columns winning, the ⋯ menu, the 44px rows, the
2274
2278
  phone's line and sheet.
@@ -54,6 +54,24 @@ there is no push at all, so `usePushPermission` says `needs-install` and
54
54
  `AllowReminders` shows the steps. `pwa()`'s manifest (`display:
55
55
  standalone`) is what makes the Home Screen app an app.
56
56
 
57
+ ## Home-screen shortcuts
58
+
59
+ `pwa({ name, shortcuts: [{ name: 'Add To-Do', url: '/todo/add' }] })` writes
60
+ the manifest's `shortcuts`: actions on the installed icon that open the
61
+ app at a path. `url` is a path inside the app (it gets the Vite `base`);
62
+ `shortName` and a square `icon` PNG (192×192 or more) are optional. Left
63
+ out, the manifest is unchanged.
64
+
65
+ | Platform | What it does with them |
66
+ |---|---|
67
+ | Android (Chrome, installed app) | Long-press the icon: the shortcuts list above it, and can be dragged to the Home Screen. Most launchers show about four |
68
+ | Desktop Chrome and Edge | Right-click the installed app's icon (taskbar, dock or Start menu) |
69
+ | iPhone and iPad | Ignored: the Home Screen app's long-press menu has none from the manifest. Safari supports `shortcuts` only on macOS (since 17.4), per [firt.dev's iOS PWA compatibility notes](https://firt.dev/notes/pwa-ios/), updated October 2026. Give the action somewhere in the app too |
70
+
71
+ Treat a shortcut as a convenience, never the only way to an action. A
72
+ phone caches the manifest, so a changed list can take a reinstall or a day
73
+ to show.
74
+
57
75
  ## A reminder is the app's own row
58
76
 
59
77
  The reference backend has a `reminders` table and the job that sends it;
@@ -84,6 +84,13 @@ export type DataTablePhoneRow<TData> = {
84
84
  status?: (row: TData) => ReactNode;
85
85
  /** The facts that matter (two, usually) on one muted line under it, between dots; empty ones are left out. */
86
86
  facts?: (row: TData) => readonly ReactNode[];
87
+ /**
88
+ * A control at the row's start, outside the link (4.134): the tick that
89
+ * completes a to-do from its row, say. Its clicks are its own, so it
90
+ * never opens the record; it gets a 44px-wide column, centred, and its
91
+ * own label (the row's title is in the link, not around it).
92
+ */
93
+ lead?: (row: TData) => ReactNode;
87
94
  };
88
95
  export declare function PhoneRow<TData>({ row, phoneRow, actions, highlighted, href, onOpen, }: {
89
96
  row: TData;
@@ -43,7 +43,7 @@ export function PhoneRow({ row, phoneRow, actions, highlighted, href, onOpen, })
43
43
  const facts = (phoneRow.facts?.(row) ?? []).filter((fact) => fact !== null && fact !== undefined && fact !== '' && fact !== false);
44
44
  const content = (_jsxs(_Fragment, { children: [_jsxs("span", { className: "flex min-w-0 items-baseline justify-between gap-3", children: [_jsx("span", { className: "min-w-0 type-body font-medium break-words text-foreground", children: phoneRow.title(row) }), phoneRow.status ? _jsx("span", { className: "shrink-0", children: phoneRow.status(row) }) : null] }), facts.length > 0 ? (_jsx("span", { className: "flex flex-wrap gap-x-1.5 type-caption text-muted-foreground", children: facts.map((fact, index) => (_jsxs("span", { className: "inline-flex gap-x-1.5", children: [index > 0 ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", children: "\u00B7" }), _jsx("span", { className: "sr-only", children: ", " })] })) : null, fact] }, index))) })) : null] }));
45
45
  return (_jsxs("li", { "data-slot": "data-table-phone-row", "data-highlighted": highlighted || undefined, className: cn('flex items-center gap-1 border-b border-border last:border-b-0', highlighted &&
46
- '[--muted-foreground:var(--table-highlight-muted-foreground)] bg-(--table-highlight) shadow-[inset_3px_0_0_0_var(--info-text)]'), children: [href !== undefined ? (_jsx("a", { href: href, className: cn(PHONE_TARGET_CLASS, PHONE_OPENS_CLASS), onClick: (event) => {
46
+ '[--muted-foreground:var(--table-highlight-muted-foreground)] bg-(--table-highlight) shadow-[inset_3px_0_0_0_var(--info-text)]'), children: [phoneRow.lead ? (_jsx("span", { "data-slot": "data-table-phone-row-lead", className: "flex w-11 shrink-0 items-center justify-center self-stretch", children: phoneRow.lead(row) })) : null, href !== undefined ? (_jsx("a", { href: href, className: cn(PHONE_TARGET_CLASS, PHONE_OPENS_CLASS), onClick: (event) => {
47
47
  if (!onOpen || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
48
48
  return;
49
49
  event.preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.133.0",
3
+ "version": "4.135.0",
4
4
  "description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/vite/index.d.ts CHANGED
@@ -48,6 +48,23 @@ export type PwaOptions = {
48
48
  * root). Replaces the generated ones everywhere.
49
49
  */
50
50
  icon?: string
51
+ /**
52
+ * Home-screen shortcuts: actions offered when the installed icon is
53
+ * long-pressed (Android, Chrome and Edge on desktop). Left out, the manifest
54
+ * has none. iOS and iPadOS ignore them.
55
+ */
56
+ shortcuts?: PwaShortcut[]
57
+ }
58
+
59
+ export type PwaShortcut = {
60
+ /** The action's label, e.g. "Add To-Do". */
61
+ name: string
62
+ /** A shorter label where space is tight. */
63
+ shortName?: string
64
+ /** A path inside the app, starting with `/`, e.g. `/todo/add`. Prefixed with the base. */
65
+ url: string
66
+ /** A square PNG of at least 192×192 (path from the Vite root). Without one the OS uses the app's icon. */
67
+ icon?: string
51
68
  }
52
69
 
53
70
  /**
package/vite/pwa.js CHANGED
@@ -188,6 +188,28 @@ export function pwaFiles(options, base = '/', root = process.cwd()) {
188
188
  ]
189
189
  touchIcon = 'icons/apple-touch-icon.png'
190
190
  }
191
+ const shortcuts = (options.shortcuts ?? []).map((shortcut, index) => {
192
+ const label = shortcut?.name?.trim()
193
+ const url = shortcut?.url?.trim()
194
+ if (!label) throw new Error(`pwa: shortcuts[${index}] needs a \`name\`.`)
195
+ if (!url?.startsWith('/') || url.startsWith('//')) {
196
+ throw new Error(`pwa: shortcuts[${index}].url must be a path inside the app, starting with "/" (got "${shortcut?.url}").`)
197
+ }
198
+ let icon
199
+ if (shortcut.icon) {
200
+ const own = path.resolve(root, shortcut.icon)
201
+ if (!own.endsWith('.png') || !fs.existsSync(own)) throw new Error(`pwa: shortcuts[${index}].icon must be a PNG file; ${own} isn't one.`)
202
+ const file = `icons/shortcut-${index}.png`
203
+ files.set(file, { type: 'image/png', source: fs.readFileSync(own) })
204
+ icon = [{ src: at(file), sizes: '192x192', type: 'image/png' }]
205
+ }
206
+ return {
207
+ name: label,
208
+ ...(shortcut.shortName?.trim() ? { short_name: shortcut.shortName.trim() } : {}),
209
+ url: `${base.replace(/\/$/, '')}${url}`,
210
+ ...(icon ? { icons: icon } : {}),
211
+ }
212
+ })
191
213
  const manifest = {
192
214
  name,
193
215
  short_name: shortName,
@@ -198,6 +220,7 @@ export function pwaFiles(options, base = '/', root = process.cwd()) {
198
220
  theme_color: theme,
199
221
  background_color: background,
200
222
  icons,
223
+ ...(shortcuts.length ? { shortcuts } : {}),
201
224
  }
202
225
  files.set('manifest.webmanifest', {
203
226
  type: 'application/manifest+json',