@m3e/fab-menu 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 +172 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +60 -0
- package/dist/css-custom-data.json +142 -0
- package/dist/custom-elements.json +687 -0
- package/dist/html-custom-data.json +56 -0
- package/dist/index.js +740 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +268 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/FabMenuElement.d.ts +106 -0
- package/dist/src/FabMenuElement.d.ts.map +1 -0
- package/dist/src/FabMenuItemElement.d.ts +72 -0
- package/dist/src/FabMenuItemElement.d.ts.map +1 -0
- package/dist/src/FabMenuTriggerElement.d.ts +50 -0
- package/dist/src/FabMenuTriggerElement.d.ts.map +1 -0
- package/dist/src/FabMenuVariant.d.ts +3 -0
- package/dist/src/FabMenuVariant.d.ts.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/eslint.config.mjs +13 -0
- package/package.json +49 -0
- package/rollup.config.js +32 -0
- package/src/FabMenuElement.ts +391 -0
- package/src/FabMenuItemElement.ts +253 -0
- package/src/FabMenuTriggerElement.ts +108 -0
- package/src/FabMenuVariant.ts +2 -0
- package/src/index.ts +4 -0
- package/tsconfig.json +9 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,740 @@
|
|
|
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, html, unsafeCSS, css } from 'lit';
|
|
7
|
+
import { KeyboardClick, LinkButton, Disabled, AttachInternals, Role, renderPseudoLink, DesignToken, ScrollController, HtmlFor } from '@m3e/core';
|
|
8
|
+
import { RovingTabIndexManager, addAriaReferencedId, removeAriaReferencedId } from '@m3e/core/a11y';
|
|
9
|
+
import { M3eDirectionality } from '@m3e/core/bidi';
|
|
10
|
+
import { positionAnchor } from '@m3e/core/anchoring';
|
|
11
|
+
|
|
12
|
+
/******************************************************************************
|
|
13
|
+
Copyright (c) Microsoft Corporation.
|
|
14
|
+
|
|
15
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
16
|
+
purpose with or without fee is hereby granted.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
19
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
20
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
21
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
22
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
23
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
24
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
25
|
+
***************************************************************************** */
|
|
26
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
function __decorate(decorators, target, key, desc) {
|
|
30
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
32
|
+
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;
|
|
33
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
37
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
38
|
+
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");
|
|
39
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
43
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
44
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
45
|
+
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");
|
|
46
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @license
|
|
56
|
+
* Copyright 2017 Google LLC
|
|
57
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
58
|
+
*/
|
|
59
|
+
const t$1=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @license
|
|
63
|
+
* Copyright 2019 Google LLC
|
|
64
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
65
|
+
*/
|
|
66
|
+
const t=globalThis,e$3=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),o$2=new WeakMap;let n$2 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==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 s=this.t;if(e$3&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$2.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$2.set(s,t));}return t}toString(){return this.cssText}};const r$2=t=>new n$2("string"==typeof t?t:t+"",void 0,s),S=(s,o)=>{if(e$3)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$1=e$3?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$2(e)})(t):t;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @license
|
|
70
|
+
* Copyright 2017 Google LLC
|
|
71
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
72
|
+
*/const{is:i,defineProperty:e$2,getOwnPropertyDescriptor:h,getOwnPropertyNames:r$1,getOwnPropertySymbols:o$1,getPrototypeOf:n$1}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:"",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l: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=(t,s)=>!i(t,s),b={attribute:true,type:String,converter:u,reflect:false,useDefault:false,hasChanged:f};Symbol.metadata??=Symbol("metadata"),a.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$2(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h(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("elementProperties")))return;const t=n$1(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d("properties"))){const t=this.properties,s=[...r$1(t),...o$1(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$1(s));}else void 0!==s&&i.push(c$1(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(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).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;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)(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("elementProperties")]=new Map,y[d("finalized")]=new Map,p?.({ReactiveElement:y}),(a.reactiveElementVersions??=[]).push("2.1.1");
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @license
|
|
76
|
+
* Copyright 2017 Google LLC
|
|
77
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
78
|
+
*/const o={attribute:true,type:String,converter:u,reflect:false,hasChanged:f},r=(t=o,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(t){return (e,o)=>"object"==typeof o?r(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)}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @license
|
|
82
|
+
* Copyright 2017 Google LLC
|
|
83
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
84
|
+
*/
|
|
85
|
+
const e$1=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @license
|
|
89
|
+
* Copyright 2017 Google LLC
|
|
90
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
91
|
+
*/function e(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$1(n,s,{get(){return o(this)}})}}
|
|
92
|
+
|
|
93
|
+
var _M3eFabMenuItemElement_instances, _M3eFabMenuItemElement_clickHandler, _M3eFabMenuItemElement_handleClick;
|
|
94
|
+
/**
|
|
95
|
+
* An item of a floating action button (FAB) menu.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`.
|
|
99
|
+
* ```html
|
|
100
|
+
* <m3e-fab variant="primary" size="large">
|
|
101
|
+
* <m3e-fab-menu-trigger for="fabmenu">
|
|
102
|
+
* <m3e-icon name="edit"></m3e-icon>
|
|
103
|
+
* </m3e-fab-menu-trigger>
|
|
104
|
+
* </m3e-fab>
|
|
105
|
+
* <m3e-fab-menu id="fabmenu" variant="secondary">
|
|
106
|
+
* <m3e-fab-menu-item>First</m3e-fab-menu-item>
|
|
107
|
+
* <m3e-fab-menu-item>Second</m3e-fab-menu-item>
|
|
108
|
+
* <m3e-fab-menu-item>Third</m3e-fab-menu-item>
|
|
109
|
+
* <m3e-fab-menu-item>Forth</m3e-fab-menu-item>
|
|
110
|
+
* <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>
|
|
111
|
+
* <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>
|
|
112
|
+
* </m3e-fab-menu>
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @tag m3e-menu-item
|
|
116
|
+
*
|
|
117
|
+
* @slot - Renders the label of the item.
|
|
118
|
+
* @slot icon - Renders an icon before the items's label.
|
|
119
|
+
*
|
|
120
|
+
* @attr disabled - Whether the element is disabled.
|
|
121
|
+
* @attr download - A value indicating whether the `target` of the link button will be downloaded, optionally specifying the new name of the file.
|
|
122
|
+
* @attr href - The URL to which the link button points.
|
|
123
|
+
* @attr rel - The relationship between the `target` of the link button and the document.
|
|
124
|
+
* @attr target - The target of the link button.
|
|
125
|
+
*
|
|
126
|
+
* @cssprop --m3e-fab-menu-item-height - Height of the menu item.
|
|
127
|
+
* @cssprop --m3e-fab-menu-item-font-size - Font size of the menu item label.
|
|
128
|
+
* @cssprop --m3e-fab-menu-item-font-weight - Font weight of the menu item label.
|
|
129
|
+
* @cssprop --m3e-fab-menu-item-line-height - Line height of the menu item label.
|
|
130
|
+
* @cssprop --m3e-fab-menu-item-tracking - Letter spacing of the menu item label.
|
|
131
|
+
* @cssprop --m3e-fab-menu-item-shape - Border radius of the menu item.
|
|
132
|
+
* @cssprop --m3e-fab-menu-item-leading-space - Padding at the start of the menu item.
|
|
133
|
+
* @cssprop --m3e-fab-menu-item-trailing-space - Padding at the end of the menu item.
|
|
134
|
+
* @cssprop --m3e-fab-menu-item-spacing - Gap between icon and label.
|
|
135
|
+
* @cssprop --m3e-fab-menu-item-icon-size - Size of the icon in the menu item.
|
|
136
|
+
*/
|
|
137
|
+
let M3eFabMenuItemElement = class M3eFabMenuItemElement extends KeyboardClick(LinkButton(Disabled(AttachInternals(Role(LitElement, "menuitem"), true)))) {
|
|
138
|
+
constructor() {
|
|
139
|
+
super(...arguments);
|
|
140
|
+
_M3eFabMenuItemElement_instances.add(this);
|
|
141
|
+
/** @private */ _M3eFabMenuItemElement_clickHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eFabMenuItemElement_instances, "m", _M3eFabMenuItemElement_handleClick).call(this, e));
|
|
142
|
+
}
|
|
143
|
+
/** The floating action button (FAB) menu to which this item belongs. */
|
|
144
|
+
get menu() {
|
|
145
|
+
return this.closest("m3e-fab-menu");
|
|
146
|
+
}
|
|
147
|
+
/** @inheritdoc */
|
|
148
|
+
connectedCallback() {
|
|
149
|
+
super.connectedCallback();
|
|
150
|
+
this.addEventListener("click", __classPrivateFieldGet(this, _M3eFabMenuItemElement_clickHandler, "f"));
|
|
151
|
+
}
|
|
152
|
+
/** @inheritdoc */
|
|
153
|
+
disconnectedCallback() {
|
|
154
|
+
super.disconnectedCallback();
|
|
155
|
+
this.removeEventListener("click", __classPrivateFieldGet(this, _M3eFabMenuItemElement_clickHandler, "f"));
|
|
156
|
+
}
|
|
157
|
+
/** @inheritdoc */
|
|
158
|
+
firstUpdated(_changedProperties) {
|
|
159
|
+
super.firstUpdated(_changedProperties);
|
|
160
|
+
[this._elevation, this._focusRing, this._stateLayer, this._ripple].forEach((x) => x?.attach(this));
|
|
161
|
+
}
|
|
162
|
+
/** @inheritdoc */
|
|
163
|
+
render() {
|
|
164
|
+
return html `<div class="base">
|
|
165
|
+
<m3e-elevation class="elevation" ?disabled="${this.disabled}"></m3e-elevation>
|
|
166
|
+
<m3e-state-layer class="state-layer" ?disabled="${this.disabled}"></m3e-state-layer>
|
|
167
|
+
<m3e-focus-ring class="focus-ring" ?disabled="${this.disabled}"></m3e-focus-ring>
|
|
168
|
+
<m3e-ripple class="ripple" ?disabled="${this.disabled}"></m3e-ripple>
|
|
169
|
+
<div class="touch" aria-hidden="true"></div>
|
|
170
|
+
${this[renderPseudoLink]()}
|
|
171
|
+
<div class="wrapper">
|
|
172
|
+
<slot class="icon" name="icon" aria-hidden="true"></slot>
|
|
173
|
+
<div class="label"><slot></slot></div>
|
|
174
|
+
</div>
|
|
175
|
+
</div>`;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
_M3eFabMenuItemElement_clickHandler = new WeakMap();
|
|
179
|
+
_M3eFabMenuItemElement_instances = new WeakSet();
|
|
180
|
+
_M3eFabMenuItemElement_handleClick = function _M3eFabMenuItemElement_handleClick(e) {
|
|
181
|
+
if (!e.defaultPrevented) {
|
|
182
|
+
this.menu?.hide(true);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
/** The styles of the element. */
|
|
186
|
+
M3eFabMenuItemElement.styles = css `
|
|
187
|
+
:host {
|
|
188
|
+
display: inline-block;
|
|
189
|
+
outline: none;
|
|
190
|
+
user-select: none;
|
|
191
|
+
}
|
|
192
|
+
.base {
|
|
193
|
+
box-sizing: border-box;
|
|
194
|
+
vertical-align: middle;
|
|
195
|
+
display: inline-flex;
|
|
196
|
+
align-items: center;
|
|
197
|
+
justify-content: center;
|
|
198
|
+
position: relative;
|
|
199
|
+
width: 100%;
|
|
200
|
+
transition: ${unsafeCSS(`background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};
|
|
201
|
+
height: var(--m3e-fab-menu-item-height, 3.5rem);
|
|
202
|
+
font-size: var(--m3e-fab-menu-item-font-size, ${DesignToken.typescale.standard.label.large.fontSize});
|
|
203
|
+
font-weight: var(--m3e-fab-menu-item-font-weight, ${DesignToken.typescale.standard.label.large.fontWeight});
|
|
204
|
+
line-height: var(--m3e-fab-menu-item-line-height, ${DesignToken.typescale.standard.label.large.lineHeight});
|
|
205
|
+
letter-spacing: var(--m3e-fab-menu-item-tracking, ${DesignToken.typescale.standard.label.large.tracking});
|
|
206
|
+
border-radius: var(--m3e-fab-menu-item-shape, ${DesignToken.shape.corner.full});
|
|
207
|
+
}
|
|
208
|
+
:host(:not(:disabled)) .label,
|
|
209
|
+
:host(:not(:disabled)) .icon {
|
|
210
|
+
color: var(--_fab-menu-item-color);
|
|
211
|
+
}
|
|
212
|
+
:host(:not(:disabled)) .base {
|
|
213
|
+
background-color: var(--_fab-menu-item-container-color);
|
|
214
|
+
--m3e-state-layer-hover-color: var(--_fab-menu-background-hover-color);
|
|
215
|
+
--m3e-state-layer-focus-color: var(--_fab-menu-background-focus-color);
|
|
216
|
+
--m3e-ripple-color: var(--_fab-menu-ripple-color);
|
|
217
|
+
}
|
|
218
|
+
:host(:disabled) .base {
|
|
219
|
+
background-color: color-mix(
|
|
220
|
+
in srgb,
|
|
221
|
+
var(--m3e-fab-menu-item-disabled-container-color, ${DesignToken.color.onSurface})
|
|
222
|
+
var(--m3e-fab-menu-item-disabled-container-opacity, 10%),
|
|
223
|
+
transparent
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
:host(:disabled) .label,
|
|
227
|
+
:host(:disabled) .icon {
|
|
228
|
+
color: color-mix(
|
|
229
|
+
in srgb,
|
|
230
|
+
var(--m3e-fab-menu-item-disabled-color, ${DesignToken.color.onSurface})
|
|
231
|
+
var(--m3e-fab-menu-item-disabled-opacity, 38%),
|
|
232
|
+
transparent
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
.touch {
|
|
236
|
+
position: absolute;
|
|
237
|
+
height: 3rem;
|
|
238
|
+
left: 0;
|
|
239
|
+
right: 0;
|
|
240
|
+
}
|
|
241
|
+
.wrapper {
|
|
242
|
+
width: 100%;
|
|
243
|
+
overflow: hidden;
|
|
244
|
+
display: inline-flex;
|
|
245
|
+
align-items: center;
|
|
246
|
+
padding-inline-start: var(--m3e-fab-menu-item-leading-space, 1.5rem);
|
|
247
|
+
padding-inline-end: var(--m3e-fab-menu-item-trailing-space, 1.5rem);
|
|
248
|
+
column-gap: var(--m3e-fab-menu-item-spacing, 0.5rem);
|
|
249
|
+
}
|
|
250
|
+
.label {
|
|
251
|
+
justify-self: center;
|
|
252
|
+
flex: 1 1 auto;
|
|
253
|
+
text-align: center;
|
|
254
|
+
white-space: nowrap;
|
|
255
|
+
overflow: hidden;
|
|
256
|
+
text-overflow: ellipsis;
|
|
257
|
+
transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};
|
|
258
|
+
}
|
|
259
|
+
.icon {
|
|
260
|
+
font-size: var(--m3e-fab-menu-item-icon-size, 1.5rem);
|
|
261
|
+
transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};
|
|
262
|
+
}
|
|
263
|
+
:host(:not(:disabled)) {
|
|
264
|
+
cursor: pointer;
|
|
265
|
+
}
|
|
266
|
+
::slotted([slot="icon"]) {
|
|
267
|
+
font-size: inherit !important;
|
|
268
|
+
flex: none;
|
|
269
|
+
}
|
|
270
|
+
::slotted(svg[slot="icon"]) {
|
|
271
|
+
width: 1em;
|
|
272
|
+
height: 1em;
|
|
273
|
+
}
|
|
274
|
+
a {
|
|
275
|
+
all: unset;
|
|
276
|
+
display: block;
|
|
277
|
+
position: absolute;
|
|
278
|
+
top: 0px;
|
|
279
|
+
left: 0px;
|
|
280
|
+
right: 0px;
|
|
281
|
+
bottom: 0px;
|
|
282
|
+
z-index: 1;
|
|
283
|
+
}
|
|
284
|
+
@media (prefers-reduced-motion) {
|
|
285
|
+
.base,
|
|
286
|
+
.label,
|
|
287
|
+
.icon {
|
|
288
|
+
transition: none;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
@media (forced-colors: active) {
|
|
292
|
+
.base,
|
|
293
|
+
.label,
|
|
294
|
+
.icon {
|
|
295
|
+
transition: none;
|
|
296
|
+
}
|
|
297
|
+
:host(:not(:disabled)) .base {
|
|
298
|
+
background-color: Menu;
|
|
299
|
+
}
|
|
300
|
+
:host(:not(:disabled)) .label,
|
|
301
|
+
:host(:not(:disabled)) .icon {
|
|
302
|
+
color: MenuText;
|
|
303
|
+
}
|
|
304
|
+
:host(:disabled) .label,
|
|
305
|
+
:host(:disabled) .icon {
|
|
306
|
+
color: GrayText;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
`;
|
|
310
|
+
__decorate([
|
|
311
|
+
e(".elevation")
|
|
312
|
+
], M3eFabMenuItemElement.prototype, "_elevation", void 0);
|
|
313
|
+
__decorate([
|
|
314
|
+
e(".focus-ring")
|
|
315
|
+
], M3eFabMenuItemElement.prototype, "_focusRing", void 0);
|
|
316
|
+
__decorate([
|
|
317
|
+
e(".state-layer")
|
|
318
|
+
], M3eFabMenuItemElement.prototype, "_stateLayer", void 0);
|
|
319
|
+
__decorate([
|
|
320
|
+
e(".ripple")
|
|
321
|
+
], M3eFabMenuItemElement.prototype, "_ripple", void 0);
|
|
322
|
+
M3eFabMenuItemElement = __decorate([
|
|
323
|
+
t$1("m3e-fab-menu-item")
|
|
324
|
+
], M3eFabMenuItemElement);
|
|
325
|
+
|
|
326
|
+
var _M3eFabMenuElement_instances, _M3eFabMenuElement_fabTabIndex, _M3eFabMenuElement_trigger, _M3eFabMenuElement_anchoringCleanup, _M3eFabMenuElement_listManager, _M3eFabMenuElement_keyDownHandler, _M3eFabMenuElement_documentClickHandler, _M3eFabMenuElement_scrollController, _M3eFabMenuElement_toggleHandler, _M3eFabMenuElement_handleSlotChange, _M3eFabMenuElement_handleKeyDown, _M3eFabMenuElement_handleDocumentClick, _M3eFabMenuElement_attachFab, _M3eFabMenuElement_detachFab;
|
|
327
|
+
/**
|
|
328
|
+
* @summary
|
|
329
|
+
* A menu, opened from a floating action button (FAB), used to display multiple related actions.
|
|
330
|
+
*
|
|
331
|
+
* @description
|
|
332
|
+
* The `m3e-fab-menu` component presents a dynamic menu of related actions, elegantly revealed from a
|
|
333
|
+
* floating action button (FAB). Designed using expressive, adaptive surfaces, it enables seamless access
|
|
334
|
+
* to contextual actions in modern, visually rich interfaces.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`.
|
|
338
|
+
* ```html
|
|
339
|
+
* <m3e-fab variant="primary" size="large">
|
|
340
|
+
* <m3e-fab-menu-trigger for="fabmenu">
|
|
341
|
+
* <m3e-icon name="edit"></m3e-icon>
|
|
342
|
+
* </m3e-fab-menu-trigger>
|
|
343
|
+
* </m3e-fab>
|
|
344
|
+
* <m3e-fab-menu id="fabmenu" variant="secondary">
|
|
345
|
+
* <m3e-fab-menu-item>First</m3e-fab-menu-item>
|
|
346
|
+
* <m3e-fab-menu-item>Second</m3e-fab-menu-item>
|
|
347
|
+
* <m3e-fab-menu-item>Third</m3e-fab-menu-item>
|
|
348
|
+
* <m3e-fab-menu-item>Forth</m3e-fab-menu-item>
|
|
349
|
+
* <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>
|
|
350
|
+
* <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>
|
|
351
|
+
* </m3e-fab-menu>
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* @tag m3e-fab-menu
|
|
355
|
+
*
|
|
356
|
+
* @slot - Renders the contents of the menu.
|
|
357
|
+
*
|
|
358
|
+
* @attr variant - The appearance variant of the menu.
|
|
359
|
+
*
|
|
360
|
+
* @cssprop --m3e-fab-menu-spacing - Vertical gap between menu items.
|
|
361
|
+
* @cssprop --m3e-fab-menu-max-width - Maximum width of the menu.
|
|
362
|
+
* @cssprop --m3e-primary-fab-color - Foreground color for primary variant items.
|
|
363
|
+
* @cssprop --m3e-primary-fab-container-color - Container color for primary variant items.
|
|
364
|
+
* @cssprop --m3e-primary-fab-hover-color - Hover background color for primary variant items.
|
|
365
|
+
* @cssprop --m3e-primary-fab-focus-color - Focus background color for primary variant items.
|
|
366
|
+
* @cssprop --m3e-primary-fab-ripple-color - Ripple color for primary variant items.
|
|
367
|
+
* @cssprop --m3e-secondary-fab-color - Foreground color for secondary variant items.
|
|
368
|
+
* @cssprop --m3e-secondary-fab-container-color - Container color for secondary variant items.
|
|
369
|
+
* @cssprop --m3e-secondary-fab-hover-color - Hover background color for secondary variant items.
|
|
370
|
+
* @cssprop --m3e-secondary-fab-focus-color - Focus background color for secondary variant items.
|
|
371
|
+
* @cssprop --m3e-secondary-fab-ripple-color - Ripple color for secondary variant items.
|
|
372
|
+
* @cssprop --m3e-tertiary-fab-color - Foreground color for tertiary variant items.
|
|
373
|
+
* @cssprop --m3e-tertiary-fab-container-color - Container color for tertiary variant items.
|
|
374
|
+
* @cssprop --m3e-tertiary-fab-hover-color - Hover background color for tertiary variant items.
|
|
375
|
+
* @cssprop --m3e-tertiary-fab-focus-color - Focus background color for tertiary variant items.
|
|
376
|
+
* @cssprop --m3e-tertiary-fab-ripple-color - Ripple color for tertiary variant items.
|
|
377
|
+
*/
|
|
378
|
+
let M3eFabMenuElement = class M3eFabMenuElement extends Role(LitElement, "menu") {
|
|
379
|
+
constructor() {
|
|
380
|
+
super(...arguments);
|
|
381
|
+
_M3eFabMenuElement_instances.add(this);
|
|
382
|
+
/** @private */ _M3eFabMenuElement_fabTabIndex.set(this, void 0);
|
|
383
|
+
/** @private */ _M3eFabMenuElement_trigger.set(this, void 0);
|
|
384
|
+
/** @private */ _M3eFabMenuElement_anchoringCleanup.set(this, void 0);
|
|
385
|
+
/** @private */
|
|
386
|
+
_M3eFabMenuElement_listManager.set(this, new RovingTabIndexManager()
|
|
387
|
+
.withWrap()
|
|
388
|
+
.withHomeAndEnd()
|
|
389
|
+
.withVerticalOrientation());
|
|
390
|
+
/** @private */ _M3eFabMenuElement_keyDownHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eFabMenuElement_instances, "m", _M3eFabMenuElement_handleKeyDown).call(this, e));
|
|
391
|
+
/** @private */ _M3eFabMenuElement_documentClickHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eFabMenuElement_instances, "m", _M3eFabMenuElement_handleDocumentClick).call(this, e));
|
|
392
|
+
/** @private */
|
|
393
|
+
_M3eFabMenuElement_scrollController.set(this, new ScrollController(this, { target: null, callback: () => this.hide() }));
|
|
394
|
+
/** @private */
|
|
395
|
+
_M3eFabMenuElement_toggleHandler.set(this, (e) => {
|
|
396
|
+
if (e.newState === "closed") {
|
|
397
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_anchoringCleanup, "f")?.call(this);
|
|
398
|
+
__classPrivateFieldSet(this, _M3eFabMenuElement_anchoringCleanup, undefined, "f");
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
setTimeout(() => {
|
|
402
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").setActiveItem(__classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").items.find((x) => !x.disabled));
|
|
403
|
+
}, 40);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
/**
|
|
407
|
+
* The appearance variant of the menu.
|
|
408
|
+
* @default "primary"
|
|
409
|
+
*/
|
|
410
|
+
this.variant = "primary";
|
|
411
|
+
}
|
|
412
|
+
/** Whether the menu is open. */
|
|
413
|
+
get isOpen() {
|
|
414
|
+
return __classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f") !== undefined;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Opens the menu.
|
|
418
|
+
* @param {HTMLElement} trigger The element that triggered the menu.
|
|
419
|
+
* @returns {Promise<void>} A `Promise` that resolves when the menu is opened.
|
|
420
|
+
*/
|
|
421
|
+
async show(trigger) {
|
|
422
|
+
if (__classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f") && __classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f") !== trigger) {
|
|
423
|
+
this.hide();
|
|
424
|
+
}
|
|
425
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_anchoringCleanup, "f")?.call(this);
|
|
426
|
+
__classPrivateFieldSet(this, _M3eFabMenuElement_anchoringCleanup, await positionAnchor(this, trigger, {
|
|
427
|
+
position: M3eDirectionality.current === "ltr" ? "top-end" : "top-start",
|
|
428
|
+
inline: true,
|
|
429
|
+
shift: true,
|
|
430
|
+
flip: true,
|
|
431
|
+
offset: 8,
|
|
432
|
+
}, (x, y, position) => {
|
|
433
|
+
this.classList.toggle("-right", position.includes("end"));
|
|
434
|
+
this.classList.toggle("-left", position.includes("start"));
|
|
435
|
+
this.style.left = `${x}px`;
|
|
436
|
+
this.style.top = `${y}px`;
|
|
437
|
+
}), "f");
|
|
438
|
+
this.showPopover();
|
|
439
|
+
__classPrivateFieldSet(this, _M3eFabMenuElement_trigger, trigger, "f");
|
|
440
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f").ariaExpanded = "true";
|
|
441
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_scrollController, "f").observe(__classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f"));
|
|
442
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_instances, "m", _M3eFabMenuElement_attachFab).call(this);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Hides the menu.
|
|
446
|
+
* @param {boolean} [restoreFocus=false] A value indicating whether to restore focus to the menu's trigger.
|
|
447
|
+
*/
|
|
448
|
+
hide(restoreFocus = false) {
|
|
449
|
+
this.hidePopover();
|
|
450
|
+
if (__classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f")) {
|
|
451
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f").ariaExpanded = "false";
|
|
452
|
+
if (restoreFocus) {
|
|
453
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f").focus();
|
|
454
|
+
}
|
|
455
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_instances, "m", _M3eFabMenuElement_detachFab).call(this);
|
|
456
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_scrollController, "f").unobserve(__classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f"));
|
|
457
|
+
__classPrivateFieldSet(this, _M3eFabMenuElement_trigger, undefined, "f");
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Toggles the menu.
|
|
462
|
+
* @param {HTMLElement} trigger The element that triggered the menu.
|
|
463
|
+
* @returns {Promise<void>} A `Promise` that resolves when the menu is opened or closed.
|
|
464
|
+
*/
|
|
465
|
+
async toggle(trigger) {
|
|
466
|
+
if (__classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f")) {
|
|
467
|
+
this.hide();
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
await this.show(trigger);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/** @inheritdoc */
|
|
474
|
+
connectedCallback() {
|
|
475
|
+
super.connectedCallback();
|
|
476
|
+
this.tabIndex = -1;
|
|
477
|
+
this.setAttribute("popover", "manual");
|
|
478
|
+
this.addEventListener("keydown", __classPrivateFieldGet(this, _M3eFabMenuElement_keyDownHandler, "f"));
|
|
479
|
+
this.addEventListener("toggle", __classPrivateFieldGet(this, _M3eFabMenuElement_toggleHandler, "f"));
|
|
480
|
+
document.addEventListener("click", __classPrivateFieldGet(this, _M3eFabMenuElement_documentClickHandler, "f"));
|
|
481
|
+
}
|
|
482
|
+
/** @inheritdoc */
|
|
483
|
+
disconnectedCallback() {
|
|
484
|
+
super.disconnectedCallback();
|
|
485
|
+
this.removeEventListener("keydown", __classPrivateFieldGet(this, _M3eFabMenuElement_keyDownHandler, "f"));
|
|
486
|
+
this.removeEventListener("toggle", __classPrivateFieldGet(this, _M3eFabMenuElement_toggleHandler, "f"));
|
|
487
|
+
document.removeEventListener("click", __classPrivateFieldGet(this, _M3eFabMenuElement_documentClickHandler, "f"));
|
|
488
|
+
}
|
|
489
|
+
/** @inheritdoc */
|
|
490
|
+
render() {
|
|
491
|
+
return html `<div class="base"><slot @slotchange="${__classPrivateFieldGet(this, _M3eFabMenuElement_instances, "m", _M3eFabMenuElement_handleSlotChange)}"></slot></div>`;
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
_M3eFabMenuElement_fabTabIndex = new WeakMap();
|
|
495
|
+
_M3eFabMenuElement_trigger = new WeakMap();
|
|
496
|
+
_M3eFabMenuElement_anchoringCleanup = new WeakMap();
|
|
497
|
+
_M3eFabMenuElement_listManager = new WeakMap();
|
|
498
|
+
_M3eFabMenuElement_keyDownHandler = new WeakMap();
|
|
499
|
+
_M3eFabMenuElement_documentClickHandler = new WeakMap();
|
|
500
|
+
_M3eFabMenuElement_scrollController = new WeakMap();
|
|
501
|
+
_M3eFabMenuElement_toggleHandler = new WeakMap();
|
|
502
|
+
_M3eFabMenuElement_instances = new WeakSet();
|
|
503
|
+
_M3eFabMenuElement_handleSlotChange = function _M3eFabMenuElement_handleSlotChange() {
|
|
504
|
+
const { added } = __classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").setItems([...this.querySelectorAll("m3e-fab-menu-item")]);
|
|
505
|
+
if (!__classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").activeItem) {
|
|
506
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").updateActiveItem(added.find((x) => !x.disabled));
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
_M3eFabMenuElement_handleKeyDown = function _M3eFabMenuElement_handleKeyDown(e) {
|
|
510
|
+
switch (e.key) {
|
|
511
|
+
case "Tab":
|
|
512
|
+
this.hide();
|
|
513
|
+
break;
|
|
514
|
+
case "Escape":
|
|
515
|
+
if (!e.shiftKey && !e.ctrlKey) {
|
|
516
|
+
this.hide(true);
|
|
517
|
+
}
|
|
518
|
+
break;
|
|
519
|
+
default:
|
|
520
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").onKeyDown(e);
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
_M3eFabMenuElement_handleDocumentClick = function _M3eFabMenuElement_handleDocumentClick(e) {
|
|
525
|
+
if (!e.composedPath().some((x) => x instanceof M3eFabMenuItemElement || x === __classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f"))) {
|
|
526
|
+
this.hide();
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
_M3eFabMenuElement_attachFab = function _M3eFabMenuElement_attachFab() {
|
|
530
|
+
const fab = __classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f")?.closest("m3e-fab");
|
|
531
|
+
if (fab) {
|
|
532
|
+
__classPrivateFieldSet(this, _M3eFabMenuElement_fabTabIndex, fab.tabIndex, "f");
|
|
533
|
+
fab.addEventListener("keydown", __classPrivateFieldGet(this, _M3eFabMenuElement_keyDownHandler, "f"));
|
|
534
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").setItems([...__classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").items, fab]);
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
_M3eFabMenuElement_detachFab = function _M3eFabMenuElement_detachFab() {
|
|
538
|
+
const fab = __classPrivateFieldGet(this, _M3eFabMenuElement_trigger, "f")?.closest("m3e-fab");
|
|
539
|
+
if (fab) {
|
|
540
|
+
if (__classPrivateFieldGet(this, _M3eFabMenuElement_fabTabIndex, "f") !== undefined) {
|
|
541
|
+
fab.tabIndex = __classPrivateFieldGet(this, _M3eFabMenuElement_fabTabIndex, "f");
|
|
542
|
+
}
|
|
543
|
+
fab.removeEventListener("keydown", __classPrivateFieldGet(this, _M3eFabMenuElement_keyDownHandler, "f"));
|
|
544
|
+
__classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").setItems([...__classPrivateFieldGet(this, _M3eFabMenuElement_listManager, "f").items.filter((x) => x !== fab)]);
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
/** The styles of the element. */
|
|
548
|
+
M3eFabMenuElement.styles = css `
|
|
549
|
+
:host {
|
|
550
|
+
position: absolute;
|
|
551
|
+
flex-direction: column;
|
|
552
|
+
row-gap: var(--m3e-fab-menu-spacing, 0.25rem);
|
|
553
|
+
padding: unset;
|
|
554
|
+
margin: unset;
|
|
555
|
+
border: unset;
|
|
556
|
+
overflow: visible;
|
|
557
|
+
max-width: var(--m3e-fab-menu-max-width, 17.5rem);
|
|
558
|
+
opacity: 0;
|
|
559
|
+
background-color: transparent;
|
|
560
|
+
display: none;
|
|
561
|
+
transition: ${unsafeCSS(`opacity ${DesignToken.motion.spring.fastEffects},
|
|
562
|
+
transform ${DesignToken.motion.spring.fastSpatial},
|
|
563
|
+
overlay ${DesignToken.motion.spring.fastEffects} allow-discrete,
|
|
564
|
+
display ${DesignToken.motion.spring.fastEffects} allow-discrete`)};
|
|
565
|
+
}
|
|
566
|
+
.base {
|
|
567
|
+
display: contents;
|
|
568
|
+
}
|
|
569
|
+
:host([variant="primary"]) .base {
|
|
570
|
+
--_fab-menu-item-color: var(--m3e-primary-fab-color, ${DesignToken.color.onPrimaryContainer});
|
|
571
|
+
--_fab-menu-item-container-color: var(--m3e-primary-fab-container-color, ${DesignToken.color.primaryContainer});
|
|
572
|
+
--_fab-menu-background-hover-color: var(--m3e-primary-fab-hover-color, ${DesignToken.color.onPrimaryContainer});
|
|
573
|
+
--_fab-menu-background-focus-color: var(--m3e-primary-fab-focus-color, ${DesignToken.color.onPrimaryContainer});
|
|
574
|
+
--_fab-menu-ripple-color: var(--m3e-primary-fab-ripple-color, ${DesignToken.color.onPrimaryContainer});
|
|
575
|
+
}
|
|
576
|
+
:host([variant="secondary"]) .base {
|
|
577
|
+
--_fab-menu-item-color: var(--m3e-secondary-fab-color, ${DesignToken.color.onSecondaryContainer});
|
|
578
|
+
--_fab-menu-item-container-color: var(
|
|
579
|
+
--m3e-secondary-fab-container-color,
|
|
580
|
+
${DesignToken.color.secondaryContainer}
|
|
581
|
+
);
|
|
582
|
+
--_fab-menu-background-hover-color: var(
|
|
583
|
+
--m3e-secondary-fab-hover-color,
|
|
584
|
+
${DesignToken.color.onSecondaryContainer}
|
|
585
|
+
);
|
|
586
|
+
--_fab-menu-background-focus-color: var(
|
|
587
|
+
--m3e-secondary-fab-focus-color,
|
|
588
|
+
${DesignToken.color.onSecondaryContainer}
|
|
589
|
+
);
|
|
590
|
+
--_fab-menu-ripple-color: var(--m3e-secondary-fab-ripple-color, ${DesignToken.color.onSecondaryContainer});
|
|
591
|
+
}
|
|
592
|
+
:host([variant="tertiary"]) .base {
|
|
593
|
+
--_fab-menu-item-color: var(--m3e-tertiary-fab-color, ${DesignToken.color.onTertiaryContainer});
|
|
594
|
+
--_fab-menu-item-container-color: var(--m3e-tertiary-fab-container-color, ${DesignToken.color.tertiaryContainer});
|
|
595
|
+
--_fab-menu-background-hover-color: var(--m3e-tertiary-fab-hover-color, ${DesignToken.color.onTertiaryContainer});
|
|
596
|
+
--_fab-menu-background-focus-color: var(--m3e-tertiary-fab-focus-color, ${DesignToken.color.onTertiaryContainer});
|
|
597
|
+
--_fab-menu-ripple-color: var(--m3e-tertiary-fab-ripple-color, ${DesignToken.color.onTertiaryContainer});
|
|
598
|
+
}
|
|
599
|
+
:host {
|
|
600
|
+
transform: scaleX(0.8);
|
|
601
|
+
}
|
|
602
|
+
:host(.-left) {
|
|
603
|
+
align-items: flex-start;
|
|
604
|
+
transform-origin: left;
|
|
605
|
+
}
|
|
606
|
+
:host(.-right) {
|
|
607
|
+
align-items: flex-end;
|
|
608
|
+
transform-origin: right;
|
|
609
|
+
}
|
|
610
|
+
:host(:popover-open) {
|
|
611
|
+
transform: scaleX(1);
|
|
612
|
+
display: inline-flex;
|
|
613
|
+
opacity: 1;
|
|
614
|
+
}
|
|
615
|
+
:host::backdrop {
|
|
616
|
+
background-color: transparent;
|
|
617
|
+
}
|
|
618
|
+
@starting-style {
|
|
619
|
+
:host(:popover-open) {
|
|
620
|
+
opacity: 0;
|
|
621
|
+
}
|
|
622
|
+
:host(:popover-open) {
|
|
623
|
+
transform: scaleX(0.8);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
@media (prefers-reduced-motion) {
|
|
627
|
+
:host {
|
|
628
|
+
transition: none;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
@media (forced-colors: active) {
|
|
632
|
+
:host {
|
|
633
|
+
border-radius: ${DesignToken.shape.corner.medium};
|
|
634
|
+
border: 1px solid MenuText;
|
|
635
|
+
background-color: Menu;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
`;
|
|
639
|
+
__decorate([
|
|
640
|
+
n({ reflect: true })
|
|
641
|
+
], M3eFabMenuElement.prototype, "variant", void 0);
|
|
642
|
+
M3eFabMenuElement = __decorate([
|
|
643
|
+
t$1("m3e-fab-menu")
|
|
644
|
+
], M3eFabMenuElement);
|
|
645
|
+
|
|
646
|
+
var _M3eFabMenuTriggerElement_instances, _M3eFabMenuTriggerElement_clickHandler, _M3eFabMenuTriggerElement_handleClick;
|
|
647
|
+
/**
|
|
648
|
+
* An element, nested within a clickable element, used to open a floating action button (FAB) menu.
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`.
|
|
652
|
+
* ```html
|
|
653
|
+
* <m3e-fab variant="primary" size="large">
|
|
654
|
+
* <m3e-fab-menu-trigger for="fabmenu">
|
|
655
|
+
* <m3e-icon name="edit"></m3e-icon>
|
|
656
|
+
* </m3e-fab-menu-trigger>
|
|
657
|
+
* </m3e-fab>
|
|
658
|
+
* <m3e-fab-menu id="fabmenu" variant="secondary">
|
|
659
|
+
* <m3e-fab-menu-item>First</m3e-fab-menu-item>
|
|
660
|
+
* <m3e-fab-menu-item>Second</m3e-fab-menu-item>
|
|
661
|
+
* <m3e-fab-menu-item>Third</m3e-fab-menu-item>
|
|
662
|
+
* <m3e-fab-menu-item>Forth</m3e-fab-menu-item>
|
|
663
|
+
* <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>
|
|
664
|
+
* <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>
|
|
665
|
+
* </m3e-fab-menu>
|
|
666
|
+
* ```
|
|
667
|
+
*
|
|
668
|
+
* @tag m3e-fab-menu-trigger
|
|
669
|
+
*/
|
|
670
|
+
let M3eFabMenuTriggerElement = class M3eFabMenuTriggerElement extends HtmlFor(Role(LitElement, "none")) {
|
|
671
|
+
constructor() {
|
|
672
|
+
super(...arguments);
|
|
673
|
+
_M3eFabMenuTriggerElement_instances.add(this);
|
|
674
|
+
/** @private */ _M3eFabMenuTriggerElement_clickHandler.set(this, async (e) => __classPrivateFieldGet(this, _M3eFabMenuTriggerElement_instances, "m", _M3eFabMenuTriggerElement_handleClick).call(this, e));
|
|
675
|
+
}
|
|
676
|
+
/** The menu triggered by the element. */
|
|
677
|
+
get menu() {
|
|
678
|
+
return this.control instanceof M3eFabMenuElement ? this.control : null;
|
|
679
|
+
}
|
|
680
|
+
/** @inheritdoc */
|
|
681
|
+
connectedCallback() {
|
|
682
|
+
super.connectedCallback();
|
|
683
|
+
this.parentElement?.addEventListener("click", __classPrivateFieldGet(this, _M3eFabMenuTriggerElement_clickHandler, "f"));
|
|
684
|
+
}
|
|
685
|
+
/** @inheritdoc */
|
|
686
|
+
disconnectedCallback() {
|
|
687
|
+
super.disconnectedCallback();
|
|
688
|
+
this.parentElement?.removeEventListener("click", __classPrivateFieldGet(this, _M3eFabMenuTriggerElement_clickHandler, "f"));
|
|
689
|
+
}
|
|
690
|
+
/** @inheritdoc */
|
|
691
|
+
attach(control) {
|
|
692
|
+
super.attach(control);
|
|
693
|
+
if (control instanceof M3eFabMenuElement) {
|
|
694
|
+
if (this.parentElement) {
|
|
695
|
+
this.parentElement.ariaHasPopup = "menu";
|
|
696
|
+
this.parentElement.ariaExpanded = "false";
|
|
697
|
+
if (control.id) {
|
|
698
|
+
addAriaReferencedId(this.parentElement, "aria-controls", control.id);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
/** @inheritdoc */
|
|
704
|
+
detach() {
|
|
705
|
+
if (this.parentElement) {
|
|
706
|
+
this.parentElement.ariaHasPopup = null;
|
|
707
|
+
this.parentElement.ariaExpanded = null;
|
|
708
|
+
if (this.control?.id) {
|
|
709
|
+
removeAriaReferencedId(this.parentElement, "aria-controls", this.control.id);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
super.detach();
|
|
713
|
+
}
|
|
714
|
+
/** @inheritdoc */
|
|
715
|
+
render() {
|
|
716
|
+
return html `<slot></slot>`;
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
_M3eFabMenuTriggerElement_clickHandler = new WeakMap();
|
|
720
|
+
_M3eFabMenuTriggerElement_instances = new WeakSet();
|
|
721
|
+
_M3eFabMenuTriggerElement_handleClick = function _M3eFabMenuTriggerElement_handleClick(e) {
|
|
722
|
+
if (!e.defaultPrevented && this.parentElement) {
|
|
723
|
+
this.menu?.toggle(this.parentElement);
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
/** The styles of the element. */
|
|
727
|
+
M3eFabMenuTriggerElement.styles = css `
|
|
728
|
+
:host {
|
|
729
|
+
display: contents;
|
|
730
|
+
}
|
|
731
|
+
::slotted(.material-icons) {
|
|
732
|
+
font-size: inherit !important;
|
|
733
|
+
}
|
|
734
|
+
`;
|
|
735
|
+
M3eFabMenuTriggerElement = __decorate([
|
|
736
|
+
t$1("m3e-fab-menu-trigger")
|
|
737
|
+
], M3eFabMenuTriggerElement);
|
|
738
|
+
|
|
739
|
+
export { M3eFabMenuElement, M3eFabMenuItemElement, M3eFabMenuTriggerElement };
|
|
740
|
+
//# sourceMappingURL=index.js.map
|