@colixsystems/widget-sdk 0.107.0 → 0.108.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
@@ -17,7 +17,7 @@ The data layer lives in **four separate domain-client packages**, each instantia
17
17
 
18
18
  | Group | Hook (signature) | Returns | Reads / scope |
19
19
  | ----- | ---------------- | ------- | ------------- |
20
- | **CORE** | `useTheme()` | `{ colors, elevation, spacing, spacingScale, radii, typography, components, widgetStyles }` | `ctx.workspace.theme` — no scope. `elevation` is the shared depth scale (`none / sm / md / lg / xl`) you spread into a style; `colors` includes the accent's quiet tiers (`primarySoft` / `onPrimarySoft` / `primaryStrong`). `components` is HOST-OWNED (the theme's per-component style tokens); the host has already folded it into your `props.style`, so read `useWidgetStyle()` and ignore this slice. |
20
+ | **CORE** | `useTheme()` | `{ colors, elevation, spacing, spacingScale, radii, typography, components, widgetStyles }` | `ctx.workspace.theme` — no scope. `elevation` is the shared depth scale (`none / sm / md / lg / xl`) you spread into a style; `colors` includes the accent's quiet tiers (`primarySoft` / `onPrimarySoft` / `primaryStrong`) and `loader`, the spinner colour for your own loading state. `components` is HOST-OWNED (the theme's per-component style tokens); the host has already folded it into your `props.style`, so read `useWidgetStyle()` and ignore this slice. |
21
21
  | **CORE** | `useWorkspaceCurrency()` | `{ currency, formatMoney }` | `ctx.workspace.currency` — no scope. The currency this workspace charges its app users in, resolved at RENDER time. Render every price as `formatMoney(minorUnits)` and never write a currency symbol or code into a widget: the owner can change it after the widget ships, and a baked label then contradicts the charge. |
22
22
  | **CORE** | `useWidgetStyle()` | `{ [styleField]: value }` | `ctx.props.style` — no scope. The author-set per-widget style values declared in `manifest.styleSchema`; apply each onto whatever element you choose. |
23
23
  | **CORE** | `useUser()` | `{ id, email, displayName, roles, groupIds }` | `ctx.user` (host-built context, **camelCase** — not a wire payload; `id` null when anonymous) — no scope |
@@ -68,7 +68,20 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
68
68
 
69
69
  ## Status
70
70
 
71
- `v0.107.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**.
71
+ `v0.108.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**.
72
+
73
+ ### What's new in 0.108.0 (contract 1.82.0)
74
+
75
+ **`themeTokens.colors` gains `loader` — the surface's spinner colour (sc-6095).** A widget that drew its own loading state had no token for it, so it reached for a literal grey. On a dark theme that grey vanished into the background and the widget looked frozen rather than busy — the same bug the host's own loading holds had.
76
+
77
+ `loader` tracks `onSurfaceMuted`, which means it rides the existing REQ-THEME-SURFACE derivation: it flips light on a dark page background, and it re-derives for a container that paints its own dark fill, exactly like the text colours around it. So reading it is enough — there is nothing to branch on:
78
+
79
+ ```js
80
+ const t = useTheme();
81
+ if (loading) return <ActivityIndicator color={t.colors.loader} />;
82
+ ```
83
+
84
+ The workspace's *Design → Loading Indicator* panel can override it app-wide; unset, it stays derived. Additive — the full `colors` shape is now `{ primary, onPrimary, primarySoft, onPrimarySoft, primaryStrong, secondary, onSecondary, surface, onSurface, surfaceMuted, onSurfaceMuted, border, loader, danger, success, warning, info }`.
72
85
 
73
86
  ### What's new in 0.107.0 (contract 1.81.0)
74
87
 
@@ -388,7 +401,7 @@ Additive — one new hook, one new optional device capability, one new error cla
388
401
 
389
402
  - **The workspace theme now reaches the elements an app is built from.** Three things that used to be unreachable are now themeable: an element inside YOUR widget, the structural card container a page is made of, and any style field whose name the platform does not know. For a widget author the practical change is that **your `styleSchema` is the contract**: every field you declare becomes a knob the workspace owner can set once for the whole app, so declare the fields that describe your widget's appearance and give them clear `label`s and `ui.group`s — those labels are what the owner reads.
