@re-code/aurora 0.2.0 → 0.3.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/README.md +1 -1
- package/dist/aurora/aurora.esm.js +1 -1
- package/dist/aurora/{p-8ed72e5b.entry.js → p-01ff4d34.entry.js} +1 -1
- package/dist/aurora/{p-c3668073.entry.js → p-0554ffea.entry.js} +1 -1
- package/dist/aurora/{p-278d3434.entry.js → p-0a0a2bfe.entry.js} +1 -1
- package/dist/aurora/{p-e1c97234.entry.js → p-0a7e9e8e.entry.js} +1 -1
- package/dist/aurora/{p-c330982c.entry.js → p-1670a9bd.entry.js} +1 -1
- package/dist/aurora/{p-efd60427.entry.js → p-17c6de2c.entry.js} +1 -1
- package/dist/aurora/{p-a87dc1d3.entry.js → p-24ff90e0.entry.js} +1 -1
- package/dist/aurora/p-27da7b8a.entry.js +1 -0
- package/dist/aurora/p-380d8ebe.entry.js +1 -0
- package/dist/aurora/{p-a1e257c7.entry.js → p-3cfccef1.entry.js} +1 -1
- package/dist/aurora/{p-e72126a2.entry.js → p-4fd71d14.entry.js} +1 -1
- package/dist/aurora/{p-89b66c7a.entry.js → p-5606ed9c.entry.js} +1 -1
- package/dist/aurora/p-56fc4315.entry.js +1 -0
- package/dist/aurora/{p-685b9e53.entry.js → p-5a027df1.entry.js} +1 -1
- package/dist/aurora/{p-487df7d8.entry.js → p-5dd73182.entry.js} +1 -1
- package/dist/aurora/{p-17e65032.entry.js → p-62d79933.entry.js} +1 -1
- package/dist/aurora/p-6a1363da.entry.js +1 -0
- package/dist/aurora/{p-fd4e9cdd.entry.js → p-6e9c8e27.entry.js} +1 -1
- package/dist/aurora/{p-31a86367.entry.js → p-742abb2c.entry.js} +1 -1
- package/dist/aurora/{p-40bb52c3.entry.js → p-7a9bc20f.entry.js} +1 -1
- package/dist/aurora/{p-35edd036.entry.js → p-7cc6bb71.entry.js} +1 -1
- package/dist/aurora/{p-689f37db.entry.js → p-7fa0ee48.entry.js} +1 -1
- package/dist/aurora/{p-ee2ea46e.entry.js → p-815611f9.entry.js} +1 -1
- package/dist/aurora/{p-a8e984e1.entry.js → p-8800c466.entry.js} +1 -1
- package/dist/aurora/{p-5d2a88ca.entry.js → p-9e9377b5.entry.js} +1 -1
- package/dist/aurora/p-DMeUBbqF.js +7 -0
- package/dist/aurora/{p-DXbj-yic.js → p-DNpzZvak.js} +1 -1
- package/dist/aurora/p-DjW6oMgu.js +7 -0
- package/dist/aurora/{p-DzNA1eDU.js → p-DqAwSryz.js} +1 -1
- package/dist/aurora/p-NvNa2Iiu.js +1 -0
- package/dist/aurora/p-a376a248.entry.js +1 -0
- package/dist/aurora/{p-0608e910.entry.js → p-a63d1f80.entry.js} +1 -1
- package/dist/aurora/p-b0ebcc51.entry.js +1 -0
- package/dist/aurora/p-be98a1d7.entry.js +1 -0
- package/dist/aurora/{p-ed998b0c.entry.js → p-bf922703.entry.js} +1 -1
- package/dist/aurora/{p-ee4475a6.entry.js → p-c1422894.entry.js} +1 -1
- package/dist/aurora/{p-372a3416.entry.js → p-c2164ffe.entry.js} +1 -1
- package/dist/aurora/{p-2a16d544.entry.js → p-cb63ca43.entry.js} +1 -1
- package/dist/aurora/p-cc1015fe.entry.js +1 -0
- package/dist/aurora/{p-88b72de7.entry.js → p-cf16464e.entry.js} +1 -1
- package/dist/aurora/p-cfa0166b.entry.js +1 -0
- package/dist/aurora/{p-e7c81a6b.entry.js → p-d85e1d60.entry.js} +1 -1
- package/dist/aurora/{p-64229ad2.entry.js → p-f176be8b.entry.js} +1 -1
- package/dist/aurora/{p-bd1f6486.entry.js → p-f3383f3c.entry.js} +1 -1
- package/dist/aurora/p-f5d3aefa.entry.js +1 -0
- package/dist/aurora/{p-038b2190.entry.js → p-f85687a5.entry.js} +1 -1
- package/dist/aurora/{p-546a2f69.entry.js → p-fe143404.entry.js} +1 -1
- package/dist/cjs/au-alert.cjs.entry.js +1 -1
- package/dist/cjs/au-breadcrumb-item.cjs.entry.js +1 -1
- package/dist/cjs/au-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/au-checkbox.cjs.entry.js +4 -4
- package/dist/cjs/au-combobox.cjs.entry.js +6 -6
- package/dist/cjs/au-container.cjs.entry.js +1 -1
- package/dist/cjs/au-dialog.cjs.entry.js +4 -4
- package/dist/cjs/au-divider.cjs.entry.js +1 -1
- package/dist/cjs/au-field.cjs.entry.js +1 -1
- package/dist/cjs/{au-icon-D0L9Wwy0.js → au-icon-0-khGfX2.js} +1 -1
- package/dist/cjs/au-icon.cjs.entry.js +1 -1
- package/dist/cjs/au-input.cjs.entry.js +6 -6
- package/dist/cjs/au-kbd.cjs.entry.js +355 -0
- package/dist/cjs/au-list-item.cjs.entry.js +195 -0
- package/dist/cjs/au-list.cjs.entry.js +78 -0
- package/dist/cjs/au-menu-item.cjs.entry.js +1 -1
- package/dist/cjs/au-menu.cjs.entry.js +1 -1
- package/dist/cjs/au-nav-link.cjs.entry.js +1 -1
- package/dist/cjs/au-navbar.cjs.entry.js +4 -4
- package/dist/cjs/au-number-input.cjs.entry.js +4 -4
- package/dist/cjs/au-popover.cjs.entry.js +1 -1
- package/dist/cjs/au-progress.cjs.entry.js +107 -0
- package/dist/cjs/au-radio-group.cjs.entry.js +3 -3
- package/dist/cjs/au-radio.cjs.entry.js +1 -1
- package/dist/cjs/au-segmented-control.cjs.entry.js +3 -3
- package/dist/cjs/au-segmented-option.cjs.entry.js +1 -1
- package/dist/cjs/au-select.cjs.entry.js +4 -4
- package/dist/cjs/au-sidebar-nav.cjs.entry.js +1 -1
- package/dist/cjs/au-skeleton.cjs.entry.js +106 -0
- package/dist/cjs/au-slider.cjs.entry.js +3 -3
- package/dist/cjs/au-splitter.cjs.entry.js +2 -2
- package/dist/cjs/au-stat.cjs.entry.js +262 -0
- package/dist/cjs/au-switch.cjs.entry.js +4 -4
- package/dist/cjs/au-tab-panel.cjs.entry.js +1 -1
- package/dist/cjs/au-tab.cjs.entry.js +1 -1
- package/dist/cjs/au-table.cjs.entry.js +337 -0
- package/dist/cjs/au-tabs.cjs.entry.js +4 -4
- package/dist/cjs/au-textarea.cjs.entry.js +3 -3
- package/dist/cjs/au-toast-region.cjs.entry.js +1 -1
- package/dist/cjs/au-toast.cjs.entry.js +1 -1
- package/dist/cjs/au-toc.cjs.entry.js +1 -1
- package/dist/cjs/au-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/aurora.cjs.js +1 -1
- package/dist/cjs/{icon-loader-DyRasOnf.js → icon-loader-Dij7pYkP.js} +3 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/trending-down-BKjmYE1H.js +19 -0
- package/dist/cjs/trending-up-CoWuXxqz.js +19 -0
- package/dist/collection/collection-manifest.json +7 -0
- package/dist/collection/components/data-display/au-kbd/au-kbd.constants.js +85 -0
- package/dist/collection/components/data-display/au-kbd/au-kbd.css +98 -0
- package/dist/collection/components/data-display/au-kbd/au-kbd.js +189 -0
- package/dist/collection/components/data-display/au-kbd/au-kbd.types.js +1 -0
- package/dist/collection/components/data-display/au-kbd/index.js +2 -0
- package/dist/collection/components/data-display/au-kbd/internal/describe.js +67 -0
- package/dist/collection/components/data-display/au-kbd/internal/parse.js +85 -0
- package/dist/collection/components/data-display/au-kbd/internal/platform.js +19 -0
- package/dist/collection/components/data-display/au-list/au-list.constants.js +8 -0
- package/dist/collection/components/data-display/au-list/au-list.css +30 -0
- package/dist/collection/components/data-display/au-list/au-list.js +132 -0
- package/dist/collection/components/data-display/au-list/au-list.types.js +1 -0
- package/dist/collection/components/data-display/au-list/index.js +2 -0
- package/dist/collection/components/data-display/au-list-item/au-list-item.css +196 -0
- package/dist/collection/components/data-display/au-list-item/au-list-item.js +305 -0
- package/dist/collection/components/data-display/au-list-item/index.js +1 -0
- package/dist/collection/components/data-display/au-list-item/internal/interactive-content.js +29 -0
- package/dist/collection/components/data-display/au-stat/au-stat.constants.js +44 -0
- package/dist/collection/components/data-display/au-stat/au-stat.css +139 -0
- package/dist/collection/components/data-display/au-stat/au-stat.js +491 -0
- package/dist/collection/components/data-display/au-stat/au-stat.types.js +1 -0
- package/dist/collection/components/data-display/au-stat/index.js +2 -0
- package/dist/collection/components/data-display/au-stat/internal/announcement.js +13 -0
- package/dist/collection/components/data-display/au-table/au-table.constants.js +21 -0
- package/dist/collection/components/data-display/au-table/au-table.css +20 -0
- package/dist/collection/components/data-display/au-table/au-table.js +482 -0
- package/dist/collection/components/data-display/au-table/au-table.types.js +1 -0
- package/dist/collection/components/data-display/au-table/index.js +2 -0
- package/dist/collection/components/data-display/au-table/internal/scroller-label.js +11 -0
- package/dist/collection/components/data-display/au-table/internal/sort.js +17 -0
- package/dist/collection/components/feedback/au-alert/au-alert.js +1 -1
- package/dist/collection/components/feedback/au-progress/au-progress.constants.js +38 -0
- package/dist/collection/components/feedback/au-progress/au-progress.css +201 -0
- package/dist/collection/components/feedback/au-progress/au-progress.js +226 -0
- package/dist/collection/components/feedback/au-progress/au-progress.types.js +1 -0
- package/dist/collection/components/feedback/au-progress/index.js +2 -0
- package/dist/collection/components/feedback/au-skeleton/au-skeleton.constants.js +33 -0
- package/dist/collection/components/feedback/au-skeleton/au-skeleton.css +108 -0
- package/dist/collection/components/feedback/au-skeleton/au-skeleton.js +159 -0
- package/dist/collection/components/feedback/au-skeleton/au-skeleton.types.js +1 -0
- package/dist/collection/components/feedback/au-skeleton/index.js +2 -0
- package/dist/collection/components/feedback/au-toast/au-toast.js +1 -1
- package/dist/collection/components/feedback/au-toast-region/au-toast-region.js +1 -1
- package/dist/collection/components/forms/au-checkbox/au-checkbox.js +4 -4
- package/dist/collection/components/forms/au-combobox/au-combobox.js +6 -6
- package/dist/collection/components/forms/au-field/au-field.js +1 -1
- package/dist/collection/components/forms/au-input/au-input.js +6 -6
- package/dist/collection/components/forms/au-number-input/au-number-input.js +4 -4
- package/dist/collection/components/forms/au-radio/au-radio.js +1 -1
- package/dist/collection/components/forms/au-radio-group/au-radio-group.js +3 -3
- package/dist/collection/components/forms/au-segmented-control/au-segmented-control.js +3 -3
- package/dist/collection/components/forms/au-segmented-option/au-segmented-option.js +1 -1
- package/dist/collection/components/forms/au-select/au-select.js +4 -4
- package/dist/collection/components/forms/au-slider/au-slider.js +3 -3
- package/dist/collection/components/forms/au-switch/au-switch.js +4 -4
- package/dist/collection/components/forms/au-textarea/au-textarea.js +3 -3
- package/dist/collection/components/layout/au-container/au-container.js +1 -1
- package/dist/collection/components/layout/au-divider/au-divider.js +1 -1
- package/dist/collection/components/layout/au-splitter/au-splitter.js +2 -2
- package/dist/collection/components/navigation/au-breadcrumb/au-breadcrumb.js +1 -1
- package/dist/collection/components/navigation/au-breadcrumb-item/au-breadcrumb-item.js +1 -1
- package/dist/collection/components/navigation/au-nav-link/au-nav-link.js +1 -1
- package/dist/collection/components/navigation/au-navbar/au-navbar.js +4 -4
- package/dist/collection/components/navigation/au-sidebar-nav/au-sidebar-nav.js +1 -1
- package/dist/collection/components/navigation/au-tab/au-tab.js +1 -1
- package/dist/collection/components/navigation/au-tab-panel/au-tab-panel.js +1 -1
- package/dist/collection/components/navigation/au-tabs/au-tabs.js +4 -4
- package/dist/collection/components/navigation/au-toc/au-toc.js +1 -1
- package/dist/collection/components/overlays/au-dialog/au-dialog.js +4 -4
- package/dist/collection/components/overlays/au-menu/au-menu.js +1 -1
- package/dist/collection/components/overlays/au-menu-item/au-menu-item.js +1 -1
- package/dist/collection/components/overlays/au-popover/au-popover.js +1 -1
- package/dist/collection/components/overlays/au-tooltip/au-tooltip.js +1 -1
- package/dist/collection/components/primitives/au-icon/core-icons.js +2 -0
- package/dist/components/au-alert.js +1 -1
- package/dist/components/au-avatar.js +1 -1
- package/dist/components/au-breadcrumb-item.js +1 -1
- package/dist/components/au-breadcrumb.js +1 -1
- package/dist/components/au-checkbox.js +1 -1
- package/dist/components/au-chip.js +1 -1
- package/dist/components/au-code-block.js +1 -1
- package/dist/components/au-combobox.js +1 -1
- package/dist/components/au-container.js +1 -1
- package/dist/components/au-dialog.js +1 -1
- package/dist/components/au-divider.js +1 -1
- package/dist/components/au-field.js +1 -1
- package/dist/components/au-icon.js +1 -1
- package/dist/components/au-input.js +1 -1
- package/dist/components/au-kbd.d.ts +11 -0
- package/dist/components/au-kbd.js +1 -0
- package/dist/components/au-list-item.d.ts +11 -0
- package/dist/components/au-list-item.js +1 -0
- package/dist/components/au-list.d.ts +11 -0
- package/dist/components/au-list.js +1 -0
- package/dist/components/au-menu-item.js +1 -1
- package/dist/components/au-menu.js +1 -1
- package/dist/components/au-nav-link.js +1 -1
- package/dist/components/au-navbar.js +1 -1
- package/dist/components/au-number-input.js +1 -1
- package/dist/components/au-popover.js +1 -1
- package/dist/components/au-progress.d.ts +11 -0
- package/dist/components/au-progress.js +1 -0
- package/dist/components/au-radio-group.js +1 -1
- package/dist/components/au-radio.js +1 -1
- package/dist/components/au-segmented-control.js +1 -1
- package/dist/components/au-segmented-option.js +1 -1
- package/dist/components/au-select.js +1 -1
- package/dist/components/au-sidebar-nav.js +1 -1
- package/dist/components/au-skeleton.d.ts +11 -0
- package/dist/components/au-skeleton.js +1 -0
- package/dist/components/au-slider.js +1 -1
- package/dist/components/au-splitter.js +1 -1
- package/dist/components/au-stat.d.ts +11 -0
- package/dist/components/au-stat.js +1 -0
- package/dist/components/au-switch.js +1 -1
- package/dist/components/au-tab-panel.js +1 -1
- package/dist/components/au-tab.js +1 -1
- package/dist/components/au-table.d.ts +11 -0
- package/dist/components/au-table.js +1 -0
- package/dist/components/au-tabs.js +1 -1
- package/dist/components/au-textarea.js +1 -1
- package/dist/components/au-toast-region.js +1 -1
- package/dist/components/au-toast.js +1 -1
- package/dist/components/au-toc.js +1 -1
- package/dist/components/au-tooltip.js +1 -1
- package/dist/components/p-B5BhPkwP.js +1 -0
- package/dist/components/p-DMeUBbqF.js +7 -0
- package/dist/components/p-DjW6oMgu.js +7 -0
- package/dist/components/{p-DzNA1eDU.js → p-DqAwSryz.js} +1 -1
- package/dist/components/{p-DAqsVCAy.js → p-Dw0zb4x_.js} +1 -1
- package/dist/components/{p-DIL-tsh4.js → p-ZpauIcNt.js} +1 -1
- package/dist/custom-elements.json +1338 -66
- package/dist/esm/au-alert.entry.js +1 -1
- package/dist/esm/au-breadcrumb-item.entry.js +1 -1
- package/dist/esm/au-breadcrumb.entry.js +1 -1
- package/dist/esm/au-checkbox.entry.js +4 -4
- package/dist/esm/au-code-block.entry.js +1 -1
- package/dist/esm/au-combobox.entry.js +7 -7
- package/dist/esm/au-container.entry.js +1 -1
- package/dist/esm/au-dialog.entry.js +4 -4
- package/dist/esm/au-divider.entry.js +1 -1
- package/dist/esm/au-field.entry.js +1 -1
- package/dist/esm/{au-icon-B17psn7x.js → au-icon-6iJTkDID.js} +1 -1
- package/dist/esm/au-icon.entry.js +1 -1
- package/dist/esm/au-input.entry.js +6 -6
- package/dist/esm/au-kbd.entry.js +353 -0
- package/dist/esm/au-list-item.entry.js +193 -0
- package/dist/esm/au-list.entry.js +76 -0
- package/dist/esm/au-menu-item.entry.js +1 -1
- package/dist/esm/au-menu.entry.js +1 -1
- package/dist/esm/au-nav-link.entry.js +1 -1
- package/dist/esm/au-navbar.entry.js +4 -4
- package/dist/esm/au-number-input.entry.js +4 -4
- package/dist/esm/au-popover.entry.js +1 -1
- package/dist/esm/au-progress.entry.js +105 -0
- package/dist/esm/au-radio-group.entry.js +3 -3
- package/dist/esm/au-radio.entry.js +1 -1
- package/dist/esm/au-segmented-control.entry.js +3 -3
- package/dist/esm/au-segmented-option.entry.js +1 -1
- package/dist/esm/au-select.entry.js +4 -4
- package/dist/esm/au-sidebar-nav.entry.js +1 -1
- package/dist/esm/au-skeleton.entry.js +104 -0
- package/dist/esm/au-slider.entry.js +3 -3
- package/dist/esm/au-splitter.entry.js +2 -2
- package/dist/esm/au-stat.entry.js +260 -0
- package/dist/esm/au-switch.entry.js +4 -4
- package/dist/esm/au-tab-panel.entry.js +1 -1
- package/dist/esm/au-tab.entry.js +1 -1
- package/dist/esm/au-table.entry.js +335 -0
- package/dist/esm/au-tabs.entry.js +4 -4
- package/dist/esm/au-textarea.entry.js +3 -3
- package/dist/esm/au-toast-region.entry.js +2 -2
- package/dist/esm/au-toast.entry.js +1 -1
- package/dist/esm/au-toc.entry.js +1 -1
- package/dist/esm/au-tooltip.entry.js +1 -1
- package/dist/esm/aurora.js +1 -1
- package/dist/esm/{icon-loader-CqLCmu4h.js → icon-loader-B2WSNZ27.js} +3 -1
- package/dist/esm/{live-announcer-CXd2OhYs.js → live-announcer-IAjNBWYI.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/trending-down-DjW6oMgu.js +17 -0
- package/dist/esm/trending-up-DMeUBbqF.js +17 -0
- package/dist/styles.css +139 -0
- package/dist/types/components/data-display/au-kbd/au-kbd.constants.d.ts +41 -0
- package/dist/types/components/data-display/au-kbd/au-kbd.d.ts +36 -0
- package/dist/types/components/data-display/au-kbd/au-kbd.types.d.ts +1 -0
- package/dist/types/components/data-display/au-kbd/index.d.ts +3 -0
- package/dist/types/components/data-display/au-kbd/internal/describe.d.ts +13 -0
- package/dist/types/components/data-display/au-kbd/internal/parse.d.ts +18 -0
- package/dist/types/components/data-display/au-kbd/internal/platform.d.ts +13 -0
- package/dist/types/components/data-display/au-list/au-list.constants.d.ts +8 -0
- package/dist/types/components/data-display/au-list/au-list.d.ts +29 -0
- package/dist/types/components/data-display/au-list/au-list.types.d.ts +1 -0
- package/dist/types/components/data-display/au-list/index.d.ts +3 -0
- package/dist/types/components/data-display/au-list-item/au-list-item.d.ts +61 -0
- package/dist/types/components/data-display/au-list-item/index.d.ts +1 -0
- package/dist/types/components/data-display/au-list-item/internal/interactive-content.d.ts +2 -0
- package/dist/types/components/data-display/au-stat/au-stat.constants.d.ts +44 -0
- package/dist/types/components/data-display/au-stat/au-stat.d.ts +67 -0
- package/dist/types/components/data-display/au-stat/au-stat.types.d.ts +1 -0
- package/dist/types/components/data-display/au-stat/index.d.ts +3 -0
- package/dist/types/components/data-display/au-stat/internal/announcement.d.ts +16 -0
- package/dist/types/components/data-display/au-table/au-table.constants.d.ts +26 -0
- package/dist/types/components/data-display/au-table/au-table.d.ts +86 -0
- package/dist/types/components/data-display/au-table/au-table.types.d.ts +1 -0
- package/dist/types/components/data-display/au-table/index.d.ts +3 -0
- package/dist/types/components/data-display/au-table/internal/scroller-label.d.ts +9 -0
- package/dist/types/components/data-display/au-table/internal/sort.d.ts +11 -0
- package/dist/types/components/feedback/au-progress/au-progress.constants.d.ts +31 -0
- package/dist/types/components/feedback/au-progress/au-progress.d.ts +32 -0
- package/dist/types/components/feedback/au-progress/au-progress.types.d.ts +1 -0
- package/dist/types/components/feedback/au-progress/index.d.ts +3 -0
- package/dist/types/components/feedback/au-skeleton/au-skeleton.constants.d.ts +27 -0
- package/dist/types/components/feedback/au-skeleton/au-skeleton.d.ts +31 -0
- package/dist/types/components/feedback/au-skeleton/au-skeleton.types.d.ts +1 -0
- package/dist/types/components/feedback/au-skeleton/index.d.ts +3 -0
- package/dist/types/components.d.ts +712 -0
- package/dist/types/vue.d.ts +7 -0
- package/package.json +53 -1
- package/dist/aurora/p-746825ce.entry.js +0 -1
- package/dist/aurora/p-CoyAdNcI.js +0 -1
- package/dist/aurora/p-b2feddb2.entry.js +0 -1
- package/dist/aurora/p-f89bde2b.entry.js +0 -1
- package/dist/components/p-M21eKzKU.js +0 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-B8lDYTMv.js');
|
|
4
|
+
var liveAnnouncer = require('./live-announcer-vcS-BUxR.js');
|
|
5
|
+
var warnOnce = require('./warn-once-lHF-gQZp.js');
|
|
6
|
+
require('./deep-active-element-CoEYUbhF.js');
|
|
7
|
+
|
|
8
|
+
/** Literals only: no import of the generated constants, so the `/constants` subpath stays standalone. */
|
|
9
|
+
const STAT_SIZE = {
|
|
10
|
+
small: 'small',
|
|
11
|
+
medium: 'medium',
|
|
12
|
+
large: 'large',
|
|
13
|
+
};
|
|
14
|
+
/** Direction of the change. Independent of `intent` (ST-D4): the component never infers one from the other. */
|
|
15
|
+
const STAT_TREND = {
|
|
16
|
+
up: 'up',
|
|
17
|
+
down: 'down',
|
|
18
|
+
flat: 'flat',
|
|
19
|
+
};
|
|
20
|
+
/** Color of the delta row only. */
|
|
21
|
+
const STAT_INTENT = {
|
|
22
|
+
neutral: 'neutral',
|
|
23
|
+
success: 'success',
|
|
24
|
+
danger: 'danger',
|
|
25
|
+
};
|
|
26
|
+
/** `polite` announces value changes through the document announcer. `off` (default) never does. */
|
|
27
|
+
const STAT_LIVE = {
|
|
28
|
+
off: 'off',
|
|
29
|
+
polite: 'polite',
|
|
30
|
+
};
|
|
31
|
+
/** Defaults of the four localizable labels (hidden direction words and the empty state). */
|
|
32
|
+
const STAT_DEFAULT_LABELS = {
|
|
33
|
+
up: 'Up',
|
|
34
|
+
down: 'Down',
|
|
35
|
+
flat: 'Unchanged',
|
|
36
|
+
empty: 'No data',
|
|
37
|
+
};
|
|
38
|
+
/** The decorative icon of each direction. Literals typed `BuiltInIconName`, pinned to the core icons by AC-8.IC6. */
|
|
39
|
+
const STAT_TREND_ICON = {
|
|
40
|
+
up: 'trending-up',
|
|
41
|
+
down: 'trending-down',
|
|
42
|
+
flat: 'minus',
|
|
43
|
+
};
|
|
44
|
+
const sizes = new Set(Object.values(STAT_SIZE));
|
|
45
|
+
const trends = new Set(Object.values(STAT_TREND));
|
|
46
|
+
const intents = new Set(Object.values(STAT_INTENT));
|
|
47
|
+
const lives = new Set(Object.values(STAT_LIVE));
|
|
48
|
+
const isStatSize = (value) => typeof value === 'string' && sizes.has(value);
|
|
49
|
+
const isStatTrend = (value) => typeof value === 'string' && trends.has(value);
|
|
50
|
+
const isStatIntent = (value) => typeof value === 'string' && intents.has(value);
|
|
51
|
+
const isStatLive = (value) => typeof value === 'string' && lives.has(value);
|
|
52
|
+
|
|
53
|
+
const clean = (value) => typeof value === 'string' ? value.trim() : '';
|
|
54
|
+
/**
|
|
55
|
+
* The text the announcer speaks for a stat (ST-D10): the non-blank parts joined with `, `, namely
|
|
56
|
+
* the label, the value with its unit (or the empty label), and the direction word with the delta.
|
|
57
|
+
* Pure, so it can be unit-tested.
|
|
58
|
+
*/
|
|
59
|
+
function composeStatAnnouncement(parts) {
|
|
60
|
+
const value = clean(parts.value);
|
|
61
|
+
const unit = clean(parts.unit);
|
|
62
|
+
const measured = value === '' ? clean(parts.emptyLabel) : [value, unit].filter(Boolean).join(' ');
|
|
63
|
+
const change = [clean(parts.trendWord), clean(parts.delta)].filter(Boolean).join(' ');
|
|
64
|
+
return [clean(parts.label), measured, change].filter(Boolean).join(', ');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const auStatCss = () => `:host{display:block;min-width:0}.stat{--_stat-value-font-size:var(--aurora-stat-value-font-size, var(--aurora-font-size-2xl, 1.5rem));--_stat-delta-color:var(--aurora-stat-neutral-color, var(--aurora-color-text-muted, #566273));margin:0;min-width:0;padding:0;position:relative}.stat--small{--_stat-value-font-size:var(--aurora-stat-value-font-size, var(--aurora-font-size-xl, 1.25rem))}.stat--medium{--_stat-value-font-size:var(--aurora-stat-value-font-size, var(--aurora-font-size-2xl, 1.5rem))}.stat--large{--_stat-value-font-size:var( --aurora-stat-value-font-size, var(--aurora-font-size-3xl, 1.875rem) )}.stat--intent-neutral{--_stat-delta-color:var(--aurora-stat-neutral-color, var(--aurora-color-text-muted, #566273))}.stat--intent-success{--_stat-delta-color:var(--aurora-stat-success-color, var(--aurora-color-success, #176b48))}.stat--intent-danger{--_stat-delta-color:var(--aurora-stat-danger-color, var(--aurora-color-danger, #a32635))}.stat__group{display:flex;flex-direction:column;gap:var(--aurora-stat-gap, var(--aurora-spacing-extra-small, 0.25rem));min-width:0}.stat__label{align-items:center;color:var(--aurora-stat-label-color, var(--aurora-color-text-muted, #566273));display:flex;font-family:var(--aurora-font-family-small, Lato, sans-serif);font-size:var(--aurora-stat-label-font-size, var(--aurora-font-size-sm, 0.875rem));line-height:1.35;margin:0;overflow-wrap:anywhere}.stat__start{display:contents}::slotted([slot=start]){flex:none;margin-inline-end:0.375em}.stat__value{color:var(--aurora-stat-value-color, var(--aurora-color-text, #202733));font-family:var(--aurora-font-family-heading, Montserrat, sans-serif);font-size:var(--_stat-value-font-size);font-weight:var(--aurora-stat-value-font-weight, var(--aurora-font-weight-semibold, 600));line-height:1.2;margin:0;overflow-wrap:anywhere}.stat__number,.stat__delta-text{font-kerning:none;font-variant-numeric:tabular-nums}.stat__unit{color:var(--aurora-stat-unit-color, var(--aurora-color-text-muted, #566273));font-size:0.6em;font-weight:var(--aurora-font-weight-normal, 400)}.stat__delta{color:var(--_stat-delta-color);font-family:var(--aurora-font-family-small, Lato, sans-serif);font-size:var(--aurora-stat-delta-font-size, var(--aurora-font-size-sm, 0.875rem));line-height:1.35;margin:0;overflow-wrap:anywhere}.stat__trend-icon{--aurora-icon-size:1em;vertical-align:-0.125em}.stat__description{color:var(--aurora-stat-label-color, var(--aurora-color-text-muted, #566273));font-family:var(--aurora-font-family-small, Lato, sans-serif);font-size:var(--aurora-stat-label-font-size, var(--aurora-font-size-sm, 0.875rem));line-height:1.35;margin:0}.stat__visually-hidden{border:0;clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}@media (forced-colors: active){.stat__label,.stat__value,.stat__unit,.stat__delta,.stat__delta-text,.stat__description,.stat__trend-icon{color:CanvasText}}`;
|
|
68
|
+
|
|
69
|
+
const EMPTY_DASH = '\u2014';
|
|
70
|
+
/** One announcer key per instance, so a stat replaces its own pending text and no other. */
|
|
71
|
+
let nextInstance = 0;
|
|
72
|
+
const text = (value) => value === undefined || value === null ? '' : String(value).trim();
|
|
73
|
+
const AuStat = class {
|
|
74
|
+
constructor(hostRef) {
|
|
75
|
+
index.registerInstance(this, hostRef);
|
|
76
|
+
}
|
|
77
|
+
get host() { return index.getElement(this); }
|
|
78
|
+
/** The term of the description list. Trimmed. A blank label warns once. */
|
|
79
|
+
label = '';
|
|
80
|
+
/** The value, rendered as written (`String()` for a number). Blank shows the empty state. */
|
|
81
|
+
value = '';
|
|
82
|
+
/** The unit, shown after the value. Omitted when blank. */
|
|
83
|
+
unit = '';
|
|
84
|
+
/** The change, rendered as written, sign included (`+3.2 %`). */
|
|
85
|
+
delta = '';
|
|
86
|
+
/** Direction of the change. Adds a decorative icon and a visually hidden direction word. Unsupported values render no direction and warn once. */
|
|
87
|
+
trend;
|
|
88
|
+
/** Color of the delta row only, independent of `trend`. Unsupported values render `neutral` and warn once. */
|
|
89
|
+
intent = STAT_INTENT.neutral;
|
|
90
|
+
/** `polite` announces changes through the document announcer. Unsupported values render `off` and warn once. */
|
|
91
|
+
live = STAT_LIVE.off;
|
|
92
|
+
/** Size of the value. Unsupported values render `medium` and warn once. */
|
|
93
|
+
size = STAT_SIZE.medium;
|
|
94
|
+
/** Hidden direction word for `trend="up"`. Blank falls back to `Up`. */
|
|
95
|
+
upLabel = STAT_DEFAULT_LABELS.up;
|
|
96
|
+
/** Hidden direction word for `trend="down"`. Blank falls back to `Down`. */
|
|
97
|
+
downLabel = STAT_DEFAULT_LABELS.down;
|
|
98
|
+
/** Hidden direction word for `trend="flat"`. Blank falls back to `Unchanged`. */
|
|
99
|
+
flatLabel = STAT_DEFAULT_LABELS.flat;
|
|
100
|
+
/** Hidden text (and announcement) for a blank value. Blank falls back to `No data`. */
|
|
101
|
+
emptyLabel = STAT_DEFAULT_LABELS.empty;
|
|
102
|
+
/** True while the `description` slot has an assigned element. */
|
|
103
|
+
described = false;
|
|
104
|
+
/** The announcement text last seen (ST-D9). Undefined until the first load completes. */
|
|
105
|
+
baseline;
|
|
106
|
+
announcerKey = `au-stat:${(nextInstance += 1)}`;
|
|
107
|
+
componentWillLoad() {
|
|
108
|
+
this.measureDescription();
|
|
109
|
+
}
|
|
110
|
+
componentDidLoad() {
|
|
111
|
+
this.baseline = this.announcementText();
|
|
112
|
+
}
|
|
113
|
+
connectedCallback() {
|
|
114
|
+
// A moved or re-attached stat takes its current text as the baseline (changes while detached are silent).
|
|
115
|
+
if (this.baseline !== undefined)
|
|
116
|
+
this.baseline = this.announcementText();
|
|
117
|
+
}
|
|
118
|
+
disconnectedCallback() {
|
|
119
|
+
liveAnnouncer.cancelAnnouncement(this.announcerKey, this.host.ownerDocument);
|
|
120
|
+
}
|
|
121
|
+
contentChanged() {
|
|
122
|
+
if (this.baseline === undefined)
|
|
123
|
+
return;
|
|
124
|
+
const next = this.announcementText();
|
|
125
|
+
if (next === this.baseline)
|
|
126
|
+
return;
|
|
127
|
+
this.baseline = next;
|
|
128
|
+
if (this.live === STAT_LIVE.polite && this.canAnnounce()) {
|
|
129
|
+
liveAnnouncer.announce(next, { politeness: 'polite', key: this.announcerKey }, this.host.ownerDocument);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
liveChanged() {
|
|
133
|
+
if (this.baseline === undefined)
|
|
134
|
+
return;
|
|
135
|
+
this.baseline = this.announcementText();
|
|
136
|
+
if (this.live !== STAT_LIVE.polite) {
|
|
137
|
+
liveAnnouncer.cancelAnnouncement(this.announcerKey, this.host.ownerDocument);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/** A hidden host (a closed popover or dock) or a detached one stays silent (ST-D9). */
|
|
141
|
+
canAnnounce() {
|
|
142
|
+
return this.host.isConnected && this.host.getClientRects().length > 0;
|
|
143
|
+
}
|
|
144
|
+
announcementText() {
|
|
145
|
+
const trend = this.safeTrend;
|
|
146
|
+
return composeStatAnnouncement({
|
|
147
|
+
label: this.label,
|
|
148
|
+
value: text(this.value),
|
|
149
|
+
unit: this.unit,
|
|
150
|
+
trendWord: trend === undefined ? '' : this.directionWord(trend),
|
|
151
|
+
delta: this.delta,
|
|
152
|
+
emptyLabel: this.emptyText,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
componentWillRender() {
|
|
156
|
+
this.warnAboutProperties();
|
|
157
|
+
}
|
|
158
|
+
get safeSize() {
|
|
159
|
+
return isStatSize(this.size) ? this.size : STAT_SIZE.medium;
|
|
160
|
+
}
|
|
161
|
+
get safeIntent() {
|
|
162
|
+
return isStatIntent(this.intent) ? this.intent : STAT_INTENT.neutral;
|
|
163
|
+
}
|
|
164
|
+
get safeTrend() {
|
|
165
|
+
return isStatTrend(this.trend) ? this.trend : undefined;
|
|
166
|
+
}
|
|
167
|
+
warn(key, message) {
|
|
168
|
+
warnOnce.warnOncePerDocument(this.host.ownerDocument, `au-stat:${key}`, `[au-stat] ${message}`);
|
|
169
|
+
}
|
|
170
|
+
warnAboutProperties() {
|
|
171
|
+
if (text(this.label) === '') {
|
|
172
|
+
this.warn('missing-label', 'Missing label: the term of the description list is empty. Set the label attribute.');
|
|
173
|
+
}
|
|
174
|
+
if (!isStatSize(this.size)) {
|
|
175
|
+
this.warn('size', `Unsupported size ${JSON.stringify(this.size)}; it renders "medium". Use "small", "medium" or "large".`);
|
|
176
|
+
}
|
|
177
|
+
if (this.isSet(this.trend) && !isStatTrend(this.trend)) {
|
|
178
|
+
this.warn('trend', `Unsupported trend ${JSON.stringify(this.trend)}; no direction is rendered. Use "up", "down" or "flat".`);
|
|
179
|
+
}
|
|
180
|
+
if (!isStatIntent(this.intent)) {
|
|
181
|
+
this.warn('intent', `Unsupported intent ${JSON.stringify(this.intent)}; it renders "neutral". Use "neutral", "success" or "danger".`);
|
|
182
|
+
}
|
|
183
|
+
if (!isStatLive(this.live)) {
|
|
184
|
+
this.warn('live', `Unsupported live ${JSON.stringify(this.live)}; it renders "off", so nothing is announced. Use "off" or "polite".`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** A trend of `undefined`, `null` or a blank string means "no direction", not a mistake. */
|
|
188
|
+
isSet(value) {
|
|
189
|
+
return value !== undefined && value !== null && text(value) !== '';
|
|
190
|
+
}
|
|
191
|
+
/** The visually hidden direction word, with the default when the label is blank. */
|
|
192
|
+
directionWord(trend) {
|
|
193
|
+
const labels = {
|
|
194
|
+
up: [this.upLabel, STAT_DEFAULT_LABELS.up],
|
|
195
|
+
down: [this.downLabel, STAT_DEFAULT_LABELS.down],
|
|
196
|
+
flat: [this.flatLabel, STAT_DEFAULT_LABELS.flat],
|
|
197
|
+
};
|
|
198
|
+
const [custom, fallback] = labels[trend];
|
|
199
|
+
return text(custom) || fallback;
|
|
200
|
+
}
|
|
201
|
+
get emptyText() {
|
|
202
|
+
return text(this.emptyLabel) || STAT_DEFAULT_LABELS.empty;
|
|
203
|
+
}
|
|
204
|
+
/** An element assigned to `description`. Text cannot be assigned to a named slot. */
|
|
205
|
+
measureDescription() {
|
|
206
|
+
this.described = Array.from(this.host.children).some((child) => child.getAttribute('slot') === 'description');
|
|
207
|
+
}
|
|
208
|
+
handleDescriptionChange = () => {
|
|
209
|
+
this.measureDescription();
|
|
210
|
+
};
|
|
211
|
+
renderValue(value, unit) {
|
|
212
|
+
if (value === '') {
|
|
213
|
+
return (index.h("dd", { part: "value", class: "stat__value" }, index.h("span", { part: "number", class: "stat__number", "aria-hidden": "true" }, EMPTY_DASH), index.h("span", { class: "stat__visually-hidden" }, this.emptyText)));
|
|
214
|
+
}
|
|
215
|
+
return (index.h("dd", { part: "value", class: "stat__value" }, index.h("span", { part: "number", class: "stat__number" }, value), unit !== '' && ' ', unit !== '' && (index.h("span", { part: "unit", class: "stat__unit" }, unit))));
|
|
216
|
+
}
|
|
217
|
+
renderDelta(trend, delta) {
|
|
218
|
+
if (delta === '' && trend === undefined)
|
|
219
|
+
return null;
|
|
220
|
+
return (index.h("dd", { part: "delta", class: "stat__delta" }, trend !== undefined && (index.h("au-icon", { part: "trend-icon", class: "stat__trend-icon", icon: STAT_TREND_ICON[trend], decorative: true })), trend !== undefined && (index.h("span", { part: "trend-label", class: "stat__visually-hidden" }, this.directionWord(trend))), trend !== undefined && delta !== '' && ' ', delta !== '' && (index.h("span", { part: "delta-text", class: "stat__delta-text" }, delta))));
|
|
221
|
+
}
|
|
222
|
+
render() {
|
|
223
|
+
const trend = this.safeTrend;
|
|
224
|
+
const description = index.h("slot", { key: '2cc75e8084e7202b222eb7bac38ccf63685a0942', name: "description", onSlotchange: this.handleDescriptionChange });
|
|
225
|
+
return (index.h(index.Host, { key: 'c50f47e2206a641fb6bb37a2535da931944dce75' }, index.h("dl", { key: '6531686606609edf978023d64128ce44acd3fc93', part: "base", class: `stat stat--${this.safeSize} stat--intent-${this.safeIntent}` }, index.h("div", { key: '64bfeb24696cdd0522558dced3befa459596c379', part: "group", class: "stat__group" }, index.h("dt", { key: '57f7b40f54d53b4b6da4749a37c6a5172be05034', part: "label", class: "stat__label" }, index.h("span", { key: 'e22d4b68635d8ccdb947cc10b7e109b72eb4f99c', part: "start", class: "stat__start" }, index.h("slot", { key: '2561e47fc3d00f6c1f1fbf4e5a860d7a61210404', name: "start" })), text(this.label)), this.renderValue(text(this.value), text(this.unit)), this.renderDelta(trend, text(this.delta)), this.described && (index.h("dd", { key: '0681accd58a6c224cd8a9d329850aacd6e74896f', part: "description", class: "stat__description" }, description)))), !this.described && index.h("span", { key: '53477e8a01c555fbad766284c3c57c2db10138e3', hidden: true }, description)));
|
|
226
|
+
}
|
|
227
|
+
static get watchers() { return {
|
|
228
|
+
"label": [{
|
|
229
|
+
"contentChanged": 0
|
|
230
|
+
}],
|
|
231
|
+
"value": [{
|
|
232
|
+
"contentChanged": 0
|
|
233
|
+
}],
|
|
234
|
+
"unit": [{
|
|
235
|
+
"contentChanged": 0
|
|
236
|
+
}],
|
|
237
|
+
"delta": [{
|
|
238
|
+
"contentChanged": 0
|
|
239
|
+
}],
|
|
240
|
+
"trend": [{
|
|
241
|
+
"contentChanged": 0
|
|
242
|
+
}],
|
|
243
|
+
"upLabel": [{
|
|
244
|
+
"contentChanged": 0
|
|
245
|
+
}],
|
|
246
|
+
"downLabel": [{
|
|
247
|
+
"contentChanged": 0
|
|
248
|
+
}],
|
|
249
|
+
"flatLabel": [{
|
|
250
|
+
"contentChanged": 0
|
|
251
|
+
}],
|
|
252
|
+
"emptyLabel": [{
|
|
253
|
+
"contentChanged": 0
|
|
254
|
+
}],
|
|
255
|
+
"live": [{
|
|
256
|
+
"liveChanged": 0
|
|
257
|
+
}]
|
|
258
|
+
}; }
|
|
259
|
+
};
|
|
260
|
+
AuStat.style = auStatCss();
|
|
261
|
+
|
|
262
|
+
exports.au_stat = AuStat;
|
|
@@ -149,19 +149,19 @@ const AuSwitch = class {
|
|
|
149
149
|
'aria-invalid': this.isInvalid ? 'true' : undefined,
|
|
150
150
|
'aria-describedby': this.descriptionIds,
|
|
151
151
|
});
|
|
152
|
-
return (index.h(index.Host, { key: '
|
|
152
|
+
return (index.h(index.Host, { key: '4986a8a1ca543e107da7949efa307113cff87714', class: {
|
|
153
153
|
'switch-host--disabled': this.isDisabled,
|
|
154
154
|
'switch-host--invalid': this.isInvalid,
|
|
155
|
-
} }, index.h("div", { key: '
|
|
155
|
+
} }, index.h("div", { key: 'b4685afda1ab303b7e859b15eab4474ea3038b58', class: {
|
|
156
156
|
switch: true,
|
|
157
157
|
'switch--checked': this.checked,
|
|
158
158
|
'switch--disabled': this.isDisabled,
|
|
159
159
|
'switch--invalid': this.isInvalid,
|
|
160
|
-
} }, index.h("label", { key: '
|
|
160
|
+
} }, index.h("label", { key: '82d61c4d8050875627631463c74061e21b02129d', class: "switch__label", part: "label" }, index.h("input", { key: 'c78c494a5e3beae2e1dcc194779519e01247ba10', ref: (element) => {
|
|
161
161
|
this.inputElement = element;
|
|
162
162
|
if (element && element.checked !== this.checked)
|
|
163
163
|
element.checked = this.checked;
|
|
164
|
-
}, id: this.switchId, class: "switch__control", part: "control", type: "checkbox", role: "switch", checked: this.checked, required: this.required, disabled: this.isDisabled, ...nativeAttributes, onInput: this.handleInput, onChange: this.handleChange }), index.h("span", { key: '
|
|
164
|
+
}, id: this.switchId, class: "switch__control", part: "control", type: "checkbox", role: "switch", checked: this.checked, required: this.required, disabled: this.isDisabled, ...nativeAttributes, onInput: this.handleInput, onChange: this.handleChange }), index.h("span", { key: '5d03f1208c81f04e545ce652133a9b2ad228ed45', class: "switch__track", part: "track", "aria-hidden": "true" }, index.h("span", { key: '336873aa45d649424ccd7bbb7c6644dbe9213062', class: "switch__thumb", part: "thumb", "aria-hidden": "true" })), index.h("span", { key: '82d7210ec03b2e04ea9e1850f5cbca09b011a30a', class: "switch__text", part: "text" }, index.h("slot", { key: '9023a1158a19815b43a72e74162c9fb9e4194313' }, labelText)), this.required ? (index.h("span", { class: "switch__required", "aria-hidden": "true" }, "*")) : null), hintText ? (index.h("p", { class: "switch__hint", id: this.hintId, part: "hint" }, hintText)) : null, errorText ? (index.h("p", { class: "switch__error", id: this.errorId, part: "error", "aria-live": "polite" }, errorText)) : null)));
|
|
165
165
|
}
|
|
166
166
|
static get formAssociated() { return true; }
|
|
167
167
|
static get watchers() { return {
|
|
@@ -47,7 +47,7 @@ const AuTabPanel = class {
|
|
|
47
47
|
first.after(this.host.ownerDocument.importNode(content, true));
|
|
48
48
|
}
|
|
49
49
|
render() {
|
|
50
|
-
return (index.h(index.Host, { key: '
|
|
50
|
+
return (index.h(index.Host, { key: '5bac0591714959242818a220b5b696e5fdf13ace', role: "tabpanel", hidden: !this.active }, this.activated ? index.h("slot", null) : null));
|
|
51
51
|
}
|
|
52
52
|
static get watchers() { return {
|
|
53
53
|
"value": [{
|
|
@@ -22,7 +22,7 @@ const AuTab = class {
|
|
|
22
22
|
itemUpdate.dispatchItemUpdate(this.host);
|
|
23
23
|
}
|
|
24
24
|
render() {
|
|
25
|
-
return (index.h(index.Host, { key: '
|
|
25
|
+
return (index.h(index.Host, { key: '1f231220ec57ae50e0a1636e03b8cb357bc8f65c', role: "tab", "aria-selected": this.selected ? 'true' : 'false' }, index.h("span", { key: '0254822f3b0c330981a81743f126cab8e7508de2', part: "content" }, index.h("slot", { key: '3a4459efd4ade5d704f4df414ec14a8fec3959c2' }))));
|
|
26
26
|
}
|
|
27
27
|
static get watchers() { return {
|
|
28
28
|
"value": [{
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-B8lDYTMv.js');
|
|
4
|
+
var index$1 = require('./index-DI4bia-1.js');
|
|
5
|
+
var warnOnce = require('./warn-once-lHF-gQZp.js');
|
|
6
|
+
|
|
7
|
+
/** Literals only: no import from the foundations, so the `/constants` subpath stays standalone. */
|
|
8
|
+
/** Cell density: `small` is the compact density (Flux `compact`), `medium` the default (Flux `comfortable`). */
|
|
9
|
+
const TABLE_SIZE = {
|
|
10
|
+
small: 'small',
|
|
11
|
+
medium: 'medium',
|
|
12
|
+
};
|
|
13
|
+
/** The two sort states of a column (there is no unsorted third state in v1). */
|
|
14
|
+
const TABLE_SORT_DIRECTION = {
|
|
15
|
+
ascending: 'ascending',
|
|
16
|
+
descending: 'descending',
|
|
17
|
+
};
|
|
18
|
+
/** Consumer attribute on a `thead` `th` that makes the column sortable. Its value is the key. */
|
|
19
|
+
const TABLE_SORT_ATTRIBUTE = 'data-table-sort';
|
|
20
|
+
/** Name of the scroll region when there is neither a `label` nor a caption. */
|
|
21
|
+
const TABLE_DEFAULT_LABEL = 'Table';
|
|
22
|
+
const sizes = new Set(Object.values(TABLE_SIZE));
|
|
23
|
+
const directions = new Set(Object.values(TABLE_SORT_DIRECTION));
|
|
24
|
+
const isTableSize = (value) => typeof value === 'string' && sizes.has(value);
|
|
25
|
+
const isTableSortDirection = (value) => typeof value === 'string' && directions.has(value);
|
|
26
|
+
|
|
27
|
+
/** A trimmed string with its whitespace runs collapsed; anything that is not a string is blank. */
|
|
28
|
+
const clean = (value) => typeof value === 'string' ? value.replace(/\s+/g, ' ').trim() : '';
|
|
29
|
+
/**
|
|
30
|
+
* The name of the scroll region (spec TB-D9): the `label`, else the caption text, else `Table`.
|
|
31
|
+
* `aria-labelledby` cannot reach the light-DOM caption from the shadow scroller, so the text is
|
|
32
|
+
* resolved here.
|
|
33
|
+
*/
|
|
34
|
+
function resolveScrollerLabel(input) {
|
|
35
|
+
return clean(input.label) || clean(input.captionText) || TABLE_DEFAULT_LABEL;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The state after a user activates the header of `key` (spec TB-D5): a different column starts
|
|
40
|
+
* ascending, the same column flips its direction. There is no unsorted third state. Pure: the
|
|
41
|
+
* result is a new object and the input is not changed.
|
|
42
|
+
*/
|
|
43
|
+
function nextSort(current, key) {
|
|
44
|
+
if (current.key === key) {
|
|
45
|
+
return {
|
|
46
|
+
key,
|
|
47
|
+
direction: current.direction === TABLE_SORT_DIRECTION.ascending
|
|
48
|
+
? TABLE_SORT_DIRECTION.descending
|
|
49
|
+
: TABLE_SORT_DIRECTION.ascending,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return { key, direction: TABLE_SORT_DIRECTION.ascending };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const auTableCss = () => `:host{display:block}[part=scroller]{max-block-size:var(--aurora-table-max-block-size, none);overflow:auto}[part=scroller]:focus-visible{outline:var(--aurora-focus-ring-width, 2px) solid var(--aurora-table-focus-ring-color, var(--aurora-focus-ring-color, Highlight));outline-offset:calc(-1 * var(--aurora-focus-ring-width, 2px))}@media print{[part=scroller]{max-block-size:none;overflow:visible}}`;
|
|
56
|
+
|
|
57
|
+
const AuTable = class {
|
|
58
|
+
constructor(hostRef) {
|
|
59
|
+
index.registerInstance(this, hostRef);
|
|
60
|
+
this.auSort = index.createEvent(this, "au-sort", 6);
|
|
61
|
+
}
|
|
62
|
+
get host() { return index.getElement(this); }
|
|
63
|
+
/** Key of the sorted column (the `data-table-sort` value of its header). Unset: no column is sorted. */
|
|
64
|
+
sortKey = undefined;
|
|
65
|
+
/** Direction of the sorted column. An unsupported value is ascending and warns once. */
|
|
66
|
+
sortDirection = TABLE_SORT_DIRECTION.ascending;
|
|
67
|
+
/** Keeps the header row visible while the table scrolls inside a scroller with a bounded block size. */
|
|
68
|
+
stickyHeader = false;
|
|
69
|
+
/** Gives every other body row a stripe background. */
|
|
70
|
+
striped = false;
|
|
71
|
+
/** Cell density: `small` or `medium`. Unsupported values render `medium` and warn once. */
|
|
72
|
+
size = TABLE_SIZE.medium;
|
|
73
|
+
/** Name of the scroll region while it overflows. Blank falls back to the caption text, then to `Table`. */
|
|
74
|
+
label = undefined;
|
|
75
|
+
/**
|
|
76
|
+
* A user activation of a sortable header changed the sort. `detail` is the new state, already
|
|
77
|
+
* written to `sortKey` and `sortDirection`. Programmatic writes of those properties are silent.
|
|
78
|
+
* The component never reorders the rows: sort the data or the DOM in the handler.
|
|
79
|
+
*/
|
|
80
|
+
auSort;
|
|
81
|
+
/** True while the scroller overflows (or still has focus after it stopped): it is then a focusable group. */
|
|
82
|
+
scrollable = false;
|
|
83
|
+
/** The caption text, re-read on every table mutation: it names the scroller. */
|
|
84
|
+
captionText = '';
|
|
85
|
+
loaded = false;
|
|
86
|
+
table;
|
|
87
|
+
slotElement;
|
|
88
|
+
scroller;
|
|
89
|
+
scrollerFocused = false;
|
|
90
|
+
stopMutations;
|
|
91
|
+
stopSize;
|
|
92
|
+
observedTable;
|
|
93
|
+
observedScroller;
|
|
94
|
+
sizeChanged() {
|
|
95
|
+
this.normalizeSize();
|
|
96
|
+
}
|
|
97
|
+
sortDirectionChanged() {
|
|
98
|
+
this.normalizeDirection();
|
|
99
|
+
this.syncSort();
|
|
100
|
+
}
|
|
101
|
+
sortKeyChanged() {
|
|
102
|
+
this.syncSort();
|
|
103
|
+
}
|
|
104
|
+
stickyHeaderChanged() {
|
|
105
|
+
this.checkStickyHeader();
|
|
106
|
+
}
|
|
107
|
+
connectedCallback() {
|
|
108
|
+
// The host subtree covers the table and survives a replaced table (`slotchange` may not fire
|
|
109
|
+
// for a new table written by a framework in the same task).
|
|
110
|
+
this.stopMutations ??= index$1.observeMutations(this.host, () => {
|
|
111
|
+
if (this.loaded)
|
|
112
|
+
this.refresh();
|
|
113
|
+
}, {
|
|
114
|
+
childList: true,
|
|
115
|
+
characterData: true,
|
|
116
|
+
subtree: true,
|
|
117
|
+
attributes: true,
|
|
118
|
+
attributeFilter: [TABLE_SORT_ATTRIBUTE, 'aria-sort'],
|
|
119
|
+
});
|
|
120
|
+
if (this.loaded)
|
|
121
|
+
this.refresh();
|
|
122
|
+
}
|
|
123
|
+
disconnectedCallback() {
|
|
124
|
+
this.stopMutations?.();
|
|
125
|
+
this.stopMutations = undefined;
|
|
126
|
+
this.stopSize?.();
|
|
127
|
+
this.stopSize = undefined;
|
|
128
|
+
this.observedTable = undefined;
|
|
129
|
+
this.observedScroller = undefined;
|
|
130
|
+
}
|
|
131
|
+
componentWillLoad() {
|
|
132
|
+
this.normalizeSize();
|
|
133
|
+
this.normalizeDirection();
|
|
134
|
+
}
|
|
135
|
+
componentDidLoad() {
|
|
136
|
+
this.loaded = true;
|
|
137
|
+
this.refresh();
|
|
138
|
+
this.checkStickyHeader();
|
|
139
|
+
}
|
|
140
|
+
componentDidRender() {
|
|
141
|
+
this.measure();
|
|
142
|
+
}
|
|
143
|
+
warn(key, message) {
|
|
144
|
+
warnOnce.warnOncePerDocument(this.host.ownerDocument, `au-table:${key}`, `au-table:${key}: ${message}`);
|
|
145
|
+
}
|
|
146
|
+
/** An unsupported size renders `medium` (also on the reflected attribute) and warns once. */
|
|
147
|
+
normalizeSize() {
|
|
148
|
+
if (isTableSize(this.size))
|
|
149
|
+
return;
|
|
150
|
+
this.warn('size', `size=${JSON.stringify(this.size)} is not supported and renders "medium". Use "small" or "medium".`);
|
|
151
|
+
this.size = TABLE_SIZE.medium;
|
|
152
|
+
}
|
|
153
|
+
/** An unsupported direction is ascending (also on the reflected attribute) and warns once. */
|
|
154
|
+
normalizeDirection() {
|
|
155
|
+
if (isTableSortDirection(this.sortDirection))
|
|
156
|
+
return;
|
|
157
|
+
this.warn('sort-direction', `sort-direction=${JSON.stringify(this.sortDirection)} is not supported and behaves as "ascending". Use "ascending" or "descending".`);
|
|
158
|
+
this.sortDirection = TABLE_SORT_DIRECTION.ascending;
|
|
159
|
+
}
|
|
160
|
+
/** The table is the first `table` among the slot's assigned elements (TB-D1). */
|
|
161
|
+
discoverTable() {
|
|
162
|
+
const assigned = this.slotElement?.assignedElements({ flatten: true }) ?? Array.from(this.host.children);
|
|
163
|
+
const tables = assigned.filter((element) => element.localName === 'table');
|
|
164
|
+
if (tables.length === 0) {
|
|
165
|
+
this.warn('no-table', 'the default slot holds no <table>, so there is nothing to enhance.');
|
|
166
|
+
}
|
|
167
|
+
else if (tables.length > 1) {
|
|
168
|
+
this.warn('multiple-tables', 'the default slot holds more than one <table>. The first one is used.');
|
|
169
|
+
}
|
|
170
|
+
return tables[0];
|
|
171
|
+
}
|
|
172
|
+
/** Everything that follows the table: discovery, `aria-sort`, the caption name and the overflow. */
|
|
173
|
+
refresh() {
|
|
174
|
+
this.table = this.discoverTable();
|
|
175
|
+
this.bindSize();
|
|
176
|
+
this.syncSort();
|
|
177
|
+
this.syncCaption();
|
|
178
|
+
this.measure();
|
|
179
|
+
}
|
|
180
|
+
handleSlotChange = () => {
|
|
181
|
+
if (this.loaded)
|
|
182
|
+
this.refresh();
|
|
183
|
+
};
|
|
184
|
+
/** The direct `thead` of the slotted table, found by name: `table.tHead` is not reliable everywhere. */
|
|
185
|
+
headOf(table) {
|
|
186
|
+
return Array.from(table.children).find((child) => child.localName === 'thead');
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The sortable headers of the slotted table: `th[data-table-sort]` in its own `thead`, not in a
|
|
190
|
+
* nested table. A blank key makes the header unsortable (TB-D4).
|
|
191
|
+
*/
|
|
192
|
+
sortableHeaders() {
|
|
193
|
+
const table = this.table;
|
|
194
|
+
const head = table ? this.headOf(table) : undefined;
|
|
195
|
+
if (!table || !head)
|
|
196
|
+
return [];
|
|
197
|
+
const found = [];
|
|
198
|
+
for (const header of Array.from(head.querySelectorAll('th'))) {
|
|
199
|
+
const raw = header.getAttribute(TABLE_SORT_ATTRIBUTE);
|
|
200
|
+
if (raw === null || header.closest('table') !== table)
|
|
201
|
+
continue;
|
|
202
|
+
const key = raw.trim();
|
|
203
|
+
if (key === '') {
|
|
204
|
+
this.warn('sort-key', `a header has a blank ${TABLE_SORT_ATTRIBUTE}, so it is not sortable. Give it a key.`);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (!header.querySelector('button')) {
|
|
208
|
+
this.warn('sort-button', `the header of "${key}" has no <button>, so nothing activates it. Write <button type="button"> inside the th.`);
|
|
209
|
+
}
|
|
210
|
+
found.push({ header, key });
|
|
211
|
+
}
|
|
212
|
+
return found;
|
|
213
|
+
}
|
|
214
|
+
/** `aria-sort` is component-owned on every sortable header (TB-D6). Writes only when the value differs. */
|
|
215
|
+
syncSort() {
|
|
216
|
+
for (const { header, key } of this.sortableHeaders()) {
|
|
217
|
+
const wanted = key === this.sortKey ? this.sortDirection : null;
|
|
218
|
+
const current = header.getAttribute('aria-sort');
|
|
219
|
+
if (wanted === null) {
|
|
220
|
+
if (current !== null)
|
|
221
|
+
header.removeAttribute('aria-sort');
|
|
222
|
+
}
|
|
223
|
+
else if (current !== wanted) {
|
|
224
|
+
header.setAttribute('aria-sort', wanted);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
syncCaption() {
|
|
229
|
+
const table = this.table;
|
|
230
|
+
const caption = table
|
|
231
|
+
? Array.from(table.children).find((child) => child.localName === 'caption')
|
|
232
|
+
: undefined;
|
|
233
|
+
const text = caption?.textContent ?? '';
|
|
234
|
+
if (text !== this.captionText)
|
|
235
|
+
this.captionText = text;
|
|
236
|
+
}
|
|
237
|
+
/** Activation is delegated on the host (TB-D7): one listener, no keys of its own. */
|
|
238
|
+
handleClick(event) {
|
|
239
|
+
if (event.defaultPrevented)
|
|
240
|
+
return;
|
|
241
|
+
const target = event.target;
|
|
242
|
+
if (typeof target?.closest !== 'function')
|
|
243
|
+
return;
|
|
244
|
+
const button = target.closest('button');
|
|
245
|
+
const header = button?.closest('th[data-table-sort]');
|
|
246
|
+
const table = this.table;
|
|
247
|
+
if (!button || !header || !table)
|
|
248
|
+
return;
|
|
249
|
+
if (header.closest('table') !== table || header.closest('thead')?.parentElement !== table) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const key = (header.getAttribute(TABLE_SORT_ATTRIBUTE) ?? '').trim();
|
|
253
|
+
if (key === '')
|
|
254
|
+
return;
|
|
255
|
+
const next = nextSort({ key: this.sortKey, direction: this.sortDirection }, key);
|
|
256
|
+
// The state is final before the event, so a listener reads `sortKey` and `aria-sort` as updated.
|
|
257
|
+
this.sortKey = next.key;
|
|
258
|
+
this.sortDirection = next.direction;
|
|
259
|
+
this.syncSort();
|
|
260
|
+
this.auSort.emit({ key, direction: next.direction });
|
|
261
|
+
}
|
|
262
|
+
/** Watches the scroller and the table: a cell that grows overflows without resizing the scroller. */
|
|
263
|
+
bindSize() {
|
|
264
|
+
if (this.stopSize &&
|
|
265
|
+
this.observedTable === this.table &&
|
|
266
|
+
this.observedScroller === this.scroller) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
this.stopSize?.();
|
|
270
|
+
this.stopSize = undefined;
|
|
271
|
+
this.observedTable = this.table;
|
|
272
|
+
this.observedScroller = this.scroller;
|
|
273
|
+
const targets = [this.scroller, this.table].filter((element) => element !== undefined);
|
|
274
|
+
if (targets.length > 0)
|
|
275
|
+
this.stopSize = index$1.observeSize(targets, this.measure);
|
|
276
|
+
}
|
|
277
|
+
/** The scroller is a focusable group only while it overflows; it keeps the attributes while focused. */
|
|
278
|
+
measure = () => {
|
|
279
|
+
const scroller = this.scroller;
|
|
280
|
+
if (!scroller)
|
|
281
|
+
return;
|
|
282
|
+
const overflows = scroller.scrollWidth > scroller.clientWidth || scroller.scrollHeight > scroller.clientHeight;
|
|
283
|
+
if (!overflows && this.scrollerFocused)
|
|
284
|
+
return;
|
|
285
|
+
if (this.scrollable !== overflows)
|
|
286
|
+
this.scrollable = overflows;
|
|
287
|
+
};
|
|
288
|
+
handleScrollerFocus = () => {
|
|
289
|
+
this.scrollerFocused = true;
|
|
290
|
+
};
|
|
291
|
+
handleScrollerBlur = () => {
|
|
292
|
+
this.scrollerFocused = false;
|
|
293
|
+
this.measure();
|
|
294
|
+
};
|
|
295
|
+
/** A sticky header needs a bounded scroller (TB-D10, TS5). Silent where there is no layout. */
|
|
296
|
+
checkStickyHeader() {
|
|
297
|
+
if (!this.stickyHeader || !this.scroller)
|
|
298
|
+
return;
|
|
299
|
+
const view = this.host.ownerDocument.defaultView;
|
|
300
|
+
if (view?.getComputedStyle(this.scroller).maxBlockSize !== 'none')
|
|
301
|
+
return;
|
|
302
|
+
this.warn('sticky-header', 'sticky-header needs a bounded block size: set --aurora-table-max-block-size (for example 24rem), or ::part(scroller) { max-block-size }. Without it the header scrolls with the page.');
|
|
303
|
+
}
|
|
304
|
+
render() {
|
|
305
|
+
return (index.h(index.Host, { key: '209a5e210ba3a13cf5428df22de193c8b39ca305', ...(this.scrollable ? { scrollable: '' } : {}) }, index.h("div", { key: '5957323b686ab11b856fea697c90128a35bf8286', part: "scroller", ref: (element) => {
|
|
306
|
+
this.scroller = element;
|
|
307
|
+
}, onFocus: this.handleScrollerFocus, onBlur: this.handleScrollerBlur, ...(this.scrollable
|
|
308
|
+
? {
|
|
309
|
+
tabindex: '0',
|
|
310
|
+
role: 'group',
|
|
311
|
+
'aria-label': resolveScrollerLabel({
|
|
312
|
+
label: this.label,
|
|
313
|
+
captionText: this.captionText,
|
|
314
|
+
}),
|
|
315
|
+
}
|
|
316
|
+
: {}) }, index.h("slot", { key: '1ae5f2a7d0d7641ba85c7308716fb13662791eed', onSlotchange: this.handleSlotChange, ref: (element) => {
|
|
317
|
+
this.slotElement = element;
|
|
318
|
+
} }))));
|
|
319
|
+
}
|
|
320
|
+
static get watchers() { return {
|
|
321
|
+
"size": [{
|
|
322
|
+
"sizeChanged": 0
|
|
323
|
+
}],
|
|
324
|
+
"sortDirection": [{
|
|
325
|
+
"sortDirectionChanged": 0
|
|
326
|
+
}],
|
|
327
|
+
"sortKey": [{
|
|
328
|
+
"sortKeyChanged": 0
|
|
329
|
+
}],
|
|
330
|
+
"stickyHeader": [{
|
|
331
|
+
"stickyHeaderChanged": 0
|
|
332
|
+
}]
|
|
333
|
+
}; }
|
|
334
|
+
};
|
|
335
|
+
AuTable.style = auTableCss();
|
|
336
|
+
|
|
337
|
+
exports.au_table = AuTable;
|