@keemakr/ui-sdk 1.6.0-dev-20261027083656 → 1.6.0-dev-20261027084552

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.
@@ -71,8 +71,12 @@ import type { ChatPress, ScreenRootNode, ScreenTree } from './schema.js';
71
71
  * published release; core's own renderer draws it). An older parse strips it without a sign,
72
72
  * so without it the bar's legend ("Red 8 · Amber 13 · Green 29") is written into the tile's
73
73
  * `hint`, after any hint it had, and the bar is dropped.
74
+ * - `section.action`: a section's `action`, a press drawn at the right end of its title line
75
+ * (newer than any published release; core's own renderer draws it). An older parse strips it,
76
+ * so without it the action becomes a `button` with the same label and press, last in the
77
+ * section, and the reader can still go where it led. A full section drops it.
74
78
  */
75
- 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';
79
+ 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';
76
80
  /** The node types and features one ui-sdk release, or one client, draws. */
77
81
  export interface NodeSet {
78
82
  /** For messages: "ui-sdk 1.4.0", "mobile 0.2.5". */
@@ -109,7 +113,7 @@ export declare const UI_SDK_SNAPSHOTS: {
109
113
  readonly current: {
110
114
  readonly name: "ui-sdk (this package)";
111
115
  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"];
112
- 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"];
116
+ 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"];
113
117
  };
114
118
  };
115
119
  export type UiSdkSnapshot = keyof typeof UI_SDK_SNAPSHOTS;
package/dist/negotiate.js CHANGED
@@ -51,6 +51,7 @@ const ALL_FEATURES = [
51
51
  'edit.inline',
52
52
  'timeline.time_tag',
53
53
  'stat.bar',
54
+ 'section.action',
54
55
  ];
55
56
  /** The nodes of ui-sdk 1.1.0 and 1.2.0 (one schema). */
56
57
  const NODES_1_1_0 = [
@@ -339,6 +340,9 @@ export function negotiateTree(tree, set) {
339
340
  fallbacks.push({ path, type: 'section', reason: 'section.row', as: 'folded' });
340
341
  next = { ...next, layout: 'stack' };
341
342
  }
343
+ if (next.action && !features.has('section.action')) {
344
+ next = foldSectionAction(next, path, fallbacks);
345
+ }
342
346
  return next;
343
347
  }
344
348
  case 'form': {
@@ -617,6 +621,38 @@ export function foldChoiceActions(node, path, fallbacks) {
617
621
  });
618
622
  return { ...node, choices };
619
623
  }
624
+ /**
625
+ * A section with its `action` moved into its body as a last `button`, for a client that does not
626
+ * draw the action on the title line (`section.action`). Dropped when the section is full.
627
+ */
628
+ function foldSectionAction(node, path, fallbacks) {
629
+ const { action, ...rest } = node;
630
+ if (!action)
631
+ return node;
632
+ if (rest.children.length >= CHILDREN_MAX) {
633
+ fallbacks.push({
634
+ path: `${path}.action`,
635
+ type: 'section',
636
+ reason: 'section.action',
637
+ as: 'dropped',
638
+ });
639
+ return rest;
640
+ }
641
+ fallbacks.push({
642
+ path: `${path}.action`,
643
+ type: 'section',
644
+ reason: 'section.action',
645
+ as: 'folded',
646
+ });
647
+ const button = {
648
+ type: 'button',
649
+ label: action.label,
650
+ onPress: action.onPress,
651
+ variant: 'secondary',
652
+ disabled: false,
653
+ };
654
+ return { ...rest, children: [...rest.children, button] };
655
+ }
620
656
  /**
621
657
  * The node as a client that draws no edit control should get it (`edit.inline`): the same block,
622
658
  * read-only. Drops `edit` from a `text`, `markdown` or `details` block and its items, and from each
@@ -687,6 +723,11 @@ function withoutPresses(node, path, fallbacks, matches, reason) {
687
723
  return node;
688
724
  dropped(`${path}.action`, 'button');
689
725
  return omit(node, 'action');
726
+ case 'section':
727
+ if (!node.action || !matches(node.action.onPress))
728
+ return node;
729
+ dropped(`${path}.action`, 'section');
730
+ return omit(node, 'action');
690
731
  case 'image':
691
732
  if (!matches(node.onPress))
692
733
  return node;
package/dist/schema.d.ts CHANGED
@@ -1919,6 +1919,10 @@ export type ScreenNode = LeafScreenNode | {
1919
1919
  badge?: string;
1920
1920
  badgeTone?: 'default' | 'success' | 'warning' | 'destructive' | 'info' | 'accent';
1921
1921
  icon?: UiIcon;
1922
+ action?: {
1923
+ label: string;
1924
+ onPress: Press;
1925
+ };
1922
1926
  children: ScreenNode[];
1923
1927
  };
1924
1928
  type ScreenNodeInput = LeafScreenNodeInput | {
@@ -1939,6 +1943,10 @@ type ScreenNodeInput = LeafScreenNodeInput | {
1939
1943
  badge?: string;
1940
1944
  badgeTone?: 'default' | 'success' | 'warning' | 'destructive' | 'info' | 'accent';
1941
1945
  icon?: UiIcon;
1946
+ action?: {
1947
+ label: string;
1948
+ onPress: z.input<typeof pressSchema>;
1949
+ };
1942
1950
  children: ScreenNodeInput[];
1943
1951
  };
1944
1952
  /**
package/dist/schema.js CHANGED
@@ -2275,6 +2275,16 @@ const sectionShape = (children) => z.object({
2275
2275
  * apart at a glance. Decorative: the title says what the section is. Needs a `title`.
2276
2276
  */
2277
2277
  icon: z.enum(UI_ICONS).optional(),
2278
+ /**
2279
+ * A press at the right end of the title line: "All", "Open", "See all 13 amber". Drawn as a
2280
+ * quiet text button, so the label says where it goes. Needs a `title`.
2281
+ */
2282
+ action: z
2283
+ .object({
2284
+ label: z.string().min(1).max(40),
2285
+ onPress: pressSchema,
2286
+ })
2287
+ .optional(),
2278
2288
  children: z.array(children).max(100),
2279
2289
  });
2280
2290
  /** The rules between a section's fields, which a field's own schema cannot state. */
@@ -2344,6 +2354,13 @@ function checkSection(node, ctx) {
2344
2354
  message: 'a section icon sits before its title, so it needs a title',
2345
2355
  });
2346
2356
  }
2357
+ if (node.action !== undefined && !node.title) {
2358
+ ctx.addIssue({
2359
+ code: 'custom',
2360
+ path: ['action'],
2361
+ message: 'a section action sits on its title line, so it needs a title',
2362
+ });
2363
+ }
2347
2364
  }
2348
2365
  const sectionBranch = (children) => sectionShape(children).superRefine(checkSection);
2349
2366
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keemakr/ui-sdk",
3
- "version": "1.6.0-dev-20261027083656",
3
+ "version": "1.6.0-dev-20261027084552",
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",