390
403
  - **A field name you invented is as reachable as a canonical one.** A theme may carry values keyed by your widget's manifest id and then by your own field names, so `panelFill` is adjustable app-wide exactly like `cardBackground`. Separately, the unambiguous card names (`cardBackground`, `cardBorderColor`, `cardRadius`, `cardPadding`, `cardGradient`) bind by NAME to any widget that declares them, so naming a genuine card surface canonically opts it into the workspace's Cards controls for free.
391
- - **`useTheme().colors` describes the surface your widget SITS ON, not the page.** A layout container that paints its own background re-derives the surface roles for everything inside it, so reading `colors.onSurface` for your text is readable whether your widget lands on the page, in a dark hero, or in a light card nested inside that hero. Nothing to opt into.
404
+ - **`useTheme().colors` describes the surface your widget SITS ON, not the page.** A layout container that paints its own background re-derives the surface roles for everything inside it, so reading `colors.onSurface` for your text is readable whether your widget lands on the page, in a dark hero, or in a light card nested inside that hero. `colors.loader` is that same surface's spinner colour — paint your loading state with it rather than a literal grey. Nothing to opt into.
392
405
  - **Precedence, unchanged in spirit.** Contract default → workspace palette → component scope → per-widget-type value → the app author's per-instance `props.style`. Most specific wins, and the Properties Panel is still the final word. Your widget reads `props.style` exactly as before and never learns which layer supplied a value.
393
406
  - **A colour may carry OPACITY.** `isHexColor` accepts the 8-digit `#RRGGBBAA` form alongside 3 and 6 digits, so a theme colour with an alpha reaches `useTheme()` with its transparency intact. It used to be rejected and the host dropped the key outright, which is why a translucent page background never reached the dark-surface derivation and every panel fell back to white.
394
407
  - **The colour maths ignores alpha, on purpose.** `hexChannels` reads the R/G/B pair and skips any alpha, so contrast, readable text and the derived accent tints reason about the opaque colour. None of them can composite without knowing the backdrop, which a token table does not have — so transparency lives in the VALUE your widget renders, not in the decision about whether that colour reads as light or dark.
