@keemakr/ui-sdk 1.4.0 → 1.5.0-dev-20261015182415

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.
@@ -1,4 +1,9 @@
1
1
  export type CalendarView = 'day' | 'week' | 'month';
2
+ /**
3
+ * Where a calendar lays out: `true` is UTC, `false` the viewer's own zone, and a
4
+ * string that IANA zone. The zone math uses Intl alone, no dependency.
5
+ */
6
+ export type CalendarZone = boolean | string;
2
7
  /** `days` after a YYYY-MM-DD day, as YYYY-MM-DD. Calendar arithmetic, no zone. */
3
8
  export declare function addDays(day: string, days: number): string;
4
9
  /**
@@ -10,12 +15,24 @@ export declare function calendarDays(view: CalendarView, date: string): string[]
10
15
  /** The date previous or next moves to. A month step keeps the day where it can:
11
16
  * 31 January steps to 28 (or 29) February, not into March. */
12
17
  export declare function shiftCalendarDate(view: CalendarView, date: string, step: 1 | -1): string;
13
- /** Midnight at the start of a day, in the viewer's zone or in UTC. */
14
- export declare function dayStartMs(day: string, utc: boolean): number;
15
- /** Today as YYYY-MM-DD, in the viewer's zone or in UTC. */
16
- export declare function todayIn(utc: boolean, now?: number): string;
18
+ /**
19
+ * The name Intl takes for a zone: "UTC" for true, undefined (the viewer's own)
20
+ * for false, and the IANA name itself for a string. For a renderer formatting a
21
+ * time: `new Intl.DateTimeFormat(locale, { timeZone: intlTimeZone(zone) })`.
22
+ */
23
+ export declare function intlTimeZone(zone: CalendarZone): string | undefined;
24
+ /**
25
+ * True for an IANA zone name Intl can format in: "America/Toronto", "UTC". An
26
+ * offset such as "+05:30" is refused even where Intl takes one, because it is
27
+ * wrong for half the year wherever clocks change.
28
+ */
29
+ export declare function isTimeZone(value: string): boolean;
30
+ /** Midnight at the start of a day, in the viewer's zone, in UTC, or in a named zone. */
31
+ export declare function dayStartMs(day: string, zone: CalendarZone): number;
32
+ /** Today as YYYY-MM-DD, in the viewer's zone, in UTC, or in a named zone. */
33
+ export declare function todayIn(zone: CalendarZone, now?: number): string;
17
34
  /** The ISO start and end of the free time `slot` (counted from `startHour`). */
