@ukho/admiralty-core 0.15.0 → 0.16.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.
@@ -1,2 +1,2 @@
1
- import{p as a,b as e}from"./p-ac0ad15a.js";export{s as setNonce}from"./p-ac0ad15a.js";import{g as i}from"./p-e1255160.js";var l=()=>{const e=import.meta.url;const i={};if(e!==""){i.resourcesUrl=new URL(".",e).href}return a(i)};l().then((async a=>{await i();return e([["p-0c600251",[[6,"admiralty-type-ahead",{value:[1],label:[1],hint:[1],placeholder:[1],resultsOnInitFocus:[4,"results-on-init-focus"],filterResult:[32]}]]],["p-caf28231",[[2,"admiralty-autocomplete",{autoselect:[4],cssNamespace:[1,"css-namespace"],displayMenu:[1,"display-menu"],minLength:[2,"min-length"],name:[1],placeholder:[1],confirmOnBlur:[4,"confirm-on-blur"],showNoOptionsFound:[4,"show-no-options-found"],showAllValues:[4,"show-all-values"],required:[4],assistiveHint:[1,"assistive-hint"],menuAttributes:[8,"menu-attributes"],inputClasses:[1,"input-classes"],menuClasses:[1,"menu-classes"],label:[1],hint:[1],invalid:[4],invalidMessage:[1,"invalid-message"],disabled:[4],value:[1025],focused:[32],hovered:[32],menuOpen:[32],options:[32],option:[32],query:[32],validChoiceMade:[32],selected:[32],ariaHint:[32]},null,{value:["onValueChange"],focused:["onFocusedChange"]}]]],["p-ea845f4a",[[6,"admiralty-select",{disabled:[4],invalid:[4],invalidMessage:[1,"invalid-message"],hint:[1],label:[1],width:[2],value:[1032]},null,{value:["valueChanged"]}]]],["p-abb4639b",[[2,"admiralty-textarea",{label:[1],hint:[1],width:[2],maxLength:[2,"max-length"],disabled:[4],invalid:[4],invalidMessage:[1,"invalid-message"],value:[1032]},null,{value:["valueChanged"]}]]],["p-5a8e43f2",[[6,"admiralty-colour-block",{width:[2],height:[2],heading:[1],colour:[1],actionText:[1,"action-text"]}]]],["p-4e73bd73",[[2,"admiralty-file-input",{label:[1],multiple:[4],invalid:[4],invalidMessage:[1,"invalid-message"],files:[32]}]]],["p-a2ae15a3",[[6,"admiralty-filter",{filterTitle:[1,"filter-title"]}]]],["p-afadb041",[[6,"admiralty-filter-group",{groupTitle:[1,"group-title"]}]]],["p-55648914",[[2,"admiralty-paginator",{pages:[2],currentPage:[2,"current-page"],label:[1]}]]],["p-13eab822",[[6,"admiralty-radio-group",{name:[1],value:[1032],displayVertical:[4,"display-vertical"],invalid:[4],invalidMessage:[1,"invalid-message"]},null,{value:["valueChanged"],invalid:["invalidChanged"]}]]],["p-b743ca74",[[6,"admiralty-breadcrumb",{active:[4],first:[4],href:[1]}]]],["p-77549f7b",[[6,"admiralty-dialogue",{type:[1],heading:[1]}]]],["p-0e66fea2",[[6,"admiralty-header",{headerTitle:[1,"header-title"],headerTitleUrl:[1,"header-title-url"],logoLinkUrl:[1,"logo-link-url"],logoImgUrl:[1,"logo-img-url"],logoAltText:[1,"logo-alt-text"],mobileMenuOpen:[32],displayHamburger:[32]}]]],["p-e9ff954f",[[2,"admiralty-progress-bar",{label:[1],progression:[2],error:[4],progressionValue:[32]},null,{progression:["progressionChanged"]}]]],["p-2780d617",[[6,"admiralty-read-more",{heading:[1],expanded:[32]}]]],["p-ae23a899",[[2,"admiralty-autocomplete-option",{value:[8]}]]],["p-298fe86e",[[6,"admiralty-breadcrumbs"]]],["p-00bdb9a8",[[6,"admiralty-card",{heading:[1]}]]],["p-5fb35437",[[2,"admiralty-checkbox",{checkboxRight:[4,"checkbox-right"],disabled:[4],name:[1],checked:[1028],value:[8],labelText:[1,"label-text"]},null,{checked:["checkedChanged"]}]]],["p-675fb90c",[[6,"admiralty-footer",{imageLink:[1,"image-link"],imageSrc:[1,"image-src"],imageAlt:[1,"image-alt"],text:[1]}]]],["p-99d0a688",[[6,"admiralty-header-menu-item",{menuTitle:[1,"menu-title"],active:[4]}]]],["p-ba35abbe",[[2,"admiralty-header-profile",{isSignedIn:[4,"is-signed-in"],signedInText:[1,"signed-in-text"],signInOnly:[4,"sign-in-only"]}]]],["p-5585be8a",[[2,"admiralty-header-sub-menu-item",{menuTitle:[1,"menu-title"]}]]],["p-aaf7fb89",[[2,"admiralty-hr"]]],["p-bfb87bdb",[[6,"admiralty-link",{href:[1],newTab:[4,"new-tab"]}]]],["p-e13daa98",[[6,"admiralty-modal-dialog",{heading:[1],label:[1],description:[1],show:[4]}]]],["p-6f84528b",[[4,"admiralty-paginator-wrapper",null,[[0,"pageChange","pageChangedHandler"]]]]],["p-6def54c9",[[2,"admiralty-phase-banner",{phase:[1],link:[1]}]]],["p-73bfd052",[[6,"admiralty-radio",{name:[1],value:[1025],disabled:[4],checked:[1028],invalid:[4],buttonTabindex:[32],setButtonTabindex:[64]},null,{value:["valueChanged"]}]]],["p-bc290da9",[[6,"admiralty-side-nav",{label:[1]}]]],["p-a08bec80",[[2,"admiralty-side-nav-item",{sideNavItemId:[1,"side-nav-item-id"],headingTitle:[1,"heading-title"],navActive:[4,"nav-active"]}]]],["p-60b9c4d4",[[4,"admiralty-side-nav-wrapper",null,[[0,"sideNavItemSelected","onSideNavItemSelected"]]]]],["p-88b9303c",[[2,"admiralty-skip-link",{href:[1]}]]],["p-aa6c608f",[[6,"admiralty-tab",{label:[1],tabLabelId:[1,"tab-label-id"],tabContentId:[1,"tab-content-id"]}]]],["p-79e7da4b",[[6,"admiralty-tab-group",{selectedIndex:[1026,"selected-index"]}]]],["p-1e1935af",[[6,"admiralty-table",{caption:[1]}]]],["p-4c25b2d6",[[6,"admiralty-table-body"]]],["p-4d3c0cdc",[[6,"admiralty-table-cell"]]],["p-2943fbbb",[[6,"admiralty-table-header"]]],["p-003aa9ce",[[6,"admiralty-table-header-cell"]]],["p-f2f92bbf",[[6,"admiralty-table-row"]]],["p-a4d60733",[[2,"admiralty-type-ahead-item",{value:[1]}]]],["p-d93164bf",[[1,"admiralty-icon",{iconName:[1,"icon-name"],iconPrefix:[1,"icon-prefix"]}]]],["p-cf2bfbae",[[2,"admiralty-input",{name:[1],label:[1],hint:[1],disabled:[4],type:[1],placeholder:[1],width:[2],maxLength:[2,"max-length"],required:[4],invalid:[4],invalidMessage:[1,"invalid-message"],autocomplete:[1],value:[1032]},null,{value:["valueChanged"]}]]],["p-68a54540",[[6,"admiralty-expansion",{heading:[1],expanded:[1540],alignHeadingRight:[4,"align-heading-right"],hideBorder:[4,"hide-border"]}]]],["p-b4465943",[[6,"admiralty-button",{variant:[1],icon:[1],disabled:[516],type:[1]}]]],["p-6492124b",[[6,"admiralty-hint",{disabled:[4]}],[6,"admiralty-label",{disabled:[4],for:[1]}],[6,"admiralty-input-invalid"]]]],a)}));
1
+ import{p as a,b as e}from"./p-ac0ad15a.js";export{s as setNonce}from"./p-ac0ad15a.js";import{g as i}from"./p-e1255160.js";var l=()=>{const e=import.meta.url;const i={};if(e!==""){i.resourcesUrl=new URL(".",e).href}return a(i)};l().then((async a=>{await i();return e([["p-6229741b",[[6,"admiralty-type-ahead",{value:[1],label:[1],hint:[1],placeholder:[1],resultsOnInitFocus:[4,"results-on-init-focus"],filterResult:[32]}]]],["p-caf28231",[[2,"admiralty-autocomplete",{autoselect:[4],cssNamespace:[1,"css-namespace"],displayMenu:[1,"display-menu"],minLength:[2,"min-length"],name:[1],placeholder:[1],confirmOnBlur:[4,"confirm-on-blur"],showNoOptionsFound:[4,"show-no-options-found"],showAllValues:[4,"show-all-values"],required:[4],assistiveHint:[1,"assistive-hint"],menuAttributes:[8,"menu-attributes"],inputClasses:[1,"input-classes"],menuClasses:[1,"menu-classes"],label:[1],hint:[1],invalid:[4],invalidMessage:[1,"invalid-message"],disabled:[4],value:[1025],focused:[32],hovered:[32],menuOpen:[32],options:[32],option:[32],query:[32],validChoiceMade:[32],selected:[32],ariaHint:[32]},null,{value:["onValueChange"],focused:["onFocusedChange"]}]]],["p-ea845f4a",[[6,"admiralty-select",{disabled:[4],invalid:[4],invalidMessage:[1,"invalid-message"],hint:[1],label:[1],width:[2],value:[1032]},null,{value:["valueChanged"]}]]],["p-abb4639b",[[2,"admiralty-textarea",{label:[1],hint:[1],width:[2],maxLength:[2,"max-length"],disabled:[4],invalid:[4],invalidMessage:[1,"invalid-message"],value:[1032]},null,{value:["valueChanged"]}]]],["p-5a8e43f2",[[6,"admiralty-colour-block",{width:[2],height:[2],heading:[1],colour:[1],actionText:[1,"action-text"]}]]],["p-4e73bd73",[[2,"admiralty-file-input",{label:[1],multiple:[4],invalid:[4],invalidMessage:[1,"invalid-message"],files:[32]}]]],["p-a2ae15a3",[[6,"admiralty-filter",{filterTitle:[1,"filter-title"]}]]],["p-afadb041",[[6,"admiralty-filter-group",{groupTitle:[1,"group-title"]}]]],["p-55648914",[[2,"admiralty-paginator",{pages:[2],currentPage:[2,"current-page"],label:[1]}]]],["p-13eab822",[[6,"admiralty-radio-group",{name:[1],value:[1032],displayVertical:[4,"display-vertical"],invalid:[4],invalidMessage:[1,"invalid-message"]},null,{value:["valueChanged"],invalid:["invalidChanged"]}]]],["p-b743ca74",[[6,"admiralty-breadcrumb",{active:[4],first:[4],href:[1]}]]],["p-77549f7b",[[6,"admiralty-dialogue",{type:[1],heading:[1]}]]],["p-0e66fea2",[[6,"admiralty-header",{headerTitle:[1,"header-title"],headerTitleUrl:[1,"header-title-url"],logoLinkUrl:[1,"logo-link-url"],logoImgUrl:[1,"logo-img-url"],logoAltText:[1,"logo-alt-text"],mobileMenuOpen:[32],displayHamburger:[32]}]]],["p-e9ff954f",[[2,"admiralty-progress-bar",{label:[1],progression:[2],error:[4],progressionValue:[32]},null,{progression:["progressionChanged"]}]]],["p-2780d617",[[6,"admiralty-read-more",{heading:[1],expanded:[32]}]]],["p-ae23a899",[[2,"admiralty-autocomplete-option",{value:[8]}]]],["p-298fe86e",[[6,"admiralty-breadcrumbs"]]],["p-00bdb9a8",[[6,"admiralty-card",{heading:[1]}]]],["p-5fb35437",[[2,"admiralty-checkbox",{checkboxRight:[4,"checkbox-right"],disabled:[4],name:[1],checked:[1028],value:[8],labelText:[1,"label-text"]},null,{checked:["checkedChanged"]}]]],["p-675fb90c",[[6,"admiralty-footer",{imageLink:[1,"image-link"],imageSrc:[1,"image-src"],imageAlt:[1,"image-alt"],text:[1]}]]],["p-99d0a688",[[6,"admiralty-header-menu-item",{menuTitle:[1,"menu-title"],active:[4]}]]],["p-ba35abbe",[[2,"admiralty-header-profile",{isSignedIn:[4,"is-signed-in"],signedInText:[1,"signed-in-text"],signInOnly:[4,"sign-in-only"]}]]],["p-5585be8a",[[2,"admiralty-header-sub-menu-item",{menuTitle:[1,"menu-title"]}]]],["p-aaf7fb89",[[2,"admiralty-hr"]]],["p-bfb87bdb",[[6,"admiralty-link",{href:[1],newTab:[4,"new-tab"]}]]],["p-e13daa98",[[6,"admiralty-modal-dialog",{heading:[1],label:[1],description:[1],show:[4]}]]],["p-6f84528b",[[4,"admiralty-paginator-wrapper",null,[[0,"pageChange","pageChangedHandler"]]]]],["p-6def54c9",[[2,"admiralty-phase-banner",{phase:[1],link:[1]}]]],["p-73bfd052",[[6,"admiralty-radio",{name:[1],value:[1025],disabled:[4],checked:[1028],invalid:[4],buttonTabindex:[32],setButtonTabindex:[64]},null,{value:["valueChanged"]}]]],["p-bc290da9",[[6,"admiralty-side-nav",{label:[1]}]]],["p-a08bec80",[[2,"admiralty-side-nav-item",{sideNavItemId:[1,"side-nav-item-id"],headingTitle:[1,"heading-title"],navActive:[4,"nav-active"]}]]],["p-60b9c4d4",[[4,"admiralty-side-nav-wrapper",null,[[0,"sideNavItemSelected","onSideNavItemSelected"]]]]],["p-88b9303c",[[2,"admiralty-skip-link",{href:[1]}]]],["p-aa6c608f",[[6,"admiralty-tab",{label:[1],tabLabelId:[1,"tab-label-id"],tabContentId:[1,"tab-content-id"]}]]],["p-79e7da4b",[[6,"admiralty-tab-group",{selectedIndex:[1026,"selected-index"]}]]],["p-1e1935af",[[6,"admiralty-table",{caption:[1]}]]],["p-4c25b2d6",[[6,"admiralty-table-body"]]],["p-4d3c0cdc",[[6,"admiralty-table-cell"]]],["p-2943fbbb",[[6,"admiralty-table-header"]]],["p-003aa9ce",[[6,"admiralty-table-header-cell"]]],["p-f2f92bbf",[[6,"admiralty-table-row"]]],["p-a4d60733",[[2,"admiralty-type-ahead-item",{value:[1]}]]],["p-d93164bf",[[1,"admiralty-icon",{iconName:[1,"icon-name"],iconPrefix:[1,"icon-prefix"]}]]],["p-cf2bfbae",[[2,"admiralty-input",{name:[1],label:[1],hint:[1],disabled:[4],type:[1],placeholder:[1],width:[2],maxLength:[2,"max-length"],required:[4],invalid:[4],invalidMessage:[1,"invalid-message"],autocomplete:[1],value:[1032]},null,{value:["valueChanged"]}]]],["p-68a54540",[[6,"admiralty-expansion",{heading:[1],expanded:[1540],alignHeadingRight:[4,"align-heading-right"],hideBorder:[4,"hide-border"]}]]],["p-b4465943",[[6,"admiralty-button",{variant:[1],icon:[1],disabled:[516],type:[1]}]]],["p-1fd9acd6",[[6,"admiralty-hint",{disabled:[4]}],[6,"admiralty-label",{disabled:[4],for:[1]}],[6,"admiralty-input-invalid"]]]],a)}));
2
2
  //# sourceMappingURL=admiralty.esm.js.map
