@colixsystems/widget-sdk 0.299.1 → 0.301.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,15 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
90
90
 
91
91
  ## Status
92
92
 
93
- `v0.299.1` — 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.301.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.301.0 (contract 1.247.0)
96
+
97
+ **Status colours are fixed again.** A badge, banner, progress bar, stat delta or toast wears the contract's four status colours on every palette: `success` `#059669`, `danger` `#dc2626`, `warning` `#d97706`, `info` `#0284c7`. Since 0.290.0 the hosts derived them from the app's accent, and a muted accent left a "done" chip grey and an "in progress" one beige, so the state no longer read at a glance. The Alerts section's per-tone colours still win. `deriveStatusColors` stays exported; the hosts no longer call it.
98
+
99
+ ### What's new in 0.300.0 (contract 1.246.0)
100
+
101
+ **New linter rule `text-symbol-icon` (severity `warning`, blocking for agents).** A JSX text child that is nothing but a symbol or an emoji (`<Text>✓</Text>`, `<Text>⌕</Text>`, `{open ? "▲" : "▼"}`, a `✓` leading `{label}`) draws an icon as text: it takes the text's size and weight and looks different per font and platform. The finding names the SDK `<Icon>` to use and, where one is obvious, its lucide name (✓ check, ★ star, → arrow-right, ☰ menu, ⌕ search). A symbol inside running text, bullets, dashes, ×, ©, currency signs and flag emoji pass. `appstudio-widget lint` and the marketplace analyzer report it without refusing; the AI widget agent and `/mcp/build`'s `check_widget` / `submit_widget_source` refuse it, like every other lint finding. See *Design & visual polish*.
94
102
 
95
103
  ### What's new in 0.299.1
96
104
 
@@ -3538,6 +3546,7 @@ A widget that works but looks unfinished is only half done. `useTheme()` is the
3538
3546
  - **Answer the touch.** Every tappable card, row and list entry lifts while the pointer is over it (web) or it is pressed (touch). One declaration does both: give the Pressable a style FUNCTION and spread `pressableLift` — `<Pressable onPress={open} style={(state) => [styles.card, ...pressableLift(state)]}>`. The lift is a -2px nudge plus one elevation step from `theme.interaction`, with the web transition built in. Never hand-write hover logic or your own pressed shadows, and never fake feedback with `opacity` — a dimmed surface reads as disabling itself.
