@ukic/web-components 2.1.0-beta.0 → 2.1.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/core.cjs.js +2 -2
- package/dist/cjs/core.cjs.js.map +1 -1
- package/dist/cjs/{helpers-d0eeccf0.js → helpers-8bc3b6d2.js} +83 -38
- package/dist/cjs/helpers-8bc3b6d2.js.map +1 -0
- package/dist/cjs/ic-alert.cjs.entry.js +2 -2
- package/dist/cjs/ic-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-back-to-top.cjs.entry.js +2 -2
- package/dist/cjs/ic-back-to-top.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-breadcrumb-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-breadcrumb.cjs.entry.js +2 -2
- package/dist/cjs/ic-breadcrumb.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-button_3.cjs.entry.js +56 -17
- package/dist/cjs/ic-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-card.cjs.entry.js +16 -3
- 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 +5 -4
- package/dist/cjs/ic-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-classification-banner.cjs.entry.js +1 -1
- package/dist/cjs/ic-classification-banner.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-data-entity.cjs.entry.js +1 -1
- package/dist/cjs/ic-data-entity.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-data-row.cjs.entry.js +2 -2
- package/dist/cjs/ic-data-row.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-divider.cjs.entry.js +1 -1
- package/dist/cjs/ic-footer-link-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-footer-link.cjs.entry.js +2 -2
- package/dist/cjs/ic-footer-link.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-footer.cjs.entry.js +2 -2
- package/dist/cjs/ic-footer.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-hero.cjs.entry.js +1 -1
- package/dist/cjs/ic-input-component-container_3.cjs.entry.js +3 -3
- package/dist/cjs/ic-input-component-container_3.cjs.entry.js.map +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-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-radio-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-radio-option.cjs.entry.js +2 -2
- package/dist/cjs/ic-radio-option.cjs.entry.js.map +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 +2 -2
- package/dist/cjs/ic-side-navigation.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/ic-skeleton.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-status-tag.cjs.entry.js +2 -2
- package/dist/cjs/ic-status-tag.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-step.cjs.entry.js +1 -9
- package/dist/cjs/ic-step.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-stepper.cjs.entry.js +1 -1
- package/dist/cjs/ic-switch.cjs.entry.js +2 -2
- package/dist/cjs/ic-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-tab-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-tab-panel.cjs.entry.js +0 -4
- package/dist/cjs/ic-tab-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-tab.cjs.entry.js +1 -5
- package/dist/cjs/ic-tab.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-text-field.cjs.entry.js +2 -2
- package/dist/cjs/ic-text-field.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-theme.cjs.entry.js +19 -11
- package/dist/cjs/ic-theme.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-top-navigation.cjs.entry.js +2 -2
- package/dist/cjs/ic-top-navigation.cjs.entry.js.map +1 -1
- package/dist/cjs/index-3ef30d9d.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/types-3eb02246.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/ic-alert/ic-alert.css +10 -4
- package/dist/collection/components/ic-back-to-top/ic-back-to-top.css +6 -0
- package/dist/collection/components/ic-breadcrumb/ic-breadcrumb.css +6 -0
- package/dist/collection/components/ic-button/ic-button.css +11 -0
- package/dist/collection/components/ic-card/ic-card.css +5 -0
- package/dist/collection/components/ic-card/ic-card.js +23 -2
- package/dist/collection/components/ic-card/ic-card.js.map +1 -1
- package/dist/collection/components/ic-checkbox/ic-checkbox.css +38 -1
- package/dist/collection/components/ic-checkbox/ic-checkbox.js +4 -3
- package/dist/collection/components/ic-checkbox/ic-checkbox.js.map +1 -1
- package/dist/collection/components/ic-classification-banner/ic-classification-banner.css +6 -0
- package/dist/collection/components/ic-data-entity/ic-data-entity.css +6 -0
- package/dist/collection/components/ic-data-row/ic-data-row.css +7 -1
- package/dist/collection/components/ic-footer/ic-footer.css +6 -0
- package/dist/collection/components/ic-footer-link/ic-footer-link.css +7 -0
- package/dist/collection/components/ic-input-component-container/ic-input-component-container.css +18 -4
- package/dist/collection/components/ic-loading-indicator/ic-loading-indicator.css +56 -101
- package/dist/collection/components/ic-loading-indicator/ic-loading-indicator.js +53 -12
- package/dist/collection/components/ic-loading-indicator/ic-loading-indicator.js.map +1 -1
- package/dist/collection/components/ic-loading-indicator/ic-loading-indicator.types.js.map +1 -1
- package/dist/collection/components/ic-menu/ic-menu.css +8 -1
- package/dist/collection/components/ic-radio-option/ic-radio-option.css +29 -10
- package/dist/collection/components/ic-side-navigation/ic-side-navigation.css +11 -0
- package/dist/collection/components/ic-skeleton/ic-skeleton.css +8 -0
- package/dist/collection/components/ic-status-tag/ic-status-tag.css +8 -0
- package/dist/collection/components/ic-step/ic-step.css +36 -1
- package/dist/collection/components/ic-step/ic-step.js +4 -11
- package/dist/collection/components/ic-step/ic-step.js.map +1 -1
- package/dist/collection/components/ic-switch/ic-switch.css +30 -0
- package/dist/collection/components/ic-tab/ic-tab.css +11 -1
- package/dist/collection/components/ic-tab/ic-tab.js +2 -6
- package/dist/collection/components/ic-tab/ic-tab.js.map +1 -1
- package/dist/collection/components/ic-tab-panel/ic-tab-panel.js +2 -6
- package/dist/collection/components/ic-tab-panel/ic-tab-panel.js.map +1 -1
- package/dist/collection/components/ic-text-field/ic-text-field.css +11 -0
- package/dist/collection/components/ic-theme/ic-theme.js +21 -11
- package/dist/collection/components/ic-theme/ic-theme.js.map +1 -1
- package/dist/collection/components/ic-tooltip/ic-tooltip.css +6 -0
- package/dist/collection/components/ic-tooltip/ic-tooltip.js +3 -1
- package/dist/collection/components/ic-tooltip/ic-tooltip.js.map +1 -1
- package/dist/collection/components/ic-top-navigation/ic-top-navigation.css +91 -78
- package/dist/collection/utils/constants.js +9 -0
- package/dist/collection/utils/constants.js.map +1 -1
- package/dist/collection/utils/helpers.js +68 -35
- package/dist/collection/utils/helpers.js.map +1 -1
- package/dist/collection/utils/types.js.map +1 -1
- package/dist/components/helpers.js +78 -36
- package/dist/components/helpers.js.map +1 -1
- package/dist/components/ic-alert.js +1 -1
- package/dist/components/ic-alert.js.map +1 -1
- package/dist/components/ic-back-to-top.js +1 -1
- package/dist/components/ic-back-to-top.js.map +1 -1
- package/dist/components/ic-breadcrumb2.js +1 -1
- package/dist/components/ic-breadcrumb2.js.map +1 -1
- package/dist/components/ic-button2.js +2 -2
- package/dist/components/ic-button2.js.map +1 -1
- package/dist/components/ic-card.js +19 -4
- package/dist/components/ic-card.js.map +1 -1
- package/dist/components/ic-checkbox-group.js +1 -1
- package/dist/components/ic-checkbox.js +5 -4
- package/dist/components/ic-checkbox.js.map +1 -1
- package/dist/components/ic-classification-banner.js +1 -1
- package/dist/components/ic-classification-banner.js.map +1 -1
- package/dist/components/ic-data-entity.js +1 -1
- package/dist/components/ic-data-entity.js.map +1 -1
- package/dist/components/ic-data-row.js +1 -1
- package/dist/components/ic-data-row.js.map +1 -1
- package/dist/components/ic-divider2.js +1 -1
- package/dist/components/ic-footer-link-group.js +1 -1
- package/dist/components/ic-footer-link.js +2 -2
- package/dist/components/ic-footer-link.js.map +1 -1
- package/dist/components/ic-footer.js +2 -2
- package/dist/components/ic-footer.js.map +1 -1
- package/dist/components/ic-hero.js +1 -1
- package/dist/components/ic-input-component-container2.js +1 -1
- package/dist/components/ic-input-component-container2.js.map +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 +53 -14
- package/dist/components/ic-loading-indicator2.js.map +1 -1
- package/dist/components/ic-menu2.js +1 -1
- package/dist/components/ic-menu2.js.map +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-radio-group.js +1 -1
- package/dist/components/ic-radio-option.js +2 -2
- package/dist/components/ic-radio-option.js.map +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 +2 -2
- package/dist/components/ic-side-navigation.js.map +1 -1
- package/dist/components/ic-skeleton.js +1 -1
- package/dist/components/ic-skeleton.js.map +1 -1
- package/dist/components/ic-status-tag.js +1 -1
- package/dist/components/ic-status-tag.js.map +1 -1
- package/dist/components/ic-step.js +1 -8
- package/dist/components/ic-step.js.map +1 -1
- package/dist/components/ic-switch.js +2 -2
- package/dist/components/ic-switch.js.map +1 -1
- package/dist/components/ic-tab-group.js +1 -1
- package/dist/components/ic-tab-panel.js +0 -4
- package/dist/components/ic-tab-panel.js.map +1 -1
- package/dist/components/ic-tab.js +1 -5
- package/dist/components/ic-tab.js.map +1 -1
- package/dist/components/ic-text-field2.js +2 -2
- package/dist/components/ic-text-field2.js.map +1 -1
- package/dist/components/ic-theme.js +19 -11
- package/dist/components/ic-theme.js.map +1 -1
- package/dist/components/ic-tooltip2.js +4 -2
- package/dist/components/ic-tooltip2.js.map +1 -1
- package/dist/components/ic-top-navigation.js +2 -2
- package/dist/components/ic-top-navigation.js.map +1 -1
- package/dist/components/types.js.map +1 -1
- package/dist/core/core.css +11 -11
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/{p-9c1f2861.entry.js → p-0118400b.entry.js} +2 -2
- package/dist/core/p-0118400b.entry.js.map +1 -0
- package/dist/core/{p-0992a2ee.entry.js → p-02799e26.entry.js} +2 -2
- package/dist/core/p-02799e26.entry.js.map +1 -0
- package/dist/core/{p-972f4e69.entry.js → p-07cd789d.entry.js} +2 -2
- package/dist/core/{p-972f4e69.entry.js.map → p-07cd789d.entry.js.map} +1 -1
- package/dist/core/{p-48029498.entry.js → p-0b125f26.entry.js} +2 -2
- package/dist/core/{p-48029498.entry.js.map → p-0b125f26.entry.js.map} +0 -0
- package/dist/core/{p-3c6defd7.entry.js → p-10da19d2.entry.js} +2 -2
- package/dist/core/{p-3c6defd7.entry.js.map → p-10da19d2.entry.js.map} +0 -0
- package/dist/core/{p-6009c5bc.entry.js → p-1337db5e.entry.js} +2 -2
- package/dist/core/p-1337db5e.entry.js.map +1 -0
- package/dist/core/p-1721bcf3.entry.js +2 -0
- package/dist/core/p-1721bcf3.entry.js.map +1 -0
- package/dist/core/p-23831891.js +2 -0
- package/dist/core/p-23831891.js.map +1 -0
- package/dist/core/p-272c7abd.entry.js +2 -0
- package/dist/core/p-272c7abd.entry.js.map +1 -0
- package/dist/core/{p-ee3a9fd0.entry.js → p-2f114521.entry.js} +2 -2
- package/dist/core/{p-ee3a9fd0.entry.js.map → p-2f114521.entry.js.map} +0 -0
- package/dist/core/{p-54b77947.entry.js → p-31a8595f.entry.js} +2 -2
- package/dist/core/{p-54b77947.entry.js.map → p-31a8595f.entry.js.map} +0 -0
- package/dist/core/p-33a45ace.entry.js +2 -0
- package/dist/core/{p-c96adfd7.entry.js.map → p-33a45ace.entry.js.map} +1 -1
- package/dist/core/{p-a9237c61.entry.js → p-347ec49e.entry.js} +2 -2
- package/dist/core/{p-a9237c61.entry.js.map → p-347ec49e.entry.js.map} +0 -0
- package/dist/core/p-39ae284e.entry.js +2 -0
- package/dist/core/p-39ae284e.entry.js.map +1 -0
- package/dist/core/{p-bf4ddf33.entry.js → p-558552f8.entry.js} +2 -2
- package/dist/core/p-558552f8.entry.js.map +1 -0
- package/dist/core/{p-af6a41bd.entry.js → p-5e261268.entry.js} +2 -2
- package/dist/core/{p-af6a41bd.entry.js.map → p-5e261268.entry.js.map} +0 -0
- package/dist/core/p-60ffb73e.entry.js +2 -0
- package/dist/core/p-60ffb73e.entry.js.map +1 -0
- package/dist/core/p-69650186.entry.js +2 -0
- package/dist/core/p-69650186.entry.js.map +1 -0
- package/dist/core/{p-12e113bf.entry.js → p-6b34d98f.entry.js} +2 -2
- package/dist/core/{p-12e113bf.entry.js.map → p-6b34d98f.entry.js.map} +0 -0
- package/dist/core/p-6f57b13c.js.map +1 -1
- package/dist/core/{p-a183353c.entry.js → p-6f6bd657.entry.js} +2 -2
- package/dist/core/{p-a183353c.entry.js.map → p-6f6bd657.entry.js.map} +0 -0
- package/dist/core/p-7093d214.entry.js +2 -0
- package/dist/core/p-7093d214.entry.js.map +1 -0
- package/dist/core/p-7b11e1dc.entry.js +2 -0
- package/dist/core/{p-db6566c0.entry.js.map → p-7b11e1dc.entry.js.map} +1 -1
- package/dist/core/p-7b39977f.entry.js +2 -0
- package/dist/core/p-7b39977f.entry.js.map +1 -0
- package/dist/core/p-7f632414.entry.js +2 -0
- package/dist/core/p-7f632414.entry.js.map +1 -0
- package/dist/core/{p-59041cfc.entry.js → p-898607d0.entry.js} +2 -2
- package/dist/core/{p-59041cfc.entry.js.map → p-898607d0.entry.js.map} +0 -0
- package/dist/core/{p-c023c49c.entry.js → p-8ddeb574.entry.js} +2 -2
- package/dist/core/p-8ddeb574.entry.js.map +1 -0
- package/dist/core/{p-037273aa.entry.js → p-9cd04875.entry.js} +2 -2
- package/dist/core/{p-037273aa.entry.js.map → p-9cd04875.entry.js.map} +0 -0
- package/dist/core/{p-17d0d631.entry.js → p-ac43322e.entry.js} +2 -2
- package/dist/core/p-ac43322e.entry.js.map +1 -0
- package/dist/core/{p-2177dae2.entry.js → p-ae81dffa.entry.js} +2 -2
- package/dist/core/{p-2177dae2.entry.js.map → p-ae81dffa.entry.js.map} +1 -1
- package/dist/core/{p-1b619302.entry.js → p-b3dec76d.entry.js} +2 -2
- package/dist/core/{p-1b619302.entry.js.map → p-b3dec76d.entry.js.map} +0 -0
- package/dist/core/p-b5a988c0.entry.js +2 -0
- package/dist/core/p-b5a988c0.entry.js.map +1 -0
- package/dist/core/{p-0d63bfe4.entry.js → p-c4d3c18c.entry.js} +2 -2
- package/dist/core/{p-0d63bfe4.entry.js.map → p-c4d3c18c.entry.js.map} +0 -0
- package/dist/core/{p-9a3d6bca.entry.js → p-c6dd4f47.entry.js} +2 -2
- package/dist/core/p-c6dd4f47.entry.js.map +1 -0
- package/dist/core/p-cadb531f.entry.js +2 -0
- package/dist/core/p-cadb531f.entry.js.map +1 -0
- package/dist/core/p-cc83692e.entry.js +2 -0
- package/dist/core/{p-d38168f0.entry.js.map → p-cc83692e.entry.js.map} +1 -1
- package/dist/core/{p-9db8edb7.entry.js → p-dd3c3e3c.entry.js} +2 -2
- package/dist/core/{p-9db8edb7.entry.js.map → p-dd3c3e3c.entry.js.map} +0 -0
- package/dist/core/p-df5caf13.entry.js +2 -0
- package/dist/core/p-df5caf13.entry.js.map +1 -0
- package/dist/core/p-e106305b.entry.js +2 -0
- package/dist/core/{p-8054c2c0.entry.js.map → p-e106305b.entry.js.map} +1 -1
- package/dist/core/p-e590f1d2.entry.js +2 -0
- package/dist/core/p-e590f1d2.entry.js.map +1 -0
- package/dist/core/{p-eb33ece2.entry.js → p-e93e9aa3.entry.js} +2 -2
- package/dist/core/p-e93e9aa3.entry.js.map +1 -0
- package/dist/core/{p-378a7270.entry.js → p-ecfb2e6b.entry.js} +2 -2
- package/dist/core/{p-378a7270.entry.js.map → p-ecfb2e6b.entry.js.map} +0 -0
- package/dist/core/p-f9370be6.js.map +1 -1
- package/dist/esm/core.js +2 -2
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/{helpers-e090fe7e.js → helpers-3d41833c.js} +79 -37
- package/dist/esm/helpers-3d41833c.js.map +1 -0
- package/dist/esm/ic-alert.entry.js +2 -2
- package/dist/esm/ic-alert.entry.js.map +1 -1
- package/dist/esm/ic-back-to-top.entry.js +2 -2
- package/dist/esm/ic-back-to-top.entry.js.map +1 -1
- package/dist/esm/ic-breadcrumb-group.entry.js +1 -1
- package/dist/esm/ic-breadcrumb.entry.js +2 -2
- package/dist/esm/ic-breadcrumb.entry.js.map +1 -1
- package/dist/esm/ic-button_3.entry.js +56 -17
- package/dist/esm/ic-button_3.entry.js.map +1 -1
- package/dist/esm/ic-card.entry.js +16 -3
- 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 +5 -4
- package/dist/esm/ic-checkbox.entry.js.map +1 -1
- package/dist/esm/ic-classification-banner.entry.js +1 -1
- package/dist/esm/ic-classification-banner.entry.js.map +1 -1
- package/dist/esm/ic-data-entity.entry.js +1 -1
- package/dist/esm/ic-data-entity.entry.js.map +1 -1
- package/dist/esm/ic-data-row.entry.js +2 -2
- package/dist/esm/ic-data-row.entry.js.map +1 -1
- package/dist/esm/ic-divider.entry.js +1 -1
- package/dist/esm/ic-footer-link-group.entry.js +1 -1
- package/dist/esm/ic-footer-link.entry.js +2 -2
- package/dist/esm/ic-footer-link.entry.js.map +1 -1
- package/dist/esm/ic-footer.entry.js +2 -2
- package/dist/esm/ic-footer.entry.js.map +1 -1
- package/dist/esm/ic-hero.entry.js +1 -1
- package/dist/esm/ic-input-component-container_3.entry.js +3 -3
- package/dist/esm/ic-input-component-container_3.entry.js.map +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-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-radio-group.entry.js +1 -1
- package/dist/esm/ic-radio-option.entry.js +2 -2
- package/dist/esm/ic-radio-option.entry.js.map +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 +2 -2
- package/dist/esm/ic-side-navigation.entry.js.map +1 -1
- package/dist/esm/ic-skeleton.entry.js +1 -1
- package/dist/esm/ic-skeleton.entry.js.map +1 -1
- package/dist/esm/ic-status-tag.entry.js +2 -2
- package/dist/esm/ic-status-tag.entry.js.map +1 -1
- package/dist/esm/ic-step.entry.js +1 -9
- package/dist/esm/ic-step.entry.js.map +1 -1
- package/dist/esm/ic-stepper.entry.js +1 -1
- package/dist/esm/ic-switch.entry.js +2 -2
- package/dist/esm/ic-switch.entry.js.map +1 -1
- package/dist/esm/ic-tab-group.entry.js +1 -1
- package/dist/esm/ic-tab-panel.entry.js +0 -4
- package/dist/esm/ic-tab-panel.entry.js.map +1 -1
- package/dist/esm/ic-tab.entry.js +1 -5
- package/dist/esm/ic-tab.entry.js.map +1 -1
- package/dist/esm/ic-text-field.entry.js +2 -2
- package/dist/esm/ic-text-field.entry.js.map +1 -1
- package/dist/esm/ic-theme.entry.js +19 -11
- package/dist/esm/ic-theme.entry.js.map +1 -1
- package/dist/esm/ic-top-navigation.entry.js +2 -2
- package/dist/esm/ic-top-navigation.entry.js.map +1 -1
- package/dist/esm/index-1500de1f.js.map +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/types-dd515332.js.map +1 -1
- package/dist/types/components/ic-card/ic-card.d.ts +4 -0
- package/dist/types/components/ic-checkbox/ic-checkbox.d.ts +1 -1
- package/dist/types/components/ic-loading-indicator/ic-loading-indicator.d.ts +8 -1
- package/dist/types/components/ic-loading-indicator/ic-loading-indicator.types.d.ts +5 -0
- package/dist/types/components/ic-step/ic-step.d.ts +2 -3
- package/dist/types/components/ic-tab/ic-tab.d.ts +1 -2
- package/dist/types/components/ic-tab-panel/ic-tab-panel.d.ts +1 -2
- package/dist/types/components/ic-theme/ic-theme.d.ts +2 -1
- package/dist/types/components.d.ts +6 -6
- package/dist/types/utils/constants.d.ts +2 -0
- package/dist/types/utils/helpers.d.ts +15 -3
- package/dist/types/utils/types.d.ts +3 -0
- package/hydrate/index.d.ts +1 -1
- package/hydrate/index.js +200 -106
- package/package.json +8 -5
- package/dist/cjs/helpers-d0eeccf0.js.map +0 -1
- package/dist/core/p-0992a2ee.entry.js.map +0 -1
- package/dist/core/p-155114db.entry.js +0 -2
- package/dist/core/p-155114db.entry.js.map +0 -1
- package/dist/core/p-17d0d631.entry.js.map +0 -1
- package/dist/core/p-40d3fd89.entry.js +0 -2
- package/dist/core/p-40d3fd89.entry.js.map +0 -1
- package/dist/core/p-50a0f1a0.entry.js +0 -2
- package/dist/core/p-50a0f1a0.entry.js.map +0 -1
- package/dist/core/p-5977c1e0.entry.js +0 -2
- package/dist/core/p-5977c1e0.entry.js.map +0 -1
- package/dist/core/p-6009c5bc.entry.js.map +0 -1
- package/dist/core/p-8054c2c0.entry.js +0 -2
- package/dist/core/p-89d46b9b.entry.js +0 -2
- package/dist/core/p-89d46b9b.entry.js.map +0 -1
- package/dist/core/p-9a3d6bca.entry.js.map +0 -1
- package/dist/core/p-9c1f2861.entry.js.map +0 -1
- package/dist/core/p-9e1f450f.entry.js +0 -2
- package/dist/core/p-9e1f450f.entry.js.map +0 -1
- package/dist/core/p-a6715f61.entry.js +0 -2
- package/dist/core/p-a6715f61.entry.js.map +0 -1
- package/dist/core/p-aad5da60.entry.js +0 -2
- package/dist/core/p-aad5da60.entry.js.map +0 -1
- package/dist/core/p-bf4ddf33.entry.js.map +0 -1
- package/dist/core/p-bfa9392f.entry.js +0 -2
- package/dist/core/p-bfa9392f.entry.js.map +0 -1
- package/dist/core/p-c023c49c.entry.js.map +0 -1
- package/dist/core/p-c96adfd7.entry.js +0 -2
- package/dist/core/p-d38168f0.entry.js +0 -2
- package/dist/core/p-d61c2983.entry.js +0 -2
- package/dist/core/p-d61c2983.entry.js.map +0 -1
- package/dist/core/p-db6566c0.entry.js +0 -2
- package/dist/core/p-eb33ece2.entry.js.map +0 -1
- package/dist/core/p-ef59f111.entry.js +0 -2
- package/dist/core/p-ef59f111.entry.js.map +0 -1
- package/dist/core/p-f228c232.js +0 -2
- package/dist/core/p-f228c232.js.map +0 -1
- package/dist/core/p-fce4b26b.entry.js +0 -2
- package/dist/core/p-fce4b26b.entry.js.map +0 -1
- package/dist/esm/helpers-e090fe7e.js.map +0 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
import { IcThemeForegroundEnum, } from "../utils/types";
|
2
2
|
import { IC_BLOCK_COLOR_COMPONENTS, IC_BLOCK_COLOR_EXCEPTIONS, IC_FIXED_COLOR_COMPONENTS, } from "./constants";
|
3
|
-
const DARK_MODE_THRESHOLD =
|
3
|
+
const DARK_MODE_THRESHOLD = 133.3505;
|
4
4
|
/**
|
5
5
|
* Used to inherit global attributes set on the host. Called in componentWillLoad and assigned
|
6
6
|
* to a variable that is later used in the render function.
|
@@ -49,21 +49,29 @@ export const debounce = (func, wait = 0) => {
|
|
49
49
|
* @param disabled If true, the input is disabled
|
50
50
|
*/
|
51
51
|
export const renderHiddenInput = (always, container, name, value, disabled) => {
|
52
|
-
if (
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
input
|
58
|
-
|
52
|
+
if (name !== undefined) {
|
53
|
+
if (always || hasShadowDom(container)) {
|
54
|
+
const inputs = container.querySelectorAll("input.ic-input");
|
55
|
+
const inputEls = Array.from(inputs);
|
56
|
+
const filtered = inputEls.filter((el) => container === el.parentElement);
|
57
|
+
let input = filtered[0];
|
58
|
+
if (input === null || input === undefined) {
|
59
|
+
input = container.ownerDocument.createElement("input");
|
60
|
+
input.type = "hidden";
|
61
|
+
input.classList.add("ic-input");
|
62
|
+
container.appendChild(input);
|
63
|
+
}
|
64
|
+
input.disabled = disabled;
|
65
|
+
input.name = name;
|
66
|
+
input.value = value || "";
|
59
67
|
}
|
60
|
-
input.disabled = disabled;
|
61
|
-
input.name = name;
|
62
|
-
input.value = value || "";
|
63
68
|
}
|
64
69
|
};
|
65
70
|
export const removeHiddenInput = (container) => {
|
66
|
-
const
|
71
|
+
const inputs = container.querySelectorAll("input.ic-input");
|
72
|
+
const inputEls = Array.from(inputs);
|
73
|
+
const filtered = inputEls.filter((el) => container === el.parentElement);
|
74
|
+
const input = filtered[0];
|
67
75
|
input === null || input === void 0 ? void 0 : input.remove();
|
68
76
|
};
|
69
77
|
export const hasShadowDom = (el) => {
|
@@ -92,7 +100,8 @@ export const getInputDescribedByText = (inputId, helperText, validationText) =>
|
|
92
100
|
*/
|
93
101
|
export const getThemeFromContext = (el, themeFromEvent = null) => {
|
94
102
|
var _a;
|
95
|
-
const
|
103
|
+
const parentElement = el.parentElement || el.getRootNode().host.parentElement;
|
104
|
+
const blockColorParent = parentElement.closest(IC_BLOCK_COLOR_COMPONENTS.join(","));
|
96
105
|
// If within a block color component
|
97
106
|
if (blockColorParent !== null) {
|
98
107
|
const parentTag = blockColorParent.tagName.toLowerCase();
|
@@ -214,22 +223,29 @@ export const getCurrentDeviceSize = () => {
|
|
214
223
|
export const getCssProperty = (cssVar) => {
|
215
224
|
return getComputedStyle(document.documentElement).getPropertyValue(cssVar);
|
216
225
|
};
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
226
|
+
/**
|
227
|
+
* Returns the brightness of the theme colour, calculated by using the theme RGB CSS values by:
|
228
|
+
* - Multiplying each RGB value by a set number: https://www.w3.org/TR/AERT/#color-contrast
|
229
|
+
* - Adding them together and dividing by 1000
|
230
|
+
* This is a similar calculation to its CSS counterpart: "--ic-theme-text"
|
231
|
+
* @returns number representing the brightness of the theme colour
|
232
|
+
*/
|
233
|
+
export const getThemeColorBrightness = () => {
|
225
234
|
const themeRed = getCssProperty("--ic-theme-primary-r");
|
226
235
|
const themeGreen = getCssProperty("--ic-theme-primary-g");
|
227
236
|
const themeBlue = getCssProperty("--ic-theme-primary-b");
|
228
|
-
const
|
237
|
+
const themeColorBrightness = (parseInt(themeRed) * 299 +
|
229
238
|
parseInt(themeGreen) * 587 +
|
230
239
|
parseInt(themeBlue) * 114) /
|
231
|
-
1000
|
232
|
-
return
|
240
|
+
1000;
|
241
|
+
return themeColorBrightness;
|
242
|
+
};
|
243
|
+
/**
|
244
|
+
* Returns if dark or light foreground colors should be used for color contrast reasons
|
245
|
+
* @returns "dark" or "light"
|
246
|
+
*/
|
247
|
+
export const getThemeForegroundColor = () => {
|
248
|
+
return getThemeColorBrightness() > DARK_MODE_THRESHOLD
|
233
249
|
? IcThemeForegroundEnum.Dark
|
234
250
|
: IcThemeForegroundEnum.Light;
|
235
251
|
};
|
@@ -327,7 +343,7 @@ export const checkResizeObserver = (callbackFn) => {
|
|
327
343
|
const hex2dec = function (v) {
|
328
344
|
return parseInt(v, 16);
|
329
345
|
};
|
330
|
-
export const
|
346
|
+
export const hexToRgba = (hex) => {
|
331
347
|
let c;
|
332
348
|
if (hex.length === 4) {
|
333
349
|
c = hex.replace("#", "").split("");
|
@@ -335,6 +351,7 @@ export const hexToRgb = (hex) => {
|
|
335
351
|
r: hex2dec(c[0] + c[0]),
|
336
352
|
g: hex2dec(c[1] + c[1]),
|
337
353
|
b: hex2dec(c[2] + c[2]),
|
354
|
+
a: 1,
|
338
355
|
};
|
339
356
|
}
|
340
357
|
else {
|
@@ -342,19 +359,35 @@ export const hexToRgb = (hex) => {
|
|
342
359
|
r: hex2dec(hex.slice(1, 3)),
|
343
360
|
g: hex2dec(hex.slice(3, 5)),
|
344
361
|
b: hex2dec(hex.slice(5)),
|
362
|
+
a: 1,
|
345
363
|
};
|
346
364
|
}
|
347
365
|
};
|
348
|
-
export const
|
349
|
-
const
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
366
|
+
export const rgbaStrToObj = (rgbaStr) => {
|
367
|
+
const fourthChar = rgbaStr.slice(3, 4);
|
368
|
+
let colorRGBA;
|
369
|
+
if (fourthChar.toLowerCase() === "a") {
|
370
|
+
colorRGBA = { r: null, g: null, b: null, a: null };
|
371
|
+
const rgba = rgbaStr
|
372
|
+
.substring(5, rgbaStr.length - 1)
|
373
|
+
.replace(/ /g, "")
|
374
|
+
.split(",");
|
375
|
+
colorRGBA.r = Number(rgba[0]);
|
376
|
+
colorRGBA.g = Number(rgba[1]);
|
377
|
+
colorRGBA.b = Number(rgba[2]);
|
378
|
+
colorRGBA.a = Number(rgba[3]);
|
379
|
+
}
|
380
|
+
else {
|
381
|
+
colorRGBA = { r: null, g: null, b: null, a: 1 };
|
382
|
+
const rgb = rgbaStr
|
383
|
+
.substring(4, rgbaStr.length - 1)
|
384
|
+
.replace(/ /g, "")
|
385
|
+
.split(",");
|
386
|
+
colorRGBA.r = Number(rgb[0]);
|
387
|
+
colorRGBA.g = Number(rgb[1]);
|
388
|
+
colorRGBA.b = Number(rgb[2]);
|
389
|
+
}
|
390
|
+
return colorRGBA;
|
358
391
|
};
|
359
392
|
export const elementOverflowsX = (element) => {
|
360
393
|
return element.scrollWidth > element.clientWidth;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAUA,OAAO,EAGL,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAAoB,EACpB,aAAuB,EAAE,EACG,EAAE;EAC9B,MAAM,eAAe,GAA+B,EAAE,CAAC;EAEvD,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;IAC1B,IAAI,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;MAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;MACzC,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,eAAe,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;OACpD;MACD,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;KAC/B;EACH,CAAC,CAAC,CAAC;EAEH,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAmB,EACnB,IAAY,EACE,EAAE;EAChB,8DAA8D;EAC9D,MAAM,QAAQ,GAAI,KAAa,CAAC,SAAS,IAAI,KAAK,CAAC;EACnD,OAAO;IACL,SAAS,EAAE,KAAK;IAChB,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC;GACnC,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CACt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,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;EACzB,IAAI,IAAI,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;GAC/C;AACH,CAAC,CAAC","sourcesContent":["import { EventEmitter } from \"@stencil/core\";\nimport {\n IcCallbackFunctionNoReturn,\n IcInformationStatusOrEmpty,\n IcNavParentDetails,\n IcPropObject,\n IcColorRGB,\n IcSearchMatchPositions,\n} from \"./types\";\n\nimport {\n IcMenuOption,\n IcThemeForeground,\n IcThemeForegroundEnum,\n} from \"../utils/types\";\nimport {\n IC_BLOCK_COLOR_COMPONENTS,\n IC_BLOCK_COLOR_EXCEPTIONS,\n IC_FIXED_COLOR_COMPONENTS,\n} from \"./constants\";\n\nconst DARK_MODE_THRESHOLD = 128;\n\n/**\n * Used to inherit global attributes set on the host. Called in componentWillLoad and assigned\n * to a variable that is later used in the render function.\n *\n * This does not need to be reactive as changing attributes on the host element\n * does not trigger a re-render.\n */\nexport const inheritAttributes = (\n element: HTMLElement,\n attributes: string[] = []\n): { [key: string]: unknown } => {\n const attributeObject: { [key: string]: unknown } = {};\n\n attributes.forEach((attr) => {\n if (element.hasAttribute(attr)) {\n const value = element.getAttribute(attr);\n if (value !== null) {\n attributeObject[attr] = element.getAttribute(attr);\n }\n element.removeAttribute(attr);\n }\n });\n\n return attributeObject;\n};\n\nexport const debounceEvent = (\n event: EventEmitter,\n wait: number\n): EventEmitter => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const original = (event as any)._original || event;\n return {\n _original: event,\n emit: debounce(original.emit.bind(original), wait),\n } as EventEmitter;\n};\n\nexport const debounce = (\n func: (...args: unknown[]) => void,\n wait = 0\n): unknown => {\n let timer: ReturnType<typeof setTimeout>;\n return (...args: unknown[]) => {\n clearTimeout(timer);\n timer = setTimeout(func, wait, ...args);\n };\n};\n\n/**\n * This method is used to add a hidden input to a host element that contains\n * a Shadow DOM. It does not add the input inside of the Shadow root which\n * allows it to be picked up inside of forms. It should contain the same\n * values as the host element.\n *\n * @param always Add a hidden input even if the container does not use Shadow\n * @param container The element where the input will be added\n * @param name The name of the input\n * @param value The value of the input\n * @param disabled If true, the input is disabled\n */\nexport const renderHiddenInput = (\n always: boolean,\n container: HTMLElement,\n name: string,\n value: string | undefined | null,\n disabled: boolean\n): void => {\n if (always || hasShadowDom(container)) {\n let input = container.querySelector(\n \"input.ic-input\"\n ) as HTMLInputElement | null;\n if (input === null) {\n input = container.ownerDocument.createElement(\"input\");\n input.type = \"hidden\";\n input.classList.add(\"ic-input\");\n container.appendChild(input);\n }\n input.disabled = disabled;\n input.name = name;\n input.value = value || \"\";\n }\n};\n\nexport const removeHiddenInput = (container: HTMLElement): void => {\n const input = container.querySelector(\n \"input.ic-input\"\n ) as HTMLInputElement | null;\n input?.remove();\n};\n\nexport const hasShadowDom = (el: HTMLElement): boolean => {\n return !!el.shadowRoot && !!el.attachShadow;\n};\n\nexport const getInputHelperTextID = (id: string): string => {\n return id + \"-helper-text\";\n};\n\nexport const getInputValidationTextID = (id: string): string => {\n return id + \"-validation-text\";\n};\n\nexport const getInputDescribedByText = (\n inputId: string,\n helperText: boolean,\n validationText: boolean\n): string => {\n return `${helperText ? getInputHelperTextID(inputId) : \"\"} ${\n validationText ? getInputValidationTextID(inputId) : \"\"\n }`.trim();\n};\n\n/**\n * This method helps to understand the context in which a component exists,\n * to assist with choosing appropriate foreground colours to use. For example,\n * this method will help you use the 'white' version of a button if it's within\n * a block colour element using white foreground text.\n *\n * This only works for components/elements passed via <slot> and not if they\n * are part of an IC component.\n *\n * \"\"\n * @returns IcThemeForeground depending on the context\n */\nexport const getThemeFromContext = (\n el: Element,\n themeFromEvent: IcThemeForeground = null\n): IcThemeForeground => {\n const blockColorParent = el.parentElement.closest(\n IC_BLOCK_COLOR_COMPONENTS.join(\",\")\n );\n\n // If within a block color component\n if (blockColorParent !== null) {\n const parentTag = blockColorParent.tagName.toLowerCase();\n const currentTag = el.tagName.toLowerCase();\n\n if (IC_BLOCK_COLOR_EXCEPTIONS[parentTag]?.includes(currentTag)) {\n return IcThemeForegroundEnum.Default;\n } else if (\n themeFromEvent !== null &&\n !IC_FIXED_COLOR_COMPONENTS.includes(parentTag)\n ) {\n return themeFromEvent;\n } else if (\n blockColorParent.classList.contains(IcThemeForegroundEnum.Dark)\n ) {\n return IcThemeForegroundEnum.Dark;\n }\n\n return IcThemeForegroundEnum.Light;\n }\n\n return IcThemeForegroundEnum.Default;\n};\n\nexport const isMobileOrTablet = (): boolean => {\n let isMobileOrTablet = false;\n if (\"maxTouchPoints\" in navigator) {\n isMobileOrTablet = navigator.maxTouchPoints > 0;\n }\n return isMobileOrTablet;\n};\n\n/**\n * Will create a button within the lightDOM which interacts with the parent form.\n * This is required as buttons within the shadowDOM will not invoke a submit or reset\n *\n * @param form - parent form element which contains shadowDom button\n * @param button - shadowDOM button\n */\nexport const handleHiddenFormButtonClick = (\n form: HTMLFormElement,\n button: HTMLIcButtonElement | HTMLButtonElement\n): void => {\n const hiddenFormButton = document.createElement(\"button\");\n\n hiddenFormButton.setAttribute(\"type\", button.type);\n hiddenFormButton.style.display = \"none\";\n\n form.appendChild(hiddenFormButton);\n\n hiddenFormButton.click();\n hiddenFormButton.remove();\n};\n\nexport const isEmptyString = (value: string): boolean =>\n value.trim().length === 0;\n\n/**\n * Extracts the label using the value from an object. Requires the object to have a label and value property.\n * @param value - value from object\n * @param options - list of menu items\n * @returns - label corresponding to value\n */\nexport const getLabelFromValue = (\n value: string,\n options: IcMenuOption[]\n): string | undefined => {\n const ungroupedOptions: IcMenuOption[] = [];\n if (options.length > 0) {\n options.map((option) => {\n if (option.children) {\n option.children.map((option: IcMenuOption) =>\n ungroupedOptions.push(option)\n );\n } else {\n ungroupedOptions.push(option);\n }\n });\n return ungroupedOptions.find((option) => option.value === value)?.label;\n }\n\n return undefined;\n};\n\n/**\n * Filters the options based on the search string.\n * @param options - array of options\n * @param includeDescriptions - determines whether option descriptions are included when filtering options\n * @param searchString - string used to filter the options\n * @param position - whether the search string matches the start of or anywhere in the options\n * @returns filtered array of options\n */\nexport const getFilteredMenuOptions = (\n options: IcMenuOption[],\n includeDescriptions: boolean,\n searchString: string,\n position: IcSearchMatchPositions\n): IcMenuOption[] => {\n let rawFilteredOptions;\n\n if (position === \"anywhere\") {\n rawFilteredOptions = options.filter((option) => {\n if (includeDescriptions) {\n return (\n option.label.toLowerCase().includes(searchString.toLowerCase()) ||\n option.description?.toLowerCase().includes(searchString.toLowerCase())\n );\n } else {\n return option.label.toLowerCase().includes(searchString.toLowerCase());\n }\n });\n } else {\n rawFilteredOptions = options.filter((option) => {\n if (includeDescriptions) {\n return (\n option.label.toLowerCase().startsWith(searchString.toLowerCase()) ||\n option.description\n ?.toLowerCase()\n .startsWith(searchString.toLowerCase())\n );\n } else {\n return option.label\n .toLowerCase()\n .startsWith(searchString.toLowerCase());\n }\n });\n }\n\n return rawFilteredOptions;\n};\n\nexport const deviceSizeMatches = (size: number): boolean =>\n window.matchMedia(`(max-width: ${size}px)`).matches;\n\nexport const getCurrentDeviceSize = (): number => {\n if (deviceSizeMatches(DEVICE_SIZES.S)) {\n return DEVICE_SIZES.S;\n }\n if (deviceSizeMatches(DEVICE_SIZES.M)) {\n return DEVICE_SIZES.M;\n }\n if (deviceSizeMatches(DEVICE_SIZES.L)) {\n return DEVICE_SIZES.L;\n }\n if (deviceSizeMatches(DEVICE_SIZES.XL)) {\n return DEVICE_SIZES.XL;\n }\n //fallback needed as all of above get initialised to 0 in jest tests\n return DEVICE_SIZES.UNDEFINED;\n};\n\nexport const getCssProperty = (cssVar: string): string => {\n return getComputedStyle(document.documentElement).getPropertyValue(cssVar);\n};\n\nexport const getThemeForegroundColor = (): IcThemeForeground => {\n /*\n Returns if dark or light font colors should be used for color contrast reasons, calculated by using the theme RGB CSS values by:\n - Multiplying each RGB value by a set number: https://www.w3.org/TR/AERT/#color-contrast\n - Adding them together and dividing by 1000\n - If the result is greater than 128 return \"dark\" color, else return \"light\" color\n This is a similar calculation to it's CSS counterpart: \"--ic-theme-text\"\n */\n const themeRed = getCssProperty(\"--ic-theme-primary-r\");\n const themeGreen = getCssProperty(\"--ic-theme-primary-g\");\n const themeBlue = getCssProperty(\"--ic-theme-primary-b\");\n const fontColor = Math.round(\n (parseInt(themeRed) * 299 +\n parseInt(themeGreen) * 587 +\n parseInt(themeBlue) * 114) /\n 1000\n );\n\n return fontColor > DARK_MODE_THRESHOLD\n ? IcThemeForegroundEnum.Dark\n : IcThemeForegroundEnum.Light;\n};\n\nexport const getSlot = (element: HTMLElement, name: string): Element | null => {\n if (element && element.querySelector) {\n return element.querySelector(`[slot=\"${name}\"]`);\n }\n return null;\n};\n\nexport const slotHasContent = (element: HTMLElement, name: string): boolean =>\n getSlot(element, name) !== null;\n\nexport const getSlotContent = (\n element: HTMLElement,\n name: string\n): Element[] | NodeListOf<ChildNode> | null => {\n const slot = getSlot(element, name);\n if (slot) {\n return getSlotElements(slot);\n }\n\n return null;\n};\n\nconst getSlotElements = (slot: Element) => {\n const slotContent = slot.firstElementChild as HTMLSlotElement;\n\n if (slotContent !== null) {\n const elements = slotContent.assignedElements\n ? slotContent.assignedElements()\n : slotContent.childNodes;\n return elements.length ? elements : null;\n } else {\n //check for single element\n return slot === null ? null : [slot];\n }\n};\n\nexport const getNavItemParentDetails = (\n el: HTMLElement\n): IcNavParentDetails => {\n let navType: IcNavParentDetails = { navType: \"\", parent: null };\n switch (getParentElementType(el)) {\n case \"IC-NAVIGATION-GROUP\":\n navType = getNavItemParentDetails(el.parentElement);\n break;\n case \"IC-TOP-NAVIGATION\":\n navType = { navType: \"top\", parent: getParentElement(el) };\n break;\n case \"IC-SIDE-NAVIGATION\":\n navType = { navType: \"side\", parent: getParentElement(el) };\n break;\n case \"IC-PAGE-HEADER\":\n navType = { navType: \"page-header\", parent: null };\n break;\n }\n return navType;\n};\n\nexport const DEVICE_SIZES = {\n XS: Number(getCssProperty(\"--ic-breakpoint-xs\").replace(\"px\", \"\")), // 0\n S: Number(getCssProperty(\"--ic-breakpoint-sm\").replace(\"px\", \"\")), // 576\n M: Number(getCssProperty(\"--ic-breakpoint-md\").replace(\"px\", \"\")), // 768\n L: Number(getCssProperty(\"--ic-breakpoint-lg\").replace(\"px\", \"\")), // 992\n XL: Number(getCssProperty(\"--ic-breakpoint-xl\").replace(\"px\", \"\")), // 1200\n UNDEFINED: 1200,\n};\n\nexport const hasValidationStatus = (\n status: IcInformationStatusOrEmpty,\n disabled: boolean\n): boolean => {\n return status !== \"\" && !disabled;\n};\n\nexport const isSlotUsed = (element: HTMLElement, slotName: string): boolean => {\n return !!element.querySelector(`[slot=\"${slotName}\"]`);\n};\n\n// added as a common method to allow detection of gatsby hydration issue, where (camelCase) props are initially undefined & then update\n// with a value. Allows a callback function to be executed when this is the case\nexport const onComponentPropUndefinedChange = (\n oldValue: string | undefined,\n newValue: string | undefined,\n callback: IcCallbackFunctionNoReturn\n): void => {\n if (oldValue === undefined && newValue !== oldValue) {\n callback();\n }\n};\n\nexport const onComponentRequiredPropUndefined = (\n props: IcPropObject[],\n component: string\n): void => {\n for (let i = 0; i < props.length; i++) {\n const { prop, propName } = props[i];\n if (prop === null || prop === undefined) {\n console.error(\n `No ${propName} specified for ${component} component - prop '${propName}' (web components) / '${kebabToCamelCase(\n propName\n )}' (react) required`\n );\n }\n }\n};\n\nexport const kebabToCamelCase = (kebabCase: string): string => {\n kebabCase = kebabCase.toLowerCase();\n const individualWords: string[] = kebabCase.split(\"-\");\n let camelCase = individualWords[0];\n for (let i = 1; i < individualWords.length; i++) {\n camelCase +=\n individualWords[i].substring(0, 1).toUpperCase() +\n individualWords[i].substring(1);\n }\n return camelCase;\n};\n\nexport const checkResizeObserver = (\n callbackFn: IcCallbackFunctionNoReturn\n): void => {\n if (\n typeof window !== \"undefined\" &&\n typeof window.ResizeObserver !== \"undefined\"\n ) {\n callbackFn();\n }\n};\n\nconst hex2dec = function (v: string) {\n return parseInt(v, 16);\n};\n\nexport const hexToRgb = (hex: string): IcColorRGB => {\n let c;\n if (hex.length === 4) {\n c = hex.replace(\"#\", \"\").split(\"\");\n return {\n r: hex2dec(c[0] + c[0]),\n g: hex2dec(c[1] + c[1]),\n b: hex2dec(c[2] + c[2]),\n };\n } else {\n return {\n r: hex2dec(hex.slice(1, 3)),\n g: hex2dec(hex.slice(3, 5)),\n b: hex2dec(hex.slice(5)),\n };\n }\n};\n\nexport const rgbStrToObj = (rgbStr: string): IcColorRGB => {\n const colorRGB: IcColorRGB = { r: null, g: null, b: null };\n const rgb = rgbStr\n .substring(4, rgbStr.length - 1)\n .replace(/ /g, \"\")\n .split(\",\");\n colorRGB.r = Number(rgb[0]);\n colorRGB.g = Number(rgb[1]);\n colorRGB.b = Number(rgb[2]);\n\n return colorRGB;\n};\n\nexport const elementOverflowsX = (element: HTMLElement): boolean => {\n return element.scrollWidth > element.clientWidth;\n};\n/**\n *\n * @param child - The child element\n * @returns string\n */\nexport const getParentElementType = (child: HTMLElement): string =>\n child.parentElement.tagName;\n\nexport const getParentElement = (child: HTMLElement): HTMLElement =>\n child.parentElement;\n\nexport const hasClassificationBanner = (): boolean => {\n if (document.querySelector(\"ic-classification-banner:not([inline='true'])\")) {\n return true;\n } else {\n return false;\n }\n};\n\nexport const getForm = (el: HTMLElement): HTMLFormElement | null => {\n return el.closest(\"FORM\");\n};\n\nexport const addFormResetListener = (\n el: HTMLElement,\n callbackFn: IcCallbackFunctionNoReturn\n) => {\n const form = getForm(el);\n if (form !== null) {\n form.addEventListener(\"reset\", callbackFn);\n }\n};\n\nexport const removeFormResetListener = (\n el: HTMLElement,\n callbackFn: IcCallbackFunctionNoReturn\n) => {\n const form = getForm(el);\n if (form !== null) {\n form.removeEventListener(\"reset\", callbackFn);\n }\n};\n"]}
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAUA,OAAO,EAGL,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAA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AAC,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;GAC5C;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,EAAe,EACf,UAAsC,EACtC,EAAE;EACF,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;EACzB,IAAI,IAAI,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;GAC/C;AACH,CAAC,CAAC","sourcesContent":["import { EventEmitter } from \"@stencil/core\";\nimport {\n IcCallbackFunctionNoReturn,\n IcInformationStatusOrEmpty,\n IcNavParentDetails,\n IcPropObject,\n IcSearchMatchPositions,\n IcColorRGBA,\n} from \"./types\";\n\nimport {\n IcMenuOption,\n IcThemeForeground,\n IcThemeForegroundEnum,\n} from \"../utils/types\";\nimport {\n IC_BLOCK_COLOR_COMPONENTS,\n IC_BLOCK_COLOR_EXCEPTIONS,\n IC_FIXED_COLOR_COMPONENTS,\n} from \"./constants\";\n\nconst DARK_MODE_THRESHOLD = 133.3505;\n\n/**\n * Used to inherit global attributes set on the host. Called in componentWillLoad and assigned\n * to a variable that is later used in the render function.\n *\n * This does not need to be reactive as changing attributes on the host element\n * does not trigger a re-render.\n */\nexport const inheritAttributes = (\n element: HTMLElement,\n attributes: string[] = []\n): { [key: string]: unknown } => {\n const attributeObject: { [key: string]: unknown } = {};\n\n attributes.forEach((attr) => {\n if (element.hasAttribute(attr)) {\n const value = element.getAttribute(attr);\n if (value !== null) {\n attributeObject[attr] = element.getAttribute(attr);\n }\n element.removeAttribute(attr);\n }\n });\n\n return attributeObject;\n};\n\nexport const debounceEvent = (\n event: EventEmitter,\n wait: number\n): EventEmitter => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const original = (event as any)._original || event;\n return {\n _original: event,\n emit: debounce(original.emit.bind(original), wait),\n } as EventEmitter;\n};\n\nexport const debounce = (\n func: (...args: unknown[]) => void,\n wait = 0\n): unknown => {\n let timer: ReturnType<typeof setTimeout>;\n return (...args: unknown[]) => {\n clearTimeout(timer);\n timer = setTimeout(func, wait, ...args);\n };\n};\n\n/**\n * This method is used to add a hidden input to a host element that contains\n * a Shadow DOM. It does not add the input inside of the Shadow root which\n * allows it to be picked up inside of forms. It should contain the same\n * values as the host element.\n *\n * @param always Add a hidden input even if the container does not use Shadow\n * @param container The element where the input will be added\n * @param name The name of the input\n * @param value The value of the input\n * @param disabled If true, the input is disabled\n */\nexport const renderHiddenInput = (\n always: boolean,\n container: HTMLElement,\n name: string,\n value: string | undefined | null,\n disabled: boolean\n): void => {\n if (name !== undefined) {\n if (always || hasShadowDom(container)) {\n const inputs = container.querySelectorAll(\"input.ic-input\");\n const inputEls = Array.from(inputs);\n const filtered = inputEls.filter((el) => container === el.parentElement);\n\n let input = filtered[0] as HTMLInputElement;\n if (input === null || input === undefined) {\n input = container.ownerDocument.createElement(\"input\");\n input.type = \"hidden\";\n input.classList.add(\"ic-input\");\n container.appendChild(input);\n }\n input.disabled = disabled;\n input.name = name;\n input.value = value || \"\";\n }\n }\n};\n\nexport const removeHiddenInput = (container: HTMLElement): void => {\n const inputs = container.querySelectorAll(\"input.ic-input\");\n const inputEls = Array.from(inputs);\n const filtered = inputEls.filter((el) => container === el.parentElement);\n const input = filtered[0] as HTMLInputElement;\n input?.remove();\n};\n\nexport const hasShadowDom = (el: HTMLElement): boolean => {\n return !!el.shadowRoot && !!el.attachShadow;\n};\n\nexport const getInputHelperTextID = (id: string): string => {\n return id + \"-helper-text\";\n};\n\nexport const getInputValidationTextID = (id: string): string => {\n return id + \"-validation-text\";\n};\n\nexport const getInputDescribedByText = (\n inputId: string,\n helperText: boolean,\n validationText: boolean\n): string => {\n return `${helperText ? getInputHelperTextID(inputId) : \"\"} ${\n validationText ? getInputValidationTextID(inputId) : \"\"\n }`.trim();\n};\n\n/**\n * This method helps to understand the context in which a component exists,\n * to assist with choosing appropriate foreground colours to use. For example,\n * this method will help you use the 'white' version of a button if it's within\n * a block colour element using white foreground text.\n *\n * This only works for components/elements passed via <slot> and not if they\n * are part of an IC component.\n *\n * \"\"\n * @returns IcThemeForeground depending on the context\n */\nexport const getThemeFromContext = (\n el: Element,\n themeFromEvent: IcThemeForeground = null\n): IcThemeForeground => {\n const parentElement =\n el.parentElement || (<ShadowRoot>el.getRootNode()).host.parentElement;\n const blockColorParent = parentElement.closest(\n IC_BLOCK_COLOR_COMPONENTS.join(\",\")\n );\n\n // If within a block color component\n if (blockColorParent !== null) {\n const parentTag = blockColorParent.tagName.toLowerCase();\n const currentTag = el.tagName.toLowerCase();\n\n if (IC_BLOCK_COLOR_EXCEPTIONS[parentTag]?.includes(currentTag)) {\n return IcThemeForegroundEnum.Default;\n } else if (\n themeFromEvent !== null &&\n !IC_FIXED_COLOR_COMPONENTS.includes(parentTag)\n ) {\n return themeFromEvent;\n } else if (\n blockColorParent.classList.contains(IcThemeForegroundEnum.Dark)\n ) {\n return IcThemeForegroundEnum.Dark;\n }\n\n return IcThemeForegroundEnum.Light;\n }\n\n return IcThemeForegroundEnum.Default;\n};\n\nexport const isMobileOrTablet = (): boolean => {\n let isMobileOrTablet = false;\n if (\"maxTouchPoints\" in navigator) {\n isMobileOrTablet = navigator.maxTouchPoints > 0;\n }\n return isMobileOrTablet;\n};\n\n/**\n * Will create a button within the lightDOM which interacts with the parent form.\n * This is required as buttons within the shadowDOM will not invoke a submit or reset\n *\n * @param form - parent form element which contains shadowDom button\n * @param button - shadowDOM button\n */\nexport const handleHiddenFormButtonClick = (\n form: HTMLFormElement,\n button: HTMLIcButtonElement | HTMLButtonElement\n): void => {\n const hiddenFormButton = document.createElement(\"button\");\n\n hiddenFormButton.setAttribute(\"type\", button.type);\n hiddenFormButton.style.display = \"none\";\n\n form.appendChild(hiddenFormButton);\n\n hiddenFormButton.click();\n hiddenFormButton.remove();\n};\n\nexport const isEmptyString = (value: string): boolean =>\n value.trim().length === 0;\n\n/**\n * Extracts the label using the value from an object. Requires the object to have a label and value property.\n * @param value - value from object\n * @param options - list of menu items\n * @returns - label corresponding to value\n */\nexport const getLabelFromValue = (\n value: string,\n options: IcMenuOption[]\n): string | undefined => {\n const ungroupedOptions: IcMenuOption[] = [];\n if (options.length > 0) {\n options.map((option) => {\n if (option.children) {\n option.children.map((option: IcMenuOption) =>\n ungroupedOptions.push(option)\n );\n } else {\n ungroupedOptions.push(option);\n }\n });\n return ungroupedOptions.find((option) => option.value === value)?.label;\n }\n\n return undefined;\n};\n\n/**\n * Filters the options based on the search string.\n * @param options - array of options\n * @param includeDescriptions - determines whether option descriptions are included when filtering options\n * @param searchString - string used to filter the options\n * @param position - whether the search string matches the start of or anywhere in the options\n * @returns filtered array of options\n */\nexport const getFilteredMenuOptions = (\n options: IcMenuOption[],\n includeDescriptions: boolean,\n searchString: string,\n position: IcSearchMatchPositions\n): IcMenuOption[] => {\n let rawFilteredOptions;\n\n if (position === \"anywhere\") {\n rawFilteredOptions = options.filter((option) => {\n if (includeDescriptions) {\n return (\n option.label.toLowerCase().includes(searchString.toLowerCase()) ||\n option.description?.toLowerCase().includes(searchString.toLowerCase())\n );\n } else {\n return option.label.toLowerCase().includes(searchString.toLowerCase());\n }\n });\n } else {\n rawFilteredOptions = options.filter((option) => {\n if (includeDescriptions) {\n return (\n option.label.toLowerCase().startsWith(searchString.toLowerCase()) ||\n option.description\n ?.toLowerCase()\n .startsWith(searchString.toLowerCase())\n );\n } else {\n return option.label\n .toLowerCase()\n .startsWith(searchString.toLowerCase());\n }\n });\n }\n\n return rawFilteredOptions;\n};\n\nexport const deviceSizeMatches = (size: number): boolean =>\n window.matchMedia(`(max-width: ${size}px)`).matches;\n\nexport const getCurrentDeviceSize = (): number => {\n if (deviceSizeMatches(DEVICE_SIZES.S)) {\n return DEVICE_SIZES.S;\n }\n if (deviceSizeMatches(DEVICE_SIZES.M)) {\n return DEVICE_SIZES.M;\n }\n if (deviceSizeMatches(DEVICE_SIZES.L)) {\n return DEVICE_SIZES.L;\n }\n if (deviceSizeMatches(DEVICE_SIZES.XL)) {\n return DEVICE_SIZES.XL;\n }\n //fallback needed as all of above get initialised to 0 in jest tests\n return DEVICE_SIZES.UNDEFINED;\n};\n\nexport const getCssProperty = (cssVar: string): string => {\n return getComputedStyle(document.documentElement).getPropertyValue(cssVar);\n};\n\n/**\n * Returns the brightness of the theme colour, calculated by using the theme RGB CSS values by:\n * - Multiplying each RGB value by a set number: https://www.w3.org/TR/AERT/#color-contrast\n * - Adding them together and dividing by 1000\n * This is a similar calculation to its CSS counterpart: \"--ic-theme-text\"\n * @returns number representing the brightness of the theme colour\n */\nexport const getThemeColorBrightness = () => {\n const themeRed = getCssProperty(\"--ic-theme-primary-r\");\n const themeGreen = getCssProperty(\"--ic-theme-primary-g\");\n const themeBlue = getCssProperty(\"--ic-theme-primary-b\");\n const themeColorBrightness =\n (parseInt(themeRed) * 299 +\n parseInt(themeGreen) * 587 +\n parseInt(themeBlue) * 114) /\n 1000;\n return themeColorBrightness;\n};\n\n/**\n * Returns if dark or light foreground colors should be used for color contrast reasons\n * @returns \"dark\" or \"light\"\n */\nexport const getThemeForegroundColor = (): IcThemeForeground => {\n return getThemeColorBrightness() > DARK_MODE_THRESHOLD\n ? IcThemeForegroundEnum.Dark\n : IcThemeForegroundEnum.Light;\n};\n\nexport const getSlot = (element: HTMLElement, name: string): Element | null => {\n if (element && element.querySelector) {\n return element.querySelector(`[slot=\"${name}\"]`);\n }\n return null;\n};\n\nexport const slotHasContent = (element: HTMLElement, name: string): boolean =>\n getSlot(element, name) !== null;\n\nexport const getSlotContent = (\n element: HTMLElement,\n name: string\n): Element[] | NodeListOf<ChildNode> | null => {\n const slot = getSlot(element, name);\n if (slot) {\n return getSlotElements(slot);\n }\n\n return null;\n};\n\nconst getSlotElements = (slot: Element) => {\n const slotContent = slot.firstElementChild as HTMLSlotElement;\n\n if (slotContent !== null) {\n const elements = slotContent.assignedElements\n ? slotContent.assignedElements()\n : slotContent.childNodes;\n return elements.length ? elements : null;\n } else {\n //check for single element\n return slot === null ? null : [slot];\n }\n};\n\nexport const getNavItemParentDetails = (\n el: HTMLElement\n): IcNavParentDetails => {\n let navType: IcNavParentDetails = { navType: \"\", parent: null };\n switch (getParentElementType(el)) {\n case \"IC-NAVIGATION-GROUP\":\n navType = getNavItemParentDetails(el.parentElement);\n break;\n case \"IC-TOP-NAVIGATION\":\n navType = { navType: \"top\", parent: getParentElement(el) };\n break;\n case \"IC-SIDE-NAVIGATION\":\n navType = { navType: \"side\", parent: getParentElement(el) };\n break;\n case \"IC-PAGE-HEADER\":\n navType = { navType: \"page-header\", parent: null };\n break;\n }\n return navType;\n};\n\nexport const DEVICE_SIZES = {\n XS: Number(getCssProperty(\"--ic-breakpoint-xs\").replace(\"px\", \"\")), // 0\n S: Number(getCssProperty(\"--ic-breakpoint-sm\").replace(\"px\", \"\")), // 576\n M: Number(getCssProperty(\"--ic-breakpoint-md\").replace(\"px\", \"\")), // 768\n L: Number(getCssProperty(\"--ic-breakpoint-lg\").replace(\"px\", \"\")), // 992\n XL: Number(getCssProperty(\"--ic-breakpoint-xl\").replace(\"px\", \"\")), // 1200\n UNDEFINED: 1200,\n};\n\nexport const hasValidationStatus = (\n status: IcInformationStatusOrEmpty,\n disabled: boolean\n): boolean => {\n return status !== \"\" && !disabled;\n};\n\nexport const isSlotUsed = (element: HTMLElement, slotName: string): boolean => {\n return !!element.querySelector(`[slot=\"${slotName}\"]`);\n};\n\n// added as a common method to allow detection of gatsby hydration issue, where (camelCase) props are initially undefined & then update\n// with a value. Allows a callback function to be executed when this is the case\nexport const onComponentPropUndefinedChange = (\n oldValue: string | undefined,\n newValue: string | undefined,\n callback: IcCallbackFunctionNoReturn\n): void => {\n if (oldValue === undefined && newValue !== oldValue) {\n callback();\n }\n};\n\nexport const onComponentRequiredPropUndefined = (\n props: IcPropObject[],\n component: string\n): void => {\n for (let i = 0; i < props.length; i++) {\n const { prop, propName } = props[i];\n if (prop === null || prop === undefined) {\n console.error(\n `No ${propName} specified for ${component} component - prop '${propName}' (web components) / '${kebabToCamelCase(\n propName\n )}' (react) required`\n );\n }\n }\n};\n\nexport const kebabToCamelCase = (kebabCase: string): string => {\n kebabCase = kebabCase.toLowerCase();\n const individualWords: string[] = kebabCase.split(\"-\");\n let camelCase = individualWords[0];\n for (let i = 1; i < individualWords.length; i++) {\n camelCase +=\n individualWords[i].substring(0, 1).toUpperCase() +\n individualWords[i].substring(1);\n }\n return camelCase;\n};\n\nexport const checkResizeObserver = (\n callbackFn: IcCallbackFunctionNoReturn\n): void => {\n if (\n typeof window !== \"undefined\" &&\n typeof window.ResizeObserver !== \"undefined\"\n ) {\n callbackFn();\n }\n};\n\nconst hex2dec = function (v: string) {\n return parseInt(v, 16);\n};\n\nexport const hexToRgba = (hex: string): IcColorRGBA => {\n let c;\n if (hex.length === 4) {\n c = hex.replace(\"#\", \"\").split(\"\");\n return {\n r: hex2dec(c[0] + c[0]),\n g: hex2dec(c[1] + c[1]),\n b: hex2dec(c[2] + c[2]),\n a: 1,\n };\n } else {\n return {\n r: hex2dec(hex.slice(1, 3)),\n g: hex2dec(hex.slice(3, 5)),\n b: hex2dec(hex.slice(5)),\n a: 1,\n };\n }\n};\n\nexport const rgbaStrToObj = (rgbaStr: string): IcColorRGBA => {\n const fourthChar = rgbaStr.slice(3, 4);\n let colorRGBA: IcColorRGBA;\n if (fourthChar.toLowerCase() === \"a\") {\n colorRGBA = { r: null, g: null, b: null, a: null };\n const rgba = rgbaStr\n .substring(5, rgbaStr.length - 1)\n .replace(/ /g, \"\")\n .split(\",\");\n colorRGBA.r = Number(rgba[0]);\n colorRGBA.g = Number(rgba[1]);\n colorRGBA.b = Number(rgba[2]);\n colorRGBA.a = Number(rgba[3]);\n } else {\n colorRGBA = { r: null, g: null, b: null, a: 1 };\n const rgb = rgbaStr\n .substring(4, rgbaStr.length - 1)\n .replace(/ /g, \"\")\n .split(\",\");\n colorRGBA.r = Number(rgb[0]);\n colorRGBA.g = Number(rgb[1]);\n colorRGBA.b = Number(rgb[2]);\n }\n\n return colorRGBA;\n};\n\nexport const elementOverflowsX = (element: HTMLElement): boolean => {\n return element.scrollWidth > element.clientWidth;\n};\n/**\n *\n * @param child - The child element\n * @returns string\n */\nexport const getParentElementType = (child: HTMLElement): string =>\n child.parentElement.tagName;\n\nexport const getParentElement = (child: HTMLElement): HTMLElement =>\n child.parentElement;\n\nexport const hasClassificationBanner = (): boolean => {\n if (document.querySelector(\"ic-classification-banner:not([inline='true'])\")) {\n return true;\n } else {\n return false;\n }\n};\n\nexport const getForm = (el: HTMLElement): HTMLFormElement | null => {\n return el.closest(\"FORM\");\n};\n\nexport const addFormResetListener = (\n el: HTMLElement,\n callbackFn: IcCallbackFunctionNoReturn\n) => {\n const form = getForm(el);\n if (form !== null) {\n form.addEventListener(\"reset\", callbackFn);\n }\n};\n\nexport const removeFormResetListener = (\n el: HTMLElement,\n callbackFn: IcCallbackFunctionNoReturn\n) => {\n const form = getForm(el);\n if (form !== null) {\n form.removeEventListener(\"reset\", callbackFn);\n }\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAIX;AAJD,WAAY,mBAAmB;EAC7B,0CAAmB,CAAA;EACnB,sCAAe,CAAA;EACf,0CAAmB,CAAA;AACrB,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,QAI9B;AAkED,MAAM,CAAN,IAAY,qBAIX;AAJD,WAAY,qBAAqB;EAC/B,4CAAmB,CAAA;EACnB,sCAAa,CAAA;EACb,wCAAe,CAAA;AACjB,CAAC,EAJW,qBAAqB,KAArB,qBAAqB,QAIhC","sourcesContent":["export enum IcInformationStatus {\n Warning = \"warning\",\n Error = \"error\",\n Success = \"success\",\n}\n\nexport type IcInformationStatusOrEmpty = \"warning\" | \"error\" | \"success\" | \"\";\n\nexport type IcNavType = \"side\" | \"top\" | \"page-header\";\n\n// From: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\nexport type IcAutocompleteTypes =\n | \"on\"\n | \"off\"\n | \"name\"\n | \"honorific-prefix\"\n | \"given-name\"\n | \"additional-name\"\n | \"family-name\"\n | \"honorific-suffix\"\n | \"nickname\"\n | \"email\"\n | \"username\"\n | \"new-password\"\n | \"current-password\"\n | \"one-time-code\"\n | \"organization-title\"\n | \"organization\"\n | \"street-address\"\n | \"address-line1\"\n | \"address-line2\"\n | \"address-line3\"\n | \"address-level4\"\n | \"address-level3\"\n | \"address-level2\"\n | \"address-level1\"\n | \"country\"\n | \"country-name\"\n | \"postal-code\"\n | \"cc-name\"\n | \"cc-given-name\"\n | \"cc-additional-name\"\n | \"cc-family-name\"\n | \"cc-family-name\"\n | \"cc-number\"\n | \"cc-exp\"\n | \"cc-exp-month\"\n | \"cc-exp-year\"\n | \"cc-csc\"\n | \"cc-type\"\n | \"transaction-currency\"\n | \"transaction-amount\"\n | \"language\"\n | \"bday\"\n | \"bday-day\"\n | \"bday-month\"\n | \"bday-year\"\n | \"sex\"\n | \"tel\"\n | \"tel-country-code\"\n | \"tel-national\"\n | \"tel-area-code\"\n | \"tel-local\"\n | \"tel-extension\"\n | \"impp\"\n | \"url\"\n | \"photo\";\n\nexport type IcAlignment = \"left\" | \"center\" | \"full-width\";\n\nexport enum IcThemeForegroundEnum {\n Default = \"default\",\n Dark = \"dark\",\n Light = \"light\",\n}\n\nexport type IcThemeForeground = \"default\" | \"dark\" | \"light\";\n\nexport type IcThemeForegroundNoDefault = \"dark\" | \"light\";\n\nexport type IcTheme = {\n mode: IcThemeForeground;\n color: IcColorRGB;\n};\n\nexport type IcAdditionalFieldTypes = \"static\" | \"dynamic\";\n\nexport type IcColorRGB = {\n r: number;\n g: number;\n b: number;\n};\n\nexport type IcActivationTypes = \"automatic\" | \"manual\";\n\nexport type IcAutocorrectStates = \"on\" | \"off\";\n\nexport type IcNavParentDetails = {\n navType: IcNavType | \"\";\n parent: HTMLElement;\n};\n\nexport type IcTypographyVariants =\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"subtitle-large\"\n | \"subtitle-small\"\n | \"body\"\n | \"label\"\n | \"label-uppercase\"\n | \"caption\"\n | \"caption-uppercase\";\n\nexport interface IcMenuOption {\n value?: string;\n label: string;\n description?: string;\n disabled?: boolean;\n recommended?: boolean;\n children?: IcMenuOption[];\n}\n\nexport type IcSearchMatchPositions = \"start\" | \"anywhere\";\n\nexport type IcCallbackFunctionNoReturn = (...args: unknown[]) => void;\n\nexport type IcRequiredPropsTypes =\n | string\n | boolean\n | number\n | HTMLElement\n | IcMenuOption[];\n\nexport type IcPropObject = { prop: IcRequiredPropsTypes; propName: string };\n\nexport type IcRelatedTarget = EventTarget | undefined;\n\nexport interface IcValueEventDetail {\n value: string;\n}\nexport interface IcBlurEventDetail {\n relatedTarget: IcRelatedTarget;\n}\n"]}
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAIX;AAJD,WAAY,mBAAmB;EAC7B,0CAAmB,CAAA;EACnB,sCAAe,CAAA;EACf,0CAAmB,CAAA;AACrB,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,QAI9B;AAkED,MAAM,CAAN,IAAY,qBAIX;AAJD,WAAY,qBAAqB;EAC/B,4CAAmB,CAAA;EACnB,sCAAa,CAAA;EACb,wCAAe,CAAA;AACjB,CAAC,EAJW,qBAAqB,KAArB,qBAAqB,QAIhC","sourcesContent":["export enum IcInformationStatus {\n Warning = \"warning\",\n Error = \"error\",\n Success = \"success\",\n}\n\nexport type IcInformationStatusOrEmpty = \"warning\" | \"error\" | \"success\" | \"\";\n\nexport type IcNavType = \"side\" | \"top\" | \"page-header\";\n\n// From: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\nexport type IcAutocompleteTypes =\n | \"on\"\n | \"off\"\n | \"name\"\n | \"honorific-prefix\"\n | \"given-name\"\n | \"additional-name\"\n | \"family-name\"\n | \"honorific-suffix\"\n | \"nickname\"\n | \"email\"\n | \"username\"\n | \"new-password\"\n | \"current-password\"\n | \"one-time-code\"\n | \"organization-title\"\n | \"organization\"\n | \"street-address\"\n | \"address-line1\"\n | \"address-line2\"\n | \"address-line3\"\n | \"address-level4\"\n | \"address-level3\"\n | \"address-level2\"\n | \"address-level1\"\n | \"country\"\n | \"country-name\"\n | \"postal-code\"\n | \"cc-name\"\n | \"cc-given-name\"\n | \"cc-additional-name\"\n | \"cc-family-name\"\n | \"cc-family-name\"\n | \"cc-number\"\n | \"cc-exp\"\n | \"cc-exp-month\"\n | \"cc-exp-year\"\n | \"cc-csc\"\n | \"cc-type\"\n | \"transaction-currency\"\n | \"transaction-amount\"\n | \"language\"\n | \"bday\"\n | \"bday-day\"\n | \"bday-month\"\n | \"bday-year\"\n | \"sex\"\n | \"tel\"\n | \"tel-country-code\"\n | \"tel-national\"\n | \"tel-area-code\"\n | \"tel-local\"\n | \"tel-extension\"\n | \"impp\"\n | \"url\"\n | \"photo\";\n\nexport type IcAlignment = \"left\" | \"center\" | \"full-width\";\n\nexport enum IcThemeForegroundEnum {\n Default = \"default\",\n Dark = \"dark\",\n Light = \"light\",\n}\n\nexport type IcThemeForeground = \"default\" | \"dark\" | \"light\";\n\nexport type IcThemeForegroundNoDefault = \"dark\" | \"light\";\n\nexport type IcTheme = {\n mode: IcThemeForeground;\n color: IcColorRGB;\n};\n\nexport type IcAdditionalFieldTypes = \"static\" | \"dynamic\";\n\nexport type IcColorRGB = {\n r: number;\n g: number;\n b: number;\n};\n\nexport type IcColorRGBA = IcColorRGB & {\n a: number;\n};\n\nexport type IcActivationTypes = \"automatic\" | \"manual\";\n\nexport type IcAutocorrectStates = \"on\" | \"off\";\n\nexport type IcNavParentDetails = {\n navType: IcNavType | \"\";\n parent: HTMLElement;\n};\n\nexport type IcTypographyVariants =\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"subtitle-large\"\n | \"subtitle-small\"\n | \"body\"\n | \"label\"\n | \"label-uppercase\"\n | \"caption\"\n | \"caption-uppercase\";\n\nexport interface IcMenuOption {\n value?: string;\n label: string;\n description?: string;\n disabled?: boolean;\n recommended?: boolean;\n children?: IcMenuOption[];\n}\n\nexport type IcSearchMatchPositions = \"start\" | \"anywhere\";\n\nexport type IcCallbackFunctionNoReturn = (...args: unknown[]) => void;\n\nexport type IcRequiredPropsTypes =\n | string\n | boolean\n | number\n | HTMLElement\n | IcMenuOption[];\n\nexport type IcPropObject = { prop: IcRequiredPropsTypes; propName: string };\n\nexport type IcRelatedTarget = EventTarget | undefined;\n\nexport interface IcValueEventDetail {\n value: string;\n}\nexport interface IcBlurEventDetail {\n relatedTarget: IcRelatedTarget;\n}\n"]}
|
@@ -43,8 +43,17 @@ const IC_FIXED_COLOR_COMPONENTS = ["ic-alert"];
|
|
43
43
|
const IC_BLOCK_COLOR_EXCEPTIONS = {
|
44
44
|
"ic-alert": ["ic-link"],
|
45
45
|
};
|
46
|
+
/* Range within which the chosen theme colour would not have a sufficient brightness difference with either of the black or white foreground colours
|
47
|
+
* The brightness difference must be greater than 125 to provide good colour visibility
|
48
|
+
* Calculated by:
|
49
|
+
* - Using the brightness formula for both colours: https://www.w3.org/TR/AERT/#color-contrast
|
50
|
+
* - Adding 125 to the brightness of the black foreground colour - RGB(11, 12, 12)
|
51
|
+
* - Subtracting 125 from the brightness of the white foreground colour - RGB(255, 255, 255)
|
52
|
+
*/
|
53
|
+
const BLACK_MIN_COLOR_BRIGHTNESS = 136.701;
|
54
|
+
const WHITE_MAX_COLOR_BRIGHTNESS = 130;
|
46
55
|
|
47
|
-
const DARK_MODE_THRESHOLD =
|
56
|
+
const DARK_MODE_THRESHOLD = 133.3505;
|
48
57
|
/**
|
49
58
|
* Used to inherit global attributes set on the host. Called in componentWillLoad and assigned
|
50
59
|
* to a variable that is later used in the render function.
|
@@ -93,21 +102,29 @@ const debounce = (func, wait = 0) => {
|
|
93
102
|
* @param disabled If true, the input is disabled
|
94
103
|
*/
|
95
104
|
const renderHiddenInput = (always, container, name, value, disabled) => {
|
96
|
-
if (
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
input
|
102
|
-
|
105
|
+
if (name !== undefined) {
|
106
|
+
if (always || hasShadowDom(container)) {
|
107
|
+
const inputs = container.querySelectorAll("input.ic-input");
|
108
|
+
const inputEls = Array.from(inputs);
|
109
|
+
const filtered = inputEls.filter((el) => container === el.parentElement);
|
110
|
+
let input = filtered[0];
|
111
|
+
if (input === null || input === undefined) {
|
112
|
+
input = container.ownerDocument.createElement("input");
|
113
|
+
input.type = "hidden";
|
114
|
+
input.classList.add("ic-input");
|
115
|
+
container.appendChild(input);
|
116
|
+
}
|
117
|
+
input.disabled = disabled;
|
118
|
+
input.name = name;
|
119
|
+
input.value = value || "";
|
103
120
|
}
|
104
|
-
input.disabled = disabled;
|
105
|
-
input.name = name;
|
106
|
-
input.value = value || "";
|
107
121
|
}
|
108
122
|
};
|
109
123
|
const removeHiddenInput = (container) => {
|
110
|
-
const
|
124
|
+
const inputs = container.querySelectorAll("input.ic-input");
|
125
|
+
const inputEls = Array.from(inputs);
|
126
|
+
const filtered = inputEls.filter((el) => container === el.parentElement);
|
127
|
+
const input = filtered[0];
|
111
128
|
input === null || input === void 0 ? void 0 : input.remove();
|
112
129
|
};
|
113
130
|
const hasShadowDom = (el) => {
|
@@ -136,7 +153,8 @@ const getInputDescribedByText = (inputId, helperText, validationText) => {
|
|
136
153
|
*/
|
137
154
|
const getThemeFromContext = (el, themeFromEvent = null) => {
|
138
155
|
var _a;
|
139
|
-
const
|
156
|
+
const parentElement = el.parentElement || el.getRootNode().host.parentElement;
|
157
|
+
const blockColorParent = parentElement.closest(IC_BLOCK_COLOR_COMPONENTS.join(","));
|
140
158
|
// If within a block color component
|
141
159
|
if (blockColorParent !== null) {
|
142
160
|
const parentTag = blockColorParent.tagName.toLowerCase();
|
@@ -258,22 +276,29 @@ const getCurrentDeviceSize = () => {
|
|
258
276
|
const getCssProperty = (cssVar) => {
|
259
277
|
return getComputedStyle(document.documentElement).getPropertyValue(cssVar);
|
260
278
|
};
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
279
|
+
/**
|
280
|
+
* Returns the brightness of the theme colour, calculated by using the theme RGB CSS values by:
|
281
|
+
* - Multiplying each RGB value by a set number: https://www.w3.org/TR/AERT/#color-contrast
|
282
|
+
* - Adding them together and dividing by 1000
|
283
|
+
* This is a similar calculation to its CSS counterpart: "--ic-theme-text"
|
284
|
+
* @returns number representing the brightness of the theme colour
|
285
|
+
*/
|
286
|
+
const getThemeColorBrightness = () => {
|
269
287
|
const themeRed = getCssProperty("--ic-theme-primary-r");
|
270
288
|
const themeGreen = getCssProperty("--ic-theme-primary-g");
|
271
289
|
const themeBlue = getCssProperty("--ic-theme-primary-b");
|
272
|
-
const
|
290
|
+
const themeColorBrightness = (parseInt(themeRed) * 299 +
|
273
291
|
parseInt(themeGreen) * 587 +
|
274
292
|
parseInt(themeBlue) * 114) /
|
275
|
-
1000
|
276
|
-
return
|
293
|
+
1000;
|
294
|
+
return themeColorBrightness;
|
295
|
+
};
|
296
|
+
/**
|
297
|
+
* Returns if dark or light foreground colors should be used for color contrast reasons
|
298
|
+
* @returns "dark" or "light"
|
299
|
+
*/
|
300
|
+
const getThemeForegroundColor = () => {
|
301
|
+
return getThemeColorBrightness() > DARK_MODE_THRESHOLD
|
277
302
|
? IcThemeForegroundEnum.Dark
|
278
303
|
: IcThemeForegroundEnum.Light;
|
279
304
|
};
|
@@ -371,7 +396,7 @@ const checkResizeObserver = (callbackFn) => {
|
|
371
396
|
const hex2dec = function (v) {
|
372
397
|
return parseInt(v, 16);
|
373
398
|
};
|
374
|
-
const
|
399
|
+
const hexToRgba = (hex) => {
|
375
400
|
let c;
|
376
401
|
if (hex.length === 4) {
|
377
402
|
c = hex.replace("#", "").split("");
|
@@ -379,6 +404,7 @@ const hexToRgb = (hex) => {
|
|
379
404
|
r: hex2dec(c[0] + c[0]),
|
380
405
|
g: hex2dec(c[1] + c[1]),
|
381
406
|
b: hex2dec(c[2] + c[2]),
|
407
|
+
a: 1,
|
382
408
|
};
|
383
409
|
}
|
384
410
|
else {
|
@@ -386,19 +412,35 @@ const hexToRgb = (hex) => {
|
|
386
412
|
r: hex2dec(hex.slice(1, 3)),
|
387
413
|
g: hex2dec(hex.slice(3, 5)),
|
388
414
|
b: hex2dec(hex.slice(5)),
|
415
|
+
a: 1,
|
389
416
|
};
|
390
417
|
}
|
391
418
|
};
|
392
|
-
const
|
393
|
-
const
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
419
|
+
const rgbaStrToObj = (rgbaStr) => {
|
420
|
+
const fourthChar = rgbaStr.slice(3, 4);
|
421
|
+
let colorRGBA;
|
422
|
+
if (fourthChar.toLowerCase() === "a") {
|
423
|
+
colorRGBA = { r: null, g: null, b: null, a: null };
|
424
|
+
const rgba = rgbaStr
|
425
|
+
.substring(5, rgbaStr.length - 1)
|
426
|
+
.replace(/ /g, "")
|
427
|
+
.split(",");
|
428
|
+
colorRGBA.r = Number(rgba[0]);
|
429
|
+
colorRGBA.g = Number(rgba[1]);
|
430
|
+
colorRGBA.b = Number(rgba[2]);
|
431
|
+
colorRGBA.a = Number(rgba[3]);
|
432
|
+
}
|
433
|
+
else {
|
434
|
+
colorRGBA = { r: null, g: null, b: null, a: 1 };
|
435
|
+
const rgb = rgbaStr
|
436
|
+
.substring(4, rgbaStr.length - 1)
|
437
|
+
.replace(/ /g, "")
|
438
|
+
.split(",");
|
439
|
+
colorRGBA.r = Number(rgb[0]);
|
440
|
+
colorRGBA.g = Number(rgb[1]);
|
441
|
+
colorRGBA.b = Number(rgb[2]);
|
442
|
+
}
|
443
|
+
return colorRGBA;
|
402
444
|
};
|
403
445
|
const elementOverflowsX = (element) => {
|
404
446
|
return element.scrollWidth > element.clientWidth;
|
@@ -434,6 +476,6 @@ const removeFormResetListener = (el, callbackFn) => {
|
|
434
476
|
}
|
435
477
|
};
|
436
478
|
|
437
|
-
export {
|
479
|
+
export { elementOverflowsX as A, getThemeColorBrightness as B, BLACK_MIN_COLOR_BRIGHTNESS as C, DEVICE_SIZES as D, hexToRgba as E, rgbaStrToObj as F, getSlot as G, getInputHelperTextID as H, IC_DEVICE_SIZES as I, getInputValidationTextID as J, isEmptyString as K, WHITE_MAX_COLOR_BRIGHTNESS as W, onComponentRequiredPropUndefined as a, getThemeFromContext as b, checkResizeObserver as c, addFormResetListener as d, renderHiddenInput as e, removeHiddenInput as f, getCurrentDeviceSize as g, getInputDescribedByText as h, isSlotUsed as i, hasValidationStatus as j, getThemeForegroundColor as k, hasClassificationBanner as l, inheritAttributes as m, IC_INHERITED_ARIA as n, onComponentPropUndefinedChange as o, getNavItemParentDetails as p, getParentElementType as q, removeFormResetListener as r, slotHasContent as s, getSlotContent as t, handleHiddenFormButtonClick as u, getFilteredMenuOptions as v, debounceEvent as w, getLabelFromValue as x, isMobileOrTablet as y, getCssProperty as z };
|
438
480
|
|
439
481
|
//# sourceMappingURL=helpers.js.map
|