@tristan2828/ui-foundation 4.96.0 → 4.97.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.
Files changed (51) hide show
  1. package/conventions/AGENTS.md +1 -1
  2. package/conventions/docs/add-an-entity.md +38 -26
  3. package/conventions/docs/cell-patterns.md +57 -54
  4. package/conventions/docs/design-language.md +78 -42
  5. package/conventions/docs/reminders.md +2 -2
  6. package/conventions/docs/timed-screens.md +1 -1
  7. package/dist/components/app/action-error.js +1 -1
  8. package/dist/components/app/allow-reminders.js +1 -1
  9. package/dist/components/app/app-shell.js +4 -4
  10. package/dist/components/app/board.js +1 -1
  11. package/dist/components/app/choice-buttons.js +6 -1
  12. package/dist/components/app/data-table-tools.js +2 -2
  13. package/dist/components/app/data-table.js +4 -4
  14. package/dist/components/app/date-field.js +1 -1
  15. package/dist/components/app/emoji-field-data.js +7 -7
  16. package/dist/components/app/entity-form.js +1 -1
  17. package/dist/components/app/entity-view.js +5 -5
  18. package/dist/components/app/error-state.js +1 -1
  19. package/dist/components/app/field-rows.js +6 -3
  20. package/dist/components/app/fill-in-queue.js +2 -2
  21. package/dist/components/app/filter-bar.js +1 -1
  22. package/dist/components/app/form-dialog.js +1 -1
  23. package/dist/components/app/form-section.d.ts +1 -1
  24. package/dist/components/app/image-field.js +3 -2
  25. package/dist/components/app/list-header.js +2 -2
  26. package/dist/components/app/milkdown-editor.js +4 -4
  27. package/dist/components/app/month-day-field.js +3 -3
  28. package/dist/components/app/multi-pick.js +1 -1
  29. package/dist/components/app/needs-you.js +1 -1
  30. package/dist/components/app/notes-outline.js +1 -1
  31. package/dist/components/app/password-input.js +1 -1
  32. package/dist/components/app/record-dialog.js +1 -1
  33. package/dist/components/app/rich-text-format-items.js +6 -6
  34. package/dist/components/app/rich-text-highlight-menu.js +1 -1
  35. package/dist/components/app/rich-text-table-grips.js +16 -16
  36. package/dist/components/app/rich-text-toolbar.js +2 -2
  37. package/dist/components/app/rich-text-widgets.js +2 -2
  38. package/dist/components/app/secondary-filters.js +2 -2
  39. package/dist/components/app/session-view.js +1 -1
  40. package/dist/components/app/timeline.js +1 -1
  41. package/dist/components/app/widget-layout-sheet.js +1 -1
  42. package/dist/components/ui/combobox.js +1 -1
  43. package/dist/components/ui/dialog.js +1 -1
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +1 -0
  46. package/dist/lib/group-by-day.js +2 -2
  47. package/dist/lib/title-case.d.ts +13 -0
  48. package/dist/lib/title-case.js +66 -0
  49. package/dist/routes/login.js +4 -4
  50. package/dist/routes/register.js +1 -1
  51. package/package.json +1 -1
@@ -23,19 +23,19 @@ export const FORMAT_GROUPS = [
23
23
  { id: 'heading1', label: 'Heading 1', icon: Heading1Icon, keys: 'Block+1' },
24
24
  { id: 'heading2', label: 'Heading 2', icon: Heading2Icon, keys: 'Block+2' },
25
25
  { id: 'heading3', label: 'Heading 3', icon: Heading3Icon, keys: 'Block+3' },
26
- { id: 'toggleHeading', label: 'Toggle heading', icon: ListCollapseIcon, hint: 'folds what is under it; or type >## ' },
26
+ { id: 'toggleHeading', label: 'Toggle Heading', icon: ListCollapseIcon, hint: 'folds what is under it; or type >## ' },
27
27
  ],
28
28
  [
29
- { id: 'tasks', label: 'Task list', icon: ListChecksIcon, keys: 'Block+4', hint: 'tick an item: Mod+Shift+Enter' },
30
- { id: 'bullets', label: 'Bulleted list', icon: ListIcon, keys: 'Block+5' },
31
- { id: 'numbers', label: 'Numbered list', icon: ListOrderedIcon, keys: 'Block+6' },
29
+ { id: 'tasks', label: 'Task List', icon: ListChecksIcon, keys: 'Block+4', hint: 'tick an item: Mod+Shift+Enter' },
30
+ { id: 'bullets', label: 'Bulleted List', icon: ListIcon, keys: 'Block+5' },
31
+ { id: 'numbers', label: 'Numbered List', icon: ListOrderedIcon, keys: 'Block+6' },
32
32
  { id: 'outdent', label: 'Outdent', icon: IndentDecreaseIcon, hint: 'a list item, one level out', action: true, touch: true },
33
33
  { id: 'indent', label: 'Indent', icon: IndentIncreaseIcon, hint: 'a list item, one level in', action: true, touch: true },
34
34
  ],
35
35
  [
36
36
  { id: 'quote', label: 'Quote', icon: TextQuoteIcon, keys: 'Mod+Shift+B' },
37
37
  { id: 'callout', label: 'Callout', icon: CALLOUT_LOOK.note.icon },
38
- { id: 'codeBlock', label: 'Code block', icon: SquareCodeIcon, keys: 'Block+8' },
38
+ { id: 'codeBlock', label: 'Code Block', icon: SquareCodeIcon, keys: 'Block+8' },
39
39
  { id: 'divider', label: 'Divider', icon: MinusIcon, hint: 'or type ---' },
40
40
  ],
41
41
  [{ id: 'table', label: 'Table', icon: TableIcon, hint: 'its grips edit it', action: true }],
@@ -50,7 +50,7 @@ export const FORMAT_ITEMS = new Map(FORMAT_GROUPS.flat().map((item) => [item.id,
50
50
  */
51
51
  export const TOGGLE_HEADING_VARIANTS = [1, 2, 3].map((level) => ({
52
52
  id: `toggleHeading${level}`,
53
- label: `Toggle heading ${level}`,
53
+ label: `Toggle Heading ${level}`,
54
54
  icon: [Heading1Icon, Heading2Icon, Heading3Icon][level - 1],
55
55
  hint: `or type >${'#'.repeat(level)} `,
56
56
  }));
@@ -39,5 +39,5 @@ export function RichTextHighlightMenu({ state, readOnly, tabIndex, onFocus, onKe
39
39
  onMouseDown: (event) => event.preventDefault(), onFocus: onFocus, onKeyDown: onKeyDown, children: [_jsx(HighlighterIcon, { "aria-hidden": "true" }), _jsx(ChevronDownIcon, { "aria-hidden": "true", className: "size-3" })] }), _jsxs(DropdownMenuContent, { className: "w-44", "data-rich-text-menu": "", finalFocus: finalFocus, children: [_jsx(DropdownMenuRadioGroup, { value: current, onValueChange: (value) => {
40
40
  if (HIGHLIGHT_COLORS.includes(value))
41
41
  run(`highlight-${value}`);
42
- }, children: HIGHLIGHT_COLORS.map((color) => (_jsxs(DropdownMenuRadioItem, { value: color, closeOnClick: true, children: [_jsx("span", { "aria-hidden": "true", className: `size-4 shrink-0 rounded-sm border border-foreground/30 ${SWATCH[color]}` }), color[0].toUpperCase() + color.slice(1)] }, color))) }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { disabled: current === null, onClick: () => run('highlight-off'), children: [_jsx(RemoveFormattingIcon, { "aria-hidden": "true" }), "Remove highlight"] })] })] }));
42
+ }, children: HIGHLIGHT_COLORS.map((color) => (_jsxs(DropdownMenuRadioItem, { value: color, closeOnClick: true, children: [_jsx("span", { "aria-hidden": "true", className: `size-4 shrink-0 rounded-sm border border-foreground/30 ${SWATCH[color]}` }), color[0].toUpperCase() + color.slice(1)] }, color))) }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { disabled: current === null, onClick: () => run('highlight-off'), children: [_jsx(RemoveFormattingIcon, { "aria-hidden": "true" }), "Remove Highlight"] })] })] }));
43
43
  }
