@xsolla/xui-toggle-button-group 0.216.0 → 0.217.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ToggleButtonGroup.tsx","../../../../foundation/primitives-native/src/Box.tsx","../../../../foundation/primitives-native/src/Text.tsx","../../../../foundation/primitives-native/src/index.tsx"],"sourcesContent":["import React, { useCallback, useRef, useState } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text, isWeb } from \"@xsolla/xui-primitives\";\nimport { useResolvedTheme } from \"@xsolla/xui-core\";\nimport { Tooltip } from \"@xsolla/xui-tooltip\";\nimport type { ToggleButtonGroupProps } from \"./types\";\n\nconst cloneIconWithDefaults = (\n icon: React.ReactNode,\n defaultSize: number,\n defaultColor: string\n): React.ReactNode => {\n if (!React.isValidElement(icon)) return icon;\n\n const iconElement = icon as React.ReactElement<Record<string, unknown>>;\n const existingProps = iconElement.props || {};\n\n return React.cloneElement(iconElement, {\n ...existingProps,\n size: existingProps.size ?? defaultSize,\n color: existingProps.color ?? defaultColor,\n });\n};\n\nconst getUnitedItemCornerStyle = (\n index: number,\n total: number,\n borderRadius: number,\n isVertical: boolean\n): React.CSSProperties => {\n const isFirst = index === 0;\n const isLast = index === total - 1;\n if (!isFirst && !isLast) return {};\n\n const radius = `${borderRadius}px`;\n\n if (isVertical) {\n return {\n ...(isFirst && {\n borderTopLeftRadius: radius,\n borderTopRightRadius: radius,\n }),\n ...(isLast && {\n borderBottomLeftRadius: radius,\n borderBottomRightRadius: radius,\n }),\n };\n }\n\n return {\n ...(isFirst && {\n borderTopLeftRadius: radius,\n borderBottomLeftRadius: radius,\n }),\n ...(isLast && {\n borderTopRightRadius: radius,\n borderBottomRightRadius: radius,\n }),\n };\n};\n\n/**\n * ToggleButtonGroup - A control for picking one or several options from a set\n *\n * Used to pick one or several options from a linear set of closely related options.\n * Can be used to filter or to sort elements.\n *\n * ## Accessibility Features\n *\n * - **Role**: Uses `role=\"radiogroup\"` for single selection, `role=\"group\"` for multiple\n * - **Keyboard Navigation**: Arrow keys to navigate, Enter/Space to select\n * - **ARIA**: Proper aria-checked and aria-disabled states\n */\nexport const ToggleButtonGroup: React.FC<ToggleButtonGroupProps> = ({\n items,\n value,\n defaultValue,\n onChange,\n size = \"sm\",\n appearance = \"separated\",\n view = \"horizontal\",\n multiple = false,\n id,\n testID,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n fullWidth = false,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n const sizeStyles = theme.sizing.toggleButtonGroup(size);\n const itemRefs = useRef<(HTMLElement | null)[]>([]);\n\n const [internalValue, setInternalValue] = useState<string[]>(() => {\n if (defaultValue !== undefined) {\n return Array.isArray(defaultValue) ? defaultValue : [defaultValue];\n }\n return [];\n });\n\n const currentValue =\n value !== undefined\n ? Array.isArray(value)\n ? value\n : [value]\n : internalValue;\n\n const isItemActive = (itemId: string) => currentValue.includes(itemId);\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 handleSelect = useCallback(\n (itemId: string) => {\n let newValue: string[];\n\n if (multiple) {\n if (currentValue.includes(itemId)) {\n newValue = currentValue.filter((v) => v !== itemId);\n } else {\n newValue = [...currentValue, itemId];\n }\n } else {\n newValue = [itemId];\n }\n\n if (value === undefined) {\n setInternalValue(newValue);\n }\n\n if (onChange) {\n if (multiple) {\n onChange(newValue);\n } else {\n onChange(newValue[0] || \"\");\n }\n }\n },\n [currentValue, multiple, value, onChange]\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 (!items[currentIndex].disabled) {\n handleSelect(items[currentIndex].id);\n }\n break;\n\n default:\n break;\n }\n },\n [enabledIndices, focusItem, handleSelect, items]\n );\n\n const isSeparated = appearance === \"separated\";\n const isVertical = view === \"vertical\";\n const containerGap = isSeparated ? sizeStyles.itemGap : 0;\n\n // Determine first active item for tabindex in single selection mode\n const firstActiveIndex = items.findIndex((item) =>\n currentValue.includes(item.id)\n );\n const firstEnabledIndex = enabledIndices[0] ?? 0;\n\n return (\n <Box\n id={id}\n role={multiple ? \"group\" : \"radiogroup\"}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n testID={testID}\n flexDirection={isVertical ? \"column\" : \"row\"}\n alignItems=\"stretch\"\n flexWrap={isSeparated && !isVertical ? \"wrap\" : \"nowrap\"}\n gap={containerGap}\n width={fullWidth ? \"100%\" : \"fit-content\"}\n {...(!isSeparated && {\n borderRadius: sizeStyles.borderRadius,\n overflow: \"hidden\",\n })}\n >\n {items.map((item, index) => {\n const isActive = isItemActive(item.id);\n const isDisabled = item.disabled;\n const itemId = id ? `${id}-item-${item.id}` : undefined;\n\n let tabIndex: number;\n if (isDisabled) {\n tabIndex = -1;\n } else if (multiple) {\n // In multiple mode, all enabled items are tabbable\n tabIndex = 0;\n } else {\n // In single mode, only the active item (or first enabled if none active) is tabbable\n tabIndex =\n isActive || (firstActiveIndex === -1 && index === firstEnabledIndex)\n ? 0\n : -1;\n }\n\n const handlePress = () => {\n if (!isDisabled) {\n handleSelect(item.id);\n }\n };\n\n const toggleColors = theme.colors.control.toggleButton;\n\n const bgColor = isDisabled\n ? toggleColors.bgDisable\n : isActive\n ? toggleColors.bgActive\n : toggleColors.bg;\n\n const textColor = isDisabled\n ? toggleColors.textDisable\n : isActive\n ? toggleColors.textActive\n : toggleColors.text;\n\n const borderColor = isDisabled\n ? toggleColors.borderDisable\n : isActive\n ? toggleColors.borderActive\n : toggleColors.border;\n\n const button = (\n <Box\n as=\"button\"\n role={multiple ? \"checkbox\" : \"radio\"}\n id={itemId}\n testID={item.testID}\n aria-checked={isActive}\n aria-disabled={isDisabled}\n aria-label={item[\"aria-label\"] || item.label}\n tabIndex={tabIndex}\n disabled={isDisabled}\n ref={(el: HTMLElement | null) => {\n itemRefs.current[index] = el;\n }}\n onPress={handlePress}\n onKeyDown={(e: React.KeyboardEvent) => handleKeyDown(e, index)}\n flex={fullWidth ? 1 : undefined}\n height={sizeStyles.height}\n paddingHorizontal={sizeStyles.paddingHorizontal}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"center\"\n gap={sizeStyles.gap}\n backgroundColor={bgColor}\n {...(isSeparated\n ? {\n borderWidth: theme.shape.toggleButtonGroup[size].borderWidth,\n borderColor: borderColor,\n borderStyle: \"solid\",\n borderRadius: sizeStyles.borderRadius,\n }\n : {\n borderWidth: theme.shape.toggleButtonGroup[size].borderWidth,\n borderColor: borderColor,\n borderStyle: \"solid\",\n })}\n cursor={isDisabled ? \"not-allowed\" : \"pointer\"}\n hoverStyle={\n !isDisabled && !isActive\n ? {\n backgroundColor: toggleColors.bgHover,\n borderColor: toggleColors.borderHover,\n }\n : undefined\n }\n style={{\n flexShrink: 0,\n ...(!isSeparated &&\n getUnitedItemCornerStyle(\n index,\n items.length,\n sizeStyles.borderRadius,\n isVertical\n )),\n ...(!isSeparated &&\n !isVertical &&\n index < items.length - 1 && { marginRight: -1 }),\n ...(!isSeparated &&\n isVertical &&\n index < items.length - 1 && { marginBottom: -1 }),\n }}\n >\n {item.iconLeft &&\n cloneIconWithDefaults(\n item.iconLeft,\n sizeStyles.iconSize,\n textColor\n )}\n {item.label && (\n <Text\n color={textColor}\n fontSize={sizeStyles.fontSize}\n fontWeight=\"400\"\n textAlign=\"center\"\n whiteSpace=\"nowrap\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n style={{\n lineHeight: `${sizeStyles.lineHeight}px`,\n }}\n >\n {item.label}\n </Text>\n )}\n {item.iconRight &&\n cloneIconWithDefaults(\n item.iconRight,\n sizeStyles.iconSize,\n textColor\n )}\n </Box>\n );\n\n if (!item.tooltip || !isWeb) {\n return <React.Fragment key={item.id}>{button}</React.Fragment>;\n }\n\n const defaultTooltipPlacement = isVertical ? \"right\" : \"top\";\n\n return (\n <Tooltip\n key={item.id}\n {...item.tooltip}\n placement={item.tooltip.placement ?? defaultTooltipPlacement}\n size={item.tooltip.size ?? sizeStyles.tooltipSize}\n style={\n fullWidth\n ? { flex: 1, ...item.tooltip.style }\n : item.tooltip.style\n }\n >\n {button}\n </Tooltip>\n );\n })}\n </Box>\n );\n};\n\nToggleButtonGroup.displayName = \"ToggleButtonGroup\";\n","import React from \"react\";\nimport {\n View,\n Pressable,\n Image,\n ViewStyle,\n ImageStyle,\n DimensionValue,\n AnimatableNumericValue,\n AccessibilityRole,\n} from \"react-native\";\nimport { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nconst roleToAccessibilityRole: Record<string, AccessibilityRole> = {\n button: \"button\",\n link: \"link\",\n img: \"image\",\n image: \"image\",\n summary: \"summary\",\n switch: \"switch\",\n checkbox: \"checkbox\",\n radio: \"radio\",\n heading: \"header\",\n text: \"text\",\n search: \"search\",\n alert: \"alert\",\n none: \"none\",\n presentation: \"none\",\n progressbar: \"progressbar\",\n scrollbar: \"scrollbar\",\n adjustable: \"adjustable\",\n tab: \"tab\",\n menu: \"menu\",\n menuitem: \"menuitem\",\n list: \"list\",\n timer: \"timer\",\n};\n\n/** RN ViewStyle.gap is typed as number (Yoga gap), not DimensionValue. */\nconst toGapValue = (gap: number | string | undefined): number | undefined => {\n if (gap === undefined) return undefined;\n if (typeof gap === \"number\") return gap;\n const pxMatch = /^(\\d+(?:\\.\\d+)?)px$/.exec(gap);\n if (pxMatch) return Number(pxMatch[1]);\n const asNumber = Number(gap);\n return Number.isFinite(asNumber) ? asNumber : undefined;\n};\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 flexWrap,\n alignItems,\n justifyContent,\n alignSelf,\n position,\n top,\n bottom,\n left,\n right,\n width,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flex,\n flexShrink,\n gap,\n overflow,\n opacity,\n zIndex,\n hoverStyle,\n pressStyle,\n style,\n disabled,\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 opacity: opacity ?? (disabled ? 0.5 : undefined),\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 flexWrap,\n alignItems,\n justifyContent,\n alignSelf,\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 flexShrink,\n gap: toGapValue(gap),\n ...(style as ViewStyle),\n });\n\n const finalTestID = dataTestId || testID;\n\n // Map web a11y props; drop the rest of the web-only attributes before\n // spreading onto RN hosts (unknown props warn at runtime).\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 \"aria-busy\": ariaBusy,\n className,\n \"data-testid\": _dataTestId,\n cursor: _cursor,\n type: _type,\n ...nativeRest\n } = rest as Record<string, unknown>;\n\n const accessibilityRole =\n (typeof role === \"string\" && roleToAccessibilityRole[role]) ||\n (as === \"button\" ? \"button\" : undefined);\n const isDisabled = Boolean(disabled || ariaDisabled);\n const accessibilityState = {\n disabled: isDisabled || undefined,\n busy: Boolean(ariaBusy) || undefined,\n };\n const accessibilityLiveRegion =\n ariaLive === \"polite\" || ariaLive === \"assertive\" ? ariaLive : undefined;\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 accessibilityLabel={typeof ariaLabel === \"string\" ? ariaLabel : alt}\n resizeMode=\"cover\"\n {...nativeRest}\n />\n );\n }\n\n // Prefer Pressable whenever the node is interactive or explicitly a button,\n // so disabled / aria-disabled controls stay in the a11y tree as buttons.\n if (onPress || as === \"button\") {\n return (\n <Pressable\n onPress={!isDisabled && onPress ? onPress : undefined}\n disabled={isDisabled}\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 accessibilityRole={accessibilityRole}\n accessibilityLabel={\n typeof ariaLabel === \"string\" ? ariaLabel : undefined\n }\n accessibilityState={accessibilityState}\n accessibilityLiveRegion={accessibilityLiveRegion}\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 accessibilityRole={accessibilityRole}\n accessibilityLabel={typeof ariaLabel === \"string\" ? ariaLabel : undefined}\n accessibilityState={accessibilityState}\n accessibilityLiveRegion={accessibilityLiveRegion}\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 testID,\n \"data-testid\": dataTestId,\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={dataTestId || testID || id}\n accessibilityRole={accessibilityRole}\n >\n {children}\n </RNText>\n );\n};\n","export * from \"./Box\";\nexport * from \"./Text\";\nexport * from \"./Spinner\";\nexport * from \"./Icon\";\nexport * from \"./Divider\";\nexport * from \"./Input\";\nexport * from \"./TextArea\";\nexport * from \"./LinearGradient\";\n\nexport const isWeb = false;\nexport const isNative = true;\n"],"mappings":";AAAA,OAAO,SAAS,aAAa,QAAQ,gBAAgB;;;AC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3B,iBAAO,gBAAAA,KAAC,MAAM,UAAN,EAA8B,oBAAV,KAAK,EAAY;AAAA,QAC/C;AAEA,cAAM,0BAA0B,aAAa,UAAU;AAEvD,eACE,gBAAAA;AAAA,UAAC;AAAA;AAAA,YAEE,GAAG,KAAK;AAAA,YACT,WAAW,KAAK,QAAQ,aAAa;AAAA,YACrC,MAAM,KAAK,QAAQ,QAAQ,WAAW;AAAA,YACtC,OACE,YACI,EAAE,MAAM,GAAG,GAAG,KAAK,QAAQ,MAAM,IACjC,KAAK,QAAQ;AAAA,YAGlB;AAAA;AAAA,UAVI,KAAK;AAAA,QAWZ;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,kBAAkB,cAAc;","names":["jsx","jsx"]}
1
+ {"version":3,"sources":["../../src/ToggleButtonGroup.tsx","../../../../foundation/primitives-native/src/Box.tsx","../../../../foundation/primitives-native/src/Text.tsx","../../../../foundation/primitives-native/src/index.tsx"],"sourcesContent":["import React, { useCallback, useRef, useState } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Box, Text, isWeb } from \"@xsolla/xui-primitives\";\nimport { useResolvedTheme } from \"@xsolla/xui-core\";\nimport { Tooltip } from \"@xsolla/xui-tooltip\";\nimport type {\n ToggleButtonGroupItem,\n ToggleButtonGroupProps,\n} from \"./types\";\n\n/**\n * Opacity applied to a `locked` item while the theme carries no dedicated\n * locked tokens.\n *\n * A locked item keeps the *active* fill, text and border — so it still reads as\n * ON — and is dimmed as a whole to signal that it is not interactive. Dimming\n * the element (rather than swapping in the disable palette) preserves the\n * text-on-fill contrast ratio; only the contrast against the page drops, which\n * is the conventional treatment for a non-interactive control.\n *\n * Once design lands `bgActiveDisable` / `textActiveDisable` /\n * `borderActiveDisable` in `theme.colors.control.toggleButton`, those values\n * are used verbatim and this opacity is not applied — see `lockedColors` below.\n */\nconst LOCKED_OPACITY = 0.6;\n\n/** A locked item is selected and immutable; `locked` wins over `disabled`. */\nconst isItemLocked = (item: ToggleButtonGroupItem) => Boolean(item.locked);\n\n/** Disabled in the native sense: inert *and* not keyboard-reachable. */\nconst isItemDisabled = (item: ToggleButtonGroupItem) =>\n Boolean(item.disabled) && !isItemLocked(item);\n\n/** Can the item's selection be changed by the user? */\nconst isItemInteractive = (item: ToggleButtonGroupItem) =>\n !isItemDisabled(item) && !isItemLocked(item);\n\n/**\n * Can the item receive keyboard focus? Locked items can — that is how a\n * keyboard user reaches the tooltip explaining why the item is locked.\n */\nconst isItemFocusable = (item: ToggleButtonGroupItem) => !isItemDisabled(item);\n\nconst cloneIconWithDefaults = (\n icon: React.ReactNode,\n defaultSize: number,\n defaultColor: string\n): React.ReactNode => {\n if (!React.isValidElement(icon)) return icon;\n\n const iconElement = icon as React.ReactElement<Record<string, unknown>>;\n const existingProps = iconElement.props || {};\n\n return React.cloneElement(iconElement, {\n ...existingProps,\n size: existingProps.size ?? defaultSize,\n color: existingProps.color ?? defaultColor,\n });\n};\n\nconst getUnitedItemCornerStyle = (\n index: number,\n total: number,\n borderRadius: number,\n isVertical: boolean\n): React.CSSProperties => {\n const isFirst = index === 0;\n const isLast = index === total - 1;\n if (!isFirst && !isLast) return {};\n\n const radius = `${borderRadius}px`;\n\n if (isVertical) {\n return {\n ...(isFirst && {\n borderTopLeftRadius: radius,\n borderTopRightRadius: radius,\n }),\n ...(isLast && {\n borderBottomLeftRadius: radius,\n borderBottomRightRadius: radius,\n }),\n };\n }\n\n return {\n ...(isFirst && {\n borderTopLeftRadius: radius,\n borderBottomLeftRadius: radius,\n }),\n ...(isLast && {\n borderTopRightRadius: radius,\n borderBottomRightRadius: radius,\n }),\n };\n};\n\n/**\n * ToggleButtonGroup - A control for picking one or several options from a set\n *\n * Used to pick one or several options from a linear set of closely related options.\n * Can be used to filter or to sort elements.\n *\n * ## Item states\n *\n * - **Default / active** — selection driven by `value` / `defaultValue`.\n * - **`disabled`** — inert and not focusable; painted with the disable palette.\n * - **`locked`** — selected and immutable: painted with the *active* palette,\n * dimmed, inert, but still keyboard-focusable so its `tooltip` is reachable.\n *\n * ## Accessibility Features\n *\n * - **Role**: Uses `role=\"radiogroup\"` for single selection, `role=\"group\"` for multiple\n * - **Keyboard Navigation**: Arrow keys to navigate, Enter/Space to select\n * - **ARIA**: Proper aria-checked and aria-disabled states\n */\nexport const ToggleButtonGroup: React.FC<ToggleButtonGroupProps> = ({\n items,\n value,\n defaultValue,\n onChange,\n size = \"sm\",\n appearance = \"separated\",\n view = \"horizontal\",\n multiple = false,\n id,\n testID,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n fullWidth = false,\n themeMode,\n themeProductContext,\n}) => {\n const { theme } = useResolvedTheme({ themeMode, themeProductContext });\n const sizeStyles = theme.sizing.toggleButtonGroup(size);\n const itemRefs = useRef<(HTMLElement | null)[]>([]);\n\n const toggleColors = theme.colors.control.toggleButton;\n\n /**\n * Locked-state tokens are not in the Figma token export yet. Read them\n * optionally so the component picks them up automatically once design adds\n * them to `control.toggleButton`, with no further code change.\n */\n const lockedColors = toggleColors as typeof toggleColors & {\n bgActiveDisable?: string;\n textActiveDisable?: string;\n borderActiveDisable?: string;\n };\n\n const hasLockedTokens = Boolean(\n lockedColors.bgActiveDisable ??\n lockedColors.textActiveDisable ??\n lockedColors.borderActiveDisable\n );\n\n const [internalValue, setInternalValue] = useState<string[]>(() => {\n if (defaultValue !== undefined) {\n return Array.isArray(defaultValue) ? defaultValue : [defaultValue];\n }\n return [];\n });\n\n const currentValue =\n value !== undefined\n ? Array.isArray(value)\n ? value\n : [value]\n : internalValue;\n\n const isItemActive = (item: ToggleButtonGroupItem) =>\n currentValue.includes(item.id) || isItemLocked(item);\n\n const focusableIndices = items\n .map((item, index) => (isItemFocusable(item) ? 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 handleSelect = useCallback(\n (itemId: string) => {\n let newValue: string[];\n\n if (multiple) {\n if (currentValue.includes(itemId)) {\n newValue = currentValue.filter((v) => v !== itemId);\n } else {\n newValue = [...currentValue, itemId];\n }\n } else {\n newValue = [itemId];\n }\n\n if (value === undefined) {\n setInternalValue(newValue);\n }\n\n if (onChange) {\n if (multiple) {\n onChange(newValue);\n } else {\n onChange(newValue[0] || \"\");\n }\n }\n },\n [currentValue, multiple, value, onChange]\n );\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent, currentIndex: number) => {\n const currentFocusableIndex = focusableIndices.indexOf(currentIndex);\n\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n e.preventDefault();\n {\n const nextFocusableIndex =\n currentFocusableIndex < focusableIndices.length - 1\n ? focusableIndices[currentFocusableIndex + 1]\n : focusableIndices[0];\n focusItem(nextFocusableIndex);\n }\n break;\n\n case \"ArrowLeft\":\n case \"ArrowUp\":\n e.preventDefault();\n {\n const prevFocusableIndex =\n currentFocusableIndex > 0\n ? focusableIndices[currentFocusableIndex - 1]\n : focusableIndices[focusableIndices.length - 1];\n focusItem(prevFocusableIndex);\n }\n break;\n\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (isItemInteractive(items[currentIndex])) {\n handleSelect(items[currentIndex].id);\n }\n break;\n\n default:\n break;\n }\n },\n [focusableIndices, focusItem, handleSelect, items]\n );\n\n const isSeparated = appearance === \"separated\";\n const isVertical = view === \"vertical\";\n const containerGap = isSeparated ? sizeStyles.itemGap : 0;\n\n // Determine first active item for tabindex in single selection mode\n const firstActiveIndex = items.findIndex((item) => isItemActive(item));\n const firstFocusableIndex = focusableIndices[0] ?? 0;\n\n return (\n <Box\n id={id}\n role={multiple ? \"group\" : \"radiogroup\"}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n testID={testID}\n flexDirection={isVertical ? \"column\" : \"row\"}\n alignItems=\"stretch\"\n flexWrap={isSeparated && !isVertical ? \"wrap\" : \"nowrap\"}\n gap={containerGap}\n width={fullWidth ? \"100%\" : \"fit-content\"}\n {...(!isSeparated && {\n borderRadius: sizeStyles.borderRadius,\n overflow: \"hidden\",\n })}\n >\n {items.map((item, index) => {\n const isLocked = isItemLocked(item);\n const isDisabled = isItemDisabled(item);\n const isInteractive = isItemInteractive(item);\n const isFocusable = isItemFocusable(item);\n const isActive = isItemActive(item);\n const itemId = id ? `${id}-item-${item.id}` : undefined;\n\n let tabIndex: number;\n if (!isFocusable) {\n tabIndex = -1;\n } else if (multiple) {\n // In multiple mode, all focusable items are tabbable\n tabIndex = 0;\n } else {\n // In single mode, only the active item (or first focusable if none active) is tabbable\n tabIndex =\n isActive ||\n (firstActiveIndex === -1 && index === firstFocusableIndex)\n ? 0\n : -1;\n }\n\n const handlePress = () => {\n if (isInteractive) {\n handleSelect(item.id);\n }\n };\n\n const bgColor = isLocked\n ? (lockedColors.bgActiveDisable ?? toggleColors.bgActive)\n : isDisabled\n ? toggleColors.bgDisable\n : isActive\n ? toggleColors.bgActive\n : toggleColors.bg;\n\n const textColor = isLocked\n ? (lockedColors.textActiveDisable ?? toggleColors.textActive)\n : isDisabled\n ? toggleColors.textDisable\n : isActive\n ? toggleColors.textActive\n : toggleColors.text;\n\n const borderColor = isLocked\n ? (lockedColors.borderActiveDisable ?? toggleColors.borderActive)\n : isDisabled\n ? toggleColors.borderDisable\n : isActive\n ? toggleColors.borderActive\n : toggleColors.border;\n\n const button = (\n <Box\n as=\"button\"\n role={multiple ? \"checkbox\" : \"radio\"}\n id={itemId}\n testID={item.testID}\n aria-checked={isActive}\n aria-disabled={isDisabled || isLocked}\n aria-label={item[\"aria-label\"] || item.label}\n tabIndex={tabIndex}\n // A locked item deliberately omits the native `disabled` attribute\n // so it stays focusable and its tooltip is reachable by keyboard.\n disabled={isDisabled}\n ref={(el: HTMLElement | null) => {\n itemRefs.current[index] = el;\n }}\n onPress={handlePress}\n onKeyDown={(e: React.KeyboardEvent) => handleKeyDown(e, index)}\n flex={fullWidth ? 1 : undefined}\n height={sizeStyles.height}\n paddingHorizontal={sizeStyles.paddingHorizontal}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"center\"\n gap={sizeStyles.gap}\n backgroundColor={bgColor}\n {...(isSeparated\n ? {\n borderWidth: theme.shape.toggleButtonGroup[size].borderWidth,\n borderColor: borderColor,\n borderStyle: \"solid\",\n borderRadius: sizeStyles.borderRadius,\n }\n : {\n borderWidth: theme.shape.toggleButtonGroup[size].borderWidth,\n borderColor: borderColor,\n borderStyle: \"solid\",\n })}\n cursor={isInteractive ? \"pointer\" : \"not-allowed\"}\n hoverStyle={\n isInteractive && !isActive\n ? {\n backgroundColor: toggleColors.bgHover,\n borderColor: toggleColors.borderHover,\n }\n : undefined\n }\n style={{\n flexShrink: 0,\n ...(isLocked && !hasLockedTokens && { opacity: LOCKED_OPACITY }),\n ...(!isSeparated &&\n getUnitedItemCornerStyle(\n index,\n items.length,\n sizeStyles.borderRadius,\n isVertical\n )),\n ...(!isSeparated &&\n !isVertical &&\n index < items.length - 1 && { marginRight: -1 }),\n ...(!isSeparated &&\n isVertical &&\n index < items.length - 1 && { marginBottom: -1 }),\n }}\n >\n {item.iconLeft &&\n cloneIconWithDefaults(\n item.iconLeft,\n sizeStyles.iconSize,\n textColor\n )}\n {item.label && (\n <Text\n color={textColor}\n fontSize={sizeStyles.fontSize}\n fontWeight=\"400\"\n textAlign=\"center\"\n whiteSpace=\"nowrap\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n style={{\n lineHeight: `${sizeStyles.lineHeight}px`,\n }}\n >\n {item.label}\n </Text>\n )}\n {item.iconRight &&\n cloneIconWithDefaults(\n item.iconRight,\n sizeStyles.iconSize,\n textColor\n )}\n </Box>\n );\n\n if (!item.tooltip || !isWeb) {\n return <React.Fragment key={item.id}>{button}</React.Fragment>;\n }\n\n const defaultTooltipPlacement = isVertical ? \"right\" : \"top\";\n\n return (\n <Tooltip\n key={item.id}\n {...item.tooltip}\n placement={item.tooltip.placement ?? defaultTooltipPlacement}\n size={item.tooltip.size ?? sizeStyles.tooltipSize}\n style={\n fullWidth\n ? { flex: 1, ...item.tooltip.style }\n : item.tooltip.style\n }\n >\n {button}\n </Tooltip>\n );\n })}\n </Box>\n );\n};\n\nToggleButtonGroup.displayName = \"ToggleButtonGroup\";\n","import React from \"react\";\nimport {\n View,\n Pressable,\n Image,\n ViewStyle,\n ImageStyle,\n DimensionValue,\n AnimatableNumericValue,\n AccessibilityRole,\n} from \"react-native\";\nimport { BoxProps } from \"@xsolla/xui-primitives-core\";\n\nconst roleToAccessibilityRole: Record<string, AccessibilityRole> = {\n button: \"button\",\n link: \"link\",\n img: \"image\",\n image: \"image\",\n summary: \"summary\",\n switch: \"switch\",\n checkbox: \"checkbox\",\n radio: \"radio\",\n heading: \"header\",\n text: \"text\",\n search: \"search\",\n alert: \"alert\",\n none: \"none\",\n presentation: \"none\",\n progressbar: \"progressbar\",\n scrollbar: \"scrollbar\",\n adjustable: \"adjustable\",\n tab: \"tab\",\n menu: \"menu\",\n menuitem: \"menuitem\",\n list: \"list\",\n timer: \"timer\",\n};\n\n/** RN ViewStyle.gap is typed as number (Yoga gap), not DimensionValue. */\nconst toGapValue = (gap: number | string | undefined): number | undefined => {\n if (gap === undefined) return undefined;\n if (typeof gap === \"number\") return gap;\n const pxMatch = /^(\\d+(?:\\.\\d+)?)px$/.exec(gap);\n if (pxMatch) return Number(pxMatch[1]);\n const asNumber = Number(gap);\n return Number.isFinite(asNumber) ? asNumber : undefined;\n};\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 flexWrap,\n alignItems,\n justifyContent,\n alignSelf,\n position,\n top,\n bottom,\n left,\n right,\n width,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flex,\n flexShrink,\n gap,\n overflow,\n opacity,\n zIndex,\n hoverStyle,\n pressStyle,\n style,\n disabled,\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 opacity: opacity ?? (disabled ? 0.5 : undefined),\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 flexWrap,\n alignItems,\n justifyContent,\n alignSelf,\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 flexShrink,\n gap: toGapValue(gap),\n ...(style as ViewStyle),\n });\n\n const finalTestID = dataTestId || testID;\n\n // Map web a11y props; drop the rest of the web-only attributes before\n // spreading onto RN hosts (unknown props warn at runtime).\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 \"aria-busy\": ariaBusy,\n className,\n \"data-testid\": _dataTestId,\n cursor: _cursor,\n type: _type,\n ...nativeRest\n } = rest as Record<string, unknown>;\n\n const accessibilityRole =\n (typeof role === \"string\" && roleToAccessibilityRole[role]) ||\n (as === \"button\" ? \"button\" : undefined);\n const isDisabled = Boolean(disabled || ariaDisabled);\n const accessibilityState = {\n disabled: isDisabled || undefined,\n busy: Boolean(ariaBusy) || undefined,\n };\n const accessibilityLiveRegion =\n ariaLive === \"polite\" || ariaLive === \"assertive\" ? ariaLive : undefined;\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 accessibilityLabel={typeof ariaLabel === \"string\" ? ariaLabel : alt}\n resizeMode=\"cover\"\n {...nativeRest}\n />\n );\n }\n\n // Prefer Pressable whenever the node is interactive or explicitly a button,\n // so disabled / aria-disabled controls stay in the a11y tree as buttons.\n if (onPress || as === \"button\") {\n return (\n <Pressable\n onPress={!isDisabled && onPress ? onPress : undefined}\n disabled={isDisabled}\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 accessibilityRole={accessibilityRole}\n accessibilityLabel={\n typeof ariaLabel === \"string\" ? ariaLabel : undefined\n }\n accessibilityState={accessibilityState}\n accessibilityLiveRegion={accessibilityLiveRegion}\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 accessibilityRole={accessibilityRole}\n accessibilityLabel={typeof ariaLabel === \"string\" ? ariaLabel : undefined}\n accessibilityState={accessibilityState}\n accessibilityLiveRegion={accessibilityLiveRegion}\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 testID,\n \"data-testid\": dataTestId,\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={dataTestId || testID || id}\n accessibilityRole={accessibilityRole}\n >\n {children}\n </RNText>\n );\n};\n","export * from \"./Box\";\nexport * from \"./Text\";\nexport * from \"./Spinner\";\nexport * from \"./Icon\";\nexport * from \"./Divider\";\nexport * from \"./Input\";\nexport * from \"./TextArea\";\nexport * from \"./LinearGradient\";\n\nexport const isWeb = false;\nexport const isNative = true;\n"],"mappings":";AAAA,OAAO,SAAS,aAAa,QAAQ,gBAAgB;;;ACCrD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAwMD;AArMN,IAAM,0BAA6D;AAAA,EACjE,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,cAAc;AAAA,EACd,aAAa;AAAA,EACb,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,KAAK;AAAA,EACL,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,OAAO;AACT;AAGA,IAAM,aAAa,CAAC,QAAyD;AAC3E,MAAI,QAAQ,OAAW,QAAO;AAC9B,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,UAAU,sBAAs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AAAA;AAAA;AAAA,QACJ;AAGF,YAAI,CAAC,KAAK,WAAW,CAAC,OAAO;AAC3B,iBAAO,gBAAAA,KAAC,MAAM,UAAN,EAA8B,oBAAV,KAAK,EAAY;AAAA,QAC/C;AAEA,cAAM,0BAA0B,aAAa,UAAU;AAEvD,eACE,gBAAAA;AAAA,UAAC;AAAA;AAAA,YAEE,GAAG,KAAK;AAAA,YACT,WAAW,KAAK,QAAQ,aAAa;AAAA,YACrC,MAAM,KAAK,QAAQ,QAAQ,WAAW;AAAA,YACtC,OACE,YACI,EAAE,MAAM,GAAG,GAAG,KAAK,QAAQ,MAAM,IACjC,KAAK,QAAQ;AAAA,YAGlB;AAAA;AAAA,UAVI,KAAK;AAAA,QAWZ;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,kBAAkB,cAAc;","names":["jsx","jsx"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-toggle-button-group",
3
- "version": "0.216.0",
3
+ "version": "0.217.0",
4
4
  "main": "./web/index.js",
5
5
  "module": "./web/index.mjs",
6
6
  "types": "./web/index.d.ts",
@@ -10,9 +10,9 @@
10
10
  "build:native": "PLATFORM=native tsup"
11
11
  },
12
12
  "dependencies": {
13
- "@xsolla/xui-core": "0.216.0",
14
- "@xsolla/xui-primitives-core": "0.216.0",
15
- "@xsolla/xui-tooltip": "0.216.0"
13
+ "@xsolla/xui-core": "0.217.0",
14
+ "@xsolla/xui-primitives-core": "0.217.0",
15
+ "@xsolla/xui-tooltip": "0.217.0"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": ">=16.8.0",
package/web/index.d.mts CHANGED
@@ -18,6 +18,29 @@ interface ToggleButtonGroupItem {
18
18
  iconRight?: React.ReactNode;
19
19
  /** Whether the item is disabled */
20
20
  disabled?: boolean;
21
+ /**
22
+ * Whether the item is **locked**: selected and immutable.
23
+ *
24
+ * Use for an irreversible opt-in — a capability that, once switched on, can
25
+ * never be switched off (an OS a launcher already supports, a plan feature
26
+ * that cannot be dropped, a mandatory permission scope, a region already
27
+ * launched).
28
+ *
29
+ * A locked item:
30
+ * - renders with the *active* palette, dimmed — so it still reads as ON,
31
+ * unlike `disabled`, which paints a selected item in the disable palette
32
+ * and loses the "on" signal entirely;
33
+ * - is implicitly active; it does not need to be present in `value`
34
+ * (although including it is harmless and recommended for clarity);
35
+ * - ignores clicks, Enter and Space, and never fires `onChange`;
36
+ * - stays keyboard-focusable (`aria-disabled="true"` + `tabIndex={0}`, no
37
+ * native `disabled` attribute), so a keyboard user can reach its
38
+ * `tooltip` and learn *why* it is locked. This is the focusable-disabled
39
+ * pattern, and is the main behavioural difference from `disabled`.
40
+ *
41
+ * Takes precedence over `disabled` when both are set.
42
+ */
43
+ locked?: boolean;
21
44
  /** Test ID applied as `data-testid` on the item's button root */
22
45
  testID?: string;
23
46
  /** Accessible label for screen readers */
@@ -62,6 +85,13 @@ interface ToggleButtonGroupProps extends ThemeOverrideProps {
62
85
  * Used to pick one or several options from a linear set of closely related options.
63
86
  * Can be used to filter or to sort elements.
64
87
  *
88
+ * ## Item states
89
+ *
90
+ * - **Default / active** — selection driven by `value` / `defaultValue`.
91
+ * - **`disabled`** — inert and not focusable; painted with the disable palette.
92
+ * - **`locked`** — selected and immutable: painted with the *active* palette,
93
+ * dimmed, inert, but still keyboard-focusable so its `tooltip` is reachable.
94
+ *
65
95
  * ## Accessibility Features
66
96
  *
67
97
  * - **Role**: Uses `role="radiogroup"` for single selection, `role="group"` for multiple
package/web/index.d.ts CHANGED
@@ -18,6 +18,29 @@ interface ToggleButtonGroupItem {
18
18
  iconRight?: React.ReactNode;
19
19
  /** Whether the item is disabled */
20
20
  disabled?: boolean;
21
+ /**
22
+ * Whether the item is **locked**: selected and immutable.
23
+ *
24
+ * Use for an irreversible opt-in — a capability that, once switched on, can
25
+ * never be switched off (an OS a launcher already supports, a plan feature
26
+ * that cannot be dropped, a mandatory permission scope, a region already
27
+ * launched).
28
+ *
29
+ * A locked item:
30
+ * - renders with the *active* palette, dimmed — so it still reads as ON,
31
+ * unlike `disabled`, which paints a selected item in the disable palette
32
+ * and loses the "on" signal entirely;
33
+ * - is implicitly active; it does not need to be present in `value`
34
+ * (although including it is harmless and recommended for clarity);
35
+ * - ignores clicks, Enter and Space, and never fires `onChange`;
36
+ * - stays keyboard-focusable (`aria-disabled="true"` + `tabIndex={0}`, no
37
+ * native `disabled` attribute), so a keyboard user can reach its
38
+ * `tooltip` and learn *why* it is locked. This is the focusable-disabled
39
+ * pattern, and is the main behavioural difference from `disabled`.
40
+ *
41
+ * Takes precedence over `disabled` when both are set.
42
+ */
43
+ locked?: boolean;
21
44
  /** Test ID applied as `data-testid` on the item's button root */
22
45
  testID?: string;
23
46
  /** Accessible label for screen readers */
@@ -62,6 +85,13 @@ interface ToggleButtonGroupProps extends ThemeOverrideProps {
62
85
  * Used to pick one or several options from a linear set of closely related options.
63
86
  * Can be used to filter or to sort elements.
64
87
  *
88
+ * ## Item states
89
+ *
90
+ * - **Default / active** — selection driven by `value` / `defaultValue`.
91
+ * - **`disabled`** — inert and not focusable; painted with the disable palette.
92
+ * - **`locked`** — selected and immutable: painted with the *active* palette,
93
+ * dimmed, inert, but still keyboard-focusable so its `tooltip` is reachable.
94
+ *
65
95
  * ## Accessibility Features
66
96
  *
67
97
  * - **Role**: Uses `role="radiogroup"` for single selection, `role="group"` for multiple
package/web/index.js CHANGED
@@ -375,6 +375,11 @@ var isWeb = true;
375
375
  var import_xui_core = require("@xsolla/xui-core");
376
376
  var import_xui_tooltip = require("@xsolla/xui-tooltip");
377
377
  var import_jsx_runtime3 = require("react/jsx-runtime");
378
+ var LOCKED_OPACITY = 0.6;
379
+ var isItemLocked = (item) => Boolean(item.locked);
380
+ var isItemDisabled = (item) => Boolean(item.disabled) && !isItemLocked(item);
381
+ var isItemInteractive = (item) => !isItemDisabled(item) && !isItemLocked(item);
382
+ var isItemFocusable = (item) => !isItemDisabled(item);
378
383
  var cloneIconWithDefaults = (icon, defaultSize, defaultColor) => {
379
384
  if (!import_react3.default.isValidElement(icon)) return icon;
380
385
  const iconElement = icon;
@@ -433,6 +438,11 @@ var ToggleButtonGroup = ({
433
438
  const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
434
439
  const sizeStyles = theme.sizing.toggleButtonGroup(size);
435
440
  const itemRefs = (0, import_react3.useRef)([]);
441
+ const toggleColors = theme.colors.control.toggleButton;
442
+ const lockedColors = toggleColors;
443
+ const hasLockedTokens = Boolean(
444
+ lockedColors.bgActiveDisable ?? lockedColors.textActiveDisable ?? lockedColors.borderActiveDisable
445
+ );
436
446
  const [internalValue, setInternalValue] = (0, import_react3.useState)(() => {
437
447
  if (defaultValue !== void 0) {
438
448
  return Array.isArray(defaultValue) ? defaultValue : [defaultValue];
@@ -440,8 +450,8 @@ var ToggleButtonGroup = ({
440
450
  return [];
441
451
  });
442
452
  const currentValue = value !== void 0 ? Array.isArray(value) ? value : [value] : internalValue;
443
- const isItemActive = (itemId) => currentValue.includes(itemId);
444
- const enabledIndices = items.map((item, index2) => !item.disabled ? index2 : -1).filter((i) => i !== -1);
453
+ const isItemActive = (item) => currentValue.includes(item.id) || isItemLocked(item);
454
+ const focusableIndices = items.map((item, index2) => isItemFocusable(item) ? index2 : -1).filter((i) => i !== -1);
445
455
  const focusItem = (0, import_react3.useCallback)((index2) => {
446
456
  const element = itemRefs.current[index2];
447
457
  if (element) {
@@ -475,28 +485,28 @@ var ToggleButtonGroup = ({
475
485
  );
476
486
  const handleKeyDown = (0, import_react3.useCallback)(
477
487
  (e, currentIndex) => {
478
- const currentEnabledIndex = enabledIndices.indexOf(currentIndex);
488
+ const currentFocusableIndex = focusableIndices.indexOf(currentIndex);
479
489
  switch (e.key) {
480
490
  case "ArrowRight":
481
491
  case "ArrowDown":
482
492
  e.preventDefault();
483
493
  {
484
- const nextEnabledIndex = currentEnabledIndex < enabledIndices.length - 1 ? enabledIndices[currentEnabledIndex + 1] : enabledIndices[0];
485
- focusItem(nextEnabledIndex);
494
+ const nextFocusableIndex = currentFocusableIndex < focusableIndices.length - 1 ? focusableIndices[currentFocusableIndex + 1] : focusableIndices[0];
495
+ focusItem(nextFocusableIndex);
486
496
  }
487
497
  break;
488
498
  case "ArrowLeft":
489
499
  case "ArrowUp":
490
500
  e.preventDefault();
491
501
  {
492
- const prevEnabledIndex = currentEnabledIndex > 0 ? enabledIndices[currentEnabledIndex - 1] : enabledIndices[enabledIndices.length - 1];
493
- focusItem(prevEnabledIndex);
502
+ const prevFocusableIndex = currentFocusableIndex > 0 ? focusableIndices[currentFocusableIndex - 1] : focusableIndices[focusableIndices.length - 1];
503
+ focusItem(prevFocusableIndex);
494
504
  }
495
505
  break;
496
506
  case "Enter":
497
507
  case " ":
498
508
  e.preventDefault();
499
- if (!items[currentIndex].disabled) {
509
+ if (isItemInteractive(items[currentIndex])) {
500
510
  handleSelect(items[currentIndex].id);
501
511
  }
502
512
  break;
@@ -504,15 +514,13 @@ var ToggleButtonGroup = ({
504
514
  break;
505
515
  }
506
516
  },
507
- [enabledIndices, focusItem, handleSelect, items]
517
+ [focusableIndices, focusItem, handleSelect, items]
508
518
  );
509
519
  const isSeparated = appearance === "separated";
510
520
  const isVertical = view === "vertical";
511
521
  const containerGap = isSeparated ? sizeStyles.itemGap : 0;
512
- const firstActiveIndex = items.findIndex(
513
- (item) => currentValue.includes(item.id)
514
- );
515
- const firstEnabledIndex = enabledIndices[0] ?? 0;
522
+ const firstActiveIndex = items.findIndex((item) => isItemActive(item));
523
+ const firstFocusableIndex = focusableIndices[0] ?? 0;
516
524
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
517
525
  Box,
518
526
  {
@@ -531,26 +539,28 @@ var ToggleButtonGroup = ({
531
539
  overflow: "hidden"
532
540
  },
533
541
  children: items.map((item, index2) => {
534
- const isActive = isItemActive(item.id);
535
- const isDisabled = item.disabled;
542
+ const isLocked = isItemLocked(item);
543
+ const isDisabled = isItemDisabled(item);
544
+ const isInteractive = isItemInteractive(item);
545
+ const isFocusable = isItemFocusable(item);
546
+ const isActive = isItemActive(item);
536
547
  const itemId = id ? `${id}-item-${item.id}` : void 0;
537
548
  let tabIndex;
538
- if (isDisabled) {
549
+ if (!isFocusable) {
539
550
  tabIndex = -1;
540
551
  } else if (multiple) {
541
552
  tabIndex = 0;
542
553
  } else {
543
- tabIndex = isActive || firstActiveIndex === -1 && index2 === firstEnabledIndex ? 0 : -1;
554
+ tabIndex = isActive || firstActiveIndex === -1 && index2 === firstFocusableIndex ? 0 : -1;
544
555
  }
545
556
  const handlePress = () => {
546
- if (!isDisabled) {
557
+ if (isInteractive) {
547
558
  handleSelect(item.id);
548
559
  }
549
560
  };
550
- const toggleColors = theme.colors.control.toggleButton;
551
- const bgColor = isDisabled ? toggleColors.bgDisable : isActive ? toggleColors.bgActive : toggleColors.bg;
552
- const textColor = isDisabled ? toggleColors.textDisable : isActive ? toggleColors.textActive : toggleColors.text;
553
- const borderColor = isDisabled ? toggleColors.borderDisable : isActive ? toggleColors.borderActive : toggleColors.border;
561
+ const bgColor = isLocked ? lockedColors.bgActiveDisable ?? toggleColors.bgActive : isDisabled ? toggleColors.bgDisable : isActive ? toggleColors.bgActive : toggleColors.bg;
562
+ const textColor = isLocked ? lockedColors.textActiveDisable ?? toggleColors.textActive : isDisabled ? toggleColors.textDisable : isActive ? toggleColors.textActive : toggleColors.text;
563
+ const borderColor = isLocked ? lockedColors.borderActiveDisable ?? toggleColors.borderActive : isDisabled ? toggleColors.borderDisable : isActive ? toggleColors.borderActive : toggleColors.border;
554
564
  const button = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
555
565
  Box,
556
566
  {
@@ -559,7 +569,7 @@ var ToggleButtonGroup = ({
559
569
  id: itemId,
560
570
  testID: item.testID,
561
571
  "aria-checked": isActive,
562
- "aria-disabled": isDisabled,
572
+ "aria-disabled": isDisabled || isLocked,
563
573
  "aria-label": item["aria-label"] || item.label,
564
574
  tabIndex,
565
575
  disabled: isDisabled,
@@ -586,13 +596,14 @@ var ToggleButtonGroup = ({
586
596
  borderColor,
587
597
  borderStyle: "solid"
588
598
  },
589
- cursor: isDisabled ? "not-allowed" : "pointer",
590
- hoverStyle: !isDisabled && !isActive ? {
599
+ cursor: isInteractive ? "pointer" : "not-allowed",
600
+ hoverStyle: isInteractive && !isActive ? {
591
601
  backgroundColor: toggleColors.bgHover,
592
602
  borderColor: toggleColors.borderHover
593
603
  } : void 0,
594
604
  style: {
595
605
  flexShrink: 0,
606
+ ...isLocked && !hasLockedTokens && { opacity: LOCKED_OPACITY },
596
607
  ...!isSeparated && getUnitedItemCornerStyle(
597
608
  index2,
598
609
  items.length,