@ukic/web-components 2.25.0 → 2.26.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/{helpers-80016ff7.js → helpers-94b33ab0.js} +6 -2
- package/dist/cjs/helpers-94b33ab0.js.map +1 -0
- package/dist/cjs/ic-accordion-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-accordion.cjs.entry.js +1 -1
- package/dist/cjs/ic-alert.cjs.entry.js +17 -1
- package/dist/cjs/ic-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-back-to-top.cjs.entry.js +1 -1
- package/dist/cjs/ic-badge.cjs.entry.js +1 -1
- package/dist/cjs/ic-breadcrumb-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/ic-button_3.cjs.entry.js +11 -6
- package/dist/cjs/ic-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-card.cjs.entry.js +25 -1
- package/dist/cjs/ic-card.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-checkbox-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/ic-chip.cjs.entry.js +9 -3
- package/dist/cjs/ic-chip.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-classification-banner.cjs.entry.js +12 -3
- package/dist/cjs/ic-classification-banner.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-data-row.cjs.entry.js +1 -1
- package/dist/cjs/ic-dialog.cjs.entry.js +1 -1
- package/dist/cjs/ic-divider.cjs.entry.js +1 -1
- package/dist/cjs/ic-empty-state.cjs.entry.js +20 -1
- package/dist/cjs/ic-empty-state.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-footer-link-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-footer-link.cjs.entry.js +1 -1
- package/dist/cjs/ic-footer.cjs.entry.js +1 -1
- package/dist/cjs/ic-hero.cjs.entry.js +17 -1
- package/dist/cjs/ic-hero.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-horizontal-scroll.cjs.entry.js +1 -1
- package/dist/cjs/ic-input-component-container_3.cjs.entry.js +1 -1
- package/dist/cjs/ic-input-label_2.cjs.entry.js +1 -1
- package/dist/cjs/ic-link.cjs.entry.js +1 -1
- package/dist/cjs/ic-menu-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-menu-item.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-button.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-item.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-menu.cjs.entry.js +1 -1
- package/dist/cjs/ic-page-header.cjs.entry.js +1 -1
- package/dist/cjs/ic-pagination-item.cjs.entry.js +1 -1
- package/dist/cjs/ic-pagination.cjs.entry.js +1 -1
- package/dist/cjs/ic-popover-menu.cjs.entry.js +1 -1
- package/dist/cjs/ic-radio-group.cjs.entry.js +41 -22
- package/dist/cjs/ic-radio-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-radio-option.cjs.entry.js +1 -1
- package/dist/cjs/ic-search-bar.cjs.entry.js +1 -1
- package/dist/cjs/ic-select.cjs.entry.js +1 -1
- package/dist/cjs/ic-side-navigation.cjs.entry.js +1 -1
- package/dist/cjs/ic-status-tag.cjs.entry.js +1 -1
- package/dist/cjs/ic-step.cjs.entry.js +1 -1
- package/dist/cjs/ic-stepper.cjs.entry.js +1 -1
- package/dist/cjs/ic-switch.cjs.entry.js +1 -1
- package/dist/cjs/ic-tab-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-tab-panel.cjs.entry.js +1 -1
- package/dist/cjs/ic-tab.cjs.entry.js +1 -1
- package/dist/cjs/ic-text-field.cjs.entry.js +1 -1
- package/dist/cjs/ic-theme.cjs.entry.js +1 -1
- package/dist/cjs/ic-toast.cjs.entry.js +1 -1
- package/dist/cjs/ic-toggle-button.cjs.entry.js +1 -1
- package/dist/cjs/ic-top-navigation.cjs.entry.js +1 -1
- package/dist/cjs/ic-typography.cjs.entry.js +47 -12
- package/dist/cjs/ic-typography.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ic-alert/ic-alert.js +18 -2
- package/dist/collection/components/ic-alert/ic-alert.js.map +1 -1
- package/dist/collection/components/ic-alert/test/basic/ic-alert.spec.js +15 -0
- package/dist/collection/components/ic-alert/test/basic/ic-alert.spec.js.map +1 -1
- package/dist/collection/components/ic-card/ic-card.js +26 -2
- package/dist/collection/components/ic-card/ic-card.js.map +1 -1
- package/dist/collection/components/ic-card/test/basic/ic-card.spec.js +21 -0
- package/dist/collection/components/ic-card/test/basic/ic-card.spec.js.map +1 -1
- package/dist/collection/components/ic-chip/ic-chip.css +1 -0
- package/dist/collection/components/ic-chip/ic-chip.js +8 -2
- package/dist/collection/components/ic-chip/ic-chip.js.map +1 -1
- package/dist/collection/components/ic-chip/test/basic/ic-chip.spec.js +15 -0
- package/dist/collection/components/ic-chip/test/basic/ic-chip.spec.js.map +1 -1
- package/dist/collection/components/ic-classification-banner/ic-classification-banner.js +12 -3
- package/dist/collection/components/ic-classification-banner/ic-classification-banner.js.map +1 -1
- package/dist/collection/components/ic-classification-banner/test/basic/ic-classification-banner.spec.js +48 -0
- package/dist/collection/components/ic-classification-banner/test/basic/ic-classification-banner.spec.js.map +1 -1
- package/dist/collection/components/ic-empty-state/ic-empty-state.js +21 -2
- package/dist/collection/components/ic-empty-state/ic-empty-state.js.map +1 -1
- package/dist/collection/components/ic-hero/ic-hero.js +18 -2
- package/dist/collection/components/ic-hero/ic-hero.js.map +1 -1
- package/dist/collection/components/ic-hero/test/basic/ic-hero.spec.js +15 -0
- package/dist/collection/components/ic-hero/test/basic/ic-hero.spec.js.map +1 -1
- package/dist/collection/components/ic-radio-group/ic-radio-group.js +40 -21
- package/dist/collection/components/ic-radio-group/ic-radio-group.js.map +1 -1
- package/dist/collection/components/ic-tooltip/ic-tooltip.js +56 -6
- package/dist/collection/components/ic-tooltip/ic-tooltip.js.map +1 -1
- package/dist/collection/components/ic-typography/ic-typography.css +8 -0
- package/dist/collection/components/ic-typography/ic-typography.js +148 -13
- package/dist/collection/components/ic-typography/ic-typography.js.map +1 -1
- package/dist/collection/components/ic-typography/test/basic/ic-typography.spec.js +55 -0
- package/dist/collection/components/ic-typography/test/basic/ic-typography.spec.js.map +1 -1
- package/dist/collection/utils/helpers.js +4 -1
- package/dist/collection/utils/helpers.js.map +1 -1
- package/dist/components/helpers.js +5 -2
- package/dist/components/helpers.js.map +1 -1
- package/dist/components/ic-alert2.js +18 -2
- package/dist/components/ic-alert2.js.map +1 -1
- package/dist/components/ic-back-to-top.js +1 -1
- package/dist/components/ic-badge.js +1 -1
- package/dist/components/ic-breadcrumb-group.js +1 -1
- package/dist/components/ic-breadcrumb2.js +1 -1
- package/dist/components/ic-button2.js +1 -1
- package/dist/components/ic-card.js +26 -2
- package/dist/components/ic-card.js.map +1 -1
- package/dist/components/ic-checkbox-group.js +1 -1
- package/dist/components/ic-checkbox.js +1 -1
- package/dist/components/ic-chip.js +9 -3
- package/dist/components/ic-chip.js.map +1 -1
- package/dist/components/ic-classification-banner.js +12 -3
- package/dist/components/ic-classification-banner.js.map +1 -1
- package/dist/components/ic-data-row.js +1 -1
- package/dist/components/ic-dialog.js +1 -1
- package/dist/components/ic-divider2.js +1 -1
- package/dist/components/ic-empty-state.js +21 -2
- package/dist/components/ic-empty-state.js.map +1 -1
- package/dist/components/ic-footer-link-group.js +1 -1
- package/dist/components/ic-footer-link.js +1 -1
- package/dist/components/ic-footer.js +1 -1
- package/dist/components/ic-hero.js +18 -2
- package/dist/components/ic-hero.js.map +1 -1
- package/dist/components/ic-horizontal-scroll2.js +1 -1
- package/dist/components/ic-input-component-container2.js +1 -1
- package/dist/components/ic-input-label2.js +1 -1
- package/dist/components/ic-input-validation2.js +1 -1
- package/dist/components/ic-link2.js +1 -1
- package/dist/components/ic-loading-indicator2.js +1 -1
- package/dist/components/ic-menu-group.js +1 -1
- package/dist/components/ic-menu-item2.js +1 -1
- package/dist/components/ic-navigation-button.js +1 -1
- package/dist/components/ic-navigation-group.js +1 -1
- package/dist/components/ic-navigation-item.js +1 -1
- package/dist/components/ic-navigation-menu2.js +1 -1
- package/dist/components/ic-page-header.js +1 -1
- package/dist/components/ic-pagination-item2.js +1 -1
- package/dist/components/ic-popover-menu.js +1 -1
- package/dist/components/ic-radio-group.js +41 -22
- package/dist/components/ic-radio-group.js.map +1 -1
- package/dist/components/ic-radio-option.js +1 -1
- package/dist/components/ic-search-bar.js +1 -1
- package/dist/components/ic-select.js +1 -1
- package/dist/components/ic-side-navigation.js +1 -1
- package/dist/components/ic-step.js +1 -1
- package/dist/components/ic-stepper.js +1 -1
- package/dist/components/ic-switch.js +1 -1
- package/dist/components/ic-tab-panel.js +1 -1
- package/dist/components/ic-text-field2.js +1 -1
- package/dist/components/ic-theme.js +1 -1
- package/dist/components/ic-toast.js +1 -1
- package/dist/components/ic-tooltip2.js +12 -5
- package/dist/components/ic-tooltip2.js.map +1 -1
- package/dist/components/ic-top-navigation.js +1 -1
- package/dist/components/ic-typography2.js +53 -15
- package/dist/components/ic-typography2.js.map +1 -1
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/{p-21885256.entry.js → p-02262e76.entry.js} +2 -2
- package/dist/core/{p-e720925a.entry.js → p-03f23a55.entry.js} +2 -2
- package/dist/core/{p-b85c5581.entry.js → p-093600a2.entry.js} +2 -2
- package/dist/core/{p-6fdc8bef.entry.js → p-13a6e7ea.entry.js} +2 -2
- package/dist/core/{p-3574b7e4.entry.js → p-13ec2a00.entry.js} +2 -2
- package/dist/core/{p-bf70fe93.entry.js → p-1ae6aadb.entry.js} +2 -2
- package/dist/core/{p-c9efaee1.entry.js → p-1d6e6ebe.entry.js} +2 -2
- package/dist/core/{p-cc3f2353.entry.js → p-223889da.entry.js} +2 -2
- package/dist/core/{p-9128a8e0.entry.js → p-227f6a41.entry.js} +2 -2
- package/dist/core/{p-2e8aaf89.entry.js → p-230187a8.entry.js} +2 -2
- package/dist/core/p-2d930c9c.entry.js +2 -0
- package/dist/core/p-2d930c9c.entry.js.map +1 -0
- package/dist/core/p-3af60dee.entry.js +2 -0
- package/dist/core/{p-ced03499.entry.js.map → p-3af60dee.entry.js.map} +1 -1
- package/dist/core/{p-af439ab9.entry.js → p-3b4c9571.entry.js} +2 -2
- package/dist/core/{p-c623e1b0.entry.js → p-3f2d4108.entry.js} +2 -2
- package/dist/core/{p-9ec428cc.entry.js → p-49e997c7.entry.js} +2 -2
- package/dist/core/{p-de8d16f8.entry.js → p-55b11f6f.entry.js} +2 -2
- package/dist/core/{p-a10eebcc.entry.js → p-5ccd3703.entry.js} +2 -2
- package/dist/core/{p-a0e94ddd.entry.js → p-60746e10.entry.js} +2 -2
- package/dist/core/{p-4e6c5e80.entry.js → p-60f7f555.entry.js} +2 -2
- package/dist/core/{p-a305dc90.entry.js → p-69576aa0.entry.js} +2 -2
- package/dist/core/{p-3cc52cbc.entry.js → p-6fae7e1f.entry.js} +2 -2
- package/dist/core/{p-3cc52cbc.entry.js.map → p-6fae7e1f.entry.js.map} +1 -1
- package/dist/core/{p-81d3b43b.entry.js → p-7c2b59fe.entry.js} +2 -2
- package/dist/core/{p-cbb92eb0.entry.js → p-836e71de.entry.js} +2 -2
- package/dist/core/{p-52855153.entry.js → p-843ed766.entry.js} +2 -2
- package/dist/core/p-8c325d9b.entry.js +2 -0
- package/dist/core/p-8c325d9b.entry.js.map +1 -0
- package/dist/core/{p-20f1b05a.entry.js → p-9146a7f9.entry.js} +2 -2
- package/dist/core/{p-5443b79a.entry.js → p-936ab032.entry.js} +2 -2
- package/dist/core/{p-a399de54.entry.js → p-96505636.entry.js} +2 -2
- package/dist/core/{p-deebcbe3.entry.js → p-9c9ba3cd.entry.js} +2 -2
- package/dist/core/{p-072a5366.entry.js → p-a6ff78aa.entry.js} +2 -2
- package/dist/core/{p-74176f4c.entry.js → p-a75f3c4d.entry.js} +2 -2
- package/dist/core/p-ad67c84f.entry.js +2 -0
- package/dist/core/p-ad67c84f.entry.js.map +1 -0
- package/dist/core/{p-73e5eca2.entry.js → p-aeb001d7.entry.js} +2 -2
- package/dist/core/{p-1c654ddd.entry.js → p-b2ceb541.entry.js} +2 -2
- package/dist/core/{p-18536c24.entry.js → p-b9be021b.entry.js} +2 -2
- package/dist/core/p-b9be021b.entry.js.map +1 -0
- package/dist/core/{p-910ab8e5.entry.js → p-bb963aa4.entry.js} +2 -2
- package/dist/core/p-be5d5f93.entry.js +2 -0
- package/dist/core/p-be5d5f93.entry.js.map +1 -0
- package/dist/core/{p-6167880d.entry.js → p-c1d5e7f2.entry.js} +2 -2
- package/dist/core/{p-8df60639.entry.js → p-c59474bb.entry.js} +2 -2
- package/dist/core/{p-8d98835c.entry.js → p-cb14349b.entry.js} +2 -2
- package/dist/core/p-d21f0d15.entry.js +2 -0
- package/dist/core/p-d21f0d15.entry.js.map +1 -0
- package/dist/core/{p-9419b840.entry.js → p-d3750771.entry.js} +2 -2
- package/dist/core/{p-b3178032.entry.js → p-db52d416.entry.js} +2 -2
- package/dist/core/p-dbc0f5da.entry.js +2 -0
- package/dist/core/p-dbc0f5da.entry.js.map +1 -0
- package/dist/core/{p-7ce6fb3b.entry.js → p-dcd475cc.entry.js} +2 -2
- package/dist/core/{p-4661ee3b.entry.js → p-dd9d8e68.entry.js} +2 -2
- package/dist/core/{p-09a2f6ff.entry.js → p-def5ba6b.entry.js} +2 -2
- package/dist/core/{p-e4f0fc68.entry.js → p-e6bad80b.entry.js} +2 -2
- package/dist/core/{p-2c9cf064.entry.js → p-e7fa6804.entry.js} +2 -2
- package/dist/core/{p-8619c625.entry.js → p-e8fa0095.entry.js} +2 -2
- package/dist/core/p-ed2b2bd7.entry.js +2 -0
- package/dist/core/p-ed2b2bd7.entry.js.map +1 -0
- package/dist/core/{p-92c7f4c5.entry.js → p-ee1c9f20.entry.js} +2 -2
- package/dist/core/{p-4c97f1e6.entry.js → p-f735a277.entry.js} +2 -2
- package/dist/core/{p-a5dd7065.js → p-fef9e8c9.js} +2 -2
- package/dist/core/p-fef9e8c9.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/{helpers-988ce06b.js → helpers-3905ccc4.js} +6 -3
- package/dist/esm/helpers-3905ccc4.js.map +1 -0
- package/dist/esm/ic-accordion-group.entry.js +1 -1
- package/dist/esm/ic-accordion.entry.js +1 -1
- package/dist/esm/ic-alert.entry.js +18 -2
- package/dist/esm/ic-alert.entry.js.map +1 -1
- package/dist/esm/ic-back-to-top.entry.js +1 -1
- package/dist/esm/ic-badge.entry.js +1 -1
- package/dist/esm/ic-breadcrumb-group.entry.js +1 -1
- package/dist/esm/ic-breadcrumb.entry.js +1 -1
- package/dist/esm/ic-button_3.entry.js +11 -6
- package/dist/esm/ic-button_3.entry.js.map +1 -1
- package/dist/esm/ic-card.entry.js +26 -2
- package/dist/esm/ic-card.entry.js.map +1 -1
- package/dist/esm/ic-checkbox-group.entry.js +1 -1
- package/dist/esm/ic-checkbox.entry.js +1 -1
- package/dist/esm/ic-chip.entry.js +9 -3
- package/dist/esm/ic-chip.entry.js.map +1 -1
- package/dist/esm/ic-classification-banner.entry.js +12 -3
- package/dist/esm/ic-classification-banner.entry.js.map +1 -1
- package/dist/esm/ic-data-row.entry.js +1 -1
- package/dist/esm/ic-dialog.entry.js +1 -1
- package/dist/esm/ic-divider.entry.js +1 -1
- package/dist/esm/ic-empty-state.entry.js +21 -2
- package/dist/esm/ic-empty-state.entry.js.map +1 -1
- package/dist/esm/ic-footer-link-group.entry.js +1 -1
- package/dist/esm/ic-footer-link.entry.js +1 -1
- package/dist/esm/ic-footer.entry.js +1 -1
- package/dist/esm/ic-hero.entry.js +18 -2
- package/dist/esm/ic-hero.entry.js.map +1 -1
- package/dist/esm/ic-horizontal-scroll.entry.js +1 -1
- package/dist/esm/ic-input-component-container_3.entry.js +1 -1
- package/dist/esm/ic-input-label_2.entry.js +1 -1
- package/dist/esm/ic-link.entry.js +1 -1
- package/dist/esm/ic-menu-group.entry.js +1 -1
- package/dist/esm/ic-menu-item.entry.js +1 -1
- package/dist/esm/ic-navigation-button.entry.js +1 -1
- package/dist/esm/ic-navigation-group.entry.js +1 -1
- package/dist/esm/ic-navigation-item.entry.js +1 -1
- package/dist/esm/ic-navigation-menu.entry.js +1 -1
- package/dist/esm/ic-page-header.entry.js +1 -1
- package/dist/esm/ic-pagination-item.entry.js +1 -1
- package/dist/esm/ic-pagination.entry.js +1 -1
- package/dist/esm/ic-popover-menu.entry.js +1 -1
- package/dist/esm/ic-radio-group.entry.js +41 -22
- package/dist/esm/ic-radio-group.entry.js.map +1 -1
- package/dist/esm/ic-radio-option.entry.js +1 -1
- package/dist/esm/ic-search-bar.entry.js +1 -1
- package/dist/esm/ic-select.entry.js +1 -1
- package/dist/esm/ic-side-navigation.entry.js +1 -1
- package/dist/esm/ic-status-tag.entry.js +1 -1
- package/dist/esm/ic-step.entry.js +1 -1
- package/dist/esm/ic-stepper.entry.js +1 -1
- package/dist/esm/ic-switch.entry.js +1 -1
- package/dist/esm/ic-tab-group.entry.js +1 -1
- package/dist/esm/ic-tab-panel.entry.js +1 -1
- package/dist/esm/ic-tab.entry.js +1 -1
- package/dist/esm/ic-text-field.entry.js +1 -1
- package/dist/esm/ic-theme.entry.js +1 -1
- package/dist/esm/ic-toast.entry.js +1 -1
- package/dist/esm/ic-toggle-button.entry.js +1 -1
- package/dist/esm/ic-top-navigation.entry.js +1 -1
- package/dist/esm/ic-typography.entry.js +48 -13
- package/dist/esm/ic-typography.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/ic-alert/ic-alert.d.ts +3 -0
- package/dist/types/components/ic-card/ic-card.d.ts +2 -0
- package/dist/types/components/ic-chip/ic-chip.d.ts +2 -0
- package/dist/types/components/ic-empty-state/ic-empty-state.d.ts +3 -0
- package/dist/types/components/ic-hero/ic-hero.d.ts +3 -0
- package/dist/types/components/ic-radio-group/ic-radio-group.d.ts +3 -0
- package/dist/types/components/ic-tooltip/ic-tooltip.d.ts +7 -0
- package/dist/types/components/ic-typography/ic-typography.d.ts +23 -1
- package/dist/types/components.d.ts +30 -0
- package/dist/types/utils/helpers.d.ts +2 -1
- package/hydrate/index.js +194 -45
- package/package.json +2 -2
- package/dist/cjs/helpers-80016ff7.js.map +0 -1
- package/dist/core/p-18536c24.entry.js.map +0 -1
- package/dist/core/p-2eb95212.entry.js +0 -2
- package/dist/core/p-2eb95212.entry.js.map +0 -1
- package/dist/core/p-4d1490ce.entry.js +0 -2
- package/dist/core/p-4d1490ce.entry.js.map +0 -1
- package/dist/core/p-74e3ca39.entry.js +0 -2
- package/dist/core/p-74e3ca39.entry.js.map +0 -1
- package/dist/core/p-88c0dc04.entry.js +0 -2
- package/dist/core/p-88c0dc04.entry.js.map +0 -1
- package/dist/core/p-a5dd7065.js.map +0 -1
- package/dist/core/p-ced03499.entry.js +0 -2
- package/dist/core/p-de7c0f2c.entry.js +0 -2
- package/dist/core/p-de7c0f2c.entry.js.map +0 -1
- package/dist/core/p-e5a6218b.entry.js +0 -2
- package/dist/core/p-e5a6218b.entry.js.map +0 -1
- package/dist/core/p-f807e600.entry.js +0 -2
- package/dist/core/p-f807e600.entry.js.map +0 -1
- package/dist/esm/helpers-988ce06b.js.map +0 -1
- /package/dist/core/{p-21885256.entry.js.map → p-02262e76.entry.js.map} +0 -0
- /package/dist/core/{p-e720925a.entry.js.map → p-03f23a55.entry.js.map} +0 -0
- /package/dist/core/{p-b85c5581.entry.js.map → p-093600a2.entry.js.map} +0 -0
- /package/dist/core/{p-6fdc8bef.entry.js.map → p-13a6e7ea.entry.js.map} +0 -0
- /package/dist/core/{p-3574b7e4.entry.js.map → p-13ec2a00.entry.js.map} +0 -0
- /package/dist/core/{p-bf70fe93.entry.js.map → p-1ae6aadb.entry.js.map} +0 -0
- /package/dist/core/{p-c9efaee1.entry.js.map → p-1d6e6ebe.entry.js.map} +0 -0
- /package/dist/core/{p-cc3f2353.entry.js.map → p-223889da.entry.js.map} +0 -0
- /package/dist/core/{p-9128a8e0.entry.js.map → p-227f6a41.entry.js.map} +0 -0
- /package/dist/core/{p-2e8aaf89.entry.js.map → p-230187a8.entry.js.map} +0 -0
- /package/dist/core/{p-af439ab9.entry.js.map → p-3b4c9571.entry.js.map} +0 -0
- /package/dist/core/{p-c623e1b0.entry.js.map → p-3f2d4108.entry.js.map} +0 -0
- /package/dist/core/{p-9ec428cc.entry.js.map → p-49e997c7.entry.js.map} +0 -0
- /package/dist/core/{p-de8d16f8.entry.js.map → p-55b11f6f.entry.js.map} +0 -0
- /package/dist/core/{p-a10eebcc.entry.js.map → p-5ccd3703.entry.js.map} +0 -0
- /package/dist/core/{p-a0e94ddd.entry.js.map → p-60746e10.entry.js.map} +0 -0
- /package/dist/core/{p-4e6c5e80.entry.js.map → p-60f7f555.entry.js.map} +0 -0
- /package/dist/core/{p-a305dc90.entry.js.map → p-69576aa0.entry.js.map} +0 -0
- /package/dist/core/{p-81d3b43b.entry.js.map → p-7c2b59fe.entry.js.map} +0 -0
- /package/dist/core/{p-cbb92eb0.entry.js.map → p-836e71de.entry.js.map} +0 -0
- /package/dist/core/{p-52855153.entry.js.map → p-843ed766.entry.js.map} +0 -0
- /package/dist/core/{p-20f1b05a.entry.js.map → p-9146a7f9.entry.js.map} +0 -0
- /package/dist/core/{p-5443b79a.entry.js.map → p-936ab032.entry.js.map} +0 -0
- /package/dist/core/{p-a399de54.entry.js.map → p-96505636.entry.js.map} +0 -0
- /package/dist/core/{p-deebcbe3.entry.js.map → p-9c9ba3cd.entry.js.map} +0 -0
- /package/dist/core/{p-072a5366.entry.js.map → p-a6ff78aa.entry.js.map} +0 -0
- /package/dist/core/{p-74176f4c.entry.js.map → p-a75f3c4d.entry.js.map} +0 -0
- /package/dist/core/{p-73e5eca2.entry.js.map → p-aeb001d7.entry.js.map} +0 -0
- /package/dist/core/{p-1c654ddd.entry.js.map → p-b2ceb541.entry.js.map} +0 -0
- /package/dist/core/{p-910ab8e5.entry.js.map → p-bb963aa4.entry.js.map} +0 -0
- /package/dist/core/{p-6167880d.entry.js.map → p-c1d5e7f2.entry.js.map} +0 -0
- /package/dist/core/{p-8df60639.entry.js.map → p-c59474bb.entry.js.map} +0 -0
- /package/dist/core/{p-8d98835c.entry.js.map → p-cb14349b.entry.js.map} +0 -0
- /package/dist/core/{p-9419b840.entry.js.map → p-d3750771.entry.js.map} +0 -0
- /package/dist/core/{p-b3178032.entry.js.map → p-db52d416.entry.js.map} +0 -0
- /package/dist/core/{p-7ce6fb3b.entry.js.map → p-dcd475cc.entry.js.map} +0 -0
- /package/dist/core/{p-4661ee3b.entry.js.map → p-dd9d8e68.entry.js.map} +0 -0
- /package/dist/core/{p-09a2f6ff.entry.js.map → p-def5ba6b.entry.js.map} +0 -0
- /package/dist/core/{p-e4f0fc68.entry.js.map → p-e6bad80b.entry.js.map} +0 -0
- /package/dist/core/{p-2c9cf064.entry.js.map → p-e7fa6804.entry.js.map} +0 -0
- /package/dist/core/{p-8619c625.entry.js.map → p-e8fa0095.entry.js.map} +0 -0
- /package/dist/core/{p-92c7f4c5.entry.js.map → p-ee1c9f20.entry.js.map} +0 -0
- /package/dist/core/{p-4c97f1e6.entry.js.map → p-f735a277.entry.js.map} +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-alert.js","sourceRoot":"","sources":["../../../src/components/ic-alert/ic-alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,KAAK,EAEL,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,EACJ,CAAC,
|
1
|
+
{"version":3,"file":"ic-alert.js","sourceRoot":"","sources":["../../../src/components/ic-alert/ic-alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,KAAK,EAEL,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,EACJ,CAAC,EACD,WAAW,GACZ,MAAM,eAAe,CAAC;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CAAC,cAAc;yBACpC;wBAEA,OAAO,IAAI,CACV,qBACE,KAAK,EAAE;gCACL,CAAC,aAAa,CAAC,EAAE,IAAI;gCACrB,CAAC,mBAAmB,CAAC,EAAE,UAAU,IAAI,IAAI,CAAC,cAAc;6BACzD,EACD,OAAO,EAAC,gBAAgB;4BAExB,aAAI,OAAO,CAAK,CACF,CACjB;wBACD,YAAM,IAAI,EAAC,SAAS;4BAClB,qBAAe,OAAO,EAAC,MAAM,IAAE,OAAO,CAAiB,CAClD,CACH;oBACL,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAChC,WAAK,KAAK,EAAC,wBAAwB;wBACjC,YAAM,IAAI,EAAC,QAAQ,GAAG,CAClB,CACP,CACG;gBACN,WAAK,KAAK,EAAC,wBAAwB,IAChC,WAAW,IAAI,CACd,iBACE,KAAK,EAAE;wBACL,CAAC,eAAe,CAAC,EAAE,IAAI;wBACvB,CAAC,cAAc,CAAC,EAAE,IAAI;qBACvB,EACD,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,IAAI,CAAC,aAAa,EAC3B,OAAO,EAAC,MAAM,EACd,UAAU,EAAE,qBAAqB,CAAC,IAAI,EACtC,KAAK,EAAC,SAAS,GACJ,CACd,CACG,CACF,CACD,CACR,CACF,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Element,\n Event,\n EventEmitter,\n Host,\n State,\n Listen,\n Prop,\n h,\n forceUpdate,\n} from \"@stencil/core\";\nimport closeIcon from \"../../assets/close-icon.svg\";\nimport { isSlotUsed, checkSlotInChildMutations } from \"../../utils/helpers\";\nimport { IcThemeForegroundEnum, IcStatusVariants } from \"../../utils/types\";\nimport { VARIANT_ICONS } from \"../../utils/constants\";\n\n/**\n * @slot message - Content is placed to the right of the title.\n * @slot action - Content is placed to the right of the message.\n */\n@Component({\n tag: \"ic-alert\",\n styleUrl: \"ic-alert.css\",\n shadow: true,\n})\nexport class Alert {\n private hostMutationObserver: MutationObserver = null;\n\n @Element() el: HTMLIcAlertElement;\n\n @State() alertTitleWrap: boolean = false;\n @State() visible: boolean = true;\n\n /**\n * If `true`, the alert will have the 'alert' ARIA role and will be announced to screen readers.\n */\n @Prop() announced?: boolean = true;\n\n /**\n * If `true`, the alert will have a close icon at the end to dismiss it.\n */\n @Prop() dismissible?: boolean = false;\n\n /**\n * The optional title to display at the start of the alert.\n */\n @Prop() heading?: string = \"\";\n\n /**\n * The main body message of the alert.\n */\n @Prop() message?: string;\n\n /**\n * If `true`, the title and message will appear above and below instead of inline.\n */\n @Prop() titleAbove?: boolean = false;\n\n /**\n * The variant of the alert which will be rendered.\n */\n @Prop() variant?: IcStatusVariants = \"neutral\";\n\n /**\n * @deprecated This event should not be used anymore. Use icDismiss instead.\n */\n @Event() dismiss: EventEmitter<void>;\n\n /**\n * Is emitted when the user dismisses the alert.\n */\n @Event() icDismiss: EventEmitter<void>;\n\n disconnectedCallback(): void {\n this.hostMutationObserver?.disconnect();\n }\n\n componentDidLoad(): void {\n this.alertTitleShouldWrap();\n\n this.hostMutationObserver = new MutationObserver(this.hostMutationCallback);\n this.hostMutationObserver.observe(this.el, {\n childList: true,\n });\n }\n\n @Listen(\"icDismiss\", { capture: true })\n handleClick(): void {\n this.visible = !this.visible;\n }\n\n private dismissAction = (): void => {\n this.dismiss.emit();\n this.icDismiss.emit();\n };\n\n private alertTitleShouldWrap() {\n const titleHeight =\n this.el.shadowRoot.querySelector(\".alert-title\")?.clientHeight;\n if (titleHeight > 24) this.alertTitleWrap = true;\n }\n\n private hostMutationCallback = (mutationList: MutationRecord[]): void => {\n if (\n mutationList.some(({ type, addedNodes, removedNodes }) =>\n type === \"childList\"\n ? checkSlotInChildMutations(addedNodes, removedNodes, \"action\")\n : false\n )\n ) {\n forceUpdate(this);\n }\n };\n\n render() {\n const {\n variant,\n heading,\n message,\n titleAbove,\n dismissible,\n announced,\n visible,\n } = this;\n\n return (\n visible && (\n <Host\n role={announced ? \"alert\" : null}\n class={{\n [IcThemeForegroundEnum.Dark]: true,\n }}\n >\n <div\n class={{\n [\"container\"]: true,\n [`container-${variant}`]: true,\n }}\n >\n <div class=\"alert-icon-container\">\n <div\n class={{\n [\"divider\"]: true,\n [`divider-${variant}`]: true,\n }}\n ></div>\n <span\n class={{\n [\"alert-icon\"]: true,\n [\"svg-container\"]: true,\n [`icon-${variant}`]: true,\n }}\n innerHTML={VARIANT_ICONS[variant].icon}\n ></span>\n </div>\n <div class=\"alert-content\">\n <div\n class={{\n [\"alert-message\"]: true,\n [\"alert-message-title-above\"]:\n titleAbove || this.alertTitleWrap,\n }}\n >\n {heading && (\n <ic-typography\n class={{\n [\"alert-title\"]: true,\n [\"alert-title-above\"]: titleAbove || this.alertTitleWrap,\n }}\n variant=\"subtitle-large\"\n >\n <p>{heading}</p>\n </ic-typography>\n )}\n <slot name=\"message\">\n <ic-typography variant=\"body\">{message}</ic-typography>\n </slot>\n </div>\n {isSlotUsed(this.el, \"action\") && (\n <div class=\"alert-action-container\">\n <slot name=\"action\" />\n </div>\n )}\n </div>\n <div class=\"dismiss-icon-container\">\n {dismissible && (\n <ic-button\n class={{\n [\"svg-container\"]: true,\n [\"dismiss-icon\"]: true,\n }}\n innerHTML={closeIcon}\n onClick={this.dismissAction}\n variant=\"icon\"\n appearance={IcThemeForegroundEnum.Dark}\n title=\"dismiss\"\n ></ic-button>\n )}\n </div>\n </div>\n </Host>\n )\n );\n }\n}\n"]}
|
@@ -178,5 +178,20 @@ describe("ic-alert component", () => {
|
|
178
178
|
alert = await page.root.shadowRoot.querySelector("div.container-neutral");
|
179
179
|
expect(alert).toBeNull();
|
180
180
|
});
|
181
|
+
it("should test rendering an action after initial render", async () => {
|
182
|
+
const page = await newSpecPage({
|
183
|
+
components: [Alert],
|
184
|
+
html: `<ic-alert heading="Test heading"></ic-alert>`,
|
185
|
+
});
|
186
|
+
const action = document.createElement("button");
|
187
|
+
action.setAttribute("slot", "action");
|
188
|
+
page.rootInstance.hostMutationCallback([
|
189
|
+
{
|
190
|
+
type: "childList",
|
191
|
+
addedNodes: [action],
|
192
|
+
removedNodes: [],
|
193
|
+
},
|
194
|
+
]);
|
195
|
+
});
|
181
196
|
});
|
182
197
|
//# sourceMappingURL=ic-alert.spec.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-alert.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-alert/test/basic/ic-alert.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC1D,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,KAAK,CAAC;YACnB,IAAI,EAAE,8CAA8C;SACrD,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;oBA0Bd,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC1D,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,KAAK,CAAC;YACnB,IAAI,EAAE,8CAA8C;SACrD,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;oBAuBd,CAAC,CAAC;IACpB,CAAC,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M,aAAa,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAE5E,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC7B,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAErC,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC;QAE5B,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;QAE1E,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from \"@stencil/core/testing\";\nimport { Alert } from \"../../ic-alert\";\n\ndescribe(\"ic-alert component\", () => {\n it(\"should render with a heading when supplied\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert heading=\"Test heading\"></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" heading=\"Test heading\" role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <ic-typography class=\"alert-title\" variant=\"subtitle-large\">\n <p>\n Test heading\n </p>\n </ic-typography>\n <slot name=\"message\">\n <ic-typography variant=\"body\"></ic-typography>\n </slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\">\n </div>\n </div>\n </mock:shadow-root>\n </ic-alert>`);\n });\n\n it(\"should render with a message when supplied\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert message=\"Test message\"></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" message=\"Test message\" role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <slot name=\"message\">\n <ic-typography variant=\"body\">\n Test message\n </ic-typography>\n </slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\">\n </div>\n </div>\n </mock:shadow-root>\n </ic-alert>`);\n });\n\n it(\"should render an action in the correct position when supplied\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert message=\"This has an action\"><button slot=\"action\"></button></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" message=\"This has an action\" role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <slot name=\"message\">\n <ic-typography variant=\"body\">\n This has an action\n </ic-typography>\n </slot>\n </div>\n <div class=\"alert-action-container\">\n <slot name=\"action\"></slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\">\n </div>\n </div>\n </mock:shadow-root>\n <button slot=\"action\"></button>\n </ic-alert>`);\n });\n\n it(\"should render with a dismiss icon when the prop is applied\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert message=\"This is dismissible\" dismissible=true></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" message=\"This is dismissible\" dismissible=true role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <slot name=\"message\">\n <ic-typography variant=\"body\">\n This is dismissible\n </ic-typography>\n </slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\">\n <ic-button appearance=\"dark\" class=\"dismiss-icon svg-container\" title=\"dismiss\" variant=\"icon\">\n svg\n </ic-button>\n </div>\n </div>\n </mock:shadow-root>\n </ic-alert>`);\n });\n\n it(\"should render an element in the message slot\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert heading=\"Using custom message\"><ic-typography variant=\"h1\" slot=\"message\">Custom h1 message</ic-typography></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" heading=\"Using custom message\" role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <ic-typography class=\"alert-title\" variant=\"subtitle-large\">\n <p>\n Using custom message\n </p>\n </ic-typography>\n <slot name=\"message\">\n <ic-typography variant=\"body\"></ic-typography>\n </slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\"></div>\n </div>\n </mock:shadow-root>\n <ic-typography variant=\"h1\" slot=\"message\">Custom h1 message</ic-typography>\n </ic-alert>`);\n });\n\n it(\"should close on dismiss icon click\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert message=\"This is dismissible\" dismissible=true></ic-alert>`,\n });\n\n let alert = await page.root.shadowRoot.querySelector(\n \"div.container-neutral\"\n );\n const dismissButton = await page.root.shadowRoot.querySelector(\"ic-button\");\n\n expect(alert).not.toBeNull();\n expect(dismissButton).not.toBeNull();\n\n await dismissButton.click();\n\n await page.waitForChanges();\n alert = await page.root.shadowRoot.querySelector(\"div.container-neutral\");\n\n expect(alert).toBeNull();\n });\n});\n"]}
|
1
|
+
{"version":3,"file":"ic-alert.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-alert/test/basic/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AE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;QACpE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,KAAK,CAAC;YACnB,IAAI,EAAE,8CAA8C;SACrD,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEtC,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC;YACrC;gBACE,IAAI,EAAE,WAAW;gBACjB,UAAU,EAAE,CAAC,MAAM,CAAC;gBACpB,YAAY,EAAE,EAAE;aACjB;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from \"@stencil/core/testing\";\nimport { Alert } from \"../../ic-alert\";\n\ndescribe(\"ic-alert component\", () => {\n it(\"should render with a heading when supplied\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert heading=\"Test heading\"></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" heading=\"Test heading\" role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <ic-typography class=\"alert-title\" variant=\"subtitle-large\">\n <p>\n Test heading\n </p>\n </ic-typography>\n <slot name=\"message\">\n <ic-typography variant=\"body\"></ic-typography>\n </slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\">\n </div>\n </div>\n </mock:shadow-root>\n </ic-alert>`);\n });\n\n it(\"should render with a message when supplied\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert message=\"Test message\"></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" message=\"Test message\" role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <slot name=\"message\">\n <ic-typography variant=\"body\">\n Test message\n </ic-typography>\n </slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\">\n </div>\n </div>\n </mock:shadow-root>\n </ic-alert>`);\n });\n\n it(\"should render an action in the correct position when supplied\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert message=\"This has an action\"><button slot=\"action\"></button></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" message=\"This has an action\" role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <slot name=\"message\">\n <ic-typography variant=\"body\">\n This has an action\n </ic-typography>\n </slot>\n </div>\n <div class=\"alert-action-container\">\n <slot name=\"action\"></slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\">\n </div>\n </div>\n </mock:shadow-root>\n <button slot=\"action\"></button>\n </ic-alert>`);\n });\n\n it(\"should render with a dismiss icon when the prop is applied\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert message=\"This is dismissible\" dismissible=true></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" message=\"This is dismissible\" dismissible=true role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <slot name=\"message\">\n <ic-typography variant=\"body\">\n This is dismissible\n </ic-typography>\n </slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\">\n <ic-button appearance=\"dark\" class=\"dismiss-icon svg-container\" title=\"dismiss\" variant=\"icon\">\n svg\n </ic-button>\n </div>\n </div>\n </mock:shadow-root>\n </ic-alert>`);\n });\n\n it(\"should render an element in the message slot\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert heading=\"Using custom message\"><ic-typography variant=\"h1\" slot=\"message\">Custom h1 message</ic-typography></ic-alert>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-alert class=\"dark\" heading=\"Using custom message\" role=\"alert\">\n <mock:shadow-root>\n <div class=\"container container-neutral\">\n <div class=\"alert-icon-container\">\n <div class=\"divider divider-neutral\"></div>\n <span class=\"alert-icon icon-neutral svg-container\">\n svg\n </span>\n </div>\n <div class=\"alert-content\">\n <div class=\"alert-message\">\n <ic-typography class=\"alert-title\" variant=\"subtitle-large\">\n <p>\n Using custom message\n </p>\n </ic-typography>\n <slot name=\"message\">\n <ic-typography variant=\"body\"></ic-typography>\n </slot>\n </div>\n </div>\n <div class=\"dismiss-icon-container\"></div>\n </div>\n </mock:shadow-root>\n <ic-typography variant=\"h1\" slot=\"message\">Custom h1 message</ic-typography>\n </ic-alert>`);\n });\n\n it(\"should close on dismiss icon click\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert message=\"This is dismissible\" dismissible=true></ic-alert>`,\n });\n\n let alert = await page.root.shadowRoot.querySelector(\n \"div.container-neutral\"\n );\n const dismissButton = await page.root.shadowRoot.querySelector(\"ic-button\");\n\n expect(alert).not.toBeNull();\n expect(dismissButton).not.toBeNull();\n\n await dismissButton.click();\n\n await page.waitForChanges();\n alert = await page.root.shadowRoot.querySelector(\"div.container-neutral\");\n\n expect(alert).toBeNull();\n });\n\n it(\"should test rendering an action after initial render\", async () => {\n const page = await newSpecPage({\n components: [Alert],\n html: `<ic-alert heading=\"Test heading\"></ic-alert>`,\n });\n\n const action = document.createElement(\"button\");\n action.setAttribute(\"slot\", \"action\");\n\n page.rootInstance.hostMutationCallback([\n {\n type: \"childList\",\n addedNodes: [action],\n removedNodes: [],\n },\n ]);\n });\n});\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { h, } from "@stencil/core";
|
2
|
-
import { onComponentRequiredPropUndefined, isSlotUsed, getThemeFromContext, removeDisabledFalse, } from "../../utils/helpers";
|
1
|
+
import { h, forceUpdate, } from "@stencil/core";
|
2
|
+
import { onComponentRequiredPropUndefined, isSlotUsed, getThemeFromContext, removeDisabledFalse, checkSlotInChildMutations, } from "../../utils/helpers";
|
3
3
|
import { IcThemeForegroundEnum, } from "../../utils/types";
|
4
4
|
import chevronIcon from "../../assets/chevron-icon.svg";
|
5
5
|
/**
|
@@ -17,6 +17,7 @@ import chevronIcon from "../../assets/chevron-icon.svg";
|
|
17
17
|
*/
|
18
18
|
export class Card {
|
19
19
|
constructor() {
|
20
|
+
this.hostMutationObserver = null;
|
20
21
|
this.parentFocussed = () => {
|
21
22
|
this.isFocussed = true;
|
22
23
|
};
|
@@ -26,6 +27,23 @@ export class Card {
|
|
26
27
|
this.toggleExpanded = () => {
|
27
28
|
this.areaExpanded = !this.areaExpanded;
|
28
29
|
};
|
30
|
+
this.hostMutationCallback = (mutationList) => {
|
31
|
+
if (mutationList.some(({ type, addedNodes, removedNodes }) => type === "childList"
|
32
|
+
? checkSlotInChildMutations(addedNodes, removedNodes, [
|
33
|
+
"message",
|
34
|
+
"adornment",
|
35
|
+
"expanded-content",
|
36
|
+
"image-top",
|
37
|
+
"image-mid",
|
38
|
+
"icon",
|
39
|
+
"interaction-button",
|
40
|
+
"badge",
|
41
|
+
"interaction-controls",
|
42
|
+
])
|
43
|
+
: false)) {
|
44
|
+
forceUpdate(this);
|
45
|
+
}
|
46
|
+
};
|
29
47
|
this.appearance = "default";
|
30
48
|
this.areaExpanded = false;
|
31
49
|
this.isFocussed = false;
|
@@ -45,10 +63,12 @@ export class Card {
|
|
45
63
|
this.target = undefined;
|
46
64
|
}
|
47
65
|
disconnectedCallback() {
|
66
|
+
var _a;
|
48
67
|
if (this.parentIsAnchorTag) {
|
49
68
|
this.parentEl.removeEventListener("focus", this.parentFocussed);
|
50
69
|
this.parentEl.removeEventListener("blur", this.parentBlurred);
|
51
70
|
}
|
71
|
+
(_a = this.hostMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
52
72
|
}
|
53
73
|
componentWillLoad() {
|
54
74
|
this.parentEl = this.el.parentElement;
|
@@ -65,6 +85,10 @@ export class Card {
|
|
65
85
|
!isSlotUsed(this.el, "heading") &&
|
66
86
|
onComponentRequiredPropUndefined([{ prop: this.heading, propName: "heading" }], "Card");
|
67
87
|
this.updateTheme();
|
88
|
+
this.hostMutationObserver = new MutationObserver(this.hostMutationCallback);
|
89
|
+
this.hostMutationObserver.observe(this.el, {
|
90
|
+
childList: true,
|
91
|
+
});
|
68
92
|
}
|
69
93
|
handleHostClick(event) {
|
70
94
|
if (this.disabled) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-card.js","sourceRoot":"","sources":["../../../src/components/ic-card/ic-card.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACL,CAAC,EACD,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gCAAgC,EAChC,UAAU,EACV,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,WAAW,MAAM,+BAA+B,CAAC;AAExD;;;;;;;;;;;;GAYG;AAMH,MAAM,OAAO,IAAI;;QA2HP,mBAAc,GAAG,GAAS,EAAE;YAClC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC,CAAC;QAE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Element,\n Listen,\n Prop,\n State,\n h,\n Method,\n} from \"@stencil/core\";\nimport {\n onComponentRequiredPropUndefined,\n isSlotUsed,\n getThemeFromContext,\n removeDisabledFalse,\n} from \"../../utils/helpers\";\nimport {\n IcTheme,\n IcThemeForeground,\n IcThemeForegroundEnum,\n} from \"../../utils/types\";\nimport chevronIcon from \"../../assets/chevron-icon.svg\";\n\n/**\n * @slot heading - Content will be placed at the top of the card to the right of the icon.\n * @slot message - Content will be placed in the main body of the card.\n * @slot subheading - Content will be placed below the card heading.\n * @slot adornment - Content will be placed below the card subheading.\n * @slot image-top - Content will be placed at the top of the card above all other content.\n * @slot image-mid - Content will be placed below the card heading section.\n * @slot icon - Content will be placed to the left of the card heading.\n * @slot interaction-button - Content will be placed in the top right corner of the heading section.\n * @slot interaction-controls - Content will be placed below the card message.\n * @slot expanded-content - Content will be placed below the interaction controls but will not initially be rendered.\n * @slot badge - Badge component overlaying the top right of the card.\n */\n@Component({\n tag: \"ic-card\",\n styleUrl: \"ic-card.css\",\n shadow: true,\n})\nexport class Card {\n @Element() el: HTMLIcCardElement;\n\n @State() appearance?: IcThemeForeground = \"default\";\n @State() areaExpanded: boolean = false;\n @State() isFocussed: boolean = false;\n @State() parentEl: HTMLElement | null = null;\n @State() parentIsAnchorTag: boolean = false;\n\n /**\n * If `true`, the card will be a clickable variant, instead of static.\n */\n @Prop({ mutable: true }) clickable?: boolean = false;\n\n /**\n * If `true`, the card will be disabled if it is clickable.\n */\n @Prop() disabled?: boolean = false;\n\n /**\n * If `true`, the card will have an expandable area and expansion toggle button.\n */\n @Prop() expandable?: boolean = false;\n\n /**\n * If `true`, the card will fill the width of the container.\n */\n @Prop() fullWidth?: boolean = false;\n\n /**\n * The heading for the card. This is required, unless a slotted heading is used.\n */\n @Prop() heading?: string;\n\n /**\n * The URL that the clickable card link points to. If set, the clickable card will render as an \"a\" tag, otherwise it will render as a button.\n */\n @Prop() href?: string | undefined;\n\n /**\n * The human language of the linked URL.\n */\n @Prop() hreflang?: string = \"\";\n\n /**\n * The main body message of the card.\n */\n @Prop() message?: string = \"\";\n\n /**\n * How much of the referrer to send when following the link.\n */\n @Prop() referrerpolicy?: ReferrerPolicy;\n\n /**\n * The relationship of the linked URL as space-separated link types.\n */\n @Prop() rel?: string;\n\n /**\n * The subheading for the card.\n */\n @Prop() subheading?: string;\n\n /**\n * The place to display the linked URL, as the name for a browsing context (a tab, window, or iframe).\n */\n @Prop() target?: string;\n\n disconnectedCallback(): void {\n if (this.parentIsAnchorTag) {\n this.parentEl.removeEventListener(\"focus\", this.parentFocussed);\n this.parentEl.removeEventListener(\"blur\", this.parentBlurred);\n }\n }\n\n componentWillLoad(): void {\n this.parentEl = this.el.parentElement;\n\n if (this.parentEl.tagName === \"A\") {\n this.clickable = true;\n this.parentIsAnchorTag = true;\n this.parentEl.classList.add(\"ic-card-wrapper-link\");\n this.parentEl.addEventListener(\"focus\", this.parentFocussed);\n this.parentEl.addEventListener(\"blur\", this.parentBlurred);\n }\n removeDisabledFalse(this.disabled, this.el);\n }\n\n componentDidLoad(): void {\n !isSlotUsed(this.el, \"heading\") &&\n onComponentRequiredPropUndefined(\n [{ prop: this.heading, propName: \"heading\" }],\n \"Card\"\n );\n this.updateTheme();\n }\n\n @Listen(\"click\", { capture: true })\n handleHostClick(event: Event): void {\n if (this.disabled) {\n event.stopImmediatePropagation();\n }\n }\n\n @Listen(\"themeChange\", { target: \"document\" })\n themeChangeHandler(ev: CustomEvent): void {\n const theme: IcTheme = ev.detail;\n this.updateTheme(theme.mode);\n }\n\n /**\n * Sets focus on the card.\n */\n @Method()\n async setFocus(): Promise<void> {\n if (this.el.shadowRoot.querySelector(\"a\")) {\n this.el.shadowRoot.querySelector(\"a\").focus();\n } else if (this.el.shadowRoot.querySelector(\"button\")) {\n this.el.shadowRoot.querySelector(\"button\").focus();\n }\n }\n\n private parentFocussed = (): void => {\n this.isFocussed = true;\n };\n\n private parentBlurred = (): void => {\n this.isFocussed = false;\n };\n\n private updateTheme(newTheme: IcThemeForeground = null): void {\n const foregroundColor = getThemeFromContext(this.el, newTheme || null);\n\n if (foregroundColor !== IcThemeForegroundEnum.Default) {\n this.appearance = foregroundColor;\n }\n }\n\n private toggleExpanded = (): void => {\n this.areaExpanded = !this.areaExpanded;\n };\n\n render() {\n const {\n clickable,\n disabled,\n expandable,\n heading,\n message,\n href,\n hreflang,\n referrerpolicy,\n rel,\n subheading,\n target,\n fullWidth,\n parentIsAnchorTag,\n isFocussed,\n } = this;\n\n const Component = parentIsAnchorTag\n ? \"div\"\n : clickable\n ? this.href === undefined\n ? \"button\"\n : \"a\"\n : \"div\";\n\n const attrs = Component == \"a\" && {\n href: href,\n hrefLang: hreflang,\n referrerPolicy: referrerpolicy,\n rel: rel,\n target: target,\n };\n\n return (\n <Component\n class={{\n [\"card\"]: true,\n [\"clickable\"]: clickable && !disabled,\n [\"disabled\"]: disabled,\n [\"fullwidth\"]: fullWidth,\n [\"focussed\"]: isFocussed,\n [\"dark\"]: this.appearance === IcThemeForegroundEnum.Dark,\n }}\n tabindex={clickable && !parentIsAnchorTag ? 0 : null}\n aria-disabled={disabled ? \"true\" : null}\n disabled={disabled ? true : null}\n {...attrs}\n >\n {isSlotUsed(this.el, \"image-top\") && (\n <div class=\"image-top\">\n <slot name=\"image-top\"></slot>\n </div>\n )}\n <div class=\"card-header\">\n {isSlotUsed(this.el, \"icon\") && (\n <div class=\"icon\">\n <slot name=\"icon\" />\n </div>\n )}\n <div class=\"card-title\">\n <slot name=\"heading\">\n <ic-typography variant=\"h4\">\n <p>{heading}</p>\n </ic-typography>\n </slot>\n </div>\n {isSlotUsed(this.el, \"interaction-button\") && (\n <div class=\"interaction-button\">\n <slot name=\"interaction-button\"></slot>\n </div>\n )}\n </div>\n {(subheading || isSlotUsed(this.el, \"subheading\")) && (\n <div class=\"subheading\">\n <slot name=\"subheading\">\n <ic-typography variant=\"subtitle-small\">\n {subheading}\n </ic-typography>\n </slot>\n </div>\n )}\n {isSlotUsed(this.el, \"adornment\") && (\n <div class=\"adornment\">\n <slot name=\"adornment\"></slot>\n </div>\n )}\n {isSlotUsed(this.el, \"image-mid\") && (\n <div class=\"image-mid\">\n <slot name=\"image-mid\"></slot>\n </div>\n )}\n {(message || isSlotUsed(this.el, \"message\")) && (\n <div\n class={{\n [\"card-message\"]: true,\n }}\n >\n {message && <ic-typography variant=\"body\">{message}</ic-typography>}\n {isSlotUsed(this.el, \"message\") && <slot name=\"message\"></slot>}\n </div>\n )}\n {(isSlotUsed(this.el, \"interaction-controls\") || expandable) && (\n <div class=\"interaction-area\">\n <div class=\"interaction-controls\">\n <slot name=\"interaction-controls\"></slot>\n </div>\n {expandable && (\n <ic-tooltip\n id=\"ic-tooltip-expand-button\"\n label=\"Toggle expandable area\"\n silent\n >\n <button\n class={{\n [\"toggle-button\"]: true,\n [`toggle-button-${\n this.areaExpanded ? \"expanded\" : \"closed\"\n }`]: true,\n }}\n aria-label=\"Toggle expandable area\"\n aria-expanded={`${this.areaExpanded}`}\n aria-controls={\n this.areaExpanded ? \"expanded-content-area\" : null\n }\n onClick={this.toggleExpanded}\n innerHTML={chevronIcon}\n ></button>\n </ic-tooltip>\n )}\n </div>\n )}\n {isSlotUsed(this.el, \"expanded-content\") && this.areaExpanded && (\n <div class=\"expanded-content\" id=\"expanded-content-area\">\n <slot name=\"expanded-content\"></slot>\n </div>\n )}\n {isSlotUsed(this.el, \"badge\") && <slot name=\"badge\"></slot>}\n </Component>\n );\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ic-card.js","sourceRoot":"","sources":["../../../src/components/ic-card/ic-card.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACL,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Element,\n Listen,\n Prop,\n State,\n h,\n Method,\n forceUpdate,\n} from \"@stencil/core\";\nimport {\n onComponentRequiredPropUndefined,\n isSlotUsed,\n getThemeFromContext,\n removeDisabledFalse,\n checkSlotInChildMutations,\n} from \"../../utils/helpers\";\nimport {\n IcTheme,\n IcThemeForeground,\n IcThemeForegroundEnum,\n} from \"../../utils/types\";\nimport chevronIcon from \"../../assets/chevron-icon.svg\";\n\n/**\n * @slot heading - Content will be placed at the top of the card to the right of the icon.\n * @slot message - Content will be placed in the main body of the card.\n * @slot subheading - Content will be placed below the card heading.\n * @slot adornment - Content will be placed below the card subheading.\n * @slot image-top - Content will be placed at the top of the card above all other content.\n * @slot image-mid - Content will be placed below the card heading section.\n * @slot icon - Content will be placed to the left of the card heading.\n * @slot interaction-button - Content will be placed in the top right corner of the heading section.\n * @slot interaction-controls - Content will be placed below the card message.\n * @slot expanded-content - Content will be placed below the interaction controls but will not initially be rendered.\n * @slot badge - Badge component overlaying the top right of the card.\n */\n@Component({\n tag: \"ic-card\",\n styleUrl: \"ic-card.css\",\n shadow: true,\n})\nexport class Card {\n private hostMutationObserver: MutationObserver = null;\n\n @Element() el: HTMLIcCardElement;\n\n @State() appearance?: IcThemeForeground = \"default\";\n @State() areaExpanded: boolean = false;\n @State() isFocussed: boolean = false;\n @State() parentEl: HTMLElement | null = null;\n @State() parentIsAnchorTag: boolean = false;\n\n /**\n * If `true`, the card will be a clickable variant, instead of static.\n */\n @Prop({ mutable: true }) clickable?: boolean = false;\n\n /**\n * If `true`, the card will be disabled if it is clickable.\n */\n @Prop() disabled?: boolean = false;\n\n /**\n * If `true`, the card will have an expandable area and expansion toggle button.\n */\n @Prop() expandable?: boolean = false;\n\n /**\n * If `true`, the card will fill the width of the container.\n */\n @Prop() fullWidth?: boolean = false;\n\n /**\n * The heading for the card. This is required, unless a slotted heading is used.\n */\n @Prop() heading?: string;\n\n /**\n * The URL that the clickable card link points to. If set, the clickable card will render as an \"a\" tag, otherwise it will render as a button.\n */\n @Prop() href?: string | undefined;\n\n /**\n * The human language of the linked URL.\n */\n @Prop() hreflang?: string = \"\";\n\n /**\n * The main body message of the card.\n */\n @Prop() message?: string = \"\";\n\n /**\n * How much of the referrer to send when following the link.\n */\n @Prop() referrerpolicy?: ReferrerPolicy;\n\n /**\n * The relationship of the linked URL as space-separated link types.\n */\n @Prop() rel?: string;\n\n /**\n * The subheading for the card.\n */\n @Prop() subheading?: string;\n\n /**\n * The place to display the linked URL, as the name for a browsing context (a tab, window, or iframe).\n */\n @Prop() target?: string;\n\n disconnectedCallback(): void {\n if (this.parentIsAnchorTag) {\n this.parentEl.removeEventListener(\"focus\", this.parentFocussed);\n this.parentEl.removeEventListener(\"blur\", this.parentBlurred);\n }\n\n this.hostMutationObserver?.disconnect();\n }\n\n componentWillLoad(): void {\n this.parentEl = this.el.parentElement;\n\n if (this.parentEl.tagName === \"A\") {\n this.clickable = true;\n this.parentIsAnchorTag = true;\n this.parentEl.classList.add(\"ic-card-wrapper-link\");\n this.parentEl.addEventListener(\"focus\", this.parentFocussed);\n this.parentEl.addEventListener(\"blur\", this.parentBlurred);\n }\n removeDisabledFalse(this.disabled, this.el);\n }\n\n componentDidLoad(): void {\n !isSlotUsed(this.el, \"heading\") &&\n onComponentRequiredPropUndefined(\n [{ prop: this.heading, propName: \"heading\" }],\n \"Card\"\n );\n this.updateTheme();\n\n this.hostMutationObserver = new MutationObserver(this.hostMutationCallback);\n this.hostMutationObserver.observe(this.el, {\n childList: true,\n });\n }\n\n @Listen(\"click\", { capture: true })\n handleHostClick(event: Event): void {\n if (this.disabled) {\n event.stopImmediatePropagation();\n }\n }\n\n @Listen(\"themeChange\", { target: \"document\" })\n themeChangeHandler(ev: CustomEvent): void {\n const theme: IcTheme = ev.detail;\n this.updateTheme(theme.mode);\n }\n\n /**\n * Sets focus on the card.\n */\n @Method()\n async setFocus(): Promise<void> {\n if (this.el.shadowRoot.querySelector(\"a\")) {\n this.el.shadowRoot.querySelector(\"a\").focus();\n } else if (this.el.shadowRoot.querySelector(\"button\")) {\n this.el.shadowRoot.querySelector(\"button\").focus();\n }\n }\n\n private parentFocussed = (): void => {\n this.isFocussed = true;\n };\n\n private parentBlurred = (): void => {\n this.isFocussed = false;\n };\n\n private updateTheme(newTheme: IcThemeForeground = null): void {\n const foregroundColor = getThemeFromContext(this.el, newTheme || null);\n\n if (foregroundColor !== IcThemeForegroundEnum.Default) {\n this.appearance = foregroundColor;\n }\n }\n\n private toggleExpanded = (): void => {\n this.areaExpanded = !this.areaExpanded;\n };\n\n private hostMutationCallback = (mutationList: MutationRecord[]): void => {\n if (\n mutationList.some(({ type, addedNodes, removedNodes }) =>\n type === \"childList\"\n ? checkSlotInChildMutations(addedNodes, removedNodes, [\n \"message\",\n \"adornment\",\n \"expanded-content\",\n \"image-top\",\n \"image-mid\",\n \"icon\",\n \"interaction-button\",\n \"badge\",\n \"interaction-controls\",\n ])\n : false\n )\n ) {\n forceUpdate(this);\n }\n };\n\n render() {\n const {\n clickable,\n disabled,\n expandable,\n heading,\n message,\n href,\n hreflang,\n referrerpolicy,\n rel,\n subheading,\n target,\n fullWidth,\n parentIsAnchorTag,\n isFocussed,\n } = this;\n\n const Component = parentIsAnchorTag\n ? \"div\"\n : clickable\n ? this.href === undefined\n ? \"button\"\n : \"a\"\n : \"div\";\n\n const attrs = Component == \"a\" && {\n href: href,\n hrefLang: hreflang,\n referrerPolicy: referrerpolicy,\n rel: rel,\n target: target,\n };\n\n return (\n <Component\n class={{\n [\"card\"]: true,\n [\"clickable\"]: clickable && !disabled,\n [\"disabled\"]: disabled,\n [\"fullwidth\"]: fullWidth,\n [\"focussed\"]: isFocussed,\n [\"dark\"]: this.appearance === IcThemeForegroundEnum.Dark,\n }}\n tabindex={clickable && !parentIsAnchorTag ? 0 : null}\n aria-disabled={disabled ? \"true\" : null}\n disabled={disabled ? true : null}\n {...attrs}\n >\n {isSlotUsed(this.el, \"image-top\") && (\n <div class=\"image-top\">\n <slot name=\"image-top\"></slot>\n </div>\n )}\n <div class=\"card-header\">\n {isSlotUsed(this.el, \"icon\") && (\n <div class=\"icon\">\n <slot name=\"icon\" />\n </div>\n )}\n <div class=\"card-title\">\n <slot name=\"heading\">\n <ic-typography variant=\"h4\">\n <p>{heading}</p>\n </ic-typography>\n </slot>\n </div>\n {isSlotUsed(this.el, \"interaction-button\") && (\n <div class=\"interaction-button\">\n <slot name=\"interaction-button\"></slot>\n </div>\n )}\n </div>\n {(subheading || isSlotUsed(this.el, \"subheading\")) && (\n <div class=\"subheading\">\n <slot name=\"subheading\">\n <ic-typography variant=\"subtitle-small\">\n {subheading}\n </ic-typography>\n </slot>\n </div>\n )}\n {isSlotUsed(this.el, \"adornment\") && (\n <div class=\"adornment\">\n <slot name=\"adornment\"></slot>\n </div>\n )}\n {isSlotUsed(this.el, \"image-mid\") && (\n <div class=\"image-mid\">\n <slot name=\"image-mid\"></slot>\n </div>\n )}\n {(message || isSlotUsed(this.el, \"message\")) && (\n <div\n class={{\n [\"card-message\"]: true,\n }}\n >\n {message && <ic-typography variant=\"body\">{message}</ic-typography>}\n {isSlotUsed(this.el, \"message\") && <slot name=\"message\"></slot>}\n </div>\n )}\n {(isSlotUsed(this.el, \"interaction-controls\") || expandable) && (\n <div class=\"interaction-area\">\n <div class=\"interaction-controls\">\n <slot name=\"interaction-controls\"></slot>\n </div>\n {expandable && (\n <ic-tooltip\n id=\"ic-tooltip-expand-button\"\n label=\"Toggle expandable area\"\n silent\n >\n <button\n class={{\n [\"toggle-button\"]: true,\n [`toggle-button-${\n this.areaExpanded ? \"expanded\" : \"closed\"\n }`]: true,\n }}\n aria-label=\"Toggle expandable area\"\n aria-expanded={`${this.areaExpanded}`}\n aria-controls={\n this.areaExpanded ? \"expanded-content-area\" : null\n }\n onClick={this.toggleExpanded}\n innerHTML={chevronIcon}\n ></button>\n </ic-tooltip>\n )}\n </div>\n )}\n {isSlotUsed(this.el, \"expanded-content\") && this.areaExpanded && (\n <div class=\"expanded-content\" id=\"expanded-content-area\">\n <slot name=\"expanded-content\"></slot>\n </div>\n )}\n {isSlotUsed(this.el, \"badge\") && <slot name=\"badge\"></slot>}\n </Component>\n );\n }\n}\n"]}
|
@@ -148,5 +148,26 @@ describe("ic-card", () => {
|
|
148
148
|
//Can't expect anything in this test - this is to increase code coverage only
|
149
149
|
await page.rootInstance.setFocus().toHaveBeenCalled;
|
150
150
|
});
|
151
|
+
it("should test rendering slotted after initial render", async () => {
|
152
|
+
const page = await newSpecPage({
|
153
|
+
components: [Card],
|
154
|
+
html: `<ic-card heading="Card" message="This is a static card"></ic-card>`,
|
155
|
+
});
|
156
|
+
const icon = document.createElement("svg");
|
157
|
+
icon.setAttribute("slot", "icon");
|
158
|
+
const imageMid = document.createElement("svg");
|
159
|
+
imageMid.setAttribute("slot", "image-mid");
|
160
|
+
const imageTop = document.createElement("svg");
|
161
|
+
imageTop.setAttribute("slot", "image-top");
|
162
|
+
const button = document.createElement("button");
|
163
|
+
button.setAttribute("slot", "interaction-button");
|
164
|
+
page.rootInstance.hostMutationCallback([
|
165
|
+
{
|
166
|
+
type: "childList",
|
167
|
+
addedNodes: [icon, imageMid, imageTop, button],
|
168
|
+
removedNodes: [],
|
169
|
+
},
|
170
|
+
]);
|
171
|
+
});
|
151
172
|
});
|
152
173
|
//# sourceMappingURL=ic-card.spec.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-card.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-card/test/basic/ic-card.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,IAAI,GAAG,MAAM,WAA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C,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;QAC/E,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,gKAAgK;SACvK,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;QAEpC,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;QAEnC,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;QACvE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,2GAA2G;SAClH,CAAC,CAAC;QAEH,6EAA6E;QAC7E,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACrE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,oHAAoH;SAC3H,CAAC,CAAC;QAEH,6EAA6E;QAC7E,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from \"@stencil/core/testing\";\nimport { Card } from \"../../ic-card\";\n\ndescribe(\"ic-card\", () => {\n it(\"should render\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a static card\"></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render as a button\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a clickable card rendered as a button\" clickable=true></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render as a link\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a clickable card rendered as a button\" clickable=true href=\"/\"></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render full width variant\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" full-width=true message=\"This is a full width card\" clickable=true></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with a link parent\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<a href=\"/\"><ic-card heading=\"Card\" message=\"This is a clickable card\" clickable=true></ic-card></a>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should apply 'focussed' style when parent is focussed\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<a href=\"/\"><ic-card id=\"test-id\" heading=\"Card\" message=\"This is a clickable card\" clickable=true></ic-card></a>`,\n });\n\n expect(page.root).not.toBeNull;\n\n const element = await document.getElementById(\"test-id\");\n\n await expect(element.classList.contains(\"focussed\")).toBeFalsy;\n\n await element.focus();\n\n await expect(element.classList.contains(\"focussed\")).toBeTruthy;\n });\n\n it(\"should lose 'focussed' style when parent loses focus\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<a href=\"/\"><ic-card id=\"test-card\" heading=\"Card\" message=\"This is a clickable card\" clickable=true></ic-card></a>`,\n });\n\n expect(page.root).not.toBeNull;\n\n const element = await document.getElementById(\"test-card\");\n\n await element.focus();\n\n await expect(element.classList.contains(\"focussed\")).toBeTruthy;\n\n await element.blur();\n\n await expect(element.classList.contains(\"focussed\")).toBeFalsy;\n\n await page.rootInstance.disconnectedCallback();\n });\n\n it(\"should stop immediate propagation of a click event when disabled\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" message=\"This is a clickable card\" clickable=true disabled=true onclick=\"alert('test')\"></ic-card>`,\n });\n\n jest.spyOn(window, \"alert\").mockImplementation();\n\n const element = await document.getElementById(\"test-card\");\n\n element.click();\n\n await page.waitForChanges();\n\n await expect(window.alert).not.toHaveBeenCalled;\n });\n\n it(\"should render with a subheading\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with an interaction button\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"><ic-button variant=\"primary\" slot=\"interaction-button\">Click here</ic-button></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with a top image\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"><div slot=\"image-top\">Image placeholder</div></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with a middle image\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"><div slot=\"image-mid\">Image placeholder</div></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with interaction controls\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"><ic-button slot=\"interaction-controls\">Click here</ic-button></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render as expandable\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\" expandable></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render content in expanded area\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\" expandable><ic-typography slot=\"expanded-content\">Extra content</ic-typography></ic-card>`,\n });\n\n page.rootInstance.areaExpanded = true;\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should toggle expanded content when expansion toggle is clicked\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" message=\"This is a clickable card\" expandable><ic-typography slot=\"expanded-content\">Expanded</ic-typography></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n\n page.rootInstance.toggleExpanded();\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should call 'setFocus' when card as a button is focused\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a clickable card rendered as a button\" clickable=true></ic-card>`,\n });\n\n //Can't expect anything in this test - this is to increase code coverage only\n await page.rootInstance.setFocus().toHaveBeenCalled;\n });\n\n it(\"should call 'setFocus' when card as a link is focused\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a clickable card rendered as a button\" clickable=true href=\"/\"></ic-card>`,\n });\n\n //Can't expect anything in this test - this is to increase code coverage only\n await page.rootInstance.setFocus().toHaveBeenCalled;\n });\n});\n"]}
|
1
|
+
{"version":3,"file":"ic-card.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-card/test/basic/ic-card.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,QAAQ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E;QAClE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,oEAAoE;SAC3E,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/C,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC/C,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAE3C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;QAElD,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC;YACrC;gBACE,IAAI,EAAE,WAAW;gBACjB,UAAU,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;gBAC9C,YAAY,EAAE,EAAE;aACjB;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from \"@stencil/core/testing\";\nimport { Card } from \"../../ic-card\";\n\ndescribe(\"ic-card\", () => {\n it(\"should render\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a static card\"></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render as a button\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a clickable card rendered as a button\" clickable=true></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render as a link\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a clickable card rendered as a button\" clickable=true href=\"/\"></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render full width variant\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" full-width=true message=\"This is a full width card\" clickable=true></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with a link parent\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<a href=\"/\"><ic-card heading=\"Card\" message=\"This is a clickable card\" clickable=true></ic-card></a>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should apply 'focussed' style when parent is focussed\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<a href=\"/\"><ic-card id=\"test-id\" heading=\"Card\" message=\"This is a clickable card\" clickable=true></ic-card></a>`,\n });\n\n expect(page.root).not.toBeNull;\n\n const element = await document.getElementById(\"test-id\");\n\n await expect(element.classList.contains(\"focussed\")).toBeFalsy;\n\n await element.focus();\n\n await expect(element.classList.contains(\"focussed\")).toBeTruthy;\n });\n\n it(\"should lose 'focussed' style when parent loses focus\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<a href=\"/\"><ic-card id=\"test-card\" heading=\"Card\" message=\"This is a clickable card\" clickable=true></ic-card></a>`,\n });\n\n expect(page.root).not.toBeNull;\n\n const element = await document.getElementById(\"test-card\");\n\n await element.focus();\n\n await expect(element.classList.contains(\"focussed\")).toBeTruthy;\n\n await element.blur();\n\n await expect(element.classList.contains(\"focussed\")).toBeFalsy;\n\n await page.rootInstance.disconnectedCallback();\n });\n\n it(\"should stop immediate propagation of a click event when disabled\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" message=\"This is a clickable card\" clickable=true disabled=true onclick=\"alert('test')\"></ic-card>`,\n });\n\n jest.spyOn(window, \"alert\").mockImplementation();\n\n const element = await document.getElementById(\"test-card\");\n\n element.click();\n\n await page.waitForChanges();\n\n await expect(window.alert).not.toHaveBeenCalled;\n });\n\n it(\"should render with a subheading\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with an interaction button\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"><ic-button variant=\"primary\" slot=\"interaction-button\">Click here</ic-button></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with a top image\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"><div slot=\"image-top\">Image placeholder</div></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with a middle image\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"><div slot=\"image-mid\">Image placeholder</div></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with interaction controls\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\"><ic-button slot=\"interaction-controls\">Click here</ic-button></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render as expandable\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\" expandable></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render content in expanded area\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" subheading=\"Card subheading\" message=\"This is a card\" expandable><ic-typography slot=\"expanded-content\">Extra content</ic-typography></ic-card>`,\n });\n\n page.rootInstance.areaExpanded = true;\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should toggle expanded content when expansion toggle is clicked\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card id=\"test-card\" heading=\"Card\" message=\"This is a clickable card\" expandable><ic-typography slot=\"expanded-content\">Expanded</ic-typography></ic-card>`,\n });\n\n expect(page.root).toMatchSnapshot();\n\n page.rootInstance.toggleExpanded();\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should call 'setFocus' when card as a button is focused\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a clickable card rendered as a button\" clickable=true></ic-card>`,\n });\n\n //Can't expect anything in this test - this is to increase code coverage only\n await page.rootInstance.setFocus().toHaveBeenCalled;\n });\n\n it(\"should call 'setFocus' when card as a link is focused\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a clickable card rendered as a button\" clickable=true href=\"/\"></ic-card>`,\n });\n\n //Can't expect anything in this test - this is to increase code coverage only\n await page.rootInstance.setFocus().toHaveBeenCalled;\n });\n\n it(\"should test rendering slotted after initial render\", async () => {\n const page = await newSpecPage({\n components: [Card],\n html: `<ic-card heading=\"Card\" message=\"This is a static card\"></ic-card>`,\n });\n\n const icon = document.createElement(\"svg\");\n icon.setAttribute(\"slot\", \"icon\");\n\n const imageMid = document.createElement(\"svg\");\n imageMid.setAttribute(\"slot\", \"image-mid\");\n\n const imageTop = document.createElement(\"svg\");\n imageTop.setAttribute(\"slot\", \"image-top\");\n\n const button = document.createElement(\"button\");\n button.setAttribute(\"slot\", \"interaction-button\");\n\n page.rootInstance.hostMutationCallback([\n {\n type: \"childList\",\n addedNodes: [icon, imageMid, imageTop, button],\n removedNodes: [],\n },\n ]);\n });\n});\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { h, } from "@stencil/core";
|
2
|
-
import { onComponentRequiredPropUndefined, isSlotUsed, removeDisabledFalse, convertToRGBA, } from "../../utils/helpers";
|
2
|
+
import { onComponentRequiredPropUndefined, isSlotUsed, removeDisabledFalse, convertToRGBA, isElInAGGrid, } from "../../utils/helpers";
|
3
3
|
import dismissIcon from "../../assets/dismiss-icon.svg";
|
4
4
|
/**
|
5
5
|
* @slot icon - Content will be rendered at the start of the chip.
|
@@ -7,6 +7,7 @@ import dismissIcon from "../../assets/dismiss-icon.svg";
|
|
7
7
|
*/
|
8
8
|
export class Chip {
|
9
9
|
constructor() {
|
10
|
+
this.inAGGrid = false;
|
10
11
|
this.dismissAction = () => {
|
11
12
|
this.dismiss.emit();
|
12
13
|
this.icDismiss.emit();
|
@@ -50,6 +51,11 @@ export class Chip {
|
|
50
51
|
this.variant = "outlined";
|
51
52
|
}
|
52
53
|
}
|
54
|
+
componentWillRender() {
|
55
|
+
if (isElInAGGrid(this.el)) {
|
56
|
+
this.inAGGrid = true;
|
57
|
+
}
|
58
|
+
}
|
53
59
|
componentDidLoad() {
|
54
60
|
onComponentRequiredPropUndefined([{ prop: this.label, propName: "label" }], "Chip");
|
55
61
|
}
|
@@ -74,7 +80,7 @@ export class Chip {
|
|
74
80
|
dismissible,
|
75
81
|
hovered,
|
76
82
|
"white-background": this.variant === "outlined" && !this.transparentBackground,
|
77
|
-
} }, isSlotUsed(this.el, "icon") && (h("div", { class: "icon" }, h("slot", { name: "icon" }))), h("ic-typography", { variant: "label", "apply-vertical-margins": false, class:
|
83
|
+
} }, isSlotUsed(this.el, "icon") && (h("div", { class: "icon" }, h("slot", { name: "icon" }))), h("ic-typography", { variant: "label", "apply-vertical-margins": false, class: { label: true, "in-ag-grid": this.inAGGrid } }, h("span", null, label)), dismissible && (h("ic-tooltip", { label: "Dismiss", target: "dismiss-icon", class: { "tooltip-disabled": disabled } }, h("button", { id: "dismiss-icon", class: "dismiss-icon", "aria-label": `Dismiss ${label} chip`, disabled: disabled, tabindex: disabled ? -1 : 0, onClick: this.dismissAction, onMouseEnter: this.mouseEnterHandler, onMouseLeave: this.mouseLeaveHandler, innerHTML: dismissIcon }))), isSlotUsed(this.el, "badge") && h("slot", { name: "badge" }))));
|
78
84
|
}
|
79
85
|
static get is() { return "ic-chip"; }
|
80
86
|
static get encapsulation() { return "shadow"; }
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-chip.js","sourceRoot":"","sources":["../../../src/components/ic-chip/ic-chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,CAAC,EACD,IAAI,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EAEL,OAAO,EACP,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gCAAgC,EAChC,UAAU,EACV,mBAAmB,EACnB,aAAa,
|
1
|
+
{"version":3,"file":"ic-chip.js","sourceRoot":"","sources":["../../../src/components/ic-chip/ic-chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,CAAC,EACD,IAAI,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EAEL,OAAO,EACP,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gCAAgC,EAChC,UAAU,EACV,mBAAmB,EACnB,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,WAAW,MAAM,+BAA+B,CAAC;AAExD;;;GAGG;AAQH,MAAM,OAAO,IAAI;;QACP,aAAQ,GAAY,KAAK,CAAC;QAuG1B,kBAAa,GAAG,GAAS,EAAE;YACjC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,CAAC;QAEM,sBAAiB,GAAG,GAAS,EAAE;YACrC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,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AE,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE;gBAEnD,gBAAO,KAAK,CAAQ,CACN;YACf,WAAW,IAAI,CACd,kBACE,KAAK,EAAC,SAAS,EACf,MAAM,EAAC,cAAc,EACrB,KAAK,EAAE,EAAE,kBAAkB,EAAE,QAAQ,EAAE;gBAEvC,cACE,EAAE,EAAC,cAAc,EACjB,KAAK,EAAC,cAAc,gBACR,WAAW,KAAK,OAAO,EACnC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,IAAI,CAAC,aAAa,EAC3B,YAAY,EAAE,IAAI,CAAC,iBAAiB,EACpC,YAAY,EAAE,IAAI,CAAC,iBAAiB,EACpC,SAAS,EAAE,WAAW,GACd,CACC,CACd;YACA,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,YAAM,IAAI,EAAC,OAAO,GAAQ,CACvD,CACP,CACF,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n h,\n Prop,\n State,\n Listen,\n Event,\n EventEmitter,\n Element,\n Method,\n Watch,\n} from \"@stencil/core\";\nimport {\n onComponentRequiredPropUndefined,\n isSlotUsed,\n removeDisabledFalse,\n convertToRGBA,\n isElInAGGrid,\n} from \"../../utils/helpers\";\nimport { IcChipAppearance } from \"./ic-chip.types\";\nimport { IcColor, IcEmphasisType, IcSizes } from \"../../utils/types\";\nimport dismissIcon from \"../../assets/dismiss-icon.svg\";\n\n/**\n * @slot icon - Content will be rendered at the start of the chip.\n * @slot badge - Badge component overlaying the top right of the chip.\n */\n@Component({\n tag: \"ic-chip\",\n styleUrl: \"ic-chip.css\",\n shadow: {\n delegatesFocus: true,\n },\n})\nexport class Chip {\n private inAGGrid: boolean = false;\n\n @Element() el: HTMLIcChipElement;\n\n @State() hovered: boolean = false;\n @State() visible: boolean = true;\n\n /**\n * @deprecated This prop should not be used anymore. Use variant prop instead.\n */\n @Prop() appearance?: IcChipAppearance;\n\n /**\n * The custom chip colour. This prop will be applied to the chip component if `dismissible` is set to `false`.\n * Can be a hex value e.g. \"#ff0000\", RGB e.g. \"rgb(255, 0, 0)\", or RGBA e.g. \"rgba(255, 0, 0, 1)\".\n */\n @Prop() customColor?: IcColor = null;\n\n @Watch(\"customColor\")\n customColorHandler(): void {\n if (!this.dismissible) {\n this.setChipColour();\n }\n }\n\n /**\n * If `true`, the chip will appear disabled.\n */\n @Prop() disabled?: boolean = false;\n\n /**\n * If `true`, the chip will have a close button at the end to dismiss it.\n */\n @Prop() dismissible?: boolean = false;\n\n /**\n * The text rendered within the chip.\n */\n @Prop() label!: string;\n\n /**\n * The size of the chip.\n */\n @Prop() size?: IcSizes = \"default\";\n\n /**\n * If `true`, the outlined variant of chip will have a transparent background rather than white.\n */\n @Prop() transparentBackground?: boolean = true;\n\n /**\n * The emphasis of the chip.\n */\n @Prop() variant?: IcEmphasisType = \"filled\";\n\n /**\n * @deprecated This event should not be used anymore. Use icDismiss instead.\n */\n @Event() dismiss: EventEmitter<void>;\n\n /**\n * Is emitted when the user dismisses the chip.\n */\n @Event() icDismiss: EventEmitter<void>;\n\n componentWillLoad(): void {\n removeDisabledFalse(this.disabled, this.el);\n\n if (!this.dismissible) {\n this.setChipColour();\n }\n\n if (this.appearance === \"outline\") {\n this.variant = \"outlined\";\n }\n }\n\n componentWillRender(): void {\n if (isElInAGGrid(this.el)) {\n this.inAGGrid = true;\n }\n }\n\n componentDidLoad(): void {\n onComponentRequiredPropUndefined(\n [{ prop: this.label, propName: \"label\" }],\n \"Chip\"\n );\n }\n\n @Listen(\"icDismiss\", { capture: true })\n handleClick(): void {\n this.visible = !this.visible;\n }\n\n /**\n * Sets focus on the chip.\n */\n @Method()\n async setFocus(): Promise<void> {\n this.el.shadowRoot.querySelector(\"button\")?.focus();\n }\n\n private dismissAction = (): void => {\n this.dismiss.emit();\n this.icDismiss.emit();\n };\n\n private mouseEnterHandler = (): void => {\n this.hovered = true;\n };\n\n private mouseLeaveHandler = (): void => {\n this.hovered = false;\n };\n\n private setChipColour = () => {\n const colorRGBA = convertToRGBA(this.customColor);\n if (colorRGBA) {\n const { r, g, b, a } = colorRGBA;\n const foregroundColour =\n (r * 299 + g * 587 + b * 114) / 1000 > 133.3505 ? \"black\" : \"white\";\n this.el.setAttribute(\n \"style\",\n `--chip-custom-color: rgba(${r}, ${g}, ${b}, ${a}); --chip-custom-foreground-color: var(--ic-architectural-${foregroundColour})`\n );\n }\n };\n\n render() {\n const {\n label,\n appearance,\n variant,\n size,\n dismissible,\n visible,\n disabled,\n hovered,\n } = this;\n\n return (\n visible && (\n <div\n class={{\n chip: true,\n [`${appearance}`]: appearance !== undefined,\n [`${variant}`]: true,\n [`${size}`]: true,\n disabled,\n dismissible,\n hovered,\n \"white-background\":\n this.variant === \"outlined\" && !this.transparentBackground,\n }}\n >\n {isSlotUsed(this.el, \"icon\") && (\n <div class=\"icon\">\n <slot name=\"icon\" />\n </div>\n )}\n <ic-typography\n variant=\"label\"\n apply-vertical-margins={false}\n class={{ label: true, \"in-ag-grid\": this.inAGGrid }}\n >\n <span>{label}</span>\n </ic-typography>\n {dismissible && (\n <ic-tooltip\n label=\"Dismiss\"\n target=\"dismiss-icon\"\n class={{ \"tooltip-disabled\": disabled }}\n >\n <button\n id=\"dismiss-icon\"\n class=\"dismiss-icon\"\n aria-label={`Dismiss ${label} chip`}\n disabled={disabled}\n tabindex={disabled ? -1 : 0}\n onClick={this.dismissAction}\n onMouseEnter={this.mouseEnterHandler}\n onMouseLeave={this.mouseLeaveHandler}\n innerHTML={dismissIcon}\n ></button>\n </ic-tooltip>\n )}\n {isSlotUsed(this.el, \"badge\") && <slot name=\"badge\"></slot>}\n </div>\n )\n );\n }\n}\n"]}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { newSpecPage } from "@stencil/core/testing";
|
2
2
|
import { Chip } from "../../ic-chip";
|
3
|
+
import * as helpers from "../../../../utils/helpers";
|
3
4
|
describe("ic-chip component renders label", () => {
|
4
5
|
it("should render static", async () => {
|
5
6
|
const page = await newSpecPage({
|
@@ -150,5 +151,19 @@ describe("ic-chip component renders label", () => {
|
|
150
151
|
await page.waitForChanges();
|
151
152
|
expect(page.rootInstance.customColor).toBe("#00008B");
|
152
153
|
});
|
154
|
+
it("should apply the correct class when in an AG Grid", async () => {
|
155
|
+
Object.defineProperty(helpers, "isElInAGGrid", {
|
156
|
+
value: jest.fn().mockReturnValue(true),
|
157
|
+
});
|
158
|
+
const page = await newSpecPage({
|
159
|
+
components: [Chip],
|
160
|
+
html: `<ic-chip label="Default"></ic-chip>`,
|
161
|
+
});
|
162
|
+
await page.waitForChanges();
|
163
|
+
expect(page.rootInstance.inAGGrid).toBe(true);
|
164
|
+
expect(page.root.shadowRoot
|
165
|
+
.querySelector("ic-typography")
|
166
|
+
.classList.contains("in-ag-grid")).toBe(true);
|
167
|
+
});
|
153
168
|
});
|
154
169
|
//# sourceMappingURL=ic-chip.spec.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-chip.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-chip/test/basic/ic-chip.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,EAAE,CAAC,sBAAsB,E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EH,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAE/C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEtD,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from \"@stencil/core/testing\";\nimport { Chip } from \"../../ic-chip\";\n\ndescribe(\"ic-chip component renders label\", () => {\n it(\"should render static\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n </ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render dismissible\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" dismissible=\"true\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n </ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render disabled\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" dismissible=\"true\" disabled=\"true\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n </ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render small\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" dismissible=\"true\" size=\"small\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n </svg>\n </ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with custom colour\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" custom-color=\"#F8C8DC\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n</ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with custom rgb colour\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" custom-color=\"rgb(248,200,220)\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n</ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with custom colour that sets white foreground text\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" custom-color=\"#00008B\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n</ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should apply 'hovered' style when cursor is on dismiss button\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip id=\"test-id\" label=\"Label\" dismissible=\"true\"></ic-chip>`,\n });\n\n expect(page.root).not.toBeNull;\n\n const chip = await document.getElementById(\"test-id\");\n\n const dismissButton = page.root.shadowRoot.querySelector(\"button\");\n\n await expect(chip.classList.contains(\"hovered\")).toBeFalsy;\n\n const event = new Event(\"mouseenter\", {\n bubbles: true,\n cancelable: true,\n });\n\n dismissButton.dispatchEvent(event);\n await page.waitForChanges();\n\n await expect(chip.classList.contains(\"hovered\")).toBeTruthy;\n });\n\n it(\"should lose 'hovered' style when cursor moves off dismiss button\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip id=\"test-id\" label=\"Label\" dismissible=\"true\"></ic-chip>`,\n });\n\n expect(page.root).not.toBeNull;\n\n const chip = await document.getElementById(\"test-id\");\n\n const dismissButton = page.root.shadowRoot.querySelector(\"button\");\n\n const enterEvent = new Event(\"mouseenter\", {\n bubbles: true,\n cancelable: true,\n });\n\n dismissButton.dispatchEvent(enterEvent);\n await page.waitForChanges();\n\n await expect(chip.classList.contains(\"hovered\")).toBeTruthy;\n\n const leaveEvent = new Event(\"mouseleave\", {\n bubbles: true,\n cancelable: true,\n });\n\n dismissButton.dispatchEvent(leaveEvent);\n\n await expect(chip.classList.contains(\"hovered\")).toBeFalsy;\n });\n\n it(\"should close on dismiss icon click\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"This is dismissible\" dismissible=\"true\"></ic-chip>`,\n });\n\n let chip = await page.root.shadowRoot.querySelector(\"div\");\n const dismissButton = await page.root.shadowRoot.querySelector(\"button\");\n\n expect(chip).not.toBeNull();\n expect(dismissButton).not.toBeNull();\n\n await dismissButton.click();\n\n await page.waitForChanges();\n chip = await page.root.shadowRoot.querySelector(\"div\");\n\n expect(chip).toBeNull();\n });\n\n it(\"should call 'setFocus' when chip is focused\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"This is dismissible\" dismissible=\"true\"></ic-chip>`,\n });\n\n //Can't expect anything in this test - this is to increase code coverage only\n await page.rootInstance.setFocus().toHaveBeenCalled;\n });\n\n it(\"should switch custom colour after initial render\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Default\" custom-color=\"#F8C8DC\"></ic-chip>`,\n });\n\n const chip = document.querySelector(\"ic-chip\");\n\n expect(page.rootInstance.customColor).toBe(\"#F8C8DC\");\n\n chip.customColor = \"#00008B\";\n await page.waitForChanges();\n\n expect(page.rootInstance.customColor).toBe(\"#00008B\");\n });\n});\n"]}
|
1
|
+
{"version":3,"file":"ic-chip.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-chip/test/basic/ic-chip.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,2BAA2B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C7B,UAAU,EAAE,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,4DAA4D;SACnE,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAE/C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEtD,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;QACjE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE;YAC7C,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;SACvC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,qCAAqC;SAC5C,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,CACJ,IAAI,CAAC,IAAI,CAAC,UAAU;aACjB,aAAa,CAAC,eAAe,CAAC;aAC9B,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,CACpC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from \"@stencil/core/testing\";\nimport { Chip } from \"../../ic-chip\";\nimport * as helpers from \"../../../../utils/helpers\";\n\ndescribe(\"ic-chip component renders label\", () => {\n it(\"should render static\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n </ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render dismissible\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" dismissible=\"true\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n </ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render disabled\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" dismissible=\"true\" disabled=\"true\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n </ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render small\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" dismissible=\"true\" size=\"small\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n </svg>\n </ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with custom colour\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" custom-color=\"#F8C8DC\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n</ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with custom rgb colour\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" custom-color=\"rgb(248,200,220)\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n</ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should render with custom colour that sets white foreground text\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Label\" custom-color=\"#00008B\">\n <svg slot=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M10 0C4.48 0 0 4.48 0 10C0 15.52 4.48 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34 9 7 7.66 7 6C7 4.34 8.34 3 10 3ZM10 17.2C7.5 17.2 5.29 15.92 4 13.98C4.03 11.99 8 10.9 10 10.9C11.99 10.9 15.97 11.99 16 13.98C14.71 15.92 12.5 17.2 10 17.2Z\" fill=\"currentColor\"/>\n</svg>\n</ic-chip>`,\n });\n\n expect(page.root).toMatchSnapshot();\n });\n\n it(\"should apply 'hovered' style when cursor is on dismiss button\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip id=\"test-id\" label=\"Label\" dismissible=\"true\"></ic-chip>`,\n });\n\n expect(page.root).not.toBeNull;\n\n const chip = await document.getElementById(\"test-id\");\n\n const dismissButton = page.root.shadowRoot.querySelector(\"button\");\n\n await expect(chip.classList.contains(\"hovered\")).toBeFalsy;\n\n const event = new Event(\"mouseenter\", {\n bubbles: true,\n cancelable: true,\n });\n\n dismissButton.dispatchEvent(event);\n await page.waitForChanges();\n\n await expect(chip.classList.contains(\"hovered\")).toBeTruthy;\n });\n\n it(\"should lose 'hovered' style when cursor moves off dismiss button\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip id=\"test-id\" label=\"Label\" dismissible=\"true\"></ic-chip>`,\n });\n\n expect(page.root).not.toBeNull;\n\n const chip = await document.getElementById(\"test-id\");\n\n const dismissButton = page.root.shadowRoot.querySelector(\"button\");\n\n const enterEvent = new Event(\"mouseenter\", {\n bubbles: true,\n cancelable: true,\n });\n\n dismissButton.dispatchEvent(enterEvent);\n await page.waitForChanges();\n\n await expect(chip.classList.contains(\"hovered\")).toBeTruthy;\n\n const leaveEvent = new Event(\"mouseleave\", {\n bubbles: true,\n cancelable: true,\n });\n\n dismissButton.dispatchEvent(leaveEvent);\n\n await expect(chip.classList.contains(\"hovered\")).toBeFalsy;\n });\n\n it(\"should close on dismiss icon click\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"This is dismissible\" dismissible=\"true\"></ic-chip>`,\n });\n\n let chip = await page.root.shadowRoot.querySelector(\"div\");\n const dismissButton = await page.root.shadowRoot.querySelector(\"button\");\n\n expect(chip).not.toBeNull();\n expect(dismissButton).not.toBeNull();\n\n await dismissButton.click();\n\n await page.waitForChanges();\n chip = await page.root.shadowRoot.querySelector(\"div\");\n\n expect(chip).toBeNull();\n });\n\n it(\"should call 'setFocus' when chip is focused\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"This is dismissible\" dismissible=\"true\"></ic-chip>`,\n });\n\n //Can't expect anything in this test - this is to increase code coverage only\n await page.rootInstance.setFocus().toHaveBeenCalled;\n });\n\n it(\"should switch custom colour after initial render\", async () => {\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Default\" custom-color=\"#F8C8DC\"></ic-chip>`,\n });\n\n const chip = document.querySelector(\"ic-chip\");\n\n expect(page.rootInstance.customColor).toBe(\"#F8C8DC\");\n\n chip.customColor = \"#00008B\";\n await page.waitForChanges();\n\n expect(page.rootInstance.customColor).toBe(\"#00008B\");\n });\n\n it(\"should apply the correct class when in an AG Grid\", async () => {\n Object.defineProperty(helpers, \"isElInAGGrid\", {\n value: jest.fn().mockReturnValue(true),\n });\n\n const page = await newSpecPage({\n components: [Chip],\n html: `<ic-chip label=\"Default\"></ic-chip>`,\n });\n\n await page.waitForChanges();\n\n expect(page.rootInstance.inAGGrid).toBe(true);\n expect(\n page.root.shadowRoot\n .querySelector(\"ic-typography\")\n .classList.contains(\"in-ag-grid\")\n ).toBe(true);\n });\n});\n"]}
|