@fluid-app/portal-sdk 0.1.199 → 0.1.200

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.
Files changed (62) hide show
  1. package/dist/{ContactsScreen-Cheiwaxn.cjs → ContactsScreen-BOMxeTG8.cjs} +2 -2
  2. package/dist/{ContactsScreen-BtBNMZzG.mjs → ContactsScreen-Bm9SlMY3.mjs} +17 -7
  3. package/dist/ContactsScreen-Bm9SlMY3.mjs.map +1 -0
  4. package/dist/{ContactsScreen-DvohvoOE.cjs → ContactsScreen-DflUjayA.cjs} +291 -281
  5. package/dist/ContactsScreen-DflUjayA.cjs.map +1 -0
  6. package/dist/{FluidProvider-D177ez3m.cjs → FluidProvider-ByBDIQeW.cjs} +6 -986
  7. package/dist/FluidProvider-ByBDIQeW.cjs.map +1 -0
  8. package/dist/{FluidProvider-DiJy4Zve.mjs → FluidProvider-DFZiXiqm.mjs} +3 -814
  9. package/dist/FluidProvider-DFZiXiqm.mjs.map +1 -0
  10. package/dist/{MessagingScreen-Cu3tcpPs.mjs → MessagingScreen-D6d83q2n.mjs} +2 -2
  11. package/dist/{MessagingScreen-Cu3tcpPs.mjs.map → MessagingScreen-D6d83q2n.mjs.map} +1 -1
  12. package/dist/{MessagingScreen-Ysi48svi.cjs → MessagingScreen-HT_HSiNW.cjs} +3 -3
  13. package/dist/{MessagingScreen-gKidMcrr.cjs → MessagingScreen-shEWzTmQ.cjs} +2 -2
  14. package/dist/{MessagingScreen-gKidMcrr.cjs.map → MessagingScreen-shEWzTmQ.cjs.map} +1 -1
  15. package/dist/{PortalContentApiProvider-CWRAw9kL.mjs → PortalContentApiProvider-CNYq1_OD.mjs} +114 -88
  16. package/dist/PortalContentApiProvider-CNYq1_OD.mjs.map +1 -0
  17. package/dist/{PortalContentApiProvider-CPnqELEX.cjs → PortalContentApiProvider-ChmcXmbv.cjs} +113 -87
  18. package/dist/PortalContentApiProvider-ChmcXmbv.cjs.map +1 -0
  19. package/dist/{ProductsScreen-Al6H4ujs.mjs → ProductsScreen-CDjpHF49.mjs} +2 -2
  20. package/dist/{ProductsScreen-Al6H4ujs.mjs.map → ProductsScreen-CDjpHF49.mjs.map} +1 -1
  21. package/dist/{ProductsScreen-CQ5-A8AL.cjs → ProductsScreen-CzfDX0xx.cjs} +2 -2
  22. package/dist/{ProductsScreen-CQ5-A8AL.cjs.map → ProductsScreen-CzfDX0xx.cjs.map} +1 -1
  23. package/dist/{ProductsScreen-CexZ0gx9.mjs → ProductsScreen-D6-ehQjh.mjs} +2 -2
  24. package/dist/{ProductsScreen-BnwMOZ4-.cjs → ProductsScreen-fN3fh3PB.cjs} +2 -2
  25. package/dist/{ProfileScreen-DJZoMzE6.cjs → ProfileScreen-B0EU-TLa.cjs} +101 -101
  26. package/dist/{ProfileScreen-DJZoMzE6.cjs.map → ProfileScreen-B0EU-TLa.cjs.map} +1 -1
  27. package/dist/{ProfileScreen-hE1S_99P.mjs → ProfileScreen-BIs70k9W.mjs} +3 -3
  28. package/dist/{ProfileScreen-hE1S_99P.mjs.map → ProfileScreen-BIs70k9W.mjs.map} +1 -1
  29. package/dist/{ProfileScreen-CGS7YkcT.cjs → ProfileScreen-Dqu2nK_2.cjs} +3 -3
  30. package/dist/{ShareablesScreen-CzTU7e0l.mjs → ShareablesScreen-B8rPq-_7.mjs} +2 -2
  31. package/dist/{ShareablesScreen-CzTU7e0l.mjs.map → ShareablesScreen-B8rPq-_7.mjs.map} +1 -1
  32. package/dist/{ShareablesScreen-DujtMoAi.cjs → ShareablesScreen-DFLAJxjs.cjs} +2 -2
  33. package/dist/{ShareablesScreen-CmZ5CX99.cjs → ShareablesScreen-DLXK1PAg.cjs} +2 -2
  34. package/dist/{ShareablesScreen-CmZ5CX99.cjs.map → ShareablesScreen-DLXK1PAg.cjs.map} +1 -1
  35. package/dist/{ShareablesScreen-yscAsNpq.mjs → ShareablesScreen-Dc57L9m8.mjs} +2 -2
  36. package/dist/{ShopScreen-Bdo59te-.mjs → ShopScreen-2yMsyFwk.mjs} +2 -2
  37. package/dist/{ShopScreen-Bdo59te-.mjs.map → ShopScreen-2yMsyFwk.mjs.map} +1 -1
  38. package/dist/{ShopScreen-DKlDKNom.cjs → ShopScreen-BmHSLZ7H.cjs} +2 -2
  39. package/dist/{ShopScreen-DKlDKNom.cjs.map → ShopScreen-BmHSLZ7H.cjs.map} +1 -1
  40. package/dist/{ShopScreen-R9zk7d5d.cjs → ShopScreen-kk4yLzrW.cjs} +3 -3
  41. package/dist/index.cjs +67 -67
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +132 -128
  44. package/dist/index.d.cts.map +1 -1
  45. package/dist/index.d.mts +132 -128
  46. package/dist/index.d.mts.map +1 -1
  47. package/dist/index.mjs +21 -21
  48. package/dist/src-BRTXunU1.mjs +851 -0
  49. package/dist/src-BRTXunU1.mjs.map +1 -0
  50. package/dist/src-DvVPCD01.cjs +1038 -0
  51. package/dist/src-DvVPCD01.cjs.map +1 -0
  52. package/package.json +16 -16
  53. package/dist/ContactsScreen-BtBNMZzG.mjs.map +0 -1
  54. package/dist/ContactsScreen-DvohvoOE.cjs.map +0 -1
  55. package/dist/FluidProvider-D177ez3m.cjs.map +0 -1
  56. package/dist/FluidProvider-DiJy4Zve.mjs.map +0 -1
  57. package/dist/PortalContentApiProvider-CPnqELEX.cjs.map +0 -1
  58. package/dist/PortalContentApiProvider-CWRAw9kL.mjs.map +0 -1
  59. package/dist/countries-api-context-Dob_AzPO.mjs +0 -13
  60. package/dist/countries-api-context-Dob_AzPO.mjs.map +0 -1
  61. package/dist/countries-api-context-G-NW4BoH.cjs +0 -25
  62. package/dist/countries-api-context-G-NW4BoH.cjs.map +0 -1
