@nova-design-system/nova-react 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/cjs/{index-E_eTmclZ.js → index-Cv7U-U85.js} +292 -241
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{nv-accordion-item.entry-B9iMQoRk.js → nv-accordion-item.entry-BgDBJjHO.js} +3 -3
- package/dist/cjs/{nv-accordion.entry-2oOEkDVq.js → nv-accordion.entry-1dHBq_qo.js} +17 -44
- package/dist/cjs/{nv-alert.entry-CJcHACkm.js → nv-alert.entry-6J-BEBxl.js} +1 -1
- package/dist/cjs/{nv-avatar.entry-COkIaFDp.js → nv-avatar.entry-Lav6aVEw.js} +1 -1
- package/dist/cjs/{nv-badge_2.entry-CQHT-nck.js → nv-badge_2.entry-DaAOJgy_.js} +2 -2
- package/dist/cjs/{nv-breadcrumb.entry-DElOQJUD.js → nv-breadcrumb.entry-BKoLlkWC.js} +1 -1
- package/dist/cjs/{nv-breadcrumbs.entry-CDfxiMbp.js → nv-breadcrumbs.entry-BdGgzdxC.js} +1 -1
- package/dist/cjs/{nv-button.entry-CTJT4SzB.js → nv-button.entry-Pe2qJFy0.js} +1 -1
- package/dist/cjs/{nv-calendar.entry-BU2OBf6g.js → nv-calendar.entry-WRFrbZtz.js} +97 -76
- package/dist/cjs/{nv-col.entry-Bsz14pxY.js → nv-col.entry-C3IgKfxS.js} +1 -1
- package/dist/cjs/{nv-datagrid.entry-2DyB7G5f.js → nv-datagrid.entry-Bh1mgk8D.js} +1 -1
- package/dist/cjs/{nv-datagridcolumn.entry-DquF2Cc1.js → nv-datagridcolumn.entry-DopvtY6C.js} +1 -1
- package/dist/cjs/{nv-dialog.entry-QzImh4AV.js → nv-dialog.entry-D8oF5B-9.js} +1 -1
- package/dist/cjs/{nv-dialogfooter_2.entry-MikGtnGi.js → nv-dialogfooter_2.entry-QE1dFuOh.js} +1 -1
- package/dist/cjs/{nv-fieldcheckbox.entry-DKhH58rn.js → nv-fieldcheckbox.entry-BbC0JUWc.js} +5 -5
- package/dist/cjs/{nv-fielddate.entry-Dj_oMJ2a.js → nv-fielddate.entry-BIuQgdYW.js} +27 -6
- package/dist/cjs/{nv-fielddaterange.entry-CWwH83ug.js → nv-fielddaterange.entry-C82h1WUR.js} +33 -5
- package/dist/cjs/{nv-fielddropdown.entry-CPD-1tGj.js → nv-fielddropdown.entry-CWqg8M3_.js} +4 -4
- package/dist/cjs/{nv-fielddropdownitem.entry-CM5Fogll.js → nv-fielddropdownitem.entry-KuL1iVS4.js} +2 -2
- package/dist/cjs/{nv-fieldmultiselect.entry-DodoLrhv.js → nv-fieldmultiselect.entry-CAdWlUw2.js} +15 -7
- package/dist/cjs/{nv-fieldnumber.entry-063nS6p_.js → nv-fieldnumber.entry-Bbk2wO5k.js} +4 -4
- package/dist/cjs/{nv-fieldpassword.entry-CreA_Yx8.js → nv-fieldpassword.entry-BOtLqrGx.js} +4 -4
- package/dist/cjs/{nv-fieldradio.entry-Y8YSlQbK.js → nv-fieldradio.entry-CY4txacC.js} +4 -4
- package/dist/cjs/{nv-fieldselect.entry-B1X8kT8-.js → nv-fieldselect.entry-CRP6e7uq.js} +6 -6
- package/dist/cjs/{nv-fieldslider.entry-CJlQWgFy.js → nv-fieldslider.entry-BLO9yOcu.js} +4 -4
- package/dist/cjs/{nv-fieldtext.entry-Cib7Q9Wi.js → nv-fieldtext.entry-BqgV8SxD.js} +4 -4
- package/dist/cjs/{nv-fieldtextarea.entry-QYIEAbAM.js → nv-fieldtextarea.entry-dDaXddme.js} +4 -4
- package/dist/cjs/{nv-fieldtime.entry-D6jX_bbE.js → nv-fieldtime.entry-DAIYFHO7.js} +11 -11
- package/dist/cjs/{nv-icon.entry-DyYPxO1l.js → nv-icon.entry-CxE0uTUN.js} +2 -2
- package/dist/cjs/{nv-iconbutton_2.entry-BDpYysUa.js → nv-iconbutton_2.entry-DAWQjqvb.js} +3 -3
- package/dist/cjs/{nv-menu.entry-EY6i9-lW.js → nv-menu.entry-Fg1jfAeH.js} +2 -2
- package/dist/cjs/{nv-menuitem.entry-D3_V7wz6.js → nv-menuitem.entry-CGg4iJrd.js} +2 -2
- package/dist/cjs/{nv-popover.entry-VI0JSWEK.js → nv-popover.entry-DsKxPxfa.js} +2 -2
- package/dist/cjs/{nv-row.entry-Da5sYAGY.js → nv-row.entry-BsPFwLLA.js} +2 -2
- package/dist/cjs/{nv-stack.entry-CQ8A3wKB.js → nv-stack.entry-4Ec3nJml.js} +2 -2
- package/dist/cjs/{nv-table.entry-DkALs4J_.js → nv-table.entry-Bv0iDqou.js} +3 -3
- package/dist/cjs/{nv-tablecolumn.entry-C_9y9_Tk.js → nv-tablecolumn.entry-XJJCmUC2.js} +1 -1
- package/dist/cjs/{nv-toggle.entry-CPvuKc2f.js → nv-toggle.entry-C72c_569.js} +3 -3
- package/dist/cjs/{nv-tooltip.entry-dvTSw6dq.js → nv-tooltip.entry-BNvm30iV.js} +2 -2
- package/dist/generated/components.js +1 -1
- package/dist/generated/components.server.js +2 -5
- package/dist/types/generated/components.d.ts +1 -1
- package/dist/types/generated/components.server.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
package/dist/cjs/{nv-accordion-item.entry-B9iMQoRk.js → nv-accordion-item.entry-BgDBJjHO.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Cv7U-U85.js');
|
|
4
4
|
var collapse_animation16e3af45 = require('./collapse.animation-16e3af45-CChx_tQJ.js');
|
|
5
5
|
require('./stylefire.es-74da334a-y0piPjlz.js');
|
|
6
6
|
require('react');
|
|
@@ -161,12 +161,12 @@ const NvAccordionItem = class {
|
|
|
161
161
|
/****************************************************************************/
|
|
162
162
|
//#region RENDER
|
|
163
163
|
render() {
|
|
164
|
-
return (index.h(index.Host, { key: '
|
|
164
|
+
return (index.h(index.Host, { key: 'dfb8ca76f8ac40c938323be1ccba4353ea33a616', class: {
|
|
165
165
|
'nv-accordion-item': true,
|
|
166
166
|
'is-open': this.open,
|
|
167
167
|
'is-disabled': this.disabled,
|
|
168
168
|
'is-animating': this.isAnimating,
|
|
169
|
-
}, role: "listitem", "aria-expanded": this.open ? 'true' : 'false', "aria-disabled": this.disabled ? 'true' : 'false' }, index.h("div", { key: '
|
|
169
|
+
}, role: "listitem", "aria-expanded": this.open ? 'true' : 'false', "aria-disabled": this.disabled ? 'true' : 'false' }, index.h("div", { key: '258efe0502a39d963a9e75c16285ee9cbc65cb9f', class: "nv-accordion-item__header", onClick: this.handleHeaderClick, "aria-controls": "content" }, index.h("slot", { key: 'bb4dae743f06e3d41d1f7b8c17793b668df9347b', name: "header" }, index.h("div", { key: 'f3142a81c6be776d95ab9292101b889db6e35805', class: "nv-accordion-item__header-content" }, this.itemTitle && (index.h("span", { key: 'e897d8b4d414ba4e93b2853c152059579063335e', class: "nv-accordion-item__title" }, this.itemTitle)), this.subtitle && (index.h("span", { key: 'b8e03ceb1ca0e4c0b0fe24398f0e1c592ac077ab', class: "nv-accordion-item__subtitle" }, this.subtitle)))), index.h("nv-iconbutton", { key: '8d90711a96f5ce2e7d6f5ebcf3922cd0fedd69bd', emphasis: "low", size: "sm", shape: "square", name: this.chevronIconName, tabindex: this.disabled ? -1 : 0, onClick: this.handleIconClick, onKeyDown: this.handleHeaderKeyDown, "aria-expanded": this.open ? 'true' : 'false', "aria-controls": "content", "aria-label": this.open ? 'Fermer la section' : 'Ouvrir la section' })), index.h("div", { key: '171b5165f3663fa5f0fa28ef84145dfc998e9f10', id: "content", class: "nv-accordion-item__content", "aria-hidden": !this.open ? 'true' : 'false', ref: el => (this.contentRef = el) }, index.h("div", { key: 'dcf753f23cec073a036d8137f1299dcf4ca4af78', class: "nv-accordion-item__content-inner" }, index.h("slot", { key: '3dc85def21aace19f3d211262b6cf66ccb9438fa', name: "content" })))));
|
|
170
170
|
}
|
|
171
171
|
get el() { return index.getElement(this); }
|
|
172
172
|
static get watchers() { return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Cv7U-U85.js');
|
|
4
4
|
require('react');
|
|
5
5
|
|
|
6
6
|
const nvAccordionCss = "nv-accordion{display:block;border:var(--spacing-px) solid var(--color-content-low-border);border-radius:var(--radius-rounded-lg)}nv-accordion .nv-accordion__footer{padding:var(--spacing-3);background:var(--color-level-05-background);border-radius:0 0 var(--radius-rounded-lg) var(--radius-rounded-lg);margin-top:calc(var(--spacing-px) * -1);border-top:var(--spacing-px) solid var(--color-content-low-border)}nv-accordion .nv-accordion__footer:empty{display:none}";
|
|
@@ -9,7 +9,13 @@ const NvAccordionStyle0 = nvAccordionCss;
|
|
|
9
9
|
const NvAccordion = class {
|
|
10
10
|
constructor(hostRef) {
|
|
11
11
|
index.registerInstance(this, hostRef);
|
|
12
|
-
this.
|
|
12
|
+
this.openChanged = index.createEvent(this, "openChanged");
|
|
13
|
+
/****************************************************************************/
|
|
14
|
+
//#region PROPERTIES
|
|
15
|
+
/**
|
|
16
|
+
* Data to display as a list of items (title, subtitle, content).
|
|
17
|
+
*/
|
|
18
|
+
this.data = [];
|
|
13
19
|
/**
|
|
14
20
|
* Expansion mode: 'accordion' (single open) or 'multi' (multiple open)
|
|
15
21
|
*/
|
|
@@ -21,12 +27,6 @@ const NvAccordion = class {
|
|
|
21
27
|
* Internal index of open items (not exposed)
|
|
22
28
|
*/
|
|
23
29
|
this.internalOpenIndexes = [];
|
|
24
|
-
/**
|
|
25
|
-
* Parsed data from data prop
|
|
26
|
-
*/
|
|
27
|
-
this.parsedData = [];
|
|
28
|
-
// Synchronization openIndexes <-> internalOpenIndexes
|
|
29
|
-
this.itemToggleHandlers = [];
|
|
30
30
|
}
|
|
31
31
|
//#endregion EVENTS
|
|
32
32
|
/****************************************************************************/
|
|
@@ -67,7 +67,7 @@ const NvAccordion = class {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
this.internalOpenIndexes = openIndexes;
|
|
70
|
-
this.
|
|
70
|
+
this.openChanged.emit({ openIndexes });
|
|
71
71
|
if (this.openIndexes !== undefined) {
|
|
72
72
|
this.openIndexes =
|
|
73
73
|
this.mode === 'accordion'
|
|
@@ -89,9 +89,6 @@ const NvAccordion = class {
|
|
|
89
89
|
* @param {CustomEvent<boolean>} event Event emitted by nv-accordion-item
|
|
90
90
|
*/
|
|
91
91
|
onItemToggle(event) {
|
|
92
|
-
// Ignore if using data (handled by itemToggleHandlers)
|
|
93
|
-
if (this.parsedData && this.parsedData.length > 0)
|
|
94
|
-
return;
|
|
95
92
|
// Find the index of the item that emitted the event
|
|
96
93
|
const items = Array.from(this.el.querySelectorAll('nv-accordion-item'));
|
|
97
94
|
const targetItem = event.target;
|
|
@@ -119,8 +116,8 @@ const NvAccordion = class {
|
|
|
119
116
|
// If the item is closing, remove it from internalOpenIndexes
|
|
120
117
|
this.internalOpenIndexes = this.internalOpenIndexes.filter(i => i !== index);
|
|
121
118
|
}
|
|
122
|
-
// Emit
|
|
123
|
-
this.
|
|
119
|
+
// Emit openChanged event
|
|
120
|
+
this.openChanged.emit({ openIndexes: this.internalOpenIndexes });
|
|
124
121
|
if (this.openIndexes !== undefined) {
|
|
125
122
|
this.openIndexes =
|
|
126
123
|
this.mode === 'accordion'
|
|
@@ -132,35 +129,17 @@ const NvAccordion = class {
|
|
|
132
129
|
//#endregion METHODS
|
|
133
130
|
/****************************************************************************/
|
|
134
131
|
//#region WATCHERS
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
parseData() {
|
|
139
|
-
if (typeof this.data === 'string') {
|
|
140
|
-
try {
|
|
141
|
-
this.parsedData = JSON.parse(this.data);
|
|
142
|
-
}
|
|
143
|
-
catch (e) {
|
|
144
|
-
console.error('nv-accordion: Failed to parse data prop.', e);
|
|
145
|
-
this.parsedData = [];
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
this.parsedData = this.data || [];
|
|
150
|
-
}
|
|
151
|
-
if (this.parsedData) {
|
|
152
|
-
this.itemToggleHandlers = this.parsedData.map((_, i) => () => this.toggleItem(i));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
132
|
+
//#endregion WATCHERS
|
|
133
|
+
/****************************************************************************/
|
|
134
|
+
//#region LIFECYCLE
|
|
155
135
|
componentWillLoad() {
|
|
156
|
-
this.parseData();
|
|
157
136
|
if (this.openIndexes !== undefined) {
|
|
158
137
|
this.internalOpenIndexes = [...this.openIndexes];
|
|
159
138
|
}
|
|
160
139
|
}
|
|
161
140
|
componentDidLoad() {
|
|
162
141
|
// If using direct child elements, initialize their state
|
|
163
|
-
if (!this.
|
|
142
|
+
if (!this.data || this.data.length === 0) {
|
|
164
143
|
this.updateChildrenState();
|
|
165
144
|
}
|
|
166
145
|
}
|
|
@@ -169,22 +148,16 @@ const NvAccordion = class {
|
|
|
169
148
|
this.internalOpenIndexes = [...this.openIndexes];
|
|
170
149
|
}
|
|
171
150
|
}
|
|
172
|
-
//#endregion WATCHERS
|
|
173
|
-
/****************************************************************************/
|
|
174
|
-
//#region LIFECYCLE
|
|
175
151
|
//#endregion LIFECYCLE
|
|
176
152
|
/****************************************************************************/
|
|
177
153
|
//#region RENDER
|
|
178
154
|
render() {
|
|
179
|
-
return (index.h(index.Host, { key: '
|
|
155
|
+
return (index.h(index.Host, { key: 'a6cb21b274024a00e60e0d0db780f25fab6e5bc2', role: "list", class: "nv-accordion" }, this.data && this.data.length > 0 ? (this.data.map((item, i) => {
|
|
180
156
|
var _a;
|
|
181
|
-
return (index.h("nv-accordion-item", { key: (_a = item.id) !== null && _a !== void 0 ? _a : i,
|
|
157
|
+
return (index.h("nv-accordion-item", { key: (_a = item.id) !== null && _a !== void 0 ? _a : i, itemTitle: item.title, disabled: item.disabled, open: (this.internalOpenIndexes || []).includes(i) }, item.subtitle ? (index.h("div", { slot: "header" }, index.h("div", { class: "nv-accordion-item__header-content" }, index.h("span", { class: "nv-accordion-item__title" }, item.title), index.h("span", { class: "nv-accordion-item__subtitle" }, item.subtitle)))) : null, index.h("div", { slot: "content" }, item.content), item.footer && index.h("div", { slot: "footer" }, item.footer)));
|
|
182
158
|
})) : (index.h("slot", null))));
|
|
183
159
|
}
|
|
184
160
|
get el() { return index.getElement(this); }
|
|
185
|
-
static get watchers() { return {
|
|
186
|
-
"data": ["dataChanged"]
|
|
187
|
-
}; }
|
|
188
161
|
};
|
|
189
162
|
NvAccordion.style = NvAccordionStyle0;
|
|
190
163
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Cv7U-U85.js');
|
|
4
4
|
var clsx297c1ffe = require('./clsx-297c1ffe-BtxeOLZW.js');
|
|
5
5
|
var constants4faa1fae = require('./constants-4faa1fae-BzFAKCkR.js');
|
|
6
6
|
var collapse_animation16e3af45 = require('./collapse.animation-16e3af45-CChx_tQJ.js');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Cv7U-U85.js');
|
|
4
4
|
var clsx297c1ffe = require('./clsx-297c1ffe-BtxeOLZW.js');
|
|
5
5
|
var collapse_animation16e3af45 = require('./collapse.animation-16e3af45-CChx_tQJ.js');
|
|
6
6
|
var fade_animation71e8e34c = require('./fade.animation-71e8e34c-BAw_TYsB.js');
|
|
@@ -196,7 +196,7 @@ const NvFielddropdownitemcheck = class {
|
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
render() {
|
|
199
|
-
return (index.h(index.Host, { key: '
|
|
199
|
+
return (index.h(index.Host, { key: '82abe79dd061f60e380f033027f799121769f89e', onClick: this.handleClick }, index.h("nv-fieldcheckbox", { key: '505181c56faacb09e55c428d91287d96e1c3b72a', checked: this.checked, name: this.label || this.value, label: this.label || this.value, "label-placement": "after", description: this.description, disabled: this.disabled, tabindex: "-1", role: "option", onCheckedChanged: this.onFieldcheckboxChanged }, index.h("slot", { key: '95a53b7d4ec735fd3256505b57e2a497b475f511' }), index.h("slot", { key: '137d5e2b3046417bbc90c0bd2dd10b846d1dfd53', name: "main" }), index.h("slot", { key: '47d4a73e401186b7bc7a18aaad82018f0ccc1e2f', name: "label" }), index.h("slot", { key: 'ff5c752d386c282635a97ad2bcb8858571aff7e9', name: "description" }))));
|
|
200
200
|
}
|
|
201
201
|
get el() { return index.getElement(this); }
|
|
202
202
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Cv7U-U85.js');
|
|
4
4
|
require('react');
|
|
5
5
|
|
|
6
6
|
const nvBreadcrumbsCss = "nv-breadcrumbs{display:block}nv-breadcrumbs>ol{display:flex;flex-wrap:wrap;align-items:center;gap:var(--breadcrumb-padding-y)}nv-breadcrumbs nv-breadcrumb:last-child [data-scope=separator],nv-breadcrumbs nv-breadcrumb:last-child [slot=separator]{display:none}";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Cv7U-U85.js');
|
|
4
4
|
var constants4faa1fae = require('./constants-4faa1fae-BzFAKCkR.js');
|
|
5
5
|
var _commonjsHelpers1789f0cf = require('./_commonjsHelpers-1789f0cf-BJu3ubxk.js');
|
|
6
6
|
require('react');
|
|
@@ -396,6 +396,9 @@ const CalendarGrid = props => {
|
|
|
396
396
|
return (index.h("div", { class: "days-container" },
|
|
397
397
|
index.h("div", { class: "days-header" }, dayNames.map((day, index$1) => (index.h("div", { class: "day-header", key: `day-header-${index$1}` }, day)))),
|
|
398
398
|
index.h("div", { class: "days-grid" }, days.map(day => {
|
|
399
|
+
if (day.isBlank) {
|
|
400
|
+
return index.h("div", { class: "day day-blank" });
|
|
401
|
+
}
|
|
399
402
|
const date = day.date;
|
|
400
403
|
if (!date || !day.dayOfMonth) {
|
|
401
404
|
return index.h("div", { class: "day-cell is-disabled is-empty" });
|
|
@@ -410,7 +413,7 @@ const CalendarGrid = props => {
|
|
|
410
413
|
}))));
|
|
411
414
|
};
|
|
412
415
|
|
|
413
|
-
const nvCalendarCss = "nv-calendar{display:block}.datepicker-root{display:flex;justify-content:center;align-items:flex-start;width:auto}.datepicker-container{font-family:system-ui, sans-serif;display:flex;flex-direction:column;align-items:stretch;background:var(--components-calendar-background);border-radius:var(--calendar-radius);padding:var(--calendar-padding);box-shadow:0px var(--shadow-y-axis-md-1) var(--shadow-blur-md-1) var(--shadow-spread-md, 0) var(--shadow-color-opacity-0), 0px var(--shadow-y-axis-md-2) var(--shadow-blur-md-2) var(--shadow-spread-md, 0) var(--shadow-color-opacity-2);border:1px solid var(--components-calendar-border);width:auto;max-width:100%}.datepicker-container-single{max-width:300px}.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-left),.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-container-single:has(.shortcuts-placement-left),.datepicker-container-single:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-wrapper{display:flex;justify-content:center;align-items:flex-start;gap:var(--calendar-gap-x);width:auto;overflow-x:hidden}.datepicker-wrapper::-webkit-scrollbar{width:6px;height:6px}.datepicker-wrapper::-webkit-scrollbar-track{background-color:var(--color-level-10-background);border-radius:9999px}.datepicker-wrapper::-webkit-scrollbar-thumb{background-color:var(--color-gray-200);border-radius:9999px}.datepicker-wrapper.single{justify-content:center}.calendar-container{display:flex;flex-direction:column;align-items:center;padding:var(--calendar-padding);width:auto;position:relative}.calendar-separator{width:1px;background:var(--components-calendar-border);height:auto;min-height:100%;margin:0 10px}.header{display:flex;justify-content:start;align-items:center;margin-bottom:var(--calendar-header-margin-bottom);width:100%}.header nv-iconbutton{width:var(--calendar-header-button-size);height:var(--calendar-header-button-size)}.nav-buttons{display:flex;gap:var(--spacing-0);margin-left:auto}.nav-left{order:-1}.date-controls{display:flex;gap:var(--spacing-1);align-items:center;min-height:34px;justify-content:center}.datepicker-container-single .date-controls{justify-content:flex-start}.datepicker-container:not(.datepicker-container-single) .date-controls{justify-content:start;flex-grow:1}.date-controls .month-select,.date-controls .year-input{background:transparent !important}.calendar-wrapper:nth-child(n+2) .datepicker-container{margin-left:42px}.calendar-grid{display:grid;grid-template-columns:auto 1fr;column-gap:var(--calendar-weeks-calendar-gap-x);position:relative}.calendar-grid.slide-left{animation:slideLeft 0.3s ease-out}.calendar-grid.slide-right{animation:slideRight 0.3s ease-out}.week-numbers{display:grid;grid-template-rows:var(--calendar-cell-size) repeat(6, var(--calendar-cell-size));background:var(--components-calendar-weeks-background);color:var(--components-calendar-weeks-text);border-radius:var(--calendar-weeks-radius);width:var(--calendar-weeks-size);row-gap:var(--calendar-grid-gap-y)}.week-numbers .clickable{cursor:pointer}.week-numbers .clickable:hover{background-color:var(--components-calendar-weeks-background-hover);color:var(--components-calendar-weeks-text-hover);border-radius:var(--calendar-radius)}.week-header,.week-number{display:grid;place-items:center;font-size:var(--calendar-cell-font-size)}.week-header{font-weight:700;color:var(--components-calendar-weeks-text)}.week-number{color:var(--components-calendar-cell-text)}.days-container{display:grid;grid-template-rows:auto 1fr;row-gap:var(--calendar-grid-gap-y)}.days-header{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));height:var(--calendar-cell-size)}.day-header{display:grid;place-items:center;font-size:var(--calendar-cell-font-size);color:var(--components-calendar-cell-text)}.days-grid{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));grid-template-rows:repeat(6, var(--calendar-cell-size));animation:fadeIn 0.2s ease-in;row-gap:var(--calendar-grid-gap-y);z-index:0}.day{display:grid;place-items:center;width:var(--calendar-cell-size);height:var(--calendar-cell-size);font-size:var(--calendar-cell-font-size);border-radius:var(--calendar-cell-radius);cursor:pointer;border:none;background:transparent;transition:all 0.2s ease;text-align:center;animation:scaleIn 0.2s ease-out}.day:hover:not(.disabled,.empty,.selected){background:var(--components-calendar-cell-background-hover);color:var(--components-calendar-cell-text-hover)}.day.selected,.day.selected:hover .day.is-today.selected,.day.is-today.selected:hover{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected) !important}.day.disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.day.is-empty{pointer-events:none;background-color:transparent;border-color:transparent}.day.outside-month{color:var(--components-calendar-cell-text);opacity:var(--opacity-disabled)}.day.outside-month.selected{opacity:1 !important;color:var(--components-calendar-cell-text-selected)}.day.outside-month.in-range{opacity:0.5 !important;background-color:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range)}.day.outside-month.in-range:hover{opacity:0.7 !important;background-color:var(--components-calendar-cell-background-in-range)}.day.in-range{background:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range);border-radius:0;position:relative}.day.range-start,.day.range-start:focus,.day.range-start:hover,.day.range-end,.day.range-end:focus,.day.range-end:hover{background-color:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected) !important}.day.range-start,.day.range-end,.day.range-start.is-today,.day.range-end.is-today{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected);position:relative;border-radius:var(--radius-rounded-full)}.day.range-start:hover,.day.range-end:hover,.day.range-start.is-today:hover,.day.range-end.is-today:hover{color:var(--components-calendar-cell-text-today)}.day.range-start:before,.day.range-end:before,.day.range-start.is-today:before,.day.range-end.is-today:before{content:\"\";position:absolute;bottom:0;left:0;right:0;top:0;z-index:-1;background-color:var(--components-calendar-cell-background-in-range);border-radius:var(--radius-rounded-full);width:auto;height:auto}.day.range-start:has(~.range-end):before,.day.range-start:has(+.in-range):before{border-top-right-radius:0;border-bottom-right-radius:0}.day.range-end:before{border-top-left-radius:0 !important;border-bottom-left-radius:0 !important}.day.outside-month.range-start,.day.outside-month.range-end{opacity:1 !important;background:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected)}.day.is-today{font-weight:700;position:relative;color:var(--components-calendar-cell-text-today)}.day.is-today.range-start,.day.is-today.range-end{color:var(--components-calendar-cell-text-selected)}.day.is-today.range-start:hover,.day.is-today.range-end:hover{color:var(--components-calendar-cell-text-today)}.day.is-today::after{content:\"\";position:absolute;bottom:var(--spacing-1);left:50%;transform:translateX(-50%);width:var(--calendar-cell-dot-size);height:var(--calendar-cell-dot-size);background-color:currentColor;border-radius:50%}.day.is-today.selected::after{color:var(--components-calendar-cell-text-selected)}.day.is-today.selected::after::after{background-color:var(--components-calendar-cell-dot-selected)}.calendar-footer{display:flex;gap:var(--spacing-1);justify-content:flex-start;width:100%;flex-wrap:wrap}.footer-placement-left{justify-content:flex-start}.footer-placement-right{justify-content:flex-end}.footer-placement-center{justify-content:center}.datepicker-controls{display:flex;flex-direction:column;border-top:1px solid var(--components-calendar-border);padding:var(--calendar-controls-padding-top) var(--calendar-padding) var(--calendar-padding);gap:var(--calendar-grid-gap-y);margin-top:var(--calendar-controls-margin-top)}.datepicker-actions{display:flex;justify-content:flex-end;gap:var(--spacing-1);width:100%}.datepicker-actions slot-fb{display:contents !important}.calendar-footer+.datepicker-actions{margin-top:0}.shortcuts-placement-left,.shortcuts-placement-right{display:flex;flex-direction:column;gap:var(--spacing-1);margin-top:var(--spacing-4)}.shortcuts-placement-left{align-items:flex-end}.shortcuts-placement-right{align-items:flex-start}@keyframes slideLeft{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:translateX(0)}}@keyframes slideRight{from{opacity:0;transform:translateX(-20px)}to{opacity:1;transform:translateX(0)}}@keyframes fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes scaleIn{from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:scale(1)}}";
|
|
416
|
+
const nvCalendarCss = "nv-calendar{display:block}.datepicker-root{display:flex;justify-content:center;align-items:flex-start;width:auto}.datepicker-container{font-family:system-ui, sans-serif;display:flex;flex-direction:column;align-items:stretch;background:var(--components-calendar-background);border-radius:var(--calendar-radius);padding:var(--calendar-padding);box-shadow:0px var(--shadow-y-axis-md-1) var(--shadow-blur-md-1) var(--shadow-spread-md, 0) var(--shadow-color-opacity-0), 0px var(--shadow-y-axis-md-2) var(--shadow-blur-md-2) var(--shadow-spread-md, 0) var(--shadow-color-opacity-2);border:1px solid var(--components-calendar-border);width:auto;max-width:100%}.datepicker-container-single{max-width:300px}.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-left),.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-container-single:has(.shortcuts-placement-left),.datepicker-container-single:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-wrapper{display:flex;justify-content:center;align-items:flex-start;gap:var(--calendar-gap-x);width:auto;overflow-x:hidden}.datepicker-wrapper::-webkit-scrollbar{width:6px;height:6px}.datepicker-wrapper::-webkit-scrollbar-track{background-color:var(--color-level-10-background);border-radius:9999px}.datepicker-wrapper::-webkit-scrollbar-thumb{background-color:var(--color-gray-200);border-radius:9999px}.datepicker-wrapper.single{justify-content:center}.calendar-container{display:flex;flex-direction:column;align-items:center;padding:var(--calendar-padding);width:auto;position:relative}.calendar-separator{width:1px;background:var(--components-calendar-border);height:auto;min-height:100%;margin:0 10px}.header{display:flex;justify-content:start;align-items:center;margin-bottom:var(--calendar-header-margin-bottom);width:100%}.header nv-iconbutton{width:var(--calendar-header-button-size);height:var(--calendar-header-button-size)}.nav-buttons{display:flex;gap:var(--spacing-0);margin-left:auto}.nav-left{order:-1}.date-controls{display:flex;gap:var(--spacing-1);align-items:center;min-height:34px;justify-content:center}.datepicker-container-single .date-controls{justify-content:flex-start}.datepicker-container:not(.datepicker-container-single) .date-controls{justify-content:start;flex-grow:1}.date-controls .month-select,.date-controls .year-input{background:transparent !important}.calendar-wrapper:nth-child(n+2) .datepicker-container{margin-left:42px}.calendar-grid{display:grid;grid-template-columns:auto 1fr;column-gap:var(--calendar-weeks-calendar-gap-x);position:relative}.calendar-grid.slide-left{animation:slideLeft 0.3s ease-out}.calendar-grid.slide-right{animation:slideRight 0.3s ease-out}.week-numbers{display:grid;grid-template-rows:var(--calendar-cell-size) repeat(6, var(--calendar-cell-size));background:var(--components-calendar-weeks-background);color:var(--components-calendar-weeks-text);border-radius:var(--calendar-weeks-radius);width:var(--calendar-weeks-size);row-gap:var(--calendar-grid-gap-y)}.week-numbers .clickable{cursor:pointer}.week-numbers .clickable:hover{background-color:var(--components-calendar-weeks-background-hover);color:var(--components-calendar-weeks-text-hover);border-radius:var(--calendar-radius)}.week-header,.week-number{display:grid;place-items:center;font-size:var(--calendar-cell-font-size)}.week-header{font-weight:700;color:var(--components-calendar-weeks-text)}.week-number{color:var(--components-calendar-cell-text)}.days-container{display:grid;grid-template-rows:auto 1fr;row-gap:var(--calendar-grid-gap-y)}.days-header{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));height:var(--calendar-cell-size)}.day-header{display:grid;place-items:center;font-size:var(--calendar-cell-font-size);color:var(--components-calendar-cell-text)}.days-grid{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));grid-template-rows:repeat(6, var(--calendar-cell-size));animation:fadeIn 0.2s ease-in;row-gap:var(--calendar-grid-gap-y);z-index:0}.day{display:grid;place-items:center;width:var(--calendar-cell-size);height:var(--calendar-cell-size);font-size:var(--calendar-cell-font-size);border-radius:var(--calendar-cell-radius);cursor:pointer;border:none;background:transparent;transition:all 0.2s ease;text-align:center;animation:scaleIn 0.2s ease-out}.day:hover:not(.disabled,.empty,.selected){background:var(--components-calendar-cell-background-hover);color:var(--components-calendar-cell-text-hover)}.day.selected,.day.selected:hover .day.is-today.selected,.day.is-today.selected:hover{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected) !important}.day.disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.day.is-empty{pointer-events:none;background-color:transparent;border-color:transparent}.day.day-blank{pointer-events:none;background-color:transparent;border-color:transparent}.day.outside-month{color:var(--components-calendar-cell-text);opacity:var(--opacity-disabled)}.day.outside-month.selected{opacity:1 !important;color:var(--components-calendar-cell-text-selected)}.day.outside-month.in-range{opacity:0.5 !important;background-color:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range)}.day.outside-month.in-range:hover{opacity:0.7 !important;background-color:var(--components-calendar-cell-background-in-range)}.day.in-range{background:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range);border-radius:0;position:relative}.day.range-start,.day.range-start:focus,.day.range-start:hover,.day.range-end,.day.range-end:focus,.day.range-end:hover{background-color:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected) !important}.day.range-start,.day.range-end,.day.range-start.is-today,.day.range-end.is-today{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected);position:relative;border-radius:var(--radius-rounded-full)}.day.range-start:hover,.day.range-end:hover,.day.range-start.is-today:hover,.day.range-end.is-today:hover{color:var(--components-calendar-cell-text-today)}.day.range-start:before,.day.range-end:before,.day.range-start.is-today:before,.day.range-end.is-today:before{content:\"\";position:absolute;bottom:0;left:0;right:0;top:0;z-index:-1;background-color:var(--components-calendar-cell-background-in-range);border-radius:var(--radius-rounded-full);width:auto;height:auto}.day.range-start:has(~.range-end):before,.day.range-start:has(+.in-range):before{border-top-right-radius:0;border-bottom-right-radius:0}.day.range-end:before{border-top-left-radius:0 !important;border-bottom-left-radius:0 !important}.day.outside-month.range-start,.day.outside-month.range-end{opacity:1 !important;background:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected)}.day.is-today{font-weight:700;position:relative;color:var(--components-calendar-cell-text-today)}.day.is-today.range-start,.day.is-today.range-end{color:var(--components-calendar-cell-text-selected)}.day.is-today.range-start:hover,.day.is-today.range-end:hover{color:var(--components-calendar-cell-text-today)}.day.is-today::after{content:\"\";position:absolute;bottom:var(--spacing-1);left:50%;transform:translateX(-50%);width:var(--calendar-cell-dot-size);height:var(--calendar-cell-dot-size);background-color:currentColor;border-radius:50%}.day.is-today.selected::after{color:var(--components-calendar-cell-text-selected)}.day.is-today.selected::after::after{background-color:var(--components-calendar-cell-dot-selected)}.calendar-footer{display:flex;gap:var(--spacing-1);justify-content:flex-start;width:100%;flex-wrap:wrap}.footer-placement-left{justify-content:flex-start}.footer-placement-right{justify-content:flex-end}.footer-placement-center{justify-content:center}.datepicker-controls{display:flex;flex-direction:column;border-top:1px solid var(--components-calendar-border);padding:var(--calendar-controls-padding-top) var(--calendar-padding) var(--calendar-padding);gap:var(--calendar-grid-gap-y);margin-top:var(--calendar-controls-margin-top)}.datepicker-actions{display:flex;justify-content:flex-end;gap:var(--spacing-1);width:100%}.datepicker-actions slot-fb{display:contents !important}.calendar-footer+.datepicker-actions{margin-top:0}.shortcuts-placement-left,.shortcuts-placement-right{display:flex;flex-direction:column;gap:var(--spacing-1);margin-top:var(--spacing-4)}.shortcuts-placement-left{align-items:flex-end}.shortcuts-placement-right{align-items:flex-start}@keyframes slideLeft{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:translateX(0)}}@keyframes slideRight{from{opacity:0;transform:translateX(-20px)}to{opacity:1;transform:translateX(0)}}@keyframes fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes scaleIn{from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:scale(1)}}";
|
|
414
417
|
const NvCalendarStyle0 = nvCalendarCss;
|
|
415
418
|
|
|
416
419
|
const NvCalendar = class {
|
|
@@ -468,6 +471,8 @@ const NvCalendar = class {
|
|
|
468
471
|
this.showActions = false;
|
|
469
472
|
/** Cache for parsed disabled dates */
|
|
470
473
|
this.parsedDisabledDates = [];
|
|
474
|
+
/** Flag to indicate a user click for selection */
|
|
475
|
+
this.isUserClick = false;
|
|
471
476
|
//#endregion PROPERTIES
|
|
472
477
|
/****************************************************************************/
|
|
473
478
|
//#region STATE
|
|
@@ -503,7 +508,7 @@ const NvCalendar = class {
|
|
|
503
508
|
}
|
|
504
509
|
// Navigate to the date if not prevented
|
|
505
510
|
const preventNavigation = this.el.getAttribute('data-prevent-navigation') === 'true';
|
|
506
|
-
if (!preventNavigation) {
|
|
511
|
+
if (!preventNavigation && !this.isUserClick) {
|
|
507
512
|
this.currentDate = parsedDate;
|
|
508
513
|
}
|
|
509
514
|
}
|
|
@@ -531,7 +536,7 @@ const NvCalendar = class {
|
|
|
531
536
|
}
|
|
532
537
|
// Navigate to start date if not prevented
|
|
533
538
|
const preventNavigation = this.el.getAttribute('data-prevent-navigation') === 'true';
|
|
534
|
-
if (!preventNavigation) {
|
|
539
|
+
if (!preventNavigation && !this.isUserClick) {
|
|
535
540
|
this.currentDate = startDate;
|
|
536
541
|
}
|
|
537
542
|
}
|
|
@@ -552,20 +557,14 @@ const NvCalendar = class {
|
|
|
552
557
|
*/
|
|
553
558
|
this.changeMonth = (offset) => {
|
|
554
559
|
const newDate = new Date(this.currentDate);
|
|
555
|
-
//
|
|
560
|
+
newDate.setUTCDate(1); // Set to the first of the month to avoid day-of-month issues
|
|
556
561
|
newDate.setUTCMonth(newDate.getUTCMonth() + offset);
|
|
557
|
-
// Add the appropriate animation class
|
|
558
562
|
const containers = this.el.querySelectorAll('.calendar-grid');
|
|
559
563
|
containers.forEach(container => {
|
|
560
|
-
// Remove existing animation classes
|
|
561
564
|
container.classList.remove('slide-left', 'slide-right');
|
|
562
|
-
// Add the new animation class
|
|
563
565
|
const animationClass = offset > 0 ? 'slide-left' : 'slide-right';
|
|
564
566
|
container.classList.add(animationClass);
|
|
565
|
-
|
|
566
|
-
setTimeout(() => {
|
|
567
|
-
container.classList.remove(animationClass);
|
|
568
|
-
}, 300); // 300ms corresponds to $slide-duration in the SCSS
|
|
567
|
+
setTimeout(() => container.classList.remove(animationClass), 300);
|
|
569
568
|
});
|
|
570
569
|
this.currentDate = newDate;
|
|
571
570
|
};
|
|
@@ -577,12 +576,16 @@ const NvCalendar = class {
|
|
|
577
576
|
if (this.isDateDisabled(date)) {
|
|
578
577
|
return;
|
|
579
578
|
}
|
|
579
|
+
this.isUserClick = true;
|
|
580
580
|
if (this.selectionType === 'single') {
|
|
581
581
|
this.handleSingleSelection(date);
|
|
582
582
|
}
|
|
583
583
|
else {
|
|
584
584
|
this.handleRangeSelection(date);
|
|
585
585
|
}
|
|
586
|
+
requestAnimationFrame(() => {
|
|
587
|
+
this.isUserClick = false;
|
|
588
|
+
});
|
|
586
589
|
};
|
|
587
590
|
/**
|
|
588
591
|
* Handles single date selection
|
|
@@ -725,12 +728,15 @@ const NvCalendar = class {
|
|
|
725
728
|
/**
|
|
726
729
|
* Generates the days of the current month
|
|
727
730
|
* @param {number} offset - Month offset (0 by default)
|
|
728
|
-
* @param {number} totalCalendars - Number of calendars to display (1 by default)
|
|
729
731
|
* @returns {Array<{ dayOfMonth: number | null, date: Date | null, isSelected: boolean, isDisabled: boolean }>} Array of formatted days
|
|
730
732
|
*/
|
|
731
733
|
this.getDaysInMonth = (offset = 0) => {
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
+
const baseMonth = this.currentDate.getUTCMonth();
|
|
735
|
+
// Correctly calculate the year and month for the given offset
|
|
736
|
+
const targetDate = new Date(this.currentDate);
|
|
737
|
+
targetDate.setUTCMonth(baseMonth + offset);
|
|
738
|
+
const year = targetDate.getUTCFullYear();
|
|
739
|
+
const month = targetDate.getUTCMonth();
|
|
734
740
|
const firstDay = new Date(Date.UTC(year, month, 1));
|
|
735
741
|
const lastDay = new Date(Date.UTC(year, month + 1, 0));
|
|
736
742
|
const days = [];
|
|
@@ -739,32 +745,18 @@ const NvCalendar = class {
|
|
|
739
745
|
const dayOfWeekIndex = firstDay.getUTCDay(); // 0 = Sunday, 1 = Monday, etc.
|
|
740
746
|
// Adjust based on firstDayOfWeek (if week starts on Monday, offset is different)
|
|
741
747
|
const offsetDays = (dayOfWeekIndex - this.firstDayOfWeek + 7) % 7;
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
isDisabled: this.isDateDisabled(date),
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
else {
|
|
759
|
-
for (let i = 0; i < offsetDays; i++) {
|
|
760
|
-
days.push({
|
|
761
|
-
dayOfMonth: null,
|
|
762
|
-
date: null,
|
|
763
|
-
isCurrentMonth: false,
|
|
764
|
-
isDisabled: true,
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
}
|
|
748
|
+
// Add padding days from the previous month
|
|
749
|
+
for (let i = 0; i < offsetDays; i++) {
|
|
750
|
+
const prevMonthDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
751
|
+
const date = new Date(Date.UTC(year, month - 1, prevMonthDay - offsetDays + 1 + i));
|
|
752
|
+
days.push({
|
|
753
|
+
dayOfMonth: date.getUTCDate(),
|
|
754
|
+
date,
|
|
755
|
+
isCurrentMonth: false,
|
|
756
|
+
isDisabled: this.isDateDisabled(date),
|
|
757
|
+
// Days from previous month are blank if not the first calendar
|
|
758
|
+
isBlank: offset > 0,
|
|
759
|
+
});
|
|
768
760
|
}
|
|
769
761
|
// Add the days of the current month
|
|
770
762
|
for (let i = 1; i <= lastDay.getUTCDate(); i++) {
|
|
@@ -774,33 +766,22 @@ const NvCalendar = class {
|
|
|
774
766
|
date,
|
|
775
767
|
isCurrentMonth: true,
|
|
776
768
|
isDisabled: this.isDateDisabled(date),
|
|
769
|
+
isBlank: false,
|
|
777
770
|
});
|
|
778
771
|
}
|
|
779
|
-
|
|
780
|
-
(this.numberOfCalendars > 1 && offset === this.numberOfCalendars - 1);
|
|
781
|
-
// Add the days of the next month to fill the grid
|
|
772
|
+
// Add padding days to fill the last week
|
|
782
773
|
const nextMonthDaysNeeded = 7 - (days.length % 7 || 7);
|
|
783
774
|
if (nextMonthDaysNeeded < 7) {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
else {
|
|
796
|
-
for (let i = 0; i < nextMonthDaysNeeded; i++) {
|
|
797
|
-
days.push({
|
|
798
|
-
dayOfMonth: null,
|
|
799
|
-
date: null,
|
|
800
|
-
isCurrentMonth: false,
|
|
801
|
-
isDisabled: true,
|
|
802
|
-
});
|
|
803
|
-
}
|
|
775
|
+
for (let i = 1; i <= nextMonthDaysNeeded; i++) {
|
|
776
|
+
const date = new Date(Date.UTC(year, month + 1, i));
|
|
777
|
+
days.push({
|
|
778
|
+
dayOfMonth: i,
|
|
779
|
+
date,
|
|
780
|
+
isCurrentMonth: false,
|
|
781
|
+
isDisabled: this.isDateDisabled(date),
|
|
782
|
+
// Days from next month are blank if not the last calendar
|
|
783
|
+
isBlank: offset < this.numberOfCalendars - 1,
|
|
784
|
+
});
|
|
804
785
|
}
|
|
805
786
|
}
|
|
806
787
|
return days;
|
|
@@ -837,12 +818,25 @@ const NvCalendar = class {
|
|
|
837
818
|
this.handleMonthChange = (event, calendarOffset = 0) => {
|
|
838
819
|
const select = event.target;
|
|
839
820
|
const selectedMonth = parseInt(select.value, 10);
|
|
840
|
-
const currentMonth = this.currentDate.getUTCMonth();
|
|
841
|
-
// Calculate the difference considering the calendar offset
|
|
842
|
-
const monthDiff = selectedMonth - ((currentMonth + calendarOffset) % 12);
|
|
843
821
|
const newDate = new Date(this.currentDate);
|
|
844
|
-
|
|
845
|
-
|
|
822
|
+
// Date for the calendar being changed
|
|
823
|
+
const targetCalendarDate = new Date(newDate.toUTCString());
|
|
824
|
+
targetCalendarDate.setUTCMonth(targetCalendarDate.getUTCMonth() + calendarOffset);
|
|
825
|
+
const currentMonth = targetCalendarDate.getUTCMonth();
|
|
826
|
+
let monthDiff = selectedMonth - currentMonth;
|
|
827
|
+
// Smartly adjust for year change
|
|
828
|
+
if (monthDiff > 6) {
|
|
829
|
+
// e.g. from Jan to Dec, go back 1 month
|
|
830
|
+
monthDiff -= 12;
|
|
831
|
+
}
|
|
832
|
+
if (monthDiff < -6) {
|
|
833
|
+
// e.g. from Dec to Jan, go forward 1 month
|
|
834
|
+
monthDiff += 12;
|
|
835
|
+
}
|
|
836
|
+
// Apply the diff to the original `currentDate`
|
|
837
|
+
const finalDate = new Date(this.currentDate);
|
|
838
|
+
finalDate.setUTCMonth(finalDate.getUTCMonth() + monthDiff);
|
|
839
|
+
this.currentDate = finalDate;
|
|
846
840
|
};
|
|
847
841
|
/**
|
|
848
842
|
* Handles year change in the numeric entry
|
|
@@ -854,9 +848,10 @@ const NvCalendar = class {
|
|
|
854
848
|
const year = parseInt(input.value, 10);
|
|
855
849
|
if (!isNaN(year) && year >= 1900 && year <= 2100) {
|
|
856
850
|
const newDate = new Date(this.currentDate);
|
|
857
|
-
newDate.setUTCFullYear(year);
|
|
858
851
|
newDate.setUTCMonth(newDate.getUTCMonth() + calendarOffset);
|
|
859
|
-
|
|
852
|
+
newDate.setUTCFullYear(year);
|
|
853
|
+
newDate.setUTCMonth(newDate.getUTCMonth() - calendarOffset);
|
|
854
|
+
this.currentDate = new Date(newDate);
|
|
860
855
|
}
|
|
861
856
|
};
|
|
862
857
|
/**
|
|
@@ -1085,7 +1080,12 @@ const NvCalendar = class {
|
|
|
1085
1080
|
for (let i = 0; i < days.length; i += 7) {
|
|
1086
1081
|
weeks.push(days.slice(i, i + 7));
|
|
1087
1082
|
}
|
|
1088
|
-
|
|
1083
|
+
// Add year and month to the key to force re-render on date change
|
|
1084
|
+
const targetDate = new Date(this.currentDate);
|
|
1085
|
+
targetDate.setUTCMonth(targetDate.getUTCMonth() + offset);
|
|
1086
|
+
const year = targetDate.getUTCFullYear();
|
|
1087
|
+
const month = targetDate.getUTCMonth();
|
|
1088
|
+
return (index.h("div", { class: "calendar-wrapper" }, index.h("div", { class: "calendar-container", key: `calendar-${index$1}-${year}-${month}` }, this.renderHeader(offset, index$1), index.h("div", { class: "calendar-grid" }, this.showWeekNumbers && this.renderWeekNumbers(weeks, index$1), index.h(CalendarGrid, { days: days, dayNames: this.getDayNames(), selectionType: this.selectionType, selectedDate: this.selectedDate, startDate: this.startDate, endDate: this.endDate, isUTCMode: this.isUTCMode, onDayClick: this.handleDateSelection, isDateInRange: this.isDateInRange, isToday: this.isToday }))), index$1 < this.numberOfCalendars - 1 && (index.h("div", { class: "calendar-separator" }))));
|
|
1089
1089
|
};
|
|
1090
1090
|
/**
|
|
1091
1091
|
* Renders the shortcuts
|
|
@@ -1135,7 +1135,7 @@ const NvCalendar = class {
|
|
|
1135
1135
|
this.endDate = endDate;
|
|
1136
1136
|
// Do not navigate to the start date if data-prevent-navigation attribute is present
|
|
1137
1137
|
const preventNavigation = this.el.getAttribute('data-prevent-navigation') === 'true';
|
|
1138
|
-
if (!preventNavigation) {
|
|
1138
|
+
if (!preventNavigation && !this.isUserClick) {
|
|
1139
1139
|
this.currentDate = startDate;
|
|
1140
1140
|
}
|
|
1141
1141
|
}
|
|
@@ -1163,7 +1163,7 @@ const NvCalendar = class {
|
|
|
1163
1163
|
this.selectedDate = parsedDate;
|
|
1164
1164
|
// Do not navigate to the selected date if data-prevent-navigation attribute is present
|
|
1165
1165
|
const preventNavigation = this.el.getAttribute('data-prevent-navigation') === 'true';
|
|
1166
|
-
if (!preventNavigation) {
|
|
1166
|
+
if (!preventNavigation && !this.isUserClick) {
|
|
1167
1167
|
this.currentDate = parsedDate;
|
|
1168
1168
|
}
|
|
1169
1169
|
}
|
|
@@ -1277,6 +1277,27 @@ const NvCalendar = class {
|
|
|
1277
1277
|
throw error; // Re-throw to let the caller handle it
|
|
1278
1278
|
}
|
|
1279
1279
|
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Clears the current selection and resets the calendar to its initial state.
|
|
1282
|
+
* This method can be called programmatically to reset the calendar.
|
|
1283
|
+
*/
|
|
1284
|
+
async clear() {
|
|
1285
|
+
if (this.selectionType === 'single') {
|
|
1286
|
+
this.selectedDate = null;
|
|
1287
|
+
this.singleValue = '';
|
|
1288
|
+
this.value = '';
|
|
1289
|
+
this.singleDateChange.emit('');
|
|
1290
|
+
this.valueChanged.emit('');
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
this.startDate = null;
|
|
1294
|
+
this.endDate = null;
|
|
1295
|
+
this.rangeValue = { start: '', end: '' };
|
|
1296
|
+
this.value = '';
|
|
1297
|
+
this.rangeDateChange.emit({ start: '', end: '' });
|
|
1298
|
+
this.valueChanged.emit('');
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1280
1301
|
/**
|
|
1281
1302
|
* Renders the datepicker
|
|
1282
1303
|
* @returns {JSX.Element} Datepicker
|
|
@@ -1284,8 +1305,8 @@ const NvCalendar = class {
|
|
|
1284
1305
|
* @slot default - Child content of the component.
|
|
1285
1306
|
*/
|
|
1286
1307
|
render() {
|
|
1287
|
-
return (index.h(index.Host, { key: '
|
|
1288
|
-
this.hasActions) && (index.h("div", { key: '
|
|
1308
|
+
return (index.h(index.Host, { key: '7abeb96312f2bcf26eed3a133ef59d5d3b5b528f' }, index.h("div", { key: 'e0b2db720853551e3b6445e92b39b418123cb83e', class: "datepicker-root" }, index.h("div", { key: '1a83c285278c440c4e33ae770a033974e4924830', class: `datepicker-container ${this.numberOfCalendars === 1 ? 'datepicker-container-single' : ''}` }, index.h("div", { key: '3481fe780a3e1d8f0c1e22ffc82c3b7830721055', class: `datepicker-wrapper ${this.numberOfCalendars === 1 ? 'single' : ''}` }, this.shortcutsPlacement === 'left' && this.renderShortcuts(), Array.from({ length: this.numberOfCalendars }, (_, index) => this.renderCalendar(index, index)), this.shortcutsPlacement === 'right' && this.renderShortcuts()), ((this.hasShortcuts && this.shortcutsPlacement === 'bottom') ||
|
|
1309
|
+
this.hasActions) && (index.h("div", { key: '3a644bdc993142c181c45173756e362025d4a23a', class: "datepicker-controls" }, this.shortcutsPlacement === 'bottom' && this.renderShortcuts(), this.hasActions && this.renderActions())))), index.h("slot", { key: '4a4290ccf63429a9a88cfd95a33b4fdc34c8ef74' })));
|
|
1289
1310
|
}
|
|
1290
1311
|
get el() { return index.getElement(this); }
|
|
1291
1312
|
static get watchers() { return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Cv7U-U85.js');
|
|
4
4
|
var dom_utilsAc71e0ef = require('./dom.utils-ac71e0ef-CmIwRr6O.js');
|
|
5
5
|
var constants4faa1fae = require('./constants-4faa1fae-BzFAKCkR.js');
|
|
6
6
|
require('react');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-Cv7U-U85.js');
|
|
4
4
|
var events_utilsFe1d907f = require('./events.utils-fe1d907f-01N__3wY.js');
|
|
5
5
|
var clsx297c1ffe = require('./clsx-297c1ffe-BtxeOLZW.js');
|
|
6
6
|
var constants4faa1fae = require('./constants-4faa1fae-BzFAKCkR.js');
|