@xsolla/xui-typography 0.134.0 → 0.136.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/native/index.d.mts +1 -1
- package/native/index.d.ts +1 -1
- package/native/index.js +208 -45
- package/native/index.js.map +1 -1
- package/native/index.mjs +211 -46
- package/native/index.mjs.map +1 -1
- package/package.json +3 -3
- package/web/index.d.mts +1 -1
- package/web/index.d.ts +1 -1
- package/web/index.js +208 -45
- package/web/index.js.map +1 -1
- package/web/index.mjs +211 -46
- package/web/index.mjs.map +1 -1
package/native/index.mjs
CHANGED
|
@@ -72,7 +72,9 @@ import {
|
|
|
72
72
|
useResolvedTheme,
|
|
73
73
|
getTypographyTokens,
|
|
74
74
|
getFonts,
|
|
75
|
-
|
|
75
|
+
isWeb,
|
|
76
|
+
isNative,
|
|
77
|
+
cssVar
|
|
76
78
|
} from "@xsolla/xui-core";
|
|
77
79
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
78
80
|
var getColor = (color, theme) => {
|
|
@@ -93,22 +95,41 @@ var getColor = (color, theme) => {
|
|
|
93
95
|
return colorMap[color] || color;
|
|
94
96
|
};
|
|
95
97
|
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "h5" || variant === "display";
|
|
98
|
+
var bodyMap = {
|
|
99
|
+
bodyLg: "body-lg",
|
|
100
|
+
bodyLgAccent: "body-lg",
|
|
101
|
+
bodyLgParagraph: "body-lg",
|
|
102
|
+
bodyMd: "body-md",
|
|
103
|
+
bodyMdAccent: "body-md",
|
|
104
|
+
bodyMdParagraph: "body-md",
|
|
105
|
+
bodySm: "body-sm",
|
|
106
|
+
bodySmAccent: "body-sm",
|
|
107
|
+
bodySmParagraph: "body-sm",
|
|
108
|
+
bodyXs: "body-xs",
|
|
109
|
+
bodyXsAccent: "body-xs",
|
|
110
|
+
bodyXsParagraph: "body-xs",
|
|
111
|
+
bodyXxs: "body-xxs",
|
|
112
|
+
bodyXxsAccent: "body-xxs",
|
|
113
|
+
bodyXxsParagraph: "body-xxs"
|
|
114
|
+
};
|
|
115
|
+
var headingMap = {
|
|
116
|
+
h1: "h1",
|
|
117
|
+
h2: "h2",
|
|
118
|
+
h3: "h3",
|
|
119
|
+
h4: "h4",
|
|
120
|
+
h5: "h5"
|
|
121
|
+
};
|
|
96
122
|
var getVariantStyles = (variant, typographyTokens) => {
|
|
97
123
|
if (typographyTokens) {
|
|
98
|
-
const headingMap = {
|
|
99
|
-
h1: "h1",
|
|
100
|
-
h2: "h2",
|
|
101
|
-
h3: "h3",
|
|
102
|
-
h4: "h4",
|
|
103
|
-
h5: "h5"
|
|
104
|
-
};
|
|
105
124
|
if (headingMap[variant]) {
|
|
106
125
|
const token = typographyTokens.heading[headingMap[variant]];
|
|
107
126
|
if (token) {
|
|
108
127
|
return {
|
|
109
128
|
fontSize: token.fontSize,
|
|
110
129
|
fontWeight: String(token.fontWeight),
|
|
111
|
-
lineHeight: token.lineHeight
|
|
130
|
+
lineHeight: token.lineHeight,
|
|
131
|
+
scaleStep: token.scaleStep,
|
|
132
|
+
lineHeightCategory: token.lineHeightCategory
|
|
112
133
|
};
|
|
113
134
|
}
|
|
114
135
|
}
|
|
@@ -117,82 +138,223 @@ var getVariantStyles = (variant, typographyTokens) => {
|
|
|
117
138
|
return {
|
|
118
139
|
fontSize: token.fontSize,
|
|
119
140
|
fontWeight: String(token.fontWeight),
|
|
120
|
-
lineHeight: token.lineHeight
|
|
141
|
+
lineHeight: token.lineHeight,
|
|
142
|
+
scaleStep: token.scaleStep,
|
|
143
|
+
lineHeightCategory: token.lineHeightCategory
|
|
121
144
|
};
|
|
122
145
|
}
|
|
123
|
-
const bodyMap = {
|
|
124
|
-
bodyLg: "body-lg",
|
|
125
|
-
bodyLgAccent: "body-lg",
|
|
126
|
-
bodyLgParagraph: "body-lg",
|
|
127
|
-
bodyMd: "body-md",
|
|
128
|
-
bodyMdAccent: "body-md",
|
|
129
|
-
bodyMdParagraph: "body-md",
|
|
130
|
-
bodySm: "body-sm",
|
|
131
|
-
bodySmAccent: "body-sm",
|
|
132
|
-
bodySmParagraph: "body-sm",
|
|
133
|
-
bodyXs: "body-xs",
|
|
134
|
-
bodyXsAccent: "body-xs",
|
|
135
|
-
bodyXsParagraph: "body-xs"
|
|
136
|
-
};
|
|
137
146
|
const bodyKey = bodyMap[variant];
|
|
138
147
|
if (bodyKey && typographyTokens.basic?.[bodyKey]) {
|
|
139
148
|
const token = typographyTokens.basic[bodyKey];
|
|
140
149
|
let fontWeight = token.fontWeight;
|
|
141
150
|
let lineHeight = token.lineHeight;
|
|
151
|
+
let lineHeightCategory = token.lineHeightCategory;
|
|
152
|
+
let lineHeightScaleStep;
|
|
142
153
|
if (variant.includes("Accent") && token.accent) {
|
|
143
154
|
fontWeight = token.accent.fontWeight;
|
|
144
155
|
}
|
|
145
156
|
if (variant.includes("Paragraph") && token.paragraph) {
|
|
146
157
|
lineHeight = token.paragraph.lineHeight;
|
|
158
|
+
lineHeightCategory = "text";
|
|
159
|
+
lineHeightScaleStep = token.paragraph.lineHeightScaleStep;
|
|
147
160
|
}
|
|
148
161
|
return {
|
|
149
162
|
fontSize: token.fontSize,
|
|
150
163
|
fontWeight: String(fontWeight),
|
|
151
|
-
lineHeight
|
|
164
|
+
lineHeight,
|
|
165
|
+
scaleStep: token.scaleStep,
|
|
166
|
+
lineHeightCategory,
|
|
167
|
+
lineHeightScaleStep
|
|
152
168
|
};
|
|
153
169
|
}
|
|
154
170
|
}
|
|
155
171
|
switch (variant) {
|
|
156
172
|
case "h1":
|
|
157
|
-
return {
|
|
173
|
+
return {
|
|
174
|
+
fontSize: 56,
|
|
175
|
+
fontWeight: "400",
|
|
176
|
+
lineHeight: "56px",
|
|
177
|
+
scaleStep: "650",
|
|
178
|
+
lineHeightCategory: "display"
|
|
179
|
+
};
|
|
158
180
|
case "h2":
|
|
159
|
-
return {
|
|
181
|
+
return {
|
|
182
|
+
fontSize: 48,
|
|
183
|
+
fontWeight: "400",
|
|
184
|
+
lineHeight: "48px",
|
|
185
|
+
scaleStep: "550",
|
|
186
|
+
lineHeightCategory: "display"
|
|
187
|
+
};
|
|
160
188
|
case "h3":
|
|
161
|
-
return {
|
|
189
|
+
return {
|
|
190
|
+
fontSize: 32,
|
|
191
|
+
fontWeight: "400",
|
|
192
|
+
lineHeight: "32px",
|
|
193
|
+
scaleStep: "350",
|
|
194
|
+
lineHeightCategory: "display"
|
|
195
|
+
};
|
|
162
196
|
case "h4":
|
|
163
|
-
return {
|
|
197
|
+
return {
|
|
198
|
+
fontSize: 24,
|
|
199
|
+
fontWeight: "400",
|
|
200
|
+
lineHeight: "24px",
|
|
201
|
+
scaleStep: "250",
|
|
202
|
+
lineHeightCategory: "display"
|
|
203
|
+
};
|
|
164
204
|
case "h5":
|
|
165
|
-
return {
|
|
205
|
+
return {
|
|
206
|
+
fontSize: 20,
|
|
207
|
+
fontWeight: "600",
|
|
208
|
+
lineHeight: "20px",
|
|
209
|
+
scaleStep: "200",
|
|
210
|
+
lineHeightCategory: "display"
|
|
211
|
+
};
|
|
166
212
|
case "display":
|
|
167
|
-
return {
|
|
213
|
+
return {
|
|
214
|
+
fontSize: 64,
|
|
215
|
+
fontWeight: "400",
|
|
216
|
+
lineHeight: "64px",
|
|
217
|
+
scaleStep: "750",
|
|
218
|
+
lineHeightCategory: "display"
|
|
219
|
+
};
|
|
168
220
|
case "bodyLg":
|
|
169
|
-
return {
|
|
221
|
+
return {
|
|
222
|
+
fontSize: 18,
|
|
223
|
+
fontWeight: "400",
|
|
224
|
+
lineHeight: "24px",
|
|
225
|
+
scaleStep: "175",
|
|
226
|
+
lineHeightCategory: "compact"
|
|
227
|
+
};
|
|
170
228
|
case "bodyLgAccent":
|
|
171
|
-
return {
|
|
229
|
+
return {
|
|
230
|
+
fontSize: 18,
|
|
231
|
+
fontWeight: "500",
|
|
232
|
+
lineHeight: "24px",
|
|
233
|
+
scaleStep: "175",
|
|
234
|
+
lineHeightCategory: "compact"
|
|
235
|
+
};
|
|
172
236
|
case "bodyLgParagraph":
|
|
173
|
-
return {
|
|
237
|
+
return {
|
|
238
|
+
fontSize: 18,
|
|
239
|
+
fontWeight: "400",
|
|
240
|
+
lineHeight: "26px",
|
|
241
|
+
scaleStep: "175",
|
|
242
|
+
lineHeightCategory: "text"
|
|
243
|
+
};
|
|
174
244
|
case "bodyMd":
|
|
175
|
-
return {
|
|
245
|
+
return {
|
|
246
|
+
fontSize: 16,
|
|
247
|
+
fontWeight: "400",
|
|
248
|
+
lineHeight: "20px",
|
|
249
|
+
scaleStep: "150",
|
|
250
|
+
lineHeightCategory: "compact"
|
|
251
|
+
};
|
|
176
252
|
case "bodyMdAccent":
|
|
177
|
-
return {
|
|
253
|
+
return {
|
|
254
|
+
fontSize: 16,
|
|
255
|
+
fontWeight: "500",
|
|
256
|
+
lineHeight: "20px",
|
|
257
|
+
scaleStep: "150",
|
|
258
|
+
lineHeightCategory: "compact"
|
|
259
|
+
};
|
|
178
260
|
case "bodyMdParagraph":
|
|
179
|
-
return {
|
|
261
|
+
return {
|
|
262
|
+
fontSize: 16,
|
|
263
|
+
fontWeight: "400",
|
|
264
|
+
lineHeight: "22px",
|
|
265
|
+
scaleStep: "150",
|
|
266
|
+
lineHeightCategory: "text"
|
|
267
|
+
};
|
|
180
268
|
case "bodySm":
|
|
181
|
-
return {
|
|
269
|
+
return {
|
|
270
|
+
fontSize: 14,
|
|
271
|
+
fontWeight: "400",
|
|
272
|
+
lineHeight: "18px",
|
|
273
|
+
scaleStep: "125",
|
|
274
|
+
lineHeightCategory: "compact"
|
|
275
|
+
};
|
|
182
276
|
case "bodySmAccent":
|
|
183
|
-
return {
|
|
277
|
+
return {
|
|
278
|
+
fontSize: 14,
|
|
279
|
+
fontWeight: "500",
|
|
280
|
+
lineHeight: "18px",
|
|
281
|
+
scaleStep: "125",
|
|
282
|
+
lineHeightCategory: "compact"
|
|
283
|
+
};
|
|
184
284
|
case "bodySmParagraph":
|
|
185
|
-
return {
|
|
285
|
+
return {
|
|
286
|
+
fontSize: 14,
|
|
287
|
+
fontWeight: "400",
|
|
288
|
+
lineHeight: "20px",
|
|
289
|
+
scaleStep: "125",
|
|
290
|
+
lineHeightCategory: "text"
|
|
291
|
+
};
|
|
186
292
|
case "bodyXs":
|
|
187
|
-
return {
|
|
293
|
+
return {
|
|
294
|
+
fontSize: 12,
|
|
295
|
+
fontWeight: "400",
|
|
296
|
+
lineHeight: "16px",
|
|
297
|
+
scaleStep: "100",
|
|
298
|
+
lineHeightCategory: "compact"
|
|
299
|
+
};
|
|
188
300
|
case "bodyXsAccent":
|
|
189
|
-
return {
|
|
301
|
+
return {
|
|
302
|
+
fontSize: 12,
|
|
303
|
+
fontWeight: "500",
|
|
304
|
+
lineHeight: "16px",
|
|
305
|
+
scaleStep: "100",
|
|
306
|
+
lineHeightCategory: "compact"
|
|
307
|
+
};
|
|
190
308
|
case "bodyXsParagraph":
|
|
191
|
-
return {
|
|
309
|
+
return {
|
|
310
|
+
fontSize: 12,
|
|
311
|
+
fontWeight: "400",
|
|
312
|
+
lineHeight: "18px",
|
|
313
|
+
scaleStep: "100",
|
|
314
|
+
lineHeightCategory: "text"
|
|
315
|
+
};
|
|
316
|
+
case "bodyXxs":
|
|
317
|
+
return {
|
|
318
|
+
fontSize: 10,
|
|
319
|
+
fontWeight: "400",
|
|
320
|
+
lineHeight: "14px",
|
|
321
|
+
scaleStep: "75",
|
|
322
|
+
lineHeightCategory: "compact"
|
|
323
|
+
};
|
|
324
|
+
case "bodyXxsAccent":
|
|
325
|
+
return {
|
|
326
|
+
fontSize: 10,
|
|
327
|
+
fontWeight: "500",
|
|
328
|
+
lineHeight: "14px",
|
|
329
|
+
scaleStep: "75",
|
|
330
|
+
lineHeightCategory: "compact"
|
|
331
|
+
};
|
|
332
|
+
case "bodyXxsParagraph":
|
|
333
|
+
return {
|
|
334
|
+
fontSize: 10,
|
|
335
|
+
fontWeight: "400",
|
|
336
|
+
lineHeight: "14px",
|
|
337
|
+
scaleStep: "75",
|
|
338
|
+
lineHeightCategory: "text"
|
|
339
|
+
};
|
|
192
340
|
default:
|
|
193
|
-
return {
|
|
341
|
+
return {
|
|
342
|
+
fontSize: 16,
|
|
343
|
+
fontWeight: "400",
|
|
344
|
+
lineHeight: "20px",
|
|
345
|
+
scaleStep: "150",
|
|
346
|
+
lineHeightCategory: "compact"
|
|
347
|
+
};
|
|
194
348
|
}
|
|
195
349
|
};
|
|
350
|
+
function getResponsiveLineHeight(styles) {
|
|
351
|
+
const step = styles.lineHeightScaleStep || styles.scaleStep;
|
|
352
|
+
if (!step) return void 0;
|
|
353
|
+
const cat = styles.lineHeightCategory;
|
|
354
|
+
if (cat === "display") return cssVar.lhDisplay(step);
|
|
355
|
+
if (cat === "text") return cssVar.lhText(step);
|
|
356
|
+
return cssVar.lhCompact(step);
|
|
357
|
+
}
|
|
196
358
|
var Typography = forwardRef(
|
|
197
359
|
({
|
|
198
360
|
children,
|
|
@@ -214,6 +376,9 @@ var Typography = forwardRef(
|
|
|
214
376
|
const colorValue = getColor(color, theme);
|
|
215
377
|
const contextFonts = productContext ? getFonts(productContext) : theme.fonts;
|
|
216
378
|
const fontFamily = isHeadingVariant(variant) ? contextFonts?.heading : contextFonts?.body;
|
|
379
|
+
const useResponsiveCSS = isWeb && variantStyles.scaleStep;
|
|
380
|
+
const responsiveFontSize = useResponsiveCSS ? cssVar.fontSize(variantStyles.scaleStep) : void 0;
|
|
381
|
+
const responsiveLineHeight = useResponsiveCSS ? getResponsiveLineHeight(variantStyles) : void 0;
|
|
217
382
|
return /* @__PURE__ */ jsx2(
|
|
218
383
|
Text,
|
|
219
384
|
{
|
|
@@ -221,7 +386,7 @@ var Typography = forwardRef(
|
|
|
221
386
|
ref,
|
|
222
387
|
as,
|
|
223
388
|
color: colorValue,
|
|
224
|
-
fontSize: variantStyles.fontSize,
|
|
389
|
+
fontSize: useResponsiveCSS ? void 0 : variantStyles.fontSize,
|
|
225
390
|
fontWeight: variantStyles.fontWeight,
|
|
226
391
|
fontFamily,
|
|
227
392
|
numberOfLines: noWrap ? 1 : void 0,
|
|
@@ -229,7 +394,7 @@ var Typography = forwardRef(
|
|
|
229
394
|
marginTop,
|
|
230
395
|
marginBottom,
|
|
231
396
|
textAlign: align === "inherit" ? void 0 : align,
|
|
232
|
-
lineHeight: variantStyles.lineHeight,
|
|
397
|
+
...useResponsiveCSS ? { fontSize: responsiveFontSize, lineHeight: responsiveLineHeight } : { lineHeight: variantStyles.lineHeight },
|
|
233
398
|
...noWrap && {
|
|
234
399
|
overflow: "hidden",
|
|
235
400
|
textOverflow: "ellipsis",
|
package/native/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Typography.tsx","../../../primitives-native/src/Text.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport {\n useResolvedTheme,\n getTypographyTokens,\n getFonts,\n isNative,\n} from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") {\n return isNative ? theme?.colors?.content?.primary : undefined;\n }\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"h5\" ||\n variant === \"display\";\n\nconst getVariantStyles = (variant: VariantType, typographyTokens?: any) => {\n // If typography tokens are provided from theme, use them\n if (typographyTokens) {\n const headingMap: Record<string, keyof typeof typographyTokens.heading> = {\n h1: \"h1\",\n h2: \"h2\",\n h3: \"h3\",\n h4: \"h4\",\n h5: \"h5\",\n };\n\n if (headingMap[variant]) {\n const token = typographyTokens.heading[headingMap[variant]];\n if (token) {\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n }\n\n if (variant === \"display\" && typographyTokens.basic?.display) {\n const token = typographyTokens.basic.display;\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n\n // Body variants\n const bodyMap: Record<string, string> = {\n bodyLg: \"body-lg\",\n bodyLgAccent: \"body-lg\",\n bodyLgParagraph: \"body-lg\",\n bodyMd: \"body-md\",\n bodyMdAccent: \"body-md\",\n bodyMdParagraph: \"body-md\",\n bodySm: \"body-sm\",\n bodySmAccent: \"body-sm\",\n bodySmParagraph: \"body-sm\",\n bodyXs: \"body-xs\",\n bodyXsAccent: \"body-xs\",\n bodyXsParagraph: \"body-xs\",\n };\n\n const bodyKey = bodyMap[variant];\n if (bodyKey && typographyTokens.basic?.[bodyKey]) {\n const token = typographyTokens.basic[bodyKey];\n let fontWeight = token.fontWeight;\n let lineHeight = token.lineHeight;\n\n if (variant.includes(\"Accent\") && token.accent) {\n fontWeight = token.accent.fontWeight;\n }\n\n if (variant.includes(\"Paragraph\") && token.paragraph) {\n lineHeight = token.paragraph.lineHeight;\n }\n\n return {\n fontSize: token.fontSize,\n fontWeight: String(fontWeight),\n lineHeight: lineHeight,\n };\n }\n }\n\n // Fallback to default styles (B2B mode for backwards compatibility)\n switch (variant) {\n case \"h1\":\n return { fontSize: 56, fontWeight: \"400\", lineHeight: \"68px\" };\n case \"h2\":\n return { fontSize: 48, fontWeight: \"400\", lineHeight: \"58px\" };\n case \"h3\":\n return { fontSize: 32, fontWeight: \"400\", lineHeight: \"38px\" };\n case \"h4\":\n return { fontSize: 24, fontWeight: \"400\", lineHeight: \"28px\" };\n case \"h5\":\n return { fontSize: 20, fontWeight: \"600\", lineHeight: \"24px\" };\n case \"display\":\n return { fontSize: 64, fontWeight: \"400\", lineHeight: \"78px\" };\n case \"bodyLg\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"24px\" };\n case \"bodyLgAccent\":\n return { fontSize: 18, fontWeight: \"500\", lineHeight: \"24px\" };\n case \"bodyLgParagraph\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"26px\" };\n case \"bodyMd\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyMdAccent\":\n return { fontSize: 16, fontWeight: \"500\", lineHeight: \"20px\" };\n case \"bodyMdParagraph\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"22px\" };\n case \"bodySm\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"18px\" };\n case \"bodySmAccent\":\n return { fontSize: 14, fontWeight: \"500\", lineHeight: \"18px\" };\n case \"bodySmParagraph\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyXs\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"16px\" };\n case \"bodyXsAccent\":\n return { fontSize: 12, fontWeight: \"500\", lineHeight: \"16px\" };\n case \"bodyXsParagraph\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"18px\" };\n default:\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n }\n};\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n productContext,\n themeMode,\n themeProductContext,\n ...rest\n },\n ref\n ) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n // If productContext is provided, use tokens for that specific context\n // Otherwise, use the tokens from the theme (context)\n const typographyTokens = productContext\n ? getTypographyTokens(productContext)\n : (theme as any).typographyTokens;\n const variantStyles = getVariantStyles(variant, typographyTokens);\n const colorValue = getColor(color, theme);\n const contextFonts = productContext\n ? getFonts(productContext)\n : (theme.fonts as Record<string, string>);\n const fontFamily = isHeadingVariant(variant)\n ? contextFonts?.heading\n : contextFonts?.body;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n numberOfLines={noWrap ? 1 : undefined}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n lineHeight: variantStyles.lineHeight,\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport {\n Text as RNText,\n TextStyle,\n AccessibilityRole,\n StyleSheet,\n} from \"react-native\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst roleMap: Record<string, AccessibilityRole> = {\n alert: \"alert\",\n heading: \"header\",\n button: \"button\",\n link: \"link\",\n text: \"text\",\n};\n\nconst parseNumericValue = (\n value: string | number | undefined\n): number | undefined => {\n if (value === undefined) return undefined;\n if (typeof value === \"number\") return value;\n const parsed = parseFloat(value);\n return isNaN(parsed) ? undefined : parsed;\n};\n\nexport const Text: React.FC<TextProps> = ({\n children,\n color,\n fontSize,\n fontWeight,\n fontFamily,\n textAlign,\n lineHeight,\n numberOfLines,\n id,\n role,\n style: styleProp,\n ...props\n}) => {\n let resolvedFontFamily = fontFamily\n ? fontFamily.split(\",\")[0].replace(/['\"]/g, \"\").trim()\n : undefined;\n\n if (\n resolvedFontFamily === \"Pilat Wide\" ||\n resolvedFontFamily === \"Pilat Wide Bold\" ||\n resolvedFontFamily === \"Aktiv Grotesk\"\n ) {\n resolvedFontFamily = undefined;\n }\n\n const incomingStyle = StyleSheet.flatten(styleProp) as TextStyle | undefined;\n\n const baseStyle: TextStyle = {\n color: color ?? incomingStyle?.color,\n fontSize: typeof fontSize === \"number\" ? fontSize : undefined,\n fontWeight: fontWeight as TextStyle[\"fontWeight\"],\n fontFamily: resolvedFontFamily,\n textDecorationLine: props.textDecoration as TextStyle[\"textDecorationLine\"],\n textAlign: textAlign ?? incomingStyle?.textAlign,\n lineHeight: parseNumericValue(lineHeight ?? incomingStyle?.lineHeight),\n marginTop: parseNumericValue(\n incomingStyle?.marginTop as number | string | undefined\n ),\n marginBottom: parseNumericValue(\n incomingStyle?.marginBottom as number | string | undefined\n ),\n };\n\n const accessibilityRole = role ? roleMap[role] : undefined;\n\n return (\n <RNText\n style={baseStyle}\n numberOfLines={numberOfLines}\n testID={id}\n accessibilityRole={accessibilityRole}\n >\n {children}\n </RNText>\n );\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACC3B;AAAA,EACE,QAAQ;AAAA,EAGR;AAAA,OACK;AAmEH;AAhEJ,IAAM,UAA6C;AAAA,EACjD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AACR;AAEA,IAAM,oBAAoB,CACxB,UACuB;AACvB,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,SAAS,WAAW,KAAK;AAC/B,SAAO,MAAM,MAAM,IAAI,SAAY;AACrC;AAEO,IAAM,OAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,MAAM;AACJ,MAAI,qBAAqB,aACrB,WAAW,MAAM,GAAG,EAAE,CAAC,EAAE,QAAQ,SAAS,EAAE,EAAE,KAAK,IACnD;AAEJ,MACE,uBAAuB,gBACvB,uBAAuB,qBACvB,uBAAuB,i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Y;AAAA,UACd;AAAA,UACA,GAAG,KAAK;AAAA,QACV;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":["jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Typography.tsx","../../../primitives-native/src/Text.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport {\n useResolvedTheme,\n getTypographyTokens,\n getFonts,\n isWeb,\n isNative,\n cssVar,\n} from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") {\n return isNative ? theme?.colors?.content?.primary : undefined;\n }\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"h5\" ||\n variant === \"display\";\n\nconst bodyMap: Record<string, string> = {\n bodyLg: \"body-lg\",\n bodyLgAccent: \"body-lg\",\n bodyLgParagraph: \"body-lg\",\n bodyMd: \"body-md\",\n bodyMdAccent: \"body-md\",\n bodyMdParagraph: \"body-md\",\n bodySm: \"body-sm\",\n bodySmAccent: \"body-sm\",\n bodySmParagraph: \"body-sm\",\n bodyXs: \"body-xs\",\n bodyXsAccent: \"body-xs\",\n bodyXsParagraph: \"body-xs\",\n bodyXxs: \"body-xxs\",\n bodyXxsAccent: \"body-xxs\",\n bodyXxsParagraph: \"body-xxs\",\n};\n\nconst headingMap: Record<string, string> = {\n h1: \"h1\",\n h2: \"h2\",\n h3: \"h3\",\n h4: \"h4\",\n h5: \"h5\",\n};\n\nconst getVariantStyles = (variant: VariantType, typographyTokens?: any) => {\n if (typographyTokens) {\n if (headingMap[variant]) {\n const token = typographyTokens.heading[headingMap[variant]];\n if (token) {\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n scaleStep: token.scaleStep,\n lineHeightCategory: token.lineHeightCategory,\n };\n }\n }\n\n if (variant === \"display\" && typographyTokens.basic?.display) {\n const token = typographyTokens.basic.display;\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n scaleStep: token.scaleStep,\n lineHeightCategory: token.lineHeightCategory,\n };\n }\n\n const bodyKey = bodyMap[variant];\n if (bodyKey && typographyTokens.basic?.[bodyKey]) {\n const token = typographyTokens.basic[bodyKey];\n let fontWeight = token.fontWeight;\n let lineHeight = token.lineHeight;\n let lineHeightCategory = token.lineHeightCategory;\n let lineHeightScaleStep: string | undefined;\n\n if (variant.includes(\"Accent\") && token.accent) {\n fontWeight = token.accent.fontWeight;\n }\n\n if (variant.includes(\"Paragraph\") && token.paragraph) {\n lineHeight = token.paragraph.lineHeight;\n lineHeightCategory = \"text\";\n lineHeightScaleStep = token.paragraph.lineHeightScaleStep;\n }\n\n return {\n fontSize: token.fontSize,\n fontWeight: String(fontWeight),\n lineHeight,\n scaleStep: token.scaleStep,\n lineHeightCategory,\n lineHeightScaleStep,\n };\n }\n }\n\n switch (variant) {\n case \"h1\":\n return {\n fontSize: 56,\n fontWeight: \"400\",\n lineHeight: \"56px\",\n scaleStep: \"650\",\n lineHeightCategory: \"display\" as const,\n };\n case \"h2\":\n return {\n fontSize: 48,\n fontWeight: \"400\",\n lineHeight: \"48px\",\n scaleStep: \"550\",\n lineHeightCategory: \"display\" as const,\n };\n case \"h3\":\n return {\n fontSize: 32,\n fontWeight: \"400\",\n lineHeight: \"32px\",\n scaleStep: \"350\",\n lineHeightCategory: \"display\" as const,\n };\n case \"h4\":\n return {\n fontSize: 24,\n fontWeight: \"400\",\n lineHeight: \"24px\",\n scaleStep: \"250\",\n lineHeightCategory: \"display\" as const,\n };\n case \"h5\":\n return {\n fontSize: 20,\n fontWeight: \"600\",\n lineHeight: \"20px\",\n scaleStep: \"200\",\n lineHeightCategory: \"display\" as const,\n };\n case \"display\":\n return {\n fontSize: 64,\n fontWeight: \"400\",\n lineHeight: \"64px\",\n scaleStep: \"750\",\n lineHeightCategory: \"display\" as const,\n };\n case \"bodyLg\":\n return {\n fontSize: 18,\n fontWeight: \"400\",\n lineHeight: \"24px\",\n scaleStep: \"175\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodyLgAccent\":\n return {\n fontSize: 18,\n fontWeight: \"500\",\n lineHeight: \"24px\",\n scaleStep: \"175\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodyLgParagraph\":\n return {\n fontSize: 18,\n fontWeight: \"400\",\n lineHeight: \"26px\",\n scaleStep: \"175\",\n lineHeightCategory: \"text\" as const,\n };\n case \"bodyMd\":\n return {\n fontSize: 16,\n fontWeight: \"400\",\n lineHeight: \"20px\",\n scaleStep: \"150\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodyMdAccent\":\n return {\n fontSize: 16,\n fontWeight: \"500\",\n lineHeight: \"20px\",\n scaleStep: \"150\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodyMdParagraph\":\n return {\n fontSize: 16,\n fontWeight: \"400\",\n lineHeight: \"22px\",\n scaleStep: \"150\",\n lineHeightCategory: \"text\" as const,\n };\n case \"bodySm\":\n return {\n fontSize: 14,\n fontWeight: \"400\",\n lineHeight: \"18px\",\n scaleStep: \"125\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodySmAccent\":\n return {\n fontSize: 14,\n fontWeight: \"500\",\n lineHeight: \"18px\",\n scaleStep: \"125\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodySmParagraph\":\n return {\n fontSize: 14,\n fontWeight: \"400\",\n lineHeight: \"20px\",\n scaleStep: \"125\",\n lineHeightCategory: \"text\" as const,\n };\n case \"bodyXs\":\n return {\n fontSize: 12,\n fontWeight: \"400\",\n lineHeight: \"16px\",\n scaleStep: \"100\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodyXsAccent\":\n return {\n fontSize: 12,\n fontWeight: \"500\",\n lineHeight: \"16px\",\n scaleStep: \"100\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodyXsParagraph\":\n return {\n fontSize: 12,\n fontWeight: \"400\",\n lineHeight: \"18px\",\n scaleStep: \"100\",\n lineHeightCategory: \"text\" as const,\n };\n case \"bodyXxs\":\n return {\n fontSize: 10,\n fontWeight: \"400\",\n lineHeight: \"14px\",\n scaleStep: \"75\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodyXxsAccent\":\n return {\n fontSize: 10,\n fontWeight: \"500\",\n lineHeight: \"14px\",\n scaleStep: \"75\",\n lineHeightCategory: \"compact\" as const,\n };\n case \"bodyXxsParagraph\":\n return {\n fontSize: 10,\n fontWeight: \"400\",\n lineHeight: \"14px\",\n scaleStep: \"75\",\n lineHeightCategory: \"text\" as const,\n };\n default:\n return {\n fontSize: 16,\n fontWeight: \"400\",\n lineHeight: \"20px\",\n scaleStep: \"150\",\n lineHeightCategory: \"compact\" as const,\n };\n }\n};\n\nfunction getResponsiveLineHeight(\n styles: ReturnType<typeof getVariantStyles>\n): string | undefined {\n const step = styles.lineHeightScaleStep || styles.scaleStep;\n if (!step) return undefined;\n\n const cat = styles.lineHeightCategory;\n if (cat === \"display\") return cssVar.lhDisplay(step);\n if (cat === \"text\") return cssVar.lhText(step);\n return cssVar.lhCompact(step);\n}\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n productContext,\n themeMode,\n themeProductContext,\n ...rest\n },\n ref\n ) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n const typographyTokens = productContext\n ? getTypographyTokens(productContext)\n : (theme as any).typographyTokens;\n const variantStyles = getVariantStyles(variant, typographyTokens);\n const colorValue = getColor(color, theme);\n const contextFonts = productContext\n ? getFonts(productContext)\n : (theme.fonts as Record<string, string>);\n const fontFamily = isHeadingVariant(variant)\n ? contextFonts?.heading\n : contextFonts?.body;\n\n const useResponsiveCSS = isWeb && variantStyles.scaleStep;\n\n const responsiveFontSize = useResponsiveCSS\n ? cssVar.fontSize(variantStyles.scaleStep!)\n : undefined;\n const responsiveLineHeight = useResponsiveCSS\n ? getResponsiveLineHeight(variantStyles)\n : undefined;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={useResponsiveCSS ? undefined : variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n numberOfLines={noWrap ? 1 : undefined}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n ...(useResponsiveCSS\n ? { fontSize: responsiveFontSize, lineHeight: responsiveLineHeight }\n : { lineHeight: variantStyles.lineHeight }),\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport {\n Text as RNText,\n TextStyle,\n AccessibilityRole,\n StyleSheet,\n} from \"react-native\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst roleMap: Record<string, AccessibilityRole> = {\n alert: \"alert\",\n heading: \"header\",\n button: \"button\",\n link: \"link\",\n text: \"text\",\n};\n\nconst parseNumericValue = (\n value: string | number | undefined\n): number | undefined => {\n if (value === undefined) return undefined;\n if (typeof value === \"number\") return value;\n const parsed = parseFloat(value);\n return isNaN(parsed) ? undefined : parsed;\n};\n\nexport const Text: React.FC<TextProps> = ({\n children,\n color,\n fontSize,\n fontWeight,\n fontFamily,\n textAlign,\n lineHeight,\n numberOfLines,\n id,\n role,\n style: styleProp,\n ...props\n}) => {\n let resolvedFontFamily = fontFamily\n ? fontFamily.split(\",\")[0].replace(/['\"]/g, \"\").trim()\n : undefined;\n\n if (\n resolvedFontFamily === \"Pilat Wide\" ||\n resolvedFontFamily === \"Pilat Wide Bold\" ||\n resolvedFontFamily === \"Aktiv Grotesk\"\n ) {\n resolvedFontFamily = undefined;\n }\n\n const incomingStyle = StyleSheet.flatten(styleProp) as TextStyle | undefined;\n\n const baseStyle: TextStyle = {\n color: color ?? incomingStyle?.color,\n fontSize: typeof fontSize === \"number\" ? fontSize : undefined,\n fontWeight: fontWeight as TextStyle[\"fontWeight\"],\n fontFamily: resolvedFontFamily,\n textDecorationLine: props.textDecoration as TextStyle[\"textDecorationLine\"],\n textAlign: textAlign ?? incomingStyle?.textAlign,\n lineHeight: parseNumericValue(lineHeight ?? incomingStyle?.lineHeight),\n marginTop: parseNumericValue(\n incomingStyle?.marginTop as number | string | undefined\n ),\n marginBottom: parseNumericValue(\n incomingStyle?.marginBottom as number | string | undefined\n ),\n };\n\n const accessibilityRole = role ? roleMap[role] : undefined;\n\n return (\n <RNText\n style={baseStyle}\n numberOfLines={numberOfLines}\n testID={id}\n accessibilityRole={accessibilityRole}\n >\n {children}\n </RNText>\n );\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACC3B;AAAA,EACE,QAAQ;AAAA,EAGR;AAAA,OACK;AAmEH;AAhEJ,IAAM,UAA6C;AAAA,EACjD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AACR;AAEA,IAAM,oBAAoB,CACxB,UACuB;AACvB,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,S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AC7C,GAAI,mBACA,EAAE,UAAU,oBAAoB,YAAY,qBAAqB,IACjE,EAAE,YAAY,cAAc,WAAW;AAAA,UAC3C,GAAI,UAAU;AAAA,YACZ,UAAU;AAAA,YACV,cAAc;AAAA,YACd,YAAY;AAAA,UACd;AAAA,UACA,GAAG,KAAK;AAAA,QACV;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":["jsx"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-typography",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.136.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-core": "0.
|
|
17
|
-
"@xsolla/xui-primitives-core": "0.
|
|
16
|
+
"@xsolla/xui-core": "0.136.0",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.136.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=16.8.0",
|
package/web/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { ReactNode, ElementType } from 'react';
|
|
|
3
3
|
import { ThemeOverrideProps } from '@xsolla/xui-core';
|
|
4
4
|
|
|
5
5
|
type AlignType = "center" | "inherit" | "justify" | "left" | "right";
|
|
6
|
-
type VariantType = "h1" | "h2" | "h3" | "h4" | "h5" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
6
|
+
type VariantType = "h1" | "h2" | "h3" | "h4" | "h5" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph" | "bodyXxs" | "bodyXxsAccent" | "bodyXxsParagraph";
|
|
7
7
|
type ThemeColorType = "primary" | "secondary" | "tertiary" | "brand" | "brandSecondary" | "success" | "warning" | "alert" | "neutral";
|
|
8
8
|
type ColorType = ThemeColorType | "inherit";
|
|
9
9
|
type ProductContext = "b2c" | "b2b" | "paystation" | "presentation";
|
package/web/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ReactNode, ElementType } from 'react';
|
|
|
3
3
|
import { ThemeOverrideProps } from '@xsolla/xui-core';
|
|
4
4
|
|
|
5
5
|
type AlignType = "center" | "inherit" | "justify" | "left" | "right";
|
|
6
|
-
type VariantType = "h1" | "h2" | "h3" | "h4" | "h5" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
6
|
+
type VariantType = "h1" | "h2" | "h3" | "h4" | "h5" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph" | "bodyXxs" | "bodyXxsAccent" | "bodyXxsParagraph";
|
|
7
7
|
type ThemeColorType = "primary" | "secondary" | "tertiary" | "brand" | "brandSecondary" | "success" | "warning" | "alert" | "neutral";
|
|
8
8
|
type ColorType = ThemeColorType | "inherit";
|
|
9
9
|
type ProductContext = "b2c" | "b2b" | "paystation" | "presentation";
|