@@ -40,22 +40,22 @@ const SWATCH = {
40
40
  red: 'bg-highlight-red',
41
41
  };
42
42
  const ROW_ITEMS = [
43
- { action: 'rowAbove', label: 'Insert row above', icon: BetweenHorizontalStartIcon },
44
- { action: 'rowBelow', label: 'Insert row below', icon: BetweenHorizontalEndIcon },
45
- { action: 'moveRowUp', label: 'Move row up', icon: ArrowUpIcon },
46
- { action: 'moveRowDown', label: 'Move row down', icon: ArrowDownIcon },
47
- { action: 'deleteRow', label: 'Delete row', icon: Trash2Icon },
43
+ { action: 'rowAbove', label: 'Insert Row Above', icon: BetweenHorizontalStartIcon },
44
+ { action: 'rowBelow', label: 'Insert Row Below', icon: BetweenHorizontalEndIcon },
45
+ { action: 'moveRowUp', label: 'Move Row Up', icon: ArrowUpIcon },
46
+ { action: 'moveRowDown', label: 'Move Row Down', icon: ArrowDownIcon },
47
+ { action: 'deleteRow', label: 'Delete Row', icon: Trash2Icon },
48
48
  ];
49
49
  const COLUMN_ITEMS = [
50
- { action: 'columnLeft', label: 'Insert column left', icon: BetweenVerticalStartIcon },
51
- { action: 'columnRight', label: 'Insert column right', icon: BetweenVerticalEndIcon },
52
- { action: 'moveColumnLeft', label: 'Move column left', icon: ArrowLeftIcon },
53
- { action: 'moveColumnRight', label: 'Move column right', icon: ArrowRightIcon },
54
- { action: 'deleteColumn', label: 'Delete column', icon: Trash2Icon },
50
+ { action: 'columnLeft', label: 'Insert Column Left', icon: BetweenVerticalStartIcon },
51
+ { action: 'columnRight', label: 'Insert Column Right', icon: BetweenVerticalEndIcon },
52
+ { action: 'moveColumnLeft', label: 'Move Column Left', icon: ArrowLeftIcon },
53
+ { action: 'moveColumnRight', label: 'Move Column Right', icon: ArrowRightIcon },
54
+ { action: 'deleteColumn', label: 'Delete Column', icon: Trash2Icon },
55
55
  ];
56
56
  const SORT_ITEMS = [
57
- { action: 'sortAscending', label: 'Sort ascending', icon: ArrowDownAZIcon },
58
- { action: 'sortDescending', label: 'Sort descending', icon: ArrowUpZAIcon },
57
+ { action: 'sortAscending', label: 'Sort Ascending', icon: ArrowDownAZIcon },
58
+ { action: 'sortDescending', label: 'Sort Descending', icon: ArrowUpZAIcon },
59
59
  ];
60
60
  const ALIGNMENTS = [
61
61
  { value: 'left', action: 'alignLeft', label: 'Left', icon: AlignLeftIcon },
@@ -309,7 +309,7 @@ export function TableGrips({ view, state, getPos, frame, box, table, readOnly, f
309
309
  // A cell says its colour; a row's or a column's cells may differ.
310
310
  , {
311
311
  // A cell says its colour; a row's or a column's cells may differ.
312
- value: scope === 'cell' ? (current ?? '') : null, onValueChange: (value) => color(scope, HIGHLIGHT_COLORS.includes(value) ? value : null), children: [HIGHLIGHT_COLORS.map((one) => (_jsxs(DropdownMenuRadioItem, { value: one, closeOnClick: true, children: [_jsx("span", { "aria-hidden": "true", className: cn('size-4 shrink-0 rounded-sm border border-foreground/30', SWATCH[one]) }), one[0].toUpperCase() + one.slice(1)] }, one))), _jsxs(DropdownMenuRadioItem, { value: "", closeOnClick: true, children: [_jsx("span", { "aria-hidden": "true", className: "size-4 shrink-0 rounded-sm border border-foreground/30" }), "No colour"] })] })] }));
312
+ value: scope === 'cell' ? (current ?? '') : null, onValueChange: (value) => color(scope, HIGHLIGHT_COLORS.includes(value) ? value : null), children: [HIGHLIGHT_COLORS.map((one) => (_jsxs(DropdownMenuRadioItem, { value: one, closeOnClick: true, children: [_jsx("span", { "aria-hidden": "true", className: cn('size-4 shrink-0 rounded-sm border border-foreground/30', SWATCH[one]) }), one[0].toUpperCase() + one.slice(1)] }, one))), _jsxs(DropdownMenuRadioItem, { value: "", closeOnClick: true, children: [_jsx("span", { "aria-hidden": "true", className: "size-4 shrink-0 rounded-sm border border-foreground/30" }), "No Colour"] })] })] }));
313
313
  };
314
314
  const setWidth = there ? columnWidthAt(there) : null;
315
315
  const anyWidth = there ? tableHasWidths(there) : false;
