@xsolla/xui-switch 0.141.0 → 0.141.1
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 +2 -2
- package/native/index.js.map +1 -1
- package/native/index.mjs +2 -2
- package/native/index.mjs.map +1 -1
- package/package.json +3 -3
- package/web/index.js +7 -7
- package/web/index.js.map +1 -1
- package/web/index.mjs +7 -7
- package/web/index.mjs.map +1 -1
- package/README.md +0 -257
package/native/index.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// ../../foundation/primitives-native/src/Box.tsx
|
|
28
28
|
var import_react_native = require("react-native");
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
var Box = ({
|
|
@@ -198,7 +198,7 @@ var Box = ({
|
|
|
198
198
|
);
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
-
//
|
|
201
|
+
// ../../foundation/primitives-native/src/Text.tsx
|
|
202
202
|
var import_react_native2 = require("react-native");
|
|
203
203
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
204
204
|
var roleMap = {
|
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 {\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,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,i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AAY;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","../../../../foundation/primitives-native/src/Box.tsx","../../../../foundation/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,EACA;AAAA,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,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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// ../../foundation/primitives-native/src/Box.tsx
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
4
|
Pressable,
|
|
@@ -176,7 +176,7 @@ var Box = ({
|
|
|
176
176
|
);
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
-
//
|
|
179
|
+
// ../../foundation/primitives-native/src/Text.tsx
|
|
180
180
|
import {
|
|
181
181
|
Text as RNText,
|
|
182
182
|
StyleSheet
|
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 {\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,E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AAK;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":["jsx","jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../../../foundation/primitives-native/src/Box.tsx","../../../../foundation/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,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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA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AAAA,IAAC;AAAA;AAAA,MACC,OAAO,OAAO;AAAA,MACd,QAAQ,OAAO;AAAA,MACf,iBAAiB,WAAW;AAAA,MAC5B,aAAa,eAAe;AAAA,MAC5B,aAAa;AAAA,MACb,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,QACjB,aAAa,UACT,YAAY,cACZ,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,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":["jsx","jsx"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-switch",
|
|
3
|
-
"version": "0.141.
|
|
3
|
+
"version": "0.141.1",
|
|
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.141.
|
|
17
|
-
"@xsolla/xui-primitives-core": "0.141.
|
|
16
|
+
"@xsolla/xui-core": "0.141.1",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.141.1"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=16.8.0",
|
package/web/index.js
CHANGED
|
@@ -34,14 +34,14 @@ __export(index_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
|
-
//
|
|
37
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
38
38
|
var import_react2 = __toESM(require("react"));
|
|
39
39
|
var import_styled_components = __toESM(require("styled-components"));
|
|
40
40
|
|
|
41
|
-
//
|
|
41
|
+
// ../../foundation/primitives-web/src/filterDOMProps.ts
|
|
42
42
|
var import_react = __toESM(require("react"));
|
|
43
43
|
|
|
44
|
-
//
|
|
44
|
+
// ../../../node_modules/@emotion/memoize/dist/memoize.esm.js
|
|
45
45
|
function memoize(fn) {
|
|
46
46
|
var cache = {};
|
|
47
47
|
return function(arg) {
|
|
@@ -51,7 +51,7 @@ function memoize(fn) {
|
|
|
51
51
|
}
|
|
52
52
|
var memoize_esm_default = memoize;
|
|
53
53
|
|
|
54
|
-
//
|
|
54
|
+
// ../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
|
|
55
55
|
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
|
|
56
56
|
var index = memoize_esm_default(
|
|
57
57
|
function(prop) {
|
|
@@ -61,7 +61,7 @@ var index = memoize_esm_default(
|
|
|
61
61
|
);
|
|
62
62
|
var is_prop_valid_esm_default = index;
|
|
63
63
|
|
|
64
|
-
//
|
|
64
|
+
// ../../foundation/primitives-web/src/filterDOMProps.ts
|
|
65
65
|
var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
66
66
|
// RN-only event handlers (pass isPropValid's on* pattern)
|
|
67
67
|
"onPress",
|
|
@@ -107,7 +107,7 @@ function createFilteredElement(defaultTag) {
|
|
|
107
107
|
return Component;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
//
|
|
110
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
111
111
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
112
112
|
var FilteredDiv = createFilteredElement("div");
|
|
113
113
|
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
@@ -280,7 +280,7 @@ var Box = import_react2.default.forwardRef(
|
|
|
280
280
|
);
|
|
281
281
|
Box.displayName = "Box";
|
|
282
282
|
|
|
283
|
-
//
|
|
283
|
+
// ../../foundation/primitives-web/src/Text.tsx
|
|
284
284
|
var import_styled_components2 = __toESM(require("styled-components"));
|
|
285
285
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
286
286
|
var FilteredSpan = createFilteredElement("span");
|
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","../../../../node_modules/@emotion/memoize/dist/memoize.esm.js","../../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js","../../../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 testID,\n \"data-testid\": dataTestId,\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 data-testid={dataTestId || testID}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\nimport isPropValid from \"@emotion/is-prop-valid\";\n\n// Props that @emotion/is-prop-valid incorrectly treats as valid HTML.\n// These are React Native or component-specific props that match\n// valid HTML patterns (on* event handlers, SVG attributes).\nexport const ADDITIONAL_BLOCKED_PROPS = new Set([\n // RN-only event handlers (pass isPropValid's on* pattern)\n \"onPress\",\n \"onChangeText\",\n \"onLayout\",\n \"onMoveShouldSetResponder\",\n \"onResponderGrant\",\n \"onResponderMove\",\n \"onResponderRelease\",\n \"onResponderTerminate\",\n // SVG attributes that pass isPropValid\n \"strokeWidth\",\n // CSS properties that pass isPropValid but are used as component props\n \"overflow\",\n \"cursor\",\n \"fontSize\",\n \"fontWeight\",\n \"fontFamily\",\n \"textDecoration\",\n]);\n\nfunction shouldForwardProp(key: string): boolean {\n if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;\n return isPropValid(key);\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 * Uses @emotion/is-prop-valid (same library styled-components v4\n * uses internally) to automatically block invalid HTML attributes,\n * plus a small blocklist for false positives (RN on* handlers, SVG attrs).\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, Record<string, unknown>>(\n ({ children, elementType, ...props }, ref) => {\n const Tag = (elementType as string) || defaultTag;\n const htmlProps: Record<string, unknown> = {};\n for (const key of Object.keys(props)) {\n if (shouldForwardProp(key)) {\n htmlProps[key] = props[key];\n }\n }\n return React.createElement(\n Tag,\n { ref, ...htmlProps },\n children as React.ReactNode\n );\n }\n );\n Component.displayName = `Filtered(${defaultTag})`;\n return Component;\n}\n","function memoize(fn) {\n var cache = {};\n return function (arg) {\n if (cache[arg] === undefined) cache[arg] = fn(arg);\n return cache[arg];\n };\n}\n\nexport default memoize;\n","import memoize from '@emotion/memoize';\n\nvar reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23\n\nvar index = memoize(function (prop) {\n return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111\n /* o */\n && prop.charCodeAt(1) === 110\n /* n */\n && prop.charCodeAt(2) < 91;\n}\n/* Z+1 */\n);\n\nexport default index;\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 {\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,IAAAA,gBAAkB;AAClB,+BAAmB;;;ACDnB,mBAAkB;;;ACAlB,SAAS,QAAQ,IAAI;AACnB,MAAI,QAAQ,CAAC;AACb,SAAO,SAAU,KAAK;AACpB,QAAI,MAAM,GAAG,MAAM,OAAW,OAAM,GAAG,IAAI,GAAG,GAAG;AACjD,WAAO,MAAM,GAAG;AAAA,EAClB;AACF;AAEA,IAAO,sBAAQ;;;ACNf,IAAI,kBAAkB;AAEtB,IAAI,QAAQ;AAAA,EAAQ,SAAU,MAAM;AAClC,WAAO,gBAAgB,KAAK,IAAI,KAAK,KAAK,WAAW,CAAC,MAAM,OAEzD,KAAK,WAAW,CAAC,MAAM,OAEvB,KAAK,WAAW,CAAC,IAAI;AAAA,EAC1B;AAAA;AAEA;AAEA,IAAO,4BAAQ;;;AFRR,IAAM,2BAA2B,oBAAI,IAAI;AAAA;AAAA,EAE9C;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;AACF,CAAC;AAED,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;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","React","styled","React","import_styled_components","import_jsx_runtime","styled","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.tsx","../../../../foundation/primitives-web/src/Box.tsx","../../../../foundation/primitives-web/src/filterDOMProps.ts","../../../../../node_modules/@emotion/memoize/dist/memoize.esm.js","../../../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js","../../../../foundation/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 testID,\n \"data-testid\": dataTestId,\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 data-testid={dataTestId || testID}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\nimport isPropValid from \"@emotion/is-prop-valid\";\n\n// Props that @emotion/is-prop-valid incorrectly treats as valid HTML.\n// These are React Native or component-specific props that match\n// valid HTML patterns (on* event handlers, SVG attributes).\nexport const ADDITIONAL_BLOCKED_PROPS = new Set([\n // RN-only event handlers (pass isPropValid's on* pattern)\n \"onPress\",\n \"onChangeText\",\n \"onLayout\",\n \"onMoveShouldSetResponder\",\n \"onResponderGrant\",\n \"onResponderMove\",\n \"onResponderRelease\",\n \"onResponderTerminate\",\n // SVG attributes that pass isPropValid\n \"strokeWidth\",\n // CSS properties that pass isPropValid but are used as component props\n \"overflow\",\n \"cursor\",\n \"fontSize\",\n \"fontWeight\",\n \"fontFamily\",\n \"textDecoration\",\n]);\n\nfunction shouldForwardProp(key: string): boolean {\n if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;\n return isPropValid(key);\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 * Uses @emotion/is-prop-valid (same library styled-components v4\n * uses internally) to automatically block invalid HTML attributes,\n * plus a small blocklist for false positives (RN on* handlers, SVG attrs).\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, Record<string, unknown>>(\n ({ children, elementType, ...props }, ref) => {\n const Tag = (elementType as string) || defaultTag;\n const htmlProps: Record<string, unknown> = {};\n for (const key of Object.keys(props)) {\n if (shouldForwardProp(key)) {\n htmlProps[key] = props[key];\n }\n }\n return React.createElement(\n Tag,\n { ref, ...htmlProps },\n children as React.ReactNode\n );\n }\n );\n Component.displayName = `Filtered(${defaultTag})`;\n return Component;\n}\n","function memoize(fn) {\n var cache = {};\n return function (arg) {\n if (cache[arg] === undefined) cache[arg] = fn(arg);\n return cache[arg];\n };\n}\n\nexport default memoize;\n","import memoize from '@emotion/memoize';\n\nvar reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23\n\nvar index = memoize(function (prop) {\n return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111\n /* o */\n && prop.charCodeAt(1) === 110\n /* n */\n && prop.charCodeAt(2) < 91;\n}\n/* Z+1 */\n);\n\nexport default index;\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 {\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 >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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,aAAa,eAAe;AAAA,MAC5B,aAAa;AAAA,MACb,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,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","React","styled","React","import_styled_components","import_jsx_runtime","styled","import_jsx_runtime"]}
|
package/web/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
//
|
|
1
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
2
2
|
import React2 from "react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
|
|
5
|
-
//
|
|
5
|
+
// ../../foundation/primitives-web/src/filterDOMProps.ts
|
|
6
6
|
import React from "react";
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// ../../../node_modules/@emotion/memoize/dist/memoize.esm.js
|
|
9
9
|
function memoize(fn) {
|
|
10
10
|
var cache = {};
|
|
11
11
|
return function(arg) {
|
|
@@ -15,7 +15,7 @@ function memoize(fn) {
|
|
|
15
15
|
}
|
|
16
16
|
var memoize_esm_default = memoize;
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// ../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
|
|
19
19
|
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
|
|
20
20
|
var index = memoize_esm_default(
|
|
21
21
|
function(prop) {
|
|
@@ -25,7 +25,7 @@ var index = memoize_esm_default(
|
|
|
25
25
|
);
|
|
26
26
|
var is_prop_valid_esm_default = index;
|
|
27
27
|
|
|
28
|
-
//
|
|
28
|
+
// ../../foundation/primitives-web/src/filterDOMProps.ts
|
|
29
29
|
var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
30
30
|
// RN-only event handlers (pass isPropValid's on* pattern)
|
|
31
31
|
"onPress",
|
|
@@ -71,7 +71,7 @@ function createFilteredElement(defaultTag) {
|
|
|
71
71
|
return Component;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
//
|
|
74
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
75
75
|
import { jsx } from "react/jsx-runtime";
|
|
76
76
|
var FilteredDiv = createFilteredElement("div");
|
|
77
77
|
var StyledBox = styled(FilteredDiv)`
|
|
@@ -244,7 +244,7 @@ var Box = React2.forwardRef(
|
|
|
244
244
|
);
|
|
245
245
|
Box.displayName = "Box";
|
|
246
246
|
|
|
247
|
-
//
|
|
247
|
+
// ../../foundation/primitives-web/src/Text.tsx
|
|
248
248
|
import styled2 from "styled-components";
|
|
249
249
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
250
250
|
var FilteredSpan = createFilteredElement("span");
|
package/web/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../primitives-web/src/Box.tsx","../../../primitives-web/src/filterDOMProps.ts","../../../../node_modules/@emotion/memoize/dist/memoize.esm.js","../../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js","../../../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 testID,\n \"data-testid\": dataTestId,\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 data-testid={dataTestId || testID}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\nimport isPropValid from \"@emotion/is-prop-valid\";\n\n// Props that @emotion/is-prop-valid incorrectly treats as valid HTML.\n// These are React Native or component-specific props that match\n// valid HTML patterns (on* event handlers, SVG attributes).\nexport const ADDITIONAL_BLOCKED_PROPS = new Set([\n // RN-only event handlers (pass isPropValid's on* pattern)\n \"onPress\",\n \"onChangeText\",\n \"onLayout\",\n \"onMoveShouldSetResponder\",\n \"onResponderGrant\",\n \"onResponderMove\",\n \"onResponderRelease\",\n \"onResponderTerminate\",\n // SVG attributes that pass isPropValid\n \"strokeWidth\",\n // CSS properties that pass isPropValid but are used as component props\n \"overflow\",\n \"cursor\",\n \"fontSize\",\n \"fontWeight\",\n \"fontFamily\",\n \"textDecoration\",\n]);\n\nfunction shouldForwardProp(key: string): boolean {\n if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;\n return isPropValid(key);\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 * Uses @emotion/is-prop-valid (same library styled-components v4\n * uses internally) to automatically block invalid HTML attributes,\n * plus a small blocklist for false positives (RN on* handlers, SVG attrs).\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, Record<string, unknown>>(\n ({ children, elementType, ...props }, ref) => {\n const Tag = (elementType as string) || defaultTag;\n const htmlProps: Record<string, unknown> = {};\n for (const key of Object.keys(props)) {\n if (shouldForwardProp(key)) {\n htmlProps[key] = props[key];\n }\n }\n return React.createElement(\n Tag,\n { ref, ...htmlProps },\n children as React.ReactNode\n );\n }\n );\n Component.displayName = `Filtered(${defaultTag})`;\n return Component;\n}\n","function memoize(fn) {\n var cache = {};\n return function (arg) {\n if (cache[arg] === undefined) cache[arg] = fn(arg);\n return cache[arg];\n };\n}\n\nexport default memoize;\n","import memoize from '@emotion/memoize';\n\nvar reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23\n\nvar index = memoize(function (prop) {\n return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111\n /* o */\n && prop.charCodeAt(1) === 110\n /* n */\n && prop.charCodeAt(2) < 91;\n}\n/* Z+1 */\n);\n\nexport default index;\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 {\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,OAAOA,YAAW;AAClB,OAAO,YAAY;;;ACDnB,OAAO,WAAW;;;ACAlB,SAAS,QAAQ,IAAI;AACnB,MAAI,QAAQ,CAAC;AACb,SA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;AAAA,MAC5B,aAAa;AAAA,MACb,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,QACjB,aAAa,UACT,YAAY,cACZ,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,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":["React","React","styled","jsx","styled","jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../../../foundation/primitives-web/src/Box.tsx","../../../../foundation/primitives-web/src/filterDOMProps.ts","../../../../../node_modules/@emotion/memoize/dist/memoize.esm.js","../../../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js","../../../../foundation/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 testID,\n \"data-testid\": dataTestId,\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 data-testid={dataTestId || testID}\n {...props}\n >\n {children}\n </StyledBox>\n );\n }\n);\n\nBox.displayName = \"Box\";\n","import React from \"react\";\nimport isPropValid from \"@emotion/is-prop-valid\";\n\n// Props that @emotion/is-prop-valid incorrectly treats as valid HTML.\n// These are React Native or component-specific props that match\n// valid HTML patterns (on* event handlers, SVG attributes).\nexport const ADDITIONAL_BLOCKED_PROPS = new Set([\n // RN-only event handlers (pass isPropValid's on* pattern)\n \"onPress\",\n \"onChangeText\",\n \"onLayout\",\n \"onMoveShouldSetResponder\",\n \"onResponderGrant\",\n \"onResponderMove\",\n \"onResponderRelease\",\n \"onResponderTerminate\",\n // SVG attributes that pass isPropValid\n \"strokeWidth\",\n // CSS properties that pass isPropValid but are used as component props\n \"overflow\",\n \"cursor\",\n \"fontSize\",\n \"fontWeight\",\n \"fontFamily\",\n \"textDecoration\",\n]);\n\nfunction shouldForwardProp(key: string): boolean {\n if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;\n return isPropValid(key);\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 * Uses @emotion/is-prop-valid (same library styled-components v4\n * uses internally) to automatically block invalid HTML attributes,\n * plus a small blocklist for false positives (RN on* handlers, SVG attrs).\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, Record<string, unknown>>(\n ({ children, elementType, ...props }, ref) => {\n const Tag = (elementType as string) || defaultTag;\n const htmlProps: Record<string, unknown> = {};\n for (const key of Object.keys(props)) {\n if (shouldForwardProp(key)) {\n htmlProps[key] = props[key];\n }\n }\n return React.createElement(\n Tag,\n { ref, ...htmlProps },\n children as React.ReactNode\n );\n }\n );\n Component.displayName = `Filtered(${defaultTag})`;\n return Component;\n}\n","function memoize(fn) {\n var cache = {};\n return function (arg) {\n if (cache[arg] === undefined) cache[arg] = fn(arg);\n return cache[arg];\n };\n}\n\nexport default memoize;\n","import memoize from '@emotion/memoize';\n\nvar reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23\n\nvar index = memoize(function (prop) {\n return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111\n /* o */\n && prop.charCodeAt(1) === 110\n /* n */\n && prop.charCodeAt(2) < 91;\n}\n/* Z+1 */\n);\n\nexport default index;\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 {\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,OAAOA,YAAW;AAClB,OAAO,YAAY;;;ACDnB,OAAO,WAAW;;;ACAlB,SAAS,QAAQ,IAAI;AACnB,MAAI,QAAQ,CAAC;AACb,SAAO,SAAU,KAAK;AACpB,QAAI,MAAM,GAAG,MAAM,OAAW,OAAM,GAAG,IAAI,GAAG,GAAG;AACjD,WAAO,MAAM,GAAG;AAAA,EAClB;AACF;AAEA,IAAO,sBAAQ;;;ACNf,IAAI,kBAAkB;AAEtB,IAAI,QAAQ;AAAA,EAAQ,SAAU,MAAM;AAClC,WAAO,gBAAgB,KAAK,IAAI,KAAK,KAAK,WAAW,CAAC,MAAM,OAEzD,KAAK,WAAW,CAAC,MAAM,OAEvB,KAAK,WAAW,CAAC,IAAI;AAAA,EAC1B;AAAA;AAEA;AAEA,IAAO,4BAAQ;;;AFRR,IAAM,2BAA2B,oBAAI,IAAI;AAA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AA;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":["React","React","styled","jsx","styled","jsx"]}
|
package/README.md
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
# Switch
|
|
2
|
-
|
|
3
|
-
A cross-platform React switch component for toggling between on and off states. Provides a visual alternative to checkboxes for boolean settings.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @xsolla/xui-switch
|
|
9
|
-
# or
|
|
10
|
-
yarn add @xsolla/xui-switch
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Demo
|
|
14
|
-
|
|
15
|
-
### Basic Switch
|
|
16
|
-
|
|
17
|
-
```tsx
|
|
18
|
-
import * as React from 'react';
|
|
19
|
-
import { Switch } from '@xsolla/xui-switch';
|
|
20
|
-
|
|
21
|
-
export default function BasicSwitch() {
|
|
22
|
-
const [enabled, setEnabled] = React.useState(false);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Switch
|
|
26
|
-
checked={enabled}
|
|
27
|
-
onValueChange={setEnabled}
|
|
28
|
-
label="Enable notifications"
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Switch with Description
|
|
35
|
-
|
|
36
|
-
```tsx
|
|
37
|
-
import * as React from 'react';
|
|
38
|
-
import { Switch } from '@xsolla/xui-switch';
|
|
39
|
-
|
|
40
|
-
export default function SwitchWithDescription() {
|
|
41
|
-
const [darkMode, setDarkMode] = React.useState(false);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<Switch
|
|
45
|
-
checked={darkMode}
|
|
46
|
-
onValueChange={setDarkMode}
|
|
47
|
-
label="Dark Mode"
|
|
48
|
-
description="Enable dark theme across the application"
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Label Position
|
|
55
|
-
|
|
56
|
-
```tsx
|
|
57
|
-
import * as React from 'react';
|
|
58
|
-
import { Switch } from '@xsolla/xui-switch';
|
|
59
|
-
|
|
60
|
-
export default function SwitchLabelPosition() {
|
|
61
|
-
const [left, setLeft] = React.useState(false);
|
|
62
|
-
const [right, setRight] = React.useState(false);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
66
|
-
<Switch
|
|
67
|
-
label="Label on the right (default)"
|
|
68
|
-
labelPosition="right"
|
|
69
|
-
checked={right}
|
|
70
|
-
onValueChange={setRight}
|
|
71
|
-
/>
|
|
72
|
-
<Switch
|
|
73
|
-
label="Label on the left"
|
|
74
|
-
labelPosition="left"
|
|
75
|
-
checked={left}
|
|
76
|
-
onValueChange={setLeft}
|
|
77
|
-
/>
|
|
78
|
-
</div>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Switch Sizes
|
|
84
|
-
|
|
85
|
-
```tsx
|
|
86
|
-
import * as React from 'react';
|
|
87
|
-
import { Switch } from '@xsolla/xui-switch';
|
|
88
|
-
|
|
89
|
-
export default function SwitchSizes() {
|
|
90
|
-
return (
|
|
91
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
92
|
-
<Switch size="sm" label="Small switch" checked />
|
|
93
|
-
<Switch size="md" label="Medium switch (default)" checked />
|
|
94
|
-
<Switch size="lg" label="Large switch" checked />
|
|
95
|
-
<Switch size="xl" label="Extra large switch" checked />
|
|
96
|
-
</div>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## Anatomy
|
|
102
|
-
|
|
103
|
-
Import the component and use it directly:
|
|
104
|
-
|
|
105
|
-
```jsx
|
|
106
|
-
import { Switch } from '@xsolla/xui-switch';
|
|
107
|
-
|
|
108
|
-
<Switch
|
|
109
|
-
checked={isEnabled} // Whether switch is on
|
|
110
|
-
onValueChange={handleToggle} // Toggle handler
|
|
111
|
-
label="Setting label" // Label text
|
|
112
|
-
labelPosition="right" // "left" | "right" (default: "right")
|
|
113
|
-
description="Help text" // Description below label
|
|
114
|
-
errorLabel="Error text" // Error message
|
|
115
|
-
state="default" // Visual state
|
|
116
|
-
size="md" // Size variant
|
|
117
|
-
/>
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Examples
|
|
121
|
-
|
|
122
|
-
### Settings Panel
|
|
123
|
-
|
|
124
|
-
```tsx
|
|
125
|
-
import * as React from 'react';
|
|
126
|
-
import { Switch } from '@xsolla/xui-switch';
|
|
127
|
-
|
|
128
|
-
export default function SettingsPanel() {
|
|
129
|
-
const [settings, setSettings] = React.useState({
|
|
130
|
-
notifications: true,
|
|
131
|
-
sounds: false,
|
|
132
|
-
autoUpdate: true,
|
|
133
|
-
analytics: false,
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
const toggle = (key: string) => (value: boolean) => {
|
|
137
|
-
setSettings((prev) => ({ ...prev, [key]: value }));
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 20 }}>
|
|
142
|
-
<Switch
|
|
143
|
-
checked={settings.notifications}
|
|
144
|
-
onValueChange={toggle('notifications')}
|
|
145
|
-
label="Push Notifications"
|
|
146
|
-
description="Receive push notifications for important updates"
|
|
147
|
-
/>
|
|
148
|
-
<Switch
|
|
149
|
-
checked={settings.sounds}
|
|
150
|
-
onValueChange={toggle('sounds')}
|
|
151
|
-
label="Sound Effects"
|
|
152
|
-
description="Play sounds for actions and alerts"
|
|
153
|
-
/>
|
|
154
|
-
<Switch
|
|
155
|
-
checked={settings.autoUpdate}
|
|
156
|
-
onValueChange={toggle('autoUpdate')}
|
|
157
|
-
label="Auto Update"
|
|
158
|
-
description="Automatically download and install updates"
|
|
159
|
-
/>
|
|
160
|
-
<Switch
|
|
161
|
-
checked={settings.analytics}
|
|
162
|
-
onValueChange={toggle('analytics')}
|
|
163
|
-
label="Usage Analytics"
|
|
164
|
-
description="Help improve the app by sharing anonymous usage data"
|
|
165
|
-
/>
|
|
166
|
-
</div>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### Error State
|
|
172
|
-
|
|
173
|
-
```tsx
|
|
174
|
-
import * as React from 'react';
|
|
175
|
-
import { Switch } from '@xsolla/xui-switch';
|
|
176
|
-
|
|
177
|
-
export default function ErrorSwitch() {
|
|
178
|
-
return (
|
|
179
|
-
<Switch
|
|
180
|
-
checked={false}
|
|
181
|
-
state="error"
|
|
182
|
-
label="Required Setting"
|
|
183
|
-
errorLabel="This setting must be enabled to continue"
|
|
184
|
-
/>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### Disabled Switch
|
|
190
|
-
|
|
191
|
-
```tsx
|
|
192
|
-
import * as React from 'react';
|
|
193
|
-
import { Switch } from '@xsolla/xui-switch';
|
|
194
|
-
|
|
195
|
-
export default function DisabledSwitch() {
|
|
196
|
-
return (
|
|
197
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
198
|
-
<Switch state="disable" label="Disabled off" />
|
|
199
|
-
<Switch state="disable" checked label="Disabled on" />
|
|
200
|
-
</div>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## API Reference
|
|
206
|
-
|
|
207
|
-
### Switch
|
|
208
|
-
|
|
209
|
-
A toggle switch component.
|
|
210
|
-
|
|
211
|
-
**Switch Props:**
|
|
212
|
-
|
|
213
|
-
| Prop | Type | Default | Description |
|
|
214
|
-
| :--- | :--- | :------ | :---------- |
|
|
215
|
-
| checked | `boolean` | `false` | Whether the switch is on. |
|
|
216
|
-
| size | `"sm" \| "md" \| "lg" \| "xl"` | `"md"` | Size of the switch. |
|
|
217
|
-
| state | `"default" \| "hover" \| "disable" \| "error"` | `"default"` | Visual state. |
|
|
218
|
-
| label | `string` | - | Label text displayed next to switch. |
|
|
219
|
-
| labelPosition | `"left" \| "right"` | `"right"` | Position of the label relative to the switch. |
|
|
220
|
-
| description | `string` | - | Description text below the label. |
|
|
221
|
-
| errorLabel | `string` | - | Error message when state is "error". |
|
|
222
|
-
| onValueChange | `(value: boolean) => void` | - | Callback when toggled. |
|
|
223
|
-
| ariaLabel | `string` | - | Accessible label for screen readers. |
|
|
224
|
-
| ariaLabelledBy | `string` | - | ID of element that labels this switch. |
|
|
225
|
-
|
|
226
|
-
**Size Configuration:**
|
|
227
|
-
|
|
228
|
-
| Size | Track Width | Track Height | Knob Size |
|
|
229
|
-
| :--- | :---------- | :----------- | :-------- |
|
|
230
|
-
| sm | 32px | 18px | 14px |
|
|
231
|
-
| md | 40px | 22px | 18px |
|
|
232
|
-
| lg | 48px | 26px | 22px |
|
|
233
|
-
| xl | 56px | 30px | 26px |
|
|
234
|
-
|
|
235
|
-
## Theming
|
|
236
|
-
|
|
237
|
-
Switch uses the design system theme for colors:
|
|
238
|
-
|
|
239
|
-
```typescript
|
|
240
|
-
// Colors accessed via theme
|
|
241
|
-
theme.colors.control.switch.bgOff // Track background when off
|
|
242
|
-
theme.colors.control.switch.bgOn // Track background when on
|
|
243
|
-
theme.colors.control.switch.knob // Knob color
|
|
244
|
-
theme.colors.control.switch.border // Border color
|
|
245
|
-
theme.colors.content.primary // Label text
|
|
246
|
-
theme.colors.content.secondary // Description text
|
|
247
|
-
theme.colors.content.error // Error text
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
## Accessibility
|
|
251
|
-
|
|
252
|
-
- Uses `role="switch"` semantic role
|
|
253
|
-
- `aria-checked` reflects on/off state
|
|
254
|
-
- Keyboard support (Space/Enter to toggle)
|
|
255
|
-
- Focus indicator follows WCAG guidelines
|
|
256
|
-
- Label properly associated with control
|
|
257
|
-
- Disabled state announced to assistive technology
|