@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
@@ -15,16 +15,25 @@ export class ClassificationBanner {
|
|
15
15
|
this.upTo = false;
|
16
16
|
}
|
17
17
|
render() {
|
18
|
-
const {
|
18
|
+
const { inline, upTo } = this;
|
19
|
+
// In case of unrecognized props, fallback to default
|
20
|
+
let { country, additionalSelectors, classification } = this;
|
21
|
+
if (!country)
|
22
|
+
country = "";
|
23
|
+
if (!additionalSelectors)
|
24
|
+
additionalSelectors = "";
|
25
|
+
if (!classification ||
|
26
|
+
(classification && !classificationText[classification]))
|
27
|
+
classification = "default";
|
19
28
|
return (h(Host, { class: { ["inline"]: inline } }, h("banner", { "aria-label": "Protective marking", class: {
|
20
29
|
["classification-banner"]: true,
|
21
30
|
[`${classification}`]: classification,
|
22
31
|
} }, classification !== "default" ? (h("span", { class: "offscreen" }, "The protective marking of this page is:", " ")) : null, h("ic-typography", { variant: "caption-uppercase" }, classification === "default"
|
23
32
|
? classificationText[classification]
|
24
33
|
: `${upTo ? "up to" : ""}
|
25
|
-
${country
|
34
|
+
${country}
|
26
35
|
${classificationText[classification]}
|
27
|
-
${additionalSelectors
|
36
|
+
${additionalSelectors}`))));
|
28
37
|
}
|
29
38
|
static get is() { return "ic-classification-banner"; }
|
30
39
|
static get encapsulation() { return "shadow"; }
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-classification-banner.js","sourceRoot":"","sources":["../../../src/components/ic-classification-banner/ic-classification-banner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGzD,MAAM,kBAAkB,GAAG;IACzB,OAAO,EAAE,4BAA4B;IACrC,QAAQ,EAAE,UAAU;IACpB,oBAAoB,EAAE,oBAAoB;IAC1C,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,YAAY;CAC3B,CAAC;AAOF,MAAM,OAAO,oBAAoB;;mCAIQ,EAAE;8BAIO,SAAS;uBAI9B,IAAI;sBAIJ,KAAK;oBAIP,KAAK;;IAE9B,MAAM;QACJ,MAAM,EAAE,
|
1
|
+
{"version":3,"file":"ic-classification-banner.js","sourceRoot":"","sources":["../../../src/components/ic-classification-banner/ic-classification-banner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGzD,MAAM,kBAAkB,GAAG;IACzB,OAAO,EAAE,4BAA4B;IACrC,QAAQ,EAAE,UAAU;IACpB,oBAAoB,EAAE,oBAAoB;IAC1C,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,YAAY;CAC3B,CAAC;AAOF,MAAM,OAAO,oBAAoB;;mCAIQ,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sourcesContent":["import { Component, Prop, h, Host } from \"@stencil/core\";\nimport { IcProtectiveMarkings } from \"./ic-classification-banner.types\";\n\nconst classificationText = {\n default: \"protective marking not set\",\n official: \"official\",\n \"official-sensitive\": \"official sensitive\",\n secret: \"secret\",\n \"top-secret\": \"top secret\",\n};\n\n@Component({\n tag: \"ic-classification-banner\",\n styleUrl: \"ic-classification-banner.css\",\n shadow: true,\n})\nexport class ClassificationBanner {\n /**\n * The additional information that will be displayed after the classification.\n */\n @Prop() additionalSelectors?: string = \"\";\n /**\n * The classification level to be displayed - also determines the banner and text colour.\n */\n @Prop() classification?: IcProtectiveMarkings = \"default\";\n /**\n * The optional text that will be displayed before classification to specify relevant country/countries.\n */\n @Prop() country?: string = \"uk\";\n /**\n * If `true`, the banner will appear inline with the page, instead of sticking to the bottom of the page.\n */\n @Prop() inline?: boolean = false;\n /**\n * If `true`, \"Up to\" will be displayed before the classification and country.\n */\n @Prop() upTo?: boolean = false;\n\n render() {\n const { inline, upTo } = this;\n\n // In case of unrecognized props, fallback to default\n let { country, additionalSelectors, classification } = this;\n if (!country) country = \"\";\n if (!additionalSelectors) additionalSelectors = \"\";\n if (\n !classification ||\n (classification && !classificationText[classification])\n )\n classification = \"default\";\n\n return (\n <Host class={{ [\"inline\"]: inline }}>\n <banner\n aria-label=\"Protective marking\"\n class={{\n [\"classification-banner\"]: true,\n [`${classification}`]: classification,\n }}\n >\n {classification !== \"default\" ? (\n <span class=\"offscreen\">\n The protective marking of this page is:{\" \"}\n </span>\n ) : null}\n <ic-typography variant=\"caption-uppercase\">\n {classification === \"default\"\n ? classificationText[classification]\n : `${upTo ? \"up to\" : \"\"} \n ${country} \n ${classificationText[classification]} \n ${additionalSelectors}`}\n </ic-typography>\n </banner>\n </Host>\n );\n }\n}\n"]}
|
@@ -121,6 +121,54 @@ describe("ic-classification-banner component", () => {
|
|
121
121
|
</mock:shadow-root>
|
122
122
|
</ic-classification-banner>`);
|
123
123
|
});
|
124
|
+
it("should render default banner if no props are passed", async () => {
|
125
|
+
const page = await newSpecPage({
|
126
|
+
components: [ClassificationBanner],
|
127
|
+
html: `<ic-classification-banner></ic-classification-banner>`,
|
128
|
+
});
|
129
|
+
expect(page.root).toEqualHtml(`
|
130
|
+
<ic-classification-banner>
|
131
|
+
<mock:shadow-root>
|
132
|
+
<banner aria-label="Protective marking" class="classification-banner default">
|
133
|
+
<ic-typography variant="caption-uppercase">
|
134
|
+
protective marking not set
|
135
|
+
</ic-typography>
|
136
|
+
</banner>
|
137
|
+
</mock:shadow-root>
|
138
|
+
</ic-classification-banner>`);
|
139
|
+
});
|
140
|
+
it("should render default banner if props with empty strings are passed", async () => {
|
141
|
+
const page = await newSpecPage({
|
142
|
+
components: [ClassificationBanner],
|
143
|
+
html: `<ic-classification-banner classification="" country="" additionalSelectors=""></ic-classification-banner>`,
|
144
|
+
});
|
145
|
+
expect(page.root).toEqualHtml(`
|
146
|
+
<ic-classification-banner classification="" country="" additionalSelectors="">
|
147
|
+
<mock:shadow-root>
|
148
|
+
<banner aria-label="Protective marking" class="classification-banner default">
|
149
|
+
<ic-typography variant="caption-uppercase">
|
150
|
+
protective marking not set
|
151
|
+
</ic-typography>
|
152
|
+
</banner>
|
153
|
+
</mock:shadow-root>
|
154
|
+
</ic-classification-banner>`);
|
155
|
+
});
|
156
|
+
it("should render default banner if props with undefined are passed", async () => {
|
157
|
+
const page = await newSpecPage({
|
158
|
+
components: [ClassificationBanner],
|
159
|
+
html: `<ic-classification-banner classification=${undefined} country=${undefined} additionalSelectors=${undefined}></ic-classification-banner>`,
|
160
|
+
});
|
161
|
+
expect(page.root).toEqualHtml(`
|
162
|
+
<ic-classification-banner classification="undefined" country="undefined" additionalSelectors="undefined">
|
163
|
+
<mock:shadow-root>
|
164
|
+
<banner aria-label="Protective marking" class="classification-banner default">
|
165
|
+
<ic-typography variant="caption-uppercase">
|
166
|
+
protective marking not set
|
167
|
+
</ic-typography>
|
168
|
+
</banner>
|
169
|
+
</mock:shadow-root>
|
170
|
+
</ic-classification-banner>`);
|
171
|
+
});
|
124
172
|
it("should render with additional selectors after classification when supplied", async () => {
|
125
173
|
const page = await newSpecPage({
|
126
174
|
components: [ClassificationBanner],
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-classification-banner.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-classification-banner/test/basic/ic-classification-banner.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEtE,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,EAAE,CAAC,2EAA2E,EAAE,KAAK,IAAI,EAAE;QACzF,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,oBAAoB,CAAC;YAClC,IAAI,EAAE,uDAAuD;SAC9D,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;CAQjC,CAAC,CAAC;IACD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,oBAAoB,CAAC;YAClC,IAAI,EAAE,iFAAiF;SACxF,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;oCAQE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QACzE,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,oBAAoB,CAAC;YAClC,IAAI,EAAE,2FAA2F;SAClG,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;oCAQE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K,IAAI,EAAE;QAC9D,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,oBAAoB,CAAC;YAClC,IAAI,EAAE,4FAA4F;SACnG,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;oCAQE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4EAA4E,EAAE,KAAK,IAAI,EAAE;QAC1F,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,oBAAoB,CAAC;YAClC,IAAI,EAAE,6GAA6G;SACpH,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;oCAQE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from \"@stencil/core/testing\";\nimport { ClassificationBanner } from \"../../ic-classification-banner\";\n\ndescribe(\"ic-classification-banner component\", () => {\n it(\"should render with default classification text when no classification set\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner>\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner default\">\n <ic-typography variant=\"caption-uppercase\">protective marking not set</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>\n`);\n });\n\n it(\"should render with official classification text\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk official</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with official sensitive classification text\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official-sensitive\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official-sensitive\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official-sensitive\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk official sensitive</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with secret classification text\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"secret\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"secret\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner secret\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk secret</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with top secret classification text\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"top-secret\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"top-secret\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner top-secret\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk top secret</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with up to before classification\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\" up-to=true></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\" up-to=true>\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">up to uk official</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with a different country when supplied\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\" country=\"us\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\" country=\"us\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">us official</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it('should render with no country when supplied \"\"', async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\" country=\"\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\" country=\"\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">official</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with additional selectors after classification when supplied\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\" additional-selectors=\"ukic\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\" additional-selectors=\"ukic\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk official ukic</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n});\n"]}
|
1
|
+
{"version":3,"file":"ic-classification-banner.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-classification-banner/test/basic/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ACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from \"@stencil/core/testing\";\nimport { ClassificationBanner } from \"../../ic-classification-banner\";\n\ndescribe(\"ic-classification-banner component\", () => {\n it(\"should render with default classification text when no classification set\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner>\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner default\">\n <ic-typography variant=\"caption-uppercase\">protective marking not set</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>\n`);\n });\n\n it(\"should render with official classification text\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk official</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with official sensitive classification text\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official-sensitive\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official-sensitive\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official-sensitive\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk official sensitive</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with secret classification text\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"secret\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"secret\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner secret\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk secret</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with top secret classification text\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"top-secret\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"top-secret\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner top-secret\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk top secret</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with up to before classification\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\" up-to=true></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\" up-to=true>\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">up to uk official</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with a different country when supplied\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\" country=\"us\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\" country=\"us\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">us official</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it('should render with no country when supplied \"\"', async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\" country=\"\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\" country=\"\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">official</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render default banner if no props are passed\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner></ic-classification-banner>`,\n });\n expect(page.root).toEqualHtml(`\n <ic-classification-banner>\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner default\">\n <ic-typography variant=\"caption-uppercase\">\n protective marking not set\n </ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render default banner if props with empty strings are passed\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"\" country=\"\" additionalSelectors=\"\"></ic-classification-banner>`,\n });\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"\" country=\"\" additionalSelectors=\"\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner default\">\n <ic-typography variant=\"caption-uppercase\">\n protective marking not set\n </ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render default banner if props with undefined are passed\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=${undefined} country=${undefined} additionalSelectors=${undefined}></ic-classification-banner>`,\n });\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"undefined\" country=\"undefined\" additionalSelectors=\"undefined\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner default\">\n <ic-typography variant=\"caption-uppercase\">\n protective marking not set\n </ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n\n it(\"should render with additional selectors after classification when supplied\", async () => {\n const page = await newSpecPage({\n components: [ClassificationBanner],\n html: `<ic-classification-banner classification=\"official\" additional-selectors=\"ukic\"></ic-classification-banner>`,\n });\n\n expect(page.root).toEqualHtml(`\n <ic-classification-banner classification=\"official\" additional-selectors=\"ukic\">\n <mock:shadow-root>\n <banner aria-label=\"Protective marking\" class=\"classification-banner official\">\n <span class=\"offscreen\">The protective marking of this page is: </span>\n <ic-typography variant=\"caption-uppercase\">uk official ukic</ic-typography>\n </banner>\n </mock:shadow-root>\n </ic-classification-banner>`);\n });\n});\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { h, Host } from "@stencil/core";
|
2
|
-
import { isSlotUsed, onComponentRequiredPropUndefined, } from "../../utils/helpers";
|
1
|
+
import { h, Host, forceUpdate } from "@stencil/core";
|
2
|
+
import { isSlotUsed, onComponentRequiredPropUndefined, checkSlotInChildMutations, } from "../../utils/helpers";
|
3
3
|
/**
|
4
4
|
* @slot image - Content is placed at the top above all other content.
|
5
5
|
* @slot actions - Content is placed at the bottom below all other content.
|
@@ -9,6 +9,17 @@ import { isSlotUsed, onComponentRequiredPropUndefined, } from "../../utils/helpe
|
|
9
9
|
*/
|
10
10
|
export class EmptyState {
|
11
11
|
constructor() {
|
12
|
+
this.hostMutationObserver = null;
|
13
|
+
this.hostMutationCallback = (mutationList) => {
|
14
|
+
if (mutationList.some(({ type, addedNodes, removedNodes }) => type === "childList"
|
15
|
+
? checkSlotInChildMutations(addedNodes, removedNodes, [
|
16
|
+
"image",
|
17
|
+
"actions",
|
18
|
+
])
|
19
|
+
: false)) {
|
20
|
+
forceUpdate(this);
|
21
|
+
}
|
22
|
+
};
|
12
23
|
this.aligned = "left";
|
13
24
|
this.body = undefined;
|
14
25
|
this.bodyMaxLines = undefined;
|
@@ -16,9 +27,17 @@ export class EmptyState {
|
|
16
27
|
this.imageSize = "default";
|
17
28
|
this.subheading = undefined;
|
18
29
|
}
|
30
|
+
disconnectedCallback() {
|
31
|
+
var _a;
|
32
|
+
(_a = this.hostMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
33
|
+
}
|
19
34
|
componentDidLoad() {
|
20
35
|
!isSlotUsed(this.el, "heading") &&
|
21
36
|
onComponentRequiredPropUndefined([{ prop: this.heading, propName: "heading" }], "Empty State");
|
37
|
+
this.hostMutationObserver = new MutationObserver(this.hostMutationCallback);
|
38
|
+
this.hostMutationObserver.observe(this.el, {
|
39
|
+
childList: true,
|
40
|
+
});
|
22
41
|
}
|
23
42
|
render() {
|
24
43
|
const { aligned, body, bodyMaxLines, heading, imageSize, subheading } = this;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-empty-state.js","sourceRoot":"","sources":["../../../src/components/ic-empty-state/ic-empty-state.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
1
|
+
{"version":3,"file":"ic-empty-state.js","sourceRoot":"","sources":["../../../src/components/ic-empty-state/ic-empty-state.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG/E,OAAO,EACL,UAAU,EACV,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAG7B;;;;;;GAMG;AAMH,MAAM,OAAO,UAAU;;QACb,yBAAoB,GAAqB,IAAI,CAAC;QAmD9C,yBAAoB,GAAG,CAAC,YAA8B,EAAQ,EAAE;YACtE,IACE,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE,CACvD,IAAI,KAAK,WAAW;gBAClB,CAAC,CAAC,yBAAyB,CAAC,UAAU,EAAE,YAAY,EAAE;oBAClD,OAAO;oBACP,SAAS;iBACV,CAAC;gBACJ,CAAC,CAAC,KAAK,CACV,EACD,CAAC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QAAQ,EAAE,YAAY,IAAG,IAAI,CAAiB,CACxD,CACH;YACL,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,IAAI,CACjC,WAAK,KAAK,EAAC,aAAa;gBACtB,YAAM,IAAI,EAAC,SAAS,GAAG,CACnB,CACP,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { h, Component, Host, Prop, Element, forceUpdate } from \"@stencil/core\";\n\nimport { IcEmptyStateAlignment } from \"./ic-empty-state.types\";\nimport {\n isSlotUsed,\n onComponentRequiredPropUndefined,\n checkSlotInChildMutations,\n} from \"../../utils/helpers\";\nimport { IcSizes } from \"../../utils/types\";\n\n/**\n * @slot image - Content is placed at the top above all other content.\n * @slot actions - Content is placed at the bottom below all other content.\n * @slot heading - Content will be rendered in place of the heading prop.\n * @slot subheading - Content will be rendered in place of the subheading prop.\n * @slot body - Content will be rendered in place of the body prop.\n */\n@Component({\n tag: \"ic-empty-state\",\n styleUrl: \"ic-empty-state.css\",\n shadow: true,\n})\nexport class EmptyState {\n private hostMutationObserver: MutationObserver = null;\n\n @Element() el: HTMLIcEmptyStateElement;\n\n /**\n * The alignment of the empty state container.\n */\n @Prop() aligned?: IcEmptyStateAlignment = \"left\";\n\n /**\n * The body text rendered in the empty state container.\n */\n @Prop() body?: string;\n\n /**\n * The number of lines of body text to display before truncating.\n */\n @Prop() bodyMaxLines?: number;\n\n /**\n * The title rendered in the empty state container.\n */\n @Prop() heading?: string;\n\n /**\n * The size of the image or icon used in the image slot.\n */\n @Prop() imageSize?: IcSizes = \"default\";\n\n /**\n * The subtitle rendered in the empty state container.\n */\n @Prop() subheading?: string;\n\n disconnectedCallback(): void {\n this.hostMutationObserver?.disconnect();\n }\n\n componentDidLoad(): void {\n !isSlotUsed(this.el, \"heading\") &&\n onComponentRequiredPropUndefined(\n [{ prop: this.heading, propName: \"heading\" }],\n \"Empty State\"\n );\n\n this.hostMutationObserver = new MutationObserver(this.hostMutationCallback);\n this.hostMutationObserver.observe(this.el, {\n childList: true,\n });\n }\n\n private hostMutationCallback = (mutationList: MutationRecord[]): void => {\n if (\n mutationList.some(({ type, addedNodes, removedNodes }) =>\n type === \"childList\"\n ? checkSlotInChildMutations(addedNodes, removedNodes, [\n \"image\",\n \"actions\",\n ])\n : false\n )\n ) {\n forceUpdate(this);\n }\n };\n\n render() {\n const { aligned, body, bodyMaxLines, heading, imageSize, subheading } =\n this;\n return (\n <Host\n class={{\n [`${aligned}`]: true,\n [`image-${imageSize}`]: isSlotUsed(this.el, \"image\"),\n }}\n >\n {isSlotUsed(this.el, \"image\") && <slot name=\"image\"></slot>}\n <div>\n <slot name=\"heading\">\n <ic-typography variant=\"h4\">{heading}</ic-typography>\n </slot>\n <slot name=\"subheading\">\n <ic-typography variant=\"subtitle-small\">{subheading}</ic-typography>\n </slot>\n <slot name=\"body\">\n <ic-typography maxLines={bodyMaxLines}>{body}</ic-typography>\n </slot>\n </div>\n {isSlotUsed(this.el, \"actions\") && (\n <div class=\"action-area\">\n <slot name=\"actions\" />\n </div>\n )}\n </Host>\n );\n }\n}\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { Host, h, } from "@stencil/core";
|
1
|
+
import { Host, h, forceUpdate, } from "@stencil/core";
|
2
2
|
import { IcThemeForegroundEnum, } from "../../utils/types";
|
3
|
-
import { slotHasContent, getThemeForegroundColor, onComponentRequiredPropUndefined, isPropDefined, isSlotUsed, } from "../../utils/helpers";
|
3
|
+
import { slotHasContent, getThemeForegroundColor, onComponentRequiredPropUndefined, isPropDefined, isSlotUsed, checkSlotInChildMutations, } from "../../utils/helpers";
|
4
4
|
/**
|
5
5
|
* @slot heading - Content will be rendered in the title area, in place of the heading.
|
6
6
|
* @slot subheading - Content will be rendered in the title area, in place of the subheading.
|
@@ -9,6 +9,14 @@ import { slotHasContent, getThemeForegroundColor, onComponentRequiredPropUndefin
|
|
9
9
|
*/
|
10
10
|
export class Hero {
|
11
11
|
constructor() {
|
12
|
+
this.hostMutationObserver = null;
|
13
|
+
this.hostMutationCallback = (mutationList) => {
|
14
|
+
if (mutationList.some(({ type, addedNodes, removedNodes }) => type === "childList"
|
15
|
+
? checkSlotInChildMutations(addedNodes, removedNodes, "secondary")
|
16
|
+
: false)) {
|
17
|
+
forceUpdate(this);
|
18
|
+
}
|
19
|
+
};
|
12
20
|
this.foregroundColor = getThemeForegroundColor();
|
13
21
|
this.rightContent = false;
|
14
22
|
this.leftContentFullWidth = !this.rightContent && this.secondaryHeading === undefined;
|
@@ -24,12 +32,20 @@ export class Hero {
|
|
24
32
|
this.small = false;
|
25
33
|
this.subheading = undefined;
|
26
34
|
}
|
35
|
+
disconnectedCallback() {
|
36
|
+
var _a;
|
37
|
+
(_a = this.hostMutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
38
|
+
}
|
27
39
|
componentWillLoad() {
|
28
40
|
this.rightContent = slotHasContent(this.el, "secondary");
|
29
41
|
}
|
30
42
|
componentDidLoad() {
|
31
43
|
!isSlotUsed(this.el, "heading") &&
|
32
44
|
onComponentRequiredPropUndefined([{ prop: this.heading, propName: "heading" }], "Hero");
|
45
|
+
this.hostMutationObserver = new MutationObserver(this.hostMutationCallback);
|
46
|
+
this.hostMutationObserver.observe(this.el, {
|
47
|
+
childList: true,
|
48
|
+
});
|
33
49
|
}
|
34
50
|
componentWillRender() {
|
35
51
|
this.rightContent = slotHasContent(this.el, "secondary");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-hero.js","sourceRoot":"","sources":["../../../src/components/ic-hero/ic-hero.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,CAAC,EACD,KAAK,EACL,MAAM,GACP,MAAM,e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ACH;oBACN,WAAK,KAAK,EAAC,YAAY;wBACrB,YAAM,IAAI,EAAC,YAAY;4BACrB,qBAAe,OAAO,EAAC,MAAM,IAAE,UAAU,CAAiB,CACrD,CACH;oBACN,WAAK,KAAK,EAAC,uBAAuB;wBAChC,YAAM,IAAI,EAAC,aAAa,GAAQ,CAC5B,CACF;gBACL,CAAC,aAAa,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CACzD,WAAK,KAAK,EAAC,iBAAiB;oBAC1B,YAAM,IAAI,EAAC,WAAW,IACnB,gBAAgB,IAAI,CACnB,WAAK,KAAK,EAAC,qBAAqB;wBAC9B,WAAK,KAAK,EAAC,mBAAmB;4BAC5B,qBAAe,OAAO,EAAC,IAAI,IACxB,gBAAgB,CACH,CACZ;wBACN,WAAK,KAAK,EAAC,sBAAsB;4BAC/B,qBAAe,OAAO,EAAC,gBAAgB,IACpC,mBAAmB,CACN,CACZ,CACF,CACP,CACI,CACH,CACP,CACoB,CAClB,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Element,\n Host,\n Prop,\n h,\n State,\n Listen,\n} from \"@stencil/core\";\nimport {\n IcAlignment,\n IcSizesNoLarge,\n IcTheme,\n IcThemeForeground,\n IcThemeForegroundEnum,\n} from \"../../utils/types\";\nimport {\n slotHasContent,\n getThemeForegroundColor,\n onComponentRequiredPropUndefined,\n isPropDefined,\n isSlotUsed,\n} from \"../../utils/helpers\";\nimport { IcHeroContentAlignments } from \"./ic-hero.types\";\n\n/**\n * @slot heading - Content will be rendered in the title area, in place of the heading.\n * @slot subheading - Content will be rendered in the title area, in place of the subheading.\n * @slot interaction - Content will be rendered in the interaction area, adjacent to the title area.\n * @slot secondary - Content will be rendered in the secondary content area.\n */\n\n@Component({\n tag: \"ic-hero\",\n styleUrl: \"ic-hero.css\",\n shadow: true,\n})\nexport class Hero {\n @Element() el: HTMLIcHeroElement;\n\n @State() foregroundColor: IcThemeForeground = getThemeForegroundColor();\n @State() rightContent: boolean = false;\n // set by above state\n @State() leftContentFullWidth: boolean =\n !this.rightContent && this.secondaryHeading === undefined;\n @State() scrollFactor: string = \"right -100px\";\n\n /**\n * The alignment of the hero.\n */\n @Prop() aligned: IcAlignment = \"left\";\n\n /**\n * The optional background image.\n */\n @Prop() backgroundImage?: string;\n\n /**\n * The alignment of the hero content.\n */\n @Prop() contentAligned: IcHeroContentAlignments = \"left\";\n\n /**\n * If `true`, the background image (if set) will not scroll using a parallax effect.\n */\n @Prop() disableBackgroundParallax?: boolean = false;\n\n /**\n * The heading of the hero.\n */\n @Prop() heading: string;\n\n /**\n * The optional secondary heading, replaced by slotted right content.\n */\n @Prop() secondaryHeading?: string;\n\n /**\n * The optional secondary subheading, replaced by slotted right content.\n */\n @Prop() secondarySubheading?: string;\n\n /**\n * The size of the hero component.\n */\n @Prop() size?: IcSizesNoLarge = \"default\";\n\n /**\n * @deprecated This prop should not be used anymore. Set prop `size` to \"small\" instead.\n */\n @Prop() small?: boolean = false;\n\n /**\n * The description for the hero.\n */\n @Prop() subheading?: string;\n\n componentWillLoad(): void {\n this.rightContent = slotHasContent(this.el, \"secondary\");\n }\n\n componentDidLoad(): void {\n !isSlotUsed(this.el, \"heading\") &&\n onComponentRequiredPropUndefined(\n [{ prop: this.heading, propName: \"heading\" }],\n \"Hero\"\n );\n }\n\n componentWillRender(): void {\n this.rightContent = slotHasContent(this.el, \"secondary\");\n }\n\n @Listen(\"themeChange\", { target: \"document\" })\n themeChangeHandler(ev: CustomEvent): void {\n const theme: IcTheme = ev.detail;\n this.foregroundColor = theme.mode;\n }\n\n @Listen(\"scroll\", { target: \"document\" })\n doScroll(): void {\n if (this.disableBackgroundParallax) {\n return;\n }\n\n const scrolltotop = document.scrollingElement.scrollTop;\n const factor = 0.4;\n const y = -100 + scrolltotop * factor;\n this.scrollFactor = \"right \" + y + \"px\";\n }\n\n render() {\n const {\n aligned,\n small,\n size,\n heading,\n subheading,\n secondaryHeading,\n secondarySubheading,\n foregroundColor,\n backgroundImage,\n scrollFactor,\n } = this;\n\n let style = {};\n\n if (isPropDefined(backgroundImage)) {\n style = {\n \"background-image\": \"url(\" + backgroundImage + \")\",\n \"background-position\": scrollFactor,\n };\n }\n\n return (\n <Host\n class={{\n [IcThemeForegroundEnum.Dark]:\n foregroundColor === IcThemeForegroundEnum.Dark,\n [\"has-background-image\"]: backgroundImage !== undefined,\n [\"small\"]: small || size === \"small\",\n [\"secondary-heading\"]: !!secondaryHeading,\n }}\n style={style}\n >\n <ic-section-container\n aligned={aligned}\n fullHeight\n class=\"section-container\"\n >\n <div\n class={{\n [\"left-container\"]: true,\n [\"left-container-full-width\"]: this.leftContentFullWidth,\n }}\n >\n <div class=\"heading\">\n <slot name=\"heading\">\n <ic-typography\n variant={small || size === \"small\" ? \"h2\" : \"h1\"}\n class={{\n [\"heading-bottom-spacing\"]: !small && size !== \"small\",\n }}\n >\n {heading}\n </ic-typography>\n </slot>\n </div>\n <div class=\"subheading\">\n <slot name=\"subheading\">\n <ic-typography variant=\"body\">{subheading}</ic-typography>\n </slot>\n </div>\n <div class=\"interaction-container\">\n <slot name=\"interaction\"></slot>\n </div>\n </div>\n {(isPropDefined(secondaryHeading) || this.rightContent) && (\n <div class=\"right-container\">\n <slot name=\"secondary\">\n {secondaryHeading && (\n <div class=\"secondary-container\">\n <div class=\"secondary-heading\">\n <ic-typography variant=\"h4\">\n {secondaryHeading}\n </ic-typography>\n </div>\n <div class=\"secondary-subheading\">\n <ic-typography variant=\"subtitle-small\">\n {secondarySubheading}\n </ic-typography>\n </div>\n </div>\n )}\n </slot>\n </div>\n )}\n </ic-section-container>\n </Host>\n );\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ic-hero.js","sourceRoot":"","sources":["../../../src/components/ic-hero/ic-hero.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,CAAC,EACD,KAAK,EACL,MAAM,EACN,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAKL,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,gCAAgC,EAChC,aAAa,EACb,UAAU,EACV,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAG7B;;;;;GAKG;AAOH,MAAM,OAAO,IAAI;;QACP,yBAAoB,GAAqB,IAAI,CAAC;QAwG9C,yBAAoB,GAAG,CAAC,YAA8B,EAAQ,EAAE;YACtE,IACE,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE,CACvD,IAAI,KAAK,WAAW;gBAClB,CAAC,CAAC,yBAAyB,CAAC,UAAU,EAAE,YAAY,EAAE,WAAW,CAAC;gBAClE,CAAC,CAAC,KAAK,CACV,EACD,CAAC;gBACD,WAAW,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC,CAAC;+BA9G4C,uBAAuB,EAAE;4BACtC,KAAK;oCAGpC,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,gBAAgB,KAAK,SAAS;4BAC3B,cAAc;uBAKf,MAAM;;8BAUa,MAAM;yCAKV,KAAK;;;;oBAoBnB,SAAS;qBAKf,KAAK;;;IAO/B,oBAAoB;;QAClB,MAAA,IAAI,CAAC,oBAAoB,0CAAE,UAAU,EAAE,CAAC;IAC1C,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,E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AAC,IAAI,CACzD,WAAK,KAAK,EAAC,iBAAiB;oBAC1B,YAAM,IAAI,EAAC,WAAW,IACnB,gBAAgB,IAAI,CACnB,WAAK,KAAK,EAAC,qBAAqB;wBAC9B,WAAK,KAAK,EAAC,mBAAmB;4BAC5B,qBAAe,OAAO,EAAC,IAAI,IACxB,gBAAgB,CACH,CACZ;wBACN,WAAK,KAAK,EAAC,sBAAsB;4BAC/B,qBAAe,OAAO,EAAC,gBAAgB,IACpC,mBAAmB,CACN,CACZ,CACF,CACP,CACI,CACH,CACP,CACoB,CAClB,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Element,\n Host,\n Prop,\n h,\n State,\n Listen,\n forceUpdate,\n} from \"@stencil/core\";\nimport {\n IcAlignment,\n IcSizesNoLarge,\n IcTheme,\n IcThemeForeground,\n IcThemeForegroundEnum,\n} from \"../../utils/types\";\nimport {\n slotHasContent,\n getThemeForegroundColor,\n onComponentRequiredPropUndefined,\n isPropDefined,\n isSlotUsed,\n checkSlotInChildMutations,\n} from \"../../utils/helpers\";\nimport { IcHeroContentAlignments } from \"./ic-hero.types\";\n\n/**\n * @slot heading - Content will be rendered in the title area, in place of the heading.\n * @slot subheading - Content will be rendered in the title area, in place of the subheading.\n * @slot interaction - Content will be rendered in the interaction area, adjacent to the title area.\n * @slot secondary - Content will be rendered in the secondary content area.\n */\n\n@Component({\n tag: \"ic-hero\",\n styleUrl: \"ic-hero.css\",\n shadow: true,\n})\nexport class Hero {\n private hostMutationObserver: MutationObserver = null;\n\n @Element() el: HTMLIcHeroElement;\n\n @State() foregroundColor: IcThemeForeground = getThemeForegroundColor();\n @State() rightContent: boolean = false;\n // set by above state\n @State() leftContentFullWidth: boolean =\n !this.rightContent && this.secondaryHeading === undefined;\n @State() scrollFactor: string = \"right -100px\";\n\n /**\n * The alignment of the hero.\n */\n @Prop() aligned: IcAlignment = \"left\";\n\n /**\n * The optional background image.\n */\n @Prop() backgroundImage?: string;\n\n /**\n * The alignment of the hero content.\n */\n @Prop() contentAligned: IcHeroContentAlignments = \"left\";\n\n /**\n * If `true`, the background image (if set) will not scroll using a parallax effect.\n */\n @Prop() disableBackgroundParallax?: boolean = false;\n\n /**\n * The heading of the hero.\n */\n @Prop() heading: string;\n\n /**\n * The optional secondary heading, replaced by slotted right content.\n */\n @Prop() secondaryHeading?: string;\n\n /**\n * The optional secondary subheading, replaced by slotted right content.\n */\n @Prop() secondarySubheading?: string;\n\n /**\n * The size of the hero component.\n */\n @Prop() size?: IcSizesNoLarge = \"default\";\n\n /**\n * @deprecated This prop should not be used anymore. Set prop `size` to \"small\" instead.\n */\n @Prop() small?: boolean = false;\n\n /**\n * The description for the hero.\n */\n @Prop() subheading?: string;\n\n disconnectedCallback(): void {\n this.hostMutationObserver?.disconnect();\n }\n\n componentWillLoad(): void {\n this.rightContent = slotHasContent(this.el, \"secondary\");\n }\n\n componentDidLoad(): void {\n !isSlotUsed(this.el, \"heading\") &&\n onComponentRequiredPropUndefined(\n [{ prop: this.heading, propName: \"heading\" }],\n \"Hero\"\n );\n\n this.hostMutationObserver = new MutationObserver(this.hostMutationCallback);\n this.hostMutationObserver.observe(this.el, {\n childList: true,\n });\n }\n\n componentWillRender(): void {\n this.rightContent = slotHasContent(this.el, \"secondary\");\n }\n\n @Listen(\"themeChange\", { target: \"document\" })\n themeChangeHandler(ev: CustomEvent): void {\n const theme: IcTheme = ev.detail;\n this.foregroundColor = theme.mode;\n }\n\n @Listen(\"scroll\", { target: \"document\" })\n doScroll(): void {\n if (this.disableBackgroundParallax) {\n return;\n }\n\n const scrolltotop = document.scrollingElement.scrollTop;\n const factor = 0.4;\n const y = -100 + scrolltotop * factor;\n this.scrollFactor = \"right \" + y + \"px\";\n }\n\n private hostMutationCallback = (mutationList: MutationRecord[]): void => {\n if (\n mutationList.some(({ type, addedNodes, removedNodes }) =>\n type === \"childList\"\n ? checkSlotInChildMutations(addedNodes, removedNodes, \"secondary\")\n : false\n )\n ) {\n forceUpdate(this);\n }\n };\n\n render() {\n const {\n aligned,\n small,\n size,\n heading,\n subheading,\n secondaryHeading,\n secondarySubheading,\n foregroundColor,\n backgroundImage,\n scrollFactor,\n } = this;\n\n let style = {};\n\n if (isPropDefined(backgroundImage)) {\n style = {\n \"background-image\": \"url(\" + backgroundImage + \")\",\n \"background-position\": scrollFactor,\n };\n }\n\n return (\n <Host\n class={{\n [IcThemeForegroundEnum.Dark]:\n foregroundColor === IcThemeForegroundEnum.Dark,\n [\"has-background-image\"]: backgroundImage !== undefined,\n [\"small\"]: small || size === \"small\",\n [\"secondary-heading\"]: !!secondaryHeading,\n }}\n style={style}\n >\n <ic-section-container\n aligned={aligned}\n fullHeight\n class=\"section-container\"\n >\n <div\n class={{\n [\"left-container\"]: true,\n [\"left-container-full-width\"]: this.leftContentFullWidth,\n }}\n >\n <div class=\"heading\">\n <slot name=\"heading\">\n <ic-typography\n variant={small || size === \"small\" ? \"h2\" : \"h1\"}\n class={{\n [\"heading-bottom-spacing\"]: !small && size !== \"small\",\n }}\n >\n {heading}\n </ic-typography>\n </slot>\n </div>\n <div class=\"subheading\">\n <slot name=\"subheading\">\n <ic-typography variant=\"body\">{subheading}</ic-typography>\n </slot>\n </div>\n <div class=\"interaction-container\">\n <slot name=\"interaction\"></slot>\n </div>\n </div>\n {(isPropDefined(secondaryHeading) || this.rightContent) && (\n <div class=\"right-container\">\n <slot name=\"secondary\">\n {secondaryHeading && (\n <div class=\"secondary-container\">\n <div class=\"secondary-heading\">\n <ic-typography variant=\"h4\">\n {secondaryHeading}\n </ic-typography>\n </div>\n <div class=\"secondary-subheading\">\n <ic-typography variant=\"subtitle-small\">\n {secondarySubheading}\n </ic-typography>\n </div>\n </div>\n )}\n </slot>\n </div>\n )}\n </ic-section-container>\n </Host>\n );\n }\n}\n"]}
|
@@ -72,5 +72,20 @@ describe("ic-hero component", () => {
|
|
72
72
|
await page.waitForChanges();
|
73
73
|
expect(page.rootInstance.foregroundColor).toBe("dark");
|
74
74
|
});
|
75
|
+
it("should test rendering secondary slot after initial render", async () => {
|
76
|
+
const page = await newSpecPage({
|
77
|
+
components: [Hero],
|
78
|
+
html: `<ic-hero heading="Test title" subheading="Test text"></ic-hero>`,
|
79
|
+
});
|
80
|
+
const icon = document.createElement("svg");
|
81
|
+
icon.setAttribute("slot", "secondary");
|
82
|
+
page.rootInstance.hostMutationCallback([
|
83
|
+
{
|
84
|
+
type: "childList",
|
85
|
+
addedNodes: [icon],
|
86
|
+
removedNodes: [],
|
87
|
+
},
|
88
|
+
]);
|
89
|
+
});
|
75
90
|
});
|
76
91
|
//# sourceMappingURL=ic-hero.spec.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-hero.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-hero/test/basic/ic-hero.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,IAAI,CAAC;YAClB,IAAI,EAAE,iEAAiE;SACxE,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,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AAI,EAAE,iEAAiE;SACxE,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACzE,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from \"@stencil/core/testing\";\nimport { Hero } from \"../../ic-hero\";\n\ndescribe(\"ic-hero component\", () => {\n it(\"should render\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\"></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders\");\n });\n\n it(\"should render with a secondary heading\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\" secondary-heading=\"Test title\" secondary-subheading=\"Test text\"></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-with-secondary-heading\");\n });\n\n it(\"should render with interaction content\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\"><ic-button slot=\"interaction\">Button</ic-button></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-with-interaction-content\");\n });\n\n it(\"should render with secondary content\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\"><ic-card slot=\"secondary\" heading=\"Test card\"></ic-card></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-with-secondary-content\");\n });\n\n it(\"should render with a background image when given\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\" background-image=\"test.png\"><ic-card slot=\"secondary\" heading=\"Test card\"></ic-card></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-with-background-image\");\n });\n\n it(\"should use parallax on scroll when a background image is given\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\" background-image=\"test.png\"><ic-card slot=\"secondary\" heading=\"Test card\"></ic-card></ic-hero>`,\n });\n\n page.doc.scrollingElement.scrollTop = 50;\n page.doc.dispatchEvent(new CustomEvent(\"scroll\"));\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot(\"renders-with-parallax-on-scroll\");\n });\n\n it(\"should use not parallax on scroll when a background image is given, but parallax disabled\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" disable-background-parallax subheading=\"Test text\" background-image=\"test.png\"><ic-card slot=\"secondary\" heading=\"Test card\"></ic-card></ic-hero>`,\n });\n\n page.doc.scrollingElement.scrollTop = 50;\n page.doc.dispatchEvent(new CustomEvent(\"scroll\"));\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot(\n \"renders-with-parallax-on-scroll-disabled\"\n );\n });\n\n it(\"should render small\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero small heading=\"Test title\" subheading=\"Test text\"></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-small-variant\");\n });\n\n it(\"should correctly set foregroundColor on theme change\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\"></ic-hero>`,\n });\n\n await page.rootInstance.themeChangeHandler({ detail: { mode: \"dark\" } });\n await page.waitForChanges();\n\n expect(page.rootInstance.foregroundColor).toBe(\"dark\");\n });\n});\n"]}
|
1
|
+
{"version":3,"file":"ic-hero.spec.js","sourceRoot":"","sources":["../../../../../src/components/ic-hero/test/basic/ic-hero.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD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newSpecPage } from \"@stencil/core/testing\";\nimport { Hero } from \"../../ic-hero\";\n\ndescribe(\"ic-hero component\", () => {\n it(\"should render\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\"></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders\");\n });\n\n it(\"should render with a secondary heading\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\" secondary-heading=\"Test title\" secondary-subheading=\"Test text\"></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-with-secondary-heading\");\n });\n\n it(\"should render with interaction content\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\"><ic-button slot=\"interaction\">Button</ic-button></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-with-interaction-content\");\n });\n\n it(\"should render with secondary content\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\"><ic-card slot=\"secondary\" heading=\"Test card\"></ic-card></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-with-secondary-content\");\n });\n\n it(\"should render with a background image when given\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\" background-image=\"test.png\"><ic-card slot=\"secondary\" heading=\"Test card\"></ic-card></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-with-background-image\");\n });\n\n it(\"should use parallax on scroll when a background image is given\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\" background-image=\"test.png\"><ic-card slot=\"secondary\" heading=\"Test card\"></ic-card></ic-hero>`,\n });\n\n page.doc.scrollingElement.scrollTop = 50;\n page.doc.dispatchEvent(new CustomEvent(\"scroll\"));\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot(\"renders-with-parallax-on-scroll\");\n });\n\n it(\"should use not parallax on scroll when a background image is given, but parallax disabled\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" disable-background-parallax subheading=\"Test text\" background-image=\"test.png\"><ic-card slot=\"secondary\" heading=\"Test card\"></ic-card></ic-hero>`,\n });\n\n page.doc.scrollingElement.scrollTop = 50;\n page.doc.dispatchEvent(new CustomEvent(\"scroll\"));\n\n await page.waitForChanges();\n\n expect(page.root).toMatchSnapshot(\n \"renders-with-parallax-on-scroll-disabled\"\n );\n });\n\n it(\"should render small\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero small heading=\"Test title\" subheading=\"Test text\"></ic-hero>`,\n });\n\n expect(page.root).toMatchSnapshot(\"renders-small-variant\");\n });\n\n it(\"should correctly set foregroundColor on theme change\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\"></ic-hero>`,\n });\n\n await page.rootInstance.themeChangeHandler({ detail: { mode: \"dark\" } });\n await page.waitForChanges();\n\n expect(page.rootInstance.foregroundColor).toBe(\"dark\");\n });\n\n it(\"should test rendering secondary slot after initial render\", async () => {\n const page = await newSpecPage({\n components: [Hero],\n html: `<ic-hero heading=\"Test title\" subheading=\"Test text\"></ic-hero>`,\n });\n\n const icon = document.createElement(\"svg\");\n icon.setAttribute(\"slot\", \"secondary\");\n\n page.rootInstance.hostMutationCallback([\n {\n type: \"childList\",\n addedNodes: [icon],\n removedNodes: [],\n },\n ]);\n });\n});\n"]}
|
@@ -3,6 +3,9 @@ import { hasValidationStatus, isSlotUsed, onComponentRequiredPropUndefined, remo
|
|
3
3
|
export class RadioGroup {
|
4
4
|
constructor() {
|
5
5
|
this.resizeObserver = null;
|
6
|
+
this.ADDITIONAL_FIELD = "additional-field";
|
7
|
+
this.RADIO_HORIZONTAL = "horizontal";
|
8
|
+
this.RADIO_VERTICAL = "vertical";
|
6
9
|
this.runResizeObserver = () => {
|
7
10
|
this.resizeObserver = new ResizeObserver(() => {
|
8
11
|
this.checkOrientation();
|
@@ -64,14 +67,14 @@ export class RadioGroup {
|
|
64
67
|
}
|
65
68
|
});
|
66
69
|
this.setFirstRadioOptionTabIndex(this.selectedChild > 0 ? -1 : 0);
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
if (this.initialOrientation === this.RADIO_HORIZONTAL &&
|
71
|
+
this.radioOptions !== undefined &&
|
72
|
+
(this.radioOptions.length > 2 ||
|
73
|
+
(this.radioOptions.length === 2 &&
|
74
|
+
(isSlotUsed(this.radioOptions[0], this.ADDITIONAL_FIELD) ||
|
75
|
+
isSlotUsed(this.radioOptions[1], this.ADDITIONAL_FIELD))))) {
|
76
|
+
this.currentOrientation = this.RADIO_VERTICAL;
|
77
|
+
}
|
75
78
|
}
|
76
79
|
};
|
77
80
|
this.checkedValue = "";
|
@@ -92,6 +95,7 @@ export class RadioGroup {
|
|
92
95
|
}
|
93
96
|
orientationChangeHandler() {
|
94
97
|
this.initialOrientation = this.orientation;
|
98
|
+
this.checkOrientation();
|
95
99
|
}
|
96
100
|
disconnectedCallback() {
|
97
101
|
var _a, _b;
|
@@ -141,20 +145,35 @@ export class RadioGroup {
|
|
141
145
|
}
|
142
146
|
}
|
143
147
|
checkOrientation() {
|
144
|
-
|
148
|
+
var _a, _b;
|
149
|
+
if (this.initialOrientation === this.RADIO_HORIZONTAL) {
|
145
150
|
let totalWidth = 0;
|
146
|
-
this.radioOptions
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
totalWidth > this.radioContainer.clientWidth) {
|
153
|
-
this.currentOrientation = "vertical";
|
151
|
+
if (Array.isArray(this.radioOptions) && this.radioOptions.length > 0) {
|
152
|
+
this.radioOptions.forEach(({ clientWidth }, i, arr) => {
|
153
|
+
totalWidth += clientWidth;
|
154
|
+
if (i < arr.length - 1)
|
155
|
+
totalWidth += 40;
|
156
|
+
});
|
154
157
|
}
|
155
|
-
else
|
156
|
-
totalWidth
|
157
|
-
|
158
|
+
else {
|
159
|
+
totalWidth = 0;
|
160
|
+
}
|
161
|
+
if (this.initialOrientation == this.RADIO_HORIZONTAL) {
|
162
|
+
if (this.radioOptions !== undefined &&
|
163
|
+
(this.radioOptions.length > 2 ||
|
164
|
+
(this.radioOptions.length === 2 &&
|
165
|
+
(isSlotUsed(this.radioOptions[0], this.ADDITIONAL_FIELD) ||
|
166
|
+
isSlotUsed(this.radioOptions[1], this.ADDITIONAL_FIELD))))) {
|
167
|
+
this.currentOrientation = this.RADIO_VERTICAL;
|
168
|
+
}
|
169
|
+
else {
|
170
|
+
if (totalWidth >= ((_a = this.radioContainer) === null || _a === void 0 ? void 0 : _a.clientWidth)) {
|
171
|
+
this.currentOrientation = this.RADIO_VERTICAL;
|
172
|
+
}
|
173
|
+
else if (totalWidth < ((_b = this.radioContainer) === null || _b === void 0 ? void 0 : _b.clientWidth)) {
|
174
|
+
this.currentOrientation = this.RADIO_HORIZONTAL;
|
175
|
+
}
|
176
|
+
}
|
158
177
|
}
|
159
178
|
}
|
160
179
|
}
|
@@ -162,7 +181,7 @@ export class RadioGroup {
|
|
162
181
|
renderHiddenInput(true, this.el, this.name, this.checkedValue, this.disabled);
|
163
182
|
return (h(Host, { onKeyDown: this.handleKeyDown, class: { small: this.small || this.size === "small" } }, h("div", { role: "radiogroup", "aria-label": `${this.label}${this.required ? ", required" : ""}` }, !this.hideLabel && (h("ic-input-label", { class: { [`${this.validationStatus}`]: true }, label: this.label, helperText: this.helperText, required: this.required, disabled: this.disabled })), h("div", { class: {
|
164
183
|
"radio-buttons-container": true,
|
165
|
-
horizontal: this.currentOrientation ===
|
184
|
+
horizontal: this.currentOrientation === this.RADIO_HORIZONTAL,
|
166
185
|
}, ref: (el) => (this.radioContainer = el) }, h("slot", null))), hasValidationStatus(this.validationStatus, this.disabled) && (h("ic-input-validation", { ariaLiveMode: "polite", status: this.validationStatus, message: this.validationText }))));
|
167
186
|
}
|
168
187
|
static get is() { return "ic-radio-group"; }
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ic-radio-group.js","sourceRoot":"","sources":["../../../src/components/ic-radio-group/ic-radio-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,CAAC,EACD,IAAI,EACJ,KAAK,EACL,MAAM,EACN,OAAO,EACP,KAAK,EAEL,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,gCAAgC,EAChC,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAc7B,MAAM,OAAO,UAAU;;QAGb,mBAAc,GAAmB,IAAI,CAAC;QAwItC,sBAAiB,GAAG,GAAG,EAAE;YAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CAAC,GAAG,EAAE;gBAC5C,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvC,CAAC,CAAC;QAwBM,kBAAa,GAAG,CAAC,KAAoB,EAAQ,EAAE;YACrD,QAAQ,KAAK,CAAC,GAAG,EAAE,CAAC;gBAClB,KAAK,WAAW,CAAC;gBACjB,KAAK,YAAY;oBACf,IAAI,CAAC,YAAY,CACf,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CACnD,CAAC,KAAK,EAAE,CAAC;oBACV,KAAK,CAAC,cAAc,EAAE,CAAC;oBACvB,MAAM;gBACR,KAAK,SAAS,CAAC;gBACf,KAAK,WAAW;oBACd,IAAI,CAAC,YAAY,CACf,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CACpD,CAAC,KAAK,EAAE,CAAC;oBACV,KA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KAAK,YAAY;qBACrD,EACD,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;oBAEvC,eAAa,CACT,CACF;YACL,mBAAmB,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC5D,2BACE,YAAY,EAAC,QAAQ,EACrB,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAC7B,OAAO,EAAE,IAAI,CAAC,cAAc,GACP,CACxB,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Host,\n h,\n Prop,\n State,\n Listen,\n Element,\n Event,\n EventEmitter,\n Watch,\n} from \"@stencil/core\";\nimport {\n hasValidationStatus,\n isSlotUsed,\n onComponentRequiredPropUndefined,\n removeDisabledFalse,\n renderHiddenInput,\n checkResizeObserver,\n} from \"../../utils/helpers\";\nimport {\n IcInformationStatusOrEmpty,\n IcOrientation,\n IcSizesNoLarge,\n IcValueEventDetail,\n} from \"../../utils/types\";\nimport { IcChangeEventDetail } from \"./ic-radio-group.types\";\n\n@Component({\n tag: \"ic-radio-group\",\n styleUrl: \"ic-radio-group.css\",\n shadow: true,\n})\nexport class RadioGroup {\n private radioContainer: HTMLDivElement;\n private radioOptions: HTMLIcRadioOptionElement[];\n private resizeObserver: ResizeObserver = null;\n\n @Element() el: HTMLIcRadioGroupElement;\n\n @State() checkedValue: string = \"\";\n @State() currentOrientation: IcOrientation;\n @State() initialOrientation: IcOrientation;\n @State() selectedChild: number = -1;\n\n /**\n * If `true`, the disabled state will be set.\n */\n @Prop() disabled: boolean = false;\n\n /**\n * The helper text that will be displayed for additional field guidance.\n */\n @Prop() helperText: string;\n\n /**\n * If `true`, the label will be hidden and the required label value will be applied as an aria-label.\n */\n @Prop() hideLabel: boolean = false;\n\n /**\n * The label for the radio group to be displayed.\n */\n @Prop() label!: string;\n\n /**\n * The name for the radio group to differentiate from other groups.\n */\n @Prop() name!: string;\n\n /**\n * The orientation of the radio buttons in the radio group. If there are more than two radio buttons in a radio group or either of the radio buttons use the `additional-field` slot, then the orientation will always be vertical.\n */\n @Prop() orientation: IcOrientation = \"vertical\";\n\n /**\n * If `true`, the radio group will require a value.\n */\n @Prop() required: boolean = false;\n\n /**\n * The size of the radio group component.\n */\n @Prop() size?: IcSizesNoLarge = \"default\";\n\n /**\n * @deprecated This prop should not be used anymore. Set prop `size` to \"small\" instead.\n */\n @Prop() small?: boolean = false;\n\n /**\n * The validation status - e.g. 'error' | 'warning' | 'success'.\n */\n @Prop() validationStatus: IcInformationStatusOrEmpty = \"\";\n /**\n * The validation text - e.g. 'error' | 'warning' | 'success'.\n */\n @Prop() validationText: string = \"\";\n\n @Watch(\"orientation\")\n orientationChangeHandler(): void {\n this.initialOrientation = this.orientation;\n }\n\n /**\n * Emitted when a user selects a radio.\n */\n @Event() icChange: EventEmitter<IcChangeEventDetail>;\n\n disconnectedCallback(): void {\n this.resizeObserver?.disconnect();\n this.radioContainer?.removeEventListener(\n \"slotchange\",\n this.setRadioOptions\n );\n }\n\n componentWillLoad(): void {\n removeDisabledFalse(this.disabled, this.el);\n\n this.orientationChangeHandler();\n this.currentOrientation = this.initialOrientation;\n }\n\n componentDidLoad(): void {\n this.setRadioOptions();\n checkResizeObserver(this.runResizeObserver);\n this.addSlotChangeListener();\n\n onComponentRequiredPropUndefined(\n [\n { prop: this.label, propName: \"label\" },\n { prop: this.name, propName: \"name\" },\n ],\n \"Radio Group\"\n );\n }\n\n @Listen(\"icCheck\")\n selectHandler({ detail, target }: CustomEvent<IcValueEventDetail>): void {\n this.checkedValue = detail.value;\n const selectedOption = target as HTMLIcRadioOptionElement;\n this.icChange.emit({\n value: this.checkedValue,\n selectedOption: {\n radio: selectedOption,\n textFieldValue: selectedOption?.querySelector(\"ic-text-field\")?.value,\n },\n });\n\n if (this.radioOptions !== undefined) {\n this.radioOptions.forEach((radioOption, index) => {\n radioOption.selected = this.checkedValue === radioOption.value;\n if (radioOption.selected) {\n this.selectedChild = index;\n }\n });\n this.setFirstRadioOptionTabIndex(this.selectedChild > 0 ? -1 : 0);\n }\n }\n\n @Listen(\"icSelectedChange\")\n changeHandler(): void {\n const selectedOption = this.radioOptions.findIndex(\n (radioOption) => radioOption.selected\n );\n if (selectedOption < 0) {\n this.setFirstRadioOptionTabIndex(0);\n this.selectedChild = selectedOption;\n }\n }\n\n private runResizeObserver = () => {\n this.resizeObserver = new ResizeObserver(() => {\n this.checkOrientation();\n });\n\n this.resizeObserver.observe(this.el);\n };\n\n private checkOrientation() {\n if (this.initialOrientation === \"horizontal\") {\n let totalWidth = 0;\n this.radioOptions.forEach(({ clientWidth }, i, arr) => {\n totalWidth += clientWidth;\n if (i < arr.length - 1) totalWidth += 40;\n });\n\n if (\n this.currentOrientation === \"horizontal\" &&\n totalWidth > this.radioContainer.clientWidth\n ) {\n this.currentOrientation = \"vertical\";\n } else if (\n this.currentOrientation === \"vertical\" &&\n totalWidth < this.radioContainer.clientWidth\n ) {\n this.currentOrientation = \"horizontal\";\n }\n }\n }\n\n private handleKeyDown = (event: KeyboardEvent): void => {\n switch (event.key) {\n case \"ArrowDown\":\n case \"ArrowRight\":\n this.radioOptions[\n this.getNextItemToSelect(this.selectedChild, true)\n ].click();\n event.preventDefault();\n break;\n case \"ArrowUp\":\n case \"ArrowLeft\":\n this.radioOptions[\n this.getNextItemToSelect(this.selectedChild, false)\n ].click();\n event.preventDefault();\n }\n };\n\n private getNextItemToSelect = (\n currentItem: number,\n movingDown: boolean\n ): number => {\n const numRadios = this.radioOptions.length - 1;\n\n if (currentItem < 1) {\n currentItem = 0;\n }\n\n let nextItem = movingDown ? currentItem + 1 : currentItem - 1;\n\n //check if wrap around necessary\n if (nextItem < 0) {\n nextItem = numRadios;\n } else if (nextItem > numRadios) {\n nextItem = 0;\n }\n\n //if next item is disabled then find next\n if (this.radioOptions[nextItem].disabled) {\n nextItem = this.getNextItemToSelect(nextItem, movingDown);\n }\n\n return nextItem;\n };\n\n private addSlotChangeListener = () => {\n this.radioContainer.addEventListener(\"slotchange\", this.setRadioOptions);\n };\n\n private setFirstRadioOptionTabIndex = (value: number) => {\n this.radioOptions[0].setTabIndex(value);\n };\n\n private setRadioOptions = () => {\n this.selectedChild = -1;\n this.checkedValue = \"\";\n this.radioOptions = Array.from(this.el.querySelectorAll(\"ic-radio-option\"));\n if (this.radioOptions.length > 0) {\n this.radioOptions.forEach((radioOption, index) => {\n if (!radioOption.selected) {\n radioOption.selected = this.checkedValue === radioOption.value;\n }\n radioOption.name = this.name;\n radioOption.groupLabel = this.label;\n if (radioOption.selected) {\n this.selectedChild = index;\n this.checkedValue = radioOption.value;\n }\n });\n this.setFirstRadioOptionTabIndex(this.selectedChild > 0 ? -1 : 0);\n }\n\n if (\n this.initialOrientation === \"horizontal\" &&\n this.radioOptions !== undefined &&\n (this.radioOptions.length > 2 ||\n (this.radioOptions.length === 2 &&\n (isSlotUsed(this.radioOptions[0], \"additional-field\") ||\n isSlotUsed(this.radioOptions[1], \"additional-field\"))))\n ) {\n this.currentOrientation = \"vertical\";\n }\n };\n\n render() {\n renderHiddenInput(\n true,\n this.el,\n this.name,\n this.checkedValue,\n this.disabled\n );\n\n return (\n <Host\n onKeyDown={this.handleKeyDown}\n class={{ small: this.small || this.size === \"small\" }}\n >\n <div\n role=\"radiogroup\"\n aria-label={`${this.label}${this.required ? \", required\" : \"\"}`}\n >\n {!this.hideLabel && (\n <ic-input-label\n class={{ [`${this.validationStatus}`]: true }}\n label={this.label}\n helperText={this.helperText}\n required={this.required}\n disabled={this.disabled}\n ></ic-input-label>\n )}\n <div\n class={{\n \"radio-buttons-container\": true,\n horizontal: this.currentOrientation === \"horizontal\",\n }}\n ref={(el) => (this.radioContainer = el)}\n >\n <slot></slot>\n </div>\n </div>\n {hasValidationStatus(this.validationStatus, this.disabled) && (\n <ic-input-validation\n ariaLiveMode=\"polite\"\n status={this.validationStatus}\n message={this.validationText}\n ></ic-input-validation>\n )}\n </Host>\n );\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ic-radio-group.js","sourceRoot":"","sources":["../../../src/components/ic-radio-group/ic-radio-group.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,CAAC,EACD,IAAI,EACJ,KAAK,EACL,MAAM,EACN,OAAO,EACP,KAAK,EAEL,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,gCAAgC,EAChC,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAc7B,MAAM,OAAO,UAAU;;QAGb,mBAAc,GAAmB,IAAI,CAAC;QACtC,qBAAgB,GAAG,kBAAkB,CAAC;QACtC,qBAAgB,GAAkB,YAAY,CAAC;QAC/C,mBAAc,GAAkB,UAAU,CAAC;QAyI3C,sBAAiB,GAAG,GAAG,EAAE;YAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CAAC,GAAG,EAAE;gBAC5C,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvC,CAAC,CAAC;QAkCM,kBAAa,GAAG,CAAC,KAAoB,EAAQ,EAAE;YACrD,QAAQ,KAAK,CAAC,GAAG,EAAE,CAAC;gBAClB,KAAK,WAAW,CAAC;gBACjB,KAAK,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AAE,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;oBAEvC,eAAa,CACT,CACF;YACL,mBAAmB,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC5D,2BACE,YAAY,EAAC,QAAQ,EACrB,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAC7B,OAAO,EAAE,IAAI,CAAC,cAAc,GACP,CACxB,CACI,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Host,\n h,\n Prop,\n State,\n Listen,\n Element,\n Event,\n EventEmitter,\n Watch,\n} from \"@stencil/core\";\nimport {\n hasValidationStatus,\n isSlotUsed,\n onComponentRequiredPropUndefined,\n removeDisabledFalse,\n renderHiddenInput,\n checkResizeObserver,\n} from \"../../utils/helpers\";\nimport {\n IcInformationStatusOrEmpty,\n IcOrientation,\n IcSizesNoLarge,\n IcValueEventDetail,\n} from \"../../utils/types\";\nimport { IcChangeEventDetail } from \"./ic-radio-group.types\";\n\n@Component({\n tag: \"ic-radio-group\",\n styleUrl: \"ic-radio-group.css\",\n shadow: true,\n})\nexport class RadioGroup {\n private radioContainer: HTMLDivElement;\n private radioOptions: HTMLIcRadioOptionElement[];\n private resizeObserver: ResizeObserver = null;\n private ADDITIONAL_FIELD = \"additional-field\";\n private RADIO_HORIZONTAL: IcOrientation = \"horizontal\";\n private RADIO_VERTICAL: IcOrientation = \"vertical\";\n\n @Element() el: HTMLIcRadioGroupElement;\n\n @State() checkedValue: string = \"\";\n @State() currentOrientation: IcOrientation;\n @State() initialOrientation: IcOrientation;\n @State() selectedChild: number = -1;\n\n /**\n * If `true`, the disabled state will be set.\n */\n @Prop() disabled: boolean = false;\n\n /**\n * The helper text that will be displayed for additional field guidance.\n */\n @Prop() helperText: string;\n\n /**\n * If `true`, the label will be hidden and the required label value will be applied as an aria-label.\n */\n @Prop() hideLabel: boolean = false;\n\n /**\n * The label for the radio group to be displayed.\n */\n @Prop() label!: string;\n\n /**\n * The name for the radio group to differentiate from other groups.\n */\n @Prop() name!: string;\n\n /**\n * The orientation of the radio buttons in the radio group. If there are more than two radio buttons in a radio group or either of the radio buttons use the `additional-field` slot, then the orientation will always be vertical.\n */\n @Prop() orientation: IcOrientation = \"vertical\";\n\n /**\n * If `true`, the radio group will require a value.\n */\n @Prop() required: boolean = false;\n\n /**\n * The size of the radio group component.\n */\n @Prop() size?: IcSizesNoLarge = \"default\";\n\n /**\n * @deprecated This prop should not be used anymore. Set prop `size` to \"small\" instead.\n */\n @Prop() small?: boolean = false;\n\n /**\n * The validation status - e.g. 'error' | 'warning' | 'success'.\n */\n @Prop() validationStatus: IcInformationStatusOrEmpty = \"\";\n /**\n * The validation text - e.g. 'error' | 'warning' | 'success'.\n */\n @Prop() validationText: string = \"\";\n\n @Watch(\"orientation\")\n orientationChangeHandler(): void {\n this.initialOrientation = this.orientation;\n this.checkOrientation();\n }\n\n /**\n * Emitted when a user selects a radio.\n */\n @Event() icChange: EventEmitter<IcChangeEventDetail>;\n\n disconnectedCallback(): void {\n this.resizeObserver?.disconnect();\n this.radioContainer?.removeEventListener(\n \"slotchange\",\n this.setRadioOptions\n );\n }\n\n componentWillLoad(): void {\n removeDisabledFalse(this.disabled, this.el);\n\n this.orientationChangeHandler();\n this.currentOrientation = this.initialOrientation;\n }\n\n componentDidLoad(): void {\n this.setRadioOptions();\n checkResizeObserver(this.runResizeObserver);\n this.addSlotChangeListener();\n\n onComponentRequiredPropUndefined(\n [\n { prop: this.label, propName: \"label\" },\n { prop: this.name, propName: \"name\" },\n ],\n \"Radio Group\"\n );\n }\n\n @Listen(\"icCheck\")\n selectHandler({ detail, target }: CustomEvent<IcValueEventDetail>): void {\n this.checkedValue = detail.value;\n const selectedOption = target as HTMLIcRadioOptionElement;\n this.icChange.emit({\n value: this.checkedValue,\n selectedOption: {\n radio: selectedOption,\n textFieldValue: selectedOption?.querySelector(\"ic-text-field\")?.value,\n },\n });\n\n if (this.radioOptions !== undefined) {\n this.radioOptions.forEach((radioOption, index) => {\n radioOption.selected = this.checkedValue === radioOption.value;\n if (radioOption.selected) {\n this.selectedChild = index;\n }\n });\n this.setFirstRadioOptionTabIndex(this.selectedChild > 0 ? -1 : 0);\n }\n }\n\n @Listen(\"icSelectedChange\")\n changeHandler(): void {\n const selectedOption = this.radioOptions.findIndex(\n (radioOption) => radioOption.selected\n );\n if (selectedOption < 0) {\n this.setFirstRadioOptionTabIndex(0);\n this.selectedChild = selectedOption;\n }\n }\n\n private runResizeObserver = () => {\n this.resizeObserver = new ResizeObserver(() => {\n this.checkOrientation();\n });\n\n this.resizeObserver.observe(this.el);\n };\n\n private checkOrientation() {\n if (this.initialOrientation === this.RADIO_HORIZONTAL) {\n let totalWidth = 0;\n if (Array.isArray(this.radioOptions) && this.radioOptions.length > 0) {\n this.radioOptions.forEach(({ clientWidth }, i, arr) => {\n totalWidth += clientWidth;\n if (i < arr.length - 1) totalWidth += 40;\n });\n } else {\n totalWidth = 0;\n }\n\n if (this.initialOrientation == this.RADIO_HORIZONTAL) {\n if (\n this.radioOptions !== undefined &&\n (this.radioOptions.length > 2 ||\n (this.radioOptions.length === 2 &&\n (isSlotUsed(this.radioOptions[0], this.ADDITIONAL_FIELD) ||\n isSlotUsed(this.radioOptions[1], this.ADDITIONAL_FIELD))))\n ) {\n this.currentOrientation = this.RADIO_VERTICAL;\n } else {\n if (totalWidth >= this.radioContainer?.clientWidth) {\n this.currentOrientation = this.RADIO_VERTICAL;\n } else if (totalWidth < this.radioContainer?.clientWidth) {\n this.currentOrientation = this.RADIO_HORIZONTAL;\n }\n }\n }\n }\n }\n\n private handleKeyDown = (event: KeyboardEvent): void => {\n switch (event.key) {\n case \"ArrowDown\":\n case \"ArrowRight\":\n this.radioOptions[\n this.getNextItemToSelect(this.selectedChild, true)\n ].click();\n event.preventDefault();\n break;\n case \"ArrowUp\":\n case \"ArrowLeft\":\n this.radioOptions[\n this.getNextItemToSelect(this.selectedChild, false)\n ].click();\n event.preventDefault();\n }\n };\n\n private getNextItemToSelect = (\n currentItem: number,\n movingDown: boolean\n ): number => {\n const numRadios = this.radioOptions.length - 1;\n\n if (currentItem < 1) {\n currentItem = 0;\n }\n\n let nextItem = movingDown ? currentItem + 1 : currentItem - 1;\n\n //check if wrap around necessary\n if (nextItem < 0) {\n nextItem = numRadios;\n } else if (nextItem > numRadios) {\n nextItem = 0;\n }\n\n //if next item is disabled then find next\n if (this.radioOptions[nextItem].disabled) {\n nextItem = this.getNextItemToSelect(nextItem, movingDown);\n }\n\n return nextItem;\n };\n\n private addSlotChangeListener = () => {\n this.radioContainer.addEventListener(\"slotchange\", this.setRadioOptions);\n };\n\n private setFirstRadioOptionTabIndex = (value: number) => {\n this.radioOptions[0].setTabIndex(value);\n };\n\n private setRadioOptions = () => {\n this.selectedChild = -1;\n this.checkedValue = \"\";\n this.radioOptions = Array.from(this.el.querySelectorAll(\"ic-radio-option\"));\n if (this.radioOptions.length > 0) {\n this.radioOptions.forEach((radioOption, index) => {\n if (!radioOption.selected) {\n radioOption.selected = this.checkedValue === radioOption.value;\n }\n radioOption.name = this.name;\n radioOption.groupLabel = this.label;\n if (radioOption.selected) {\n this.selectedChild = index;\n this.checkedValue = radioOption.value;\n }\n });\n this.setFirstRadioOptionTabIndex(this.selectedChild > 0 ? -1 : 0);\n\n if (\n this.initialOrientation === this.RADIO_HORIZONTAL &&\n this.radioOptions !== undefined &&\n (this.radioOptions.length > 2 ||\n (this.radioOptions.length === 2 &&\n (isSlotUsed(this.radioOptions[0], this.ADDITIONAL_FIELD) ||\n isSlotUsed(this.radioOptions[1], this.ADDITIONAL_FIELD))))\n ) {\n this.currentOrientation = this.RADIO_VERTICAL;\n }\n }\n };\n\n render() {\n renderHiddenInput(\n true,\n this.el,\n this.name,\n this.checkedValue,\n this.disabled\n );\n\n return (\n <Host\n onKeyDown={this.handleKeyDown}\n class={{ small: this.small || this.size === \"small\" }}\n >\n <div\n role=\"radiogroup\"\n aria-label={`${this.label}${this.required ? \", required\" : \"\"}`}\n >\n {!this.hideLabel && (\n <ic-input-label\n class={{ [`${this.validationStatus}`]: true }}\n label={this.label}\n helperText={this.helperText}\n required={this.required}\n disabled={this.disabled}\n ></ic-input-label>\n )}\n <div\n class={{\n \"radio-buttons-container\": true,\n horizontal: this.currentOrientation === this.RADIO_HORIZONTAL,\n }}\n ref={(el) => (this.radioContainer = el)}\n >\n <slot></slot>\n </div>\n </div>\n {hasValidationStatus(this.validationStatus, this.disabled) && (\n <ic-input-validation\n ariaLiveMode=\"polite\"\n status={this.validationStatus}\n message={this.validationText}\n ></ic-input-validation>\n )}\n </Host>\n );\n }\n}\n"]}
|