@vonage/vivid 3.47.0 → 3.49.0-preview.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 +3 -403
- package/accordion/index.cjs +21 -0
- package/accordion-item/index.cjs +18 -0
- package/action-group/index.cjs +7 -0
- package/alert/index.cjs +30 -0
- package/alert/index.js +0 -1
- package/appearance-ui/index.cjs +96 -0
- package/audio-player/index.cjs +34 -0
- package/audio-player/index.js +0 -1
- package/avatar/index.cjs +11 -0
- package/badge/index.cjs +14 -0
- package/banner/index.cjs +29 -0
- package/banner/index.js +0 -1
- package/breadcrumb/index.cjs +13 -0
- package/breadcrumb-item/index.cjs +22 -0
- package/button/index.cjs +25 -0
- package/button/index.js +0 -1
- package/calendar/index.cjs +9 -0
- package/calendar-event/index.cjs +9 -0
- package/card/index.cjs +14 -0
- package/checkbox/index.cjs +21 -0
- package/combobox/index.cjs +39 -0
- package/combobox/index.js +1 -1
- package/custom-elements.json +30 -35
- package/data-grid/index.cjs +18 -0
- package/date-picker/index.cjs +40 -0
- package/date-picker/index.js +1 -1
- package/date-range-picker/index.cjs +40 -0
- package/date-range-picker/index.js +1 -1
- package/dialog/index.cjs +31 -0
- package/dialog/index.js +1 -1
- package/divider/index.cjs +8 -0
- package/elevation/index.cjs +7 -0
- package/empty-state/index.cjs +12 -0
- package/fab/index.cjs +22 -0
- package/file-picker/index.cjs +30 -0
- package/file-picker/index.js +1 -1
- package/focus/index.cjs +7 -0
- package/header/index.cjs +8 -0
- package/icon/index.cjs +10 -0
- package/index.cjs +296 -0
- package/index.js +1 -1
- package/layout/index.cjs +7 -0
- package/lib/menu-item/menu-item.d.ts +1 -0
- package/lib/tabs/tabs.d.ts +1 -0
- package/listbox/index.cjs +77 -0
- package/locales/en-GB.cjs +106 -0
- package/locales/en-US.cjs +106 -0
- package/locales/ja-JP.cjs +106 -0
- package/locales/zh-CN.cjs +106 -0
- package/menu/index.cjs +32 -0
- package/menu/index.js +0 -1
- package/menu-item/index.cjs +22 -0
- package/menu-item/index.js +0 -1
- package/nav/index.cjs +6 -0
- package/nav-disclosure/index.cjs +17 -0
- package/nav-disclosure/index.js +0 -1
- package/nav-item/index.cjs +22 -0
- package/note/index.cjs +16 -0
- package/number-field/index.cjs +33 -0
- package/number-field/index.js +1 -1
- package/option/index.cjs +23 -0
- package/package.json +20 -2
- package/pagination/index.cjs +28 -0
- package/pagination/index.js +0 -1
- package/popup/index.cjs +27 -0
- package/popup/index.js +0 -1
- package/progress/index.cjs +9 -0
- package/progress-ring/index.cjs +9 -0
- package/radio/index.cjs +14 -0
- package/radio-group/index.cjs +14 -0
- package/select/index.cjs +38 -0
- package/select/index.js +1 -1
- package/selectable-box/index.cjs +25 -0
- package/shared/Reflector.cjs +67 -0
- package/shared/_has.cjs +62 -0
- package/shared/affix.cjs +64 -0
- package/shared/affix.js +8 -4
- package/shared/anchor.cjs +90 -0
- package/shared/anchored.cjs +78 -0
- package/shared/apply-mixins.cjs +25 -0
- package/shared/aria-global.cjs +74 -0
- package/shared/aria.cjs +11 -0
- package/shared/aria2.cjs +11 -0
- package/shared/base-progress.cjs +72 -0
- package/shared/breadcrumb-item.cjs +27 -0
- package/shared/button.cjs +202 -0
- package/shared/calendar-event.cjs +41 -0
- package/shared/children.cjs +61 -0
- package/shared/class-names.cjs +17 -0
- package/shared/definition.cjs +165 -0
- package/shared/definition10.cjs +102 -0
- package/shared/definition11.cjs +164 -0
- package/shared/definition11.js +39 -42
- package/shared/definition12.cjs +50 -0
- package/shared/definition13.cjs +779 -0
- package/shared/definition14.cjs +157 -0
- package/shared/definition15.cjs +249 -0
- package/shared/definition16.cjs +746 -0
- package/shared/definition17.cjs +1372 -0
- package/shared/definition18.cjs +175 -0
- package/shared/definition19.cjs +416 -0
- package/shared/definition2.cjs +232 -0
- package/shared/definition20.cjs +278 -0
- package/shared/definition21.cjs +83 -0
- package/shared/definition22.cjs +74 -0
- package/shared/definition23.cjs +106 -0
- package/shared/definition24.cjs +2392 -0
- package/shared/definition25.cjs +75 -0
- package/shared/definition26.cjs +39 -0
- package/shared/definition27.cjs +66 -0
- package/shared/definition28.cjs +849 -0
- package/shared/definition28.js +5 -4
- package/shared/definition29.cjs +72 -0
- package/shared/definition29.js +1 -1
- package/shared/definition3.cjs +72 -0
- package/shared/definition30.cjs +98 -0
- package/shared/definition30.js +1 -4
- package/shared/definition31.cjs +37 -0
- package/shared/definition32.cjs +24 -0
- package/shared/definition33.cjs +64 -0
- package/shared/definition34.cjs +533 -0
- package/shared/definition35.cjs +295 -0
- package/shared/definition36.cjs +219 -0
- package/shared/definition37.cjs +109 -0
- package/shared/definition38.cjs +92 -0
- package/shared/definition39.cjs +448 -0
- package/shared/definition4.cjs +198 -0
- package/shared/definition40.cjs +49 -0
- package/shared/definition41.cjs +694 -0
- package/shared/definition41.js +1 -6
- package/shared/definition42.cjs +152 -0
- package/shared/definition43.cjs +113 -0
- package/shared/definition44.cjs +607 -0
- package/shared/definition45.cjs +152 -0
- package/shared/definition45.js +1 -6
- package/shared/definition46.cjs +166 -0
- package/shared/definition46.js +2 -7
- package/shared/definition47.cjs +35 -0
- package/shared/definition48.cjs +98 -0
- package/shared/definition49.cjs +543 -0
- package/shared/definition49.js +12 -3
- package/shared/definition5.cjs +199 -0
- package/shared/definition50.cjs +52 -0
- package/shared/definition51.cjs +150 -0
- package/shared/definition52.cjs +304 -0
- package/shared/definition53.cjs +309 -0
- package/shared/definition54.cjs +146 -0
- package/shared/definition55.cjs +128 -0
- package/shared/definition56.cjs +99 -0
- package/shared/definition57.cjs +310 -0
- package/shared/definition58.cjs +20 -0
- package/shared/definition59.cjs +51 -0
- package/shared/definition6.cjs +83 -0
- package/shared/definition60.cjs +1810 -0
- package/shared/definition7.cjs +72 -0
- package/shared/definition8.cjs +152 -0
- package/shared/definition9.cjs +69 -0
- package/shared/dialog-polyfill.esm.cjs +862 -0
- package/shared/direction.cjs +22 -0
- package/shared/dom.cjs +23 -0
- package/shared/enums.cjs +87 -0
- package/shared/focus.cjs +8 -0
- package/shared/focus2.cjs +11 -0
- package/shared/form-associated.cjs +470 -0
- package/shared/icon.cjs +237 -0
- package/shared/index.cjs +5061 -0
- package/shared/index2.cjs +231 -0
- package/shared/key-codes.cjs +115 -0
- package/shared/key-codes2.cjs +14 -0
- package/shared/listbox.cjs +1072 -0
- package/shared/localized.cjs +11 -0
- package/shared/numbers.cjs +38 -0
- package/shared/patterns/affix.d.ts +5 -1
- package/shared/presentationDate.cjs +6192 -0
- package/shared/presentationDate.js +1 -6
- package/shared/radio.cjs +153 -0
- package/shared/ref.cjs +43 -0
- package/shared/repeat.cjs +767 -0
- package/shared/select.options.cjs +12 -0
- package/shared/slotted.cjs +123 -0
- package/shared/start-end.cjs +52 -0
- package/shared/strings.cjs +11 -0
- package/shared/text-anchor.cjs +33 -0
- package/shared/text-anchor.template.cjs +48 -0
- package/shared/text-field.cjs +5 -0
- package/shared/text-field2.cjs +228 -0
- package/shared/tree-item.cjs +154 -0
- package/shared/when.cjs +31 -0
- package/side-drawer/index.cjs +8 -0
- package/slider/index.cjs +16 -0
- package/split-button/index.cjs +20 -0
- package/split-button/index.js +0 -1
- package/style.css +1 -1
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/switch/index.cjs +15 -0
- package/switch/index.js +0 -5
- package/tab/index.cjs +17 -0
- package/tab-panel/index.cjs +6 -0
- package/tabs/index.cjs +24 -0
- package/tag/index.cjs +17 -0
- package/tag-group/index.cjs +7 -0
- package/text-anchor/index.cjs +24 -0
- package/text-area/index.cjs +25 -0
- package/text-field/index.cjs +27 -0
- package/toggletip/index.cjs +29 -0
- package/toggletip/index.js +0 -1
- package/tooltip/index.cjs +29 -0
- package/tooltip/index.js +0 -1
- package/tree-item/index.cjs +22 -0
- package/tree-view/index.cjs +14 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
const definition$1 = require('./definition60.cjs');
|
|
5
|
+
const definition$3 = require('./definition58.cjs');
|
|
6
|
+
const definition = require('./definition11.cjs');
|
|
7
|
+
const definition$2 = require('./definition53.cjs');
|
|
8
|
+
const definition$4 = require('./definition21.cjs');
|
|
9
|
+
const presentationDate = require('./presentationDate.cjs');
|
|
10
|
+
require('./affix.cjs');
|
|
11
|
+
const index$1 = require('./index2.cjs');
|
|
12
|
+
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
16
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
17
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
18
|
+
if (decorator = decorators[i])
|
|
19
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
20
|
+
if (kind && result)
|
|
21
|
+
__defProp(target, key, result);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
let DatePicker = class extends presentationDate.DatePickerBase {
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
this._textFieldSize = "20";
|
|
31
|
+
this.proxy.type = "date";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
valueChanged(previous, next) {
|
|
37
|
+
super.valueChanged(previous, next);
|
|
38
|
+
if (this.value) {
|
|
39
|
+
if (!presentationDate.isValidDateStr(this.value)) {
|
|
40
|
+
this.value = "";
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this._presentationValue = presentationDate.formatPresentationDate(
|
|
44
|
+
this.value,
|
|
45
|
+
this.locale.datePicker
|
|
46
|
+
);
|
|
47
|
+
this._adjustSelectedMonthToEnsureVisibilityOf(this.value);
|
|
48
|
+
} else {
|
|
49
|
+
this._presentationValue = "";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
#updateValueDueToUserInteraction(newValue) {
|
|
53
|
+
this.value = newValue;
|
|
54
|
+
this.$emit("change");
|
|
55
|
+
this.$emit("input");
|
|
56
|
+
}
|
|
57
|
+
get _calendarButtonLabel() {
|
|
58
|
+
if (this.value) {
|
|
59
|
+
return this.locale.datePicker.changeDateLabel(presentationDate.formatPresentationDate(this.value, this.locale.datePicker));
|
|
60
|
+
} else {
|
|
61
|
+
return this.locale.datePicker.chooseDateLabel;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
get _textFieldPlaceholder() {
|
|
68
|
+
return this.locale.datePicker.dateFormatPlaceholder;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
_onTextFieldChange() {
|
|
74
|
+
if (this._presentationValue === "") {
|
|
75
|
+
this.#updateValueDueToUserInteraction("");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
this.#updateValueDueToUserInteraction(
|
|
80
|
+
presentationDate.parsePresentationDate(this._presentationValue, this.locale.datePicker)
|
|
81
|
+
);
|
|
82
|
+
} catch (_) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Handle selecting a date from the calendar.
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
_onDateClick(date) {
|
|
91
|
+
this.#updateValueDueToUserInteraction(date);
|
|
92
|
+
this._closePopup();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
_isDateSelected(date) {
|
|
98
|
+
return date === this.value;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
_isDateAriaSelected(date) {
|
|
104
|
+
return this._isDateSelected(date);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
_getSelectedDates() {
|
|
110
|
+
const dates = [];
|
|
111
|
+
if (this.value) {
|
|
112
|
+
dates.push(this.value);
|
|
113
|
+
}
|
|
114
|
+
return dates;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
_getCustomValidationError() {
|
|
120
|
+
if (this._isPresentationValueInvalid()) {
|
|
121
|
+
return this.locale.datePicker.invalidDateError;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
_isPresentationValueInvalid() {
|
|
129
|
+
if (this._presentationValue === "") {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
presentationDate.parsePresentationDate(this._presentationValue, this.locale.datePicker);
|
|
134
|
+
return false;
|
|
135
|
+
} catch (_) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
_onClearClick() {
|
|
143
|
+
this.#updateValueDueToUserInteraction("");
|
|
144
|
+
super._onClearClick();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
__decorateClass([
|
|
148
|
+
index.volatile
|
|
149
|
+
], DatePicker.prototype, "_calendarButtonLabel", 1);
|
|
150
|
+
DatePicker = __decorateClass([
|
|
151
|
+
index$1.errorText,
|
|
152
|
+
index$1.formElements
|
|
153
|
+
], DatePicker);
|
|
154
|
+
|
|
155
|
+
const datePickerDefinition = DatePicker.compose({
|
|
156
|
+
baseName: "date-picker",
|
|
157
|
+
template: presentationDate.DatePickerBaseTemplate,
|
|
158
|
+
styles: presentationDate.styles,
|
|
159
|
+
shadowOptions: {
|
|
160
|
+
delegatesFocus: true
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
const datePickerRegistries = [
|
|
164
|
+
datePickerDefinition(),
|
|
165
|
+
...definition.buttonRegistries,
|
|
166
|
+
...definition$1.popupRegistries,
|
|
167
|
+
...definition$2.textFieldRegistries,
|
|
168
|
+
...definition$3.focusRegistries,
|
|
169
|
+
...definition$4.dividerRegistries
|
|
170
|
+
];
|
|
171
|
+
const registerDatePicker = index.registerFactory(datePickerRegistries);
|
|
172
|
+
|
|
173
|
+
exports.datePickerDefinition = datePickerDefinition;
|
|
174
|
+
exports.datePickerRegistries = datePickerRegistries;
|
|
175
|
+
exports.registerDatePicker = registerDatePicker;
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index.cjs');
|
|
4
|
+
const definition = require('./definition11.cjs');
|
|
5
|
+
const definition$1 = require('./definition60.cjs');
|
|
6
|
+
const definition$2 = require('./definition53.cjs');
|
|
7
|
+
const definition$3 = require('./definition58.cjs');
|
|
8
|
+
const definition$4 = require('./definition21.cjs');
|
|
9
|
+
const presentationDate = require('./presentationDate.cjs');
|
|
10
|
+
require('./affix.cjs');
|
|
11
|
+
const index$1 = require('./index2.cjs');
|
|
12
|
+
|
|
13
|
+
const formatRange = (from, to) => {
|
|
14
|
+
return `${from} – ${to}`;
|
|
15
|
+
};
|
|
16
|
+
const formatPresentationDateRange = (dateRange, locale) => {
|
|
17
|
+
return formatRange(presentationDate.formatPresentationDate(dateRange.start, locale), presentationDate.formatPresentationDate(dateRange.end, locale));
|
|
18
|
+
};
|
|
19
|
+
const parsePresentationDateRange = (presentationDateRange, locale) => {
|
|
20
|
+
const fragments = presentationDateRange.trim().split(/[\s—–-]+/);
|
|
21
|
+
if (fragments.length !== 2) {
|
|
22
|
+
throw new Error(`Invalid date range: ${presentationDateRange}`);
|
|
23
|
+
}
|
|
24
|
+
const [start, end] = fragments.map((fragment) => presentationDate.parsePresentationDate(fragment, locale));
|
|
25
|
+
return { start, end };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var __defProp = Object.defineProperty;
|
|
29
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
30
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
31
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
32
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
33
|
+
if (decorator = decorators[i])
|
|
34
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
35
|
+
if (kind && result)
|
|
36
|
+
__defProp(target, key, result);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
const isFormAssociatedTryingToSetFormValue = (value) => typeof value === "string";
|
|
40
|
+
function isDefined(value) {
|
|
41
|
+
return !!value;
|
|
42
|
+
}
|
|
43
|
+
let DateRangePicker = class extends presentationDate.DatePickerBase {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(...arguments);
|
|
46
|
+
this.initialStart = "";
|
|
47
|
+
this.initialEnd = "";
|
|
48
|
+
this.#isInternalValueUpdate = false;
|
|
49
|
+
this.start = "";
|
|
50
|
+
this.end = "";
|
|
51
|
+
this.setFormValue = (value, state) => {
|
|
52
|
+
if (isFormAssociatedTryingToSetFormValue(value)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
super.setFormValue(value, state);
|
|
56
|
+
};
|
|
57
|
+
this._numCalendars = 2;
|
|
58
|
+
/**
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
this._hideDatesOutsideMonth = true;
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
this._textFieldSize = "30";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
initialStartChanged() {
|
|
71
|
+
if (!this.dirtyValue) {
|
|
72
|
+
this.start = this.initialStart;
|
|
73
|
+
this.dirtyValue = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
initialEndChanged() {
|
|
80
|
+
if (!this.dirtyValue) {
|
|
81
|
+
this.end = this.initialEnd;
|
|
82
|
+
this.dirtyValue = false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
#isInternalValueUpdate;
|
|
86
|
+
/**
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
startChanged() {
|
|
90
|
+
if (this.start && !presentationDate.isValidDateStr(this.start)) {
|
|
91
|
+
this.start = "";
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.currentStart = this.start;
|
|
95
|
+
this.dirtyValue = true;
|
|
96
|
+
if (!this.#isInternalValueUpdate) {
|
|
97
|
+
this.#handleChangedValues();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
endChanged() {
|
|
104
|
+
if (this.end && !presentationDate.isValidDateStr(this.end)) {
|
|
105
|
+
this.end = "";
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.currentEnd = this.end;
|
|
109
|
+
this.dirtyValue = true;
|
|
110
|
+
if (!this.#isInternalValueUpdate) {
|
|
111
|
+
this.#handleChangedValues();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
currentStartChanged() {
|
|
118
|
+
this.start = this.currentStart;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
123
|
+
currentEndChanged() {
|
|
124
|
+
this.end = this.currentEnd;
|
|
125
|
+
}
|
|
126
|
+
#updateValues(range) {
|
|
127
|
+
this.#isInternalValueUpdate = true;
|
|
128
|
+
if (range.start !== void 0) {
|
|
129
|
+
this.start = range.start;
|
|
130
|
+
this.$emit("input:start");
|
|
131
|
+
}
|
|
132
|
+
if (range.end !== void 0) {
|
|
133
|
+
this.end = range.end;
|
|
134
|
+
this.$emit("input:end");
|
|
135
|
+
}
|
|
136
|
+
this.#isInternalValueUpdate = false;
|
|
137
|
+
this.$emit("input");
|
|
138
|
+
this.$emit("change");
|
|
139
|
+
this.#handleChangedValues();
|
|
140
|
+
}
|
|
141
|
+
#handleChangedValues() {
|
|
142
|
+
if (this.start && this.end) {
|
|
143
|
+
if (presentationDate.compareDateStr(this.start, this.end) > 0) {
|
|
144
|
+
this.#updateValues({ start: this.end, end: this.start });
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this._presentationValue = formatPresentationDateRange(
|
|
148
|
+
{
|
|
149
|
+
start: this.start,
|
|
150
|
+
end: this.end
|
|
151
|
+
},
|
|
152
|
+
this.locale.datePicker
|
|
153
|
+
);
|
|
154
|
+
this.value = formatRange(this.start, this.end);
|
|
155
|
+
} else {
|
|
156
|
+
this.value = "";
|
|
157
|
+
this._presentationValue = "";
|
|
158
|
+
}
|
|
159
|
+
const dateToEnsureVisibilityOf = this.start || this.end;
|
|
160
|
+
if (dateToEnsureVisibilityOf) {
|
|
161
|
+
this._adjustSelectedMonthToEnsureVisibilityOf(dateToEnsureVisibilityOf);
|
|
162
|
+
}
|
|
163
|
+
this.#updateFormValue();
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
nameChanged(previous, next) {
|
|
169
|
+
super.nameChanged(previous, next);
|
|
170
|
+
this.#updateFormValue();
|
|
171
|
+
}
|
|
172
|
+
#updateFormValue() {
|
|
173
|
+
if (!this.name || !this.start || !this.end) {
|
|
174
|
+
this.setFormValue(null);
|
|
175
|
+
} else {
|
|
176
|
+
const formData = new FormData();
|
|
177
|
+
formData.append(this.name, this.start);
|
|
178
|
+
formData.append(this.name, this.end);
|
|
179
|
+
this.setFormValue(formData);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
connectedCallback() {
|
|
183
|
+
super.connectedCallback();
|
|
184
|
+
if (!this.start) {
|
|
185
|
+
this.start = this.initialStart;
|
|
186
|
+
}
|
|
187
|
+
if (!this.end) {
|
|
188
|
+
this.end = this.initialEnd;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
#getVisibleRange() {
|
|
192
|
+
const candidates = [this.start, this.end].filter(isDefined);
|
|
193
|
+
const isPartialRange = candidates.length === 1;
|
|
194
|
+
if (this._hoverDate && isPartialRange) {
|
|
195
|
+
candidates.push(this._hoverDate);
|
|
196
|
+
}
|
|
197
|
+
const [start, end] = candidates.sort(presentationDate.compareDateStr);
|
|
198
|
+
return { start, end };
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @internal
|
|
202
|
+
*/
|
|
203
|
+
_isDateAriaSelected(date) {
|
|
204
|
+
return date === this.start || date === this.end;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
_isDateInSelectedRange(date) {
|
|
210
|
+
const { start, end } = this.#getVisibleRange();
|
|
211
|
+
if (start && end) {
|
|
212
|
+
return presentationDate.compareDateStr(date, start) >= 0 && presentationDate.compareDateStr(date, end) <= 0;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* @internal
|
|
218
|
+
*/
|
|
219
|
+
_isDateRangeStart(date) {
|
|
220
|
+
return date === this.#getVisibleRange().start;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* @internal
|
|
224
|
+
*/
|
|
225
|
+
_isDateRangeEnd(date) {
|
|
226
|
+
return date === this.#getVisibleRange().end;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
231
|
+
_getSelectedDates() {
|
|
232
|
+
const dates = [];
|
|
233
|
+
if (this.start) {
|
|
234
|
+
dates.push(this.start);
|
|
235
|
+
}
|
|
236
|
+
if (this.end) {
|
|
237
|
+
dates.push(this.end);
|
|
238
|
+
}
|
|
239
|
+
return dates;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
_onDateClick(date) {
|
|
245
|
+
if (this.start && this.end) {
|
|
246
|
+
this.#updateValues({ start: date, end: "" });
|
|
247
|
+
} else if (this.start) {
|
|
248
|
+
this.#updateValues({ end: date });
|
|
249
|
+
this._closePopup();
|
|
250
|
+
} else if (this.end) {
|
|
251
|
+
this.#updateValues({ start: date });
|
|
252
|
+
this._closePopup();
|
|
253
|
+
} else {
|
|
254
|
+
this.#updateValues({ start: date });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @internal
|
|
259
|
+
*/
|
|
260
|
+
get _textFieldPlaceholder() {
|
|
261
|
+
return formatRange(
|
|
262
|
+
this.locale.datePicker.dateFormatPlaceholder,
|
|
263
|
+
this.locale.datePicker.dateFormatPlaceholder
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* @internal
|
|
268
|
+
*/
|
|
269
|
+
_onTextFieldChange() {
|
|
270
|
+
if (this._presentationValue === "") {
|
|
271
|
+
this.#updateValues({ start: "", end: "" });
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const { start, end } = parsePresentationDateRange(
|
|
276
|
+
this._presentationValue,
|
|
277
|
+
this.locale.datePicker
|
|
278
|
+
);
|
|
279
|
+
this.#updateValues({ start, end });
|
|
280
|
+
} catch (_) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @internal
|
|
286
|
+
*/
|
|
287
|
+
_onDateMouseEnter(date) {
|
|
288
|
+
this._hoverDate = date;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* @internal
|
|
292
|
+
*/
|
|
293
|
+
_onDateMouseLeave() {
|
|
294
|
+
this._hoverDate = void 0;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
299
|
+
_getCustomValidationError() {
|
|
300
|
+
if (this._isPresentationValueInvalid()) {
|
|
301
|
+
return this.locale.datePicker.invalidDateRangeError;
|
|
302
|
+
}
|
|
303
|
+
if (this.min && this.start && presentationDate.compareDateStr(this.start, this.min) < 0) {
|
|
304
|
+
return this.locale.datePicker.startDateAfterMinDateError(
|
|
305
|
+
presentationDate.formatPresentationDate(this.min, this.locale.datePicker)
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
if (this.max && this.end && presentationDate.compareDateStr(this.end, this.max) > 0) {
|
|
309
|
+
return this.locale.datePicker.endDateBeforeMaxDateError(
|
|
310
|
+
presentationDate.formatPresentationDate(this.max, this.locale.datePicker)
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* @internal
|
|
317
|
+
*/
|
|
318
|
+
_isPresentationValueInvalid() {
|
|
319
|
+
if (this._presentationValue === "") {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
try {
|
|
323
|
+
parsePresentationDateRange(
|
|
324
|
+
this._presentationValue,
|
|
325
|
+
this.locale.datePicker
|
|
326
|
+
);
|
|
327
|
+
return false;
|
|
328
|
+
} catch (_) {
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* @internal
|
|
334
|
+
*/
|
|
335
|
+
_onClearClick() {
|
|
336
|
+
this.#updateValues({ start: "", end: "" });
|
|
337
|
+
super._onClearClick();
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* @internal
|
|
341
|
+
*/
|
|
342
|
+
formResetCallback() {
|
|
343
|
+
this.#updateValues({ start: this.initialStart, end: this.initialEnd });
|
|
344
|
+
super.formResetCallback();
|
|
345
|
+
}
|
|
346
|
+
get _calendarButtonLabel() {
|
|
347
|
+
if (this.start && this.end) {
|
|
348
|
+
return this.locale.datePicker.changeDatesLabel(
|
|
349
|
+
formatPresentationDateRange(
|
|
350
|
+
{
|
|
351
|
+
start: this.start,
|
|
352
|
+
end: this.end
|
|
353
|
+
},
|
|
354
|
+
this.locale.datePicker
|
|
355
|
+
)
|
|
356
|
+
);
|
|
357
|
+
} else {
|
|
358
|
+
return this.locale.datePicker.chooseDatesLabel;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
__decorateClass([
|
|
363
|
+
index.attr({ mode: "fromView", attribute: "start" })
|
|
364
|
+
], DateRangePicker.prototype, "initialStart", 2);
|
|
365
|
+
__decorateClass([
|
|
366
|
+
index.attr({ mode: "fromView", attribute: "end" })
|
|
367
|
+
], DateRangePicker.prototype, "initialEnd", 2);
|
|
368
|
+
__decorateClass([
|
|
369
|
+
index.observable
|
|
370
|
+
], DateRangePicker.prototype, "start", 2);
|
|
371
|
+
__decorateClass([
|
|
372
|
+
index.observable
|
|
373
|
+
], DateRangePicker.prototype, "end", 2);
|
|
374
|
+
__decorateClass([
|
|
375
|
+
index.attr({ attribute: "current-start" })
|
|
376
|
+
], DateRangePicker.prototype, "currentStart", 2);
|
|
377
|
+
__decorateClass([
|
|
378
|
+
index.attr({ attribute: "current-end" })
|
|
379
|
+
], DateRangePicker.prototype, "currentEnd", 2);
|
|
380
|
+
__decorateClass([
|
|
381
|
+
index.observable
|
|
382
|
+
], DateRangePicker.prototype, "_numCalendars", 2);
|
|
383
|
+
__decorateClass([
|
|
384
|
+
index.observable
|
|
385
|
+
], DateRangePicker.prototype, "_hoverDate", 2);
|
|
386
|
+
__decorateClass([
|
|
387
|
+
index.volatile
|
|
388
|
+
], DateRangePicker.prototype, "_calendarButtonLabel", 1);
|
|
389
|
+
DateRangePicker = __decorateClass([
|
|
390
|
+
index$1.errorText,
|
|
391
|
+
index$1.formElements
|
|
392
|
+
], DateRangePicker);
|
|
393
|
+
|
|
394
|
+
const dateRangePickerDefinition = DateRangePicker.compose({
|
|
395
|
+
baseName: "date-range-picker",
|
|
396
|
+
template: presentationDate.DatePickerBaseTemplate,
|
|
397
|
+
styles: presentationDate.styles,
|
|
398
|
+
shadowOptions: {
|
|
399
|
+
delegatesFocus: true
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
const dateRangePickerRegistries = [
|
|
403
|
+
dateRangePickerDefinition(),
|
|
404
|
+
...definition.buttonRegistries,
|
|
405
|
+
...definition$1.popupRegistries,
|
|
406
|
+
...definition$2.textFieldRegistries,
|
|
407
|
+
...definition$3.focusRegistries,
|
|
408
|
+
...definition$4.dividerRegistries
|
|
409
|
+
];
|
|
410
|
+
const registerDateRangePicker = index.registerFactory(
|
|
411
|
+
dateRangePickerRegistries
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
exports.dateRangePickerDefinition = dateRangePickerDefinition;
|
|
415
|
+
exports.dateRangePickerRegistries = dateRangePickerRegistries;
|
|
416
|
+
exports.registerDateRangePicker = registerDateRangePicker;
|