@@ -2,7 +2,7 @@ import { d as DataSourceApiProvider, l as RegistryProvider } from "./ScreenRende
2
2
  import { t as AccountApiProvider } from "./account-api-context-BIZ_aibJ.mjs";
3
3
  import { t as StoreApiProvider } from "./store-api-context-C1lXT_3d.mjs";
4
4
  import { t as MySiteApiProvider } from "./mysite-api-context-bXtZ8Gbm.mjs";
5
- import { t as CountriesApiProvider } from "./countries-api-context-Dob_AzPO.mjs";
5
+ import { A as CountriesApiProvider, r as removeTheme, t as applyTheme, w as resolveTheme } from "./src-BRTXunU1.mjs";
6
6
  import { T as todos_list, a as enrollment_pack_metrics_share_visits, c as orders_list, d as product_metrics_visits, f as products_list, g as store_show, h as products_show, i as calendar_events_list, n as account_update, o as enrollment_pack_metrics_visits, r as app_manifest_show, s as enrollment_packs_show, t as account_show, u as product_metrics_share_visits, v as subscriptions_list } from "./portal_tenant-8RPVJCll.mjs";
7
7
  import { S as pages_show, a as content_playlists_metrics_share_visits, b as media_show, i as content_pages_metrics_visits, k as playlists_show, n as content_media_metrics_visits, o as content_playlists_metrics_visits, r as content_pages_metrics_share_visits, t as content_media_metrics_share_visits } from "./portal_tenant_content-DzIQtSLE.mjs";
8
8
  import { n as usePortalTenantClient, t as PortalTenantClientProvider } from "./PortalTenantClientProvider-4ZmY6hac.mjs";
@@ -35,7 +35,6 @@ import { t as VideoWidget } from "./VideoWidget-BdXJhiPF.mjs";
35
35
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
36
36
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
37
37
  import { jsx } from "react/jsx-runtime";
38
- import Color from "colorjs.io";
39
38
  //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.90.12/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
40
39
  var defaultTimeoutProvider = {
41
40
  setTimeout: (callback, delay) => setTimeout(callback, delay),
@@ -1570,816 +1569,6 @@ function createMySiteApiAdapter(client) {
1570
1569
  };
1571
1570
  }
1572
1571
  //#endregion
