UNPKG

@carbon/ibm-products-web-components

Version:
96 lines (94 loc) 3.57 kB
/** * 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 tearsheet_default from "./tearsheet.scss.js"; import { tearsheetSignal } from "./tearsheet-signal.js"; import "../side-panel/index.js"; import { LitElement, html } from "lit"; import { property } from "lit/decorators.js"; import HostListenerMixin from "@carbon/web-components/es/globals/mixins/host-listener.js"; import { carbonElement } from "@carbon/web-components/es/globals/decorators/carbon-element.js"; import { classMap } from "lit-html/directives/class-map.js"; import { SignalWatcher } from "@lit-labs/signals"; //#region src/components/tearsheet-preview/tearsheet-summary-content.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. */ const blockClass = `c4p--tearsheet__next`; /** * Tearsheet Summary Content component - Right-side panel for summary details. * Automatically converts to a slide-in panel on small screens. * * @element c4p-tearsheet-summary-content * @slot - Content for the summary panel * @fires cds-custom-tearsheet-summary-closed - Fired when the summary panel is closed (mobile only) */ let CDSTearsheetSummaryContent = class CDSTearsheetSummaryContent extends SignalWatcher(HostListenerMixin(LitElement)) { constructor(..._args) { super(..._args); this.slot = "summary-content"; this.isFlush = false; this.summaryPanelOpen = false; this.summaryPanelAriaLabel = "Summary panel"; this.handleClose = () => { this.summaryPanelOpen = false; this.dispatchEvent(new CustomEvent("cds-custom-tearsheet-summary-closed", { bubbles: true, composed: true })); }; } firstUpdated() { this.classList.add(`${blockClass}__summary-content`); } render() { const { isSm } = tearsheetSignal.get(); const classes = classMap({ [`${blockClass}__flush`]: this.isFlush }); return !isSm ? html` <aside class="${classes}" aria-label="${this.summaryPanelAriaLabel}" > <slot></slot> </aside>` : html` <c4p-side-panel size="sm" ?slide-in=${true} ?open="${this.summaryPanelOpen}" placement="right" aria-label="${this.summaryPanelAriaLabel}" aria-modal="true" @c4p-side-panel-closed="${this.handleClose}" > <slot></slot> </c4p-side-panel>`; } static { this.styles = tearsheet_default; } }; __decorate([property({ reflect: true })], CDSTearsheetSummaryContent.prototype, "slot", void 0); __decorate([property({ type: Boolean, reflect: true, attribute: "is-flush" })], CDSTearsheetSummaryContent.prototype, "isFlush", void 0); __decorate([property({ type: Boolean, reflect: true, attribute: "summary-panel-open" })], CDSTearsheetSummaryContent.prototype, "summaryPanelOpen", void 0); __decorate([property({ attribute: "summary-panel-aria-label" })], CDSTearsheetSummaryContent.prototype, "summaryPanelAriaLabel", void 0); CDSTearsheetSummaryContent = __decorate([carbonElement(`c4p-tearsheet-summary-content`)], CDSTearsheetSummaryContent); var tearsheet_summary_content_default = CDSTearsheetSummaryContent; //#endregion export { tearsheet_summary_content_default as default }; //# sourceMappingURL=tearsheet-summary-content.js.map