@xsolla/xui-status-dropdown 0.167.0 → 0.168.0-pr325.1780576648

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/README.md CHANGED
@@ -14,6 +14,7 @@ npm install @xsolla/xui-status-dropdown
14
14
  import { StatusDropdown } from '@xsolla/xui-status-dropdown';
15
15
  import type { StatusDropdownProps, StatusDropdownPalette } from '@xsolla/xui-status-dropdown';
16
16
  import { ContextMenuItem } from '@xsolla/xui-context-menu';
17
+ import { XUIProvider } from '@xsolla/xui-core';
17
18
  ```
18
19
 
19
20
  Also re-exported from the `@xsolla/xui-controls` meta-package:
@@ -51,7 +52,7 @@ const [status, setStatus] = useState('Success');
51
52
  | `id` | `string` | — | HTML id on the underlying dropdown. |
52
53
  | `testID` | `string` | — | Test identifier; suffixed for inner trigger and dot. |
53
54
 
54
- Inherits `ThemeOverrideProps` (`themeMode`, `themeProductContext`).
55
+ Inherits `ThemeOverrideProps` (`themeMode`, `themeProductContext`). Overrides are applied to the trigger, dropdown surface, and theme-aware menu children, so a dropdown can render in dark mode inside a light provider.
55
56
 
56
57
  ### Types
57
58
 
@@ -94,6 +95,18 @@ const [current, setCurrent] = useState(STATUSES[0]);
94
95
  </StatusDropdown>
95
96
  ```
96
97
 
98
+ ### Dark dropdown in a light provider
99
+
100
+ ```tsx
101
+ <XUIProvider initialMode="light">
102
+ <StatusDropdown label="Review" palette="Warning" dot themeMode="dark">
103
+ <ContextMenuItem type="option" label="Paid" />
104
+ <ContextMenuItem type="option" label="Review" checked />
105
+ <ContextMenuItem type="option" label="Blocked" destructive />
106
+ </StatusDropdown>
107
+ </XUIProvider>
108
+ ```
109
+
97
110
  ## Accessibility
98
111
 
99
112
  - Trigger renders with `role="button"` and `aria-haspopup="listbox"`.
package/native/index.js CHANGED
@@ -35,7 +35,7 @@ __export(index_exports, {
35
35
  module.exports = __toCommonJS(index_exports);
36
36
 
37
37
  // src/StatusDropdown.tsx
38
- var import_react2 = require("react");
38
+ var import_react2 = __toESM(require("react"));
39
39
 
40
40
  // ../../foundation/primitives-native/src/Box.tsx
41
41
  var import_react_native = require("react-native");
@@ -1126,6 +1126,37 @@ var getPaletteColors = (palette, theme) => {
1126
1126
  };
1127
1127
  }
1128
1128
  };
1129
+ var applyThemeOverridesToChildren = (children, overrides) => {
1130
+ if (overrides.themeMode === void 0 && overrides.themeProductContext === void 0) {
1131
+ return children;
1132
+ }
1133
+ return import_react2.default.Children.map(children, (child) => {
1134
+ if (!import_react2.default.isValidElement(child)) {
1135
+ return child;
1136
+ }
1137
+ const childChildren = child.props.children;
1138
+ const themedChildren = childChildren === void 0 ? childChildren : applyThemeOverridesToChildren(childChildren, overrides);
1139
+ if (child.type === import_react2.default.Fragment) {
1140
+ return import_react2.default.cloneElement(child, { children: themedChildren });
1141
+ }
1142
+ const nextProps = {};
1143
+ if (typeof child.type !== "string") {
1144
+ if (overrides.themeMode !== void 0 && child.props.themeMode === void 0) {
1145
+ nextProps.themeMode = overrides.themeMode;
1146
+ }
1147
+ if (overrides.themeProductContext !== void 0 && child.props.themeProductContext === void 0) {
1148
+ nextProps.themeProductContext = overrides.themeProductContext;
1149
+ }
1150
+ }
1151
+ if (themedChildren !== childChildren) {
1152
+ nextProps.children = themedChildren;
1153
+ }
1154
+ if (Object.keys(nextProps).length === 0) {
1155
+ return child;
1156
+ }
1157
+ return import_react2.default.cloneElement(child, nextProps);
1158
+ });
1159
+ };
1129
1160
  var StatusDropdown = (0, import_react2.forwardRef)(
1130
1161
  ({
1131
1162
  label,
@@ -1143,6 +1174,10 @@ var StatusDropdown = (0, import_react2.forwardRef)(
1143
1174
  }, ref) => {
1144
1175
  const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
1145
1176
  const paletteColors = getPaletteColors(palette, theme);
1177
+ const themedChildren = applyThemeOverridesToChildren(children, {
1178
+ themeMode,
1179
+ themeProductContext
1180
+ });
1146
1181
  const [internalIsOpen, setInternalIsOpen] = (0, import_react2.useState)(false);
1147
1182
  const isOpen = propIsOpen !== void 0 ? propIsOpen : internalIsOpen;
1148
1183
  const handleOpenChange = (open) => {
@@ -1235,7 +1270,7 @@ var StatusDropdown = (0, import_react2.forwardRef)(
1235
1270
  if (onSelect) {
1236
1271
  }
1237
1272
  },
1238
- children
1273
+ children: themedChildren
1239
1274
  }
1240
1275
  )
1241
1276
  }