@nova-design-system/nova-webcomponents 3.9.0 → 3.9.1
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/loader.cjs.js +1 -1
- package/dist/cjs/native.cjs.js +1 -1
- package/dist/cjs/nv-calendar.cjs.entry.js +9 -3
- package/dist/cjs/nv-calendar.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddate.cjs.entry.js +62 -94
- package/dist/cjs/nv-fielddate.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddaterange.cjs.entry.js +52 -33
- package/dist/cjs/nv-fielddaterange.cjs.entry.js.map +1 -1
- package/dist/collection/components/nv-calendar/nv-calendar.js +9 -3
- package/dist/collection/components/nv-calendar/nv-calendar.js.map +1 -1
- package/dist/collection/components/nv-fielddate/nv-fielddate.js +63 -94
- package/dist/collection/components/nv-fielddate/nv-fielddate.js.map +1 -1
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.js +52 -33
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.js.map +1 -1
- package/dist/components/nv-calendar.js +1 -1
- package/dist/components/nv-fielddate.js +66 -98
- package/dist/components/nv-fielddate.js.map +1 -1
- package/dist/components/nv-fielddaterange.js +54 -35
- package/dist/components/nv-fielddaterange.js.map +1 -1
- package/dist/components/{p-d32b75ac.js → p-82e5674c.js} +10 -4
- package/dist/components/p-82e5674c.js.map +1 -0
- package/dist/components/{p-91a558eb.js → p-f1df2634.js} +2 -2
- package/dist/components/{p-91a558eb.js.map → p-f1df2634.js.map} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/native.js +1 -1
- package/dist/esm/nv-calendar.entry.js +9 -3
- package/dist/esm/nv-calendar.entry.js.map +1 -1
- package/dist/esm/nv-fielddate.entry.js +62 -94
- package/dist/esm/nv-fielddate.entry.js.map +1 -1
- package/dist/esm/nv-fielddaterange.entry.js +52 -33
- package/dist/esm/nv-fielddaterange.entry.js.map +1 -1
- package/dist/native/native.esm.js +1 -1
- package/dist/native/native.esm.js.map +1 -1
- package/dist/native/{p-dc34da69.entry.js → p-4a533dd8.entry.js} +2 -2
- package/dist/native/p-4a533dd8.entry.js.map +1 -0
- package/dist/native/{p-f687e05c.entry.js → p-55cd3d62.entry.js} +2 -2
- package/dist/native/p-55cd3d62.entry.js.map +1 -0
- package/dist/native/{p-516da423.entry.js → p-9ea3d30d.entry.js} +2 -2
- package/dist/native/p-9ea3d30d.entry.js.map +1 -0
- package/dist/types/components/nv-fielddate/nv-fielddate.d.ts +4 -19
- package/dist/types/components/nv-fielddaterange/nv-fielddaterange.d.ts +1 -0
- package/hydrate/index.js +123 -131
- package/hydrate/index.mjs +123 -131
- package/package.json +1 -1
- package/dist/components/p-d32b75ac.js.map +0 -1
- package/dist/native/p-516da423.entry.js.map +0 -1
- package/dist/native/p-dc34da69.entry.js.map +0 -1
- package/dist/native/p-f687e05c.entry.js.map +0 -1
|
@@ -46,8 +46,6 @@ const NvFielddate = class {
|
|
|
46
46
|
* The initial value of the input (date in string format).
|
|
47
47
|
* @bind value
|
|
48
48
|
*/
|
|
49
|
-
// eslint-disable-next-line @stencil-community/own-props-must-be-private
|
|
50
|
-
// eslint-disable-next-line @stencil-community/strict-mutable
|
|
51
49
|
this.value = '';
|
|
52
50
|
/**
|
|
53
51
|
* The current value of the input date in string format.
|
|
@@ -119,18 +117,10 @@ const NvFielddate = class {
|
|
|
119
117
|
return;
|
|
120
118
|
}
|
|
121
119
|
this.inputElement.focus();
|
|
122
|
-
// Select the first characters based on the date format
|
|
123
|
-
const format = this.dateFormat;
|
|
124
|
-
if (format.startsWith('DD') || format.startsWith('MM')) {
|
|
125
|
-
this.inputElement.setSelectionRange(0, 2);
|
|
126
|
-
}
|
|
127
|
-
else if (format.startsWith('YYYY')) {
|
|
128
|
-
this.inputElement.setSelectionRange(0, 4);
|
|
129
|
-
}
|
|
130
120
|
};
|
|
131
121
|
/**
|
|
132
122
|
* Handles the input event on the input element.
|
|
133
|
-
* Updates the singleValue and emits the valueChanged event.
|
|
123
|
+
* Updates the singleValue and emits the valueChanged event if empty.
|
|
134
124
|
* @param {Event} event - The input event.
|
|
135
125
|
*/
|
|
136
126
|
this.handleInput = (event) => {
|
|
@@ -139,74 +129,10 @@ const NvFielddate = class {
|
|
|
139
129
|
return;
|
|
140
130
|
}
|
|
141
131
|
const input = event.target;
|
|
142
|
-
const previousValue = this.value;
|
|
143
132
|
this.singleValue = input.value;
|
|
144
133
|
this.value = input.value;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this.valueChanged.emit(input.value);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* Initializes the input mask.
|
|
152
|
-
*/
|
|
153
|
-
this.initializeInputMask = () => {
|
|
154
|
-
this.currentPlaceholder = '';
|
|
155
|
-
if (this.inputElement.inputmask) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const inputMask = new Inputmask({
|
|
159
|
-
alias: 'datetime',
|
|
160
|
-
inputFormat: this.convertToInputmaskFormat(this.dateFormat),
|
|
161
|
-
placeholder: ' ',
|
|
162
|
-
prefillYear: false,
|
|
163
|
-
clearIncomplete: false,
|
|
164
|
-
showMaskOnHover: false,
|
|
165
|
-
showMaskOnFocus: false,
|
|
166
|
-
clearMaskOnLostFocus: false,
|
|
167
|
-
insertMode: true,
|
|
168
|
-
rightAlign: false,
|
|
169
|
-
oncomplete: function (e) {
|
|
170
|
-
const input = e.target;
|
|
171
|
-
const event = new CustomEvent('input', { bubbles: true });
|
|
172
|
-
input.dispatchEvent(event);
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
inputMask.mask(this.inputElement);
|
|
176
|
-
// Set the value after applying the mask
|
|
177
|
-
if (this.inputElement.name === this.name && this.singleValue) {
|
|
178
|
-
requestAnimationFrame(() => {
|
|
179
|
-
this.inputElement.value = this.singleValue;
|
|
180
|
-
const event = new CustomEvent('input', { bubbles: true });
|
|
181
|
-
this.inputElement.dispatchEvent(event);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* Handles keydown events on the input before the mask is initialized.
|
|
187
|
-
* Initializes the mask on the first number input.
|
|
188
|
-
* @param {KeyboardEvent} event - The keyboard event.
|
|
189
|
-
*/
|
|
190
|
-
this.handleKeydownBeforeMask = (event) => {
|
|
191
|
-
const allowedKeys = [
|
|
192
|
-
'Backspace',
|
|
193
|
-
'Delete',
|
|
194
|
-
'Tab',
|
|
195
|
-
'ArrowLeft',
|
|
196
|
-
'ArrowRight',
|
|
197
|
-
'ArrowUp',
|
|
198
|
-
'ArrowDown',
|
|
199
|
-
'Home',
|
|
200
|
-
'End',
|
|
201
|
-
];
|
|
202
|
-
if (/\d/.test(event.key)) {
|
|
203
|
-
this.initializeInputMask();
|
|
204
|
-
this.inputElement.removeEventListener('keydown', this.handleKeydownBeforeMask);
|
|
205
|
-
}
|
|
206
|
-
else if (!allowedKeys.includes(event.key) &&
|
|
207
|
-
!event.metaKey &&
|
|
208
|
-
!event.ctrlKey) {
|
|
209
|
-
event.preventDefault();
|
|
134
|
+
if (this.value === '') {
|
|
135
|
+
this.valueChanged.emit('');
|
|
210
136
|
}
|
|
211
137
|
};
|
|
212
138
|
/**
|
|
@@ -219,17 +145,8 @@ const NvFielddate = class {
|
|
|
219
145
|
event.target.blur();
|
|
220
146
|
return;
|
|
221
147
|
}
|
|
222
|
-
if (!this.inputElement.inputmask) {
|
|
223
|
-
this.inputElement.addEventListener('keydown', this.handleKeydownBeforeMask);
|
|
224
|
-
}
|
|
225
148
|
this.open = true;
|
|
226
149
|
};
|
|
227
|
-
/**
|
|
228
|
-
* Handles blur events on the input element.
|
|
229
|
-
*/
|
|
230
|
-
this.handleBlur = () => {
|
|
231
|
-
this.inputElement.removeEventListener('keydown', this.handleKeydownBeforeMask);
|
|
232
|
-
};
|
|
233
150
|
/**
|
|
234
151
|
* Prevents the valueChanged event from the calendar from propagating up.
|
|
235
152
|
* @param {CustomEvent} event - The valueChanged event from nv-calendar.
|
|
@@ -304,6 +221,27 @@ const NvFielddate = class {
|
|
|
304
221
|
// Close the popover if open
|
|
305
222
|
this.open = false;
|
|
306
223
|
}
|
|
224
|
+
updateMask() {
|
|
225
|
+
var _a, _b;
|
|
226
|
+
if (!this.inputElement)
|
|
227
|
+
return;
|
|
228
|
+
(_b = (_a = this.inputElement.inputmask) === null || _a === void 0 ? void 0 : _a.remove) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
229
|
+
const inputMask = new Inputmask({
|
|
230
|
+
alias: 'datetime',
|
|
231
|
+
inputFormat: this.convertToInputmaskFormat(this.dateFormat),
|
|
232
|
+
placeholder: this.convertToInputmaskFormat(this.dateFormat),
|
|
233
|
+
clearIncomplete: false,
|
|
234
|
+
showMaskOnHover: false,
|
|
235
|
+
showMaskOnFocus: true,
|
|
236
|
+
clearMaskOnLostFocus: !this.open,
|
|
237
|
+
postValidation: true,
|
|
238
|
+
oncomplete: (e) => {
|
|
239
|
+
var _a;
|
|
240
|
+
this.valueChanged.emit((_a = e.target) === null || _a === void 0 ? void 0 : _a.value);
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
inputMask.mask(this.inputElement);
|
|
244
|
+
}
|
|
307
245
|
//#endregion METHODS
|
|
308
246
|
/****************************************************************************/
|
|
309
247
|
//#region LIFECYCLE
|
|
@@ -314,10 +252,26 @@ const NvFielddate = class {
|
|
|
314
252
|
if (this.value) {
|
|
315
253
|
this.singleValue = this.value;
|
|
316
254
|
}
|
|
317
|
-
this.currentPlaceholder = this.placeholder || this.dateFormat;
|
|
318
255
|
}
|
|
319
256
|
componentDidLoad() {
|
|
320
|
-
|
|
257
|
+
this.updateMask();
|
|
258
|
+
// Set the initial value after applying the mask
|
|
259
|
+
if (this.inputElement.name === this.name && this.singleValue) {
|
|
260
|
+
requestAnimationFrame(() => {
|
|
261
|
+
this.inputElement.value = this.singleValue;
|
|
262
|
+
const event = new CustomEvent('input', { bubbles: true });
|
|
263
|
+
this.inputElement.dispatchEvent(event);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
componentDidRender() {
|
|
268
|
+
// Only set value on initial render when there's no existing value in the input
|
|
269
|
+
if (this.singleValue && this.inputElement && !this.inputElement.value) {
|
|
270
|
+
requestAnimationFrame(() => {
|
|
271
|
+
this.inputElement.value = this.singleValue;
|
|
272
|
+
this.inputElement.setAttribute('value', this.singleValue);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
321
275
|
}
|
|
322
276
|
disconnectedCallback() {
|
|
323
277
|
document.removeEventListener('click', this.handleClickOutside);
|
|
@@ -336,6 +290,10 @@ const NvFielddate = class {
|
|
|
336
290
|
const previousValue = this.value;
|
|
337
291
|
this.singleValue = value;
|
|
338
292
|
this.value = value;
|
|
293
|
+
// Set the input value directly when calendar is used
|
|
294
|
+
if (this.inputElement) {
|
|
295
|
+
this.inputElement.value = value;
|
|
296
|
+
}
|
|
339
297
|
// Only emit valueChanged if the value actually changed
|
|
340
298
|
if (previousValue !== value) {
|
|
341
299
|
this.valueChanged.emit(value);
|
|
@@ -364,21 +322,31 @@ const NvFielddate = class {
|
|
|
364
322
|
}
|
|
365
323
|
handleValueChange(newValue) {
|
|
366
324
|
this.singleValue = newValue;
|
|
325
|
+
// Only set input value if it's different from current input value
|
|
326
|
+
// This prevents interfering with user typing
|
|
327
|
+
if (this.inputElement && this.inputElement.value !== newValue) {
|
|
328
|
+
this.inputElement.value = newValue;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
handleOpenChange() {
|
|
332
|
+
this.updateMask();
|
|
367
333
|
}
|
|
368
334
|
//#endregion EVENTS
|
|
369
335
|
/****************************************************************************/
|
|
370
336
|
//#region RENDER
|
|
371
337
|
render() {
|
|
372
|
-
return (h(Host, { key: '
|
|
373
|
-
this.el.querySelector('[slot="label"]')) && (h("label", { key: '
|
|
338
|
+
return (h(Host, { key: 'e72afd15f69aa6267cc9444e63fae12e4cfcf05b' }, ((this.label && this.label.length > 0) ||
|
|
339
|
+
this.el.querySelector('[slot="label"]')) && (h("label", { key: 'bc13c15f74ac4dbe4b326fe479dcd9a6fb20cf40', htmlFor: this.inputId }, h("slot", { key: '30ae9788e7768adc9da95e0b89a3f6f7027e625f', name: "label" }, this.label))), h("nv-popover", { key: 'e043d7b021d1d7ee206d231a1cfc7b4541091ae5', ref: this.setPopoverRef, id: this.popoverId, triggerMode: "controlled", placement: "bottom-start", open: this.open }, h("div", { key: '75682a712a8276bc24b285a48ef2312aae9f5097', slot: "trigger", class: "input-wrapper" }, h("slot", { key: '17593b316a870a5edbbc50eb4bb9441759309612', name: "before-input" }), h("div", { key: '0eb576fbe4a800ed7e1583810986e5f7f07e175a', class: "input-container", onClick: this.handleInputContainerClick }, h("slot", { key: 'c058ea07757486cf69621deba85ebbec3b075779', name: "leading-input" }), h("input", { key: '4c31a633358ff96f774a7862507c4c40301062cb', id: this.inputId, ref: this.setInputRef, placeholder: this.placeholder ||
|
|
340
|
+
this.convertToInputmaskFormat(this.dateFormat), name: this.name, disabled: this.disabled, readOnly: this.readonly, required: this.required, autofocus: this.autofocus, onInput: this.handleInput, onFocus: this.handleFocus, "data-scope": "date" }), this.error && (h("nv-icon", { key: '036392f177a0c10f609e7b555c3e7f256cd63962', name: "alert-circle", class: "validation", size: "md" })), this.success && (h("nv-icon", { key: '5a74ecdd55177d8cda55e8afdb05978e23450346', name: "circle-check", class: "validation", size: "md" })), h("nv-iconbutton", { key: 'e07f8b69d1810430cffff071d39ca7c72a15ccaf', class: "toggle-calendar-icon", name: "calendar" //{this.open ? 'chevron-top' : 'chevron-down'}
|
|
374
341
|
,
|
|
375
|
-
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 })), h("slot", { key: '
|
|
376
|
-
this.el.querySelector('[slot="description"]')) && (h("div", { key: '
|
|
377
|
-
this.el.querySelector('[slot="error-description"]')) && (h("div", { key: '
|
|
342
|
+
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 })), h("slot", { key: 'a84e382a534735adb22741df1751d9c70c050b69', name: "after-input" })), h("div", { key: '29a3ca7ed69a772497590595fc82a78fddf0c32a', slot: "content" }, h("nv-calendar", { key: '6797dab38dba23f7396aadcbf5281aefdabd891f', dateFormat: this.dateFormat, singleValue: this.singleValue, 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, onValueChanged: this.handleCalendarValueChanged }))), ((this.description && this.description.length > 0) ||
|
|
343
|
+
this.el.querySelector('[slot="description"]')) && (h("div", { key: '1799cd4dc4f6ca4b520277c080574af089816a9b', class: "description" }, h("slot", { key: 'eb2d9ac73687786e589f5a90791763f4465d1d20', name: "description" }, this.description))), (this.errorDescription ||
|
|
344
|
+
this.el.querySelector('[slot="error-description"]')) && (h("div", { key: '7c25fc8369b6bc948d7b233eb5b58451b02cbc62', hidden: !this.error, class: "error-description" }, this.el.querySelector('[slot="error-description"]') ? (h("slot", { name: "error-description" })) : (this.errorDescription))), h("slot", { key: '1499ea51b0e2d283037bf71aae6da242839c0e49' })));
|
|
378
345
|
}
|
|
379
346
|
get el() { return getElement(this); }
|
|
380
347
|
static get watchers() { return {
|
|
381
|
-
"value": ["handleValueChange"]
|
|
348
|
+
"value": ["handleValueChange"],
|
|
349
|
+
"open": ["handleOpenChange"]
|
|
382
350
|
}; }
|
|
383
351
|
};
|
|
384
352
|
NvFielddate.style = NvFielddateStyle0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"nv-fielddate.entry.js","mappings":";;;;;AAAA,MAAM,c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IAClD,YAAM,IAAI,EAAC,mBAAmB,GAAQ,KAEtC,IAAI,CAAC,gBAAgB,CACtB,CACG,CACP,EAED,8DAAa,CACR,EACP;KACH;;;;;;;;;;","names":["uuidv4"],"sources":["src/components/nv-fielddate/styles/nv-fielddate.scss?tag=nv-fielddate","src/components/nv-fielddate/nv-fielddate.tsx"],"sourcesContent":["@import '../../../styles/form-field';\n\nnv-fielddate {\n @include form-field-variables();\n @include form-field-root();\n\n &[fluid]:not([fluid=\"false\"]) {\n @include form-field-fluid();\n }\n\n &[readonly]:not([readonly='false']) {\n @include form-field-readonly-variables();\n }\n\n &[error]:not([error='false']) {\n @include form-field-error-variables();\n }\n\n &[success]:not([success='false']) {\n @include form-field-success-variables();\n }\n\n &[required]:not([required='false']) label {\n @include form-field-label-required();\n }\n\n label {\n @include form-field-label();\n }\n\n nv-popover {\n width: 100%;\n display: block;\n\n [data-scope='popover'] {\n padding: 0;\n background-color: var(--components-list-dropdown-background);\n border: 1px solid var(--components-list-dropdown-border);\n width: auto;\n }\n\n [slot='content'] {\n display: block;\n width: 100%;\n }\n .datepicker-container {\n border: none\n }\n }\n\n .input-wrapper {\n @include form-field-input-wrapper();\n display: flex;\n align-items: center;\n gap: 8px;\n\n .input-container {\n @include form-field-input-container();\n\n input {\n @include form-field-input();\n font-feature-settings: 'tnum';\n font-family: \"TTNorms Pro Mono\", monospace;\n }\n\n > nv-iconbutton {\n @include form-field-action();\n }\n\n nv-icon.validation {\n @include form-field-icon();\n }\n }\n }\n\n .description {\n @include form-field-description();\n }\n\n .error-description {\n @include form-field-error-description();\n }\n}\n","import {\n Component,\n h,\n Prop,\n State,\n Element,\n Event,\n EventEmitter,\n Listen,\n Host,\n Watch,\n Method,\n} from '@stencil/core';\nimport Inputmask from 'inputmask';\nimport { v4 as uuidv4 } from 'uuid';\n\n/**\n * Extends HTMLInputElement to include the inputmask property.\n */\ninterface HTMLInputElementWithInputmask extends HTMLInputElement {\n /**\n * The inputmask instance that provides masking functionality.\n */\n inputmask?: {\n /**\n * Removes the inputmask instance.\n */\n remove: () => void;\n };\n}\n\n/**\n * A field date component that combines an input with a calendar popover.\n *\n * @slot default - Child content of the component.\n * @slot leading-input - Content to be placed before the input text, within the input container.\n * @slot before-input - Content to be placed before the input text, outside the input container.\n * @slot after-input - Content to be placed after the input text, outside the input container.\n * @slot label - Content to be placed as the label, will override the label prop.\n * @slot description - Content to be placed as the description, will override the description prop.\n * @slot error-description - Content to be placed as the error description, will override the errorDescription prop.\n */\n@Component({\n tag: 'nv-fielddate',\n styleUrl: 'styles/nv-fielddate.scss',\n shadow: false,\n})\nexport class NvFielddate {\n @Element() el: HTMLNvFielddateElement;\n private inputElement!: HTMLInputElement;\n\n private popoverElement!: HTMLNvPopoverElement;\n private popoverId: string = uuidv4();\n\n /****************************************************************************/\n //#region PROPERTIES\n\n /**\n * Sets the ID for the input element and the for attribute of the associated\n * label. If no ID is provided, a random one will be automatically generated.\n */\n @Prop({ reflect: true })\n readonly inputId: string = uuidv4();\n\n /**\n * Text displayed as label. A slot label can override this prop.\n */\n @Prop({ reflect: true })\n readonly label: string;\n\n /**\n * Description displayed below the input. A slot description can override this prop.\n */\n @Prop({ reflect: true })\n readonly description: string;\n\n /**\n * Placeholder for the input field.\n */\n @Prop({ reflect: true })\n readonly placeholder: string;\n\n /**\n * Name attribute for the input.\n */\n @Prop({ reflect: true })\n readonly name: string;\n\n /**\n * Disables the input field.\n */\n @Prop({ reflect: true })\n readonly disabled: boolean = false;\n\n /**\n * Sets the input field as read-only.\n */\n @Prop({ reflect: true })\n readonly readonly: boolean = false;\n\n /**\n * Marks the input field as required.\n */\n @Prop({ reflect: true })\n readonly required: boolean = false;\n\n /**\n * Indicates an error state.\n */\n @Prop({ reflect: true })\n readonly error: boolean = false;\n\n /**\n * Error description. A slot error-description can override this prop.\n */\n @Prop({ reflect: true })\n readonly errorDescription?: string;\n\n /**\n * Indicates a success state.\n */\n @Prop({ reflect: true })\n readonly success: boolean = false;\n\n /**\n * Autofocus the input when the component is mounted.\n */\n @Prop({ reflect: true })\n // eslint-disable-next-line @stencil-community/reserved-member-names\n readonly autofocus: boolean = false;\n\n /**\n * The initial value of the input (date in string format).\n * @bind value\n */\n // eslint-disable-next-line @stencil-community/own-props-must-be-private\n // eslint-disable-next-line @stencil-community/strict-mutable\n @Prop({ reflect: true, mutable: true })\n value: string = '';\n\n /**\n * The current value of the input date in string format.\n */\n @State()\n singleValue: string = '';\n\n /**\n * The placeholder to display in the input.\n */\n @State()\n currentPlaceholder: string;\n\n /**\n * Controls the opening of the popover.\n */\n @State()\n open: boolean = false;\n\n /**\n * First day of the week 0 = Sunday, 1 = Monday, etc.\n * @default 1\n */\n @Prop({ reflect: true })\n readonly firstDayOfWeek: number = 1;\n\n /**\n * Number of calendars to display\n * @default 1\n */\n @Prop({ reflect: true })\n readonly numberOfCalendars: number = 1;\n\n /**\n * Minimum date for selection ISO string format, ex: 2025-01-01\n */\n @Prop({ reflect: true })\n readonly min?: string = '';\n\n /**\n * Maximum date for selection ISO string format, ex: 2025-12-31\n */\n @Prop({ reflect: true })\n readonly max?: string = '';\n\n /** Locale for date formatting\n * @default 'en-BE'\n */\n @Prop({ reflect: true })\n readonly locale: string = 'en-BE';\n\n /** Date format ex: YYYY-MM-DD, DD-MM-YYYY, etc.\n * @default 'YYYY-MM-DD'\n * @note If the date format is in UTC mode, the date will be displayed in UTC time.\n * @note If the date format is not in UTC mode, the date will be displayed in the local time.\n */\n @Prop({ reflect: true })\n readonly dateFormat: string = 'YYYY-MM-DD';\n\n /**\n * Footer placement\n * @default 'bottom'\n */\n @Prop({ reflect: true })\n readonly shortcutsPlacement: 'bottom' | 'left' | 'right' = 'bottom';\n\n /**\n * Show action buttons\n * @default false\n */\n @Prop({ reflect: true })\n readonly showActions: boolean = false;\n\n /**\n * Custom actions to display in the footer\n */\n @Prop({ reflect: true })\n readonly shortcuts: HTMLNvCalendarElement['shortcuts'];\n\n /**\n * Show week numbers\n * @default true\n */\n @Prop({ reflect: true })\n readonly showWeekNumbers: boolean;\n\n /**\n * Disabled dates ISO string array\n */\n @Prop({ reflect: true })\n readonly disabledDates: Array<string>;\n\n /**\n * Allows the field to stretch and fill the entire width of its container.\n */\n @Prop({ reflect: true })\n readonly fluid: boolean = false;\n\n //#endregion PROPERTIES\n /****************************************************************************/\n //#region METHODS\n\n /**\n * Converts the nv-calendar date format to the format expected by Inputmask.\n * @param {string} format - The date format.\n * @returns {string} Format adapted for Inputmask.\n */\n private convertToInputmaskFormat(format: string): string {\n // If the format is not specified, use the default format\n if (!format) {\n return 'dd/mm/yyyy';\n }\n\n const formatMap = {\n 'DD/MM/YYYY': 'dd/mm/yyyy',\n 'MM/DD/YYYY': 'mm/dd/yyyy',\n 'YYYY-MM-DD': 'yyyy-mm-dd',\n 'DD.MM.YYYY': 'dd.mm.yyyy',\n 'YYYYMMDD': 'yyyymmdd',\n };\n\n return formatMap[format] || 'dd/mm/yyyy';\n }\n\n /**\n * Closes the popover when a click is detected outside the component.\n * @param {MouseEvent} event - The click event.\n */\n private handleClickOutside = (event: MouseEvent) => {\n if (this.open && this.el && !this.el.contains(event.target as Node)) {\n this.open = false;\n }\n };\n\n /**\n * Focuses the input when the input container is clicked.\n * @param {MouseEvent} event - The click event.\n */\n private handleInputContainerClick = (event: MouseEvent) => {\n if (this.readonly || this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n this.inputElement.focus();\n // Select the first characters based on the date format\n const format = this.dateFormat;\n if (format.startsWith('DD') || format.startsWith('MM')) {\n this.inputElement.setSelectionRange(0, 2);\n } else if (format.startsWith('YYYY')) {\n this.inputElement.setSelectionRange(0, 4);\n }\n };\n\n /**\n * Handles the input event on the input element.\n * Updates the singleValue and emits the valueChanged event.\n * @param {Event} event - The input event.\n */\n private handleInput = (event: Event) => {\n if (this.readonly || this.disabled) {\n event.preventDefault();\n return;\n }\n const input = event.target as HTMLInputElement;\n const previousValue = this.value;\n this.singleValue = input.value;\n this.value = input.value;\n // Only emit valueChanged if the value actually changed\n if (previousValue !== input.value) {\n this.valueChanged.emit(input.value);\n }\n };\n\n /**\n * Initializes the input mask.\n */\n private initializeInputMask = () => {\n this.currentPlaceholder = '';\n\n if ((this.inputElement as HTMLInputElementWithInputmask).inputmask) {\n return;\n }\n\n const inputMask = new Inputmask({\n alias: 'datetime',\n inputFormat: this.convertToInputmaskFormat(this.dateFormat),\n placeholder: ' ',\n prefillYear: false,\n clearIncomplete: false,\n showMaskOnHover: false,\n showMaskOnFocus: false,\n clearMaskOnLostFocus: false,\n insertMode: true,\n rightAlign: false,\n oncomplete: function (e) {\n const input = e.target as HTMLInputElement;\n const event = new CustomEvent('input', { bubbles: true });\n input.dispatchEvent(event);\n },\n });\n inputMask.mask(this.inputElement);\n\n // Set the value after applying the mask\n if (this.inputElement.name === this.name && this.singleValue) {\n requestAnimationFrame(() => {\n this.inputElement.value = this.singleValue;\n const event = new CustomEvent('input', { bubbles: true });\n this.inputElement.dispatchEvent(event);\n });\n }\n };\n\n /**\n * Handles keydown events on the input before the mask is initialized.\n * Initializes the mask on the first number input.\n * @param {KeyboardEvent} event - The keyboard event.\n */\n private handleKeydownBeforeMask = (event: KeyboardEvent) => {\n const allowedKeys = [\n 'Backspace',\n 'Delete',\n 'Tab',\n 'ArrowLeft',\n 'ArrowRight',\n 'ArrowUp',\n 'ArrowDown',\n 'Home',\n 'End',\n ];\n\n if (/\\d/.test(event.key)) {\n this.initializeInputMask();\n this.inputElement.removeEventListener(\n 'keydown',\n this.handleKeydownBeforeMask,\n );\n } else if (\n !allowedKeys.includes(event.key) &&\n !event.metaKey &&\n !event.ctrlKey\n ) {\n event.preventDefault();\n }\n };\n\n /**\n * Handles focus events on the input element.\n * @param {FocusEvent} event - The focus event.\n */\n private handleFocus = (event: FocusEvent) => {\n if (this.readonly || this.disabled) {\n event.preventDefault();\n (event.target as HTMLElement).blur();\n return;\n }\n\n if (!(this.inputElement as HTMLInputElementWithInputmask).inputmask) {\n this.inputElement.addEventListener(\n 'keydown',\n this.handleKeydownBeforeMask,\n );\n }\n\n this.open = true;\n };\n\n /**\n * Handles blur events on the input element.\n */\n private handleBlur = () => {\n this.inputElement.removeEventListener(\n 'keydown',\n this.handleKeydownBeforeMask,\n );\n };\n\n /**\n * Prevents the valueChanged event from the calendar from propagating up.\n * @param {CustomEvent} event - The valueChanged event from nv-calendar.\n */\n private handleCalendarValueChanged = (event: CustomEvent) => {\n event.stopPropagation();\n };\n\n /**\n * Sets the reference to the popover element.\n * @param {HTMLNvPopoverElement} el - The popover element.\n */\n private setPopoverRef = (el: HTMLNvPopoverElement) => {\n this.popoverElement = el;\n };\n\n /**\n * Sets the reference to the input element.\n * @param {HTMLInputElement} el - The input element.\n */\n private setInputRef = (el: HTMLInputElement) => {\n this.inputElement = el;\n };\n\n /**\n * Toggles the opening/closing of the popover.\n */\n private toggleCalendar = () => {\n if (this.readonly || this.disabled) {\n return;\n }\n this.open = !this.open;\n };\n\n /**\n * Clears the current selection and resets the field to its initial state.\n * This method can be called programmatically to reset the field.\n */\n @Method()\n async clear(): Promise<void> {\n // Reset internal state\n this.singleValue = '';\n this.value = '';\n\n // Reset the input element value\n if (this.inputElement) {\n this.inputElement.value = '';\n // Remove the input mask and reinitialize if needed\n if ((this.inputElement as HTMLInputElementWithInputmask).inputmask) {\n (this.inputElement as HTMLInputElementWithInputmask).inputmask.remove();\n }\n }\n\n // Emit events to notify about the change\n this.valueChanged.emit('');\n\n // Close the popover if open\n this.open = false;\n }\n\n //#endregion METHODS\n /****************************************************************************/\n //#region LIFECYCLE\n\n connectedCallback() {\n document.addEventListener('click', this.handleClickOutside);\n }\n\n componentWillLoad() {\n if (this.value) {\n this.singleValue = this.value;\n }\n this.currentPlaceholder = this.placeholder || this.dateFormat;\n }\n\n componentDidLoad() {\n // Inputmask is now initialized on the first keypress\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this.handleClickOutside);\n if (\n this.inputElement &&\n (this.inputElement as HTMLInputElementWithInputmask).inputmask\n ) {\n (this.inputElement as HTMLInputElementWithInputmask).inputmask.remove();\n }\n }\n\n //#endregion LIFECYCLE\n /****************************************************************************/\n //#region EVENTS\n\n /**\n * Emitted when the value changes (unified value binding).\n * @bind value\n */\n @Event()\n valueChanged: EventEmitter<string>;\n\n /**\n * Handles the single date selection event from nv-calendar.\n * Updates the input value and closes the popover.\n * @param {CustomEvent} event - The event from nv-calendar.\n */\n @Listen('singleDateChange')\n handleSingleDateChange(event: CustomEvent) {\n const value: string = event.detail;\n const previousValue = this.value;\n this.singleValue = value;\n this.value = value;\n // Only emit valueChanged if the value actually changed\n if (previousValue !== value) {\n this.valueChanged.emit(value);\n }\n if (!this.showActions) {\n this.open = false;\n }\n }\n\n @Listen('closePopover')\n handleClosePopover() {\n this.open = false;\n }\n\n @Listen('keydown', { passive: false })\n handleKeyDown(event: KeyboardEvent) {\n if (!this.open) {\n if (event.key === 'ArrowDown') {\n this.open = true;\n\n event.preventDefault();\n return;\n }\n return;\n }\n\n // Verify if the popover element is defined\n if (!this.popoverElement) {\n console.warn('nv-fielddate -> Popover element is not defined');\n return;\n }\n }\n\n @Watch('value')\n handleValueChange(newValue: string) {\n this.singleValue = newValue;\n }\n\n //#endregion EVENTS\n /****************************************************************************/\n //#region RENDER\n render() {\n return (\n <Host>\n {((this.label && this.label.length > 0) ||\n this.el.querySelector('[slot=\"label\"]')) && (\n <label htmlFor={this.inputId}>\n <slot name=\"label\">{this.label}</slot>\n </label>\n )}\n\n <nv-popover\n ref={this.setPopoverRef}\n id={this.popoverId}\n triggerMode=\"controlled\"\n placement=\"bottom-start\"\n open={this.open}\n >\n <div slot=\"trigger\" class=\"input-wrapper\">\n <slot name=\"before-input\"></slot>\n\n <div\n class=\"input-container\"\n onClick={this.handleInputContainerClick}\n >\n <slot name=\"leading-input\"></slot>\n\n <input\n id={this.inputId}\n ref={this.setInputRef}\n placeholder={this.currentPlaceholder}\n name={this.name}\n disabled={this.disabled}\n readOnly={this.readonly}\n required={this.required}\n autofocus={this.autofocus}\n value={this.singleValue}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n data-scope=\"date\"\n />\n\n {this.error && (\n <nv-icon name=\"alert-circle\" class=\"validation\" size=\"md\" />\n )}\n {this.success && (\n <nv-icon name=\"circle-check\" class=\"validation\" size=\"md\" />\n )}\n\n <nv-iconbutton\n class=\"toggle-calendar-icon\"\n name=\"calendar\" //{this.open ? 'chevron-top' : 'chevron-down'}\n size=\"md\"\n emphasis=\"lower\"\n aria-label={this.open ? 'Hide calendar' : 'Show calendar'}\n aria-pressed={this.open.toString()}\n onClick={this.toggleCalendar}\n tabIndex={this.disabled ? -1 : 0}\n />\n </div>\n\n <slot name=\"after-input\"></slot>\n </div>\n\n <div slot=\"content\">\n <nv-calendar\n dateFormat={this.dateFormat}\n singleValue={this.singleValue}\n firstDayOfWeek={this.firstDayOfWeek}\n numberOfCalendars={this.numberOfCalendars}\n min={this.min}\n max={this.max}\n locale={this.locale}\n shortcutsPlacement={this.shortcutsPlacement}\n showActions={this.showActions}\n shortcuts={this.shortcuts}\n showWeekNumbers={this.showWeekNumbers}\n disabledDates={this.disabledDates}\n onValueChanged={this.handleCalendarValueChanged}\n ></nv-calendar>\n </div>\n </nv-popover>\n\n {((this.description && this.description.length > 0) ||\n this.el.querySelector('[slot=\"description\"]')) && (\n <div class=\"description\">\n <slot name=\"description\">{this.description}</slot>\n </div>\n )}\n\n {(this.errorDescription ||\n this.el.querySelector('[slot=\"error-description\"]')) && (\n <div hidden={!this.error} class=\"error-description\">\n {this.el.querySelector('[slot=\"error-description\"]') ? (\n <slot name=\"error-description\"></slot>\n ) : (\n this.errorDescription\n )}\n </div>\n )}\n\n <slot></slot>\n </Host>\n );\n }\n //#endregion RENDER\n}\n"],"version":3}
|
|
1
|
+
{"file":"nv-fielddate.entry.js","mappings":";;;;;AAAA,MAAM,cAAc,GAAG,4mPAA4mP,CAAC;AACpoP,0BAAe,cAAc;;MC8ChB,WAAW;IALxB;;;QAUU,cAAS,GAAWA,E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AAK,EAAC,aAAa,IACtB,6DAAM,IAAI,EAAC,aAAa,IAAE,IAAI,CAAC,WAAW,CAAQ,CAC9C,CACP,EAEA,CAAC,IAAI,CAAC,gBAAgB;YACrB,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,4BAA4B,CAAC,MACnD,4DAAK,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAC,mBAAmB,IAChD,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,4BAA4B,CAAC,IAClD,YAAM,IAAI,EAAC,mBAAmB,GAAQ,KAEtC,IAAI,CAAC,gBAAgB,CACtB,CACG,CACP,EAED,8DAAa,CACR,EACP;KACH;;;;;;;;;;;","names":["uuidv4"],"sources":["src/components/nv-fielddate/styles/nv-fielddate.scss?tag=nv-fielddate","src/components/nv-fielddate/nv-fielddate.tsx"],"sourcesContent":["@import '../../../styles/form-field';\n\nnv-fielddate {\n @include form-field-variables();\n @include form-field-root();\n\n &[fluid]:not([fluid=\"false\"]) {\n @include form-field-fluid();\n }\n\n &[readonly]:not([readonly='false']) {\n @include form-field-readonly-variables();\n }\n\n &[error]:not([error='false']) {\n @include form-field-error-variables();\n }\n\n &[success]:not([success='false']) {\n @include form-field-success-variables();\n }\n\n &[required]:not([required='false']) label {\n @include form-field-label-required();\n }\n\n label {\n @include form-field-label();\n }\n\n nv-popover {\n width: 100%;\n display: block;\n\n [data-scope='popover'] {\n padding: 0;\n background-color: var(--components-list-dropdown-background);\n border: 1px solid var(--components-list-dropdown-border);\n width: auto;\n }\n\n [slot='content'] {\n display: block;\n width: 100%;\n }\n .datepicker-container {\n border: none\n }\n }\n\n .input-wrapper {\n @include form-field-input-wrapper();\n display: flex;\n align-items: center;\n gap: 8px;\n\n .input-container {\n @include form-field-input-container();\n\n input {\n @include form-field-input();\n font-feature-settings: 'tnum';\n font-family: \"TTNorms Pro Mono\", monospace;\n }\n\n > nv-iconbutton {\n @include form-field-action();\n }\n\n nv-icon.validation {\n @include form-field-icon();\n }\n }\n }\n\n .description {\n @include form-field-description();\n }\n\n .error-description {\n @include form-field-error-description();\n }\n}\n","import {\n Component,\n h,\n Prop,\n State,\n Element,\n Event,\n EventEmitter,\n Listen,\n Host,\n Watch,\n Method,\n} from '@stencil/core';\nimport Inputmask from 'inputmask';\nimport { v4 as uuidv4 } from 'uuid';\n\n/**\n * Extends HTMLInputElement to include the inputmask property.\n */\ninterface HTMLInputElementWithInputmask extends HTMLInputElement {\n /**\n * The inputmask instance that provides masking functionality.\n */\n inputmask?: {\n /**\n * Removes the inputmask instance.\n */\n remove?: () => void;\n };\n}\n\n/**\n * A field date component that combines an input with a calendar popover.\n *\n * @slot default - Child content of the component.\n * @slot leading-input - Content to be placed before the input text, within the input container.\n * @slot before-input - Content to be placed before the input text, outside the input container.\n * @slot after-input - Content to be placed after the input text, outside the input container.\n * @slot label - Content to be placed as the label, will override the label prop.\n * @slot description - Content to be placed as the description, will override the description prop.\n * @slot error-description - Content to be placed as the error description, will override the errorDescription prop.\n */\n@Component({\n tag: 'nv-fielddate',\n styleUrl: 'styles/nv-fielddate.scss',\n shadow: false,\n})\nexport class NvFielddate {\n @Element() el: HTMLNvFielddateElement;\n private inputElement!: HTMLInputElement;\n\n private popoverElement!: HTMLNvPopoverElement;\n private popoverId: string = uuidv4();\n\n /****************************************************************************/\n //#region PROPERTIES\n\n /**\n * Sets the ID for the input element and the for attribute of the associated\n * label. If no ID is provided, a random one will be automatically generated.\n */\n @Prop({ reflect: true })\n readonly inputId: string = uuidv4();\n\n /**\n * Text displayed as label. A slot label can override this prop.\n */\n @Prop({ reflect: true })\n readonly label: string;\n\n /**\n * Description displayed below the input. A slot description can override this prop.\n */\n @Prop({ reflect: true })\n readonly description: string;\n\n /**\n * Placeholder for the input field.\n */\n @Prop({ reflect: true })\n readonly placeholder: string;\n\n /**\n * Name attribute for the input.\n */\n @Prop({ reflect: true })\n readonly name: string;\n\n /**\n * Disables the input field.\n */\n @Prop({ reflect: true })\n readonly disabled: boolean = false;\n\n /**\n * Sets the input field as read-only.\n */\n @Prop({ reflect: true })\n readonly readonly: boolean = false;\n\n /**\n * Marks the input field as required.\n */\n @Prop({ reflect: true })\n readonly required: boolean = false;\n\n /**\n * Indicates an error state.\n */\n @Prop({ reflect: true })\n readonly error: boolean = false;\n\n /**\n * Error description. A slot error-description can override this prop.\n */\n @Prop({ reflect: true })\n readonly errorDescription?: string;\n\n /**\n * Indicates a success state.\n */\n @Prop({ reflect: true })\n readonly success: boolean = false;\n\n /**\n * Autofocus the input when the component is mounted.\n */\n @Prop({ reflect: true })\n // eslint-disable-next-line @stencil-community/reserved-member-names\n readonly autofocus: boolean = false;\n\n /**\n * The initial value of the input (date in string format).\n * @bind value\n */\n @Prop({ reflect: true, mutable: true })\n value: string = '';\n\n /**\n * The current value of the input date in string format.\n */\n @State()\n singleValue: string = '';\n\n /**\n * Controls the opening of the popover.\n */\n @State()\n open: boolean = false;\n\n /**\n * First day of the week 0 = Sunday, 1 = Monday, etc.\n * @default 1\n */\n @Prop({ reflect: true })\n readonly firstDayOfWeek: number = 1;\n\n /**\n * Number of calendars to display\n * @default 1\n */\n @Prop({ reflect: true })\n readonly numberOfCalendars: number = 1;\n\n /**\n * Minimum date for selection ISO string format, ex: 2025-01-01\n */\n @Prop({ reflect: true })\n readonly min?: string = '';\n\n /**\n * Maximum date for selection ISO string format, ex: 2025-12-31\n */\n @Prop({ reflect: true })\n readonly max?: string = '';\n\n /** Locale for date formatting\n * @default 'en-BE'\n */\n @Prop({ reflect: true })\n readonly locale: string = 'en-BE';\n\n /** Date format ex: YYYY-MM-DD, DD-MM-YYYY, etc.\n * @default 'YYYY-MM-DD'\n * @note If the date format is in UTC mode, the date will be displayed in UTC time.\n * @note If the date format is not in UTC mode, the date will be displayed in the local time.\n */\n @Prop({ reflect: true })\n readonly dateFormat: string = 'YYYY-MM-DD';\n\n /**\n * Footer placement\n * @default 'bottom'\n */\n @Prop({ reflect: true })\n readonly shortcutsPlacement: 'bottom' | 'left' | 'right' = 'bottom';\n\n /**\n * Show action buttons\n * @default false\n */\n @Prop({ reflect: true })\n readonly showActions: boolean = false;\n\n /**\n * Custom actions to display in the footer\n */\n @Prop({ reflect: true })\n readonly shortcuts: HTMLNvCalendarElement['shortcuts'];\n\n /**\n * Show week numbers\n * @default true\n */\n @Prop({ reflect: true })\n readonly showWeekNumbers: boolean;\n\n /**\n * Disabled dates ISO string array\n */\n @Prop({ reflect: true })\n readonly disabledDates: Array<string>;\n\n /**\n * Allows the field to stretch and fill the entire width of its container.\n */\n @Prop({ reflect: true })\n readonly fluid: boolean = false;\n\n //#endregion PROPERTIES\n /****************************************************************************/\n //#region METHODS\n\n /**\n * Converts the nv-calendar date format to the format expected by Inputmask.\n * @param {string} format - The date format.\n * @returns {string} Format adapted for Inputmask.\n */\n private convertToInputmaskFormat(format: string): string {\n // If the format is not specified, use the default format\n if (!format) {\n return 'dd/mm/yyyy';\n }\n\n const formatMap = {\n 'DD/MM/YYYY': 'dd/mm/yyyy',\n 'MM/DD/YYYY': 'mm/dd/yyyy',\n 'YYYY-MM-DD': 'yyyy-mm-dd',\n 'DD.MM.YYYY': 'dd.mm.yyyy',\n 'YYYYMMDD': 'yyyymmdd',\n };\n\n return formatMap[format] || 'dd/mm/yyyy';\n }\n\n /**\n * Closes the popover when a click is detected outside the component.\n * @param {MouseEvent} event - The click event.\n */\n private handleClickOutside = (event: MouseEvent) => {\n if (this.open && this.el && !this.el.contains(event.target as Node)) {\n this.open = false;\n }\n };\n\n /**\n * Focuses the input when the input container is clicked.\n * @param {MouseEvent} event - The click event.\n */\n private handleInputContainerClick = (event: MouseEvent) => {\n if (this.readonly || this.disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n this.inputElement.focus();\n };\n\n /**\n * Handles the input event on the input element.\n * Updates the singleValue and emits the valueChanged event if empty.\n * @param {Event} event - The input event.\n */\n private handleInput = (event: Event) => {\n if (this.readonly || this.disabled) {\n event.preventDefault();\n return;\n }\n const input = event.target as HTMLInputElement;\n this.singleValue = input.value;\n this.value = input.value;\n\n if (this.value === '') {\n this.valueChanged.emit('');\n }\n };\n\n /**\n * Handles focus events on the input element.\n * @param {FocusEvent} event - The focus event.\n */\n private handleFocus = (event: FocusEvent) => {\n if (this.readonly || this.disabled) {\n event.preventDefault();\n (event.target as HTMLElement).blur();\n return;\n }\n\n this.open = true;\n };\n\n /**\n * Prevents the valueChanged event from the calendar from propagating up.\n * @param {CustomEvent} event - The valueChanged event from nv-calendar.\n */\n private handleCalendarValueChanged = (event: CustomEvent) => {\n event.stopPropagation();\n };\n\n /**\n * Sets the reference to the popover element.\n * @param {HTMLNvPopoverElement} el - The popover element.\n */\n private setPopoverRef = (el: HTMLNvPopoverElement) => {\n this.popoverElement = el;\n };\n\n /**\n * Sets the reference to the input element.\n * @param {HTMLInputElement} el - The input element.\n */\n private setInputRef = (el: HTMLInputElement) => {\n this.inputElement = el;\n };\n\n /**\n * Toggles the opening/closing of the popover.\n */\n private toggleCalendar = () => {\n if (this.readonly || this.disabled) {\n return;\n }\n this.open = !this.open;\n };\n\n /**\n * Clears the current selection and resets the field to its initial state.\n * This method can be called programmatically to reset the field.\n */\n @Method()\n async clear(): Promise<void> {\n // Reset internal state\n this.singleValue = '';\n this.value = '';\n\n // Reset the input element value\n if (this.inputElement) {\n this.inputElement.value = '';\n // Remove the input mask and reinitialize if needed\n if ((this.inputElement as HTMLInputElementWithInputmask).inputmask) {\n (this.inputElement as HTMLInputElementWithInputmask).inputmask.remove();\n }\n }\n\n // Emit events to notify about the change\n this.valueChanged.emit('');\n\n // Close the popover if open\n this.open = false;\n }\n\n private updateMask() {\n if (!this.inputElement) return;\n (this.inputElement as HTMLInputElementWithInputmask).inputmask?.remove?.();\n\n const inputMask = new Inputmask({\n alias: 'datetime',\n inputFormat: this.convertToInputmaskFormat(this.dateFormat),\n placeholder: this.convertToInputmaskFormat(this.dateFormat),\n clearIncomplete: false,\n showMaskOnHover: false,\n showMaskOnFocus: true,\n clearMaskOnLostFocus: !this.open,\n postValidation: true,\n oncomplete: (e: CustomEvent) => {\n this.valueChanged.emit((e.target as HTMLInputElement)?.value);\n },\n });\n inputMask.mask(this.inputElement);\n }\n\n //#endregion METHODS\n /****************************************************************************/\n //#region LIFECYCLE\n\n connectedCallback() {\n document.addEventListener('click', this.handleClickOutside);\n }\n\n componentWillLoad() {\n if (this.value) {\n this.singleValue = this.value;\n }\n }\n\n componentDidLoad() {\n this.updateMask();\n\n // Set the initial value after applying the mask\n if (this.inputElement.name === this.name && this.singleValue) {\n requestAnimationFrame(() => {\n this.inputElement.value = this.singleValue;\n const event = new CustomEvent('input', { bubbles: true });\n this.inputElement.dispatchEvent(event);\n });\n }\n }\n\n componentDidRender() {\n // Only set value on initial render when there's no existing value in the input\n if (this.singleValue && this.inputElement && !this.inputElement.value) {\n requestAnimationFrame(() => {\n this.inputElement.value = this.singleValue;\n this.inputElement.setAttribute('value', this.singleValue);\n });\n }\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this.handleClickOutside);\n if (\n this.inputElement &&\n (this.inputElement as HTMLInputElementWithInputmask).inputmask\n ) {\n (this.inputElement as HTMLInputElementWithInputmask).inputmask.remove();\n }\n }\n\n //#endregion LIFECYCLE\n /****************************************************************************/\n //#region EVENTS\n\n /**\n * Emitted when the value changes (unified value binding).\n * @bind value\n */\n @Event()\n valueChanged: EventEmitter<string>;\n\n /**\n * Handles the single date selection event from nv-calendar.\n * Updates the input value and closes the popover.\n * @param {CustomEvent} event - The event from nv-calendar.\n */\n @Listen('singleDateChange')\n handleSingleDateChange(event: CustomEvent) {\n const value: string = event.detail;\n const previousValue = this.value;\n this.singleValue = value;\n this.value = value;\n\n // Set the input value directly when calendar is used\n if (this.inputElement) {\n this.inputElement.value = value;\n }\n\n // Only emit valueChanged if the value actually changed\n if (previousValue !== value) {\n this.valueChanged.emit(value);\n }\n if (!this.showActions) {\n this.open = false;\n }\n }\n\n @Listen('closePopover')\n handleClosePopover() {\n this.open = false;\n }\n\n @Listen('keydown', { passive: false })\n handleKeyDown(event: KeyboardEvent) {\n if (!this.open) {\n if (event.key === 'ArrowDown') {\n this.open = true;\n\n event.preventDefault();\n return;\n }\n return;\n }\n\n // Verify if the popover element is defined\n if (!this.popoverElement) {\n console.warn('nv-fielddate -> Popover element is not defined');\n return;\n }\n }\n\n @Watch('value')\n handleValueChange(newValue: string) {\n this.singleValue = newValue;\n // Only set input value if it's different from current input value\n // This prevents interfering with user typing\n if (this.inputElement && this.inputElement.value !== newValue) {\n this.inputElement.value = newValue;\n }\n }\n\n @Watch('open')\n handleOpenChange() {\n this.updateMask();\n }\n\n //#endregion EVENTS\n /****************************************************************************/\n //#region RENDER\n render() {\n return (\n <Host>\n {((this.label && this.label.length > 0) ||\n this.el.querySelector('[slot=\"label\"]')) && (\n <label htmlFor={this.inputId}>\n <slot name=\"label\">{this.label}</slot>\n </label>\n )}\n\n <nv-popover\n ref={this.setPopoverRef}\n id={this.popoverId}\n triggerMode=\"controlled\"\n placement=\"bottom-start\"\n open={this.open}\n >\n <div slot=\"trigger\" class=\"input-wrapper\">\n <slot name=\"before-input\"></slot>\n\n <div\n class=\"input-container\"\n onClick={this.handleInputContainerClick}\n >\n <slot name=\"leading-input\"></slot>\n\n <input\n id={this.inputId}\n ref={this.setInputRef}\n placeholder={\n this.placeholder ||\n this.convertToInputmaskFormat(this.dateFormat)\n }\n name={this.name}\n disabled={this.disabled}\n readOnly={this.readonly}\n required={this.required}\n autofocus={this.autofocus}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n data-scope=\"date\"\n />\n\n {this.error && (\n <nv-icon name=\"alert-circle\" class=\"validation\" size=\"md\" />\n )}\n {this.success && (\n <nv-icon name=\"circle-check\" class=\"validation\" size=\"md\" />\n )}\n\n <nv-iconbutton\n class=\"toggle-calendar-icon\"\n name=\"calendar\" //{this.open ? 'chevron-top' : 'chevron-down'}\n size=\"md\"\n emphasis=\"lower\"\n aria-label={this.open ? 'Hide calendar' : 'Show calendar'}\n aria-pressed={this.open.toString()}\n onClick={this.toggleCalendar}\n tabIndex={this.disabled ? -1 : 0}\n />\n </div>\n\n <slot name=\"after-input\"></slot>\n </div>\n\n <div slot=\"content\">\n <nv-calendar\n dateFormat={this.dateFormat}\n singleValue={this.singleValue}\n firstDayOfWeek={this.firstDayOfWeek}\n numberOfCalendars={this.numberOfCalendars}\n min={this.min}\n max={this.max}\n locale={this.locale}\n shortcutsPlacement={this.shortcutsPlacement}\n showActions={this.showActions}\n shortcuts={this.shortcuts}\n showWeekNumbers={this.showWeekNumbers}\n disabledDates={this.disabledDates}\n onValueChanged={this.handleCalendarValueChanged}\n ></nv-calendar>\n </div>\n </nv-popover>\n\n {((this.description && this.description.length > 0) ||\n this.el.querySelector('[slot=\"description\"]')) && (\n <div class=\"description\">\n <slot name=\"description\">{this.description}</slot>\n </div>\n )}\n\n {(this.errorDescription ||\n this.el.querySelector('[slot=\"error-description\"]')) && (\n <div hidden={!this.error} class=\"error-description\">\n {this.el.querySelector('[slot=\"error-description\"]') ? (\n <slot name=\"error-description\"></slot>\n ) : (\n this.errorDescription\n )}\n </div>\n )}\n\n <slot></slot>\n </Host>\n );\n }\n //#endregion RENDER\n}\n"],"version":3}
|
|
@@ -127,12 +127,6 @@ const NvFielddaterange = class {
|
|
|
127
127
|
this.startValue = values[0];
|
|
128
128
|
this.endValue = values[1];
|
|
129
129
|
}
|
|
130
|
-
else {
|
|
131
|
-
// Handle malformed value gracefully
|
|
132
|
-
console.warn(`Invalid date range format: ${value}`);
|
|
133
|
-
this.startValue = '';
|
|
134
|
-
this.endValue = '';
|
|
135
|
-
}
|
|
136
130
|
};
|
|
137
131
|
/**
|
|
138
132
|
* Closes the popover when a click is detected outside the component.
|
|
@@ -156,9 +150,6 @@ const NvFielddaterange = class {
|
|
|
156
150
|
this.startValue = input.value;
|
|
157
151
|
// Update unified value prop
|
|
158
152
|
this.value = `${input.value},${this.endValue}`;
|
|
159
|
-
this.valueChanged.emit(this.value);
|
|
160
|
-
// Legacy support (deprecated)
|
|
161
|
-
this.dateRangeChange.emit({ start: input.value, end: this.endValue });
|
|
162
153
|
// Temporarily enable navigation for keyboard input
|
|
163
154
|
if (this.calendarElement) {
|
|
164
155
|
this.calendarElement.removeAttribute('data-prevent-navigation');
|
|
@@ -184,9 +175,6 @@ const NvFielddaterange = class {
|
|
|
184
175
|
this.endValue = input.value;
|
|
185
176
|
// Update unified value prop
|
|
186
177
|
this.value = `${this.startValue},${input.value}`;
|
|
187
|
-
this.valueChanged.emit(this.value);
|
|
188
|
-
// Legacy support (deprecated)
|
|
189
|
-
this.dateRangeChange.emit({ start: this.startValue, end: input.value });
|
|
190
178
|
// Temporarily enable navigation for keyboard input
|
|
191
179
|
if (this.calendarElement) {
|
|
192
180
|
this.calendarElement.removeAttribute('data-prevent-navigation');
|
|
@@ -283,6 +271,50 @@ const NvFielddaterange = class {
|
|
|
283
271
|
this.calendarElement.clear();
|
|
284
272
|
}
|
|
285
273
|
}
|
|
274
|
+
updateMask() {
|
|
275
|
+
const inputs = this.el.querySelectorAll('.input-wrapper input');
|
|
276
|
+
inputs.forEach((input) => {
|
|
277
|
+
var _a, _b;
|
|
278
|
+
(_b = (_a = input.inputmask) === null || _a === void 0 ? void 0 : _a.remove) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
279
|
+
const inputMask = new Inputmask({
|
|
280
|
+
alias: 'datetime',
|
|
281
|
+
inputFormat: this.convertToInputmaskFormat(this.dateFormat),
|
|
282
|
+
placeholder: this.convertToInputmaskFormat(this.dateFormat),
|
|
283
|
+
clearIncomplete: false,
|
|
284
|
+
showMaskOnHover: false,
|
|
285
|
+
showMaskOnFocus: true,
|
|
286
|
+
clearMaskOnLostFocus: !this.open,
|
|
287
|
+
postValidation: true,
|
|
288
|
+
oncleared: (e) => {
|
|
289
|
+
const input = e.target;
|
|
290
|
+
if (input.id === this.startInputId) {
|
|
291
|
+
this.startValue = '';
|
|
292
|
+
}
|
|
293
|
+
if (input.id === this.endInputId) {
|
|
294
|
+
this.endValue = '';
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
oncomplete: () => {
|
|
298
|
+
if (/[a-zA-Z]/g.test(this.value))
|
|
299
|
+
return;
|
|
300
|
+
const values = this.value
|
|
301
|
+
.split(',')
|
|
302
|
+
.map(v => v.trim())
|
|
303
|
+
.filter(Boolean);
|
|
304
|
+
if (values.length < 2)
|
|
305
|
+
return;
|
|
306
|
+
// If valid emit change event
|
|
307
|
+
this.valueChanged.emit(this.value);
|
|
308
|
+
// Legacy support (deprecated)
|
|
309
|
+
this.dateRangeChange.emit({
|
|
310
|
+
start: this.startValue,
|
|
311
|
+
end: input.value,
|
|
312
|
+
});
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
inputMask.mask(input);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
286
318
|
//#endregion METHODS
|
|
287
319
|
/****************************************************************************/
|
|
288
320
|
//#region LIFECYCLE
|
|
@@ -296,25 +328,9 @@ const NvFielddaterange = class {
|
|
|
296
328
|
}
|
|
297
329
|
}
|
|
298
330
|
componentDidLoad() {
|
|
331
|
+
this.updateMask();
|
|
299
332
|
const inputs = this.el.querySelectorAll('.input-wrapper input');
|
|
300
333
|
inputs.forEach((input) => {
|
|
301
|
-
const inputMask = new Inputmask({
|
|
302
|
-
alias: 'datetime',
|
|
303
|
-
inputFormat: this.convertToInputmaskFormat(this.dateFormat),
|
|
304
|
-
placeholder: this.convertToInputmaskFormat(this.dateFormat),
|
|
305
|
-
clearIncomplete: false,
|
|
306
|
-
showMaskOnHover: false,
|
|
307
|
-
showMaskOnFocus: false,
|
|
308
|
-
clearMaskOnLostFocus: false,
|
|
309
|
-
insertMode: true,
|
|
310
|
-
rightAlign: false,
|
|
311
|
-
oncomplete: function (e) {
|
|
312
|
-
const input = e.target;
|
|
313
|
-
const event = new CustomEvent('input', { bubbles: true });
|
|
314
|
-
input.dispatchEvent(event);
|
|
315
|
-
},
|
|
316
|
-
});
|
|
317
|
-
inputMask.mask(input);
|
|
318
334
|
// Set the value after applying the mask
|
|
319
335
|
if (input.name === this.startName && this.startValue) {
|
|
320
336
|
requestAnimationFrame(() => {
|
|
@@ -446,6 +462,7 @@ const NvFielddaterange = class {
|
|
|
446
462
|
this.parseUnifiedValue(newValue);
|
|
447
463
|
}
|
|
448
464
|
onOpenChanged(newValue) {
|
|
465
|
+
this.updateMask();
|
|
449
466
|
if (this.contentRef) {
|
|
450
467
|
if (newValue) {
|
|
451
468
|
this.contentRef.style.transition = 'none';
|
|
@@ -471,10 +488,12 @@ const NvFielddaterange = class {
|
|
|
471
488
|
/****************************************************************************/
|
|
472
489
|
//#region RENDER
|
|
473
490
|
render() {
|
|
474
|
-
return (h(Host, { key: '
|
|
475
|
-
this.el.querySelector('[slot="label"]')) && (h("label", { key: '
|
|
476
|
-
|
|
477
|
-
|
|
491
|
+
return (h(Host, { key: '2f100d067fa3ca5917252ac2ce921eecac98791e' }, ((this.label && this.label.length > 0) ||
|
|
492
|
+
this.el.querySelector('[slot="label"]')) && (h("label", { key: 'd427e5fd307896971a798a61461a5545af107d95', htmlFor: this.startInputId }, h("slot", { key: 'b6735f19e0fa53528e0c088ee81eb54f7076a8b5', name: "label" }, this.label))), h("nv-popover", { key: '069225a1606c105b9370f6eb0b5268fbf3fc5d96', ref: el => (this.popoverElement = el), id: this.popoverId, triggerMode: "controlled", placement: "bottom-start", open: this.open }, h("div", { key: 'ec43cbd1c063f2e8c4de3e765b776982da607fbe', slot: "trigger", class: "input-wrapper" }, h("slot", { key: '6d6dc2263764bdd53674d9b62eb04904ceecf428', name: "before-input" }), h("div", { key: 'd465d4a360baf008977e9f9c23058980c7357668', class: "input-container" }, h("slot", { key: '52463fb16a84025f910ab5d34ad5f95e575a3999', name: "leading-input" }), h("div", { key: 'a432151dabdf6976f463d794b24b85cb7c784d3f', class: "range-inputs" }, h("input", { key: '98e48271dce40353ba577aedc1daca8398f9526a', id: this.startInputId, type: "text", placeholder: this.startPlaceholder ||
|
|
493
|
+
this.convertToInputmaskFormat(this.dateFormat), 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" }), h("div", { key: 'daddef3bb169bcdf4baf4d5dd7c727d7fa66dd0f', class: "range-separator" }), h("input", { key: 'c498d3b8a82372606d315a3102ada5763bc4791e', id: this.endInputId, type: "text", placeholder: this.endPlaceholder ||
|
|
494
|
+
this.convertToInputmaskFormat(this.dateFormat), 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 && (h("nv-icon", { key: 'c83a0f241b7eb2407117a5eb52caa1bee955c764', name: "alert-circle", class: "validation", size: "md" })), this.success && (h("nv-icon", { key: 'a96c7cd55a903e38f10453fe6bbea0f828573367', name: "circle-check", class: "validation", size: "md" })), h("nv-iconbutton", { key: '39b92aa357457f0be9264335173f8335fdd84b26', 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 })), h("slot", { key: 'b739f98ecb80e73fd84b557a0165438beb3f16bd', name: "after-input" })), h("div", { key: '503406610a224a2b0173fcf6117b1b3a45d3d44d', slot: "content" }, h("nv-calendar", { key: 'ac97339bef8aa214da1317601a31af2c2555acaa', ref: el => (this.calendarElement = el), dateFormat: this.dateFormat, value: this.value, 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) ||
|
|
495
|
+
this.el.querySelector('[slot="description"]')) && (h("div", { key: '302bf932d36f484db34d7c94206697fb469faadc', class: "description" }, h("slot", { key: '133e4c69264dbb856f42dee40fbdfe2286caf87d', name: "description" }, this.description))), (this.errorDescription ||
|
|
496
|
+
this.el.querySelector('[slot="error-description"]')) && (h("div", { key: '2cc57d57cb18cc7ac89135f5e128ffa9ee5487bc', hidden: !this.error, class: "error-description" }, this.el.querySelector('[slot="error-description"]') ? (h("slot", { name: "error-description" })) : (this.errorDescription))), h("slot", { key: '3ef1b28e2bd3879c33faefd20af8cf33360af56c' })));
|
|
478
497
|
}
|
|
479
498
|
get el() { return getElement(this); }
|
|
480
499
|
static get watchers() { return {
|