3539
3547
  - **Size to your container — measure it, don't stretch into it.** The same widget sits in a full-width desktop section (~1400px), a half-width grid cell (~700px) and a phone (~360px), so layout built only from `flex: 1` stretches to fill whatever it is handed — a month calendar ends up with 200px day cells and swallows the page. Measure your own width with `const [width, onLayout] = useContainerWidth();`, spreading `onLayout` on an unpadded root `View` (a React Native callback, so it behaves identically on both hosts). A width of `0` means "not yet measured" and the SDK helpers answer it with the wide form, so do not special-case it — except a count or size computed from the width (a calendar day, a chart, a card grid's cards per line), which renders nothing size-dependent until the width arrives: a widget gets no declared breakpoint prop, but it can always measure. **Every form, list, table and filter bar lays out in three tiers**: `const [width, onLayout] = useContainerWidth();` then branch on `widthTier(width)` — a form is one column narrow, paired short fields at medium, a 2–3 column grid capped near 1000px wide; a list is stacked cards, one-line cards, then real columns under a header; a filter bar is one toolbar row (search, a dropdown per facet, sort) with the active filters as removable chips beneath, and a single "Filters" button opening a panel when narrow. **Cap a repeating cell** rather than giving a grid `flex: 1` — `const cell = Math.max(32, Math.min(Math.floor((usable - gap * (columns - 1)) / columns), 64));`, with a calendar day cell topping out at 56–72px on `aspectRatio: 1`, and the grid given its exact computed width plus `alignSelf: 'center'` when the cap leaves slack. **Split two co-equal surfaces in the wide tier** (`flexDirection: widthTier(width) === 'wide' ? 'row' : 'column'`, each half `{ flex: 1, minWidth: 0 }`) — a picker beside the form it feeds on a wide canvas, stacked in reading order below it. Never hardcode a width, never put `flex: 1` / `height: '100%'` on a content widget's root, and don't read the screen with `Dimensions` — the screen is not the widget. **Whatever you narrow, you centre** — a block that caps its own measure carries all three of `{ width: '100%', maxWidth: FORM_MAX, alignSelf: 'center' }`, because `alignSelf` alone stops the block stretching and sizes it to its content instead, and `maxWidth` alone leaves the widget flush left with dead space beside it; a capped wrap row lays its cells out along the MAIN axis, so it centres with `justifyContent: 'center'` on the row instead — but a card grid or a tile row is never capped. **Lay out a card grid, a tile row or a grid of capped cells with `<Grid>` by default** — it measures its own unpadded box and applies the rules below; lay one out yourself when it needs what `<Grid>` cannot express, such as masonry or cells that span lines. **A card grid fills its lines, it never wraps freely** — a free `flexWrap` strands the remainder (six cards that fit five render 5 + 1). Count the cards that fit the measured width (`const max = Math.max(1, Math.floor((width + gap) / (CARD_MIN + gap)));`), take `const lines = Math.ceil(count / max); const cols = Math.ceil(count / lines);`, and render each slice of `cols` cards as a row of `{ flex: 1, minWidth: 0 }` cells, padding the last line with empty `{ flex: 1 }` spacers so its cards keep the width of the cards above (six that fit five are 3 + 3, ten that fit four are 4 + 4 + 2). **A short value never breaks across lines** — a time, date, price, count, percentage or code takes `numberOfLines={1}` and `flexShrink: 0`, never a fixed width narrower than it, and a narrow slot re-arranges or steps the font down instead. **A metric / stat-tile row FILLS ITS ROW** — when you know the count, balance the lines (`const lines = Math.ceil(count / max); const base = Math.floor(count / lines); const extra = count % lines; const rows = Array.from({ length: lines }, (_, i) => tiles.slice(i * base + Math.min(i, extra), (i + 1) * base + Math.min(i + 1, extra)));`, with `max` 4 / 3 / 2 by tier, each tile `{ flex: 1, minWidth: 0 }`), and when the count comes from data wrap it (`{ flexDirection: 'row', flexWrap: 'wrap', gap: theme.spacing.md }`, each tile `{ flexGrow: 1, flexBasis: TILE_MIN }`, never a `maxWidth` — capped tiles cluster to one side), because a bare `flexDirection: 'row'` has no way to break and a React Native flex child defaults to `flexShrink: 0` (unlike CSS), so the tiles cannot give ground either: the row runs past its container, spilling out of the card natively and cut off by the scrolling page column on web, with nothing thrown and nothing logged, once there are enough of them (four fit where five do not). The basis is also the per-line ceiling — `Math.floor((usable + gap) / (TILE_MIN + gap))` tiles fit a line, so 240 tops out at five across a full-width ~1400px section and 320 at four; past four or five a line the tiles stop reading as cards.
3540
3548
  - **A Grid cell that holds more than one `Text` is at least 200 wide.** A cell that holds more than one Text is at least 200 wide: `<Grid minCellWidth={150}>` makes five narrow columns at desktop width, and a card carrying a title, a duration and a price breaks words and wraps the price onto two lines there. Leave `minCellWidth` off (the default is 240) or set it to 240 or more; a width under 200 is for cells of a single `Text` (chips, avatars, icon tiles), and the publish gate refuses (`grid-cell-too-narrow`) a narrower Grid whose cell holds more than one `Text`. An action inside a card is a `<Button>`, never a `Pressable` around text.
3549
+ - **Never draw an icon as a text symbol.** A text child that is only a symbol or an emoji, such as "✓", "★", "→", "☰", "⚙", "⌕", "◇", "🔍" or "📞", renders at the text's size and weight and looks different per font and platform, so it reads as unfinished beside the app's line icons. Draw it with the SDK's `<Icon name="check" />` (✓ check, ★ star, → arrow-right, ☰ menu, ⌕ search), or `<IconButton>` when it is pressed; the publish gate refuses a symbol-only text child (`text-symbol-icon`). A symbol inside running text ("Steg 1 → 2", "© 2026"), a bullet or a dash stays text, and an emoji that is the content itself, such as a reaction, renders from data.
3541
3550
  - **Compose forms — pair fields into rows, don't stack one per row.** Lay a form out with `<Form>` by default (above), which does the following for you; when it needs what `<Form>` cannot do (a multi-step wizard, a form beside a live preview, fields laid over a picture), lay the form out in three tiers and cap it near 1000px, centred with the three declarations above — never a 560–720px column alone in a wide box, which leaves a form that IS the page as a narrow strip in empty space. Put short, related fields side by side (first + last name, city + postal code, expiry + CVC): a row of `{ flexDirection: 'row', flexWrap: 'wrap', gap: theme.spacing.md }` with each field cell `{ flexGrow: 1, flexBasis: 160 }` splits the width on a wide card and wraps to stacked on a narrow phone — the right recipe for field pairs because it needs no measurement (a fixed-width column overflows a phone; when a layout needs a real column count instead of wrapping, measure your width as above). Keep wide fields (email, address, notes) full-width with `width: '100%'` — NEVER `flexBasis: '100%'`, which sizes the main axis and therefore claims the parent's whole HEIGHT in a column — cap it at two–three per row, group a long form into labelled sections, and label every input above it (not placeholder-only). Give a `multiline` field BOTH a floor and a ceiling (`{ minHeight: 150, maxHeight: 260 }`) so a long value scrolls inside the box instead of growing past its card, and keep the Save / Cancel row in normal flow below the fields, never positioned over them. A search box is `<SearchField>`, which already carries its glyph and clear control. Any other icon goes inside the field through `leadingIcon` / `trailingIcon`; never wrap a `<TextField>` in a bordered row, since it draws its own border. Put a unit beside the field as a sibling in a row (`flex: 1, minWidth: 0` on the field, so a long value shrinks instead of pushing the row past its container) rather than rebuilding the field to hold it: a hand-built bordered wrapper around a bare `TextInput` loses the app's input look and its label, focus and error handling.
