@sky.ui/core 0.0.41 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +1277 -541
- package/dist/helper/controllers/animation-controller.d.ts +4 -4
- package/dist/helper/controllers/animation-controller.js.map +1 -1
- package/dist/helper/controllers/index.d.ts +1 -0
- package/dist/helper/controllers/index.js +1 -1
- package/dist/helper/controllers/popover-controller.d.ts +1 -1
- package/dist/helper/controllers/popover-controller.js.map +1 -1
- package/dist/helper/controllers/preset-controller.d.ts +55 -0
- package/dist/helper/controllers/preset-controller.js +2 -0
- package/dist/helper/controllers/preset-controller.js.map +1 -0
- package/dist/helper/iconify-offline.js.map +1 -1
- package/dist/helper/index.js +1 -1
- package/dist/helper/internals/form-control-base.d.ts +2 -2
- package/dist/helper/internals/form-control-base.js.map +1 -1
- package/dist/helper/styles/focus-ring.d.ts +10 -0
- package/dist/helper/styles/focus-ring.js +10 -0
- package/dist/helper/styles/focus-ring.js.map +1 -0
- package/dist/helper/utils/color-resolver.d.ts +0 -14
- package/dist/helper/utils/color-resolver.js +1 -1
- package/dist/helper/utils/color-resolver.js.map +1 -1
- package/dist/helper/utils/component-presets.d.ts +132 -0
- package/dist/helper/utils/component-presets.js +2 -0
- package/dist/helper/utils/component-presets.js.map +1 -0
- package/dist/helper/utils/contrast-color.d.ts +2 -2
- package/dist/helper/utils/contrast-color.js.map +1 -1
- package/dist/helper/utils/index.d.ts +1 -0
- package/dist/helper/utils/index.js +1 -1
- package/dist/helper/utils/size-resolver.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/sky-alert/sky-alert.d.ts +12 -4
- package/dist/sky-alert/sky-alert.js +4 -4
- package/dist/sky-alert/sky-alert.js.map +1 -1
- package/dist/sky-appbar/sky-appbar.d.ts +9 -3
- package/dist/sky-appbar/sky-appbar.js +4 -4
- package/dist/sky-appbar/sky-appbar.js.map +1 -1
- package/dist/sky-avatar/sky-avatar.d.ts +5 -1
- package/dist/sky-avatar/sky-avatar.js +7 -7
- package/dist/sky-avatar/sky-avatar.js.map +1 -1
- package/dist/sky-badge/sky-badge.d.ts +6 -2
- package/dist/sky-badge/sky-badge.js +6 -6
- package/dist/sky-badge/sky-badge.js.map +1 -1
- package/dist/sky-button/sky-button.d.ts +24 -4
- package/dist/sky-button/sky-button.js +9 -8
- package/dist/sky-button/sky-button.js.map +1 -1
- package/dist/sky-card/sky-card.d.ts +10 -2
- package/dist/sky-card/sky-card.js +4 -4
- package/dist/sky-card/sky-card.js.map +1 -1
- package/dist/sky-checkbox/sky-checkbox.d.ts +6 -3
- package/dist/sky-checkbox/sky-checkbox.js +47 -40
- package/dist/sky-checkbox/sky-checkbox.js.map +1 -1
- package/dist/sky-chip/sky-chip.d.ts +6 -2
- package/dist/sky-chip/sky-chip.js +10 -9
- package/dist/sky-chip/sky-chip.js.map +1 -1
- package/dist/sky-col/sky-col.d.ts +5 -1
- package/dist/sky-col/sky-col.js +4 -4
- package/dist/sky-col/sky-col.js.map +1 -1
- package/dist/sky-combobox/sky-combobox.d.ts +9 -2
- package/dist/sky-combobox/sky-combobox.js +27 -58
- package/dist/sky-combobox/sky-combobox.js.map +1 -1
- package/dist/sky-dialog/sky-dialog.d.ts +5 -1
- package/dist/sky-dialog/sky-dialog.js +3 -3
- package/dist/sky-dialog/sky-dialog.js.map +1 -1
- package/dist/sky-divider/sky-divider.d.ts +5 -1
- package/dist/sky-divider/sky-divider.js +5 -5
- package/dist/sky-divider/sky-divider.js.map +1 -1
- package/dist/sky-flexbox/sky-flexbox.d.ts +5 -1
- package/dist/sky-flexbox/sky-flexbox.js +4 -4
- package/dist/sky-flexbox/sky-flexbox.js.map +1 -1
- package/dist/sky-flexcol/sky-flexcol.d.ts +5 -1
- package/dist/sky-flexcol/sky-flexcol.js +2 -2
- package/dist/sky-flexcol/sky-flexcol.js.map +1 -1
- package/dist/sky-form/sky-form.d.ts +5 -1
- package/dist/sky-form/sky-form.js +2 -2
- package/dist/sky-form/sky-form.js.map +1 -1
- package/dist/sky-grid/sky-grid.d.ts +5 -1
- package/dist/sky-grid/sky-grid.js +3 -3
- package/dist/sky-grid/sky-grid.js.map +1 -1
- package/dist/sky-icon/sky-icon.d.ts +4 -1
- package/dist/sky-icon/sky-icon.js +4 -4
- package/dist/sky-icon/sky-icon.js.map +1 -1
- package/dist/sky-image/sky-image.d.ts +5 -1
- package/dist/sky-image/sky-image.js +5 -5
- package/dist/sky-image/sky-image.js.map +1 -1
- package/dist/sky-image/srcset-utils.js.map +1 -1
- package/dist/sky-input/sky-input.d.ts +5 -1
- package/dist/sky-input/sky-input.js +111 -111
- package/dist/sky-input/sky-input.js.map +1 -1
- package/dist/sky-list/sky-list.d.ts +5 -1
- package/dist/sky-list/sky-list.js +3 -3
- package/dist/sky-list/sky-list.js.map +1 -1
- package/dist/sky-listitem/sky-listitem.d.ts +5 -1
- package/dist/sky-listitem/sky-listitem.js +3 -3
- package/dist/sky-listitem/sky-listitem.js.map +1 -1
- package/dist/sky-radio/sky-radio.d.ts +8 -3
- package/dist/sky-radio/sky-radio.js +4 -3
- package/dist/sky-radio/sky-radio.js.map +1 -1
- package/dist/sky-row/sky-row.d.ts +4 -1
- package/dist/sky-row/sky-row.js +2 -2
- package/dist/sky-row/sky-row.js.map +1 -1
- package/dist/sky-sheet/sky-sheet.d.ts +7 -2
- package/dist/sky-sheet/sky-sheet.js +2 -2
- package/dist/sky-sheet/sky-sheet.js.map +1 -1
- package/dist/sky-simple-table/sky-simple-table.d.ts +5 -1
- package/dist/sky-simple-table/sky-simple-table.js +3 -3
- package/dist/sky-simple-table/sky-simple-table.js.map +1 -1
- package/dist/sky-theme-provider/sky-theme-provider.d.ts +1 -1
- package/dist/sky-theme-provider/sky-theme-provider.js +2 -2
- package/dist/sky-theme-provider/sky-theme-provider.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefined as a}from"lit/directives/if-defined.js";import{styleMap as r}from"lit/directives/style-map.js";import{property as n,state as o,query as l,customElement as p}from"lit/decorators.js";import{resolveColor as d}from"../helper/utils/color-resolver.js";import{live as h}from"lit/directives/live.js";import{FormControlBase as c}from"../helper/internals/form-control-base.js";import{SkyIcon as u}from"../sky-icon/sky-icon.js";var y=Object.defineProperty,v=Object.getOwnPropertyDescriptor,f=(t,e,i,s)=>{for(var a,r=s>1?void 0:s?v(e,i):e,n=t.length-1;n>=0;n--)(a=t[n])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&y(e,i,r),r};let m=class extends c{constructor(){super(...arguments),this.value="",this.placeholder="",this.label="",this.type="text",this.suffix="",this.prefix="",this.prefixColor="",this.suffixColor="",this.color="primary",this._validations=[],this.compact=!1,this.loading=!1,this.showErrors=!1,this.clearable=!1,this.errorDisplayMode="single",this.required=!1,this.step=null,this.min=null,this.max=null,this.autocapitalize="off",this.autocomplete="off",this.spellcheck=!1,this.dir="ltr",this.rows=6,this.resizable="none",this.accept="",this.multiple=!1,this.inputmode=null,this.enterkeyhint=null,this.pattern=null,this.minlength=null,this.maxlength=null,this.list=null,this.size=null,this.cols=null,this.autofocus=!1,this.capture=!1,this.inputRole=null,this.ariaLabel=null,this.ariaLabelledby=null,this.ariaDescribedby=null,this.showNumberButtons=!1,this.showPasswordToggle=!0,this.passwordVisibleIcon="material-symbols:visibility-off",this.passwordHiddenIcon="material-symbols:visibility",this.validationActive=!1,this.invalid=!1,this.variant="default",this.selectedFileName="",this.selectedFiles=[],this.focused=!1,this.validationStatus=[],this.validationErrors=[],this.typingStarted=!1,this.autofillIconSlot="left",this.autofillGuardActive=!1,this.showPassword=!1,this.totalFileSize=0,this.selectedFileCount=0,this.filePreview=null,this._leftIconSlot=null,this._rightIconSlot=null,this._iconClickWired=new WeakSet,this._onLeftIconSlotChange=()=>this._wireIconSlot("left",this._leftIconSlot),this._onRightIconSlotChange=()=>this._wireIconSlot("right",this._rightIconSlot),this.keepInputFocused=t=>{t.preventDefault(),t.stopPropagation(),this.refocusInput()}}get validations(){return this._validations}set validations(t){const e=this._validations;this._validations=Array.isArray(t)?t:[],this.requestUpdate("validations",e)}connectedCallback(){super.connectedCallback(),this.autofillGuardActive="search"===this.type,this.hasAttribute("tabindex")||(this.tabIndex=this.disabled?-1:0),this.hasUpdated&&this._setupIconSlots()}disconnectedCallback(){this._leftIconSlot?.removeEventListener("slotchange",this._onLeftIconSlotChange),this._rightIconSlot?.removeEventListener("slotchange",this._onRightIconSlotChange),this._leftIconSlot=null,this._rightIconSlot=null,super.disconnectedCallback()}_setupIconSlots(){this._leftIconSlot||(this._leftIconSlot=this.shadowRoot?.querySelector('slot[name="icon-left"]')??null,this._leftIconSlot?.addEventListener("slotchange",this._onLeftIconSlotChange)),this._rightIconSlot||(this._rightIconSlot=this.shadowRoot?.querySelector('slot[name="icon-right"]')??null,this._rightIconSlot?.addEventListener("slotchange",this._onRightIconSlotChange)),this._wireIconSlot("left",this._leftIconSlot),this._wireIconSlot("right",this._rightIconSlot)}_wireIconSlot(t,e){if(e)for(const i of e.assignedElements({flatten:!0}))i instanceof HTMLElement&&(this._iconClickWired.has(i)||(this._iconClickWired.add(i),i.addEventListener("click",()=>this.handleIconClick(t))))}firstUpdated(t){super.firstUpdated(t),this.captureDefaultValue(this.value),this.syncFormValue(),this.syncValidity(),this._setupIconSlots()}willUpdate(t){t.has("validations")&&Array.isArray(this.validations)&&(this.validationStatus=this.validations.map(()=>!1)),t.has("value")&&"file"===this.type&&(null==this.value||""===String(this.value).trim()?(this.selectedFileName="",this.selectedFiles=[],this.totalFileSize=0,this.selectedFileCount=0,this.filePreview=null):this.selectedFileName||(this.selectedFileName=this.value)),t.has("type")&&"search"===this.type&&(this.autofillGuardActive=!0)}updated(t){if(super.updated(t),t.has("color")&&this.color&&this.style.setProperty("--sky-input-color",d(this.color)),t.has("rows")){const t=this.inputWrapperEl;t&&t.style.setProperty("--rows",String(this.rows))}(t.has("value")||t.has("selectedFiles")||t.has("selectedFileName")||t.has("type")||t.has("multiple")||t.has("name")||t.has("disabled"))&&this.syncFormValue(),(t.has("value")||t.has("selectedFiles")||t.has("selectedFileName")||t.has("validationErrors")||t.has("required")||t.has("disabled")||t.has("readonly"))&&this.syncValidity()}getFormValue(){if(!this.name)return null;if("file"===this.type){if(!this.selectedFiles||0===this.selectedFiles.length)return null;if(this.multiple){const t=new FormData;for(const e of this.selectedFiles)t.append(this.name,e);return t}return this.selectedFiles[0]}return this.value??""}setValueFromFormState(t){"string"!=typeof t?(this.value="",this.selectedFileName="",this.selectedFiles=[],this.totalFileSize=0,this.selectedFileCount=0,this.filePreview=null):this.value=t}getValidityAnchor(){return this}isEmpty(){return"file"===this.type?!this.selectedFiles||0===this.selectedFiles.length:!this.value||""===this.value.toString().trim()}getCustomErrorMessage(){return this.validationErrors?.length?"all"===this.errorDisplayMode?this.validationErrors.join("\n"):this.validationErrors[0]:""}getNativeControl(){return"textarea"===this.type?this.shadowRoot?.querySelector("textarea"):this.shadowRoot?.querySelector("input")}onNativeValueMutated(t){"file"!==this.type&&(this.value=t?.value??""),this.validateInput()}reset(){this.value="",this.selectedFileName="",this.filePreview=null,this.selectedFiles=[],this.selectedFileCount=0,this.validationErrors=[],this.typingStarted=!1,this.validationActive=!1,this.selectedFileCount=0,this.totalFileSize=0}get nativeRequiredMessage(){return this.validationActive?this.disabled?"":this.required&&this.isEmpty()?this.requiredMessage||"This field is required.":"":""}getEmittedValue(){if("number"!==this.type)return this.value;if(""===this.value||null==this.value)return"";const t=Number(this.value);return Number.isFinite(t)?t:this.value}handleClear(){this.disabled||this.readonly||(this.reset(),this.validationActive=!0,this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.getEmittedValue()},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("value-cleared",{detail:{value:this.getEmittedValue()},bubbles:!0,composed:!0})))}handleFileChange(t){if(this.disabled||this.readonly)return;const e=t.target.files;if(e&&e.length){const i=Array.from(e);this.selectedFiles=i,this.selectedFileName=i.map(t=>t.name).join(", "),this.value=this.selectedFileName,this.syncFormValue(),this.syncValidity();const s=i.reduce((t,e)=>t+e.size,0);if(this.totalFileSize=s,this.selectedFileCount=i.length,i[0].type.startsWith("image/")){const t=new FileReader;t.onload=t=>{t.target&&(this.filePreview=t.target.result)},t.readAsDataURL(i[0])}else this.filePreview=null;this.reemitNativeEvent("change",t),this.reemitNativeEvent("input",t),this.dispatchEvent(new CustomEvent("file-selected",{detail:{files:i,fileName:this.selectedFileName,totalSize:s,fileCount:this.selectedFileCount},bubbles:!0,composed:!0})),this.validateInput()}else this.value="",this.filePreview=null,this.totalFileSize=0,this.selectedFileCount=0,this.selectedFiles=[],this.validateInput()}handleKeydown(t){this.disabled||this.readonly||"Enter"===t.key&&"file"===this.type&&(t.preventDefault(),t.stopPropagation(),this.triggerNativeDropdown())}get preview(){return this.filePreview}handleInput(t){t.stopPropagation(),this.disabled||this.readonly?t.preventDefault():(this.value=t.target.value,this.syncFormValue(),this.syncValidity(),this.typingStarted||(this.typingStarted=!0),this.validateInput(),this.reemitNativeEvent("input",t),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.getEmittedValue()},bubbles:!0,composed:!0})))}handleFocus(t){t.stopPropagation(),this.releaseAutofillGuard(),this.focused=!0,this.reemitNativeEvent("focus",t)}releaseAutofillGuard(){this.autofillGuardActive&&(this.autofillGuardActive=!1)}handleAutofillGuardPointerDown(t){this.releaseAutofillGuard(),t.stopPropagation()}onFormReset(){this.setValueFromFormState(this.defaultValue),this.validationActive=!1,this.invalid=!1,this.typingStarted=!1,this.validationErrors=[],this.validationStatus=[],"file"===this.type&&(this.selectedFiles=[],this.selectedFileName="",this.totalFileSize=0,this.selectedFileCount=0,this.filePreview=null),"search"===this.type&&(this.autofillGuardActive=!0)}handleBlur(t){t.stopPropagation(),this.validationActive=!0,this.focused=!1,this.reemitNativeEvent("blur",t)}validateForForm(){const t="file"===this.type?this.selectedFiles??[]:this.value??"";for(const e of this.validations??[]){const i=e(t);if(!0!==i)return"string"==typeof i?i:"Invalid value."}return""}validateInput(){this.validationErrors=[],this.validationStatus=[];const t="file"===this.type,e=t?!this.selectedFiles||0===this.selectedFiles.length:!this.value||""===this.value.toString().trim();if(this.required&&e&&this.syncValidity(),Array.isArray(this.validations)&&this.validations.length){const e=t?this.selectedFiles??[]:this.value??"";this.validationStatus=this.validations.map((t,i)=>{try{if("function"!=typeof t)throw new Error(`Validation at index ${i} must be a function.`);const s=t(e);return!0===s||(this.validationErrors.push("string"==typeof s?s:`Validation ${i} failed.`),!1)}catch(t){const e="object"==typeof t&&null!==t&&"message"in t?String(t.message):"string"==typeof t?t:"Unknown error";return this.validationErrors.push(`Error in validation ${i}: ${e}`),!1}})}this.dispatchEvent(new CustomEvent("validation-error",{detail:{errors:this.validationErrors},bubbles:!0,composed:!0})),this.syncValidity();const i=0===this.validationErrors.length;return this.invalid=!i,i}getErrorMessages(){switch(this.errorDisplayMode){case"single":return this.validationErrors.slice(0,1);case"all":return this.validationErrors;default:return[]}}handleIconClick(t,e=null){this.dispatchEvent(new CustomEvent(`${t}-icon-click`,{detail:{position:t,eventType:e?e.type:null,eventData:e},bubbles:!0,composed:!0}))}formatFileSize(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,e)).toFixed(2))} ${["Bytes","KB","MB","GB","TB"][e]}`}incrementValue(){if(this.disabled||this.readonly)return;const t=parseFloat(this.value)||0,e=parseFloat(this.step??"")||1;t+e<=(this.max?parseFloat(this.max):1/0)&&(this.value=(t+e).toString(),this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.getEmittedValue()}}))),this.refocusInput()}decrementValue(){if(this.disabled||this.readonly)return;const t=parseFloat(this.value)||0,e=parseFloat(this.step??"")||1;t-e>=(this.min?parseFloat(this.min):-1/0)&&(this.value=(t-e).toString(),this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.getEmittedValue()}}))),this.refocusInput()}renderValidationErrors(){if(!this.showErrors||!this.validationActive)return null;const t=this.nativeRequiredMessage,e=this.getErrorMessages();let s=[];if("single"===this.errorDisplayMode?t?s=[t]:e.length&&(s=[e[0]]):s=t?[t,...e]:e,!s.length)return null;const a=`${this.id||"sky-input"}-errors`;return i`
|
|
1
|
+
import{css as t,LitElement as e,html as i,nothing as a}from"lit";import{ifDefined as s}from"lit/directives/if-defined.js";import{styleMap as r}from"lit/directives/style-map.js";import{property as o,state as n,query as l,customElement as p}from"lit/decorators.js";import{resolveColor as d}from"../helper/utils/color-resolver.js";import{PresetController as h}from"../helper/controllers/preset-controller.js";import{live as c}from"lit/directives/live.js";import{FormControlBase as u}from"../helper/internals/form-control-base.js";import{SkyIcon as y}from"../sky-icon/sky-icon.js";var v=Object.defineProperty,f=Object.getOwnPropertyDescriptor,m=(t,e,i,a)=>{for(var s,r=a>1?void 0:a?f(e,i):e,o=t.length-1;o>=0;o--)(s=t[o])&&(r=(a?s(e,i,r):s(r))||r);return a&&r&&v(e,i,r),r};let g=class extends u{constructor(){super(...arguments),this.value="",this.placeholder="",this.label="",this.type="text",this.suffix="",this.prefix="",this.prefixColor="",this.suffixColor="",this.color="primary",this._validations=[],this.compact=!1,this.loading=!1,this.showErrors=!1,this.clearable=!1,this.errorDisplayMode="single",this.required=!1,this.step=null,this.min=null,this.max=null,this.autocapitalize="off",this.autocomplete="off",this.spellcheck=!1,this.dir="ltr",this.rows=6,this.resizable="none",this.accept="",this.multiple=!1,this.inputmode=null,this.enterkeyhint=null,this.pattern=null,this.minlength=null,this.maxlength=null,this.list=null,this.size=null,this.cols=null,this.autofocus=!1,this.capture=!1,this.inputRole=null,this.ariaLabel=null,this.ariaLabelledby=null,this.ariaDescribedby=null,this.showNumberButtons=!1,this.showPasswordToggle=!0,this.passwordVisibleIcon="material-symbols:visibility-off",this.passwordHiddenIcon="material-symbols:visibility",this.validationActive=!1,this.invalid=!1,this.variant="default",this.preset="",this._presets=new h(this),this.selectedFileName="",this.selectedFiles=[],this.focused=!1,this.validationStatus=[],this.validationErrors=[],this.typingStarted=!1,this.autofillIconSlot="left",this.autofillGuardActive=!1,this.showPassword=!1,this.totalFileSize=0,this.selectedFileCount=0,this.filePreview=null,this._leftIconSlot=null,this._rightIconSlot=null,this._iconClickWired=new WeakSet,this._onLeftIconSlotChange=()=>this._wireIconSlot("left",this._leftIconSlot),this._onRightIconSlotChange=()=>this._wireIconSlot("right",this._rightIconSlot),this.keepInputFocused=t=>{t.preventDefault(),t.stopPropagation(),this.refocusInput()}}get validations(){return this._validations}set validations(t){const e=this._validations;this._validations=Array.isArray(t)?t:[],this.requestUpdate("validations",e)}connectedCallback(){super.connectedCallback(),this.autofillGuardActive="search"===this.type,this.hasAttribute("tabindex")||(this.tabIndex=this.disabled?-1:0),this.hasUpdated&&this._setupIconSlots()}disconnectedCallback(){this._leftIconSlot?.removeEventListener("slotchange",this._onLeftIconSlotChange),this._rightIconSlot?.removeEventListener("slotchange",this._onRightIconSlotChange),this._leftIconSlot=null,this._rightIconSlot=null,super.disconnectedCallback()}_setupIconSlots(){this._leftIconSlot||(this._leftIconSlot=this.shadowRoot?.querySelector('slot[name="icon-left"]')??null,this._leftIconSlot?.addEventListener("slotchange",this._onLeftIconSlotChange)),this._rightIconSlot||(this._rightIconSlot=this.shadowRoot?.querySelector('slot[name="icon-right"]')??null,this._rightIconSlot?.addEventListener("slotchange",this._onRightIconSlotChange)),this._wireIconSlot("left",this._leftIconSlot),this._wireIconSlot("right",this._rightIconSlot)}_wireIconSlot(t,e){if(e)for(const i of e.assignedElements({flatten:!0}))i instanceof HTMLElement&&(this._iconClickWired.has(i)||(this._iconClickWired.add(i),i.addEventListener("click",()=>this.handleIconClick(t))))}firstUpdated(t){super.firstUpdated(t),this.captureDefaultValue(this.value),this.syncFormValue(),this.syncValidity(),this._setupIconSlots()}willUpdate(t){t.has("validations")&&Array.isArray(this.validations)&&(this.validationStatus=this.validations.map(()=>!1)),t.has("value")&&"file"===this.type&&(null==this.value||""===String(this.value).trim()?(this.selectedFileName="",this.selectedFiles=[],this.totalFileSize=0,this.selectedFileCount=0,this.filePreview=null):this.selectedFileName||(this.selectedFileName=this.value)),t.has("type")&&"search"===this.type&&(this.autofillGuardActive=!0)}updated(t){if(super.updated(t),this.setAttribute("data-sky-variant",this.variant),this.toggleAttribute("data-sky-compact",this.compact),this.color&&this.style.setProperty("--sky-input-color",d(this.color)),t.has("rows")){const t=this.inputWrapperEl;t&&t.style.setProperty("--rows",String(this.rows))}(t.has("value")||t.has("selectedFiles")||t.has("selectedFileName")||t.has("type")||t.has("multiple")||t.has("name")||t.has("disabled"))&&this.syncFormValue(),(t.has("value")||t.has("selectedFiles")||t.has("selectedFileName")||t.has("validationErrors")||t.has("required")||t.has("disabled")||t.has("readonly"))&&this.syncValidity()}getFormValue(){if(!this.name)return null;if("file"===this.type){if(!this.selectedFiles||0===this.selectedFiles.length)return null;if(this.multiple){const t=new FormData;for(const e of this.selectedFiles)t.append(this.name,e);return t}return this.selectedFiles[0]}return this.value??""}setValueFromFormState(t){"string"!=typeof t?(this.value="",this.selectedFileName="",this.selectedFiles=[],this.totalFileSize=0,this.selectedFileCount=0,this.filePreview=null):this.value=t}getValidityAnchor(){return this}isEmpty(){return"file"===this.type?!this.selectedFiles||0===this.selectedFiles.length:!this.value||""===this.value.toString().trim()}getCustomErrorMessage(){return this.validationErrors?.length?"all"===this.errorDisplayMode?this.validationErrors.join("\n"):this.validationErrors[0]:""}getNativeControl(){return"textarea"===this.type?this.shadowRoot?.querySelector("textarea"):this.shadowRoot?.querySelector("input")}onNativeValueMutated(t){"file"!==this.type&&(this.value=t?.value??""),this.validateInput()}reset(){this.value="",this.selectedFileName="",this.filePreview=null,this.selectedFiles=[],this.selectedFileCount=0,this.validationErrors=[],this.typingStarted=!1,this.validationActive=!1,this.selectedFileCount=0,this.totalFileSize=0}get nativeRequiredMessage(){return this.validationActive?this.disabled?"":this.required&&this.isEmpty()?this.requiredMessage||"This field is required.":"":""}getEmittedValue(){if("number"!==this.type)return this.value;if(""===this.value||null==this.value)return"";const t=Number(this.value);return Number.isFinite(t)?t:this.value}handleClear(){this.disabled||this.readonly||(this.reset(),this.validationActive=!0,this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.getEmittedValue()},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("value-cleared",{detail:{value:this.getEmittedValue()},bubbles:!0,composed:!0})))}handleFileChange(t){if(this.disabled||this.readonly)return;const e=t.target.files;if(e&&e.length){const i=Array.from(e);this.selectedFiles=i,this.selectedFileName=i.map(t=>t.name).join(", "),this.value=this.selectedFileName,this.syncFormValue(),this.syncValidity();const a=i.reduce((t,e)=>t+e.size,0);if(this.totalFileSize=a,this.selectedFileCount=i.length,i[0].type.startsWith("image/")){const t=new FileReader;t.onload=t=>{t.target&&(this.filePreview=t.target.result)},t.readAsDataURL(i[0])}else this.filePreview=null;this.reemitNativeEvent("change",t),this.reemitNativeEvent("input",t),this.dispatchEvent(new CustomEvent("file-selected",{detail:{files:i,fileName:this.selectedFileName,totalSize:a,fileCount:this.selectedFileCount},bubbles:!0,composed:!0})),this.validateInput()}else this.value="",this.filePreview=null,this.totalFileSize=0,this.selectedFileCount=0,this.selectedFiles=[],this.validateInput()}handleKeydown(t){this.disabled||this.readonly||"Enter"===t.key&&"file"===this.type&&(t.preventDefault(),t.stopPropagation(),this.triggerNativeDropdown())}get preview(){return this.filePreview}handleInput(t){t.stopPropagation(),this.disabled||this.readonly?t.preventDefault():(this.value=t.target.value,this.syncFormValue(),this.syncValidity(),this.typingStarted||(this.typingStarted=!0),this.validateInput(),this.reemitNativeEvent("input",t),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.getEmittedValue()},bubbles:!0,composed:!0})))}handleFocus(t){t.stopPropagation(),this.releaseAutofillGuard(),this.focused=!0,this.reemitNativeEvent("focus",t)}releaseAutofillGuard(){this.autofillGuardActive&&(this.autofillGuardActive=!1)}handleAutofillGuardPointerDown(t){this.releaseAutofillGuard(),t.stopPropagation()}onFormReset(){this.setValueFromFormState(this.defaultValue),this.validationActive=!1,this.invalid=!1,this.typingStarted=!1,this.validationErrors=[],this.validationStatus=[],"file"===this.type&&(this.selectedFiles=[],this.selectedFileName="",this.totalFileSize=0,this.selectedFileCount=0,this.filePreview=null),"search"===this.type&&(this.autofillGuardActive=!0)}handleBlur(t){t.stopPropagation(),this.validationActive=!0,this.focused=!1,this.reemitNativeEvent("blur",t)}validateForForm(){const t="file"===this.type?this.selectedFiles??[]:this.value??"";for(const e of this.validations??[]){const i=e(t);if(!0!==i)return"string"==typeof i?i:"Invalid value."}return""}validateInput(){this.validationErrors=[],this.validationStatus=[];const t="file"===this.type,e=t?!this.selectedFiles||0===this.selectedFiles.length:!this.value||""===this.value.toString().trim();if(this.required&&e&&this.syncValidity(),Array.isArray(this.validations)&&this.validations.length){const e=t?this.selectedFiles??[]:this.value??"";this.validationStatus=this.validations.map((t,i)=>{try{if("function"!=typeof t)throw new Error(`Validation at index ${i} must be a function.`);const a=t(e);return!0===a||(this.validationErrors.push("string"==typeof a?a:`Validation ${i} failed.`),!1)}catch(t){const e="object"==typeof t&&null!==t&&"message"in t?String(t.message):"string"==typeof t?t:"Unknown error";return this.validationErrors.push(`Error in validation ${i}: ${e}`),!1}})}this.dispatchEvent(new CustomEvent("validation-error",{detail:{errors:this.validationErrors},bubbles:!0,composed:!0})),this.syncValidity();const i=0===this.validationErrors.length;return this.invalid=!i,i}getErrorMessages(){switch(this.errorDisplayMode){case"single":return this.validationErrors.slice(0,1);case"all":return this.validationErrors;default:return[]}}handleIconClick(t,e=null){this.dispatchEvent(new CustomEvent(`${t}-icon-click`,{detail:{position:t,eventType:e?e.type:null,eventData:e},bubbles:!0,composed:!0}))}formatFileSize(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,e)).toFixed(2))} ${["Bytes","KB","MB","GB","TB"][e]}`}incrementValue(){if(this.disabled||this.readonly)return;const t=parseFloat(this.value)||0,e=parseFloat(this.step??"")||1;t+e<=(this.max?parseFloat(this.max):1/0)&&(this.value=(t+e).toString(),this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.getEmittedValue()}}))),this.refocusInput()}decrementValue(){if(this.disabled||this.readonly)return;const t=parseFloat(this.value)||0,e=parseFloat(this.step??"")||1;t-e>=(this.min?parseFloat(this.min):-1/0)&&(this.value=(t-e).toString(),this.validateInput(),this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:this.getEmittedValue()}}))),this.refocusInput()}renderValidationErrors(){if(!this.showErrors||!this.validationActive)return null;const t=this.nativeRequiredMessage,e=this.getErrorMessages();let a=[];if("single"===this.errorDisplayMode?t?a=[t]:e.length&&(a=[e[0]]):a=t?[t,...e]:e,!a.length)return null;const s=`${this.id||"sky-input"}-errors`;return i`
|
|
2
2
|
<div class="progress-message">
|
|
3
|
-
<ul id=${
|
|
4
|
-
${
|
|
3
|
+
<ul id=${s} class="error-list" part="error-list">
|
|
4
|
+
${a.map(t=>i`<li class="error" part="error">${t}</li>`)}
|
|
5
5
|
</ul>
|
|
6
6
|
</div>
|
|
7
|
-
`}togglePasswordVisibility(){this.showPassword=!this.showPassword}focusInput(){const t=this.nativeInputEl;t&&"function"==typeof t.focus&&t.focus()}handleWrapperClick(t){if(t.stopPropagation(),this.disabled)return;const e=this.nativeInputEl;e&&"function"==typeof e.focus&&e.focus()}get isInvalid(){return this.matches(":invalid")||this.validationActive&&this.validationErrors.length>0}get describedById(){return this.ariaDescribedby??(this.showErrors?`${this.id||"sky-input"}-errors`:void 0)}refocusInput(){const t=this.shadowRoot?.querySelector("input");t?.focus({preventScroll:!0})}triggerNativeDropdown(){if(this.disabled||this.readonly)return;const t=this.shadowRoot?.querySelector('input[type="date"], input[type="time"], input[type="week"], input[type="month"], input[type="datetime-local"], input[type="file"]');t&&("file"===this.type?t.click():this.showPicker())}isFilterSearchInput(){return"search"===this.type}nativeAutocomplete(){return this.isFilterSearchInput()?"off":this.autocomplete}nativeTextInputType(t){return t&&this.showPassword||this.isFilterSearchInput()?"text":this.type}nativeInputMode(){return this.inputmode?this.inputmode:this.isFilterSearchInput()?"search":void 0}nativeEnterKeyHint(){return this.enterkeyhint?this.enterkeyhint:this.isFilterSearchInput()?"search":void 0}nativeInputRole(){return this.inputRole?this.inputRole:"search"===this.type?"searchbox":void 0}affixColorStyle(t){const e=String(t??"").trim();if(e)return{color:d(e)}}renderInputAffix(t){const e="prefix"===t?this.prefix:this.suffix;if(!String(e??"").length)return
|
|
7
|
+
`}togglePasswordVisibility(){this.showPassword=!this.showPassword}focusInput(){const t=this.nativeInputEl;t&&"function"==typeof t.focus&&t.focus()}handleWrapperClick(t){if(t.stopPropagation(),this.disabled)return;const e=this.nativeInputEl;e&&"function"==typeof e.focus&&e.focus()}get isInvalid(){return this.matches(":invalid")||this.validationActive&&this.validationErrors.length>0}get describedById(){return this.ariaDescribedby??(this.showErrors?`${this.id||"sky-input"}-errors`:void 0)}refocusInput(){const t=this.shadowRoot?.querySelector("input");t?.focus({preventScroll:!0})}triggerNativeDropdown(){if(this.disabled||this.readonly)return;const t=this.shadowRoot?.querySelector('input[type="date"], input[type="time"], input[type="week"], input[type="month"], input[type="datetime-local"], input[type="file"]');t&&("file"===this.type?t.click():this.showPicker())}isFilterSearchInput(){return"search"===this.type}nativeAutocomplete(){return this.isFilterSearchInput()?"off":this.autocomplete}nativeTextInputType(t){return t&&this.showPassword||this.isFilterSearchInput()?"text":this.type}nativeInputMode(){return this.inputmode?this.inputmode:this.isFilterSearchInput()?"search":void 0}nativeEnterKeyHint(){return this.enterkeyhint?this.enterkeyhint:this.isFilterSearchInput()?"search":void 0}nativeInputRole(){return this.inputRole?this.inputRole:"search"===this.type?"searchbox":void 0}affixColorStyle(t){const e=String(t??"").trim();if(e)return{color:d(e)}}renderInputAffix(t){const e="prefix"===t?this.prefix:this.suffix;if(!String(e??"").length)return a;const s="prefix"===t?this.prefixColor:this.suffixColor,o=this.affixColorStyle(s);return i`<span
|
|
8
8
|
class="input-affix ${t}"
|
|
9
9
|
part="input-${t}"
|
|
10
|
-
style=${
|
|
10
|
+
style=${o?r(o):a}
|
|
11
11
|
>${e}</span
|
|
12
|
-
>`}render(){const t="file"===this.type,e="textarea"===this.type,r="number"===this.type,
|
|
12
|
+
>`}render(){const t="file"===this.type,e="textarea"===this.type,r="number"===this.type,o="password"===this.type,n=!t&&!e,l=!!this.querySelector('[slot="icon-left"]'),p=!!this.querySelector('[slot="icon-right"]');let d=null;"date"===this.type?d=i`<sky-icon icon="ion:calendar"></sky-icon>`:"time"===this.type?d=i`<sky-icon icon="ion:time"></sky-icon>`:"week"===this.type||"month"===this.type?d=i`<sky-icon icon="ion:calendar"></sky-icon>`:"datetime-local"===this.type&&(d=i`<sky-icon icon="ion:time"></sky-icon>`);const h=this.filePreview&&(l||p),u="left"===this.autofillIconSlot&&d,y="right"===this.autofillIconSlot&&d,v=()=>i`
|
|
13
13
|
<img
|
|
14
|
-
src=${
|
|
14
|
+
src=${s("string"==typeof this.filePreview?this.filePreview:void 0)}
|
|
15
15
|
alt="Preview"
|
|
16
16
|
style="width:100%;height:100%;object-fit:cover;border-radius:12px;"
|
|
17
17
|
/>
|
|
@@ -19,10 +19,10 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
19
19
|
<div
|
|
20
20
|
class="icon-slot left ${this.focused?"focused":""}"
|
|
21
21
|
part="icon-slot icon-slot-left"
|
|
22
|
-
?filled=${Boolean(
|
|
22
|
+
?filled=${Boolean(h&&l)||Boolean(u)||l}
|
|
23
23
|
@click=${()=>{(t||u)&&this.triggerNativeDropdown()}}
|
|
24
24
|
>
|
|
25
|
-
${
|
|
25
|
+
${h&&l?v():u?d:i`<slot name="icon-left"></slot>`}
|
|
26
26
|
</div>
|
|
27
27
|
`,m=()=>this.loading?i`<div
|
|
28
28
|
class="loading-indicator"
|
|
@@ -32,10 +32,10 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
32
32
|
<div
|
|
33
33
|
class="icon-slot right ${this.focused?"focused":""}"
|
|
34
34
|
part="icon-slot icon-slot-right"
|
|
35
|
-
?filled=${Boolean(
|
|
35
|
+
?filled=${Boolean(h&&p)||Boolean(y)||p}
|
|
36
36
|
@click=${()=>{(t||y)&&this.triggerNativeDropdown()}}
|
|
37
37
|
>
|
|
38
|
-
${
|
|
38
|
+
${h&&p?v():y?d:i`<slot name="icon-right"></slot>`}
|
|
39
39
|
</div>
|
|
40
40
|
`,g=()=>i`
|
|
41
41
|
<label
|
|
@@ -65,24 +65,24 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
65
65
|
.required=${this.required}
|
|
66
66
|
@keydown=${this.handleKeydown}
|
|
67
67
|
.dir=${this.dir}
|
|
68
|
-
name=${
|
|
68
|
+
name=${s(this.name||void 0)}
|
|
69
69
|
.autocomplete=${this.nativeAutocomplete()}
|
|
70
70
|
.autocapitalize=${this.autocapitalize}
|
|
71
71
|
spellcheck=${this.spellcheck}
|
|
72
72
|
?autofocus=${this.autofocus}
|
|
73
|
-
inputmode=${
|
|
74
|
-
enterkeyhint=${
|
|
75
|
-
list=${
|
|
76
|
-
capture=${
|
|
73
|
+
inputmode=${s(this.inputmode||void 0)}
|
|
74
|
+
enterkeyhint=${s(this.enterkeyhint)}
|
|
75
|
+
list=${s(this.list||void 0)}
|
|
76
|
+
capture=${s(this.capture?"environment":void 0)}
|
|
77
77
|
.aria-invalid=${String(this.isInvalid)}
|
|
78
78
|
.aria-required=${String(this.required)}
|
|
79
|
-
aria-label=${
|
|
80
|
-
aria-labelledby=${
|
|
81
|
-
aria-describedby=${
|
|
79
|
+
aria-label=${s(this.ariaLabel||void 0)}
|
|
80
|
+
aria-labelledby=${s(this.ariaLabelledby||void 0)}
|
|
81
|
+
aria-describedby=${s(this.describedById)}
|
|
82
82
|
/>
|
|
83
83
|
`,b=()=>i`
|
|
84
84
|
<textarea
|
|
85
|
-
.value=${
|
|
85
|
+
.value=${c(this.value)}
|
|
86
86
|
@input=${this.handleInput}
|
|
87
87
|
@focus=${this.handleFocus}
|
|
88
88
|
@blur=${this.handleBlur}
|
|
@@ -95,24 +95,24 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
95
95
|
style="width:100%;border:none;outline:none;"
|
|
96
96
|
.autocapitalize=${this.autocapitalize}
|
|
97
97
|
?spellcheck=${this.spellcheck}
|
|
98
|
-
name=${
|
|
98
|
+
name=${s(this.name||void 0)}
|
|
99
99
|
.autocomplete=${this.nativeAutocomplete()}
|
|
100
|
-
inputmode=${
|
|
101
|
-
enterkeyhint=${
|
|
102
|
-
minlength=${
|
|
103
|
-
maxlength=${
|
|
100
|
+
inputmode=${s(this.inputmode||void 0)}
|
|
101
|
+
enterkeyhint=${s(this.enterkeyhint)}
|
|
102
|
+
minlength=${s(this.minlength??void 0)}
|
|
103
|
+
maxlength=${s(this.maxlength??void 0)}
|
|
104
104
|
?autofocus=${this.autofocus}
|
|
105
105
|
.aria-invalid=${String(this.isInvalid)}
|
|
106
106
|
.aria-required=${String(this.required)}
|
|
107
|
-
aria-label=${
|
|
108
|
-
aria-labelledby=${
|
|
109
|
-
aria-describedby=${
|
|
110
|
-
role=${
|
|
107
|
+
aria-label=${s(this.ariaLabel||void 0)}
|
|
108
|
+
aria-labelledby=${s(this.ariaLabelledby||void 0)}
|
|
109
|
+
aria-describedby=${s(this.describedById)}
|
|
110
|
+
role=${s(this.nativeInputRole())}
|
|
111
111
|
></textarea>
|
|
112
112
|
`,k=()=>i`
|
|
113
113
|
<input
|
|
114
|
-
.type=${this.nativeTextInputType(
|
|
115
|
-
.value=${
|
|
114
|
+
.type=${this.nativeTextInputType(o)}
|
|
115
|
+
.value=${c(this.value)}
|
|
116
116
|
@input=${this.handleInput}
|
|
117
117
|
@focus=${this.handleFocus}
|
|
118
118
|
@blur=${this.handleBlur}
|
|
@@ -123,32 +123,32 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
123
123
|
.readOnly=${this.readonly||this.autofillGuardActive}
|
|
124
124
|
style="appearance:none;pointer-events:auto;"
|
|
125
125
|
placeholder=${this.placeholder}
|
|
126
|
-
name=${
|
|
126
|
+
name=${s(this.name||void 0)}
|
|
127
127
|
.autocomplete=${this.nativeAutocomplete()}
|
|
128
128
|
.autocapitalize=${this.autocapitalize}
|
|
129
129
|
spellcheck=${this.spellcheck}
|
|
130
|
-
inputmode=${
|
|
131
|
-
enterkeyhint=${
|
|
132
|
-
data-form-type=${this.isFilterSearchInput()?"other":
|
|
130
|
+
inputmode=${s(this.nativeInputMode())}
|
|
131
|
+
enterkeyhint=${s(this.nativeEnterKeyHint())}
|
|
132
|
+
data-form-type=${this.isFilterSearchInput()?"other":a}
|
|
133
133
|
?data-1p-ignore=${this.isFilterSearchInput()}
|
|
134
134
|
?data-lpignore=${this.isFilterSearchInput()}
|
|
135
|
-
list=${
|
|
136
|
-
pattern=${
|
|
137
|
-
minlength=${
|
|
138
|
-
maxlength=${
|
|
139
|
-
size=${
|
|
140
|
-
step=${
|
|
141
|
-
min=${
|
|
142
|
-
max=${
|
|
135
|
+
list=${s(this.list||void 0)}
|
|
136
|
+
pattern=${s(this.pattern||void 0)}
|
|
137
|
+
minlength=${s(this.minlength??void 0)}
|
|
138
|
+
maxlength=${s(this.maxlength??void 0)}
|
|
139
|
+
size=${s(this.size??void 0)}
|
|
140
|
+
step=${s(null!==this.step?Number(this.step):void 0)}
|
|
141
|
+
min=${s(this.min??void 0)}
|
|
142
|
+
max=${s(this.max??void 0)}
|
|
143
143
|
?autofocus=${this.autofocus}
|
|
144
144
|
.aria-invalid=${String(this.isInvalid)}
|
|
145
145
|
.aria-required=${String(this.required)}
|
|
146
|
-
aria-label=${
|
|
147
|
-
aria-labelledby=${
|
|
148
|
-
aria-describedby=${
|
|
149
|
-
role=${
|
|
146
|
+
aria-label=${s(this.ariaLabel||void 0)}
|
|
147
|
+
aria-labelledby=${s(this.ariaLabelledby||void 0)}
|
|
148
|
+
aria-describedby=${s(this.describedById)}
|
|
149
|
+
role=${s(this.nativeInputRole())}
|
|
150
150
|
/>
|
|
151
|
-
`,
|
|
151
|
+
`,w=()=>r&&this.showNumberButtons?i`
|
|
152
152
|
<div class="number-btn">
|
|
153
153
|
<button
|
|
154
154
|
class="decrement-btn"
|
|
@@ -173,7 +173,7 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
173
173
|
<sky-icon icon="ion:add"></sky-icon>
|
|
174
174
|
</button>
|
|
175
175
|
</div>
|
|
176
|
-
`:null,
|
|
176
|
+
`:null,x=()=>o&&this.showPasswordToggle?i`
|
|
177
177
|
<sky-icon
|
|
178
178
|
class="toggle-password"
|
|
179
179
|
part="toggle-password"
|
|
@@ -191,17 +191,17 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
191
191
|
icon="ion:close"
|
|
192
192
|
></sky-icon>
|
|
193
193
|
`:null,S=()=>t?g():e?b():k(),F="fieldset"===this.variant,I="inside"===this.variant,z=this.label?F?i`<legend class="label" part="label">${this.label}</legend>`:i`<div class="label" part="label">${this.label}</div>`:null,E=i`
|
|
194
|
-
${
|
|
194
|
+
${n?this.renderInputAffix("prefix"):a}
|
|
195
195
|
${S()}
|
|
196
|
-
${
|
|
197
|
-
${
|
|
196
|
+
${n?this.renderInputAffix("suffix"):a}
|
|
197
|
+
${w()} ${x()}
|
|
198
198
|
${$()}
|
|
199
199
|
`,C=i`
|
|
200
200
|
${f()}
|
|
201
|
-
${
|
|
201
|
+
${n?this.renderInputAffix("prefix"):a}
|
|
202
202
|
${S()}
|
|
203
|
-
${
|
|
204
|
-
${
|
|
203
|
+
${n?this.renderInputAffix("suffix"):a}
|
|
204
|
+
${w()} ${x()}
|
|
205
205
|
${$()} ${m()}
|
|
206
206
|
`,A=i`
|
|
207
207
|
${f()}
|
|
@@ -216,7 +216,7 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
216
216
|
@click=${this.handleWrapperClick}
|
|
217
217
|
part="input-container"
|
|
218
218
|
>
|
|
219
|
-
${F||I?
|
|
219
|
+
${F||I?a:z}
|
|
220
220
|
${F?i`<fieldset
|
|
221
221
|
class="input-wrapper"
|
|
222
222
|
part="input-wrapper"
|
|
@@ -226,10 +226,10 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
226
226
|
${z}
|
|
227
227
|
<div class="input-fieldset-body">
|
|
228
228
|
${f()}
|
|
229
|
-
${
|
|
229
|
+
${n?this.renderInputAffix("prefix"):a}
|
|
230
230
|
${S()}
|
|
231
|
-
${
|
|
232
|
-
${
|
|
231
|
+
${n?this.renderInputAffix("suffix"):a}
|
|
232
|
+
${w()} ${x()}
|
|
233
233
|
${$()} ${m()}
|
|
234
234
|
</div>
|
|
235
235
|
</fieldset>`:i`<div
|
|
@@ -251,7 +251,7 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
251
251
|
</div>
|
|
252
252
|
`:null)()} ${this.renderValidationErrors()}
|
|
253
253
|
</div>
|
|
254
|
-
`}};
|
|
254
|
+
`}};g.dependencies={"sky-icon":y},g.styles=t`
|
|
255
255
|
:host {
|
|
256
256
|
display: block;
|
|
257
257
|
font-family: var(--sky-font);
|
|
@@ -270,36 +270,36 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
270
270
|
--sky-input-icon-width: 2rem;
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
:host([compact]) {
|
|
273
|
+
:host([data-sky-compact]) {
|
|
274
274
|
--sky-input-pad-x: var(--sky-space-2, 8px);
|
|
275
275
|
--sky-input-pad-x-sm: var(--sky-space-1, 4px);
|
|
276
276
|
--sky-input-icon-width: 1.75rem;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
/* Compact typography + denser chrome for every variant */
|
|
280
|
-
:host([compact]) .input-container > .label {
|
|
280
|
+
:host([data-sky-compact]) .input-container > .label {
|
|
281
281
|
font-size: var(--sky-font-size-xs);
|
|
282
282
|
margin-bottom: var(--sky-space-1, 4px);
|
|
283
283
|
line-height: 1.2;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
:host([compact]) input,
|
|
287
|
-
:host([compact]) textarea,
|
|
288
|
-
:host([compact]) .input-affix,
|
|
289
|
-
:host([compact]) .custom-file-label__text {
|
|
286
|
+
:host([data-sky-compact]) input,
|
|
287
|
+
:host([data-sky-compact]) textarea,
|
|
288
|
+
:host([data-sky-compact]) .input-affix,
|
|
289
|
+
:host([data-sky-compact]) .custom-file-label__text {
|
|
290
290
|
font-size: var(--sky-font-size-sm);
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
:host([compact]) .icon-slot {
|
|
293
|
+
:host([data-sky-compact]) .icon-slot {
|
|
294
294
|
font-size: var(--sky-font-size-lg);
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
:host([compact]) .toggle-password,
|
|
298
|
-
:host([compact]) .clear-button {
|
|
297
|
+
:host([data-sky-compact]) .toggle-password,
|
|
298
|
+
:host([data-sky-compact]) .clear-button {
|
|
299
299
|
font-size: var(--sky-font-size-md);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
:host([compact]) .custom-file-label {
|
|
302
|
+
:host([data-sky-compact]) .custom-file-label {
|
|
303
303
|
border-radius: var(--sky-radius-primary);
|
|
304
304
|
}
|
|
305
305
|
|
|
@@ -310,23 +310,23 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
310
310
|
pointer-events: none;
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
:host([variant="highlight"]){
|
|
313
|
+
:host([data-sky-variant="highlight"]){
|
|
314
314
|
.label{
|
|
315
315
|
color: var(--sky-input-color);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/* Fieldset / legend: native fieldset+legend; wrapper keeps solid fill */
|
|
320
|
-
:host([variant="fieldset"]) {
|
|
320
|
+
:host([data-sky-variant="fieldset"]) {
|
|
321
321
|
overflow: visible;
|
|
322
322
|
padding-block-start: 0;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
:host([variant="fieldset"]) .input-container {
|
|
325
|
+
:host([data-sky-variant="fieldset"]) .input-container {
|
|
326
326
|
overflow: visible;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
:host([variant="fieldset"]) fieldset.input-wrapper {
|
|
329
|
+
:host([data-sky-variant="fieldset"]) fieldset.input-wrapper {
|
|
330
330
|
display: block;
|
|
331
331
|
height: auto;
|
|
332
332
|
margin: 0;
|
|
@@ -338,11 +338,11 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
338
338
|
box-shadow: none;
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
:host([variant="fieldset"]) fieldset.input-wrapper[compact] {
|
|
341
|
+
:host([data-sky-variant="fieldset"]) fieldset.input-wrapper[compact] {
|
|
342
342
|
height: auto;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
:host([variant="fieldset"]) .input-fieldset-body {
|
|
345
|
+
:host([data-sky-variant="fieldset"]) .input-fieldset-body {
|
|
346
346
|
display: flex;
|
|
347
347
|
width: 100%;
|
|
348
348
|
align-items: center;
|
|
@@ -360,7 +360,7 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
360
360
|
overflow: hidden;
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
:host([variant="fieldset"]) fieldset.input-wrapper[compact] .input-fieldset-body {
|
|
363
|
+
:host([data-sky-variant="fieldset"]) fieldset.input-wrapper[compact] .input-fieldset-body {
|
|
364
364
|
height: calc(
|
|
365
365
|
var(--sky-input-height-compact) - 2 * var(--sky-input-border-width)
|
|
366
366
|
);
|
|
@@ -369,17 +369,17 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
369
369
|
);
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
:host([variant="fieldset"]) fieldset.input-wrapper:has(textarea) {
|
|
372
|
+
:host([data-sky-variant="fieldset"]) fieldset.input-wrapper:has(textarea) {
|
|
373
373
|
height: auto;
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
-
:host([variant="fieldset"]) fieldset.input-wrapper:has(textarea) .input-fieldset-body {
|
|
376
|
+
:host([data-sky-variant="fieldset"]) fieldset.input-wrapper:has(textarea) .input-fieldset-body {
|
|
377
377
|
height: calc((var(--rows)) * 23px);
|
|
378
378
|
min-height: calc((var(--rows)) * 23px);
|
|
379
379
|
align-items: flex-start;
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
:host([variant="fieldset"]) legend.label {
|
|
382
|
+
:host([data-sky-variant="fieldset"]) legend.label {
|
|
383
383
|
float: unset;
|
|
384
384
|
width: auto;
|
|
385
385
|
max-width: calc(100% - 2 * var(--sky-input-pad-x));
|
|
@@ -400,40 +400,40 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
400
400
|
pointer-events: none;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
|
-
:host([variant="fieldset"]) .input-container:focus-within legend.label {
|
|
403
|
+
:host([data-sky-variant="fieldset"]) .input-container:focus-within legend.label {
|
|
404
404
|
color: var(--sky-input-color);
|
|
405
405
|
font-size: var(--sky-font-size-xs);
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
/* Focus via real border — ::after would paint over the legend gap */
|
|
409
|
-
:host([variant="fieldset"]) .input-wrapper::after {
|
|
409
|
+
:host([data-sky-variant="fieldset"]) .input-wrapper::after {
|
|
410
410
|
content: none;
|
|
411
411
|
display: none;
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
:host([variant="fieldset"]) .input-wrapper:has(input:focus),
|
|
415
|
-
:host([variant="fieldset"]) .input-wrapper:has(input:focus-visible),
|
|
416
|
-
:host([variant="fieldset"]) .input-wrapper:has(textarea:focus),
|
|
417
|
-
:host([variant="fieldset"]) .input-wrapper:has(textarea:focus-visible) {
|
|
414
|
+
:host([data-sky-variant="fieldset"]) .input-wrapper:has(input:focus),
|
|
415
|
+
:host([data-sky-variant="fieldset"]) .input-wrapper:has(input:focus-visible),
|
|
416
|
+
:host([data-sky-variant="fieldset"]) .input-wrapper:has(textarea:focus),
|
|
417
|
+
:host([data-sky-variant="fieldset"]) .input-wrapper:has(textarea:focus-visible) {
|
|
418
418
|
border-color: var(--sky-input-color);
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
-
:host([variant="fieldset"][validationActive]:invalid) .input-wrapper {
|
|
421
|
+
:host([data-sky-variant="fieldset"][validationActive]:invalid) .input-wrapper {
|
|
422
422
|
border-color: var(--sky-danger-primary);
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
:host([variant="fieldset"][validationActive]:invalid) legend.label {
|
|
425
|
+
:host([data-sky-variant="fieldset"][validationActive]:invalid) legend.label {
|
|
426
426
|
color: var(--sky-danger-primary);
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
:host([variant="fieldset"][compact]) legend.label,
|
|
430
|
-
:host([variant="fieldset"][compact]) .input-container:focus-within legend.label {
|
|
429
|
+
:host([data-sky-variant="fieldset"][compact]) legend.label,
|
|
430
|
+
:host([data-sky-variant="fieldset"][compact]) .input-container:focus-within legend.label {
|
|
431
431
|
font-size: var(--sky-font-size-xs);
|
|
432
432
|
line-height: 1.4;
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
/* Inside: label lives in the wrapper above the value row */
|
|
436
|
-
:host([variant="inside"]) {
|
|
436
|
+
:host([data-sky-variant="inside"]) {
|
|
437
437
|
--sky-input-height-inside: 44px;
|
|
438
438
|
/* Two lines (label + value) need a bit more than single-line compact */
|
|
439
439
|
--sky-input-height-inside-compact: 40px;
|
|
@@ -441,20 +441,20 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
441
441
|
--sky-input-inside-value-min: 1.375rem;
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
:host([variant="inside"]) .input-wrapper {
|
|
444
|
+
:host([data-sky-variant="inside"]) .input-wrapper {
|
|
445
445
|
height: auto;
|
|
446
446
|
min-height: var(--sky-input-height-inside);
|
|
447
447
|
align-items: center;
|
|
448
448
|
padding-block: var(--sky-input-pad-y-sm, 0px);
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
:host([variant="inside"]) .input-wrapper[compact] {
|
|
451
|
+
:host([data-sky-variant="inside"]) .input-wrapper[compact] {
|
|
452
452
|
height: auto;
|
|
453
453
|
min-height: var(--sky-input-height-inside-compact);
|
|
454
454
|
padding-block: var(--sky-input-pad-y-sm, 0px);
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
:host([variant="inside"]) .input-inside-main {
|
|
457
|
+
:host([data-sky-variant="inside"]) .input-inside-main {
|
|
458
458
|
flex: 1 1 auto;
|
|
459
459
|
min-width: 0;
|
|
460
460
|
display: flex;
|
|
@@ -464,7 +464,7 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
464
464
|
padding-block: var(--sky-input-inside-label-block);
|
|
465
465
|
}
|
|
466
466
|
|
|
467
|
-
:host([variant="inside"]) .input-inside-main > .label {
|
|
467
|
+
:host([data-sky-variant="inside"]) .input-inside-main > .label {
|
|
468
468
|
margin: 0;
|
|
469
469
|
padding-inline: var(--sky-input-pad-x);
|
|
470
470
|
font-size: var(--sky-font-size-xs);
|
|
@@ -477,32 +477,32 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
477
477
|
flex-shrink: 0;
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
-
:host([variant="inside"][compact]) .input-inside-main > .label {
|
|
480
|
+
:host([data-sky-variant="inside"][compact]) .input-inside-main > .label {
|
|
481
481
|
font-size: 0.6875rem; /* ~11px — denser than xs for two-line compact */
|
|
482
482
|
line-height: 1.3;
|
|
483
483
|
min-height: calc(0.6875rem * 1.3);
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
:host([variant="inside"][compact]) .input-inside-row input,
|
|
487
|
-
:host([variant="inside"][compact]) .input-inside-row textarea {
|
|
486
|
+
:host([data-sky-variant="inside"][compact]) .input-inside-row input,
|
|
487
|
+
:host([data-sky-variant="inside"][compact]) .input-inside-row textarea {
|
|
488
488
|
font-size: var(--sky-font-size-sm);
|
|
489
489
|
line-height: 1.15;
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
-
:host([variant="inside"]) .input-container:focus-within .input-inside-main > .label {
|
|
492
|
+
:host([data-sky-variant="inside"]) .input-container:focus-within .input-inside-main > .label {
|
|
493
493
|
color: var(--sky-input-color);
|
|
494
494
|
font-size: var(--sky-font-size-xs);
|
|
495
495
|
}
|
|
496
496
|
|
|
497
|
-
:host([variant="inside"][compact]) .input-container:focus-within .input-inside-main > .label {
|
|
497
|
+
:host([data-sky-variant="inside"][compact]) .input-container:focus-within .input-inside-main > .label {
|
|
498
498
|
font-size: 0.6875rem;
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
-
:host([variant="inside"][validationActive]:invalid) .input-inside-main > .label {
|
|
501
|
+
:host([data-sky-variant="inside"][validationActive]:invalid) .input-inside-main > .label {
|
|
502
502
|
color: var(--sky-danger-primary);
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
:host([variant="inside"]) .input-inside-row {
|
|
505
|
+
:host([data-sky-variant="inside"]) .input-inside-row {
|
|
506
506
|
display: flex;
|
|
507
507
|
align-items: center;
|
|
508
508
|
min-width: 0;
|
|
@@ -510,27 +510,27 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
510
510
|
min-height: var(--sky-input-inside-value-min);
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
-
:host([variant="inside"]) .input-wrapper:has(.icon-slot[filled].left) .input-inside-main > .label,
|
|
514
|
-
:host([variant="inside"]) .input-wrapper:has(.input-affix.prefix) .input-inside-main > .label {
|
|
513
|
+
:host([data-sky-variant="inside"]) .input-wrapper:has(.icon-slot[filled].left) .input-inside-main > .label,
|
|
514
|
+
:host([data-sky-variant="inside"]) .input-wrapper:has(.input-affix.prefix) .input-inside-main > .label {
|
|
515
515
|
padding-inline-start: 0;
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
-
:host([variant="inside"]) .input-inside-row input,
|
|
519
|
-
:host([variant="inside"]) .input-inside-row textarea {
|
|
518
|
+
:host([data-sky-variant="inside"]) .input-inside-row input,
|
|
519
|
+
:host([data-sky-variant="inside"]) .input-inside-row textarea {
|
|
520
520
|
padding-block: 0;
|
|
521
521
|
height: auto;
|
|
522
522
|
min-height: 0;
|
|
523
523
|
line-height: 1.2;
|
|
524
524
|
}
|
|
525
525
|
|
|
526
|
-
:host([variant="inside"]) .input-wrapper:has(textarea) {
|
|
526
|
+
:host([data-sky-variant="inside"]) .input-wrapper:has(textarea) {
|
|
527
527
|
height: auto;
|
|
528
528
|
min-height: var(--sky-input-height-inside);
|
|
529
529
|
align-items: flex-start;
|
|
530
530
|
}
|
|
531
531
|
|
|
532
|
-
:host([variant="inside"]) .icon-slot,
|
|
533
|
-
:host([variant="inside"]) .icon-slot[filled] {
|
|
532
|
+
:host([data-sky-variant="inside"]) .icon-slot,
|
|
533
|
+
:host([data-sky-variant="inside"]) .icon-slot[filled] {
|
|
534
534
|
align-self: center;
|
|
535
535
|
height: auto;
|
|
536
536
|
max-height: none;
|
|
@@ -558,7 +558,7 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
558
558
|
transition: color var(--sky-transition-normal, 200ms ease);
|
|
559
559
|
}
|
|
560
560
|
|
|
561
|
-
:host([compact]) .input-container:focus-within > .label {
|
|
561
|
+
:host([data-sky-compact]) .input-container:focus-within > .label {
|
|
562
562
|
font-size: var(--sky-font-size-xs);
|
|
563
563
|
}
|
|
564
564
|
|
|
@@ -1090,5 +1090,5 @@ import{css as t,LitElement as e,html as i,nothing as s}from"lit";import{ifDefine
|
|
|
1090
1090
|
transition: none;
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
|
-
`,
|
|
1093
|
+
`,g.shadowRootOptions={...e.shadowRootOptions,delegatesFocus:!0},m([o({type:String})],g.prototype,"value",2),m([o({type:String})],g.prototype,"placeholder",2),m([o({type:String})],g.prototype,"label",2),m([o({type:String})],g.prototype,"type",2),m([o({type:String})],g.prototype,"suffix",2),m([o({type:String})],g.prototype,"prefix",2),m([o({type:String})],g.prototype,"prefixColor",2),m([o({type:String})],g.prototype,"suffixColor",2),m([o({type:String})],g.prototype,"color",2),m([o({type:Array})],g.prototype,"validations",1),m([o({type:Boolean,reflect:!0})],g.prototype,"compact",2),m([o({type:Boolean,reflect:!0})],g.prototype,"loading",2),m([o({type:Boolean})],g.prototype,"showErrors",2),m([o({type:Boolean,reflect:!0})],g.prototype,"clearable",2),m([o({type:String})],g.prototype,"errorDisplayMode",2),m([o({type:Boolean,reflect:!0})],g.prototype,"required",2),m([o({type:String})],g.prototype,"step",2),m([o({type:String})],g.prototype,"min",2),m([o({type:String})],g.prototype,"max",2),m([o({type:String})],g.prototype,"autocapitalize",2),m([o({type:String})],g.prototype,"autocomplete",2),m([o({type:Boolean})],g.prototype,"spellcheck",2),m([o({type:String})],g.prototype,"dir",2),m([o({type:Number})],g.prototype,"rows",2),m([o({type:String})],g.prototype,"resizable",2),m([o({type:String})],g.prototype,"accept",2),m([o({type:Boolean})],g.prototype,"multiple",2),m([o({type:String})],g.prototype,"inputmode",2),m([o({type:String})],g.prototype,"enterkeyhint",2),m([o({type:String})],g.prototype,"pattern",2),m([o({type:Number})],g.prototype,"minlength",2),m([o({type:Number})],g.prototype,"maxlength",2),m([o({type:String})],g.prototype,"list",2),m([o({type:Number})],g.prototype,"size",2),m([o({type:Number})],g.prototype,"cols",2),m([o({type:Boolean})],g.prototype,"autofocus",2),m([o({type:Boolean})],g.prototype,"capture",2),m([o({type:String})],g.prototype,"inputRole",2),m([o({type:String})],g.prototype,"ariaLabel",2),m([o({type:String})],g.prototype,"ariaLabelledby",2),m([o({type:String})],g.prototype,"ariaDescribedby",2),m([o({type:Boolean})],g.prototype,"showNumberButtons",2),m([o({type:Boolean})],g.prototype,"showPasswordToggle",2),m([o({type:String})],g.prototype,"passwordVisibleIcon",2),m([o({type:String})],g.prototype,"passwordHiddenIcon",2),m([o({type:Boolean,reflect:!0})],g.prototype,"validationActive",2),m([o({type:Boolean,reflect:!0})],g.prototype,"invalid",2),m([o({type:String,reflect:!0})],g.prototype,"variant",2),m([o({type:String,reflect:!0})],g.prototype,"preset",2),m([n()],g.prototype,"selectedFileName",2),m([n()],g.prototype,"selectedFiles",2),m([n()],g.prototype,"focused",2),m([n()],g.prototype,"validationStatus",2),m([n()],g.prototype,"validationErrors",2),m([n()],g.prototype,"typingStarted",2),m([n()],g.prototype,"autofillIconSlot",2),m([n()],g.prototype,"autofillGuardActive",2),m([n()],g.prototype,"showPassword",2),m([n()],g.prototype,"totalFileSize",2),m([n()],g.prototype,"selectedFileCount",2),m([n()],g.prototype,"filePreview",2),m([l(".input-wrapper")],g.prototype,"inputWrapperEl",2),m([l("input, textarea")],g.prototype,"nativeInputEl",2),g=m([p("sky-input")],g);export{g as SkyInput};
|
|
1094
1094
|
//# sourceMappingURL=sky-input.js.map
|