@keemakr/ui-sdk 1.6.0-dev-20261029083138 → 1.6.0-dev-20261029101536

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.
@@ -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
@@ -85,6 +85,17 @@ export declare const seekPressSchema: z.ZodObject<{
85
85
  at: z.ZodNumber;
86
86
  kind: z.ZodLiteral<"seek">;
87
87
  }, z.core.$strip>;
88
+ /**
89
+ * Puts the caret at the end of a form field on the same screen, so the reader can start typing:
90
+ * "Edit draft" beside "Approve & send". `field` is the `name` of a `text`, `textarea` or `combobox`
91
+ * field, and exactly one field on the screen has it (checked when the tree is parsed). It is drawn
92
+ * and handled by the renderer alone: nothing is posted to the module and the host never sees it.
93
+ * A field that is not drawn (hidden by its `showWhen`) leaves the press doing nothing.
94
+ */
95
+ export declare const focusPressSchema: z.ZodObject<{
96
+ kind: z.ZodLiteral<"focus">;
97
+ field: z.ZodString;
98
+ }, z.core.$strip>;
88
99
  /**
89
100
  * What a control that applies a chosen value calls: a pager, a select, a
90
101
  * toggle, a sort or filter header. The value is merged in (`pressWithValue`),
@@ -106,8 +117,8 @@ export declare const valuePressSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
106
117
  * What a button (or table row, card, choice, calendar entry, image) does when
107
118
  * pressed: call an action, open another screen of the module (as a page, or in
108
119
  * 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`).
120
+ * typed in (`chat`, never sent), move a recording on the screen to a moment
121
+ * (`seek`), or put the caret in a form field on the screen (`focus`).
111
122
  */
112
123
  export declare const pressSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
113
124
  kind: z.ZodLiteral<"action">;
@@ -129,6 +140,9 @@ export declare const pressSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
129
140
  player: z.ZodString;
130
141
  at: z.ZodNumber;
131
142
  kind: z.ZodLiteral<"seek">;
143
+ }, z.core.$strip>, z.ZodObject<{
144
+ kind: z.ZodLiteral<"focus">;
145
+ field: z.ZodString;
132
146
  }, z.core.$strip>], "kind">;
