@tmorrow/cre8-wc 1.1.2 → 1.1.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/cdn/cre8-wc.esm.js +1 -1
- package/cdn/cre8-wc.esm.js.map +1 -1
- package/cdn/cre8-wc.min.js +1 -1
- package/cdn/cre8-wc.min.js.map +1 -1
- package/lib/cdn-entry.js +129 -0
- package/lib/cdn-entry.js.map +1 -0
- package/lib/components/accordion/accordion.js +58 -40
- package/lib/components/accordion/accordion.js.map +1 -0
- package/lib/components/accordion/accordion.styles.js +4 -0
- package/lib/components/accordion/accordion.styles.js.map +1 -0
- package/lib/components/accordion-item/accordion-item.js +187 -98
- package/lib/components/accordion-item/accordion-item.js.map +1 -0
- package/lib/components/accordion-item/accordion-item.styles.js +4 -0
- package/lib/components/accordion-item/accordion-item.styles.js.map +1 -0
- package/lib/components/alert/alert.js +146 -107
- package/lib/components/alert/alert.js.map +1 -0
- package/lib/components/alert/alert.styles.js +4 -0
- package/lib/components/alert/alert.styles.js.map +1 -0
- package/lib/components/badge/badge.js +73 -50
- package/lib/components/badge/badge.js.map +1 -0
- package/lib/components/badge/badge.styles.js +4 -0
- package/lib/components/badge/badge.styles.js.map +1 -0
- package/lib/components/band/band.js +34 -31
- package/lib/components/band/band.js.map +1 -0
- package/lib/components/band/band.styles.js +4 -0
- package/lib/components/band/band.styles.js.map +1 -0
- package/lib/components/breadcrumbs/breadcrumbs.js +52 -28
- package/lib/components/breadcrumbs/breadcrumbs.js.map +1 -0
- package/lib/components/breadcrumbs/breadcrumbs.styles.js +4 -0
- package/lib/components/breadcrumbs/breadcrumbs.styles.js.map +1 -0
- package/lib/components/breadcrumbs-item/breadcrumbs-item.js +28 -27
- package/lib/components/breadcrumbs-item/breadcrumbs-item.js.map +1 -0
- package/lib/components/breadcrumbs-item/breadcrumbs-item.styles.js +4 -0
- package/lib/components/breadcrumbs-item/breadcrumbs-item.styles.js.map +1 -0
- package/lib/components/button/button.js +297 -1040
- package/lib/components/button/button.js.map +1 -0
- package/lib/components/button/button.styles.js +885 -0
- package/lib/components/button/button.styles.js.map +1 -0
- package/lib/components/button-group/button-group.js +30 -27
- package/lib/components/button-group/button-group.js.map +1 -0
- package/lib/components/button-group/button-group.styles.js +4 -0
- package/lib/components/button-group/button-group.styles.js.map +1 -0
- package/lib/components/card/card.js +57 -35
- package/lib/components/card/card.js.map +1 -0
- package/lib/components/card/card.styles.js +4 -0
- package/lib/components/card/card.styles.js.map +1 -0
- package/lib/components/chart/chart.js +528 -354
- package/lib/components/chart/chart.js.map +1 -0
- package/lib/components/chart/chart.styles.js +4 -0
- package/lib/components/chart/chart.styles.js.map +1 -0
- package/lib/components/checkbox-field/checkbox-field.js +66 -53
- package/lib/components/checkbox-field/checkbox-field.js.map +1 -0
- package/lib/components/checkbox-field/checkbox-field.styles.js +4 -0
- package/lib/components/checkbox-field/checkbox-field.styles.js.map +1 -0
- package/lib/components/checkbox-field-item/checkbox-field-item.js +252 -183
- package/lib/components/checkbox-field-item/checkbox-field-item.js.map +1 -0
- package/lib/components/checkbox-field-item/checkbox-field-item.styles.js +4 -0
- package/lib/components/checkbox-field-item/checkbox-field-item.styles.js.map +1 -0
- package/lib/components/contexts/form-internals-context.js +9 -0
- package/lib/components/contexts/form-internals-context.js.map +1 -0
- package/lib/components/cre8-element.js +57 -56
- package/lib/components/cre8-element.js.map +1 -0
- package/lib/components/cre8-form-element.js +212 -244
- package/lib/components/cre8-form-element.js.map +1 -0
- package/lib/components/danger-button/danger-button.js +274 -147
- package/lib/components/danger-button/danger-button.js.map +1 -0
- package/lib/components/danger-button/danger-button.styles.js +4 -0
- package/lib/components/danger-button/danger-button.styles.js.map +1 -0
- package/lib/components/date-picker/calendar/calendar.js +465 -0
- package/lib/components/date-picker/calendar/calendar.js.map +1 -0
- package/lib/components/date-picker/calendar/calendar.styles.js +4 -0
- package/lib/components/date-picker/calendar/calendar.styles.js.map +1 -0
- package/lib/components/date-picker/calendar-month-modal/calendar-month-modal.js +76 -0
- package/lib/components/date-picker/calendar-month-modal/calendar-month-modal.js.map +1 -0
- package/lib/components/date-picker/calendar-month-modal/calendar-month-modal.styles.js +4 -0
- package/lib/components/date-picker/calendar-month-modal/calendar-month-modal.styles.js.map +1 -0
- package/lib/components/date-picker/calendar-navigation/calendar-navigation.js +110 -0
- package/lib/components/date-picker/calendar-navigation/calendar-navigation.js.map +1 -0
- package/lib/components/date-picker/calendar-navigation/calendar-navigation.styles.js +4 -0
- package/lib/components/date-picker/calendar-navigation/calendar-navigation.styles.js.map +1 -0
- package/lib/components/date-picker/calendar-year-modal/calendar-year-modal.js +116 -0
- package/lib/components/date-picker/calendar-year-modal/calendar-year-modal.js.map +1 -0
- package/lib/components/date-picker/calendar-year-modal/calendar-year-modal.styles.js +4 -0
- package/lib/components/date-picker/calendar-year-modal/calendar-year-modal.styles.js.map +1 -0
- package/lib/components/date-picker/date-picker.js +91 -784
- package/lib/components/date-picker/date-picker.js.map +1 -0
- package/lib/components/date-picker/date-picker.styles.js +4 -0
- package/lib/components/date-picker/date-picker.styles.js.map +1 -0
- package/lib/components/divider/divider.js +45 -35
- package/lib/components/divider/divider.js.map +1 -0
- package/lib/components/divider/divider.styles.js +4 -0
- package/lib/components/divider/divider.styles.js.map +1 -0
- package/lib/components/dropdown/dropdown.js +97 -63
- package/lib/components/dropdown/dropdown.js.map +1 -0
- package/lib/components/dropdown/dropdown.styles.js +4 -0
- package/lib/components/dropdown/dropdown.styles.js.map +1 -0
- package/lib/components/dropdown-item/dropdown-item.js +38 -31
- package/lib/components/dropdown-item/dropdown-item.js.map +1 -0
- package/lib/components/dropdown-item/dropdown-item.styles.js +4 -0
- package/lib/components/dropdown-item/dropdown-item.styles.js.map +1 -0
- package/lib/components/feature/feature.js +40 -35
- package/lib/components/feature/feature.js.map +1 -0
- package/lib/components/feature/feature.styles.js +4 -0
- package/lib/components/feature/feature.styles.js.map +1 -0
- package/lib/components/field/field.js +218 -153
- package/lib/components/field/field.js.map +1 -0
- package/lib/components/field/field.styles.js +4 -0
- package/lib/components/field/field.styles.js.map +1 -0
- package/lib/components/field-note/field-note.js +58 -45
- package/lib/components/field-note/field-note.js.map +1 -0
- package/lib/components/field-note/field-note.styles.js +4 -0
- package/lib/components/field-note/field-note.styles.js.map +1 -0
- package/lib/components/footer/footer.js +25 -18
- package/lib/components/footer/footer.js.map +1 -0
- package/lib/components/footer/footer.styles.js +4 -0
- package/lib/components/footer/footer.styles.js.map +1 -0
- package/lib/components/global-nav/global-nav.js +44 -37
- package/lib/components/global-nav/global-nav.js.map +1 -0
- package/lib/components/global-nav/global-nav.styles.js +4 -0
- package/lib/components/global-nav/global-nav.styles.js.map +1 -0
- package/lib/components/global-nav-item/global-nav-item.js +149 -112
- package/lib/components/global-nav-item/global-nav-item.js.map +1 -0
- package/lib/components/global-nav-item/global-nav-item.styles.js +4 -0
- package/lib/components/global-nav-item/global-nav-item.styles.js.map +1 -0
- package/lib/components/grid/grid.js +48 -45
- package/lib/components/grid/grid.js.map +1 -0
- package/lib/components/grid/grid.styles.js +4 -0
- package/lib/components/grid/grid.styles.js.map +1 -0
- package/lib/components/grid-item/grid-item.js +19 -16
- package/lib/components/grid-item/grid-item.js.map +1 -0
- package/lib/components/grid-item/grid-item.styles.js +4 -0
- package/lib/components/grid-item/grid-item.styles.js.map +1 -0
- package/lib/components/header/header.js +34 -29
- package/lib/components/header/header.js.map +1 -0
- package/lib/components/header/header.styles.js +4 -0
- package/lib/components/header/header.styles.js.map +1 -0
- package/lib/components/heading/heading.js +113 -76
- package/lib/components/heading/heading.js.map +1 -0
- package/lib/components/heading/heading.styles.js +4 -0
- package/lib/components/heading/heading.styles.js.map +1 -0
- package/lib/components/hero/hero.js +43 -40
- package/lib/components/hero/hero.js.map +1 -0
- package/lib/components/hero/hero.styles.js +4 -0
- package/lib/components/hero/hero.styles.js.map +1 -0
- package/lib/components/icon/icon.js +232 -9
- package/lib/components/icon/icon.js.map +1 -0
- package/lib/components/icon/icon.styles.js +4 -0
- package/lib/components/icon/icon.styles.js.map +1 -0
- package/lib/components/inline-alert/inline-alert.js +114 -87
- package/lib/components/inline-alert/inline-alert.js.map +1 -0
- package/lib/components/inline-alert/inline-alert.styles.js +4 -0
- package/lib/components/inline-alert/inline-alert.styles.js.map +1 -0
- package/lib/components/layout/layout.js +30 -27
- package/lib/components/layout/layout.js.map +1 -0
- package/lib/components/layout/layout.styles.js +4 -0
- package/lib/components/layout/layout.styles.js.map +1 -0
- package/lib/components/layout-container/layout-container.js +30 -27
- package/lib/components/layout-container/layout-container.js.map +1 -0
- package/lib/components/layout-container/layout-container.styles.js +4 -0
- package/lib/components/layout-container/layout-container.styles.js.map +1 -0
- package/lib/components/layout-section/layout-section.js +41 -33
- package/lib/components/layout-section/layout-section.js.map +1 -0
- package/lib/components/layout-section/layout-section.styles.js +4 -0
- package/lib/components/layout-section/layout-section.styles.js.map +1 -0
- package/lib/components/linelength-container/linelength-container.js +19 -16
- package/lib/components/linelength-container/linelength-container.js.map +1 -0
- package/lib/components/linelength-container/linelength-container.styles.js +4 -0
- package/lib/components/linelength-container/linelength-container.styles.js.map +1 -0
- package/lib/components/link/link.js +125 -87
- package/lib/components/link/link.js.map +1 -0
- package/lib/components/link/link.styles.js +4 -0
- package/lib/components/link/link.styles.js.map +1 -0
- package/lib/components/link-list/link-list.js +48 -45
- package/lib/components/link-list/link-list.js.map +1 -0
- package/lib/components/link-list/link-list.styles.js +4 -0
- package/lib/components/link-list/link-list.styles.js.map +1 -0
- package/lib/components/link-list-item/link-list-item.js +40 -37
- package/lib/components/link-list-item/link-list-item.js.map +1 -0
- package/lib/components/link-list-item/link-list-item.styles.js +4 -0
- package/lib/components/link-list-item/link-list-item.styles.js.map +1 -0
- package/lib/components/list/list.js +35 -32
- package/lib/components/list/list.js.map +1 -0
- package/lib/components/list/list.styles.js +4 -0
- package/lib/components/list/list.styles.js.map +1 -0
- package/lib/components/list-item/list-item.js +25 -21
- package/lib/components/list-item/list-item.js.map +1 -0
- package/lib/components/list-item/list-item.styles.js +4 -0
- package/lib/components/list-item/list-item.styles.js.map +1 -0
- package/lib/components/loading-spinner/loading-spinner.js +126 -71
- package/lib/components/loading-spinner/loading-spinner.js.map +1 -0
- package/lib/components/loading-spinner/loading-spinner.styles.js +4 -0
- package/lib/components/loading-spinner/loading-spinner.styles.js.map +1 -0
- package/lib/components/logo/logo.js +28 -25
- package/lib/components/logo/logo.js.map +1 -0
- package/lib/components/logo/logo.styles.js +4 -0
- package/lib/components/logo/logo.styles.js.map +1 -0
- package/lib/components/main/main.js +29 -26
- package/lib/components/main/main.js.map +1 -0
- package/lib/components/main/main.styles.js +4 -0
- package/lib/components/main/main.styles.js.map +1 -0
- package/lib/components/modal/modal.js +174 -125
- package/lib/components/modal/modal.js.map +1 -0
- package/lib/components/modal/modal.styles.js +4 -0
- package/lib/components/modal/modal.styles.js.map +1 -0
- package/lib/components/multi-select/multi-select.js +300 -211
- package/lib/components/multi-select/multi-select.js.map +1 -0
- package/lib/components/multi-select/multi-select.styles.js +4 -0
- package/lib/components/multi-select/multi-select.styles.js.map +1 -0
- package/lib/components/nav-container/nav-container.js +19 -16
- package/lib/components/nav-container/nav-container.js.map +1 -0
- package/lib/components/nav-container/nav-container.styles.js +4 -0
- package/lib/components/nav-container/nav-container.styles.js.map +1 -0
- package/lib/components/page-header/page-header.js +36 -29
- package/lib/components/page-header/page-header.js.map +1 -0
- package/lib/components/page-header/page-header.styles.js +4 -0
- package/lib/components/page-header/page-header.styles.js.map +1 -0
- package/lib/components/pagination/page-counter/page-counter.js +67 -0
- package/lib/components/pagination/page-counter/page-counter.js.map +1 -0
- package/lib/components/pagination/page-counter/page-counter.styles.js +4 -0
- package/lib/components/pagination/page-counter/page-counter.styles.js.map +1 -0
- package/lib/components/pagination/pagination.js +282 -237
- package/lib/components/pagination/pagination.js.map +1 -0
- package/lib/components/pagination/pagination.styles.js +4 -0
- package/lib/components/pagination/pagination.styles.js.map +1 -0
- package/lib/components/percent-bar/percent-bar.js +56 -48
- package/lib/components/percent-bar/percent-bar.js.map +1 -0
- package/lib/components/percent-bar/percent-bar.styles.js +4 -0
- package/lib/components/percent-bar/percent-bar.styles.js.map +1 -0
- package/lib/components/popover/popover.js +304 -179
- package/lib/components/popover/popover.js.map +1 -0
- package/lib/components/popover/popover.styles.js +4 -0
- package/lib/components/popover/popover.styles.js.map +1 -0
- package/lib/components/primary-nav/primary-nav.js +44 -37
- package/lib/components/primary-nav/primary-nav.js.map +1 -0
- package/lib/components/primary-nav/primary-nav.styles.js +4 -0
- package/lib/components/primary-nav/primary-nav.styles.js.map +1 -0
- package/lib/components/primary-nav-item/primary-nav-item.js +151 -113
- package/lib/components/primary-nav-item/primary-nav-item.js.map +1 -0
- package/lib/components/primary-nav-item/primary-nav-item.styles.js +4 -0
- package/lib/components/primary-nav-item/primary-nav-item.styles.js.map +1 -0
- package/lib/components/progress-meter/progress-meter.js +74 -57
- package/lib/components/progress-meter/progress-meter.js.map +1 -0
- package/lib/components/progress-meter/progress-meter.styles.js +4 -0
- package/lib/components/progress-meter/progress-meter.styles.js.map +1 -0
- package/lib/components/progress-steps/progress-steps.js +19 -0
- package/lib/components/progress-steps/progress-steps.js.map +1 -0
- package/lib/components/progress-steps/progress-steps.styles.js +4 -0
- package/lib/components/progress-steps/progress-steps.styles.js.map +1 -0
- package/lib/components/progress-steps-item/progress-steps-item.js +52 -40
- package/lib/components/progress-steps-item/progress-steps-item.js.map +1 -0
- package/lib/components/progress-steps-item/progress-steps-item.styles.js +4 -0
- package/lib/components/progress-steps-item/progress-steps-item.styles.js.map +1 -0
- package/lib/components/radio-field/radio-field.js +59 -49
- package/lib/components/radio-field/radio-field.js.map +1 -0
- package/lib/components/radio-field/radio-field.styles.js +4 -0
- package/lib/components/radio-field/radio-field.styles.js.map +1 -0
- package/lib/components/radio-field-item/radio-field-item.js +222 -179
- package/lib/components/radio-field-item/radio-field-item.js.map +1 -0
- package/lib/components/radio-field-item/radio-field-item.styles.js +4 -0
- package/lib/components/radio-field-item/radio-field-item.styles.js.map +1 -0
- package/lib/components/remove-tag/remove-tag.js +89 -60
- package/lib/components/remove-tag/remove-tag.js.map +1 -0
- package/lib/components/remove-tag/remove-tag.styles.js +4 -0
- package/lib/components/remove-tag/remove-tag.styles.js.map +1 -0
- package/lib/components/section/section.js +46 -27
- package/lib/components/section/section.js.map +1 -0
- package/lib/components/section/section.styles.js +4 -0
- package/lib/components/section/section.styles.js.map +1 -0
- package/lib/components/select/select.js +243 -158
- package/lib/components/select/select.js.map +1 -0
- package/lib/components/select/select.styles.js +4 -0
- package/lib/components/select/select.styles.js.map +1 -0
- package/lib/components/select-tile/select-tile-checkbox-controller.js +60 -0
- package/lib/components/select-tile/select-tile-checkbox-controller.js.map +1 -0
- package/lib/components/select-tile/select-tile-radio-controller.js +167 -0
- package/lib/components/select-tile/select-tile-radio-controller.js.map +1 -0
- package/lib/components/select-tile/select-tile.js +228 -223
- package/lib/components/select-tile/select-tile.js.map +1 -0
- package/lib/components/select-tile/select-tile.styles.js +4 -0
- package/lib/components/select-tile/select-tile.styles.js.map +1 -0
- package/lib/components/select-tile-list/select-tile-list.js +76 -62
- package/lib/components/select-tile-list/select-tile-list.js.map +1 -0
- package/lib/components/select-tile-list/select-tile-list.styles.js +4 -0
- package/lib/components/select-tile-list/select-tile-list.styles.js.map +1 -0
- package/lib/components/skeleton-loader/skeleton-loader.js +68 -39
- package/lib/components/skeleton-loader/skeleton-loader.js.map +1 -0
- package/lib/components/skeleton-loader/skeleton-loader.styles.js +4 -0
- package/lib/components/skeleton-loader/skeleton-loader.styles.js.map +1 -0
- package/lib/components/split-button/split-button.js +51 -46
- package/lib/components/split-button/split-button.js.map +1 -0
- package/lib/components/split-button/split-button.styles.js +4 -0
- package/lib/components/split-button/split-button.styles.js.map +1 -0
- package/lib/components/submenu/submenu.js +19 -16
- package/lib/components/submenu/submenu.js.map +1 -0
- package/lib/components/submenu/submenu.styles.js +4 -0
- package/lib/components/submenu/submenu.styles.js.map +1 -0
- package/lib/components/submenu-item/submenu-item.js +32 -26
- package/lib/components/submenu-item/submenu-item.js.map +1 -0
- package/lib/components/submenu-item/submenu-item.styles.js +4 -0
- package/lib/components/submenu-item/submenu-item.styles.js.map +1 -0
- package/lib/components/tab/tab.js +74 -63
- package/lib/components/tab/tab.js.map +1 -0
- package/lib/components/tab/tab.styles.js +4 -0
- package/lib/components/tab/tab.styles.js.map +1 -0
- package/lib/components/tab-panel/tab-panel.js +49 -43
- package/lib/components/tab-panel/tab-panel.js.map +1 -0
- package/lib/components/tab-panel/tab-panel.styles.js +4 -0
- package/lib/components/tab-panel/tab-panel.styles.js.map +1 -0
- package/lib/components/table/table.js +46 -41
- package/lib/components/table/table.js.map +1 -0
- package/lib/components/table/table.styles.js +4 -0
- package/lib/components/table/table.styles.js.map +1 -0
- package/lib/components/table-body/table-body.js +20 -17
- package/lib/components/table-body/table-body.js.map +1 -0
- package/lib/components/table-body/table-body.styles.js +4 -0
- package/lib/components/table-body/table-body.styles.js.map +1 -0
- package/lib/components/table-cell/table-cell.js +39 -36
- package/lib/components/table-cell/table-cell.js.map +1 -0
- package/lib/components/table-cell/table-cell.styles.js +4 -0
- package/lib/components/table-cell/table-cell.styles.js.map +1 -0
- package/lib/components/table-header/table-header.js +20 -17
- package/lib/components/table-header/table-header.js.map +1 -0
- package/lib/components/table-header/table-header.styles.js +4 -0
- package/lib/components/table-header/table-header.styles.js.map +1 -0
- package/lib/components/table-header-cell/table-header-cell.js +35 -32
- package/lib/components/table-header-cell/table-header-cell.js.map +1 -0
- package/lib/components/table-header-cell/table-header-cell.styles.js +4 -0
- package/lib/components/table-header-cell/table-header-cell.styles.js.map +1 -0
- package/lib/components/table-object/table-object.js +21 -18
- package/lib/components/table-object/table-object.js.map +1 -0
- package/lib/components/table-object/table-object.styles.js +4 -0
- package/lib/components/table-object/table-object.styles.js.map +1 -0
- package/lib/components/table-row/table-row.js +76 -55
- package/lib/components/table-row/table-row.js.map +1 -0
- package/lib/components/table-row/table-row.styles.js +4 -0
- package/lib/components/table-row/table-row.styles.js.map +1 -0
- package/lib/components/tabs/tabs.js +452 -303
- package/lib/components/tabs/tabs.js.map +1 -0
- package/lib/components/tabs/tabs.styles.js +4 -0
- package/lib/components/tabs/tabs.styles.js.map +1 -0
- package/lib/components/tag/tag.js +236 -167
- package/lib/components/tag/tag.js.map +1 -0
- package/lib/components/tag/tag.styles.js +4 -0
- package/lib/components/tag/tag.styles.js.map +1 -0
- package/lib/components/tag-list/tag-list.js +40 -35
- package/lib/components/tag-list/tag-list.js.map +1 -0
- package/lib/components/tag-list/tag-list.styles.js +4 -0
- package/lib/components/tag-list/tag-list.styles.js.map +1 -0
- package/lib/components/tertiary-nav/tertiary-nav.js +40 -33
- package/lib/components/tertiary-nav/tertiary-nav.js.map +1 -0
- package/lib/components/tertiary-nav/tertiary-nav.styles.js +4 -0
- package/lib/components/tertiary-nav/tertiary-nav.styles.js.map +1 -0
- package/lib/components/tertiary-nav-item/tertiary-nav-item.js +52 -43
- package/lib/components/tertiary-nav-item/tertiary-nav-item.js.map +1 -0
- package/lib/components/tertiary-nav-item/tertiary-nav-item.styles.js +4 -0
- package/lib/components/tertiary-nav-item/tertiary-nav-item.styles.js.map +1 -0
- package/lib/components/text-link/text-link.js +45 -41
- package/lib/components/text-link/text-link.js.map +1 -0
- package/lib/components/text-link/text-link.styles.js +4 -0
- package/lib/components/text-link/text-link.styles.js.map +1 -0
- package/lib/components/text-passage/text-passage-light-dom.js +145 -0
- package/lib/components/text-passage/text-passage-light-dom.js.map +1 -0
- package/lib/components/text-passage/text-passage-light-dom.styles.js +4 -0
- package/lib/components/text-passage/text-passage-light-dom.styles.js.map +1 -0
- package/lib/components/text-passage/text-passage.js +72 -44
- package/lib/components/text-passage/text-passage.js.map +1 -0
- package/lib/components/text-passage/text-passage.styles.js +4 -0
- package/lib/components/text-passage/text-passage.styles.js.map +1 -0
- package/lib/components/tooltip/tooltip.js +278 -173
- package/lib/components/tooltip/tooltip.js.map +1 -0
- package/lib/components/tooltip/tooltip.styles.js +4 -0
- package/lib/components/tooltip/tooltip.styles.js.map +1 -0
- package/lib/components/utility-nav/utility-nav.js +40 -33
- package/lib/components/utility-nav/utility-nav.js.map +1 -0
- package/lib/components/utility-nav/utility-nav.styles.js +4 -0
- package/lib/components/utility-nav/utility-nav.styles.js.map +1 -0
- package/lib/components/utility-nav-item/utility-nav-item.js +70 -49
- package/lib/components/utility-nav-item/utility-nav-item.js.map +1 -0
- package/lib/components/utility-nav-item/utility-nav-item.styles.js +4 -0
- package/lib/components/utility-nav-item/utility-nav-item.styles.js.map +1 -0
- package/lib/design-tokens/brands/blue/css/tokens_blue.module.js +737 -0
- package/lib/design-tokens/brands/blue/css/tokens_blue.module.js.map +1 -0
- package/lib/design-tokens/brands/bolt/tokens_bolt.theme.js +756 -0
- package/lib/design-tokens/brands/bolt/tokens_bolt.theme.js.map +1 -0
- package/lib/design-tokens/brands/cre8/css/tokens_cre8.module.js +771 -0
- package/lib/design-tokens/brands/cre8/css/tokens_cre8.module.js.map +1 -0
- package/lib/design-tokens/brands/cre8-a2ui/css/tokens_cre8-a2ui.module.js +772 -0
- package/lib/design-tokens/brands/cre8-a2ui/css/tokens_cre8-a2ui.module.js.map +1 -0
- package/lib/design-tokens/brands/cre8-legacy/css/tokens_cre8-legacy.module.js +737 -0
- package/lib/design-tokens/brands/cre8-legacy/css/tokens_cre8-legacy.module.js.map +1 -0
- package/lib/design-tokens/brands/femmecubator/css/tokens_femmecubator2.module.js +983 -0
- package/lib/design-tokens/brands/femmecubator/css/tokens_femmecubator2.module.js.map +1 -0
- package/lib/design-tokens/brands/legacy/css/tokens_legacy.module.js +737 -0
- package/lib/design-tokens/brands/legacy/css/tokens_legacy.module.js.map +1 -0
- package/lib/design-tokens/brands/marketing/css/tokens_marketing.module.js +736 -0
- package/lib/design-tokens/brands/marketing/css/tokens_marketing.module.js.map +1 -0
- package/lib/design-tokens/brands/minimalist/css/tokens_minimalist.module.js +737 -0
- package/lib/design-tokens/brands/minimalist/css/tokens_minimalist.module.js.map +1 -0
- package/lib/design-tokens/brands/prisma/tokens_prisma.module.js +771 -0
- package/lib/design-tokens/brands/prisma/tokens_prisma.module.js.map +1 -0
- package/lib/design-tokens/brands/starbucks/tokens.module.js +552 -0
- package/lib/design-tokens/brands/starbucks/tokens.module.js.map +1 -0
- package/lib/design-tokens/brands/starbucks/tokens_starbucks.module.js +776 -0
- package/lib/design-tokens/brands/starbucks/tokens_starbucks.module.js.map +1 -0
- package/lib/design-tokens/brands copy/blue/css/tokens_blue.module.js +253 -0
- package/lib/design-tokens/brands copy/blue/css/tokens_blue.module.js.map +1 -0
- package/lib/design-tokens/core/scss/theming/head.module.js +6 -0
- package/lib/design-tokens/core/scss/theming/head.module.js.map +1 -0
- package/lib/design-tokens/tokens_netflix.theme.js +806 -0
- package/lib/design-tokens/tokens_netflix.theme.js.map +1 -0
- package/lib/directives/if-truthy.js +24 -0
- package/lib/directives/if-truthy.js.map +1 -0
- package/lib/directives/spread.js +29 -0
- package/lib/directives/spread.js.map +1 -0
- package/lib/index.js +84 -168
- package/lib/index.js.map +1 -0
- package/lib/scripts/convert-scss-to-ts.js +25 -0
- package/lib/scripts/convert-scss-to-ts.js.map +1 -0
- package/lib/scripts/extract-tokens.js +120 -0
- package/lib/scripts/extract-tokens.js.map +1 -0
- package/lib/scripts/generate-react-wrappers.js +229 -0
- package/lib/scripts/generate-react-wrappers.js.map +1 -0
- package/lib/scripts/generateWesparkleThemes.js +52 -0
- package/lib/scripts/generateWesparkleThemes.js.map +1 -0
- package/lib/toBeAccessible.js +18 -0
- package/lib/toBeAccessible.js.map +1 -0
- package/lib/utilities/is-mobile.js +10 -0
- package/lib/utilities/is-mobile.js.map +1 -0
- package/lib/utilities/story-helpers.js +14 -0
- package/lib/utilities/story-helpers.js.map +1 -0
- package/lib/vite.config.cdn.js +85 -0
- package/lib/vite.config.cdn.js.map +1 -0
- package/lib/vite.config.js +156 -0
- package/lib/vite.config.js.map +1 -0
- package/package.json +8 -9
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to wrap indexes around, to help us treat the array as a ring.
|
|
3
|
+
*/
|
|
4
|
+
function wrapIndex(arr, index) {
|
|
5
|
+
if (index < 0) {
|
|
6
|
+
return arr.length - 1;
|
|
7
|
+
}
|
|
8
|
+
if (index >= arr.length) {
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
return index;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* This Controller handles the special radio button logic.
|
|
15
|
+
*
|
|
16
|
+
* - Handle clicks and key presses, which involves
|
|
17
|
+
* - Unchecking other select-tile's when this one is checked, if they are in the same form.
|
|
18
|
+
* - Changing focus between `0` and `-1`, and moving focus correctly on key press
|
|
19
|
+
* - checking/unchecking on spacebar
|
|
20
|
+
*
|
|
21
|
+
* See also https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radio_role
|
|
22
|
+
* and https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radiogroup_role
|
|
23
|
+
*
|
|
24
|
+
* Also see https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-autonomous-drawbacks
|
|
25
|
+
*
|
|
26
|
+
* This started out as a copy of radio-field-item.ts.
|
|
27
|
+
*
|
|
28
|
+
* Part of the reason I extracted this was to see if I could share this logic with radio-field-item,
|
|
29
|
+
* but that would be separate refactor.
|
|
30
|
+
*
|
|
31
|
+
* It might also be good for the "checkbox" mode of select-tile.
|
|
32
|
+
*
|
|
33
|
+
* And it might also just be a cleaner separation of concerns.
|
|
34
|
+
*/
|
|
35
|
+
export class SelectTileRadioController {
|
|
36
|
+
constructor(host) {
|
|
37
|
+
/**
|
|
38
|
+
* Handle clicking on the radio button
|
|
39
|
+
* @see _checkAndFocus
|
|
40
|
+
*/
|
|
41
|
+
this._clickHandler = (e) => {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
this._checkAndFocus(this.host);
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Set the element to `checked`
|
|
47
|
+
* 1) Remove `checked` and set tabindex to -1 on all elements in our radio group
|
|
48
|
+
* 2) Set us to checked.
|
|
49
|
+
* 3) Set our tabindex to 0
|
|
50
|
+
*/
|
|
51
|
+
this._checkAndFocus = (target) => {
|
|
52
|
+
const wasChecked = target.checked;
|
|
53
|
+
this.removeChecked(); /* 1 */
|
|
54
|
+
target.focus();
|
|
55
|
+
target.checked = true; /* 2 */
|
|
56
|
+
target.setAttribute('tabindex', '0'); /* 3 */
|
|
57
|
+
if (!wasChecked) {
|
|
58
|
+
target.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
59
|
+
target.dispatchEvent(new Event('change', { bubbles: true }));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Handle keydown
|
|
64
|
+
* 1) If left or up arrow key is struck and radio field item exists before current item,
|
|
65
|
+
* remove checked from all items and add it to the next item
|
|
66
|
+
* 2) If right or down arrow key is struck and radio field item exists after current item,
|
|
67
|
+
* remove checked from all items and add checked to the next item.
|
|
68
|
+
* Focus on this item and set tabindex for when focusing out of radio field and back onto checked item.
|
|
69
|
+
* 3) If the element is in focused, then for event emission the
|
|
70
|
+
* current focues element should be clicked to emit event.
|
|
71
|
+
* 4) If the Enter key is pressed, then check the radio if no other radio items are checked
|
|
72
|
+
*/
|
|
73
|
+
this._handleKeyDown = (e) => {
|
|
74
|
+
// The arrow keys
|
|
75
|
+
if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].includes(e.code)) {
|
|
76
|
+
this._handleArrowKeys(e);
|
|
77
|
+
}
|
|
78
|
+
// Enter and Space
|
|
79
|
+
if (['Enter', ' '].includes(e.key)) {
|
|
80
|
+
this._handleEnterSpace(e);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
this._handleArrowKeys = (e) => {
|
|
84
|
+
const siblings = this.findAllElementsInSameRadioButtonGroup({ excludeDisabled: true });
|
|
85
|
+
// If we're the only radio-like element, nothing to do
|
|
86
|
+
if (siblings.length <= 1) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const ourIndex = siblings.findIndex((item) => item === this.host);
|
|
90
|
+
let moveToElement;
|
|
91
|
+
if (e.code === 'ArrowLeft' || e.code === 'ArrowUp') {
|
|
92
|
+
moveToElement = siblings[wrapIndex(siblings, ourIndex - 1)];
|
|
93
|
+
}
|
|
94
|
+
else if (e.code === 'ArrowRight' || e.code === 'ArrowDown') {
|
|
95
|
+
moveToElement = siblings[wrapIndex(siblings, ourIndex + 1)];
|
|
96
|
+
}
|
|
97
|
+
this._checkAndFocus(moveToElement);
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Handle Enter and Space
|
|
102
|
+
* @see _checkAndFocus
|
|
103
|
+
*/
|
|
104
|
+
this._handleEnterSpace = (e) => {
|
|
105
|
+
this._checkAndFocus(this.host);
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
};
|
|
108
|
+
this.host = host;
|
|
109
|
+
host.addController(this);
|
|
110
|
+
}
|
|
111
|
+
hostConnected() {
|
|
112
|
+
this.host._internals.role = 'radio';
|
|
113
|
+
// If we don't also do this, we can't use css selectors to find ourselves
|
|
114
|
+
this.host.setAttribute('role', 'radio');
|
|
115
|
+
this.host.setAttribute('tabindex', '0');
|
|
116
|
+
this.host.addEventListener('click', this._clickHandler);
|
|
117
|
+
this.host.addEventListener('keydown', this._handleKeyDown);
|
|
118
|
+
}
|
|
119
|
+
hostDisconnected() {
|
|
120
|
+
this.host._internals.role = undefined;
|
|
121
|
+
this.host.removeAttribute('role');
|
|
122
|
+
this.host.removeAttribute('tabindex');
|
|
123
|
+
this.host.removeEventListener('click', this._clickHandler);
|
|
124
|
+
this.host.removeEventListener('keydown', this._handleKeyDown);
|
|
125
|
+
}
|
|
126
|
+
hostUpdate() {
|
|
127
|
+
// TODO: do stuff if name, checked, etc change.
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Find all elements that are in the same "radio button group", following the HTML 5 spec,
|
|
131
|
+
* except that we're looking at `[role="radio"]` instead of `input[type="radio"]`.
|
|
132
|
+
*
|
|
133
|
+
* - They have the attribute role="radio" set
|
|
134
|
+
* - They have the same form owner, or both have no form owner
|
|
135
|
+
* - They're in the same tree (same document, don't look at shadow dom)
|
|
136
|
+
* - They both have non-empty name attributes, and the names are the same
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
findAllElementsInSameRadioButtonGroup({ excludeDisabled } = {}) {
|
|
140
|
+
const name = this.host.name;
|
|
141
|
+
const form = this.host.form;
|
|
142
|
+
if (name && name.length > 0) {
|
|
143
|
+
const document = this.host.ownerDocument;
|
|
144
|
+
const matches = Array.from(document.querySelectorAll(`[role="radio"][name="${name}"]`)).filter((element) => element.form === form);
|
|
145
|
+
if (excludeDisabled === true) {
|
|
146
|
+
return matches
|
|
147
|
+
.filter((element) => !(element.disabled || element.ariaDisabled === 'true'));
|
|
148
|
+
}
|
|
149
|
+
return matches;
|
|
150
|
+
}
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Remove checked
|
|
155
|
+
* 1) Reset the form field to not checked
|
|
156
|
+
* 2) Remove checked property from all items and set tabindex to -1
|
|
157
|
+
*/
|
|
158
|
+
removeChecked() {
|
|
159
|
+
const radioFieldItems = this.findAllElementsInSameRadioButtonGroup();
|
|
160
|
+
radioFieldItems.forEach((element) => {
|
|
161
|
+
element.checked = false; /* 1 */
|
|
162
|
+
element.setAttribute('tabindex', '-1'); /* 2 */
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export default SelectTileRadioController;
|
|
167
|
+
//# sourceMappingURL=select-tile-radio-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-tile-radio-controller.js","sourceRoot":"","sources":["../../../components/select-tile/select-tile-radio-controller.ts"],"names":[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eAAe,KAAmC,EAAE;QACxF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5B,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;YACzC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CACtB,QAAQ,CAAC,gBAAgB,CAAC,wBAAwB,IAAI,IAAI,CAAC,CAC9D,CAAC,MAAM,CAAC,CAAC,OAAgD,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YAEtF,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;gBAC3B,OAAO,OAAO;qBACT,MAAM,CAAC,CAAC,OAA4C,EAAE,EAAE,CAAC,CAAC,CACvD,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,YAAY,KAAK,MAAM,CACtD,CAAC,CAAC;YACX,CAAC;YAED,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,OAAO,EAAE,CAAC;IACd,CAAC;IAEJ;;;;QAII;IACD,aAAa;QACT,MAAM,eAAe,GAAG,IAAI,CAAC,qCAAqC,EAAE,CAAC;QACrE,eAAe,CAAC,OAAO,CAAC,CAAC,OAA2B,EAAE,EAAE;YACpD,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,OAAO;YAChC,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO;QACnD,CAAC,CAAC,CAAC;IACP,CAAC;CAgFJ;AAED,eAAe,yBAAyB,CAAC","sourcesContent":["import { ReactiveController } from 'lit';\nimport { Cre8FormElement } from '../cre8-form-element';\nimport { Cre8RadioFieldItem } from '../radio-field-item/radio-field-item';\n\ntype FormElement = Cre8FormElement & { form: HTMLFormElement, name?: string, checked?: boolean };\n\n/**\n * Helper function to wrap indexes around, to help us treat the array as a ring.\n */\nfunction wrapIndex(arr: unknown[], index: number) {\n if (index < 0) {\n return arr.length - 1;\n } if (index >= arr.length) {\n return 0;\n }\n return index;\n}\n\n/**\n * This Controller handles the special radio button logic.\n *\n * - Handle clicks and key presses, which involves\n * - Unchecking other select-tile's when this one is checked, if they are in the same form.\n * - Changing focus between `0` and `-1`, and moving focus correctly on key press\n * - checking/unchecking on spacebar\n *\n * See also https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radio_role\n * and https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radiogroup_role\n *\n * Also see https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-autonomous-drawbacks\n *\n * This started out as a copy of radio-field-item.ts.\n *\n * Part of the reason I extracted this was to see if I could share this logic with radio-field-item,\n * but that would be separate refactor.\n *\n * It might also be good for the \"checkbox\" mode of select-tile.\n *\n * And it might also just be a cleaner separation of concerns.\n */\nexport class SelectTileRadioController implements ReactiveController {\n private host: FormElement;\n\n constructor(host: FormElement) {\n this.host = host;\n host.addController(this);\n }\n\n hostConnected(): void {\n this.host._internals.role = 'radio';\n // If we don't also do this, we can't use css selectors to find ourselves\n this.host.setAttribute('role', 'radio');\n this.host.setAttribute('tabindex', '0');\n\n this.host.addEventListener('click', this._clickHandler);\n this.host.addEventListener('keydown', this._handleKeyDown);\n }\n\n hostDisconnected(): void {\n this.host._internals.role = undefined;\n this.host.removeAttribute('role');\n this.host.removeAttribute('tabindex');\n\n this.host.removeEventListener('click', this._clickHandler);\n this.host.removeEventListener('keydown', this._handleKeyDown);\n }\n\n hostUpdate(): void {\n // TODO: do stuff if name, checked, etc change.\n }\n\n /**\n * Find all elements that are in the same \"radio button group\", following the HTML 5 spec,\n * except that we're looking at `[role=\"radio\"]` instead of `input[type=\"radio\"]`.\n *\n * - They have the attribute role=\"radio\" set\n * - They have the same form owner, or both have no form owner\n * - They're in the same tree (same document, don't look at shadow dom)\n * - They both have non-empty name attributes, and the names are the same\n *\n */\n findAllElementsInSameRadioButtonGroup({ excludeDisabled }: { excludeDisabled?: boolean} = {}) {\n const name = this.host.name;\n const form = this.host.form;\n if (name && name.length > 0) {\n const document = this.host.ownerDocument;\n const matches = Array.from(\n document.querySelectorAll(`[role=\"radio\"][name=\"${name}\"]`)\n ).filter((element: HTMLElement & { form?: HTMLFormElement}) => element.form === form);\n\n if (excludeDisabled === true) {\n return matches\n .filter((element: HTMLElement & { disabled?: boolean}) => !(\n element.disabled || element.ariaDisabled === 'true'\n ));\n }\n\n return matches;\n }\n return [];\n }\n\n /**\n * Remove checked\n * 1) Reset the form field to not checked\n * 2) Remove checked property from all items and set tabindex to -1\n */\n removeChecked() {\n const radioFieldItems = this.findAllElementsInSameRadioButtonGroup();\n radioFieldItems.forEach((element: Cre8RadioFieldItem) => {\n element.checked = false; /* 1 */\n element.setAttribute('tabindex', '-1'); /* 2 */\n });\n }\n\n /**\n * Handle clicking on the radio button\n * @see _checkAndFocus\n */\n private _clickHandler = (e: MouseEvent | KeyboardEvent) => {\n e.preventDefault();\n this._checkAndFocus(this.host);\n };\n\n /**\n * Set the element to `checked`\n * 1) Remove `checked` and set tabindex to -1 on all elements in our radio group\n * 2) Set us to checked.\n * 3) Set our tabindex to 0\n */\n private _checkAndFocus = (target: HTMLElement & { checked?: boolean }) => {\n const wasChecked = target.checked;\n this.removeChecked(); /* 1 */\n target.focus();\n target.checked = true; /* 2 */\n target.setAttribute('tabindex', '0'); /* 3 */\n if (!wasChecked) {\n target.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n target.dispatchEvent(new Event('change', { bubbles: true }));\n }\n };\n\n /**\n * Handle keydown\n * 1) If left or up arrow key is struck and radio field item exists before current item,\n * remove checked from all items and add it to the next item\n * 2) If right or down arrow key is struck and radio field item exists after current item,\n * remove checked from all items and add checked to the next item.\n * Focus on this item and set tabindex for when focusing out of radio field and back onto checked item.\n * 3) If the element is in focused, then for event emission the\n * current focues element should be clicked to emit event.\n * 4) If the Enter key is pressed, then check the radio if no other radio items are checked\n */\n private _handleKeyDown = (e: KeyboardEvent) => {\n // The arrow keys\n if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].includes(e.code)) {\n this._handleArrowKeys(e);\n }\n // Enter and Space\n if (['Enter', ' '].includes(e.key)) {\n this._handleEnterSpace(e);\n }\n };\n\n private _handleArrowKeys = (e: KeyboardEvent) => {\n const siblings = this.findAllElementsInSameRadioButtonGroup({ excludeDisabled: true });\n\n // If we're the only radio-like element, nothing to do\n if (siblings.length <= 1) {\n return;\n }\n\n const ourIndex = siblings.findIndex((item) => item === this.host);\n let moveToElement: HTMLElement & { checked?: boolean };\n if (e.code === 'ArrowLeft' || e.code === 'ArrowUp') {\n moveToElement = siblings[wrapIndex(siblings, ourIndex - 1)] as HTMLElement;\n } else if (e.code === 'ArrowRight' || e.code === 'ArrowDown') {\n moveToElement = siblings[wrapIndex(siblings, ourIndex + 1)] as HTMLElement;\n }\n\n this._checkAndFocus(moveToElement);\n\n e.preventDefault();\n };\n\n /**\n * Handle Enter and Space\n * @see _checkAndFocus\n */\n private _handleEnterSpace = (e: KeyboardEvent) => {\n this._checkAndFocus(this.host);\n e.preventDefault();\n };\n}\n\nexport default SelectTileRadioController;\n"]}
|