@@ -318,13 +318,13 @@ export function TableGrips({ view, state, getPos, frame, box, table, readOnly, f
318
318
  const width = clampColumnWidth(shownWidth(column) + by);
319
319
  later(() => onWidth(column, width));
320
320
  };
321
- const columnItems = (withColor, label) => (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuGroup, { children: [label && _jsx(DropdownMenuLabel, { children: label }), items(COLUMN_ITEMS)] }), _jsx(DropdownMenuSeparator, {}), !phone && menuCell && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuGroup, { children: [_jsxs(DropdownMenuLabel, { children: ["Width: ", setWidth === null ? 'fit to content' : `${setWidth} px`] }), _jsxs(DropdownMenuItem, { disabled: shownWidth(menuCell.column) <= MIN_COLUMN_WIDTH, onClick: () => resize(menuCell.column, -WIDTH_STEP), children: [_jsx(ChevronsRightLeftIcon, { "aria-hidden": "true" }), "Narrower"] }), _jsxs(DropdownMenuItem, { disabled: shownWidth(menuCell.column) >= MAX_COLUMN_WIDTH, onClick: () => resize(menuCell.column, WIDTH_STEP), children: [_jsx(ChevronsLeftRightIcon, { "aria-hidden": "true" }), "Wider"] }), _jsxs(DropdownMenuItem, { disabled: setWidth === null, onClick: () => later(() => onWidth(menuCell.column, null)), children: [_jsx(MoveHorizontalIcon, { "aria-hidden": "true" }), "Fit to content"] }), _jsxs(DropdownMenuItem, { disabled: !anyWidth, onClick: () => later(() => onWidth(menuCell.column, 'all')), children: [_jsx(Columns3Icon, { "aria-hidden": "true" }), "Fit all columns"] })] }), _jsx(DropdownMenuSeparator, {})] })), _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: "Align column" }), _jsx(DropdownMenuRadioGroup, { value: there ? columnAlignment(there) : 'left', onValueChange: (value) => {
321
+ const columnItems = (withColor, label) => (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuGroup, { children: [label && _jsx(DropdownMenuLabel, { children: label }), items(COLUMN_ITEMS)] }), _jsx(DropdownMenuSeparator, {}), !phone && menuCell && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuGroup, { children: [_jsxs(DropdownMenuLabel, { children: ["Width: ", setWidth === null ? 'fit to content' : `${setWidth} px`] }), _jsxs(DropdownMenuItem, { disabled: shownWidth(menuCell.column) <= MIN_COLUMN_WIDTH, onClick: () => resize(menuCell.column, -WIDTH_STEP), children: [_jsx(ChevronsRightLeftIcon, { "aria-hidden": "true" }), "Narrower"] }), _jsxs(DropdownMenuItem, { disabled: shownWidth(menuCell.column) >= MAX_COLUMN_WIDTH, onClick: () => resize(menuCell.column, WIDTH_STEP), children: [_jsx(ChevronsLeftRightIcon, { "aria-hidden": "true" }), "Wider"] }), _jsxs(DropdownMenuItem, { disabled: setWidth === null, onClick: () => later(() => onWidth(menuCell.column, null)), children: [_jsx(MoveHorizontalIcon, { "aria-hidden": "true" }), "Fit to Content"] }), _jsxs(DropdownMenuItem, { disabled: !anyWidth, onClick: () => later(() => onWidth(menuCell.column, 'all')), children: [_jsx(Columns3Icon, { "aria-hidden": "true" }), "Fit All Columns"] })] }), _jsx(DropdownMenuSeparator, {})] })), _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: "Align Column" }), _jsx(DropdownMenuRadioGroup, { value: there ? columnAlignment(there) : 'left', onValueChange: (value) => {
322
322
  const one = ALIGNMENTS.find((alignment) => alignment.value === value);
323
323
  if (one)
324
324
  run(one.action);
325
- }, children: ALIGNMENTS.map(({ value, label, icon: Icon }) => (_jsxs(DropdownMenuRadioItem, { value: value, closeOnClick: true, children: [_jsx(Icon, { "aria-hidden": "true" }), label] }, value))) })] }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuGroup, { children: items(SORT_ITEMS) }), menuCell?.column === 0 && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuCheckboxItem, { checked: there ? headerColumnOn(there) : false, disabled: !enabled('headerColumn'), onCheckedChange: () => run('headerColumn'), closeOnClick: true, children: [_jsx(PanelLeftIcon, { "aria-hidden": "true" }), "Header column"] })] })), withColor && there && tableColorEnabled(there, 'column') && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), colorGroup('column', 'Colour column')] })), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: () => run('deleteTable'), children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Delete table"] })] }));
325
+ }, children: ALIGNMENTS.map(({ value, label, icon: Icon }) => (_jsxs(DropdownMenuRadioItem, { value: value, closeOnClick: true, children: [_jsx(Icon, { "aria-hidden": "true" }), label] }, value))) })] }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuGroup, { children: items(SORT_ITEMS) }), menuCell?.column === 0 && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuCheckboxItem, { checked: there ? headerColumnOn(there) : false, disabled: !enabled('headerColumn'), onCheckedChange: () => run('headerColumn'), closeOnClick: true, children: [_jsx(PanelLeftIcon, { "aria-hidden": "true" }), "Header Column"] })] })), withColor && there && tableColorEnabled(there, 'column') && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), colorGroup('column', 'Colour Column')] })), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: () => run('deleteTable'), children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Delete Table"] })] }));
326
326
  const rowColor = there && tableColorEnabled(there, 'row');
327
327
  const finalFocus = () => text() ?? true;
328
328
  const grip = 'pointer-events-auto absolute flex items-center justify-center rounded-sm border border-border bg-muted text-muted-foreground shadow-xs outline-none hover:bg-primary hover:text-primary-foreground data-popup-open:bg-primary data-popup-open:text-primary-foreground';
329
- return (_jsxs(_Fragment, { children: [!phone && (_jsxs("div", { ref: edgeHandle, hidden: true, "aria-hidden": "true", "data-slot": "rich-text-table-column-edge", className: "pointer-events-auto absolute z-10 flex w-3 -translate-x-1/2 cursor-col-resize touch-none justify-center", onPointerDown: startDrag, onDoubleClick: () => edge !== null && onWidth(edge, null), children: [_jsx("span", { className: "h-full w-0.5 bg-primary" }), drag && (_jsx("span", { "data-slot": "rich-text-table-column-size", className: "absolute bottom-full mb-1 rounded-sm bg-primary px-1.5 font-mono text-xs whitespace-nowrap text-primary-foreground tabular-nums", children: drag.label }))] })), _jsxs(DropdownMenu, { open: open === 'column' || open === 'cell', onOpenChange: openMenu('column'), children: [_jsx(DropdownMenuTrigger, { tabIndex: -1, "aria-label": menuCell ? `Column: ${columnName(menuCell.column)}` : 'Column', ref: columnGrip, "data-slot": "rich-text-table-column-grip", className: cn(grip, 'h-3.5 w-6 -translate-x-1/2 -translate-y-1/2'), children: _jsx(GripHorizontalIcon, { "aria-hidden": "true", className: "size-3" }) }), _jsx(DropdownMenuContent, { className: "w-56", "data-rich-text-menu": "", finalFocus: finalFocus, children: open === 'cell' ? (_jsxs(_Fragment, { children: [menuCell && menuCell.row > 0 && (_jsxs(_Fragment, { children: [colorGroup('cell', 'Cell colour'), _jsx(DropdownMenuSeparator, {})] })), _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: "Row" }), items(ROW_ITEMS)] }), _jsx(DropdownMenuSeparator, {}), columnItems(false, menuCell ? `Column: ${columnName(menuCell.column)}` : 'Column')] })) : (columnItems(true)) })] }), _jsxs(DropdownMenu, { open: open === 'row', onOpenChange: openMenu('row'), children: [_jsx(DropdownMenuTrigger, { tabIndex: -1, "aria-label": menuCell ? (menuCell.row === 0 ? 'Header row' : `Row ${menuCell.row}`) : 'Row', ref: rowGrip, "data-slot": "rich-text-table-row-grip", className: cn(grip, 'h-6 w-3.5 -translate-x-1/2 -translate-y-1/2'), children: _jsx(GripVerticalIcon, { "aria-hidden": "true", className: "size-3" }) }), _jsxs(DropdownMenuContent, { className: "w-56", "data-rich-text-menu": "", finalFocus: finalFocus, children: [_jsx(DropdownMenuGroup, { children: items(ROW_ITEMS) }), rowColor && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), colorGroup('row', 'Colour row')] }))] })] })] }));
329
+ return (_jsxs(_Fragment, { children: [!phone && (_jsxs("div", { ref: edgeHandle, hidden: true, "aria-hidden": "true", "data-slot": "rich-text-table-column-edge", className: "pointer-events-auto absolute z-10 flex w-3 -translate-x-1/2 cursor-col-resize touch-none justify-center", onPointerDown: startDrag, onDoubleClick: () => edge !== null && onWidth(edge, null), children: [_jsx("span", { className: "h-full w-0.5 bg-primary" }), drag && (_jsx("span", { "data-slot": "rich-text-table-column-size", className: "absolute bottom-full mb-1 rounded-sm bg-primary px-1.5 font-mono text-xs whitespace-nowrap text-primary-foreground tabular-nums", children: drag.label }))] })), _jsxs(DropdownMenu, { open: open === 'column' || open === 'cell', onOpenChange: openMenu('column'), children: [_jsx(DropdownMenuTrigger, { tabIndex: -1, "aria-label": menuCell ? `Column: ${columnName(menuCell.column)}` : 'Column', ref: columnGrip, "data-slot": "rich-text-table-column-grip", className: cn(grip, 'h-3.5 w-6 -translate-x-1/2 -translate-y-1/2'), children: _jsx(GripHorizontalIcon, { "aria-hidden": "true", className: "size-3" }) }), _jsx(DropdownMenuContent, { className: "w-56", "data-rich-text-menu": "", finalFocus: finalFocus, children: open === 'cell' ? (_jsxs(_Fragment, { children: [menuCell && menuCell.row > 0 && (_jsxs(_Fragment, { children: [colorGroup('cell', 'Cell Colour'), _jsx(DropdownMenuSeparator, {})] })), _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: "Row" }), items(ROW_ITEMS)] }), _jsx(DropdownMenuSeparator, {}), columnItems(false, menuCell ? `Column: ${columnName(menuCell.column)}` : 'Column')] })) : (columnItems(true)) })] }), _jsxs(DropdownMenu, { open: open === 'row', onOpenChange: openMenu('row'), children: [_jsx(DropdownMenuTrigger, { tabIndex: -1, "aria-label": menuCell ? (menuCell.row === 0 ? 'Header Row' : `Row ${menuCell.row}`) : 'Row', ref: rowGrip, "data-slot": "rich-text-table-row-grip", className: cn(grip, 'h-6 w-3.5 -translate-x-1/2 -translate-y-1/2'), children: _jsx(GripVerticalIcon, { "aria-hidden": "true", className: "size-3" }) }), _jsxs(DropdownMenuContent, { className: "w-56", "data-rich-text-menu": "", finalFocus: finalFocus, children: [_jsx(DropdownMenuGroup, { children: items(ROW_ITEMS) }), rowColor && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), colorGroup('row', 'Colour Row')] }))] })] })] }));
330
330
  }
