UNPKG

@carbon/ibm-products-web-components

Version:
69 lines (67 loc) 2.15 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 checklist_default from "./checklist.scss.js"; import { LitElement, nothing } from "lit"; import { property } from "lit/decorators.js"; import { carbonElement } from "@carbon/web-components/es/globals/decorators/carbon-element.js"; //#region src/components/checklist/checklist-chart.ts /** * @license * * Copyright IBM Corp. 2025 * * 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--checklist__chart`; /** * Clamps a value between a minimum and maximum. * If the value, min, or max is NaN, the function returns void. * */ const clamp = (value, min, max) => { if (isNaN(value) || isNaN(min) || isNaN(max)) return; if (max !== void 0) value = value <= max ? value : max; if (min !== void 0) value = value >= min ? value : min; return value; }; /** * @element c4p-checklist-chart */ let CDSChecklistChart = class CDSChecklistChart extends LitElement { constructor(..._args) { super(..._args); this.value = 0; } connectedCallback() { super.connectedCallback(); this.classList.add(`${blockClass}`); } _updateChart(value) { this.style.setProperty(`--c4p-num-degrees`, `${clamp(value * 360, 0, 360)}deg`); } static get observedAttributes() { return ["value"]; } attributeChangedCallback(name, oldValue, newValue) { if (name === "value" && oldValue !== newValue) this._updateChart(newValue); } render() { return nothing; } static { this.styles = checklist_default; } }; __decorate([property({ type: Number })], CDSChecklistChart.prototype, "value", void 0); CDSChecklistChart = __decorate([carbonElement(`c4p-checklist-chart`)], CDSChecklistChart); var checklist_chart_default = CDSChecklistChart; //#endregion export { checklist_chart_default as default }; //# sourceMappingURL=checklist-chart.js.map