@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-skeleton.d.ts","sourceRoot":"","sources":["../src/tt-skeleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C;;;;GAIG;AACH,qBACa,UAAW,SAAQ,UAAU;IAExC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAU;IAI3B,KAAK,SAAM;IACX,MAAM,SAAM;IAGZ,KAAK,SAAK;IAEtC,MAAM,CAAC,MAAM,0BAyEX;IAEF,MAAM;CAiCP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
|
|
@@ -0,0 +1,143 @@
|
|
|
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 { styleMap } from "lit/directives/style-map.js";
|
|
10
|
+
/**
|
|
11
|
+
* Placeholder shape shown while data loads. Use it in the same layout as
|
|
12
|
+
* the real content so nothing jumps when the data arrives: a skeleton
|
|
13
|
+
* that is a different size than what replaces it is worse than a spinner.
|
|
14
|
+
*/
|
|
15
|
+
let TTSkeleton = class TTSkeleton extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.variant = "text";
|
|
19
|
+
// Any CSS length. Text lines often want a varied width so a paragraph
|
|
20
|
+
// does not look like a solid block.
|
|
21
|
+
this.width = "";
|
|
22
|
+
this.height = "";
|
|
23
|
+
// Number of stacked lines, for the text variant.
|
|
24
|
+
this.lines = 1;
|
|
25
|
+
}
|
|
26
|
+
static { this.styles = css `
|
|
27
|
+
/* The browser's own [hidden] rule loses to any :host display, so a
|
|
28
|
+
hidden element would still show. Important, so it always wins. */
|
|
29
|
+
:host([hidden]) {
|
|
30
|
+
display: none !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host {
|
|
34
|
+
display: block;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.stack {
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
gap: var(--tt-space-2);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.bone {
|
|
44
|
+
background: var(--tt-muted);
|
|
45
|
+
border-radius: var(--tt-radius-sm);
|
|
46
|
+
|
|
47
|
+
/* A moving highlight rather than a pulse: it reads as "loading"
|
|
48
|
+
instead of "broken and flashing". */
|
|
49
|
+
background-image: linear-gradient(
|
|
50
|
+
90deg,
|
|
51
|
+
transparent 0%,
|
|
52
|
+
color-mix(in srgb, var(--tt-foreground) 6%, transparent) 50%,
|
|
53
|
+
transparent 100%
|
|
54
|
+
);
|
|
55
|
+
background-size: 200% 100%;
|
|
56
|
+
background-repeat: no-repeat;
|
|
57
|
+
|
|
58
|
+
animation: shimmer 1.4s ease-in-out infinite;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:host([variant="text"]) .bone {
|
|
62
|
+
height: 0.85em;
|
|
63
|
+
border-radius: var(--tt-radius-sm);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host([variant="title"]) .bone {
|
|
67
|
+
height: 1.4em;
|
|
68
|
+
border-radius: var(--tt-radius-sm);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([variant="circle"]) .bone {
|
|
72
|
+
border-radius: var(--tt-radius-full);
|
|
73
|
+
aspect-ratio: 1;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([variant="rect"]) .bone {
|
|
77
|
+
border-radius: var(--tt-radius);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* The last line of a paragraph is rarely full width. */
|
|
81
|
+
.stack .bone:last-child:not(:only-child) {
|
|
82
|
+
width: 70%;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@keyframes shimmer {
|
|
86
|
+
from { background-position: 200% 0; }
|
|
87
|
+
to { background-position: -200% 0; }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Cannot come from a token: an infinite animation at 1ms strobes rather
|
|
91
|
+
than stops, so the shimmer has to be switched off properly. Everything
|
|
92
|
+
else in the library is handled centrally in tokens.css. */
|
|
93
|
+
|
|
94
|
+
@media (prefers-reduced-motion: reduce) {
|
|
95
|
+
.bone {
|
|
96
|
+
animation: none;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`; }
|
|
100
|
+
render() {
|
|
101
|
+
/*
|
|
102
|
+
A width of "10px; position: fixed" used to write a second
|
|
103
|
+
declaration into the style string. styleMap sets one property per
|
|
104
|
+
key on every update, but its FIRST render still joins them into one
|
|
105
|
+
string, so each value is also checked to be a single valid value for
|
|
106
|
+
its property. Anything else, empty included, is dropped and leaves
|
|
107
|
+
the CSS default.
|
|
108
|
+
*/
|
|
109
|
+
const valid = (property, value) => value && CSS.supports(property, value) ? value : undefined;
|
|
110
|
+
const style = styleMap({
|
|
111
|
+
width: valid("width", this.width),
|
|
112
|
+
height: valid("height", this.height),
|
|
113
|
+
});
|
|
114
|
+
const count = this.variant === "text" ? Math.max(1, this.lines) : 1;
|
|
115
|
+
return html `
|
|
116
|
+
<!--
|
|
117
|
+
aria-hidden and aria-busy: a screen reader should hear "loading",
|
|
118
|
+
not a description of grey rectangles. Put aria-busy on the region
|
|
119
|
+
being replaced.
|
|
120
|
+
-->
|
|
121
|
+
<div class="stack" part="stack" aria-hidden="true">
|
|
122
|
+
${Array.from({ length: count }, () => html `<div class="bone" part="bone" style=${style}></div>`)}
|
|
123
|
+
</div>
|
|
124
|
+
`;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
__decorate([
|
|
128
|
+
property({ type: String, reflect: true })
|
|
129
|
+
], TTSkeleton.prototype, "variant", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
property({ type: String })
|
|
132
|
+
], TTSkeleton.prototype, "width", void 0);
|
|
133
|
+
__decorate([
|
|
134
|
+
property({ type: String })
|
|
135
|
+
], TTSkeleton.prototype, "height", void 0);
|
|
136
|
+
__decorate([
|
|
137
|
+
property({ type: Number })
|
|
138
|
+
], TTSkeleton.prototype, "lines", void 0);
|
|
139
|
+
TTSkeleton = __decorate([
|
|
140
|
+
customElement("tt-skeleton")
|
|
141
|
+
], TTSkeleton);
|
|
142
|
+
export { TTSkeleton };
|
|
143
|
+
//# sourceMappingURL=tt-skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-skeleton.js","sourceRoot":"","sources":["../src/tt-skeleton.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;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD;;;;GAIG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAEL,YAAO,GAAyC,MAAM,CAAC;QAEvD,sEAAsE;QACtE,oCAAoC;QACR,UAAK,GAAG,EAAE,CAAC;QACX,WAAM,GAAG,EAAE,CAAC;QAExC,iDAAiD;QACrB,UAAK,GAAG,CAAC,CAAC;IA8GxC,CAAC;aA5GQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyElB,AAzEY,CAyEX;IAEF,MAAM;QACJ;;;;;;;UAOE;QACF,MAAM,KAAK,GAAG,CAAC,QAAgB,EAAE,KAAa,EAAE,EAAE,CAChD,KAAK,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAE7D,MAAM,KAAK,GAAG,QAAQ,CAAC;YACrB,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC;YACjC,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC;SACrC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpE,OAAO,IAAI,CAAA;;;;;;;UAOL,KAAK,CAAC,IAAI,CACV,EAAE,MAAM,EAAE,KAAK,EAAE,EACjB,GAAG,EAAE,CAAC,IAAI,CAAA,uCAAuC,KAAK,SAAS,CAChE;;KAEJ,CAAC;IACJ,CAAC;;AArHD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACa;AAI3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAY;AACX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAa;AAGZ;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAW;AAV3B,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAwHtB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { PropertyValues } from "lit";
|
|
3
|
+
/**
|
|
4
|
+
* A value picked from a range.
|
|
5
|
+
*
|
|
6
|
+
* ---------------------------------------------------------------------
|
|
7
|
+
* IT WRAPS A REAL `<input type="range">`, AND THAT IS THE DESIGN.
|
|
8
|
+
*
|
|
9
|
+
* A div with a draggable dot is about forty lines to make look right and
|
|
10
|
+
* several hundred to make correct. The native input already ships:
|
|
11
|
+
*
|
|
12
|
+
* - Arrow keys, Home, End, Page Up, Page Down, all with the right step
|
|
13
|
+
* - role="slider" with aria-valuenow / valuemin / valuemax kept in sync
|
|
14
|
+
* - pointer capture, so a drag survives leaving the element
|
|
15
|
+
* - touch, pen and mouse without a line of code
|
|
16
|
+
* - correct behaviour in a form, including reset
|
|
17
|
+
*
|
|
18
|
+
* Every one of those is a thing hand-rolled sliders get wrong. So this
|
|
19
|
+
* component styles the native control rather than replacing it. The cost
|
|
20
|
+
* is four vendor pseudo-elements below; the alternative cost is the list
|
|
21
|
+
* above.
|
|
22
|
+
*
|
|
23
|
+
* ---------------------------------------------------------------------
|
|
24
|
+
* TWO EVENTS, BECAUSE THERE ARE TWO QUESTIONS.
|
|
25
|
+
*
|
|
26
|
+
* tt-input fires continuously while dragging. Use it to update a
|
|
27
|
+
* preview: a live number, a colour, a zoom level.
|
|
28
|
+
* tt-change fires once, when the drag is released. Use it to save.
|
|
29
|
+
*
|
|
30
|
+
* Collapsing them into one would force every consumer that writes to a
|
|
31
|
+
* server to debounce, and every consumer that draws a preview to poll.
|
|
32
|
+
* The platform already draws this line and this keeps it.
|
|
33
|
+
*
|
|
34
|
+
* It owns its own `value`, like the native input it wraps. Setting the
|
|
35
|
+
* property from outside still wins.
|
|
36
|
+
*/
|
|
37
|
+
export declare class TTSlider extends LitElement {
|
|
38
|
+
static formAssociated: boolean;
|
|
39
|
+
private internals;
|
|
40
|
+
name: string;
|
|
41
|
+
value: number;
|
|
42
|
+
min: number;
|
|
43
|
+
max: number;
|
|
44
|
+
step: number;
|
|
45
|
+
label: string;
|
|
46
|
+
labelHidden: boolean;
|
|
47
|
+
showValue: boolean;
|
|
48
|
+
unit: string;
|
|
49
|
+
disabled: boolean;
|
|
50
|
+
private control;
|
|
51
|
+
private sliderId;
|
|
52
|
+
get form(): HTMLFormElement | null;
|
|
53
|
+
get validity(): ValidityState;
|
|
54
|
+
checkValidity(): boolean;
|
|
55
|
+
reportValidity(): boolean;
|
|
56
|
+
focus(options?: FocusOptions): void;
|
|
57
|
+
connectedCallback(): void;
|
|
58
|
+
formResetCallback(): void;
|
|
59
|
+
formStateRestoreCallback(state: string): void;
|
|
60
|
+
updated(changed: PropertyValues): void;
|
|
61
|
+
private syncFormState;
|
|
62
|
+
/** How far along the track the value sits, 0 to 100. */
|
|
63
|
+
private get percent();
|
|
64
|
+
private handleInput;
|
|
65
|
+
private handleChange;
|
|
66
|
+
static styles: import("lit").CSSResult[];
|
|
67
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
68
|
+
}
|
|
69
|
+
declare global {
|
|
70
|
+
interface HTMLElementTagNameMap {
|
|
71
|
+
"tt-slider": TTSlider;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=tt-slider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-slider.d.ts","sourceRoot":"","sources":["../src/tt-slider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAQ1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,MAAM,CAAC,cAAc,UAAQ;IAE7B,OAAO,CAAC,SAAS,CAA0B;IASA,IAAI,SAAM;IAEzB,KAAK,SAAM;IAEX,GAAG,SAAK;IACR,GAAG,SAAO;IACV,IAAI,SAAK;IAET,KAAK,SAAM;IAIvC,WAAW,UAAS;IAKkC,SAAS,UAAS;IAG5C,IAAI,SAAM;IAEM,QAAQ,UAAS;IAE7C,OAAO,CAAC,OAAO,CAAoB;IAEnD,OAAO,CAAC,QAAQ,CAAwB;IAExC,IAAI,IAAI,2BAEP;IAED,IAAI,QAAQ,kBAEX;IAID,aAAa;IAIb,cAAc;IAUd,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY;IAI5B,iBAAiB;IAKjB,iBAAiB;IASjB,wBAAwB,CAAC,KAAK,EAAE,MAAM;IAKtC,OAAO,CAAC,OAAO,EAAE,cAAc;IAW/B,OAAO,CAAC,aAAa;IAIrB,wDAAwD;IACxD,OAAO,KAAK,OAAO,GASlB;IAED,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,YAAY;IAiBpB,MAAM,CAAC,MAAM,4BA0LV;IAEH,MAAM;CAkDP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|
|
@@ -0,0 +1,426 @@
|
|
|
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 { ifDefined } from "lit/directives/if-defined.js";
|
|
10
|
+
import { srOnly } from "./sr-only.js";
|
|
11
|
+
let uid = 0;
|
|
12
|
+
/**
|
|
13
|
+
* A value picked from a range.
|
|
14
|
+
*
|
|
15
|
+
* ---------------------------------------------------------------------
|
|
16
|
+
* IT WRAPS A REAL `<input type="range">`, AND THAT IS THE DESIGN.
|
|
17
|
+
*
|
|
18
|
+
* A div with a draggable dot is about forty lines to make look right and
|
|
19
|
+
* several hundred to make correct. The native input already ships:
|
|
20
|
+
*
|
|
21
|
+
* - Arrow keys, Home, End, Page Up, Page Down, all with the right step
|
|
22
|
+
* - role="slider" with aria-valuenow / valuemin / valuemax kept in sync
|
|
23
|
+
* - pointer capture, so a drag survives leaving the element
|
|
24
|
+
* - touch, pen and mouse without a line of code
|
|
25
|
+
* - correct behaviour in a form, including reset
|
|
26
|
+
*
|
|
27
|
+
* Every one of those is a thing hand-rolled sliders get wrong. So this
|
|
28
|
+
* component styles the native control rather than replacing it. The cost
|
|
29
|
+
* is four vendor pseudo-elements below; the alternative cost is the list
|
|
30
|
+
* above.
|
|
31
|
+
*
|
|
32
|
+
* ---------------------------------------------------------------------
|
|
33
|
+
* TWO EVENTS, BECAUSE THERE ARE TWO QUESTIONS.
|
|
34
|
+
*
|
|
35
|
+
* tt-input fires continuously while dragging. Use it to update a
|
|
36
|
+
* preview: a live number, a colour, a zoom level.
|
|
37
|
+
* tt-change fires once, when the drag is released. Use it to save.
|
|
38
|
+
*
|
|
39
|
+
* Collapsing them into one would force every consumer that writes to a
|
|
40
|
+
* server to debounce, and every consumer that draws a preview to poll.
|
|
41
|
+
* The platform already draws this line and this keeps it.
|
|
42
|
+
*
|
|
43
|
+
* It owns its own `value`, like the native input it wraps. Setting the
|
|
44
|
+
* property from outside still wins.
|
|
45
|
+
*/
|
|
46
|
+
let TTSlider = class TTSlider extends LitElement {
|
|
47
|
+
constructor() {
|
|
48
|
+
super(...arguments);
|
|
49
|
+
this.internals = this.attachInternals();
|
|
50
|
+
/*
|
|
51
|
+
Reflected, and it has to be. A form-associated custom element is
|
|
52
|
+
submitted under its name CONTENT ATTRIBUTE, not its JS property.
|
|
53
|
+
Without reflect, setting .name from script leaves the attribute
|
|
54
|
+
absent and the field vanishes from FormData with no error anywhere.
|
|
55
|
+
Same trap as tt-switch and tt-checkbox-group.
|
|
56
|
+
*/
|
|
57
|
+
this.name = "";
|
|
58
|
+
this.value = 50;
|
|
59
|
+
this.min = 0;
|
|
60
|
+
this.max = 100;
|
|
61
|
+
this.step = 1;
|
|
62
|
+
this.label = "";
|
|
63
|
+
// Hides the label but keeps it as the control's name, as on tt-input.
|
|
64
|
+
this.labelHidden = false;
|
|
65
|
+
// Prints the current value beside the label. Off by default: on a
|
|
66
|
+
// slider whose meaning is relative (volume, opacity) the number is
|
|
67
|
+
// noise, and on one whose meaning is absolute it is essential.
|
|
68
|
+
this.showValue = false;
|
|
69
|
+
// Appended to the printed value only. Never part of the form value.
|
|
70
|
+
this.unit = "";
|
|
71
|
+
this.disabled = false;
|
|
72
|
+
this.sliderId = `tt-slider-${++uid}`;
|
|
73
|
+
}
|
|
74
|
+
static { this.formAssociated = true; }
|
|
75
|
+
get form() {
|
|
76
|
+
return this.internals.form;
|
|
77
|
+
}
|
|
78
|
+
get validity() {
|
|
79
|
+
return this.internals.validity;
|
|
80
|
+
}
|
|
81
|
+
// Form-associated elements do not get these for free, and tt-form
|
|
82
|
+
// calls them rather than reaching into internals.
|
|
83
|
+
checkValidity() {
|
|
84
|
+
return this.internals.checkValidity();
|
|
85
|
+
}
|
|
86
|
+
reportValidity() {
|
|
87
|
+
return this.internals.reportValidity();
|
|
88
|
+
}
|
|
89
|
+
/*
|
|
90
|
+
Focus has to be forwarded by hand. Calling focus() on a custom
|
|
91
|
+
element focuses the host, not the control inside its shadow root, so
|
|
92
|
+
without this a form trying to jump to its first invalid field would
|
|
93
|
+
move focus to something that cannot receive a keystroke.
|
|
94
|
+
*/
|
|
95
|
+
focus(options) {
|
|
96
|
+
this.control?.focus(options);
|
|
97
|
+
}
|
|
98
|
+
connectedCallback() {
|
|
99
|
+
super.connectedCallback();
|
|
100
|
+
this.syncFormState();
|
|
101
|
+
}
|
|
102
|
+
formResetCallback() {
|
|
103
|
+
/*
|
|
104
|
+
Back to the middle of the range rather than to 0, because 0 may not
|
|
105
|
+
be in the range at all. A slider from 200 to 800 reset to 0 would
|
|
106
|
+
be outside its own bounds.
|
|
107
|
+
*/
|
|
108
|
+
this.value = this.min + (this.max - this.min) / 2;
|
|
109
|
+
}
|
|
110
|
+
formStateRestoreCallback(state) {
|
|
111
|
+
const restored = Number(state);
|
|
112
|
+
if (!Number.isNaN(restored))
|
|
113
|
+
this.value = restored;
|
|
114
|
+
}
|
|
115
|
+
updated(changed) {
|
|
116
|
+
if (changed.has("value") ||
|
|
117
|
+
changed.has("min") ||
|
|
118
|
+
changed.has("max") ||
|
|
119
|
+
changed.has("name")) {
|
|
120
|
+
this.syncFormState();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
syncFormState() {
|
|
124
|
+
this.internals.setFormValue(String(this.value));
|
|
125
|
+
}
|
|
126
|
+
/** How far along the track the value sits, 0 to 100. */
|
|
127
|
+
get percent() {
|
|
128
|
+
const span = this.max - this.min;
|
|
129
|
+
// A zero-width range is a configuration mistake, not a crash. Show a
|
|
130
|
+
// full track rather than dividing by zero and painting NaN.
|
|
131
|
+
if (span <= 0)
|
|
132
|
+
return 100;
|
|
133
|
+
const clamped = Math.min(this.max, Math.max(this.min, this.value));
|
|
134
|
+
return ((clamped - this.min) / span) * 100;
|
|
135
|
+
}
|
|
136
|
+
handleInput(event) {
|
|
137
|
+
const next = Number(event.target.value);
|
|
138
|
+
this.value = next;
|
|
139
|
+
this.dispatchEvent(new CustomEvent("tt-input", {
|
|
140
|
+
detail: { value: next },
|
|
141
|
+
bubbles: true,
|
|
142
|
+
composed: true,
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
handleChange(event) {
|
|
146
|
+
/*
|
|
147
|
+
Stops the native `change` here. It is composed by default, so it
|
|
148
|
+
would cross the shadow boundary and arrive at a listener as an
|
|
149
|
+
untyped event that looks like tt-change but carries no detail.
|
|
150
|
+
*/
|
|
151
|
+
event.stopPropagation();
|
|
152
|
+
this.dispatchEvent(new CustomEvent("tt-change", {
|
|
153
|
+
detail: { value: this.value },
|
|
154
|
+
bubbles: true,
|
|
155
|
+
composed: true,
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
static { this.styles = [srOnly, css `
|
|
159
|
+
/* The browser's own [hidden] rule loses to any :host display, so a
|
|
160
|
+
hidden element would still show. Important, so it always wins. */
|
|
161
|
+
:host([hidden]) {
|
|
162
|
+
display: none !important;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
:host {
|
|
166
|
+
display: block;
|
|
167
|
+
|
|
168
|
+
font-family: var(--tt-font-sans);
|
|
169
|
+
-webkit-font-smoothing: antialiased;
|
|
170
|
+
|
|
171
|
+
color: var(--tt-foreground);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
:host([disabled]) {
|
|
175
|
+
opacity: var(--tt-opacity-disabled);
|
|
176
|
+
pointer-events: none;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.head {
|
|
180
|
+
display: flex;
|
|
181
|
+
align-items: baseline;
|
|
182
|
+
justify-content: space-between;
|
|
183
|
+
gap: var(--tt-space-3);
|
|
184
|
+
|
|
185
|
+
margin-bottom: var(--tt-space-2);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
label {
|
|
189
|
+
font-size: var(--tt-text-sm);
|
|
190
|
+
font-weight: var(--tt-weight-medium);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.value {
|
|
194
|
+
font-family: var(--tt-font-mono);
|
|
195
|
+
font-size: var(--tt-text-xs);
|
|
196
|
+
color: var(--tt-muted-foreground);
|
|
197
|
+
|
|
198
|
+
/* Tabular figures, so the number does not shuffle sideways while
|
|
199
|
+
you drag. A proportional 1 is narrower than a 0. */
|
|
200
|
+
font-variant-numeric: tabular-nums;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* ---- the control ----
|
|
204
|
+
|
|
205
|
+
appearance: none is required before ANY of the vendor
|
|
206
|
+
pseudo-elements below will take effect. Without it the browser
|
|
207
|
+
keeps its own widget and every rule underneath is silently
|
|
208
|
+
ignored, which reads as "my CSS does nothing". */
|
|
209
|
+
|
|
210
|
+
input {
|
|
211
|
+
-webkit-appearance: none;
|
|
212
|
+
appearance: none;
|
|
213
|
+
|
|
214
|
+
display: block;
|
|
215
|
+
width: 100%;
|
|
216
|
+
margin: 0;
|
|
217
|
+
|
|
218
|
+
background: transparent;
|
|
219
|
+
cursor: pointer;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
input:disabled {
|
|
223
|
+
cursor: not-allowed;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* The filled part is painted with a gradient on the track rather
|
|
227
|
+
than with a second element, so there is nothing to keep in sync
|
|
228
|
+
with the thumb position. One number, --_pct, drives both. */
|
|
229
|
+
|
|
230
|
+
/* Chrome, Edge, Safari */
|
|
231
|
+
input::-webkit-slider-runnable-track {
|
|
232
|
+
height: 6px;
|
|
233
|
+
border-radius: var(--tt-radius-full);
|
|
234
|
+
background: linear-gradient(
|
|
235
|
+
to right,
|
|
236
|
+
var(--tt-primary) 0 var(--_pct),
|
|
237
|
+
var(--tt-muted) var(--_pct) 100%
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
input::-webkit-slider-thumb {
|
|
242
|
+
-webkit-appearance: none;
|
|
243
|
+
appearance: none;
|
|
244
|
+
|
|
245
|
+
width: 16px;
|
|
246
|
+
height: 16px;
|
|
247
|
+
|
|
248
|
+
/* Centres the thumb on the track: half the thumb minus half the
|
|
249
|
+
track. Webkit aligns the thumb's TOP to the track's top, unlike
|
|
250
|
+
Firefox, which centres it for you. */
|
|
251
|
+
margin-top: -5px;
|
|
252
|
+
|
|
253
|
+
border: 2px solid var(--tt-primary);
|
|
254
|
+
border-radius: var(--tt-radius-full);
|
|
255
|
+
background: var(--tt-background);
|
|
256
|
+
|
|
257
|
+
box-shadow: var(--tt-elevation-1);
|
|
258
|
+
|
|
259
|
+
transition: transform var(--tt-duration-fast) var(--tt-ease-out);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
input:hover::-webkit-slider-thumb,
|
|
263
|
+
input:active::-webkit-slider-thumb {
|
|
264
|
+
transform: scale(1.15);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/* Firefox */
|
|
268
|
+
input::-moz-range-track {
|
|
269
|
+
height: 6px;
|
|
270
|
+
border-radius: var(--tt-radius-full);
|
|
271
|
+
background: var(--tt-muted);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
input::-moz-range-progress {
|
|
275
|
+
height: 6px;
|
|
276
|
+
border-radius: var(--tt-radius-full);
|
|
277
|
+
background: var(--tt-primary);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
input::-moz-range-thumb {
|
|
281
|
+
width: 16px;
|
|
282
|
+
height: 16px;
|
|
283
|
+
|
|
284
|
+
border: 2px solid var(--tt-primary);
|
|
285
|
+
border-radius: var(--tt-radius-full);
|
|
286
|
+
background: var(--tt-background);
|
|
287
|
+
|
|
288
|
+
transition: transform var(--tt-duration-fast) var(--tt-ease-out);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
input:hover::-moz-range-thumb,
|
|
292
|
+
input:active::-moz-range-thumb {
|
|
293
|
+
transform: scale(1.15);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/*
|
|
297
|
+
The token file's one focus recipe: an outline, never a box-shadow.
|
|
298
|
+
It goes on .field, the box around everything, rather than on the
|
|
299
|
+
input, because the input is only as tall as its thumb and a ring
|
|
300
|
+
drawn on it would cut through the track.
|
|
301
|
+
|
|
302
|
+
---------------------------------------------------------------
|
|
303
|
+
:has(input:focus-visible), NOT :focus-within.
|
|
304
|
+
|
|
305
|
+
They look interchangeable and are not.
|
|
306
|
+
|
|
307
|
+
:focus-within true whenever anything inside holds focus, and
|
|
308
|
+
clicking a slider gives it focus. So dragging
|
|
309
|
+
the thumb with a mouse drew a ring around the
|
|
310
|
+
whole component, which is not what a ring is
|
|
311
|
+
for: the pointer user can already see what they
|
|
312
|
+
grabbed.
|
|
313
|
+
|
|
314
|
+
:focus-visible the browser's own judgement about whether a
|
|
315
|
+
ring is WARRANTED. Keyboard focus matches;
|
|
316
|
+
a mouse press on a slider does not. Arrow-key
|
|
317
|
+
after a click does, which is right.
|
|
318
|
+
|
|
319
|
+
Note the element: a wrapper inside the shadow root, NOT the host.
|
|
320
|
+
|
|
321
|
+
This first shipped as :host:has(input:focus-visible), and Firefox
|
|
322
|
+
had no keyboard ring at all. The host is a strange element from
|
|
323
|
+
inside its own stylesheet, and engines disagree on whether :has()
|
|
324
|
+
on it may look into the shadow tree: Chrome says yes, Firefox says
|
|
325
|
+
no. :host(:has(...)) is no better, it searches the host's light-DOM
|
|
326
|
+
children and never finds the input in here. An ordinary element
|
|
327
|
+
in the shadow tree has no such question, so the ring lives on one
|
|
328
|
+
and every engine agrees.
|
|
329
|
+
|
|
330
|
+
The ring cannot live on the input itself either: the input is
|
|
331
|
+
thumb-height, so a ring on it cuts the track in half. So the input
|
|
332
|
+
suppresses its own ring and .field draws one, keyed off the
|
|
333
|
+
input's state.
|
|
334
|
+
*/
|
|
335
|
+
input:focus-visible {
|
|
336
|
+
outline: none;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.field:has(input:focus-visible) {
|
|
340
|
+
border-radius: var(--tt-radius-sm);
|
|
341
|
+
outline: var(--tt-ring-width) solid var(--tt-ring);
|
|
342
|
+
outline-offset: var(--tt-ring-offset);
|
|
343
|
+
}
|
|
344
|
+
`]; }
|
|
345
|
+
render() {
|
|
346
|
+
const showHead = this.label !== "" || this.showValue;
|
|
347
|
+
// .field exists only to draw the focus ring; see the styles above.
|
|
348
|
+
return html `
|
|
349
|
+
<div class="field">
|
|
350
|
+
${showHead
|
|
351
|
+
? html `
|
|
352
|
+
<div class="head">
|
|
353
|
+
<label
|
|
354
|
+
for=${this.sliderId}
|
|
355
|
+
part="label"
|
|
356
|
+
class=${this.labelHidden ? "sr-only" : ""}
|
|
357
|
+
>${this.label}</label>
|
|
358
|
+
|
|
359
|
+
${this.showValue
|
|
360
|
+
? html `<span class="value" part="value"
|
|
361
|
+
>${this.value}${this.unit}</span
|
|
362
|
+
>`
|
|
363
|
+
: ""}
|
|
364
|
+
</div>
|
|
365
|
+
`
|
|
366
|
+
: ""}
|
|
367
|
+
|
|
368
|
+
<!-- aria-valuetext carries the unit. Without it a screen reader read
|
|
369
|
+
"40" for a slider the screen showed as "40%". -->
|
|
370
|
+
<input
|
|
371
|
+
id=${this.sliderId}
|
|
372
|
+
type="range"
|
|
373
|
+
part="input"
|
|
374
|
+
style=${`--_pct: ${this.percent}%`}
|
|
375
|
+
.value=${String(this.value)}
|
|
376
|
+
min=${this.min}
|
|
377
|
+
max=${this.max}
|
|
378
|
+
step=${this.step}
|
|
379
|
+
?disabled=${this.disabled}
|
|
380
|
+
aria-label=${ifDefined(this.label ? undefined : "Value")}
|
|
381
|
+
aria-valuetext=${ifDefined(this.unit ? `${this.value}${this.unit}` : undefined)}
|
|
382
|
+
@input=${this.handleInput}
|
|
383
|
+
@change=${this.handleChange}
|
|
384
|
+
/>
|
|
385
|
+
</div>
|
|
386
|
+
`;
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
__decorate([
|
|
390
|
+
property({ type: String, reflect: true })
|
|
391
|
+
], TTSlider.prototype, "name", void 0);
|
|
392
|
+
__decorate([
|
|
393
|
+
property({ type: Number })
|
|
394
|
+
], TTSlider.prototype, "value", void 0);
|
|
395
|
+
__decorate([
|
|
396
|
+
property({ type: Number })
|
|
397
|
+
], TTSlider.prototype, "min", void 0);
|
|
398
|
+
__decorate([
|
|
399
|
+
property({ type: Number })
|
|
400
|
+
], TTSlider.prototype, "max", void 0);
|
|
401
|
+
__decorate([
|
|
402
|
+
property({ type: Number })
|
|
403
|
+
], TTSlider.prototype, "step", void 0);
|
|
404
|
+
__decorate([
|
|
405
|
+
property({ type: String })
|
|
406
|
+
], TTSlider.prototype, "label", void 0);
|
|
407
|
+
__decorate([
|
|
408
|
+
property({ type: Boolean, attribute: "label-hidden", reflect: true })
|
|
409
|
+
], TTSlider.prototype, "labelHidden", void 0);
|
|
410
|
+
__decorate([
|
|
411
|
+
property({ type: Boolean, attribute: "show-value" })
|
|
412
|
+
], TTSlider.prototype, "showValue", void 0);
|
|
413
|
+
__decorate([
|
|
414
|
+
property({ type: String })
|
|
415
|
+
], TTSlider.prototype, "unit", void 0);
|
|
416
|
+
__decorate([
|
|
417
|
+
property({ type: Boolean, reflect: true })
|
|
418
|
+
], TTSlider.prototype, "disabled", void 0);
|
|
419
|
+
__decorate([
|
|
420
|
+
query("input")
|
|
421
|
+
], TTSlider.prototype, "control", void 0);
|
|
422
|
+
TTSlider = __decorate([
|
|
423
|
+
customElement("tt-slider")
|
|
424
|
+
], TTSlider);
|
|
425
|
+
export { TTSlider };
|
|
426
|
+
//# sourceMappingURL=tt-slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tt-slider.js","sourceRoot":"","sources":["../src/tt-slider.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,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,IAAI,GAAG,GAAG,CAAC,CAAC;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QAGG,cAAS,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAE3C;;;;;;UAME;QACyC,SAAI,GAAG,EAAE,CAAC;QAEzB,UAAK,GAAG,EAAE,CAAC;QAEX,QAAG,GAAG,CAAC,CAAC;QACR,QAAG,GAAG,GAAG,CAAC;QACV,SAAI,GAAG,CAAC,CAAC;QAET,UAAK,GAAG,EAAE,CAAC;QAEvC,sEAAsE;QAEtE,gBAAW,GAAG,KAAK,CAAC;QAEpB,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