@@ -109,11 +109,11 @@ export function FormatButtons({ formats, state, readOnly, onFormat, onPage, onIm
109
109
  onMouseDown: (event) => event.preventDefault(), onFocus: () => setCurrent(index), onKeyDown: onKeyDown, onPressedChange: () => onFormat(item.id) }), children: _jsx(Icon, {}) }), _jsx(TooltipContent, { children: tip })] }, item.id));
110
110
  })] }, groupIndex))), onPage && (_jsxs(_Fragment, { children: [_jsx(Separator, { orientation: "vertical", className: "mx-1 h-5 self-center" }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(Button, { ref: (element) => {
111
111
  buttons.current[pageIndex] = element;
112
- }, variant: "ghost", size: "icon-sm", "aria-label": "Turn into page", disabled: readOnly, tabIndex: pageIndex === current ? 0 : -1, onMouseDown: (event) => event.preventDefault(), onFocus: () => setCurrent(pageIndex), onKeyDown: onKeyDown, onClick: onPage }), children: _jsx(FileTextIcon, {}) }), _jsx(TooltipContent, { children: "Turn into page \u00B7 a new page named for the words, linked here" })] })] })), onImage && (_jsxs(_Fragment, { children: [_jsx(Separator, { orientation: "vertical", className: "mx-1 h-5 self-center" }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(Button, { ref: (element) => {
112
+ }, variant: "ghost", size: "icon-sm", "aria-label": "Turn Into Page", disabled: readOnly, tabIndex: pageIndex === current ? 0 : -1, onMouseDown: (event) => event.preventDefault(), onFocus: () => setCurrent(pageIndex), onKeyDown: onKeyDown, onClick: onPage }), children: _jsx(FileTextIcon, {}) }), _jsx(TooltipContent, { children: "Turn Into Page \u00B7 a new page named for the words, linked here" })] })] })), onImage && (_jsxs(_Fragment, { children: [_jsx(Separator, { orientation: "vertical", className: "mx-1 h-5 self-center" }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(Button, { ref: (element) => {
113
113
  buttons.current[imageIndex] = element;
114
114
  }, variant: "ghost", size: "icon-sm", "aria-label": "Image", disabled: readOnly, tabIndex: imageIndex === current ? 0 : -1, onMouseDown: (event) => event.preventDefault(), onFocus: () => setCurrent(imageIndex), onKeyDown: onKeyDown, onClick: onImage }), children: _jsx(ImageIcon, {}) }), _jsx(TooltipContent, { children: "Image \u00B7 or paste or drop one" })] })] })), onFullScreen && (_jsxs(_Fragment, { children: [_jsx(Separator, { orientation: "vertical", className: "mx-1 h-5 self-center" }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(Toggle, { ref: (element) => {
115
115
  buttons.current[fullScreenIndex] = element;
116
- }, size: "icon-sm", "aria-label": "Full screen", pressed: fullScreen, tabIndex: fullScreenIndex === current ? 0 : -1, className: "aria-pressed:bg-muted aria-pressed:text-foreground", onMouseDown: (event) => event.preventDefault(), onFocus: () => setCurrent(fullScreenIndex), onKeyDown: onKeyDown, onPressedChange: onFullScreen }), children: fullScreen ? _jsx(Minimize2Icon, {}) : _jsx(Maximize2Icon, {}) }), _jsx(TooltipContent, { children: fullScreen ? 'Leave full screen · Esc' : 'Full screen' })] })] }))] }));
116
+ }, size: "icon-sm", "aria-label": "Full Screen", pressed: fullScreen, tabIndex: fullScreenIndex === current ? 0 : -1, className: "aria-pressed:bg-muted aria-pressed:text-foreground", onMouseDown: (event) => event.preventDefault(), onFocus: () => setCurrent(fullScreenIndex), onKeyDown: onKeyDown, onPressedChange: onFullScreen }), children: fullScreen ? _jsx(Minimize2Icon, {}) : _jsx(Maximize2Icon, {}) }), _jsx(TooltipContent, { children: fullScreen ? 'Leave Full Screen · Esc' : 'Full Screen' })] })] }))] }));
117
117
  }
118
118
  export function RichTextToolbar({ state, readOnly, controls, onFormat, onImage, onFullScreen, fullScreen, text, ref }) {
119
119
  return (_jsx("div", { ref: ref, role: "toolbar", "aria-label": "Formatting", "aria-controls": controls, "data-slot": "rich-text-toolbar", className: "flex flex-wrap items-center gap-0.5 border-b border-input px-1 py-1", children: _jsx(FormatButtons, { formats: "all", state: state, readOnly: readOnly, onFormat: onFormat, onImage: onImage, onFullScreen: onFullScreen, fullScreen: fullScreen, text: text }) }));
@@ -23,12 +23,12 @@ export function CalloutKindMenu({ kind, readOnly, onPick, onRemove, text }) {
23
23
  return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { tabIndex: -1, disabled: readOnly, "aria-label": `${look.label} callout: change its kind`, "data-slot": "rich-text-callout-kind", className: "flex size-5 items-center justify-center rounded-md outline-none hover:bg-foreground/10 focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none", children: _jsx(Icon, { "aria-hidden": "true", className: cn('size-4', look.tint) }) }), _jsxs(DropdownMenuContent, { className: "w-44", finalFocus: () => text() ?? true, children: [_jsx(DropdownMenuRadioGroup, { value: kind, onValueChange: (value) => onPick(value), children: CALLOUT_KINDS.map((one) => {
24
24
  const OneIcon = CALLOUT_LOOK[one].icon;
25
25
  return (_jsxs(DropdownMenuRadioItem, { value: one, closeOnClick: true, children: [_jsx(OneIcon, { "aria-hidden": "true", className: CALLOUT_LOOK[one].tint }), CALLOUT_LOOK[one].label] }, one));
26
- }) }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onClick: onRemove, children: "Remove callout" })] })] }));
26
+ }) }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onClick: onRemove, children: "Remove Callout" })] })] }));
27
27
  }
