@keemakr/ui-sdk 1.5.0-dev-20261017075113 → 1.5.0-dev-20261017092333

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/dist/form.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Press } from './schema.js';
1
2
  export type FormFieldKind = 'text' | 'textarea' | 'select' | 'number' | 'date' | 'datetime' | 'checkbox' | 'multiselect' | 'combobox' | 'list';
2
3
  export interface FormFieldLike {
3
4
  kind: FormFieldKind;
@@ -17,3 +18,35 @@ export declare function localInputToIso(local: string): string;
17
18
  export declare function initialDraft(field: FormFieldLike): FormDraft;
18
19
  /** What the module receives for a field. See the form schema for each kind. */
19
20
  export declare function postedValue(field: Pick<FormFieldLike, 'kind'>, draft: FormDraft): string | number | boolean | string[] | null;
21
+ /** One send button of a form: its `submit` or one of its `secondary`. */
22
+ export interface FormSubmit {
23
+ label: string;
24
+ action: string;
25
+ input?: Record<string, unknown>;
26
+ confirm?: string;
27
+ /** Check required fields before posting. */
28
+ validate: boolean;
29
+ /** The form's own `submit`: Enter presses it, and it is drawn as the main button. */
30
+ primary: boolean;
31
+ }
32
+ /** Every send button of a form in drawing order: `submit` first, then `secondary`. */
33
+ export declare function formSubmits(form: {
34
+ submit: {
35
+ label: string;
36
+ action: string;
37
+ confirm?: string;
38
+ };
39
+ secondary?: ReadonlyArray<{
40
+ label: string;
41
+ action: string;
42
+ input?: Record<string, unknown>;
43
+ confirm?: string;
44
+ validate?: boolean;
45
+ }>;
46
+ }): FormSubmit[];
47
+ /**
48
+ * The press a form's send button fires: its action, with its own static input
49
+ * under the posted field values (a field wins over a same-named key), and its
50
+ * confirm.
51
+ */
52
+ export declare function formPress(submit: Pick<FormSubmit, 'action' | 'input' | 'confirm'>, values: Record<string, unknown>): Press;
package/dist/form.js CHANGED
@@ -51,3 +51,27 @@ export function postedValue(field, draft) {
51
51
  return typeof draft === 'string' ? draft : '';
52
52
  }
53
53
  }
54
+ /** Every send button of a form in drawing order: `submit` first, then `secondary`. */
55
+ export function formSubmits(form) {
56
+ return [
57
+ { ...form.submit, validate: true, primary: true },
58
+ ...(form.secondary ?? []).map((more) => ({
59
+ ...more,
60
+ validate: more.validate ?? true,
61
+ primary: false,
62
+ })),
63
+ ];
64
+ }
65
+ /**
66
+ * The press a form's send button fires: its action, with its own static input
67
+ * under the posted field values (a field wins over a same-named key), and its
68
+ * confirm.
69
+ */
70
+ export function formPress(submit, values) {
71
+ return {
72
+ kind: 'action',
73
+ action: submit.action,
74
+ input: { ...submit.input, ...values },
75
+ ...(submit.confirm ? { confirm: submit.confirm } : {}),
76
+ };
77
+ }
package/dist/index.d.ts CHANGED
@@ -4,8 +4,8 @@ export { childNodesOf, KNOWN_CONTAINERS, KNOWN_NODE_TYPES } from './nodes.js';
4
4
  export type { ContainerChild, ContainerNodeType, KnownNodeType } from './nodes.js';
5
5
  export { pageRangeLabel, pageWindow, pressWithValue } from './pager.js';
6
6
  export { MEDIA_CONTENT_TYPES, mediaContentType, mediaPathOf } from './media.js';
7
- export { initialDraft, isoToLocalInput, localInputToIso, postedValue } from './form.js';
8
- export type { FormDraft, FormFieldKind, FormFieldLike } from './form.js';
7
+ export { formPress, formSubmits, initialDraft, isoToLocalInput, localInputToIso, postedValue, } from './form.js';
8
+ export type { FormDraft, FormFieldKind, FormFieldLike, FormSubmit } from './form.js';
9
9
  export { composerPress, composerShortcut } from './composer.js';
