@m3e/chips 1.0.0-rc.1
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/LICENSE +22 -0
- package/README.md +539 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +183 -0
- package/dist/css-custom-data.json +777 -0
- package/dist/custom-elements.json +3307 -0
- package/dist/html-custom-data.json +277 -0
- package/dist/index.js +1516 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +480 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/AssistChipElement.d.ts +82 -0
- package/dist/src/AssistChipElement.d.ts.map +1 -0
- package/dist/src/ChipElement.d.ts +86 -0
- package/dist/src/ChipElement.d.ts.map +1 -0
- package/dist/src/ChipSetElement.d.ts +43 -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 +93 -0
- package/dist/src/FilterChipElement.d.ts.map +1 -0
- package/dist/src/FilterChipSetElement.d.ts +78 -0
- package/dist/src/FilterChipSetElement.d.ts.map +1 -0
- package/dist/src/InputChipElement.d.ts +104 -0
- package/dist/src/InputChipElement.d.ts.map +1 -0
- package/dist/src/InputChipSetElement.d.ts +75 -0
- package/dist/src/InputChipSetElement.d.ts.map +1 -0
- package/dist/src/SuggestionChipElement.d.ts +83 -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/eslint.config.mjs +13 -0
- package/package.json +55 -0
- package/rollup.config.js +32 -0
- package/src/AssistChipElement.ts +103 -0
- package/src/ChipElement.ts +336 -0
- package/src/ChipSetElement.ts +60 -0
- package/src/ChipVariant.ts +2 -0
- package/src/FilterChipElement.ts +254 -0
- package/src/FilterChipSetElement.ts +161 -0
- package/src/InputChipElement.ts +287 -0
- package/src/InputChipSetElement.ts +360 -0
- package/src/SuggestionChipElement.ts +104 -0
- package/src/index.ts +9 -0
- package/tsconfig.json +9 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1516 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement, nothing, html, unsafeCSS, css } from 'lit';
|
|
7
|
+
import { Role, isDisabledMixin, isDisabledInteractiveMixin, isLinkButtonMixin, renderPseudoLink, DesignToken, hasAssignedNodes, getTextContent, FormSubmitter, AttachInternals, LinkButton, KeyboardClick, Focusable, DisabledInteractive, Disabled, Vertical, Selected, Labelled, Dirty, Touched, FormAssociated, formValue, EventAttribute, RequiredConstraintValidation, Required, ConstraintValidation } from '@m3e/core';
|
|
8
|
+
import { selectionManager, SelectionManager, ListManager, ListKeyManager } from '@m3e/core/a11y';
|
|
9
|
+
|
|
10
|
+
/******************************************************************************
|
|
11
|
+
Copyright (c) Microsoft Corporation.
|
|
12
|
+
|
|
13
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
+
purpose with or without fee is hereby granted.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
***************************************************************************** */
|
|
24
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
function __decorate(decorators, target, key, desc) {
|
|
28
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
30
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
31
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
35
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
36
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
37
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
41
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
42
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
43
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
44
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
48
|
+
var e = new Error(message);
|
|
49
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @license
|
|
54
|
+
* Copyright 2017 Google LLC
|
|
55
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
56
|
+
*/
|
|
57
|
+
const t$2=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @license
|
|
61
|
+
* Copyright 2019 Google LLC
|
|
62
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
63
|
+
*/
|
|
64
|
+
const t$1=globalThis,e$4=t$1.ShadowRoot&&(void 0===t$1.ShadyCSS||t$1.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$1=Symbol(),o$4=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$1)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$4&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$4.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$4.set(s,t));}return t}toString(){return this.cssText}};const r$3=t=>new n$3("string"==typeof t?t:t+"",void 0,s$1),S$1=(s,o)=>{if(e$4)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$1.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$4?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$3(e)})(t):t;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @license
|
|
68
|
+
* Copyright 2017 Google LLC
|
|
69
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
70
|
+
*/const{is:i$1,defineProperty:e$3,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$2,getOwnPropertySymbols:o$3,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$1(t,s),b={attribute:true,type:String,converter:u$1,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$3(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$2(t),...o$3(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[d$1("elementProperties")]=new Map,y[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y}),(a$1.reactiveElementVersions??=[]).push("2.1.1");
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @license
|
|
74
|
+
* Copyright 2017 Google LLC
|
|
75
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
76
|
+
*/const o$2={attribute:true,type:String,converter:u$1,reflect:false,hasChanged:f$1},r$1=(t=o$2,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=true),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n$1(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @license
|
|
80
|
+
* Copyright 2017 Google LLC
|
|
81
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
82
|
+
*/
|
|
83
|
+
const e$2=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @license
|
|
87
|
+
* Copyright 2017 Google LLC
|
|
88
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
89
|
+
*/function e$1(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$2(n,s,{get(){return o(this)}})}}
|
|
90
|
+
|
|
91
|
+
var _M3eChipElement_instances, _M3eChipElement_value, _M3eChipElement_textContent, _M3eChipElement_renderContent, _M3eChipElement_handleIconSlotChange, _M3eChipElement_handleTrailingIconSlotChange, _M3eChipElement_handleSlotChange;
|
|
92
|
+
/**
|
|
93
|
+
* @summary
|
|
94
|
+
* A non-interactive chip used to convey small pieces of information.
|
|
95
|
+
*
|
|
96
|
+
* @description
|
|
97
|
+
* The `m3e-chip` component establishes the foundational structure for chips. It supports expressive styling,
|
|
98
|
+
* accessible interaction, and flexible content projection, aligning with Material 3 guidelines. Appearance
|
|
99
|
+
* variants include `elevated` and `outlined`, enabling visual differentiation and contextual emphasis.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* The following example illustrates use of the `m3e-chip` and `m3e-chip-set` components to present non-interactive chips.
|
|
103
|
+
* ```html
|
|
104
|
+
* <m3e-chip-set>
|
|
105
|
+
* <m3e-chip><m3e-icon slot="icon" name="palette"></m3e-icon>Design</m3e-chip>
|
|
106
|
+
* <m3e-chip><m3e-icon slot="icon" name="accessibility_new"></m3e-icon>Accessibility</m3e-chip>
|
|
107
|
+
* <m3e-chip><m3e-icon slot="icon" name="motion_photos_on"></m3e-icon>Motion</m3e-chip>
|
|
108
|
+
* <m3e-chip><m3e-icon slot="icon" name="description"></m3e-icon>Documentation</m3e-chip>
|
|
109
|
+
* </m3e-chip-set>
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @tag m3e-chip
|
|
113
|
+
*
|
|
114
|
+
* @slot - Renders the label of the chip.
|
|
115
|
+
* @slot icon - Renders an icon before the chip's label.
|
|
116
|
+
* @slot trailing-icon - Renders an icon after the chip's label.
|
|
117
|
+
*
|
|
118
|
+
* @attr value - A string representing the value of the chip.
|
|
119
|
+
* @attr variant - The appearance variant of the chip.
|
|
120
|
+
*
|
|
121
|
+
* @cssprop --m3e-chip-container-shape - Border radius of the chip container.
|
|
122
|
+
* @cssprop --m3e-chip-container-height - Base height of the chip container before density adjustment.
|
|
123
|
+
* @cssprop --m3e-chip-label-text-font-size - Font size of the chip label text.
|
|
124
|
+
* @cssprop --m3e-chip-label-text-font-weight - Font weight of the chip label text.
|
|
125
|
+
* @cssprop --m3e-chip-label-text-line-height - Line height of the chip label text.
|
|
126
|
+
* @cssprop --m3e-chip-label-text-tracking - Letter spacing of the chip label text.
|
|
127
|
+
* @cssprop --m3e-chip-label-text-color - Label text color in default state.
|
|
128
|
+
* @cssprop --m3e-chip-icon-color - Icon color in default state.
|
|
129
|
+
* @cssprop --m3e-chip-icon-size - Font size of leading/trailing icons.
|
|
130
|
+
* @cssprop --m3e-chip-spacing - Horizontal gap between chip content elements.
|
|
131
|
+
* @cssprop --m3e-chip-padding-start - Default start padding when no icon is present.
|
|
132
|
+
* @cssprop --m3e-chip-padding-end - Default end padding when no trailing icon is present.
|
|
133
|
+
* @cssprop --m3e-chip-with-icon-padding-start - Start padding when leading icon is present.
|
|
134
|
+
* @cssprop --m3e-chip-with-icon-padding-end - End padding when trailing icon is present.
|
|
135
|
+
* @cssprop --m3e-elevated-chip-container-color - Background color for elevated variant.
|
|
136
|
+
* @cssprop --m3e-elevated-chip-elevation - Elevation level for elevated variant.
|
|
137
|
+
* @cssprop --m3e-elevated-chip-hover-elevation - Elevation level on hover.
|
|
138
|
+
* @cssprop --m3e-outlined-chip-outline-thickness - Outline thickness for outlined variant.
|
|
139
|
+
* @cssprop --m3e-outlined-chip-outline-color - Outline color for outlined variant.
|
|
140
|
+
*/
|
|
141
|
+
let M3eChipElement = class M3eChipElement extends Role(LitElement, "none") {
|
|
142
|
+
constructor() {
|
|
143
|
+
super(...arguments);
|
|
144
|
+
_M3eChipElement_instances.add(this);
|
|
145
|
+
/** @private */ _M3eChipElement_value.set(this, void 0);
|
|
146
|
+
/** @private */ _M3eChipElement_textContent.set(this, "");
|
|
147
|
+
/**
|
|
148
|
+
* The appearance variant of the chip.
|
|
149
|
+
* @default "outlined"
|
|
150
|
+
*/
|
|
151
|
+
this.variant = "outlined";
|
|
152
|
+
}
|
|
153
|
+
/** A string representing the value of the chip. */
|
|
154
|
+
get value() {
|
|
155
|
+
return __classPrivateFieldGet(this, _M3eChipElement_value, "f") ?? __classPrivateFieldGet(this, _M3eChipElement_textContent, "f");
|
|
156
|
+
}
|
|
157
|
+
set value(value) {
|
|
158
|
+
__classPrivateFieldSet(this, _M3eChipElement_value, value, "f");
|
|
159
|
+
}
|
|
160
|
+
/** @inheritdoc */
|
|
161
|
+
firstUpdated(_changedProperties) {
|
|
162
|
+
super.firstUpdated(_changedProperties);
|
|
163
|
+
if (this.role === "listitem") {
|
|
164
|
+
this.removeAttribute("tabindex");
|
|
165
|
+
}
|
|
166
|
+
[this._elevation, this._focusRing, this._stateLayer, this._ripple].forEach((x) => {
|
|
167
|
+
if (!x?.htmlFor) {
|
|
168
|
+
x?.attach(this);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/** @inheritdoc */
|
|
173
|
+
render() {
|
|
174
|
+
const disabled = !isDisabledMixin(this) || this.disabled;
|
|
175
|
+
const disabledInteractive = isDisabledInteractiveMixin(this) && this.disabledInteractive;
|
|
176
|
+
return html `<div class="base">
|
|
177
|
+
<m3e-elevation class="elevation" ?disabled="${disabled || disabledInteractive}"></m3e-elevation>
|
|
178
|
+
<m3e-state-layer class="state-layer" ?disabled="${disabled || disabledInteractive}"></m3e-state-layer>
|
|
179
|
+
<m3e-focus-ring class="focus-ring" ?disabled="${disabled}"></m3e-focus-ring>
|
|
180
|
+
<m3e-ripple class="ripple" ?disabled="${disabled || disabledInteractive}"></m3e-ripple>
|
|
181
|
+
<div class="touch" aria-hidden="true"></div>
|
|
182
|
+
${isLinkButtonMixin(this) ? this[renderPseudoLink]() : nothing}
|
|
183
|
+
<div class="wrapper">${__classPrivateFieldGet(this, _M3eChipElement_instances, "m", _M3eChipElement_renderContent).call(this)}</div>
|
|
184
|
+
</div>`;
|
|
185
|
+
}
|
|
186
|
+
/** @internal */
|
|
187
|
+
_renderIcon() {
|
|
188
|
+
return html `<slot name="icon" aria-hidden="true" @slotchange="${__classPrivateFieldGet(this, _M3eChipElement_instances, "m", _M3eChipElement_handleIconSlotChange)}"></slot>`;
|
|
189
|
+
}
|
|
190
|
+
/** @internal */
|
|
191
|
+
_renderTrailingIcon() {
|
|
192
|
+
return html `<slot
|
|
193
|
+
name="trailing-icon"
|
|
194
|
+
aria-hidden="true"
|
|
195
|
+
@slotchange="${__classPrivateFieldGet(this, _M3eChipElement_instances, "m", _M3eChipElement_handleTrailingIconSlotChange)}"
|
|
196
|
+
></slot>`;
|
|
197
|
+
}
|
|
198
|
+
/** @internal */
|
|
199
|
+
_renderSlot() {
|
|
200
|
+
return html `<slot @slotchange="${__classPrivateFieldGet(this, _M3eChipElement_instances, "m", _M3eChipElement_handleSlotChange)}"></slot>`;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
_M3eChipElement_value = new WeakMap();
|
|
204
|
+
_M3eChipElement_textContent = new WeakMap();
|
|
205
|
+
_M3eChipElement_instances = new WeakSet();
|
|
206
|
+
_M3eChipElement_renderContent = function _M3eChipElement_renderContent() {
|
|
207
|
+
return html `${this._renderIcon()}
|
|
208
|
+
<div class="label">${this._renderSlot()}</div>
|
|
209
|
+
${this._renderTrailingIcon()}`;
|
|
210
|
+
};
|
|
211
|
+
_M3eChipElement_handleIconSlotChange = function _M3eChipElement_handleIconSlotChange(e) {
|
|
212
|
+
this.classList.toggle("-with-icon", hasAssignedNodes(e.target));
|
|
213
|
+
};
|
|
214
|
+
_M3eChipElement_handleTrailingIconSlotChange = function _M3eChipElement_handleTrailingIconSlotChange(e) {
|
|
215
|
+
this.classList.toggle("-with-trailing-icon", hasAssignedNodes(e.target));
|
|
216
|
+
};
|
|
217
|
+
_M3eChipElement_handleSlotChange = function _M3eChipElement_handleSlotChange(e) {
|
|
218
|
+
__classPrivateFieldSet(this, _M3eChipElement_textContent, getTextContent(e.target), "f");
|
|
219
|
+
};
|
|
220
|
+
/** The styles of the element. */
|
|
221
|
+
M3eChipElement.styles = css `
|
|
222
|
+
:host {
|
|
223
|
+
display: inline-block;
|
|
224
|
+
vertical-align: middle;
|
|
225
|
+
outline: none;
|
|
226
|
+
}
|
|
227
|
+
.base {
|
|
228
|
+
box-sizing: border-box;
|
|
229
|
+
vertical-align: middle;
|
|
230
|
+
display: inline-flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
justify-content: center;
|
|
233
|
+
position: relative;
|
|
234
|
+
width: 100%;
|
|
235
|
+
transition: ${unsafeCSS(`background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};
|
|
236
|
+
border-radius: var(--m3e-chip-container-shape, ${DesignToken.shape.corner.small});
|
|
237
|
+
height: calc(var(--m3e-chip-container-height, 2rem) + ${DesignToken.density.calc(-2)});
|
|
238
|
+
font-size: var(--m3e-chip-label-text-font-size, ${DesignToken.typescale.standard.label.large.fontSize});
|
|
239
|
+
font-weight: var(--m3e-chip-label-text-font-weight, ${DesignToken.typescale.standard.label.large.fontWeight});
|
|
240
|
+
line-height: var(--m3e-chip-label-text-line-height, ${DesignToken.typescale.standard.label.large.lineHeight});
|
|
241
|
+
letter-spacing: var(--m3e-chip-label-text-tracking, ${DesignToken.typescale.standard.label.large.tracking});
|
|
242
|
+
}
|
|
243
|
+
:host(:not(m3e-chip):not(:disabled):not([disabled-interactive])) {
|
|
244
|
+
cursor: pointer;
|
|
245
|
+
}
|
|
246
|
+
:host(:not(m3e-chip):not(:disabled)[disabled-interactive]) {
|
|
247
|
+
cursor: not-allowed;
|
|
248
|
+
}
|
|
249
|
+
:host(:not(m3e-chip):not(:disabled):not([disabled-interactive])) .base {
|
|
250
|
+
user-select: none;
|
|
251
|
+
}
|
|
252
|
+
.touch {
|
|
253
|
+
position: absolute;
|
|
254
|
+
height: 3rem;
|
|
255
|
+
left: 0;
|
|
256
|
+
right: 0;
|
|
257
|
+
}
|
|
258
|
+
.wrapper {
|
|
259
|
+
width: 100%;
|
|
260
|
+
overflow: hidden;
|
|
261
|
+
display: inline-flex;
|
|
262
|
+
align-items: center;
|
|
263
|
+
column-gap: var(--m3e-chip-spacing, 0.5rem);
|
|
264
|
+
}
|
|
265
|
+
.label {
|
|
266
|
+
flex: 1 1 auto;
|
|
267
|
+
min-width: 0;
|
|
268
|
+
white-space: nowrap;
|
|
269
|
+
overflow: hidden;
|
|
270
|
+
text-overflow: ellipsis;
|
|
271
|
+
}
|
|
272
|
+
:host([variant="elevated"]) .base {
|
|
273
|
+
background-color: var(--m3e-elevated-chip-container-color, ${DesignToken.color.surfaceContainerLow});
|
|
274
|
+
|
|
275
|
+
--m3e-elevation-level: var(--m3e-elevated-chip-elevation, ${DesignToken.elevation.level1});
|
|
276
|
+
--m3e-elevation-hover-level: var(--m3e-elevated-chip-hover-elevation, ${DesignToken.elevation.level2});
|
|
277
|
+
--m3e-elevation-focus-level: var(--m3e-elevated-chip-elevation, ${DesignToken.elevation.level1});
|
|
278
|
+
--m3e-elevation-pressed-level: var(--m3e-elevated-chip-elevation, ${DesignToken.elevation.level1});
|
|
279
|
+
}
|
|
280
|
+
:host([variant="outlined"]) .base {
|
|
281
|
+
outline-width: var(--m3e-outlined-chip-outline-thickness, 1px);
|
|
282
|
+
outline-style: solid;
|
|
283
|
+
outline-offset: calc(0px - var(--m3e-outlined-chip-outline-thickness, 1px));
|
|
284
|
+
}
|
|
285
|
+
:host(:not(:disabled):not([disabled-interactive])[variant="outlined"]) .base {
|
|
286
|
+
outline-color: var(--m3e-outlined-chip-outline-color, ${DesignToken.color.outlineVariant});
|
|
287
|
+
}
|
|
288
|
+
:host(:disabled[variant="outlined"]) .base,
|
|
289
|
+
:host([disabled-interactive][variant="outlined"]) .base {
|
|
290
|
+
outline-color: color-mix(
|
|
291
|
+
in srgb,
|
|
292
|
+
var(--m3e-outlined-chip-disabled-outline-color, ${DesignToken.color.onSurface})
|
|
293
|
+
var(--m3e-outlined-chip-disabled-outline-opacity, 12%),
|
|
294
|
+
transparent
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
:host(.-with-icon) .wrapper {
|
|
298
|
+
padding-inline-start: var(--m3e-chip-with-icon-padding-start, 0.5rem);
|
|
299
|
+
}
|
|
300
|
+
:host(:not(.-with-icon)) .wrapper {
|
|
301
|
+
padding-inline-start: var(--m3e-chip-padding-start, 1rem);
|
|
302
|
+
}
|
|
303
|
+
:host(.-with-trailing-icon) .wrapper {
|
|
304
|
+
padding-inline-end: var(--m3e-chip-with-icon-padding-end, 0.5rem);
|
|
305
|
+
}
|
|
306
|
+
:host(:not(.-with-trailing-icon)) .wrapper {
|
|
307
|
+
padding-inline-end: var(--m3e-chip-padding-end, 1rem);
|
|
308
|
+
}
|
|
309
|
+
::slotted([slot="icon"]),
|
|
310
|
+
::slotted([slot="trailing-icon"]) {
|
|
311
|
+
flex: none;
|
|
312
|
+
width: 1em;
|
|
313
|
+
font-size: var(--m3e-chip-icon-size, 1.125rem) !important;
|
|
314
|
+
}
|
|
315
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) .base {
|
|
316
|
+
color: var(--m3e-chip-label-text-color, ${DesignToken.color.onSurface});
|
|
317
|
+
}
|
|
318
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]),
|
|
319
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) {
|
|
320
|
+
color: var(--m3e-chip-icon-color, ${DesignToken.color.primary});
|
|
321
|
+
}
|
|
322
|
+
:host(:disabled) .base,
|
|
323
|
+
:host([disabled-interactive]) .base {
|
|
324
|
+
color: color-mix(
|
|
325
|
+
in srgb,
|
|
326
|
+
var(--m3e-chip-disabled-label-text-color, ${DesignToken.color.onSurface})
|
|
327
|
+
var(--m3e-chip-disabled-label-text-opacity, 38%),
|
|
328
|
+
transparent
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
:host(:disabled) ::slotted([slot="icon"]),
|
|
332
|
+
:host([disabled-interactive]) ::slotted([slot="icon"]),
|
|
333
|
+
:host(:disabled) ::slotted([slot="trailing-icon"]),
|
|
334
|
+
:host([disabled-interactive]) ::slotted([slot="trailing-icon"]) {
|
|
335
|
+
color: color-mix(
|
|
336
|
+
in srgb,
|
|
337
|
+
var(--m3e-chip-disabled-icon-color, ${DesignToken.color.onSurface}) var(--m3e-chip-disabled-icon-opacity, 38%),
|
|
338
|
+
transparent
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
:host([variant="elevated"]:disabled) .base,
|
|
342
|
+
:host([variant="elevated"][disabled-interactive]) .base {
|
|
343
|
+
background-color: color-mix(
|
|
344
|
+
in srgb,
|
|
345
|
+
var(--m3e-elevated-chip-disabled-container-color, ${DesignToken.color.onSurface})
|
|
346
|
+
var(--m3e-elevated-chip-disabled-container-opacity, 12%),
|
|
347
|
+
transparent
|
|
348
|
+
);
|
|
349
|
+
--m3e-elevation-level: var(--m3e-elevated-chip-disabled-elevation, ${DesignToken.elevation.level0});
|
|
350
|
+
}
|
|
351
|
+
@media (prefers-reduced-motion) {
|
|
352
|
+
.base {
|
|
353
|
+
transition: none;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
@media (forced-colors: active) {
|
|
357
|
+
.base {
|
|
358
|
+
transition: none;
|
|
359
|
+
}
|
|
360
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) .base,
|
|
361
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]),
|
|
362
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) {
|
|
363
|
+
color: CanvasText;
|
|
364
|
+
}
|
|
365
|
+
:host(:not(:disabled):not([disabled-interactive])[variant="outlined"]) .base {
|
|
366
|
+
outline-color: CanvasText;
|
|
367
|
+
}
|
|
368
|
+
:host(:disabled) .base,
|
|
369
|
+
:host([disabled-interactive]) .base,
|
|
370
|
+
:host(:disabled) ::slotted([slot="icon"]),
|
|
371
|
+
:host([disabled-interactive]) ::slotted([slot="icon"]),
|
|
372
|
+
:host(:disabled) ::slotted([slot="trailing-icon"]),
|
|
373
|
+
:host([disabled-interactive]) ::slotted([slot="trailing-icon"]) {
|
|
374
|
+
color: GrayText;
|
|
375
|
+
}
|
|
376
|
+
:host(:disabled[variant="outlined"]) .base,
|
|
377
|
+
:host([disabled-interactive][variant="outlined"]) .base {
|
|
378
|
+
outline-color: GrayText;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
`;
|
|
382
|
+
__decorate([
|
|
383
|
+
e$1(".elevation")
|
|
384
|
+
], M3eChipElement.prototype, "_elevation", void 0);
|
|
385
|
+
__decorate([
|
|
386
|
+
e$1(".focus-ring")
|
|
387
|
+
], M3eChipElement.prototype, "_focusRing", void 0);
|
|
388
|
+
__decorate([
|
|
389
|
+
e$1(".state-layer")
|
|
390
|
+
], M3eChipElement.prototype, "_stateLayer", void 0);
|
|
391
|
+
__decorate([
|
|
392
|
+
e$1(".ripple")
|
|
393
|
+
], M3eChipElement.prototype, "_ripple", void 0);
|
|
394
|
+
__decorate([
|
|
395
|
+
n$1({ reflect: true })
|
|
396
|
+
], M3eChipElement.prototype, "variant", void 0);
|
|
397
|
+
__decorate([
|
|
398
|
+
n$1()
|
|
399
|
+
], M3eChipElement.prototype, "value", null);
|
|
400
|
+
M3eChipElement = __decorate([
|
|
401
|
+
t$2("m3e-chip")
|
|
402
|
+
], M3eChipElement);
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* @summary
|
|
406
|
+
* A chip users interact with to perform a smart or automated action that can span multiple applications.
|
|
407
|
+
*
|
|
408
|
+
* @description
|
|
409
|
+
* The `m3e-assist-chip` component presents a Material 3 assist chip, providing users with quick access to
|
|
410
|
+
* contextually relevant actions. It is designed for use cases like suggested actions, quick filters, or
|
|
411
|
+
* secondary operations, and supports accessibility, keyboard interaction, and expressive state styling
|
|
412
|
+
* in line with Material 3 guidelines. Appearance variants include `elevated` and `outlined`, enabling visual
|
|
413
|
+
* differentiation and contextual emphasis.
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* The following example illustrates use of the `m3e-assist-chip`. In this example, multiple chips are nested inside
|
|
417
|
+
* a `m3e-chip-set` container to create a cohesive set of chips. The container is given the ARIA `role="group"` to convey
|
|
418
|
+
* to assistive technologies that the chips are part of a related set of element.
|
|
419
|
+
* ```html
|
|
420
|
+
* <m3e-chip-set role="group" aria-label="Quick actions">
|
|
421
|
+
* <m3e-assist-chip><m3e-icon slot="icon" name="edit"></m3e-icon>Edit</m3e-assist-chip>
|
|
422
|
+
* <m3e-assist-chip><m3e-icon slot="icon" name="delete"></m3e-icon>Delete</m3e-assist-chip>
|
|
423
|
+
* <m3e-assist-chip><m3e-icon slot="icon" name="content_copy"></m3e-icon>Copy</m3e-assist-chip>
|
|
424
|
+
* <m3e-assist-chip><m3e-icon slot="icon" name="share"></m3e-icon>Share</m3e-assist-chip>
|
|
425
|
+
* </m3e-chip-set>
|
|
426
|
+
* ```
|
|
427
|
+
*
|
|
428
|
+
* @tag m3e-assist-chip
|
|
429
|
+
*
|
|
430
|
+
* @slot - Renders the label of the chip.
|
|
431
|
+
* @slot icon - Renders an icon before the chip's label.
|
|
432
|
+
*
|
|
433
|
+
* @attr disabled - A value indicating whether the element is disabled.
|
|
434
|
+
* @attr disabled-interactive - A value indicating whether the element is disabled and interactive.
|
|
435
|
+
* @attr download - A value indicating whether the `target` of the link button will be downloaded, optionally specifying the new name of the file.
|
|
436
|
+
* @attr href - The URL to which the link button points.
|
|
437
|
+
* @attr name - The name of the element, submitted as a pair with the element's `value` as part of form data, when the element is used to submit a form.
|
|
438
|
+
* @attr rel - The relationship between the `target` of the link button and the document.
|
|
439
|
+
* @attr target - The target of the link button.
|
|
440
|
+
* @attr type - The type of the element.
|
|
441
|
+
* @attr value - A string representing the value of the chip.
|
|
442
|
+
* @attr variant - The appearance variant of the chip.
|
|
443
|
+
*
|
|
444
|
+
* @cssprop --m3e-chip-container-shape - Border radius of the chip container.
|
|
445
|
+
* @cssprop --m3e-chip-container-height - Base height of the chip container before density adjustment.
|
|
446
|
+
* @cssprop --m3e-chip-label-text-font-size - Font size of the chip label text.
|
|
447
|
+
* @cssprop --m3e-chip-label-text-font-weight - Font weight of the chip label text.
|
|
448
|
+
* @cssprop --m3e-chip-label-text-line-height - Line height of the chip label text.
|
|
449
|
+
* @cssprop --m3e-chip-label-text-tracking - Letter spacing of the chip label text.
|
|
450
|
+
* @cssprop --m3e-chip-label-text-color - Label text color in default state.
|
|
451
|
+
* @cssprop --m3e-chip-icon-color - Icon color in default state.
|
|
452
|
+
* @cssprop --m3e-chip-icon-size - Font size of leading/trailing icons.
|
|
453
|
+
* @cssprop --m3e-chip-spacing - Horizontal gap between chip content elements.
|
|
454
|
+
* @cssprop --m3e-chip-padding-start - Default start padding when no icon is present.
|
|
455
|
+
* @cssprop --m3e-chip-padding-end - Default end padding when no trailing icon is present.
|
|
456
|
+
* @cssprop --m3e-chip-with-icon-padding-start - Start padding when leading icon is present.
|
|
457
|
+
* @cssprop --m3e-chip-with-icon-padding-end - End padding when trailing icon is present.
|
|
458
|
+
* @cssprop --m3e-chip-disabled-label-text-color - Base color for disabled label text.
|
|
459
|
+
* @cssprop --m3e-chip-disabled-label-text-opacity - Opacity applied to disabled label text.
|
|
460
|
+
* @cssprop --m3e-chip-disabled-icon-color - Base color for disabled icons.
|
|
461
|
+
* @cssprop --m3e-chip-disabled-icon-opacity - Opacity applied to disabled icons.
|
|
462
|
+
* @cssprop --m3e-elevated-chip-container-color - Background color for elevated variant.
|
|
463
|
+
* @cssprop --m3e-elevated-chip-elevation - Elevation level for elevated variant.
|
|
464
|
+
* @cssprop --m3e-elevated-chip-hover-elevation - Elevation level on hover.
|
|
465
|
+
* @cssprop --m3e-elevated-chip-disabled-container-color - Background color for disabled elevated variant.
|
|
466
|
+
* @cssprop --m3e-elevated-chip-disabled-container-opacity - Opacity applied to disabled elevated background.
|
|
467
|
+
* @cssprop --m3e-elevated-chip-disabled-elevation - Elevation level for disabled elevated variant.
|
|
468
|
+
* @cssprop --m3e-outlined-chip-outline-thickness - Outline thickness for outlined variant.
|
|
469
|
+
* @cssprop --m3e-outlined-chip-outline-color - Outline color for outlined variant.
|
|
470
|
+
* @cssprop --m3e-outlined-chip-disabled-outline-color - Outline color for disabled outlined variant.
|
|
471
|
+
* @cssprop --m3e-outlined-chip-disabled-outline-opacity - Opacity applied to disabled outline.
|
|
472
|
+
*/
|
|
473
|
+
let M3eAssistChipElement = class M3eAssistChipElement extends FormSubmitter(AttachInternals(LinkButton(KeyboardClick(Focusable(DisabledInteractive(Disabled(Role(M3eChipElement, "button")))))), true)) {
|
|
474
|
+
/** @internal @inheritdoc */
|
|
475
|
+
_renderTrailingIcon() {
|
|
476
|
+
return nothing;
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
M3eAssistChipElement = __decorate([
|
|
480
|
+
t$2("m3e-assist-chip")
|
|
481
|
+
], M3eAssistChipElement);
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* @summary
|
|
485
|
+
* A container used to organize chips into a cohesive unit.
|
|
486
|
+
*
|
|
487
|
+
* @description
|
|
488
|
+
* The `m3e-chip-set` component provides a flexible container for grouping chips, supporting both
|
|
489
|
+
* horizontal and vertical layouts. It manages chip arrangement, spacing, and accessibility, and
|
|
490
|
+
* serves as the foundation for chip set variants such as input and filter chip sets.
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* The following example illustrates use of the `m3e-chip` and `m3e-chip-set` components to present non-interactive chips.
|
|
494
|
+
* ```html
|
|
495
|
+
* <m3e-chip-set>
|
|
496
|
+
* <m3e-chip><m3e-icon slot="icon" name="palette"></m3e-icon>Design</m3e-chip>
|
|
497
|
+
* <m3e-chip><m3e-icon slot="icon" name="accessibility_new"></m3e-icon>Accessibility</m3e-chip>
|
|
498
|
+
* <m3e-chip><m3e-icon slot="icon" name="motion_photos_on"></m3e-icon>Motion</m3e-chip>
|
|
499
|
+
* <m3e-chip><m3e-icon slot="icon" name="description"></m3e-icon>Documentation</m3e-chip>
|
|
500
|
+
* </m3e-chip-set>
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* @tag m3e-chip-set
|
|
504
|
+
*
|
|
505
|
+
* @slot - Renders the chips of the set.
|
|
506
|
+
*
|
|
507
|
+
* @attr vertical - Whether the element is oriented vertically.
|
|
508
|
+
*
|
|
509
|
+
* @cssprop --m3e-chip-set-spacing - The spacing (gap) between chips in the set.
|
|
510
|
+
*/
|
|
511
|
+
let M3eChipSetElement = class M3eChipSetElement extends Vertical(Role(LitElement, "none")) {
|
|
512
|
+
/** @inheritdoc */
|
|
513
|
+
render() {
|
|
514
|
+
return html `<slot></slot>`;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
/** The styles of the element. */
|
|
518
|
+
M3eChipSetElement.styles = css `
|
|
519
|
+
:host {
|
|
520
|
+
display: inline-flex;
|
|
521
|
+
flex-wrap: wrap;
|
|
522
|
+
vertical-align: middle;
|
|
523
|
+
gap: var(--m3e-chip-set-spacing, 0.5rem);
|
|
524
|
+
outline: none;
|
|
525
|
+
}
|
|
526
|
+
:host([vertical]) {
|
|
527
|
+
flex-direction: column;
|
|
528
|
+
}
|
|
529
|
+
`;
|
|
530
|
+
M3eChipSetElement = __decorate([
|
|
531
|
+
t$2("m3e-chip-set")
|
|
532
|
+
], M3eChipSetElement);
|
|
533
|
+
|
|
534
|
+
var _M3eFilterChipElement_instances, _M3eFilterChipElement_clickHandler, _M3eFilterChipElement_handleClick;
|
|
535
|
+
/**
|
|
536
|
+
* @summary
|
|
537
|
+
* A chip users interact with to select/deselect options.
|
|
538
|
+
*
|
|
539
|
+
* @description
|
|
540
|
+
* The `m3e-filter-chip` component presents a chip that users can select or deselect to filter
|
|
541
|
+
* content or data sets. It supports single and multi-selection, keyboard interaction, accessibility,
|
|
542
|
+
* and expressive state styling, providing a modern and interactive filtering experience in line
|
|
543
|
+
* with Material 3 guidelines. Appearance variants include `elevated` and `outlined`, enabling visual
|
|
544
|
+
* differentiation and contextual emphasis.
|
|
545
|
+
*
|
|
546
|
+
* @tag m3e-filter-chip
|
|
547
|
+
*
|
|
548
|
+
* @slot - Renders the label of the chip.
|
|
549
|
+
* @slot icon - Renders an icon before the chip's label.
|
|
550
|
+
* @slot trailing-icon - Renders an icon after the chip's label.
|
|
551
|
+
*
|
|
552
|
+
* @attr disabled - A value indicating whether the element is disabled.
|
|
553
|
+
* @attr disabled-interactive - A value indicating whether the element is disabled and interactive.
|
|
554
|
+
* @attr selected - A value indicating whether the element is selected.
|
|
555
|
+
* @attr value - A string representing the value of the chip.
|
|
556
|
+
* @attr variant - The appearance variant of the chip.
|
|
557
|
+
*
|
|
558
|
+
* @fires input - Emitted when the selected state changes.
|
|
559
|
+
* @fires change - Emitted when the selected state changes.
|
|
560
|
+
*
|
|
561
|
+
* @cssprop --m3e-chip-container-shape - Border radius of the chip container.
|
|
562
|
+
* @cssprop --m3e-chip-container-height - Base height of the chip container before density adjustment.
|
|
563
|
+
* @cssprop --m3e-chip-label-text-font-size - Font size of the chip label text.
|
|
564
|
+
* @cssprop --m3e-chip-label-text-font-weight - Font weight of the chip label text.
|
|
565
|
+
* @cssprop --m3e-chip-label-text-line-height - Line height of the chip label text.
|
|
566
|
+
* @cssprop --m3e-chip-label-text-tracking - Letter spacing of the chip label text.
|
|
567
|
+
* @cssprop --m3e-chip-icon-size - Font size of leading/trailing icons.
|
|
568
|
+
* @cssprop --m3e-chip-spacing - Horizontal gap between chip content elements.
|
|
569
|
+
* @cssprop --m3e-chip-padding-start - Default start padding when no icon is present.
|
|
570
|
+
* @cssprop --m3e-chip-padding-end - Default end padding when no trailing icon is present.
|
|
571
|
+
* @cssprop --m3e-chip-with-icon-padding-start - Start padding when leading icon is present.
|
|
572
|
+
* @cssprop --m3e-chip-with-icon-padding-end - End padding when trailing icon is present.
|
|
573
|
+
* @cssprop --m3e-chip-disabled-label-text-color - Base color for disabled label text.
|
|
574
|
+
* @cssprop --m3e-chip-disabled-label-text-opacity - Opacity applied to disabled label text.
|
|
575
|
+
* @cssprop --m3e-chip-disabled-icon-color - Base color for disabled icons.
|
|
576
|
+
* @cssprop --m3e-chip-disabled-icon-opacity - Opacity applied to disabled icons.
|
|
577
|
+
* @cssprop --m3e-elevated-chip-container-color - Background color for elevated variant.
|
|
578
|
+
* @cssprop --m3e-elevated-chip-elevation - Elevation level for elevated variant.
|
|
579
|
+
* @cssprop --m3e-elevated-chip-hover-elevation - Elevation level on hover.
|
|
580
|
+
* @cssprop --m3e-elevated-chip-disabled-container-color - Background color for disabled elevated variant.
|
|
581
|
+
* @cssprop --m3e-elevated-chip-disabled-container-opacity - Opacity applied to disabled elevated background.
|
|
582
|
+
* @cssprop --m3e-elevated-chip-disabled-elevation - Elevation level for disabled elevated variant.
|
|
583
|
+
* @cssprop --m3e-outlined-chip-outline-thickness - Outline thickness for outlined variant.
|
|
584
|
+
* @cssprop --m3e-outlined-chip-outline-color - Outline color for outlined variant.
|
|
585
|
+
* @cssprop --m3e-outlined-chip-disabled-outline-color - Outline color for disabled outlined variant.
|
|
586
|
+
* @cssprop --m3e-outlined-chip-disabled-outline-opacity - Opacity applied to disabled outline.
|
|
587
|
+
* @cssprop --m3e-chip-selected-outline-thickness - Outline thickness for selected state.
|
|
588
|
+
* @cssprop --m3e-chip-selected-label-text-color - Text color in selected state.
|
|
589
|
+
* @cssprop --m3e-chip-selected-container-color - Background color in selected state.
|
|
590
|
+
* @cssprop --m3e-chip-selected-container-hover-color - Hover state layer color in selected state.
|
|
591
|
+
* @cssprop --m3e-chip-selected-container-focus-color - Focus state layer color in selected state.
|
|
592
|
+
* @cssprop --m3e-chip-selected-hover-elevation - Elevation on hover in selected state.
|
|
593
|
+
* @cssprop --m3e-chip-selected-ripple-color - Ripple color in selected state.
|
|
594
|
+
* @cssprop --m3e-chip-selected-state-layer-focus-color - Focus state layer color in selected state.
|
|
595
|
+
* @cssprop --m3e-chip-selected-state-layer-hover-color - Hover state layer color in selected state.
|
|
596
|
+
* @cssprop --m3e-chip-selected-leading-icon-color - Leading icon color in selected state.
|
|
597
|
+
* @cssprop --m3e-chip-selected-trailing-icon-color - Trailing icon color in selected state.
|
|
598
|
+
* @cssprop --m3e-chip-unselected-label-text-color - Text color in unselected state.
|
|
599
|
+
* @cssprop --m3e-chip-unselected-ripple-color - Ripple color in unselected state.
|
|
600
|
+
* @cssprop --m3e-chip-unselected-state-layer-focus-color - Focus state layer color in unselected state.
|
|
601
|
+
* @cssprop --m3e-chip-unselected-state-layer-hover-color - Hover state layer color in unselected state.
|
|
602
|
+
* @cssprop --m3e-chip-unselected-leading-icon-color - Leading icon color in unselected state.
|
|
603
|
+
* @cssprop --m3e-chip-unselected-trailing-icon-color - Trailing icon color in unselected state.
|
|
604
|
+
*/
|
|
605
|
+
let M3eFilterChipElement = class M3eFilterChipElement extends Selected(KeyboardClick(Focusable(DisabledInteractive(Disabled(AttachInternals(Role(M3eChipElement, "option"), true)))))) {
|
|
606
|
+
constructor() {
|
|
607
|
+
super(...arguments);
|
|
608
|
+
_M3eFilterChipElement_instances.add(this);
|
|
609
|
+
/** @private */ _M3eFilterChipElement_clickHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eFilterChipElement_instances, "m", _M3eFilterChipElement_handleClick).call(this, e));
|
|
610
|
+
}
|
|
611
|
+
/** @inheritdoc */
|
|
612
|
+
connectedCallback() {
|
|
613
|
+
super.connectedCallback();
|
|
614
|
+
this.addEventListener("click", __classPrivateFieldGet(this, _M3eFilterChipElement_clickHandler, "f"));
|
|
615
|
+
}
|
|
616
|
+
/** @inheritdoc */
|
|
617
|
+
disconnectedCallback() {
|
|
618
|
+
super.disconnectedCallback();
|
|
619
|
+
this.removeEventListener("click", __classPrivateFieldGet(this, _M3eFilterChipElement_clickHandler, "f"));
|
|
620
|
+
}
|
|
621
|
+
/** @inheritdoc */
|
|
622
|
+
update(changedProperties) {
|
|
623
|
+
super.update(changedProperties);
|
|
624
|
+
if (changedProperties.has("selected")) {
|
|
625
|
+
this.closest("m3e-filter-chip-set")?.[selectionManager].notifySelectionChange(this);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
/** @inheritdoc @private */
|
|
629
|
+
_renderIcon() {
|
|
630
|
+
return html `<div class="icon" aria-hidden="true">
|
|
631
|
+
<svg class="check" viewBox="0 -960 960 960" aria-hidden="true">
|
|
632
|
+
<path fill="currentColor" d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z" />
|
|
633
|
+
</svg>
|
|
634
|
+
${super._renderIcon()}
|
|
635
|
+
</div>`;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
_M3eFilterChipElement_clickHandler = new WeakMap();
|
|
639
|
+
_M3eFilterChipElement_instances = new WeakSet();
|
|
640
|
+
_M3eFilterChipElement_handleClick = function _M3eFilterChipElement_handleClick(e) {
|
|
641
|
+
if (e.defaultPrevented)
|
|
642
|
+
return;
|
|
643
|
+
const selected = this.selected;
|
|
644
|
+
this.selected = !this.selected;
|
|
645
|
+
if (this.dispatchEvent(new Event("input", { bubbles: true, composed: true, cancelable: true }))) {
|
|
646
|
+
this.closest("m3e-filter-chip-set")?.[selectionManager].notifySelectionChange(this);
|
|
647
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
this.selected = selected;
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
/** The styles of the element. */
|
|
654
|
+
M3eFilterChipElement.styles = [
|
|
655
|
+
M3eChipElement.styles,
|
|
656
|
+
css `
|
|
657
|
+
:host([selected]:not(.-hide-selection)) .wrapper {
|
|
658
|
+
padding-inline-start: var(--m3e-chip-with-icon-padding-start, 0.5rem);
|
|
659
|
+
}
|
|
660
|
+
.icon {
|
|
661
|
+
display: flex;
|
|
662
|
+
align-items: center;
|
|
663
|
+
justify-content: center;
|
|
664
|
+
}
|
|
665
|
+
.check {
|
|
666
|
+
width: 1em;
|
|
667
|
+
font-size: var(--m3e-chip-icon-size, 1.125rem);
|
|
668
|
+
}
|
|
669
|
+
:host(:not(:disabled):not([disabled-interactive])) .check {
|
|
670
|
+
color: var(--m3e-chip-selected-leading-icon-color, ${DesignToken.color.onSecondaryContainer});
|
|
671
|
+
}
|
|
672
|
+
:host(:not([selected])) .check,
|
|
673
|
+
:host(.-hide-selection) .check,
|
|
674
|
+
:host(.-hide-selection:not(.-with-icon)) .icon {
|
|
675
|
+
display: none;
|
|
676
|
+
}
|
|
677
|
+
:host(:not(.-with-icon)) .icon {
|
|
678
|
+
margin-inline-start: calc(0px - var(--m3e-chip-with-icon-padding-start, 0.5rem));
|
|
679
|
+
transition: margin-inline-start ${DesignToken.motion.spring.fastEffects};
|
|
680
|
+
}
|
|
681
|
+
:host([selected]) .icon {
|
|
682
|
+
margin-inline-start: 0;
|
|
683
|
+
}
|
|
684
|
+
:host([selected]:not(.-hide-selection)) ::slotted([slot="icon"]) {
|
|
685
|
+
display: none !important;
|
|
686
|
+
}
|
|
687
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) .base {
|
|
688
|
+
color: var(--m3e-chip-unselected-label-text-color, ${DesignToken.color.onSurfaceVariant});
|
|
689
|
+
--m3e-ripple-color: var(--m3e-chip-unselected-ripple-color, ${DesignToken.color.onSurfaceVariant});
|
|
690
|
+
--m3e-state-layer-focus-color: var(
|
|
691
|
+
--m3e-chip-unselected-state-layer-focus-color,
|
|
692
|
+
${DesignToken.color.onSurfaceVariant}
|
|
693
|
+
);
|
|
694
|
+
--m3e-state-layer-hover-color: var(
|
|
695
|
+
--m3e-chip-unselected-state-layer-hover-color,
|
|
696
|
+
${DesignToken.color.onSurfaceVariant}
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]) {
|
|
700
|
+
color: var(--m3e-chip-unselected-leading-icon-color, ${DesignToken.color.primary});
|
|
701
|
+
}
|
|
702
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) {
|
|
703
|
+
color: var(--m3e-chip-unselected-trailing-icon-color, ${DesignToken.color.onSurfaceVariant});
|
|
704
|
+
}
|
|
705
|
+
:host(:not(:disabled):not([disabled-interactive])[selected]) .base {
|
|
706
|
+
outline-offset: unset;
|
|
707
|
+
outline-width: var(--m3e-chip-selected-outline-thickness, 0);
|
|
708
|
+
color: var(--m3e-chip-selected-label-text-color, ${DesignToken.color.onSecondaryContainer});
|
|
709
|
+
background-color: var(--m3e-chip-selected-container-color, ${DesignToken.color.secondaryContainer});
|
|
710
|
+
--m3e-state-layer-hover-color: var(
|
|
711
|
+
--m3e-chip-selected-container-hover-color,
|
|
712
|
+
${DesignToken.color.onSecondaryContainer}
|
|
713
|
+
);
|
|
714
|
+
--m3e-state-layer-focus-color: var(
|
|
715
|
+
--m3e-chip-selected-container-focus-color,
|
|
716
|
+
${DesignToken.color.onSecondaryContainer}
|
|
717
|
+
);
|
|
718
|
+
--m3e-elevation-hover-level: var(--m3e-chip-selected-hover-elevation, ${DesignToken.elevation.level1});
|
|
719
|
+
--m3e-ripple-color: var(--m3e-chip-selected-ripple-color, ${DesignToken.color.onSecondaryContainer});
|
|
720
|
+
--m3e-state-layer-focus-color: var(
|
|
721
|
+
--m3e-chip-selected-state-layer-focus-color,
|
|
722
|
+
${DesignToken.color.onSecondaryContainer}
|
|
723
|
+
);
|
|
724
|
+
--m3e-state-layer-hover-color: var(
|
|
725
|
+
--m3e-chip-selected-state-layer-hover-color,
|
|
726
|
+
${DesignToken.color.onSecondaryContainer}
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
:host(:not(:disabled):not([disabled-interactive])[selected]) ::slotted([slot="icon"]) {
|
|
730
|
+
color: var(--m3e-chip-selected-leading-icon-color, ${DesignToken.color.onSecondaryContainer});
|
|
731
|
+
}
|
|
732
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) {
|
|
733
|
+
color: var(--m3e-chip-selected-trailing-icon-color, ${DesignToken.color.onSecondaryContainer});
|
|
734
|
+
}
|
|
735
|
+
@media (prefers-reduced-motion) {
|
|
736
|
+
.base,
|
|
737
|
+
:host(:not(.-with-icon)) .icon {
|
|
738
|
+
transition: none;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
@media (forced-colors: active) {
|
|
742
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) .base,
|
|
743
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="icon"]),
|
|
744
|
+
:host(:not(:disabled):not([disabled-interactive]):not([selected])) ::slotted([slot="trailing-icon"]) {
|
|
745
|
+
color: CanvasText;
|
|
746
|
+
}
|
|
747
|
+
:host(:not(:disabled):not([disabled-interactive])[selected]) .base,
|
|
748
|
+
:host(:not(:disabled):not([disabled-interactive])[selected]) ::slotted([slot="icon"]),
|
|
749
|
+
:host(:not(:disabled):not([disabled-interactive])[selected]) ::slotted([slot="trailing-icon"]),
|
|
750
|
+
:host(:not(:disabled):not([disabled-interactive])) .check {
|
|
751
|
+
color: ButtonText;
|
|
752
|
+
}
|
|
753
|
+
:host(:not(:disabled):not([disabled-interactive])[selected]) .base {
|
|
754
|
+
outline-offset: calc(0px - var(--m3e-outlined-chip-outline-thickness, 1px));
|
|
755
|
+
outline-width: var(--m3e-outlined-chip-outline-thickness, 1px);
|
|
756
|
+
outline-color: ButtonText;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
`,
|
|
760
|
+
];
|
|
761
|
+
M3eFilterChipElement = __decorate([
|
|
762
|
+
t$2("m3e-filter-chip")
|
|
763
|
+
], M3eFilterChipElement);
|
|
764
|
+
|
|
765
|
+
var _M3eFilterChipSetElement_instances, _M3eFilterChipSetElement_handleSlotChange, _M3eFilterChipSetElement_handleKeyDown, _M3eFilterChipSetElement_handleChange, _a;
|
|
766
|
+
/**
|
|
767
|
+
* @summary
|
|
768
|
+
* A container that organizes filter chips into a cohesive group, enabling selection and
|
|
769
|
+
* deselection of values used to refine content or trigger contextual behavior.
|
|
770
|
+
*
|
|
771
|
+
* @description
|
|
772
|
+
* The `m3e-filter-chip-set` component presents a group of filter chips, enabling users to select
|
|
773
|
+
* one or more options to filter content or data sets. It supports single and multi-selection,
|
|
774
|
+
* keyboard navigation, accessibility, and seamless form association, providing expressive and
|
|
775
|
+
* interactive filtering experiences in line with Material 3 guidelines.
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* The following example illustrates a single-select `m3e-filter-chip-set` containing multiple `m3e-filter-chip` components that
|
|
779
|
+
* allow a user to choose an option. You can use the `multi` attribute to enable multiselect.
|
|
780
|
+
* ```html
|
|
781
|
+
* <m3e-filter-chip-set aria-label="Filter by topic">
|
|
782
|
+
* <m3e-filter-chip><m3e-icon slot="icon" name="palette"></m3e-icon>Design</m3e-filter-chip>
|
|
783
|
+
* <m3e-filter-chip><m3e-icon slot="icon" name="accessibility_new"></m3e-icon>Accessibility</m3e-filter-chip>
|
|
784
|
+
* <m3e-filter-chip><m3e-icon slot="icon" name="motion_photos_on"></m3e-icon>Motion</m3e-filter-chip>
|
|
785
|
+
* <m3e-filter-chip><m3e-icon slot="icon" name="description"></m3e-icon>Documentation</m3e-filter-chip>
|
|
786
|
+
* </m3e-filter-chip-set>
|
|
787
|
+
* ```
|
|
788
|
+
*
|
|
789
|
+
* @tag m3e-filter-chip-set
|
|
790
|
+
*
|
|
791
|
+
* @slot - Renders the chips of the set.
|
|
792
|
+
*
|
|
793
|
+
* @attr disabled - Whether the element is disabled.
|
|
794
|
+
* @attr hide-selection-indicator - Whether to hide the selection indicator.
|
|
795
|
+
* @attr multi - Whether multiple chips can be selected.
|
|
796
|
+
* @attr name - The name that identifies the element when submitting the associated form.
|
|
797
|
+
* @attr vertical - Whether the element is oriented vertically.
|
|
798
|
+
*
|
|
799
|
+
* @fires input - Emitted when the selected state of a chip changes.
|
|
800
|
+
* @fires change - Emitted when the selected state of a chip changes.
|
|
801
|
+
*
|
|
802
|
+
* @cssprop --m3e-chip-set-spacing - The spacing (gap) between chips in the set.
|
|
803
|
+
*/
|
|
804
|
+
let M3eFilterChipSetElement = class M3eFilterChipSetElement extends Labelled(Dirty(Touched(FormAssociated(Disabled(AttachInternals(Role(M3eChipSetElement, "listbox"))))))) {
|
|
805
|
+
constructor() {
|
|
806
|
+
super(...arguments);
|
|
807
|
+
_M3eFilterChipSetElement_instances.add(this);
|
|
808
|
+
/** @internal */
|
|
809
|
+
this[_a] = new SelectionManager()
|
|
810
|
+
.onActiveItemChange(() => this[selectionManager].activeItem?.focus())
|
|
811
|
+
.withWrap();
|
|
812
|
+
/**
|
|
813
|
+
* Whether multiple chips can be selected.
|
|
814
|
+
* @default false
|
|
815
|
+
*/
|
|
816
|
+
this.multi = false;
|
|
817
|
+
/**
|
|
818
|
+
* Whether to hide the selection indicator.
|
|
819
|
+
* @default false
|
|
820
|
+
*/
|
|
821
|
+
this.hideSelectionIndicator = false;
|
|
822
|
+
}
|
|
823
|
+
/** The chips of the set. */
|
|
824
|
+
get chips() {
|
|
825
|
+
return this[selectionManager]?.items ?? [];
|
|
826
|
+
}
|
|
827
|
+
/** The selected chip(s) of the set. */
|
|
828
|
+
get selected() {
|
|
829
|
+
return this[selectionManager]?.selectedItems ?? [];
|
|
830
|
+
}
|
|
831
|
+
/** The selected value(s) of the set. */
|
|
832
|
+
get value() {
|
|
833
|
+
const values = this.selected.map((x) => x.value);
|
|
834
|
+
switch (values.length) {
|
|
835
|
+
case 0:
|
|
836
|
+
return null;
|
|
837
|
+
case 1:
|
|
838
|
+
return values[0];
|
|
839
|
+
default:
|
|
840
|
+
return values;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
/** @inheritdoc @internal */
|
|
844
|
+
get [(_M3eFilterChipSetElement_instances = new WeakSet(), _a = selectionManager, formValue)]() {
|
|
845
|
+
const values = this.value;
|
|
846
|
+
if (Array.isArray(values)) {
|
|
847
|
+
const data = new FormData();
|
|
848
|
+
for (const value of values) {
|
|
849
|
+
data.append(this.name, value);
|
|
850
|
+
}
|
|
851
|
+
return data;
|
|
852
|
+
}
|
|
853
|
+
return values;
|
|
854
|
+
}
|
|
855
|
+
/** @inheritdoc */
|
|
856
|
+
update(changedProperties) {
|
|
857
|
+
super.update(changedProperties);
|
|
858
|
+
if (changedProperties.has("vertical")) {
|
|
859
|
+
this[selectionManager].vertical = this.vertical;
|
|
860
|
+
}
|
|
861
|
+
if (changedProperties.has("disabled") && (changedProperties.get("disabled") !== undefined || this.disabled)) {
|
|
862
|
+
this[selectionManager].disabled = this.disabled;
|
|
863
|
+
}
|
|
864
|
+
if (changedProperties.has("multi")) {
|
|
865
|
+
this.ariaMultiSelectable = `${this.multi}`;
|
|
866
|
+
this[selectionManager].multi = this.multi;
|
|
867
|
+
this[selectionManager].disableRovingTabIndex(this.multi);
|
|
868
|
+
}
|
|
869
|
+
if (changedProperties.has("hideSelectionIndicator")) {
|
|
870
|
+
this.chips.forEach((x) => x.classList.toggle("-hide-selection", this.hideSelectionIndicator));
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
/** @inheritdoc */
|
|
874
|
+
render() {
|
|
875
|
+
return html `<slot
|
|
876
|
+
@slotchange="${__classPrivateFieldGet(this, _M3eFilterChipSetElement_instances, "m", _M3eFilterChipSetElement_handleSlotChange)}"
|
|
877
|
+
@keydown="${__classPrivateFieldGet(this, _M3eFilterChipSetElement_instances, "m", _M3eFilterChipSetElement_handleKeyDown)}"
|
|
878
|
+
@change="${__classPrivateFieldGet(this, _M3eFilterChipSetElement_instances, "m", _M3eFilterChipSetElement_handleChange)}"
|
|
879
|
+
></slot>`;
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
_M3eFilterChipSetElement_handleSlotChange = function _M3eFilterChipSetElement_handleSlotChange() {
|
|
883
|
+
const { added } = this[selectionManager].setItems([...this.querySelectorAll("m3e-filter-chip")]);
|
|
884
|
+
added.forEach((x) => x.classList.toggle("-hide-selection", this.hideSelectionIndicator));
|
|
885
|
+
};
|
|
886
|
+
_M3eFilterChipSetElement_handleKeyDown = function _M3eFilterChipSetElement_handleKeyDown(e) {
|
|
887
|
+
if (!this.multi) {
|
|
888
|
+
this[selectionManager].onKeyDown(e);
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
_M3eFilterChipSetElement_handleChange = function _M3eFilterChipSetElement_handleChange(e) {
|
|
892
|
+
e.stopPropagation();
|
|
893
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
894
|
+
};
|
|
895
|
+
__decorate([
|
|
896
|
+
n$1({ type: Boolean })
|
|
897
|
+
], M3eFilterChipSetElement.prototype, "multi", void 0);
|
|
898
|
+
__decorate([
|
|
899
|
+
n$1({ attribute: "hide-selection-indicator", type: Boolean })
|
|
900
|
+
], M3eFilterChipSetElement.prototype, "hideSelectionIndicator", void 0);
|
|
901
|
+
M3eFilterChipSetElement = __decorate([
|
|
902
|
+
t$2("m3e-filter-chip-set")
|
|
903
|
+
], M3eFilterChipSetElement);
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* @license
|
|
907
|
+
* Copyright 2017 Google LLC
|
|
908
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
909
|
+
*/
|
|
910
|
+
const t=globalThis,i=t.trustedTypes,s=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$1="?"+h,n=`<${o$1}>`,r=document,l=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n:d>=0?(o.push(a),s.slice(0,d)+e+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i?i.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$1)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r).importNode(i,true);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(false,true,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t.litHtmlPolyfillSupport;j?.(N,R),(t.litHtmlVersions??=[]).push("3.3.1");
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* @license
|
|
914
|
+
* Copyright 2018 Google LLC
|
|
915
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
916
|
+
*/const o=o=>o??E;
|
|
917
|
+
|
|
918
|
+
var _M3eInputChipElement_instances, _M3eInputChipElement_handleAvatarSlotChange, _M3eInputChipElement_handleRemoveButtonClick, _M3eInputChipElement_handleKeyDown;
|
|
919
|
+
/**
|
|
920
|
+
* @summary
|
|
921
|
+
* A chip which represents a discrete piece of information entered by a user.
|
|
922
|
+
*
|
|
923
|
+
* @description
|
|
924
|
+
* The `m3e-input-chip` component represents an input chip, allowing users to enter, display,
|
|
925
|
+
* and manage discrete values such as tags or keywords. It supports expressive styling, accessibility,
|
|
926
|
+
* keyboard interaction, and appearance variants including `elevated` and `outlined`.
|
|
927
|
+
*
|
|
928
|
+
* @tag m3e-input-chip
|
|
929
|
+
*
|
|
930
|
+
* @slot - Renders the label of the chip.
|
|
931
|
+
* @slot avatar - Renders an avatar before the chip's label.
|
|
932
|
+
* @slot icon - Renders an icon before the chip's label.
|
|
933
|
+
* @slot remove-icon - Renders the icon for the button used to remove the chip.
|
|
934
|
+
*
|
|
935
|
+
* @attr disabled - Whether the element is disabled.
|
|
936
|
+
* @attr disabled-interactive - Whether the element is disabled and interactive.
|
|
937
|
+
* @attr removable - Whether the chip is removable.
|
|
938
|
+
* @attr remove-label - The accessible label given to the button used to remove the chip.
|
|
939
|
+
* @attr value - A string representing the value of the chip.
|
|
940
|
+
* @attr variant - The appearance variant of the chip.
|
|
941
|
+
*
|
|
942
|
+
* @fires remove - Emitted when the remove button is clicked or DELETE or BACKSPACE key is pressed.
|
|
943
|
+
*
|
|
944
|
+
* @cssprop --m3e-chip-container-shape - Border radius of the chip container.
|
|
945
|
+
* @cssprop --m3e-chip-container-height - Base height of the chip container before density adjustment.
|
|
946
|
+
* @cssprop --m3e-chip-label-text-font-size - Font size of the chip label text.
|
|
947
|
+
* @cssprop --m3e-chip-label-text-font-weight - Font weight of the chip label text.
|
|
948
|
+
* @cssprop --m3e-chip-label-text-line-height - Line height of the chip label text.
|
|
949
|
+
* @cssprop --m3e-chip-label-text-tracking - Letter spacing of the chip label text.
|
|
950
|
+
* @cssprop --m3e-chip-label-text-color - Label text color in default state.
|
|
951
|
+
* @cssprop --m3e-chip-icon-color - Icon color in default state.
|
|
952
|
+
* @cssprop --m3e-chip-icon-size - Font size of leading/trailing icons.
|
|
953
|
+
* @cssprop --m3e-chip-spacing - Horizontal gap between chip content elements.
|
|
954
|
+
* @cssprop --m3e-chip-padding-start - Default start padding when no icon is present.
|
|
955
|
+
* @cssprop --m3e-chip-padding-end - Default end padding when no trailing icon is present.
|
|
956
|
+
* @cssprop --m3e-chip-with-icon-padding-start - Start padding when leading icon is present.
|
|
957
|
+
* @cssprop --m3e-chip-with-icon-padding-end - End padding when trailing icon is present.
|
|
958
|
+
* @cssprop --m3e-chip-disabled-label-text-color - Base color for disabled label text.
|
|
959
|
+
* @cssprop --m3e-chip-disabled-label-text-opacity - Opacity applied to disabled label text.
|
|
960
|
+
* @cssprop --m3e-chip-disabled-icon-color - Base color for disabled icons.
|
|
961
|
+
* @cssprop --m3e-chip-disabled-icon-opacity - Opacity applied to disabled icons.
|
|
962
|
+
* @cssprop --m3e-elevated-chip-container-color - Background color for elevated variant.
|
|
963
|
+
* @cssprop --m3e-elevated-chip-elevation - Elevation level for elevated variant.
|
|
964
|
+
* @cssprop --m3e-elevated-chip-hover-elevation - Elevation level on hover.
|
|
965
|
+
* @cssprop --m3e-elevated-chip-disabled-container-color - Background color for disabled elevated variant.
|
|
966
|
+
* @cssprop --m3e-elevated-chip-disabled-container-opacity - Opacity applied to disabled elevated background.
|
|
967
|
+
* @cssprop --m3e-elevated-chip-disabled-elevation - Elevation level for disabled elevated variant.
|
|
968
|
+
* @cssprop --m3e-outlined-chip-outline-thickness - Outline thickness for outlined variant.
|
|
969
|
+
* @cssprop --m3e-outlined-chip-outline-color - Outline color for outlined variant.
|
|
970
|
+
* @cssprop --m3e-outlined-chip-disabled-outline-color - Outline color for disabled outlined variant.
|
|
971
|
+
* @cssprop --m3e-outlined-chip-disabled-outline-opacity - Opacity applied to disabled outline.
|
|
972
|
+
* @cssprop --m3e-chip-avatar-size - Font size of the avatar slot content.
|
|
973
|
+
* @cssprop --m3e-chip-disabled-avatar-opacity - Opacity applied to the avatar when disabled.
|
|
974
|
+
* @cssprop --m3e-chip-with-avatar-padding-start - Start padding when an avatar is present.
|
|
975
|
+
*/
|
|
976
|
+
let M3eInputChipElement = class M3eInputChipElement extends EventAttribute(DisabledInteractive(Disabled(AttachInternals(Role(M3eChipElement, "row"), true))), "remove") {
|
|
977
|
+
constructor() {
|
|
978
|
+
super(...arguments);
|
|
979
|
+
_M3eInputChipElement_instances.add(this);
|
|
980
|
+
/**
|
|
981
|
+
* Whether the chip is removable.
|
|
982
|
+
* @default false
|
|
983
|
+
*/
|
|
984
|
+
this.removable = false;
|
|
985
|
+
/**
|
|
986
|
+
* The accessible label given to the button used to remove the chip.
|
|
987
|
+
* @default "Remove"
|
|
988
|
+
*/
|
|
989
|
+
this.removeLabel = "Remove";
|
|
990
|
+
}
|
|
991
|
+
/** @inheritdoc */
|
|
992
|
+
connectedCallback() {
|
|
993
|
+
super.connectedCallback();
|
|
994
|
+
this.removeAttribute("tabindex");
|
|
995
|
+
}
|
|
996
|
+
/** @inheritdoc */
|
|
997
|
+
update(changedProperties) {
|
|
998
|
+
super.update(changedProperties);
|
|
999
|
+
this.removeAttribute("tabindex");
|
|
1000
|
+
if (changedProperties.has("removable")) {
|
|
1001
|
+
this.classList.toggle("-with-trailing-icon", this.removable);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
/** @inheritdoc */
|
|
1005
|
+
render() {
|
|
1006
|
+
return html `<div class="base">
|
|
1007
|
+
<m3e-elevation
|
|
1008
|
+
class="elevation"
|
|
1009
|
+
for="cell"
|
|
1010
|
+
?disabled="${this.disabled || this.disabledInteractive}"
|
|
1011
|
+
></m3e-elevation>
|
|
1012
|
+
<m3e-state-layer
|
|
1013
|
+
class="state-layer"
|
|
1014
|
+
for="cell"
|
|
1015
|
+
?disabled="${this.disabled || this.disabledInteractive}"
|
|
1016
|
+
></m3e-state-layer>
|
|
1017
|
+
<m3e-focus-ring class="focus-ring" for="cell" ?disabled="${this.disabled}"></m3e-focus-ring>
|
|
1018
|
+
<m3e-ripple class="ripple" for="cell" ?disabled="${this.disabled || this.disabledInteractive}"></m3e-ripple>
|
|
1019
|
+
<div class="wrapper">
|
|
1020
|
+
<div
|
|
1021
|
+
id="cell"
|
|
1022
|
+
class="cell"
|
|
1023
|
+
role="gridcell"
|
|
1024
|
+
tabindex="${o(this.disabled ? undefined : "-1")}"
|
|
1025
|
+
@keydown="${__classPrivateFieldGet(this, _M3eInputChipElement_instances, "m", _M3eInputChipElement_handleKeyDown)}"
|
|
1026
|
+
>
|
|
1027
|
+
<slot name="avatar" @slotchange="${__classPrivateFieldGet(this, _M3eInputChipElement_instances, "m", _M3eInputChipElement_handleAvatarSlotChange)}"></slot>
|
|
1028
|
+
${this._renderIcon()}
|
|
1029
|
+
<div class="label">${this._renderSlot()}</div>
|
|
1030
|
+
<div class="touch" aria-hidden="true"></div>
|
|
1031
|
+
</div>
|
|
1032
|
+
${this._renderTrailingIcon()}
|
|
1033
|
+
</div>
|
|
1034
|
+
</div>`;
|
|
1035
|
+
}
|
|
1036
|
+
/** @internal @inheritdoc */
|
|
1037
|
+
_renderTrailingIcon() {
|
|
1038
|
+
return this.removable
|
|
1039
|
+
? html `<span role="gridcell" class="remove">
|
|
1040
|
+
<m3e-icon-button
|
|
1041
|
+
class="remove-button"
|
|
1042
|
+
aria-label="${this.removeLabel}"
|
|
1043
|
+
size="extra-small"
|
|
1044
|
+
tabindex="-1"
|
|
1045
|
+
?disabled="${this.disabled}"
|
|
1046
|
+
?disabled-interactive="${this.disabledInteractive}"
|
|
1047
|
+
@click="${__classPrivateFieldGet(this, _M3eInputChipElement_instances, "m", _M3eInputChipElement_handleRemoveButtonClick)}"
|
|
1048
|
+
>
|
|
1049
|
+
<slot name="remove-icon">
|
|
1050
|
+
<svg class="remove-icon" viewBox="0 -960 960 960" fill="currentColor">
|
|
1051
|
+
<path
|
|
1052
|
+
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"
|
|
1053
|
+
/>
|
|
1054
|
+
</svg>
|
|
1055
|
+
</slot>
|
|
1056
|
+
</m3e-icon-button>
|
|
1057
|
+
</span>`
|
|
1058
|
+
: nothing;
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
_M3eInputChipElement_instances = new WeakSet();
|
|
1062
|
+
_M3eInputChipElement_handleAvatarSlotChange = function _M3eInputChipElement_handleAvatarSlotChange(e) {
|
|
1063
|
+
this.classList.toggle("-with-avatar", hasAssignedNodes(e.target));
|
|
1064
|
+
};
|
|
1065
|
+
_M3eInputChipElement_handleRemoveButtonClick = function _M3eInputChipElement_handleRemoveButtonClick(e) {
|
|
1066
|
+
e.stopPropagation();
|
|
1067
|
+
this.dispatchEvent(new Event("remove"));
|
|
1068
|
+
};
|
|
1069
|
+
_M3eInputChipElement_handleKeyDown = function _M3eInputChipElement_handleKeyDown(e) {
|
|
1070
|
+
if (this.removable) {
|
|
1071
|
+
switch (e.key) {
|
|
1072
|
+
case "Backspace":
|
|
1073
|
+
case "Delete":
|
|
1074
|
+
this.dispatchEvent(new Event("remove"));
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
/** The styles of the element. */
|
|
1080
|
+
M3eInputChipElement.styles = [
|
|
1081
|
+
M3eChipElement.styles,
|
|
1082
|
+
css `
|
|
1083
|
+
.cell {
|
|
1084
|
+
display: inline-flex;
|
|
1085
|
+
align-items: center;
|
|
1086
|
+
outline: none;
|
|
1087
|
+
column-gap: var(--m3e-chip-spacing, 0.5rem);
|
|
1088
|
+
min-width: 0;
|
|
1089
|
+
}
|
|
1090
|
+
.remove-button {
|
|
1091
|
+
--m3e-icon-button-extra-small-container-height: 1.5rem;
|
|
1092
|
+
--m3e-icon-button-extra-small-icon-size: var(--m3e-chip-icon-size, 1.125rem);
|
|
1093
|
+
width: 1.5rem;
|
|
1094
|
+
}
|
|
1095
|
+
.remove-icon {
|
|
1096
|
+
flex: none;
|
|
1097
|
+
width: var(--m3e-chip-icon-size, 1.125rem);
|
|
1098
|
+
height: var(--m3e-chip-icon-size, 1.125rem);
|
|
1099
|
+
}
|
|
1100
|
+
.touch {
|
|
1101
|
+
top: calc(
|
|
1102
|
+
0px - calc(calc(3rem - calc(var(--m3e-chip-container-height, 2rem) + ${DesignToken.density.calc(-2)})) / 2)
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
.wrapper {
|
|
1106
|
+
height: 100%;
|
|
1107
|
+
overflow: visible;
|
|
1108
|
+
min-width: 0;
|
|
1109
|
+
}
|
|
1110
|
+
::slotted([slot="avatar"]) {
|
|
1111
|
+
flex: none;
|
|
1112
|
+
font-size: var(--m3e-chip-avatar-size, 1.5rem);
|
|
1113
|
+
}
|
|
1114
|
+
:host(:disabled) ::slotted([slot="avatar"]),
|
|
1115
|
+
:host([disabled-interactive]) ::slotted([slot="avatar"]) {
|
|
1116
|
+
opacity: var(--m3e-chip-disabled-avatar-opacity, 38%);
|
|
1117
|
+
color: var(--m3e-chip-disabled-icon-color, ${DesignToken.color.onSurface});
|
|
1118
|
+
}
|
|
1119
|
+
:host(.-with-avatar) ::slotted([slot="icon"]) {
|
|
1120
|
+
display: none;
|
|
1121
|
+
}
|
|
1122
|
+
:host(.-with-avatar) .wrapper {
|
|
1123
|
+
padding-inline-start: var(--m3e-chip-with-avatar-padding-start, 0.25rem);
|
|
1124
|
+
}
|
|
1125
|
+
@media (forced-colors: active) {
|
|
1126
|
+
:host(:disabled) ::slotted([slot="avatar"]),
|
|
1127
|
+
:host([disabled-interactive]) ::slotted([slot="avatar"]) {
|
|
1128
|
+
color: CanvasText;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
`,
|
|
1132
|
+
];
|
|
1133
|
+
__decorate([
|
|
1134
|
+
e$1(".cell")
|
|
1135
|
+
], M3eInputChipElement.prototype, "cell", void 0);
|
|
1136
|
+
__decorate([
|
|
1137
|
+
e$1(".remove-button")
|
|
1138
|
+
], M3eInputChipElement.prototype, "removeButton", void 0);
|
|
1139
|
+
__decorate([
|
|
1140
|
+
n$1({ type: Boolean })
|
|
1141
|
+
], M3eInputChipElement.prototype, "removable", void 0);
|
|
1142
|
+
__decorate([
|
|
1143
|
+
n$1({ attribute: "remove-label" })
|
|
1144
|
+
], M3eInputChipElement.prototype, "removeLabel", void 0);
|
|
1145
|
+
M3eInputChipElement = __decorate([
|
|
1146
|
+
t$2("m3e-input-chip")
|
|
1147
|
+
], M3eInputChipElement);
|
|
1148
|
+
|
|
1149
|
+
var _M3eInputChipSetElement_instances, _M3eInputChipSetElement_inputChangeHandler, _M3eInputChipSetElement_inputKeyDownHandler, _M3eInputChipSetElement_focusHandler, _M3eInputChipSetElement_focusInHandler, _M3eInputChipSetElement_focusOutHandler, _M3eInputChipSetElement_chipRemoveHandler, _M3eInputChipSetElement_chipClickHandler, _M3eInputChipSetElement_listManager, _M3eInputChipSetElement_listKeyManager, _M3eInputChipSetElement_ignoreInputChange, _M3eInputChipSetElement_input, _M3eInputChipSetElement_tabindex, _M3eInputChipSetElement_handleKeyDown, _M3eInputChipSetElement_handleSlotChange, _M3eInputChipSetElement_handleInputSlotChange, _M3eInputChipSetElement_handleFocus, _M3eInputChipSetElement_handleFocusIn, _M3eInputChipSetElement_handleFocusOut, _M3eInputChipSetElement_handleChipRemove, _M3eInputChipSetElement_handleChipClick, _M3eInputChipSetElement_handleInputChange, _M3eInputChipSetElement_handleInputKeyDown;
|
|
1150
|
+
/**
|
|
1151
|
+
* @summary
|
|
1152
|
+
* A container that transforms user input into a cohesive set of interactive chips, supporting entry, editing, and removal of discrete values.
|
|
1153
|
+
*
|
|
1154
|
+
* @description
|
|
1155
|
+
* The `m3e-input-chip-set` component enables users to input, display, and manage a collection of discrete
|
|
1156
|
+
* values as input chips. Designed for expressive, accessible forms, it supports keyboard navigation, validation,
|
|
1157
|
+
* and seamless integration with form controls. This component is ideal for capturing user-generated tags,
|
|
1158
|
+
* keywords, or selections in a visually consistent and interactive manner.
|
|
1159
|
+
*
|
|
1160
|
+
* @example
|
|
1161
|
+
* The following example illustrates the use of the `m3e-input-chip-set` inside a `m3e-form-field`.
|
|
1162
|
+
* In this example, the `input` slot specifies the `input` element used to add input chips and the
|
|
1163
|
+
* field label's `for` attribute targets the `input` element to provide an accessible label.
|
|
1164
|
+
* ```html
|
|
1165
|
+
* <m3e-form-field>
|
|
1166
|
+
* <label slot="label" for="keywords">Keywords</label>
|
|
1167
|
+
* <m3e-input-chip-set aria-label="Enter keywords">
|
|
1168
|
+
* <input id="keywords" slot="input" placeholder="New keyword..." />
|
|
1169
|
+
* </m3e-input-chip-set>
|
|
1170
|
+
* </m3e-form-field>
|
|
1171
|
+
* ```
|
|
1172
|
+
*
|
|
1173
|
+
* @tag m3e-input-chip-set
|
|
1174
|
+
*
|
|
1175
|
+
* @slot - Renders the chips of the set.
|
|
1176
|
+
* @slot input - Renders the input element used to add new chips to the set.
|
|
1177
|
+
*
|
|
1178
|
+
* @attr disabled - Whether the element is disabled.
|
|
1179
|
+
* @attr name - The name that identifies the element when submitting the associated form.
|
|
1180
|
+
* @attr required - Whether a value is required for the element.
|
|
1181
|
+
* @attr vertical - Whether the element is oriented vertically.
|
|
1182
|
+
*
|
|
1183
|
+
* @fires change - Emitted when a chip is added to, or removed from, the set.
|
|
1184
|
+
*
|
|
1185
|
+
* @cssprop --m3e-chip-set-spacing - The spacing (gap) between chips in the set.
|
|
1186
|
+
*/
|
|
1187
|
+
let M3eInputChipSetElement = class M3eInputChipSetElement extends RequiredConstraintValidation(Required(ConstraintValidation(Dirty(Touched(FormAssociated(Disabled(AttachInternals(Role(M3eChipSetElement, "grid"))))))))) {
|
|
1188
|
+
constructor() {
|
|
1189
|
+
super(...arguments);
|
|
1190
|
+
_M3eInputChipSetElement_instances.add(this);
|
|
1191
|
+
/** @private */ _M3eInputChipSetElement_inputChangeHandler.set(this, () => __classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleInputChange).call(this));
|
|
1192
|
+
/** @private */ _M3eInputChipSetElement_inputKeyDownHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleInputKeyDown).call(this, e));
|
|
1193
|
+
/** @private */ _M3eInputChipSetElement_focusHandler.set(this, () => __classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleFocus).call(this));
|
|
1194
|
+
/** @private */ _M3eInputChipSetElement_focusInHandler.set(this, () => __classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleFocusIn).call(this));
|
|
1195
|
+
/** @private */ _M3eInputChipSetElement_focusOutHandler.set(this, () => __classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleFocusOut).call(this));
|
|
1196
|
+
/** @private */ _M3eInputChipSetElement_chipRemoveHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleChipRemove).call(this, e));
|
|
1197
|
+
/** @private */ _M3eInputChipSetElement_chipClickHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleChipClick).call(this, e));
|
|
1198
|
+
/** @private */ _M3eInputChipSetElement_listManager.set(this, new ListManager());
|
|
1199
|
+
/** @private */ _M3eInputChipSetElement_listKeyManager.set(this, new ListKeyManager()
|
|
1200
|
+
.onActiveItemChange(() => __classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").activeItem?.focus())
|
|
1201
|
+
.withHomeAndEnd()
|
|
1202
|
+
.withSkipPredicate((x) => !x.hasAttribute("tabindex")));
|
|
1203
|
+
/** @private */ _M3eInputChipSetElement_ignoreInputChange.set(this, false);
|
|
1204
|
+
/** @private */ _M3eInputChipSetElement_input.set(this, null);
|
|
1205
|
+
/** @private */ _M3eInputChipSetElement_tabindex.set(this, 0);
|
|
1206
|
+
}
|
|
1207
|
+
/** The chips of the set. */
|
|
1208
|
+
get chips() {
|
|
1209
|
+
// NOTE: query is used instead of the internal list management due to
|
|
1210
|
+
// validating required state on change to support form-field integration.
|
|
1211
|
+
return [...this.querySelectorAll("m3e-input-chip")];
|
|
1212
|
+
}
|
|
1213
|
+
/** The selected values of the set. */
|
|
1214
|
+
get value() {
|
|
1215
|
+
const values = this.chips.map((x) => x.value);
|
|
1216
|
+
return values.length == 0 ? null : values;
|
|
1217
|
+
}
|
|
1218
|
+
/** @inheritdoc @internal */
|
|
1219
|
+
get [(_M3eInputChipSetElement_inputChangeHandler = new WeakMap(), _M3eInputChipSetElement_inputKeyDownHandler = new WeakMap(), _M3eInputChipSetElement_focusHandler = new WeakMap(), _M3eInputChipSetElement_focusInHandler = new WeakMap(), _M3eInputChipSetElement_focusOutHandler = new WeakMap(), _M3eInputChipSetElement_chipRemoveHandler = new WeakMap(), _M3eInputChipSetElement_chipClickHandler = new WeakMap(), _M3eInputChipSetElement_listManager = new WeakMap(), _M3eInputChipSetElement_listKeyManager = new WeakMap(), _M3eInputChipSetElement_ignoreInputChange = new WeakMap(), _M3eInputChipSetElement_input = new WeakMap(), _M3eInputChipSetElement_tabindex = new WeakMap(), _M3eInputChipSetElement_instances = new WeakSet(), formValue)]() {
|
|
1220
|
+
const values = this.value;
|
|
1221
|
+
if (!values)
|
|
1222
|
+
return null;
|
|
1223
|
+
const data = new FormData();
|
|
1224
|
+
for (const value of values) {
|
|
1225
|
+
data.append(this.name, value);
|
|
1226
|
+
}
|
|
1227
|
+
return data;
|
|
1228
|
+
}
|
|
1229
|
+
/** @inheritdoc */
|
|
1230
|
+
get shouldLabelFloat() {
|
|
1231
|
+
return this.chips.length > 0;
|
|
1232
|
+
}
|
|
1233
|
+
/** @inheritdoc */
|
|
1234
|
+
onContainerClick() {
|
|
1235
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f")?.focus();
|
|
1236
|
+
}
|
|
1237
|
+
/** @inheritdoc */
|
|
1238
|
+
connectedCallback() {
|
|
1239
|
+
super.connectedCallback();
|
|
1240
|
+
this.closest("m3e-form-field")?.notifyControlStateChange();
|
|
1241
|
+
__classPrivateFieldSet(this, _M3eInputChipSetElement_tabindex, Number.parseInt(this.getAttribute("tabindex") ?? "0"), "f");
|
|
1242
|
+
this.addEventListener("focus", __classPrivateFieldGet(this, _M3eInputChipSetElement_focusHandler, "f"));
|
|
1243
|
+
this.addEventListener("focusin", __classPrivateFieldGet(this, _M3eInputChipSetElement_focusInHandler, "f"));
|
|
1244
|
+
this.addEventListener("focusout", __classPrivateFieldGet(this, _M3eInputChipSetElement_focusOutHandler, "f"));
|
|
1245
|
+
}
|
|
1246
|
+
/** @inheritdoc */
|
|
1247
|
+
disconnectedCallback() {
|
|
1248
|
+
super.disconnectedCallback();
|
|
1249
|
+
this.removeEventListener("focus", __classPrivateFieldGet(this, _M3eInputChipSetElement_focusHandler, "f"));
|
|
1250
|
+
this.removeEventListener("focusin", __classPrivateFieldGet(this, _M3eInputChipSetElement_focusInHandler, "f"));
|
|
1251
|
+
this.removeEventListener("focusout", __classPrivateFieldGet(this, _M3eInputChipSetElement_focusOutHandler, "f"));
|
|
1252
|
+
}
|
|
1253
|
+
/** @inheritdoc */
|
|
1254
|
+
firstUpdated(_changedProperties) {
|
|
1255
|
+
super.firstUpdated(_changedProperties);
|
|
1256
|
+
if (!this.hasAttribute("tabindex")) {
|
|
1257
|
+
this.setAttribute("tabindex", `${__classPrivateFieldGet(this, _M3eInputChipSetElement_tabindex, "f")}`);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
/** @inheritdoc */
|
|
1261
|
+
update(changedProperties) {
|
|
1262
|
+
super.update(changedProperties);
|
|
1263
|
+
if (changedProperties.has("vertical")) {
|
|
1264
|
+
this.ariaOrientation = null;
|
|
1265
|
+
}
|
|
1266
|
+
if (changedProperties.has("disabled")) {
|
|
1267
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_listManager, "f").items.forEach((x) => (x.disabled = this.disabled));
|
|
1268
|
+
if (__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f")) {
|
|
1269
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f").disabled = this.disabled;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
/** @inheritdoc */
|
|
1274
|
+
render() {
|
|
1275
|
+
return html `<slot @keydown="${__classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleKeyDown)}" @slotchange="${__classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleSlotChange)}"></slot>
|
|
1276
|
+
<span role="row">
|
|
1277
|
+
<span role="gridcell"><slot name="input" @slotchange="${__classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleInputSlotChange)}"></slot></span>
|
|
1278
|
+
</span> `;
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
_M3eInputChipSetElement_handleKeyDown = function _M3eInputChipSetElement_handleKeyDown(e) {
|
|
1282
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").onKeyDown(e);
|
|
1283
|
+
};
|
|
1284
|
+
_M3eInputChipSetElement_handleSlotChange =
|
|
1285
|
+
/** @private */
|
|
1286
|
+
async function _M3eInputChipSetElement_handleSlotChange() {
|
|
1287
|
+
const { added, removed } = __classPrivateFieldGet(this, _M3eInputChipSetElement_listManager, "f").setItems([...this.querySelectorAll("m3e-input-chip")]);
|
|
1288
|
+
for (const chip of added) {
|
|
1289
|
+
if (chip.isUpdatePending) {
|
|
1290
|
+
await chip.updateComplete;
|
|
1291
|
+
}
|
|
1292
|
+
if (this.disabled) {
|
|
1293
|
+
chip.disabled = true;
|
|
1294
|
+
}
|
|
1295
|
+
chip.addEventListener("remove", __classPrivateFieldGet(this, _M3eInputChipSetElement_chipRemoveHandler, "f"));
|
|
1296
|
+
chip.cell.addEventListener("click", __classPrivateFieldGet(this, _M3eInputChipSetElement_chipClickHandler, "f"));
|
|
1297
|
+
}
|
|
1298
|
+
removed.forEach((x) => {
|
|
1299
|
+
x.removeEventListener("remove", __classPrivateFieldGet(this, _M3eInputChipSetElement_chipRemoveHandler, "f"));
|
|
1300
|
+
x.cell.removeEventListener("click", __classPrivateFieldGet(this, _M3eInputChipSetElement_chipClickHandler, "f"));
|
|
1301
|
+
});
|
|
1302
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").setItems(__classPrivateFieldGet(this, _M3eInputChipSetElement_listManager, "f").items.flatMap((x) => (x.removeButton ? [x.cell, x.removeButton] : [x.cell])));
|
|
1303
|
+
if (!__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").activeItem) {
|
|
1304
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").updateActiveItem(__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").items.find((x) => x.hasAttribute("tabindex")));
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
_M3eInputChipSetElement_handleInputSlotChange = function _M3eInputChipSetElement_handleInputSlotChange() {
|
|
1308
|
+
const input = this.querySelector("input");
|
|
1309
|
+
if (__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f")) {
|
|
1310
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f").removeEventListener("change", __classPrivateFieldGet(this, _M3eInputChipSetElement_inputChangeHandler, "f"));
|
|
1311
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f").removeEventListener("keydown", __classPrivateFieldGet(this, _M3eInputChipSetElement_inputKeyDownHandler, "f"));
|
|
1312
|
+
}
|
|
1313
|
+
__classPrivateFieldSet(this, _M3eInputChipSetElement_input, input, "f");
|
|
1314
|
+
if (__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f")) {
|
|
1315
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f").disabled = this.disabled;
|
|
1316
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f").addEventListener("change", __classPrivateFieldGet(this, _M3eInputChipSetElement_inputChangeHandler, "f"));
|
|
1317
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f").addEventListener("keydown", __classPrivateFieldGet(this, _M3eInputChipSetElement_inputKeyDownHandler, "f"));
|
|
1318
|
+
const property = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");
|
|
1319
|
+
Object.defineProperty(input, "value", {
|
|
1320
|
+
get: () => property.get?.call(input),
|
|
1321
|
+
set: (value) => {
|
|
1322
|
+
property.set?.call(input, value);
|
|
1323
|
+
if (__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f") === input && !__classPrivateFieldGet(this, _M3eInputChipSetElement_ignoreInputChange, "f")) {
|
|
1324
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_instances, "m", _M3eInputChipSetElement_handleInputChange).call(this);
|
|
1325
|
+
}
|
|
1326
|
+
},
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
_M3eInputChipSetElement_handleFocus = function _M3eInputChipSetElement_handleFocus() {
|
|
1331
|
+
setTimeout(() => (__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").activeItem ?? __classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f"))?.focus());
|
|
1332
|
+
};
|
|
1333
|
+
_M3eInputChipSetElement_handleFocusIn = function _M3eInputChipSetElement_handleFocusIn() {
|
|
1334
|
+
this.setAttribute("tabindex", "-1");
|
|
1335
|
+
};
|
|
1336
|
+
_M3eInputChipSetElement_handleFocusOut = function _M3eInputChipSetElement_handleFocusOut() {
|
|
1337
|
+
this.setAttribute("tabindex", `${__classPrivateFieldGet(this, _M3eInputChipSetElement_tabindex, "f")}`);
|
|
1338
|
+
};
|
|
1339
|
+
_M3eInputChipSetElement_handleChipRemove = function _M3eInputChipSetElement_handleChipRemove(e) {
|
|
1340
|
+
const chip = e.target;
|
|
1341
|
+
const index = __classPrivateFieldGet(this, _M3eInputChipSetElement_listManager, "f").items.indexOf(chip);
|
|
1342
|
+
const nextChip = __classPrivateFieldGet(this, _M3eInputChipSetElement_listManager, "f").items.find((x, y) => y > index && !x.disabled && x.removable);
|
|
1343
|
+
chip.remove();
|
|
1344
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").setActiveItem(__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").items.find((x) => x === nextChip?.removeButton));
|
|
1345
|
+
if (!__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").activeItem) {
|
|
1346
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f")?.focus();
|
|
1347
|
+
}
|
|
1348
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1349
|
+
};
|
|
1350
|
+
_M3eInputChipSetElement_handleChipClick = function _M3eInputChipSetElement_handleChipClick(e) {
|
|
1351
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_listKeyManager, "f").updateActiveItem(e.composedPath().find((x) => x instanceof M3eInputChipElement)?.cell);
|
|
1352
|
+
};
|
|
1353
|
+
_M3eInputChipSetElement_handleInputChange = function _M3eInputChipSetElement_handleInputChange() {
|
|
1354
|
+
const value = __classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f")?.value;
|
|
1355
|
+
if (!value)
|
|
1356
|
+
return;
|
|
1357
|
+
setTimeout(() => {
|
|
1358
|
+
const value = __classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f")?.value;
|
|
1359
|
+
if (!value)
|
|
1360
|
+
return;
|
|
1361
|
+
const chip = document.createElement("m3e-input-chip");
|
|
1362
|
+
chip.removable = true;
|
|
1363
|
+
chip.appendChild(document.createTextNode(value));
|
|
1364
|
+
this.appendChild(chip);
|
|
1365
|
+
if (__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f")) {
|
|
1366
|
+
try {
|
|
1367
|
+
__classPrivateFieldSet(this, _M3eInputChipSetElement_ignoreInputChange, true, "f");
|
|
1368
|
+
__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f").value = "";
|
|
1369
|
+
}
|
|
1370
|
+
finally {
|
|
1371
|
+
__classPrivateFieldSet(this, _M3eInputChipSetElement_ignoreInputChange, false, "f");
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1375
|
+
});
|
|
1376
|
+
};
|
|
1377
|
+
_M3eInputChipSetElement_handleInputKeyDown = function _M3eInputChipSetElement_handleInputKeyDown(e) {
|
|
1378
|
+
if (e.key === "Backspace" && !__classPrivateFieldGet(this, _M3eInputChipSetElement_input, "f")?.value) {
|
|
1379
|
+
const item = [...__classPrivateFieldGet(this, _M3eInputChipSetElement_listManager, "f").items]
|
|
1380
|
+
.reverse()
|
|
1381
|
+
.find((x) => !x.disabled && !x.disabledInteractive && x.removable);
|
|
1382
|
+
if (item) {
|
|
1383
|
+
item.dispatchEvent(new Event("remove"));
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
/** The styles of the element. */
|
|
1388
|
+
M3eInputChipSetElement.styles = [
|
|
1389
|
+
M3eChipSetElement.styles,
|
|
1390
|
+
css `
|
|
1391
|
+
::slotted([slot="input"]) {
|
|
1392
|
+
outline: unset;
|
|
1393
|
+
border: unset;
|
|
1394
|
+
background-color: transparent;
|
|
1395
|
+
box-shadow: none;
|
|
1396
|
+
font-family: inherit;
|
|
1397
|
+
font-size: inherit;
|
|
1398
|
+
line-height: initial;
|
|
1399
|
+
letter-spacing: inherit;
|
|
1400
|
+
color: var(--_form-field-input-color, inherit);
|
|
1401
|
+
flex: 1 1 auto;
|
|
1402
|
+
min-width: 0;
|
|
1403
|
+
padding: unset;
|
|
1404
|
+
}
|
|
1405
|
+
::slotted(m3e-input-chip) {
|
|
1406
|
+
min-width: 0;
|
|
1407
|
+
}
|
|
1408
|
+
::slotted([slot="input"])::placeholder {
|
|
1409
|
+
user-select: none;
|
|
1410
|
+
color: currentColor;
|
|
1411
|
+
transition: opacity ${DesignToken.motion.duration.extraLong1};
|
|
1412
|
+
}
|
|
1413
|
+
:host(:not(:focus-within)) ::slotted([slot="input"])::placeholder {
|
|
1414
|
+
opacity: 0;
|
|
1415
|
+
transition: 0s;
|
|
1416
|
+
}
|
|
1417
|
+
:host(:hover) ::slotted([slot="input"])::placeholder {
|
|
1418
|
+
transition: 0s;
|
|
1419
|
+
}
|
|
1420
|
+
span[role="row"],
|
|
1421
|
+
span[role="gridcell"] {
|
|
1422
|
+
display: contents;
|
|
1423
|
+
}
|
|
1424
|
+
@media (prefers-reduced-motion) {
|
|
1425
|
+
::slotted([slot="input"])::placeholder {
|
|
1426
|
+
transition: none !important;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
`,
|
|
1430
|
+
];
|
|
1431
|
+
M3eInputChipSetElement = __decorate([
|
|
1432
|
+
t$2("m3e-input-chip-set")
|
|
1433
|
+
], M3eInputChipSetElement);
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* @summary
|
|
1437
|
+
* A chip used to help narrow a user's intent by presenting dynamically generated suggestions, such as
|
|
1438
|
+
* suggested responses or search filters.
|
|
1439
|
+
*
|
|
1440
|
+
* @description
|
|
1441
|
+
* The `m3e-suggestion-chip` component presents a suggestion chip, offering users contextually relevant
|
|
1442
|
+
* actions or responses. It is designed for dynamic suggestion scenarios, such as search filters or
|
|
1443
|
+
* smart replies, and supports accessibility, keyboard interaction, and expressive state styling in line
|
|
1444
|
+
* with Material 3 guidelines. Appearance variants include `elevated` and `outlined`, enabling visual
|
|
1445
|
+
* differentiation and contextual emphasis.
|
|
1446
|
+
*
|
|
1447
|
+
* @example
|
|
1448
|
+
* The following example illustrates use of the `m3e-suggestion-chip`. In this example, multiple chips are nested inside
|
|
1449
|
+
* a `m3e-chip-set` container to create a cohesive set of chips. The container is given the ARIA `role="group"` to convey
|
|
1450
|
+
* to assistive technologies that the chips are part of a related set of element.
|
|
1451
|
+
* ```html
|
|
1452
|
+
* <m3e-chip-set role="group" aria-label="Suggested replies">
|
|
1453
|
+
* <m3e-suggestion-chip>Sounds good!</m3e-suggestion-chip>
|
|
1454
|
+
* <m3e-suggestion-chip>Can you clarify?</m3e-suggestion-chip>
|
|
1455
|
+
* <m3e-suggestion-chip>Let's do it.</m3e-suggestion-chip>
|
|
1456
|
+
* <m3e-suggestion-chip>Maybe later.</m3e-suggestion-chip>
|
|
1457
|
+
* </m3e-chip-set>
|
|
1458
|
+
* ```
|
|
1459
|
+
*
|
|
1460
|
+
* @tag m3e-suggestion-chip
|
|
1461
|
+
*
|
|
1462
|
+
* @slot - Renders the label of the chip.
|
|
1463
|
+
* @slot icon - Renders an icon before the chip's label.
|
|
1464
|
+
*
|
|
1465
|
+
* @attr disabled - A value indicating whether the element is disabled.
|
|
1466
|
+
* @attr disabled-interactive - A value indicating whether the element is disabled and interactive.
|
|
1467
|
+
* @attr download - A value indicating whether the `target` of the link button will be downloaded, optionally specifying the new name of the file.
|
|
1468
|
+
* @attr href - The URL to which the link button points.
|
|
1469
|
+
* @attr name - The name of the element, submitted as a pair with the element's `value` as part of form data, when the element is used to submit a form.
|
|
1470
|
+
* @attr rel - The relationship between the `target` of the link button and the document.
|
|
1471
|
+
* @attr target - The target of the link button.
|
|
1472
|
+
* @attr type - The type of the element.
|
|
1473
|
+
* @attr value - A string representing the value of the chip.
|
|
1474
|
+
* @attr variant - The appearance variant of the chip.
|
|
1475
|
+
*
|
|
1476
|
+
* @cssprop --m3e-chip-container-shape - Border radius of the chip container.
|
|
1477
|
+
* @cssprop --m3e-chip-container-height - Base height of the chip container before density adjustment.
|
|
1478
|
+
* @cssprop --m3e-chip-label-text-font-size - Font size of the chip label text.
|
|
1479
|
+
* @cssprop --m3e-chip-label-text-font-weight - Font weight of the chip label text.
|
|
1480
|
+
* @cssprop --m3e-chip-label-text-line-height - Line height of the chip label text.
|
|
1481
|
+
* @cssprop --m3e-chip-label-text-tracking - Letter spacing of the chip label text.
|
|
1482
|
+
* @cssprop --m3e-chip-label-text-color - Label text color in default state.
|
|
1483
|
+
* @cssprop --m3e-chip-icon-color - Icon color in default state.
|
|
1484
|
+
* @cssprop --m3e-chip-icon-size - Font size of leading/trailing icons.
|
|
1485
|
+
* @cssprop --m3e-chip-spacing - Horizontal gap between chip content elements.
|
|
1486
|
+
* @cssprop --m3e-chip-padding-start - Default start padding when no icon is present.
|
|
1487
|
+
* @cssprop --m3e-chip-padding-end - Default end padding when no trailing icon is present.
|
|
1488
|
+
* @cssprop --m3e-chip-with-icon-padding-start - Start padding when leading icon is present.
|
|
1489
|
+
* @cssprop --m3e-chip-with-icon-padding-end - End padding when trailing icon is present.
|
|
1490
|
+
* @cssprop --m3e-chip-disabled-label-text-color - Base color for disabled label text.
|
|
1491
|
+
* @cssprop --m3e-chip-disabled-label-text-opacity - Opacity applied to disabled label text.
|
|
1492
|
+
* @cssprop --m3e-chip-disabled-icon-color - Base color for disabled icons.
|
|
1493
|
+
* @cssprop --m3e-chip-disabled-icon-opacity - Opacity applied to disabled icons.
|
|
1494
|
+
* @cssprop --m3e-elevated-chip-container-color - Background color for elevated variant.
|
|
1495
|
+
* @cssprop --m3e-elevated-chip-elevation - Elevation level for elevated variant.
|
|
1496
|
+
* @cssprop --m3e-elevated-chip-hover-elevation - Elevation level on hover.
|
|
1497
|
+
* @cssprop --m3e-elevated-chip-disabled-container-color - Background color for disabled elevated variant.
|
|
1498
|
+
* @cssprop --m3e-elevated-chip-disabled-container-opacity - Opacity applied to disabled elevated background.
|
|
1499
|
+
* @cssprop --m3e-elevated-chip-disabled-elevation - Elevation level for disabled elevated variant.
|
|
1500
|
+
* @cssprop --m3e-outlined-chip-outline-thickness - Outline thickness for outlined variant.
|
|
1501
|
+
* @cssprop --m3e-outlined-chip-outline-color - Outline color for outlined variant.
|
|
1502
|
+
* @cssprop --m3e-outlined-chip-disabled-outline-color - Outline color for disabled outlined variant.
|
|
1503
|
+
* @cssprop --m3e-outlined-chip-disabled-outline-opacity - Opacity applied to disabled outline.
|
|
1504
|
+
*/
|
|
1505
|
+
let M3eSuggestionChipElement = class M3eSuggestionChipElement extends FormSubmitter(AttachInternals(LinkButton(KeyboardClick(Focusable(DisabledInteractive(Disabled(Role(M3eChipElement, "button")))))), true)) {
|
|
1506
|
+
/** @internal @inheritdoc */
|
|
1507
|
+
_renderTrailingIcon() {
|
|
1508
|
+
return nothing;
|
|
1509
|
+
}
|
|
1510
|
+
};
|
|
1511
|
+
M3eSuggestionChipElement = __decorate([
|
|
1512
|
+
t$2("m3e-suggestion-chip")
|
|
1513
|
+
], M3eSuggestionChipElement);
|
|
1514
|
+
|
|
1515
|
+
export { M3eAssistChipElement, M3eChipElement, M3eChipSetElement, M3eFilterChipElement, M3eFilterChipSetElement, M3eInputChipElement, M3eInputChipSetElement, M3eSuggestionChipElement };
|
|
1516
|
+
//# sourceMappingURL=index.js.map
|