@tristan2828/ui-foundation 4.82.0 → 4.84.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.
- package/README.md +1 -1
- package/conventions/docs/add-an-entity.md +4 -4
- package/conventions/docs/cell-patterns.md +111 -50
- package/conventions/docs/design-language.md +75 -30
- package/conventions/docs/entity-plan-template.md +3 -3
- package/dist/components/app/data-table.d.ts +36 -8
- package/dist/components/app/data-table.js +142 -90
- package/dist/components/app/freshness.d.ts +14 -0
- package/dist/components/app/freshness.js +25 -0
- package/dist/components/app/list-header.d.ts +44 -0
- package/dist/components/app/list-header.js +27 -0
- package/dist/components/app/needs-you.d.ts +19 -0
- package/dist/components/app/needs-you.js +30 -0
- package/dist/components/app/part-empty.d.ts +20 -0
- package/dist/components/app/part-empty.js +17 -0
- package/dist/components/app/timeline.d.ts +25 -0
- package/dist/components/app/timeline.js +31 -0
- package/dist/components/app/value-list.d.ts +14 -0
- package/dist/components/app/value-list.js +13 -0
- package/dist/components/app/widget-card.d.ts +9 -1
- package/dist/components/app/widget-card.js +3 -2
- package/dist/hooks/use-table-url-state.d.ts +19 -1
- package/dist/hooks/use-table-url-state.js +31 -3
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/lib/freshness.d.ts +6 -0
- package/dist/lib/freshness.js +37 -0
- package/package.json +1 -1
- package/styles/theme.css +6 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// A record's dated history (record standard R7): updates, changes, a
|
|
3
|
+
// care log. Dates line up in a tabular column on the left, a dot and a
|
|
4
|
+
// thin line between, the entry on the right, so it reads as a history
|
|
5
|
+
// instead of a stack of paragraphs. The newest `initial` (5) show, then
|
|
6
|
+
// "Show all N": a long history stays short and the entries after it stay
|
|
7
|
+
// where they were.
|
|
8
|
+
//
|
|
9
|
+
// Items are given newest first, as the app sorts them. An entry has its
|
|
10
|
+
// date (`date`, already formatted; `dateTime` the machine-readable day
|
|
11
|
+
// for the <time>), an optional `kind` ("Visit", "Note") as a muted line
|
|
12
|
+
// under the body, the `body` (text, or markup such as <Markdown inline>),
|
|
13
|
+
// and `edit`: the entry's own control (an edit button, a menu), at its
|
|
14
|
+
// end. Under 24rem of the timeline's own width (a phone, a narrow
|
|
15
|
+
// dialog) the date moves above its entry and the column goes.
|
|
16
|
+
//
|
|
17
|
+
// It owns the empty state: "Nothing yet" (`emptyText`), never a blank.
|
|
18
|
+
import { useId, useState } from 'react';
|
|
19
|
+
import { cn } from 'cn';
|
|
20
|
+
import { Button } from '../ui/button.js';
|
|
21
|
+
export function Timeline({ items, initial = 5, label, emptyText = 'Nothing yet', className }) {
|
|
22
|
+
const [all, setAll] = useState(false);
|
|
23
|
+
const listId = useId();
|
|
24
|
+
if (items.length === 0) {
|
|
25
|
+
return (_jsx("p", { "data-slot": "timeline", "data-state": "empty", className: cn('type-body text-muted-foreground', className), children: emptyText }));
|
|
26
|
+
}
|
|
27
|
+
const limit = Math.max(1, initial);
|
|
28
|
+
const folds = items.length > limit;
|
|
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}` }))] }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type ValueListItem = {
|
|
3
|
+
/** Plain text: the chip's text, the tooltip's line and the screen reader's. Unique in the list. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** The app's own mark for the value (an icon, a swatch), drawn in place of the chip. */
|
|
6
|
+
node?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export type ValueListProps = {
|
|
9
|
+
items: readonly ValueListItem[];
|
|
10
|
+
/** How many show before "+N". Defaults to 2. */
|
|
11
|
+
max?: number;
|
|
12
|
+
className?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function ValueList({ items, max, className }: ValueListProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from 'cn';
|
|
3
|
+
import { Badge } from '../ui/badge.js';
|
|
4
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip.js';
|
|
5
|
+
export function ValueList({ items, max = 2, className }) {
|
|
6
|
+
if (items.length === 0) {
|
|
7
|
+
return (_jsxs("span", { "data-slot": "value-list", "data-state": "empty", className: cn('text-muted-foreground', className), children: [_jsx("span", { "aria-hidden": "true", children: "\u2014" }), _jsx("span", { className: "sr-only", children: "None" })] }));
|
|
8
|
+
}
|
|
9
|
+
const shown = items.slice(0, Math.max(0, max));
|
|
10
|
+
const folded = items.slice(shown.length);
|
|
11
|
+
const names = folded.map((item) => item.label).join(', ');
|
|
12
|
+
return (_jsxs("span", { "data-slot": "value-list", className: cn('inline-flex items-center gap-1 whitespace-nowrap', className), children: [shown.map((item) => (_jsx("span", { "data-slot": "value-list-item", className: "inline-flex shrink-0 items-center", children: item.node ?? _jsx(Badge, { children: item.label }) }, item.label))), folded.length > 0 && (_jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsxs(TooltipTrigger, { render: _jsx("button", { type: "button", "data-slot": "value-list-more", "aria-label": `${folded.length} more: ${names}`, className: "rounded-sm px-1 type-caption tabular-nums text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50" }), children: ["+", folded.length] }), _jsx(TooltipContent, { children: names })] }) }))] }));
|
|
13
|
+
}
|
|
@@ -2,6 +2,7 @@ import { type ReactNode } from 'react';
|
|
|
2
2
|
import { type To } from 'react-router';
|
|
3
3
|
import type { AppError } from '../../api/contracts.js';
|
|
4
4
|
import type { IconComponent } from './icon-component.js';
|
|
5
|
+
import { type PartEmptyState } from './part-empty.js';
|
|
5
6
|
export interface WidgetCardProps {
|
|
6
7
|
title: string;
|
|
7
8
|
/**
|
|
@@ -32,6 +33,13 @@ export interface WidgetCardProps {
|
|
|
32
33
|
isEmpty: boolean;
|
|
33
34
|
/** The empty state's one line: "Nothing waiting". */
|
|
34
35
|
emptyMessage: string;
|
|
36
|
+
/**
|
|
37
|
+
* A card with nothing yet that offers a way to start (overview standard
|
|
38
|
+
* O5): `{ text, action }` draws "Nothing here yet" and one button, the
|
|
39
|
+
* foundation's Empty at card size (PartEmpty), in place of the plain
|
|
40
|
+
* `emptyMessage` line. `text` defaults to "Nothing here yet".
|
|
41
|
+
*/
|
|
42
|
+
empty?: PartEmptyState;
|
|
35
43
|
/** How many rows the loading skeleton shows: the number the widget usually holds. */
|
|
36
44
|
skeletonRows?: number;
|
|
37
45
|
/** A button at the header's end that folds the card to its header, and opens it again. */
|
|
@@ -64,7 +72,7 @@ export type WidgetCardLink = {
|
|
|
64
72
|
label: string;
|
|
65
73
|
to?: never;
|
|
66
74
|
};
|
|
67
|
-
export declare function WidgetCard({ id, title, icon: Icon, headingLevel, link, isLoading, error, onRetry, isEmpty, emptyMessage, skeletonRows, collapsible, defaultCollapsed, storageKey, summary, emptySummary, children, className, }: WidgetCardProps): import("react").JSX.Element;
|
|
75
|
+
export declare function WidgetCard({ id, title, icon: Icon, headingLevel, link, isLoading, error, onRetry, isEmpty, emptyMessage, empty, skeletonRows, collapsible, defaultCollapsed, storageKey, summary, emptySummary, children, className, }: WidgetCardProps): import("react").JSX.Element;
|
|
68
76
|
export interface WidgetCardGroupProps {
|
|
69
77
|
/**
|
|
70
78
|
* One card open at a time: `true` always, `"mobile"` only below the
|
|
@@ -59,6 +59,7 @@ import { Link } from 'react-router';
|
|
|
59
59
|
import { ChevronDownIcon, ExternalLinkIcon } from 'lucide-react';
|
|
60
60
|
import { cn } from 'cn';
|
|
61
61
|
import { ErrorState } from './error-state.js';
|
|
62
|
+
import { PartEmpty } from './part-empty.js';
|
|
62
63
|
import { Button } from '../ui/button.js';
|
|
63
64
|
import { Card, CardContent, CardHeader } from '../ui/card.js';
|
|
64
65
|
import { Skeleton } from '../ui/skeleton.js';
|
|
@@ -66,7 +67,7 @@ import { useIsMobile } from '../../hooks/use-mobile.js';
|
|
|
66
67
|
import { useRememberedFlag } from '../../hooks/use-remembered-flag.js';
|
|
67
68
|
const HEADER_LINK_CLASS = 'shrink-0 rounded-sm type-label text-foreground underline underline-offset-4 outline-none ' +
|
|
68
69
|
'hover:decoration-2 focus-visible:ring-3 focus-visible:ring-ring/50';
|
|
69
|
-
export function WidgetCard({ id, title, icon: Icon, headingLevel = 2, link, isLoading, error, onRetry, isEmpty, emptyMessage, skeletonRows = 3, collapsible = false, defaultCollapsed = false, storageKey, summary, emptySummary, children, className, }) {
|
|
70
|
+
export function WidgetCard({ id, title, icon: Icon, headingLevel = 2, link, isLoading, error, onRetry, isEmpty, emptyMessage, empty, skeletonRows = 3, collapsible = false, defaultCollapsed = false, storageKey, summary, emptySummary, children, className, }) {
|
|
70
71
|
const headingId = useId();
|
|
71
72
|
const contentId = useId();
|
|
72
73
|
const summaryId = useId();
|
|
@@ -93,7 +94,7 @@ export function WidgetCard({ id, title, icon: Icon, headingLevel = 2, link, isLo
|
|
|
93
94
|
return (_jsx("section", { id: id, "aria-labelledby": headingId, "data-slot": "widget-card", "data-state": state, "data-collapsed": collapsed || undefined, className: cn('min-w-0 self-start', className), children: _jsxs(Card, { className: cn('glow-edge density-compact:[--card-spacing:--spacing(3)]', collapsed && 'pb-0'), children: [_jsxs(CardHeader, { onClick: onHeaderClick, className: cn('flex items-center justify-between gap-3', inAccordion && 'cursor-pointer select-none', collapsed && 'border-b-0'), children: [_jsxs(Heading, { id: headingId, className: "flex min-w-0 items-center gap-2 type-section-title text-foreground", children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground" }), _jsx("span", { className: "truncate", children: title })] }), (link || foldable || summaryShown) && (_jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [summaryShown && (_jsx("span", { id: summaryId, "data-slot": "widget-card-summary", className: "mr-2 flex items-center", children: _jsx(WidgetCardSummary, { state: state, summary: summary, emptySummary: emptySummary }) })), link?.href !== undefined ? (_jsxs("a", { href: link.href, target: "_blank", rel: "noreferrer", "aria-describedby": headingId, className: cn(HEADER_LINK_CLASS, 'inline-flex items-center gap-1'), children: [link.label, _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3 shrink-0 text-muted-foreground" }), _jsx("span", { className: "sr-only", children: " (opens in a new tab)" })] })) : (link && (_jsx(Link, { to: link.to, "aria-describedby": headingId, className: HEADER_LINK_CLASS, children: link.label }))), foldable && (_jsx(Button, { variant: "ghost", size: "icon-sm", "aria-labelledby": headingId, "aria-describedby": summaryShown ? summaryId : undefined, "aria-expanded": !collapsed, "aria-controls": contentId, onClick: toggle,
|
|
94
95
|
// The button's own open look (a filled background) would
|
|
95
96
|
// read as pressed: the chevron says it.
|
|
96
|
-
className: "-my-1 -mr-1.5 aria-expanded:not-hover:bg-transparent", children: _jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('transition-transform', collapsed && '-rotate-90') }) }))] }))] }), _jsx(CardContent, { id: contentId, hidden: collapsed, "aria-busy": state === 'loading' || undefined, children: error ? (_jsx(ErrorState, { error: error, onRetry: onRetry, size: "compact" })) : state === 'loading' ? (_jsx(WidgetListSkeleton, { rows: skeletonRows })) : state === 'empty' ? (_jsx("p", { "data-state": "empty", className: "py-2 type-body text-muted-foreground", children: emptyMessage })) : (children) })] }) }));
|
|
97
|
+
className: "-my-1 -mr-1.5 aria-expanded:not-hover:bg-transparent", children: _jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('transition-transform', collapsed && '-rotate-90') }) }))] }))] }), _jsx(CardContent, { id: contentId, hidden: collapsed, "aria-busy": state === 'loading' || undefined, children: error ? (_jsx(ErrorState, { error: error, onRetry: onRetry, size: "compact" })) : state === 'loading' ? (_jsx(WidgetListSkeleton, { rows: skeletonRows })) : state === 'empty' ? (empty ? (_jsx(PartEmpty, { ...empty })) : (_jsx("p", { "data-state": "empty", className: "py-2 type-body text-muted-foreground", children: emptyMessage }))) : (children) })] }) }));
|
|
97
98
|
}
|
|
98
99
|
// A folded card's one value, by state. Loading's skeleton is about one
|
|
99
100
|
// number wide; an error's dash says "Couldn't load" to a screen reader,
|
|
@@ -7,14 +7,30 @@ export type TableUrlStateOptions = {
|
|
|
7
7
|
* useTableLayout remembers a layout. Without one it lives only in the URL.
|
|
8
8
|
*/
|
|
9
9
|
groupStorageKey?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The rows-per-page choices, for DataTable's `pageSizes`: `[25, 50, 100]`
|
|
12
|
+
* unless set. A size from the URL or storage that isn't one of them is
|
|
13
|
+
* ignored.
|
|
14
|
+
*/
|
|
15
|
+
pageSizes?: readonly number[];
|
|
16
|
+
/** The rows per page until one is picked: 50 unless set (one of `pageSizes`). */
|
|
17
|
+
defaultPageSize?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Where the rows per page are remembered on this device, one key per table
|
|
20
|
+
* (`"my-app:tasks:page-size"`). Without one the pick lives only in the URL.
|
|
21
|
+
*/
|
|
22
|
+
pageSizeStorageKey?: string;
|
|
10
23
|
};
|
|
11
|
-
export declare function useTableUrlState<F extends string, M extends string = never, V extends string = never>(filterNames: readonly F[], multiFilterNames?: readonly M[], views?: Readonly<Record<V, TableView<NoInfer<F>, NoInfer<M>>>>, { groupStorageKey }?: TableUrlStateOptions): {
|
|
24
|
+
export declare function useTableUrlState<F extends string, M extends string = never, V extends string = never>(filterNames: readonly F[], multiFilterNames?: readonly M[], views?: Readonly<Record<V, TableView<NoInfer<F>, NoInfer<M>>>>, { groupStorageKey, pageSizes, defaultPageSize, pageSizeStorageKey, }?: TableUrlStateOptions): {
|
|
12
25
|
page: number;
|
|
13
26
|
sorting: SortingState;
|
|
14
27
|
filters: Record<F, string>;
|
|
15
28
|
multiFilters: Record<M, string[]>;
|
|
16
29
|
activeView: V | null;
|
|
17
30
|
grouping: string;
|
|
31
|
+
pageSize: number;
|
|
32
|
+
pageSizes: readonly number[];
|
|
33
|
+
setPageSize: (next: number) => void;
|
|
18
34
|
setGrouping: (next: string) => void;
|
|
19
35
|
setPage: (next: number) => void;
|
|
20
36
|
setSorting: (next: SortingState) => void;
|
|
@@ -23,3 +39,5 @@ export declare function useTableUrlState<F extends string, M extends string = ne
|
|
|
23
39
|
setMultiFilter: (name: M, values: string[]) => void;
|
|
24
40
|
applyView: (view: TableView<F, M>) => void;
|
|
25
41
|
};
|
|
42
|
+
/** The rows per page: the URL's if it's one of the choices, then the remembered one, then the default. */
|
|
43
|
+
export declare function resolvePageSize(pageSizes: readonly number[], fromUrl: string | null, remembered: string | null, defaultPageSize: number): number;
|
|
@@ -2,6 +2,7 @@ import { useCallback, useSyncExternalStore } from 'react';
|
|
|
2
2
|
import { useSearchParams } from 'react-router';
|
|
3
3
|
import { activeViewOf, applyUrlChanges, serializeSort, viewToUrlChanges, } from './table-url-changes.js';
|
|
4
4
|
import { browserStore } from './use-table-layout.js';
|
|
5
|
+
const DEFAULT_PAGE_SIZES = [25, 50, 100];
|
|
5
6
|
// A table's page, sort and filters, kept in the URL query string
|
|
6
7
|
// (`?page=2&sort=name:asc&search=mouse&tags=fragile&tags=bulky`) instead of
|
|
7
8
|
// component state, so they survive going to the edit form and back, a
|
|
@@ -17,6 +18,11 @@ import { browserStore } from './use-table-layout.js';
|
|
|
17
18
|
// counts as active); pass that view's `columns` to DataTable. A view is
|
|
18
19
|
// pressed with applyView().
|
|
19
20
|
//
|
|
21
|
+
// `pageSize` is the rows per page, for the query and DataTable: `?size=` in
|
|
22
|
+
// the URL, then the one remembered under `pageSizeStorageKey`, then
|
|
23
|
+
// `defaultPageSize`; `setPageSize` (DataTable's `onPageSizeChange`) picks
|
|
24
|
+
// one and returns to page 1. `pageSizes` is the menu's choices.
|
|
25
|
+
//
|
|
20
26
|
// `grouping` is DataTable's: a grouping's id, or '' for None. It's
|
|
21
27
|
// `?group=` in the URL, then the one remembered under `groupStorageKey`,
|
|
22
28
|
// then None. Like the sort it doesn't change which rows are shown, so it
|
|
@@ -24,10 +30,11 @@ import { browserStore } from './use-table-layout.js';
|
|
|
24
30
|
// names a `group` sets it when pressed.
|
|
25
31
|
//
|
|
26
32
|
// Every setter is one update(), and must stay one: see setFilters.
|
|
27
|
-
export function useTableUrlState(filterNames, multiFilterNames = [], views = {}, { groupStorageKey } = {}) {
|
|
33
|
+
export function useTableUrlState(filterNames, multiFilterNames = [], views = {}, { groupStorageKey, pageSizes = DEFAULT_PAGE_SIZES, defaultPageSize = 50, pageSizeStorageKey, } = {}) {
|
|
28
34
|
const [params, setParams] = useSearchParams();
|
|
29
|
-
const
|
|
30
|
-
const
|
|
35
|
+
const rememberedPageSize = useRemembered(pageSizeStorageKey);
|
|
36
|
+
const pageSize = resolvePageSize(pageSizes, params.get('size'), rememberedPageSize, defaultPageSize);
|
|
37
|
+
const rememberedGrouping = useRemembered(groupStorageKey);
|
|
31
38
|
const grouping = params.get('group') ?? rememberedGrouping ?? '';
|
|
32
39
|
const rememberGrouping = (next) => {
|
|
33
40
|
if (groupStorageKey !== undefined)
|
|
@@ -49,6 +56,13 @@ export function useTableUrlState(filterNames, multiFilterNames = [], views = {},
|
|
|
49
56
|
multiFilters,
|
|
50
57
|
activeView,
|
|
51
58
|
grouping,
|
|
59
|
+
pageSize,
|
|
60
|
+
pageSizes,
|
|
61
|
+
setPageSize: (next) => {
|
|
62
|
+
if (pageSizeStorageKey !== undefined)
|
|
63
|
+
browserStore.set(pageSizeStorageKey, String(next));
|
|
64
|
+
update({ size: next === defaultPageSize ? null : String(next), page: null });
|
|
65
|
+
},
|
|
52
66
|
setGrouping: (next) => {
|
|
53
67
|
rememberGrouping(next);
|
|
54
68
|
update({ group: next || null });
|
|
@@ -73,3 +87,17 @@ export function useTableUrlState(filterNames, multiFilterNames = [], views = {},
|
|
|
73
87
|
},
|
|
74
88
|
};
|
|
75
89
|
}
|
|
90
|
+
// A value remembered on this device under `key`, or null (none, or no key).
|
|
91
|
+
function useRemembered(key) {
|
|
92
|
+
const subscribe = useCallback((listener) => (key === undefined ? () => { } : browserStore.subscribe(key, listener)), [key]);
|
|
93
|
+
return useSyncExternalStore(subscribe, () => (key === undefined ? null : browserStore.get(key)), () => null);
|
|
94
|
+
}
|
|
95
|
+
/** The rows per page: the URL's if it's one of the choices, then the remembered one, then the default. */
|
|
96
|
+
export function resolvePageSize(pageSizes, fromUrl, remembered, defaultPageSize) {
|
|
97
|
+
for (const candidate of [fromUrl, remembered]) {
|
|
98
|
+
const size = candidate === null ? NaN : Number(candidate);
|
|
99
|
+
if (pageSizes.includes(size))
|
|
100
|
+
return size;
|
|
101
|
+
}
|
|
102
|
+
return defaultPageSize;
|
|
103
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,13 @@ export { SessionStage, SessionView, sessionStageLit, sessionStageMain, sessionSt
|
|
|
49
49
|
export { AllowReminders, type AllowRemindersProps } from './components/app/allow-reminders.js';
|
|
50
50
|
export { StageCircle, type StageCircleProps, type StageCircleStage, type StageCircleTone, } from './components/app/stage-circle.js';
|
|
51
51
|
export { Notice, type NoticeProps, type NoticeTone } from './components/app/notice.js';
|
|
52
|
+
export { ValueList, type ValueListItem, type ValueListProps } from './components/app/value-list.js';
|
|
53
|
+
export { ListHeader, type ListHeaderAction, type ListHeaderLink, type ListHeaderProps, } from './components/app/list-header.js';
|
|
54
|
+
export { Timeline, type TimelineItem, type TimelineProps } from './components/app/timeline.js';
|
|
55
|
+
export { NeedsYou, type NeedsYouItem, type NeedsYouProps, type NeedsYouTone } from './components/app/needs-you.js';
|
|
56
|
+
export { Freshness, type FreshnessProps } from './components/app/freshness.js';
|
|
57
|
+
export { isStale } from './lib/freshness.js';
|
|
58
|
+
export { PartEmpty, type PartEmptyAction, type PartEmptyProps, type PartEmptyState } from './components/app/part-empty.js';
|
|
52
59
|
export { SourceCredit, type Source, type SourceCreditProps } from './components/app/source-credit.js';
|
|
53
60
|
export { ProgressRing, type ProgressRingProps } from './components/app/progress-ring.js';
|
|
54
61
|
export { LineChart, type LineChartMark, type LineChartPoint, type LineChartProps, } from './components/app/line-chart.js';
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,13 @@ export { SessionStage, SessionView, sessionStageLit, sessionStageMain, sessionSt
|
|
|
51
51
|
export { AllowReminders } from './components/app/allow-reminders.js';
|
|
52
52
|
export { StageCircle, } from './components/app/stage-circle.js';
|
|
53
53
|
export { Notice } from './components/app/notice.js';
|
|
54
|
+
export { ValueList } from './components/app/value-list.js';
|
|
55
|
+
export { ListHeader, } from './components/app/list-header.js';
|
|
56
|
+
export { Timeline } from './components/app/timeline.js';
|
|
57
|
+
export { NeedsYou } from './components/app/needs-you.js';
|
|
58
|
+
export { Freshness } from './components/app/freshness.js';
|
|
59
|
+
export { isStale } from './lib/freshness.js';
|
|
60
|
+
export { PartEmpty } from './components/app/part-empty.js';
|
|
54
61
|
export { SourceCredit } from './components/app/source-credit.js';
|
|
55
62
|
export { ProgressRing } from './components/app/progress-ring.js';
|
|
56
63
|
export { LineChart, } from './components/app/line-chart.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** A plain day as local midnight, anything else as the instant it names; null when it isn't a date. */
|
|
2
|
+
export declare function toDate(value: Date | string): Date | null;
|
|
3
|
+
/** "Aug 2" this year, "Aug 2, 2025" before it; '' when it isn't a date. */
|
|
4
|
+
export declare function showDate(value: Date | string, now: Date): string;
|
|
5
|
+
/** True once `staleAfter` is before `now`. Never for a missing or unreadable date. */
|
|
6
|
+
export declare function isStale(staleAfter: Date | string | undefined, now?: Date): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The rules under <Freshness>: reading a date the way the wire writes it,
|
|
2
|
+
// showing it short, and saying whether a limit has passed. A plain day
|
|
3
|
+
// ('YYYY-MM-DD') is a calendar day, never shifted by the time zone; any
|
|
4
|
+
// other string is an instant (an ISO timestamp).
|
|
5
|
+
import { formatPlainDate } from './plain-date.js';
|
|
6
|
+
const PLAIN_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
7
|
+
/** A plain day as local midnight, anything else as the instant it names; null when it isn't a date. */
|
|
8
|
+
export function toDate(value) {
|
|
9
|
+
if (value instanceof Date)
|
|
10
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
11
|
+
if (PLAIN_DAY.test(value)) {
|
|
12
|
+
const [year, month, day] = value.split('-').map(Number);
|
|
13
|
+
return new Date(year, month - 1, day);
|
|
14
|
+
}
|
|
15
|
+
const parsed = new Date(value);
|
|
16
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
|
17
|
+
}
|
|
18
|
+
/** "Aug 2" this year, "Aug 2, 2025" before it; '' when it isn't a date. */
|
|
19
|
+
export function showDate(value, now) {
|
|
20
|
+
const date = toDate(value);
|
|
21
|
+
if (!date)
|
|
22
|
+
return '';
|
|
23
|
+
const sameYear = date.getFullYear() === now.getFullYear();
|
|
24
|
+
const options = sameYear
|
|
25
|
+
? { month: 'short', day: 'numeric' }
|
|
26
|
+
: { month: 'short', day: 'numeric', year: 'numeric' };
|
|
27
|
+
if (typeof value === 'string' && PLAIN_DAY.test(value))
|
|
28
|
+
return formatPlainDate(value, options);
|
|
29
|
+
return date.toLocaleDateString(undefined, options);
|
|
30
|
+
}
|
|
31
|
+
/** True once `staleAfter` is before `now`. Never for a missing or unreadable date. */
|
|
32
|
+
export function isStale(staleAfter, now = new Date()) {
|
|
33
|
+
if (staleAfter === undefined || staleAfter === '')
|
|
34
|
+
return false;
|
|
35
|
+
const limit = toDate(staleAfter);
|
|
36
|
+
return limit !== null && limit.getTime() < now.getTime();
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.84.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/styles/theme.css
CHANGED
|
@@ -672,6 +672,11 @@
|
|
|
672
672
|
6.75:1. In dark the usual muted already clears it (6.61:1). */
|
|
673
673
|
--table-highlight: color-mix(in srgb, var(--info) 10%, var(--background));
|
|
674
674
|
--table-highlight-muted-foreground: var(--gray-600);
|
|
675
|
+
/* A body row under the pointer (DataTable, 4.83): the muted fill, solid
|
|
676
|
+
so pinned cells can wear it. Muted text measures 4.34:1 on it, so the
|
|
677
|
+
row takes --table-highlight-muted-foreground's darker grey (7.0:1).
|
|
678
|
+
In dark the usual muted clears it (5.9:1); a palette's dim, 5.8. */
|
|
679
|
+
--table-hover: var(--muted);
|
|
675
680
|
--border: var(--gray-200);
|
|
676
681
|
--input: var(--gray-200);
|
|
677
682
|
--ring: var(--gray-400);
|
|
@@ -962,6 +967,7 @@
|
|
|
962
967
|
--category-12-depth-5-foreground: var(--black);
|
|
963
968
|
--table-stripe: color-mix(in srgb, var(--muted) 40%, var(--background));
|
|
964
969
|
--table-highlight: color-mix(in srgb, var(--info) 20%, var(--background));
|
|
970
|
+
--table-hover: var(--muted);
|
|
965
971
|
--table-highlight-muted-foreground: var(--gray-400); /* the usual muted: not var(--muted-foreground), which the row redefines from this */
|
|
966
972
|
--border: var(--white-a10);
|
|
967
973
|
--input: var(--white-a15);
|