@colixsystems/widget-sdk 0.328.0 → 0.329.1

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
@@ -24,7 +24,7 @@ The data layer lives in **four separate domain-client packages**, each instantia
24
24
  | **CORE** | `useUser()` | `{ id, email, displayName, photoUrl, roles, groupIds }` | `ctx.user` (host-built context, **camelCase** — not a wire payload; `id` null when anonymous) — no scope. `photoUrl` is the user's own profile photo as an absolute URL, or `null`. |
25
25
  | **CORE** | `useUserPhoto()` | `{ url, canEdit, upload, remove, uploading, error }` | `ctx.user` + the optional `ctx.account` — no scope. Changes the signed-in user's OWN profile photo. `canEdit` is false when nobody is signed in or the host cannot change it; `upload` / `remove` then reject. |
26
26
  | **CORE** | `useAnonymousAccount()` | `{ supported, canCreate, creating, error, create }` | The optional `ctx.account.anonymous` — no scope. Offers an account with a generated login code and password and no email. `create()` opens the app's own dialog, which confirms, creates the account, shows the pair once and signs the visitor in; the widget never receives the pair and `create()` resolves `{ created: true }`. `supported` is false where the workspace has not turned anonymous accounts on, on the Builder canvas, in a preview and for a badge counter; `canCreate` is false while someone is signed in. |
