@colixsystems/widget-sdk 0.297.0 → 0.299.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 +17 -5
- package/dist/banner-view.js +15 -13
- package/dist/board-view.js +19 -17
- package/dist/button-view.js +3 -1
- package/dist/chip-view.js +20 -18
- package/dist/component-props.cjs +83 -0
- package/dist/component-props.js +73 -0
- package/dist/confirm-dialog-view.js +16 -14
- package/dist/contract.cjs +32 -6
- package/dist/contract.js +31 -6
- package/dist/detail-parts-view.js +4 -2
- package/dist/hooks.js +38 -1
- package/dist/index.d.ts +17 -2
- package/dist/radio-group-view.js +2 -1
- package/dist/select-view.js +2 -1
- package/dist/tabs-view.js +23 -19
- package/dist/tooltip-view.js +4 -5
- package/package.json +1 -1
- package/src/contract.js +31 -6
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ The data layer lives in **four separate domain-client packages**, each instantia
|
|
|
58
58
|
| **DATASTORE** | `useBoundColumns(tableId, shape, props)` | `{ columns, resolved, missing, loading, error }` | `schema(tableId)` (built on `useDatastoreSchema`) — `datastore.read:<table>`. Resolves author-bound column NAMES from `props` by exact name → case-insensitive name → first unclaimed column matching `shape[key].dataType`, so a column an author renamed after install still resolves instead of `record[props.titleField]` reading `undefined`. `columns` holds the resolved NAME (`record[columns.titleField]`); `resolved` holds the full `Column`; `missing` lists non-`optional` keys that never resolved. Falsy `tableId` collapses to `{ columns: {}, resolved: {}, missing: Object.keys(shape), loading: false, error: null }`. |
|
|
59
59
|
| **DATASTORE** | `useInterpretDraft(tableId)` | `{ interpret, interpreting, error, result, available }` | `interpret(tableId, body)` — `datastore.read:<table>`. Turns ONE sentence a user typed ("walk at 11 am tomorrow") into DRAFT column values so a form can prefill itself. IMPERATIVE: call `interpret(text, { fields?, timeZone? })` from an event handler, never on mount. It DRAFTS and writes nothing — show the values for review, then submit through `useDatastoreMutation().create`. Resolves to `{ values, unresolved }`; `values` is keyed by column NAME (the shape `create()` takes) and `unresolved` names the fields the sentence did not state. Only text / number / boolean / date / datetime / array columns are drafted — `FILE`, `RELATION`, `USER` and `USER_GROUP` carry ids and are never guessed. Fails closed to an empty draft. **Every call spends the workspace's AI credits** and is rate-limited per actor, so call it once per user action (never on mount or in a render loop); once the workspace runs out the call is refused with a generic 429 — an app user is deliberately **not** told the workspace's billing state, since they have never heard of an AI credit and cannot buy one. Never surface a raw error to the person filling the form: say drafting is unavailable and keep every field editable by hand. `available` is false where the host brokers no interpreter. |
|
|
60
60
|
| **AGENTS** | `useAgent(agentRef)` | `{ send, cancel, reset, messages, sending, resuming, error, available }` | `ctx.agents` — `ai.invoke:*`. Hold a conversation with one of the WORKSPACE's own AI agents (an author-written name + system prompt). Sending is IMPERATIVE: call `send(text)` from an event handler, never on mount — the first send opens the conversation, so a widget nobody types into costs nothing. On mount the hook DOES reopen the caller's most recent thread with this agent, so a refresh or a navigation keeps the conversation instead of starting a blank one; that resume only READS and spends no credit. `resuming` is true while it runs — render a loading state, not an empty thread. `messages` is the running transcript, oldest first. You **cannot** set or read the system prompt, replay an edited transcript, or pick a model: the server assembles every turn from the stored prompt plus the stored history, and `content` is the only thing that reaches the wire. `reset()` drops the thread (a "new chat" affordance), and the new thread is the one a later mount resumes. **Every send spends the workspace's AI credits** and is rate-limited per caller AND per workspace. Rejects with `AgentError`; branch on `.code` — `AI_QUOTA_EXCEEDED` (429) is the workspace's credit ceiling and will NOT clear on a retry, unlike `RATE_LIMITED`, so never offer "try again" for it, and `AGENT_DISABLED` (409) means the author turned it off, so hide the affordance. Never surface a raw error or the workspace's billing state to an app user. `available` is false when no agent is bound or the host brokers none — render a visible unbound state, never a blank box. An assistant message that used a tool also carries **`activity`** — what the agent DID with the user's data: the table it read (with the `search` text and `filters` it read with), or the table and columns it CHANGED (never the values, and never a row the permissions refused). **Render a write.** A reply saying "done!" is not evidence a row was written, and if the agent got it wrong the user has no other way to notice. A talk-only turn omits the key entirely. |
|
|
61
|
-
| **ACTIONS** | `useAction(actionRef)` | `{ available, run, running, result, error }` | `ctx.actions` — `actions.run:*`. Run one of the workspace's Actions from an event handler (never on mount) and read the value it passed to `respond()
|
|
61
|
+
| **ACTIONS** | `useAction(actionRef)` | `{ available, run, enqueue, running, result, error }` | `ctx.actions` — `actions.run:*`. Run one of the workspace's Actions from an event handler (never on mount) and read the value it passed to `respond()`, or `enqueue` it to run later with its normal limits and no answer. The Action needs the app trigger. `available` is false when nothing is bound or the host brokers no client. Errors are `ActionError` with a stable `code`. |
|
|
62
62
|
| **DATASTORE** | `useDatastoreMutation(table)` | `{ create, update, delete }` | `records(table).{ create, update (PATCH), delete }` — `datastore.write:*`. A successful write re-reads every query, record, figure and aggregate on that table in every widget on the screen (a run of writes at most once a second, always once more after the last), so never refetch after it, and never write from an effect that re-runs on the data it reads unless a ref or Set marks what it already wrote. **To CLEAR a cell, pass it empty** — `update(id, { when: null })` (also `""` or `[]`) empties that cell and it reads back as `null` (`[]` on an array column). There is no separate clear call, so never write a sentinel such as `0` or a placeholder date to mean "no value". `false` and `0` are values, not clears, and a REQUIRED column cannot be cleared. |
|
|
63
63
|
| **DATASTORE** | `useDatastoreSubscription(table, handlers, options)` (optional: options) | `{ status }` — `"connecting" \| "live" \| "reconnecting" \| "fallback"` | `records(table).subscribe` — `datastore.read:<table>`. To keep a list, record or figure current, pass `live: true` to its read hook instead (*Live lists*); this hook is for acting on each change. Live `onCreated` / `onUpdated` / `onDeleted` off the realtime socket; never throws, resolving to `{ status: "fallback" }` so the widget polls instead. A whole-table subscribe is gated on read-EVERY-row, because one envelope reaches every subscriber of the table — so for a table governed by per-record grants pass `options.scope`: `{ kind: "record", record_id }` for one row, or `{ kind: "parent", relation_column, record_id }` for the rows whose RELATION column points at that parent (the column must carry `inheritAcl`, else the subscribe reports `"fallback"`). For a live list of the signed-in user's own rows pass `{ kind: "granted" }`: every row they read through a grant to them or one of their groups, plus `onAccessGained(record)` / `onAccessLost({ id })` as rows enter and leave that set. Re-subscribes on the scope's VALUES, so a fresh object literal each render is fine. |
|
|
64
64
|
| **DATASTORE** | `useTyping(tableId, recordId)` | `{ typingUserIds, setTyping, status }` — status `"connecting" \| "live" \| "unavailable"` | `records(table).typing` — `datastore.read:<table>`. Who else is typing in one record, over the same socket as `useDatastoreSubscription`. Call `setTyping(true)` on every keystroke (throttled to one signal per 3 s; `false` is sent after 5 s idle) and `setTyping(false)` on send, clear or blur. `typingUserIds` lists the OTHER users' ids; each drops out 6 s after their last signal. Needs a signed-in user who can read the record. Never throws: an anonymous visitor, a refused subscription or a host whose client lacks `typing` reads `{ typingUserIds: [], status: "unavailable" }`. Re-subscribes when either id changes. |
|
|
@@ -90,7 +90,19 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
90
90
|
|
|
91
91
|
## Status
|
|
92
92
|
|
|
93
|
-
`v0.
|
|
93
|
+
`v0.299.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.299.0 (contract 1.246.0)
|
|
96
|
+
|
|
97
|
+
**`useAction()` can queue a run instead of waiting for it.** The hook now returns `enqueue(input)` beside `run(input)`. `run` still waits for the Action and hands back its `respond()` value, and must finish within 500 ms of the press. `enqueue` resolves as soon as the server has queued the run, with the same refusals as `run` (`ACTION_NOT_APP_INVOKABLE`, `ACTION_NOT_FOUND`, `INVALID_ACTION_INPUT`, `RATE_LIMITED`, a signed-out caller). The Action then runs away from the request with its normal time limits, the way a scheduled run does, and a pod restart does not lose it. Nothing comes back: `running`, `result` and `error` stay as they were. Use it to start work the widget needs no answer from (a batch, a sync, a long send), and tell the user it has started, not that it is done. It is also refused, rather than queued, when the Action is switched off (`ACTION_DISABLED`) or paused (`ACTION_PAUSED`), and with `RATE_LIMITED` when the workspace already has 10 queued runs waiting or running. It can run twice: a scheduler restarted mid-run starts it again, so write the Action to be safe to repeat. On a host whose actions client cannot queue, `enqueue` rejects `UNAVAILABLE`. The injected client is `@colixsystems/actions-client` 0.4.0.
|
|
98
|
+
|
|
99
|
+
```jsx
|
|
100
|
+
const { available, enqueue } = useAction(props.actionId);
|
|
101
|
+
const start = () => enqueue({ batch_id: batch.id }).then(() => toast.show("Started"), () => toast.show("Could not start"));
|
|
102
|
+
|
|
103
|
+
### What's new in 0.298.0 (contract 1.245.0)
|
|
104
|
+
|
|
105
|
+
**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
106
|
|
|
95
107
|
### What's new in 0.297.0 (contract 1.244.0)
|
|
96
108
|
|
|
@@ -115,7 +127,7 @@ const dx = (pressed.has("ArrowRight") ? 1 : 0) - (pressed.has("ArrowLeft") ? 1 :
|
|
|
115
127
|
|
|
116
128
|
### What's new in 0.292.0 (contract 1.239.0)
|
|
117
129
|
|
|
118
|
-
**An Action a widget runs must be done
|
|
130
|
+
**An Action a widget runs must be done 500 ms after the press.** The time counts from when the press reaches the server, so waiting for a free sandbox and setting the run up spend from it too. A run started by `useAction()` (or a Button's Run action) that is still going then is stopped, and `run()` rejects with `ACTION_TIMEOUT` (504). Its outcome is unknown: open requests and connector calls are cut and no new work starts, but a write that had already finished stays, and a notification already sent can't be recalled. So an Action the app waits on must do its writes as one call (a bulk write) or be safe to repeat, and never tell the user it did nothing. Move slow or multi-step work to an Action triggered by a record the widget writes. Scheduled, record-triggered and Run now runs keep their own limits.
|
|
119
131
|
|
|
120
132
|
### What's new in 0.291.0 (contract 1.238.0)
|
|
121
133
|
|
|
@@ -123,7 +135,7 @@ const dx = (pressed.has("ArrowRight") ? 1 : 0) - (pressed.has("ArrowLeft") ? 1 :
|
|
|
123
135
|
|
|
124
136
|
### What's new in 0.290.0 (contract 1.238.0)
|
|
125
137
|
|
|
126
|
-
**New `useConnector(connectorRef)` hook — a widget can call one of the workspace's REST connectors and use the answer itself.** Bind a connector with a `{ type: "connectorRef" }` property and declare `connectors.call:*` in `requestedScopes`. `call(operation, { params, query, body })` names an operation the workspace listed for apps on that connector — never a method or a path — and resolves `{ status, content_type, body }` with the outside API's status and parsed body. The whole call has
|
|
138
|
+
**New `useConnector(connectorRef)` hook — a widget can call one of the workspace's REST connectors and use the answer itself.** Bind a connector with a `{ type: "connectorRef" }` property and declare `connectors.call:*` in `requestedScopes`. `call(operation, { params, query, body })` names an operation the workspace listed for apps on that connector — never a method or a path — and resolves `{ status, content_type, body }` with the outside API's status and parsed body. The whole call has 500 ms, token exchange included: a slower outside API is cut off and the call rejects with `UPSTREAM_TIMEOUT`. The credential is added on the server and never reaches the app. A new `connectors` host client (`createConnectorsClient` in `@colixsystems/actions-client`), the `connectorRef` property type, the `connectors.call:*` scope and a `ConnectorError`. Everything is additive.
|
|
127
139
|
|
|
128
140
|
### What's new in 0.289.0 (contract 1.237.0)
|
|
129
141
|
|
|
@@ -324,7 +336,7 @@ const { available, run, running, result, error } = useAction(props.actionId);
|
|
|
324
336
|
|
|
325
337
|
**Bind it with an `actionRef` property.** Declare `{ type: "actionRef" }` in your `propertySchema` and the Studio renders an Action picker that warns when the chosen Action lacks the app trigger. The value is a bare Action id, so Copy Workspace remaps it like `pageRef`.
|
|
326
338
|
|
|
327
|
-
When nothing is bound, or the host brokers no actions client, `available` is `false` and `run()` rejects `UNAVAILABLE`: render a visible "pick an action" state, never a blank box. A changed binding clears `result` and `error`, and a run that settles after the binding changed or the widget unmounted writes nothing. When runs overlap, `result` and `error` follow the newest one. Branch on `error.code`: `ACTION_NOT_APP_INVOKABLE` and `ACTION_NOT_FOUND` will not clear on a retry, `RATE_LIMITED` will, `INVALID_ACTION_INPUT` means the input was refused, `AUTH_REQUIRED`, `TOKEN_EXPIRED` and `TOKEN_INVALID` mean the app user must sign in, `ACTION_FAILED` means the Action ran and failed, and `ACTION_TIMEOUT` means it was still running
|
|
339
|
+
When nothing is bound, or the host brokers no actions client, `available` is `false` and `run()` rejects `UNAVAILABLE`: render a visible "pick an action" state, never a blank box. A changed binding clears `result` and `error`, and a run that settles after the binding changed or the widget unmounted writes nothing. When runs overlap, `result` and `error` follow the newest one. Branch on `error.code`: `ACTION_NOT_APP_INVOKABLE` and `ACTION_NOT_FOUND` will not clear on a retry, `RATE_LIMITED` will, `INVALID_ACTION_INPUT` means the input was refused, `AUTH_REQUIRED`, `TOKEN_EXPIRED` and `TOKEN_INVALID` mean the app user must sign in, `ACTION_FAILED` means the Action ran and failed, and `ACTION_TIMEOUT` means it was still running 500 ms after the press and was stopped, so its outcome is unknown: some of its writes may have happened. Never show an app user the raw message. A text answer from a bot is often markdown, so render it with `<RichText>`.
|
|
328
340
|
|
|
329
341
|
The linter rejects `useAction()` unless your manifest declares `actions.run:*` in `requestedScopes`.
|
|
330
342
|
|
package/dist/banner-view.js
CHANGED
|
@@ -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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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;
|
package/dist/board-view.js
CHANGED
|
@@ -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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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);
|
package/dist/button-view.js
CHANGED
|
@@ -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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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({
|
|
@@ -2288,7 +2291,7 @@ const HOOKS = [
|
|
|
2288
2291
|
"INVALID_ACTION_INPUT (400) — the input was refused; " +
|
|
2289
2292
|
"ACTION_NOT_APP_INVOKABLE (403) and ACTION_NOT_FOUND (404) will NOT " +
|
|
2290
2293
|
"clear on a retry, so hide the affordance; RATE_LIMITED (429) will; " +
|
|
2291
|
-
"ACTION_TIMEOUT (504) — the run was still going
|
|
2294
|
+
"ACTION_TIMEOUT (504) — the run was still going 500 ms after the press " +
|
|
2292
2295
|
"and was stopped, so its OUTCOME IS UNKNOWN: some of its writes may " +
|
|
2293
2296
|
"have happened. Never retry it blindly and never tell the user it did " +
|
|
2294
2297
|
"nothing; an Action a widget runs must do its writes as one call or be " +
|
|
@@ -2297,10 +2300,22 @@ const HOOKS = [
|
|
|
2297
2300
|
"ACTION_FAILED — the Action ran and failed, or no answer arrived. NEVER " +
|
|
2298
2301
|
"show an app user a raw error. A text answer from a bot is often " +
|
|
2299
2302
|
"MARKDOWN, so render it with <RichText value={result} />, not <Text>. " +
|
|
2303
|
+
"enqueue(input) QUEUES the run instead: it resolves as soon " +
|
|
2304
|
+
"as the server accepted it (the same refusals as run), and the script " +
|
|
2305
|
+
"runs later, away from the request, with the Action's normal limits " +
|
|
2306
|
+
"rather than the 500 ms an app run gets. Nothing comes back — no " +
|
|
2307
|
+
"respond() value, and running/result/error are untouched — so use it to " +
|
|
2308
|
+
"start work the widget needs no answer from (a batch, a sync, a long " +
|
|
2309
|
+
"send) and tell the user it has started, never that it is done. " +
|
|
2310
|
+
"It is also refused when the Action is switched off (ACTION_DISABLED) " +
|
|
2311
|
+
"or paused (ACTION_PAUSED), and with RATE_LIMITED when the workspace " +
|
|
2312
|
+
"already has 10 queued runs waiting. A queued run can run twice (a " +
|
|
2313
|
+
"restart mid-run starts it again), so its Action must be safe to repeat. " +
|
|
2300
2314
|
"Reads ctx.actions.",
|
|
2301
2315
|
returnShape: {
|
|
2302
2316
|
available: "boolean // false when no Action is bound, the host brokers none, or the server says a run would not reach the script",
|
|
2303
2317
|
run: "(input) => Promise<unknown> // input is optional; resolves with the Action's respond() value, or null; rejects with ActionError",
|
|
2318
|
+
enqueue: "(input) => Promise<void> // input is optional; resolves once the run is queued, returns nothing; rejects with ActionError (run's codes plus ACTION_DISABLED, ACTION_PAUSED)",
|
|
2304
2319
|
running: "boolean // true while any run is in flight",
|
|
2305
2320
|
result: "unknown // the last successful run's result; null before the first run",
|
|
2306
2321
|
error: "ActionError | null",
|
|
@@ -2323,7 +2338,7 @@ const HOOKS = [
|
|
|
2323
2338
|
"only where the operation takes one. call resolves with { status, " +
|
|
2324
2339
|
"content_type, body } — the outside API's status (a non-2xx answer " +
|
|
2325
2340
|
"still resolves: branch on status) and its parsed JSON or text body. " +
|
|
2326
|
-
"The whole call must finish within
|
|
2341
|
+
"The whole call must finish within 500 ms, token exchange included: a " +
|
|
2327
2342
|
"slower outside API is cut off and the call rejects with UPSTREAM_TIMEOUT. " +
|
|
2328
2343
|
"May run on mount for a read operation; an operation that changes data " +
|
|
2329
2344
|
"belongs in an event handler. `connectorRef` is a connector id an " +
|
|
@@ -3831,7 +3846,7 @@ const PRIMITIVES = [
|
|
|
3831
3846
|
{
|
|
3832
3847
|
name: "Tabs",
|
|
3833
3848
|
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.',
|
|
3849
|
+
'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
3850
|
rnComponent: null,
|
|
3836
3851
|
docsUrl: null,
|
|
3837
3852
|
},
|
|
@@ -4416,14 +4431,15 @@ const WIDGET_CONTEXT_SHAPE = {
|
|
|
4416
4431
|
actions: {
|
|
4417
4432
|
description:
|
|
4418
4433
|
"sc-13843 — injected @colixsystems/actions-client instance. " +
|
|
4419
|
-
"{ run(actionId, input?) -> Promise<{ ok, result }>,
|
|
4434
|
+
"{ run(actionId, input?) -> Promise<{ ok, result }>, enqueue(actionId, " +
|
|
4435
|
+
"input?) -> Promise<{ queued: true }>, status(actionId) -> " +
|
|
4420
4436
|
"Promise<{ available, reason }> }. Backs useAction(). " +
|
|
4421
4437
|
"Runs one Action as the signed-in caller; the server refuses an Action " +
|
|
4422
4438
|
"without the app trigger. Errors carry the server's `code` and `status`. " +
|
|
4423
4439
|
"Absent on a host that brokers no actions client, where useAction() " +
|
|
4424
4440
|
"degrades to available: false rather than throwing.",
|
|
4425
4441
|
required: false,
|
|
4426
|
-
fields: { run: "function", status: "function" },
|
|
4442
|
+
fields: { run: "function", enqueue: "function", status: "function" },
|
|
4427
4443
|
},
|
|
4428
4444
|
connectors: {
|
|
4429
4445
|
description:
|
|
@@ -6892,7 +6908,13 @@ const CONTRACT = deepFreeze({
|
|
|
6892
6908
|
// on web, expo-key-event on native).
|
|
6893
6909
|
// 1.244.0: additive (sc-15915) — `fixedScopes`, the requestedScopes entries
|
|
6894
6910
|
// whose target the scope fixes; the publish gate accepts exactly these.
|
|
6895
|
-
|
|
6911
|
+
// 1.245.0: additive (sc-15920) — a Tabs item with `value` and no `key` is
|
|
6912
|
+
// keyed by its `value`; a host may set `ctx.strictProps` so a component
|
|
6913
|
+
// throws on a prop it cannot render without (the widget check's render).
|
|
6914
|
+
// 1.246.0: additive (sc-15876) — `useAction()` gains `enqueue(input)`, which
|
|
6915
|
+
// queues the run and resolves at once; the script runs with the Action's
|
|
6916
|
+
// normal limits and returns nothing to the widget.
|
|
6917
|
+
version: "1.246.0",
|
|
6896
6918
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6897
6919
|
hooks: HOOKS,
|
|
6898
6920
|
primitives: PRIMITIVES,
|
|
@@ -7380,6 +7402,10 @@ const APPEARANCE_PREFERENCES = Object.freeze(["light", "dark", "system"]);
|
|
|
7380
7402
|
|
|
7381
7403
|
module.exports = {
|
|
7382
7404
|
CONTRACT,
|
|
7405
|
+
COMPONENT_PROPS,
|
|
7406
|
+
COMPONENT_PROPS_ERROR_PREFIX,
|
|
7407
|
+
componentPropsError,
|
|
7408
|
+
tabItemKey,
|
|
7383
7409
|
APPEARANCE_PREFERENCES,
|
|
7384
7410
|
clampSpacingScale,
|
|
7385
7411
|
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({
|
|
@@ -2284,7 +2286,7 @@ const HOOKS = [
|
|
|
2284
2286
|
"INVALID_ACTION_INPUT (400) — the input was refused; " +
|
|
2285
2287
|
"ACTION_NOT_APP_INVOKABLE (403) and ACTION_NOT_FOUND (404) will NOT " +
|
|
2286
2288
|
"clear on a retry, so hide the affordance; RATE_LIMITED (429) will; " +
|
|
2287
|
-
"ACTION_TIMEOUT (504) — the run was still going
|
|
2289
|
+
"ACTION_TIMEOUT (504) — the run was still going 500 ms after the press " +
|
|
2288
2290
|
"and was stopped, so its OUTCOME IS UNKNOWN: some of its writes may " +
|
|
2289
2291
|
"have happened. Never retry it blindly and never tell the user it did " +
|
|
2290
2292
|
"nothing; an Action a widget runs must do its writes as one call or be " +
|
|
@@ -2293,10 +2295,22 @@ const HOOKS = [
|
|
|
2293
2295
|
"ACTION_FAILED — the Action ran and failed, or no answer arrived. NEVER " +
|
|
2294
2296
|
"show an app user a raw error. A text answer from a bot is often " +
|
|
2295
2297
|
"MARKDOWN, so render it with <RichText value={result} />, not <Text>. " +
|
|
2298
|
+
"enqueue(input) QUEUES the run instead: it resolves as soon " +
|
|
2299
|
+
"as the server accepted it (the same refusals as run), and the script " +
|
|
2300
|
+
"runs later, away from the request, with the Action's normal limits " +
|
|
2301
|
+
"rather than the 500 ms an app run gets. Nothing comes back — no " +
|
|
2302
|
+
"respond() value, and running/result/error are untouched — so use it to " +
|
|
2303
|
+
"start work the widget needs no answer from (a batch, a sync, a long " +
|
|
2304
|
+
"send) and tell the user it has started, never that it is done. " +
|
|
2305
|
+
"It is also refused when the Action is switched off (ACTION_DISABLED) " +
|
|
2306
|
+
"or paused (ACTION_PAUSED), and with RATE_LIMITED when the workspace " +
|
|
2307
|
+
"already has 10 queued runs waiting. A queued run can run twice (a " +
|
|
2308
|
+
"restart mid-run starts it again), so its Action must be safe to repeat. " +
|
|
2296
2309
|
"Reads ctx.actions.",
|
|
2297
2310
|
returnShape: {
|
|
2298
2311
|
available: "boolean // false when no Action is bound, the host brokers none, or the server says a run would not reach the script",
|
|
2299
2312
|
run: "(input) => Promise<unknown> // input is optional; resolves with the Action's respond() value, or null; rejects with ActionError",
|
|
2313
|
+
enqueue: "(input) => Promise<void> // input is optional; resolves once the run is queued, returns nothing; rejects with ActionError (run's codes plus ACTION_DISABLED, ACTION_PAUSED)",
|
|
2300
2314
|
running: "boolean // true while any run is in flight",
|
|
2301
2315
|
result: "unknown // the last successful run's result; null before the first run",
|
|
2302
2316
|
error: "ActionError | null",
|
|
@@ -2319,7 +2333,7 @@ const HOOKS = [
|
|
|
2319
2333
|
"only where the operation takes one. call resolves with { status, " +
|
|
2320
2334
|
"content_type, body } — the outside API's status (a non-2xx answer " +
|
|
2321
2335
|
"still resolves: branch on status) and its parsed JSON or text body. " +
|
|
2322
|
-
"The whole call must finish within
|
|
2336
|
+
"The whole call must finish within 500 ms, token exchange included: a " +
|
|
2323
2337
|
"slower outside API is cut off and the call rejects with UPSTREAM_TIMEOUT. " +
|
|
2324
2338
|
"May run on mount for a read operation; an operation that changes data " +
|
|
2325
2339
|
"belongs in an event handler. `connectorRef` is a connector id an " +
|
|
@@ -3827,7 +3841,7 @@ const PRIMITIVES = [
|
|
|
3827
3841
|
{
|
|
3828
3842
|
name: "Tabs",
|
|
3829
3843
|
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.',
|
|
3844
|
+
'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
3845
|
rnComponent: null,
|
|
3832
3846
|
docsUrl: null,
|
|
3833
3847
|
},
|
|
@@ -4412,14 +4426,15 @@ const WIDGET_CONTEXT_SHAPE = {
|
|
|
4412
4426
|
actions: {
|
|
4413
4427
|
description:
|
|
4414
4428
|
"sc-13843 — injected @colixsystems/actions-client instance. " +
|
|
4415
|
-
"{ run(actionId, input?) -> Promise<{ ok, result }>,
|
|
4429
|
+
"{ run(actionId, input?) -> Promise<{ ok, result }>, enqueue(actionId, " +
|
|
4430
|
+
"input?) -> Promise<{ queued: true }>, status(actionId) -> " +
|
|
4416
4431
|
"Promise<{ available, reason }> }. Backs useAction(). " +
|
|
4417
4432
|
"Runs one Action as the signed-in caller; the server refuses an Action " +
|
|
4418
4433
|
"without the app trigger. Errors carry the server's `code` and `status`. " +
|
|
4419
4434
|
"Absent on a host that brokers no actions client, where useAction() " +
|
|
4420
4435
|
"degrades to available: false rather than throwing.",
|
|
4421
4436
|
required: false,
|
|
4422
|
-
fields: { run: "function", status: "function" },
|
|
4437
|
+
fields: { run: "function", enqueue: "function", status: "function" },
|
|
4423
4438
|
},
|
|
4424
4439
|
connectors: {
|
|
4425
4440
|
description:
|
|
@@ -6888,7 +6903,13 @@ const CONTRACT = deepFreeze({
|
|
|
6888
6903
|
// on web, expo-key-event on native).
|
|
6889
6904
|
// 1.244.0: additive (sc-15915) — `fixedScopes`, the requestedScopes entries
|
|
6890
6905
|
// whose target the scope fixes; the publish gate accepts exactly these.
|
|
6891
|
-
|
|
6906
|
+
// 1.245.0: additive (sc-15920) — a Tabs item with `value` and no `key` is
|
|
6907
|
+
// keyed by its `value`; a host may set `ctx.strictProps` so a component
|
|
6908
|
+
// throws on a prop it cannot render without (the widget check's render).
|
|
6909
|
+
// 1.246.0: additive (sc-15876) — `useAction()` gains `enqueue(input)`, which
|
|
6910
|
+
// queues the run and resolves at once; the script runs with the Action's
|
|
6911
|
+
// normal limits and returns nothing to the widget.
|
|
6912
|
+
version: "1.246.0",
|
|
6892
6913
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6893
6914
|
hooks: HOOKS,
|
|
6894
6915
|
primitives: PRIMITIVES,
|
|
@@ -7376,6 +7397,10 @@ const APPEARANCE_PREFERENCES = Object.freeze(["light", "dark", "system"]);
|
|
|
7376
7397
|
|
|
7377
7398
|
export {
|
|
7378
7399
|
CONTRACT,
|
|
7400
|
+
COMPONENT_PROPS,
|
|
7401
|
+
COMPONENT_PROPS_ERROR_PREFIX,
|
|
7402
|
+
componentPropsError,
|
|
7403
|
+
tabItemKey,
|
|
7379
7404
|
APPEARANCE_PREFERENCES,
|
|
7380
7405
|
clampSpacingScale,
|
|
7381
7406
|
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(
|
|
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
|
|
@@ -3993,9 +4008,16 @@ function toActionError(err) {
|
|
|
3993
4008
|
|
|
3994
4009
|
/**
|
|
3995
4010
|
* sc-13843 — run one of the workspace's Actions and read what it returned.
|
|
3996
|
-
* Returns `{ available, run, running, result, error }`.
|
|
4011
|
+
* Returns `{ available, run, enqueue, running, result, error }`.
|
|
3997
4012
|
*
|
|
3998
4013
|
* run(input?) → Promise<result> the Action's `respond()` value, or null
|
|
4014
|
+
* enqueue(input?) → Promise<void> resolves once the run is queued
|
|
4015
|
+
*
|
|
4016
|
+
* sc-15876 — `enqueue` starts the run away from the request: the server
|
|
4017
|
+
* answers as soon as it accepted it and the script runs later with the
|
|
4018
|
+
* Action's normal limits, not the app-run deadline. Nothing comes back, so
|
|
4019
|
+
* `running`, `result` and `error` are untouched. A host whose client has no
|
|
4020
|
+
* `enqueue` rejects UNAVAILABLE.
|
|
3999
4021
|
*
|
|
4000
4022
|
* IMPERATIVE — it never runs on mount or render; call `run` from an event
|
|
4001
4023
|
* handler. An Action can write data and send messages, so running it because
|
|
@@ -4108,10 +4130,25 @@ export function useAction(actionRef) {
|
|
|
4108
4130
|
}
|
|
4109
4131
|
}, []);
|
|
4110
4132
|
|
|
4133
|
+
// sc-15876: queues the run; no answer comes back, so no state changes.
|
|
4134
|
+
const enqueue = useCallback(async (input) => {
|
|
4135
|
+
const client = clientRef.current;
|
|
4136
|
+
const actionId = actionIdRef.current;
|
|
4137
|
+
if (!client || !actionId || typeof client.enqueue !== "function") {
|
|
4138
|
+
throw new ActionError("UNAVAILABLE", "No action is available for this host");
|
|
4139
|
+
}
|
|
4140
|
+
try {
|
|
4141
|
+
await client.enqueue(actionId, input);
|
|
4142
|
+
} catch (err) {
|
|
4143
|
+
throw toActionError(err);
|
|
4144
|
+
}
|
|
4145
|
+
}, []);
|
|
4146
|
+
|
|
4111
4147
|
const current = outcome.generation === generationRef.current;
|
|
4112
4148
|
return {
|
|
4113
4149
|
available,
|
|
4114
4150
|
run,
|
|
4151
|
+
enqueue,
|
|
4115
4152
|
running: current && outcome.pending > 0,
|
|
4116
4153
|
result: current ? outcome.result : null,
|
|
4117
4154
|
error: current ? outcome.error : null,
|
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
|
|
@@ -909,6 +915,8 @@ export interface WidgetContext<TProps = unknown> {
|
|
|
909
915
|
run(actionId: string, input?: Record<string, unknown> | null): Promise<{ ok: boolean; result: unknown }>;
|
|
910
916
|
/** sc-14224 — whether a run would reach the script; optional on older hosts. */
|
|
911
917
|
status?(actionId: string): Promise<{ available: boolean; reason: string | null }>;
|
|
918
|
+
/** sc-15876 — queues a run; optional on older hosts. */
|
|
919
|
+
enqueue?(actionId: string, input?: Record<string, unknown> | null): Promise<{ queued: true }>;
|
|
912
920
|
};
|
|
913
921
|
/** sc-15659 — injected @colixsystems/actions-client backing useConnector(). */
|
|
914
922
|
connectors?: {
|
|
@@ -2135,6 +2143,12 @@ export interface ActionApi {
|
|
|
2135
2143
|
* value the Action passed to `respond()`, or null; rejects with ActionError.
|
|
2136
2144
|
*/
|
|
2137
2145
|
run(input?: Record<string, unknown> | null): Promise<unknown>;
|
|
2146
|
+
/**
|
|
2147
|
+
* Imperative — queues the run and resolves once the server accepted it. The
|
|
2148
|
+
* script runs later with the Action's normal limits and returns nothing;
|
|
2149
|
+
* `running`, `result` and `error` are untouched. Rejects with ActionError.
|
|
2150
|
+
*/
|
|
2151
|
+
enqueue(input?: Record<string, unknown> | null): Promise<void>;
|
|
2138
2152
|
/** True while any run is in flight. */
|
|
2139
2153
|
running: boolean;
|
|
2140
2154
|
/** The last successful run's result; cleared when the binding changes. */
|
|
@@ -3550,7 +3564,7 @@ export class AgentError extends Error {
|
|
|
3550
3564
|
}
|
|
3551
3565
|
|
|
3552
3566
|
/**
|
|
3553
|
-
* sc-13843 — structured error thrown by `useAction().run`. Branch on `code`:
|
|
3567
|
+
* sc-13843 — structured error thrown by `useAction().run` and `.enqueue`. Branch on `code`:
|
|
3554
3568
|
* `ACTION_NOT_APP_INVOKABLE` and `ACTION_NOT_FOUND` will not clear on a retry,
|
|
3555
3569
|
* `RATE_LIMITED` will. `AUTH_REQUIRED`, `TOKEN_EXPIRED` and `TOKEN_INVALID`
|
|
3556
3570
|
* mean the app user must sign in. Never show an app user the raw message.
|
|
@@ -5312,7 +5326,8 @@ export type TabStyle = "segmented" | "pill" | "underline";
|
|
|
5312
5326
|
* <Tabs items={[{ key: "open", label: "Open" }, { key: "done", label: "Done" }]} value={tab} onChange={setTab} />
|
|
5313
5327
|
*/
|
|
5314
5328
|
export const Tabs: (props: {
|
|
5315
|
-
|
|
5329
|
+
/** An item with `value` and no `key` is keyed by its `value`, like a Select option. */
|
|
5330
|
+
items: Array<{ key?: string; value?: string; label: ReactNode; icon?: string; disabled?: boolean; testID?: string }>;
|
|
5316
5331
|
value?: string;
|
|
5317
5332
|
onChange?: (key: string) => void;
|
|
5318
5333
|
/** Overrides the theme's tab style for this strip. */
|
package/dist/radio-group-view.js
CHANGED
|
@@ -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,
|
package/dist/select-view.js
CHANGED
|
@@ -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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
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
|
|
117
|
+
key,
|
|
114
118
|
onPress: () => {
|
|
115
|
-
if (!active && typeof onChange === "function") onChange(
|
|
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.
|
package/dist/tooltip-view.js
CHANGED
|
@@ -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
|
-
|
|
74
|
-
|
|
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.
|
|
3
|
+
"version": "0.299.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({
|
|
@@ -2284,7 +2286,7 @@ const HOOKS = [
|
|
|
2284
2286
|
"INVALID_ACTION_INPUT (400) — the input was refused; " +
|
|
2285
2287
|
"ACTION_NOT_APP_INVOKABLE (403) and ACTION_NOT_FOUND (404) will NOT " +
|
|
2286
2288
|
"clear on a retry, so hide the affordance; RATE_LIMITED (429) will; " +
|
|
2287
|
-
"ACTION_TIMEOUT (504) — the run was still going
|
|
2289
|
+
"ACTION_TIMEOUT (504) — the run was still going 500 ms after the press " +
|
|
2288
2290
|
"and was stopped, so its OUTCOME IS UNKNOWN: some of its writes may " +
|
|
2289
2291
|
"have happened. Never retry it blindly and never tell the user it did " +
|
|
2290
2292
|
"nothing; an Action a widget runs must do its writes as one call or be " +
|
|
@@ -2293,10 +2295,22 @@ const HOOKS = [
|
|
|
2293
2295
|
"ACTION_FAILED — the Action ran and failed, or no answer arrived. NEVER " +
|
|
2294
2296
|
"show an app user a raw error. A text answer from a bot is often " +
|
|
2295
2297
|
"MARKDOWN, so render it with <RichText value={result} />, not <Text>. " +
|
|
2298
|
+
"enqueue(input) QUEUES the run instead: it resolves as soon " +
|
|
2299
|
+
"as the server accepted it (the same refusals as run), and the script " +
|
|
2300
|
+
"runs later, away from the request, with the Action's normal limits " +
|
|
2301
|
+
"rather than the 500 ms an app run gets. Nothing comes back — no " +
|
|
2302
|
+
"respond() value, and running/result/error are untouched — so use it to " +
|
|
2303
|
+
"start work the widget needs no answer from (a batch, a sync, a long " +
|
|
2304
|
+
"send) and tell the user it has started, never that it is done. " +
|
|
2305
|
+
"It is also refused when the Action is switched off (ACTION_DISABLED) " +
|
|
2306
|
+
"or paused (ACTION_PAUSED), and with RATE_LIMITED when the workspace " +
|
|
2307
|
+
"already has 10 queued runs waiting. A queued run can run twice (a " +
|
|
2308
|
+
"restart mid-run starts it again), so its Action must be safe to repeat. " +
|
|
2296
2309
|
"Reads ctx.actions.",
|
|
2297
2310
|
returnShape: {
|
|
2298
2311
|
available: "boolean // false when no Action is bound, the host brokers none, or the server says a run would not reach the script",
|
|
2299
2312
|
run: "(input) => Promise<unknown> // input is optional; resolves with the Action's respond() value, or null; rejects with ActionError",
|
|
2313
|
+
enqueue: "(input) => Promise<void> // input is optional; resolves once the run is queued, returns nothing; rejects with ActionError (run's codes plus ACTION_DISABLED, ACTION_PAUSED)",
|
|
2300
2314
|
running: "boolean // true while any run is in flight",
|
|
2301
2315
|
result: "unknown // the last successful run's result; null before the first run",
|
|
2302
2316
|
error: "ActionError | null",
|
|
@@ -2319,7 +2333,7 @@ const HOOKS = [
|
|
|
2319
2333
|
"only where the operation takes one. call resolves with { status, " +
|
|
2320
2334
|
"content_type, body } — the outside API's status (a non-2xx answer " +
|
|
2321
2335
|
"still resolves: branch on status) and its parsed JSON or text body. " +
|
|
2322
|
-
"The whole call must finish within
|
|
2336
|
+
"The whole call must finish within 500 ms, token exchange included: a " +
|
|
2323
2337
|
"slower outside API is cut off and the call rejects with UPSTREAM_TIMEOUT. " +
|
|
2324
2338
|
"May run on mount for a read operation; an operation that changes data " +
|
|
2325
2339
|
"belongs in an event handler. `connectorRef` is a connector id an " +
|
|
@@ -3827,7 +3841,7 @@ const PRIMITIVES = [
|
|
|
3827
3841
|
{
|
|
3828
3842
|
name: "Tabs",
|
|
3829
3843
|
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.',
|
|
3844
|
+
'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
3845
|
rnComponent: null,
|
|
3832
3846
|
docsUrl: null,
|
|
3833
3847
|
},
|
|
@@ -4412,14 +4426,15 @@ const WIDGET_CONTEXT_SHAPE = {
|
|
|
4412
4426
|
actions: {
|
|
4413
4427
|
description:
|
|
4414
4428
|
"sc-13843 — injected @colixsystems/actions-client instance. " +
|
|
4415
|
-
"{ run(actionId, input?) -> Promise<{ ok, result }>,
|
|
4429
|
+
"{ run(actionId, input?) -> Promise<{ ok, result }>, enqueue(actionId, " +
|
|
4430
|
+
"input?) -> Promise<{ queued: true }>, status(actionId) -> " +
|
|
4416
4431
|
"Promise<{ available, reason }> }. Backs useAction(). " +
|
|
4417
4432
|
"Runs one Action as the signed-in caller; the server refuses an Action " +
|
|
4418
4433
|
"without the app trigger. Errors carry the server's `code` and `status`. " +
|
|
4419
4434
|
"Absent on a host that brokers no actions client, where useAction() " +
|
|
4420
4435
|
"degrades to available: false rather than throwing.",
|
|
4421
4436
|
required: false,
|
|
4422
|
-
fields: { run: "function", status: "function" },
|
|
4437
|
+
fields: { run: "function", enqueue: "function", status: "function" },
|
|
4423
4438
|
},
|
|
4424
4439
|
connectors: {
|
|
4425
4440
|
description:
|
|
@@ -6888,7 +6903,13 @@ const CONTRACT = deepFreeze({
|
|
|
6888
6903
|
// on web, expo-key-event on native).
|
|
6889
6904
|
// 1.244.0: additive (sc-15915) — `fixedScopes`, the requestedScopes entries
|
|
6890
6905
|
// whose target the scope fixes; the publish gate accepts exactly these.
|
|
6891
|
-
|
|
6906
|
+
// 1.245.0: additive (sc-15920) — a Tabs item with `value` and no `key` is
|
|
6907
|
+
// keyed by its `value`; a host may set `ctx.strictProps` so a component
|
|
6908
|
+
// throws on a prop it cannot render without (the widget check's render).
|
|
6909
|
+
// 1.246.0: additive (sc-15876) — `useAction()` gains `enqueue(input)`, which
|
|
6910
|
+
// queues the run and resolves at once; the script runs with the Action's
|
|
6911
|
+
// normal limits and returns nothing to the widget.
|
|
6912
|
+
version: "1.246.0",
|
|
6892
6913
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6893
6914
|
hooks: HOOKS,
|
|
6894
6915
|
primitives: PRIMITIVES,
|
|
@@ -7376,6 +7397,10 @@ const APPEARANCE_PREFERENCES = Object.freeze(["light", "dark", "system"]);
|
|
|
7376
7397
|
|
|
7377
7398
|
export {
|
|
7378
7399
|
CONTRACT,
|
|
7400
|
+
COMPONENT_PROPS,
|
|
7401
|
+
COMPONENT_PROPS_ERROR_PREFIX,
|
|
7402
|
+
componentPropsError,
|
|
7403
|
+
tabItemKey,
|
|
7379
7404
|
APPEARANCE_PREFERENCES,
|
|
7380
7405
|
clampSpacingScale,
|
|
7381
7406
|
scaleSpacing,
|