@colixsystems/widget-sdk 0.327.0 → 0.329.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
@@ -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.327.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.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.329.0 (contract 1.268.0)
97
+
98
+ **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).
99
+
100
+ ```jsx
101
+ import { useNavigation, useUser, Button } from "@colixsystems/widget-sdk";
102
+
103
+ export default function AddToBag() {
104
+ const user = useUser();
105
+ const { signIn } = useNavigation();
106
+ if (!user.id) return <Button title="Sign in to add to bag" onPress={() => signIn()} />;
107
+ return <Button title="Add to bag" onPress={() => {}} />;
108
+ }
109
+ ```
110
+
111
+ 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.
112
+
113
+ ### What's new in 0.328.0 (contract 1.267.0)
114
+
115
+ **Text a widget sizes itself no longer draws below 12px.** The theme's type scale already stopped at `CONTRACT.minFontPx` (12), the smallest text the app's render check accepts, but a size set on one widget could still go below it, and the page then failed the check and could not publish. The style fields that size text, `fontSize`, `titleSize` and `fieldLabelSize` (listed in `CONTRACT.themeWidgetStyles.fontSizeFields`), now render at 12 when a widget's own style or the app-wide per-widget style sets less, in the web Player and the exported app alike, and are saved as 12. So does any style field whose `themeDefault` is a `typography.sizes` token. A field the `styleSchema` declares as a scale, with a `validation.max` below 12 or a fractional `ui.step`, keeps its value. A page that already holds a 10 keeps saving. A widget that declares a `fontSize` style field should give it `validation: { min: CONTRACT.minFontPx }`. Hosts get the clamp as `floorStyleFontSizes` from `@colixsystems/widget-sdk/host`.
95
116
 
96
117
  ### What's new in 0.327.0 (contract 1.266.0)
97
118
 
