@acorex/platform 21.0.0-next.59 → 21.0.0-next.63

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.
@@ -1671,21 +1671,6 @@ function hexToRgb(hex) {
1671
1671
  parseInt(full.slice(4, 6), 16),
1672
1672
  ];
1673
1673
  }
1674
- function rgbToHex(r, g, b) {
1675
- const clamp = (n) => Math.max(0, Math.min(255, Math.round(n)));
1676
- return `#${[clamp(r), clamp(g), clamp(b)]
1677
- .map((c) => c.toString(16).padStart(2, '0'))
1678
- .join('')}`;
1679
- }
1680
- /**
1681
- * Linear RGB mix: ratio 0 → `from`, ratio 1 → `to`.
1682
- */
1683
- function mixHex(from, to, ratio) {
1684
- const t = Math.max(0, Math.min(1, ratio));
1685
- const [r0, g0, b0] = hexToRgb(from);
1686
- const [r1, g1, b1] = hexToRgb(to);
1687
- return rgbToHex(r0 + (r1 - r0) * t, g0 + (g1 - g0) * t, b0 + (b1 - b0) * t);
1688
- }
1689
1674
  function relativeLuminance(hex) {
1690
1675
  const [r, g, b] = hexToRgb(hex).map((c) => {
1691
1676
  const s = c / 255;
@@ -1706,28 +1691,6 @@ function titleCase(str) {
1706
1691
  * canvas `light` and `dark` as poles so swatches stay aligned with `AXPThemePaletteProvider` data.
1707
1692
  */
1708
1693
  const SURFACE_VARIANTS = ['lightest', 'lighter', 'light', 'surface', 'dark', 'darker', 'darkest'];
1709
- function tonalBackgroundHex(base, variant, canvas) {
1710
- switch (variant) {
1711
- case 'lightest':
1712
- return mixHex(base, canvas.light, 0.85);
1713
- case 'lighter':
1714
- return mixHex(base, canvas.light, 0.62);
1715
- case 'light':
1716
- return mixHex(base, canvas.light, 0.38);
1717
- case 'surface':
1718
- return base;
1719
- case 'dark':
1720
- return mixHex(base, canvas.dark, 0.35);
1721
- case 'darker':
1722
- return mixHex(base, canvas.dark, 0.58);
1723
- case 'darkest':
1724
- return mixHex(base, canvas.dark, 0.8);
1725
- default: {
1726
- const _exhaustive = variant;
1727
- return _exhaustive;
1728
- }
1729
- }
1730
- }
1731
1694
  function styleTitlePrefix(style) {
1732
1695
  const accentMatch = /^accent(\d+)$/.exec(style);
1733
1696
  if (accentMatch) {
@@ -1741,17 +1704,26 @@ function surfaceVariantTitle(style, variant) {
1741
1704
  }
1742
1705
  return `${styleTitlePrefix(style)} ${titleCase(variant)}`;
1743
1706
  }
1744
- function pushVariantScale(entries, styleKey, baseHex, canvas) {
1707
+ /** Tailwind utility triplet stored by theme-color-chooser and outcome display rules. */
1708
+ function buildThemeSurfaceColorTriplet(styleKey, variant) {
1709
+ return {
1710
+ color: `ax-text-${styleKey}-on-${variant}`,
1711
+ background: `ax-bg-${styleKey}-${variant}`,
1712
+ border: `ax-border-${styleKey}-${variant}`,
1713
+ };
1714
+ }
1715
+ /** Ordered `"foreground background border"` string for theme-color-chooser values. */
1716
+ function buildThemeSurfaceColorValue(styleKey, variant = 'lightest') {
1717
+ const triplet = buildThemeSurfaceColorTriplet(styleKey, variant);
1718
+ return `${triplet.color} ${triplet.background} ${triplet.border}`;
1719
+ }
1720
+ function pushVariantScale(entries, styleKey, _baseHex, _canvas) {
1745
1721
  for (const variant of SURFACE_VARIANTS) {
1746
- const background = tonalBackgroundHex(baseHex, variant, canvas);
1747
- const color = contrastForeground(background);
1748
1722
  const name = `${styleKey}-${variant}`;
1749
1723
  entries.push({
1750
1724
  title: surfaceVariantTitle(styleKey, variant),
1751
1725
  name,
1752
- color,
1753
- background,
1754
- border: background,
1726
+ ...buildThemeSurfaceColorTriplet(styleKey, variant),
1755
1727
  });
1756
1728
  }
1757
1729
  }
@@ -1861,11 +1833,21 @@ class AXPColorChooserWidgetEditComponent extends AXPValueWidgetComponent {
1861
1833
  return null;
1862
1834
  }
1863
1835
  const [color, background, border] = parts;
1864
- const match = this.colors().find((c) => c.color === color && c.background === background && c.border === border);
1865
- return match?.name ?? null;
1836
+ const exactMatch = this.colors().find((entry) => entry.color === color && entry.background === background && entry.border === border);
1837
+ if (exactMatch) {
1838
+ return exactMatch.name;
1839
+ }
1840
+ const backgroundMatch = /^ax-bg-(.+)-(.+)$/.exec(background);
1841
+ if (backgroundMatch) {
1842
+ const name = `${backgroundMatch[1]}-${backgroundMatch[2]}`;
1843
+ if (this.colors().some((entry) => entry.name === name)) {
1844
+ return name;
1845
+ }
1846
+ }
1847
+ return null;
1866
1848
  }
1867
1849
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPColorChooserWidgetEditComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1868
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: AXPColorChooserWidgetEditComponent, isStandalone: true, selector: "ax-color-chooser-widget", usesInheritance: true, ngImport: i0, template: `
1850
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: AXPColorChooserWidgetEditComponent, isStandalone: true, selector: "ax-color-chooser-widget", host: { classAttribute: "ax-block ax-flex-1 ax-w-full" }, usesInheritance: true, ngImport: i0, template: `
1869
1851
  <ax-form [messageStyle]="'float'" [updateOn]="'change'">
1870
1852
  <ax-form-field>
1871
1853
  <ax-select-box
@@ -1952,6 +1934,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
1952
1934
  </ax-form-field>
1953
1935
  </ax-form>
1954
1936
  `,
1937
+ host: {
1938
+ class: 'ax-block ax-flex-1 ax-w-full',
1939
+ },
1955
1940
  imports: [AXSelectBoxModule, AXFormModule, CommonModule, AXSearchBoxModule, AXButtonModule, FormsModule],
1956
1941
  changeDetection: ChangeDetectionStrategy.OnPush,
1957
1942
  }]