dasar-ui 1.1.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +31 -0
- package/.github/workflows/npm-publish-github-packages.yml +36 -0
- package/.versionrc.json +4 -0
- package/CHANGELOG.md +30 -0
- package/Dockerfile +26 -0
- package/angular.json +77 -0
- package/package.json +38 -24
- package/projects/dasar-ui/package.json +1 -1
- package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.ts +3 -7
- package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.ts +1 -1
- package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.ts +2 -2
- package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.ts +0 -2
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.html +11 -2
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.scss +30 -0
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.spec.ts +78 -6
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.ts +32 -32
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.registry.ts +0 -2
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.ts +1 -1
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.scss +0 -30
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.ts +0 -4
- package/projects/dasar-ui/src/lib/components/dasar-list/dasar-list-item.html +17 -0
- package/projects/dasar-ui/src/lib/components/dasar-list/dasar-list.html +25 -0
- package/projects/dasar-ui/src/lib/components/dasar-list/dasar-list.scss +122 -0
- package/projects/dasar-ui/src/lib/components/dasar-list/dasar-list.spec.ts +21 -0
- package/projects/dasar-ui/src/lib/components/dasar-list/dasar-list.ts +166 -0
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.html +6 -5
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.scss +39 -5
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.spec.ts +78 -6
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.ts +41 -3
- package/projects/dasar-ui/src/lib/components/dasar-modal/dasar-modal.html +72 -0
- package/projects/dasar-ui/src/lib/components/dasar-modal/dasar-modal.scss +170 -0
- package/projects/dasar-ui/src/lib/components/dasar-modal/dasar-modal.spec.ts +267 -0
- package/projects/dasar-ui/src/lib/components/dasar-modal/dasar-modal.ts +305 -0
- package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.scss +2 -7
- package/projects/dasar-ui/src/lib/components/dasar-overlay/dasar-overlay.html +11 -0
- package/projects/dasar-ui/src/lib/components/dasar-overlay/dasar-overlay.scss +18 -0
- package/projects/dasar-ui/src/lib/components/dasar-overlay/dasar-overlay.spec.ts +104 -0
- package/projects/dasar-ui/src/lib/components/dasar-overlay/dasar-overlay.ts +87 -0
- package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.ts +1 -1
- package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.html +1 -14
- package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.scss +0 -11
- package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.ts +0 -2
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.html +9 -5
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.scss +62 -22
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.spec.ts +82 -6
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.ts +47 -4
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.html +92 -30
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.scss +137 -25
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.spec.ts +554 -5
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.ts +312 -35
- package/projects/dasar-ui/src/lib/components/dasar-theme-provider/dasar-theme-provider.ts +6 -21
- package/projects/dasar-ui/src/lib/models/theme.model.ts +35 -12
- package/projects/dasar-ui/src/lib/services/theme.service.spec.ts +65 -0
- package/projects/dasar-ui/src/lib/services/theme.service.ts +68 -4
- package/projects/dasar-ui/src/lib/styles/theme.scss +47 -48
- package/projects/dasar-ui/src/lib/utils/common.ts +5 -24
- package/projects/dasar-ui/src/lib/utils/icon-size.spec.ts +23 -0
- package/projects/dasar-ui/src/lib/utils/icon-size.ts +16 -0
- package/projects/dasar-ui/src/lib/utils/panel-placement.spec.ts +90 -0
- package/projects/dasar-ui/src/lib/utils/panel-placement.ts +53 -0
- package/projects/dasar-ui/src/public-api.ts +4 -4
- package/projects/dasar-ui/tsconfig.spec.json +8 -1
- package/projects/documentation/public/favicon.ico +0 -0
- package/projects/documentation/src/app/app.html +51 -0
- package/projects/documentation/src/app/app.spec.ts +23 -0
- package/projects/documentation/src/app/app.ts +23 -0
- package/projects/documentation/src/app/components/doc-customize-modal.component.ts +314 -0
- package/projects/documentation/src/app/components/doc-example.component.ts +195 -0
- package/projects/documentation/src/app/config/app.config.server.ts +10 -0
- package/projects/documentation/src/app/config/app.config.ts +17 -0
- package/projects/documentation/src/app/layouts/doc.layout.ts +229 -0
- package/projects/documentation/src/app/pages/button/button.page.html +65 -0
- package/projects/documentation/src/app/pages/button/button.page.ts +139 -0
- package/projects/documentation/src/app/pages/button/examples/appearance/button-appearance.example.html +7 -0
- package/projects/documentation/src/app/pages/button/examples/appearance/button-appearance.example.ts +10 -0
- package/projects/documentation/src/app/pages/button/examples/icon/button-icon.example.html +19 -0
- package/projects/documentation/src/app/pages/button/examples/icon/button-icon.example.ts +10 -0
- package/projects/documentation/src/app/pages/button/examples/radius/button-radius.example.html +9 -0
- package/projects/documentation/src/app/pages/button/examples/radius/button-radius.example.ts +10 -0
- package/projects/documentation/src/app/pages/button/examples/sizes/button-sizes.example.html +7 -0
- package/projects/documentation/src/app/pages/button/examples/sizes/button-sizes.example.ts +10 -0
- package/projects/documentation/src/app/pages/button/examples/state/button-state.example.html +10 -0
- package/projects/documentation/src/app/pages/button/examples/state/button-state.example.ts +10 -0
- package/projects/documentation/src/app/pages/button/examples/variant/button-variant.example.html +9 -0
- package/projects/documentation/src/app/pages/button/examples/variant/button-variant.example.ts +10 -0
- package/projects/documentation/src/app/pages/calendar/calendar.page.html +75 -0
- package/projects/documentation/src/app/pages/calendar/calendar.page.ts +165 -0
- package/projects/documentation/src/app/pages/calendar/examples/actions/calendar-actions.example.html +21 -0
- package/projects/documentation/src/app/pages/calendar/examples/actions/calendar-actions.example.ts +10 -0
- package/projects/documentation/src/app/pages/calendar/examples/basic/calendar-basic.example.html +11 -0
- package/projects/documentation/src/app/pages/calendar/examples/basic/calendar-basic.example.ts +13 -0
- package/projects/documentation/src/app/pages/calendar/examples/custom-header/calendar-custom-header.example.html +36 -0
- package/projects/documentation/src/app/pages/calendar/examples/custom-header/calendar-custom-header.example.ts +11 -0
- package/projects/documentation/src/app/pages/calendar/examples/dropdown/calendar-dropdown.example.html +10 -0
- package/projects/documentation/src/app/pages/calendar/examples/dropdown/calendar-dropdown.example.ts +12 -0
- package/projects/documentation/src/app/pages/calendar/examples/format/calendar-format.example.html +15 -0
- package/projects/documentation/src/app/pages/calendar/examples/format/calendar-format.example.ts +12 -0
- package/projects/documentation/src/app/pages/calendar/examples/locale/calendar-locale.example.html +34 -0
- package/projects/documentation/src/app/pages/calendar/examples/locale/calendar-locale.example.ts +14 -0
- package/projects/documentation/src/app/pages/calendar/examples/more/calendar.more.example.html +20 -0
- package/projects/documentation/src/app/pages/calendar/examples/more/calendar.more.example.ts +37 -0
- package/projects/documentation/src/app/pages/calendar/examples/styles/calendar-styles.example.html +16 -0
- package/projects/documentation/src/app/pages/calendar/examples/styles/calendar-styles.example.ts +10 -0
- package/projects/documentation/src/app/pages/card/card.page.html +75 -0
- package/projects/documentation/src/app/pages/card/card.page.ts +182 -0
- package/projects/documentation/src/app/pages/card/examples/appearance/card-appearance.example.html +13 -0
- package/projects/documentation/src/app/pages/card/examples/appearance/card-appearance.example.ts +10 -0
- package/projects/documentation/src/app/pages/card/examples/closable/card-closable.example.html +30 -0
- package/projects/documentation/src/app/pages/card/examples/closable/card-closable.example.ts +19 -0
- package/projects/documentation/src/app/pages/card/examples/custom-style/card-custom-style.example.html +173 -0
- package/projects/documentation/src/app/pages/card/examples/custom-style/card-custom-style.example.ts +10 -0
- package/projects/documentation/src/app/pages/card/examples/media/card-media.example.html +27 -0
- package/projects/documentation/src/app/pages/card/examples/media/card-media.example.ts +10 -0
- package/projects/documentation/src/app/pages/card/examples/radius/card-radius.example.html +13 -0
- package/projects/documentation/src/app/pages/card/examples/radius/card-radius.example.ts +10 -0
- package/projects/documentation/src/app/pages/card/examples/slots/card-slots.example.html +20 -0
- package/projects/documentation/src/app/pages/card/examples/slots/card-slots.example.ts +10 -0
- package/projects/documentation/src/app/pages/card/examples/spacing/card-spacing.example.html +11 -0
- package/projects/documentation/src/app/pages/card/examples/spacing/card-spacing.example.ts +10 -0
- package/projects/documentation/src/app/pages/chip/chip.page.html +55 -0
- package/projects/documentation/src/app/pages/chip/chip.page.ts +158 -0
- package/projects/documentation/src/app/pages/chip/examples/appearance/chip-appearance.example.html +7 -0
- package/projects/documentation/src/app/pages/chip/examples/appearance/chip-appearance.example.ts +10 -0
- package/projects/documentation/src/app/pages/chip/examples/more/chip-more.example.html +13 -0
- package/projects/documentation/src/app/pages/chip/examples/more/chip-more.example.ts +17 -0
- package/projects/documentation/src/app/pages/chip/examples/radius/chip-radius.example.html +9 -0
- package/projects/documentation/src/app/pages/chip/examples/radius/chip-radius.example.ts +10 -0
- package/projects/documentation/src/app/pages/chip/examples/sizes/chip-sizes.example.html +6 -0
- package/projects/documentation/src/app/pages/chip/examples/sizes/chip-sizes.example.ts +10 -0
- package/projects/documentation/src/app/pages/chip/examples/variant/chip-variant.example.html +8 -0
- package/projects/documentation/src/app/pages/chip/examples/variant/chip-variant.example.ts +10 -0
- package/projects/documentation/src/app/pages/datepicker/datepicker.page.html +75 -0
- package/projects/documentation/src/app/pages/datepicker/datepicker.page.ts +181 -0
- package/projects/documentation/src/app/pages/datepicker/examples/appearance/datepicker-appearance.example.html +29 -0
- package/projects/documentation/src/app/pages/datepicker/examples/appearance/datepicker-appearance.example.ts +10 -0
- package/projects/documentation/src/app/pages/datepicker/examples/basic/datepicker-basic.example.html +12 -0
- package/projects/documentation/src/app/pages/datepicker/examples/basic/datepicker-basic.example.ts +12 -0
- package/projects/documentation/src/app/pages/datepicker/examples/footer/datepicker-footer.example.html +23 -0
- package/projects/documentation/src/app/pages/datepicker/examples/footer/datepicker-footer.example.ts +17 -0
- package/projects/documentation/src/app/pages/datepicker/examples/format/datepicker-format.example.html +30 -0
- package/projects/documentation/src/app/pages/datepicker/examples/format/datepicker-format.example.ts +13 -0
- package/projects/documentation/src/app/pages/datepicker/examples/placement/datepicker-placement.example.html +24 -0
- package/projects/documentation/src/app/pages/datepicker/examples/placement/datepicker-placement.example.ts +10 -0
- package/projects/documentation/src/app/pages/datepicker/examples/slots/datepicker-slots.example.html +19 -0
- package/projects/documentation/src/app/pages/datepicker/examples/slots/datepicker-slots.example.ts +10 -0
- package/projects/documentation/src/app/pages/datepicker/examples/states/datepicker-states.example.html +28 -0
- package/projects/documentation/src/app/pages/datepicker/examples/states/datepicker-states.example.ts +12 -0
- package/projects/documentation/src/app/pages/icon/icon.page.html +15 -0
- package/projects/documentation/src/app/pages/icon/icon.page.ts +60 -0
- package/projects/documentation/src/app/pages/input/examples/appearance/input-appearance.example.html +27 -0
- package/projects/documentation/src/app/pages/input/examples/appearance/input-appearance.example.ts +10 -0
- package/projects/documentation/src/app/pages/input/examples/basic/input-basic.example.html +13 -0
- package/projects/documentation/src/app/pages/input/examples/basic/input-basic.example.ts +13 -0
- package/projects/documentation/src/app/pages/input/examples/mask/input-mask.example.html +31 -0
- package/projects/documentation/src/app/pages/input/examples/mask/input-mask.example.ts +19 -0
- package/projects/documentation/src/app/pages/input/examples/more/input-more.example.html +68 -0
- package/projects/documentation/src/app/pages/input/examples/more/input-more.example.ts +18 -0
- package/projects/documentation/src/app/pages/input/examples/slots/input-slots.example.html +52 -0
- package/projects/documentation/src/app/pages/input/examples/slots/input-slots.example.ts +10 -0
- package/projects/documentation/src/app/pages/input/examples/states/input-states.example.html +29 -0
- package/projects/documentation/src/app/pages/input/examples/states/input-states.example.ts +10 -0
- package/projects/documentation/src/app/pages/input/input.page.html +65 -0
- package/projects/documentation/src/app/pages/input/input.page.ts +170 -0
- package/projects/documentation/src/app/pages/menu/examples/basic/menu-basic.example.html +5 -0
- package/projects/documentation/src/app/pages/menu/examples/basic/menu-basic.example.ts +17 -0
- package/projects/documentation/src/app/pages/menu/examples/custom-template/menu-custom-template.example.html +35 -0
- package/projects/documentation/src/app/pages/menu/examples/custom-template/menu-custom-template.example.ts +57 -0
- package/projects/documentation/src/app/pages/menu/examples/placement/menu-placement.example.html +12 -0
- package/projects/documentation/src/app/pages/menu/examples/placement/menu-placement.example.ts +16 -0
- package/projects/documentation/src/app/pages/menu/menu.page.html +35 -0
- package/projects/documentation/src/app/pages/menu/menu.page.ts +149 -0
- package/projects/documentation/src/app/pages/modal/examples/appearance/modal-appearance.example.html +18 -0
- package/projects/documentation/src/app/pages/modal/examples/appearance/modal-appearance.example.ts +21 -0
- package/projects/documentation/src/app/pages/modal/examples/basic/modal-basic.example.html +8 -0
- package/projects/documentation/src/app/pages/modal/examples/basic/modal-basic.example.ts +12 -0
- package/projects/documentation/src/app/pages/modal/examples/close-behavior/modal-close-behavior.example.html +44 -0
- package/projects/documentation/src/app/pages/modal/examples/close-behavior/modal-close-behavior.example.ts +14 -0
- package/projects/documentation/src/app/pages/modal/examples/custom-style/modal-custom-style.example.html +36 -0
- package/projects/documentation/src/app/pages/modal/examples/custom-style/modal-custom-style.example.ts +12 -0
- package/projects/documentation/src/app/pages/modal/examples/overlay/modal-overlay.example.html +29 -0
- package/projects/documentation/src/app/pages/modal/examples/overlay/modal-overlay.example.ts +14 -0
- package/projects/documentation/src/app/pages/modal/examples/radius-spacing/modal-radius-spacing.example.html +27 -0
- package/projects/documentation/src/app/pages/modal/examples/radius-spacing/modal-radius-spacing.example.ts +27 -0
- package/projects/documentation/src/app/pages/modal/examples/scroll/modal-scroll.example.html +14 -0
- package/projects/documentation/src/app/pages/modal/examples/scroll/modal-scroll.example.ts +13 -0
- package/projects/documentation/src/app/pages/modal/examples/size/modal-size.example.html +17 -0
- package/projects/documentation/src/app/pages/modal/examples/size/modal-size.example.ts +21 -0
- package/projects/documentation/src/app/pages/modal/examples/slots/modal-slots.example.html +30 -0
- package/projects/documentation/src/app/pages/modal/examples/slots/modal-slots.example.ts +12 -0
- package/projects/documentation/src/app/pages/modal/examples/width/modal-width.example.html +23 -0
- package/projects/documentation/src/app/pages/modal/examples/width/modal-width.example.ts +13 -0
- package/projects/documentation/src/app/pages/modal/modal.page.html +105 -0
- package/projects/documentation/src/app/pages/modal/modal.page.ts +257 -0
- package/projects/documentation/src/app/pages/number-input/examples/appearance/number-input-appearance.example.html +30 -0
- package/projects/documentation/src/app/pages/number-input/examples/appearance/number-input-appearance.example.ts +10 -0
- package/projects/documentation/src/app/pages/number-input/examples/basic/number-input-basic.example.html +12 -0
- package/projects/documentation/src/app/pages/number-input/examples/basic/number-input-basic.example.ts +13 -0
- package/projects/documentation/src/app/pages/number-input/examples/limits/number-input-limits.example.html +30 -0
- package/projects/documentation/src/app/pages/number-input/examples/limits/number-input-limits.example.ts +14 -0
- package/projects/documentation/src/app/pages/number-input/examples/slots/number-input-slots.example.html +49 -0
- package/projects/documentation/src/app/pages/number-input/examples/slots/number-input-slots.example.ts +10 -0
- package/projects/documentation/src/app/pages/number-input/examples/states/number-input-states.example.html +21 -0
- package/projects/documentation/src/app/pages/number-input/examples/states/number-input-states.example.ts +10 -0
- package/projects/documentation/src/app/pages/number-input/number-input.page.html +55 -0
- package/projects/documentation/src/app/pages/number-input/number-input.page.ts +142 -0
- package/projects/documentation/src/app/pages/select/examples/appearance/select-appearance.example.html +32 -0
- package/projects/documentation/src/app/pages/select/examples/appearance/select-appearance.example.ts +15 -0
- package/projects/documentation/src/app/pages/select/examples/basic/select-basic.example.html +13 -0
- package/projects/documentation/src/app/pages/select/examples/basic/select-basic.example.ts +20 -0
- package/projects/documentation/src/app/pages/select/examples/multiple/select-multiple.example.html +24 -0
- package/projects/documentation/src/app/pages/select/examples/multiple/select-multiple.example.ts +59 -0
- package/projects/documentation/src/app/pages/select/examples/placement/select-placement.example.html +20 -0
- package/projects/documentation/src/app/pages/select/examples/placement/select-placement.example.ts +20 -0
- package/projects/documentation/src/app/pages/select/examples/search/select-search.example.html +13 -0
- package/projects/documentation/src/app/pages/select/examples/search/select-search.example.ts +22 -0
- package/projects/documentation/src/app/pages/select/examples/slots/select-slots.example.html +44 -0
- package/projects/documentation/src/app/pages/select/examples/slots/select-slots.example.ts +15 -0
- package/projects/documentation/src/app/pages/select/examples/states/select-states.example.html +31 -0
- package/projects/documentation/src/app/pages/select/examples/states/select-states.example.ts +12 -0
- package/projects/documentation/src/app/pages/select/select.page.html +75 -0
- package/projects/documentation/src/app/pages/select/select.page.ts +195 -0
- package/projects/documentation/src/app/pages/table/examples/cell-actions/table-cell-actions.example.html +14 -0
- package/projects/documentation/src/app/pages/table/examples/cell-actions/table-cell-actions.example.ts +25 -0
- package/projects/documentation/src/app/pages/table/examples/cell-badge/table-cell-badge.example.html +12 -0
- package/projects/documentation/src/app/pages/table/examples/cell-badge/table-cell-badge.example.ts +21 -0
- package/projects/documentation/src/app/pages/table/examples/cell-profile/table-cell-profile.example.html +29 -0
- package/projects/documentation/src/app/pages/table/examples/cell-profile/table-cell-profile.example.ts +20 -0
- package/projects/documentation/src/app/pages/table/examples/custom-body/table-custom-body.example.html +39 -0
- package/projects/documentation/src/app/pages/table/examples/custom-body/table-custom-body.example.ts +21 -0
- package/projects/documentation/src/app/pages/table/examples/custom-sizes/table-custom-sizes.example.html +7 -0
- package/projects/documentation/src/app/pages/table/examples/custom-sizes/table-custom-sizes.example.ts +21 -0
- package/projects/documentation/src/app/pages/table/examples/dynamic-style/table-dynamic-style.example.html +3 -0
- package/projects/documentation/src/app/pages/table/examples/dynamic-style/table-dynamic-style.example.ts +41 -0
- package/projects/documentation/src/app/pages/table/examples/empty/table-empty.example.html +43 -0
- package/projects/documentation/src/app/pages/table/examples/empty/table-empty.example.ts +21 -0
- package/projects/documentation/src/app/pages/table/examples/expanded/table-expanded.example.html +36 -0
- package/projects/documentation/src/app/pages/table/examples/expanded/table-expanded.example.ts +34 -0
- package/projects/documentation/src/app/pages/table/examples/heatmap/table-heatmap.example.html +8 -0
- package/projects/documentation/src/app/pages/table/examples/heatmap/table-heatmap.example.ts +52 -0
- package/projects/documentation/src/app/pages/table/examples/inline-edit/table-inline-edit.example.html +53 -0
- package/projects/documentation/src/app/pages/table/examples/inline-edit/table-inline-edit.example.ts +50 -0
- package/projects/documentation/src/app/pages/table/examples/nested/table-nested.example.html +23 -0
- package/projects/documentation/src/app/pages/table/examples/nested/table-nested.example.ts +42 -0
- package/projects/documentation/src/app/pages/table/examples/pagination/table-pagination.example.html +20 -0
- package/projects/documentation/src/app/pages/table/examples/pagination/table-pagination.example.ts +21 -0
- package/projects/documentation/src/app/pages/table/table.page.html +125 -0
- package/projects/documentation/src/app/pages/table/table.page.ts +261 -0
- package/projects/documentation/src/app/pages/tabs/examples/advanced-dynamic/tabs-advanced-dynamic.example.html +13 -0
- package/projects/documentation/src/app/pages/tabs/examples/advanced-dynamic/tabs-advanced-dynamic.example.ts +27 -0
- package/projects/documentation/src/app/pages/tabs/examples/advanced-form/tabs-advanced-form.example.html +27 -0
- package/projects/documentation/src/app/pages/tabs/examples/advanced-form/tabs-advanced-form.example.ts +36 -0
- package/projects/documentation/src/app/pages/tabs/examples/advanced-theme/tabs-advanced-theme.example.html +5 -0
- package/projects/documentation/src/app/pages/tabs/examples/advanced-theme/tabs-advanced-theme.example.ts +20 -0
- package/projects/documentation/src/app/pages/tabs/examples/appearance/tabs-appearance.example.html +6 -0
- package/projects/documentation/src/app/pages/tabs/examples/appearance/tabs-appearance.example.ts +13 -0
- package/projects/documentation/src/app/pages/tabs/examples/basic/tabs-basic.example.html +13 -0
- package/projects/documentation/src/app/pages/tabs/examples/basic/tabs-basic.example.ts +13 -0
- package/projects/documentation/src/app/pages/tabs/examples/custom-style/tabs-custom-style.example.html +19 -0
- package/projects/documentation/src/app/pages/tabs/examples/custom-style/tabs-custom-style.example.ts +12 -0
- package/projects/documentation/src/app/pages/tabs/examples/events/tabs-events.example.html +16 -0
- package/projects/documentation/src/app/pages/tabs/examples/events/tabs-events.example.ts +23 -0
- package/projects/documentation/src/app/pages/tabs/examples/fluid/tabs-fluid.example.html +5 -0
- package/projects/documentation/src/app/pages/tabs/examples/fluid/tabs-fluid.example.ts +12 -0
- package/projects/documentation/src/app/pages/tabs/examples/no-body/tabs-no-body.example.html +6 -0
- package/projects/documentation/src/app/pages/tabs/examples/no-body/tabs-no-body.example.ts +12 -0
- package/projects/documentation/src/app/pages/tabs/examples/radius/tabs-radius.example.html +6 -0
- package/projects/documentation/src/app/pages/tabs/examples/radius/tabs-radius.example.ts +13 -0
- package/projects/documentation/src/app/pages/tabs/examples/scroll/tabs-scroll.example.html +20 -0
- package/projects/documentation/src/app/pages/tabs/examples/scroll/tabs-scroll.example.ts +30 -0
- package/projects/documentation/src/app/pages/tabs/examples/scroll-icon/tabs-scroll-icon.example.html +16 -0
- package/projects/documentation/src/app/pages/tabs/examples/scroll-icon/tabs-scroll-icon.example.ts +26 -0
- package/projects/documentation/src/app/pages/tabs/examples/scroll-slot/tabs-scroll-slot.example.html +22 -0
- package/projects/documentation/src/app/pages/tabs/examples/scroll-slot/tabs-scroll-slot.example.ts +26 -0
- package/projects/documentation/src/app/pages/tabs/examples/size/tabs-size.example.html +6 -0
- package/projects/documentation/src/app/pages/tabs/examples/size/tabs-size.example.ts +13 -0
- package/projects/documentation/src/app/pages/tabs/examples/slots/tabs-slots.example.html +25 -0
- package/projects/documentation/src/app/pages/tabs/examples/slots/tabs-slots.example.ts +10 -0
- package/projects/documentation/src/app/pages/tabs/examples/spacing/tabs-spacing.example.html +6 -0
- package/projects/documentation/src/app/pages/tabs/examples/spacing/tabs-spacing.example.ts +13 -0
- package/projects/documentation/src/app/pages/tabs/tabs.page.html +165 -0
- package/projects/documentation/src/app/pages/tabs/tabs.page.ts +340 -0
- package/projects/documentation/src/app/routes/app.routes.server.ts +8 -0
- package/projects/documentation/src/app/routes/app.routes.ts +87 -0
- package/projects/documentation/src/app/services/doc-customize.service.ts +107 -0
- package/projects/documentation/src/app/utils/highlight.pipe.ts +43 -0
- package/projects/documentation/src/index.html +13 -0
- package/projects/documentation/src/main.server.ts +7 -0
- package/projects/documentation/src/main.ts +5 -0
- package/projects/documentation/src/server.ts +47 -0
- package/projects/documentation/src/styles.scss +7 -0
- package/projects/documentation/tsconfig.app.json +11 -0
- package/projects/documentation/tsconfig.spec.json +10 -0
- package/tsconfig.json +6 -3
- package/.nvmrc +0 -1
|
@@ -1,21 +1,570 @@
|
|
|
1
|
+
import { Component, signal } from '@angular/core';
|
|
1
2
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import {
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
4
|
+
import { DasarTabs, DasarTabsComponent } from './dasar-tabs';
|
|
5
|
+
import { ScaleAttributeType } from '../../models/type.model';
|
|
6
|
+
import { DASAR_THEME_PROVIDER } from '../dasar-theme-provider/dasar-theme-provider';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
standalone: true,
|
|
10
|
+
imports: [DasarTabsComponent],
|
|
11
|
+
template: `
|
|
12
|
+
<dasar-tabs
|
|
13
|
+
[items]="items()"
|
|
14
|
+
[size]="size()"
|
|
15
|
+
[spacing]="spacing()"
|
|
16
|
+
[radius]="radius()"
|
|
17
|
+
[appearance]="appearance()"
|
|
18
|
+
[fluid]="fluid()"
|
|
19
|
+
[active-index]="active()"
|
|
20
|
+
container-class="my-container"
|
|
21
|
+
list-class="my-list"
|
|
22
|
+
content-class="my-content"
|
|
23
|
+
[container-style]="{ 'margin-top': '3px' }"
|
|
24
|
+
(onTabsChange)="active.set($event); changed.set(changed() + 1)"
|
|
25
|
+
(onTabsClick)="clicked.set(clicked() + 1)"
|
|
26
|
+
>
|
|
27
|
+
<p class="body">Body {{ active() }}</p>
|
|
28
|
+
</dasar-tabs>
|
|
29
|
+
`,
|
|
30
|
+
})
|
|
31
|
+
class ItemsHost {
|
|
32
|
+
items = signal(['One', 'Two', 'Three']);
|
|
33
|
+
size = signal<ScaleAttributeType>('md');
|
|
34
|
+
spacing = signal<'compact' | 'normal'>('normal');
|
|
35
|
+
radius = signal<ScaleAttributeType>('md');
|
|
36
|
+
appearance = signal<'solid' | 'subtle' | 'outline'>('subtle');
|
|
37
|
+
fluid = signal(false);
|
|
38
|
+
active = signal(0);
|
|
39
|
+
changed = signal(0);
|
|
40
|
+
clicked = signal(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Component({
|
|
44
|
+
standalone: true,
|
|
45
|
+
imports: [DasarTabsComponent],
|
|
46
|
+
template: `
|
|
47
|
+
<dasar-tabs>
|
|
48
|
+
<ng-template tab-item-slot><span class="slot-label">A</span></ng-template>
|
|
49
|
+
<ng-template tab-item-slot><span class="slot-label">B</span></ng-template>
|
|
50
|
+
<ng-template tab-item-slot><span class="slot-label">C</span></ng-template>
|
|
51
|
+
</dasar-tabs>
|
|
52
|
+
`,
|
|
53
|
+
})
|
|
54
|
+
class SlotHost {}
|
|
55
|
+
|
|
56
|
+
@Component({
|
|
57
|
+
selector: 'app-empty-body-host',
|
|
58
|
+
standalone: true,
|
|
59
|
+
imports: [DasarTabsComponent],
|
|
60
|
+
template: `<dasar-tabs [items]="['A', 'B']" />`,
|
|
61
|
+
})
|
|
62
|
+
class EmptyBodyHost {}
|
|
63
|
+
|
|
64
|
+
@Component({
|
|
65
|
+
selector: 'app-theme-host',
|
|
66
|
+
standalone: true,
|
|
67
|
+
imports: [DasarTabsComponent],
|
|
68
|
+
template: `<dasar-tabs [items]="['A']" />`,
|
|
69
|
+
})
|
|
70
|
+
class ThemeHost {}
|
|
71
|
+
|
|
72
|
+
@Component({
|
|
73
|
+
standalone: true,
|
|
74
|
+
imports: [DasarTabsComponent],
|
|
75
|
+
template: `
|
|
76
|
+
<dasar-tabs
|
|
77
|
+
[items]="['Alpha', 'Beta', 'Gamma']"
|
|
78
|
+
scroll-left-icon-name="arrow-left"
|
|
79
|
+
scroll-right-icon-name="arrow-right"
|
|
80
|
+
scroll-button-class="my-scroll"
|
|
81
|
+
[scroll-button-style]="{ 'margin-inline': '2px' }"
|
|
82
|
+
/>
|
|
83
|
+
`,
|
|
84
|
+
})
|
|
85
|
+
class ScrollIconHost {}
|
|
86
|
+
|
|
87
|
+
@Component({
|
|
88
|
+
standalone: true,
|
|
89
|
+
imports: [DasarTabsComponent],
|
|
90
|
+
template: `
|
|
91
|
+
<dasar-tabs [items]="['Alpha', 'Beta', 'Gamma']">
|
|
92
|
+
<ng-template tabs-scroll-left-slot><span class="my-left">Prev</span></ng-template>
|
|
93
|
+
<ng-template tabs-scroll-right-slot><span class="my-right">Next</span></ng-template>
|
|
94
|
+
</dasar-tabs>
|
|
95
|
+
`,
|
|
96
|
+
})
|
|
97
|
+
class ScrollSlotHost {}
|
|
98
|
+
|
|
99
|
+
const containerOf = (fixture: ComponentFixture<unknown>) =>
|
|
100
|
+
fixture.nativeElement.querySelector('.dasar-tabs-container') as HTMLElement;
|
|
101
|
+
const listOf = (fixture: ComponentFixture<unknown>) =>
|
|
102
|
+
fixture.nativeElement.querySelector('.dasar-tabs-list') as HTMLElement;
|
|
103
|
+
const contentOf = (fixture: ComponentFixture<unknown>) =>
|
|
104
|
+
fixture.nativeElement.querySelector('.dasar-tabs-content') as HTMLElement;
|
|
105
|
+
const triggerElementsOf = (fixture: ComponentFixture<unknown>) =>
|
|
106
|
+
Array.from(fixture.nativeElement.querySelectorAll('.dasar-tab-trigger-btn')) as HTMLElement[];
|
|
107
|
+
const wrapperOf = (fixture: ComponentFixture<unknown>) =>
|
|
108
|
+
fixture.nativeElement.querySelector('.dasar-tabs-list-wrapper') as HTMLElement;
|
|
109
|
+
const scrollButtonsOf = (fixture: ComponentFixture<unknown>) =>
|
|
110
|
+
Array.from(fixture.nativeElement.querySelectorAll('.dasar-tabs-scroll-btn')) as HTMLElement[];
|
|
111
|
+
|
|
112
|
+
const setMetrics = (el: HTMLElement, scrollWidth: number, clientWidth: number, scrollLeft = 0) => {
|
|
113
|
+
Object.defineProperty(el, 'scrollWidth', {
|
|
114
|
+
value: scrollWidth,
|
|
115
|
+
configurable: true,
|
|
116
|
+
writable: true,
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(el, 'clientWidth', {
|
|
119
|
+
value: clientWidth,
|
|
120
|
+
configurable: true,
|
|
121
|
+
writable: true,
|
|
122
|
+
});
|
|
123
|
+
Object.defineProperty(el, 'scrollLeft', {
|
|
124
|
+
value: scrollLeft,
|
|
125
|
+
configurable: true,
|
|
126
|
+
writable: true,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
class FakeResizeObserver {
|
|
131
|
+
static instances: FakeResizeObserver[] = [];
|
|
132
|
+
|
|
133
|
+
constructor(private readonly callback: () => void) {
|
|
134
|
+
FakeResizeObserver.instances.push(this);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
observe() {}
|
|
138
|
+
unobserve() {}
|
|
139
|
+
|
|
140
|
+
disconnect() {
|
|
141
|
+
const at = FakeResizeObserver.instances.indexOf(this);
|
|
142
|
+
if (at >= 0) FakeResizeObserver.instances.splice(at, 1);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
trigger() {
|
|
146
|
+
this.callback();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
3
149
|
|
|
4
150
|
describe('DasarTabs', () => {
|
|
5
151
|
let component: DasarTabs;
|
|
6
|
-
let fixture: ComponentFixture<
|
|
152
|
+
let fixture: ComponentFixture<ItemsHost>;
|
|
153
|
+
let host: ItemsHost;
|
|
154
|
+
|
|
155
|
+
const triggers = () => triggerElementsOf(fixture);
|
|
156
|
+
const clickTab = async (index: number) => {
|
|
157
|
+
(triggers()[index].querySelector('button') as HTMLElement).click();
|
|
158
|
+
await fixture.whenStable();
|
|
159
|
+
};
|
|
7
160
|
|
|
8
161
|
beforeEach(async () => {
|
|
9
162
|
await TestBed.configureTestingModule({
|
|
10
|
-
imports: [
|
|
163
|
+
imports: [ItemsHost],
|
|
11
164
|
}).compileComponents();
|
|
12
165
|
|
|
13
|
-
fixture = TestBed.createComponent(
|
|
14
|
-
|
|
166
|
+
fixture = TestBed.createComponent(ItemsHost);
|
|
167
|
+
host = fixture.componentInstance;
|
|
168
|
+
component = fixture.debugElement.children[0].componentInstance;
|
|
15
169
|
await fixture.whenStable();
|
|
16
170
|
});
|
|
17
171
|
|
|
18
172
|
it('should create', () => {
|
|
19
173
|
expect(component).toBeTruthy();
|
|
20
174
|
});
|
|
175
|
+
|
|
176
|
+
it('renders one tab trigger per item with its label', () => {
|
|
177
|
+
const buttons = triggers();
|
|
178
|
+
|
|
179
|
+
expect(buttons.length).toBe(3);
|
|
180
|
+
expect(buttons[0].textContent).toContain('One');
|
|
181
|
+
expect(buttons[1].textContent).toContain('Two');
|
|
182
|
+
expect(buttons[2].textContent).toContain('Three');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('applies the default container classes', () => {
|
|
186
|
+
expect(containerOf(fixture).classList).toContain('size-md');
|
|
187
|
+
expect(containerOf(fixture).classList).toContain('spacing-normal');
|
|
188
|
+
expect(containerOf(fixture).classList).toContain('radius-md');
|
|
189
|
+
expect(containerOf(fixture).classList).toContain('appearance-subtle');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('size drives the container class and the button size', async () => {
|
|
193
|
+
host.size.set('lg');
|
|
194
|
+
await fixture.whenStable();
|
|
195
|
+
|
|
196
|
+
expect(containerOf(fixture).classList).toContain('size-lg');
|
|
197
|
+
expect(fixture.debugElement.query(By.css('dasar-button')).componentInstance.size).toBe('lg');
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it('maps the clamped sizes onto the button size scale', async () => {
|
|
201
|
+
host.size.set('none');
|
|
202
|
+
await fixture.whenStable();
|
|
203
|
+
expect(containerOf(fixture).classList).toContain('size-none');
|
|
204
|
+
expect(fixture.debugElement.query(By.css('dasar-button')).componentInstance.size).toBe('xs');
|
|
205
|
+
|
|
206
|
+
host.size.set('full');
|
|
207
|
+
await fixture.whenStable();
|
|
208
|
+
expect(containerOf(fixture).classList).toContain('size-full');
|
|
209
|
+
expect(fixture.debugElement.query(By.css('dasar-button')).componentInstance.size).toBe('xl');
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('spacing drives the container class', async () => {
|
|
213
|
+
host.spacing.set('compact');
|
|
214
|
+
await fixture.whenStable();
|
|
215
|
+
|
|
216
|
+
expect(containerOf(fixture).classList).toContain('spacing-compact');
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('radius drives the container class', async () => {
|
|
220
|
+
for (const value of ['none', 'sm', 'lg', 'full'] as ScaleAttributeType[]) {
|
|
221
|
+
host.radius.set(value);
|
|
222
|
+
await fixture.whenStable();
|
|
223
|
+
|
|
224
|
+
expect(containerOf(fixture).classList).toContain(`radius-${value}`);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('passes radius none to the buttons in the outline appearance', async () => {
|
|
229
|
+
host.appearance.set('outline');
|
|
230
|
+
await fixture.whenStable();
|
|
231
|
+
|
|
232
|
+
expect(containerOf(fixture).classList).toContain('appearance-outline');
|
|
233
|
+
const buttonDebugs = fixture.debugElement.queryAll(By.css('dasar-tab-trigger-btn'));
|
|
234
|
+
for (const debug of buttonDebugs) {
|
|
235
|
+
expect(debug.componentInstance.radius).toBe('none');
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('selecting a tab updates the active state and emits both outputs', async () => {
|
|
240
|
+
await clickTab(1);
|
|
241
|
+
|
|
242
|
+
expect(host.active()).toBe(1);
|
|
243
|
+
expect(host.changed()).toBe(1);
|
|
244
|
+
expect(host.clicked()).toBe(1);
|
|
245
|
+
expect(triggers()[1].classList).toContain('active');
|
|
246
|
+
expect(triggers()[0].classList).not.toContain('active');
|
|
247
|
+
expect(triggers()[1].getAttribute('aria-selected')).toBe('true');
|
|
248
|
+
expect(triggers()[0].getAttribute('aria-selected')).toBe('false');
|
|
249
|
+
expect(contentOf(fixture).textContent).toContain('Body 1');
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('clicking the active tab only emits onTabsClick', async () => {
|
|
253
|
+
await clickTab(1);
|
|
254
|
+
await clickTab(1);
|
|
255
|
+
|
|
256
|
+
expect(host.clicked()).toBe(2);
|
|
257
|
+
expect(host.changed()).toBe(1);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('keeps the body rendered when content is projected', () => {
|
|
261
|
+
expect(contentOf(fixture).querySelector('.body')).toBeTruthy();
|
|
262
|
+
expect(contentOf(fixture).matches(':empty')).toBe(false);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('fluid adds the fluid class', async () => {
|
|
266
|
+
host.fluid.set(true);
|
|
267
|
+
await fixture.whenStable();
|
|
268
|
+
|
|
269
|
+
expect(containerOf(fixture).classList).toContain('fluid');
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it('applies the class and style inputs to the right elements', () => {
|
|
273
|
+
expect(containerOf(fixture).classList).toContain('my-container');
|
|
274
|
+
expect(containerOf(fixture).style.marginTop).toBe('3px');
|
|
275
|
+
expect(listOf(fixture).classList).toContain('my-list');
|
|
276
|
+
expect(contentOf(fixture).classList).toContain('my-content');
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('exposes the tablist, tab and tabpanel roles', () => {
|
|
280
|
+
expect(listOf(fixture).getAttribute('role')).toBe('tablist');
|
|
281
|
+
for (const trigger of triggers()) {
|
|
282
|
+
expect(trigger.getAttribute('role')).toBe('tab');
|
|
283
|
+
}
|
|
284
|
+
expect(contentOf(fixture).getAttribute('role')).toBe('tabpanel');
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
describe('DasarTabs with tab-item-slot', () => {
|
|
289
|
+
let fixture: ComponentFixture<SlotHost>;
|
|
290
|
+
|
|
291
|
+
beforeEach(async () => {
|
|
292
|
+
await TestBed.configureTestingModule({
|
|
293
|
+
imports: [SlotHost],
|
|
294
|
+
}).compileComponents();
|
|
295
|
+
|
|
296
|
+
fixture = TestBed.createComponent(SlotHost);
|
|
297
|
+
await fixture.whenStable();
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('renders one tab trigger per tab-item-slot with the slot template', () => {
|
|
301
|
+
const labels = Array.from(
|
|
302
|
+
fixture.nativeElement.querySelectorAll(
|
|
303
|
+
'.dasar-tab-trigger-btn .slot-label',
|
|
304
|
+
) as NodeListOf<HTMLElement>,
|
|
305
|
+
);
|
|
306
|
+
expect(labels.map((label) => label.textContent)).toEqual(['A', 'B', 'C']);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
describe('DasarTabs without a projected body', () => {
|
|
311
|
+
let fixture: ComponentFixture<EmptyBodyHost>;
|
|
312
|
+
|
|
313
|
+
beforeEach(async () => {
|
|
314
|
+
await TestBed.configureTestingModule({
|
|
315
|
+
imports: [EmptyBodyHost],
|
|
316
|
+
}).compileComponents();
|
|
317
|
+
|
|
318
|
+
fixture = TestBed.createComponent(EmptyBodyHost);
|
|
319
|
+
await fixture.whenStable();
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('removes the body padding when no content is projected', () => {
|
|
323
|
+
expect(contentOf(fixture).matches(':empty')).toBe(true);
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
describe('DasarTabs theme defaults', () => {
|
|
328
|
+
let fixture: ComponentFixture<ThemeHost>;
|
|
329
|
+
let component: DasarTabs;
|
|
330
|
+
|
|
331
|
+
beforeEach(async () => {
|
|
332
|
+
await TestBed.configureTestingModule({
|
|
333
|
+
imports: [ThemeHost],
|
|
334
|
+
providers: [
|
|
335
|
+
{
|
|
336
|
+
provide: DASAR_THEME_PROVIDER,
|
|
337
|
+
useValue: {
|
|
338
|
+
componentConfig: {
|
|
339
|
+
tabs: {
|
|
340
|
+
size: 'lg',
|
|
341
|
+
spacing: 'compact',
|
|
342
|
+
appearance: 'outline',
|
|
343
|
+
scrollLeftIconName: 'arrow-left',
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
}).compileComponents();
|
|
350
|
+
|
|
351
|
+
fixture = TestBed.createComponent(ThemeHost);
|
|
352
|
+
component = fixture.debugElement.children[0].componentInstance;
|
|
353
|
+
await fixture.whenStable();
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('reads the defaults from the component config', () => {
|
|
357
|
+
const container = containerOf(fixture);
|
|
358
|
+
|
|
359
|
+
expect(container.classList).toContain('size-lg');
|
|
360
|
+
expect(container.classList).toContain('spacing-compact');
|
|
361
|
+
expect(container.classList).toContain('appearance-outline');
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('reads the scroll icon default from the component config', async () => {
|
|
365
|
+
setMetrics(listOf(fixture), 600, 300);
|
|
366
|
+
component.updateScrollState();
|
|
367
|
+
await fixture.whenStable();
|
|
368
|
+
|
|
369
|
+
const icons = fixture.debugElement.queryAll(By.css('.dasar-tabs-scroll-btn dasar-icon'));
|
|
370
|
+
expect(icons.map((icon) => icon.componentInstance.name)).toEqual([
|
|
371
|
+
'arrow-left',
|
|
372
|
+
'chevron-right',
|
|
373
|
+
]);
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
describe('DasarTabs scroll arrows', () => {
|
|
378
|
+
let fixture: ComponentFixture<ItemsHost>;
|
|
379
|
+
let component: DasarTabs;
|
|
380
|
+
let originalResizeObserver: unknown;
|
|
381
|
+
let originalScrollIntoView: unknown;
|
|
382
|
+
let scrollIntoViewTargets: Element[] = [];
|
|
383
|
+
|
|
384
|
+
const triggers = () => triggerElementsOf(fixture);
|
|
385
|
+
const clickTab = async (index: number) => {
|
|
386
|
+
(triggers()[index].querySelector('button') as HTMLElement).click();
|
|
387
|
+
await fixture.whenStable();
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const measure = async (scrollWidth: number, clientWidth: number, scrollLeft = 0) => {
|
|
391
|
+
setMetrics(listOf(fixture), scrollWidth, clientWidth, scrollLeft);
|
|
392
|
+
component.updateScrollState();
|
|
393
|
+
await fixture.whenStable();
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
beforeAll(() => {
|
|
397
|
+
originalResizeObserver = (globalThis as any).ResizeObserver;
|
|
398
|
+
(globalThis as any).ResizeObserver = FakeResizeObserver;
|
|
399
|
+
originalScrollIntoView = (Element.prototype as any).scrollIntoView;
|
|
400
|
+
(Element.prototype as any).scrollIntoView = function (this: Element) {
|
|
401
|
+
scrollIntoViewTargets.push(this);
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
afterAll(() => {
|
|
406
|
+
if (originalResizeObserver === undefined) delete (globalThis as any).ResizeObserver;
|
|
407
|
+
else (globalThis as any).ResizeObserver = originalResizeObserver;
|
|
408
|
+
if (originalScrollIntoView === undefined) delete (Element.prototype as any).scrollIntoView;
|
|
409
|
+
else (Element.prototype as any).scrollIntoView = originalScrollIntoView;
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
beforeEach(async () => {
|
|
413
|
+
scrollIntoViewTargets = [];
|
|
414
|
+
await TestBed.configureTestingModule({
|
|
415
|
+
imports: [ItemsHost],
|
|
416
|
+
}).compileComponents();
|
|
417
|
+
|
|
418
|
+
fixture = TestBed.createComponent(ItemsHost);
|
|
419
|
+
component = fixture.debugElement.children[0].componentInstance;
|
|
420
|
+
await fixture.whenStable();
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it('starts with no scroll arrows before any measurement', () => {
|
|
424
|
+
expect(scrollButtonsOf(fixture).length).toBe(0);
|
|
425
|
+
expect(wrapperOf(fixture).classList).not.toContain('overflowing');
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
it('does not render the arrows when the strip fits the container', async () => {
|
|
429
|
+
await measure(300, 300);
|
|
430
|
+
|
|
431
|
+
expect(scrollButtonsOf(fixture).length).toBe(0);
|
|
432
|
+
expect(wrapperOf(fixture).classList).not.toContain('overflowing');
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('renders both arrows with the left one disabled at the start', async () => {
|
|
436
|
+
await measure(600, 300);
|
|
437
|
+
|
|
438
|
+
const buttons = scrollButtonsOf(fixture);
|
|
439
|
+
expect(buttons.length).toBe(2);
|
|
440
|
+
expect(wrapperOf(fixture).classList).toContain('overflowing');
|
|
441
|
+
expect(wrapperOf(fixture).classList).toContain('can-scroll-right');
|
|
442
|
+
expect(wrapperOf(fixture).classList).not.toContain('can-scroll-left');
|
|
443
|
+
expect((buttons[0].querySelector('button') as HTMLButtonElement).disabled).toBe(true);
|
|
444
|
+
expect((buttons[1].querySelector('button') as HTMLButtonElement).disabled).toBe(false);
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it('enables both arrows in the middle of the scroll range', async () => {
|
|
448
|
+
await measure(600, 300, 150);
|
|
449
|
+
|
|
450
|
+
const buttons = scrollButtonsOf(fixture);
|
|
451
|
+
expect((buttons[0].querySelector('button') as HTMLButtonElement).disabled).toBe(false);
|
|
452
|
+
expect((buttons[1].querySelector('button') as HTMLButtonElement).disabled).toBe(false);
|
|
453
|
+
expect(wrapperOf(fixture).classList).toContain('can-scroll-left');
|
|
454
|
+
expect(wrapperOf(fixture).classList).toContain('can-scroll-right');
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it('disables the right arrow at the end of the scroll range', async () => {
|
|
458
|
+
await measure(600, 300, 300);
|
|
459
|
+
|
|
460
|
+
const buttons = scrollButtonsOf(fixture);
|
|
461
|
+
expect((buttons[0].querySelector('button') as HTMLButtonElement).disabled).toBe(false);
|
|
462
|
+
expect((buttons[1].querySelector('button') as HTMLButtonElement).disabled).toBe(true);
|
|
463
|
+
expect(wrapperOf(fixture).classList).not.toContain('can-scroll-right');
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
it('scrolls by 80 percent of the visible width', async () => {
|
|
467
|
+
await measure(600, 300, 150);
|
|
468
|
+
const calls: ScrollToOptions[] = [];
|
|
469
|
+
(listOf(fixture) as any).scrollBy = (options: ScrollToOptions) => calls.push(options);
|
|
470
|
+
|
|
471
|
+
(scrollButtonsOf(fixture)[1].querySelector('button') as HTMLElement).click();
|
|
472
|
+
await fixture.whenStable();
|
|
473
|
+
|
|
474
|
+
expect(calls).toEqual([{ left: 240, behavior: 'smooth' }]);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it('removes the arrows once the strip fits again', async () => {
|
|
478
|
+
await measure(600, 300);
|
|
479
|
+
expect(scrollButtonsOf(fixture).length).toBe(2);
|
|
480
|
+
|
|
481
|
+
await measure(300, 300);
|
|
482
|
+
expect(scrollButtonsOf(fixture).length).toBe(0);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it('attaches a resize observer to the strip', () => {
|
|
486
|
+
expect(FakeResizeObserver.instances.length).toBeGreaterThan(0);
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it('shows the default chevron icons in the arrows', async () => {
|
|
490
|
+
await measure(600, 300);
|
|
491
|
+
|
|
492
|
+
const icons = fixture.debugElement.queryAll(By.css('.dasar-tabs-scroll-btn dasar-icon'));
|
|
493
|
+
expect(icons.map((icon) => icon.componentInstance.name)).toEqual([
|
|
494
|
+
'chevron-left',
|
|
495
|
+
'chevron-right',
|
|
496
|
+
]);
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
it('labels the arrows and keeps them out of the tablist', async () => {
|
|
500
|
+
await measure(600, 300);
|
|
501
|
+
|
|
502
|
+
const buttons = scrollButtonsOf(fixture);
|
|
503
|
+
expect(buttons[0].getAttribute('aria-label')).toBe('Scroll tabs left');
|
|
504
|
+
expect(buttons[1].getAttribute('aria-label')).toBe('Scroll tabs right');
|
|
505
|
+
expect(buttons[0].getAttribute('role')).toBeNull();
|
|
506
|
+
expect(buttons[1].getAttribute('role')).toBeNull();
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
it('scrolls the newly selected tab into view', async () => {
|
|
510
|
+
await clickTab(1);
|
|
511
|
+
|
|
512
|
+
expect(scrollIntoViewTargets).toContain(triggers()[1]);
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
describe('DasarTabs custom scroll icons', () => {
|
|
517
|
+
let fixture: ComponentFixture<ScrollIconHost>;
|
|
518
|
+
let component: DasarTabs;
|
|
519
|
+
|
|
520
|
+
beforeEach(async () => {
|
|
521
|
+
await TestBed.configureTestingModule({
|
|
522
|
+
imports: [ScrollIconHost],
|
|
523
|
+
}).compileComponents();
|
|
524
|
+
|
|
525
|
+
fixture = TestBed.createComponent(ScrollIconHost);
|
|
526
|
+
component = fixture.debugElement.children[0].componentInstance;
|
|
527
|
+
await fixture.whenStable();
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
it('uses the icon name inputs and the scroll button class and style', async () => {
|
|
531
|
+
setMetrics(listOf(fixture), 600, 300);
|
|
532
|
+
component.updateScrollState();
|
|
533
|
+
await fixture.whenStable();
|
|
534
|
+
|
|
535
|
+
const icons = fixture.debugElement.queryAll(By.css('.dasar-tabs-scroll-btn dasar-icon'));
|
|
536
|
+
expect(icons.map((icon) => icon.componentInstance.name)).toEqual(['arrow-left', 'arrow-right']);
|
|
537
|
+
|
|
538
|
+
const buttons = scrollButtonsOf(fixture);
|
|
539
|
+
expect(buttons[0].classList).toContain('my-scroll');
|
|
540
|
+
expect(buttons[0].style.marginInline).toBe('2px');
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
describe('DasarTabs scroll slots', () => {
|
|
545
|
+
let fixture: ComponentFixture<ScrollSlotHost>;
|
|
546
|
+
let component: DasarTabs;
|
|
547
|
+
|
|
548
|
+
beforeEach(async () => {
|
|
549
|
+
await TestBed.configureTestingModule({
|
|
550
|
+
imports: [ScrollSlotHost],
|
|
551
|
+
}).compileComponents();
|
|
552
|
+
|
|
553
|
+
fixture = TestBed.createComponent(ScrollSlotHost);
|
|
554
|
+
component = fixture.debugElement.children[0].componentInstance;
|
|
555
|
+
await fixture.whenStable();
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
it('renders the slot templates instead of the default icons', async () => {
|
|
559
|
+
setMetrics(listOf(fixture), 600, 300);
|
|
560
|
+
component.updateScrollState();
|
|
561
|
+
await fixture.whenStable();
|
|
562
|
+
|
|
563
|
+
const buttons = scrollButtonsOf(fixture);
|
|
564
|
+
expect(buttons.length).toBe(2);
|
|
565
|
+
expect(buttons[0].querySelector('.my-left')?.textContent).toContain('Prev');
|
|
566
|
+
expect(buttons[1].querySelector('.my-right')?.textContent).toContain('Next');
|
|
567
|
+
expect(buttons[0].querySelector('dasar-icon')).toBeNull();
|
|
568
|
+
expect(buttons[1].querySelector('dasar-icon')).toBeNull();
|
|
569
|
+
});
|
|
21
570
|
});
|