@@ -0,0 +1,2 @@
1
+ import{r as a,h as e,H as d}from"./p-ac0ad15a.js";import{a as t}from"./p-a28a614b.js";const i="p.sc-admiralty-hint{margin-top:0;margin-bottom:6px;display:block;font-weight:300}p.disabled.sc-admiralty-hint{color:#adadad}";const c=i;const s=class{constructor(e){a(this,e);this.disabled=undefined}render(){return e("p",{key:"d5c32ab0bb0416a7f1e10ae3c134477785cd9c2b",class:{disabled:this.disabled}},e("slot",{key:"2f34effc00bded2b043d3e6329a6d3f1d9e8ba0e"}))}};s.style=c;const l=".sc-admiralty-input-invalid-h{display:flex;align-items:center}admiralty-icon.sc-admiralty-input-invalid{color:#e20d0d;margin:4px 0}p.sc-admiralty-input-invalid{margin:0;color:#e20d0d}";const n=l;const r=class{constructor(e){a(this,e)}render(){return e(d,{key:"9267bec797b4495d10b0a5095c7406a8b9d45189"},e("admiralty-icon",{key:"4d2be552269678fb718cc1a431e8e734602c7dcf","icon-name":t.iconName,class:"error-icon"}),e("p",{key:"2bdee004583f330f204e3601e2dc6fa6dee5759e"},e("slot",{key:"5544283b85989a983a59a2cce4eb4f6de6fae41e"})))}};r.style=n;const o="label.sc-admiralty-label{margin-bottom:6px;display:inline-block;font-weight:normal}label.disabled.sc-admiralty-label{color:#adadad}";const b=o;const m=class{constructor(e){a(this,e);this.disabled=undefined;this.for=undefined}render(){return e("label",{key:"685f1ed5184b955228654c935f24b45efe7b84b0",htmlFor:this.for,class:{disabled:this.disabled}},e("slot",{key:"561906355acbccdaf9cdc12fd09225bae6946d50"}))}};m.style=b;export{s as admiralty_hint,r as admiralty_input_invalid,m as admiralty_label};
2
+ //# sourceMappingURL=p-1fd9acd6.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hintCss","AdmiraltyHintStyle0","HintComponent","render","h","key","class","disabled","this","inputInvalidCss","AdmiraltyInputInvalidStyle0","InputInvalidComponent","Host","faExclamation","iconName","labelCss","AdmiraltyLabelStyle0","LabelComponent","htmlFor","for"],"sources":["src/components/hint/hint.scss?tag=admiralty-hint&encapsulation=scoped","src/components/hint/hint.tsx","src/components/input-invalid/input-invalid.scss?tag=admiralty-input-invalid&encapsulation=scoped","src/components/input-invalid/input-invalid.tsx","src/components/label/label.scss?tag=admiralty-label&encapsulation=scoped","src/components/label/label.tsx"],"sourcesContent":["@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\np {\n margin-top: 0;\n margin-bottom: 6px;\n display: block;\n font-weight: typography.$font-weight-light;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The hint content should be placed in the slot e.g.\n * `<admiralty-hint>Enter your full name</admiralty-hint>`\n */\n@Component({\n tag: 'admiralty-hint',\n styleUrl: 'hint.scss',\n scoped: true,\n})\nexport class HintComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n render() {\n return (\n <p class={{ disabled: this.disabled }}>\n <slot></slot>\n </p>\n );\n }\n}\n","@use '../../scss/vars/colours';\n\n:host {\n display: flex;\n align-items: center;\n}\n\nadmiralty-icon {\n color: colours.$colour-utility-error;\n margin: 4px 0;\n}\n\np {\n margin: 0;\n color: colours.$colour-utility-error;\n}\n","import { Component, h, Host } from '@stencil/core';\nimport { faExclamation } from '@fortawesome/free-solid-svg-icons';\n\n/**\n * @slot - The error content should be placed in the slot e.g.\n * `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`\n */\n@Component({\n tag: 'admiralty-input-invalid',\n styleUrl: 'input-invalid.scss',\n scoped: true,\n})\nexport class InputInvalidComponent {\n render() {\n return (\n <Host>\n <admiralty-icon icon-name={faExclamation.iconName} class=\"error-icon\"></admiralty-icon>\n <p>\n <slot></slot>\n </p>\n </Host>\n );\n }\n}\n","@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\nlabel {\n margin-bottom: 6px;\n display: inline-block;\n font-weight: typography.$font-weight-medium;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The label content should be placed in the slot e.g.\n * `<admiralty-label>First Name</admiralty-label>`\n */\n@Component({\n tag: 'admiralty-label',\n styleUrl: 'label.scss',\n scoped: true,\n})\nexport class LabelComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n /**\n * The id of the input the label is attached to\n */\n @Prop() for: string;\n\n render() {\n return (\n <label htmlFor={this.for} class={{ disabled: this.disabled }}>\n <slot></slot>\n </label>\n );\n }\n}\n"],"mappings":"sFAAA,MAAMA,EAAU,+HAChB,MAAAC,EAAeD,E,MCUFE,EAAa,M,iDAMxB,MAAAC,GACE,OACEC,EAAA,KAAAC,IAAA,2CAAGC,MAAO,CAAEC,SAAUC,KAAKD,WACzBH,EAAA,QAAAC,IAAA,6C,aCpBR,MAAMI,EAAkB,0LACxB,MAAAC,EAAeD,E,MCWFE,EAAqB,M,yBAChC,MAAAR,GACE,OACEC,EAACQ,EAAI,CAAAP,IAAA,4CACHD,EAAA,kBAAAC,IAAA,uDAA2BQ,EAAcC,SAAUR,MAAM,eACzDF,EAAA,KAAAC,IAAA,4CACED,EAAA,QAAAC,IAAA,8C,aClBV,MAAMU,EAAW,sIACjB,MAAAC,EAAeD,E,MCUFE,EAAc,M,oEAWzB,MAAAd,GACE,OACEC,EAAA,SAAAC,IAAA,2CAAOa,QAASV,KAAKW,IAAKb,MAAO,CAAEC,SAAUC,KAAKD,WAChDH,EAAA,QAAAC,IAAA,6C"}
@@ -1,2 +1,2 @@
1
- import{r as t,c as a,f as e,h as i,H as s,g as h}from"./p-ac0ad15a.js";import{K as d}from"./p-a4bd6904.js";const n='@charset "UTF-8";.visually-hidden.sc-admiralty-type-ahead:not(:focus):not(:active){position:absolute !important;width:1px !important;height:1px !important;margin:0 !important;padding:0 !important;overflow:hidden !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;border:0 !important;white-space:nowrap !important}@media (max-width: 1023px){.desktop-only.sc-admiralty-type-ahead{display:none}}@media (min-width: 1024px){.not-desktop.sc-admiralty-type-ahead{display:none}}@media (min-width: 1024px){.tablet-only.sc-admiralty-type-ahead{display:none}}@media (max-width: 479px) and (min-width: 0px){.tablet-only.sc-admiralty-type-ahead{display:none}}@media (max-width: 479px) and (min-width: 0px){.tablet-or-desktop.sc-admiralty-type-ahead{display:none}}@media (min-width: 1024px){.phone-or-tablet.sc-admiralty-type-ahead{display:none}}@media (min-width: 1024px){.phone-only.sc-admiralty-type-ahead{display:none}}@media (max-width: 1023px) and (min-width: 480px){.phone-only.sc-admiralty-type-ahead{display:none}}*.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;font-size:18px;line-height:24px;font-weight:300;color:#333333}@media (max-width: 1023px){*.sc-admiralty-type-ahead{font-size:16px}}a.sc-admiralty-type-ahead{color:#09315b}a.sc-admiralty-type-ahead:focus{outline:3px solid #ffdd00;outline-offset:1px}h1.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;color:#09315b;font-weight:normal;font-size:48px;line-height:60px;margin:0 0 30px 0}@media (max-width: 1023px){h1.sc-admiralty-type-ahead{font-size:46px;line-height:54px}}h2.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;color:#09315b;font-weight:normal;font-size:36px;line-height:48px;margin-bottom:18px}@media (max-width: 1023px){h2.sc-admiralty-type-ahead{font-size:34px;line-height:42px}}h3.sc-admiralty-type-ahead,h4.sc-admiralty-type-ahead,h5.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;color:#09315b;font-weight:normal;font-size:21px;line-height:30px;margin-bottom:12px}@media (max-width: 1023px){h3.sc-admiralty-type-ahead,h4.sc-admiralty-type-ahead,h5.sc-admiralty-type-ahead{font-size:20px;line-height:30px}}h6.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;color:#09315b;font-weight:normal;font-size:18px;line-height:24px;margin-bottom:12px}@media (max-width: 1023px){h6.sc-admiralty-type-ahead{font-size:16px}}p.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;margin-bottom:30px}.intro.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;font-size:28px;line-height:36px;margin-bottom:30px}@media (max-width: 1023px){.intro.sc-admiralty-type-ahead{font-size:26px}}.small.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;font-size:16px}@media (max-width: 1023px){.small.sc-admiralty-type-ahead{font-size:14px;line-height:22px}}blockquote.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;line-height:30px;width:100%;padding:24px 18px;border-left:5px solid #09315b;margin-bottom:30px;background:#eeeeee}@media (max-width: 1023px){blockquote.sc-admiralty-type-ahead{line-height:24px}}ul.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;list-style:none}ul.sc-admiralty-type-ahead a.sc-admiralty-type-ahead{font-weight:300}ul.sc-admiralty-type-ahead li.sc-admiralty-type-ahead{margin-bottom:12px}ul.sc-admiralty-type-ahead li.sc-admiralty-type-ahead:before{content:"■";font-size:18px;color:#09315b;vertical-align:text-bottom;margin-right:12px}@media (max-width: 1023px){ul.sc-admiralty-type-ahead li.sc-admiralty-type-ahead:before{font-size:8px}}ol.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;list-style:none;counter-reset:li}ol.sc-admiralty-type-ahead a.sc-admiralty-type-ahead{font-weight:300}ol.sc-admiralty-type-ahead li.sc-admiralty-type-ahead:before{content:counter(li) ".";color:#03284f;font-size:18px;margin-right:12px}ol.sc-admiralty-type-ahead li.sc-admiralty-type-ahead{counter-increment:li;margin-bottom:12px}.white-text.sc-admiralty-type-ahead *.sc-admiralty-type-ahead{color:#ffffff}*.sc-admiralty-type-ahead{margin:0px;padding:0px}.text-input-wrap.sc-admiralty-type-ahead{height:auto !important}.filterTextInput.sc-admiralty-type-ahead{width:100%}.typeahead-list-container.sc-admiralty-type-ahead{position:relative}.typeahead-list-container.sc-admiralty-type-ahead .typeahead-list.sc-admiralty-type-ahead{position:absolute;left:0px;top:-24px;background-color:#ffffff;width:100%;box-shadow:0px 4px 4px rgba(0, 0, 0, 0.25);border:2px solid #333333;border-top:none;box-sizing:border-box;max-height:180px;overflow-y:auto;z-index:1;list-style:none}.typeahead-list-container.sc-admiralty-type-ahead .typeahead-list.sc-admiralty-type-ahead li.sc-admiralty-type-ahead{cursor:pointer;transform:unset !important;padding:6px;min-height:24px;margin:0}.typeahead-list-container.sc-admiralty-type-ahead .typeahead-list.sc-admiralty-type-ahead li.sc-admiralty-type-ahead:before{content:none}.typeahead-list-container.sc-admiralty-type-ahead .typeahead-list.sc-admiralty-type-ahead li.highlighted.sc-admiralty-type-ahead{background-color:#09315b;color:#ffffff}';const l=n;const o=class{constructor(e){t(this,e);this.selectionChanged=a(this,"selectionChanged",7);this.valueChanged=a(this,"valueChanged",7);this._id=`admiralty-typeahead-${++r}`;this.hintId=`${this._id}-assistive-hint`;this.listId=`${this._id}-list`;this.filterList=[];this.selectedItemIndex=-1;this.isFocused=false;this.isSilenced=false;this.isAlternateStatusSection=false;this.originalSearch="";this.hasBeenFocusedAtLeastOnce=false;this.filterResult=new Array;this.value=undefined;this.label=undefined;this.hint=undefined;this.placeholder=undefined;this.resultsOnInitFocus=false}get inputValue(){return this.inputControl.value.toString()}set inputValue(t){this.inputControl.value=t}componentDidLoad(){if(this.value){this.inputValue=this.value}}connectedCallback(){this.mutation=new MutationObserver((()=>{this.populateFilterList();e(this)}));this.mutation.observe(this.el,{childList:true,subtree:true})}disconnectedCallback(){if(this.mutation){this.mutation.disconnect();this.mutation=undefined}}populateFilterList(){const t=this.el.querySelectorAll("admiralty-type-ahead-item");this.filterList=[];t.forEach((t=>{this.filterList.push(t.getAttribute("value"));console.log("fliterlist value ",t.getAttribute("value"))}))}handleFocusIn(){if(this.resultsOnInitFocus&&!this.hasBeenFocusedAtLeastOnce){this.performFilter("");this.hasBeenFocusedAtLeastOnce=true}this.isFocused=true;this.isSilenced=false}handleFocusOut(){this.isFocused=false;this.statusText=null;this.isSilenced=true}textChanged(t){this.originalSearch=t;this.performFilter(t);this.isSilenced=false;this.valueChanged.emit(t)}handleKeyPressed(t){t.stopImmediatePropagation();if(t.key===d.UP_ARROW||t.key===d.DOWN_ARROW){this.navigateSuggestions(t.key);this.updateScroll()}else if(t.key!==d.ENTER){this.textChanged(this.inputValue);this.selectCurrentItem()}}handleKeyDown(t){t.stopImmediatePropagation();if(t.key===d.TAB||t.key===d.ENTER){this.selectCurrentItem()}}handleItemSelected(t){this.inputValue=t;this.textChanged(t);this.filterResult=new Array;this.selectionChanged.emit(t)}performFilter(t){const a=(t,a)=>{const e=t.filter((t=>a===null||a.length<1||t.toLowerCase().indexOf(a.toLowerCase())>-1));return e};this.filterResult=a(this.filterList,t);this.selectedItemIndex=-1}addHighlight(){if(this.selectedItemIndex>-1){const t=this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);t.classList.add("highlighted")}}removeHighlight(t){if(t>-1){const a=this.el.querySelector(`#${this.getListItemId(t)}`);a.classList.remove("highlighted")}}selectCurrentItem(){if(this.selectedItemIndex>=0){const t=this.filterResult[this.selectedItemIndex];this.handleItemSelected(t)}}handleItemHovered(t){this.removeHighlight(this.selectedItemIndex);this.selectedItemIndex=t;this.addHighlight()}handleComponentFocusOut(){var t;if(((t=this.filterResult)===null||t===void 0?void 0:t.length)>0){this.filterResult=new Array;this.hasBeenFocusedAtLeastOnce=false}}updateScroll(){const t=this.listContainer;const a=t.querySelector("ul");const e=Array.from(a.childNodes).find((t=>t.ariaPosInSet===`${this.selectedItemIndex+1}`));if(t&&e&&t.scrollHeight+t.clientHeight){e.scrollIntoView()}}navigateSuggestions(t){if(t===d.UP_ARROW){this.removeHighlight(this.selectedItemIndex);this.selectedItemIndex--;if(this.selectedItemIndex===-2){this.selectedItemIndex=this.filterResult.length-1}}if(t===d.DOWN_ARROW){this.removeHighlight(this.selectedItemIndex);this.selectedItemIndex++;if(this.selectedItemIndex>this.filterResult.length-1){this.selectedItemIndex=-1}}if(this.selectedItemIndex===-1){this.inputValue=this.originalSearch}else{const t=this.filterResult[this.selectedItemIndex];this.inputValue=t;this.addHighlight()}}getListItemId(t){return`${this.listId}-item-${t}`}render(){return i(s,{key:"9c58ee688918a293bda88a9cf0150214510f7bc0",onFocusout:t=>this.handleComponentFocusOut()},i("div",{key:"3144d016e0594a18e4dc6d473c32599fae8c01d3",class:"visually-hidden"},i("div",{key:"e6c3c437cb4e12158b8ea880ce21c7908b68a638",class:"results-status-a",role:"status","aria-atomic":"true","aria-live":"polite"},!this.isSilenced&&this.isAlternateStatusSection?this.statusText:""),i("div",{key:"c35e28c3de7e3fb97f9e0c8aab2d3a34f658000b",class:"results-status-b",role:"status","aria-atomic":"true","aria-live":"polite"},!this.isSilenced&&!this.isAlternateStatusSection?this.statusText:"")),i("admiralty-input",{key:"88c82941c54dbad9fea476dbd5ec8b0c88efc1b8",type:"text",ref:t=>this.inputControl=t,label:this.label,hint:this.hint,placeholder:this.placeholder,class:"filterTextInput",onKeyUp:t=>this.handleKeyPressed(t),onKeyDown:t=>this.handleKeyDown(t),onFocusin:t=>this.handleFocusIn(),onFocusout:t=>this.handleFocusOut(),"aria-expanded":this.isFocused&&this.filterResult.length>0}),i("span",{key:"3959c94636207a7fcefeabda1ab693f1aa0e2204",id:this.hintId,class:"visually-hidden"},"When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."),this.filterResult.length>0?i("div",{class:"typeahead-list-container",ref:t=>this.listContainer=t},i("ul",{class:"typeahead-list",id:this.listId,role:"listbox"},this.filterResult.map(((t,a)=>i("li",{id:this.getListItemId(a),onMouseDown:a=>this.handleItemSelected(t),onMouseOver:t=>this.handleItemHovered(a),"aria-selected":a===this.selectedItemIndex,role:"option",tabindex:"-1","aria-posinset":a+1,"aria-setsize":this.filterResult.length},t))))):null,i("slot",{key:"bf5408374f50291a4adfa81cd23b4346712bbd8a"}))}get el(){return h(this)}};let r=0;o.style=l;export{o as admiralty_type_ahead};
2
- //# sourceMappingURL=p-0c600251.entry.js.map
1
+ import{r as t,c as a,f as e,h as i,H as s,g as h}from"./p-ac0ad15a.js";import{K as d}from"./p-a4bd6904.js";const n='@charset "UTF-8";.visually-hidden.sc-admiralty-type-ahead:not(:focus):not(:active){position:absolute !important;width:1px !important;height:1px !important;margin:0 !important;padding:0 !important;overflow:hidden !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;border:0 !important;white-space:nowrap !important}@media (max-width: 1023px){.desktop-only.sc-admiralty-type-ahead{display:none}}@media (min-width: 1024px){.not-desktop.sc-admiralty-type-ahead{display:none}}@media (min-width: 1024px){.tablet-only.sc-admiralty-type-ahead{display:none}}@media (max-width: 479px) and (min-width: 0px){.tablet-only.sc-admiralty-type-ahead{display:none}}@media (max-width: 479px) and (min-width: 0px){.tablet-or-desktop.sc-admiralty-type-ahead{display:none}}@media (min-width: 1024px){.phone-or-tablet.sc-admiralty-type-ahead{display:none}}@media (min-width: 1024px){.phone-only.sc-admiralty-type-ahead{display:none}}@media (max-width: 1023px) and (min-width: 480px){.phone-only.sc-admiralty-type-ahead{display:none}}*.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;font-size:18px;line-height:24px;font-weight:300;color:#333333}@media (max-width: 1023px){*.sc-admiralty-type-ahead{font-size:16px}}a.sc-admiralty-type-ahead{color:#09315b}a.sc-admiralty-type-ahead:focus{outline:3px solid #ffdd00;outline-offset:1px}h1.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;color:#09315b;font-weight:normal;font-size:48px;line-height:60px;margin:0 0 30px 0}@media (max-width: 1023px){h1.sc-admiralty-type-ahead{font-size:46px;line-height:54px}}h2.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;color:#09315b;font-weight:normal;font-size:36px;line-height:48px;margin-bottom:18px}@media (max-width: 1023px){h2.sc-admiralty-type-ahead{font-size:34px;line-height:42px}}h3.sc-admiralty-type-ahead,h4.sc-admiralty-type-ahead,h5.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;color:#09315b;font-weight:normal;font-size:21px;line-height:30px;margin-bottom:12px}@media (max-width: 1023px){h3.sc-admiralty-type-ahead,h4.sc-admiralty-type-ahead,h5.sc-admiralty-type-ahead{font-size:20px;line-height:30px}}h6.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;color:#09315b;font-weight:normal;font-size:18px;line-height:24px;margin-bottom:12px}@media (max-width: 1023px){h6.sc-admiralty-type-ahead{font-size:16px}}p.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;margin-bottom:30px}.intro.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;font-size:28px;line-height:36px;margin-bottom:30px}@media (max-width: 1023px){.intro.sc-admiralty-type-ahead{font-size:26px}}.small.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;font-size:16px}@media (max-width: 1023px){.small.sc-admiralty-type-ahead{font-size:14px;line-height:22px}}blockquote.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;line-height:30px;width:100%;padding:24px 18px;border-left:5px solid #09315b;margin-bottom:30px;background:#eeeeee}@media (max-width: 1023px){blockquote.sc-admiralty-type-ahead{line-height:24px}}ul.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;list-style:none}ul.sc-admiralty-type-ahead a.sc-admiralty-type-ahead{font-weight:300}ul.sc-admiralty-type-ahead li.sc-admiralty-type-ahead{margin-bottom:12px}ul.sc-admiralty-type-ahead li.sc-admiralty-type-ahead:before{content:"■";font-size:18px;color:#09315b;vertical-align:text-bottom;margin-right:12px}@media (max-width: 1023px){ul.sc-admiralty-type-ahead li.sc-admiralty-type-ahead:before{font-size:8px}}ol.sc-admiralty-type-ahead{font-family:"JohnstonITC", Helvetica, sans-serif;list-style:none;counter-reset:li}ol.sc-admiralty-type-ahead a.sc-admiralty-type-ahead{font-weight:300}ol.sc-admiralty-type-ahead li.sc-admiralty-type-ahead:before{content:counter(li) ".";color:#03284f;font-size:18px;margin-right:12px}ol.sc-admiralty-type-ahead li.sc-admiralty-type-ahead{counter-increment:li;margin-bottom:12px}.white-text.sc-admiralty-type-ahead *.sc-admiralty-type-ahead{color:#ffffff}*.sc-admiralty-type-ahead{margin:0px;padding:0px}.text-input-wrap.sc-admiralty-type-ahead{height:auto !important}.filterTextInput.sc-admiralty-type-ahead{width:100%}.typeahead-list-container.sc-admiralty-type-ahead{position:relative}.typeahead-list-container.sc-admiralty-type-ahead .typeahead-list.sc-admiralty-type-ahead{position:absolute;left:0px;top:-24px;background-color:#ffffff;width:100%;box-shadow:0px 4px 4px rgba(0, 0, 0, 0.25);border:2px solid #333333;border-top:none;box-sizing:border-box;max-height:180px;overflow-y:auto;z-index:1;list-style:none}.typeahead-list-container.sc-admiralty-type-ahead .typeahead-list.sc-admiralty-type-ahead li.sc-admiralty-type-ahead{cursor:pointer;transform:unset !important;padding:6px;min-height:24px;margin:0}.typeahead-list-container.sc-admiralty-type-ahead .typeahead-list.sc-admiralty-type-ahead li.sc-admiralty-type-ahead:before{content:none}.typeahead-list-container.sc-admiralty-type-ahead .typeahead-list.sc-admiralty-type-ahead li.highlighted.sc-admiralty-type-ahead{background-color:#09315b;color:#ffffff}';const o=n;const l=class{constructor(e){t(this,e);this.selectionChanged=a(this,"selectionChanged",7);this.valueChanged=a(this,"valueChanged",7);this._id=`admiralty-typeahead-${++r}`;this.hintId=`${this._id}-assistive-hint`;this.listId=`${this._id}-list`;this.filterList=[];this.selectedItemIndex=-1;this.isFocused=false;this.isSilenced=false;this.isAlternateStatusSection=false;this.originalSearch="";this.hasBeenFocusedAtLeastOnce=false;this.filterResult=new Array;this.value=undefined;this.label=undefined;this.hint=undefined;this.placeholder=undefined;this.resultsOnInitFocus=false}get inputValue(){return this.inputControl.value.toString()}set inputValue(t){this.inputControl.value=t}componentDidLoad(){if(this.value){this.inputValue=this.value}}connectedCallback(){this.mutation=new MutationObserver((()=>{this.populateFilterList();e(this)}));this.mutation.observe(this.el,{childList:true,subtree:true})}disconnectedCallback(){if(this.mutation){this.mutation.disconnect();this.mutation=undefined}}populateFilterList(){const t=this.el.querySelectorAll("admiralty-type-ahead-item");this.filterList=[];t.forEach((t=>{this.filterList.push(t.getAttribute("value"))}))}handleFocusIn(){if(this.resultsOnInitFocus&&!this.hasBeenFocusedAtLeastOnce){this.performFilter("");this.hasBeenFocusedAtLeastOnce=true}this.isFocused=true;this.isSilenced=false}handleFocusOut(){this.isFocused=false;this.statusText=null;this.isSilenced=true}textChanged(t){this.originalSearch=t;this.performFilter(t);this.isSilenced=false;this.valueChanged.emit(t)}handleKeyPressed(t){t.stopImmediatePropagation();if(t.key===d.UP_ARROW||t.key===d.DOWN_ARROW){this.navigateSuggestions(t.key);this.updateScroll()}else if(t.key!==d.ENTER){this.textChanged(this.inputValue);this.selectCurrentItem()}}handleKeyDown(t){t.stopImmediatePropagation();if(t.key===d.TAB||t.key===d.ENTER){this.selectCurrentItem()}}handleItemSelected(t){this.inputValue=t;this.textChanged(t);this.filterResult=new Array;this.selectionChanged.emit(t)}performFilter(t){const a=(t,a)=>{const e=t.filter((t=>a===null||a.length<1||t.toLowerCase().indexOf(a.toLowerCase())>-1));return e};this.filterResult=a(this.filterList,t);this.selectedItemIndex=-1}addHighlight(){if(this.selectedItemIndex>-1){const t=this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);t.classList.add("highlighted")}}removeHighlight(t){if(t>-1){const a=this.el.querySelector(`#${this.getListItemId(t)}`);a.classList.remove("highlighted")}}selectCurrentItem(){if(this.selectedItemIndex>=0){const t=this.filterResult[this.selectedItemIndex];this.handleItemSelected(t)}}handleItemHovered(t){this.removeHighlight(this.selectedItemIndex);this.selectedItemIndex=t;this.addHighlight()}handleComponentFocusOut(){var t;if(((t=this.filterResult)===null||t===void 0?void 0:t.length)>0){this.filterResult=new Array;this.hasBeenFocusedAtLeastOnce=false}}updateScroll(){const t=this.listContainer;const a=t.querySelector("ul");const e=Array.from(a.childNodes).find((t=>t.ariaPosInSet===`${this.selectedItemIndex+1}`));if(t&&e&&t.scrollHeight+t.clientHeight){e.scrollIntoView()}}navigateSuggestions(t){if(t===d.UP_ARROW){this.removeHighlight(this.selectedItemIndex);this.selectedItemIndex--;if(this.selectedItemIndex===-2){this.selectedItemIndex=this.filterResult.length-1}}if(t===d.DOWN_ARROW){this.removeHighlight(this.selectedItemIndex);this.selectedItemIndex++;if(this.selectedItemIndex>this.filterResult.length-1){this.selectedItemIndex=-1}}if(this.selectedItemIndex===-1){this.inputValue=this.originalSearch}else{const t=this.filterResult[this.selectedItemIndex];this.inputValue=t;this.addHighlight()}}getListItemId(t){return`${this.listId}-item-${t}`}render(){return i(s,{key:"1b207cbc8db3ecc8f56bd37e0a4dd6467760e9f3",onFocusout:t=>this.handleComponentFocusOut()},i("div",{key:"35f64ad887609c0bfb61b2f14bb45e6ae4ea3b11",class:"visually-hidden"},i("div",{key:"05a99b1fa37ae53f40f609a4b26b7ba35926cbae",class:"results-status-a",role:"status","aria-atomic":"true","aria-live":"polite"},!this.isSilenced&&this.isAlternateStatusSection?this.statusText:""),i("div",{key:"560d3c5b1d383cf6055c29bd5ca44a8bd320c30e",class:"results-status-b",role:"status","aria-atomic":"true","aria-live":"polite"},!this.isSilenced&&!this.isAlternateStatusSection?this.statusText:"")),i("admiralty-input",{key:"3adc22e97d4c0c301806294ebf0636c71fddf120",type:"text",ref:t=>this.inputControl=t,label:this.label,hint:this.hint,placeholder:this.placeholder,class:"filterTextInput",onKeyUp:t=>this.handleKeyPressed(t),onKeyDown:t=>this.handleKeyDown(t),onFocusin:t=>this.handleFocusIn(),onFocusout:t=>this.handleFocusOut(),"aria-expanded":this.isFocused&&this.filterResult.length>0}),i("span",{key:"996c387351a79a8b39df0cf3e1bacb18c190d03b",id:this.hintId,class:"visually-hidden"},"When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."),this.filterResult.length>0?i("div",{class:"typeahead-list-container",ref:t=>this.listContainer=t},i("ul",{class:"typeahead-list",id:this.listId,role:"listbox"},this.filterResult.map(((t,a)=>i("li",{id:this.getListItemId(a),onMouseDown:a=>this.handleItemSelected(t),onMouseOver:t=>this.handleItemHovered(a),"aria-selected":a===this.selectedItemIndex,role:"option",tabindex:"-1","aria-posinset":a+1,"aria-setsize":this.filterResult.length},t))))):null,i("slot",{key:"2fd643c3154d7ece80fd1d1fab1c2058e477a047"}))}get el(){return h(this)}};let r=0;l.style=o;export{l as admiralty_type_ahead};
2
+ //# sourceMappingURL=p-6229741b.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["typeAheadCss","AdmiraltyTypeAheadStyle0","TypeAheadComponent","this","_id","id","hintId","listId","filterList","selectedItemIndex","isFocused","isSilenced","isAlternateStatusSection","originalSearch","hasBeenFocusedAtLeastOnce","Array","inputValue","inputControl","value","toString","componentDidLoad","connectedCallback","mutation","MutationObserver","populateFilterList","forceUpdate","observe","el","childList","subtree","disconnectedCallback","disconnect","undefined","slotItems","querySelectorAll","forEach","push","getAttribute","handleFocusIn","resultsOnInitFocus","performFilter","handleFocusOut","statusText","textChanged","valueChanged","emit","handleKeyPressed","event","stopImmediatePropagation","key","Keys","UP_ARROW","DOWN_ARROW","navigateSuggestions","updateScroll","ENTER","selectCurrentItem","handleKeyDown","TAB","handleItemSelected","filterResult","selectionChanged","filter","text","length","toLowerCase","indexOf","addHighlight","listItem","querySelector","getListItemId","classList","add","removeHighlight","i","remove","selectedItemText","handleItemHovered","index","handleComponentFocusOut","_a","container","listContainer","ul","selectedItem","from","childNodes","find","item","ariaPosInSet","scrollHeight","clientHeight","scrollIntoView","render","h","Host","onFocusout","_ev","class","role","type","ref","label","hint","placeholder","onKeyUp","ev","onKeyDown","onFocusin","map","onMouseDown","onMouseOver","tabindex"],"sources":["src/components/type-ahead/type-ahead.scss?tag=admiralty-type-ahead&encapsulation=scoped","src/components/type-ahead/type-ahead.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n@use '../../scss/base/a11y';\n@use '../../scss/base/typography';\n\n* {\n margin: 0px;\n padding: 0px;\n}\n\n.text-input-wrap {\n height: auto !important;\n}\n\n.filterTextInput {\n width: 100%;\n}\n\n.typeahead-list-container {\n position: relative;\n\n .typeahead-list {\n position: absolute;\n left: 0px;\n top: -24px;\n background-color: colours.$colour-white;\n width: 100%;\n box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);\n border: 2px solid colours.$colour-text;\n border-top: none;\n box-sizing: border-box;\n max-height: 180px;\n overflow-y: auto;\n z-index: 1;\n list-style: none;\n\n li {\n cursor: pointer;\n transform: unset !important;\n padding: 6px;\n min-height: 24px;\n margin: 0;\n }\n\n li:before {\n content: none;\n }\n\n li.highlighted {\n background-color: colours.$colour-admiralty-blue;\n color: colours.$colour-white;\n }\n }\n}\n","import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"],"mappings":"2GAAA,MAAMA,EAAe,gpKACrB,MAAAC,EAAeD,E,MCOFE,EAAkB,M,uHACrBC,KAAAC,IAAM,yBAAyBC,IAEvCF,KAAAG,OAAS,GAAGH,KAAKC,qBACjBD,KAAAI,OAAS,GAAGJ,KAAKC,WASjBD,KAAAK,WAA4B,GAE5BL,KAAAM,mBAAqB,EACrBN,KAAAO,UAAY,MAEZP,KAAAQ,WAAa,MACbR,KAAAS,yBAA2B,MAKnBT,KAAAU,eAAiB,GACjBV,KAAAW,0BAA4B,M,kBAdF,IAAIC,M,iHA+CA,K,CA/BtC,cAAYC,GACV,OAAOb,KAAKc,aAAaC,MAAMC,U,CAGjC,cAAYH,CAAWE,GACrBf,KAAKc,aAAaC,MAAQA,C,CAuC5B,gBAAAE,GACE,GAAIjB,KA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AAarG,KAAKqG,YAClBN,MAAM,kBACNO,QAASC,GAAMvG,KAAK2C,iBAAiB4D,GACrCC,UAAWD,GAAMvG,KAAKsD,cAAciD,GACpCE,UAAWX,GAAO9F,KAAKmC,gBACvB0D,WAAYC,GAAO9F,KAAKsC,iBAAgB,gBACzBtC,KAAKO,WAAaP,KAAKyD,aAAaI,OAAS,IAG9D8B,EAAA,QAAA7C,IAAA,2CAAM5C,GAAIF,KAAKG,OAAQ4F,MAAM,mBAAiB,8JAG7C/F,KAAKyD,aAAaI,OAAS,EAC1B8B,EAAA,OAAKI,MAAM,2BAA2BG,IAAK1E,GAAOxB,KAAK+E,cAAgBvD,GACrEmE,EAAA,MAAII,MAAM,iBAAiB7F,GAAIF,KAAKI,OAAQ4F,KAAK,WAC9ChG,KAAKyD,aAAaiD,KAAI,CAACrB,EAAMd,IAC5BoB,EAAA,MACEzF,GAAIF,KAAKmE,cAAcI,GACvBoC,YAAab,GAAO9F,KAAKwD,mBAAmB6B,GAC5CuB,YAAad,GAAO9F,KAAK0E,kBAAkBH,GAAE,gBAC9BA,IAAMvE,KAAKM,kBAC1B0F,KAAK,SACLa,SAAS,KAAI,gBACEtC,EAAI,EAAC,eACNvE,KAAKyD,aAAaI,QAE/BwB,OAKP,KACJM,EAAA,QAAA7C,IAAA,6C,2BAMR,IAAI5C,EAAK,E"}
@@ -19,7 +19,7 @@ const HintComponent = class {
19
19
  };
