@xsolla/xui-core 0.113.0 → 0.114.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +52 -4
- package/index.d.ts +52 -4
- package/index.js +243 -5
- package/index.js.flow +52 -6
- package/index.js.map +1 -1
- package/index.mjs +239 -5
- package/index.mjs.map +1 -1
- package/package.json +5 -2
package/index.mjs
CHANGED
|
@@ -1803,6 +1803,207 @@ var typography = {
|
|
|
1803
1803
|
}
|
|
1804
1804
|
};
|
|
1805
1805
|
|
|
1806
|
+
// src/tokens/typography.ts
|
|
1807
|
+
var typographyTokens = {
|
|
1808
|
+
b2c: {
|
|
1809
|
+
heading: {
|
|
1810
|
+
h1: { fontSize: 40, lineHeight: "48px", fontWeight: 700 },
|
|
1811
|
+
h2: { fontSize: 32, lineHeight: "38px", fontWeight: 700 },
|
|
1812
|
+
h3: { fontSize: 28, lineHeight: "34px", fontWeight: 700 },
|
|
1813
|
+
h4: { fontSize: 24, lineHeight: "28px", fontWeight: 700 },
|
|
1814
|
+
h5: { fontSize: 20, lineHeight: "24px", fontWeight: 700 }
|
|
1815
|
+
},
|
|
1816
|
+
basic: {
|
|
1817
|
+
display: { fontSize: 48, lineHeight: "58px", fontWeight: 800 },
|
|
1818
|
+
"body-lg": {
|
|
1819
|
+
fontSize: 18,
|
|
1820
|
+
lineHeight: "24px",
|
|
1821
|
+
fontWeight: 400,
|
|
1822
|
+
accent: { fontWeight: 500 },
|
|
1823
|
+
paragraph: { lineHeight: "26px", spacing: 20 }
|
|
1824
|
+
},
|
|
1825
|
+
"body-md": {
|
|
1826
|
+
fontSize: 16,
|
|
1827
|
+
lineHeight: "20px",
|
|
1828
|
+
fontWeight: 400,
|
|
1829
|
+
accent: { fontWeight: 500 },
|
|
1830
|
+
paragraph: { lineHeight: "22px", spacing: 16 }
|
|
1831
|
+
},
|
|
1832
|
+
"body-sm": {
|
|
1833
|
+
fontSize: 14,
|
|
1834
|
+
lineHeight: "18px",
|
|
1835
|
+
fontWeight: 400,
|
|
1836
|
+
accent: { fontWeight: 500 },
|
|
1837
|
+
paragraph: { lineHeight: "20px", spacing: 12 }
|
|
1838
|
+
},
|
|
1839
|
+
"body-xs": {
|
|
1840
|
+
fontSize: 12,
|
|
1841
|
+
lineHeight: "16px",
|
|
1842
|
+
fontWeight: 400,
|
|
1843
|
+
accent: { fontWeight: 500 },
|
|
1844
|
+
paragraph: { lineHeight: "18px", spacing: 8 }
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
},
|
|
1848
|
+
b2b: {
|
|
1849
|
+
heading: {
|
|
1850
|
+
h1: { fontSize: 56, lineHeight: "68px", fontWeight: 400 },
|
|
1851
|
+
h2: { fontSize: 48, lineHeight: "58px", fontWeight: 400 },
|
|
1852
|
+
h3: { fontSize: 32, lineHeight: "38px", fontWeight: 400 },
|
|
1853
|
+
h4: { fontSize: 24, lineHeight: "28px", fontWeight: 400 },
|
|
1854
|
+
h5: { fontSize: 20, lineHeight: "24px", fontWeight: 600 }
|
|
1855
|
+
},
|
|
1856
|
+
basic: {
|
|
1857
|
+
display: { fontSize: 64, lineHeight: "78px", fontWeight: 400 },
|
|
1858
|
+
"body-lg": {
|
|
1859
|
+
fontSize: 18,
|
|
1860
|
+
lineHeight: "24px",
|
|
1861
|
+
fontWeight: 400,
|
|
1862
|
+
accent: { fontWeight: 500 },
|
|
1863
|
+
paragraph: { lineHeight: "26px", spacing: 20 }
|
|
1864
|
+
},
|
|
1865
|
+
"body-md": {
|
|
1866
|
+
fontSize: 16,
|
|
1867
|
+
lineHeight: "20px",
|
|
1868
|
+
fontWeight: 400,
|
|
1869
|
+
accent: { fontWeight: 500 },
|
|
1870
|
+
paragraph: { lineHeight: "22px", spacing: 16 }
|
|
1871
|
+
},
|
|
1872
|
+
"body-sm": {
|
|
1873
|
+
fontSize: 14,
|
|
1874
|
+
lineHeight: "18px",
|
|
1875
|
+
fontWeight: 400,
|
|
1876
|
+
accent: { fontWeight: 500 },
|
|
1877
|
+
paragraph: { lineHeight: "20px", spacing: 12 }
|
|
1878
|
+
},
|
|
1879
|
+
"body-xs": {
|
|
1880
|
+
fontSize: 12,
|
|
1881
|
+
lineHeight: "16px",
|
|
1882
|
+
fontWeight: 400,
|
|
1883
|
+
accent: { fontWeight: 500 },
|
|
1884
|
+
paragraph: { lineHeight: "18px", spacing: 8 }
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
},
|
|
1888
|
+
paystation: {
|
|
1889
|
+
heading: {
|
|
1890
|
+
h1: { fontSize: 28, lineHeight: "34px", fontWeight: 700 },
|
|
1891
|
+
h2: { fontSize: 24, lineHeight: "28px", fontWeight: 700 },
|
|
1892
|
+
h3: { fontSize: 20, lineHeight: "24px", fontWeight: 700 },
|
|
1893
|
+
h4: { fontSize: 18, lineHeight: "22px", fontWeight: 700 },
|
|
1894
|
+
h5: { fontSize: 16, lineHeight: "20px", fontWeight: 700 }
|
|
1895
|
+
},
|
|
1896
|
+
basic: {
|
|
1897
|
+
display: { fontSize: 40, lineHeight: "48px", fontWeight: 800 },
|
|
1898
|
+
"body-lg": {
|
|
1899
|
+
fontSize: 16,
|
|
1900
|
+
lineHeight: "20px",
|
|
1901
|
+
fontWeight: 400,
|
|
1902
|
+
accent: { fontWeight: 500 },
|
|
1903
|
+
paragraph: { lineHeight: "22px", spacing: 16 }
|
|
1904
|
+
},
|
|
1905
|
+
"body-md": {
|
|
1906
|
+
fontSize: 14,
|
|
1907
|
+
lineHeight: "18px",
|
|
1908
|
+
fontWeight: 400,
|
|
1909
|
+
accent: { fontWeight: 500 },
|
|
1910
|
+
paragraph: { lineHeight: "20px", spacing: 12 }
|
|
1911
|
+
},
|
|
1912
|
+
"body-sm": {
|
|
1913
|
+
fontSize: 12,
|
|
1914
|
+
lineHeight: "16px",
|
|
1915
|
+
fontWeight: 400,
|
|
1916
|
+
accent: { fontWeight: 500 },
|
|
1917
|
+
paragraph: { lineHeight: "18px", spacing: 8 }
|
|
1918
|
+
},
|
|
1919
|
+
"body-xs": {
|
|
1920
|
+
fontSize: 10,
|
|
1921
|
+
lineHeight: "14px",
|
|
1922
|
+
fontWeight: 400,
|
|
1923
|
+
accent: { fontWeight: 500 },
|
|
1924
|
+
paragraph: { lineHeight: "14px", spacing: 6 }
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
},
|
|
1928
|
+
presentation: {
|
|
1929
|
+
heading: {
|
|
1930
|
+
h1: { fontSize: 56, lineHeight: "68px", fontWeight: 700 },
|
|
1931
|
+
h2: { fontSize: 48, lineHeight: "58px", fontWeight: 700 },
|
|
1932
|
+
h3: { fontSize: 40, lineHeight: "48px", fontWeight: 700 },
|
|
1933
|
+
h4: { fontSize: 32, lineHeight: "38px", fontWeight: 700 },
|
|
1934
|
+
h5: { fontSize: 28, lineHeight: "34px", fontWeight: 700 }
|
|
1935
|
+
},
|
|
1936
|
+
basic: {
|
|
1937
|
+
display: { fontSize: 64, lineHeight: "78px", fontWeight: 800 },
|
|
1938
|
+
"body-lg": {
|
|
1939
|
+
fontSize: 24,
|
|
1940
|
+
lineHeight: "30px",
|
|
1941
|
+
fontWeight: 400,
|
|
1942
|
+
accent: { fontWeight: 500 },
|
|
1943
|
+
paragraph: { lineHeight: "34px", spacing: 24 }
|
|
1944
|
+
},
|
|
1945
|
+
"body-md": {
|
|
1946
|
+
fontSize: 20,
|
|
1947
|
+
lineHeight: "26px",
|
|
1948
|
+
fontWeight: 400,
|
|
1949
|
+
accent: { fontWeight: 500 },
|
|
1950
|
+
paragraph: { lineHeight: "28px", spacing: 20 }
|
|
1951
|
+
},
|
|
1952
|
+
"body-sm": {
|
|
1953
|
+
fontSize: 18,
|
|
1954
|
+
lineHeight: "24px",
|
|
1955
|
+
fontWeight: 400,
|
|
1956
|
+
accent: { fontWeight: 500 },
|
|
1957
|
+
paragraph: { lineHeight: "26px", spacing: 16 }
|
|
1958
|
+
},
|
|
1959
|
+
"body-xs": {
|
|
1960
|
+
fontSize: 16,
|
|
1961
|
+
lineHeight: "20px",
|
|
1962
|
+
fontWeight: 400,
|
|
1963
|
+
accent: { fontWeight: 500 },
|
|
1964
|
+
paragraph: { lineHeight: "22px", spacing: 12 }
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
};
|
|
1969
|
+
var defaultProductContext = "b2b";
|
|
1970
|
+
var getTypographyTokens = (productContext = defaultProductContext) => {
|
|
1971
|
+
return typographyTokens[productContext] || typographyTokens[defaultProductContext];
|
|
1972
|
+
};
|
|
1973
|
+
var getTypographyVariant = (productContext, variant) => {
|
|
1974
|
+
const tokens = getTypographyTokens(productContext);
|
|
1975
|
+
if (variant in tokens.heading) {
|
|
1976
|
+
return tokens.heading[variant];
|
|
1977
|
+
}
|
|
1978
|
+
if (variant === "display") {
|
|
1979
|
+
return tokens.basic.display;
|
|
1980
|
+
}
|
|
1981
|
+
const bodyVariantMap = {
|
|
1982
|
+
bodyLg: "body-lg",
|
|
1983
|
+
bodyMd: "body-md",
|
|
1984
|
+
bodySm: "body-sm",
|
|
1985
|
+
bodyXs: "body-xs"
|
|
1986
|
+
};
|
|
1987
|
+
const bodyKey = bodyVariantMap[variant.replace("Accent", "").replace("Paragraph", "")];
|
|
1988
|
+
if (bodyKey && bodyKey in tokens.basic) {
|
|
1989
|
+
const baseVariant = tokens.basic[bodyKey];
|
|
1990
|
+
if (variant.includes("Accent") && baseVariant.accent) {
|
|
1991
|
+
return {
|
|
1992
|
+
...baseVariant,
|
|
1993
|
+
fontWeight: baseVariant.accent.fontWeight
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
if (variant.includes("Paragraph") && baseVariant.paragraph) {
|
|
1997
|
+
return {
|
|
1998
|
+
...baseVariant,
|
|
1999
|
+
lineHeight: baseVariant.paragraph.lineHeight
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
return baseVariant;
|
|
2003
|
+
}
|
|
2004
|
+
return void 0;
|
|
2005
|
+
};
|
|
2006
|
+
|
|
1806
2007
|
// src/fonts/FontLoader.tsx
|
|
1807
2008
|
import { useEffect, useRef } from "react";
|
|
1808
2009
|
|
|
@@ -1817,6 +2018,13 @@ var CDN_BASE = "https://cdn.xsolla.net/strapi-v2-bucket-prod";
|
|
|
1817
2018
|
var fontFacesCSS = `
|
|
1818
2019
|
/* \u2500\u2500 Pilat Wide (headings) \u2500\u2500 */
|
|
1819
2020
|
|
|
2021
|
+
@font-face {
|
|
2022
|
+
font-family: 'Pilat Wide';
|
|
2023
|
+
src: url('${CDN_BASE}/Pilat_Test_Medium_/Pilat_Test_Medium.ttf') format('truetype');
|
|
2024
|
+
font-weight: 400;
|
|
2025
|
+
font-style: normal;
|
|
2026
|
+
font-display: swap;
|
|
2027
|
+
}
|
|
1820
2028
|
@font-face {
|
|
1821
2029
|
font-family: 'Pilat Wide';
|
|
1822
2030
|
src: url('${CDN_BASE}/Pilat_Test_Demi_Bold_bee67c470a/Pilat_Test_Demi_Bold_bee67c470a.ttf') format('truetype');
|
|
@@ -1862,6 +2070,13 @@ var fontFacesCSS = `
|
|
|
1862
2070
|
font-style: normal;
|
|
1863
2071
|
font-display: swap;
|
|
1864
2072
|
}
|
|
2073
|
+
@font-face {
|
|
2074
|
+
font-family: 'Aktiv Grotesk';
|
|
2075
|
+
src: url('${CDN_BASE}/Pilat_Test_Bold_195d1b44fa/Pilat_Test_Bold_195d1b44fa.otf') format('opentype');
|
|
2076
|
+
font-weight: 600;
|
|
2077
|
+
font-style: normal;
|
|
2078
|
+
font-display: swap;
|
|
2079
|
+
}
|
|
1865
2080
|
@font-face {
|
|
1866
2081
|
font-family: 'Aktiv Grotesk';
|
|
1867
2082
|
src: url('${CDN_BASE}/Pilat_Test_Bold_195d1b44fa/Pilat_Test_Bold_195d1b44fa.otf') format('opentype');
|
|
@@ -1895,7 +2110,7 @@ FontLoader.displayName = "FontLoader";
|
|
|
1895
2110
|
|
|
1896
2111
|
// src/index.tsx
|
|
1897
2112
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1898
|
-
var themeConfig = (mode = "dark") => ({
|
|
2113
|
+
var themeConfig = (mode = "dark", productContext = defaultProductContext) => ({
|
|
1899
2114
|
colors: colors[mode],
|
|
1900
2115
|
spacing,
|
|
1901
2116
|
radius,
|
|
@@ -1906,6 +2121,8 @@ var themeConfig = (mode = "dark") => ({
|
|
|
1906
2121
|
heading: fonts.heading,
|
|
1907
2122
|
body: fonts.body
|
|
1908
2123
|
},
|
|
2124
|
+
typographyTokens: getTypographyTokens(productContext),
|
|
2125
|
+
productContext,
|
|
1909
2126
|
sizing: {
|
|
1910
2127
|
button: (size) => {
|
|
1911
2128
|
const configs = {
|
|
@@ -2854,15 +3071,25 @@ var themeConfig = (mode = "dark") => ({
|
|
|
2854
3071
|
var DesignSystemContext = createContext(
|
|
2855
3072
|
void 0
|
|
2856
3073
|
);
|
|
2857
|
-
var XUIProvider = ({
|
|
3074
|
+
var XUIProvider = ({
|
|
3075
|
+
children,
|
|
3076
|
+
initialMode = "dark",
|
|
3077
|
+
initialProductContext = defaultProductContext,
|
|
3078
|
+
loadFonts = true
|
|
3079
|
+
}) => {
|
|
2858
3080
|
const [mode, setMode] = useState(initialMode);
|
|
3081
|
+
const [productContext, setProductContext] = useState(
|
|
3082
|
+
initialProductContext
|
|
3083
|
+
);
|
|
2859
3084
|
const value = useMemo(
|
|
2860
3085
|
() => ({
|
|
2861
3086
|
mode,
|
|
2862
3087
|
setMode,
|
|
2863
|
-
|
|
3088
|
+
productContext,
|
|
3089
|
+
setProductContext,
|
|
3090
|
+
theme: themeConfig(mode, productContext)
|
|
2864
3091
|
}),
|
|
2865
|
-
[mode]
|
|
3092
|
+
[mode, productContext]
|
|
2866
3093
|
);
|
|
2867
3094
|
return /* @__PURE__ */ jsxs(DesignSystemContext.Provider, { value, children: [
|
|
2868
3095
|
loadFonts && /* @__PURE__ */ jsx(FontLoader, {}),
|
|
@@ -2876,7 +3103,10 @@ var useDesignSystem = () => {
|
|
|
2876
3103
|
mode: "dark",
|
|
2877
3104
|
setMode: () => {
|
|
2878
3105
|
},
|
|
2879
|
-
|
|
3106
|
+
productContext: defaultProductContext,
|
|
3107
|
+
setProductContext: () => {
|
|
3108
|
+
},
|
|
3109
|
+
theme: themeConfig("dark", defaultProductContext)
|
|
2880
3110
|
};
|
|
2881
3111
|
}
|
|
2882
3112
|
return context;
|
|
@@ -2895,8 +3125,11 @@ export {
|
|
|
2895
3125
|
ModalIdContext,
|
|
2896
3126
|
XUIProvider,
|
|
2897
3127
|
colors,
|
|
3128
|
+
defaultProductContext,
|
|
2898
3129
|
fontFacesCSS,
|
|
2899
3130
|
fonts,
|
|
3131
|
+
getTypographyTokens,
|
|
3132
|
+
getTypographyVariant,
|
|
2900
3133
|
isAndroid,
|
|
2901
3134
|
isIOS,
|
|
2902
3135
|
isNative,
|
|
@@ -2906,6 +3139,7 @@ export {
|
|
|
2906
3139
|
spacing,
|
|
2907
3140
|
themeConfig,
|
|
2908
3141
|
typography,
|
|
3142
|
+
typographyTokens,
|
|
2909
3143
|
useDesignSystem,
|
|
2910
3144
|
useId,
|
|
2911
3145
|
useModalId
|