27
- | **CORE** | `useNavigation()` | `{ goTo, goToStartPage, scrollToSection, scrollIntoView, goBack, push, replace, back, currentRoute, openLink }` | `ctx.navigation` — no scope. `goTo(pageIdOrSlug, params?)` accepts a page UUID (a `pageRef` prop) **or its slug** (a row's page-key field) — both hosts resolve either; `goToStartPage()` opens the signed-in user's own start page; `scrollToSection(id)` scrolls this page to a section picked with a `sectionRef` prop; `scrollIntoView(ref)` scrolls it to an element inside your widget (a heading your table of contents jumps to) (`openLink` for a link of unknown shape; a known external URL can also use the `Linking` primitive) |
27
+ | **CORE** | `useNavigation()` | `{ goTo, goToStartPage, signIn, scrollToSection, scrollIntoView, goBack, push, replace, back, currentRoute, openLink }` | `ctx.navigation` — no scope. `goTo(pageIdOrSlug, params?)` accepts a page UUID (a `pageRef` prop) **or its slug** (a row's page-key field) — both hosts resolve either; `goToStartPage()` opens the signed-in user's own start page; `signIn({ email? })` opens the app's sign-in screen over this page; `scrollToSection(id)` scrolls this page to a section picked with a `sectionRef` prop; `scrollIntoView(ref)` scrolls it to an element inside your widget (a heading your table of contents jumps to) (`openLink` for a link of unknown shape; a known external URL can also use the `Linking` primitive) |
28
28
  | **CORE** | `useFilePreview(file)` | `{ uri }` | No scope. A temporary address an `<Image>` can show for a file the person picked but has not uploaded yet (a photo in a composer). Native picks use their own uri; on the web the SDK creates and releases an object URL, which widgets may not do themselves. `uri` is null for no file. |
29
29
  | **CORE** | `usePageBadge(count)` | `{ supported }` | `ctx.navigation.setBadge` — no scope. Puts `count` on the menu entry or tab of the page the widget is on (a chat's unread messages). The host sums the page's widgets and keeps the last count after the widget leaves the screen, until it reports again; `0` clears this widget's share. `supported` is false where the host draws no page badges (the Builder canvas). |
30
30
  | **CORE** | `useRouteParams()` | `{ [paramKey]: value }` | `ctx.navigation.currentRoute.params` — no scope. The nav params the previous page passed via `goTo(pageId, params)`; the flat accessor for master→detail (read `recordId` on a detail page). Empty object when none. |
@@ -91,7 +91,28 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
91
91
 
92
92
  ## Status
93
93
 
94
- `v0.328.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
+ `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**.
95
+
96
+ ### What's new in 0.329.1 (contract 1.268.0)
97
+
98
+ **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.
99
+
100
+ ### What's new in 0.329.0 (contract 1.268.0)
101
+
102
+ **A widget opens the app's sign-in screen itself — `useNavigation().signIn()`.** A signed-out visitor's "Sign in to add to bag" or "Sign in to comment" control used to fire an event the page had to bind to the Sign in action; a page that never bound it left a button that did nothing. `signIn({ email? })` opens the same sign-in screen as a Button's Sign in action, over the current page, and the visitor stays on that page once signed in. `email` pre-fills the field. It works on the web Player and the exported app, and is a no-op on the Studio canvas. Additive, plus a stricter lint: the new `sign-in-event` error refuses an event declared for the page to bind to Sign in (one whose description asks for that binding, or a sign-in press event with no description).
103
+
104
+ ```jsx
105
+ import { useNavigation, useUser, Button } from "@colixsystems/widget-sdk";
106
+
107
+ export default function AddToBag() {
108
+ const user = useUser();
109
+ const { signIn } = useNavigation();
110
+ if (!user.id) return <Button title="Sign in to add to bag" onPress={() => signIn()} />;
111
+ return <Button title="Add to bag" onPress={() => {}} />;
112
+ }
113
+ ```
114
+
115
+ While nobody is signed in, hand a table the visitor cannot read to no hook: pass `user.id ? props.bagTable : null`, and `useDatastoreQuery`, `useDatastoreSchema`, `useCanWrite` and the other table hooks send no request until someone signs in.
95
116
 
96
117
  ### What's new in 0.328.0 (contract 1.267.0)
97
118
 
@@ -3619,7 +3640,7 @@ import { defineWidget, validateManifest, useDatastoreQuery, Text, View } from "@
3619
3640
  - `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).
3620
3641
  - `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`.
3621
3642
  - `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`.
3622
- - `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 `maxColumns` or the width tier (4 / 3 / 2) as the ceiling. `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()`.
3643
+ - `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()`.
3623
3644
  - `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()`.
3624
3645
  - `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`.
3625
3646
  - `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
@@ -1304,6 +1304,8 @@ const HOOKS = [
1304
1304
  openLink: "(link: string) => boolean",
1305
1305
  goToStartPage:
1306
1306
  "() => void — opens the signed-in user's own start page, the page the app opens on for them (it can differ per user, since page access is restricted per group). Use it for a 'back to start' or 'home' button instead of hard-coding a page. A no-op where there is no live router (the Studio canvas, a badge counter).",
1307
+ signIn:
1308
+ "(options?: { email?: string }) => void — opens the app's own sign-in screen over the current page, the same screen the app's 'Log in' opens, and leaves the visitor on this page once they are signed in. `email` pre-fills the field. Use it for a signed-out visitor's 'Sign in to …' control inside a widget; never declare an event for the page to bind to Sign in. A no-op where no sign-in screen exists (the Studio canvas, a badge counter).",
1307
1309
  scrollToSection:
1308
1310
  "(sectionId: string) => void — scrolls THIS page to one of its sections (a root section or a layout container), landing its top just below any pinned site header; smooth unless the visitor prefers reduced motion. Take the id from a `sectionRef` prop the author picks; never hard-code a node id. An unknown, deleted or hidden section is a no-op, and so is the Studio canvas.",
1309
1311
  scrollIntoView:
@@ -4453,7 +4455,7 @@ const WIDGET_CONTEXT_SHAPE = {
4453
4455
  },
4454
4456
  navigation: {
4455
4457
  description:
4456
- "{ push(path), replace(path), back() }, and optionally setBadge(count) — the page badge usePageBadge() writes, bound by the host to this widget on its page — and onHardwareBack(listener) → unsubscribe, Android's back button for useHardwareBack(), which the native host answers only for the screen in view.",
4458
+ "{ push(path), replace(path), back() }, and optionally signIn({ email? }) — the app's sign-in screen useNavigation().signIn() opens — setBadge(count) — the page badge usePageBadge() writes, bound by the host to this widget on its page — and onHardwareBack(listener) → unsubscribe, Android's back button for useHardwareBack(), which the native host answers only for the screen in view.",
4457
4459
  required: true,
4458
4460
  fields: { push: "function", replace: "function", back: "function" },
4459
4461
  },
@@ -7054,7 +7056,11 @@ const CONTRACT = deepFreeze({
7054
7056
  // 1.267.0: fix (sc-16875) — `themeWidgetStyles.fontSizeFields` names the
7055
7057
  // style fields that size text. A widget's own or app-wide value below
7056
7058
  // `minFontPx` renders and saves at it on both hosts.
7057
- version: "1.267.0",
7059
+ // 1.268.0: additive + stricter lint (sc-16523) — `useNavigation().signIn({
7060
+ // email? })` opens the app's sign-in screen over the page on both hosts,
7061
+ // and an event declared for the page to bind to Sign in is the
7062
+ // `sign-in-event` error.
7063
+ version: "1.268.0",
7058
7064
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7059
7065
  hooks: HOOKS,
7060
7066
  primitives: PRIMITIVES,
package/dist/contract.js CHANGED
@@ -1299,6 +1299,8 @@ const HOOKS = [
1299
1299
  openLink: "(link: string) => boolean",
1300
1300
  goToStartPage:
1301
1301
  "() => void — opens the signed-in user's own start page, the page the app opens on for them (it can differ per user, since page access is restricted per group). Use it for a 'back to start' or 'home' button instead of hard-coding a page. A no-op where there is no live router (the Studio canvas, a badge counter).",
1302
+ signIn:
1303
+ "(options?: { email?: string }) => void — opens the app's own sign-in screen over the current page, the same screen the app's 'Log in' opens, and leaves the visitor on this page once they are signed in. `email` pre-fills the field. Use it for a signed-out visitor's 'Sign in to …' control inside a widget; never declare an event for the page to bind to Sign in. A no-op where no sign-in screen exists (the Studio canvas, a badge counter).",
1302
1304
  scrollToSection:
1303
1305
  "(sectionId: string) => void — scrolls THIS page to one of its sections (a root section or a layout container), landing its top just below any pinned site header; smooth unless the visitor prefers reduced motion. Take the id from a `sectionRef` prop the author picks; never hard-code a node id. An unknown, deleted or hidden section is a no-op, and so is the Studio canvas.",
1304
1306
  scrollIntoView:
@@ -4448,7 +4450,7 @@ const WIDGET_CONTEXT_SHAPE = {
4448
4450
  },
4449
4451
  navigation: {
4450
4452
  description:
4451
- "{ push(path), replace(path), back() }, and optionally setBadge(count) — the page badge usePageBadge() writes, bound by the host to this widget on its page — and onHardwareBack(listener) → unsubscribe, Android's back button for useHardwareBack(), which the native host answers only for the screen in view.",
4453
+ "{ push(path), replace(path), back() }, and optionally signIn({ email? }) — the app's sign-in screen useNavigation().signIn() opens — setBadge(count) — the page badge usePageBadge() writes, bound by the host to this widget on its page — and onHardwareBack(listener) → unsubscribe, Android's back button for useHardwareBack(), which the native host answers only for the screen in view.",
4452
4454
  required: true,
4453
4455
  fields: { push: "function", replace: "function", back: "function" },
4454
4456
  },
@@ -7049,7 +7051,11 @@ const CONTRACT = deepFreeze({
7049
7051
  // 1.267.0: fix (sc-16875) — `themeWidgetStyles.fontSizeFields` names the
7050
7052
  // style fields that size text. A widget's own or app-wide value below
7051
7053
  // `minFontPx` renders and saves at it on both hosts.
7052
- version: "1.267.0",
7054
+ // 1.268.0: additive + stricter lint (sc-16523) — `useNavigation().signIn({
7055
+ // email? })` opens the app's sign-in screen over the page on both hosts,
7056
+ // and an event declared for the page to bind to Sign in is the
7057
+ // `sign-in-event` error.
7058
+ version: "1.268.0",
7053
7059
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7054
7060
  hooks: HOOKS,
7055
7061
  primitives: PRIMITIVES,
@@ -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
- let max;
152
- if (counted) {
153
- if (width === 0) return null;
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
@@ -788,11 +788,12 @@ export function useContainerWidth() {
788
788
 
789
789
  /**
790
790
  * Returns the host-provided navigation surface: `{ goTo, goToStartPage,
791
- * scrollToSection, scrollIntoView, goBack, push, replace, back, currentRoute,
792
- * openLink }`.
791
+ * signIn, scrollToSection, scrollIntoView, goBack, push, replace, back,
792
+ * currentRoute, openLink }`.
793
793
  *
794
794
  * `goTo(pageId, params?)` navigates to an internal app page. `goToStartPage()`
795
795
  * opens the signed-in user's own start page, which can differ per user.
796
+ * `signIn({ email? })` opens the app's sign-in screen over this page.
796
797
  * `scrollToSection(id)` scrolls the page to one of its sections, and (sc-12088)
797
798
  * `scrollIntoView(ref)` to an element inside the calling widget.
798
799
  * `goBack()` pops the stack. `push` / `replace` / `back` are aliases that map to
package/dist/index.d.ts CHANGED
@@ -891,6 +891,7 @@ export interface WidgetContext<TProps = unknown> {
891
891
  navigation: {
892
892
  goTo(pageId: string, params?: Record<string, string>): void;
893
893
  goToStartPage(): void;
894
+ signIn(options?: { email?: string }): void;
894
895
  scrollToSection(sectionId: string): void;
895
896
  scrollIntoView(ref: { readonly current: unknown } | object | null | undefined): void;
896
897
  goBack(): void;
@@ -2663,6 +2664,8 @@ export function useFitScreenInsets(): FitScreenInsets;
2663
2664
  * The host-provided navigation surface. `goTo(pageId, params?)` navigates
2664
2665
  * to an internal app page; `goBack()` pops the stack. `goToStartPage()`
2665
2666
  * opens the signed-in user's own start page, which can differ per user.
2667
+ * `signIn({ email? })` opens the app's sign-in screen over this page, for a
2668
+ * signed-out visitor's "Sign in to …" control.
2666
2669
  * `scrollToSection(sectionId)` scrolls this page to one of its sections (the
2667
2670
  * id comes from a `sectionRef` prop); an unknown section is a no-op.
2668
2671
  * `scrollIntoView(ref)` scrolls this page to an element inside the calling
@@ -2673,6 +2676,7 @@ export function useFitScreenInsets(): FitScreenInsets;
2673
2676
  export function useNavigation(): {
2674
2677
  goTo(pageId: string, params?: Record<string, unknown>): void;
2675
2678
  goToStartPage(): void;
2679
+ signIn(options?: { email?: string }): void;
2676
2680
  scrollToSection(sectionId: string): void;
2677
2681
  scrollIntoView(ref: { readonly current: unknown } | object | null | undefined): void;
2678
2682
  goBack(): void;
@@ -2855,8 +2859,9 @@ export type GridGap = "xs" | "sm" | "md" | "lg" | "xl" | number;
2855
2859
  * above. 6 that fit 5 are 3 + 3.
2856
2860
  * - `balance="tiles"`: the remainder spreads over every line and each line
2857
2861
  * stretches, so 5 tiles at 4 per line are 3 + 2, never 4 + 1. The per-line
2858
- * ceiling is `maxColumns`, or what fits at `minCellWidth`, or else 4 / 3 / 2
2859
- * for the wide / medium / narrow width tier.
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.
2860
2865
  * - `columns`: exactly that many cells per line, the last line padded.
2861
2866
  * - `cell={{ min, max }}`: definite-size cells (calendar days, seats,
2862
2867
  * swatches) as large as fit up to `max`, never below `min` (32 when unset),
@@ -2879,6 +2884,7 @@ export const Grid: (props: {
2879
2884
  balance?: GridBalance;
2880
2885
  /** The narrowest a cell may be; the per-line count is derived from it. */
2881
2886
  minCellWidth?: number;
2887
+ /** Lowers the per-line ceiling; never raises it past what the width allows. */
2882
2888
  maxColumns?: number;
2883
2889
  columns?: number;
2884
2890
  cell?: { min?: number; max: number };
package/dist/linter.cjs CHANGED
@@ -970,6 +970,47 @@ function _scopeRules(source, manifest) {
970
970
  // validated structurally here (shape + caps) rather than scanned as component
971
971
  // source. Mirrors the validator in manifest.js; emits `error` findings so a
972
972
  // malformed / oversized / mis-triggered action blocks publish.
973
+ // sc-16523 — an event that only signs the visitor in once the page binds it to
974
+ // Sign in. Nothing binds it for a widget, so its button did nothing in a built
975
+ // shop; useNavigation().signIn() opens the sign-in screen from the widget.
976
+ const SIGN_IN_PRESS_EVENT_RE =
977
+ /^(?:on)?(?:sign|log)[_-]?in[_-]?(?:press(?:ed)?|tap(?:ped)?|click(?:ed)?|request(?:ed)?)$/i;
978
+ const BIND_WORD_RE = /\b(?:bind(?:s|ing)?|bound|wir(?:e|es|ed|ing))\b/i;
979
+ // One clause names the Sign in action: `Sign in action`, `"sign-in" action`, `action "sign-in"`.
980
+ const SIGN_IN_ACTION_RE =
981
+ /\b(?:sign|log)[ -]?in\b["'\u201d]?(?: page)? action\b|\baction ["'\u201c]?(?:sign|log)[ -]?in\b/i;
982
+
983
+ function _asksForSignInBinding(description) {
984
+ return description
985
+ .split(/[.;!?\n]+/)
986
+ .some((clause) => BIND_WORD_RE.test(clause) && SIGN_IN_ACTION_RE.test(clause.replace(/\s+/g, " ")));
987
+ }
988
+
989
+ function _signInEventRules(manifest) {
990
+ const events = manifest && Array.isArray(manifest.events) ? manifest.events : [];
991
+ const findings = [];
992
+ for (const e of events) {
993
+ const name = e && typeof e.name === "string" ? e.name.trim() : "";
994
+ if (!name) continue;
995
+ const description = typeof e.description === "string" ? e.description.trim() : "";
996
+ const asksForSignIn = description
997
+ ? _asksForSignInBinding(description)
998
+ : SIGN_IN_PRESS_EVENT_RE.test(name);
999
+ if (!asksForSignIn) continue;
1000
+ findings.push({
1001
+ rule: "sign-in-event",
1002
+ severity: "error",
1003
+ label:
1004
+ `declares event "${name}" for the page to bind to Sign in - nothing ` +
1005
+ `binds it, so the control does nothing. Call ` +
1006
+ `useNavigation().signIn() from the control and drop the event.`,
1007
+ line: 0,
1008
+ snippet: "",
1009
+ });
1010
+ }
1011
+ return findings;
1012
+ }
1013
+
973
1014
  function _manifestActionRules(manifest) {
974
1015
  const findings = [];
975
1016
  if (!manifest || manifest.actions === undefined) return findings;
@@ -3724,6 +3765,7 @@ function lintSource(source, options) {
3724
3765
  );
3725
3766
  // REQ-WIDGET-ACTION — structural validation of manifest-declared actions.
3726
3767
  findings.push(..._manifestActionRules(options && options.manifest));
3768
+ findings.push(..._signInEventRules(options && options.manifest));
3727
3769
  findings.push(..._groupIdTextRules(source, options && options.manifest));
3728
3770
  findings.push(..._badgeCounterRules(source, options && options.manifest));
3729
3771
  const hasErrors = findings.some((f) => f.severity !== "warning");
package/dist/linter.js CHANGED
@@ -965,6 +965,47 @@ function _scopeRules(source, manifest) {
965
965
  // validated structurally here (shape + caps) rather than scanned as component
966
966
  // source. Mirrors the validator in manifest.js; emits `error` findings so a
967
967
  // malformed / oversized / mis-triggered action blocks publish.
968
+ // sc-16523 — an event that only signs the visitor in once the page binds it to
969
+ // Sign in. Nothing binds it for a widget, so its button did nothing in a built
970
+ // shop; useNavigation().signIn() opens the sign-in screen from the widget.
971
+ const SIGN_IN_PRESS_EVENT_RE =
972
+ /^(?:on)?(?:sign|log)[_-]?in[_-]?(?:press(?:ed)?|tap(?:ped)?|click(?:ed)?|request(?:ed)?)$/i;
973
+ const BIND_WORD_RE = /\b(?:bind(?:s|ing)?|bound|wir(?:e|es|ed|ing))\b/i;
974
+ // One clause names the Sign in action: `Sign in action`, `"sign-in" action`, `action "sign-in"`.
975
+ const SIGN_IN_ACTION_RE =
976
+ /\b(?:sign|log)[ -]?in\b["'\u201d]?(?: page)? action\b|\baction ["'\u201c]?(?:sign|log)[ -]?in\b/i;
977
+
978
+ function _asksForSignInBinding(description) {
979
+ return description
980
+ .split(/[.;!?\n]+/)
981
+ .some((clause) => BIND_WORD_RE.test(clause) && SIGN_IN_ACTION_RE.test(clause.replace(/\s+/g, " ")));
982
+ }
983
+
984
+ function _signInEventRules(manifest) {
985
+ const events = manifest && Array.isArray(manifest.events) ? manifest.events : [];
986
+ const findings = [];
987
+ for (const e of events) {
988
+ const name = e && typeof e.name === "string" ? e.name.trim() : "";
989
+ if (!name) continue;
990
+ const description = typeof e.description === "string" ? e.description.trim() : "";
991
+ const asksForSignIn = description
992
+ ? _asksForSignInBinding(description)
993
+ : SIGN_IN_PRESS_EVENT_RE.test(name);
994
+ if (!asksForSignIn) continue;
995
+ findings.push({
996
+ rule: "sign-in-event",
997
+ severity: "error",
998
+ label:
999
+ `declares event "${name}" for the page to bind to Sign in - nothing ` +
1000
+ `binds it, so the control does nothing. Call ` +
1001
+ `useNavigation().signIn() from the control and drop the event.`,
1002
+ line: 0,
1003
+ snippet: "",
1004
+ });
1005
+ }
1006
+ return findings;
1007
+ }
1008
+
968
1009
  function _manifestActionRules(manifest) {
969
1010
  const findings = [];
970
1011
  if (!manifest || manifest.actions === undefined) return findings;
@@ -3719,6 +3760,7 @@ export function lintSource(source, options) {
3719
3760
  );
3720
3761
  // REQ-WIDGET-ACTION — structural validation of manifest-declared actions.
3721
3762
  findings.push(..._manifestActionRules(options && options.manifest));
3763
+ findings.push(..._signInEventRules(options && options.manifest));
3722
3764
  findings.push(..._groupIdTextRules(source, options && options.manifest));
3723
3765
  findings.push(..._badgeCounterRules(source, options && options.manifest));
3724
3766
  const hasErrors = findings.some((f) => f.severity !== "warning");
@@ -66,8 +66,7 @@ const VALID_TYPES = new Set([
66
66
  // folder UUID (or null = space root); renders `FolderSelector` in the Studio
67
67
  // Properties Panel, scoped by a sibling space field named via
68
68
  // `ui.spaceTypeField`. Filestore spaces are per-tenant end-user data and are
69
- // NOT copied, so tenant-copy leaves the id as-is (it resolves to the space
70
- // root if absent in the target).
69
+ // NOT copied, so tenant-copy removes the id and the copy reads the space root.
71
70
  "folderRef",
72
71
  // REQ-LAY-16 (sc-5890): `cornerRadius` is a corner-radius picker. Its value
73
72
  // is `number | { topLeft, topRight, bottomRight, bottomLeft }` — a scalar
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.328.0",
3
+ "version": "0.329.1",
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
@@ -1299,6 +1299,8 @@ const HOOKS = [
1299
1299
  openLink: "(link: string) => boolean",
1300
1300
  goToStartPage:
1301
1301
  "() => void — opens the signed-in user's own start page, the page the app opens on for them (it can differ per user, since page access is restricted per group). Use it for a 'back to start' or 'home' button instead of hard-coding a page. A no-op where there is no live router (the Studio canvas, a badge counter).",
1302
+ signIn:
1303
+ "(options?: { email?: string }) => void — opens the app's own sign-in screen over the current page, the same screen the app's 'Log in' opens, and leaves the visitor on this page once they are signed in. `email` pre-fills the field. Use it for a signed-out visitor's 'Sign in to …' control inside a widget; never declare an event for the page to bind to Sign in. A no-op where no sign-in screen exists (the Studio canvas, a badge counter).",
1302
1304
  scrollToSection:
1303
1305
  "(sectionId: string) => void — scrolls THIS page to one of its sections (a root section or a layout container), landing its top just below any pinned site header; smooth unless the visitor prefers reduced motion. Take the id from a `sectionRef` prop the author picks; never hard-code a node id. An unknown, deleted or hidden section is a no-op, and so is the Studio canvas.",
1304
1306
  scrollIntoView:
@@ -4448,7 +4450,7 @@ const WIDGET_CONTEXT_SHAPE = {
4448
4450
  },
4449
4451
  navigation: {
4450
4452
  description:
4451
- "{ push(path), replace(path), back() }, and optionally setBadge(count) — the page badge usePageBadge() writes, bound by the host to this widget on its page — and onHardwareBack(listener) → unsubscribe, Android's back button for useHardwareBack(), which the native host answers only for the screen in view.",
4453
+ "{ push(path), replace(path), back() }, and optionally signIn({ email? }) — the app's sign-in screen useNavigation().signIn() opens — setBadge(count) — the page badge usePageBadge() writes, bound by the host to this widget on its page — and onHardwareBack(listener) → unsubscribe, Android's back button for useHardwareBack(), which the native host answers only for the screen in view.",
4452
4454
  required: true,
4453
4455
  fields: { push: "function", replace: "function", back: "function" },
4454
4456
  },
@@ -7049,7 +7051,11 @@ const CONTRACT = deepFreeze({
7049
7051
  // 1.267.0: fix (sc-16875) — `themeWidgetStyles.fontSizeFields` names the
7050
7052
  // style fields that size text. A widget's own or app-wide value below
7051
7053
  // `minFontPx` renders and saves at it on both hosts.
7052
- version: "1.267.0",
7054
+ // 1.268.0: additive + stricter lint (sc-16523) — `useNavigation().signIn({
7055
+ // email? })` opens the app's sign-in screen over the page on both hosts,
7056
+ // and an event declared for the page to bind to Sign in is the
7057
+ // `sign-in-event` error.
7058
+ version: "1.268.0",
7053
7059
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7054
7060
  hooks: HOOKS,
7055
7061
  primitives: PRIMITIVES,