1573
- //#region ../core/src/theme/types.ts
1574
- const SEMANTIC_COLOR_NAMES = [
1575
- "background",
1576
- "foreground",
1577
- "primary",
1578
- "secondary",
1579
- "accent",
1580
- "muted",
1581
- "destructive"
1582
- ];
1583
- const SHADE_STEPS = [
1584
- 100,
1585
- 200,
1586
- 300,
1587
- 400,
1588
- 500,
1589
- 600,
1590
- 700,
1591
- 800,
1592
- 900
1593
- ];
1594
- const FONT_SIZE_KEYS = [
1595
- "extraSmall",
1596
- "small",
1597
- "regular",
1598
- "large",
1599
- "extraLarge",
1600
- "giant"
1601
- ];
1602
- const FONT_FAMILY_KEYS = ["header", "body"];
1603
- const RADIUS_KEYS = [
1604
- "small",
1605
- "medium",
1606
- "large",
1607
- "extraLarge"
1608
- ];
1609
- //#endregion
1610
- //#region ../core/src/theme/color-engine.ts
1611
- /**
1612
- * Attempt to convert any string into a Color using colorjs.io.
1613
- * If the string is exactly 6 characters it is assumed to be a bare hex value
1614
- * (e.g. "3b82f6") and a "#" prefix is added before parsing.
1615
- *
1616
- * @returns the parsed Color, or a neutral gray (`oklch(0.5 0 0)`) on failure
1617
- */
1618
- function parseColor(value) {
1619
- if (value.length === 6) value = `#${value}`;
1620
- try {
1621
- return new Color(value);
1622
- } catch (error) {
1623
- console.warn("[theme] Failed to parse color:", value, error);
1624
- return new Color("oklch", [
1625
- .5,
1626
- 0,
1627
- 0
1628
- ]);
1629
- }
1630
- }
1631
- /**
1632
- * Returns either the original foreground or a corrected lightness variant,
1633
- * whichever provides better contrast against `color`.
1634
- * Inversion triggers when the APCA contrast is below 50.
1635
- */
1636
- function getForegroundColor(foreground, color) {
1637
- if (foreground.oklch.l == null || color.oklch.l == null) return foreground;
1638
- if (color.contrastAPCA(foreground) < 50) return new Color("oklch", [
1639
- color.oklch.l < .7 ? .95 : .15,
1640
- foreground.oklch.c || 0,
1641
- foreground.oklch.h || 0
1642
- ]);
1643
- return foreground;
1644
- }
1645
- /**
1646
- * Generate a 100–900 shade ramp from a base color.
1647
- * Base anchors at 500. Light shades (100–400) step toward white,
1648
- * dark shades (600–900) step toward black. Dark steps use an asymmetric
1649
- * multiplier (1.6×, 1.875×, 3×, 4× of `darkStep`) for a more gradual
1650
- * initial descent. Chroma is nudged per step for perceptually natural ramps.
1651
- */
1652
- function generateShades(base) {
1653
- const l = base.oklch.l ?? 0;
1654
- const c = base.oklch.c ?? 0;
1655
- const h = base.oklch.h ?? 0;
1656
- const safeMax = l >= .885 ? .995 : .97;
1657
- const safeMin = l <= .33 ? 0 : .21;
1658
- const lightStep = (safeMax - l) / 5;
1659
- const darkStep = -(l - safeMin) / 8;
1660
- const shade = (lDelta, cDelta) => {
1661
- return new Color("oklch", [
1662
- Math.max(0, Math.min(1, l + lDelta)),
1663
- c <= .001 ? c : Math.max(0, c + cDelta),
1664
- h
1665
- ]);
1666
- };
1667
- return {
1668
- 100: shade(5 * lightStep, -.00375),
1669
- 200: shade(4 * lightStep, -.00375),
1670
- 300: shade(3 * lightStep, -.00375),
1671
- 400: shade(2 * lightStep, -.00375),
1672
- 500: new Color("oklch", [
1673
- l,
1674
- c,
1675
- h
1676
- ]),
1677
- 600: shade(1.6 * darkStep, .025),
1678
- 700: shade(1.875 * 2 * darkStep, .05),
1679
- 800: shade(6 * darkStep, .075),
1680
- 900: shade(8 * darkStep, .1)
1681
- };
1682
- }
1683
- const DARK_DERIVATION_CONFIG = {
1684
- background: {
1685
- baseLightness: .15,
1686
- fgLightness: .93
1687
- },
1688
- foreground: {
1689
- baseLightness: .93,
1690
- fgLightness: .15
1691
- },
1692
- muted: {
1693
- baseLightness: .22,
1694
- fgLightness: .75
1695
- },
1696
- primary: {
1697
- baseLightness: "invert",
1698
- fgLightness: .95,
1699
- chromaScale: .9
1700
- },
1701
- secondary: {
1702
- baseLightness: "invert",
1703
- fgLightness: .93,
1704
- chromaScale: .85
1705
- },
1706
- accent: {
1707
- baseLightness: "invert",
1708
- fgLightness: .95,
1709
- chromaScale: .9
1710
- },
1711
- destructive: {
1712
- baseLightness: "invert",
1713
- fgLightness: .95,
1714
- chromaScale: .95
1715
- }
1716
- };
1717
- /** Invert OKLCH lightness (1 - l), clamped to [0.35, 0.75] to avoid extremes. */
1718
- function invertLightness(l) {
1719
- const inverted = 1 - l;
1720
- return Math.max(.35, Math.min(.75, inverted));
1721
- }
1722
- /**
1723
- * Derive a dark-mode ThemeColorInput from its light-mode counterpart.
1724
- */
1725
- function deriveDarkVariant(name, light) {
1726
- const config = DARK_DERIVATION_CONFIG[name];
1727
- const chromaScale = config.chromaScale ?? 1;
1728
- const baseLightness = config.baseLightness === "invert" ? invertLightness(light.base.oklch.l ?? 0) : config.baseLightness;
1729
- const fgLightness = config.fgLightness === "invert" ? invertLightness(light.foreground.oklch.l ?? 0) : config.fgLightness;
1730
- return {
1731
- base: new Color("oklch", [
1732
- baseLightness,
1733
- (light.base.oklch.c || 0) * chromaScale,
1734
- light.base.oklch.h || 0
1735
- ]),
1736
- foreground: new Color("oklch", [
1737
- fgLightness,
1738
- (light.foreground.oklch.c || 0) * chromaScale,
1739
- light.foreground.oklch.h || 0
1740
- ])
1741
- };
1742
- }
1743
- /**
1744
- * Merge auto-derived dark colors with any user-specified overrides.
1745
- * For each semantic color, if the user has fully overridden both base and
1746
- * foreground those are used; otherwise the missing channels are derived.
1747
- */
1748
- function mergeDarkOverrides(def) {
1749
- const darkColors = {};
1750
- for (const name of SEMANTIC_COLOR_NAMES) {
1751
- const lightInput = def.light[name];
1752
- const darkOverride = def.dark[name];
1753
- if (darkOverride?.base && darkOverride?.foreground) darkColors[name] = darkOverride;
1754
- else if (darkOverride) {
1755
- const base = darkOverride.base ?? deriveDarkVariant(name, lightInput).base;
1756
- darkColors[name] = {
1757
- base,
1758
- foreground: darkOverride.foreground ?? getForegroundColor(def.light.foreground.base, base)
1759
- };
1760
- } else darkColors[name] = deriveDarkVariant(name, lightInput);
1761
- }
1762
- return darkColors;
1763
- }
1764
- function resolveColorSet(colors) {
1765
- const resolved = {};
1766
- for (const name of SEMANTIC_COLOR_NAMES) {
1767
- const input = colors[name];
1768
- const shades = generateShades(input.base);
1769
- const resolvedShades = {};
1770
- for (const step of SHADE_STEPS) resolvedShades[step] = shades[step];
1771
- resolved[name] = {
1772
- base: input.base.clone(),
1773
- foreground: input.foreground.clone(),
1774
- shades: resolvedShades
1775
- };
1776
- }
1777
- return resolved;
1778
- }
1779
- /**
1780
- * Resolve a ThemeDefinition into a complete ResolvedTheme.
1781
- * Dark mode colors are derived from light where not overridden.
1782
- */
1783
- function resolveTheme(def) {
1784
- return {
1785
- id: def.id,
1786
- name: def.name,
1787
- light: resolveColorSet(def.light),
1788
- dark: resolveColorSet(mergeDarkOverrides(def)),
1789
- fontSizes: { ...def.fontSizes },
1790
- fontFamilies: { ...def.fontFamilies },
1791
- spacing: def.spacing,
1792
- radii: { ...def.radii }
1793
- };
1794
- }
1795
- //#endregion
1796
- //#region ../core/src/theme/tailwind-overrides.ts
1797
- /**
1798
- * Specific overrides, otherwise all the overrides are generated using emitTailwindOverrides
1799
- */
1800
- const OVERRIDES = {
1801
- "--color-gray-50": "var(--color-muted)",
1802
- "--color-gray-100": "var(--color-muted-600)",
1803
- "--color-gray-200": "var(--color-border)"
1804
- };
1805
- /**
1806
- * Returns the inverted shade for dark mode foreground colors.
1807
- * In dark mode, light shades (50, 100) should map to dark values (950, 900) and vice versa.
1808
- */
1809
- function getInvertedStep(shade) {
1810
- const shadeIndex = SHADE_STEPS.indexOf(shade);
1811
- return SHADE_STEPS[SHADE_STEPS.length - 1 - shadeIndex] || 500;
1812
- }
1813
- /**
1814
- * Map semantic colors to Tailwind built-in color names.
1815
- */
1816
- function emitTailwindOverrides(darkMode = false) {
1817
- const TAILWIND_COLOR_MAP = {
1818
- gray: "foreground",
1819
- red: "destructive",
1820
- blue: "primary",
1821
- green: "accent"
1822
- };
1823
- const TAILWIND_SHADES = [
1824
- 50,
1825
- 100,
1826
- 200,
1827
- 300,
1828
- 400,
1829
- 500,
1830
- 600,
1831
- 700,
1832
- 800,
1833
- 900,
1834
- 950
1835
- ];
1836
- const SHADE_REMAP = {
1837
- 50: 100,
1838
- 950: 900
1839
- };
1840
- const lines = [];
1841
- for (const [twName, semantic] of Object.entries(TAILWIND_COLOR_MAP)) for (const shade of TAILWIND_SHADES) {
1842
- const step = SHADE_REMAP[shade] ?? shade;
1843
- const override = OVERRIDES[`--color-${twName}-${shade}`];
1844
- lines.push(`--color-${twName}-${shade}: ${override ? override : `var(--color-${semantic}-${semantic === "foreground" && darkMode === true ? getInvertedStep(step) : step})`};`);
1845
- }
1846
- lines.push("--color-white: var(--color-background);");
1847
- lines.push("--color-black: var(--color-foreground);");
1848
- return lines;
1849
- }
1850
- //#endregion
1851
- //#region ../core/src/theme/css-generator.ts
1852
- function colorToCSS(color) {
1853
- const result = color.toString({ format: "oklch" });
1854
- if (result.includes("NaN")) {
1855
- console.warn("[theme] colorToCSS produced NaN, using neutral fallback:", result);
1856
- return "oklch(0.5 0 0)";
1857
- }
1858
- return result;
1859
- }
1860
- function camelToKebab(str) {
1861
- return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1862
- }
1863
- /**
1864
- * Emit --color-{name}, --color-{name}-foreground, --color-{name}-{shade} vars.
1865
- * Uses --color- prefix to match portal-widgets/tailwind.config.ts.
1866
- */
1867
- function emitColorVars(colors) {
1868
- const lines = [];
1869
- for (const name of SEMANTIC_COLOR_NAMES) {
1870
- const color = colors[name];
1871
- lines.push(`--color-${name}: ${colorToCSS(color.base)};`);
1872
- lines.push(`--color-${name}-foreground: ${colorToCSS(color.foreground)};`);
1873
- for (const step of SHADE_STEPS) lines.push(`--color-${name}-${step}: ${colorToCSS(color.shades[step])};`);
1874
- }
1875
- return lines;
1876
- }
1877
- /**
1878
- * Format a font family value for CSS output.
1879
- * - If the value starts with "var(" (legacy), pass through as-is
1880
- * - If the value already contains a comma (has fallback), pass through as-is
1881
- * - Otherwise, wrap in quotes and append a generic sans-serif fallback
1882
- */
1883
- function formatFontFamily(value) {
1884
- if (value.startsWith("var(")) return value;
1885
- if (value.includes(",")) return value;
1886
- return `'${value}', sans-serif`;
1887
- }
1888
- /**
1889
- * Emit non-color CSS variables (font sizes, families, spacing, radii).
1890
- */
1891
- function emitNonColorVars(theme) {
1892
- const lines = [];
1893
- for (const key of FONT_SIZE_KEYS) lines.push(`--font-size-${camelToKebab(key)}: ${theme.fontSizes[key]};`);
1894
- for (const key of FONT_FAMILY_KEYS) lines.push(`--font-${key}: ${formatFontFamily(theme.fontFamilies[key])};`);
1895
- lines.push(`--spacing: ${theme.spacing};`);
1896
- for (const key of RADIUS_KEYS) lines.push(`--radius-${camelToKebab(key)}: ${theme.radii[key]};`);
1897
- return lines;
1898
- }
1899
- /**
1900
- * Static CSS alias variables that bridge theme var names to Tailwind/component conventions.
1901
- * These are always emitted and not mode-dependent.
1902
- */
1903
- const globalCSSOverride = [
1904
- "--color-background-foreground: var(--color-foreground);",
1905
- "--color-foreground-foreground: var(--color-background);",
1906
- "--color-contrast: var(--color-foreground);",
1907
- ...SEMANTIC_COLOR_NAMES.map((value) => `--${value}: var(--color-${value});`),
1908
- ...SEMANTIC_COLOR_NAMES.map((value) => `--${value}-foreground: var(--color-${value}-foreground);`),
1909
- "--sidebar-ring: var(--color-primary);",
1910
- "--sidebar-border: var(--color-border);",
1911
- "--sidebar-accent-foreground: var(--color-accent-foreground);",
1912
- "--sidebar-accent: var(--color-accent);",
1913
- "--sidebar-primary-foreground: var(--color-primary-foreground);",
1914
- "--sidebar-primary: var(--color-primary);",
1915
- "--sidebar-foreground: var(--color-muted-foreground);",
1916
- "--sidebar: var(--color-muted);",
1917
- "--border: var(--color-background-600);",
1918
- "--ring: var(--color-primary);",
1919
- "--popover: var(--color-background);",
1920
- "--popover-foreground: var(--color-foreground);",
1921
- "--card: var(--color-muted);",
1922
- "--card-foreground: var(--color-muted-foreground);",
1923
- "--radius-sm: var(--radius-small);",
1924
- "--radius-md: var(--radius-medium);",
1925
- "--radius-lg: var(--radius-large);",
1926
- "--radius-xl: var(--radius-extra-large);",
1927
- "--text-xs: var(--font-size-extra-small);",
1928
- "--text-sm: var(--font-size-small);",
1929
- "--text-base: var(--font-size-regular);",
1930
- "--text-lg: var(--font-size-large);",
1931
- "--text-xl: var(--font-size-extra-large);",
1932
- "--text-2xl: var(--font-size-giant);"
1933
- ];
1934
- /**
1935
- * Overrides for global tailwindcss for specifically dark mode.
1936
- */
1937
- const globalDarkCSSOverride = ["--border: var(--color-background-400);"];
1938
- /**
1939
- * Generate a complete CSS string for a resolved theme.
1940
- * Outputs 2–3 blocks: light default, dark explicit via `[data-theme-mode="dark"]`,
1941
- * and (unless `disableAutoTheme`) a `prefers-color-scheme: dark` media query block.
1942
- */
1943
- function generateThemeCSS(theme, options = {}) {
1944
- const sel = `[data-theme="${theme.id}"]`;
1945
- const tw = options.mapTailwindColors ?? true;
1946
- const blocks = [];
1947
- blocks.push(`${sel} {`);
1948
- blocks.push(...globalCSSOverride);
1949
- blocks.push(...emitNonColorVars(theme));
1950
- blocks.push(...emitColorVars(theme.light));
1951
- if (tw) blocks.push(...emitTailwindOverrides());
1952
- blocks.push(`}`);
1953
- blocks.push(`${sel}[data-theme-mode="dark"] {`);
1954
- blocks.push(...globalDarkCSSOverride);
1955
- blocks.push(...emitColorVars(theme.dark));
1956
- if (tw) blocks.push(...emitTailwindOverrides(true));
1957
- blocks.push(`}`);
1958
- if (!options.disableAutoTheme) {
1959
- blocks.push(`@media (prefers-color-scheme: dark) {`);
1960
- blocks.push(`${sel}:not([data-theme-mode]) {`);
1961
- blocks.push(...globalDarkCSSOverride);
1962
- blocks.push(...emitColorVars(theme.dark).map((l) => `${l}`));
1963
- if (tw) blocks.push(...emitTailwindOverrides(true).map((l) => `${l}`));
1964
- blocks.push(`}`);
1965
- blocks.push(`}`);
1966
- }
1967
- return blocks.join("\n");
1968
- }
1969
- //#endregion
1970
- //#region ../core/src/theme/defaults.ts
1971
- const DEFAULT_FONT_SIZES = {
1972
- extraSmall: "0.75rem",
1973
- small: "0.875rem",
1974
- regular: "1rem",
1975
- large: "1.125rem",
1976
- extraLarge: "1.25rem",
1977
- giant: "1.5rem"
1978
- };
1979
- const DEFAULT_FONT_FAMILIES = {
1980
- header: "Inter",
1981
- body: "Inter"
1982
- };
1983
- const DEFAULT_SPACING = "0.25rem";
1984
- const DEFAULT_RADII = {
1985
- small: "0.25rem",
1986
- medium: "0.5rem",
1987
- large: "0.75rem",
1988
- extraLarge: "1rem"
1989
- };
1990
- const DEFAULT_COLORS = {
1991
- background: "#ffffff",
1992
- foreground: "#1a1a1a",
1993
- primary: "#3b82f6",
1994
- secondary: "#6b7280",
1995
- accent: "#10b981",
1996
- muted: "#f3f4f6",
1997
- destructive: "#ef4444",
1998
- mutedForeground: "#6b7280"
1999
- };
2000
- const DEFAULT_THEME_ID = "default";
2001
- const DEFAULT_THEME_NAME = "Default Theme";
2002
- /**
2003
- * Build a fresh ThemeDefinition populated with all defaults.
2004
- * Returns a new object each call because Color instances are mutable — do not cache the result.
2005
- */
2006
- function getDefaultThemeDefinition() {
2007
- const bg = new Color(DEFAULT_COLORS.background);
2008
- const fg = new Color(DEFAULT_COLORS.foreground);
2009
- const primary = new Color(DEFAULT_COLORS.primary);
2010
- const secondary = new Color(DEFAULT_COLORS.secondary);
2011
- const accent = new Color(DEFAULT_COLORS.accent);
2012
- const muted = new Color(DEFAULT_COLORS.muted);
2013
- const destructive = new Color(DEFAULT_COLORS.destructive);
2014
- const mutedFg = new Color(DEFAULT_COLORS.mutedForeground);
2015
- const darkBg = new Color("#0a0a0a");
2016
- const darkFg = new Color("#fafafa");
2017
- const darkMuted = new Color("#171717");
2018
- const darkMutedForeground = new Color("#dddddd");
2019
- return {
2020
- id: DEFAULT_THEME_ID,
2021
- name: DEFAULT_THEME_NAME,
2022
- light: {
2023
- background: {
2024
- base: bg,
2025
- foreground: fg
2026
- },
2027
- foreground: {
2028
- base: fg,
2029
- foreground: bg
2030
- },
2031
- primary: {
2032
- base: primary,
2033
- foreground: getForegroundColor(fg, primary)
2034
- },
2035
- secondary: {
2036
- base: secondary,
2037
- foreground: getForegroundColor(fg, secondary)
2038
- },
2039
- accent: {
2040
- base: accent,
2041
- foreground: getForegroundColor(fg, accent)
2042
- },
2043
- muted: {
2044
- base: muted,
2045
- foreground: mutedFg
2046
- },
2047
- destructive: {
2048
- base: destructive,
2049
- foreground: getForegroundColor(fg, destructive)
2050
- }
2051
- },
2052
- dark: {
2053
- background: {
2054
- base: darkBg,
2055
- foreground: darkFg
2056
- },
2057
- foreground: {
2058
- base: darkFg,
2059
- foreground: darkBg
2060
- },
2061
- muted: {
2062
- base: darkMuted,
2063
- foreground: darkMutedForeground
2064
- }
2065
- },
2066
- fontSizes: { ...DEFAULT_FONT_SIZES },
2067
- fontFamilies: { ...DEFAULT_FONT_FAMILIES },
2068
- spacing: DEFAULT_SPACING,
2069
- radii: { ...DEFAULT_RADII }
2070
- };
2071
- }
2072
- //#endregion
2073
- //#region ../core/src/theme/serialisation.ts
2074
- function colorToPlain(color) {
2075
- return {
2076
- l: color.oklch.l ?? 0,
2077
- c: color.oklch.c ?? 0,
2078
- h: color.oklch.h ?? 0
2079
- };
2080
- }
2081
- function plainToColor(plain) {
2082
- return new Color("oklch", [
2083
- plain.l,
2084
- plain.c,
2085
- plain.h
2086
- ]);
2087
- }
2088
- /**
2089
- * Serialise a ThemeDefinition (with Color objects) to a plain JSON payload
2090
- * suitable for backend storage.
2091
- */
2092
- function serialiseTheme(def) {
2093
- const light = {};
2094
- for (const name of SEMANTIC_COLOR_NAMES) light[name] = {
2095
- base: colorToPlain(def.light[name].base),
2096
- foreground: colorToPlain(def.light[name].foreground)
2097
- };
2098
- const dark = {};
2099
- for (const [name, value] of Object.entries(def.dark)) {
2100
- if (!value) continue;
2101
- dark[name] = {
2102
- ...value.base ? { base: colorToPlain(value.base) } : {},
2103
- ...value.foreground ? { foreground: colorToPlain(value.foreground) } : {}
2104
- };
2105
- }
2106
- return {
2107
- id: def.id,
2108
- name: def.name,
2109
- light,
2110
- dark,
2111
- fontSizes: { ...def.fontSizes },
2112
- fontFamilies: { ...def.fontFamilies },
2113
- spacing: def.spacing,
2114
- radii: { ...def.radii },
2115
- ...def.syncWithBrandColors ? { syncWithBrandColors: true } : {}
2116
- };
2117
- }
2118
- /**
2119
- * Deserialise a backend payload into a ThemeDefinition with Color objects.
2120
- * Accepts `Record<string, unknown>` because API data is untyped at the boundary.
2121
- * Falls back to default colors for any missing light-mode entries.
2122
- */
2123
- function deserialiseTheme(payload) {
2124
- const lightRaw = payload.light ?? {};
2125
- const darkRaw = payload.dark ?? {};
2126
- const defaults = getDefaultThemeDefinition();
2127
- const light = {};
2128
- for (const name of SEMANTIC_COLOR_NAMES) {
2129
- const entry = lightRaw[name];
2130
- if (entry) light[name] = {
2131
- base: plainToColor(entry.base),
2132
- foreground: plainToColor(entry.foreground)
2133
- };
2134
- else {
2135
- console.warn(`[theme] deserialiseTheme: missing light color "${name}", using default`);
2136
- light[name] = defaults.light[name];
2137
- }
2138
- }
2139
- const dark = {};
2140
- for (const [name, value] of Object.entries(darkRaw)) {
2141
- if (!value) continue;
2142
- dark[name] = {
2143
- ...value.base ? { base: plainToColor(value.base) } : {},
2144
- ...value.foreground ? { foreground: plainToColor(value.foreground) } : {}
2145
- };
2146
- }
2147
- return {
2148
- id: payload.id,
2149
- name: payload.name,
2150
- light,
2151
- dark,
2152
- fontSizes: payload.fontSizes ?? DEFAULT_FONT_SIZES,
2153
- fontFamilies: payload.fontFamilies ?? DEFAULT_FONT_FAMILIES,
2154
- spacing: payload.spacing ?? "0.25rem",
2155
- radii: payload.radii ?? DEFAULT_RADII,
2156
- ...payload.syncWithBrandColors === true ? { syncWithBrandColors: true } : {}
2157
- };
2158
- }
2159
- //#endregion
2160
- //#region ../core/src/theme/transforms.ts
2161
- /**
2162
- * Check if a theme config uses the new structured format (has a `light` key
2163
- * that is an object) vs the legacy flat format.
2164
- */
2165
- function isNewThemeFormat(config) {
2166
- return config.light != null && typeof config.light === "object";
2167
- }
2168
- /**
2169
- * Convert a legacy flat config to a ThemeDefinition.
2170
- * Legacy format: { base: "#fff", text: "#000", primary: "oklch(0.6 0.2 250)", ... }
2171
- */
2172
- function legacyConfigToDefinition(id, name, config) {
2173
- const bg = parseColor(config.base ?? config.background ?? DEFAULT_COLORS.background);
2174
- const fg = parseColor(config.text ?? config.foreground ?? DEFAULT_COLORS.foreground);
2175
- const primary = parseColor(config.primary ?? DEFAULT_COLORS.primary);
2176
- const secondary = parseColor(config.secondary ?? DEFAULT_COLORS.secondary);
2177
- const accent = parseColor(config.accent ?? DEFAULT_COLORS.accent);
2178
- const muted = parseColor(config.muted ?? DEFAULT_COLORS.muted);
2179
- const destructive = parseColor(config.destructive ?? DEFAULT_COLORS.destructive);
2180
- const mutedFg = parseColor(config.mutedForeground ?? DEFAULT_COLORS.mutedForeground);
2181
- return {
2182
- id: String(id),
2183
- name,
2184
- light: {
2185
- background: {
2186
- base: bg,
2187
- foreground: fg
2188
- },
2189
- foreground: {
2190
- base: fg,
2191
- foreground: bg
2192
- },
2193
- primary: {
2194
- base: primary,
2195
- foreground: getForegroundColor(fg, primary)
2196
- },
2197
- secondary: {
2198
- base: secondary,
2199
- foreground: getForegroundColor(fg, secondary)
2200
- },
2201
- accent: {
2202
- base: accent,
2203
- foreground: getForegroundColor(fg, accent)
2204
- },
2205
- muted: {
2206
- base: muted,
2207
- foreground: mutedFg
2208
- },
2209
- destructive: {
2210
- base: destructive,
2211
- foreground: getForegroundColor(fg, destructive)
2212
- }
2213
- },
2214
- dark: {},
2215
- fontSizes: {
2216
- extraSmall: config.extraSmall ?? DEFAULT_FONT_SIZES.extraSmall,
2217
- small: config.small ?? DEFAULT_FONT_SIZES.small,
2218
- regular: config.regular ?? DEFAULT_FONT_SIZES.regular,
2219
- large: config.large ?? DEFAULT_FONT_SIZES.large,
2220
- extraLarge: config.extraLarge ?? DEFAULT_FONT_SIZES.extraLarge,
2221
- giant: config.giant ?? DEFAULT_FONT_SIZES.giant
2222
- },
2223
- fontFamilies: {
2224
- header: config.headerFont ?? DEFAULT_FONT_FAMILIES.header,
2225
- body: config.bodyFont ?? DEFAULT_FONT_FAMILIES.body
2226
- },
2227
- spacing: config.globalSpacing ?? "0.25rem",
2228
- radii: {
2229
- small: config.radiusSmall ?? DEFAULT_RADII.small,
2230
- medium: config.radiusMedium ?? DEFAULT_RADII.medium,
2231
- large: config.radiusLarge ?? DEFAULT_RADII.large,
2232
- extraLarge: config.radiusExtraLarge ?? DEFAULT_RADII.extraLarge
2233
- }
2234
- };
2235
- }
2236
- /**
2237
- * Build a ThemeDefinition from a single API theme object.
2238
- * Handles both new structured format and legacy flat format.
2239
- */
2240
- function buildThemeDefinition(theme) {
2241
- const config = theme.config ?? {};
2242
- if (isNewThemeFormat(config)) return deserialiseTheme({
2243
- ...config,
2244
- id: String(theme.id),
2245
- name: theme.name ?? "Untitled Theme"
2246
- });
2247
- return legacyConfigToDefinition(theme.id, theme.name ?? "Untitled Theme", config);
2248
- }
2249
- /**
2250
- * Transform raw API themes to ThemeDefinition[].
2251
- * Catches and logs errors per theme (graceful degradation).
2252
- */
2253
- function transformThemes(themes) {
2254
- return themes.flatMap((theme) => {
2255
- try {
2256
- return [buildThemeDefinition(theme)];
2257
- } catch (error) {
2258
- console.error(`[theme] Failed to build theme id=${theme.id}:`, error);
2259
- return [];
2260
- }
2261
- });
2262
- }
2263
- /**
2264
- * Get the active theme ID from a list of raw API themes.
2265
- * Falls back to the first theme if none is marked active.
2266
- */
2267
- function getActiveThemeId(themes) {
2268
- const active = themes.find((t) => t.active) ?? themes[0];
2269
- return active ? String(active.id) : void 0;
2270
- }
2271
- //#endregion
2272
- //#region ../core/src/theme/theme-applicator.ts
2273
- const STYLE_PREFIX = "theme-style-";
2274
- const FONT_LINK_PREFIX = "theme-font-";
2275
- const SYSTEM_FONTS = new Set([
2276
- "sans-serif",
2277
- "serif",
2278
- "monospace",
2279
- "cursive",
2280
- "fantasy",
2281
- "system-ui",
2282
- "ui-sans-serif",
2283
- "ui-serif",
2284
- "ui-monospace"
2285
- ]);
2286
- /** Build a Google Fonts CSS2 URL for a given font family with all weights. */
2287
- function buildGoogleFontUrl(family) {
2288
- return `https://fonts.googleapis.com/css2?family=${encodeURIComponent(family).replace(/%20/g, "+")}:wght@100;200;300;400;500;600;700;800;900&display=swap`;
2289
- }
2290
- /** Check if a font family value needs to be loaded (i.e. is not a CSS var or system font). */
2291
- function isLoadableFont(value) {
2292
- if (!value) return false;
2293
- if (value.startsWith("var(")) return false;
2294
- return !SYSTEM_FONTS.has(value.toLowerCase());
2295
- }
2296
- /** Deterministic link element ID for a font family. */
2297
- function fontLinkId(family) {
2298
- return `${FONT_LINK_PREFIX}${family.replace(/\s+/g, "-").toLowerCase()}`;
2299
- }
2300
- /**
2301
- * Inject or update `<link>` elements for Google Fonts used by the theme.
2302
- * Removes links for fonts that are no longer referenced.
2303
- */
2304
- function loadThemeFonts(theme) {
2305
- if (typeof document === "undefined") return;
2306
- const fontsToLoad = /* @__PURE__ */ new Set();
2307
- for (const key of FONT_FAMILY_KEYS) {
2308
- const value = theme.fontFamilies[key];
2309
- if (isLoadableFont(value)) fontsToLoad.add(value);
2310
- }
2311
- document.querySelectorAll(`link[id^="${FONT_LINK_PREFIX}"]`).forEach((link) => {
2312
- const owners = link.getAttribute("data-font-theme-ids")?.split(",") ?? [];
2313
- if (!owners.includes(theme.id)) return;
2314
- const fontName = link.getAttribute("data-font-family");
2315
- if (fontName && !fontsToLoad.has(fontName)) {
2316
- const remaining = owners.filter((id) => id !== theme.id);
2317
- if (remaining.length === 0) link.remove();
2318
- else link.setAttribute("data-font-theme-ids", remaining.join(","));
2319
- }
2320
- });
2321
- for (const family of fontsToLoad) {
2322
- const id = fontLinkId(family);
2323
- const existing = document.getElementById(id);
2324
- if (existing) {
2325
- const owners = existing.getAttribute("data-font-theme-ids")?.split(",") ?? [];
2326
- if (!owners.includes(theme.id)) existing.setAttribute("data-font-theme-ids", [...owners, theme.id].join(","));
2327
- } else {
2328
- const link = document.createElement("link");
2329
- link.id = id;
2330
- link.rel = "stylesheet";
2331
- link.href = buildGoogleFontUrl(family);
2332
- link.setAttribute("data-font-family", family);
2333
- link.setAttribute("data-font-theme-ids", theme.id);
2334
- document.head.appendChild(link);
2335
- }
2336
- }
2337
- }
2338
- /** Remove all font `<link>` elements injected by the theme system. */
2339
- function removeAllFontLinks() {
2340
- if (typeof document === "undefined") return;
2341
- document.querySelectorAll(`link[id^="${FONT_LINK_PREFIX}"]`).forEach((el) => el.remove());
2342
- }
2343
- /**
2344
- * Inject or update a `<style>` element in `<head>` for the given theme.
2345
- * The element ID is deterministic (`theme-style-{themeId}`) so repeated calls
2346
- * for the same theme are idempotent — the existing element is updated in place.
2347
- * Also loads Google Fonts referenced by the theme's font families.
2348
- * No-op when `document` is unavailable (SSR).
2349
- */
2350
- function applyTheme(theme, options) {
2351
- if (typeof document === "undefined") return;
2352
- try {
2353
- loadThemeFonts(theme);
2354
- const styleId = `${STYLE_PREFIX}${theme.id}`;
2355
- let el = document.getElementById(styleId);
2356
- if (!el) {
2357
- el = document.createElement("style");
2358
- el.id = styleId;
2359
- document.head.appendChild(el);
2360
- }
2361
- el.textContent = generateThemeCSS(theme, options);
2362
- } catch (error) {
2363
- console.error(`[theme] applyTheme failed for "${theme.id}":`, error);
2364
- }
2365
- }
2366
- /** Remove an injected theme stylesheet and clean up font link ownership. No-op during SSR. */
2367
- function removeTheme(themeId) {
2368
- if (typeof document === "undefined") return;
2369
- document.getElementById(`${STYLE_PREFIX}${themeId}`)?.remove();
2370
- document.querySelectorAll(`link[id^="${FONT_LINK_PREFIX}"]`).forEach((link) => {
2371
- const remaining = (link.getAttribute("data-font-theme-ids")?.split(",") ?? []).filter((id) => id !== themeId);
2372
- if (remaining.length === 0) link.remove();
2373
- else link.setAttribute("data-font-theme-ids", remaining.join(","));
2374
- });
2375
- }
2376
- /** Remove all injected theme stylesheets and font links. No-op during SSR. */
2377
- function removeAllThemes() {
2378
- if (typeof document === "undefined") return;
2379
- document.querySelectorAll(`style[id^="${STYLE_PREFIX}"]`).forEach((el) => el.remove());
2380
- removeAllFontLinks();
2381
- }
2382
- //#endregion
2383
1572
  //#region src/providers/FluidThemeProvider.tsx
