12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-1f9b54dc.js';
- import { g as guid } from './guid-9f15e57a.js';
- import { i as isValidNumber, g as getSupportedLocale, b as getSupportedNumberingSystem, n as numberStringFormatter, u as updateEffectiveLocale, c as connectLocalized, d as disconnectLocalized } from './locale-35f81208.js';
- import { c as connectLabel, d as disconnectLabel, g as getLabelText } from './label-333c4a4c.js';
- import { s as submitForm, c as connectForm, d as disconnectForm, H as HiddenFormInputSlot } from './form-80dbd90e.js';
- import { u as updateHostInteraction } from './interactive-5db230e8.js';
- import { n as numberKeys, i as isActivationKey } from './key-acc755b7.js';
- import './observers-9f44e9b3.js';
- import './dom-8f0a9ff2.js';
- import './resources-9c476cb6.js';
- const maxTenthForMinuteAndSecond = 5;
- function createLocaleDateTimeFormatter(locale, numberingSystem, includeSeconds = true) {
- try {
- const options = {
- hour: "2-digit",
- minute: "2-digit",
- timeZone: "UTC",
- numberingSystem: getSupportedNumberingSystem(numberingSystem)
- };
- if (includeSeconds) {
- options.second = "2-digit";
- }
- return new Intl.DateTimeFormat(getSupportedLocale(locale), options);
- }
- catch (error) {
- throw new Error(`Invalid locale supplied while attempting to create a DateTime formatter: ${locale}`);
- }
- }
- function formatTimePart(number) {
- const numberAsString = number.toString();
- return number >= 0 && number <= 9 ? numberAsString.padStart(2, "0") : numberAsString;
- }
- function formatTimeString(value) {
- if (!isValidTime(value)) {
- return null;
- }
- const [hourString, minuteString, secondString] = value.split(":");
- const hour = formatTimePart(parseInt(hourString));
- const minute = formatTimePart(parseInt(minuteString));
- if (secondString) {
- const second = formatTimePart(parseInt(secondString));
- return `${hour}:${minute}:${second}`;
- }
- return `${hour}:${minute}`;
- }
- function getLocaleHourCycle(locale, numberingSystem) {
- const formatter = createLocaleDateTimeFormatter(locale, numberingSystem);
- const parts = formatter.formatToParts(new Date(Date.UTC(0, 0, 0, 0, 0, 0)));
- return getLocalizedTimePart("meridiem", parts) ? "12" : "24";
- }
- function getLocalizedTimePart(part, parts) {
- var _a, _b, _c, _d;
- if (!part || !parts) {
- return null;
- }
- if (part === "hourSuffix") {
- const hourIndex = parts.indexOf(parts.find(({ type }) => type === "hour"));
- const minuteIndex = parts.indexOf(parts.find(({ type }) => type === "minute"));
- const hourSuffix = parts[hourIndex + 1];
- return hourSuffix && hourSuffix.type === "literal" && minuteIndex - hourIndex === 2
- ? ((_a = hourSuffix.value) === null || _a === void 0 ? void 0 : _a.trim()) || null
- : null;
- }
- if (part === "minuteSuffix") {
- const minuteIndex = parts.indexOf(parts.find(({ type }) => type === "minute"));
- const secondIndex = parts.indexOf(parts.find(({ type }) => type === "second"));
- const minuteSuffix = parts[minuteIndex + 1];
- return minuteSuffix && minuteSuffix.type === "literal" && secondIndex - minuteIndex === 2
- ? ((_b = minuteSuffix.value) === null || _b === void 0 ? void 0 : _b.trim()) || null
- : null;
- }
- if (part === "secondSuffix") {
- const secondIndex = parts.indexOf(parts.find(({ type }) => type === "second"));
- const secondSuffix = parts[secondIndex + 1];
- return secondSuffix && secondSuffix.type === "literal" ? ((_c = secondSuffix.value) === null || _c === void 0 ? void 0 : _c.trim()) || null : null;
- }
- return ((_d = parts.find(({ type }) => (part == "meridiem" ? type === "dayPeriod" : type === part))) === null || _d === void 0 ? void 0 : _d.value) || null;
- }
- function getMeridiem(hour) {
- if (!isValidNumber(hour)) {
- return null;
- }
- const hourAsNumber = parseInt(hour);
- return hourAsNumber >= 0 && hourAsNumber <= 11 ? "AM" : "PM";
- }
- function isValidTime(value) {
- if (!value || value.startsWith(":") || value.endsWith(":")) {
- return false;
- }
- const splitValue = value.split(":");
- const validLength = splitValue.length > 1 && splitValue.length < 4;
- if (!validLength) {
- return false;
- }
- const [hour, minute, second] = splitValue;
- const hourAsNumber = parseInt(splitValue[0]);
- const minuteAsNumber = parseInt(splitValue[1]);
- const secondAsNumber = parseInt(splitValue[2]);
- const hourValid = isValidNumber(hour) && hourAsNumber >= 0 && hourAsNumber < 24;
- const minuteValid = isValidNumber(minute) && minuteAsNumber >= 0 && minuteAsNumber < 60;
- const secondValid = isValidNumber(second) && secondAsNumber >= 0 && secondAsNumber < 60;
- if ((hourValid && minuteValid && !second) || (hourValid && minuteValid && secondValid)) {
- return true;
- }
- }
- function isValidTimePart(value, part) {
- if (part === "meridiem") {
- return value === "AM" || value === "PM";
- }
- if (!isValidNumber(value)) {
- return false;
- }
- const valueAsNumber = Number(value);
- return part === "hour" ? valueAsNumber >= 0 && valueAsNumber < 24 : valueAsNumber >= 0 && valueAsNumber < 60;
- }
- function localizeTimePart({ value, part, locale, numberingSystem }) {
- if (!isValidTimePart(value, part)) {
- return;
- }
- const valueAsNumber = parseInt(value);
- 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));
- if (!date) {
- return;
- }
- const formatter = createLocaleDateTimeFormatter(locale, numberingSystem);
- const parts = formatter.formatToParts(date);
- return getLocalizedTimePart(part, parts);
- }
- function localizeTimeString({ value, locale, numberingSystem, includeSeconds = true }) {
- if (!isValidTime(value)) {
- return null;
- }
- const { hour, minute, second = "0" } = parseTimeString(value);
- const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
- const formatter = createLocaleDateTimeFormatter(locale, numberingSystem, includeSeconds);
- return (formatter === null || formatter === void 0 ? void 0 : formatter.format(dateFromTimeString)) || null;
- }
- function localizeTimeStringToParts({ value, locale, numberingSystem }) {
- if (!isValidTime(value)) {
- return null;
- }
- const { hour, minute, second = "0" } = parseTimeString(value);
- const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
- if (dateFromTimeString) {
- const formatter = createLocaleDateTimeFormatter(locale, numberingSystem);
- const parts = formatter.formatToParts(dateFromTimeString);
- return {
- localizedHour: getLocalizedTimePart("hour", parts),
- localizedHourSuffix: getLocalizedTimePart("hourSuffix", parts),
- localizedMinute: getLocalizedTimePart("minute", parts),
- localizedMinuteSuffix: getLocalizedTimePart("minuteSuffix", parts),
- localizedSecond: getLocalizedTimePart("second", parts),
- localizedSecondSuffix: getLocalizedTimePart("secondSuffix", parts),
- localizedMeridiem: getLocalizedTimePart("meridiem", parts)
- };
- }
- return null;
- }
- function getTimeParts({ value, locale, numberingSystem }) {
- if (!isValidTime(value)) {
- return null;
- }
- const { hour, minute, second = "0" } = parseTimeString(value);
- const dateFromTimeString = new Date(Date.UTC(0, 0, 0, parseInt(hour), parseInt(minute), parseInt(second)));
- if (dateFromTimeString) {
- const formatter = createLocaleDateTimeFormatter(locale, numberingSystem);
- const parts = formatter.formatToParts(dateFromTimeString);
- return parts;
- }
- return null;
- }
- function parseTimeString(value) {
- if (isValidTime(value)) {
- const [hour, minute, second] = value.split(":");
- return {
- hour,
- minute,
- second
- };
- }
- return {
- hour: null,
- minute: null,
- second: null
- };
- }
- const inputTimePickerCss = "@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([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{display:inline-block;-webkit-user-select:none;user-select:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}::slotted(input[slot=hidden-form-input]){margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;inset:0 !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
- const InputTimePicker = class {
- constructor(hostRef) {
- registerInstance(this, hostRef);
- this.calciteInputTimePickerChange = createEvent(this, "calciteInputTimePickerChange", 7);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /**
- * When `true`, the component is active.
- *
- * @deprecated Use `open` instead.
- */
- this.active = false;
- /** When `true`, displays the `calcite-time-picker` component. */
- this.open = false;
- /** When `true`, interaction is prevented and the component is displayed with lower opacity. */
- this.disabled = false;
- /**
- * When `true`, the component's value can be read, but controls are not accessible and the value cannot be modified.
- *
- * @mdn [readOnly](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)
- */
- this.readOnly = false;
- /**
- * When `true`, the component must have a value in order for the form to submit.
- *
- * @internal
- */
- this.required = false;
- /** Specifies the size of the component. */
- this.scale = "m";
- /**
- * Determines the type of positioning to use for the overlaid content.
- *
- * Using `"absolute"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout.
- *
- * `"fixed"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `"fixed"`.
- *
- */
- this.overlayPositioning = "absolute";
- /**
- * Determines where the popover will be positioned relative to the input.
- *
- * @see [LogicalPlacement](https://github.com/Esri/calcite-components/blob/master/src/utils/floating-ui.ts#L25)
- */
- this.placement = "auto";
- /** Specifies the granularity the component's `value` must adhere to (in seconds). */
- this.step = 60;
- /** The component's value in UTC (always 24-hour format). */
- this.value = null;
- /** whether the value of the input was changed as a result of user typing or not */
- this.internalValueChange = false;
- this.previousValidValue = null;
- this.referenceElementId = `input-time-picker-${guid()}`;
- //--------------------------------------------------------------------------
- //
- // State
- //
- //--------------------------------------------------------------------------
- this.effectiveLocale = "";
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- this.calciteInternalInputBlurHandler = () => {
- this.open = false;
- const shouldIncludeSeconds = this.shouldIncludeSeconds();
- const { effectiveLocale: locale, numberingSystem, value, calciteInputEl } = this;
- numberStringFormatter.numberFormatOptions = {
- locale,
- numberingSystem,
- useGrouping: false
- };
- const delocalizedValue = numberStringFormatter.delocalize(calciteInputEl.value);
- const localizedInputValue = localizeTimeString({
- value: delocalizedValue,
- includeSeconds: shouldIncludeSeconds,
- locale,
- numberingSystem
- });
- this.setInputValue(localizedInputValue ||
- localizeTimeString({ value, locale, numberingSystem, includeSeconds: shouldIncludeSeconds }));
- };
- this.calciteInternalInputFocusHandler = (event) => {
- if (!this.readOnly) {
- this.open = true;
- event.stopPropagation();
- }
- };
- this.calciteInputInputHandler = (event) => {
- const target = event.target;
- numberStringFormatter.numberFormatOptions = {
- locale: this.effectiveLocale,
- numberingSystem: this.numberingSystem,
- useGrouping: false
- };
- const delocalizedValue = numberStringFormatter.delocalize(target.value);
- this.setValue({ value: delocalizedValue });
- // only translate the numerals until blur
- const localizedValue = delocalizedValue
- .split("")
- .map((char) => numberKeys.includes(char)
- ? numberStringFormatter.numberFormatter.format(Number(char))
- : char)
- .join("");
- this.setInputValue(localizedValue);
- };
- this.timePickerChangeHandler = (event) => {
- event.stopPropagation();
- const target = event.target;
- const value = target.value;
- this.setValue({ value, origin: "time-picker" });
- };
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.keyDownHandler = (event) => {
- const { defaultPrevented, key } = event;
- if (defaultPrevented) {
- return;
- }
- if (key === "Enter") {
- if (submitForm(this)) {
- event.preventDefault();
- }
- }
- if (key === "Escape" && this.open) {
- this.open = false;
- event.preventDefault();
- }
- };
- this.setCalcitePopoverEl = (el) => {
- this.popoverEl = el;
- };
- this.setCalciteInputEl = (el) => {
- this.calciteInputEl = el;
- };
- this.setCalciteTimePickerEl = (el) => {
- this.calciteTimePickerEl = el;
- };
- this.setInputValue = (newInputValue) => {
- if (!this.calciteInputEl) {
- return;
- }
- this.calciteInputEl.value = newInputValue;
- };
- this.setValue = ({ value, origin = "input" }) => {
- const previousValue = this.value;
- const newValue = formatTimeString(value);
- const newLocalizedValue = localizeTimeString({
- value: newValue,
- locale: this.effectiveLocale,
- numberingSystem: this.numberingSystem,
- includeSeconds: this.shouldIncludeSeconds()
- });
- this.internalValueChange = origin !== "external" && origin !== "loading";
- const shouldEmit = origin !== "loading" &&
- origin !== "external" &&
- ((value !== this.previousValidValue && !value) ||
- !!(!this.previousValidValue && newValue) ||
- (newValue !== this.previousValidValue && newValue));
- if (value) {
- if (shouldEmit) {
- this.previousValidValue = newValue;
- }
- if (newValue && newValue !== this.value) {
- this.value = newValue;
- }
- this.localizedValue = newLocalizedValue;
- }
- else {
- this.value = value;
- this.localizedValue = null;
- }
- if (origin === "time-picker" || origin === "external") {
- this.setInputValue(newLocalizedValue);
- }
- if (shouldEmit) {
- const changeEvent = this.calciteInputTimePickerChange.emit();
- if (changeEvent.defaultPrevented) {
- this.internalValueChange = false;
- this.value = previousValue;
- this.setInputValue(previousValue);
- this.previousValidValue = previousValue;
- }
- else {
- this.previousValidValue = newValue;
- }
- }
- };
- }
- activeHandler(value) {
- this.open = value;
- }
- openHandler(value) {
- this.active = value;
- if (this.disabled || this.readOnly) {
- this.open = false;
- return;
- }
- if (value) {
- this.reposition(true);
- }
- }
- handleDisabledAndReadOnlyChange(value) {
- if (!value) {
- this.open = false;
- }
- }
- localeChanged() {
- updateEffectiveLocale(this);
- }
- valueWatcher(newValue) {
- if (!this.internalValueChange) {
- this.setValue({ value: newValue, origin: "external" });
- }
- this.internalValueChange = false;
- }
- effectiveLocaleWatcher() {
- this.setInputValue(localizeTimeString({
- value: this.value,
- locale: this.effectiveLocale,
- numberingSystem: this.numberingSystem,
- includeSeconds: this.shouldIncludeSeconds()
- }));
- }
- clickHandler(event) {
- if (event.composedPath().includes(this.calciteTimePickerEl)) {
- return;
- }
- this.setFocus();
- }
- timePickerBlurHandler(event) {
- event.preventDefault();
- event.stopPropagation();
- this.open = false;
- }
- timePickerFocusHandler(event) {
- event.preventDefault();
- event.stopPropagation();
- if (!this.readOnly) {
- this.open = true;
- }
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Sets focus on the component. */
- async setFocus() {
- var _a;
- (_a = this.calciteInputEl) === null || _a === void 0 ? void 0 : _a.setFocus();
- }
- /**
- * Updates the position of the component.
- *
- * @param delayed
- */
- async reposition(delayed = false) {
- var _a;
- (_a = this.popoverEl) === null || _a === void 0 ? void 0 : _a.reposition(delayed);
- }
- onLabelClick() {
- this.setFocus();
- }
- shouldIncludeSeconds() {
- return this.step < 60;
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- connectLocalized(this);
- const { active, open } = this;
- if (this.value) {
- this.setValue({ value: isValidTime(this.value) ? this.value : undefined, origin: "loading" });
- }
- connectLabel(this);
- connectForm(this);
- if (open) {
- this.active = open;
- }
- else if (active) {
- this.open = active;
- }
- }
- componentDidLoad() {
- this.setInputValue(this.localizedValue);
- }
- disconnectedCallback() {
- disconnectLabel(this);
- disconnectForm(this);
- disconnectLocalized(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const popoverId = `${this.referenceElementId}-popover`;
- return (h(Host, { onKeyDown: this.keyDownHandler }, h("div", { "aria-controls": popoverId, "aria-haspopup": "dialog", "aria-label": this.name, "aria-owns": popoverId, id: this.referenceElementId, role: "combobox" }, h("calcite-input", { disabled: this.disabled, icon: "clock", label: getLabelText(this), onCalciteInputInput: this.calciteInputInputHandler, onCalciteInternalInputBlur: this.calciteInternalInputBlurHandler, onCalciteInternalInputFocus: this.calciteInternalInputFocusHandler, readOnly: this.readOnly, ref: this.setCalciteInputEl, scale: this.scale, step: this.step })), h("calcite-popover", { id: popoverId, label: "Time Picker", open: this.open, overlayPositioning: this.overlayPositioning, placement: this.placement, ref: this.setCalcitePopoverEl, referenceElement: this.referenceElementId, triggerDisabled: true }, h("calcite-time-picker", { intlHour: this.intlHour, intlHourDown: this.intlHourDown, intlHourUp: this.intlHourUp, intlMeridiem: this.intlMeridiem, intlMeridiemDown: this.intlMeridiemDown, intlMeridiemUp: this.intlMeridiemUp, intlMinute: this.intlMinute, intlMinuteDown: this.intlMinuteDown, intlMinuteUp: this.intlMinuteUp, intlSecond: this.intlSecond, intlSecondDown: this.intlSecondDown, intlSecondUp: this.intlSecondUp, lang: this.effectiveLocale, numberingSystem: this.numberingSystem, onCalciteInternalTimePickerChange: this.timePickerChangeHandler, ref: this.setCalciteTimePickerEl, scale: this.scale, step: this.step, value: this.value })), h(HiddenFormInputSlot, { component: this })));
- }
- get el() { return getElement(this); }
- static get watchers() { return {
- "active": ["activeHandler"],
- "open": ["openHandler"],
- "disabled": ["handleDisabledAndReadOnlyChange"],
- "readOnly": ["handleDisabledAndReadOnlyChange"],
- "locale": ["localeChanged"],
- "value": ["valueWatcher"],
- "effectiveLocale": ["effectiveLocaleWatcher"]
- }; }
- };
- InputTimePicker.style = inputTimePickerCss;
- const CSS = {
- button: "button",
- buttonBottomLeft: "button--bottom-left",
- buttonBottomRight: "button--bottom-right",
- buttonHourDown: "button--hour-down",
- buttonHourUp: "button--hour-up",
- buttonMeridiemDown: "button--meridiem-down",
- buttonMeridiemUp: "button--meridiem-up",
- buttonMinuteDown: "button--minute-down",
- buttonMinuteUp: "button--minute-up",
- buttonSecondDown: "button--second-down",
- buttonSecondUp: "button--second-up",
- buttonTopLeft: "button--top-left",
- buttonTopRight: "button--top-right",
- column: "column",
- delimiter: "delimiter",
- hour: "hour",
- input: "input",
- meridiem: "meridiem",
- minute: "minute",
- second: "second",
- showMeridiem: "show-meridiem",
- showSecond: "show-second",
- "scale-s": "scale-s",
- "scale-m": "scale-m",
- "scale-l": "scale-l",
- timePicker: "time-picker",
- meridiemStart: "meridiem--start"
- };
- const TEXT = {
- hour: "Hour",
- hourDown: "Decrease hour",
- hourUp: "Increase hour",
- meridiem: "AM/PM",
- meridiemDown: "Decrease AM/PM",
- meridiemUp: "Increase AM/PM",
- minute: "Minute",
- minuteDown: "Decrease minute",
- minuteUp: "Increase minute",
- second: "Second",
- secondDown: "Decrease second",
- secondUp: "Increase second"
- };
- 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;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{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{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{padding-inline-end:1.25rem}";
- function capitalize(str) {
- return str.charAt(0).toUpperCase() + str.slice(1);
- }
- const TimePicker = class {
- constructor(hostRef) {
- registerInstance(this, hostRef);
- this.calciteInternalTimePickerBlur = createEvent(this, "calciteInternalTimePickerBlur", 6);
- this.calciteInternalTimePickerChange = createEvent(this, "calciteInternalTimePickerChange", 6);
- this.calciteInternalTimePickerFocus = createEvent(this, "calciteInternalTimePickerFocus", 6);
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /**
- * Accessible name for the component's hour input.
- *
- * @default "Hour"
- */
- this.intlHour = TEXT.hour;
- /**
- * Accessible name for the component's hour down button.
- *
- * @default "Decrease hour"
- */
- this.intlHourDown = TEXT.hourDown;
- /**
- * Accessible name for the component's hour up button.
- *
- * @default "Increase hour"
- */
- this.intlHourUp = TEXT.hourUp;
- /**
- * Accessible name for the component's meridiem (AM/PM) input.
- *
- * @default "AM/PM"
- */
- this.intlMeridiem = TEXT.meridiem;
- /**
- * Accessible name for the component's meridiem (AM/PM) down button.
- *
- * @default "Decrease AM/PM"
- */
- this.intlMeridiemDown = TEXT.meridiemDown;
- /**
- * Accessible name for the component's meridiem (AM/PM) up button.
- *
- * @default "Increase AM/PM"
- */
- this.intlMeridiemUp = TEXT.meridiemUp;
- /**
- * Accessible name for the component's minute input.
- *
- * @default "Minute"
- */
- this.intlMinute = TEXT.minute;
- /**
- * Accessible name for the component's minute down button.
- *
- * @default "Decrease minute"
- */
- this.intlMinuteDown = TEXT.minuteDown;
- /**
- * Accessible name for the component's minute up button.
- *
- * @default "Increase minute"
- */
- this.intlMinuteUp = TEXT.minuteUp;
- /**
- * Accessible name for the component's second input.
- *
- * @default "Second"
- */
- this.intlSecond = TEXT.second;
- /**
- * Accessible name for the component's second down button.
- *
- * @default "Decrease second"
- */
- this.intlSecondDown = TEXT.secondDown;
- /**
- * Accessible name for the component's second up button.
- *
- * @default "Increase second"
- */
- this.intlSecondUp = TEXT.secondUp;
- /** Specifies the size of the component. */
- this.scale = "m";
- /** Specifies the granularity the `value` must adhere to (in seconds). */
- this.step = 60;
- /** The component's value in UTC (always 24-hour format). */
- this.value = null;
- // --------------------------------------------------------------------------
- //
- // State
- //
- // --------------------------------------------------------------------------
- this.effectiveLocale = "";
- this.showSecond = this.step < 60;
- this.decrementHour = () => {
- const newHour = !this.hour ? 0 : this.hour === "00" ? 23 : parseInt(this.hour) - 1;
- this.setValuePart("hour", newHour);
- };
- this.decrementMeridiem = () => {
- const newMeridiem = this.meridiem === "PM" ? "AM" : "PM";
- this.setValuePart("meridiem", newMeridiem);
- };
- this.decrementMinuteOrSecond = (key) => {
- let newValue;
- if (isValidNumber(this[key])) {
- const valueAsNumber = parseInt(this[key]);
- newValue = valueAsNumber === 0 ? 59 : valueAsNumber - 1;
- }
- else {
- newValue = 59;
- }
- this.setValuePart(key, newValue);
- };
- this.decrementMinute = () => {
- this.decrementMinuteOrSecond("minute");
- };
- this.decrementSecond = () => {
- this.decrementMinuteOrSecond("second");
- };
- this.focusHandler = (event) => {
- this.activeEl = event.currentTarget;
- };
- this.hourDownButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.decrementHour();
- }
- };
- this.hourKeyDownHandler = (event) => {
- const { key } = event;
- if (numberKeys.includes(key)) {
- const keyAsNumber = parseInt(key);
- let newHour;
- if (isValidNumber(this.hour)) {
- switch (this.hourCycle) {
- case "12":
- newHour =
- this.hour === "01" && keyAsNumber >= 0 && keyAsNumber <= 2
- ? `1${keyAsNumber}`
- : keyAsNumber;
- break;
- case "24":
- if (this.hour === "01") {
- newHour = `1${keyAsNumber}`;
- }
- else if (this.hour === "02" && keyAsNumber >= 0 && keyAsNumber <= 3) {
- newHour = `2${keyAsNumber}`;
- }
- else {
- newHour = keyAsNumber;
- }
- break;
- }
- }
- else {
- newHour = keyAsNumber;
- }
- this.setValuePart("hour", newHour);
- }
- else {
- switch (key) {
- case "Backspace":
- case "Delete":
- this.setValuePart("hour", null);
- break;
- case "ArrowDown":
- event.preventDefault();
- this.decrementHour();
- break;
- case "ArrowUp":
- event.preventDefault();
- this.incrementHour();
- break;
- case " ":
- event.preventDefault();
- break;
- }
- }
- };
- this.hourUpButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.incrementHour();
- }
- };
- this.incrementMeridiem = () => {
- const newMeridiem = this.meridiem === "AM" ? "PM" : "AM";
- this.setValuePart("meridiem", newMeridiem);
- };
- this.incrementHour = () => {
- const newHour = isValidNumber(this.hour)
- ? this.hour === "23"
- ? 0
- : parseInt(this.hour) + 1
- : 1;
- this.setValuePart("hour", newHour);
- };
- this.incrementMinuteOrSecond = (key) => {
- const newValue = isValidNumber(this[key])
- ? this[key] === "59"
- ? 0
- : parseInt(this[key]) + 1
- : 0;
- this.setValuePart(key, newValue);
- };
- this.incrementMinute = () => {
- this.incrementMinuteOrSecond("minute");
- };
- this.incrementSecond = () => {
- this.incrementMinuteOrSecond("second");
- };
- this.meridiemDownButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.decrementMeridiem();
- }
- };
- this.meridiemKeyDownHandler = (event) => {
- switch (event.key) {
- case "a":
- this.setValuePart("meridiem", "AM");
- break;
- case "p":
- this.setValuePart("meridiem", "PM");
- break;
- case "Backspace":
- case "Delete":
- this.setValuePart("meridiem", null);
- break;
- case "ArrowUp":
- event.preventDefault();
- this.incrementMeridiem();
- break;
- case "ArrowDown":
- event.preventDefault();
- this.decrementMeridiem();
- break;
- case " ":
- event.preventDefault();
- break;
- }
- };
- this.meridiemUpButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.incrementMeridiem();
- }
- };
- this.minuteDownButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.decrementMinute();
- }
- };
- this.minuteKeyDownHandler = (event) => {
- const { key } = event;
- if (numberKeys.includes(key)) {
- const keyAsNumber = parseInt(key);
- let newMinute;
- if (isValidNumber(this.minute) && this.minute.startsWith("0")) {
- const minuteAsNumber = parseInt(this.minute);
- newMinute =
- minuteAsNumber > maxTenthForMinuteAndSecond
- ? keyAsNumber
- : `${minuteAsNumber}${keyAsNumber}`;
- }
- else {
- newMinute = keyAsNumber;
- }
- this.setValuePart("minute", newMinute);
- }
- else {
- switch (key) {
- case "Backspace":
- case "Delete":
- this.setValuePart("minute", null);
- break;
- case "ArrowDown":
- event.preventDefault();
- this.decrementMinute();
- break;
- case "ArrowUp":
- event.preventDefault();
- this.incrementMinute();
- break;
- case " ":
- event.preventDefault();
- break;
- }
- }
- };
- this.minuteUpButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.incrementMinute();
- }
- };
- this.secondDownButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.decrementSecond();
- }
- };
- this.secondKeyDownHandler = (event) => {
- const { key } = event;
- if (numberKeys.includes(key)) {
- const keyAsNumber = parseInt(key);
- let newSecond;
- if (isValidNumber(this.second) && this.second.startsWith("0")) {
- const secondAsNumber = parseInt(this.second);
- newSecond =
- secondAsNumber > maxTenthForMinuteAndSecond
- ? keyAsNumber
- : `${secondAsNumber}${keyAsNumber}`;
- }
- else {
- newSecond = keyAsNumber;
- }
- this.setValuePart("second", newSecond);
- }
- else {
- switch (key) {
- case "Backspace":
- case "Delete":
- this.setValuePart("second", null);
- break;
- case "ArrowDown":
- event.preventDefault();
- this.decrementSecond();
- break;
- case "ArrowUp":
- event.preventDefault();
- this.incrementSecond();
- break;
- case " ":
- event.preventDefault();
- break;
- }
- }
- };
- this.secondUpButtonKeyDownHandler = (event) => {
- if (this.buttonActivated(event)) {
- this.incrementSecond();
- }
- };
- this.setHourEl = (el) => (this.hourEl = el);
- this.setMeridiemEl = (el) => (this.meridiemEl = el);
- this.setMinuteEl = (el) => (this.minuteEl = el);
- this.setSecondEl = (el) => (this.secondEl = el);
- this.setValue = (value, emit = true) => {
- if (isValidTime(value)) {
- const { hour, minute, second } = parseTimeString(value);
- const { effectiveLocale: locale, numberingSystem } = this;
- const { localizedHour, localizedHourSuffix, localizedMinute, localizedMinuteSuffix, localizedSecond, localizedSecondSuffix, localizedMeridiem } = localizeTimeStringToParts({ value, locale, numberingSystem });
- this.localizedHour = localizedHour;
- this.localizedHourSuffix = localizedHourSuffix;
- this.localizedMinute = localizedMinute;
- this.localizedMinuteSuffix = localizedMinuteSuffix;
- this.localizedSecond = localizedSecond;
- this.localizedSecondSuffix = localizedSecondSuffix;
- this.hour = hour;
- this.minute = minute;
- this.second = second;
- if (localizedMeridiem) {
- this.localizedMeridiem = localizedMeridiem;
- this.meridiem = getMeridiem(this.hour);
- const formatParts = getTimeParts({ value, locale, numberingSystem });
- this.meridiemOrder = this.getMeridiemOrder(formatParts);
- }
- }
- else {
- this.hour = null;
- this.localizedHour = null;
- this.localizedHourSuffix = null;
- this.localizedMeridiem = null;
- this.localizedMinute = null;
- this.localizedMinuteSuffix = null;
- this.localizedSecond = null;
- this.localizedSecondSuffix = null;
- this.meridiem = null;
- this.minute = null;
- this.second = null;
- this.value = null;
- }
- if (emit) {
- this.calciteInternalTimePickerChange.emit();
- }
- };
- this.setValuePart = (key, value, emit = true) => {
- var _a;
- const { effectiveLocale: locale, numberingSystem } = this;
- if (key === "meridiem") {
- this.meridiem = value;
- if (isValidNumber(this.hour)) {
- const hourAsNumber = parseInt(this.hour);
- switch (value) {
- case "AM":
- if (hourAsNumber >= 12) {
- this.hour = formatTimePart(hourAsNumber - 12);
- }
- break;
- case "PM":
- if (hourAsNumber < 12) {
- this.hour = formatTimePart(hourAsNumber + 12);
- }
- break;
- }
- this.localizedHour = localizeTimePart({
- value: this.hour,
- part: "hour",
- locale,
- numberingSystem
- });
- }
- }
- else {
- this[key] = typeof value === "number" ? formatTimePart(value) : value;
- this[`localized${capitalize(key)}`] = localizeTimePart({
- value: this[key],
- part: key,
- locale,
- numberingSystem
- });
- }
- if (this.hour && this.minute) {
- const showSeconds = this.second && this.showSecond;
- this.value = `${this.hour}:${this.minute}:${showSeconds ? this.second : "00"}`;
- }
- else {
- this.value = null;
- }
- this.localizedMeridiem = this.value
- ? ((_a = localizeTimeStringToParts({ value: this.value, locale, numberingSystem })) === null || _a === void 0 ? void 0 : _a.localizedMeridiem) || null
- : localizeTimePart({ value: this.meridiem, part: "meridiem", locale, numberingSystem });
- if (emit) {
- this.calciteInternalTimePickerChange.emit();
- }
- };
- }
- localeChanged() {
- updateEffectiveLocale(this);
- }
- valueWatcher(newValue) {
- this.setValue(newValue, false);
- }
- effectiveLocaleWatcher() {
- this.updateLocale();
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- hostBlurHandler() {
- this.calciteInternalTimePickerBlur.emit();
- }
- hostFocusHandler() {
- this.calciteInternalTimePickerFocus.emit();
- }
- keyDownHandler(event) {
- const { defaultPrevented, key } = event;
- if (defaultPrevented) {
- return;
- }
- switch (this.activeEl) {
- case this.hourEl:
- if (key === "ArrowRight") {
- this.setFocus("minute");
- event.preventDefault();
- }
- break;
- case this.minuteEl:
- switch (key) {
- case "ArrowLeft":
- this.setFocus("hour");
- event.preventDefault();
- break;
- case "ArrowRight":
- if (this.step !== 60) {
- this.setFocus("second");
- event.preventDefault();
- }
- else if (this.hourCycle === "12") {
- this.setFocus("meridiem");
- event.preventDefault();
- }
- break;
- }
- break;
- case this.secondEl:
- switch (key) {
- case "ArrowLeft":
- this.setFocus("minute");
- event.preventDefault();
- break;
- case "ArrowRight":
- if (this.hourCycle === "12") {
- this.setFocus("meridiem");
- event.preventDefault();
- }
- break;
- }
- break;
- case this.meridiemEl:
- switch (key) {
- case "ArrowLeft":
- if (this.step !== 60) {
- this.setFocus("second");
- event.preventDefault();
- }
- else {
- this.setFocus("minute");
- event.preventDefault();
- }
- break;
- }
- break;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /**
- * Sets focus on the component.
- *
- * @param target
- */
- async setFocus(target) {
- var _a;
- (_a = this[`${target || "hour"}El`]) === null || _a === void 0 ? void 0 : _a.focus();
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- buttonActivated(event) {
- const { key } = event;
- if (key === " ") {
- event.preventDefault();
- }
- return isActivationKey(key);
- }
- getMeridiemOrder(formatParts) {
- const locale = this.effectiveLocale;
- const isRTLKind = locale === "ar" || locale === "he";
- if (formatParts && !isRTLKind) {
- const index = formatParts.findIndex((parts) => {
- return parts.value === this.localizedMeridiem;
- });
- return index;
- }
- return 0;
- }
- updateLocale() {
- this.hourCycle = getLocaleHourCycle(this.effectiveLocale, this.numberingSystem);
- this.setValue(this.value, false);
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectLocalized(this);
- this.updateLocale();
- this.meridiemOrder = this.getMeridiemOrder(getTimeParts({
- value: "0:00:00",
- locale: this.effectiveLocale,
- numberingSystem: this.numberingSystem
- }));
- }
- disconnectedCallback() {
- disconnectLocalized(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- render() {
- const hourIsNumber = isValidNumber(this.hour);
- const iconScale = this.scale === "s" || this.scale === "m" ? "s" : "m";
- const minuteIsNumber = isValidNumber(this.minute);
- const secondIsNumber = isValidNumber(this.second);
- const showMeridiem = this.hourCycle === "12";
- return (h("div", { class: {
- [CSS.timePicker]: true,
- [CSS.showMeridiem]: showMeridiem,
- [CSS.showSecond]: this.showSecond,
- [CSS[`scale-${this.scale}`]]: true
- }, dir: "ltr" }, h("div", { class: CSS.column, role: "group" }, h("span", { "aria-label": this.intlHourUp, class: {
- [CSS.button]: true,
- [CSS.buttonHourUp]: true,
- [CSS.buttonTopLeft]: true
- }, 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: {
- [CSS.input]: true,
- [CSS.hour]: true
- }, onFocus: this.focusHandler, onKeyDown: this.hourKeyDownHandler, ref: this.setHourEl, role: "spinbutton", tabIndex: 0 }, this.localizedHour || "--"), h("span", { "aria-label": this.intlHourDown, class: {
- [CSS.button]: true,
- [CSS.buttonHourDown]: true,
- [CSS.buttonBottomLeft]: true
- }, 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: {
- [CSS.button]: true,
- [CSS.buttonMinuteUp]: true
- }, 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: {
- [CSS.input]: true,
- [CSS.minute]: true
- }, onFocus: this.focusHandler, onKeyDown: this.minuteKeyDownHandler, ref: this.setMinuteEl, role: "spinbutton", tabIndex: 0 }, this.localizedMinute || "--"), h("span", { "aria-label": this.intlMinuteDown, class: {
- [CSS.button]: true,
- [CSS.buttonMinuteDown]: true
- }, 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: {
- [CSS.button]: true,
- [CSS.buttonSecondUp]: true
- }, 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: {
- [CSS.input]: true,
- [CSS.second]: true
- }, onFocus: this.focusHandler, onKeyDown: this.secondKeyDownHandler, ref: this.setSecondEl, role: "spinbutton", tabIndex: 0 }, this.localizedSecond || "--"), h("span", { "aria-label": this.intlSecondDown, class: {
- [CSS.button]: true,
- [CSS.buttonSecondDown]: true
- }, 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: {
- [CSS.column]: true,
- [CSS.meridiemStart]: this.meridiemOrder === 0
- }, role: "group" }, h("span", { "aria-label": this.intlMeridiemUp, class: {
- [CSS.button]: true,
- [CSS.buttonMeridiemUp]: true,
- [CSS.buttonTopRight]: true
- }, 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: {
- [CSS.input]: true,
- [CSS.meridiem]: true
- }, onFocus: this.focusHandler, onKeyDown: this.meridiemKeyDownHandler, ref: this.setMeridiemEl, role: "spinbutton", tabIndex: 0 }, this.localizedMeridiem || "--"), h("span", { "aria-label": this.intlMeridiemDown, class: {
- [CSS.button]: true,
- [CSS.buttonMeridiemDown]: true,
- [CSS.buttonBottomRight]: true
- }, onClick: this.decrementMeridiem, onKeyDown: this.meridiemDownButtonKeyDownHandler, role: "button", tabIndex: -1 }, h("calcite-icon", { icon: "chevron-down", scale: iconScale }))))));
- }
- get el() { return getElement(this); }
- static get watchers() { return {
- "locale": ["localeChanged"],
- "value": ["valueWatcher"],
- "effectiveLocale": ["effectiveLocaleWatcher"]
- }; }
- };
- TimePicker.style = timePickerCss;
- export { InputTimePicker as calcite_input_time_picker, TimePicker as calcite_time_picker };
|