123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.82
- */
- 'use strict';
- Object.defineProperty(exports, '__esModule', { value: true });
- const index = require('./index-5c65e149.js');
- const dom = require('./dom-9ac0341c.js');
- const interactive = require('./interactive-e294111f.js');
- require('./guid-8b6d6cb4.js');
- const stepperCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:-ms-flexbox;display:flex;width:100%;min-width:100%;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:justify;justify-content:space-between}:host([layout=vertical]){-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-direction:column;flex-direction:column}:host ::slotted(.calcite-stepper-content){display:-ms-flexbox;display:flex;width:100%;min-width:100%;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap}";
- const Stepper = class {
- constructor(hostRef) {
- index.registerInstance(this, hostRef);
- this.calciteStepperItemChange = index.createEvent(this, "calciteStepperItemChange", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** optionally display a status icon next to the step title */
- this.icon = false;
- /** specify the layout of stepper, defaults to horizontal */
- this.layout = "horizontal";
- /** optionally display the number next to the step title */
- this.numbered = false;
- /** specify the scale of stepper, defaults to m */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- this.itemMap = new Map();
- /** list of sorted Stepper items */
- this.items = [];
- /** list of enabled Stepper items */
- this.enabledItems = [];
- }
- // watch for removal of disabled to register step
- contentWatcher() {
- if (this.layout === "horizontal") {
- if (!this.stepperContentContainer && this.requestedContent) {
- this.addHorizontalContentContainer();
- }
- this.updateContent(this.requestedContent);
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidLoad() {
- // if no stepper items are set as active, default to the first one
- if (!this.currentPosition) {
- this.calciteStepperItemChange.emit({
- position: 0
- });
- }
- }
- componentWillLoad() {
- if (this.layout === "horizontal" && !this.stepperContentContainer) {
- this.addHorizontalContentContainer();
- }
- }
- render() {
- return index.h("slot", null);
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- calciteStepperItemKeyEvent(e) {
- const item = e.detail.item;
- const itemToFocus = e.target;
- const isFirstItem = this.itemIndex(itemToFocus) === 0;
- const isLastItem = this.itemIndex(itemToFocus) === this.enabledItems.length - 1;
- switch (item.key) {
- case "ArrowDown":
- case "ArrowRight":
- if (isLastItem) {
- this.focusFirstItem();
- }
- else {
- this.focusNextItem(itemToFocus);
- }
- break;
- case "ArrowUp":
- case "ArrowLeft":
- if (isFirstItem) {
- this.focusLastItem();
- }
- else {
- this.focusPrevItem(itemToFocus);
- }
- break;
- case "Home":
- this.focusFirstItem();
- break;
- case "End":
- this.focusLastItem();
- break;
- }
- }
- registerItem(event) {
- const item = event.target;
- const { content, position } = event.detail;
- if (content && item.active) {
- this.requestedContent = content;
- }
- this.itemMap.set(item, position);
- this.items = this.sortItems();
- this.enabledItems = this.filterItems();
- }
- updateItem(event) {
- if (event.detail.content) {
- this.requestedContent = event.detail.content;
- }
- this.currentPosition = event.detail.position;
- this.calciteStepperItemChange.emit({
- position: this.currentPosition
- });
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** set the next step as active */
- async nextStep() {
- const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition + 1, "next");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.emitChangedItem(enabledStepIndex);
- }
- /** set the previous step as active */
- async prevStep() {
- const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition - 1, "previous");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.emitChangedItem(enabledStepIndex);
- }
- /** set the requested step as active */
- async goToStep(step) {
- const position = step - 1;
- if (this.currentPosition !== position) {
- this.emitChangedItem(position);
- }
- }
- /** set the first step as active */
- async startStep() {
- const enabledStepIndex = this.getEnabledStepIndex(0, "next");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.emitChangedItem(enabledStepIndex);
- }
- /** set the last step as active */
- async endStep() {
- const enabledStepIndex = this.getEnabledStepIndex(this.items.length - 1, "previous");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.emitChangedItem(enabledStepIndex);
- }
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- getEnabledStepIndex(startIndex, direction = "next") {
- var _a;
- const { items, currentPosition } = this;
- let newIndex = startIndex;
- while ((_a = items[newIndex]) === null || _a === void 0 ? void 0 : _a.disabled) {
- newIndex = newIndex + (direction === "previous" ? -1 : 1);
- }
- return newIndex !== currentPosition && newIndex < items.length && newIndex >= 0
- ? newIndex
- : null;
- }
- addHorizontalContentContainer() {
- this.stepperContentContainer = document.createElement("div");
- this.stepperContentContainer.classList.add("calcite-stepper-content");
- this.el.insertAdjacentElement("beforeend", this.stepperContentContainer);
- }
- emitChangedItem(position) {
- this.currentPosition = position;
- this.calciteStepperItemChange.emit({
- position
- });
- }
- focusFirstItem() {
- const firstItem = this.enabledItems[0];
- this.focusElement(firstItem);
- }
- focusLastItem() {
- const lastItem = this.enabledItems[this.enabledItems.length - 1];
- this.focusElement(lastItem);
- }
- focusNextItem(e) {
- const index = this.itemIndex(e);
- const nextItem = this.enabledItems[index + 1] || this.enabledItems[0];
- this.focusElement(nextItem);
- }
- focusPrevItem(e) {
- const index = this.itemIndex(e);
- const prevItem = this.enabledItems[index - 1] || this.enabledItems[this.enabledItems.length - 1];
- this.focusElement(prevItem);
- }
- itemIndex(e) {
- return this.enabledItems.indexOf(e);
- }
- focusElement(item) {
- item.focus();
- }
- sortItems() {
- const { itemMap } = this;
- return Array.from(itemMap.keys()).sort((a, b) => itemMap.get(a) - itemMap.get(b));
- }
- filterItems() {
- return this.items.filter((item) => !item.disabled);
- }
- updateContent(content) {
- this.stepperContentContainer.innerHTML = "";
- this.stepperContentContainer.append(...content);
- }
- get el() { return index.getElement(this); }
- static get watchers() { return {
- "requestedContent": ["contentWatcher"]
- }; }
- };
- Stepper.style = stepperCss;
- const stepperItemCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([scale=s]){--calcite-stepper-item-spacing-unit-s:0.25rem;--calcite-stepper-item-spacing-unit-m:0.75rem;--calcite-stepper-item-spacing-unit-l:1rem;font-size:var(--calcite-font-size--1);line-height:1rem;-webkit-margin-end:0.25rem;margin-inline-end:0.25rem}:host([scale=s]) .stepper-item-subtitle{font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]){--calcite-stepper-item-spacing-unit-s:0.5rem;--calcite-stepper-item-spacing-unit-m:1rem;--calcite-stepper-item-spacing-unit-l:1.25rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}:host([scale=m]) .stepper-item-subtitle{font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]){--calcite-stepper-item-spacing-unit-s:0.75rem;--calcite-stepper-item-spacing-unit-m:1.25rem;--calcite-stepper-item-spacing-unit-l:1.5rem;font-size:var(--calcite-font-size-1);line-height:1.5rem;-webkit-margin-end:0.75rem;margin-inline-end:0.75rem}:host([scale=l]) .stepper-item-subtitle{font-size:var(--calcite-font-size-0);line-height:1.25rem}:host{position:relative;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;-ms-flex-direction:column;flex-direction:column;margin-bottom:var(--calcite-stepper-item-spacing-unit-s)}:host .container{position:relative;display:-ms-flexbox;display:flex;-ms-flex-positive:1;flex-grow:1;cursor:pointer;-ms-flex-direction:column;flex-direction:column;border-width:0px;border-top-width:2px;border-style:solid;border-color:var(--calcite-ui-border-3);color:var(--calcite-ui-text-3);-webkit-text-decoration-line:none;text-decoration-line:none;outline:2px solid transparent;outline-offset:2px;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host{outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out}:host(:focus){outline:2px solid var(--calcite-ui-brand);outline-offset:2px}:host .stepper-item-header{display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-align:start;align-items:flex-start}:host .stepper-item-content,:host .stepper-item-header{-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);padding-block:var(--calcite-stepper-item-spacing-unit-l);-webkit-padding-end:var(--calcite-stepper-item-spacing-unit-m);padding-inline-end:var(--calcite-stepper-item-spacing-unit-m);text-align:start}:host .stepper-item-header *{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host .stepper-item-content{display:none;width:100%;-ms-flex-direction:column;flex-direction:column;font-size:var(--calcite-font-size--2);line-height:1.375}:host .stepper-item-icon{-webkit-margin-end:var(--calcite-stepper-item-spacing-unit-m);margin-inline-end:var(--calcite-stepper-item-spacing-unit-m);margin-top:1px;display:-ms-inline-flexbox;display:inline-flex;height:0.75rem;-ms-flex-negative:0;flex-shrink:0;-ms-flex-item-align:start;align-self:flex-start;color:var(--calcite-ui-text-3);opacity:var(--calcite-ui-opacity-disabled);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host .stepper-item-header-text{-ms-flex-direction:column;flex-direction:column;text-align:initial;-webkit-margin-end:auto;margin-inline-end:auto}:host .stepper-item-title,:host .stepper-item-subtitle{display:-ms-flexbox;display:flex;width:100%}:host .stepper-item-title{margin-bottom:0.25rem;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2)}:host .stepper-item-subtitle{color:var(--calcite-ui-text-3)}:host .stepper-item-number{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-3);-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);-webkit-margin-end:var(--calcite-stepper-item-spacing-unit-m);margin-inline-end:var(--calcite-stepper-item-spacing-unit-m)}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([complete]) .container{border-color:rgba(0, 122, 194, 0.5)}:host([complete]) .container .stepper-item-icon{color:var(--calcite-ui-brand)}:host([error]) .container{border-top-color:var(--calcite-ui-danger)}:host([error]) .container .stepper-item-number{color:var(--calcite-ui-danger)}:host([error]) .container .stepper-item-icon{opacity:1;color:var(--calcite-ui-danger)}:host(:hover:not([disabled]):not([active])) .container,:host(:focus:not([disabled]):not([active])) .container{border-top-color:var(--calcite-ui-brand)}:host(:hover:not([disabled]):not([active])) .container .stepper-item-title,:host(:focus:not([disabled]):not([active])) .container .stepper-item-title{color:var(--calcite-ui-text-1)}:host(:hover:not([disabled]):not([active])) .container .stepper-item-subtitle,:host(:focus:not([disabled]):not([active])) .container .stepper-item-subtitle{color:var(--calcite-ui-text-2)}:host([error]:hover:not([disabled]):not([active])) .container,:host([error]:focus:not([disabled]):not([active])) .container{border-top-color:var(--calcite-ui-danger-hover)}:host([active]) .container{border-top-color:var(--calcite-ui-brand)}:host([active]) .container .stepper-item-title{color:var(--calcite-ui-text-1)}:host([active]) .container .stepper-item-subtitle{color:var(--calcite-ui-text-2)}:host([active]) .container .stepper-item-number{color:var(--calcite-ui-brand)}:host([active]) .container .stepper-item-icon{color:var(--calcite-ui-brand);opacity:1}:host([layout=vertical]) .container{margin-left:0px;margin-right:0px;margin-top:0px;-ms-flex:1 1 auto;flex:1 1 auto;border-top-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3);padding-top:0px;padding-bottom:0px;border-inline-start-width:2px;-webkit-padding-start:var(--calcite-stepper-item-spacing-unit-l);padding-inline-start:var(--calcite-stepper-item-spacing-unit-l)}:host([layout=vertical]) .container .stepper-item-icon{-ms-flex-order:3;order:3;margin-top:1px;margin-bottom:0px;-webkit-padding-start:var(--calcite-stepper-item-spacing-unit-s);padding-inline-start:var(--calcite-stepper-item-spacing-unit-s);-webkit-margin-start:auto;margin-inline-start:auto}:host([layout=vertical]) .container .stepper-item-header{-webkit-padding-end:0px;padding-inline-end:0px}:host([layout=vertical]) .container .stepper-item-content{padding:0px}:host([layout=vertical][active]) .container .stepper-item-content{display:-ms-flexbox;display:flex}:host([layout=vertical][active]) .container .stepper-item-content ::slotted(:last-child){margin-bottom:var(--calcite-stepper-item-spacing-unit-l)}:host([layout=vertical][complete]) .container{border-color:rgba(0, 122, 194, 0.5)}:host([layout=vertical][complete]:hover:not([disabled]):not([active])) .container,:host([layout=vertical][complete]:focus:not([disabled]):not([active])) .container{border-color:var(--calcite-ui-brand)}:host([layout=vertical][error]) .container{border-color:var(--calcite-ui-danger)}:host([layout=vertical][active]) .container{border-color:var(--calcite-ui-brand)}:host([layout=vertical]:hover:not([disabled]):not([active])) .container,:host([layout=vertical]:focus:not([disabled]):not([active])) .container{border-color:rgba(0, 122, 194, 0.5)}:host([layout=vertical][error]:hover:not([disabled]):not([active])) .container,:host([layout=vertical][error]:focus:not([disabled]):not([active])) .container{border-color:var(--calcite-ui-danger-hover)}";
- const StepperItem = class {
- constructor(hostRef) {
- index.registerInstance(this, hostRef);
- this.calciteStepperItemKeyEvent = index.createEvent(this, "calciteStepperItemKeyEvent", 7);
- this.calciteStepperItemSelect = index.createEvent(this, "calciteStepperItemSelect", 7);
- this.calciteStepperItemRegister = index.createEvent(this, "calciteStepperItemRegister", 7);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** is the step active */
- this.active = false;
- /** has the step been completed */
- this.complete = false;
- /** does the step contain an error that needs to be resolved by the user */
- this.error = false;
- /** is the step disabled and not navigable to by a user */
- this.disabled = false;
- /** should the items display an icon based on status */
- /** @internal */
- this.icon = false;
- /** optionally display the step number next to the title and subtitle */
- /** @internal */
- this.numbered = false;
- /** the scale of the item */
- /** @internal */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.keyDownHandler = (e) => {
- if (!this.disabled && e.target === this.el) {
- switch (e.key) {
- case " ":
- case "Enter":
- this.emitRequestedItem();
- e.preventDefault();
- break;
- case "ArrowUp":
- case "ArrowDown":
- case "ArrowLeft":
- case "ArrowRight":
- case "Home":
- case "End":
- this.calciteStepperItemKeyEvent.emit({ item: e });
- e.preventDefault();
- break;
- }
- }
- };
- this.emitRequestedItem = () => {
- if (!this.disabled) {
- this.calciteStepperItemSelect.emit({
- position: this.itemPosition,
- content: this.itemContent
- });
- }
- };
- this.setItemContent = (event) => {
- this.itemPosition = this.getItemPosition();
- const itemContent = event.target.assignedNodes({ flatten: true });
- if (itemContent.length) {
- this.itemContent = itemContent;
- }
- this.registerStepperItem();
- if (this.active) {
- this.emitRequestedItem();
- }
- };
- }
- // watch for removal of disabled to register step
- disabledWatcher() {
- this.registerStepperItem();
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentWillLoad() {
- this.icon = dom.getElementProp(this.el, "icon", false);
- this.numbered = dom.getElementProp(this.el, "numbered", false);
- this.layout = dom.getElementProp(this.el, "layout", false);
- this.scale = dom.getElementProp(this.el, "scale", "m");
- this.parentStepperEl = this.el.parentElement;
- }
- componentDidRender() {
- interactive.updateHostInteraction(this, true);
- }
- render() {
- return (index.h(index.Host, { "aria-expanded": dom.toAriaBoolean(this.active), onClick: this.emitRequestedItem, onKeyDown: this.keyDownHandler }, index.h("div", { class: "container" }, index.h("div", { class: "stepper-item-header" }, this.icon ? this.renderIcon() : null, this.numbered ? (index.h("div", { class: "stepper-item-number" }, this.getItemPosition() + 1, ".")) : null, index.h("div", { class: "stepper-item-header-text" }, index.h("span", { class: "stepper-item-title" }, this.itemTitle), index.h("span", { class: "stepper-item-subtitle" }, this.itemSubtitle))), index.h("div", { class: "stepper-item-content" }, index.h("slot", { onSlotchange: this.setItemContent })))));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- updateActiveItemOnChange(event) {
- if (event.target === this.parentStepperEl ||
- event.composedPath().includes(this.parentStepperEl)) {
- this.activePosition = event.detail.position;
- this.determineActiveItem();
- }
- }
- renderIcon() {
- const path = this.active
- ? "circleF"
- : this.error
- ? "exclamationMarkCircleF"
- : this.complete
- ? "checkCircleF"
- : "circle";
- return index.h("calcite-icon", { class: "stepper-item-icon", icon: path, scale: "s" });
- }
- determineActiveItem() {
- this.active = !this.disabled && this.itemPosition === this.activePosition;
- }
- registerStepperItem() {
- this.calciteStepperItemRegister.emit({
- position: this.itemPosition,
- content: this.itemContent
- });
- }
- getItemPosition() {
- return Array.prototype.indexOf.call(this.parentStepperEl.querySelectorAll("calcite-stepper-item"), this.el);
- }
- get el() { return index.getElement(this); }
- static get watchers() { return {
- "disabled": ["disabledWatcher"]
- }; }
- };
- StepperItem.style = stepperItemCss;
- exports.calcite_stepper = Stepper;
- exports.calcite_stepper_item = StepperItem;
|