18
- export declare function slotTimes(day: string, startHour: number, slotMinutes: number, slot: number, utc: boolean): {
35
+ export declare function slotTimes(day: string, startHour: number, slotMinutes: number, slot: number, zone: CalendarZone): {
19
36
  start: string;
20
37
  end: string;
21
38
  };
@@ -39,9 +56,9 @@ export interface PlacedEntry<E> {
39
56
  * entry that runs past either edge is clipped to it; one wholly outside is left
40
57
  * out. Overlapping entries share the width in lanes, as a printed diary does.
41
58
  */
42
- export declare function placeEntries<E extends CalendarEntryLike>(entries: readonly E[], day: string, startHour: number, endHour: number, utc: boolean): PlacedEntry<E>[];
59
+ export declare function placeEntries<E extends CalendarEntryLike>(entries: readonly E[], day: string, startHour: number, endHour: number, zone: CalendarZone): PlacedEntry<E>[];
43
60
  /** The entries that touch any part of `day`, earliest first. For the month view. */
44
- export declare function entriesOnDay<E extends CalendarEntryLike>(entries: readonly E[], day: string, utc: boolean): E[];
61
+ export declare function entriesOnDay<E extends CalendarEntryLike>(entries: readonly E[], day: string, zone: CalendarZone): E[];
45
62
  /** True when a free time in a column is not covered by any entry in it. */
46
63
  export declare function slotIsFree(entries: readonly CalendarEntryLike[], times: {
47
64
  start: string;
package/dist/calendar.js CHANGED
@@ -3,9 +3,11 @@
3
3
  // holds, where an entry sits and which entries share a row must be one rule, or
4
4
  // the same tree lays out differently on web and mobile.
5
5
  //
6
- // Every function takes `utc`. A renderer passes false to lay out in the viewer's
7
- // own time zone, and true where it cannot know that zone (a server render), so
8
- // the first paint never claims to be local time.
6
+ // Every function takes a `zone`. A renderer passes the tree's zone (an IANA name
7
+ // such as "America/Toronto", from `calendar.timeZone ?? tree.timeZone`) so a
8
+ // clinic's 8:30 booking sits at 8:30 for every viewer. Without one it passes
9
+ // false to lay out in the viewer's own zone, and true where it cannot know that
10
+ // zone (a server render), so the first paint never claims to be local time.
9
11
  const DAY_MS = 24 * 3600 * 1000;
10
12
  function parts(day) {
11
13
  const [y, m, d] = day.split('-').map(Number);
@@ -52,22 +54,114 @@ export function shiftCalendarDate(view, date, step) {
52
54
  const lastDay = new Date(Date.UTC(y, m + step + 1, 0)).getUTCDate();
53
55
  return isoDay(Date.UTC(y, m + step, Math.min(d, lastDay)));
54
56
  }
55
- /** Midnight at the start of a day, in the viewer's zone or in UTC. */
56
- export function dayStartMs(day, utc) {
57
+ /**
58
+ * The name Intl takes for a zone: "UTC" for true, undefined (the viewer's own)
59
+ * for false, and the IANA name itself for a string. For a renderer formatting a
60
+ * time: `new Intl.DateTimeFormat(locale, { timeZone: intlTimeZone(zone) })`.
61
+ */
62
+ export function intlTimeZone(zone) {
63
+ if (zone === true)
64
+ return 'UTC';
65
+ if (zone === false)
66
+ return undefined;
67
+ return zone;
68
+ }
69
+ /**
70
+ * True for an IANA zone name Intl can format in: "America/Toronto", "UTC". An
71
+ * offset such as "+05:30" is refused even where Intl takes one, because it is
72
+ * wrong for half the year wherever clocks change.
73
+ */
74
+ export function isTimeZone(value) {
75
+ if (!/^[A-Za-z][A-Za-z0-9+_-]*(\/[A-Za-z0-9+_.-]+)+$/.test(value) && value !== 'UTC') {
76
+ return false;
77
+ }
78
+ try {
79
+ new Intl.DateTimeFormat('en-US', { timeZone: value }).format(new Date(0));
80
+ return true;
81
+ }
82
+ catch {
83
+ return false;
84
+ }
85
+ }
86
+ const wallFormatters = new Map();
87
+ /** The wall clock in `zone` at an instant, to the second. */
88
+ function wallClock(ms, zone) {
89
+ let format = wallFormatters.get(zone);
90
+ if (!format) {
91
+ format = new Intl.DateTimeFormat('en-US', {
92
+ timeZone: zone,
93
+ hourCycle: 'h23',
94
+ year: 'numeric',
95
+ month: 'numeric',
96
+ day: 'numeric',
97
+ hour: 'numeric',
98
+ minute: 'numeric',
99
+ second: 'numeric',
100
+ });
101
+ wallFormatters.set(zone, format);
102
+ }
103
+ const out = {};
104
+ for (const part of format.formatToParts(new Date(ms))) {
105
+ if (part.type !== 'literal')
106
+ out[part.type] = Number(part.value);
107
+ }
108
+ return {
109
+ year: out.year ?? 1970,
110
+ month: out.month ?? 1,
111
+ day: out.day ?? 1,
112
+ // Some engines write midnight as 24 even with h23.
113
+ hour: (out.hour ?? 0) % 24,
114
+ minute: out.minute ?? 0,
115
+ second: out.second ?? 0,
116
+ };
117
+ }
118
+ /** How far `zone` is ahead of UTC at an instant, in milliseconds. */
119
+ function zoneOffsetMs(ms, zone) {
120
+ const whole = Math.floor(ms / 1000) * 1000;
121
+ const w = wallClock(whole, zone);
122
+ return Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute, w.second) - whole;
123
+ }
124
+ /**
125
+ * The instant a wall-clock time in `zone` names. `minutes` counts from the
126
+ * day's midnight and may run past it. Across a daylight-saving change the
127
+ * offset is read again at the answer, so midnight of a change day is right.
128
+ */
129
+ function wallToMs(day, minutes, zone) {
57
130
  const [y, m, d] = parts(day);
58
- return utc ? Date.UTC(y, m, d) : new Date(y, m, d).getTime();
131
+ const asUtc = Date.UTC(y, m, d, 0, minutes);
132
+ const first = asUtc - zoneOffsetMs(asUtc, zone);
133
+ const second = asUtc - zoneOffsetMs(first, zone);
134
+ return second;
135
+ }
136
+ /** The instant `minutes` after the start of a day, in `zone`. Booleans keep
137
+ * the old rule (midnight plus the minutes); a named zone reads the wall clock. */
138
+ function dayMinuteMs(day, minutes, zone) {
139
+ if (typeof zone === 'string')
140
+ return wallToMs(day, minutes, zone);
141
+ return dayStartMs(day, zone) + minutes * 60_000;
59
142
  }
60
- /** Today as YYYY-MM-DD, in the viewer's zone or in UTC. */
61
- export function todayIn(utc, now = Date.now()) {
62
- if (utc)
143
+ /** Midnight at the start of a day, in the viewer's zone, in UTC, or in a named zone. */
144
+ export function dayStartMs(day, zone) {
145
+ if (typeof zone === 'string')
146
+ return wallToMs(day, 0, zone);
147
+ const [y, m, d] = parts(day);
148
+ return zone ? Date.UTC(y, m, d) : new Date(y, m, d).getTime();
149
+ }
150
+ /** Today as YYYY-MM-DD, in the viewer's zone, in UTC, or in a named zone. */
151
+ export function todayIn(zone, now = Date.now()) {
152
+ const pad = (n) => String(n).padStart(2, '0');
153
+ if (typeof zone === 'string') {
154
+ const w = wallClock(now, zone);
155
+ return `${w.year}-${pad(w.month)}-${pad(w.day)}`;
156
+ }
157
+ if (zone)
63
158
  return isoDay(now);
64
159
  const date = new Date(now);
65
- const pad = (n) => String(n).padStart(2, '0');
66
160
  return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
67
161
  }
68
162
  /** The ISO start and end of the free time `slot` (counted from `startHour`). */
69
- export function slotTimes(day, startHour, slotMinutes, slot, utc) {
70
- const startMs = dayStartMs(day, utc) + (startHour * 60 + slot * slotMinutes) * 60_000;
163
+ export function slotTimes(day, startHour, slotMinutes, slot, zone) {
164
+ const startMs = dayMinuteMs(day, startHour * 60 + slot * slotMinutes, zone);
71
165
  return {
72
166
  start: new Date(startMs).toISOString(),
73
167
  end: new Date(startMs + slotMinutes * 60_000).toISOString(),
@@ -78,9 +172,9 @@ export function slotTimes(day, startHour, slotMinutes, slot, utc) {
78
172
  * entry that runs past either edge is clipped to it; one wholly outside is left
79
173
  * out. Overlapping entries share the width in lanes, as a printed diary does.
80
174
  */
81
- export function placeEntries(entries, day, startHour, endHour, utc) {
82
- const from = dayStartMs(day, utc) + startHour * 3600_000;
83
- const to = dayStartMs(day, utc) + endHour * 3600_000;
175
+ export function placeEntries(entries, day, startHour, endHour, zone) {
176
+ const from = dayMinuteMs(day, startHour * 60, zone);
177
+ const to = dayMinuteMs(day, endHour * 60, zone);
84
178
  const span = to - from;
85
179
  const inView = entries
86
180
  .map((entry) => ({
@@ -123,9 +217,10 @@ export function placeEntries(entries, day, startHour, endHour, utc) {
123
217
  return placed;
124
218
  }
125
219
  /** The entries that touch any part of `day`, earliest first. For the month view. */
126
- export function entriesOnDay(entries, day, utc) {
127
- const from = dayStartMs(day, utc);
128
- const to = from + DAY_MS;
220
+ export function entriesOnDay(entries, day, zone) {
221
+ const from = dayStartMs(day, zone);
222
+ // A named zone's day can be 23 or 25 hours long; it ends at the next midnight.
223
+ const to = typeof zone === 'string' ? dayStartMs(addDays(day, 1), zone) : from + DAY_MS;
129
224
  return entries
130
225
  .filter((e) => Date.parse(e.start) < to && Date.parse(e.end) > from)
131
226
  .sort((a, b) => Date.parse(a.start) - Date.parse(b.start));
@@ -17,8 +17,9 @@ export interface ComposerKey {
17
17
  export declare function composerShortcut(event: ComposerKey): ComposerShortcut | null;
18
18
  /**
19
19
  * The press a send fires: its action, with the send's own input, then the
20
- * mode, the channel and the text. The text, mode and channel win over a
21
- * same-named key in the send's input, because the reader chose them.
20
+ * mode, the channel, the subject and the text. These win over a same-named key
21
+ * in the send's input, because the reader chose them. `subject` is passed only
22
+ * while the chosen channel takes one (`subject: true` on its option).
22
23
  */
23
24
  export declare function composerPress(send: {
24
25
  action: string;
@@ -31,4 +32,5 @@ export declare function composerPress(send: {
31
32
  name: string;
32
33
  value: string;
33
34
  };
35
+ subject?: string;
34
36
  }): Press;
package/dist/composer.js CHANGED
@@ -16,8 +16,9 @@ export function composerShortcut(event) {
16
16
  }
17
17
  /**
18
18
  * The press a send fires: its action, with the send's own input, then the
19
- * mode, the channel and the text. The text, mode and channel win over a
20
- * same-named key in the send's input, because the reader chose them.
19
+ * mode, the channel, the subject and the text. These win over a same-named key
20
+ * in the send's input, because the reader chose them. `subject` is passed only
21
+ * while the chosen channel takes one (`subject: true` on its option).
21
22
  */
22
23
  export function composerPress(send, values) {
23
24
  return {
@@ -27,6 +28,7 @@ export function composerPress(send, values) {
27
28
  ...send.input,
28
29
  mode: values.mode,
29
30
  ...(values.channel ? { [values.channel.name]: values.channel.value } : {}),
31
+ ...(values.subject !== undefined ? { subject: values.subject } : {}),
30
32
  [values.name]: values.text,
31
33
  },
32
34
  };
package/dist/index.d.ts CHANGED
@@ -8,8 +8,8 @@ export { initialDraft, isoToLocalInput, localInputToIso, postedValue } from './f
8
8
  export type { FormDraft, FormFieldKind, FormFieldLike } from './form.js';
9
9
  export { composerPress, composerShortcut } from './composer.js';
10
10
  export type { ComposerKey, ComposerShortcut } from './composer.js';
11
- export { addDays, calendarDays, dayStartMs, entriesOnDay, placeEntries, shiftCalendarDate, slotIsFree, slotTimes, todayIn, } from './calendar.js';
12
- export type { CalendarEntryLike, CalendarView, PlacedEntry } from './calendar.js';
11
+ export { addDays, calendarDays, dayStartMs, entriesOnDay, intlTimeZone, isTimeZone, placeEntries, shiftCalendarDate, slotIsFree, slotTimes, todayIn, } from './calendar.js';
12
+ export type { CalendarEntryLike, CalendarView, CalendarZone, PlacedEntry } from './calendar.js';
13
13
  export { DATASET_FIELD_ROLES, DATASET_FIELD_TYPES, DATASET_LIMITS, answerDatasetCreate, answerDatasetQuery, datasetCreateInput, datasetCreateRequestSchema, datasetCreateResponseSchema, datasetDeclarationSchema, datasetFieldSchema, datasetManifestSchema, datasetQueryRequestSchema, datasetQueryResponseSchema, datasetRequestIssues, datasetResponseIssues, datasetRowSchema, defineDataset, } from './dataset.js';
14
14
  export type { DatasetCell, DatasetCreateCheck, DatasetCreateHandler, DatasetCreateRequest, DatasetCreateResponse, DatasetCreateResponseInput, DatasetDeclaration, DatasetDeclarationInput, DatasetDefinition, DatasetField, DatasetFieldRole, DatasetFieldType, DatasetQueryHandler, DatasetQueryRequest, DatasetQueryRequestInput, DatasetQueryResponse, DatasetQueryResponseInput, DatasetRow, } from './dataset.js';
15
15
  export { DATASET_CREATE_ACTION, DATASET_LAYOUTS, DATASET_MAX_PAGE, DATASET_NEW_PARAM, DATASET_RECORD_SECTION, compileDatasetCreate, compileDatasetNode, compileDatasetRecord, compileDatasetRecordPanel, datasetCell, datasetNodeIssues, datasetNodeSchema, datasetPage, datasetQueryFor, datasetRecordKey, datasetRecordQuery, } from './dataset-view.js';
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ export { pageRangeLabel, pageWindow, pressWithValue } from './pager.js';
12
12
  export { MEDIA_CONTENT_TYPES, mediaContentType, mediaPathOf } from './media.js';
13
13
  export { initialDraft, isoToLocalInput, localInputToIso, postedValue } from './form.js';
14
14
  export { composerPress, composerShortcut } from './composer.js';
15
- export { addDays, calendarDays, dayStartMs, entriesOnDay, placeEntries, shiftCalendarDate, slotIsFree, slotTimes, todayIn, } from './calendar.js';
15
+ export { addDays, calendarDays, dayStartMs, entriesOnDay, intlTimeZone, isTimeZone, placeEntries, shiftCalendarDate, slotIsFree, slotTimes, todayIn, } from './calendar.js';
16
16
  export { DATASET_FIELD_ROLES, DATASET_FIELD_TYPES, DATASET_LIMITS, answerDatasetCreate, answerDatasetQuery, datasetCreateInput, datasetCreateRequestSchema, datasetCreateResponseSchema, datasetDeclarationSchema, datasetFieldSchema, datasetManifestSchema, datasetQueryRequestSchema, datasetQueryResponseSchema, datasetRequestIssues, datasetResponseIssues, datasetRowSchema, defineDataset, } from './dataset.js';
17
17
  export { DATASET_CREATE_ACTION, DATASET_LAYOUTS, DATASET_MAX_PAGE, DATASET_NEW_PARAM, DATASET_RECORD_SECTION, compileDatasetCreate, compileDatasetNode, compileDatasetRecord, compileDatasetRecordPanel, datasetCell, datasetNodeIssues, datasetNodeSchema, datasetPage, datasetQueryFor, datasetRecordKey, datasetRecordQuery, } from './dataset-view.js';
18
18
  export { CHAT_BLOCK_EXAMPLES, CHAT_BLOCK_FENCE, CHAT_BLOCK_LIMITS, CHAT_BLOCK_TYPES, chatBlocksGuide, checkChatBlocks, findChatBlockFences, parseChatBlocks, settleChatBlocks, } from './chat-blocks.js';
package/dist/schema.d.ts CHANGED
@@ -57,7 +57,10 @@ export declare const cellSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
57
57
  success: "success";
58
58
  warning: "warning";
59
59
  destructive: "destructive";
60
+ info: "info";
61
+ accent: "accent";
60
62
  }>>;
63
+ outline: z.ZodOptional<z.ZodBoolean>;
61
64
  }, z.core.$strip>, z.ZodObject<{
62
65
  kind: z.ZodLiteral<"date">;
63
66
  value: z.ZodISODateTime;
@@ -139,6 +142,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
139
142
  max: z.ZodOptional<z.ZodNumber>;
140
143
  step: z.ZodOptional<z.ZodNumber>;
141
144
  }, z.core.$strip>>;
145
+ layout: z.ZodOptional<z.ZodEnum<{
146
+ stack: "stack";
147
+ inline: "inline";
148
+ }>>;
142
149
  submit: z.ZodObject<{
143
150
  label: z.ZodString;
144
151
  action: z.ZodString;
@@ -150,6 +157,12 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
150
157
  key: z.ZodString;
151
158
  label: z.ZodString;
152
159
  sortable: z.ZodDefault<z.ZodBoolean>;
160
+ width: z.ZodOptional<z.ZodEnum<{
161
+ narrow: "narrow";
162
+ medium: "medium";
163
+ wide: "wide";
164
+ }>>;
165
+ nowrap: z.ZodOptional<z.ZodBoolean>;
153
166
  filter: z.ZodOptional<z.ZodObject<{
154
167
  value: z.ZodOptional<z.ZodString>;
155
168
  options: z.ZodArray<z.ZodObject<{
@@ -199,7 +212,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
199
212
  success: "success";
200
213
  warning: "warning";
201
214
  destructive: "destructive";
215
+ info: "info";
216
+ accent: "accent";
202
217
  }>>;
218
+ outline: z.ZodOptional<z.ZodBoolean>;
203
219
  }, z.core.$strip>, z.ZodObject<{
204
220
  kind: z.ZodLiteral<"date">;
205
221
  value: z.ZodISODateTime;
@@ -361,6 +377,14 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
361
377
  series: z.ZodArray<z.ZodObject<{
362
378
  name: z.ZodString;
363
379
  values: z.ZodArray<z.ZodNumber>;
380
+ tone: z.ZodOptional<z.ZodEnum<{
381
+ default: "default";
382
+ success: "success";
383
+ warning: "warning";
384
+ destructive: "destructive";
385
+ info: "info";
386
+ accent: "accent";
387
+ }>>;
364
388
  }, z.core.$strip>>;
365
389
  }, z.core.$strip>, z.ZodObject<{
366
390
  type: z.ZodLiteral<"pagination">;
@@ -454,7 +478,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
454
478
  success: "success";
455
479
  warning: "warning";
456
480
  destructive: "destructive";
481
+ info: "info";
482
+ accent: "accent";
457
483
  }>>;
484
+ outline: z.ZodOptional<z.ZodBoolean>;
458
485
  }, z.core.$strip>, z.ZodObject<{
459
486
  kind: z.ZodLiteral<"date">;
460
487
  value: z.ZodISODateTime;
@@ -481,6 +508,8 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
481
508
  success: "success";
482
509
  warning: "warning";
483
510
  destructive: "destructive";
511
+ info: "info";
512
+ accent: "accent";
484
513
  }>>;
485
514
  cards: z.ZodArray<z.ZodObject<{
486
515
  key: z.ZodString;
@@ -497,7 +526,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
497
526
  success: "success";
498
527
  warning: "warning";
499
528
  destructive: "destructive";
529
+ info: "info";
530
+ accent: "accent";
500
531
  }>>;
532
+ outline: z.ZodOptional<z.ZodBoolean>;
501
533
  }, z.core.$strip>, z.ZodObject<{
502
534
  kind: z.ZodLiteral<"date">;
503
535
  value: z.ZodISODateTime;
@@ -515,6 +547,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
515
547
  }, z.core.$strip>>;
516
548
  }, z.core.$strip>>;
517
549
  empty: z.ZodDefault<z.ZodString>;
550
+ scroll: z.ZodOptional<z.ZodBoolean>;
518
551
  }, z.core.$strip>, z.ZodObject<{
519
552
  type: z.ZodLiteral<"link">;
520
553
  label: z.ZodString;
@@ -531,7 +564,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
531
564
  success: "success";
532
565
  warning: "warning";
533
566
  destructive: "destructive";
567
+ info: "info";
568
+ accent: "accent";
534
569
  }>>;
570
+ outline: z.ZodOptional<z.ZodBoolean>;
535
571
  }, z.core.$strip>>;
536
572
  }, z.core.$strip>, z.ZodObject<{
537
573
  type: z.ZodLiteral<"toggle">;
@@ -581,6 +617,8 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
581
617
  success: "success";
582
618
  warning: "warning";
583
619
  destructive: "destructive";
620
+ info: "info";
621
+ accent: "accent";
584
622
  }>>;
585
623
  valueLabel: z.ZodOptional<z.ZodString>;
586
624
  }, z.core.$strip>, z.ZodObject<{
@@ -606,6 +644,8 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
606
644
  success: "success";
607
645
  warning: "warning";
608
646
  destructive: "destructive";
647
+ info: "info";
648
+ accent: "accent";
609
649
  }>>;
610
650
  }, z.core.$strip>>;
611
651
  empty: z.ZodDefault<z.ZodString>;
@@ -643,6 +683,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
643
683
  options: z.ZodArray<z.ZodObject<{
644
684
  value: z.ZodString;
645
685
  label: z.ZodString;
686
+ subject: z.ZodOptional<z.ZodBoolean>;
646
687
  }, z.core.$strip>>;
647
688
  }, z.core.$strip>>;
648
689
  draft: z.ZodOptional<z.ZodObject<{
@@ -655,14 +696,14 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
655
696
  type: z.ZodLiteral<"calendar">;
656
697
  view: z.ZodDefault<z.ZodEnum<{
657
698
  day: "day";
658
- month: "month";
659
699
  week: "week";
700
+ month: "month";
660
701
  }>>;
661
702
  date: z.ZodISODate;
662
703
  views: z.ZodDefault<z.ZodArray<z.ZodEnum<{
663
704
  day: "day";
664
- month: "month";
665
705
  week: "week";
706
+ month: "month";
666
707
  }>>>;
667
708
  onChange: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
668
709
  kind: z.ZodLiteral<"action">;
@@ -692,6 +733,8 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
692
733
  success: "success";
693
734
  warning: "warning";
694
735
  destructive: "destructive";
736
+ info: "info";
737
+ accent: "accent";
695
738
  }>>;
696
739
  subtitle: z.ZodOptional<z.ZodString>;
697
740
  details: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -707,7 +750,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
707
750
  success: "success";
708
751
  warning: "warning";
709
752
  destructive: "destructive";
753
+ info: "info";
754
+ accent: "accent";
710
755
  }>>;
756
+ outline: z.ZodOptional<z.ZodBoolean>;
711
757
  }, z.core.$strip>, z.ZodObject<{
712
758
  kind: z.ZodLiteral<"date">;
713
759
  value: z.ZodISODateTime;
@@ -757,6 +803,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
757
803
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
758
804
  }, z.core.$strip>], "kind">>;
759
805
  empty: z.ZodDefault<z.ZodString>;
806
+ timeZone: z.ZodOptional<z.ZodString>;
760
807
  }, z.core.$strip>, z.ZodObject<{
761
808
  type: z.ZodLiteral<"image">;
762
809
  src: z.ZodString;
@@ -847,6 +894,8 @@ export type ScreenNode = LeafScreenNode | {
847
894
  layout: 'stack' | 'grid' | 'row';
848
895
  columns: number;
849
896
  scroll: boolean;
897
+ surface?: 'plain' | 'card';
898
+ justify?: 'start' | 'end' | 'between';
850
899
  children: ScreenNode[];
851
900
  };
852
901
  type ScreenNodeInput = LeafScreenNodeInput | {
@@ -857,6 +906,8 @@ type ScreenNodeInput = LeafScreenNodeInput | {
857
906
  layout: 'stack' | 'grid' | 'row';
858
907
  columns?: number;
859
908
  scroll?: boolean;
909
+ surface?: 'plain' | 'card';
910
+ justify?: 'start' | 'end' | 'between';
860
911
  children: ScreenNodeInput[];
861
912
  };
862
913
  /**
@@ -944,6 +995,54 @@ export declare const screenTreeSchema: z.ZodObject<{
944
995
  hint: z.ZodOptional<z.ZodString>;
945
996
  disabledReason: z.ZodOptional<z.ZodString>;
946
997
  }, z.core.$strip>>>;
998
+ headerControls: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
999
+ type: z.ZodLiteral<"segmented">;
1000
+ name: z.ZodString;
1001
+ label: z.ZodString;
1002
+ value: z.ZodString;
1003
+ options: z.ZodArray<z.ZodObject<{
1004
+ value: z.ZodString;
1005
+ label: z.ZodString;
1006
+ count: z.ZodOptional<z.ZodNumber>;
1007
+ }, z.core.$strip>>;
1008
+ onChange: z.ZodDiscriminatedUnion<[z.ZodObject<{
1009
+ kind: z.ZodLiteral<"action">;
1010
+ action: z.ZodString;
1011
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1012
+ confirm: z.ZodOptional<z.ZodString>;
1013
+ }, z.core.$strip>, z.ZodObject<{
1014
+ kind: z.ZodLiteral<"navigate">;
1015
+ screen: z.ZodString;
1016
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1017
+ }, z.core.$strip>], "kind">;
1018
+ }, z.core.$strip>, z.ZodObject<{
1019
+ type: z.ZodLiteral<"select">;
1020
+ name: z.ZodString;
1021
+ label: z.ZodString;
1022
+ value: z.ZodOptional<z.ZodString>;
1023
+ options: z.ZodArray<z.ZodObject<{
1024
+ value: z.ZodString;
1025
+ label: z.ZodString;
1026
+ }, z.core.$strip>>;
1027
+ onChange: z.ZodDiscriminatedUnion<[z.ZodObject<{
1028
+ kind: z.ZodLiteral<"action">;
1029
+ action: z.ZodString;
1030
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1031
+ confirm: z.ZodOptional<z.ZodString>;
1032
+ }, z.core.$strip>, z.ZodObject<{
1033
+ kind: z.ZodLiteral<"navigate">;
1034
+ screen: z.ZodString;
1035
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1036
+ }, z.core.$strip>], "kind">;
1037
+ disabled: z.ZodDefault<z.ZodBoolean>;
1038
+ labelPlacement: z.ZodDefault<z.ZodEnum<{
1039
+ above: "above";
1040
+ inline: "inline";
1041
+ }>>;
1042
+ hint: z.ZodOptional<z.ZodString>;
1043
+ disabledReason: z.ZodOptional<z.ZodString>;
1044
+ }, z.core.$strip>], "type">>>;
1045
+ timeZone: z.ZodOptional<z.ZodString>;
947
1046
  children: z.ZodArray<z.ZodType<ScreenRootNode, ScreenRootNodeInput, z.core.$ZodTypeInternals<ScreenRootNode, ScreenRootNodeInput>>>;
948
1047
  presentation: z.ZodOptional<z.ZodObject<{
949
1048
  layout: z.ZodLiteral<"workspace">;
@@ -1040,6 +1139,54 @@ export declare const screenLoadResponseSchema: z.ZodObject<{
1040
1139
  hint: z.ZodOptional<z.ZodString>;
1041
1140
  disabledReason: z.ZodOptional<z.ZodString>;
1042
1141
  }, z.core.$strip>>>;
1142
+ headerControls: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1143
+ type: z.ZodLiteral<"segmented">;
1144
+ name: z.ZodString;
1145
+ label: z.ZodString;
1146
+ value: z.ZodString;
1147
+ options: z.ZodArray<z.ZodObject<{
1148
+ value: z.ZodString;
1149
+ label: z.ZodString;
1150
+ count: z.ZodOptional<z.ZodNumber>;
1151
+ }, z.core.$strip>>;
1152
+ onChange: z.ZodDiscriminatedUnion<[z.ZodObject<{
1153
+ kind: z.ZodLiteral<"action">;
1154
+ action: z.ZodString;
1155
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1156
+ confirm: z.ZodOptional<z.ZodString>;
1157
+ }, z.core.$strip>, z.ZodObject<{
1158
+ kind: z.ZodLiteral<"navigate">;
1159
+ screen: z.ZodString;
1160
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1161
+ }, z.core.$strip>], "kind">;
1162
+ }, z.core.$strip>, z.ZodObject<{
1163
+ type: z.ZodLiteral<"select">;
1164
+ name: z.ZodString;
1165
+ label: z.ZodString;
1166
+ value: z.ZodOptional<z.ZodString>;
1167
+ options: z.ZodArray<z.ZodObject<{
1168
+ value: z.ZodString;
1169
+ label: z.ZodString;
1170
+ }, z.core.$strip>>;
1171
+ onChange: z.ZodDiscriminatedUnion<[z.ZodObject<{
1172
+ kind: z.ZodLiteral<"action">;
1173
+ action: z.ZodString;
1174
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1175
+ confirm: z.ZodOptional<z.ZodString>;
1176
+ }, z.core.$strip>, z.ZodObject<{
1177
+ kind: z.ZodLiteral<"navigate">;
1178
+ screen: z.ZodString;
1179
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1180
+ }, z.core.$strip>], "kind">;
1181
+ disabled: z.ZodDefault<z.ZodBoolean>;
1182
+ labelPlacement: z.ZodDefault<z.ZodEnum<{
1183
+ above: "above";
1184
+ inline: "inline";
1185
+ }>>;
1186
+ hint: z.ZodOptional<z.ZodString>;
1187
+ disabledReason: z.ZodOptional<z.ZodString>;
1188
+ }, z.core.$strip>], "type">>>;
1189
+ timeZone: z.ZodOptional<z.ZodString>;
1043
1190
  children: z.ZodArray<z.ZodType<ScreenRootNode, ScreenRootNodeInput, z.core.$ZodTypeInternals<ScreenRootNode, ScreenRootNodeInput>>>;
1044
1191
  presentation: z.ZodOptional<z.ZodObject<{
1045
1192
  layout: z.ZodLiteral<"workspace">;
package/dist/schema.js CHANGED
@@ -11,6 +11,7 @@
11
11
  * versions until modules migrate.
12
12
  */
13
13
  import { z } from 'zod';
14
+ import { isTimeZone } from './calendar.js';
14
15
  import { datasetNodeSchema } from './dataset-view.js';
15
16
  export const UI_SCHEMA_VERSION = 1;
16
17
  const slug = z
@@ -34,7 +35,20 @@ export const pressSchema = z.discriminatedUnion('kind', [
34
35
  params: z.record(z.string(), z.string()).optional(),
35
36
  }),
36
37
  ]);
37
- const tone = z.enum(['default', 'success', 'warning', 'destructive']);
38
+ /**
39
+ * The colour a block speaks in. `info` is the calm blue of a note; `accent` is
40
+ * the brand orange, for the one thing on a screen that should catch the eye.
41
+ */
42
+ const tone = z.enum(['default', 'success', 'warning', 'destructive', 'info', 'accent']);
43
+ /**
44
+ * An IANA time zone, "America/Toronto". Checked with Intl, so a zone the
45
+ * runtime cannot format in is refused here instead of throwing in a renderer.
46
+ */
47
+ const timeZoneSchema = z
48
+ .string()
49
+ .min(1)
50
+ .max(64)
51
+ .refine(isTimeZone, 'an IANA time zone such as "America/Toronto"');
38
52
  export const buttonSchema = z.object({
39
53
  type: z.literal('button'),
40
54
  label: z.string().max(80),
@@ -55,7 +69,13 @@ export const buttonSchema = z.object({
55
69
  /** A table cell. Dates are ISO 8601; core formats them tenant-locale-aware. */
56
70
  export const cellSchema = z.discriminatedUnion('kind', [
57
71
  z.object({ kind: z.literal('text'), value: z.string().max(500) }),
58
- z.object({ kind: z.literal('badge'), value: z.string().max(40), tone: tone.default('default') }),
72
+ z.object({
73
+ kind: z.literal('badge'),
74
+ value: z.string().max(40),
75
+ tone: tone.default('default'),
76
+ /** Drawn as an outline in the tone's colour instead of a filled badge. Default false. */
77
+ outline: z.boolean().optional(),
78
+ }),
59
79
  z.object({ kind: z.literal('date'), value: z.iso.datetime() }),
60
80
  ]);
61
81
  const choiceCardsSchema = z.object({
@@ -108,6 +128,11 @@ const chartSchema = z
108
128
  .array(z.object({
109
129
  name: z.string().min(1).max(80),
110
130
  values: z.array(z.number().finite()).min(1).max(50),
131
+ /**
132
+ * The series' colour. Without it each series takes the next of the
133
+ * renderer's own distinct colours.
134
+ */
135
+ tone: tone.optional(),
111
136
  }))
112
137
  .min(1)
113
138
  .max(8),
@@ -280,6 +305,12 @@ const boardSchema = z
280
305
  .max(8),
281
306
  /** Shown in a column that has no cards. */
282
307
  empty: z.string().min(1).max(80).default('Nothing here'),
308
+ /**
309
+ * Each column scrolls inside itself at a height the renderer chooses, so a
310
+ * long column does not stretch the page. Column headings stay in view.
311
+ * Default false.
312
+ */
313
+ scroll: z.boolean().optional(),
283
314
  })
284
315
  .superRefine((node, ctx) => {
285
316
  const columnKeys = new Set();
@@ -319,8 +350,10 @@ const CALENDAR_VIEWS = ['day', 'week', 'month'];
319
350
  * Appointments on a day, a week or a month. A coordinator reads several
320
351
  * providers at once and books into a free time from the same screen.
321
352
  *
322
- * Times are ISO 8601 and show in the viewer's time zone, as dates do
323
- * everywhere else. `date` is the day the view is built around; a week starts
353
+ * Times are ISO 8601 and show in the screen's time zone, as dates do
354
+ * everywhere else: `calendar.timeZone ?? tree.timeZone ?? the viewer's zone`.
355
+ * The days, where an entry sits and which day is "today" all follow that zone,
356
+ * so a clinic's 8:30 booking sits at 8:30 for a viewer anywhere. `date` is the day the view is built around; a week starts
324
357
  * on Monday. In the day view each `resource` (a provider, a room) gets a
325
358
  * column; in the week and month views an entry names its resource instead.
326
359
  *
@@ -376,6 +409,11 @@ const calendarSchema = z
376
409
  onSlotPress: pressSchema.optional(),
377
410
  /** Shown when no entry falls in the view. */
378
411
  empty: z.string().min(1).max(80).default('Nothing booked'),
412
+ /**
413
+ * Lays this calendar out in an IANA zone, overriding the screen's
414
+ * `timeZone`. See the screen's `timeZone` for the rule.
415
+ */
416
+ timeZone: timeZoneSchema.optional(),
379
417
  })
380
418
  .superRefine((node, ctx) => {
381
419
  if (node.endHour <= node.startHour) {
@@ -480,8 +518,8 @@ const conversationSchema = z
480
518
  * draft that goes into the box only when the reader asks for it.
481
519
  *
482
520
  * A send calls its action with `input` holding the text under `name`, the mode
483
- * key under `mode`, the chosen channel under the channel's `name`, and the
484
- * send's own `input`. Each mode has its own sends: a note mode has "Save note"
521
+ * key under `mode`, the chosen channel under the channel's `name`, the subject
522
+ * under `subject` when the chosen channel takes one, and the send's own `input`. Each mode has its own sends: a note mode has "Save note"
485
523
  * where a reply mode has "Send" and "Send and hand to Kee".
486
524
  *
487
525
  * Keys: Enter adds a new line unless a send in the mode takes `enter`, and
@@ -530,7 +568,16 @@ const composerSchema = z
530
568
  name: slug.default('channel'),
531
569
  value: z.string().min(1).max(64),
532
570
  options: z
533
- .array(z.object({ value: z.string().min(1).max(64), label: z.string().min(1).max(40) }))
571
+ .array(z.object({
572
+ value: z.string().min(1).max(64),
573
+ label: z.string().min(1).max(40),
574
+ /**
575
+ * This channel takes a subject line, as email does. While it is
576
+ * chosen the box shows a Subject field, and a send carries its
577
+ * text under the input key `subject`. Default false.
578
+ */
579
+ subject: z.boolean().optional(),
580
+ }))
534
581
  .min(1)
535
582
  .max(10),
536
583
  })
@@ -631,7 +678,12 @@ const tagsSchema = z.object({
631
678
  /** Shown before the tags, muted: "Sources". */
632
679
  label: z.string().max(80).optional(),
633
680
  items: z
634
- .array(z.object({ label: z.string().min(1).max(40), tone: tone.default('default') }))
681
+ .array(z.object({
682
+ label: z.string().min(1).max(40),
683
+ tone: tone.default('default'),
684
+ /** Drawn as an outline in the tone's colour instead of a filled badge. Default false. */
685
+ outline: z.boolean().optional(),
686
+ }))
635
687
  .min(1)
636
688
  .max(20),
637
689
  });
@@ -856,6 +908,12 @@ const leafNodeSchema = z.discriminatedUnion('type', [
856
908
  step: z.number().finite().positive().optional(),
857
909
  }))
858
910
  .max(30),
911
+ /**
912
+ * `stack`: one field per line, the submit under them. `inline`: the fields
913
+ * and the submit on one line, for a search box or a one-field filter. A
914
+ * narrow screen may still wrap it. Default `stack`.
915
+ */
916
+ layout: z.enum(['stack', 'inline']).optional(),
859
917
  /** Field values are posted as the action's `input`, keyed by field name. */
860
918
  submit: z.object({
861
919
  label: z.string().max(80),
@@ -933,6 +991,13 @@ const leafNodeSchema = z.discriminatedUnion('type', [
933
991
  label: z.string().max(80),
934
992
  /** The header sorts by this column. Needs the table's `onSort`. */
935
993
  sortable: z.boolean().default(false),
994
+ /**
995
+ * How much room the column asks for. Without it the renderer sizes
996
+ * the column to its content.
997
+ */
998
+ width: z.enum(['narrow', 'medium', 'wide']).optional(),
999
+ /** The column's cells stay on one line instead of wrapping. Default false. */
1000
+ nowrap: z.boolean().optional(),
936
1001
  /**
937
1002
  * The header narrows the rows to one value of this column, from a menu
938
1003
  * on the column itself. "All" is always the first choice and sends ''.
@@ -1131,6 +1196,18 @@ const sectionBranch = (children) => z.object({
1131
1196
  * above its reply box.
1132
1197
  */
1133
1198
  scroll: z.boolean().default(false),
1199
+ /**
1200
+ * `card` draws the section as a bordered card; `plain` (the default) does
1201
+ * not. Core's own renderer has always framed sections lightly and keeps
1202
+ * that for `plain`; `card` lifts it onto the card surface.
1203
+ */
1204
+ surface: z.enum(['plain', 'card']).optional(),
1205
+ /**
1206
+ * Where a `row` puts its children: at the `start`, at the `end`, or
1207
+ * `between`, which pushes the last child to the far end (a title on the
1208
+ * left, its button on the right). Other layouts ignore it. Default `start`.
1209
+ */
1210
+ justify: z.enum(['start', 'end', 'between']).optional(),
1134
1211
  children: z.array(children).max(100),
1135
1212
  });
1136
1213
  const tabsBranch = (children) => z
@@ -1239,6 +1316,25 @@ export const screenTreeSchema = z
1239
1316
  .optional(),
1240
1317
  /** Page-level actions. Presentation chooses header or pinned workspace footer. */
1241
1318
  actions: z.array(buttonSchema).max(4).optional(),
1319
+ /**
1320
+ * Up to two controls drawn in the screen's header beside `actions`: a view
1321
+ * switch, a location picker. Each applies at once, as it does in the body.
1322
+ */
1323
+ headerControls: z
1324
+ .array(z.discriminatedUnion('type', [segmentedSchema, selectSchema]))
1325
+ .max(2)
1326
+ .optional(),
1327
+ /**
1328
+ * The IANA zone the screen's times are drawn in, "America/Toronto". Core
1329
+ * fills in the org's zone when a module sends none.
1330
+ *
1331
+ * A renderer uses `calendar.timeZone ?? tree.timeZone ?? the viewer's own
1332
+ * zone` for: a calendar's days, where its entries sit and which day is
1333
+ * "today"; `conversation` message times; `timeline` times; `date` cells in
1334
+ * tables, details and board cards; and the `timestamp` block. So a clinic
1335
+ * in Toronto reads its 8:30 bookings at 8:30 from anywhere.
1336
+ */
1337
+ timeZone: timeZoneSchema.optional(),
1242
1338
  children: z.array(nodeSchema).max(100),
1243
1339
  /** Optional platform-owned layout semantics. Absence preserves the document layout. */
1244
1340
  presentation: screenPresentationSchema.optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keemakr/ui-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.5.0-dev-20261015182415",
4
4
  "description": "Product screens for keemakr marketplace modules: a versioned, server-driven UI tree schema plus defineScreen() handlers. Module code never ships to the browser — keemakr-core validates the tree and renders it with platform components.",
5
5
  "license": "MIT",
6
6
  "type": "module",