@nova-design-system/nova-react 3.2.0 → 3.3.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/dist/cjs/{index-B2jv2KXv.js → index-BlWxX8x6.js} +824 -894
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{nv-alert.entry-pxBJfmIm.js → nv-alert.entry-BLGSitrm.js} +7 -7
- package/dist/cjs/{nv-avatar.entry-CHtVctSK.js → nv-avatar.entry-CRcLMbEx.js} +7 -7
- package/dist/cjs/{nv-badge_2.entry-BO88KO1O.js → nv-badge_2.entry-BtDAr7_d.js} +1 -1
- package/dist/cjs/{nv-breadcrumb.entry-7azRtyl5.js → nv-breadcrumb.entry-PVDZoF9i.js} +1 -1
- package/dist/cjs/{nv-breadcrumbs.entry-DfZVMKpY.js → nv-breadcrumbs.entry-BY169s5F.js} +1 -1
- package/dist/cjs/{nv-button.entry-DW9SblsY.js → nv-button.entry-BpxpxFJP.js} +7 -7
- package/dist/cjs/{nv-calendar.entry-BeayRRor.js → nv-calendar.entry-BobyjFdK.js} +376 -143
- package/dist/cjs/{nv-col.entry-C6oEkSbI.js → nv-col.entry-B4BJXJw-.js} +1 -1
- package/dist/cjs/{nv-datagrid.entry-xhQP6JJP.js → nv-datagrid.entry-D5UVDiYl.js} +6 -6
- package/dist/cjs/{nv-datagridcolumn.entry-CjYmo4fM.js → nv-datagridcolumn.entry-dmpcmCIT.js} +1 -1
- package/dist/cjs/{nv-dialog.entry-mxETaZbc.js → nv-dialog.entry-BYovzkco.js} +3 -3
- package/dist/cjs/{nv-dialogfooter_2.entry-DnLg2DHy.js → nv-dialogfooter_2.entry-C9dhLKRM.js} +3 -3
- package/dist/cjs/{nv-fieldcheckbox.entry-Be9__i15.js → nv-fieldcheckbox.entry-BvFqY2dM.js} +1 -1
- package/dist/cjs/nv-fielddate.entry-CSpAcEXW.js +303 -0
- package/dist/cjs/nv-fielddaterange.entry-C14o96dd.js +439 -0
- package/dist/cjs/{nv-fielddropdown.entry-BPwviyCp.js → nv-fielddropdown.entry-C3VzNRhh.js} +2 -2
- package/dist/cjs/{nv-fielddropdownitem.entry-BGuUR9KP.js → nv-fielddropdownitem.entry-D4G4Ytus.js} +1 -1
- package/dist/cjs/{nv-fieldmultiselect.entry-Lrxr1gsi.js → nv-fieldmultiselect.entry-Ci43ZvzC.js} +2 -2
- package/dist/cjs/nv-fieldnumber.entry-nvUi-64H.js +130 -0
- package/dist/cjs/nv-fieldpassword.entry-C2uqwDah.js +121 -0
- package/dist/cjs/{nv-fieldradio.entry-CDu8xs0p.js → nv-fieldradio.entry-DL2GdKqO.js} +1 -1
- package/dist/cjs/{nv-fieldselect.entry-NEdv8bQK.js → nv-fieldselect.entry-D4AIRE24.js} +2 -2
- package/dist/cjs/{nv-fieldslider.entry-51gF9XPz.js → nv-fieldslider.entry-BNge4J69.js} +25 -20
- package/dist/cjs/nv-fieldtext.entry-BI-fdkdX.js +123 -0
- package/dist/cjs/{nv-fieldtextarea.entry-D44HbsVQ.js → nv-fieldtextarea.entry-Ct0g9Qtb.js} +2 -2
- package/dist/cjs/{nv-fieldtime.entry-MbaWbVtc.js → nv-fieldtime.entry-CmO96Py1.js} +61 -61
- package/dist/cjs/{nv-icon.entry-BSSHr-ud.js → nv-icon.entry-TepdQ1jA.js} +7 -7
- package/dist/cjs/{nv-iconbutton_2.entry-DMaO-JWz.js → nv-iconbutton_2.entry-B7Xyut9H.js} +1 -1
- package/dist/cjs/{nv-menu.entry-D5_lj9XB.js → nv-menu.entry-DHrRi_37.js} +1 -1
- package/dist/cjs/{nv-menuitem.entry-fhnYI91K.js → nv-menuitem.entry-B_D1pSYa.js} +1 -1
- package/dist/cjs/{nv-popover.entry-CYqBaVbr.js → nv-popover.entry-DyQPEQ4I.js} +1 -1
- package/dist/cjs/{nv-row.entry-BUheLufV.js → nv-row.entry-CDTv7ikK.js} +1 -1
- package/dist/cjs/{nv-stack.entry-DNPce51E.js → nv-stack.entry-A78c6BVf.js} +1 -1
- package/dist/cjs/{nv-table.entry-DXQM8l3t.js → nv-table.entry-DkwcfdJM.js} +1 -1
- package/dist/cjs/{nv-tablecolumn.entry-DROQK_0c.js → nv-tablecolumn.entry-C8VNSpDf.js} +1 -1
- package/dist/cjs/{nv-toggle.entry-fMzTrdte.js → nv-toggle.entry-vxSyUDKZ.js} +1 -1
- package/dist/cjs/{nv-tooltip.entry-yB2Ek1Cz.js → nv-tooltip.entry-BQKXRp4d.js} +1 -1
- package/dist/generated/components.js +7 -3
- package/dist/types/generated/components.d.ts +4 -4
- package/package.json +1 -1
- package/dist/cjs/nv-fielddate.entry-BlNily-X.js +0 -269
- package/dist/cjs/nv-fielddaterange.entry-CycpKoJd.js +0 -408
- package/dist/cjs/nv-fieldnumber.entry-B1VySoWj.js +0 -130
- package/dist/cjs/nv-fieldpassword.entry-D7Qlx7Bh.js +0 -121
- package/dist/cjs/nv-fieldtext.entry-Bug9zMgo.js +0 -123
- /package/dist/cjs/{constants-b97e736d-BzFAKCkR.js → constants-4faa1fae-BzFAKCkR.js} +0 -0
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-B2jv2KXv.js');
|
|
4
|
-
var inputmaskEdcad3c1 = require('./inputmask-edcad3c1-B9Omti4z.js');
|
|
5
|
-
var v4A79185f4 = require('./v4-a79185f4-2n0dOd_Y.js');
|
|
6
|
-
require('react');
|
|
7
|
-
require('./_commonjsHelpers-1789f0cf-BJu3ubxk.js');
|
|
8
|
-
|
|
9
|
-
const nvFielddaterangeCss = "nv-fielddaterange{--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;max-width:480px}nv-fielddaterange[fluid]:not([fluid=false]){max-width:unset}nv-fielddaterange[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-fielddaterange[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-in-field)}nv-fielddaterange[success]:not([success=false]){--nv-field-border-default:var(--components-form-field-border-success);--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-success)}nv-fielddaterange[required]:not([required=false]) label::after{content:\"*\";color:var(--components-form-text-required);font-weight:700}nv-fielddaterange 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-fielddaterange nv-popover{width:100%;display:block}nv-fielddaterange nv-popover [data-scope=popover]{padding:0;background-color:var(--components-list-dropdown-background);border:1px solid var(--components-list-dropdown-border);width:auto}nv-fielddaterange nv-popover [slot=content]{display:block;width:100%}nv-fielddaterange .input-wrapper{display:flex;flex-wrap:wrap;gap:var(--form-gap-x);align-items:stretch;align-self:stretch;display:flex;align-items:center;gap:8px}nv-fielddaterange .input-wrapper .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}nv-fielddaterange .input-wrapper .input-container:hover{border-color:var(--nv-field-border-hover)}nv-fielddaterange .input-wrapper .input-container:focus-within,nv-fielddaterange .input-wrapper .input-container:focus-within:hover,nv-fielddaterange .input-wrapper .input-container:focus,nv-fielddaterange .input-wrapper .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-fielddaterange .input-wrapper .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-fielddaterange .input-wrapper .input-container:has(input:disabled){opacity:0.5;background-color:var(--components-form-field-background-disabled);border-color:var(--nv-field-border-disabled)}nv-fielddaterange .input-wrapper .input-container input{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);width:100%;width:100%}nv-fielddaterange .input-wrapper .input-container input:focus{outline:none}nv-fielddaterange .input-wrapper .input-container input::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-fielddaterange .input-wrapper .input-container>nv-iconbutton{border:0px;border-radius:0px}nv-fielddaterange .input-wrapper .input-container>nv-iconbutton:focus-visible{border-radius:var(--button-md-border-radius);outline-offset:-3px}nv-fielddaterange .input-wrapper .input-container nv-icon.validation{color:var(--nv-field-border-default)}nv-fielddaterange .description{display:flex;align-items:center;align-self:stretch;gap:var(--spacing-1);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-fielddaterange .error-description{display:flex;align-items:center;align-self:stretch;gap:var(--spacing-1);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)}nv-fielddaterange .range-inputs{display:flex;align-items:center;gap:8px}nv-fielddaterange .range-inputs input{flex:1;border:none;outline:none;padding:0;font-size:var(--form-field-font-size);color:var(--components-form-field-content-text);background:transparent;min-width:0;text-align:center}nv-fielddaterange .range-inputs input::placeholder{color:var(--components-form-field-content-placeholder)}nv-fielddaterange .range-inputs input:disabled{cursor:not-allowed;color:var(--components-form-field-content-text);background-color:var(--components-form-field-background-disabled)}";
|
|
10
|
-
const NvFielddaterangeStyle0 = nvFielddaterangeCss;
|
|
11
|
-
|
|
12
|
-
const NvFielddaterange = class {
|
|
13
|
-
constructor(hostRef) {
|
|
14
|
-
index.registerInstance(this, hostRef);
|
|
15
|
-
this.dateRangeChange = index.createEvent(this, "dateRangeChange");
|
|
16
|
-
this.popoverId = v4A79185f4.v4();
|
|
17
|
-
/****************************************************************************/
|
|
18
|
-
//#region PROPERTIES
|
|
19
|
-
/**
|
|
20
|
-
* Sets the ID for the start input element and the for attribute of the associated
|
|
21
|
-
* label. If no ID is provided, a random one will be automatically generated.
|
|
22
|
-
*/
|
|
23
|
-
this.startInputId = v4A79185f4.v4();
|
|
24
|
-
/**
|
|
25
|
-
* Sets the ID for the end input element and the for attribute of the associated
|
|
26
|
-
* label. If no ID is provided, a random one will be automatically generated.
|
|
27
|
-
*/
|
|
28
|
-
this.endInputId = v4A79185f4.v4();
|
|
29
|
-
/**
|
|
30
|
-
* Disables both input fields.
|
|
31
|
-
*/
|
|
32
|
-
this.disabled = false;
|
|
33
|
-
/**
|
|
34
|
-
* Sets both input fields as read-only.
|
|
35
|
-
*/
|
|
36
|
-
this.readonly = false;
|
|
37
|
-
/**
|
|
38
|
-
* Marks both input fields as required.
|
|
39
|
-
*/
|
|
40
|
-
this.required = false;
|
|
41
|
-
/**
|
|
42
|
-
* Indicates an error state.
|
|
43
|
-
*/
|
|
44
|
-
this.error = false;
|
|
45
|
-
/**
|
|
46
|
-
* Indicates a success state.
|
|
47
|
-
*/
|
|
48
|
-
this.success = false;
|
|
49
|
-
/**
|
|
50
|
-
* Autofocus the start input when the component is mounted.
|
|
51
|
-
*/
|
|
52
|
-
this.autofocus = false;
|
|
53
|
-
/**
|
|
54
|
-
* The initial value of the date range (in string format).
|
|
55
|
-
*/
|
|
56
|
-
this.value = '';
|
|
57
|
-
/**
|
|
58
|
-
* The current value of the start date in string format.
|
|
59
|
-
*/
|
|
60
|
-
this.startValue = '';
|
|
61
|
-
/**
|
|
62
|
-
* The current value of the end date in string format.
|
|
63
|
-
*/
|
|
64
|
-
this.endValue = '';
|
|
65
|
-
/**
|
|
66
|
-
* Controls the opening of the popover.
|
|
67
|
-
*/
|
|
68
|
-
this.open = false;
|
|
69
|
-
/**
|
|
70
|
-
* Current calendar state to prevent unwanted navigation
|
|
71
|
-
*/
|
|
72
|
-
this.calendarState = null;
|
|
73
|
-
/**
|
|
74
|
-
* First day of the week 0 = Sunday, 1 = Monday, etc.
|
|
75
|
-
* @default 1
|
|
76
|
-
*/
|
|
77
|
-
this.firstDayOfWeek = 1;
|
|
78
|
-
/**
|
|
79
|
-
* Number of calendars to display
|
|
80
|
-
* @default 2
|
|
81
|
-
*/
|
|
82
|
-
this.numberOfCalendars = 2;
|
|
83
|
-
/**
|
|
84
|
-
* Minimum date for selection ISO string format, ex: 2025-01-01
|
|
85
|
-
*/
|
|
86
|
-
this.min = '';
|
|
87
|
-
/**
|
|
88
|
-
* Maximum date for selection ISO string format, ex: 2025-12-31
|
|
89
|
-
*/
|
|
90
|
-
this.max = '';
|
|
91
|
-
/** Locale for date formatting
|
|
92
|
-
* @default 'en-BE'
|
|
93
|
-
*/
|
|
94
|
-
this.locale = 'en-BE';
|
|
95
|
-
/** Date format ex: YYYY-MM-DD, DD-MM-YYYY, etc.
|
|
96
|
-
* @default 'YYYY-MM-DD'
|
|
97
|
-
*/
|
|
98
|
-
this.dateFormat = 'YYYY-MM-DD';
|
|
99
|
-
/**
|
|
100
|
-
* Footer placement
|
|
101
|
-
* @default 'bottom'
|
|
102
|
-
*/
|
|
103
|
-
this.shortcutsPlacement = 'bottom';
|
|
104
|
-
/**
|
|
105
|
-
* Show action buttons
|
|
106
|
-
* @default false
|
|
107
|
-
*/
|
|
108
|
-
this.showActions = false;
|
|
109
|
-
/**
|
|
110
|
-
* Allows the field to stretch and fill the entire width of its container.
|
|
111
|
-
*/
|
|
112
|
-
this.fluid = false;
|
|
113
|
-
/**
|
|
114
|
-
* Closes the popover when a click is detected outside the component.
|
|
115
|
-
* @param {MouseEvent} event - The mouse event
|
|
116
|
-
*/
|
|
117
|
-
this.handleClickOutside = (event) => {
|
|
118
|
-
if (this.open && this.el && !this.el.contains(event.target)) {
|
|
119
|
-
this.open = false;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Handles the input event on the start input element.
|
|
124
|
-
* @param {Event} event - The input event
|
|
125
|
-
*/
|
|
126
|
-
this.handleStartInput = (event) => {
|
|
127
|
-
if (this.readonly || this.disabled) {
|
|
128
|
-
event.preventDefault();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const input = event.target;
|
|
132
|
-
this.startValue = input.value;
|
|
133
|
-
this.dateRangeChange.emit({ start: input.value, end: this.endValue });
|
|
134
|
-
// Temporarily enable navigation for keyboard input
|
|
135
|
-
if (this.calendarElement) {
|
|
136
|
-
this.calendarElement.removeAttribute('data-prevent-navigation');
|
|
137
|
-
this.updateCalendarValue();
|
|
138
|
-
// Restore navigation prevention after update
|
|
139
|
-
setTimeout(() => {
|
|
140
|
-
if (this.calendarElement) {
|
|
141
|
-
this.calendarElement.setAttribute('data-prevent-navigation', 'true');
|
|
142
|
-
}
|
|
143
|
-
}, 100);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Handles the input event on the end input element.
|
|
148
|
-
* @param {Event} event - The input event
|
|
149
|
-
*/
|
|
150
|
-
this.handleEndInput = (event) => {
|
|
151
|
-
if (this.readonly || this.disabled) {
|
|
152
|
-
event.preventDefault();
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const input = event.target;
|
|
156
|
-
this.endValue = input.value;
|
|
157
|
-
this.dateRangeChange.emit({ start: this.startValue, end: input.value });
|
|
158
|
-
// Temporarily enable navigation for keyboard input
|
|
159
|
-
if (this.calendarElement) {
|
|
160
|
-
this.calendarElement.removeAttribute('data-prevent-navigation');
|
|
161
|
-
this.updateCalendarValue();
|
|
162
|
-
// Restore navigation prevention after update
|
|
163
|
-
setTimeout(() => {
|
|
164
|
-
if (this.calendarElement) {
|
|
165
|
-
this.calendarElement.setAttribute('data-prevent-navigation', 'true');
|
|
166
|
-
}
|
|
167
|
-
}, 100);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Handles focus events on the input elements.
|
|
172
|
-
* @param {FocusEvent} event - The focus event
|
|
173
|
-
*/
|
|
174
|
-
this.handleFocus = (event) => {
|
|
175
|
-
if (this.readonly || this.disabled) {
|
|
176
|
-
event.preventDefault();
|
|
177
|
-
event.target.blur();
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
// Enable navigation on focus
|
|
181
|
-
if (this.calendarElement) {
|
|
182
|
-
this.calendarElement.removeAttribute('data-prevent-navigation');
|
|
183
|
-
}
|
|
184
|
-
this.open = true;
|
|
185
|
-
// Restore navigation prevention after opening
|
|
186
|
-
setTimeout(() => {
|
|
187
|
-
if (this.calendarElement) {
|
|
188
|
-
this.calendarElement.setAttribute('data-prevent-navigation', 'true');
|
|
189
|
-
}
|
|
190
|
-
}, 300);
|
|
191
|
-
};
|
|
192
|
-
/**
|
|
193
|
-
* Toggles the opening/closing of the popover.
|
|
194
|
-
*/
|
|
195
|
-
this.toggleCalendar = () => {
|
|
196
|
-
if (this.readonly || this.disabled) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
this.open = !this.open;
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
//#endregion PROPERTIES
|
|
203
|
-
/****************************************************************************/
|
|
204
|
-
//#region METHODS
|
|
205
|
-
/**
|
|
206
|
-
* Converts the nv-calendar date format to the format expected by Inputmask.
|
|
207
|
-
* @param {string} format - The date format to convert
|
|
208
|
-
* @returns {string} The converted format for Inputmask
|
|
209
|
-
*/
|
|
210
|
-
convertToInputmaskFormat(format) {
|
|
211
|
-
// If the format is not specified, use the default format YYYY-MM-DD
|
|
212
|
-
if (!format) {
|
|
213
|
-
return 'dd/mm/yyyy';
|
|
214
|
-
}
|
|
215
|
-
const formatMap = {
|
|
216
|
-
'YYYY-MM-DD': 'yyyy-mm-dd',
|
|
217
|
-
'DD/MM/YYYY': 'dd/mm/yyyy',
|
|
218
|
-
'MM/DD/YYYY': 'mm/dd/yyyy',
|
|
219
|
-
'DD.MM.YYYY': 'dd.mm.yyyy',
|
|
220
|
-
'YYYYMMDD': 'yyyymmdd',
|
|
221
|
-
};
|
|
222
|
-
return formatMap[format] || 'dd/mm/yyyy';
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Update the calendar's rangeValue property without forcing month change
|
|
226
|
-
*/
|
|
227
|
-
updateCalendarValue() {
|
|
228
|
-
if (this.calendarElement && this.startValue && this.endValue) {
|
|
229
|
-
// Store the current calendar state
|
|
230
|
-
this.calendarState = {
|
|
231
|
-
start: this.startValue,
|
|
232
|
-
end: this.endValue,
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
//#endregion METHODS
|
|
237
|
-
/****************************************************************************/
|
|
238
|
-
//#region LIFECYCLE
|
|
239
|
-
connectedCallback() {
|
|
240
|
-
document.addEventListener('click', this.handleClickOutside);
|
|
241
|
-
}
|
|
242
|
-
componentWillLoad() {
|
|
243
|
-
if (this.value) {
|
|
244
|
-
try {
|
|
245
|
-
const range = JSON.parse(this.value);
|
|
246
|
-
this.startValue = range.start || '';
|
|
247
|
-
this.endValue = range.end || '';
|
|
248
|
-
if (range.start && range.end) {
|
|
249
|
-
this.calendarState = {
|
|
250
|
-
start: range.start,
|
|
251
|
-
end: range.end,
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
catch (error) {
|
|
256
|
-
console.error('Invalid JSON for value:');
|
|
257
|
-
console.error(error);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
componentDidLoad() {
|
|
262
|
-
const inputs = this.el.querySelectorAll('.input-wrapper input');
|
|
263
|
-
inputs.forEach((input) => {
|
|
264
|
-
const inputMask = new inputmaskEdcad3c1.Inputmask({
|
|
265
|
-
alias: 'datetime',
|
|
266
|
-
inputFormat: this.convertToInputmaskFormat(this.dateFormat),
|
|
267
|
-
placeholder: '_',
|
|
268
|
-
clearIncomplete: false,
|
|
269
|
-
showMaskOnHover: false,
|
|
270
|
-
showMaskOnFocus: false,
|
|
271
|
-
clearMaskOnLostFocus: false,
|
|
272
|
-
insertMode: true,
|
|
273
|
-
rightAlign: false,
|
|
274
|
-
oncomplete: function (e) {
|
|
275
|
-
const input = e.target;
|
|
276
|
-
const event = new CustomEvent('input', { bubbles: true });
|
|
277
|
-
input.dispatchEvent(event);
|
|
278
|
-
},
|
|
279
|
-
});
|
|
280
|
-
inputMask.mask(input);
|
|
281
|
-
// Set the value after applying the mask
|
|
282
|
-
if (input.name === this.startName && this.startValue) {
|
|
283
|
-
requestAnimationFrame(() => {
|
|
284
|
-
input.value = this.startValue;
|
|
285
|
-
const event = new CustomEvent('input', { bubbles: true });
|
|
286
|
-
input.dispatchEvent(event);
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
else if (input.name === this.endName && this.endValue) {
|
|
290
|
-
requestAnimationFrame(() => {
|
|
291
|
-
input.value = this.endValue;
|
|
292
|
-
const event = new CustomEvent('input', { bubbles: true });
|
|
293
|
-
input.dispatchEvent(event);
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
componentDidRender() {
|
|
299
|
-
const inputs = this.el.querySelectorAll('.input-wrapper input');
|
|
300
|
-
inputs.forEach((input) => {
|
|
301
|
-
const value = input.name === this.startName
|
|
302
|
-
? this.startValue
|
|
303
|
-
: this.endName
|
|
304
|
-
? this.endValue
|
|
305
|
-
: '';
|
|
306
|
-
if (value) {
|
|
307
|
-
// Make sure the value is defined both as a property and attribute
|
|
308
|
-
requestAnimationFrame(() => {
|
|
309
|
-
input.value = value;
|
|
310
|
-
input.setAttribute('value', value);
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
disconnectedCallback() {
|
|
316
|
-
document.removeEventListener('click', this.handleClickOutside);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Handles the range date selection event from nv-calendar.
|
|
320
|
-
* @param {CustomEvent<DateRange>} event - The custom event
|
|
321
|
-
*/
|
|
322
|
-
handleRangeDateChange(event) {
|
|
323
|
-
const { start, end } = event.detail || {};
|
|
324
|
-
// Check that both dates are defined
|
|
325
|
-
if (start && end) {
|
|
326
|
-
this.startValue = start;
|
|
327
|
-
this.endValue = end;
|
|
328
|
-
this.calendarState = { start, end };
|
|
329
|
-
this.dateRangeChange.emit({
|
|
330
|
-
start: this.startValue,
|
|
331
|
-
end: this.endValue,
|
|
332
|
-
});
|
|
333
|
-
if (!this.showActions) {
|
|
334
|
-
this.open = false;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
handleClosePopover() {
|
|
339
|
-
this.open = false;
|
|
340
|
-
}
|
|
341
|
-
handleApplyDateRange() {
|
|
342
|
-
this.open = false;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Handles the reset event from the calendar's cancel button
|
|
346
|
-
* @param {CustomEvent} event - The event emitted by the calendar
|
|
347
|
-
*/
|
|
348
|
-
handleDateReset(event) {
|
|
349
|
-
const isResetSingle = event.type === 'singleDateChange' && event.detail === '';
|
|
350
|
-
const isResetRange = event.type === 'rangeDateChange' &&
|
|
351
|
-
event.detail &&
|
|
352
|
-
event.detail.start === '' &&
|
|
353
|
-
event.detail.end === '';
|
|
354
|
-
if (isResetSingle || isResetRange) {
|
|
355
|
-
this.startValue = '';
|
|
356
|
-
this.endValue = '';
|
|
357
|
-
const inputs = this.el.querySelectorAll('.input-wrapper input');
|
|
358
|
-
inputs.forEach((input) => {
|
|
359
|
-
input.value = '';
|
|
360
|
-
});
|
|
361
|
-
this.dateRangeChange.emit({ start: '', end: '' });
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Handles keyboard events.
|
|
366
|
-
* @param {KeyboardEvent} event - The keyboard event
|
|
367
|
-
*/
|
|
368
|
-
handleKeyDown(event) {
|
|
369
|
-
if (!this.open) {
|
|
370
|
-
if (event.key === 'ArrowDown') {
|
|
371
|
-
this.open = true;
|
|
372
|
-
event.preventDefault();
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
if (!this.popoverElement) {
|
|
378
|
-
console.warn('nv-fielddaterange -> Popover element is not defined');
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
handleValueChange(newValue) {
|
|
383
|
-
try {
|
|
384
|
-
const range = JSON.parse(newValue);
|
|
385
|
-
this.startValue = range.start || '';
|
|
386
|
-
this.endValue = range.end || '';
|
|
387
|
-
}
|
|
388
|
-
catch (error) {
|
|
389
|
-
console.error('Invalid JSON for value:', error);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
//#endregion EVENTS
|
|
393
|
-
/****************************************************************************/
|
|
394
|
-
//#region RENDER
|
|
395
|
-
render() {
|
|
396
|
-
return (index.h(index.Host, { key: '152a588b815a0f3846c5b0c8b9da8d3dbc8f4768' }, ((this.label && this.label.length > 0) ||
|
|
397
|
-
this.el.querySelector('[slot="label"]')) && (index.h("label", { key: '786269a2bd4a50559cfad72c61f80797e4afc902', htmlFor: this.startInputId }, index.h("slot", { key: 'e1c6ed7d288d21889e1ebdfdf0595d4f43e551f7', name: "label" }, this.label))), index.h("nv-popover", { key: '228966569f5670f1b283c2e45f1c1057811e699d', ref: el => (this.popoverElement = el), id: this.popoverId, triggerMode: "controlled", placement: "bottom-start", open: this.open }, index.h("div", { key: 'ee39e8da7367bceb1fdcaf7f008d780652471e8e', slot: "trigger", class: "input-wrapper" }, index.h("slot", { key: '0555695d16ae919327771c586a291dc1767ed98f', name: "before-input" }), index.h("div", { key: '106aec6a9be06a03497f66407ea8038d5e4be899', class: "input-container" }, index.h("slot", { key: 'e448f8bacd3b383944f862b9dc1b7ea64feb565e', name: "leading-input" }), index.h("div", { key: '52ef48b4d76f063c65daa43865da607273ba6410', class: "range-inputs" }, index.h("input", { key: '899e309f7e100b7b6d12603b229aa4c429ddc1d2', id: this.startInputId, type: "text", placeholder: this.startPlaceholder, name: this.startName, disabled: this.disabled, readOnly: this.readonly, required: this.required, autofocus: this.autofocus, value: this.startValue, onInput: this.handleStartInput, onFocus: this.handleFocus, "data-scope": "date-range" }), index.h("svg", { key: '083bef93159b08aaf5c9f7637fbe459c2017e82f', xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "icon icon-tabler icons-tabler-outline icon-tabler-arrows-move-horizontal" }, index.h("path", { key: '2946dbfae81e0b3cdd62f77bb928617d182ae5c1', stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), index.h("path", { key: 'afcf53514d22c9f8bb5d7d09294808f3ca053cc9', d: "M18 9l3 3l-3 3" }), index.h("path", { key: '53fe61cf1c1a5206f22d4c065292680f28fa3c59', d: "M15 12h6" }), index.h("path", { key: '1e138be2146498fa127922dcba9646e2e960a7e3', d: "M6 9l-3 3l3 3" }), index.h("path", { key: '3e324bf333bd69374fccac278386f6cc966fc3bd', d: "M3 12h6" })), index.h("input", { key: 'b7eeab7a9e0071c862528e8fa47c543d0295d331', id: this.endInputId, type: "text", placeholder: this.endPlaceholder, name: this.endName, disabled: this.disabled, readOnly: this.readonly, required: this.required, value: this.endValue, onInput: this.handleEndInput, onFocus: this.handleFocus, "data-scope": "date-range" })), this.error && (index.h("nv-icon", { key: 'f2ab540736820a8fcf7f4dbb973bc3a16b14fa8d', name: "alert-circle", class: "validation", size: "md" })), this.success && (index.h("nv-icon", { key: '91e75c515c4a44a3e499240e4d3c45b7a736429a', name: "circle-check", class: "validation", size: "md" })), index.h("nv-iconbutton", { key: 'a471cb1db59673f07ce493bae59e54ee8ecd8968', class: "toggle-calendar-icon", name: "calendar", size: "md", emphasis: "lower", "aria-label": this.open ? 'Hide calendar' : 'Show calendar', "aria-pressed": this.open.toString(), onClick: this.toggleCalendar, tabIndex: this.disabled ? -1 : 0 })), index.h("slot", { key: '375a0c1848445652c2ef5f20ded877223774f792', name: "after-input" })), index.h("div", { key: '7427c51a78cf38a979b9f7eb4e9a7f49a36279d5', slot: "content" }, index.h("nv-calendar", { key: '1f9ad9bed53d9496f17544c6381824490431c342', ref: el => (this.calendarElement = el), dateFormat: this.dateFormat, rangeValue: this.calendarState, firstDayOfWeek: this.firstDayOfWeek, numberOfCalendars: this.numberOfCalendars, min: this.min, max: this.max, locale: this.locale, shortcutsPlacement: this.shortcutsPlacement, showActions: this.showActions, shortcuts: this.shortcuts, showWeekNumbers: this.showWeekNumbers, disabledDates: this.disabledDates, selectionType: "range", "data-prevent-navigation": "true" }))), ((this.description && this.description.length > 0) ||
|
|
398
|
-
this.el.querySelector('[slot="description"]')) && (index.h("div", { key: 'c964928de34f26fc82619601d0964079b061048f', class: "description" }, index.h("slot", { key: 'f409a5286e1c0ba16f36f062df3df5531dad6296', name: "description" }, this.description))), (this.errorDescription ||
|
|
399
|
-
this.el.querySelector('[slot="error-description"]')) && (index.h("div", { key: '5e8a1b48da516f801372a59e379c5ade77f9761a', hidden: !this.error, class: "error-description" }, this.el.querySelector('[slot="error-description"]') ? (index.h("slot", { name: "error-description" })) : (this.errorDescription))), index.h("slot", { key: '68f37bddcd3208217a26eb230d1f8afdd3552eff' })));
|
|
400
|
-
}
|
|
401
|
-
get el() { return index.getElement(this); }
|
|
402
|
-
static get watchers() { return {
|
|
403
|
-
"value": ["handleValueChange"]
|
|
404
|
-
}; }
|
|
405
|
-
};
|
|
406
|
-
NvFielddaterange.style = NvFielddaterangeStyle0;
|
|
407
|
-
|
|
408
|
-
exports.nv_fielddaterange = NvFielddaterange;
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-B2jv2KXv.js');
|
|
4
|
-
var v4A79185f4 = require('./v4-a79185f4-2n0dOd_Y.js');
|
|
5
|
-
require('react');
|
|
6
|
-
|
|
7
|
-
const nvFieldnumberCss = "nv-fieldnumber {\n --nv-field-border-default: var(--components-form-field-border-default);\n --nv-field-border-hover: var(--components-form-field-border-hover);\n --nv-field-border-focus: var(--components-form-field-border-focus);\n --nv-field-border-disabled: var(--components-form-field-border-default);\n --nv-field-border-readonly: var(--components-form-field-border-default);\n --nv-field-focus-box-shadow: var(--color-focus-brand);\n --nv-field-background: var(--components-form-field-background-default);\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--form-gap-y);\n box-sizing: border-box;\n max-width: 480px;\n}\nnv-fieldnumber[fluid]:not([fluid=false]) {\n max-width: unset;\n}\nnv-fieldnumber[readonly]:not([readonly=false]) {\n --nv-field-border-default: var(--components-form-field-border-readonly);\n --nv-field-border-hover: var(--nv-field-border-default);\n --nv-field-border-focus: var(--components-form-field-border-focus);\n --nv-field-border-disabled: var(--nv-field-border-default);\n --nv-field-border-readonly: var(--nv-field-border-default);\n --nv-field-background: var(--components-form-field-background-readonly);\n}\nnv-fieldnumber[error]:not([error=false]) {\n --nv-field-border-default: var(--components-form-field-border-error);\n --nv-field-border-hover: var(--nv-field-border-default);\n --nv-field-border-focus: var(--nv-field-border-default);\n --nv-field-border-disabled: var(--nv-field-border-default);\n --nv-field-border-readonly: var(--nv-field-border-default);\n --nv-field-focus-box-shadow: var(--color-focus-destructive-in-field);\n}\nnv-fieldnumber[success]:not([success=false]) {\n --nv-field-border-default: var(--components-form-field-border-success);\n --nv-field-border-hover: var(--nv-field-border-default);\n --nv-field-border-focus: var(--nv-field-border-default);\n --nv-field-border-disabled: var(--nv-field-border-default);\n --nv-field-border-readonly: var(--nv-field-border-default);\n --nv-field-focus-box-shadow: var(--color-focus-success);\n}\nnv-fieldnumber[required]:not([required=false]) label::after {\n content: \"*\";\n color: var(--components-form-text-required);\n font-weight: 700;\n}\nnv-fieldnumber label {\n display: flex;\n align-items: center;\n gap: var(--form-label-gap);\n align-self: stretch;\n color: var(--components-form-text-label-default);\n font-family: \"TT Norms Pro\", sans-serif;\n font-size: var(--form-label-font-size);\n font-style: normal;\n font-weight: 500;\n line-height: var(--form-label-line-height);\n}\nnv-fieldnumber .input-wrapper {\n display: flex;\n flex-wrap: wrap;\n gap: var(--form-gap-x);\n align-items: stretch;\n align-self: stretch;\n}\nnv-fieldnumber .input-wrapper .input-container {\n display: flex;\n flex-grow: 1;\n justify-content: center;\n align-items: center;\n align-self: stretch;\n border-radius: var(--form-field-radius);\n border-width: 1px;\n border-style: solid;\n border-color: var(--nv-field-border-default);\n opacity: var(--components-form-opacity-default, 1);\n background: var(--nv-field-background);\n transition: all 150ms ease-out;\n container-type: inline-size;\n container-name: field-number-input-container;\n overflow: hidden;\n position: relative;\n}\nnv-fieldnumber .input-wrapper .input-container:hover {\n border-color: var(--nv-field-border-hover);\n}\nnv-fieldnumber .input-wrapper .input-container:focus-within, nv-fieldnumber .input-wrapper .input-container:focus-within:hover, nv-fieldnumber .input-wrapper .input-container:focus, nv-fieldnumber .input-wrapper .input-container:focus:hover {\n border-color: var(--nv-field-border-focus);\n box-shadow: 0px 0px 0px var(--focus-field-stroke) var(--nv-field-focus-box-shadow);\n}\nnv-fieldnumber .input-wrapper .input-container:has(input:read-only) {\n opacity: 0.5;\n background-color: var(--components-form-field-background-readonly);\n border-color: var(--nv-field-border-readonly);\n}\nnv-fieldnumber .input-wrapper .input-container:has(input:disabled) {\n opacity: 0.5;\n background-color: var(--components-form-field-background-disabled);\n border-color: var(--nv-field-border-disabled);\n}\nnv-fieldnumber .input-wrapper .input-container input {\n display: flex;\n align-items: center;\n flex: 1 0 0;\n overflow: hidden;\n background-color: transparent;\n color: var(--components-form-field-content-text);\n padding: var(--form-field-padding-y) var(--form-field-padding-x);\n font-size: var(--form-field-font-size);\n font-style: normal;\n font-weight: 500;\n line-height: var(--form-field-line-height);\n width: 100%;\n width: 100%;\n appearance: textfield;\n}\nnv-fieldnumber .input-wrapper .input-container input:focus {\n outline: none;\n}\nnv-fieldnumber .input-wrapper .input-container input::placeholder {\n overflow: hidden;\n color: var(--components-form-field-content-placeholder);\n text-overflow: ellipsis;\n font-family: \"TT Norms Pro\", sans-serif;\n font-size: var(--form-field-font-size);\n font-style: normal;\n font-weight: 400;\n line-height: var(--form-field-line-height);\n}\nnv-fieldnumber .input-wrapper .input-container input::-webkit-inner-spin-button, nv-fieldnumber .input-wrapper .input-container input::-webkit-outer-spin-button {\n appearance: none;\n margin: 0;\n}\nnv-fieldnumber .input-wrapper .input-container nv-icon.validation {\n color: var(--nv-field-border-default);\n margin-right: var(--form-field-gap);\n}\nnv-fieldnumber .input-wrapper .input-container > nv-iconbutton {\n border: 0px;\n border-radius: 0px;\n}\nnv-fieldnumber .input-wrapper .input-container > nv-iconbutton:focus-visible {\n border-radius: var(--button-md-border-radius);\n outline-offset: -3px;\n}\nnv-fieldnumber .input-wrapper .input-container .stepper {\n display: flex;\n border-left: var(--notification-border-width-low-emphasis) solid var(--components-form-field-border-readonly);\n}\nnv-fieldnumber .input-wrapper .input-container .stepper > nv-iconbutton {\n border: 0px;\n border-radius: 0px;\n border-radius: 0px;\n}\nnv-fieldnumber .input-wrapper .input-container .stepper > nv-iconbutton:focus-visible {\n border-radius: var(--button-md-border-radius);\n outline-offset: -3px;\n}\n@container field-number-input-container (width < 150px) {\n nv-fieldnumber .input-wrapper .input-container .stepper-spacer {\n display: none;\n }\n nv-fieldnumber .input-wrapper .input-container .stepper {\n display: none;\n }\n}\nnv-fieldnumber .description {\n display: flex;\n align-items: center;\n align-self: stretch;\n gap: var(--spacing-1);\n color: var(--components-form-text-description-default);\n font-family: \"TT Norms Pro\", sans-serif;\n font-size: var(--form-description-font-size);\n font-style: normal;\n line-height: var(--form-description-line-height);\n}\nnv-fieldnumber .error-description {\n display: flex;\n align-items: center;\n align-self: stretch;\n gap: var(--spacing-1);\n color: var(--components-form-text-description-default);\n font-family: \"TT Norms Pro\", sans-serif;\n font-size: var(--form-description-font-size);\n font-style: normal;\n line-height: var(--form-description-line-height);\n color: var(--components-form-text-description-error);\n}";
|
|
8
|
-
const NvFieldnumberStyle0 = nvFieldnumberCss;
|
|
9
|
-
|
|
10
|
-
const NvFieldnumber = class {
|
|
11
|
-
constructor(hostRef) {
|
|
12
|
-
index.registerInstance(this, hostRef);
|
|
13
|
-
this.valueChanged = index.createEvent(this, "valueChanged");
|
|
14
|
-
//#endregion DEPRECATED
|
|
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
|
-
* The disabled prop lets you turn off the input field so that users can’t
|
|
26
|
-
* type in it. When disabled, the field is grayed out and won’t respond to#
|
|
27
|
-
* clicks or touches.
|
|
28
|
-
*/
|
|
29
|
-
this.disabled = false;
|
|
30
|
-
/**
|
|
31
|
-
* Display the input field’s content without allowing users to change it.
|
|
32
|
-
* Users can still click on it, select, and copy the text, but they won’t be
|
|
33
|
-
* able to type or delete anything.
|
|
34
|
-
*/
|
|
35
|
-
this.readonly = false;
|
|
36
|
-
/**
|
|
37
|
-
* Marks the input field as required, ensuring that the user must fill it out
|
|
38
|
-
* before submitting the form.
|
|
39
|
-
*/
|
|
40
|
-
this.required = false;
|
|
41
|
-
/**
|
|
42
|
-
* Alters the input field’s appearance to indicate an error, helping users
|
|
43
|
-
* identify fields that need correction.
|
|
44
|
-
* @validator error
|
|
45
|
-
*/
|
|
46
|
-
this.error = false;
|
|
47
|
-
/**
|
|
48
|
-
* Changes the input field’s appearance to indicate successful input or
|
|
49
|
-
* validation.
|
|
50
|
-
*/
|
|
51
|
-
this.success = false;
|
|
52
|
-
/**
|
|
53
|
-
* Define the increment value for the input field. It determines how much the
|
|
54
|
-
* value will increase or decrease when the user clicks the stepper buttons.
|
|
55
|
-
*/
|
|
56
|
-
this.step = 1;
|
|
57
|
-
/**
|
|
58
|
-
* Applies focus to the input field as soon as the component is mounted. This
|
|
59
|
-
* is equivalent to setting the native autofocus attribute on an <input>
|
|
60
|
-
* element.
|
|
61
|
-
*/
|
|
62
|
-
this.autofocus = false;
|
|
63
|
-
/**
|
|
64
|
-
* Allows the field to stretch and fill the entire width of its container.
|
|
65
|
-
*/
|
|
66
|
-
this.fluid = false;
|
|
67
|
-
//#endregion WATCHERS
|
|
68
|
-
/****************************************************************************/
|
|
69
|
-
//#region METHODS
|
|
70
|
-
this.handleInput = (event) => {
|
|
71
|
-
const input = event.target;
|
|
72
|
-
this.value = Number(input.value);
|
|
73
|
-
};
|
|
74
|
-
this.handleInputContainerClick = () => {
|
|
75
|
-
this.inputElement.focus();
|
|
76
|
-
};
|
|
77
|
-
this.handlePlus = () => {
|
|
78
|
-
this.inputElement.stepUp();
|
|
79
|
-
this.value = Number(this.inputElement.value);
|
|
80
|
-
};
|
|
81
|
-
this.handleMinus = () => {
|
|
82
|
-
this.inputElement.stepDown();
|
|
83
|
-
this.value = Number(this.inputElement.value);
|
|
84
|
-
};
|
|
85
|
-
// prevents text selection when clicking the buttons multiple times
|
|
86
|
-
this.preventSelection = (event) => {
|
|
87
|
-
event.preventDefault();
|
|
88
|
-
};
|
|
89
|
-
this.isMinValueReached = () => {
|
|
90
|
-
return this.min !== undefined && this.value <= this.min;
|
|
91
|
-
};
|
|
92
|
-
this.isMaxValueReached = () => {
|
|
93
|
-
return this.max !== undefined && this.value >= this.max;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
//#endregion EVENTS
|
|
97
|
-
/****************************************************************************/
|
|
98
|
-
//#region WATCHERS
|
|
99
|
-
watchValueHandler(newValue) {
|
|
100
|
-
this.valueChanged.emit(newValue);
|
|
101
|
-
}
|
|
102
|
-
//#endregion METHODS
|
|
103
|
-
/****************************************************************************/
|
|
104
|
-
//#region LIFECYCLE
|
|
105
|
-
componentWillRender() {
|
|
106
|
-
if (this.message) {
|
|
107
|
-
this.description = this.message;
|
|
108
|
-
}
|
|
109
|
-
if (this.validation) {
|
|
110
|
-
this.errorDescription = this.validation;
|
|
111
|
-
this.error = true;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
//#endregion LIFECYCLE
|
|
115
|
-
/****************************************************************************/
|
|
116
|
-
//#region RENDER
|
|
117
|
-
render() {
|
|
118
|
-
return (index.h(index.Host, { key: 'ff097af3b023ea85fe549331219fd147aaf5d587' }, (this.label || this.el.querySelector('[slot="label"]')) && (index.h("label", { key: 'fbb5a460baf515c9f41068126db0dfc80f3aba64', htmlFor: this.inputId }, index.h("slot", { key: '27963c9e2f61213b1897e117a68a2cb0d56e7d0f', name: "label" }, this.label))), index.h("div", { key: 'f1f53b27aabd76cfe478ca0de182fd0d181e1c4b', class: "input-wrapper" }, index.h("slot", { key: 'f5f0fe6e8fbaa63bb961a5216eba0d0a10ca4cf7', name: "before-input" }), index.h("div", { key: '6d615f206e6b0ed3b228c75601fd7608b1aa4869', class: "input-container", onClick: this.handleInputContainerClick }, index.h("slot", { key: 'd4cbd09db77e7998020289b44d43be1c37c1197a', name: "leading-input" }), index.h("input", { key: 'fa8620fa422b1b96a05630da3f5bed20281b8d19', id: this.inputId, ref: e => (this.inputElement = e), placeholder: this.placeholder, name: this.name, type: "number", autofocus: this.autofocus, required: this.required, max: this.max, min: this.min, step: this.step, value: this.value, disabled: this.disabled, readOnly: this.readonly, onInput: this.handleInput }), this.error && (index.h("nv-icon", { key: '0787893a02fbebf2bec97f4285d4b396fc1a474d', name: "alert-circle", class: "validation", size: "md" })), this.success && (index.h("nv-icon", { key: 'd2d244b7a2280c3b7719927d6550a28c75743a48', name: "circle-check", class: "validation", size: "md" })), index.h("div", { key: 'ebe05dafe4b7ec67dbe59d5da612f2f5e6951e3f', class: "stepper" }, index.h("nv-iconbutton", { key: '3112ee0b6f5b3982290cd1ec006653d48d3db626', size: "md", name: "minus", emphasis: "lower", onClick: this.handleMinus, disabled: this.isMinValueReached(), onMouseDown: this.preventSelection, tabindex: "-1" }), index.h("nv-iconbutton", { key: 'e3cdf3ca761ebd647e13f23df44c4e18879b8913', size: "md", name: "plus", emphasis: "lower", onClick: this.handlePlus, disabled: this.isMaxValueReached(), onMouseDown: this.preventSelection, tabindex: "-1" }))), index.h("slot", { key: 'c6de7aaff35002e78e5a27d5f37fe06297b3693f', name: "after-input" })), (this.description ||
|
|
119
|
-
this.el.querySelector('[slot="description"]')) && (index.h("div", { key: 'e2c1ea1eb866593cee0eb4218dba9665cd8a321c', class: "description" }, index.h("slot", { key: '1fd324333be676116f5d614bb2dc7448ecd7d3a1', name: "description" }, this.description))), (this.errorDescription ||
|
|
120
|
-
this.el.querySelector('[slot="error-description"]')) && (index.h("div", { key: 'adb8565f5204849caff31758f739d732f2eb5a01', hidden: !this.error, class: "error-description" }, index.h("slot", { key: '0f2ec09a50e98855cc3f2451c75bd6dca4a6baec', name: "error-description" }, this.errorDescription)))));
|
|
121
|
-
}
|
|
122
|
-
static get formAssociated() { return true; }
|
|
123
|
-
get el() { return index.getElement(this); }
|
|
124
|
-
static get watchers() { return {
|
|
125
|
-
"value": ["watchValueHandler"]
|
|
126
|
-
}; }
|
|
127
|
-
};
|
|
128
|
-
NvFieldnumber.style = NvFieldnumberStyle0;
|
|
129
|
-
|
|
130
|
-
exports.nv_fieldnumber = NvFieldnumber;
|