package/dist/contract.cjs CHANGED
@@ -64,6 +64,11 @@ const DEFAULT_THEME_TOKENS = Object.freeze({
64
64
  onSurface: "#111827",
65
65
  surfaceMuted: "#f8fafc",
66
66
  onSurfaceMuted: "#475569",
67
+ // sc-6095: the colour a loading spinner is painted with. A spinner is a
68
+ // muted foreground mark on the surface it sits on, so it tracks
69
+ // `onSurfaceMuted`, which deriveSurfaceTokens already flips for a dark
70
+ // background — so a dark theme gets a visible spinner with no new maths.
71
+ loader: "#475569",
67
72
  border: "#e2e8f0",
68
73
  danger: "#dc2626",
69
74
  success: "#059669",
@@ -457,12 +462,13 @@ const HOOKS = [
457
462
  signature: "useTheme()",
458
463
  returnShape: {
459
464
  colors:
460
- "{ primary, onPrimary, secondary, onSecondary, surface, onSurface, surfaceMuted, onSurfaceMuted, border, danger, success, warning, info } — " +
465
+ "{ primary, onPrimary, secondary, onSecondary, surface, onSurface, surfaceMuted, onSurfaceMuted, border, loader, danger, success, warning, info } — " +
461
466
  "REQ-THEME-SURFACE: the surface group (surface / surfaceMuted / onSurface / " +
462
- "onSurfaceMuted / border) describes the surface your widget SITS ON, not the " +
467
+ "onSurfaceMuted / border / loader) describes the surface your widget SITS ON, not the " +
463
468
  "page: a container painting its own background re-derives them for its " +
464
469
  "subtree. Read them and your text is readable wherever the widget lands; " +
465
- "there is nothing to opt into.",
470
+ "there is nothing to opt into. `loader` is that surface's spinner colour " +
471
+ "(sc-6095) — paint your own loading state with it rather than a literal grey.",
466
472
  spacing: "{ xs, sm, md, lg, xl }",
467
473
  spacingScale:
468
474
  "number — the app-wide spacing multiplier (REQ-THEME-LOOK, default 1). " +
@@ -3326,7 +3332,16 @@ const CONTRACT = deepFreeze({
3326
3332
  // through the already-vetted react-native-svg and carries no native
3327
3333
  // module of its own, so it is host-shimmed on web and pinned in the
3328
3334
  // export like date-fns. No existing entry changed shape.
3329
- version: "1.81.0",
3335
+ //
3336
+ // 1.82.0: additive (sc-6095) — `themeTokens.colors` gains `loader`, the
3337
+ // colour a loading spinner is painted with, and `deriveSurfaceTokens`
3338
+ // returns it alongside the surface/text/border set. A spinner is a muted
3339
+ // foreground mark on the surface it sits on, so it tracks `onSurfaceMuted`
3340
+ // and inherits that set's dark-background flip — which is what makes a
3341
+ // dark theme's spinner visible instead of grey-on-grey.
3342
+ // `useTheme().colors.loader` is the value a widget reads for its own
3343
+ // loading state; both hosts paint their chrome spinners from the same key.
3344
+ version: "1.82.0",
3330
3345
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
3331
3346
  hooks: HOOKS,
3332
3347
  primitives: PRIMITIVES,
@@ -3511,7 +3526,7 @@ const DARK_SURFACE_TEXT = Object.freeze({
3511
3526
  * page, which is in turn what lets a built app follow its theme instead of
3512
3527
  * carrying a baked-in hex for every heading.
3513
3528
  *
3514
- * Returns all five keys together, never a subset: layering a dark card's text
3529
+ * Returns all six keys together, never a subset: layering a dark card's text
3515
3530
  * colour over a light ancestor's surface is exactly how light-on-light happens.
3516
3531
  * `null` only when the colour is unusable, letting the caller keep what it had.
3517
3532
  */
@@ -3528,6 +3543,7 @@ function deriveSurfaceTokens(backgroundColor) {
3528
3543
  surfaceMuted: base.surfaceMuted,
3529
3544
  onSurface: base.onSurface,
3530
3545
  onSurfaceMuted: base.onSurfaceMuted,
3546
+ loader: base.loader,
3531
3547
  border: base.border,
3532
3548
  };
3533
3549
  }
@@ -3536,6 +3552,7 @@ function deriveSurfaceTokens(backgroundColor) {
3536
3552
  surfaceMuted: mixHex(backgroundColor, "#ffffff", SURFACE_LIFT.surfaceMuted),
3537
3553
  onSurface: DARK_SURFACE_TEXT.onSurface,
3538
3554
  onSurfaceMuted: DARK_SURFACE_TEXT.onSurfaceMuted,
3555
+ loader: DARK_SURFACE_TEXT.onSurfaceMuted,
3539
3556
  border: mixHex(backgroundColor, "#ffffff", SURFACE_LIFT.border),
3540
3557
  };
3541
3558
  }
package/dist/contract.js CHANGED
@@ -64,6 +64,11 @@ const DEFAULT_THEME_TOKENS = Object.freeze({
64
64
  onSurface: "#111827",
65
65
  surfaceMuted: "#f8fafc",
66
66
  onSurfaceMuted: "#475569",
67
+ // sc-6095: the colour a loading spinner is painted with. A spinner is a
68
+ // muted foreground mark on the surface it sits on, so it tracks
69
+ // `onSurfaceMuted`, which deriveSurfaceTokens already flips for a dark
70
+ // background — so a dark theme gets a visible spinner with no new maths.
71
+ loader: "#475569",
67
72
  border: "#e2e8f0",
68
73
  danger: "#dc2626",
69
74
  success: "#059669",
@@ -457,12 +462,13 @@ const HOOKS = [
457
462
  signature: "useTheme()",
458
463
  returnShape: {
459
464
  colors:
460
- "{ primary, onPrimary, secondary, onSecondary, surface, onSurface, surfaceMuted, onSurfaceMuted, border, danger, success, warning, info } — " +
465
+ "{ primary, onPrimary, secondary, onSecondary, surface, onSurface, surfaceMuted, onSurfaceMuted, border, loader, danger, success, warning, info } — " +
461
466
  "REQ-THEME-SURFACE: the surface group (surface / surfaceMuted / onSurface / " +
462
- "onSurfaceMuted / border) describes the surface your widget SITS ON, not the " +
467
+ "onSurfaceMuted / border / loader) describes the surface your widget SITS ON, not the " +
463
468
  "page: a container painting its own background re-derives them for its " +
464
469
  "subtree. Read them and your text is readable wherever the widget lands; " +
465
- "there is nothing to opt into.",
470
+ "there is nothing to opt into. `loader` is that surface's spinner colour " +
471
+ "(sc-6095) — paint your own loading state with it rather than a literal grey.",
466
472
  spacing: "{ xs, sm, md, lg, xl }",
467
473
  spacingScale:
468
474
  "number — the app-wide spacing multiplier (REQ-THEME-LOOK, default 1). " +
@@ -3326,7 +3332,16 @@ const CONTRACT = deepFreeze({
3326
3332
  // through the already-vetted react-native-svg and carries no native
3327
3333
  // module of its own, so it is host-shimmed on web and pinned in the
3328
3334
  // export like date-fns. No existing entry changed shape.
3329
- version: "1.81.0",
3335
+ //
3336
+ // 1.82.0: additive (sc-6095) — `themeTokens.colors` gains `loader`, the
3337
+ // colour a loading spinner is painted with, and `deriveSurfaceTokens`
3338
+ // returns it alongside the surface/text/border set. A spinner is a muted
3339
+ // foreground mark on the surface it sits on, so it tracks `onSurfaceMuted`
3340
+ // and inherits that set's dark-background flip — which is what makes a
3341
+ // dark theme's spinner visible instead of grey-on-grey.
3342
+ // `useTheme().colors.loader` is the value a widget reads for its own
3343
+ // loading state; both hosts paint their chrome spinners from the same key.
3344
+ version: "1.82.0",
3330
3345
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
3331
3346
  hooks: HOOKS,
3332
3347
  primitives: PRIMITIVES,
@@ -3511,7 +3526,7 @@ const DARK_SURFACE_TEXT = Object.freeze({
3511
3526
  * page, which is in turn what lets a built app follow its theme instead of
3512
3527
  * carrying a baked-in hex for every heading.
3513
3528
  *
3514
- * Returns all five keys together, never a subset: layering a dark card's text
3529
+ * Returns all six keys together, never a subset: layering a dark card's text
3515
3530
  * colour over a light ancestor's surface is exactly how light-on-light happens.
3516
3531
  * `null` only when the colour is unusable, letting the caller keep what it had.
3517
3532
  */
@@ -3528,6 +3543,7 @@ function deriveSurfaceTokens(backgroundColor) {
3528
3543
  surfaceMuted: base.surfaceMuted,
3529
3544
  onSurface: base.onSurface,
3530
3545
  onSurfaceMuted: base.onSurfaceMuted,
3546
+ loader: base.loader,
3531
3547
  border: base.border,
3532
3548
  };
3533
3549
  }
@@ -3536,6 +3552,7 @@ function deriveSurfaceTokens(backgroundColor) {
3536
3552
  surfaceMuted: mixHex(backgroundColor, "#ffffff", SURFACE_LIFT.surfaceMuted),
3537
3553
  onSurface: DARK_SURFACE_TEXT.onSurface,
3538
3554
  onSurfaceMuted: DARK_SURFACE_TEXT.onSurfaceMuted,
3555
+ loader: DARK_SURFACE_TEXT.onSurfaceMuted,
3539
3556
  border: mixHex(backgroundColor, "#ffffff", SURFACE_LIFT.border),
3540
3557
  };
3541
3558
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.107.0",
3
+ "version": "0.108.0",
4
4
  "description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",