@m3e/fab-menu 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +641 -520
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +7 -238
- package/dist/index.min.js.map +1 -1
- package/dist/src/FabMenuElement.d.ts.map +1 -1
- package/package.json +3 -17
package/dist/index.min.js
CHANGED
|
@@ -3,269 +3,38 @@
|
|
|
3
3
|
* Copyright (c) 2025 matraic
|
|
4
4
|
* See LICENSE file in the project root for full license text.
|
|
5
5
|
*/
|
|
6
|
-
import{LitElement as
|
|
6
|
+
import{LitElement as t,html as e,unsafeCSS as i,css as o}from"lit";import{KeyboardClick as s,LinkButton as r,Disabled as a,AttachInternals as n,Role as l,renderPseudoLink as c,DesignToken as h,ScrollController as d,HtmlFor as p}from"@m3e/core";import{RovingTabIndexManager as f,addAriaReferencedId as m,removeAriaReferencedId as u}from"@m3e/core/a11y";import{M3eDirectionality as b}from"@m3e/core/bidi";import{positionAnchor as y}from"@m3e/core/anchoring";function v(t,e,i,o){var s,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,o);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(r<3?s(a):r>3?s(e,i,a):s(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function g(t,e,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(t):o?o.value:e.get(t)}function w(t,e,i,o,s){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?s.call(t,i):s?s.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
11
|
*/
|
|
12
|
-
const E=
|
|
12
|
+
const E=t=>(e,i)=>{void 0!==i?i.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)},$=globalThis,_=$.ShadowRoot&&(void 0===$.ShadyCSS||$.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,S=Symbol(),k=new WeakMap;
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2019 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
-
*/let P=class{constructor(e,
|
|
17
|
+
*/let P=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==S)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(_&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=k.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&k.set(e,t))}return t}toString(){return this.cssText}};const C=(t,e)=>{if(_)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),o=$.litNonce;void 0!==o&&e.setAttribute("nonce",o),e.textContent=i.cssText,t.appendChild(e)}},x=_?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new P("string"==typeof t?t:t+"",void 0,S))(e)})(t):t,{is:U,defineProperty:O,getOwnPropertyDescriptor:M,getOwnPropertyNames:A,getOwnPropertySymbols:T,getPrototypeOf:L}=Object,R=globalThis,j=R.trustedTypes,z=j?j.emptyScript:"",W=R.reactiveElementPolyfillSupport,q=(t,e)=>t,D={toAttribute(t,e){switch(e){case Boolean:t=t?z:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){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}},I=(t,e)=>!U(t,e),N={attribute:!0,type:String,converter:D,reflect:!1,useDefault:!1,hasChanged:I};
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/Symbol.metadata??=Symbol("metadata"),R.litPropertyMetadata??=new WeakMap;class H extends HTMLElement{static addInitializer(
|
|
22
|
+
*/Symbol.metadata??=Symbol("metadata"),R.litPropertyMetadata??=new WeakMap;class H 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,e=N){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),o=this.getPropertyDescriptor(t,i,e);void 0!==o&&O(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){const{get:o,set:s}=M(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:o,set(e){const r=o?.call(this);s?.call(this,e),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??N}static _$Ei(){if(this.hasOwnProperty(q("elementProperties")))return;const t=L(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(q("properties"))){const t=this.properties,e=[...A(t),...T(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(x(t))}else void 0!==t&&e.push(x(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,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,e=this.constructor.elementProperties;for(const i of e.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 C(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){const i=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,i);if(void 0!==o&&!0===i.reflect){const s=(void 0!==i.converter?.toAttribute?i.converter:D).toAttribute(e,i.type);this._$Em=t,null==s?this.removeAttribute(o):this.setAttribute(o,s),this._$Em=null}}_$AK(t,e){const i=this.constructor,o=i._$Eh.get(t);if(void 0!==o&&this._$Em!==o){const t=i.getPropertyOptions(o),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:D;this._$Em=o;const r=s.fromAttribute(e,t.type);this[o]=r??this._$Ej?.get(o)??r,this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){const o=this.constructor,s=this[t];if(i??=o.getPropertyOptions(t),!((i.hasChanged??I)(s,e)||i.useDefault&&i.reflect&&s===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:o,wrapped:s},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??e??this[t]),!0!==s||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===o&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;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,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t){const{wrapped:t}=i,o=this[e];!0!==t||this._$AL.has(e)||void 0===o||this.C(e,void 0,i,o)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}}H.elementStyles=[],H.shadowRootOptions={mode:"open"},H[q("elementProperties")]=new Map,H[q("finalized")]=new Map,W?.({ReactiveElement:H}),(R.reactiveElementVersions??=[]).push("2.1.1");
|
|
23
23
|
/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
27
|
*/
|
|
28
|
-
const K={attribute:!0,type:String,converter:D,reflect:!1,hasChanged:I},X=(
|
|
28
|
+
const K={attribute:!0,type:String,converter:D,reflect:!1,hasChanged:I},X=(t=K,e,i)=>{const{kind:o,metadata:s}=i;let r=globalThis.litPropertyMetadata.get(s);if(void 0===r&&globalThis.litPropertyMetadata.set(s,r=new Map),"setter"===o&&((t=Object.create(t)).wrapped=!0),r.set(i.name,t),"accessor"===o){const{name:o}=i;return{set(i){const s=e.get.call(this);e.set.call(this,i),this.requestUpdate(o,s,t)},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===o){const{name:o}=i;return function(i){const s=this[o];e.call(this,i),this.requestUpdate(o,s,t)}}throw Error("Unsupported decorator location: "+o)};
|
|
29
29
|
/**
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2017 Google LLC
|
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
33
|
*/
|
|
34
|
-
function B(e,t){return(t,i,o)=>((e,t,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,i),i))(t,i,{get(){return(t=>t.renderRoot?.querySelector(e)??null)(this)}})}var J,V,F;let G=class extends(s(r(a(n(l(e,"menuitem"),!0))))){constructor(){super(...arguments),J.add(this),V.set(this,e=>g(this,J,"m",F).call(this,e))}get menu(){return this.closest("m3e-fab-menu")}connectedCallback(){super.connectedCallback(),this.addEventListener("click",g(this,V,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",g(this,V,"f"))}firstUpdated(e){super.firstUpdated(e),[this._elevation,this._focusRing,this._stateLayer,this._ripple].forEach(e=>e?.attach(this))}render(){return t`<div class="base">
|
|
35
|
-
<m3e-elevation class="elevation" ?disabled="${this.disabled}"></m3e-elevation>
|
|
36
|
-
<m3e-state-layer class="state-layer" ?disabled="${this.disabled}"></m3e-state-layer>
|
|
37
|
-
<m3e-focus-ring class="focus-ring" ?disabled="${this.disabled}"></m3e-focus-ring>
|
|
38
|
-
<m3e-ripple class="ripple" ?disabled="${this.disabled}"></m3e-ripple>
|
|
39
|
-
<div class="touch" aria-hidden="true"></div>
|
|
40
|
-
${this[c]()}
|
|
41
|
-
<div class="wrapper">
|
|
42
|
-
<slot class="icon" name="icon" aria-hidden="true"></slot>
|
|
43
|
-
<div class="label"><slot></slot></div>
|
|
44
|
-
</div>
|
|
45
|
-
</div>`}};var Q,Y,Z,ee,te,ie,oe,se,re,ae,ne,le,ce,he;V=new WeakMap,J=new WeakSet,F=function(e){e.defaultPrevented||this.menu?.hide(!0)},G.styles=o`
|
|
46
|
-
:host {
|
|
47
|
-
display: inline-block;
|
|
48
|
-
outline: none;
|
|
49
|
-
user-select: none;
|
|
50
|
-
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
51
|
-
}
|
|
52
|
-
.base {
|
|
53
|
-
box-sizing: border-box;
|
|
54
|
-
vertical-align: middle;
|
|
55
|
-
display: inline-flex;
|
|
56
|
-
align-items: center;
|
|
57
|
-
justify-content: center;
|
|
58
|
-
position: relative;
|
|
59
|
-
width: 100%;
|
|
60
|
-
transition: ${i(`background-color ${h.motion.duration.short4} ${h.motion.easing.standard}`)};
|
|
61
|
-
height: var(--m3e-fab-menu-item-height, 3.5rem);
|
|
62
|
-
font-size: var(--m3e-fab-menu-item-font-size, ${h.typescale.standard.label.large.fontSize});
|
|
63
|
-
font-weight: var(--m3e-fab-menu-item-font-weight, ${h.typescale.standard.label.large.fontWeight});
|
|
64
|
-
line-height: var(--m3e-fab-menu-item-line-height, ${h.typescale.standard.label.large.lineHeight});
|
|
65
|
-
letter-spacing: var(--m3e-fab-menu-item-tracking, ${h.typescale.standard.label.large.tracking});
|
|
66
|
-
border-radius: var(--m3e-fab-menu-item-shape, ${h.shape.corner.full});
|
|
67
|
-
}
|
|
68
|
-
:host(:not(:disabled)) .label,
|
|
69
|
-
:host(:not(:disabled)) .icon {
|
|
70
|
-
color: var(--_fab-menu-item-color);
|
|
71
|
-
}
|
|
72
|
-
:host(:not(:disabled)) .base {
|
|
73
|
-
background-color: var(--_fab-menu-item-container-color);
|
|
74
|
-
--m3e-state-layer-hover-color: var(--_fab-menu-background-hover-color);
|
|
75
|
-
--m3e-state-layer-focus-color: var(--_fab-menu-background-focus-color);
|
|
76
|
-
--m3e-ripple-color: var(--_fab-menu-ripple-color);
|
|
77
|
-
}
|
|
78
|
-
:host(:disabled) .base {
|
|
79
|
-
background-color: color-mix(
|
|
80
|
-
in srgb,
|
|
81
|
-
var(--m3e-fab-menu-item-disabled-container-color, ${h.color.onSurface})
|
|
82
|
-
var(--m3e-fab-menu-item-disabled-container-opacity, 10%),
|
|
83
|
-
transparent
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
:host(:disabled) .label,
|
|
87
|
-
:host(:disabled) .icon {
|
|
88
|
-
color: color-mix(
|
|
89
|
-
in srgb,
|
|
90
|
-
var(--m3e-fab-menu-item-disabled-color, ${h.color.onSurface})
|
|
91
|
-
var(--m3e-fab-menu-item-disabled-opacity, 38%),
|
|
92
|
-
transparent
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
.touch {
|
|
96
|
-
position: absolute;
|
|
97
|
-
height: 3rem;
|
|
98
|
-
left: 0;
|
|
99
|
-
right: 0;
|
|
100
|
-
}
|
|
101
|
-
.wrapper {
|
|
102
|
-
width: 100%;
|
|
103
|
-
overflow: hidden;
|
|
104
|
-
display: inline-flex;
|
|
105
|
-
align-items: center;
|
|
106
|
-
padding-inline-start: var(--m3e-fab-menu-item-leading-space, 1.5rem);
|
|
107
|
-
padding-inline-end: var(--m3e-fab-menu-item-trailing-space, 1.5rem);
|
|
108
|
-
column-gap: var(--m3e-fab-menu-item-spacing, 0.5rem);
|
|
109
|
-
}
|
|
110
|
-
.label {
|
|
111
|
-
justify-self: center;
|
|
112
|
-
flex: 1 1 auto;
|
|
113
|
-
text-align: center;
|
|
114
|
-
white-space: nowrap;
|
|
115
|
-
overflow: hidden;
|
|
116
|
-
text-overflow: ellipsis;
|
|
117
|
-
transition: ${i(`color ${h.motion.duration.short4} ${h.motion.easing.standard}`)};
|
|
118
|
-
}
|
|
119
|
-
.icon {
|
|
120
|
-
font-size: var(--m3e-fab-menu-item-icon-size, 1.5rem);
|
|
121
|
-
transition: ${i(`color ${h.motion.duration.short4} ${h.motion.easing.standard}`)};
|
|
122
|
-
}
|
|
123
|
-
:host(:not(:disabled)) {
|
|
124
|
-
cursor: pointer;
|
|
125
|
-
}
|
|
126
|
-
::slotted([slot="icon"]) {
|
|
127
|
-
font-size: inherit !important;
|
|
128
|
-
flex: none;
|
|
129
|
-
}
|
|
130
|
-
::slotted(svg[slot="icon"]) {
|
|
131
|
-
width: 1em;
|
|
132
|
-
height: 1em;
|
|
133
|
-
}
|
|
134
|
-
a {
|
|
135
|
-
all: unset;
|
|
136
|
-
display: block;
|
|
137
|
-
position: absolute;
|
|
138
|
-
top: 0px;
|
|
139
|
-
left: 0px;
|
|
140
|
-
right: 0px;
|
|
141
|
-
bottom: 0px;
|
|
142
|
-
z-index: 1;
|
|
143
|
-
}
|
|
144
|
-
@media (prefers-reduced-motion) {
|
|
145
|
-
.base,
|
|
146
|
-
.label,
|
|
147
|
-
.icon {
|
|
148
|
-
transition: none;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
@media (forced-colors: active) {
|
|
152
|
-
.base,
|
|
153
|
-
.label,
|
|
154
|
-
.icon {
|
|
155
|
-
transition: none;
|
|
156
|
-
}
|
|
157
|
-
:host(:not(:disabled)) .base {
|
|
158
|
-
background-color: Menu;
|
|
159
|
-
}
|
|
160
|
-
:host(:not(:disabled)) .label,
|
|
161
|
-
:host(:not(:disabled)) .icon {
|
|
162
|
-
color: MenuText;
|
|
163
|
-
}
|
|
164
|
-
:host(:disabled) .label,
|
|
165
|
-
:host(:disabled) .icon {
|
|
166
|
-
color: GrayText;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
`,y([B(".elevation")],G.prototype,"_elevation",void 0),y([B(".focus-ring")],G.prototype,"_focusRing",void 0),y([B(".state-layer")],G.prototype,"_stateLayer",void 0),y([B(".ripple")],G.prototype,"_ripple",void 0),G=y([E("m3e-fab-menu-item")],G);let de=class extends(l(e,"menu")){constructor(){super(...arguments),Q.add(this),Y.set(this,void 0),Z.set(this,void 0),ee.set(this,void 0),te.set(this,(new f).withWrap().withHomeAndEnd().withVerticalOrientation()),ie.set(this,e=>g(this,Q,"m",ne).call(this,e)),oe.set(this,e=>g(this,Q,"m",le).call(this,e)),se.set(this,new d(this,{target:null,callback:()=>this.hide()})),re.set(this,e=>{"closed"===e.newState?(g(this,ee,"f")?.call(this),w(this,ee,void 0,"f")):setTimeout(()=>{g(this,te,"f").setActiveItem(g(this,te,"f").items.find(e=>!e.disabled))},40)}),this.variant="primary"}get isOpen(){return void 0!==g(this,Z,"f")}async show(e){g(this,Z,"f")&&g(this,Z,"f")!==e&&this.hide(),g(this,ee,"f")?.call(this),w(this,ee,await v(this,e,{position:"ltr"===b.current?"top-end":"top-start",inline:!0,shift:!0,flip:!0,offset:8},(e,t,i)=>{this.classList.toggle("-right",i.includes("end")),this.classList.toggle("-left",i.includes("start")),this.style.left=`${e}px`,this.style.top=`${t}px`}),"f"),this.showPopover(),w(this,Z,e,"f"),g(this,Z,"f").ariaExpanded="true",g(this,se,"f").observe(g(this,Z,"f")),g(this,Q,"m",ce).call(this)}hide(e=!1){g(this,ee,"f")?.call(this),w(this,ee,void 0,"f"),g(this,Z,"f")&&(g(this,Z,"f").ariaExpanded="false",e&&g(this,Z,"f").focus(),g(this,Q,"m",he).call(this),g(this,se,"f").unobserve(g(this,Z,"f")),w(this,Z,void 0,"f")),this.hidePopover()}async toggle(e){g(this,Z,"f")?this.hide():await this.show(e)}connectedCallback(){super.connectedCallback(),this.tabIndex=-1,this.setAttribute("popover","manual"),this.classList.add("-no-animate"),this.addEventListener("keydown",g(this,ie,"f")),this.addEventListener("toggle",g(this,re,"f")),document.addEventListener("click",g(this,oe,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",g(this,ie,"f")),this.removeEventListener("toggle",g(this,re,"f")),document.removeEventListener("click",g(this,oe,"f"))}firstUpdated(e){super.firstUpdated(e),requestAnimationFrame(()=>this.classList.remove("-no-animate"))}render(){return t`<div class="base"><slot @slotchange="${g(this,Q,"m",ae)}"></slot></div>`}};var pe,fe,me;Y=new WeakMap,Z=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,oe=new WeakMap,se=new WeakMap,re=new WeakMap,Q=new WeakSet,ae=function(){const{added:e}=g(this,te,"f").setItems([...this.querySelectorAll("m3e-fab-menu-item")]);g(this,te,"f").activeItem||g(this,te,"f").updateActiveItem(e.find(e=>!e.disabled))},ne=function(e){switch(e.key){case"Tab":this.hide();break;case"Escape":e.shiftKey||e.ctrlKey||this.hide(!0);break;default:g(this,te,"f").onKeyDown(e)}},le=function(e){e.composedPath().some(e=>e instanceof G||e===g(this,Z,"f"))||this.hide()},ce=function(){const e=g(this,Z,"f")?.closest("m3e-fab");e&&(w(this,Y,e.tabIndex,"f"),e.addEventListener("keydown",g(this,ie,"f")),g(this,te,"f").setItems([...g(this,te,"f").items,e]))},he=function(){const e=g(this,Z,"f")?.closest("m3e-fab");e&&(void 0!==g(this,Y,"f")&&(e.tabIndex=g(this,Y,"f")),e.removeEventListener("keydown",g(this,ie,"f")),g(this,te,"f").setItems([...g(this,te,"f").items.filter(t=>t!==e)]))},de.styles=o`
|
|
170
|
-
:host {
|
|
171
|
-
position: absolute;
|
|
172
|
-
flex-direction: column;
|
|
173
|
-
row-gap: var(--m3e-fab-menu-spacing, 0.25rem);
|
|
174
|
-
padding: unset;
|
|
175
|
-
margin: unset;
|
|
176
|
-
border: unset;
|
|
177
|
-
overflow: visible;
|
|
178
|
-
max-width: var(--m3e-fab-menu-max-width, 17.5rem);
|
|
179
|
-
opacity: 0;
|
|
180
|
-
background-color: transparent;
|
|
181
|
-
display: none;
|
|
182
|
-
}
|
|
183
|
-
:host(:not(.-no-animate)) {
|
|
184
|
-
transition: ${i(`opacity ${h.motion.spring.fastEffects}, \n transform ${h.motion.spring.fastSpatial},\n overlay ${h.motion.spring.fastEffects} allow-discrete,\n display ${h.motion.spring.fastEffects} allow-discrete`)};
|
|
185
|
-
}
|
|
186
|
-
.base {
|
|
187
|
-
display: contents;
|
|
188
|
-
}
|
|
189
|
-
:host([variant="primary"]) .base {
|
|
190
|
-
--_fab-menu-item-color: var(--m3e-primary-fab-color, ${h.color.onPrimaryContainer});
|
|
191
|
-
--_fab-menu-item-container-color: var(--m3e-primary-fab-container-color, ${h.color.primaryContainer});
|
|
192
|
-
--_fab-menu-background-hover-color: var(--m3e-primary-fab-hover-color, ${h.color.onPrimaryContainer});
|
|
193
|
-
--_fab-menu-background-focus-color: var(--m3e-primary-fab-focus-color, ${h.color.onPrimaryContainer});
|
|
194
|
-
--_fab-menu-ripple-color: var(--m3e-primary-fab-ripple-color, ${h.color.onPrimaryContainer});
|
|
195
|
-
}
|
|
196
|
-
:host([variant="secondary"]) .base {
|
|
197
|
-
--_fab-menu-item-color: var(--m3e-secondary-fab-color, ${h.color.onSecondaryContainer});
|
|
198
|
-
--_fab-menu-item-container-color: var(
|
|
199
|
-
--m3e-secondary-fab-container-color,
|
|
200
|
-
${h.color.secondaryContainer}
|
|
201
|
-
);
|
|
202
|
-
--_fab-menu-background-hover-color: var(
|
|
203
|
-
--m3e-secondary-fab-hover-color,
|
|
204
|
-
${h.color.onSecondaryContainer}
|
|
205
|
-
);
|
|
206
|
-
--_fab-menu-background-focus-color: var(
|
|
207
|
-
--m3e-secondary-fab-focus-color,
|
|
208
|
-
${h.color.onSecondaryContainer}
|
|
209
|
-
);
|
|
210
|
-
--_fab-menu-ripple-color: var(--m3e-secondary-fab-ripple-color, ${h.color.onSecondaryContainer});
|
|
211
|
-
}
|
|
212
|
-
:host([variant="tertiary"]) .base {
|
|
213
|
-
--_fab-menu-item-color: var(--m3e-tertiary-fab-color, ${h.color.onTertiaryContainer});
|
|
214
|
-
--_fab-menu-item-container-color: var(--m3e-tertiary-fab-container-color, ${h.color.tertiaryContainer});
|
|
215
|
-
--_fab-menu-background-hover-color: var(--m3e-tertiary-fab-hover-color, ${h.color.onTertiaryContainer});
|
|
216
|
-
--_fab-menu-background-focus-color: var(--m3e-tertiary-fab-focus-color, ${h.color.onTertiaryContainer});
|
|
217
|
-
--_fab-menu-ripple-color: var(--m3e-tertiary-fab-ripple-color, ${h.color.onTertiaryContainer});
|
|
218
|
-
}
|
|
219
|
-
:host {
|
|
220
|
-
transform: scaleX(0.8);
|
|
221
|
-
}
|
|
222
|
-
:host(.-left) {
|
|
223
|
-
align-items: flex-start;
|
|
224
|
-
transform-origin: left;
|
|
225
|
-
}
|
|
226
|
-
:host(.-right) {
|
|
227
|
-
align-items: flex-end;
|
|
228
|
-
transform-origin: right;
|
|
229
|
-
}
|
|
230
|
-
:host(:popover-open) {
|
|
231
|
-
transform: scaleX(1);
|
|
232
|
-
display: inline-flex;
|
|
233
|
-
opacity: 1;
|
|
234
|
-
}
|
|
235
|
-
:host::backdrop {
|
|
236
|
-
background-color: transparent;
|
|
237
|
-
}
|
|
238
|
-
@starting-style {
|
|
239
|
-
:host(:popover-open) {
|
|
240
|
-
opacity: 0;
|
|
241
|
-
}
|
|
242
|
-
:host(:popover-open) {
|
|
243
|
-
transform: scaleX(0.8);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
@media (prefers-reduced-motion) {
|
|
247
|
-
:host(:not(.-no-animate)) {
|
|
248
|
-
transition: none;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
@media (forced-colors: active) {
|
|
252
|
-
:host {
|
|
253
|
-
border-radius: ${h.shape.corner.medium};
|
|
254
|
-
border: 1px solid MenuText;
|
|
255
|
-
background-color: Menu;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
`,y([function(e){return(t,i)=>"object"==typeof i?X(e,t,i):((e,t,i)=>{const o=t.hasOwnProperty(i);return t.constructor.createProperty(i,e),o?Object.getOwnPropertyDescriptor(t,i):void 0})(e,t,i)}
|
|
34
|
+
function B(t,e){return(e,i,o)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,i),i))(e,i,{get(){return(e=>e.renderRoot?.querySelector(t)??null)(this)}})}var J,V,F;let G=class extends(s(r(a(n(l(t,"menuitem"),!0))))){constructor(){super(...arguments),J.add(this),V.set(this,t=>g(this,J,"m",F).call(this,t))}get menu(){return this.closest("m3e-fab-menu")}connectedCallback(){super.connectedCallback(),this.addEventListener("click",g(this,V,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",g(this,V,"f"))}firstUpdated(t){super.firstUpdated(t),[this._elevation,this._focusRing,this._stateLayer,this._ripple].forEach(t=>t?.attach(this))}render(){return e`<div class="base"><m3e-elevation class="elevation" ?disabled="${this.disabled}"></m3e-elevation><m3e-state-layer class="state-layer" ?disabled="${this.disabled}"></m3e-state-layer><m3e-focus-ring class="focus-ring" ?disabled="${this.disabled}"></m3e-focus-ring><m3e-ripple class="ripple" ?disabled="${this.disabled}"></m3e-ripple><div class="touch" aria-hidden="true"></div>${this[c]()}<div class="wrapper"><slot class="icon" name="icon" aria-hidden="true"></slot><div class="label"><slot></slot></div></div></div>`}};var Q,Y,Z,tt,et,it,ot,st,rt,at,nt,lt,ct,ht;V=new WeakMap,J=new WeakSet,F=function(t){t.defaultPrevented||this.menu?.hide(!0)},G.styles=o`:host { display: inline-block; outline: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .base { box-sizing: border-box; vertical-align: middle; display: inline-flex; align-items: center; justify-content: center; position: relative; width: 100%; transition: ${i(`background-color ${h.motion.duration.short4} ${h.motion.easing.standard}`)}; height: var(--m3e-fab-menu-item-height, 3.5rem); font-size: var(--m3e-fab-menu-item-font-size, ${h.typescale.standard.label.large.fontSize}); font-weight: var(--m3e-fab-menu-item-font-weight, ${h.typescale.standard.label.large.fontWeight}); line-height: var(--m3e-fab-menu-item-line-height, ${h.typescale.standard.label.large.lineHeight}); letter-spacing: var(--m3e-fab-menu-item-tracking, ${h.typescale.standard.label.large.tracking}); border-radius: var(--m3e-fab-menu-item-shape, ${h.shape.corner.full}); } :host(:not(:disabled)) .label, :host(:not(:disabled)) .icon { color: var(--_fab-menu-item-color); } :host(:not(:disabled)) .base { background-color: var(--_fab-menu-item-container-color); --m3e-state-layer-hover-color: var(--_fab-menu-background-hover-color); --m3e-state-layer-focus-color: var(--_fab-menu-background-focus-color); --m3e-ripple-color: var(--_fab-menu-ripple-color); } :host(:disabled) .base { background-color: color-mix( in srgb, var(--m3e-fab-menu-item-disabled-container-color, ${h.color.onSurface}) var(--m3e-fab-menu-item-disabled-container-opacity, 10%), transparent ); } :host(:disabled) .label, :host(:disabled) .icon { color: color-mix( in srgb, var(--m3e-fab-menu-item-disabled-color, ${h.color.onSurface}) var(--m3e-fab-menu-item-disabled-opacity, 38%), transparent ); } .touch { position: absolute; height: 3rem; left: 0; right: 0; } .wrapper { width: 100%; overflow: hidden; display: inline-flex; align-items: center; padding-inline-start: var(--m3e-fab-menu-item-leading-space, 1.5rem); padding-inline-end: var(--m3e-fab-menu-item-trailing-space, 1.5rem); column-gap: var(--m3e-fab-menu-item-spacing, 0.5rem); } .label { justify-self: center; flex: 1 1 auto; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: ${i(`color ${h.motion.duration.short4} ${h.motion.easing.standard}`)}; } .icon { font-size: var(--m3e-fab-menu-item-icon-size, 1.5rem); transition: ${i(`color ${h.motion.duration.short4} ${h.motion.easing.standard}`)}; } :host(:not(:disabled)) { cursor: pointer; } ::slotted([slot="icon"]) { font-size: inherit !important; flex: none; } ::slotted(svg[slot="icon"]) { width: 1em; height: 1em; } a { all: unset; display: block; position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; z-index: 1; } @media (prefers-reduced-motion) { .base, .label, .icon { transition: none; } } @media (forced-colors: active) { .base, .label, .icon { transition: none; } :host(:not(:disabled)) .base { background-color: Menu; } :host(:not(:disabled)) .label, :host(:not(:disabled)) .icon { color: MenuText; } :host(:disabled) .label, :host(:disabled) .icon { color: GrayText; } }`,v([B(".elevation")],G.prototype,"_elevation",void 0),v([B(".focus-ring")],G.prototype,"_focusRing",void 0),v([B(".state-layer")],G.prototype,"_stateLayer",void 0),v([B(".ripple")],G.prototype,"_ripple",void 0),G=v([E("m3e-fab-menu-item")],G);let dt=class extends(l(t,"menu")){constructor(){super(...arguments),Q.add(this),Y.set(this,void 0),Z.set(this,void 0),tt.set(this,void 0),et.set(this,(new f).withWrap().withHomeAndEnd().withVerticalOrientation()),it.set(this,t=>g(this,Q,"m",nt).call(this,t)),ot.set(this,t=>g(this,Q,"m",lt).call(this,t)),st.set(this,new d(this,{target:null,callback:()=>this.hide()})),rt.set(this,t=>{"closed"===t.newState?(g(this,tt,"f")?.call(this),w(this,tt,void 0,"f")):setTimeout(()=>{g(this,et,"f").setActiveItem(g(this,et,"f").items.find(t=>!t.disabled))},40)}),this.variant="primary"}get isOpen(){return void 0!==g(this,Z,"f")}async show(t){g(this,Z,"f")&&g(this,Z,"f")!==t&&this.hide(),g(this,tt,"f")?.call(this),w(this,tt,await y(this,t,{position:"top-end",inline:!0,shift:!0,flip:!0,offset:8},(t,e,i)=>{this.classList.toggle("-right",i.includes("end")),this.classList.toggle("-left",i.includes("start")),"rtl"===b.current?(this.style.right=window.innerWidth-t-this.clientWidth+"px",this.style.left=""):(this.style.left=`${t}px`,this.style.right=""),this.style.top=`${e}px`}),"f"),this.showPopover(),w(this,Z,t,"f"),g(this,Z,"f").ariaExpanded="true",g(this,st,"f").observe(g(this,Z,"f")),g(this,Q,"m",ct).call(this)}hide(t=!1){g(this,tt,"f")?.call(this),w(this,tt,void 0,"f"),g(this,Z,"f")&&(g(this,Z,"f").ariaExpanded="false",t&&g(this,Z,"f").focus(),g(this,Q,"m",ht).call(this),g(this,st,"f").unobserve(g(this,Z,"f")),w(this,Z,void 0,"f")),this.hidePopover()}async toggle(t){g(this,Z,"f")?this.hide():await this.show(t)}connectedCallback(){super.connectedCallback(),this.tabIndex=-1,this.setAttribute("popover","manual"),this.classList.add("-no-animate"),this.addEventListener("keydown",g(this,it,"f")),this.addEventListener("toggle",g(this,rt,"f")),document.addEventListener("click",g(this,ot,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",g(this,it,"f")),this.removeEventListener("toggle",g(this,rt,"f")),document.removeEventListener("click",g(this,ot,"f"))}firstUpdated(t){super.firstUpdated(t),requestAnimationFrame(()=>this.classList.remove("-no-animate"))}render(){return e`<div class="base"><slot @slotchange="${g(this,Q,"m",at)}"></slot></div>`}};var pt,ft,mt;Y=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,it=new WeakMap,ot=new WeakMap,st=new WeakMap,rt=new WeakMap,Q=new WeakSet,at=function(){const{added:t}=g(this,et,"f").setItems([...this.querySelectorAll("m3e-fab-menu-item")]);g(this,et,"f").activeItem||g(this,et,"f").updateActiveItem(t.find(t=>!t.disabled))},nt=function(t){switch(t.key){case"Tab":this.hide();break;case"Escape":t.shiftKey||t.ctrlKey||this.hide(!0);break;default:g(this,et,"f").onKeyDown(t)}},lt=function(t){t.composedPath().some(t=>t instanceof G||t===g(this,Z,"f"))||this.hide()},ct=function(){const t=g(this,Z,"f")?.closest("m3e-fab");t&&(w(this,Y,t.tabIndex,"f"),t.addEventListener("keydown",g(this,it,"f")),g(this,et,"f").setItems([...g(this,et,"f").items,t]))},ht=function(){const t=g(this,Z,"f")?.closest("m3e-fab");t&&(void 0!==g(this,Y,"f")&&(t.tabIndex=g(this,Y,"f")),t.removeEventListener("keydown",g(this,it,"f")),g(this,et,"f").setItems([...g(this,et,"f").items.filter(e=>e!==t)]))},dt.styles=o`:host { position: absolute; flex-direction: column; row-gap: var(--m3e-fab-menu-spacing, 0.25rem); padding: unset; margin: unset; border: unset; overflow: visible; max-width: var(--m3e-fab-menu-max-width, 17.5rem); opacity: 0; background-color: transparent; display: none; } :host(:not(.-no-animate)) { transition: ${i(`opacity ${h.motion.spring.fastEffects}, \n transform ${h.motion.spring.fastSpatial},\n overlay ${h.motion.spring.fastEffects} allow-discrete,\n display ${h.motion.spring.fastEffects} allow-discrete`)}; } .base { display: contents; } :host([variant="primary"]) .base { --_fab-menu-item-color: var(--m3e-primary-fab-color, ${h.color.onPrimaryContainer}); --_fab-menu-item-container-color: var(--m3e-primary-fab-container-color, ${h.color.primaryContainer}); --_fab-menu-background-hover-color: var(--m3e-primary-fab-hover-color, ${h.color.onPrimaryContainer}); --_fab-menu-background-focus-color: var(--m3e-primary-fab-focus-color, ${h.color.onPrimaryContainer}); --_fab-menu-ripple-color: var(--m3e-primary-fab-ripple-color, ${h.color.onPrimaryContainer}); } :host([variant="secondary"]) .base { --_fab-menu-item-color: var(--m3e-secondary-fab-color, ${h.color.onSecondaryContainer}); --_fab-menu-item-container-color: var( --m3e-secondary-fab-container-color, ${h.color.secondaryContainer} ); --_fab-menu-background-hover-color: var( --m3e-secondary-fab-hover-color, ${h.color.onSecondaryContainer} ); --_fab-menu-background-focus-color: var( --m3e-secondary-fab-focus-color, ${h.color.onSecondaryContainer} ); --_fab-menu-ripple-color: var(--m3e-secondary-fab-ripple-color, ${h.color.onSecondaryContainer}); } :host([variant="tertiary"]) .base { --_fab-menu-item-color: var(--m3e-tertiary-fab-color, ${h.color.onTertiaryContainer}); --_fab-menu-item-container-color: var(--m3e-tertiary-fab-container-color, ${h.color.tertiaryContainer}); --_fab-menu-background-hover-color: var(--m3e-tertiary-fab-hover-color, ${h.color.onTertiaryContainer}); --_fab-menu-background-focus-color: var(--m3e-tertiary-fab-focus-color, ${h.color.onTertiaryContainer}); --_fab-menu-ripple-color: var(--m3e-tertiary-fab-ripple-color, ${h.color.onTertiaryContainer}); } :host { transform: scaleX(0.8); } :host(.-left) { align-items: flex-start; transform-origin: left; } :host(.-right) { align-items: flex-end; transform-origin: right; } :host(:popover-open) { transform: scaleX(1); display: inline-flex; opacity: 1; } :host::backdrop { background-color: transparent; } @starting-style { :host(:popover-open) { opacity: 0; } :host(:popover-open) { transform: scaleX(0.8); } } @media (prefers-reduced-motion) { :host(:not(.-no-animate)) { transition: none; } } @media (forced-colors: active) { :host { border-radius: ${h.shape.corner.medium}; border: 1px solid MenuText; background-color: Menu; } }`,v([function(t){return(e,i)=>"object"==typeof i?X(t,e,i):((t,e,i)=>{const o=e.hasOwnProperty(i);return e.constructor.createProperty(i,t),o?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}
|
|
259
35
|
/**
|
|
260
36
|
* @license
|
|
261
37
|
* Copyright 2017 Google LLC
|
|
262
38
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
263
|
-
*/({reflect:!0})],
|
|
264
|
-
:host {
|
|
265
|
-
display: contents;
|
|
266
|
-
}
|
|
267
|
-
::slotted(.material-icons) {
|
|
268
|
-
font-size: inherit !important;
|
|
269
|
-
}
|
|
270
|
-
`,ue=y([E("m3e-fab-menu-trigger")],ue);export{de as M3eFabMenuElement,G as M3eFabMenuItemElement,ue as M3eFabMenuTriggerElement};
|
|
39
|
+
*/({reflect:!0})],dt.prototype,"variant",void 0),dt=v([E("m3e-fab-menu")],dt);let ut=class extends(p(t)){constructor(){super(...arguments),pt.add(this),ft.set(this,async t=>g(this,pt,"m",mt).call(this,t))}get menu(){return this.control instanceof dt?this.control:null}connectedCallback(){super.connectedCallback(),this.parentElement?.addEventListener("click",g(this,ft,"f"))}disconnectedCallback(){super.disconnectedCallback(),this.parentElement?.removeEventListener("click",g(this,ft,"f"))}attach(t){super.attach(t),t instanceof dt&&this.parentElement&&(this.parentElement.ariaHasPopup="menu",this.parentElement.ariaExpanded="false",t.id&&m(this.parentElement,"aria-controls",t.id))}detach(){this.parentElement&&(this.parentElement.ariaHasPopup=null,this.parentElement.ariaExpanded=null,this.control?.id&&u(this.parentElement,"aria-controls",this.control.id)),super.detach()}render(){return e`<slot></slot>`}};ft=new WeakMap,pt=new WeakSet,mt=function(t){!t.defaultPrevented&&this.parentElement&&this.menu?.toggle(this.parentElement)},ut.styles=o`:host { display: contents; } ::slotted(.material-icons) { font-size: inherit !important; }`,ut=v([E("m3e-fab-menu-trigger")],ut);export{dt as M3eFabMenuElement,G as M3eFabMenuItemElement,ut as M3eFabMenuTriggerElement};
|
|
271
40
|
//# sourceMappingURL=index.min.js.map
|