@keemakr/ui-sdk 1.6.0-dev-20261029083803 → 1.6.0-dev-20261029102802

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/conform.js CHANGED
@@ -10,6 +10,7 @@
10
10
  // - `tone: 'info' | 'accent'` (badge cells, tags, board columns, calendar entries, progress
11
11
  // bars; after 1.4.0) -> 'default', or the first tone that parse lists
12
12
  // - a string `min`/`max` on a date or datetime field (after 1.4.0) -> dropped
13
+ // - a button's `variant: 'ghost'` (after 1.4.0) -> 'secondary', the same button with a border
13
14
  // - an image's or video's portrait `aspect: '3:4' | '9:16'` (after 1.4.0)
14
15
  // -> 'auto', so the picture keeps its own shape
15
16
  // - a chart with more points than the parse takes (120 after 1.4.0, 50 before)
@@ -213,6 +214,16 @@ export function conformTree(tree, parser, options) {
213
214
  fallbacks.push({ path: pathText(path), type: 'chartType', reason: 'parse', as: 'folded' });
214
215
  return true;
215
216
  }
217
+ if (key === 'variant' &&
218
+ issue.code === 'invalid_value' &&
219
+ isObject(holder) &&
220
+ holder.variant === 'ghost' &&
221
+ (issue.values ?? []).includes('secondary')) {
222
+ // A ghost button is a lighter secondary: the press and the label are the same.
223
+ holder.variant = 'secondary';
224
+ fallbacks.push({ path: pathText(path), type: 'variant', reason: 'parse', as: 'folded' });
225
+ return true;
226
+ }
216
227
  if (key === 'aspect' &&
217
228
  issue.code === 'invalid_value' &&
218
229
  isObject(holder) &&
@@ -0,0 +1,33 @@
1
+ /** The form field kinds a focus press may name: the ones a reader types into. */
2
+ export declare const FOCUSABLE_FIELD_KINDS: readonly ["text", "textarea", "combobox"];
3
+ /** True for a press that moves the caret into a form field on the screen. */
4
+ export declare function isFocusPress(press: {
5
+ kind: string;
6
+ } | undefined): press is {
7
+ kind: 'focus';
8
+ field: string;
9
+ };
10
+ /** One place a tree names a field to focus. */
11
+ export interface FocusReference {
12
+ path: Array<string | number>;
13
+ field: string;
14
+ }
15
+ /** One form field, by its `name`. */
16
+ export interface FormFieldName {
17
+ name: string;
18
+ kind: string;
19
+ }
20
+ /**
21
+ * Every form field and every focus press in a tree's children. Walks the tree as data, as
22
+ * `seeksIn` does, so a focus is found wherever a press is taken. An action's `input` and a
23
+ * navigate's `params` are the module's own data and are not read.
24
+ */
25
+ export declare function focusesIn(value: unknown): {
26
+ fields: FormFieldName[];
27
+ focuses: FocusReference[];
28
+ };
29
+ /**
30
+ * What is wrong with a focus on `field`, or null: it must name exactly one form field on the
31
+ * screen, of a kind the reader types into.
32
+ */
33
+ export declare function focusIssue(field: string, fields: readonly FormFieldName[]): string | null;
package/dist/focus.js ADDED
@@ -0,0 +1,60 @@
1
+ // A `focus` press: "Edit draft" puts the caret at the end of a form field on the same screen, so
2
+ // the reader can start typing. Shared by core and the clients, so every renderer finds the same
3
+ // field for it and the tree check refuses one that names no field it could land in.
4
+ /** The form field kinds a focus press may name: the ones a reader types into. */
5
+ export const FOCUSABLE_FIELD_KINDS = ['text', 'textarea', 'combobox'];
6
+ /** True for a press that moves the caret into a form field on the screen. */
7
+ export function isFocusPress(press) {
8
+ return press?.kind === 'focus';
9
+ }
10
+ /**
11
+ * Every form field and every focus press in a tree's children. Walks the tree as data, as
12
+ * `seeksIn` does, so a focus is found wherever a press is taken. An action's `input` and a
13
+ * navigate's `params` are the module's own data and are not read.
14
+ */
15
+ export function focusesIn(value) {
16
+ const fields = [];
17
+ const focuses = [];
18
+ const walk = (item, path) => {
19
+ if (Array.isArray(item)) {
20
+ item.forEach((child, index) => walk(child, [...path, index]));
21
+ return;
22
+ }
23
+ if (!item || typeof item !== 'object')
24
+ return;
25
+ const record = item;
26
+ if (record.type === 'form' && Array.isArray(record.fields)) {
27
+ for (const field of record.fields) {
28
+ if (typeof field?.name === 'string' && typeof field.kind === 'string') {
29
+ fields.push({ name: field.name, kind: field.kind });
30
+ }
31
+ }
32
+ }
33
+ if (record.kind === 'focus' && typeof record.field === 'string') {
34
+ focuses.push({ path: [...path, 'field'], field: record.field });
35
+ }
36
+ for (const [key, child] of Object.entries(record)) {
37
+ if (key === 'input' || key === 'params')
38
+ continue;
39
+ walk(child, [...path, key]);
40
+ }
41
+ };
42
+ walk(value, []);
43
+ return { fields, focuses };
44
+ }
45
+ /**
46
+ * What is wrong with a focus on `field`, or null: it must name exactly one form field on the
47
+ * screen, of a kind the reader types into.
48
+ */
49
+ export function focusIssue(field, fields) {
50
+ const named = fields.filter((f) => f.name === field);
51
+ if (named.length === 0)
52
+ return `no form field on this screen is named "${field}"`;
53
+ if (named.length > 1)
54
+ return `two form fields on this screen are named "${field}"`;
55
+ const kind = named[0].kind;
56
+ if (!FOCUSABLE_FIELD_KINDS.includes(kind)) {
57
+ return `a focus lands in a text, textarea or combobox field, not a ${kind}`;
58
+ }
59
+ return null;
60
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { UI_SCHEMA_VERSION, pressSchema, chatPressSchema, valuePressSchema, NAVIGATE_OPENS, buttonSchema, cellSchema, factCellSchema, tableCellSchema, dateFormatSchema, nodeSchema, screenPresentationSchema, screenTreeSchema, actionResultSchema, screenLoadRequestSchema, screenLoadResponseSchema, screenActionRequestSchema, interfaceFamilySchema, surfaceDefinitionSchema, surfaceSchema, screenRegistrationSchema, uiManifestSchema, jobIdSchema, jobStatusSchema, screenJobRequestSchema, mediaPathSchema, seekPointSchema, seekPressSchema, BADGE_COUNT_MAX, surfaceBadgeSchema, screenBadgesRequestSchema, screenBadgesResponseSchema, TABS_MAX, } from './schema.js';
2
- export type { Press, ChatPress, SeekPress, SeekPoint, ValuePress, NavigatePress, NavigateOpen, ScreenPresentation, ScreenNode, ScreenRootNode, ScreenTree, ActionResult, InterfaceFamily, SurfaceDefinition, Surface, ScreenRegistration, UiManifest, ScreenTreeInput, ActionResultInput, JobStatus, JobStatusInput, SurfaceBadge, SurfaceBadgeInput, ScreenBadgesRequest, ScreenBadgesResponse, } from './schema.js';
1
+ export { UI_SCHEMA_VERSION, pressSchema, chatPressSchema, valuePressSchema, NAVIGATE_OPENS, buttonSchema, cellSchema, factCellSchema, tableCellSchema, dateFormatSchema, nodeSchema, screenPresentationSchema, screenTreeSchema, actionResultSchema, screenLoadRequestSchema, screenLoadResponseSchema, screenActionRequestSchema, interfaceFamilySchema, surfaceDefinitionSchema, surfaceSchema, screenRegistrationSchema, uiManifestSchema, jobIdSchema, jobStatusSchema, screenJobRequestSchema, mediaPathSchema, seekPointSchema, seekPressSchema, focusPressSchema, BADGE_COUNT_MAX, surfaceBadgeSchema, screenBadgesRequestSchema, screenBadgesResponseSchema, TABS_MAX, } from './schema.js';
2
+ export type { Press, ChatPress, SeekPress, SeekPoint, FocusPress, ValuePress, NavigatePress, NavigateOpen, ScreenPresentation, ScreenNode, ScreenRootNode, ScreenTree, ActionResult, InterfaceFamily, SurfaceDefinition, Surface, ScreenRegistration, UiManifest, ScreenTreeInput, ActionResultInput, JobStatus, JobStatusInput, SurfaceBadge, SurfaceBadgeInput, ScreenBadgesRequest, ScreenBadgesResponse, } from './schema.js';
3
3
  export { BADGE_DISPLAY_MAX, answerBadges, badgeSpokenLabel, badgeText, defineBadges, parseScreenBadges, } from './badges.js';
4
4
  export type { BadgesHandler } from './badges.js';
5
5
  export { CHART_POINTS_MAX, thinChart, thinnedIndices } from './chart.js';
@@ -19,6 +19,8 @@ export { PUBLISHED_PARSERS, type PublishedParser } from './published/index.js';
19
19
  export { MEDIA_CONTENT_TYPES, mediaContentType, mediaPathOf } from './media.js';
20
20
  export { PLAYBACK_RATES, SEEK_AT_MAX, formatPlayhead, isSeekPress, nextPlaybackRate, playbackRateLabel, playheadWords, seekTarget, seeksIn, } from './player.js';
21
21
  export type { PlaybackRate, PlayerKey, SeekReference } from './player.js';
22
+ export { FOCUSABLE_FIELD_KINDS, focusIssue, focusesIn, isFocusPress } from './focus.js';
23
+ export type { FocusReference, FormFieldName } from './focus.js';
22
24
  export { heatmapCellText, heatmapIntensity, heatmapMixPercent, heatmapRange, heatmapStrong, } from './heatmap.js';
23
25
  export type { HeatmapLike, HeatmapRange } from './heatmap.js';
24
26
  export { checkFormInput, chosenSubmit, formPress, formState, formSubmits, initialDraft, isoToLocalInput, localInputToIso, postedValue, searchableOptions, } from './form.js';
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  // platform components, proxies load/action with a grant
7
7
  //
8
8
  // Module code never ships to the browser. UI is data, not code.
9
- export { UI_SCHEMA_VERSION, pressSchema, chatPressSchema, valuePressSchema, NAVIGATE_OPENS, buttonSchema, cellSchema, factCellSchema, tableCellSchema, dateFormatSchema, nodeSchema, screenPresentationSchema, screenTreeSchema, actionResultSchema, screenLoadRequestSchema, screenLoadResponseSchema, screenActionRequestSchema, interfaceFamilySchema, surfaceDefinitionSchema, surfaceSchema, screenRegistrationSchema, uiManifestSchema, jobIdSchema, jobStatusSchema, screenJobRequestSchema, mediaPathSchema, seekPointSchema, seekPressSchema, BADGE_COUNT_MAX, surfaceBadgeSchema, screenBadgesRequestSchema, screenBadgesResponseSchema, TABS_MAX, } from './schema.js';
9
+ export { UI_SCHEMA_VERSION, pressSchema, chatPressSchema, valuePressSchema, NAVIGATE_OPENS, buttonSchema, cellSchema, factCellSchema, tableCellSchema, dateFormatSchema, nodeSchema, screenPresentationSchema, screenTreeSchema, actionResultSchema, screenLoadRequestSchema, screenLoadResponseSchema, screenActionRequestSchema, interfaceFamilySchema, surfaceDefinitionSchema, surfaceSchema, screenRegistrationSchema, uiManifestSchema, jobIdSchema, jobStatusSchema, screenJobRequestSchema, mediaPathSchema, seekPointSchema, seekPressSchema, focusPressSchema, BADGE_COUNT_MAX, surfaceBadgeSchema, screenBadgesRequestSchema, screenBadgesResponseSchema, TABS_MAX, } from './schema.js';
10
10
  export { BADGE_DISPLAY_MAX, answerBadges, badgeSpokenLabel, badgeText, defineBadges, parseScreenBadges, } from './badges.js';
11
11
  export { CHART_POINTS_MAX, thinChart, thinnedIndices } from './chart.js';
12
12
  export { TABS_MAX_1_4_0, foldTabs, onlyTabParamsDiffer, openingTab, tabParamsOf } from './tabs.js';
@@ -20,6 +20,7 @@ export { CHANNEL_BUILDS, CLIENT_RELEASES, CORE_DRAWN_NODE_TYPES, CURRENT_SCHEMA_
20
20
  export { PUBLISHED_PARSERS } from './published/index.js';
21
21
  export { MEDIA_CONTENT_TYPES, mediaContentType, mediaPathOf } from './media.js';
22
22
  export { PLAYBACK_RATES, SEEK_AT_MAX, formatPlayhead, isSeekPress, nextPlaybackRate, playbackRateLabel, playheadWords, seekTarget, seeksIn, } from './player.js';
23
+ export { FOCUSABLE_FIELD_KINDS, focusIssue, focusesIn, isFocusPress } from './focus.js';
23
24
  export { heatmapCellText, heatmapIntensity, heatmapMixPercent, heatmapRange, heatmapStrong, } from './heatmap.js';
24
25
  export { checkFormInput, chosenSubmit, formPress, formState, formSubmits, initialDraft, isoToLocalInput, localInputToIso, postedValue, searchableOptions, } from './form.js';
25
26
  export { stackedBarParts, stackedBarValue } from './stacked-bar.js';
@@ -86,8 +86,13 @@ import type { ChatPress, ScreenRootNode, ScreenTree } from './schema.js';
86
86
  * is optional: a safe superset, and the module's `checkFormInput` still refuses an empty
87
87
  * shown required field. A send's `disabledUntilValid` needs no fold: an older parse strips it,
88
88
  * and the send stays pressable with the browser's required check in front of it.
89
+ * - `press.focus`: a `focus` press puts the caret at the end of a form field on the same screen
90
+ * ("Edit draft"), newer than any published release; core's own renderer draws it. The field
91
+ * is editable without it, so without it every control with a focus press is dropped, a body
92
+ * button included (never left as muted text, which would read as a label), and a row, card,
93
+ * entry or image stays but is no longer pressable.
89
94
  */
90
- export type UiFeature = 'breadcrumbs' | 'button.disabled' | 'section.row' | 'form.field_kinds' | 'form.confirm' | 'press.chat' | 'form.radio' | 'table.cells' | 'header.meta' | 'tabs.many' | 'choice.action' | 'markdown.links' | 'form.disabled' | 'press.seek' | 'edit.inline' | 'timeline.time_tag' | 'stat.bar' | 'section.action' | 'facts.meter' | 'form.show_when';
95
+ export type UiFeature = 'breadcrumbs' | 'button.disabled' | 'section.row' | 'form.field_kinds' | 'form.confirm' | 'press.chat' | 'form.radio' | 'table.cells' | 'header.meta' | 'tabs.many' | 'choice.action' | 'markdown.links' | 'form.disabled' | 'press.seek' | 'edit.inline' | 'timeline.time_tag' | 'stat.bar' | 'section.action' | 'facts.meter' | 'form.show_when' | 'press.focus';
91
96
  /** The node types and features one ui-sdk release, or one client, draws. */
92
97
  export interface NodeSet {
93
98
  /** For messages: "ui-sdk 1.4.0", "mobile 0.2.5". */
@@ -124,7 +129,7 @@ export declare const UI_SDK_SNAPSHOTS: {
124
129
  readonly current: {
125
130
  readonly name: "ui-sdk (this package)";
126
131
  readonly nodes: readonly ["heading", "text", "markdown", "stat", "button", "form", "table", "timeline", "pending_request", "pending_requests", "choice_cards", "progress", "chart", "section", "tabs", "pagination", "select", "alert", "details", "timestamp", "divider", "board", "link", "tags", "toggle", "segmented", "progress_bar", "conversation", "composer", "calendar", "image", "video", "stacked_bar", "heatmap", "audio", "document"];
127
- readonly features: readonly ["breadcrumbs", "button.disabled", "section.row", "form.field_kinds", "form.confirm", "press.chat", "form.radio", "table.cells", "header.meta", "tabs.many", "choice.action", "markdown.links", "form.disabled", "press.seek", "edit.inline", "timeline.time_tag", "stat.bar", "section.action", "facts.meter", "form.show_when"];
132
+ readonly features: readonly ["breadcrumbs", "button.disabled", "section.row", "form.field_kinds", "form.confirm", "press.chat", "form.radio", "table.cells", "header.meta", "tabs.many", "choice.action", "markdown.links", "form.disabled", "press.seek", "edit.inline", "timeline.time_tag", "stat.bar", "section.action", "facts.meter", "form.show_when", "press.focus"];
128
133
  };
129
134
  };
130
135
  export type UiSdkSnapshot = keyof typeof UI_SDK_SNAPSHOTS;
package/dist/negotiate.js CHANGED
@@ -22,6 +22,7 @@
22
22
  // parses with that row's published schema with no safety field lost.
23
23
  import { foldTableCell, isNewerTableCell, meterLabel } from './cells.js';
24
24
  import { conformTree } from './conform.js';
25
+ import { isFocusPress } from './focus.js';
25
26
  import { withoutScreenLinks } from './markdown-links.js';
26
27
  import { pageRangeLabel } from './pager.js';
27
28
  import { formatPlayhead, isSeekPress } from './player.js';
@@ -54,6 +55,7 @@ const ALL_FEATURES = [
54
55
  'section.action',
55
56
  'facts.meter',
56
57
  'form.show_when',
58
+ 'press.focus',
57
59
  ];
58
60
  /** The nodes of ui-sdk 1.1.0 and 1.2.0 (one schema). */
59
61
  const NODES_1_1_0 = [
@@ -309,6 +311,7 @@ export function negotiateTree(tree, set) {
309
311
  // The zone the screen's times are drawn in (core fills in the Company's when the module named
310
312
  // none). A stand-in line writes its times in it, read before a fit may take the field away.
311
313
  const zone = tree.timeZone;
314
+ // Null drops the node from its list.
312
315
  const visit = (original, path) => {
313
316
  const loose = original;
314
317
  if (!nodes.has(loose.type)) {
@@ -316,13 +319,23 @@ export function negotiateTree(tree, set) {
316
319
  fallbacks.push({ path, type: loose.type, reason: 'node', as: replacement.type });
317
320
  return replacement;
318
321
  }
319
- // A client that cannot open its chat, or move a recording, gets no control that offers to.
322
+ if (!features.has('press.focus') &&
323
+ original.type === 'button' &&
324
+ isFocusPress(original.onPress)) {
325
+ fallbacks.push({ path, type: 'button', reason: 'press.focus', as: 'dropped' });
326
+ return null;
327
+ }
328
+ // A client that cannot open its chat, move a recording or focus a field gets no control that
329
+ // offers to.
320
330
  let node = features.has('press.chat')
321
331
  ? original
322
332
  : withoutPresses(original, path, fallbacks, isChatPress, 'press.chat');
323
333
  if (node.type !== 'text' && !features.has('press.seek')) {
324
334
  node = withoutSeeks(node, path, fallbacks);
325
335
  }
336
+ if (node.type !== 'text' && !features.has('press.focus')) {
337
+ node = withoutPresses(node, path, fallbacks, isFocusPress, 'press.focus');
338
+ }
326
339
  if (node !== original && node.type === 'text')
327
340
  return node;
328
341
  // A client that draws no edit control gets the block read-only.
@@ -491,11 +504,11 @@ export function negotiateTree(tree, set) {
491
504
  // returned as the same object and costs no copy.
492
505
  const visitAll = (list, path) => {
493
506
  let changed = false;
494
- const out = list.map((child, index) => {
507
+ const out = list.flatMap((child, index) => {
495
508
  const next = visit(child, `${path}[${index}]`);
496
509
  if (next !== child)
497
510
  changed = true;
498
- return next;
511
+ return next === null ? [] : [next];
499
512
  });
500
513
  return changed ? out : list;
501
514
  };
@@ -504,7 +517,10 @@ export function negotiateTree(tree, set) {
504
517
  if (children !== tree.children)
505
518
  next = { ...next, children };
506
519
  if (tree.actions &&
507
- (!features.has('button.disabled') || !features.has('press.chat') || !features.has('press.seek'))) {
520
+ (!features.has('button.disabled') ||
521
+ !features.has('press.chat') ||
522
+ !features.has('press.seek') ||
523
+ !features.has('press.focus'))) {
508
524
  // The header holds buttons only, so one the client cannot draw safely is dropped.
509
525
  const kept = tree.actions.filter((action, index) => {
510
526
  const reason = action.disabled && !features.has('button.disabled')
@@ -513,7 +529,9 @@ export function negotiateTree(tree, set) {
513
529
  ? 'press.chat'
514
530
  : isSeekPress(action.onPress) && !features.has('press.seek')
515
531
  ? 'press.seek'
516
- : null;
532
+ : isFocusPress(action.onPress) && !features.has('press.focus')
533
+ ? 'press.focus'
534
+ : null;
517
535
  if (!reason)
518
536
  return true;
519
537
  fallbacks.push({ path: `actions[${index}]`, type: 'button', reason, as: 'dropped' });
@@ -739,9 +757,9 @@ export function withoutInlineEdit(node, path, fallbacks) {
739
757
  }
740
758
  /**
741
759
  * The node as a client that cannot run one kind of press should get it: no control left on it that
742
- * offers to (see `press.chat` and `press.seek` above). `matches` picks the presses to take away and
743
- * `reason` is the feature the client lacks. Only the node's own presses; its child nodes are
744
- * visited on their own. Returns the same object when there is nothing to take away.
760
+ * offers to (see `press.chat`, `press.seek` and `press.focus` above). `matches` picks the presses
761
+ * to take away and `reason` is the feature the client lacks. Only the node's own presses; its child
762
+ * nodes are visited on their own. Returns the same object when there is nothing to take away.
745
763
  */
746
764
  function withoutPresses(node, path, fallbacks, matches, reason) {
747
765
  const dropped = (at, type, as = 'dropped') => fallbacks.push({ path: at, type, reason, as });
@@ -119,9 +119,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
119
119
  list: "list";
120
120
  select: "select";
121
121
  checkbox: "checkbox";
122
- multiselect: "multiselect";
123
122
  textarea: "textarea";
124
123
  combobox: "combobox";
124
+ multiselect: "multiselect";
125
125
  }>;
126
126
  name: z.ZodString;
127
127
  label: z.ZodString;
package/dist/schema.d.ts CHANGED
@@ -27,7 +27,11 @@ export declare const NAVIGATE_OPENS: readonly ["drawer"];
27
27
  * - a press in it with `open: 'drawer'`, and an action result's `navigate`, show that screen in
28
28
  * the same drawer (a drawer never opens another drawer);
29
29
  * - a press in it without `open` leaves the drawer and opens the screen as a page;
30
- * - `refresh` and a returned `tree` refresh the drawer, not the screen underneath;
30
+ * - an action run in it that succeeds closes it ("Approve", "Done": the item is dealt with),
31
+ * unless its result returns a `tree` (the drawer is drawn again as it now is) or a `navigate`
32
+ * (the drawer moves on). A failed action keeps it open, with the failure said;
33
+ * - `refresh` refreshes the drawer, not the screen underneath, for an action that keeps it open
34
+ * (a finished job's result follows the same rule);
31
35
  * - closing it reads the screen underneath again when an action ran in it, so "Mark done" in
32
36
  * the drawer shows on the list.
33
37
  * The drawer is not in the address: a reload shows the screen underneath, and a link opens a
@@ -85,6 +89,17 @@ export declare const seekPressSchema: z.ZodObject<{
85
89
  at: z.ZodNumber;
86
90
  kind: z.ZodLiteral<"seek">;
87
91
  }, z.core.$strip>;
92
+ /**
93
+ * Puts the caret at the end of a form field on the same screen, so the reader can start typing:
94
+ * "Edit draft" beside "Approve & send". `field` is the `name` of a `text`, `textarea` or `combobox`
95
+ * field, and exactly one field on the screen has it (checked when the tree is parsed). It is drawn
96
+ * and handled by the renderer alone: nothing is posted to the module and the host never sees it.
97
+ * A field that is not drawn (hidden by its `showWhen`) leaves the press doing nothing.
98
+ */
99
+ export declare const focusPressSchema: z.ZodObject<{
100
+ kind: z.ZodLiteral<"focus">;
101
+ field: z.ZodString;
102
+ }, z.core.$strip>;
88
103
  /**
89
104
  * What a control that applies a chosen value calls: a pager, a select, a
90
105
  * toggle, a sort or filter header. The value is merged in (`pressWithValue`),
@@ -106,8 +121,8 @@ export declare const valuePressSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
106
121
  * What a button (or table row, card, choice, calendar entry, image) does when
107
122
  * pressed: call an action, open another screen of the module (as a page, or in
108
123
  * a drawer over this one with `open: 'drawer'`), open the chat with a prompt
109
- * typed in (`chat`, never sent), or move a recording on the screen to a moment
110
- * (`seek`).
124
+ * typed in (`chat`, never sent), move a recording on the screen to a moment
125
+ * (`seek`), or put the caret in a form field on the screen (`focus`).
111
126
  */
112
127
  export declare const pressSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
113
128
  kind: z.ZodLiteral<"action">;
@@ -129,6 +144,9 @@ export declare const pressSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
129
144
  player: z.ZodString;
130
145
  at: z.ZodNumber;
131
146
  kind: z.ZodLiteral<"seek">;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ kind: z.ZodLiteral<"focus">;
149
+ field: z.ZodString;
132
150
  }, z.core.$strip>], "kind">;
133
151
  /**
134
152
  * How a screen writes its dates and times. Set on the tree for the whole screen;
@@ -173,11 +191,15 @@ export declare const buttonSchema: z.ZodObject<{
173
191
  player: z.ZodString;
174
192
  at: z.ZodNumber;
175
193
  kind: z.ZodLiteral<"seek">;
194
+ }, z.core.$strip>, z.ZodObject<{
195
+ kind: z.ZodLiteral<"focus">;
196
+ field: z.ZodString;
176
197
  }, z.core.$strip>], "kind">;
177
198
  variant: z.ZodDefault<z.ZodEnum<{
178
199
  destructive: "destructive";
179
200
  secondary: "secondary";
180
201
  primary: "primary";
202
+ ghost: "ghost";
181
203
  }>>;
182
204
  disabled: z.ZodDefault<z.ZodBoolean>;
183
205
  hint: z.ZodOptional<z.ZodString>;
@@ -483,6 +505,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
483
505
  player: z.ZodString;
484
506
  at: z.ZodNumber;
485
507
  kind: z.ZodLiteral<"seek">;
508
+ }, z.core.$strip>, z.ZodObject<{
509
+ kind: z.ZodLiteral<"focus">;
510
+ field: z.ZodString;
486
511
  }, z.core.$strip>], "kind">>;
487
512
  selected: z.ZodOptional<z.ZodBoolean>;
488
513
  bar: z.ZodOptional<z.ZodObject<{
@@ -523,11 +548,15 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
523
548
  player: z.ZodString;
524
549
  at: z.ZodNumber;
525
550
  kind: z.ZodLiteral<"seek">;
551
+ }, z.core.$strip>, z.ZodObject<{
552
+ kind: z.ZodLiteral<"focus">;
553
+ field: z.ZodString;
526
554
  }, z.core.$strip>], "kind">;
527
555
  variant: z.ZodDefault<z.ZodEnum<{
528
556
  destructive: "destructive";
529
557
  secondary: "secondary";
530
558
  primary: "primary";
559
+ ghost: "ghost";
531
560
  }>>;
532
561
  disabled: z.ZodDefault<z.ZodBoolean>;
533
562
  hint: z.ZodOptional<z.ZodString>;
@@ -574,9 +603,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
574
603
  list: "list";
575
604
  select: "select";
576
605
  checkbox: "checkbox";
577
- multiselect: "multiselect";
578
606
  textarea: "textarea";
579
607
  combobox: "combobox";
608
+ multiselect: "multiselect";
580
609
  radio: "radio";
581
610
  }>;
582
611
  name: z.ZodString;
@@ -773,6 +802,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
773
802
  player: z.ZodString;
774
803
  at: z.ZodNumber;
775
804
  kind: z.ZodLiteral<"seek">;
805
+ }, z.core.$strip>, z.ZodObject<{
806
+ kind: z.ZodLiteral<"focus">;
807
+ field: z.ZodString;
776
808
  }, z.core.$strip>], "kind">>;
777
809
  expand: z.ZodOptional<z.ZodObject<{
778
810
  children: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -879,6 +911,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
879
911
  player: z.ZodString;
880
912
  at: z.ZodNumber;
881
913
  kind: z.ZodLiteral<"seek">;
914
+ }, z.core.$strip>, z.ZodObject<{
915
+ kind: z.ZodLiteral<"focus">;
916
+ field: z.ZodString;
882
917
  }, z.core.$strip>], "kind">>;
883
918
  selected: z.ZodOptional<z.ZodBoolean>;
884
919
  bar: z.ZodOptional<z.ZodObject<{
@@ -919,11 +954,15 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
919
954
  player: z.ZodString;
920
955
  at: z.ZodNumber;
921
956
  kind: z.ZodLiteral<"seek">;
957
+ }, z.core.$strip>, z.ZodObject<{
958
+ kind: z.ZodLiteral<"focus">;
959
+ field: z.ZodString;
922
960
  }, z.core.$strip>], "kind">;
923
961
  variant: z.ZodDefault<z.ZodEnum<{
924
962
  destructive: "destructive";
925
963
  secondary: "secondary";
926
964
  primary: "primary";
965
+ ghost: "ghost";
927
966
  }>>;
928
967
  disabled: z.ZodDefault<z.ZodBoolean>;
929
968
  hint: z.ZodOptional<z.ZodString>;
@@ -983,11 +1022,15 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
983
1022
  player: z.ZodString;
984
1023
  at: z.ZodNumber;
985
1024
  kind: z.ZodLiteral<"seek">;
1025
+ }, z.core.$strip>, z.ZodObject<{
1026
+ kind: z.ZodLiteral<"focus">;
1027
+ field: z.ZodString;
986
1028
  }, z.core.$strip>], "kind">;
987
1029
  variant: z.ZodDefault<z.ZodEnum<{
988
1030
  destructive: "destructive";
989
1031
  secondary: "secondary";
990
1032
  primary: "primary";
1033
+ ghost: "ghost";
991
1034
  }>>;
992
1035
  disabled: z.ZodDefault<z.ZodBoolean>;
993
1036
  hint: z.ZodOptional<z.ZodString>;
@@ -1121,6 +1164,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1121
1164
  player: z.ZodString;
1122
1165
  at: z.ZodNumber;
1123
1166
  kind: z.ZodLiteral<"seek">;
1167
+ }, z.core.$strip>, z.ZodObject<{
1168
+ kind: z.ZodLiteral<"focus">;
1169
+ field: z.ZodString;
1124
1170
  }, z.core.$strip>], "kind">>;
1125
1171
  tone: z.ZodOptional<z.ZodEnum<{
1126
1172
  default: "default";
@@ -1164,6 +1210,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1164
1210
  player: z.ZodString;
1165
1211
  at: z.ZodNumber;
1166
1212
  kind: z.ZodLiteral<"seek">;
1213
+ }, z.core.$strip>, z.ZodObject<{
1214
+ kind: z.ZodLiteral<"focus">;
1215
+ field: z.ZodString;
1167
1216
  }, z.core.$strip>], "kind">;
1168
1217
  }, z.core.$strip>>;
1169
1218
  }, z.core.$strip>>;
@@ -1294,11 +1343,15 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1294
1343
  player: z.ZodString;
1295
1344
  at: z.ZodNumber;
1296
1345
  kind: z.ZodLiteral<"seek">;
1346
+ }, z.core.$strip>, z.ZodObject<{
1347
+ kind: z.ZodLiteral<"focus">;
1348
+ field: z.ZodString;
1297
1349
  }, z.core.$strip>], "kind">;
1298
1350
  variant: z.ZodDefault<z.ZodEnum<{
1299
1351
  destructive: "destructive";
1300
1352
  secondary: "secondary";
1301
1353
  primary: "primary";
1354
+ ghost: "ghost";
1302
1355
  }>>;
1303
1356
  disabled: z.ZodDefault<z.ZodBoolean>;
1304
1357
  hint: z.ZodOptional<z.ZodString>;
@@ -1483,6 +1536,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1483
1536
  player: z.ZodString;
1484
1537
  at: z.ZodNumber;
1485
1538
  kind: z.ZodLiteral<"seek">;
1539
+ }, z.core.$strip>, z.ZodObject<{
1540
+ kind: z.ZodLiteral<"focus">;
1541
+ field: z.ZodString;
1486
1542
  }, z.core.$strip>], "kind">>;
1487
1543
  }, z.core.$strip>>;
1488
1544
  }, z.core.$strip>>;
@@ -1618,6 +1674,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1618
1674
  player: z.ZodString;
1619
1675
  at: z.ZodNumber;
1620
1676
  kind: z.ZodLiteral<"seek">;
1677
+ }, z.core.$strip>, z.ZodObject<{
1678
+ kind: z.ZodLiteral<"focus">;
1679
+ field: z.ZodString;
1621
1680
  }, z.core.$strip>], "kind">>;
1622
1681
  selected: z.ZodOptional<z.ZodBoolean>;
1623
1682
  }, z.core.$strip>>;
@@ -1814,11 +1873,15 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1814
1873
  player: z.ZodString;
1815
1874
  at: z.ZodNumber;
1816
1875
  kind: z.ZodLiteral<"seek">;
1876
+ }, z.core.$strip>, z.ZodObject<{
1877
+ kind: z.ZodLiteral<"focus">;
1878
+ field: z.ZodString;
1817
1879
  }, z.core.$strip>], "kind">;
1818
1880
  variant: z.ZodDefault<z.ZodEnum<{
1819
1881
  destructive: "destructive";
1820
1882
  secondary: "secondary";
1821
1883
  primary: "primary";
1884
+ ghost: "ghost";
1822
1885
  }>>;
1823
1886
  disabled: z.ZodDefault<z.ZodBoolean>;
1824
1887
  hint: z.ZodOptional<z.ZodString>;
@@ -1874,6 +1937,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1874
1937
  player: z.ZodString;
1875
1938
  at: z.ZodNumber;
1876
1939
  kind: z.ZodLiteral<"seek">;
1940
+ }, z.core.$strip>, z.ZodObject<{
1941
+ kind: z.ZodLiteral<"focus">;
1942
+ field: z.ZodString;
1877
1943
  }, z.core.$strip>], "kind">>;
1878
1944
  }, z.core.$strip>>;
1879
1945
  onSlotPress: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1931,6 +1997,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1931
1997
  player: z.ZodString;
1932
1998
  at: z.ZodNumber;
1933
1999
  kind: z.ZodLiteral<"seek">;
2000
+ }, z.core.$strip>, z.ZodObject<{
2001
+ kind: z.ZodLiteral<"focus">;
2002
+ field: z.ZodString;
1934
2003
  }, z.core.$strip>], "kind">>;
1935
2004
  }, z.core.$strip>, z.ZodObject<{
1936
2005
  type: z.ZodLiteral<"video">;
@@ -2234,11 +2303,15 @@ export declare const screenTreeSchema: z.ZodObject<{
2234
2303
  player: z.ZodString;
2235
2304
  at: z.ZodNumber;
2236
2305
  kind: z.ZodLiteral<"seek">;
2306
+ }, z.core.$strip>, z.ZodObject<{
2307
+ kind: z.ZodLiteral<"focus">;
2308
+ field: z.ZodString;
2237
2309
  }, z.core.$strip>], "kind">;
2238
2310
  variant: z.ZodDefault<z.ZodEnum<{
2239
2311
  destructive: "destructive";
2240
2312
  secondary: "secondary";
2241
2313
  primary: "primary";
2314
+ ghost: "ghost";
2242
2315
  }>>;
2243
2316
  disabled: z.ZodDefault<z.ZodBoolean>;
2244
2317
  hint: z.ZodOptional<z.ZodString>;
@@ -2476,11 +2549,15 @@ export declare const actionResultSchema: z.ZodObject<{
2476
2549
  player: z.ZodString;
2477
2550
  at: z.ZodNumber;
2478
2551
  kind: z.ZodLiteral<"seek">;
2552
+ }, z.core.$strip>, z.ZodObject<{
2553
+ kind: z.ZodLiteral<"focus">;
2554
+ field: z.ZodString;
2479
2555
  }, z.core.$strip>], "kind">;
2480
2556
  variant: z.ZodDefault<z.ZodEnum<{
2481
2557
  destructive: "destructive";
2482
2558
  secondary: "secondary";
2483
2559
  primary: "primary";
2560
+ ghost: "ghost";
2484
2561
  }>>;
2485
2562
  disabled: z.ZodDefault<z.ZodBoolean>;
2486
2563
  hint: z.ZodOptional<z.ZodString>;
@@ -2711,11 +2788,15 @@ export declare const jobStatusSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2711
2788
  player: z.ZodString;
2712
2789
  at: z.ZodNumber;
2713
2790
  kind: z.ZodLiteral<"seek">;
2791
+ }, z.core.$strip>, z.ZodObject<{
2792
+ kind: z.ZodLiteral<"focus">;
2793
+ field: z.ZodString;
2714
2794
  }, z.core.$strip>], "kind">;
2715
2795
  variant: z.ZodDefault<z.ZodEnum<{
2716
2796
  destructive: "destructive";
2717
2797
  secondary: "secondary";
2718
2798
  primary: "primary";
2799
+ ghost: "ghost";
2719
2800
  }>>;
2720
2801
  disabled: z.ZodDefault<z.ZodBoolean>;
2721
2802
  hint: z.ZodOptional<z.ZodString>;
@@ -2936,11 +3017,15 @@ export declare const screenLoadResponseSchema: z.ZodObject<{
2936
3017
  player: z.ZodString;
2937
3018
  at: z.ZodNumber;
2938
3019
  kind: z.ZodLiteral<"seek">;
3020
+ }, z.core.$strip>, z.ZodObject<{
3021
+ kind: z.ZodLiteral<"focus">;
3022
+ field: z.ZodString;
2939
3023
  }, z.core.$strip>], "kind">;
2940
3024
  variant: z.ZodDefault<z.ZodEnum<{
2941
3025
  destructive: "destructive";
2942
3026
  secondary: "secondary";
2943
3027
  primary: "primary";
3028
+ ghost: "ghost";
2944
3029
  }>>;
2945
3030
  disabled: z.ZodDefault<z.ZodBoolean>;
2946
3031
  hint: z.ZodOptional<z.ZodString>;
@@ -3117,6 +3202,7 @@ export type ValuePress = z.infer<typeof valuePressSchema>;
3117
3202
  export type ChatPress = z.infer<typeof chatPressSchema>;
3118
3203
  export type SeekPress = z.infer<typeof seekPressSchema>;
3119
3204
  export type SeekPoint = z.infer<typeof seekPointSchema>;
3205
+ export type FocusPress = z.infer<typeof focusPressSchema>;
3120
3206
  export type NavigatePress = z.infer<typeof openingNavigatePressSchema>;
3121
3207
  export type NavigateOpen = (typeof NAVIGATE_OPENS)[number];
3122
3208
  export type ScreenPresentation = z.infer<typeof screenPresentationSchema>;
package/dist/schema.js CHANGED
@@ -16,6 +16,7 @@ import { CHART_POINTS_MAX } from './chart.js';
16
16
  import { isDateLocale } from './date-format.js';
17
17
  import { datasetNodeSchema } from './dataset-view.js';
18
18
  import { MARKDOWN_LINKS_MAX } from './markdown-links.js';
19
+ import { focusesIn, focusIssue } from './focus.js';
19
20
  import { SEEK_AT_MAX, seeksIn } from './player.js';
20
21
  import { UI_ICONS } from './icon.js';
21
22
  import { TIMELINE_ICONS } from './timeline.js';
@@ -54,7 +55,11 @@ export const NAVIGATE_OPENS = ['drawer'];
54
55
  * - a press in it with `open: 'drawer'`, and an action result's `navigate`, show that screen in
55
56
  * the same drawer (a drawer never opens another drawer);
56
57
  * - a press in it without `open` leaves the drawer and opens the screen as a page;
57
- * - `refresh` and a returned `tree` refresh the drawer, not the screen underneath;
58
+ * - an action run in it that succeeds closes it ("Approve", "Done": the item is dealt with),
59
+ * unless its result returns a `tree` (the drawer is drawn again as it now is) or a `navigate`
60
+ * (the drawer moves on). A failed action keeps it open, with the failure said;
61
+ * - `refresh` refreshes the drawer, not the screen underneath, for an action that keeps it open
62
+ * (a finished job's result follows the same rule);
58
63
  * - closing it reads the screen underneath again when an action ran in it, so "Mark done" in
59
64
  * the drawer shows on the list.
60
65
  * The drawer is not in the address: a reload shows the screen underneath, and a link opens a
@@ -112,6 +117,18 @@ export const seekPressSchema = z.object({
112
117
  kind: z.literal('seek'),
113
118
  ...seekPointSchema.shape,
114
119
  });
120
+ /**
121
+ * Puts the caret at the end of a form field on the same screen, so the reader can start typing:
122
+ * "Edit draft" beside "Approve & send". `field` is the `name` of a `text`, `textarea` or `combobox`
123
+ * field, and exactly one field on the screen has it (checked when the tree is parsed). It is drawn
124
+ * and handled by the renderer alone: nothing is posted to the module and the host never sees it.
125
+ * A field that is not drawn (hidden by its `showWhen`) leaves the press doing nothing.
126
+ */
127
+ export const focusPressSchema = z.object({
128
+ kind: z.literal('focus'),
129
+ /** The `name` of a form field on this screen. */
130
+ field: slug,
131
+ });
115
132
  /**
116
133
  * What a control that applies a chosen value calls: a pager, a select, a
117
134
  * toggle, a sort or filter header. The value is merged in (`pressWithValue`),
@@ -127,14 +144,15 @@ export const valuePressSchema = z.discriminatedUnion('kind', [
127
144
  * What a button (or table row, card, choice, calendar entry, image) does when
128
145
  * pressed: call an action, open another screen of the module (as a page, or in
129
146
  * a drawer over this one with `open: 'drawer'`), open the chat with a prompt
130
- * typed in (`chat`, never sent), or move a recording on the screen to a moment
131
- * (`seek`).
147
+ * typed in (`chat`, never sent), move a recording on the screen to a moment
148
+ * (`seek`), or put the caret in a form field on the screen (`focus`).
132
149
  */
133
150
  export const pressSchema = z.discriminatedUnion('kind', [
134
151
  actionPressSchema,
135
152
  openingNavigatePressSchema,
136
153
  chatPressSchema,
137
154
  seekPressSchema,
155
+ focusPressSchema,
138
156
  ]);
139
157
  /**
140
158
  * Edit one part of a record where it stands (`edit` on `text`, `markdown`, `details` and a
@@ -218,7 +236,12 @@ const buttonShape = z.object({
218
236
  /** What the button does. Also the accessible name and the tooltip of an icon-only button. */
219
237
  label: z.string().max(80),
220
238
  onPress: pressSchema,
221
- variant: z.enum(['primary', 'secondary', 'destructive']).default('secondary'),
239
+ /**
240
+ * How much weight the button carries. `ghost` is lighter than `secondary`: no border, quiet
241
+ * text, for a way out beside the real actions (Ask Operator, Open account at the end of a
242
+ * drawer's row). An app whose parse predates `ghost` draws it as `secondary`.
243
+ */
244
+ variant: z.enum(['primary', 'secondary', 'destructive', 'ghost']).default('secondary'),
222
245
  /** Shown but not pressable — a Next button on the last page, an action not yet available. */
223
246
  disabled: z.boolean().default(false),
224
247
  /** A short explanation shown next to the button on hover or keyboard focus. */
@@ -2737,6 +2760,13 @@ export const screenTreeSchema = z
2737
2760
  });
2738
2761
  }
2739
2762
  }
2763
+ // A focus puts the caret in one field the reader types into; it must name exactly one.
2764
+ const { fields, focuses } = focusesIn(tree);
2765
+ for (const focus of focuses) {
2766
+ const issue = focusIssue(focus.field, fields);
2767
+ if (issue)
2768
+ ctx.addIssue({ code: 'custom', path: focus.path, message: issue });
2769
+ }
2740
2770
  const rail = tree.presentation?.rightRail;
2741
2771
  if (!rail)
2742
2772
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keemakr/ui-sdk",
3
- "version": "1.6.0-dev-20261029083803",
3
+ "version": "1.6.0-dev-20261029102802",
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",