@gravitee/ui-components 3.25.3-typescript-ad6021f → 3.25.3-typescript-bfd8f67

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.
Files changed (188) hide show
  1. package/package.json +5 -8
  2. package/src/atoms/gv-autocomplete.js +1 -461
  3. package/src/atoms/gv-button.js +1 -410
  4. package/src/atoms/gv-checkbox.js +1 -187
  5. package/src/atoms/gv-date-picker-calendar.js +1 -894
  6. package/src/atoms/gv-date-picker-cell.js +1 -190
  7. package/src/atoms/gv-date-picker.js +1 -671
  8. package/src/atoms/gv-file-upload.js +1 -367
  9. package/src/atoms/gv-icon.js +1 -103
  10. package/src/atoms/gv-image.js +1 -144
  11. package/src/atoms/gv-input-message.js +1 -84
  12. package/src/atoms/gv-input.js +1 -561
  13. package/src/atoms/gv-link.js +1 -210
  14. package/src/atoms/gv-message.js +1 -128
  15. package/src/atoms/gv-metric.js +1 -117
  16. package/src/atoms/gv-relative-time.js +1 -156
  17. package/src/atoms/gv-select-native.js +1 -388
  18. package/src/atoms/gv-select.js +1 -437
  19. package/src/atoms/gv-spinner.js +1 -57
  20. package/src/atoms/gv-state.js +1 -130
  21. package/src/atoms/gv-switch.js +1 -243
  22. package/src/atoms/gv-tag.js +1 -168
  23. package/src/atoms/gv-text.js +1 -168
  24. package/src/charts/gv-chart-bar.js +1 -103
  25. package/src/charts/gv-chart-gauge.js +1 -100
  26. package/src/charts/gv-chart-histogram.js +1 -83
  27. package/src/charts/gv-chart-line.js +1 -224
  28. package/src/charts/gv-chart-map.js +1 -112
  29. package/src/charts/gv-chart-pie.js +1 -91
  30. package/src/index.js +1 -77
  31. package/src/lib/cron-expression.js +1 -205
  32. package/src/lib/date.js +1 -44
  33. package/src/lib/events.js +1 -26
  34. package/src/lib/http-client-schema-form.js +1 -67
  35. package/src/lib/http.js +1 -237
  36. package/src/lib/i18n.js +1 -103
  37. package/src/lib/item.js +1 -118
  38. package/src/lib/properties.js +1 -189
  39. package/src/lib/schema-form.js +1 -44
  40. package/src/lib/studio.js +1 -141
  41. package/src/lib/style.js +1 -41
  42. package/src/lib/text-format.js +1 -69
  43. package/src/lib/theme.js +1 -63
  44. package/src/lib/utils.js +1 -111
  45. package/src/mixins/chart-element.js +1 -165
  46. package/src/mixins/input-element.js +1 -144
  47. package/src/mixins/item-resource.js +1 -120
  48. package/src/mixins/keyboard-element.js +1 -69
  49. package/src/mixins/update-after-browser.js +1 -30
  50. package/src/mixins/with-resize-observer.js +1 -68
  51. package/src/mixins/with-skeleton-attribute.js +1 -112
  52. package/src/molecules/gv-card-full.js +1 -218
  53. package/src/molecules/gv-card-list.js +1 -113
  54. package/src/molecules/gv-card.js +1 -133
  55. package/src/molecules/gv-category-list.js +1 -60
  56. package/src/molecules/gv-category.js +1 -170
  57. package/src/molecules/gv-code.js +1 -359
  58. package/src/molecules/gv-confirm.js +1 -188
  59. package/src/molecules/gv-cron-editor.js +1 -710
  60. package/src/molecules/gv-dropdown-menu.js +1 -116
  61. package/src/molecules/gv-expandable.js +1 -122
  62. package/src/molecules/gv-expression-language.js +1 -270
  63. package/src/molecules/gv-identity-picture.js +1 -148
  64. package/src/molecules/gv-list.js +1 -227
  65. package/src/molecules/gv-metrics.js +1 -162
  66. package/src/molecules/gv-modal.js +1 -213
  67. package/src/molecules/gv-nav.js +1 -196
  68. package/src/molecules/gv-option.js +1 -242
  69. package/src/molecules/gv-plans.js +1 -429
  70. package/src/molecules/gv-popover.js +1 -351
  71. package/src/molecules/gv-promote.js +1 -209
  72. package/src/molecules/gv-rating-list.js +1 -365
  73. package/src/molecules/gv-rating.js +1 -253
  74. package/src/molecules/gv-row-expandable.js +1 -45
  75. package/src/molecules/gv-row.js +1 -210
  76. package/src/molecules/gv-stats.js +1 -121
  77. package/src/molecules/gv-stepper.js +1 -288
  78. package/src/molecules/gv-table.js +1 -685
  79. package/src/molecules/gv-tree.js +1 -250
  80. package/src/organisms/gv-documentation.js +1 -215
  81. package/src/organisms/gv-header.js +1 -288
  82. package/src/organisms/gv-http-client.js +1 -275
  83. package/src/organisms/gv-menu.js +1 -263
  84. package/src/organisms/gv-newsletter-subscription.js +1 -271
  85. package/src/organisms/gv-pagination.js +1 -198
  86. package/src/organisms/gv-properties.js +1 -920
  87. package/src/organisms/gv-resizable-views.js +1 -396
  88. package/src/organisms/gv-resources.js +1 -535
  89. package/src/organisms/gv-schema-form-array.js +1 -250
  90. package/src/organisms/gv-schema-form-control-object.js +1 -154
  91. package/src/organisms/gv-schema-form-control.js +1 -443
  92. package/src/organisms/gv-schema-form.js +1 -751
  93. package/src/organisms/gv-tabs.js +1 -210
  94. package/src/organisms/gv-user-menu.js +1 -314
  95. package/src/organisms/gv-vertical-menu.js +1 -123
  96. package/src/policy-studio/gv-flow-step.js +1 -464
  97. package/src/policy-studio/gv-flow.js +1 -621
  98. package/src/policy-studio/gv-policy-studio-menu.js +1 -750
  99. package/src/policy-studio/gv-policy-studio.js +1 -1842
  100. package/src/styles/empty.js +1 -36
  101. package/src/styles/input.js +1 -263
  102. package/src/styles/link.js +1 -32
  103. package/src/styles/shapes.js +1 -17
  104. package/src/styles/skeleton.js +1 -53
  105. package/src/styles/zoom.js +1 -40
  106. package/src/theme/gv-theme.js +1 -203
  107. package/wc/gv-autocomplete.js +1 -1
  108. package/wc/gv-button.js +1 -1
  109. package/wc/gv-card-full.js +1 -1
  110. package/wc/gv-card-list.js +1 -1
  111. package/wc/gv-card.js +1 -1
  112. package/wc/gv-category-list.js +1 -1
  113. package/wc/gv-category.js +1 -1
  114. package/wc/gv-chart-bar.js +1 -1
  115. package/wc/gv-chart-gauge.js +1 -1
  116. package/wc/gv-chart-histogram.js +1 -1
  117. package/wc/gv-chart-line.js +1 -1
  118. package/wc/gv-chart-map.js +1 -1
  119. package/wc/gv-chart-pie.js +1 -1
  120. package/wc/gv-checkbox.js +1 -1
  121. package/wc/gv-code.js +1 -1
  122. package/wc/gv-confirm.js +1 -1
  123. package/wc/gv-cron-editor.js +1 -1
  124. package/wc/gv-date-picker-calendar.js +1 -1
  125. package/wc/gv-date-picker-cell.js +1 -1
  126. package/wc/gv-date-picker.js +1 -1
  127. package/wc/gv-documentation.js +1 -1
  128. package/wc/gv-dropdown-menu.js +1 -1
  129. package/wc/gv-expandable.js +1 -1
  130. package/wc/gv-expression-language.js +1 -1
  131. package/wc/gv-file-upload.js +1 -1
  132. package/wc/gv-flow-step.js +1 -1
  133. package/wc/gv-flow.js +1 -1
  134. package/wc/gv-header.js +1 -1
  135. package/wc/gv-http-client.js +1 -1
  136. package/wc/gv-icon.js +1 -1
  137. package/wc/gv-identity-picture.js +1 -1
  138. package/wc/gv-image.js +1 -1
  139. package/wc/gv-input-message.js +1 -1
  140. package/wc/gv-input.js +1 -1
  141. package/wc/gv-link.js +1 -1
  142. package/wc/gv-list.js +1 -1
  143. package/wc/gv-menu.js +1 -1
  144. package/wc/gv-message.js +1 -1
  145. package/wc/gv-metric.js +1 -1
  146. package/wc/gv-metrics.js +1 -1
  147. package/wc/gv-modal.js +1 -1
  148. package/wc/gv-nav.js +1 -1
  149. package/wc/gv-newsletter-subscription.js +1 -1
  150. package/wc/gv-option.js +1 -1
  151. package/wc/gv-pagination.js +1 -1
  152. package/wc/gv-plans.js +1 -1
  153. package/wc/gv-policy-studio-menu.js +1 -1
  154. package/wc/gv-policy-studio.js +1 -1
  155. package/wc/gv-popover.js +1 -1
  156. package/wc/gv-promote.js +1 -1
  157. package/wc/gv-properties.js +1 -1
  158. package/wc/gv-rating-list.js +1 -1
  159. package/wc/gv-rating.js +1 -1
  160. package/wc/gv-relative-time.js +1 -1
  161. package/wc/gv-resizable-views.js +1 -1
  162. package/wc/gv-resources.js +1 -1
  163. package/wc/gv-row-expandable.js +1 -1
  164. package/wc/gv-row.js +1 -1
  165. package/wc/gv-schema-form-array.js +1 -1
  166. package/wc/gv-schema-form-control-object.js +1 -1
  167. package/wc/gv-schema-form-control.js +1 -1
  168. package/wc/gv-schema-form.js +1 -1
  169. package/wc/gv-select-native.js +1 -1
  170. package/wc/gv-select.js +1 -1
  171. package/wc/gv-spinner.js +1 -1
  172. package/wc/gv-state.js +1 -1
  173. package/wc/gv-stats.js +1 -1
  174. package/wc/gv-stepper.js +1 -1
  175. package/wc/gv-switch.js +1 -1
  176. package/wc/gv-table.js +1 -1
  177. package/wc/gv-tabs.js +1 -1
  178. package/wc/gv-tag.js +1 -1
  179. package/wc/gv-text.js +1 -1
  180. package/wc/gv-theme.js +1 -1
  181. package/wc/gv-tree.js +1 -1
  182. package/wc/gv-user-menu.js +1 -1
  183. package/wc/gv-vertical-menu.js +1 -1
  184. package/CHANGELOG.md +0 -1292
  185. package/LICENSE.txt +0 -202
  186. package/README.md +0 -195
  187. package/src/.eslintrc.js +0 -19
  188. package/src/theme/definition.json +0 -1762
