@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
|
@@ -0,0 +1,372 @@
|
|
|
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 { ifDefined } from "lit/directives/if-defined.js";
|
|
10
|
+
import { srOnly } from "./sr-only.js";
|
|
11
|
+
let uid = 0;
|
|
12
|
+
/**
|
|
13
|
+
* Pick exactly one of a small set.
|
|
14
|
+
*
|
|
15
|
+
* The group is the form control, not the individual radios, which is why
|
|
16
|
+
* this is form-associated and there is no tt-radio. A lone radio button
|
|
17
|
+
* is meaningless: "one of these" is a property of the set.
|
|
18
|
+
*/
|
|
19
|
+
let TTRadioGroup = class TTRadioGroup extends LitElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.internals = this.attachInternals();
|
|
23
|
+
/*
|
|
24
|
+
Reflected, and it has to be.
|
|
25
|
+
|
|
26
|
+
A form-associated custom element is submitted under its name CONTENT
|
|
27
|
+
ATTRIBUTE, not its JS property. Without reflect, setting .name = "x"
|
|
28
|
+
from script leaves the attribute absent and the field vanishes from
|
|
29
|
+
FormData with no error anywhere. It only appeared to work because
|
|
30
|
+
every call site so far wrote name="x" in markup, which sets the
|
|
31
|
+
attribute directly.
|
|
32
|
+
*/
|
|
33
|
+
this.name = "";
|
|
34
|
+
this.value = "";
|
|
35
|
+
// The group's name, visible above it. `label`, as on every other form
|
|
36
|
+
// control (it was `heading` here and on tt-checkbox-group only).
|
|
37
|
+
this.label = "";
|
|
38
|
+
// Hides the label but keeps it as the group's name, as on tt-input.
|
|
39
|
+
this.labelHidden = false;
|
|
40
|
+
this.error = "";
|
|
41
|
+
this.options = [];
|
|
42
|
+
this.required = false;
|
|
43
|
+
// Reflected: the :host([disabled]) styles below never matched a group
|
|
44
|
+
// disabled through the property.
|
|
45
|
+
this.disabled = false;
|
|
46
|
+
// `orientation`, as on tt-button-group and the cards.
|
|
47
|
+
this.orientation = "vertical";
|
|
48
|
+
this.groupId = `tt-radio-group-${++uid}`;
|
|
49
|
+
}
|
|
50
|
+
static { this.formAssociated = true; }
|
|
51
|
+
get form() {
|
|
52
|
+
return this.internals.form;
|
|
53
|
+
}
|
|
54
|
+
get validity() {
|
|
55
|
+
return this.internals.validity;
|
|
56
|
+
}
|
|
57
|
+
// Exposed so tt-form (and any consumer) can validate without reaching
|
|
58
|
+
// into internals. Form-associated elements do not get these for free.
|
|
59
|
+
checkValidity() {
|
|
60
|
+
return this.internals.checkValidity();
|
|
61
|
+
}
|
|
62
|
+
reportValidity() {
|
|
63
|
+
return this.internals.reportValidity();
|
|
64
|
+
}
|
|
65
|
+
connectedCallback() {
|
|
66
|
+
super.connectedCallback();
|
|
67
|
+
this.syncFormState();
|
|
68
|
+
}
|
|
69
|
+
formResetCallback() {
|
|
70
|
+
this.value = "";
|
|
71
|
+
}
|
|
72
|
+
formStateRestoreCallback(state) {
|
|
73
|
+
this.value = state ?? "";
|
|
74
|
+
}
|
|
75
|
+
updated(changed) {
|
|
76
|
+
if (changed.has("value") || changed.has("required")) {
|
|
77
|
+
this.syncFormState();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
syncFormState() {
|
|
81
|
+
this.internals.setFormValue(this.value || null);
|
|
82
|
+
const missing = this.required && this.value === "";
|
|
83
|
+
if (missing) {
|
|
84
|
+
this.internals.setValidity({ valueMissing: true }, "Please choose an option.", this.renderRoot?.querySelector("button") ?? undefined);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.internals.setValidity({});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
select(option) {
|
|
91
|
+
if (option.disabled || this.disabled || option.value === this.value)
|
|
92
|
+
return;
|
|
93
|
+
this.value = option.value;
|
|
94
|
+
this.dispatchEvent(new CustomEvent("tt-change", {
|
|
95
|
+
detail: { value: this.value },
|
|
96
|
+
bubbles: true,
|
|
97
|
+
composed: true,
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
/*
|
|
101
|
+
Arrow keys move between radios and select as they go. That is the
|
|
102
|
+
documented behaviour for a radio group, and it differs from a listbox
|
|
103
|
+
where arrows only move focus.
|
|
104
|
+
*/
|
|
105
|
+
handleKeydown(event, index) {
|
|
106
|
+
const usable = this.options.filter((o) => !o.disabled);
|
|
107
|
+
if (usable.length === 0)
|
|
108
|
+
return;
|
|
109
|
+
const keys = ["ArrowDown", "ArrowRight", "ArrowUp", "ArrowLeft"];
|
|
110
|
+
if (!keys.includes(event.key))
|
|
111
|
+
return;
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
const forward = event.key === "ArrowDown" || event.key === "ArrowRight";
|
|
114
|
+
const step = forward ? 1 : -1;
|
|
115
|
+
let next = index;
|
|
116
|
+
for (let i = 0; i < this.options.length; i++) {
|
|
117
|
+
next = (next + step + this.options.length) % this.options.length;
|
|
118
|
+
if (!this.options[next].disabled)
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
this.select(this.options[next]);
|
|
122
|
+
const buttons = this.renderRoot?.querySelectorAll("button");
|
|
123
|
+
buttons?.[next]?.focus();
|
|
124
|
+
}
|
|
125
|
+
static { this.styles = [srOnly, css `
|
|
126
|
+
/* The browser's own [hidden] rule loses to any :host display, so a
|
|
127
|
+
hidden element would still show. Important, so it always wins. */
|
|
128
|
+
:host([hidden]) {
|
|
129
|
+
display: none !important;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:host {
|
|
133
|
+
display: block;
|
|
134
|
+
font-family: var(--tt-font-sans);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
:host([disabled]) {
|
|
138
|
+
opacity: var(--tt-opacity-disabled);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.heading {
|
|
142
|
+
margin-bottom: var(--tt-space-2);
|
|
143
|
+
|
|
144
|
+
font-size: var(--tt-text-xs);
|
|
145
|
+
font-weight: var(--tt-weight-semibold);
|
|
146
|
+
text-transform: uppercase;
|
|
147
|
+
letter-spacing: 0.05em;
|
|
148
|
+
color: var(--tt-muted-foreground);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.options {
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: column;
|
|
154
|
+
gap: var(--tt-space-2);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
:host([orientation="horizontal"]) .options {
|
|
158
|
+
flex-direction: row;
|
|
159
|
+
flex-wrap: wrap;
|
|
160
|
+
gap: var(--tt-space-4);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
button {
|
|
164
|
+
display: flex;
|
|
165
|
+
align-items: flex-start;
|
|
166
|
+
gap: var(--tt-space-2);
|
|
167
|
+
|
|
168
|
+
padding: 0;
|
|
169
|
+
border: none;
|
|
170
|
+
background: transparent;
|
|
171
|
+
color: inherit;
|
|
172
|
+
|
|
173
|
+
font: inherit;
|
|
174
|
+
text-align: left;
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
/* Long-press should activate the control, not start selecting
|
|
177
|
+
its label. The other half of the mobile blue flash: the tap
|
|
178
|
+
highlight is the flash, this is the drag-select. */
|
|
179
|
+
-webkit-user-select: none;
|
|
180
|
+
user-select: none;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* Only an option disabled on its own. When the whole group is
|
|
184
|
+
disabled the host has already faded, and fading each option again
|
|
185
|
+
multiplied the two: the group dropped to a quarter opacity. */
|
|
186
|
+
:host(:not([disabled])) button:disabled {
|
|
187
|
+
opacity: var(--tt-opacity-disabled);
|
|
188
|
+
cursor: not-allowed;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.dot {
|
|
192
|
+
position: relative;
|
|
193
|
+
flex: 0 0 auto;
|
|
194
|
+
margin-top: 1px;
|
|
195
|
+
|
|
196
|
+
width: 18px;
|
|
197
|
+
height: 18px;
|
|
198
|
+
|
|
199
|
+
/* The same edge and surface as tt-checkbox, for the same reason:
|
|
200
|
+
this ring is the only thing that shows an option is there. The
|
|
201
|
+
surface was --tt-background, the page, which put a grey dot on
|
|
202
|
+
a white card and a darker hole in a dark one. */
|
|
203
|
+
border: 1px solid var(--tt-border-strong);
|
|
204
|
+
border-radius: var(--tt-radius-full);
|
|
205
|
+
background: var(--tt-field);
|
|
206
|
+
|
|
207
|
+
transition:
|
|
208
|
+
border-color var(--tt-duration-normal) var(--tt-ease),
|
|
209
|
+
box-shadow var(--tt-duration-normal) var(--tt-ease);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
button:hover:not(:disabled) .dot {
|
|
213
|
+
border-color: var(--tt-foreground);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
button:focus-visible {
|
|
217
|
+
outline: var(--tt-ring-width) solid var(--tt-ring);
|
|
218
|
+
outline-offset: var(--tt-ring-offset);
|
|
219
|
+
border-radius: var(--tt-radius-sm);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
button[aria-checked="true"] .dot {
|
|
223
|
+
border-color: var(--tt-primary);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
button[aria-checked="true"] .dot::after {
|
|
227
|
+
content: "";
|
|
228
|
+
position: absolute;
|
|
229
|
+
inset: 3px;
|
|
230
|
+
border-radius: var(--tt-radius-full);
|
|
231
|
+
background: var(--tt-primary);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.text {
|
|
235
|
+
display: flex;
|
|
236
|
+
flex-direction: column;
|
|
237
|
+
gap: 1px;
|
|
238
|
+
min-width: 0;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.label {
|
|
242
|
+
font-size: var(--tt-text-sm);
|
|
243
|
+
color: var(--tt-foreground);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.description {
|
|
247
|
+
font-size: var(--tt-text-xs);
|
|
248
|
+
line-height: var(--tt-leading-snug);
|
|
249
|
+
color: var(--tt-muted-foreground);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.error-text {
|
|
253
|
+
margin-top: var(--tt-space-2);
|
|
254
|
+
color: var(--tt-destructive);
|
|
255
|
+
font-size: var(--tt-text-xs);
|
|
256
|
+
font-weight: var(--tt-weight-medium);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
`]; }
|
|
260
|
+
// Focus has to be forwarded: focusing the host focuses nothing, since the
|
|
261
|
+
// control lives in the shadow root. Same as tt-slider and tt-input.
|
|
262
|
+
// Lands on the selected radio, or the first: the one roving tabindex makes tabbable.
|
|
263
|
+
/*
|
|
264
|
+
Which radio Tab lands on: the checked one, or else the first that is
|
|
265
|
+
not disabled. Exactly one, always.
|
|
266
|
+
|
|
267
|
+
It used to be "the checked one, or index 0 when nothing is checked".
|
|
268
|
+
If option 0 was disabled, or the value matched no option, NO radio
|
|
269
|
+
had tabindex 0 and the whole group was unreachable from the keyboard.
|
|
270
|
+
*/
|
|
271
|
+
get tabStop() {
|
|
272
|
+
const checked = this.options.findIndex((o) => o.value === this.value && !o.disabled);
|
|
273
|
+
if (checked !== -1)
|
|
274
|
+
return checked;
|
|
275
|
+
return this.options.findIndex((o) => !o.disabled);
|
|
276
|
+
}
|
|
277
|
+
focus(options) {
|
|
278
|
+
this.renderRoot
|
|
279
|
+
?.querySelector('[role="radio"][tabindex="0"]')
|
|
280
|
+
?.focus(options);
|
|
281
|
+
}
|
|
282
|
+
render() {
|
|
283
|
+
return html `
|
|
284
|
+
<!-- The id is what names the radiogroup below. It used to be
|
|
285
|
+
referenced but never set, so the group had no name at all. -->
|
|
286
|
+
${this.label
|
|
287
|
+
? html `<div
|
|
288
|
+
class="heading ${this.labelHidden ? "sr-only" : ""}"
|
|
289
|
+
part="label"
|
|
290
|
+
id=${this.groupId}
|
|
291
|
+
>
|
|
292
|
+
${this.label}
|
|
293
|
+
</div>`
|
|
294
|
+
: ""}
|
|
295
|
+
|
|
296
|
+
<div
|
|
297
|
+
class="options"
|
|
298
|
+
part="group"
|
|
299
|
+
role="radiogroup"
|
|
300
|
+
aria-labelledby=${ifDefined(this.label ? this.groupId : undefined)}
|
|
301
|
+
aria-required=${this.required ? "true" : "false"}
|
|
302
|
+
aria-invalid=${this.error ? "true" : "false"}
|
|
303
|
+
aria-describedby=${ifDefined(this.error ? `${this.groupId}-error` : undefined)}
|
|
304
|
+
>
|
|
305
|
+
${this.options.map((option, index) => html `
|
|
306
|
+
<!--
|
|
307
|
+
Roving tabindex: only the selected radio is tabbable, so Tab
|
|
308
|
+
moves past the whole group rather than through every option.
|
|
309
|
+
-->
|
|
310
|
+
<button
|
|
311
|
+
type="button"
|
|
312
|
+
role="radio"
|
|
313
|
+
part="option"
|
|
314
|
+
aria-checked=${option.value === this.value ? "true" : "false"}
|
|
315
|
+
tabindex=${index === this.tabStop ? 0 : -1}
|
|
316
|
+
?disabled=${option.disabled || this.disabled}
|
|
317
|
+
@click=${() => this.select(option)}
|
|
318
|
+
@keydown=${(e) => this.handleKeydown(e, index)}
|
|
319
|
+
>
|
|
320
|
+
<span class="dot"></span>
|
|
321
|
+
|
|
322
|
+
<span class="text">
|
|
323
|
+
<span class="label">${option.label}</span>
|
|
324
|
+
|
|
325
|
+
${option.description
|
|
326
|
+
? html `<span class="description">${option.description}</span>`
|
|
327
|
+
: ""}
|
|
328
|
+
</span>
|
|
329
|
+
</button>
|
|
330
|
+
`)}
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
${this.error
|
|
334
|
+
? html `<div class="error-text" id=${`${this.groupId}-error`} role="alert">
|
|
335
|
+
${this.error}
|
|
336
|
+
</div>`
|
|
337
|
+
: ""}
|
|
338
|
+
`;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
__decorate([
|
|
342
|
+
property({ type: String, reflect: true })
|
|
343
|
+
], TTRadioGroup.prototype, "name", void 0);
|
|
344
|
+
__decorate([
|
|
345
|
+
property({ type: String })
|
|
346
|
+
], TTRadioGroup.prototype, "value", void 0);
|
|
347
|
+
__decorate([
|
|
348
|
+
property({ type: String })
|
|
349
|
+
], TTRadioGroup.prototype, "label", void 0);
|
|
350
|
+
__decorate([
|
|
351
|
+
property({ type: Boolean, attribute: "label-hidden", reflect: true })
|
|
352
|
+
], TTRadioGroup.prototype, "labelHidden", void 0);
|
|
353
|
+
__decorate([
|
|
354
|
+
property({ type: String })
|
|
355
|
+
], TTRadioGroup.prototype, "error", void 0);
|
|
356
|
+
__decorate([
|
|
357
|
+
property({ type: Array })
|
|
358
|
+
], TTRadioGroup.prototype, "options", void 0);
|
|
359
|
+
__decorate([
|
|
360
|
+
property({ type: Boolean })
|
|
361
|
+
], TTRadioGroup.prototype, "required", void 0);
|
|
362
|
+
__decorate([
|
|
363
|
+
property({ type: Boolean, reflect: true })
|
|
364
|
+
], TTRadioGroup.prototype, "disabled", void 0);
|
|
365
|
+
__decorate([
|
|
366
|
+
property({ type: String, reflect: true })
|
|
367
|
+
], TTRadioGroup.prototype, "orientation", void 0);
|
|
368
|
+
TTRadioGroup = __decorate([
|
|
369
|
+
customElement("tt-radio-group")
|
|
370
|
+
], TTRadioGroup);
|
|
371
|
+
export { TTRadioGroup };
|
|
372
|
+
//# sourceMappingURL=tt-radio-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-radio-group.js","sourceRoot":"","sources":["../src/tt-radio-group.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAStC,IAAI,GAAG,GAAG,CAAC,CAAC;AAEZ;;;;;;GAMG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IA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IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6CAA6B;AAE1B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CAAkB;AAIF;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB;AAI7D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDACU;AArCzC,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAsWxB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* A star rating, readable or settable.
|
|
4
|
+
*
|
|
5
|
+
* The library already had tt-product, tt-profile-card and tt-company-card
|
|
6
|
+
* and no way to say how good any of them were, which is the one number
|
|
7
|
+
* every listing, review and directory entry eventually needs.
|
|
8
|
+
*
|
|
9
|
+
* TWO COMPONENTS IN ONE, ON PURPOSE. A rating is displayed far more often
|
|
10
|
+
* than it is set, and the two cases want different semantics rather than
|
|
11
|
+
* different elements. Read-only is a single image with a text
|
|
12
|
+
* alternative, because a screen reader needs "4.5 out of 5", not five
|
|
13
|
+
* separate stars it has to add up. Interactive is a slider, which is the
|
|
14
|
+
* pattern that already works with arrow keys everywhere else.
|
|
15
|
+
*
|
|
16
|
+
* Fractions are supported for the read-only case only. An average of many
|
|
17
|
+
* ratings is 4.3; nobody has ever meant to award 4.3 themselves.
|
|
18
|
+
*/
|
|
19
|
+
export declare class TTRating extends LitElement {
|
|
20
|
+
/** Stars filled. Fractional values are drawn as partial stars. */
|
|
21
|
+
value: number;
|
|
22
|
+
max: number;
|
|
23
|
+
label: string;
|
|
24
|
+
/** Show the number beside the stars. An average is easier to read as digits. */
|
|
25
|
+
showValue: boolean;
|
|
26
|
+
/** How many ratings the value averages, shown as "(128)". */
|
|
27
|
+
count?: number;
|
|
28
|
+
/** Let the user set it. Off by default: display is the common case. */
|
|
29
|
+
interactive: boolean;
|
|
30
|
+
size: string;
|
|
31
|
+
/**
|
|
32
|
+
* Colour by value rather than always gold. Off by default, because a
|
|
33
|
+
* product rating is gold everywhere and a red two-star review would
|
|
34
|
+
* look like an error state rather than a low score.
|
|
35
|
+
*/
|
|
36
|
+
grade: boolean;
|
|
37
|
+
/** What the pointer is over, which previews a click before committing it. */
|
|
38
|
+
private hovered?;
|
|
39
|
+
private get shown();
|
|
40
|
+
private get tone();
|
|
41
|
+
/** "4.5" but "4", because a whole number with a trailing .0 reads as noise. */
|
|
42
|
+
private get printed();
|
|
43
|
+
private commit;
|
|
44
|
+
private onKey;
|
|
45
|
+
static styles: import("lit").CSSResult;
|
|
46
|
+
private star;
|
|
47
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
48
|
+
}
|
|
49
|
+
declare global {
|
|
50
|
+
interface HTMLElementTagNameMap {
|
|
51
|
+
"tt-rating": TTRating;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=tt-rating.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-rating.d.ts","sourceRoot":"","sources":["../src/tt-rating.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA2B,MAAM,KAAK,CAAC;AAI1D;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,kEAAkE;IACtC,KAAK,SAAK;IAEV,GAAG,SAAK;IAER,KAAK,SAAM;IAEvC,gFAAgF;IAC1B,SAAS,UAAS;IAExE,6DAA6D;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IAE3C,uEAAuE;IAC1C,WAAW,UAAS;IAErB,IAAI,SAAU;IAE1C;;;;OAIG;IAC0B,KAAK,UAAS;IAE3C,6EAA6E;IACpE,OAAO,CAAC,OAAO,CAAC,CAAS;IAElC,OAAO,KAAK,KAAK,GAGhB;IAED,OAAO,KAAK,IAAI,GAMf;IAED,+EAA+E;IAC/E,OAAO,KAAK,OAAO,GAIlB;IAED,OAAO,CAAC,MAAM;IAmBd,OAAO,CAAC,KAAK;IA2Bb,MAAM,CAAC,MAAM,0BA8FX;IAEF,OAAO,CAAC,IAAI;IAoCZ,MAAM;CAoDP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|