@xsolla/xui-status-dropdown 0.170.6 → 0.171.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/native/index.mjs CHANGED
@@ -282,7 +282,7 @@ var isWeb = false;
282
282
 
283
283
  // src/StatusDropdown.tsx
284
284
  import { useResolvedTheme } from "@xsolla/xui-core";
285
- import { Dropdown } from "@xsolla/xui-dropdown";
285
+ import { ContextMenu } from "@xsolla/xui-context-menu";
286
286
 
287
287
  // ../../foundation/icons-base/dist/web/index.mjs
288
288
  import styled from "styled-components";
@@ -1056,44 +1056,48 @@ var ChevronDown = (props) => /* @__PURE__ */ jsx127(BaseIcon, { ...props, solidC
1056
1056
 
1057
1057
  // src/StatusDropdown.tsx
1058
1058
  import { jsx as jsx722, jsxs } from "react/jsx-runtime";
1059
+ var gapMap = {
1060
+ xl: 4,
1061
+ lg: 4,
1062
+ md: 2,
1063
+ sm: 2,
1064
+ xs: 2
1065
+ };
1066
+ var dotSizeMap = {
1067
+ xl: 8,
1068
+ lg: 8,
1069
+ md: 8,
1070
+ sm: 4,
1071
+ xs: 4
1072
+ };
1059
1073
  var getPaletteColors = (palette, theme) => {
1060
1074
  const colors = theme.colors;
1061
1075
  switch (palette) {
1062
1076
  case "Success":
1063
1077
  return {
1064
- background: colors.background.success.primary,
1065
- border: colors.border.success,
1066
- content: colors.content.on.success
1078
+ background: colors.background.success.secondary,
1079
+ border: colors.border.success
1067
1080
  };
1068
1081
  case "Warning":
1069
1082
  return {
1070
- background: colors.background.warning.primary,
1071
- border: colors.border.warning,
1072
- content: colors.content.on.warning
1083
+ background: colors.background.warning.secondary,
1084
+ border: colors.border.warning
1073
1085
  };
1074
1086
  case "Alert":
1075
1087
  return {
1076
- background: colors.background.alert.primary,
1077
- border: colors.border.alert,
1078
- content: colors.content.on.alert
1079
- };
1080
- case "Neutral":
1081
- return {
1082
- background: colors.background.neutral.primary,
1083
- border: colors.border.neutral,
1084
- content: colors.content.on.neutral
1088
+ background: colors.background.alert.secondary,
1089
+ border: colors.border.alert
1085
1090
  };
1086
1091
  case "Brand":
1087
1092
  return {
1088
- background: colors.background.brand.primary,
1089
- border: colors.border.brand,
1090
- content: colors.content.on.brand
1093
+ background: colors.background.brand.secondary,
1094
+ border: colors.border.brand
1091
1095
  };
1096
+ case "Neutral":
1092
1097
  default:
1093
1098
  return {
1094
- background: colors.background.neutral.primary,
1095
- border: colors.border.neutral,
1096
- content: colors.content.on.neutral
1099
+ background: colors.background.neutral.secondary,
1100
+ border: colors.border.neutral
1097
1101
  };
1098
1102
  }
1099
1103
  };
@@ -1101,9 +1105,9 @@ var StatusDropdown = forwardRef(
1101
1105
  ({
1102
1106
  label,
1103
1107
  palette = "Neutral",
1108
+ size = "xs",
1104
1109
  dot = false,
1105
1110
  children,
1106
- onSelect,
1107
1111
  isOpen: propIsOpen,
1108
1112
  onOpenChange,
1109
1113
  "aria-label": ariaLabel,
@@ -1114,8 +1118,13 @@ var StatusDropdown = forwardRef(
1114
1118
  }, ref) => {
1115
1119
  const { theme } = useResolvedTheme({ themeMode, themeProductContext });
1116
1120
  const paletteColors = getPaletteColors(palette, theme);
1121
+ const contentColor = theme.colors.content.primary;
1122
+ const sizeStyles = theme.sizing.tag(size);
1123
+ const gap = gapMap[size];
1124
+ const dotSize = dotSizeMap[size];
1117
1125
  const [internalIsOpen, setInternalIsOpen] = useState(false);
1118
1126
  const isOpen = propIsOpen !== void 0 ? propIsOpen : internalIsOpen;
1127
+ const [isFocusVisible, setIsFocusVisible] = useState(false);
1119
1128
  const handleOpenChange = (open) => {
1120
1129
  if (onOpenChange) onOpenChange(open);
1121
1130
  if (propIsOpen === void 0) {
@@ -1125,26 +1134,64 @@ var StatusDropdown = forwardRef(
1125
1134
  const trigger = /* @__PURE__ */ jsxs(
1126
1135
  Box,
1127
1136
  {
1137
+ ref,
1138
+ id,
1128
1139
  role: "button",
1129
- "aria-haspopup": "listbox",
1140
+ tabIndex: 0,
1130
1141
  "aria-label": ariaLabel || `Status: ${label}`,
1131
1142
  testID: testID ? `${testID}-trigger` : void 0,
1143
+ onKeyDown: (event) => {
1144
+ if (event.key === "Enter" || event.key === " ") {
1145
+ event.preventDefault();
1146
+ handleOpenChange(!isOpen);
1147
+ } else if (event.key === "ArrowDown" && !isOpen) {
1148
+ event.preventDefault();
1149
+ handleOpenChange(true);
1150
+ }
1151
+ },
1152
+ position: "relative",
1132
1153
  flexDirection: "row",
1133
1154
  alignItems: "center",
1134
1155
  backgroundColor: paletteColors.background,
1135
1156
  borderColor: paletteColors.border,
1136
- borderWidth: 1,
1137
- borderRadius: 4,
1138
- height: 20,
1139
- paddingHorizontal: 3,
1140
- gap: 2,
1141
- style: isWeb ? { cursor: "pointer" } : void 0,
1157
+ borderWidth: sizeStyles.borderWidth,
1158
+ borderRadius: sizeStyles.radius,
1159
+ height: sizeStyles.height,
1160
+ paddingHorizontal: sizeStyles.padding,
1161
+ gap,
1162
+ ...isWeb ? {
1163
+ onFocus: (event) => {
1164
+ const target = event?.target;
1165
+ setIsFocusVisible(
1166
+ typeof target?.matches === "function" ? target.matches(":focus-visible") : true
1167
+ );
1168
+ },
1169
+ onBlur: () => setIsFocusVisible(false)
1170
+ } : {},
1171
+ style: isWeb ? {
1172
+ cursor: "pointer",
1173
+ outline: isFocusVisible ? `2px solid ${theme.colors.border.brand}` : "none",
1174
+ outlineOffset: isFocusVisible ? 2 : void 0
1175
+ } : void 0,
1142
1176
  children: [
1177
+ isWeb && /* @__PURE__ */ jsx722(
1178
+ Box,
1179
+ {
1180
+ "aria-hidden": true,
1181
+ position: "absolute",
1182
+ top: 0,
1183
+ left: 0,
1184
+ right: 0,
1185
+ bottom: 0,
1186
+ borderRadius: sizeStyles.radius,
1187
+ hoverStyle: { backgroundColor: theme.colors.overlay.mono }
1188
+ }
1189
+ ),
1143
1190
  dot && /* @__PURE__ */ jsx722(
1144
1191
  Box,
1145
1192
  {
1146
- width: 14,
1147
- height: 14,
1193
+ width: sizeStyles.iconSize,
1194
+ height: sizeStyles.iconSize,
1148
1195
  alignItems: "center",
1149
1196
  justifyContent: "center",
1150
1197
  flexShrink: 0,
@@ -1152,63 +1199,62 @@ var StatusDropdown = forwardRef(
1152
1199
  Box,
1153
1200
  {
1154
1201
  testID: testID ? `${testID}-dot` : "status-dropdown-dot",
1155
- width: 4,
1156
- height: 4,
1202
+ width: dotSize,
1203
+ height: dotSize,
1157
1204
  borderRadius: 999,
1158
- backgroundColor: paletteColors.content
1205
+ backgroundColor: contentColor
1159
1206
  }
1160
1207
  )
1161
1208
  }
1162
1209
  ),
1163
- /* @__PURE__ */ jsx722(Box, { paddingHorizontal: 2, flexShrink: 0, children: /* @__PURE__ */ jsx722(
1210
+ /* @__PURE__ */ jsx722(Box, { paddingHorizontal: gap, flexShrink: 0, children: /* @__PURE__ */ jsx722(
1164
1211
  Text,
1165
1212
  {
1166
- color: paletteColors.content,
1167
- fontSize: 14,
1213
+ color: contentColor,
1214
+ fontSize: sizeStyles.fontSize,
1168
1215
  fontWeight: "500",
1169
1216
  numberOfLines: 1,
1170
1217
  style: {
1171
- lineHeight: "16px"
1218
+ lineHeight: `${sizeStyles.lineHeight}px`
1172
1219
  },
1173
1220
  children: label
1174
1221
  }
1175
1222
  ) }),
1176
- /* @__PURE__ */ jsx722(Box, { width: 14, height: 14, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsx722(
1177
- Icon,
1223
+ /* @__PURE__ */ jsx722(
1224
+ Box,
1178
1225
  {
1179
- size: 14,
1180
- color: paletteColors.content,
1181
- style: {
1182
- transform: isOpen ? "rotate(180deg)" : "rotate(0deg)",
1183
- ...isWeb ? { transition: "transform 0.2s ease-in-out" } : {}
1184
- },
1185
- children: /* @__PURE__ */ jsx722(ChevronDown, {})
1226
+ width: sizeStyles.iconSize,
1227
+ height: sizeStyles.iconSize,
1228
+ alignItems: "center",
1229
+ justifyContent: "center",
1230
+ children: /* @__PURE__ */ jsx722(
1231
+ Icon,
1232
+ {
1233
+ size: sizeStyles.iconSize,
1234
+ color: contentColor,
1235
+ style: {
1236
+ transform: isOpen ? "rotate(180deg)" : "rotate(0deg)",
1237
+ ...isWeb ? { transition: "transform 0.2s ease-in-out" } : {}
1238
+ },
1239
+ children: /* @__PURE__ */ jsx722(ChevronDown, {})
1240
+ }
1241
+ )
1186
1242
  }
1187
- ) })
1243
+ )
1188
1244
  ]
1189
1245
  }
1190
1246
  );
1191
1247
  return /* @__PURE__ */ jsx722(
1192
- Dropdown,
1248
+ ContextMenu,
1193
1249
  {
1194
- ref,
1195
- id,
1196
1250
  trigger,
1197
1251
  isOpen,
1198
1252
  onOpenChange: handleOpenChange,
1253
+ "aria-label": "Change status",
1199
1254
  testID,
1200
1255
  themeMode,
1201
1256
  themeProductContext,
1202
- children: /* @__PURE__ */ jsx722(
1203
- Box,
1204
- {
1205
- onPress: (e) => {
1206
- if (onSelect) {
1207
- }
1208
- },
1209
- children
1210
- }
1211
- )
1257
+ children
1212
1258
  }
1213
1259
  );
1214
1260
  }