@nova-design-system/nova-react 3.0.0-beta.43 → 3.0.0-beta.45
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/cjs/{index-CinzsZ8D.js → index-S09Gr7Tw.js} +180 -218
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{nv-alert.entry-BVY_rxey.js → nv-alert.entry-DH8Qd2s2.js} +1 -1
- package/dist/cjs/{nv-avatar.entry-pREKtiv2.js → nv-avatar.entry-B3-elLZC.js} +1 -1
- package/dist/cjs/{nv-badge_2.entry-wDuiCwys.js → nv-badge_2.entry-D15EDzX0.js} +2 -2
- package/dist/cjs/{nv-base.entry-DwtTXK_n.js → nv-base.entry-D-_RUZTX.js} +1 -1
- package/dist/cjs/{nv-breadcrumb.entry-B0hIeE83.js → nv-breadcrumb.entry-DG49Nj1L.js} +2 -2
- package/dist/cjs/{nv-breadcrumbs.entry-Cq0LsIFs.js → nv-breadcrumbs.entry-BqJO5pbN.js} +1 -1
- package/dist/cjs/{nv-button.entry-DaSGnB1L.js → nv-button.entry-CN9kB98T.js} +6 -4
- package/dist/cjs/{nv-calendar.entry-BC6NDsVl.js → nv-calendar.entry-CMEgSU64.js} +6 -6
- package/dist/cjs/{nv-col.entry-DNUY559i.js → nv-col.entry-wcZ9HHAb.js} +1 -1
- package/dist/cjs/{nv-datagrid.entry-Cp8RCSEv.js → nv-datagrid.entry-GCLeN2qT.js} +32 -5
- package/dist/cjs/{nv-datagridcolumn.entry-CR9_1fsZ.js → nv-datagridcolumn.entry-lgIz71UU.js} +1 -1
- package/dist/cjs/{nv-dialog.entry-BjTJ5FFL.js → nv-dialog.entry-DfY0TaYp.js} +17 -13
- package/dist/cjs/{nv-dialogfooter_2.entry-DJkKzEgO.js → nv-dialogfooter_2.entry-OByWsulH.js} +6 -6
- package/dist/cjs/{nv-fieldcheckbox.entry-C0DmeqXD.js → nv-fieldcheckbox.entry-Bqpe9BK3.js} +2 -2
- package/dist/cjs/{nv-fielddate.entry-DRX2mfZL.js → nv-fielddate.entry-DJePv6tR.js} +1 -1
- package/dist/cjs/{nv-fielddaterange.entry-ka3JiDvT.js → nv-fielddaterange.entry--YC750sX.js} +1 -1
- package/dist/cjs/{nv-fielddropdown.entry-DUAKFYgw.js → nv-fielddropdown.entry-BPlTlc_S.js} +45 -75
- package/dist/cjs/{nv-fielddropdownitem.entry-BsbvJERH.js → nv-fielddropdownitem.entry-zwoGySum.js} +7 -9
- package/dist/cjs/{nv-fieldmultiselect.entry-DFr-ZICs.js → nv-fieldmultiselect.entry-Bg_v0LUF.js} +7 -49
- package/dist/cjs/{nv-fieldnumber.entry-ezdDvJh_.js → nv-fieldnumber.entry-BLNaq7yr.js} +1 -1
- package/dist/cjs/{nv-fieldpassword.entry-D4a8SnGr.js → nv-fieldpassword.entry-iSEdS5R8.js} +1 -1
- package/dist/cjs/{nv-fieldradio.entry-Co7WX2vI.js → nv-fieldradio.entry-Dov4vZkh.js} +1 -1
- package/dist/cjs/{nv-fieldselect.entry-sTbv_flF.js → nv-fieldselect.entry-NmpesarX.js} +1 -1
- package/dist/cjs/{nv-fieldtext.entry-DRPCH6Sf.js → nv-fieldtext.entry-r6oQajRS.js} +1 -1
- package/dist/cjs/{nv-fieldtextarea.entry-BwJCUiVW.js → nv-fieldtextarea.entry-CJ2yQkfi.js} +1 -1
- package/dist/cjs/{nv-fieldtime.entry-uU-IET2k.js → nv-fieldtime.entry-Bxoj6N53.js} +1 -1
- package/dist/cjs/nv-icon.entry-CWKRt8F0.js +79 -0
- package/dist/cjs/{nv-iconbutton_2.entry-Dx4usGkY.js → nv-iconbutton_2.entry-CnbscpNn.js} +1 -1
- package/dist/cjs/{nv-menu.entry-D3qvf_0H.js → nv-menu.entry-wC7oSruP.js} +1 -1
- package/dist/cjs/{nv-menuitem.entry-3t6TixM7.js → nv-menuitem.entry-BVSa1vrS.js} +1 -1
- package/dist/cjs/{nv-popover.entry-Bv6kuTK_.js → nv-popover.entry-ChP1we3l.js} +12 -10
- package/dist/cjs/{nv-row.entry-BPK1Li7w.js → nv-row.entry-D6FeFpzG.js} +1 -1
- package/dist/cjs/{nv-stack.entry-ByaO-0TJ.js → nv-stack.entry-zjJmztkO.js} +1 -1
- package/dist/cjs/{nv-table.entry-C7Hd57Iq.js → nv-table.entry-CGX0jsR3.js} +2 -2
- package/dist/cjs/{nv-tablecolumn.entry-BDCw_45v.js → nv-tablecolumn.entry-Cwdmo_RY.js} +1 -1
- package/dist/cjs/{nv-toggle.entry-BTqGH_H0.js → nv-toggle.entry-BvToMkI2.js} +2 -2
- package/dist/cjs/{nv-tooltip.entry-BDZfrLHv.js → nv-tooltip.entry-DZ7_lB-p.js} +2 -2
- package/dist/generated/components.js +3 -3
- package/dist/types/generated/components.d.ts +3 -5
- package/package.json +1 -1
- package/dist/cjs/index-C8UfzrMI.js +0 -26405
- package/dist/cjs/nv-alert.entry-8esWDUyU.js +0 -173
- package/dist/cjs/nv-avatar.entry-CO6bt4k6.js +0 -67
- package/dist/cjs/nv-badge_2.entry-xfXsesV0.js +0 -195
- package/dist/cjs/nv-base.entry-BO-6krwg.js +0 -71
- package/dist/cjs/nv-breadcrumb.entry-DTwjCmMI.js +0 -45
- package/dist/cjs/nv-breadcrumbs.entry-jn5hRjpQ.js +0 -20
- package/dist/cjs/nv-button.entry-DxzA6-My.js +0 -162
- package/dist/cjs/nv-calendar.entry-DKz-iBnp.js +0 -1036
- package/dist/cjs/nv-col.entry-X7jkNThH.js +0 -37
- package/dist/cjs/nv-datagrid.entry-DL-Fyo4l.js +0 -3671
- package/dist/cjs/nv-datagridcolumn.entry-CyTG5E7M.js +0 -18
- package/dist/cjs/nv-dialog.entry-Do_uALC6.js +0 -784
- package/dist/cjs/nv-dialogfooter_2.entry-DJ8qS9q6.js +0 -134
- package/dist/cjs/nv-fieldcheckbox.entry-DoGQX-5D.js +0 -137
- package/dist/cjs/nv-fielddate.entry-D-PjbYaA.js +0 -278
- package/dist/cjs/nv-fielddaterange.entry-BrC5jKLp.js +0 -355
- package/dist/cjs/nv-fielddropdown.entry-MsUR1kVe.js +0 -391
- package/dist/cjs/nv-fielddropdownitem.entry-DRM-Zljt.js +0 -70
- package/dist/cjs/nv-fieldmultiselect.entry-Dr8FfT_W.js +0 -1060
- package/dist/cjs/nv-fieldnumber.entry-DZsM1vmO.js +0 -126
- package/dist/cjs/nv-fieldpassword.entry-Biw__M2W.js +0 -115
- package/dist/cjs/nv-fieldradio.entry-ZL7KgEZ7.js +0 -102
- package/dist/cjs/nv-fieldselect.entry-D6eRsM9T.js +0 -365
- package/dist/cjs/nv-fieldtext.entry-DKdxC2cG.js +0 -119
- package/dist/cjs/nv-fieldtextarea.entry-Dc_TGlmI.js +0 -194
- package/dist/cjs/nv-fieldtime.entry-CXRtpWt1.js +0 -1011
- package/dist/cjs/nv-icon.entry-iipuvT3D.js +0 -79
- package/dist/cjs/nv-icon.entry-xltjoSa2.js +0 -79
- package/dist/cjs/nv-iconbutton_2.entry-BsXvYbCi.js +0 -163
- package/dist/cjs/nv-menu.entry-DFEYw_KZ.js +0 -227
- package/dist/cjs/nv-menuitem.entry-BeTXOtir.js +0 -58
- package/dist/cjs/nv-popover.entry-Zt25YeAv.js +0 -1960
- package/dist/cjs/nv-row.entry-Bwzlub3i.js +0 -21
- package/dist/cjs/nv-stack.entry-bhess4lQ.js +0 -30
- package/dist/cjs/nv-table.entry-D3U4dFcw.js +0 -338
- package/dist/cjs/nv-tablecolumn.entry-BzwWPlLf.js +0 -18
- package/dist/cjs/nv-toggle.entry-DXpNGkbz.js +0 -79
- package/dist/cjs/nv-tooltip.entry-CvCZZV88.js +0 -44
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-CinzsZ8D.js');
|
|
4
|
-
var v4A79185f4 = require('./v4-a79185f4-2n0dOd_Y.js');
|
|
5
|
-
require('react');
|
|
6
|
-
|
|
7
|
-
const nvFielddropdownCss = "nv-fielddropdown{--nv-field-border-default:var(--components-form-field-border-default);--nv-field-border-hover:var(--components-form-field-border-hover);--nv-field-border-focus:var(--components-form-field-border-focus);--nv-field-border-disabled:var(--components-form-field-border-default);--nv-field-border-readonly:var(--components-form-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-brand);--nv-field-background:var(--components-form-field-background-default);display:flex;flex-direction:column;align-items:flex-start;gap:var(--form-gap-y);box-sizing:border-box}nv-fielddropdown[readonly]:not([readonly=false]){--nv-field-border-default:var(--components-form-field-border-readonly);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--components-form-field-border-focus);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-background:var(--components-form-field-background-readonly)}nv-fielddropdown[error]:not([error=false]){--nv-field-border-default:var(--components-form-field-border-error);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--nv-field-border-default);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-destructive)}nv-fielddropdown[required]:not([required=false]) label::after{content:\"*\";color:var(--components-form-text-required);font-weight:700}nv-fielddropdown label{display:flex;align-items:center;gap:var(--form-label-gap);align-self:stretch;color:var(--components-form-text-label-default);font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-label-font-size);font-style:normal;font-weight:500;line-height:var(--form-label-line-height)}nv-fielddropdown nv-popover{width:100%;display:block}nv-fielddropdown nv-popover [data-scope=popover]{width:100%;padding:var(--list-dropdown-padding);border-radius:var(--list-dropdown-radius);background-color:var(--components-list-dropdown-background);border:1px solid var(--components-list-dropdown-border)}nv-fielddropdown nv-popover [slot=content]{gap:var(--list-dropdown-gap-y);display:flex;flex-direction:column}nv-fielddropdown nv-popover hr{color:var(--components-list-dropdown-separator)}nv-fielddropdown .input-wrapper{display:flex;flex-wrap:wrap;gap:var(--form-gap-x);align-items:stretch;align-self:stretch;width:100%}nv-fielddropdown .input-container{display:flex;flex-grow:1;justify-content:center;align-items:center;align-self:stretch;border-radius:var(--form-field-radius);border-width:1px;border-style:solid;border-color:var(--nv-field-border-default);opacity:var(--components-form-opacity-default, 1);background:var(--nv-field-background);transition:all 150ms ease-out;position:relative;width:100%;min-height:40px}nv-fielddropdown .input-container:hover{border-color:var(--nv-field-border-hover)}nv-fielddropdown .input-container:focus-within,nv-fielddropdown .input-container:focus-within:hover,nv-fielddropdown .input-container:focus,nv-fielddropdown .input-container:focus:hover{border-color:var(--nv-field-border-focus);box-shadow:0px 0px 0px var(--focus-field-stroke) var(--nv-field-focus-box-shadow)}nv-fielddropdown .input-container:has(input:read-only){opacity:0.5;background-color:var(--components-form-field-background-readonly);border-color:var(--nv-field-border-readonly)}nv-fielddropdown .input-container:has(input:disabled){opacity:0.5;background-color:var(--components-form-field-background-disabled);border-color:var(--nv-field-border-disabled)}nv-fielddropdown .input-container input[type=search]::-webkit-search-decoration,nv-fielddropdown .input-container input[type=search]::-webkit-search-cancel-button,nv-fielddropdown .input-container input[type=search]::-webkit-search-results-button,nv-fielddropdown .input-container input[type=search]::-webkit-search-results-decoration{-webkit-appearance:none}nv-fielddropdown .input-container input,nv-fielddropdown .input-container p.non-filterable-text{display:flex;align-items:center;flex:1 0 0;overflow:hidden;background-color:transparent;color:var(--components-form-field-content-text);padding:var(--form-field-padding-y) var(--form-field-padding-x);font-size:var(--form-field-font-size);font-style:normal;font-weight:500;line-height:var(--form-field-line-height)}nv-fielddropdown .input-container input:focus,nv-fielddropdown .input-container p.non-filterable-text:focus{outline:none}nv-fielddropdown .input-container input::placeholder,nv-fielddropdown .input-container p.non-filterable-text::placeholder{overflow:hidden;color:var(--components-form-field-content-placeholder);text-overflow:ellipsis;font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-field-font-size);font-style:normal;font-weight:400;line-height:var(--form-field-line-height)}nv-fielddropdown .input-container>nv-iconbutton{border:0px;border-radius:0px}nv-fielddropdown .input-container>nv-iconbutton:focus-visible{border-radius:var(--button-md-border-radius);outline-offset:-3px}nv-fielddropdown .input-container nv-icon.validation{color:var(--nv-field-border-default)}nv-fielddropdown .non-filterable-text{display:block;border-radius:var(--form-field-radius);background-color:var(--nv-field-background);color:var(--components-form-field-content-text);font-size:var(--form-field-font-size);font-weight:500;line-height:var(--form-field-line-height);box-sizing:border-box;cursor:pointer;height:100%;min-height:40px}nv-fielddropdown .non-filterable-text span{display:inline-block;width:100%;overflow:hidden;text-overflow:ellipsis}nv-fielddropdown .description{align-self:stretch;color:var(--components-form-text-description-default);font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-description-font-size);font-style:normal;line-height:var(--form-description-line-height)}nv-fielddropdown .error-description{align-self:stretch;color:var(--components-form-text-description-default);font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-description-font-size);font-style:normal;line-height:var(--form-description-line-height);color:var(--components-form-text-description-error)}";
|
|
8
|
-
const NvFielddropdownStyle0 = nvFielddropdownCss;
|
|
9
|
-
|
|
10
|
-
const NvFielddropdown = class {
|
|
11
|
-
constructor(hostRef) {
|
|
12
|
-
index.registerInstance(this, hostRef);
|
|
13
|
-
this.valueChanged = index.createEvent(this, "valueChanged");
|
|
14
|
-
this.dropdownItemSelected = index.createEvent(this, "dropdownItemSelected");
|
|
15
|
-
/****************************************************************************/
|
|
16
|
-
//#region PROPERTIES
|
|
17
|
-
/**
|
|
18
|
-
* Sets the ID for the input element and the for attribute of the associated
|
|
19
|
-
* label. If no ID is provided, a random one will be automatically generated
|
|
20
|
-
* to ensure unique identification, facilitating proper label association and
|
|
21
|
-
* accessibility.
|
|
22
|
-
*/
|
|
23
|
-
this.inputId = v4A79185f4.v4();
|
|
24
|
-
/**
|
|
25
|
-
* State of the dropdown popover.
|
|
26
|
-
*/
|
|
27
|
-
this.open = false;
|
|
28
|
-
/**
|
|
29
|
-
* The autocomplete prop helps users fill out the input field faster by
|
|
30
|
-
* suggesting entries they've used before, like their email or address.
|
|
31
|
-
* You can turn it on to make forms more convenient or off to ensure users
|
|
32
|
-
* always type in fresh data.
|
|
33
|
-
*/
|
|
34
|
-
this.autocomplete = 'off';
|
|
35
|
-
/**
|
|
36
|
-
* Marks the input field as required, ensuring that the user must fill it out
|
|
37
|
-
* before submitting the form.
|
|
38
|
-
*/
|
|
39
|
-
this.required = false;
|
|
40
|
-
/**
|
|
41
|
-
* Alters the input field's appearance to indicate an error, helping users
|
|
42
|
-
* identify fields that need correction.
|
|
43
|
-
* @validator error
|
|
44
|
-
*/
|
|
45
|
-
this.error = false;
|
|
46
|
-
/**
|
|
47
|
-
* Display the input field's content without allowing users to change it.
|
|
48
|
-
* Users can still click on it, select, and copy the text, but they won't be
|
|
49
|
-
* able to type or delete anything.
|
|
50
|
-
*/
|
|
51
|
-
this.readonly = false;
|
|
52
|
-
/**
|
|
53
|
-
* The disabled prop lets you turn off the input field so that users can't
|
|
54
|
-
* type in it. When disabled, the field is grayed out and won't respond to
|
|
55
|
-
* clicks or touches.
|
|
56
|
-
*/
|
|
57
|
-
this.disabled = false;
|
|
58
|
-
/**
|
|
59
|
-
* The text to display when no items match the filter.
|
|
60
|
-
*/
|
|
61
|
-
this.emptyResult = 'No results found';
|
|
62
|
-
/**
|
|
63
|
-
* Enables or disables the filtering feature for the dropdown items.
|
|
64
|
-
*/
|
|
65
|
-
this.filterable = false;
|
|
66
|
-
/**
|
|
67
|
-
* Applies focus to the input field as soon as the component is mounted. This
|
|
68
|
-
* is equivalent to setting the native autofocus attribute on an <input>
|
|
69
|
-
* element.
|
|
70
|
-
*/
|
|
71
|
-
this.autofocus = false;
|
|
72
|
-
//#endregion PROPERTIES
|
|
73
|
-
/****************************************************************************/
|
|
74
|
-
//#region STATE
|
|
75
|
-
/** The text entered by the user for filtering dropdown items. */
|
|
76
|
-
this.filterText = '';
|
|
77
|
-
this.isFilterable = this.filterable;
|
|
78
|
-
this.selectedValues = new Set();
|
|
79
|
-
/**
|
|
80
|
-
* Options configuration for the dropdown items.
|
|
81
|
-
*/
|
|
82
|
-
this.parsedOptions = [];
|
|
83
|
-
this.handleInputContainerClick = (event) => {
|
|
84
|
-
if (this.disabled || this.readonly) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const target = event.target;
|
|
88
|
-
if (target.tagName === 'P' || target.tagName === 'SPAN') {
|
|
89
|
-
this.open = true;
|
|
90
|
-
// Simulate focus to trigger "focus-within" style
|
|
91
|
-
const inputContainer = this.el.querySelector('.input-container');
|
|
92
|
-
if (inputContainer) {
|
|
93
|
-
inputContainer.classList.add('focus-within');
|
|
94
|
-
// Remove the "focus-within" class after a delay or when the popover is closed
|
|
95
|
-
const removeFocusWithin = () => {
|
|
96
|
-
inputContainer.classList.remove('focus-within');
|
|
97
|
-
};
|
|
98
|
-
// Or remove the class when the popover is closed
|
|
99
|
-
this.popoverElement.addEventListener('hide', removeFocusWithin);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
this.handleInput = (event) => {
|
|
104
|
-
if (!this.filterable)
|
|
105
|
-
return;
|
|
106
|
-
if (this.disabled || this.readonly) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const input = event.target;
|
|
110
|
-
this.filterText = input.value.toLowerCase();
|
|
111
|
-
this.filterItems();
|
|
112
|
-
};
|
|
113
|
-
this.handleInputFocus = () => {
|
|
114
|
-
if (this.disabled || this.readonly)
|
|
115
|
-
return;
|
|
116
|
-
this.open = true;
|
|
117
|
-
};
|
|
118
|
-
this.togglePopover = () => {
|
|
119
|
-
if (this.disabled || this.readonly)
|
|
120
|
-
return;
|
|
121
|
-
this.open = !this.open;
|
|
122
|
-
if (this.open && !this.filterable) {
|
|
123
|
-
this.focusFirstItem();
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
this.getSelectedLabel = () => {
|
|
127
|
-
var _a, _b, _c;
|
|
128
|
-
const items = Array.from(this.el.querySelectorAll('nv-fielddropdownitem'));
|
|
129
|
-
const matchingItem = items.find(item => item.getAttribute('value') === this.value);
|
|
130
|
-
return matchingItem
|
|
131
|
-
? (_c = (_a = matchingItem.label) !== null && _a !== void 0 ? _a : (_b = matchingItem.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : matchingItem.value
|
|
132
|
-
: '';
|
|
133
|
-
};
|
|
134
|
-
this.clearFilter = () => {
|
|
135
|
-
this.filterText = '';
|
|
136
|
-
this.inputElement.value = '';
|
|
137
|
-
this.inputElement.focus();
|
|
138
|
-
this.filterItems();
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
handleDropdownItemSelected(event) {
|
|
142
|
-
if (this.disabled || this.readonly)
|
|
143
|
-
return;
|
|
144
|
-
const items = Array.from(this.el.querySelectorAll('nv-fielddropdownitem'));
|
|
145
|
-
items.forEach(item => {
|
|
146
|
-
if (item !== event.target) {
|
|
147
|
-
item.removeAttribute('selected');
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
item.setAttribute('selected', 'true');
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
this.value = event.detail.value;
|
|
154
|
-
this.open = false;
|
|
155
|
-
}
|
|
156
|
-
handleOpenChanged(event) {
|
|
157
|
-
this.open = event.detail; // Update `open` based on the popover state
|
|
158
|
-
}
|
|
159
|
-
watchFilterableHandler(newValue) {
|
|
160
|
-
this.isFilterable = newValue;
|
|
161
|
-
this.filterable = newValue;
|
|
162
|
-
}
|
|
163
|
-
watchValueHandler(newValue) {
|
|
164
|
-
if (newValue) {
|
|
165
|
-
this.updateSelectedItem(newValue);
|
|
166
|
-
}
|
|
167
|
-
this.valueChanged.emit(newValue);
|
|
168
|
-
}
|
|
169
|
-
handleOptionsChange(newValue) {
|
|
170
|
-
if (newValue) {
|
|
171
|
-
try {
|
|
172
|
-
const parsedOpts = JSON.parse(newValue);
|
|
173
|
-
this.parsedOptions = [...parsedOpts];
|
|
174
|
-
const selectedOption = this.parsedOptions.find(opt => opt.selected);
|
|
175
|
-
if (selectedOption) {
|
|
176
|
-
this.value = selectedOption.value;
|
|
177
|
-
requestAnimationFrame(() => {
|
|
178
|
-
// Wait for items to be rendered
|
|
179
|
-
this.updateSelectedItem(selectedOption.value);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
console.error('nv-fielddropdown: error parsing options:', error);
|
|
185
|
-
this.parsedOptions = [];
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
this.parsedOptions = [];
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
handleBlur(event) {
|
|
193
|
-
const target = event.relatedTarget;
|
|
194
|
-
if (!(target instanceof Node) || !this.el.contains(target)) {
|
|
195
|
-
this.open = false;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
handleKeyDown(event) {
|
|
199
|
-
if (!this.open) {
|
|
200
|
-
if (event.key === 'ArrowDown') {
|
|
201
|
-
this.open = true;
|
|
202
|
-
if (!this.filterable) {
|
|
203
|
-
// Focus on the first item if it is not filterable
|
|
204
|
-
this.focusFirstItem();
|
|
205
|
-
}
|
|
206
|
-
event.preventDefault();
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const items = Array.from(this.el.querySelectorAll('nv-fielddropdownitem:not([data-empty])'));
|
|
212
|
-
if (items.length === 0) {
|
|
213
|
-
console.warn('No dropdown items found to navigate');
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
let currentIndex = items.findIndex(item => item.classList.contains('highlighted'));
|
|
217
|
-
if (event.key === 'ArrowDown') {
|
|
218
|
-
event.preventDefault();
|
|
219
|
-
currentIndex = (currentIndex + 1) % items.length;
|
|
220
|
-
this.updateHighlightedItem(items, currentIndex);
|
|
221
|
-
}
|
|
222
|
-
else if (event.key === 'ArrowUp') {
|
|
223
|
-
event.preventDefault();
|
|
224
|
-
currentIndex = (currentIndex - 1 + items.length) % items.length;
|
|
225
|
-
this.updateHighlightedItem(items, currentIndex);
|
|
226
|
-
}
|
|
227
|
-
else if (event.key === 'Escape') {
|
|
228
|
-
event.preventDefault();
|
|
229
|
-
this.open = false;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
//#endregion EVENTS
|
|
233
|
-
/****************************************************************************/
|
|
234
|
-
//#region METHODS
|
|
235
|
-
/**
|
|
236
|
-
* Retrieves the current filter text entered by the user.
|
|
237
|
-
* @returns {string} The filter text.
|
|
238
|
-
*/
|
|
239
|
-
async getFilterText() {
|
|
240
|
-
return this.filterText;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Set the initial selection based on the current value and update the
|
|
244
|
-
* inputElement value.
|
|
245
|
-
*/
|
|
246
|
-
setInitialSelection() {
|
|
247
|
-
if (!this.value)
|
|
248
|
-
return;
|
|
249
|
-
const items = Array.from(this.el.querySelectorAll('nv-fielddropdownitem'));
|
|
250
|
-
const selectedItem = items.find(item => item.getAttribute('value') === this.value);
|
|
251
|
-
items.forEach(item => {
|
|
252
|
-
item.removeAttribute('selected');
|
|
253
|
-
item.classList.remove('selected');
|
|
254
|
-
});
|
|
255
|
-
if (selectedItem) {
|
|
256
|
-
selectedItem.setAttribute('selected', 'true');
|
|
257
|
-
selectedItem.classList.add('selected');
|
|
258
|
-
this.value = selectedItem.getAttribute('value');
|
|
259
|
-
if (this.inputElement) {
|
|
260
|
-
this.inputElement.value = this.value;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
console.warn('No matching item found for value:', this.value);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Filter dropdown items based on the text entered by the user.
|
|
269
|
-
* If no items are found, display a message indicating no results.
|
|
270
|
-
*/
|
|
271
|
-
filterItems() {
|
|
272
|
-
var _a;
|
|
273
|
-
const items = Array.from(this.el.querySelectorAll('nv-fielddropdownitem'));
|
|
274
|
-
// Remove the "no results found" item if it exists
|
|
275
|
-
const existingEmptyItem = this.el.querySelector('nv-fielddropdownitem[data-empty]');
|
|
276
|
-
if (existingEmptyItem) {
|
|
277
|
-
existingEmptyItem.remove();
|
|
278
|
-
}
|
|
279
|
-
let hasVisibleItems = false;
|
|
280
|
-
// Iterate over all items and adjust their visibility
|
|
281
|
-
items.forEach(item => {
|
|
282
|
-
var _a, _b;
|
|
283
|
-
const textContent = ((_a = item.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || ''; // Get the textual content of the slot
|
|
284
|
-
const value = ((_b = item.value) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || ''; // Get the value of the `value` attribute
|
|
285
|
-
// Check if the filtered text is present either in the value or in the textual content
|
|
286
|
-
const shouldShow = value.includes(this.filterText) ||
|
|
287
|
-
textContent.includes(this.filterText);
|
|
288
|
-
item.style.display = shouldShow ? '' : 'none'; // Hide or show the item
|
|
289
|
-
if (shouldShow) {
|
|
290
|
-
hasVisibleItems = true;
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
// If no items are visible, add the "no results found" item
|
|
294
|
-
if (!hasVisibleItems) {
|
|
295
|
-
const emptyItem = document.createElement('nv-fielddropdownitem');
|
|
296
|
-
emptyItem.setAttribute('data-empty', 'true');
|
|
297
|
-
emptyItem.setAttribute('disabled', 'true');
|
|
298
|
-
emptyItem.textContent = this.emptyResult;
|
|
299
|
-
(_a = this.el.querySelector('ul[slot="content"]')) === null || _a === void 0 ? void 0 : _a.appendChild(emptyItem);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/** Reset the filter and make all items visible. */
|
|
303
|
-
resetFilter() {
|
|
304
|
-
const items = Array.from(this.el.querySelectorAll('nv-fielddropdownitem'));
|
|
305
|
-
items.forEach(item => {
|
|
306
|
-
item.style.display = '';
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
updateHighlightedItem(items, index) {
|
|
310
|
-
items.forEach((item, i) => {
|
|
311
|
-
if (i === index) {
|
|
312
|
-
item.classList.add('highlighted');
|
|
313
|
-
item.focus();
|
|
314
|
-
item.scrollIntoView({ block: 'nearest' });
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
item.classList.remove('highlighted');
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
focusFirstItem() {
|
|
322
|
-
const firstItem = this.el.querySelector('nv-fielddropdownitem');
|
|
323
|
-
if (firstItem) {
|
|
324
|
-
firstItem.focus();
|
|
325
|
-
this.updateHighlightedItem(Array.from(this.el.querySelectorAll('nv-fielddropdownitem')), 0);
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
console.warn('nv-fielddropdown: no first item found to focus');
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
updateSelectedItem(value) {
|
|
332
|
-
const items = Array.from(this.el.querySelectorAll('nv-fielddropdownitem'));
|
|
333
|
-
const matchingItem = items.find(item => {
|
|
334
|
-
var _a;
|
|
335
|
-
const itemLabel = item.getAttribute('label');
|
|
336
|
-
const itemValue = item.getAttribute('value');
|
|
337
|
-
const itemText = (_a = item.textContent) === null || _a === void 0 ? void 0 : _a.trim();
|
|
338
|
-
return itemLabel === value || itemValue === value || itemText === value;
|
|
339
|
-
});
|
|
340
|
-
items.forEach(item => {
|
|
341
|
-
if (item === matchingItem) {
|
|
342
|
-
item.setAttribute('selected', '');
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
item.removeAttribute('selected');
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
if (matchingItem && this.inputElement) {
|
|
349
|
-
this.inputElement.value = value;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
//#endregion METHODS
|
|
353
|
-
/****************************************************************************/
|
|
354
|
-
//#region LIFECYCLE
|
|
355
|
-
componentWillLoad() {
|
|
356
|
-
this.resetFilter();
|
|
357
|
-
this.setInitialSelection();
|
|
358
|
-
if (this.filterable && this.filterText) {
|
|
359
|
-
this.filterItems();
|
|
360
|
-
}
|
|
361
|
-
if (this.options) {
|
|
362
|
-
this.handleOptionsChange(this.options);
|
|
363
|
-
}
|
|
364
|
-
if (this.value) {
|
|
365
|
-
this.updateSelectedItem(this.value);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
componentDidLoad() {
|
|
369
|
-
if (this.value) {
|
|
370
|
-
this.updateSelectedItem(this.value);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
//#endregion LIFECYCLE
|
|
374
|
-
/****************************************************************************/
|
|
375
|
-
//#region RENDER
|
|
376
|
-
render() {
|
|
377
|
-
return (index.h(index.Host, { key: '189f41e526d7245f4d5fae078d2bea1528a9a8d1' }, (this.label || this.el.querySelector('[slot="label"]')) && (index.h("label", { key: '91d5c635c4d37f5d6d3fef0e6dd3212009d1be35', htmlFor: this.inputId }, index.h("slot", { key: 'e749e641f077753464eaa21289ebf71c0b6f673b', name: "label" }, this.label))), index.h("nv-popover", { key: 'c3c0456e9937745b4784c7b858b9cfadcf4e7240', ref: el => (this.popoverElement = el), triggerMode: "controlled", placement: "bottom-start", open: this.open }, index.h("div", { key: '1ad04f70880de711e371267859950d272f78902f', class: "input-wrapper", slot: "trigger" }, index.h("slot", { key: '99ff9d306c69aba7e5eb033feae1a05f7dcb01f6', name: "before-input" }), index.h("div", { key: '7afb87ecb3eacaf7510abd5b6b02645ba355f719', class: "input-container", onClick: this.handleInputContainerClick }, index.h("slot", { key: 'fe3749cdf9f25f0b7fd52949c955b1804fd65630', name: "leading-input" }), this.isFilterable || this.disabled || this.readonly ? (index.h("input", { id: this.inputId, type: "search", ref: e => (this.inputElement = e), autofocus: this.autofocus, autocomplete: this.autocomplete, placeholder: this.placeholder, name: this.name, value: this.getSelectedLabel(), required: this.required, disabled: this.disabled, readOnly: this.readonly, onInput: this.handleInput, onFocus: this.handleInputFocus, onKeyDown: this.handleKeyDown })) : (index.h("p", { id: this.inputId, class: "non-filterable-text", onClick: this.handleInputContainerClick, tabIndex: this.disabled ? -1 : 0, onKeyDown: this.handleKeyDown, onFocus: this.handleInputFocus }, index.h("span", null, this.getSelectedLabel() || this.value || this.placeholder))), this.isFilterable && this.filterText && this.open && (index.h("nv-iconbutton", { key: '9806da726e4dce22f0a73664b482a405cb7cc071', name: "x", size: "md", emphasis: "lower", class: "clear-button", onClick: this.clearFilter, "aria-label": "Clear input" })), this.error && (index.h("nv-icon", { key: '781fb90765533615737da8c294ce497f22dbd9c6', name: "alert-circle", class: "validation", size: "md" })), index.h("nv-iconbutton", { key: '1060f3a91606d26c3368299623b0d8211df5f6ec', "data-scope": "toggle-dropdown", name: this.open ? 'chevron-top' : 'chevron-down', size: "md", emphasis: "lower", "aria-label": this.open ? 'Hide dropdown' : 'Show dropdown', "aria-pressed": this.open.toString(), onClick: this.togglePopover, tabIndex: this.disabled ? -1 : 0 })), index.h("slot", { key: 'b123b91bb2c09f77010bef649d11a27bf16cb3ab', name: "after-input" })), index.h("div", { key: '94234acfe1881c11b3e6fadda0f234d036ea47ef', slot: "content" }, this.parsedOptions.length > 0 ? (index.h("ul", null, this.parsedOptions.map(option => (index.h("nv-fielddropdownitem", { label: option.label, value: option.value, disabled: option.disabled, selected: option.value === this.value }))))) : (index.h("slot", { name: "content" })))), (this.description ||
|
|
378
|
-
this.el.querySelector('[slot="description"]')) && (index.h("div", { key: '26de437b142f81e21145ac4f6a15c7e6aecfbfa7', class: "description" }, index.h("slot", { key: '6c95582790d276567ad9e1619a949419a72f54c1', name: "description" }, this.description))), (this.errorDescription ||
|
|
379
|
-
this.el.querySelector('[slot="error-description"]')) && (index.h("div", { key: '6ac20b9462e708a456e61c8e3721a585b03e696e', hidden: !this.error, class: "error-description" }, index.h("slot", { key: '1def9c4e17495a831ea9702ae121c64e812df9b6', name: "error-description" }, this.errorDescription)))));
|
|
380
|
-
}
|
|
381
|
-
static get formAssociated() { return true; }
|
|
382
|
-
get el() { return index.getElement(this); }
|
|
383
|
-
static get watchers() { return {
|
|
384
|
-
"filterable": ["watchFilterableHandler"],
|
|
385
|
-
"value": ["watchValueHandler"],
|
|
386
|
-
"options": ["handleOptionsChange"]
|
|
387
|
-
}; }
|
|
388
|
-
};
|
|
389
|
-
NvFielddropdown.style = NvFielddropdownStyle0;
|
|
390
|
-
|
|
391
|
-
exports.nv_fielddropdown = NvFielddropdown;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-CinzsZ8D.js');
|
|
4
|
-
require('react');
|
|
5
|
-
|
|
6
|
-
const nvFielddropdownitemCss = "nv-fielddropdownitem{display:flex;gap:var(--spacing-2);flex-wrap:wrap;align-items:center;width:100%;padding:var(--list-dropdown-item-padding-y) var(--list-dropdown-item-padding-x);font-weight:var(--menu-contextual-item-font-weight);font-size:var(--list-dropdown-font-size);line-height:var(--list-dropdown-line-height);color:var(--components-list-dropdown-item-label-default);border-radius:var(--list-dropdown-item-radius);transition:background-color 150ms ease-out, color 150ms ease-out;cursor:pointer}nv-fielddropdownitem:hover,nv-fielddropdownitem:focus,nv-fielddropdownitem:focus-within{background-color:var(--components-list-dropdown-item-background-hover);color:var(--components-menu-contextual-item-content-hover)}nv-fielddropdownitem[disabled]:not([disabled=false]){cursor:not-allowed;background-color:unset;color:var(--components-menu-contextual-item-content-disabled)}nv-fielddropdownitem .text-wrapper{display:flex;flex-grow:1;align-items:center;justify-content:space-between}nv-fielddropdownitem [data-scope=text]{flex-grow:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}nv-fielddropdownitem nv-icon[data-scope=selected]{color:var(--components-list-dropdown-item-label-default);align-self:center;margin-left:auto}";
|
|
7
|
-
const NvFielddropdownitemStyle0 = nvFielddropdownitemCss;
|
|
8
|
-
|
|
9
|
-
const NvFielddropdownitem = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
index.registerInstance(this, hostRef);
|
|
12
|
-
this.dropdownItemSelected = index.createEvent(this, "dropdownItemSelected");
|
|
13
|
-
this.composed = false;
|
|
14
|
-
/****************************************************************************/
|
|
15
|
-
//#region PROPERTIES
|
|
16
|
-
/**
|
|
17
|
-
* Disables the item, preventing any user interaction.
|
|
18
|
-
*/
|
|
19
|
-
this.disabled = false;
|
|
20
|
-
/**
|
|
21
|
-
* Indicates if the item is selected.
|
|
22
|
-
*/
|
|
23
|
-
this.selected = false;
|
|
24
|
-
//#endregion EVENTS
|
|
25
|
-
/****************************************************************************/
|
|
26
|
-
//#region METHODS
|
|
27
|
-
this.handleSelected = () => {
|
|
28
|
-
if (this.disabled || this.selected)
|
|
29
|
-
return;
|
|
30
|
-
this.selected = true;
|
|
31
|
-
this.dropdownItemSelected.emit({
|
|
32
|
-
label: this.label,
|
|
33
|
-
value: this.value,
|
|
34
|
-
selected: this.selected,
|
|
35
|
-
disabled: this.disabled,
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
handleKeyDown(event) {
|
|
40
|
-
if (event.target !== this.el)
|
|
41
|
-
return;
|
|
42
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
43
|
-
event.preventDefault();
|
|
44
|
-
this.handleSelected();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//#endregion METHODS
|
|
48
|
-
/****************************************************************************/
|
|
49
|
-
//#region LIFECYCLE
|
|
50
|
-
componentWillLoad() {
|
|
51
|
-
this.composed = Boolean(this.el.children.length);
|
|
52
|
-
}
|
|
53
|
-
componentDidLoad() {
|
|
54
|
-
var _a;
|
|
55
|
-
if (!this.value) {
|
|
56
|
-
const fallback = (_a = this.label) !== null && _a !== void 0 ? _a : this.el.textContent;
|
|
57
|
-
this.value = fallback.replace(/\W+/g, ''); // Remove non-word characters
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
//#endregion LIFECYCLE
|
|
61
|
-
/****************************************************************************/
|
|
62
|
-
//#region RENDER
|
|
63
|
-
render() {
|
|
64
|
-
return (index.h(index.Host, { key: '00b69c6a38cf852643a7e239bf07d7a123c84dc7', role: "menuitem", tabindex: '-1', onClick: this.handleSelected }, index.h("slot", { key: '4bd9cc35162030b57de567de4b824728c6d3c031' }), !this.composed && (index.h("div", { key: '17fde413045c683a09467037a4513649deda8eeb', class: "text-wrapper" }, index.h("span", { key: 'e4ae14322a14725d142ce57da45e50edff416935', "data-scope": "text" }, this.label))), this.selected && (index.h("nv-icon", { key: '95536cced4b7abeca334eee13e38870cd642ebc5', name: "check", "aria-hidden": "true", "data-scope": "selected" }))));
|
|
65
|
-
}
|
|
66
|
-
get el() { return index.getElement(this); }
|
|
67
|
-
};
|
|
68
|
-
NvFielddropdownitem.style = NvFielddropdownitemStyle0;
|
|
69
|
-
|
|
70
|
-
exports.nv_fielddropdownitem = NvFielddropdownitem;
|