@nova-design-system/nova-react 3.18.0 → 3.20.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/README.md +3 -20
- package/dist/cjs/generated/components.server.js +4 -2
- package/dist/cjs/{index-_oq_uffl.js → index-BObVnP12.js} +373 -332
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/{nv-accordion-item.entry-DBO7ztqb.js → nv-accordion-item.entry-BBAGkmLI.js} +1 -1
- package/dist/cjs/{nv-accordion.entry-Ma9HqnfE.js → nv-accordion.entry-CvvtdLIz.js} +1 -1
- package/dist/cjs/{nv-alert.entry--bKp-lux.js → nv-alert.entry-w5XeFsrC.js} +1 -1
- package/dist/cjs/{nv-avatar.entry-DN_-lrBo.js → nv-avatar.entry-BxUZg-8h.js} +1 -1
- package/dist/cjs/{nv-badge_2.entry-Dl4iJgMU.js → nv-badge_2.entry-DdSIFlJf.js} +2 -2
- package/dist/cjs/{nv-breadcrumb.entry-BBvgQ-p_.js → nv-breadcrumb.entry-CmbqGw3C.js} +1 -1
- package/dist/cjs/{nv-breadcrumbs.entry-1SoAvjZG.js → nv-breadcrumbs.entry-DFHxtPKv.js} +1 -1
- package/dist/cjs/{nv-button.entry-B4k5GJIo.js → nv-button.entry-Dyks6_mF.js} +1 -1
- package/dist/cjs/{nv-buttongroup.entry-B5LQavYS.js → nv-buttongroup.entry-wn9zFd_M.js} +1 -1
- package/dist/cjs/{nv-calendar.entry-mOSPsfm-.js → nv-calendar.entry-Dldsa6dz.js} +1 -1
- package/dist/cjs/{nv-col.entry-Dzg7C_6U.js → nv-col.entry-DnG79KM1.js} +1 -1
- package/dist/cjs/{nv-datagrid.entry-CfZeMjYO.js → nv-datagrid.entry-C2ML-e47.js} +1 -1
- package/dist/cjs/{nv-datagridcolumn.entry-DEqq7_M9.js → nv-datagridcolumn.entry-DcMPUtQS.js} +1 -1
- package/dist/cjs/{nv-dialog.entry-DSX9jRuv.js → nv-dialog.entry-C0Vx7dQc.js} +1 -1
- package/dist/cjs/{nv-dialogfooter_2.entry-t9MuuUDn.js → nv-dialogfooter_2.entry-BGq8Jiib.js} +1 -1
- package/dist/cjs/{nv-fieldcheckbox.entry-KDMtAaLt.js → nv-fieldcheckbox.entry-CAPwYnSU.js} +1 -1
- package/dist/cjs/{nv-fielddate.entry-SjEKszkJ.js → nv-fielddate.entry-Byt5cmQi.js} +11 -7
- package/dist/cjs/{nv-fielddaterange.entry-B6pLWuF3.js → nv-fielddaterange.entry-CCFeFP2q.js} +12 -8
- package/dist/cjs/{nv-fielddropdown.entry-DIYVOvRw.js → nv-fielddropdown.entry-BFp_2vBC.js} +194 -210
- package/dist/cjs/{nv-fielddropdownitem.entry-CUMPmEzj.js → nv-fielddropdownitem.entry-D_4KdBY1.js} +8 -5
- package/dist/cjs/{nv-fieldmultiselect.entry-BFt11EM5.js → nv-fieldmultiselect.entry-BaUD7Dcr.js} +5 -1
- package/dist/cjs/{nv-fieldnumber.entry-V2AYjG7j.js → nv-fieldnumber.entry-DOmhBrDv.js} +25 -8
- package/dist/cjs/{nv-fieldpassword.entry-BoQAgzW2.js → nv-fieldpassword.entry-hogiPC5z.js} +4 -4
- package/dist/cjs/{nv-fieldradio.entry-CKDZ6g8q.js → nv-fieldradio.entry-CKbyWpIK.js} +4 -4
- package/dist/cjs/{nv-fieldselect.entry-Daa3JB5t.js → nv-fieldselect.entry-tpURNUEP.js} +6 -6
- package/dist/cjs/{nv-fieldslider.entry-BhT0C9hG.js → nv-fieldslider.entry-v0d92XEY.js} +7 -5
- package/dist/cjs/{nv-fieldtext.entry-a1x9CfYv.js → nv-fieldtext.entry-DNYrOAhj.js} +4 -4
- package/dist/cjs/{nv-fieldtextarea.entry-nn5SqAJD.js → nv-fieldtextarea.entry-cRsjPwwR.js} +4 -4
- package/dist/cjs/{nv-fieldtime.entry-DQb9u4eg.js → nv-fieldtime.entry-BpGBUfKr.js} +5 -4
- package/dist/cjs/nv-icon.entry-BfmyacWA.js +80 -0
- package/dist/cjs/{nv-iconbutton_2.entry-WTj2sSR7.js → nv-iconbutton_2.entry-DOv1RrkS.js} +3 -3
- package/dist/cjs/{nv-menu.entry-DnHSkRkc.js → nv-menu.entry-C2L8F-nG.js} +3 -3
- package/dist/cjs/{nv-menuitem.entry-BMThBD-z.js → nv-menuitem.entry-DuDZTlJ1.js} +2 -2
- package/dist/cjs/{nv-notification.entry-BgORwEc6.js → nv-notification.entry-DxAj-mc7.js} +2 -2
- package/dist/cjs/{nv-notificationcontainer.entry-C3D52xHp.js → nv-notificationcontainer.entry-CUnTicXF.js} +2 -2
- package/dist/cjs/{nv-popover.entry-Bc5Hs_ZA.js → nv-popover.entry-DVwa4DvW.js} +3 -3
- package/dist/cjs/{nv-row.entry-rTFsRQhn.js → nv-row.entry-iLk2UglX.js} +2 -2
- package/dist/cjs/{nv-split.entry-CEkdVB0d.js → nv-split.entry-BrMHK6TS.js} +2 -2
- package/dist/cjs/{nv-stack.entry-DFWmiZRf.js → nv-stack.entry-C8jLJ5Ki.js} +2 -2
- package/dist/cjs/{nv-table.entry-Drf8wXN5.js → nv-table.entry-D6o4g9Vo.js} +2 -2
- package/dist/cjs/{nv-toggle.entry-D3jHT0co.js → nv-toggle.entry-9iwmu7qi.js} +3 -3
- package/dist/cjs/{nv-togglebutton.entry-zN93TaA9.js → nv-togglebutton.entry-N7_CSvzS.js} +2 -2
- package/dist/cjs/{nv-togglebuttongroup.entry-D4dUkodA.js → nv-togglebuttongroup.entry-DWCytOhV.js} +2 -2
- package/dist/cjs/{nv-tooltip.entry-DqFRA9_B.js → nv-tooltip.entry-BMxnZVYA.js} +2 -2
- package/dist/components/NvDatatable.js +17 -2
- package/dist/generated/components.js +2 -0
- package/dist/generated/components.server.js +4 -2
- package/dist/types/components/NvDatatable.d.ts +26 -19
- package/dist/types/generated/components.d.ts +4 -1
- package/dist/types/generated/components.server.d.ts +4 -1
- package/package.json +1 -1
- package/dist/cjs/nv-icon.entry-17nX7627.js +0 -80
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-BObVnP12.js');
|
|
4
4
|
var v4A79185f4 = require('./v4-a79185f4-2n0dOd_Y.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('react-dom');
|
|
@@ -12,6 +12,8 @@ const NvFielddropdown = class {
|
|
|
12
12
|
constructor(hostRef) {
|
|
13
13
|
index.registerInstance(this, hostRef);
|
|
14
14
|
this.valueChanged = index.createEvent(this, "valueChanged");
|
|
15
|
+
this.filterTextChanged = index.createEvent(this, "filterTextChanged");
|
|
16
|
+
this.openChanged = index.createEvent(this, "openChanged");
|
|
15
17
|
this.dropdownItemSelected = index.createEvent(this, "dropdownItemSelected");
|
|
16
18
|
/****************************************************************************/
|
|
17
19
|
//#region PROPERTIES
|
|
@@ -56,10 +58,6 @@ const NvFielddropdown = class {
|
|
|
56
58
|
* Defines the maximum height of the multiselect list when open.
|
|
57
59
|
*/
|
|
58
60
|
this.maxHeight = '';
|
|
59
|
-
/**
|
|
60
|
-
* State of the dropdown popover.
|
|
61
|
-
*/
|
|
62
|
-
this.open = false;
|
|
63
61
|
/**
|
|
64
62
|
* The text to display when no items match the filter.
|
|
65
63
|
*/
|
|
@@ -69,7 +67,21 @@ const NvFielddropdown = class {
|
|
|
69
67
|
*/
|
|
70
68
|
this.filterable = false;
|
|
71
69
|
/**
|
|
72
|
-
*
|
|
70
|
+
* When an item is selected by the user, the dropdown will continue to stay
|
|
71
|
+
* open.
|
|
72
|
+
*/
|
|
73
|
+
this.openOnSelect = false;
|
|
74
|
+
/**
|
|
75
|
+
* Determines if the component’s filtering behavior is managed externally.
|
|
76
|
+
* When set to true and filterable is enabled, the component won’t
|
|
77
|
+
* automatically filter items. Instead, you must implement your own filtering
|
|
78
|
+
* logic (e.g., server-side search or custom matching) using the
|
|
79
|
+
* filterTextChanged event.
|
|
80
|
+
*/
|
|
81
|
+
this.controlledFilter = false;
|
|
82
|
+
/**
|
|
83
|
+
* Delay in milliseconds before the search is triggered when typing in the
|
|
84
|
+
* filter input.
|
|
73
85
|
* @default 300
|
|
74
86
|
*/
|
|
75
87
|
this.debounceDelay = 300;
|
|
@@ -91,132 +103,75 @@ const NvFielddropdown = class {
|
|
|
91
103
|
*/
|
|
92
104
|
this.filterText = '';
|
|
93
105
|
this.selectedValues = new Set();
|
|
94
|
-
this.
|
|
95
|
-
|
|
106
|
+
this.open = false;
|
|
107
|
+
/**
|
|
108
|
+
* Closes the popover when a click is detected outside the component.
|
|
109
|
+
* @param {MouseEvent} event - The click event.
|
|
110
|
+
*/
|
|
111
|
+
this.handleClickOutside = (event) => {
|
|
112
|
+
var _a;
|
|
113
|
+
if (!(event.target instanceof Node))
|
|
96
114
|
return;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (target.tagName === 'P' || target.tagName === 'SPAN') {
|
|
100
|
-
this.open = true;
|
|
101
|
-
// Simulate focus to trigger "focus-within" style
|
|
102
|
-
const inputContainer = this.el.querySelector('.input-container');
|
|
103
|
-
if (inputContainer) {
|
|
104
|
-
inputContainer.classList.add('focus-within');
|
|
105
|
-
// Remove the "focus-within" class after a delay or when the popover is closed
|
|
106
|
-
const removeFocusWithin = () => {
|
|
107
|
-
inputContainer.classList.remove('focus-within');
|
|
108
|
-
};
|
|
109
|
-
// Or remove the class when the popover is closed
|
|
110
|
-
this.popoverElement.addEventListener('hide', removeFocusWithin);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
115
|
+
if (!((_a = this.el) === null || _a === void 0 ? void 0 : _a.contains(event.target)))
|
|
116
|
+
this.open = false;
|
|
113
117
|
};
|
|
114
|
-
this.
|
|
115
|
-
if (!this.filterable)
|
|
116
|
-
return;
|
|
117
|
-
if (this.disabled || this.readonly) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const input = event.target;
|
|
118
|
+
this.handleFilterInput = () => {
|
|
121
119
|
this.open = true;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
// Set a new timer for filtering
|
|
120
|
+
this.filterText = this.inputElement.value;
|
|
121
|
+
this.filterTextChanged.emit(this.inputElement.value);
|
|
122
|
+
clearTimeout(this.debounceTimer);
|
|
127
123
|
this.debounceTimer = window.setTimeout(() => {
|
|
128
|
-
this.filterText = input.value.toLowerCase();
|
|
129
124
|
this.filterItems();
|
|
130
125
|
}, this.debounceDelay);
|
|
131
126
|
};
|
|
132
|
-
this.handleInputFocus = () => {
|
|
133
|
-
if (this.disabled || this.readonly)
|
|
134
|
-
return;
|
|
135
|
-
this.open = true;
|
|
136
|
-
};
|
|
137
|
-
this.togglePopover = () => {
|
|
138
|
-
if (this.disabled || this.readonly)
|
|
139
|
-
return;
|
|
140
|
-
this.open = !this.open;
|
|
141
|
-
};
|
|
142
127
|
this.getSelectedLabel = () => {
|
|
143
|
-
var _a, _b, _c, _d, _e, _f;
|
|
128
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
144
129
|
if (!this.value)
|
|
145
130
|
return '';
|
|
146
|
-
if ((
|
|
131
|
+
if ((_a = this.filterText) === null || _a === void 0 ? void 0 : _a.length)
|
|
132
|
+
return this.filterText;
|
|
133
|
+
if (((_b = this.options) === null || _b === void 0 ? void 0 : _b.length) > 1) {
|
|
147
134
|
const matchingItem = this.options.find(option => option.value === this.value);
|
|
148
|
-
return (
|
|
135
|
+
return (_d = (_c = matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.label) !== null && _c !== void 0 ? _c : matchingItem === null || matchingItem === void 0 ? void 0 : matchingItem.value) !== null && _d !== void 0 ? _d : this.value;
|
|
149
136
|
}
|
|
150
137
|
const items = Array.from(this.el.querySelectorAll('nv-fielddropdownitem'));
|
|
151
138
|
const matchingItem = items.find(item => item.value === this.value);
|
|
152
139
|
const selectedLabel = matchingItem
|
|
153
|
-
? (
|
|
140
|
+
? (_g = (_e = matchingItem.label) !== null && _e !== void 0 ? _e : (_f = matchingItem.textContent) === null || _f === void 0 ? void 0 : _f.trim()) !== null && _g !== void 0 ? _g : matchingItem.value
|
|
154
141
|
: '';
|
|
155
142
|
return selectedLabel;
|
|
156
143
|
};
|
|
157
|
-
this.clearFilter = () => {
|
|
158
|
-
if (!this.filterable)
|
|
159
|
-
return;
|
|
160
|
-
this.filterText = '';
|
|
161
|
-
this.inputElement.value = this.getSelectedLabel();
|
|
162
|
-
this.inputElement.focus();
|
|
163
|
-
this.filterItems();
|
|
164
|
-
};
|
|
165
|
-
this.handleBlurInput = (event) => {
|
|
166
|
-
var _a;
|
|
167
|
-
const relatedTarget = event.relatedTarget;
|
|
168
|
-
if (!this.el.contains(relatedTarget) &&
|
|
169
|
-
!((_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.contains(relatedTarget))) {
|
|
170
|
-
this.open = false;
|
|
171
|
-
if (this.filterable) {
|
|
172
|
-
this.clearFilter(); // Resets input to selected label, clears filterText
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
144
|
}
|
|
177
145
|
//#endregion EVENTS
|
|
178
146
|
/****************************************************************************/
|
|
179
147
|
//#region WATCHERS
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
this.value = (_a = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value) !== null && _a !== void 0 ? _a : '';
|
|
187
|
-
this.updateSelectedItem(this.value);
|
|
148
|
+
handleOpenChange(newOpen) {
|
|
149
|
+
if (newOpen === false) {
|
|
150
|
+
clearTimeout(this.debounceTimer);
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
this.clearFilter();
|
|
153
|
+
}, 100);
|
|
188
154
|
}
|
|
189
155
|
}
|
|
190
|
-
|
|
191
|
-
this.
|
|
156
|
+
handleValueChange() {
|
|
157
|
+
this.updateSelectedItem();
|
|
158
|
+
if (!this.open || !this.filterText)
|
|
159
|
+
this.setFilterInputToSelectedValue();
|
|
192
160
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (newOpen && this.filterable) {
|
|
196
|
-
this.filterItems(); // Ensure items are filtered if filterText exists
|
|
197
|
-
}
|
|
198
|
-
else if (!newOpen) {
|
|
199
|
-
this.clearFilter(); // Clear on external close
|
|
200
|
-
}
|
|
161
|
+
handleOptionsChange() {
|
|
162
|
+
this.updateSelectedItem();
|
|
201
163
|
}
|
|
202
164
|
//#endregion WATCHERS
|
|
203
165
|
/****************************************************************************/
|
|
204
166
|
//#region LISTENERS
|
|
205
|
-
handleOpenChanged(event) {
|
|
206
|
-
// Stop propagation to prevent the event from affecting parent components like dialogs
|
|
207
|
-
event.stopPropagation();
|
|
208
|
-
// Update `open` based on the popover state
|
|
209
|
-
if (event.target === this.popoverElement) {
|
|
210
|
-
this.open = event.detail;
|
|
211
|
-
}
|
|
212
|
-
if (!event.detail && this.filterable) {
|
|
213
|
-
this.clearFilter();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
167
|
handleDropdownItemSelected(event) {
|
|
217
168
|
if (this.disabled || this.readonly)
|
|
218
169
|
return;
|
|
219
|
-
|
|
170
|
+
if (!this.openOnSelect)
|
|
171
|
+
this.open = false;
|
|
172
|
+
if (event.detail.detached)
|
|
173
|
+
return;
|
|
174
|
+
const items = this.getAllItems();
|
|
220
175
|
items.forEach(item => {
|
|
221
176
|
if (item !== event.target) {
|
|
222
177
|
item.removeAttribute('selected');
|
|
@@ -225,102 +180,147 @@ const NvFielddropdown = class {
|
|
|
225
180
|
item.setAttribute('selected', 'true');
|
|
226
181
|
}
|
|
227
182
|
});
|
|
228
|
-
this.clearFilter();
|
|
229
183
|
this.value = event.detail.value;
|
|
230
|
-
this.
|
|
184
|
+
this.setFilterInputToSelectedValue();
|
|
185
|
+
this.valueChanged.emit(event.detail.value);
|
|
231
186
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (this.inputElement) {
|
|
237
|
-
this.filterText = '';
|
|
238
|
-
this.inputElement.value = this.getSelectedLabel();
|
|
239
|
-
setTimeout(() => {
|
|
240
|
-
this.filterItems();
|
|
241
|
-
}, 200);
|
|
242
|
-
}
|
|
187
|
+
handleFocus(event) {
|
|
188
|
+
if (event.relatedTarget instanceof HTMLElement &&
|
|
189
|
+
event.relatedTarget.tagName.includes('NV-FIELDDROPDOWNITEM')) {
|
|
190
|
+
return;
|
|
243
191
|
}
|
|
192
|
+
if (event.target != this.toggleElement)
|
|
193
|
+
this.open = true;
|
|
194
|
+
}
|
|
195
|
+
handleFocusOut(event) {
|
|
196
|
+
if (!(event.relatedTarget instanceof Node))
|
|
197
|
+
return;
|
|
198
|
+
if (this.el.contains(event.relatedTarget))
|
|
199
|
+
return;
|
|
200
|
+
this.open = false;
|
|
244
201
|
}
|
|
245
202
|
handleKeyDown(event) {
|
|
246
|
-
if (
|
|
203
|
+
if (event.key === 'Escape') {
|
|
204
|
+
this.focusField();
|
|
205
|
+
this.open = false;
|
|
247
206
|
return;
|
|
248
|
-
|
|
249
|
-
|
|
207
|
+
}
|
|
208
|
+
if (event.key === ' ') {
|
|
209
|
+
if (event.target == this.selectElement) {
|
|
210
|
+
event.preventDefault(); // Prevent scrolling down
|
|
250
211
|
this.open = true;
|
|
251
|
-
event.preventDefault();
|
|
252
|
-
return;
|
|
253
212
|
}
|
|
254
213
|
return;
|
|
255
214
|
}
|
|
256
|
-
const items =
|
|
257
|
-
|
|
215
|
+
const items = this.getNavigableItems();
|
|
216
|
+
const highlightedItem = this.getHighlightedItemIndex(items);
|
|
258
217
|
if (event.key === 'ArrowDown') {
|
|
259
|
-
event.preventDefault();
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
else if (event.key === 'ArrowUp') {
|
|
264
|
-
event.preventDefault();
|
|
265
|
-
currentIndex = (currentIndex - 1 + items.length) % items.length;
|
|
266
|
-
this.updateHighlightedItem(items, currentIndex);
|
|
218
|
+
event.preventDefault(); // Prevent scrolling down
|
|
219
|
+
this.open = true;
|
|
220
|
+
const nextIndex = highlightedItem + 1;
|
|
221
|
+
this.updateHighlightedItem(items, nextIndex >= items.length ? 0 : nextIndex);
|
|
267
222
|
}
|
|
268
|
-
|
|
269
|
-
event.preventDefault();
|
|
270
|
-
this.open =
|
|
223
|
+
if (event.key === 'ArrowUp') {
|
|
224
|
+
event.preventDefault(); // Prevent scrolling up
|
|
225
|
+
this.open = true;
|
|
226
|
+
const nextIndex = highlightedItem - 1;
|
|
227
|
+
this.updateHighlightedItem(items, nextIndex < 0 ? items.length - 1 : nextIndex);
|
|
271
228
|
}
|
|
272
229
|
}
|
|
230
|
+
handleDocumentClick(event) {
|
|
231
|
+
this.handleClickOutside(event);
|
|
232
|
+
}
|
|
273
233
|
//#endregion LISTENERS
|
|
274
234
|
/****************************************************************************/
|
|
275
|
-
//#region
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
if (this.
|
|
282
|
-
this.
|
|
235
|
+
//#region METHODS
|
|
236
|
+
/** Clears the filter text */
|
|
237
|
+
async clearFilter() {
|
|
238
|
+
var _a;
|
|
239
|
+
if (!this.filterable)
|
|
240
|
+
return;
|
|
241
|
+
if ((_a = this.filterText) === null || _a === void 0 ? void 0 : _a.length) {
|
|
242
|
+
this.filterText = '';
|
|
243
|
+
this.filterTextChanged.emit(this.filterText);
|
|
283
244
|
}
|
|
245
|
+
this.filterItems();
|
|
246
|
+
// Wait for wrapper lifecycle to finish
|
|
247
|
+
setTimeout(() => {
|
|
248
|
+
this.setFilterInputToSelectedValue();
|
|
249
|
+
}, 0);
|
|
284
250
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
251
|
+
/**
|
|
252
|
+
* Toggles the dropdown popover open state
|
|
253
|
+
* @param {boolean} open - The open state to set, if null, toggles the state
|
|
254
|
+
*/
|
|
255
|
+
async toggleDropdown(open) {
|
|
256
|
+
if (open !== undefined) {
|
|
257
|
+
setTimeout(() => {
|
|
258
|
+
this.open = open;
|
|
259
|
+
}, 0);
|
|
288
260
|
}
|
|
289
|
-
|
|
290
|
-
|
|
261
|
+
else {
|
|
262
|
+
setTimeout(() => {
|
|
263
|
+
this.open = !this.open;
|
|
264
|
+
}, 0);
|
|
291
265
|
}
|
|
292
266
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
267
|
+
syncToggleDropdown() {
|
|
268
|
+
this.open = !this.open;
|
|
269
|
+
}
|
|
270
|
+
setFilterInputToSelectedValue() {
|
|
271
|
+
if (!this.filterable)
|
|
272
|
+
return;
|
|
273
|
+
if (!this.value)
|
|
274
|
+
return (this.inputElement.value = '');
|
|
275
|
+
this.inputElement.value = this.getSelectedLabel();
|
|
276
|
+
}
|
|
277
|
+
// Will exclude detached items and data-empty
|
|
278
|
+
getFilterableItems() {
|
|
279
|
+
return Array.from(this.el.querySelectorAll('nv-fielddropdownitem:not([data-empty]):not([detached])'));
|
|
280
|
+
}
|
|
281
|
+
getNavigableItems() {
|
|
282
|
+
return Array.from(this.el.querySelectorAll('nv-fielddropdownitem:not([disabled]):not([hidden])'));
|
|
283
|
+
}
|
|
284
|
+
getAllItems() {
|
|
285
|
+
return Array.from(this.el.querySelectorAll('nv-fielddropdownitem'));
|
|
286
|
+
}
|
|
287
|
+
getHighlightedItemIndex(items) {
|
|
288
|
+
return items.findIndex(item => item.classList.contains('highlighted'));
|
|
289
|
+
}
|
|
290
|
+
updateHighlightedItem(items, index) {
|
|
291
|
+
items.forEach((item, i) => {
|
|
292
|
+
item.classList.remove('highlighted');
|
|
293
|
+
if (i === index) {
|
|
294
|
+
item.classList.add('highlighted');
|
|
295
|
+
item.focus();
|
|
296
|
+
item.scrollIntoView({ block: 'nearest' });
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
focusField() {
|
|
301
|
+
const focusableItem = this.el.querySelector('[data-scope="focusable"]');
|
|
302
|
+
focusableItem === null || focusableItem === void 0 ? void 0 : focusableItem.focus();
|
|
302
303
|
}
|
|
303
304
|
/**
|
|
304
305
|
* Filter dropdown items based on the text entered by the user.
|
|
305
306
|
* If no items are found, display a message indicating no results.
|
|
306
307
|
*/
|
|
307
308
|
filterItems() {
|
|
308
|
-
var _a;
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
const existingEmptyItem = this.el.querySelector('nv-fielddropdownitem[data-empty]');
|
|
312
|
-
if (existingEmptyItem) {
|
|
313
|
-
existingEmptyItem.remove();
|
|
314
|
-
}
|
|
309
|
+
var _a, _b;
|
|
310
|
+
if (this.controlledFilter)
|
|
311
|
+
return;
|
|
315
312
|
let hasVisibleItems = false;
|
|
316
|
-
|
|
313
|
+
const items = this.getFilterableItems();
|
|
314
|
+
// Remove the "no results found" item if it exists
|
|
315
|
+
(_a = this.el
|
|
316
|
+
.querySelector('nv-fielddropdownitem[data-empty]')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
317
317
|
items.forEach(item => {
|
|
318
318
|
var _a, _b;
|
|
319
|
-
const
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
319
|
+
const filterText = this.filterText.toLowerCase();
|
|
320
|
+
const textContent = ((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
|
|
321
|
+
const value = ((_b = item.value) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || '';
|
|
322
|
+
// Either in the value or in the textual content
|
|
323
|
+
const shouldShow = value.includes(filterText) || textContent.includes(filterText);
|
|
324
324
|
if (shouldShow)
|
|
325
325
|
item.removeAttribute('hidden');
|
|
326
326
|
else
|
|
@@ -335,63 +335,47 @@ const NvFielddropdown = class {
|
|
|
335
335
|
emptyItem.setAttribute('data-empty', 'true');
|
|
336
336
|
emptyItem.setAttribute('disabled', 'true');
|
|
337
337
|
emptyItem.textContent = this.emptyResult;
|
|
338
|
-
(
|
|
338
|
+
(_b = this.el.querySelector('div[slot="content"] ul')) === null || _b === void 0 ? void 0 : _b.prepend(emptyItem);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
341
|
+
async updateSelectedItem() {
|
|
342
|
+
const items = this.getAllItems();
|
|
343
|
+
if (this.value) {
|
|
344
|
+
items.forEach(item => {
|
|
345
|
+
if (item.value === this.value) {
|
|
346
|
+
item.selected = true;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
item.selected = false;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}
|
|
347
353
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
item.classList.remove('highlighted');
|
|
357
|
-
}
|
|
358
|
-
});
|
|
354
|
+
//#endregion METHODS
|
|
355
|
+
/****************************************************************************/
|
|
356
|
+
//#region LIFECYCLE
|
|
357
|
+
componentDidLoad() {
|
|
358
|
+
this.updateSelectedItem();
|
|
359
|
+
this.setFilterInputToSelectedValue();
|
|
359
360
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return;
|
|
363
|
-
const items = Array.from(this.el.querySelectorAll('nv-fielddropdownitem'));
|
|
364
|
-
const matchingItem = items.find(item => {
|
|
365
|
-
var _a;
|
|
366
|
-
const itemLabel = item.getAttribute('label');
|
|
367
|
-
const itemValue = item.getAttribute('value');
|
|
368
|
-
const itemText = (_a = item.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
369
|
-
return itemLabel === value || itemValue === value || itemText === value;
|
|
370
|
-
});
|
|
371
|
-
items.forEach(item => {
|
|
372
|
-
if (item === matchingItem) {
|
|
373
|
-
item.setAttribute('selected', '');
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
item.removeAttribute('selected');
|
|
377
|
-
}
|
|
378
|
-
});
|
|
361
|
+
disconnectedCallback() {
|
|
362
|
+
clearTimeout(this.debounceTimer);
|
|
379
363
|
}
|
|
380
|
-
//#endregion
|
|
364
|
+
//#endregion LIFECYCLE
|
|
381
365
|
/****************************************************************************/
|
|
382
366
|
//#region RENDER
|
|
383
367
|
render() {
|
|
384
368
|
var _a;
|
|
385
|
-
return (index.h(index.Host, { key: '
|
|
386
|
-
this.el.querySelector('[slot="description"]')) && (index.h("div", { key: '
|
|
387
|
-
this.el.querySelector('[slot="error-description"]')) && (index.h("div", { key: '
|
|
369
|
+
return (index.h(index.Host, { key: '428dd85337710d430ac04cf8cbc9021a93307bfe', role: "combobox", "aria-expanded": this.open.toString(), "aria-haspopup": "listbox", "aria-label": this.label }, (this.label || this.el.querySelector('[slot="label"]')) && (index.h("label", { key: 'a527c33d31152a90f8641e27fbaf91cf73eb06b6', htmlFor: this.inputId, onClick: this.syncToggleDropdown.bind(this) }, index.h("slot", { key: 'e4cf96c38db69080228666e4b924367a0c3a9d72', name: "label" }, this.label))), index.h("nv-popover", { key: '41723f7ec67e4e5680381e217eba45a1d73b47fc', triggerMode: "controlled", placement: "bottom-start", open: this.open }, index.h("div", { key: 'd4af00d5171b09923c36df9fd44853e1399e584f', class: "input-wrapper", slot: "trigger" }, index.h("slot", { key: 'bb6e53746c70fcc8172acd9a7ef8cbf72ae70698', name: "before-input" }), index.h("div", { key: 'ef3dc9ac5d0d895384653a17f8e61f616a7cbba9', class: "input-container" }, index.h("slot", { key: '7621b8cb7222330e73a426282877df2e0040714c', name: "leading-input" }), this.filterable || this.disabled || this.readonly ? (index.h("input", { "data-scope": "focusable", id: this.inputId, type: "search", ref: e => (this.inputElement = e), autofocus: this.autofocus, autocomplete: this.autocomplete, placeholder: this.placeholder, name: this.name, required: this.required, disabled: this.disabled, readOnly: this.readonly, onInput: this.handleFilterInput })) : (index.h("p", { "data-scope": "focusable", id: this.inputId, ref: el => (this.selectElement = el), class: "non-filterable-text", tabIndex: this.disabled ? -1 : 0 }, this.getSelectedLabel() || this.value || this.placeholder)), this.filterable && this.filterText && (index.h("nv-iconbutton", { key: '3de283e59d0c7811b39e30d98fdd7e400a1b3d49', name: "x", size: "md", emphasis: "lower", class: "clear-button", onClick: this.clearFilter.bind(this), "aria-label": "Clear input" })), this.error && (index.h("nv-icon", { key: '6f826edb19430ce535dc8742dfbd77b05d673f4d', name: "alert-circle", class: "validation", size: "md" })), index.h("nv-iconbutton", { key: '611f8df410c38faeb9fec9a43ac1f7013ce9b32b', "data-scope": "toggle-dropdown", ref: el => (this.toggleElement = el), name: this.open ? 'chevron-top' : 'chevron-down', size: "md", emphasis: "lower", "aria-label": this.open ? 'Hide dropdown' : 'Show dropdown', onClick: this.syncToggleDropdown.bind(this), tabIndex: this.disabled ? -1 : 0 })), index.h("slot", { key: '18d16b6c1d3c1ab910f8a45a339ae750e2277542', name: "after-input" })), index.h("div", { key: '53624675adac2c6c9345b64e634cbbad4f009a82', slot: "content", style: this.maxHeight ? { maxHeight: this.maxHeight } : {} }, ((_a = this.options) === null || _a === void 0 ? void 0 : _a.length) > 0 && (index.h("ul", { key: '3dfd5e914176bab898fd7872eb4ea0206d12b80a' }, this.options.map(option => (index.h("nv-fielddropdownitem", { label: option.label, value: option.value, disabled: option.disabled, selected: option.value === this.value }))))), index.h("slot", { key: 'e1c9151e125d0fe6f129b879b0adf1ae91b94bc4', name: "content" }))), (this.description ||
|
|
370
|
+
this.el.querySelector('[slot="description"]')) && (index.h("div", { key: '13247930760480ec767ce75c61385036126cd2f3', class: "description" }, index.h("slot", { key: '09c3f2fa0a1be5bcbe69b757a68a8327fef29ec1', name: "description" }, this.description))), (this.errorDescription ||
|
|
371
|
+
this.el.querySelector('[slot="error-description"]')) && (index.h("div", { key: '9b43e41b6b38242b21c750d2d442c78e0930b9bc', hidden: !this.error, class: "error-description" }, index.h("slot", { key: '44f7756522adbc54b8d85a211dace24a37073fc6', name: "error-description" }, this.errorDescription)))));
|
|
388
372
|
}
|
|
389
373
|
static get formAssociated() { return true; }
|
|
390
374
|
get el() { return index.getElement(this); }
|
|
391
375
|
static get watchers() { return {
|
|
392
|
-
"
|
|
393
|
-
"value": ["
|
|
394
|
-
"
|
|
376
|
+
"open": ["handleOpenChange"],
|
|
377
|
+
"value": ["handleValueChange"],
|
|
378
|
+
"options": ["handleOptionsChange"]
|
|
395
379
|
}; }
|
|
396
380
|
};
|
|
397
381
|
NvFielddropdown.style = NvFielddropdownStyle0;
|
package/dist/cjs/{nv-fielddropdownitem.entry-CUMPmEzj.js → nv-fielddropdownitem.entry-D_4KdBY1.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-BObVnP12.js');
|
|
4
4
|
require('react');
|
|
5
5
|
require('react-dom');
|
|
6
6
|
|
|
@@ -22,6 +22,11 @@ const NvFielddropdownitem = class {
|
|
|
22
22
|
* Indicates if the item is selected.
|
|
23
23
|
*/
|
|
24
24
|
this.selected = false;
|
|
25
|
+
/**
|
|
26
|
+
* If detached, the item will not be filtered out or change the dropdown's
|
|
27
|
+
* selected item. Useful for actionable items, such as Add New item, etc.
|
|
28
|
+
*/
|
|
29
|
+
this.detached = false;
|
|
25
30
|
//#endregion EVENTS
|
|
26
31
|
/****************************************************************************/
|
|
27
32
|
//#region METHODS
|
|
@@ -31,18 +36,16 @@ const NvFielddropdownitem = class {
|
|
|
31
36
|
this.dropdownItemSelected.emit({
|
|
32
37
|
label: this.label,
|
|
33
38
|
value: this.value,
|
|
39
|
+
detached: this.detached,
|
|
34
40
|
});
|
|
35
41
|
};
|
|
36
42
|
}
|
|
37
43
|
handleKeyDown(event) {
|
|
38
|
-
var _a, _b;
|
|
39
44
|
if (event.target !== this.el)
|
|
40
45
|
return;
|
|
41
46
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
42
47
|
event.preventDefault();
|
|
43
48
|
this.handleSelected();
|
|
44
|
-
(_b = (_a = this.el
|
|
45
|
-
.closest('nv-fielddropdown')) === null || _a === void 0 ? void 0 : _a.querySelector("[data-scope='focusable']")) === null || _b === void 0 ? void 0 : _b.focus();
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
//#endregion METHODS
|
|
@@ -60,7 +63,7 @@ const NvFielddropdownitem = class {
|
|
|
60
63
|
/****************************************************************************/
|
|
61
64
|
//#region RENDER
|
|
62
65
|
render() {
|
|
63
|
-
return (index.h(index.Host, { key: '
|
|
66
|
+
return (index.h(index.Host, { key: 'e099d616e8cf3aac2ec1fad7f3c0aee8a0456dbf', role: "menuitem", tabindex: '-1', onClick: this.handleSelected }, index.h("slot", { key: '17a6b60db0685997663de23436f673f29627b661' }), !this.composed && (index.h("div", { key: '92ce5251e1b99c281ca9c26d6927b08056a9957f', class: "text-wrapper" }, index.h("span", { key: '7821e235f3e342d71f0d6d6e7d6176d3100c9305', "data-scope": "text" }, this.label))), this.selected && (index.h("nv-icon", { key: '3da4ac75ebd8a662b054c5ad06c4939969fcd5f8', name: "check", "aria-hidden": "true", "data-scope": "selected" }))));
|
|
64
67
|
}
|
|
65
68
|
get el() { return index.getElement(this); }
|
|
66
69
|
};
|
package/dist/cjs/{nv-fieldmultiselect.entry-BFt11EM5.js → nv-fieldmultiselect.entry-BaUD7Dcr.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-BObVnP12.js');
|
|
4
4
|
var v4A79185f4 = require('./v4-a79185f4-2n0dOd_Y.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('react-dom');
|
|
@@ -621,6 +621,10 @@ const NvFieldmultiselect = class {
|
|
|
621
621
|
* @param {KeyboardEvent} event - The keyboard event.
|
|
622
622
|
*/
|
|
623
623
|
async handleKeyDown(event) {
|
|
624
|
+
if (event.key === 'Escape') {
|
|
625
|
+
this.open = false;
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
624
628
|
if (!this.open) {
|
|
625
629
|
if (event.key === 'ArrowDown') {
|
|
626
630
|
this.open = true;
|