133
147
  /**
134
148
  * How a screen writes its dates and times. Set on the tree for the whole screen;
@@ -173,6 +187,9 @@ export declare const buttonSchema: z.ZodObject<{
173
187
  player: z.ZodString;
174
188
  at: z.ZodNumber;
175
189
  kind: z.ZodLiteral<"seek">;
190
+ }, z.core.$strip>, z.ZodObject<{
191
+ kind: z.ZodLiteral<"focus">;
192
+ field: z.ZodString;
176
193
  }, z.core.$strip>], "kind">;
177
194
  variant: z.ZodDefault<z.ZodEnum<{
178
195
  destructive: "destructive";
@@ -483,6 +500,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
483
500
  player: z.ZodString;
484
501
  at: z.ZodNumber;
485
502
  kind: z.ZodLiteral<"seek">;
503
+ }, z.core.$strip>, z.ZodObject<{
504
+ kind: z.ZodLiteral<"focus">;
505
+ field: z.ZodString;
486
506
  }, z.core.$strip>], "kind">>;
487
507
  selected: z.ZodOptional<z.ZodBoolean>;
488
508
  bar: z.ZodOptional<z.ZodObject<{
@@ -523,6 +543,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
523
543
  player: z.ZodString;
524
544
  at: z.ZodNumber;
525
545
  kind: z.ZodLiteral<"seek">;
546
+ }, z.core.$strip>, z.ZodObject<{
547
+ kind: z.ZodLiteral<"focus">;
548
+ field: z.ZodString;
526
549
  }, z.core.$strip>], "kind">;
527
550
  variant: z.ZodDefault<z.ZodEnum<{
528
551
  destructive: "destructive";
@@ -574,9 +597,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
574
597
  list: "list";
575
598
  select: "select";
576
599
  checkbox: "checkbox";
577
- multiselect: "multiselect";
578
600
  textarea: "textarea";
579
601
  combobox: "combobox";
602
+ multiselect: "multiselect";
580
603
  radio: "radio";
581
604
  }>;
582
605
  name: z.ZodString;
@@ -773,6 +796,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
773
796
  player: z.ZodString;
774
797
  at: z.ZodNumber;
775
798
  kind: z.ZodLiteral<"seek">;
799
+ }, z.core.$strip>, z.ZodObject<{
800
+ kind: z.ZodLiteral<"focus">;
801
+ field: z.ZodString;
776
802
  }, z.core.$strip>], "kind">>;
777
803
  expand: z.ZodOptional<z.ZodObject<{
778
804
  children: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -879,6 +905,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
879
905
  player: z.ZodString;
880
906
  at: z.ZodNumber;
881
907
  kind: z.ZodLiteral<"seek">;
908
+ }, z.core.$strip>, z.ZodObject<{
909
+ kind: z.ZodLiteral<"focus">;
910
+ field: z.ZodString;
882
911
  }, z.core.$strip>], "kind">>;
883
912
  selected: z.ZodOptional<z.ZodBoolean>;
884
913
  bar: z.ZodOptional<z.ZodObject<{
@@ -919,6 +948,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
919
948
  player: z.ZodString;
920
949
  at: z.ZodNumber;
921
950
  kind: z.ZodLiteral<"seek">;
951
+ }, z.core.$strip>, z.ZodObject<{
952
+ kind: z.ZodLiteral<"focus">;
953
+ field: z.ZodString;
922
954
  }, z.core.$strip>], "kind">;
923
955
  variant: z.ZodDefault<z.ZodEnum<{
924
956
  destructive: "destructive";
@@ -983,6 +1015,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
983
1015
  player: z.ZodString;
984
1016
  at: z.ZodNumber;
985
1017
  kind: z.ZodLiteral<"seek">;
1018
+ }, z.core.$strip>, z.ZodObject<{
1019
+ kind: z.ZodLiteral<"focus">;
1020
+ field: z.ZodString;
986
1021
  }, z.core.$strip>], "kind">;
987
1022
  variant: z.ZodDefault<z.ZodEnum<{
988
1023
  destructive: "destructive";
@@ -1121,6 +1156,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1121
1156
  player: z.ZodString;
1122
1157
  at: z.ZodNumber;
1123
1158
  kind: z.ZodLiteral<"seek">;
1159
+ }, z.core.$strip>, z.ZodObject<{
1160
+ kind: z.ZodLiteral<"focus">;
1161
+ field: z.ZodString;
1124
1162
  }, z.core.$strip>], "kind">>;
1125
1163
  tone: z.ZodOptional<z.ZodEnum<{
1126
1164
  default: "default";
@@ -1164,6 +1202,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1164
1202
  player: z.ZodString;
1165
1203
  at: z.ZodNumber;
1166
1204
  kind: z.ZodLiteral<"seek">;
1205
+ }, z.core.$strip>, z.ZodObject<{
1206
+ kind: z.ZodLiteral<"focus">;
1207
+ field: z.ZodString;
1167
1208
  }, z.core.$strip>], "kind">;
1168
1209
  }, z.core.$strip>>;
1169
1210
  }, z.core.$strip>>;
@@ -1294,6 +1335,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1294
1335
  player: z.ZodString;
1295
1336
  at: z.ZodNumber;
1296
1337
  kind: z.ZodLiteral<"seek">;
1338
+ }, z.core.$strip>, z.ZodObject<{
1339
+ kind: z.ZodLiteral<"focus">;
1340
+ field: z.ZodString;
1297
1341
  }, z.core.$strip>], "kind">;
1298
1342
  variant: z.ZodDefault<z.ZodEnum<{
1299
1343
  destructive: "destructive";
@@ -1483,6 +1527,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1483
1527
  player: z.ZodString;
1484
1528
  at: z.ZodNumber;
1485
1529
  kind: z.ZodLiteral<"seek">;
1530
+ }, z.core.$strip>, z.ZodObject<{
1531
+ kind: z.ZodLiteral<"focus">;
1532
+ field: z.ZodString;
1486
1533
  }, z.core.$strip>], "kind">>;
1487
1534
  }, z.core.$strip>>;
1488
1535
  }, z.core.$strip>>;
@@ -1618,6 +1665,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1618
1665
  player: z.ZodString;
1619
1666
  at: z.ZodNumber;
1620
1667
  kind: z.ZodLiteral<"seek">;
1668
+ }, z.core.$strip>, z.ZodObject<{
1669
+ kind: z.ZodLiteral<"focus">;
1670
+ field: z.ZodString;
1621
1671
  }, z.core.$strip>], "kind">>;
1622
1672
  selected: z.ZodOptional<z.ZodBoolean>;
1623
1673
  }, z.core.$strip>>;
@@ -1814,6 +1864,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1814
1864
  player: z.ZodString;
1815
1865
  at: z.ZodNumber;
1816
1866
  kind: z.ZodLiteral<"seek">;
1867
+ }, z.core.$strip>, z.ZodObject<{
1868
+ kind: z.ZodLiteral<"focus">;
1869
+ field: z.ZodString;
1817
1870
  }, z.core.$strip>], "kind">;
1818
1871
  variant: z.ZodDefault<z.ZodEnum<{
1819
1872
  destructive: "destructive";
@@ -1874,6 +1927,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1874
1927
  player: z.ZodString;
1875
1928
  at: z.ZodNumber;
1876
1929
  kind: z.ZodLiteral<"seek">;
1930
+ }, z.core.$strip>, z.ZodObject<{
1931
+ kind: z.ZodLiteral<"focus">;
1932
+ field: z.ZodString;
1877
1933
  }, z.core.$strip>], "kind">>;
1878
1934
  }, z.core.$strip>>;
1879
1935
  onSlotPress: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1931,6 +1987,9 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1931
1987
  player: z.ZodString;
1932
1988
  at: z.ZodNumber;
1933
1989
  kind: z.ZodLiteral<"seek">;
1990
+ }, z.core.$strip>, z.ZodObject<{
1991
+ kind: z.ZodLiteral<"focus">;
1992
+ field: z.ZodString;
1934
1993
  }, z.core.$strip>], "kind">>;
1935
1994
  }, z.core.$strip>, z.ZodObject<{
1936
1995
  type: z.ZodLiteral<"video">;
@@ -2234,6 +2293,9 @@ export declare const screenTreeSchema: z.ZodObject<{
2234
2293
  player: z.ZodString;
2235
2294
  at: z.ZodNumber;
2236
2295
  kind: z.ZodLiteral<"seek">;
2296
+ }, z.core.$strip>, z.ZodObject<{
2297
+ kind: z.ZodLiteral<"focus">;
2298
+ field: z.ZodString;
2237
2299
  }, z.core.$strip>], "kind">;
2238
2300
  variant: z.ZodDefault<z.ZodEnum<{
2239
2301
  destructive: "destructive";
@@ -2476,6 +2538,9 @@ export declare const actionResultSchema: z.ZodObject<{
2476
2538
  player: z.ZodString;
2477
2539
  at: z.ZodNumber;
2478
2540
  kind: z.ZodLiteral<"seek">;
2541
+ }, z.core.$strip>, z.ZodObject<{
2542
+ kind: z.ZodLiteral<"focus">;
2543
+ field: z.ZodString;
2479
2544
  }, z.core.$strip>], "kind">;
2480
2545
  variant: z.ZodDefault<z.ZodEnum<{
2481
2546
  destructive: "destructive";
@@ -2711,6 +2776,9 @@ export declare const jobStatusSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2711
2776
  player: z.ZodString;
2712
2777
  at: z.ZodNumber;
2713
2778
  kind: z.ZodLiteral<"seek">;
2779
+ }, z.core.$strip>, z.ZodObject<{
2780
+ kind: z.ZodLiteral<"focus">;
2781
+ field: z.ZodString;
2714
2782
  }, z.core.$strip>], "kind">;
2715
2783
  variant: z.ZodDefault<z.ZodEnum<{
2716
2784
  destructive: "destructive";
@@ -2936,6 +3004,9 @@ export declare const screenLoadResponseSchema: z.ZodObject<{
2936
3004
  player: z.ZodString;
2937
3005
  at: z.ZodNumber;
2938
3006
  kind: z.ZodLiteral<"seek">;
3007
+ }, z.core.$strip>, z.ZodObject<{
3008
+ kind: z.ZodLiteral<"focus">;
3009
+ field: z.ZodString;
2939
3010
  }, z.core.$strip>], "kind">;
2940
3011
  variant: z.ZodDefault<z.ZodEnum<{
2941
3012
  destructive: "destructive";
@@ -3117,6 +3188,7 @@ export type ValuePress = z.infer<typeof valuePressSchema>;
3117
3188
  export type ChatPress = z.infer<typeof chatPressSchema>;
3118
3189
  export type SeekPress = z.infer<typeof seekPressSchema>;
3119
3190
  export type SeekPoint = z.infer<typeof seekPointSchema>;
3191
+ export type FocusPress = z.infer<typeof focusPressSchema>;
3120
3192
  export type NavigatePress = z.infer<typeof openingNavigatePressSchema>;
3121
3193
  export type NavigateOpen = (typeof NAVIGATE_OPENS)[number];
3122
3194
  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';
@@ -112,6 +113,18 @@ export const seekPressSchema = z.object({
112
113
  kind: z.literal('seek'),
113
114
  ...seekPointSchema.shape,
114
115
  });
116
+ /**
117
+ * Puts the caret at the end of a form field on the same screen, so the reader can start typing:
118
+ * "Edit draft" beside "Approve & send". `field` is the `name` of a `text`, `textarea` or `combobox`
119
+ * field, and exactly one field on the screen has it (checked when the tree is parsed). It is drawn
120
+ * and handled by the renderer alone: nothing is posted to the module and the host never sees it.
121
+ * A field that is not drawn (hidden by its `showWhen`) leaves the press doing nothing.
122
+ */
123
+ export const focusPressSchema = z.object({
124
+ kind: z.literal('focus'),
125
+ /** The `name` of a form field on this screen. */
126
+ field: slug,
127
+ });
115
128
  /**
116
129
  * What a control that applies a chosen value calls: a pager, a select, a
117
130
  * toggle, a sort or filter header. The value is merged in (`pressWithValue`),
@@ -127,14 +140,15 @@ export const valuePressSchema = z.discriminatedUnion('kind', [
127
140
  * What a button (or table row, card, choice, calendar entry, image) does when
128
141
  * pressed: call an action, open another screen of the module (as a page, or in
129
142
  * 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`).
143
+ * typed in (`chat`, never sent), move a recording on the screen to a moment
144
+ * (`seek`), or put the caret in a form field on the screen (`focus`).
132
145
  */
133
146
  export const pressSchema = z.discriminatedUnion('kind', [
134
147
  actionPressSchema,
135
148
  openingNavigatePressSchema,
136
149
  chatPressSchema,
137
150
  seekPressSchema,
151
+ focusPressSchema,
138
152
  ]);
139
153
  /**
140
154
  * Edit one part of a record where it stands (`edit` on `text`, `markdown`, `details` and a
@@ -2737,6 +2751,13 @@ export const screenTreeSchema = z
2737
2751
  });
2738
2752
  }
2739
2753
  }
2754
+ // A focus puts the caret in one field the reader types into; it must name exactly one.
2755
+ const { fields, focuses } = focusesIn(tree);
2756
+ for (const focus of focuses) {
2757
+ const issue = focusIssue(focus.field, fields);
2758
+ if (issue)
2759
+ ctx.addIssue({ code: 'custom', path: focus.path, message: issue });
2760
+ }
2740
2761
  const rail = tree.presentation?.rightRail;
2741
2762
  if (!rail)
2742
2763
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keemakr/ui-sdk",
3
- "version": "1.6.0-dev-20261029083138",
3
+ "version": "1.6.0-dev-20261029101536",
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",