@@ -1,671 +1 @@
1
- /*
2
- * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import './gv-date-picker-calendar';
17
- import enUS from 'date-fns/locale/en-US';
18
- import { format, getMonth, getYear, parse } from 'date-fns';
19
- import { classMap } from 'lit/directives/class-map';
20
- import { css, LitElement, html } from 'lit';
21
- import { getLanguage, i18n } from '../lib/i18n';
22
-
23
- import { isInvalid } from '../lib/date';
24
- import { until } from 'lit/directives/until';
25
- import { dispatchCustomEvent } from '../lib/events';
26
-
27
- const locales = { en: enUS };
28
-
29
- /**
30
- * Date Picker
31
- *
32
- * ## Details
33
- * * has @theme facet
34
- *
35
- * @attr {Number|Array} value - if range picker, value is an array of timestamp else is a timestamp
36
- * @attr {Boolean} range - if has range picker
37
- * @attr {Boolean} time - if has time picker
38
- * @attr {String} name - name of the input
39
- * @attr {Boolean} strict - in completion of time if just have time picker
40
- * @attr {Number} min - min timestamp
41
- * @attr {Number} max - max timestamp
42
- * @attr {Number} distanceFromNow - The distance timestamp relative to the current date. If configured, the min / max will be updated every minute.
43
- * @attr {String} format - date format
44
- * @attr {Boolean} valid - if value is valid
45
- * @attr {Boolean} invalid - if value is invalid
46
- * @attr {Boolean} small - for a small input
47
- *
48
- * @cssprop {Color} [--gv-date-picker-hover--bgc=var(--gv-theme-color-light, #86c3d0)] - Hover background color
49
- * @cssprop {Color} [--gv-date-picker-hover--c=var(--gv-theme-font-color-dark, #262626)] - Hover color
50
- * @cssprop {Color} [--gv-date-picker-selected--bgc=var(--gv-theme-color, #5a7684)] - Selected background color
51
- * @cssprop {Color} [--gv-date-picker-selected--c=var(--gv-theme-font-color-light, #ffffff)] - Selected color
52
- */
53
- export class GvDatePicker extends LitElement {
54
- static get properties() {
55
- return {
56
- range: { type: Boolean },
57
- label: { type: String },
58
- name: { type: String },
59
- time: { type: Boolean },
60
- strict: { type: Boolean },
61
- small: { type: Boolean },
62
- value: { type: Array, reflect: true },
63
- min: { type: Number },
64
- max: { type: Number },
65
- distanceFromNow: { type: Number },
66
- disabledDates: { type: Array },
67
- format: { type: String },
68
- invalid: { type: Boolean, reflect: true },
69
- valid: { type: Boolean, reflect: true },
70
- _hoveredDate: { type: String, attribute: false },
71
- _open: { type: Boolean, attribute: false },
72
- _month: { type: String, attribute: false },
73
- _year: { type: String, attribute: false },
74
- _monthPlus: { type: String, attribute: false },
75
- _yearPlus: { type: Number, attribute: false },
76
- _mode: { type: String, attribute: false },
77
- _from: { type: Number, attribute: false },
78
- _to: { type: Number, attribute: false },
79
- _min: { type: Number, attribute: false },
80
- _max: { type: Number, attribute: false },
81
- _distance: { type: Number, attribute: false },
82
- };
83
- }
84
-
85
- static get styles() {
86
- return [
87
- // language=CSS
88
- css`
89
- :host {
90
- box-sizing: border-box;
91
- display: inline-block;
92
- margin: 0.2rem;
93
- --gv-input-icon--bgc: transparent;
94
- --gv-icon--s: 22px;
95
- --date-picker-hover--bgc: var(--gv-date-picker-hover--bgc, var(--gv-theme-color-light, #86c3d0));
96
- --date-picker-hover--c: var(--gv-date-picker-hover--c, var(--gv-theme-font-color-dark, #262626));
97
- --date-picker-selected--bgc: var(--gv-date-picker-selected--bgc, var(--gv-theme-color, #5a7684));
98
- --date-picker-selected--c: var(--gv-date-picker-selected--c, var(--gv-theme-font-color-light, #ffffff));
99
- font-size: var(--gv-theme-font-size-m, 14px);
100
- }
101
-
102
- :host([small]) {
103
- font-size: var(--gv-theme-font-size-s, 12px);
104
- }
105
-
106
- .box {
107
- display: inline-block;
108
- width: 100%;
109
- }
110
-
111
- gv-input {
112
- width: 160px;
113
- margin: 0;
114
- }
115
-
116
- .time gv-input {
117
- width: 205px;
118
- }
119
-
120
- :not(.range) gv-input {
121
- width: 100%;
122
- }
123
-
124
- .range gv-input {
125
- --gv-input--bds: none;
126
- --gv-input--bdw: 0;
127
- }
128
-
129
- .time .range-input gv-input {
130
- width: 150px;
131
- }
132
-
133
- .range-input gv-input {
134
- width: 120px;
135
- }
136
-
137
- .range.hasFrom.open gv-input:first-of-type,
138
- .range.hasFrom.open .box-icon:first-of-type {
139
- border-bottom: 1px solid var(--gv-date-picker-selected--bgc, var(--gv-theme-color, #5a7684));
140
- }
141
-
142
- .range.hasTo.open gv-input:last-of-type,
143
- .range.hasTo.open .box-icon:not(.box-icon-calendar) {
144
- border-bottom: 1px solid var(--gv-date-picker-selected--bgc, var(--gv-theme-color, #5a7684));
145
- }
146
-
147
- .range-input {
148
- position: relative;
149
- z-index: 10;
150
- border: var(--gv-input--bdw, 1px) var(--gv-input--bds, solid) var(--gv-input--bdc, var(--gv-theme-neutral-color-dark, #d9d9d9));
151
- border-radius: 4px;
152
- margin: 0.2rem;
153
- display: flex;
154
- }
155
-
156
- .box-icon {
157
- display: flex;
158
- justify-content: center;
159
- align-items: center;
160
- }
161
-
162
- .box-icon-calendar {
163
- padding: 0 6px;
164
- }
165
-
166
- .box-icon-arrow,
167
- .box-icon-calendar {
168
- }
169
-
170
- .box-icon-clear {
171
- --gv-icon--s: 16px;
172
- padding-right: 6px;
173
- width: 22px;
174
- }
175
-
176
- .box-icon-clear gv-icon {
177
- cursor: pointer;
178
- }
179
-
180
- .box.open .calendar {
181
- visibility: visible;
182
- opacity: 1;
183
- -webkit-transform: -webkit-translateY(0%);
184
- transform: translateY(0%);
185
- z-index: 100;
186
- }
187
-
188
- .calendar {
189
- background-color: var(--gv-theme-neutral-color-lightest, #ffffff);
190
- color: var(--gv-theme-font-color, #262626);
191
- margin: 0.2rem;
192
- position: absolute;
193
- box-shadow: 0 0 0 1px var(--gv-theme-neutral-color, #f5f5f5), 0 1px 3px var(--gv-theme-neutral-color-dark, #bfbfbf);
194
- border-radius: 2px;
195
- display: flex;
196
- cursor: pointer;
197
- visibility: hidden;
198
- opacity: 0;
199
- -webkit-transform: -webkit-translateY(-2em);
200
- transform: translateY(-2em);
201
- -webkit-transition: -webkit-transform 150ms ease-in-out, opacity 150ms ease-in-out;
202
- -moz-transition: all 150ms ease-in-out;
203
- -ms-transition: all 150ms ease-in-out;
204
- -o-transition: all 150ms ease-in-out;
205
- overflow: auto;
206
- position: absolute;
207
- }
208
-
209
- :host([invalid]) .range-input {
210
- border-left: 5px solid #a94442;
211
- padding-left: 0;
212
- }
213
-
214
- :host([invalid]) .box-icon-calendar {
215
- padding-left: 2px;
216
- }
217
- `,
218
- ];
219
- }
220
-
221
- constructor() {
222
- super();
223
- this._id = 'gv-id';
224
- this.strict = false;
225
- this.range = false;
226
- this.time = false;
227
- this.format = 'dd/MM/yyyy';
228
- const format = i18n('gv-date-picker.format');
229
- if (format !== 'unknown') {
230
- this.format = format;
231
- }
232
- this.timeFormat = 'HH:mm';
233
- this.strictTimeFormat = 'HH:mm:ss';
234
- this.handleClick = this._onClick.bind(this);
235
- this.handleDocumentClick = this._onDocumentClick.bind(this);
236
- this.disabledDates = [];
237
- }
238
-
239
- connectedCallback() {
240
- super.connectedCallback();
241
- this.addEventListener('click', this.handleClick);
242
- document.addEventListener('click', this.handleDocumentClick);
243
- this.getLocale().then((locale) => {
244
- this._year = format(new Date().getTime(), 'yyyy', { locale });
245
- this._month = format(new Date().getTime(), 'MM', { locale });
246
- });
247
- }
248
-
249
- disconnectedCallback() {
250
- clearInterval(this._distanceTimer);
251
- this.removeEventListener('click', this.handleClick);
252
- document.removeEventListener('click', this.handleDocumentClick);
253
- super.disconnectedCallback();
254
- }
255
-
256
- set min(value) {
257
- this._min = parseInt(value / 1000, 10);
258
- }
259
-
260
- set max(value) {
261
- this._max = parseInt(value / 1000, 10);
262
- }
263
-
264
- set distanceFromNow(value) {
265
- this._distance = value;
266
- this._max = parseInt(Date.now() / 1000, 10);
267
- this._min = parseInt((Date.now() - value) / 1000, 10);
268
- if (this._from && this._from < this._min) {
269
- this._from = this._min;
270
- }
271
- }
272
-
273
- _onClick(e) {
274
- e.preventDefault();
275
- e.stopPropagation();
276
- }
277
-
278
- _onDocumentClick(e) {
279
- this._open = false;
280
- this.performUpdate();
281
- }
282
-
283
- _onFocus(mode) {
284
- this._open = true;
285
- if (this.time && this.range) {
286
- this._mode = mode;
287
- }
288
- this.performUpdate();
289
- }
290
-
291
- async getLocale() {
292
- const lang = getLanguage();
293
- if (!lang) {
294
- return locales.en;
295
- }
296
- if (!locales[lang]) {
297
- try {
298
- const locale = await import(`date-fns/locale/${lang}/index.js`);
299
- locales[lang] = locale.default;
300
- } catch (e) {
301
- console.error(`[Error] cannot load locale ${lang}`, e);
302
- }
303
- }
304
- return locales[lang];
305
- }
306
-
307
- get dateFromPlaceholder() {
308
- if (this.range && this.time && this.strict) {
309
- return i18n('gv-date-picker.startTime');
310
- }
311
- if (this.range) {
312
- return i18n('gv-date-picker.startDate');
313
- }
314
- return this.getFormat();
315
- }
316
-
317
- get dateToPlaceholder() {
318
- if (this.range && this.time && this.strict) {
319
- return i18n('gv-date-picker.endTime');
320
- }
321
- if (this.range) {
322
- return i18n('gv-date-picker.endDate');
323
- }
324
- return this.getFormat();
325
- }
326
-
327
- get icon() {
328
- return this._from != null || this._to != null ? 'code:error' : 'general:calendar';
329
- }
330
-
331
- get hasContent() {
332
- return this._from != null || this._to != null;
333
- }
334
-
335
- _onClear() {
336
- this.invalid = false;
337
- this.value = null;
338
- this.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
339
- dispatchCustomEvent(this, 'input', this.value);
340
- }
341
-
342
- render() {
343
- const classes = {
344
- box: true,
345
- open: this._open,
346
- range: this.range,
347
- time: this.time,
348
- hasFrom: this.hasFrom(),
349
- hasTo: this.hasTo(),
350
- };
351
-
352
- return html` <div class="${classMap(classes)}">
353
- ${this.range
354
- ? html`
355
- ${this.label ? html`<label for=${this._id} title="${this.label}">${this.label}</label>` : ''}
356
- <div class="range-input">
357
- <div class="box-icon box-icon-calendar"><gv-icon shape="general:calendar"></gv-icon></div>
358
- <gv-input
359
- id="${this._id}"
360
- ?small="${this.small}"
361
- ?disabled="${this.disabled}"
362
- @focus="${this._onFocus.bind(this, 'from')}"
363
- @blur="${this._onBlurForm}"
364
- @gv-input:submit="${this._onBlurForm}"
365
- .value="${until(this.getFormattedDate(this._from))}"
366
- .placeholder="${this.dateFromPlaceholder}"
367
- ></gv-input>
368
- <div class="box-icon box-icon-arrow"><gv-icon shape="navigation:arrow-right"></gv-icon></div>
369
- <gv-input
370
- .placeholder="${this.dateToPlaceholder}"
371
- ?small="${this.small}"
372
- ?disabled="${this.disabled}"
373
- @focus="${this._onFocus.bind(this, 'to')}"
374
- @blur="${this._onBlurTo}"
375
- @gv-input:submit="${this._onBlurTo}"
376
- .value="${until(this.getFormattedDate(this._to))}"
377
- ></gv-input>
378
- <div class="box-icon box-icon-clear">
379
- ${this.hasContent ? html`<gv-icon class="link" @click=${this._onClear} shape="code:error"></gv-icon>` : ''}
380
- </div>
381
- </div>
382
- `
383
- : html`
384
- <gv-input
385
- id="${this._id}"
386
- icon="${this.time && this.strict ? 'home:timer' : 'general:calendar'}"
387
- ?small="${this.small}"
388
- ?disabled="${this.disabled}"
389
- clearable
390
- .label="${this.label}"
391
- @focus="${this._onFocus.bind(this, null)}"
392
- @blur="${this._onBlurForm}"
393
- ?invalid="${this.invalid}"
394
- @gv-input:submit="${this._onBlurForm}"
395
- @gv-input:clear="${this._onClear}"
396
- .placeholder="${this.dateToPlaceholder}"
397
- .value="${until(this.getFormattedDate(this._from))}"></gv-input></div>
398
- `}
399
-
400
- <span class="calendar">
401
- ${this.range
402
- ? html`
403
- ${this.hasFrom()
404
- ? html`<gv-date-picker-calendar
405
- .disabledDates="${this.disabledDates}"
406
- .min="${this._min}"
407
- .max="${this._max}"
408
- ?time="${this.time}"
409
- ?strict="${this.strict}"
410
- ?small="${this.small}"
411
- ?prev="${true}"
412
- ?next="${this.time}"
413
- ?range="${this.range && !this.time}"
414
- .month="${this._month}"
415
- .year="${this._year}"
416
- .hoveredDate="${this._hoveredDate}"
417
- .dateTo="${this._to}"
418
- .dateFrom="${this._from}"
419
- .locale="${until(this.getLocale())}"
420
- @gv-date-picker-calendar:month-mode="${this._onMonthMode}"
421
- @gv-date-picker-calendar:year-mode="${this._onYearMode}"
422
- @gv-date-picker-calendar:month-changed="${this._onMonthChanged}"
423
- @gv-date-picker-calendar:year-changed="${this._onYearChanged}"
424
- @hovered-date-changed="${this.hoveredDateChanged}"
425
- @date-to-changed="${this.dateToChanged}"
426
- @date-from-changed="${this.dateFromChanged}"
427
- >
428
- </gv-date-picker-calendar>`
429
- : ''}
430
- ${this.hasTo()
431
- ? html`<gv-date-picker-calendar
432
- .disabledDates="${this.disabledDates}"
433
- .min="${this._min}"
434
- .max="${this._max}"
435
- ?time="${this.time}"
436
- ?strict="${this.strict}"
437
- ?small="${this.small}"
438
- ?prev="${this.time}"
439
- ?next="${true}"
440
- ?range="${this.range && !this.time}"
441
- .month="${this._monthPlus}"
442
- .year="${this._yearPlus}"
443
- .hoveredDate="${this._hoveredDate}"
444
- .dateTo="${this._to}"
445
- .dateFrom="${this._from}"
446
- .locale="${until(this.getLocale())}"
447
- @gv-date-picker-calendar:month-mode="${this._onMonthMode}"
448
- @gv-date-picker-calendar:year-mode="${this._onYearMode}"
449
- @gv-date-picker-calendar:month-changed="${this._onMonthChanged}"
450
- @gv-date-picker-calendar:year-changed="${this._onYearChanged}"
451
- @hovered-date-changed="${this.hoveredDateChanged}"
452
- @date-to-changed="${this.dateToChanged}"
453
- @date-from-changed="${this.dateFromChanged}"
454
- >
455
- </gv-date-picker-calendar>`
456
- : ''}
457
- `
458
- : html`
459
- <gv-date-picker-calendar
460
- .disabledDates="${this.disabledDates}"
461
- .min="${this._min}"
462
- .max="${this._max}"
463
- ?time="${this.time}"
464
- ?small="${this.small}"
465
- ?strict="${this.strict}"
466
- ?prev="${true}"
467
- ?next="${true}"
468
- ?range="${this.range}"
469
- .month="${this._month}"
470
- .year="${this._year}"
471
- .hoveredDate="${this._hoveredDate}"
472
- .dateTo="${this._to}"
473
- .dateFrom="${this._from}"
474
- .locale="${until(this.getLocale())}"
475
- @hovered-date-changed="${this.hoveredDateChanged}"
476
- @date-to-changed="${this.dateToChanged}"
477
- @date-from-changed="${this.dateFromChanged}"
478
- >
479
- </gv-date-picker-calendar>
480
- `}
481
- </span>
482
- </div>`;
483
- }
484
-
485
- hasFrom() {
486
- return this._mode == null || this._mode === 'from';
487
- }
488
-
489
- hasTo() {
490
- return this._mode == null || this._mode === 'to';
491
- }
492
-
493
- firstUpdated() {
494
- if (this.time && this.range) {
495
- this._mode = 'from';
496
- }
497
-
498
- if (this._distance) {
499
- this._distanceTimer = setInterval(() => {
500
- this.distanceFromNow = this._distance;
501
- }, 30000);
502
- }
503
- }
504
-
505
- monthChanged(month, year) {
506
- if (year && month) {
507
- const add = this.time && this.range ? 0 : 1;
508
- const monthPlus = `0${(month % 12) + add}`;
509
- this._monthPlus = monthPlus.substring(monthPlus.length - 2);
510
- if (this._monthPlus === '01') {
511
- this._yearPlus = parseInt(year, 10) + add;
512
- } else {
513
- this._yearPlus = parseInt(year, 10);
514
- }
515
- }
516
- }
517
-
518
- updated(properties) {
519
- if (properties.has('_month') || properties.has('_year')) {
520
- this.monthChanged(this._month, this._year);
521
- }
522
- if (properties.has('value')) {
523
- if (this.value == null || (this.value.filter && this.value.filter((v) => v != null).length === 0)) {
524
- this._from = null;
525
- this._to = null;
526
- } else {
527
- if (this.range) {
528
- this._from = this.value && this.value.length > 0 ? this.value[0] / 1000 : null;
529
- this._to = this.value && this.value.length > 1 ? this.value[1] / 1000 : null;
530
- } else {
531
- this._from = this.value / 1000;
532
- }
533
- }
534
- }
535
- }
536
-
537
- _onMonthChanged({ detail }) {
538
- this._month = detail.month;
539
- this._year = detail.year;
540
- this._hoveredDate = null;
541
- if (!(this.range && this.time)) {
542
- this._mode = null;
543
- }
544
- }
545
-
546
- _onYearChanged({ detail }) {
547
- this._year = detail.year;
548
- }
549
-
550
- _onMonthMode({ detail }) {
551
- if (this.time && this.range) {
552
- this._month = detail.month;
553
- this._year = detail.year;
554
- }
555
- }
556
-
557
- _onYearMode({ detail }) {
558
- if (this.time && this.range) {
559
- this._month = detail.month;
560
- this._year = detail.year;
561
- }
562
- }
563
-
564
- _onBlurForm({ target }) {
565
- const value = target.value;
566
- if (value) {
567
- const date = this.parseValue(value);
568
- if (date && !isNaN(date)) {
569
- this._month = (getMonth(date) + 1).toString();
570
- this._year = getYear(date).toString();
571
- this._from = date.getTime() / 1000;
572
- this.invalid = isInvalid(this._from, this._min, this._max, !this.time);
573
- }
574
- }
575
- }
576
-
577
- _onBlurTo({ target }) {
578
- const value = target.value;
579
- if (value) {
580
- const date = this.parseValue(value);
581
- if (date && !isNaN(date)) {
582
- this._month = (getMonth(date) + 1).toString();
583
- this._year = getYear(date).toString();
584
- this._to = date.getTime() / 1000;
585
- this.invalid = isInvalid(this._to, this._min, this._max, !this.time);
586
- }
587
- }
588
- }
589
-
590
- hoveredDateChanged({ detail }) {
591
- this._hoveredDate = detail.value;
592
- }
593
-
594
- dateFromChanged({ detail }) {
595
- if (this.time && this.range) {
596
- if (this._mode === 'from') {
597
- this._from = detail.value;
598
- const inputs = this.shadowRoot.querySelectorAll('.range-input gv-input');
599
- inputs[inputs.length - 1].focus();
600
- setTimeout(() => (this._mode = 'to'), 0);
601
- } else {
602
- this._to = detail.value;
603
- this._open = false;
604
- if (this._to < this._from) {
605
- const tmp = this._to;
606
- this._to = this._from;
607
- this._from = tmp;
608
- }
609
- }
610
- } else if (!this.range) {
611
- this._from = detail.value;
612
- this._open = false;
613
- } else {
614
- this._from = detail.value;
615
- }
616
- if (this._distance) {
617
- this.distanceFromNow = this._distance;
618
- }
619
-
620
- if (this.range) {
621
- this.value = [this._from * 1000, this._to * 1000];
622
- this.invalid =
623
- isInvalid(this._to, this._min, this._max, !this.time) ||
624
- isInvalid(this._from, this._min, this._max, !this.time) ||
625
- this._to === this._form;
626
- } else {
627
- this.value = this._from * 1000;
628
- this.invalid = isInvalid(this._from, this._min, this._max, !this.time);
629
- }
630
- this.valid = !this.invalid;
631
- this.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
632
- dispatchCustomEvent(this, 'input', this.value);
633
- }
634
-
635
- dateToChanged({ detail }) {
636
- if (this._distance) {
637
- this.distanceFromNow = this._distance;
638
- }
639
- this._to = detail.value;
640
- if (this._to) {
641
- this._open = false;
642
- this.value = [this._from * 1000, this._to * 1000];
643
- this.dispatchEvent(new Event('input', { bubbles: true, cancelable: true }));
644
- dispatchCustomEvent(this, 'input', this.value);
645
- }
646
- }
647
-
648
- getFormat() {
649
- if (this.time && this.strict) {
650
- return this.strictTimeFormat;
651
- }
652
- return this.time ? `${this.format} ${this.timeFormat}` : this.format;
653
- }
654
-
655
- async getFormattedDate(date) {
656
- if (date) {
657
- const locale = await this.getLocale();
658
- return format(new Date(date * 1000), this.getFormat(), locale);
659
- }
660
- return '';
661
- }
662
-
663
- parseValue(value) {
664
- if (value) {
665
- return parse(value, this.getFormat(), new Date());
666
- }
667
- return '';
668
- }
669
- }
670
-
671
- window.customElements.define('gv-date-picker', GvDatePicker);
1
+ var t=Object.create?function(t,e,i,a){void 0===a&&(a=i),Object.defineProperty(t,a,{enumerable:!0,get:function(){return e[i]}})}:function(t,e,i,a){void 0===a&&(a=i),t[a]=e[i]},e=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e},i=function(i){if(i&&i.__esModule)return i;var a={};if(null!=i)for(var s in i)"default"!==s&&Object.prototype.hasOwnProperty.call(i,s)&&t(a,i,s);return e(a,i),a},a=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvDatePicker=void 0,require("./gv-date-picker-calendar");const s=a(require("date-fns/locale/en-US")),n=require("date-fns"),r=require("lit/directives/class-map"),o=require("lit"),h=require("../lib/i18n"),l=require("../lib/date"),d=require("lit/directives/until"),c=require("../lib/events"),m={en:s.default};class u extends o.LitElement{static get properties(){return{range:{type:Boolean},label:{type:String},name:{type:String},time:{type:Boolean},strict:{type:Boolean},small:{type:Boolean},value:{type:Array,reflect:!0},min:{type:Number},max:{type:Number},distanceFromNow:{type:Number},disabledDates:{type:Array},format:{type:String},invalid:{type:Boolean,reflect:!0},valid:{type:Boolean,reflect:!0},_hoveredDate:{type:String,attribute:!1},_open:{type:Boolean,attribute:!1},_month:{type:String,attribute:!1},_year:{type:String,attribute:!1},_monthPlus:{type:String,attribute:!1},_yearPlus:{type:Number,attribute:!1},_mode:{type:String,attribute:!1},_from:{type:Number,attribute:!1},_to:{type:Number,attribute:!1},_min:{type:Number,attribute:!1},_max:{type:Number,attribute:!1},_distance:{type:Number,attribute:!1}}}static get styles(){return[o.css`:host{box-sizing:border-box;display:inline-block;margin:.2rem;--gv-input-icon--bgc:transparent;--gv-icon--s:22px;--date-picker-hover--bgc:var(--gv-date-picker-hover--bgc, var(--gv-theme-color-light, #86c3d0));--date-picker-hover--c:var(--gv-date-picker-hover--c, var(--gv-theme-font-color-dark, #262626));--date-picker-selected--bgc:var(--gv-date-picker-selected--bgc, var(--gv-theme-color, #5a7684));--date-picker-selected--c:var(--gv-date-picker-selected--c, var(--gv-theme-font-color-light, #ffffff));font-size:var(--gv-theme-font-size-m,14px)}:host([small]){font-size:var(--gv-theme-font-size-s,12px)}.box{display:inline-block;width:100%}gv-input{width:160px;margin:0}.time gv-input{width:205px}:not(.range) gv-input{width:100%}.range gv-input{--gv-input--bds:none;--gv-input--bdw:0}.time .range-input gv-input{width:150px}.range-input gv-input{width:120px}.range.hasFrom.open .box-icon:first-of-type,.range.hasFrom.open gv-input:first-of-type{border-bottom:1px solid var(--gv-date-picker-selected--bgc,var(--gv-theme-color,#5a7684))}.range.hasTo.open .box-icon:not(.box-icon-calendar),.range.hasTo.open gv-input:last-of-type{border-bottom:1px solid var(--gv-date-picker-selected--bgc,var(--gv-theme-color,#5a7684))}.range-input{position:relative;z-index:10;border:var(--gv-input--bdw,1px) var(--gv-input--bds,solid) var(--gv-input--bdc,var(--gv-theme-neutral-color-dark,#d9d9d9));border-radius:4px;margin:.2rem;display:flex}.box-icon{display:flex;justify-content:center;align-items:center}.box-icon-calendar{padding:0 6px}.box-icon-clear{--gv-icon--s:16px;padding-right:6px;width:22px}.box-icon-clear gv-icon{cursor:pointer}.box.open .calendar{visibility:visible;opacity:1;-webkit-transform:-webkit-translateY(0);transform:translateY(0);z-index:100}.calendar{background-color:var(--gv-theme-neutral-color-lightest,#fff);color:var(--gv-theme-font-color,#262626);margin:.2rem;position:absolute;box-shadow:0 0 0 1px var(--gv-theme-neutral-color,#f5f5f5),0 1px 3px var(--gv-theme-neutral-color-dark,#bfbfbf);border-radius:2px;display:flex;cursor:pointer;visibility:hidden;opacity:0;-webkit-transform:-webkit-translateY(-2em);transform:translateY(-2em);-webkit-transition:-webkit-transform 150ms ease-in-out,opacity 150ms ease-in-out;-moz-transition:all 150ms ease-in-out;-ms-transition:all 150ms ease-in-out;-o-transition:all 150ms ease-in-out;overflow:auto;position:absolute}:host([invalid]) .range-input{border-left:5px solid #a94442;padding-left:0}:host([invalid]) .box-icon-calendar{padding-left:2px}`]}constructor(){super(),this._id="gv-id",this.strict=!1,this.range=!1,this.time=!1,this.format="dd/MM/yyyy";const t=(0,h.i18n)("gv-date-picker.format");"unknown"!==t&&(this.format=t),this.timeFormat="HH:mm",this.strictTimeFormat="HH:mm:ss",this.handleClick=this._onClick.bind(this),this.handleDocumentClick=this._onDocumentClick.bind(this),this.disabledDates=[]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleClick),document.addEventListener("click",this.handleDocumentClick),this.getLocale().then((t=>{this._year=(0,n.format)((new Date).getTime(),"yyyy",{locale:t}),this._month=(0,n.format)((new Date).getTime(),"MM",{locale:t})}))}disconnectedCallback(){clearInterval(this._distanceTimer),this.removeEventListener("click",this.handleClick),document.removeEventListener("click",this.handleDocumentClick),super.disconnectedCallback()}set min(t){this._min=parseInt(t/1e3,10)}set max(t){this._max=parseInt(t/1e3,10)}set distanceFromNow(t){this._distance=t,this._max=parseInt(Date.now()/1e3,10),this._min=parseInt((Date.now()-t)/1e3,10),this._from&&this._from<this._min&&(this._from=this._min)}_onClick(t){t.preventDefault(),t.stopPropagation()}_onDocumentClick(t){this._open=!1,this.performUpdate()}_onFocus(t){this._open=!0,this.time&&this.range&&(this._mode=t),this.performUpdate()}async getLocale(){const t=(0,h.getLanguage)();if(!t)return m.en;if(!m[t])try{const e=await Promise.resolve().then((()=>i(require(`date-fns/locale/${t}/index.js`))));m[t]=e.default}catch(e){console.error(`[Error] cannot load locale ${t}`,e)}return m[t]}get dateFromPlaceholder(){return this.range&&this.time&&this.strict?(0,h.i18n)("gv-date-picker.startTime"):this.range?(0,h.i18n)("gv-date-picker.startDate"):this.getFormat()}get dateToPlaceholder(){return this.range&&this.time&&this.strict?(0,h.i18n)("gv-date-picker.endTime"):this.range?(0,h.i18n)("gv-date-picker.endDate"):this.getFormat()}get icon(){return null!=this._from||null!=this._to?"code:error":"general:calendar"}get hasContent(){return null!=this._from||null!=this._to}_onClear(){this.invalid=!1,this.value=null,this.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),(0,c.dispatchCustomEvent)(this,"input",this.value)}render(){const t={box:!0,open:this._open,range:this.range,time:this.time,hasFrom:this.hasFrom(),hasTo:this.hasTo()};return o.html`<div class="${(0,r.classMap)(t)}">${this.range?o.html`${this.label?o.html`<label for="${this._id}" title="${this.label}">${this.label}</label>`:""}<div class="range-input"><div class="box-icon box-icon-calendar"><gv-icon shape="general:calendar"></gv-icon></div><gv-input id="${this._id}" ?small="${this.small}" ?disabled="${this.disabled}" @focus="${this._onFocus.bind(this,"from")}" @blur="${this._onBlurForm}" @gv-input:submit="${this._onBlurForm}" .value="${(0,d.until)(this.getFormattedDate(this._from))}" .placeholder="${this.dateFromPlaceholder}"></gv-input><div class="box-icon box-icon-arrow"><gv-icon shape="navigation:arrow-right"></gv-icon></div><gv-input .placeholder="${this.dateToPlaceholder}" ?small="${this.small}" ?disabled="${this.disabled}" @focus="${this._onFocus.bind(this,"to")}" @blur="${this._onBlurTo}" @gv-input:submit="${this._onBlurTo}" .value="${(0,d.until)(this.getFormattedDate(this._to))}"></gv-input><div class="box-icon box-icon-clear">${this.hasContent?o.html`<gv-icon class="link" @click="${this._onClear}" shape="code:error"></gv-icon>`:""}</div></div>`:o.html`<gv-input id="${this._id}" icon="${this.time&&this.strict?"home:timer":"general:calendar"}" ?small="${this.small}" ?disabled="${this.disabled}" clearable .label="${this.label}" @focus="${this._onFocus.bind(this,null)}" @blur="${this._onBlurForm}" ?invalid="${this.invalid}" @gv-input:submit="${this._onBlurForm}" @gv-input:clear="${this._onClear}" .placeholder="${this.dateToPlaceholder}" .value="${(0,d.until)(this.getFormattedDate(this._from))}"></gv-input>`} <span class="calendar">${this.range?o.html`${this.hasFrom()?o.html`<gv-date-picker-calendar .disabledDates="${this.disabledDates}" .min="${this._min}" .max="${this._max}" ?time="${this.time}" ?strict="${this.strict}" ?small="${this.small}" ?prev="${!0}" ?next="${this.time}" ?range="${this.range&&!this.time}" .month="${this._month}" .year="${this._year}" .hoveredDate="${this._hoveredDate}" .dateTo="${this._to}" .dateFrom="${this._from}" .locale="${(0,d.until)(this.getLocale())}" @gv-date-picker-calendar:month-mode="${this._onMonthMode}" @gv-date-picker-calendar:year-mode="${this._onYearMode}" @gv-date-picker-calendar:month-changed="${this._onMonthChanged}" @gv-date-picker-calendar:year-changed="${this._onYearChanged}" @hovered-date-changed="${this.hoveredDateChanged}" @date-to-changed="${this.dateToChanged}" @date-from-changed="${this.dateFromChanged}"></gv-date-picker-calendar>`:""} ${this.hasTo()?o.html`<gv-date-picker-calendar .disabledDates="${this.disabledDates}" .min="${this._min}" .max="${this._max}" ?time="${this.time}" ?strict="${this.strict}" ?small="${this.small}" ?prev="${this.time}" ?next="${!0}" ?range="${this.range&&!this.time}" .month="${this._monthPlus}" .year="${this._yearPlus}" .hoveredDate="${this._hoveredDate}" .dateTo="${this._to}" .dateFrom="${this._from}" .locale="${(0,d.until)(this.getLocale())}" @gv-date-picker-calendar:month-mode="${this._onMonthMode}" @gv-date-picker-calendar:year-mode="${this._onYearMode}" @gv-date-picker-calendar:month-changed="${this._onMonthChanged}" @gv-date-picker-calendar:year-changed="${this._onYearChanged}" @hovered-date-changed="${this.hoveredDateChanged}" @date-to-changed="${this.dateToChanged}" @date-from-changed="${this.dateFromChanged}"></gv-date-picker-calendar>`:""}`:o.html`<gv-date-picker-calendar .disabledDates="${this.disabledDates}" .min="${this._min}" .max="${this._max}" ?time="${this.time}" ?small="${this.small}" ?strict="${this.strict}" ?prev="${!0}" ?next="${!0}" ?range="${this.range}" .month="${this._month}" .year="${this._year}" .hoveredDate="${this._hoveredDate}" .dateTo="${this._to}" .dateFrom="${this._from}" .locale="${(0,d.until)(this.getLocale())}" @hovered-date-changed="${this.hoveredDateChanged}" @date-to-changed="${this.dateToChanged}" @date-from-changed="${this.dateFromChanged}"></gv-date-picker-calendar>`}</span></div>`}hasFrom(){return null==this._mode||"from"===this._mode}hasTo(){return null==this._mode||"to"===this._mode}firstUpdated(){this.time&&this.range&&(this._mode="from"),this._distance&&(this._distanceTimer=setInterval((()=>{this.distanceFromNow=this._distance}),3e4))}monthChanged(t,e){if(e&&t){const i=this.time&&this.range?0:1,a=`0${t%12+i}`;this._monthPlus=a.substring(a.length-2),"01"===this._monthPlus?this._yearPlus=parseInt(e,10)+i:this._yearPlus=parseInt(e,10)}}updated(t){(t.has("_month")||t.has("_year"))&&this.monthChanged(this._month,this._year),t.has("value")&&(null==this.value||this.value.filter&&0===this.value.filter((t=>null!=t)).length?(this._from=null,this._to=null):this.range?(this._from=this.value&&this.value.length>0?this.value[0]/1e3:null,this._to=this.value&&this.value.length>1?this.value[1]/1e3:null):this._from=this.value/1e3)}_onMonthChanged({detail:t}){this._month=t.month,this._year=t.year,this._hoveredDate=null,this.range&&this.time||(this._mode=null)}_onYearChanged({detail:t}){this._year=t.year}_onMonthMode({detail:t}){this.time&&this.range&&(this._month=t.month,this._year=t.year)}_onYearMode({detail:t}){this.time&&this.range&&(this._month=t.month,this._year=t.year)}_onBlurForm({target:t}){const e=t.value;if(e){const t=this.parseValue(e);t&&!isNaN(t)&&(this._month=((0,n.getMonth)(t)+1).toString(),this._year=(0,n.getYear)(t).toString(),this._from=t.getTime()/1e3,this.invalid=(0,l.isInvalid)(this._from,this._min,this._max,!this.time))}}_onBlurTo({target:t}){const e=t.value;if(e){const t=this.parseValue(e);t&&!isNaN(t)&&(this._month=((0,n.getMonth)(t)+1).toString(),this._year=(0,n.getYear)(t).toString(),this._to=t.getTime()/1e3,this.invalid=(0,l.isInvalid)(this._to,this._min,this._max,!this.time))}}hoveredDateChanged({detail:t}){this._hoveredDate=t.value}dateFromChanged({detail:t}){if(this.time&&this.range){if("from"===this._mode){this._from=t.value;const e=this.shadowRoot.querySelectorAll(".range-input gv-input");e[e.length-1].focus(),setTimeout((()=>this._mode="to"),0)}else if(this._to=t.value,this._open=!1,this._to<this._from){const t=this._to;this._to=this._from,this._from=t}}else this.range?this._from=t.value:(this._from=t.value,this._open=!1);this._distance&&(this.distanceFromNow=this._distance),this.range?(this.value=[1e3*this._from,1e3*this._to],this.invalid=(0,l.isInvalid)(this._to,this._min,this._max,!this.time)||(0,l.isInvalid)(this._from,this._min,this._max,!this.time)||this._to===this._form):(this.value=1e3*this._from,this.invalid=(0,l.isInvalid)(this._from,this._min,this._max,!this.time)),this.valid=!this.invalid,this.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),(0,c.dispatchCustomEvent)(this,"input",this.value)}dateToChanged({detail:t}){this._distance&&(this.distanceFromNow=this._distance),this._to=t.value,this._to&&(this._open=!1,this.value=[1e3*this._from,1e3*this._to],this.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),(0,c.dispatchCustomEvent)(this,"input",this.value))}getFormat(){return this.time&&this.strict?this.strictTimeFormat:this.time?`${this.format} ${this.timeFormat}`:this.format}async getFormattedDate(t){if(t){const e=await this.getLocale();return(0,n.format)(new Date(1e3*t),this.getFormat(),e)}return""}parseValue(t){return t?(0,n.parse)(t,this.getFormat(),new Date):""}}exports.GvDatePicker=u,window.customElements.define("gv-date-picker",u);