123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- /*!
- * 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.97
- */
- 'use strict';
- Object.defineProperty(exports, '__esModule', { value: true });
- const index = require('./index-a0010f96.js');
- const dom = require('./dom-2ec8c9ed.js');
- const interactive = require('./interactive-32293bca.js');
- const locale = require('./locale-678ce361.js');
- require('./resources-b5a5f8a7.js');
- require('./guid-f4f03a7a.js');
- require('./key-6a462411.js');
- require('./observers-5706326b.js');
- const stepperCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity: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;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:flex;inline-size:100%;min-inline-size:-moz-fit-content;min-inline-size:fit-content;flex-direction:row;flex-wrap:wrap;align-items:stretch;justify-content:space-between}:host([layout=vertical]){flex:1 1 auto;flex-direction:column}:host([layout=horizontal]){display:grid;grid-template-areas:\"items\" \"content\"}";
- const Stepper = class {
- constructor(hostRef) {
- index.registerInstance(this, hostRef);
- this.calciteStepperItemChange = index.createEvent(this, "calciteStepperItemChange", 6);
- this.calciteInternalStepperItemChange = index.createEvent(this, "calciteInternalStepperItemChange", 6);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /** When `true`, displays a status icon in the `calcite-stepper-item` heading. */
- this.icon = false;
- /** Defines the layout of the component. */
- this.layout = "horizontal";
- /** When `true`, displays the step number in the `calcite-stepper-item` heading. */
- this.numbered = false;
- /** Specifies the size of the component. */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Private State/Props
- //
- //--------------------------------------------------------------------------
- this.itemMap = new Map();
- /** list of sorted Stepper items */
- this.items = [];
- /** list of enabled Stepper items */
- this.enabledItems = [];
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidLoad() {
- // if no stepper items are set as active, default to the first one
- if (typeof this.currentPosition !== "number") {
- this.calciteInternalStepperItemChange.emit({
- position: 0
- });
- }
- }
- render() {
- return (index.h("slot", { onSlotchange: (event) => {
- const items = event.currentTarget
- .assignedElements()
- .filter((el) => (el === null || el === void 0 ? void 0 : el.tagName) === "CALCITE-STEPPER-ITEM");
- const spacing = Array(items.length).fill("1fr").join(" ");
- this.el.style.gridTemplateAreas = spacing;
- this.el.style.gridTemplateColumns = spacing;
- } }));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- calciteInternalStepperItemKeyEvent(event) {
- const item = event.detail.item;
- const itemToFocus = event.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;
- }
- event.stopPropagation();
- }
- registerItem(event) {
- const item = event.target;
- const { content, position } = event.detail;
- this.itemMap.set(item, { position, content });
- this.items = this.sortItems();
- this.enabledItems = this.filterItems();
- event.stopPropagation();
- }
- updateItem(event) {
- const { position } = event.detail;
- if (typeof position === "number") {
- this.currentPosition = position;
- }
- this.calciteInternalStepperItemChange.emit({
- position
- });
- }
- handleUserRequestedStepperItemSelect(event) {
- const { position } = event.detail;
- this.calciteStepperItemChange.emit({
- position
- });
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- /** Set the next `calcite-stepper-item` as active. */
- async nextStep() {
- const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition + 1, "next");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.updateStep(enabledStepIndex);
- }
- /** Set the previous `calcite-stepper-item` as active. */
- async prevStep() {
- const enabledStepIndex = this.getEnabledStepIndex(this.currentPosition - 1, "previous");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.updateStep(enabledStepIndex);
- }
- /**
- * Set a specified `calcite-stepper-item` as active.
- *
- * @param step
- */
- async goToStep(step) {
- const position = step - 1;
- if (this.currentPosition !== position) {
- this.updateStep(position);
- }
- }
- /** Set the first `calcite-stepper-item` as active. */
- async startStep() {
- const enabledStepIndex = this.getEnabledStepIndex(0, "next");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.updateStep(enabledStepIndex);
- }
- /** Set the last `calcite-stepper-item` as active. */
- async endStep() {
- const enabledStepIndex = this.getEnabledStepIndex(this.items.length - 1, "previous");
- if (typeof enabledStepIndex !== "number") {
- return;
- }
- this.updateStep(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;
- }
- updateStep(position) {
- this.currentPosition = position;
- this.calciteInternalStepperItemChange.emit({
- position
- });
- }
- focusFirstItem() {
- const firstItem = this.enabledItems[0];
- dom.focusElement(firstItem);
- }
- focusLastItem() {
- const lastItem = this.enabledItems[this.enabledItems.length - 1];
- dom.focusElement(lastItem);
- }
- focusNextItem(el) {
- const index = this.itemIndex(el);
- const nextItem = this.enabledItems[index + 1] || this.enabledItems[0];
- dom.focusElement(nextItem);
- }
- focusPrevItem(el) {
- const index = this.itemIndex(el);
- const prevItem = this.enabledItems[index - 1] || this.enabledItems[this.enabledItems.length - 1];
- dom.focusElement(prevItem);
- }
- itemIndex(el) {
- return this.enabledItems.indexOf(el);
- }
- sortItems() {
- const { itemMap } = this;
- return Array.from(itemMap.keys()).sort((a, b) => itemMap.get(a).position - itemMap.get(b).position);
- }
- filterItems() {
- return this.items.filter((item) => !item.disabled);
- }
- get el() { return index.getElement(this); }
- };
- Stepper.style = stepperCss;
- const stepperItemCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity: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;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([layout=horizontal][disabled]) .stepper-item-header,:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}: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;margin-inline-end:0.25rem}:host([scale=s]) .stepper-item-description{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;margin-inline-end:0.5rem}:host([scale=m]) .stepper-item-description{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;margin-inline-end:0.75rem}:host([scale=l]) .stepper-item-description{font-size:var(--calcite-font-size-0);line-height:1.25rem}:host{position:relative;display:flex;flex-grow:1;flex-direction:column;align-self:flex-start;margin-block-end:var(--calcite-stepper-item-spacing-unit-s)}:host .container{position:relative;display:flex;flex-grow:1;cursor:pointer;flex-direction:column;border-width:0px;border-block-start-width:2px;border-style:solid;border-color:var(--calcite-ui-border-3);color:var(--calcite-ui-text-3);text-decoration-line:none;outline:2px solid transparent;outline-offset:2px;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host{outline-color:transparent}:host(:focus){outline:2px solid var(--calcite-ui-brand);outline-offset:2px}:host .stepper-item-header{display:flex;cursor:pointer;align-items:flex-start}:host .stepper-item-content,:host .stepper-item-header{transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);padding-block:var(--calcite-stepper-item-spacing-unit-l);padding-inline-end:var(--calcite-stepper-item-spacing-unit-m);text-align:start}:host .stepper-item-header *{display:inline-flex;align-items:center;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host .stepper-item-content{display:none;inline-size:100%;flex-direction:column;font-size:var(--calcite-font-size--2);line-height:1.375}:host .stepper-item-icon{margin-inline-end:var(--calcite-stepper-item-spacing-unit-m);margin-block-start:1px;display:inline-flex;block-size:0.75rem;flex-shrink:0;align-self:flex-start;color:var(--calcite-ui-text-3);opacity:var(--calcite-ui-opacity-disabled);transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}:host .stepper-item-header-text{flex-direction:column;text-align:initial;margin-inline-end:auto}:host .stepper-item-heading,:host .stepper-item-description{display:flex;inline-size:100%}:host .stepper-item-heading{margin-block-end:0.25rem;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2)}:host .stepper-item-description{color:var(--calcite-ui-text-3)}:host .stepper-item-number{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-3);transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);margin-inline-end:var(--calcite-stepper-item-spacing-unit-m)}: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-block-start-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([selected])) .container,:host(:focus:not([disabled]):not([selected])) .container{border-block-start-color:var(--calcite-ui-brand)}:host(:hover:not([disabled]):not([selected])) .container .stepper-item-heading,:host(:focus:not([disabled]):not([selected])) .container .stepper-item-heading{color:var(--calcite-ui-text-1)}:host(:hover:not([disabled]):not([selected])) .container .stepper-item-description,:host(:focus:not([disabled]):not([selected])) .container .stepper-item-description{color:var(--calcite-ui-text-2)}:host([error]:hover:not([disabled]):not([selected])) .container,:host([error]:focus:not([disabled]):not([selected])) .container{border-block-start-color:var(--calcite-ui-danger-hover)}:host([selected]) .container{border-block-start-color:var(--calcite-ui-brand)}:host([selected]) .container .stepper-item-heading{color:var(--calcite-ui-text-1)}:host([selected]) .container .stepper-item-description{color:var(--calcite-ui-text-2)}:host([selected]) .container .stepper-item-number{color:var(--calcite-ui-brand)}:host([selected]) .container .stepper-item-icon{color:var(--calcite-ui-brand);opacity:1}:host([selected]) .container .stepper-item-content{display:flex}:host([layout=vertical]) .container{margin-inline:0px;margin-block-start:0px;flex:1 1 auto;border-block-start-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3);padding-block:0px;border-inline-start-width:2px;padding-inline-start:var(--calcite-stepper-item-spacing-unit-l)}:host([layout=vertical]) .container .stepper-item-icon{order:3;margin-block:1px 0px;padding-inline-start:var(--calcite-stepper-item-spacing-unit-s);margin-inline-start:auto}:host([layout=vertical]) .container .stepper-item-header{padding-inline-end:0px}:host([layout=vertical]) .container .stepper-item-content{padding:0px}:host([layout=vertical][complete]) .container{border-color:rgba(0, 122, 194, 0.5)}:host([layout=vertical][complete]:hover:not([disabled]):not([selected])) .container,:host([layout=vertical][complete]:focus:not([disabled]):not([selected])) .container{border-color:var(--calcite-ui-brand)}:host([layout=vertical][error]) .container{border-color:var(--calcite-ui-danger)}:host([layout=vertical][selected]) .container{border-color:var(--calcite-ui-brand)}:host([layout=vertical][selected]) .container .stepper-item-content ::slotted(:last-child){margin-block-end:var(--calcite-stepper-item-spacing-unit-l)}:host([layout=vertical]:hover:not([disabled]):not([selected])) .container,:host([layout=vertical]:focus:not([disabled]):not([selected])) .container{border-color:rgba(0, 122, 194, 0.5)}:host([layout=vertical][error]:hover:not([disabled]):not([selected])) .container,:host([layout=vertical][error]:focus:not([disabled]):not([selected])) .container{border-color:var(--calcite-ui-danger-hover)}:host([layout=horizontal]){display:contents}:host([layout=horizontal]) .container{display:contents}:host([layout=horizontal]) .stepper-item-header{border-width:0px;border-block-start-width:2px;border-style:solid;border-color:var(--calcite-ui-border-3);outline-color:transparent;grid-row:items;margin-inline-end:0.5rem;margin-block-end:var(--calcite-stepper-item-spacing-unit-s)}:host([layout=horizontal]) .stepper-item-header:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}:host([layout=horizontal]) .stepper-item-content{cursor:auto;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);padding-block:0;padding-inline-end:var(--calcite-stepper-item-spacing-unit-m);text-align:start}:host([layout=horizontal][selected]) .stepper-item-content{grid-area:2/1/2/-1}:host([layout=horizontal][scale=s]) .stepper-item-header{margin-inline-end:0.25rem;margin-block-end:var(--calcite-stepper-item-spacing-unit-s)}:host([layout=horizontal][scale=l]) .stepper-item-header{margin-inline-end:0.75rem;margin-block-end:var(--calcite-stepper-item-spacing-unit-s)}:host([layout=horizontal][complete]) .stepper-item-header{border-color:rgba(0, 122, 194, 0.5)}:host([layout=horizontal][complete]:hover:not([disabled]):not([selected])) .stepper-item-header,:host([layout=horizontal][complete]:focus:not([disabled]):not([selected])) .stepper-item-header{border-color:var(--calcite-ui-brand)}:host([layout=horizontal][error]) .stepper-item-header{border-color:var(--calcite-ui-danger)}:host([layout=horizontal][selected]) .stepper-item-header{border-color:var(--calcite-ui-brand)}:host([layout=horizontal]:hover:not([disabled]):not([selected])) .stepper-item-header,:host([layout=horizontal]:focus:not([disabled]):not([selected])) .stepper-item-header{border-color:rgba(0, 122, 194, 0.5)}:host([layout=horizontal][error]:hover:not([disabled]):not([selected])) .stepper-item-header,:host([layout=horizontal][error]:focus:not([disabled]):not([selected])) .stepper-item-header{border-color:var(--calcite-ui-danger-hover)}@media (forced-colors: active){:host .container{outline-width:0;outline-offset:0}:host(:focus),:host(:focus-visible){outline-color:canvasText}:host([selected]) .container{border-block-start-color:highlight}:host([selected]) .container .stepper-item-number{color:highlight}:host([selected]) .container .stepper-item-icon{color:highlight}:host([layout=vertical][selected]) .container{border-color:highlight}}";
- const StepperItem = class {
- constructor(hostRef) {
- index.registerInstance(this, hostRef);
- this.calciteInternalStepperItemKeyEvent = index.createEvent(this, "calciteInternalStepperItemKeyEvent", 6);
- this.calciteInternalStepperItemSelect = index.createEvent(this, "calciteInternalStepperItemSelect", 6);
- this.calciteInternalUserRequestedStepperItemSelect = index.createEvent(this, "calciteInternalUserRequestedStepperItemSelect", 6);
- this.calciteInternalStepperItemRegister = index.createEvent(this, "calciteInternalStepperItemRegister", 6);
- //--------------------------------------------------------------------------
- //
- // Public Properties
- //
- //--------------------------------------------------------------------------
- /**
- * When `true`, the component is selected.
- *
- * @deprecated Use `selected` instead.
- */
- this.active = false;
- /**
- * When `true`, the component is selected.
- */
- this.selected = false;
- /** When `true`, the step has been completed. */
- this.complete = false;
- /** When `true`, the component contains an error that requires resolution from the user. */
- this.error = false;
- /** When `true`, interaction is prevented and the component is displayed with lower opacity. */
- this.disabled = false;
- // internal props inherited from wrapping calcite-stepper
- /** Defines the layout of the component. */
- /** @internal */
- this.layout = "horizontal";
- /** When `true`, displays a status icon in the component's heading. */
- /** @internal */
- this.icon = false;
- /** When `true`, displays the step number in the component's heading. */
- /** @internal */
- this.numbered = false;
- /** Specifies the size of the component. */
- /** @internal */
- this.scale = "m";
- //--------------------------------------------------------------------------
- //
- // Internal State/Props
- //
- //--------------------------------------------------------------------------
- this.effectiveLocale = "";
- //--------------------------------------------------------------------------
- //
- // Private Methods
- //
- //--------------------------------------------------------------------------
- this.keyDownHandler = (event) => {
- if (!this.disabled && event.target === this.el) {
- switch (event.key) {
- case " ":
- case "Enter":
- this.emitUserRequestedItem();
- event.preventDefault();
- break;
- case "ArrowUp":
- case "ArrowDown":
- case "ArrowLeft":
- case "ArrowRight":
- case "Home":
- case "End":
- this.calciteInternalStepperItemKeyEvent.emit({ item: event });
- event.preventDefault();
- break;
- }
- }
- };
- this.handleItemClick = (event) => {
- if (this.layout === "horizontal" &&
- event
- .composedPath()
- .some((el) => { var _a; return (_a = el.classList) === null || _a === void 0 ? void 0 : _a.contains("stepper-item-content"); })) {
- return;
- }
- this.emitUserRequestedItem();
- };
- this.emitUserRequestedItem = () => {
- this.emitRequestedItem();
- if (!this.disabled) {
- const position = this.itemPosition;
- this.calciteInternalUserRequestedStepperItemSelect.emit({
- position
- });
- }
- };
- this.emitRequestedItem = () => {
- if (!this.disabled) {
- const position = this.itemPosition;
- this.calciteInternalStepperItemSelect.emit({
- position
- });
- }
- };
- }
- activeHandler(value) {
- this.selected = value;
- }
- selectedHandler(value) {
- this.active = value;
- if (this.selected) {
- this.emitRequestedItem();
- }
- }
- // watch for removal of disabled to register step
- disabledWatcher() {
- this.registerStepperItem();
- }
- effectiveLocaleWatcher(locale$1) {
- var _a;
- locale.numberStringFormatter.numberFormatOptions = {
- locale: locale$1,
- numberingSystem: (_a = this.parentStepperEl) === null || _a === void 0 ? void 0 : _a.numberingSystem,
- useGrouping: false
- };
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- connectedCallback() {
- locale.connectLocalized(this);
- const { selected, active } = this;
- if (selected) {
- this.active = selected;
- }
- else if (active) {
- this.selected = active;
- }
- }
- componentWillLoad() {
- var _a;
- 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;
- this.itemPosition = this.getItemPosition();
- this.registerStepperItem();
- if (this.selected) {
- this.emitRequestedItem();
- }
- locale.numberStringFormatter.numberFormatOptions = {
- locale: this.effectiveLocale,
- numberingSystem: (_a = this.parentStepperEl) === null || _a === void 0 ? void 0 : _a.numberingSystem,
- useGrouping: false
- };
- }
- componentDidRender() {
- interactive.updateHostInteraction(this, true);
- }
- disconnectedCallback() {
- locale.disconnectLocalized(this);
- }
- render() {
- return (index.h(index.Host, { "aria-expanded": dom.toAriaBoolean(this.active), onClick: this.handleItemClick, onKeyDown: this.keyDownHandler }, index.h("div", { class: "container" }, index.h("div", { class: "stepper-item-header", ref: (el) => (this.headerEl = el), tabIndex:
- /* additional tab index logic needed because of display: contents */
- this.layout === "horizontal" && !this.disabled ? 0 : null }, this.icon ? this.renderIcon() : null, this.numbered ? (index.h("div", { class: "stepper-item-number" }, locale.numberStringFormatter.numberFormatter.format(this.itemPosition + 1), ".")) : null, index.h("div", { class: "stepper-item-header-text" }, index.h("span", { class: "stepper-item-heading" }, this.heading || this.itemTitle), index.h("span", { class: "stepper-item-description" }, this.description || this.itemSubtitle))), index.h("div", { class: "stepper-item-content" }, index.h("slot", null)))));
- }
- //--------------------------------------------------------------------------
- //
- // Event Listeners
- //
- //--------------------------------------------------------------------------
- updateActiveItemOnChange(event) {
- if (event.target === this.parentStepperEl ||
- event.composedPath().includes(this.parentStepperEl)) {
- this.selectedPosition = event.detail.position;
- this.determineSelectedItem();
- }
- }
- //--------------------------------------------------------------------------
- //
- // Public Methods
- //
- //--------------------------------------------------------------------------
- async setFocus() {
- var _a;
- (_a = (this.layout === "vertical" ? this.el : this.headerEl)) === null || _a === void 0 ? void 0 : _a.focus();
- }
- renderIcon() {
- const path = this.selected
- ? "circleF"
- : this.error
- ? "exclamationMarkCircleF"
- : this.complete
- ? "checkCircleF"
- : "circle";
- return index.h("calcite-icon", { class: "stepper-item-icon", icon: path, scale: "s" });
- }
- determineSelectedItem() {
- this.selected = !this.disabled && this.itemPosition === this.selectedPosition;
- }
- registerStepperItem() {
- this.calciteInternalStepperItemRegister.emit({
- position: this.itemPosition
- });
- }
- getItemPosition() {
- var _a;
- return Array.from((_a = this.parentStepperEl) === null || _a === void 0 ? void 0 : _a.querySelectorAll("calcite-stepper-item")).indexOf(this.el);
- }
- get el() { return index.getElement(this); }
- static get watchers() { return {
- "active": ["activeHandler"],
- "selected": ["selectedHandler"],
- "disabled": ["disabledWatcher"],
- "effectiveLocale": ["effectiveLocaleWatcher"]
- }; }
- };
- StepperItem.style = stepperItemCss;
- exports.calcite_stepper = Stepper;
- exports.calcite_stepper_item = StepperItem;
|