@m3e/stepper 1.0.2
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 +263 -0
- package/dist/css-custom-data.json +172 -0
- package/dist/custom-elements.json +4143 -0
- package/dist/html-custom-data.json +99 -0
- package/dist/index.js +1152 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +334 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/StepElement.d.ts +161 -0
- package/dist/src/StepElement.d.ts.map +1 -0
- package/dist/src/StepHeaderPosition.d.ts +3 -0
- package/dist/src/StepHeaderPosition.d.ts.map +1 -0
- package/dist/src/StepLabelPosition.d.ts +3 -0
- package/dist/src/StepLabelPosition.d.ts.map +1 -0
- package/dist/src/StepPanelElement.d.ts +74 -0
- package/dist/src/StepPanelElement.d.ts.map +1 -0
- package/dist/src/StepperButtonElementBase.d.ts +17 -0
- package/dist/src/StepperButtonElementBase.d.ts.map +1 -0
- package/dist/src/StepperElement.d.ts +139 -0
- package/dist/src/StepperElement.d.ts.map +1 -0
- package/dist/src/StepperNextElement.d.ts +16 -0
- package/dist/src/StepperNextElement.d.ts.map +1 -0
- package/dist/src/StepperOrientation.d.ts +3 -0
- package/dist/src/StepperOrientation.d.ts.map +1 -0
- package/dist/src/StepperPreviousElement.d.ts +16 -0
- package/dist/src/StepperPreviousElement.d.ts.map +1 -0
- package/dist/src/StepperResetElement.d.ts +16 -0
- package/dist/src/StepperResetElement.d.ts.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.d.ts.map +1 -0
- package/package.json +48 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { css, LitElement, html, nothing } from 'lit';
|
|
7
|
+
import { Selected, KeyboardClick, Focusable, HtmlFor, Disabled, AttachInternals, Role, DesignToken } from '@m3e/core';
|
|
8
|
+
import { addAriaReferencedId, removeAriaReferencedId, selectionManager, SelectionManager } from '@m3e/core/a11y';
|
|
9
|
+
import { M3eBreakpointObserver, Breakpoint } from '@m3e/core/layout';
|
|
10
|
+
|
|
11
|
+
/******************************************************************************
|
|
12
|
+
Copyright (c) Microsoft Corporation.
|
|
13
|
+
|
|
14
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
15
|
+
purpose with or without fee is hereby granted.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
18
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
19
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
20
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
21
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
22
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
23
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
24
|
+
***************************************************************************** */
|
|
25
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function __decorate(decorators, target, key, desc) {
|
|
29
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
30
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31
|
+
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;
|
|
32
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
36
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
37
|
+
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");
|
|
38
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
42
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
43
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
44
|
+
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");
|
|
45
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
49
|
+
var e = new Error(message);
|
|
50
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright 2017 Google LLC
|
|
56
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
57
|
+
*/
|
|
58
|
+
const t$2=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @license
|
|
62
|
+
* Copyright 2019 Google LLC
|
|
63
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
64
|
+
*/
|
|
65
|
+
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$4=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$4(e)})(t):t;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @license
|
|
69
|
+
* Copyright 2017 Google LLC
|
|
70
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
71
|
+
*/const{is:i$1,defineProperty:e$3,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$3,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$3(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");
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @license
|
|
75
|
+
* Copyright 2017 Google LLC
|
|
76
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
77
|
+
*/const o$2={attribute:true,type:String,converter:u$1,reflect:false,hasChanged:f$1},r$2=(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$2(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)}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @license
|
|
81
|
+
* Copyright 2017 Google LLC
|
|
82
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
83
|
+
*/function r$1(r){return n$1({...r,state:true,attribute:false})}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @license
|
|
87
|
+
* Copyright 2017 Google LLC
|
|
88
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
89
|
+
*/
|
|
90
|
+
const e$2=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @license
|
|
94
|
+
* Copyright 2017 Google LLC
|
|
95
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
96
|
+
*/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)}})}}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A panel presented for a step in a wizard-like workflow.
|
|
100
|
+
*
|
|
101
|
+
* @description
|
|
102
|
+
* The `m3e-step-panel` is a container for presenting contextual content and actions
|
|
103
|
+
* associated with a single step in a structured workflow.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* The following example demonstrates a linear multi-step form flow using the `m3e-stepper`
|
|
107
|
+
* component. Each `m3e-step` defines a navigable step label, linked to its corresponding
|
|
108
|
+
* `m3e-step-panel` via the `for` attribute. Navigation is orchestrated using the
|
|
109
|
+
* `m3e-stepper-next`, `m3e-stepper-previous`, and `m3e-stepper-reset` components.
|
|
110
|
+
*
|
|
111
|
+
* <m3e-stepper>
|
|
112
|
+
* <m3e-step for="step1">Fill out your name</m3e-step>
|
|
113
|
+
* <m3e-step for="step2">Fill out your address</m3e-step>
|
|
114
|
+
* <m3e-step for="step3">Done</m3e-step>
|
|
115
|
+
* <m3e-step-panel id="step1">
|
|
116
|
+
* <form>
|
|
117
|
+
* <m3e-form-field>
|
|
118
|
+
* <label slot="label" for="name">Name</label>
|
|
119
|
+
* <input name="name" id="name" required />
|
|
120
|
+
* </m3e-form-field>
|
|
121
|
+
* </form>
|
|
122
|
+
* <div slot="actions">
|
|
123
|
+
* <m3e-button><m3e-stepper-next>Next</m3e-stepper-next></m3e-button>
|
|
124
|
+
* </div>
|
|
125
|
+
* </m3e-step-panel>
|
|
126
|
+
* <m3e-step-panel id="step2">
|
|
127
|
+
* <form>
|
|
128
|
+
* <m3e-form-field>
|
|
129
|
+
* <label slot="label" for="address">Address</label>
|
|
130
|
+
* <input name="address" id="address" required />
|
|
131
|
+
* </m3e-form-field>
|
|
132
|
+
* </form>
|
|
133
|
+
* <div slot="actions">
|
|
134
|
+
* <m3e-button><m3e-stepper-previous>Back</m3e-stepper-previous></m3e-button>
|
|
135
|
+
* <m3e-button><m3e-stepper-next>Next</m3e-stepper-next></m3e-button>
|
|
136
|
+
* </div>
|
|
137
|
+
* </m3e-step-panel>
|
|
138
|
+
* <m3e-step-panel id="step3">Done
|
|
139
|
+
* <div slot="actions">
|
|
140
|
+
* <m3e-button><m3e-stepper-previous>Back</m3e-stepper-previous></m3e-button>
|
|
141
|
+
* <m3e-button><m3e-stepper-reset>Reset</m3e-stepper-reset></m3e-button>
|
|
142
|
+
* </div>
|
|
143
|
+
* </m3e-step-panel>
|
|
144
|
+
* </m3e-stepper>
|
|
145
|
+
*
|
|
146
|
+
* @tag m3e-step-panel
|
|
147
|
+
*
|
|
148
|
+
* @slot - Renders the content of the panel.
|
|
149
|
+
* @slot actions- Renders the actions bar of the panel.
|
|
150
|
+
*
|
|
151
|
+
* @cssprop --m3e-step-panel-padding - Padding inside the step panel container, defining internal spacing around content.
|
|
152
|
+
* @cssprop --m3e-step-panel-spacing - Vertical gap between stacked elements within the step panel.
|
|
153
|
+
* @cssprop --m3e-step-panel-actions-height - Minimum height of the slotted actions container.
|
|
154
|
+
*/
|
|
155
|
+
let M3eStepPanelElement = class M3eStepPanelElement extends LitElement {
|
|
156
|
+
constructor() {
|
|
157
|
+
super(...arguments);
|
|
158
|
+
/** @internal */
|
|
159
|
+
this.active = false;
|
|
160
|
+
}
|
|
161
|
+
/** @inheritdoc */
|
|
162
|
+
connectedCallback() {
|
|
163
|
+
this.role = this.role || "tabpanel";
|
|
164
|
+
this.slot = "panel";
|
|
165
|
+
super.connectedCallback();
|
|
166
|
+
}
|
|
167
|
+
/** @inheritdoc */
|
|
168
|
+
render() {
|
|
169
|
+
return html `<m3e-collapsible ?open=${this.active}>
|
|
170
|
+
<div class="content">
|
|
171
|
+
<div><slot></slot></div>
|
|
172
|
+
<slot name="actions"></slot>
|
|
173
|
+
</div>
|
|
174
|
+
</m3e-collapsible>`;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
/** The styles of the element. */
|
|
178
|
+
M3eStepPanelElement.styles = css `
|
|
179
|
+
:host {
|
|
180
|
+
display: block;
|
|
181
|
+
}
|
|
182
|
+
.content {
|
|
183
|
+
display: flex;
|
|
184
|
+
flex-direction: column;
|
|
185
|
+
padding: var(--m3e-step-panel-padding, 1rem 1.5rem 1.5rem 1.5rem);
|
|
186
|
+
row-gap: var(--m3e-step-panel-spacing, 0.5rem);
|
|
187
|
+
}
|
|
188
|
+
::slotted([slot="actions"]) {
|
|
189
|
+
flex: none;
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: center;
|
|
192
|
+
min-height: var(--m3e-step-panel-actions-height, 3rem);
|
|
193
|
+
}
|
|
194
|
+
::slotted([slot="actions"][end]) {
|
|
195
|
+
justify-content: flex-end;
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
198
|
+
__decorate([
|
|
199
|
+
r$1()
|
|
200
|
+
], M3eStepPanelElement.prototype, "active", void 0);
|
|
201
|
+
M3eStepPanelElement = __decorate([
|
|
202
|
+
t$2("m3e-step-panel")
|
|
203
|
+
], M3eStepPanelElement);
|
|
204
|
+
|
|
205
|
+
var _M3eStepElement_instances, _M3eStepElement_clickHandler, _M3eStepElement_renderIcon, _M3eStepElement_handleClick;
|
|
206
|
+
var M3eStepElement_1;
|
|
207
|
+
/**
|
|
208
|
+
* A step in a wizard-like workflow.
|
|
209
|
+
*
|
|
210
|
+
* @description
|
|
211
|
+
* The `m3e-step` component represents a single step in a structured, wizard-like workflow.
|
|
212
|
+
* It supports semantic labeling, stateful styling, and optional interaction for completed,
|
|
213
|
+
* selected, invalid, or disabled states. It aligns with Material Design guidance for progressive
|
|
214
|
+
* disclosure, accessible navigation, and visual continuity across horizontal and vertical layouts.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* The following example demonstrates a linear multi-step form flow using the `m3e-stepper`
|
|
218
|
+
* component. Each `m3e-step` defines a navigable step label, linked to its corresponding
|
|
219
|
+
* `m3e-step-panel` via the `for` attribute. Navigation is orchestrated using the
|
|
220
|
+
* `m3e-stepper-next`, `m3e-stepper-previous`, and `m3e-stepper-reset` components.
|
|
221
|
+
*
|
|
222
|
+
* <m3e-stepper>
|
|
223
|
+
* <m3e-step for="step1">Fill out your name</m3e-step>
|
|
224
|
+
* <m3e-step for="step2">Fill out your address</m3e-step>
|
|
225
|
+
* <m3e-step for="step3">Done</m3e-step>
|
|
226
|
+
* <m3e-step-panel id="step1">
|
|
227
|
+
* <form>
|
|
228
|
+
* <m3e-form-field>
|
|
229
|
+
* <label slot="label" for="name">Name</label>
|
|
230
|
+
* <input name="name" id="name" required />
|
|
231
|
+
* </m3e-form-field>
|
|
232
|
+
* </form>
|
|
233
|
+
* <div slot="actions">
|
|
234
|
+
* <m3e-button><m3e-stepper-next>Next</m3e-stepper-next></m3e-button>
|
|
235
|
+
* </div>
|
|
236
|
+
* </m3e-step-panel>
|
|
237
|
+
* <m3e-step-panel id="step2">
|
|
238
|
+
* <form>
|
|
239
|
+
* <m3e-form-field>
|
|
240
|
+
* <label slot="label" for="address">Address</label>
|
|
241
|
+
* <input name="address" id="address" required />
|
|
242
|
+
* </m3e-form-field>
|
|
243
|
+
* </form>
|
|
244
|
+
* <div slot="actions">
|
|
245
|
+
* <m3e-button><m3e-stepper-previous>Back</m3e-stepper-previous></m3e-button>
|
|
246
|
+
* <m3e-button><m3e-stepper-next>Next</m3e-stepper-next></m3e-button>
|
|
247
|
+
* </div>
|
|
248
|
+
* </m3e-step-panel>
|
|
249
|
+
* <m3e-step-panel id="step3">Done
|
|
250
|
+
* <div slot="actions">
|
|
251
|
+
* <m3e-button><m3e-stepper-previous>Back</m3e-stepper-previous></m3e-button>
|
|
252
|
+
* <m3e-button><m3e-stepper-reset>Reset</m3e-stepper-reset></m3e-button>
|
|
253
|
+
* </div>
|
|
254
|
+
* </m3e-step-panel>
|
|
255
|
+
* </m3e-stepper>
|
|
256
|
+
*
|
|
257
|
+
* @tag m3e-step
|
|
258
|
+
*
|
|
259
|
+
* @slot - Renders the label of the step.
|
|
260
|
+
* @slot icon - Renders the icon of the step.
|
|
261
|
+
* @slot done-icon - Renders the icon of a completed step.
|
|
262
|
+
* @slot edit-icon - Renders the icon of a completed editable step.
|
|
263
|
+
* @slot error-icon - Renders icon of an invalid step.
|
|
264
|
+
* @slot hint - Renders the hint text of the step.
|
|
265
|
+
* @slot error - Renders the error message for an invalid step.
|
|
266
|
+
*
|
|
267
|
+
* @attr completed - Whether the step has been completed.
|
|
268
|
+
* @attr disabled - Whether the element is disabled.
|
|
269
|
+
* @attr editable - Whether the step is editable and users can return to it after completion.
|
|
270
|
+
* @attr for - The identifier of the interactive control to which this element is attached.
|
|
271
|
+
* @attr optional - Whether the step is optional.
|
|
272
|
+
* @attr selected - Whether the element is selected.
|
|
273
|
+
*
|
|
274
|
+
* @fires input - Emitted when the selected state changes.
|
|
275
|
+
* @fires change - Emitted when the selected state changes.
|
|
276
|
+
* @fires click - Emitted when the element is clicked.
|
|
277
|
+
*
|
|
278
|
+
* @cssprop --m3e-step-shape - Border radius of the step container, defining its visual shape.
|
|
279
|
+
* @cssprop --m3e-step-padding - Internal padding of the step container, used for layout spacing.
|
|
280
|
+
* @cssprop --m3e-step-icon-shape - Border radius of the icon container, controlling its geometric form.
|
|
281
|
+
* @cssprop --m3e-step-icon-size - Width and height of the icon container and icon glyph.
|
|
282
|
+
* @cssprop --m3e-step-selected-icon-container-color - Background color of the icon when the step is selected.
|
|
283
|
+
* @cssprop --m3e-step-selected-icon-color - Foreground color of the icon when the step is selected.
|
|
284
|
+
* @cssprop --m3e-step-completed-icon-container-color - Background color of the icon when the step is completed.
|
|
285
|
+
* @cssprop --m3e-step-completed-icon-color - Foreground color of the icon when the step is completed.
|
|
286
|
+
* @cssprop --m3e-step-unselected-icon-container-color - Background color of the icon when the step is inactive.
|
|
287
|
+
* @cssprop --m3e-step-unselected-icon-color - Foreground color of the icon when the step is inactive.
|
|
288
|
+
* @cssprop --m3e-step-icon-error-color - Foreground color of the icon when the step is invalid.
|
|
289
|
+
* @cssprop --m3e-step-disabled-icon-container-color - Base color used to mix the disabled icon background.
|
|
290
|
+
* @cssprop --m3e-step-disabled-icon-color - Base color used to mix the disabled icon foreground.
|
|
291
|
+
* @cssprop --m3e-step-label-color - Text color of the step label in its default state.
|
|
292
|
+
* @cssprop --m3e-step-label-error-color - Text color of the step label when the step is invalid.
|
|
293
|
+
* @cssprop --m3e-step-disabled-label-color - Base color used to mix the disabled label foreground.
|
|
294
|
+
* @cssprop --m3e-step-font-size - Font size of the step label.
|
|
295
|
+
* @cssprop --m3e-step-font-weight - Font weight of the step label.
|
|
296
|
+
* @cssprop --m3e-step-line-height - Line height of the step label.
|
|
297
|
+
* @cssprop --m3e-step-tracking - Letter spacing of the step label.
|
|
298
|
+
* @cssprop --m3e-step-icon-label-space - Gap between icon and label.
|
|
299
|
+
* @cssprop --m3e-step-hint-font-size - Font size of hint and error messages.
|
|
300
|
+
* @cssprop --m3e-step-hint-font-weight - Font weight of hint and error messages.
|
|
301
|
+
* @cssprop --m3e-step-hint-line-height - Line height of hint and error messages.
|
|
302
|
+
* @cssprop --m3e-step-hint-tracking - Letter spacing of hint and error messages.
|
|
303
|
+
* @cssprop --m3e-step-hint-color - Text color of hint messages in valid state.
|
|
304
|
+
* @cssprop --m3e-step-disabled-hint-color - Base color used to mix the disabled hint foreground.
|
|
305
|
+
*/
|
|
306
|
+
let M3eStepElement = M3eStepElement_1 = class M3eStepElement extends Selected(KeyboardClick(Focusable(HtmlFor(Disabled(AttachInternals(Role(LitElement, "tab"))))))) {
|
|
307
|
+
constructor() {
|
|
308
|
+
super(...arguments);
|
|
309
|
+
_M3eStepElement_instances.add(this);
|
|
310
|
+
/** @private */ _M3eStepElement_clickHandler.set(this, (e) => __classPrivateFieldGet(this, _M3eStepElement_instances, "m", _M3eStepElement_handleClick).call(this, e));
|
|
311
|
+
/**
|
|
312
|
+
* Whether the step is optional.
|
|
313
|
+
* @default false
|
|
314
|
+
*/
|
|
315
|
+
this.optional = false;
|
|
316
|
+
/**
|
|
317
|
+
* Whether the step is editable and users can return to it after completion.
|
|
318
|
+
* @default false
|
|
319
|
+
*/
|
|
320
|
+
this.editable = false;
|
|
321
|
+
/**
|
|
322
|
+
* Whether the step has been completed.
|
|
323
|
+
* @default false
|
|
324
|
+
*/
|
|
325
|
+
this.completed = false;
|
|
326
|
+
/**
|
|
327
|
+
* Whether the step has an error.
|
|
328
|
+
* @default false
|
|
329
|
+
*/
|
|
330
|
+
this.invalid = false;
|
|
331
|
+
/** @internal */
|
|
332
|
+
this.index = -1;
|
|
333
|
+
}
|
|
334
|
+
/** A reference to the panel controlled by the step. */
|
|
335
|
+
get panel() {
|
|
336
|
+
return this.control instanceof M3eStepPanelElement ? this.control : null;
|
|
337
|
+
}
|
|
338
|
+
/** The stepper to which this step belongs. */
|
|
339
|
+
get stepper() {
|
|
340
|
+
return this.closest("m3e-stepper");
|
|
341
|
+
}
|
|
342
|
+
/** Resets the step to its initial state, clearing any form data. */
|
|
343
|
+
reset() {
|
|
344
|
+
this.invalid = false;
|
|
345
|
+
this.completed = false;
|
|
346
|
+
this.panel?.querySelector("form")?.reset();
|
|
347
|
+
}
|
|
348
|
+
/** @inheritdoc */
|
|
349
|
+
attach(control) {
|
|
350
|
+
if (control instanceof M3eStepPanelElement) {
|
|
351
|
+
control.id = control.id || `m3e-step-panel-${M3eStepElement_1.__nextId++}`;
|
|
352
|
+
addAriaReferencedId(this, "aria-controls", control.id);
|
|
353
|
+
}
|
|
354
|
+
super.attach(control);
|
|
355
|
+
}
|
|
356
|
+
/** @inheritdoc */
|
|
357
|
+
detach() {
|
|
358
|
+
if (this.control?.id) {
|
|
359
|
+
removeAriaReferencedId(this, "aria-controls", this.control.id);
|
|
360
|
+
}
|
|
361
|
+
super.detach();
|
|
362
|
+
}
|
|
363
|
+
/** @inheritdoc */
|
|
364
|
+
connectedCallback() {
|
|
365
|
+
this.slot = "step";
|
|
366
|
+
super.connectedCallback();
|
|
367
|
+
this.addEventListener("click", __classPrivateFieldGet(this, _M3eStepElement_clickHandler, "f"));
|
|
368
|
+
}
|
|
369
|
+
/** @inheritdoc */
|
|
370
|
+
disconnectedCallback() {
|
|
371
|
+
super.disconnectedCallback();
|
|
372
|
+
this.removeEventListener("click", __classPrivateFieldGet(this, _M3eStepElement_clickHandler, "f"));
|
|
373
|
+
}
|
|
374
|
+
/** @inheritdoc */
|
|
375
|
+
update(changedProperties) {
|
|
376
|
+
super.update(changedProperties);
|
|
377
|
+
if (changedProperties.has("selected")) {
|
|
378
|
+
this.closest("m3e-stepper")?.[selectionManager].notifySelectionChange(this);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/** @inheritdoc */
|
|
382
|
+
firstUpdated(_changedProperties) {
|
|
383
|
+
super.firstUpdated(_changedProperties);
|
|
384
|
+
[this._focusRing, this._stateLayer, this._ripple].forEach((x) => x?.attach(this));
|
|
385
|
+
}
|
|
386
|
+
/** @inheritdoc */
|
|
387
|
+
render() {
|
|
388
|
+
const hint = html `<slot name="hint">${this.optional ? html `<span class="hint">(Optional)</span>` : nothing}</slot>`;
|
|
389
|
+
const error = html `<slot name="error">${hint}</slot>`;
|
|
390
|
+
return html ` <m3e-state-layer class="state-layer" ?disabled="${this.disabled}"></m3e-state-layer>
|
|
391
|
+
<m3e-focus-ring class="focus-ring" ?disabled="${this.disabled}"></m3e-focus-ring>
|
|
392
|
+
<m3e-ripple class="ripple" ?disabled="${this.disabled}"></m3e-ripple>
|
|
393
|
+
<div class="wrapper">
|
|
394
|
+
<div class="icon" aria-hidden="true">${__classPrivateFieldGet(this, _M3eStepElement_instances, "m", _M3eStepElement_renderIcon).call(this)}</div>
|
|
395
|
+
<div class="label">
|
|
396
|
+
<slot></slot>
|
|
397
|
+
${this.invalid ? error : hint}
|
|
398
|
+
</div>
|
|
399
|
+
</div>`;
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
_M3eStepElement_clickHandler = new WeakMap();
|
|
403
|
+
_M3eStepElement_instances = new WeakSet();
|
|
404
|
+
_M3eStepElement_renderIcon = function _M3eStepElement_renderIcon() {
|
|
405
|
+
if (!this.selected) {
|
|
406
|
+
if (this.invalid) {
|
|
407
|
+
return html `<slot name="error-icon">
|
|
408
|
+
<svg viewBox="0 -960 960 960" fill="currentColor">
|
|
409
|
+
<path
|
|
410
|
+
d="m40-120 440-760 440 760H40Zm138-80h604L480-720 178-200Zm302-40q17 0 28.5-11.5T520-280q0-17-11.5-28.5T480-320q-17 0-28.5 11.5T440-280q0 17 11.5 28.5T480-240Zm-40-120h80v-200h-80v200Zm40-100Z"
|
|
411
|
+
/>
|
|
412
|
+
</svg>
|
|
413
|
+
</slot>`;
|
|
414
|
+
}
|
|
415
|
+
if (this.completed) {
|
|
416
|
+
if (this.editable) {
|
|
417
|
+
return html `<slot name="edit-icon">
|
|
418
|
+
<svg viewBox="0 -960 960 960" fill="currentColor">
|
|
419
|
+
<path
|
|
420
|
+
d="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"
|
|
421
|
+
/>
|
|
422
|
+
</svg>
|
|
423
|
+
</slot>`;
|
|
424
|
+
}
|
|
425
|
+
return html `<slot name="done-icon">
|
|
426
|
+
<svg viewBox="0 -960 960 960" fill="currentColor">
|
|
427
|
+
<path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z" />
|
|
428
|
+
</svg>
|
|
429
|
+
</slot>`;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return html `<slot name="icon">${this.index + 1}</slot>`;
|
|
433
|
+
};
|
|
434
|
+
_M3eStepElement_handleClick = function _M3eStepElement_handleClick(e) {
|
|
435
|
+
if (this.disabled) {
|
|
436
|
+
e.preventDefault();
|
|
437
|
+
e.stopImmediatePropagation();
|
|
438
|
+
}
|
|
439
|
+
if (e.defaultPrevented || this.selected)
|
|
440
|
+
return;
|
|
441
|
+
this.selected = true;
|
|
442
|
+
if (this.dispatchEvent(new Event("input", { bubbles: true, composed: true, cancelable: true }))) {
|
|
443
|
+
this.closest("m3e-stepper")?.moveTo(this.index);
|
|
444
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
this.selected = false;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
/** The styles of the element. */
|
|
451
|
+
M3eStepElement.styles = css `
|
|
452
|
+
:host {
|
|
453
|
+
display: block;
|
|
454
|
+
position: relative;
|
|
455
|
+
outline: none;
|
|
456
|
+
min-width: 0px;
|
|
457
|
+
border-radius: var(--m3e-step-shape, ${DesignToken.shape.corner.medium});
|
|
458
|
+
padding: var(--m3e-step-padding, 1.5rem);
|
|
459
|
+
}
|
|
460
|
+
:host(:not([aria-disabled="true"])) {
|
|
461
|
+
cursor: pointer;
|
|
462
|
+
user-select: none;
|
|
463
|
+
}
|
|
464
|
+
.icon {
|
|
465
|
+
flex: none;
|
|
466
|
+
display: flex;
|
|
467
|
+
align-items: center;
|
|
468
|
+
justify-content: center;
|
|
469
|
+
border-radius: var(--m3e-step-icon-shape, 50%);
|
|
470
|
+
width: var(--m3e-step-icon-size, 1.5rem);
|
|
471
|
+
height: var(--m3e-step-icon-size, 1.5rem);
|
|
472
|
+
}
|
|
473
|
+
.icon svg,
|
|
474
|
+
::slotted([slot="icon"]),
|
|
475
|
+
::slotted([slot="edit-icon"]),
|
|
476
|
+
::slotted([slot="done-icon"]),
|
|
477
|
+
::slotted([slot="error-icon"]) {
|
|
478
|
+
width: 1em;
|
|
479
|
+
font-size: var(--m3e-step-icon-size, 1.5rem) !important;
|
|
480
|
+
}
|
|
481
|
+
:host(:not([aria-disabled="true"])[selected]) .icon {
|
|
482
|
+
background-color: var(--m3e-step-selected-icon-container-color, ${DesignToken.color.primary});
|
|
483
|
+
color: var(--m3e-step-selected-icon-color, ${DesignToken.color.onPrimary});
|
|
484
|
+
}
|
|
485
|
+
:host(:not([aria-disabled="true"])[completed]:not([invalid])) .icon {
|
|
486
|
+
background-color: var(--m3e-step-completed-icon-container-color, ${DesignToken.color.primary});
|
|
487
|
+
color: var(--m3e-step-completed-icon-color, ${DesignToken.color.onPrimary});
|
|
488
|
+
}
|
|
489
|
+
:host(:not([aria-disabled="true"]):not([selected]):not([completed]):not([invalid])) .icon {
|
|
490
|
+
background-color: var(--m3e-step-unselected-icon-container-color, ${DesignToken.color.inverseSurface});
|
|
491
|
+
color: var(--m3e-step-unselected-icon-color, ${DesignToken.color.inverseOnSurface});
|
|
492
|
+
}
|
|
493
|
+
:host(:not([aria-disabled="true"]):not([selected])[invalid]) .icon {
|
|
494
|
+
color: var(--m3e-step-icon-error-color, ${DesignToken.color.error});
|
|
495
|
+
}
|
|
496
|
+
:host([aria-disabled="true"]) .icon {
|
|
497
|
+
background-color: color-mix(
|
|
498
|
+
in srgb,
|
|
499
|
+
var(--m3e-step-disabled-icon-container-color, ${DesignToken.color.onSurface}) 10%,
|
|
500
|
+
transparent
|
|
501
|
+
);
|
|
502
|
+
color: color-mix(in srgb, var(--m3e-step-disabled-icon-color, ${DesignToken.color.onSurface}) 38%, transparent);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
:host(:not([aria-disabled="true"])) .label {
|
|
506
|
+
color: var(--m3e-step-label-color, ${DesignToken.color.onSurface});
|
|
507
|
+
}
|
|
508
|
+
:host(:not([aria-disabled="true"]):not([selected])[invalid]) .label {
|
|
509
|
+
color: var(--m3e-step-label-error-color, ${DesignToken.color.error});
|
|
510
|
+
}
|
|
511
|
+
:host([aria-disabled="true"]) .label {
|
|
512
|
+
color: color-mix(in srgb, var(--m3e-step-disabled-label-color, ${DesignToken.color.onSurface}) 38%, transparent);
|
|
513
|
+
}
|
|
514
|
+
.wrapper {
|
|
515
|
+
display: flex;
|
|
516
|
+
align-items: center;
|
|
517
|
+
height: 100%;
|
|
518
|
+
border-radius: inherit;
|
|
519
|
+
font-size: var(--m3e-step-font-size, ${DesignToken.typescale.standard.title.small.fontSize});
|
|
520
|
+
font-weight: var(--m3e-step-font-weight, ${DesignToken.typescale.standard.title.small.fontWeight});
|
|
521
|
+
line-height: var(--m3e-step-line-height, ${DesignToken.typescale.standard.title.small.lineHeight});
|
|
522
|
+
letter-spacing: var(--m3e-step-tracking, ${DesignToken.typescale.standard.title.small.tracking});
|
|
523
|
+
flex-direction: var(--_step-direction, row);
|
|
524
|
+
gap: var(--m3e-step-icon-label-space, 0.5rem);
|
|
525
|
+
justify-content: flex-start;
|
|
526
|
+
}
|
|
527
|
+
.label {
|
|
528
|
+
display: flex;
|
|
529
|
+
flex-direction: column;
|
|
530
|
+
align-items: var(--_step-label-align-items, flex-start);
|
|
531
|
+
}
|
|
532
|
+
::slotted([slot="hint"]),
|
|
533
|
+
.hint,
|
|
534
|
+
::slotted([slot="error"]) {
|
|
535
|
+
font-size: var(--m3e-step-hint-font-size, ${DesignToken.typescale.standard.body.small.fontSize});
|
|
536
|
+
font-weight: var(--m3e-step-hint-font-weight, ${DesignToken.typescale.standard.body.small.fontWeight});
|
|
537
|
+
line-height: var(--m3e-step-hint-line-height, ${DesignToken.typescale.standard.body.small.lineHeight});
|
|
538
|
+
letter-spacing: var(--m3e-step-hint-tracking, ${DesignToken.typescale.standard.body.small.tracking});
|
|
539
|
+
}
|
|
540
|
+
:host(:not([aria-disabled="true"]):not([invalid])) ::slotted([slot="hint"]),
|
|
541
|
+
:host(:not([aria-disabled="true"]):not([invalid])) .hint {
|
|
542
|
+
color: var(--m3e-step-hint-color, ${DesignToken.color.onSurfaceVariant});
|
|
543
|
+
}
|
|
544
|
+
:host([aria-disabled="true"]) ::slotted([slot="hint"]),
|
|
545
|
+
:host([aria-disabled="true"]) .hint {
|
|
546
|
+
color: color-mix(in srgb, var(--m3e-step-disabled-hint-color, ${DesignToken.color.onSurface}) 38%, transparent);
|
|
547
|
+
}
|
|
548
|
+
`;
|
|
549
|
+
/** @private */ M3eStepElement.__nextId = 0;
|
|
550
|
+
__decorate([
|
|
551
|
+
e$1(".focus-ring")
|
|
552
|
+
], M3eStepElement.prototype, "_focusRing", void 0);
|
|
553
|
+
__decorate([
|
|
554
|
+
e$1(".state-layer")
|
|
555
|
+
], M3eStepElement.prototype, "_stateLayer", void 0);
|
|
556
|
+
__decorate([
|
|
557
|
+
e$1(".ripple")
|
|
558
|
+
], M3eStepElement.prototype, "_ripple", void 0);
|
|
559
|
+
__decorate([
|
|
560
|
+
n$1({ type: Boolean, reflect: true })
|
|
561
|
+
], M3eStepElement.prototype, "optional", void 0);
|
|
562
|
+
__decorate([
|
|
563
|
+
n$1({ type: Boolean, reflect: true })
|
|
564
|
+
], M3eStepElement.prototype, "editable", void 0);
|
|
565
|
+
__decorate([
|
|
566
|
+
n$1({ type: Boolean, reflect: true })
|
|
567
|
+
], M3eStepElement.prototype, "completed", void 0);
|
|
568
|
+
__decorate([
|
|
569
|
+
n$1({ type: Boolean, reflect: true })
|
|
570
|
+
], M3eStepElement.prototype, "invalid", void 0);
|
|
571
|
+
__decorate([
|
|
572
|
+
r$1()
|
|
573
|
+
], M3eStepElement.prototype, "index", void 0);
|
|
574
|
+
M3eStepElement = M3eStepElement_1 = __decorate([
|
|
575
|
+
t$2("m3e-step")
|
|
576
|
+
], M3eStepElement);
|
|
577
|
+
|
|
578
|
+
var _StepperButtonElementBase_instances, _StepperButtonElementBase_clickHandler, _StepperButtonElementBase_action, _StepperButtonElementBase_handleClick;
|
|
579
|
+
/** A base implementation for a button used to move to a step in a stepper. This class must be inherited. */
|
|
580
|
+
class StepperButtonElementBase extends AttachInternals(LitElement) {
|
|
581
|
+
constructor(action) {
|
|
582
|
+
super();
|
|
583
|
+
_StepperButtonElementBase_instances.add(this);
|
|
584
|
+
/** @private */ _StepperButtonElementBase_clickHandler.set(this, (e) => __classPrivateFieldGet(this, _StepperButtonElementBase_instances, "m", _StepperButtonElementBase_handleClick).call(this, e));
|
|
585
|
+
/** @private */ _StepperButtonElementBase_action.set(this, void 0);
|
|
586
|
+
__classPrivateFieldSet(this, _StepperButtonElementBase_action, action, "f");
|
|
587
|
+
}
|
|
588
|
+
/** @inheritdoc */
|
|
589
|
+
connectedCallback() {
|
|
590
|
+
this.role = this.role || "none";
|
|
591
|
+
super.connectedCallback();
|
|
592
|
+
this.parentElement?.addEventListener("click", __classPrivateFieldGet(this, _StepperButtonElementBase_clickHandler, "f"));
|
|
593
|
+
}
|
|
594
|
+
/** @inheritdoc */
|
|
595
|
+
disconnectedCallback() {
|
|
596
|
+
super.disconnectedCallback();
|
|
597
|
+
this.parentElement?.removeEventListener("click", __classPrivateFieldGet(this, _StepperButtonElementBase_clickHandler, "f"));
|
|
598
|
+
}
|
|
599
|
+
/** @inheritdoc */
|
|
600
|
+
render() {
|
|
601
|
+
return html `<slot></slot>`;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
_StepperButtonElementBase_clickHandler = new WeakMap(), _StepperButtonElementBase_action = new WeakMap(), _StepperButtonElementBase_instances = new WeakSet(), _StepperButtonElementBase_handleClick = function _StepperButtonElementBase_handleClick(e) {
|
|
605
|
+
if (!e.defaultPrevented) {
|
|
606
|
+
switch (__classPrivateFieldGet(this, _StepperButtonElementBase_action, "f")) {
|
|
607
|
+
case "next":
|
|
608
|
+
this.closest("m3e-stepper")?.moveNext();
|
|
609
|
+
break;
|
|
610
|
+
case "previous":
|
|
611
|
+
this.closest("m3e-stepper")?.movePrevious();
|
|
612
|
+
break;
|
|
613
|
+
case "reset":
|
|
614
|
+
this.closest("m3e-stepper")?.reset();
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
/** The styles of the element. */
|
|
620
|
+
StepperButtonElementBase.styles = css `
|
|
621
|
+
:host {
|
|
622
|
+
display: contents;
|
|
623
|
+
}
|
|
624
|
+
::slotted(.material-icons) {
|
|
625
|
+
font-size: inherit !important;
|
|
626
|
+
}
|
|
627
|
+
`;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* @license
|
|
631
|
+
* Copyright 2017 Google LLC
|
|
632
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
633
|
+
*/
|
|
634
|
+
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");
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* @license
|
|
638
|
+
* Copyright 2018 Google LLC
|
|
639
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
640
|
+
*/const o=o=>o??E;
|
|
641
|
+
|
|
642
|
+
var _M3eStepperElement_instances, _M3eStepperElement_breakpointUnobserve, _M3eStepperElement_renderHeader, _M3eStepperElement_handleChange, _M3eStepperElement_handleSlotChange, _M3eStepperElement_handleKeyDown, _M3eStepperElement_handleSelectedChange, _M3eStepperElement_checkValidity, _M3eStepperElement_updateDisplayOrder, _a;
|
|
643
|
+
/**
|
|
644
|
+
* Provides a wizard-like workflow by dividing content into logical steps.
|
|
645
|
+
*
|
|
646
|
+
* @description
|
|
647
|
+
* The `m3e-stepper` component orchestrates a structured, wizard-like workflow by dividing
|
|
648
|
+
* content into discrete, navigable steps. It supports horizontal and vertical orientations,
|
|
649
|
+
* linear progression, and configurable label and header positioning.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* The following example demonstrates a linear multi-step form flow using the `m3e-stepper`
|
|
653
|
+
* component. Each `m3e-step` defines a navigable step label, linked to its corresponding
|
|
654
|
+
* `m3e-step-panel` via the `for` attribute. Navigation is orchestrated using the
|
|
655
|
+
* `m3e-stepper-next`, `m3e-stepper-previous`, and `m3e-stepper-reset` components.
|
|
656
|
+
*
|
|
657
|
+
* <m3e-stepper>
|
|
658
|
+
* <m3e-step for="step1">Fill out your name</m3e-step>
|
|
659
|
+
* <m3e-step for="step2">Fill out your address</m3e-step>
|
|
660
|
+
* <m3e-step for="step3">Done</m3e-step>
|
|
661
|
+
* <m3e-step-panel id="step1">
|
|
662
|
+
* <form>
|
|
663
|
+
* <m3e-form-field>
|
|
664
|
+
* <label slot="label" for="name">Name</label>
|
|
665
|
+
* <input name="name" id="name" required />
|
|
666
|
+
* </m3e-form-field>
|
|
667
|
+
* </form>
|
|
668
|
+
* <div slot="actions">
|
|
669
|
+
* <m3e-button><m3e-stepper-next>Next</m3e-stepper-next></m3e-button>
|
|
670
|
+
* </div>
|
|
671
|
+
* </m3e-step-panel>
|
|
672
|
+
* <m3e-step-panel id="step2">
|
|
673
|
+
* <form>
|
|
674
|
+
* <m3e-form-field>
|
|
675
|
+
* <label slot="label" for="address">Address</label>
|
|
676
|
+
* <input name="address" id="address" required />
|
|
677
|
+
* </m3e-form-field>
|
|
678
|
+
* </form>
|
|
679
|
+
* <div slot="actions">
|
|
680
|
+
* <m3e-button><m3e-stepper-previous>Back</m3e-stepper-previous></m3e-button>
|
|
681
|
+
* <m3e-button><m3e-stepper-next>Next</m3e-stepper-next></m3e-button>
|
|
682
|
+
* </div>
|
|
683
|
+
* </m3e-step-panel>
|
|
684
|
+
* <m3e-step-panel id="step3">Done
|
|
685
|
+
* <div slot="actions">
|
|
686
|
+
* <m3e-button><m3e-stepper-previous>Back</m3e-stepper-previous></m3e-button>
|
|
687
|
+
* <m3e-button><m3e-stepper-reset>Reset</m3e-stepper-reset></m3e-button>
|
|
688
|
+
* </div>
|
|
689
|
+
* </m3e-step-panel>
|
|
690
|
+
* </m3e-stepper>
|
|
691
|
+
*
|
|
692
|
+
* @tag m3e-stepper
|
|
693
|
+
*
|
|
694
|
+
* @attr header-position - The position of the step header, when oriented horizontally.
|
|
695
|
+
* @attr label-position - The position of the step labels, when oriented horizontally.
|
|
696
|
+
* @attr linear - Whether the validity of previous steps should be checked or not.
|
|
697
|
+
* @attr orientation - The orientation of the stepper.
|
|
698
|
+
*
|
|
699
|
+
* @slot step - Renders a step.
|
|
700
|
+
* @slot panel - Renders a panel.
|
|
701
|
+
*
|
|
702
|
+
* @fires change - Emitted when the selected step changes.
|
|
703
|
+
*
|
|
704
|
+
* @cssprop --m3e-step-divider-thickness - Thickness of the divider line between steps.
|
|
705
|
+
* @cssprop --m3e-step-divider-color - Color of the divider line between steps.
|
|
706
|
+
* @cssprop --m3e-step-divider-inset - Inset offset for divider alignment within step layout.
|
|
707
|
+
*/
|
|
708
|
+
let M3eStepperElement = class M3eStepperElement extends AttachInternals(LitElement) {
|
|
709
|
+
constructor() {
|
|
710
|
+
super(...arguments);
|
|
711
|
+
_M3eStepperElement_instances.add(this);
|
|
712
|
+
/** @private */ _M3eStepperElement_breakpointUnobserve.set(this, void 0);
|
|
713
|
+
/** @private */ this._selectedIndex = null;
|
|
714
|
+
/** @internal */ this[_a] = new SelectionManager()
|
|
715
|
+
.withHomeAndEnd()
|
|
716
|
+
.withWrap()
|
|
717
|
+
.onSelectedItemsChange(() => __classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_handleSelectedChange).call(this));
|
|
718
|
+
/**
|
|
719
|
+
* The position of the step header, when oriented horizontally.
|
|
720
|
+
* @default "above"
|
|
721
|
+
*/
|
|
722
|
+
this.headerPosition = "above";
|
|
723
|
+
/**
|
|
724
|
+
* The position of the step labels, when oriented horizontally.
|
|
725
|
+
* @default "end"
|
|
726
|
+
*/
|
|
727
|
+
this.labelPosition = "end";
|
|
728
|
+
/**
|
|
729
|
+
* Whether the validity of previous steps should be checked or not.
|
|
730
|
+
* @default false
|
|
731
|
+
*/
|
|
732
|
+
this.linear = false;
|
|
733
|
+
/**
|
|
734
|
+
* The orientation of the stepper.
|
|
735
|
+
* @default "horizontal"
|
|
736
|
+
*/
|
|
737
|
+
this.orientation = "horizontal";
|
|
738
|
+
}
|
|
739
|
+
/** The steps. */
|
|
740
|
+
get steps() {
|
|
741
|
+
return this[selectionManager]?.items ?? [];
|
|
742
|
+
}
|
|
743
|
+
/** The selected step. */
|
|
744
|
+
get selectedStep() {
|
|
745
|
+
return this._selectedIndex !== null ? (this.steps[this._selectedIndex] ?? null) : null;
|
|
746
|
+
}
|
|
747
|
+
/** The zero-based index of the selected step. */
|
|
748
|
+
get selectedIndex() {
|
|
749
|
+
return this._selectedIndex ?? -1;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Moves the stepper to the previous step.
|
|
753
|
+
* @returns {boolean} Whether the stepper moved to the previous step.
|
|
754
|
+
*/
|
|
755
|
+
movePrevious() {
|
|
756
|
+
return this.moveTo((this._selectedIndex ?? 1) - 1);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Moves the stepper to the next step.
|
|
760
|
+
* @returns {boolean} Whether the stepper moved to the next step.
|
|
761
|
+
*/
|
|
762
|
+
moveNext() {
|
|
763
|
+
return this.moveTo((this._selectedIndex ?? -1) + 1);
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Moves the stepper to the step with the specified index.
|
|
767
|
+
* @param index The zero-based index of the step to which to move.
|
|
768
|
+
* @returns {boolean} Whether the stepper moved to the specified `index`.
|
|
769
|
+
*/
|
|
770
|
+
moveTo(index) {
|
|
771
|
+
const selectedStep = this.selectedStep;
|
|
772
|
+
if (selectedStep && selectedStep.index === index) {
|
|
773
|
+
return true;
|
|
774
|
+
}
|
|
775
|
+
if (index >= 0 && index < this.steps.length) {
|
|
776
|
+
if (selectedStep) {
|
|
777
|
+
const valid = __classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_checkValidity).call(this);
|
|
778
|
+
if (this.linear) {
|
|
779
|
+
if (index < selectedStep.index) {
|
|
780
|
+
const previousStep = this[selectionManager].items[index];
|
|
781
|
+
if (!previousStep || (previousStep.completed && !previousStep.editable)) {
|
|
782
|
+
return false;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
else if (index > selectedStep.index + 1) {
|
|
786
|
+
const nextStep = this[selectionManager].items[index];
|
|
787
|
+
if (!nextStep || !nextStep.completed) {
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
else if (!valid && !selectedStep.optional) {
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
selectedStep.completed = true;
|
|
796
|
+
}
|
|
797
|
+
this._selectedIndex = index;
|
|
798
|
+
this[selectionManager].select(this.selectedStep);
|
|
799
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
800
|
+
return true;
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
if (selectedStep) {
|
|
804
|
+
this[selectionManager].deselect(selectedStep);
|
|
805
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
806
|
+
}
|
|
807
|
+
return false;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
/** Resets the stepper to its initial state, clearing any form data. */
|
|
811
|
+
reset() {
|
|
812
|
+
this.steps.forEach((x) => x.reset());
|
|
813
|
+
const firstStep = this.steps.find((x) => !x.disabled);
|
|
814
|
+
if (firstStep) {
|
|
815
|
+
this.moveTo(this.steps.indexOf(firstStep));
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
this.moveTo(-1);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
/** @inheritdoc */
|
|
822
|
+
connectedCallback() {
|
|
823
|
+
this.role = this.role || "none";
|
|
824
|
+
super.connectedCallback();
|
|
825
|
+
this.classList.toggle("-no-animate", true);
|
|
826
|
+
}
|
|
827
|
+
/** @inheritdoc */
|
|
828
|
+
disconnectedCallback() {
|
|
829
|
+
super.disconnectedCallback();
|
|
830
|
+
this._orientation = undefined;
|
|
831
|
+
__classPrivateFieldGet(this, _M3eStepperElement_breakpointUnobserve, "f")?.call(this);
|
|
832
|
+
}
|
|
833
|
+
/** @inheritdoc */
|
|
834
|
+
update(changedProperties) {
|
|
835
|
+
super.update(changedProperties);
|
|
836
|
+
if (changedProperties.has("orientation")) {
|
|
837
|
+
__classPrivateFieldGet(this, _M3eStepperElement_breakpointUnobserve, "f")?.call(this);
|
|
838
|
+
if (this.orientation === "auto") {
|
|
839
|
+
__classPrivateFieldSet(this, _M3eStepperElement_breakpointUnobserve, M3eBreakpointObserver.observe([Breakpoint.XSmall], (matches) => {
|
|
840
|
+
this._orientation = matches.get(Breakpoint.XSmall) ? "vertical" : "horizontal";
|
|
841
|
+
__classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_updateDisplayOrder).call(this);
|
|
842
|
+
}), "f");
|
|
843
|
+
}
|
|
844
|
+
else {
|
|
845
|
+
__classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_updateDisplayOrder).call(this);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
if (changedProperties.has("_orientation")) {
|
|
849
|
+
__classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_updateDisplayOrder).call(this);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
/** @inheritdoc */
|
|
853
|
+
render() {
|
|
854
|
+
let panelIndex = null;
|
|
855
|
+
if (this.selectedStep?.panel) {
|
|
856
|
+
panelIndex = [...this.querySelectorAll("[slot='panel']")].indexOf(this.selectedStep.panel);
|
|
857
|
+
if (panelIndex === -1) {
|
|
858
|
+
panelIndex = null;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
if (!this[selectionManager].vertical) {
|
|
862
|
+
return html `${this.headerPosition === "above" ? __classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_renderHeader).call(this) : nothing}
|
|
863
|
+
<m3e-slide class="steps" .selectedIndex="${panelIndex}">
|
|
864
|
+
<slot name="panel"></slot>
|
|
865
|
+
</m3e-slide>
|
|
866
|
+
${this.headerPosition === "below" ? __classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_renderHeader).call(this) : nothing}`;
|
|
867
|
+
}
|
|
868
|
+
return html `${__classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_renderHeader).call(this)} <slot name="panel"></slot>`;
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
_M3eStepperElement_breakpointUnobserve = new WeakMap();
|
|
872
|
+
_M3eStepperElement_instances = new WeakSet();
|
|
873
|
+
_a = selectionManager;
|
|
874
|
+
_M3eStepperElement_renderHeader = function _M3eStepperElement_renderHeader() {
|
|
875
|
+
return html `<div
|
|
876
|
+
class="header"
|
|
877
|
+
role="tablist"
|
|
878
|
+
aria-orientation="${o(this[selectionManager].vertical ? "vertical" : undefined)}"
|
|
879
|
+
@change="${__classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_handleChange)}"
|
|
880
|
+
>
|
|
881
|
+
<slot name="step" @slotchange="${__classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_handleSlotChange)}" @keydown="${__classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_handleKeyDown)}"></slot>
|
|
882
|
+
</div>`;
|
|
883
|
+
};
|
|
884
|
+
_M3eStepperElement_handleChange = function _M3eStepperElement_handleChange(e) {
|
|
885
|
+
e.stopPropagation();
|
|
886
|
+
// Note: change event emitted from moveTo.
|
|
887
|
+
};
|
|
888
|
+
_M3eStepperElement_handleSlotChange = function _M3eStepperElement_handleSlotChange() {
|
|
889
|
+
const { added, removed } = this[selectionManager].setItems([...this.querySelectorAll("m3e-step")]);
|
|
890
|
+
if (added.length > 0 || removed.length > 0) {
|
|
891
|
+
this.querySelectorAll(".-m3e-step-divider").forEach((x) => x.remove());
|
|
892
|
+
for (let i = 0; i < this[selectionManager].items.length; i++) {
|
|
893
|
+
const step = this[selectionManager].items[i];
|
|
894
|
+
step.index = i;
|
|
895
|
+
if (i > 0) {
|
|
896
|
+
const divider = document.createElement("div");
|
|
897
|
+
divider.ariaHidden = "true";
|
|
898
|
+
divider.classList.add("-m3e-step-divider");
|
|
899
|
+
divider.slot = "step";
|
|
900
|
+
step.insertAdjacentElement("beforebegin", divider);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
__classPrivateFieldGet(this, _M3eStepperElement_instances, "m", _M3eStepperElement_updateDisplayOrder).call(this);
|
|
904
|
+
if (this[selectionManager].selectedItems.length == 0) {
|
|
905
|
+
this[selectionManager].select(this[selectionManager].items.find((x) => !x.disabled));
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
_M3eStepperElement_handleKeyDown = function _M3eStepperElement_handleKeyDown(e) {
|
|
910
|
+
this[selectionManager].onKeyDown(e);
|
|
911
|
+
};
|
|
912
|
+
_M3eStepperElement_handleSelectedChange = function _M3eStepperElement_handleSelectedChange() {
|
|
913
|
+
const selected = this[selectionManager].selectedItems[0];
|
|
914
|
+
let selectedIndex = selected ? this.steps.indexOf(selected) : null;
|
|
915
|
+
if (selectedIndex === -1) {
|
|
916
|
+
selectedIndex = null;
|
|
917
|
+
}
|
|
918
|
+
this._selectedIndex = selectedIndex;
|
|
919
|
+
for (const step of this[selectionManager].items) {
|
|
920
|
+
if (step.panel) {
|
|
921
|
+
step.panel.active = step.index === selectedIndex;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
if (selected && this.matches(":focus-within") && !selected.matches(":focus")) {
|
|
925
|
+
selected.focus();
|
|
926
|
+
}
|
|
927
|
+
if (this.classList.contains("-no-animate")) {
|
|
928
|
+
requestAnimationFrame(() => this.classList.toggle("-no-animate", false));
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
_M3eStepperElement_checkValidity = function _M3eStepperElement_checkValidity() {
|
|
932
|
+
let valid = false;
|
|
933
|
+
if (this.selectedStep) {
|
|
934
|
+
valid = this.selectedStep.panel?.querySelector("form")?.checkValidity() ?? true;
|
|
935
|
+
if (this.selectedStep.optional) {
|
|
936
|
+
valid = true;
|
|
937
|
+
}
|
|
938
|
+
this.selectedStep.invalid = !valid;
|
|
939
|
+
}
|
|
940
|
+
return valid;
|
|
941
|
+
};
|
|
942
|
+
_M3eStepperElement_updateDisplayOrder = function _M3eStepperElement_updateDisplayOrder() {
|
|
943
|
+
this[selectionManager].vertical = (this._orientation ?? this.orientation) === "vertical";
|
|
944
|
+
this.classList.toggle("-vertical", this[selectionManager].vertical);
|
|
945
|
+
if (!this[selectionManager].vertical) {
|
|
946
|
+
this.steps.forEach((x) => {
|
|
947
|
+
x.style.order = "";
|
|
948
|
+
if (x.panel) {
|
|
949
|
+
x.panel.style.order = "";
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
else {
|
|
954
|
+
this.steps.forEach((x, i) => {
|
|
955
|
+
x.style.order = `${i}`;
|
|
956
|
+
if (x.panel) {
|
|
957
|
+
x.panel.style.order = `${i}`;
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
/** The styles of the element. */
|
|
963
|
+
M3eStepperElement.styles = css `
|
|
964
|
+
:host {
|
|
965
|
+
display: flex;
|
|
966
|
+
flex-direction: column;
|
|
967
|
+
position: relative;
|
|
968
|
+
}
|
|
969
|
+
:host(:not(.-vertical)) .header {
|
|
970
|
+
display: flex;
|
|
971
|
+
align-items: flex-start;
|
|
972
|
+
flex-wrap: nowrap;
|
|
973
|
+
}
|
|
974
|
+
:host(:not(.-vertical)) ::slotted(.-m3e-step-divider) {
|
|
975
|
+
flex: 1 1 auto;
|
|
976
|
+
position: relative;
|
|
977
|
+
min-width: 2rem;
|
|
978
|
+
}
|
|
979
|
+
:host(:not(.-vertical)) ::slotted(.-m3e-step-divider)::before {
|
|
980
|
+
content: "";
|
|
981
|
+
position: absolute;
|
|
982
|
+
left: 0;
|
|
983
|
+
right: 0;
|
|
984
|
+
border-bottom-width: var(--m3e-step-divider-thickness, 1px);
|
|
985
|
+
border-bottom-style: solid;
|
|
986
|
+
border-bottom-color: var(--m3e-step-divider-color, ${DesignToken.color.outline});
|
|
987
|
+
}
|
|
988
|
+
:host(:not(.-vertical):not([label-position="below"])) ::slotted(.-m3e-step-divider)::before {
|
|
989
|
+
top: 50%;
|
|
990
|
+
}
|
|
991
|
+
:host(:not(.-vertical)) ::slotted([slot="step"]) {
|
|
992
|
+
align-self: stretch;
|
|
993
|
+
}
|
|
994
|
+
:host(:not(.-vertical)) ::slotted([slot="step"]:not(.-m3e-step-divider):not(:first-of-type))::before,
|
|
995
|
+
:host(:not(.-vertical)) ::slotted([slot="step"]:not(.-m3e-step-divider):not(:last-of-type))::after {
|
|
996
|
+
content: "";
|
|
997
|
+
display: block;
|
|
998
|
+
position: absolute;
|
|
999
|
+
top: 0;
|
|
1000
|
+
border-bottom-width: var(--m3e-step-divider-thickness, 1px);
|
|
1001
|
+
border-bottom-style: solid;
|
|
1002
|
+
border-bottom-color: var(--m3e-step-divider-color, ${DesignToken.color.outline});
|
|
1003
|
+
}
|
|
1004
|
+
:host(:not(.-vertical)[label-position="end"]) ::slotted(.-m3e-step-divider) {
|
|
1005
|
+
margin-block: auto;
|
|
1006
|
+
}
|
|
1007
|
+
:host(:not(.-vertical)[label-position="end"])
|
|
1008
|
+
::slotted([slot="step"]:not(.-m3e-step-divider):not(:first-of-type))::before,
|
|
1009
|
+
:host(:not(.-vertical)[label-position="end"])
|
|
1010
|
+
::slotted([slot="step"]:not(.-m3e-step-divider):not(:last-of-type))::after {
|
|
1011
|
+
top: 50%;
|
|
1012
|
+
}
|
|
1013
|
+
:host(:not(.-vertical)[label-position="end"])
|
|
1014
|
+
::slotted([slot="step"]:not(.-m3e-step-divider):not(:first-of-type))::before {
|
|
1015
|
+
left: 0;
|
|
1016
|
+
right: calc(100% - var(--m3e-step-padding, 1.5rem) + var(--m3e-step-divider-inset, 0.5rem));
|
|
1017
|
+
}
|
|
1018
|
+
:host(:not(.-vertical)[label-position="end"])
|
|
1019
|
+
::slotted([slot="step"]:not(.-m3e-step-divider):not(:last-of-type))::after {
|
|
1020
|
+
left: calc(100% - var(--m3e-step-padding, 1.5rem) + var(--m3e-step-divider-inset, 0.5rem));
|
|
1021
|
+
right: 0;
|
|
1022
|
+
}
|
|
1023
|
+
:host(:not(.-vertical)[label-position="below"]) ::slotted(.-m3e-step-divider)::before,
|
|
1024
|
+
:host(:not(.-vertical)[label-position="below"])
|
|
1025
|
+
::slotted([slot="step"]:not(.-m3e-step-divider):not(:first-of-type))::before,
|
|
1026
|
+
:host(:not(.-vertical)[label-position="below"])
|
|
1027
|
+
::slotted([slot="step"]:not(.-m3e-step-divider):not(:last-of-type))::after {
|
|
1028
|
+
margin-block-start: calc(var(--m3e-step-padding, 1.5rem) + calc(var(--m3e-step-icon-size, 1.5rem) / 2));
|
|
1029
|
+
}
|
|
1030
|
+
:host(:not(.-vertical)[label-position="below"])
|
|
1031
|
+
::slotted([slot="step"]:not(.-m3e-step-divider):not(:first-of-type))::before {
|
|
1032
|
+
left: 0;
|
|
1033
|
+
right: calc(50% + calc(var(--m3e-step-icon-size, 1.5rem) / 2) + var(--m3e-step-divider-inset, 0.5rem));
|
|
1034
|
+
}
|
|
1035
|
+
:host(:not(.-vertical)[label-position="below"])
|
|
1036
|
+
::slotted([slot="step"]:not(.-m3e-step-divider):not(:last-of-type))::after {
|
|
1037
|
+
left: calc(50% + calc(var(--m3e-step-icon-size, 1.5rem) / 2) + var(--m3e-step-divider-inset, 0.5rem));
|
|
1038
|
+
right: 0;
|
|
1039
|
+
}
|
|
1040
|
+
:host(:not(.-vertical)[label-position="below"]) {
|
|
1041
|
+
--_step-direction: column;
|
|
1042
|
+
--_step-label-align-items: center;
|
|
1043
|
+
}
|
|
1044
|
+
:host(.-vertical) .header {
|
|
1045
|
+
display: contents;
|
|
1046
|
+
}
|
|
1047
|
+
:host(.-vertical) ::slotted([slot="step"]:not(.-m3e-step-divider)) {
|
|
1048
|
+
flex: none;
|
|
1049
|
+
}
|
|
1050
|
+
:host(.-vertical) ::slotted([slot="panel"]) {
|
|
1051
|
+
margin-inline-start: calc(var(--m3e-step-padding, 1.5rem) + calc(var(--m3e-step-icon-size, 1.5rem) / 2));
|
|
1052
|
+
}
|
|
1053
|
+
:host(.-vertical) ::slotted([slot="panel"]:not(:last-of-type)) {
|
|
1054
|
+
border-inline-start-width: var(--m3e-step-divider-thickness, 1px);
|
|
1055
|
+
border-inline-start-style: solid;
|
|
1056
|
+
border-inline-start-color: var(--m3e-step-divider-color, ${DesignToken.color.outline});
|
|
1057
|
+
}
|
|
1058
|
+
:host(.-vertical) ::slotted([slot="step"]:not(.-m3e-step-divider):not(:first-of-type))::before,
|
|
1059
|
+
:host(.-vertical) ::slotted([slot="step"]:not(.-m3e-step-divider):not(:last-of-type))::after {
|
|
1060
|
+
content: "";
|
|
1061
|
+
display: block;
|
|
1062
|
+
position: absolute;
|
|
1063
|
+
left: 0;
|
|
1064
|
+
margin-inline-start: calc(var(--m3e-step-padding, 1.5rem) + calc(var(--m3e-step-icon-size, 1.5rem) / 2));
|
|
1065
|
+
border-inline-start-width: var(--m3e-step-divider-thickness, 1px);
|
|
1066
|
+
border-inline-start-style: solid;
|
|
1067
|
+
border-inline-start-color: var(--m3e-step-divider-color, ${DesignToken.color.outline});
|
|
1068
|
+
}
|
|
1069
|
+
:host(.-vertical) ::slotted([slot="step"]:not(.-m3e-step-divider):not(:first-of-type))::before {
|
|
1070
|
+
top: 0;
|
|
1071
|
+
bottom: calc(100% - var(--m3e-step-padding, 1.5rem) + var(--m3e-step-divider-inset, 0.5rem));
|
|
1072
|
+
}
|
|
1073
|
+
:host(.-vertical) ::slotted([slot="step"]:not(.-m3e-step-divider):not(:last-of-type))::after {
|
|
1074
|
+
top: calc(100% - var(--m3e-step-padding, 1.5rem) + var(--m3e-step-divider-inset, 0.5rem));
|
|
1075
|
+
bottom: 0;
|
|
1076
|
+
}
|
|
1077
|
+
:host(:not(.-vertical)) {
|
|
1078
|
+
--m3e-collapsible-animation-duration: 0ms;
|
|
1079
|
+
}
|
|
1080
|
+
:host(.-no-animate) {
|
|
1081
|
+
--m3e-collapsible-animation-duration: 0ms;
|
|
1082
|
+
}
|
|
1083
|
+
`;
|
|
1084
|
+
__decorate([
|
|
1085
|
+
r$1()
|
|
1086
|
+
], M3eStepperElement.prototype, "_orientation", void 0);
|
|
1087
|
+
__decorate([
|
|
1088
|
+
r$1()
|
|
1089
|
+
], M3eStepperElement.prototype, "_selectedIndex", void 0);
|
|
1090
|
+
__decorate([
|
|
1091
|
+
n$1({ attribute: "header-position", reflect: true })
|
|
1092
|
+
], M3eStepperElement.prototype, "headerPosition", void 0);
|
|
1093
|
+
__decorate([
|
|
1094
|
+
n$1({ attribute: "label-position", reflect: true })
|
|
1095
|
+
], M3eStepperElement.prototype, "labelPosition", void 0);
|
|
1096
|
+
__decorate([
|
|
1097
|
+
n$1({ type: Boolean, reflect: true })
|
|
1098
|
+
], M3eStepperElement.prototype, "linear", void 0);
|
|
1099
|
+
__decorate([
|
|
1100
|
+
n$1({ reflect: true })
|
|
1101
|
+
], M3eStepperElement.prototype, "orientation", void 0);
|
|
1102
|
+
M3eStepperElement = __decorate([
|
|
1103
|
+
t$2("m3e-stepper")
|
|
1104
|
+
], M3eStepperElement);
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* An element, nested within a clickable element, used to move a stepper to the next step.
|
|
1108
|
+
* @tag m3e-stepper-previous
|
|
1109
|
+
*
|
|
1110
|
+
* @slot - Renders the content of the action.
|
|
1111
|
+
*/
|
|
1112
|
+
let M3eStepperNextElement = class M3eStepperNextElement extends StepperButtonElementBase {
|
|
1113
|
+
constructor() {
|
|
1114
|
+
super("next");
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
M3eStepperNextElement = __decorate([
|
|
1118
|
+
t$2("m3e-stepper-next")
|
|
1119
|
+
], M3eStepperNextElement);
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* An element, nested within a clickable element, used to move a stepper to the previous step.
|
|
1123
|
+
* @tag m3e-stepper-previous
|
|
1124
|
+
*
|
|
1125
|
+
* @slot - Renders the content of the action.
|
|
1126
|
+
*/
|
|
1127
|
+
let M3eStepperPreviousElement = class M3eStepperPreviousElement extends StepperButtonElementBase {
|
|
1128
|
+
constructor() {
|
|
1129
|
+
super("previous");
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
M3eStepperPreviousElement = __decorate([
|
|
1133
|
+
t$2("m3e-stepper-previous")
|
|
1134
|
+
], M3eStepperPreviousElement);
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* An element, nested within a clickable element, used to reset a stepper to its initial state.
|
|
1138
|
+
* @tag m3e-stepper-reset
|
|
1139
|
+
*
|
|
1140
|
+
* @slot - Renders the content of the action.
|
|
1141
|
+
*/
|
|
1142
|
+
let M3eStepperResetElement = class M3eStepperResetElement extends StepperButtonElementBase {
|
|
1143
|
+
constructor() {
|
|
1144
|
+
super("reset");
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1147
|
+
M3eStepperResetElement = __decorate([
|
|
1148
|
+
t$2("m3e-stepper-reset")
|
|
1149
|
+
], M3eStepperResetElement);
|
|
1150
|
+
|
|
1151
|
+
export { M3eStepElement, M3eStepPanelElement, M3eStepperElement, M3eStepperNextElement, M3eStepperPreviousElement, M3eStepperResetElement, StepperButtonElementBase };
|
|
1152
|
+
//# sourceMappingURL=index.js.map
|