10
10
  export type { ComposerKey, ComposerShortcut } from './composer.js';
11
11
  export { addDays, calendarDays, dayStartMs, entriesOnDay, intlTimeZone, isTimeZone, placeEntries, shiftCalendarDate, slotIsFree, slotTimes, todayIn, } from './calendar.js';
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ export { UI_SCHEMA_VERSION, pressSchema, buttonSchema, cellSchema, dateFormatSch
10
10
  export { childNodesOf, KNOWN_CONTAINERS, KNOWN_NODE_TYPES } from './nodes.js';
11
11
  export { pageRangeLabel, pageWindow, pressWithValue } from './pager.js';
12
12
  export { MEDIA_CONTENT_TYPES, mediaContentType, mediaPathOf } from './media.js';
13
- export { initialDraft, isoToLocalInput, localInputToIso, postedValue } from './form.js';
13
+ export { formPress, formSubmits, initialDraft, isoToLocalInput, localInputToIso, postedValue, } from './form.js';
14
14
  export { composerPress, composerShortcut } from './composer.js';
15
15
  export { addDays, calendarDays, dayStartMs, entriesOnDay, intlTimeZone, isTimeZone, placeEntries, shiftCalendarDate, slotIsFree, slotTimes, todayIn, } from './calendar.js';
16
16
  export { dateTimeFormatOptions, formatMoment, isDateLocale, mergeDateFormat, } from './date-format.js';
package/dist/schema.d.ts CHANGED
@@ -64,6 +64,7 @@ export declare const buttonSchema: z.ZodObject<{
64
64
  disabled: z.ZodDefault<z.ZodBoolean>;
65
65
  hint: z.ZodOptional<z.ZodString>;
66
66
  disabledReason: z.ZodOptional<z.ZodString>;
67
+ private: z.ZodOptional<z.ZodBoolean>;
67
68
  }, z.core.$strip>;
68
69
  /** A table cell. Dates are ISO 8601; core formats them tenant-locale-aware. */
69
70
  export declare const cellSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -81,6 +82,7 @@ export declare const cellSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
81
82
  accent: "accent";
82
83
  }>>;
83
84
  outline: z.ZodOptional<z.ZodBoolean>;
85
+ hint: z.ZodOptional<z.ZodString>;
84
86
  }, z.core.$strip>, z.ZodObject<{
85
87
  kind: z.ZodLiteral<"date">;
86
88
  value: z.ZodISODateTime;
@@ -140,6 +142,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
140
142
  disabled: z.ZodDefault<z.ZodBoolean>;
141
143
  hint: z.ZodOptional<z.ZodString>;
142
144
  disabledReason: z.ZodOptional<z.ZodString>;
145
+ private: z.ZodOptional<z.ZodBoolean>;
143
146
  }, z.core.$strip>, z.ZodObject<{
144
147
  type: z.ZodLiteral<"form">;
145
148
  key: z.ZodString;
@@ -181,6 +184,13 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
181
184
  action: z.ZodString;
182
185
  confirm: z.ZodOptional<z.ZodString>;
183
186
  }, z.core.$strip>;
187
+ secondary: z.ZodOptional<z.ZodArray<z.ZodObject<{
188
+ label: z.ZodString;
189
+ action: z.ZodString;
190
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
191
+ confirm: z.ZodOptional<z.ZodString>;
192
+ validate: z.ZodOptional<z.ZodBoolean>;
193
+ }, z.core.$strip>>>;
184
194
  }, z.core.$strip>, z.ZodObject<{
185
195
  type: z.ZodLiteral<"table">;
186
196
  columns: z.ZodArray<z.ZodObject<{
@@ -246,6 +256,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
246
256
  accent: "accent";
247
257
  }>>;
248
258
  outline: z.ZodOptional<z.ZodBoolean>;
259
+ hint: z.ZodOptional<z.ZodString>;
249
260
  }, z.core.$strip>, z.ZodObject<{
250
261
  kind: z.ZodLiteral<"date">;
251
262
  value: z.ZodISODateTime;
@@ -307,6 +318,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
307
318
  disabled: z.ZodDefault<z.ZodBoolean>;
308
319
  hint: z.ZodOptional<z.ZodString>;
309
320
  disabledReason: z.ZodOptional<z.ZodString>;
321
+ private: z.ZodOptional<z.ZodBoolean>;
310
322
  }, z.core.$strip>], "type">>;