20
20
  HintComponent.style = AdmiraltyHintStyle0;
21
21
 
22
- const inputInvalidCss = ".sc-admiralty-input-invalid-h{display:flex;align-items:center}admiralty-icon.sc-admiralty-input-invalid{color:#e20d0d}p.sc-admiralty-input-invalid{margin:0;color:#e20d0d}";
22
+ const inputInvalidCss = ".sc-admiralty-input-invalid-h{display:flex;align-items:center}admiralty-icon.sc-admiralty-input-invalid{color:#e20d0d;margin:4px 0}p.sc-admiralty-input-invalid{margin:0;color:#e20d0d}";
23
23
  const AdmiraltyInputInvalidStyle0 = inputInvalidCss;
24
24
 
25
25
  const InputInvalidComponent = class {
@@ -1 +1 @@
1
- {"file":"admiralty-hint.admiralty-input-invalid.admiralty-label.entry.cjs.js","mappings":";;;;;;;AAAA,MAAM,OAAO,GAAG,8HAA8H,CAAC;AAC/I,4BAAe,OAAO;;MCUT,aAAa;;;;;IAMxB,MAAM;QACJ,QACEA,gEAAG,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IACnCA,oEAAa,CACX,EACJ;KACH;;;;ACvBH,MAAM,eAAe,GAAG,4KAA4K,CAAC;AACrM,oCAAe,eAAe;;MCWjB,qBAAqB;;;;IAChC,MAAM;QACJ,QACEA,QAACC,UAAI,uDACHD,0FAA2BE,qBAAa,CAAC,QAAQ,EAAE,KAAK,EAAC,YAAY,GAAkB,EACvFF,kEACEA,oEAAa,CACX,CACC,EACP;KACH;;;;ACtBH,MAAM,QAAQ,GAAG,qIAAqI,CAAC;AACvJ,6BAAe,QAAQ;;MCUV,cAAc;;;;;;IAWzB,MAAM;QACJ,QACEA,oEAAO,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAC1DA,oEAAa,CACP,EACR;KACH;;;;;;;;","names":["h","Host","faExclamation"],"sources":["src/components/hint/hint.scss?tag=admiralty-hint&encapsulation=scoped","src/components/hint/hint.tsx","src/components/input-invalid/input-invalid.scss?tag=admiralty-input-invalid&encapsulation=scoped","src/components/input-invalid/input-invalid.tsx","src/components/label/label.scss?tag=admiralty-label&encapsulation=scoped","src/components/label/label.tsx"],"sourcesContent":["@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\np {\n margin-top: 0;\n margin-bottom: 6px;\n display: block;\n font-weight: typography.$font-weight-light;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The hint content should be placed in the slot e.g.\n * `<admiralty-hint>Enter your full name</admiralty-hint>`\n */\n@Component({\n tag: 'admiralty-hint',\n styleUrl: 'hint.scss',\n scoped: true,\n})\nexport class HintComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n render() {\n return (\n <p class={{ disabled: this.disabled }}>\n <slot></slot>\n </p>\n );\n }\n}\n","@use '../../scss/vars/colours';\n\n:host {\n display: flex;\n align-items: center;\n}\n\nadmiralty-icon {\n color: colours.$colour-utility-error;\n}\n\np {\n margin: 0;\n color: colours.$colour-utility-error;\n}\n\n","import { Component, h, Host } from '@stencil/core';\nimport { faExclamation } from '@fortawesome/free-solid-svg-icons';\n\n/**\n * @slot - The error content should be placed in the slot e.g.\n * `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`\n */\n@Component({\n tag: 'admiralty-input-invalid',\n styleUrl: 'input-invalid.scss',\n scoped: true,\n})\nexport class InputInvalidComponent {\n render() {\n return (\n <Host>\n <admiralty-icon icon-name={faExclamation.iconName} class=\"error-icon\"></admiralty-icon>\n <p>\n <slot></slot>\n </p>\n </Host>\n );\n }\n}\n","@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\nlabel {\n margin-bottom: 6px;\n display: inline-block;\n font-weight: typography.$font-weight-medium;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The label content should be placed in the slot e.g.\n * `<admiralty-label>First Name</admiralty-label>`\n */\n@Component({\n tag: 'admiralty-label',\n styleUrl: 'label.scss',\n scoped: true,\n})\nexport class LabelComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n /**\n * The id of the input the label is attached to\n */\n @Prop() for: string;\n\n render() {\n return (\n <label htmlFor={this.for} class={{ disabled: this.disabled }}>\n <slot></slot>\n </label>\n );\n }\n}\n"],"version":3}
1
+ {"file":"admiralty-hint.admiralty-input-invalid.admiralty-label.entry.cjs.js","mappings":";;;;;;;AAAA,MAAM,OAAO,GAAG,8HAA8H,CAAC;AAC/I,4BAAe,OAAO;;MCUT,aAAa;;;;;IAMxB,MAAM;QACJ,QACEA,gEAAG,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IACnCA,oEAAa,CACX,EACJ;KACH;;;;ACvBH,MAAM,eAAe,GAAG,yLAAyL,CAAC;AAClN,oCAAe,eAAe;;MCWjB,qBAAqB;;;;IAChC,MAAM;QACJ,QACEA,QAACC,UAAI,uDACHD,0FAA2BE,qBAAa,CAAC,QAAQ,EAAE,KAAK,EAAC,YAAY,GAAkB,EACvFF,kEACEA,oEAAa,CACX,CACC,EACP;KACH;;;;ACtBH,MAAM,QAAQ,GAAG,qIAAqI,CAAC;AACvJ,6BAAe,QAAQ;;MCUV,cAAc;;;;;;IAWzB,MAAM;QACJ,QACEA,oEAAO,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAC1DA,oEAAa,CACP,EACR;KACH;;;;;;;;","names":["h","Host","faExclamation"],"sources":["src/components/hint/hint.scss?tag=admiralty-hint&encapsulation=scoped","src/components/hint/hint.tsx","src/components/input-invalid/input-invalid.scss?tag=admiralty-input-invalid&encapsulation=scoped","src/components/input-invalid/input-invalid.tsx","src/components/label/label.scss?tag=admiralty-label&encapsulation=scoped","src/components/label/label.tsx"],"sourcesContent":["@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\np {\n margin-top: 0;\n margin-bottom: 6px;\n display: block;\n font-weight: typography.$font-weight-light;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The hint content should be placed in the slot e.g.\n * `<admiralty-hint>Enter your full name</admiralty-hint>`\n */\n@Component({\n tag: 'admiralty-hint',\n styleUrl: 'hint.scss',\n scoped: true,\n})\nexport class HintComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n render() {\n return (\n <p class={{ disabled: this.disabled }}>\n <slot></slot>\n </p>\n );\n }\n}\n","@use '../../scss/vars/colours';\n\n:host {\n display: flex;\n align-items: center;\n}\n\nadmiralty-icon {\n color: colours.$colour-utility-error;\n margin: 4px 0;\n}\n\np {\n margin: 0;\n color: colours.$colour-utility-error;\n}\n","import { Component, h, Host } from '@stencil/core';\nimport { faExclamation } from '@fortawesome/free-solid-svg-icons';\n\n/**\n * @slot - The error content should be placed in the slot e.g.\n * `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`\n */\n@Component({\n tag: 'admiralty-input-invalid',\n styleUrl: 'input-invalid.scss',\n scoped: true,\n})\nexport class InputInvalidComponent {\n render() {\n return (\n <Host>\n <admiralty-icon icon-name={faExclamation.iconName} class=\"error-icon\"></admiralty-icon>\n <p>\n <slot></slot>\n </p>\n </Host>\n );\n }\n}\n","@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\nlabel {\n margin-bottom: 6px;\n display: inline-block;\n font-weight: typography.$font-weight-medium;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The label content should be placed in the slot e.g.\n * `<admiralty-label>First Name</admiralty-label>`\n */\n@Component({\n tag: 'admiralty-label',\n styleUrl: 'label.scss',\n scoped: true,\n})\nexport class LabelComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n /**\n * The id of the input the label is attached to\n */\n @Prop() for: string;\n\n render() {\n return (\n <label htmlFor={this.for} class={{ disabled: this.disabled }}>\n <slot></slot>\n </label>\n );\n }\n}\n"],"version":3}
@@ -62,7 +62,6 @@ const TypeAheadComponent = class {
62
62
  this.filterList = [];
63
63
  slotItems.forEach(el => {
64
64
  this.filterList.push(el.getAttribute('value'));
65
- console.log('fliterlist value ', el.getAttribute('value'));
66
65
  });
67
66
  }
68
67
  handleFocusIn() {
@@ -187,7 +186,7 @@ const TypeAheadComponent = class {
187
186
  return `${this.listId}-item-${i}`;
188
187
  }
189
188
  render() {
190
- return (index.h(index.Host, { key: '9c58ee688918a293bda88a9cf0150214510f7bc0', onFocusout: _ev => this.handleComponentFocusOut() }, index.h("div", { key: '3144d016e0594a18e4dc6d473c32599fae8c01d3', class: "visually-hidden" }, index.h("div", { key: 'e6c3c437cb4e12158b8ea880ce21c7908b68a638', class: "results-status-a", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''), index.h("div", { key: 'c35e28c3de7e3fb97f9e0c8aab2d3a34f658000b', class: "results-status-b", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && !this.isAlternateStatusSection ? this.statusText : '')), index.h("admiralty-input", { key: '88c82941c54dbad9fea476dbd5ec8b0c88efc1b8', type: "text", ref: el => (this.inputControl = el), label: this.label, hint: this.hint, placeholder: this.placeholder, class: "filterTextInput", onKeyUp: ev => this.handleKeyPressed(ev), onKeyDown: ev => this.handleKeyDown(ev), onFocusin: _ev => this.handleFocusIn(), onFocusout: _ev => this.handleFocusOut(), "aria-expanded": this.isFocused && this.filterResult.length > 0 }), index.h("span", { key: '3959c94636207a7fcefeabda1ab693f1aa0e2204', id: this.hintId, class: "visually-hidden" }, "When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."), this.filterResult.length > 0 ? (index.h("div", { class: "typeahead-list-container", ref: el => (this.listContainer = el) }, index.h("ul", { class: "typeahead-list", id: this.listId, role: "listbox" }, this.filterResult.map((item, i) => (index.h("li", { id: this.getListItemId(i), onMouseDown: _ev => this.handleItemSelected(item), onMouseOver: _ev => this.handleItemHovered(i), "aria-selected": i === this.selectedItemIndex, role: "option", tabindex: "-1", "aria-posinset": i + 1, "aria-setsize": this.filterResult.length }, item)))))) : null, index.h("slot", { key: 'bf5408374f50291a4adfa81cd23b4346712bbd8a' })));
189
+ return (index.h(index.Host, { key: '1b207cbc8db3ecc8f56bd37e0a4dd6467760e9f3', onFocusout: _ev => this.handleComponentFocusOut() }, index.h("div", { key: '35f64ad887609c0bfb61b2f14bb45e6ae4ea3b11', class: "visually-hidden" }, index.h("div", { key: '05a99b1fa37ae53f40f609a4b26b7ba35926cbae', class: "results-status-a", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''), index.h("div", { key: '560d3c5b1d383cf6055c29bd5ca44a8bd320c30e', class: "results-status-b", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && !this.isAlternateStatusSection ? this.statusText : '')), index.h("admiralty-input", { key: '3adc22e97d4c0c301806294ebf0636c71fddf120', type: "text", ref: el => (this.inputControl = el), label: this.label, hint: this.hint, placeholder: this.placeholder, class: "filterTextInput", onKeyUp: ev => this.handleKeyPressed(ev), onKeyDown: ev => this.handleKeyDown(ev), onFocusin: _ev => this.handleFocusIn(), onFocusout: _ev => this.handleFocusOut(), "aria-expanded": this.isFocused && this.filterResult.length > 0 }), index.h("span", { key: '996c387351a79a8b39df0cf3e1bacb18c190d03b', id: this.hintId, class: "visually-hidden" }, "When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."), this.filterResult.length > 0 ? (index.h("div", { class: "typeahead-list-container", ref: el => (this.listContainer = el) }, index.h("ul", { class: "typeahead-list", id: this.listId, role: "listbox" }, this.filterResult.map((item, i) => (index.h("li", { id: this.getListItemId(i), onMouseDown: _ev => this.handleItemSelected(item), onMouseOver: _ev => this.handleItemHovered(i), "aria-selected": i === this.selectedItemIndex, role: "option", tabindex: "-1", "aria-posinset": i + 1, "aria-setsize": this.filterResult.length }, item)))))) : null, index.h("slot", { key: '2fd643c3154d7ece80fd1d1fab1c2058e477a047' })));
191
190
  }
192
191
  get el() { return index.getElement(this); }
193
192
  };
@@ -1 +1 @@
1
- {"file":"admiralty-type-ahead.entry.cjs.js","mappings":";;;;;;;AAAA,MAAM,YAAY,GAAG,2q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AAE,KAAK,EAAC,iBAAiB,iKAEvC,EACN,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,IAC3BA,iBAAK,KAAK,EAAC,0BAA0B,EAAC,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC,IACxEA,gBAAI,KAAK,EAAC,gBAAgB,EAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAC,SAAS,IACvD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,MAC7BA,gBACE,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EACzB,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACjD,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAC9B,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAC3C,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAC,IAAI,mBACE,CAAC,GAAG,CAAC,kBACN,IAAI,CAAC,YAAY,CAAC,MAAM,IAErC,IAAI,CACF,CACN,CAAC,CACC,CACD,IACJ,IAAI,EACRA,oEAAa,CACR,EACP;KACH;;;AAGH,IAAI,EAAE,GAAG,CAAC,CAAC;;;;;","names":["forceUpdate","Keys","h","Host"],"sources":["src/components/type-ahead/type-ahead.scss?tag=admiralty-type-ahead&encapsulation=scoped","src/components/type-ahead/type-ahead.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n@use '../../scss/base/a11y';\n@use '../../scss/base/typography';\n\n* {\n margin: 0px;\n padding: 0px;\n}\n\n.text-input-wrap {\n height: auto !important;\n}\n\n.filterTextInput {\n width: 100%;\n}\n\n.typeahead-list-container {\n position: relative;\n\n .typeahead-list {\n position: absolute;\n left: 0px;\n top: -24px;\n background-color: colours.$colour-white;\n width: 100%;\n box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);\n border: 2px solid colours.$colour-text;\n border-top: none;\n box-sizing: border-box;\n max-height: 180px;\n overflow-y: auto;\n z-index: 1;\n list-style: none;\n\n li {\n cursor: pointer;\n transform: unset !important;\n padding: 6px;\n min-height: 24px;\n margin: 0;\n }\n\n li:before {\n content: none;\n }\n\n li.highlighted {\n background-color: colours.$colour-admiralty-blue;\n color: colours.$colour-white;\n }\n }\n}\n","import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n console.log('fliterlist value ', el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"],"version":3}
1
+ {"file":"admiralty-type-ahead.entry.cjs.js","mappings":";;;;;;;AAAA,MAAM,YAAY,GAAG,2qKAA2qK,CAAC;AACjsK,iCAAe,YAAY;;MCOd,kBAAkB;;;;;QACrB,QAAG,GAAG,uBAAuB,EAAE,EAAE,EAAE,CAAC;QAE5C,WAAM,GAAG,GAAG,IAAI,CAAC,GAAG,iBAAiB,CAAC;QACtC,WAAM,GAAG,GAAG,IAAI,CAAC,GAAG,OAA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AC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,MAC7BA,gBACE,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EACzB,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACjD,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAC9B,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAC3C,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAC,IAAI,mBACE,CAAC,GAAG,CAAC,kBACN,IAAI,CAAC,YAAY,CAAC,MAAM,IAErC,IAAI,CACF,CACN,CAAC,CACC,CACD,IACJ,IAAI,EACRA,oEAAa,CACR,EACP;KACH;;;AAGH,IAAI,EAAE,GAAG,CAAC,CAAC;;;;;","names":["forceUpdate","Keys","h","Host"],"sources":["src/components/type-ahead/type-ahead.scss?tag=admiralty-type-ahead&encapsulation=scoped","src/components/type-ahead/type-ahead.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n@use '../../scss/base/a11y';\n@use '../../scss/base/typography';\n\n* {\n margin: 0px;\n padding: 0px;\n}\n\n.text-input-wrap {\n height: auto !important;\n}\n\n.filterTextInput {\n width: 100%;\n}\n\n.typeahead-list-container {\n position: relative;\n\n .typeahead-list {\n position: absolute;\n left: 0px;\n top: -24px;\n background-color: colours.$colour-white;\n width: 100%;\n box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);\n border: 2px solid colours.$colour-text;\n border-top: none;\n box-sizing: border-box;\n max-height: 180px;\n overflow-y: auto;\n z-index: 1;\n list-style: none;\n\n li {\n cursor: pointer;\n transform: unset !important;\n padding: 6px;\n min-height: 24px;\n margin: 0;\n }\n\n li:before {\n content: none;\n }\n\n li.highlighted {\n background-color: colours.$colour-admiralty-blue;\n color: colours.$colour-white;\n }\n }\n}\n","import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"],"version":3}
@@ -22,6 +22,7 @@
22
22
 
23
23
  admiralty-icon {
24
24
  color: #e20d0d;
25
+ margin: 4px 0;
25
26
  }
26
27
 
27
28
  p {
@@ -51,7 +51,6 @@ export class TypeAheadComponent {
51
51
  this.filterList = [];
52
52
  slotItems.forEach(el => {
53
53
  this.filterList.push(el.getAttribute('value'));
54
- console.log('fliterlist value ', el.getAttribute('value'));
55
54
  });
56
55
  }
57
56
  handleFocusIn() {
@@ -176,7 +175,7 @@ export class TypeAheadComponent {
176
175
  return `${this.listId}-item-${i}`;
177
176
  }
178
177
  render() {
179
- return (h(Host, { key: '9c58ee688918a293bda88a9cf0150214510f7bc0', onFocusout: _ev => this.handleComponentFocusOut() }, h("div", { key: '3144d016e0594a18e4dc6d473c32599fae8c01d3', class: "visually-hidden" }, h("div", { key: 'e6c3c437cb4e12158b8ea880ce21c7908b68a638', class: "results-status-a", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''), h("div", { key: 'c35e28c3de7e3fb97f9e0c8aab2d3a34f658000b', class: "results-status-b", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && !this.isAlternateStatusSection ? this.statusText : '')), h("admiralty-input", { key: '88c82941c54dbad9fea476dbd5ec8b0c88efc1b8', type: "text", ref: el => (this.inputControl = el), label: this.label, hint: this.hint, placeholder: this.placeholder, class: "filterTextInput", onKeyUp: ev => this.handleKeyPressed(ev), onKeyDown: ev => this.handleKeyDown(ev), onFocusin: _ev => this.handleFocusIn(), onFocusout: _ev => this.handleFocusOut(), "aria-expanded": this.isFocused && this.filterResult.length > 0 }), h("span", { key: '3959c94636207a7fcefeabda1ab693f1aa0e2204', id: this.hintId, class: "visually-hidden" }, "When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."), this.filterResult.length > 0 ? (h("div", { class: "typeahead-list-container", ref: el => (this.listContainer = el) }, h("ul", { class: "typeahead-list", id: this.listId, role: "listbox" }, this.filterResult.map((item, i) => (h("li", { id: this.getListItemId(i), onMouseDown: _ev => this.handleItemSelected(item), onMouseOver: _ev => this.handleItemHovered(i), "aria-selected": i === this.selectedItemIndex, role: "option", tabindex: "-1", "aria-posinset": i + 1, "aria-setsize": this.filterResult.length }, item)))))) : null, h("slot", { key: 'bf5408374f50291a4adfa81cd23b4346712bbd8a' })));
178
+ return (h(Host, { key: '1b207cbc8db3ecc8f56bd37e0a4dd6467760e9f3', onFocusout: _ev => this.handleComponentFocusOut() }, h("div", { key: '35f64ad887609c0bfb61b2f14bb45e6ae4ea3b11', class: "visually-hidden" }, h("div", { key: '05a99b1fa37ae53f40f609a4b26b7ba35926cbae', class: "results-status-a", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''), h("div", { key: '560d3c5b1d383cf6055c29bd5ca44a8bd320c30e', class: "results-status-b", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && !this.isAlternateStatusSection ? this.statusText : '')), h("admiralty-input", { key: '3adc22e97d4c0c301806294ebf0636c71fddf120', type: "text", ref: el => (this.inputControl = el), label: this.label, hint: this.hint, placeholder: this.placeholder, class: "filterTextInput", onKeyUp: ev => this.handleKeyPressed(ev), onKeyDown: ev => this.handleKeyDown(ev), onFocusin: _ev => this.handleFocusIn(), onFocusout: _ev => this.handleFocusOut(), "aria-expanded": this.isFocused && this.filterResult.length > 0 }), h("span", { key: '996c387351a79a8b39df0cf3e1bacb18c190d03b', id: this.hintId, class: "visually-hidden" }, "When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."), this.filterResult.length > 0 ? (h("div", { class: "typeahead-list-container", ref: el => (this.listContainer = el) }, h("ul", { class: "typeahead-list", id: this.listId, role: "listbox" }, this.filterResult.map((item, i) => (h("li", { id: this.getListItemId(i), onMouseDown: _ev => this.handleItemSelected(item), onMouseOver: _ev => this.handleItemHovered(i), "aria-selected": i === this.selectedItemIndex, role: "option", tabindex: "-1", "aria-posinset": i + 1, "aria-setsize": this.filterResult.length }, item)))))) : null, h("slot", { key: '2fd643c3154d7ece80fd1d1fab1c2058e477a047' })));
180
179
  }
181
180
  static get is() { return "admiralty-type-ahead"; }
182
181
  static get encapsulation() { return "scoped"; }
@@ -1 +1 @@
1
- {"version":3,"file":"type-ahead.js","sourceRoot":"","sources":["../../../src/components/type-ahead/type-ahead.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAO/B,MAAM,OAAO,kBAAkB;;QACrB,QAAG,GAAG,uBAAuB,EAAE,EAAE,EAAE,CAAC;QAE5C,WAAM,GAAG,GAAG,IAAI,CAAC,GAAG,iBAAiB,CAAC;QACtC,WAAM,GAAG,GAAG,IAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,EAAE,GAAG,CAAC,CAAC","sourcesContent":["import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n console.log('fliterlist value ', el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"]}
1
+ {"version":3,"file":"type-ahead.js","sourceRoot":"","sources":["../../../src/components/type-ahead/type-ahead.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAO/B,MAAM,OAAO,kBAAkB;;QACrB,QAAG,GAAG,uB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CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAED,IAAI,EAAE,GAAG,CAAC,CAAC","sourcesContent":["import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"]}
@@ -64,7 +64,6 @@ const TypeAheadComponent = /*@__PURE__*/ proxyCustomElement(class TypeAheadCompo
64
64
  this.filterList = [];
65
65
  slotItems.forEach(el => {
66
66
  this.filterList.push(el.getAttribute('value'));
67
- console.log('fliterlist value ', el.getAttribute('value'));
68
67
  });
69
68
  }
70
69
  handleFocusIn() {
@@ -189,7 +188,7 @@ const TypeAheadComponent = /*@__PURE__*/ proxyCustomElement(class TypeAheadCompo
189
188
  return `${this.listId}-item-${i}`;
190
189
  }
191
190
  render() {
192
- return (h(Host, { key: '9c58ee688918a293bda88a9cf0150214510f7bc0', onFocusout: _ev => this.handleComponentFocusOut() }, h("div", { key: '3144d016e0594a18e4dc6d473c32599fae8c01d3', class: "visually-hidden" }, h("div", { key: 'e6c3c437cb4e12158b8ea880ce21c7908b68a638', class: "results-status-a", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''), h("div", { key: 'c35e28c3de7e3fb97f9e0c8aab2d3a34f658000b', class: "results-status-b", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && !this.isAlternateStatusSection ? this.statusText : '')), h("admiralty-input", { key: '88c82941c54dbad9fea476dbd5ec8b0c88efc1b8', type: "text", ref: el => (this.inputControl = el), label: this.label, hint: this.hint, placeholder: this.placeholder, class: "filterTextInput", onKeyUp: ev => this.handleKeyPressed(ev), onKeyDown: ev => this.handleKeyDown(ev), onFocusin: _ev => this.handleFocusIn(), onFocusout: _ev => this.handleFocusOut(), "aria-expanded": this.isFocused && this.filterResult.length > 0 }), h("span", { key: '3959c94636207a7fcefeabda1ab693f1aa0e2204', id: this.hintId, class: "visually-hidden" }, "When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."), this.filterResult.length > 0 ? (h("div", { class: "typeahead-list-container", ref: el => (this.listContainer = el) }, h("ul", { class: "typeahead-list", id: this.listId, role: "listbox" }, this.filterResult.map((item, i) => (h("li", { id: this.getListItemId(i), onMouseDown: _ev => this.handleItemSelected(item), onMouseOver: _ev => this.handleItemHovered(i), "aria-selected": i === this.selectedItemIndex, role: "option", tabindex: "-1", "aria-posinset": i + 1, "aria-setsize": this.filterResult.length }, item)))))) : null, h("slot", { key: 'bf5408374f50291a4adfa81cd23b4346712bbd8a' })));
191
+ return (h(Host, { key: '1b207cbc8db3ecc8f56bd37e0a4dd6467760e9f3', onFocusout: _ev => this.handleComponentFocusOut() }, h("div", { key: '35f64ad887609c0bfb61b2f14bb45e6ae4ea3b11', class: "visually-hidden" }, h("div", { key: '05a99b1fa37ae53f40f609a4b26b7ba35926cbae', class: "results-status-a", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''), h("div", { key: '560d3c5b1d383cf6055c29bd5ca44a8bd320c30e', class: "results-status-b", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && !this.isAlternateStatusSection ? this.statusText : '')), h("admiralty-input", { key: '3adc22e97d4c0c301806294ebf0636c71fddf120', type: "text", ref: el => (this.inputControl = el), label: this.label, hint: this.hint, placeholder: this.placeholder, class: "filterTextInput", onKeyUp: ev => this.handleKeyPressed(ev), onKeyDown: ev => this.handleKeyDown(ev), onFocusin: _ev => this.handleFocusIn(), onFocusout: _ev => this.handleFocusOut(), "aria-expanded": this.isFocused && this.filterResult.length > 0 }), h("span", { key: '996c387351a79a8b39df0cf3e1bacb18c190d03b', id: this.hintId, class: "visually-hidden" }, "When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."), this.filterResult.length > 0 ? (h("div", { class: "typeahead-list-container", ref: el => (this.listContainer = el) }, h("ul", { class: "typeahead-list", id: this.listId, role: "listbox" }, this.filterResult.map((item, i) => (h("li", { id: this.getListItemId(i), onMouseDown: _ev => this.handleItemSelected(item), onMouseOver: _ev => this.handleItemHovered(i), "aria-selected": i === this.selectedItemIndex, role: "option", tabindex: "-1", "aria-posinset": i + 1, "aria-setsize": this.filterResult.length }, item)))))) : null, h("slot", { key: '2fd643c3154d7ece80fd1d1fab1c2058e477a047' })));
193
192
  }
194
193
  get el() { return this; }
195
194
  static get style() { return AdmiraltyTypeAheadStyle0; }
@@ -1 +1 @@
1
- {"file":"admiralty-type-ahead.js","mappings":";;;;;;;;AAAA,MAAM,YAAY,GAAG,2qKAA2qK,CAAC;AACjsK,iCAAe,YAAY;;MCOd,kBAAkB;;;;;;QACrB,QAAG,GAAG,uBAAuB,EAAE,EAAE,EAAE,CAAC;QAE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AAE,EAAE,KAAK,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC,IACxE,UAAI,KAAK,EAAC,gBAAgB,EAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAC,SAAS,IACvD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,MAC7B,UACE,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EACzB,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACjD,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAC9B,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAC3C,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAC,IAAI,mBACE,CAAC,GAAG,CAAC,kBACN,IAAI,CAAC,YAAY,CAAC,MAAM,IAErC,IAAI,CACF,CACN,CAAC,CACC,CACD,IACJ,IAAI,EACR,8DAAa,CACR,EACP;KACH;;;;;;;;;;;AAGH,IAAI,EAAE,GAAG,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/type-ahead/type-ahead.scss?tag=admiralty-type-ahead&encapsulation=scoped","src/components/type-ahead/type-ahead.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n@use '../../scss/base/a11y';\n@use '../../scss/base/typography';\n\n* {\n margin: 0px;\n padding: 0px;\n}\n\n.text-input-wrap {\n height: auto !important;\n}\n\n.filterTextInput {\n width: 100%;\n}\n\n.typeahead-list-container {\n position: relative;\n\n .typeahead-list {\n position: absolute;\n left: 0px;\n top: -24px;\n background-color: colours.$colour-white;\n width: 100%;\n box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);\n border: 2px solid colours.$colour-text;\n border-top: none;\n box-sizing: border-box;\n max-height: 180px;\n overflow-y: auto;\n z-index: 1;\n list-style: none;\n\n li {\n cursor: pointer;\n transform: unset !important;\n padding: 6px;\n min-height: 24px;\n margin: 0;\n }\n\n li:before {\n content: none;\n }\n\n li.highlighted {\n background-color: colours.$colour-admiralty-blue;\n color: colours.$colour-white;\n }\n }\n}\n","import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n console.log('fliterlist value ', el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"],"version":3}
1
+ {"file":"admiralty-type-ahead.js","mappings":";;;;;;;;AAAA,MAAM,YAAY,GAAG,2qKAA2qK,CAAC;AACjsK,iCAAe,YAAY;;MCOd,kBAAkB;;;;;;QACrB,QAAG,GAAG,uBAAuB,EAAE,EAAE,EAAE,CAAC;QAE5C,WAAM,GAAG,GAAG,IAAI,CAAC,GAAG,iBAAiB,CAAC;QACtC,WAAM,GAAG,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;QAS5B,eAAU,GAAkB,EAAE,CAAC;QAE/B,sBAAiB,GAAG,CAAC,CAAC,CAAC;QACvB,cAAS,GAAG,KAAK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AI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACjD,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAC9B,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAC3C,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAC,IAAI,mBACE,CAAC,GAAG,CAAC,kBACN,IAAI,CAAC,YAAY,CAAC,MAAM,IAErC,IAAI,CACF,CACN,CAAC,CACC,CACD,IACJ,IAAI,EACR,8DAAa,CACR,EACP;KACH;;;;;;;;;;;AAGH,IAAI,EAAE,GAAG,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/type-ahead/type-ahead.scss?tag=admiralty-type-ahead&encapsulation=scoped","src/components/type-ahead/type-ahead.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n@use '../../scss/base/a11y';\n@use '../../scss/base/typography';\n\n* {\n margin: 0px;\n padding: 0px;\n}\n\n.text-input-wrap {\n height: auto !important;\n}\n\n.filterTextInput {\n width: 100%;\n}\n\n.typeahead-list-container {\n position: relative;\n\n .typeahead-list {\n position: absolute;\n left: 0px;\n top: -24px;\n background-color: colours.$colour-white;\n width: 100%;\n box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);\n border: 2px solid colours.$colour-text;\n border-top: none;\n box-sizing: border-box;\n max-height: 180px;\n overflow-y: auto;\n z-index: 1;\n list-style: none;\n\n li {\n cursor: pointer;\n transform: unset !important;\n padding: 6px;\n min-height: 24px;\n margin: 0;\n }\n\n li:before {\n content: none;\n }\n\n li.highlighted {\n background-color: colours.$colour-admiralty-blue;\n color: colours.$colour-white;\n }\n }\n}\n","import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"],"version":3}
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
2
  import { f as faExclamation, d as defineCustomElement$1 } from './icon.js';
3
3
 
4
- const inputInvalidCss = ".sc-admiralty-input-invalid-h{display:flex;align-items:center}admiralty-icon.sc-admiralty-input-invalid{color:#e20d0d}p.sc-admiralty-input-invalid{margin:0;color:#e20d0d}";
4
+ const inputInvalidCss = ".sc-admiralty-input-invalid-h{display:flex;align-items:center}admiralty-icon.sc-admiralty-input-invalid{color:#e20d0d;margin:4px 0}p.sc-admiralty-input-invalid{margin:0;color:#e20d0d}";
5
5
  const AdmiraltyInputInvalidStyle0 = inputInvalidCss;
6
6
 
7
7
  const InputInvalidComponent = /*@__PURE__*/ proxyCustomElement(class InputInvalidComponent extends HTMLElement {
@@ -1 +1 @@
1
- {"file":"input-invalid.js","mappings":";;;AAAA,MAAM,eAAe,GAAG,4KAA4K,CAAC;AACrM,oCAAe,eAAe;;MCWjB,qBAAqB;;;;;IAChC,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,oFAA2B,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAC,YAAY,GAAkB,EACvF,4DACE,8DAAa,CACX,CACC,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/input-invalid/input-invalid.scss?tag=admiralty-input-invalid&encapsulation=scoped","src/components/input-invalid/input-invalid.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n\n:host {\n display: flex;\n align-items: center;\n}\n\nadmiralty-icon {\n color: colours.$colour-utility-error;\n}\n\np {\n margin: 0;\n color: colours.$colour-utility-error;\n}\n\n","import { Component, h, Host } from '@stencil/core';\nimport { faExclamation } from '@fortawesome/free-solid-svg-icons';\n\n/**\n * @slot - The error content should be placed in the slot e.g.\n * `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`\n */\n@Component({\n tag: 'admiralty-input-invalid',\n styleUrl: 'input-invalid.scss',\n scoped: true,\n})\nexport class InputInvalidComponent {\n render() {\n return (\n <Host>\n <admiralty-icon icon-name={faExclamation.iconName} class=\"error-icon\"></admiralty-icon>\n <p>\n <slot></slot>\n </p>\n </Host>\n );\n }\n}\n"],"version":3}
1
+ {"file":"input-invalid.js","mappings":";;;AAAA,MAAM,eAAe,GAAG,yLAAyL,CAAC;AAClN,oCAAe,eAAe;;MCWjB,qBAAqB;;;;;IAChC,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,oFAA2B,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAC,YAAY,GAAkB,EACvF,4DACE,8DAAa,CACX,CACC,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/input-invalid/input-invalid.scss?tag=admiralty-input-invalid&encapsulation=scoped","src/components/input-invalid/input-invalid.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n\n:host {\n display: flex;\n align-items: center;\n}\n\nadmiralty-icon {\n color: colours.$colour-utility-error;\n margin: 4px 0;\n}\n\np {\n margin: 0;\n color: colours.$colour-utility-error;\n}\n","import { Component, h, Host } from '@stencil/core';\nimport { faExclamation } from '@fortawesome/free-solid-svg-icons';\n\n/**\n * @slot - The error content should be placed in the slot e.g.\n * `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`\n */\n@Component({\n tag: 'admiralty-input-invalid',\n styleUrl: 'input-invalid.scss',\n scoped: true,\n})\nexport class InputInvalidComponent {\n render() {\n return (\n <Host>\n <admiralty-icon icon-name={faExclamation.iconName} class=\"error-icon\"></admiralty-icon>\n <p>\n <slot></slot>\n </p>\n </Host>\n );\n }\n}\n"],"version":3}
@@ -15,7 +15,7 @@ const HintComponent = class {
15
15
  };
16
16
  HintComponent.style = AdmiraltyHintStyle0;
17
17
 
18
- const inputInvalidCss = ".sc-admiralty-input-invalid-h{display:flex;align-items:center}admiralty-icon.sc-admiralty-input-invalid{color:#e20d0d}p.sc-admiralty-input-invalid{margin:0;color:#e20d0d}";
18
+ const inputInvalidCss = ".sc-admiralty-input-invalid-h{display:flex;align-items:center}admiralty-icon.sc-admiralty-input-invalid{color:#e20d0d;margin:4px 0}p.sc-admiralty-input-invalid{margin:0;color:#e20d0d}";
19
19
  const AdmiraltyInputInvalidStyle0 = inputInvalidCss;
20
20
 
21
21
  const InputInvalidComponent = class {
@@ -1 +1 @@
1
- {"file":"admiralty-hint.admiralty-input-invalid.admiralty-label.entry.js","mappings":";;;AAAA,MAAM,OAAO,GAAG,8HAA8H,CAAC;AAC/I,4BAAe,OAAO;;MCUT,aAAa;;;;;IAMxB,MAAM;QACJ,QACE,0DAAG,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IACnC,8DAAa,CACX,EACJ;KACH;;;;ACvBH,MAAM,eAAe,GAAG,4KAA4K,CAAC;AACrM,oCAAe,eAAe;;MCWjB,qBAAqB;;;;IAChC,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,oFAA2B,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAC,YAAY,GAAkB,EACvF,4DACE,8DAAa,CACX,CACC,EACP;KACH;;;;ACtBH,MAAM,QAAQ,GAAG,qIAAqI,CAAC;AACvJ,6BAAe,QAAQ;;MCUV,cAAc;;;;;;IAWzB,MAAM;QACJ,QACE,8DAAO,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAC1D,8DAAa,CACP,EACR;KACH;;;;;;","names":[],"sources":["src/components/hint/hint.scss?tag=admiralty-hint&encapsulation=scoped","src/components/hint/hint.tsx","src/components/input-invalid/input-invalid.scss?tag=admiralty-input-invalid&encapsulation=scoped","src/components/input-invalid/input-invalid.tsx","src/components/label/label.scss?tag=admiralty-label&encapsulation=scoped","src/components/label/label.tsx"],"sourcesContent":["@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\np {\n margin-top: 0;\n margin-bottom: 6px;\n display: block;\n font-weight: typography.$font-weight-light;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The hint content should be placed in the slot e.g.\n * `<admiralty-hint>Enter your full name</admiralty-hint>`\n */\n@Component({\n tag: 'admiralty-hint',\n styleUrl: 'hint.scss',\n scoped: true,\n})\nexport class HintComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n render() {\n return (\n <p class={{ disabled: this.disabled }}>\n <slot></slot>\n </p>\n );\n }\n}\n","@use '../../scss/vars/colours';\n\n:host {\n display: flex;\n align-items: center;\n}\n\nadmiralty-icon {\n color: colours.$colour-utility-error;\n}\n\np {\n margin: 0;\n color: colours.$colour-utility-error;\n}\n\n","import { Component, h, Host } from '@stencil/core';\nimport { faExclamation } from '@fortawesome/free-solid-svg-icons';\n\n/**\n * @slot - The error content should be placed in the slot e.g.\n * `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`\n */\n@Component({\n tag: 'admiralty-input-invalid',\n styleUrl: 'input-invalid.scss',\n scoped: true,\n})\nexport class InputInvalidComponent {\n render() {\n return (\n <Host>\n <admiralty-icon icon-name={faExclamation.iconName} class=\"error-icon\"></admiralty-icon>\n <p>\n <slot></slot>\n </p>\n </Host>\n );\n }\n}\n","@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\nlabel {\n margin-bottom: 6px;\n display: inline-block;\n font-weight: typography.$font-weight-medium;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The label content should be placed in the slot e.g.\n * `<admiralty-label>First Name</admiralty-label>`\n */\n@Component({\n tag: 'admiralty-label',\n styleUrl: 'label.scss',\n scoped: true,\n})\nexport class LabelComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n /**\n * The id of the input the label is attached to\n */\n @Prop() for: string;\n\n render() {\n return (\n <label htmlFor={this.for} class={{ disabled: this.disabled }}>\n <slot></slot>\n </label>\n );\n }\n}\n"],"version":3}
1
+ {"file":"admiralty-hint.admiralty-input-invalid.admiralty-label.entry.js","mappings":";;;AAAA,MAAM,OAAO,GAAG,8HAA8H,CAAC;AAC/I,4BAAe,OAAO;;MCUT,aAAa;;;;;IAMxB,MAAM;QACJ,QACE,0DAAG,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IACnC,8DAAa,CACX,EACJ;KACH;;;;ACvBH,MAAM,eAAe,GAAG,yLAAyL,CAAC;AAClN,oCAAe,eAAe;;MCWjB,qBAAqB;;;;IAChC,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,oFAA2B,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAC,YAAY,GAAkB,EACvF,4DACE,8DAAa,CACX,CACC,EACP;KACH;;;;ACtBH,MAAM,QAAQ,GAAG,qIAAqI,CAAC;AACvJ,6BAAe,QAAQ;;MCUV,cAAc;;;;;;IAWzB,MAAM;QACJ,QACE,8DAAO,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAC1D,8DAAa,CACP,EACR;KACH;;;;;;","names":[],"sources":["src/components/hint/hint.scss?tag=admiralty-hint&encapsulation=scoped","src/components/hint/hint.tsx","src/components/input-invalid/input-invalid.scss?tag=admiralty-input-invalid&encapsulation=scoped","src/components/input-invalid/input-invalid.tsx","src/components/label/label.scss?tag=admiralty-label&encapsulation=scoped","src/components/label/label.tsx"],"sourcesContent":["@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\np {\n margin-top: 0;\n margin-bottom: 6px;\n display: block;\n font-weight: typography.$font-weight-light;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The hint content should be placed in the slot e.g.\n * `<admiralty-hint>Enter your full name</admiralty-hint>`\n */\n@Component({\n tag: 'admiralty-hint',\n styleUrl: 'hint.scss',\n scoped: true,\n})\nexport class HintComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n render() {\n return (\n <p class={{ disabled: this.disabled }}>\n <slot></slot>\n </p>\n );\n }\n}\n","@use '../../scss/vars/colours';\n\n:host {\n display: flex;\n align-items: center;\n}\n\nadmiralty-icon {\n color: colours.$colour-utility-error;\n margin: 4px 0;\n}\n\np {\n margin: 0;\n color: colours.$colour-utility-error;\n}\n","import { Component, h, Host } from '@stencil/core';\nimport { faExclamation } from '@fortawesome/free-solid-svg-icons';\n\n/**\n * @slot - The error content should be placed in the slot e.g.\n * `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`\n */\n@Component({\n tag: 'admiralty-input-invalid',\n styleUrl: 'input-invalid.scss',\n scoped: true,\n})\nexport class InputInvalidComponent {\n render() {\n return (\n <Host>\n <admiralty-icon icon-name={faExclamation.iconName} class=\"error-icon\"></admiralty-icon>\n <p>\n <slot></slot>\n </p>\n </Host>\n );\n }\n}\n","@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\nlabel {\n margin-bottom: 6px;\n display: inline-block;\n font-weight: typography.$font-weight-medium;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The label content should be placed in the slot e.g.\n * `<admiralty-label>First Name</admiralty-label>`\n */\n@Component({\n tag: 'admiralty-label',\n styleUrl: 'label.scss',\n scoped: true,\n})\nexport class LabelComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n /**\n * The id of the input the label is attached to\n */\n @Prop() for: string;\n\n render() {\n return (\n <label htmlFor={this.for} class={{ disabled: this.disabled }}>\n <slot></slot>\n </label>\n );\n }\n}\n"],"version":3}
@@ -58,7 +58,6 @@ const TypeAheadComponent = class {
58
58
  this.filterList = [];
59
59
  slotItems.forEach(el => {
60
60
  this.filterList.push(el.getAttribute('value'));
61
- console.log('fliterlist value ', el.getAttribute('value'));
62
61
  });
63
62
  }
64
63
  handleFocusIn() {
@@ -183,7 +182,7 @@ const TypeAheadComponent = class {
183
182
  return `${this.listId}-item-${i}`;
184
183
  }
185
184
  render() {
186
- return (h(Host, { key: '9c58ee688918a293bda88a9cf0150214510f7bc0', onFocusout: _ev => this.handleComponentFocusOut() }, h("div", { key: '3144d016e0594a18e4dc6d473c32599fae8c01d3', class: "visually-hidden" }, h("div", { key: 'e6c3c437cb4e12158b8ea880ce21c7908b68a638', class: "results-status-a", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''), h("div", { key: 'c35e28c3de7e3fb97f9e0c8aab2d3a34f658000b', class: "results-status-b", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && !this.isAlternateStatusSection ? this.statusText : '')), h("admiralty-input", { key: '88c82941c54dbad9fea476dbd5ec8b0c88efc1b8', type: "text", ref: el => (this.inputControl = el), label: this.label, hint: this.hint, placeholder: this.placeholder, class: "filterTextInput", onKeyUp: ev => this.handleKeyPressed(ev), onKeyDown: ev => this.handleKeyDown(ev), onFocusin: _ev => this.handleFocusIn(), onFocusout: _ev => this.handleFocusOut(), "aria-expanded": this.isFocused && this.filterResult.length > 0 }), h("span", { key: '3959c94636207a7fcefeabda1ab693f1aa0e2204', id: this.hintId, class: "visually-hidden" }, "When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."), this.filterResult.length > 0 ? (h("div", { class: "typeahead-list-container", ref: el => (this.listContainer = el) }, h("ul", { class: "typeahead-list", id: this.listId, role: "listbox" }, this.filterResult.map((item, i) => (h("li", { id: this.getListItemId(i), onMouseDown: _ev => this.handleItemSelected(item), onMouseOver: _ev => this.handleItemHovered(i), "aria-selected": i === this.selectedItemIndex, role: "option", tabindex: "-1", "aria-posinset": i + 1, "aria-setsize": this.filterResult.length }, item)))))) : null, h("slot", { key: 'bf5408374f50291a4adfa81cd23b4346712bbd8a' })));
185
+ return (h(Host, { key: '1b207cbc8db3ecc8f56bd37e0a4dd6467760e9f3', onFocusout: _ev => this.handleComponentFocusOut() }, h("div", { key: '35f64ad887609c0bfb61b2f14bb45e6ae4ea3b11', class: "visually-hidden" }, h("div", { key: '05a99b1fa37ae53f40f609a4b26b7ba35926cbae', class: "results-status-a", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''), h("div", { key: '560d3c5b1d383cf6055c29bd5ca44a8bd320c30e', class: "results-status-b", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !this.isSilenced && !this.isAlternateStatusSection ? this.statusText : '')), h("admiralty-input", { key: '3adc22e97d4c0c301806294ebf0636c71fddf120', type: "text", ref: el => (this.inputControl = el), label: this.label, hint: this.hint, placeholder: this.placeholder, class: "filterTextInput", onKeyUp: ev => this.handleKeyPressed(ev), onKeyDown: ev => this.handleKeyDown(ev), onFocusin: _ev => this.handleFocusIn(), onFocusout: _ev => this.handleFocusOut(), "aria-expanded": this.isFocused && this.filterResult.length > 0 }), h("span", { key: '996c387351a79a8b39df0cf3e1bacb18c190d03b', id: this.hintId, class: "visually-hidden" }, "When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures."), this.filterResult.length > 0 ? (h("div", { class: "typeahead-list-container", ref: el => (this.listContainer = el) }, h("ul", { class: "typeahead-list", id: this.listId, role: "listbox" }, this.filterResult.map((item, i) => (h("li", { id: this.getListItemId(i), onMouseDown: _ev => this.handleItemSelected(item), onMouseOver: _ev => this.handleItemHovered(i), "aria-selected": i === this.selectedItemIndex, role: "option", tabindex: "-1", "aria-posinset": i + 1, "aria-setsize": this.filterResult.length }, item)))))) : null, h("slot", { key: '2fd643c3154d7ece80fd1d1fab1c2058e477a047' })));
187
186
  }
188
187
  get el() { return getElement(this); }
189
188
  };
@@ -1 +1 @@
1
- {"file":"admiralty-type-ahead.entry.js","mappings":";;;AAAA,MAAM,YAAY,GAAG,2qKAA2qK,CAAC;AACjsK,iCAAe,YAAY;;MCOd,kBAAkB;;;;;QACrB,QAAG,GAAG,uBAAuB,EAAE,EAAE,EAAE,CAAC;QAE5C,WAAM,GAAG,GAAG,IAAI,CAAC,GAAG,iBAAiB,CAAC;QACtC,WAAM,GAAG,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;QAS5B,eAAU,GAAkB,EAAE,CAAC;QAE/B,sBAAiB,GAAG,CAAC,CAAC,CAAC;QACvB,cAAS,GAAG,KAAK,CAAC;QAElB,eAAU,GAAG,KAAK,CAAC;QACnB,6BAAwB,GAAG,KAAK,CAAC;QAKzB,mBAAc,GAAG,EAAE,CAAC;QACpB,8BAAyB,GAAG,KAAK,CAAC;4BAdR,IAAI,KAAK,EAAU;;;;;kCA+Cf,KAAK;;IA/B3C,IAAY,UAAU;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;KAC3C;IAED,IAAY,UAAU,CAAC,KAAa;QAClC,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC;KACjC;IAsCD,gBAAgB;Q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C,CACC,CACD,IACJ,IAAI,EACR,8DAAa,CACR,EACP;KACH;;;AAGH,IAAI,EAAE,GAAG,CAAC,CAAC;;;;;","names":[],"sources":["src/components/type-ahead/type-ahead.scss?tag=admiralty-type-ahead&encapsulation=scoped","src/components/type-ahead/type-ahead.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n@use '../../scss/base/a11y';\n@use '../../scss/base/typography';\n\n* {\n margin: 0px;\n padding: 0px;\n}\n\n.text-input-wrap {\n height: auto !important;\n}\n\n.filterTextInput {\n width: 100%;\n}\n\n.typeahead-list-container {\n position: relative;\n\n .typeahead-list {\n position: absolute;\n left: 0px;\n top: -24px;\n background-color: colours.$colour-white;\n width: 100%;\n box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);\n border: 2px solid colours.$colour-text;\n border-top: none;\n box-sizing: border-box;\n max-height: 180px;\n overflow-y: auto;\n z-index: 1;\n list-style: none;\n\n li {\n cursor: pointer;\n transform: unset !important;\n padding: 6px;\n min-height: 24px;\n margin: 0;\n }\n\n li:before {\n content: none;\n }\n\n li.highlighted {\n background-color: colours.$colour-admiralty-blue;\n color: colours.$colour-white;\n }\n }\n}\n","import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n console.log('fliterlist value ', el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"],"version":3}
1
+ {"file":"admiralty-type-ahead.entry.js","mappings":";;;AAAA,MAAM,YAAY,GAAG,2qKAA2qK,CAAC;AACjsK,iCAAe,YAAY;;MCOd,kBAAkB;;;;;QACrB,QAAG,GAAG,uBAAuB,EAAE,EAAE,EAAE,CAAC;QAE5C,WAAM,GAAG,GAAG,IAAI,CAAC,GAAG,iBAAiB,CAAC;QACtC,WAAM,GAAG,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;QAS5B,eAAU,GAAkB,EAAE,CAAC;QAE/B,sBAAiB,GAAG,CAAC,CAAC,CAAC;QACvB,cAAS,GAAG,KAAK,CAAC;QAElB,eAAU,GAAG,KAAK,CAAC;QACnB,6BAAwB,GAAG,KAAK,CAAC;QAKzB,mBAAc,GAAG,EAAE,CAAC;QACpB,8BAAyB,GAAG,KAAK,CAAC;4BAdR,IAAI,KAAK,EAAU;;;;;kCA+Cf,KAAK;;IA/B3C,IAAY,UAAU;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;KAC3C;IAED,IAAY,UAAU,CAAC,KAAa;QAClC,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC;KACjC;IAsCD,gBAAgB;QACd,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC;SAC9B;KACF;IAED,iBAAiB;QACf,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC;YACnC,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,WAAW,CAAC,IAAI,CAAC,CAAC;SACnB,CAAC,CAAC;QACH,IAA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G,IAAI,IAAI,CAAC,cAAc,EAAE,mBACzB,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,GAC5C,EAEnB,6DAAM,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAC,iBAAiB,iKAEvC,EACN,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,IAC3B,WAAK,KAAK,EAAC,0BAA0B,EAAC,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC,IACxE,UAAI,KAAK,EAAC,gBAAgB,EAAC,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAC,SAAS,IACvD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,MAC7B,UACE,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EACzB,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACjD,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,mBAC9B,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAC3C,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAC,IAAI,mBACE,CAAC,GAAG,CAAC,kBACN,IAAI,CAAC,YAAY,CAAC,MAAM,IAErC,IAAI,CACF,CACN,CAAC,CACC,CACD,IACJ,IAAI,EACR,8DAAa,CACR,EACP;KACH;;;AAGH,IAAI,EAAE,GAAG,CAAC,CAAC;;;;;","names":[],"sources":["src/components/type-ahead/type-ahead.scss?tag=admiralty-type-ahead&encapsulation=scoped","src/components/type-ahead/type-ahead.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n@use '../../scss/base/a11y';\n@use '../../scss/base/typography';\n\n* {\n margin: 0px;\n padding: 0px;\n}\n\n.text-input-wrap {\n height: auto !important;\n}\n\n.filterTextInput {\n width: 100%;\n}\n\n.typeahead-list-container {\n position: relative;\n\n .typeahead-list {\n position: absolute;\n left: 0px;\n top: -24px;\n background-color: colours.$colour-white;\n width: 100%;\n box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);\n border: 2px solid colours.$colour-text;\n border-top: none;\n box-sizing: border-box;\n max-height: 180px;\n overflow-y: auto;\n z-index: 1;\n list-style: none;\n\n li {\n cursor: pointer;\n transform: unset !important;\n padding: 6px;\n min-height: 24px;\n margin: 0;\n }\n\n li:before {\n content: none;\n }\n\n li.highlighted {\n background-color: colours.$colour-admiralty-blue;\n color: colours.$colour-white;\n }\n }\n}\n","import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"],"version":3}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukho/admiralty-core",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Stencil Component Starter",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -70,5 +70,5 @@
70
70
  "license": "MIT",
71
71
  "url": "https://github.com/UKHO/admiralty-design-system",
72
72
  "repository": "git://github.com/UKHO/admiralty-design-system.git",
73
- "gitHead": "f9877c858b6c00e28a73a729379ca5898940c188"
73
+ "gitHead": "0309fc4d50c588fdf7498b2405dae81ac0d217fb"
74
74
  }
@@ -1 +0,0 @@
1
- {"version":3,"names":["typeAheadCss","AdmiraltyTypeAheadStyle0","TypeAheadComponent","this","_id","id","hintId","listId","filterList","selectedItemIndex","isFocused","isSilenced","isAlternateStatusSection","originalSearch","hasBeenFocusedAtLeastOnce","Array","inputValue","inputControl","value","toString","componentDidLoad","connectedCallback","mutation","MutationObserver","populateFilterList","forceUpdate","observe","el","childList","subtree","disconnectedCallback","disconnect","undefined","slotItems","querySelectorAll","forEach","push","getAttribute","console","log","handleFocusIn","resultsOnInitFocus","performFilter","handleFocusOut","statusText","textChanged","valueChanged","emit","handleKeyPressed","event","stopImmediatePropagation","key","Keys","UP_ARROW","DOWN_ARROW","navigateSuggestions","updateScroll","ENTER","selectCurrentItem","handleKeyDown","TAB","handleItemSelected","filterResult","selectionChanged","filter","text","length","toLowerCase","indexOf","addHighlight","listItem","querySelector","getListItemId","classList","add","removeHighlight","i","remove","selectedItemText","handleItemHovered","index","handleComponentFocusOut","_a","container","listContainer","ul","selectedItem","from","childNodes","find","item","ariaPosInSet","scrollHeight","clientHeight","scrollIntoView","render","h","Host","onFocusout","_ev","class","role","type","ref","label","hint","placeholder","onKeyUp","ev","onKeyDown","onFocusin","map","onMouseDown","onMouseOver","tabindex"],"sources":["src/components/type-ahead/type-ahead.scss?tag=admiralty-type-ahead&encapsulation=scoped","src/components/type-ahead/type-ahead.tsx"],"sourcesContent":["@use '../../scss/vars/colours';\n@use '../../scss/base/a11y';\n@use '../../scss/base/typography';\n\n* {\n margin: 0px;\n padding: 0px;\n}\n\n.text-input-wrap {\n height: auto !important;\n}\n\n.filterTextInput {\n width: 100%;\n}\n\n.typeahead-list-container {\n position: relative;\n\n .typeahead-list {\n position: absolute;\n left: 0px;\n top: -24px;\n background-color: colours.$colour-white;\n width: 100%;\n box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);\n border: 2px solid colours.$colour-text;\n border-top: none;\n box-sizing: border-box;\n max-height: 180px;\n overflow-y: auto;\n z-index: 1;\n list-style: none;\n\n li {\n cursor: pointer;\n transform: unset !important;\n padding: 6px;\n min-height: 24px;\n margin: 0;\n }\n\n li:before {\n content: none;\n }\n\n li.highlighted {\n background-color: colours.$colour-admiralty-blue;\n color: colours.$colour-white;\n }\n }\n}\n","import { Component, EventEmitter, Host, Prop, Event, h, State, Element, forceUpdate } from '@stencil/core';\nimport { Keys } from '../Keys';\n\n@Component({\n tag: 'admiralty-type-ahead',\n styleUrl: 'type-ahead.scss',\n scoped: true,\n})\nexport class TypeAheadComponent {\n private _id = `admiralty-typeahead-${++id}`;\n\n hintId = `${this._id}-assistive-hint`;\n listId = `${this._id}-list`;\n\n @Element() el: HTMLElement;\n\n listContainer!: HTMLDivElement;\n inputControl!: HTMLAdmiraltyInputElement;\n\n @State() filterResult: string[] = new Array<string>();\n\n filterList: Array<string> = [];\n\n selectedItemIndex = -1;\n isFocused = false;\n\n isSilenced = false;\n isAlternateStatusSection = false;\n statusText: string;\n\n private mutation: MutationObserver;\n\n private originalSearch = '';\n private hasBeenFocusedAtLeastOnce = false;\n\n private get inputValue() {\n return this.inputControl.value.toString();\n }\n\n private set inputValue(value: string) {\n this.inputControl.value = value;\n }\n\n /**\n * The value of the textinput\n */\n @Prop() value: string;\n\n /**\n * The text content of the label for the input box\n */\n @Prop() label: string;\n\n /**\n * The hint which will be used under the label to describe the input.\n */\n @Prop() hint: string;\n\n /**\n * The placeholder text for the input field\n */\n @Prop() placeholder: string;\n\n /**\n * Optional property to show results when input box is initally focused\n */\n @Prop() resultsOnInitFocus: boolean = false;\n\n /**\n * Optional function that will be executed when the user selects an item from the typeahead\n */\n @Event() selectionChanged: EventEmitter<string>;\n\n /**\n * Event that is fired whenever the value of the typeahead changes\n * e.g. selection from the dropdown or manually typed entry\n */\n @Event() valueChanged: EventEmitter<string>;\n\n componentDidLoad() {\n if (this.value) {\n this.inputValue = this.value;\n }\n }\n\n connectedCallback() {\n this.mutation = new MutationObserver(() => {\n this.populateFilterList();\n forceUpdate(this);\n });\n this.mutation.observe(this.el, {\n childList: true,\n subtree: true,\n });\n }\n\n disconnectedCallback() {\n if (this.mutation) {\n this.mutation.disconnect();\n this.mutation = undefined;\n }\n }\n\n populateFilterList() {\n const slotItems = this.el.querySelectorAll('admiralty-type-ahead-item');\n this.filterList = [];\n slotItems.forEach(el => {\n this.filterList.push(el.getAttribute('value'));\n console.log('fliterlist value ', el.getAttribute('value'));\n });\n }\n\n handleFocusIn() {\n if (this.resultsOnInitFocus && !this.hasBeenFocusedAtLeastOnce) {\n this.performFilter('');\n this.hasBeenFocusedAtLeastOnce = true;\n }\n\n this.isFocused = true;\n this.isSilenced = false;\n }\n\n handleFocusOut() {\n this.isFocused = false;\n this.statusText = null;\n this.isSilenced = true;\n }\n\n private textChanged(value: string): void {\n this.originalSearch = value;\n this.performFilter(value);\n this.isSilenced = false;\n this.valueChanged.emit(value);\n }\n\n handleKeyPressed(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.UP_ARROW || event.key === Keys.DOWN_ARROW) {\n this.navigateSuggestions(event.key);\n this.updateScroll();\n } else if (event.key !== Keys.ENTER) {\n this.textChanged(this.inputValue);\n this.selectCurrentItem();\n }\n }\n\n handleKeyDown(event: KeyboardEvent): void {\n event.stopImmediatePropagation();\n\n if (event.key === Keys.TAB || event.key === Keys.ENTER) {\n this.selectCurrentItem();\n }\n }\n\n handleItemSelected(value: string): void {\n this.inputValue = value;\n this.textChanged(value);\n this.filterResult = new Array<string>();\n this.selectionChanged.emit(value);\n }\n\n private performFilter(value: string) {\n const filter = (filterList: string[], text: string) => {\n const filterResult = filterList.filter(value => {\n return text === null || text.length < 1 || value.toLowerCase().indexOf(text.toLowerCase()) > -1;\n });\n return filterResult;\n };\n\n this.filterResult = filter(this.filterList, value);\n\n this.selectedItemIndex = -1;\n }\n\n private addHighlight() {\n if (this.selectedItemIndex > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(this.selectedItemIndex)}`);\n listItem.classList.add('highlighted');\n }\n }\n\n private removeHighlight(i: number) {\n if (i > -1) {\n const listItem = this.el.querySelector(`#${this.getListItemId(i)}`);\n listItem.classList.remove('highlighted');\n }\n }\n\n private selectCurrentItem(): void {\n if (this.selectedItemIndex >= 0) {\n const selectedItemText = this.filterResult[this.selectedItemIndex];\n this.handleItemSelected(selectedItemText);\n }\n }\n\n handleItemHovered(index: number): void {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex = index;\n this.addHighlight();\n }\n\n handleComponentFocusOut() {\n // Ensure dropdown closed on clicking or tabbing away from this component\n if (this.filterResult?.length > 0) {\n this.filterResult = new Array<string>();\n this.hasBeenFocusedAtLeastOnce = false;\n }\n }\n\n /**\n * Check if the selected option is in view, and scroll if not\n */\n private updateScroll() {\n const container = this.listContainer;\n\n const ul = container.querySelector('ul');\n const selectedItem: any = Array.from(ul.childNodes).find((item: any) => item.ariaPosInSet === `${this.selectedItemIndex + 1}`);\n\n if (container && selectedItem && container.scrollHeight + container.clientHeight) {\n selectedItem.scrollIntoView();\n }\n }\n\n private navigateSuggestions(key: Keys) {\n if (key === Keys.UP_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex--;\n if (this.selectedItemIndex === -2) {\n this.selectedItemIndex = this.filterResult.length - 1;\n }\n }\n if (key === Keys.DOWN_ARROW) {\n this.removeHighlight(this.selectedItemIndex);\n this.selectedItemIndex++;\n if (this.selectedItemIndex > this.filterResult.length - 1) {\n this.selectedItemIndex = -1;\n }\n }\n if (this.selectedItemIndex === -1) {\n this.inputValue = this.originalSearch;\n } else {\n const value = this.filterResult[this.selectedItemIndex];\n\n this.inputValue = value;\n\n this.addHighlight();\n }\n }\n\n private getListItemId(i: number) {\n return `${this.listId}-item-${i}`;\n }\n\n render() {\n return (\n <Host onFocusout={_ev => this.handleComponentFocusOut()}>\n <div class=\"visually-hidden\">\n <div class=\"results-status-a\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n <div class=\"results-status-b\" role=\"status\" aria-atomic=\"true\" aria-live=\"polite\">\n {!this.isSilenced && !this.isAlternateStatusSection ? this.statusText : ''}\n </div>\n </div>\n <admiralty-input\n type=\"text\"\n ref={el => (this.inputControl = el)}\n label={this.label}\n hint={this.hint}\n placeholder={this.placeholder}\n class=\"filterTextInput\"\n onKeyUp={ev => this.handleKeyPressed(ev)}\n onKeyDown={ev => this.handleKeyDown(ev)}\n onFocusin={_ev => this.handleFocusIn()}\n onFocusout={_ev => this.handleFocusOut()}\n aria-expanded={this.isFocused && this.filterResult.length > 0}\n ></admiralty-input>\n\n <span id={this.hintId} class=\"visually-hidden\">\n When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.\n </span>\n {this.filterResult.length > 0 ? (\n <div class=\"typeahead-list-container\" ref={el => (this.listContainer = el)}>\n <ul class=\"typeahead-list\" id={this.listId} role=\"listbox\">\n {this.filterResult.map((item, i) => (\n <li\n id={this.getListItemId(i)}\n onMouseDown={_ev => this.handleItemSelected(item)}\n onMouseOver={_ev => this.handleItemHovered(i)}\n aria-selected={i === this.selectedItemIndex}\n role=\"option\"\n tabindex=\"-1\"\n aria-posinset={i + 1}\n aria-setsize={this.filterResult.length}\n >\n {item}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n <slot></slot>\n </Host>\n );\n }\n}\n\nlet id = 0;\n"],"mappings":"2GAAA,MAAMA,EAAe,gpKACrB,MAAAC,EAAeD,E,MCOFE,EAAkB,M,uHACrBC,KAAAC,IAAM,yBAAyBC,IAEvCF,KAAAG,OAAS,GAAGH,KAAKC,qBACjBD,KAAAI,OAAS,GAAGJ,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@
1
- import{r as a,h as e,H as d}from"./p-ac0ad15a.js";import{a as t}from"./p-a28a614b.js";const i="p.sc-admiralty-hint{margin-top:0;margin-bottom:6px;display:block;font-weight:300}p.disabled.sc-admiralty-hint{color:#adadad}";const c=i;const s=class{constructor(e){a(this,e);this.disabled=undefined}render(){return e("p",{key:"d5c32ab0bb0416a7f1e10ae3c134477785cd9c2b",class:{disabled:this.disabled}},e("slot",{key:"2f34effc00bded2b043d3e6329a6d3f1d9e8ba0e"}))}};s.style=c;const l=".sc-admiralty-input-invalid-h{display:flex;align-items:center}admiralty-icon.sc-admiralty-input-invalid{color:#e20d0d}p.sc-admiralty-input-invalid{margin:0;color:#e20d0d}";const n=l;const r=class{constructor(e){a(this,e)}render(){return e(d,{key:"9267bec797b4495d10b0a5095c7406a8b9d45189"},e("admiralty-icon",{key:"4d2be552269678fb718cc1a431e8e734602c7dcf","icon-name":t.iconName,class:"error-icon"}),e("p",{key:"2bdee004583f330f204e3601e2dc6fa6dee5759e"},e("slot",{key:"5544283b85989a983a59a2cce4eb4f6de6fae41e"})))}};r.style=n;const o="label.sc-admiralty-label{margin-bottom:6px;display:inline-block;font-weight:normal}label.disabled.sc-admiralty-label{color:#adadad}";const b=o;const m=class{constructor(e){a(this,e);this.disabled=undefined;this.for=undefined}render(){return e("label",{key:"685f1ed5184b955228654c935f24b45efe7b84b0",htmlFor:this.for,class:{disabled:this.disabled}},e("slot",{key:"561906355acbccdaf9cdc12fd09225bae6946d50"}))}};m.style=b;export{s as admiralty_hint,r as admiralty_input_invalid,m as admiralty_label};
2
- //# sourceMappingURL=p-6492124b.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["hintCss","AdmiraltyHintStyle0","HintComponent","render","h","key","class","disabled","this","inputInvalidCss","AdmiraltyInputInvalidStyle0","InputInvalidComponent","Host","faExclamation","iconName","labelCss","AdmiraltyLabelStyle0","LabelComponent","htmlFor","for"],"sources":["src/components/hint/hint.scss?tag=admiralty-hint&encapsulation=scoped","src/components/hint/hint.tsx","src/components/input-invalid/input-invalid.scss?tag=admiralty-input-invalid&encapsulation=scoped","src/components/input-invalid/input-invalid.tsx","src/components/label/label.scss?tag=admiralty-label&encapsulation=scoped","src/components/label/label.tsx"],"sourcesContent":["@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\np {\n margin-top: 0;\n margin-bottom: 6px;\n display: block;\n font-weight: typography.$font-weight-light;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The hint content should be placed in the slot e.g.\n * `<admiralty-hint>Enter your full name</admiralty-hint>`\n */\n@Component({\n tag: 'admiralty-hint',\n styleUrl: 'hint.scss',\n scoped: true,\n})\nexport class HintComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n render() {\n return (\n <p class={{ disabled: this.disabled }}>\n <slot></slot>\n </p>\n );\n }\n}\n","@use '../../scss/vars/colours';\n\n:host {\n display: flex;\n align-items: center;\n}\n\nadmiralty-icon {\n color: colours.$colour-utility-error;\n}\n\np {\n margin: 0;\n color: colours.$colour-utility-error;\n}\n\n","import { Component, h, Host } from '@stencil/core';\nimport { faExclamation } from '@fortawesome/free-solid-svg-icons';\n\n/**\n * @slot - The error content should be placed in the slot e.g.\n * `<admiralty-input-invalid>This field is required</admiralty-input-invalid>`\n */\n@Component({\n tag: 'admiralty-input-invalid',\n styleUrl: 'input-invalid.scss',\n scoped: true,\n})\nexport class InputInvalidComponent {\n render() {\n return (\n <Host>\n <admiralty-icon icon-name={faExclamation.iconName} class=\"error-icon\"></admiralty-icon>\n <p>\n <slot></slot>\n </p>\n </Host>\n );\n }\n}\n","@use \"../../scss/vars/colours\";\n@use \"../../scss/vars/typography\";\n\nlabel {\n margin-bottom: 6px;\n display: inline-block;\n font-weight: typography.$font-weight-medium;\n\n &.disabled {\n color: colours.$colour-textinput-text-disabled;\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\n/**\n * @slot - The label content should be placed in the slot e.g.\n * `<admiralty-label>First Name</admiralty-label>`\n */\n@Component({\n tag: 'admiralty-label',\n styleUrl: 'label.scss',\n scoped: true,\n})\nexport class LabelComponent {\n /**\n * The disabled option can be used to disable the component.\n */\n @Prop() disabled: boolean;\n\n /**\n * The id of the input the label is attached to\n */\n @Prop() for: string;\n\n render() {\n return (\n <label htmlFor={this.for} class={{ disabled: this.disabled }}>\n <slot></slot>\n </label>\n );\n }\n}\n"],"mappings":"sFAAA,MAAMA,EAAU,+HAChB,MAAAC,EAAeD,E,MCUFE,EAAa,M,iDAMxB,MAAAC,GACE,OACEC,EAAA,KAAAC,IAAA,2CAAGC,MAAO,CAAEC,SAAUC,KAAKD,WACzBH,EAAA,QAAAC,IAAA,6C,aCpBR,MAAMI,EAAkB,6KACxB,MAAAC,EAAeD,E,MCWFE,EAAqB,M,yBAChC,MAAAR,GACE,OACEC,EAACQ,EAAI,CAAAP,IAAA,4CACHD,EAAA,kBAAAC,IAAA,uDAA2BQ,EAAcC,SAAUR,MAAM,eACzDF,EAAA,KAAAC,IAAA,4CACED,EAAA,QAAAC,IAAA,8C,aClBV,MAAMU,EAAW,sIACjB,MAAAC,EAAeD,E,MCUFE,EAAc,M,oEAWzB,MAAAd,GACE,OACEC,EAAA,SAAAC,IAAA,2CAAOa,QAASV,KAAKW,IAAKb,MAAO,CAAEC,SAAUC,KAAKD,WAChDH,EAAA,QAAAC,IAAA,6C"}