28
28
  export function TableBar({ side, active, readOnly, onAdd }) {
29
29
  if (readOnly)
30
30
  return null;
31
- return (_jsx("button", { type: "button", tabIndex: -1, "aria-label": side === 'row' ? 'Add a row' : 'Add a column', "data-slot": `rich-text-table-add-${side}`, className: cn('flex flex-1 items-center justify-center rounded-md text-muted-foreground transition-opacity hover:bg-muted hover:text-foreground', 'opacity-0 group-hover/table:opacity-100', active && 'opacity-100'),
31
+ return (_jsx("button", { type: "button", tabIndex: -1, "aria-label": side === 'row' ? 'Add a Row' : 'Add a Column', "data-slot": `rich-text-table-add-${side}`, className: cn('flex flex-1 items-center justify-center rounded-md text-muted-foreground transition-opacity hover:bg-muted hover:text-foreground', 'opacity-0 group-hover/table:opacity-100', active && 'opacity-100'),
32
32
  // A press keeps focus in the text: the caret moves into the new cell.
33
33
  onMouseDown: (event) => event.preventDefault(), onClick: onAdd, children: _jsx(PlusIcon, { "aria-hidden": "true", className: "size-3.5" }) }));
34
34
  }
@@ -28,6 +28,6 @@ export function SecondaryFilters({ children, active, onClear, label = 'Filters',
28
28
  const [open, setOpen] = useState(false);
29
29
  const count = active.length;
30
30
  const trigger = (_jsxs(Button, { variant: "outline", children: [_jsx(SlidersHorizontalIcon, { "aria-hidden": "true" }), _jsxs("span", { children: [label, count > 0 && _jsx("span", { className: "text-[0px]", children: "," })] }), count > 0 && (_jsxs(_Fragment, { children: [_jsx("span", { className: "rounded-full bg-primary px-1.5 type-caption text-primary-foreground tabular-nums", children: count }), _jsx("span", { className: "sr-only", children: " active" })] }))] }));
31
- const footer = (_jsxs("div", { className: "flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", disabled: count === 0, onClick: onClear, children: "Clear filters" }), _jsx(Button, { size: "sm", onClick: () => setOpen(false), children: "Done" })] }));
32
- return (_jsxs("div", { "data-slot": "secondary-filters", className: cn('flex flex-wrap items-center gap-2', className), children: [isMobile ? (_jsxs(Sheet, { open: open, onOpenChange: setOpen, children: [_jsx(SheetTrigger, { render: trigger }), _jsxs(SheetContent, { side: "bottom", className: "max-h-[85svh] overflow-y-auto", children: [_jsx(SheetHeader, { children: _jsx(SheetTitle, { children: label }) }), _jsx("div", { className: "flex flex-col gap-3 px-4 [&>*]:w-full", children: children }), _jsx(SheetFooter, { children: footer })] })] })) : (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { render: trigger }), _jsxs(PopoverContent, { align: "start", className: "w-auto min-w-64 gap-3 p-3", children: [_jsx(PopoverTitle, { children: label }), _jsx("div", { className: "flex flex-col gap-3", children: children }), footer] })] })), active.map((filter) => (_jsxs("span", { "data-slot": "secondary-filter-chip", className: "inline-flex h-7 items-center gap-0.5 rounded-md bg-muted pr-0.5 pl-2 type-caption text-foreground", children: [filter.label, _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": `Remove filter: ${filter.label}`, onClick: filter.onRemove, children: _jsx(XIcon, { "aria-hidden": "true" }) })] }, filter.id))), count > 1 && (_jsx(Button, { variant: "ghost", size: "sm", onClick: onClear, children: "Clear filters" }))] }));
31
+ const footer = (_jsxs("div", { className: "flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", disabled: count === 0, onClick: onClear, children: "Clear Filters" }), _jsx(Button, { size: "sm", onClick: () => setOpen(false), children: "Done" })] }));
32
+ return (_jsxs("div", { "data-slot": "secondary-filters", className: cn('flex flex-wrap items-center gap-2', className), children: [isMobile ? (_jsxs(Sheet, { open: open, onOpenChange: setOpen, children: [_jsx(SheetTrigger, { render: trigger }), _jsxs(SheetContent, { side: "bottom", className: "max-h-[85svh] overflow-y-auto", children: [_jsx(SheetHeader, { children: _jsx(SheetTitle, { children: label }) }), _jsx("div", { className: "flex flex-col gap-3 px-4 [&>*]:w-full", children: children }), _jsx(SheetFooter, { children: footer })] })] })) : (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { render: trigger }), _jsxs(PopoverContent, { align: "start", className: "w-auto min-w-64 gap-3 p-3", children: [_jsx(PopoverTitle, { children: label }), _jsx("div", { className: "flex flex-col gap-3", children: children }), footer] })] })), active.map((filter) => (_jsxs("span", { "data-slot": "secondary-filter-chip", className: "inline-flex h-7 items-center gap-0.5 rounded-md bg-muted pr-0.5 pl-2 type-caption text-foreground", children: [filter.label, _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": `Remove filter: ${filter.label}`, onClick: filter.onRemove, children: _jsx(XIcon, { "aria-hidden": "true" }) })] }, filter.id))), count > 1 && (_jsx(Button, { variant: "ghost", size: "sm", onClick: onClear, children: "Clear Filters" }))] }));
33
33
  }
@@ -26,7 +26,7 @@ export function SessionView({ open, onOpenChange, title, children, keepAwake = f
26
26
  // theme.css's .dark block remaps the tokens for this subtree only.
27
27
  dark && 'dark scheme-dark',
28
28
  // The insets are 0 unless the page's viewport meta has viewport-fit=cover.
29
- 'pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)]', 'duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0'), children: [_jsxs("header", { className: "flex items-center gap-1 px-4 py-2", children: [_jsx(DialogTitle, { className: "min-w-0 flex-1 truncate type-section-title", children: title }), fullscreenControl && fullscreen.supported && (_jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Full screen", "aria-pressed": fullscreen.active, onClick: fullscreen.toggle, children: fullscreen.active ? _jsx(Minimize2Icon, {}) : _jsx(Maximize2Icon, {}) })), _jsx(DialogClose, { render: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Close" }), children: _jsx(XIcon, {}) })] }), _jsx("div", { className: cn('flex min-h-0 flex-1 flex-col overflow-auto px-4 pb-4', className), children: children })] }) }) }));
29
+ 'pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)]', 'duration-150 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0'), children: [_jsxs("header", { className: "flex items-center gap-1 px-4 py-2", children: [_jsx(DialogTitle, { className: "min-w-0 flex-1 truncate type-section-title", children: title }), fullscreenControl && fullscreen.supported && (_jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Full Screen", "aria-pressed": fullscreen.active, onClick: fullscreen.toggle, children: fullscreen.active ? _jsx(Minimize2Icon, {}) : _jsx(Maximize2Icon, {}) })), _jsx(DialogClose, { render: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Close" }), children: _jsx(XIcon, {}) })] }), _jsx("div", { className: cn('flex min-h-0 flex-1 flex-col overflow-auto px-4 pb-4', className), children: children })] }) }) }));
30
30
  }
31
31
  // The whole page in the browser's fullscreen (not the view's own element:
32
32
  // popups inside the view portal to <body>, and would vanish outside a