311
323
  }, z.core.$strip>>;
312
324
  actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -330,6 +342,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
330
342
  disabled: z.ZodDefault<z.ZodBoolean>;
331
343
  hint: z.ZodOptional<z.ZodString>;
332
344
  disabledReason: z.ZodOptional<z.ZodString>;
345
+ private: z.ZodOptional<z.ZodBoolean>;
333
346
  }, z.core.$strip>>>;
334
347
  }, z.core.$strip>>;
335
348
  bulk: z.ZodOptional<z.ZodObject<{
@@ -500,6 +513,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
500
513
  disabled: z.ZodDefault<z.ZodBoolean>;
501
514
  hint: z.ZodOptional<z.ZodString>;
502
515
  disabledReason: z.ZodOptional<z.ZodString>;
516
+ private: z.ZodOptional<z.ZodBoolean>;
503
517
  }, z.core.$strip>>;
504
518
  }, z.core.$strip>, z.ZodObject<{
505
519
  type: z.ZodLiteral<"details">;
@@ -522,6 +536,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
522
536
  accent: "accent";
523
537
  }>>;
524
538
  outline: z.ZodOptional<z.ZodBoolean>;
539
+ hint: z.ZodOptional<z.ZodString>;
525
540
  }, z.core.$strip>, z.ZodObject<{
526
541
  kind: z.ZodLiteral<"date">;
527
542
  value: z.ZodISODateTime;
@@ -590,6 +605,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
590
605
  accent: "accent";
591
606
  }>>;
592
607
  outline: z.ZodOptional<z.ZodBoolean>;
608
+ hint: z.ZodOptional<z.ZodString>;
593
609
  }, z.core.$strip>, z.ZodObject<{
594
610
  kind: z.ZodLiteral<"date">;
595
611
  value: z.ZodISODateTime;
@@ -638,6 +654,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
638
654
  accent: "accent";
639
655
  }>>;
640
656
  outline: z.ZodOptional<z.ZodBoolean>;
657
+ hint: z.ZodOptional<z.ZodString>;
641
658
  }, z.core.$strip>>;
642
659
  }, z.core.$strip>, z.ZodObject<{
643
660
  type: z.ZodLiteral<"toggle">;
@@ -825,6 +842,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
825
842
  accent: "accent";
826
843
  }>>;
827
844
  outline: z.ZodOptional<z.ZodBoolean>;
845
+ hint: z.ZodOptional<z.ZodString>;
828
846
  }, z.core.$strip>, z.ZodObject<{
829
847
  kind: z.ZodLiteral<"date">;
830
848
  value: z.ZodISODateTime;
@@ -861,6 +879,7 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
861
879
  disabled: z.ZodDefault<z.ZodBoolean>;
862
880
  hint: z.ZodOptional<z.ZodString>;
863
881
  disabledReason: z.ZodOptional<z.ZodString>;
882
+ private: z.ZodOptional<z.ZodBoolean>;
864
883
  }, z.core.$strip>>>;
865
884
  onPress: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
866
885
  kind: z.ZodLiteral<"action">;
