@tristan2828/ui-foundation 4.145.0 → 4.146.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.
@@ -3,50 +3,51 @@
3
3
  <!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
4
4
  ## Index
5
5
 
6
- - [Palettes](#palettes) · lines 59–142
7
- - [Glow](#glow) · lines 144–163
8
- - [Semantic tones](#semantic-tones) · lines 165–193
9
- - [The three badge styles](#the-three-badge-styles) · lines 195–212
10
- - [Status marks](#status-marks) · lines 214–257
11
- - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 259–288
12
- - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 290–301
13
- - [Logos and brand marks](#logos-and-brand-marks) · lines 303–343
14
- - [Emoji](#emoji) · lines 345–385
15
- - [Categorical colour](#categorical-colour) · lines 387–452
16
- - [Heat scale](#heat-scale) · lines 454–506
17
- - [Depth ramps](#depth-ramps) · lines 508–575
18
- - [A stored colour](#a-stored-colour) · lines 577–624
19
- - [Shapes and sizes](#shapes-and-sizes) · lines 626–647
20
- - [Typography](#typography) · lines 649–819
21
- - [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 683–715
22
- - [Written text (notes)](#written-text-notes) · lines 717–819
23
- - [Density](#density) · lines 821–950
24
- - [Rows on this device](#rows-on-this-device) · lines 894–922
25
- - [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 924–950
26
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 952–1064
27
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1066–1138
28
- - [Notices](#notices) · lines 1140–1167
29
- - [A value over time](#a-value-over-time) · lines 1169–1299
30
- - [Several values over time](#several-values-over-time) · lines 1218–1256
31
- - [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1258–1299
32
- - [A list as a board](#a-list-as-a-board) · lines 1301–1411
33
- - [Order, groups and the header](#order-groups-and-the-header) · lines 1354–1411
34
- - [A list as cards](#a-list-as-cards) · lines 1413–1460
35
- - [Images full screen](#images-full-screen) · lines 1462–1508
36
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1510–1546
37
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1548–1584
38
- - [A few equal things](#a-few-equal-things) · lines 1586–1701
39
- - [An overview page](#an-overview-page) · lines 1703–1768
40
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1770–1833
41
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1835–1922
42
- - [Picking at random](#picking-at-random) · lines 1924–1955
43
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1957–2024
44
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 2026–2045
45
- - [A quick add line](#a-quick-add-line) · lines 2047–2075
46
- - [A date field's quick picks](#a-date-fields-quick-picks) · lines 2077–2101
47
- - [A month calendar](#a-month-calendar) · lines 2103–2135
48
- - [A settings page](#a-settings-page) · lines 2137–2194
49
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2196–2255
6
+ - [Palettes](#palettes) · lines 60–143
7
+ - [Glow](#glow) · lines 145–164
8
+ - [Semantic tones](#semantic-tones) · lines 166–194
9
+ - [The three badge styles](#the-three-badge-styles) · lines 196–213
10
+ - [Status marks](#status-marks) · lines 215–258
11
+ - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 260–289
12
+ - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 291–302
13
+ - [Logos and brand marks](#logos-and-brand-marks) · lines 304–344
14
+ - [Emoji](#emoji) · lines 346–386
15
+ - [Categorical colour](#categorical-colour) · lines 388–453
16
+ - [Heat scale](#heat-scale) · lines 455–507
17
+ - [Depth ramps](#depth-ramps) · lines 509–576
18
+ - [A stored colour](#a-stored-colour) · lines 578–625
19
+ - [Shapes and sizes](#shapes-and-sizes) · lines 627–648
20
+ - [Typography](#typography) · lines 650–820
21
+ - [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 684–716
22
+ - [Written text (notes)](#written-text-notes) · lines 718–820
23
+ - [Density](#density) · lines 822–951
24
+ - [Rows on this device](#rows-on-this-device) · lines 895–923
25
+ - [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 925–951
26
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 953–1065
27
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1067–1139
28
+ - [Notices](#notices) · lines 1141–1168
29
+ - [A value over time](#a-value-over-time) · lines 1170–1300
30
+ - [Several values over time](#several-values-over-time) · lines 1219–1257
31
+ - [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1259–1300
32
+ - [A list as a board](#a-list-as-a-board) · lines 1302–1412
33
+ - [Order, groups and the header](#order-groups-and-the-header) · lines 1355–1412
34
+ - [A list as cards](#a-list-as-cards) · lines 1414–1461
35
+ - [Images full screen](#images-full-screen) · lines 1463–1509
36
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1511–1547
37
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1549–1585
38
+ - [A few equal things](#a-few-equal-things) · lines 1587–1702
39
+ - [An overview page](#an-overview-page) · lines 1704–1769
40
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1771–1834
41
+ - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1836–1923
42
+ - [Picking at random](#picking-at-random) · lines 1925–1956
43
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1958–2025
44
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 2027–2046
45
+ - [A quick add line](#a-quick-add-line) · lines 2048–2076
46
+ - [A date field's quick picks](#a-date-fields-quick-picks) · lines 2078–2102
47
+ - [A few choices, then the month](#a-few-choices-then-the-month) · lines 2104–2130
48
+ - [A month calendar](#a-month-calendar) · lines 2132–2164
49
+ - [A settings page](#a-settings-page) · lines 2166–2223
50
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2225–2284
50
51
 
51
52
  <!-- /index -->
52
53
 
@@ -2100,6 +2101,34 @@ days over the calendar, for a due day picked in one press:
2100
2101
  ahead; a day something happened (finished, bought) has no use for
2101
2102
  them.
2102
2103
 
2104
+ ## A few choices, then the month
2105
+
2106
+ A row's "move to" picker (a to-do's ⋯: the parts of the day, Tomorrow,
2107
+ or any day) is the package's `DateChoices`, never a `DropdownMenu` with a
2108
+ calendar in it. A calendar's grid can't sit inside `role="menu"`, and a
2109
+ menu's arrows never reach it.
2110
+
2111
+ - **The look is DateField's popup:** the app's `choices` at the top, under
2112
+ their `choicesLabel` heading ("Move to"), each a ghost button with its
2113
+ label on the left and its `value` muted on the right (a start time, "Thu,
2114
+ Nov 26"), over a `border-border` rule. Then the month, on the day the
2115
+ thing sits on (`value`), with today ringed (`today`, the app's own day,
2116
+ the browser's when left out). A choice that can't be picked now (a block
2117
+ that has ended) is `disabled`: shown, greyed, skipped by Tab.
2118
+ - **It's a dialog named for what it moves** (`label`, "Move Water the
2119
+ plants"), opened from the app's own `trigger`. It opens on the first
2120
+ choice that can be pressed, or on the month's day when there are none.
2121
+ Tab goes through the choices, then the month's buttons and its day,
2122
+ where the arrows move a day or a week. Escape closes, and focus goes
2123
+ back to the trigger.
2124
+ - **A choice runs its own `onSelect`; a day picked runs `onPick`** with
2125
+ its `'YYYY-MM-DD'`. Either closes the popup first, so a row that moves
2126
+ away leaves nothing open behind it. Each choice is named for its label
2127
+ and value ("Tomorrow, Thu, Nov 26"), as the quick picks are.
2128
+ - **DateField's popup shares its parts:** its quick picks are the same
2129
+ rows, its month the same calendar. A field still opens on the day, with
2130
+ its picks before it; a picker opens on its first choice.
2131
+
2103
2132
  ## A month calendar
2104
2133
 
2105
2134
  A month of days holding the app's dated things (events, visits): the
@@ -0,0 +1,63 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ import { type PlainDate } from '../../lib/plain-date.js';
3
+ import type { WeekdayCode } from '../../lib/recurrence.js';
4
+ export type DateChoice = {
5
+ /** Its words, on the left: "Morning", "Tomorrow". Title Case. */
6
+ label: string;
7
+ /** What it means, muted on the right: a start time, a day ("Thu, Nov 26"). */
8
+ value?: string;
9
+ /** Shown, greyed and not pressable: a block that has ended. */
10
+ disabled?: boolean;
11
+ /** Pressed: the popup closes, then this runs. */
12
+ onSelect: () => void;
13
+ };
14
+ export type DateChoicesProps = {
15
+ /**
16
+ * The button that opens it, as a Base UI `render` element (`<Button
17
+ * size="icon-sm" variant="ghost" aria-label="Move Water the plants" />`),
18
+ * with `children` inside it.
19
+ */
20
+ trigger: ReactElement;
21
+ children?: ReactNode;
22
+ /** The popup's name, read when it opens: "Move Water the plants". */
23
+ label: string;
24
+ /** The rows' heading, shown over them and naming their group: "Move to". */
25
+ choicesLabel?: string;
26
+ choices?: readonly DateChoice[];
27
+ /** The day it's on now, `'YYYY-MM-DD'`: marked in the calendar, whose month opens on it. */
28
+ value?: PlainDate;
29
+ /**
30
+ * Today as the app counts it (a day that rolls over at 4 AM, say), ringed
31
+ * in the calendar. Defaults to the browser's today.
32
+ */
33
+ today?: PlainDate;
34
+ /** A day picked in the calendar, `'YYYY-MM-DD'`. The popup closes first. */
35
+ onPick: (day: PlainDate) => void;
36
+ /** The day the calendar's weeks start on (`'MO'` to `'SU'`; Monday when left out). */
37
+ weekStart?: WeekdayCode;
38
+ /** Where it lines up with the trigger. Defaults to `'end'`, as a row's ⋯ menu does. */
39
+ align?: 'start' | 'center' | 'end';
40
+ open?: boolean;
41
+ onOpenChange?: (open: boolean) => void;
42
+ className?: string;
43
+ };
44
+ export declare function DateChoices({ trigger, children, label, choicesLabel, choices, value, today, onPick, weekStart, align, open: givenOpen, onOpenChange, className, }: DateChoicesProps): import("react").JSX.Element;
45
+ /**
46
+ * The rows over a date popup's calendar, DateField's quick picks among
47
+ * them: ghost buttons in a named group, each its label on the left and its
48
+ * value muted on the right, named for both ("Tomorrow, Thu, Nov 26").
49
+ */
50
+ export declare function DateChoiceRows({ label, showLabel, choices, slot, }: {
51
+ label?: string;
52
+ /** The heading over the rows; `false` names the group without showing it (Quick Picks). */
53
+ showLabel?: boolean;
54
+ choices: readonly DateChoice[];
55
+ slot?: string;
56
+ }): import("react").JSX.Element | null;
57
+ /** A date popup's month: the day it's on marked, today ringed, a pick given as `'YYYY-MM-DD'`. */
58
+ export declare function DateChoiceCalendar({ value, today, weekStart, onPick, }: {
59
+ value?: PlainDate;
60
+ today?: PlainDate;
61
+ weekStart?: WeekdayCode;
62
+ onPick: (day: PlainDate) => void;
63
+ }): import("react").JSX.Element;
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A few choices, then the month calendar, opened from any trigger: a
3
+ // "move to" picker in DateField's look. The app gives its rows (a label,
4
+ // its value muted on the right, disabled or not) and the day the thing
5
+ // sits on; a row runs its own `onSelect` and a day picked in the calendar
6
+ // runs `onPick`, and either closes the popup.
7
+ //
8
+ // It is a dialog, never a menu: a calendar's grid can't sit inside a
9
+ // `role="menu"`, whose children are menu items. So the rows are buttons
10
+ // in a named group and the keyboard is DateField's: Tab goes through the
11
+ // rows, then the calendar (its month buttons, then its day, where the
12
+ // arrows move), Escape closes and focus goes back to the trigger. It
13
+ // opens on the first row that can be pressed, or on the calendar's day
14
+ // when there is none.
15
+ //
16
+ // DateField's own popup is built from the same parts: its quick picks are
17
+ // `DateChoiceRows`, and its calendar is `DateChoiceCalendar`.
18
+ import { useId, useRef, useState } from 'react';
19
+ import { cn } from 'cn';
20
+ import { Button } from '../ui/button.js';
21
+ import { Calendar } from '../ui/calendar.js';
22
+ import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover.js';
23
+ import { localToPlainDate, plainDateToLocal } from '../../lib/plain-date.js';
24
+ export function DateChoices({ trigger, children, label, choicesLabel, choices = [], value, today, onPick, weekStart, align = 'end', open: givenOpen, onOpenChange, className, }) {
25
+ const [ownOpen, setOwnOpen] = useState(false);
26
+ const open = givenOpen ?? ownOpen;
27
+ const popup = useRef(null);
28
+ const changeOpen = (next) => {
29
+ setOwnOpen(next);
30
+ onOpenChange?.(next);
31
+ };
32
+ // Closed first, then the app's own work: a row that moves the thing away
33
+ // (and unmounts the trigger) leaves nothing open behind it.
34
+ const close = (then) => {
35
+ changeOpen(false);
36
+ then();
37
+ };
38
+ return (_jsxs(Popover, { open: open, onOpenChange: changeOpen, children: [_jsx(PopoverTrigger, { render: trigger, children: children }), _jsxs(PopoverContent, { ref: popup, align: align, className: cn('w-auto p-0', className), "data-slot": "date-choices", "aria-label": label, initialFocus: () => popup.current?.querySelector('[data-slot="date-choice"]:not(:disabled)') ??
39
+ popup.current?.querySelector('button[data-day][tabindex="0"]') ??
40
+ true, children: [_jsx(DateChoiceRows, { label: choicesLabel, choices: choices.map((choice) => ({ ...choice, onSelect: () => close(choice.onSelect) })) }), _jsx(DateChoiceCalendar, { value: value, today: today, weekStart: weekStart, onPick: (day) => close(() => onPick(day)) })] })] }));
41
+ }
42
+ /**
43
+ * The rows over a date popup's calendar, DateField's quick picks among
44
+ * them: ghost buttons in a named group, each its label on the left and its
45
+ * value muted on the right, named for both ("Tomorrow, Thu, Nov 26").
46
+ */
47
+ export function DateChoiceRows({ label, showLabel = true, choices, slot = 'date-choices-rows', }) {
48
+ const headingId = useId();
49
+ if (choices.length === 0)
50
+ return null;
51
+ const shown = label && showLabel;
52
+ return (_jsxs("div", { role: "group", "aria-label": shown ? undefined : label, "aria-labelledby": shown ? headingId : undefined, "data-slot": slot, className: "flex flex-col gap-0.5 border-b border-border p-2", children: [shown && (_jsx("div", { id: headingId, className: "px-3 py-1 text-xs font-medium text-muted-foreground", children: label })), choices.map((choice) => (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", "data-slot": "date-choice", disabled: choice.disabled, className: "w-full justify-between gap-4 font-normal", "aria-label": choice.value ? `${choice.label}, ${choice.value}` : choice.label, onClick: choice.onSelect, children: [_jsx("span", { children: choice.label }), choice.value && _jsx("span", { className: "text-muted-foreground tabular-nums", children: choice.value })] }, choice.label)))] }));
53
+ }
54
+ // Calendar's `weekStartsOn` by code. Left out, it's Calendar's own default (Monday).
55
+ const WEEK_STARTS_ON = { SU: 0, MO: 1, TU: 2, WE: 3, TH: 4, FR: 5, SA: 6 };
56
+ /** A date popup's month: the day it's on marked, today ringed, a pick given as `'YYYY-MM-DD'`. */
57
+ export function DateChoiceCalendar({ value, today, weekStart, onPick, }) {
58
+ const selected = value ? plainDateToLocal(value) : undefined;
59
+ return (_jsx(Calendar, { mode: "single",
60
+ // Picking the chosen day again keeps it (and closes), never unsets it: Clear does that.
61
+ required: true, selected: selected, defaultMonth: selected, today: today ? plainDateToLocal(today) : undefined, weekStartsOn: weekStart && WEEK_STARTS_ON[weekStart], onSelect: (date) => onPick(localToPlainDate(date)) }));
62
+ }
@@ -24,21 +24,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  // week start), or an app passes its own list. Each is a button named for
25
25
  // its words and the day it sets ("Next Week, Mon, Nov 30"); pressing one
26
26
  // sets that day and closes, as a day picked in the calendar does. Off
27
- // unless asked for.
27
+ // unless asked for. The picks and the calendar are DateChoices' parts, the
28
+ // same rows and month an app's own "move to" picker shows.
28
29
  import { useId, useRef, useState } from 'react';
29
30
  import { CalendarIcon } from 'lucide-react';
30
31
  import { cn } from 'cn';
31
32
  import { Button } from '../ui/button.js';
32
- import { Calendar } from '../ui/calendar.js';
33
33
  import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '../ui/input-group.js';
34
34
  import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover.js';
35
35
  import { DATE_QUICK_PICKS } from '../../lib/date-quick-picks.js';
36
- import { formatPlainDate, localToPlainDate, parsePlainDate, plainDateExamples, plainDateToLocal, unreadableDateMessage, } from '../../lib/plain-date.js';
36
+ import { formatPlainDate, localToPlainDate, parsePlainDate, plainDateExamples, unreadableDateMessage, } from '../../lib/plain-date.js';
37
+ import { DateChoiceCalendar, DateChoiceRows } from './date-choices.js';
37
38
  export function DateField({ typing = true, onProblem, ...props }) {
38
39
  return typing ? _jsx(TypedDate, { ...props, onProblem: onProblem }) : _jsx(DateButton, { ...props });
39
40
  }
40
- // Calendar's `weekStartsOn` by code. Left out, it's Calendar's own default (Monday).
41
- const WEEK_STARTS_ON = { SU: 0, MO: 1, TU: 2, WE: 3, TH: 4, FR: 5, SA: 6 };
42
41
  // The quick picks over the calendar, each named for its words and its day,
43
42
  // counted from the browser's own today when the calendar opens.
44
43
  function QuickPicks({ picks, weekStart = 'MO', locale, onPick, }) {
@@ -46,10 +45,9 @@ function QuickPicks({ picks, weekStart = 'MO', locale, onPick, }) {
46
45
  if (list.length === 0)
47
46
  return null;
48
47
  const today = localToPlainDate(new Date());
49
- return (_jsx("div", { role: "group", "aria-label": "Quick Picks", "data-slot": "date-field-quick-picks", className: "flex flex-col gap-0.5 border-b border-border p-2", children: list.map((pick) => {
48
+ return (_jsx(DateChoiceRows, { label: "Quick Picks", showLabel: false, slot: "date-field-quick-picks", choices: list.map((pick) => {
50
49
  const day = pick.day(today, weekStart);
51
- const shown = formatPlainDate(day, { weekday: 'short', month: 'short', day: 'numeric' }, locale);
52
- return (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full justify-between gap-4 font-normal", "aria-label": `${pick.label}, ${shown}`, onClick: () => onPick(day), children: [_jsx("span", { children: pick.label }), _jsx("span", { className: "text-muted-foreground", children: shown })] }, pick.label));
50
+ return { label: pick.label, value: formatPlainDate(day, { weekday: 'short', month: 'short', day: 'numeric' }, locale), onSelect: () => onPick(day) };
53
51
  }) }));
54
52
  }
55
53
  function TypedDate({ id, value, onChange, onPick, onProblem, placeholder, clearable = false, invalid = false, readOnly = false, defaultOpen = false, modal, onOpenChange, format, weekStart, quickPicks, locale, className, 'aria-describedby': describedBy, ...aria }) {
@@ -125,20 +123,16 @@ function TypedDate({ id, value, onChange, onPick, onProblem, placeholder, cleara
125
123
  changeOpen(true);
126
124
  }
127
125
  };
128
- const selected = plainDateToLocal(given);
129
126
  const showProblem = told && problem !== null;
130
127
  return (_jsxs("div", { "data-slot": "date-field", "data-kind": "date", className: cn('flex w-full min-w-0 flex-col gap-1.5', className), children: [_jsxs(InputGroup, { ref: group, children: [_jsx(InputGroupInput, { ref: box, id: id, value: text, onChange: (event) => type(event.target.value), onBlur: settle, onKeyDown: onKeyDown, placeholder: placeholder ?? plainDateExamples(locale), readOnly: readOnly, autoComplete: "off", "aria-invalid": invalid || showProblem || undefined, "aria-describedby": [showProblem ? messageId : null, describedBy].filter(Boolean).join(' ') || undefined, ...aria }), _jsx(InputGroupAddon, { align: "inline-end", children: _jsxs(Popover, { open: open, onOpenChange: changeOpen, modal: modal, children: [_jsx(PopoverTrigger, { render: _jsx(InputGroupButton, { type: "button", size: "icon-xs", variant: "ghost", disabled: readOnly, "aria-label": "Open Calendar" }), children: _jsx(CalendarIcon, { "aria-hidden": "true" }) }), _jsxs(PopoverContent, { ref: popup, anchor: group, align: "start", className: "w-auto p-0", "data-slot": "date-field-calendar", "aria-label": "Calendar",
131
128
  // The day the keyboard starts from (the chosen one, else today).
132
129
  initialFocus: () => popup.current?.querySelector('button[data-day][tabindex="0"]') ?? true,
133
130
  // Back to the box, where typing goes on.
134
- finalFocus: box, children: [_jsx(QuickPicks, { picks: quickPicks, weekStart: weekStart, locale: locale, onPick: pick }), _jsx(Calendar, { mode: "single",
135
- // Picking the chosen day again keeps it (and closes), never unsets it: Clear does that.
136
- required: true, selected: selected, defaultMonth: selected, weekStartsOn: weekStart && WEEK_STARTS_ON[weekStart], onSelect: (date) => pick(localToPlainDate(date)) }), clearable && given && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }) })] }), showProblem && (_jsx("p", { id: messageId, "data-slot": "date-field-problem", className: "type-caption text-destructive-text", children: problem }))] }));
131
+ finalFocus: box, children: [_jsx(QuickPicks, { picks: quickPicks, weekStart: weekStart, locale: locale, onPick: pick }), _jsx(DateChoiceCalendar, { value: given, weekStart: weekStart, onPick: pick }), clearable && given && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }) })] }), showProblem && (_jsx("p", { id: messageId, "data-slot": "date-field-problem", className: "type-caption text-destructive-text", children: problem }))] }));
137
132
  }
138
133
  function DateButton({ id, value, onChange, onPick, placeholder = 'Pick a date', clearable = false, invalid = false, readOnly = false, defaultOpen = false, modal, onOpenChange, format, weekStart, quickPicks, locale, className, ...aria }) {
139
134
  const [open, setOpen] = useState(defaultOpen && !readOnly);
140
135
  const popup = useRef(null);
141
- const selected = plainDateToLocal(value);
142
136
  const shown = formatPlainDate(value, format, locale);
143
137
  const changeOpen = (next) => {
144
138
  if (next && readOnly)
@@ -155,7 +149,5 @@ function DateButton({ id, value, onChange, onPick, placeholder = 'Pick a date',
155
149
  // The day the keyboard starts from (the chosen one, else today):
156
150
  // the one day react-day-picker makes tabbable. The popup would
157
151
  // otherwise take focus itself, past the Calendar's autoFocus.
158
- initialFocus: () => popup.current?.querySelector('button[data-day][tabindex="0"]') ?? true, children: [_jsx(QuickPicks, { picks: quickPicks, weekStart: weekStart, locale: locale, onPick: pick }), _jsx(Calendar, { mode: "single",
159
- // Picking the chosen day again keeps it (and closes), never unsets it: Clear does that.
160
- required: true, selected: selected, defaultMonth: selected, weekStartsOn: weekStart && WEEK_STARTS_ON[weekStart], onSelect: (date) => pick(localToPlainDate(date)) }), clearable && value && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }));
152
+ initialFocus: () => popup.current?.querySelector('button[data-day][tabindex="0"]') ?? true, children: [_jsx(QuickPicks, { picks: quickPicks, weekStart: weekStart, locale: locale, onPick: pick }), _jsx(DateChoiceCalendar, { value: value, weekStart: weekStart, onPick: pick }), clearable && value && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }));
161
153
  }
package/dist/index.d.ts CHANGED
@@ -105,6 +105,7 @@ export { RatingStar, type RatingStarProps, type RatingStarValue } from './compon
105
105
  export { RatingScore, type RatingScoreGlyph, type RatingScoreProps } from './components/app/rating-score.js';
106
106
  export { RatingInput, type RatingInputProps, type RatingInputSource } from './components/app/rating-input.js';
107
107
  export { DateField, type DateFieldProps } from './components/app/date-field.js';
108
+ export { DateChoices, type DateChoice, type DateChoicesProps } from './components/app/date-choices.js';
108
109
  export { addPlainDays, comingWeekday, DATE_QUICK_PICKS, NEXT_WEEK_PICK, THIS_WEEKEND_PICK, TODAY_PICK, TOMORROW_PICK, type DateQuickPick, } from './lib/date-quick-picks.js';
109
110
  export { EmojiField, type EmojiFieldProps } from './components/app/emoji-field.js';
110
111
  export { Emoji, EmojiTile, type EmojiProps, type EmojiTileProps } from './components/app/emoji.js';
package/dist/index.js CHANGED
@@ -115,6 +115,7 @@ export { RatingStar } from './components/app/rating-star.js';
115
115
  export { RatingScore } from './components/app/rating-score.js';
116
116
  export { RatingInput } from './components/app/rating-input.js';
117
117
  export { DateField } from './components/app/date-field.js';
118
+ export { DateChoices } from './components/app/date-choices.js';
118
119
  export { addPlainDays, comingWeekday, DATE_QUICK_PICKS, NEXT_WEEK_PICK, THIS_WEEKEND_PICK, TODAY_PICK, TOMORROW_PICK, } from './lib/date-quick-picks.js';
119
120
  export { EmojiField } from './components/app/emoji-field.js';
120
121
  export { Emoji, EmojiTile } from './components/app/emoji.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.145.0",
3
+ "version": "4.146.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": {