@@ -27,5 +27,5 @@ export function Timeline({ items, initial = 5, label, emptyText = 'Nothing yet',
27
27
  const limit = Math.max(1, initial);
28
28
  const folds = items.length > limit;
29
29
  const shown = folds && !all ? items.slice(0, limit) : items;
30
- return (_jsxs("div", { "data-slot": "timeline", className: cn('@container flex min-w-0 flex-col gap-2', className), children: [_jsx("ol", { id: listId, "aria-label": label, className: "flex flex-col", children: shown.map((item, index) => (_jsxs("li", { "data-slot": "timeline-item", className: "grid grid-cols-[5.5rem_1rem_minmax(0,1fr)] gap-x-2 @max-[24rem]:grid-cols-[1rem_minmax(0,1fr)]", children: [_jsx("div", { className: "col-start-1 row-start-1 pt-px text-right type-caption tabular-nums text-muted-foreground @max-[24rem]:col-start-2 @max-[24rem]:text-left", children: item.dateTime ? _jsx("time", { dateTime: item.dateTime, children: item.date }) : item.date }), _jsxs("div", { "aria-hidden": "true", className: "col-start-2 row-start-1 flex flex-col items-center @max-[24rem]:col-start-1 @max-[24rem]:row-span-2", children: [_jsx("span", { className: "mt-1.5 size-2 shrink-0 rounded-full bg-primary" }), index < shown.length - 1 && _jsx("span", { className: "w-px flex-1 bg-border" })] }), _jsxs("div", { className: "col-start-3 row-start-1 flex min-w-0 items-start gap-2 pb-3 @max-[24rem]:col-start-2 @max-[24rem]:row-start-2", children: [_jsxs("div", { className: "min-w-0 flex-1 type-body text-foreground", children: [_jsx("div", { className: "break-words", children: item.body }), item.kind && _jsx("div", { className: "type-caption text-muted-foreground", children: item.kind })] }), item.edit && _jsx("div", { className: "shrink-0", children: item.edit })] })] }, item.id))) }), folds && (_jsx(Button, { variant: "link", size: "sm", "aria-expanded": all, "aria-controls": listId, onClick: () => setAll(!all), className: "self-start", children: all ? 'Show fewer' : `Show all ${items.length}` }))] }));
30
+ return (_jsxs("div", { "data-slot": "timeline", className: cn('@container flex min-w-0 flex-col gap-2', className), children: [_jsx("ol", { id: listId, "aria-label": label, className: "flex flex-col", children: shown.map((item, index) => (_jsxs("li", { "data-slot": "timeline-item", className: "grid grid-cols-[5.5rem_1rem_minmax(0,1fr)] gap-x-2 @max-[24rem]:grid-cols-[1rem_minmax(0,1fr)]", children: [_jsx("div", { className: "col-start-1 row-start-1 pt-px text-right type-caption tabular-nums text-muted-foreground @max-[24rem]:col-start-2 @max-[24rem]:text-left", children: item.dateTime ? _jsx("time", { dateTime: item.dateTime, children: item.date }) : item.date }), _jsxs("div", { "aria-hidden": "true", className: "col-start-2 row-start-1 flex flex-col items-center @max-[24rem]:col-start-1 @max-[24rem]:row-span-2", children: [_jsx("span", { className: "mt-1.5 size-2 shrink-0 rounded-full bg-primary" }), index < shown.length - 1 && _jsx("span", { className: "w-px flex-1 bg-border" })] }), _jsxs("div", { className: "col-start-3 row-start-1 flex min-w-0 items-start gap-2 pb-3 @max-[24rem]:col-start-2 @max-[24rem]:row-start-2", children: [_jsxs("div", { className: "min-w-0 flex-1 type-body text-foreground", children: [_jsx("div", { className: "break-words", children: item.body }), item.kind && _jsx("div", { className: "type-caption text-muted-foreground", children: item.kind })] }), item.edit && _jsx("div", { className: "shrink-0", children: item.edit })] })] }, item.id))) }), folds && (_jsx(Button, { variant: "link", size: "sm", "aria-expanded": all, "aria-controls": listId, onClick: () => setAll(!all), className: "self-start", children: all ? 'Show Fewer' : `Show All ${items.length}` }))] }));
31
31
  }
@@ -19,7 +19,7 @@ import { cn } from 'cn';
19
19
  import { Button } from '../ui/button.js';
20
20
  import { Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, } from '../ui/sheet.js';
21
21
  import { Switch } from '../ui/switch.js';
22
- export function WidgetLayoutSheet({ layout, titles, title = 'Customize this page', description = 'Order the cards, and hide the ones you don’t need.', triggerLabel = 'Customize', open, defaultOpen, onOpenChange, trigger = true, side = 'right', className, }) {
22
+ export function WidgetLayoutSheet({ layout, titles, title = 'Customize This Page', description = 'Order the cards, and hide the ones you don’t need.', triggerLabel = 'Customize', open, defaultOpen, onOpenChange, trigger = true, side = 'right', className, }) {
23
23
  const listRef = useRef(null);
24
24
  const [moved, setMoved] = useState(null);
25
25
  const [announcement, setAnnouncement] = useState('');
@@ -11,7 +11,7 @@ function ComboboxValue({ ...props }) {
11
11
  return _jsx(ComboboxPrimitive.Value, { "data-slot": "combobox-value", ...props });
12
12
  }
13
13
  function ComboboxTrigger({ className, children, ...props }) {
14
- return (_jsxs(ComboboxPrimitive.Trigger, { "data-slot": "combobox-trigger", "aria-label": "Show options", className: cn("[&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(ChevronDownIcon, { className: "pointer-events-none size-4 text-muted-foreground" })] }));
14
+ return (_jsxs(ComboboxPrimitive.Trigger, { "data-slot": "combobox-trigger", "aria-label": "Show Options", className: cn("[&_svg:not([class*='size-'])]:size-4", className), ...props, children: [children, _jsx(ChevronDownIcon, { className: "pointer-events-none size-4 text-muted-foreground" })] }));
15
15
  }
16
16
  function ComboboxClear({ className, ...props }) {
17
17
  return (_jsx(ComboboxPrimitive.Clear, { "data-slot": "combobox-clear", "aria-label": "Clear", render: _jsx(InputGroupButton, { variant: "ghost", size: "icon-xs" }), className: cn(className), ...props, children: _jsx(XIcon, { className: "pointer-events-none" }) }));
@@ -89,6 +89,6 @@ function DiscardChangesDialog({ open, onKeepEditing, onDiscard, description = "W
89
89
  return (_jsx(DialogGuardContext.Provider, { value: null, children: _jsx(DialogPrimitive.Root, { open: open, onOpenChange: (next) => {
90
90
  if (!next)
91
91
  onKeepEditing();
92
- }, children: _jsxs(DialogContent, { size: "confirm", showCloseButton: false, "data-discard-changes": "", ...props, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Discard your changes?" }), _jsx(DialogDescription, { children: description })] }), _jsxs(DialogFooter, { children: [_jsx(DialogClose, { render: _jsx(Button, { variant: "outline" }), children: "Keep editing" }), _jsx(Button, { variant: "destructive", onClick: onDiscard, children: "Discard" })] })] }) }) }));
92
+ }, children: _jsxs(DialogContent, { size: "confirm", showCloseButton: false, "data-discard-changes": "", ...props, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Discard your changes?" }), _jsx(DialogDescription, { children: description })] }), _jsxs(DialogFooter, { children: [_jsx(DialogClose, { render: _jsx(Button, { variant: "outline" }), children: "Keep Editing" }), _jsx(Button, { variant: "destructive", onClick: onDiscard, children: "Discard" })] })] }) }) }));
93
93
  }
94
94
  export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiscardChangesDialog, };
package/dist/index.d.ts CHANGED
@@ -41,6 +41,7 @@ export { useOffline } from './lib/connection.js';
41
41
  export { editInPlace, type EditControlProps, type EditInPlace, type EditInPlaceList, type EditInPlaceListOptions, type EditInPlaceOptions, type EditKind, type EditListAddProps, type EditListItemProps, } from './components/app/edit-in-place.js';
42
42
  export { inPlace, type InPlaceDateConfig, type InPlaceFieldsOptions, type InPlaceLinkConfig, type InPlaceLinkValue, type InPlaceMoneyConfig, type InPlaceMonthDayConfig, type InPlaceNumberConfig, type InPlaceOption, type InPlacePart, type InPlaceRecord, type InPlaceRecurrenceConfig, type InPlaceReferenceConfig, type InPlaceSaved, type InPlaceSelectConfig, type InPlaceTextConfig, } from './components/app/edit-in-place-presets.js';
43
43
  export { linkHost, linkHref, linkRule } from './lib/link-href.js';
44
+ export { TITLE_CASE_SMALL_WORDS, titleCase } from './lib/title-case.js';
44
45
  export { DataEnvironmentBanner } from './components/app/data-environment-banner.js';
45
46
  export { EditableValue, type EditableValueProps } from './components/app/editable-value.js';
46
47
  export { editRowClass, onEditRowClick, SAVED_FOR_MS } from './components/app/edit-row.js';
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ export { useOffline } from './lib/connection.js';
49
49
  export { editInPlace, } from './components/app/edit-in-place.js';
50
50
  export { inPlace, } from './components/app/edit-in-place-presets.js';
51
51
  export { linkHost, linkHref, linkRule } from './lib/link-href.js';
52
+ export { TITLE_CASE_SMALL_WORDS, titleCase } from './lib/title-case.js';
52
53
  export { DataEnvironmentBanner } from './components/app/data-environment-banner.js';
53
54
  export { EditableValue } from './components/app/editable-value.js';
54
55
  export { editRowClass, onEditRowClick, SAVED_FOR_MS } from './components/app/edit-row.js';
@@ -26,7 +26,7 @@ export function byDay(field, { now = new Date(), timeZone, weekStartsOn = 1, loc
26
26
  const value = read(row);
27
27
  const date = value === null || value === undefined || value === '' ? null : new Date(value);
28
28
  if (date === null || Number.isNaN(date.getTime()))
29
- return { key: 'none', label: 'No date' };
29
+ return { key: 'none', label: 'No Date' };
30
30
  const day = dayOf(date);
31
31
  if (day > today)
32
32
  return { key: 'upcoming', label: 'Upcoming' };
@@ -35,7 +35,7 @@ export function byDay(field, { now = new Date(), timeZone, weekStartsOn = 1, loc
35
35
  if (day === today - 1)
36
36
  return { key: 'yesterday', label: 'Yesterday' };
37
37
  if (day >= thisWeek)
38
- return { key: 'this-week', label: 'Earlier this week' };
38
+ return { key: 'this-week', label: 'Earlier This Week' };
39
39
  const week = weekStart(day);
40
40
  if (week >= thisWeek - WEEKS_BY_WEEK * 7) {
41
41
  return { key: `week:${isoDay(week)}`, label: `Week of ${dayMonth.format(new Date(week * DAY_MS))}` };
@@ -0,0 +1,13 @@
1
+ /** The short words a title keeps lowercase, unless first or last. */
2
+ export declare const TITLE_CASE_SMALL_WORDS: ReadonlySet<string>;
3
+ /**
4
+ * A label in Title Case: every word capitalised but the short ones
5
+ * (`TITLE_CASE_SMALL_WORDS`: a, an, the, and, or, of, to, in, on, for, by,
6
+ * with, ...), which stay lowercase unless first or last, or first after a
7
+ * colon. A word that already holds a capital is left as written, so names
8
+ * and acronyms survive: `titleCase('rows per page')` is "Rows per Page",
9
+ * `titleCase('move to')` is "Move To", `titleCase('open in GitHub')` is
10
+ * "Open in GitHub". For a label built from a value (`Any ${label}`); a
11
+ * label written in the code is written in Title Case to begin with.
12
+ */
13
+ export declare function titleCase(text: string): string;
@@ -0,0 +1,66 @@
1
+ // The words a label is written in (design-language.md "Words on screen"):
2
+ // titles, buttons, menu items, tabs, column headers and field labels are
3
+ // Title Case. Messages, help text, toasts, placeholders and screen-reader
4
+ // sentences stay sentence case, so they never go through this.
5
+ /** The short words a title keeps lowercase, unless first or last. */
6
+ export const TITLE_CASE_SMALL_WORDS = new Set([
7
+ 'a',
8
+ 'an',
9
+ 'the',
10
+ 'and',
11
+ 'but',
12
+ 'or',
13
+ 'nor',
14
+ 'as',
15
+ 'at',
16
+ 'by',
17
+ 'for',
18
+ 'in',
19
+ 'of',
20
+ 'on',
21
+ 'per',
22
+ 'to',
23
+ 'with',
24
+ ]);
25
+ const upperFirst = (part) => part.replace(/\p{L}/u, (letter) => letter.toUpperCase());
26
+ function casePart(part, edge) {
27
+ if (!/\p{L}/u.test(part))
28
+ return part;
29
+ // A word already holding a capital ("iPhone", "URL", "McKay") is written as its owner wrote it.
30
+ if (/\p{Lu}/u.test(part))
31
+ return part;
32
+ const bare = part.replace(/^[^\p{L}]+|[^\p{L}]+$/gu, '');
33
+ if (!edge && TITLE_CASE_SMALL_WORDS.has(bare))
34
+ return part;
35
+ return upperFirst(part);
36
+ }
37
+ /**
38
+ * A label in Title Case: every word capitalised but the short ones
39
+ * (`TITLE_CASE_SMALL_WORDS`: a, an, the, and, or, of, to, in, on, for, by,
40
+ * with, ...), which stay lowercase unless first or last, or first after a
41
+ * colon. A word that already holds a capital is left as written, so names
42
+ * and acronyms survive: `titleCase('rows per page')` is "Rows per Page",
43
+ * `titleCase('move to')` is "Move To", `titleCase('open in GitHub')` is
44
+ * "Open in GitHub". For a label built from a value (`Any ${label}`); a
45
+ * label written in the code is written in Title Case to begin with.
46
+ */
47
+ export function titleCase(text) {
48
+ const words = text.split(/(\s+)/);
49
+ const real = words.map((word, index) => (index % 2 === 0 && word !== '' ? index : -1)).filter((index) => index >= 0);
50
+ const first = real[0];
51
+ const last = real.at(-1);
52
+ let afterColon = false;
53
+ return words
54
+ .map((word, index) => {
55
+ if (index % 2 === 1 || word === '')
56
+ return word;
57
+ const edge = index === first || index === last || afterColon;
58
+ afterColon = /:$/.test(word);
59
+ return word
60
+ .split('-')
61
+ // Each part of a hyphenated word is a word ("Follow-Up"), small or not.
62
+ .map((part, partIndex) => casePart(part, edge || partIndex > 0))
63
+ .join('-');
64
+ })
65
+ .join('');
66
+ }
@@ -59,7 +59,7 @@ export function LoginRoute({ registerPath = '/register' } = {}) {
59
59
  setStep('password');
60
60
  }
61
61
  };
62
- return (_jsx("main", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs(Card, { className: "w-full max-w-sm", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-lg", children: _jsx("h1", { children: "Sign in" }) }), step === 'code' && _jsx(CardDescription, { children: "Your account has two-step sign-in." })] }), _jsx(CardContent, { children: step === 'password' ? (_jsx(PasswordStep, { registerPath: registerPath, restartReason: restartReason, onResult: onResult })) : (_jsx(CodeStep, { onResult: onResult, onStartOver: () => {
62
+ return (_jsx("main", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs(Card, { className: "w-full max-w-sm", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-lg", children: _jsx("h1", { children: "Sign In" }) }), step === 'code' && _jsx(CardDescription, { children: "Your account has two-step sign-in." })] }), _jsx(CardContent, { children: step === 'password' ? (_jsx(PasswordStep, { registerPath: registerPath, restartReason: restartReason, onResult: onResult })) : (_jsx(CodeStep, { onResult: onResult, onStartOver: () => {
63
63
  setRestartReason(null);
64
64
  setStep('password');
65
65
  } })) })] }) }));
@@ -98,7 +98,7 @@ function PasswordStep({ registerPath, restartReason, onResult, }) {
98
98
  setIsSubmitting(false);
99
99
  }
100
100
  });
101
- return (_jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [restartReason && _jsx(FieldError, { children: restartReason }), _jsxs(FieldGroup, { children: [_jsxs(Field, { "data-invalid": !!form.formState.errors.email, children: [_jsx(FieldLabel, { htmlFor: "login-email", children: "Email" }), _jsx(Input, { id: "login-email", type: "email", autoComplete: "username", "aria-invalid": !!form.formState.errors.email, ...form.register('email') }), _jsx(FieldError, { errors: [form.formState.errors.email] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.password, children: [_jsx(FieldLabel, { htmlFor: "login-password", children: "Password" }), _jsx(PasswordInput, { id: "login-password", autoComplete: "current-password", "aria-invalid": !!form.formState.errors.password, ...form.register('password') }), _jsx(FieldError, { errors: [form.formState.errors.password] })] })] }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting || held, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Sign in"] }), registerPath !== null && (_jsx(Button, { variant: "link", size: "sm", nativeButton: false, render: _jsx(Link, { to: registerPath, state: location.state }), children: "Create account" }))] }));
101
+ return (_jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [restartReason && _jsx(FieldError, { children: restartReason }), _jsxs(FieldGroup, { children: [_jsxs(Field, { "data-invalid": !!form.formState.errors.email, children: [_jsx(FieldLabel, { htmlFor: "login-email", children: "Email" }), _jsx(Input, { id: "login-email", type: "email", autoComplete: "username", "aria-invalid": !!form.formState.errors.email, ...form.register('email') }), _jsx(FieldError, { errors: [form.formState.errors.email] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.password, children: [_jsx(FieldLabel, { htmlFor: "login-password", children: "Password" }), _jsx(PasswordInput, { id: "login-password", autoComplete: "current-password", "aria-invalid": !!form.formState.errors.password, ...form.register('password') }), _jsx(FieldError, { errors: [form.formState.errors.password] })] })] }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting || held, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Sign In"] }), registerPath !== null && (_jsx(Button, { variant: "link", size: "sm", nativeButton: false, render: _jsx(Link, { to: registerPath, state: location.state }), children: "Create Account" }))] }));
102
102
  }
103
103
  function CodeStep({ onResult, onStartOver, }) {
104
104
  const [recovery, setRecovery] = useState(false);
@@ -138,7 +138,7 @@ function CodeForm({ recovery, onSwitchMode, onResult, onStartOver, }) {
138
138
  }
139
139
  });
140
140
  const invalid = !!form.formState.errors.code;
141
- return (_jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [_jsx(FieldGroup, { children: _jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: "login-code", children: recovery ? 'Recovery code' : 'Authentication code' }), _jsx(Input, { id: "login-code", autoComplete: recovery ? 'off' : 'one-time-code', inputMode: recovery ? 'text' : 'numeric', spellCheck: false, "aria-invalid": invalid, "aria-describedby": "login-code-description", ...form.register('code') }), _jsx(FieldDescription, { id: "login-code-description", children: recovery
141
+ return (_jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [_jsx(FieldGroup, { children: _jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: "login-code", children: recovery ? 'Recovery Code' : 'Authentication Code' }), _jsx(Input, { id: "login-code", autoComplete: recovery ? 'off' : 'one-time-code', inputMode: recovery ? 'text' : 'numeric', spellCheck: false, "aria-invalid": invalid, "aria-describedby": "login-code-description", ...form.register('code') }), _jsx(FieldDescription, { id: "login-code-description", children: recovery
142
142
  ? 'One of the recovery codes you saved when two-step sign-in was turned on. Each works once.'
143
- : 'The 6-digit code your authenticator app shows for this account.' }), _jsx(FieldError, { errors: [form.formState.errors.code] })] }) }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting || held, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Verify"] }), _jsxs("div", { className: "flex flex-wrap justify-between gap-2", children: [_jsx(Button, { type: "button", variant: "link", size: "sm", onClick: onSwitchMode, children: recovery ? 'Use your authenticator app' : 'Use a recovery code' }), _jsx(Button, { type: "button", variant: "link", size: "sm", onClick: onStartOver, children: "Start over" })] })] }));
143
+ : 'The 6-digit code your authenticator app shows for this account.' }), _jsx(FieldError, { errors: [form.formState.errors.code] })] }) }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting || held, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Verify"] }), _jsxs("div", { className: "flex flex-wrap justify-between gap-2", children: [_jsx(Button, { type: "button", variant: "link", size: "sm", onClick: onSwitchMode, children: recovery ? 'Use Your Authenticator App' : 'Use a Recovery Code' }), _jsx(Button, { type: "button", variant: "link", size: "sm", onClick: onStartOver, children: "Start Over" })] })] }));
144
144
  }
@@ -54,5 +54,5 @@ export function RegisterRoute() {
54
54
  setIsSubmitting(false);
55
55
  }
56
56
  });
57
- return (_jsx("main", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs(Card, { className: "w-full max-w-sm", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "text-lg", children: _jsx("h1", { children: "Create an account" }) }) }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [_jsxs(FieldGroup, { children: [_jsxs(Field, { "data-invalid": !!form.formState.errors.name, children: [_jsx(FieldLabel, { htmlFor: "register-name", children: "Name" }), _jsx(Input, { id: "register-name", autoComplete: "name", "aria-invalid": !!form.formState.errors.name, ...form.register('name') }), _jsx(FieldError, { errors: [form.formState.errors.name] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.email, children: [_jsx(FieldLabel, { htmlFor: "register-email", children: "Email" }), _jsx(Input, { id: "register-email", type: "email", autoComplete: "username", "aria-invalid": !!form.formState.errors.email, ...form.register('email') }), _jsx(FieldError, { errors: [form.formState.errors.email] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.password, children: [_jsx(FieldLabel, { htmlFor: "register-password", children: "Password" }), _jsx(PasswordInput, { id: "register-password", autoComplete: "new-password", "aria-invalid": !!form.formState.errors.password, ...form.register('password') }), _jsx(FieldError, { errors: [form.formState.errors.password] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.confirmPassword, children: [_jsx(FieldLabel, { htmlFor: "register-confirm-password", children: "Confirm password" }), _jsx(PasswordInput, { id: "register-confirm-password", autoComplete: "new-password", "aria-invalid": !!form.formState.errors.confirmPassword, ...form.register('confirmPassword') }), _jsx(FieldError, { errors: [form.formState.errors.confirmPassword] })] })] }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Create account"] }), _jsx(Button, { variant: "link", size: "sm", nativeButton: false, render: _jsx(Link, { to: "/login", state: location.state }), children: "Sign in instead" })] }) })] }) }));
57
+ return (_jsx("main", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs(Card, { className: "w-full max-w-sm", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "text-lg", children: _jsx("h1", { children: "Create an Account" }) }) }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [_jsxs(FieldGroup, { children: [_jsxs(Field, { "data-invalid": !!form.formState.errors.name, children: [_jsx(FieldLabel, { htmlFor: "register-name", children: "Name" }), _jsx(Input, { id: "register-name", autoComplete: "name", "aria-invalid": !!form.formState.errors.name, ...form.register('name') }), _jsx(FieldError, { errors: [form.formState.errors.name] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.email, children: [_jsx(FieldLabel, { htmlFor: "register-email", children: "Email" }), _jsx(Input, { id: "register-email", type: "email", autoComplete: "username", "aria-invalid": !!form.formState.errors.email, ...form.register('email') }), _jsx(FieldError, { errors: [form.formState.errors.email] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.password, children: [_jsx(FieldLabel, { htmlFor: "register-password", children: "Password" }), _jsx(PasswordInput, { id: "register-password", autoComplete: "new-password", "aria-invalid": !!form.formState.errors.password, ...form.register('password') }), _jsx(FieldError, { errors: [form.formState.errors.password] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.confirmPassword, children: [_jsx(FieldLabel, { htmlFor: "register-confirm-password", children: "Confirm Password" }), _jsx(PasswordInput, { id: "register-confirm-password", autoComplete: "new-password", "aria-invalid": !!form.formState.errors.confirmPassword, ...form.register('confirmPassword') }), _jsx(FieldError, { errors: [form.formState.errors.confirmPassword] })] })] }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Create Account"] }), _jsx(Button, { variant: "link", size: "sm", nativeButton: false, render: _jsx(Link, { to: "/login", state: location.state }), children: "Sign In Instead" })] }) })] }) }));
58
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.96.0",
3
+ "version": "4.97.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": {