{"version":3,"file":"step-indicator.BcehQo9v.js","sources":["../../../../../packages/web-components/src/lib/components/step-indicator/step-indicator.ts"],"sourcesContent":["import { html, isServer } from 'lit';\nimport { property, queryAssignedElements, state } from 'lit/decorators.js';\nimport { ResizeObserver as ResizeObserverPolyfill } from '@juggle/resize-observer';\nimport { pdsCustomElement as customElement } from '../../decorators/pds-custom-element';\nimport { PdsElement } from '../PdsElement';\nimport '../step-indicator-item/step-indicator-item';\nimport styles from './step-indicator.scss?inline';\nimport { requiredSlot } from '../../decorators/requiredSlot';\n\n/**\n * @summary A step indicator\n *\n * @slot default Required: Contains the step indicator items, restricted to pds-step-indicator-item element\n */\n@customElement('pds-step-indicator', {\n category: 'component',\n type: 'component',\n state: 'stable',\n styles,\n})\nexport class PdsStepIndicator extends PdsElement {\n connectedCallback() {\n super.connectedCallback();\n this.initLocalization();\n }\n\n /**\n * variant\n * - **horizontal** renders the step-indicator horizontal on large screens and up\n * - **vertical** renders the step-indicator always vertical\n */\n @property()\n variant: 'horizontal' | 'vertical' = 'horizontal';\n\n /**\n * interactive\n */\n @property({ type: Boolean })\n interactive: boolean = false;\n\n /**\n * inverted\n */\n @property({ type: Boolean })\n inverted: boolean = false;\n\n /**\n * Indicates if the parent container in narrower than step-indicator width\n * @internal\n */\n @state()\n isNarrowContainer: boolean = false;\n\n /** @internal */\n @state()\n ResizeObserver =\n !isServer && window && window.ResizeObserver\n ? window.ResizeObserver\n : ResizeObserverPolyfill;\n\n /**\n * Listen for resize events on parent and checks if the parent is narrow in width\n *\n * @internal\n */\n // We can't actually call the observer, because Jest has no concept of element width\n /* istanbul ignore next */\n resizeObserver = new this.ResizeObserver((entries: any[]) => {\n entries.forEach(async () => this.getContainerSize());\n });\n\n protected override firstUpdated() {\n super.firstUpdated();\n this.handleSlotValidation();\n this.addPropertiesToStepIndicatorItems();\n }\n\n /**\n * if the parent container is not wide enough to accomodate step-indicator\n * isNarrowContainer prop helps with the responsive design\n * @internal\n * */\n getContainerSize() {\n const { parentElement } = this;\n const { length } = this.stepIndicatorItems;\n // Calculates the minimum step indicator width, 90 is the min-width for step-indicator item\n const controlWidth = 90 * length;\n if (parentElement) {\n this.isNarrowContainer = parentElement.clientWidth <= controlWidth;\n }\n }\n\n /**\n * @internal\n */\n @queryAssignedElements({\n slot: undefined,\n selector: 'pds-step-indicator-item',\n })\n stepIndicatorItems: HTMLElement[];\n\n /**\n * @internal\n * pushes properties down to subcomponent step indicator items\n */\n addPropertiesToStepIndicatorItems() {\n this.stepIndicatorItems.forEach((stepIndicatorItem) => {\n if (this.inverted) {\n stepIndicatorItem.setAttribute('variant', 'inverted');\n } else {\n stepIndicatorItem.removeAttribute('variant');\n }\n });\n }\n\n handleSlotChange(e: Event) {\n this.handleSlotValidation(e);\n this.addPropertiesToStepIndicatorItems();\n }\n\n updated() {\n if (this.variant === 'horizontal') {\n this.resizeObserver.observe(this);\n }\n }\n\n /**\n * @internal\n */\n get classNames() {\n return {\n [this.variant]: !!this.variant,\n inverted: !!this.inverted,\n 'narrow-container': !!this.isNarrowContainer,\n };\n }\n\n listTemplate() {\n return html`