2384
1573
  /**
2385
1574
  * Theme Provider for Fluid SDK
@@ -2950,6 +2139,6 @@ function useFluidContext() {
2950
2139
  return context;
2951
2140
  }
2952
2141
  //#endregion
2953
- export { mergeDarkOverrides as A, usePayApi as B, DEFAULT_THEME_ID as C, deriveDarkVariant as D, generateThemeCSS as E, RADIUS_KEYS as F, createPersister as H, SEMANTIC_COLOR_NAMES as I, SHADE_STEPS as L, resolveTheme as M, FONT_FAMILY_KEYS as N, generateShades as O, FONT_SIZE_KEYS as P, ApiError as R, DEFAULT_SPACING as S, getDefaultThemeDefinition as T, deleteDatabase as U, useAppDefinitionApi as V, serialiseTheme as _, createScreen as a, DEFAULT_FONT_SIZES as b, FluidThemeProvider as c, removeAllThemes as d, removeTheme as f, deserialiseTheme as g, transformThemes as h, widgetPropertySchemas as i, parseColor as j, getForegroundColor as k, useThemeContext as l, getActiveThemeId as m, useFluidContext as n, createWidgetFromShareable as o, buildThemeDefinition as p, DEFAULT_SDK_WIDGET_REGISTRY as r, createWidgetRegistry as s, FluidProvider as t, applyTheme as u, DEFAULT_COLORS as v, DEFAULT_THEME_NAME as w, DEFAULT_RADII as x, DEFAULT_FONT_FAMILIES as y, useLanguagesApi as z };
2142
+ export { createScreen as a, FluidThemeProvider as c, useLanguagesApi as d, usePayApi as f, deleteDatabase as h, widgetPropertySchemas as i, useThemeContext as l, createPersister as m, useFluidContext as n, createWidgetFromShareable as o, useAppDefinitionApi as p, DEFAULT_SDK_WIDGET_REGISTRY as r, createWidgetRegistry as s, FluidProvider as t, ApiError as u };
2954
2143
 
2955
- //# sourceMappingURL=FluidProvider-DiJy4Zve.mjs.map
2144
+ //# sourceMappingURL=FluidProvider-DFZiXiqm.mjs.map