3542
3551
  - **Respond to touch.** Give every `Pressable` the lift via the function-style `style={(state) => [base, ...pressableLift(state)]}` — see "Answer the touch" above. Never dim with `opacity`, which reads as the surface disabling itself.
3543
3552
  - **Drag and drop — show what is being dragged.** Use `<SortableList>` for a list the user reorders and `<Board>` for cards moved between columns by default: they do everything this item describes, on both hosts, and give a user who cannot drag the same moves from the handle. When the request needs what they cannot do (free-form positioning on a canvas, a drag between two widgets), build your own as follows. A drag where the item stays put reads as broken. Three things change the moment a drag starts: the **drag proxy** (the item lifts and follows the finger — `...theme.elevation.lg`, `{ scale: 1.03 }`, `opacity: 0.9`; for a tall or full-width item drag a compact `primarySoft` pill with its icon + one line of label instead), the **source placeholder** (the vacated slot keeps its height as a quiet `colors.surfaceMuted` block so the list doesn't collapse), and the **drop target** (one slot at a time highlighted with `primarySoft` or a 2px `colors.primary` border). Always animate the release — settle into the new slot, or `Animated.spring(pan, { toValue: { x: 0, y: 0 }, useNativeDriver: false })` back to the origin on cancel. Build it with `Animated` + `PanResponder` from `react-native` (the only mechanism that behaves identically on both hosts) — never HTML5 drag events (`draggable` / `onDragStart` / `dataTransfer` are web-only, and `document` / `window` are banned) — and start the drag from a `GripVertical` grip handle whenever the row is also tappable or sits in a `ScrollView`. **A board (kanban, pipeline) drops onto ANOTHER column**, which needs four more things: the board's root renders the one proxy (a column clips whatever leaves it); you hit-test the drop yourself — `measureInWindow` every column and the board when the drag starts and compare the gesture's window `moveX` (never `onLayout` frames, which are relative to a padded or scrolled parent) — highlighting exactly one target; the drop WRITES (`update(id, { [statusField]: value })` through `useDatastoreMutation`, optimistic until `refetch()`, a toast and a spring-back on failure); and three or more columns go in a `horizontal` `ScrollView` when `widthTier(width) === "narrow"`, with the grip claiming the gesture (`onStartShouldSetPanResponder`, `onPanResponderTerminationRequest: () => false`) and carrying `touchAction: 'none'` on web so a finger drag moves the card instead of scrolling the page. And because `useRef(PanResponder.create(...))` runs ONCE, everything its callbacks read — the `useCanWrite` flag included, which starts `false` — goes through a ref refreshed every render (`latest.current.canDrag`); the publish gate `widget.staleResponder` rejects a value read directly.
@@ -3952,6 +3961,8 @@ Pass `--manifest` to enable `style-field-unread` and the three editability rules
3952
3961
 
3953
3962
  `grid-cell-too-narrow` refuses a `<Grid minCellWidth={N}>` with `N` under 200 whose cell holds more than one `Text`, naming the cell width and the default of 240: a card with a title and a price breaks its words at that width. A cell of a single `Text` passes at any width, and a Grid without `minCellWidth` passes. An error.
3954
3963
 
3964
+ `text-symbol-icon` flags a JSX text child that is nothing but symbols or emoji (`<Text>✓</Text>`, `<Text>{open ? "▲" : "▼"}</Text>`, or `✓ {label}`), naming the lucide `<Icon>` to draw instead where one is obvious (✓ check, ★ star, → arrow-right, ☰ menu, ⌕ search). A symbol inside running text ("Steg 1 → 2", "© 2026"), bullets and dashes (• · – —), ×, currency signs and flag emoji pass. A warning for a human author, blocking for the AI widget agent and `/mcp/build`.
3965
+
3955
3966
  `row-action-not-gated` flags a widget that calls `update` or `delete` from `useDatastoreMutation` without a per-row permission check: no `_capabilities` read and no `useCanWrite(tableId, { recordId })`. The table-level `useCanWrite(tableId)` only answers "may create", so a list gated on it shows Edit / Delete on rows the server will refuse. A warning.
3956
3967
 
3957
3968
  `no-html-in-content` flags an HTML tag inside a **string** — `"<strong>"`, `"<br>"`, `"<p>…</p>"`. There is no HTML renderer on either host, so the tag reaches the reader as literal text; author formatted text with `<MarkdownInput>` and render it with `<RichText>` instead. Only string and template content is scanned, so your own `<View>` / `<Text>` JSX can never trip it. A warning for a human author, blocking for the AI widget agent.
package/dist/contract.cjs CHANGED
@@ -90,13 +90,11 @@ const DEFAULT_THEME_TOKENS = Object.freeze({
90
90
  // background — so a dark theme gets a visible spinner with no new maths.
91
91
  loader: "#475569",
92
92
  border: "#e2e8f0",
93
- // The four status tones are re-derived per tenant by `deriveStatusColors`
94
- // (their hue families on the accent's saturation and lightness); these
95
- // literals are that derivation applied to the default palette.
96
- danger: "#e90b0b",
97
- success: "#067e56",
98
- warning: "#9b6507",
99
- info: "#0877af",
93
+ // Fixed for every palette: hosts do not derive them (see 1.247.0).
94
+ danger: "#dc2626",
95
+ success: "#059669",
96
+ warning: "#d97706",
97
+ info: "#0284c7",
100
98
  }),
101
99
  elevation: ELEVATION,
102
100
  interaction: INTERACTION,
@@ -6914,7 +6912,10 @@ const CONTRACT = deepFreeze({
6914
6912
  // 1.246.0: additive (sc-15876) — `useAction()` gains `enqueue(input)`, which
6915
6913
  // queues the run and resolves at once; the script runs with the Action's
6916
6914
  // normal limits and returns nothing to the widget.
6917
- version: "1.246.0",
6915
+ // 1.247.0: the four status tokens are fixed again (danger #dc2626, success
6916
+ // #059669, warning #d97706, info #0284c7); hosts no longer derive them from
6917
+ // the palette. `deriveStatusColors` stays exported, unused by the hosts.
6918
+ version: "1.247.0",
6918
6919
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6919
6920
  hooks: HOOKS,
6920
6921
  primitives: PRIMITIVES,
package/dist/contract.js CHANGED
@@ -85,13 +85,11 @@ const DEFAULT_THEME_TOKENS = Object.freeze({
85
85
  // background — so a dark theme gets a visible spinner with no new maths.
86
86
  loader: "#475569",
87
87
  border: "#e2e8f0",
88
- // The four status tones are re-derived per tenant by `deriveStatusColors`
89
- // (their hue families on the accent's saturation and lightness); these
90
- // literals are that derivation applied to the default palette.
91
- danger: "#e90b0b",
92
- success: "#067e56",
93
- warning: "#9b6507",
94
- info: "#0877af",
88
+ // Fixed for every palette: hosts do not derive them (see 1.247.0).
89
+ danger: "#dc2626",
90
+ success: "#059669",
91
+ warning: "#d97706",
92
+ info: "#0284c7",
95
93
  }),
96
94
  elevation: ELEVATION,
97
95
  interaction: INTERACTION,
@@ -6909,7 +6907,10 @@ const CONTRACT = deepFreeze({
6909
6907
  // 1.246.0: additive (sc-15876) — `useAction()` gains `enqueue(input)`, which
6910
6908
  // queues the run and resolves at once; the script runs with the Action's
6911
6909
  // normal limits and returns nothing to the widget.
6912
- version: "1.246.0",
6910
+ // 1.247.0: the four status tokens are fixed again (danger #dc2626, success
6911
+ // #059669, warning #d97706, info #0284c7); hosts no longer derive them from
6912
+ // the palette. `deriveStatusColors` stays exported, unused by the hosts.
6913
+ version: "1.247.0",
6913
6914
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6914
6915
  hooks: HOOKS,
6915
6916
  primitives: PRIMITIVES,
package/dist/index.d.ts CHANGED
@@ -6162,7 +6162,8 @@ export function deriveAccentTints(
6162
6162
  * Derive the four status colours from a resolved palette: each keeps its hue
6163
6163
  * family and takes the accent's saturation and lightness, stepped toward
6164
6164
  * `onSurface` until it clears WCAG AA against the surface. `null` when the
6165
- * inputs aren't hex.
6165
+ * inputs aren't hex. The hosts do not apply it: a theme's status tones are the
6166
+ * contract's fixed four.
6166
6167
  */
6167
6168
  export function deriveStatusColors(
6168
6169
  primary: string,
package/dist/linter.cjs CHANGED
@@ -1118,6 +1118,129 @@ function _lucideIconRules(source) {
1118
1118
  return findings;
1119
1119
  }
1120
1120
 
1121
+ // A symbol drawn as text renders at the text's size and weight, differs per
1122
+ // font and platform, and reads as unfinished beside the app's line icons.
1123
+ // Only a text child that is nothing but symbols counts: inside running text
1124
+ // ("Steg 1 → 2", "© 2026") a symbol is copy. Bullets, dashes, ×, ©, currency
1125
+ // and flag emoji are outside the set on purpose. A warning: agents' publish
1126
+ // gates refuse it, while a human author's widget only hears about it.
1127
+ const _ICON_SYMBOL_RE =
1128
+ /^[\u2190-\u21FF\u22EE\u2300-\u23FF\u25A0-\u25FF\u2600-\u27BF\u27F0-\u27FF\u2900-\u297F\u2B00-\u2BFF\u{1F000}-\u{1F1E5}\u{1F200}-\u{1FAFF}]$/u;
1129
+ const _BULLET_SYMBOLS = new Set(["●", "○", "◦", "▪", "▫"]);
1130
+ const _SYMBOL_JOINERS_RE = /\s|\uFE0E|\uFE0F|\u200D|\u20E3/gu;
1131
+ const _SYMBOL_ICON_NAMES = new Map(
1132
+ Object.entries({
1133
+ check: "✓✔☑✅",
1134
+ x: "✗✘✕✖❌",
1135
+ star: "★☆⭐",
1136
+ heart: "♥♡❤",
1137
+ "arrow-right": "→➜➔➡⟶",
1138
+ "arrow-left": "←⬅⟵",
1139
+ "arrow-up": "↑⬆",
1140
+ "arrow-down": "↓⬇",
1141
+ "chevron-right": "▸►",
1142
+ "chevron-left": "◂◄◀",
1143
+ "chevron-down": "▼▾",
1144
+ "chevron-up": "▲▴",
1145
+ play: "▶",
1146
+ menu: "☰",
1147
+ search: "⌕🔍🔎",
1148
+ settings: "⚙",
1149
+ diamond: "◇◆♦",
1150
+ wrench: "🔧🛠⚒",
1151
+ "ellipsis-vertical": "⋮",
1152
+ phone: "☎📞",
1153
+ mail: "✉📧📩",
1154
+ calendar: "📅📆",
1155
+ "map-pin": "📍",
1156
+ clock: "⏰⏱🕐⌚",
1157
+ "triangle-alert": "⚠",
1158
+ home: "⌂🏠",
1159
+ "shopping-cart": "🛒",
1160
+ "thumbs-up": "👍",
1161
+ lock: "🔒",
1162
+ bell: "🔔",
1163
+ camera: "📷",
1164
+ sun: "☀",
1165
+ pencil: "✎✏",
1166
+ "trash-2": "🗑",
1167
+ gift: "🎁",
1168
+ truck: "🚚",
1169
+ sparkles: "✨",
1170
+ }).flatMap(([name, symbols]) => [...symbols].map((s) => [s, name])),
1171
+ );
1172
+ const _STRING_LITERAL_RE = /(["'`])((?:\\.|(?!\1)[^\\\r\n\u2028\u2029])*)\1/g;
1173
+ // What may sit around the strings: `open ? "▲" : "▼"`, `done && "✓"`.
1174
+ const _CHOICE_EXPRESSION_RE = /^[\w$.\s?:!&|()<>=]*$/;
1175
+
1176
+ function _iconSymbols(text) {
1177
+ const symbols = [...text.replace(_SYMBOL_JOINERS_RE, "")];
1178
+ if (symbols.length === 0) return null;
1179
+ const isIcon = (s) => _ICON_SYMBOL_RE.test(s) && !_BULLET_SYMBOLS.has(s);
1180
+ return symbols.every(isIcon) ? symbols.join("") : null;
1181
+ }
1182
+
1183
+ // A braced child rendering only symbol strings: `{"✓"}`, `{open ? "▲" : "▼"}`.
1184
+ function _bracedIconSymbols(inner) {
1185
+ const strings = [...inner.matchAll(_STRING_LITERAL_RE)];
1186
+ if (strings.length === 0) return null;
1187
+ if (!_CHOICE_EXPRESSION_RE.test(inner.replace(_STRING_LITERAL_RE, ""))) return null;
1188
+ if (strings.some(([, quote, text]) => quote === "`" && text.includes("${"))) return null;
1189
+ const texts = strings.map((s) => s[2]).filter((t) => t.trim() !== "");
1190
+ const symbols = texts.map(_iconSymbols);
1191
+ return texts.length > 0 && symbols.every(Boolean) ? symbols[0] : null;
1192
+ }
1193
+
1194
+ // The first child of each JSX element, when it is symbols alone or symbols
1195
+ // leading a value (`✓ {label}`), as { text, at }.
1196
+ function _symbolIconChildren(code, mask) {
1197
+ const index = _jsxScanIndex(mask);
1198
+ const found = [];
1199
+ const tag = /<[A-Za-z][\w.]*/g;
1200
+ let m;
1201
+ while ((m = tag.exec(mask)) !== null) {
1202
+ const end = index.tagEnd(m.index);
1203
+ if (end === -1 || mask[end - 1] === "/") continue;
1204
+ const child = /^[^<>{}]*/.exec(code.slice(end + 1, end + 2001))[0];
1205
+ const at = end + 1 + child.length;
1206
+ let text = null;
1207
+ if (child.trim() !== "") {
1208
+ if (code[at] === "<" || code[at] === "{") text = _iconSymbols(child);
1209
+ } else if (code[at] === "{") {
1210
+ const close = index.braceClose(at);
1211
+ if (close !== -1) text = _bracedIconSymbols(code.slice(at + 1, close));
1212
+ }
1213
+ if (text) found.push({ text, at: child.trim() !== "" ? end + 1 + child.search(/\S/) : at });
1214
+ }
1215
+ return found;
1216
+ }
1217
+
1218
+ function _textSymbolIconRules(source) {
1219
+ const code = _stripNonCode(source, { keepStrings: true });
1220
+ const lineAt = _lineCounter(code);
1221
+ const sourceLines = source.split(/\r?\n/);
1222
+ const seen = new Set();
1223
+ const findings = [];
1224
+ for (const { text, at } of _symbolIconChildren(code, _stripNonCode(source))) {
1225
+ if (seen.has(text)) continue;
1226
+ seen.add(text);
1227
+ const name = _SYMBOL_ICON_NAMES.get([...text][0]);
1228
+ const line = lineAt(at);
1229
+ findings.push({
1230
+ rule: "text-symbol-icon",
1231
+ severity: "warning",
1232
+ label:
1233
+ `"${text}" drawn as text is an icon that takes the text's size and weight and ` +
1234
+ `looks different per font and platform. Draw it with the SDK's ` +
1235
+ `${name ? `<Icon name="${name}" />` : `<Icon> (a lucide name)`} instead. An emoji ` +
1236
+ `that is the content itself, such as a reaction, renders from data or a prop.`,
1237
+ line,
1238
+ snippet: (sourceLines[line - 1] || "").trim().slice(0, 200),
1239
+ });
1240
+ }
1241
+ return findings;
1242
+ }
1243
+
1121
1244
  // sc-2353 / sc-5897 — widget source must be SELF-CONTAINED: every identifier it
1122
1245
  // references needs a binding in that file. Two rules share ONE detector here
1123
1246
  // because they are one bug with one cause (CLAUDE.md §3):
@@ -2956,6 +3079,7 @@ function lintSource(source, options) {
2956
3079
  findings.push(..._scopeMintRules(source));
2957
3080
  findings.push(..._handBuiltPageUrlRules(source));
2958
3081
  findings.push(..._lucideIconRules(source));
3082
+ findings.push(..._textSymbolIconRules(source));
2959
3083
  findings.push(..._bundledAssetRules(source, options && options.assetFiles));
2960
3084
  // sc-2353 / sc-5897 — widget source must be self-contained: a referenced
2961
3085
  // `React` global or SDK export with no import throws at render.
package/dist/linter.js CHANGED
@@ -1113,6 +1113,129 @@ function _lucideIconRules(source) {
1113
1113
  return findings;
1114
1114
  }
1115
1115
 
1116
+ // A symbol drawn as text renders at the text's size and weight, differs per
1117
+ // font and platform, and reads as unfinished beside the app's line icons.
1118
+ // Only a text child that is nothing but symbols counts: inside running text
1119
+ // ("Steg 1 → 2", "© 2026") a symbol is copy. Bullets, dashes, ×, ©, currency
1120
+ // and flag emoji are outside the set on purpose. A warning: agents' publish
1121
+ // gates refuse it, while a human author's widget only hears about it.
1122
+ const _ICON_SYMBOL_RE =
1123
+ /^[\u2190-\u21FF\u22EE\u2300-\u23FF\u25A0-\u25FF\u2600-\u27BF\u27F0-\u27FF\u2900-\u297F\u2B00-\u2BFF\u{1F000}-\u{1F1E5}\u{1F200}-\u{1FAFF}]$/u;
1124
+ const _BULLET_SYMBOLS = new Set(["●", "○", "◦", "▪", "▫"]);
1125
+ const _SYMBOL_JOINERS_RE = /\s|\uFE0E|\uFE0F|\u200D|\u20E3/gu;
1126
+ const _SYMBOL_ICON_NAMES = new Map(
1127
+ Object.entries({
1128
+ check: "✓✔☑✅",
1129
+ x: "✗✘✕✖❌",
1130
+ star: "★☆⭐",
1131
+ heart: "♥♡❤",
1132
+ "arrow-right": "→➜➔➡⟶",
1133
+ "arrow-left": "←⬅⟵",
1134
+ "arrow-up": "↑⬆",
1135
+ "arrow-down": "↓⬇",
1136
+ "chevron-right": "▸►",
1137
+ "chevron-left": "◂◄◀",
1138
+ "chevron-down": "▼▾",
1139
+ "chevron-up": "▲▴",
1140
+ play: "▶",
1141
+ menu: "☰",
1142
+ search: "⌕🔍🔎",
1143
+ settings: "⚙",
1144
+ diamond: "◇◆♦",
1145
+ wrench: "🔧🛠⚒",
1146
+ "ellipsis-vertical": "⋮",
1147
+ phone: "☎📞",
1148
+ mail: "✉📧📩",
1149
+ calendar: "📅📆",
1150
+ "map-pin": "📍",
1151
+ clock: "⏰⏱🕐⌚",
1152
+ "triangle-alert": "⚠",
1153
+ home: "⌂🏠",
1154
+ "shopping-cart": "🛒",
1155
+ "thumbs-up": "👍",
1156
+ lock: "🔒",
1157
+ bell: "🔔",
1158
+ camera: "📷",
1159
+ sun: "☀",
1160
+ pencil: "✎✏",
1161
+ "trash-2": "🗑",
1162
+ gift: "🎁",
1163
+ truck: "🚚",
1164
+ sparkles: "✨",
1165
+ }).flatMap(([name, symbols]) => [...symbols].map((s) => [s, name])),
1166
+ );
1167
+ const _STRING_LITERAL_RE = /(["'`])((?:\\.|(?!\1)[^\\\r\n\u2028\u2029])*)\1/g;
1168
+ // What may sit around the strings: `open ? "▲" : "▼"`, `done && "✓"`.
1169
+ const _CHOICE_EXPRESSION_RE = /^[\w$.\s?:!&|()<>=]*$/;
1170
+
1171
+ function _iconSymbols(text) {
1172
+ const symbols = [...text.replace(_SYMBOL_JOINERS_RE, "")];
1173
+ if (symbols.length === 0) return null;
1174
+ const isIcon = (s) => _ICON_SYMBOL_RE.test(s) && !_BULLET_SYMBOLS.has(s);
1175
+ return symbols.every(isIcon) ? symbols.join("") : null;
1176
+ }
1177
+
1178
+ // A braced child rendering only symbol strings: `{"✓"}`, `{open ? "▲" : "▼"}`.
1179
+ function _bracedIconSymbols(inner) {
1180
+ const strings = [...inner.matchAll(_STRING_LITERAL_RE)];
1181
+ if (strings.length === 0) return null;
1182
+ if (!_CHOICE_EXPRESSION_RE.test(inner.replace(_STRING_LITERAL_RE, ""))) return null;
1183
+ if (strings.some(([, quote, text]) => quote === "`" && text.includes("${"))) return null;
1184
+ const texts = strings.map((s) => s[2]).filter((t) => t.trim() !== "");
1185
+ const symbols = texts.map(_iconSymbols);
1186
+ return texts.length > 0 && symbols.every(Boolean) ? symbols[0] : null;
1187
+ }
1188
+
1189
+ // The first child of each JSX element, when it is symbols alone or symbols
1190
+ // leading a value (`✓ {label}`), as { text, at }.
1191
+ function _symbolIconChildren(code, mask) {
1192
+ const index = _jsxScanIndex(mask);
1193
+ const found = [];
1194
+ const tag = /<[A-Za-z][\w.]*/g;
1195
+ let m;
1196
+ while ((m = tag.exec(mask)) !== null) {
1197
+ const end = index.tagEnd(m.index);
1198
+ if (end === -1 || mask[end - 1] === "/") continue;
1199
+ const child = /^[^<>{}]*/.exec(code.slice(end + 1, end + 2001))[0];
1200
+ const at = end + 1 + child.length;
1201
+ let text = null;
1202
+ if (child.trim() !== "") {
1203
+ if (code[at] === "<" || code[at] === "{") text = _iconSymbols(child);
1204
+ } else if (code[at] === "{") {
1205
+ const close = index.braceClose(at);
1206
+ if (close !== -1) text = _bracedIconSymbols(code.slice(at + 1, close));
1207
+ }
1208
+ if (text) found.push({ text, at: child.trim() !== "" ? end + 1 + child.search(/\S/) : at });
1209
+ }
1210
+ return found;
1211
+ }
1212
+
1213
+ function _textSymbolIconRules(source) {
1214
+ const code = _stripNonCode(source, { keepStrings: true });
1215
+ const lineAt = _lineCounter(code);
1216
+ const sourceLines = source.split(/\r?\n/);
1217
+ const seen = new Set();
1218
+ const findings = [];
1219
+ for (const { text, at } of _symbolIconChildren(code, _stripNonCode(source))) {
1220
+ if (seen.has(text)) continue;
1221
+ seen.add(text);
1222
+ const name = _SYMBOL_ICON_NAMES.get([...text][0]);
1223
+ const line = lineAt(at);
1224
+ findings.push({
1225
+ rule: "text-symbol-icon",
1226
+ severity: "warning",
1227
+ label:
1228
+ `"${text}" drawn as text is an icon that takes the text's size and weight and ` +
1229
+ `looks different per font and platform. Draw it with the SDK's ` +
1230
+ `${name ? `<Icon name="${name}" />` : `<Icon> (a lucide name)`} instead. An emoji ` +
1231
+ `that is the content itself, such as a reaction, renders from data or a prop.`,
1232
+ line,
1233
+ snippet: (sourceLines[line - 1] || "").trim().slice(0, 200),
1234
+ });
1235
+ }
1236
+ return findings;
1237
+ }
1238
+
1116
1239
  // sc-2353 / sc-5897 — widget source must be SELF-CONTAINED: every identifier it
1117
1240
  // references needs a binding in that file. Two rules share ONE detector here
1118
1241
  // because they are one bug with one cause (CLAUDE.md §3):
@@ -2951,6 +3074,7 @@ export function lintSource(source, options) {
2951
3074
  findings.push(..._scopeMintRules(source));
2952
3075
  findings.push(..._handBuiltPageUrlRules(source));
2953
3076
  findings.push(..._lucideIconRules(source));
3077
+ findings.push(..._textSymbolIconRules(source));
2954
3078
  findings.push(..._bundledAssetRules(source, options && options.assetFiles));
2955
3079
  // sc-2353 / sc-5897 — widget source must be self-contained: a referenced
2956
3080
  // `React` global or SDK export with no import throws at render.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.299.1",
3
+ "version": "0.301.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
@@ -85,13 +85,11 @@ const DEFAULT_THEME_TOKENS = Object.freeze({
85
85
  // background — so a dark theme gets a visible spinner with no new maths.
86
86
  loader: "#475569",
87
87
  border: "#e2e8f0",
88
- // The four status tones are re-derived per tenant by `deriveStatusColors`
89
- // (their hue families on the accent's saturation and lightness); these
90
- // literals are that derivation applied to the default palette.
91
- danger: "#e90b0b",
92
- success: "#067e56",
93
- warning: "#9b6507",
94
- info: "#0877af",
88
+ // Fixed for every palette: hosts do not derive them (see 1.247.0).
89
+ danger: "#dc2626",
90
+ success: "#059669",
91
+ warning: "#d97706",
92
+ info: "#0284c7",
95
93
  }),
96
94
  elevation: ELEVATION,
97
95
  interaction: INTERACTION,
@@ -6909,7 +6907,10 @@ const CONTRACT = deepFreeze({
6909
6907
  // 1.246.0: additive (sc-15876) — `useAction()` gains `enqueue(input)`, which
6910
6908
  // queues the run and resolves at once; the script runs with the Action's
6911
6909
  // normal limits and returns nothing to the widget.
6912
- version: "1.246.0",
6910
+ // 1.247.0: the four status tokens are fixed again (danger #dc2626, success
6911
+ // #059669, warning #d97706, info #0284c7); hosts no longer derive them from
6912
+ // the palette. `deriveStatusColors` stays exported, unused by the hosts.
6913
+ version: "1.247.0",
6913
6914
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6914
6915
  hooks: HOOKS,
6915
6916
  primitives: PRIMITIVES,