@esri/calcite-components 1.0.0-next.317 → 1.0.0-next.320

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 (110) hide show
  1. package/dist/calcite/assets/calcite-icon/centerAlign16.json +1 -0
  2. package/dist/calcite/assets/calcite-icon/centerAlign24.json +1 -0
  3. package/dist/calcite/assets/calcite-icon/centerAlign32.json +1 -0
  4. package/dist/calcite/assets/calcite-icon/convert16.json +1 -0
  5. package/dist/calcite/assets/calcite-icon/convert24.json +1 -0
  6. package/dist/calcite/assets/calcite-icon/convert32.json +1 -0
  7. package/dist/calcite/assets/calcite-icon/formDropdown16.json +1 -0
  8. package/dist/calcite/assets/calcite-icon/formDropdown24.json +1 -0
  9. package/dist/calcite/assets/calcite-icon/formDropdown32.json +1 -0
  10. package/dist/calcite/assets/calcite-icon/language16.json +1 -0
  11. package/dist/calcite/assets/calcite-icon/language24.json +1 -0
  12. package/dist/calcite/assets/calcite-icon/language32.json +1 -0
  13. package/dist/calcite/assets/calcite-icon/languageTranslate16.json +1 -0
  14. package/dist/calcite/assets/calcite-icon/languageTranslate24.json +1 -0
  15. package/dist/calcite/assets/calcite-icon/languageTranslate32.json +1 -0
  16. package/dist/calcite/assets/calcite-icon/leftAlign16.json +1 -0
  17. package/dist/calcite/assets/calcite-icon/leftAlign24.json +1 -0
  18. package/dist/calcite/assets/calcite-icon/leftAlign32.json +1 -0
  19. package/dist/calcite/assets/calcite-icon/terminal16.json +1 -0
  20. package/dist/calcite/assets/calcite-icon/terminal24.json +1 -0
  21. package/dist/calcite/assets/calcite-icon/terminal32.json +1 -0
  22. package/dist/calcite/assets/calcite-icon/touch16.json +1 -0
  23. package/dist/calcite/assets/calcite-icon/touch24.json +1 -0
  24. package/dist/calcite/assets/calcite-icon/touch32.json +1 -0
  25. package/dist/calcite/calcite.esm.js +1 -1
  26. package/dist/calcite/p-1480eb2d.entry.js +5 -0
  27. package/dist/calcite/p-2cd9d307.entry.js +5 -0
  28. package/dist/calcite/p-6e050609.entry.js +5 -0
  29. package/dist/calcite/p-8e252799.system.js +1 -1
  30. package/dist/calcite/p-96bbc815.system.entry.js +5 -0
  31. package/dist/calcite/p-cb55c32c.system.entry.js +5 -0
  32. package/dist/calcite/p-e817ded0.entry.js +5 -0
  33. package/dist/calcite/{p-44a07313.system.entry.js → p-f7b5dd98.system.entry.js} +1 -1
  34. package/dist/calcite/p-fa9a1d8f.system.entry.js +5 -0
  35. package/dist/cjs/calcite-action-bar.cjs.entry.js +24 -0
  36. package/dist/cjs/calcite-color-picker_3.cjs.entry.js +3 -3
  37. package/dist/cjs/calcite-input-time-picker_2.cjs.entry.js +349 -223
  38. package/dist/cjs/calcite-panel.cjs.entry.js +3 -3
  39. package/dist/cjs/calcite.cjs.js +1 -1
  40. package/dist/cjs/loader.cjs.js +1 -1
  41. package/dist/collection/components/calcite-action-bar/calcite-action-bar.js +3 -0
  42. package/dist/collection/components/calcite-filter/calcite-filter.js +1 -1
  43. package/dist/collection/components/calcite-icon/assets/calcite-icon/centerAlign16.json +1 -0
  44. package/dist/collection/components/calcite-icon/assets/calcite-icon/centerAlign24.json +1 -0
  45. package/dist/collection/components/calcite-icon/assets/calcite-icon/centerAlign32.json +1 -0
  46. package/dist/collection/components/calcite-icon/assets/calcite-icon/convert16.json +1 -0
  47. package/dist/collection/components/calcite-icon/assets/calcite-icon/convert24.json +1 -0
  48. package/dist/collection/components/calcite-icon/assets/calcite-icon/convert32.json +1 -0
  49. package/dist/collection/components/calcite-icon/assets/calcite-icon/formDropdown16.json +1 -0
  50. package/dist/collection/components/calcite-icon/assets/calcite-icon/formDropdown24.json +1 -0
  51. package/dist/collection/components/calcite-icon/assets/calcite-icon/formDropdown32.json +1 -0
  52. package/dist/collection/components/calcite-icon/assets/calcite-icon/language16.json +1 -0
  53. package/dist/collection/components/calcite-icon/assets/calcite-icon/language24.json +1 -0
  54. package/dist/collection/components/calcite-icon/assets/calcite-icon/language32.json +1 -0
  55. package/dist/collection/components/calcite-icon/assets/calcite-icon/languageTranslate16.json +1 -0
  56. package/dist/collection/components/calcite-icon/assets/calcite-icon/languageTranslate24.json +1 -0
  57. package/dist/collection/components/calcite-icon/assets/calcite-icon/languageTranslate32.json +1 -0
  58. package/dist/collection/components/calcite-icon/assets/calcite-icon/leftAlign16.json +1 -0
  59. package/dist/collection/components/calcite-icon/assets/calcite-icon/leftAlign24.json +1 -0
  60. package/dist/collection/components/calcite-icon/assets/calcite-icon/leftAlign32.json +1 -0
  61. package/dist/collection/components/calcite-icon/assets/calcite-icon/terminal16.json +1 -0
  62. package/dist/collection/components/calcite-icon/assets/calcite-icon/terminal24.json +1 -0
  63. package/dist/collection/components/calcite-icon/assets/calcite-icon/terminal32.json +1 -0
  64. package/dist/collection/components/calcite-icon/assets/calcite-icon/touch16.json +1 -0
  65. package/dist/collection/components/calcite-icon/assets/calcite-icon/touch24.json +1 -0
  66. package/dist/collection/components/calcite-icon/assets/calcite-icon/touch32.json +1 -0
  67. package/dist/collection/components/calcite-input-time-picker/calcite-input-time-picker.js +81 -76
  68. package/dist/collection/components/calcite-panel/calcite-panel.js +3 -3
  69. package/dist/collection/components/calcite-time-picker/calcite-time-picker.css +56 -91
  70. package/dist/collection/components/calcite-time-picker/calcite-time-picker.js +254 -289
  71. package/dist/collection/components/calcite-time-picker/resources.js +15 -9
  72. package/dist/collection/utils/conditionalSlot.js +26 -0
  73. package/dist/collection/utils/time.js +144 -36
  74. package/dist/components/calcite-action-bar.js +25 -1
  75. package/dist/components/calcite-color-picker-swatch2.js +3 -3
  76. package/dist/components/calcite-input-time-picker.js +51 -48
  77. package/dist/components/calcite-panel.js +3 -3
  78. package/dist/components/calcite-time-picker2.js +320 -187
  79. package/dist/custom-elements/index.js +381 -231
  80. package/dist/esm/calcite-action-bar.entry.js +25 -1
  81. package/dist/esm/calcite-color-picker_3.entry.js +3 -3
  82. package/dist/esm/calcite-input-time-picker_2.entry.js +349 -223
  83. package/dist/esm/calcite-panel.entry.js +3 -3
  84. package/dist/esm/calcite.js +1 -1
  85. package/dist/esm/loader.js +1 -1
  86. package/dist/esm-es5/calcite-action-bar.entry.js +1 -1
  87. package/dist/esm-es5/calcite-color-picker_3.entry.js +1 -1
  88. package/dist/esm-es5/calcite-input-time-picker_2.entry.js +2 -2
  89. package/dist/esm-es5/calcite-panel.entry.js +1 -1
  90. package/dist/esm-es5/calcite.js +1 -1
  91. package/dist/esm-es5/loader.js +1 -1
  92. package/dist/extras/docs-json.json +23 -101
  93. package/dist/types/components/calcite-action-bar/calcite-action-bar.d.ts +2 -1
  94. package/dist/types/components/calcite-input-time-picker/calcite-input-time-picker.d.ts +12 -4
  95. package/dist/types/components/calcite-panel/calcite-panel.d.ts +1 -1
  96. package/dist/types/components/calcite-time-picker/calcite-time-picker.d.ts +35 -23
  97. package/dist/types/components/calcite-time-picker/resources.d.ts +14 -8
  98. package/dist/types/components.d.ts +17 -41
  99. package/dist/types/utils/conditionalSlot.d.ts +17 -0
  100. package/dist/types/utils/time.d.ts +18 -5
  101. package/hydrate/index.js +399 -239
  102. package/package.json +11 -11
  103. package/readme.md +2 -2
  104. package/dist/calcite/p-12a9599d.system.entry.js +0 -5
  105. package/dist/calcite/p-88784777.system.entry.js +0 -5
  106. package/dist/calcite/p-9634f89d.entry.js +0 -5
  107. package/dist/calcite/p-b37b7b9e.system.entry.js +0 -5
  108. package/dist/calcite/p-e1da1646.entry.js +0 -5
  109. package/dist/calcite/p-e78e743b.entry.js +0 -5
  110. package/dist/calcite/p-f333e31b.entry.js +0 -5
