@ukic/web-components 3.25.0 → 3.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/OpenInNew.js +5 -0
- package/components/OpenInNew.js.map +1 -0
- package/components/check-icon.js +8 -0
- package/components/check-icon.js.map +1 -0
- package/components/chevron-icon.js +8 -0
- package/components/chevron-icon.js.map +1 -0
- package/components/close-icon.js +10 -0
- package/components/close-icon.js.map +1 -0
- package/components/constants.js +184 -0
- package/components/constants.js.map +1 -0
- package/components/custom-elements.d.ts +2 -0
- package/components/helpers.js +547 -0
- package/components/helpers.js.map +1 -0
- package/components/ic-accordion-group.d.ts +11 -0
- package/components/ic-accordion-group.js +191 -0
- package/components/ic-accordion-group.js.map +1 -0
- package/components/ic-accordion.d.ts +11 -0
- package/components/ic-accordion.js +188 -0
- package/components/ic-accordion.js.map +1 -0
- package/components/ic-action-chip.d.ts +11 -0
- package/components/ic-action-chip.js +164 -0
- package/components/ic-action-chip.js.map +1 -0
- package/components/ic-alert.d.ts +11 -0
- package/components/ic-alert.js +193 -0
- package/components/ic-alert.js.map +1 -0
- package/components/ic-back-to-top.d.ts +11 -0
- package/components/ic-back-to-top.js +216 -0
- package/components/ic-back-to-top.js.map +1 -0
- package/components/ic-badge.d.ts +11 -0
- package/components/ic-badge.js +222 -0
- package/components/ic-badge.js.map +1 -0
- package/components/ic-breadcrumb-group.d.ts +11 -0
- package/components/ic-breadcrumb-group.js +278 -0
- package/components/ic-breadcrumb-group.js.map +1 -0
- package/components/ic-breadcrumb.d.ts +11 -0
- package/components/ic-breadcrumb.js +8 -0
- package/components/ic-breadcrumb.js.map +1 -0
- package/components/ic-breadcrumb2.js +145 -0
- package/components/ic-breadcrumb2.js.map +1 -0
- package/components/ic-button.d.ts +11 -0
- package/components/ic-button.js +8 -0
- package/components/ic-button.js.map +1 -0
- package/components/ic-button2.js +509 -0
- package/components/ic-button2.js.map +1 -0
- package/components/ic-card-horizontal.d.ts +11 -0
- package/components/ic-card-horizontal.js +214 -0
- package/components/ic-card-horizontal.js.map +1 -0
- package/components/ic-card-vertical.d.ts +11 -0
- package/components/ic-card-vertical.js +219 -0
- package/components/ic-card-vertical.js.map +1 -0
- package/components/ic-checkbox-group.d.ts +11 -0
- package/components/ic-checkbox-group.js +198 -0
- package/components/ic-checkbox-group.js.map +1 -0
- package/components/ic-checkbox.d.ts +11 -0
- package/components/ic-checkbox.js +202 -0
- package/components/ic-checkbox.js.map +1 -0
- package/components/ic-chip.d.ts +11 -0
- package/components/ic-chip.js +183 -0
- package/components/ic-chip.js.map +1 -0
- package/components/ic-classification-banner.d.ts +11 -0
- package/components/ic-classification-banner.js +102 -0
- package/components/ic-classification-banner.js.map +1 -0
- package/components/ic-data-list.d.ts +11 -0
- package/components/ic-data-list.js +63 -0
- package/components/ic-data-list.js.map +1 -0
- package/components/ic-data-row.d.ts +11 -0
- package/components/ic-data-row.js +115 -0
- package/components/ic-data-row.js.map +1 -0
- package/components/ic-dialog.d.ts +11 -0
- package/components/ic-dialog.js +366 -0
- package/components/ic-dialog.js.map +1 -0
- package/components/ic-divider.d.ts +11 -0
- package/components/ic-divider.js +8 -0
- package/components/ic-divider.js.map +1 -0
- package/components/ic-divider2.js +148 -0
- package/components/ic-divider2.js.map +1 -0
- package/components/ic-empty-state.d.ts +11 -0
- package/components/ic-empty-state.js +82 -0
- package/components/ic-empty-state.js.map +1 -0
- package/components/ic-footer-link-group.d.ts +11 -0
- package/components/ic-footer-link-group.js +101 -0
- package/components/ic-footer-link-group.js.map +1 -0
- package/components/ic-footer-link.d.ts +11 -0
- package/components/ic-footer-link.js +95 -0
- package/components/ic-footer-link.js.map +1 -0
- package/components/ic-footer.d.ts +11 -0
- package/components/ic-footer.js +156 -0
- package/components/ic-footer.js.map +1 -0
- package/components/ic-hero.d.ts +11 -0
- package/components/ic-hero.js +145 -0
- package/components/ic-hero.js.map +1 -0
- package/components/ic-horizontal-scroll.d.ts +11 -0
- package/components/ic-horizontal-scroll.js +8 -0
- package/components/ic-horizontal-scroll.js.map +1 -0
- package/components/ic-horizontal-scroll2.js +240 -0
- package/components/ic-horizontal-scroll2.js.map +1 -0
- package/components/ic-input-component-container.d.ts +11 -0
- package/components/ic-input-component-container.js +8 -0
- package/components/ic-input-component-container.js.map +1 -0
- package/components/ic-input-component-container2.js +95 -0
- package/components/ic-input-component-container2.js.map +1 -0
- package/components/ic-input-container.d.ts +11 -0
- package/components/ic-input-container.js +8 -0
- package/components/ic-input-container.js.map +1 -0
- package/components/ic-input-container2.js +47 -0
- package/components/ic-input-container2.js.map +1 -0
- package/components/ic-input-label.d.ts +11 -0
- package/components/ic-input-label.js +8 -0
- package/components/ic-input-label.js.map +1 -0
- package/components/ic-input-label2.js +121 -0
- package/components/ic-input-label2.js.map +1 -0
- package/components/ic-input-validation.d.ts +11 -0
- package/components/ic-input-validation.js +8 -0
- package/components/ic-input-validation.js.map +1 -0
- package/components/ic-input-validation2.js +90 -0
- package/components/ic-input-validation2.js.map +1 -0
- package/components/ic-layout-grid-item.d.ts +11 -0
- package/components/ic-layout-grid-item.js +95 -0
- package/components/ic-layout-grid-item.js.map +1 -0
- package/components/ic-layout-grid.d.ts +11 -0
- package/components/ic-layout-grid.js +188 -0
- package/components/ic-layout-grid.js.map +1 -0
- package/components/ic-link.d.ts +11 -0
- package/components/ic-link.js +8 -0
- package/components/ic-link.js.map +1 -0
- package/components/ic-link2.js +135 -0
- package/components/ic-link2.js.map +1 -0
- package/components/ic-loading-indicator.d.ts +11 -0
- package/components/ic-loading-indicator.js +8 -0
- package/components/ic-loading-indicator.js.map +1 -0
- package/components/ic-loading-indicator2.js +278 -0
- package/components/ic-loading-indicator2.js.map +1 -0
- package/components/ic-menu-group.d.ts +11 -0
- package/components/ic-menu-group.js +47 -0
- package/components/ic-menu-group.js.map +1 -0
- package/components/ic-menu-item.d.ts +11 -0
- package/components/ic-menu-item.js +8 -0
- package/components/ic-menu-item.js.map +1 -0
- package/components/ic-menu-item2.js +171 -0
- package/components/ic-menu-item2.js.map +1 -0
- package/components/ic-menu.d.ts +11 -0
- package/components/ic-menu.js +8 -0
- package/components/ic-menu.js.map +1 -0
- package/components/ic-menu2.js +2590 -0
- package/components/ic-menu2.js.map +1 -0
- package/components/ic-navigation-button.d.ts +11 -0
- package/components/ic-navigation-button.js +175 -0
- package/components/ic-navigation-button.js.map +1 -0
- package/components/ic-navigation-group.d.ts +11 -0
- package/components/ic-navigation-group.js +326 -0
- package/components/ic-navigation-group.js.map +1 -0
- package/components/ic-navigation-item.d.ts +11 -0
- package/components/ic-navigation-item.js +294 -0
- package/components/ic-navigation-item.js.map +1 -0
- package/components/ic-navigation-menu.d.ts +11 -0
- package/components/ic-navigation-menu.js +8 -0
- package/components/ic-navigation-menu.js.map +1 -0
- package/components/ic-navigation-menu2.js +188 -0
- package/components/ic-navigation-menu2.js.map +1 -0
- package/components/ic-page-header.d.ts +11 -0
- package/components/ic-page-header.js +196 -0
- package/components/ic-page-header.js.map +1 -0
- package/components/ic-pagination-bar.d.ts +11 -0
- package/components/ic-pagination-bar.js +523 -0
- package/components/ic-pagination-bar.js.map +1 -0
- package/components/ic-pagination-item.d.ts +11 -0
- package/components/ic-pagination-item.js +8 -0
- package/components/ic-pagination-item.js.map +1 -0
- package/components/ic-pagination-item2.js +107 -0
- package/components/ic-pagination-item2.js.map +1 -0
- package/components/ic-pagination.d.ts +11 -0
- package/components/ic-pagination.js +8 -0
- package/components/ic-pagination.js.map +1 -0
- package/components/ic-pagination2.js +379 -0
- package/components/ic-pagination2.js.map +1 -0
- package/components/ic-popover-menu.d.ts +11 -0
- package/components/ic-popover-menu.js +369 -0
- package/components/ic-popover-menu.js.map +1 -0
- package/components/ic-radio-group.d.ts +11 -0
- package/components/ic-radio-group.js +317 -0
- package/components/ic-radio-group.js.map +1 -0
- package/components/ic-radio-option.d.ts +11 -0
- package/components/ic-radio-option.js +211 -0
- package/components/ic-radio-option.js.map +1 -0
- package/components/ic-search-bar.d.ts +11 -0
- package/components/ic-search-bar.js +719 -0
- package/components/ic-search-bar.js.map +1 -0
- package/components/ic-section-container.d.ts +11 -0
- package/components/ic-section-container.js +8 -0
- package/components/ic-section-container.js.map +1 -0
- package/components/ic-section-container2.js +50 -0
- package/components/ic-section-container2.js.map +1 -0
- package/components/ic-select.d.ts +11 -0
- package/components/ic-select.js +8 -0
- package/components/ic-select.js.map +1 -0
- package/components/ic-select2.js +806 -0
- package/components/ic-select2.js.map +1 -0
- package/components/ic-side-navigation.d.ts +11 -0
- package/components/ic-side-navigation.js +568 -0
- package/components/ic-side-navigation.js.map +1 -0
- package/components/ic-skeleton.d.ts +11 -0
- package/components/ic-skeleton.js +81 -0
- package/components/ic-skeleton.js.map +1 -0
- package/components/ic-skip-link.d.ts +11 -0
- package/components/ic-skip-link.js +91 -0
- package/components/ic-skip-link.js.map +1 -0
- package/components/ic-status-tag.d.ts +11 -0
- package/components/ic-status-tag.js +85 -0
- package/components/ic-status-tag.js.map +1 -0
- package/components/ic-step.d.ts +11 -0
- package/components/ic-step.js +200 -0
- package/components/ic-step.js.map +1 -0
- package/components/ic-stepper.d.ts +11 -0
- package/components/ic-stepper.js +340 -0
- package/components/ic-stepper.js.map +1 -0
- package/components/ic-switch.d.ts +11 -0
- package/components/ic-switch.js +164 -0
- package/components/ic-switch.js.map +1 -0
- package/components/ic-tab-context.d.ts +11 -0
- package/components/ic-tab-context.js +275 -0
- package/components/ic-tab-context.js.map +1 -0
- package/components/ic-tab-group.d.ts +11 -0
- package/components/ic-tab-group.js +89 -0
- package/components/ic-tab-group.js.map +1 -0
- package/components/ic-tab-panel.d.ts +11 -0
- package/components/ic-tab-panel.js +63 -0
- package/components/ic-tab-panel.js.map +1 -0
- package/components/ic-tab.d.ts +11 -0
- package/components/ic-tab.js +143 -0
- package/components/ic-tab.js.map +1 -0
- package/components/ic-text-field.d.ts +11 -0
- package/components/ic-text-field.js +8 -0
- package/components/ic-text-field.js.map +1 -0
- package/components/ic-text-field2.js +532 -0
- package/components/ic-text-field2.js.map +1 -0
- package/components/ic-theme.d.ts +11 -0
- package/components/ic-theme.js +105 -0
- package/components/ic-theme.js.map +1 -0
- package/components/ic-toast-region.d.ts +11 -0
- package/components/ic-toast-region.js +76 -0
- package/components/ic-toast-region.js.map +1 -0
- package/components/ic-toast.d.ts +11 -0
- package/components/ic-toast.js +295 -0
- package/components/ic-toast.js.map +1 -0
- package/components/ic-toggle-button-group.d.ts +11 -0
- package/components/ic-toggle-button-group.js +323 -0
- package/components/ic-toggle-button-group.js.map +1 -0
- package/components/ic-toggle-button.d.ts +11 -0
- package/components/ic-toggle-button.js +235 -0
- package/components/ic-toggle-button.js.map +1 -0
- package/components/ic-tooltip.d.ts +11 -0
- package/components/ic-tooltip.js +8 -0
- package/components/ic-tooltip.js.map +1 -0
- package/components/ic-tooltip2.js +2078 -0
- package/components/ic-tooltip2.js.map +1 -0
- package/components/ic-top-navigation.d.ts +11 -0
- package/components/ic-top-navigation.js +320 -0
- package/components/ic-top-navigation.js.map +1 -0
- package/components/ic-typography.d.ts +11 -0
- package/components/ic-typography.js +8 -0
- package/components/ic-typography.js.map +1 -0
- package/components/ic-typography2.js +228 -0
- package/components/ic-typography2.js.map +1 -0
- package/components/index.d.ts +33 -0
- package/components/index.js +4 -0
- package/components/index.js.map +1 -0
- package/components/package.json +9 -0
- package/dist/cjs/core.cjs.js +1 -1
- package/dist/cjs/ic-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-input-component-container_3.cjs.entry.js +63 -37
- package/dist/cjs/ic-input-component-container_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-pagination_3.cjs.entry.js +17 -17
- package/dist/cjs/ic-pagination_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-section-container.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-top-navigation.cjs.entry.js +12 -8
- package/dist/cjs/ic-top-navigation.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ic-menu/ic-menu.css +19 -0
- package/dist/collection/components/ic-menu/ic-menu.js +62 -36
- package/dist/collection/components/ic-menu/ic-menu.js.map +1 -1
- package/dist/collection/components/ic-menu/ic-menu.types.js.map +1 -1
- package/dist/collection/components/ic-select/ic-select.js +17 -17
- package/dist/collection/components/ic-select/ic-select.js.map +1 -1
- package/dist/collection/components/ic-select/ic-select_(single).stories.js +54 -0
- package/dist/collection/components/ic-top-navigation/ic-top-navigation.js +33 -9
- package/dist/collection/components/ic-top-navigation/ic-top-navigation.js.map +1 -1
- package/dist/collection/components/ic-top-navigation/ic-top-navigation.stories.js +26 -0
- package/dist/components/ic-menu2.js +63 -37
- package/dist/components/ic-menu2.js.map +1 -1
- package/dist/components/ic-page-header.js.map +1 -1
- package/dist/components/ic-popover-menu.js.map +1 -1
- package/dist/components/ic-radio-group.js.map +1 -1
- package/dist/components/ic-radio-option.js.map +1 -1
- package/dist/components/ic-select2.js +17 -17
- package/dist/components/ic-select2.js.map +1 -1
- package/dist/components/ic-top-navigation.js +13 -8
- package/dist/components/ic-top-navigation.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-46e5a58b.entry.js → p-12474095.entry.js} +2 -2
- package/dist/core/p-12474095.entry.js.map +1 -0
- package/dist/core/p-98dee727.entry.js.map +1 -1
- package/dist/core/p-d1220d2a.entry.js.map +1 -1
- package/dist/core/p-e0b66371.entry.js +2 -0
- package/dist/core/p-e0b66371.entry.js.map +1 -0
- package/dist/core/{p-171a19bf.entry.js → p-fdc4376e.entry.js} +2 -2
- package/dist/core/p-fdc4376e.entry.js.map +1 -0
- package/dist/esm/core.js +1 -1
- package/dist/esm/ic-button_3.entry.js.map +1 -1
- package/dist/esm/ic-input-component-container_3.entry.js +63 -37
- package/dist/esm/ic-input-component-container_3.entry.js.map +1 -1
- package/dist/esm/ic-pagination_3.entry.js +17 -17
- package/dist/esm/ic-pagination_3.entry.js.map +1 -1
- package/dist/esm/ic-section-container.entry.js.map +1 -1
- package/dist/esm/ic-top-navigation.entry.js +12 -8
- package/dist/esm/ic-top-navigation.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/ic-menu/ic-menu.types.d.ts +1 -0
- package/dist/types/components/ic-top-navigation/ic-top-navigation.d.ts +4 -1
- package/dist/types/components.d.ts +10 -2
- package/hydrate/index.js +93 -62
- package/hydrate/index.mjs +93 -62
- package/package.json +4 -2
- package/vscode-data.json +5 -1
- package/dist/core/p-171a19bf.entry.js.map +0 -1
- package/dist/core/p-343670b4.entry.js +0 -2
- package/dist/core/p-343670b4.entry.js.map +0 -1
- package/dist/core/p-46e5a58b.entry.js.map +0 -1
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
import { forceUpdate } from '@stencil/core/internal/client';
|
|
2
|
+
import { b as IC_BLOCK_COLOR_COMPONENTS, d as IC_BLOCK_COLOR_EXCEPTIONS, c as IC_FIXED_COLOR_COMPONENTS, l as IC_TEXT_FIELD, k as IC_TAB_CONTEXT, j as IC_SEARCH_BAR, i as IC_CHECKBOX, h as IC_ACCORDION_GROUP, g as IC_ACCORDION } from './constants.js';
|
|
3
|
+
|
|
4
|
+
var IcInformationStatus;
|
|
5
|
+
(function (IcInformationStatus) {
|
|
6
|
+
IcInformationStatus["Warning"] = "warning";
|
|
7
|
+
IcInformationStatus["Error"] = "error";
|
|
8
|
+
IcInformationStatus["Success"] = "success";
|
|
9
|
+
})(IcInformationStatus || (IcInformationStatus = {}));
|
|
10
|
+
var IcBrandForegroundEnum;
|
|
11
|
+
(function (IcBrandForegroundEnum) {
|
|
12
|
+
IcBrandForegroundEnum["Default"] = "default";
|
|
13
|
+
IcBrandForegroundEnum["Dark"] = "dark";
|
|
14
|
+
IcBrandForegroundEnum["Light"] = "light";
|
|
15
|
+
})(IcBrandForegroundEnum || (IcBrandForegroundEnum = {}));
|
|
16
|
+
|
|
17
|
+
const DARK_MODE_THRESHOLD = 133.3505;
|
|
18
|
+
const icInput = "ic-input";
|
|
19
|
+
/**
|
|
20
|
+
* Used to inherit global attributes set on the host. Called in componentWillLoad and assigned
|
|
21
|
+
* to a variable that is later used in the render function.
|
|
22
|
+
*
|
|
23
|
+
* This does not need to be reactive as changing attributes on the host element
|
|
24
|
+
* does not trigger a re-render.
|
|
25
|
+
*/
|
|
26
|
+
const inheritAttributes = (element, attributes = []) => {
|
|
27
|
+
const attributeObject = {};
|
|
28
|
+
attributes.forEach((attr) => {
|
|
29
|
+
const value = element.getAttribute(attr);
|
|
30
|
+
if (value !== null) {
|
|
31
|
+
attributeObject[attr] = value;
|
|
32
|
+
element.removeAttribute(attr);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return attributeObject;
|
|
36
|
+
};
|
|
37
|
+
const debounceEvent = (event, wait) => {
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
const original = event._original || event;
|
|
40
|
+
return {
|
|
41
|
+
_original: event,
|
|
42
|
+
emit: debounce(original.emit.bind(original), wait),
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const debounce = (func, wait = 0) => {
|
|
46
|
+
let timer;
|
|
47
|
+
return (...args) => {
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
timer = setTimeout(func, wait, ...args);
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* This method is used to add a hidden input to a host element that contains
|
|
54
|
+
* a Shadow DOM. It does not add the input inside of the Shadow root which
|
|
55
|
+
* allows it to be picked up inside of forms. It should contain the same
|
|
56
|
+
* values as the host element.
|
|
57
|
+
*
|
|
58
|
+
* @param container The element where the input will be added
|
|
59
|
+
* @param value The value of the input
|
|
60
|
+
* @param name The name of the input
|
|
61
|
+
* @param disabled If true, the input is disabled
|
|
62
|
+
* @param always Add a hidden input even if the container does not use Shadow
|
|
63
|
+
*/
|
|
64
|
+
const renderHiddenInput = (container, value, name, disabled = false, always = true) => {
|
|
65
|
+
if (name && (always || hasShadowDom(container))) {
|
|
66
|
+
let input = getHiddenInputElement(container);
|
|
67
|
+
if (!input) {
|
|
68
|
+
input = container.ownerDocument.createElement("input");
|
|
69
|
+
input.type = "hidden";
|
|
70
|
+
input.classList.add(icInput);
|
|
71
|
+
container.appendChild(input);
|
|
72
|
+
}
|
|
73
|
+
input.disabled = disabled;
|
|
74
|
+
input.name = name;
|
|
75
|
+
input.value = value instanceof Date ? value.toISOString() : value || "";
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const getHiddenInputElement = (container) => Array.from(container.querySelectorAll(`input.${icInput}`)).filter((el) => container === el.parentElement)[0];
|
|
79
|
+
/**
|
|
80
|
+
* This method is used to add a hidden file input to a host element that contains
|
|
81
|
+
* a Shadow DOM. It does not add the input inside of the Shadow root which
|
|
82
|
+
* allows it to be picked up inside of forms. It should contain the same
|
|
83
|
+
* values as the host element.
|
|
84
|
+
*
|
|
85
|
+
* @param event: The event that is emitted once a file is selected.
|
|
86
|
+
* @param container The element where the input will be added
|
|
87
|
+
* @param multiple If true, multiple files can be selected
|
|
88
|
+
* @param disabled If true, the input is disabled
|
|
89
|
+
* @param accept A string of the accepted files
|
|
90
|
+
* @param name The name of the input
|
|
91
|
+
* @param value The value of the input
|
|
92
|
+
*/
|
|
93
|
+
const renderFileHiddenInput = (event, container, multiple, disabled, accept, name, value) => {
|
|
94
|
+
if (name !== undefined && hasShadowDom(container)) {
|
|
95
|
+
let input = getHiddenInputElement(container);
|
|
96
|
+
if (input === null || input === undefined) {
|
|
97
|
+
input = container.ownerDocument.createElement("input");
|
|
98
|
+
input.classList.add(icInput);
|
|
99
|
+
container.appendChild(input);
|
|
100
|
+
}
|
|
101
|
+
input.type = "file";
|
|
102
|
+
input.hidden = true;
|
|
103
|
+
input.multiple = multiple;
|
|
104
|
+
input.name = name;
|
|
105
|
+
input.disabled = disabled;
|
|
106
|
+
if (value)
|
|
107
|
+
input.files = value;
|
|
108
|
+
if (accept)
|
|
109
|
+
input.accept = accept;
|
|
110
|
+
input.onchange = () => {
|
|
111
|
+
event.emit(input.files);
|
|
112
|
+
};
|
|
113
|
+
input.click();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const removeHiddenInput = (container) => {
|
|
117
|
+
var _a;
|
|
118
|
+
(_a = getHiddenInputElement(container)) === null || _a === void 0 ? void 0 : _a.remove();
|
|
119
|
+
};
|
|
120
|
+
const hasShadowDom = (el) => !!el && !!el.shadowRoot && !!el.attachShadow;
|
|
121
|
+
const getInputHelperTextID = (id) => id + "-helper-text";
|
|
122
|
+
const getInputValidationTextID = (id) => id + "-validation-text";
|
|
123
|
+
const getInputDescribedByText = (el, inputId, helperText, validationText) => `${isSlotUsed(el, "helper-text") || helperText
|
|
124
|
+
? getInputHelperTextID(inputId)
|
|
125
|
+
: ""} ${validationText ? getInputValidationTextID(inputId) : ""}`.trim();
|
|
126
|
+
/**
|
|
127
|
+
* This method helps to understand the context in which a component exists,
|
|
128
|
+
* to assist with choosing appropriate foreground colours to use. For example,
|
|
129
|
+
* this method will help you use the 'white' version of a button if it's within
|
|
130
|
+
* a block colour element using white foreground text.
|
|
131
|
+
*
|
|
132
|
+
* This only works for components/elements passed via <slot> and not if they
|
|
133
|
+
* are part of an IC component.
|
|
134
|
+
*
|
|
135
|
+
* ""
|
|
136
|
+
* @returns IcBrandForeground depending on the context
|
|
137
|
+
*/
|
|
138
|
+
const getBrandFromContext = (el, brandFromEvent = null) => {
|
|
139
|
+
var _a;
|
|
140
|
+
const parentElement = el.parentElement || el.getRootNode().host.parentElement;
|
|
141
|
+
const blockColorParent = parentElement === null || parentElement === void 0 ? void 0 : parentElement.closest(IC_BLOCK_COLOR_COMPONENTS);
|
|
142
|
+
if (!blockColorParent)
|
|
143
|
+
return IcBrandForegroundEnum.Default;
|
|
144
|
+
const parentTag = blockColorParent.tagName.toLowerCase();
|
|
145
|
+
if ((_a = IC_BLOCK_COLOR_EXCEPTIONS[parentTag]) === null || _a === void 0 ? void 0 : _a.includes(el.tagName.toLowerCase())) {
|
|
146
|
+
return IcBrandForegroundEnum.Default;
|
|
147
|
+
}
|
|
148
|
+
else if (brandFromEvent !== null &&
|
|
149
|
+
!IC_FIXED_COLOR_COMPONENTS.includes(parentTag)) {
|
|
150
|
+
return brandFromEvent;
|
|
151
|
+
}
|
|
152
|
+
else if (blockColorParent.classList.contains(`${parentTag}-${IcBrandForegroundEnum.Dark}`) ||
|
|
153
|
+
blockColorParent.classList.contains(IcBrandForegroundEnum.Dark)) {
|
|
154
|
+
return IcBrandForegroundEnum.Dark;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
return IcBrandForegroundEnum.Light;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Checks if the current device is a mobile or tablet device.
|
|
162
|
+
* @returns {boolean} Returns true if the device is a mobile or tablet device, otherwise returns false.
|
|
163
|
+
*/
|
|
164
|
+
const isMobileOrTablet = () => "maxTouchPoints" in navigator && "userAgent" in navigator
|
|
165
|
+
? navigator.maxTouchPoints > 0 &&
|
|
166
|
+
/iPad|iPhone|iPod|Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
|
167
|
+
: false;
|
|
168
|
+
/**
|
|
169
|
+
* Will create a button within the lightDOM which interacts with the form.
|
|
170
|
+
* This is required as buttons within the shadowDOM will not invoke a submit or reset
|
|
171
|
+
*
|
|
172
|
+
* @param form - form element to associate button with
|
|
173
|
+
* @param button - shadowDOM button
|
|
174
|
+
*/
|
|
175
|
+
const handleHiddenFormButtonClick = (form, button) => {
|
|
176
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
177
|
+
const hiddenFormButtonId = button.type === "submit" || button.type === "reset"
|
|
178
|
+
? `hidden-form-${button.type}-button`
|
|
179
|
+
: "hidden-form-button";
|
|
180
|
+
const hiddenFormButton = (_a = document.querySelector(`#${hiddenFormButtonId}`)) !== null && _a !== void 0 ? _a : document.createElement("button");
|
|
181
|
+
hiddenFormButton.setAttribute("type", (_b = button.type) !== null && _b !== void 0 ? _b : "button");
|
|
182
|
+
hiddenFormButton.id = hiddenFormButtonId;
|
|
183
|
+
hiddenFormButton.style.display = "none";
|
|
184
|
+
hiddenFormButton.formAction = (_c = button.formaction) !== null && _c !== void 0 ? _c : "";
|
|
185
|
+
hiddenFormButton.formEnctype = (_d = button.formenctype) !== null && _d !== void 0 ? _d : "";
|
|
186
|
+
hiddenFormButton.formMethod = (_e = button.formmethod) !== null && _e !== void 0 ? _e : "";
|
|
187
|
+
hiddenFormButton.formNoValidate = (_f = button.formnovalidate) !== null && _f !== void 0 ? _f : false;
|
|
188
|
+
hiddenFormButton.formTarget = (_g = button.formtarget) !== null && _g !== void 0 ? _g : "";
|
|
189
|
+
form === null || form === void 0 ? void 0 : form.appendChild(hiddenFormButton);
|
|
190
|
+
hiddenFormButton.click();
|
|
191
|
+
};
|
|
192
|
+
const isEmptyString = (value) => !value || value.trim().length === 0;
|
|
193
|
+
// A helper function that checks if a prop has been defined
|
|
194
|
+
const isPropDefined = (prop) => prop !== undefined ? prop : undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Extracts the label using the value from an object. Requires the object to have a label and value property.
|
|
197
|
+
* @param value - value from object
|
|
198
|
+
* @param options - list of menu items
|
|
199
|
+
* @returns - label corresponding to value
|
|
200
|
+
*/
|
|
201
|
+
const getLabelFromValue = (value, options, valueField = "value", labelField = "label") => {
|
|
202
|
+
const ungroupedOptions = [];
|
|
203
|
+
if (options.length > 0 && options.map) {
|
|
204
|
+
options.map((option) => {
|
|
205
|
+
if (option.children) {
|
|
206
|
+
option.children.map((option) => ungroupedOptions.push(option));
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
ungroupedOptions.push(option);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
const matchingValue = ungroupedOptions.find((option) => option[valueField] === value);
|
|
213
|
+
if (matchingValue !== undefined)
|
|
214
|
+
return matchingValue[labelField];
|
|
215
|
+
}
|
|
216
|
+
return undefined;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Filters the options based on the search string.
|
|
220
|
+
* @param options - array of options
|
|
221
|
+
* @param searchString - string used to filter the options
|
|
222
|
+
* @returns filtered array of options
|
|
223
|
+
*/
|
|
224
|
+
const getFilteredMenuOptions = (options, searchString, labelField = "label") => options.filter((option) => {
|
|
225
|
+
const label = option[labelField].toLowerCase();
|
|
226
|
+
const lowerSearchString = searchString.toLowerCase();
|
|
227
|
+
return label.includes(lowerSearchString);
|
|
228
|
+
});
|
|
229
|
+
/**
|
|
230
|
+
* Gets count of options where only group title "parent" options have been removed.
|
|
231
|
+
* Disabled options are included in the count.
|
|
232
|
+
* @param options - array of options
|
|
233
|
+
* @returns number of options not including group titles
|
|
234
|
+
*/
|
|
235
|
+
const getOptionsWithoutGroupTitlesCount = (options) => {
|
|
236
|
+
const optionsWithoutGroupTitles = [];
|
|
237
|
+
if (options.length > 0 && options.map) {
|
|
238
|
+
options.map((option) => {
|
|
239
|
+
if (option.children) {
|
|
240
|
+
option.children.map((option) => optionsWithoutGroupTitles.push(option));
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
optionsWithoutGroupTitles.push(option);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return optionsWithoutGroupTitles.length;
|
|
248
|
+
};
|
|
249
|
+
const deviceSizeMatches = (size) => window.matchMedia(`(max-width: ${size}px)`).matches;
|
|
250
|
+
const getCurrentDeviceSize = () => {
|
|
251
|
+
if (deviceSizeMatches(DEVICE_SIZES.S)) {
|
|
252
|
+
return DEVICE_SIZES.S;
|
|
253
|
+
}
|
|
254
|
+
if (deviceSizeMatches(DEVICE_SIZES.M)) {
|
|
255
|
+
return DEVICE_SIZES.M;
|
|
256
|
+
}
|
|
257
|
+
if (deviceSizeMatches(DEVICE_SIZES.L)) {
|
|
258
|
+
return DEVICE_SIZES.L;
|
|
259
|
+
}
|
|
260
|
+
if (deviceSizeMatches(DEVICE_SIZES.XL)) {
|
|
261
|
+
return DEVICE_SIZES.XL;
|
|
262
|
+
}
|
|
263
|
+
//fallback needed as all of above get initialised to 0 in jest tests
|
|
264
|
+
return DEVICE_SIZES.UNDEFINED;
|
|
265
|
+
};
|
|
266
|
+
const getCssProperty = (cssVar) => getComputedStyle(document.documentElement).getPropertyValue(cssVar);
|
|
267
|
+
/**
|
|
268
|
+
* Returns the brightness of the theme colour, calculated by using the theme RGB CSS values by:
|
|
269
|
+
* - Multiplying each RGB value by a set number: https://www.w3.org/TR/AERT/#color-contrast
|
|
270
|
+
* - Adding them together and dividing by 1000
|
|
271
|
+
* This is a similar calculation to its CSS counterpart: "--ic-brand-text-color"
|
|
272
|
+
* @returns number representing the brightness of the theme colour
|
|
273
|
+
*/
|
|
274
|
+
const getBrandColorBrightness = () => (parseInt(getCssProperty("--ic-brand-color-primary-r")) * 299 +
|
|
275
|
+
parseInt(getCssProperty("--ic-brand-color-primary-g")) * 587 +
|
|
276
|
+
parseInt(getCssProperty("--ic-brand-color-primary-b")) * 114) /
|
|
277
|
+
1000;
|
|
278
|
+
/**
|
|
279
|
+
* Returns if dark or light foreground colors should be used for color contrast reasons
|
|
280
|
+
* @returns "dark" or "light"
|
|
281
|
+
* @param brightness - Optional custom brightness value. Defaults to `getBrandColorBrightness`
|
|
282
|
+
*/
|
|
283
|
+
const getBrandForegroundAppearance = (brightness = getBrandColorBrightness()) => brightness > DARK_MODE_THRESHOLD
|
|
284
|
+
? IcBrandForegroundEnum.Dark
|
|
285
|
+
: IcBrandForegroundEnum.Light;
|
|
286
|
+
const getSlot = (element, name) => (element === null || element === void 0 ? void 0 : element.querySelector(`[slot="${name}"]`)) || null;
|
|
287
|
+
const slotHasContent = (element, name) => getSlot(element, name) !== null;
|
|
288
|
+
const getSlotContent = (element, name) => {
|
|
289
|
+
const slot = getSlot(element, name);
|
|
290
|
+
return slot ? getSlotElements(slot) : null;
|
|
291
|
+
};
|
|
292
|
+
const getSlotElements = (slot) => {
|
|
293
|
+
const slotContent = slot.firstElementChild;
|
|
294
|
+
if (slotContent === null)
|
|
295
|
+
return [slot];
|
|
296
|
+
const elements = slotContent.assignedElements
|
|
297
|
+
? slotContent.assignedElements()
|
|
298
|
+
: slotContent.childNodes;
|
|
299
|
+
return elements.length ? elements : slot.tagName ? [slot] : null;
|
|
300
|
+
};
|
|
301
|
+
const getNavItemParentDetails = ({ parentElement, }) => {
|
|
302
|
+
let navType = { navType: "", parent: null };
|
|
303
|
+
if (parentElement) {
|
|
304
|
+
switch (parentElement.tagName) {
|
|
305
|
+
case "IC-NAVIGATION-GROUP":
|
|
306
|
+
navType = getNavItemParentDetails(parentElement);
|
|
307
|
+
break;
|
|
308
|
+
case "IC-TOP-NAVIGATION":
|
|
309
|
+
navType = { navType: "top", parent: parentElement };
|
|
310
|
+
break;
|
|
311
|
+
case "IC-SIDE-NAVIGATION":
|
|
312
|
+
navType = { navType: "side", parent: parentElement };
|
|
313
|
+
break;
|
|
314
|
+
case "IC-PAGE-HEADER":
|
|
315
|
+
navType = { navType: "page-header", parent: null };
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return navType;
|
|
320
|
+
};
|
|
321
|
+
const DEVICE_SIZES = {
|
|
322
|
+
XS: Number(getCssProperty("--ic-breakpoint-xs").replace("px", "")), // 0
|
|
323
|
+
S: Number(getCssProperty("--ic-breakpoint-sm").replace("px", "")), // 576
|
|
324
|
+
M: Number(getCssProperty("--ic-breakpoint-md").replace("px", "")), // 768
|
|
325
|
+
L: Number(getCssProperty("--ic-breakpoint-lg").replace("px", "")), // 992
|
|
326
|
+
XL: Number(getCssProperty("--ic-breakpoint-xl").replace("px", "")), // 1200
|
|
327
|
+
UNDEFINED: 1200,
|
|
328
|
+
};
|
|
329
|
+
const hasValidationStatus = (status, disabled) => !!status && !disabled;
|
|
330
|
+
const isSlotUsed = ({ children }, slotName) => Array.from(children).some((child) => child.getAttribute("slot") === slotName);
|
|
331
|
+
// added as a common method to allow detection of gatsby hydration issue, where (camelCase) props are initially undefined & then update
|
|
332
|
+
// with a value. Allows a callback function to be executed when this is the case
|
|
333
|
+
const onComponentPropUndefinedChange = (oldValue, newValue, callback) => {
|
|
334
|
+
if (oldValue === undefined && newValue !== oldValue) {
|
|
335
|
+
callback();
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const onComponentRequiredPropUndefined = (props, component) => {
|
|
339
|
+
props.forEach(({ prop, propName }) => {
|
|
340
|
+
if (prop === null || prop === undefined) {
|
|
341
|
+
console.error(`No ${propName} specified for ${component} component - prop '${propName}' (web components) / '${kebabToCamelCase(propName)}' (react) required`);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
const kebabToCamelCase = (kebabCase) => kebabCase
|
|
346
|
+
.toLowerCase()
|
|
347
|
+
.split("-")
|
|
348
|
+
.map((word, index) => index === 0
|
|
349
|
+
? word
|
|
350
|
+
: `${word.substring(0, 1).toUpperCase()}${word.substring(1)}`)
|
|
351
|
+
.join("");
|
|
352
|
+
const checkResizeObserver = (callbackFn) => {
|
|
353
|
+
if (typeof window !== "undefined" &&
|
|
354
|
+
typeof window.ResizeObserver !== "undefined") {
|
|
355
|
+
callbackFn();
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const hex2dec = (v) => parseInt(v, 16);
|
|
359
|
+
const hexToRgba = (hex) => {
|
|
360
|
+
const hexChars = hex
|
|
361
|
+
.replace("#", "")
|
|
362
|
+
.split("")
|
|
363
|
+
.map((char) => char.repeat(2));
|
|
364
|
+
return {
|
|
365
|
+
r: hex2dec(hex.length === 4 ? hexChars[0] : hex.slice(1, 3)),
|
|
366
|
+
g: hex2dec(hex.length === 4 ? hexChars[1] : hex.slice(3, 5)),
|
|
367
|
+
b: hex2dec(hex.length === 4 ? hexChars[2] : hex.slice(5)),
|
|
368
|
+
a: 1,
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
const rgbaStrToObj = (rgbaStr) => {
|
|
372
|
+
const isRGBA = rgbaStr.slice(3, 4).toLowerCase() === "a";
|
|
373
|
+
const rgbValues = rgbaStr
|
|
374
|
+
.substring(isRGBA ? 5 : 4, rgbaStr.length - 1)
|
|
375
|
+
.replace(/ /g, "")
|
|
376
|
+
.split(",")
|
|
377
|
+
.map(Number);
|
|
378
|
+
return {
|
|
379
|
+
r: rgbValues[0],
|
|
380
|
+
g: rgbValues[1],
|
|
381
|
+
b: rgbValues[2],
|
|
382
|
+
a: isRGBA ? rgbValues[3] : 1,
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
const elementOverflowsX = ({ scrollWidth, clientWidth, }) => scrollWidth > clientWidth;
|
|
386
|
+
const hasClassificationBanner = () => !!document.querySelector("ic-classification-banner:not([inline='true'])");
|
|
387
|
+
const addFormResetListener = (el, callbackFn) => {
|
|
388
|
+
var _a;
|
|
389
|
+
(_a = el.closest("FORM")) === null || _a === void 0 ? void 0 : _a.addEventListener("reset", callbackFn);
|
|
390
|
+
};
|
|
391
|
+
const removeFormResetListener = (el, callbackFn) => {
|
|
392
|
+
var _a;
|
|
393
|
+
(_a = el.closest("FORM")) === null || _a === void 0 ? void 0 : _a.removeEventListener("reset", callbackFn);
|
|
394
|
+
};
|
|
395
|
+
const pxToRem = (px, base = 16) => `${(1 / base) * parseInt(px)}rem`;
|
|
396
|
+
/**
|
|
397
|
+
* Removes the disabled attribute from the provided element when its value is set to false.
|
|
398
|
+
* This effectively makes it null, to not confuse screen readers that cannot interpret the false value
|
|
399
|
+
*/
|
|
400
|
+
const removeDisabledFalse = (disabled, element) => {
|
|
401
|
+
if (!disabled) {
|
|
402
|
+
element.removeAttribute("disabled");
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
const isMacDevice = () => window.navigator.userAgent.toUpperCase().indexOf("MAC") >= 0;
|
|
406
|
+
const convertToRGBA = (color) => {
|
|
407
|
+
const firstChar = color === null || color === void 0 ? void 0 : color.slice(0, 1).toLowerCase();
|
|
408
|
+
if (firstChar !== "#" && firstChar !== "r")
|
|
409
|
+
return null;
|
|
410
|
+
return firstChar === "#" ? hexToRgba(color) : rgbaStrToObj(color);
|
|
411
|
+
};
|
|
412
|
+
const capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
413
|
+
const checkSlotInChildMutations = (addedNodes, removedNodes, slotName) => {
|
|
414
|
+
const hasSlot = (nodeList) => Array.from(nodeList).some((node) => Array.isArray(slotName)
|
|
415
|
+
? slotName.some((name) => node.slot === name)
|
|
416
|
+
: node.slot === slotName);
|
|
417
|
+
return hasSlot(addedNodes) || hasSlot(removedNodes);
|
|
418
|
+
};
|
|
419
|
+
const isElInAGGrid = (el) => !!el.closest(".ag-cell") && !!el.closest(".ag-root");
|
|
420
|
+
/**
|
|
421
|
+
* Checks if the component is slotted in its relevant 'group' component
|
|
422
|
+
* @param component - the component to check
|
|
423
|
+
*/
|
|
424
|
+
const isSlottedInGroup = (component) => { var _a; return ((_a = component.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === `${component.tagName}-GROUP`; };
|
|
425
|
+
const hasDynamicChildSlots = (mutationList, slotNames) => mutationList.some(({ type, addedNodes, removedNodes }) => type === "childList" &&
|
|
426
|
+
checkSlotInChildMutations(addedNodes, removedNodes, slotNames));
|
|
427
|
+
const renderDynamicChildSlots = (mutationList, slotNames, ref) => {
|
|
428
|
+
if (hasDynamicChildSlots(mutationList, slotNames)) {
|
|
429
|
+
forceUpdate(ref);
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
const getElementInheritedTheme = (el) => {
|
|
433
|
+
var _a, _b, _c, _d, _e;
|
|
434
|
+
const blockParentTheme = (_b = (_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.closest(IC_BLOCK_COLOR_COMPONENTS)) === null || _b === void 0 ? void 0 : _b.theme;
|
|
435
|
+
if (blockParentTheme && blockParentTheme !== "inherit")
|
|
436
|
+
return blockParentTheme;
|
|
437
|
+
const wrapperTheme = (_d = (_c = el.parentElement) === null || _c === void 0 ? void 0 : _c.closest("ic-theme")) === null || _d === void 0 ? void 0 : _d.theme;
|
|
438
|
+
if (wrapperTheme && wrapperTheme !== "system")
|
|
439
|
+
return wrapperTheme;
|
|
440
|
+
return ((_e = window.matchMedia) === null || _e === void 0 ? void 0 : _e.call(window, "(prefers-color-scheme: dark)").matches)
|
|
441
|
+
? "dark"
|
|
442
|
+
: "light";
|
|
443
|
+
};
|
|
444
|
+
const isSafari = /safari/i.test(window.navigator.userAgent) &&
|
|
445
|
+
!/Edge/i.test(window.navigator.userAgent) &&
|
|
446
|
+
!/chrome/i.test(window.navigator.userAgent);
|
|
447
|
+
/**
|
|
448
|
+
* Focuses the provided element, or the next focusable element if it should be skipped. Used for focus trapping.
|
|
449
|
+
* @param focusAttemptCount - number of focus attempts that have been made
|
|
450
|
+
* @param focusedElementIndex - current focused element index
|
|
451
|
+
* @param interactiveElementList - list of interactive elements
|
|
452
|
+
* @param shiftKey - whether the shift key is pressed
|
|
453
|
+
*/
|
|
454
|
+
const focusElement = (focusAttemptCount, focusedElementIndex, interactiveElementList, shiftKey = false) => {
|
|
455
|
+
const element = interactiveElementList[focusedElementIndex];
|
|
456
|
+
if (!element) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
let newFocusAttemptCount = focusAttemptCount;
|
|
460
|
+
if (newFocusAttemptCount++ > interactiveElementList.length) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
if (shouldSkipElement(element)) {
|
|
464
|
+
const nextIndex = shiftKey
|
|
465
|
+
? focusedElementIndex - 1
|
|
466
|
+
: focusedElementIndex + 1;
|
|
467
|
+
const newFocusedElementIndex = nextIndex < 0
|
|
468
|
+
? interactiveElementList.length - 1
|
|
469
|
+
: nextIndex % interactiveElementList.length;
|
|
470
|
+
return focusElement(newFocusAttemptCount, newFocusedElementIndex, interactiveElementList, shiftKey);
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
switch (element.tagName) {
|
|
474
|
+
case IC_ACCORDION:
|
|
475
|
+
case IC_ACCORDION_GROUP:
|
|
476
|
+
case IC_CHECKBOX:
|
|
477
|
+
case IC_SEARCH_BAR:
|
|
478
|
+
case IC_TAB_CONTEXT:
|
|
479
|
+
case IC_TEXT_FIELD:
|
|
480
|
+
element.setFocus();
|
|
481
|
+
break;
|
|
482
|
+
default:
|
|
483
|
+
element.focus();
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
newFocusAttemptCount,
|
|
487
|
+
newFocusedElementIndex: focusedElementIndex,
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* Sets up listener and mutation observer to refresh interactive elements on slot changes. Used for focus trapping.
|
|
493
|
+
* @param contentWrapper - content wrapper element
|
|
494
|
+
* @param getInteractiveElements - function to get interactive elements
|
|
495
|
+
*/
|
|
496
|
+
const refreshInteractiveElementsOnSlotChange = (contentWrapper, getInteractiveElements) => {
|
|
497
|
+
var _a;
|
|
498
|
+
let contentAreaSlot = null;
|
|
499
|
+
let contentAreaMutationObserver = null;
|
|
500
|
+
if (contentWrapper) {
|
|
501
|
+
contentAreaSlot = contentWrapper.querySelector("slot");
|
|
502
|
+
// Detect changes to slotted elements
|
|
503
|
+
contentAreaSlot === null || contentAreaSlot === void 0 ? void 0 : contentAreaSlot.addEventListener("slotchange", getInteractiveElements);
|
|
504
|
+
contentAreaMutationObserver = new MutationObserver(() => {
|
|
505
|
+
getInteractiveElements();
|
|
506
|
+
});
|
|
507
|
+
// Detect changes to children of slotted elements
|
|
508
|
+
(_a = getSlotElements(contentWrapper)) === null || _a === void 0 ? void 0 : _a.forEach((el) => {
|
|
509
|
+
contentAreaMutationObserver === null || contentAreaMutationObserver === void 0 ? void 0 : contentAreaMutationObserver.observe(el, {
|
|
510
|
+
childList: true,
|
|
511
|
+
subtree: true,
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
return { contentAreaSlot, contentAreaMutationObserver };
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* Determines whether an element should be skipped when focusing interactive elements. Used for focus trapping.
|
|
519
|
+
* @param element - element to check
|
|
520
|
+
*/
|
|
521
|
+
const shouldSkipElement = (element) => {
|
|
522
|
+
if (!element) {
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
525
|
+
const isHidden = getComputedStyle(element).visibility === "hidden" ||
|
|
526
|
+
element.offsetHeight === 0 ||
|
|
527
|
+
element.hasAttribute("disabled") ||
|
|
528
|
+
(element.tagName === IC_ACCORDION_GROUP &&
|
|
529
|
+
element.hasAttribute("single-expansion"));
|
|
530
|
+
const radioEl = element.closest("ic-radio-option");
|
|
531
|
+
return (isHidden ||
|
|
532
|
+
(element.getAttribute("type") === "radio" &&
|
|
533
|
+
!!radioEl &&
|
|
534
|
+
!(radioEl.hasAttribute("selected") || element.tabIndex === 0)));
|
|
535
|
+
};
|
|
536
|
+
/**
|
|
537
|
+
* Gets all interactive elements slotted within a component. Used for focus trapping.
|
|
538
|
+
* @param el - host element of the component
|
|
539
|
+
*/
|
|
540
|
+
const slottedInteractiveElements = (el) => Array.from(el.querySelectorAll(`a[href], button, input:not(.ic-input), textarea, select, details, [tabindex]:not([tabindex="-1"]),
|
|
541
|
+
ic-button, ic-checkbox, ic-select, ic-search-bar, ic-tab-context,
|
|
542
|
+
ic-back-to-top, ic-breadcrumb, ic-chip[dismissible="true"], ic-footer-link, ic-link, ic-navigation-button,
|
|
543
|
+
ic-navigation-item, ic-switch, ic-text-field, ic-accordion-group, ic-accordion, ic-date-input, ic-date-picker, ic-action-chip, ic-time-input`));
|
|
544
|
+
|
|
545
|
+
export { IcInformationStatus as A, slotHasContent as B, refreshInteractiveElementsOnSlotChange as C, DEVICE_SIZES as D, focusElement as E, slottedInteractiveElements as F, isEmptyString as G, hasClassificationBanner as H, IcBrandForegroundEnum as I, elementOverflowsX as J, isMacDevice as K, getOptionsWithoutGroupTitlesCount as L, getElementInheritedTheme as M, getNavItemParentDetails as N, getCssProperty as O, getSlot as P, getSlotContent as Q, capitalize as R, checkSlotInChildMutations as S, isMobileOrTablet as T, debounceEvent as U, getFilteredMenuOptions as V, getLabelFromValue as W, getBrandColorBrightness as X, isSlottedInGroup as Y, isElInAGGrid as a, inheritAttributes as b, checkResizeObserver as c, renderFileHiddenInput as d, renderDynamicChildSlots as e, isSafari as f, getBrandFromContext as g, handleHiddenFormButtonClick as h, isSlotUsed as i, onComponentPropUndefinedChange as j, convertToRGBA as k, getBrandForegroundAppearance as l, isPropDefined as m, getSlotElements as n, onComponentRequiredPropUndefined as o, pxToRem as p, getCurrentDeviceSize as q, removeDisabledFalse as r, addFormResetListener as s, removeFormResetListener as t, renderHiddenInput as u, removeHiddenInput as v, getInputDescribedByText as w, hasValidationStatus as x, getInputHelperTextID as y, getInputValidationTextID as z };
|
|
546
|
+
|
|
547
|
+
//# sourceMappingURL=helpers.js.map
|