@xsolla/xui-segmented-native 0.64.0-pr56.1768348754

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.tsx","../../src/Segmented.tsx","../../../primitives-native/src/Box.tsx","../../../primitives-native/src/Text.tsx","../../../primitives-native/src/Spinner.tsx","../../../primitives-native/src/Icon.tsx","../../../primitives-native/src/Divider.tsx","../../../primitives-native/src/Input.tsx","../../../primitives-native/src/TextArea.tsx"],"sourcesContent":["export * from \"./Segmented\";\n","import React, { useState, useCallback, useRef } from \"react\";\n// @ts-ignore - this will be resolved at build time\nimport { Box, Text, Icon } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem } from \"@xsolla/xui-core\";\n\nexport interface SegmentedItemType {\n /** Unique identifier for the item */\n id: string;\n /** Display label for the item */\n label: string;\n /** Optional icon to display */\n icon?: React.ReactNode;\n /** Whether the item is disabled */\n disabled?: boolean;\n /** Accessible label for screen readers */\n \"aria-label\"?: string;\n}\n\nexport interface SegmentedProps {\n /** Array of items */\n items: SegmentedItemType[];\n /** ID of the currently active item */\n activeId?: string;\n /** Callback when an item is selected */\n onChange?: (id: string) => void;\n /** Size variant */\n size?: \"xl\" | \"l\" | \"m\" | \"s\";\n /** Whether to show a border around the container */\n stroke?: boolean;\n /** HTML id attribute */\n id?: string;\n /** Test ID for testing frameworks */\n testID?: string;\n /** Full width of the container */\n fullWidth?: boolean;\n}\n\n/**\n * Segmented - A control for switching between related views or filters\n */\nexport const Segmented: React.FC<SegmentedProps> = ({\n items,\n activeId,\n onChange,\n size = \"m\",\n stroke = false,\n id,\n testID,\n fullWidth = false,\n}) => {\n const { theme } = useDesignSystem();\n const sizeStyles = theme.sizing.segmented(size);\n\n const containerId = id ? `${id}-container` : undefined;\n const itemRefs = useRef<(HTMLElement | null)[]>([]);\n\n const enabledIndices = items\n .map((item, index) => (!item.disabled ? index : -1))\n .filter((i) => i !== -1);\n\n const focusItem = useCallback((index: number) => {\n const element = itemRefs.current[index];\n if (element) {\n element.focus();\n }\n }, []);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent, currentIndex: number) => {\n const currentEnabledIndex = enabledIndices.indexOf(currentIndex);\n\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n e.preventDefault();\n {\n const nextEnabledIndex =\n currentEnabledIndex < enabledIndices.length - 1\n ? enabledIndices[currentEnabledIndex + 1]\n : enabledIndices[0];\n focusItem(nextEnabledIndex);\n }\n break;\n\n case \"ArrowLeft\":\n case \"ArrowUp\":\n e.preventDefault();\n {\n const prevEnabledIndex =\n currentEnabledIndex > 0\n ? enabledIndices[currentEnabledIndex - 1]\n : enabledIndices[enabledIndices.length - 1];\n focusItem(prevEnabledIndex);\n }\n break;\n\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (onChange && !items[currentIndex].disabled) {\n onChange(items[currentIndex].id);\n }\n break;\n\n default:\n break;\n }\n },\n [enabledIndices, focusItem, onChange, items]\n );\n\n return (\n <Box\n id={containerId}\n role=\"radiogroup\"\n testID={testID}\n flexDirection=\"row\"\n alignItems=\"center\"\n flexShrink={0}\n width={fullWidth ? \"100%\" : \"fit-content\"}\n height={sizeStyles.height}\n backgroundColor={theme.colors.overlay.mono}\n borderRadius={theme.radius.button}\n padding={stroke ? 1 : 0}\n borderWidth={stroke ? 1 : 0}\n borderColor={theme.colors.border.secondary}\n borderStyle=\"solid\"\n overflow=\"hidden\"\n >\n {items.map((item, index) => {\n const isActive = item.id === activeId;\n const isDisabled = item.disabled;\n const itemId = id ? `${id}-item-${item.id}` : undefined;\n\n const handlePress = () => {\n if (!isDisabled && onChange) {\n onChange(item.id);\n }\n };\n\n const textColor = isDisabled\n ? theme.colors.content.tertiary\n : isActive\n ? theme.colors.content.primary\n : theme.colors.content.secondary;\n\n return (\n <Box\n key={item.id}\n as=\"button\"\n role=\"radio\"\n id={itemId}\n aria-checked={isActive}\n aria-disabled={isDisabled}\n aria-label={item[\"aria-label\"] || item.label}\n tabIndex={isActive ? 0 : -1}\n disabled={isDisabled}\n // @ts-ignore\n ref={(el: HTMLElement | null) => {\n itemRefs.current[index] = el;\n }}\n onPress={handlePress}\n // @ts-ignore\n onKeyDown={(e: React.KeyboardEvent) => handleKeyDown(e, index)}\n flex={fullWidth ? 1 : undefined}\n flexShrink={0}\n height=\"100%\"\n paddingHorizontal={sizeStyles.padding}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"center\"\n gap={8}\n backgroundColor={\n isActive ? theme.colors.background.primary : \"transparent\"\n }\n borderRadius={isActive ? theme.radius.button - (stroke ? 1 : 0) : 0}\n cursor={isDisabled ? \"not-allowed\" : \"pointer\"}\n boxShadow={isActive ? \"0px 1px 2px rgba(0, 0, 0, 0.1)\" : \"none\"}\n hoverStyle={\n !isDisabled && !isActive\n ? {\n backgroundColor: theme.colors.overlay.mono,\n }\n : undefined\n }\n >\n {item.icon && (\n <Icon size={sizeStyles.iconSize} color={textColor} aria-hidden>\n {item.icon}\n </Icon>\n )}\n <Text\n color={textColor}\n fontSize={sizeStyles.fontSize}\n fontWeight={isActive ? \"600\" : \"500\"}\n textAlign=\"center\"\n whiteSpace=\"nowrap\"\n >\n {item.label}\n </Text>\n </Box>\n );\n })}\n </Box>\n );\n};\n\nSegmented.displayName = \"Segmented\";\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 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 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 { Text as RNText, TextStyle, AccessibilityRole } from \"react-native\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\n// Map web roles to React Native accessibility roles\nconst roleMap: Record<string, AccessibilityRole> = {\n alert: \"alert\",\n heading: \"header\",\n button: \"button\",\n link: \"link\",\n text: \"text\",\n};\n\nexport const Text: React.FC<TextProps> = ({\n children,\n color,\n fontSize,\n fontWeight,\n fontFamily,\n id,\n role,\n ...props\n}) => {\n // Extract the first font name from a comma-separated list (e.g. for web-style font stacks)\n let resolvedFontFamily = fontFamily\n ? fontFamily.split(\",\")[0].replace(/['\"]/g, \"\").trim()\n : undefined;\n\n // On native, if we don't have the custom font loaded, it's better to use the system font\n // to avoid rendering issues or missing text.\n if (resolvedFontFamily === \"Pilat Wide Bold\") {\n resolvedFontFamily = undefined;\n }\n\n const style: TextStyle = {\n 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 };\n\n // Map role to React Native accessibilityRole\n const accessibilityRole = role ? roleMap[role] : undefined;\n\n return (\n <RNText style={style} testID={id} accessibilityRole={accessibilityRole}>\n {children}\n </RNText>\n );\n};\n","import type React from \"react\";\nimport { ActivityIndicator, View } from \"react-native\";\nimport type { SpinnerProps } from \"@xsolla/xui-primitives-core\";\n\nexport const Spinner: React.FC<SpinnerProps> = ({\n color,\n size,\n role,\n \"aria-label\": ariaLabel,\n \"aria-live\": ariaLive,\n \"aria-describedby\": ariaDescribedBy,\n testID,\n}) => {\n return (\n <View\n accessible={true}\n accessibilityRole={role === \"status\" ? \"none\" : undefined}\n accessibilityLabel={ariaLabel}\n accessibilityLiveRegion={\n ariaLive === \"polite\"\n ? \"polite\"\n : ariaLive === \"assertive\"\n ? \"assertive\"\n : \"none\"\n }\n testID={testID}\n >\n <ActivityIndicator\n color={color}\n size={typeof size === \"number\" ? size : \"small\"}\n />\n </View>\n );\n};\n\nSpinner.displayName = \"Spinner\";\n","import React from \"react\";\nimport { View, ViewStyle } from \"react-native\";\nimport { IconProps } from \"@xsolla/xui-primitives-core\";\n\nexport const Icon: React.FC<IconProps> = ({ children, color, size }) => {\n const style: ViewStyle = {\n width: typeof size === \"number\" ? size : undefined,\n height: typeof size === \"number\" ? size : undefined,\n alignItems: \"center\",\n justifyContent: \"center\",\n };\n\n // On native, we try to pass the color down to children (like Text primitives)\n // to mimic the CSS inheritance behavior of the web version.\n const childrenWithProps = React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n // @ts-ignore - passing color down to potential Text/Icon children\n return React.cloneElement(child, {\n color: child.props.color || color,\n // Also pass size if child seems to be an icon that needs it\n size: child.props.size || size,\n });\n }\n return child;\n });\n\n return <View style={style}>{childrenWithProps}</View>;\n};\n","import React from \"react\";\nimport { View, ViewStyle } from \"react-native\";\nimport { DividerProps } from \"@xsolla/xui-primitives-core\";\n\nexport const Divider: React.FC<DividerProps> = ({\n color,\n height,\n width,\n vertical,\n dashStroke,\n}) => {\n const style: ViewStyle = {\n backgroundColor: dashStroke\n ? \"transparent\"\n : color || \"rgba(255, 255, 255, 0.15)\",\n width: vertical ? (typeof width === \"number\" ? width : 1) : \"100%\",\n height: vertical ? \"100%\" : typeof height === \"number\" ? height : 1,\n ...(dashStroke && {\n borderStyle: \"dashed\",\n borderColor: color || \"rgba(255, 255, 255, 0.15)\",\n borderWidth: 0,\n ...(vertical\n ? { borderLeftWidth: typeof width === \"number\" ? width : 1 }\n : { borderTopWidth: typeof height === \"number\" ? height : 1 }),\n }),\n };\n\n return <View style={style} />;\n};\n","import React, { forwardRef } from \"react\";\nimport { TextInput as RNTextInput } from \"react-native\";\nimport { InputPrimitiveProps } from \"@xsolla/xui-primitives-core\";\n\n// Map web input types to React Native keyboard types\nconst keyboardTypeMap: Record<string, any> = {\n text: \"default\",\n number: \"numeric\",\n email: \"email-address\",\n tel: \"phone-pad\",\n url: \"url\",\n decimal: \"decimal-pad\",\n};\n\n// Map web inputMode to React Native keyboard types\nconst inputModeToKeyboardType: Record<string, any> = {\n none: \"default\",\n text: \"default\",\n decimal: \"decimal-pad\",\n numeric: \"number-pad\",\n tel: \"phone-pad\",\n search: \"default\",\n email: \"email-address\",\n url: \"url\",\n};\n\n// Map web autoComplete to React Native textContentType (iOS)\nconst autoCompleteToTextContentType: Record<string, any> = {\n \"one-time-code\": \"oneTimeCode\",\n email: \"emailAddress\",\n username: \"username\",\n password: \"password\",\n \"new-password\": \"newPassword\",\n tel: \"telephoneNumber\",\n \"postal-code\": \"postalCode\",\n name: \"name\",\n};\n\nexport const InputPrimitive = forwardRef<RNTextInput, InputPrimitiveProps>(\n (\n {\n value,\n placeholder,\n onChange,\n onChangeText,\n onFocus,\n onBlur,\n onKeyDown,\n disabled,\n secureTextEntry,\n style,\n color,\n fontSize,\n placeholderTextColor,\n maxLength,\n name,\n type,\n inputMode,\n autoComplete,\n id,\n \"aria-invalid\": ariaInvalid,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-label\": ariaLabel,\n \"aria-disabled\": ariaDisabled,\n \"data-testid\": dataTestId,\n },\n ref\n ) => {\n const handleChangeText = (text: string) => {\n onChangeText?.(text);\n\n // Create a synthetic event for onChange compatibility\n // Include nativeEvent and no-op methods to prevent runtime errors\n // when consumers expect DOM-like event behavior\n if (onChange) {\n const syntheticEvent = {\n target: { value: text },\n currentTarget: { value: text },\n type: \"change\",\n nativeEvent: { text },\n preventDefault: () => {},\n stopPropagation: () => {},\n isTrusted: false,\n } as unknown as React.ChangeEvent<HTMLInputElement>;\n onChange(syntheticEvent);\n }\n };\n\n // Determine keyboard type - inputMode takes precedence over type\n const keyboardType = inputMode\n ? inputModeToKeyboardType[inputMode] || \"default\"\n : type\n ? keyboardTypeMap[type] || \"default\"\n : \"default\";\n\n // Determine textContentType for iOS autofill\n const textContentType = autoComplete\n ? autoCompleteToTextContentType[autoComplete]\n : undefined;\n\n return (\n <RNTextInput\n ref={ref}\n value={value}\n placeholder={placeholder}\n onChangeText={handleChangeText}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={(e) => {\n // Map onKeyPress to onKeyDown for cross-platform compatibility\n // Include preventDefault to avoid runtime errors when consumers call it\n if (onKeyDown) {\n onKeyDown({\n key: e.nativeEvent.key,\n preventDefault: () => {},\n } as any);\n }\n }}\n editable={!disabled}\n secureTextEntry={secureTextEntry || type === \"password\"}\n keyboardType={keyboardType}\n textContentType={textContentType}\n style={[\n {\n color,\n fontSize: typeof fontSize === \"number\" ? fontSize : undefined,\n flex: 1,\n padding: 0,\n textAlign: (style as any)?.textAlign || \"left\",\n },\n style as any,\n ]}\n placeholderTextColor={placeholderTextColor}\n maxLength={maxLength}\n // React Native accessibility props\n testID={dataTestId || id}\n accessibilityLabel={ariaLabel}\n accessibilityHint={ariaDescribedBy}\n accessibilityState={{\n disabled: disabled || ariaDisabled,\n }}\n accessible={true}\n />\n );\n }\n);\n\nInputPrimitive.displayName = \"InputPrimitive\";\n","import React, { forwardRef } from \"react\";\nimport { TextInput as RNTextInput } from \"react-native\";\nimport { TextAreaPrimitiveProps } from \"@xsolla/xui-primitives-core\";\n\nexport const TextAreaPrimitive = forwardRef<\n RNTextInput,\n TextAreaPrimitiveProps\n>(\n (\n {\n value,\n placeholder,\n onChange,\n onChangeText,\n onFocus,\n onBlur,\n onKeyDown,\n disabled,\n style,\n color,\n fontSize,\n placeholderTextColor,\n maxLength,\n rows,\n id,\n \"aria-invalid\": ariaInvalid,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-label\": ariaLabel,\n \"aria-disabled\": ariaDisabled,\n \"data-testid\": dataTestId,\n },\n ref\n ) => {\n const handleChangeText = (text: string) => {\n onChangeText?.(text);\n\n if (onChange) {\n const syntheticEvent = {\n target: { value: text },\n currentTarget: { value: text },\n type: \"change\",\n nativeEvent: { text },\n preventDefault: () => {},\n stopPropagation: () => {},\n isTrusted: false,\n } as unknown as React.ChangeEvent<HTMLTextAreaElement>;\n onChange(syntheticEvent);\n }\n };\n\n return (\n <RNTextInput\n ref={ref}\n value={value}\n placeholder={placeholder}\n onChangeText={handleChangeText}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyPress={(e) => {\n if (onKeyDown) {\n onKeyDown({\n key: e.nativeEvent.key,\n preventDefault: () => {},\n } as any);\n }\n }}\n editable={!disabled}\n multiline={true}\n numberOfLines={rows || 4}\n style={[\n {\n color,\n fontSize: typeof fontSize === \"number\" ? fontSize : undefined,\n flex: 1,\n padding: 0,\n textAlignVertical: \"top\",\n textAlign: (style as any)?.textAlign || \"left\",\n },\n style as any,\n ]}\n placeholderTextColor={placeholderTextColor}\n maxLength={maxLength}\n testID={dataTestId || id}\n accessibilityLabel={ariaLabel}\n accessibilityHint={ariaDescribedBy}\n accessibilityState={{\n disabled: disabled || ariaDisabled,\n }}\n accessible={true}\n />\n );\n }\n);\n\nTextAreaPrimitive.displayName = \"TextAreaPrimitive\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAqD;;;ACCrD,0BAQO;AAmID;AAhIC,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,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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WAAU;AAAA,kBACV,YAAW;AAAA,kBAEV,eAAK;AAAA;AAAA,cACR;AAAA;AAAA;AAAA,UAnDK,KAAK;AAAA,QAoDZ;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,UAAU,cAAc;","names":["import_react","import_react_native","import_jsx_runtime","RNText","import_react_native","import_jsx_runtime","import_react_native","import_jsx_runtime","React","import_react_native","import_jsx_runtime","import_react","import_react_native","import_jsx_runtime","RNTextInput","import_react","import_react_native","import_jsx_runtime","RNTextInput","import_jsx_runtime"]}
package/index.mjs ADDED
@@ -0,0 +1,628 @@
1
+ // src/Segmented.tsx
2
+ import { useCallback, useRef } from "react";
3
+
4
+ // ../primitives-native/src/Box.tsx
5
+ import {
6
+ View,
7
+ Pressable,
8
+ Image
9
+ } from "react-native";
10
+ import { jsx } from "react/jsx-runtime";
11
+ var Box = ({
12
+ children,
13
+ onPress,
14
+ onLayout,
15
+ onMoveShouldSetResponder,
16
+ onResponderGrant,
17
+ onResponderMove,
18
+ onResponderRelease,
19
+ onResponderTerminate,
20
+ backgroundColor,
21
+ borderColor,
22
+ borderWidth,
23
+ borderBottomWidth,
24
+ borderBottomColor,
25
+ borderTopWidth,
26
+ borderTopColor,
27
+ borderLeftWidth,
28
+ borderLeftColor,
29
+ borderRightWidth,
30
+ borderRightColor,
31
+ borderRadius,
32
+ borderStyle,
33
+ height,
34
+ padding,
35
+ paddingHorizontal,
36
+ paddingVertical,
37
+ margin,
38
+ marginTop,
39
+ marginBottom,
40
+ marginLeft,
41
+ marginRight,
42
+ flexDirection,
43
+ alignItems,
44
+ justifyContent,
45
+ position,
46
+ top,
47
+ bottom,
48
+ left,
49
+ right,
50
+ width,
51
+ flex,
52
+ overflow,
53
+ zIndex,
54
+ hoverStyle,
55
+ pressStyle,
56
+ style,
57
+ "data-testid": dataTestId,
58
+ testID,
59
+ as,
60
+ src,
61
+ alt,
62
+ ...rest
63
+ }) => {
64
+ const getContainerStyle = (pressed) => ({
65
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
66
+ borderColor,
67
+ borderWidth,
68
+ borderBottomWidth,
69
+ borderBottomColor,
70
+ borderTopWidth,
71
+ borderTopColor,
72
+ borderLeftWidth,
73
+ borderLeftColor,
74
+ borderRightWidth,
75
+ borderRightColor,
76
+ borderRadius,
77
+ borderStyle,
78
+ overflow,
79
+ zIndex,
80
+ height,
81
+ width,
82
+ padding,
83
+ paddingHorizontal,
84
+ paddingVertical,
85
+ margin,
86
+ marginTop,
87
+ marginBottom,
88
+ marginLeft,
89
+ marginRight,
90
+ flexDirection,
91
+ alignItems,
92
+ justifyContent,
93
+ position,
94
+ top,
95
+ bottom,
96
+ left,
97
+ right,
98
+ flex,
99
+ ...style
100
+ });
101
+ const finalTestID = dataTestId || testID;
102
+ const {
103
+ role,
104
+ tabIndex,
105
+ onKeyDown,
106
+ onKeyUp,
107
+ "aria-label": _ariaLabel,
108
+ "aria-labelledby": _ariaLabelledBy,
109
+ "aria-current": _ariaCurrent,
110
+ "aria-disabled": _ariaDisabled,
111
+ "aria-live": _ariaLive,
112
+ className,
113
+ "data-testid": _dataTestId,
114
+ ...nativeRest
115
+ } = rest;
116
+ if (as === "img" && src) {
117
+ const imageStyle = {
118
+ width,
119
+ height,
120
+ borderRadius,
121
+ position,
122
+ top,
123
+ bottom,
124
+ left,
125
+ right,
126
+ ...style
127
+ };
128
+ return /* @__PURE__ */ jsx(
129
+ Image,
130
+ {
131
+ source: { uri: src },
132
+ style: imageStyle,
133
+ testID: finalTestID,
134
+ resizeMode: "cover",
135
+ ...nativeRest
136
+ }
137
+ );
138
+ }
139
+ if (onPress) {
140
+ return /* @__PURE__ */ jsx(
141
+ Pressable,
142
+ {
143
+ onPress,
144
+ onLayout,
145
+ onMoveShouldSetResponder,
146
+ onResponderGrant,
147
+ onResponderMove,
148
+ onResponderRelease,
149
+ onResponderTerminate,
150
+ style: ({ pressed }) => getContainerStyle(pressed),
151
+ testID: finalTestID,
152
+ ...nativeRest,
153
+ children
154
+ }
155
+ );
156
+ }
157
+ return /* @__PURE__ */ jsx(
158
+ View,
159
+ {
160
+ style: getContainerStyle(),
161
+ testID: finalTestID,
162
+ onLayout,
163
+ onMoveShouldSetResponder,
164
+ onResponderGrant,
165
+ onResponderMove,
166
+ onResponderRelease,
167
+ onResponderTerminate,
168
+ ...nativeRest,
169
+ children
170
+ }
171
+ );
172
+ };
173
+
174
+ // ../primitives-native/src/Text.tsx
175
+ import { Text as RNText } from "react-native";
176
+ import { jsx as jsx2 } from "react/jsx-runtime";
177
+ var roleMap = {
178
+ alert: "alert",
179
+ heading: "header",
180
+ button: "button",
181
+ link: "link",
182
+ text: "text"
183
+ };
184
+ var Text = ({
185
+ children,
186
+ color,
187
+ fontSize,
188
+ fontWeight,
189
+ fontFamily,
190
+ id,
191
+ role,
192
+ ...props
193
+ }) => {
194
+ let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
195
+ if (resolvedFontFamily === "Pilat Wide Bold") {
196
+ resolvedFontFamily = void 0;
197
+ }
198
+ const style = {
199
+ color,
200
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
201
+ fontWeight,
202
+ fontFamily: resolvedFontFamily,
203
+ textDecorationLine: props.textDecoration
204
+ };
205
+ const accessibilityRole = role ? roleMap[role] : void 0;
206
+ return /* @__PURE__ */ jsx2(RNText, { style, testID: id, accessibilityRole, children });
207
+ };
208
+
209
+ // ../primitives-native/src/Spinner.tsx
210
+ import { ActivityIndicator, View as View2 } from "react-native";
211
+ import { jsx as jsx3 } from "react/jsx-runtime";
212
+ var Spinner = ({
213
+ color,
214
+ size,
215
+ role,
216
+ "aria-label": ariaLabel,
217
+ "aria-live": ariaLive,
218
+ "aria-describedby": ariaDescribedBy,
219
+ testID
220
+ }) => {
221
+ return /* @__PURE__ */ jsx3(
222
+ View2,
223
+ {
224
+ accessible: true,
225
+ accessibilityRole: role === "status" ? "none" : void 0,
226
+ accessibilityLabel: ariaLabel,
227
+ accessibilityLiveRegion: ariaLive === "polite" ? "polite" : ariaLive === "assertive" ? "assertive" : "none",
228
+ testID,
229
+ children: /* @__PURE__ */ jsx3(
230
+ ActivityIndicator,
231
+ {
232
+ color,
233
+ size: typeof size === "number" ? size : "small"
234
+ }
235
+ )
236
+ }
237
+ );
238
+ };
239
+ Spinner.displayName = "Spinner";
240
+
241
+ // ../primitives-native/src/Icon.tsx
242
+ import React from "react";
243
+ import { View as View3 } from "react-native";
244
+ import { jsx as jsx4 } from "react/jsx-runtime";
245
+ var Icon = ({ children, color, size }) => {
246
+ const style = {
247
+ width: typeof size === "number" ? size : void 0,
248
+ height: typeof size === "number" ? size : void 0,
249
+ alignItems: "center",
250
+ justifyContent: "center"
251
+ };
252
+ const childrenWithProps = React.Children.map(children, (child) => {
253
+ if (React.isValidElement(child)) {
254
+ return React.cloneElement(child, {
255
+ color: child.props.color || color,
256
+ // Also pass size if child seems to be an icon that needs it
257
+ size: child.props.size || size
258
+ });
259
+ }
260
+ return child;
261
+ });
262
+ return /* @__PURE__ */ jsx4(View3, { style, children: childrenWithProps });
263
+ };
264
+
265
+ // ../primitives-native/src/Divider.tsx
266
+ import { View as View4 } from "react-native";
267
+ import { jsx as jsx5 } from "react/jsx-runtime";
268
+
269
+ // ../primitives-native/src/Input.tsx
270
+ import { forwardRef } from "react";
271
+ import { TextInput as RNTextInput } from "react-native";
272
+ import { jsx as jsx6 } from "react/jsx-runtime";
273
+ var keyboardTypeMap = {
274
+ text: "default",
275
+ number: "numeric",
276
+ email: "email-address",
277
+ tel: "phone-pad",
278
+ url: "url",
279
+ decimal: "decimal-pad"
280
+ };
281
+ var inputModeToKeyboardType = {
282
+ none: "default",
283
+ text: "default",
284
+ decimal: "decimal-pad",
285
+ numeric: "number-pad",
286
+ tel: "phone-pad",
287
+ search: "default",
288
+ email: "email-address",
289
+ url: "url"
290
+ };
291
+ var autoCompleteToTextContentType = {
292
+ "one-time-code": "oneTimeCode",
293
+ email: "emailAddress",
294
+ username: "username",
295
+ password: "password",
296
+ "new-password": "newPassword",
297
+ tel: "telephoneNumber",
298
+ "postal-code": "postalCode",
299
+ name: "name"
300
+ };
301
+ var InputPrimitive = forwardRef(
302
+ ({
303
+ value,
304
+ placeholder,
305
+ onChange,
306
+ onChangeText,
307
+ onFocus,
308
+ onBlur,
309
+ onKeyDown,
310
+ disabled,
311
+ secureTextEntry,
312
+ style,
313
+ color,
314
+ fontSize,
315
+ placeholderTextColor,
316
+ maxLength,
317
+ name,
318
+ type,
319
+ inputMode,
320
+ autoComplete,
321
+ id,
322
+ "aria-invalid": ariaInvalid,
323
+ "aria-describedby": ariaDescribedBy,
324
+ "aria-labelledby": ariaLabelledBy,
325
+ "aria-label": ariaLabel,
326
+ "aria-disabled": ariaDisabled,
327
+ "data-testid": dataTestId
328
+ }, ref) => {
329
+ const handleChangeText = (text) => {
330
+ onChangeText?.(text);
331
+ if (onChange) {
332
+ const syntheticEvent = {
333
+ target: { value: text },
334
+ currentTarget: { value: text },
335
+ type: "change",
336
+ nativeEvent: { text },
337
+ preventDefault: () => {
338
+ },
339
+ stopPropagation: () => {
340
+ },
341
+ isTrusted: false
342
+ };
343
+ onChange(syntheticEvent);
344
+ }
345
+ };
346
+ const keyboardType = inputMode ? inputModeToKeyboardType[inputMode] || "default" : type ? keyboardTypeMap[type] || "default" : "default";
347
+ const textContentType = autoComplete ? autoCompleteToTextContentType[autoComplete] : void 0;
348
+ return /* @__PURE__ */ jsx6(
349
+ RNTextInput,
350
+ {
351
+ ref,
352
+ value,
353
+ placeholder,
354
+ onChangeText: handleChangeText,
355
+ onFocus,
356
+ onBlur,
357
+ onKeyPress: (e) => {
358
+ if (onKeyDown) {
359
+ onKeyDown({
360
+ key: e.nativeEvent.key,
361
+ preventDefault: () => {
362
+ }
363
+ });
364
+ }
365
+ },
366
+ editable: !disabled,
367
+ secureTextEntry: secureTextEntry || type === "password",
368
+ keyboardType,
369
+ textContentType,
370
+ style: [
371
+ {
372
+ color,
373
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
374
+ flex: 1,
375
+ padding: 0,
376
+ textAlign: style?.textAlign || "left"
377
+ },
378
+ style
379
+ ],
380
+ placeholderTextColor,
381
+ maxLength,
382
+ testID: dataTestId || id,
383
+ accessibilityLabel: ariaLabel,
384
+ accessibilityHint: ariaDescribedBy,
385
+ accessibilityState: {
386
+ disabled: disabled || ariaDisabled
387
+ },
388
+ accessible: true
389
+ }
390
+ );
391
+ }
392
+ );
393
+ InputPrimitive.displayName = "InputPrimitive";
394
+
395
+ // ../primitives-native/src/TextArea.tsx
396
+ import { forwardRef as forwardRef2 } from "react";
397
+ import { TextInput as RNTextInput2 } from "react-native";
398
+ import { jsx as jsx7 } from "react/jsx-runtime";
399
+ var TextAreaPrimitive = forwardRef2(
400
+ ({
401
+ value,
402
+ placeholder,
403
+ onChange,
404
+ onChangeText,
405
+ onFocus,
406
+ onBlur,
407
+ onKeyDown,
408
+ disabled,
409
+ style,
410
+ color,
411
+ fontSize,
412
+ placeholderTextColor,
413
+ maxLength,
414
+ rows,
415
+ id,
416
+ "aria-invalid": ariaInvalid,
417
+ "aria-describedby": ariaDescribedBy,
418
+ "aria-labelledby": ariaLabelledBy,
419
+ "aria-label": ariaLabel,
420
+ "aria-disabled": ariaDisabled,
421
+ "data-testid": dataTestId
422
+ }, ref) => {
423
+ const handleChangeText = (text) => {
424
+ onChangeText?.(text);
425
+ if (onChange) {
426
+ const syntheticEvent = {
427
+ target: { value: text },
428
+ currentTarget: { value: text },
429
+ type: "change",
430
+ nativeEvent: { text },
431
+ preventDefault: () => {
432
+ },
433
+ stopPropagation: () => {
434
+ },
435
+ isTrusted: false
436
+ };
437
+ onChange(syntheticEvent);
438
+ }
439
+ };
440
+ return /* @__PURE__ */ jsx7(
441
+ RNTextInput2,
442
+ {
443
+ ref,
444
+ value,
445
+ placeholder,
446
+ onChangeText: handleChangeText,
447
+ onFocus,
448
+ onBlur,
449
+ onKeyPress: (e) => {
450
+ if (onKeyDown) {
451
+ onKeyDown({
452
+ key: e.nativeEvent.key,
453
+ preventDefault: () => {
454
+ }
455
+ });
456
+ }
457
+ },
458
+ editable: !disabled,
459
+ multiline: true,
460
+ numberOfLines: rows || 4,
461
+ style: [
462
+ {
463
+ color,
464
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
465
+ flex: 1,
466
+ padding: 0,
467
+ textAlignVertical: "top",
468
+ textAlign: style?.textAlign || "left"
469
+ },
470
+ style
471
+ ],
472
+ placeholderTextColor,
473
+ maxLength,
474
+ testID: dataTestId || id,
475
+ accessibilityLabel: ariaLabel,
476
+ accessibilityHint: ariaDescribedBy,
477
+ accessibilityState: {
478
+ disabled: disabled || ariaDisabled
479
+ },
480
+ accessible: true
481
+ }
482
+ );
483
+ }
484
+ );
485
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
486
+
487
+ // src/Segmented.tsx
488
+ import { useDesignSystem } from "@xsolla/xui-core";
489
+ import { jsx as jsx8, jsxs } from "react/jsx-runtime";
490
+ var Segmented = ({
491
+ items,
492
+ activeId,
493
+ onChange,
494
+ size = "m",
495
+ stroke = false,
496
+ id,
497
+ testID,
498
+ fullWidth = false
499
+ }) => {
500
+ const { theme } = useDesignSystem();
501
+ const sizeStyles = theme.sizing.segmented(size);
502
+ const containerId = id ? `${id}-container` : void 0;
503
+ const itemRefs = useRef([]);
504
+ const enabledIndices = items.map((item, index) => !item.disabled ? index : -1).filter((i) => i !== -1);
505
+ const focusItem = useCallback((index) => {
506
+ const element = itemRefs.current[index];
507
+ if (element) {
508
+ element.focus();
509
+ }
510
+ }, []);
511
+ const handleKeyDown = useCallback(
512
+ (e, currentIndex) => {
513
+ const currentEnabledIndex = enabledIndices.indexOf(currentIndex);
514
+ switch (e.key) {
515
+ case "ArrowRight":
516
+ case "ArrowDown":
517
+ e.preventDefault();
518
+ {
519
+ const nextEnabledIndex = currentEnabledIndex < enabledIndices.length - 1 ? enabledIndices[currentEnabledIndex + 1] : enabledIndices[0];
520
+ focusItem(nextEnabledIndex);
521
+ }
522
+ break;
523
+ case "ArrowLeft":
524
+ case "ArrowUp":
525
+ e.preventDefault();
526
+ {
527
+ const prevEnabledIndex = currentEnabledIndex > 0 ? enabledIndices[currentEnabledIndex - 1] : enabledIndices[enabledIndices.length - 1];
528
+ focusItem(prevEnabledIndex);
529
+ }
530
+ break;
531
+ case "Enter":
532
+ case " ":
533
+ e.preventDefault();
534
+ if (onChange && !items[currentIndex].disabled) {
535
+ onChange(items[currentIndex].id);
536
+ }
537
+ break;
538
+ default:
539
+ break;
540
+ }
541
+ },
542
+ [enabledIndices, focusItem, onChange, items]
543
+ );
544
+ return /* @__PURE__ */ jsx8(
545
+ Box,
546
+ {
547
+ id: containerId,
548
+ role: "radiogroup",
549
+ testID,
550
+ flexDirection: "row",
551
+ alignItems: "center",
552
+ flexShrink: 0,
553
+ width: fullWidth ? "100%" : "fit-content",
554
+ height: sizeStyles.height,
555
+ backgroundColor: theme.colors.overlay.mono,
556
+ borderRadius: theme.radius.button,
557
+ padding: stroke ? 1 : 0,
558
+ borderWidth: stroke ? 1 : 0,
559
+ borderColor: theme.colors.border.secondary,
560
+ borderStyle: "solid",
561
+ overflow: "hidden",
562
+ children: items.map((item, index) => {
563
+ const isActive = item.id === activeId;
564
+ const isDisabled = item.disabled;
565
+ const itemId = id ? `${id}-item-${item.id}` : void 0;
566
+ const handlePress = () => {
567
+ if (!isDisabled && onChange) {
568
+ onChange(item.id);
569
+ }
570
+ };
571
+ const textColor = isDisabled ? theme.colors.content.tertiary : isActive ? theme.colors.content.primary : theme.colors.content.secondary;
572
+ return /* @__PURE__ */ jsxs(
573
+ Box,
574
+ {
575
+ as: "button",
576
+ role: "radio",
577
+ id: itemId,
578
+ "aria-checked": isActive,
579
+ "aria-disabled": isDisabled,
580
+ "aria-label": item["aria-label"] || item.label,
581
+ tabIndex: isActive ? 0 : -1,
582
+ disabled: isDisabled,
583
+ ref: (el) => {
584
+ itemRefs.current[index] = el;
585
+ },
586
+ onPress: handlePress,
587
+ onKeyDown: (e) => handleKeyDown(e, index),
588
+ flex: fullWidth ? 1 : void 0,
589
+ flexShrink: 0,
590
+ height: "100%",
591
+ paddingHorizontal: sizeStyles.padding,
592
+ flexDirection: "row",
593
+ alignItems: "center",
594
+ justifyContent: "center",
595
+ gap: 8,
596
+ backgroundColor: isActive ? theme.colors.background.primary : "transparent",
597
+ borderRadius: isActive ? theme.radius.button - (stroke ? 1 : 0) : 0,
598
+ cursor: isDisabled ? "not-allowed" : "pointer",
599
+ boxShadow: isActive ? "0px 1px 2px rgba(0, 0, 0, 0.1)" : "none",
600
+ hoverStyle: !isDisabled && !isActive ? {
601
+ backgroundColor: theme.colors.overlay.mono
602
+ } : void 0,
603
+ children: [
604
+ item.icon && /* @__PURE__ */ jsx8(Icon, { size: sizeStyles.iconSize, color: textColor, "aria-hidden": true, children: item.icon }),
605
+ /* @__PURE__ */ jsx8(
606
+ Text,
607
+ {
608
+ color: textColor,
609
+ fontSize: sizeStyles.fontSize,
610
+ fontWeight: isActive ? "600" : "500",
611
+ textAlign: "center",
612
+ whiteSpace: "nowrap",
613
+ children: item.label
614
+ }
615
+ )
616
+ ]
617
+ },
618
+ item.id
619
+ );
620
+ })
621
+ }
622
+ );
623
+ };
624
+ Segmented.displayName = "Segmented";
625
+ export {
626
+ Segmented
627
+ };
628
+ //# sourceMappingURL=index.mjs.map