@tartaguti/ui-components 0.0.0-stage → 0.1.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 +7 -0
- package/LICENSE +21 -0
- package/README.md +192 -2
- package/THIRD-PARTY-NOTICES.md +29 -0
- package/custom-elements.json +16731 -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 +69 -0
- package/dist/tt-data-table.d.ts.map +1 -0
- package/dist/tt-data-table.js +542 -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 +2907 -0
package/dist/tt-stack.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
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 } from "lit/decorators.js";
|
|
9
|
+
/**
|
|
10
|
+
* Lays its children out in a column or a row, with a gap from the
|
|
11
|
+
* spacing scale.
|
|
12
|
+
*
|
|
13
|
+
* The layout every screen repeats, and the library had no general one:
|
|
14
|
+
* tt-grid is a responsive grid, tt-toolbar a row with two sides,
|
|
15
|
+
* tt-button-group joins controls into one unit. So the apps wrote their
|
|
16
|
+
* own `display: flex; gap: ...` in some 26 files, with the same gap
|
|
17
|
+
* spelled 0.75rem in one and 12px in the next. A stack can only take a
|
|
18
|
+
* step of the scale, and because the steps are tokens, a stack also
|
|
19
|
+
* follows the density modes, which a hand-written 12px never will.
|
|
20
|
+
*
|
|
21
|
+
* THE HOST IS THE FLEX CONTAINER. The shadow root holds only a slot, and
|
|
22
|
+
* a slot is display: contents, so the slotted children become flex items
|
|
23
|
+
* of the host itself. With no inner wrapper there is nothing to reach
|
|
24
|
+
* through: a consumer's own `gap` or `flex-wrap` on the element simply
|
|
25
|
+
* wins, because a rule from outside beats :host.
|
|
26
|
+
*
|
|
27
|
+
* No reverse option, on purpose. A row drawn in the opposite order to
|
|
28
|
+
* its markup is read and tabbed through backwards by keyboard and screen
|
|
29
|
+
* reader users. Reorder the markup instead.
|
|
30
|
+
*/
|
|
31
|
+
let TTStack = class TTStack extends LitElement {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
/*
|
|
35
|
+
All five are reflected. Every style below is a :host([attr]) rule,
|
|
36
|
+
and a selector matches an attribute, never a property, so without
|
|
37
|
+
reflection setting one from script would change nothing on screen.
|
|
38
|
+
*/
|
|
39
|
+
this.orientation = "vertical";
|
|
40
|
+
this.gap = "medium";
|
|
41
|
+
// The cross axis (align-items): across a column, up and down a row.
|
|
42
|
+
this.align = "stretch";
|
|
43
|
+
// The main axis (justify-content). "between" pushes the first and last
|
|
44
|
+
// children to the two ends, which is the header row with an action.
|
|
45
|
+
this.justify = "start";
|
|
46
|
+
// Lets a row run onto more lines instead of squeezing its children.
|
|
47
|
+
this.wrap = false;
|
|
48
|
+
}
|
|
49
|
+
static { this.styles = css `
|
|
50
|
+
/*
|
|
51
|
+
The defaults are written on :host itself, not only behind
|
|
52
|
+
attributes, so the layout is already right before the first render
|
|
53
|
+
reflects them, and a value it does not know falls back to the
|
|
54
|
+
default instead of to no layout at all.
|
|
55
|
+
*/
|
|
56
|
+
:host {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
gap: var(--tt-space-4);
|
|
60
|
+
align-items: stretch;
|
|
61
|
+
justify-content: flex-start;
|
|
62
|
+
|
|
63
|
+
/* A stack is often a flex or grid item itself, and those refuse to
|
|
64
|
+
shrink below their content without this. */
|
|
65
|
+
min-width: 0;
|
|
66
|
+
|
|
67
|
+
/*
|
|
68
|
+
align is also an old HTML attribute, and Chrome still turns it
|
|
69
|
+
into text-align on ANY element, so align="center" or "end" would
|
|
70
|
+
realign every line of text inside the stack as well. In a row,
|
|
71
|
+
where align means top, middle or bottom, that is plainly wrong.
|
|
72
|
+
inherit beats that leftover rule, and still loses to a text-align
|
|
73
|
+
a consumer sets on the element.
|
|
74
|
+
*/
|
|
75
|
+
text-align: inherit;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
The browser's own [hidden] rule is weaker than any author style,
|
|
80
|
+
so the display: flex above would beat it and hidden would show the
|
|
81
|
+
stack anyway.
|
|
82
|
+
*/
|
|
83
|
+
:host([hidden]) {
|
|
84
|
+
display: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:host([orientation="horizontal"]) {
|
|
88
|
+
flex-direction: row;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:host([gap="none"]) {
|
|
92
|
+
gap: 0;
|
|
93
|
+
}
|
|
94
|
+
:host([gap="small"]) {
|
|
95
|
+
gap: var(--tt-space-2);
|
|
96
|
+
}
|
|
97
|
+
:host([gap="medium"]) {
|
|
98
|
+
gap: var(--tt-space-4);
|
|
99
|
+
}
|
|
100
|
+
:host([gap="large"]) {
|
|
101
|
+
gap: var(--tt-space-6);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
:host([align="start"]) {
|
|
105
|
+
align-items: flex-start;
|
|
106
|
+
}
|
|
107
|
+
:host([align="center"]) {
|
|
108
|
+
align-items: center;
|
|
109
|
+
}
|
|
110
|
+
:host([align="end"]) {
|
|
111
|
+
align-items: flex-end;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:host([justify="center"]) {
|
|
115
|
+
justify-content: center;
|
|
116
|
+
}
|
|
117
|
+
:host([justify="end"]) {
|
|
118
|
+
justify-content: flex-end;
|
|
119
|
+
}
|
|
120
|
+
:host([justify="between"]) {
|
|
121
|
+
justify-content: space-between;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
:host([wrap]) {
|
|
125
|
+
flex-wrap: wrap;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Each child is a flex item, and the same rule applies to it: a long
|
|
129
|
+
word or a wide child would otherwise push a row past its container
|
|
130
|
+
rather than shrink. */
|
|
131
|
+
::slotted(*) {
|
|
132
|
+
min-width: 0;
|
|
133
|
+
}
|
|
134
|
+
`; }
|
|
135
|
+
render() {
|
|
136
|
+
return html `<slot></slot>`;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
__decorate([
|
|
140
|
+
property({ type: String, reflect: true })
|
|
141
|
+
], TTStack.prototype, "orientation", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
property({ type: String, reflect: true })
|
|
144
|
+
], TTStack.prototype, "gap", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
property({ type: String, reflect: true })
|
|
147
|
+
], TTStack.prototype, "align", void 0);
|
|
148
|
+
__decorate([
|
|
149
|
+
property({ type: String, reflect: true })
|
|
150
|
+
], TTStack.prototype, "justify", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
property({ type: Boolean, reflect: true })
|
|
153
|
+
], TTStack.prototype, "wrap", void 0);
|
|
154
|
+
TTStack = __decorate([
|
|
155
|
+
customElement("tt-stack")
|
|
156
|
+
], TTStack);
|
|
157
|
+
export { TTStack };
|
|
158
|
+
//# sourceMappingURL=tt-stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-stack.js","sourceRoot":"","sources":["../src/tt-stack.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,UAAU;IAAhC;;QACL;;;;UAIE;QAEF,gBAAW,GAAqB,UAAU,CAAC;QAEA,QAAG,GAAa,QAAQ,CAAC;QAEpE,oEAAoE;QACzB,UAAK,GAAe,SAAS,CAAC;QAEzE,uEAAuE;QACvE,oEAAoE;QACzB,YAAO,GAAiB,OAAO,CAAC;QAE3E,oEAAoE;QACxB,SAAI,GAAG,KAAK,CAAC;IA4F3D,CAAC;aA1FQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqFlB,AArFY,CAqFX;IAEF,MAAM;QACJ,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;;AAvGD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACC;AAEA;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCAA0B;AAGzB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCAA+B;AAI9B;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAiC;AAG/B;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCAAc;AAnB9C,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CA+GnB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import "./tt-card.js";
|
|
3
|
+
export type StatTrend = "positive" | "negative" | "neutral";
|
|
4
|
+
export declare class TTStat extends LitElement {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
delta: string;
|
|
8
|
+
trend: StatTrend;
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
"tt-stat": TTStat;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=tt-stat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-stat.d.ts","sourceRoot":"","sources":["../src/tt-stat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,OAAO,cAAc,CAAC;AAEtB,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAE5D,qBACa,MAAO,SAAQ,UAAU;IACR,KAAK,SAAM;IACX,KAAK,SAAM;IACX,KAAK,SAAM;IACX,KAAK,EAAE,SAAS,CAAa;IAEzD,MAAM,CAAC,MAAM,0BA6EX;IAEF,MAAM;CAqBP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB;CACF"}
|
package/dist/tt-stat.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
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 } from "lit/decorators.js";
|
|
9
|
+
import "./tt-card.js";
|
|
10
|
+
let TTStat = class TTStat extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.label = "";
|
|
14
|
+
this.value = "";
|
|
15
|
+
this.delta = "";
|
|
16
|
+
this.trend = "neutral";
|
|
17
|
+
}
|
|
18
|
+
static { this.styles = css `
|
|
19
|
+
/* The browser's own [hidden] rule loses to any :host display, so a
|
|
20
|
+
hidden element would still show. Important, so it always wins. */
|
|
21
|
+
:host([hidden]) {
|
|
22
|
+
display: none !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:host {
|
|
26
|
+
display: block;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
A grid stretches the HOST to the tallest stat in the row, but the
|
|
31
|
+
card inside is an ordinary block and stays content-sized, so a stat
|
|
32
|
+
without a delta drew a shorter box than its neighbours. tt-card
|
|
33
|
+
already fills its own host; this makes that host fill ours.
|
|
34
|
+
*/
|
|
35
|
+
tt-card {
|
|
36
|
+
height: 100%;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.stat {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
gap: var(--tt-space-1);
|
|
43
|
+
|
|
44
|
+
/* Take the card's spare height, so a slotted visual given
|
|
45
|
+
margin-top: auto sits on the bottom edge across a row. */
|
|
46
|
+
flex: 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* A step more room under the label than between value and delta:
|
|
50
|
+
the label names the number, the delta belongs to it. At one shared
|
|
51
|
+
4px gap a 24px figure sat right up against its 14px label. */
|
|
52
|
+
.label {
|
|
53
|
+
margin-bottom: var(--tt-space-1);
|
|
54
|
+
font-size: var(--tt-text-sm);
|
|
55
|
+
font-weight: var(--tt-weight-medium);
|
|
56
|
+
color: var(--tt-muted-foreground);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.value {
|
|
60
|
+
font-size: var(--tt-text-2xl);
|
|
61
|
+
font-weight: var(--tt-weight-bold);
|
|
62
|
+
line-height: var(--tt-leading-tight);
|
|
63
|
+
letter-spacing: -0.02em;
|
|
64
|
+
|
|
65
|
+
color: var(--tt-foreground);
|
|
66
|
+
|
|
67
|
+
/* Digits share one width, so a row of stats lines up and the
|
|
68
|
+
number doesn't jitter when it changes. */
|
|
69
|
+
font-variant-numeric: tabular-nums;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.delta {
|
|
73
|
+
/* One variable drives the colour; each trend overrides just this. */
|
|
74
|
+
--_color: var(--tt-muted-foreground);
|
|
75
|
+
|
|
76
|
+
font-size: var(--tt-text-xs);
|
|
77
|
+
font-weight: var(--tt-weight-semibold);
|
|
78
|
+
color: var(--_color);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.delta.positive {
|
|
82
|
+
--_color: var(--tt-success);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.delta.negative {
|
|
86
|
+
--_color: var(--tt-destructive);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Only applies when something is actually slotted, so an empty
|
|
90
|
+
visual area adds no spacing. */
|
|
91
|
+
::slotted([slot="visual"]) {
|
|
92
|
+
display: block;
|
|
93
|
+
margin-top: var(--tt-space-3);
|
|
94
|
+
}
|
|
95
|
+
`; }
|
|
96
|
+
render() {
|
|
97
|
+
return html `
|
|
98
|
+
<tt-card part="card">
|
|
99
|
+
<div class="stat">
|
|
100
|
+
<div class="label" part="label">${this.label}</div>
|
|
101
|
+
|
|
102
|
+
<div class="value" part="value">${this.value}</div>
|
|
103
|
+
|
|
104
|
+
${this.delta
|
|
105
|
+
? html `
|
|
106
|
+
<div class="delta ${this.trend}" part="delta">
|
|
107
|
+
${this.delta}
|
|
108
|
+
</div>
|
|
109
|
+
`
|
|
110
|
+
: ""}
|
|
111
|
+
|
|
112
|
+
<slot name="visual"></slot>
|
|
113
|
+
</div>
|
|
114
|
+
</tt-card>
|
|
115
|
+
`;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
__decorate([
|
|
119
|
+
property({ type: String })
|
|
120
|
+
], TTStat.prototype, "label", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
property({ type: String })
|
|
123
|
+
], TTStat.prototype, "value", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ type: String })
|
|
126
|
+
], TTStat.prototype, "delta", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
property({ type: String })
|
|
129
|
+
], TTStat.prototype, "trend", void 0);
|
|
130
|
+
TTStat = __decorate([
|
|
131
|
+
customElement("tt-stat")
|
|
132
|
+
], TTStat);
|
|
133
|
+
export { TTStat };
|
|
134
|
+
//# sourceMappingURL=tt-stat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-stat.js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} from "lit";
|
|
3
|
+
/**
|
|
4
|
+
* A switch, not a checkbox. Use it for a setting that takes effect
|
|
5
|
+
* immediately ("Email notifications on"). Use tt-checkbox for something
|
|
6
|
+
* confirmed later by a submit ("I accept the terms").
|
|
7
|
+
*/
|
|
8
|
+
export declare class TTSwitch extends LitElement {
|
|
9
|
+
static formAssociated: boolean;
|
|
10
|
+
private internals;
|
|
11
|
+
name: string;
|
|
12
|
+
value: string;
|
|
13
|
+
label: string;
|
|
14
|
+
checked: boolean;
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
labelFirst: boolean;
|
|
17
|
+
labelHidden: boolean;
|
|
18
|
+
private control;
|
|
19
|
+
private switchId;
|
|
20
|
+
get form(): HTMLFormElement | null;
|
|
21
|
+
get validity(): ValidityState;
|
|
22
|
+
checkValidity(): boolean;
|
|
23
|
+
reportValidity(): boolean;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
formResetCallback(): void;
|
|
26
|
+
formStateRestoreCallback(state: string): void;
|
|
27
|
+
updated(changed: PropertyValues): void;
|
|
28
|
+
private syncFormState;
|
|
29
|
+
private toggle;
|
|
30
|
+
focus(options?: FocusOptions): void;
|
|
31
|
+
static styles: import("lit").CSSResult[];
|
|
32
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
"tt-switch": TTSwitch;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=tt-switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-switch.d.ts","sourceRoot":"","sources":["../src/tt-switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAM1C;;;;GAIG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,MAAM,CAAC,cAAc,UAAQ;IAE7B,OAAO,CAAC,SAAS,CAA0B;IAYA,IAAI,SAAM;IACzC,KAAK,SAAQ;IACb,KAAK,SAAM;IAEqB,OAAO,UAAS;IAChB,QAAQ,UAAS;IAIN,UAAU,UAAS;IAK1E,WAAW,UAAS;IAEH,OAAO,CAAC,OAAO,CAAqB;IAErD,OAAO,CAAC,QAAQ,CAAwB;IAExC,IAAI,IAAI,2BAEP;IACD,IAAI,QAAQ,kBAEX;IAID,aAAa;IAIb,cAAc;IAId,iBAAiB;IAKjB,iBAAiB;IAIjB,wBAAwB,CAAC,KAAK,EAAE,MAAM;IAItC,OAAO,CAAC,OAAO,EAAE,cAAc;IAM/B,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,MAAM;IAcd,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY;IAI5B,MAAM,CAAC,MAAM,4BAyGV;IAEH,MAAM;CA6BP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|
|
@@ -0,0 +1,254 @@
|
|
|
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, query } from "lit/decorators.js";
|
|
9
|
+
import { srOnly } from "./sr-only.js";
|
|
10
|
+
let uid = 0;
|
|
11
|
+
/**
|
|
12
|
+
* A switch, not a checkbox. Use it for a setting that takes effect
|
|
13
|
+
* immediately ("Email notifications on"). Use tt-checkbox for something
|
|
14
|
+
* confirmed later by a submit ("I accept the terms").
|
|
15
|
+
*/
|
|
16
|
+
let TTSwitch = class TTSwitch extends LitElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.internals = this.attachInternals();
|
|
20
|
+
/*
|
|
21
|
+
Reflected, and it has to be.
|
|
22
|
+
|
|
23
|
+
A form-associated custom element is submitted under its name CONTENT
|
|
24
|
+
ATTRIBUTE, not its JS property. Without reflect, setting .name = "x"
|
|
25
|
+
from script leaves the attribute absent and the field vanishes from
|
|
26
|
+
FormData with no error anywhere. It only appeared to work because
|
|
27
|
+
every call site so far wrote name="x" in markup, which sets the
|
|
28
|
+
attribute directly.
|
|
29
|
+
*/
|
|
30
|
+
this.name = "";
|
|
31
|
+
this.value = "on";
|
|
32
|
+
this.label = "";
|
|
33
|
+
this.checked = false;
|
|
34
|
+
this.disabled = false;
|
|
35
|
+
// Label on the left rather than the right. Settings lists usually read
|
|
36
|
+
// better with the control aligned down the right edge.
|
|
37
|
+
this.labelFirst = false;
|
|
38
|
+
// Named for a screen reader, invisible on screen. Same contract as the
|
|
39
|
+
// other form controls. Without a label a switch is just "switch, off".
|
|
40
|
+
this.labelHidden = false;
|
|
41
|
+
this.switchId = `tt-switch-${++uid}`;
|
|
42
|
+
}
|
|
43
|
+
static { this.formAssociated = true; }
|
|
44
|
+
get form() {
|
|
45
|
+
return this.internals.form;
|
|
46
|
+
}
|
|
47
|
+
get validity() {
|
|
48
|
+
return this.internals.validity;
|
|
49
|
+
}
|
|
50
|
+
// Exposed so tt-form (and any consumer) can validate without reaching
|
|
51
|
+
// into internals. Form-associated elements do not get these for free.
|
|
52
|
+
checkValidity() {
|
|
53
|
+
return this.internals.checkValidity();
|
|
54
|
+
}
|
|
55
|
+
reportValidity() {
|
|
56
|
+
return this.internals.reportValidity();
|
|
57
|
+
}
|
|
58
|
+
connectedCallback() {
|
|
59
|
+
super.connectedCallback();
|
|
60
|
+
this.syncFormState();
|
|
61
|
+
}
|
|
62
|
+
formResetCallback() {
|
|
63
|
+
this.checked = false;
|
|
64
|
+
}
|
|
65
|
+
formStateRestoreCallback(state) {
|
|
66
|
+
this.checked = state === this.value;
|
|
67
|
+
}
|
|
68
|
+
updated(changed) {
|
|
69
|
+
if (changed.has("checked") || changed.has("value")) {
|
|
70
|
+
this.syncFormState();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
syncFormState() {
|
|
74
|
+
// Off submits nothing at all, like an unchecked checkbox.
|
|
75
|
+
this.internals.setFormValue(this.checked ? this.value : null);
|
|
76
|
+
}
|
|
77
|
+
toggle() {
|
|
78
|
+
if (this.disabled)
|
|
79
|
+
return;
|
|
80
|
+
this.checked = !this.checked;
|
|
81
|
+
this.dispatchEvent(new CustomEvent("tt-change", {
|
|
82
|
+
detail: { checked: this.checked, value: this.value },
|
|
83
|
+
bubbles: true,
|
|
84
|
+
composed: true,
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
focus(options) {
|
|
88
|
+
this.control?.focus(options);
|
|
89
|
+
}
|
|
90
|
+
static { this.styles = [srOnly, css `
|
|
91
|
+
/* The browser's own [hidden] rule loses to any :host display, so a
|
|
92
|
+
hidden element would still show. Important, so it always wins. */
|
|
93
|
+
:host([hidden]) {
|
|
94
|
+
display: none !important;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
:host {
|
|
98
|
+
display: inline-block;
|
|
99
|
+
font-family: var(--tt-font-sans);
|
|
100
|
+
-webkit-font-smoothing: antialiased;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:host([disabled]) {
|
|
104
|
+
opacity: var(--tt-opacity-disabled);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.row {
|
|
108
|
+
display: inline-flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
gap: var(--tt-space-3);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.row.label-first {
|
|
114
|
+
flex-direction: row-reverse;
|
|
115
|
+
justify-content: space-between;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/*
|
|
119
|
+
A real button with role="switch". Native HTML has no switch element,
|
|
120
|
+
so the role plus aria-checked is what tells a screen reader what
|
|
121
|
+
this is. A styled div would announce nothing.
|
|
122
|
+
*/
|
|
123
|
+
button {
|
|
124
|
+
position: relative;
|
|
125
|
+
flex: 0 0 auto;
|
|
126
|
+
|
|
127
|
+
width: 36px;
|
|
128
|
+
height: 20px;
|
|
129
|
+
padding: 0;
|
|
130
|
+
|
|
131
|
+
border: none;
|
|
132
|
+
border-radius: var(--tt-radius-full);
|
|
133
|
+
|
|
134
|
+
background: var(--tt-input);
|
|
135
|
+
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
|
|
138
|
+
transition: background var(--tt-duration-normal) var(--tt-ease);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
button:disabled {
|
|
142
|
+
cursor: not-allowed;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
button[aria-checked="true"] {
|
|
146
|
+
background: var(--tt-primary);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
button:focus-visible {
|
|
150
|
+
outline: var(--tt-ring-width) solid var(--tt-ring);
|
|
151
|
+
outline-offset: var(--tt-ring-offset);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.thumb {
|
|
155
|
+
position: absolute;
|
|
156
|
+
top: 2px;
|
|
157
|
+
left: 2px;
|
|
158
|
+
|
|
159
|
+
width: 16px;
|
|
160
|
+
height: 16px;
|
|
161
|
+
|
|
162
|
+
/*
|
|
163
|
+
Off: white in BOTH modes, the one constant that contrasts with the
|
|
164
|
+
track in both. It used to be --tt-field, the field surface, which
|
|
165
|
+
is dark in dark mode: a dark thumb on a dark track, so every switch
|
|
166
|
+
that was off looked like an empty slot. On: the text colour of the
|
|
167
|
+
fill, the same pair a primary button uses, so it reads on a dark
|
|
168
|
+
fill in light mode and a light one in dark mode or any brand.
|
|
169
|
+
*/
|
|
170
|
+
border-radius: var(--tt-radius-full);
|
|
171
|
+
background: var(--tt-white);
|
|
172
|
+
box-shadow: var(--tt-elevation-1);
|
|
173
|
+
|
|
174
|
+
transition:
|
|
175
|
+
transform var(--tt-duration-normal) var(--tt-ease),
|
|
176
|
+
background var(--tt-duration-normal) var(--tt-ease);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
button[aria-checked="true"] .thumb {
|
|
180
|
+
transform: translateX(16px);
|
|
181
|
+
background: var(--tt-primary-foreground);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.text {
|
|
185
|
+
font-size: var(--tt-text-sm);
|
|
186
|
+
color: var(--tt-foreground);
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
user-select: none;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
:host([disabled]) .text {
|
|
192
|
+
cursor: not-allowed;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
`]; }
|
|
196
|
+
render() {
|
|
197
|
+
return html `
|
|
198
|
+
<div class="row ${this.labelFirst ? "label-first" : ""}">
|
|
199
|
+
<button
|
|
200
|
+
part="control"
|
|
201
|
+
id=${this.switchId}
|
|
202
|
+
type="button"
|
|
203
|
+
role="switch"
|
|
204
|
+
aria-checked=${this.checked ? "true" : "false"}
|
|
205
|
+
?disabled=${this.disabled}
|
|
206
|
+
@click=${this.toggle}
|
|
207
|
+
>
|
|
208
|
+
<span class="thumb"></span>
|
|
209
|
+
</button>
|
|
210
|
+
|
|
211
|
+
${this.label
|
|
212
|
+
? html `
|
|
213
|
+
<label
|
|
214
|
+
class="text ${this.labelHidden ? "sr-only" : ""}"
|
|
215
|
+
for=${this.switchId}
|
|
216
|
+
part="label"
|
|
217
|
+
>
|
|
218
|
+
${this.label}
|
|
219
|
+
</label>
|
|
220
|
+
`
|
|
221
|
+
: ""}
|
|
222
|
+
</div>
|
|
223
|
+
`;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
__decorate([
|
|
227
|
+
property({ type: String, reflect: true })
|
|
228
|
+
], TTSwitch.prototype, "name", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
property()
|
|
231
|
+
], TTSwitch.prototype, "value", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
property()
|
|
234
|
+
], TTSwitch.prototype, "label", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
property({ type: Boolean, reflect: true })
|
|
237
|
+
], TTSwitch.prototype, "checked", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
property({ type: Boolean, reflect: true })
|
|
240
|
+
], TTSwitch.prototype, "disabled", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
property({ type: Boolean, attribute: "label-first" })
|
|
243
|
+
], TTSwitch.prototype, "labelFirst", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
property({ type: Boolean, attribute: "label-hidden", reflect: true })
|
|
246
|
+
], TTSwitch.prototype, "labelHidden", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
query("button")
|
|
249
|
+
], TTSwitch.prototype, "control", void 0);
|
|
250
|
+
TTSwitch = __decorate([
|
|
251
|
+
customElement("tt-switch")
|
|
252
|
+
], TTSwitch);
|
|
253
|
+
export { TTSwitch };
|
|
254
|
+
//# sourceMappingURL=tt-switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-switch.js","sourceRoot":"","sources":["../src/tt-switch.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,IAAI,GAAG,GAAG,CAAC,CAAC;AAEZ;;;;GAIG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;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AC,EAAE;sBACzC,IAAI,CAAC,QAAQ;;;kBAGjB,IAAI,CAAC,KAAK;;aAEf;YACH,CAAC,CAAC,EAAE;;KAET,CAAC;IACJ,CAAC;;AAtN0C;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCAAW;AACzC;IAAX,QAAQ,EAAE;uCAAc;AACb;IAAX,QAAQ,EAAE;uCAAY;AAEqB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAiB;AAChB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAkB;AAIN;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;4CAAoB;AAK1E;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAClD;AAEK;IAAxB,KAAK,CAAC,QAAQ,CAAC;yCAAqC;AA/B1C,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAsOpB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { PropertyValues } from "lit";
|
|
3
|
+
import "./tt-button.js";
|
|
4
|
+
import "./tt-code-block.js";
|
|
5
|
+
export interface SwitcherItem {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
code?: string;
|
|
9
|
+
language?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class TTSwitcher extends LitElement {
|
|
12
|
+
items: SwitcherItem[];
|
|
13
|
+
activeIndex: number;
|
|
14
|
+
updated(changed: PropertyValues): void;
|
|
15
|
+
static styles: import("lit").CSSResult;
|
|
16
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
17
|
+
}
|
|
18
|
+
declare global {
|
|
19
|
+
interface HTMLElementTagNameMap {
|
|
20
|
+
"tt-switcher": TTSwitcher;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=tt-switcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-switcher.d.ts","sourceRoot":"","sources":["../src/tt-switcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAG1C,OAAO,gBAAgB,CAAC;AACxB,OAAO,oBAAoB,CAAC;AAE5B,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBACa,UAAW,SAAQ,UAAU;IAExC,KAAK,EAAE,YAAY,EAAE,CAAM;IAG3B,WAAW,SAAK;IAIhB,OAAO,CAAC,OAAO,EAAE,cAAc;IAU/B,MAAM,CAAC,MAAM,0BAsHX;IAEF,MAAM;CAmDP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
|