@scania/tegel 1.0.0 → 1.0.3
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 +178 -178
- package/dist/cjs/dfs-babd18a6.js +29 -0
- package/dist/cjs/generateUniqueId-56da4810.js +28 -0
- package/dist/cjs/hasSlot-1c90e9ba.js +11 -0
- package/dist/cjs/{index-2a60e106.js → index-862c9693.js} +5 -5
- package/dist/cjs/inheritAriaAttributes-640b1abb.js +78 -0
- package/dist/cjs/inheritAttributes-845f5217.js +27 -0
- package/dist/cjs/isHeadingElement-d31dde38.js +71 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/tds-accordion-item.cjs.entry.js +6 -6
- package/dist/cjs/tds-accordion.cjs.entry.js +1 -1
- package/dist/cjs/tds-badge.cjs.entry.js +1 -1
- package/dist/cjs/tds-banner.cjs.entry.js +7 -15
- package/dist/cjs/tds-block.cjs.entry.js +5 -3
- package/dist/cjs/tds-body-cell.cjs.entry.js +1 -1
- package/dist/cjs/tds-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/tds-breadcrumbs.cjs.entry.js +1 -1
- package/dist/cjs/tds-button.cjs.entry.js +4 -4
- package/dist/cjs/tds-card.cjs.entry.js +11 -10
- package/dist/cjs/tds-checkbox.cjs.entry.js +4 -4
- package/dist/cjs/tds-chip.cjs.entry.js +7 -6
- package/dist/cjs/tds-core-header-item_2.cjs.entry.js +3 -3
- package/dist/cjs/tds-datetime.cjs.entry.js +10 -10
- package/dist/cjs/tds-divider.cjs.entry.js +1 -1
- package/dist/cjs/tds-dropdown-option.cjs.entry.js +9 -8
- package/dist/cjs/tds-dropdown.cjs.entry.js +195 -69
- package/dist/cjs/tds-folder-tab.cjs.entry.js +2 -2
- package/dist/cjs/tds-folder-tabs.cjs.entry.js +1 -1
- package/dist/cjs/tds-footer-group.cjs.entry.js +3 -3
- package/dist/cjs/tds-footer-item.cjs.entry.js +1 -1
- package/dist/cjs/tds-footer.cjs.entry.js +5 -5
- package/dist/cjs/tds-header-brand-symbol.cjs.entry.js +1 -1
- package/dist/cjs/tds-header-cell.cjs.entry.js +1 -1
- package/dist/cjs/tds-header-dropdown-list-item.cjs.entry.js +1 -1
- package/dist/cjs/tds-header-dropdown-list-user.cjs.entry.js +1 -1
- package/dist/cjs/tds-header-dropdown-list.cjs.entry.js +4 -3
- package/dist/cjs/tds-header-dropdown.cjs.entry.js +3 -3
- package/dist/cjs/tds-header-hamburger.cjs.entry.js +4 -3
- package/dist/cjs/tds-header-launcher-button.cjs.entry.js +4 -3
- package/dist/cjs/tds-header-launcher-grid-item.cjs.entry.js +1 -1
- package/dist/cjs/tds-header-launcher-grid-title.cjs.entry.js +3 -3
- package/dist/cjs/tds-header-launcher-grid.cjs.entry.js +5 -4
- package/dist/cjs/tds-header-launcher-list-item.cjs.entry.js +1 -1
- package/dist/cjs/tds-header-launcher-list-title.cjs.entry.js +3 -3
- package/dist/cjs/tds-header-launcher-list.cjs.entry.js +3 -3
- package/dist/cjs/tds-header-launcher.cjs.entry.js +6 -4
- package/dist/cjs/tds-header-title.cjs.entry.js +1 -1
- package/dist/cjs/tds-header.cjs.entry.js +21 -5
- package/dist/cjs/tds-icon.cjs.entry.js +5 -3
- package/dist/cjs/tds-inline-tab.cjs.entry.js +2 -2
- package/dist/cjs/tds-inline-tabs.cjs.entry.js +1 -7
- package/dist/cjs/tds-link.cjs.entry.js +4 -4
- package/dist/cjs/tds-message.cjs.entry.js +4 -4
- package/dist/cjs/tds-modal.cjs.entry.js +5 -5
- package/dist/cjs/tds-navigation-tab.cjs.entry.js +2 -2
- package/dist/cjs/tds-navigation-tabs.cjs.entry.js +1 -4
- package/dist/cjs/tds-popover-canvas.cjs.entry.js +3 -3
- package/dist/cjs/tds-popover-core.cjs.entry.js +1 -1
- package/dist/cjs/tds-popover-menu-item.cjs.entry.js +1 -1
- package/dist/cjs/tds-popover-menu.cjs.entry.js +3 -3
- package/dist/cjs/tds-radio-button.cjs.entry.js +3 -3
- package/dist/cjs/tds-side-menu-close-button.cjs.entry.js +4 -3
- package/dist/cjs/tds-side-menu-collapse-button.cjs.entry.js +1 -1
- package/dist/cjs/tds-side-menu-dropdown-list-item.cjs.entry.js +1 -1
- package/dist/cjs/tds-side-menu-dropdown-list.cjs.entry.js +1 -1
- package/dist/cjs/tds-side-menu-dropdown.cjs.entry.js +1 -1
- package/dist/cjs/tds-side-menu-item.cjs.entry.js +3 -3
- package/dist/cjs/tds-side-menu-overlay.cjs.entry.js +1 -1
- package/dist/cjs/tds-side-menu-user-image_2.cjs.entry.js +1 -1
- package/dist/cjs/tds-side-menu-user.cjs.entry.js +1 -1
- package/dist/cjs/tds-side-menu.cjs.entry.js +1 -1
- package/dist/cjs/tds-slider.cjs.entry.js +15 -9
- package/dist/cjs/tds-spinner.cjs.entry.js +1 -1
- package/dist/cjs/tds-step.cjs.entry.js +1 -1
- package/dist/cjs/tds-stepper.cjs.entry.js +3 -3
- package/dist/cjs/tds-table-body-row-expandable.cjs.entry.js +1 -1
- package/dist/cjs/tds-table-body-row.cjs.entry.js +1 -1
- package/dist/cjs/tds-table-body.cjs.entry.js +1 -1
- package/dist/cjs/tds-table-footer.cjs.entry.js +2 -2
- package/dist/cjs/tds-table-header.cjs.entry.js +1 -1
- package/dist/cjs/tds-table-toolbar.cjs.entry.js +1 -1
- package/dist/cjs/tds-table.cjs.entry.js +3 -3
- package/dist/cjs/tds-text-field.cjs.entry.js +16 -16
- package/dist/cjs/tds-textarea.cjs.entry.js +11 -11
- package/dist/cjs/tds-toast.cjs.entry.js +9 -8
- package/dist/cjs/tds-toggle.cjs.entry.js +3 -3
- package/dist/cjs/tds-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/tegel.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/accordion/accordion-item/accordion-item.js +6 -6
- package/dist/collection/components/accordion/accordion.stories.js +22 -22
- package/dist/collection/components/badge/badge.stories.js +31 -31
- package/dist/collection/components/banner/banner.js +4 -26
- package/dist/collection/components/banner/banner.stories.js +17 -20
- package/dist/collection/components/block/block.js +4 -2
- package/dist/collection/components/block/block.stories.js +10 -10
- package/dist/collection/components/breadcrumbs/breadcrumbs.stories.js +13 -13
- package/dist/collection/components/button/button.js +1 -1
- package/dist/collection/components/button/button.stories.js +27 -27
- package/dist/collection/components/card/card.css +1 -0
- package/dist/collection/components/card/card.js +4 -3
- package/dist/collection/components/card/card.stories.js +32 -32
- package/dist/collection/components/checkbox/checkbox.css +14 -0
- package/dist/collection/components/checkbox/checkbox.js +2 -2
- package/dist/collection/components/checkbox/checkbox.stories.js +23 -23
- package/dist/collection/components/chip/chip.js +7 -6
- package/dist/collection/components/chip/chip.stories.js +94 -94
- package/dist/collection/components/datetime/datetime.js +9 -9
- package/dist/collection/components/datetime/datetime.stories.js +41 -41
- package/dist/collection/components/divider/divider.stories.js +5 -5
- package/dist/collection/components/dropdown/dropdown-option/dropdown-option.css +4 -4
- package/dist/collection/components/dropdown/dropdown-option/dropdown-option.js +8 -7
- package/dist/collection/components/dropdown/dropdown.css +7 -2
- package/dist/collection/components/dropdown/dropdown.js +165 -75
- package/dist/collection/components/dropdown/dropdown.stories.js +54 -58
- package/dist/collection/components/footer/footer-group/footer-group.js +2 -2
- package/dist/collection/components/footer/footer.js +1 -1
- package/dist/collection/components/footer/footer.stories.js +94 -94
- package/dist/collection/components/header/header-dropdown/header-dropdown.js +2 -2
- package/dist/collection/components/header/header-dropdown-list/header-dropdown-list.js +2 -1
- package/dist/collection/components/header/header-hamburger/header-hamburger.js +1 -1
- package/dist/collection/components/header/header-item/header-item.js +2 -2
- package/dist/collection/components/header/header-launcher/header-launcher.js +2 -1
- package/dist/collection/components/header/header-launcher-button/header-launcher-button.js +2 -2
- package/dist/collection/components/header/header-launcher-grid/header-launcher-grid.js +2 -1
- package/dist/collection/components/header/header-launcher-grid-title/header-launcher-grid-title.js +1 -1
- package/dist/collection/components/header/header-launcher-list/header-launcher-list.js +1 -1
- package/dist/collection/components/header/header-launcher-list-title/header-launcher-list-title.js +1 -1
- package/dist/collection/components/header/header.js +2 -1
- package/dist/collection/components/header/header.stories.js +32 -32
- package/dist/collection/components/icon/icon.js +20 -1
- package/dist/collection/components/icon/icon.stories.js +3 -3
- package/dist/collection/components/icon/iconsArray.js +115 -115
- package/dist/collection/components/link/link.js +3 -3
- package/dist/collection/components/link/link.stories.js +10 -10
- package/dist/collection/components/message/message.js +3 -3
- package/dist/collection/components/message/message.stories.js +19 -19
- package/dist/collection/components/modal/modal.js +2 -2
- package/dist/collection/components/modal/modal.stories.js +28 -28
- package/dist/collection/components/popover-canvas/popover-canvas.js +2 -2
- package/dist/collection/components/popover-canvas/popover-canvas.stories.js +34 -34
- package/dist/collection/components/popover-core/popover-core.js +1 -1
- package/dist/collection/components/popover-menu/popover-menu.js +2 -2
- package/dist/collection/components/popover-menu/popover-menu.stories.js +59 -61
- package/dist/collection/components/radio-button/radio-button.js +3 -3
- package/dist/collection/components/radio-button/radio-button.stories.js +45 -45
- package/dist/collection/components/side-menu/side-menu-close-button/side-menu-close-button.js +1 -1
- package/dist/collection/components/side-menu/side-menu-collapse-button/side-menu-collapse-button.js +1 -1
- package/dist/collection/components/side-menu/side-menu-dropdown/side-menu-dropdown.js +1 -1
- package/dist/collection/components/side-menu/side-menu-item/side-menu-item.js +2 -2
- package/dist/collection/components/side-menu/side-menu.js +4 -4
- package/dist/collection/components/side-menu/side-menu.stories.js +144 -144
- package/dist/collection/components/slider/slider.js +17 -8
- package/dist/collection/components/slider/slider.stories.js +39 -39
- package/dist/collection/components/spinner/spinner.stories.js +6 -6
- package/dist/collection/components/stepper/stepper.js +3 -3
- package/dist/collection/components/stepper/stepper.stories.js +15 -15
- package/dist/collection/components/table/table/table.js +3 -3
- package/dist/collection/components/table/table-body-row/table-body-row.js +1 -1
- package/dist/collection/components/table/table-body-row-expandable/table-body-row-expandable.js +1 -1
- package/dist/collection/components/table/table-component-basic.stories.js +52 -52
- package/dist/collection/components/table/table-component-batch-actions.stories.js +59 -59
- package/dist/collection/components/table/table-component-custom-width.stories.js +53 -53
- package/dist/collection/components/table/table-component-expandable-rows.stories.js +39 -39
- package/dist/collection/components/table/table-component-filtering.stories.js +72 -80
- package/dist/collection/components/table/table-component-multiselect.stories.js +74 -75
- package/dist/collection/components/table/table-component-pagination.stories.js +73 -73
- package/dist/collection/components/table/table-component-sorting.stories.js +75 -75
- package/dist/collection/components/table/table-footer/table-footer.css +2 -1
- package/dist/collection/components/table/table-footer/table-footer.js +1 -1
- package/dist/collection/components/table/table-header/table-header.js +1 -1
- package/dist/collection/components/table/table-header-cell/table-header-cell.js +3 -3
- package/dist/collection/components/table/table-toolbar/table-toolbar.js +2 -2
- package/dist/collection/components/tabs/folder-tabs/folder-tab/folder-tab.js +1 -1
- package/dist/collection/components/tabs/folder-tabs/folder-tabs.js +2 -2
- package/dist/collection/components/tabs/folder-tabs/folder-tabs.stories.js +35 -35
- package/dist/collection/components/tabs/inline-tabs/inline-tab/inline-tab.js +1 -1
- package/dist/collection/components/tabs/inline-tabs/inline-tabs.js +2 -8
- package/dist/collection/components/tabs/inline-tabs/inline-tabs.stories.js +35 -35
- package/dist/collection/components/tabs/navigation-tabs/navigation-tab/navigation-tab.js +1 -1
- package/dist/collection/components/tabs/navigation-tabs/navigation-tabs.js +2 -5
- package/dist/collection/components/tabs/navigation-tabs/navigation-tabs.stories.js +37 -37
- package/dist/collection/components/text-field/text-field.js +14 -14
- package/dist/collection/components/text-field/text-field.stories.js +46 -46
- package/dist/collection/components/textarea/textarea.js +10 -10
- package/dist/collection/components/textarea/textarea.stories.js +41 -41
- package/dist/collection/components/toast/toast.js +5 -4
- package/dist/collection/components/toast/toast.stories.js +16 -16
- package/dist/collection/components/toggle/toggle.js +2 -2
- package/dist/collection/components/toggle/toggle.stories.js +18 -18
- package/dist/collection/components/tooltip/tooltip.js +1 -1
- package/dist/collection/components/tooltip/tooltip.stories.js +24 -34
- package/dist/collection/stories/Installation/installation.stories.js +201 -205
- package/dist/collection/stories/announcements/announce-tegel.stories.js +248 -248
- package/dist/collection/stories/announcements/prefix-change.stories.js +79 -79
- package/dist/collection/stories/formatHtmlPreview.js +10 -0
- package/dist/collection/stories/foundations/color/color-brand.stories.js +25 -25
- package/dist/collection/stories/foundations/color/color-scales.stories.js +19 -19
- package/dist/collection/stories/foundations/color/color-semantic.stories.js +28 -28
- package/dist/collection/stories/foundations/grid/grid.stories.js +335 -335
- package/dist/collection/stories/foundations/spacing/spacing-element.stories.js +91 -91
- package/dist/collection/stories/foundations/spacing/spacing-layout.stories.js +85 -85
- package/dist/collection/stories/foundations/typography/typography-body.stories.js +8 -8
- package/dist/collection/stories/foundations/typography/typography-detail.stories.js +9 -9
- package/dist/collection/stories/foundations/typography/typography-headline.stories.js +18 -18
- package/dist/collection/stories/foundations/typography/typography-paragraph.stories.js +4 -4
- package/dist/collection/stories/patterns/navigation/navigation-basic.stories.js +54 -54
- package/dist/collection/stories/patterns/navigation/navigation-fewitems.stories.js +228 -228
- package/dist/collection/stories/patterns/navigation/navigation-manyitems.stories.js +203 -203
- package/dist/collection/stories/patterns/navigation/navigation-user-menu.stories.js +99 -99
- package/dist/collection/stories/tegel.stories.js +270 -279
- package/dist/collection/stories/utility/color/background-color.stories.js +14 -14
- package/dist/collection/stories/utility/color/text-color.stories.js +12 -12
- package/dist/collection/types/Attributes.js +1 -0
- package/dist/collection/utils/appendHiddenInput.js +25 -0
- package/dist/collection/utils/dfs.js +26 -0
- package/dist/collection/utils/findNextFocusableElement.js +16 -0
- package/dist/collection/utils/findPreviousFocusableElement.js +17 -0
- package/dist/collection/utils/generateUniqueId.js +25 -0
- package/dist/collection/utils/getNestedChildOfSiblingsMatching.js +22 -0
- package/dist/collection/utils/getNextNestedChildOfSiblingsMatching.js +32 -0
- package/dist/collection/utils/getNextSibling.js +2 -0
- package/dist/collection/utils/getPreviousNestedChildOfSiblingsMatching.js +32 -0
- package/dist/collection/utils/getPreviousSibling.js +2 -0
- package/dist/collection/utils/hasSlot.js +8 -0
- package/dist/collection/utils/inheritAriaAttributes.js +74 -0
- package/dist/collection/utils/inheritAttributes.js +24 -0
- package/dist/collection/utils/isHeadingElement.js +12 -0
- package/dist/collection/utils/updateListChildrenRoles.js +15 -0
- package/dist/components/checkbox.js +3 -2
- package/dist/components/core-header-item.js +1 -0
- package/dist/components/dfs.js +27 -0
- package/dist/components/divider.js +1 -0
- package/dist/components/generateUniqueId.js +26 -0
- package/dist/components/getPreviousNestedChildOfSiblingsMatching.js +68 -0
- package/dist/components/hasSlot.js +9 -0
- package/dist/components/header-dropdown-list-item.js +1 -0
- package/dist/components/header-dropdown-list.js +2 -1
- package/dist/components/header-item.js +2 -1
- package/dist/components/header-launcher-button.js +2 -1
- package/dist/components/icon.js +6 -2
- package/dist/components/inheritAriaAttributes.js +76 -0
- package/dist/components/inheritAttributes.js +25 -0
- package/dist/components/popover-canvas.js +2 -1
- package/dist/components/popover-core.js +1 -0
- package/dist/components/side-menu-item.js +2 -1
- package/dist/components/side-menu-user-image.js +1 -0
- package/dist/components/side-menu-user-label.js +1 -0
- package/dist/components/tds-accordion-item.js +6 -5
- package/dist/components/tds-accordion.js +1 -0
- package/dist/components/tds-badge.js +1 -0
- package/dist/components/tds-banner.js +3 -10
- package/dist/components/tds-block.js +5 -2
- package/dist/components/tds-body-cell.js +1 -0
- package/dist/components/tds-breadcrumb.js +1 -0
- package/dist/components/tds-breadcrumbs.js +1 -0
- package/dist/components/tds-button.js +2 -1
- package/dist/components/tds-card.js +4 -2
- package/dist/components/tds-chip.js +3 -1
- package/dist/components/tds-datetime.js +10 -9
- package/dist/components/tds-dropdown-option.js +9 -7
- package/dist/components/tds-dropdown.js +197 -69
- package/dist/components/tds-folder-tab.js +2 -1
- package/dist/components/tds-folder-tabs.js +1 -0
- package/dist/components/tds-footer-group.js +3 -2
- package/dist/components/tds-footer-item.js +1 -0
- package/dist/components/tds-footer.js +2 -1
- package/dist/components/tds-header-brand-symbol.js +1 -0
- package/dist/components/tds-header-cell.js +1 -0
- package/dist/components/tds-header-dropdown-list-user.js +1 -0
- package/dist/components/tds-header-dropdown.js +2 -1
- package/dist/components/tds-header-hamburger.js +2 -1
- package/dist/components/tds-header-launcher-grid-item.js +1 -0
- package/dist/components/tds-header-launcher-grid-title.js +2 -1
- package/dist/components/tds-header-launcher-grid.js +2 -1
- package/dist/components/tds-header-launcher-list-item.js +1 -0
- package/dist/components/tds-header-launcher-list-title.js +2 -1
- package/dist/components/tds-header-launcher-list.js +2 -1
- package/dist/components/tds-header-launcher.js +3 -1
- package/dist/components/tds-header-title.js +1 -0
- package/dist/components/tds-header.js +17 -1
- package/dist/components/tds-inline-tab.js +2 -1
- package/dist/components/tds-inline-tabs.js +1 -6
- package/dist/components/tds-link.js +4 -3
- package/dist/components/tds-message.js +4 -3
- package/dist/components/tds-modal.js +2 -1
- package/dist/components/tds-navigation-tab.js +2 -1
- package/dist/components/tds-navigation-tabs.js +1 -3
- package/dist/components/tds-popover-menu-item.js +1 -0
- package/dist/components/tds-popover-menu.js +2 -1
- package/dist/components/tds-radio-button.js +2 -1
- package/dist/components/tds-side-menu-close-button.js +2 -1
- package/dist/components/tds-side-menu-collapse-button.js +1 -0
- package/dist/components/tds-side-menu-dropdown-list-item.js +1 -0
- package/dist/components/tds-side-menu-dropdown-list.js +1 -0
- package/dist/components/tds-side-menu-dropdown.js +1 -0
- package/dist/components/tds-side-menu-overlay.js +1 -0
- package/dist/components/tds-side-menu-user.js +1 -0
- package/dist/components/tds-side-menu.js +1 -0
- package/dist/components/tds-slider.js +14 -7
- package/dist/components/tds-spinner.js +1 -0
- package/dist/components/tds-step.js +1 -0
- package/dist/components/tds-stepper.js +2 -1
- package/dist/components/tds-table-body-row-expandable.js +1 -0
- package/dist/components/tds-table-body-row.js +1 -0
- package/dist/components/tds-table-body.js +1 -0
- package/dist/components/tds-table-footer.js +2 -1
- package/dist/components/tds-table-header.js +1 -0
- package/dist/components/tds-table-toolbar.js +1 -0
- package/dist/components/tds-table.js +2 -1
- package/dist/components/tds-text-field.js +14 -13
- package/dist/components/tds-textarea.js +11 -10
- package/dist/components/tds-toast.js +5 -3
- package/dist/components/tds-toggle.js +2 -1
- package/dist/components/tds-tooltip.js +2 -1
- package/dist/esm/dfs-3f5bd9e8.js +27 -0
- package/dist/esm/generateUniqueId-c96c8ee6.js +26 -0
- package/dist/esm/hasSlot-d52114d0.js +9 -0
- package/dist/esm/{index-7471aeb6.js → index-21543b0f.js} +5 -5
- package/dist/esm/inheritAriaAttributes-d4dfca6b.js +76 -0
- package/dist/esm/inheritAttributes-8bb09af0.js +25 -0
- package/dist/esm/isHeadingElement-2c158fc4.js +68 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/tds-accordion-item.entry.js +6 -6
- package/dist/esm/tds-accordion.entry.js +1 -1
- package/dist/esm/tds-badge.entry.js +1 -1
- package/dist/esm/tds-banner.entry.js +3 -11
- package/dist/esm/tds-block.entry.js +5 -3
- package/dist/esm/tds-body-cell.entry.js +1 -1
- package/dist/esm/tds-breadcrumb.entry.js +1 -1
- package/dist/esm/tds-breadcrumbs.entry.js +1 -1
- package/dist/esm/tds-button.entry.js +2 -2
- package/dist/esm/tds-card.entry.js +4 -3
- package/dist/esm/tds-checkbox.entry.js +3 -3
- package/dist/esm/tds-chip.entry.js +3 -2
- package/dist/esm/tds-core-header-item_2.entry.js +2 -2
- package/dist/esm/tds-datetime.entry.js +10 -10
- package/dist/esm/tds-divider.entry.js +1 -1
- package/dist/esm/tds-dropdown-option.entry.js +9 -8
- package/dist/esm/tds-dropdown.entry.js +195 -69
- package/dist/esm/tds-folder-tab.entry.js +2 -2
- package/dist/esm/tds-folder-tabs.entry.js +1 -1
- package/dist/esm/tds-footer-group.entry.js +3 -3
- package/dist/esm/tds-footer-item.entry.js +1 -1
- package/dist/esm/tds-footer.entry.js +2 -2
- package/dist/esm/tds-header-brand-symbol.entry.js +1 -1
- package/dist/esm/tds-header-cell.entry.js +1 -1
- package/dist/esm/tds-header-dropdown-list-item.entry.js +1 -1
- package/dist/esm/tds-header-dropdown-list-user.entry.js +1 -1
- package/dist/esm/tds-header-dropdown-list.entry.js +3 -2
- package/dist/esm/tds-header-dropdown.entry.js +2 -2
- package/dist/esm/tds-header-hamburger.entry.js +3 -2
- package/dist/esm/tds-header-launcher-button.entry.js +3 -2
- package/dist/esm/tds-header-launcher-grid-item.entry.js +1 -1
- package/dist/esm/tds-header-launcher-grid-title.entry.js +2 -2
- package/dist/esm/tds-header-launcher-grid.entry.js +3 -2
- package/dist/esm/tds-header-launcher-list-item.entry.js +1 -1
- package/dist/esm/tds-header-launcher-list-title.entry.js +2 -2
- package/dist/esm/tds-header-launcher-list.entry.js +2 -2
- package/dist/esm/tds-header-launcher.entry.js +4 -2
- package/dist/esm/tds-header-title.entry.js +1 -1
- package/dist/esm/tds-header.entry.js +18 -2
- package/dist/esm/tds-icon.entry.js +5 -3
- package/dist/esm/tds-inline-tab.entry.js +2 -2
- package/dist/esm/tds-inline-tabs.entry.js +1 -7
- package/dist/esm/tds-link.entry.js +4 -4
- package/dist/esm/tds-message.entry.js +4 -4
- package/dist/esm/tds-modal.entry.js +2 -2
- package/dist/esm/tds-navigation-tab.entry.js +2 -2
- package/dist/esm/tds-navigation-tabs.entry.js +1 -4
- package/dist/esm/tds-popover-canvas.entry.js +2 -2
- package/dist/esm/tds-popover-core.entry.js +1 -1
- package/dist/esm/tds-popover-menu-item.entry.js +1 -1
- package/dist/esm/tds-popover-menu.entry.js +2 -2
- package/dist/esm/tds-radio-button.entry.js +2 -2
- package/dist/esm/tds-side-menu-close-button.entry.js +3 -2
- package/dist/esm/tds-side-menu-collapse-button.entry.js +1 -1
- package/dist/esm/tds-side-menu-dropdown-list-item.entry.js +1 -1
- package/dist/esm/tds-side-menu-dropdown-list.entry.js +1 -1
- package/dist/esm/tds-side-menu-dropdown.entry.js +1 -1
- package/dist/esm/tds-side-menu-item.entry.js +2 -2
- package/dist/esm/tds-side-menu-overlay.entry.js +1 -1
- package/dist/esm/tds-side-menu-user-image_2.entry.js +1 -1
- package/dist/esm/tds-side-menu-user.entry.js +1 -1
- package/dist/esm/tds-side-menu.entry.js +1 -1
- package/dist/esm/tds-slider.entry.js +14 -8
- package/dist/esm/tds-spinner.entry.js +1 -1
- package/dist/esm/tds-step.entry.js +1 -1
- package/dist/esm/tds-stepper.entry.js +2 -2
- package/dist/esm/tds-table-body-row-expandable.entry.js +1 -1
- package/dist/esm/tds-table-body-row.entry.js +1 -1
- package/dist/esm/tds-table-body.entry.js +1 -1
- package/dist/esm/tds-table-footer.entry.js +2 -2
- package/dist/esm/tds-table-header.entry.js +1 -1
- package/dist/esm/tds-table-toolbar.entry.js +1 -1
- package/dist/esm/tds-table.entry.js +2 -2
- package/dist/esm/tds-text-field.entry.js +14 -14
- package/dist/esm/tds-textarea.entry.js +11 -11
- package/dist/esm/tds-toast.entry.js +5 -4
- package/dist/esm/tds-toggle.entry.js +2 -2
- package/dist/esm/tds-tooltip.entry.js +2 -2
- package/dist/esm/tegel.js +4 -4
- package/dist/tegel/p-098a26f3.js +1 -0
- package/dist/tegel/{p-bd823881.entry.js → p-0a8ee1f9.entry.js} +1 -1
- package/dist/tegel/p-0c4fbe10.entry.js +1 -0
- package/dist/tegel/p-0edeccb6.js +1 -0
- package/dist/tegel/p-0f8f9398.entry.js +1 -0
- package/dist/tegel/p-1168e527.entry.js +1 -0
- package/dist/tegel/{p-52edb8b7.entry.js → p-15230250.entry.js} +1 -1
- package/dist/tegel/{p-514610b9.entry.js → p-17d0b13e.entry.js} +1 -1
- package/dist/tegel/{p-888fec9e.entry.js → p-22f15794.entry.js} +1 -1
- package/dist/tegel/{p-37b1329c.entry.js → p-235cda64.entry.js} +1 -1
- package/dist/tegel/{p-54ebce22.entry.js → p-23822382.entry.js} +1 -1
- package/dist/tegel/p-26e5d00c.entry.js +1 -0
- package/dist/tegel/p-2727d592.entry.js +1 -0
- package/dist/tegel/{p-9af2e8ab.entry.js → p-289a487d.entry.js} +1 -1
- package/dist/tegel/p-2955b397.entry.js +1 -0
- package/dist/tegel/{p-f2819741.entry.js → p-2ab8970f.entry.js} +1 -1
- package/dist/tegel/{p-5663c320.entry.js → p-30743f62.entry.js} +1 -1
- package/dist/tegel/p-3079490b.entry.js +1 -0
- package/dist/tegel/{p-446ab609.entry.js → p-30c571d4.entry.js} +1 -1
- package/dist/tegel/{p-286691df.entry.js → p-32c133ba.entry.js} +1 -1
- package/dist/tegel/p-35265b56.entry.js +1 -0
- package/dist/tegel/p-363ee512.entry.js +1 -0
- package/dist/tegel/{p-0d573de8.entry.js → p-3ad7d61d.entry.js} +1 -1
- package/dist/tegel/{p-d8215514.entry.js → p-3b39140f.entry.js} +1 -1
- package/dist/tegel/{p-0eac159c.entry.js → p-3cd5821f.entry.js} +1 -1
- package/dist/tegel/{p-073cf6c0.entry.js → p-44a3b63b.entry.js} +1 -1
- package/dist/tegel/p-4a02a38f.entry.js +1 -0
- package/dist/tegel/{p-824f5dad.entry.js → p-4af50429.entry.js} +1 -1
- package/dist/tegel/{p-62732059.entry.js → p-4bca96e5.entry.js} +1 -1
- package/dist/tegel/p-4df1ed46.entry.js +1 -0
- package/dist/tegel/{p-166d6252.entry.js → p-50ea7ad8.entry.js} +1 -1
- package/dist/tegel/{p-0d886890.entry.js → p-52719efc.entry.js} +1 -1
- package/dist/tegel/{p-d1be74e7.entry.js → p-555e1263.entry.js} +1 -1
- package/dist/tegel/p-57156832.entry.js +1 -0
- package/dist/tegel/{p-f6ff8d7e.entry.js → p-595c3a77.entry.js} +1 -1
- package/dist/tegel/{p-2782cab8.entry.js → p-5a6efad0.entry.js} +1 -1
- package/dist/tegel/{p-fc88f7ba.entry.js → p-5b9115c3.entry.js} +1 -1
- package/dist/tegel/{p-8b634b36.entry.js → p-72bbf0af.entry.js} +1 -1
- package/dist/tegel/{p-d289a792.entry.js → p-74644ab7.entry.js} +1 -1
- package/dist/tegel/{p-94c27eb3.entry.js → p-762357bb.entry.js} +1 -1
- package/dist/tegel/{p-cbb227b3.entry.js → p-7b0dabcb.entry.js} +1 -1
- package/dist/tegel/p-7e0ec688.entry.js +1 -0
- package/dist/tegel/p-81039661.js +1 -0
- package/dist/tegel/p-86f542a6.js +1 -0
- package/dist/tegel/{p-a72409fc.entry.js → p-8ad9d997.entry.js} +1 -1
- package/dist/tegel/{p-f712146b.entry.js → p-90597e3c.entry.js} +1 -1
- package/dist/tegel/p-931a6b29.entry.js +1 -0
- package/dist/tegel/{p-5b58d6c9.entry.js → p-950ad7d7.entry.js} +1 -1
- package/dist/tegel/{p-495d2b37.entry.js → p-970da069.entry.js} +1 -1
- package/dist/tegel/{p-26757a32.entry.js → p-9920be66.entry.js} +1 -1
- package/dist/tegel/{p-c1ed83c6.entry.js → p-9bc33f53.entry.js} +1 -1
- package/dist/tegel/{p-364654b5.entry.js → p-a0a1840f.entry.js} +1 -1
- package/dist/tegel/{p-026a3e05.entry.js → p-a3123355.entry.js} +1 -1
- package/dist/tegel/{p-d1289eb3.entry.js → p-a3440291.entry.js} +1 -1
- package/dist/tegel/{p-ae2c6537.entry.js → p-a7a12627.entry.js} +1 -1
- package/dist/tegel/{p-7bbae944.entry.js → p-a9df694d.entry.js} +1 -1
- package/dist/tegel/{p-9c6e8abb.entry.js → p-ac253317.entry.js} +1 -1
- package/dist/tegel/{p-38c68fac.entry.js → p-ac8585f9.entry.js} +1 -1
- package/dist/tegel/{p-301110a1.entry.js → p-adca7314.entry.js} +1 -1
- package/dist/tegel/p-adf21f07.entry.js +1 -0
- package/dist/tegel/p-ae110fc2.js +1 -0
- package/dist/tegel/{p-b0a5cef2.entry.js → p-b1e3feda.entry.js} +1 -1
- package/dist/tegel/{p-62154528.entry.js → p-c1b19d10.entry.js} +1 -1
- package/dist/tegel/{p-045e99f2.entry.js → p-c46dad72.entry.js} +1 -1
- package/dist/tegel/{p-77282750.entry.js → p-cb3ba5d0.entry.js} +1 -1
- package/dist/tegel/p-cc0ea750.entry.js +1 -0
- package/dist/tegel/p-cc2a998f.entry.js +1 -0
- package/dist/tegel/p-cc771b46.entry.js +1 -0
- package/dist/tegel/{p-386c3c42.entry.js → p-d98cf434.entry.js} +1 -1
- package/dist/tegel/{p-acabb656.entry.js → p-da386849.entry.js} +1 -1
- package/dist/tegel/p-df2c8c5b.entry.js +1 -0
- package/dist/tegel/{p-dfeaa580.entry.js → p-df7f3773.entry.js} +1 -1
- package/dist/tegel/{p-78a367c0.entry.js → p-e122947b.entry.js} +1 -1
- package/dist/tegel/p-e179315a.entry.js +1 -0
- package/dist/tegel/p-e74f77c4.entry.js +1 -0
- package/dist/tegel/{p-34e75630.entry.js → p-edc8b0b0.entry.js} +1 -1
- package/dist/tegel/p-effd0764.entry.js +1 -0
- package/dist/tegel/{p-c9c5b832.entry.js → p-f375707c.entry.js} +1 -1
- package/dist/tegel/{p-ef96df10.entry.js → p-f6ca4367.entry.js} +1 -1
- package/dist/tegel/p-f71c9fe3.entry.js +1 -0
- package/dist/tegel/p-f7ce52e9.js +1 -0
- package/dist/tegel/{p-974ee937.entry.js → p-f84d4394.entry.js} +1 -1
- package/dist/tegel/{p-eeedd806.entry.js → p-f9c37154.entry.js} +1 -1
- package/dist/tegel/p-ff07dea0.entry.js +1 -0
- package/dist/tegel/tegel.css +2 -4
- package/dist/tegel/tegel.esm.js +1 -1
- package/dist/types/components/banner/banner.d.ts +0 -5
- package/dist/types/components/block/block.d.ts +1 -1
- package/dist/types/components/dropdown/dropdown.d.ts +29 -11
- package/dist/types/components/icon/icon.d.ts +2 -0
- package/dist/types/components/popover-canvas/popover-canvas.d.ts +1 -1
- package/dist/types/components/popover-menu/popover-menu.d.ts +1 -1
- package/dist/types/components/slider/slider.d.ts +1 -1
- package/dist/types/components/table/table-component-filtering.stories.d.ts +0 -8
- package/dist/types/components/table/table-component-multiselect.stories.d.ts +0 -1
- package/dist/types/components/text-field/text-field.d.ts +1 -1
- package/dist/types/components/tooltip/tooltip.d.ts +1 -1
- package/dist/types/components.d.ts +69 -66
- package/dist/types/global.d.ts +2 -2
- package/dist/types/stencil-public-runtime.d.ts +3 -3
- package/dist/types/stories/formatHtmlPreview.d.ts +2 -0
- package/dist/types/stories/foundations/color/color-semantic.stories.d.ts +1 -1
- package/dist/types/types/Attributes.d.ts +3 -0
- package/dist/types/utils/appendHiddenInput.d.ts +15 -0
- package/dist/types/utils/dfs.d.ts +10 -0
- package/dist/types/utils/findNextFocusableElement.d.ts +7 -0
- package/dist/types/utils/findPreviousFocusableElement.d.ts +8 -0
- package/dist/types/utils/generateUniqueId.d.ts +15 -0
- package/dist/types/utils/getNestedChildOfSiblingsMatching.d.ts +2 -0
- package/dist/types/utils/getNextNestedChildOfSiblingsMatching.d.ts +30 -0
- package/dist/types/utils/getNextSibling.d.ts +2 -0
- package/dist/types/utils/getPreviousNestedChildOfSiblingsMatching.d.ts +30 -0
- package/dist/types/utils/getPreviousSibling.d.ts +2 -0
- package/dist/types/utils/hasSlot.d.ts +8 -0
- package/dist/types/utils/inheritAriaAttributes.d.ts +9 -0
- package/dist/types/utils/inheritAttributes.d.ts +13 -0
- package/dist/types/utils/isHeadingElement.d.ts +8 -0
- package/dist/types/utils/updateListChildrenRoles.d.ts +6 -0
- package/package.json +81 -80
- package/dist/cjs/utils-23ce2e45.js +0 -501
- package/dist/collection/utils/utils.js +0 -369
- package/dist/collection/utils/utils.spec.js +0 -15
- package/dist/components/utils.js +0 -489
- package/dist/esm/utils-4d967376.js +0 -489
- package/dist/tegel/p-1af982bc.entry.js +0 -1
- package/dist/tegel/p-24fc848d.entry.js +0 -1
- package/dist/tegel/p-271d0081.entry.js +0 -1
- package/dist/tegel/p-3c5acada.entry.js +0 -1
- package/dist/tegel/p-461e81bd.entry.js +0 -1
- package/dist/tegel/p-4e676ba1.entry.js +0 -1
- package/dist/tegel/p-52b727a7.entry.js +0 -1
- package/dist/tegel/p-5e6318d2.entry.js +0 -1
- package/dist/tegel/p-6e1c6b71.entry.js +0 -1
- package/dist/tegel/p-7125dad7.entry.js +0 -1
- package/dist/tegel/p-8a502e4f.entry.js +0 -1
- package/dist/tegel/p-8a6dac22.entry.js +0 -1
- package/dist/tegel/p-8faaaaf3.entry.js +0 -1
- package/dist/tegel/p-8fea52fe.js +0 -43
- package/dist/tegel/p-98d31b74.entry.js +0 -1
- package/dist/tegel/p-9b560c6d.entry.js +0 -1
- package/dist/tegel/p-aeff41d5.entry.js +0 -1
- package/dist/tegel/p-c65429b4.entry.js +0 -1
- package/dist/tegel/p-ca8b8a16.entry.js +0 -1
- package/dist/tegel/p-cf75e7c1.entry.js +0 -1
- package/dist/tegel/p-d4aa3315.entry.js +0 -1
- package/dist/tegel/p-d852143b.entry.js +0 -1
- package/dist/tegel/p-ec6afc7b.entry.js +0 -1
- package/dist/tegel/p-f147d270.entry.js +0 -1
- package/dist/tegel/p-faaa50c2.entry.js +0 -1
- package/dist/types/utils/utils.d.ts +0 -164
- /package/dist/tegel/{p-43fe6507.js → p-31561847.js} +0 -0
package/README.md
CHANGED
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
[](https://www.npmjs.com/package/@scania/tegel)
|
|
2
|
-
[](https://tegel-storybook.netlify.app/)
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# @scania/tegel
|
|
10
|
-
|
|
11
|
-
Official website: https://tegel.scania.com/
|
|
12
|
-
|
|
13
|
-
Storybook: https://tegel-storybook.netlify.app/
|
|
14
|
-
|
|
15
|
-
The design system supports the design and development of digital solutions at Scania. The purpose is to secure a coherent, premium brand and user experience across all of Scania's digital touchpoints.
|
|
16
|
-
|
|
17
|
-
## Status
|
|
18
|
-
|
|
19
|
-
This package is currently in a
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
### React
|
|
24
|
-
|
|
25
|
-
#### with Typescript
|
|
26
|
-
|
|
27
|
-
1. Run `npm install @scania/tegel`
|
|
28
|
-
2. src folder create a file called `register-webcomponents.ts`
|
|
29
|
-
3. Paste the following into that file:
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
import { defineCustomElements, JSX as LocalJSX } from '@scania/tegel/loader';
|
|
33
|
-
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
34
|
-
|
|
35
|
-
type StencilProps<T> = {
|
|
36
|
-
[P in keyof T]?: Omit<T[P], 'ref'> | HTMLAttributes<T>;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
type ReactProps<T> = {
|
|
40
|
-
[P in keyof T]?: DetailedHTMLProps<HTMLAttributes<T[P]>, T[P]>;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type StencilToReact<T = LocalJSX.IntrinsicElements, U = HTMLElementTagNameMap> = StencilProps<T> &
|
|
44
|
-
ReactProps<U>;
|
|
45
|
-
|
|
46
|
-
declare global {
|
|
47
|
-
export namespace JSX {
|
|
48
|
-
interface IntrinsicElements extends StencilToReact {}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
defineCustomElements(window);
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
4. In your index.tsx import `register-webcomponents.ts`
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
import React from 'react';
|
|
59
|
-
import ReactDOM from 'react-dom/client';
|
|
60
|
-
import './index.css';
|
|
61
|
-
import App from './App';
|
|
62
|
-
import reportWebVitals from './reportWebVitals';
|
|
63
|
-
import './register-webcomponents';
|
|
64
|
-
|
|
65
|
-
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
|
66
|
-
root.render(
|
|
67
|
-
<React.StrictMode>
|
|
68
|
-
<App />
|
|
69
|
-
</React.StrictMode>,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
reportWebVitals();
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
5. In your global css file (usually `App.css`) import the tegel stylesheet.
|
|
76
|
-
|
|
77
|
-
```css
|
|
78
|
-
@import url('@scania/tegel/dist/tegel/tegel.css');
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
#### with Javascript
|
|
82
|
-
|
|
83
|
-
1. Run `npm install @scania/tegel`
|
|
84
|
-
2. In your index.jsx define the custom components:
|
|
85
|
-
|
|
86
|
-
```jsx
|
|
87
|
-
import React from 'react';
|
|
88
|
-
import ReactDOM from 'react-dom/client';
|
|
89
|
-
import './index.css';
|
|
90
|
-
import App from './App';
|
|
91
|
-
import reportWebVitals from './reportWebVitals';
|
|
92
|
-
import { defineCustomElements } from '@scania/tegel/loader';
|
|
93
|
-
|
|
94
|
-
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
95
|
-
root.render(
|
|
96
|
-
<React.StrictMode>
|
|
97
|
-
<App />
|
|
98
|
-
</React.StrictMode>,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
reportWebVitals();
|
|
102
|
-
defineCustomElements();
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
3. In your global css file (usually `App.css`) import the tegel stylesheet.
|
|
106
|
-
|
|
107
|
-
```css
|
|
108
|
-
@import url('@scania/tegel/dist/tegel/tegel.css');
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Angular
|
|
112
|
-
|
|
113
|
-
1. Run `npm install @scania/tegel`
|
|
114
|
-
2. In your `main.ts` import and call the function `defineCustomElements()`:
|
|
115
|
-
|
|
116
|
-
```ts
|
|
117
|
-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
118
|
-
import { defineCustomElements } from '@scania/tegel/loader';
|
|
119
|
-
import { AppModule } from './app/app.module';
|
|
120
|
-
|
|
121
|
-
platformBrowserDynamic()
|
|
122
|
-
.bootstrapModule(AppModule)
|
|
123
|
-
.catch((err) => console.error(err));
|
|
124
|
-
|
|
125
|
-
defineCustomElements(window);
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
3. In your `app.module.ts` import `CUSTOM_ELEMENTS_SCHEMA`:
|
|
129
|
-
|
|
130
|
-
```ts
|
|
131
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
132
|
-
import { AppComponent } from './app.component';
|
|
133
|
-
|
|
134
|
-
@NgModule({
|
|
135
|
-
declarations: [AppComponent],
|
|
136
|
-
imports: [BrowserModule],
|
|
137
|
-
providers: [],
|
|
138
|
-
bootstrap: [AppComponent],
|
|
139
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
140
|
-
})
|
|
141
|
-
export class AppModule {}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
4. In your global css file (`styles.css`) import the tegel stylesheet.
|
|
145
|
-
|
|
146
|
-
```css
|
|
147
|
-
@import url('@scania/tegel/dist/tegel/tegel.css');
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### HTML
|
|
151
|
-
|
|
152
|
-
1. Run `npm init` to generate a package.json
|
|
153
|
-
2. Run `npm install @scania/tegel`
|
|
154
|
-
3. Import the package and its style in your `<head>`:
|
|
155
|
-
|
|
156
|
-
```html
|
|
157
|
-
<script type="module">
|
|
158
|
-
import { defineCustomElements } from './node_modules/@scania/tegel/loader/index.es2017.js';
|
|
159
|
-
defineCustomElements();
|
|
160
|
-
</script>
|
|
161
|
-
<link rel="stylesheet" href="./node_modules/@scania/tegel/dist/tegel/tegel.css" />
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
See all available components in the [Tegel Design System](https://tegel.scania.com/components/overview).
|
|
165
|
-
|
|
166
|
-
## Browser support
|
|
167
|
-
|
|
168
|
-
See the browser support section on [the Tegel website](https://tegel.scania.com/development/getting-started-development/introduction#browser-support).
|
|
169
|
-
|
|
170
|
-
## Community
|
|
171
|
-
|
|
172
|
-
Get in touch with the team and the community:
|
|
173
|
-
|
|
174
|
-
- [Teams](https://teams.microsoft.com/l/team/19%3a1257007a64d44c64954acca27a9d4b46%40thread.skype/conversations?groupId=79f9bfeb-73e2-424d-9477-b236191ece5e&tenantId=3bc062e4-ac9d-4c17-b4dd-3aad637ff1ac)
|
|
175
|
-
|
|
176
|
-
## License
|
|
177
|
-
|
|
178
|
-
All CSS, HTML and JS code are available under the MIT license. The Scania brand identity, logos and photographs found in this repository are copyrighted Scania CV AB and are not available on an open source basis or to be used as examples or in any other way, if not specifically ordered by Scania CV AB.
|
|
1
|
+
[](https://www.npmjs.com/package/@scania/tegel)
|
|
2
|
+
[](https://tegel-storybook.netlify.app/)
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# @scania/tegel
|
|
10
|
+
|
|
11
|
+
Official website: https://tegel.scania.com/
|
|
12
|
+
|
|
13
|
+
Storybook: https://tegel-storybook.netlify.app/
|
|
14
|
+
|
|
15
|
+
The design system supports the design and development of digital solutions at Scania. The purpose is to secure a coherent, premium brand and user experience across all of Scania's digital touchpoints.
|
|
16
|
+
|
|
17
|
+
## Status
|
|
18
|
+
|
|
19
|
+
This package is currently in a **beta** stage. We are now working hard towards a 1.0 release, but if you want to try out the package today you can!
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### React
|
|
24
|
+
|
|
25
|
+
#### with Typescript
|
|
26
|
+
|
|
27
|
+
1. Run `npm install @scania/tegel`
|
|
28
|
+
2. src folder create a file called `register-webcomponents.ts`
|
|
29
|
+
3. Paste the following into that file:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { defineCustomElements, JSX as LocalJSX } from '@scania/tegel/loader';
|
|
33
|
+
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
34
|
+
|
|
35
|
+
type StencilProps<T> = {
|
|
36
|
+
[P in keyof T]?: Omit<T[P], 'ref'> | HTMLAttributes<T>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type ReactProps<T> = {
|
|
40
|
+
[P in keyof T]?: DetailedHTMLProps<HTMLAttributes<T[P]>, T[P]>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type StencilToReact<T = LocalJSX.IntrinsicElements, U = HTMLElementTagNameMap> = StencilProps<T> &
|
|
44
|
+
ReactProps<U>;
|
|
45
|
+
|
|
46
|
+
declare global {
|
|
47
|
+
export namespace JSX {
|
|
48
|
+
interface IntrinsicElements extends StencilToReact {}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
defineCustomElements(window);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
4. In your index.tsx import `register-webcomponents.ts`
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import React from 'react';
|
|
59
|
+
import ReactDOM from 'react-dom/client';
|
|
60
|
+
import './index.css';
|
|
61
|
+
import App from './App';
|
|
62
|
+
import reportWebVitals from './reportWebVitals';
|
|
63
|
+
import './register-webcomponents';
|
|
64
|
+
|
|
65
|
+
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
|
66
|
+
root.render(
|
|
67
|
+
<React.StrictMode>
|
|
68
|
+
<App />
|
|
69
|
+
</React.StrictMode>,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
reportWebVitals();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
5. In your global css file (usually `App.css`) import the tegel stylesheet.
|
|
76
|
+
|
|
77
|
+
```css
|
|
78
|
+
@import url('@scania/tegel/dist/tegel/tegel.css');
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### with Javascript
|
|
82
|
+
|
|
83
|
+
1. Run `npm install @scania/tegel`
|
|
84
|
+
2. In your index.jsx define the custom components:
|
|
85
|
+
|
|
86
|
+
```jsx
|
|
87
|
+
import React from 'react';
|
|
88
|
+
import ReactDOM from 'react-dom/client';
|
|
89
|
+
import './index.css';
|
|
90
|
+
import App from './App';
|
|
91
|
+
import reportWebVitals from './reportWebVitals';
|
|
92
|
+
import { defineCustomElements } from '@scania/tegel/loader';
|
|
93
|
+
|
|
94
|
+
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
95
|
+
root.render(
|
|
96
|
+
<React.StrictMode>
|
|
97
|
+
<App />
|
|
98
|
+
</React.StrictMode>,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
reportWebVitals();
|
|
102
|
+
defineCustomElements();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
3. In your global css file (usually `App.css`) import the tegel stylesheet.
|
|
106
|
+
|
|
107
|
+
```css
|
|
108
|
+
@import url('@scania/tegel/dist/tegel/tegel.css');
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Angular
|
|
112
|
+
|
|
113
|
+
1. Run `npm install @scania/tegel`
|
|
114
|
+
2. In your `main.ts` import and call the function `defineCustomElements()`:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
118
|
+
import { defineCustomElements } from '@scania/tegel/loader';
|
|
119
|
+
import { AppModule } from './app/app.module';
|
|
120
|
+
|
|
121
|
+
platformBrowserDynamic()
|
|
122
|
+
.bootstrapModule(AppModule)
|
|
123
|
+
.catch((err) => console.error(err));
|
|
124
|
+
|
|
125
|
+
defineCustomElements(window);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
3. In your `app.module.ts` import `CUSTOM_ELEMENTS_SCHEMA`:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
132
|
+
import { AppComponent } from './app.component';
|
|
133
|
+
|
|
134
|
+
@NgModule({
|
|
135
|
+
declarations: [AppComponent],
|
|
136
|
+
imports: [BrowserModule],
|
|
137
|
+
providers: [],
|
|
138
|
+
bootstrap: [AppComponent],
|
|
139
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
140
|
+
})
|
|
141
|
+
export class AppModule {}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
4. In your global css file (`styles.css`) import the tegel stylesheet.
|
|
145
|
+
|
|
146
|
+
```css
|
|
147
|
+
@import url('@scania/tegel/dist/tegel/tegel.css');
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### HTML
|
|
151
|
+
|
|
152
|
+
1. Run `npm init` to generate a package.json
|
|
153
|
+
2. Run `npm install @scania/tegel`
|
|
154
|
+
3. Import the package and its style in your `<head>`:
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
<script type="module">
|
|
158
|
+
import { defineCustomElements } from './node_modules/@scania/tegel/loader/index.es2017.js';
|
|
159
|
+
defineCustomElements();
|
|
160
|
+
</script>
|
|
161
|
+
<link rel="stylesheet" href="./node_modules/@scania/tegel/dist/tegel/tegel.css" />
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
See all available components in the [Tegel Design System](https://tegel.scania.com/components/overview).
|
|
165
|
+
|
|
166
|
+
## Browser support
|
|
167
|
+
|
|
168
|
+
See the browser support section on [the Tegel website](https://tegel.scania.com/development/getting-started-development/introduction#browser-support).
|
|
169
|
+
|
|
170
|
+
## Community
|
|
171
|
+
|
|
172
|
+
Get in touch with the team and the community:
|
|
173
|
+
|
|
174
|
+
- [Teams](https://teams.microsoft.com/l/team/19%3a1257007a64d44c64954acca27a9d4b46%40thread.skype/conversations?groupId=79f9bfeb-73e2-424d-9477-b236191ece5e&tenantId=3bc062e4-ac9d-4c17-b4dd-3aad637ff1ac)
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
All CSS, HTML and JS code are available under the MIT license. The Scania brand identity, logos and photographs found in this repository are copyrighted Scania CV AB and are not available on an open source basis or to be used as examples or in any other way, if not specifically ordered by Scania CV AB.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Recursively finds the first matching element or child based on a provided condition.
|
|
5
|
+
*
|
|
6
|
+
* @param {ParentNode} parentNode - The starting element or shadow root to search from.
|
|
7
|
+
* @param {(el: HTMLElement) => boolean} searchPredicate - The condition to match the element, receives an HTMLElement and returns a boolean.
|
|
8
|
+
* @param {boolean} [pierceShadow=false] - Whether to pierce through shadow DOM boundaries.
|
|
9
|
+
* @returns {HTMLElement | null} - The first matching element or child, or null if none is found.
|
|
10
|
+
*/
|
|
11
|
+
function dfs(parentNode, searchPredicate, pierceShadow = false) {
|
|
12
|
+
if (parentNode instanceof HTMLElement && searchPredicate(parentNode)) {
|
|
13
|
+
return parentNode;
|
|
14
|
+
}
|
|
15
|
+
const childElements = parentNode instanceof HTMLSlotElement
|
|
16
|
+
? parentNode.assignedElements({ flatten: true })
|
|
17
|
+
: Array.from(parentNode.children);
|
|
18
|
+
if (pierceShadow && parentNode instanceof HTMLElement && parentNode.shadowRoot) {
|
|
19
|
+
childElements.push(...Array.from(parentNode.shadowRoot.children));
|
|
20
|
+
}
|
|
21
|
+
let foundElement = null;
|
|
22
|
+
childElements.some((child) => {
|
|
23
|
+
foundElement = dfs(child, searchPredicate, pierceShadow);
|
|
24
|
+
return foundElement !== null;
|
|
25
|
+
});
|
|
26
|
+
return foundElement;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.dfs = dfs;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generates a reasonably unique string ID based on current time (minutes, seconds, milliseconds) and random numbers.
|
|
5
|
+
*
|
|
6
|
+
* This function combines the current time and random numbers to generate
|
|
7
|
+
* a unique string ID. The function assumes that it won't be called frequently
|
|
8
|
+
* enough to generate two identical IDs within a millisecond, or that the random
|
|
9
|
+
* number generator will produce the same value twice in quick succession.
|
|
10
|
+
*
|
|
11
|
+
* Note: The IDs generated by this function are not globally unique and their length may vary.
|
|
12
|
+
* For truly unique and fixed-length IDs, consider using a more robust method such as UUID.
|
|
13
|
+
*
|
|
14
|
+
* @returns {string} A unique string ID.
|
|
15
|
+
*/
|
|
16
|
+
function generateUniqueId() {
|
|
17
|
+
const now = new Date();
|
|
18
|
+
const timeInMilliseconds = now.getMinutes() * 60000 + now.getSeconds() * 1000 + now.getMilliseconds(); // Get current time in milliseconds from the start of the hour
|
|
19
|
+
const randomNum1 = Math.floor(Math.random() * 1000000); // Random number between 0 and 999999
|
|
20
|
+
const randomNum2 = Math.floor(Math.random() * 1000000); // Another random number
|
|
21
|
+
// Convert to base 36 (using numbers and letters) and remove '0.' from the random number
|
|
22
|
+
const uniqueString = randomNum1.toString(36).substring(2) +
|
|
23
|
+
timeInMilliseconds.toString(36) +
|
|
24
|
+
randomNum2.toString(36).substring(2);
|
|
25
|
+
return uniqueString;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.generateUniqueId = generateUniqueId;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the provided element has a slotted element
|
|
5
|
+
* in the slot with the corresponding slotName
|
|
6
|
+
* @param slotName the name of the slot.
|
|
7
|
+
* @param element the element to look for the slot within.
|
|
8
|
+
*/
|
|
9
|
+
const hasSlot = (slotName, element) => !!element.querySelector(`[slot="${slotName}"]`);
|
|
10
|
+
|
|
11
|
+
exports.hasSlot = hasSlot;
|
|
@@ -133,13 +133,13 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
133
133
|
};
|
|
134
134
|
walk(children);
|
|
135
135
|
if (vnodeData) {
|
|
136
|
-
// normalize class / classname attributes
|
|
137
136
|
if (vnodeData.key) {
|
|
138
137
|
key = vnodeData.key;
|
|
139
138
|
}
|
|
140
139
|
if (vnodeData.name) {
|
|
141
140
|
slotName = vnodeData.name;
|
|
142
141
|
}
|
|
142
|
+
// normalize class / className attributes
|
|
143
143
|
{
|
|
144
144
|
const classData = vnodeData.className || vnodeData.class;
|
|
145
145
|
if (classData) {
|
|
@@ -1396,7 +1396,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
1396
1396
|
// has a different next sibling or parent relocated
|
|
1397
1397
|
if (nodeToRelocate !== insertBeforeNode) {
|
|
1398
1398
|
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
1399
|
-
// probably a component in the index.html that doesn't have
|
|
1399
|
+
// probably a component in the index.html that doesn't have its hostname set
|
|
1400
1400
|
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
1401
1401
|
}
|
|
1402
1402
|
// add it back to the dom but in its new home
|
|
@@ -1788,12 +1788,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1788
1788
|
// customElements.define('my-component', MyComponent);
|
|
1789
1789
|
// </script>
|
|
1790
1790
|
// ```
|
|
1791
|
-
// In this case if we do not
|
|
1791
|
+
// In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
|
|
1792
1792
|
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
|
1793
1793
|
// to the value that was set inline i.e. "some-value" from above example. When
|
|
1794
|
-
// the connectedCallback attempts to
|
|
1794
|
+
// the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
|
|
1795
1795
|
//
|
|
1796
|
-
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/
|
|
1796
|
+
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
|
|
1797
1797
|
// by connectedCallback as this attributeChangedCallback will not fire.
|
|
1798
1798
|
//
|
|
1799
1799
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const inheritAttributes = require('./inheritAttributes-845f5217.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* List of available ARIA attributes + `role`.
|
|
7
|
+
* Removed deprecated attributes.
|
|
8
|
+
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes
|
|
9
|
+
*/
|
|
10
|
+
const ariaAttributes = [
|
|
11
|
+
'role',
|
|
12
|
+
'aria-activedescendant',
|
|
13
|
+
'aria-atomic',
|
|
14
|
+
'aria-autocomplete',
|
|
15
|
+
'aria-braillelabel',
|
|
16
|
+
'aria-brailleroledescription',
|
|
17
|
+
'aria-busy',
|
|
18
|
+
'aria-checked',
|
|
19
|
+
'aria-colcount',
|
|
20
|
+
'aria-colindex',
|
|
21
|
+
'aria-colindextext',
|
|
22
|
+
'aria-colspan',
|
|
23
|
+
'aria-controls',
|
|
24
|
+
'aria-current',
|
|
25
|
+
'aria-describedby',
|
|
26
|
+
'aria-description',
|
|
27
|
+
'aria-details',
|
|
28
|
+
'aria-disabled',
|
|
29
|
+
'aria-errormessage',
|
|
30
|
+
'aria-expanded',
|
|
31
|
+
'aria-flowto',
|
|
32
|
+
'aria-haspopup',
|
|
33
|
+
'aria-hidden',
|
|
34
|
+
'aria-invalid',
|
|
35
|
+
'aria-keyshortcuts',
|
|
36
|
+
'aria-label',
|
|
37
|
+
'aria-labelledby',
|
|
38
|
+
'aria-level',
|
|
39
|
+
'aria-live',
|
|
40
|
+
'aria-multiline',
|
|
41
|
+
'aria-multiselectable',
|
|
42
|
+
'aria-orientation',
|
|
43
|
+
'aria-owns',
|
|
44
|
+
'aria-placeholder',
|
|
45
|
+
'aria-posinset',
|
|
46
|
+
'aria-pressed',
|
|
47
|
+
'aria-readonly',
|
|
48
|
+
'aria-relevant',
|
|
49
|
+
'aria-required',
|
|
50
|
+
'aria-roledescription',
|
|
51
|
+
'aria-rowcount',
|
|
52
|
+
'aria-rowindex',
|
|
53
|
+
'aria-rowindextext',
|
|
54
|
+
'aria-rowspan',
|
|
55
|
+
'aria-selected',
|
|
56
|
+
'aria-setsize',
|
|
57
|
+
'aria-sort',
|
|
58
|
+
'aria-valuemax',
|
|
59
|
+
'aria-valuemin',
|
|
60
|
+
'aria-valuenow',
|
|
61
|
+
'aria-valuetext',
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* Returns an array of aria attributes that should be copied from
|
|
65
|
+
* the shadow host element to a target within the light DOM.
|
|
66
|
+
* @param el The element that the attributes should be copied from.
|
|
67
|
+
* @param ignoreList The list of aria-attributes to ignore reflecting and removing from the host.
|
|
68
|
+
* Use this in instances where we manually specify aria attributes on the `<Host>` element.
|
|
69
|
+
*/
|
|
70
|
+
const inheritAriaAttributes = (el, ignoreList) => {
|
|
71
|
+
let attributesToInherit = ariaAttributes;
|
|
72
|
+
if (ignoreList && ignoreList.length > 0) {
|
|
73
|
+
attributesToInherit = attributesToInherit.filter((attr) => !ignoreList.includes(attr));
|
|
74
|
+
}
|
|
75
|
+
return inheritAttributes.inheritAttributes(el, attributesToInherit);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.inheritAriaAttributes = inheritAriaAttributes;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Elements inside of web components sometimes need to inherit global attributes
|
|
5
|
+
* set on the host. For example, the inner input in `ion-input` should inherit
|
|
6
|
+
* the `title` attribute that developers set directly on `ion-input`. This
|
|
7
|
+
* helper function should be called in componentWillLoad and assigned to a variable
|
|
8
|
+
* that is later used in the render function.
|
|
9
|
+
*
|
|
10
|
+
* This does not need to be reactive as changing attributes on the host element
|
|
11
|
+
* does not trigger a re-render.
|
|
12
|
+
*/
|
|
13
|
+
const inheritAttributes = (el, attributes = []) => {
|
|
14
|
+
const attributeObject = {};
|
|
15
|
+
attributes.forEach((attr) => {
|
|
16
|
+
if (el.hasAttribute(attr)) {
|
|
17
|
+
const value = el.getAttribute(attr);
|
|
18
|
+
if (value !== null) {
|
|
19
|
+
attributeObject[attr] = el.getAttribute(attr);
|
|
20
|
+
}
|
|
21
|
+
el.removeAttribute(attr);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return attributeObject;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.inheritAttributes = inheritAttributes;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const dfs = require('./dfs-babd18a6.js');
|
|
4
|
+
|
|
5
|
+
// A higher-order function to find the nested child of siblings matching a predicate,
|
|
6
|
+
// based on a sibling traversal function (getNextSibling or getPreviousSibling).
|
|
7
|
+
function getNestedChildOfSiblingsMatching(element, searchPredicate, siblingTraversalFn) {
|
|
8
|
+
// Start with the sibling of the provided element.
|
|
9
|
+
let sibling = siblingTraversalFn(element);
|
|
10
|
+
// Iterate through the siblings until there are no more siblings.
|
|
11
|
+
while (sibling) {
|
|
12
|
+
// Use the dfs helper function to find the deeply nested child
|
|
13
|
+
// that matches the given criteria within the current sibling.
|
|
14
|
+
const nestedChild = dfs.dfs(sibling, searchPredicate);
|
|
15
|
+
// If a matching deeply nested child is found, return it.
|
|
16
|
+
if (nestedChild) {
|
|
17
|
+
return nestedChild;
|
|
18
|
+
}
|
|
19
|
+
// Move on to the next sibling.
|
|
20
|
+
sibling = siblingTraversalFn(sibling);
|
|
21
|
+
}
|
|
22
|
+
// If no matching deeply nested child is found, return null.
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const getPreviousSibling = (element) => element.previousElementSibling;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Searches for a previous sibling element that has a nested child element matching the provided search predicate.
|
|
30
|
+
* The search starts from the given element and proceeds to its previous siblings, diving deep into each sibling's descendants.
|
|
31
|
+
*
|
|
32
|
+
* @param {HTMLElement} element - The starting element to begin the search from.
|
|
33
|
+
* @param {(el: HTMLElement) => boolean} searchPredicate - A predicate function that checks if an element matches the desired condition.
|
|
34
|
+
* @returns {HTMLElement | null} - The matching nested child element, or null if no matching element is found.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // HTML structure:
|
|
38
|
+
* // <div>
|
|
39
|
+
* // <h1>Heading 1</h1>
|
|
40
|
+
* // <ul role="list">
|
|
41
|
+
* // <li>Item 1</li>
|
|
42
|
+
* // </ul>
|
|
43
|
+
* // </div>
|
|
44
|
+
* // <div>
|
|
45
|
+
* // <h2>Heading 2</h2>
|
|
46
|
+
* // <ul role="list">
|
|
47
|
+
* // <li>Item 2</li>
|
|
48
|
+
* // </ul>
|
|
49
|
+
* // </div>
|
|
50
|
+
*
|
|
51
|
+
* const searchPredicate = (el) => el.tagName.toLowerCase() === 'h2';
|
|
52
|
+
* const startingElement = document.querySelector('[role="list"]');
|
|
53
|
+
* const headingEl = getPreviousNestedChildOfSiblingsMatching(startingElement, searchPredicate);
|
|
54
|
+
* console.log(headingEl); // Logs the <h2>Heading 2</h2> element
|
|
55
|
+
*/
|
|
56
|
+
const getPreviousNestedChildOfSiblingsMatching = (element, searchPredicate) => getNestedChildOfSiblingsMatching(element, searchPredicate, getPreviousSibling);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Checks if the given element is a heading element (h1-h6) or has a role of "heading".
|
|
60
|
+
*
|
|
61
|
+
* @param {HTMLElement} el - The element to check.
|
|
62
|
+
* @returns {boolean} - True if the element is a heading element, false otherwise.
|
|
63
|
+
*/
|
|
64
|
+
const isHeadingElement = (el) => {
|
|
65
|
+
const tagName = el.tagName.toLowerCase();
|
|
66
|
+
const role = el.getAttribute('role');
|
|
67
|
+
return ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tagName) || role === 'heading';
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.getPreviousNestedChildOfSiblingsMatching = getPreviousNestedChildOfSiblingsMatching;
|
|
71
|
+
exports.isHeadingElement = isHeadingElement;
|