@colixsystems/widget-sdk 0.297.0 → 0.298.0

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/README.md CHANGED
@@ -90,7 +90,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
90
90
 
91
91
  ## Status
92
92
 
93
- `v0.297.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
93
+ `v0.298.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
94
+
95
+ ### What's new in 0.298.0 (contract 1.245.0)
96
+
97
+ **A Tabs item may be keyed by `value`, and the widget check refuses a component missing what it cannot draw without.** `<Tabs>` reads an item's `value` as its key when it has no `key`, so items shaped like Select options (`{ value, label }`) select and report as expected instead of leaving every tab unselected. The check that runs before a widget publishes (`check_widget`, `submit_widget_source`, the Widget Builder) now test-renders with `ctx.strictProps` set, under which a component throws on a prop the source never passes and it cannot render without: a `<Tabs>` item with neither `key` nor `value`, a `<Select>` or `<RadioGroup>` option with no `value`, a `<Board>` column with no `key`, a `<Button>` with no `title`, an `<IconButton>` with no `icon` or `accessibilityLabel`, a `<Badge>`, `<Chip>` or `<Tooltip>` with no `label`, a `<Banner>` with no `message`, a `<ConfirmDialog>` with no `title`. The check reports it as the finding `render.props`, naming the component, the prop and the fix. The Player, the Studio and the exported app never set `strictProps`, so a published widget renders as before. The table is `COMPONENT_PROPS` in `component-props.js`, and `componentPropsError(component, props, table)` is the one checker both the components and the check run.
94
98
 
95
99
  ### What's new in 0.297.0 (contract 1.244.0)
96
100
 
@@ -6,7 +6,7 @@
6
6
  // different in every widget. This one reads the theme's `alert` scope.
7
7
 
8
8
  import React from "react";
9
- import { useHostTheme } from "./hooks.js";
9
+ import { useHostTheme, useStrictProps } from "./hooks.js";
10
10
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
11
11
  import { Icon } from "./icon.js";
12
12
  import { resolveBannerTokens } from "./banner-tokens.js";
@@ -105,18 +105,20 @@ export function makeBanner(rn) {
105
105
  );
106
106
  }
107
107
 
