@esri/solutions-components 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/deduct-calculator.cjs.entry.js +1 -1
- package/dist/cjs/pci-calculator.cjs.entry.js +1 -1
- package/dist/cjs/{pciUtils-6a806ba4.js → pciUtils-423cfc68.js} +25 -7
- package/dist/collection/demos/deduct-calculator.html +2 -5
- package/dist/collection/demos/new-public-notification.html +6 -4
- package/dist/collection/utils/pciUtils.js +25 -7
- package/dist/collection/utils/pciUtils.ts +30 -7
- package/dist/components/ExpandToggle.js +110 -0
- package/dist/components/Heading.js +22 -0
- package/dist/components/_commonjsHelpers.js +22 -0
- package/dist/components/action-bar.js +276 -0
- package/dist/components/action-group.js +149 -0
- package/dist/components/action-menu.js +356 -0
- package/dist/components/action.js +214 -0
- package/dist/components/add-record-modal.d.ts +11 -0
- package/dist/components/add-record-modal.js +171 -0
- package/dist/components/array.js +15 -0
- package/dist/components/block.js +272 -0
- package/dist/components/buffer-tools.d.ts +11 -0
- package/dist/components/buffer-tools.js +11 -0
- package/dist/components/buffer-tools2.js +262 -0
- package/dist/components/button.js +263 -0
- package/dist/components/calcite-accordion-item.js +244 -0
- package/dist/components/calcite-accordion.js +180 -0
- package/dist/components/calcite-action-bar.js +11 -0
- package/dist/components/calcite-action-group.js +11 -0
- package/dist/components/calcite-action-menu.js +11 -0
- package/dist/components/calcite-action-pad.js +197 -0
- package/dist/components/calcite-action.js +11 -0
- package/dist/components/calcite-alert.js +297 -0
- package/dist/components/calcite-avatar.js +182 -0
- package/dist/components/calcite-block-section.js +155 -0
- package/dist/components/calcite-block.js +11 -0
- package/dist/components/calcite-button.js +11 -0
- package/dist/components/calcite-card.js +187 -0
- package/dist/components/calcite-checkbox.js +11 -0
- package/dist/components/calcite-chip.js +11 -0
- package/dist/components/calcite-color-picker-hex-input.js +11 -0
- package/dist/components/calcite-color-picker-swatch.js +11 -0
- package/dist/components/calcite-color-picker.js +1036 -0
- package/dist/components/calcite-combobox-item-group.js +75 -0
- package/dist/components/calcite-combobox-item.js +11 -0
- package/dist/components/calcite-combobox.js +11 -0
- package/dist/components/calcite-date-picker-day.js +11 -0
- package/dist/components/calcite-date-picker-month-header.js +11 -0
- package/dist/components/calcite-date-picker-month.js +11 -0
- package/dist/components/calcite-date-picker.js +11 -0
- package/dist/components/calcite-dropdown-group.js +11 -0
- package/dist/components/calcite-dropdown-item.js +11 -0
- package/dist/components/calcite-dropdown.js +11 -0
- package/dist/components/calcite-fab.js +144 -0
- package/dist/components/calcite-filter.js +195 -0
- package/dist/components/calcite-flow-item.js +243 -0
- package/dist/components/calcite-flow.js +147 -0
- package/dist/components/calcite-graph.js +11 -0
- package/dist/components/calcite-handle.js +11 -0
- package/dist/components/calcite-icon.js +11 -0
- package/dist/components/calcite-inline-editable.js +294 -0
- package/dist/components/calcite-input-date-picker.js +713 -0
- package/dist/components/calcite-input-message.js +11 -0
- package/dist/components/calcite-input-number.js +637 -0
- package/dist/components/calcite-input-text.js +400 -0
- package/dist/components/calcite-input-time-picker.js +434 -0
- package/dist/components/calcite-input.js +11 -0
- package/dist/components/calcite-label.js +11 -0
- package/dist/components/calcite-link.js +11 -0
- package/dist/components/calcite-list-item-group.js +65 -0
- package/dist/components/calcite-list-item.js +11 -0
- package/dist/components/calcite-list.js +11 -0
- package/dist/components/calcite-loader.js +11 -0
- package/dist/components/calcite-modal.js +11 -0
- package/dist/components/calcite-notice.js +11 -0
- package/dist/components/calcite-option-group.js +64 -0
- package/dist/components/calcite-option.js +11 -0
- package/dist/components/calcite-pagination.js +258 -0
- package/dist/components/calcite-panel.js +11 -0
- package/dist/components/calcite-pick-list-group.js +74 -0
- package/dist/components/calcite-pick-list-item.js +11 -0
- package/dist/components/calcite-pick-list.js +11 -0
- package/dist/components/calcite-popover-manager.js +94 -0
- package/dist/components/calcite-popover.js +11 -0
- package/dist/components/calcite-progress.js +11 -0
- package/dist/components/calcite-radio-button-group.js +132 -0
- package/dist/components/calcite-radio-button.js +310 -0
- package/dist/components/calcite-radio-group-item.js +11 -0
- package/dist/components/calcite-radio-group.js +11 -0
- package/dist/components/calcite-rating.js +201 -0
- package/dist/components/calcite-scrim.js +11 -0
- package/dist/components/calcite-select.js +11 -0
- package/dist/components/calcite-shell-center-row.js +100 -0
- package/dist/components/calcite-shell-panel.js +11 -0
- package/dist/components/calcite-shell.js +11 -0
- package/dist/components/calcite-slider.js +11 -0
- package/dist/components/calcite-sortable-list.js +202 -0
- package/dist/components/calcite-split-button.js +11 -0
- package/dist/components/calcite-stepper-item.js +271 -0
- package/dist/components/calcite-stepper.js +256 -0
- package/dist/components/calcite-switch.js +11 -0
- package/dist/components/calcite-tab-nav.js +11 -0
- package/dist/components/calcite-tab-title.js +11 -0
- package/dist/components/calcite-tab.js +11 -0
- package/dist/components/calcite-tabs.js +11 -0
- package/dist/components/calcite-tile-select-group.js +65 -0
- package/dist/components/calcite-tile-select.js +266 -0
- package/dist/components/calcite-tile.js +11 -0
- package/dist/components/calcite-time-picker.js +11 -0
- package/dist/components/calcite-tip-group.js +41 -0
- package/dist/components/calcite-tip-manager.js +223 -0
- package/dist/components/calcite-tip.js +162 -0
- package/dist/components/calcite-tooltip-manager.js +57 -0
- package/dist/components/calcite-tooltip.js +11 -0
- package/dist/components/calcite-tree-item.js +11 -0
- package/dist/components/calcite-tree.js +11 -0
- package/dist/components/calcite-value-list-item.js +11 -0
- package/dist/components/calcite-value-list.js +11 -0
- package/dist/components/card-manager.d.ts +11 -0
- package/dist/components/card-manager.js +143 -0
- package/dist/components/check-list.d.ts +11 -0
- package/dist/components/check-list.js +11 -0
- package/dist/components/check-list2.js +131 -0
- package/dist/components/checkbox.js +165 -0
- package/dist/components/chip.js +170 -0
- package/dist/components/color-picker-hex-input.js +363 -0
- package/dist/components/color-picker-swatch.js +2034 -0
- package/dist/components/combobox-item.js +182 -0
- package/dist/components/combobox.js +912 -0
- package/dist/components/comment-card.d.ts +11 -0
- package/dist/components/comment-card.js +90 -0
- package/dist/components/conditionalSlot.js +50 -0
- package/dist/components/config-buffer-tools.d.ts +11 -0
- package/dist/components/config-buffer-tools.js +187 -0
- package/dist/components/config-draw-tools.d.ts +11 -0
- package/dist/components/config-draw-tools.js +121 -0
- package/dist/components/config-layer-picker.d.ts +11 -0
- package/dist/components/config-layer-picker.js +163 -0
- package/dist/components/config-pdf-download.d.ts +11 -0
- package/dist/components/config-pdf-download.js +154 -0
- package/dist/components/crowdsource-manager.d.ts +11 -0
- package/dist/components/crowdsource-manager.js +90 -0
- package/dist/components/crowdsource-reporter.d.ts +11 -0
- package/dist/components/crowdsource-reporter.js +90 -0
- package/dist/components/csvUtils.js +74 -0
- package/dist/components/date-picker-day.js +111 -0
- package/dist/components/date-picker-month-header.js +224 -0
- package/dist/components/date-picker-month.js +344 -0
- package/dist/components/date-picker.js +575 -0
- package/dist/components/date.js +180 -0
- package/dist/components/debounce.js +487 -0
- package/dist/components/deduct-calculator.d.ts +11 -0
- package/dist/components/deduct-calculator.js +11 -0
- package/dist/components/deduct-calculator2.js +1002 -0
- package/dist/components/dom.js +231 -0
- package/dist/components/dropdown-group.js +96 -0
- package/dist/components/dropdown-item.js +232 -0
- package/dist/components/dropdown.js +505 -0
- package/dist/components/edit-record-modal.d.ts +11 -0
- package/dist/components/edit-record-modal.js +11 -0
- package/dist/components/edit-record-modal2.js +161 -0
- package/dist/components/filter.js +763 -0
- package/dist/components/floating-ui.js +1768 -0
- package/dist/components/form.js +228 -0
- package/dist/components/graph.js +254 -0
- package/dist/components/guid.js +24 -0
- package/dist/components/handle.js +119 -0
- package/dist/components/icon.js +202 -0
- package/dist/components/index.d.ts +61 -0
- package/dist/components/index.js +196 -0
- package/dist/components/index2.js +199 -0
- package/dist/components/info-card.d.ts +11 -0
- package/dist/components/info-card.js +11 -0
- package/dist/components/info-card2.js +97 -0
- package/dist/components/input-message.js +101 -0
- package/dist/components/input.js +740 -0
- package/dist/components/interactive.js +51 -0
- package/dist/components/interfaces.js +19 -0
- package/dist/components/interfaces2.js +21 -0
- package/dist/components/interfaces3.js +80 -0
- package/dist/components/json-editor.d.ts +11 -0
- package/dist/components/json-editor.js +11 -0
- package/dist/components/json-editor2.js +441 -0
- package/dist/components/key.js +16 -0
- package/dist/components/label.js +106 -0
- package/dist/components/label2.js +131 -0
- package/dist/components/labelFormats.js +210 -0
- package/dist/components/layer-table.d.ts +11 -0
- package/dist/components/layer-table.js +453 -0
- package/dist/components/link.js +123 -0
- package/dist/components/list-item.d.ts +11 -0
- package/dist/components/list-item.js +90 -0
- package/dist/components/list-item2.js +149 -0
- package/dist/components/list.js +83 -0
- package/dist/components/loadModules.js +28 -0
- package/dist/components/loader.js +116 -0
- package/dist/components/locale.js +412 -0
- package/dist/components/locale2.js +413 -0
- package/dist/components/map-card.d.ts +11 -0
- package/dist/components/map-card.js +354 -0
- package/dist/components/map-draw-tools.d.ts +11 -0
- package/dist/components/map-draw-tools.js +11 -0
- package/dist/components/map-draw-tools2.js +228 -0
- package/dist/components/map-layer-picker.d.ts +11 -0
- package/dist/components/map-layer-picker.js +11 -0
- package/dist/components/map-layer-picker2.js +188 -0
- package/dist/components/map-search.d.ts +11 -0
- package/dist/components/map-search.js +155 -0
- package/dist/components/map-select-tools.d.ts +11 -0
- package/dist/components/map-select-tools.js +11 -0
- package/dist/components/map-select-tools2.js +588 -0
- package/dist/components/mapViewUtils.js +129 -0
- package/dist/components/math.js +24 -0
- package/dist/components/media-card.d.ts +11 -0
- package/dist/components/media-card.js +11 -0
- package/dist/components/media-card2.js +177 -0
- package/dist/components/modal.js +495 -0
- package/dist/components/nonChromiumPlatformUtils.js +503 -0
- package/dist/components/notice.js +192 -0
- package/dist/components/observers.js +56 -0
- package/dist/components/openCloseComponent.js +56 -0
- package/dist/components/option.js +109 -0
- package/dist/components/panel.js +459 -0
- package/dist/components/pci-calculator.d.ts +11 -0
- package/dist/components/pci-calculator.js +193 -0
- package/dist/components/pdf-download.d.ts +11 -0
- package/dist/components/pdf-download.js +11 -0
- package/dist/components/pdf-download2.js +189 -0
- package/dist/components/pick-list-item.js +255 -0
- package/dist/components/pick-list.js +170 -0
- package/dist/components/popover.js +500 -0
- package/dist/components/progress.js +60 -0
- package/dist/components/public-notification.d.ts +11 -0
- package/dist/components/public-notification.js +825 -0
- package/dist/components/publicNotificationStore.js +38 -0
- package/dist/components/queryUtils.js +187 -0
- package/dist/components/radio-group-item.js +101 -0
- package/dist/components/radio-group.js +235 -0
- package/dist/components/refine-selection-tools.d.ts +11 -0
- package/dist/components/refine-selection-tools.js +11 -0
- package/dist/components/refine-selection-tools2.js +492 -0
- package/dist/components/refine-selection.d.ts +11 -0
- package/dist/components/refine-selection.js +11 -0
- package/dist/components/refine-selection2.js +376 -0
- package/dist/components/resources.js +24 -0
- package/dist/components/resources2.js +21 -0
- package/dist/components/resources3.js +38 -0
- package/dist/components/scrim.js +83 -0
- package/dist/components/select.js +259 -0
- package/dist/components/shared-list-render.js +319 -0
- package/dist/components/shell-panel.js +281 -0
- package/dist/components/shell.js +121 -0
- package/dist/components/slider.js +896 -0
- package/dist/components/solution-configuration.d.ts +11 -0
- package/dist/components/solution-configuration.js +2233 -0
- package/dist/components/solution-contents.d.ts +11 -0
- package/dist/components/solution-contents.js +11 -0
- package/dist/components/solution-contents2.js +128 -0
- package/dist/components/solution-item-details.d.ts +11 -0
- package/dist/components/solution-item-details.js +11 -0
- package/dist/components/solution-item-details2.js +234 -0
- package/dist/components/solution-item-icon.d.ts +11 -0
- package/dist/components/solution-item-icon.js +11 -0
- package/dist/components/solution-item-icon2.js +342 -0
- package/dist/components/solution-item-sharing.d.ts +11 -0
- package/dist/components/solution-item-sharing.js +11 -0
- package/dist/components/solution-item-sharing2.js +167 -0
- package/dist/components/solution-item.d.ts +11 -0
- package/dist/components/solution-item.js +11 -0
- package/dist/components/solution-item2.js +315 -0
- package/dist/components/solution-organization-variables.d.ts +11 -0
- package/dist/components/solution-organization-variables.js +11 -0
- package/dist/components/solution-organization-variables2.js +132 -0
- package/dist/components/solution-resource-item.d.ts +11 -0
- package/dist/components/solution-resource-item.js +11 -0
- package/dist/components/solution-resource-item2.js +356 -0
- package/dist/components/solution-spatial-ref.d.ts +11 -0
- package/dist/components/solution-spatial-ref.js +11 -0
- package/dist/components/solution-spatial-ref2.js +21446 -0
- package/dist/components/solution-store.js +4092 -0
- package/dist/components/solution-template-data.d.ts +11 -0
- package/dist/components/solution-template-data.js +11 -0
- package/dist/components/solution-template-data2.js +233 -0
- package/dist/components/solution-variables.d.ts +11 -0
- package/dist/components/solution-variables.js +11 -0
- package/dist/components/solution-variables2.js +150 -0
- package/dist/components/sortable.esm.js +3026 -0
- package/dist/components/split-button.js +165 -0
- package/dist/components/store-manager.d.ts +11 -0
- package/dist/components/store-manager.js +83 -0
- package/dist/components/switch.js +139 -0
- package/dist/components/tab-nav.js +241 -0
- package/dist/components/tab-title.js +276 -0
- package/dist/components/tab.js +154 -0
- package/dist/components/tabs.js +188 -0
- package/dist/components/tile.js +129 -0
- package/dist/components/time-picker.js +943 -0
- package/dist/components/tooltip.js +399 -0
- package/dist/components/tree-item.js +294 -0
- package/dist/components/tree.js +327 -0
- package/dist/components/utils.js +119 -0
- package/dist/components/utils2.js +51 -0
- package/dist/components/value-list-item.js +204 -0
- package/dist/components/value-list.js +333 -0
- package/dist/esm/deduct-calculator.entry.js +1 -1
- package/dist/esm/pci-calculator.entry.js +1 -1
- package/dist/esm/{pciUtils-e3007a1c.js → pciUtils-ecda46e5.js} +25 -7
- package/dist/solutions-components/demos/deduct-calculator.html +2 -5
- package/dist/solutions-components/demos/new-public-notification.html +6 -4
- package/dist/solutions-components/{p-ff80ffbb.entry.js → p-0512635b.entry.js} +1 -1
- package/dist/solutions-components/{p-5ec407c2.entry.js → p-0c088725.entry.js} +1 -1
- package/dist/solutions-components/p-cc815aca.js +21 -0
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/pciUtils.ts +30 -7
- package/dist/types/utils/pciUtils.d.ts +2 -1
- package/package.json +4 -3
- package/dist/solutions-components/p-647bbd18.js +0 -21
@@ -0,0 +1,943 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
7
|
+
import { n as numberKeys, i as isActivationKey } from './key.js';
|
8
|
+
import { i as isValidNumber, g as getSupportedLocale, b as getSupportedNumberingSystem, u as updateEffectiveLocale, c as connectLocalized, d as disconnectLocalized } from './locale2.js';
|
9
|
+
import { d as defineCustomElement$1 } from './icon.js';
|
10
|
+
|
11
|
+
/*!
|
12
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
13
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
14
|
+
* v1.0.0-beta.97
|
15
|
+
*/
|
16
|
+
const maxTenthForMinuteAndSecond = 5;
|
17
|
+
function createLocaleDateTimeFormatter(locale, numberingSystem, includeSeconds = true) {
|
18
|
+
try {
|
19
|
+
const options = {
|
20
|
+
hour: "2-digit",
|
21
|
+
minute: "2-digit",
|
22
|
+
timeZone: "UTC",
|
23
|
+
numberingSystem: getSupportedNumberingSystem(numberingSystem)
|
24
|
+
};
|
25
|
+
if (includeSeconds) {
|
26
|
+
options.second = "2-digit";
|
27
|
+
}
|
28
|
+
return new Intl.DateTimeFormat(getSupportedLocale(locale), options);
|
29
|
+
}
|
30
|
+
catch (error) {
|
31
|
+
throw new Error(`Invalid locale supplied while attempting to create a DateTime formatter: ${locale}`);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
function formatTimePart(number) {
|
35
|
+
const numberAsString = number.toString();
|
36
|
+
return number >= 0 && number <= 9 ? numberAsString.padStart(2, "0") : numberAsString;
|
37
|
+
}
|
38
|
+
function formatTimeString(value) {
|
39
|
+
if (!isValidTime(value)) {
|
40
|
+
return null;
|
41
|
+
}
|
42
|
+
const [hourString, minuteString, secondString] = value.split(":");
|
43
|
+
const hour = formatTimePart(parseInt(hourString));
|
44
|
+
const minute = formatTimePart(parseInt(minuteString));
|
45
|
+
if (secondString) {
|
46
|
+
const second = formatTimePart(parseInt(secondString));
|
47
|
+
return `${hour}:${minute}:${second}`;
|
48
|
+
}
|
49
|
+
return `${hour}:${minute}`;
|
50
|
+
}
|
51
|
+
function getLocaleHourCycle(locale, numberingSystem) {
|
52
|
+
const formatter = createLocaleDateTimeFormatter(locale, numberingSystem);
|
53
|
+
const parts = formatter.formatToParts(new Date(Date.UTC(0, 0, 0, 0, 0, 0)));
|
54
|
+
return getLocalizedTimePart("meridiem", parts) ? "12" : "24";
|
55
|
+
}
|
56
|
+
function getLocalizedTimePart(part, parts) {
|
57
|
+
var _a, _b, _c, _d;
|
58
|
+
if (!part || !parts) {
|
59
|
+
return null;
|
60
|
+
}
|
61
|
+
if (part === "hourSuffix") {
|
62
|
+
const hourIndex = parts.indexOf(parts.find(({ type }) => type === "hour"));
|
63
|
+
const minuteIndex = parts.indexOf(parts.find(({ type }) => type === "minute"));
|
64
|
+
const hourSuffix = parts[hourIndex + 1];
|
65
|
+
return hourSuffix && hourSuffix.type === "literal" && minuteIndex - hourIndex === 2
|
66
|
+
? ((_a = hourSuffix.value) === null || _a === void 0 ? void 0 : _a.trim()) || null
|
67
|
+
: null;
|
68
|
+
}
|
69
|
+
if (part === "minuteSuffix") {
|
70
|
+
const minuteIndex = parts.indexOf(parts.find(({ type }) => type === "minute"));
|
71
|
+
const secondIndex = parts.indexOf(parts.find(({ type }) => type === "second"));
|
72
|
+
const minuteSuffix = parts[minuteIndex + 1];
|
73
|
+
return minuteSuffix && minuteSuffix.type === "literal" && secondIndex - minuteIndex === 2
|
74
|
+
? ((_b = minuteSuffix.value) === null || _b === void 0 ? void 0 : _b.trim()) || null
|
75
|
+
: null;
|
76
|
+
}
|
77
|
+
if (part === "secondSuffix") {
|
78
|
+
const secondIndex = parts.indexOf(parts.find(({ type }) => type === "second"));
|
79
|
+
const secondSuffix = parts[secondIndex + 1];
|
80
|
+
return secondSuffix && secondSuffix.type === "literal" ? ((_c = secondSuffix.value) === null || _c === void 0 ? void 0 : _c.trim()) || null : null;
|
81
|
+
}
|
82
|
+
return ((_d = parts.find(({ type }) => (part == "meridiem" ? type === "dayPeriod" : type === part))) === null || _d === void 0 ? void 0 : _d.value) || null;
|
83
|
+
}
|
84
|
+
function getMeridiem(hour) {
|
85
|
+
if (!isValidNumber(hour)) {
|
86
|
+
return null;
|
87
|
+
}
|
88
|
+
const hourAsNumber = parseInt(hour);
|
89
|
+
return hourAsNumber >= 0 && hourAsNumber <= 11 ? "AM" : "PM";
|
90
|
+
}
|
91
|
+
function isValidTime(value) {
|
92
|
+
if (!value || value.startsWith(":") || value.endsWith(":")) {
|
93
|
+
return false;
|
94
|
+
}
|
95
|
+
const splitValue = value.split(":");
|
96
|
+
const validLength = splitValue.length > 1 && splitValue.length < 4;
|
97
|
+
if (!validLength) {
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
const [hour, minute, second] = splitValue;
|
101
|
+
const hourAsNumber = parseInt(splitValue[0]);
|
102
|
+
const minuteAsNumber = parseInt(splitValue[1]);
|
103
|
+
const secondAsNumber = parseInt(splitValue[2]);
|
104
|
+
const hourValid = isValidNumber(hour) && hourAsNumber >= 0 && hourAsNumber < 24;
|
105
|
+
const minuteValid = isValidNumber(minute) && minuteAsNumber >= 0 && minuteAsNumber < 60;
|
106
|
+
const secondValid = isValidNumber(second) && secondAsNumber >= 0 && secondAsNumber < 60;
|
107
|
+
if ((hourValid && minuteValid && !second) || (hourValid && minuteValid && secondValid)) {
|
108
|
+
return true;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
function isValidTimePart(value, part) {
|
112
|
+
if (part === "meridiem") {
|
113
|
+
return value === "AM" || value === "PM";
|
114
|
+
}
|
115
|
+
if (!isValidNumber(value)) {
|
116
|
+
return false;
|
117
|
+
}
|
118
|
+
const valueAsNumber = Number(value);
|
119
|
+
return part === "hour" ? valueAsNumber >= 0 && valueAsNumber < 24 : valueAsNumber >= 0 && valueAsNumber < 60;
|
120
|
+
}
|
121
|
+
function localizeTimePart({ value, part, locale, numberingSystem }) {
|
122
|
+
if (!isValidTimePart(value, part)) {
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
const valueAsNumber = parseInt(value);
|
126
|
+
const date = new Date(Date.UTC(0, 0, 0, part === "hour" ? valueAsNumber : part === "meridiem" ? (value === "AM" ? 0 : 12) : 0, part === "minute" ? valueAsNumber : 0, part === "second" ? valueAsNumber : 0));
|
127
|
+
if (!date) {
|
128
|
+
return;
|
129
|
+
}
|
130
|
+
const formatter = createLocaleDateTimeFormatter(locale, numberingSystem);
|
131
|
+
const parts = formatter.formatToParts(date);
|
132
|
+
return getLocalizedTimePart(part, parts);
|
133
|
+
}
|
134
|
+
function localizeTimeString({ value, locale, numberingSystem, includeSeconds = true }) {
|
135
|
+
if (!isValidTime(value)) {
|
136
|
+
return null;
|
137
|
+
}
|
138
|
+
const { hour, minute, second = "0" } = parseTimeString(value);
|
139
|
+
const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
|
140
|
+
const formatter = createLocaleDateTimeFormatter(locale, numberingSystem, includeSeconds);
|
141
|
+
return (formatter === null || formatter === void 0 ? void 0 : formatter.format(dateFromTimeString)) || null;
|
142
|
+
}
|
143
|
+
function localizeTimeStringToParts({ value, locale, numberingSystem }) {
|
144
|
+
if (!isValidTime(value)) {
|
145
|
+
return null;
|
146
|
+
}
|
147
|
+
const { hour, minute, second = "0" } = parseTimeString(value);
|
148
|
+
const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
|
149
|
+
if (dateFromTimeString) {
|
150
|
+
const formatter = createLocaleDateTimeFormatter(locale, numberingSystem);
|
151
|
+
const parts = formatter.formatToParts(dateFromTimeString);
|
152
|
+
return {
|
153
|
+
localizedHour: getLocalizedTimePart("hour", parts),
|
154
|
+
localizedHourSuffix: getLocalizedTimePart("hourSuffix", parts),
|
155
|
+
localizedMinute: getLocalizedTimePart("minute", parts),
|
156
|
+
localizedMinuteSuffix: getLocalizedTimePart("minuteSuffix", parts),
|
157
|
+
localizedSecond: getLocalizedTimePart("second", parts),
|
158
|
+
localizedSecondSuffix: getLocalizedTimePart("secondSuffix", parts),
|
159
|
+
localizedMeridiem: getLocalizedTimePart("meridiem", parts)
|
160
|
+
};
|
161
|
+
}
|
162
|
+
return null;
|
163
|
+
}
|
164
|
+
function getTimeParts({ value, locale, numberingSystem }) {
|
165
|
+
if (!isValidTime(value)) {
|
166
|
+
return null;
|
167
|
+
}
|
168
|
+
const { hour, minute, second = "0" } = parseTimeString(value);
|
169
|
+
const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
|
170
|
+
if (dateFromTimeString) {
|
171
|
+
const formatter = createLocaleDateTimeFormatter(locale, numberingSystem);
|
172
|
+
const parts = formatter.formatToParts(dateFromTimeString);
|
173
|
+
return parts;
|
174
|
+
}
|
175
|
+
return null;
|
176
|
+
}
|
177
|
+
function parseTimeString(value) {
|
178
|
+
if (isValidTime(value)) {
|
179
|
+
const [hour, minute, second] = value.split(":");
|
180
|
+
return {
|
181
|
+
hour,
|
182
|
+
minute,
|
183
|
+
second
|
184
|
+
};
|
185
|
+
}
|
186
|
+
return {
|
187
|
+
hour: null,
|
188
|
+
minute: null,
|
189
|
+
second: null
|
190
|
+
};
|
191
|
+
}
|
192
|
+
|
193
|
+
/*!
|
194
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
195
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
196
|
+
* v1.0.0-beta.97
|
197
|
+
*/
|
198
|
+
const CSS = {
|
199
|
+
button: "button",
|
200
|
+
buttonBottomLeft: "button--bottom-left",
|
201
|
+
buttonBottomRight: "button--bottom-right",
|
202
|
+
buttonHourDown: "button--hour-down",
|
203
|
+
buttonHourUp: "button--hour-up",
|
204
|
+
buttonMeridiemDown: "button--meridiem-down",
|
205
|
+
buttonMeridiemUp: "button--meridiem-up",
|
206
|
+
buttonMinuteDown: "button--minute-down",
|
207
|
+
buttonMinuteUp: "button--minute-up",
|
208
|
+
buttonSecondDown: "button--second-down",
|
209
|
+
buttonSecondUp: "button--second-up",
|
210
|
+
buttonTopLeft: "button--top-left",
|
211
|
+
buttonTopRight: "button--top-right",
|
212
|
+
column: "column",
|
213
|
+
delimiter: "delimiter",
|
214
|
+
hour: "hour",
|
215
|
+
input: "input",
|
216
|
+
meridiem: "meridiem",
|
217
|
+
minute: "minute",
|
218
|
+
second: "second",
|
219
|
+
showMeridiem: "show-meridiem",
|
220
|
+
showSecond: "show-second",
|
221
|
+
"scale-s": "scale-s",
|
222
|
+
"scale-m": "scale-m",
|
223
|
+
"scale-l": "scale-l",
|
224
|
+
timePicker: "time-picker",
|
225
|
+
meridiemStart: "meridiem--start"
|
226
|
+
};
|
227
|
+
const TEXT = {
|
228
|
+
hour: "Hour",
|
229
|
+
hourDown: "Decrease hour",
|
230
|
+
hourUp: "Increase hour",
|
231
|
+
meridiem: "AM/PM",
|
232
|
+
meridiemDown: "Decrease AM/PM",
|
233
|
+
meridiemUp: "Increase AM/PM",
|
234
|
+
minute: "Minute",
|
235
|
+
minuteDown: "Decrease minute",
|
236
|
+
minuteUp: "Increase minute",
|
237
|
+
second: "Second",
|
238
|
+
secondDown: "Decrease second",
|
239
|
+
secondUp: "Increase second"
|
240
|
+
};
|
241
|
+
|
242
|
+
const timePickerCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:inline-block}.time-picker{display:flex;-webkit-user-select:none;-moz-user-select:none;user-select:none;align-items:center;background-color:var(--calcite-ui-foreground-1);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1);--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);border-radius:var(--calcite-border-radius)}.time-picker .column{display:flex;flex-direction:column}.time-picker .meridiem--start{order:-1}.time-picker .button{display:inline-flex;cursor:pointer;align-items:center;justify-content:center;background-color:var(--calcite-ui-foreground-1)}.time-picker .button:hover,.time-picker .button:focus{background-color:var(--calcite-ui-foreground-2);outline:2px solid transparent;outline-offset:2px}.time-picker .button:active{background-color:var(--calcite-ui-foreground-3)}.time-picker .button.top-left{border-start-start-radius:var(--calcite-border-radius)}.time-picker .button.bottom-left{border-end-start-radius:var(--calcite-border-radius)}.time-picker .button.top-right{border-start-end-radius:var(--calcite-border-radius)}.time-picker .button.bottom-right{border-end-end-radius:var(--calcite-border-radius)}.time-picker .button calcite-icon{color:var(--calcite-ui-text-3)}.time-picker .input{display:inline-flex;cursor:pointer;align-items:center;justify-content:center;background-color:var(--calcite-ui-foreground-1);font-weight:var(--calcite-font-weight-medium)}.time-picker .input:hover{box-shadow:inset 0 0 0 2px var(--calcite-ui-foreground-2)}.time-picker .input:focus,.time-picker .input:hover:focus{outline:2px solid transparent;outline-offset:2px;box-shadow:inset 0 0 0 2px var(--calcite-ui-brand)}.time-picker.scale-s{font-size:var(--calcite-font-size--1)}.time-picker.scale-s .button,.time-picker.scale-s .input{padding-inline:0.75rem;padding-block:0.25rem}.time-picker.scale-s:not(.show-meridiem) .delimiter:last-child{-webkit-padding-end:0.75rem;padding-inline-end:0.75rem}.time-picker.scale-m{font-size:var(--calcite-font-size-0)}.time-picker.scale-m .button,.time-picker.scale-m .input{padding-inline:1rem;padding-block:0.5rem}.time-picker.scale-m:not(.show-meridiem) .delimiter:last-child{-webkit-padding-end:1rem;padding-inline-end:1rem}.time-picker.scale-l{font-size:var(--calcite-font-size-1)}.time-picker.scale-l .button,.time-picker.scale-l .input{padding-inline:1.25rem;padding-block:0.75rem}.time-picker.scale-l:not(.show-meridiem) .delimiter:last-child{-webkit-padding-end:1.25rem;padding-inline-end:1.25rem}";
|
243
|
+
|
244
|
+
function capitalize(str) {
|
245
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
246
|
+
}
|
247
|
+
const TimePicker = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
248
|
+
constructor() {
|
249
|
+
super();
|
250
|
+
this.__registerHost();
|
251
|
+
this.__attachShadow();
|
252
|
+
this.calciteInternalTimePickerBlur = createEvent(this, "calciteInternalTimePickerBlur", 6);
|
253
|
+
this.calciteInternalTimePickerChange = createEvent(this, "calciteInternalTimePickerChange", 6);
|
254
|
+
this.calciteInternalTimePickerFocus = createEvent(this, "calciteInternalTimePickerFocus", 6);
|
255
|
+
//--------------------------------------------------------------------------
|
256
|
+
//
|
257
|
+
// Properties
|
258
|
+
//
|
259
|
+
//--------------------------------------------------------------------------
|
260
|
+
/**
|
261
|
+
* Accessible name for the component's hour input.
|
262
|
+
*
|
263
|
+
* @default "Hour"
|
264
|
+
*/
|
265
|
+
this.intlHour = TEXT.hour;
|
266
|
+
/**
|
267
|
+
* Accessible name for the component's hour down button.
|
268
|
+
*
|
269
|
+
* @default "Decrease hour"
|
270
|
+
*/
|
271
|
+
this.intlHourDown = TEXT.hourDown;
|
272
|
+
/**
|
273
|
+
* Accessible name for the component's hour up button.
|
274
|
+
*
|
275
|
+
* @default "Increase hour"
|
276
|
+
*/
|
277
|
+
this.intlHourUp = TEXT.hourUp;
|
278
|
+
/**
|
279
|
+
* Accessible name for the component's meridiem (AM/PM) input.
|
280
|
+
*
|
281
|
+
* @default "AM/PM"
|
282
|
+
*/
|
283
|
+
this.intlMeridiem = TEXT.meridiem;
|
284
|
+
/**
|
285
|
+
* Accessible name for the component's meridiem (AM/PM) down button.
|
286
|
+
*
|
287
|
+
* @default "Decrease AM/PM"
|
288
|
+
*/
|
289
|
+
this.intlMeridiemDown = TEXT.meridiemDown;
|
290
|
+
/**
|
291
|
+
* Accessible name for the component's meridiem (AM/PM) up button.
|
292
|
+
*
|
293
|
+
* @default "Increase AM/PM"
|
294
|
+
*/
|
295
|
+
this.intlMeridiemUp = TEXT.meridiemUp;
|
296
|
+
/**
|
297
|
+
* Accessible name for the component's minute input.
|
298
|
+
*
|
299
|
+
* @default "Minute"
|
300
|
+
*/
|
301
|
+
this.intlMinute = TEXT.minute;
|
302
|
+
/**
|
303
|
+
* Accessible name for the component's minute down button.
|
304
|
+
*
|
305
|
+
* @default "Decrease minute"
|
306
|
+
*/
|
307
|
+
this.intlMinuteDown = TEXT.minuteDown;
|
308
|
+
/**
|
309
|
+
* Accessible name for the component's minute up button.
|
310
|
+
*
|
311
|
+
* @default "Increase minute"
|
312
|
+
*/
|
313
|
+
this.intlMinuteUp = TEXT.minuteUp;
|
314
|
+
/**
|
315
|
+
* Accessible name for the component's second input.
|
316
|
+
*
|
317
|
+
* @default "Second"
|
318
|
+
*/
|
319
|
+
this.intlSecond = TEXT.second;
|
320
|
+
/**
|
321
|
+
* Accessible name for the component's second down button.
|
322
|
+
*
|
323
|
+
* @default "Decrease second"
|
324
|
+
*/
|
325
|
+
this.intlSecondDown = TEXT.secondDown;
|
326
|
+
/**
|
327
|
+
* Accessible name for the component's second up button.
|
328
|
+
*
|
329
|
+
* @default "Increase second"
|
330
|
+
*/
|
331
|
+
this.intlSecondUp = TEXT.secondUp;
|
332
|
+
/** Specifies the size of the component. */
|
333
|
+
this.scale = "m";
|
334
|
+
/** Specifies the granularity the `value` must adhere to (in seconds). */
|
335
|
+
this.step = 60;
|
336
|
+
/** The component's value in UTC (always 24-hour format). */
|
337
|
+
this.value = null;
|
338
|
+
// --------------------------------------------------------------------------
|
339
|
+
//
|
340
|
+
// State
|
341
|
+
//
|
342
|
+
// --------------------------------------------------------------------------
|
343
|
+
this.effectiveLocale = "";
|
344
|
+
this.showSecond = this.step < 60;
|
345
|
+
this.decrementHour = () => {
|
346
|
+
const newHour = !this.hour ? 0 : this.hour === "00" ? 23 : parseInt(this.hour) - 1;
|
347
|
+
this.setValuePart("hour", newHour);
|
348
|
+
};
|
349
|
+
this.decrementMeridiem = () => {
|
350
|
+
const newMeridiem = this.meridiem === "PM" ? "AM" : "PM";
|
351
|
+
this.setValuePart("meridiem", newMeridiem);
|
352
|
+
};
|
353
|
+
this.decrementMinuteOrSecond = (key) => {
|
354
|
+
let newValue;
|
355
|
+
if (isValidNumber(this[key])) {
|
356
|
+
const valueAsNumber = parseInt(this[key]);
|
357
|
+
newValue = valueAsNumber === 0 ? 59 : valueAsNumber - 1;
|
358
|
+
}
|
359
|
+
else {
|
360
|
+
newValue = 59;
|
361
|
+
}
|
362
|
+
this.setValuePart(key, newValue);
|
363
|
+
};
|
364
|
+
this.decrementMinute = () => {
|
365
|
+
this.decrementMinuteOrSecond("minute");
|
366
|
+
};
|
367
|
+
this.decrementSecond = () => {
|
368
|
+
this.decrementMinuteOrSecond("second");
|
369
|
+
};
|
370
|
+
this.focusHandler = (event) => {
|
371
|
+
this.activeEl = event.currentTarget;
|
372
|
+
};
|
373
|
+
this.hourDownButtonKeyDownHandler = (event) => {
|
374
|
+
if (this.buttonActivated(event)) {
|
375
|
+
this.decrementHour();
|
376
|
+
}
|
377
|
+
};
|
378
|
+
this.hourKeyDownHandler = (event) => {
|
379
|
+
const { key } = event;
|
380
|
+
if (numberKeys.includes(key)) {
|
381
|
+
const keyAsNumber = parseInt(key);
|
382
|
+
let newHour;
|
383
|
+
if (isValidNumber(this.hour)) {
|
384
|
+
switch (this.hourCycle) {
|
385
|
+
case "12":
|
386
|
+
newHour =
|
387
|
+
this.hour === "01" && keyAsNumber >= 0 && keyAsNumber <= 2
|
388
|
+
? `1${keyAsNumber}`
|
389
|
+
: keyAsNumber;
|
390
|
+
break;
|
391
|
+
case "24":
|
392
|
+
if (this.hour === "01") {
|
393
|
+
newHour = `1${keyAsNumber}`;
|
394
|
+
}
|
395
|
+
else if (this.hour === "02" && keyAsNumber >= 0 && keyAsNumber <= 3) {
|
396
|
+
newHour = `2${keyAsNumber}`;
|
397
|
+
}
|
398
|
+
else {
|
399
|
+
newHour = keyAsNumber;
|
400
|
+
}
|
401
|
+
break;
|
402
|
+
}
|
403
|
+
}
|
404
|
+
else {
|
405
|
+
newHour = keyAsNumber;
|
406
|
+
}
|
407
|
+
this.setValuePart("hour", newHour);
|
408
|
+
}
|
409
|
+
else {
|
410
|
+
switch (key) {
|
411
|
+
case "Backspace":
|
412
|
+
case "Delete":
|
413
|
+
this.setValuePart("hour", null);
|
414
|
+
break;
|
415
|
+
case "ArrowDown":
|
416
|
+
event.preventDefault();
|
417
|
+
this.decrementHour();
|
418
|
+
break;
|
419
|
+
case "ArrowUp":
|
420
|
+
event.preventDefault();
|
421
|
+
this.incrementHour();
|
422
|
+
break;
|
423
|
+
case " ":
|
424
|
+
event.preventDefault();
|
425
|
+
break;
|
426
|
+
}
|
427
|
+
}
|
428
|
+
};
|
429
|
+
this.hourUpButtonKeyDownHandler = (event) => {
|
430
|
+
if (this.buttonActivated(event)) {
|
431
|
+
this.incrementHour();
|
432
|
+
}
|
433
|
+
};
|
434
|
+
this.incrementMeridiem = () => {
|
435
|
+
const newMeridiem = this.meridiem === "AM" ? "PM" : "AM";
|
436
|
+
this.setValuePart("meridiem", newMeridiem);
|
437
|
+
};
|
438
|
+
this.incrementHour = () => {
|
439
|
+
const newHour = isValidNumber(this.hour)
|
440
|
+
? this.hour === "23"
|
441
|
+
? 0
|
442
|
+
: parseInt(this.hour) + 1
|
443
|
+
: 1;
|
444
|
+
this.setValuePart("hour", newHour);
|
445
|
+
};
|
446
|
+
this.incrementMinuteOrSecond = (key) => {
|
447
|
+
const newValue = isValidNumber(this[key])
|
448
|
+
? this[key] === "59"
|
449
|
+
? 0
|
450
|
+
: parseInt(this[key]) + 1
|
451
|
+
: 0;
|
452
|
+
this.setValuePart(key, newValue);
|
453
|
+
};
|
454
|
+
this.incrementMinute = () => {
|
455
|
+
this.incrementMinuteOrSecond("minute");
|
456
|
+
};
|
457
|
+
this.incrementSecond = () => {
|
458
|
+
this.incrementMinuteOrSecond("second");
|
459
|
+
};
|
460
|
+
this.meridiemDownButtonKeyDownHandler = (event) => {
|
461
|
+
if (this.buttonActivated(event)) {
|
462
|
+
this.decrementMeridiem();
|
463
|
+
}
|
464
|
+
};
|
465
|
+
this.meridiemKeyDownHandler = (event) => {
|
466
|
+
switch (event.key) {
|
467
|
+
case "a":
|
468
|
+
this.setValuePart("meridiem", "AM");
|
469
|
+
break;
|
470
|
+
case "p":
|
471
|
+
this.setValuePart("meridiem", "PM");
|
472
|
+
break;
|
473
|
+
case "Backspace":
|
474
|
+
case "Delete":
|
475
|
+
this.setValuePart("meridiem", null);
|
476
|
+
break;
|
477
|
+
case "ArrowUp":
|
478
|
+
event.preventDefault();
|
479
|
+
this.incrementMeridiem();
|
480
|
+
break;
|
481
|
+
case "ArrowDown":
|
482
|
+
event.preventDefault();
|
483
|
+
this.decrementMeridiem();
|
484
|
+
break;
|
485
|
+
case " ":
|
486
|
+
event.preventDefault();
|
487
|
+
break;
|
488
|
+
}
|
489
|
+
};
|
490
|
+
this.meridiemUpButtonKeyDownHandler = (event) => {
|
491
|
+
if (this.buttonActivated(event)) {
|
492
|
+
this.incrementMeridiem();
|
493
|
+
}
|
494
|
+
};
|
495
|
+
this.minuteDownButtonKeyDownHandler = (event) => {
|
496
|
+
if (this.buttonActivated(event)) {
|
497
|
+
this.decrementMinute();
|
498
|
+
}
|
499
|
+
};
|
500
|
+
this.minuteKeyDownHandler = (event) => {
|
501
|
+
const { key } = event;
|
502
|
+
if (numberKeys.includes(key)) {
|
503
|
+
const keyAsNumber = parseInt(key);
|
504
|
+
let newMinute;
|
505
|
+
if (isValidNumber(this.minute) && this.minute.startsWith("0")) {
|
506
|
+
const minuteAsNumber = parseInt(this.minute);
|
507
|
+
newMinute =
|
508
|
+
minuteAsNumber > maxTenthForMinuteAndSecond
|
509
|
+
? keyAsNumber
|
510
|
+
: `${minuteAsNumber}${keyAsNumber}`;
|
511
|
+
}
|
512
|
+
else {
|
513
|
+
newMinute = keyAsNumber;
|
514
|
+
}
|
515
|
+
this.setValuePart("minute", newMinute);
|
516
|
+
}
|
517
|
+
else {
|
518
|
+
switch (key) {
|
519
|
+
case "Backspace":
|
520
|
+
case "Delete":
|
521
|
+
this.setValuePart("minute", null);
|
522
|
+
break;
|
523
|
+
case "ArrowDown":
|
524
|
+
event.preventDefault();
|
525
|
+
this.decrementMinute();
|
526
|
+
break;
|
527
|
+
case "ArrowUp":
|
528
|
+
event.preventDefault();
|
529
|
+
this.incrementMinute();
|
530
|
+
break;
|
531
|
+
case " ":
|
532
|
+
event.preventDefault();
|
533
|
+
break;
|
534
|
+
}
|
535
|
+
}
|
536
|
+
};
|
537
|
+
this.minuteUpButtonKeyDownHandler = (event) => {
|
538
|
+
if (this.buttonActivated(event)) {
|
539
|
+
this.incrementMinute();
|
540
|
+
}
|
541
|
+
};
|
542
|
+
this.secondDownButtonKeyDownHandler = (event) => {
|
543
|
+
if (this.buttonActivated(event)) {
|
544
|
+
this.decrementSecond();
|
545
|
+
}
|
546
|
+
};
|
547
|
+
this.secondKeyDownHandler = (event) => {
|
548
|
+
const { key } = event;
|
549
|
+
if (numberKeys.includes(key)) {
|
550
|
+
const keyAsNumber = parseInt(key);
|
551
|
+
let newSecond;
|
552
|
+
if (isValidNumber(this.second) && this.second.startsWith("0")) {
|
553
|
+
const secondAsNumber = parseInt(this.second);
|
554
|
+
newSecond =
|
555
|
+
secondAsNumber > maxTenthForMinuteAndSecond
|
556
|
+
? keyAsNumber
|
557
|
+
: `${secondAsNumber}${keyAsNumber}`;
|
558
|
+
}
|
559
|
+
else {
|
560
|
+
newSecond = keyAsNumber;
|
561
|
+
}
|
562
|
+
this.setValuePart("second", newSecond);
|
563
|
+
}
|
564
|
+
else {
|
565
|
+
switch (key) {
|
566
|
+
case "Backspace":
|
567
|
+
case "Delete":
|
568
|
+
this.setValuePart("second", null);
|
569
|
+
break;
|
570
|
+
case "ArrowDown":
|
571
|
+
event.preventDefault();
|
572
|
+
this.decrementSecond();
|
573
|
+
break;
|
574
|
+
case "ArrowUp":
|
575
|
+
event.preventDefault();
|
576
|
+
this.incrementSecond();
|
577
|
+
break;
|
578
|
+
case " ":
|
579
|
+
event.preventDefault();
|
580
|
+
break;
|
581
|
+
}
|
582
|
+
}
|
583
|
+
};
|
584
|
+
this.secondUpButtonKeyDownHandler = (event) => {
|
585
|
+
if (this.buttonActivated(event)) {
|
586
|
+
this.incrementSecond();
|
587
|
+
}
|
588
|
+
};
|
589
|
+
this.setHourEl = (el) => (this.hourEl = el);
|
590
|
+
this.setMeridiemEl = (el) => (this.meridiemEl = el);
|
591
|
+
this.setMinuteEl = (el) => (this.minuteEl = el);
|
592
|
+
this.setSecondEl = (el) => (this.secondEl = el);
|
593
|
+
this.setValue = (value, emit = true) => {
|
594
|
+
if (isValidTime(value)) {
|
595
|
+
const { hour, minute, second } = parseTimeString(value);
|
596
|
+
const { effectiveLocale: locale, numberingSystem } = this;
|
597
|
+
const { localizedHour, localizedHourSuffix, localizedMinute, localizedMinuteSuffix, localizedSecond, localizedSecondSuffix, localizedMeridiem } = localizeTimeStringToParts({ value, locale, numberingSystem });
|
598
|
+
this.localizedHour = localizedHour;
|
599
|
+
this.localizedHourSuffix = localizedHourSuffix;
|
600
|
+
this.localizedMinute = localizedMinute;
|
601
|
+
this.localizedMinuteSuffix = localizedMinuteSuffix;
|
602
|
+
this.localizedSecond = localizedSecond;
|
603
|
+
this.localizedSecondSuffix = localizedSecondSuffix;
|
604
|
+
this.hour = hour;
|
605
|
+
this.minute = minute;
|
606
|
+
this.second = second;
|
607
|
+
if (localizedMeridiem) {
|
608
|
+
this.localizedMeridiem = localizedMeridiem;
|
609
|
+
this.meridiem = getMeridiem(this.hour);
|
610
|
+
const formatParts = getTimeParts({ value, locale, numberingSystem });
|
611
|
+
this.meridiemOrder = this.getMeridiemOrder(formatParts);
|
612
|
+
}
|
613
|
+
}
|
614
|
+
else {
|
615
|
+
this.hour = null;
|
616
|
+
this.localizedHour = null;
|
617
|
+
this.localizedHourSuffix = null;
|
618
|
+
this.localizedMeridiem = null;
|
619
|
+
this.localizedMinute = null;
|
620
|
+
this.localizedMinuteSuffix = null;
|
621
|
+
this.localizedSecond = null;
|
622
|
+
this.localizedSecondSuffix = null;
|
623
|
+
this.meridiem = null;
|
624
|
+
this.minute = null;
|
625
|
+
this.second = null;
|
626
|
+
this.value = null;
|
627
|
+
}
|
628
|
+
if (emit) {
|
629
|
+
this.calciteInternalTimePickerChange.emit();
|
630
|
+
}
|
631
|
+
};
|
632
|
+
this.setValuePart = (key, value, emit = true) => {
|
633
|
+
var _a;
|
634
|
+
const { effectiveLocale: locale, numberingSystem } = this;
|
635
|
+
if (key === "meridiem") {
|
636
|
+
this.meridiem = value;
|
637
|
+
if (isValidNumber(this.hour)) {
|
638
|
+
const hourAsNumber = parseInt(this.hour);
|
639
|
+
switch (value) {
|
640
|
+
case "AM":
|
641
|
+
if (hourAsNumber >= 12) {
|
642
|
+
this.hour = formatTimePart(hourAsNumber - 12);
|
643
|
+
}
|
644
|
+
break;
|
645
|
+
case "PM":
|
646
|
+
if (hourAsNumber < 12) {
|
647
|
+
this.hour = formatTimePart(hourAsNumber + 12);
|
648
|
+
}
|
649
|
+
break;
|
650
|
+
}
|
651
|
+
this.localizedHour = localizeTimePart({
|
652
|
+
value: this.hour,
|
653
|
+
part: "hour",
|
654
|
+
locale,
|
655
|
+
numberingSystem
|
656
|
+
});
|
657
|
+
}
|
658
|
+
}
|
659
|
+
else {
|
660
|
+
this[key] = typeof value === "number" ? formatTimePart(value) : value;
|
661
|
+
this[`localized${capitalize(key)}`] = localizeTimePart({
|
662
|
+
value: this[key],
|
663
|
+
part: key,
|
664
|
+
locale,
|
665
|
+
numberingSystem
|
666
|
+
});
|
667
|
+
}
|
668
|
+
if (this.hour && this.minute) {
|
669
|
+
const showSeconds = this.second && this.showSecond;
|
670
|
+
this.value = `${this.hour}:${this.minute}:${showSeconds ? this.second : "00"}`;
|
671
|
+
}
|
672
|
+
else {
|
673
|
+
this.value = null;
|
674
|
+
}
|
675
|
+
this.localizedMeridiem = this.value
|
676
|
+
? ((_a = localizeTimeStringToParts({ value: this.value, locale, numberingSystem })) === null || _a === void 0 ? void 0 : _a.localizedMeridiem) || null
|
677
|
+
: localizeTimePart({ value: this.meridiem, part: "meridiem", locale, numberingSystem });
|
678
|
+
if (emit) {
|
679
|
+
this.calciteInternalTimePickerChange.emit();
|
680
|
+
}
|
681
|
+
};
|
682
|
+
}
|
683
|
+
localeChanged() {
|
684
|
+
updateEffectiveLocale(this);
|
685
|
+
}
|
686
|
+
valueWatcher(newValue) {
|
687
|
+
this.setValue(newValue, false);
|
688
|
+
}
|
689
|
+
effectiveLocaleWatcher() {
|
690
|
+
this.updateLocale();
|
691
|
+
}
|
692
|
+
//--------------------------------------------------------------------------
|
693
|
+
//
|
694
|
+
// Event Listeners
|
695
|
+
//
|
696
|
+
//--------------------------------------------------------------------------
|
697
|
+
hostBlurHandler() {
|
698
|
+
this.calciteInternalTimePickerBlur.emit();
|
699
|
+
}
|
700
|
+
hostFocusHandler() {
|
701
|
+
this.calciteInternalTimePickerFocus.emit();
|
702
|
+
}
|
703
|
+
keyDownHandler(event) {
|
704
|
+
const { defaultPrevented, key } = event;
|
705
|
+
if (defaultPrevented) {
|
706
|
+
return;
|
707
|
+
}
|
708
|
+
switch (this.activeEl) {
|
709
|
+
case this.hourEl:
|
710
|
+
if (key === "ArrowRight") {
|
711
|
+
this.setFocus("minute");
|
712
|
+
event.preventDefault();
|
713
|
+
}
|
714
|
+
break;
|
715
|
+
case this.minuteEl:
|
716
|
+
switch (key) {
|
717
|
+
case "ArrowLeft":
|
718
|
+
this.setFocus("hour");
|
719
|
+
event.preventDefault();
|
720
|
+
break;
|
721
|
+
case "ArrowRight":
|
722
|
+
if (this.step !== 60) {
|
723
|
+
this.setFocus("second");
|
724
|
+
event.preventDefault();
|
725
|
+
}
|
726
|
+
else if (this.hourCycle === "12") {
|
727
|
+
this.setFocus("meridiem");
|
728
|
+
event.preventDefault();
|
729
|
+
}
|
730
|
+
break;
|
731
|
+
}
|
732
|
+
break;
|
733
|
+
case this.secondEl:
|
734
|
+
switch (key) {
|
735
|
+
case "ArrowLeft":
|
736
|
+
this.setFocus("minute");
|
737
|
+
event.preventDefault();
|
738
|
+
break;
|
739
|
+
case "ArrowRight":
|
740
|
+
if (this.hourCycle === "12") {
|
741
|
+
this.setFocus("meridiem");
|
742
|
+
event.preventDefault();
|
743
|
+
}
|
744
|
+
break;
|
745
|
+
}
|
746
|
+
break;
|
747
|
+
case this.meridiemEl:
|
748
|
+
switch (key) {
|
749
|
+
case "ArrowLeft":
|
750
|
+
if (this.step !== 60) {
|
751
|
+
this.setFocus("second");
|
752
|
+
event.preventDefault();
|
753
|
+
}
|
754
|
+
else {
|
755
|
+
this.setFocus("minute");
|
756
|
+
event.preventDefault();
|
757
|
+
}
|
758
|
+
break;
|
759
|
+
}
|
760
|
+
break;
|
761
|
+
}
|
762
|
+
}
|
763
|
+
//--------------------------------------------------------------------------
|
764
|
+
//
|
765
|
+
// Public Methods
|
766
|
+
//
|
767
|
+
//--------------------------------------------------------------------------
|
768
|
+
/**
|
769
|
+
* Sets focus on the component.
|
770
|
+
*
|
771
|
+
* @param target
|
772
|
+
*/
|
773
|
+
async setFocus(target) {
|
774
|
+
var _a;
|
775
|
+
(_a = this[`${target || "hour"}El`]) === null || _a === void 0 ? void 0 : _a.focus();
|
776
|
+
}
|
777
|
+
// --------------------------------------------------------------------------
|
778
|
+
//
|
779
|
+
// Private Methods
|
780
|
+
//
|
781
|
+
// --------------------------------------------------------------------------
|
782
|
+
buttonActivated(event) {
|
783
|
+
const { key } = event;
|
784
|
+
if (key === " ") {
|
785
|
+
event.preventDefault();
|
786
|
+
}
|
787
|
+
return isActivationKey(key);
|
788
|
+
}
|
789
|
+
getMeridiemOrder(formatParts) {
|
790
|
+
const locale = this.effectiveLocale;
|
791
|
+
const isRTLKind = locale === "ar" || locale === "he";
|
792
|
+
if (formatParts && !isRTLKind) {
|
793
|
+
const index = formatParts.findIndex((parts) => {
|
794
|
+
return parts.value === this.localizedMeridiem;
|
795
|
+
});
|
796
|
+
return index;
|
797
|
+
}
|
798
|
+
return 0;
|
799
|
+
}
|
800
|
+
updateLocale() {
|
801
|
+
this.hourCycle = getLocaleHourCycle(this.effectiveLocale, this.numberingSystem);
|
802
|
+
this.setValue(this.value, false);
|
803
|
+
}
|
804
|
+
// --------------------------------------------------------------------------
|
805
|
+
//
|
806
|
+
// Lifecycle
|
807
|
+
//
|
808
|
+
// --------------------------------------------------------------------------
|
809
|
+
connectedCallback() {
|
810
|
+
connectLocalized(this);
|
811
|
+
this.updateLocale();
|
812
|
+
this.meridiemOrder = this.getMeridiemOrder(getTimeParts({
|
813
|
+
value: "0:00:00",
|
814
|
+
locale: this.effectiveLocale,
|
815
|
+
numberingSystem: this.numberingSystem
|
816
|
+
}));
|
817
|
+
}
|
818
|
+
disconnectedCallback() {
|
819
|
+
disconnectLocalized(this);
|
820
|
+
}
|
821
|
+
// --------------------------------------------------------------------------
|
822
|
+
//
|
823
|
+
// Render Methods
|
824
|
+
//
|
825
|
+
// --------------------------------------------------------------------------
|
826
|
+
render() {
|
827
|
+
const hourIsNumber = isValidNumber(this.hour);
|
828
|
+
const iconScale = this.scale === "s" || this.scale === "m" ? "s" : "m";
|
829
|
+
const minuteIsNumber = isValidNumber(this.minute);
|
830
|
+
const secondIsNumber = isValidNumber(this.second);
|
831
|
+
const showMeridiem = this.hourCycle === "12";
|
832
|
+
return (h("div", { class: {
|
833
|
+
[CSS.timePicker]: true,
|
834
|
+
[CSS.showMeridiem]: showMeridiem,
|
835
|
+
[CSS.showSecond]: this.showSecond,
|
836
|
+
[CSS[`scale-${this.scale}`]]: true
|
837
|
+
}, dir: "ltr" }, h("div", { class: CSS.column, role: "group" }, h("span", { "aria-label": this.intlHourUp, class: {
|
838
|
+
[CSS.button]: true,
|
839
|
+
[CSS.buttonHourUp]: true,
|
840
|
+
[CSS.buttonTopLeft]: true
|
841
|
+
}, onClick: this.incrementHour, onKeyDown: this.hourUpButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-up", scale: iconScale })), h("span", { "aria-label": this.intlHour, "aria-valuemax": "23", "aria-valuemin": "1", "aria-valuenow": (hourIsNumber && parseInt(this.hour)) || "0", "aria-valuetext": this.hour, class: {
|
842
|
+
[CSS.input]: true,
|
843
|
+
[CSS.hour]: true
|
844
|
+
}, onFocus: this.focusHandler, onKeyDown: this.hourKeyDownHandler, ref: this.setHourEl, role: "spinbutton", tabIndex: 0 }, this.localizedHour || "--"), h("span", { "aria-label": this.intlHourDown, class: {
|
845
|
+
[CSS.button]: true,
|
846
|
+
[CSS.buttonHourDown]: true,
|
847
|
+
[CSS.buttonBottomLeft]: true
|
848
|
+
}, onClick: this.decrementHour, onKeyDown: this.hourDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale }))), h("span", { class: CSS.delimiter }, this.localizedHourSuffix), h("div", { class: CSS.column, role: "group" }, h("span", { "aria-label": this.intlMinuteUp, class: {
|
849
|
+
[CSS.button]: true,
|
850
|
+
[CSS.buttonMinuteUp]: true
|
851
|
+
}, onClick: this.incrementMinute, onKeyDown: this.minuteUpButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-up", scale: iconScale })), h("span", { "aria-label": this.intlMinute, "aria-valuemax": "12", "aria-valuemin": "1", "aria-valuenow": (minuteIsNumber && parseInt(this.minute)) || "0", "aria-valuetext": this.minute, class: {
|
852
|
+
[CSS.input]: true,
|
853
|
+
[CSS.minute]: true
|
854
|
+
}, onFocus: this.focusHandler, onKeyDown: this.minuteKeyDownHandler, ref: this.setMinuteEl, role: "spinbutton", tabIndex: 0 }, this.localizedMinute || "--"), h("span", { "aria-label": this.intlMinuteDown, class: {
|
855
|
+
[CSS.button]: true,
|
856
|
+
[CSS.buttonMinuteDown]: true
|
857
|
+
}, onClick: this.decrementMinute, onKeyDown: this.minuteDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale }))), this.showSecond && h("span", { class: CSS.delimiter }, this.localizedMinuteSuffix), this.showSecond && (h("div", { class: CSS.column, role: "group" }, h("span", { "aria-label": this.intlSecondUp, class: {
|
858
|
+
[CSS.button]: true,
|
859
|
+
[CSS.buttonSecondUp]: true
|
860
|
+
}, onClick: this.incrementSecond, onKeyDown: this.secondUpButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-up", scale: iconScale })), h("span", { "aria-label": this.intlSecond, "aria-valuemax": "59", "aria-valuemin": "0", "aria-valuenow": (secondIsNumber && parseInt(this.second)) || "0", "aria-valuetext": this.second, class: {
|
861
|
+
[CSS.input]: true,
|
862
|
+
[CSS.second]: true
|
863
|
+
}, onFocus: this.focusHandler, onKeyDown: this.secondKeyDownHandler, ref: this.setSecondEl, role: "spinbutton", tabIndex: 0 }, this.localizedSecond || "--"), h("span", { "aria-label": this.intlSecondDown, class: {
|
864
|
+
[CSS.button]: true,
|
865
|
+
[CSS.buttonSecondDown]: true
|
866
|
+
}, onClick: this.decrementSecond, onKeyDown: this.secondDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale })))), this.localizedSecondSuffix && (h("span", { class: CSS.delimiter }, this.localizedSecondSuffix)), showMeridiem && (h("div", { class: {
|
867
|
+
[CSS.column]: true,
|
868
|
+
[CSS.meridiemStart]: this.meridiemOrder === 0
|
869
|
+
}, role: "group" }, h("span", { "aria-label": this.intlMeridiemUp, class: {
|
870
|
+
[CSS.button]: true,
|
871
|
+
[CSS.buttonMeridiemUp]: true,
|
872
|
+
[CSS.buttonTopRight]: true
|
873
|
+
}, onClick: this.incrementMeridiem, onKeyDown: this.meridiemUpButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-up", scale: iconScale })), h("span", { "aria-label": this.intlMeridiem, "aria-valuemax": "2", "aria-valuemin": "1", "aria-valuenow": (this.meridiem === "PM" && "2") || "1", "aria-valuetext": this.meridiem, class: {
|
874
|
+
[CSS.input]: true,
|
875
|
+
[CSS.meridiem]: true
|
876
|
+
}, onFocus: this.focusHandler, onKeyDown: this.meridiemKeyDownHandler, ref: this.setMeridiemEl, role: "spinbutton", tabIndex: 0 }, this.localizedMeridiem || "--"), h("span", { "aria-label": this.intlMeridiemDown, class: {
|
877
|
+
[CSS.button]: true,
|
878
|
+
[CSS.buttonMeridiemDown]: true,
|
879
|
+
[CSS.buttonBottomRight]: true
|
880
|
+
}, onClick: this.decrementMeridiem, onKeyDown: this.meridiemDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale }))))));
|
881
|
+
}
|
882
|
+
get el() { return this; }
|
883
|
+
static get watchers() { return {
|
884
|
+
"locale": ["localeChanged"],
|
885
|
+
"value": ["valueWatcher"],
|
886
|
+
"effectiveLocale": ["effectiveLocaleWatcher"]
|
887
|
+
}; }
|
888
|
+
static get style() { return timePickerCss; }
|
889
|
+
}, [1, "calcite-time-picker", {
|
890
|
+
"intlHour": [1, "intl-hour"],
|
891
|
+
"intlHourDown": [1, "intl-hour-down"],
|
892
|
+
"intlHourUp": [1, "intl-hour-up"],
|
893
|
+
"intlMeridiem": [1, "intl-meridiem"],
|
894
|
+
"intlMeridiemDown": [1, "intl-meridiem-down"],
|
895
|
+
"intlMeridiemUp": [1, "intl-meridiem-up"],
|
896
|
+
"intlMinute": [1, "intl-minute"],
|
897
|
+
"intlMinuteDown": [1, "intl-minute-down"],
|
898
|
+
"intlMinuteUp": [1, "intl-minute-up"],
|
899
|
+
"intlSecond": [1, "intl-second"],
|
900
|
+
"intlSecondDown": [1, "intl-second-down"],
|
901
|
+
"intlSecondUp": [1, "intl-second-up"],
|
902
|
+
"locale": [1025],
|
903
|
+
"scale": [513],
|
904
|
+
"step": [514],
|
905
|
+
"numberingSystem": [1, "numbering-system"],
|
906
|
+
"value": [1025],
|
907
|
+
"effectiveLocale": [32],
|
908
|
+
"hour": [32],
|
909
|
+
"hourCycle": [32],
|
910
|
+
"localizedHour": [32],
|
911
|
+
"localizedHourSuffix": [32],
|
912
|
+
"localizedMeridiem": [32],
|
913
|
+
"localizedMinute": [32],
|
914
|
+
"localizedMinuteSuffix": [32],
|
915
|
+
"localizedSecond": [32],
|
916
|
+
"localizedSecondSuffix": [32],
|
917
|
+
"meridiem": [32],
|
918
|
+
"minute": [32],
|
919
|
+
"second": [32],
|
920
|
+
"showSecond": [32],
|
921
|
+
"setFocus": [64]
|
922
|
+
}, [[0, "blur", "hostBlurHandler"], [0, "focus", "hostFocusHandler"], [0, "keydown", "keyDownHandler"]]]);
|
923
|
+
function defineCustomElement() {
|
924
|
+
if (typeof customElements === "undefined") {
|
925
|
+
return;
|
926
|
+
}
|
927
|
+
const components = ["calcite-time-picker", "calcite-icon"];
|
928
|
+
components.forEach(tagName => { switch (tagName) {
|
929
|
+
case "calcite-time-picker":
|
930
|
+
if (!customElements.get(tagName)) {
|
931
|
+
customElements.define(tagName, TimePicker);
|
932
|
+
}
|
933
|
+
break;
|
934
|
+
case "calcite-icon":
|
935
|
+
if (!customElements.get(tagName)) {
|
936
|
+
defineCustomElement$1();
|
937
|
+
}
|
938
|
+
break;
|
939
|
+
} });
|
940
|
+
}
|
941
|
+
defineCustomElement();
|
942
|
+
|
943
|
+
export { TimePicker as T, defineCustomElement as d, formatTimeString as f, isValidTime as i, localizeTimeString as l };
|