@digital-realty/ix-select
Advanced tools
Comparing version 1.0.40-alpha-222122-t56.0 to 1.0.40-alpha-222662-t51.0
@@ -1,2 +0,2 @@ | ||
import{LitElement,html,nothing,isServer,css}from"lit";import{__decorate}from"tslib";import"@digital-realty/ix-icon/ix-icon.js";import{requestUpdateOnAriaChange}from"@material/web/internal/aria/delegate.js";import{DEFAULT_TYPEAHEAD_BUFFER_TIME}from"@material/web/menu/internal/menu.js";import"@material/web/select/filled-select.js";import"@material/web/select/outlined-select.js";import{property,query,queryAssignedElements,queryAssignedNodes,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{literal,html as html$1}from"lit/static-html.js";import{styles}from"@material/web/menu/internal/menuitem/menu-item-styles.css.js";import"@material/web/ripple/ripple.js";import"@material/web/focus/md-focus-ring.js";import"@material/web/labs/item/item.js";import{classMap}from"lit/directives/class-map.js";import{MenuItemController}from"@material/web/menu/internal/controllers/menuItemController.js";function createRequestSelectionEvent(){return new Event("request-selection",{bubbles:!0,composed:!0})}function createRequestDeselectionEvent(){return new Event("request-deselection",{bubbles:!0,composed:!0})}class SelectOptionController{get role(){return this.menuItemController.role}get typeaheadText(){return this.menuItemController.typeaheadText}setTypeaheadText(e){this.menuItemController.setTypeaheadText(e)}get displayText(){if(null!==this.internalDisplayText)return this.internalDisplayText;var e=this.getHeadlineElements();let t=[];return e.forEach(e=>{e.textContent&&e.textContent.trim()&&t.push(e.textContent.trim())}),t.join(" ")}setDisplayText(e){this.internalDisplayText=e}constructor(e,t){this.host=e,this.internalDisplayText=null,this.lastSelected=this.host.selected,this.firstUpdate=!0,this.onClick=()=>{this.menuItemController.onClick()},this.onKeydown=e=>{this.menuItemController.onKeydown(e)},this.menuItemController=new MenuItemController(e,t),this.getHeadlineElements=t.getHeadlineElements,e.addController(this)}hostUpdate(){this.lastSelected!==this.host.selected&&(this.host.ariaSelected=this.host.selected?"true":"false")}hostUpdated(){this.lastSelected===this.host.selected||this.firstUpdate||(this.host.selected?this.host.dispatchEvent(createRequestSelectionEvent()):this.host.dispatchEvent(createRequestDeselectionEvent())),this.lastSelected=this.host.selected,this.firstUpdate=!1}}class IxSelectOption extends LitElement{constructor(){super(...arguments),this.disabled=!1,this.isMenuItem=!0,this.selected=!1,this.value="",this.type="option",this.selectOptionController=new SelectOptionController(this,{getHeadlineElements:()=>this.headlineElements,getSupportingTextElements:()=>this.supportingTextElements,getDefaultElements:()=>this.defaultElements,getInteractiveElement:()=>this.listItemRoot})}get typeaheadText(){return this.selectOptionController.typeaheadText}set typeaheadText(e){this.selectOptionController.setTypeaheadText(e)}get displayText(){return this.selectOptionController.displayText}set displayText(e){this.selectOptionController.setDisplayText(e)}render(){return this.renderListItem(html`<md-item><div slot="container">${this.renderRipple()} ${this.renderFocusRing()}</div><slot name="start" slot="start"></slot><slot name="end" slot="end"></slot>${this.renderBody()}</md-item>`)}renderListItem(e){return html`<li id="item" tabindex="${this.disabled?-1:0}" role="${this.selectOptionController.role}" aria-label="${this.ariaLabel||nothing}" aria-selected="${this.ariaSelected||nothing}" aria-checked="${this.ariaChecked||nothing}" aria-expanded="${this.ariaExpanded||nothing}" aria-haspopup="${this.ariaHasPopup||nothing}" class="list-item ${classMap(this.getRenderClasses())}" @click="${this.selectOptionController.onClick}" @keydown="${this.selectOptionController.onKeydown}">${e}</li>`}renderRipple(){return html`<md-ripple part="ripple" for="item" ?disabled="${this.disabled}"></md-ripple>`}renderFocusRing(){return html`<md-focus-ring part="focus-ring" for="item" inward></md-focus-ring>`}getRenderClasses(){return{disabled:this.disabled,selected:this.selected}}renderBody(){return html`<slot></slot><slot name="overline" slot="overline"></slot><slot name="headline" slot="headline"></slot><slot name="supporting-text" slot="supporting-text"></slot><slot name="trailing-supporting-text" slot="trailing-supporting-text"></slot>`}focus(){var e;null!=(e=this.listItemRoot)&&e.focus()}}requestUpdateOnAriaChange(IxSelectOption),IxSelectOption.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0},__decorate([property({type:Boolean,reflect:!0})],IxSelectOption.prototype,"disabled",void 0),__decorate([property({type:Boolean,attribute:"md-menu-item",reflect:!0})],IxSelectOption.prototype,"isMenuItem",void 0),__decorate([property({type:Boolean})],IxSelectOption.prototype,"selected",void 0),__decorate([property()],IxSelectOption.prototype,"value",void 0),__decorate([query(".list-item")],IxSelectOption.prototype,"listItemRoot",void 0),__decorate([queryAssignedElements({slot:"headline"})],IxSelectOption.prototype,"headlineElements",void 0),__decorate([queryAssignedElements({slot:"supporting-text"})],IxSelectOption.prototype,"supportingTextElements",void 0),__decorate([queryAssignedNodes({slot:""})],IxSelectOption.prototype,"defaultElements",void 0),__decorate([property({attribute:"typeahead-text"})],IxSelectOption.prototype,"typeaheadText",null),__decorate([property({attribute:"display-text"})],IxSelectOption.prototype,"displayText",null);class IxSelectOptionStyled extends IxSelectOption{}var _a;IxSelectOptionStyled.styles=[styles],window.customElements.define("ix-select-option",IxSelectOptionStyled);let VALUE=Symbol("value");class IxSelect extends LitElement{constructor(){super(...arguments),this.minWidth=0,this.wideMenu=!1,this.filled=!1,this.label="",this.quick=!1,this.required=!1,this.disabled=!1,this.errorText="",this.supportingText="",this.error=!1,this.displayText="",this.leadingIcon="",this.trailingIcon="",this.menuPositioning="absolute",this.typeaheadDelay=DEFAULT_TYPEAHEAD_BUFFER_TIME,this.selectedIndex=-1,this.nativeError=!1,this.nativeErrorText="",this.internals=this.attachInternals(),this.customValidationMessage="",this[_a]="",this.handleResize=()=>{this.minWidth=0},this.handleScroll=()=>{var e;"absolute"!==this.menuPositioning&&(e=null==(e=this.shadowRoot)?void 0:e.querySelector(".select")).open&&(e.open=!1)}}get hasError(){return this.error||this.nativeError}get form(){return this.internals.form}get labels(){return this.internals.labels}get name(){var e;return null!=(e=this.getAttribute("name"))?e:""}set name(e){this.setAttribute("name",e)}get validity(){return this.syncValidity(),this.internals.validity}get value(){return this[VALUE]=this.component.value,this[VALUE]}set value(e){isServer||(this.component.value=e)}get validationMessage(){return this.syncValidity(),this.internals.validationMessage}handleSelection(){this.internals.setFormValue(this.component.value),this.syncValidity()}setMenuWidth(){this.wideMenu&&(this.minWidth=this.component.offsetWidth)}async getUpdateComplete(){return await super.getUpdateComplete(),await this.component.updateComplete,this.setMenuWidth(),this.internals.setFormValue(this.component.value),!0}async updated(e){e.has("required")&&this.syncValidity(),await this.getUpdateComplete()}getErrorText(){return this.error?this.errorText:this.nativeErrorText}async syncValidity(){var e=this.required&&!this.component.value,t=!!this.customValidationMessage,i=this.customValidationMessage||e&&this.getRequiredValidationMessage()||"";this.internals.setValidity({valueMissing:e,customError:t},i,this.component)}getRequiredValidationMessage(){var e=document.createElement("select");return e.required=!0,e.validationMessage}checkValidity(){return this.syncValidity(),this.internals.checkValidity()}reportValidity(){return this.component.reportValidity()}setCustomValidity(e){this.customValidationMessage=e,this.syncValidity()}focus(){var e;null!=(e=null==(e=this.component.shadowRoot)?void 0:e.querySelector(".field"))&&e.focus()}onBlur(e){var t=e.relatedTarget;"IX-SELECT-OPTION"===(null==t?void 0:t.tagName)&&e.stopPropagation()}reset(){this.component.reset(),this.internals.setFormValue(this.component.value)}formResetCallback(){this.reset()}formStateRestoreCallback(e){this.value=e}connectedCallback(){super.connectedCallback(),!isServer&&this.wideMenu&&window.addEventListener("resize",this.handleResize),window.addEventListener("scroll",this.handleScroll)}disconnectedCallback(){super.disconnectedCallback(),!isServer&&this.wideMenu&&window.removeEventListener("resize",this.handleResize),window.removeEventListener("scroll",this.handleScroll)}render(){var e=this.filled?literal`md-filled-select`:literal`md-outlined-select`,t=this.label||this.ariaLabel;return html$1`<${e} | ||
import{LitElement,html,nothing,isServer,css}from"lit";import{__decorate}from"tslib";import"@digital-realty/ix-icon/ix-icon.js";import{requestUpdateOnAriaChange}from"@material/web/internal/aria/delegate.js";import{DEFAULT_TYPEAHEAD_BUFFER_TIME}from"@material/web/menu/internal/menu.js";import"@material/web/select/filled-select.js";import"@material/web/select/outlined-select.js";import{property,query,queryAssignedElements,queryAssignedNodes,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{literal,html as html$1}from"lit/static-html.js";import{styles}from"@material/web/menu/internal/menuitem/menu-item-styles.css.js";import"@material/web/ripple/ripple.js";import"@material/web/focus/md-focus-ring.js";import"@material/web/labs/item/item.js";import{classMap}from"lit/directives/class-map.js";import{MenuItemController}from"@material/web/menu/internal/controllers/menuItemController.js";function createRequestSelectionEvent(){return new Event("request-selection",{bubbles:!0,composed:!0})}function createRequestDeselectionEvent(){return new Event("request-deselection",{bubbles:!0,composed:!0})}class SelectOptionController{get role(){return this.menuItemController.role}get typeaheadText(){return this.menuItemController.typeaheadText}setTypeaheadText(e){this.menuItemController.setTypeaheadText(e)}get displayText(){if(null!==this.internalDisplayText)return this.internalDisplayText;var e=this.getHeadlineElements();let t=[];return e.forEach(e=>{e.textContent&&e.textContent.trim()&&t.push(e.textContent.trim())}),t.join(" ")}setDisplayText(e){this.internalDisplayText=e}constructor(e,t){this.host=e,this.internalDisplayText=null,this.lastSelected=this.host.selected,this.firstUpdate=!0,this.onClick=()=>{this.menuItemController.onClick()},this.onKeydown=e=>{this.menuItemController.onKeydown(e)},this.menuItemController=new MenuItemController(e,t),this.getHeadlineElements=t.getHeadlineElements,e.addController(this)}hostUpdate(){this.lastSelected!==this.host.selected&&(this.host.ariaSelected=this.host.selected?"true":"false")}hostUpdated(){this.lastSelected===this.host.selected||this.firstUpdate||(this.host.selected?this.host.dispatchEvent(createRequestSelectionEvent()):this.host.dispatchEvent(createRequestDeselectionEvent())),this.lastSelected=this.host.selected,this.firstUpdate=!1}}class IxSelectOption extends LitElement{constructor(){super(...arguments),this.disabled=!1,this.isMenuItem=!0,this.selected=!1,this.value="",this.type="option",this.selectOptionController=new SelectOptionController(this,{getHeadlineElements:()=>this.headlineElements,getSupportingTextElements:()=>this.supportingTextElements,getDefaultElements:()=>this.defaultElements,getInteractiveElement:()=>this.listItemRoot})}get typeaheadText(){return this.selectOptionController.typeaheadText}set typeaheadText(e){this.selectOptionController.setTypeaheadText(e)}get displayText(){return this.selectOptionController.displayText}set displayText(e){this.selectOptionController.setDisplayText(e)}render(){return this.renderListItem(html`<md-item><div slot="container">${this.renderRipple()} ${this.renderFocusRing()}</div><slot name="start" slot="start"></slot><slot name="end" slot="end"></slot>${this.renderBody()}</md-item>`)}renderListItem(e){return html`<li id="item" tabindex="${this.disabled?-1:0}" role="${this.selectOptionController.role}" aria-label="${this.ariaLabel||nothing}" aria-selected="${this.ariaSelected||nothing}" aria-checked="${this.ariaChecked||nothing}" aria-expanded="${this.ariaExpanded||nothing}" aria-haspopup="${this.ariaHasPopup||nothing}" class="list-item ${classMap(this.getRenderClasses())}" @click="${this.selectOptionController.onClick}" @keydown="${this.selectOptionController.onKeydown}">${e}</li>`}renderRipple(){return html`<md-ripple part="ripple" for="item" ?disabled="${this.disabled}"></md-ripple>`}renderFocusRing(){return html`<md-focus-ring part="focus-ring" for="item" inward></md-focus-ring>`}getRenderClasses(){return{disabled:this.disabled,selected:this.selected}}renderBody(){return html`<slot></slot><slot name="overline" slot="overline"></slot><slot name="headline" slot="headline"></slot><slot name="supporting-text" slot="supporting-text"></slot><slot name="trailing-supporting-text" slot="trailing-supporting-text"></slot>`}focus(){var e;null!=(e=this.listItemRoot)&&e.focus()}}requestUpdateOnAriaChange(IxSelectOption),IxSelectOption.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0},__decorate([property({type:Boolean,reflect:!0})],IxSelectOption.prototype,"disabled",void 0),__decorate([property({type:Boolean,attribute:"md-menu-item",reflect:!0})],IxSelectOption.prototype,"isMenuItem",void 0),__decorate([property({type:Boolean})],IxSelectOption.prototype,"selected",void 0),__decorate([property()],IxSelectOption.prototype,"value",void 0),__decorate([query(".list-item")],IxSelectOption.prototype,"listItemRoot",void 0),__decorate([queryAssignedElements({slot:"headline"})],IxSelectOption.prototype,"headlineElements",void 0),__decorate([queryAssignedElements({slot:"supporting-text"})],IxSelectOption.prototype,"supportingTextElements",void 0),__decorate([queryAssignedNodes({slot:""})],IxSelectOption.prototype,"defaultElements",void 0),__decorate([property({attribute:"typeahead-text"})],IxSelectOption.prototype,"typeaheadText",null),__decorate([property({attribute:"display-text"})],IxSelectOption.prototype,"displayText",null);class IxSelectOptionStyled extends IxSelectOption{}var _a;IxSelectOptionStyled.styles=[styles],window.customElements.define("ix-select-option",IxSelectOptionStyled);let VALUE=Symbol("value");class IxSelect extends LitElement{constructor(){super(...arguments),this.minWidth=0,this.wideMenu=!1,this.filled=!1,this.label="",this.quick=!1,this.required=!1,this.disabled=!1,this.errorText="",this.supportingText="",this.error=!1,this.displayText="",this.leadingIcon="",this.trailingIcon="",this.menuPositioning="absolute",this.typeaheadDelay=DEFAULT_TYPEAHEAD_BUFFER_TIME,this.selectedIndex=-1,this.nativeError=!1,this.nativeErrorText="",this.internals=this.attachInternals(),this.customValidationMessage="",this[_a]="",this.handleResize=()=>{this.minWidth=0}}get hasError(){return this.error||this.nativeError}get form(){return this.internals.form}get labels(){return this.internals.labels}get name(){var e;return null!=(e=this.getAttribute("name"))?e:""}set name(e){this.setAttribute("name",e)}get validity(){return this.syncValidity(),this.internals.validity}get value(){return this[VALUE]=this.component.value,this[VALUE]}set value(e){isServer||(this.component.value=e)}get validationMessage(){return this.syncValidity(),this.internals.validationMessage}handleSelection(){this.internals.setFormValue(this.component.value),this.syncValidity()}setMenuSize(){var e=null==(e=this.shadowRoot)?void 0:e.querySelector(".select"),e=null==(e=null==(e=null==(e=null==e?void 0:e.shadowRoot)?void 0:e.querySelector("#listbox"))?void 0:e.shadowRoot)?void 0:e.querySelector(".menu");e.style&&(e.style.maxHeight="70vh"),this.wideMenu&&(this.minWidth=this.component.offsetWidth)}async getUpdateComplete(){return await super.getUpdateComplete(),await this.component.updateComplete,this.setMenuSize(),this.internals.setFormValue(this.component.value),!0}async updated(e){e.has("required")&&this.syncValidity(),await this.getUpdateComplete()}getErrorText(){return this.error?this.errorText:this.nativeErrorText}async syncValidity(){var e=this.required&&!this.component.value,t=!!this.customValidationMessage,i=this.customValidationMessage||e&&this.getRequiredValidationMessage()||"";this.internals.setValidity({valueMissing:e,customError:t},i,this.component)}getRequiredValidationMessage(){var e=document.createElement("select");return e.required=!0,e.validationMessage}checkValidity(){return this.syncValidity(),this.internals.checkValidity()}reportValidity(){return this.component.reportValidity()}setCustomValidity(e){this.customValidationMessage=e,this.syncValidity()}focus(){var e;null!=(e=null==(e=this.component.shadowRoot)?void 0:e.querySelector(".field"))&&e.focus()}onBlur(e){var t=e.relatedTarget;"IX-SELECT-OPTION"===(null==t?void 0:t.tagName)&&e.stopPropagation()}reset(){this.component.reset(),this.internals.setFormValue(this.component.value)}formResetCallback(){this.reset()}formStateRestoreCallback(e){this.value=e}connectedCallback(){super.connectedCallback(),!isServer&&this.wideMenu&&window.addEventListener("resize",this.handleResize)}disconnectedCallback(){super.disconnectedCallback(),!isServer&&this.wideMenu&&window.removeEventListener("resize",this.handleResize)}render(){var e=this.filled?literal`md-filled-select`:literal`md-outlined-select`,t=this.label||this.ariaLabel;return html$1`<${e} | ||
?disabled=${this.disabled} | ||
@@ -18,3 +18,3 @@ ?quick=${this.quick} | ||
@request-selection=${this.handleSelection} | ||
@opening=${this.setMenuWidth} | ||
@opening=${this.setMenuSize} | ||
class="select" | ||
@@ -21,0 +21,0 @@ style="min-width:${this.minWidth}px" |
@@ -108,3 +108,3 @@ import '@digital-realty/ix-icon/ix-icon.js'; | ||
private handleSelection; | ||
private setMenuWidth; | ||
private setMenuSize; | ||
getUpdateComplete(): Promise<boolean>; | ||
@@ -131,5 +131,4 @@ protected updated(changed: PropertyValues<Select>): Promise<void>; | ||
disconnectedCallback(): void; | ||
handleScroll: () => void; | ||
render(): import("lit").TemplateResult<1 | 2>; | ||
} | ||
export {}; |
@@ -105,12 +105,2 @@ var _a; | ||
}; | ||
this.handleScroll = () => { | ||
var _b; | ||
if (this.menuPositioning === 'absolute') { | ||
return; | ||
} | ||
const select = (_b = this.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.select'); | ||
if (select.open) { | ||
select.open = false; | ||
} | ||
}; | ||
} | ||
@@ -154,3 +144,11 @@ get hasError() { | ||
} | ||
setMenuWidth() { | ||
setMenuSize() { | ||
var _b, _c, _d, _e; | ||
const select = (_b = this.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.select'); | ||
const menu = (_e = (_d = (_c = select === null || select === void 0 ? void 0 : select.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#listbox')) === null || _d === void 0 ? void 0 : _d.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelector('.menu'); | ||
// Set max-height to 70vh to prevent menus with many options from overflowing the viewport which | ||
// can cause some options to become inaccessible: https://telxapp.atlassian.net/browse/IXUAT-9459 | ||
if (menu.style) { | ||
menu.style.maxHeight = `70vh`; | ||
} | ||
if (this.wideMenu) { | ||
@@ -163,3 +161,3 @@ this.minWidth = this.component.offsetWidth; | ||
await this.component.updateComplete; | ||
this.setMenuWidth(); | ||
this.setMenuSize(); | ||
this.internals.setFormValue(this.component.value); | ||
@@ -235,3 +233,2 @@ return true; | ||
} | ||
window.addEventListener('scroll', this.handleScroll); | ||
} | ||
@@ -243,3 +240,2 @@ disconnectedCallback() { | ||
} | ||
window.removeEventListener('scroll', this.handleScroll); | ||
} | ||
@@ -268,3 +264,3 @@ render() { | ||
@request-selection=${this.handleSelection} | ||
@opening=${this.setMenuWidth} | ||
@opening=${this.setMenuSize} | ||
class="select" | ||
@@ -271,0 +267,0 @@ style="min-width:${this.minWidth}px" |
@@ -6,3 +6,3 @@ { | ||
"author": "interxion", | ||
"version": "1.0.40-alpha-222122-t56.0", | ||
"version": "1.0.40-alpha-222662-t51.0", | ||
"type": "module", | ||
@@ -112,3 +112,3 @@ "main": "dist/index.js", | ||
], | ||
"gitHead": "964414ebf4fb5882367bd831e30b36ab247ca057" | ||
"gitHead": "65eca14abef55a13b88d8cc675f40a53a8c45004" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91765
2308
94
36
64
79
1110