@colixsystems/widget-sdk 0.329.1 → 0.330.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
@@ -91,7 +91,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
91
91
 
92
92
  ## Status
93
93
 
94
- `v0.329.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**.
94
+ `v0.330.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**.
95
+
96
+ ### What's new in 0.330.0 (contract 1.269.0)
97
+
98
+ **A `<ListRow>` takes a `ref`, and `useCanWrite` waits for its answer.** The ref reaches the row's press target (the row itself when it has no `onPress`), so a list-and-detail widget can put focus back on the row a person opened when they go back. `useCanWrite` now reports `loading: true` until the answer for the bound table (and row) has arrived: a widget that binds its table after mount, or whose viewer signs in, no longer sees `canWrite: false, loading: false` for a render and flashes its "not allowed" state. Additive.
95
99
 
96
100
  ### What's new in 0.329.1 (contract 1.268.0)
97
101
 
package/dist/contract.cjs CHANGED
@@ -3083,7 +3083,8 @@ const HOOKS = [
3083
3083
  "NOT distinguish 'not signed in' from 'signed in but forbidden' (both resolve canWrite:false); pair it with useUser() when the UI needs to " +
3084
3084
  "tell those apart. For a LIST, gate each row's edit/delete on useDatastoreQuery's `includeCapabilities` answer instead — a " +
3085
3085
  "{ recordId } check per row is one request per row, and the table-level answer only says whether they may CREATE. myPermissions is a newer client method: a host that has not injected it is NOT a hard error — this hook collapses to " +
3086
- "{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy.",
3086
+ "{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy. " +
3087
+ "With a table bound, loading stays true until the answer for that table (and row) has arrived, so canWrite:false with loading:false is always an answer.",
3087
3088
  returnShape: {
3088
3089
  canWrite: "boolean",
3089
3090
  loading: "boolean",
@@ -3766,7 +3767,7 @@ const PRIMITIVES = [
3766
3767
  {
3767
3768
  name: "ListRow",
3768
3769
  description:
3769
- 'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
3770
+ 'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, `ref` (the row\'s press target, so focus can return to the row a person opened), plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
3770
3771
  rnComponent: null,
3771
3772
  docsUrl: null,
3772
3773
  },
@@ -7060,7 +7061,10 @@ const CONTRACT = deepFreeze({
7060
7061
  // email? })` opens the app's sign-in screen over the page on both hosts,
7061
7062
  // and an event declared for the page to bind to Sign in is the
7062
7063
  // `sign-in-event` error.
7063
- version: "1.268.0",
7064
+ // 1.269.0: additive (sc-17385) — `<ListRow ref>` reaches the row's press
7065
+ // target, so a widget can return focus to it; useCanWrite stays
7066
+ // loading until it has the answer for the bound table.
7067
+ version: "1.269.0",
7064
7068
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7065
7069
  hooks: HOOKS,
7066
7070
  primitives: PRIMITIVES,
package/dist/contract.js CHANGED
@@ -3078,7 +3078,8 @@ const HOOKS = [
3078
3078
  "NOT distinguish 'not signed in' from 'signed in but forbidden' (both resolve canWrite:false); pair it with useUser() when the UI needs to " +
3079
3079
  "tell those apart. For a LIST, gate each row's edit/delete on useDatastoreQuery's `includeCapabilities` answer instead — a " +
3080
3080
  "{ recordId } check per row is one request per row, and the table-level answer only says whether they may CREATE. myPermissions is a newer client method: a host that has not injected it is NOT a hard error — this hook collapses to " +
3081
- "{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy.",
3081
+ "{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy. " +
3082
+ "With a table bound, loading stays true until the answer for that table (and row) has arrived, so canWrite:false with loading:false is always an answer.",
3082
3083
  returnShape: {
3083
3084
  canWrite: "boolean",
3084
3085
  loading: "boolean",
@@ -3761,7 +3762,7 @@ const PRIMITIVES = [
3761
3762
  {
3762
3763
  name: "ListRow",
3763
3764
  description:
3764
- 'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
3765
+ 'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, `ref` (the row\'s press target, so focus can return to the row a person opened), plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
3765
3766
  rnComponent: null,
3766
3767
  docsUrl: null,
3767
3768
  },
@@ -7055,7 +7056,10 @@ const CONTRACT = deepFreeze({
7055
7056
  // email? })` opens the app's sign-in screen over the page on both hosts,
7056
7057
  // and an event declared for the page to bind to Sign in is the
7057
7058
  // `sign-in-event` error.
7058
- version: "1.268.0",
7059
+ // 1.269.0: additive (sc-17385) — `<ListRow ref>` reaches the row's press
7060
+ // target, so a widget can return focus to it; useCanWrite stays
7061
+ // loading until it has the answer for the bound table.
7062
+ version: "1.269.0",
7059
7063
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7060
7064
  hooks: HOOKS,
7061
7065
  primitives: PRIMITIVES,
package/dist/hooks.js CHANGED
@@ -4701,6 +4701,11 @@ export function useCanWrite(tableId, options) {
4701
4701
  const [canWrite, setCanWrite] = useState(false);
4702
4702
  const [loading, setLoading] = useState(ready);
4703
4703
  const [error, setError] = useState(null);
4704
+ // sc-17385 — the table (and row) the last answer was for. Until it matches
4705
+ // the current one the hook is still loading, so a widget never reads a
4706
+ // render-long canWrite:false before the first request has even started.
4707
+ const [answeredFor, setAnsweredFor] = useState(null);
4708
+ const askedFor = ready ? `${tableId}|${recordId || ""}` : null;
4704
4709
 
4705
4710
  // Same ref discipline as useDatastoreSchema / useRecordPermissions — `ctx`
4706
4711
  // is a fresh object identity on every host render, so we hold the live
@@ -4724,6 +4729,7 @@ export function useCanWrite(tableId, options) {
4724
4729
  setCanWrite(false);
4725
4730
  return;
4726
4731
  }
4732
+ const asked = `${t}|${recordIdRef.current || ""}`;
4727
4733
  setLoading(true);
4728
4734
  setError(null);
4729
4735
  // A permission must fail CLOSED: never carry the previous table's or row's
@@ -4738,6 +4744,7 @@ export function useCanWrite(tableId, options) {
4738
4744
  ? Boolean(result && result.record && result.record.can_write)
4739
4745
  : Boolean(result && result.can_create),
4740
4746
  );
4747
+ setAnsweredFor(asked);
4741
4748
  setLoading(false);
4742
4749
  } catch (err) {
4743
4750
  if (runRef.current !== myRun) return;
@@ -4746,6 +4753,7 @@ export function useCanWrite(tableId, options) {
4746
4753
  // A refusal IS the answer here, not a failure: an anonymous visitor on a
4747
4754
  // private table 404s by design. Surfacing it would banner every guest.
4748
4755
  setError(e.code === "NOT_FOUND" || e.code === "FORBIDDEN" ? null : e);
4756
+ setAnsweredFor(asked);
4749
4757
  setLoading(false);
4750
4758
  }
4751
4759
  }, []);
@@ -4763,7 +4771,13 @@ export function useCanWrite(tableId, options) {
4763
4771
  return _NOOP_CAN_WRITE_RESULT;
4764
4772
  }
4765
4773
 
4766
- return { canWrite, loading, error, refetch };
4774
+ const answered = answeredFor === askedFor;
4775
+ return {
4776
+ canWrite: answered && canWrite,
4777
+ loading: loading || !answered,
4778
+ error: answered ? error : null,
4779
+ refetch,
4780
+ };
4767
4781
  }
4768
4782
 
4769
4783
  /**
package/dist/index.d.ts CHANGED
@@ -4214,7 +4214,8 @@ export interface CanWriteResult {
4214
4214
  * "signed in but forbidden". Falsy `tableId`, or a host that has not
4215
4215
  * injected `ctx.datastore.myPermissions`, collapses to `{ canWrite: false,
4216
4216
  * loading: false, error: null, refetch: async () => undefined }` rather than
4217
- * throwing.
4217
+ * throwing. With a table bound, `loading` stays true until the answer for
4218
+ * that table (and row) has arrived.
4218
4219
  */
4219
4220
  export function useCanWrite(
4220
4221
  tableId: string | null | undefined,
@@ -4567,6 +4568,8 @@ export const ListRow: (props: ListRowTokens & {
4567
4568
  disabled?: boolean;
4568
4569
  /** Defaults to true; pass false on the last row. */
4569
4570
  divider?: boolean;
4571
+ /** The row's press target (the row itself when it is not pressable), so focus can return to it. */
4572
+ ref?: { current: any } | ((node: any) => void);
4570
4573
  accessibilityLabel?: string;
4571
4574
  style?: any;
4572
4575
  testID?: string;
package/dist/list-view.js CHANGED
@@ -192,6 +192,7 @@ export function makeList(rn) {
192
192
  Pressable,
193
193
  {
194
194
  ...pressProps(props),
195
+ ref: props.ref,
195
196
  onPressIn: () => row.setPressed(true),
196
197
  onPressOut: () => row.setPressed(false),
197
198
  style: [pressRegionStyle(style, row.theme.spacing), disabled ? { opacity: 0.5 } : null],
@@ -215,6 +216,7 @@ export function makeList(rn) {
215
216
  View,
216
217
  {
217
218
  style: [rowStyle, row.pressed ? pressedFill : null, style],
219
+ ref: row.splitPress ? undefined : props.ref,
218
220
  testID,
219
221
  accessibilityLabel: row.splitPress ? undefined : accessibilityLabel,
220
222
  accessible: accessibilityLabel && !row.splitPress ? true : undefined,
@@ -226,6 +228,7 @@ export function makeList(rn) {
226
228
  Pressable,
227
229
  {
228
230
  ...pressProps(props),
231
+ ref: props.ref,
229
232
  testID,
230
233
  style: ({ pressed }) => [
231
234
  rowStyle,
@@ -258,6 +261,7 @@ export function makeList(rn) {
258
261
  Card,
259
262
  {
260
263
  testID,
264
+ ref: row.splitPress ? undefined : props.ref,
261
265
  accessibilityLabel: row.splitPress ? undefined : accessibilityLabel,
262
266
  accessible: accessibilityLabel && !row.splitPress ? true : undefined,
263
267
  containerStyle: [frame, mark, row.pressed ? pressedFill : null, style],
@@ -271,6 +275,7 @@ export function makeList(rn) {
271
275
  as: Pressable,
272
276
  fillInGradient: true,
273
277
  ...pressProps(props),
278
+ ref: props.ref,
274
279
  testID,
275
280
  containerStyle: ({ pressed }) => [
276
281
  frame,
@@ -306,6 +311,7 @@ export function makeList(rn) {
306
311
  }
307
312
  List.displayName = "List";
308
313
 
314
+ // React 19 hands `ref` over as a prop; it reaches the row's press target.
309
315
  function ListRow(props) {
310
316
  const [theme, tokens, list] = useRowTokens(props);
311
317
  const [pressed, setPressed] = React.useState(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.329.1",
3
+ "version": "0.330.0",
4
4
  "description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/contract.js CHANGED
@@ -3078,7 +3078,8 @@ const HOOKS = [
3078
3078
  "NOT distinguish 'not signed in' from 'signed in but forbidden' (both resolve canWrite:false); pair it with useUser() when the UI needs to " +
3079
3079
  "tell those apart. For a LIST, gate each row's edit/delete on useDatastoreQuery's `includeCapabilities` answer instead — a " +
3080
3080
  "{ recordId } check per row is one request per row, and the table-level answer only says whether they may CREATE. myPermissions is a newer client method: a host that has not injected it is NOT a hard error — this hook collapses to " +
3081
- "{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy.",
3081
+ "{ canWrite: false, loading: false, error: null, refetch: async () => undefined } rather than throwing. Same collapse when tableId is falsy. " +
3082
+ "With a table bound, loading stays true until the answer for that table (and row) has arrived, so canWrite:false with loading:false is always an answer.",
3082
3083
  returnShape: {
3083
3084
  canWrite: "boolean",
3084
3085
  loading: "boolean",
@@ -3761,7 +3762,7 @@ const PRIMITIVES = [
3761
3762
  {
3762
3763
  name: "ListRow",
3763
3764
  description:
3764
- 'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
3765
+ 'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. The default way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches. Use it rather than a row of your own from `View` + `Pressable`; when the request needs a row it cannot lay out (a chat bubble, a timeline entry on a rail), draw your own with the theme\'s spacing, surface and divider colours. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block: a single `View` child — your own row of cells — spans the full width between `leading` and `trailing`; anything else, such as several cells, sits in the row as given, which is the shape a table row takes under a `<ListHeader>`), `onPress` (makes it a button with a press state), `actions` (the row\'s OWN buttons, such as remove, move up or sign: drawn after `trailing` and, on a row with `onPress`, kept OUTSIDE its tap target so each stays a separate button the keyboard and a screen reader reach; never put a `Pressable` in `trailing` of a pressable row), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, `defaults`, `ref` (the row\'s press target, so focus can return to the row a person opened), plus the same per-row overrides `<List>` takes. Inside a `<List variant="card">` the row is drawn as one card. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
3765
3766
  rnComponent: null,
3766
3767
  docsUrl: null,
3767
3768
  },
@@ -7055,7 +7056,10 @@ const CONTRACT = deepFreeze({
7055
7056
  // email? })` opens the app's sign-in screen over the page on both hosts,
7056
7057
  // and an event declared for the page to bind to Sign in is the
7057
7058
  // `sign-in-event` error.
7058
- version: "1.268.0",
7059
+ // 1.269.0: additive (sc-17385) — `<ListRow ref>` reaches the row's press
7060
+ // target, so a widget can return focus to it; useCanWrite stays
7061
+ // loading until it has the answer for the bound table.
7062
+ version: "1.269.0",
7059
7063
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7060
7064
  hooks: HOOKS,
7061
7065
  primitives: PRIMITIVES,