@aurodesignsystem-dev/auro-formkit 0.0.0-pr593.0
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/CHANGELOG.md +5 -0
- package/LICENSE +201 -0
- package/NOTICE +2 -0
- package/README.md +314 -0
- package/components/bibtemplate/dist/auro-bibtemplate.d.ts +39 -0
- package/components/bibtemplate/dist/headerVersion.d.ts +2 -0
- package/components/bibtemplate/dist/iconVersion.d.ts +2 -0
- package/components/bibtemplate/dist/index.d.ts +2 -0
- package/components/bibtemplate/dist/index.js +709 -0
- package/components/bibtemplate/dist/registered.js +709 -0
- package/components/bibtemplate/dist/styles/color-css.d.ts +2 -0
- package/components/bibtemplate/dist/styles/style-css.d.ts +2 -0
- package/components/bibtemplate/dist/styles/tokens-css.d.ts +2 -0
- package/components/checkbox/README.md +142 -0
- package/components/checkbox/demo/api.html +55 -0
- package/components/checkbox/demo/api.js +17 -0
- package/components/checkbox/demo/api.md +401 -0
- package/components/checkbox/demo/api.min.js +1833 -0
- package/components/checkbox/demo/index.html +51 -0
- package/components/checkbox/demo/index.js +8 -0
- package/components/checkbox/demo/index.md +327 -0
- package/components/checkbox/demo/index.min.js +1808 -0
- package/components/checkbox/demo/readme.html +50 -0
- package/components/checkbox/demo/readme.md +142 -0
- package/components/checkbox/dist/auro-checkbox-group.d.ts +166 -0
- package/components/checkbox/dist/auro-checkbox.d.ts +129 -0
- package/components/checkbox/dist/helptextVersion.d.ts +2 -0
- package/components/checkbox/dist/index.d.ts +3 -0
- package/components/checkbox/dist/index.js +1757 -0
- package/components/checkbox/dist/registered.js +1758 -0
- package/components/checkbox/dist/styles/auro-checkbox-css.d.ts +2 -0
- package/components/checkbox/dist/styles/auro-checkbox-group-css.d.ts +2 -0
- package/components/checkbox/dist/styles/color-css.d.ts +2 -0
- package/components/checkbox/dist/styles/colorGroup-css.d.ts +2 -0
- package/components/checkbox/dist/styles/tokens-css.d.ts +2 -0
- package/components/combobox/README.md +152 -0
- package/components/combobox/demo/api.html +57 -0
- package/components/combobox/demo/api.js +36 -0
- package/components/combobox/demo/api.md +1209 -0
- package/components/combobox/demo/api.min.js +15117 -0
- package/components/combobox/demo/index.html +56 -0
- package/components/combobox/demo/index.js +26 -0
- package/components/combobox/demo/index.md +621 -0
- package/components/combobox/demo/index.min.js +14971 -0
- package/components/combobox/demo/readme.html +50 -0
- package/components/combobox/demo/readme.md +152 -0
- package/components/combobox/dist/auro-combobox.d.ts +384 -0
- package/components/combobox/dist/bibtemplateVersion.d.ts +2 -0
- package/components/combobox/dist/dropdownVersion.d.ts +2 -0
- package/components/combobox/dist/index.d.ts +2 -0
- package/components/combobox/dist/index.js +13554 -0
- package/components/combobox/dist/inputVersion.d.ts +2 -0
- package/components/combobox/dist/registered.js +13556 -0
- package/components/combobox/dist/styles/style-css.d.ts +2 -0
- package/components/counter/README.md +146 -0
- package/components/counter/demo/api.html +54 -0
- package/components/counter/demo/api.js +20 -0
- package/components/counter/demo/api.md +584 -0
- package/components/counter/demo/api.min.js +7111 -0
- package/components/counter/demo/index.html +54 -0
- package/components/counter/demo/index.js +21 -0
- package/components/counter/demo/index.md +244 -0
- package/components/counter/demo/index.min.js +7075 -0
- package/components/counter/demo/readme.html +50 -0
- package/components/counter/demo/readme.md +146 -0
- package/components/counter/dist/auro-counter-button.d.ts +12 -0
- package/components/counter/dist/auro-counter-group.d.ts +235 -0
- package/components/counter/dist/auro-counter-wrapper.d.ts +22 -0
- package/components/counter/dist/auro-counter.d.ts +97 -0
- package/components/counter/dist/bibtemplateVersion.d.ts +2 -0
- package/components/counter/dist/dropdownVersion.d.ts +2 -0
- package/components/counter/dist/iconVersion.d.ts +2 -0
- package/components/counter/dist/index.d.ts +3 -0
- package/components/counter/dist/index.js +7018 -0
- package/components/counter/dist/registered.js +7019 -0
- package/components/counter/dist/styles/color-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-button-color-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-button-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-group-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-wrapper-color-css.d.ts +2 -0
- package/components/counter/dist/styles/counter-wrapper-css.d.ts +2 -0
- package/components/counter/dist/styles/style-css.d.ts +2 -0
- package/components/counter/dist/styles/tokens-css.d.ts +2 -0
- package/components/datepicker/README.md +140 -0
- package/components/datepicker/demo/api.html +57 -0
- package/components/datepicker/demo/api.js +35 -0
- package/components/datepicker/demo/api.md +1479 -0
- package/components/datepicker/demo/api.min.js +24534 -0
- package/components/datepicker/demo/index.html +56 -0
- package/components/datepicker/demo/index.js +19 -0
- package/components/datepicker/demo/index.md +112 -0
- package/components/datepicker/demo/index.min.js +24255 -0
- package/components/datepicker/demo/readme.html +50 -0
- package/components/datepicker/demo/readme.md +140 -0
- package/components/datepicker/dist/auro-calendar-cell.d.ts +163 -0
- package/components/datepicker/dist/auro-calendar-month.d.ts +20 -0
- package/components/datepicker/dist/auro-calendar.d.ts +133 -0
- package/components/datepicker/dist/auro-datepicker.d.ts +466 -0
- package/components/datepicker/dist/bibtemplateVersion.d.ts +2 -0
- package/components/datepicker/dist/buttonVersion.d.ts +2 -0
- package/components/datepicker/dist/dropdownVersion.d.ts +2 -0
- package/components/datepicker/dist/index.d.ts +2 -0
- package/components/datepicker/dist/index.js +24185 -0
- package/components/datepicker/dist/inputVersion.d.ts +2 -0
- package/components/datepicker/dist/popoverVersion.d.ts +2 -0
- package/components/datepicker/dist/registered.js +24185 -0
- package/components/datepicker/dist/styles/color-calendar-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-cell-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-css.d.ts +2 -0
- package/components/datepicker/dist/styles/color-month-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-auro-calendar-cell-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-auro-calendar-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-auro-calendar-month-css.d.ts +2 -0
- package/components/datepicker/dist/styles/style-css.d.ts +2 -0
- package/components/datepicker/dist/styles/tokens-css.d.ts +2 -0
- package/components/datepicker/dist/utilities.d.ts +78 -0
- package/components/datepicker/dist/utilitiesCalendar.d.ts +38 -0
- package/components/datepicker/dist/utilitiesCalendarRender.d.ts +50 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/day.d.ts +5 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker-calendar.d.ts +60 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker-cell.d.ts +1 -0
- package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker.d.ts +57 -0
- package/components/dropdown/README.md +144 -0
- package/components/dropdown/demo/api.html +57 -0
- package/components/dropdown/demo/api.js +21 -0
- package/components/dropdown/demo/api.md +1434 -0
- package/components/dropdown/demo/api.min.js +3826 -0
- package/components/dropdown/demo/index.html +55 -0
- package/components/dropdown/demo/index.js +19 -0
- package/components/dropdown/demo/index.md +510 -0
- package/components/dropdown/demo/index.min.js +3789 -0
- package/components/dropdown/demo/readme.html +50 -0
- package/components/dropdown/demo/readme.md +144 -0
- package/components/dropdown/dist/auro-dropdown.d.ts +406 -0
- package/components/dropdown/dist/auro-dropdownBib.d.ts +46 -0
- package/components/dropdown/dist/dropdownVersion.d.ts +2 -0
- package/components/dropdown/dist/helptextVersion.d.ts +2 -0
- package/components/dropdown/dist/iconVersion.d.ts +2 -0
- package/components/dropdown/dist/index.d.ts +2 -0
- package/components/dropdown/dist/index.js +3734 -0
- package/components/dropdown/dist/registered.js +3734 -0
- package/components/dropdown/dist/styles/bibColors-css.d.ts +2 -0
- package/components/dropdown/dist/styles/bibStyles-css.d.ts +2 -0
- package/components/dropdown/dist/styles/color-css.d.ts +2 -0
- package/components/dropdown/dist/styles/style-css.d.ts +2 -0
- package/components/dropdown/dist/styles/tokens-css.d.ts +2 -0
- package/components/form/README.md +142 -0
- package/components/form/demo/api.html +49 -0
- package/components/form/demo/api.js +3 -0
- package/components/form/demo/api.md +51 -0
- package/components/form/demo/api.min.js +638 -0
- package/components/form/demo/autocomplete.html +15 -0
- package/components/form/demo/index.html +50 -0
- package/components/form/demo/index.js +4 -0
- package/components/form/demo/index.md +403 -0
- package/components/form/demo/index.min.js +639 -0
- package/components/form/demo/readme.html +50 -0
- package/components/form/demo/readme.md +142 -0
- package/components/form/demo/registerDemoDeps.js +23 -0
- package/components/form/demo/working.html +118 -0
- package/components/form/dist/auro-form.d.ts +223 -0
- package/components/form/dist/index.d.ts +2 -0
- package/components/form/dist/index.js +614 -0
- package/components/form/dist/registered.d.ts +1 -0
- package/components/form/dist/registered.js +614 -0
- package/components/form/dist/styles/style-css.d.ts +2 -0
- package/components/helptext/dist/auro-helptext.d.ts +61 -0
- package/components/helptext/dist/index.d.ts +2 -0
- package/components/helptext/dist/index.js +209 -0
- package/components/helptext/dist/registered.js +209 -0
- package/components/helptext/dist/styles/color-css.d.ts +2 -0
- package/components/helptext/dist/styles/style-css.d.ts +2 -0
- package/components/helptext/dist/styles/tokens-css.d.ts +2 -0
- package/components/input/README.md +135 -0
- package/components/input/demo/api.html +42 -0
- package/components/input/demo/api.js +29 -0
- package/components/input/demo/api.md +1252 -0
- package/components/input/demo/api.min.js +7238 -0
- package/components/input/demo/index.html +43 -0
- package/components/input/demo/index.js +20 -0
- package/components/input/demo/index.md +202 -0
- package/components/input/demo/index.min.js +7157 -0
- package/components/input/demo/readme.html +50 -0
- package/components/input/demo/readme.md +135 -0
- package/components/input/dist/auro-input.d.ts +31 -0
- package/components/input/dist/base-input.d.ts +512 -0
- package/components/input/dist/buttonVersion.d.ts +2 -0
- package/components/input/dist/helptextVersion.d.ts +2 -0
- package/components/input/dist/i18n.d.ts +18 -0
- package/components/input/dist/iconVersion.d.ts +2 -0
- package/components/input/dist/index.d.ts +2 -0
- package/components/input/dist/index.js +7063 -0
- package/components/input/dist/registered.js +7063 -0
- package/components/input/dist/styles/borders-css.d.ts +2 -0
- package/components/input/dist/styles/color-css.d.ts +2 -0
- package/components/input/dist/styles/input-css.d.ts +2 -0
- package/components/input/dist/styles/label-css.d.ts +2 -0
- package/components/input/dist/styles/mixins-css.d.ts +2 -0
- package/components/input/dist/styles/notificationIcons-css.d.ts +2 -0
- package/components/input/dist/styles/style-css.d.ts +2 -0
- package/components/input/dist/styles/tokens-css.d.ts +2 -0
- package/components/input/dist/utilities.d.ts +25 -0
- package/components/menu/README.md +145 -0
- package/components/menu/demo/api.html +55 -0
- package/components/menu/demo/api.js +27 -0
- package/components/menu/demo/api.md +954 -0
- package/components/menu/demo/api.min.js +1538 -0
- package/components/menu/demo/index.html +52 -0
- package/components/menu/demo/index.js +28 -0
- package/components/menu/demo/index.md +61 -0
- package/components/menu/demo/index.min.js +1484 -0
- package/components/menu/demo/readme.html +50 -0
- package/components/menu/demo/readme.md +145 -0
- package/components/menu/dist/auro-menu-utils.d.ts +42 -0
- package/components/menu/dist/auro-menu.d.ts +205 -0
- package/components/menu/dist/auro-menuoption.d.ts +63 -0
- package/components/menu/dist/dropdownVersion.d.ts +2 -0
- package/components/menu/dist/iconVersion.d.ts +2 -0
- package/components/menu/dist/index.d.ts +4 -0
- package/components/menu/dist/index.js +1426 -0
- package/components/menu/dist/registered.js +1427 -0
- package/components/menu/dist/styles/color-menu-css.d.ts +2 -0
- package/components/menu/dist/styles/color-menuoption-css.d.ts +2 -0
- package/components/menu/dist/styles/style-menu-css.d.ts +2 -0
- package/components/menu/dist/styles/style-menuoption-css.d.ts +2 -0
- package/components/menu/dist/styles/tokens-css.d.ts +2 -0
- package/components/radio/README.md +137 -0
- package/components/radio/demo/api.html +53 -0
- package/components/radio/demo/api.js +19 -0
- package/components/radio/demo/api.md +562 -0
- package/components/radio/demo/api.min.js +1944 -0
- package/components/radio/demo/index.html +50 -0
- package/components/radio/demo/index.js +8 -0
- package/components/radio/demo/index.md +150 -0
- package/components/radio/demo/index.min.js +1901 -0
- package/components/radio/demo/readme.html +50 -0
- package/components/radio/demo/readme.md +137 -0
- package/components/radio/dist/auro-radio-group.d.ts +194 -0
- package/components/radio/dist/auro-radio.d.ts +144 -0
- package/components/radio/dist/helptextVersion.d.ts +2 -0
- package/components/radio/dist/index.d.ts +3 -0
- package/components/radio/dist/index.js +1850 -0
- package/components/radio/dist/registered.js +1851 -0
- package/components/radio/dist/styles/auro-radio-group-css.d.ts +2 -0
- package/components/radio/dist/styles/color-css.d.ts +2 -0
- package/components/radio/dist/styles/groupColor-css.d.ts +2 -0
- package/components/radio/dist/styles/style-css.d.ts +2 -0
- package/components/radio/dist/styles/tokens-css.d.ts +2 -0
- package/components/select/README.md +144 -0
- package/components/select/demo/api.html +71 -0
- package/components/select/demo/api.js +35 -0
- package/components/select/demo/api.md +1313 -0
- package/components/select/demo/api.min.js +7763 -0
- package/components/select/demo/index.html +66 -0
- package/components/select/demo/index.js +9 -0
- package/components/select/demo/index.md +815 -0
- package/components/select/demo/index.min.js +7651 -0
- package/components/select/demo/readme.html +50 -0
- package/components/select/demo/readme.md +144 -0
- package/components/select/dist/auro-select.d.ts +359 -0
- package/components/select/dist/bibtemplateVersion.d.ts +2 -0
- package/components/select/dist/dropdownVersion.d.ts +2 -0
- package/components/select/dist/index.d.ts +2 -0
- package/components/select/dist/index.js +6300 -0
- package/components/select/dist/registered.js +6300 -0
- package/components/select/dist/styles/style-css.d.ts +2 -0
- package/package.json +217 -0
- package/packages/build-tools/src/postinstall.mjs +12 -0
|
@@ -0,0 +1,1808 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
const t$2=globalThis,e$4=t$2.ShadowRoot&&(void 0===t$2.ShadyCSS||t$2.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$3=Symbol(),o$5=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$3)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$4&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$2=t=>new n$3("string"==typeof t?t:t+"",void 0,s$3),i$5=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(true===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$3(o,t,s$3)},S$1=(s,o)=>{if(e$4)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$2.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$4?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$2(e)})(t):t;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2017 Google LLC
|
|
11
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
+
*/const{is:i$4,defineProperty:e$3,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$1,getOwnPropertySymbols:o$4,getPrototypeOf:n$2}=Object,a$2=globalThis,c$1=a$2.trustedTypes,l$2=c$1?c$1.emptyScript:"",p$1=a$2.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$2={toAttribute(t,s){switch(s){case Boolean:t=t?l$2:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$4(t,s),b={attribute:true,type:String,converter:u$2,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$2.litPropertyMetadata??=new WeakMap;let y$1 = class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$3(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$1(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$2).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$2;this._$Em=e,this[e]=h.fromAttribute(s,t.type)??this._$Ej?.get(e)??null,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}};y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y$1}),(a$2.reactiveElementVersions??=[]).push("2.1.0");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @license
|
|
16
|
+
* Copyright 2017 Google LLC
|
|
17
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
|
+
*/
|
|
19
|
+
const t$1=globalThis,i$3=t$1.trustedTypes,s$2=i$3?i$3.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$2="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$1=`<${o$3}>`,r=document,l$1=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a$1=Array.isArray,u$1=t=>a$1(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a$1(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$2?s$2.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$1:d>=0?(o.push(a),s.slice(0,d)+e$2+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$2)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$3?i$3.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l$1()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l$1());}}}else if(8===r.nodeType)if(r.data===o$3)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,true);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u$1(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a$1(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l$1()),this.O(l$1()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(false,true,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t$1.litHtmlPolyfillSupport;j?.(N,R),(t$1.litHtmlVersions??=[]).push("3.3.0");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l$1(),t),t,void 0,s??{});}return h._$AI(t),h};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2017 Google LLC
|
|
24
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/const s$1=globalThis;let i$2 = class i extends y$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(false);}render(){return T}};i$2._$litElement$=true,i$2["finalized"]=true,s$1.litElementHydrateSupport?.({LitElement:i$2});const o$2=s$1.litElementPolyfillSupport;o$2?.({LitElement:i$2});(s$1.litElementVersions??=[]).push("4.2.0");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2017 Google LLC
|
|
30
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
+
*/
|
|
32
|
+
const t={ATTRIBUTE:1},e$1=t=>(...e)=>({_$litDirective$:t,values:e});let i$1 = class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @license
|
|
36
|
+
* Copyright 2018 Google LLC
|
|
37
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
|
+
*/const e=e$1(class extends i$1{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return T}});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @license
|
|
42
|
+
* Copyright 2018 Google LLC
|
|
43
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
|
+
*/const o$1=o=>o??E;
|
|
45
|
+
|
|
46
|
+
var styleCss$2 = i$5`:focus:not(:focus-visible){outline:3px solid transparent}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock{display:block}.util_displayFlex{display:flex}.util_displayHidden{display:none}.util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}:host{display:block;--cbxLocation: var(--ds-size-50, 0.25rem)}fieldset{all:unset}@media screen and (min-width: 576px){.displayFlex slot{display:flex}}.cbxContainer{position:relative;padding-left:var(--ds-size-100, 0.5rem);padding-right:var(--ds-size-100, 0.5rem);line-height:var(--ds-size-400, 2rem)}.cbx--input:disabled+label:hover{cursor:auto}.label{margin-left:var(--ds-size-300, 1.5rem);display:block}.label:hover{cursor:pointer}.label--cbx:after{-webkit-tap-highlight-color:transparent;position:absolute;content:"";top:50%;left:var(--cbxLocation);width:calc(var(--ds-size-200, 1rem) + var(--ds-size-50, 0.25rem));height:calc(var(--ds-size-200, 1rem) + var(--ds-size-50, 0.25rem));transform:translateY(-50%);border-width:1px;border-style:solid;border-radius:var(--ds-border-radius, 0.375rem);outline-style:solid;outline-width:1px;z-index:0}.svg--cbx{position:absolute;top:var(--ds-size-25, 0.125rem);left:var(--ds-size-25, 0.125rem);padding-top:3px;padding-bottom:3px;z-index:1}`;
|
|
47
|
+
|
|
48
|
+
var colorCss$2 = i$5`:host .label{color:var(--ds-auro-checkbox-label-color)}:host .label--cbx:after{background-color:var(--ds-auro-checkbox-container-color);border-color:var(--ds-auro-checkbox-border-color);outline-color:var(--ds-auro-checkbox-outline-color)}:host .label--cbx:hover{--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-isfalse-hover, #f2f2f2)}:host .svg--cbx{color:var(--ds-auro-checkbox-checkmark-color)}:host(:focus-within){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused, #01426a);--ds-auro-checkbox-outline-color: var(--ds-advanced-color-state-focused, #01426a)}:host([checked]){--ds-auro-checkbox-border-color: var(--ds-advanced-color-boolean-istrue, #01426a);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-istrue, #01426a)}:host([checked]) .label--cbx:hover{--ds-auro-checkbox-border-color: var(--ds-advanced-color-boolean-istrue-hover, #00274a);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-istrue-hover, #00274a)}:host([checked]:focus-within){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused-inverse, #ffffff)}:host([checked]:focus-within) .label--cbx:hover{--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-istrue-hover, #00274a)}:host([disabled]){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-background-disabled, #dddddd);--ds-auro-checkbox-label-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host([disabled]) .label--cbx:hover{--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-background-disabled, #dddddd);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-isfalse, #ffffff)}:host([disabled][checked]){--ds-auro-checkbox-container-color: var(--ds-advanced-color-state-background-disabled, #dddddd)}:host([disabled][checked]) .label--cbx:hover{--ds-auro-checkbox-container-color: var(--ds-advanced-color-state-background-disabled, #dddddd)}:host([error]){--ds-auro-checkbox-border-color: var(--ds-advanced-color-boolean-error, #e31f26)}:host([error]:not([checked]):focus-within){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused, #01426a);--ds-auro-checkbox-outline-color: var(--ds-advanced-color-state-focused, #01426a)}:host([error][checked]){--ds-auro-checkbox-border-color: var(--ds-advanced-color-boolean-error, #e31f26);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-error, #e31f26)}:host([error][checked]) .label--cbx:hover{--ds-auro-checkbox-border-color: var(--ds-advanced-color-boolean-error-hover, #b1161c);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-error-hover, #b1161c)}:host([error][checked]:focus-within){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused-inverse, #ffffff)}:host([error][checked]:focus-within) .label--cbx:hover{--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-error-hover, #b1161c)}:host([onDark]){--ds-auro-checkbox-label-color: var(--ds-basic-color-texticon-inverse, #ffffff);--ds-auro-checkbox-border-color: var(--ds-basic-color-border-inverse, #ffffff);--ds-auro-checkbox-container-color: transparent}:host([onDark]) .label--cbx:hover{--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-isfalse-inverse-hover, rgba(255, 255, 255, 0.2))}:host([onDark]:focus-within){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-checkbox-outline-color: var(--ds-advanced-color-state-focused-inverse, #ffffff)}:host([onDark][checked]){--ds-auro-checkbox-checkmark-color: var(--ds-advanced-color-boolean-indicator-inverse, #00274a);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-istrue-inverse, #ffffff)}:host([onDark][checked]) .label--cbx:hover{--ds-auro-checkbox-border-color: transparent;--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-istrue-inverse-hover, rgba(255, 255, 255, 0.7))}:host([onDark][checked]:focus-within){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused, #01426a)}:host([onDark][checked]:focus-within) .label--cbx:hover{--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused, #01426a);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-istrue-inverse-hover, rgba(255, 255, 255, 0.7))}:host([onDark][disabled]){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-background-inverse-disabled, #7e8894);--ds-auro-checkbox-label-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}:host([onDark][disabled]) .label--cbx:hover{--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-background-inverse-disabled, #7e8894);--ds-auro-checkbox-container-color: transparent}:host([onDark][disabled][checked]){--ds-auro-checkbox-container-color: var(--ds-advanced-color-state-background-inverse-disabled, #7e8894)}:host([onDark][disabled][checked]) .label--cbx:hover{--ds-auro-checkbox-container-color: var(--ds-advanced-color-state-background-inverse-disabled, #7e8894)}:host([onDark][error]){--ds-auro-checkbox-border-color: var(--ds-advanced-color-boolean-error-inverse, #f9a4a8)}:host([onDark][error]:not([checked]):focus-within){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-checkbox-outline-color: var(--ds-advanced-color-state-focused-inverse, #ffffff)}:host([onDark][error][checked]){--ds-auro-checkbox-border-color: var(--ds-advanced-color-boolean-error-inverse, #f9a4a8);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-error-inverse, #f9a4a8)}:host([onDark][error][checked]) .label--cbx:hover{--ds-auro-checkbox-border-color: var(--ds-advanced-color-boolean-error-inverse-hover, #f15f65);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-error-inverse-hover, #f15f65)}:host([onDark][error][checked]:focus-within){--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused, #01426a)}:host([onDark][error][checked]:focus-within) .label--cbx:hover{--ds-auro-checkbox-border-color: var(--ds-advanced-color-state-focused, #01426a);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-error-inverse-hover, #f15f65)}`;
|
|
49
|
+
|
|
50
|
+
var tokensCss$1 = i$5`:host{--ds-auro-checkbox-border-color: var(--ds-basic-color-border-bold, #585e67);--ds-auro-checkbox-checkmark-color: var(--ds-advanced-color-boolean-indicator, #ffffff);--ds-auro-checkbox-container-color: var(--ds-advanced-color-boolean-isfalse, #ffffff);--ds-auro-checkbox-label-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-checkbox-outline-color: transparent;--ds-auro-checkbox-group-text-color: var(--ds-basic-color-texticon-default, #2a2a2a)}`;
|
|
51
|
+
|
|
52
|
+
var checkLg = {"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-hidden=\"true\" class=\"ico_squareLarge\" data-deprecated=\"true\" role=\"img\" style=\"min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor\" viewBox=\"0 0 24 24\" part=\"svg\"><title/><path d=\"M5.321 12.514a.75.75 0 0 0-1.142.972l4.25 5a.75.75 0 0 0 1.141.001l10.25-12a.75.75 0 1 0-1.14-.975L9 16.844z\"/></svg>"};
|
|
53
|
+
|
|
54
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
55
|
+
// See LICENSE in the project root for license information.
|
|
56
|
+
|
|
57
|
+
// ---------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
/* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
|
|
60
|
+
|
|
61
|
+
let AuroLibraryRuntimeUtils$1 = class AuroLibraryRuntimeUtils {
|
|
62
|
+
|
|
63
|
+
/* eslint-disable jsdoc/require-param */
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* This will register a new custom element with the browser.
|
|
67
|
+
* @param {String} name - The name of the custom element.
|
|
68
|
+
* @param {Object} componentClass - The class to register as a custom element.
|
|
69
|
+
* @returns {void}
|
|
70
|
+
*/
|
|
71
|
+
registerComponent(name, componentClass) {
|
|
72
|
+
if (!customElements.get(name)) {
|
|
73
|
+
customElements.define(name, class extends componentClass {});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Finds and returns the closest HTML Element based on a selector.
|
|
79
|
+
* @returns {void}
|
|
80
|
+
*/
|
|
81
|
+
closestElement(
|
|
82
|
+
selector, // selector like in .closest()
|
|
83
|
+
base = this, // extra functionality to skip a parent
|
|
84
|
+
__Closest = (el, found = el && el.closest(selector)) =>
|
|
85
|
+
!el || el === document || el === window
|
|
86
|
+
? null // standard .closest() returns null for non-found selectors also
|
|
87
|
+
: found
|
|
88
|
+
? found // found a selector INside this element
|
|
89
|
+
: __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
|
|
90
|
+
) {
|
|
91
|
+
return __Closest(base);
|
|
92
|
+
}
|
|
93
|
+
/* eslint-enable jsdoc/require-param */
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* If the element passed is registered with a different tag name than what is passed in, the tag name is added as an attribute to the element.
|
|
97
|
+
* @param {Object} elem - The element to check.
|
|
98
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
99
|
+
* @returns {void}
|
|
100
|
+
*/
|
|
101
|
+
handleComponentTagRename(elem, tagName) {
|
|
102
|
+
const tag = tagName.toLowerCase();
|
|
103
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
104
|
+
|
|
105
|
+
if (elemTag !== tag) {
|
|
106
|
+
elem.setAttribute(tag, true);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Validates if an element is a specific Auro component.
|
|
112
|
+
* @param {Object} elem - The element to validate.
|
|
113
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
114
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
115
|
+
*/
|
|
116
|
+
elementMatch(elem, tagName) {
|
|
117
|
+
const tag = tagName.toLowerCase();
|
|
118
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
119
|
+
|
|
120
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
125
|
+
// See LICENSE in the project root for license information.
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Custom element for the purpose of allowing users to select one or more options of a limited number of choices.
|
|
130
|
+
*
|
|
131
|
+
* @prop {string} id - The id global attribute defines an identifier (ID) which must be unique in the whole document.
|
|
132
|
+
* @attr id
|
|
133
|
+
*
|
|
134
|
+
* @csspart checkbox - apply css to a specific checkbox.
|
|
135
|
+
* @csspart checkbox-input - apply css to a specific checkbox's input.
|
|
136
|
+
* @csspart checkbox-label - apply css to a specific checkbox's label.
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
// build the component class
|
|
140
|
+
class AuroCheckbox extends i$2 {
|
|
141
|
+
constructor() {
|
|
142
|
+
super();
|
|
143
|
+
this.checked = false;
|
|
144
|
+
this.disabled = false;
|
|
145
|
+
this.error = false;
|
|
146
|
+
this.onDark = false;
|
|
147
|
+
this.touched = false;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @private
|
|
151
|
+
*/
|
|
152
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils$1();
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @private
|
|
156
|
+
* @property {boolean} delegatesFocus - Whether the shadow root delegates focus.
|
|
157
|
+
*/
|
|
158
|
+
this.constructor.shadowRootOptions = {
|
|
159
|
+
...i$2.shadowRootOptions,
|
|
160
|
+
delegatesFocus: true,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
static get styles() {
|
|
165
|
+
return [
|
|
166
|
+
styleCss$2,
|
|
167
|
+
colorCss$2,
|
|
168
|
+
tokensCss$1
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// function to define props used within the scope of this component
|
|
173
|
+
static get properties() {
|
|
174
|
+
return {
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* If set to true, the checkbox will be filled with a checkmark.
|
|
178
|
+
*/
|
|
179
|
+
checked: {
|
|
180
|
+
type: Boolean,
|
|
181
|
+
reflect: true
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* If set to true, the checkbox will not be clickable.
|
|
186
|
+
*/
|
|
187
|
+
disabled: {
|
|
188
|
+
type: Boolean,
|
|
189
|
+
reflect: true
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* If set to true, the checkbox will be displayed with an error state.
|
|
194
|
+
*/
|
|
195
|
+
error: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
reflect: true
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Accepts any string and is used to identify related checkboxes when submitting form data.
|
|
202
|
+
*/
|
|
203
|
+
name: { type: String },
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Sets onDark styles for component.
|
|
207
|
+
*/
|
|
208
|
+
onDark: {
|
|
209
|
+
type: Boolean,
|
|
210
|
+
reflect: true
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Sets the element's input value. Must be unique within an auro-checkbox-group element.
|
|
215
|
+
*/
|
|
216
|
+
value: {
|
|
217
|
+
type: String,
|
|
218
|
+
reflect: true
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Indicates whether the checkbox has been interacted with.
|
|
223
|
+
* @type {boolean}
|
|
224
|
+
* @private
|
|
225
|
+
*/
|
|
226
|
+
touched: {
|
|
227
|
+
type: Boolean,
|
|
228
|
+
reflect: true,
|
|
229
|
+
attribute: false
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* @private
|
|
234
|
+
* id for input node
|
|
235
|
+
*/
|
|
236
|
+
inputId: {
|
|
237
|
+
type: String,
|
|
238
|
+
reflect: false,
|
|
239
|
+
attribute: false
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* This will register this element with the browser.
|
|
246
|
+
* @param {string} [name="auro-checkbox"] - The name of element that you want to register to.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* AuroCheckbox.register("custom-checkbox") // this will register this element to <custom-checkbox/>
|
|
250
|
+
*
|
|
251
|
+
*/
|
|
252
|
+
static register(name = "auro-checkbox") {
|
|
253
|
+
AuroLibraryRuntimeUtils$1.prototype.registerComponent(name, AuroCheckbox);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Handles the change event for the checkbox input.
|
|
258
|
+
* Updates the checked state and dispatches a corresponding custom event.
|
|
259
|
+
* This custom event is only for the purpose of supporting IE
|
|
260
|
+
* @private
|
|
261
|
+
* @param {Event} event - The change event from the checkbox input.
|
|
262
|
+
* @returns {void}
|
|
263
|
+
*/
|
|
264
|
+
handleChange(event) {
|
|
265
|
+
this.checked = event.target.checked;
|
|
266
|
+
const customEvent = new CustomEvent(event.type, event);
|
|
267
|
+
|
|
268
|
+
this.dispatchEvent(customEvent);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Handles the input event for the checkbox input.
|
|
273
|
+
* Updates the checked state and dispatches a custom 'auroCheckbox-input' event.
|
|
274
|
+
* @private
|
|
275
|
+
* @param {Event} event - The input event from the checkbox input.
|
|
276
|
+
* @returns {void}
|
|
277
|
+
*/
|
|
278
|
+
handleInput(event) {
|
|
279
|
+
this.checked = event.target.checked;
|
|
280
|
+
|
|
281
|
+
this.dispatchEvent(new CustomEvent('auroCheckbox-input', {
|
|
282
|
+
bubbles: true,
|
|
283
|
+
cancelable: false,
|
|
284
|
+
composed: true,
|
|
285
|
+
}));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Function to support @focusin event.
|
|
290
|
+
* @private
|
|
291
|
+
* @returns {void}
|
|
292
|
+
*/
|
|
293
|
+
handleFocusin() {
|
|
294
|
+
this.touched = true;
|
|
295
|
+
this.dispatchEvent(new CustomEvent('auroCheckbox-focusin', {
|
|
296
|
+
bubbles: true,
|
|
297
|
+
cancelable: false,
|
|
298
|
+
composed: true,
|
|
299
|
+
}));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Function to generate checkmark svg.
|
|
304
|
+
* @private
|
|
305
|
+
* @returns {void}
|
|
306
|
+
*/
|
|
307
|
+
generateIconHtml() {
|
|
308
|
+
this.dom = new DOMParser().parseFromString(checkLg.svg, 'text/html');
|
|
309
|
+
this.svg = this.dom.body.firstChild;
|
|
310
|
+
|
|
311
|
+
this.svg.classList.add('svg--cbx');
|
|
312
|
+
|
|
313
|
+
return this.svg;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Resets component to initial state.
|
|
318
|
+
* @returns {void}
|
|
319
|
+
*/
|
|
320
|
+
reset() {
|
|
321
|
+
this.checked = false;
|
|
322
|
+
this.error = false;
|
|
323
|
+
this.touched = false;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
firstUpdated() {
|
|
327
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
328
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-checkbox');
|
|
329
|
+
|
|
330
|
+
this.inputId = this.id ? `${this.id}-input` : window.crypto.randomUUID();
|
|
331
|
+
|
|
332
|
+
this.addEventListener('click', () => {
|
|
333
|
+
this.handleFocusin();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
this.addEventListener('focusin', () => {
|
|
337
|
+
this.handleFocusin();
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
this.addEventListener('focusout', () => {
|
|
341
|
+
this.dispatchEvent(new CustomEvent('auroCheckbox-focusout', {
|
|
342
|
+
bubbles: true,
|
|
343
|
+
cancelable: false,
|
|
344
|
+
composed: true,
|
|
345
|
+
}));
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// function that renders the HTML and CSS into the scope of the component
|
|
350
|
+
render() {
|
|
351
|
+
const labelClasses = {
|
|
352
|
+
'label': true,
|
|
353
|
+
'label--cbx': true,
|
|
354
|
+
'errorBorder': this.error
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
return x`
|
|
358
|
+
<div class="cbxContainer" part="checkbox">
|
|
359
|
+
<input
|
|
360
|
+
class="util_displayHiddenVisually cbx--input"
|
|
361
|
+
part="checkbox-input"
|
|
362
|
+
@change=${this.handleChange}
|
|
363
|
+
@input="${this.handleInput}"
|
|
364
|
+
?disabled="${this.disabled}"
|
|
365
|
+
.checked="${this.checked}"
|
|
366
|
+
id="${this.inputId}"
|
|
367
|
+
name="${o$1(this.name)}"
|
|
368
|
+
type="checkbox"
|
|
369
|
+
.value="${this.value}"
|
|
370
|
+
/>
|
|
371
|
+
|
|
372
|
+
<label for="${this.inputId}" class="${e(labelClasses)}" part="checkbox-label">
|
|
373
|
+
${this.checked ? this.generateIconHtml() : undefined}
|
|
374
|
+
<slot></slot>
|
|
375
|
+
</label>
|
|
376
|
+
</div>
|
|
377
|
+
`;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* @license
|
|
383
|
+
* Copyright 2020 Google LLC
|
|
384
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
385
|
+
*/
|
|
386
|
+
const a=Symbol.for(""),o=t=>{if(t?.r===a)return t?._$litStatic$},s=t=>({_$litStatic$:t,r:a}),i=(t,...r)=>({_$litStatic$:r.reduce(((r,e,a)=>r+(t=>{if(void 0!==t._$litStatic$)return t._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${t}. Use 'unsafeStatic' to pass non-literal values, but\n take care to ensure page security.`)})(e)+t[a+1]),t[0]),r:a}),l=new Map,n=t=>(r,...e)=>{const a=e.length;let s,i;const n=[],u=[];let c,$=0,f=false;for(;$<a;){for(c=r[$];$<a&&void 0!==(i=e[$],s=o(i));)c+=s+r[++$],f=true;$!==a&&u.push(i),n.push(c),$++;}if($===a&&n.push(r[a]),f){const t=n.join("$$lit$$");void 0===(r=l.get(t))&&(n.raw=n,l.set(t,r=n)),e=u;}return t(r,...e)},u=n(x);
|
|
387
|
+
|
|
388
|
+
class DateFormatter {
|
|
389
|
+
|
|
390
|
+
constructor() {
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* @description Parses a date string into its components.
|
|
394
|
+
* @param {string} dateStr - Date string to parse.
|
|
395
|
+
* @param {string} format - Date format to parse.
|
|
396
|
+
* @returns {Object<key["month" | "day" | "year"]: number>|undefined}
|
|
397
|
+
*/
|
|
398
|
+
this.parseDate = (dateStr, format = 'mm/dd/yyyy') => {
|
|
399
|
+
|
|
400
|
+
// Guard Clause: Date string is defined
|
|
401
|
+
if (!dateStr) {
|
|
402
|
+
return undefined;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Assume the separator is a "/" a defined in our code base
|
|
406
|
+
const separator = '/';
|
|
407
|
+
|
|
408
|
+
// Get the parts of the date and format
|
|
409
|
+
const valueParts = dateStr.split(separator);
|
|
410
|
+
const formatParts = format.split(separator);
|
|
411
|
+
|
|
412
|
+
// Check if the value and format have the correct number of parts
|
|
413
|
+
if (valueParts.length !== formatParts.length) {
|
|
414
|
+
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Holds the result to be returned
|
|
418
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
419
|
+
const value = valueParts[index];
|
|
420
|
+
|
|
421
|
+
if ((/m/iu).test(part)) {
|
|
422
|
+
acc.month = value;
|
|
423
|
+
} else if ((/d/iu).test(part)) {
|
|
424
|
+
acc.day = value;
|
|
425
|
+
} else if ((/y/iu).test(part)) {
|
|
426
|
+
acc.year = value;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return acc;
|
|
430
|
+
}, {});
|
|
431
|
+
|
|
432
|
+
// If we found all the parts, return the result
|
|
433
|
+
if (result.month && result.year) {
|
|
434
|
+
return result;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Throw an error to let the dev know we were unable to parse the date string
|
|
438
|
+
throw new Error('AuroDatepickerUtilities | parseDate: Unable to parse date string');
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Convert a date object to string format.
|
|
443
|
+
* @param {Object} date - Date to convert to string.
|
|
444
|
+
* @returns {Object} Returns the date as a string.
|
|
445
|
+
*/
|
|
446
|
+
this.getDateAsString = (date) => date.toLocaleDateString(undefined, {
|
|
447
|
+
year: "numeric",
|
|
448
|
+
month: "2-digit",
|
|
449
|
+
day: "2-digit",
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Converts a date string to a North American date format.
|
|
454
|
+
* @param {String} dateStr - Date to validate.
|
|
455
|
+
* @param {String} format - Date format to validate against.
|
|
456
|
+
* @returns {Boolean}
|
|
457
|
+
*/
|
|
458
|
+
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
459
|
+
|
|
460
|
+
if (format === 'mm/dd/yyyy') {
|
|
461
|
+
return dateStr;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const parsedDate = this.parseDate(dateStr, format);
|
|
465
|
+
|
|
466
|
+
if (!parsedDate) {
|
|
467
|
+
throw new Error('AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string');
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const { month, day, year } = parsedDate;
|
|
471
|
+
|
|
472
|
+
const dateParts = [];
|
|
473
|
+
if (month) {
|
|
474
|
+
dateParts.push(month);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (day) {
|
|
478
|
+
dateParts.push(day);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (year) {
|
|
482
|
+
dateParts.push(year);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
return dateParts.join('/');
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
const dateFormatter = new DateFormatter();
|
|
490
|
+
|
|
491
|
+
// filepath: dateConstraints.mjs
|
|
492
|
+
const DATE_UTIL_CONSTRAINTS = {
|
|
493
|
+
maxDay: 31,
|
|
494
|
+
maxMonth: 12,
|
|
495
|
+
maxYear: 2400,
|
|
496
|
+
minDay: 1,
|
|
497
|
+
minMonth: 1,
|
|
498
|
+
minYear: 1900,
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
class AuroDateUtilitiesBase {
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* @description The maximum day value allowed by the various utilities in this class.
|
|
505
|
+
* @readonly
|
|
506
|
+
* @type {Number}
|
|
507
|
+
*/
|
|
508
|
+
get maxDay() {
|
|
509
|
+
return DATE_UTIL_CONSTRAINTS.maxDay;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* @description The maximum month value allowed by the various utilities in this class.
|
|
514
|
+
* @readonly
|
|
515
|
+
* @type {Number}
|
|
516
|
+
*/
|
|
517
|
+
get maxMonth() {
|
|
518
|
+
return DATE_UTIL_CONSTRAINTS.maxMonth;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* @description The maximum year value allowed by the various utilities in this class.
|
|
523
|
+
* @readonly
|
|
524
|
+
* @type {Number}
|
|
525
|
+
*/
|
|
526
|
+
get maxYear() {
|
|
527
|
+
return DATE_UTIL_CONSTRAINTS.maxYear;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* @description The minimum day value allowed by the various utilities in this class.
|
|
532
|
+
* @readonly
|
|
533
|
+
* @type {Number}
|
|
534
|
+
*/
|
|
535
|
+
get minDay() {
|
|
536
|
+
return DATE_UTIL_CONSTRAINTS.minDay;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* @description The minimum month value allowed by the various utilities in this class.
|
|
541
|
+
* @readonly
|
|
542
|
+
* @type {Number}
|
|
543
|
+
*/
|
|
544
|
+
get minMonth() {
|
|
545
|
+
return DATE_UTIL_CONSTRAINTS.minMonth;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* @description The minimum year value allowed by the various utilities in this class.
|
|
550
|
+
* @readonly
|
|
551
|
+
* @type {Number}
|
|
552
|
+
*/
|
|
553
|
+
get minYear() {
|
|
554
|
+
return DATE_UTIL_CONSTRAINTS.minYear;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/* eslint-disable no-magic-numbers */
|
|
559
|
+
|
|
560
|
+
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Returns the current century.
|
|
564
|
+
* @returns {String} The current century.
|
|
565
|
+
*/
|
|
566
|
+
getCentury () {
|
|
567
|
+
return String(new Date().getFullYear()).slice(0, 2);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Returns a four digit year.
|
|
572
|
+
* @param {String} year - The year to convert to four digits.
|
|
573
|
+
* @returns {String} The four digit year.
|
|
574
|
+
*/
|
|
575
|
+
getFourDigitYear (year) {
|
|
576
|
+
|
|
577
|
+
const strYear = String(year).trim();
|
|
578
|
+
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
constructor() {
|
|
582
|
+
|
|
583
|
+
super();
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Compares two dates to see if they match.
|
|
587
|
+
* @param {Object} date1 - First date to compare.
|
|
588
|
+
* @param {Object} date2 - Second date to compare.
|
|
589
|
+
* @returns {Boolean} Returns true if the dates match.
|
|
590
|
+
*/
|
|
591
|
+
this.datesMatch = (date1, date2) => new Date(date1).getTime() === new Date(date2).getTime();
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Returns true if value passed in is a valid date.
|
|
595
|
+
* @param {String} date - Date to validate.
|
|
596
|
+
* @param {String} format - Date format to validate against.
|
|
597
|
+
* @returns {Boolean}
|
|
598
|
+
*/
|
|
599
|
+
this.validDateStr = (date, format) => {
|
|
600
|
+
|
|
601
|
+
// The length we expect the date string to be
|
|
602
|
+
const dateStrLength = format.length;
|
|
603
|
+
|
|
604
|
+
// Guard Clause: Date and format are defined
|
|
605
|
+
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
606
|
+
throw new Error('AuroDatepickerUtilities | validateDateStr: Date and format are required');
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// Guard Clause: Date should be of type string
|
|
610
|
+
if (typeof date !== "string") {
|
|
611
|
+
throw new Error('AuroDatepickerUtilities | validateDateStr: Date must be a string');
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// Guard Clause: Format should be of type string
|
|
615
|
+
if (typeof format !== "string") {
|
|
616
|
+
throw new Error('AuroDatepickerUtilities | validateDateStr: Format must be a string');
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// Guard Clause: Length is what we expect it to be
|
|
620
|
+
if (date.length !== dateStrLength) {
|
|
621
|
+
return false;
|
|
622
|
+
}
|
|
623
|
+
// Get a formatted date string and parse it
|
|
624
|
+
const dateParts = dateFormatter.parseDate(date, format);
|
|
625
|
+
|
|
626
|
+
// Guard Clause: Date parse succeeded
|
|
627
|
+
if (!dateParts) {
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// Create the expected date string based on the date parts
|
|
632
|
+
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
633
|
+
|
|
634
|
+
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
635
|
+
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
636
|
+
|
|
637
|
+
// Get the date string of the date object we created from the string date
|
|
638
|
+
const actualDateStr = dateFormatter.getDateAsString(dateObj);
|
|
639
|
+
|
|
640
|
+
// Guard Clause: Generated date matches date string input
|
|
641
|
+
if (expectedDateStr !== actualDateStr) {
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// If we passed all other checks, we can assume the date is valid
|
|
646
|
+
return true;
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Determines if a string date value matches the format provided.
|
|
651
|
+
* @param {string} value = The date string value.
|
|
652
|
+
* @param { string} format = The date format to match against.
|
|
653
|
+
* @returns {boolean}
|
|
654
|
+
*/
|
|
655
|
+
this.dateAndFormatMatch = (value, format) => {
|
|
656
|
+
|
|
657
|
+
// Ensure we have both values we need to do the comparison
|
|
658
|
+
if (!value || !format) {
|
|
659
|
+
throw new Error('AuroFormValidation | dateFormatMatch: value and format are required');
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// If the lengths are different, they cannot match
|
|
663
|
+
if (value.length !== format.length) {
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// Get the parts of the date
|
|
668
|
+
const dateParts = dateFormatter.parseDate(value, format);
|
|
669
|
+
|
|
670
|
+
// Validator for day
|
|
671
|
+
const dayValueIsValid = (day) => {
|
|
672
|
+
|
|
673
|
+
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
674
|
+
if (!dateParts.day) {
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// Guard clause: ensure day exists.
|
|
679
|
+
if (!day) {
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// Convert day to number
|
|
684
|
+
const numDay = Number.parseInt(day, 10);
|
|
685
|
+
|
|
686
|
+
// Guard clause: ensure day is a valid integer
|
|
687
|
+
if (Number.isNaN(numDay)) {
|
|
688
|
+
throw new Error('AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer');
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// Guard clause: ensure day is within the valid range
|
|
692
|
+
if (numDay < this.minDay || numDay > this.maxDay) {
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// Default return
|
|
697
|
+
return true;
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
// Validator for month
|
|
701
|
+
const monthValueIsValid = (month) => {
|
|
702
|
+
|
|
703
|
+
// Guard clause: ensure month exists.
|
|
704
|
+
if (!month) {
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// Convert month to number
|
|
709
|
+
const numMonth = Number.parseInt(month, 10);
|
|
710
|
+
|
|
711
|
+
// Guard clause: ensure month is a valid integer
|
|
712
|
+
if (Number.isNaN(numMonth)) {
|
|
713
|
+
throw new Error('AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer');
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// Guard clause: ensure month is within the valid range
|
|
717
|
+
if (numMonth < this.minMonth || numMonth > this.maxMonth) {
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// Default return
|
|
722
|
+
return true;
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
// Validator for year
|
|
726
|
+
const yearIsValid = (_year) => {
|
|
727
|
+
|
|
728
|
+
// Guard clause: ensure year exists.
|
|
729
|
+
if (!_year) {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// Get the full year
|
|
734
|
+
const year = this.getFourDigitYear(_year);
|
|
735
|
+
|
|
736
|
+
// Convert year to number
|
|
737
|
+
const numYear = Number.parseInt(year, 10);
|
|
738
|
+
|
|
739
|
+
// Guard clause: ensure year is a valid integer
|
|
740
|
+
if (Number.isNaN(numYear)) {
|
|
741
|
+
throw new Error('AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer');
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// Guard clause: ensure year is within the valid range
|
|
745
|
+
if (numYear < this.minYear || numYear > this.maxYear) {
|
|
746
|
+
return false;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// Default return
|
|
750
|
+
return true;
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
// Self-contained checks for month, day, and year
|
|
754
|
+
const checks = [
|
|
755
|
+
monthValueIsValid(dateParts.month),
|
|
756
|
+
dayValueIsValid(dateParts.day),
|
|
757
|
+
yearIsValid(dateParts.year)
|
|
758
|
+
];
|
|
759
|
+
|
|
760
|
+
// If any of the checks failed, the date format does not match and the result is invalid
|
|
761
|
+
const isValid = checks.every((check) => check === true);
|
|
762
|
+
|
|
763
|
+
// If the check is invalid, return false
|
|
764
|
+
if (!isValid) {
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// Default case
|
|
769
|
+
return true;
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// Export a class instance
|
|
775
|
+
const dateUtilities = new AuroDateUtilities();
|
|
776
|
+
|
|
777
|
+
// Export the class instance methods individually
|
|
778
|
+
const {
|
|
779
|
+
datesMatch,
|
|
780
|
+
validDateStr,
|
|
781
|
+
dateAndFormatMatch,
|
|
782
|
+
minDay,
|
|
783
|
+
minMonth,
|
|
784
|
+
minYear,
|
|
785
|
+
maxDay,
|
|
786
|
+
maxMonth,
|
|
787
|
+
maxYear
|
|
788
|
+
} = dateUtilities;
|
|
789
|
+
|
|
790
|
+
const {
|
|
791
|
+
toNorthAmericanFormat,
|
|
792
|
+
parseDate,
|
|
793
|
+
getDateAsString
|
|
794
|
+
} = dateFormatter;
|
|
795
|
+
|
|
796
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
797
|
+
// See LICENSE in the project root for license information.
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
class AuroFormValidation {
|
|
801
|
+
|
|
802
|
+
constructor() {
|
|
803
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils$1();
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Resets the element to its initial state.
|
|
808
|
+
* @private
|
|
809
|
+
* @param {object} elem - HTML element to reset.
|
|
810
|
+
* @returns {void}
|
|
811
|
+
*/
|
|
812
|
+
reset(elem) {
|
|
813
|
+
elem.validity = undefined;
|
|
814
|
+
elem.value = undefined;
|
|
815
|
+
elem.touched = false;
|
|
816
|
+
|
|
817
|
+
// Resets the second value of the datepicker in range state
|
|
818
|
+
if (elem.valueEnd) {
|
|
819
|
+
elem.valueEnd = undefined;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// Resets selected option of element
|
|
823
|
+
if (elem.optionSelected) {
|
|
824
|
+
elem.optionSelected = undefined;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// Runs validation to handle error attribute
|
|
828
|
+
this.validate(elem);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* Validates the attributes of a given element based on predefined validation rules.
|
|
833
|
+
*
|
|
834
|
+
* @param {HTMLElement} elem - The element to be validated.
|
|
835
|
+
* @returns {void}
|
|
836
|
+
*
|
|
837
|
+
* @example
|
|
838
|
+
* // Assuming `inputElement` is a reference to an input element in the DOM
|
|
839
|
+
* validateElementAttributes(inputElement);
|
|
840
|
+
*
|
|
841
|
+
* The function checks the element's attributes against the validation rules defined for 'input' and 'counter' types.
|
|
842
|
+
* If a validation rule is violated, it sets the element's validity state and error message accordingly.
|
|
843
|
+
*
|
|
844
|
+
* Validation rules:
|
|
845
|
+
* - input:
|
|
846
|
+
* - length:
|
|
847
|
+
* - tooShort: Checks if the value length is less than the minimum length.
|
|
848
|
+
* - tooLong: Checks if the value length exceeds the maximum length.
|
|
849
|
+
* - pattern:
|
|
850
|
+
* - patternMismatch: Checks if the value does not match the specified pattern.
|
|
851
|
+
* - counter:
|
|
852
|
+
* - range:
|
|
853
|
+
* - rangeOverflow: Checks if the value exceeds the maximum value.
|
|
854
|
+
* - rangeUnderflow: Checks if the value is less than the minimum value.
|
|
855
|
+
*/
|
|
856
|
+
validateElementAttributes(elem) {
|
|
857
|
+
const validationRules = {
|
|
858
|
+
input: {
|
|
859
|
+
length: [
|
|
860
|
+
{
|
|
861
|
+
check: (e) => e.value?.length > 0 && e.value?.length < e.minLength,
|
|
862
|
+
validity: 'tooShort',
|
|
863
|
+
message: e => e.setCustomValidityTooShort || e.setCustomValidity || ''
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
check: (e) => e.value?.length > e.maxLength,
|
|
867
|
+
validity: 'tooLong',
|
|
868
|
+
message: e => e.setCustomValidityTooLong || e.setCustomValidity || ''
|
|
869
|
+
}
|
|
870
|
+
],
|
|
871
|
+
pattern: [
|
|
872
|
+
{
|
|
873
|
+
check: (e) => e.pattern && !new RegExp(`^${e.pattern}$`, 'u').test(e.value),
|
|
874
|
+
validity: 'patternMismatch',
|
|
875
|
+
message: e => e.setCustomValidityPatternMismatch || e.setCustomValidity || ''
|
|
876
|
+
}
|
|
877
|
+
]
|
|
878
|
+
},
|
|
879
|
+
counter: {
|
|
880
|
+
range: [
|
|
881
|
+
{
|
|
882
|
+
check: (e) => e.max !== undefined && Number(e.max) < Number(e.value),
|
|
883
|
+
validity: 'rangeOverflow',
|
|
884
|
+
message: e => e.getAttribute('setCustomValidityRangeOverflow') || ''
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
check: (e) => e.min !== undefined && Number(e.min) > Number(e.value),
|
|
888
|
+
validity: 'rangeUnderflow',
|
|
889
|
+
message: e => e.getAttribute('setCustomValidityRangeUnderflow') || ''
|
|
890
|
+
}
|
|
891
|
+
]
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
let elementType;
|
|
896
|
+
if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
897
|
+
elementType = 'input';
|
|
898
|
+
} else if (this.runtimeUtils.elementMatch(elem, 'auro-counter') || this.runtimeUtils.elementMatch(elem, 'auro-counter-group')) {
|
|
899
|
+
elementType = 'counter';
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
if (elementType) {
|
|
903
|
+
const rules = validationRules[elementType];
|
|
904
|
+
|
|
905
|
+
if (rules) {
|
|
906
|
+
Object.values(rules).flat().forEach(rule => {
|
|
907
|
+
if (rule.check(elem)) {
|
|
908
|
+
elem.validity = rule.validity;
|
|
909
|
+
elem.errorMessage = rule.message(elem);
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Determines the validity state of the element based on the type attribute.
|
|
918
|
+
* @private
|
|
919
|
+
* @param {object} elem - HTML element to validate.
|
|
920
|
+
* @returns {void}
|
|
921
|
+
*/
|
|
922
|
+
validateType(elem) {
|
|
923
|
+
if (elem.hasAttribute('type')) {
|
|
924
|
+
if (elem.type === 'email') {
|
|
925
|
+
const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; // eslint-disable-line require-unicode-regexp
|
|
926
|
+
|
|
927
|
+
if (!elem.value.match(emailRegex)) {
|
|
928
|
+
elem.validity = 'patternMismatch';
|
|
929
|
+
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
} else if (elem.type === 'credit-card') {
|
|
933
|
+
if (elem.value.length > 0 && elem.value.length < elem.validationCCLength) {
|
|
934
|
+
elem.validity = 'tooShort';
|
|
935
|
+
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
} else if (elem.type === 'number') {
|
|
939
|
+
if (elem.max !== undefined && Number(elem.max) < Number(elem.value)) {
|
|
940
|
+
elem.validity = 'rangeOverflow';
|
|
941
|
+
elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
if (elem.min !== undefined && elem.value?.length > 0 && Number(elem.min) > Number(elem.value)) {
|
|
946
|
+
elem.validity = 'rangeUnderflow';
|
|
947
|
+
elem.errorMessage = elem.setCustomValidityRangeUnderflow || elem.setCustomValidity || '';
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
} else if (elem.type === 'date' && elem.value?.length > 0) {
|
|
951
|
+
|
|
952
|
+
// Guard Clause: if the value is too short
|
|
953
|
+
if (elem.value?.length < elem.lengthForType) {
|
|
954
|
+
|
|
955
|
+
elem.validity = 'tooShort';
|
|
956
|
+
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// Guard Clause: If the value is too long for the type
|
|
961
|
+
if (elem.value?.length > elem.lengthForType) {
|
|
962
|
+
|
|
963
|
+
elem.validity = 'tooLong';
|
|
964
|
+
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// Validate that the date passed was the correct format
|
|
969
|
+
if (!dateAndFormatMatch(elem.value, elem.format)) {
|
|
970
|
+
elem.validity = 'patternMismatch';
|
|
971
|
+
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || 'Invalid Date Format Entered';
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// Validate that the date passed was a valid date
|
|
976
|
+
if (!validDateStr(elem.value, elem.format)) {
|
|
977
|
+
elem.validity = 'invalidDate';
|
|
978
|
+
elem.errorMessage = elem.setCustomValidityInvalidDate || elem.setCustomValidity || 'Invalid Date Entered';
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// Perform the rest of the validation
|
|
983
|
+
const formattedValue = toNorthAmericanFormat(elem.value, elem.format);
|
|
984
|
+
const valueDate = new Date(formattedValue);
|
|
985
|
+
|
|
986
|
+
// // Validate max date
|
|
987
|
+
if (elem.max?.length === elem.lengthForType) {
|
|
988
|
+
|
|
989
|
+
const maxDate = new Date(toNorthAmericanFormat(elem.max, elem.format));
|
|
990
|
+
|
|
991
|
+
if (valueDate > maxDate) {
|
|
992
|
+
elem.validity = 'rangeOverflow';
|
|
993
|
+
elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// Validate min date
|
|
999
|
+
if (elem.min?.length === elem.lengthForType) {
|
|
1000
|
+
const minDate = new Date(toNorthAmericanFormat(elem.min, elem.format));
|
|
1001
|
+
|
|
1002
|
+
if (valueDate < minDate) {
|
|
1003
|
+
elem.validity = 'rangeUnderflow';
|
|
1004
|
+
elem.errorMessage = elem.setCustomValidityRangeUnderflow || elem.setCustomValidity || '';
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Determines the validity state of the element.
|
|
1014
|
+
* @param {object} elem - HTML element to validate.
|
|
1015
|
+
* @param {boolean} force - Boolean that forces validation to run.
|
|
1016
|
+
* @returns {void}
|
|
1017
|
+
*/
|
|
1018
|
+
validate(elem, force) {
|
|
1019
|
+
this.getInputElements(elem);
|
|
1020
|
+
this.getAuroInputs(elem);
|
|
1021
|
+
|
|
1022
|
+
// Validate only if noValidate is not true and the input does not have focus
|
|
1023
|
+
let validationShouldRun =
|
|
1024
|
+
force ||
|
|
1025
|
+
(!elem.contains(document.activeElement) &&
|
|
1026
|
+
(elem.touched ||
|
|
1027
|
+
(!elem.touched && typeof elem.value !== "undefined"))) ||
|
|
1028
|
+
elem.validateOnInput;
|
|
1029
|
+
|
|
1030
|
+
if (elem.hasAttribute('error')) {
|
|
1031
|
+
elem.validity = 'customError';
|
|
1032
|
+
elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
|
|
1033
|
+
validationShouldRun = false;
|
|
1034
|
+
} else if (validationShouldRun) {
|
|
1035
|
+
elem.validity = 'valid';
|
|
1036
|
+
elem.errorMessage = '';
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Only validate once we interact with the datepicker
|
|
1040
|
+
* elem.value === undefined is the initial state pre-interaction.
|
|
1041
|
+
*
|
|
1042
|
+
* The validityState definitions are located at https://developer.mozilla.org/en-US/docs/Web/API/ValidityState.
|
|
1043
|
+
*/
|
|
1044
|
+
|
|
1045
|
+
let hasValue = false;
|
|
1046
|
+
|
|
1047
|
+
// Check string for having a value
|
|
1048
|
+
if (typeof elem.value === "string") {
|
|
1049
|
+
hasValue = elem.value && elem.value.length > 0;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
// Check array value types for having a value
|
|
1053
|
+
if (Array.isArray(elem.value)) {
|
|
1054
|
+
hasValue = Boolean(
|
|
1055
|
+
elem.value.length > 0 &&
|
|
1056
|
+
elem.value.some((value) => typeof value === "string" && value.length > 0)
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// If there is a second input in the elem and that value is undefined or an empty string set hasValue to false;
|
|
1061
|
+
if (this.auroInputElements?.length === 2) {
|
|
1062
|
+
if (!this.auroInputElements[1].value || this.auroInputElements[1].length === 0) {
|
|
1063
|
+
hasValue = false;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
if (!hasValue && elem.required && elem.touched) {
|
|
1068
|
+
elem.validity = 'valueMissing';
|
|
1069
|
+
elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
|
|
1070
|
+
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
1071
|
+
this.validateType(elem);
|
|
1072
|
+
this.validateElementAttributes(elem);
|
|
1073
|
+
} else if (this.runtimeUtils.elementMatch(elem, 'auro-counter') || this.runtimeUtils.elementMatch(elem, 'auro-counter-group')) {
|
|
1074
|
+
this.validateElementAttributes(elem);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
|
|
1079
|
+
elem.validity = this.auroInputElements[0].validity;
|
|
1080
|
+
elem.errorMessage = this.auroInputElements[0].errorMessage;
|
|
1081
|
+
|
|
1082
|
+
if (elem.validity === 'valid' && this.auroInputElements.length > 1) {
|
|
1083
|
+
elem.validity = this.auroInputElements[1].validity;
|
|
1084
|
+
elem.errorMessage = this.auroInputElements[1].errorMessage;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
if (validationShouldRun || elem.hasAttribute('error')) {
|
|
1089
|
+
// Use the validity message override if it is declared
|
|
1090
|
+
if (elem.validity && elem.validity !== 'valid' && elem.ValidityMessageOverride) {
|
|
1091
|
+
elem.errorMessage = elem.ValidityMessageOverride;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
this.getErrorMessage(elem);
|
|
1095
|
+
|
|
1096
|
+
elem.dispatchEvent(new CustomEvent('auroFormElement-validated', {
|
|
1097
|
+
bubbles: true,
|
|
1098
|
+
composed: true,
|
|
1099
|
+
detail: {
|
|
1100
|
+
validity: elem.validity,
|
|
1101
|
+
message: elem.errorMessage
|
|
1102
|
+
}
|
|
1103
|
+
}));
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* Gets all the HTML5 `inputs` in the element shadow DOM.
|
|
1109
|
+
* @private
|
|
1110
|
+
* @param {object} elem - HTML element to validate.
|
|
1111
|
+
* @returns {void}
|
|
1112
|
+
*/
|
|
1113
|
+
getInputElements(elem) {
|
|
1114
|
+
this.inputElements = elem.renderRoot.querySelectorAll('input');
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Gets all the `auro-inputs` in the element shadow DOM.
|
|
1119
|
+
* @private
|
|
1120
|
+
* @param {object} elem - HTML element to validate.
|
|
1121
|
+
* @returns {void}
|
|
1122
|
+
*/
|
|
1123
|
+
getAuroInputs(elem) {
|
|
1124
|
+
this.auroInputElements = elem.shadowRoot.querySelectorAll('auro-input, [auro-input]');
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* Return appropriate error message.
|
|
1129
|
+
* @private
|
|
1130
|
+
* @param {object} elem - HTML element to validate.
|
|
1131
|
+
* @returns {void}
|
|
1132
|
+
*/
|
|
1133
|
+
getErrorMessage(elem) {
|
|
1134
|
+
if (elem.validity !== 'valid') {
|
|
1135
|
+
if (elem.setCustomValidity) {
|
|
1136
|
+
elem.errorMessage = elem.setCustomValidity;
|
|
1137
|
+
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input') && elem.errorMessage === '') {
|
|
1138
|
+
const input = elem.renderRoot.querySelector('input');
|
|
1139
|
+
|
|
1140
|
+
if (input.validationMessage.length > 0) {
|
|
1141
|
+
elem.errorMessage = input.validationMessage;
|
|
1142
|
+
}
|
|
1143
|
+
} else if (this.inputElements?.length > 0 && elem.errorMessage === '') {
|
|
1144
|
+
const firstInput = this.inputElements[0];
|
|
1145
|
+
|
|
1146
|
+
if (firstInput.validationMessage.length > 0) {
|
|
1147
|
+
elem.errorMessage = firstInput.validationMessage;
|
|
1148
|
+
} else if (this.inputElements?.length === 2) {
|
|
1149
|
+
const secondInput = this.inputElements[1];
|
|
1150
|
+
|
|
1151
|
+
if (secondInput.validationMessage.length > 0) {
|
|
1152
|
+
elem.errorMessage = secondInput.validationMessage;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
} else {
|
|
1157
|
+
elem.errorMessage = '';
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1163
|
+
// See LICENSE in the project root for license information.
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
class AuroDependencyVersioning {
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Generates a unique string to be used for child auro element naming.
|
|
1170
|
+
* @private
|
|
1171
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
1172
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
1173
|
+
* @returns {string} - Unique string to be used for naming.
|
|
1174
|
+
*/
|
|
1175
|
+
generateElementName(baseName, version) {
|
|
1176
|
+
let result = baseName;
|
|
1177
|
+
|
|
1178
|
+
result += '-';
|
|
1179
|
+
result += version.replace(/[.]/g, '_');
|
|
1180
|
+
|
|
1181
|
+
return result;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* Generates a unique string to be used for child auro element naming.
|
|
1186
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
1187
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
1188
|
+
* @returns {string} - Unique string to be used for naming.
|
|
1189
|
+
*/
|
|
1190
|
+
generateTag(baseName, version, tagClass) {
|
|
1191
|
+
const elementName = this.generateElementName(baseName, version);
|
|
1192
|
+
const tag = i`${s(elementName)}`;
|
|
1193
|
+
|
|
1194
|
+
if (!customElements.get(elementName)) {
|
|
1195
|
+
customElements.define(elementName, class extends tagClass {});
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
return tag;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
var styleCss$1 = i$5`:host{display:block;padding-bottom:var(--ds-size-150, 0.75rem)}.displayFlex legend+slot{display:flex;white-space:nowrap}fieldset{all:unset}legend{margin-bottom:var(--ds-size-150, 0.75rem)}`;
|
|
1203
|
+
|
|
1204
|
+
var colorCss$1 = i$5`:host{color:var(--ds-auro-checkbox-group-text-color)}:host([disabled]){--ds-auro-checkbox-group-text-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host([onDark]){--ds-auro-checkbox-group-text-color: var(--ds-basic-color-texticon-inverse, #ffffff)}:host([onDark][disabled]){--ds-auro-checkbox-group-text-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}`;
|
|
1205
|
+
|
|
1206
|
+
var colorCss = i$5`:host([error]){--ds-auro-helptext-color: var(--ds-basic-color-status-error, #e31f26)}:host([onDark]){--ds-auro-helptext-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}:host([onDark][error]){--ds-auro-helptext-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}.helptext-wrapper{color:var(--ds-auro-helptext-color)}`;
|
|
1207
|
+
|
|
1208
|
+
var styleCss = i$5`.helptext-wrapper{display:none;font-size:var(--ds-basic-text-body-xs-font-size, 12px);font-weight:var(--ds-basic-text-body-xs-font-weight, 450);letter-spacing:var(--ds-basic-text-body-xs-letter-spacing, 0);line-height:var(--ds-basic-text-body-xs-line-height, 16px)}:host([large]) .helptext-wrapper{font-size:var(--ds-basic-text-body-default-font-size, 16px);font-weight:var(--ds-basic-text-body-default-font-weight, 450);letter-spacing:var(--ds-basic-text-body-default-letter-spacing, 0);line-height:var(--ds-basic-text-body-default-line-height, 24px)}.helptext-wrapper[visible]{display:block}::slotted(*:not(:empty)){margin-top:var(--ds-size-50, 0.25rem);margin-bottom:0}::slotted(p){margin-block:0}`;
|
|
1209
|
+
|
|
1210
|
+
var tokensCss = i$5`:host{--ds-auro-helptext-color: var(--ds-basic-color-texticon-muted, #676767)}`;
|
|
1211
|
+
|
|
1212
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1213
|
+
// See LICENSE in the project root for license information.
|
|
1214
|
+
|
|
1215
|
+
// ---------------------------------------------------------------------
|
|
1216
|
+
|
|
1217
|
+
/* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
|
|
1218
|
+
|
|
1219
|
+
class AuroLibraryRuntimeUtils {
|
|
1220
|
+
|
|
1221
|
+
/* eslint-disable jsdoc/require-param */
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* This will register a new custom element with the browser.
|
|
1225
|
+
* @param {String} name - The name of the custom element.
|
|
1226
|
+
* @param {Object} componentClass - The class to register as a custom element.
|
|
1227
|
+
* @returns {void}
|
|
1228
|
+
*/
|
|
1229
|
+
registerComponent(name, componentClass) {
|
|
1230
|
+
if (!customElements.get(name)) {
|
|
1231
|
+
customElements.define(name, class extends componentClass {});
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* Finds and returns the closest HTML Element based on a selector.
|
|
1237
|
+
* @returns {void}
|
|
1238
|
+
*/
|
|
1239
|
+
closestElement(
|
|
1240
|
+
selector, // selector like in .closest()
|
|
1241
|
+
base = this, // extra functionality to skip a parent
|
|
1242
|
+
__Closest = (el, found = el && el.closest(selector)) =>
|
|
1243
|
+
!el || el === document || el === window
|
|
1244
|
+
? null // standard .closest() returns null for non-found selectors also
|
|
1245
|
+
: found
|
|
1246
|
+
? found // found a selector INside this element
|
|
1247
|
+
: __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
|
|
1248
|
+
) {
|
|
1249
|
+
return __Closest(base);
|
|
1250
|
+
}
|
|
1251
|
+
/* eslint-enable jsdoc/require-param */
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* If the element passed is registered with a different tag name than what is passed in, the tag name is added as an attribute to the element.
|
|
1255
|
+
* @param {Object} elem - The element to check.
|
|
1256
|
+
* @param {String} tagName - The name of the Auro component to check for or add as an attribute.
|
|
1257
|
+
* @returns {void}
|
|
1258
|
+
*/
|
|
1259
|
+
handleComponentTagRename(elem, tagName) {
|
|
1260
|
+
const tag = tagName.toLowerCase();
|
|
1261
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
1262
|
+
|
|
1263
|
+
if (elemTag !== tag) {
|
|
1264
|
+
elem.setAttribute(tag, true);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Validates if an element is a specific Auro component.
|
|
1270
|
+
* @param {Object} elem - The element to validate.
|
|
1271
|
+
* @param {String} tagName - The name of the Auro component to check against.
|
|
1272
|
+
* @returns {Boolean} - Returns true if the element is the specified Auro component.
|
|
1273
|
+
*/
|
|
1274
|
+
elementMatch(elem, tagName) {
|
|
1275
|
+
const tag = tagName.toLowerCase();
|
|
1276
|
+
const elemTag = elem.tagName.toLowerCase();
|
|
1277
|
+
|
|
1278
|
+
return elemTag === tag || elem.hasAttribute(tag);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1283
|
+
// See LICENSE in the project root for license information.
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
/**
|
|
1287
|
+
* Displays help text or error messages within form elements - Internal Use Only.
|
|
1288
|
+
*
|
|
1289
|
+
* @attr { Boolean } large - If declared, make font-size to 1rem(16px).
|
|
1290
|
+
*/
|
|
1291
|
+
class AuroHelpText extends i$2 {
|
|
1292
|
+
|
|
1293
|
+
constructor() {
|
|
1294
|
+
super();
|
|
1295
|
+
|
|
1296
|
+
this.error = false;
|
|
1297
|
+
this.onDark = false;
|
|
1298
|
+
this.hasTextContent = false;
|
|
1299
|
+
|
|
1300
|
+
AuroLibraryRuntimeUtils.prototype.handleComponentTagRename(this, 'auro-helptext');
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
static get styles() {
|
|
1304
|
+
return [
|
|
1305
|
+
colorCss,
|
|
1306
|
+
styleCss,
|
|
1307
|
+
tokensCss
|
|
1308
|
+
];
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// function to define props used within the scope of this component
|
|
1312
|
+
static get properties() {
|
|
1313
|
+
return {
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* @private
|
|
1317
|
+
*/
|
|
1318
|
+
slotNodes: {
|
|
1319
|
+
type: Boolean,
|
|
1320
|
+
},
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* @private
|
|
1324
|
+
*/
|
|
1325
|
+
hasTextContent: {
|
|
1326
|
+
type: Boolean,
|
|
1327
|
+
},
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* If declared, make font color red.
|
|
1331
|
+
*/
|
|
1332
|
+
error: {
|
|
1333
|
+
type: Boolean,
|
|
1334
|
+
reflect: true,
|
|
1335
|
+
},
|
|
1336
|
+
|
|
1337
|
+
/**
|
|
1338
|
+
* If declared, will apply onDark styles.
|
|
1339
|
+
*/
|
|
1340
|
+
onDark: {
|
|
1341
|
+
type: Boolean,
|
|
1342
|
+
reflect: true
|
|
1343
|
+
}
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* This will register this element with the browser.
|
|
1349
|
+
* @param {string} [name="auro-helptext"] - The name of element that you want to register to.
|
|
1350
|
+
*
|
|
1351
|
+
* @example
|
|
1352
|
+
* AuroCheckbox.register("custom-helptext") // this will register this element to <custom-helptext/>
|
|
1353
|
+
*
|
|
1354
|
+
*/
|
|
1355
|
+
static register(name = "auro-helptext") {
|
|
1356
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroHelpText);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
updated() {
|
|
1360
|
+
this.handleSlotChange();
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
handleSlotChange(event) {
|
|
1364
|
+
if (event) {
|
|
1365
|
+
this.slotNodes = event.target.assignedNodes();
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
this.hasTextContent = this.checkSlotsForContent(this.slotNodes);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* Checks if any of the provided nodes or their nested slot nodes contain non-empty text content.
|
|
1373
|
+
*
|
|
1374
|
+
* @param {NodeList|Array} nodes - The list of nodes to check for content.
|
|
1375
|
+
* @returns {boolean} - Returns true if any node or nested slot node contains non-empty text content, otherwise false.
|
|
1376
|
+
* @private
|
|
1377
|
+
*/
|
|
1378
|
+
checkSlotsForContent(nodes) {
|
|
1379
|
+
if (!nodes) {
|
|
1380
|
+
return false;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
return nodes.some((node) => {
|
|
1384
|
+
if (node.textContent.trim()) {
|
|
1385
|
+
return true;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
if (!node.querySelector) {
|
|
1389
|
+
return false;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
const nestedSlot = node.tagName === 'SLOT' ? node : node.querySelector('slot');
|
|
1393
|
+
if (!nestedSlot) {
|
|
1394
|
+
return false;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
const nestedSlotNodes = nestedSlot.assignedNodes();
|
|
1398
|
+
return this.checkSlotsForContent(nestedSlotNodes);
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
// function that renders the HTML and CSS into the scope of the component
|
|
1403
|
+
render() {
|
|
1404
|
+
return x`
|
|
1405
|
+
<div class="helptext-wrapper" ?visible="${this.hasTextContent}">
|
|
1406
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
1407
|
+
</div>
|
|
1408
|
+
`;
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
var helpTextVersion = '1.0.0';
|
|
1413
|
+
|
|
1414
|
+
// Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1415
|
+
// See LICENSE in the project root for license information.
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* The auro-checkbox-group element is a wrapper for auro-checkbox element.
|
|
1420
|
+
*
|
|
1421
|
+
* @slot {HTMLSlotElement} legend - Allows for the legend to be overridden.
|
|
1422
|
+
* @slot {HTMLSlotElement} optionalLabel - Allows for the optional label to be overridden.
|
|
1423
|
+
* @slot {HTMLSlotElement} helpText - Allows for the helper text to be overridden.
|
|
1424
|
+
* @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` values have changed.
|
|
1425
|
+
*/
|
|
1426
|
+
|
|
1427
|
+
class AuroCheckboxGroup extends i$2 {
|
|
1428
|
+
constructor() {
|
|
1429
|
+
super();
|
|
1430
|
+
|
|
1431
|
+
this.validity = undefined;
|
|
1432
|
+
this.disabled = undefined;
|
|
1433
|
+
this.required = false;
|
|
1434
|
+
this.horizontal = false;
|
|
1435
|
+
this.onDark = false;
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* Indicates whether the checkbox group is in a dirty state (has been interacted with).
|
|
1439
|
+
* @type {boolean}
|
|
1440
|
+
* @default false
|
|
1441
|
+
* @private
|
|
1442
|
+
*/
|
|
1443
|
+
this.touched = false;
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* @private
|
|
1447
|
+
*/
|
|
1448
|
+
this.value = undefined;
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* @private
|
|
1452
|
+
*/
|
|
1453
|
+
this.index = 0;
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* @private
|
|
1457
|
+
*/
|
|
1458
|
+
this.maxNumber = 3;
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
* @private
|
|
1462
|
+
*/
|
|
1463
|
+
this.validation = new AuroFormValidation();
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* @private
|
|
1467
|
+
*/
|
|
1468
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils$1();
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* Generate unique names for dependency components.
|
|
1472
|
+
*/
|
|
1473
|
+
const versioning = new AuroDependencyVersioning();
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* @private
|
|
1477
|
+
*/
|
|
1478
|
+
this.helpTextTag = versioning.generateTag('auro-formkit-checkbox-helptext', helpTextVersion, AuroHelpText);
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
static get styles() {
|
|
1482
|
+
return [
|
|
1483
|
+
styleCss$1,
|
|
1484
|
+
colorCss$1,
|
|
1485
|
+
tokensCss$1
|
|
1486
|
+
];
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
static get properties() {
|
|
1490
|
+
return {
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* If set, disables the checkbox group.
|
|
1494
|
+
*/
|
|
1495
|
+
disabled: {
|
|
1496
|
+
type: Boolean,
|
|
1497
|
+
reflect: true
|
|
1498
|
+
},
|
|
1499
|
+
|
|
1500
|
+
/**
|
|
1501
|
+
* When defined, sets persistent validity to `customError` and sets the validation message to the attribute value.
|
|
1502
|
+
*/
|
|
1503
|
+
error: {
|
|
1504
|
+
type: String,
|
|
1505
|
+
reflect: true
|
|
1506
|
+
},
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* If set, checkboxes will be aligned horizontally.
|
|
1510
|
+
*/
|
|
1511
|
+
horizontal: {
|
|
1512
|
+
type: Boolean,
|
|
1513
|
+
reflect: true
|
|
1514
|
+
},
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* If set, disables auto-validation on blur.
|
|
1518
|
+
*/
|
|
1519
|
+
noValidate: {
|
|
1520
|
+
type: Boolean,
|
|
1521
|
+
reflect: true
|
|
1522
|
+
},
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* Sets onDark styles for component.
|
|
1526
|
+
*/
|
|
1527
|
+
onDark: {
|
|
1528
|
+
type: Boolean,
|
|
1529
|
+
reflect: true
|
|
1530
|
+
},
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* Populates the `required` attribute on the element. Used for client-side validation.
|
|
1534
|
+
*/
|
|
1535
|
+
required: {
|
|
1536
|
+
type: Boolean,
|
|
1537
|
+
reflect: true
|
|
1538
|
+
},
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* Sets a custom help text message to display for all validityStates.
|
|
1542
|
+
*/
|
|
1543
|
+
setCustomValidity: {
|
|
1544
|
+
type: String
|
|
1545
|
+
},
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Custom help text message to display when validity = `customError`.
|
|
1549
|
+
*/
|
|
1550
|
+
setCustomValidityCustomError: {
|
|
1551
|
+
type: String
|
|
1552
|
+
},
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* Custom help text message to display when validity = `valueMissing`.
|
|
1556
|
+
*/
|
|
1557
|
+
setCustomValidityValueMissing: {
|
|
1558
|
+
type: String
|
|
1559
|
+
},
|
|
1560
|
+
|
|
1561
|
+
/**
|
|
1562
|
+
* Specifies the `validityState` this element is in.
|
|
1563
|
+
*/
|
|
1564
|
+
validity: {
|
|
1565
|
+
type: String,
|
|
1566
|
+
reflect: true
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* This will register this element with the browser.
|
|
1573
|
+
* @param {string} [name="auro-checkbox-group"] - The name of element that you want to register to.
|
|
1574
|
+
*
|
|
1575
|
+
* @example
|
|
1576
|
+
* AuroCheckboxGroup.register("custom-checkbox-group") // this will register this element to <custom-checkbox-group/>
|
|
1577
|
+
*
|
|
1578
|
+
*/
|
|
1579
|
+
static register(name = "auro-checkbox-group") {
|
|
1580
|
+
AuroLibraryRuntimeUtils$1.prototype.registerComponent(name, AuroCheckboxGroup);
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
connectedCallback() {
|
|
1584
|
+
super.connectedCallback();
|
|
1585
|
+
this.handleItems();
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* Helper method to handle checkbox value changing.
|
|
1590
|
+
* @private
|
|
1591
|
+
* @param {String} value - The value of the checkbox.
|
|
1592
|
+
* @param {Boolean} selected - The checked state of the checkbox.
|
|
1593
|
+
* @returns {void}
|
|
1594
|
+
*/
|
|
1595
|
+
handleValueUpdate(value, selected) {
|
|
1596
|
+
if (selected) {
|
|
1597
|
+
// add if it isn't already in the value list
|
|
1598
|
+
if (!this.value.includes(value)) {
|
|
1599
|
+
this.value.push(value);
|
|
1600
|
+
}
|
|
1601
|
+
} else if (this.value.indexOf(value) > -1) { // eslint-disable-line no-magic-numbers
|
|
1602
|
+
// remove if it is in the value list
|
|
1603
|
+
const index = this.value.indexOf(value);
|
|
1604
|
+
|
|
1605
|
+
this.value.splice(index, 1);
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
this.dispatchEvent(new CustomEvent('input', {
|
|
1609
|
+
bubbles: true,
|
|
1610
|
+
cancelable: false,
|
|
1611
|
+
composed: true,
|
|
1612
|
+
}));
|
|
1613
|
+
|
|
1614
|
+
this.validate(true);
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
firstUpdated() {
|
|
1618
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
1619
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-checkbox-group');
|
|
1620
|
+
|
|
1621
|
+
// must declare this function as a variable to correctly pass the reference to the removeEventListener
|
|
1622
|
+
const checkFocusWithin = function(evt) {
|
|
1623
|
+
if (document.auroCheckboxGroupActive && !document.auroCheckboxGroupActive.contains(evt.target)) {
|
|
1624
|
+
// if focus has left the group, cleanup and validate
|
|
1625
|
+
document.auroCheckboxGroupActive.focusWithin = false;
|
|
1626
|
+
window.removeEventListener('focusin', checkFocusWithin);
|
|
1627
|
+
document.removeEventListener('click', checkFocusWithin);
|
|
1628
|
+
// execute the validation
|
|
1629
|
+
document.auroCheckboxGroupActive.validation.validate(document.auroCheckboxGroupActive);
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
|
|
1633
|
+
this.addEventListener('auroCheckbox-focusin', () => {
|
|
1634
|
+
this.touched = true;
|
|
1635
|
+
|
|
1636
|
+
if (!this.value) {
|
|
1637
|
+
this.value = [];
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// handle click outside the group
|
|
1641
|
+
if (!this.focusWithin) {
|
|
1642
|
+
document.addEventListener('click', checkFocusWithin);
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
this.focusWithin = true;
|
|
1646
|
+
});
|
|
1647
|
+
|
|
1648
|
+
this.addEventListener('auroCheckbox-focusout', () => {
|
|
1649
|
+
document.auroCheckboxGroupActive = this;
|
|
1650
|
+
|
|
1651
|
+
// Only add the focusWithin check event listener once as you move focus through the options
|
|
1652
|
+
if (this.focusWithin) {
|
|
1653
|
+
window.addEventListener('focusin', checkFocusWithin);
|
|
1654
|
+
} else {
|
|
1655
|
+
this.focusWithin = true;
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
|
|
1659
|
+
this.addEventListener('auroCheckbox-input', (evt) => {
|
|
1660
|
+
this.handleValueUpdate(evt.target.value, evt.target.checked);
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
/**
|
|
1665
|
+
* Helper method that handles the state of preselected checkboxes.
|
|
1666
|
+
* @private
|
|
1667
|
+
* @returns {void}
|
|
1668
|
+
*/
|
|
1669
|
+
handlePreselectedItems() {
|
|
1670
|
+
let preSelectedValues = false;
|
|
1671
|
+
|
|
1672
|
+
this.checkboxes.forEach((item) => {
|
|
1673
|
+
if (item.hasAttribute('checked') && this.value === undefined) {
|
|
1674
|
+
preSelectedValues = true;
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
|
|
1678
|
+
if (preSelectedValues) {
|
|
1679
|
+
if (!this.value) {
|
|
1680
|
+
this.value = [];
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
this.checkboxes.forEach((item) => {
|
|
1684
|
+
this.handleValueUpdate(item.getAttribute('value'), Boolean(item.hasAttribute('checked')));
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
/**
|
|
1690
|
+
* Helper method that handles the state of checkboxes.
|
|
1691
|
+
* @private
|
|
1692
|
+
* @returns {void}
|
|
1693
|
+
*/
|
|
1694
|
+
handleItems() {
|
|
1695
|
+
const groupTagName = this.tagName.toLowerCase();
|
|
1696
|
+
const checkboxTagName = groupTagName.substring(0, groupTagName.indexOf('-group'));
|
|
1697
|
+
|
|
1698
|
+
this.checkboxes = Array.from(this.querySelectorAll(checkboxTagName));
|
|
1699
|
+
|
|
1700
|
+
this.handlePreselectedItems();
|
|
1701
|
+
|
|
1702
|
+
this.validate();
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* Resets component to initial state.
|
|
1707
|
+
* @returns {void}
|
|
1708
|
+
*/
|
|
1709
|
+
reset() {
|
|
1710
|
+
this.checkboxes.forEach((checkbox) => {
|
|
1711
|
+
checkbox.reset();
|
|
1712
|
+
});
|
|
1713
|
+
|
|
1714
|
+
this.validation.reset(this);
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
/**
|
|
1718
|
+
* LitElement lifecycle method. Called after the DOM has been updated.
|
|
1719
|
+
* @param {Map<string, any>} changedProperties - Keys are the names of changed properties, values are the corresponding previous values.
|
|
1720
|
+
* @returns {void}
|
|
1721
|
+
*/
|
|
1722
|
+
updated(changedProperties) {
|
|
1723
|
+
if (changedProperties.has('disabled')) {
|
|
1724
|
+
this.checkboxes.forEach((el) => {
|
|
1725
|
+
if (this.disabled) {
|
|
1726
|
+
el.setAttribute('disabled', true);
|
|
1727
|
+
} else {
|
|
1728
|
+
el.removeAttribute('disabled');
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
if (changedProperties.has('validity')) {
|
|
1734
|
+
this.checkboxes.forEach((el) => {
|
|
1735
|
+
if (this.validity && this.validity !== 'valid') {
|
|
1736
|
+
el.setAttribute('error', true);
|
|
1737
|
+
} else {
|
|
1738
|
+
el.removeAttribute('error');
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
if (changedProperties.has('required')) {
|
|
1744
|
+
if (this.required) {
|
|
1745
|
+
this.setAttribute('aria-required', true);
|
|
1746
|
+
} else {
|
|
1747
|
+
this.removeAttribute('aria-required');
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
if (changedProperties.has('onDark')) {
|
|
1752
|
+
this.checkboxes.forEach((el) => {
|
|
1753
|
+
el.onDark = this.onDark;
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
if (changedProperties.has('error')) {
|
|
1758
|
+
if (this.error) {
|
|
1759
|
+
this.setAttribute('aria-invalid', true);
|
|
1760
|
+
} else {
|
|
1761
|
+
this.removeAttribute('aria-invalid');
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
this.validate(true);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* Validates value.
|
|
1770
|
+
* @param {boolean} [force=false] - Whether to force validation.
|
|
1771
|
+
*/
|
|
1772
|
+
validate(force = false) {
|
|
1773
|
+
this.validation.validate(this, force);
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
render() {
|
|
1777
|
+
const groupClasses = {
|
|
1778
|
+
'displayFlex': this.horizontal && this.checkboxes.length <= this.maxNumber
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1781
|
+
return u`
|
|
1782
|
+
<fieldset class="${e(groupClasses)}">
|
|
1783
|
+
${this.required
|
|
1784
|
+
? u`<legend><slot name="legend"></slot></legend>`
|
|
1785
|
+
: u`<legend><slot name="legend"></slot> (optional)</legend>`
|
|
1786
|
+
}
|
|
1787
|
+
<slot @slotchange=${this.handleItems}></slot>
|
|
1788
|
+
</fieldset>
|
|
1789
|
+
|
|
1790
|
+
${!this.validity || this.validity === undefined || this.validity === 'valid'
|
|
1791
|
+
? u`
|
|
1792
|
+
<${this.helpTextTag} large part="helpText" ?onDark="${this.onDark}">
|
|
1793
|
+
<slot name="helpText"></slot>
|
|
1794
|
+
</${this.helpTextTag}>`
|
|
1795
|
+
: u`
|
|
1796
|
+
<${this.helpTextTag} error large ?onDark="${this.onDark}" role="alert" aria-live="assertive" part="helpText">
|
|
1797
|
+
${this.errorMessage}
|
|
1798
|
+
</${this.helpTextTag}>`
|
|
1799
|
+
}
|
|
1800
|
+
`;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
AuroCheckbox.register(); // registering to `auro-checkbox`
|
|
1805
|
+
AuroCheckboxGroup.register(); // registering to `auro-checkbox-group`
|
|
1806
|
+
|
|
1807
|
+
AuroCheckbox.register('custom-checkbox');
|
|
1808
|
+
AuroCheckboxGroup.register('custom-checkbox-group');
|