@m3e/chips 1.0.0-rc.2 → 1.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +42 -65
- package/dist/index.js +59 -18
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +29 -18
- package/dist/index.min.js.map +1 -1
- package/dist/src/AssistChipElement.d.ts +83 -0
- package/dist/src/AssistChipElement.d.ts.map +1 -0
- package/dist/src/ChipElement.d.ts +83 -0
- package/dist/src/ChipElement.d.ts.map +1 -0
- package/dist/src/ChipSetElement.d.ts +42 -0
- package/dist/src/ChipSetElement.d.ts.map +1 -0
- package/dist/src/ChipVariant.d.ts +3 -0
- package/dist/src/ChipVariant.d.ts.map +1 -0
- package/dist/src/FilterChipElement.d.ts +105 -0
- package/dist/src/FilterChipElement.d.ts.map +1 -0
- package/dist/src/FilterChipSetElement.d.ts +77 -0
- package/dist/src/FilterChipSetElement.d.ts.map +1 -0
- package/dist/src/InputChipElement.d.ts +117 -0
- package/dist/src/InputChipElement.d.ts.map +1 -0
- package/dist/src/InputChipSetElement.d.ts +74 -0
- package/dist/src/InputChipSetElement.d.ts.map +1 -0
- package/dist/src/SuggestionChipElement.d.ts +84 -0
- package/dist/src/SuggestionChipElement.d.ts.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.d.ts.map +1 -0
- package/package.json +4 -4
package/dist/index.min.js
CHANGED
|
@@ -101,6 +101,16 @@ function ce(e,t){return(t,i,s)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Ref
|
|
|
101
101
|
overflow: hidden;
|
|
102
102
|
text-overflow: ellipsis;
|
|
103
103
|
}
|
|
104
|
+
a {
|
|
105
|
+
all: unset;
|
|
106
|
+
display: block;
|
|
107
|
+
position: absolute;
|
|
108
|
+
top: 0px;
|
|
109
|
+
left: 0px;
|
|
110
|
+
right: 0px;
|
|
111
|
+
bottom: 0px;
|
|
112
|
+
z-index: 1;
|
|
113
|
+
}
|
|
104
114
|
:host([variant="elevated"]) .base {
|
|
105
115
|
background-color: var(--m3e-elevated-chip-container-color, ${n.color.surfaceContainerLow});
|
|
106
116
|
|
|
@@ -437,7 +447,25 @@ const Te=globalThis,Me=Te.trustedTypes,Ie=Me?Me.createPolicy("lit-html",{createH
|
|
|
437
447
|
`],L([ce(".cell")],mt.prototype,"cell",void 0),L([ce(".remove-button")],mt.prototype,"removeButton",void 0),L([le({type:Boolean})],mt.prototype,"removable",void 0),L([le({attribute:"remove-label"})],mt.prototype,"removeLabel",void 0),mt=L([R("m3e-input-chip")],mt);let zt=class extends(k(P(T(A(E(S(g(u($($e,"grid")))))))))){constructor(){super(...arguments),ft.add(this),bt.set(this,()=>H(this,ft,"m",Nt).call(this)),gt.set(this,e=>H(this,ft,"m",Rt).call(this,e)),$t.set(this,()=>H(this,ft,"m",It).call(this)),yt.set(this,()=>H(this,ft,"m",Ut).call(this)),_t.set(this,()=>H(this,ft,"m",Ot).call(this)),wt.set(this,e=>H(this,ft,"m",Lt).call(this,e)),At.set(this,e=>H(this,ft,"m",Ht).call(this,e)),Et.set(this,new U),St.set(this,(new O).onActiveItemChange(()=>H(this,St,"f").activeItem?.focus()).withHomeAndEnd().withSkipPredicate(e=>!e.hasAttribute("tabindex"))),xt.set(this,!1),Ct.set(this,null),kt.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[(bt=new WeakMap,gt=new WeakMap,$t=new WeakMap,yt=new WeakMap,_t=new WeakMap,wt=new WeakMap,At=new WeakMap,Et=new WeakMap,St=new WeakMap,xt=new WeakMap,Ct=new WeakMap,kt=new WeakMap,ft=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(){H(this,Ct,"f")?.focus()}connectedCallback(){super.connectedCallback(),this.closest("m3e-form-field")?.notifyControlStateChange(),N(this,kt,Number.parseInt(this.getAttribute("tabindex")??"0"),"f"),this.addEventListener("focus",H(this,$t,"f")),this.addEventListener("focusin",H(this,yt,"f")),this.addEventListener("focusout",H(this,_t,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("focus",H(this,$t,"f")),this.removeEventListener("focusin",H(this,yt,"f")),this.removeEventListener("focusout",H(this,_t,"f"))}firstUpdated(e){super.firstUpdated(e),this.hasAttribute("tabindex")||this.setAttribute("tabindex",`${H(this,kt,"f")}`)}update(e){super.update(e),e.has("vertical")&&(this.ariaOrientation=null),e.has("disabled")&&(H(this,Et,"f").items.forEach(e=>e.disabled=this.disabled),H(this,Ct,"f")&&(H(this,Ct,"f").disabled=this.disabled))}render(){return o`<slot @keydown="${H(this,ft,"m",Pt)}" @slotchange="${H(this,ft,"m",Tt)}"></slot>
|
|
438
448
|
<span role="row">
|
|
439
449
|
<span role="gridcell"><slot name="input" @slotchange="${H(this,ft,"m",Mt)}"></slot></span>
|
|
440
|
-
</span> `}};Pt=function(e){H(this,St,"f").onKeyDown(e)},Tt=async function(){const{added:e,removed:t}=H(this,Et,"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",H(this,wt,"f")),t.cell.addEventListener("click",H(this,At,"f"));t.forEach(e=>{e.removeEventListener("remove",H(this,wt,"f")),e.cell.removeEventListener("click",H(this,At,"f"))}),H(this,St,"f").setItems(H(this,Et,"f").items.flatMap(e=>e.removeButton?[e.cell,e.removeButton]:[e.cell])),H(this,St,"f").activeItem||H(this,St,"f").updateActiveItem(H(this,St,"f").items.find(e=>e.hasAttribute("tabindex")))},Mt=function(){const e=this.querySelector("input");if(H(this,Ct,"f")&&(H(this,Ct,"f").removeEventListener("change",H(this,bt,"f")),H(this,Ct,"f").removeEventListener("keydown",H(this,gt,"f"))),N(this,Ct,e,"f"),H(this,Ct,"f")){H(this,Ct,"f").disabled=this.disabled,H(this,Ct,"f").addEventListener("change",H(this,bt,"f")),H(this,Ct,"f").addEventListener("keydown",H(this,gt,"f"));const t=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");Object.defineProperty(e,"value",{get:()=>t.get?.call(e),set:i=>{t.set?.call(e,i),H(this,Ct,"f")!==e||H(this,xt,"f")||H(this,ft,"m",Nt).call(this)}})}},It=function(){setTimeout(()=>(H(this,St,"f").activeItem??H(this,Ct,"f"))?.focus())},Ut=function(){this.setAttribute("tabindex","-1")},Ot=function(){this.setAttribute("tabindex",`${H(this,kt,"f")}`)},Lt=function(e){const t=e.target,i=H(this,Et,"f").items.indexOf(t),s=H(this,Et,"f").items.find((e,t)=>t>i&&!e.disabled&&e.removable);t.remove(),H(this,St,"f").setActiveItem(H(this,St,"f").items.find(e=>e===s?.removeButton)),H(this,St,"f").activeItem||H(this,Ct,"f")?.focus(),this.dispatchEvent(new Event("change",{bubbles:!0}))},Ht=function(e){H(this,St,"f").updateActiveItem(e.composedPath().find(e=>e instanceof mt)?.cell)},Nt=function(){const e=H(this,Ct,"f")?.value;e&&setTimeout(()=>{const e=H(this,Ct,"f")?.value;if(!e)return;const t=document.createElement("m3e-input-chip");if(t.removable=!0,t.appendChild(document.createTextNode(e)),this.appendChild(t),H(this,Ct,"f"))try{N(this,xt,!0,"f"),H(this,Ct,"f").value=""}finally{N(this,xt,!1,"f")}this.dispatchEvent(new Event("change",{bubbles:!0}))})},Rt=function(e){if("Backspace"===e.key&&!H(this,Ct,"f")?.value){const e=[...H(this,Et,"f").items].reverse().find(e=>!e.disabled&&!e.disabledInteractive&&e.removable);e&&e.dispatchEvent(new Event("remove"))}},
|
|
450
|
+
</span> `}};Pt=function(e){H(this,St,"f").onKeyDown(e)},Tt=async function(){const{added:e,removed:t}=H(this,Et,"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",H(this,wt,"f")),t.cell.addEventListener("click",H(this,At,"f"));t.forEach(e=>{e.removeEventListener("remove",H(this,wt,"f")),e.cell.removeEventListener("click",H(this,At,"f"))}),H(this,St,"f").setItems(H(this,Et,"f").items.flatMap(e=>e.removeButton?[e.cell,e.removeButton]:[e.cell])),H(this,St,"f").activeItem||H(this,St,"f").updateActiveItem(H(this,St,"f").items.find(e=>e.hasAttribute("tabindex")))},Mt=function(){const e=this.querySelector("input");if(H(this,Ct,"f")&&(H(this,Ct,"f").removeEventListener("change",H(this,bt,"f")),H(this,Ct,"f").removeEventListener("keydown",H(this,gt,"f"))),N(this,Ct,e,"f"),H(this,Ct,"f")){H(this,Ct,"f").disabled=this.disabled,H(this,Ct,"f").addEventListener("change",H(this,bt,"f")),H(this,Ct,"f").addEventListener("keydown",H(this,gt,"f"));const t=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");Object.defineProperty(e,"value",{get:()=>t.get?.call(e),set:i=>{t.set?.call(e,i),H(this,Ct,"f")!==e||H(this,xt,"f")||H(this,ft,"m",Nt).call(this)}})}},It=function(){setTimeout(()=>(H(this,St,"f").activeItem??H(this,Ct,"f"))?.focus())},Ut=function(){this.setAttribute("tabindex","-1")},Ot=function(){this.setAttribute("tabindex",`${H(this,kt,"f")}`)},Lt=function(e){const t=e.target,i=H(this,Et,"f").items.indexOf(t),s=H(this,Et,"f").items.find((e,t)=>t>i&&!e.disabled&&e.removable);t.remove(),H(this,St,"f").setActiveItem(H(this,St,"f").items.find(e=>e===s?.removeButton)),H(this,St,"f").activeItem||H(this,Ct,"f")?.focus(),this.dispatchEvent(new Event("change",{bubbles:!0}))},Ht=function(e){H(this,St,"f").updateActiveItem(e.composedPath().find(e=>e instanceof mt)?.cell)},Nt=function(){const e=H(this,Ct,"f")?.value;e&&setTimeout(()=>{const e=H(this,Ct,"f")?.value;if(!e)return;const t=document.createElement("m3e-input-chip");if(t.removable=!0,t.appendChild(document.createTextNode(e)),this.appendChild(t),H(this,Ct,"f"))try{N(this,xt,!0,"f"),H(this,Ct,"f").value=""}finally{N(this,xt,!1,"f")}this.dispatchEvent(new Event("change",{bubbles:!0}))})},Rt=function(e){if("Backspace"===e.key&&!H(this,Ct,"f")?.value){const e=[...H(this,Et,"f").items].reverse().find(e=>!e.disabled&&!e.disabledInteractive&&e.removable);e&&e.dispatchEvent(new Event("remove"))}},(()=>{const e=new CSSStyleSheet;e.replaceSync(t`
|
|
451
|
+
m3e-input-chip-set [slot="input"]::placeholder {
|
|
452
|
+
user-select: none;
|
|
453
|
+
color: currentColor;
|
|
454
|
+
transition: opacity ${n.motion.duration.extraLong1};
|
|
455
|
+
}
|
|
456
|
+
m3e-input-chip-set:not(:focus-within) [slot="input"]::placeholder {
|
|
457
|
+
opacity: 0;
|
|
458
|
+
transition: 0s;
|
|
459
|
+
}
|
|
460
|
+
m3e-input-chip-set:hover [slot="input"]::placeholder {
|
|
461
|
+
transition: 0s;
|
|
462
|
+
}
|
|
463
|
+
@media (prefers-reduced-motion) {
|
|
464
|
+
m3e-input-chip-set [slot="input"]::placeholder {
|
|
465
|
+
transition: none !important;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
`.toString()),document.adoptedStyleSheets=[...document.adoptedStyleSheets,e]})(),zt.styles=[$e.styles,t`
|
|
441
469
|
::slotted([slot="input"]) {
|
|
442
470
|
outline: unset;
|
|
443
471
|
border: unset;
|
|
@@ -455,26 +483,9 @@ const Te=globalThis,Me=Te.trustedTypes,Ie=Me?Me.createPolicy("lit-html",{createH
|
|
|
455
483
|
::slotted(m3e-input-chip) {
|
|
456
484
|
min-width: 0;
|
|
457
485
|
}
|
|
458
|
-
::slotted([slot="input"])::placeholder {
|
|
459
|
-
user-select: none;
|
|
460
|
-
color: currentColor;
|
|
461
|
-
transition: opacity ${n.motion.duration.extraLong1};
|
|
462
|
-
}
|
|
463
|
-
:host(:not(:focus-within)) ::slotted([slot="input"])::placeholder {
|
|
464
|
-
opacity: 0;
|
|
465
|
-
transition: 0s;
|
|
466
|
-
}
|
|
467
|
-
:host(:hover) ::slotted([slot="input"])::placeholder {
|
|
468
|
-
transition: 0s;
|
|
469
|
-
}
|
|
470
486
|
span[role="row"],
|
|
471
487
|
span[role="gridcell"] {
|
|
472
488
|
display: contents;
|
|
473
489
|
}
|
|
474
|
-
@media (prefers-reduced-motion) {
|
|
475
|
-
::slotted([slot="input"])::placeholder {
|
|
476
|
-
transition: none !important;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
490
|
`],zt=L([R("m3e-input-chip-set")],zt);let Wt=class extends(p(u(v(m(f(b(g($(be,"button")))))),!0))){_renderTrailingIcon(){return s}};Wt=L([R("m3e-suggestion-chip")],Wt);export{ge as M3eAssistChipElement,be as M3eChipElement,$e as M3eChipSetElement,Ae as M3eFilterChipElement,Pe as M3eFilterChipSetElement,mt as M3eInputChipElement,zt as M3eInputChipSetElement,Wt as M3eSuggestionChipElement};
|
|
480
491
|
//# sourceMappingURL=index.min.js.map
|