@colixsystems/widget-sdk 0.319.1 → 0.319.2

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
@@ -90,7 +90,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
90
90
 
91
91
  ## Status
92
92
 
93
- `v0.319.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**.
93
+ `v0.319.2` — 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
+
95
+ ### What's new in 0.319.2 (contract 1.259.0)
96
+
97
+ **A danger button stays red when the app's button look gives every button a fill.** A `<Button variant="danger">` (and the built-in Button widget's Danger variant, the destructive `<ConfirmDialog>` confirm and a danger `<IconButton>`) took the Buttons fill, gradient, label and border colour, so a lime button look painted Delete lime too. Its colours now come only from Danger buttons (Design > Components) over the theme's danger colour; with no Danger buttons colours set it draws `theme.colors.danger`, never the general button fill. The Buttons corner radius, size and shadow still apply, and a colour you pass in `fields` or the maker sets on that button still wins. Hosts get the same rule from `applyThemeComponentStyle`, which leaves those four colours out of an `appstudio.button` whose `props.variant` is `"danger"`. The widget contract is unchanged.
94
98
 
95
99
  ### What's new in 0.319.1 (contract 1.259.0)
96
100
 
@@ -46,6 +46,7 @@ const CENTRED_OVER = {
46
46
  };
47
47
 
48
48
  // Precedence, weakest first: variant, danger scope, ring, then the fields.
49
+ // A danger button's fields hold no theme-wide button colour (the fold drops it).
49
50
  function containerLayers(variant, selected, f, colors, owned) {
50
51
  const paint = paintOnBackdrop(variant, variantPaint(variant, colors, selected), colors, owned);
51
52
  let ink = paint.ink;
@@ -86,7 +87,7 @@ function useButtonLook({ variant, selected, fields, hostThemed, style, labelStyl
86
87
  const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
87
88
  const folded = hostThemed
88
89
  ? fields || {}
89
- : applyThemeComponentStyle(THEMED_AS, theme, { style: fields }).style || {};
90
+ : applyThemeComponentStyle(THEMED_AS, theme, { variant, style: fields }).style || {};
90
91
  const f = isQuietLook(variant, selected) ? quietButtonFields(folded, fields) : folded;
91
92
  const owned = ownedButtonPaint(variant, f, flattenStyle(style), flattenStyle(labelStyle));
92
93
  const { layers, ink } = containerLayers(variant, selected, f, theme.colors, owned);
package/dist/host.d.ts CHANGED
@@ -123,6 +123,8 @@ export function normaliseWidgetStyles(raw: unknown): ThemeWidgetStyles;
123
123
  * palette/`components.<scope>` -> `widgetStyles[manifestId]` -> per-instance
124
124
  * `props.style`. Returns the same `props` reference when neither the theme nor
125
125
  * the schema sets anything. Applied by the platform hosts, never by authors.
126
+ * An `appstudio.button` whose `props.variant` is `"danger"` takes no general
127
+ * button colour (background, gradient, text, border) from the theme layers.
126
128
  */
127
129
  export function applyThemeComponentStyle<T = Record<string, unknown>>(
128
130
  manifestId: string,
@@ -363,6 +363,21 @@ function componentStyleFor(manifestId, components, styleSchema, widgetStyles) {
363
363
  return Object.keys(out).length > 0 ? out : null;
364
364
  }
365
365
 
366
+ // The general button colours a danger button never takes from the theme.
367
+ const GENERAL_BUTTON_PAINT = Object.freeze(["background", "gradient", "textColor", "borderColor"]);
368
+
369
+ /**
370
+ * A danger button is coloured by the `destructive` scope (its `danger*`
371
+ * fields) over the variant's danger colour, so the theme's general button
372
+ * colours are left out of its themed layer. Its own `props.style` still wins.
373
+ */
374
+ function withoutGeneralButtonPaint(manifestId, props, themed) {
375
+ if (manifestId !== "appstudio.button" || props.variant !== "danger") return themed;
376
+ const kept = { ...themed };
377
+ for (const field of GENERAL_BUTTON_PAINT) delete kept[field];
378
+ return kept;
379
+ }
380
+
366
381
  /**
367
382
  * Fold the widget's declared `styleSchema` defaults and the theme's
368
383
  * per-component tokens into a widget's props as `style` DEFAULTS. The author's
@@ -397,7 +412,7 @@ function applyThemeComponentStyle(manifestId, theme, props, styleSchema) {
397
412
  if (!themed) return props;
398
413
  const base = isPlainObject(props) ? props : {};
399
414
  const authored = isPlainObject(base.style) ? base.style : null;
400
- return { ...base, style: { ...themed, ...authored } };
415
+ return { ...base, style: { ...withoutGeneralButtonPaint(manifestId, base, themed), ...authored } };
401
416
  }
402
417
  module.exports = {
403
418
  coerceThemeColor,
@@ -358,6 +358,21 @@ function componentStyleFor(manifestId, components, styleSchema, widgetStyles) {
358
358
  return Object.keys(out).length > 0 ? out : null;
359
359
  }
360
360
 
361
+ // The general button colours a danger button never takes from the theme.
362
+ const GENERAL_BUTTON_PAINT = Object.freeze(["background", "gradient", "textColor", "borderColor"]);
363
+
364
+ /**
365
+ * A danger button is coloured by the `destructive` scope (its `danger*`
366
+ * fields) over the variant's danger colour, so the theme's general button
367
+ * colours are left out of its themed layer. Its own `props.style` still wins.
368
+ */
369
+ function withoutGeneralButtonPaint(manifestId, props, themed) {
370
+ if (manifestId !== "appstudio.button" || props.variant !== "danger") return themed;
371
+ const kept = { ...themed };
372
+ for (const field of GENERAL_BUTTON_PAINT) delete kept[field];
373
+ return kept;
374
+ }
375
+
361
376
  /**
362
377
  * Fold the widget's declared `styleSchema` defaults and the theme's
363
378
  * per-component tokens into a widget's props as `style` DEFAULTS. The author's
@@ -392,5 +407,5 @@ export function applyThemeComponentStyle(manifestId, theme, props, styleSchema)
392
407
  if (!themed) return props;
393
408
  const base = isPlainObject(props) ? props : {};
394
409
  const authored = isPlainObject(base.style) ? base.style : null;
395
- return { ...base, style: { ...themed, ...authored } };
410
+ return { ...base, style: { ...withoutGeneralButtonPaint(manifestId, base, themed), ...authored } };
396
411
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.319.1",
3
+ "version": "0.319.2",
4
4
  "description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
5
5
  "repository": {
6
6
  "type": "git",