@tartaguti/ui-components 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +192 -2
- package/THIRD-PARTY-NOTICES.md +29 -0
- package/custom-elements.json +16899 -0
- package/dist/accordion/tt-accordion-item.d.ts +32 -0
- package/dist/accordion/tt-accordion-item.d.ts.map +1 -0
- package/dist/accordion/tt-accordion-item.js +247 -0
- package/dist/accordion/tt-accordion-item.js.map +1 -0
- package/dist/accordion/tt-accordion.d.ts +28 -0
- package/dist/accordion/tt-accordion.d.ts.map +1 -0
- package/dist/accordion/tt-accordion.js +148 -0
- package/dist/accordion/tt-accordion.js.map +1 -0
- package/dist/bento/tt-bento-item.d.ts +35 -0
- package/dist/bento/tt-bento-item.d.ts.map +1 -0
- package/dist/bento/tt-bento-item.js +201 -0
- package/dist/bento/tt-bento-item.js.map +1 -0
- package/dist/bento/tt-bento.d.ts +25 -0
- package/dist/bento/tt-bento.d.ts.map +1 -0
- package/dist/bento/tt-bento.js +314 -0
- package/dist/bento/tt-bento.js.map +1 -0
- package/dist/floating.d.ts +61 -0
- package/dist/floating.d.ts.map +1 -0
- package/dist/floating.js +120 -0
- package/dist/floating.js.map +1 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/tt-draggable.d.ts +29 -0
- package/dist/interaction/tt-draggable.d.ts.map +1 -0
- package/dist/interaction/tt-draggable.js +66 -0
- package/dist/interaction/tt-draggable.js.map +1 -0
- package/dist/interaction/tt-droppable.d.ts +37 -0
- package/dist/interaction/tt-droppable.d.ts.map +1 -0
- package/dist/interaction/tt-droppable.js +108 -0
- package/dist/interaction/tt-droppable.js.map +1 -0
- package/dist/interaction/tt-resizable.d.ts +45 -0
- package/dist/interaction/tt-resizable.d.ts.map +1 -0
- package/dist/interaction/tt-resizable.js +210 -0
- package/dist/interaction/tt-resizable.js.map +1 -0
- package/dist/interaction/tt-reveal.d.ts +54 -0
- package/dist/interaction/tt-reveal.d.ts.map +1 -0
- package/dist/interaction/tt-reveal.js +302 -0
- package/dist/interaction/tt-reveal.js.map +1 -0
- package/dist/motion.d.ts +8 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +49 -0
- package/dist/motion.js.map +1 -0
- package/dist/overlay.d.ts +7 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +121 -0
- package/dist/overlay.js.map +1 -0
- package/dist/safe-url.d.ts +14 -0
- package/dist/safe-url.d.ts.map +1 -0
- package/dist/safe-url.js +46 -0
- package/dist/safe-url.js.map +1 -0
- package/dist/scroll-lock.d.ts +22 -0
- package/dist/scroll-lock.d.ts.map +1 -0
- package/dist/scroll-lock.js +56 -0
- package/dist/scroll-lock.js.map +1 -0
- package/dist/sidebar/tt-menu-group.d.ts +69 -0
- package/dist/sidebar/tt-menu-group.d.ts.map +1 -0
- package/dist/sidebar/tt-menu-group.js +358 -0
- package/dist/sidebar/tt-menu-group.js.map +1 -0
- package/dist/sidebar/tt-menu-item.d.ts +70 -0
- package/dist/sidebar/tt-menu-item.d.ts.map +1 -0
- package/dist/sidebar/tt-menu-item.js +502 -0
- package/dist/sidebar/tt-menu-item.js.map +1 -0
- package/dist/sidebar/tt-sidebar-footer.d.ts +39 -0
- package/dist/sidebar/tt-sidebar-footer.d.ts.map +1 -0
- package/dist/sidebar/tt-sidebar-footer.js +205 -0
- package/dist/sidebar/tt-sidebar-footer.js.map +1 -0
- package/dist/sidebar/tt-sidebar-header.d.ts +31 -0
- package/dist/sidebar/tt-sidebar-header.d.ts.map +1 -0
- package/dist/sidebar/tt-sidebar-header.js +150 -0
- package/dist/sidebar/tt-sidebar-header.js.map +1 -0
- package/dist/sidebar/tt-sidebar.d.ts +72 -0
- package/dist/sidebar/tt-sidebar.d.ts.map +1 -0
- package/dist/sidebar/tt-sidebar.js +539 -0
- package/dist/sidebar/tt-sidebar.js.map +1 -0
- package/dist/sr-only.d.ts +15 -0
- package/dist/sr-only.d.ts.map +1 -0
- package/dist/sr-only.js +27 -0
- package/dist/sr-only.js.map +1 -0
- package/dist/tokens.css +1124 -0
- package/dist/tt-alert.d.ts +26 -0
- package/dist/tt-alert.d.ts.map +1 -0
- package/dist/tt-alert.js +165 -0
- package/dist/tt-alert.js.map +1 -0
- package/dist/tt-aspect-ratio.d.ts +40 -0
- package/dist/tt-aspect-ratio.d.ts.map +1 -0
- package/dist/tt-aspect-ratio.js +98 -0
- package/dist/tt-aspect-ratio.js.map +1 -0
- package/dist/tt-auth.d.ts +75 -0
- package/dist/tt-auth.d.ts.map +1 -0
- package/dist/tt-auth.js +520 -0
- package/dist/tt-auth.js.map +1 -0
- package/dist/tt-avatar.d.ts +26 -0
- package/dist/tt-avatar.d.ts.map +1 -0
- package/dist/tt-avatar.js +169 -0
- package/dist/tt-avatar.js.map +1 -0
- package/dist/tt-badge.d.ts +36 -0
- package/dist/tt-badge.d.ts.map +1 -0
- package/dist/tt-badge.js +135 -0
- package/dist/tt-badge.js.map +1 -0
- package/dist/tt-breadcrumbs.d.ts +22 -0
- package/dist/tt-breadcrumbs.d.ts.map +1 -0
- package/dist/tt-breadcrumbs.js +144 -0
- package/dist/tt-breadcrumbs.js.map +1 -0
- package/dist/tt-button-group.d.ts +32 -0
- package/dist/tt-button-group.d.ts.map +1 -0
- package/dist/tt-button-group.js +132 -0
- package/dist/tt-button-group.js.map +1 -0
- package/dist/tt-button.d.ts +31 -0
- package/dist/tt-button.d.ts.map +1 -0
- package/dist/tt-button.js +483 -0
- package/dist/tt-button.js.map +1 -0
- package/dist/tt-card.d.ts +26 -0
- package/dist/tt-card.d.ts.map +1 -0
- package/dist/tt-card.js +429 -0
- package/dist/tt-card.js.map +1 -0
- package/dist/tt-chart.d.ts +36 -0
- package/dist/tt-chart.d.ts.map +1 -0
- package/dist/tt-chart.js +332 -0
- package/dist/tt-chart.js.map +1 -0
- package/dist/tt-checkbox-group.d.ts +38 -0
- package/dist/tt-checkbox-group.d.ts.map +1 -0
- package/dist/tt-checkbox-group.js +243 -0
- package/dist/tt-checkbox-group.js.map +1 -0
- package/dist/tt-checkbox.d.ts +35 -0
- package/dist/tt-checkbox.d.ts.map +1 -0
- package/dist/tt-checkbox.js +354 -0
- package/dist/tt-checkbox.js.map +1 -0
- package/dist/tt-code-block.d.ts +37 -0
- package/dist/tt-code-block.d.ts.map +1 -0
- package/dist/tt-code-block.js +409 -0
- package/dist/tt-code-block.js.map +1 -0
- package/dist/tt-collapsible.d.ts +71 -0
- package/dist/tt-collapsible.d.ts.map +1 -0
- package/dist/tt-collapsible.js +206 -0
- package/dist/tt-collapsible.js.map +1 -0
- package/dist/tt-combobox.d.ts +107 -0
- package/dist/tt-combobox.d.ts.map +1 -0
- package/dist/tt-combobox.js +816 -0
- package/dist/tt-combobox.js.map +1 -0
- package/dist/tt-company-card.d.ts +30 -0
- package/dist/tt-company-card.d.ts.map +1 -0
- package/dist/tt-company-card.js +382 -0
- package/dist/tt-company-card.js.map +1 -0
- package/dist/tt-comparison-table.d.ts +59 -0
- package/dist/tt-comparison-table.d.ts.map +1 -0
- package/dist/tt-comparison-table.js +441 -0
- package/dist/tt-comparison-table.js.map +1 -0
- package/dist/tt-component-doc.d.ts +63 -0
- package/dist/tt-component-doc.d.ts.map +1 -0
- package/dist/tt-component-doc.js +585 -0
- package/dist/tt-component-doc.js.map +1 -0
- package/dist/tt-confirm.d.ts +45 -0
- package/dist/tt-confirm.d.ts.map +1 -0
- package/dist/tt-confirm.js +151 -0
- package/dist/tt-confirm.js.map +1 -0
- package/dist/tt-contact-list.d.ts +18 -0
- package/dist/tt-contact-list.d.ts.map +1 -0
- package/dist/tt-contact-list.js +101 -0
- package/dist/tt-contact-list.js.map +1 -0
- package/dist/tt-copy-button.d.ts +25 -0
- package/dist/tt-copy-button.d.ts.map +1 -0
- package/dist/tt-copy-button.js +194 -0
- package/dist/tt-copy-button.js.map +1 -0
- package/dist/tt-data-table.d.ts +96 -0
- package/dist/tt-data-table.d.ts.map +1 -0
- package/dist/tt-data-table.js +812 -0
- package/dist/tt-data-table.js.map +1 -0
- package/dist/tt-divider.d.ts +19 -0
- package/dist/tt-divider.d.ts.map +1 -0
- package/dist/tt-divider.js +104 -0
- package/dist/tt-divider.js.map +1 -0
- package/dist/tt-drawer.d.ts +38 -0
- package/dist/tt-drawer.d.ts.map +1 -0
- package/dist/tt-drawer.js +433 -0
- package/dist/tt-drawer.js.map +1 -0
- package/dist/tt-dropdown-menu.d.ts +57 -0
- package/dist/tt-dropdown-menu.d.ts.map +1 -0
- package/dist/tt-dropdown-menu.js +631 -0
- package/dist/tt-dropdown-menu.js.map +1 -0
- package/dist/tt-empty-state.d.ts +13 -0
- package/dist/tt-empty-state.d.ts.map +1 -0
- package/dist/tt-empty-state.js +94 -0
- package/dist/tt-empty-state.js.map +1 -0
- package/dist/tt-example.d.ts +33 -0
- package/dist/tt-example.d.ts.map +1 -0
- package/dist/tt-example.js +250 -0
- package/dist/tt-example.js.map +1 -0
- package/dist/tt-file-upload.d.ts +85 -0
- package/dist/tt-file-upload.d.ts.map +1 -0
- package/dist/tt-file-upload.js +662 -0
- package/dist/tt-file-upload.js.map +1 -0
- package/dist/tt-filter.d.ts +62 -0
- package/dist/tt-filter.d.ts.map +1 -0
- package/dist/tt-filter.js +393 -0
- package/dist/tt-filter.js.map +1 -0
- package/dist/tt-form.d.ts +33 -0
- package/dist/tt-form.d.ts.map +1 -0
- package/dist/tt-form.js +202 -0
- package/dist/tt-form.js.map +1 -0
- package/dist/tt-grid.d.ts +22 -0
- package/dist/tt-grid.d.ts.map +1 -0
- package/dist/tt-grid.js +106 -0
- package/dist/tt-grid.js.map +1 -0
- package/dist/tt-icon.d.ts +20 -0
- package/dist/tt-icon.d.ts.map +1 -0
- package/dist/tt-icon.js +510 -0
- package/dist/tt-icon.js.map +1 -0
- package/dist/tt-image.d.ts +59 -0
- package/dist/tt-image.d.ts.map +1 -0
- package/dist/tt-image.js +314 -0
- package/dist/tt-image.js.map +1 -0
- package/dist/tt-inbox.d.ts +45 -0
- package/dist/tt-inbox.d.ts.map +1 -0
- package/dist/tt-inbox.js +275 -0
- package/dist/tt-inbox.js.map +1 -0
- package/dist/tt-input.d.ts +43 -0
- package/dist/tt-input.d.ts.map +1 -0
- package/dist/tt-input.js +476 -0
- package/dist/tt-input.js.map +1 -0
- package/dist/tt-kbd.d.ts +39 -0
- package/dist/tt-kbd.d.ts.map +1 -0
- package/dist/tt-kbd.js +145 -0
- package/dist/tt-kbd.js.map +1 -0
- package/dist/tt-key-values.d.ts +17 -0
- package/dist/tt-key-values.d.ts.map +1 -0
- package/dist/tt-key-values.js +126 -0
- package/dist/tt-key-values.js.map +1 -0
- package/dist/tt-knowledge-doc.d.ts +24 -0
- package/dist/tt-knowledge-doc.d.ts.map +1 -0
- package/dist/tt-knowledge-doc.js +120 -0
- package/dist/tt-knowledge-doc.js.map +1 -0
- package/dist/tt-layout.d.ts +36 -0
- package/dist/tt-layout.d.ts.map +1 -0
- package/dist/tt-layout.js +318 -0
- package/dist/tt-layout.js.map +1 -0
- package/dist/tt-modal.d.ts +32 -0
- package/dist/tt-modal.d.ts.map +1 -0
- package/dist/tt-modal.js +553 -0
- package/dist/tt-modal.js.map +1 -0
- package/dist/tt-navbar.d.ts +33 -0
- package/dist/tt-navbar.d.ts.map +1 -0
- package/dist/tt-navbar.js +390 -0
- package/dist/tt-navbar.js.map +1 -0
- package/dist/tt-page-header.d.ts +28 -0
- package/dist/tt-page-header.d.ts.map +1 -0
- package/dist/tt-page-header.js +166 -0
- package/dist/tt-page-header.js.map +1 -0
- package/dist/tt-page.d.ts +14 -0
- package/dist/tt-page.d.ts.map +1 -0
- package/dist/tt-page.js +163 -0
- package/dist/tt-page.js.map +1 -0
- package/dist/tt-pagination.d.ts +27 -0
- package/dist/tt-pagination.d.ts.map +1 -0
- package/dist/tt-pagination.js +194 -0
- package/dist/tt-pagination.js.map +1 -0
- package/dist/tt-preview.d.ts +11 -0
- package/dist/tt-preview.d.ts.map +1 -0
- package/dist/tt-preview.js +68 -0
- package/dist/tt-preview.js.map +1 -0
- package/dist/tt-product.d.ts +40 -0
- package/dist/tt-product.d.ts.map +1 -0
- package/dist/tt-product.js +590 -0
- package/dist/tt-product.js.map +1 -0
- package/dist/tt-profile-card.d.ts +23 -0
- package/dist/tt-profile-card.d.ts.map +1 -0
- package/dist/tt-profile-card.js +199 -0
- package/dist/tt-profile-card.js.map +1 -0
- package/dist/tt-progress.d.ts +26 -0
- package/dist/tt-progress.d.ts.map +1 -0
- package/dist/tt-progress.js +156 -0
- package/dist/tt-progress.js.map +1 -0
- package/dist/tt-quantity.d.ts +36 -0
- package/dist/tt-quantity.d.ts.map +1 -0
- package/dist/tt-quantity.js +396 -0
- package/dist/tt-quantity.js.map +1 -0
- package/dist/tt-radio-group.d.ts +50 -0
- package/dist/tt-radio-group.d.ts.map +1 -0
- package/dist/tt-radio-group.js +372 -0
- package/dist/tt-radio-group.js.map +1 -0
- package/dist/tt-rating.d.ts +54 -0
- package/dist/tt-rating.d.ts.map +1 -0
- package/dist/tt-rating.js +312 -0
- package/dist/tt-rating.js.map +1 -0
- package/dist/tt-search.d.ts +47 -0
- package/dist/tt-search.d.ts.map +1 -0
- package/dist/tt-search.js +360 -0
- package/dist/tt-search.js.map +1 -0
- package/dist/tt-section.d.ts +13 -0
- package/dist/tt-section.d.ts.map +1 -0
- package/dist/tt-section.js +98 -0
- package/dist/tt-section.js.map +1 -0
- package/dist/tt-select.d.ts +62 -0
- package/dist/tt-select.d.ts.map +1 -0
- package/dist/tt-select.js +662 -0
- package/dist/tt-select.js.map +1 -0
- package/dist/tt-skeleton.d.ts +20 -0
- package/dist/tt-skeleton.d.ts.map +1 -0
- package/dist/tt-skeleton.js +143 -0
- package/dist/tt-skeleton.js.map +1 -0
- package/dist/tt-slider.d.ts +74 -0
- package/dist/tt-slider.d.ts.map +1 -0
- package/dist/tt-slider.js +426 -0
- package/dist/tt-slider.js.map +1 -0
- package/dist/tt-social-links.d.ts +34 -0
- package/dist/tt-social-links.d.ts.map +1 -0
- package/dist/tt-social-links.js +242 -0
- package/dist/tt-social-links.js.map +1 -0
- package/dist/tt-sparkline.d.ts +19 -0
- package/dist/tt-sparkline.d.ts.map +1 -0
- package/dist/tt-sparkline.js +191 -0
- package/dist/tt-sparkline.js.map +1 -0
- package/dist/tt-spinner.d.ts +19 -0
- package/dist/tt-spinner.d.ts.map +1 -0
- package/dist/tt-spinner.js +93 -0
- package/dist/tt-spinner.js.map +1 -0
- package/dist/tt-stack.d.ts +42 -0
- package/dist/tt-stack.d.ts.map +1 -0
- package/dist/tt-stack.js +158 -0
- package/dist/tt-stack.js.map +1 -0
- package/dist/tt-stat.d.ts +17 -0
- package/dist/tt-stat.d.ts.map +1 -0
- package/dist/tt-stat.js +134 -0
- package/dist/tt-stat.js.map +1 -0
- package/dist/tt-switch.d.ts +39 -0
- package/dist/tt-switch.d.ts.map +1 -0
- package/dist/tt-switch.js +254 -0
- package/dist/tt-switch.js.map +1 -0
- package/dist/tt-switcher.d.ts +23 -0
- package/dist/tt-switcher.d.ts.map +1 -0
- package/dist/tt-switcher.js +203 -0
- package/dist/tt-switcher.js.map +1 -0
- package/dist/tt-table-cell.d.ts +26 -0
- package/dist/tt-table-cell.d.ts.map +1 -0
- package/dist/tt-table-cell.js +121 -0
- package/dist/tt-table-cell.js.map +1 -0
- package/dist/tt-table-row.d.ts +31 -0
- package/dist/tt-table-row.d.ts.map +1 -0
- package/dist/tt-table-row.js +72 -0
- package/dist/tt-table-row.js.map +1 -0
- package/dist/tt-table.d.ts +44 -0
- package/dist/tt-table.d.ts.map +1 -0
- package/dist/tt-table.js +270 -0
- package/dist/tt-table.js.map +1 -0
- package/dist/tt-tabs.d.ts +31 -0
- package/dist/tt-tabs.d.ts.map +1 -0
- package/dist/tt-tabs.js +223 -0
- package/dist/tt-tabs.js.map +1 -0
- package/dist/tt-tag-list.d.ts +19 -0
- package/dist/tt-tag-list.d.ts.map +1 -0
- package/dist/tt-tag-list.js +136 -0
- package/dist/tt-tag-list.js.map +1 -0
- package/dist/tt-text.d.ts +52 -0
- package/dist/tt-text.d.ts.map +1 -0
- package/dist/tt-text.js +337 -0
- package/dist/tt-text.js.map +1 -0
- package/dist/tt-textarea.d.ts +43 -0
- package/dist/tt-textarea.d.ts.map +1 -0
- package/dist/tt-textarea.js +356 -0
- package/dist/tt-textarea.js.map +1 -0
- package/dist/tt-thread.d.ts +62 -0
- package/dist/tt-thread.d.ts.map +1 -0
- package/dist/tt-thread.js +374 -0
- package/dist/tt-thread.js.map +1 -0
- package/dist/tt-toast.d.ts +49 -0
- package/dist/tt-toast.d.ts.map +1 -0
- package/dist/tt-toast.js +440 -0
- package/dist/tt-toast.js.map +1 -0
- package/dist/tt-toggle-group.d.ts +73 -0
- package/dist/tt-toggle-group.d.ts.map +1 -0
- package/dist/tt-toggle-group.js +273 -0
- package/dist/tt-toggle-group.js.map +1 -0
- package/dist/tt-toggle.d.ts +54 -0
- package/dist/tt-toggle.d.ts.map +1 -0
- package/dist/tt-toggle.js +232 -0
- package/dist/tt-toggle.js.map +1 -0
- package/dist/tt-toolbar.d.ts +26 -0
- package/dist/tt-toolbar.d.ts.map +1 -0
- package/dist/tt-toolbar.js +164 -0
- package/dist/tt-toolbar.js.map +1 -0
- package/dist/tt-tooltip.d.ts +42 -0
- package/dist/tt-tooltip.d.ts.map +1 -0
- package/dist/tt-tooltip.js +299 -0
- package/dist/tt-tooltip.js.map +1 -0
- package/package.json +84 -4
- package/vscode.html-custom-data.json +2911 -0
package/dist/tt-chart.js
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html, css } from "lit";
|
|
8
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
9
|
+
import { Chart, registerables } from "chart.js";
|
|
10
|
+
import { srOnly } from "./sr-only.js";
|
|
11
|
+
// Registered once for the module, not per instance.
|
|
12
|
+
Chart.register(...registerables);
|
|
13
|
+
let TTChart = class TTChart extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.type = "bar";
|
|
17
|
+
this.labels = [];
|
|
18
|
+
this.series = [];
|
|
19
|
+
this.legend = false;
|
|
20
|
+
this.stacked = false;
|
|
21
|
+
// Chart.js draws to a canvas, which is one opaque box to a screen
|
|
22
|
+
// reader. This is the only description it will ever get.
|
|
23
|
+
this.label = "";
|
|
24
|
+
/*
|
|
25
|
+
Frames spent waiting for the design tokens to become readable. Bounded
|
|
26
|
+
so a genuinely missing stylesheet degrades to a drawn chart rather
|
|
27
|
+
than an empty box that retries forever.
|
|
28
|
+
*/
|
|
29
|
+
this.waited = 0;
|
|
30
|
+
}
|
|
31
|
+
token(name) {
|
|
32
|
+
return getComputedStyle(this).getPropertyValue(name).trim();
|
|
33
|
+
}
|
|
34
|
+
get palette() {
|
|
35
|
+
return [
|
|
36
|
+
this.token("--tt-chart-1"),
|
|
37
|
+
this.token("--tt-chart-2"),
|
|
38
|
+
this.token("--tt-chart-3"),
|
|
39
|
+
this.token("--tt-chart-4"),
|
|
40
|
+
this.token("--tt-chart-5"),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
connectedCallback() {
|
|
44
|
+
super.connectedCallback();
|
|
45
|
+
// Watch the dark class and the theme preset on <html> and repaint.
|
|
46
|
+
// Canvas will not restyle itself the way inherited custom properties
|
|
47
|
+
// would, so a theme switch left the chart in the old colours.
|
|
48
|
+
this.themeObserver = new MutationObserver(() => this.rebuild());
|
|
49
|
+
this.themeObserver.observe(document.documentElement, {
|
|
50
|
+
attributes: true,
|
|
51
|
+
attributeFilter: ["class", "data-theme"],
|
|
52
|
+
});
|
|
53
|
+
/*
|
|
54
|
+
Reconnected after a move: drag and drop, or reparenting into a modal.
|
|
55
|
+
disconnectedCallback destroyed the chart, and firstUpdated, which
|
|
56
|
+
built it, only ever runs once per element. Without this the canvas
|
|
57
|
+
stays blank for the rest of the element's life. hasUpdated is false
|
|
58
|
+
on the very first connect, which firstUpdated already covers.
|
|
59
|
+
*/
|
|
60
|
+
if (this.hasUpdated) {
|
|
61
|
+
this.rebuild();
|
|
62
|
+
this.observeSize();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
disconnectedCallback() {
|
|
66
|
+
this.themeObserver?.disconnect();
|
|
67
|
+
this.resizeObserver?.disconnect();
|
|
68
|
+
// Chart.js holds listeners and an animation loop. Without destroy()
|
|
69
|
+
// every navigation leaks one chart.
|
|
70
|
+
this.chart?.destroy();
|
|
71
|
+
this.chart = undefined;
|
|
72
|
+
super.disconnectedCallback();
|
|
73
|
+
}
|
|
74
|
+
/*
|
|
75
|
+
Size only. The first build happens in updated(), which runs right
|
|
76
|
+
after this in the same cycle and already sees every property as
|
|
77
|
+
changed. Building here as well created a chart and destroyed it again
|
|
78
|
+
on every mount.
|
|
79
|
+
*/
|
|
80
|
+
firstUpdated() {
|
|
81
|
+
this.observeSize();
|
|
82
|
+
}
|
|
83
|
+
// Chart.js measures its container. Inside a shadow root, inside flex
|
|
84
|
+
// or grid, that measurement is often wrong on first paint, so drive
|
|
85
|
+
// resizing explicitly instead of trusting responsive: true.
|
|
86
|
+
observeSize() {
|
|
87
|
+
this.resizeObserver?.disconnect();
|
|
88
|
+
this.resizeObserver = new ResizeObserver(() => this.chart?.resize());
|
|
89
|
+
this.resizeObserver.observe(this);
|
|
90
|
+
}
|
|
91
|
+
updated(changed) {
|
|
92
|
+
if (changed.has("type") ||
|
|
93
|
+
changed.has("labels") ||
|
|
94
|
+
changed.has("series") ||
|
|
95
|
+
changed.has("legend") ||
|
|
96
|
+
changed.has("stacked")) {
|
|
97
|
+
this.rebuild();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
rebuild() {
|
|
101
|
+
// Also reached from a pending animation frame. A chart built after the
|
|
102
|
+
// element left the page is never destroyed: disconnectedCallback has
|
|
103
|
+
// already run, so its Chart.js listeners and animation loop leak.
|
|
104
|
+
if (!this.canvas || !this.isConnected)
|
|
105
|
+
return;
|
|
106
|
+
const palette = this.palette;
|
|
107
|
+
/*
|
|
108
|
+
DO NOT PAINT BEFORE THE TOKENS RESOLVE.
|
|
109
|
+
|
|
110
|
+
A canvas is pixels. Whatever colour it is given is baked in, and it
|
|
111
|
+
will not restyle itself when a stylesheet arrives later the way
|
|
112
|
+
inherited custom properties would. Chart.js also substitutes its own
|
|
113
|
+
blue-red-orange defaults for any colour it is handed as an empty
|
|
114
|
+
string, so building early does not leave a chart waiting to be
|
|
115
|
+
corrected, it leaves a confidently wrong one.
|
|
116
|
+
|
|
117
|
+
And a stylesheet really can arrive after the first paint: a dev
|
|
118
|
+
server injects CSS at runtime, and a late <link> does the same in
|
|
119
|
+
production. So wait a frame and look again.
|
|
120
|
+
|
|
121
|
+
This is what made every chart render in Chart.js blue, and what made
|
|
122
|
+
a doughnut come out in one flat colour: its per-slice array of empty
|
|
123
|
+
strings is not a value Chart.js substitutes a palette for.
|
|
124
|
+
*/
|
|
125
|
+
if (!palette[0] && this.waited < 30) {
|
|
126
|
+
this.waited += 1;
|
|
127
|
+
requestAnimationFrame(() => this.rebuild());
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
this.chart?.destroy();
|
|
131
|
+
const grid = this.token("--tt-border");
|
|
132
|
+
const text = this.token("--tt-muted-foreground");
|
|
133
|
+
const surface = this.token("--tt-popover");
|
|
134
|
+
const surfaceText = this.token("--tt-popover-foreground");
|
|
135
|
+
// What a pie's slices are cut apart against. The card, not the
|
|
136
|
+
// popover: this is the surface the chart SITS on, not the one its
|
|
137
|
+
// tooltip is drawn on, and the two only happen to match today.
|
|
138
|
+
const sliceGap = this.token("--tt-card");
|
|
139
|
+
/*
|
|
140
|
+
The typeface, resolved the same way as the colours. Chart.js draws
|
|
141
|
+
its own text in Helvetica unless told otherwise, so every axis label
|
|
142
|
+
and tooltip was in a different face from the page around it. The
|
|
143
|
+
size stays a plain 12, the --tt-text-xs size: a canvas wants pixels
|
|
144
|
+
and the token is in rem.
|
|
145
|
+
*/
|
|
146
|
+
const font = {
|
|
147
|
+
family: this.token("--tt-font-sans") || undefined,
|
|
148
|
+
size: 12,
|
|
149
|
+
};
|
|
150
|
+
/*
|
|
151
|
+
WHICH AXIS THE PALETTE RUNS ALONG depends on the chart type, and
|
|
152
|
+
getting it wrong is why a pie used to come out in one flat colour.
|
|
153
|
+
|
|
154
|
+
A line or a bar compares SERIES, so one colour per dataset is right
|
|
155
|
+
and every point in that dataset shares it. A pie, doughnut or polar
|
|
156
|
+
area has a single dataset whose SLICES are the things being
|
|
157
|
+
compared, so the colour has to vary per data point. Indexing by the
|
|
158
|
+
dataset there gives every slice palette[0] and the chart stops
|
|
159
|
+
saying anything at all.
|
|
160
|
+
*/
|
|
161
|
+
const sliced = this.type === "pie" ||
|
|
162
|
+
this.type === "doughnut" ||
|
|
163
|
+
this.type === "polarArea";
|
|
164
|
+
const config = {
|
|
165
|
+
type: this.type,
|
|
166
|
+
data: {
|
|
167
|
+
labels: this.labels,
|
|
168
|
+
datasets: this.series.map((s, i) => ({
|
|
169
|
+
label: s.label,
|
|
170
|
+
data: s.data,
|
|
171
|
+
backgroundColor: sliced
|
|
172
|
+
? s.data.map((_, j) => palette[j % palette.length])
|
|
173
|
+
: palette[i % palette.length],
|
|
174
|
+
/*
|
|
175
|
+
Slices are separated by the gap between them, so their border
|
|
176
|
+
is the surface behind the chart rather than their own fill.
|
|
177
|
+
Chart.js defaults this to white, which draws five white hairs
|
|
178
|
+
across a dark theme.
|
|
179
|
+
*/
|
|
180
|
+
borderColor: sliced ? sliceGap : palette[i % palette.length],
|
|
181
|
+
borderWidth: 2,
|
|
182
|
+
tension: 0.3,
|
|
183
|
+
pointRadius: 3,
|
|
184
|
+
borderRadius: 4,
|
|
185
|
+
})),
|
|
186
|
+
},
|
|
187
|
+
options: {
|
|
188
|
+
responsive: true,
|
|
189
|
+
maintainAspectRatio: false,
|
|
190
|
+
/*
|
|
191
|
+
"index" means "everything at this x", which is what you want on
|
|
192
|
+
a bar or a line and meaningless on a pie, where there is no x.
|
|
193
|
+
A slice is found by pointing at it.
|
|
194
|
+
*/
|
|
195
|
+
interaction: sliced
|
|
196
|
+
? { intersect: true, mode: "nearest" }
|
|
197
|
+
: { intersect: false, mode: "index" },
|
|
198
|
+
plugins: {
|
|
199
|
+
legend: {
|
|
200
|
+
display: this.legend,
|
|
201
|
+
labels: { color: text, boxWidth: 12, boxHeight: 12, font },
|
|
202
|
+
},
|
|
203
|
+
tooltip: {
|
|
204
|
+
backgroundColor: surface,
|
|
205
|
+
titleColor: surfaceText,
|
|
206
|
+
bodyColor: surfaceText,
|
|
207
|
+
borderColor: grid,
|
|
208
|
+
borderWidth: 1,
|
|
209
|
+
padding: 10,
|
|
210
|
+
titleFont: { ...font, weight: "bold" },
|
|
211
|
+
bodyFont: font,
|
|
212
|
+
displayColors: true,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
/*
|
|
216
|
+
No scales on a pie. It has no axes, and Chart.js draws whatever
|
|
217
|
+
scales it is handed, so passing these unconditionally ruled a
|
|
218
|
+
doughnut with a 0-to-1 y-axis and an x-axis underneath it.
|
|
219
|
+
*/
|
|
220
|
+
scales: sliced
|
|
221
|
+
? {}
|
|
222
|
+
: {
|
|
223
|
+
x: {
|
|
224
|
+
stacked: this.stacked,
|
|
225
|
+
grid: { display: false },
|
|
226
|
+
ticks: { color: text, font },
|
|
227
|
+
border: { color: grid },
|
|
228
|
+
},
|
|
229
|
+
y: {
|
|
230
|
+
stacked: this.stacked,
|
|
231
|
+
beginAtZero: true,
|
|
232
|
+
grid: { color: grid },
|
|
233
|
+
ticks: { color: text, font },
|
|
234
|
+
border: { display: false },
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
this.chart = new Chart(this.canvas, config);
|
|
240
|
+
}
|
|
241
|
+
static { this.styles = [
|
|
242
|
+
srOnly,
|
|
243
|
+
css `
|
|
244
|
+
/* The browser's own [hidden] rule loses to any :host display, so a
|
|
245
|
+
hidden element would still show. Important, so it always wins. */
|
|
246
|
+
:host([hidden]) {
|
|
247
|
+
display: none !important;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
:host {
|
|
251
|
+
display: block;
|
|
252
|
+
width: 100%;
|
|
253
|
+
height: 280px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* Chart.js sizes the canvas from this box, so it needs real
|
|
257
|
+
dimensions rather than being sized by its own content. */
|
|
258
|
+
.wrap {
|
|
259
|
+
position: relative;
|
|
260
|
+
width: 100%;
|
|
261
|
+
height: 100%;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
canvas {
|
|
265
|
+
display: block;
|
|
266
|
+
}
|
|
267
|
+
`,
|
|
268
|
+
]; }
|
|
269
|
+
render() {
|
|
270
|
+
return html `
|
|
271
|
+
<div class="wrap" part="wrap">
|
|
272
|
+
<!-- Never an empty name: role="img" with no name is an image a
|
|
273
|
+
screen reader announces as nothing. Same fallback idea as
|
|
274
|
+
tt-sparkline's "Trend". -->
|
|
275
|
+
<canvas
|
|
276
|
+
part="canvas"
|
|
277
|
+
role="img"
|
|
278
|
+
aria-label=${this.label || "Chart"}
|
|
279
|
+
></canvas>
|
|
280
|
+
</div>
|
|
281
|
+
|
|
282
|
+
<!-- sr-only on a wrapper, not on the table: a table ignores
|
|
283
|
+
width: 1px and overflow: hidden and grows to fit its cells,
|
|
284
|
+
so a "hidden" table stuck out and scrolled the page sideways. -->
|
|
285
|
+
<div class="sr-only">
|
|
286
|
+
<table>
|
|
287
|
+
<caption>${this.label || "Chart data"}</caption>
|
|
288
|
+
<thead>
|
|
289
|
+
<tr>
|
|
290
|
+
<th>Label</th>
|
|
291
|
+
${this.series.map((s) => html `<th>${s.label}</th>`)}
|
|
292
|
+
</tr>
|
|
293
|
+
</thead>
|
|
294
|
+
<tbody>
|
|
295
|
+
${this.labels.map((label, i) => html `
|
|
296
|
+
<tr>
|
|
297
|
+
<th>${label}</th>
|
|
298
|
+
${this.series.map((s) => html `<td>${s.data[i]}</td>`)}
|
|
299
|
+
</tr>
|
|
300
|
+
`)}
|
|
301
|
+
</tbody>
|
|
302
|
+
</table>
|
|
303
|
+
</div>
|
|
304
|
+
`;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
__decorate([
|
|
308
|
+
property({ type: String })
|
|
309
|
+
], TTChart.prototype, "type", void 0);
|
|
310
|
+
__decorate([
|
|
311
|
+
property({ type: Array })
|
|
312
|
+
], TTChart.prototype, "labels", void 0);
|
|
313
|
+
__decorate([
|
|
314
|
+
property({ type: Array })
|
|
315
|
+
], TTChart.prototype, "series", void 0);
|
|
316
|
+
__decorate([
|
|
317
|
+
property({ type: Boolean })
|
|
318
|
+
], TTChart.prototype, "legend", void 0);
|
|
319
|
+
__decorate([
|
|
320
|
+
property({ type: Boolean })
|
|
321
|
+
], TTChart.prototype, "stacked", void 0);
|
|
322
|
+
__decorate([
|
|
323
|
+
property({ type: String })
|
|
324
|
+
], TTChart.prototype, "label", void 0);
|
|
325
|
+
__decorate([
|
|
326
|
+
query("canvas")
|
|
327
|
+
], TTChart.prototype, "canvas", void 0);
|
|
328
|
+
TTChart = __decorate([
|
|
329
|
+
customElement("tt-chart")
|
|
330
|
+
], TTChart);
|
|
331
|
+
export { TTChart };
|
|
332
|
+
//# s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The same shape as tt-radio-group's and tt-select's options. */
|
|
5
|
+
export interface CheckboxOption {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** A plain string is shorthand for an option whose label is its value. */
|
|
11
|
+
export type CheckboxGroupOption = string | CheckboxOption;
|
|
12
|
+
export declare class TTCheckboxGroup extends LitElement {
|
|
13
|
+
static formAssociated: boolean;
|
|
14
|
+
private internals;
|
|
15
|
+
name: string;
|
|
16
|
+
label: string;
|
|
17
|
+
labelHidden: boolean;
|
|
18
|
+
options: CheckboxGroupOption[];
|
|
19
|
+
values: string[];
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
error: string;
|
|
22
|
+
orientation: "horizontal" | "vertical";
|
|
23
|
+
private groupId;
|
|
24
|
+
get form(): HTMLFormElement | null;
|
|
25
|
+
connectedCallback(): void;
|
|
26
|
+
formResetCallback(): void;
|
|
27
|
+
updated(changed: PropertyValues): void;
|
|
28
|
+
private syncFormState;
|
|
29
|
+
private toggle;
|
|
30
|
+
static styles: import("lit").CSSResult[];
|
|
31
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
"tt-checkbox-group": TTCheckboxGroup;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=tt-checkbox-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-checkbox-group.d.ts","sourceRoot":"","sources":["../src/tt-checkbox-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAM1C,OAAO,kBAAkB,CAAC;AAE1B,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,0EAA0E;AAC1E,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,cAAc,CAAC;AAO1D,qBACa,eAAgB,SAAQ,UAAU;IAI7C,MAAM,CAAC,cAAc,UAAQ;IAE7B,OAAO,CAAC,SAAS,CAA0B;IAYA,IAAI,SAAM;IAIzB,KAAK,SAAM;IAKvC,WAAW,UAAS;IAKO,OAAO,EAAE,mBAAmB,EAAE,CAAM;IACpC,MAAM,EAAE,MAAM,EAAE,CAAM;IAKL,QAAQ,UAAS;IAIjC,KAAK,SAAM;IAOvC,WAAW,EAAE,YAAY,GAAG,UAAU,CAAc;IAEpD,OAAO,CAAC,OAAO,CAAgC;IAE/C,IAAI,IAAI,2BAEP;IAED,iBAAiB;IAKjB,iBAAiB;IAajB,OAAO,CAAC,OAAO,EAAE,cAAc;IAW/B,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,MAAM;IA8Bd,MAAM,CAAC,MAAM,4BA2CV;IAEH,MAAM;CAkDP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,eAAe,CAAC;KACtC;CACF"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html, css } from "lit";
|
|
8
|
+
import { property, customElement } from "lit/decorators.js";
|
|
9
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
10
|
+
import { live } from "lit/directives/live.js";
|
|
11
|
+
import { srOnly } from "./sr-only.js";
|
|
12
|
+
import "./tt-checkbox.js";
|
|
13
|
+
const toOption = (option) => typeof option === "string" ? { value: option, label: option } : option;
|
|
14
|
+
let uid = 0;
|
|
15
|
+
let TTCheckboxGroup = class TTCheckboxGroup extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.internals = this.attachInternals();
|
|
19
|
+
/*
|
|
20
|
+
Reflected, and it has to be.
|
|
21
|
+
|
|
22
|
+
A form-associated custom element is submitted under its name CONTENT
|
|
23
|
+
ATTRIBUTE, not its JS property. Without reflect, setting .name = "x"
|
|
24
|
+
from script leaves the attribute absent and the field vanishes from
|
|
25
|
+
FormData with no error anywhere. It only appeared to work because
|
|
26
|
+
every call site so far wrote name="x" in markup, which sets the
|
|
27
|
+
attribute directly.
|
|
28
|
+
*/
|
|
29
|
+
this.name = "";
|
|
30
|
+
// The group's name, visible above it. `label`, as on every other form
|
|
31
|
+
// control (it was `heading` here and on tt-radio-group only).
|
|
32
|
+
this.label = "";
|
|
33
|
+
// Hides the label but keeps it as the group's name, as on every other
|
|
34
|
+
// form control.
|
|
35
|
+
this.labelHidden = false;
|
|
36
|
+
// Strings or { value, label, disabled }. Objects are what tt-radio-group
|
|
37
|
+
// and tt-select take, so a list built for one works here; strings stay
|
|
38
|
+
// as the shorthand they always were.
|
|
39
|
+
this.options = [];
|
|
40
|
+
this.values = [];
|
|
41
|
+
// Reflected like every other control's. Disables each box rather than
|
|
42
|
+
// fading the group: a tt-checkbox fades itself, and fading both would
|
|
43
|
+
// multiply the two opacities.
|
|
44
|
+
this.disabled = false;
|
|
45
|
+
// A message about the group as a whole ("Pick at least one"), shown
|
|
46
|
+
// under it and tied to it, as on tt-radio-group.
|
|
47
|
+
this.error = "";
|
|
48
|
+
// Which way the options run. `orientation`, as on tt-button-group and
|
|
49
|
+
// the cards (it was `direction: row | column` here only). Vertical by
|
|
50
|
+
// default since Oct 2026, the same as tt-radio-group: four of the five
|
|
51
|
+
// uses in this repo were already overriding a horizontal default.
|
|
52
|
+
this.orientation = "vertical";
|
|
53
|
+
this.groupId = `tt-checkbox-group-${++uid}`;
|
|
54
|
+
}
|
|
55
|
+
// Form-associated as a GROUP. The inner checkboxes carry no name, so
|
|
56
|
+
// without this the selection never reaches FormData and every page has
|
|
57
|
+
// to mirror it in state. Read it back with data.getAll(name).
|
|
58
|
+
static { this.formAssociated = true; }
|
|
59
|
+
get form() {
|
|
60
|
+
return this.internals.form;
|
|
61
|
+
}
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
super.connectedCallback();
|
|
64
|
+
this.syncFormState();
|
|
65
|
+
}
|
|
66
|
+
formResetCallback() {
|
|
67
|
+
// Cleared here, then announced, so a page that mirrors `values` hears
|
|
68
|
+
// about it and one that does not still gets an empty group.
|
|
69
|
+
this.values = [];
|
|
70
|
+
this.dispatchEvent(new CustomEvent("tt-change", {
|
|
71
|
+
detail: { values: [] },
|
|
72
|
+
bubbles: true,
|
|
73
|
+
composed: true,
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
updated(changed) {
|
|
77
|
+
if (changed.has("values") || changed.has("name")) {
|
|
78
|
+
this.syncFormState();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/*
|
|
82
|
+
A multi-select submits one entry per selected value under the same
|
|
83
|
+
name, which is what setFormValue does when given a FormData rather
|
|
84
|
+
than a string. The server then reads them all with getAll(name).
|
|
85
|
+
*/
|
|
86
|
+
syncFormState() {
|
|
87
|
+
if (!this.name)
|
|
88
|
+
return;
|
|
89
|
+
if (this.values.length === 0) {
|
|
90
|
+
this.internals.setFormValue(null);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const data = new FormData();
|
|
94
|
+
for (const value of this.values) {
|
|
95
|
+
data.append(this.name, value);
|
|
96
|
+
}
|
|
97
|
+
this.internals.setFormValue(data);
|
|
98
|
+
}
|
|
99
|
+
toggle(option, event) {
|
|
100
|
+
// The inner tt-checkbox also emits "tt-change", and it bubbles and is
|
|
101
|
+
// composed. Without this it would carry on past the group to the page,
|
|
102
|
+
// arriving after ours with a detail that has no `values`, and overwrite
|
|
103
|
+
// the selection with undefined. A composite consumes its children's
|
|
104
|
+
// events and speaks for them.
|
|
105
|
+
event.stopPropagation();
|
|
106
|
+
const next = this.values.includes(option)
|
|
107
|
+
? this.values.filter((v) => v !== option)
|
|
108
|
+
: [...this.values, option];
|
|
109
|
+
/*
|
|
110
|
+
Kept here as well as announced. The boxes already show the new
|
|
111
|
+
state, so a group that waited for the page to echo `values` back
|
|
112
|
+
worked only when someone was listening: without a listener the next
|
|
113
|
+
click started from the old set, and the form submitted that.
|
|
114
|
+
A page can still set `values` whenever it likes.
|
|
115
|
+
*/
|
|
116
|
+
this.values = next;
|
|
117
|
+
this.dispatchEvent(new CustomEvent("tt-change", {
|
|
118
|
+
detail: { values: next },
|
|
119
|
+
bubbles: true,
|
|
120
|
+
composed: true,
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
static { this.styles = [srOnly, css `
|
|
124
|
+
/* The browser's own [hidden] rule loses to any :host display, so a
|
|
125
|
+
hidden element would still show. Important, so it always wins. */
|
|
126
|
+
:host([hidden]) {
|
|
127
|
+
display: none !important;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
:host {
|
|
131
|
+
display: block;
|
|
132
|
+
font-family: var(--tt-font-sans);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.group {
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-wrap: wrap;
|
|
138
|
+
align-items: center;
|
|
139
|
+
gap: var(--tt-space-3);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
:host([orientation="vertical"]) .group {
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
align-items: flex-start;
|
|
145
|
+
gap: var(--tt-space-2);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* Above the options in both orientations, as on tt-radio-group. It
|
|
149
|
+
used to sit inline as the first item of a horizontal row. */
|
|
150
|
+
.heading {
|
|
151
|
+
margin-bottom: var(--tt-space-2);
|
|
152
|
+
|
|
153
|
+
font-size: var(--tt-text-xs);
|
|
154
|
+
font-weight: var(--tt-weight-semibold);
|
|
155
|
+
text-transform: uppercase;
|
|
156
|
+
letter-spacing: 0.05em;
|
|
157
|
+
color: var(--tt-muted-foreground);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.error-text {
|
|
161
|
+
margin-top: var(--tt-space-2);
|
|
162
|
+
color: var(--tt-destructive);
|
|
163
|
+
font-size: var(--tt-text-xs);
|
|
164
|
+
font-weight: var(--tt-weight-medium);
|
|
165
|
+
}
|
|
166
|
+
`]; }
|
|
167
|
+
render() {
|
|
168
|
+
const labelId = `${this.groupId}-label`;
|
|
169
|
+
const errorId = `${this.groupId}-error`;
|
|
170
|
+
return html `
|
|
171
|
+
${this.label
|
|
172
|
+
? html `<div
|
|
173
|
+
class="heading ${this.labelHidden ? "sr-only" : ""}"
|
|
174
|
+
part="label"
|
|
175
|
+
id=${labelId}
|
|
176
|
+
>
|
|
177
|
+
${this.label}
|
|
178
|
+
</div>`
|
|
179
|
+
: ""}
|
|
180
|
+
|
|
181
|
+
<!-- Named by the visible label rather than an aria-label copy of
|
|
182
|
+
it, which read the label twice: once as the name, once as the
|
|
183
|
+
group's first piece of text. -->
|
|
184
|
+
<div
|
|
185
|
+
class="group"
|
|
186
|
+
part="group"
|
|
187
|
+
role="group"
|
|
188
|
+
aria-labelledby=${ifDefined(this.label ? labelId : undefined)}
|
|
189
|
+
aria-invalid=${ifDefined(this.error ? "true" : undefined)}
|
|
190
|
+
aria-describedby=${ifDefined(this.error ? errorId : undefined)}
|
|
191
|
+
>
|
|
192
|
+
${this.options.map(toOption).map((option) => html `
|
|
193
|
+
<!-- live(): a box ticks itself when clicked. If the page then
|
|
194
|
+
refuses the change (sets values back, say to cap the
|
|
195
|
+
choices), the value Lit last wrote has not changed, so a
|
|
196
|
+
plain binding would write nothing and leave the box ticked.
|
|
197
|
+
live() compares with the box's REAL state instead. -->
|
|
198
|
+
<tt-checkbox
|
|
199
|
+
label=${option.label}
|
|
200
|
+
.checked=${live(this.values.includes(option.value))}
|
|
201
|
+
?disabled=${this.disabled || Boolean(option.disabled)}
|
|
202
|
+
@tt-change=${(e) => this.toggle(option.value, e)}
|
|
203
|
+
></tt-checkbox>
|
|
204
|
+
`)}
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
${this.error
|
|
208
|
+
? html `<div class="error-text" part="error" id=${errorId} role="alert">
|
|
209
|
+
${this.error}
|
|
210
|
+
</div>`
|
|
211
|
+
: ""}
|
|
212
|
+
`;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
__decorate([
|
|
216
|
+
property({ type: String, reflect: true })
|
|
217
|
+
], TTCheckboxGroup.prototype, "name", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
property({ type: String })
|
|
220
|
+
], TTCheckboxGroup.prototype, "label", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
property({ type: Boolean, attribute: "label-hidden", reflect: true })
|
|
223
|
+
], TTCheckboxGroup.prototype, "labelHidden", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
property({ type: Array })
|
|
226
|
+
], TTCheckboxGroup.prototype, "options", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
property({ type: Array })
|
|
229
|
+
], TTCheckboxGroup.prototype, "values", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
property({ type: Boolean, reflect: true })
|
|
232
|
+
], TTCheckboxGroup.prototype, "disabled", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
property({ type: String })
|
|
235
|
+
], TTCheckboxGroup.prototype, "error", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
property({ type: String, reflect: true })
|
|
238
|
+
], TTCheckboxGroup.prototype, "orientation", void 0);
|
|
239
|
+
TTCheckboxGroup = __decorate([
|
|
240
|
+
customElement("tt-checkbox-group")
|
|
241
|
+
], TTCheckboxGroup);
|
|
242
|
+
export { TTCheckboxGroup };
|
|
243
|
+
//# sourceMappingURL=tt-checkbox-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-checkbox-group.js","sourceRoot":"","sources":["../src/tt-checkbox-group.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,kBAAkB,CAAC;AAY1B,MAAM,QAAQ,GAAG,CAAC,MAA2B,EAAkB,EAAE,CAC/D,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAEzE,IAAI,GAAG,GAAG,CAAC,CAAC;AAGL,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QAMG,cAAS,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAE3C;;;;;;;;;UASE;QACyC,SAAI,GAAG,EAAE,CAAC;QAErD,sEAAsE;QACtE,8DAA8D;QAClC,UAAK,GAAG,EAAE,CAAC;QAEvC,sEAAsE;QACtE,gBAAgB;QAEhB,gBAAW,GAAG,KAAK,CAAC;QAEpB,yEAAyE;QACzE,uEAAuE;QACvE,qCAAqC;QACV,YAAO,GAA0B,EAAE,CAAC;QACpC,WAAM,GAAa,EAAE,CAAC;QAEjD,sEAAsE;QACtE,sEAAsE;QACtE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EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAClD;AAKO;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gDAAqC;AACpC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;+CAAuB;AAKL;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAAkB;AAIjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAY;AAOvC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDACU;AAjDzC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAmO3B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { PropertyValues } from "lit";
|
|
3
|
+
export declare class TTCheckbox extends LitElement {
|
|
4
|
+
static formAssociated: boolean;
|
|
5
|
+
private internals;
|
|
6
|
+
name: string;
|
|
7
|
+
value: string;
|
|
8
|
+
checked: boolean;
|
|
9
|
+
indeterminate: boolean;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
required: boolean;
|
|
12
|
+
label: string;
|
|
13
|
+
labelHidden: boolean;
|
|
14
|
+
error: string;
|
|
15
|
+
private inputId;
|
|
16
|
+
get form(): HTMLFormElement | null;
|
|
17
|
+
get validity(): ValidityState;
|
|
18
|
+
checkValidity(): boolean;
|
|
19
|
+
reportValidity(): boolean;
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
formResetCallback(): void;
|
|
22
|
+
formStateRestoreCallback(state: string): void;
|
|
23
|
+
updated(changed: PropertyValues): void;
|
|
24
|
+
private syncFormState;
|
|
25
|
+
private handleChange;
|
|
26
|
+
focus(options?: FocusOptions): void;
|
|
27
|
+
static styles: import("lit").CSSResult[];
|
|
28
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
29
|
+
}
|
|
30
|
+
declare global {
|
|
31
|
+
interface HTMLElementTagNameMap {
|
|
32
|
+
"tt-checkbox": TTCheckbox;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=tt-checkbox.d.ts.map
|