108
- function Banner({
109
- tone,
110
- title,
111
- message,
112
- icon,
113
- action,
114
- onDismiss,
115
- dismissAccessibilityLabel = "Dismiss",
116
- theme: explicitTheme,
117
- style,
118
- testID,
119
- }) {
108
+ function Banner(props) {
109
+ useStrictProps("Banner", props);
110
+ const {
111
+ tone,
112
+ title,
113
+ message,
114
+ icon,
115
+ action,
116
+ onDismiss,
117
+ dismissAccessibilityLabel = "Dismiss",
118
+ theme: explicitTheme,
119
+ style,
120
+ testID,
121
+ } = props;
120
122
  const hostTheme = useHostTheme();
121
123
  // A Studio preview renders outside a widget context, so it passes its own.
122
124
  const theme = explicitTheme || hostTheme || DEFAULT_THEME_TOKENS;
@@ -4,7 +4,7 @@
4
4
  // `card` scope. On a narrow box the columns scroll sideways.
5
5
 
6
6
  import React from "react";
7
- import { useContainerWidth, useHostTheme } from "./hooks.js";
7
+ import { useContainerWidth, useHostTheme, useStrictProps } from "./hooks.js";
8
8
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
9
9
  import { widthTier } from "./container-width.js";
10
10
  import { textRoleStyle } from "./text-roles.js";
@@ -105,22 +105,24 @@ export function makeBoard(rn, kit) {
105
105
  * toColumn, index })` runs once per real change; a drag released over no
106
106
  * column, or where it started, springs back and calls nothing.
107
107
  */
108
- function Board({
109
- columns,
110
- items,
111
- getColumn,
112
- onMove,
113
- renderCard,
114
- keyExtractor,
115
- getItemLabel,
116
- canDrag = true,
117
- reorderInColumn = true,
118
- columnWidth = BOARD_COLUMN_WIDTH,
119
- labels,
120
- style,
121
- testID,
122
- accessibilityLabel,
123
- }) {
108
+ function Board(props) {
109
+ useStrictProps("Board", props);
110
+ const {
111
+ columns,
112
+ items,
113
+ getColumn,
114
+ onMove,
115
+ renderCard,
116
+ keyExtractor,
117
+ getItemLabel,
118
+ canDrag = true,
119
+ reorderInColumn = true,
120
+ columnWidth = BOARD_COLUMN_WIDTH,
121
+ labels,
122
+ style,
123
+ testID,
124
+ accessibilityLabel,
125
+ } = props;
124
126
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
125
127
  const tokens = resolveSortableTokens(theme);
126
128
  const words = resolveSortableLabels(labels);
@@ -4,7 +4,7 @@
4
4
  // `<Gradient>` and `<Spinner>` they pass.
5
5
 
6
6
  import React from "react";
7
- import { useHostTheme } from "./hooks.js";
7
+ import { useHostTheme, useStrictProps } from "./hooks.js";
8
8
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
9
9
  import { Icon, lucideGlyph } from "./icon.js";
10
10
  import { applyThemeComponentStyle } from "./theme-components.js";
@@ -213,6 +213,7 @@ export function makeButton(rn) {
213
213
  accessibilityLabel,
214
214
  testID,
215
215
  } = props;
216
+ useStrictProps("Button", props);
216
217
  const trigger = triggerProps(props);
217
218
  const resolvedVariant = resolveButtonVariant(variant);
218
219
  const look = useButtonLook({
@@ -320,6 +321,7 @@ export function makeButton(rn) {
320
321
  style,
321
322
  testID,
322
323
  } = props;
324
+ useStrictProps("Button", props);
323
325
  const trigger = triggerProps(props);
324
326
  const resolvedVariant = resolveButtonVariant(variant === "link" ? "ghost" : variant);
325
327
  const look = useButtonLook({
package/dist/chip-view.js CHANGED
@@ -6,7 +6,7 @@
6
6
  // radius, padding and selected colour. This one reads the theme's `chip` scope.
7
7
 
8
8
  import React from "react";
9
- import { useHostTheme } from "./hooks.js";
9
+ import { useHostTheme, useStrictProps } from "./hooks.js";
10
10
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
11
11
  import { Icon } from "./icon.js";
12
12
  import {
@@ -178,23 +178,25 @@ export function makeChip(rn, host) {
178
178
  );
179
179
  }
180
180
 
181
- function Chip({
182
- label,
183
- icon,
184
- selected,
185
- onPress,
186
- onRemove,
187
- disabled,
188
- variant,
189
- size,
190
- numberOfLines = 1,
191
- theme: explicitTheme,
192
- accessibilityLabel,
193
- removeAccessibilityLabel,
194
- style,
195
- testID,
196
- ...overrides
197
- }) {
181
+ function Chip(props) {
182
+ useStrictProps("Chip", props);
183
+ const {
184
+ label,
185
+ icon,
186
+ selected,
187
+ onPress,
188
+ onRemove,
189
+ disabled,
190
+ variant,
191
+ size,
192
+ numberOfLines = 1,
193
+ theme: explicitTheme,
194
+ accessibilityLabel,
195
+ removeAccessibilityLabel,
196
+ style,
197
+ testID,
198
+ ...overrides
199
+ } = props;
198
200
  const group = React.useContext(GroupContext);
199
201
  const hostTheme = useHostTheme();
200
202
  // A Studio preview renders outside a widget context, so it passes its own.
@@ -0,0 +1,83 @@
1
+ // GENERATED from component-props.js by scripts/generate-cjs.js — DO NOT EDIT.
2
+ // Change component-props.js, then run `npm run generate:cjs` in packages/widget-sdk.
3
+ "use strict";
4
+
5
+ // The props each SDK component cannot render without, checked only where a
6
+ // host asks for it (`ctx.strictProps`): the widget check's test render. A
7
+ // production render keeps today's behaviour and never throws. Only a prop the
8
+ // element never passes counts: one passed as undefined may be a data binding
9
+ // the test render's stub rows cannot fill, which the source cannot be blamed for.
10
+ //
11
+ // Tabs keyed by `{ value, label }` items selected nothing and reported
12
+ // undefined, and every check passed because the render only proves the
13
+ // widget renders. The table is plain data, so the check's isolate reads it.
14
+
15
+ /** The prefix a strict-mode throw carries, so the check files it as its own finding. */
16
+ const COMPONENT_PROPS_ERROR_PREFIX = "Component props: ";
17
+
18
+ /**
19
+ * Per component: `true` for a prop that must be present, or the item fields of
20
+ * which every entry of a list prop must carry one (`key` or `value` for Tabs).
21
+ */
22
+ const COMPONENT_PROPS = Object.freeze({
23
+ Tabs: { items: ["key", "value"] },
24
+ Select: { options: ["value"] },
25
+ RadioGroup: { options: ["value"] },
26
+ Board: { columns: ["key"] },
27
+ Button: { title: true },
28
+ IconButton: { icon: true, accessibilityLabel: true },
29
+ Badge: { label: true },
30
+ Chip: { label: true },
31
+ Banner: { message: true },
32
+ ConfirmDialog: { title: true },
33
+ Tooltip: { label: true },
34
+ });
35
+
36
+ /** A Tabs item's key: `key`, or `value` when it is shaped like a Select option. */
37
+ function tabItemKey(item) {
38
+ return item.key !== undefined ? item.key : item.value;
39
+ }
40
+
41
+ /**
42
+ * The first finding against a component's props, or null. Self-contained and
43
+ * free of template literals: the widget check pastes its source into an
44
+ * isolate's bootstrap, which is itself a template literal.
45
+ * @param {string} component
46
+ * @param {Record<string, unknown> | null | undefined} props
47
+ * @param {Record<string, Record<string, true | string[]>>} table
48
+ * @returns {string | null}
49
+ * @example componentPropsError("Tabs", { items: [{ id: "a", label: "A" }] }, COMPONENT_PROPS)
50
+ * // "<Tabs> items[0] has no key or value; each item is { key, label }."
51
+ */
52
+ function componentPropsError(component, props, table) {
53
+ const rules = table && table[component];
54
+ if (!rules) return null;
55
+ const p = props && typeof props === "object" ? props : {};
56
+ const tag = "<" + component + ">";
57
+ for (const prop of Object.keys(rules)) {
58
+ const rule = rules[prop];
59
+ const value = p[prop];
60
+ if (rule === true) {
61
+ if (!(prop in p)) return tag + " has no " + prop + " prop; pass " + prop + ".";
62
+ continue;
63
+ }
64
+ const shape = "{ " + rule[0] + ", label }";
65
+ if (!(prop in p)) return tag + " needs " + prop + " as an array of " + shape + ".";
66
+ if (value === undefined || value === null) continue;
67
+ if (!Array.isArray(value)) return tag + " needs " + prop + " as an array of " + shape + ".";
68
+ for (let i = 0; i < value.length; i++) {
69
+ const item = value[i];
70
+ const keyed = item && typeof item === "object" && rule.some((field) => field in item);
71
+ if (!keyed) {
72
+ return tag + " " + prop + "[" + i + "] has no " + rule.join(" or ") + "; each item is " + shape + ".";
73
+ }
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ module.exports = {
79
+ COMPONENT_PROPS_ERROR_PREFIX,
80
+ COMPONENT_PROPS,
81
+ tabItemKey,
82
+ componentPropsError,
83
+ };
@@ -0,0 +1,73 @@
1
+ // The props each SDK component cannot render without, checked only where a
2
+ // host asks for it (`ctx.strictProps`): the widget check's test render. A
3
+ // production render keeps today's behaviour and never throws. Only a prop the
4
+ // element never passes counts: one passed as undefined may be a data binding
5
+ // the test render's stub rows cannot fill, which the source cannot be blamed for.
6
+ //
7
+ // Tabs keyed by `{ value, label }` items selected nothing and reported
8
+ // undefined, and every check passed because the render only proves the
9
+ // widget renders. The table is plain data, so the check's isolate reads it.
10
+
11
+ /** The prefix a strict-mode throw carries, so the check files it as its own finding. */
12
+ export const COMPONENT_PROPS_ERROR_PREFIX = "Component props: ";
13
+
14
+ /**
15
+ * Per component: `true` for a prop that must be present, or the item fields of
16
+ * which every entry of a list prop must carry one (`key` or `value` for Tabs).
17
+ */
18
+ export const COMPONENT_PROPS = Object.freeze({
19
+ Tabs: { items: ["key", "value"] },
20
+ Select: { options: ["value"] },
21
+ RadioGroup: { options: ["value"] },
22
+ Board: { columns: ["key"] },
23
+ Button: { title: true },
24
+ IconButton: { icon: true, accessibilityLabel: true },
25
+ Badge: { label: true },
26
+ Chip: { label: true },
27
+ Banner: { message: true },
28
+ ConfirmDialog: { title: true },
29
+ Tooltip: { label: true },
30
+ });
31
+
32
+ /** A Tabs item's key: `key`, or `value` when it is shaped like a Select option. */
33
+ export function tabItemKey(item) {
34
+ return item.key !== undefined ? item.key : item.value;
35
+ }
36
+
37
+ /**
38
+ * The first finding against a component's props, or null. Self-contained and
39
+ * free of template literals: the widget check pastes its source into an
40
+ * isolate's bootstrap, which is itself a template literal.
41
+ * @param {string} component
42
+ * @param {Record<string, unknown> | null | undefined} props
43
+ * @param {Record<string, Record<string, true | string[]>>} table
44
+ * @returns {string | null}
45
+ * @example componentPropsError("Tabs", { items: [{ id: "a", label: "A" }] }, COMPONENT_PROPS)
46
+ * // "<Tabs> items[0] has no key or value; each item is { key, label }."
47
+ */
48
+ export function componentPropsError(component, props, table) {
49
+ const rules = table && table[component];
50
+ if (!rules) return null;
51
+ const p = props && typeof props === "object" ? props : {};
52
+ const tag = "<" + component + ">";
53
+ for (const prop of Object.keys(rules)) {
54
+ const rule = rules[prop];
55
+ const value = p[prop];
56
+ if (rule === true) {
57
+ if (!(prop in p)) return tag + " has no " + prop + " prop; pass " + prop + ".";
58
+ continue;
59
+ }
60
+ const shape = "{ " + rule[0] + ", label }";
61
+ if (!(prop in p)) return tag + " needs " + prop + " as an array of " + shape + ".";
62
+ if (value === undefined || value === null) continue;
63
+ if (!Array.isArray(value)) return tag + " needs " + prop + " as an array of " + shape + ".";
64
+ for (let i = 0; i < value.length; i++) {
65
+ const item = value[i];
66
+ const keyed = item && typeof item === "object" && rule.some((field) => field in item);
67
+ if (!keyed) {
68
+ return tag + " " + prop + "[" + i + "] has no " + rule.join(" or ") + "; each item is " + shape + ".";
69
+ }
70
+ }
71
+ }
72
+ return null;
73
+ }
@@ -5,7 +5,7 @@
5
5
  // only in where the primitives come from, so the two hosts cannot drift.
6
6
 
7
7
  import React from "react";
8
- import { useHostSharedText, useHostTheme } from "./hooks.js";
8
+ import { useHostSharedText, useHostTheme, useStrictProps } from "./hooks.js";
9
9
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
10
10
  import { textRoleStyle } from "./text-roles.js";
11
11
 
@@ -63,19 +63,21 @@ export function makeConfirmDialog(rn, Modal, Button, Spinner) {
63
63
  * @param {string} [props.testID] — on the panel; the parts take `-message`,
64
64
  * `-cancel`, `-confirm` and `-busy`, plus the Modal's own.
65
65
  */
66
- function ConfirmDialog({
67
- visible = false,
68
- title,
69
- message,
70
- confirmLabel,
71
- cancelLabel,
72
- tone = "default",
73
- busy = false,
74
- onConfirm,
75
- onCancel,
76
- closeAccessibilityLabel,
77
- testID,
78
- }) {
66
+ function ConfirmDialog(props) {
67
+ useStrictProps("ConfirmDialog", props);
68
+ const {
69
+ visible = false,
70
+ title,
71
+ message,
72
+ confirmLabel,
73
+ cancelLabel,
74
+ tone = "default",
75
+ busy = false,
76
+ onConfirm,
77
+ onCancel,
78
+ closeAccessibilityLabel,
79
+ testID,
80
+ } = props;
79
81
  const sharedConfirm = useHostSharedText("confirm", "Confirm");
80
82
  const sharedCancel = useHostSharedText("cancel", "Cancel");
81
83
  const sharedClose = useHostSharedText("close", "Close");
package/dist/contract.cjs CHANGED
@@ -2,6 +2,8 @@
2
2
  // Change contract.js, then run `npm run generate:cjs` in packages/widget-sdk.
3
3
  "use strict";
4
4
 
5
+ const { COMPONENT_PROPS, COMPONENT_PROPS_ERROR_PREFIX, componentPropsError, tabItemKey } = require("./component-props.cjs");
6
+
5
7
  // The widget SDK contract: the ONE source the linter, the AI agents, the
6
8
  // compiler and both hosts read. `contract.cjs` is GENERATED from `contract.js`
7
9
  // (`npm run generate:cjs`) for CommonJS consumers — never edit it by hand;
@@ -12,6 +14,7 @@
12
14
  // Consumed by `_shared/cardStyle.js` SHADOW_PRESETS (web + baked built-ins),
13
15
  // the compiler's generated layout `elevationStyles`, and widgets reading
14
16
  // `useTheme().elevation` — so a widget shadow and a container shadow match.
17
+
15
18
  const ELEVATION = Object.freeze({
16
19
  none: Object.freeze({}),
17
20
  sm: Object.freeze({
@@ -3831,7 +3834,7 @@ const PRIMITIVES = [
3831
3834
  {
3832
3835
  name: "Tabs",
3833
3836
  description:
3834
- 'Themed tab strip. `<Tabs items={[{ key: "open", label: "Open" }, { key: "done", label: "Done", icon: "check" }]} value={tab} onChange={setTab} />`. The default way to switch between views inside a widget: its look (a segmented control, pills, or an underline — Theme Settings > Tabs) and its colours and corner radius come from the theme, so every tab strip in the app matches, including the page Tabs container. It draws the strip only; render the selected panel yourself below it. Use it rather than tabs of your own from `Pressable` chips; when the request needs a strip it cannot draw (a live count badge on each tab, a vertical rail down the side), build your own in the app\'s look with the tab role and its selected state. Props: `items` (`[{ key, label, icon?, disabled?, testID? }]`, icon is a lucide name), `value` (the selected key), `onChange(key)`, `accessibilityLabel`, `style`, `testID`, and the overrides `variant` ("segmented" | "pill" | "underline"), `activeColor`, `activeTextColor`, `textColor`, `radius`. When the tabs do not fit the width, the strip wraps them onto another line, so every tab stays visible; never wrap it in a horizontal `ScrollView` of your own. Declare `tabsStyle` / `tabsActiveColor` / `tabsActiveTextColor` / `tabsTextColor` / `tabsRadius` style fields and pass them through to let an author override one widget.',
3837
+ 'Themed tab strip. `<Tabs items={[{ key: "open", label: "Open" }, { key: "done", label: "Done", icon: "check" }]} value={tab} onChange={setTab} />`. The default way to switch between views inside a widget: its look (a segmented control, pills, or an underline — Theme Settings > Tabs) and its colours and corner radius come from the theme, so every tab strip in the app matches, including the page Tabs container. It draws the strip only; render the selected panel yourself below it. Use it rather than tabs of your own from `Pressable` chips; when the request needs a strip it cannot draw (a live count badge on each tab, a vertical rail down the side), build your own in the app\'s look with the tab role and its selected state. Props: `items` (`[{ key, label, icon?, disabled?, testID? }]`, icon is a lucide name; an item with `value` and no `key` is keyed by its `value`, like a Select option), `value` (the selected key), `onChange(key)`, `accessibilityLabel`, `style`, `testID`, and the overrides `variant` ("segmented" | "pill" | "underline"), `activeColor`, `activeTextColor`, `textColor`, `radius`. When the tabs do not fit the width, the strip wraps them onto another line, so every tab stays visible; never wrap it in a horizontal `ScrollView` of your own. Declare `tabsStyle` / `tabsActiveColor` / `tabsActiveTextColor` / `tabsTextColor` / `tabsRadius` style fields and pass them through to let an author override one widget.',
3835
3838
  rnComponent: null,
3836
3839
  docsUrl: null,
3837
3840
  },
@@ -6892,7 +6895,10 @@ const CONTRACT = deepFreeze({
6892
6895
  // on web, expo-key-event on native).
6893
6896
  // 1.244.0: additive (sc-15915) — `fixedScopes`, the requestedScopes entries
6894
6897
  // whose target the scope fixes; the publish gate accepts exactly these.
6895
- version: "1.244.0",
6898
+ // 1.245.0: additive (sc-15920) — a Tabs item with `value` and no `key` is
6899
+ // keyed by its `value`; a host may set `ctx.strictProps` so a component
6900
+ // throws on a prop it cannot render without (the widget check's render).
6901
+ version: "1.245.0",
6896
6902
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6897
6903
  hooks: HOOKS,
6898
6904
  primitives: PRIMITIVES,
@@ -7380,6 +7386,10 @@ const APPEARANCE_PREFERENCES = Object.freeze(["light", "dark", "system"]);
7380
7386
 
7381
7387
  module.exports = {
7382
7388
  CONTRACT,
7389
+ COMPONENT_PROPS,
7390
+ COMPONENT_PROPS_ERROR_PREFIX,
7391
+ componentPropsError,
7392
+ tabItemKey,
7383
7393
  APPEARANCE_PREFERENCES,
7384
7394
  clampSpacingScale,
7385
7395
  scaleSpacing,
package/dist/contract.js CHANGED
@@ -8,6 +8,8 @@
8
8
  // Consumed by `_shared/cardStyle.js` SHADOW_PRESETS (web + baked built-ins),
9
9
  // the compiler's generated layout `elevationStyles`, and widgets reading
10
10
  // `useTheme().elevation` — so a widget shadow and a container shadow match.
11
+ import { COMPONENT_PROPS, COMPONENT_PROPS_ERROR_PREFIX, componentPropsError, tabItemKey } from "./component-props.js";
12
+
11
13
  const ELEVATION = Object.freeze({
12
14
  none: Object.freeze({}),
13
15
  sm: Object.freeze({
@@ -3827,7 +3829,7 @@ const PRIMITIVES = [
3827
3829
  {
3828
3830
  name: "Tabs",
3829
3831
  description:
3830
- 'Themed tab strip. `<Tabs items={[{ key: "open", label: "Open" }, { key: "done", label: "Done", icon: "check" }]} value={tab} onChange={setTab} />`. The default way to switch between views inside a widget: its look (a segmented control, pills, or an underline — Theme Settings > Tabs) and its colours and corner radius come from the theme, so every tab strip in the app matches, including the page Tabs container. It draws the strip only; render the selected panel yourself below it. Use it rather than tabs of your own from `Pressable` chips; when the request needs a strip it cannot draw (a live count badge on each tab, a vertical rail down the side), build your own in the app\'s look with the tab role and its selected state. Props: `items` (`[{ key, label, icon?, disabled?, testID? }]`, icon is a lucide name), `value` (the selected key), `onChange(key)`, `accessibilityLabel`, `style`, `testID`, and the overrides `variant` ("segmented" | "pill" | "underline"), `activeColor`, `activeTextColor`, `textColor`, `radius`. When the tabs do not fit the width, the strip wraps them onto another line, so every tab stays visible; never wrap it in a horizontal `ScrollView` of your own. Declare `tabsStyle` / `tabsActiveColor` / `tabsActiveTextColor` / `tabsTextColor` / `tabsRadius` style fields and pass them through to let an author override one widget.',
3832
+ 'Themed tab strip. `<Tabs items={[{ key: "open", label: "Open" }, { key: "done", label: "Done", icon: "check" }]} value={tab} onChange={setTab} />`. The default way to switch between views inside a widget: its look (a segmented control, pills, or an underline — Theme Settings > Tabs) and its colours and corner radius come from the theme, so every tab strip in the app matches, including the page Tabs container. It draws the strip only; render the selected panel yourself below it. Use it rather than tabs of your own from `Pressable` chips; when the request needs a strip it cannot draw (a live count badge on each tab, a vertical rail down the side), build your own in the app\'s look with the tab role and its selected state. Props: `items` (`[{ key, label, icon?, disabled?, testID? }]`, icon is a lucide name; an item with `value` and no `key` is keyed by its `value`, like a Select option), `value` (the selected key), `onChange(key)`, `accessibilityLabel`, `style`, `testID`, and the overrides `variant` ("segmented" | "pill" | "underline"), `activeColor`, `activeTextColor`, `textColor`, `radius`. When the tabs do not fit the width, the strip wraps them onto another line, so every tab stays visible; never wrap it in a horizontal `ScrollView` of your own. Declare `tabsStyle` / `tabsActiveColor` / `tabsActiveTextColor` / `tabsTextColor` / `tabsRadius` style fields and pass them through to let an author override one widget.',
3831
3833
  rnComponent: null,
3832
3834
  docsUrl: null,
3833
3835
  },
@@ -6888,7 +6890,10 @@ const CONTRACT = deepFreeze({
6888
6890
  // on web, expo-key-event on native).
6889
6891
  // 1.244.0: additive (sc-15915) — `fixedScopes`, the requestedScopes entries
6890
6892
  // whose target the scope fixes; the publish gate accepts exactly these.
6891
- version: "1.244.0",
6893
+ // 1.245.0: additive (sc-15920) — a Tabs item with `value` and no `key` is
6894
+ // keyed by its `value`; a host may set `ctx.strictProps` so a component
6895
+ // throws on a prop it cannot render without (the widget check's render).
6896
+ version: "1.245.0",
6892
6897
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6893
6898
  hooks: HOOKS,
6894
6899
  primitives: PRIMITIVES,
@@ -7376,6 +7381,10 @@ const APPEARANCE_PREFERENCES = Object.freeze(["light", "dark", "system"]);
7376
7381
 
7377
7382
  export {
7378
7383
  CONTRACT,
7384
+ COMPONENT_PROPS,
7385
+ COMPONENT_PROPS_ERROR_PREFIX,
7386
+ componentPropsError,
7387
+ tabItemKey,
7379
7388
  APPEARANCE_PREFERENCES,
7380
7389
  clampSpacingScale,
7381
7390
  scaleSpacing,
@@ -7,7 +7,7 @@
7
7
  // progress its percent (unless the caller hides it), a stat's delta its sign.
8
8
 
9
9
  import React from "react";
10
- import { useHostTheme } from "./hooks.js";
10
+ import { useHostTheme, useStrictProps } from "./hooks.js";
11
11
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
12
12
  import { lucideGlyph, Icon } from "./icon.js";
13
13
  import { initialsFor } from "./initials.js";
@@ -60,7 +60,9 @@ function captionText(value) {
60
60
  export function makeDetailParts(rn) {
61
61
  const { View, Text, Image, Svg, Circle } = rn;
62
62
 
63
- function Badge({ label, tone = "neutral", icon, style, testID }) {
63
+ function Badge(props) {
64
+ useStrictProps("Badge", props);
65
+ const { label, tone = "neutral", icon, style, testID } = props;
64
66
  const { colors, spacing, radii, typography } = useDetailTheme();
65
67
  const tint = badgeTint(colors, tone);
66
68
  const text = badgeText(label);
package/dist/hooks.js CHANGED
@@ -51,6 +51,12 @@ import {
51
51
  deriveSurfaceTokens,
52
52
  // sc-12335 — the light/dark vocabulary useAppearance() validates against.
53
53
  APPEARANCE_PREFERENCES,
54
+ // sc-15920 — the props a component cannot render without; the contract
55
+ // re-exports them so this file keeps its three imports (the hook tests
56
+ // rewrite exactly those).
57
+ COMPONENT_PROPS,
58
+ COMPONENT_PROPS_ERROR_PREFIX,
59
+ componentPropsError,
54
60
  } from "./contract.js";
55
61
 
56
62
  /** @internal — host-injected context value of shape WidgetContext (see index.d.ts). */
@@ -230,6 +236,15 @@ export function useHostTheme() {
230
236
  return ctx && ctx.workspace ? ctx.workspace.theme : undefined;
231
237
  }
232
238
 
239
+ // @internal — a component's required props, enforced only where the host sets
240
+ // `ctx.strictProps` (the widget check's test render); never in production.
241
+ export function useStrictProps(component, props) {
242
+ const ctx = useContext(HostWidgetContext);
243
+ if (!ctx || !ctx.strictProps) return;
244
+ const error = componentPropsError(component, props, COMPONENT_PROPS);
245
+ if (error) throw new Error(COMPONENT_PROPS_ERROR_PREFIX + error);
246
+ }
247
+
233
248
  // @internal — the navigation counterpart of useHostTheme: reads the host's
234
249
  // navigation slice WITHOUT throwing when no provider is mounted, unlike
235
250
  // useNavigation() which asserts a widget context. `<RichText>` reads it so a
package/dist/index.d.ts CHANGED
@@ -831,6 +831,12 @@ export interface WidgetContext<TProps = unknown> {
831
831
  * the rest of the screen). Absent / `false` everywhere else.
832
832
  */
833
833
  fitScreen?: boolean;
834
+ /**
835
+ * Set by the widget check's test render only: a component throws on a prop
836
+ * it cannot render without (a Tabs item with no key, a Button with no
837
+ * title). Never set by the Player, the Studio or the exported app.
838
+ */
839
+ strictProps?: boolean;
834
840
  /**
835
841
  * sc-11615 — optional host hint backing `useFitScreenInsets()`: set only for
836
842
  * a self-scrolling fit surface with nothing below it. `claim(onInset)` runs
@@ -5312,7 +5318,8 @@ export type TabStyle = "segmented" | "pill" | "underline";
5312
5318
  * <Tabs items={[{ key: "open", label: "Open" }, { key: "done", label: "Done" }]} value={tab} onChange={setTab} />
5313
5319
  */
5314
5320
  export const Tabs: (props: {
5315
- items: Array<{ key: string; label: ReactNode; icon?: string; disabled?: boolean; testID?: string }>;
5321
+ /** An item with `value` and no `key` is keyed by its `value`, like a Select option. */
5322
+ items: Array<{ key?: string; value?: string; label: ReactNode; icon?: string; disabled?: boolean; testID?: string }>;
5316
5323
  value?: string;
5317
5324
  onChange?: (key: string) => void;
5318
5325
  /** Overrides the theme's tab style for this strip. */
@@ -6,7 +6,7 @@
6
6
  // an icon or a tab role. This one has the radio role and the app's look.
7
7
 
8
8
  import React from "react";
9
- import { useHostSharedText, useHostTheme } from "./hooks.js";
9
+ import { useHostSharedText, useHostTheme, useStrictProps } from "./hooks.js";
10
10
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
11
11
  import { Icon } from "./icon.js";
12
12
  import { CHECKBOX_SIZE, CONTROL_MIN_TARGET, focusHaloStyle } from "./form-control-tokens.js";
@@ -157,6 +157,7 @@ export function makeRadioGroup(rn) {
157
157
  }
158
158
 
159
159
  const RadioGroup = React.forwardRef(function RadioGroup(props, ref) {
160
+ useStrictProps("RadioGroup", props);
160
161
  const {
161
162
  options,
162
163
  value,
@@ -10,7 +10,7 @@
10
10
  // it is held, or each pause in typing asks `onSearch` / async `options`.
11
11
 
12
12
  import React from "react";
13
- import { useHostSharedText, useHostTheme } from "./hooks.js";
13
+ import { useHostSharedText, useHostTheme, useStrictProps } from "./hooks.js";
14
14
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
15
15
  import { Icon } from "./icon.js";
16
16
  import { TEXT_FIELD_TOKEN_NAMES } from "./text-field-tokens.js";
@@ -332,6 +332,7 @@ export function makeSelect(rn) {
332
332
  }
333
333
 
334
334
  const Select = React.forwardRef(function Select(props, ref) {
335
+ useStrictProps("Select", props);
335
336
  const {
336
337
  value,
337
338
  onValueChange,
package/dist/tabs-view.js CHANGED
@@ -7,7 +7,8 @@
7
7
  // between web and native. This strip reads the theme's `tabs` scope.
8
8
 
9
9
  import React from "react";
10
- import { useHostTheme } from "./hooks.js";
10
+ import { useHostTheme, useStrictProps } from "./hooks.js";
11
+ import { tabItemKey } from "./component-props.js";
11
12
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
12
13
  import { Icon } from "./icon.js";
13
14
  import {
@@ -60,21 +61,23 @@ function stripStyles(t, theme) {
60
61
  export function makeTabs(rn) {
61
62
  const { View, Text, Pressable } = rn;
62
63
 
63
- function Tabs({
64
- items = [],
65
- value,
66
- onChange,
67
- variant,
68
- defaultVariant,
69
- activeColor,
70
- activeTextColor,
71
- textColor,
72
- radius,
73
- theme: explicitTheme,
74
- accessibilityLabel,
75
- style,
76
- testID,
77
- }) {
64
+ function Tabs(props) {
65
+ useStrictProps("Tabs", props);
66
+ const {
67
+ items = [],
68
+ value,
69
+ onChange,
70
+ variant,
71
+ defaultVariant,
72
+ activeColor,
73
+ activeTextColor,
74
+ textColor,
75
+ radius,
76
+ theme: explicitTheme,
77
+ accessibilityLabel,
78
+ style,
79
+ testID,
80
+ } = props;
78
81
  const hostTheme = useHostTheme();
79
82
  // Layout containers render outside a widget context, so they pass theirs.
80
83
  const theme = explicitTheme || hostTheme || DEFAULT_THEME_TOKENS;
@@ -105,14 +108,15 @@ export function makeTabs(rn) {
105
108
  testID,
106
109
  },
107
110
  ...items.map((item) => {
108
- const active = item.key === value;
111
+ const key = tabItemKey(item);
112
+ const active = key === value;
109
113
  const ink = active ? t.activeTextColor : t.textColor;
110
114
  return React.createElement(
111
115
  Pressable,
112
116
  {
113
- key: item.key,
117
+ key,
114
118
  onPress: () => {
115
- if (!active && typeof onChange === "function") onChange(item.key);
119
+ if (!active && typeof onChange === "function") onChange(key);
116
120
  },
117
121
  disabled: item.disabled,
118
122
  // accessibilityRole + aria-*: the pair that announces on both hosts.
@@ -4,7 +4,7 @@
4
4
  // it instead (a sheet on a device, as `<Menu>` is).
5
5
 
6
6
  import React from "react";
7
- import { useHostTheme } from "./hooks.js";
7
+ import { useHostTheme, useStrictProps } from "./hooks.js";
8
8
  import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
9
9
  import { isText } from "./form-control-logic.js";
10
10
  import { POPOVER_DEFAULTS, resolvePopoverTokens } from "./popover-tokens.js";
@@ -69,10 +69,9 @@ export function makeTooltip(rn, AnchoredSurface) {
69
69
  * @param {string} [props.testID] — on the label.
70
70
  * @param {any} props.children — the one element it labels.
71
71
  */
72
- const Tooltip = React.forwardRef(function Tooltip(
73
- { label, placement = "top", testID, children, ...passThrough },
74
- forwardedRef,
75
- ) {
72
+ const Tooltip = React.forwardRef(function Tooltip(props, forwardedRef) {
73
+ useStrictProps("Tooltip", props);
74
+ const { label, placement = "top", testID, children, ...passThrough } = props;
76
75
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
77
76
  const anchorRef = React.useRef(null);
78
77
  const labelId = React.useId();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.297.0",
3
+ "version": "0.298.0",
4
4
  "description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
5
5
  "homepage": "https://github.com/Colix-AB/AppStudio",
6
6
  "type": "module",
package/src/contract.js CHANGED
@@ -8,6 +8,8 @@
8
8
  // Consumed by `_shared/cardStyle.js` SHADOW_PRESETS (web + baked built-ins),
9
9
  // the compiler's generated layout `elevationStyles`, and widgets reading
10
10
  // `useTheme().elevation` — so a widget shadow and a container shadow match.
11
+ import { COMPONENT_PROPS, COMPONENT_PROPS_ERROR_PREFIX, componentPropsError, tabItemKey } from "./component-props.js";
12
+
11
13
  const ELEVATION = Object.freeze({
12
14
  none: Object.freeze({}),
13
15
  sm: Object.freeze({
@@ -3827,7 +3829,7 @@ const PRIMITIVES = [
3827
3829
  {
3828
3830
  name: "Tabs",
3829
3831
  description:
3830
- 'Themed tab strip. `<Tabs items={[{ key: "open", label: "Open" }, { key: "done", label: "Done", icon: "check" }]} value={tab} onChange={setTab} />`. The default way to switch between views inside a widget: its look (a segmented control, pills, or an underline — Theme Settings > Tabs) and its colours and corner radius come from the theme, so every tab strip in the app matches, including the page Tabs container. It draws the strip only; render the selected panel yourself below it. Use it rather than tabs of your own from `Pressable` chips; when the request needs a strip it cannot draw (a live count badge on each tab, a vertical rail down the side), build your own in the app\'s look with the tab role and its selected state. Props: `items` (`[{ key, label, icon?, disabled?, testID? }]`, icon is a lucide name), `value` (the selected key), `onChange(key)`, `accessibilityLabel`, `style`, `testID`, and the overrides `variant` ("segmented" | "pill" | "underline"), `activeColor`, `activeTextColor`, `textColor`, `radius`. When the tabs do not fit the width, the strip wraps them onto another line, so every tab stays visible; never wrap it in a horizontal `ScrollView` of your own. Declare `tabsStyle` / `tabsActiveColor` / `tabsActiveTextColor` / `tabsTextColor` / `tabsRadius` style fields and pass them through to let an author override one widget.',
3832
+ 'Themed tab strip. `<Tabs items={[{ key: "open", label: "Open" }, { key: "done", label: "Done", icon: "check" }]} value={tab} onChange={setTab} />`. The default way to switch between views inside a widget: its look (a segmented control, pills, or an underline — Theme Settings > Tabs) and its colours and corner radius come from the theme, so every tab strip in the app matches, including the page Tabs container. It draws the strip only; render the selected panel yourself below it. Use it rather than tabs of your own from `Pressable` chips; when the request needs a strip it cannot draw (a live count badge on each tab, a vertical rail down the side), build your own in the app\'s look with the tab role and its selected state. Props: `items` (`[{ key, label, icon?, disabled?, testID? }]`, icon is a lucide name; an item with `value` and no `key` is keyed by its `value`, like a Select option), `value` (the selected key), `onChange(key)`, `accessibilityLabel`, `style`, `testID`, and the overrides `variant` ("segmented" | "pill" | "underline"), `activeColor`, `activeTextColor`, `textColor`, `radius`. When the tabs do not fit the width, the strip wraps them onto another line, so every tab stays visible; never wrap it in a horizontal `ScrollView` of your own. Declare `tabsStyle` / `tabsActiveColor` / `tabsActiveTextColor` / `tabsTextColor` / `tabsRadius` style fields and pass them through to let an author override one widget.',
3831
3833
  rnComponent: null,
3832
3834
  docsUrl: null,
3833
3835
  },
@@ -6888,7 +6890,10 @@ const CONTRACT = deepFreeze({
6888
6890
  // on web, expo-key-event on native).
6889
6891
  // 1.244.0: additive (sc-15915) — `fixedScopes`, the requestedScopes entries
6890
6892
  // whose target the scope fixes; the publish gate accepts exactly these.
6891
- version: "1.244.0",
6893
+ // 1.245.0: additive (sc-15920) — a Tabs item with `value` and no `key` is
6894
+ // keyed by its `value`; a host may set `ctx.strictProps` so a component
6895
+ // throws on a prop it cannot render without (the widget check's render).
6896
+ version: "1.245.0",
6892
6897
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6893
6898
  hooks: HOOKS,
6894
6899
  primitives: PRIMITIVES,
@@ -7376,6 +7381,10 @@ const APPEARANCE_PREFERENCES = Object.freeze(["light", "dark", "system"]);
7376
7381
 
7377
7382
  export {
7378
7383
  CONTRACT,
7384
+ COMPONENT_PROPS,
7385
+ COMPONENT_PROPS_ERROR_PREFIX,
7386
+ componentPropsError,
7387
+ tabItemKey,
7379
7388
  APPEARANCE_PREFERENCES,
7380
7389
  clampSpacingScale,
7381
7390
  scaleSpacing,