@@ -972,6 +991,7 @@ export type ScreenNode = LeafScreenNode | {
972
991
  key?: string;
973
992
  title?: string;
974
993
  description?: string;
994
+ private?: boolean;
975
995
  layout: 'stack' | 'grid' | 'row';
976
996
  columns: number;
977
997
  scroll: boolean;
@@ -984,6 +1004,7 @@ type ScreenNodeInput = LeafScreenNodeInput | {
984
1004
  key?: string;
985
1005
  title?: string;
986
1006
  description?: string;
1007
+ private?: boolean;
987
1008
  layout: 'stack' | 'grid' | 'row';
988
1009
  columns?: number;
989
1010
  scroll?: boolean;
@@ -1006,6 +1027,7 @@ type TabsScreenNode = {
1006
1027
  key: string;
1007
1028
  label: string;
1008
1029
  badge?: string;
1030
+ private?: boolean;
1009
1031
  children: ScreenNode[];
1010
1032
  }[];
1011
1033
  };
@@ -1017,6 +1039,7 @@ type TabsScreenNodeInput = {
1017
1039
  key: string;
1018
1040
  label: string;
1019
1041
  badge?: string;
1042
+ private?: boolean;
1020
1043
  children: ScreenNodeInput[];
1021
1044
  }[];
1022
1045
  };
@@ -1075,6 +1098,7 @@ export declare const screenTreeSchema: z.ZodObject<{
1075
1098
  disabled: z.ZodDefault<z.ZodBoolean>;
1076
1099
  hint: z.ZodOptional<z.ZodString>;
1077
1100
  disabledReason: z.ZodOptional<z.ZodString>;
1101
+ private: z.ZodOptional<z.ZodBoolean>;
1078
1102
  }, z.core.$strip>>>;
1079
1103
  headerControls: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1080
1104
  type: z.ZodLiteral<"segmented">;
@@ -1229,6 +1253,7 @@ export declare const screenLoadResponseSchema: z.ZodObject<{
1229
1253
  disabled: z.ZodDefault<z.ZodBoolean>;
1230
1254
  hint: z.ZodOptional<z.ZodString>;
1231
1255
  disabledReason: z.ZodOptional<z.ZodString>;
1256
+ private: z.ZodOptional<z.ZodBoolean>;
1232
1257
  }, z.core.$strip>>>;
1233
1258
  headerControls: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1234
1259
  type: z.ZodLiteral<"segmented">;
package/dist/schema.js CHANGED
@@ -91,6 +91,13 @@ export const buttonSchema = z.object({
91
91
  * reader guessing.
92
92
  */
93
93
  disabledReason: z.string().min(1).max(200).optional(),
94
+ /**
95
+ * What this button does stays inside the clinic: staff only, never sent to
96
+ * the patient ("Save note", "Flag for the doctor"). It carries a closed lock
97
+ * and reads as private to a screen reader, so the reader knows before
98
+ * pressing, wherever the button sits. Default false.
99
+ */
100
+ private: z.boolean().optional(),
94
101
  });
95
102
  /** A table cell. Dates are ISO 8601; core formats them tenant-locale-aware. */
