@db-ux/react-core-components 3.1.4 → 3.1.16
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.
|
@@ -156,13 +156,18 @@ function DBCustomSelectFn(props, component) {
|
|
|
156
156
|
}
|
|
157
157
|
return false;
|
|
158
158
|
}
|
|
159
|
-
function getTagRemoveLabel(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
function getTagRemoveLabel(option) {
|
|
160
|
+
const removeTexts = props.removeTagsTexts;
|
|
161
|
+
const options = props.options;
|
|
162
|
+
if (removeTexts && options) {
|
|
163
|
+
// Find the index of the option in the original options array
|
|
164
|
+
const optionIndex = options.findIndex((opt) => opt.value === option.value);
|
|
165
|
+
if (optionIndex >= 0 && optionIndex < removeTexts.length) {
|
|
166
|
+
return removeTexts[optionIndex];
|
|
167
|
+
}
|
|
165
168
|
}
|
|
169
|
+
// Fallback to default behavior
|
|
170
|
+
return `${DEFAULT_REMOVE} ${getOptionLabel(option)}`;
|
|
166
171
|
}
|
|
167
172
|
function handleTagRemove(option, event) {
|
|
168
173
|
if (event) {
|
|
@@ -184,7 +189,7 @@ function DBCustomSelectFn(props, component) {
|
|
|
184
189
|
}
|
|
185
190
|
}
|
|
186
191
|
function handleArrowDownUp(event) {
|
|
187
|
-
var _a, _b, _c
|
|
192
|
+
var _a, _b, _c;
|
|
188
193
|
if ((_a = detailsRef.current) === null || _a === void 0 ? void 0 : _a.open) {
|
|
189
194
|
if (self.document) {
|
|
190
195
|
const activeElement = self.document.activeElement;
|
|
@@ -195,36 +200,53 @@ function DBCustomSelectFn(props, component) {
|
|
|
195
200
|
if (isCheckbox) {
|
|
196
201
|
const listElement = activeElement === null || activeElement === void 0 ? void 0 : activeElement.closest("li");
|
|
197
202
|
if (event.key === "ArrowDown" || event.key === "ArrowRight") {
|
|
198
|
-
|
|
199
|
-
|
|
203
|
+
// Find next element with input, skipping group titles
|
|
204
|
+
let nextElement = listElement === null || listElement === void 0 ? void 0 : listElement.nextElementSibling;
|
|
205
|
+
while (nextElement) {
|
|
206
|
+
const nextInput = nextElement.querySelector("input");
|
|
207
|
+
if (nextInput) {
|
|
208
|
+
nextInput.focus();
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
nextElement = nextElement.nextElementSibling;
|
|
200
212
|
}
|
|
201
|
-
|
|
213
|
+
if (!nextElement) {
|
|
202
214
|
// We are on the last checkbox we move to the top checkbox
|
|
203
215
|
handleFocusFirstDropdownCheckbox(activeElement);
|
|
204
216
|
}
|
|
205
217
|
}
|
|
206
218
|
else {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
219
|
+
// Find previous element with input, skipping group titles
|
|
220
|
+
let prevElement = listElement === null || listElement === void 0 ? void 0 : listElement.previousElementSibling;
|
|
221
|
+
while (prevElement) {
|
|
222
|
+
const prevInput = prevElement.querySelector("input");
|
|
223
|
+
if (prevInput) {
|
|
224
|
+
prevInput.focus();
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
prevElement = prevElement.previousElementSibling;
|
|
214
228
|
}
|
|
215
|
-
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
search.focus();
|
|
222
|
-
}, 100);
|
|
229
|
+
if (!prevElement) {
|
|
230
|
+
// Check if we have a "select all" checkbox (only relevant for multi-select)
|
|
231
|
+
const selectAllCheckbox = detailsRef.current.querySelector(`input[type="checkbox"]`);
|
|
232
|
+
if (selectAllCheckbox && selectAllCheckbox !== activeElement) {
|
|
233
|
+
// We are on the top list checkbox but there is a select all checkbox as well
|
|
234
|
+
handleFocusFirstDropdownCheckbox(activeElement);
|
|
223
235
|
}
|
|
224
236
|
else {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
237
|
+
// We are on the top checkbox, we need to move to the search
|
|
238
|
+
// or to the last checkbox
|
|
239
|
+
const search = getSearchInput(detailsRef.current);
|
|
240
|
+
if (search) {
|
|
241
|
+
delay(() => {
|
|
242
|
+
search.focus();
|
|
243
|
+
}, 100);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
const checkboxList = Array.from((_b = detailsRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(`input[type="checkbox"],input[type="radio"]`));
|
|
247
|
+
if (checkboxList.length) {
|
|
248
|
+
(_c = checkboxList.at(-1)) === null || _c === void 0 ? void 0 : _c.focus();
|
|
249
|
+
}
|
|
228
250
|
}
|
|
229
251
|
}
|
|
230
252
|
}
|
|
@@ -510,11 +532,14 @@ function DBCustomSelectFn(props, component) {
|
|
|
510
532
|
setSearchEnabled((_a = props.showSearch) !== null && _a !== void 0 ? _a : amountOptions > 9);
|
|
511
533
|
}, [props.showSearch, amountOptions]);
|
|
512
534
|
useEffect(() => {
|
|
513
|
-
|
|
514
|
-
if (
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
535
|
+
const v = props.values;
|
|
536
|
+
if (Array.isArray(v)) {
|
|
537
|
+
if (_values !== v) {
|
|
538
|
+
set_values(v);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
else if (v == null && (_values === null || _values === void 0 ? void 0 : _values.length) !== 0) {
|
|
542
|
+
set_values([]);
|
|
518
543
|
}
|
|
519
544
|
}, [props.values]);
|
|
520
545
|
useEffect(() => {
|
|
@@ -622,7 +647,7 @@ function DBCustomSelectFn(props, component) {
|
|
|
622
647
|
props.options ? (React.createElement(React.Fragment, null,
|
|
623
648
|
React.createElement("summary", { className: "db-custom-select-form-field", id: _summaryId, "aria-disabled": getBooleanAsString(props.disabled), "aria-labelledby": _labelId },
|
|
624
649
|
(_selectedLabels === null || _selectedLabels === void 0 ? void 0 : _selectedLabels.length) ? (React.createElement("span", { "data-visually-hidden": getBooleanAsString(props.selectedType === "tag"), id: _selectedLabelsId }, _selectedLabels)) : null,
|
|
625
|
-
props.selectedType === "tag" ? (React.createElement("div", null, _selectedOptions === null || _selectedOptions === void 0 ? void 0 : _selectedOptions.map((option, index) => (React.createElement(DBTag, { emphasis: "strong", behavior: "removable", removeButton: getTagRemoveLabel(
|
|
650
|
+
props.selectedType === "tag" ? (React.createElement("div", null, _selectedOptions === null || _selectedOptions === void 0 ? void 0 : _selectedOptions.map((option, index) => (React.createElement(DBTag, { emphasis: "strong", behavior: "removable", removeButton: getTagRemoveLabel(option), onRemove: (event) => handleTagRemove(option, event), key: getOptionKey(option, "tag-") }, getOptionLabel(option)))))) : null),
|
|
626
651
|
React.createElement(DBCustomSelectDropdown, { width: props.dropdownWidth },
|
|
627
652
|
searchEnabled ? (React.createElement("div", null,
|
|
628
653
|
React.createElement(DBInput, { type: "search", ref: searchInputRef, name: _id, form: _id, showLabel: false, value: _searchValue, label: (_d = props.searchLabel) !== null && _d !== void 0 ? _d : DEFAULT_LABEL, placeholder: (_e = props.searchPlaceholder) !== null && _e !== void 0 ? _e : props.searchLabel, ariaDescribedBy: _hasNoOptions || props.showLoading
|
|
@@ -643,7 +668,7 @@ function DBCustomSelectFn(props, component) {
|
|
|
643
668
|
((_k = props.showClearSelection) !== null && _k !== void 0 ? _k : true) && (_values === null || _values === void 0 ? void 0 : _values.length) ? (React.createElement(DBButton, { icon: "cross", variant: "ghost", size: "small", noText: true, name: _id, form: _id, onClick: (event) => handleClearAll(event) },
|
|
644
669
|
props.clearSelectionText,
|
|
645
670
|
React.createElement(DBTooltip, { placement: "top" }, props.clearSelectionText))) : null,
|
|
646
|
-
React.createElement("span", { "aria-hidden": getBooleanAsString(true), id: _placeholderId }, (_l = props.placeholder) !== null && _l !== void 0 ? _l : props.label),
|
|
671
|
+
React.createElement("span", { className: "db-custom-select-placeholder", "aria-hidden": getBooleanAsString(true), id: _placeholderId }, (_l = props.placeholder) !== null && _l !== void 0 ? _l : props.label),
|
|
647
672
|
stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: "small", icon: props.messageIcon, id: _messageId }, props.message)) : null,
|
|
648
673
|
hasValidState() ? (React.createElement(DBInfotext, { size: "small", semantic: "successful", id: _validMessageId }, props.validMessage || DEFAULT_VALID_MESSAGE)) : null,
|
|
649
674
|
React.createElement(DBInfotext, { size: "small", semantic: "critical", id: _invalidMessageId }, _invalidMessage),
|
|
@@ -194,7 +194,7 @@ export type DBCustomSelectDefaultState = {
|
|
|
194
194
|
getNativeSelectValue: () => string;
|
|
195
195
|
getOptionLabel: (option: CustomSelectOptionType) => string;
|
|
196
196
|
getOptionChecked: (value?: string) => boolean;
|
|
197
|
-
getTagRemoveLabel: (
|
|
197
|
+
getTagRemoveLabel: (option: CustomSelectOptionType) => string;
|
|
198
198
|
selectAllEnabled: boolean;
|
|
199
199
|
searchEnabled: boolean;
|
|
200
200
|
amountOptions: number;
|
|
@@ -134,7 +134,7 @@ function DBSelectFn(props, component) {
|
|
|
134
134
|
var _a;
|
|
135
135
|
return option.options ? (React.createElement("optgroup", { label: getOptionLabel(option), key: getOptionKey(option, "select-optgroup-") }, (_a = option.options) === null || _a === void 0 ? void 0 : _a.map((optgroupOption) => (React.createElement("option", { value: optgroupOption.value, disabled: optgroupOption.disabled, key: getOptionKey(optgroupOption, "select-optgroup-option-") }, getOptionLabel(optgroupOption)))))) : (React.createElement("option", { value: option.value, disabled: option.disabled, key: getOptionKey(option, "select-option-") }, getOptionLabel(option)));
|
|
136
136
|
}))) : (React.createElement(React.Fragment, null, props.children))),
|
|
137
|
-
props.placeholder ? (React.createElement("span", { id: _placeholderId }, props.placeholder)) : null,
|
|
137
|
+
props.placeholder ? (React.createElement("span", { className: "db-select-placeholder", id: _placeholderId }, props.placeholder)) : null,
|
|
138
138
|
stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: "small", icon: props.messageIcon, id: _messageId }, props.message)) : null,
|
|
139
139
|
hasValidState() ? (React.createElement(DBInfotext, { size: "small", semantic: "successful", id: _validMessageId }, props.validMessage || DEFAULT_VALID_MESSAGE)) : null,
|
|
140
140
|
React.createElement(DBInfotext, { size: "small", semantic: "critical", id: _invalidMessageId }, _invalidMessage),
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
export const handleFrameworkEventAngular = (component, event, modelValue = 'value') => {
|
|
3
|
-
// Change event to work with reactive and template driven forms
|
|
4
3
|
component.propagateChange(event.target[modelValue]);
|
|
5
|
-
component.writeValue(event.target[modelValue]);
|
|
6
4
|
};
|
|
7
5
|
export const handleFrameworkEventVue = (emit, event, modelValue = 'value') => {
|
|
8
6
|
// TODO: Replace this with the solution out of https://github.com/BuilderIO/mitosis/issues/833 after this has been "solved"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@db-ux/react-core-components",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.16",
|
|
4
4
|
"description": "React components for @db-ux/core-components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"module": "./dist/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"files": [
|
|
14
|
-
"dist/"
|
|
14
|
+
"dist/",
|
|
15
|
+
"CHANGELOG.md"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|
|
17
18
|
"build": "npm-run-all tsc",
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
"tsc": "tsc --project . --sourceMap false"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@playwright/experimental-ct-react": "1.55.
|
|
31
|
+
"@playwright/experimental-ct-react": "1.55.1",
|
|
31
32
|
"@types/react": "18.3.13",
|
|
32
33
|
"react": "18.3.1",
|
|
33
34
|
"react-dom": "18.3.1"
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
},
|
|
39
40
|
"sideEffects": false,
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@db-ux/core-components": "3.1.
|
|
42
|
-
"@db-ux/core-foundations": "3.1.
|
|
42
|
+
"@db-ux/core-components": "3.1.16",
|
|
43
|
+
"@db-ux/core-foundations": "3.1.16"
|
|
43
44
|
}
|
|
44
45
|
}
|