@nectary/components 0.38.0 → 0.40.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/types.d.ts +1 -0
- package/accordion-item/index.js +26 -53
- package/action-menu/index.d.ts +0 -1
- package/action-menu/index.js +179 -223
- package/action-menu/types.d.ts +8 -18
- package/action-menu-option/index.d.ts +1 -0
- package/action-menu-option/index.js +51 -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 +42 -92
- package/card/index.d.ts +2 -0
- package/card/index.js +24 -87
- 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 +55 -107
- package/chip/index.d.ts +13 -0
- package/chip/index.js +137 -0
- package/chip/types.d.ts +38 -0
- package/color-menu/index.d.ts +13 -0
- package/color-menu/index.js +464 -0
- package/color-menu/types.d.ts +37 -0
- package/color-swatch/index.d.ts +13 -0
- package/color-swatch/index.js +59 -0
- package/color-swatch/types.d.ts +12 -0
- package/colors.json +57 -49
- package/date-picker/index.js +196 -287
- package/date-picker/types.d.ts +25 -1
- package/dialog/index.d.ts +1 -0
- package/dialog/index.js +72 -143
- package/dropdown-checkbox-option/index.js +6 -20
- package/dropdown-radio-option/index.js +6 -20
- package/field/index.js +25 -63
- 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 +1 -1
- package/horizontal-stepper/index.js +33 -59
- package/horizontal-stepper-item/index.js +13 -37
- package/icon-button/index.js +39 -84
- 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 +30 -82
- package/input/index.js +113 -222
- package/link/index.js +46 -96
- package/list-item/index.js +1 -1
- package/package.json +12 -14
- package/pagination/index.js +109 -163
- package/pagination/types.d.ts +1 -0
- package/popover/index.js +224 -294
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio/types.d.ts +1 -0
- package/radio-option/index.js +24 -48
- package/segment/index.js +50 -131
- package/segment-collapse/index.js +24 -49
- package/segment-collapse/types.d.ts +1 -0
- package/segmented-control/index.js +36 -73
- package/segmented-control/types.d.ts +1 -0
- package/segmented-control-option/index.js +41 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control/types.d.ts +1 -0
- package/segmented-icon-control-option/index.js +38 -79
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +153 -0
- package/select-button/types.d.ts +43 -0
- package/select-menu/index.d.ts +11 -0
- package/select-menu/index.js +346 -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/types.d.ts +1 -0
- package/tabs-option/index.js +20 -44
- package/tag/index.d.ts +1 -1
- package/tag/index.js +42 -36
- package/tag/types.d.ts +13 -7
- package/textarea/index.js +92 -167
- package/theme.css +80 -49
- package/tile-control/index.js +55 -96
- package/tile-control-option/index.js +40 -86
- package/time-picker/index.js +224 -368
- package/time-picker/types.d.ts +5 -1
- package/title/index.js +6 -20
- package/toast/index.d.ts +17 -0
- package/toast/index.js +115 -0
- package/toast/types.d.ts +28 -0
- package/toast/utils.d.ts +5 -0
- package/toast/utils.js +6 -0
- package/toast-manager/index.d.ts +17 -0
- package/toast-manager/index.js +195 -0
- package/toast-manager/types.d.ts +7 -0
- package/toggle/index.js +55 -108
- package/toggle/types.d.ts +1 -0
- package/types.d.ts +7 -0
- package/utils/colors.d.ts +10 -0
- package/utils/colors.js +121 -0
- package/{utils.d.ts → utils/index.d.ts} +18 -9
- package/{utils.js → utils/index.js} +118 -39
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/card-button/index.d.ts +0 -11
- package/card-button/index.js +0 -77
- package/card-button/types.d.ts +0 -12
- package/card-link/index.d.ts +0 -12
- package/card-link/index.js +0 -115
- package/card-link/types.d.ts +0 -14
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -30
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/search/index.d.ts +0 -14
- package/search/index.js +0 -523
- package/search/types.d.ts +0 -25
- package/search-option/index.d.ts +0 -11
- package/search-option/index.js +0 -55
- package/search-option/types.d.ts +0 -9
- 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 -2
- package/tag/utils.js +0 -1
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -38
- package/tag-close/types.d.ts +0 -3
- package/tag-close/types.js +0 -1
- /package/{card-button → chip}/types.js +0 -0
- /package/{card-link → color-menu}/types.js +0 -0
- /package/{dropdown-text-option → color-swatch}/types.js +0 -0
- /package/{dropdown → select-button}/types.js +0 -0
- /package/{search → select-menu}/types.js +0 -0
- /package/{search-option → select-menu-option}/types.js +0 -0
- /package/{select → toast}/types.js +0 -0
- /package/{select-option → toast-manager}/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,207 +7,68 @@ 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-aqua-400);outline-offset:1px}@supports not selector(:focus-visible){.day:focus{outline:1px solid var(--sinch-color-aqua-400);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
|
|
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-aqua-400);outline-offset:1px}@supports not selector(:focus-visible){.day:focus{outline:1px solid var(--sinch-color-aqua-400);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() {
|
|
223
|
-
return ['value', 'min', 'max', 'locale'];
|
|
71
|
+
return ['value', 'min', 'max', 'locale', 'prev-year-aria-label', 'next-year-aria-label', 'prev-month-aria-label', 'next-month-aria-label'];
|
|
224
72
|
}
|
|
225
73
|
|
|
226
74
|
attributeChangedCallback(name, prevValue, newVal) {
|
|
@@ -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,15 +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
|
});
|
|
136
|
+
this.#monthNames = getMonthNames(newVal);
|
|
137
|
+
this.#render();
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
297
140
|
|
|
298
|
-
|
|
141
|
+
case 'prev-year-aria-label':
|
|
142
|
+
{
|
|
143
|
+
updateAttribute(this.#$prevYear, 'aria-label', newVal);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
case 'next-year-aria-label':
|
|
148
|
+
{
|
|
149
|
+
updateAttribute(this.#$nextYear, 'aria-label', newVal);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
299
152
|
|
|
300
|
-
|
|
153
|
+
case 'prev-month-aria-label':
|
|
154
|
+
{
|
|
155
|
+
updateAttribute(this.#$prevMonth, 'aria-label', newVal);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
301
158
|
|
|
159
|
+
case 'next-month-aria-label':
|
|
160
|
+
{
|
|
161
|
+
updateAttribute(this.#$nextMonth, 'aria-label', newVal);
|
|
302
162
|
break;
|
|
303
163
|
}
|
|
304
164
|
}
|
|
@@ -340,20 +200,36 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
340
200
|
return getAttribute(this, 'max', '');
|
|
341
201
|
}
|
|
342
202
|
|
|
203
|
+
set prevMonthAriaLabel(value) {
|
|
204
|
+
updateAttribute(this, 'prev-month-aria-label', value);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
get prevMonthAriaLabel() {
|
|
208
|
+
return getAttribute(this, 'prev-month-aria-label', '');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
set nextMonthAriaLabel(value) {
|
|
212
|
+
updateAttribute(this, 'next-month-aria-label', value);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
get nextMonthAriaLabel() {
|
|
216
|
+
return getAttribute(this, 'next-month-aria-label', '');
|
|
217
|
+
}
|
|
218
|
+
|
|
343
219
|
get prevYearButtonRect() {
|
|
344
|
-
return getRect(
|
|
220
|
+
return getRect(this.#$prevYear);
|
|
345
221
|
}
|
|
346
222
|
|
|
347
223
|
get nextYearButtonRect() {
|
|
348
|
-
return getRect(
|
|
224
|
+
return getRect(this.#$nextYear);
|
|
349
225
|
}
|
|
350
226
|
|
|
351
227
|
get prevMonthButtonRect() {
|
|
352
|
-
return getRect(
|
|
228
|
+
return getRect(this.#$prevMonth);
|
|
353
229
|
}
|
|
354
230
|
|
|
355
231
|
get nextMonthButtonRect() {
|
|
356
|
-
return getRect(
|
|
232
|
+
return getRect(this.#$nextMonth);
|
|
357
233
|
}
|
|
358
234
|
|
|
359
235
|
nthButtonRect(index) {
|
|
@@ -361,7 +237,7 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
361
237
|
return null;
|
|
362
238
|
}
|
|
363
239
|
|
|
364
|
-
const indexOffset =
|
|
240
|
+
const indexOffset = this.#$days[0].findIndex(el => el.getAttribute('data-date') !== null);
|
|
365
241
|
|
|
366
242
|
if (indexOffset < 0) {
|
|
367
243
|
return null;
|
|
@@ -369,7 +245,7 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
369
245
|
|
|
370
246
|
const rowIndex = Math.floor((indexOffset + index) / 7);
|
|
371
247
|
const colIndex = (indexOffset + index) % 7;
|
|
372
|
-
const $el =
|
|
248
|
+
const $el = this.#$days[rowIndex]?.[colIndex];
|
|
373
249
|
|
|
374
250
|
if ($el == null) {
|
|
375
251
|
return null;
|
|
@@ -378,67 +254,100 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
|
|
|
378
254
|
return getRect($el);
|
|
379
255
|
}
|
|
380
256
|
|
|
381
|
-
|
|
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
|
+
}
|
|
382
284
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
285
|
+
this.#dispatchChangeEvent(dateIso);
|
|
286
|
+
};
|
|
387
287
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
$
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
$day.
|
|
407
|
-
$day.
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
$day.textContent = day.getDate().toString();
|
|
413
|
-
$day.setAttribute('data-date', dayIso);
|
|
414
|
-
|
|
415
|
-
if (isDateBetween(day, _classPrivateFieldGet(this, _minDate), _classPrivateFieldGet(this, _maxDate))) {
|
|
416
|
-
$day.removeAttribute('disabled');
|
|
417
|
-
$day.removeAttribute('aria-hidden');
|
|
418
|
-
} 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');
|
|
419
312
|
$day.setAttribute('disabled', '');
|
|
420
313
|
$day.setAttribute('aria-hidden', 'true');
|
|
421
|
-
}
|
|
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
|
+
}
|
|
422
326
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
327
|
+
if (areDatesEqual(day, valueDate)) {
|
|
328
|
+
$day.classList.add('selected');
|
|
329
|
+
} else if (areDatesEqual(day, todayDate)) {
|
|
330
|
+
$day.classList.add('today');
|
|
331
|
+
}
|
|
428
332
|
|
|
429
|
-
|
|
430
|
-
|
|
333
|
+
isEmptyWeek = false;
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
setClass(this.#$weeks[wi], 'empty', isEmptyWeek);
|
|
431
337
|
});
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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
|
+
});
|
package/date-picker/types.d.ts
CHANGED
|
@@ -9,6 +9,14 @@ export declare type TSinchDatePickerElement = HTMLElement & {
|
|
|
9
9
|
max: string;
|
|
10
10
|
/** BCP 47 language tag (e.g. en-US), which changes day and month display names in the calendar */
|
|
11
11
|
locale: string;
|
|
12
|
+
/** Label that is used for a11y */
|
|
13
|
+
prevYearAriaLabel: string;
|
|
14
|
+
/** Label that is used for a11y */
|
|
15
|
+
nextYearAriaLabel: string;
|
|
16
|
+
/** Label that is used for a11y */
|
|
17
|
+
prevMonthAriaLabel: string;
|
|
18
|
+
/** Label that is used for a11y */
|
|
19
|
+
nextMonthAriaLabel: string;
|
|
12
20
|
readonly prevYearButtonRect: TRect;
|
|
13
21
|
readonly nextYearButtonRect: TRect;
|
|
14
22
|
readonly prevMonthButtonRect: TRect;
|
|
@@ -24,6 +32,14 @@ export declare type TSinchDatePickerElement = HTMLElement & {
|
|
|
24
32
|
setAttribute(name: 'max', value: string): void;
|
|
25
33
|
/** BCP 47 language tag (e.g. en-US), which changes day and month display names in the calendar */
|
|
26
34
|
setAttribute(name: 'locale', value: string): void;
|
|
35
|
+
/** Label that is used for a11y */
|
|
36
|
+
setAttribute(name: 'prev-year-aria-label', value: string): void;
|
|
37
|
+
/** Label that is used for a11y */
|
|
38
|
+
setAttribute(name: 'next-year-aria-label', value: string): void;
|
|
39
|
+
/** Label that is used for a11y */
|
|
40
|
+
setAttribute(name: 'prev-month-aria-label', value: string): void;
|
|
41
|
+
/** Label that is used for a11y */
|
|
42
|
+
setAttribute(name: 'next-month-aria-label', value: string): void;
|
|
27
43
|
};
|
|
28
44
|
export declare type TSinchDatePickerReact = TSinchElementReact<TSinchDatePickerElement> & {
|
|
29
45
|
/** Date value in ISO 8601 format */
|
|
@@ -36,7 +52,15 @@ export declare type TSinchDatePickerReact = TSinchElementReact<TSinchDatePickerE
|
|
|
36
52
|
locale: string;
|
|
37
53
|
/** Label that is used for a11y */
|
|
38
54
|
'aria-label': string;
|
|
39
|
-
/**
|
|
55
|
+
/** Label that is used for a11y */
|
|
56
|
+
'prev-year-aria-label': string;
|
|
57
|
+
/** Label that is used for a11y */
|
|
58
|
+
'next-year-aria-label': string;
|
|
59
|
+
/** Label that is used for a11y */
|
|
60
|
+
'prev-month-aria-label': string;
|
|
61
|
+
/** Label that is used for a11y */
|
|
62
|
+
'next-month-aria-label': string;
|
|
63
|
+
/** @deprecated Change value handler, return date in ISO 8601 format */
|
|
40
64
|
onChange?: (e: SyntheticEvent<TSinchDatePickerElement, CustomEvent<string>>) => void;
|
|
41
65
|
/** Change value handler, return date in ISO 8601 format */
|
|
42
66
|
'on-change'?: (e: CustomEvent<string>) => void;
|