@@ -2,11 +2,14 @@
2
2
  * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
4
4
  */
5
- import { Component, Element, Host, h, Prop, Event, Watch, State, Listen, Method } from "@stencil/core";
5
+ import { Component, Element, h, Prop, Event, Watch, State, Listen, Method } from "@stencil/core";
6
6
  import { isActivationKey, numberKeys } from "../../utils/key";
7
7
  import { isValidNumber } from "../../utils/number";
8
- import { formatTimePart, maxTenthForMinuteAndSecond, getMeridiem, getMeridiemHour } from "../../utils/time";
8
+ import { formatTimePart, maxTenthForMinuteAndSecond, getMeridiem, isValidTime, localizeTimeStringToParts, parseTimeString, localizeTimePart, getLocaleHourCycle } from "../../utils/time";
9
9
  import { CSS, TEXT } from "./resources";
10
+ function capitalize(str) {
11
+ return str.charAt(0).toUpperCase() + str.slice(1);
12
+ }
10
13
  export class CalciteTimePicker {
11
14
  constructor() {
12
15
  //--------------------------------------------------------------------------
@@ -14,10 +17,6 @@ export class CalciteTimePicker {
14
17
  // Properties
15
18
  //
16
19
  //--------------------------------------------------------------------------
17
- /** The hour value (24-hour format) */
18
- this.hour = null;
19
- /** Format of the hour value (12-hour or 24-hour) (this will be replaced by locale eventually) */
20
- this.hourDisplayFormat = "12";
21
20
  /** aria-label for the hour input
22
21
  * @default "Hour"
23
22
  */
@@ -66,35 +65,25 @@ export class CalciteTimePicker {
66
65
  * @default "Increase second"
67
66
  */
68
67
  this.intlSecondUp = TEXT.secondUp;
69
- /** The minute value */
70
- this.minute = null;
71
- /** The second value */
72
- this.second = null;
68
+ /**
69
+ * BCP 47 language tag for desired language and country format
70
+ * @internal
71
+ */
72
+ this.locale = document.documentElement.lang || navigator.language || "en";
73
73
  /** The scale (size) of the time picker */
74
74
  this.scale = "m";
75
75
  /** number that specifies the granularity that the value must adhere to */
76
76
  this.step = 60;
77
- this.timeChanged = false;
78
- // --------------------------------------------------------------------------
79
- //
80
- // State
81
- //
82
- // --------------------------------------------------------------------------
83
- /** The am/pm value */
84
- this.meridiem = null;
85
- this.displayHour = this.getDisplayHour();
86
- // --------------------------------------------------------------------------
87
- //
88
- // Private Methods
89
- //
90
- // --------------------------------------------------------------------------
77
+ /** The selected time in UTC */
78
+ this.value = null;
79
+ this.showSecond = this.step < 60;
91
80
  this.decrementHour = () => {
92
81
  const newHour = !this.hour ? 0 : this.hour === "00" ? 23 : parseInt(this.hour) - 1;
93
- this.setTime("hour", newHour);
82
+ this.setValuePart("hour", newHour);
94
83
  };
95
84
  this.decrementMeridiem = () => {
96
85
  const newMeridiem = this.meridiem === "PM" ? "AM" : "PM";
97
- this.setTime("meridiem", newMeridiem);
86
+ this.setValuePart("meridiem", newMeridiem);
98
87
  };
99
88
  this.decrementMinuteOrSecond = (key) => {
100
89
  let newValue;
@@ -105,7 +94,7 @@ export class CalciteTimePicker {
105
94
  else {
106
95
  newValue = 59;
107
96
  }
108
- this.setTime(key, newValue);
97
+ this.setValuePart(key, newValue);
109
98
  };
110
99
  this.decrementMinute = () => {
111
100
  this.decrementMinuteOrSecond("minute");
@@ -127,7 +116,7 @@ export class CalciteTimePicker {
127
116
  const keyAsNumber = parseInt(key);
128
117
  let newHour;
129
118
  if (isValidNumber(this.hour)) {
130
- switch (this.hourDisplayFormat) {
119
+ switch (this.hourCycle) {
131
120
  case "12":
132
121
  newHour =
133
122
  this.hour === "01" && keyAsNumber >= 0 && keyAsNumber <= 2
@@ -150,13 +139,13 @@ export class CalciteTimePicker {
150
139
  else {
151
140
  newHour = keyAsNumber;
152
141
  }
153
- this.setTime("hour", newHour);
142
+ this.setValuePart("hour", newHour);
154
143
  }
155
144
  else {
156
145
  switch (key) {
157
146
  case "Backspace":
158
147
  case "Delete":
159
- this.setTime("hour", null);
148
+ this.setValuePart("hour", null);
160
149
  break;
161
150
  case "ArrowDown":
162
151
  event.preventDefault();
@@ -180,7 +169,7 @@ export class CalciteTimePicker {
180
169
  };
181
170
  this.incrementMeridiem = () => {
182
171
  const newMeridiem = this.meridiem === "AM" ? "PM" : "AM";
183
- this.setTime("meridiem", newMeridiem);
172
+ this.setValuePart("meridiem", newMeridiem);
184
173
  };
185
174
  this.incrementHour = () => {
186
175
  const newHour = isValidNumber(this.hour)
@@ -188,7 +177,7 @@ export class CalciteTimePicker {
188
177
  ? 0
189
178
  : parseInt(this.hour) + 1
190
179
  : 1;
191
- this.setTime("hour", newHour);
180
+ this.setValuePart("hour", newHour);
192
181
  };
193
182
  this.incrementMinuteOrSecond = (key) => {
194
183
  const newValue = isValidNumber(this[key])
@@ -196,7 +185,7 @@ export class CalciteTimePicker {
196
185
  ? 0
197
186
  : parseInt(this[key]) + 1
198
187
  : 0;
199
- this.setTime(key, newValue);
188
+ this.setValuePart(key, newValue);
200
189
  };
201
190
  this.incrementMinute = () => {
202
191
  this.incrementMinuteOrSecond("minute");
@@ -212,14 +201,14 @@ export class CalciteTimePicker {
212
201
  this.meridiemKeyDownHandler = (event) => {
213
202
  switch (event.key) {
214
203
  case "a":
215
- this.setTime("meridiem", "AM");
204
+ this.setValuePart("meridiem", "AM");
216
205
  break;
217
206
  case "p":
218
- this.setTime("meridiem", "PM");
207
+ this.setValuePart("meridiem", "PM");
219
208
  break;
220
209
  case "Backspace":
221
210
  case "Delete":
222
- this.setTime("meridiem", null);
211
+ this.setValuePart("meridiem", null);
223
212
  break;
224
213
  case "ArrowUp":
225
214
  event.preventDefault();
@@ -260,13 +249,13 @@ export class CalciteTimePicker {
260
249
  else {
261
250
  newMinute = keyAsNumber;
262
251
  }
263
- this.setTime("minute", newMinute);
252
+ this.setValuePart("minute", newMinute);
264
253
  }
265
254
  else {
266
255
  switch (key) {
267
256
  case "Backspace":
268
257
  case "Delete":
269
- this.setTime("minute", null);
258
+ this.setValuePart("minute", null);
270
259
  break;
271
260
  case "ArrowDown":
272
261
  event.preventDefault();
@@ -308,13 +297,13 @@ export class CalciteTimePicker {
308
297
  else {
309
298
  newSecond = keyAsNumber;
310
299
  }
311
- this.setTime("second", newSecond);
300
+ this.setValuePart("second", newSecond);
312
301
  }
313
302
  else {
314
303
  switch (key) {
315
304
  case "Backspace":
316
305
  case "Delete":
317
- this.setTime("second", null);
306
+ this.setValuePart("second", null);
318
307
  break;
319
308
  case "ArrowDown":
320
309
  event.preventDefault();
@@ -336,59 +325,96 @@ export class CalciteTimePicker {
336
325
  this.incrementSecond();
337
326
  }
338
327
  };
339
- this.setTime = (key, value, emit = true) => {
340
- switch (key) {
341
- default:
342
- return;
343
- case "hour":
344
- this.hour = typeof value === "number" ? formatTimePart(value) : value;
345
- break;
346
- case "minute":
347
- this.minute = typeof value === "number" ? formatTimePart(value) : value;
348
- break;
349
- case "second":
350
- this.second = typeof value === "number" ? formatTimePart(value) : value;
351
- break;
352
- case "meridiem":
353
- if (isValidNumber(this.hour)) {
354
- const hourAsNumber = parseInt(this.hour);
355
- switch (value) {
356
- case "AM":
357
- if (hourAsNumber >= 12) {
358
- this.hour = formatTimePart(hourAsNumber - 12);
359
- }
360
- break;
361
- case "PM":
362
- if (hourAsNumber < 12) {
363
- this.hour = formatTimePart(hourAsNumber + 12);
364
- }
365
- break;
366
- }
367
- this.meridiem = value;
368
- }
369
- else {
370
- this.meridiem = value;
328
+ this.setHourEl = (el) => (this.hourEl = el);
329
+ this.setMeridiemEl = (el) => (this.meridiemEl = el);
330
+ this.setMinuteEl = (el) => (this.minuteEl = el);
331
+ this.setSecondEl = (el) => (this.secondEl = el);
332
+ this.setValue = (value, emit = true) => {
333
+ if (isValidTime(value)) {
334
+ const { hour, minute, second } = parseTimeString(value);
335
+ const { localizedHour, localizedHourSuffix, localizedMinute, localizedMinuteSuffix, localizedSecond, localizedSecondSuffix, localizedMeridiem } = localizeTimeStringToParts(value, this.locale);
336
+ this.localizedHour = localizedHour;
337
+ this.localizedHourSuffix = localizedHourSuffix;
338
+ this.localizedMinute = localizedMinute;
339
+ this.localizedMinuteSuffix = localizedMinuteSuffix;
340
+ this.localizedSecond = localizedSecond;
341
+ this.localizedSecondSuffix = localizedSecondSuffix;
342
+ this.hour = hour;
343
+ this.minute = minute;
344
+ this.second = second;
345
+ if (localizedMeridiem) {
346
+ this.localizedMeridiem = localizedMeridiem;
347
+ this.meridiem = getMeridiem(this.hour);
348
+ }
349
+ }
350
+ else {
351
+ this.hour = null;
352
+ this.localizedHour = null;
353
+ this.localizedHourSuffix = null;
354
+ this.localizedMeridiem = null;
355
+ this.localizedMinute = null;
356
+ this.localizedMinuteSuffix = null;
357
+ this.localizedSecond = null;
358
+ this.localizedSecondSuffix = null;
359
+ this.meridiem = null;
360
+ this.minute = null;
361
+ this.second = null;
362
+ this.value = null;
363
+ }
364
+ if (emit) {
365
+ this.calciteTimePickerChange.emit();
366
+ }
367
+ };
368
+ this.setValuePart = (key, value, emit = true) => {
369
+ var _a;
370
+ if (key === "meridiem") {
371
+ this.meridiem = value;
372
+ if (isValidNumber(this.hour)) {
373
+ const hourAsNumber = parseInt(this.hour);
374
+ switch (value) {
375
+ case "AM":
376
+ if (hourAsNumber >= 12) {
377
+ this.hour = formatTimePart(hourAsNumber - 12);
378
+ }
379
+ break;
380
+ case "PM":
381
+ if (hourAsNumber < 12) {
382
+ this.hour = formatTimePart(hourAsNumber + 12);
383
+ }
384
+ break;
371
385
  }
372
- break;
386
+ this.localizedHour = localizeTimePart(this.hour, "hour", this.locale);
387
+ }
388
+ }
389
+ else {
390
+ this[key] = typeof value === "number" ? formatTimePart(value) : value;
391
+ this[`localized${capitalize(key)}`] = localizeTimePart(this[key], key, this.locale);
373
392
  }
374
- this.timeChanged = true;
393
+ if (this.hour && this.minute) {
394
+ const showSeconds = this.second && this.showSecond;
395
+ this.value = `${this.hour}:${this.minute}:${showSeconds ? this.second : "00"}`;
396
+ }
397
+ else {
398
+ this.value = null;
399
+ }
400
+ this.localizedMeridiem = this.value
401
+ ? ((_a = localizeTimeStringToParts(this.value, this.locale)) === null || _a === void 0 ? void 0 : _a.localizedMeridiem) || null
402
+ : localizeTimePart(this.meridiem, "meridiem", this.locale);
375
403
  if (emit) {
376
- this.calciteTimePickerChange.emit(this.getTime());
404
+ this.calciteTimePickerChange.emit();
377
405
  }
378
406
  };
379
407
  }
380
- hourChanged(newHour) {
381
- if (this.hourDisplayFormat === "12" && isValidNumber(newHour)) {
382
- this.meridiem = getMeridiem(newHour);
383
- }
408
+ localeWatcher(newLocale) {
409
+ this.hourCycle = getLocaleHourCycle(newLocale);
410
+ this.setValue(this.value, false);
384
411
  }
385
- timeChangeHandler() {
386
- const { hour, minute } = this.getTime();
387
- if (!hour && !minute) {
388
- this.setTime("meridiem", null, false);
389
- }
390
- if (this.timeChanged) {
391
- this.timeChanged = false;
412
+ valueWatcher(newValue) {
413
+ this.setValue(newValue, false);
414
+ }
415
+ hourChanged(newHour) {
416
+ if (this.meridiem && isValidNumber(newHour)) {
417
+ this.setValuePart("meridiem", getMeridiem(newHour));
392
418
  }
393
419
  }
394
420
  //--------------------------------------------------------------------------
@@ -419,7 +445,7 @@ export class CalciteTimePicker {
419
445
  if (this.step !== 60) {
420
446
  this.setFocus("second");
421
447
  }
422
- else if (this.hourDisplayFormat === "12") {
448
+ else if (this.hourCycle === "12") {
423
449
  this.setFocus("meridiem");
424
450
  }
425
451
  break;
@@ -431,7 +457,7 @@ export class CalciteTimePicker {
431
457
  this.setFocus("minute");
432
458
  break;
433
459
  case "ArrowRight":
434
- if (this.hourDisplayFormat === "12") {
460
+ if (this.hourCycle === "12") {
435
461
  this.setFocus("meridiem");
436
462
  }
437
463
  break;
@@ -461,6 +487,11 @@ export class CalciteTimePicker {
461
487
  var _a;
462
488
  (_a = this[`${target || "hour"}El`]) === null || _a === void 0 ? void 0 : _a.focus();
463
489
  }
490
+ // --------------------------------------------------------------------------
491
+ //
492
+ // Private Methods
493
+ //
494
+ // --------------------------------------------------------------------------
464
495
  buttonActivated(event) {
465
496
  const key = event.key;
466
497
  if (key === " ") {
@@ -468,40 +499,14 @@ export class CalciteTimePicker {
468
499
  }
469
500
  return isActivationKey(key);
470
501
  }
471
- getDisplayHour() {
472
- if (!this.hour) {
473
- return "--";
474
- }
475
- if (this.hourDisplayFormat === "12") {
476
- return getMeridiemHour(this.hour);
477
- }
478
- return this.hour;
479
- }
480
- getTime() {
481
- return {
482
- hour: this.hour,
483
- minute: this.minute,
484
- second: this.second
485
- };
486
- }
487
502
  // --------------------------------------------------------------------------
488
503
  //
489
504
  // Lifecycle
490
505
  //
491
506
  // --------------------------------------------------------------------------
492
507
  connectedCallback() {
493
- if (this.hourDisplayFormat === "12") {
494
- this.meridiem = getMeridiem(this.hour);
495
- }
496
- if (isValidNumber(this.hour)) {
497
- this.hour = formatTimePart(parseInt(this.hour));
498
- }
499
- if (isValidNumber(this.minute)) {
500
- this.minute = formatTimePart(parseInt(this.minute));
501
- }
502
- if (isValidNumber(this.second)) {
503
- this.second = formatTimePart(parseInt(this.second));
504
- }
508
+ this.setValue(this.value, false);
509
+ this.hourCycle = getLocaleHourCycle(this.locale);
505
510
  }
506
511
  // --------------------------------------------------------------------------
507
512
  //
@@ -509,79 +514,84 @@ export class CalciteTimePicker {
509
514
  //
510
515
  // --------------------------------------------------------------------------
511
516
  render() {
512
- const iconScale = this.scale === "s" || this.scale === "m" ? "s" : "m";
513
- const includeSeconds = this.step !== 60;
514
517
  const hourIsNumber = isValidNumber(this.hour);
518
+ const iconScale = this.scale === "s" || this.scale === "m" ? "s" : "m";
515
519
  const minuteIsNumber = isValidNumber(this.minute);
516
520
  const secondIsNumber = isValidNumber(this.second);
517
- return (h(Host, null,
518
- h("div", { class: CSS.timePicker },
519
- h("div", { role: "group" },
520
- h("span", { "aria-label": this.intlHourUp, class: {
521
- [CSS.button]: true,
522
- [CSS.buttonHourUp]: true,
523
- [CSS.buttonTopLeft]: true
524
- }, onClick: this.incrementHour, onKeyDown: this.hourUpButtonKeyDownHandler, role: "button", tabIndex: -1 },
525
- h("calcite-icon", { icon: "chevron-up", scale: iconScale })),
526
- h("span", { "aria-label": this.intlHour, "aria-valuemax": "23", "aria-valuemin": "1", "aria-valuenow": hourIsNumber && parseInt(this.hour), "aria-valuetext": this.hour, class: {
527
- [CSS.input]: true,
528
- [CSS.hour]: true
529
- }, onFocus: this.focusHandler, onKeyDown: this.hourKeyDownHandler, ref: (el) => (this.hourEl = el), role: "spinbutton", tabIndex: 0 }, this.getDisplayHour()),
530
- h("span", { "aria-label": this.intlHourDown, class: {
531
- [CSS.button]: true,
532
- [CSS.buttonHourDown]: true,
533
- [CSS.buttonBottomLeft]: true
534
- }, onClick: this.decrementHour, onKeyDown: this.hourDownButtonKeyDownHandler, role: "button", tabIndex: -1 },
535
- h("calcite-icon", { icon: "chevron-down", scale: iconScale }))),
536
- h("span", { class: CSS.delimiter }, ":"),
537
- h("div", { role: "group" },
538
- h("span", { "aria-label": this.intlMinuteUp, class: {
539
- [CSS.button]: true,
540
- [CSS.buttonMinuteUp]: true
541
- }, onClick: this.incrementMinute, onKeyDown: this.minuteUpButtonKeyDownHandler, role: "button", tabIndex: -1 },
542
- h("calcite-icon", { icon: "chevron-up", scale: iconScale })),
543
- h("span", { "aria-label": this.intlMinute, "aria-valuemax": "12", "aria-valuemin": "1", "aria-valuenow": minuteIsNumber && parseInt(this.minute), "aria-valuetext": this.minute, class: {
544
- [CSS.input]: true,
545
- [CSS.minute]: true
546
- }, onFocus: this.focusHandler, onKeyDown: this.minuteKeyDownHandler, ref: (el) => (this.minuteEl = el), role: "spinbutton", tabIndex: 0 }, this.minute ? this.minute : "--"),
547
- h("span", { "aria-label": this.intlMinuteDown, class: {
548
- [CSS.button]: true,
549
- [CSS.buttonMinuteDown]: true
550
- }, onClick: this.decrementMinute, onKeyDown: this.minuteDownButtonKeyDownHandler, role: "button", tabIndex: -1 },
551
- h("calcite-icon", { icon: "chevron-down", scale: iconScale }))),
552
- includeSeconds && h("span", { class: CSS.delimiter }, ":"),
553
- includeSeconds && (h("div", { role: "group" },
554
- h("span", { "aria-label": this.intlSecondUp, class: {
555
- [CSS.button]: true,
556
- [CSS.buttonSecondUp]: true
557
- }, onClick: this.incrementSecond, onKeyDown: this.secondUpButtonKeyDownHandler, role: "button", tabIndex: -1 },
558
- h("calcite-icon", { icon: "chevron-up", scale: iconScale })),
559
- h("span", { "aria-label": this.intlSecond, "aria-valuemax": "59", "aria-valuemin": "0", "aria-valuenow": secondIsNumber && parseInt(this.second), "aria-valuetext": this.second, class: {
560
- [CSS.input]: true,
561
- [CSS.second]: true
562
- }, onFocus: this.focusHandler, onKeyDown: this.secondKeyDownHandler, ref: (el) => (this.secondEl = el), role: "spinbutton", tabIndex: 0 }, this.second ? this.second : "--"),
563
- h("span", { "aria-label": this.intlSecondDown, class: {
564
- [CSS.button]: true,
565
- [CSS.buttonSecondDown]: true
566
- }, onClick: this.decrementSecond, onKeyDown: this.secondDownButtonKeyDownHandler, role: "button", tabIndex: -1 },
567
- h("calcite-icon", { icon: "chevron-down", scale: iconScale })))),
568
- this.hourDisplayFormat === "12" && (h("div", { role: "group" },
569
- h("span", { "aria-label": this.intlMeridiemUp, class: {
570
- [CSS.button]: true,
571
- [CSS.buttonMeridiemUp]: true,
572
- [CSS.buttonTopRight]: true
573
- }, onClick: this.incrementMeridiem, onKeyDown: this.meridiemUpButtonKeyDownHandler, role: "button", tabIndex: -1 },
574
- h("calcite-icon", { icon: "chevron-up", scale: iconScale })),
575
- h("span", { "aria-label": this.intlMeridiem, "aria-valuemax": "2", "aria-valuemin": "1", "aria-valuenow": this.meridiem === "AM" ? "1" : this.meridiem === "PM" ? "2" : undefined, "aria-valuetext": this.meridiem, class: {
576
- [CSS.input]: true,
577
- [CSS.meridiem]: true
578
- }, onFocus: this.focusHandler, onKeyDown: this.meridiemKeyDownHandler, ref: (el) => (this.meridiemEl = el), role: "spinbutton", tabIndex: 0 }, this.meridiem ? this.meridiem : "--"),
579
- h("span", { "aria-label": this.intlMeridiemDown, class: {
580
- [CSS.button]: true,
581
- [CSS.buttonMeridiemDown]: true,
582
- [CSS.buttonBottomRight]: true
583
- }, onClick: this.decrementMeridiem, onKeyDown: this.meridiemDownButtonKeyDownHandler, role: "button", tabIndex: -1 },
584
- h("calcite-icon", { icon: "chevron-down", scale: iconScale })))))));
521
+ const showMeridiem = this.hourCycle === "12";
522
+ return (h("div", { class: {
523
+ [CSS.timePicker]: true,
524
+ [CSS.showMeridiem]: showMeridiem,
525
+ [CSS.showSecond]: this.showSecond,
526
+ [CSS[`scale-${this.scale}`]]: true
527
+ } },
528
+ h("div", { class: CSS.column, role: "group" },
529
+ h("span", { "aria-label": this.intlHourUp, class: {
530
+ [CSS.button]: true,
531
+ [CSS.buttonHourUp]: true,
532
+ [CSS.buttonTopLeft]: true
533
+ }, onClick: this.incrementHour, onKeyDown: this.hourUpButtonKeyDownHandler, role: "button", tabIndex: -1 },
534
+ h("calcite-icon", { icon: "chevron-up", scale: iconScale })),
535
+ h("span", { "aria-label": this.intlHour, "aria-valuemax": "23", "aria-valuemin": "1", "aria-valuenow": (hourIsNumber && parseInt(this.hour)) || "0", "aria-valuetext": this.hour, class: {
536
+ [CSS.input]: true,
537
+ [CSS.hour]: true
538
+ }, onFocus: this.focusHandler, onKeyDown: this.hourKeyDownHandler, ref: this.setHourEl, role: "spinbutton", tabIndex: 0 }, this.localizedHour || "--"),
539
+ h("span", { "aria-label": this.intlHourDown, class: {
540
+ [CSS.button]: true,
541
+ [CSS.buttonHourDown]: true,
542
+ [CSS.buttonBottomLeft]: true
543
+ }, onClick: this.decrementHour, onKeyDown: this.hourDownButtonKeyDownHandler, role: "button", tabIndex: -1 },
544
+ h("calcite-icon", { icon: "chevron-down", scale: iconScale }))),
545
+ h("span", { class: CSS.delimiter }, this.localizedHourSuffix),
546
+ h("div", { class: CSS.column, role: "group" },
547
+ h("span", { "aria-label": this.intlMinuteUp, class: {
548
+ [CSS.button]: true,
549
+ [CSS.buttonMinuteUp]: true
550
+ }, onClick: this.incrementMinute, onKeyDown: this.minuteUpButtonKeyDownHandler, role: "button", tabIndex: -1 },
551
+ h("calcite-icon", { icon: "chevron-up", scale: iconScale })),
552
+ h("span", { "aria-label": this.intlMinute, "aria-valuemax": "12", "aria-valuemin": "1", "aria-valuenow": (minuteIsNumber && parseInt(this.minute)) || "0", "aria-valuetext": this.minute, class: {
553
+ [CSS.input]: true,
554
+ [CSS.minute]: true
555
+ }, onFocus: this.focusHandler, onKeyDown: this.minuteKeyDownHandler, ref: this.setMinuteEl, role: "spinbutton", tabIndex: 0 }, this.localizedMinute || "--"),
556
+ h("span", { "aria-label": this.intlMinuteDown, class: {
557
+ [CSS.button]: true,
558
+ [CSS.buttonMinuteDown]: true
559
+ }, onClick: this.decrementMinute, onKeyDown: this.minuteDownButtonKeyDownHandler, role: "button", tabIndex: -1 },
560
+ h("calcite-icon", { icon: "chevron-down", scale: iconScale }))),
561
+ this.showSecond && h("span", { class: CSS.delimiter }, this.localizedMinuteSuffix),
562
+ this.showSecond && (h("div", { class: CSS.column, role: "group" },
563
+ h("span", { "aria-label": this.intlSecondUp, class: {
564
+ [CSS.button]: true,
565
+ [CSS.buttonSecondUp]: true
566
+ }, onClick: this.incrementSecond, onKeyDown: this.secondUpButtonKeyDownHandler, role: "button", tabIndex: -1 },
567
+ h("calcite-icon", { icon: "chevron-up", scale: iconScale })),
568
+ h("span", { "aria-label": this.intlSecond, "aria-valuemax": "59", "aria-valuemin": "0", "aria-valuenow": (secondIsNumber && parseInt(this.second)) || "0", "aria-valuetext": this.second, class: {
569
+ [CSS.input]: true,
570
+ [CSS.second]: true
571
+ }, onFocus: this.focusHandler, onKeyDown: this.secondKeyDownHandler, ref: this.setSecondEl, role: "spinbutton", tabIndex: 0 }, this.localizedSecond || "--"),
572
+ h("span", { "aria-label": this.intlSecondDown, class: {
573
+ [CSS.button]: true,
574
+ [CSS.buttonSecondDown]: true
575
+ }, onClick: this.decrementSecond, onKeyDown: this.secondDownButtonKeyDownHandler, role: "button", tabIndex: -1 },
576
+ h("calcite-icon", { icon: "chevron-down", scale: iconScale })))),
577
+ this.localizedSecondSuffix && (h("span", { class: CSS.delimiter }, this.localizedSecondSuffix)),
578
+ showMeridiem && (h("div", { class: CSS.column, role: "group" },
579
+ h("span", { "aria-label": this.intlMeridiemUp, class: {
580
+ [CSS.button]: true,
581
+ [CSS.buttonMeridiemUp]: true,
582
+ [CSS.buttonTopRight]: true
583
+ }, onClick: this.incrementMeridiem, onKeyDown: this.meridiemUpButtonKeyDownHandler, role: "button", tabIndex: -1 },
584
+ h("calcite-icon", { icon: "chevron-up", scale: iconScale })),
585
+ h("span", { "aria-label": this.intlMeridiem, "aria-valuemax": "2", "aria-valuemin": "1", "aria-valuenow": (this.meridiem === "PM" && "2") || "1", "aria-valuetext": this.meridiem, class: {
586
+ [CSS.input]: true,
587
+ [CSS.meridiem]: true
588
+ }, onFocus: this.focusHandler, onKeyDown: this.meridiemKeyDownHandler, ref: this.setMeridiemEl, role: "spinbutton", tabIndex: 0 }, this.localizedMeridiem || "--"),
589
+ h("span", { "aria-label": this.intlMeridiemDown, class: {
590
+ [CSS.button]: true,
591
+ [CSS.buttonMeridiemDown]: true,
592
+ [CSS.buttonBottomRight]: true
593
+ }, onClick: this.decrementMeridiem, onKeyDown: this.meridiemDownButtonKeyDownHandler, role: "button", tabIndex: -1 },
594
+ h("calcite-icon", { icon: "chevron-down", scale: iconScale }))))));
585
595
  }
586
596
  static get is() { return "calcite-time-picker"; }
587
597
  static get encapsulation() { return "shadow"; }
@@ -592,47 +602,6 @@ export class CalciteTimePicker {
592
602
  "$": ["calcite-time-picker.css"]
593
603
  }; }
594
604
  static get properties() { return {
595
- "hour": {
596
- "type": "string",
597
- "mutable": true,
598
- "complexType": {
599
- "original": "string",
600
- "resolved": "string",
601
- "references": {}
602
- },
603
- "required": false,
604
- "optional": true,
605
- "docs": {
606
- "tags": [],
607
- "text": "The hour value (24-hour format)"
608
- },
609
- "attribute": "hour",
610
- "reflect": false,
611
- "defaultValue": "null"
612
- },
613
- "hourDisplayFormat": {
614
- "type": "string",
615
- "mutable": false,
616
- "complexType": {
617
- "original": "HourDisplayFormat",
618
- "resolved": "\"12\" | \"24\"",
619
- "references": {
620
- "HourDisplayFormat": {
621
- "location": "import",
622
- "path": "../../utils/time"
623
- }
624
- }
625
- },
626
- "required": false,
627
- "optional": false,
628
- "docs": {
629
- "tags": [],
630
- "text": "Format of the hour value (12-hour or 24-hour) (this will be replaced by locale eventually)"
631
- },
632
- "attribute": "hour-display-format",
633
- "reflect": true,
634
- "defaultValue": "\"12\""
635
- },
636
605
  "intlHour": {
637
606
  "type": "string",
638
607
  "mutable": false,
@@ -885,25 +854,7 @@ export class CalciteTimePicker {
885
854
  "reflect": false,
886
855
  "defaultValue": "TEXT.secondUp"
887
856
  },
888
- "minute": {
889
- "type": "string",
890
- "mutable": true,
891
- "complexType": {
892
- "original": "string",
893
- "resolved": "string",
894
- "references": {}
895
- },
896
- "required": false,
897
- "optional": true,
898
- "docs": {
899
- "tags": [],
900
- "text": "The minute value"
901
- },
902
- "attribute": "minute",
903
- "reflect": false,
904
- "defaultValue": "null"
905
- },
906
- "second": {
857
+ "locale": {
907
858
  "type": "string",
908
859
  "mutable": true,
909
860
  "complexType": {
@@ -912,14 +863,17 @@ export class CalciteTimePicker {
912
863
  "references": {}
913
864
  },
914
865
  "required": false,
915
- "optional": true,
866
+ "optional": false,
916
867
  "docs": {
917
- "tags": [],
918
- "text": "The second value"
868
+ "tags": [{
869
+ "name": "internal",
870
+ "text": undefined
871
+ }],
872
+ "text": "BCP 47 language tag for desired language and country format"
919
873
  },
920
- "attribute": "second",
874
+ "attribute": "lang",
921
875
  "reflect": false,
922
- "defaultValue": "null"
876
+ "defaultValue": "document.documentElement.lang || navigator.language || \"en\""
923
877
  },
924
878
  "scale": {
925
879
  "type": "string",
@@ -941,7 +895,7 @@ export class CalciteTimePicker {
941
895
  "text": "The scale (size) of the time picker"
942
896
  },
943
897
  "attribute": "scale",
944
- "reflect": true,
898
+ "reflect": false,
945
899
  "defaultValue": "\"m\""
946
900
  },
947
901
  "step": {
@@ -959,13 +913,42 @@ export class CalciteTimePicker {
959
913
  "text": "number that specifies the granularity that the value must adhere to"
960
914
  },
961
915
  "attribute": "step",
962
- "reflect": true,
916
+ "reflect": false,
963
917
  "defaultValue": "60"
918
+ },
919
+ "value": {
920
+ "type": "string",
921
+ "mutable": true,
922
+ "complexType": {
923
+ "original": "string",
924
+ "resolved": "string",
925
+ "references": {}
926
+ },
927
+ "required": false,
928
+ "optional": false,
929
+ "docs": {
930
+ "tags": [],
931
+ "text": "The selected time in UTC"
932
+ },
933
+ "attribute": "value",
934
+ "reflect": false,
935
+ "defaultValue": "null"
964
936
  }
965
937
  }; }
966
938
  static get states() { return {
939
+ "hour": {},
940
+ "hourCycle": {},
941
+ "localizedHour": {},
942
+ "localizedHourSuffix": {},
943
+ "localizedMeridiem": {},
944
+ "localizedMinute": {},
945
+ "localizedMinuteSuffix": {},
946
+ "localizedSecond": {},
947
+ "localizedSecondSuffix": {},
967
948
  "meridiem": {},
968
- "displayHour": {}
949
+ "minute": {},
950
+ "second": {},
951
+ "showSecond": {}
969
952
  }; }
970
953
  static get events() { return [{
971
954
  "method": "calciteTimePickerBlur",
@@ -981,14 +964,9 @@ export class CalciteTimePicker {
981
964
  "text": ""
982
965
  },
983
966
  "complexType": {
984
- "original": "Time",
985
- "resolved": "Time",
986
- "references": {
987
- "Time": {
988
- "location": "import",
989
- "path": "../../utils/time"
990
- }
991
- }
967
+ "original": "void",
968
+ "resolved": "void",
969
+ "references": {}
992
970
  }
993
971
  }, {
994
972
  "method": "calciteTimePickerChange",
@@ -1004,14 +982,9 @@ export class CalciteTimePicker {
1004
982
  "text": ""
1005
983
  },
1006
984
  "complexType": {
1007
- "original": "Time",
1008
- "resolved": "Time",
1009
- "references": {
1010
- "Time": {
1011
- "location": "import",
1012
- "path": "../../utils/time"
1013
- }
1014
- }
985
+ "original": "string",
986
+ "resolved": "string",
987
+ "references": {}
1015
988
  }
1016
989
  }, {
1017
990
  "method": "calciteTimePickerFocus",
@@ -1027,20 +1000,15 @@ export class CalciteTimePicker {
1027
1000
  "text": ""
1028
1001
  },
1029
1002
  "complexType": {
1030
- "original": "Time",
1031
- "resolved": "Time",
1032
- "references": {
1033
- "Time": {
1034
- "location": "import",
1035
- "path": "../../utils/time"
1036
- }
1037
- }
1003
+ "original": "void",
1004
+ "resolved": "void",
1005
+ "references": {}
1038
1006
  }
1039
1007
  }]; }
1040
1008
  static get methods() { return {
1041
1009
  "setFocus": {
1042
1010
  "complexType": {
1043
- "signature": "(target: TimeFocusId) => Promise<void>",
1011
+ "signature": "(target: TimePart) => Promise<void>",
1044
1012
  "parameters": [{
1045
1013
  "tags": [],
1046
1014
  "text": ""
@@ -1049,7 +1017,7 @@ export class CalciteTimePicker {
1049
1017
  "Promise": {
1050
1018
  "location": "global"
1051
1019
  },
1052
- "TimeFocusId": {
1020
+ "TimePart": {
1053
1021
  "location": "import",
1054
1022
  "path": "../../utils/time"
1055
1023
  }
@@ -1064,17 +1032,14 @@ export class CalciteTimePicker {
1064
1032
  }; }
1065
1033
  static get elementRef() { return "el"; }
1066
1034
  static get watchers() { return [{
1067
- "propName": "hour",
1068
- "methodName": "hourChanged"
1035
+ "propName": "locale",
1036
+ "methodName": "localeWatcher"
1069
1037
  }, {
1070
- "propName": "hour",
1071
- "methodName": "timeChangeHandler"
1072
- }, {
1073
- "propName": "minute",
1074
- "methodName": "timeChangeHandler"
1038
+ "propName": "value",
1039
+ "methodName": "valueWatcher"
1075
1040
  }, {
1076
- "propName": "second",
1077
- "methodName": "timeChangeHandler"
1041
+ "propName": "hour",
1042
+ "methodName": "hourChanged"
1078
1043
  }]; }
1079
1044
  static get listeners() { return [{
1080
1045
  "name": "blur",