@colixsystems/widget-sdk 0.329.0 → 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 +10 -2
- package/dist/contract.cjs +7 -3
- package/dist/contract.js +7 -3
- package/dist/grid-logic.js +3 -10
- package/dist/hooks.js +15 -1
- package/dist/index.d.ts +8 -3
- package/dist/list-view.js +6 -0
- package/package.json +1 -1
- package/src/contract.js +7 -3
package/README.md
CHANGED
|
@@ -91,7 +91,15 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
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.
|
|
99
|
+
|
|
100
|
+
### What's new in 0.329.1 (contract 1.268.0)
|
|
101
|
+
|
|
102
|
+
**A tile row given `maxColumns` still fits a phone.** `<Grid balance="tiles" maxColumns={4}>` used `maxColumns` as the count per line at every width, so four stat tiles sat side by side on a phone and their figures wrapped a word per line. `maxColumns` now only lowers the width-tier ceiling (4 wide, 3 medium, 2 narrow): the same grid is 4 a line wide and 2 + 2 on a phone, on the web and in the exported app.
|
|
95
103
|
|
|
96
104
|
### What's new in 0.329.0 (contract 1.268.0)
|
|
97
105
|
|
|
@@ -3636,7 +3644,7 @@ import { defineWidget, validateManifest, useDatastoreQuery, Text, View } from "@
|
|
|
3636
3644
|
- `List`, `ListRow`, `ListHeader`, `EmptyState` — the themed list building blocks. `<ListRow title subtitle leading trailing onPress selected divider>` draws one record row from the theme's `list` scope (padding, height, gap, radius, background, divider); `<List>` spaces its rows and hands overrides down; `<ListHeader>` labels a table's columns on the rows' own inset; `<EmptyState icon title message>` is the "nothing here" panel. Use them by default for record rows and a table's header; build your own row when it needs what `ListRow` cannot do (a swipe-to-delete row, a row that expands in place).
|
|
3637
3645
|
- `DataTable` — a list or table of records laid out for its own width, on both hosts. `<DataTable columns rows>` is stacked label/value cards when narrow, one card per row at medium and aligned columns under a sticky header when wide, built from `List` / `ListRow` / `ListHeader` and styled by the theme's `list` scope. A column is `{ key, label, flex, align, minWidth, sortable, render }`; `renderCell`, `onRowPress`, `keyField` (default `"id"`), `loading` and `emptyTitle` / `emptyMessage`, `maxHeight` (480) and `showHeader` (`false` drops the wide header row) complete it. A sortable header is a 44px button named by its column and described by its sort, and a change of sort is announced once; with `onSortChange` the widget orders the rows (a server sort) and the table draws them as given, otherwise it sorts them itself (a `Date` as a date). A controlled `sort` without `onSortChange` is display-only, its headers plain labels. Use it by default for records; editable cells, grouped rows, resizable columns or a pivot are yours to build from `ListHeader` + `ListRow`.
|
|
3638
3646
|
- `Badge`, `Avatar`, `Progress`, `Stat`, `Divider` — the themed status pill, person picture, completion bar or ring, headline figure and rule the built-in widgets of the same names render through. Reach for them inside a record row instead of hand-rolling a pill or a circle from `View`.
|
|
3639
|
-
- `Grid` — balanced lines of cells sized from the grid's own measured width, on both hosts. `<Grid minCellWidth gap balance>`: `balance` `"cards"` (default) fits as many cells to a line as `minCellWidth` allows (240 when unset), fills every line but the last and pads that one with empty cells; `"tiles"` spreads the remainder and stretches each line (5 at 4 per line are 3 + 2), with `
|
|
3647
|
+
- `Grid` — balanced lines of cells sized from the grid's own measured width, on both hosts. `<Grid minCellWidth gap balance>`: `balance` `"cards"` (default) fits as many cells to a line as `minCellWidth` allows (240 when unset), fills every line but the last and pads that one with empty cells; `"tiles"` spreads the remainder and stretches each line (5 at 4 per line are 3 + 2), with what fits at `minCellWidth` or the width tier (4 / 3 / 2) as the ceiling, which `maxColumns` only lowers. `columns` fixes the count per line; `cell={{ min, max }}` with `square` makes definite-size cells (calendar days, seats, swatches) in a centred block. It measures an inner box with no padding, and `gap` is a theme spacing name or a number. Each child keeps its own look, and a child with `flex: 1` fills its cell's height. Use it by default for card grids, tile rows and capped cells; masonry or spanning cells are yours to lay out with `useContainerWidth()`.
|
|
3640
3648
|
- `Form`, `FieldRow`, `FormSection`, `FormActions`, `FormField` — a form laid out in width tiers from its own measured width, on both hosts: `<Form columns maxWidth gap>` puts its fields one to a line when narrow, two at medium and up to three when wide (`columns` is the wide ceiling), capped near 1000px and centred (`maxWidth={null}` for none). A `<FormField>`, or a `<TextField>`, `<Select>`, `<RadioGroup>`, `<PeoplePicker>` or `<FileUpload>` with its own label, is one field; a multiline field, `<FormField span="full">`, `<FieldRow>` (short related fields on one line, stacked when narrow), `<FormSection title description>` and `<FormActions>` (Save / Cancel in normal flow, secondary first and primary last, a trailing row or a full-width stack when narrow) take the whole line. `<FormField label required helper error>` draws the form controls' label, required mark, helper and error round any control and names it for a screen reader; a control that frames its own label is handed them instead, so one label is drawn. `required` (also on `TextField`, `Select`, `RadioGroup`, `PeoplePicker`, `FileUpload`) draws the mark and adds "Required" to the spoken name; it does not validate. Use it by default; a multi-step wizard, a form beside a live preview or fields laid over a picture are yours to lay out with `useContainerWidth()`.
|
|
3641
3649
|
- `SortableList`, `Board` — drag and drop on both hosts. `<SortableList items onReorder renderItem>` is a list the user reorders, each row a `<ListRow>`; `<Board columns items getColumn onMove renderCard>` is cards moved between columns, each a `<Card>`. Both own the grip handle, the lifted copy, the vacated slot, the drop highlight in the soft primary, the spring back of a cancelled drag and a narrow board's sideways scroll, and give a user who cannot drag the same moves: a tap or Enter on the handle opens its move options, the arrow keys move it on the web, a screen reader gets them as actions, and each move is announced. `onReorder(nextItems, { from, to, item })` and `onMove(item, { fromColumn, toColumn, index })` run once per real change. Use them by default; a drag they cannot express (free-form positioning, a drag between two widgets) is yours to build with `Animated` + `PanResponder`.
|
|
3642
3650
|
- `Card`, `Button`, `TextField` — the themed card surface, button and text field the built-in widgets render through. With no props each takes the app's look from Design > Components (Cards, Buttons, Inputs); never hand-roll one from `View` / `Pressable` / a bare `TextInput`. `<TextField leadingIcon trailingIcon onTrailingPress trailingAccessibilityLabel>` draws icons inside the field's own border.
|
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
|
-
|
|
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
|
-
|
|
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/grid-logic.js
CHANGED
|
@@ -148,16 +148,9 @@ export function planGrid(input) {
|
|
|
148
148
|
|
|
149
149
|
const counted = minCellWidth !== null && minCellWidth > 0 ? minCellWidth : null;
|
|
150
150
|
if (balance === "tiles") {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
max = capped(cellsPerLine(width, gap, counted));
|
|
155
|
-
} else if (maxColumns) {
|
|
156
|
-
max = maxColumns;
|
|
157
|
-
} else {
|
|
158
|
-
if (width === 0) return null;
|
|
159
|
-
max = TILE_COLUMNS_BY_TIER[widthTier(width)];
|
|
160
|
-
}
|
|
151
|
+
if (width === 0) return null;
|
|
152
|
+
// maxColumns only lowers the ceiling: four tiles never share a phone's line.
|
|
153
|
+
const max = capped(counted ? cellsPerLine(width, gap, counted) : TILE_COLUMNS_BY_TIER[widthTier(width)]);
|
|
161
154
|
return { lengths: tileLineLengths(count, max), slots: null, cellSize: null, blockWidth: null };
|
|
162
155
|
}
|
|
163
156
|
|
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
|
-
|
|
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
|
@@ -2859,8 +2859,9 @@ export type GridGap = "xs" | "sm" | "md" | "lg" | "xl" | number;
|
|
|
2859
2859
|
* above. 6 that fit 5 are 3 + 3.
|
|
2860
2860
|
* - `balance="tiles"`: the remainder spreads over every line and each line
|
|
2861
2861
|
* stretches, so 5 tiles at 4 per line are 3 + 2, never 4 + 1. The per-line
|
|
2862
|
-
* ceiling is
|
|
2863
|
-
*
|
|
2862
|
+
* ceiling is what fits at `minCellWidth`, or else 4 / 3 / 2 for the wide /
|
|
2863
|
+
* medium / narrow width tier; `maxColumns` only lowers it, so
|
|
2864
|
+
* `maxColumns={4}` is still 2 a line on a phone.
|
|
2864
2865
|
* - `columns`: exactly that many cells per line, the last line padded.
|
|
2865
2866
|
* - `cell={{ min, max }}`: definite-size cells (calendar days, seats,
|
|
2866
2867
|
* swatches) as large as fit up to `max`, never below `min` (32 when unset),
|
|
@@ -2883,6 +2884,7 @@ export const Grid: (props: {
|
|
|
2883
2884
|
balance?: GridBalance;
|
|
2884
2885
|
/** The narrowest a cell may be; the per-line count is derived from it. */
|
|
2885
2886
|
minCellWidth?: number;
|
|
2887
|
+
/** Lowers the per-line ceiling; never raises it past what the width allows. */
|
|
2886
2888
|
maxColumns?: number;
|
|
2887
2889
|
columns?: number;
|
|
2888
2890
|
cell?: { min?: number; max: number };
|
|
@@ -4212,7 +4214,8 @@ export interface CanWriteResult {
|
|
|
4212
4214
|
* "signed in but forbidden". Falsy `tableId`, or a host that has not
|
|
4213
4215
|
* injected `ctx.datastore.myPermissions`, collapses to `{ canWrite: false,
|
|
4214
4216
|
* loading: false, error: null, refetch: async () => undefined }` rather than
|
|
4215
|
-
* throwing.
|
|
4217
|
+
* throwing. With a table bound, `loading` stays true until the answer for
|
|
4218
|
+
* that table (and row) has arrived.
|
|
4216
4219
|
*/
|
|
4217
4220
|
export function useCanWrite(
|
|
4218
4221
|
tableId: string | null | undefined,
|
|
@@ -4565,6 +4568,8 @@ export const ListRow: (props: ListRowTokens & {
|
|
|
4565
4568
|
disabled?: boolean;
|
|
4566
4569
|
/** Defaults to true; pass false on the last row. */
|
|
4567
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);
|
|
4568
4573
|
accessibilityLabel?: string;
|
|
4569
4574
|
style?: any;
|
|
4570
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
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
|
-
|
|
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,
|