package/dist/contract.cjs CHANGED
@@ -315,8 +315,8 @@ const THEME_TEXT_ROLE_FONT_WEIGHTS = Object.freeze([
315
315
  const THEME_TEXT_ROLE_FONT_STYLES = Object.freeze(["normal", "italic"]);
316
316
 
317
317
  // sc-16654 — the smallest page text the render check accepts (TEXT_TOO_SMALL
318
- // reads this value). The type scale and component font sizes clamp up to it on
319
- // both hosts and at save; a per-widget size is the author's own choice.
318
+ // reads this value). The type scale, component font sizes and a widget's own
319
+ // font-size style fields (sc-16875) clamp up to it on both hosts and at save.
320
320
  const MIN_FONT_PX = 12;
321
321
 
322
322
  // The per-role token vocabulary, declared like a `themeComponents` scope's
@@ -376,6 +376,9 @@ const THEME_WIDGET_STYLES = Object.freeze({
376
376
  // Nesting/width a structured value may reach before it is dropped.
377
377
  maxValueDepth: 3,
378
378
  maxValueEntries: 24,
379
+ // sc-16875: the style fields that size text, raised to `minFontPx`
380
+ // wherever a style is folded or saved.
381
+ fontSizeFields: Object.freeze(["fontSize", "titleSize", "fieldLabelSize"]),
379
382
  });
380
383
  // REQ-NAV-STRUCTURE: the SHAPE an app's navigation takes. One catalogue, four
381
384
  // consumers -- the Studio's Navigation page, Mason's set_theme coercion, the web
@@ -1301,6 +1304,8 @@ const HOOKS = [
1301
1304
  openLink: "(link: string) => boolean",
1302
1305
  goToStartPage:
1303
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).",
1304
1309
  scrollToSection:
1305
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.",
1306
1311
  scrollIntoView:
@@ -4450,7 +4455,7 @@ const WIDGET_CONTEXT_SHAPE = {
4450
4455
  },
4451
4456
  navigation: {
4452
4457
  description:
4453
- "{ 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.",
4454
4459
  required: true,
4455
4460
  fields: { push: "function", replace: "function", back: "function" },
4456
4461
  },
@@ -7048,7 +7053,14 @@ const CONTRACT = deepFreeze({
7048
7053
  // 1.266.0: behaviour (sc-16877) — a component's default texts (Select's
7049
7054
  // "Select", "Done", "No options", …) are in the app's language: English
7050
7055
  // and Swedish ship, any other language reads English.
7051
- version: "1.266.0",
7056
+ // 1.267.0: fix (sc-16875) — `themeWidgetStyles.fontSizeFields` names the
7057
+ // style fields that size text. A widget's own or app-wide value below
7058
+ // `minFontPx` renders and saves at it on both hosts.
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",
7052
7064
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7053
7065
  hooks: HOOKS,
7054
7066
  primitives: PRIMITIVES,
package/dist/contract.js CHANGED
@@ -310,8 +310,8 @@ const THEME_TEXT_ROLE_FONT_WEIGHTS = Object.freeze([
310
310
  const THEME_TEXT_ROLE_FONT_STYLES = Object.freeze(["normal", "italic"]);
311
311
 
312
312
  // sc-16654 — the smallest page text the render check accepts (TEXT_TOO_SMALL
313
- // reads this value). The type scale and component font sizes clamp up to it on
314
- // both hosts and at save; a per-widget size is the author's own choice.
313
+ // reads this value). The type scale, component font sizes and a widget's own
314
+ // font-size style fields (sc-16875) clamp up to it on both hosts and at save.
315
315
  const MIN_FONT_PX = 12;
316
316
 
317
317
  // The per-role token vocabulary, declared like a `themeComponents` scope's
@@ -371,6 +371,9 @@ const THEME_WIDGET_STYLES = Object.freeze({
371
371
  // Nesting/width a structured value may reach before it is dropped.
372
372
  maxValueDepth: 3,
373
373
  maxValueEntries: 24,
374
+ // sc-16875: the style fields that size text, raised to `minFontPx`
375
+ // wherever a style is folded or saved.
376
+ fontSizeFields: Object.freeze(["fontSize", "titleSize", "fieldLabelSize"]),
374
377
  });
375
378
  // REQ-NAV-STRUCTURE: the SHAPE an app's navigation takes. One catalogue, four
376
379
  // consumers -- the Studio's Navigation page, Mason's set_theme coercion, the web
@@ -1296,6 +1299,8 @@ const HOOKS = [
1296
1299
  openLink: "(link: string) => boolean",
1297
1300
  goToStartPage:
1298
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).",
1299
1304
  scrollToSection:
1300
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.",
1301
1306
  scrollIntoView:
@@ -4445,7 +4450,7 @@ const WIDGET_CONTEXT_SHAPE = {
4445
4450
  },
4446
4451
  navigation: {
4447
4452
  description:
4448
- "{ 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.",
4449
4454
  required: true,
4450
4455
  fields: { push: "function", replace: "function", back: "function" },
4451
4456
  },
@@ -7043,7 +7048,14 @@ const CONTRACT = deepFreeze({
7043
7048
  // 1.266.0: behaviour (sc-16877) — a component's default texts (Select's
7044
7049
  // "Select", "Done", "No options", …) are in the app's language: English
7045
7050
  // and Swedish ship, any other language reads English.
7046
- version: "1.266.0",
7051
+ // 1.267.0: fix (sc-16875) — `themeWidgetStyles.fontSizeFields` names the
7052
+ // style fields that size text. A widget's own or app-wide value below
7053
+ // `minFontPx` renders and saves at it on both hosts.
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",
7047
7059
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7048
7060
  hooks: HOOKS,
7049
7061
  primitives: PRIMITIVES,
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/host.d.ts CHANGED
@@ -114,6 +114,15 @@ export function normaliseWidgetStyleFields(
114
114
 
115
115
  export function normaliseWidgetStyles(raw: unknown): ThemeWidgetStyles;
116
116
 
117
+ /**
118
+ * sc-16875 host helper: a style with each `themeWidgetStyles.fontSizeFields`
119
+ * value, and each `styleSchema` field defaulting to a `typography.sizes` token,
120
+ * below `CONTRACT.minFontPx` raised to it, except a field `styleSchema`
121
+ * declares as a scale (`validation.max` below the floor, or a fractional
122
+ * `ui.step`). Returns the same object when nothing is below the floor.
123
+ */
124
+ export function floorStyleFontSizes<T>(style: T, styleSchema?: Record<string, unknown>): T;
125
+
117
126
  /**
118
127
  * REQ-THEME-15 host render-boundary helper: folds the widget's declared
119
128
  * `styleSchema` defaults and the theme's per-component tokens into a widget's
@@ -121,8 +130,9 @@ export function normaliseWidgetStyles(raw: unknown): ThemeWidgetStyles;
121
130
  *
122
131
  * sc-6750 — precedence, weakest first: `styleSchema` default ->
123
132
  * palette/`components.<scope>` -> `widgetStyles[manifestId]` -> per-instance
124
- * `props.style`. Returns the same `props` reference when neither the theme nor
125
- * the schema sets anything. Applied by the platform hosts, never by authors.
133
+ * `props.style`. A text size below `CONTRACT.minFontPx` renders at it. Returns
134
+ * the same `props` reference when neither the theme nor the schema sets
135
+ * anything and no text size is below the floor. Applied by the platform hosts, never by authors.
126
136
  * An `appstudio.button` whose `props.variant` is `"danger"` takes no general
127
137
  * button colour (background, gradient, text, border) from the theme layers.
128
138
  */
package/dist/host.js CHANGED
@@ -21,6 +21,7 @@ export {
21
21
  normaliseWidgetStyleFields,
22
22
  normaliseWidgetStyles,
23
23
  applyThemeComponentStyle,
24
+ floorStyleFontSizes,
24
25
  } from "./theme-components.js";
25
26
 
26
27
  // REQ-THEME-ROLE: the one typography-role validator, for both hosts and the backend.
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;
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
@@ -177,6 +177,55 @@ function styleValueBytes(value) {
177
177
  return typeof json === "string" ? json.length : Infinity;
178
178
  }
179
179
 
180
+ // A field the widget bounds below the floor, or steps in fractions, is a
181
+ // scale factor that only shares a text-size name.
182
+ function declaresScale(def) {
183
+ if (!isPlainObject(def)) return false;
184
+ const max = isPlainObject(def.validation) ? def.validation.max : undefined;
185
+ const step = isPlainObject(def.ui) ? def.ui.step : undefined;
186
+ return (
187
+ (typeof max === "number" && max < CONTRACT.minFontPx) ||
188
+ (typeof step === "number" && !Number.isInteger(step))
189
+ );
190
+ }
191
+
192
+ // The named fields, plus any the schema defaults to a theme text size.
193
+ function textSizeFields(declared) {
194
+ const fields = new Set(CONTRACT.themeWidgetStyles.fontSizeFields);
195
+ for (const [field, def] of Object.entries(declared)) {
196
+ const themed = isPlainObject(def) ? def.themeDefault : undefined;
197
+ if (typeof themed === "string" && themed.startsWith("typography.sizes.")) fields.add(field);
198
+ }
199
+ return fields;
200
+ }
201
+
202
+ /**
203
+ * sc-16875 — a style's text sizes, raised to the render check's floor.
204
+ *
205
+ * Text below `CONTRACT.minFontPx` fails the render check and holds the page's
206
+ * publish, so a stored 10 draws at 12 rather than being refused: existing
207
+ * pages keep saving. Fields come from `themeWidgetStyles.fontSizeFields`, plus
208
+ * any `styleSchema` field whose `themeDefault` is a `typography.sizes` token;
209
+ * one the schema declares as a scale is left alone.
210
+ *
211
+ * @param {Record<string, unknown>} style — a validated style object.
212
+ * @param {object} [styleSchema] — the widget's declared style fields.
213
+ * @returns {Record<string, unknown>} the SAME object when nothing is below it.
214
+ */
215
+ function floorStyleFontSizes(style, styleSchema) {
216
+ if (!isPlainObject(style)) return style;
217
+ const declared = isPlainObject(styleSchema) ? styleSchema : {};
218
+ let out = style;
219
+ for (const field of textSizeFields(declared)) {
220
+ const value = style[field];
221
+ if (typeof value !== "number" || !(value < CONTRACT.minFontPx)) continue;
222
+ if (declaresScale(declared[field])) continue;
223
+ if (out === style) out = { ...style };
224
+ out[field] = CONTRACT.minFontPx;
225
+ }
226
+ return out;
227
+ }
228
+
180
229
  /**
181
230
  * sc-5646: ONE widget's style fields, validated. The app-wide layer and a placed
182
231
  * node's `props.style` hold the SAME vocabulary at different scopes, so they must
@@ -204,7 +253,7 @@ function normaliseWidgetStyleFields(raw, { maxFields } = {}) {
204
253
  out[field] = coerced;
205
254
  count += 1;
206
255
  }
207
- return out;
256
+ return floorStyleFontSizes(out);
208
257
  }
209
258
 
210
259
  /**
@@ -390,9 +439,11 @@ function withoutGeneralButtonPaint(manifestId, props, themed) {
390
439
  * as before — precedence: styleSchema default -> palette/`components.<scope>`
391
440
  * -> `widgetStyles[manifestId]` -> per-instance `props.style`.
392
441
  *
442
+ * sc-16875: a text size below `CONTRACT.minFontPx`, from any layer, renders at it.
443
+ *
393
444
  * Returns the SAME `props` reference when neither the theme nor the schema sets
394
- * anything for this widget, so an unthemed app with no declared style defaults
395
- * takes no extra render work and behaves exactly as it did before REQ-THEME-15.
445
+ * anything for this widget and no text size is below the floor, so an unthemed
446
+ * app with no declared style defaults takes no extra render work.
396
447
  *
397
448
  * @param {string} manifestId — the widget's canonical manifest id.
398
449
  * @param {object} theme — the resolved widget theme (`workspace.theme`); its
@@ -409,16 +460,21 @@ function applyThemeComponentStyle(manifestId, theme, props, styleSchema) {
409
460
  styleSchema,
410
461
  theme && theme.widgetStyles,
411
462
  );
412
- if (!themed) return props;
413
463
  const base = isPlainObject(props) ? props : {};
414
464
  const authored = isPlainObject(base.style) ? base.style : null;
415
- return { ...base, style: { ...withoutGeneralButtonPaint(manifestId, base, themed), ...authored } };
465
+ if (!themed) {
466
+ const floored = floorStyleFontSizes(authored, styleSchema);
467
+ return floored === authored ? props : { ...base, style: floored };
468
+ }
469
+ const style = { ...withoutGeneralButtonPaint(manifestId, base, themed), ...authored };
470
+ return { ...base, style: floorStyleFontSizes(style, styleSchema) };
416
471
  }
417
472
  module.exports = {
418
473
  coerceThemeColor,
419
474
  normaliseThemeComponents,
420
475
  MAX_STYLE_STRING_LENGTH,
421
476
  styleValueBytes,
477
+ floorStyleFontSizes,
422
478
  normaliseWidgetStyleFields,
423
479
  normaliseWidgetStyles,
424
480
  applyThemeComponentStyle,
@@ -172,6 +172,55 @@ export function styleValueBytes(value) {
172
172
  return typeof json === "string" ? json.length : Infinity;
173
173
  }
174
174
 
175
+ // A field the widget bounds below the floor, or steps in fractions, is a
176
+ // scale factor that only shares a text-size name.
177
+ function declaresScale(def) {
178
+ if (!isPlainObject(def)) return false;
179
+ const max = isPlainObject(def.validation) ? def.validation.max : undefined;
180
+ const step = isPlainObject(def.ui) ? def.ui.step : undefined;
181
+ return (
182
+ (typeof max === "number" && max < CONTRACT.minFontPx) ||
183
+ (typeof step === "number" && !Number.isInteger(step))
184
+ );
185
+ }
186
+
187
+ // The named fields, plus any the schema defaults to a theme text size.
188
+ function textSizeFields(declared) {
189
+ const fields = new Set(CONTRACT.themeWidgetStyles.fontSizeFields);
190
+ for (const [field, def] of Object.entries(declared)) {
191
+ const themed = isPlainObject(def) ? def.themeDefault : undefined;
192
+ if (typeof themed === "string" && themed.startsWith("typography.sizes.")) fields.add(field);
193
+ }
194
+ return fields;
195
+ }
196
+
197
+ /**
198
+ * sc-16875 — a style's text sizes, raised to the render check's floor.
199
+ *
200
+ * Text below `CONTRACT.minFontPx` fails the render check and holds the page's
201
+ * publish, so a stored 10 draws at 12 rather than being refused: existing
202
+ * pages keep saving. Fields come from `themeWidgetStyles.fontSizeFields`, plus
203
+ * any `styleSchema` field whose `themeDefault` is a `typography.sizes` token;
204
+ * one the schema declares as a scale is left alone.
205
+ *
206
+ * @param {Record<string, unknown>} style — a validated style object.
207
+ * @param {object} [styleSchema] — the widget's declared style fields.
208
+ * @returns {Record<string, unknown>} the SAME object when nothing is below it.
209
+ */
210
+ export function floorStyleFontSizes(style, styleSchema) {
211
+ if (!isPlainObject(style)) return style;
212
+ const declared = isPlainObject(styleSchema) ? styleSchema : {};
213
+ let out = style;
214
+ for (const field of textSizeFields(declared)) {
215
+ const value = style[field];
216
+ if (typeof value !== "number" || !(value < CONTRACT.minFontPx)) continue;
217
+ if (declaresScale(declared[field])) continue;
218
+ if (out === style) out = { ...style };
219
+ out[field] = CONTRACT.minFontPx;
220
+ }
221
+ return out;
222
+ }
223
+
175
224
  /**
176
225
  * sc-5646: ONE widget's style fields, validated. The app-wide layer and a placed
177
226
  * node's `props.style` hold the SAME vocabulary at different scopes, so they must
@@ -199,7 +248,7 @@ export function normaliseWidgetStyleFields(raw, { maxFields } = {}) {
199
248
  out[field] = coerced;
200
249
  count += 1;
201
250
  }
202
- return out;
251
+ return floorStyleFontSizes(out);
203
252
  }
204
253
 
205
254
  /**
@@ -385,9 +434,11 @@ function withoutGeneralButtonPaint(manifestId, props, themed) {
385
434
  * as before — precedence: styleSchema default -> palette/`components.<scope>`
386
435
  * -> `widgetStyles[manifestId]` -> per-instance `props.style`.
387
436
  *
437
+ * sc-16875: a text size below `CONTRACT.minFontPx`, from any layer, renders at it.
438
+ *
388
439
  * Returns the SAME `props` reference when neither the theme nor the schema sets
389
- * anything for this widget, so an unthemed app with no declared style defaults
390
- * takes no extra render work and behaves exactly as it did before REQ-THEME-15.
440
+ * anything for this widget and no text size is below the floor, so an unthemed
441
+ * app with no declared style defaults takes no extra render work.
391
442
  *
392
443
  * @param {string} manifestId — the widget's canonical manifest id.
393
444
  * @param {object} theme — the resolved widget theme (`workspace.theme`); its
@@ -404,8 +455,12 @@ export function applyThemeComponentStyle(manifestId, theme, props, styleSchema)
404
455
  styleSchema,
405
456
  theme && theme.widgetStyles,
406
457
  );
407
- if (!themed) return props;
408
458
  const base = isPlainObject(props) ? props : {};
409
459
  const authored = isPlainObject(base.style) ? base.style : null;
410
- return { ...base, style: { ...withoutGeneralButtonPaint(manifestId, base, themed), ...authored } };
460
+ if (!themed) {
461
+ const floored = floorStyleFontSizes(authored, styleSchema);
462
+ return floored === authored ? props : { ...base, style: floored };
463
+ }
464
+ const style = { ...withoutGeneralButtonPaint(manifestId, base, themed), ...authored };
465
+ return { ...base, style: floorStyleFontSizes(style, styleSchema) };
411
466
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.327.0",
3
+ "version": "0.329.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
@@ -310,8 +310,8 @@ const THEME_TEXT_ROLE_FONT_WEIGHTS = Object.freeze([
310
310
  const THEME_TEXT_ROLE_FONT_STYLES = Object.freeze(["normal", "italic"]);
311
311
 
312
312
  // sc-16654 — the smallest page text the render check accepts (TEXT_TOO_SMALL
313
- // reads this value). The type scale and component font sizes clamp up to it on
314
- // both hosts and at save; a per-widget size is the author's own choice.
313
+ // reads this value). The type scale, component font sizes and a widget's own
314
+ // font-size style fields (sc-16875) clamp up to it on both hosts and at save.
315
315
  const MIN_FONT_PX = 12;
316
316
 
317
317
  // The per-role token vocabulary, declared like a `themeComponents` scope's
@@ -371,6 +371,9 @@ const THEME_WIDGET_STYLES = Object.freeze({
371
371
  // Nesting/width a structured value may reach before it is dropped.
372
372
  maxValueDepth: 3,
373
373
  maxValueEntries: 24,
374
+ // sc-16875: the style fields that size text, raised to `minFontPx`
375
+ // wherever a style is folded or saved.
376
+ fontSizeFields: Object.freeze(["fontSize", "titleSize", "fieldLabelSize"]),
374
377
  });
375
378
  // REQ-NAV-STRUCTURE: the SHAPE an app's navigation takes. One catalogue, four
376
379
  // consumers -- the Studio's Navigation page, Mason's set_theme coercion, the web
@@ -1296,6 +1299,8 @@ const HOOKS = [
1296
1299
  openLink: "(link: string) => boolean",
1297
1300
  goToStartPage:
1298
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).",
1299
1304
  scrollToSection:
1300
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.",
1301
1306
  scrollIntoView:
@@ -4445,7 +4450,7 @@ const WIDGET_CONTEXT_SHAPE = {
4445
4450
  },
4446
4451
  navigation: {
4447
4452
  description:
4448
- "{ 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.",
4449
4454
  required: true,
4450
4455
  fields: { push: "function", replace: "function", back: "function" },
4451
4456
  },
@@ -7043,7 +7048,14 @@ const CONTRACT = deepFreeze({
7043
7048
  // 1.266.0: behaviour (sc-16877) — a component's default texts (Select's
7044
7049
  // "Select", "Done", "No options", …) are in the app's language: English
7045
7050
  // and Swedish ship, any other language reads English.
7046
- version: "1.266.0",
7051
+ // 1.267.0: fix (sc-16875) — `themeWidgetStyles.fontSizeFields` names the
7052
+ // style fields that size text. A widget's own or app-wide value below
7053
+ // `minFontPx` renders and saves at it on both hosts.
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",
7047
7059
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
7048
7060
  hooks: HOOKS,
7049
7061
  primitives: PRIMITIVES,