@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.d.mts +4 -3
- package/native/index.d.ts +4 -3
- package/native/index.js +108 -62
- package/native/index.js.map +1 -1
- package/native/index.mjs +108 -62
- package/native/index.mjs.map +1 -1
- package/package.json +5 -6
- package/web/index.d.mts +4 -3
- package/web/index.d.ts +4 -3
- package/web/index.js +108 -62
- package/web/index.js.map +1 -1
- package/web/index.mjs +108 -62
- package/web/index.mjs.map +1 -1
package/web/index.mjs
CHANGED
|
@@ -322,7 +322,7 @@ var isWeb = true;
|
|
|
322
322
|
|
|
323
323
|
// src/StatusDropdown.tsx
|
|
324
324
|
import { useResolvedTheme } from "@xsolla/xui-core";
|
|
325
|
-
import {
|
|
325
|
+
import { ContextMenu } from "@xsolla/xui-context-menu";
|
|
326
326
|
|
|
327
327
|
// ../../foundation/icons-base/dist/web/index.mjs
|
|
328
328
|
import styled4 from "styled-components";
|
|
@@ -1096,44 +1096,48 @@ var ChevronDown = (props) => /* @__PURE__ */ jsx127(BaseIcon, { ...props, solidC
|
|
|
1096
1096
|
|
|
1097
1097
|
// src/StatusDropdown.tsx
|
|
1098
1098
|
import { jsx as jsx722, jsxs } from "react/jsx-runtime";
|
|
1099
|
+
var gapMap = {
|
|
1100
|
+
xl: 4,
|
|
1101
|
+
lg: 4,
|
|
1102
|
+
md: 2,
|
|
1103
|
+
sm: 2,
|
|
1104
|
+
xs: 2
|
|
1105
|
+
};
|
|
1106
|
+
var dotSizeMap = {
|
|
1107
|
+
xl: 8,
|
|
1108
|
+
lg: 8,
|
|
1109
|
+
md: 8,
|
|
1110
|
+
sm: 4,
|
|
1111
|
+
xs: 4
|
|
1112
|
+
};
|
|
1099
1113
|
var getPaletteColors = (palette, theme) => {
|
|
1100
1114
|
const colors = theme.colors;
|
|
1101
1115
|
switch (palette) {
|
|
1102
1116
|
case "Success":
|
|
1103
1117
|
return {
|
|
1104
|
-
background: colors.background.success.
|
|
1105
|
-
border: colors.border.success
|
|
1106
|
-
content: colors.content.on.success
|
|
1118
|
+
background: colors.background.success.secondary,
|
|
1119
|
+
border: colors.border.success
|
|
1107
1120
|
};
|
|
1108
1121
|
case "Warning":
|
|
1109
1122
|
return {
|
|
1110
|
-
background: colors.background.warning.
|
|
1111
|
-
border: colors.border.warning
|
|
1112
|
-
content: colors.content.on.warning
|
|
1123
|
+
background: colors.background.warning.secondary,
|
|
1124
|
+
border: colors.border.warning
|
|
1113
1125
|
};
|
|
1114
1126
|
case "Alert":
|
|
1115
1127
|
return {
|
|
1116
|
-
background: colors.background.alert.
|
|
1117
|
-
border: colors.border.alert
|
|
1118
|
-
content: colors.content.on.alert
|
|
1119
|
-
};
|
|
1120
|
-
case "Neutral":
|
|
1121
|
-
return {
|
|
1122
|
-
background: colors.background.neutral.primary,
|
|
1123
|
-
border: colors.border.neutral,
|
|
1124
|
-
content: colors.content.on.neutral
|
|
1128
|
+
background: colors.background.alert.secondary,
|
|
1129
|
+
border: colors.border.alert
|
|
1125
1130
|
};
|
|
1126
1131
|
case "Brand":
|
|
1127
1132
|
return {
|
|
1128
|
-
background: colors.background.brand.
|
|
1129
|
-
border: colors.border.brand
|
|
1130
|
-
content: colors.content.on.brand
|
|
1133
|
+
background: colors.background.brand.secondary,
|
|
1134
|
+
border: colors.border.brand
|
|
1131
1135
|
};
|
|
1136
|
+
case "Neutral":
|
|
1132
1137
|
default:
|
|
1133
1138
|
return {
|
|
1134
|
-
background: colors.background.neutral.
|
|
1135
|
-
border: colors.border.neutral
|
|
1136
|
-
content: colors.content.on.neutral
|
|
1139
|
+
background: colors.background.neutral.secondary,
|
|
1140
|
+
border: colors.border.neutral
|
|
1137
1141
|
};
|
|
1138
1142
|
}
|
|
1139
1143
|
};
|
|
@@ -1141,9 +1145,9 @@ var StatusDropdown = forwardRef(
|
|
|
1141
1145
|
({
|
|
1142
1146
|
label,
|
|
1143
1147
|
palette = "Neutral",
|
|
1148
|
+
size = "xs",
|
|
1144
1149
|
dot = false,
|
|
1145
1150
|
children,
|
|
1146
|
-
onSelect,
|
|
1147
1151
|
isOpen: propIsOpen,
|
|
1148
1152
|
onOpenChange,
|
|
1149
1153
|
"aria-label": ariaLabel,
|
|
@@ -1154,8 +1158,13 @@ var StatusDropdown = forwardRef(
|
|
|
1154
1158
|
}, ref) => {
|
|
1155
1159
|
const { theme } = useResolvedTheme({ themeMode, themeProductContext });
|
|
1156
1160
|
const paletteColors = getPaletteColors(palette, theme);
|
|
1161
|
+
const contentColor = theme.colors.content.primary;
|
|
1162
|
+
const sizeStyles = theme.sizing.tag(size);
|
|
1163
|
+
const gap = gapMap[size];
|
|
1164
|
+
const dotSize = dotSizeMap[size];
|
|
1157
1165
|
const [internalIsOpen, setInternalIsOpen] = useState(false);
|
|
1158
1166
|
const isOpen = propIsOpen !== void 0 ? propIsOpen : internalIsOpen;
|
|
1167
|
+
const [isFocusVisible, setIsFocusVisible] = useState(false);
|
|
1159
1168
|
const handleOpenChange = (open) => {
|
|
1160
1169
|
if (onOpenChange) onOpenChange(open);
|
|
1161
1170
|
if (propIsOpen === void 0) {
|
|
@@ -1165,26 +1174,64 @@ var StatusDropdown = forwardRef(
|
|
|
1165
1174
|
const trigger = /* @__PURE__ */ jsxs(
|
|
1166
1175
|
Box,
|
|
1167
1176
|
{
|
|
1177
|
+
ref,
|
|
1178
|
+
id,
|
|
1168
1179
|
role: "button",
|
|
1169
|
-
|
|
1180
|
+
tabIndex: 0,
|
|
1170
1181
|
"aria-label": ariaLabel || `Status: ${label}`,
|
|
1171
1182
|
testID: testID ? `${testID}-trigger` : void 0,
|
|
1183
|
+
onKeyDown: (event) => {
|
|
1184
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
1185
|
+
event.preventDefault();
|
|
1186
|
+
handleOpenChange(!isOpen);
|
|
1187
|
+
} else if (event.key === "ArrowDown" && !isOpen) {
|
|
1188
|
+
event.preventDefault();
|
|
1189
|
+
handleOpenChange(true);
|
|
1190
|
+
}
|
|
1191
|
+
},
|
|
1192
|
+
position: "relative",
|
|
1172
1193
|
flexDirection: "row",
|
|
1173
1194
|
alignItems: "center",
|
|
1174
1195
|
backgroundColor: paletteColors.background,
|
|
1175
1196
|
borderColor: paletteColors.border,
|
|
1176
|
-
borderWidth:
|
|
1177
|
-
borderRadius:
|
|
1178
|
-
height:
|
|
1179
|
-
paddingHorizontal:
|
|
1180
|
-
gap
|
|
1181
|
-
|
|
1197
|
+
borderWidth: sizeStyles.borderWidth,
|
|
1198
|
+
borderRadius: sizeStyles.radius,
|
|
1199
|
+
height: sizeStyles.height,
|
|
1200
|
+
paddingHorizontal: sizeStyles.padding,
|
|
1201
|
+
gap,
|
|
1202
|
+
...isWeb ? {
|
|
1203
|
+
onFocus: (event) => {
|
|
1204
|
+
const target = event?.target;
|
|
1205
|
+
setIsFocusVisible(
|
|
1206
|
+
typeof target?.matches === "function" ? target.matches(":focus-visible") : true
|
|
1207
|
+
);
|
|
1208
|
+
},
|
|
1209
|
+
onBlur: () => setIsFocusVisible(false)
|
|
1210
|
+
} : {},
|
|
1211
|
+
style: isWeb ? {
|
|
1212
|
+
cursor: "pointer",
|
|
1213
|
+
outline: isFocusVisible ? `2px solid ${theme.colors.border.brand}` : "none",
|
|
1214
|
+
outlineOffset: isFocusVisible ? 2 : void 0
|
|
1215
|
+
} : void 0,
|
|
1182
1216
|
children: [
|
|
1217
|
+
isWeb && /* @__PURE__ */ jsx722(
|
|
1218
|
+
Box,
|
|
1219
|
+
{
|
|
1220
|
+
"aria-hidden": true,
|
|
1221
|
+
position: "absolute",
|
|
1222
|
+
top: 0,
|
|
1223
|
+
left: 0,
|
|
1224
|
+
right: 0,
|
|
1225
|
+
bottom: 0,
|
|
1226
|
+
borderRadius: sizeStyles.radius,
|
|
1227
|
+
hoverStyle: { backgroundColor: theme.colors.overlay.mono }
|
|
1228
|
+
}
|
|
1229
|
+
),
|
|
1183
1230
|
dot && /* @__PURE__ */ jsx722(
|
|
1184
1231
|
Box,
|
|
1185
1232
|
{
|
|
1186
|
-
width:
|
|
1187
|
-
height:
|
|
1233
|
+
width: sizeStyles.iconSize,
|
|
1234
|
+
height: sizeStyles.iconSize,
|
|
1188
1235
|
alignItems: "center",
|
|
1189
1236
|
justifyContent: "center",
|
|
1190
1237
|
flexShrink: 0,
|
|
@@ -1192,63 +1239,62 @@ var StatusDropdown = forwardRef(
|
|
|
1192
1239
|
Box,
|
|
1193
1240
|
{
|
|
1194
1241
|
testID: testID ? `${testID}-dot` : "status-dropdown-dot",
|
|
1195
|
-
width:
|
|
1196
|
-
height:
|
|
1242
|
+
width: dotSize,
|
|
1243
|
+
height: dotSize,
|
|
1197
1244
|
borderRadius: 999,
|
|
1198
|
-
backgroundColor:
|
|
1245
|
+
backgroundColor: contentColor
|
|
1199
1246
|
}
|
|
1200
1247
|
)
|
|
1201
1248
|
}
|
|
1202
1249
|
),
|
|
1203
|
-
/* @__PURE__ */ jsx722(Box, { paddingHorizontal:
|
|
1250
|
+
/* @__PURE__ */ jsx722(Box, { paddingHorizontal: gap, flexShrink: 0, children: /* @__PURE__ */ jsx722(
|
|
1204
1251
|
Text,
|
|
1205
1252
|
{
|
|
1206
|
-
color:
|
|
1207
|
-
fontSize:
|
|
1253
|
+
color: contentColor,
|
|
1254
|
+
fontSize: sizeStyles.fontSize,
|
|
1208
1255
|
fontWeight: "500",
|
|
1209
1256
|
numberOfLines: 1,
|
|
1210
1257
|
style: {
|
|
1211
|
-
lineHeight:
|
|
1258
|
+
lineHeight: `${sizeStyles.lineHeight}px`
|
|
1212
1259
|
},
|
|
1213
1260
|
children: label
|
|
1214
1261
|
}
|
|
1215
1262
|
) }),
|
|
1216
|
-
/* @__PURE__ */ jsx722(
|
|
1217
|
-
|
|
1263
|
+
/* @__PURE__ */ jsx722(
|
|
1264
|
+
Box,
|
|
1218
1265
|
{
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1266
|
+
width: sizeStyles.iconSize,
|
|
1267
|
+
height: sizeStyles.iconSize,
|
|
1268
|
+
alignItems: "center",
|
|
1269
|
+
justifyContent: "center",
|
|
1270
|
+
children: /* @__PURE__ */ jsx722(
|
|
1271
|
+
Icon,
|
|
1272
|
+
{
|
|
1273
|
+
size: sizeStyles.iconSize,
|
|
1274
|
+
color: contentColor,
|
|
1275
|
+
style: {
|
|
1276
|
+
transform: isOpen ? "rotate(180deg)" : "rotate(0deg)",
|
|
1277
|
+
...isWeb ? { transition: "transform 0.2s ease-in-out" } : {}
|
|
1278
|
+
},
|
|
1279
|
+
children: /* @__PURE__ */ jsx722(ChevronDown, {})
|
|
1280
|
+
}
|
|
1281
|
+
)
|
|
1226
1282
|
}
|
|
1227
|
-
)
|
|
1283
|
+
)
|
|
1228
1284
|
]
|
|
1229
1285
|
}
|
|
1230
1286
|
);
|
|
1231
1287
|
return /* @__PURE__ */ jsx722(
|
|
1232
|
-
|
|
1288
|
+
ContextMenu,
|
|
1233
1289
|
{
|
|
1234
|
-
ref,
|
|
1235
|
-
id,
|
|
1236
1290
|
trigger,
|
|
1237
1291
|
isOpen,
|
|
1238
1292
|
onOpenChange: handleOpenChange,
|
|
1293
|
+
"aria-label": "Change status",
|
|
1239
1294
|
testID,
|
|
1240
1295
|
themeMode,
|
|
1241
1296
|
themeProductContext,
|
|
1242
|
-
children
|
|
1243
|
-
Box,
|
|
1244
|
-
{
|
|
1245
|
-
onPress: (e) => {
|
|
1246
|
-
if (onSelect) {
|
|
1247
|
-
}
|
|
1248
|
-
},
|
|
1249
|
-
children
|
|
1250
|
-
}
|
|
1251
|
-
)
|
|
1297
|
+
children
|
|
1252
1298
|
}
|
|
1253
1299
|
);
|
|
1254
1300
|
}
|