@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.
- package/dist/{ContactsScreen-Cheiwaxn.cjs → ContactsScreen-BOMxeTG8.cjs} +2 -2
- package/dist/{ContactsScreen-BtBNMZzG.mjs → ContactsScreen-Bm9SlMY3.mjs} +17 -7
- package/dist/ContactsScreen-Bm9SlMY3.mjs.map +1 -0
- package/dist/{ContactsScreen-DvohvoOE.cjs → ContactsScreen-DflUjayA.cjs} +291 -281
- package/dist/ContactsScreen-DflUjayA.cjs.map +1 -0
- package/dist/{FluidProvider-D177ez3m.cjs → FluidProvider-ByBDIQeW.cjs} +6 -986
- package/dist/FluidProvider-ByBDIQeW.cjs.map +1 -0
- package/dist/{FluidProvider-DiJy4Zve.mjs → FluidProvider-DFZiXiqm.mjs} +3 -814
- package/dist/FluidProvider-DFZiXiqm.mjs.map +1 -0
- package/dist/{MessagingScreen-Cu3tcpPs.mjs → MessagingScreen-D6d83q2n.mjs} +2 -2
- package/dist/{MessagingScreen-Cu3tcpPs.mjs.map → MessagingScreen-D6d83q2n.mjs.map} +1 -1
- package/dist/{MessagingScreen-Ysi48svi.cjs → MessagingScreen-HT_HSiNW.cjs} +3 -3
- package/dist/{MessagingScreen-gKidMcrr.cjs → MessagingScreen-shEWzTmQ.cjs} +2 -2
- package/dist/{MessagingScreen-gKidMcrr.cjs.map → MessagingScreen-shEWzTmQ.cjs.map} +1 -1
- package/dist/{PortalContentApiProvider-CWRAw9kL.mjs → PortalContentApiProvider-CNYq1_OD.mjs} +114 -88
- package/dist/PortalContentApiProvider-CNYq1_OD.mjs.map +1 -0
- package/dist/{PortalContentApiProvider-CPnqELEX.cjs → PortalContentApiProvider-ChmcXmbv.cjs} +113 -87
- package/dist/PortalContentApiProvider-ChmcXmbv.cjs.map +1 -0
- package/dist/{ProductsScreen-Al6H4ujs.mjs → ProductsScreen-CDjpHF49.mjs} +2 -2
- package/dist/{ProductsScreen-Al6H4ujs.mjs.map → ProductsScreen-CDjpHF49.mjs.map} +1 -1
- package/dist/{ProductsScreen-CQ5-A8AL.cjs → ProductsScreen-CzfDX0xx.cjs} +2 -2
- package/dist/{ProductsScreen-CQ5-A8AL.cjs.map → ProductsScreen-CzfDX0xx.cjs.map} +1 -1
- package/dist/{ProductsScreen-CexZ0gx9.mjs → ProductsScreen-D6-ehQjh.mjs} +2 -2
- package/dist/{ProductsScreen-BnwMOZ4-.cjs → ProductsScreen-fN3fh3PB.cjs} +2 -2
- package/dist/{ProfileScreen-DJZoMzE6.cjs → ProfileScreen-B0EU-TLa.cjs} +101 -101
- package/dist/{ProfileScreen-DJZoMzE6.cjs.map → ProfileScreen-B0EU-TLa.cjs.map} +1 -1
- package/dist/{ProfileScreen-hE1S_99P.mjs → ProfileScreen-BIs70k9W.mjs} +3 -3
- package/dist/{ProfileScreen-hE1S_99P.mjs.map → ProfileScreen-BIs70k9W.mjs.map} +1 -1
- package/dist/{ProfileScreen-CGS7YkcT.cjs → ProfileScreen-Dqu2nK_2.cjs} +3 -3
- package/dist/{ShareablesScreen-CzTU7e0l.mjs → ShareablesScreen-B8rPq-_7.mjs} +2 -2
- package/dist/{ShareablesScreen-CzTU7e0l.mjs.map → ShareablesScreen-B8rPq-_7.mjs.map} +1 -1
- package/dist/{ShareablesScreen-DujtMoAi.cjs → ShareablesScreen-DFLAJxjs.cjs} +2 -2
- package/dist/{ShareablesScreen-CmZ5CX99.cjs → ShareablesScreen-DLXK1PAg.cjs} +2 -2
- package/dist/{ShareablesScreen-CmZ5CX99.cjs.map → ShareablesScreen-DLXK1PAg.cjs.map} +1 -1
- package/dist/{ShareablesScreen-yscAsNpq.mjs → ShareablesScreen-Dc57L9m8.mjs} +2 -2
- package/dist/{ShopScreen-Bdo59te-.mjs → ShopScreen-2yMsyFwk.mjs} +2 -2
- package/dist/{ShopScreen-Bdo59te-.mjs.map → ShopScreen-2yMsyFwk.mjs.map} +1 -1
- package/dist/{ShopScreen-DKlDKNom.cjs → ShopScreen-BmHSLZ7H.cjs} +2 -2
- package/dist/{ShopScreen-DKlDKNom.cjs.map → ShopScreen-BmHSLZ7H.cjs.map} +1 -1
- package/dist/{ShopScreen-R9zk7d5d.cjs → ShopScreen-kk4yLzrW.cjs} +3 -3
- package/dist/index.cjs +67 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +132 -128
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +132 -128
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +21 -21
- package/dist/src-BRTXunU1.mjs +851 -0
- package/dist/src-BRTXunU1.mjs.map +1 -0
- package/dist/src-DvVPCD01.cjs +1038 -0
- package/dist/src-DvVPCD01.cjs.map +1 -0
- package/package.json +16 -16
- package/dist/ContactsScreen-BtBNMZzG.mjs.map +0 -1
- package/dist/ContactsScreen-DvohvoOE.cjs.map +0 -1
- package/dist/FluidProvider-D177ez3m.cjs.map +0 -1
- package/dist/FluidProvider-DiJy4Zve.mjs.map +0 -1
- package/dist/PortalContentApiProvider-CPnqELEX.cjs.map +0 -1
- package/dist/PortalContentApiProvider-CWRAw9kL.mjs.map +0 -1
- package/dist/countries-api-context-Dob_AzPO.mjs +0 -13
- package/dist/countries-api-context-Dob_AzPO.mjs.map +0 -1
- package/dist/countries-api-context-G-NW4BoH.cjs +0 -25
- package/dist/countries-api-context-G-NW4BoH.cjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
require("./chunk-9hOWP6kD.cjs");
|
|
2
2
|
const require_ScreenRenderer = require("./ScreenRenderer-DfeRRgBO.cjs");
|
|
3
3
|
const require_account_api_context = require("./account-api-context-DZP9IiGg.cjs");
|
|
4
4
|
const require_store_api_context = require("./store-api-context-D1gZn22Z.cjs");
|
|
5
5
|
const require_mysite_api_context = require("./mysite-api-context-CilZcDS4.cjs");
|
|
6
|
-
const
|
|
6
|
+
const require_src = require("./src-DvVPCD01.cjs");
|
|
7
7
|
const require_portal_tenant = require("./portal_tenant-BdKp073-.cjs");
|
|
8
8
|
const require_portal_tenant_content = require("./portal_tenant_content-0zpnjBot.cjs");
|
|
9
9
|
const require_PortalTenantClientProvider = require("./PortalTenantClientProvider-CVv-4rQ9.cjs");
|
|
@@ -36,8 +36,6 @@ const require_VideoWidget = require("./VideoWidget-sEVQcp9o.cjs");
|
|
|
36
36
|
let react = require("react");
|
|
37
37
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
38
38
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
-
let colorjs_io = require("colorjs.io");
|
|
40
|
-
colorjs_io = require_chunk.__toESM(colorjs_io);
|
|
41
39
|
//#region ../../../node_modules/.pnpm/@tanstack+query-core@5.90.12/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
|
|
42
40
|
var defaultTimeoutProvider = {
|
|
43
41
|
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
@@ -1587,816 +1585,6 @@ function createMySiteApiAdapter(client) {
|
|
|
1587
1585
|
};
|
|
1588
1586
|
}
|
|
1589
1587
|
//#endregion
|
|
1590
|
-
//#region ../core/src/theme/types.ts
|
|
1591
|
-
const SEMANTIC_COLOR_NAMES = [
|
|
1592
|
-
"background",
|
|
1593
|
-
"foreground",
|
|
1594
|
-
"primary",
|
|
1595
|
-
"secondary",
|
|
1596
|
-
"accent",
|
|
1597
|
-
"muted",
|
|
1598
|
-
"destructive"
|
|
1599
|
-
];
|
|
1600
|
-
const SHADE_STEPS = [
|
|
1601
|
-
100,
|
|
1602
|
-
200,
|
|
1603
|
-
300,
|
|
1604
|
-
400,
|
|
1605
|
-
500,
|
|
1606
|
-
600,
|
|
1607
|
-
700,
|
|
1608
|
-
800,
|
|
1609
|
-
900
|
|
1610
|
-
];
|
|
1611
|
-
const FONT_SIZE_KEYS = [
|
|
1612
|
-
"extraSmall",
|
|
1613
|
-
"small",
|
|
1614
|
-
"regular",
|
|
1615
|
-
"large",
|
|
1616
|
-
"extraLarge",
|
|
1617
|
-
"giant"
|
|
1618
|
-
];
|
|
1619
|
-
const FONT_FAMILY_KEYS = ["header", "body"];
|
|
1620
|
-
const RADIUS_KEYS = [
|
|
1621
|
-
"small",
|
|
1622
|
-
"medium",
|
|
1623
|
-
"large",
|
|
1624
|
-
"extraLarge"
|
|
1625
|
-
];
|
|
1626
|
-
//#endregion
|
|
1627
|
-
//#region ../core/src/theme/color-engine.ts
|
|
1628
|
-
/**
|
|
1629
|
-
* Attempt to convert any string into a Color using colorjs.io.
|
|
1630
|
-
* If the string is exactly 6 characters it is assumed to be a bare hex value
|
|
1631
|
-
* (e.g. "3b82f6") and a "#" prefix is added before parsing.
|
|
1632
|
-
*
|
|
1633
|
-
* @returns the parsed Color, or a neutral gray (`oklch(0.5 0 0)`) on failure
|
|
1634
|
-
*/
|
|
1635
|
-
function parseColor(value) {
|
|
1636
|
-
if (value.length === 6) value = `#${value}`;
|
|
1637
|
-
try {
|
|
1638
|
-
return new colorjs_io.default(value);
|
|
1639
|
-
} catch (error) {
|
|
1640
|
-
console.warn("[theme] Failed to parse color:", value, error);
|
|
1641
|
-
return new colorjs_io.default("oklch", [
|
|
1642
|
-
.5,
|
|
1643
|
-
0,
|
|
1644
|
-
0
|
|
1645
|
-
]);
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
/**
|
|
1649
|
-
* Returns either the original foreground or a corrected lightness variant,
|
|
1650
|
-
* whichever provides better contrast against `color`.
|
|
1651
|
-
* Inversion triggers when the APCA contrast is below 50.
|
|
1652
|
-
*/
|
|
1653
|
-
function getForegroundColor(foreground, color) {
|
|
1654
|
-
if (foreground.oklch.l == null || color.oklch.l == null) return foreground;
|
|
1655
|
-
if (color.contrastAPCA(foreground) < 50) return new colorjs_io.default("oklch", [
|
|
1656
|
-
color.oklch.l < .7 ? .95 : .15,
|
|
1657
|
-
foreground.oklch.c || 0,
|
|
1658
|
-
foreground.oklch.h || 0
|
|
1659
|
-
]);
|
|
1660
|
-
return foreground;
|
|
1661
|
-
}
|
|
1662
|
-
/**
|
|
1663
|
-
* Generate a 100–900 shade ramp from a base color.
|
|
1664
|
-
* Base anchors at 500. Light shades (100–400) step toward white,
|
|
1665
|
-
* dark shades (600–900) step toward black. Dark steps use an asymmetric
|
|
1666
|
-
* multiplier (1.6×, 1.875×, 3×, 4× of `darkStep`) for a more gradual
|
|
1667
|
-
* initial descent. Chroma is nudged per step for perceptually natural ramps.
|
|
1668
|
-
*/
|
|
1669
|
-
function generateShades(base) {
|
|
1670
|
-
const l = base.oklch.l ?? 0;
|
|
1671
|
-
const c = base.oklch.c ?? 0;
|
|
1672
|
-
const h = base.oklch.h ?? 0;
|
|
1673
|
-
const safeMax = l >= .885 ? .995 : .97;
|
|
1674
|
-
const safeMin = l <= .33 ? 0 : .21;
|
|
1675
|
-
const lightStep = (safeMax - l) / 5;
|
|
1676
|
-
const darkStep = -(l - safeMin) / 8;
|
|
1677
|
-
const shade = (lDelta, cDelta) => {
|
|
1678
|
-
return new colorjs_io.default("oklch", [
|
|
1679
|
-
Math.max(0, Math.min(1, l + lDelta)),
|
|
1680
|
-
c <= .001 ? c : Math.max(0, c + cDelta),
|
|
1681
|
-
h
|
|
1682
|
-
]);
|
|
1683
|
-
};
|
|
1684
|
-
return {
|
|
1685
|
-
100: shade(5 * lightStep, -.00375),
|
|
1686
|
-
200: shade(4 * lightStep, -.00375),
|
|
1687
|
-
300: shade(3 * lightStep, -.00375),
|
|
1688
|
-
400: shade(2 * lightStep, -.00375),
|
|
1689
|
-
500: new colorjs_io.default("oklch", [
|
|
1690
|
-
l,
|
|
1691
|
-
c,
|
|
1692
|
-
h
|
|
1693
|
-
]),
|
|
1694
|
-
600: shade(1.6 * darkStep, .025),
|
|
1695
|
-
700: shade(1.875 * 2 * darkStep, .05),
|
|
1696
|
-
800: shade(6 * darkStep, .075),
|
|
1697
|
-
900: shade(8 * darkStep, .1)
|
|
1698
|
-
};
|
|
1699
|
-
}
|
|
1700
|
-
const DARK_DERIVATION_CONFIG = {
|
|
1701
|
-
background: {
|
|
1702
|
-
baseLightness: .15,
|
|
1703
|
-
fgLightness: .93
|
|
1704
|
-
},
|
|
1705
|
-
foreground: {
|
|
1706
|
-
baseLightness: .93,
|
|
1707
|
-
fgLightness: .15
|
|
1708
|
-
},
|
|
1709
|
-
muted: {
|
|
1710
|
-
baseLightness: .22,
|
|
1711
|
-
fgLightness: .75
|
|
1712
|
-
},
|
|
1713
|
-
primary: {
|
|
1714
|
-
baseLightness: "invert",
|
|
1715
|
-
fgLightness: .95,
|
|
1716
|
-
chromaScale: .9
|
|
1717
|
-
},
|
|
1718
|
-
secondary: {
|
|
1719
|
-
baseLightness: "invert",
|
|
1720
|
-
fgLightness: .93,
|
|
1721
|
-
chromaScale: .85
|
|
1722
|
-
},
|
|
1723
|
-
accent: {
|
|
1724
|
-
baseLightness: "invert",
|
|
1725
|
-
fgLightness: .95,
|
|
1726
|
-
chromaScale: .9
|
|
1727
|
-
},
|
|
1728
|
-
destructive: {
|
|
1729
|
-
baseLightness: "invert",
|
|
1730
|
-
fgLightness: .95,
|
|
1731
|
-
chromaScale: .95
|
|
1732
|
-
}
|
|
1733
|
-
};
|
|
1734
|
-
/** Invert OKLCH lightness (1 - l), clamped to [0.35, 0.75] to avoid extremes. */
|
|
1735
|
-
function invertLightness(l) {
|
|
1736
|
-
const inverted = 1 - l;
|
|
1737
|
-
return Math.max(.35, Math.min(.75, inverted));
|
|
1738
|
-
}
|
|
1739
|
-
/**
|
|
1740
|
-
* Derive a dark-mode ThemeColorInput from its light-mode counterpart.
|
|
1741
|
-
*/
|
|
1742
|
-
function deriveDarkVariant(name, light) {
|
|
1743
|
-
const config = DARK_DERIVATION_CONFIG[name];
|
|
1744
|
-
const chromaScale = config.chromaScale ?? 1;
|
|
1745
|
-
const baseLightness = config.baseLightness === "invert" ? invertLightness(light.base.oklch.l ?? 0) : config.baseLightness;
|
|
1746
|
-
const fgLightness = config.fgLightness === "invert" ? invertLightness(light.foreground.oklch.l ?? 0) : config.fgLightness;
|
|
1747
|
-
return {
|
|
1748
|
-
base: new colorjs_io.default("oklch", [
|
|
1749
|
-
baseLightness,
|
|
1750
|
-
(light.base.oklch.c || 0) * chromaScale,
|
|
1751
|
-
light.base.oklch.h || 0
|
|
1752
|
-
]),
|
|
1753
|
-
foreground: new colorjs_io.default("oklch", [
|
|
1754
|
-
fgLightness,
|
|
1755
|
-
(light.foreground.oklch.c || 0) * chromaScale,
|
|
1756
|
-
light.foreground.oklch.h || 0
|
|
1757
|
-
])
|
|
1758
|
-
};
|
|
1759
|
-
}
|
|
1760
|
-
/**
|
|
1761
|
-
* Merge auto-derived dark colors with any user-specified overrides.
|
|
1762
|
-
* For each semantic color, if the user has fully overridden both base and
|
|
1763
|
-
* foreground those are used; otherwise the missing channels are derived.
|
|
1764
|
-
*/
|
|
1765
|
-
function mergeDarkOverrides(def) {
|
|
1766
|
-
const darkColors = {};
|
|
1767
|
-
for (const name of SEMANTIC_COLOR_NAMES) {
|
|
1768
|
-
const lightInput = def.light[name];
|
|
1769
|
-
const darkOverride = def.dark[name];
|
|
1770
|
-
if (darkOverride?.base && darkOverride?.foreground) darkColors[name] = darkOverride;
|
|
1771
|
-
else if (darkOverride) {
|
|
1772
|
-
const base = darkOverride.base ?? deriveDarkVariant(name, lightInput).base;
|
|
1773
|
-
darkColors[name] = {
|
|
1774
|
-
base,
|
|
1775
|
-
foreground: darkOverride.foreground ?? getForegroundColor(def.light.foreground.base, base)
|
|
1776
|
-
};
|
|
1777
|
-
} else darkColors[name] = deriveDarkVariant(name, lightInput);
|
|
1778
|
-
}
|
|
1779
|
-
return darkColors;
|
|
1780
|
-
}
|
|
1781
|
-
function resolveColorSet(colors) {
|
|
1782
|
-
const resolved = {};
|
|
1783
|
-
for (const name of SEMANTIC_COLOR_NAMES) {
|
|
1784
|
-
const input = colors[name];
|
|
1785
|
-
const shades = generateShades(input.base);
|
|
1786
|
-
const resolvedShades = {};
|
|
1787
|
-
for (const step of SHADE_STEPS) resolvedShades[step] = shades[step];
|
|
1788
|
-
resolved[name] = {
|
|
1789
|
-
base: input.base.clone(),
|
|
1790
|
-
foreground: input.foreground.clone(),
|
|
1791
|
-
shades: resolvedShades
|
|
1792
|
-
};
|
|
1793
|
-
}
|
|
1794
|
-
return resolved;
|
|
1795
|
-
}
|
|
1796
|
-
/**
|
|
1797
|
-
* Resolve a ThemeDefinition into a complete ResolvedTheme.
|
|
1798
|
-
* Dark mode colors are derived from light where not overridden.
|
|
1799
|
-
*/
|
|
1800
|
-
function resolveTheme(def) {
|
|
1801
|
-
return {
|
|
1802
|
-
id: def.id,
|
|
1803
|
-
name: def.name,
|
|
1804
|
-
light: resolveColorSet(def.light),
|
|
1805
|
-
dark: resolveColorSet(mergeDarkOverrides(def)),
|
|
1806
|
-
fontSizes: { ...def.fontSizes },
|
|
1807
|
-
fontFamilies: { ...def.fontFamilies },
|
|
1808
|
-
spacing: def.spacing,
|
|
1809
|
-
radii: { ...def.radii }
|
|
1810
|
-
};
|
|
1811
|
-
}
|
|
1812
|
-
//#endregion
|
|
1813
|
-
//#region ../core/src/theme/tailwind-overrides.ts
|
|
1814
|
-
/**
|
|
1815
|
-
* Specific overrides, otherwise all the overrides are generated using emitTailwindOverrides
|
|
1816
|
-
*/
|
|
1817
|
-
const OVERRIDES = {
|
|
1818
|
-
"--color-gray-50": "var(--color-muted)",
|
|
1819
|
-
"--color-gray-100": "var(--color-muted-600)",
|
|
1820
|
-
"--color-gray-200": "var(--color-border)"
|
|
1821
|
-
};
|
|
1822
|
-
/**
|
|
1823
|
-
* Returns the inverted shade for dark mode foreground colors.
|
|
1824
|
-
* In dark mode, light shades (50, 100) should map to dark values (950, 900) and vice versa.
|
|
1825
|
-
*/
|
|
1826
|
-
function getInvertedStep(shade) {
|
|
1827
|
-
const shadeIndex = SHADE_STEPS.indexOf(shade);
|
|
1828
|
-
return SHADE_STEPS[SHADE_STEPS.length - 1 - shadeIndex] || 500;
|
|
1829
|
-
}
|
|
1830
|
-
/**
|
|
1831
|
-
* Map semantic colors to Tailwind built-in color names.
|
|
1832
|
-
*/
|
|
1833
|
-
function emitTailwindOverrides(darkMode = false) {
|
|
1834
|
-
const TAILWIND_COLOR_MAP = {
|
|
1835
|
-
gray: "foreground",
|
|
1836
|
-
red: "destructive",
|
|
1837
|
-
blue: "primary",
|
|
1838
|
-
green: "accent"
|
|
1839
|
-
};
|
|
1840
|
-
const TAILWIND_SHADES = [
|
|
1841
|
-
50,
|
|
1842
|
-
100,
|
|
1843
|
-
200,
|
|
1844
|
-
300,
|
|
1845
|
-
400,
|
|
1846
|
-
500,
|
|
1847
|
-
600,
|
|
1848
|
-
700,
|
|
1849
|
-
800,
|
|
1850
|
-
900,
|
|
1851
|
-
950
|
|
1852
|
-
];
|
|
1853
|
-
const SHADE_REMAP = {
|
|
1854
|
-
50: 100,
|
|
1855
|
-
950: 900
|
|
1856
|
-
};
|
|
1857
|
-
const lines = [];
|
|
1858
|
-
for (const [twName, semantic] of Object.entries(TAILWIND_COLOR_MAP)) for (const shade of TAILWIND_SHADES) {
|
|
1859
|
-
const step = SHADE_REMAP[shade] ?? shade;
|
|
1860
|
-
const override = OVERRIDES[`--color-${twName}-${shade}`];
|
|
1861
|
-
lines.push(`--color-${twName}-${shade}: ${override ? override : `var(--color-${semantic}-${semantic === "foreground" && darkMode === true ? getInvertedStep(step) : step})`};`);
|
|
1862
|
-
}
|
|
1863
|
-
lines.push("--color-white: var(--color-background);");
|
|
1864
|
-
lines.push("--color-black: var(--color-foreground);");
|
|
1865
|
-
return lines;
|
|
1866
|
-
}
|
|
1867
|
-
//#endregion
|
|
1868
|
-
//#region ../core/src/theme/css-generator.ts
|
|
1869
|
-
function colorToCSS(color) {
|
|
1870
|
-
const result = color.toString({ format: "oklch" });
|
|
1871
|
-
if (result.includes("NaN")) {
|
|
1872
|
-
console.warn("[theme] colorToCSS produced NaN, using neutral fallback:", result);
|
|
1873
|
-
return "oklch(0.5 0 0)";
|
|
1874
|
-
}
|
|
1875
|
-
return result;
|
|
1876
|
-
}
|
|
1877
|
-
function camelToKebab(str) {
|
|
1878
|
-
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1879
|
-
}
|
|
1880
|
-
/**
|
|
1881
|
-
* Emit --color-{name}, --color-{name}-foreground, --color-{name}-{shade} vars.
|
|
1882
|
-
* Uses --color- prefix to match portal-widgets/tailwind.config.ts.
|
|
1883
|
-
*/
|
|
1884
|
-
function emitColorVars(colors) {
|
|
1885
|
-
const lines = [];
|
|
1886
|
-
for (const name of SEMANTIC_COLOR_NAMES) {
|
|
1887
|
-
const color = colors[name];
|
|
1888
|
-
lines.push(`--color-${name}: ${colorToCSS(color.base)};`);
|
|
1889
|
-
lines.push(`--color-${name}-foreground: ${colorToCSS(color.foreground)};`);
|
|
1890
|
-
for (const step of SHADE_STEPS) lines.push(`--color-${name}-${step}: ${colorToCSS(color.shades[step])};`);
|
|
1891
|
-
}
|
|
1892
|
-
return lines;
|
|
1893
|
-
}
|
|
1894
|
-
/**
|
|
1895
|
-
* Format a font family value for CSS output.
|
|
1896
|
-
* - If the value starts with "var(" (legacy), pass through as-is
|
|
1897
|
-
* - If the value already contains a comma (has fallback), pass through as-is
|
|
1898
|
-
* - Otherwise, wrap in quotes and append a generic sans-serif fallback
|
|
1899
|
-
*/
|
|
1900
|
-
function formatFontFamily(value) {
|
|
1901
|
-
if (value.startsWith("var(")) return value;
|
|
1902
|
-
if (value.includes(",")) return value;
|
|
1903
|
-
return `'${value}', sans-serif`;
|
|
1904
|
-
}
|
|
1905
|
-
/**
|
|
1906
|
-
* Emit non-color CSS variables (font sizes, families, spacing, radii).
|
|
1907
|
-
*/
|
|
1908
|
-
function emitNonColorVars(theme) {
|
|
1909
|
-
const lines = [];
|
|
1910
|
-
for (const key of FONT_SIZE_KEYS) lines.push(`--font-size-${camelToKebab(key)}: ${theme.fontSizes[key]};`);
|
|
1911
|
-
for (const key of FONT_FAMILY_KEYS) lines.push(`--font-${key}: ${formatFontFamily(theme.fontFamilies[key])};`);
|
|
1912
|
-
lines.push(`--spacing: ${theme.spacing};`);
|
|
1913
|
-
for (const key of RADIUS_KEYS) lines.push(`--radius-${camelToKebab(key)}: ${theme.radii[key]};`);
|
|
1914
|
-
return lines;
|
|
1915
|
-
}
|
|
1916
|
-
/**
|
|
1917
|
-
* Static CSS alias variables that bridge theme var names to Tailwind/component conventions.
|
|
1918
|
-
* These are always emitted and not mode-dependent.
|
|
1919
|
-
*/
|
|
1920
|
-
const globalCSSOverride = [
|
|
1921
|
-
"--color-background-foreground: var(--color-foreground);",
|
|
1922
|
-
"--color-foreground-foreground: var(--color-background);",
|
|
1923
|
-
"--color-contrast: var(--color-foreground);",
|
|
1924
|
-
...SEMANTIC_COLOR_NAMES.map((value) => `--${value}: var(--color-${value});`),
|
|
1925
|
-
...SEMANTIC_COLOR_NAMES.map((value) => `--${value}-foreground: var(--color-${value}-foreground);`),
|
|
1926
|
-
"--sidebar-ring: var(--color-primary);",
|
|
1927
|
-
"--sidebar-border: var(--color-border);",
|
|
1928
|
-
"--sidebar-accent-foreground: var(--color-accent-foreground);",
|
|
1929
|
-
"--sidebar-accent: var(--color-accent);",
|
|
1930
|
-
"--sidebar-primary-foreground: var(--color-primary-foreground);",
|
|
1931
|
-
"--sidebar-primary: var(--color-primary);",
|
|
1932
|
-
"--sidebar-foreground: var(--color-muted-foreground);",
|
|
1933
|
-
"--sidebar: var(--color-muted);",
|
|
1934
|
-
"--border: var(--color-background-600);",
|
|
1935
|
-
"--ring: var(--color-primary);",
|
|
1936
|
-
"--popover: var(--color-background);",
|
|
1937
|
-
"--popover-foreground: var(--color-foreground);",
|
|
1938
|
-
"--card: var(--color-muted);",
|
|
1939
|
-
"--card-foreground: var(--color-muted-foreground);",
|
|
1940
|
-
"--radius-sm: var(--radius-small);",
|
|
1941
|
-
"--radius-md: var(--radius-medium);",
|
|
1942
|
-
"--radius-lg: var(--radius-large);",
|
|
1943
|
-
"--radius-xl: var(--radius-extra-large);",
|
|
1944
|
-
"--text-xs: var(--font-size-extra-small);",
|
|
1945
|
-
"--text-sm: var(--font-size-small);",
|
|
1946
|
-
"--text-base: var(--font-size-regular);",
|
|
1947
|
-
"--text-lg: var(--font-size-large);",
|
|
1948
|
-
"--text-xl: var(--font-size-extra-large);",
|
|
1949
|
-
"--text-2xl: var(--font-size-giant);"
|
|
1950
|
-
];
|
|
1951
|
-
/**
|
|
1952
|
-
* Overrides for global tailwindcss for specifically dark mode.
|
|
1953
|
-
*/
|
|
1954
|
-
const globalDarkCSSOverride = ["--border: var(--color-background-400);"];
|
|
1955
|
-
/**
|
|
1956
|
-
* Generate a complete CSS string for a resolved theme.
|
|
1957
|
-
* Outputs 2–3 blocks: light default, dark explicit via `[data-theme-mode="dark"]`,
|
|
1958
|
-
* and (unless `disableAutoTheme`) a `prefers-color-scheme: dark` media query block.
|
|
1959
|
-
*/
|
|
1960
|
-
function generateThemeCSS(theme, options = {}) {
|
|
1961
|
-
const sel = `[data-theme="${theme.id}"]`;
|
|
1962
|
-
const tw = options.mapTailwindColors ?? true;
|
|
1963
|
-
const blocks = [];
|
|
1964
|
-
blocks.push(`${sel} {`);
|
|
1965
|
-
blocks.push(...globalCSSOverride);
|
|
1966
|
-
blocks.push(...emitNonColorVars(theme));
|
|
1967
|
-
blocks.push(...emitColorVars(theme.light));
|
|
1968
|
-
if (tw) blocks.push(...emitTailwindOverrides());
|
|
1969
|
-
blocks.push(`}`);
|
|
1970
|
-
blocks.push(`${sel}[data-theme-mode="dark"] {`);
|
|
1971
|
-
blocks.push(...globalDarkCSSOverride);
|
|
1972
|
-
blocks.push(...emitColorVars(theme.dark));
|
|
1973
|
-
if (tw) blocks.push(...emitTailwindOverrides(true));
|
|
1974
|
-
blocks.push(`}`);
|
|
1975
|
-
if (!options.disableAutoTheme) {
|
|
1976
|
-
blocks.push(`@media (prefers-color-scheme: dark) {`);
|
|
1977
|
-
blocks.push(`${sel}:not([data-theme-mode]) {`);
|
|
1978
|
-
blocks.push(...globalDarkCSSOverride);
|
|
1979
|
-
blocks.push(...emitColorVars(theme.dark).map((l) => `${l}`));
|
|
1980
|
-
if (tw) blocks.push(...emitTailwindOverrides(true).map((l) => `${l}`));
|
|
1981
|
-
blocks.push(`}`);
|
|
1982
|
-
blocks.push(`}`);
|
|
1983
|
-
}
|
|
1984
|
-
return blocks.join("\n");
|
|
1985
|
-
}
|
|
1986
|
-
//#endregion
|
|
1987
|
-
//#region ../core/src/theme/defaults.ts
|
|
1988
|
-
const DEFAULT_FONT_SIZES = {
|
|
1989
|
-
extraSmall: "0.75rem",
|
|
1990
|
-
small: "0.875rem",
|
|
1991
|
-
regular: "1rem",
|
|
1992
|
-
large: "1.125rem",
|
|
1993
|
-
extraLarge: "1.25rem",
|
|
1994
|
-
giant: "1.5rem"
|
|
1995
|
-
};
|
|
1996
|
-
const DEFAULT_FONT_FAMILIES = {
|
|
1997
|
-
header: "Inter",
|
|
1998
|
-
body: "Inter"
|
|
1999
|
-
};
|
|
2000
|
-
const DEFAULT_SPACING = "0.25rem";
|
|
2001
|
-
const DEFAULT_RADII = {
|
|
2002
|
-
small: "0.25rem",
|
|
2003
|
-
medium: "0.5rem",
|
|
2004
|
-
large: "0.75rem",
|
|
2005
|
-
extraLarge: "1rem"
|
|
2006
|
-
};
|
|
2007
|
-
const DEFAULT_COLORS = {
|
|
2008
|
-
background: "#ffffff",
|
|
2009
|
-
foreground: "#1a1a1a",
|
|
2010
|
-
primary: "#3b82f6",
|
|
2011
|
-
secondary: "#6b7280",
|
|
2012
|
-
accent: "#10b981",
|
|
2013
|
-
muted: "#f3f4f6",
|
|
2014
|
-
destructive: "#ef4444",
|
|
2015
|
-
mutedForeground: "#6b7280"
|
|
2016
|
-
};
|
|
2017
|
-
const DEFAULT_THEME_ID = "default";
|
|
2018
|
-
const DEFAULT_THEME_NAME = "Default Theme";
|
|
2019
|
-
/**
|
|
2020
|
-
* Build a fresh ThemeDefinition populated with all defaults.
|
|
2021
|
-
* Returns a new object each call because Color instances are mutable — do not cache the result.
|
|
2022
|
-
*/
|
|
2023
|
-
function getDefaultThemeDefinition() {
|
|
2024
|
-
const bg = new colorjs_io.default(DEFAULT_COLORS.background);
|
|
2025
|
-
const fg = new colorjs_io.default(DEFAULT_COLORS.foreground);
|
|
2026
|
-
const primary = new colorjs_io.default(DEFAULT_COLORS.primary);
|
|
2027
|
-
const secondary = new colorjs_io.default(DEFAULT_COLORS.secondary);
|
|
2028
|
-
const accent = new colorjs_io.default(DEFAULT_COLORS.accent);
|
|
2029
|
-
const muted = new colorjs_io.default(DEFAULT_COLORS.muted);
|
|
2030
|
-
const destructive = new colorjs_io.default(DEFAULT_COLORS.destructive);
|
|
2031
|
-
const mutedFg = new colorjs_io.default(DEFAULT_COLORS.mutedForeground);
|
|
2032
|
-
const darkBg = new colorjs_io.default("#0a0a0a");
|
|
2033
|
-
const darkFg = new colorjs_io.default("#fafafa");
|
|
2034
|
-
const darkMuted = new colorjs_io.default("#171717");
|
|
2035
|
-
const darkMutedForeground = new colorjs_io.default("#dddddd");
|
|
2036
|
-
return {
|
|
2037
|
-
id: DEFAULT_THEME_ID,
|
|
2038
|
-
name: DEFAULT_THEME_NAME,
|
|
2039
|
-
light: {
|
|
2040
|
-
background: {
|
|
2041
|
-
base: bg,
|
|
2042
|
-
foreground: fg
|
|
2043
|
-
},
|
|
2044
|
-
foreground: {
|
|
2045
|
-
base: fg,
|
|
2046
|
-
foreground: bg
|
|
2047
|
-
},
|
|
2048
|
-
primary: {
|
|
2049
|
-
base: primary,
|
|
2050
|
-
foreground: getForegroundColor(fg, primary)
|
|
2051
|
-
},
|
|
2052
|
-
secondary: {
|
|
2053
|
-
base: secondary,
|
|
2054
|
-
foreground: getForegroundColor(fg, secondary)
|
|
2055
|
-
},
|
|
2056
|
-
accent: {
|
|
2057
|
-
base: accent,
|
|
2058
|
-
foreground: getForegroundColor(fg, accent)
|
|
2059
|
-
},
|
|
2060
|
-
muted: {
|
|
2061
|
-
base: muted,
|
|
2062
|
-
foreground: mutedFg
|
|
2063
|
-
},
|
|
2064
|
-
destructive: {
|
|
2065
|
-
base: destructive,
|
|
2066
|
-
foreground: getForegroundColor(fg, destructive)
|
|
2067
|
-
}
|
|
2068
|
-
},
|
|
2069
|
-
dark: {
|
|
2070
|
-
background: {
|
|
2071
|
-
base: darkBg,
|
|
2072
|
-
foreground: darkFg
|
|
2073
|
-
},
|
|
2074
|
-
foreground: {
|
|
2075
|
-
base: darkFg,
|
|
2076
|
-
foreground: darkBg
|
|
2077
|
-
},
|
|
2078
|
-
muted: {
|
|
2079
|
-
base: darkMuted,
|
|
2080
|
-
foreground: darkMutedForeground
|
|
2081
|
-
}
|
|
2082
|
-
},
|
|
2083
|
-
fontSizes: { ...DEFAULT_FONT_SIZES },
|
|
2084
|
-
fontFamilies: { ...DEFAULT_FONT_FAMILIES },
|
|
2085
|
-
spacing: DEFAULT_SPACING,
|
|
2086
|
-
radii: { ...DEFAULT_RADII }
|
|
2087
|
-
};
|
|
2088
|
-
}
|
|
2089
|
-
//#endregion
|
|
2090
|
-
//#region ../core/src/theme/serialisation.ts
|
|
2091
|
-
function colorToPlain(color) {
|
|
2092
|
-
return {
|
|
2093
|
-
l: color.oklch.l ?? 0,
|
|
2094
|
-
c: color.oklch.c ?? 0,
|
|
2095
|
-
h: color.oklch.h ?? 0
|
|
2096
|
-
};
|
|
2097
|
-
}
|
|
2098
|
-
function plainToColor(plain) {
|
|
2099
|
-
return new colorjs_io.default("oklch", [
|
|
2100
|
-
plain.l,
|
|
2101
|
-
plain.c,
|
|
2102
|
-
plain.h
|
|
2103
|
-
]);
|
|
2104
|
-
}
|
|
2105
|
-
/**
|
|
2106
|
-
* Serialise a ThemeDefinition (with Color objects) to a plain JSON payload
|
|
2107
|
-
* suitable for backend storage.
|
|
2108
|
-
*/
|
|
2109
|
-
function serialiseTheme(def) {
|
|
2110
|
-
const light = {};
|
|
2111
|
-
for (const name of SEMANTIC_COLOR_NAMES) light[name] = {
|
|
2112
|
-
base: colorToPlain(def.light[name].base),
|
|
2113
|
-
foreground: colorToPlain(def.light[name].foreground)
|
|
2114
|
-
};
|
|
2115
|
-
const dark = {};
|
|
2116
|
-
for (const [name, value] of Object.entries(def.dark)) {
|
|
2117
|
-
if (!value) continue;
|
|
2118
|
-
dark[name] = {
|
|
2119
|
-
...value.base ? { base: colorToPlain(value.base) } : {},
|
|
2120
|
-
...value.foreground ? { foreground: colorToPlain(value.foreground) } : {}
|
|
2121
|
-
};
|
|
2122
|
-
}
|
|
2123
|
-
return {
|
|
2124
|
-
id: def.id,
|
|
2125
|
-
name: def.name,
|
|
2126
|
-
light,
|
|
2127
|
-
dark,
|
|
2128
|
-
fontSizes: { ...def.fontSizes },
|
|
2129
|
-
fontFamilies: { ...def.fontFamilies },
|
|
2130
|
-
spacing: def.spacing,
|
|
2131
|
-
radii: { ...def.radii },
|
|
2132
|
-
...def.syncWithBrandColors ? { syncWithBrandColors: true } : {}
|
|
2133
|
-
};
|
|
2134
|
-
}
|
|
2135
|
-
/**
|
|
2136
|
-
* Deserialise a backend payload into a ThemeDefinition with Color objects.
|
|
2137
|
-
* Accepts `Record<string, unknown>` because API data is untyped at the boundary.
|
|
2138
|
-
* Falls back to default colors for any missing light-mode entries.
|
|
2139
|
-
*/
|
|
2140
|
-
function deserialiseTheme(payload) {
|
|
2141
|
-
const lightRaw = payload.light ?? {};
|
|
2142
|
-
const darkRaw = payload.dark ?? {};
|
|
2143
|
-
const defaults = getDefaultThemeDefinition();
|
|
2144
|
-
const light = {};
|
|
2145
|
-
for (const name of SEMANTIC_COLOR_NAMES) {
|
|
2146
|
-
const entry = lightRaw[name];
|
|
2147
|
-
if (entry) light[name] = {
|
|
2148
|
-
base: plainToColor(entry.base),
|
|
2149
|
-
foreground: plainToColor(entry.foreground)
|
|
2150
|
-
};
|
|
2151
|
-
else {
|
|
2152
|
-
console.warn(`[theme] deserialiseTheme: missing light color "${name}", using default`);
|
|
2153
|
-
light[name] = defaults.light[name];
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
const dark = {};
|
|
2157
|
-
for (const [name, value] of Object.entries(darkRaw)) {
|
|
2158
|
-
if (!value) continue;
|
|
2159
|
-
dark[name] = {
|
|
2160
|
-
...value.base ? { base: plainToColor(value.base) } : {},
|
|
2161
|
-
...value.foreground ? { foreground: plainToColor(value.foreground) } : {}
|
|
2162
|
-
};
|
|
2163
|
-
}
|
|
2164
|
-
return {
|
|
2165
|
-
id: payload.id,
|
|
2166
|
-
name: payload.name,
|
|
2167
|
-
light,
|
|
2168
|
-
dark,
|
|
2169
|
-
fontSizes: payload.fontSizes ?? DEFAULT_FONT_SIZES,
|
|
2170
|
-
fontFamilies: payload.fontFamilies ?? DEFAULT_FONT_FAMILIES,
|
|
2171
|
-
spacing: payload.spacing ?? "0.25rem",
|
|
2172
|
-
radii: payload.radii ?? DEFAULT_RADII,
|
|
2173
|
-
...payload.syncWithBrandColors === true ? { syncWithBrandColors: true } : {}
|
|
2174
|
-
};
|
|
2175
|
-
}
|
|
2176
|
-
//#endregion
|
|
2177
|
-
//#region ../core/src/theme/transforms.ts
|
|
2178
|
-
/**
|
|
2179
|
-
* Check if a theme config uses the new structured format (has a `light` key
|
|
2180
|
-
* that is an object) vs the legacy flat format.
|
|
2181
|
-
*/
|
|
2182
|
-
function isNewThemeFormat(config) {
|
|
2183
|
-
return config.light != null && typeof config.light === "object";
|
|
2184
|
-
}
|
|
2185
|
-
/**
|
|
2186
|
-
* Convert a legacy flat config to a ThemeDefinition.
|
|
2187
|
-
* Legacy format: { base: "#fff", text: "#000", primary: "oklch(0.6 0.2 250)", ... }
|
|
2188
|
-
*/
|
|
2189
|
-
function legacyConfigToDefinition(id, name, config) {
|
|
2190
|
-
const bg = parseColor(config.base ?? config.background ?? DEFAULT_COLORS.background);
|
|
2191
|
-
const fg = parseColor(config.text ?? config.foreground ?? DEFAULT_COLORS.foreground);
|
|
2192
|
-
const primary = parseColor(config.primary ?? DEFAULT_COLORS.primary);
|
|
2193
|
-
const secondary = parseColor(config.secondary ?? DEFAULT_COLORS.secondary);
|
|
2194
|
-
const accent = parseColor(config.accent ?? DEFAULT_COLORS.accent);
|
|
2195
|
-
const muted = parseColor(config.muted ?? DEFAULT_COLORS.muted);
|
|
2196
|
-
const destructive = parseColor(config.destructive ?? DEFAULT_COLORS.destructive);
|
|
2197
|
-
const mutedFg = parseColor(config.mutedForeground ?? DEFAULT_COLORS.mutedForeground);
|
|
2198
|
-
return {
|
|
2199
|
-
id: String(id),
|
|
2200
|
-
name,
|
|
2201
|
-
light: {
|
|
2202
|
-
background: {
|
|
2203
|
-
base: bg,
|
|
2204
|
-
foreground: fg
|
|
2205
|
-
},
|
|
2206
|
-
foreground: {
|
|
2207
|
-
base: fg,
|
|
2208
|
-
foreground: bg
|
|
2209
|
-
},
|
|
2210
|
-
primary: {
|
|
2211
|
-
base: primary,
|
|
2212
|
-
foreground: getForegroundColor(fg, primary)
|
|
2213
|
-
},
|
|
2214
|
-
secondary: {
|
|
2215
|
-
base: secondary,
|
|
2216
|
-
foreground: getForegroundColor(fg, secondary)
|
|
2217
|
-
},
|
|
2218
|
-
accent: {
|
|
2219
|
-
base: accent,
|
|
2220
|
-
foreground: getForegroundColor(fg, accent)
|
|
2221
|
-
},
|
|
2222
|
-
muted: {
|
|
2223
|
-
base: muted,
|
|
2224
|
-
foreground: mutedFg
|
|
2225
|
-
},
|
|
2226
|
-
destructive: {
|
|
2227
|
-
base: destructive,
|
|
2228
|
-
foreground: getForegroundColor(fg, destructive)
|
|
2229
|
-
}
|
|
2230
|
-
},
|
|
2231
|
-
dark: {},
|
|
2232
|
-
fontSizes: {
|
|
2233
|
-
extraSmall: config.extraSmall ?? DEFAULT_FONT_SIZES.extraSmall,
|
|
2234
|
-
small: config.small ?? DEFAULT_FONT_SIZES.small,
|
|
2235
|
-
regular: config.regular ?? DEFAULT_FONT_SIZES.regular,
|
|
2236
|
-
large: config.large ?? DEFAULT_FONT_SIZES.large,
|
|
2237
|
-
extraLarge: config.extraLarge ?? DEFAULT_FONT_SIZES.extraLarge,
|
|
2238
|
-
giant: config.giant ?? DEFAULT_FONT_SIZES.giant
|
|
2239
|
-
},
|
|
2240
|
-
fontFamilies: {
|
|
2241
|
-
header: config.headerFont ?? DEFAULT_FONT_FAMILIES.header,
|
|
2242
|
-
body: config.bodyFont ?? DEFAULT_FONT_FAMILIES.body
|
|
2243
|
-
},
|
|
2244
|
-
spacing: config.globalSpacing ?? "0.25rem",
|
|
2245
|
-
radii: {
|
|
2246
|
-
small: config.radiusSmall ?? DEFAULT_RADII.small,
|
|
2247
|
-
medium: config.radiusMedium ?? DEFAULT_RADII.medium,
|
|
2248
|
-
large: config.radiusLarge ?? DEFAULT_RADII.large,
|
|
2249
|
-
extraLarge: config.radiusExtraLarge ?? DEFAULT_RADII.extraLarge
|
|
2250
|
-
}
|
|
2251
|
-
};
|
|
2252
|
-
}
|
|
2253
|
-
/**
|
|
2254
|
-
* Build a ThemeDefinition from a single API theme object.
|
|
2255
|
-
* Handles both new structured format and legacy flat format.
|
|
2256
|
-
*/
|
|
2257
|
-
function buildThemeDefinition(theme) {
|
|
2258
|
-
const config = theme.config ?? {};
|
|
2259
|
-
if (isNewThemeFormat(config)) return deserialiseTheme({
|
|
2260
|
-
...config,
|
|
2261
|
-
id: String(theme.id),
|
|
2262
|
-
name: theme.name ?? "Untitled Theme"
|
|
2263
|
-
});
|
|
2264
|
-
return legacyConfigToDefinition(theme.id, theme.name ?? "Untitled Theme", config);
|
|
2265
|
-
}
|
|
2266
|
-
/**
|
|
2267
|
-
* Transform raw API themes to ThemeDefinition[].
|
|
2268
|
-
* Catches and logs errors per theme (graceful degradation).
|
|
2269
|
-
*/
|
|
2270
|
-
function transformThemes(themes) {
|
|
2271
|
-
return themes.flatMap((theme) => {
|
|
2272
|
-
try {
|
|
2273
|
-
return [buildThemeDefinition(theme)];
|
|
2274
|
-
} catch (error) {
|
|
2275
|
-
console.error(`[theme] Failed to build theme id=${theme.id}:`, error);
|
|
2276
|
-
return [];
|
|
2277
|
-
}
|
|
2278
|
-
});
|
|
2279
|
-
}
|
|
2280
|
-
/**
|
|
2281
|
-
* Get the active theme ID from a list of raw API themes.
|
|
2282
|
-
* Falls back to the first theme if none is marked active.
|
|
2283
|
-
*/
|
|
2284
|
-
function getActiveThemeId(themes) {
|
|
2285
|
-
const active = themes.find((t) => t.active) ?? themes[0];
|
|
2286
|
-
return active ? String(active.id) : void 0;
|
|
2287
|
-
}
|
|
2288
|
-
//#endregion
|
|
2289
|
-
//#region ../core/src/theme/theme-applicator.ts
|
|
2290
|
-
const STYLE_PREFIX = "theme-style-";
|
|
2291
|
-
const FONT_LINK_PREFIX = "theme-font-";
|
|
2292
|
-
const SYSTEM_FONTS = new Set([
|
|
2293
|
-
"sans-serif",
|
|
2294
|
-
"serif",
|
|
2295
|
-
"monospace",
|
|
2296
|
-
"cursive",
|
|
2297
|
-
"fantasy",
|
|
2298
|
-
"system-ui",
|
|
2299
|
-
"ui-sans-serif",
|
|
2300
|
-
"ui-serif",
|
|
2301
|
-
"ui-monospace"
|
|
2302
|
-
]);
|
|
2303
|
-
/** Build a Google Fonts CSS2 URL for a given font family with all weights. */
|
|
2304
|
-
function buildGoogleFontUrl(family) {
|
|
2305
|
-
return `https://fonts.googleapis.com/css2?family=${encodeURIComponent(family).replace(/%20/g, "+")}:wght@100;200;300;400;500;600;700;800;900&display=swap`;
|
|
2306
|
-
}
|
|
2307
|
-
/** Check if a font family value needs to be loaded (i.e. is not a CSS var or system font). */
|
|
2308
|
-
function isLoadableFont(value) {
|
|
2309
|
-
if (!value) return false;
|
|
2310
|
-
if (value.startsWith("var(")) return false;
|
|
2311
|
-
return !SYSTEM_FONTS.has(value.toLowerCase());
|
|
2312
|
-
}
|
|
2313
|
-
/** Deterministic link element ID for a font family. */
|
|
2314
|
-
function fontLinkId(family) {
|
|
2315
|
-
return `${FONT_LINK_PREFIX}${family.replace(/\s+/g, "-").toLowerCase()}`;
|
|
2316
|
-
}
|
|
2317
|
-
/**
|
|
2318
|
-
* Inject or update `<link>` elements for Google Fonts used by the theme.
|
|
2319
|
-
* Removes links for fonts that are no longer referenced.
|
|
2320
|
-
*/
|
|
2321
|
-
function loadThemeFonts(theme) {
|
|
2322
|
-
if (typeof document === "undefined") return;
|
|
2323
|
-
const fontsToLoad = /* @__PURE__ */ new Set();
|
|
2324
|
-
for (const key of FONT_FAMILY_KEYS) {
|
|
2325
|
-
const value = theme.fontFamilies[key];
|
|
2326
|
-
if (isLoadableFont(value)) fontsToLoad.add(value);
|
|
2327
|
-
}
|
|
2328
|
-
document.querySelectorAll(`link[id^="${FONT_LINK_PREFIX}"]`).forEach((link) => {
|
|
2329
|
-
const owners = link.getAttribute("data-font-theme-ids")?.split(",") ?? [];
|
|
2330
|
-
if (!owners.includes(theme.id)) return;
|
|
2331
|
-
const fontName = link.getAttribute("data-font-family");
|
|
2332
|
-
if (fontName && !fontsToLoad.has(fontName)) {
|
|
2333
|
-
const remaining = owners.filter((id) => id !== theme.id);
|
|
2334
|
-
if (remaining.length === 0) link.remove();
|
|
2335
|
-
else link.setAttribute("data-font-theme-ids", remaining.join(","));
|
|
2336
|
-
}
|
|
2337
|
-
});
|
|
2338
|
-
for (const family of fontsToLoad) {
|
|
2339
|
-
const id = fontLinkId(family);
|
|
2340
|
-
const existing = document.getElementById(id);
|
|
2341
|
-
if (existing) {
|
|
2342
|
-
const owners = existing.getAttribute("data-font-theme-ids")?.split(",") ?? [];
|
|
2343
|
-
if (!owners.includes(theme.id)) existing.setAttribute("data-font-theme-ids", [...owners, theme.id].join(","));
|
|
2344
|
-
} else {
|
|
2345
|
-
const link = document.createElement("link");
|
|
2346
|
-
link.id = id;
|
|
2347
|
-
link.rel = "stylesheet";
|
|
2348
|
-
link.href = buildGoogleFontUrl(family);
|
|
2349
|
-
link.setAttribute("data-font-family", family);
|
|
2350
|
-
link.setAttribute("data-font-theme-ids", theme.id);
|
|
2351
|
-
document.head.appendChild(link);
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
}
|
|
2355
|
-
/** Remove all font `<link>` elements injected by the theme system. */
|
|
2356
|
-
function removeAllFontLinks() {
|
|
2357
|
-
if (typeof document === "undefined") return;
|
|
2358
|
-
document.querySelectorAll(`link[id^="${FONT_LINK_PREFIX}"]`).forEach((el) => el.remove());
|
|
2359
|
-
}
|
|
2360
|
-
/**
|
|
2361
|
-
* Inject or update a `<style>` element in `<head>` for the given theme.
|
|
2362
|
-
* The element ID is deterministic (`theme-style-{themeId}`) so repeated calls
|
|
2363
|
-
* for the same theme are idempotent — the existing element is updated in place.
|
|
2364
|
-
* Also loads Google Fonts referenced by the theme's font families.
|
|
2365
|
-
* No-op when `document` is unavailable (SSR).
|
|
2366
|
-
*/
|
|
2367
|
-
function applyTheme(theme, options) {
|
|
2368
|
-
if (typeof document === "undefined") return;
|
|
2369
|
-
try {
|
|
2370
|
-
loadThemeFonts(theme);
|
|
2371
|
-
const styleId = `${STYLE_PREFIX}${theme.id}`;
|
|
2372
|
-
let el = document.getElementById(styleId);
|
|
2373
|
-
if (!el) {
|
|
2374
|
-
el = document.createElement("style");
|
|
2375
|
-
el.id = styleId;
|
|
2376
|
-
document.head.appendChild(el);
|
|
2377
|
-
}
|
|
2378
|
-
el.textContent = generateThemeCSS(theme, options);
|
|
2379
|
-
} catch (error) {
|
|
2380
|
-
console.error(`[theme] applyTheme failed for "${theme.id}":`, error);
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
/** Remove an injected theme stylesheet and clean up font link ownership. No-op during SSR. */
|
|
2384
|
-
function removeTheme(themeId) {
|
|
2385
|
-
if (typeof document === "undefined") return;
|
|
2386
|
-
document.getElementById(`${STYLE_PREFIX}${themeId}`)?.remove();
|
|
2387
|
-
document.querySelectorAll(`link[id^="${FONT_LINK_PREFIX}"]`).forEach((link) => {
|
|
2388
|
-
const remaining = (link.getAttribute("data-font-theme-ids")?.split(",") ?? []).filter((id) => id !== themeId);
|
|
2389
|
-
if (remaining.length === 0) link.remove();
|
|
2390
|
-
else link.setAttribute("data-font-theme-ids", remaining.join(","));
|
|
2391
|
-
});
|
|
2392
|
-
}
|
|
2393
|
-
/** Remove all injected theme stylesheets and font links. No-op during SSR. */
|
|
2394
|
-
function removeAllThemes() {
|
|
2395
|
-
if (typeof document === "undefined") return;
|
|
2396
|
-
document.querySelectorAll(`style[id^="${STYLE_PREFIX}"]`).forEach((el) => el.remove());
|
|
2397
|
-
removeAllFontLinks();
|
|
2398
|
-
}
|
|
2399
|
-
//#endregion
|
|
2400
1588
|
//#region src/providers/FluidThemeProvider.tsx
|
|
2401
1589
|
/**
|
|
2402
1590
|
* Theme Provider for Fluid SDK
|
|
@@ -2410,7 +1598,7 @@ const ThemeContext = (0, react.createContext)(null);
|
|
|
2410
1598
|
*/
|
|
2411
1599
|
function applyThemeToDOM(theme, mode, container) {
|
|
2412
1600
|
const target = container ?? document.documentElement;
|
|
2413
|
-
applyTheme(resolveTheme(theme));
|
|
1601
|
+
require_src.applyTheme(require_src.resolveTheme(theme));
|
|
2414
1602
|
target.dataset.theme = theme.id;
|
|
2415
1603
|
if (mode) target.dataset.themeMode = mode;
|
|
2416
1604
|
else delete target.dataset.themeMode;
|
|
@@ -2421,7 +1609,7 @@ function FluidThemeProvider({ children, initialTheme, container }) {
|
|
|
2421
1609
|
(0, react.useEffect)(() => {
|
|
2422
1610
|
if (currentTheme) applyThemeToDOM(currentTheme, mode, container ?? null);
|
|
2423
1611
|
return () => {
|
|
2424
|
-
if (currentTheme) removeTheme(currentTheme.id);
|
|
1612
|
+
if (currentTheme) require_src.removeTheme(currentTheme.id);
|
|
2425
1613
|
};
|
|
2426
1614
|
}, [
|
|
2427
1615
|
currentTheme,
|
|
@@ -2907,7 +2095,7 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
|
|
|
2907
2095
|
value: storeApi,
|
|
2908
2096
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PayApiProvider, {
|
|
2909
2097
|
value: payApi,
|
|
2910
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2098
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_src.CountriesApiProvider, {
|
|
2911
2099
|
value: countriesApi,
|
|
2912
2100
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LanguagesApiProvider, {
|
|
2913
2101
|
value: languagesApi,
|
|
@@ -2973,66 +2161,12 @@ Object.defineProperty(exports, "ApiError", {
|
|
|
2973
2161
|
return ApiError;
|
|
2974
2162
|
}
|
|
2975
2163
|
});
|
|
2976
|
-
Object.defineProperty(exports, "DEFAULT_COLORS", {
|
|
2977
|
-
enumerable: true,
|
|
2978
|
-
get: function() {
|
|
2979
|
-
return DEFAULT_COLORS;
|
|
2980
|
-
}
|
|
2981
|
-
});
|
|
2982
|
-
Object.defineProperty(exports, "DEFAULT_FONT_FAMILIES", {
|
|
2983
|
-
enumerable: true,
|
|
2984
|
-
get: function() {
|
|
2985
|
-
return DEFAULT_FONT_FAMILIES;
|
|
2986
|
-
}
|
|
2987
|
-
});
|
|
2988
|
-
Object.defineProperty(exports, "DEFAULT_FONT_SIZES", {
|
|
2989
|
-
enumerable: true,
|
|
2990
|
-
get: function() {
|
|
2991
|
-
return DEFAULT_FONT_SIZES;
|
|
2992
|
-
}
|
|
2993
|
-
});
|
|
2994
|
-
Object.defineProperty(exports, "DEFAULT_RADII", {
|
|
2995
|
-
enumerable: true,
|
|
2996
|
-
get: function() {
|
|
2997
|
-
return DEFAULT_RADII;
|
|
2998
|
-
}
|
|
2999
|
-
});
|
|
3000
2164
|
Object.defineProperty(exports, "DEFAULT_SDK_WIDGET_REGISTRY", {
|
|
3001
2165
|
enumerable: true,
|
|
3002
2166
|
get: function() {
|
|
3003
2167
|
return DEFAULT_SDK_WIDGET_REGISTRY;
|
|
3004
2168
|
}
|
|
3005
2169
|
});
|
|
3006
|
-
Object.defineProperty(exports, "DEFAULT_SPACING", {
|
|
3007
|
-
enumerable: true,
|
|
3008
|
-
get: function() {
|
|
3009
|
-
return DEFAULT_SPACING;
|
|
3010
|
-
}
|
|
3011
|
-
});
|
|
3012
|
-
Object.defineProperty(exports, "DEFAULT_THEME_ID", {
|
|
3013
|
-
enumerable: true,
|
|
3014
|
-
get: function() {
|
|
3015
|
-
return DEFAULT_THEME_ID;
|
|
3016
|
-
}
|
|
3017
|
-
});
|
|
3018
|
-
Object.defineProperty(exports, "DEFAULT_THEME_NAME", {
|
|
3019
|
-
enumerable: true,
|
|
3020
|
-
get: function() {
|
|
3021
|
-
return DEFAULT_THEME_NAME;
|
|
3022
|
-
}
|
|
3023
|
-
});
|
|
3024
|
-
Object.defineProperty(exports, "FONT_FAMILY_KEYS", {
|
|
3025
|
-
enumerable: true,
|
|
3026
|
-
get: function() {
|
|
3027
|
-
return FONT_FAMILY_KEYS;
|
|
3028
|
-
}
|
|
3029
|
-
});
|
|
3030
|
-
Object.defineProperty(exports, "FONT_SIZE_KEYS", {
|
|
3031
|
-
enumerable: true,
|
|
3032
|
-
get: function() {
|
|
3033
|
-
return FONT_SIZE_KEYS;
|
|
3034
|
-
}
|
|
3035
|
-
});
|
|
3036
2170
|
Object.defineProperty(exports, "FluidProvider", {
|
|
3037
2171
|
enumerable: true,
|
|
3038
2172
|
get: function() {
|
|
@@ -3045,36 +2179,6 @@ Object.defineProperty(exports, "FluidThemeProvider", {
|
|
|
3045
2179
|
return FluidThemeProvider;
|
|
3046
2180
|
}
|
|
3047
2181
|
});
|
|
3048
|
-
Object.defineProperty(exports, "RADIUS_KEYS", {
|
|
3049
|
-
enumerable: true,
|
|
3050
|
-
get: function() {
|
|
3051
|
-
return RADIUS_KEYS;
|
|
3052
|
-
}
|
|
3053
|
-
});
|
|
3054
|
-
Object.defineProperty(exports, "SEMANTIC_COLOR_NAMES", {
|
|
3055
|
-
enumerable: true,
|
|
3056
|
-
get: function() {
|
|
3057
|
-
return SEMANTIC_COLOR_NAMES;
|
|
3058
|
-
}
|
|
3059
|
-
});
|
|
3060
|
-
Object.defineProperty(exports, "SHADE_STEPS", {
|
|
3061
|
-
enumerable: true,
|
|
3062
|
-
get: function() {
|
|
3063
|
-
return SHADE_STEPS;
|
|
3064
|
-
}
|
|
3065
|
-
});
|
|
3066
|
-
Object.defineProperty(exports, "applyTheme", {
|
|
3067
|
-
enumerable: true,
|
|
3068
|
-
get: function() {
|
|
3069
|
-
return applyTheme;
|
|
3070
|
-
}
|
|
3071
|
-
});
|
|
3072
|
-
Object.defineProperty(exports, "buildThemeDefinition", {
|
|
3073
|
-
enumerable: true,
|
|
3074
|
-
get: function() {
|
|
3075
|
-
return buildThemeDefinition;
|
|
3076
|
-
}
|
|
3077
|
-
});
|
|
3078
2182
|
Object.defineProperty(exports, "createPersister", {
|
|
3079
2183
|
enumerable: true,
|
|
3080
2184
|
get: function() {
|
|
@@ -3105,90 +2209,6 @@ Object.defineProperty(exports, "deleteDatabase", {
|
|
|
3105
2209
|
return deleteDatabase;
|
|
3106
2210
|
}
|
|
3107
2211
|
});
|
|
3108
|
-
Object.defineProperty(exports, "deriveDarkVariant", {
|
|
3109
|
-
enumerable: true,
|
|
3110
|
-
get: function() {
|
|
3111
|
-
return deriveDarkVariant;
|
|
3112
|
-
}
|
|
3113
|
-
});
|
|
3114
|
-
Object.defineProperty(exports, "deserialiseTheme", {
|
|
3115
|
-
enumerable: true,
|
|
3116
|
-
get: function() {
|
|
3117
|
-
return deserialiseTheme;
|
|
3118
|
-
}
|
|
3119
|
-
});
|
|
3120
|
-
Object.defineProperty(exports, "generateShades", {
|
|
3121
|
-
enumerable: true,
|
|
3122
|
-
get: function() {
|
|
3123
|
-
return generateShades;
|
|
3124
|
-
}
|
|
3125
|
-
});
|
|
3126
|
-
Object.defineProperty(exports, "generateThemeCSS", {
|
|
3127
|
-
enumerable: true,
|
|
3128
|
-
get: function() {
|
|
3129
|
-
return generateThemeCSS;
|
|
3130
|
-
}
|
|
3131
|
-
});
|
|
3132
|
-
Object.defineProperty(exports, "getActiveThemeId", {
|
|
3133
|
-
enumerable: true,
|
|
3134
|
-
get: function() {
|
|
3135
|
-
return getActiveThemeId;
|
|
3136
|
-
}
|
|
3137
|
-
});
|
|
3138
|
-
Object.defineProperty(exports, "getDefaultThemeDefinition", {
|
|
3139
|
-
enumerable: true,
|
|
3140
|
-
get: function() {
|
|
3141
|
-
return getDefaultThemeDefinition;
|
|
3142
|
-
}
|
|
3143
|
-
});
|
|
3144
|
-
Object.defineProperty(exports, "getForegroundColor", {
|
|
3145
|
-
enumerable: true,
|
|
3146
|
-
get: function() {
|
|
3147
|
-
return getForegroundColor;
|
|
3148
|
-
}
|
|
3149
|
-
});
|
|
3150
|
-
Object.defineProperty(exports, "mergeDarkOverrides", {
|
|
3151
|
-
enumerable: true,
|
|
3152
|
-
get: function() {
|
|
3153
|
-
return mergeDarkOverrides;
|
|
3154
|
-
}
|
|
3155
|
-
});
|
|
3156
|
-
Object.defineProperty(exports, "parseColor", {
|
|
3157
|
-
enumerable: true,
|
|
3158
|
-
get: function() {
|
|
3159
|
-
return parseColor;
|
|
3160
|
-
}
|
|
3161
|
-
});
|
|
3162
|
-
Object.defineProperty(exports, "removeAllThemes", {
|
|
3163
|
-
enumerable: true,
|
|
3164
|
-
get: function() {
|
|
3165
|
-
return removeAllThemes;
|
|
3166
|
-
}
|
|
3167
|
-
});
|
|
3168
|
-
Object.defineProperty(exports, "removeTheme", {
|
|
3169
|
-
enumerable: true,
|
|
3170
|
-
get: function() {
|
|
3171
|
-
return removeTheme;
|
|
3172
|
-
}
|
|
3173
|
-
});
|
|
3174
|
-
Object.defineProperty(exports, "resolveTheme", {
|
|
3175
|
-
enumerable: true,
|
|
3176
|
-
get: function() {
|
|
3177
|
-
return resolveTheme;
|
|
3178
|
-
}
|
|
3179
|
-
});
|
|
3180
|
-
Object.defineProperty(exports, "serialiseTheme", {
|
|
3181
|
-
enumerable: true,
|
|
3182
|
-
get: function() {
|
|
3183
|
-
return serialiseTheme;
|
|
3184
|
-
}
|
|
3185
|
-
});
|
|
3186
|
-
Object.defineProperty(exports, "transformThemes", {
|
|
3187
|
-
enumerable: true,
|
|
3188
|
-
get: function() {
|
|
3189
|
-
return transformThemes;
|
|
3190
|
-
}
|
|
3191
|
-
});
|
|
3192
2212
|
Object.defineProperty(exports, "useAppDefinitionApi", {
|
|
3193
2213
|
enumerable: true,
|
|
3194
2214
|
get: function() {
|
|
@@ -3226,4 +2246,4 @@ Object.defineProperty(exports, "widgetPropertySchemas", {
|
|
|
3226
2246
|
}
|
|
3227
2247
|
});
|
|
3228
2248
|
|
|
3229
|
-
//# sourceMappingURL=FluidProvider-
|
|
2249
|
+
//# sourceMappingURL=FluidProvider-ByBDIQeW.cjs.map
|