xmlui 0.10.19 → 0.10.21
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/dist/lib/{apiInterceptorWorker-DPgtUtdA.mjs → apiInterceptorWorker-QiltRtq1.mjs} +1 -1
- package/dist/lib/{index-cuh97e2e.mjs → index-BiS4wEuu.mjs} +1486 -1211
- package/dist/lib/index.css +1 -1
- package/dist/{metadata/initMock-C-cnv--V.mjs → lib/initMock-CB_cMi6U.mjs} +25 -15
- package/dist/lib/language-server-web-worker.mjs +1 -1
- package/dist/lib/language-server.mjs +1 -1
- package/dist/lib/{metadata-utils-CtY0QcvH.mjs → metadata-utils-BTIt1_wE.mjs} +1 -1
- package/dist/lib/{server-common-Cine5nRR.mjs → server-common-DYZtsdM7.mjs} +51 -14
- package/dist/lib/{transform-bHBjkKSL.mjs → transform-Tooy42EB.mjs} +16 -18
- package/dist/lib/xmlui-parser.mjs +2 -2
- package/dist/lib/{xmlui-serializer-DB6BLiXK.mjs → xmlui-serializer-uCYa8_tZ.mjs} +1 -1
- package/dist/lib/xmlui.d.ts +11 -3
- package/dist/lib/xmlui.mjs +2 -2
- package/dist/metadata/{apiInterceptorWorker-BmKP8bnq.mjs → apiInterceptorWorker-Dql7QGw2.mjs} +1 -1
- package/dist/metadata/{collectedComponentMetadata-Cp-9lpnG.mjs → collectedComponentMetadata-MFUg6aSX.mjs} +1655 -1390
- package/dist/{lib/initMock-BMxsanHc.mjs → metadata/initMock-Dw9wrVkQ.mjs} +25 -15
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +3 -3
- package/dist/scripts/package.json +3 -6
- package/dist/scripts/src/components/Animation/AnimationNative.js +28 -28
- package/dist/scripts/src/components/App/App.js +4 -4
- package/dist/scripts/src/components/App/App.spec.js +17 -17
- package/dist/scripts/src/components/App/AppNative.js +1 -1
- package/dist/scripts/src/components/AppState/AppState.js +3 -2
- package/dist/scripts/src/components/AppState/AppState.spec.js +26 -2
- package/dist/scripts/src/components/AppState/AppStateNative.js +3 -4
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +15 -10
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +4 -4
- package/dist/scripts/src/components/Carousel/Carousel.spec.js +214 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +1 -1
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +2 -0
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.spec.js +193 -0
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +6 -6
- package/dist/scripts/src/components/DateInput/DateInputNative.js +0 -1
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.spec.js +3 -3
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZoneNative.js +4 -13
- package/dist/scripts/src/components/Form/Form.spec.js +25 -9
- package/dist/scripts/src/components/Form/FormNative.js +7 -5
- package/dist/scripts/src/components/FormItem/FormItem.js +3 -1
- package/dist/scripts/src/components/FormItem/FormItem.spec.js +5 -14
- package/dist/scripts/src/components/FormItem/FormItemNative.js +12 -8
- package/dist/scripts/src/components/FormItem/Validations.js +2 -2
- package/dist/scripts/src/components/IFrame/IFrameNative.js +0 -2
- package/dist/scripts/src/components/IconRegistryContext.js +1 -1
- package/dist/scripts/src/components/List/ListNative.js +2 -2
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +3 -12
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +2 -2
- package/dist/scripts/src/components/ModalDialog/ModalDialogNative.js +6 -3
- package/dist/scripts/src/components/NestedApp/AppWithCodeViewNative.js +1 -1
- package/dist/scripts/src/components/NestedApp/NestedAppNative.js +3 -3
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +2 -2
- package/dist/scripts/src/components/Pagination/Pagination.spec.js +5 -0
- package/dist/scripts/src/components/Pagination/PaginationNative.js +1 -3
- package/dist/scripts/src/components/Queue/Queue.spec.js +45 -47
- package/dist/scripts/src/components/Queue/QueueNative.js +1 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +5 -5
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapterNative.js +1 -1
- package/dist/scripts/src/components/Select/MultiSelectOption.js +42 -0
- package/dist/scripts/src/components/Select/Select.js +3 -3
- package/dist/scripts/src/components/Select/SelectContext.js +8 -1
- package/dist/scripts/src/components/Select/SelectNative.js +134 -142
- package/dist/scripts/src/components/Select/SelectOption.js +34 -0
- package/dist/scripts/src/components/Select/SimpleSelect.js +57 -0
- package/dist/scripts/src/components/Spinner/Spinner.spec.js +1 -1
- package/dist/scripts/src/components/Table/useRowSelection.js +14 -23
- package/dist/scripts/src/components/Text/Text.js +5 -1
- package/dist/scripts/src/components/Text/Text.spec.js +317 -0
- package/dist/scripts/src/components/Text/TextNative.js +112 -1
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +8 -8
- package/dist/scripts/src/components/Theme/Theme.js +2 -1
- package/dist/scripts/src/components/Theme/Theme.spec.js +266 -0
- package/dist/scripts/src/components/Theme/ThemeNative.js +8 -1
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +3 -3
- package/dist/scripts/src/components/TimeInput/TimeInputNative.js +0 -1
- package/dist/scripts/src/components/Timer/TimerNative.js +0 -1
- package/dist/scripts/src/components/Tree/TreeNative.js +16 -23
- package/dist/scripts/src/components-core/InspectorContext.js +1 -1
- package/dist/scripts/src/components-core/StandaloneApp.js +6 -8
- package/dist/scripts/src/components-core/action/FileUploadAction.js +1 -1
- package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +50 -0
- package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +6 -1
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +9 -11
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +3 -3
- package/dist/scripts/src/components-core/interception/Backend.js +1 -1
- package/dist/scripts/src/components-core/interception/IndexedDb.js +64 -66
- package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +2 -2
- package/dist/scripts/src/components-core/loader/DataLoader.js +6 -14
- package/dist/scripts/src/components-core/loader/Loader.js +11 -11
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +4 -2
- package/dist/scripts/src/components-core/loader/PageableLoader.js +10 -9
- package/dist/scripts/src/components-core/rendering/AppContent.js +1 -7
- package/dist/scripts/src/components-core/rendering/ErrorBoundary.js +1 -1
- package/dist/scripts/src/components-core/script-runner/bannedFunctions.js +1 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +180 -186
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +6 -6
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +2 -2
- package/dist/scripts/src/components-core/utils/actionUtils.js +1 -1
- package/dist/scripts/src/components-core/utils/hooks.js +1 -1
- package/dist/scripts/src/components-core/utils/misc.js +4 -4
- package/dist/scripts/src/components-core/xmlui-parser.js +47 -31
- package/dist/scripts/src/language-server/server-common.js +25 -24
- package/dist/scripts/src/language-server/services/common/lsp-utils.js +2 -2
- package/dist/scripts/src/language-server/services/completion.js +20 -2
- package/dist/scripts/src/language-server/services/diagnostic.js +1 -1
- package/dist/scripts/src/language-server/services/hover.js +2 -2
- package/dist/scripts/src/parsers/common/utils.js +2 -2
- package/dist/scripts/src/parsers/scripting/Lexer.js +21 -15
- package/dist/scripts/src/parsers/scripting/Parser.js +8 -9
- package/dist/scripts/src/parsers/style-parser/StyleLexer.js +22 -22
- package/dist/scripts/src/parsers/style-parser/StyleParser.js +70 -68
- package/dist/scripts/src/testing/ComponentDrivers.js +20 -39
- package/dist/scripts/src/testing/component-test-helpers.js +34 -50
- package/dist/scripts/src/testing/fixtures.js +114 -113
- package/dist/scripts/src/testing/themed-app-test-helpers.js +7 -13
- package/dist/standalone/xmlui-standalone.es.d.ts +11 -3
- package/dist/standalone/xmlui-standalone.umd.js +35 -35
- package/package.json +3 -6
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
3
|
var t = {};
|
|
37
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -47,16 +14,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
47
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
15
|
};
|
|
49
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.
|
|
17
|
+
exports.Select = exports.defaultProps = void 0;
|
|
51
18
|
const react_1 = require("react");
|
|
52
19
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
53
|
-
const react_2 =
|
|
20
|
+
const react_2 = require("react");
|
|
54
21
|
const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
|
|
55
|
-
const react_select_1 = require("@radix-ui/react-select");
|
|
56
22
|
const react_popover_1 = require("@radix-ui/react-popover");
|
|
57
|
-
const cmdk_1 = require("cmdk");
|
|
58
23
|
const classnames_1 = __importDefault(require("classnames"));
|
|
59
24
|
const react_focus_scope_1 = require("@radix-ui/react-focus-scope");
|
|
25
|
+
const SelectOption_1 = require("./SelectOption");
|
|
60
26
|
const Select_module_scss_1 = __importDefault(require("./Select.module.scss"));
|
|
61
27
|
const constants_1 = require("../../components-core/constants");
|
|
62
28
|
const ThemeContext_1 = require("../../components-core/theming/ThemeContext");
|
|
@@ -67,6 +33,8 @@ const OptionTypeProvider_1 = __importDefault(require("../Option/OptionTypeProvid
|
|
|
67
33
|
const OptionContext_1 = require("./OptionContext");
|
|
68
34
|
const HiddenOption_1 = require("./HiddenOption");
|
|
69
35
|
const FormContext_1 = require("../Form/FormContext");
|
|
36
|
+
const SimpleSelect_1 = require("./SimpleSelect");
|
|
37
|
+
const MultiSelectOption_1 = require("./MultiSelectOption");
|
|
70
38
|
exports.defaultProps = {
|
|
71
39
|
enabled: true,
|
|
72
40
|
placeholder: "",
|
|
@@ -80,40 +48,39 @@ exports.defaultProps = {
|
|
|
80
48
|
validationStatus: "none",
|
|
81
49
|
labelBreak: false,
|
|
82
50
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
51
|
+
// Common trigger value display component
|
|
52
|
+
const SelectTriggerValue = ({ value, placeholder, readOnly, multiSelect, options, valueRenderer, toggleOption, }) => {
|
|
53
|
+
if (multiSelect) {
|
|
54
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.badgeListContainer, children: (0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.badgeList, children: value.map((v) => {
|
|
56
|
+
var _a;
|
|
57
|
+
return valueRenderer ? (valueRenderer(Array.from(options).find((o) => o.value === `${v}`), () => {
|
|
58
|
+
toggleOption(v);
|
|
59
|
+
})) : ((0, jsx_runtime_1.jsxs)("span", { className: Select_module_scss_1.default.badge, children: [(_a = Array.from(options).find((o) => o.value === `${v}`)) === null || _a === void 0 ? void 0 : _a.label, (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "close", size: "sm", onClick: (event) => {
|
|
60
|
+
event.stopPropagation();
|
|
61
|
+
toggleOption(v);
|
|
62
|
+
} })] }, v));
|
|
63
|
+
}) }) }));
|
|
64
|
+
}
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)("span", { placeholder: placeholder, className: Select_module_scss_1.default.placeholder, children: placeholder }));
|
|
66
|
+
}
|
|
67
|
+
// Single select
|
|
68
|
+
if (value !== undefined && value !== null && value !== "") {
|
|
69
|
+
const selectedOption = Array.from(options).find((o) => o.value === value);
|
|
70
|
+
return (0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectValue, children: selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label });
|
|
71
|
+
}
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)("div", { "aria-placeholder": placeholder, className: Select_module_scss_1.default.placeholder, children: readOnly ? "" : placeholder || "" }));
|
|
73
|
+
};
|
|
74
|
+
const SelectTriggerActions = ({ value, multiSelect, enabled, readOnly, clearValue, showChevron = true, }) => {
|
|
75
|
+
const hasValue = multiSelect
|
|
76
|
+
? Array.isArray(value) && value.length > 0
|
|
77
|
+
: value !== undefined && value !== null && value !== "";
|
|
78
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.actions, children: [hasValue && enabled && !readOnly && ((0, jsx_runtime_1.jsx)("span", { className: Select_module_scss_1.default.action, onClick: (event) => {
|
|
109
79
|
event.stopPropagation();
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}), children: selectedOption ? selectedOption.label : readOnly ? "" : placeholder }), (0, jsx_runtime_1.jsx)(react_select_1.Icon, { asChild: true, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] })), (0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsxs)(react_select_1.Content, { className: Select_module_scss_1.default.selectContent, position: "popper", style: { maxHeight: height, minWidth: width }, children: [(0, jsx_runtime_1.jsx)(react_select_1.ScrollUpButton, { className: Select_module_scss_1.default.selectScrollUpButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronup" }) }), (0, jsx_runtime_1.jsxs)(react_select_1.SelectViewport, { className: Select_module_scss_1.default.selectViewport, role: "listbox", children: [children, optionsArray.length === 0 && emptyListNode] }), (0, jsx_runtime_1.jsx)(react_select_1.ScrollDownButton, { className: Select_module_scss_1.default.selectScrollDownButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }) })] }));
|
|
114
|
-
});
|
|
80
|
+
clearValue();
|
|
81
|
+
}, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "close" }) })), showChevron && ((0, jsx_runtime_1.jsx)("span", { className: Select_module_scss_1.default.action, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) }))] }));
|
|
82
|
+
};
|
|
115
83
|
exports.Select = (0, react_2.forwardRef)(function Select(_a, forwardedRef) {
|
|
116
|
-
var _b;
|
|
117
84
|
var {
|
|
118
85
|
// Basic props
|
|
119
86
|
id, initialValue, value, enabled = exports.defaultProps.enabled, placeholder = exports.defaultProps.placeholder, autoFocus = exports.defaultProps.autoFocus, readOnly = false, required = exports.defaultProps.required,
|
|
@@ -136,6 +103,26 @@ exports.Select = (0, react_2.forwardRef)(function Select(_a, forwardedRef) {
|
|
|
136
103
|
const { root } = (0, ThemeContext_1.useTheme)();
|
|
137
104
|
const [options, setOptions] = (0, react_2.useState)(new Set());
|
|
138
105
|
const isInForm = (0, FormContext_1.useIsInsideForm)();
|
|
106
|
+
const [searchTerm, setSearchTerm] = (0, react_2.useState)("");
|
|
107
|
+
const [selectedIndex, setSelectedIndex] = (0, react_2.useState)(-1);
|
|
108
|
+
// Filter options based on search term
|
|
109
|
+
const filteredOptions = (0, react_2.useMemo)(() => {
|
|
110
|
+
if (!searchTerm || searchTerm.trim() === "") {
|
|
111
|
+
return Array.from(options);
|
|
112
|
+
}
|
|
113
|
+
const searchLower = searchTerm.toLowerCase();
|
|
114
|
+
return Array.from(options).filter((option) => {
|
|
115
|
+
const extendedValue = option.value + " " + option.label + " " + (option.keywords || []).join(" ");
|
|
116
|
+
return extendedValue.toLowerCase().includes(searchLower);
|
|
117
|
+
});
|
|
118
|
+
}, [options, searchTerm]);
|
|
119
|
+
// Reset selected index when options change or dropdown closes
|
|
120
|
+
(0, react_2.useEffect)(() => {
|
|
121
|
+
if (!open) {
|
|
122
|
+
setSelectedIndex(-1);
|
|
123
|
+
setSearchTerm("");
|
|
124
|
+
}
|
|
125
|
+
}, [open]);
|
|
139
126
|
// Set initial state based on the initialValue prop
|
|
140
127
|
(0, react_2.useEffect)(() => {
|
|
141
128
|
if (initialValue !== undefined) {
|
|
@@ -179,6 +166,80 @@ exports.Select = (0, react_2.forwardRef)(function Select(_a, forwardedRef) {
|
|
|
179
166
|
updateState({ value: newValue });
|
|
180
167
|
onDidChange(newValue);
|
|
181
168
|
}, [multiSelect, updateState, onDidChange]);
|
|
169
|
+
// Helper functions to find next/previous enabled option
|
|
170
|
+
const findNextEnabledIndex = (0, react_2.useCallback)((currentIndex) => {
|
|
171
|
+
for (let i = currentIndex + 1; i < filteredOptions.length; i++) {
|
|
172
|
+
const item = filteredOptions[i];
|
|
173
|
+
if (item.enabled !== false) {
|
|
174
|
+
return i;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Wrap around to beginning
|
|
178
|
+
for (let i = 0; i <= currentIndex; i++) {
|
|
179
|
+
const item = filteredOptions[i];
|
|
180
|
+
if (item.enabled !== false) {
|
|
181
|
+
return i;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return -1;
|
|
185
|
+
}, [filteredOptions]);
|
|
186
|
+
const findPreviousEnabledIndex = (0, react_2.useCallback)((currentIndex) => {
|
|
187
|
+
for (let i = currentIndex - 1; i >= 0; i--) {
|
|
188
|
+
const item = filteredOptions[i];
|
|
189
|
+
if (item.enabled !== false) {
|
|
190
|
+
return i;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Wrap around to end
|
|
194
|
+
for (let i = filteredOptions.length - 1; i >= currentIndex; i--) {
|
|
195
|
+
const item = filteredOptions[i];
|
|
196
|
+
if (item.enabled !== false) {
|
|
197
|
+
return i;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return -1;
|
|
201
|
+
}, [filteredOptions]);
|
|
202
|
+
// Keyboard navigation
|
|
203
|
+
const handleKeyDown = (0, react_2.useCallback)((event) => {
|
|
204
|
+
if (!open)
|
|
205
|
+
return;
|
|
206
|
+
switch (event.key) {
|
|
207
|
+
case "ArrowDown":
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
setSelectedIndex((prev) => {
|
|
210
|
+
const nextIndex = findNextEnabledIndex(prev);
|
|
211
|
+
return nextIndex !== -1 ? nextIndex : prev;
|
|
212
|
+
});
|
|
213
|
+
break;
|
|
214
|
+
case "ArrowUp":
|
|
215
|
+
event.preventDefault();
|
|
216
|
+
setSelectedIndex((prev) => {
|
|
217
|
+
const prevIndex = findPreviousEnabledIndex(prev);
|
|
218
|
+
return prevIndex !== -1 ? prevIndex : prev;
|
|
219
|
+
});
|
|
220
|
+
break;
|
|
221
|
+
case "Enter":
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
if (selectedIndex >= 0 && selectedIndex < filteredOptions.length) {
|
|
224
|
+
const selectedItem = filteredOptions[selectedIndex];
|
|
225
|
+
if (selectedItem.enabled !== false) {
|
|
226
|
+
toggleOption(selectedItem.value);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
case "Escape":
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
setOpen(false);
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}, [
|
|
236
|
+
open,
|
|
237
|
+
selectedIndex,
|
|
238
|
+
filteredOptions,
|
|
239
|
+
toggleOption,
|
|
240
|
+
findNextEnabledIndex,
|
|
241
|
+
findPreviousEnabledIndex,
|
|
242
|
+
]);
|
|
182
243
|
// Register component API for external interactions
|
|
183
244
|
const focus = (0, react_2.useCallback)(() => {
|
|
184
245
|
referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.focus();
|
|
@@ -223,10 +284,11 @@ exports.Select = (0, react_2.forwardRef)(function Select(_a, forwardedRef) {
|
|
|
223
284
|
value,
|
|
224
285
|
onChange: toggleOption,
|
|
225
286
|
setOpen,
|
|
287
|
+
setSelectedIndex,
|
|
226
288
|
options,
|
|
227
289
|
optionRenderer,
|
|
228
|
-
}), [multiSelect, toggleOption, value, options]);
|
|
229
|
-
return ((0, jsx_runtime_1.jsx)(SelectContext_1.SelectContext.Provider, { value: selectContextValue, children: (0, jsx_runtime_1.jsx)(OptionContext_1.OptionContext.Provider, { value: optionContextValue, children: searchable || multiSelect ? ((0, jsx_runtime_1.jsxs)(OptionTypeProvider_1.default, { Component: HiddenOption_1.HiddenOption, children: [(0, jsx_runtime_1.jsxs)(react_popover_1.Popover, { open: open, onOpenChange: setOpen, modal: false, children: [(0, jsx_runtime_1.
|
|
290
|
+
}), [multiSelect, toggleOption, value, options, optionRenderer]);
|
|
291
|
+
return ((0, jsx_runtime_1.jsx)(SelectContext_1.SelectContext.Provider, { value: selectContextValue, children: (0, jsx_runtime_1.jsx)(OptionContext_1.OptionContext.Provider, { value: optionContextValue, children: searchable || multiSelect ? ((0, jsx_runtime_1.jsxs)(OptionTypeProvider_1.default, { Component: HiddenOption_1.HiddenOption, children: [(0, jsx_runtime_1.jsxs)(react_popover_1.Popover, { open: open, onOpenChange: setOpen, modal: false, children: [(0, jsx_runtime_1.jsxs)(react_popover_1.PopoverTrigger, Object.assign({}, rest, { ref: (0, react_compose_refs_1.composeRefs)(setReferenceElement, forwardedRef), id: id, "aria-haspopup": "listbox", style: style, onFocus: onFocus, onBlur: onBlur, disabled: !enabled, "aria-expanded": open, onClick: (event) => {
|
|
230
292
|
// Prevent event propagation to parent elements (e.g., DropdownMenu)
|
|
231
293
|
// This ensures that clicking the Select trigger doesn't close the containing DropdownMenu
|
|
232
294
|
event.stopPropagation();
|
|
@@ -234,75 +296,5 @@ exports.Select = (0, react_2.forwardRef)(function Select(_a, forwardedRef) {
|
|
|
234
296
|
}, className: (0, classnames_1.default)(Select_module_scss_1.default.selectTrigger, Select_module_scss_1.default[validationStatus], {
|
|
235
297
|
[Select_module_scss_1.default.disabled]: !enabled,
|
|
236
298
|
[Select_module_scss_1.default.multi]: multiSelect,
|
|
237
|
-
}, className), autoFocus: autoFocus, children: (0, jsx_runtime_1.
|
|
238
|
-
var _a;
|
|
239
|
-
return valueRenderer ? (valueRenderer(Array.from(options).find((o) => o.value === `${v}`), () => {
|
|
240
|
-
toggleOption(v);
|
|
241
|
-
})) : ((0, jsx_runtime_1.jsxs)("span", { className: Select_module_scss_1.default.badge, children: [(_a = Array.from(options).find((o) => o.value === `${v}`)) === null || _a === void 0 ? void 0 : _a.label, (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "close", size: "sm", onClick: (event) => {
|
|
242
|
-
event.stopPropagation();
|
|
243
|
-
toggleOption(v);
|
|
244
|
-
} })] }, v));
|
|
245
|
-
}) }) })) : ((0, jsx_runtime_1.jsx)("span", { placeholder: placeholder, className: Select_module_scss_1.default.placeholder, children: placeholder }))) : value !== undefined && value !== null ? ((0, jsx_runtime_1.jsx)("div", { children: (_b = Array.from(options).find((o) => o.value === value)) === null || _b === void 0 ? void 0 : _b.label })) : ((0, jsx_runtime_1.jsx)("span", { "aria-placeholder": placeholder, className: Select_module_scss_1.default.placeholder, children: placeholder || "" })), (0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.actions, children: [multiSelect && Array.isArray(value) && value.length > 0 && ((0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "close", onClick: (event) => {
|
|
246
|
-
event.stopPropagation();
|
|
247
|
-
clearValue();
|
|
248
|
-
} })), (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" })] })] }) })), open && ((0, jsx_runtime_1.jsx)(react_popover_1.Portal, { container: root, children: (0, jsx_runtime_1.jsx)(react_focus_scope_1.FocusScope, { asChild: true, loop: true, trapped: true, children: (0, jsx_runtime_1.jsx)(react_popover_1.PopoverContent, { style: { minWidth: width, height: dropdownHeight }, className: Select_module_scss_1.default.selectContent, children: (0, jsx_runtime_1.jsxs)(cmdk_1.Command, { className: Select_module_scss_1.default.command, shouldFilter: searchable, filter: (_, search, keywords) => {
|
|
249
|
-
const lowSearch = search.toLowerCase();
|
|
250
|
-
for (const kw of keywords) {
|
|
251
|
-
if (kw.toLowerCase().includes(lowSearch))
|
|
252
|
-
return 1;
|
|
253
|
-
}
|
|
254
|
-
return 0;
|
|
255
|
-
}, children: [searchable ? ((0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.commandInputContainer, children: [(0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "search" }), (0, jsx_runtime_1.jsx)(cmdk_1.CommandInput, { className: (0, classnames_1.default)(Select_module_scss_1.default.commandInput), placeholder: "Search..." })] })) : (
|
|
256
|
-
// https://github.com/pacocoursey/cmdk/issues/322#issuecomment-2444703817
|
|
257
|
-
(0, jsx_runtime_1.jsx)("button", { autoFocus: true, "aria-hidden": "true", className: Select_module_scss_1.default.srOnly })), (0, jsx_runtime_1.jsxs)(cmdk_1.CommandList, { className: Select_module_scss_1.default.commandList, children: [inProgress && ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.loading, children: inProgressNotificationMessage })), Array.from(options).map(({ value, label, enabled, keywords }) => ((0, jsx_runtime_1.jsx)(exports.ComboboxOption, { readOnly: readOnly, value: value, label: label, enabled: enabled, keywords: keywords }, value))), !inProgress && (0, jsx_runtime_1.jsx)(cmdk_1.CommandEmpty, { children: emptyListNode })] })] }) }) }) }))] }), children] })) : ((0, jsx_runtime_1.jsx)(OptionTypeProvider_1.default, { Component: SelectOption, children: (0, react_1.createElement)(SimpleSelect, Object.assign({}, rest, { readOnly: !!readOnly, ref: forwardedRef, key: isInForm ? (value ? `status-${value}` : "status-initial") : undefined, value: value, onValueChange: toggleOption, id: id, style: style, className: className, onFocus: onFocus, onBlur: onBlur, enabled: enabled, validationStatus: validationStatus, triggerRef: setReferenceElement, autoFocus: autoFocus, placeholder: placeholder, height: dropdownHeight, width: width, emptyListNode: emptyListNode }), children) })) }) }));
|
|
258
|
-
});
|
|
259
|
-
exports.ComboboxOption = (0, react_2.forwardRef)(function Combobox(option, forwardedRef) {
|
|
260
|
-
const id = (0, react_2.useId)();
|
|
261
|
-
const { label, value, enabled = true, keywords, readOnly, children } = option;
|
|
262
|
-
const { value: selectedValue, onChange, multiSelect, setOpen, optionRenderer } = (0, SelectContext_1.useSelect)();
|
|
263
|
-
const selected = (0, react_2.useMemo)(() => {
|
|
264
|
-
return Array.isArray(selectedValue) && multiSelect
|
|
265
|
-
? selectedValue.map((v) => String(v)).includes(value)
|
|
266
|
-
: String(selectedValue) === String(value);
|
|
267
|
-
}, [selectedValue, value, multiSelect]);
|
|
268
|
-
return ((0, jsx_runtime_1.jsx)(cmdk_1.CommandItem, { id: id, ref: forwardedRef, disabled: !enabled, value: value, className: Select_module_scss_1.default.multiComboboxOption, onSelect: () => {
|
|
269
|
-
if (readOnly) {
|
|
270
|
-
setOpen(false);
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
onChange(value);
|
|
274
|
-
}, onClick: (event) => {
|
|
275
|
-
event.stopPropagation();
|
|
276
|
-
}, "data-state": selected ? "checked" : undefined, keywords: [...keywords, label], children: (0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.multiComboboxOptionContent, children: optionRenderer ? (optionRenderer({ label, value, enabled, keywords }, selectedValue, false)) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [children || label, selected && (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" })] })) }) }, id));
|
|
277
|
-
});
|
|
278
|
-
const SelectOption = react_2.default.forwardRef((option, ref) => {
|
|
279
|
-
var _a;
|
|
280
|
-
const visibleContentRef = (0, react_2.useRef)(null);
|
|
281
|
-
const { value, label, enabled = true, children, className } = option;
|
|
282
|
-
const { value: selectedValue, optionRenderer } = (0, SelectContext_1.useSelect)();
|
|
283
|
-
const { onOptionRemove, onOptionAdd } = (0, OptionContext_1.useOption)();
|
|
284
|
-
const opt = (0, react_2.useMemo)(() => {
|
|
285
|
-
var _a, _b, _c, _d;
|
|
286
|
-
return Object.assign(Object.assign({}, option), { label: (_b = label !== null && label !== void 0 ? label : (_a = visibleContentRef.current) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : "", keywords: [(_d = label !== null && label !== void 0 ? label : (_c = visibleContentRef.current) === null || _c === void 0 ? void 0 : _c.textContent) !== null && _d !== void 0 ? _d : ""] });
|
|
287
|
-
}, [option, label, visibleContentRef.current]);
|
|
288
|
-
(0, react_2.useEffect)(() => {
|
|
289
|
-
onOptionAdd(opt);
|
|
290
|
-
return () => onOptionRemove(opt);
|
|
291
|
-
}, [opt, onOptionAdd, onOptionRemove]);
|
|
292
|
-
return ((0, jsx_runtime_1.jsxs)(react_select_1.Item, { ref: ref, className: (0, classnames_1.default)(Select_module_scss_1.default.selectItem, className), value: value, textValue: label || ((_a = visibleContentRef.current) === null || _a === void 0 ? void 0 : _a.textContent), disabled: !enabled, onClick: (event) => {
|
|
293
|
-
event.stopPropagation();
|
|
294
|
-
}, onMouseEnter: (event) => {
|
|
295
|
-
// Ensure hover state is applied even in DropdownMenu context
|
|
296
|
-
const target = event.currentTarget;
|
|
297
|
-
target.setAttribute("data-highlighted", "");
|
|
298
|
-
}, onMouseLeave: (event) => {
|
|
299
|
-
// Remove hover state when mouse leaves
|
|
300
|
-
const target = event.currentTarget;
|
|
301
|
-
target.removeAttribute("data-highlighted");
|
|
302
|
-
}, "data-state": selectedValue === value && "checked", children: [(0, jsx_runtime_1.jsx)("span", { style: { display: "none" }, children: (0, jsx_runtime_1.jsx)(react_select_1.ItemText, { children: label }) }), children ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectItemContent, ref: visibleContentRef, children: children }), selectedValue === value && ((0, jsx_runtime_1.jsx)(react_select_1.ItemIndicator, { className: Select_module_scss_1.default.selectItemIndicator, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" }) }))] })) : optionRenderer ? ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectItemContent, ref: visibleContentRef, children: optionRenderer({
|
|
303
|
-
label,
|
|
304
|
-
value,
|
|
305
|
-
enabled,
|
|
306
|
-
}, selectedValue, false) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectItemContent, ref: visibleContentRef, children: label }), selectedValue === value && ((0, jsx_runtime_1.jsx)(react_select_1.ItemIndicator, { className: Select_module_scss_1.default.selectItemIndicator, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" }) }))] }))] }));
|
|
299
|
+
}, className), autoFocus: autoFocus, children: [(0, jsx_runtime_1.jsx)(SelectTriggerValue, { value: value, placeholder: placeholder, readOnly: readOnly, multiSelect: multiSelect, options: options, valueRenderer: valueRenderer, toggleOption: toggleOption }), (0, jsx_runtime_1.jsx)(SelectTriggerActions, { value: value, multiSelect: multiSelect, enabled: enabled, readOnly: readOnly, clearValue: clearValue })] })), open && ((0, jsx_runtime_1.jsx)(react_popover_1.Portal, { container: root, children: (0, jsx_runtime_1.jsx)(react_focus_scope_1.FocusScope, { asChild: true, loop: true, trapped: true, children: (0, jsx_runtime_1.jsx)(react_popover_1.PopoverContent, { style: { minWidth: width, height: dropdownHeight }, className: Select_module_scss_1.default.selectContent, onKeyDown: handleKeyDown, children: (0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.command, children: [searchable ? ((0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.commandInputContainer, children: [(0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "search" }), (0, jsx_runtime_1.jsx)("input", { role: "combobox", className: (0, classnames_1.default)(Select_module_scss_1.default.commandInput), placeholder: "Search...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), autoFocus: true })] })) : ((0, jsx_runtime_1.jsx)("button", { autoFocus: true, "aria-hidden": "true", className: Select_module_scss_1.default.srOnly })), (0, jsx_runtime_1.jsxs)("div", { role: "listbox", className: Select_module_scss_1.default.commandList, children: [inProgress && ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.loading, children: inProgressNotificationMessage })), filteredOptions.map(({ value, label, enabled, keywords }, index) => ((0, jsx_runtime_1.jsx)(MultiSelectOption_1.MultiSelectOption, { readOnly: readOnly, value: value, label: label, enabled: enabled, keywords: keywords, isHighlighted: selectedIndex === index, itemIndex: index }, value))), !inProgress && filteredOptions.length === 0 && ((0, jsx_runtime_1.jsx)("div", { children: emptyListNode }))] })] }) }) }) }))] }), children] })) : ((0, jsx_runtime_1.jsx)(OptionTypeProvider_1.default, { Component: SelectOption_1.SelectOption, children: (0, react_1.createElement)(SimpleSelect_1.SimpleSelect, Object.assign({}, rest, { readOnly: !!readOnly, ref: forwardedRef, key: isInForm ? (value ? `status-${value}` : "status-initial") : undefined, value: value, onValueChange: toggleOption, id: id, style: style, className: className, onFocus: onFocus, onBlur: onBlur, enabled: enabled, validationStatus: validationStatus, triggerRef: setReferenceElement, autoFocus: autoFocus, placeholder: placeholder, height: dropdownHeight, width: width, emptyListNode: emptyListNode }), children) })) }) }));
|
|
307
300
|
});
|
|
308
|
-
SelectOption.displayName = "SelectOption";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SelectOption = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const react_select_1 = require("@radix-ui/react-select");
|
|
10
|
+
const SelectContext_1 = require("./SelectContext");
|
|
11
|
+
const OptionContext_1 = require("./OptionContext");
|
|
12
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
13
|
+
const Select_module_scss_1 = __importDefault(require("./Select.module.scss"));
|
|
14
|
+
const IconNative_1 = __importDefault(require("../Icon/IconNative"));
|
|
15
|
+
exports.SelectOption = (0, react_1.forwardRef)(function SelectOption(option, ref) {
|
|
16
|
+
const visibleContentRef = (0, react_1.useRef)(null);
|
|
17
|
+
const { value, label, enabled = true, children, className } = option;
|
|
18
|
+
const { value: selectedValue, optionRenderer } = (0, SelectContext_1.useSelect)();
|
|
19
|
+
const { onOptionRemove, onOptionAdd } = (0, OptionContext_1.useOption)();
|
|
20
|
+
const opt = (0, react_1.useMemo)(() => {
|
|
21
|
+
return Object.assign(Object.assign({}, option), { label: label !== null && label !== void 0 ? label : "", keywords: [label !== null && label !== void 0 ? label : ""] });
|
|
22
|
+
}, [option, label]);
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
onOptionAdd(opt);
|
|
25
|
+
return () => onOptionRemove(opt);
|
|
26
|
+
}, [opt, onOptionAdd, onOptionRemove]);
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(react_select_1.Item, { ref: ref, className: (0, classnames_1.default)(className, Select_module_scss_1.default.selectOption), value: value, textValue: label, disabled: !enabled, onClick: (event) => {
|
|
28
|
+
event.stopPropagation();
|
|
29
|
+
}, "data-state": selectedValue === value && "checked", children: [(0, jsx_runtime_1.jsx)("span", { style: { display: "none" }, children: (0, jsx_runtime_1.jsx)(react_select_1.ItemText, { children: label }) }), children ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectOptionContent, ref: visibleContentRef, children: children }), selectedValue === value && ((0, jsx_runtime_1.jsx)(react_select_1.ItemIndicator, { className: Select_module_scss_1.default.selectOptionIndicator, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" }) }))] })) : optionRenderer ? ((0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectOptionContent, ref: visibleContentRef, children: optionRenderer({
|
|
30
|
+
label,
|
|
31
|
+
value,
|
|
32
|
+
enabled,
|
|
33
|
+
}, selectedValue, false) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectOptionContent, ref: visibleContentRef, children: label }), selectedValue === value && ((0, jsx_runtime_1.jsx)(react_select_1.ItemIndicator, { className: Select_module_scss_1.default.selectItemIndicator, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "checkmark" }) }))] }))] }));
|
|
34
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.SimpleSelect = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const ThemeContext_1 = require("../../components-core/theming/ThemeContext");
|
|
21
|
+
const Select_module_scss_1 = __importDefault(require("./Select.module.scss"));
|
|
22
|
+
const SelectContext_1 = require("./SelectContext");
|
|
23
|
+
const IconNative_1 = __importDefault(require("../Icon/IconNative"));
|
|
24
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
25
|
+
const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
|
|
26
|
+
const react_select_1 = require("@radix-ui/react-select");
|
|
27
|
+
exports.SimpleSelect = (0, react_1.forwardRef)(function SimpleSelect(props, forwardedRef) {
|
|
28
|
+
const { root } = (0, ThemeContext_1.useTheme)();
|
|
29
|
+
const { enabled, onBlur, autoFocus, onValueChange, validationStatus, value, height, style, placeholder, id, triggerRef, onFocus, width, children, readOnly, emptyListNode, className } = props, rest = __rest(props, ["enabled", "onBlur", "autoFocus", "onValueChange", "validationStatus", "value", "height", "style", "placeholder", "id", "triggerRef", "onFocus", "width", "children", "readOnly", "emptyListNode", "className"]);
|
|
30
|
+
const { options } = (0, SelectContext_1.useSelect)();
|
|
31
|
+
const composedRef = react_1.forwardRef ? (0, react_compose_refs_1.composeRefs)(triggerRef, forwardedRef) : triggerRef;
|
|
32
|
+
// Convert value to string for Radix UI compatibility
|
|
33
|
+
const stringValue = (0, react_1.useMemo)(() => {
|
|
34
|
+
return value != undefined ? String(value) : undefined;
|
|
35
|
+
}, [value]);
|
|
36
|
+
// Handle value changes with proper type conversion
|
|
37
|
+
const handleValueChange = (0, react_1.useCallback)((val) => {
|
|
38
|
+
if (readOnly)
|
|
39
|
+
return;
|
|
40
|
+
onValueChange(val);
|
|
41
|
+
}, [onValueChange, readOnly]);
|
|
42
|
+
const optionsArray = (0, react_1.useMemo)(() => Array.from(options), [options]);
|
|
43
|
+
const selectedOption = (0, react_1.useMemo)(() => {
|
|
44
|
+
return optionsArray.find((option) => String(option.value) === String(value));
|
|
45
|
+
}, [optionsArray, value]);
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)(react_select_1.Root, { value: stringValue, onValueChange: handleValueChange, children: [(0, jsx_runtime_1.jsxs)(react_select_1.Trigger, Object.assign({}, rest, { id: id, ref: composedRef, "aria-haspopup": "listbox", style: style, onFocus: onFocus, onBlur: onBlur, disabled: !enabled, className: (0, classnames_1.default)(className, Select_module_scss_1.default.selectTrigger, {
|
|
47
|
+
[Select_module_scss_1.default.error]: validationStatus === "error",
|
|
48
|
+
[Select_module_scss_1.default.warning]: validationStatus === "warning",
|
|
49
|
+
[Select_module_scss_1.default.valid]: validationStatus === "valid",
|
|
50
|
+
}), onClick: (event) => {
|
|
51
|
+
// Prevent event propagation to parent elements (e.g., DropdownMenu)
|
|
52
|
+
// This ensures that clicking the Select trigger doesn't close the containing DropdownMenu
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
}, autoFocus: autoFocus, children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(Select_module_scss_1.default.selectValue, {
|
|
55
|
+
[Select_module_scss_1.default.placeholder]: value === undefined,
|
|
56
|
+
}), children: selectedOption ? selectedOption.label : readOnly ? "" : placeholder }), (0, jsx_runtime_1.jsx)("span", { className: Select_module_scss_1.default.action, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] })), (0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsxs)(react_select_1.Content, { className: Select_module_scss_1.default.selectDropdownContent, position: "popper", style: { maxHeight: height, minWidth: width }, children: [(0, jsx_runtime_1.jsx)(react_select_1.ScrollUpButton, { className: Select_module_scss_1.default.selectScrollUpButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronup" }) }), (0, jsx_runtime_1.jsxs)(react_select_1.Viewport, { className: Select_module_scss_1.default.selectViewport, role: "listbox", children: [children, optionsArray.length === 0 && emptyListNode] }), (0, jsx_runtime_1.jsx)(react_select_1.ScrollDownButton, { className: Select_module_scss_1.default.selectScrollDownButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }) })] }));
|
|
57
|
+
});
|
|
@@ -156,6 +156,6 @@ fixtures_1.test.describe("Edge Cases", { tag: "@smoke" }, () => {
|
|
|
156
156
|
const spinner = page.getByRole("status");
|
|
157
157
|
yield (0, fixtures_1.expect)(spinner).toBeVisible();
|
|
158
158
|
yield page.getByRole("button").click({ force: true });
|
|
159
|
-
fixtures_1.expect.poll(testStateDriver.testState).not.toEqual("clicked");
|
|
159
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).not.toEqual("clicked");
|
|
160
160
|
}));
|
|
161
161
|
});
|
|
@@ -100,7 +100,7 @@ function useRowSelection({ items = constants_1.EMPTY_ARRAY, visibleItems = items
|
|
|
100
100
|
const appStateSelection = (_a = syncWithAppState === null || syncWithAppState === void 0 ? void 0 : syncWithAppState.value) === null || _a === void 0 ? void 0 : _a.selectedIds;
|
|
101
101
|
const prevAppStateSelection = (0, hooks_1.usePrevious)(appStateSelection);
|
|
102
102
|
// --- State machine for sync direction control
|
|
103
|
-
const [syncState, setSyncState] = (0, react_1.useState)(
|
|
103
|
+
const [syncState, setSyncState] = (0, react_1.useState)("idle");
|
|
104
104
|
// --- Use refs to track the last known selections to prevent update loops
|
|
105
105
|
const lastAppStateSelectionRef = (0, react_1.useRef)();
|
|
106
106
|
const lastTableSelectionRef = (0, react_1.useRef)();
|
|
@@ -112,23 +112,23 @@ function useRowSelection({ items = constants_1.EMPTY_ARRAY, visibleItems = items
|
|
|
112
112
|
if (!rowsSelectable ||
|
|
113
113
|
!syncWithAppState ||
|
|
114
114
|
!appStateSelection ||
|
|
115
|
-
syncState ===
|
|
115
|
+
syncState === "updating_to_appstate") {
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
// Only update if AppState selection actually changed and this wasn't caused by our own table update
|
|
119
119
|
const appStateChanged = appStateSelection !== prevAppStateSelection;
|
|
120
120
|
const isDifferentFromLastKnown = JSON.stringify([...(appStateSelection || [])].sort()) !==
|
|
121
121
|
JSON.stringify([...(lastAppStateSelectionRef.current || [])].sort());
|
|
122
|
-
const wasNotOurUpdate = lastUpdateSourceRef.current !==
|
|
122
|
+
const wasNotOurUpdate = lastUpdateSourceRef.current !== "table";
|
|
123
123
|
if (appStateChanged && isDifferentFromLastKnown && wasNotOurUpdate && items.length > 0) {
|
|
124
124
|
// Set state machine to indicate we're updating from AppState
|
|
125
|
-
setSyncState(
|
|
125
|
+
setSyncState("updating_from_appstate");
|
|
126
126
|
const validIds = appStateSelection.filter((id) => items.some((item) => item[idKey] === id));
|
|
127
127
|
const idsToSelect = enableMultiRowSelection ? validIds : validIds.slice(0, 1);
|
|
128
128
|
// Track what we're setting to prevent loop
|
|
129
129
|
lastAppStateSelectionRef.current = [...appStateSelection];
|
|
130
130
|
lastTableSelectionRef.current = [...idsToSelect];
|
|
131
|
-
lastUpdateSourceRef.current =
|
|
131
|
+
lastUpdateSourceRef.current = "appstate";
|
|
132
132
|
setSelectedRowIds(idsToSelect);
|
|
133
133
|
setInitialSelectionApplied(true);
|
|
134
134
|
}
|
|
@@ -147,9 +147,7 @@ function useRowSelection({ items = constants_1.EMPTY_ARRAY, visibleItems = items
|
|
|
147
147
|
(0, react_1.useEffect)(() => {
|
|
148
148
|
var _a;
|
|
149
149
|
// Skip if not selectable, no sync, or currently updating from AppState
|
|
150
|
-
if (!rowsSelectable ||
|
|
151
|
-
!syncWithAppState ||
|
|
152
|
-
syncState === 'updating_from_appstate') {
|
|
150
|
+
if (!rowsSelectable || !syncWithAppState || syncState === "updating_from_appstate") {
|
|
153
151
|
return;
|
|
154
152
|
}
|
|
155
153
|
const currentSelectionIds = selectedItems.map((item) => item[idKey]);
|
|
@@ -159,37 +157,30 @@ function useRowSelection({ items = constants_1.EMPTY_ARRAY, visibleItems = items
|
|
|
159
157
|
JSON.stringify([...(lastTableSelectionRef.current || [])].sort());
|
|
160
158
|
const isDifferentFromAppState = JSON.stringify([...currentSelectionIds].sort()) !==
|
|
161
159
|
JSON.stringify([...appStateSelectionIds].sort());
|
|
162
|
-
const wasNotAppStateUpdate = lastUpdateSourceRef.current !==
|
|
160
|
+
const wasNotAppStateUpdate = lastUpdateSourceRef.current !== "appstate";
|
|
163
161
|
if (tableChanged && isDifferentFromAppState && wasNotAppStateUpdate) {
|
|
164
162
|
// Set state machine to indicate we're updating to AppState
|
|
165
|
-
setSyncState(
|
|
163
|
+
setSyncState("updating_to_appstate");
|
|
166
164
|
// Track what we're updating to prevent loop
|
|
167
165
|
lastTableSelectionRef.current = [...currentSelectionIds];
|
|
168
166
|
lastAppStateSelectionRef.current = [...currentSelectionIds];
|
|
169
|
-
lastUpdateSourceRef.current =
|
|
167
|
+
lastUpdateSourceRef.current = "table";
|
|
170
168
|
(_a = syncWithAppState.update) === null || _a === void 0 ? void 0 : _a.call(syncWithAppState, { selectedIds: currentSelectionIds });
|
|
171
169
|
}
|
|
172
|
-
}, [
|
|
173
|
-
selectedItems,
|
|
174
|
-
syncWithAppState,
|
|
175
|
-
appStateSelection,
|
|
176
|
-
idKey,
|
|
177
|
-
rowsSelectable,
|
|
178
|
-
syncState,
|
|
179
|
-
]);
|
|
170
|
+
}, [selectedItems, syncWithAppState, appStateSelection, idKey, rowsSelectable, syncState]);
|
|
180
171
|
// --- Reset sync state machine to idle when updates are complete
|
|
181
172
|
(0, react_1.useEffect)(() => {
|
|
182
|
-
if (syncState !==
|
|
173
|
+
if (syncState !== "idle") {
|
|
183
174
|
// Reset to idle state in the next tick to allow the current update to complete
|
|
184
175
|
const resetTimer = requestAnimationFrame(() => {
|
|
185
|
-
setSyncState(
|
|
176
|
+
setSyncState("idle");
|
|
186
177
|
});
|
|
187
178
|
return () => cancelAnimationFrame(resetTimer);
|
|
188
179
|
}
|
|
189
180
|
}, [syncState, appStateSelection, selectedItems]);
|
|
190
181
|
// --- Clear update source when sync state becomes idle
|
|
191
182
|
(0, react_1.useEffect)(() => {
|
|
192
|
-
if (syncState ===
|
|
183
|
+
if (syncState === "idle") {
|
|
193
184
|
// Use a separate frame to clear the source after the sync state is reset
|
|
194
185
|
const clearTimer = requestAnimationFrame(() => {
|
|
195
186
|
lastUpdateSourceRef.current = null;
|
|
@@ -389,7 +380,7 @@ function useRowSelection({ items = constants_1.EMPTY_ARRAY, visibleItems = items
|
|
|
389
380
|
});
|
|
390
381
|
(0, react_1.useEffect)(() => {
|
|
391
382
|
// console.log("selection DID CHANGE?");
|
|
392
|
-
onSelectionDidChange === null || onSelectionDidChange === void 0 ? void 0 : onSelectionDidChange(selectedItems);
|
|
383
|
+
void (onSelectionDidChange === null || onSelectionDidChange === void 0 ? void 0 : onSelectionDidChange(selectedItems));
|
|
393
384
|
}, [selectedItems, onSelectionDidChange]);
|
|
394
385
|
/**
|
|
395
386
|
* This operation checks or clears all rows
|
|
@@ -33,7 +33,11 @@ exports.TextMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
33
33
|
variant: {
|
|
34
34
|
description: "An optional string value that provides named presets for text variants with a " +
|
|
35
35
|
"unique combination of font style, weight, size, color, and other parameters. " +
|
|
36
|
-
"If not defined, the text uses the current style of its context."
|
|
36
|
+
"If not defined, the text uses the current style of its context. " +
|
|
37
|
+
"In addition to predefined variants, you can specify custom variant names and style them " +
|
|
38
|
+
"using theme variables with the pattern `{cssProperty}-Text-{variantName}` " +
|
|
39
|
+
"(e.g., `textColor-Text-brandTitle`, `fontSize-Text-highlight`). " +
|
|
40
|
+
"See the documentation for a complete list of supported CSS properties.",
|
|
37
41
|
availableValues: abstractions_1.variantOptionsMd,
|
|
38
42
|
},
|
|
39
43
|
maxLines: (0, metadata_helpers_1.d)("This property determines the maximum number of lines the component can wrap to. " +
|