@carbon/ibm-products-web-components
Version:
Carbon for IBM Products Web Components
82 lines (80 loc) • 2.54 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import "../../globals/settings.js";
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.127.0/helpers/decorate.js";
import { stackManager } from "./stack-signal.js";
import { LitElement, html } from "lit";
import { property } from "lit/decorators.js";
import { carbonElement } from "@carbon/web-components/es/globals/decorators/carbon-element.js";
//#region src/components/tearsheet-preview/tearsheet-stack.ts
/**
* @license
*
* Copyright IBM Corp. 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Tearsheet Stack wrapper component - Enables stacking behavior for child tearsheets.
*
* This component provides a context for tearsheet stacking, similar to React's StackProvider.
* Wrap multiple tearsheets with this component to enable stacking behavior.
*
* @element c4p-tearsheet-stack
* @slot - Default slot for tearsheet children
*/
let CDSTearsheetStack = class CDSTearsheetStack extends LitElement {
constructor(..._args) {
super(..._args);
this.stackStepSize = "lg";
this._isActive = false;
}
connectedCallback() {
super.connectedCallback();
stackManager.setStackStepSize(this.stackStepSize);
this._isActive = true;
this.dispatchEvent(new CustomEvent(`c4p-tearsheet-stack-connected`, {
bubbles: true,
composed: true,
detail: { stackStepSize: this.stackStepSize }
}));
}
disconnectedCallback() {
super.disconnectedCallback();
if (this._isActive) {
stackManager.reset();
this._isActive = false;
}
}
updated(changedProperties) {
super.updated(changedProperties);
if (changedProperties.has("stackStepSize")) {
stackManager.setStackStepSize(this.stackStepSize);
this.dispatchEvent(new CustomEvent(`c4p-tearsheet-stack-step-size-changed`, {
bubbles: true,
composed: true,
detail: { stackStepSize: this.stackStepSize }
}));
}
}
render() {
return html`<slot></slot>`;
}
static {
this.styles = [];
}
};
__decorate([property({
type: String,
attribute: "stack-step-size"
})], CDSTearsheetStack.prototype, "stackStepSize", void 0);
CDSTearsheetStack = __decorate([carbonElement(`c4p-tearsheet-stack`)], CDSTearsheetStack);
var tearsheet_stack_default = CDSTearsheetStack;
//#endregion
export { tearsheet_stack_default as default };
//# sourceMappingURL=tearsheet-stack.js.map