@xsolla/xui-switch 0.133.0 → 0.135.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.js +37 -5
- package/native/index.js.map +1 -1
- package/native/index.mjs +41 -6
- package/native/index.mjs.map +1 -1
- package/package.json +3 -3
- package/web/index.js +42 -118
- package/web/index.js.map +1 -1
- package/web/index.mjs +46 -119
- package/web/index.mjs.map +1 -1
package/native/index.js
CHANGED
|
@@ -284,10 +284,20 @@ var Switch = ({
|
|
|
284
284
|
const isError = state === "error";
|
|
285
285
|
const isHover = state === "hover";
|
|
286
286
|
const showErrorLabel = isError && errorLabel;
|
|
287
|
+
const rawId = (0, import_xui_core.useId)();
|
|
288
|
+
const safeId = rawId.replace(/:/g, "");
|
|
289
|
+
const descriptionId = `switch-desc-${safeId}`;
|
|
290
|
+
const errorId = `switch-error-${safeId}`;
|
|
291
|
+
const ariaDescribedByParts = [];
|
|
292
|
+
if (description) ariaDescribedByParts.push(descriptionId);
|
|
293
|
+
if (showErrorLabel) ariaDescribedByParts.push(errorId);
|
|
294
|
+
const ariaDescribedBy = ariaDescribedByParts.length > 0 ? ariaDescribedByParts.join(" ") : void 0;
|
|
287
295
|
const sizing = theme.sizing.switch(size);
|
|
288
296
|
const switchColors = theme.colors.control.switch;
|
|
289
297
|
const checkColors = theme.colors.control.check;
|
|
298
|
+
const knobColors = theme.colors.control.knob;
|
|
290
299
|
const textColors = theme.colors.control.text;
|
|
300
|
+
const borderColors = theme.colors.border;
|
|
291
301
|
const handlePress = () => {
|
|
292
302
|
if (!isDisable && onValueChange) {
|
|
293
303
|
onValueChange(!checked);
|
|
@@ -300,18 +310,33 @@ var Switch = ({
|
|
|
300
310
|
}
|
|
301
311
|
};
|
|
302
312
|
const getBgColor = () => {
|
|
303
|
-
if (isDisable)
|
|
313
|
+
if (isDisable) {
|
|
314
|
+
return checked ? checkColors.bgDisable : switchColors.bgDisable;
|
|
315
|
+
}
|
|
304
316
|
if (checked && isHover) return checkColors.bgHover;
|
|
305
317
|
if (checked) return checkColors.bg;
|
|
306
318
|
if (isHover) return switchColors.bgHover;
|
|
307
319
|
return switchColors.bg;
|
|
308
320
|
};
|
|
321
|
+
const getBorderColor = () => {
|
|
322
|
+
if (isError) return borderColors.alert;
|
|
323
|
+
if (isDisable) {
|
|
324
|
+
return checked ? checkColors.borderDisable : switchColors.borderDisable;
|
|
325
|
+
}
|
|
326
|
+
if (checked && isHover) return checkColors.borderHover;
|
|
327
|
+
if (checked) return checkColors.border;
|
|
328
|
+
if (isHover) return switchColors.borderHover;
|
|
329
|
+
return switchColors.border;
|
|
330
|
+
};
|
|
309
331
|
const getTextColor = () => {
|
|
310
332
|
if (isDisable) return textColors.disable;
|
|
311
333
|
return textColors.primary;
|
|
312
334
|
};
|
|
313
335
|
const getKnobColor = () => {
|
|
314
|
-
return
|
|
336
|
+
if (isDisable) return knobColors.bgInactive;
|
|
337
|
+
if (checked && isHover) return knobColors.bgHover;
|
|
338
|
+
if (checked) return knobColors.bg;
|
|
339
|
+
return knobColors.bgInactive;
|
|
315
340
|
};
|
|
316
341
|
const labelBlock = (label || description || showErrorLabel) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box, { flexDirection: "column", gap: sizing.textGap, children: [
|
|
317
342
|
label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -327,6 +352,7 @@ var Switch = ({
|
|
|
327
352
|
description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
328
353
|
Text,
|
|
329
354
|
{
|
|
355
|
+
id: descriptionId,
|
|
330
356
|
color: theme.colors.content.tertiary,
|
|
331
357
|
fontSize: sizing.descriptionFontSize,
|
|
332
358
|
lineHeight: sizing.descriptionLineHeight,
|
|
@@ -336,6 +362,7 @@ var Switch = ({
|
|
|
336
362
|
showErrorLabel && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
337
363
|
Text,
|
|
338
364
|
{
|
|
365
|
+
id: errorId,
|
|
339
366
|
color: theme.colors.content.alert.primary,
|
|
340
367
|
fontSize: sizing.descriptionFontSize,
|
|
341
368
|
lineHeight: sizing.descriptionLineHeight,
|
|
@@ -349,13 +376,16 @@ var Switch = ({
|
|
|
349
376
|
width: sizing.width,
|
|
350
377
|
height: sizing.height,
|
|
351
378
|
backgroundColor: getBgColor(),
|
|
379
|
+
borderColor: getBorderColor(),
|
|
380
|
+
borderWidth: 1,
|
|
352
381
|
borderRadius: sizing.frameBorderRadius,
|
|
353
|
-
padding:
|
|
382
|
+
padding: 1,
|
|
354
383
|
flexDirection: "row",
|
|
355
384
|
alignItems: "center",
|
|
356
385
|
justifyContent: checked ? "flex-end" : "flex-start",
|
|
357
386
|
hoverStyle: !isDisable && !isHover ? {
|
|
358
|
-
backgroundColor: checked ? checkColors.bgHover : switchColors.bgHover
|
|
387
|
+
backgroundColor: checked ? checkColors.bgHover : switchColors.bgHover,
|
|
388
|
+
borderColor: checked ? checkColors.borderHover : switchColors.borderHover
|
|
359
389
|
} : void 0,
|
|
360
390
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
361
391
|
Box,
|
|
@@ -374,9 +404,11 @@ var Switch = ({
|
|
|
374
404
|
role: "switch",
|
|
375
405
|
"aria-checked": checked,
|
|
376
406
|
"aria-disabled": isDisable || void 0,
|
|
407
|
+
"aria-invalid": isError || void 0,
|
|
408
|
+
"aria-describedby": ariaDescribedBy,
|
|
377
409
|
"aria-label": ariaLabelledBy ? void 0 : ariaLabel || (label ? void 0 : "Switch"),
|
|
378
410
|
"aria-labelledby": ariaLabelledBy,
|
|
379
|
-
tabIndex:
|
|
411
|
+
tabIndex: 0,
|
|
380
412
|
flexDirection: "row",
|
|
381
413
|
alignItems: description || showErrorLabel ? "flex-start" : "center",
|
|
382
414
|
gap: sizing.labelGap,
|
package/native/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.tsx","../../../primitives-native/src/Box.tsx","../../../primitives-native/src/Text.tsx","../../src/Switch.tsx"],"sourcesContent":["export * from \"./Switch\";\n","import React from \"react\";\nimport {\n View,\n Pressable,\n Image,\n ViewStyle,\n ImageStyle,\n DimensionValue,\n AnimatableNumericValue,\n} from \"react-native\";\nimport { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nexport const Box: React.FC<BoxProps> = ({\n children,\n onPress,\n onLayout,\n onMoveShouldSetResponder,\n onResponderGrant,\n onResponderMove,\n onResponderRelease,\n onResponderTerminate,\n backgroundColor,\n borderColor,\n borderWidth,\n borderBottomWidth,\n borderBottomColor,\n borderTopWidth,\n borderTopColor,\n borderLeftWidth,\n borderLeftColor,\n borderRightWidth,\n borderRightColor,\n borderRadius,\n borderStyle,\n height,\n padding,\n paddingHorizontal,\n paddingVertical,\n margin,\n marginTop,\n marginBottom,\n marginLeft,\n marginRight,\n flexDirection,\n alignItems,\n justifyContent,\n position,\n top,\n bottom,\n left,\n right,\n width,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flex,\n overflow,\n zIndex,\n hoverStyle,\n pressStyle,\n style,\n \"data-testid\": dataTestId,\n testID,\n as,\n src,\n alt,\n ...rest\n}) => {\n const getContainerStyle = (pressed?: boolean): ViewStyle => ({\n backgroundColor:\n pressed && pressStyle?.backgroundColor\n ? pressStyle.backgroundColor\n : backgroundColor,\n borderColor,\n borderWidth,\n borderBottomWidth,\n borderBottomColor,\n borderTopWidth,\n borderTopColor,\n borderLeftWidth,\n borderLeftColor,\n borderRightWidth,\n borderRightColor,\n borderRadius: borderRadius as AnimatableNumericValue,\n borderStyle: borderStyle as ViewStyle[\"borderStyle\"],\n overflow,\n zIndex,\n height: height as DimensionValue,\n width: width as DimensionValue,\n minWidth: minWidth as DimensionValue,\n minHeight: minHeight as DimensionValue,\n maxWidth: maxWidth as DimensionValue,\n maxHeight: maxHeight as DimensionValue,\n padding: padding as DimensionValue,\n paddingHorizontal: paddingHorizontal as DimensionValue,\n paddingVertical: paddingVertical as DimensionValue,\n margin: margin as DimensionValue,\n marginTop: marginTop as DimensionValue,\n marginBottom: marginBottom as DimensionValue,\n marginLeft: marginLeft as DimensionValue,\n marginRight: marginRight as DimensionValue,\n flexDirection,\n alignItems,\n justifyContent,\n position: position as ViewStyle[\"position\"],\n top: top as DimensionValue,\n bottom: bottom as DimensionValue,\n left: left as DimensionValue,\n right: right as DimensionValue,\n flex,\n ...(style as ViewStyle),\n });\n\n const finalTestID = dataTestId || testID;\n\n // Destructure and drop web-only props from rest before passing to RN components\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n role,\n tabIndex,\n onKeyDown,\n onKeyUp,\n \"aria-label\": _ariaLabel,\n \"aria-labelledby\": _ariaLabelledBy,\n \"aria-current\": _ariaCurrent,\n \"aria-disabled\": _ariaDisabled,\n \"aria-live\": _ariaLive,\n className,\n \"data-testid\": _dataTestId,\n ...nativeRest\n } = rest as Record<string, unknown>;\n\n // Handle as=\"img\" for React Native\n if (as === \"img\" && src) {\n const imageStyle: ImageStyle = {\n width: width as DimensionValue,\n height: height as DimensionValue,\n borderRadius: borderRadius as number,\n position: position as ImageStyle[\"position\"],\n top: top as DimensionValue,\n bottom: bottom as DimensionValue,\n left: left as DimensionValue,\n right: right as DimensionValue,\n ...(style as ImageStyle),\n };\n\n return (\n <Image\n source={{ uri: src }}\n style={imageStyle}\n testID={finalTestID}\n resizeMode=\"cover\"\n {...nativeRest}\n />\n );\n }\n\n if (onPress) {\n return (\n <Pressable\n onPress={onPress}\n onLayout={onLayout}\n onMoveShouldSetResponder={onMoveShouldSetResponder}\n onResponderGrant={onResponderGrant}\n onResponderMove={onResponderMove}\n onResponderRelease={onResponderRelease}\n onResponderTerminate={onResponderTerminate}\n style={({ pressed }) => getContainerStyle(pressed)}\n testID={finalTestID}\n {...nativeRest}\n >\n {children}\n </Pressable>\n );\n }\n\n return (\n <View\n style={getContainerStyle()}\n testID={finalTestID}\n onLayout={onLayout}\n onMoveShouldSetResponder={onMoveShouldSetResponder}\n onResponderGrant={onResponderGrant}\n onResponderMove={onResponderMove}\n onResponderRelease={onResponderRelease}\n onResponderTerminate={onResponderTerminate}\n {...nativeRest}\n >\n {children}\n </View>\n );\n};\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","import React from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport { useResolvedTheme, type ThemeOverrideProps } from \"@xsolla/xui-core\";\n\nexport interface SwitchProps extends ThemeOverrideProps {\n /** Size of the switch */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n /** Whether the switch is checked */\n checked?: boolean;\n /** Visual state of the switch */\n state?: \"default\" | \"hover\" | \"disable\" | \"error\";\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch */\n labelPosition?: \"left\" | \"right\";\n /** Description text to display below the label */\n description?: string;\n /** Error label text to display when state is 'error' */\n errorLabel?: string;\n /** Callback when the switch value changes */\n onValueChange?: (value: boolean) => void;\n /** Accessible label for screen readers */\n ariaLabel?: string;\n /** ID of the element that labels this switch */\n ariaLabelledBy?: string;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({\n size = \"md\",\n checked = false,\n state = \"default\",\n disabled = false,\n label,\n labelPosition = \"right\",\n description,\n errorLabel,\n onValueChange,\n ariaLabel,\n ariaLabelledBy,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n\n const isDisable = state === \"disable\" || disabled;\n const isError = state === \"error\";\n const isHover = state === \"hover\";\n const showErrorLabel = isError && errorLabel;\n\n // Resolve Sizing\n const sizing = theme.sizing.switch(size);\n\n // Resolve Colors from Theme\n const switchColors = theme.colors.control.switch;\n const checkColors = theme.colors.control.check;\n const textColors = theme.colors.control.text;\n\n const handlePress = () => {\n if (!isDisable && onValueChange) {\n onValueChange(!checked);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!isDisable && (event.key === \" \" || event.key === \"Enter\")) {\n event.preventDefault();\n handlePress();\n }\n };\n\n const getBgColor = () => {\n if (isDisable) return switchColors.bg;\n if (checked && isHover) return checkColors.bgHover;\n if (checked) return checkColors.bg;\n if (isHover) return switchColors.bgHover;\n return switchColors.bg;\n };\n\n const getTextColor = () => {\n if (isDisable) return textColors.disable;\n return textColors.primary;\n };\n\n const getKnobColor = () => {\n return theme.colors.content.static.light;\n };\n\n const labelBlock = (label || description || showErrorLabel) && (\n <Box flexDirection=\"column\" gap={sizing.textGap}>\n {label && (\n <Text\n color={getTextColor()}\n fontSize={sizing.fontSize}\n lineHeight={sizing.lineHeight}\n fontWeight=\"400\"\n >\n {label}\n </Text>\n )}\n {description && (\n <Text\n color={theme.colors.content.tertiary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {description}\n </Text>\n )}\n {showErrorLabel && (\n <Text\n color={theme.colors.content.alert.primary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {errorLabel}\n </Text>\n )}\n </Box>\n );\n\n const toggle = (\n <Box\n width={sizing.width}\n height={sizing.height}\n backgroundColor={getBgColor()}\n borderRadius={sizing.frameBorderRadius}\n padding={2}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent={checked ? \"flex-end\" : \"flex-start\"}\n hoverStyle={\n !isDisable && !isHover\n ? {\n backgroundColor: checked\n ? checkColors.bgHover\n : switchColors.bgHover,\n }\n : undefined\n }\n >\n <Box\n width={sizing.knobSize}\n height={sizing.knobSize}\n backgroundColor={getKnobColor()}\n borderRadius={sizing.knobBorderRadius}\n />\n </Box>\n );\n\n return (\n <Box\n role=\"switch\"\n aria-checked={checked}\n aria-disabled={isDisable || undefined}\n aria-label={\n ariaLabelledBy ? undefined : ariaLabel || (label ? undefined : \"Switch\")\n }\n aria-labelledby={ariaLabelledBy}\n tabIndex={isDisable ? -1 : 0}\n flexDirection=\"row\"\n alignItems={description || showErrorLabel ? \"flex-start\" : \"center\"}\n gap={sizing.labelGap}\n onPress={handlePress}\n onKeyDown={handleKeyDown}\n cursor={!isDisable ? \"pointer\" : \"default\"}\n >\n {labelPosition === \"left\" && labelBlock}\n {toggle}\n {labelPosition === \"right\" && labelBlock}\n </Box>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,0BAQO;AA2ID;AAxIC,IAAM,MAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,oBAAoB,CAAC,aAAkC;AAAA,IAC3D,iBACE,WAAW,YAAY,kBACnB,WAAW,kBACX;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;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ACX,QAAQ,CAAC,YAAY,YAAY;AAAA,MAEhC;AAAA,0BAAkB,UAAU;AAAA,QAC5B;AAAA,QACA,kBAAkB,WAAW;AAAA;AAAA;AAAA,EAChC;AAEJ;","names":["import_react_native","import_jsx_runtime","RNText","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.tsx","../../../primitives-native/src/Box.tsx","../../../primitives-native/src/Text.tsx","../../src/Switch.tsx"],"sourcesContent":["export * from \"./Switch\";\n","import React from \"react\";\nimport {\n View,\n Pressable,\n Image,\n ViewStyle,\n ImageStyle,\n DimensionValue,\n AnimatableNumericValue,\n} from \"react-native\";\nimport { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nexport const Box: React.FC<BoxProps> = ({\n children,\n onPress,\n onLayout,\n onMoveShouldSetResponder,\n onResponderGrant,\n onResponderMove,\n onResponderRelease,\n onResponderTerminate,\n backgroundColor,\n borderColor,\n borderWidth,\n borderBottomWidth,\n borderBottomColor,\n borderTopWidth,\n borderTopColor,\n borderLeftWidth,\n borderLeftColor,\n borderRightWidth,\n borderRightColor,\n borderRadius,\n borderStyle,\n height,\n padding,\n paddingHorizontal,\n paddingVertical,\n margin,\n marginTop,\n marginBottom,\n marginLeft,\n marginRight,\n flexDirection,\n alignItems,\n justifyContent,\n position,\n top,\n bottom,\n left,\n right,\n width,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flex,\n overflow,\n zIndex,\n hoverStyle,\n pressStyle,\n style,\n \"data-testid\": dataTestId,\n testID,\n as,\n src,\n alt,\n ...rest\n}) => {\n const getContainerStyle = (pressed?: boolean): ViewStyle => ({\n backgroundColor:\n pressed && pressStyle?.backgroundColor\n ? pressStyle.backgroundColor\n : backgroundColor,\n borderColor,\n borderWidth,\n borderBottomWidth,\n borderBottomColor,\n borderTopWidth,\n borderTopColor,\n borderLeftWidth,\n borderLeftColor,\n borderRightWidth,\n borderRightColor,\n borderRadius: borderRadius as AnimatableNumericValue,\n borderStyle: borderStyle as ViewStyle[\"borderStyle\"],\n overflow,\n zIndex,\n height: height as DimensionValue,\n width: width as DimensionValue,\n minWidth: minWidth as DimensionValue,\n minHeight: minHeight as DimensionValue,\n maxWidth: maxWidth as DimensionValue,\n maxHeight: maxHeight as DimensionValue,\n padding: padding as DimensionValue,\n paddingHorizontal: paddingHorizontal as DimensionValue,\n paddingVertical: paddingVertical as DimensionValue,\n margin: margin as DimensionValue,\n marginTop: marginTop as DimensionValue,\n marginBottom: marginBottom as DimensionValue,\n marginLeft: marginLeft as DimensionValue,\n marginRight: marginRight as DimensionValue,\n flexDirection,\n alignItems,\n justifyContent,\n position: position as ViewStyle[\"position\"],\n top: top as DimensionValue,\n bottom: bottom as DimensionValue,\n left: left as DimensionValue,\n right: right as DimensionValue,\n flex,\n ...(style as ViewStyle),\n });\n\n const finalTestID = dataTestId || testID;\n\n // Destructure and drop web-only props from rest before passing to RN components\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n role,\n tabIndex,\n onKeyDown,\n onKeyUp,\n \"aria-label\": _ariaLabel,\n \"aria-labelledby\": _ariaLabelledBy,\n \"aria-current\": _ariaCurrent,\n \"aria-disabled\": _ariaDisabled,\n \"aria-live\": _ariaLive,\n className,\n \"data-testid\": _dataTestId,\n ...nativeRest\n } = rest as Record<string, unknown>;\n\n // Handle as=\"img\" for React Native\n if (as === \"img\" && src) {\n const imageStyle: ImageStyle = {\n width: width as DimensionValue,\n height: height as DimensionValue,\n borderRadius: borderRadius as number,\n position: position as ImageStyle[\"position\"],\n top: top as DimensionValue,\n bottom: bottom as DimensionValue,\n left: left as DimensionValue,\n right: right as DimensionValue,\n ...(style as ImageStyle),\n };\n\n return (\n <Image\n source={{ uri: src }}\n style={imageStyle}\n testID={finalTestID}\n resizeMode=\"cover\"\n {...nativeRest}\n />\n );\n }\n\n if (onPress) {\n return (\n <Pressable\n onPress={onPress}\n onLayout={onLayout}\n onMoveShouldSetResponder={onMoveShouldSetResponder}\n onResponderGrant={onResponderGrant}\n onResponderMove={onResponderMove}\n onResponderRelease={onResponderRelease}\n onResponderTerminate={onResponderTerminate}\n style={({ pressed }) => getContainerStyle(pressed)}\n testID={finalTestID}\n {...nativeRest}\n >\n {children}\n </Pressable>\n );\n }\n\n return (\n <View\n style={getContainerStyle()}\n testID={finalTestID}\n onLayout={onLayout}\n onMoveShouldSetResponder={onMoveShouldSetResponder}\n onResponderGrant={onResponderGrant}\n onResponderMove={onResponderMove}\n onResponderRelease={onResponderRelease}\n onResponderTerminate={onResponderTerminate}\n {...nativeRest}\n >\n {children}\n </View>\n );\n};\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","import React from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport {\n useResolvedTheme,\n useId,\n type ThemeOverrideProps,\n} from \"@xsolla/xui-core\";\n\nexport interface SwitchProps extends ThemeOverrideProps {\n /** Size of the switch */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n /** Whether the switch is checked */\n checked?: boolean;\n /** Visual state of the switch */\n state?: \"default\" | \"hover\" | \"disable\" | \"error\";\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch */\n labelPosition?: \"left\" | \"right\";\n /** Description text to display below the label */\n description?: string;\n /** Error label text to display when state is 'error' */\n errorLabel?: string;\n /** Callback when the switch value changes */\n onValueChange?: (value: boolean) => void;\n /** Accessible label for screen readers */\n ariaLabel?: string;\n /** ID of the element that labels this switch */\n ariaLabelledBy?: string;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({\n size = \"md\",\n checked = false,\n state = \"default\",\n disabled = false,\n label,\n labelPosition = \"right\",\n description,\n errorLabel,\n onValueChange,\n ariaLabel,\n ariaLabelledBy,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n\n const isDisable = state === \"disable\" || disabled;\n const isError = state === \"error\";\n const isHover = state === \"hover\";\n const showErrorLabel = isError && errorLabel;\n\n const rawId = useId();\n const safeId = rawId.replace(/:/g, \"\");\n const descriptionId = `switch-desc-${safeId}`;\n const errorId = `switch-error-${safeId}`;\n\n const ariaDescribedByParts: string[] = [];\n if (description) ariaDescribedByParts.push(descriptionId);\n if (showErrorLabel) ariaDescribedByParts.push(errorId);\n const ariaDescribedBy =\n ariaDescribedByParts.length > 0\n ? ariaDescribedByParts.join(\" \")\n : undefined;\n\n const sizing = theme.sizing.switch(size);\n\n const switchColors = theme.colors.control.switch;\n const checkColors = theme.colors.control.check;\n const knobColors = theme.colors.control.knob;\n const textColors = theme.colors.control.text;\n const borderColors = theme.colors.border;\n\n const handlePress = () => {\n if (!isDisable && onValueChange) {\n onValueChange(!checked);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!isDisable && (event.key === \" \" || event.key === \"Enter\")) {\n event.preventDefault();\n handlePress();\n }\n };\n\n const getBgColor = () => {\n if (isDisable) {\n return checked ? checkColors.bgDisable : switchColors.bgDisable;\n }\n if (checked && isHover) return checkColors.bgHover;\n if (checked) return checkColors.bg;\n if (isHover) return switchColors.bgHover;\n return switchColors.bg;\n };\n\n const getBorderColor = () => {\n if (isError) return borderColors.alert;\n if (isDisable) {\n return checked ? checkColors.borderDisable : switchColors.borderDisable;\n }\n if (checked && isHover) return checkColors.borderHover;\n if (checked) return checkColors.border;\n if (isHover) return switchColors.borderHover;\n return switchColors.border;\n };\n\n const getTextColor = () => {\n if (isDisable) return textColors.disable;\n return textColors.primary;\n };\n\n const getKnobColor = () => {\n if (isDisable) return knobColors.bgInactive;\n if (checked && isHover) return knobColors.bgHover;\n if (checked) return knobColors.bg;\n return knobColors.bgInactive;\n };\n\n const labelBlock = (label || description || showErrorLabel) && (\n <Box flexDirection=\"column\" gap={sizing.textGap}>\n {label && (\n <Text\n color={getTextColor()}\n fontSize={sizing.fontSize}\n lineHeight={sizing.lineHeight}\n fontWeight=\"400\"\n >\n {label}\n </Text>\n )}\n {description && (\n <Text\n id={descriptionId}\n color={theme.colors.content.tertiary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {description}\n </Text>\n )}\n {showErrorLabel && (\n <Text\n id={errorId}\n color={theme.colors.content.alert.primary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {errorLabel}\n </Text>\n )}\n </Box>\n );\n\n const toggle = (\n <Box\n width={sizing.width}\n height={sizing.height}\n backgroundColor={getBgColor()}\n borderColor={getBorderColor()}\n borderWidth={1}\n borderRadius={sizing.frameBorderRadius}\n padding={1}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent={checked ? \"flex-end\" : \"flex-start\"}\n hoverStyle={\n !isDisable && !isHover\n ? {\n backgroundColor: checked\n ? checkColors.bgHover\n : switchColors.bgHover,\n borderColor: checked\n ? checkColors.borderHover\n : switchColors.borderHover,\n }\n : undefined\n }\n >\n <Box\n width={sizing.knobSize}\n height={sizing.knobSize}\n backgroundColor={getKnobColor()}\n borderRadius={sizing.knobBorderRadius}\n />\n </Box>\n );\n\n return (\n <Box\n role=\"switch\"\n aria-checked={checked}\n aria-disabled={isDisable || undefined}\n aria-invalid={isError || undefined}\n aria-describedby={ariaDescribedBy}\n aria-label={\n ariaLabelledBy ? undefined : ariaLabel || (label ? undefined : \"Switch\")\n }\n aria-labelledby={ariaLabelledBy}\n tabIndex={0}\n flexDirection=\"row\"\n alignItems={description || showErrorLabel ? \"flex-start\" : \"center\"}\n gap={sizing.labelGap}\n onPress={handlePress}\n onKeyDown={handleKeyDown}\n cursor={!isDisable ? \"pointer\" : \"default\"}\n >\n {labelPosition === \"left\" && labelBlock}\n {toggle}\n {labelPosition === \"right\" && labelBlock}\n </Box>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,0BAQO;AA2ID;AAxIC,IAAM,MAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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,QACjB,aAAa,UACT,YAAY,cACZ,aAAa;AAAA,MACnB,IACA;AAAA,MAGN;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,OAAO;AAAA,UACd,QAAQ,OAAO;AAAA,UACf,iBAAiB,aAAa;AAAA,UAC9B,cAAc,OAAO;AAAA;AAAA,MACvB;AAAA;AAAA,EACF;AAGF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,gBAAc;AAAA,MACd,iBAAe,aAAa;AAAA,MAC5B,gBAAc,WAAW;AAAA,MACzB,oBAAkB;AAAA,MAClB,cACE,iBAAiB,SAAY,cAAc,QAAQ,SAAY;AAAA,MAEjE,mBAAiB;AAAA,MACjB,UAAU;AAAA,MACV,eAAc;AAAA,MACd,YAAY,eAAe,iBAAiB,eAAe;AAAA,MAC3D,KAAK,OAAO;AAAA,MACZ,SAAS;AAAA,MACT,WAAW;AAAA,MACX,QAAQ,CAAC,YAAY,YAAY;AAAA,MAEhC;AAAA,0BAAkB,UAAU;AAAA,QAC5B;AAAA,QACA,kBAAkB,WAAW;AAAA;AAAA;AAAA,EAChC;AAEJ;","names":["import_react_native","import_jsx_runtime","RNText","import_jsx_runtime"]}
|
package/native/index.mjs
CHANGED
|
@@ -243,7 +243,10 @@ var Text = ({
|
|
|
243
243
|
};
|
|
244
244
|
|
|
245
245
|
// src/Switch.tsx
|
|
246
|
-
import {
|
|
246
|
+
import {
|
|
247
|
+
useResolvedTheme,
|
|
248
|
+
useId
|
|
249
|
+
} from "@xsolla/xui-core";
|
|
247
250
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
248
251
|
var Switch = ({
|
|
249
252
|
size = "md",
|
|
@@ -265,10 +268,20 @@ var Switch = ({
|
|
|
265
268
|
const isError = state === "error";
|
|
266
269
|
const isHover = state === "hover";
|
|
267
270
|
const showErrorLabel = isError && errorLabel;
|
|
271
|
+
const rawId = useId();
|
|
272
|
+
const safeId = rawId.replace(/:/g, "");
|
|
273
|
+
const descriptionId = `switch-desc-${safeId}`;
|
|
274
|
+
const errorId = `switch-error-${safeId}`;
|
|
275
|
+
const ariaDescribedByParts = [];
|
|
276
|
+
if (description) ariaDescribedByParts.push(descriptionId);
|
|
277
|
+
if (showErrorLabel) ariaDescribedByParts.push(errorId);
|
|
278
|
+
const ariaDescribedBy = ariaDescribedByParts.length > 0 ? ariaDescribedByParts.join(" ") : void 0;
|
|
268
279
|
const sizing = theme.sizing.switch(size);
|
|
269
280
|
const switchColors = theme.colors.control.switch;
|
|
270
281
|
const checkColors = theme.colors.control.check;
|
|
282
|
+
const knobColors = theme.colors.control.knob;
|
|
271
283
|
const textColors = theme.colors.control.text;
|
|
284
|
+
const borderColors = theme.colors.border;
|
|
272
285
|
const handlePress = () => {
|
|
273
286
|
if (!isDisable && onValueChange) {
|
|
274
287
|
onValueChange(!checked);
|
|
@@ -281,18 +294,33 @@ var Switch = ({
|
|
|
281
294
|
}
|
|
282
295
|
};
|
|
283
296
|
const getBgColor = () => {
|
|
284
|
-
if (isDisable)
|
|
297
|
+
if (isDisable) {
|
|
298
|
+
return checked ? checkColors.bgDisable : switchColors.bgDisable;
|
|
299
|
+
}
|
|
285
300
|
if (checked && isHover) return checkColors.bgHover;
|
|
286
301
|
if (checked) return checkColors.bg;
|
|
287
302
|
if (isHover) return switchColors.bgHover;
|
|
288
303
|
return switchColors.bg;
|
|
289
304
|
};
|
|
305
|
+
const getBorderColor = () => {
|
|
306
|
+
if (isError) return borderColors.alert;
|
|
307
|
+
if (isDisable) {
|
|
308
|
+
return checked ? checkColors.borderDisable : switchColors.borderDisable;
|
|
309
|
+
}
|
|
310
|
+
if (checked && isHover) return checkColors.borderHover;
|
|
311
|
+
if (checked) return checkColors.border;
|
|
312
|
+
if (isHover) return switchColors.borderHover;
|
|
313
|
+
return switchColors.border;
|
|
314
|
+
};
|
|
290
315
|
const getTextColor = () => {
|
|
291
316
|
if (isDisable) return textColors.disable;
|
|
292
317
|
return textColors.primary;
|
|
293
318
|
};
|
|
294
319
|
const getKnobColor = () => {
|
|
295
|
-
return
|
|
320
|
+
if (isDisable) return knobColors.bgInactive;
|
|
321
|
+
if (checked && isHover) return knobColors.bgHover;
|
|
322
|
+
if (checked) return knobColors.bg;
|
|
323
|
+
return knobColors.bgInactive;
|
|
296
324
|
};
|
|
297
325
|
const labelBlock = (label || description || showErrorLabel) && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: sizing.textGap, children: [
|
|
298
326
|
label && /* @__PURE__ */ jsx3(
|
|
@@ -308,6 +336,7 @@ var Switch = ({
|
|
|
308
336
|
description && /* @__PURE__ */ jsx3(
|
|
309
337
|
Text,
|
|
310
338
|
{
|
|
339
|
+
id: descriptionId,
|
|
311
340
|
color: theme.colors.content.tertiary,
|
|
312
341
|
fontSize: sizing.descriptionFontSize,
|
|
313
342
|
lineHeight: sizing.descriptionLineHeight,
|
|
@@ -317,6 +346,7 @@ var Switch = ({
|
|
|
317
346
|
showErrorLabel && /* @__PURE__ */ jsx3(
|
|
318
347
|
Text,
|
|
319
348
|
{
|
|
349
|
+
id: errorId,
|
|
320
350
|
color: theme.colors.content.alert.primary,
|
|
321
351
|
fontSize: sizing.descriptionFontSize,
|
|
322
352
|
lineHeight: sizing.descriptionLineHeight,
|
|
@@ -330,13 +360,16 @@ var Switch = ({
|
|
|
330
360
|
width: sizing.width,
|
|
331
361
|
height: sizing.height,
|
|
332
362
|
backgroundColor: getBgColor(),
|
|
363
|
+
borderColor: getBorderColor(),
|
|
364
|
+
borderWidth: 1,
|
|
333
365
|
borderRadius: sizing.frameBorderRadius,
|
|
334
|
-
padding:
|
|
366
|
+
padding: 1,
|
|
335
367
|
flexDirection: "row",
|
|
336
368
|
alignItems: "center",
|
|
337
369
|
justifyContent: checked ? "flex-end" : "flex-start",
|
|
338
370
|
hoverStyle: !isDisable && !isHover ? {
|
|
339
|
-
backgroundColor: checked ? checkColors.bgHover : switchColors.bgHover
|
|
371
|
+
backgroundColor: checked ? checkColors.bgHover : switchColors.bgHover,
|
|
372
|
+
borderColor: checked ? checkColors.borderHover : switchColors.borderHover
|
|
340
373
|
} : void 0,
|
|
341
374
|
children: /* @__PURE__ */ jsx3(
|
|
342
375
|
Box,
|
|
@@ -355,9 +388,11 @@ var Switch = ({
|
|
|
355
388
|
role: "switch",
|
|
356
389
|
"aria-checked": checked,
|
|
357
390
|
"aria-disabled": isDisable || void 0,
|
|
391
|
+
"aria-invalid": isError || void 0,
|
|
392
|
+
"aria-describedby": ariaDescribedBy,
|
|
358
393
|
"aria-label": ariaLabelledBy ? void 0 : ariaLabel || (label ? void 0 : "Switch"),
|
|
359
394
|
"aria-labelledby": ariaLabelledBy,
|
|
360
|
-
tabIndex:
|
|
395
|
+
tabIndex: 0,
|
|
361
396
|
flexDirection: "row",
|
|
362
397
|
alignItems: description || showErrorLabel ? "flex-start" : "center",
|
|
363
398
|
gap: sizing.labelGap,
|
package/native/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../primitives-native/src/Box.tsx","../../../primitives-native/src/Text.tsx","../../src/Switch.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n View,\n Pressable,\n Image,\n ViewStyle,\n ImageStyle,\n DimensionValue,\n AnimatableNumericValue,\n} from \"react-native\";\nimport { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nexport const Box: React.FC<BoxProps> = ({\n children,\n onPress,\n onLayout,\n onMoveShouldSetResponder,\n onResponderGrant,\n onResponderMove,\n onResponderRelease,\n onResponderTerminate,\n backgroundColor,\n borderColor,\n borderWidth,\n borderBottomWidth,\n borderBottomColor,\n borderTopWidth,\n borderTopColor,\n borderLeftWidth,\n borderLeftColor,\n borderRightWidth,\n borderRightColor,\n borderRadius,\n borderStyle,\n height,\n padding,\n paddingHorizontal,\n paddingVertical,\n margin,\n marginTop,\n marginBottom,\n marginLeft,\n marginRight,\n flexDirection,\n alignItems,\n justifyContent,\n position,\n top,\n bottom,\n left,\n right,\n width,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flex,\n overflow,\n zIndex,\n hoverStyle,\n pressStyle,\n style,\n \"data-testid\": dataTestId,\n testID,\n as,\n src,\n alt,\n ...rest\n}) => {\n const getContainerStyle = (pressed?: boolean): ViewStyle => ({\n backgroundColor:\n pressed && pressStyle?.backgroundColor\n ? pressStyle.backgroundColor\n : backgroundColor,\n borderColor,\n borderWidth,\n borderBottomWidth,\n borderBottomColor,\n borderTopWidth,\n borderTopColor,\n borderLeftWidth,\n borderLeftColor,\n borderRightWidth,\n borderRightColor,\n borderRadius: borderRadius as AnimatableNumericValue,\n borderStyle: borderStyle as ViewStyle[\"borderStyle\"],\n overflow,\n zIndex,\n height: height as DimensionValue,\n width: width as DimensionValue,\n minWidth: minWidth as DimensionValue,\n minHeight: minHeight as DimensionValue,\n maxWidth: maxWidth as DimensionValue,\n maxHeight: maxHeight as DimensionValue,\n padding: padding as DimensionValue,\n paddingHorizontal: paddingHorizontal as DimensionValue,\n paddingVertical: paddingVertical as DimensionValue,\n margin: margin as DimensionValue,\n marginTop: marginTop as DimensionValue,\n marginBottom: marginBottom as DimensionValue,\n marginLeft: marginLeft as DimensionValue,\n marginRight: marginRight as DimensionValue,\n flexDirection,\n alignItems,\n justifyContent,\n position: position as ViewStyle[\"position\"],\n top: top as DimensionValue,\n bottom: bottom as DimensionValue,\n left: left as DimensionValue,\n right: right as DimensionValue,\n flex,\n ...(style as ViewStyle),\n });\n\n const finalTestID = dataTestId || testID;\n\n // Destructure and drop web-only props from rest before passing to RN components\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n role,\n tabIndex,\n onKeyDown,\n onKeyUp,\n \"aria-label\": _ariaLabel,\n \"aria-labelledby\": _ariaLabelledBy,\n \"aria-current\": _ariaCurrent,\n \"aria-disabled\": _ariaDisabled,\n \"aria-live\": _ariaLive,\n className,\n \"data-testid\": _dataTestId,\n ...nativeRest\n } = rest as Record<string, unknown>;\n\n // Handle as=\"img\" for React Native\n if (as === \"img\" && src) {\n const imageStyle: ImageStyle = {\n width: width as DimensionValue,\n height: height as DimensionValue,\n borderRadius: borderRadius as number,\n position: position as ImageStyle[\"position\"],\n top: top as DimensionValue,\n bottom: bottom as DimensionValue,\n left: left as DimensionValue,\n right: right as DimensionValue,\n ...(style as ImageStyle),\n };\n\n return (\n <Image\n source={{ uri: src }}\n style={imageStyle}\n testID={finalTestID}\n resizeMode=\"cover\"\n {...nativeRest}\n />\n );\n }\n\n if (onPress) {\n return (\n <Pressable\n onPress={onPress}\n onLayout={onLayout}\n onMoveShouldSetResponder={onMoveShouldSetResponder}\n onResponderGrant={onResponderGrant}\n onResponderMove={onResponderMove}\n onResponderRelease={onResponderRelease}\n onResponderTerminate={onResponderTerminate}\n style={({ pressed }) => getContainerStyle(pressed)}\n testID={finalTestID}\n {...nativeRest}\n >\n {children}\n </Pressable>\n );\n }\n\n return (\n <View\n style={getContainerStyle()}\n testID={finalTestID}\n onLayout={onLayout}\n onMoveShouldSetResponder={onMoveShouldSetResponder}\n onResponderGrant={onResponderGrant}\n onResponderMove={onResponderMove}\n onResponderRelease={onResponderRelease}\n onResponderTerminate={onResponderTerminate}\n {...nativeRest}\n >\n {children}\n </View>\n );\n};\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","import React from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport { useResolvedTheme, type ThemeOverrideProps } from \"@xsolla/xui-core\";\n\nexport interface SwitchProps extends ThemeOverrideProps {\n /** Size of the switch */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n /** Whether the switch is checked */\n checked?: boolean;\n /** Visual state of the switch */\n state?: \"default\" | \"hover\" | \"disable\" | \"error\";\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch */\n labelPosition?: \"left\" | \"right\";\n /** Description text to display below the label */\n description?: string;\n /** Error label text to display when state is 'error' */\n errorLabel?: string;\n /** Callback when the switch value changes */\n onValueChange?: (value: boolean) => void;\n /** Accessible label for screen readers */\n ariaLabel?: string;\n /** ID of the element that labels this switch */\n ariaLabelledBy?: string;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({\n size = \"md\",\n checked = false,\n state = \"default\",\n disabled = false,\n label,\n labelPosition = \"right\",\n description,\n errorLabel,\n onValueChange,\n ariaLabel,\n ariaLabelledBy,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n\n const isDisable = state === \"disable\" || disabled;\n const isError = state === \"error\";\n const isHover = state === \"hover\";\n const showErrorLabel = isError && errorLabel;\n\n // Resolve Sizing\n const sizing = theme.sizing.switch(size);\n\n // Resolve Colors from Theme\n const switchColors = theme.colors.control.switch;\n const checkColors = theme.colors.control.check;\n const textColors = theme.colors.control.text;\n\n const handlePress = () => {\n if (!isDisable && onValueChange) {\n onValueChange(!checked);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!isDisable && (event.key === \" \" || event.key === \"Enter\")) {\n event.preventDefault();\n handlePress();\n }\n };\n\n const getBgColor = () => {\n if (isDisable) return switchColors.bg;\n if (checked && isHover) return checkColors.bgHover;\n if (checked) return checkColors.bg;\n if (isHover) return switchColors.bgHover;\n return switchColors.bg;\n };\n\n const getTextColor = () => {\n if (isDisable) return textColors.disable;\n return textColors.primary;\n };\n\n const getKnobColor = () => {\n return theme.colors.content.static.light;\n };\n\n const labelBlock = (label || description || showErrorLabel) && (\n <Box flexDirection=\"column\" gap={sizing.textGap}>\n {label && (\n <Text\n color={getTextColor()}\n fontSize={sizing.fontSize}\n lineHeight={sizing.lineHeight}\n fontWeight=\"400\"\n >\n {label}\n </Text>\n )}\n {description && (\n <Text\n color={theme.colors.content.tertiary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {description}\n </Text>\n )}\n {showErrorLabel && (\n <Text\n color={theme.colors.content.alert.primary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {errorLabel}\n </Text>\n )}\n </Box>\n );\n\n const toggle = (\n <Box\n width={sizing.width}\n height={sizing.height}\n backgroundColor={getBgColor()}\n borderRadius={sizing.frameBorderRadius}\n padding={2}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent={checked ? \"flex-end\" : \"flex-start\"}\n hoverStyle={\n !isDisable && !isHover\n ? {\n backgroundColor: checked\n ? checkColors.bgHover\n : switchColors.bgHover,\n }\n : undefined\n }\n >\n <Box\n width={sizing.knobSize}\n height={sizing.knobSize}\n backgroundColor={getKnobColor()}\n borderRadius={sizing.knobBorderRadius}\n />\n </Box>\n );\n\n return (\n <Box\n role=\"switch\"\n aria-checked={checked}\n aria-disabled={isDisable || undefined}\n aria-label={\n ariaLabelledBy ? undefined : ariaLabel || (label ? undefined : \"Switch\")\n }\n aria-labelledby={ariaLabelledBy}\n tabIndex={isDisable ? -1 : 0}\n flexDirection=\"row\"\n alignItems={description || showErrorLabel ? \"flex-start\" : \"center\"}\n gap={sizing.labelGap}\n onPress={handlePress}\n onKeyDown={handleKeyDown}\n cursor={!isDisable ? \"pointer\" : \"default\"}\n >\n {labelPosition === \"left\" && labelBlock}\n {toggle}\n {labelPosition === \"right\" && labelBlock}\n </Box>\n );\n};\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AA2ID;AAxIC,IAAM,MAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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AA,MACrB,SAAS;AAAA,MACT,eAAc;AAAA,MACd,YAAW;AAAA,MACX,gBAAgB,UAAU,aAAa;AAAA,MACvC,YACE,CAAC,aAAa,CAAC,UACX;AAAA,QACE,iBAAiB,UACb,YAAY,UACZ,aAAa;AAAA,MACnB,IACA;AAAA,MAGN,0BAAAA;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,OAAO;AAAA,UACd,QAAQ,OAAO;AAAA,UACf,iBAAiB,aAAa;AAAA,UAC9B,cAAc,OAAO;AAAA;AAAA,MACvB;AAAA;AAAA,EACF;AAGF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,gBAAc;AAAA,MACd,iBAAe,aAAa;AAAA,MAC5B,cACE,iBAAiB,SAAY,cAAc,QAAQ,SAAY;AAAA,MAEjE,mBAAiB;AAAA,MACjB,UAAU,YAAY,KAAK;AAAA,MAC3B,eAAc;AAAA,MACd,YAAY,eAAe,iBAAiB,eAAe;AAAA,MAC3D,KAAK,OAAO;AAAA,MACZ,SAAS;AAAA,MACT,WAAW;AAAA,MACX,QAAQ,CAAC,YAAY,YAAY;AAAA,MAEhC;AAAA,0BAAkB,UAAU;AAAA,QAC5B;AAAA,QACA,kBAAkB,WAAW;AAAA;AAAA;AAAA,EAChC;AAEJ;","names":["jsx","jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../../primitives-native/src/Box.tsx","../../../primitives-native/src/Text.tsx","../../src/Switch.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n View,\n Pressable,\n Image,\n ViewStyle,\n ImageStyle,\n DimensionValue,\n AnimatableNumericValue,\n} from \"react-native\";\nimport { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nexport const Box: React.FC<BoxProps> = ({\n children,\n onPress,\n onLayout,\n onMoveShouldSetResponder,\n onResponderGrant,\n onResponderMove,\n onResponderRelease,\n onResponderTerminate,\n backgroundColor,\n borderColor,\n borderWidth,\n borderBottomWidth,\n borderBottomColor,\n borderTopWidth,\n borderTopColor,\n borderLeftWidth,\n borderLeftColor,\n borderRightWidth,\n borderRightColor,\n borderRadius,\n borderStyle,\n height,\n padding,\n paddingHorizontal,\n paddingVertical,\n margin,\n marginTop,\n marginBottom,\n marginLeft,\n marginRight,\n flexDirection,\n alignItems,\n justifyContent,\n position,\n top,\n bottom,\n left,\n right,\n width,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flex,\n overflow,\n zIndex,\n hoverStyle,\n pressStyle,\n style,\n \"data-testid\": dataTestId,\n testID,\n as,\n src,\n alt,\n ...rest\n}) => {\n const getContainerStyle = (pressed?: boolean): ViewStyle => ({\n backgroundColor:\n pressed && pressStyle?.backgroundColor\n ? pressStyle.backgroundColor\n : backgroundColor,\n borderColor,\n borderWidth,\n borderBottomWidth,\n borderBottomColor,\n borderTopWidth,\n borderTopColor,\n borderLeftWidth,\n borderLeftColor,\n borderRightWidth,\n borderRightColor,\n borderRadius: borderRadius as AnimatableNumericValue,\n borderStyle: borderStyle as ViewStyle[\"borderStyle\"],\n overflow,\n zIndex,\n height: height as DimensionValue,\n width: width as DimensionValue,\n minWidth: minWidth as DimensionValue,\n minHeight: minHeight as DimensionValue,\n maxWidth: maxWidth as DimensionValue,\n maxHeight: maxHeight as DimensionValue,\n padding: padding as DimensionValue,\n paddingHorizontal: paddingHorizontal as DimensionValue,\n paddingVertical: paddingVertical as DimensionValue,\n margin: margin as DimensionValue,\n marginTop: marginTop as DimensionValue,\n marginBottom: marginBottom as DimensionValue,\n marginLeft: marginLeft as DimensionValue,\n marginRight: marginRight as DimensionValue,\n flexDirection,\n alignItems,\n justifyContent,\n position: position as ViewStyle[\"position\"],\n top: top as DimensionValue,\n bottom: bottom as DimensionValue,\n left: left as DimensionValue,\n right: right as DimensionValue,\n flex,\n ...(style as ViewStyle),\n });\n\n const finalTestID = dataTestId || testID;\n\n // Destructure and drop web-only props from rest before passing to RN components\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n role,\n tabIndex,\n onKeyDown,\n onKeyUp,\n \"aria-label\": _ariaLabel,\n \"aria-labelledby\": _ariaLabelledBy,\n \"aria-current\": _ariaCurrent,\n \"aria-disabled\": _ariaDisabled,\n \"aria-live\": _ariaLive,\n className,\n \"data-testid\": _dataTestId,\n ...nativeRest\n } = rest as Record<string, unknown>;\n\n // Handle as=\"img\" for React Native\n if (as === \"img\" && src) {\n const imageStyle: ImageStyle = {\n width: width as DimensionValue,\n height: height as DimensionValue,\n borderRadius: borderRadius as number,\n position: position as ImageStyle[\"position\"],\n top: top as DimensionValue,\n bottom: bottom as DimensionValue,\n left: left as DimensionValue,\n right: right as DimensionValue,\n ...(style as ImageStyle),\n };\n\n return (\n <Image\n source={{ uri: src }}\n style={imageStyle}\n testID={finalTestID}\n resizeMode=\"cover\"\n {...nativeRest}\n />\n );\n }\n\n if (onPress) {\n return (\n <Pressable\n onPress={onPress}\n onLayout={onLayout}\n onMoveShouldSetResponder={onMoveShouldSetResponder}\n onResponderGrant={onResponderGrant}\n onResponderMove={onResponderMove}\n onResponderRelease={onResponderRelease}\n onResponderTerminate={onResponderTerminate}\n style={({ pressed }) => getContainerStyle(pressed)}\n testID={finalTestID}\n {...nativeRest}\n >\n {children}\n </Pressable>\n );\n }\n\n return (\n <View\n style={getContainerStyle()}\n testID={finalTestID}\n onLayout={onLayout}\n onMoveShouldSetResponder={onMoveShouldSetResponder}\n onResponderGrant={onResponderGrant}\n onResponderMove={onResponderMove}\n onResponderRelease={onResponderRelease}\n onResponderTerminate={onResponderTerminate}\n {...nativeRest}\n >\n {children}\n </View>\n );\n};\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","import React from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport {\n useResolvedTheme,\n useId,\n type ThemeOverrideProps,\n} from \"@xsolla/xui-core\";\n\nexport interface SwitchProps extends ThemeOverrideProps {\n /** Size of the switch */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n /** Whether the switch is checked */\n checked?: boolean;\n /** Visual state of the switch */\n state?: \"default\" | \"hover\" | \"disable\" | \"error\";\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch */\n labelPosition?: \"left\" | \"right\";\n /** Description text to display below the label */\n description?: string;\n /** Error label text to display when state is 'error' */\n errorLabel?: string;\n /** Callback when the switch value changes */\n onValueChange?: (value: boolean) => void;\n /** Accessible label for screen readers */\n ariaLabel?: string;\n /** ID of the element that labels this switch */\n ariaLabelledBy?: string;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({\n size = \"md\",\n checked = false,\n state = \"default\",\n disabled = false,\n label,\n labelPosition = \"right\",\n description,\n errorLabel,\n onValueChange,\n ariaLabel,\n ariaLabelledBy,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n\n const isDisable = state === \"disable\" || disabled;\n const isError = state === \"error\";\n const isHover = state === \"hover\";\n const showErrorLabel = isError && errorLabel;\n\n const rawId = useId();\n const safeId = rawId.replace(/:/g, \"\");\n const descriptionId = `switch-desc-${safeId}`;\n const errorId = `switch-error-${safeId}`;\n\n const ariaDescribedByParts: string[] = [];\n if (description) ariaDescribedByParts.push(descriptionId);\n if (showErrorLabel) ariaDescribedByParts.push(errorId);\n const ariaDescribedBy =\n ariaDescribedByParts.length > 0\n ? ariaDescribedByParts.join(\" \")\n : undefined;\n\n const sizing = theme.sizing.switch(size);\n\n const switchColors = theme.colors.control.switch;\n const checkColors = theme.colors.control.check;\n const knobColors = theme.colors.control.knob;\n const textColors = theme.colors.control.text;\n const borderColors = theme.colors.border;\n\n const handlePress = () => {\n if (!isDisable && onValueChange) {\n onValueChange(!checked);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!isDisable && (event.key === \" \" || event.key === \"Enter\")) {\n event.preventDefault();\n handlePress();\n }\n };\n\n const getBgColor = () => {\n if (isDisable) {\n return checked ? checkColors.bgDisable : switchColors.bgDisable;\n }\n if (checked && isHover) return checkColors.bgHover;\n if (checked) return checkColors.bg;\n if (isHover) return switchColors.bgHover;\n return switchColors.bg;\n };\n\n const getBorderColor = () => {\n if (isError) return borderColors.alert;\n if (isDisable) {\n return checked ? checkColors.borderDisable : switchColors.borderDisable;\n }\n if (checked && isHover) return checkColors.borderHover;\n if (checked) return checkColors.border;\n if (isHover) return switchColors.borderHover;\n return switchColors.border;\n };\n\n const getTextColor = () => {\n if (isDisable) return textColors.disable;\n return textColors.primary;\n };\n\n const getKnobColor = () => {\n if (isDisable) return knobColors.bgInactive;\n if (checked && isHover) return knobColors.bgHover;\n if (checked) return knobColors.bg;\n return knobColors.bgInactive;\n };\n\n const labelBlock = (label || description || showErrorLabel) && (\n <Box flexDirection=\"column\" gap={sizing.textGap}>\n {label && (\n <Text\n color={getTextColor()}\n fontSize={sizing.fontSize}\n lineHeight={sizing.lineHeight}\n fontWeight=\"400\"\n >\n {label}\n </Text>\n )}\n {description && (\n <Text\n id={descriptionId}\n color={theme.colors.content.tertiary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {description}\n </Text>\n )}\n {showErrorLabel && (\n <Text\n id={errorId}\n color={theme.colors.content.alert.primary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {errorLabel}\n </Text>\n )}\n </Box>\n );\n\n const toggle = (\n <Box\n width={sizing.width}\n height={sizing.height}\n backgroundColor={getBgColor()}\n borderColor={getBorderColor()}\n borderWidth={1}\n borderRadius={sizing.frameBorderRadius}\n padding={1}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent={checked ? \"flex-end\" : \"flex-start\"}\n hoverStyle={\n !isDisable && !isHover\n ? {\n backgroundColor: checked\n ? checkColors.bgHover\n : switchColors.bgHover,\n borderColor: checked\n ? checkColors.borderHover\n : switchColors.borderHover,\n }\n : undefined\n }\n >\n <Box\n width={sizing.knobSize}\n height={sizing.knobSize}\n backgroundColor={getKnobColor()}\n borderRadius={sizing.knobBorderRadius}\n />\n </Box>\n );\n\n return (\n <Box\n role=\"switch\"\n aria-checked={checked}\n aria-disabled={isDisable || undefined}\n aria-invalid={isError || undefined}\n aria-describedby={ariaDescribedBy}\n aria-label={\n ariaLabelledBy ? undefined : ariaLabel || (label ? undefined : \"Switch\")\n }\n aria-labelledby={ariaLabelledBy}\n tabIndex={0}\n flexDirection=\"row\"\n alignItems={description || showErrorLabel ? \"flex-start\" : \"center\"}\n gap={sizing.labelGap}\n onPress={handlePress}\n onKeyDown={handleKeyDown}\n cursor={!isDisable ? \"pointer\" : \"default\"}\n >\n {labelPosition === \"left\" && labelBlock}\n {toggle}\n {labelPosition === \"right\" && labelBlock}\n </Box>\n );\n};\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AA2ID;AAxIC,IAAM,MAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,oBAAoB,CAAC,aAAkC;AAAA,IAC3D,iBACE,WAAW,YAAY,kBACnB,WAAW,kBACX;AAAA,IACN;AAAA,IAC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WAAW;AAAA,MACX,QAAQ,CAAC,YAAY,YAAY;AAAA,MAEhC;AAAA,0BAAkB,UAAU;AAAA,QAC5B;AAAA,QACA,kBAAkB,WAAW;AAAA;AAAA;AAAA,EAChC;AAEJ;","names":["jsx","jsx"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-switch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.135.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.135.0",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.135.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=16.8.0",
|
package/web/index.js
CHANGED
|
@@ -35,117 +35,10 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// ../primitives-web/src/Box.tsx
|
|
38
|
-
var import_react2 = __toESM(require("react"));
|
|
39
|
-
var import_styled_components = __toESM(require("styled-components"));
|
|
40
|
-
|
|
41
|
-
// ../primitives-web/src/filterDOMProps.ts
|
|
42
38
|
var import_react = __toESM(require("react"));
|
|
43
|
-
var
|
|
44
|
-
// BoxProps — layout & styling
|
|
45
|
-
"backgroundColor",
|
|
46
|
-
"borderColor",
|
|
47
|
-
"borderWidth",
|
|
48
|
-
"borderBottomWidth",
|
|
49
|
-
"borderBottomColor",
|
|
50
|
-
"borderTopWidth",
|
|
51
|
-
"borderTopColor",
|
|
52
|
-
"borderLeftWidth",
|
|
53
|
-
"borderLeftColor",
|
|
54
|
-
"borderRightWidth",
|
|
55
|
-
"borderRightColor",
|
|
56
|
-
"borderRadius",
|
|
57
|
-
"borderStyle",
|
|
58
|
-
"flexDirection",
|
|
59
|
-
"flexWrap",
|
|
60
|
-
"alignItems",
|
|
61
|
-
"justifyContent",
|
|
62
|
-
"alignSelf",
|
|
63
|
-
"flex",
|
|
64
|
-
"flexShrink",
|
|
65
|
-
"gap",
|
|
66
|
-
"position",
|
|
67
|
-
"top",
|
|
68
|
-
"bottom",
|
|
69
|
-
"left",
|
|
70
|
-
"right",
|
|
71
|
-
"outline",
|
|
72
|
-
"overflow",
|
|
73
|
-
"overflowX",
|
|
74
|
-
"overflowY",
|
|
75
|
-
"zIndex",
|
|
76
|
-
"cursor",
|
|
77
|
-
"padding",
|
|
78
|
-
"paddingHorizontal",
|
|
79
|
-
"paddingVertical",
|
|
80
|
-
"paddingTop",
|
|
81
|
-
"paddingBottom",
|
|
82
|
-
"paddingLeft",
|
|
83
|
-
"paddingRight",
|
|
84
|
-
"margin",
|
|
85
|
-
"marginTop",
|
|
86
|
-
"marginBottom",
|
|
87
|
-
"marginLeft",
|
|
88
|
-
"marginRight",
|
|
89
|
-
"minWidth",
|
|
90
|
-
"minHeight",
|
|
91
|
-
"maxWidth",
|
|
92
|
-
"maxHeight",
|
|
93
|
-
"hoverStyle",
|
|
94
|
-
"pressStyle",
|
|
95
|
-
"focusStyle",
|
|
96
|
-
"outlineColor",
|
|
97
|
-
"outlineWidth",
|
|
98
|
-
"outlineOffset",
|
|
99
|
-
"outlineStyle",
|
|
100
|
-
// BoxProps — RN-only
|
|
101
|
-
"onPress",
|
|
102
|
-
"onLayout",
|
|
103
|
-
"onMoveShouldSetResponder",
|
|
104
|
-
"onResponderGrant",
|
|
105
|
-
"onResponderMove",
|
|
106
|
-
"onResponderRelease",
|
|
107
|
-
"onResponderTerminate",
|
|
108
|
-
"testID",
|
|
109
|
-
// Box — custom element type
|
|
110
|
-
"elementType",
|
|
111
|
-
// TextProps
|
|
112
|
-
"fontSize",
|
|
113
|
-
"fontWeight",
|
|
114
|
-
"fontFamily",
|
|
115
|
-
"lineHeight",
|
|
116
|
-
"whiteSpace",
|
|
117
|
-
"textAlign",
|
|
118
|
-
"textDecoration",
|
|
119
|
-
"numberOfLines",
|
|
120
|
-
"letterSpacing",
|
|
121
|
-
"textTransform",
|
|
122
|
-
// SpinnerProps
|
|
123
|
-
"strokeWidth",
|
|
124
|
-
// DividerProps
|
|
125
|
-
"vertical",
|
|
126
|
-
"dashStroke"
|
|
127
|
-
]);
|
|
128
|
-
function createFilteredElement(defaultTag) {
|
|
129
|
-
const Component = import_react.default.forwardRef(
|
|
130
|
-
({ children, elementType, ...props }, ref) => {
|
|
131
|
-
const Tag = elementType || defaultTag;
|
|
132
|
-
const htmlProps = {};
|
|
133
|
-
for (const key of Object.keys(props)) {
|
|
134
|
-
if (!NON_HTML_PROPS.has(key)) {
|
|
135
|
-
htmlProps[key] = props[key];
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return import_react.default.createElement(Tag, { ref, ...htmlProps }, children);
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
Component.displayName = `Filtered(${defaultTag})`;
|
|
142
|
-
return Component;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// ../primitives-web/src/Box.tsx
|
|
39
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
146
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
147
|
-
var
|
|
148
|
-
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
41
|
+
var StyledBox = import_styled_components.default.div`
|
|
149
42
|
display: flex;
|
|
150
43
|
box-sizing: border-box;
|
|
151
44
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
@@ -232,7 +125,7 @@ var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
|
232
125
|
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
233
126
|
}
|
|
234
127
|
`;
|
|
235
|
-
var Box =
|
|
128
|
+
var Box = import_react.default.forwardRef(
|
|
236
129
|
({
|
|
237
130
|
children,
|
|
238
131
|
onPress,
|
|
@@ -284,7 +177,7 @@ var Box = import_react2.default.forwardRef(
|
|
|
284
177
|
StyledBox,
|
|
285
178
|
{
|
|
286
179
|
ref,
|
|
287
|
-
|
|
180
|
+
as,
|
|
288
181
|
id,
|
|
289
182
|
type: as === "button" ? type || "button" : void 0,
|
|
290
183
|
disabled: as === "button" ? disabled : void 0,
|
|
@@ -315,8 +208,7 @@ Box.displayName = "Box";
|
|
|
315
208
|
// ../primitives-web/src/Text.tsx
|
|
316
209
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
317
210
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
318
|
-
var
|
|
319
|
-
var StyledText = (0, import_styled_components2.default)(FilteredSpan)`
|
|
211
|
+
var StyledText = import_styled_components2.default.span`
|
|
320
212
|
color: ${(props) => props.color || "inherit"};
|
|
321
213
|
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
322
214
|
font-weight: ${(props) => props.fontWeight || "normal"};
|
|
@@ -369,10 +261,20 @@ var Switch = ({
|
|
|
369
261
|
const isError = state === "error";
|
|
370
262
|
const isHover = state === "hover";
|
|
371
263
|
const showErrorLabel = isError && errorLabel;
|
|
264
|
+
const rawId = (0, import_xui_core.useId)();
|
|
265
|
+
const safeId = rawId.replace(/:/g, "");
|
|
266
|
+
const descriptionId = `switch-desc-${safeId}`;
|
|
267
|
+
const errorId = `switch-error-${safeId}`;
|
|
268
|
+
const ariaDescribedByParts = [];
|
|
269
|
+
if (description) ariaDescribedByParts.push(descriptionId);
|
|
270
|
+
if (showErrorLabel) ariaDescribedByParts.push(errorId);
|
|
271
|
+
const ariaDescribedBy = ariaDescribedByParts.length > 0 ? ariaDescribedByParts.join(" ") : void 0;
|
|
372
272
|
const sizing = theme.sizing.switch(size);
|
|
373
273
|
const switchColors = theme.colors.control.switch;
|
|
374
274
|
const checkColors = theme.colors.control.check;
|
|
275
|
+
const knobColors = theme.colors.control.knob;
|
|
375
276
|
const textColors = theme.colors.control.text;
|
|
277
|
+
const borderColors = theme.colors.border;
|
|
376
278
|
const handlePress = () => {
|
|
377
279
|
if (!isDisable && onValueChange) {
|
|
378
280
|
onValueChange(!checked);
|
|
@@ -385,18 +287,33 @@ var Switch = ({
|
|
|
385
287
|
}
|
|
386
288
|
};
|
|
387
289
|
const getBgColor = () => {
|
|
388
|
-
if (isDisable)
|
|
290
|
+
if (isDisable) {
|
|
291
|
+
return checked ? checkColors.bgDisable : switchColors.bgDisable;
|
|
292
|
+
}
|
|
389
293
|
if (checked && isHover) return checkColors.bgHover;
|
|
390
294
|
if (checked) return checkColors.bg;
|
|
391
295
|
if (isHover) return switchColors.bgHover;
|
|
392
296
|
return switchColors.bg;
|
|
393
297
|
};
|
|
298
|
+
const getBorderColor = () => {
|
|
299
|
+
if (isError) return borderColors.alert;
|
|
300
|
+
if (isDisable) {
|
|
301
|
+
return checked ? checkColors.borderDisable : switchColors.borderDisable;
|
|
302
|
+
}
|
|
303
|
+
if (checked && isHover) return checkColors.borderHover;
|
|
304
|
+
if (checked) return checkColors.border;
|
|
305
|
+
if (isHover) return switchColors.borderHover;
|
|
306
|
+
return switchColors.border;
|
|
307
|
+
};
|
|
394
308
|
const getTextColor = () => {
|
|
395
309
|
if (isDisable) return textColors.disable;
|
|
396
310
|
return textColors.primary;
|
|
397
311
|
};
|
|
398
312
|
const getKnobColor = () => {
|
|
399
|
-
return
|
|
313
|
+
if (isDisable) return knobColors.bgInactive;
|
|
314
|
+
if (checked && isHover) return knobColors.bgHover;
|
|
315
|
+
if (checked) return knobColors.bg;
|
|
316
|
+
return knobColors.bgInactive;
|
|
400
317
|
};
|
|
401
318
|
const labelBlock = (label || description || showErrorLabel) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box, { flexDirection: "column", gap: sizing.textGap, children: [
|
|
402
319
|
label && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -412,6 +329,7 @@ var Switch = ({
|
|
|
412
329
|
description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
413
330
|
Text,
|
|
414
331
|
{
|
|
332
|
+
id: descriptionId,
|
|
415
333
|
color: theme.colors.content.tertiary,
|
|
416
334
|
fontSize: sizing.descriptionFontSize,
|
|
417
335
|
lineHeight: sizing.descriptionLineHeight,
|
|
@@ -421,6 +339,7 @@ var Switch = ({
|
|
|
421
339
|
showErrorLabel && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
422
340
|
Text,
|
|
423
341
|
{
|
|
342
|
+
id: errorId,
|
|
424
343
|
color: theme.colors.content.alert.primary,
|
|
425
344
|
fontSize: sizing.descriptionFontSize,
|
|
426
345
|
lineHeight: sizing.descriptionLineHeight,
|
|
@@ -434,13 +353,16 @@ var Switch = ({
|
|
|
434
353
|
width: sizing.width,
|
|
435
354
|
height: sizing.height,
|
|
436
355
|
backgroundColor: getBgColor(),
|
|
356
|
+
borderColor: getBorderColor(),
|
|
357
|
+
borderWidth: 1,
|
|
437
358
|
borderRadius: sizing.frameBorderRadius,
|
|
438
|
-
padding:
|
|
359
|
+
padding: 1,
|
|
439
360
|
flexDirection: "row",
|
|
440
361
|
alignItems: "center",
|
|
441
362
|
justifyContent: checked ? "flex-end" : "flex-start",
|
|
442
363
|
hoverStyle: !isDisable && !isHover ? {
|
|
443
|
-
backgroundColor: checked ? checkColors.bgHover : switchColors.bgHover
|
|
364
|
+
backgroundColor: checked ? checkColors.bgHover : switchColors.bgHover,
|
|
365
|
+
borderColor: checked ? checkColors.borderHover : switchColors.borderHover
|
|
444
366
|
} : void 0,
|
|
445
367
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
446
368
|
Box,
|
|
@@ -459,9 +381,11 @@ var Switch = ({
|
|
|
459
381
|
role: "switch",
|
|
460
382
|
"aria-checked": checked,
|
|
461
383
|
"aria-disabled": isDisable || void 0,
|
|
384
|
+
"aria-invalid": isError || void 0,
|
|
385
|
+
"aria-describedby": ariaDescribedBy,
|
|
462
386
|
"aria-label": ariaLabelledBy ? void 0 : ariaLabel || (label ? void 0 : "Switch"),
|
|
463
387
|
"aria-labelledby": ariaLabelledBy,
|
|
464
|
-
tabIndex:
|
|
388
|
+
tabIndex: 0,
|
|
465
389
|
flexDirection: "row",
|
|
466
390
|
alignItems: description || showErrorLabel ? "flex-start" : "center",
|
|
467
391
|
gap: sizing.labelGap,
|
package/web/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.tsx","../../../primitives-web/src/Box.tsx","../../../primitives-web/src/filterDOMProps.ts","../../../primitives-web/src/Text.tsx","../../src/Switch.tsx"],"sourcesContent":["export * from \"./Switch\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport type { BoxProps } from \"@xsolla/xui-primitives-core\";\nimport { createFilteredElement } from \"./filterDOMProps\";\n\nconst FilteredDiv = createFilteredElement(\"div\");\n\nconst StyledBox = styled(FilteredDiv)<BoxProps>`\n display: flex;\n box-sizing: border-box;\n background-color: ${(props) => props.backgroundColor || \"transparent\"};\n border-color: ${(props) => props.borderColor || \"transparent\"};\n border-width: ${(props) =>\n typeof props.borderWidth === \"number\"\n ? `${props.borderWidth}px`\n : props.borderWidth || 0};\n\n ${(props) =>\n props.borderBottomWidth !== undefined &&\n `\n border-bottom-width: ${typeof props.borderBottomWidth === \"number\" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};\n border-bottom-color: ${props.borderBottomColor || props.borderColor || \"transparent\"};\n border-bottom-style: solid;\n `}\n ${(props) =>\n props.borderTopWidth !== undefined &&\n `\n border-top-width: ${typeof props.borderTopWidth === \"number\" ? `${props.borderTopWidth}px` : props.borderTopWidth};\n border-top-color: ${props.borderTopColor || props.borderColor || \"transparent\"};\n border-top-style: solid;\n `}\n ${(props) =>\n props.borderLeftWidth !== undefined &&\n `\n border-left-width: ${typeof props.borderLeftWidth === \"number\" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};\n border-left-color: ${props.borderLeftColor || props.borderColor || \"transparent\"};\n border-left-style: solid;\n `}\n ${(props) =>\n props.borderRightWidth !== undefined &&\n `\n border-right-width: ${typeof props.borderRightWidth === \"number\" ? `${props.borderRightWidth}px` : props.borderRightWidth};\n border-right-color: ${props.borderRightColor || props.borderColor || \"transparent\"};\n border-right-style: solid;\n `}\n\n border-style: ${(props) =>\n props.borderStyle ||\n (props.borderWidth ||\n props.borderBottomWidth ||\n props.borderTopWidth ||\n props.borderLeftWidth ||\n props.borderRightWidth\n ? \"solid\"\n : \"none\")};\n border-radius: ${(props) =>\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius || 0};\n height: ${(props) =>\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height || \"auto\"};\n width: ${(props) =>\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width || \"auto\"};\n min-width: ${(props) =>\n typeof props.minWidth === \"number\"\n ? `${props.minWidth}px`\n : props.minWidth || \"auto\"};\n min-height: ${(props) =>\n typeof props.minHeight === \"number\"\n ? `${props.minHeight}px`\n : props.minHeight || \"auto\"};\n max-width: ${(props) =>\n typeof props.maxWidth === \"number\"\n ? `${props.maxWidth}px`\n : props.maxWidth || \"none\"};\n max-height: ${(props) =>\n typeof props.maxHeight === \"number\"\n ? `${props.maxHeight}px`\n : props.maxHeight || \"none\"};\n\n padding: ${(props) =>\n typeof props.padding === \"number\"\n ? `${props.padding}px`\n : props.padding || 0};\n ${(props) =>\n props.paddingHorizontal &&\n `\n padding-left: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n padding-right: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n `}\n ${(props) =>\n props.paddingVertical &&\n `\n padding-top: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n padding-bottom: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n `}\n ${(props) =>\n props.paddingTop !== undefined &&\n `padding-top: ${typeof props.paddingTop === \"number\" ? `${props.paddingTop}px` : props.paddingTop};`}\n ${(props) =>\n props.paddingBottom !== undefined &&\n `padding-bottom: ${typeof props.paddingBottom === \"number\" ? `${props.paddingBottom}px` : props.paddingBottom};`}\n ${(props) =>\n props.paddingLeft !== undefined &&\n `padding-left: ${typeof props.paddingLeft === \"number\" ? `${props.paddingLeft}px` : props.paddingLeft};`}\n ${(props) =>\n props.paddingRight !== undefined &&\n `padding-right: ${typeof props.paddingRight === \"number\" ? `${props.paddingRight}px` : props.paddingRight};`}\n\n margin: ${(props) =>\n typeof props.margin === \"number\" ? `${props.margin}px` : props.margin || 0};\n ${(props) =>\n props.marginTop !== undefined &&\n `margin-top: ${typeof props.marginTop === \"number\" ? `${props.marginTop}px` : props.marginTop};`}\n ${(props) =>\n props.marginBottom !== undefined &&\n `margin-bottom: ${typeof props.marginBottom === \"number\" ? `${props.marginBottom}px` : props.marginBottom};`}\n ${(props) =>\n props.marginLeft !== undefined &&\n `margin-left: ${typeof props.marginLeft === \"number\" ? `${props.marginLeft}px` : props.marginLeft};`}\n ${(props) =>\n props.marginRight !== undefined &&\n `margin-right: ${typeof props.marginRight === \"number\" ? `${props.marginRight}px` : props.marginRight};`}\n\n flex-direction: ${(props) => props.flexDirection || \"column\"};\n flex-wrap: ${(props) => props.flexWrap || \"nowrap\"};\n align-items: ${(props) => props.alignItems || \"stretch\"};\n justify-content: ${(props) => props.justifyContent || \"flex-start\"};\n cursor: ${(props) =>\n props.cursor\n ? props.cursor\n : props.onClick || props.onPress\n ? \"pointer\"\n : \"inherit\"};\n position: ${(props) => props.position || \"static\"};\n top: ${(props) =>\n typeof props.top === \"number\" ? `${props.top}px` : props.top};\n bottom: ${(props) =>\n typeof props.bottom === \"number\" ? `${props.bottom}px` : props.bottom};\n left: ${(props) =>\n typeof props.left === \"number\" ? `${props.left}px` : props.left};\n right: ${(props) =>\n typeof props.right === \"number\" ? `${props.right}px` : props.right};\n flex: ${(props) => props.flex};\n flex-shrink: ${(props) => props.flexShrink ?? 1};\n gap: ${(props) =>\n typeof props.gap === \"number\" ? `${props.gap}px` : props.gap || 0};\n align-self: ${(props) => props.alignSelf || \"auto\"};\n overflow: ${(props) => props.overflow || \"visible\"};\n overflow-x: ${(props) => props.overflowX || \"visible\"};\n overflow-y: ${(props) => props.overflowY || \"visible\"};\n z-index: ${(props) => props.zIndex};\n opacity: ${(props) => (props.disabled ? 0.5 : 1)};\n pointer-events: ${(props) => (props.disabled ? \"none\" : \"auto\")};\n\n &:hover {\n ${(props) =>\n props.hoverStyle?.backgroundColor &&\n `background-color: ${props.hoverStyle.backgroundColor};`}\n ${(props) =>\n props.hoverStyle?.borderColor &&\n `border-color: ${props.hoverStyle.borderColor};`}\n }\n\n &:active {\n ${(props) =>\n props.pressStyle?.backgroundColor &&\n `background-color: ${props.pressStyle.backgroundColor};`}\n }\n`;\n\nexport const Box = React.forwardRef<\n HTMLDivElement | HTMLButtonElement,\n BoxProps\n>(\n (\n {\n children,\n onPress,\n onKeyDown,\n onKeyUp,\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-current\": ariaCurrent,\n \"aria-disabled\": ariaDisabled,\n \"aria-live\": ariaLive,\n \"aria-busy\": ariaBusy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-expanded\": ariaExpanded,\n \"aria-haspopup\": ariaHasPopup,\n \"aria-pressed\": ariaPressed,\n \"aria-controls\": ariaControls,\n tabIndex,\n as,\n src,\n alt,\n type,\n disabled,\n id,\n ...props\n },\n ref\n ) => {\n // Handle as=\"img\" for rendering images with proper border-radius\n if (as === \"img\" && src) {\n return (\n <img\n src={src}\n alt={alt || \"\"}\n style={{\n display: \"block\",\n objectFit: \"cover\",\n width:\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width,\n height:\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height,\n borderRadius:\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius,\n position: props.position,\n top: typeof props.top === \"number\" ? `${props.top}px` : props.top,\n left:\n typeof props.left === \"number\" ? `${props.left}px` : props.left,\n right:\n typeof props.right === \"number\"\n ? `${props.right}px`\n : props.right,\n bottom:\n typeof props.bottom === \"number\"\n ? `${props.bottom}px`\n : props.bottom,\n }}\n />\n );\n }\n\n return (\n <StyledBox\n ref={ref}\n elementType={as}\n id={id}\n type={as === \"button\" ? type || \"button\" : undefined}\n disabled={as === \"button\" ? disabled : undefined}\n onClick={onPress}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-current={ariaCurrent}\n aria-disabled={ariaDisabled}\n aria-busy={ariaBusy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-haspopup={ariaHasPopup}\n aria-pressed={ariaPressed}\n aria-controls={ariaControls}\n aria-live={ariaLive}\n tabIndex={tabIndex !== undefined ? tabIndex : undefined}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\n\n// Props from BoxProps, TextProps, SpinnerProps, IconProps, DividerProps\n// that are NOT valid HTML attributes and must not reach the DOM.\nexport const NON_HTML_PROPS = new Set([\n // BoxProps — layout & styling\n \"backgroundColor\",\n \"borderColor\",\n \"borderWidth\",\n \"borderBottomWidth\",\n \"borderBottomColor\",\n \"borderTopWidth\",\n \"borderTopColor\",\n \"borderLeftWidth\",\n \"borderLeftColor\",\n \"borderRightWidth\",\n \"borderRightColor\",\n \"borderRadius\",\n \"borderStyle\",\n \"flexDirection\",\n \"flexWrap\",\n \"alignItems\",\n \"justifyContent\",\n \"alignSelf\",\n \"flex\",\n \"flexShrink\",\n \"gap\",\n \"position\",\n \"top\",\n \"bottom\",\n \"left\",\n \"right\",\n \"outline\",\n \"overflow\",\n \"overflowX\",\n \"overflowY\",\n \"zIndex\",\n \"cursor\",\n \"padding\",\n \"paddingHorizontal\",\n \"paddingVertical\",\n \"paddingTop\",\n \"paddingBottom\",\n \"paddingLeft\",\n \"paddingRight\",\n \"margin\",\n \"marginTop\",\n \"marginBottom\",\n \"marginLeft\",\n \"marginRight\",\n \"minWidth\",\n \"minHeight\",\n \"maxWidth\",\n \"maxHeight\",\n \"hoverStyle\",\n \"pressStyle\",\n \"focusStyle\",\n \"outlineColor\",\n \"outlineWidth\",\n \"outlineOffset\",\n \"outlineStyle\",\n // BoxProps — RN-only\n \"onPress\",\n \"onLayout\",\n \"onMoveShouldSetResponder\",\n \"onResponderGrant\",\n \"onResponderMove\",\n \"onResponderRelease\",\n \"onResponderTerminate\",\n \"testID\",\n // Box — custom element type\n \"elementType\",\n // TextProps\n \"fontSize\",\n \"fontWeight\",\n \"fontFamily\",\n \"lineHeight\",\n \"whiteSpace\",\n \"textAlign\",\n \"textDecoration\",\n \"numberOfLines\",\n \"letterSpacing\",\n \"textTransform\",\n // SpinnerProps\n \"strokeWidth\",\n // DividerProps\n \"vertical\",\n \"dashStroke\",\n]);\n\n/**\n * Creates a React component that renders the given HTML tag\n * but filters out non-HTML props before they reach the DOM.\n *\n * Usage: `const FilteredDiv = createFilteredElement(\"div\");`\n * Then: `const StyledBox = styled(FilteredDiv)<BoxProps>\\`...\\`;`\n *\n * styled-components can still read ALL props for CSS interpolation,\n * but only valid HTML attributes are forwarded to the DOM element.\n */\nexport function createFilteredElement(defaultTag: string) {\n const Component = React.forwardRef<HTMLElement, any>(\n ({ children, elementType, ...props }, ref) => {\n const Tag = elementType || defaultTag;\n const htmlProps: Record<string, unknown> = {};\n for (const key of Object.keys(props)) {\n if (!NON_HTML_PROPS.has(key)) {\n htmlProps[key] = props[key];\n }\n }\n return React.createElement(Tag, { ref, ...htmlProps }, children);\n }\n );\n Component.displayName = `Filtered(${defaultTag})`;\n return Component;\n}\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\nimport { createFilteredElement } from \"./filterDOMProps\";\n\nconst FilteredSpan = createFilteredElement(\"span\");\n\nconst StyledText = styled(FilteredSpan)<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Aktiv Grotesk\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n numberOfLines: _numberOfLines,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n","import React from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport { useResolvedTheme, type ThemeOverrideProps } from \"@xsolla/xui-core\";\n\nexport interface SwitchProps extends ThemeOverrideProps {\n /** Size of the switch */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n /** Whether the switch is checked */\n checked?: boolean;\n /** Visual state of the switch */\n state?: \"default\" | \"hover\" | \"disable\" | \"error\";\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch */\n labelPosition?: \"left\" | \"right\";\n /** Description text to display below the label */\n description?: string;\n /** Error label text to display when state is 'error' */\n errorLabel?: string;\n /** Callback when the switch value changes */\n onValueChange?: (value: boolean) => void;\n /** Accessible label for screen readers */\n ariaLabel?: string;\n /** ID of the element that labels this switch */\n ariaLabelledBy?: string;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({\n size = \"md\",\n checked = false,\n state = \"default\",\n disabled = false,\n label,\n labelPosition = \"right\",\n description,\n errorLabel,\n onValueChange,\n ariaLabel,\n ariaLabelledBy,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n\n const isDisable = state === \"disable\" || disabled;\n const isError = state === \"error\";\n const isHover = state === \"hover\";\n const showErrorLabel = isError && errorLabel;\n\n // Resolve Sizing\n const sizing = theme.sizing.switch(size);\n\n // Resolve Colors from Theme\n const switchColors = theme.colors.control.switch;\n const checkColors = theme.colors.control.check;\n const textColors = theme.colors.control.text;\n\n const handlePress = () => {\n if (!isDisable && onValueChange) {\n onValueChange(!checked);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!isDisable && (event.key === \" \" || event.key === \"Enter\")) {\n event.preventDefault();\n handlePress();\n }\n };\n\n const getBgColor = () => {\n if (isDisable) return switchColors.bg;\n if (checked && isHover) return checkColors.bgHover;\n if (checked) return checkColors.bg;\n if (isHover) return switchColors.bgHover;\n return switchColors.bg;\n };\n\n const getTextColor = () => {\n if (isDisable) return textColors.disable;\n return textColors.primary;\n };\n\n const getKnobColor = () => {\n return theme.colors.content.static.light;\n };\n\n const labelBlock = (label || description || showErrorLabel) && (\n <Box flexDirection=\"column\" gap={sizing.textGap}>\n {label && (\n <Text\n color={getTextColor()}\n fontSize={sizing.fontSize}\n lineHeight={sizing.lineHeight}\n fontWeight=\"400\"\n >\n {label}\n </Text>\n )}\n {description && (\n <Text\n color={theme.colors.content.tertiary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {description}\n </Text>\n )}\n {showErrorLabel && (\n <Text\n color={theme.colors.content.alert.primary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {errorLabel}\n </Text>\n )}\n </Box>\n );\n\n const toggle = (\n <Box\n width={sizing.width}\n height={sizing.height}\n backgroundColor={getBgColor()}\n borderRadius={sizing.frameBorderRadius}\n padding={2}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent={checked ? \"flex-end\" : \"flex-start\"}\n hoverStyle={\n !isDisable && !isHover\n ? {\n backgroundColor: checked\n ? checkColors.bgHover\n : switchColors.bgHover,\n }\n : undefined\n }\n >\n <Box\n width={sizing.knobSize}\n height={sizing.knobSize}\n backgroundColor={getKnobColor()}\n borderRadius={sizing.knobBorderRadius}\n />\n </Box>\n );\n\n return (\n <Box\n role=\"switch\"\n aria-checked={checked}\n aria-disabled={isDisable || undefined}\n aria-label={\n ariaLabelledBy ? undefined : ariaLabel || (label ? undefined : \"Switch\")\n }\n aria-labelledby={ariaLabelledBy}\n tabIndex={isDisable ? -1 : 0}\n flexDirection=\"row\"\n alignItems={description || showErrorLabel ? \"flex-start\" : \"center\"}\n gap={sizing.labelGap}\n onPress={handlePress}\n onKeyDown={handleKeyDown}\n cursor={!isDisable ? \"pointer\" : \"default\"}\n >\n {labelPosition === \"left\" && labelBlock}\n {toggle}\n {labelPosition === \"right\" && labelBlock}\n </Box>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAkB;AAClB,+BAAmB;;;ACDnB,mBAAkB;AAIX,IAAM,iBAAiB,oBAAI,IAAI;AAAA;AAAA,EAEpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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MAAM,OAAO,QAAQ,MAAM;AAAA,QAClC,UAAU,OAAO;AAAA,QACjB,YAAY,OAAO;AAAA,QAElB;AAAA;AAAA,IACH;AAAA,KAEJ;AAGF,QAAM,SACJ;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,OAAO;AAAA,MACd,QAAQ,OAAO;AAAA,MACf,iBAAiB,WAAW;AAAA,MAC5B,cAAc,OAAO;AAAA,MACrB,SAAS;AAAA,MACT,eAAc;AAAA,MACd,YAAW;AAAA,MACX,gBAAgB,UAAU,aAAa;AAAA,MACvC,YACE,CAAC,aAAa,CAAC,UACX;AAAA,QACE,iBAAiB,UACb,YAAY,UACZ,aAAa;AAAA,MACnB,IACA;AAAA,MAGN;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,OAAO;AAAA,UACd,QAAQ,OAAO;AAAA,UACf,iBAAiB,aAAa;AAAA,UAC9B,cAAc,OAAO;AAAA;AAAA,MACvB;AAAA;AAAA,EACF;AAGF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,gBAAc;AAAA,MACd,iBAAe,aAAa;AAAA,MAC5B,cACE,iBAAiB,SAAY,cAAc,QAAQ,SAAY;AAAA,MAEjE,mBAAiB;AAAA,MACjB,UAAU,YAAY,KAAK;AAAA,MAC3B,eAAc;AAAA,MACd,YAAY,eAAe,iBAAiB,eAAe;AAAA,MAC3D,KAAK,OAAO;AAAA,MACZ,SAAS;AAAA,MACT,WAAW;AAAA,MACX,QAAQ,CAAC,YAAY,YAAY;AAAA,MAEhC;AAAA,0BAAkB,UAAU;AAAA,QAC5B;AAAA,QACA,kBAAkB,WAAW;AAAA;AAAA;AAAA,EAChC;AAEJ;","names":["import_react","React","styled","React","import_styled_components","import_jsx_runtime","styled","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.tsx","../../../primitives-web/src/Box.tsx","../../../primitives-web/src/Text.tsx","../../src/Switch.tsx"],"sourcesContent":["export * from \"./Switch\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport type { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledBox = styled.div<BoxProps>`\n display: flex;\n box-sizing: border-box;\n background-color: ${(props) => props.backgroundColor || \"transparent\"};\n border-color: ${(props) => props.borderColor || \"transparent\"};\n border-width: ${(props) =>\n typeof props.borderWidth === \"number\"\n ? `${props.borderWidth}px`\n : props.borderWidth || 0};\n\n ${(props) =>\n props.borderBottomWidth !== undefined &&\n `\n border-bottom-width: ${typeof props.borderBottomWidth === \"number\" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};\n border-bottom-color: ${props.borderBottomColor || props.borderColor || \"transparent\"};\n border-bottom-style: solid;\n `}\n ${(props) =>\n props.borderTopWidth !== undefined &&\n `\n border-top-width: ${typeof props.borderTopWidth === \"number\" ? `${props.borderTopWidth}px` : props.borderTopWidth};\n border-top-color: ${props.borderTopColor || props.borderColor || \"transparent\"};\n border-top-style: solid;\n `}\n ${(props) =>\n props.borderLeftWidth !== undefined &&\n `\n border-left-width: ${typeof props.borderLeftWidth === \"number\" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};\n border-left-color: ${props.borderLeftColor || props.borderColor || \"transparent\"};\n border-left-style: solid;\n `}\n ${(props) =>\n props.borderRightWidth !== undefined &&\n `\n border-right-width: ${typeof props.borderRightWidth === \"number\" ? `${props.borderRightWidth}px` : props.borderRightWidth};\n border-right-color: ${props.borderRightColor || props.borderColor || \"transparent\"};\n border-right-style: solid;\n `}\n\n border-style: ${(props) =>\n props.borderStyle ||\n (props.borderWidth ||\n props.borderBottomWidth ||\n props.borderTopWidth ||\n props.borderLeftWidth ||\n props.borderRightWidth\n ? \"solid\"\n : \"none\")};\n border-radius: ${(props) =>\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius || 0};\n height: ${(props) =>\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height || \"auto\"};\n width: ${(props) =>\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width || \"auto\"};\n min-width: ${(props) =>\n typeof props.minWidth === \"number\"\n ? `${props.minWidth}px`\n : props.minWidth || \"auto\"};\n min-height: ${(props) =>\n typeof props.minHeight === \"number\"\n ? `${props.minHeight}px`\n : props.minHeight || \"auto\"};\n max-width: ${(props) =>\n typeof props.maxWidth === \"number\"\n ? `${props.maxWidth}px`\n : props.maxWidth || \"none\"};\n max-height: ${(props) =>\n typeof props.maxHeight === \"number\"\n ? `${props.maxHeight}px`\n : props.maxHeight || \"none\"};\n\n padding: ${(props) =>\n typeof props.padding === \"number\"\n ? `${props.padding}px`\n : props.padding || 0};\n ${(props) =>\n props.paddingHorizontal &&\n `\n padding-left: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n padding-right: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n `}\n ${(props) =>\n props.paddingVertical &&\n `\n padding-top: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n padding-bottom: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n `}\n ${(props) =>\n props.paddingTop !== undefined &&\n `padding-top: ${typeof props.paddingTop === \"number\" ? `${props.paddingTop}px` : props.paddingTop};`}\n ${(props) =>\n props.paddingBottom !== undefined &&\n `padding-bottom: ${typeof props.paddingBottom === \"number\" ? `${props.paddingBottom}px` : props.paddingBottom};`}\n ${(props) =>\n props.paddingLeft !== undefined &&\n `padding-left: ${typeof props.paddingLeft === \"number\" ? `${props.paddingLeft}px` : props.paddingLeft};`}\n ${(props) =>\n props.paddingRight !== undefined &&\n `padding-right: ${typeof props.paddingRight === \"number\" ? `${props.paddingRight}px` : props.paddingRight};`}\n\n margin: ${(props) =>\n typeof props.margin === \"number\" ? `${props.margin}px` : props.margin || 0};\n ${(props) =>\n props.marginTop !== undefined &&\n `margin-top: ${typeof props.marginTop === \"number\" ? `${props.marginTop}px` : props.marginTop};`}\n ${(props) =>\n props.marginBottom !== undefined &&\n `margin-bottom: ${typeof props.marginBottom === \"number\" ? `${props.marginBottom}px` : props.marginBottom};`}\n ${(props) =>\n props.marginLeft !== undefined &&\n `margin-left: ${typeof props.marginLeft === \"number\" ? `${props.marginLeft}px` : props.marginLeft};`}\n ${(props) =>\n props.marginRight !== undefined &&\n `margin-right: ${typeof props.marginRight === \"number\" ? `${props.marginRight}px` : props.marginRight};`}\n\n flex-direction: ${(props) => props.flexDirection || \"column\"};\n flex-wrap: ${(props) => props.flexWrap || \"nowrap\"};\n align-items: ${(props) => props.alignItems || \"stretch\"};\n justify-content: ${(props) => props.justifyContent || \"flex-start\"};\n cursor: ${(props) =>\n props.cursor\n ? props.cursor\n : props.onClick || props.onPress\n ? \"pointer\"\n : \"inherit\"};\n position: ${(props) => props.position || \"static\"};\n top: ${(props) =>\n typeof props.top === \"number\" ? `${props.top}px` : props.top};\n bottom: ${(props) =>\n typeof props.bottom === \"number\" ? `${props.bottom}px` : props.bottom};\n left: ${(props) =>\n typeof props.left === \"number\" ? `${props.left}px` : props.left};\n right: ${(props) =>\n typeof props.right === \"number\" ? `${props.right}px` : props.right};\n flex: ${(props) => props.flex};\n flex-shrink: ${(props) => props.flexShrink ?? 1};\n gap: ${(props) =>\n typeof props.gap === \"number\" ? `${props.gap}px` : props.gap || 0};\n align-self: ${(props) => props.alignSelf || \"auto\"};\n overflow: ${(props) => props.overflow || \"visible\"};\n overflow-x: ${(props) => props.overflowX || \"visible\"};\n overflow-y: ${(props) => props.overflowY || \"visible\"};\n z-index: ${(props) => props.zIndex};\n opacity: ${(props) => (props.disabled ? 0.5 : 1)};\n pointer-events: ${(props) => (props.disabled ? \"none\" : \"auto\")};\n\n &:hover {\n ${(props) =>\n props.hoverStyle?.backgroundColor &&\n `background-color: ${props.hoverStyle.backgroundColor};`}\n ${(props) =>\n props.hoverStyle?.borderColor &&\n `border-color: ${props.hoverStyle.borderColor};`}\n }\n\n &:active {\n ${(props) =>\n props.pressStyle?.backgroundColor &&\n `background-color: ${props.pressStyle.backgroundColor};`}\n }\n`;\n\nexport const Box = React.forwardRef<\n HTMLDivElement | HTMLButtonElement,\n BoxProps\n>(\n (\n {\n children,\n onPress,\n onKeyDown,\n onKeyUp,\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-current\": ariaCurrent,\n \"aria-disabled\": ariaDisabled,\n \"aria-live\": ariaLive,\n \"aria-busy\": ariaBusy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-expanded\": ariaExpanded,\n \"aria-haspopup\": ariaHasPopup,\n \"aria-pressed\": ariaPressed,\n \"aria-controls\": ariaControls,\n tabIndex,\n as,\n src,\n alt,\n type,\n disabled,\n id,\n ...props\n },\n ref\n ) => {\n // Handle as=\"img\" for rendering images with proper border-radius\n if (as === \"img\" && src) {\n return (\n <img\n src={src}\n alt={alt || \"\"}\n style={{\n display: \"block\",\n objectFit: \"cover\",\n width:\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width,\n height:\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height,\n borderRadius:\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius,\n position: props.position,\n top: typeof props.top === \"number\" ? `${props.top}px` : props.top,\n left:\n typeof props.left === \"number\" ? `${props.left}px` : props.left,\n right:\n typeof props.right === \"number\"\n ? `${props.right}px`\n : props.right,\n bottom:\n typeof props.bottom === \"number\"\n ? `${props.bottom}px`\n : props.bottom,\n }}\n />\n );\n }\n\n return (\n <StyledBox\n ref={ref}\n as={as}\n id={id}\n type={as === \"button\" ? type || \"button\" : undefined}\n disabled={as === \"button\" ? disabled : undefined}\n onClick={onPress}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-current={ariaCurrent}\n aria-disabled={ariaDisabled}\n aria-busy={ariaBusy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-haspopup={ariaHasPopup}\n aria-pressed={ariaPressed}\n aria-controls={ariaControls}\n aria-live={ariaLive}\n tabIndex={tabIndex !== undefined ? tabIndex : undefined}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledText = styled.span<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Aktiv Grotesk\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n numberOfLines: _numberOfLines,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n","import React from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport {\n useResolvedTheme,\n useId,\n type ThemeOverrideProps,\n} from \"@xsolla/xui-core\";\n\nexport interface SwitchProps extends ThemeOverrideProps {\n /** Size of the switch */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n /** Whether the switch is checked */\n checked?: boolean;\n /** Visual state of the switch */\n state?: \"default\" | \"hover\" | \"disable\" | \"error\";\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch */\n labelPosition?: \"left\" | \"right\";\n /** Description text to display below the label */\n description?: string;\n /** Error label text to display when state is 'error' */\n errorLabel?: string;\n /** Callback when the switch value changes */\n onValueChange?: (value: boolean) => void;\n /** Accessible label for screen readers */\n ariaLabel?: string;\n /** ID of the element that labels this switch */\n ariaLabelledBy?: string;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({\n size = \"md\",\n checked = false,\n state = \"default\",\n disabled = false,\n label,\n labelPosition = \"right\",\n description,\n errorLabel,\n onValueChange,\n ariaLabel,\n ariaLabelledBy,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n\n const isDisable = state === \"disable\" || disabled;\n const isError = state === \"error\";\n const isHover = state === \"hover\";\n const showErrorLabel = isError && errorLabel;\n\n const rawId = useId();\n const safeId = rawId.replace(/:/g, \"\");\n const descriptionId = `switch-desc-${safeId}`;\n const errorId = `switch-error-${safeId}`;\n\n const ariaDescribedByParts: string[] = [];\n if (description) ariaDescribedByParts.push(descriptionId);\n if (showErrorLabel) ariaDescribedByParts.push(errorId);\n const ariaDescribedBy =\n ariaDescribedByParts.length > 0\n ? ariaDescribedByParts.join(\" \")\n : undefined;\n\n const sizing = theme.sizing.switch(size);\n\n const switchColors = theme.colors.control.switch;\n const checkColors = theme.colors.control.check;\n const knobColors = theme.colors.control.knob;\n const textColors = theme.colors.control.text;\n const borderColors = theme.colors.border;\n\n const handlePress = () => {\n if (!isDisable && onValueChange) {\n onValueChange(!checked);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!isDisable && (event.key === \" \" || event.key === \"Enter\")) {\n event.preventDefault();\n handlePress();\n }\n };\n\n const getBgColor = () => {\n if (isDisable) {\n return checked ? checkColors.bgDisable : switchColors.bgDisable;\n }\n if (checked && isHover) return checkColors.bgHover;\n if (checked) return checkColors.bg;\n if (isHover) return switchColors.bgHover;\n return switchColors.bg;\n };\n\n const getBorderColor = () => {\n if (isError) return borderColors.alert;\n if (isDisable) {\n return checked ? checkColors.borderDisable : switchColors.borderDisable;\n }\n if (checked && isHover) return checkColors.borderHover;\n if (checked) return checkColors.border;\n if (isHover) return switchColors.borderHover;\n return switchColors.border;\n };\n\n const getTextColor = () => {\n if (isDisable) return textColors.disable;\n return textColors.primary;\n };\n\n const getKnobColor = () => {\n if (isDisable) return knobColors.bgInactive;\n if (checked && isHover) return knobColors.bgHover;\n if (checked) return knobColors.bg;\n return knobColors.bgInactive;\n };\n\n const labelBlock = (label || description || showErrorLabel) && (\n <Box flexDirection=\"column\" gap={sizing.textGap}>\n {label && (\n <Text\n color={getTextColor()}\n fontSize={sizing.fontSize}\n lineHeight={sizing.lineHeight}\n fontWeight=\"400\"\n >\n {label}\n </Text>\n )}\n {description && (\n <Text\n id={descriptionId}\n color={theme.colors.content.tertiary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {description}\n </Text>\n )}\n {showErrorLabel && (\n <Text\n id={errorId}\n color={theme.colors.content.alert.primary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {errorLabel}\n </Text>\n )}\n </Box>\n );\n\n const toggle = (\n <Box\n width={sizing.width}\n height={sizing.height}\n backgroundColor={getBgColor()}\n borderColor={getBorderColor()}\n borderWidth={1}\n borderRadius={sizing.frameBorderRadius}\n padding={1}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent={checked ? \"flex-end\" : \"flex-start\"}\n hoverStyle={\n !isDisable && !isHover\n ? {\n backgroundColor: checked\n ? checkColors.bgHover\n : switchColors.bgHover,\n borderColor: checked\n ? checkColors.borderHover\n : switchColors.borderHover,\n }\n : undefined\n }\n >\n <Box\n width={sizing.knobSize}\n height={sizing.knobSize}\n backgroundColor={getKnobColor()}\n borderRadius={sizing.knobBorderRadius}\n />\n </Box>\n );\n\n return (\n <Box\n role=\"switch\"\n aria-checked={checked}\n aria-disabled={isDisable || undefined}\n aria-invalid={isError || undefined}\n aria-describedby={ariaDescribedBy}\n aria-label={\n ariaLabelledBy ? undefined : ariaLabel || (label ? undefined : \"Switch\")\n }\n aria-labelledby={ariaLabelledBy}\n tabIndex={0}\n flexDirection=\"row\"\n alignItems={description || showErrorLabel ? \"flex-start\" : \"center\"}\n gap={sizing.labelGap}\n onPress={handlePress}\n onKeyDown={handleKeyDown}\n cursor={!isDisable ? \"pointer\" : \"default\"}\n >\n {labelPosition === \"left\" && labelBlock}\n {toggle}\n {labelPosition === \"right\" && labelBlock}\n </Box>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkB;AAClB,+BAAmB;AA+MX;AA5MR,IAAM,YAAY,yBAAAA,QAAO;AAAA;AAAA;AAAA,sBAGH,CAAC,UAAU,MAAM,mBAAmB,aAAa;AAAA,kBACrD,CAAC,UAAU,MAAM,eAAe,aAAa;AAAA,kBAC7C,CAAC,UACf,OAAO,MAAM,gBAAgB,WACzB,GAAG,MAAM,WAAW,OACpB,MAAM,eAAe,CAAC;AAAA;AAAA,IAE1B,CAAC,UACD,MAAM,sBAAsB,UAC5B;AAAA,2BACuB,OAAO,MAAM,sBAAsB,WAAW,GAAG,MAAM,iBAAiB,OAAO,MAAM,iBAAiB;AAAA,2BACtG,MAAM,qBAAqB,MAAM,eAAe,aAAa;AAAA;AAAA,GAErF;AAAA,IACC,CAAC,UACD,MAAM,mBAAmB,UACzB;AAAA,wBACoB,OAAO,MAAM,mBAAmB,WAAW,GAAG,MAAM,cAAc,OAAO,MAAM,cAAc;AAAA,wBAC7F,MAAM,kBAAkB,MAAM,eAAe,aAAa;AAAA;AAAA,GAE/E;AAAA,IACC,CAAC,UACD,MAAM,oBAAoB,UAC1B;AAAA,yBACqB,OAAO,MAAM,oBAAoB,WAAW,GAAG,MAAM,eAAe,OAAO,MAAM,eAAe;AAAA,yBAChG,MAAM,mBAAmB,MAAM,eAAe,aAAa;AAAA;AAAA,GAEjF;AAAA,IACC,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time"]}
|
package/web/index.mjs
CHANGED
|
@@ -1,115 +1,8 @@
|
|
|
1
1
|
// ../primitives-web/src/Box.tsx
|
|
2
|
-
import React2 from "react";
|
|
3
|
-
import styled from "styled-components";
|
|
4
|
-
|
|
5
|
-
// ../primitives-web/src/filterDOMProps.ts
|
|
6
2
|
import React from "react";
|
|
7
|
-
|
|
8
|
-
// BoxProps — layout & styling
|
|
9
|
-
"backgroundColor",
|
|
10
|
-
"borderColor",
|
|
11
|
-
"borderWidth",
|
|
12
|
-
"borderBottomWidth",
|
|
13
|
-
"borderBottomColor",
|
|
14
|
-
"borderTopWidth",
|
|
15
|
-
"borderTopColor",
|
|
16
|
-
"borderLeftWidth",
|
|
17
|
-
"borderLeftColor",
|
|
18
|
-
"borderRightWidth",
|
|
19
|
-
"borderRightColor",
|
|
20
|
-
"borderRadius",
|
|
21
|
-
"borderStyle",
|
|
22
|
-
"flexDirection",
|
|
23
|
-
"flexWrap",
|
|
24
|
-
"alignItems",
|
|
25
|
-
"justifyContent",
|
|
26
|
-
"alignSelf",
|
|
27
|
-
"flex",
|
|
28
|
-
"flexShrink",
|
|
29
|
-
"gap",
|
|
30
|
-
"position",
|
|
31
|
-
"top",
|
|
32
|
-
"bottom",
|
|
33
|
-
"left",
|
|
34
|
-
"right",
|
|
35
|
-
"outline",
|
|
36
|
-
"overflow",
|
|
37
|
-
"overflowX",
|
|
38
|
-
"overflowY",
|
|
39
|
-
"zIndex",
|
|
40
|
-
"cursor",
|
|
41
|
-
"padding",
|
|
42
|
-
"paddingHorizontal",
|
|
43
|
-
"paddingVertical",
|
|
44
|
-
"paddingTop",
|
|
45
|
-
"paddingBottom",
|
|
46
|
-
"paddingLeft",
|
|
47
|
-
"paddingRight",
|
|
48
|
-
"margin",
|
|
49
|
-
"marginTop",
|
|
50
|
-
"marginBottom",
|
|
51
|
-
"marginLeft",
|
|
52
|
-
"marginRight",
|
|
53
|
-
"minWidth",
|
|
54
|
-
"minHeight",
|
|
55
|
-
"maxWidth",
|
|
56
|
-
"maxHeight",
|
|
57
|
-
"hoverStyle",
|
|
58
|
-
"pressStyle",
|
|
59
|
-
"focusStyle",
|
|
60
|
-
"outlineColor",
|
|
61
|
-
"outlineWidth",
|
|
62
|
-
"outlineOffset",
|
|
63
|
-
"outlineStyle",
|
|
64
|
-
// BoxProps — RN-only
|
|
65
|
-
"onPress",
|
|
66
|
-
"onLayout",
|
|
67
|
-
"onMoveShouldSetResponder",
|
|
68
|
-
"onResponderGrant",
|
|
69
|
-
"onResponderMove",
|
|
70
|
-
"onResponderRelease",
|
|
71
|
-
"onResponderTerminate",
|
|
72
|
-
"testID",
|
|
73
|
-
// Box — custom element type
|
|
74
|
-
"elementType",
|
|
75
|
-
// TextProps
|
|
76
|
-
"fontSize",
|
|
77
|
-
"fontWeight",
|
|
78
|
-
"fontFamily",
|
|
79
|
-
"lineHeight",
|
|
80
|
-
"whiteSpace",
|
|
81
|
-
"textAlign",
|
|
82
|
-
"textDecoration",
|
|
83
|
-
"numberOfLines",
|
|
84
|
-
"letterSpacing",
|
|
85
|
-
"textTransform",
|
|
86
|
-
// SpinnerProps
|
|
87
|
-
"strokeWidth",
|
|
88
|
-
// DividerProps
|
|
89
|
-
"vertical",
|
|
90
|
-
"dashStroke"
|
|
91
|
-
]);
|
|
92
|
-
function createFilteredElement(defaultTag) {
|
|
93
|
-
const Component = React.forwardRef(
|
|
94
|
-
({ children, elementType, ...props }, ref) => {
|
|
95
|
-
const Tag = elementType || defaultTag;
|
|
96
|
-
const htmlProps = {};
|
|
97
|
-
for (const key of Object.keys(props)) {
|
|
98
|
-
if (!NON_HTML_PROPS.has(key)) {
|
|
99
|
-
htmlProps[key] = props[key];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return React.createElement(Tag, { ref, ...htmlProps }, children);
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
Component.displayName = `Filtered(${defaultTag})`;
|
|
106
|
-
return Component;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// ../primitives-web/src/Box.tsx
|
|
3
|
+
import styled from "styled-components";
|
|
110
4
|
import { jsx } from "react/jsx-runtime";
|
|
111
|
-
var
|
|
112
|
-
var StyledBox = styled(FilteredDiv)`
|
|
5
|
+
var StyledBox = styled.div`
|
|
113
6
|
display: flex;
|
|
114
7
|
box-sizing: border-box;
|
|
115
8
|
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
@@ -196,7 +89,7 @@ var StyledBox = styled(FilteredDiv)`
|
|
|
196
89
|
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
197
90
|
}
|
|
198
91
|
`;
|
|
199
|
-
var Box =
|
|
92
|
+
var Box = React.forwardRef(
|
|
200
93
|
({
|
|
201
94
|
children,
|
|
202
95
|
onPress,
|
|
@@ -248,7 +141,7 @@ var Box = React2.forwardRef(
|
|
|
248
141
|
StyledBox,
|
|
249
142
|
{
|
|
250
143
|
ref,
|
|
251
|
-
|
|
144
|
+
as,
|
|
252
145
|
id,
|
|
253
146
|
type: as === "button" ? type || "button" : void 0,
|
|
254
147
|
disabled: as === "button" ? disabled : void 0,
|
|
@@ -279,8 +172,7 @@ Box.displayName = "Box";
|
|
|
279
172
|
// ../primitives-web/src/Text.tsx
|
|
280
173
|
import styled2 from "styled-components";
|
|
281
174
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
282
|
-
var
|
|
283
|
-
var StyledText = styled2(FilteredSpan)`
|
|
175
|
+
var StyledText = styled2.span`
|
|
284
176
|
color: ${(props) => props.color || "inherit"};
|
|
285
177
|
font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
|
|
286
178
|
font-weight: ${(props) => props.fontWeight || "normal"};
|
|
@@ -311,7 +203,10 @@ var Text = ({
|
|
|
311
203
|
};
|
|
312
204
|
|
|
313
205
|
// src/Switch.tsx
|
|
314
|
-
import {
|
|
206
|
+
import {
|
|
207
|
+
useResolvedTheme,
|
|
208
|
+
useId
|
|
209
|
+
} from "@xsolla/xui-core";
|
|
315
210
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
316
211
|
var Switch = ({
|
|
317
212
|
size = "md",
|
|
@@ -333,10 +228,20 @@ var Switch = ({
|
|
|
333
228
|
const isError = state === "error";
|
|
334
229
|
const isHover = state === "hover";
|
|
335
230
|
const showErrorLabel = isError && errorLabel;
|
|
231
|
+
const rawId = useId();
|
|
232
|
+
const safeId = rawId.replace(/:/g, "");
|
|
233
|
+
const descriptionId = `switch-desc-${safeId}`;
|
|
234
|
+
const errorId = `switch-error-${safeId}`;
|
|
235
|
+
const ariaDescribedByParts = [];
|
|
236
|
+
if (description) ariaDescribedByParts.push(descriptionId);
|
|
237
|
+
if (showErrorLabel) ariaDescribedByParts.push(errorId);
|
|
238
|
+
const ariaDescribedBy = ariaDescribedByParts.length > 0 ? ariaDescribedByParts.join(" ") : void 0;
|
|
336
239
|
const sizing = theme.sizing.switch(size);
|
|
337
240
|
const switchColors = theme.colors.control.switch;
|
|
338
241
|
const checkColors = theme.colors.control.check;
|
|
242
|
+
const knobColors = theme.colors.control.knob;
|
|
339
243
|
const textColors = theme.colors.control.text;
|
|
244
|
+
const borderColors = theme.colors.border;
|
|
340
245
|
const handlePress = () => {
|
|
341
246
|
if (!isDisable && onValueChange) {
|
|
342
247
|
onValueChange(!checked);
|
|
@@ -349,18 +254,33 @@ var Switch = ({
|
|
|
349
254
|
}
|
|
350
255
|
};
|
|
351
256
|
const getBgColor = () => {
|
|
352
|
-
if (isDisable)
|
|
257
|
+
if (isDisable) {
|
|
258
|
+
return checked ? checkColors.bgDisable : switchColors.bgDisable;
|
|
259
|
+
}
|
|
353
260
|
if (checked && isHover) return checkColors.bgHover;
|
|
354
261
|
if (checked) return checkColors.bg;
|
|
355
262
|
if (isHover) return switchColors.bgHover;
|
|
356
263
|
return switchColors.bg;
|
|
357
264
|
};
|
|
265
|
+
const getBorderColor = () => {
|
|
266
|
+
if (isError) return borderColors.alert;
|
|
267
|
+
if (isDisable) {
|
|
268
|
+
return checked ? checkColors.borderDisable : switchColors.borderDisable;
|
|
269
|
+
}
|
|
270
|
+
if (checked && isHover) return checkColors.borderHover;
|
|
271
|
+
if (checked) return checkColors.border;
|
|
272
|
+
if (isHover) return switchColors.borderHover;
|
|
273
|
+
return switchColors.border;
|
|
274
|
+
};
|
|
358
275
|
const getTextColor = () => {
|
|
359
276
|
if (isDisable) return textColors.disable;
|
|
360
277
|
return textColors.primary;
|
|
361
278
|
};
|
|
362
279
|
const getKnobColor = () => {
|
|
363
|
-
return
|
|
280
|
+
if (isDisable) return knobColors.bgInactive;
|
|
281
|
+
if (checked && isHover) return knobColors.bgHover;
|
|
282
|
+
if (checked) return knobColors.bg;
|
|
283
|
+
return knobColors.bgInactive;
|
|
364
284
|
};
|
|
365
285
|
const labelBlock = (label || description || showErrorLabel) && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: sizing.textGap, children: [
|
|
366
286
|
label && /* @__PURE__ */ jsx3(
|
|
@@ -376,6 +296,7 @@ var Switch = ({
|
|
|
376
296
|
description && /* @__PURE__ */ jsx3(
|
|
377
297
|
Text,
|
|
378
298
|
{
|
|
299
|
+
id: descriptionId,
|
|
379
300
|
color: theme.colors.content.tertiary,
|
|
380
301
|
fontSize: sizing.descriptionFontSize,
|
|
381
302
|
lineHeight: sizing.descriptionLineHeight,
|
|
@@ -385,6 +306,7 @@ var Switch = ({
|
|
|
385
306
|
showErrorLabel && /* @__PURE__ */ jsx3(
|
|
386
307
|
Text,
|
|
387
308
|
{
|
|
309
|
+
id: errorId,
|
|
388
310
|
color: theme.colors.content.alert.primary,
|
|
389
311
|
fontSize: sizing.descriptionFontSize,
|
|
390
312
|
lineHeight: sizing.descriptionLineHeight,
|
|
@@ -398,13 +320,16 @@ var Switch = ({
|
|
|
398
320
|
width: sizing.width,
|
|
399
321
|
height: sizing.height,
|
|
400
322
|
backgroundColor: getBgColor(),
|
|
323
|
+
borderColor: getBorderColor(),
|
|
324
|
+
borderWidth: 1,
|
|
401
325
|
borderRadius: sizing.frameBorderRadius,
|
|
402
|
-
padding:
|
|
326
|
+
padding: 1,
|
|
403
327
|
flexDirection: "row",
|
|
404
328
|
alignItems: "center",
|
|
405
329
|
justifyContent: checked ? "flex-end" : "flex-start",
|
|
406
330
|
hoverStyle: !isDisable && !isHover ? {
|
|
407
|
-
backgroundColor: checked ? checkColors.bgHover : switchColors.bgHover
|
|
331
|
+
backgroundColor: checked ? checkColors.bgHover : switchColors.bgHover,
|
|
332
|
+
borderColor: checked ? checkColors.borderHover : switchColors.borderHover
|
|
408
333
|
} : void 0,
|
|
409
334
|
children: /* @__PURE__ */ jsx3(
|
|
410
335
|
Box,
|
|
@@ -423,9 +348,11 @@ var Switch = ({
|
|
|
423
348
|
role: "switch",
|
|
424
349
|
"aria-checked": checked,
|
|
425
350
|
"aria-disabled": isDisable || void 0,
|
|
351
|
+
"aria-invalid": isError || void 0,
|
|
352
|
+
"aria-describedby": ariaDescribedBy,
|
|
426
353
|
"aria-label": ariaLabelledBy ? void 0 : ariaLabel || (label ? void 0 : "Switch"),
|
|
427
354
|
"aria-labelledby": ariaLabelledBy,
|
|
428
|
-
tabIndex:
|
|
355
|
+
tabIndex: 0,
|
|
429
356
|
flexDirection: "row",
|
|
430
357
|
alignItems: description || showErrorLabel ? "flex-start" : "center",
|
|
431
358
|
gap: sizing.labelGap,
|
package/web/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../primitives-web/src/Box.tsx","../../../primitives-web/src/filterDOMProps.ts","../../../primitives-web/src/Text.tsx","../../src/Switch.tsx"],"sourcesContent":["import React from \"react\";\nimport styled from \"styled-components\";\nimport type { BoxProps } from \"@xsolla/xui-primitives-core\";\nimport { createFilteredElement } from \"./filterDOMProps\";\n\nconst FilteredDiv = createFilteredElement(\"div\");\n\nconst StyledBox = styled(FilteredDiv)<BoxProps>`\n display: flex;\n box-sizing: border-box;\n background-color: ${(props) => props.backgroundColor || \"transparent\"};\n border-color: ${(props) => props.borderColor || \"transparent\"};\n border-width: ${(props) =>\n typeof props.borderWidth === \"number\"\n ? `${props.borderWidth}px`\n : props.borderWidth || 0};\n\n ${(props) =>\n props.borderBottomWidth !== undefined &&\n `\n border-bottom-width: ${typeof props.borderBottomWidth === \"number\" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};\n border-bottom-color: ${props.borderBottomColor || props.borderColor || \"transparent\"};\n border-bottom-style: solid;\n `}\n ${(props) =>\n props.borderTopWidth !== undefined &&\n `\n border-top-width: ${typeof props.borderTopWidth === \"number\" ? `${props.borderTopWidth}px` : props.borderTopWidth};\n border-top-color: ${props.borderTopColor || props.borderColor || \"transparent\"};\n border-top-style: solid;\n `}\n ${(props) =>\n props.borderLeftWidth !== undefined &&\n `\n border-left-width: ${typeof props.borderLeftWidth === \"number\" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};\n border-left-color: ${props.borderLeftColor || props.borderColor || \"transparent\"};\n border-left-style: solid;\n `}\n ${(props) =>\n props.borderRightWidth !== undefined &&\n `\n border-right-width: ${typeof props.borderRightWidth === \"number\" ? `${props.borderRightWidth}px` : props.borderRightWidth};\n border-right-color: ${props.borderRightColor || props.borderColor || \"transparent\"};\n border-right-style: solid;\n `}\n\n border-style: ${(props) =>\n props.borderStyle ||\n (props.borderWidth ||\n props.borderBottomWidth ||\n props.borderTopWidth ||\n props.borderLeftWidth ||\n props.borderRightWidth\n ? \"solid\"\n : \"none\")};\n border-radius: ${(props) =>\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius || 0};\n height: ${(props) =>\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height || \"auto\"};\n width: ${(props) =>\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width || \"auto\"};\n min-width: ${(props) =>\n typeof props.minWidth === \"number\"\n ? `${props.minWidth}px`\n : props.minWidth || \"auto\"};\n min-height: ${(props) =>\n typeof props.minHeight === \"number\"\n ? `${props.minHeight}px`\n : props.minHeight || \"auto\"};\n max-width: ${(props) =>\n typeof props.maxWidth === \"number\"\n ? `${props.maxWidth}px`\n : props.maxWidth || \"none\"};\n max-height: ${(props) =>\n typeof props.maxHeight === \"number\"\n ? `${props.maxHeight}px`\n : props.maxHeight || \"none\"};\n\n padding: ${(props) =>\n typeof props.padding === \"number\"\n ? `${props.padding}px`\n : props.padding || 0};\n ${(props) =>\n props.paddingHorizontal &&\n `\n padding-left: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n padding-right: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n `}\n ${(props) =>\n props.paddingVertical &&\n `\n padding-top: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n padding-bottom: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n `}\n ${(props) =>\n props.paddingTop !== undefined &&\n `padding-top: ${typeof props.paddingTop === \"number\" ? `${props.paddingTop}px` : props.paddingTop};`}\n ${(props) =>\n props.paddingBottom !== undefined &&\n `padding-bottom: ${typeof props.paddingBottom === \"number\" ? `${props.paddingBottom}px` : props.paddingBottom};`}\n ${(props) =>\n props.paddingLeft !== undefined &&\n `padding-left: ${typeof props.paddingLeft === \"number\" ? `${props.paddingLeft}px` : props.paddingLeft};`}\n ${(props) =>\n props.paddingRight !== undefined &&\n `padding-right: ${typeof props.paddingRight === \"number\" ? `${props.paddingRight}px` : props.paddingRight};`}\n\n margin: ${(props) =>\n typeof props.margin === \"number\" ? `${props.margin}px` : props.margin || 0};\n ${(props) =>\n props.marginTop !== undefined &&\n `margin-top: ${typeof props.marginTop === \"number\" ? `${props.marginTop}px` : props.marginTop};`}\n ${(props) =>\n props.marginBottom !== undefined &&\n `margin-bottom: ${typeof props.marginBottom === \"number\" ? `${props.marginBottom}px` : props.marginBottom};`}\n ${(props) =>\n props.marginLeft !== undefined &&\n `margin-left: ${typeof props.marginLeft === \"number\" ? `${props.marginLeft}px` : props.marginLeft};`}\n ${(props) =>\n props.marginRight !== undefined &&\n `margin-right: ${typeof props.marginRight === \"number\" ? `${props.marginRight}px` : props.marginRight};`}\n\n flex-direction: ${(props) => props.flexDirection || \"column\"};\n flex-wrap: ${(props) => props.flexWrap || \"nowrap\"};\n align-items: ${(props) => props.alignItems || \"stretch\"};\n justify-content: ${(props) => props.justifyContent || \"flex-start\"};\n cursor: ${(props) =>\n props.cursor\n ? props.cursor\n : props.onClick || props.onPress\n ? \"pointer\"\n : \"inherit\"};\n position: ${(props) => props.position || \"static\"};\n top: ${(props) =>\n typeof props.top === \"number\" ? `${props.top}px` : props.top};\n bottom: ${(props) =>\n typeof props.bottom === \"number\" ? `${props.bottom}px` : props.bottom};\n left: ${(props) =>\n typeof props.left === \"number\" ? `${props.left}px` : props.left};\n right: ${(props) =>\n typeof props.right === \"number\" ? `${props.right}px` : props.right};\n flex: ${(props) => props.flex};\n flex-shrink: ${(props) => props.flexShrink ?? 1};\n gap: ${(props) =>\n typeof props.gap === \"number\" ? `${props.gap}px` : props.gap || 0};\n align-self: ${(props) => props.alignSelf || \"auto\"};\n overflow: ${(props) => props.overflow || \"visible\"};\n overflow-x: ${(props) => props.overflowX || \"visible\"};\n overflow-y: ${(props) => props.overflowY || \"visible\"};\n z-index: ${(props) => props.zIndex};\n opacity: ${(props) => (props.disabled ? 0.5 : 1)};\n pointer-events: ${(props) => (props.disabled ? \"none\" : \"auto\")};\n\n &:hover {\n ${(props) =>\n props.hoverStyle?.backgroundColor &&\n `background-color: ${props.hoverStyle.backgroundColor};`}\n ${(props) =>\n props.hoverStyle?.borderColor &&\n `border-color: ${props.hoverStyle.borderColor};`}\n }\n\n &:active {\n ${(props) =>\n props.pressStyle?.backgroundColor &&\n `background-color: ${props.pressStyle.backgroundColor};`}\n }\n`;\n\nexport const Box = React.forwardRef<\n HTMLDivElement | HTMLButtonElement,\n BoxProps\n>(\n (\n {\n children,\n onPress,\n onKeyDown,\n onKeyUp,\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-current\": ariaCurrent,\n \"aria-disabled\": ariaDisabled,\n \"aria-live\": ariaLive,\n \"aria-busy\": ariaBusy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-expanded\": ariaExpanded,\n \"aria-haspopup\": ariaHasPopup,\n \"aria-pressed\": ariaPressed,\n \"aria-controls\": ariaControls,\n tabIndex,\n as,\n src,\n alt,\n type,\n disabled,\n id,\n ...props\n },\n ref\n ) => {\n // Handle as=\"img\" for rendering images with proper border-radius\n if (as === \"img\" && src) {\n return (\n <img\n src={src}\n alt={alt || \"\"}\n style={{\n display: \"block\",\n objectFit: \"cover\",\n width:\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width,\n height:\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height,\n borderRadius:\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius,\n position: props.position,\n top: typeof props.top === \"number\" ? `${props.top}px` : props.top,\n left:\n typeof props.left === \"number\" ? `${props.left}px` : props.left,\n right:\n typeof props.right === \"number\"\n ? `${props.right}px`\n : props.right,\n bottom:\n typeof props.bottom === \"number\"\n ? `${props.bottom}px`\n : props.bottom,\n }}\n />\n );\n }\n\n return (\n <StyledBox\n ref={ref}\n elementType={as}\n id={id}\n type={as === \"button\" ? type || \"button\" : undefined}\n disabled={as === \"button\" ? disabled : undefined}\n onClick={onPress}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-current={ariaCurrent}\n aria-disabled={ariaDisabled}\n aria-busy={ariaBusy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-haspopup={ariaHasPopup}\n aria-pressed={ariaPressed}\n aria-controls={ariaControls}\n aria-live={ariaLive}\n tabIndex={tabIndex !== undefined ? tabIndex : undefined}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\n\n// Props from BoxProps, TextProps, SpinnerProps, IconProps, DividerProps\n// that are NOT valid HTML attributes and must not reach the DOM.\nexport const NON_HTML_PROPS = new Set([\n // BoxProps — layout & styling\n \"backgroundColor\",\n \"borderColor\",\n \"borderWidth\",\n \"borderBottomWidth\",\n \"borderBottomColor\",\n \"borderTopWidth\",\n \"borderTopColor\",\n \"borderLeftWidth\",\n \"borderLeftColor\",\n \"borderRightWidth\",\n \"borderRightColor\",\n \"borderRadius\",\n \"borderStyle\",\n \"flexDirection\",\n \"flexWrap\",\n \"alignItems\",\n \"justifyContent\",\n \"alignSelf\",\n \"flex\",\n \"flexShrink\",\n \"gap\",\n \"position\",\n \"top\",\n \"bottom\",\n \"left\",\n \"right\",\n \"outline\",\n \"overflow\",\n \"overflowX\",\n \"overflowY\",\n \"zIndex\",\n \"cursor\",\n \"padding\",\n \"paddingHorizontal\",\n \"paddingVertical\",\n \"paddingTop\",\n \"paddingBottom\",\n \"paddingLeft\",\n \"paddingRight\",\n \"margin\",\n \"marginTop\",\n \"marginBottom\",\n \"marginLeft\",\n \"marginRight\",\n \"minWidth\",\n \"minHeight\",\n \"maxWidth\",\n \"maxHeight\",\n \"hoverStyle\",\n \"pressStyle\",\n \"focusStyle\",\n \"outlineColor\",\n \"outlineWidth\",\n \"outlineOffset\",\n \"outlineStyle\",\n // BoxProps — RN-only\n \"onPress\",\n \"onLayout\",\n \"onMoveShouldSetResponder\",\n \"onResponderGrant\",\n \"onResponderMove\",\n \"onResponderRelease\",\n \"onResponderTerminate\",\n \"testID\",\n // Box — custom element type\n \"elementType\",\n // TextProps\n \"fontSize\",\n \"fontWeight\",\n \"fontFamily\",\n \"lineHeight\",\n \"whiteSpace\",\n \"textAlign\",\n \"textDecoration\",\n \"numberOfLines\",\n \"letterSpacing\",\n \"textTransform\",\n // SpinnerProps\n \"strokeWidth\",\n // DividerProps\n \"vertical\",\n \"dashStroke\",\n]);\n\n/**\n * Creates a React component that renders the given HTML tag\n * but filters out non-HTML props before they reach the DOM.\n *\n * Usage: `const FilteredDiv = createFilteredElement(\"div\");`\n * Then: `const StyledBox = styled(FilteredDiv)<BoxProps>\\`...\\`;`\n *\n * styled-components can still read ALL props for CSS interpolation,\n * but only valid HTML attributes are forwarded to the DOM element.\n */\nexport function createFilteredElement(defaultTag: string) {\n const Component = React.forwardRef<HTMLElement, any>(\n ({ children, elementType, ...props }, ref) => {\n const Tag = elementType || defaultTag;\n const htmlProps: Record<string, unknown> = {};\n for (const key of Object.keys(props)) {\n if (!NON_HTML_PROPS.has(key)) {\n htmlProps[key] = props[key];\n }\n }\n return React.createElement(Tag, { ref, ...htmlProps }, children);\n }\n );\n Component.displayName = `Filtered(${defaultTag})`;\n return Component;\n}\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\nimport { createFilteredElement } from \"./filterDOMProps\";\n\nconst FilteredSpan = createFilteredElement(\"span\");\n\nconst StyledText = styled(FilteredSpan)<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Aktiv Grotesk\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n numberOfLines: _numberOfLines,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n","import React from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport { useResolvedTheme, type ThemeOverrideProps } from \"@xsolla/xui-core\";\n\nexport interface SwitchProps extends ThemeOverrideProps {\n /** Size of the switch */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n /** Whether the switch is checked */\n checked?: boolean;\n /** Visual state of the switch */\n state?: \"default\" | \"hover\" | \"disable\" | \"error\";\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch */\n labelPosition?: \"left\" | \"right\";\n /** Description text to display below the label */\n description?: string;\n /** Error label text to display when state is 'error' */\n errorLabel?: string;\n /** Callback when the switch value changes */\n onValueChange?: (value: boolean) => void;\n /** Accessible label for screen readers */\n ariaLabel?: string;\n /** ID of the element that labels this switch */\n ariaLabelledBy?: string;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({\n size = \"md\",\n checked = false,\n state = \"default\",\n disabled = false,\n label,\n labelPosition = \"right\",\n description,\n errorLabel,\n onValueChange,\n ariaLabel,\n ariaLabelledBy,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n\n const isDisable = state === \"disable\" || disabled;\n const isError = state === \"error\";\n const isHover = state === \"hover\";\n const showErrorLabel = isError && errorLabel;\n\n // Resolve Sizing\n const sizing = theme.sizing.switch(size);\n\n // Resolve Colors from Theme\n const switchColors = theme.colors.control.switch;\n const checkColors = theme.colors.control.check;\n const textColors = theme.colors.control.text;\n\n const handlePress = () => {\n if (!isDisable && onValueChange) {\n onValueChange(!checked);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!isDisable && (event.key === \" \" || event.key === \"Enter\")) {\n event.preventDefault();\n handlePress();\n }\n };\n\n const getBgColor = () => {\n if (isDisable) return switchColors.bg;\n if (checked && isHover) return checkColors.bgHover;\n if (checked) return checkColors.bg;\n if (isHover) return switchColors.bgHover;\n return switchColors.bg;\n };\n\n const getTextColor = () => {\n if (isDisable) return textColors.disable;\n return textColors.primary;\n };\n\n const getKnobColor = () => {\n return theme.colors.content.static.light;\n };\n\n const labelBlock = (label || description || showErrorLabel) && (\n <Box flexDirection=\"column\" gap={sizing.textGap}>\n {label && (\n <Text\n color={getTextColor()}\n fontSize={sizing.fontSize}\n lineHeight={sizing.lineHeight}\n fontWeight=\"400\"\n >\n {label}\n </Text>\n )}\n {description && (\n <Text\n color={theme.colors.content.tertiary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {description}\n </Text>\n )}\n {showErrorLabel && (\n <Text\n color={theme.colors.content.alert.primary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {errorLabel}\n </Text>\n )}\n </Box>\n );\n\n const toggle = (\n <Box\n width={sizing.width}\n height={sizing.height}\n backgroundColor={getBgColor()}\n borderRadius={sizing.frameBorderRadius}\n padding={2}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent={checked ? \"flex-end\" : \"flex-start\"}\n hoverStyle={\n !isDisable && !isHover\n ? {\n backgroundColor: checked\n ? checkColors.bgHover\n : switchColors.bgHover,\n }\n : undefined\n }\n >\n <Box\n width={sizing.knobSize}\n height={sizing.knobSize}\n backgroundColor={getKnobColor()}\n borderRadius={sizing.knobBorderRadius}\n />\n </Box>\n );\n\n return (\n <Box\n role=\"switch\"\n aria-checked={checked}\n aria-disabled={isDisable || undefined}\n aria-label={\n ariaLabelledBy ? undefined : ariaLabel || (label ? undefined : \"Switch\")\n }\n aria-labelledby={ariaLabelledBy}\n tabIndex={isDisable ? -1 : 0}\n flexDirection=\"row\"\n alignItems={description || showErrorLabel ? \"flex-start\" : \"center\"}\n gap={sizing.labelGap}\n onPress={handlePress}\n onKeyDown={handleKeyDown}\n cursor={!isDisable ? \"pointer\" : \"default\"}\n >\n {labelPosition === \"left\" && labelBlock}\n {toggle}\n {labelPosition === \"right\" && labelBlock}\n </Box>\n );\n};\n"],"mappings":";AAAA,OAAOA,YAAW;AAClB,OAAO,YAAY;;;ACDnB,OAAO,WAAW;AAIX,IAAM,iBAAiB,oBAAI,IAAI;AAAA;AAAA,EAEpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EACA;AACF,CAAC;AAYM,SAAS,sBAAsB,YAAoB;AACxD,QAAM,YAAY,MAAM;AAAA,IACtB,CAAC,EAAE,UAAU,aAAa,GAAG,MAAM,GAAG,QAAQ;AAC5C,YAAM,MAAM,eAAe;AAC3B,YAAM,YAAqC,CAAC;AAC5C,iBAAW,OAAO,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U,YAAY,KAAK;AAAA,MAC3B,eAAc;AAAA,MACd,YAAY,eAAe,iBAAiB,eAAe;AAAA,MAC3D,KAAK,OAAO;AAAA,MACZ,SAAS;AAAA,MACT,WAAW;AAAA,MACX,QAAQ,CAAC,YAAY,YAAY;AAAA,MAEhC;AAAA,0BAAkB,UAAU;AAAA,QAC5B;AAAA,QACA,kBAAkB,WAAW;AAAA;AAAA;AAAA,EAChC;AAEJ;","names":["React","React","styled","jsx","styled","jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../../primitives-web/src/Box.tsx","../../../primitives-web/src/Text.tsx","../../src/Switch.tsx"],"sourcesContent":["import React from \"react\";\nimport styled from \"styled-components\";\nimport type { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledBox = styled.div<BoxProps>`\n display: flex;\n box-sizing: border-box;\n background-color: ${(props) => props.backgroundColor || \"transparent\"};\n border-color: ${(props) => props.borderColor || \"transparent\"};\n border-width: ${(props) =>\n typeof props.borderWidth === \"number\"\n ? `${props.borderWidth}px`\n : props.borderWidth || 0};\n\n ${(props) =>\n props.borderBottomWidth !== undefined &&\n `\n border-bottom-width: ${typeof props.borderBottomWidth === \"number\" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};\n border-bottom-color: ${props.borderBottomColor || props.borderColor || \"transparent\"};\n border-bottom-style: solid;\n `}\n ${(props) =>\n props.borderTopWidth !== undefined &&\n `\n border-top-width: ${typeof props.borderTopWidth === \"number\" ? `${props.borderTopWidth}px` : props.borderTopWidth};\n border-top-color: ${props.borderTopColor || props.borderColor || \"transparent\"};\n border-top-style: solid;\n `}\n ${(props) =>\n props.borderLeftWidth !== undefined &&\n `\n border-left-width: ${typeof props.borderLeftWidth === \"number\" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};\n border-left-color: ${props.borderLeftColor || props.borderColor || \"transparent\"};\n border-left-style: solid;\n `}\n ${(props) =>\n props.borderRightWidth !== undefined &&\n `\n border-right-width: ${typeof props.borderRightWidth === \"number\" ? `${props.borderRightWidth}px` : props.borderRightWidth};\n border-right-color: ${props.borderRightColor || props.borderColor || \"transparent\"};\n border-right-style: solid;\n `}\n\n border-style: ${(props) =>\n props.borderStyle ||\n (props.borderWidth ||\n props.borderBottomWidth ||\n props.borderTopWidth ||\n props.borderLeftWidth ||\n props.borderRightWidth\n ? \"solid\"\n : \"none\")};\n border-radius: ${(props) =>\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius || 0};\n height: ${(props) =>\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height || \"auto\"};\n width: ${(props) =>\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width || \"auto\"};\n min-width: ${(props) =>\n typeof props.minWidth === \"number\"\n ? `${props.minWidth}px`\n : props.minWidth || \"auto\"};\n min-height: ${(props) =>\n typeof props.minHeight === \"number\"\n ? `${props.minHeight}px`\n : props.minHeight || \"auto\"};\n max-width: ${(props) =>\n typeof props.maxWidth === \"number\"\n ? `${props.maxWidth}px`\n : props.maxWidth || \"none\"};\n max-height: ${(props) =>\n typeof props.maxHeight === \"number\"\n ? `${props.maxHeight}px`\n : props.maxHeight || \"none\"};\n\n padding: ${(props) =>\n typeof props.padding === \"number\"\n ? `${props.padding}px`\n : props.padding || 0};\n ${(props) =>\n props.paddingHorizontal &&\n `\n padding-left: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n padding-right: ${typeof props.paddingHorizontal === \"number\" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};\n `}\n ${(props) =>\n props.paddingVertical &&\n `\n padding-top: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n padding-bottom: ${typeof props.paddingVertical === \"number\" ? `${props.paddingVertical}px` : props.paddingVertical};\n `}\n ${(props) =>\n props.paddingTop !== undefined &&\n `padding-top: ${typeof props.paddingTop === \"number\" ? `${props.paddingTop}px` : props.paddingTop};`}\n ${(props) =>\n props.paddingBottom !== undefined &&\n `padding-bottom: ${typeof props.paddingBottom === \"number\" ? `${props.paddingBottom}px` : props.paddingBottom};`}\n ${(props) =>\n props.paddingLeft !== undefined &&\n `padding-left: ${typeof props.paddingLeft === \"number\" ? `${props.paddingLeft}px` : props.paddingLeft};`}\n ${(props) =>\n props.paddingRight !== undefined &&\n `padding-right: ${typeof props.paddingRight === \"number\" ? `${props.paddingRight}px` : props.paddingRight};`}\n\n margin: ${(props) =>\n typeof props.margin === \"number\" ? `${props.margin}px` : props.margin || 0};\n ${(props) =>\n props.marginTop !== undefined &&\n `margin-top: ${typeof props.marginTop === \"number\" ? `${props.marginTop}px` : props.marginTop};`}\n ${(props) =>\n props.marginBottom !== undefined &&\n `margin-bottom: ${typeof props.marginBottom === \"number\" ? `${props.marginBottom}px` : props.marginBottom};`}\n ${(props) =>\n props.marginLeft !== undefined &&\n `margin-left: ${typeof props.marginLeft === \"number\" ? `${props.marginLeft}px` : props.marginLeft};`}\n ${(props) =>\n props.marginRight !== undefined &&\n `margin-right: ${typeof props.marginRight === \"number\" ? `${props.marginRight}px` : props.marginRight};`}\n\n flex-direction: ${(props) => props.flexDirection || \"column\"};\n flex-wrap: ${(props) => props.flexWrap || \"nowrap\"};\n align-items: ${(props) => props.alignItems || \"stretch\"};\n justify-content: ${(props) => props.justifyContent || \"flex-start\"};\n cursor: ${(props) =>\n props.cursor\n ? props.cursor\n : props.onClick || props.onPress\n ? \"pointer\"\n : \"inherit\"};\n position: ${(props) => props.position || \"static\"};\n top: ${(props) =>\n typeof props.top === \"number\" ? `${props.top}px` : props.top};\n bottom: ${(props) =>\n typeof props.bottom === \"number\" ? `${props.bottom}px` : props.bottom};\n left: ${(props) =>\n typeof props.left === \"number\" ? `${props.left}px` : props.left};\n right: ${(props) =>\n typeof props.right === \"number\" ? `${props.right}px` : props.right};\n flex: ${(props) => props.flex};\n flex-shrink: ${(props) => props.flexShrink ?? 1};\n gap: ${(props) =>\n typeof props.gap === \"number\" ? `${props.gap}px` : props.gap || 0};\n align-self: ${(props) => props.alignSelf || \"auto\"};\n overflow: ${(props) => props.overflow || \"visible\"};\n overflow-x: ${(props) => props.overflowX || \"visible\"};\n overflow-y: ${(props) => props.overflowY || \"visible\"};\n z-index: ${(props) => props.zIndex};\n opacity: ${(props) => (props.disabled ? 0.5 : 1)};\n pointer-events: ${(props) => (props.disabled ? \"none\" : \"auto\")};\n\n &:hover {\n ${(props) =>\n props.hoverStyle?.backgroundColor &&\n `background-color: ${props.hoverStyle.backgroundColor};`}\n ${(props) =>\n props.hoverStyle?.borderColor &&\n `border-color: ${props.hoverStyle.borderColor};`}\n }\n\n &:active {\n ${(props) =>\n props.pressStyle?.backgroundColor &&\n `background-color: ${props.pressStyle.backgroundColor};`}\n }\n`;\n\nexport const Box = React.forwardRef<\n HTMLDivElement | HTMLButtonElement,\n BoxProps\n>(\n (\n {\n children,\n onPress,\n onKeyDown,\n onKeyUp,\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-current\": ariaCurrent,\n \"aria-disabled\": ariaDisabled,\n \"aria-live\": ariaLive,\n \"aria-busy\": ariaBusy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-expanded\": ariaExpanded,\n \"aria-haspopup\": ariaHasPopup,\n \"aria-pressed\": ariaPressed,\n \"aria-controls\": ariaControls,\n tabIndex,\n as,\n src,\n alt,\n type,\n disabled,\n id,\n ...props\n },\n ref\n ) => {\n // Handle as=\"img\" for rendering images with proper border-radius\n if (as === \"img\" && src) {\n return (\n <img\n src={src}\n alt={alt || \"\"}\n style={{\n display: \"block\",\n objectFit: \"cover\",\n width:\n typeof props.width === \"number\"\n ? `${props.width}px`\n : props.width,\n height:\n typeof props.height === \"number\"\n ? `${props.height}px`\n : props.height,\n borderRadius:\n typeof props.borderRadius === \"number\"\n ? `${props.borderRadius}px`\n : props.borderRadius,\n position: props.position,\n top: typeof props.top === \"number\" ? `${props.top}px` : props.top,\n left:\n typeof props.left === \"number\" ? `${props.left}px` : props.left,\n right:\n typeof props.right === \"number\"\n ? `${props.right}px`\n : props.right,\n bottom:\n typeof props.bottom === \"number\"\n ? `${props.bottom}px`\n : props.bottom,\n }}\n />\n );\n }\n\n return (\n <StyledBox\n ref={ref}\n as={as}\n id={id}\n type={as === \"button\" ? type || \"button\" : undefined}\n disabled={as === \"button\" ? disabled : undefined}\n onClick={onPress}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-current={ariaCurrent}\n aria-disabled={ariaDisabled}\n aria-busy={ariaBusy}\n aria-describedby={ariaDescribedBy}\n aria-expanded={ariaExpanded}\n aria-haspopup={ariaHasPopup}\n aria-pressed={ariaPressed}\n aria-controls={ariaControls}\n aria-live={ariaLive}\n tabIndex={tabIndex !== undefined ? tabIndex : undefined}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledText = styled.span<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Aktiv Grotesk\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n numberOfLines: _numberOfLines,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n","import React from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text } from \"@xsolla/xui-primitives\";\nimport {\n useResolvedTheme,\n useId,\n type ThemeOverrideProps,\n} from \"@xsolla/xui-core\";\n\nexport interface SwitchProps extends ThemeOverrideProps {\n /** Size of the switch */\n size?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n /** Whether the switch is checked */\n checked?: boolean;\n /** Visual state of the switch */\n state?: \"default\" | \"hover\" | \"disable\" | \"error\";\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Label text to display next to the switch */\n label?: string;\n /** Position of the label relative to the switch */\n labelPosition?: \"left\" | \"right\";\n /** Description text to display below the label */\n description?: string;\n /** Error label text to display when state is 'error' */\n errorLabel?: string;\n /** Callback when the switch value changes */\n onValueChange?: (value: boolean) => void;\n /** Accessible label for screen readers */\n ariaLabel?: string;\n /** ID of the element that labels this switch */\n ariaLabelledBy?: string;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({\n size = \"md\",\n checked = false,\n state = \"default\",\n disabled = false,\n label,\n labelPosition = \"right\",\n description,\n errorLabel,\n onValueChange,\n ariaLabel,\n ariaLabelledBy,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n\n const isDisable = state === \"disable\" || disabled;\n const isError = state === \"error\";\n const isHover = state === \"hover\";\n const showErrorLabel = isError && errorLabel;\n\n const rawId = useId();\n const safeId = rawId.replace(/:/g, \"\");\n const descriptionId = `switch-desc-${safeId}`;\n const errorId = `switch-error-${safeId}`;\n\n const ariaDescribedByParts: string[] = [];\n if (description) ariaDescribedByParts.push(descriptionId);\n if (showErrorLabel) ariaDescribedByParts.push(errorId);\n const ariaDescribedBy =\n ariaDescribedByParts.length > 0\n ? ariaDescribedByParts.join(\" \")\n : undefined;\n\n const sizing = theme.sizing.switch(size);\n\n const switchColors = theme.colors.control.switch;\n const checkColors = theme.colors.control.check;\n const knobColors = theme.colors.control.knob;\n const textColors = theme.colors.control.text;\n const borderColors = theme.colors.border;\n\n const handlePress = () => {\n if (!isDisable && onValueChange) {\n onValueChange(!checked);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!isDisable && (event.key === \" \" || event.key === \"Enter\")) {\n event.preventDefault();\n handlePress();\n }\n };\n\n const getBgColor = () => {\n if (isDisable) {\n return checked ? checkColors.bgDisable : switchColors.bgDisable;\n }\n if (checked && isHover) return checkColors.bgHover;\n if (checked) return checkColors.bg;\n if (isHover) return switchColors.bgHover;\n return switchColors.bg;\n };\n\n const getBorderColor = () => {\n if (isError) return borderColors.alert;\n if (isDisable) {\n return checked ? checkColors.borderDisable : switchColors.borderDisable;\n }\n if (checked && isHover) return checkColors.borderHover;\n if (checked) return checkColors.border;\n if (isHover) return switchColors.borderHover;\n return switchColors.border;\n };\n\n const getTextColor = () => {\n if (isDisable) return textColors.disable;\n return textColors.primary;\n };\n\n const getKnobColor = () => {\n if (isDisable) return knobColors.bgInactive;\n if (checked && isHover) return knobColors.bgHover;\n if (checked) return knobColors.bg;\n return knobColors.bgInactive;\n };\n\n const labelBlock = (label || description || showErrorLabel) && (\n <Box flexDirection=\"column\" gap={sizing.textGap}>\n {label && (\n <Text\n color={getTextColor()}\n fontSize={sizing.fontSize}\n lineHeight={sizing.lineHeight}\n fontWeight=\"400\"\n >\n {label}\n </Text>\n )}\n {description && (\n <Text\n id={descriptionId}\n color={theme.colors.content.tertiary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {description}\n </Text>\n )}\n {showErrorLabel && (\n <Text\n id={errorId}\n color={theme.colors.content.alert.primary}\n fontSize={sizing.descriptionFontSize}\n lineHeight={sizing.descriptionLineHeight}\n >\n {errorLabel}\n </Text>\n )}\n </Box>\n );\n\n const toggle = (\n <Box\n width={sizing.width}\n height={sizing.height}\n backgroundColor={getBgColor()}\n borderColor={getBorderColor()}\n borderWidth={1}\n borderRadius={sizing.frameBorderRadius}\n padding={1}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent={checked ? \"flex-end\" : \"flex-start\"}\n hoverStyle={\n !isDisable && !isHover\n ? {\n backgroundColor: checked\n ? checkColors.bgHover\n : switchColors.bgHover,\n borderColor: checked\n ? checkColors.borderHover\n : switchColors.borderHover,\n }\n : undefined\n }\n >\n <Box\n width={sizing.knobSize}\n height={sizing.knobSize}\n backgroundColor={getKnobColor()}\n borderRadius={sizing.knobBorderRadius}\n />\n </Box>\n );\n\n return (\n <Box\n role=\"switch\"\n aria-checked={checked}\n aria-disabled={isDisable || undefined}\n aria-invalid={isError || undefined}\n aria-describedby={ariaDescribedBy}\n aria-label={\n ariaLabelledBy ? undefined : ariaLabel || (label ? undefined : \"Switch\")\n }\n aria-labelledby={ariaLabelledBy}\n tabIndex={0}\n flexDirection=\"row\"\n alignItems={description || showErrorLabel ? \"flex-start\" : \"center\"}\n gap={sizing.labelGap}\n onPress={handlePress}\n onKeyDown={handleKeyDown}\n cursor={!isDisable ? \"pointer\" : \"default\"}\n >\n {labelPosition === \"left\" && labelBlock}\n {toggle}\n {labelPosition === \"right\" && labelBlock}\n </Box>\n );\n};\n"],"mappings":";AAAA,OAAO,WAAW;AAClB,OAAO,YAAY;AA+MX;AA5MR,IAAM,YAAY,OAAO;AAAA;AAAA;AAAA,sBAGH,CAAC,UAAU,MAAM,mBAAmB,aAAa;AAAA,kBACrD,CAAC,UAAU,MAAM,eAAe,aAAa;AAAA,kBAC7C,CAAC,UACf,OAAO,MAAM,gBAAgB,WACzB,GAAG,MAAM,WAAW,OACpB,MAAM,eAAe,CAAC;AAAA;AAAA,IAE1B,CAAC,UACD,MAAM,sBAAsB,UAC5B;AAAA,2BACuB,OAAO,MAAM,sBAAsB,WAAW,GAAG,MAAM,iBAAiB,OAAO,MAAM,iBAAiB;AAAA,2BACtG,MAAM,qBAAqB,MAAM,eAAe,aAAa;AAAA;AAAA,GAErF;AAAA,IACC,CAAC,UACD,MAAM,mBAAmB,UACzB;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