96
103
  export const cellSchema = z.discriminatedUnion('kind', [
@@ -101,6 +108,11 @@ export const cellSchema = z.discriminatedUnion('kind', [
101
108
  tone: tone.default('default'),
102
109
  /** Drawn as an outline in the tone's colour instead of a filled badge. Default false. */
103
110
  outline: z.boolean().optional(),
111
+ /**
112
+ * What the badge means, shown on hover, keyboard focus or a tap and read
113
+ * out with it: "Kee stopped because the patient asked for a person".
114
+ */
115
+ hint: z.string().min(1).max(200).optional(),
104
116
  }),
105
117
  z.object({
106
118
  kind: z.literal('date'),
@@ -627,7 +639,11 @@ const composerSchema = z
627
639
  .max(10),
628
640
  })
629
641
  .optional(),
630
- /** Text waiting to be used. It never enters the box until the reader presses Use. */
642
+ /**
643
+ * Text waiting to be used, shown as a card above the box so it reads
644
+ * without a click. It never enters the box until the reader presses
645
+ * "Use this draft", so the reader's words and Kee's never mix.
646
+ */
631
647
  draft: z
632
648
  .object({
633
649
  text: z.string().min(1).max(20000),
@@ -728,6 +744,11 @@ const tagsSchema = z.object({
728
744
  tone: tone.default('default'),
729
745
  /** Drawn as an outline in the tone's colour instead of a filled badge. Default false. */
730
746
  outline: z.boolean().optional(),
747
+ /**
748
+ * What the tag means, shown on hover, keyboard focus or a tap and read
749
+ * out with it: "Asked for a person" explained as "Kee stopped replying".
750
+ */
751
+ hint: z.string().min(1).max(200).optional(),
731
752
  }))
732
753
  .min(1)
733
754
  .max(20),
@@ -983,8 +1004,44 @@ const leafNodeSchema = z.discriminatedUnion('type', [
983
1004
  /** Asked before the form posts, as a button's confirm is. */
984
1005
  confirm: z.string().max(500).optional(),
985
1006
  }),
1007
+ /**
1008
+ * More send buttons, drawn after `submit`, for a form where the reader
1009
+ * makes one decision with the same values: "Send reply" and "Reply and
1010
+ * hand back to Kee". Each posts every field value to its own action, as
1011
+ * `submit` does, merged over its own static `input` (a field wins over a
1012
+ * same-named key, because the reader typed it). `submit` stays the
1013
+ * primary: Enter in a field presses it, never one of these.
1014
+ *
1015
+ * Required fields are checked for each of them too, unless it says
1016
+ * `validate: false` (a "Save draft" that may go half filled). While any
1017
+ * submit of the form is running, every one of them is disabled.
1018
+ */
1019
+ secondary: z
1020
+ .array(z.object({
1021
+ label: z.string().min(1).max(80),
1022
+ action: slug,
1023
+ /** Static values posted with the fields, as a button's input is. */
1024
+ input: z.record(z.string(), z.unknown()).optional(),
1025
+ /** Asked before the form posts, as `submit.confirm` is. */
1026
+ confirm: z.string().max(500).optional(),
1027
+ /** Check required fields before posting. Default true. */
1028
+ validate: z.boolean().optional(),
1029
+ }))
1030
+ .max(3)
1031
+ .optional(),
986
1032
  })
987
1033
  .superRefine((node, ctx) => {
1034
+ const labels = new Set([node.submit.label]);
1035
+ for (const [i, more] of (node.secondary ?? []).entries()) {
1036
+ if (labels.has(more.label)) {
1037
+ ctx.addIssue({
1038
+ code: 'custom',
1039
+ path: ['secondary', i, 'label'],
1040
+ message: `two submits are labelled "${more.label}"`,
1041
+ });
1042
+ }
1043
+ labels.add(more.label);
1044
+ }
988
1045
  const names = new Set();
989
1046
  for (const [i, field] of node.fields.entries()) {
990
1047
  const at = (key) => ['fields', i, key];
@@ -1299,6 +1356,13 @@ const sectionBranch = (children) => z.object({
1299
1356
  key: slug.optional(),
1300
1357
  title: z.string().max(120).optional(),
1301
1358
  description: z.string().max(300).optional(),
1359
+ /**
1360
+ * What the section holds is staff only: internal notes, a private flag.
1361
+ * Its title carries a closed lock and reads as private to a screen reader,
1362
+ * in place of a full line of text saying so. Shown only with a `title`.
1363
+ * Default false.
1364
+ */
1365
+ private: z.boolean().optional(),
1302
1366
  /**
1303
1367
  * `stack`: one child per line. `grid`: `columns` equal columns. `row`:
1304
1368
  * children side by side at their own width, wrapping on a narrow screen,
@@ -1341,6 +1405,12 @@ const tabsBranch = (children) => z
1341
1405
  label: z.string().min(1).max(40),
1342
1406
  /** Sits beside the label — a count, not prose. */
1343
1407
  badge: z.string().max(12).optional(),
1408
+ /**
1409
+ * The tab holds staff-only content: Notes, Internal. Its label
1410
+ * carries a closed lock and reads as private to a screen reader,
1411
+ * so the reader knows before opening it. Default false.
1412
+ */
1413
+ private: z.boolean().optional(),
1344
1414
  children: z.array(children).max(100),
1345
1415
  }))
1346
1416
  .min(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keemakr/ui-sdk",
3
- "version": "1.5.0-dev-20261017075113",
3
+ "version": "1.5.0-dev-20261017092333",
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",