UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

1 lines • 30.5 kB
var __awaiter=this&&this.__awaiter||function(t,e,i,c){function a(t){return t instanceof i?t:new i((function(e){e(t)}))}return new(i||(i=Promise))((function(i,n){function l(t){try{s(c.next(t))}catch(e){n(e)}}function r(t){try{s(c["throw"](t))}catch(e){n(e)}}function s(t){t.done?i(t.value):a(t.value).then(l,r)}s((c=c.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var i={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},c,a,n,l;return l={next:r(0),throw:r(1),return:r(2)},typeof Symbol==="function"&&(l[Symbol.iterator]=function(){return this}),l;function r(t){return function(e){return s([t,e])}}function s(l){if(c)throw new TypeError("Generator is already executing.");while(i)try{if(c=1,a&&(n=l[0]&2?a["return"]:l[0]?a["throw"]||((n=a["return"])&&n.call(a),0):a.next)&&!(n=n.call(a,l[1])).done)return n;if(a=0,n)l=[l[0]&2,n.value];switch(l[0]){case 0:case 1:n=l;break;case 4:i.label++;return{value:l[1],done:false};case 5:i.label++;a=l[1];l=[0];continue;case 7:l=i.ops.pop();i.trys.pop();continue;default:if(!(n=i.trys,n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){i=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){i.label=l[1];break}if(l[0]===6&&i.label<n[1]){i.label=n[1];n=l;break}if(n&&i.label<n[2]){i.label=n[2];i.ops.push(l);break}if(n[2])i.ops.pop();i.trys.pop();continue}l=e.call(t,i)}catch(r){l=[6,r];a=0}finally{c=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(t,e){for(var i=0,c=e.length,a=t.length;i<c;i++,a++)t[a]=e[i];return t};import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-aa8afca4.js";import{s as setRequestedIcon,c as getElementProp,g as getElementDir,d as getAttributes,C as CSS_UTILITY}from"./dom-466af3c7.js";import{g as getKey,n as numberKeys}from"./key-ec82f942.js";import{d as delocalizeNumberString,g as getDecimalSeparator,l as localizeNumberString}from"./locale-8f48fd10.js";import{h as hiddenInputStyle}from"./form-8aa0d95b.js";import{i as isValidNumber,p as parseNumberString,s as sanitizeNumberString}from"./number-ca3ae047.js";import"./guid-09142681.js";var INPUT_TYPE_ICONS={tel:"phone",password:"lock",email:"email-address",date:"calendar",time:"clock",search:"search"};var SLOTS={action:"action"};var calciteInputCss="@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}.sc-calcite-input:root{--calcite-popper-transition:150ms ease-in-out}[hidden].sc-calcite-input-h{display:none}[scale=s].sc-calcite-input-h textarea.sc-calcite-input,[scale=s].sc-calcite-input-h input.sc-calcite-input,[scale=s].sc-calcite-input-h .calcite-input-prefix.sc-calcite-input,[scale=s].sc-calcite-input-h .calcite-input-suffix.sc-calcite-input{font-size:var(--calcite-font-size--2);padding:0.5rem;height:2rem}[scale=s].sc-calcite-input-h textarea.sc-calcite-input{min-height:32px}[scale=s].sc-calcite-input-h .calcite-input-number-button-wrapper.sc-calcite-input,[scale=s].sc-calcite-input-h .calcite-action-wrapper.sc-calcite-input calcite-button.sc-calcite-input,[scale=s].sc-calcite-input-h .calcite-action-wrapper.sc-calcite-input calcite-button.sc-calcite-input button.sc-calcite-input{height:2rem}[scale=s].sc-calcite-input-h textarea.sc-calcite-input,[scale=s].sc-calcite-input-h input[type=file].sc-calcite-input{height:auto}[scale=s].sc-calcite-input-h .calcite-input-clear-button.sc-calcite-input{min-height:32px;min-width:32px}[scale=m].sc-calcite-input-h textarea.sc-calcite-input,[scale=m].sc-calcite-input-h input.sc-calcite-input,[scale=m].sc-calcite-input-h .calcite-input-prefix.sc-calcite-input,[scale=m].sc-calcite-input-h .calcite-input-suffix.sc-calcite-input{font-size:var(--calcite-font-size--1);padding:0.75rem;height:44px}[scale=m].sc-calcite-input-h textarea.sc-calcite-input{min-height:44px}[scale=m].sc-calcite-input-h .calcite-input-number-button-wrapper.sc-calcite-input,[scale=m].sc-calcite-input-h .calcite-action-wrapper.sc-calcite-input calcite-button.sc-calcite-input,[scale=m].sc-calcite-input-h .calcite-action-wrapper.sc-calcite-input calcite-button.sc-calcite-input button.sc-calcite-input{height:44px}[scale=m].sc-calcite-input-h textarea.sc-calcite-input,[scale=m].sc-calcite-input-h input[type=file].sc-calcite-input{height:auto}[scale=m].sc-calcite-input-h .calcite-input-clear-button.sc-calcite-input{min-height:44px;min-width:44px}[scale=l].sc-calcite-input-h textarea.sc-calcite-input,[scale=l].sc-calcite-input-h input.sc-calcite-input,[scale=l].sc-calcite-input-h .calcite-input-prefix.sc-calcite-input,[scale=l].sc-calcite-input-h .calcite-input-suffix.sc-calcite-input{font-size:var(--calcite-font-size-1);padding:1rem;height:56px}[scale=l].sc-calcite-input-h textarea.sc-calcite-input{min-height:56px}[scale=l].sc-calcite-input-h .calcite-input-number-button-wrapper.sc-calcite-input,[scale=l].sc-calcite-input-h .calcite-action-wrapper.sc-calcite-input calcite-button.sc-calcite-input,[scale=l].sc-calcite-input-h .calcite-action-wrapper.sc-calcite-input calcite-button.sc-calcite-input button.sc-calcite-input{height:56px}[scale=l].sc-calcite-input-h textarea.sc-calcite-input,[scale=l].sc-calcite-input-h input[type=file].sc-calcite-input{height:auto}[scale=l].sc-calcite-input-h .calcite-input-clear-button.sc-calcite-input{min-height:56px;min-width:56px}[disabled].sc-calcite-input-h{pointer-events:none}[disabled].sc-calcite-input-h .calcite-input-wrapper.sc-calcite-input{opacity:var(--calcite-ui-opacity-disabled);pointer-events:none}[disabled].sc-calcite-input-h textarea.sc-calcite-input,[disabled].sc-calcite-input-h input.sc-calcite-input{pointer-events:none}.sc-calcite-input-h textarea.sc-calcite-input,.sc-calcite-input-h input.sc-calcite-input{display:-ms-flexbox;display:flex;position:relative;min-width:20%;max-width:100%;max-height:100%;-ms-flex:1;flex:1;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:none;font-family:inherit;-webkit-transition:150ms ease-in-out, height 0s;transition:150ms ease-in-out, height 0s;-webkit-box-shadow:0 0 0 0 transparent;box-shadow:0 0 0 0 transparent;outline:0;margin:0;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-1);font-weight:400;border-radius:0;-webkit-border-radius:0}.sc-calcite-input-h input[type=search].sc-calcite-input::-webkit-search-decoration{-webkit-appearance:none}.sc-calcite-input-h textarea.sc-calcite-input,.sc-calcite-input-h input.sc-calcite-input{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}.sc-calcite-input-h textarea.sc-calcite-input:focus,.sc-calcite-input-h input.sc-calcite-input:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.sc-calcite-input-h input.sc-calcite-input,.sc-calcite-input-h textarea.sc-calcite-input{color:var(--calcite-ui-text-1);border:1px solid var(--calcite-ui-border-1)}.sc-calcite-input-h input.sc-calcite-input:-ms-input-placeholder,.sc-calcite-input-h textarea.sc-calcite-input:-ms-input-placeholder{color:var(--calcite-ui-text-3);font-weight:400}.sc-calcite-input-h input.sc-calcite-input::-ms-input-placeholder,.sc-calcite-input-h textarea.sc-calcite-input::-ms-input-placeholder{color:var(--calcite-ui-text-3);font-weight:400}.sc-calcite-input-h input.sc-calcite-input::placeholder,.sc-calcite-input-h input.sc-calcite-input:-ms-input-placeholder,.sc-calcite-input-h input.sc-calcite-input::-ms-input-placeholder,.sc-calcite-input-h textarea.sc-calcite-input::placeholder,.sc-calcite-input-h textarea.sc-calcite-input:-ms-input-placeholder,.sc-calcite-input-h textarea.sc-calcite-input::-ms-input-placeholder{color:var(--calcite-ui-text-3);font-weight:400}.sc-calcite-input-h input.sc-calcite-input:focus,.sc-calcite-input-h textarea.sc-calcite-input:focus{border-color:var(--calcite-ui-brand);color:var(--calcite-ui-text-1)}.sc-calcite-input-h input[readonly].sc-calcite-input,.sc-calcite-input-h textarea[readonly].sc-calcite-input{background-color:var(--calcite-ui-background)}.sc-calcite-input-h input[readonly].sc-calcite-input:focus,.sc-calcite-input-h textarea[readonly].sc-calcite-input:focus{color:var(--calcite-ui-text-1)}.sc-calcite-input-h calcite-icon.sc-calcite-input{color:var(--calcite-ui-text-1)}.sc-calcite-input-h slot.sc-calcite-input:not[name=input-message]{display:block;margin-bottom:0.375rem;color:var(--calcite-ui-text-2);font-weight:500}[icon].sc-calcite-input-h input.sc-calcite-input{padding-left:2.25rem}[icon].sc-calcite-input-h .calcite--rtl.sc-calcite-input input.sc-calcite-input{padding-right:2.25rem;padding-left:0.75rem}[icon][scale=l].sc-calcite-input-h .calcite--rtl.sc-calcite-input input.sc-calcite-input{padding-right:3rem;padding-left:0.75rem}[icon][scale=l].sc-calcite-input-h input.sc-calcite-input{padding-left:3rem}.calcite-input-element-wrapper.sc-calcite-input{display:-ms-inline-flexbox;display:inline-flex;-ms-flex:1;flex:1;min-width:20%;position:relative;-ms-flex-order:3;order:3}.calcite-input-icon.sc-calcite-input{display:block;position:absolute;pointer-events:none;-webkit-transition:150ms ease-in-out;transition:150ms ease-in-out;top:calc(50% - 9px);left:0.75rem;margin:1px auto 0;z-index:1}[scale=l].sc-calcite-input-h .calcite-input-icon.sc-calcite-input{top:calc(50% - 12px)}.calcite--rtl.sc-calcite-input .calcite-input-icon.sc-calcite-input{left:unset;right:0.75rem}input[type=text].sc-calcite-input::-ms-clear{display:none;width:0;height:0}input[type=text].sc-calcite-input::-ms-reveal{display:none;width:0;height:0}input[type=search].sc-calcite-input::-webkit-search-decoration,input[type=search].sc-calcite-input::-webkit-search-cancel-button,input[type=search].sc-calcite-input::-webkit-search-results-button,input[type=search].sc-calcite-input::-webkit-search-results-decoration,input[type=date].sc-calcite-input::-webkit-clear-button,input[type=time].sc-calcite-input::-webkit-clear-button{display:none}.calcite-input-clear-button.sc-calcite-input{display:-ms-flexbox;display:flex;-ms-flex-item-align:stretch;align-self:stretch;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-webkit-box-sizing:border-box;box-sizing:border-box;cursor:pointer;min-height:100%;border:1px solid var(--calcite-ui-border-1);-webkit-transition:150ms ease-in-out;transition:150ms ease-in-out;pointer-events:initial;background-color:var(--calcite-ui-foreground-1);border-left:none;-ms-flex-order:4;order:4}.calcite-input-clear-button.sc-calcite-input:hover,.calcite-input-clear-button.sc-calcite-input:focus{background-color:var(--calcite-ui-foreground-2)}.calcite-input-clear-button.sc-calcite-input:active{background-color:var(--calcite-ui-foreground-3)}.calcite-input-clear-button.sc-calcite-input:disabled{opacity:var(--calcite-ui-opacity-disabled)}.calcite--rtl.sc-calcite-input .calcite-input-clear-button.sc-calcite-input{border-left:1px solid var(--calcite-ui-border-1);border-right:none}.calcite-input-clear-button.sc-calcite-input{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}.calcite-input-clear-button.sc-calcite-input:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.calcite-input-loading.sc-calcite-input{display:block;pointer-events:none;position:absolute;top:1px;left:1px;right:1px}.calcite-action-wrapper.sc-calcite-input{display:-ms-flexbox;display:flex;-ms-flex-order:7;order:7}.calcite-input-prefix.sc-calcite-input,.calcite-input-suffix.sc-calcite-input{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;height:auto;min-height:100%;word-break:break-word;-webkit-user-select:none;-ms-user-select:none;-moz-user-select:none;user-select:none;-webkit-box-sizing:border-box;box-sizing:border-box;font-weight:500;border:1px solid var(--calcite-ui-border-1);background-color:var(--calcite-ui-background);color:var(--calcite-ui-text-2);line-height:1}.calcite-input-prefix.sc-calcite-input{-ms-flex-order:2;order:2;border-right-width:0px}.calcite-input-suffix.sc-calcite-input{-ms-flex-order:5;order:5;border-left-width:0px}.calcite--rtl.sc-calcite-input .calcite-input-prefix.sc-calcite-input{border-right-width:1px;border-left-width:0px}.calcite--rtl.sc-calcite-input .calcite-input-suffix.sc-calcite-input{border-left-width:1px;border-right-width:0px}[readonly].sc-calcite-input-h .calcite-input-number-button-item.sc-calcite-input{pointer-events:none}[alignment=start].sc-calcite-input-h textarea.sc-calcite-input,[alignment=start].sc-calcite-input-h input.sc-calcite-input{text-align:left}[alignment=end].sc-calcite-input-h textarea.sc-calcite-input,[alignment=end].sc-calcite-input-h input.sc-calcite-input{text-align:right}[alignment=start].sc-calcite-input-h .calcite--rtl.sc-calcite-input textarea.sc-calcite-input,[alignment=start].sc-calcite-input-h .calcite--rtl.sc-calcite-input input.sc-calcite-input{text-align:right}[alignment=end].sc-calcite-input-h .calcite--rtl.sc-calcite-input textarea.sc-calcite-input,[alignment=end].sc-calcite-input-h .calcite--rtl.sc-calcite-input input.sc-calcite-input{text-align:left}.sc-calcite-input-h input[type=number].sc-calcite-input{-moz-appearance:textfield}.sc-calcite-input-h input[type=number].sc-calcite-input::-webkit-inner-spin-button,.sc-calcite-input-h input[type=number].sc-calcite-input::-webkit-outer-spin-button{-webkit-appearance:none;-moz-appearance:textfield;margin:0}.calcite-input-number-button-wrapper.sc-calcite-input{-webkit-box-sizing:border-box;box-sizing:border-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;box-sizing:border-box;-webkit-transition:150ms ease-in-out;transition:150ms ease-in-out;pointer-events:none;-ms-flex-order:6;order:6}[number-button-type=vertical].sc-calcite-input-h .calcite-input-wrapper.sc-calcite-input{-ms-flex-direction:row;flex-direction:row;display:-ms-flexbox;display:flex}[number-button-type=vertical].sc-calcite-input-h input.sc-calcite-input,[number-button-type=vertical].sc-calcite-input-h textarea.sc-calcite-input{-ms-flex-order:2;order:2}[number-button-type=horizontal].sc-calcite-input-h .calcite--rtl.sc-calcite-input .calcite-input-number-button-item[data-adjustment=down].sc-calcite-input calcite-icon.sc-calcite-input{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}[number-button-type=horizontal].sc-calcite-input-h .calcite--rtl.sc-calcite-input .calcite-input-number-button-item[data-adjustment=up].sc-calcite-input calcite-icon.sc-calcite-input{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.calcite-input-number-button-item.number-button-item-horizontal[data-adjustment=down].sc-calcite-input,.calcite-input-number-button-item.number-button-item-horizontal[data-adjustment=up].sc-calcite-input{min-height:100%;max-height:100%;-ms-flex-order:1;order:1;-ms-flex-item-align:auto;align-self:auto}.calcite-input-number-button-item.number-button-item-horizontal[data-adjustment=down].sc-calcite-input calcite-icon.sc-calcite-input,.calcite-input-number-button-item.number-button-item-horizontal[data-adjustment=up].sc-calcite-input calcite-icon.sc-calcite-input{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.calcite-input-number-button-item.number-button-item-horizontal[data-adjustment=down].sc-calcite-input{border-left:1px solid var(--calcite-ui-border-1);border-right:0px}.calcite-input-number-button-item.number-button-item-horizontal[data-adjustment=up].sc-calcite-input{-ms-flex-order:5;order:5}.calcite--rtl.sc-calcite-input .calcite-input-number-button-item.number-button-item-horizontal[data-adjustment=down].sc-calcite-input{border-right:1px solid var(--calcite-ui-border-1);border-left:0px}.calcite--rtl.sc-calcite-input .calcite-input-number-button-item.number-button-item-horizontal[data-adjustment=up].sc-calcite-input{border-left:1px solid var(--calcite-ui-border-1);border-right:0px}[number-button-type=vertical].sc-calcite-input-h .calcite-input-number-button-item[data-adjustment=down].sc-calcite-input{border-top:0}.calcite-input-number-button-item.sc-calcite-input{display:-ms-flexbox;display:flex;-ms-flex-item-align:center;align-self:center;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;cursor:pointer;max-height:50%;min-height:50%;padding:0 0.75rem;border:1px solid var(--calcite-ui-border-1);-webkit-transition:background-color 0.15s ease-in-out;transition:background-color 0.15s ease-in-out;pointer-events:initial;background-color:var(--calcite-ui-foreground-1);border-left:none}.calcite-input-number-button-item.sc-calcite-input calcite-icon.sc-calcite-input{pointer-events:none}.calcite-input-number-button-item.sc-calcite-input:hover,.calcite-input-number-button-item.sc-calcite-input:focus{background-color:var(--calcite-ui-foreground-2)}.calcite-input-number-button-item.sc-calcite-input:active{background-color:var(--calcite-ui-foreground-3)}[number-button-type=vertical].sc-calcite-input-h .calcite--rtl.sc-calcite-input .calcite-input-number-button-item.sc-calcite-input{border-right:none;border-left:1px solid var(--calcite-ui-border-1)}.calcite-input-wrapper.sc-calcite-input{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;position:relative}.sc-calcite-input-h input.sc-calcite-input::-webkit-calendar-picker-indicator{display:none}.sc-calcite-input-h input[type=date].sc-calcite-input::-webkit-input-placeholder{visibility:hidden !important}.sc-calcite-input-h textarea.sc-calcite-input::-webkit-resizer{-webkit-box-sizing:border-box;box-sizing:border-box;position:absolute;bottom:0;right:0;padding:0 0.375rem}@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none){.calcite-input-resize-icon-wrapper.sc-calcite-input{display:none}}.calcite-input-resize-icon-wrapper.sc-calcite-input{background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-3);position:absolute;z-index:1;bottom:2px;right:2px;pointer-events:none;width:16px;height:16px}.calcite-input-resize-icon-wrapper.sc-calcite-input calcite-icon.sc-calcite-input{bottom:4px;right:4px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.calcite--rtl.sc-calcite-input textarea.sc-calcite-input::-webkit-resizer{left:0;right:unset}.calcite--rtl.sc-calcite-input .calcite-input-resize-icon-wrapper.sc-calcite-input{left:2px;right:unset}.calcite--rtl.sc-calcite-input .calcite-input-resize-icon-wrapper.sc-calcite-input calcite-icon.sc-calcite-input{bottom:4px;right:4px;-webkit-transform:rotate(45deg);transform:rotate(45deg)}[type=file].sc-calcite-input-h input.sc-calcite-input,[type=file].sc-calcite-input-h textarea.sc-calcite-input{cursor:pointer;padding:1.5rem;border:1px dashed #d4d4d4;background-color:#f8f8f8;text-align:center}.no-bottom-border.sc-calcite-input-h input.sc-calcite-input.sc-calcite-input{border-bottom:none}[status=invalid].sc-calcite-input-h .calcite-input-icon.sc-calcite-input{color:var(--calcite-ui-danger)}[status=valid].sc-calcite-input-h .calcite-input-icon.sc-calcite-input{color:var(--calcite-ui-success)}[status=idle].sc-calcite-input-h .calcite-input-icon.sc-calcite-input{color:var(--calcite-ui-text-2)}";var CalciteInput=function(){function t(t){var e=this;registerInstance(this,t);this.calciteInputFocus=createEvent(this,"calciteInputFocus",7);this.calciteInputBlur=createEvent(this,"calciteInputBlur",7);this.calciteInputInput=createEvent(this,"calciteInputInput",7);this.calciteInputChange=createEvent(this,"calciteInputChange",7);this.alignment="start";this.autofocus=false;this.groupSeparator=false;this.loading=false;this.locale=document.documentElement.lang||"en";this.localeFormat=false;this.numberButtonType="vertical";this.required=false;this.scale="m";this.status="idle";this.type="text";this.childElType="input";this.clearInputValue=function(t){e.setValue(null,t,true)};this.inputBlurHandler=function(){if(e.type==="number"){e.setLocalizedValue(e.value)}e.calciteInputBlur.emit({element:e.childEl,value:e.value});if(e.preFocusValue!==e.value){e.calciteInputChange.emit()}};this.inputFocusHandler=function(t){if(t.target!==e.slottedActionEl){e.setFocus()}e.calciteInputFocus.emit({element:e.childEl,value:e.value});e.preFocusValue=e.value};this.inputInputHandler=function(t){e.setValue(t.target.value,t)};this.inputKeyDownHandler=function(t){if(t.key==="Enter"){e.calciteInputChange.emit()}};this.inputNumberInputHandler=function(t){var i=t.target.value;var c=delocalizeNumberString(i,e.locale);if(t.inputType==="insertFromPaste"){if(!isValidNumber(c)){t.preventDefault()}e.setValue(parseNumberString(c),t);e.childNumberEl.value=e.localizedValue}else{e.setValue(delocalizeNumberString(i,e.locale),t)}};this.inputNumberKeyDownHandler=function(t){if(e.type!=="number"){return}if(t.key==="ArrowUp"){e.nudgeNumberValue("up",t);return}if(t.key==="ArrowDown"){e.nudgeNumberValue("down",t);return}var i=__spreadArray(__spreadArray([],numberKeys),["ArrowLeft","ArrowRight","Backspace","Delete","Enter","Escape","Tab","-"]);if(t.altKey||t.ctrlKey||t.metaKey){return}var c=t.shiftKey&&t.key==="Tab";if(i.includes(t.key)&&(!t.shiftKey||c)&&!(parseInt(e.value)===0&&getKey(t.key)==="0")){if(t.key==="Enter"){e.calciteInputChange.emit()}return}var a=getDecimalSeparator(e.locale);if(t.key===a){if(!e.value&&!e.childNumberEl.value){return}if(e.value&&e.childNumberEl.value.indexOf(a)===-1){return}}t.preventDefault()};this.nudgeNumberValue=function(t,i){var c,a;if(e.type!=="number"){return}var n=((a=(c=e.value)===null||c===void 0?void 0:c.split(".")[1])===null||a===void 0?void 0:a.length)||0;var l=e.maxString?parseFloat(e.maxString):null;var r=e.minString?parseFloat(e.minString):null;var s=e.step==="any"?1:Math.abs(e.step||1);var u=e.value&&e.value!==""?parseFloat(e.value):0;var o=e.value;if(t==="up"&&(!l&&l!==0||u<l)){o=(u+=s).toFixed(n).toString()}if(t==="down"&&(!r&&r!==0||u>r)){o=(u-=s).toFixed(n).toString()}e.setValue(o,i,true)};this.numberButtonMouseDownHandler=function(t){t.preventDefault();var i=t.target.dataset.adjustment;e.nudgeNumberValue(i,t)};this.reset=function(t){if(e.type==="number"){t.preventDefault()}e.setValue(e.defaultValue,t)};this.setChildElRef=function(t){e.childEl=t};this.setChildNumberElRef=function(t){e.childNumberEl=t};this.setLocalizedValue=function(t){e.localizedValue=localizeNumberString(t,e.locale,e.groupSeparator)};this.setValue=function(t,i,c){if(c===void 0){c=false}var a=e.value;e.value=e.type==="number"?sanitizeNumberString(t):t;if(e.type==="number"){e.setLocalizedValue(e.value)}if(i){if(e.type==="number"&&(t===null||t===void 0?void 0:t.endsWith("."))){return}var n=e.calciteInputInput.emit({element:e.childEl,nativeEvent:i,value:t});if(n.defaultPrevented){e.value=a;e.setLocalizedValue(a)}else if(c){e.calciteInputChange.emit()}}}}t.prototype.disabledWatcher=function(){this.setDisabledAction()};t.prototype.maxWatcher=function(){var t;this.maxString=((t=this.max)===null||t===void 0?void 0:t.toString())||null};t.prototype.minWatcher=function(){var t;this.minString=((t=this.min)===null||t===void 0?void 0:t.toString())||null};t.prototype.valueWatcher=function(t){if(this.type==="number"&&this.localizedValue!==localizeNumberString(t,this.locale)){this.setLocalizedValue(t)}else if(this.childEl&&this.childEl.value!==t){this.childEl.value=t}};t.prototype.updateRequestedIcon=function(){this.requestedIcon=setRequestedIcon(INPUT_TYPE_ICONS,this.icon,this.type)};Object.defineProperty(t.prototype,"isClearable",{get:function(){var t;return!this.isTextarea&&(this.clearable||this.type==="search")&&((t=this.value)===null||t===void 0?void 0:t.length)>0},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"isTextarea",{get:function(){return this.childElType==="textarea"},enumerable:false,configurable:true});t.prototype.connectedCallback=function(){var t;this.form=this.el.closest("form");(t=this.form)===null||t===void 0?void 0:t.addEventListener("reset",this.reset);this.scale=getElementProp(this.el,"scale",this.scale);this.status=getElementProp(this.el,"status",this.status);this.step=!this.step&&this.type==="number"?"any":this.step;if(this.type==="number"&&this.value){if(isValidNumber(this.value)){this.localizedValue=localizeNumberString(this.value,this.locale,this.groupSeparator)}else{this.value=undefined}}};t.prototype.disconnectedCallback=function(){var t;(t=this.form)===null||t===void 0?void 0:t.removeEventListener("reset",this.reset)};t.prototype.componentWillLoad=function(){var t,e;this.childElType=this.type==="textarea"?"textarea":"input";this.defaultValue=this.value;this.maxString=(t=this.max)===null||t===void 0?void 0:t.toString();this.minString=(e=this.min)===null||e===void 0?void 0:e.toString();this.requestedIcon=setRequestedIcon(INPUT_TYPE_ICONS,this.icon,this.type)};t.prototype.componentDidLoad=function(){this.slottedActionEl=this.el.querySelector("[slot=action]");this.setDisabledAction();if(this.type==="number"&&this.childEl){this.childEl.style.cssText=hiddenInputStyle}};t.prototype.componentShouldUpdate=function(t,e,i){if(this.type==="number"&&i==="value"&&t&&!isValidNumber(t)){this.value=e;return false}return true};t.prototype.keyDownHandler=function(t){if(this.isClearable&&getKey(t.key)==="Escape"){this.clearInputValue(t);t.preventDefault()}};t.prototype.setFocus=function(){return __awaiter(this,void 0,void 0,(function(){var t,e;return __generator(this,(function(i){if(this.type==="number"){(t=this.childNumberEl)===null||t===void 0?void 0:t.focus()}else{(e=this.childEl)===null||e===void 0?void 0:e.focus()}return[2]}))}))};t.prototype.setDisabledAction=function(){if(!this.slottedActionEl){return}var t=this.slottedActionEl;this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled")};t.prototype.render=function(){var t;var e=getElementDir(this.el);var i=getAttributes(this.el,["alignment","dir","clearable","min","max","step","value","icon","loading","prefix-text","scale","status","suffix-text","number-button-type","locale","group-separator"]);var c=h("div",{class:"calcite-input-loading"},h("calcite-progress",{type:"indeterminate"}));var a=this.scale==="s"||this.scale==="m"?"s":"m";var n=h("button",{class:"calcite-input-clear-button",disabled:this.loading,onClick:this.clearInputValue},h("calcite-icon",{icon:"x",scale:a}));var l=h("calcite-icon",{class:"calcite-input-icon",dir:e,flipRtl:this.iconFlipRtl,icon:this.requestedIcon,scale:a});var r=this.numberButtonType==="horizontal"?"number-button-item-horizontal":null;var s=h("div",{class:"calcite-input-number-button-item "+r,"data-adjustment":"up",onMouseDown:this.numberButtonMouseDownHandler},h("calcite-icon",{icon:"chevron-up",scale:a}));var u=h("div",{class:"calcite-input-number-button-item "+r,"data-adjustment":"down",onMouseDown:this.numberButtonMouseDownHandler},h("calcite-icon",{icon:"chevron-down",scale:a}));var o=h("div",{class:"calcite-input-number-button-wrapper"},s,u);var p=h("div",{class:"calcite-input-prefix"},this.prefixText);var d=h("div",{class:"calcite-input-suffix"},this.suffixText);var m=this.type==="number"?h("input",Object.assign({},i,{autofocus:this.autofocus?true:null,defaultValue:this.defaultValue,disabled:this.disabled?true:null,key:"localized-input",maxLength:this.maxLength,minLength:this.minLength,name:undefined,onBlur:this.inputBlurHandler,onFocus:this.inputFocusHandler,onInput:this.inputNumberInputHandler,onKeyDown:this.inputNumberKeyDownHandler,placeholder:this.placeholder||"",ref:this.setChildNumberElRef,tabIndex:0,type:"text",value:this.localizedValue})):null;var b=[h(this.childElType,Object.assign({},i,{autofocus:this.autofocus?true:null,defaultValue:this.defaultValue,disabled:this.disabled?true:null,max:this.maxString,maxLength:this.maxLength,min:this.minString,minLength:this.minLength,name:this.name,onBlur:this.inputBlurHandler,onFocus:this.inputFocusHandler,onInput:this.inputInputHandler,onKeyDown:this.inputKeyDownHandler,placeholder:this.placeholder||"",ref:this.setChildElRef,required:this.required?true:null,step:this.step,tabIndex:this.disabled||this.type==="number"?-1:null,type:this.type,value:this.value})),this.isTextarea?h("div",{class:"calcite-input-resize-icon-wrapper"},h("calcite-icon",{icon:"chevron-down",scale:"s"})):null];return h(Host,{onClick:this.inputFocusHandler},h("div",{class:(t={"calcite-input-wrapper":true},t[CSS_UTILITY.rtl]=e==="rtl",t),dir:e},this.type==="number"&&this.numberButtonType==="horizontal"?u:null,this.prefixText?p:null,h("div",{class:"calcite-input-element-wrapper"},m,b,this.isClearable?n:null,this.requestedIcon?l:null,this.loading?c:null),h("div",{class:"calcite-action-wrapper"},h("slot",{name:SLOTS.action})),this.type==="number"&&this.numberButtonType==="vertical"?o:null,this.suffixText?d:null,this.type==="number"&&this.numberButtonType==="horizontal"?s:null))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{disabled:["disabledWatcher"],max:["maxWatcher"],min:["minWatcher"],value:["valueWatcher"],icon:["updateRequestedIcon"],type:["updateRequestedIcon"]}},enumerable:false,configurable:true});return t}();CalciteInput.style=calciteInputCss;export{CalciteInput as calcite_input};