@nectary/components 0.39.0 → 0.41.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/accordion/index.js +47 -84
- package/accordion-item/index.js +30 -53
- package/action-menu/index.d.ts +0 -1
- package/action-menu/index.js +177 -223
- package/action-menu/types.d.ts +8 -18
- package/action-menu-option/index.d.ts +1 -0
- package/action-menu-option/index.js +52 -62
- package/action-menu-option/types.d.ts +9 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.js +6 -20
- package/avatar/index.js +12 -31
- package/avatar-badge/index.js +8 -22
- package/avatar-status/index.js +1 -1
- package/button/index.js +46 -92
- package/button/types.d.ts +1 -1
- package/card/index.js +21 -59
- package/chat-avatar/index.js +8 -22
- package/chat-block/index.js +29 -69
- package/chat-bubble/index.js +6 -20
- package/checkbox/index.js +59 -107
- package/chip/index.d.ts +13 -0
- package/chip/index.js +140 -0
- package/chip/types.d.ts +37 -0
- package/color-menu/index.d.ts +14 -0
- package/color-menu/index.js +450 -0
- package/color-menu/types.d.ts +36 -0
- package/color-menu/utils.d.ts +1 -0
- package/color-menu/utils.js +15 -0
- package/color-swatch/index.d.ts +13 -0
- package/color-swatch/index.js +60 -0
- package/color-swatch/types.d.ts +11 -0
- package/colors.json +61 -49
- package/date-picker/index.js +162 -293
- package/dialog/index.js +70 -142
- package/field/index.js +44 -65
- package/file-drop/index.js +123 -200
- package/file-picker/index.d.ts +0 -1
- package/file-picker/index.js +55 -108
- package/file-status/index.js +15 -39
- package/help-tooltip/index.js +11 -28
- package/horizontal-stepper/index.js +33 -59
- package/horizontal-stepper-item/index.js +13 -37
- package/icon-button/index.d.ts +1 -0
- package/icon-button/index.js +51 -85
- package/icon-button/types.d.ts +16 -2
- package/icons-channel/notify/index.d.ts +11 -0
- package/icons-channel/notify/index.js +4 -0
- package/illustrations/create-illustration-class.js +1 -1
- package/inline-alert/index.js +29 -81
- package/input/index.js +117 -222
- package/link/index.js +51 -97
- package/list-item/index.js +1 -1
- package/package.json +12 -14
- package/pagination/index.js +113 -163
- package/pop/index.d.ts +11 -0
- package/pop/index.js +391 -0
- package/pop/types.d.ts +35 -0
- package/pop/utils.d.ts +7 -0
- package/pop/utils.js +18 -0
- package/popover/index.d.ts +1 -0
- package/popover/index.js +105 -314
- package/popover/types.d.ts +8 -1
- package/popover/utils.d.ts +5 -0
- package/popover/utils.js +17 -1
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio-option/index.js +28 -48
- package/segment/index.js +49 -130
- package/segment-collapse/index.js +28 -49
- package/segmented-control/index.js +36 -73
- package/segmented-control-option/index.js +45 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control-option/index.js +42 -79
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +158 -0
- package/select-button/types.d.ts +43 -0
- package/select-menu/index.d.ts +11 -0
- package/select-menu/index.js +345 -0
- package/select-menu/types.d.ts +29 -0
- package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
- package/select-menu-option/index.js +76 -0
- package/{select-option → select-menu-option}/types.d.ts +8 -9
- package/stop-events/index.js +7 -20
- package/table-head-cell/index.js +7 -21
- package/tabs/index.js +103 -165
- package/tabs-option/index.js +24 -44
- package/tag/index.d.ts +0 -1
- package/tag/index.js +35 -38
- package/tag/types.d.ts +12 -7
- package/textarea/index.js +96 -167
- package/theme.css +146 -49
- package/tile-control/index.js +55 -96
- package/tile-control-option/index.js +45 -87
- package/time-picker/index.js +216 -368
- package/title/index.js +6 -20
- package/toast/index.js +32 -70
- package/toast-manager/index.js +141 -217
- package/toggle/index.js +59 -107
- package/tooltip/index.d.ts +2 -0
- package/tooltip/index.js +160 -17
- package/tooltip/types.d.ts +13 -0
- package/tooltip/utils.d.ts +5 -0
- package/tooltip/utils.js +25 -1
- package/utils/animation.d.ts +17 -0
- package/utils/animation.js +142 -0
- package/utils/colors.d.ts +5 -0
- package/utils/colors.js +5 -0
- package/utils/context.d.ts +15 -0
- package/utils/context.js +57 -0
- package/{utils.d.ts → utils/index.d.ts} +15 -11
- package/{utils.js → utils/index.js} +104 -48
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -32
- package/dropdown-checkbox-option/index.d.ts +0 -11
- package/dropdown-checkbox-option/index.js +0 -88
- package/dropdown-checkbox-option/types.d.ts +0 -15
- package/dropdown-radio-option/index.d.ts +0 -11
- package/dropdown-radio-option/index.js +0 -88
- package/dropdown-radio-option/types.d.ts +0 -15
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/select/index.d.ts +0 -13
- package/select/index.js +0 -316
- package/select/types.d.ts +0 -53
- package/select-option/index.d.ts +0 -11
- package/select-option/index.js +0 -8
- package/tag/utils.d.ts +0 -5
- package/tag/utils.js +0 -6
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -42
- package/tag-close/types.d.ts +0 -5
- /package/{dropdown-checkbox-option → chip}/types.js +0 -0
- /package/{dropdown-radio-option → color-menu}/types.js +0 -0
- /package/{dropdown-text-option → color-swatch}/types.js +0 -0
- /package/{dropdown → pop}/types.js +0 -0
- /package/{select-option → select-button}/types.js +0 -0
- /package/{tag-close → select-menu}/types.js +0 -0
- /package/{select → select-menu-option}/types.js +0 -0
package/date-picker/index.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$month, _$weeks, _$days, _$weekDayNames, _date, _minDate, _maxDate, _$prevMonth, _$nextMonth, _$prevYear, _$nextYear, _$date, _monthNames, _onPrevMonthClick, _onNextMonthClick, _onPrevYearClick, _onNextYearClick, _onDateClick, _render, _dispatchChangeEvent, _onChangeReactHandler;
|
|
5
|
-
|
|
6
|
-
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
|
-
|
|
8
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
9
|
-
|
|
10
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
11
|
-
|
|
12
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
|
-
|
|
14
1
|
import '../icon-button';
|
|
15
2
|
import '../icons/keyboard-arrow-right';
|
|
16
3
|
import '../icons/keyboard-double-arrow-right';
|
|
@@ -20,203 +7,64 @@ import '../icons/delete-outline';
|
|
|
20
7
|
import '../icons/today';
|
|
21
8
|
import '../text';
|
|
22
9
|
import { defineCustomElement, getAttribute, getReactEventHandler, getRect, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
23
|
-
const templateHTML = '<style>:host{display:block;outline:0}#content{width:fit-content;box-sizing:border-box;padding:16px;display:flex;flex-direction:column;gap:8px}#month{display:flex;flex-direction:column;row-gap:8px}.week{display:flex;flex-direction:row;column-gap:8px}.week.empty{display:none}.day{all:initial;font:var(--sinch-font-text-xs);color:var(--sinch-color-text-default);text-align:center;border-radius:var(--sinch-shape-radius-m);width:24px;height:24px;line-height:22px;cursor:pointer;border:1px solid transparent;background-color:transparent;box-sizing:border-box;user-select:none}.day.today{border:1px solid var(--sinch-color-stormy-500)}.day:disabled{cursor:initial;color:var(--sinch-color-snow-700)}.day:focus-visible{outline:1px solid var(--sinch-color-
|
|
10
|
+
const templateHTML = '<style>:host{display:block;outline:0}#content{width:fit-content;box-sizing:border-box;padding:16px;display:flex;flex-direction:column;gap:8px}#month{display:flex;flex-direction:column;row-gap:8px}.week{display:flex;flex-direction:row;column-gap:8px}.week.empty{display:none}.day{all:initial;font:var(--sinch-font-text-xs);color:var(--sinch-color-text-default);text-align:center;border-radius:var(--sinch-shape-radius-m);width:24px;height:24px;line-height:22px;cursor:pointer;border:1px solid transparent;background-color:transparent;box-sizing:border-box;user-select:none}.day.today{border:1px solid var(--sinch-color-stormy-500)}.day:disabled{cursor:initial;color:var(--sinch-color-snow-700)}.day:focus-visible{outline:1px solid var(--sinch-color-border-focus);outline-offset:1px}@supports not selector(:focus-visible){.day:focus{outline:1px solid var(--sinch-color-border-focus);outline-offset:1px}}.day.selected{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100)}.day:hover:not(:disabled):not(.selected){background-color:var(--sinch-color-snow-600)}#week-day-names{display:flex;flex-direction:row;gap:8px;height:24px}.week-day-name{font:var(--sinch-font-text-xs);font-weight:var(--sinch-font-weight-emphasized);color:var(--sinch-color-text-default);text-align:center;width:24px;height:24px;line-height:24px;user-select:none;text-transform:uppercase}#content-header{display:flex;flex-direction:row;height:32px;align-items:center}#date{flex:1;text-align:center;text-transform:capitalize}#prev-year{margin-left:-4px}#next-year{margin-right:-4px}</style><div id="content"><div id="content-header"><sinch-icon-button id="prev-year" small><sinch-icon-keyboard-double-arrow-left slot="icon"></sinch-icon-keyboard-double-arrow-left></sinch-icon-button><sinch-icon-button id="prev-month" small><sinch-icon-keyboard-arrow-left slot="icon"></sinch-icon-keyboard-arrow-left></sinch-icon-button><sinch-text id="date" type="m" emphasized aria-live="polite"></sinch-text><sinch-icon-button id="next-month" small><sinch-icon-keyboard-arrow-right slot="icon"></sinch-icon-keyboard-arrow-right></sinch-icon-button><sinch-icon-button id="next-year" small><sinch-icon-keyboard-double-arrow-right slot="icon"></sinch-icon-keyboard-double-arrow-right></sinch-icon-button></div><div id="week-day-names"><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div></div><div id="month"><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div></div></div>';
|
|
24
11
|
import { areDatesEqual, assertDate, assertLocale, assertMinMax, assertValue, canGoNextMonth, canGoNextYear, canGoPrevMonth, canGoPrevYear, clampMaxDate, clampMinDate, dateToIso, decMonth, decYear, getCalendarMonth, getDayNames, getMonthNames, incMonth, incYear, isDateBetween, isoToDate, isValidDate, today } from './utils';
|
|
25
12
|
const template = document.createElement('template');
|
|
26
13
|
template.innerHTML = templateHTML;
|
|
27
|
-
defineCustomElement('sinch-date-picker',
|
|
14
|
+
defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
15
|
+
#$month;
|
|
16
|
+
#$weeks;
|
|
17
|
+
#$days;
|
|
18
|
+
#$weekDayNames;
|
|
19
|
+
#date = null;
|
|
20
|
+
#minDate = null;
|
|
21
|
+
#maxDate = null;
|
|
22
|
+
#$prevMonth;
|
|
23
|
+
#$nextMonth;
|
|
24
|
+
#$prevYear;
|
|
25
|
+
#$nextYear;
|
|
26
|
+
#$date;
|
|
27
|
+
#monthNames;
|
|
28
|
+
|
|
28
29
|
constructor() {
|
|
29
30
|
super();
|
|
30
|
-
|
|
31
|
-
_classPrivateMethodInitSpec(this, _dispatchChangeEvent);
|
|
32
|
-
|
|
33
|
-
_classPrivateMethodInitSpec(this, _render);
|
|
34
|
-
|
|
35
|
-
_classPrivateFieldInitSpec(this, _$month, {
|
|
36
|
-
writable: true,
|
|
37
|
-
value: void 0
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
_classPrivateFieldInitSpec(this, _$weeks, {
|
|
41
|
-
writable: true,
|
|
42
|
-
value: void 0
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
_classPrivateFieldInitSpec(this, _$days, {
|
|
46
|
-
writable: true,
|
|
47
|
-
value: void 0
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
_classPrivateFieldInitSpec(this, _$weekDayNames, {
|
|
51
|
-
writable: true,
|
|
52
|
-
value: void 0
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
_classPrivateFieldInitSpec(this, _date, {
|
|
56
|
-
writable: true,
|
|
57
|
-
value: null
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
_classPrivateFieldInitSpec(this, _minDate, {
|
|
61
|
-
writable: true,
|
|
62
|
-
value: null
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
_classPrivateFieldInitSpec(this, _maxDate, {
|
|
66
|
-
writable: true,
|
|
67
|
-
value: null
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
_classPrivateFieldInitSpec(this, _$prevMonth, {
|
|
71
|
-
writable: true,
|
|
72
|
-
value: void 0
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
_classPrivateFieldInitSpec(this, _$nextMonth, {
|
|
76
|
-
writable: true,
|
|
77
|
-
value: void 0
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
_classPrivateFieldInitSpec(this, _$prevYear, {
|
|
81
|
-
writable: true,
|
|
82
|
-
value: void 0
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
_classPrivateFieldInitSpec(this, _$nextYear, {
|
|
86
|
-
writable: true,
|
|
87
|
-
value: void 0
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
_classPrivateFieldInitSpec(this, _$date, {
|
|
91
|
-
writable: true,
|
|
92
|
-
value: void 0
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
_classPrivateFieldInitSpec(this, _monthNames, {
|
|
96
|
-
writable: true,
|
|
97
|
-
value: void 0
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
_classPrivateFieldInitSpec(this, _onPrevMonthClick, {
|
|
101
|
-
writable: true,
|
|
102
|
-
value: e => {
|
|
103
|
-
e.stopPropagation();
|
|
104
|
-
decMonth(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _minDate));
|
|
105
|
-
|
|
106
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
_classPrivateFieldInitSpec(this, _onNextMonthClick, {
|
|
111
|
-
writable: true,
|
|
112
|
-
value: e => {
|
|
113
|
-
e.stopPropagation();
|
|
114
|
-
incMonth(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _maxDate));
|
|
115
|
-
|
|
116
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
_classPrivateFieldInitSpec(this, _onPrevYearClick, {
|
|
121
|
-
writable: true,
|
|
122
|
-
value: e => {
|
|
123
|
-
e.stopPropagation();
|
|
124
|
-
decYear(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _minDate));
|
|
125
|
-
|
|
126
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
_classPrivateFieldInitSpec(this, _onNextYearClick, {
|
|
131
|
-
writable: true,
|
|
132
|
-
value: e => {
|
|
133
|
-
e.stopPropagation();
|
|
134
|
-
incYear(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _maxDate));
|
|
135
|
-
|
|
136
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
_classPrivateFieldInitSpec(this, _onDateClick, {
|
|
141
|
-
writable: true,
|
|
142
|
-
value: e => {
|
|
143
|
-
e.stopPropagation();
|
|
144
|
-
const dateIso = e.target.getAttribute('data-date');
|
|
145
|
-
|
|
146
|
-
if (dateIso === null || dateIso.length === 0) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, dateIso);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
155
|
-
writable: true,
|
|
156
|
-
value: e => {
|
|
157
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
|
|
161
31
|
const shadowRoot = this.attachShadow();
|
|
162
32
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
_classPrivateFieldSet(this, _$date, shadowRoot.querySelector('#date'));
|
|
173
|
-
|
|
174
|
-
_classPrivateFieldSet(this, _$month, shadowRoot.querySelector('#month'));
|
|
175
|
-
|
|
176
|
-
_classPrivateFieldSet(this, _$days, []);
|
|
177
|
-
|
|
178
|
-
_classPrivateFieldSet(this, _$weeks, []);
|
|
179
|
-
|
|
180
|
-
_classPrivateFieldSet(this, _monthNames, []);
|
|
181
|
-
|
|
33
|
+
this.#$prevMonth = shadowRoot.querySelector('#prev-month');
|
|
34
|
+
this.#$nextMonth = shadowRoot.querySelector('#next-month');
|
|
35
|
+
this.#$prevYear = shadowRoot.querySelector('#prev-year');
|
|
36
|
+
this.#$nextYear = shadowRoot.querySelector('#next-year');
|
|
37
|
+
this.#$date = shadowRoot.querySelector('#date');
|
|
38
|
+
this.#$month = shadowRoot.querySelector('#month');
|
|
39
|
+
this.#$days = [];
|
|
40
|
+
this.#$weeks = [];
|
|
41
|
+
this.#monthNames = [];
|
|
182
42
|
shadowRoot.querySelectorAll('.week').forEach((week, i) => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
_classPrivateFieldGet(this, _$days)[i] = [];
|
|
43
|
+
this.#$weeks.push(week);
|
|
44
|
+
this.#$days[i] = [];
|
|
186
45
|
week.querySelectorAll('.day').forEach(day => {
|
|
187
|
-
|
|
46
|
+
this.#$days[i].push(day);
|
|
188
47
|
});
|
|
189
48
|
});
|
|
190
|
-
|
|
191
|
-
_classPrivateFieldSet(this, _$weekDayNames, Array.from(shadowRoot.querySelectorAll('#week-day-names > .week-day-name')));
|
|
49
|
+
this.#$weekDayNames = Array.from(shadowRoot.querySelectorAll('#week-day-names > .week-day-name'));
|
|
192
50
|
}
|
|
193
51
|
|
|
194
52
|
connectedCallback() {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
_classPrivateFieldGet(this, _$nextYear).addEventListener('click', _classPrivateFieldGet(this, _onNextYearClick));
|
|
202
|
-
|
|
203
|
-
_classPrivateFieldGet(this, _$month).addEventListener('click', _classPrivateFieldGet(this, _onDateClick));
|
|
204
|
-
|
|
205
|
-
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
53
|
+
this.#$prevMonth.addEventListener('click', this.#onPrevMonthClick);
|
|
54
|
+
this.#$nextMonth.addEventListener('click', this.#onNextMonthClick);
|
|
55
|
+
this.#$prevYear.addEventListener('click', this.#onPrevYearClick);
|
|
56
|
+
this.#$nextYear.addEventListener('click', this.#onNextYearClick);
|
|
57
|
+
this.#$month.addEventListener('click', this.#onDateClick);
|
|
58
|
+
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
206
59
|
}
|
|
207
60
|
|
|
208
61
|
disconnectedCallback() {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
_classPrivateFieldGet(this, _$nextYear).removeEventListener('click', _classPrivateFieldGet(this, _onNextYearClick));
|
|
216
|
-
|
|
217
|
-
_classPrivateFieldGet(this, _$month).removeEventListener('click', _classPrivateFieldGet(this, _onDateClick));
|
|
218
|
-
|
|
219
|
-
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
62
|
+
this.#$prevMonth.removeEventListener('click', this.#onPrevMonthClick);
|
|
63
|
+
this.#$nextMonth.removeEventListener('click', this.#onNextMonthClick);
|
|
64
|
+
this.#$prevYear.removeEventListener('click', this.#onPrevYearClick);
|
|
65
|
+
this.#$nextYear.removeEventListener('click', this.#onNextYearClick);
|
|
66
|
+
this.#$month.removeEventListener('click', this.#onDateClick);
|
|
67
|
+
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
220
68
|
}
|
|
221
69
|
|
|
222
70
|
static get observedAttributes() {
|
|
@@ -232,57 +80,49 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
232
80
|
case 'value':
|
|
233
81
|
{
|
|
234
82
|
assertValue(newVal);
|
|
83
|
+
this.#date = newVal.length > 0 ? isoToDate(newVal) : today();
|
|
235
84
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (!isValidDate(_classPrivateFieldGet(this, _date))) {
|
|
239
|
-
_classPrivateFieldSet(this, _date, today());
|
|
85
|
+
if (!isValidDate(this.#date)) {
|
|
86
|
+
this.#date = today();
|
|
240
87
|
}
|
|
241
88
|
|
|
242
|
-
if (
|
|
243
|
-
clampMinDate(
|
|
89
|
+
if (this.#minDate !== null) {
|
|
90
|
+
clampMinDate(this.#date, this.#minDate);
|
|
244
91
|
}
|
|
245
92
|
|
|
246
|
-
if (
|
|
247
|
-
clampMaxDate(
|
|
93
|
+
if (this.#maxDate !== null) {
|
|
94
|
+
clampMaxDate(this.#date, this.#maxDate);
|
|
248
95
|
}
|
|
249
96
|
|
|
250
|
-
|
|
251
|
-
|
|
97
|
+
this.#render();
|
|
252
98
|
break;
|
|
253
99
|
}
|
|
254
100
|
|
|
255
101
|
case 'min':
|
|
256
102
|
{
|
|
257
103
|
assertMinMax(newVal, name);
|
|
104
|
+
this.#minDate = isoToDate(newVal);
|
|
105
|
+
assertDate(this.#minDate, name, newVal);
|
|
258
106
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
assertDate(_classPrivateFieldGet(this, _minDate), name, newVal);
|
|
262
|
-
|
|
263
|
-
if (_classPrivateFieldGet(this, _date) !== null) {
|
|
264
|
-
clampMinDate(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _minDate));
|
|
107
|
+
if (this.#date !== null) {
|
|
108
|
+
clampMinDate(this.#date, this.#minDate);
|
|
265
109
|
}
|
|
266
110
|
|
|
267
|
-
|
|
268
|
-
|
|
111
|
+
this.#render();
|
|
269
112
|
break;
|
|
270
113
|
}
|
|
271
114
|
|
|
272
115
|
case 'max':
|
|
273
116
|
{
|
|
274
117
|
assertMinMax(newVal, name);
|
|
118
|
+
this.#maxDate = isoToDate(newVal);
|
|
119
|
+
assertDate(this.#maxDate, name, newVal);
|
|
275
120
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
assertDate(_classPrivateFieldGet(this, _maxDate), name, newVal);
|
|
279
|
-
|
|
280
|
-
if (_classPrivateFieldGet(this, _date) !== null) {
|
|
281
|
-
clampMaxDate(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _maxDate));
|
|
121
|
+
if (this.#date !== null) {
|
|
122
|
+
clampMaxDate(this.#date, this.#maxDate);
|
|
282
123
|
}
|
|
283
124
|
|
|
284
|
-
|
|
285
|
-
|
|
125
|
+
this.#render();
|
|
286
126
|
break;
|
|
287
127
|
}
|
|
288
128
|
|
|
@@ -290,39 +130,35 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
290
130
|
{
|
|
291
131
|
assertLocale(newVal);
|
|
292
132
|
const names = getDayNames(newVal);
|
|
293
|
-
|
|
294
|
-
_classPrivateFieldGet(this, _$weekDayNames).forEach(($day, i) => {
|
|
133
|
+
this.#$weekDayNames.forEach(($day, i) => {
|
|
295
134
|
$day.textContent = names[i];
|
|
296
135
|
});
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
_classPrivateMethodGet(this, _render, _render2).call(this);
|
|
301
|
-
|
|
136
|
+
this.#monthNames = getMonthNames(newVal);
|
|
137
|
+
this.#render();
|
|
302
138
|
break;
|
|
303
139
|
}
|
|
304
140
|
|
|
305
141
|
case 'prev-year-aria-label':
|
|
306
142
|
{
|
|
307
|
-
updateAttribute(
|
|
143
|
+
updateAttribute(this.#$prevYear, 'aria-label', newVal);
|
|
308
144
|
break;
|
|
309
145
|
}
|
|
310
146
|
|
|
311
147
|
case 'next-year-aria-label':
|
|
312
148
|
{
|
|
313
|
-
updateAttribute(
|
|
149
|
+
updateAttribute(this.#$nextYear, 'aria-label', newVal);
|
|
314
150
|
break;
|
|
315
151
|
}
|
|
316
152
|
|
|
317
153
|
case 'prev-month-aria-label':
|
|
318
154
|
{
|
|
319
|
-
updateAttribute(
|
|
155
|
+
updateAttribute(this.#$prevMonth, 'aria-label', newVal);
|
|
320
156
|
break;
|
|
321
157
|
}
|
|
322
158
|
|
|
323
159
|
case 'next-month-aria-label':
|
|
324
160
|
{
|
|
325
|
-
updateAttribute(
|
|
161
|
+
updateAttribute(this.#$nextMonth, 'aria-label', newVal);
|
|
326
162
|
break;
|
|
327
163
|
}
|
|
328
164
|
}
|
|
@@ -381,19 +217,19 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
381
217
|
}
|
|
382
218
|
|
|
383
219
|
get prevYearButtonRect() {
|
|
384
|
-
return getRect(
|
|
220
|
+
return getRect(this.#$prevYear);
|
|
385
221
|
}
|
|
386
222
|
|
|
387
223
|
get nextYearButtonRect() {
|
|
388
|
-
return getRect(
|
|
224
|
+
return getRect(this.#$nextYear);
|
|
389
225
|
}
|
|
390
226
|
|
|
391
227
|
get prevMonthButtonRect() {
|
|
392
|
-
return getRect(
|
|
228
|
+
return getRect(this.#$prevMonth);
|
|
393
229
|
}
|
|
394
230
|
|
|
395
231
|
get nextMonthButtonRect() {
|
|
396
|
-
return getRect(
|
|
232
|
+
return getRect(this.#$nextMonth);
|
|
397
233
|
}
|
|
398
234
|
|
|
399
235
|
nthButtonRect(index) {
|
|
@@ -401,7 +237,7 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
401
237
|
return null;
|
|
402
238
|
}
|
|
403
239
|
|
|
404
|
-
const indexOffset =
|
|
240
|
+
const indexOffset = this.#$days[0].findIndex(el => el.getAttribute('data-date') !== null);
|
|
405
241
|
|
|
406
242
|
if (indexOffset < 0) {
|
|
407
243
|
return null;
|
|
@@ -409,7 +245,7 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
409
245
|
|
|
410
246
|
const rowIndex = Math.floor((indexOffset + index) / 7);
|
|
411
247
|
const colIndex = (indexOffset + index) % 7;
|
|
412
|
-
const $el =
|
|
248
|
+
const $el = this.#$days[rowIndex]?.[colIndex];
|
|
413
249
|
|
|
414
250
|
if ($el == null) {
|
|
415
251
|
return null;
|
|
@@ -418,67 +254,100 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
418
254
|
return getRect($el);
|
|
419
255
|
}
|
|
420
256
|
|
|
421
|
-
|
|
257
|
+
#onPrevMonthClick = e => {
|
|
258
|
+
e.stopPropagation();
|
|
259
|
+
decMonth(this.#date, this.#minDate);
|
|
260
|
+
this.#render();
|
|
261
|
+
};
|
|
262
|
+
#onNextMonthClick = e => {
|
|
263
|
+
e.stopPropagation();
|
|
264
|
+
incMonth(this.#date, this.#maxDate);
|
|
265
|
+
this.#render();
|
|
266
|
+
};
|
|
267
|
+
#onPrevYearClick = e => {
|
|
268
|
+
e.stopPropagation();
|
|
269
|
+
decYear(this.#date, this.#minDate);
|
|
270
|
+
this.#render();
|
|
271
|
+
};
|
|
272
|
+
#onNextYearClick = e => {
|
|
273
|
+
e.stopPropagation();
|
|
274
|
+
incYear(this.#date, this.#maxDate);
|
|
275
|
+
this.#render();
|
|
276
|
+
};
|
|
277
|
+
#onDateClick = e => {
|
|
278
|
+
e.stopPropagation();
|
|
279
|
+
const dateIso = e.target.getAttribute('data-date');
|
|
280
|
+
|
|
281
|
+
if (dateIso === null || dateIso.length === 0) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
422
284
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
285
|
+
this.#dispatchChangeEvent(dateIso);
|
|
286
|
+
};
|
|
427
287
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
$
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
$day.
|
|
447
|
-
$day.
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
$day.textContent = day.getDate().toString();
|
|
453
|
-
$day.setAttribute('data-date', dayIso);
|
|
454
|
-
|
|
455
|
-
if (isDateBetween(day, _classPrivateFieldGet(this, _minDate), _classPrivateFieldGet(this, _maxDate))) {
|
|
456
|
-
$day.removeAttribute('disabled');
|
|
457
|
-
$day.removeAttribute('aria-hidden');
|
|
458
|
-
} else {
|
|
288
|
+
#render() {
|
|
289
|
+
if (this.#date === null || this.#minDate === null || this.#maxDate === null || this.locale === null) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const valueDate = isoToDate(this.value);
|
|
294
|
+
const todayDate = new Date();
|
|
295
|
+
const month = getCalendarMonth(this.#date);
|
|
296
|
+
updateBooleanAttribute(this.#$prevMonth, 'disabled', canGoPrevMonth(this.#date, this.#minDate) === false);
|
|
297
|
+
updateBooleanAttribute(this.#$nextMonth, 'disabled', canGoNextMonth(this.#date, this.#maxDate) === false);
|
|
298
|
+
updateBooleanAttribute(this.#$prevYear, 'disabled', canGoPrevYear(this.#date, this.#minDate) === false);
|
|
299
|
+
updateBooleanAttribute(this.#$nextYear, 'disabled', canGoNextYear(this.#date, this.#maxDate) === false);
|
|
300
|
+
this.#$date.textContent = `${this.#monthNames[this.#date.getMonth()]} ${this.#date.getFullYear()}`;
|
|
301
|
+
this.#$days.forEach(($week, wi) => {
|
|
302
|
+
let isEmptyWeek = true;
|
|
303
|
+
$week.forEach(($day, di) => {
|
|
304
|
+
const week = month[wi];
|
|
305
|
+
const day = week?.[di];
|
|
306
|
+
$day.classList.remove('selected');
|
|
307
|
+
$day.classList.remove('today');
|
|
308
|
+
|
|
309
|
+
if (day == null) {
|
|
310
|
+
$day.textContent = '';
|
|
311
|
+
$day.removeAttribute('data-date');
|
|
459
312
|
$day.setAttribute('disabled', '');
|
|
460
313
|
$day.setAttribute('aria-hidden', 'true');
|
|
461
|
-
}
|
|
314
|
+
} else {
|
|
315
|
+
const dayIso = dateToIso(day);
|
|
316
|
+
$day.textContent = day.getDate().toString();
|
|
317
|
+
$day.setAttribute('data-date', dayIso);
|
|
318
|
+
|
|
319
|
+
if (isDateBetween(day, this.#minDate, this.#maxDate)) {
|
|
320
|
+
$day.removeAttribute('disabled');
|
|
321
|
+
$day.removeAttribute('aria-hidden');
|
|
322
|
+
} else {
|
|
323
|
+
$day.setAttribute('disabled', '');
|
|
324
|
+
$day.setAttribute('aria-hidden', 'true');
|
|
325
|
+
}
|
|
462
326
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
327
|
+
if (areDatesEqual(day, valueDate)) {
|
|
328
|
+
$day.classList.add('selected');
|
|
329
|
+
} else if (areDatesEqual(day, todayDate)) {
|
|
330
|
+
$day.classList.add('today');
|
|
331
|
+
}
|
|
468
332
|
|
|
469
|
-
|
|
470
|
-
|
|
333
|
+
isEmptyWeek = false;
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
setClass(this.#$weeks[wi], 'empty', isEmptyWeek);
|
|
471
337
|
});
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
#dispatchChangeEvent(value) {
|
|
341
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
342
|
+
detail: value,
|
|
343
|
+
bubbles: true
|
|
344
|
+
}));
|
|
345
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
346
|
+
detail: value
|
|
347
|
+
}));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
#onChangeReactHandler = e => {
|
|
351
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
352
|
+
};
|
|
353
|
+
});
|