@m3e/chips 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js
CHANGED
|
@@ -36,11 +36,11 @@ const ae={attribute:!0,type:String,converter:se,reflect:!1,hasChanged:oe},le=(e=
|
|
|
36
36
|
* Copyright 2017 Google LLC
|
|
37
37
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
38
|
*/
|
|
39
|
-
function he(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,i),i))(t,i,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}var de,pe,ue,ve,me,fe,be;let ge=class extends i{constructor(){super(...arguments),de.add(this),pe.set(this,void 0),ue.set(this,""),this.variant="outlined"}get value(){return N(this,pe,"f")??N(this,ue,"f")}set value(e){R(this,pe,e,"f")}firstUpdated(e){super.firstUpdated(e),"listitem"===this.role&&this.removeAttribute("tabindex"),[this._elevation,this._focusRing,this._stateLayer,this._ripple].forEach(e=>{e?.htmlFor||e?.attach(this)})}render(){const e=!r(this)||this.disabled,t=a(this)&&this.disabledInteractive;return o`<div class="base"><m3e-elevation class="elevation" ?disabled="${e||t}"></m3e-elevation><m3e-state-layer class="state-layer" ?disabled="${e||t}"></m3e-state-layer><m3e-focus-ring class="focus-ring" ?disabled="${e}"></m3e-focus-ring><m3e-ripple class="ripple" ?disabled="${e||t}"></m3e-ripple><div class="touch" aria-hidden="true"></div>${l(this)?this[c]():s}<div class="wrapper">${N(this,de,"m",ve).call(this)}</div></div>`}_renderIcon(){return o`<slot name="icon" aria-hidden="true" @slotchange="${N(this,de,"m",me)}"></slot>`}_renderTrailingIcon(){return o`<slot name="trailing-icon" aria-hidden="true" @slotchange="${N(this,de,"m",fe)}"></slot>`}_renderSlot(){return o`<slot @slotchange="${N(this,de,"m",be)}"></slot>`}};pe=new WeakMap,ue=new WeakMap,de=new WeakSet,ve=function(){return o`${this._renderIcon()}<div class="label">${this._renderSlot()}</div>${this._renderTrailingIcon()}`},me=function(e){this.classList.toggle("-with-icon",h(e.target))},fe=function(e){this.classList.toggle("-with-trailing-icon",h(e.target))},be=function(e){R(this,ue,d(e.target),"f")},ge.styles=t`:host { display: inline-block; vertical-align: middle; outline: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .base { box-sizing: border-box; vertical-align: middle; display: inline-flex; align-items: center; justify-content: center; position: relative; width: 100%; transition: ${e(`background-color ${n.motion.duration.short4} ${n.motion.easing.standard}`)}; border-radius: var(--m3e-chip-container-shape, ${n.shape.corner.small}); height: calc(var(--m3e-chip-container-height, 2rem) + ${n.density.calc(-2)}); font-size: var(--m3e-chip-label-text-font-size, ${n.typescale.standard.label.large.fontSize}); font-weight: var(--m3e-chip-label-text-font-weight, ${n.typescale.standard.label.large.fontWeight}); line-height: var(--m3e-chip-label-text-line-height, ${n.typescale.standard.label.large.lineHeight}); letter-spacing: var(--m3e-chip-label-text-tracking, ${n.typescale.standard.label.large.tracking}); } :host(:not(m3e-chip):not(:disabled):not([disabled-interactive])) { cursor: pointer; } :host(:not(m3e-chip):not(:disabled)[disabled-interactive]) { cursor: not-allowed; } :host(:not(m3e-chip):not(:disabled):not([disabled-interactive])) .base { user-select: none; } .touch { position: absolute; height: 3rem; left: 0; right: 0; } .wrapper { width: 100%; overflow: hidden; display: inline-flex; align-items: center; column-gap: var(--m3e-chip-spacing, 0.5rem); } .label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } a { all: unset; display: block; position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; z-index: 1; } :host([variant="elevated"]) .base { background-color: var(--m3e-elevated-chip-container-color, ${n.color.surfaceContainerLow}); --m3e-elevation-level: var(--m3e-elevated-chip-elevation, ${n.elevation.level1}); --m3e-elevation-hover-level: var(--m3e-elevated-chip-hover-elevation, ${n.elevation.level2}); --m3e-elevation-focus-level: var(--m3e-elevated-chip-elevation, ${n.elevation.level1}); --m3e-elevation-pressed-level: var(--m3e-elevated-chip-elevation, ${n.elevation.level1}); } :host([variant="outlined"]) .base { outline-width: var(--m3e-outlined-chip-outline-thickness, 1px); outline-style: solid; outline-offset: calc(0px - var(--m3e-outlined-chip-outline-thickness, 1px)); } :host(:not(:disabled):not([disabled-interactive])[variant="outlined"]) .base { outline-color: var(--m3e-outlined-chip-outline-color, ${n.color.outlineVariant}); } :host(:disabled[variant="outlined"]) .base, :host([disabled-interactive][variant="outlined"]) .base { outline-color: color-mix( in srgb, var(--m3e-outlined-chip-disabled-outline-color, ${n.color.onSurface}) var(--m3e-outlined-chip-disabled-outline-opacity, 12%), transparent ); } :host(.-with-icon) .wrapper { padding-inline-start: var(--m3e-chip-with-icon-padding-start, 0.5rem); } :host(:not(.-with-icon)) .wrapper { padding-inline-start: var(--m3e-chip-padding-start, 1rem); } :host(.-with-trailing-icon) .wrapper { padding-inline-end: var(--m3e-chip-with-icon-padding-end, 0.5rem); } :host(:not(.-with-trailing-icon)) .wrapper { padding-inline-end: var(--m3e-chip-padding-end, 1rem); } ::slotted([slot="icon"]), ::slotted([slot="trailing-icon"]) { flex: none; width: 1em; font-size: var(--m3e-chip-icon-size, 1.125rem) !important; } :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base { color: var(--m3e-chip-label-text-color, ${n.color.onSurface}); } :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]), :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: var(--m3e-chip-icon-color, ${n.color.primary}); } :host(:disabled) .base, :host([disabled-interactive]) .base { color: color-mix( in srgb, var(--m3e-chip-disabled-label-text-color, ${n.color.onSurface}) var(--m3e-chip-disabled-label-text-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="icon"]), :host([disabled-interactive]) ::slotted([slot="icon"]), :host(:disabled) ::slotted([slot="trailing-icon"]), :host([disabled-interactive]) ::slotted([slot="trailing-icon"]) { color: color-mix( in srgb, var(--m3e-chip-disabled-icon-color, ${n.color.onSurface}) var(--m3e-chip-disabled-icon-opacity, 38%), transparent ); } :host([variant="elevated"]:disabled) .base, :host([variant="elevated"][disabled-interactive]) .base { background-color: color-mix( in srgb, var(--m3e-elevated-chip-disabled-container-color, ${n.color.onSurface}) var(--m3e-elevated-chip-disabled-container-opacity, 12%), transparent ); --m3e-elevation-level: var(--m3e-elevated-chip-disabled-elevation, ${n.elevation.level0}); } @media (prefers-reduced-motion) { .base { transition: none; } } @media (forced-colors: active) { .base { transition: none; } :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base, :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]), :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: CanvasText; } :host(:not(:disabled):not([disabled-interactive])[variant="outlined"]) .base { outline-color: CanvasText; } :host(:disabled) .base, :host([disabled-interactive]) .base, :host(:disabled) ::slotted([slot="icon"]), :host([disabled-interactive]) ::slotted([slot="icon"]), :host(:disabled) ::slotted([slot="trailing-icon"]), :host([disabled-interactive]) ::slotted([slot="trailing-icon"]) { color: GrayText; } :host(:disabled[variant="outlined"]) .base, :host([disabled-interactive][variant="outlined"]) .base { outline-color: GrayText; } }`,H([he(".elevation")],ge.prototype,"_elevation",void 0),H([he(".focus-ring")],ge.prototype,"_focusRing",void 0),H([he(".state-layer")],ge.prototype,"_stateLayer",void 0),H([he(".ripple")],ge.prototype,"_ripple",void 0),H([ce({reflect:!0})],ge.prototype,"variant",void 0),H([ce()],ge.prototype,"value",null),ge=H([W("m3e-chip")],ge);let $e=class extends(p(u(v(m(f(b(g($(ge,"button")))))),!0))){_renderTrailingIcon(){return s}};$e=H([W("m3e-assist-chip")],$e);let ye=class extends(y(i)){render(){return o`<slot></slot>`}};var we,_e,Ae;ye.styles=t`:host { display: inline-flex; flex-wrap: wrap; vertical-align: middle; gap: var(--m3e-chip-set-spacing, 0.5rem); outline: none; } :host([vertical]) { flex-direction: column; }`,ye=H([W("m3e-chip-set")],ye);let Ee=class extends(w(m(f(b(g(u($(ge,"radio"),!0))))))){constructor(){super(...arguments),we.add(this),_e.set(this,e=>N(this,we,"m",Ae).call(this,e))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",N(this,_e,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",N(this,_e,"f"))}update(e){super.update(e),e.has("selected")&&this.closest("m3e-filter-chip-set")?.[T].notifySelectionChange(this)}_renderIcon(){return o`<div class="icon" aria-hidden="true"><svg class="check" viewBox="0 -960 960 960" aria-hidden="true"><path fill="currentColor" d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"/></svg> ${super._renderIcon()}</div>`}};var Se,xe,Ce,ke,Pe,Me,Te;_e=new WeakMap,we=new WeakSet,Ae=function(e){if(e.defaultPrevented)return;const t=this.selected;this.selected=!this.selected,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0,cancelable:!0}))?(this.closest("m3e-filter-chip-set")?.[T].notifySelectionChange(this),this.dispatchEvent(new Event("change",{bubbles:!0}))):this.selected=t},Ee.styles=[ge.styles,t`:host([selected]:not(.-hide-selection)) .wrapper { padding-inline-start: var(--m3e-chip-with-icon-padding-start, 0.5rem); } .icon { display: flex; align-items: center; justify-content: center; } .check { width: 1em; font-size: var(--m3e-chip-icon-size, 1.125rem); } :host(:not(:disabled):not([disabled-interactive])) .check { color: var(--m3e-chip-selected-leading-icon-color, ${n.color.onSecondaryContainer}); } :host(:not([selected])) .check, :host(.-hide-selection) .check, :host(.-hide-selection:not(.-with-icon)) .icon { display: none; } :host(:not(.-with-icon)) .icon { margin-inline-start: calc(0px - var(--m3e-chip-with-icon-padding-start, 0.5rem)); transition: margin-inline-start ${n.motion.spring.fastEffects}; } :host([selected]) .icon { margin-inline-start: 0; } :host([selected]:not(.-hide-selection)) ::slotted([slot="icon"]) { display: none !important; } :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base { color: var(--m3e-chip-unselected-label-text-color, ${n.color.onSurfaceVariant}); --m3e-ripple-color: var(--m3e-chip-unselected-ripple-color, ${n.color.onSurfaceVariant}); --m3e-state-layer-focus-color: var( --m3e-chip-unselected-state-layer-focus-color, ${n.color.onSurfaceVariant} ); --m3e-state-layer-hover-color: var( --m3e-chip-unselected-state-layer-hover-color, ${n.color.onSurfaceVariant} ); } :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]) { color: var(--m3e-chip-unselected-leading-icon-color, ${n.color.primary}); } :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: var(--m3e-chip-unselected-trailing-icon-color, ${n.color.onSurfaceVariant}); } :host(:not(:disabled):not([disabled-interactive])[selected]) .base { outline-offset: unset; outline-width: var(--m3e-chip-selected-outline-thickness, 0); color: var(--m3e-chip-selected-label-text-color, ${n.color.onSecondaryContainer}); background-color: var(--m3e-chip-selected-container-color, ${n.color.secondaryContainer}); --m3e-state-layer-hover-color: var( --m3e-chip-selected-container-hover-color, ${n.color.onSecondaryContainer} ); --m3e-state-layer-focus-color: var( --m3e-chip-selected-container-focus-color, ${n.color.onSecondaryContainer} ); --m3e-elevation-hover-level: var(--m3e-chip-selected-hover-elevation, ${n.elevation.level1}); --m3e-ripple-color: var(--m3e-chip-selected-ripple-color, ${n.color.onSecondaryContainer}); --m3e-state-layer-focus-color: var( --m3e-chip-selected-state-layer-focus-color, ${n.color.onSecondaryContainer} ); --m3e-state-layer-hover-color: var( --m3e-chip-selected-state-layer-hover-color, ${n.color.onSecondaryContainer} ); } :host(:not(:disabled):not([disabled-interactive])[selected]) ::slotted([slot="icon"]) { color: var(--m3e-chip-selected-leading-icon-color, ${n.color.onSecondaryContainer}); } :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: var(--m3e-chip-selected-trailing-icon-color, ${n.color.onSecondaryContainer}); } @media (prefers-reduced-motion) { .base, :host(:not(.-with-icon)) .icon { transition: none; } } @media (forced-colors: active) { :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base, :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]), :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: CanvasText; } :host(:not(:disabled):not([disabled-interactive])[selected]) .base, :host(:not(:disabled):not([disabled-interactive])[selected]) ::slotted([slot="icon"]), :host(:not(:disabled):not([disabled-interactive])[selected]) ::slotted([slot="trailing-icon"]), :host(:not(:disabled):not([disabled-interactive])) .check { color: ButtonText; } :host(:not(:disabled):not([disabled-interactive])[selected]) .base { outline-offset: calc(0px - var(--m3e-outlined-chip-outline-thickness, 1px)); outline-width: var(--m3e-outlined-chip-outline-thickness, 1px); outline-color: ButtonText; } }`],Ee=H([W("m3e-filter-chip")],Ee);let Ie=class extends(_(A(E(S(g(u($(ye,"radiogroup")))))))){constructor(){super(...arguments),Se.add(this),xe.set(this,void 0),this[Te]=(new I).onActiveItemChange(()=>this[T].activeItem?.focus()).withWrap().withDirectionality(L.current),this.multi=!1,this.hideSelectionIndicator=!1}get chips(){return this[T]?.items??[]}get selected(){return this[T]?.selectedItems??[]}get value(){const e=this.selected.map(e=>e.value);switch(e.length){case 0:return null;case 1:return e[0];default:return e}}get[(xe=new WeakMap,Se=new WeakSet,Te=T,x)](){const e=this.value;if(Array.isArray(e)){const t=new FormData;for(const i of e)t.append(this.name,i);return t}return e}connectedCallback(){super.connectedCallback(),R(this,xe,L.observe(()=>this[T].directionality=L.current),"f")}disconnectedCallback(){super.disconnectedCallback(),N(this,xe,"f")?.call(this)}update(e){super.update(e),e.has("vertical")&&(this[T].vertical=this.vertical),e.has("disabled")&&(void 0!==e.get("disabled")||this.disabled)&&(this[T].disabled=this.disabled),e.has("multi")&&(this.role=this.multi?"group":"radiogroup",N(this,Se,"m",Me).call(this),this[T].multi=this.multi,this[T].disableRovingTabIndex(this.multi)),(e.has("multi")||e.has("disabled"))&&(this.ariaDisabled=this.multi&&this.disabled?"true":null),e.has("hideSelectionIndicator")&&this.chips.forEach(e=>e.classList.toggle("-hide-selection",this.hideSelectionIndicator))}render(){return o`<slot @slotchange="${N(this,Se,"m",Ce)}" @keydown="${N(this,Se,"m",ke)}" @change="${N(this,Se,"m",Pe)}"></slot>`}};Ce=function(){const{added:e}=this[T].setItems([...this.querySelectorAll("m3e-filter-chip")]);e.forEach(e=>e.classList.toggle("-hide-selection",this.hideSelectionIndicator)),N(this,Se,"m",Me).call(this)},ke=function(e){this.multi||this[T].onKeyDown(e)},Pe=function(e){e.stopPropagation(),this.dispatchEvent(new Event("change",{bubbles:!0}))},Me=function(){this.chips.forEach(e=>e.role=this.multi?"button":"radio")},H([ce({type:Boolean})],Ie.prototype,"multi",void 0),H([ce({attribute:"hide-selection-indicator",type:Boolean})],Ie.prototype,"hideSelectionIndicator",void 0),Ie=H([W("m3e-filter-chip-set")],Ie);
|
|
39
|
+
function he(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,i),i))(t,i,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}var de,pe,ue,ve,me,fe,be;let ge=class extends i{constructor(){super(...arguments),de.add(this),pe.set(this,void 0),ue.set(this,""),this.variant="outlined"}get value(){return N(this,pe,"f")??N(this,ue,"f")}set value(e){R(this,pe,e,"f")}firstUpdated(e){super.firstUpdated(e),"listitem"===this.role&&this.removeAttribute("tabindex"),[this._elevation,this._focusRing,this._stateLayer,this._ripple].forEach(e=>{e?.htmlFor||e?.attach(this)})}render(){const e=!r(this)||this.disabled,t=a(this)&&this.disabledInteractive;return o`<div class="base"><m3e-elevation class="elevation" ?disabled="${e||t}"></m3e-elevation><m3e-state-layer class="state-layer" ?disabled="${e||t}"></m3e-state-layer><m3e-focus-ring class="focus-ring" ?disabled="${e}"></m3e-focus-ring><m3e-ripple class="ripple" ?disabled="${e||t}"></m3e-ripple><div class="touch" aria-hidden="true"></div>${l(this)?this[c]():s}<div class="wrapper">${N(this,de,"m",ve).call(this)}</div></div>`}_renderIcon(){return o`<slot name="icon" aria-hidden="true" @slotchange="${N(this,de,"m",me)}"></slot>`}_renderTrailingIcon(){return o`<slot name="trailing-icon" aria-hidden="true" @slotchange="${N(this,de,"m",fe)}"></slot>`}_renderSlot(){return o`<slot @slotchange="${N(this,de,"m",be)}"></slot>`}};pe=new WeakMap,ue=new WeakMap,de=new WeakSet,ve=function(){return o`${this._renderIcon()}<div class="label">${this._renderSlot()}</div>${this._renderTrailingIcon()}`},me=function(e){this.classList.toggle("-with-icon",h(e.target))},fe=function(e){this.classList.toggle("-with-trailing-icon",h(e.target))},be=function(e){R(this,ue,d(e.target),"f")},ge.styles=t`:host { display: inline-block; vertical-align: middle; outline: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .base { box-sizing: border-box; vertical-align: middle; display: inline-flex; align-items: center; justify-content: center; position: relative; width: 100%; transition: ${e(`background-color ${n.motion.duration.short4} ${n.motion.easing.standard}`)}; border-radius: var(--m3e-chip-container-shape, ${n.shape.corner.small}); height: calc(var(--m3e-chip-container-height, 2rem) + ${n.density.calc(-2)}); font-size: var(--m3e-chip-label-text-font-size, ${n.typescale.standard.label.large.fontSize}); font-weight: var(--m3e-chip-label-text-font-weight, ${n.typescale.standard.label.large.fontWeight}); line-height: var(--m3e-chip-label-text-line-height, ${n.typescale.standard.label.large.lineHeight}); letter-spacing: var(--m3e-chip-label-text-tracking, ${n.typescale.standard.label.large.tracking}); } :host(:not(m3e-chip):not(:disabled):not([disabled-interactive])) { cursor: pointer; } :host(:not(m3e-chip):not(:disabled)[disabled-interactive]) { cursor: not-allowed; } :host(:not(m3e-chip):not(:disabled):not([disabled-interactive])) .base { user-select: none; } .touch { position: absolute; height: 3rem; left: 0; right: 0; } .wrapper { width: 100%; overflow: hidden; display: inline-flex; align-items: center; column-gap: var(--m3e-chip-spacing, 0.5rem); } .label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } a { all: unset; display: block; position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; z-index: 1; } :host([variant="elevated"]) .base { background-color: var(--m3e-elevated-chip-container-color, ${n.color.surfaceContainerLow}); --m3e-elevation-level: var(--m3e-elevated-chip-elevation, ${n.elevation.level1}); --m3e-elevation-hover-level: var(--m3e-elevated-chip-hover-elevation, ${n.elevation.level2}); --m3e-elevation-focus-level: var(--m3e-elevated-chip-elevation, ${n.elevation.level1}); --m3e-elevation-pressed-level: var(--m3e-elevated-chip-elevation, ${n.elevation.level1}); } :host([variant="outlined"]) .base { outline-width: var(--m3e-outlined-chip-outline-thickness, 1px); outline-style: solid; outline-offset: calc(0px - var(--m3e-outlined-chip-outline-thickness, 1px)); } :host(:not(:disabled):not([disabled-interactive])[variant="outlined"]) .base { outline-color: var(--m3e-outlined-chip-outline-color, ${n.color.outlineVariant}); } :host(:disabled[variant="outlined"]) .base, :host([disabled-interactive][variant="outlined"]) .base { outline-color: color-mix( in srgb, var(--m3e-outlined-chip-disabled-outline-color, ${n.color.onSurface}) var(--m3e-outlined-chip-disabled-outline-opacity, 12%), transparent ); } :host(.-with-icon) .wrapper { padding-inline-start: var(--m3e-chip-with-icon-padding-start, 0.5rem); } :host(:not(.-with-icon)) .wrapper { padding-inline-start: var(--m3e-chip-padding-start, 1rem); } :host(.-with-trailing-icon) .wrapper { padding-inline-end: var(--m3e-chip-with-icon-padding-end, 0.5rem); } :host(:not(.-with-trailing-icon)) .wrapper { padding-inline-end: var(--m3e-chip-padding-end, 1rem); } ::slotted([slot="icon"]), ::slotted([slot="trailing-icon"]) { flex: none; width: 1em; font-size: var(--m3e-chip-icon-size, 1.125rem) !important; } :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base { color: var(--m3e-chip-label-text-color, ${n.color.onSurface}); } :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]), :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: var(--m3e-chip-icon-color, ${n.color.primary}); } :host(:disabled) .base, :host([disabled-interactive]) .base { color: color-mix( in srgb, var(--m3e-chip-disabled-label-text-color, ${n.color.onSurface}) var(--m3e-chip-disabled-label-text-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="icon"]), :host([disabled-interactive]) ::slotted([slot="icon"]), :host(:disabled) ::slotted([slot="trailing-icon"]), :host([disabled-interactive]) ::slotted([slot="trailing-icon"]) { color: color-mix( in srgb, var(--m3e-chip-disabled-icon-color, ${n.color.onSurface}) var(--m3e-chip-disabled-icon-opacity, 38%), transparent ); } :host([variant="elevated"]:disabled) .base, :host([variant="elevated"][disabled-interactive]) .base { background-color: color-mix( in srgb, var(--m3e-elevated-chip-disabled-container-color, ${n.color.onSurface}) var(--m3e-elevated-chip-disabled-container-opacity, 12%), transparent ); --m3e-elevation-level: var(--m3e-elevated-chip-disabled-elevation, ${n.elevation.level0}); } @media (prefers-reduced-motion) { .base { transition: none; } } @media (forced-colors: active) { .base { transition: none; } :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base, :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]), :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: CanvasText; } :host(:not(:disabled):not([disabled-interactive])[variant="outlined"]) .base { outline-color: CanvasText; } :host(:disabled) .base, :host([disabled-interactive]) .base, :host(:disabled) ::slotted([slot="icon"]), :host([disabled-interactive]) ::slotted([slot="icon"]), :host(:disabled) ::slotted([slot="trailing-icon"]), :host([disabled-interactive]) ::slotted([slot="trailing-icon"]) { color: GrayText; } :host(:disabled[variant="outlined"]) .base, :host([disabled-interactive][variant="outlined"]) .base { outline-color: GrayText; } }`,H([he(".elevation")],ge.prototype,"_elevation",void 0),H([he(".focus-ring")],ge.prototype,"_focusRing",void 0),H([he(".state-layer")],ge.prototype,"_stateLayer",void 0),H([he(".ripple")],ge.prototype,"_ripple",void 0),H([ce({reflect:!0})],ge.prototype,"variant",void 0),H([ce()],ge.prototype,"value",null),ge=H([W("m3e-chip")],ge);let $e=class extends(p(u(v(m(f(b(g($(ge,"button")))))),!0))){_renderTrailingIcon(){return s}};$e=H([W("m3e-assist-chip")],$e);let ye=class extends(y(i)){render(){return o`<slot></slot>`}};var we,_e,Ae;ye.styles=t`:host { display: inline-flex; flex-wrap: wrap; vertical-align: middle; gap: var(--m3e-chip-set-spacing, 0.5rem); outline: none; } :host([vertical]) { flex-direction: column; }`,ye=H([W("m3e-chip-set")],ye);let Ee=class extends(w(m(f(b(g(u($(ge,"radio"),!0))))))){constructor(){super(...arguments),we.add(this),_e.set(this,e=>N(this,we,"m",Ae).call(this,e))}connectedCallback(){super.connectedCallback(),this.addEventListener("click",N(this,_e,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",N(this,_e,"f"))}update(e){super.update(e),e.has("selected")&&this.closest("m3e-filter-chip-set")?.[T].notifySelectionChange(this)}_renderIcon(){return o`<div class="icon" aria-hidden="true"><svg class="check" viewBox="0 -960 960 960" aria-hidden="true"><path fill="currentColor" d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"/></svg> ${super._renderIcon()}</div>`}};var Se,xe,Ce,ke,Pe,Me,Te;_e=new WeakMap,we=new WeakSet,Ae=function(e){if(e.defaultPrevented)return;const t=this.selected;this.selected=!this.selected,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0,cancelable:!0}))?(this.closest("m3e-filter-chip-set")?.[T].notifySelectionChange(this),this.dispatchEvent(new Event("change",{bubbles:!0}))):this.selected=t},Ee.styles=[ge.styles,t`:host([selected]:not(.-hide-selection)) .wrapper { padding-inline-start: var(--m3e-chip-with-icon-padding-start, 0.5rem); } .icon { display: flex; align-items: center; justify-content: center; } .check { width: 1em; font-size: var(--m3e-chip-icon-size, 1.125rem); } :host(:not(:disabled):not([disabled-interactive])) .check { color: var(--m3e-chip-selected-leading-icon-color, ${n.color.onSecondaryContainer}); } :host(:not([selected])) .check, :host(.-hide-selection) .check, :host(.-hide-selection:not(.-with-icon)) .icon { display: none; } :host(:not(.-with-icon)) .icon { margin-inline-start: calc(0px - var(--m3e-chip-with-icon-padding-start, 0.5rem)); transition: margin-inline-start ${n.motion.spring.fastEffects}; } :host([selected]) .icon { margin-inline-start: 0; } :host([selected]:not(.-hide-selection)) ::slotted([slot="icon"]) { display: none !important; } :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base { color: var(--m3e-chip-unselected-label-text-color, ${n.color.onSurfaceVariant}); --m3e-ripple-color: var(--m3e-chip-unselected-ripple-color, ${n.color.onSurfaceVariant}); --m3e-state-layer-focus-color: var( --m3e-chip-unselected-state-layer-focus-color, ${n.color.onSurfaceVariant} ); --m3e-state-layer-hover-color: var( --m3e-chip-unselected-state-layer-hover-color, ${n.color.onSurfaceVariant} ); } :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]) { color: var(--m3e-chip-unselected-leading-icon-color, ${n.color.primary}); } :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: var(--m3e-chip-unselected-trailing-icon-color, ${n.color.onSurfaceVariant}); } :host(:not(:disabled):not([disabled-interactive])[selected]) .base { outline-offset: unset; outline-width: var(--m3e-chip-selected-outline-thickness, 0); color: var(--m3e-chip-selected-label-text-color, ${n.color.onSecondaryContainer}); background-color: var(--m3e-chip-selected-container-color, ${n.color.secondaryContainer}); --m3e-state-layer-hover-color: var( --m3e-chip-selected-container-hover-color, ${n.color.onSecondaryContainer} ); --m3e-state-layer-focus-color: var( --m3e-chip-selected-container-focus-color, ${n.color.onSecondaryContainer} ); --m3e-elevation-hover-level: var(--m3e-chip-selected-hover-elevation, ${n.elevation.level1}); --m3e-ripple-color: var(--m3e-chip-selected-ripple-color, ${n.color.onSecondaryContainer}); --m3e-state-layer-focus-color: var( --m3e-chip-selected-state-layer-focus-color, ${n.color.onSecondaryContainer} ); --m3e-state-layer-hover-color: var( --m3e-chip-selected-state-layer-hover-color, ${n.color.onSecondaryContainer} ); } :host(:not(:disabled):not([disabled-interactive])[selected]) ::slotted([slot="icon"]) { color: var(--m3e-chip-selected-leading-icon-color, ${n.color.onSecondaryContainer}); } :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: var(--m3e-chip-selected-trailing-icon-color, ${n.color.onSecondaryContainer}); } @media (prefers-reduced-motion) { .base, :host(:not(.-with-icon)) .icon { transition: none; } } @media (forced-colors: active) { :host(:not(:disabled):not([disabled-interactive]):not([selected])) .base, :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]), :host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) { color: CanvasText; } :host(:not(:disabled):not([disabled-interactive])[selected]) .base, :host(:not(:disabled):not([disabled-interactive])[selected]) ::slotted([slot="icon"]), :host(:not(:disabled):not([disabled-interactive])[selected]) ::slotted([slot="trailing-icon"]), :host(:not(:disabled):not([disabled-interactive])) .check { color: ButtonText; } :host(:not(:disabled):not([disabled-interactive])[selected]) .base { outline-offset: calc(0px - var(--m3e-outlined-chip-outline-thickness, 1px)); outline-width: var(--m3e-outlined-chip-outline-thickness, 1px); outline-color: ButtonText; } }`],Ee=H([W("m3e-filter-chip")],Ee);let Ie=class extends(_(A(E(S(g(u($(ye,"radiogroup")))))))){constructor(){super(...arguments),Se.add(this),xe.set(this,void 0),this[Te]=(new I).onActiveItemChange(()=>this[T].activeItem?.focus()).withWrap().withDirectionality(L.current),this.multi=!1,this.hideSelectionIndicator=!1}get chips(){return this[T]?.items??[]}get selected(){return this[T]?.selectedItems??[]}get value(){const e=this.selected.filter(e=>!e.disabled).map(e=>e.value);switch(e.length){case 0:return null;case 1:return e[0];default:return e}}get[(xe=new WeakMap,Se=new WeakSet,Te=T,x)](){const e=this.value;if(Array.isArray(e)){const t=new FormData;for(const i of e)t.append(this.name,i);return t}return e}connectedCallback(){super.connectedCallback(),R(this,xe,L.observe(()=>this[T].directionality=L.current),"f")}disconnectedCallback(){super.disconnectedCallback(),N(this,xe,"f")?.call(this)}update(e){super.update(e),e.has("vertical")&&(this[T].vertical=this.vertical),e.has("disabled")&&(void 0!==e.get("disabled")||this.disabled)&&(this[T].disabled=this.disabled),e.has("multi")&&(this.role=this.multi?"group":"radiogroup",N(this,Se,"m",Me).call(this),this[T].multi=this.multi,this[T].disableRovingTabIndex(this.multi)),(e.has("multi")||e.has("disabled"))&&(this.ariaDisabled=this.multi&&this.disabled?"true":null),e.has("hideSelectionIndicator")&&this.chips.forEach(e=>e.classList.toggle("-hide-selection",this.hideSelectionIndicator))}render(){return o`<slot @slotchange="${N(this,Se,"m",Ce)}" @keydown="${N(this,Se,"m",ke)}" @change="${N(this,Se,"m",Pe)}"></slot>`}};Ce=function(){const{added:e}=this[T].setItems([...this.querySelectorAll("m3e-filter-chip")]);e.forEach(e=>e.classList.toggle("-hide-selection",this.hideSelectionIndicator)),N(this,Se,"m",Me).call(this)},ke=function(e){this.multi||this[T].onKeyDown(e)},Pe=function(e){e.stopPropagation(),this.dispatchEvent(new Event("change",{bubbles:!0}))},Me=function(){this.chips.forEach(e=>e.role=this.multi?"button":"radio")},H([ce({type:Boolean})],Ie.prototype,"multi",void 0),H([ce({attribute:"hide-selection-indicator",type:Boolean})],Ie.prototype,"hideSelectionIndicator",void 0),Ie=H([W("m3e-filter-chip-set")],Ie);
|
|
40
40
|
/**
|
|
41
41
|
* @license
|
|
42
42
|
* Copyright 2017 Google LLC
|
|
43
43
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
44
|
*/
|
|
45
|
-
const Ue=globalThis,Oe=Ue.trustedTypes,Le=Oe?Oe.createPolicy("lit-html",{createHTML:e=>e}):void 0,He="$lit$",Ne=`lit$${Math.random().toFixed(9).slice(2)}$`,Re="?"+Ne,We=`<${Re}>`,ze=document,je=()=>ze.createComment(""),De=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Be=Array.isArray,qe="[ \t\n\f\r]",Ve=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Fe=/-->/g,Ke=/>/g,Ze=RegExp(`>|${qe}(?:([^\\s"'>=/]+)(${qe}*=${qe}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Ge=/'/g,Je=/"/g,Qe=/^(?:script|style|textarea|title)$/i,Xe=Symbol.for("lit-noChange"),Ye=Symbol.for("lit-nothing"),et=new WeakMap,tt=ze.createTreeWalker(ze,129);function it(e,t){if(!Be(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Le?Le.createHTML(t):t}const st=(e,t)=>{const i=e.length-1,s=[];let o,n=2===t?"<svg>":3===t?"<math>":"",r=Ve;for(let t=0;t<i;t++){const i=e[t];let a,l,c=-1,h=0;for(;h<i.length&&(r.lastIndex=h,l=r.exec(i),null!==l);)h=r.lastIndex,r===Ve?"!--"===l[1]?r=Fe:void 0!==l[1]?r=Ke:void 0!==l[2]?(Qe.test(l[2])&&(o=RegExp("</"+l[2],"g")),r=Ze):void 0!==l[3]&&(r=Ze):r===Ze?">"===l[0]?(r=o??Ve,c=-1):void 0===l[1]?c=-2:(c=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?Ze:'"'===l[3]?Je:Ge):r===Je||r===Ge?r=Ze:r===Fe||r===Ke?r=Ve:(r=Ze,o=void 0);const d=r===Ze&&e[t+1].startsWith("/>")?" ":"";n+=r===Ve?i+We:c>=0?(s.push(a),i.slice(0,c)+He+i.slice(c)+Ne+d):i+Ne+(-2===c?t:d)}return[it(e,n+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]};class ot{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,n=0;const r=e.length-1,a=this.parts,[l,c]=st(e,t);if(this.el=ot.createElement(l,i),tt.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=tt.nextNode())&&a.length<r;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(He)){const t=c[n++],i=s.getAttribute(e).split(Ne),r=/([.?@])?(.*)/.exec(t);a.push({type:1,index:o,name:r[2],strings:i,ctor:"."===r[1]?ct:"?"===r[1]?ht:"@"===r[1]?dt:lt}),s.removeAttribute(e)}else e.startsWith(Ne)&&(a.push({type:6,index:o}),s.removeAttribute(e));if(Qe.test(s.tagName)){const e=s.textContent.split(Ne),t=e.length-1;if(t>0){s.textContent=Oe?Oe.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],je()),tt.nextNode(),a.push({type:2,index:++o});s.append(e[t],je())}}}else if(8===s.nodeType)if(s.data===Re)a.push({type:2,index:o});else{let e=-1;for(;-1!==(e=s.data.indexOf(Ne,e+1));)a.push({type:7,index:o}),e+=Ne.length-1}o++}}static createElement(e,t){const i=ze.createElement("template");return i.innerHTML=e,i}}function nt(e,t,i=e,s){if(t===Xe)return t;let o=void 0!==s?i._$Co?.[s]:i._$Cl;const n=De(t)?void 0:t._$litDirective$;return o?.constructor!==n&&(o?._$AO?.(!1),void 0===n?o=void 0:(o=new n(e),o._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=o:i._$Cl=o),void 0!==o&&(t=nt(e,o._$AS(e,t.values),o,s)),t}class rt{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??ze).importNode(t,!0);tt.currentNode=s;let o=tt.nextNode(),n=0,r=0,a=i[0];for(;void 0!==a;){if(n===a.index){let t;2===a.type?t=new at(o,o.nextSibling,this,e):1===a.type?t=new a.ctor(o,a.name,a.strings,this,e):6===a.type&&(t=new pt(o,this,e)),this._$AV.push(t),a=i[++r]}n!==a?.index&&(o=tt.nextNode(),n++)}return tt.currentNode=ze,s}p(e){let t=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class at{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=Ye,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=nt(this,e,t),De(e)?e===Ye||null==e||""===e?(this._$AH!==Ye&&this._$AR(),this._$AH=Ye):e!==this._$AH&&e!==Xe&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>Be(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Ye&&De(this._$AH)?this._$AA.nextSibling.data=e:this.T(ze.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:i}=e,s="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=ot.createElement(it(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new rt(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=et.get(e.strings);return void 0===t&&et.set(e.strings,t=new ot(e)),t}k(e){Be(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const o of e)s===t.length?t.push(i=new at(this.O(je()),this.O(je()),this,this.options)):i=t[s],i._$AI(o),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class lt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,o){this.type=1,this._$AH=Ye,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Ye}_$AI(e,t=this,i,s){const o=this.strings;let n=!1;if(void 0===o)e=nt(this,e,t,0),n=!De(e)||e!==this._$AH&&e!==Xe,n&&(this._$AH=e);else{const s=e;let r,a;for(e=o[0],r=0;r<o.length-1;r++)a=nt(this,s[i+r],t,r),a===Xe&&(a=this._$AH[r]),n||=!De(a)||a!==this._$AH[r],a===Ye?e=Ye:e!==Ye&&(e+=(a??"")+o[r+1]),this._$AH[r]=a}n&&!s&&this.j(e)}j(e){e===Ye?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class ct extends lt{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ye?void 0:e}}class ht extends lt{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Ye)}}class dt extends lt{constructor(e,t,i,s,o){super(e,t,i,s,o),this.type=5}_$AI(e,t=this){if((e=nt(this,e,t,0)??Ye)===Xe)return;const i=this._$AH,s=e===Ye&&i!==Ye||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==Ye&&(i===Ye||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class pt{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){nt(this,e)}}const ut=Ue.litHtmlPolyfillSupport;ut?.(ot,at),(Ue.litHtmlVersions??=[]).push("3.3.1");var vt,mt,ft,bt;let gt=class extends(C(b(g(u($(ge,"row"),!0))),"remove")){constructor(){super(...arguments),vt.add(this),this.removable=!1,this.removeLabel="Remove"}connectedCallback(){super.connectedCallback(),this.removeAttribute("tabindex")}update(e){super.update(e),this.removeAttribute("tabindex"),e.has("removable")&&this.classList.toggle("-with-trailing-icon",this.removable)}render(){return o`<div class="base"><m3e-elevation class="elevation" for="cell" ?disabled="${this.disabled||this.disabledInteractive}"></m3e-elevation><m3e-state-layer class="state-layer" for="cell" ?disabled="${this.disabled||this.disabledInteractive}"></m3e-state-layer><m3e-focus-ring class="focus-ring" for="cell" ?disabled="${this.disabled}"></m3e-focus-ring><m3e-ripple class="ripple" for="cell" ?disabled="${this.disabled||this.disabledInteractive}"></m3e-ripple><div class="wrapper"><div id="cell" class="cell" role="gridcell" tabindex="${(e=>e??Ye)(this.disabled?void 0:"-1")}" @keydown="${N(this,vt,"m",bt)}"><slot name="avatar" @slotchange="${N(this,vt,"m",mt)}"></slot>${this._renderIcon()}<div class="label">${this._renderSlot()}</div><div class="touch" aria-hidden="true"></div></div>${this._renderTrailingIcon()}</div></div>`}_renderTrailingIcon(){return this.removable?o`<span role="gridcell" class="remove"><m3e-icon-button class="remove-button" aria-label="${this.removeLabel}" size="extra-small" tabindex="-1" ?disabled="${this.disabled}" ?disabled-interactive="${this.disabledInteractive}" @click="${N(this,vt,"m",ft)}"><slot name="remove-icon"><svg class="remove-icon" viewBox="0 -960 960 960" fill="currentColor"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></slot></m3e-icon-button></span>`:s}};var $t,yt,wt,_t,At,Et,St,xt,Ct,kt,Pt,Mt,Tt,It,Ut,Ot,Lt,Ht,Nt,Rt,Wt,zt,jt,Dt;vt=new WeakSet,mt=function(e){this.classList.toggle("-with-avatar",h(e.target))},ft=function(e){e.stopPropagation(),this.dispatchEvent(new Event("remove"))},bt=function(e){if(this.removable)switch(e.key){case"Backspace":case"Delete":this.dispatchEvent(new Event("remove"))}},gt.styles=[ge.styles,t`.cell { display: inline-flex; align-items: center; outline: none; column-gap: var(--m3e-chip-spacing, 0.5rem); min-width: 0; } .remove-button { --m3e-icon-button-extra-small-container-height: 1.5rem; --m3e-icon-button-extra-small-icon-size: var(--m3e-chip-icon-size, 1.125rem); width: 1.5rem; } .remove-icon { flex: none; width: var(--m3e-chip-icon-size, 1.125rem); height: var(--m3e-chip-icon-size, 1.125rem); } .touch { top: calc( 0px - calc(calc(3rem - calc(var(--m3e-chip-container-height, 2rem) + ${n.density.calc(-2)})) / 2) ); } .wrapper { height: 100%; overflow: visible; min-width: 0; } ::slotted([slot="avatar"]) { flex: none; font-size: var(--m3e-chip-avatar-size, 1.5rem); } :host(:disabled) ::slotted([slot="avatar"]), :host([disabled-interactive]) ::slotted([slot="avatar"]) { opacity: var(--m3e-chip-disabled-avatar-opacity, 38%); color: var(--m3e-chip-disabled-icon-color, ${n.color.onSurface}); } :host(.-with-avatar) ::slotted([slot="icon"]) { display: none; } :host(.-with-avatar) .wrapper { padding-inline-start: var(--m3e-chip-with-avatar-padding-start, 0.25rem); } @media (forced-colors: active) { :host(:disabled) ::slotted([slot="avatar"]), :host([disabled-interactive]) ::slotted([slot="avatar"]) { color: CanvasText; } }`],H([he(".cell")],gt.prototype,"cell",void 0),H([he(".remove-button")],gt.prototype,"removeButton",void 0),H([ce({type:Boolean})],gt.prototype,"removable",void 0),H([ce({attribute:"remove-label"})],gt.prototype,"removeLabel",void 0),gt=H([W("m3e-input-chip")],gt);let Bt=class extends(k(P(M(A(E(S(g(u($(ye,"grid")))))))))){constructor(){super(...arguments),$t.add(this),yt.set(this,void 0),wt.set(this,()=>N(this,$t,"m",jt).call(this)),_t.set(this,e=>N(this,$t,"m",Dt).call(this,e)),At.set(this,()=>N(this,$t,"m",Ht).call(this)),Et.set(this,()=>N(this,$t,"m",Nt).call(this)),St.set(this,()=>N(this,$t,"m",Rt).call(this)),xt.set(this,e=>N(this,$t,"m",Wt).call(this,e)),Ct.set(this,e=>N(this,$t,"m",zt).call(this,e)),kt.set(this,new U),Pt.set(this,(new O).onActiveItemChange(()=>N(this,Pt,"f").activeItem?.focus()).withHomeAndEnd().withSkipPredicate(e=>!e.hasAttribute("tabindex")).withDirectionality(L.current)),Mt.set(this,!1),Tt.set(this,null),It.set(this,0)}get chips(){return[...this.querySelectorAll("m3e-input-chip")]}get value(){const e=this.chips.map(e=>e.value);return 0==e.length?null:e}get[(yt=new WeakMap,wt=new WeakMap,_t=new WeakMap,At=new WeakMap,Et=new WeakMap,St=new WeakMap,xt=new WeakMap,Ct=new WeakMap,kt=new WeakMap,Pt=new WeakMap,Mt=new WeakMap,Tt=new WeakMap,It=new WeakMap,$t=new WeakSet,x)](){const e=this.value;if(!e)return null;const t=new FormData;for(const i of e)t.append(this.name,i);return t}get shouldLabelFloat(){return this.chips.length>0}onContainerClick(){N(this,Tt,"f")?.focus()}connectedCallback(){super.connectedCallback(),this.closest("m3e-form-field")?.notifyControlStateChange(),R(this,It,Number.parseInt(this.getAttribute("tabindex")??"0"),"f"),this.addEventListener("focus",N(this,At,"f")),this.addEventListener("focusin",N(this,Et,"f")),this.addEventListener("focusout",N(this,St,"f")),R(this,yt,L.observe(()=>N(this,Pt,"f").directionality=L.current),"f")}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("focus",N(this,At,"f")),this.removeEventListener("focusin",N(this,Et,"f")),this.removeEventListener("focusout",N(this,St,"f")),N(this,yt,"f")?.call(this)}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("tabindex")||this.setAttribute("tabindex",`${N(this,It,"f")}`)}update(e){super.update(e),e.has("vertical")&&(this.ariaOrientation=null),e.has("disabled")&&(N(this,kt,"f").items.forEach(e=>e.disabled=this.disabled),N(this,Tt,"f")&&(N(this,Tt,"f").disabled=this.disabled))}render(){return o`<slot @keydown="${N(this,$t,"m",Ut)}" @slotchange="${N(this,$t,"m",Ot)}"></slot><span role="row"><span role="gridcell"><slot name="input" @slotchange="${N(this,$t,"m",Lt)}"></slot></span></span>`}};Ut=function(e){N(this,Pt,"f").onKeyDown(e)},Ot=async function(){const{added:e,removed:t}=N(this,kt,"f").setItems([...this.querySelectorAll("m3e-input-chip")]);for(const t of e)t.isUpdatePending&&await t.updateComplete,this.disabled&&(t.disabled=!0),t.addEventListener("remove",N(this,xt,"f")),t.cell.addEventListener("click",N(this,Ct,"f"));t.forEach(e=>{e.removeEventListener("remove",N(this,xt,"f")),e.cell.removeEventListener("click",N(this,Ct,"f"))}),N(this,Pt,"f").setItems(N(this,kt,"f").items.flatMap(e=>e.removeButton?[e.cell,e.removeButton]:[e.cell])),N(this,Pt,"f").activeItem||N(this,Pt,"f").updateActiveItem(N(this,Pt,"f").items.find(e=>e.hasAttribute("tabindex")))},Lt=function(){const e=this.querySelector("input");if(N(this,Tt,"f")&&(N(this,Tt,"f").removeEventListener("change",N(this,wt,"f")),N(this,Tt,"f").removeEventListener("keydown",N(this,_t,"f"))),R(this,Tt,e,"f"),N(this,Tt,"f")){N(this,Tt,"f").disabled=this.disabled,N(this,Tt,"f").addEventListener("change",N(this,wt,"f")),N(this,Tt,"f").addEventListener("keydown",N(this,_t,"f"));const t=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");Object.defineProperty(e,"value",{get:()=>t.get?.call(e),set:i=>{t.set?.call(e,i),N(this,Tt,"f")!==e||N(this,Mt,"f")||N(this,$t,"m",jt).call(this)}})}},Ht=function(){setTimeout(()=>(N(this,Pt,"f").activeItem??N(this,Tt,"f"))?.focus())},Nt=function(){this.setAttribute("tabindex","-1")},Rt=function(){this.setAttribute("tabindex",`${N(this,It,"f")}`)},Wt=function(e){const t=e.target,i=N(this,kt,"f").items.indexOf(t),s=N(this,kt,"f").items.find((e,t)=>t>i&&!e.disabled&&e.removable);t.remove(),N(this,Pt,"f").setActiveItem(N(this,Pt,"f").items.find(e=>e===s?.removeButton)),N(this,Pt,"f").activeItem||N(this,Tt,"f")?.focus(),this.dispatchEvent(new Event("change",{bubbles:!0}))},zt=function(e){N(this,Pt,"f").updateActiveItem(e.composedPath().find(e=>e instanceof gt)?.cell)},jt=function(){const e=N(this,Tt,"f")?.value;e&&setTimeout(()=>{const e=N(this,Tt,"f")?.value;if(!e)return;const t=document.createElement("m3e-input-chip");if(t.removable=!0,t.appendChild(document.createTextNode(e)),this.appendChild(t),N(this,Tt,"f"))try{R(this,Mt,!0,"f"),N(this,Tt,"f").value=""}finally{R(this,Mt,!1,"f")}this.dispatchEvent(new Event("change",{bubbles:!0}))})},Dt=function(e){if("Backspace"===e.key&&!N(this,Tt,"f")?.value){const e=[...N(this,kt,"f").items].reverse().find(e=>!e.disabled&&!e.disabledInteractive&&e.removable);e&&e.dispatchEvent(new Event("remove"))}},(()=>{const e=new CSSStyleSheet;e.replaceSync(t`m3e-input-chip-set [slot="input"]::placeholder { user-select: none; color: currentColor; transition: opacity ${n.motion.duration.extraLong1}; } m3e-input-chip-set:not(:focus-within) [slot="input"]::placeholder { opacity: 0; transition: 0s; } m3e-input-chip-set:hover [slot="input"]::placeholder { transition: 0s; } @media (prefers-reduced-motion) { m3e-input-chip-set [slot="input"]::placeholder { transition: none !important; } }`.toString()),document.adoptedStyleSheets=[...document.adoptedStyleSheets,e]})(),Bt.styles=[ye.styles,t`::slotted([slot="input"]) { outline: unset; border: unset; background-color: transparent; box-shadow: none; font-family: inherit; font-size: inherit; line-height: initial; letter-spacing: inherit; color: var(--_form-field-input-color, inherit); flex: 1 1 auto; min-width: 0; padding: unset; } ::slotted(m3e-input-chip) { min-width: 0; } span[role="row"], span[role="gridcell"] { display: contents; }`],Bt=H([W("m3e-input-chip-set")],Bt);let qt=class extends(p(u(v(m(f(b(g($(ge,"button")))))),!0))){_renderTrailingIcon(){return s}};qt=H([W("m3e-suggestion-chip")],qt);export{$e as M3eAssistChipElement,ge as M3eChipElement,ye as M3eChipSetElement,Ee as M3eFilterChipElement,Ie as M3eFilterChipSetElement,gt as M3eInputChipElement,Bt as M3eInputChipSetElement,qt as M3eSuggestionChipElement};
|
|
45
|
+
const Ue=globalThis,Oe=Ue.trustedTypes,Le=Oe?Oe.createPolicy("lit-html",{createHTML:e=>e}):void 0,He="$lit$",Ne=`lit$${Math.random().toFixed(9).slice(2)}$`,Re="?"+Ne,We=`<${Re}>`,ze=document,je=()=>ze.createComment(""),De=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Be=Array.isArray,qe="[ \t\n\f\r]",Ve=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Fe=/-->/g,Ke=/>/g,Ze=RegExp(`>|${qe}(?:([^\\s"'>=/]+)(${qe}*=${qe}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Ge=/'/g,Je=/"/g,Qe=/^(?:script|style|textarea|title)$/i,Xe=Symbol.for("lit-noChange"),Ye=Symbol.for("lit-nothing"),et=new WeakMap,tt=ze.createTreeWalker(ze,129);function it(e,t){if(!Be(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Le?Le.createHTML(t):t}const st=(e,t)=>{const i=e.length-1,s=[];let o,n=2===t?"<svg>":3===t?"<math>":"",r=Ve;for(let t=0;t<i;t++){const i=e[t];let a,l,c=-1,h=0;for(;h<i.length&&(r.lastIndex=h,l=r.exec(i),null!==l);)h=r.lastIndex,r===Ve?"!--"===l[1]?r=Fe:void 0!==l[1]?r=Ke:void 0!==l[2]?(Qe.test(l[2])&&(o=RegExp("</"+l[2],"g")),r=Ze):void 0!==l[3]&&(r=Ze):r===Ze?">"===l[0]?(r=o??Ve,c=-1):void 0===l[1]?c=-2:(c=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?Ze:'"'===l[3]?Je:Ge):r===Je||r===Ge?r=Ze:r===Fe||r===Ke?r=Ve:(r=Ze,o=void 0);const d=r===Ze&&e[t+1].startsWith("/>")?" ":"";n+=r===Ve?i+We:c>=0?(s.push(a),i.slice(0,c)+He+i.slice(c)+Ne+d):i+Ne+(-2===c?t:d)}return[it(e,n+(e[i]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]};class ot{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,n=0;const r=e.length-1,a=this.parts,[l,c]=st(e,t);if(this.el=ot.createElement(l,i),tt.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=tt.nextNode())&&a.length<r;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(He)){const t=c[n++],i=s.getAttribute(e).split(Ne),r=/([.?@])?(.*)/.exec(t);a.push({type:1,index:o,name:r[2],strings:i,ctor:"."===r[1]?ct:"?"===r[1]?ht:"@"===r[1]?dt:lt}),s.removeAttribute(e)}else e.startsWith(Ne)&&(a.push({type:6,index:o}),s.removeAttribute(e));if(Qe.test(s.tagName)){const e=s.textContent.split(Ne),t=e.length-1;if(t>0){s.textContent=Oe?Oe.emptyScript:"";for(let i=0;i<t;i++)s.append(e[i],je()),tt.nextNode(),a.push({type:2,index:++o});s.append(e[t],je())}}}else if(8===s.nodeType)if(s.data===Re)a.push({type:2,index:o});else{let e=-1;for(;-1!==(e=s.data.indexOf(Ne,e+1));)a.push({type:7,index:o}),e+=Ne.length-1}o++}}static createElement(e,t){const i=ze.createElement("template");return i.innerHTML=e,i}}function nt(e,t,i=e,s){if(t===Xe)return t;let o=void 0!==s?i._$Co?.[s]:i._$Cl;const n=De(t)?void 0:t._$litDirective$;return o?.constructor!==n&&(o?._$AO?.(!1),void 0===n?o=void 0:(o=new n(e),o._$AT(e,i,s)),void 0!==s?(i._$Co??=[])[s]=o:i._$Cl=o),void 0!==o&&(t=nt(e,o._$AS(e,t.values),o,s)),t}class rt{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??ze).importNode(t,!0);tt.currentNode=s;let o=tt.nextNode(),n=0,r=0,a=i[0];for(;void 0!==a;){if(n===a.index){let t;2===a.type?t=new at(o,o.nextSibling,this,e):1===a.type?t=new a.ctor(o,a.name,a.strings,this,e):6===a.type&&(t=new pt(o,this,e)),this._$AV.push(t),a=i[++r]}n!==a?.index&&(o=tt.nextNode(),n++)}return tt.currentNode=ze,s}p(e){let t=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class at{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=Ye,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=nt(this,e,t),De(e)?e===Ye||null==e||""===e?(this._$AH!==Ye&&this._$AR(),this._$AH=Ye):e!==this._$AH&&e!==Xe&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):(e=>Be(e)||"function"==typeof e?.[Symbol.iterator])(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Ye&&De(this._$AH)?this._$AA.nextSibling.data=e:this.T(ze.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:i}=e,s="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=ot.createElement(it(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new rt(s,this),i=e.u(this.options);e.p(t),this.T(i),this._$AH=e}}_$AC(e){let t=et.get(e.strings);return void 0===t&&et.set(e.strings,t=new ot(e)),t}k(e){Be(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const o of e)s===t.length?t.push(i=new at(this.O(je()),this.O(je()),this,this.options)):i=t[s],i._$AI(o),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class lt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,o){this.type=1,this._$AH=Ye,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Ye}_$AI(e,t=this,i,s){const o=this.strings;let n=!1;if(void 0===o)e=nt(this,e,t,0),n=!De(e)||e!==this._$AH&&e!==Xe,n&&(this._$AH=e);else{const s=e;let r,a;for(e=o[0],r=0;r<o.length-1;r++)a=nt(this,s[i+r],t,r),a===Xe&&(a=this._$AH[r]),n||=!De(a)||a!==this._$AH[r],a===Ye?e=Ye:e!==Ye&&(e+=(a??"")+o[r+1]),this._$AH[r]=a}n&&!s&&this.j(e)}j(e){e===Ye?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class ct extends lt{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ye?void 0:e}}class ht extends lt{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Ye)}}class dt extends lt{constructor(e,t,i,s,o){super(e,t,i,s,o),this.type=5}_$AI(e,t=this){if((e=nt(this,e,t,0)??Ye)===Xe)return;const i=this._$AH,s=e===Ye&&i!==Ye||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==Ye&&(i===Ye||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class pt{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){nt(this,e)}}const ut=Ue.litHtmlPolyfillSupport;ut?.(ot,at),(Ue.litHtmlVersions??=[]).push("3.3.1");var vt,mt,ft,bt;let gt=class extends(C(b(g(u($(ge,"row"),!0))),"remove")){constructor(){super(...arguments),vt.add(this),this.removable=!1,this.removeLabel="Remove"}connectedCallback(){super.connectedCallback(),this.removeAttribute("tabindex")}update(e){super.update(e),this.removeAttribute("tabindex"),e.has("removable")&&this.classList.toggle("-with-trailing-icon",this.removable)}render(){return o`<div class="base"><m3e-elevation class="elevation" for="cell" ?disabled="${this.disabled||this.disabledInteractive}"></m3e-elevation><m3e-state-layer class="state-layer" for="cell" ?disabled="${this.disabled||this.disabledInteractive}"></m3e-state-layer><m3e-focus-ring class="focus-ring" for="cell" ?disabled="${this.disabled}"></m3e-focus-ring><m3e-ripple class="ripple" for="cell" ?disabled="${this.disabled||this.disabledInteractive}"></m3e-ripple><div class="wrapper"><div id="cell" class="cell" role="gridcell" tabindex="${(e=>e??Ye)(this.disabled?void 0:"-1")}" @keydown="${N(this,vt,"m",bt)}"><slot name="avatar" @slotchange="${N(this,vt,"m",mt)}"></slot>${this._renderIcon()}<div class="label">${this._renderSlot()}</div><div class="touch" aria-hidden="true"></div></div>${this._renderTrailingIcon()}</div></div>`}_renderTrailingIcon(){return this.removable?o`<span role="gridcell" class="remove"><m3e-icon-button class="remove-button" aria-label="${this.removeLabel}" size="extra-small" tabindex="-1" ?disabled="${this.disabled}" ?disabled-interactive="${this.disabledInteractive}" @click="${N(this,vt,"m",ft)}"><slot name="remove-icon"><svg class="remove-icon" viewBox="0 -960 960 960" fill="currentColor"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></slot></m3e-icon-button></span>`:s}};var $t,yt,wt,_t,At,Et,St,xt,Ct,kt,Pt,Mt,Tt,It,Ut,Ot,Lt,Ht,Nt,Rt,Wt,zt,jt,Dt;vt=new WeakSet,mt=function(e){this.classList.toggle("-with-avatar",h(e.target))},ft=function(e){e.stopPropagation(),this.dispatchEvent(new Event("remove"))},bt=function(e){if(this.removable)switch(e.key){case"Backspace":case"Delete":this.dispatchEvent(new Event("remove"))}},gt.styles=[ge.styles,t`.cell { display: inline-flex; align-items: center; outline: none; column-gap: var(--m3e-chip-spacing, 0.5rem); min-width: 0; } .remove-button { --m3e-icon-button-extra-small-container-height: 1.5rem; --m3e-icon-button-extra-small-icon-size: var(--m3e-chip-icon-size, 1.125rem); width: 1.5rem; } .remove-icon { flex: none; width: var(--m3e-chip-icon-size, 1.125rem); height: var(--m3e-chip-icon-size, 1.125rem); } .touch { top: calc( 0px - calc(calc(3rem - calc(var(--m3e-chip-container-height, 2rem) + ${n.density.calc(-2)})) / 2) ); } .wrapper { height: 100%; overflow: visible; min-width: 0; } ::slotted([slot="avatar"]) { flex: none; font-size: var(--m3e-chip-avatar-size, 1.5rem); } :host(:disabled) ::slotted([slot="avatar"]), :host([disabled-interactive]) ::slotted([slot="avatar"]) { opacity: var(--m3e-chip-disabled-avatar-opacity, 38%); color: var(--m3e-chip-disabled-icon-color, ${n.color.onSurface}); } :host(.-with-avatar) ::slotted([slot="icon"]) { display: none; } :host(.-with-avatar) .wrapper { padding-inline-start: var(--m3e-chip-with-avatar-padding-start, 0.25rem); } @media (forced-colors: active) { :host(:disabled) ::slotted([slot="avatar"]), :host([disabled-interactive]) ::slotted([slot="avatar"]) { color: CanvasText; } }`],H([he(".cell")],gt.prototype,"cell",void 0),H([he(".remove-button")],gt.prototype,"removeButton",void 0),H([ce({type:Boolean})],gt.prototype,"removable",void 0),H([ce({attribute:"remove-label"})],gt.prototype,"removeLabel",void 0),gt=H([W("m3e-input-chip")],gt);let Bt=class extends(k(P(M(A(E(S(g(u($(ye,"grid")))))))))){constructor(){super(...arguments),$t.add(this),yt.set(this,void 0),wt.set(this,()=>N(this,$t,"m",jt).call(this)),_t.set(this,e=>N(this,$t,"m",Dt).call(this,e)),At.set(this,()=>N(this,$t,"m",Ht).call(this)),Et.set(this,()=>N(this,$t,"m",Nt).call(this)),St.set(this,()=>N(this,$t,"m",Rt).call(this)),xt.set(this,e=>N(this,$t,"m",Wt).call(this,e)),Ct.set(this,e=>N(this,$t,"m",zt).call(this,e)),kt.set(this,new U),Pt.set(this,(new O).onActiveItemChange(()=>N(this,Pt,"f").activeItem?.focus()).withHomeAndEnd().withSkipPredicate(e=>!e.hasAttribute("tabindex")).withDirectionality(L.current)),Mt.set(this,!1),Tt.set(this,null),It.set(this,0)}get chips(){return[...this.querySelectorAll("m3e-input-chip")]}get value(){const e=this.chips.filter(e=>!e.disabled).map(e=>e.value);return 0==e.length?null:e}get[(yt=new WeakMap,wt=new WeakMap,_t=new WeakMap,At=new WeakMap,Et=new WeakMap,St=new WeakMap,xt=new WeakMap,Ct=new WeakMap,kt=new WeakMap,Pt=new WeakMap,Mt=new WeakMap,Tt=new WeakMap,It=new WeakMap,$t=new WeakSet,x)](){const e=this.value;if(!e)return null;const t=new FormData;for(const i of e)t.append(this.name,i);return t}get shouldLabelFloat(){return this.chips.length>0}onContainerClick(){N(this,Tt,"f")?.focus()}connectedCallback(){super.connectedCallback(),this.closest("m3e-form-field")?.notifyControlStateChange(),R(this,It,Number.parseInt(this.getAttribute("tabindex")??"0"),"f"),this.addEventListener("focus",N(this,At,"f")),this.addEventListener("focusin",N(this,Et,"f")),this.addEventListener("focusout",N(this,St,"f")),R(this,yt,L.observe(()=>N(this,Pt,"f").directionality=L.current),"f")}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("focus",N(this,At,"f")),this.removeEventListener("focusin",N(this,Et,"f")),this.removeEventListener("focusout",N(this,St,"f")),N(this,yt,"f")?.call(this)}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("tabindex")||this.setAttribute("tabindex",`${N(this,It,"f")}`)}update(e){super.update(e),e.has("vertical")&&(this.ariaOrientation=null),e.has("disabled")&&(N(this,kt,"f").items.forEach(e=>e.disabled=this.disabled),N(this,Tt,"f")&&(N(this,Tt,"f").disabled=this.disabled))}render(){return o`<slot @keydown="${N(this,$t,"m",Ut)}" @slotchange="${N(this,$t,"m",Ot)}"></slot><span role="row"><span role="gridcell"><slot name="input" @slotchange="${N(this,$t,"m",Lt)}"></slot></span></span>`}};Ut=function(e){N(this,Pt,"f").onKeyDown(e)},Ot=async function(){const{added:e,removed:t}=N(this,kt,"f").setItems([...this.querySelectorAll("m3e-input-chip")]);for(const t of e)t.isUpdatePending&&await t.updateComplete,this.disabled&&(t.disabled=!0),t.addEventListener("remove",N(this,xt,"f")),t.cell.addEventListener("click",N(this,Ct,"f"));t.forEach(e=>{e.removeEventListener("remove",N(this,xt,"f")),e.cell.removeEventListener("click",N(this,Ct,"f"))}),N(this,Pt,"f").setItems(N(this,kt,"f").items.flatMap(e=>e.removeButton?[e.cell,e.removeButton]:[e.cell])),N(this,Pt,"f").activeItem||N(this,Pt,"f").updateActiveItem(N(this,Pt,"f").items.find(e=>e.hasAttribute("tabindex")))},Lt=function(){const e=this.querySelector("input");if(N(this,Tt,"f")&&(N(this,Tt,"f").removeEventListener("change",N(this,wt,"f")),N(this,Tt,"f").removeEventListener("keydown",N(this,_t,"f"))),R(this,Tt,e,"f"),N(this,Tt,"f")){N(this,Tt,"f").disabled=this.disabled,N(this,Tt,"f").addEventListener("change",N(this,wt,"f")),N(this,Tt,"f").addEventListener("keydown",N(this,_t,"f"));const t=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");Object.defineProperty(e,"value",{get:()=>t.get?.call(e),set:i=>{t.set?.call(e,i),N(this,Tt,"f")!==e||N(this,Mt,"f")||N(this,$t,"m",jt).call(this)}})}},Ht=function(){setTimeout(()=>(N(this,Pt,"f").activeItem??N(this,Tt,"f"))?.focus())},Nt=function(){this.setAttribute("tabindex","-1")},Rt=function(){this.setAttribute("tabindex",`${N(this,It,"f")}`)},Wt=function(e){const t=e.target,i=N(this,kt,"f").items.indexOf(t),s=N(this,kt,"f").items.find((e,t)=>t>i&&!e.disabled&&e.removable);t.remove(),N(this,Pt,"f").setActiveItem(N(this,Pt,"f").items.find(e=>e===s?.removeButton)),N(this,Pt,"f").activeItem||N(this,Tt,"f")?.focus(),this.dispatchEvent(new Event("change",{bubbles:!0}))},zt=function(e){N(this,Pt,"f").updateActiveItem(e.composedPath().find(e=>e instanceof gt)?.cell)},jt=function(){const e=N(this,Tt,"f")?.value;e&&setTimeout(()=>{const e=N(this,Tt,"f")?.value;if(!e)return;const t=document.createElement("m3e-input-chip");if(t.removable=!0,t.appendChild(document.createTextNode(e)),this.appendChild(t),N(this,Tt,"f"))try{R(this,Mt,!0,"f"),N(this,Tt,"f").value=""}finally{R(this,Mt,!1,"f")}this.dispatchEvent(new Event("change",{bubbles:!0}))})},Dt=function(e){if("Backspace"===e.key&&!N(this,Tt,"f")?.value){const e=[...N(this,kt,"f").items].reverse().find(e=>!e.disabled&&!e.disabledInteractive&&e.removable);e&&e.dispatchEvent(new Event("remove"))}},(()=>{const e=new CSSStyleSheet;e.replaceSync(t`m3e-input-chip-set [slot="input"]::placeholder { user-select: none; color: currentColor; transition: opacity ${n.motion.duration.extraLong1}; } m3e-input-chip-set:not(:focus-within) [slot="input"]::placeholder { opacity: 0; transition: 0s; } m3e-input-chip-set:hover [slot="input"]::placeholder { transition: 0s; } @media (prefers-reduced-motion) { m3e-input-chip-set [slot="input"]::placeholder { transition: none !important; } }`.toString()),document.adoptedStyleSheets=[...document.adoptedStyleSheets,e]})(),Bt.styles=[ye.styles,t`::slotted([slot="input"]) { outline: unset; border: unset; background-color: transparent; box-shadow: none; font-family: inherit; font-size: inherit; line-height: initial; letter-spacing: inherit; color: var(--_form-field-input-color, inherit); flex: 1 1 auto; min-width: 0; padding: unset; } ::slotted(m3e-input-chip) { min-width: 0; } span[role="row"], span[role="gridcell"] { display: contents; }`],Bt=H([W("m3e-input-chip-set")],Bt);let qt=class extends(p(u(v(m(f(b(g($(ge,"button")))))),!0))){_renderTrailingIcon(){return s}};qt=H([W("m3e-suggestion-chip")],qt);export{$e as M3eAssistChipElement,ge as M3eChipElement,ye as M3eChipSetElement,Ee as M3eFilterChipElement,Ie as M3eFilterChipSetElement,gt as M3eInputChipElement,Bt as M3eInputChipSetElement,qt as M3eSuggestionChipElement};
|
|
46
46
|
//# sourceMappingURL=index.min.js.map
|