@tristan2828/ui-foundation 6.0.0 → 6.1.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.
@@ -45,10 +45,10 @@
45
45
  - [A quick add line](#a-quick-add-line) · lines 2063–2091
46
46
  - [A date field's quick picks](#a-date-fields-quick-picks) · lines 2093–2117
47
47
  - [A few choices, then the month](#a-few-choices-then-the-month) · lines 2119–2145
48
- - [A month calendar](#a-month-calendar) · lines 2147–2179
49
- - [A settings page](#a-settings-page) · lines 2181–2238
50
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2240–2299
51
- - [A bare shell](#a-bare-shell) · lines 2301–2335
48
+ - [A month calendar](#a-month-calendar) · lines 2147–2180
49
+ - [A settings page](#a-settings-page) · lines 2182–2239
50
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2241–2300
51
+ - [A bare shell](#a-bare-shell) · lines 2302–2336
52
52
 
53
53
  <!-- /index -->
54
54
 
@@ -2156,7 +2156,8 @@ package's `MonthCalendar`. Not a date picker, which is
2156
2156
  - **An item's `emoji`** is drawn before its title, in the cell and the
2157
2157
  day's list (Noto's picture, `size-3.5`, decorative).
2158
2158
  - **The picked day's list is under the month**, every item with its time
2159
- ("All day" without one), its `detail` and a link (`to`). The app's own
2159
+ ("All day" without one; with an `endTime`, the span, "6:30–8:00 PM"),
2160
+ its `detail` and a link (`to`). The app's own
2160
2161
  actions for that day sit beside its heading (`dayActions`, an Add
2161
2162
  button); what picking a day does beyond that is the app's (`onSelect`).
2162
2163
  - **How an item opens its record** is `opens`, DataTable's kinds
@@ -17,6 +17,11 @@ export type MonthCalendarItem = {
17
17
  emoji?: string | null;
18
18
  /** `'HH:MM'`, or none for all day. */
19
19
  time?: string | null;
20
+ /**
21
+ * `'HH:MM'` it ends, the same day: the day's list then shows both
22
+ * ("6:30–8:00 PM"). Ignored without a `time`.
23
+ */
24
+ endTime?: string | null;
20
25
  /** Its dot and mark (design-language.md "Semantic tones"). Defaults to `info`. */
21
26
  tone?: MonthCalendarTone;
22
27
  /** Where its row in the day's list goes (how, `opens`). */
@@ -62,6 +62,24 @@ function clock(time, locale) {
62
62
  const [hour, minute] = time.split(':').map(Number);
63
63
  return new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit', timeZone: 'UTC' }).format(Date.UTC(2001, 0, 1, hour, minute));
64
64
  }
65
+ /**
66
+ * A start and its end in one phrase: "6:30–8:00 PM", "11:00 AM–1:00 PM". The
67
+ * start drops its AM or PM when the end says the same one, in a locale
68
+ * that writes it after the time; elsewhere both keep theirs.
69
+ */
70
+ function clockSpan(start, end, locale) {
71
+ const format = new Intl.DateTimeFormat(locale, { hour: 'numeric', minute: '2-digit', timeZone: 'UTC' });
72
+ const parts = (time) => {
73
+ const [hour, minute] = time.split(':').map(Number);
74
+ return format.formatToParts(Date.UTC(2001, 0, 1, hour, minute));
75
+ };
76
+ const from = parts(start);
77
+ const to = parts(end);
78
+ const period = (list) => list.find((part) => part.type === 'dayPeriod')?.value;
79
+ const shared = from.at(-1)?.type === 'dayPeriod' && period(from) === period(to);
80
+ const text = (list) => list.map((part) => part.value).join('');
81
+ return `${shared ? text(from.slice(0, -1)).trimEnd() : text(from)}–${text(to)}`;
82
+ }
65
83
  /** Monday 0 … Sunday 6. */
66
84
  function weekdayIndex(day) {
67
85
  const [year, month, date] = parts(day);
@@ -164,7 +182,8 @@ export function MonthCalendar({ label, items = [], today, selected, onSelect, mo
164
182
  const count = list.length;
165
183
  return (_jsxs("td", { "data-day": day, "aria-selected": isPicked, "aria-current": isToday ? 'date' : undefined, tabIndex: day === stop ? 0 : -1, onClick: () => pick(day), onKeyDown: (event) => onKeyDown(event, day), className: cn('h-11 cursor-pointer border-r border-b border-border bg-card p-1 align-top outline-none md:h-20', 'hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset', isPicked && 'shadow-[inset_0_0_0_2px_var(--color-ring)]'), children: [_jsxs("span", { className: "sr-only", children: [`${dayLabel(day)}${isToday ? ', today' : ''}, ${count === 0 ? 'nothing' : count === 1 ? '1 item' : `${count} items`}`, count > 0 && `: ${list.map((item) => item.title).join(', ')}`] }), _jsxs("div", { className: "flex flex-col max-md:items-center", "aria-hidden": "true", children: [_jsx("span", { className: cn('w-fit rounded px-1 text-xs tabular-nums', isToday ? 'bg-primary font-semibold text-primary-foreground' : 'text-muted-foreground'), children: Number(day.slice(8)) }), isLoading ? (_jsx(Skeleton, { className: "mt-1 h-3 w-3/4 max-md:hidden" })) : (_jsxs(_Fragment, { children: [_jsxs("ul", { className: "mt-0.5 flex min-w-0 flex-col gap-0.5 max-md:hidden", children: [list.slice(0, 2).map((item) => (_jsxs("li", { className: "flex min-w-0 items-center gap-1 text-xs text-foreground", children: [_jsx("span", { className: cn('size-1.5 shrink-0 rounded-full', TONE_DOT[item.tone ?? 'info']) }), item.emoji && _jsx(Emoji, { emoji: item.emoji, className: "size-3.5" }), _jsx("span", { className: "truncate", children: item.title })] }, item.id))), count > 2 && _jsxs("li", { className: "pl-2.5 text-xs text-muted-foreground", children: ["+", count - 2, " more"] })] }), count > 0 && (_jsx("span", { className: "mt-1 flex justify-center gap-0.5 md:hidden", children: list.slice(0, 4).map((item) => (_jsx("span", { className: cn('size-1.5 rounded-full', TONE_DOT[item.tone ?? 'info']) }, item.id))) }))] }))] })] }, day));
166
184
  }) }, row))) })] }), _jsxs("div", { role: "group", "aria-label": `${dayLabel(picked)}${picked === today ? ', today' : ''}`, "data-slot": "month-calendar-day", className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("h3", { className: cn('mr-auto text-sm font-semibold', picked === today ? 'text-link' : 'text-foreground'), children: [dayLabel(picked), picked === today && ' · Today'] }), dayActions?.(picked)] }), isLoading ? (_jsxs("div", { className: "flex flex-col gap-2 py-1", children: [_jsx(Skeleton, { className: "h-4 w-2/3" }), _jsx(Skeleton, { className: "h-4 w-1/2" })] })) : pickedItems.length === 0 ? (_jsx("p", { className: "border-t border-border py-1.5 text-sm text-muted-foreground", children: "Nothing that day." })) : (_jsx("ul", { className: "flex flex-col", children: pickedItems.map((item) => {
167
- const when = [item.time ? clock(item.time, locale) : 'All day', item.detail].filter(Boolean).join(' · ');
185
+ const time = !item.time ? 'All day' : item.endTime ? clockSpan(item.time, item.endTime, locale) : clock(item.time, locale);
186
+ const when = [time, item.detail].filter(Boolean).join(' · ');
168
187
  const body = (_jsxs(_Fragment, { children: [_jsx("span", { className: cn('size-2 shrink-0 rounded-full', TONE_DOT[item.tone ?? 'info']), "aria-hidden": "true" }), item.emoji && _jsx(Emoji, { emoji: item.emoji, className: "size-3.5" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: item.title }), _jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: when })] }));
169
188
  return (_jsx("li", { className: "border-t border-border", children: item.to ? (_jsx(Link, { to: item.to, state: linkState, className: "flex min-h-10 items-center gap-2 py-1.5 text-sm text-foreground outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50", children: body })) : (_jsx("div", { className: "flex min-h-10 items-center gap-2 py-1.5 text-sm text-foreground", children: body })) }, item.id));
170
189
  }) }))] })] }))] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "6.0.0",
3
+ "version": "6.1.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": {