@keemakr/ui-sdk 1.6.0-dev-20261103135437 → 1.6.0-dev-20261103162022
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 +19 -0
- package/dist/form.js +25 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/negotiate.d.ts +7 -2
- package/dist/negotiate.js +14 -1
- package/dist/schema.d.ts +37 -0
- package/dist/schema.js +107 -4
- package/package.json +1 -1
package/dist/form.d.ts
CHANGED
|
@@ -73,6 +73,25 @@ export declare function searchableOptions<T extends {
|
|
|
73
73
|
value: string;
|
|
74
74
|
label: string;
|
|
75
75
|
}>(options: readonly T[], pinned: readonly string[], query: string): T[];
|
|
76
|
+
/** An option of a choice field: what it posts and what the reader sees. */
|
|
77
|
+
export interface FieldOption {
|
|
78
|
+
value: string;
|
|
79
|
+
label: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The option an `addsTo` combobox adds to its multiselect for the text in its box, or null when
|
|
83
|
+
* it adds nothing: the option whose value is the text, or whose label is (any case), or, with
|
|
84
|
+
* `allowNew`, a new option that is the trimmed text. Blank text adds nothing.
|
|
85
|
+
*/
|
|
86
|
+
export declare function comboboxPick(combobox: {
|
|
87
|
+
options?: readonly FieldOption[];
|
|
88
|
+
allowNew?: boolean;
|
|
89
|
+
}, text: string): FieldOption | null;
|
|
90
|
+
/**
|
|
91
|
+
* The chips of a `mirror` list: the ticked options of its multiselect in the order they were
|
|
92
|
+
* ticked, each by its label. A ticked value with no option is shown as itself.
|
|
93
|
+
*/
|
|
94
|
+
export declare function mirrorChips(options: readonly FieldOption[], ticked: readonly string[]): FieldOption[];
|
|
76
95
|
/** One send button of a form: its `submit` or one of its `secondary`. */
|
|
77
96
|
export interface FormSubmit {
|
|
78
97
|
label: string;
|
package/dist/form.js
CHANGED
|
@@ -111,6 +111,31 @@ export function searchableOptions(options, pinned, query) {
|
|
|
111
111
|
const rest = options.filter((o) => !pinned.includes(o.value) && o.label.toLocaleLowerCase().includes(needle));
|
|
112
112
|
return [...top, ...rest];
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* The option an `addsTo` combobox adds to its multiselect for the text in its box, or null when
|
|
116
|
+
* it adds nothing: the option whose value is the text, or whose label is (any case), or, with
|
|
117
|
+
* `allowNew`, a new option that is the trimmed text. Blank text adds nothing.
|
|
118
|
+
*/
|
|
119
|
+
export function comboboxPick(combobox, text) {
|
|
120
|
+
const typed = text.trim();
|
|
121
|
+
if (typed === '')
|
|
122
|
+
return null;
|
|
123
|
+
const needle = typed.toLocaleLowerCase();
|
|
124
|
+
const match = combobox.options?.find((o) => o.value === typed || o.label.toLocaleLowerCase() === needle);
|
|
125
|
+
if (match)
|
|
126
|
+
return { value: match.value, label: match.label };
|
|
127
|
+
return combobox.allowNew ? { value: typed, label: typed } : null;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The chips of a `mirror` list: the ticked options of its multiselect in the order they were
|
|
131
|
+
* ticked, each by its label. A ticked value with no option is shown as itself.
|
|
132
|
+
*/
|
|
133
|
+
export function mirrorChips(options, ticked) {
|
|
134
|
+
return ticked.map((value) => ({
|
|
135
|
+
value,
|
|
136
|
+
label: options.find((o) => o.value === value)?.label ?? value,
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
114
139
|
/**
|
|
115
140
|
* Every send button of a form in drawing order: `submit` first, then `secondary`. `valid` says
|
|
116
141
|
* whether every shown required field is filled (`formState(...).missing` is empty); a send with
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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, appPressSchema, BADGE_COUNT_MAX, surfaceBadgeSchema, screenBadgesRequestSchema, screenBadgesResponseSchema, TABS_MAX, } from './schema.js';
|
|
2
|
-
export type { Press, ChatPress, SeekPress, SeekPoint, FocusPress, AppPress, ValuePress, NavigatePress, NavigateOpen, ScreenPresentation, ScreenNode, ScreenRootNode, ScreenTree, ActionResult, InterfaceFamily, SurfaceDefinition, Surface, ScreenRegistration, UiManifest, ScreenTreeInput, ActionResultInput, JobStatus, JobStatusInput, SurfaceBadge, SurfaceBadgeInput, ScreenBadgesRequest, ScreenBadgesResponse, } from './schema.js';
|
|
2
|
+
export type { Press, ChatPress, SeekPress, SeekPoint, FocusPress, AppPress, ValuePress, NavigatePress, PendingOpenOption, 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';
|
|
@@ -25,8 +25,8 @@ export type { AppDestination } from './app-press.js';
|
|
|
25
25
|
export type { FocusReference, FormFieldName } from './focus.js';
|
|
26
26
|
export { heatmapCellText, heatmapIntensity, heatmapMixPercent, heatmapRange, heatmapStrong, } from './heatmap.js';
|
|
27
27
|
export type { HeatmapLike, HeatmapRange } from './heatmap.js';
|
|
28
|
-
export { checkFormInput, chosenSubmit, formPress, formState, formSubmits, initialDraft, isoToLocalInput, localInputToIso, postedValue, searchableOptions, } from './form.js';
|
|
29
|
-
export type { FormDraft, FormFieldKind, FormFieldLike, FormFieldRule, FormInputCheck, FormState, FormSubmit, ShowWhen, } from './form.js';
|
|
28
|
+
export { checkFormInput, chosenSubmit, comboboxPick, formPress, formState, formSubmits, initialDraft, isoToLocalInput, localInputToIso, mirrorChips, postedValue, searchableOptions, } from './form.js';
|
|
29
|
+
export type { FieldOption, FormDraft, FormFieldKind, FormFieldLike, FormFieldRule, FormInputCheck, FormState, FormSubmit, ShowWhen, } from './form.js';
|
|
30
30
|
export { stackedBarParts, stackedBarValue } from './stacked-bar.js';
|
|
31
31
|
export type { StackedBarLike, StackedBarParts, StackedBarSegmentPart } from './stacked-bar.js';
|
|
32
32
|
export { statTrend } from './stat.js';
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export { PLAYBACK_RATES, SEEK_AT_MAX, formatPlayhead, isSeekPress, nextPlaybackR
|
|
|
23
23
|
export { FOCUSABLE_FIELD_KINDS, focusIssue, focusesIn, isFocusPress } from './focus.js';
|
|
24
24
|
export { APP_DESTINATIONS, APPOINTMENT_PARAM, appPressPath, isAppPress } from './app-press.js';
|
|
25
25
|
export { heatmapCellText, heatmapIntensity, heatmapMixPercent, heatmapRange, heatmapStrong, } from './heatmap.js';
|
|
26
|
-
export { checkFormInput, chosenSubmit, formPress, formState, formSubmits, initialDraft, isoToLocalInput, localInputToIso, postedValue, searchableOptions, } from './form.js';
|
|
26
|
+
export { checkFormInput, chosenSubmit, comboboxPick, formPress, formState, formSubmits, initialDraft, isoToLocalInput, localInputToIso, mirrorChips, postedValue, searchableOptions, } from './form.js';
|
|
27
27
|
export { stackedBarParts, stackedBarValue } from './stacked-bar.js';
|
|
28
28
|
export { statTrend } from './stat.js';
|
|
29
29
|
export { createSectionMemory, sectionBadge, sectionCollapsible, sectionColumnWeights, sectionGridTemplate, sectionScrollHeight, } from './section.js';
|
package/dist/negotiate.d.ts
CHANGED
|
@@ -102,8 +102,13 @@ import type { ChatPress, ScreenRootNode, ScreenTree } from './schema.js';
|
|
|
102
102
|
* draws it. Without it, every control with an app press is dropped exactly as for
|
|
103
103
|
* `press.focus` (a body button included: muted text would read as a label), and a row, card,
|
|
104
104
|
* entry or image stays but is no longer pressable.
|
|
105
|
+
* - `pending.open`: a `pending_request`'s `options`, the one option of the module's own that
|
|
106
|
+
* opens a screen and leaves the request pending (newer than any published release; core's own
|
|
107
|
+
* renderer draws it). Without it, the option is dropped and the card keeps its own answers.
|
|
108
|
+
* It is never folded into a button: an older renderer could not tell it from an answer, and
|
|
109
|
+
* the screen it opens is reachable from the module's own presses.
|
|
105
110
|
*/
|
|
106
|
-
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' | 'stat.sparkline' | 'section.action' | 'facts.meter' | 'form.show_when' | 'press.focus' | 'press.app';
|
|
111
|
+
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' | 'stat.sparkline' | 'section.action' | 'facts.meter' | 'form.show_when' | 'press.focus' | 'press.app' | 'pending.open';
|
|
107
112
|
/** The node types and features one ui-sdk release, or one client, draws. */
|
|
108
113
|
export interface NodeSet {
|
|
109
114
|
/** For messages: "ui-sdk 1.4.0", "mobile 0.2.5". */
|
|
@@ -140,7 +145,7 @@ export declare const UI_SDK_SNAPSHOTS: {
|
|
|
140
145
|
readonly current: {
|
|
141
146
|
readonly name: "ui-sdk (this package)";
|
|
142
147
|
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"];
|
|
143
|
-
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", "stat.sparkline", "section.action", "facts.meter", "form.show_when", "press.focus", "press.app"];
|
|
148
|
+
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", "stat.sparkline", "section.action", "facts.meter", "form.show_when", "press.focus", "press.app", "pending.open"];
|
|
144
149
|
};
|
|
145
150
|
};
|
|
146
151
|
export type UiSdkSnapshot = keyof typeof UI_SDK_SNAPSHOTS;
|
package/dist/negotiate.js
CHANGED
|
@@ -59,6 +59,7 @@ const ALL_FEATURES = [
|
|
|
59
59
|
'form.show_when',
|
|
60
60
|
'press.focus',
|
|
61
61
|
'press.app',
|
|
62
|
+
'pending.open',
|
|
62
63
|
];
|
|
63
64
|
/** The nodes of ui-sdk 1.1.0 and 1.2.0 (one schema). */
|
|
64
65
|
const NODES_1_1_0 = [
|
|
@@ -358,6 +359,18 @@ export function negotiateTree(tree, set) {
|
|
|
358
359
|
return { type: 'text', value: clip(node.label, TEXT_MAX), muted: true };
|
|
359
360
|
}
|
|
360
361
|
return node;
|
|
362
|
+
case 'pending_request': {
|
|
363
|
+
if (!node.options || features.has('pending.open'))
|
|
364
|
+
return node;
|
|
365
|
+
fallbacks.push({
|
|
366
|
+
path: `${path}.options`,
|
|
367
|
+
type: 'pending_request',
|
|
368
|
+
reason: 'pending.open',
|
|
369
|
+
as: 'dropped',
|
|
370
|
+
});
|
|
371
|
+
const { options: _options, ...card } = node;
|
|
372
|
+
return card;
|
|
373
|
+
}
|
|
361
374
|
case 'section': {
|
|
362
375
|
const children = visitAll(node.children, `${path}.children`);
|
|
363
376
|
let next = children === node.children ? node : { ...node, children };
|
|
@@ -1003,7 +1016,7 @@ export function foldChoiceField(field) {
|
|
|
1003
1016
|
* list -> textarea, one item per line
|
|
1004
1017
|
*/
|
|
1005
1018
|
export function foldFormField(field) {
|
|
1006
|
-
const { values, checked, min: _min, max: _max, step: _step, searchable: _searchable, ...rest } = field;
|
|
1019
|
+
const { values, checked, min: _min, max: _max, step: _step, searchable: _searchable, addsTo: _addsTo, allowNew: _allowNew, mirror: _mirror, removable: _removable, ...rest } = field;
|
|
1007
1020
|
switch (field.kind) {
|
|
1008
1021
|
case 'number':
|
|
1009
1022
|
case 'date':
|
package/dist/schema.d.ts
CHANGED
|
@@ -52,6 +52,28 @@ declare const openingNavigatePressSchema: z.ZodObject<{
|
|
|
52
52
|
drawer: "drawer";
|
|
53
53
|
}>>;
|
|
54
54
|
}, z.core.$strip>;
|
|
55
|
+
/**
|
|
56
|
+
* An option the module adds to a placed approval card that opens one of its screens instead of
|
|
57
|
+
* answering: "Tick and untick them" opens the lead, where the reader changes what the request is
|
|
58
|
+
* about, then comes back to answer. Pressing it is a navigate press (`open: 'drawer'` included),
|
|
59
|
+
* so it posts nothing: the request stays pending on the card, and the screen it opens loads and
|
|
60
|
+
* checks access like any other. It is drawn after the card's own answers, before Dismiss.
|
|
61
|
+
*
|
|
62
|
+
* Strict, so an option that also answers (an `id`, as the agent's own options carry) is refused:
|
|
63
|
+
* an option either answers the request or opens a screen, never both. A client without it draws
|
|
64
|
+
* the card without the option (negotiate.ts `pending.open`), so it can never be taken for an
|
|
65
|
+
* answer.
|
|
66
|
+
*/
|
|
67
|
+
declare const pendingOpenOptionSchema: z.ZodObject<{
|
|
68
|
+
label: z.ZodString;
|
|
69
|
+
open: z.ZodObject<{
|
|
70
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
71
|
+
screen: z.ZodString;
|
|
72
|
+
open: z.ZodOptional<z.ZodEnum<{
|
|
73
|
+
drawer: "drawer";
|
|
74
|
+
}>>;
|
|
75
|
+
}, z.core.$strict>;
|
|
76
|
+
}, z.core.$strict>;
|
|
55
77
|
/**
|
|
56
78
|
* Opens the chat with `prompt` already typed in the box, and stops there. It
|
|
57
79
|
* NEVER sends: the reader reads the words, changes them if they like, and
|
|
@@ -685,6 +707,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
685
707
|
description: z.ZodOptional<z.ZodString>;
|
|
686
708
|
}, z.core.$strip>>>;
|
|
687
709
|
searchable: z.ZodOptional<z.ZodBoolean>;
|
|
710
|
+
addsTo: z.ZodOptional<z.ZodString>;
|
|
711
|
+
allowNew: z.ZodOptional<z.ZodBoolean>;
|
|
712
|
+
mirror: z.ZodOptional<z.ZodString>;
|
|
713
|
+
removable: z.ZodOptional<z.ZodBoolean>;
|
|
688
714
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
689
715
|
placeholder: z.ZodOptional<z.ZodString>;
|
|
690
716
|
hint: z.ZodOptional<z.ZodString>;
|
|
@@ -1243,6 +1269,16 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1243
1269
|
}, z.core.$strip>, z.ZodObject<{
|
|
1244
1270
|
type: z.ZodLiteral<"pending_request">;
|
|
1245
1271
|
requestId: z.ZodString;
|
|
1272
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1273
|
+
label: z.ZodString;
|
|
1274
|
+
open: z.ZodObject<{
|
|
1275
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1276
|
+
screen: z.ZodString;
|
|
1277
|
+
open: z.ZodOptional<z.ZodEnum<{
|
|
1278
|
+
drawer: "drawer";
|
|
1279
|
+
}>>;
|
|
1280
|
+
}, z.core.$strict>;
|
|
1281
|
+
}, z.core.$strict>>>;
|
|
1246
1282
|
}, z.core.$strip>, z.ZodObject<{
|
|
1247
1283
|
type: z.ZodLiteral<"pending_requests">;
|
|
1248
1284
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -3414,6 +3450,7 @@ export type SeekPoint = z.infer<typeof seekPointSchema>;
|
|
|
3414
3450
|
export type FocusPress = z.infer<typeof focusPressSchema>;
|
|
3415
3451
|
export type AppPress = z.infer<typeof appPressSchema>;
|
|
3416
3452
|
export type NavigatePress = z.infer<typeof openingNavigatePressSchema>;
|
|
3453
|
+
export type PendingOpenOption = z.infer<typeof pendingOpenOptionSchema>;
|
|
3417
3454
|
export type NavigateOpen = (typeof NAVIGATE_OPENS)[number];
|
|
3418
3455
|
export type ScreenPresentation = z.infer<typeof screenPresentationSchema>;
|
|
3419
3456
|
export type ScreenTree = z.infer<typeof screenTreeSchema>;
|
package/dist/schema.js
CHANGED
|
@@ -76,6 +76,27 @@ export const NAVIGATE_OPENS = ['drawer'];
|
|
|
76
76
|
const openingNavigatePressSchema = navigatePressSchema.extend({
|
|
77
77
|
open: z.enum(NAVIGATE_OPENS).optional(),
|
|
78
78
|
});
|
|
79
|
+
/**
|
|
80
|
+
* An option the module adds to a placed approval card that opens one of its screens instead of
|
|
81
|
+
* answering: "Tick and untick them" opens the lead, where the reader changes what the request is
|
|
82
|
+
* about, then comes back to answer. Pressing it is a navigate press (`open: 'drawer'` included),
|
|
83
|
+
* so it posts nothing: the request stays pending on the card, and the screen it opens loads and
|
|
84
|
+
* checks access like any other. It is drawn after the card's own answers, before Dismiss.
|
|
85
|
+
*
|
|
86
|
+
* Strict, so an option that also answers (an `id`, as the agent's own options carry) is refused:
|
|
87
|
+
* an option either answers the request or opens a screen, never both. A client without it draws
|
|
88
|
+
* the card without the option (negotiate.ts `pending.open`), so it can never be taken for an
|
|
89
|
+
* answer.
|
|
90
|
+
*/
|
|
91
|
+
const pendingOpenOptionSchema = z.strictObject({
|
|
92
|
+
label: z.string().min(1).max(80),
|
|
93
|
+
/** The screen it opens: a navigate press without its `kind`. */
|
|
94
|
+
open: openingNavigatePressSchema.omit({ kind: true }).strict(),
|
|
95
|
+
}, {
|
|
96
|
+
error: (issue) => issue.code === 'unrecognized_keys'
|
|
97
|
+
? 'an option on a pending_request only opens a screen (label and open): it cannot answer'
|
|
98
|
+
: undefined,
|
|
99
|
+
});
|
|
79
100
|
/**
|
|
80
101
|
* Opens the chat with `prompt` already typed in the box, and stops there. It
|
|
81
102
|
* NEVER sends: the reader reads the words, changes them if they like, and
|
|
@@ -1693,6 +1714,44 @@ function showWhenIssue(name, when, fields) {
|
|
|
1693
1714
|
}
|
|
1694
1715
|
return null;
|
|
1695
1716
|
}
|
|
1717
|
+
/**
|
|
1718
|
+
* What is wrong with a field's `addsTo`, `allowNew`, `mirror` or `removable`, each with the key it
|
|
1719
|
+
* is on: an `addsTo` combobox or a `mirror` list names a multiselect of the same form, and the two
|
|
1720
|
+
* flags come only with the link they modify.
|
|
1721
|
+
*/
|
|
1722
|
+
function linkedFieldIssues(field, fields) {
|
|
1723
|
+
const issues = [];
|
|
1724
|
+
const names = (key, target) => {
|
|
1725
|
+
if (!fields.some((other) => other.name === target && other.kind === 'multiselect')) {
|
|
1726
|
+
issues.push({ key, message: `${key} names no multiselect "${target}" in this form` });
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
if (field.addsTo !== undefined) {
|
|
1730
|
+
if (field.kind !== 'combobox') {
|
|
1731
|
+
issues.push({ key: 'addsTo', message: 'addsTo is for combobox fields' });
|
|
1732
|
+
}
|
|
1733
|
+
else {
|
|
1734
|
+
names('addsTo', field.addsTo);
|
|
1735
|
+
if (field.required) {
|
|
1736
|
+
// It empties after each pick, so a required one could never be sent.
|
|
1737
|
+
issues.push({ key: 'required', message: 'a combobox with addsTo cannot be required' });
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
if (field.allowNew !== undefined && (field.kind !== 'combobox' || field.addsTo === undefined)) {
|
|
1742
|
+
issues.push({ key: 'allowNew', message: 'allowNew is for a combobox with addsTo' });
|
|
1743
|
+
}
|
|
1744
|
+
if (field.mirror !== undefined) {
|
|
1745
|
+
if (field.kind !== 'list')
|
|
1746
|
+
issues.push({ key: 'mirror', message: 'mirror is for list fields' });
|
|
1747
|
+
else
|
|
1748
|
+
names('mirror', field.mirror);
|
|
1749
|
+
}
|
|
1750
|
+
if (field.removable !== undefined && (field.kind !== 'list' || field.mirror === undefined)) {
|
|
1751
|
+
issues.push({ key: 'removable', message: 'removable is for a list with mirror' });
|
|
1752
|
+
}
|
|
1753
|
+
return issues;
|
|
1754
|
+
}
|
|
1696
1755
|
/** A real YYYY-MM-DD calendar day: `2026-02-30` is refused. */
|
|
1697
1756
|
function isCalendarDate(text) {
|
|
1698
1757
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(text))
|
|
@@ -1790,6 +1849,35 @@ const leafNodeSchema = z.discriminatedUnion('type', [
|
|
|
1790
1849
|
* posts what a multiselect posts. Default false.
|
|
1791
1850
|
*/
|
|
1792
1851
|
searchable: z.boolean().optional(),
|
|
1852
|
+
/**
|
|
1853
|
+
* A combobox only: the `name` of a multiselect in this form, for "Add another
|
|
1854
|
+
* form". Picking an option (`comboboxPick`) adds it to that multiselect's
|
|
1855
|
+
* options when it is not there yet, ticks it, and empties the box. Typed text
|
|
1856
|
+
* that matches no option is refused unless `allowNew`. The combobox posts what
|
|
1857
|
+
* a combobox posts, so '' once the pick is made; the multiselect posts its
|
|
1858
|
+
* ticked values. A client without it draws a plain combobox, which posts the
|
|
1859
|
+
* typed text, so the action must take that too.
|
|
1860
|
+
*/
|
|
1861
|
+
addsTo: slug.optional(),
|
|
1862
|
+
/**
|
|
1863
|
+
* An `addsTo` combobox only: typed text that matches no option is added as a
|
|
1864
|
+
* new option, its value and label the text. Default false.
|
|
1865
|
+
*/
|
|
1866
|
+
allowNew: z.boolean().optional(),
|
|
1867
|
+
/**
|
|
1868
|
+
* A list only: the `name` of a multiselect in this form. The list shows the
|
|
1869
|
+
* labels of its ticked options as read-only chips, in the order they were
|
|
1870
|
+
* ticked (`mirrorChips`), and posts those labels, as a list posts its values.
|
|
1871
|
+
* Set `values` to the same labels: a client without it draws an editable list
|
|
1872
|
+
* starting from them.
|
|
1873
|
+
*/
|
|
1874
|
+
mirror: slug.optional(),
|
|
1875
|
+
/**
|
|
1876
|
+
* A `mirror` list only: each chip has a cross that unticks its option. A
|
|
1877
|
+
* required multiselect is still checked on send, as when its box is unticked.
|
|
1878
|
+
* Default false.
|
|
1879
|
+
*/
|
|
1880
|
+
removable: z.boolean().optional(),
|
|
1793
1881
|
required: z.boolean().default(false),
|
|
1794
1882
|
placeholder: z.string().max(120).optional(),
|
|
1795
1883
|
/** Shown under the field. */
|
|
@@ -2011,6 +2099,9 @@ const leafNodeSchema = z.discriminatedUnion('type', [
|
|
|
2011
2099
|
message: 'searchable is for multiselect fields',
|
|
2012
2100
|
});
|
|
2013
2101
|
}
|
|
2102
|
+
for (const issue of linkedFieldIssues(field, node.fields)) {
|
|
2103
|
+
ctx.addIssue({ code: 'custom', path: at(issue.key), message: issue.message });
|
|
2104
|
+
}
|
|
2014
2105
|
if (field.checked !== undefined && field.kind !== 'checkbox') {
|
|
2015
2106
|
ctx.addIssue({
|
|
2016
2107
|
code: 'custom',
|
|
@@ -2343,11 +2434,23 @@ const leafNodeSchema = z.discriminatedUnion('type', [
|
|
|
2343
2434
|
* A HITL approval slot — a REFERENCE, never content. The module places the
|
|
2344
2435
|
* request id where the card should appear; core resolves it at render time
|
|
2345
2436
|
* (tenant + this-install + still-pending checks) and renders the platform
|
|
2346
|
-
* card wired to the respond endpoint. The module cannot author the card
|
|
2347
|
-
*
|
|
2348
|
-
*
|
|
2437
|
+
* card wired to the respond endpoint. The module cannot author the card's
|
|
2438
|
+
* question or its answers (this node carries no fields for them) and the
|
|
2439
|
+
* tree transports no PHI, only the opaque id.
|
|
2349
2440
|
*/
|
|
2350
|
-
z.object({
|
|
2441
|
+
z.object({
|
|
2442
|
+
type: z.literal('pending_request'),
|
|
2443
|
+
requestId: z.string().min(1).max(128),
|
|
2444
|
+
/**
|
|
2445
|
+
* One option of the module's own on the card, which opens a screen and answers nothing
|
|
2446
|
+
* (`pendingOpenOptionSchema`). At most one: a second would be a second way off the card.
|
|
2447
|
+
*/
|
|
2448
|
+
options: z
|
|
2449
|
+
.array(pendingOpenOptionSchema)
|
|
2450
|
+
.min(1)
|
|
2451
|
+
.max(1, 'a pending_request takes one option that opens a screen, no more')
|
|
2452
|
+
.optional(),
|
|
2453
|
+
}),
|
|
2351
2454
|
/**
|
|
2352
2455
|
* The zero-bookkeeping HITL slot: "render ALL of this module's still-pending
|
|
2353
2456
|
* approvals here." Core fills it from its own pending store — the module
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keemakr/ui-sdk",
|
|
3
|
-
"version": "1.6.0-dev-
|
|
3
|
+
"version": "1.6.0-dev-20261103162022",
|
|
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",
|