@telesign/boreal-web-components 0.1.0-alpha.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/LICENSE +21 -0
- package/components-build/bds-banner.d.ts +11 -0
- package/components-build/bds-banner.js +1 -0
- package/components-build/bds-typography.d.ts +11 -0
- package/components-build/bds-typography.js +1 -0
- package/components-build/index.d.ts +35 -0
- package/components-build/index.js +1 -0
- package/components-build/my-component.d.ts +11 -0
- package/components-build/my-component.js +1 -0
- package/components-build/p-B9wshZ_4.js +1 -0
- package/components-build/p-noyWJ11s.js +1 -0
- package/custom-elements.json +764 -0
- package/dist/boreal-web-components/boreal-web-components.css +1 -0
- package/dist/boreal-web-components/boreal-web-components.esm.js +1 -0
- package/dist/boreal-web-components/boreal-web-components.js +127 -0
- package/dist/boreal-web-components/css/boreal.css +1594 -0
- package/dist/boreal-web-components/css/global.css +682 -0
- package/dist/boreal-web-components/css/theme-connect.css +227 -0
- package/dist/boreal-web-components/css/theme-engage.css +227 -0
- package/dist/boreal-web-components/css/theme-protect.css +227 -0
- package/dist/boreal-web-components/css/theme-proximus.css +227 -0
- package/dist/boreal-web-components/index.esm.js +0 -0
- package/dist/boreal-web-components/p-412d037b.system.entry.js +1 -0
- package/dist/boreal-web-components/p-527a761b.entry.js +1 -0
- package/dist/boreal-web-components/p-5666a22a.system.entry.js +1 -0
- package/dist/boreal-web-components/p-B-PpI2Xv.system.js +1 -0
- package/dist/boreal-web-components/p-B9wshZ_4.js +1 -0
- package/dist/boreal-web-components/p-BQdH0ijK.system.js +2 -0
- package/dist/boreal-web-components/p-BbPAtVJG.system.js +1 -0
- package/dist/boreal-web-components/p-CMd-Mv-5.system.js +1 -0
- package/dist/boreal-web-components/p-CaVEtaG3.system.js +1 -0
- package/dist/boreal-web-components/p-DQuL1Twl.js +1 -0
- package/dist/boreal-web-components/p-DgFiTd6X.js +2 -0
- package/dist/boreal-web-components/p-YWpyar7R.system.js +1 -0
- package/dist/boreal-web-components/p-b818618b.entry.js +1 -0
- package/dist/boreal-web-components/p-d596406b.entry.js +1 -0
- package/dist/boreal-web-components/p-e37e7dba.system.entry.js +1 -0
- package/dist/boreal-web-components/p-noyWJ11s.js +1 -0
- package/dist/boreal-web-components/scss/global/_fonts.scss +1 -0
- package/dist/boreal-web-components/scss/global/_index.scss +3 -0
- package/dist/boreal-web-components/scss/global/_reset.scss +50 -0
- package/dist/boreal-web-components/scss/global/_typography.scss +156 -0
- package/dist/boreal-web-components/scss/maps/_primitives.scss +461 -0
- package/dist/boreal-web-components/scss/maps/_theme-connect.scss +227 -0
- package/dist/boreal-web-components/scss/maps/_theme-engage.scss +227 -0
- package/dist/boreal-web-components/scss/maps/_theme-protect.scss +227 -0
- package/dist/boreal-web-components/scss/maps/_theme-proximus.scss +227 -0
- package/dist/boreal-web-components/scss/variables/_primitives.scss +459 -0
- package/dist/boreal-web-components/scss/variables/_theme-connect.scss +225 -0
- package/dist/boreal-web-components/scss/variables/_theme-engage.scss +225 -0
- package/dist/boreal-web-components/scss/variables/_theme-protect.scss +225 -0
- package/dist/boreal-web-components/scss/variables/_theme-proximus.scss +225 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/attributes-RPVEtBdj.js +90 -0
- package/dist/cjs/bds-banner.cjs.entry.js +130 -0
- package/dist/cjs/bds-typography.cjs.entry.js +167 -0
- package/dist/cjs/boreal-web-components.cjs.js +46 -0
- package/dist/cjs/index-CD9v53WJ.js +133 -0
- package/dist/cjs/index-Cdb66Tqj.js +2342 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/my-component.cjs.entry.js +29 -0
- package/dist/collection/collection-manifest.json +14 -0
- package/dist/collection/components/feedback/bds-banner/bds-banner.css +101 -0
- package/dist/collection/components/feedback/bds-banner/bds-banner.js +266 -0
- package/dist/collection/components/feedback/bds-banner/types/IBanner.js +1 -0
- package/dist/collection/components/my-component/my-component.css +3 -0
- package/dist/collection/components/my-component/my-component.js +95 -0
- package/dist/collection/components/titles-text/bds-typography/bds-typography.css +183 -0
- package/dist/collection/components/titles-text/bds-typography/bds-typography.js +577 -0
- package/dist/collection/components/titles-text/bds-typography/types/ITypography.js +1 -0
- package/dist/collection/components/titles-text/bds-typography/types/enum.js +23 -0
- package/dist/collection/components/titles-text/bds-typography/types/types.js +1 -0
- package/dist/collection/components/titles-text/bds-typography/utils/bds-typography-utils.js +41 -0
- package/dist/collection/css/boreal.css +1594 -0
- package/dist/collection/css/global.css +682 -0
- package/dist/collection/css/theme-connect.css +227 -0
- package/dist/collection/css/theme-engage.css +227 -0
- package/dist/collection/css/theme-protect.css +227 -0
- package/dist/collection/css/theme-proximus.css +227 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/mixins/anchored.mixin.js +272 -0
- package/dist/collection/mixins/floating.mixin.js +181 -0
- package/dist/collection/mixins/form-associated.mixin.js +95 -0
- package/dist/collection/mixins/index.js +3 -0
- package/dist/collection/scss/global/_fonts.scss +1 -0
- package/dist/collection/scss/global/_index.scss +3 -0
- package/dist/collection/scss/global/_reset.scss +50 -0
- package/dist/collection/scss/global/_typography.scss +156 -0
- package/dist/collection/scss/maps/_primitives.scss +461 -0
- package/dist/collection/scss/maps/_theme-connect.scss +227 -0
- package/dist/collection/scss/maps/_theme-engage.scss +227 -0
- package/dist/collection/scss/maps/_theme-protect.scss +227 -0
- package/dist/collection/scss/maps/_theme-proximus.scss +227 -0
- package/dist/collection/scss/variables/_primitives.scss +459 -0
- package/dist/collection/scss/variables/_theme-connect.scss +225 -0
- package/dist/collection/scss/variables/_theme-engage.scss +225 -0
- package/dist/collection/scss/variables/_theme-protect.scss +225 -0
- package/dist/collection/scss/variables/_theme-proximus.scss +225 -0
- package/dist/collection/services/floating/interfaces/Floating.js +1 -0
- package/dist/collection/services/floating/interfaces/Positioning.js +1 -0
- package/dist/collection/services/floating/interfaces/Props.js +1 -0
- package/dist/collection/services/floating/positioning.service.js +71 -0
- package/dist/collection/services/floating/types/Arrow.js +1 -0
- package/dist/collection/services/logger/Logger.js +47 -0
- package/dist/collection/types/alignment.js +6 -0
- package/dist/collection/types/form.js +1 -0
- package/dist/collection/types/index.js +5 -0
- package/dist/collection/types/position.js +11 -0
- package/dist/collection/types/size.js +7 -0
- package/dist/collection/types/states.js +22 -0
- package/dist/collection/types/stylesMap.js +1 -0
- package/dist/collection/utils/a11y/attributes.js +80 -0
- package/dist/collection/utils/a11y/index.js +1 -0
- package/dist/collection/utils/constants/common/Events.js +10 -0
- package/dist/collection/utils/constants/common/Keys.js +16 -0
- package/dist/collection/utils/dom/elements.js +22 -0
- package/dist/collection/utils/dom/index.js +1 -0
- package/dist/collection/utils/form/index.js +1 -0
- package/dist/collection/utils/form/internals.js +79 -0
- package/dist/collection/utils/helpers/common/BaseAttributes.js +17 -0
- package/dist/collection/utils/index.js +3 -0
- package/dist/css/boreal.css +1594 -0
- package/dist/css/global.css +682 -0
- package/dist/css/theme-connect.css +227 -0
- package/dist/css/theme-engage.css +227 -0
- package/dist/css/theme-protect.css +227 -0
- package/dist/css/theme-proximus.css +227 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/attributes-B9wshZ_4.js +86 -0
- package/dist/esm/bds-banner.entry.js +128 -0
- package/dist/esm/bds-typography.entry.js +165 -0
- package/dist/esm/boreal-web-components.js +42 -0
- package/dist/esm/index-DgFiTd6X.js +2332 -0
- package/dist/esm/index-noyWJ11s.js +131 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/my-component.entry.js +27 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm-es5/app-globals-DQuL1Twl.js +1 -0
- package/dist/esm-es5/attributes-B9wshZ_4.js +1 -0
- package/dist/esm-es5/bds-banner.entry.js +1 -0
- package/dist/esm-es5/bds-typography.entry.js +1 -0
- package/dist/esm-es5/boreal-web-components.js +1 -0
- package/dist/esm-es5/index-DgFiTd6X.js +2 -0
- package/dist/esm-es5/index-noyWJ11s.js +1 -0
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +1 -0
- package/dist/esm-es5/my-component.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/scss/global/_fonts.scss +1 -0
- package/dist/scss/global/_index.scss +3 -0
- package/dist/scss/global/_reset.scss +50 -0
- package/dist/scss/global/_typography.scss +156 -0
- package/dist/scss/maps/_primitives.scss +461 -0
- package/dist/scss/maps/_theme-connect.scss +227 -0
- package/dist/scss/maps/_theme-engage.scss +227 -0
- package/dist/scss/maps/_theme-protect.scss +227 -0
- package/dist/scss/maps/_theme-proximus.scss +227 -0
- package/dist/scss/variables/_primitives.scss +459 -0
- package/dist/scss/variables/_theme-connect.scss +225 -0
- package/dist/scss/variables/_theme-engage.scss +225 -0
- package/dist/scss/variables/_theme-protect.scss +225 -0
- package/dist/scss/variables/_theme-proximus.scss +225 -0
- package/dist/types/components/feedback/bds-banner/bds-banner.d.ts +71 -0
- package/dist/types/components/feedback/bds-banner/types/IBanner.d.ts +10 -0
- package/dist/types/components/my-component/my-component.d.ts +16 -0
- package/dist/types/components/titles-text/bds-typography/bds-typography.d.ts +99 -0
- package/dist/types/components/titles-text/bds-typography/types/ITypography.d.ts +22 -0
- package/dist/types/components/titles-text/bds-typography/types/enum.d.ts +24 -0
- package/dist/types/components/titles-text/bds-typography/types/types.d.ts +4 -0
- package/dist/types/components/titles-text/bds-typography/utils/bds-typography-utils.d.ts +15 -0
- package/dist/types/components.d.ts +565 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/mixins/anchored.mixin.d.ts +228 -0
- package/dist/types/mixins/floating.mixin.d.ts +158 -0
- package/dist/types/mixins/form-associated.mixin.d.ts +127 -0
- package/dist/types/mixins/index.d.ts +4 -0
- package/dist/types/services/floating/interfaces/Floating.d.ts +38 -0
- package/dist/types/services/floating/interfaces/Positioning.d.ts +22 -0
- package/dist/types/services/floating/interfaces/Props.d.ts +35 -0
- package/dist/types/services/floating/positioning.service.d.ts +45 -0
- package/dist/types/services/floating/types/Arrow.d.ts +7 -0
- package/dist/types/services/logger/Logger.d.ts +50 -0
- package/dist/types/stencil-public-runtime.d.ts +1858 -0
- package/dist/types/types/alignment.d.ts +8 -0
- package/dist/types/types/form.d.ts +7 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/position.d.ts +13 -0
- package/dist/types/types/size.d.ts +9 -0
- package/dist/types/types/states.d.ts +26 -0
- package/dist/types/types/stylesMap.d.ts +2 -0
- package/dist/types/utils/a11y/attributes.d.ts +13 -0
- package/dist/types/utils/a11y/index.d.ts +2 -0
- package/dist/types/utils/constants/common/Events.d.ts +14 -0
- package/dist/types/utils/constants/common/Keys.d.ts +18 -0
- package/dist/types/utils/dom/elements.d.ts +12 -0
- package/dist/types/utils/dom/index.d.ts +2 -0
- package/dist/types/utils/form/index.d.ts +2 -0
- package/dist/types/utils/form/internals.d.ts +66 -0
- package/dist/types/utils/helpers/common/BaseAttributes.d.ts +16 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/loader/cdn.js +2 -0
- package/loader/index.cjs.js +2 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +2 -0
- package/loader/index.js +3 -0
- package/package.json +96 -0
- package/readme.md +111 -0
- package/scripts/copy-styles.js +18 -0
- package/scripts/postbuild.js +21 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const STATES = {
|
|
4
|
+
DEFAULT: 'default',
|
|
5
|
+
ERROR: 'error',
|
|
6
|
+
DISABLED: 'disabled'};
|
|
7
|
+
const STATUS_VARIANT = {
|
|
8
|
+
INFO: 'info'};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Taken from StencilJS Ionic team
|
|
12
|
+
* This helper pass the attributes passed to components directly to the inner element
|
|
13
|
+
* e.g. <my-component aria-hidden="true">Text</my-component>
|
|
14
|
+
* will pass the aria-hidden to the inner element inside my-component
|
|
15
|
+
* <span { ...myComponentAttr }>Hidden</span>
|
|
16
|
+
*/
|
|
17
|
+
const inheritAttributes = (el, attributes = []) => {
|
|
18
|
+
const attributeObject = {};
|
|
19
|
+
attributes.forEach(attr => {
|
|
20
|
+
if (el.hasAttribute(attr)) {
|
|
21
|
+
const value = el.getAttribute(attr);
|
|
22
|
+
if (value !== null) {
|
|
23
|
+
attributeObject[attr] = value;
|
|
24
|
+
}
|
|
25
|
+
el.removeAttribute(attr);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return attributeObject;
|
|
29
|
+
};
|
|
30
|
+
const ariaAttributes = [
|
|
31
|
+
'role',
|
|
32
|
+
'aria-activedescendant',
|
|
33
|
+
'aria-atomic',
|
|
34
|
+
'aria-autocomplete',
|
|
35
|
+
'aria-braillelabel',
|
|
36
|
+
'aria-brailleroledescription',
|
|
37
|
+
'aria-busy',
|
|
38
|
+
'aria-checked',
|
|
39
|
+
'aria-colcount',
|
|
40
|
+
'aria-colindex',
|
|
41
|
+
'aria-colindextext',
|
|
42
|
+
'aria-colspan',
|
|
43
|
+
'aria-controls',
|
|
44
|
+
'aria-current',
|
|
45
|
+
'aria-describedby',
|
|
46
|
+
'aria-description',
|
|
47
|
+
'aria-details',
|
|
48
|
+
'aria-disabled',
|
|
49
|
+
'aria-errormessage',
|
|
50
|
+
'aria-expanded',
|
|
51
|
+
'aria-flowto',
|
|
52
|
+
'aria-haspopup',
|
|
53
|
+
'aria-hidden',
|
|
54
|
+
'aria-invalid',
|
|
55
|
+
'aria-keyshortcuts',
|
|
56
|
+
'aria-label',
|
|
57
|
+
'aria-labelledby',
|
|
58
|
+
'aria-level',
|
|
59
|
+
'aria-live',
|
|
60
|
+
'aria-multiline',
|
|
61
|
+
'aria-multiselectable',
|
|
62
|
+
'aria-orientation',
|
|
63
|
+
'aria-owns',
|
|
64
|
+
'aria-placeholder',
|
|
65
|
+
'aria-posinset',
|
|
66
|
+
'aria-pressed',
|
|
67
|
+
'aria-readonly',
|
|
68
|
+
'aria-relevant',
|
|
69
|
+
'aria-required',
|
|
70
|
+
'aria-roledescription',
|
|
71
|
+
'aria-rowcount',
|
|
72
|
+
'aria-rowindex',
|
|
73
|
+
'aria-rowindextext',
|
|
74
|
+
'aria-rowspan',
|
|
75
|
+
'aria-selected',
|
|
76
|
+
'aria-setsize',
|
|
77
|
+
'aria-sort',
|
|
78
|
+
'aria-valuemax',
|
|
79
|
+
'aria-valuemin',
|
|
80
|
+
'aria-valuenow',
|
|
81
|
+
'aria-valuetext',
|
|
82
|
+
];
|
|
83
|
+
const inheritAriaAttributes = (el, ignoreList) => {
|
|
84
|
+
let attributesToInherit = ariaAttributes;
|
|
85
|
+
return inheritAttributes(el, attributesToInherit);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
exports.STATES = STATES;
|
|
89
|
+
exports.STATUS_VARIANT = STATUS_VARIANT;
|
|
90
|
+
exports.inheritAriaAttributes = inheritAriaAttributes;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-Cdb66Tqj.js');
|
|
4
|
+
var attributes = require('./attributes-RPVEtBdj.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Ensure the given component instance has an auto-generated id if one wasn't provided.
|
|
8
|
+
* Designed to be called from `componentWillLoad` on a Stencil component.
|
|
9
|
+
*/
|
|
10
|
+
function createId(component) {
|
|
11
|
+
if (!component.idComponent)
|
|
12
|
+
component.idComponent = `bds-${Math.random().toString(36).substr(2, 9)}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Components can spread the result into their host.
|
|
16
|
+
*/
|
|
17
|
+
function getBaseAttributes(component) {
|
|
18
|
+
createId(component);
|
|
19
|
+
return {
|
|
20
|
+
id: component.idComponent,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const bdsBannerCss = () => `.bds-banner{position:relative;display:-ms-flexbox;display:flex;border:var(--boreal-spacing-4xs) solid var(--boreal-stroke-info-base);border-radius:var(--boreal-radius-xs);border-left:0;font-family:var(--boreal-typography-font-family-primary);height:100%;-webkit-transition:all 0.3s ease-out;transition:all 0.3s ease-out}.bds-banner__vertical-line{width:var(--boreal-spacing-2xs);border-top-left-radius:var(--boreal-radius-xs);border-bottom-left-radius:var(--boreal-radius-xs);background-color:var(--boreal-stroke-info-base)}.bds-banner__container{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;width:100%;gap:var(--boreal-spacing-xs);padding:var(--boreal-spacing-s)}.bds-banner__content{width:100%}.bds-banner__title{font-weight:var(--boreal-typography-font-weight-semibold);font-size:var(--boreal-typography-font-size-md);line-height:var(--boreal-typography-line-height-md)}.bds-banner__body{padding-top:var(--boreal-spacing-2xs);font-size:var(--boreal-typography-font-size-sm);line-height:var(--boreal-typography-line-height-sm)}.bds-banner__actions{padding-top:var(--boreal-spacing-s);min-height:0px}.bds-banner__actions:empty{display:none}.bds-banner__status-icon{font-size:var(--boreal-typography-font-size-md);line-height:var(--boreal-typography-line-height-md);margin-top:var(--boreal-spacing-3xs)}.bds-banner__close-icon{background:none;border:none;-ms-flex-item-align:start;align-self:start;font-size:var(--boreal-typography-font-size-md);line-height:var(--boreal-typography-line-height-md);color:var(--boreal-neutral-base);cursor:pointer}.bds-banner--info{border-color:var(--boreal-stroke-info-base);background-color:var(--boreal-ui-info-lighter)}.bds-banner--info .bds-banner__vertical-line{background-color:var(--boreal-stroke-info-base)}.bds-banner--info .bds-banner__status-icon{color:var(--boreal-stroke-info-base)}.bds-banner--success{border-color:var(--boreal-stroke-success-base);background-color:var(--boreal-ui-success-lighter)}.bds-banner--success .bds-banner__vertical-line{background-color:var(--boreal-stroke-success-base)}.bds-banner--success .bds-banner__status-icon{color:var(--boreal-stroke-success-base)}.bds-banner--warning{border-color:var(--boreal-stroke-warning);background-color:var(--boreal-ui-warning-lighter)}.bds-banner--warning .bds-banner__vertical-line{background-color:var(--boreal-stroke-warning)}.bds-banner--warning .bds-banner__status-icon{color:var(--boreal-stroke-warning)}.bds-banner--danger{border-color:var(--boreal-stroke-danger-base);background-color:var(--boreal-ui-danger-lighter)}.bds-banner--danger .bds-banner__vertical-line{background-color:var(--boreal-stroke-danger-base)}.bds-banner--danger .bds-banner__status-icon{color:var(--boreal-stroke-danger-base)}.bds-banner--closing{opacity:0;height:0}`;
|
|
25
|
+
|
|
26
|
+
const BdsBanner = class {
|
|
27
|
+
constructor(hostRef) {
|
|
28
|
+
index.registerInstance(this, hostRef);
|
|
29
|
+
this.close = index.createEvent(this, "close");
|
|
30
|
+
this.inheritedAttributes = {};
|
|
31
|
+
/**
|
|
32
|
+
* Internal state tracking the banner's closing animation.
|
|
33
|
+
*/
|
|
34
|
+
this.isClosing = false;
|
|
35
|
+
/**
|
|
36
|
+
* Controls the visibility of the banner. Set to false to hide the banner.
|
|
37
|
+
*/
|
|
38
|
+
this.isOpen = true;
|
|
39
|
+
/**
|
|
40
|
+
* Unique identifier for the banner element.
|
|
41
|
+
*/
|
|
42
|
+
this.idComponent = '';
|
|
43
|
+
/**
|
|
44
|
+
* Visual style variant: 'info', 'success', 'warning', or 'danger'.
|
|
45
|
+
* @default "info"
|
|
46
|
+
*/
|
|
47
|
+
this.variant = attributes.STATUS_VARIANT.INFO;
|
|
48
|
+
/**
|
|
49
|
+
* Shows a close button that allows users to dismiss the banner.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
this.enableClose = false;
|
|
53
|
+
this.handleAnimationEnd = () => {
|
|
54
|
+
if (this.isClosing)
|
|
55
|
+
requestAnimationFrame(() => {
|
|
56
|
+
this.isClosing = false;
|
|
57
|
+
this.isOpen = false;
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
componentWillLoad() {
|
|
62
|
+
this.inheritedAttributes = {
|
|
63
|
+
...attributes.inheritAriaAttributes(this.el),
|
|
64
|
+
...getBaseAttributes(this),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Programmatic method to close the banner and emit the `close` event
|
|
69
|
+
*/
|
|
70
|
+
async closeBanner() {
|
|
71
|
+
this.handleCloseBanner();
|
|
72
|
+
}
|
|
73
|
+
handleCloseBanner(e) {
|
|
74
|
+
if (e !== undefined)
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
this.isClosing = true;
|
|
77
|
+
this.close.emit();
|
|
78
|
+
}
|
|
79
|
+
handleEscapeKeyClose(e) {
|
|
80
|
+
if (!this.enableClose)
|
|
81
|
+
return;
|
|
82
|
+
if (e.key === 'Escape')
|
|
83
|
+
this.handleCloseBanner();
|
|
84
|
+
}
|
|
85
|
+
getIconName() {
|
|
86
|
+
const iconMap = {
|
|
87
|
+
info: 'bds-icon-info-circle-fill',
|
|
88
|
+
success: 'bds-icon-check-circle-fill',
|
|
89
|
+
warning: 'bds-icon-info-major-triangle-up-fill',
|
|
90
|
+
danger: 'bds-icon-alert-circle-fill',
|
|
91
|
+
};
|
|
92
|
+
if (iconMap[this.variant] === undefined)
|
|
93
|
+
return iconMap['info'];
|
|
94
|
+
return iconMap[this.variant];
|
|
95
|
+
}
|
|
96
|
+
getAttributes() {
|
|
97
|
+
return {
|
|
98
|
+
...this.inheritedAttributes,
|
|
99
|
+
role: 'alert',
|
|
100
|
+
'aria-describedby': this.isOpen ? 'bds-banner__content' : null,
|
|
101
|
+
'aria-live': 'polite',
|
|
102
|
+
'aria-hidden': `${!this.isOpen}`,
|
|
103
|
+
tabIndex: this.isOpen ? 0 : -1,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
getStyles() {
|
|
107
|
+
return {
|
|
108
|
+
'bds-banner': true,
|
|
109
|
+
[`bds-banner--${this.variant}`]: true,
|
|
110
|
+
'bds-banner--closing': this.isClosing,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
renderCloseIcon() {
|
|
114
|
+
return (
|
|
115
|
+
// TODO how to pass this inner aria attr from outside?
|
|
116
|
+
index.h("button", { role: "close-button", class: "bds-banner__close-icon", "aria-label": "Alert close button", onClick: e => this.handleCloseBanner(e) }, index.h("em", { class: "bds-icon-close" })));
|
|
117
|
+
}
|
|
118
|
+
render() {
|
|
119
|
+
if (!this.isOpen)
|
|
120
|
+
return;
|
|
121
|
+
const closeIcon = this.renderCloseIcon();
|
|
122
|
+
const classes = this.getStyles();
|
|
123
|
+
const iconName = this.getIconName();
|
|
124
|
+
return (index.h(index.Host, { class: classes, ...this.getAttributes(), onTransitionEnd: this.handleAnimationEnd, onKeyDown: (e) => this.handleEscapeKeyClose(e) }, index.h("div", { class: "bds-banner__vertical-line" }), index.h("div", { class: "bds-banner__container" }, index.h("div", { class: "bds-banner__status-icon", role: "status", "aria-live": "polite", "aria-label": `status ${this.variant}` }, index.h("em", { "aria-hidden": "true", class: iconName })), index.h("div", { class: "bds-banner__content" }, index.h("div", { class: "bds-banner__title" }, index.h("slot", { name: "title" })), index.h("div", { class: "bds-banner__body" }, index.h("slot", null)), index.h("div", { class: "bds-banner__actions" }, index.h("slot", { name: "actions" }))), this.enableClose && closeIcon)));
|
|
125
|
+
}
|
|
126
|
+
get el() { return index.getElement(this); }
|
|
127
|
+
};
|
|
128
|
+
BdsBanner.style = bdsBannerCss();
|
|
129
|
+
|
|
130
|
+
exports.bds_banner = BdsBanner;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-Cdb66Tqj.js');
|
|
4
|
+
var attributes = require('./attributes-RPVEtBdj.js');
|
|
5
|
+
|
|
6
|
+
const ALIGNMENT = {
|
|
7
|
+
START: 'start'};
|
|
8
|
+
|
|
9
|
+
const SIZES = {
|
|
10
|
+
XS: 'xs',
|
|
11
|
+
S: 'sm',
|
|
12
|
+
M: 'md',
|
|
13
|
+
L: 'lg',
|
|
14
|
+
XL: 'xl',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const VARIANT_TYPOGRAPHY = {
|
|
18
|
+
DISPLAY: 'display',
|
|
19
|
+
LINK: 'link'};
|
|
20
|
+
const TAG_ELEMENT = {
|
|
21
|
+
P: 'p',
|
|
22
|
+
A: 'a'};
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* LINK consts
|
|
26
|
+
*/
|
|
27
|
+
const FILENAME = 'download';
|
|
28
|
+
/*
|
|
29
|
+
* Variant map to apply size, state, etc, styles based on variant type
|
|
30
|
+
*/
|
|
31
|
+
const VARIANT_CONFIG = {
|
|
32
|
+
link: {
|
|
33
|
+
states: [attributes.STATES.DISABLED /* STATES.VISITED, STATES.HOVER, STATES.ACTIVE, STATES.FOCUS */],
|
|
34
|
+
size: [SIZES.S, SIZES.M],
|
|
35
|
+
},
|
|
36
|
+
label: {
|
|
37
|
+
states: [attributes.STATES.DISABLED],
|
|
38
|
+
isRequired: true,
|
|
39
|
+
canUseTooltip: true,
|
|
40
|
+
},
|
|
41
|
+
heading: { canUseTooltip: true },
|
|
42
|
+
subheading: { canUseTooltip: true },
|
|
43
|
+
helper: { states: [attributes.STATES.ERROR] },
|
|
44
|
+
display: { size: [SIZES.XS, SIZES.S, SIZES.M, SIZES.L, SIZES.XL] },
|
|
45
|
+
};
|
|
46
|
+
/*
|
|
47
|
+
* ATTRIBUTE MAP
|
|
48
|
+
*/
|
|
49
|
+
const getAttributesByTag = (comp, tagName) => {
|
|
50
|
+
const ATTR_MAP = {
|
|
51
|
+
a: {
|
|
52
|
+
href: comp.state !== attributes.STATES.DISABLED ? comp.sanitizedHref : null,
|
|
53
|
+
target: comp.target,
|
|
54
|
+
download: comp.isDownloadable ? comp.filename : null,
|
|
55
|
+
rel: comp.target === '_blank' ? 'noopener noreferrer' : undefined,
|
|
56
|
+
},
|
|
57
|
+
label: {
|
|
58
|
+
htmlFor: comp.htmlFor,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
return ATTR_MAP[tagName] || {};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const bdsTypographyCss = () => `.bds-typography{-webkit-box-sizing:border-box;box-sizing:border-box;font-family:var(--boreal-typography-font-family-primary);font-weight:var(--boreal-typography-font-weight-regular)}.bds-typography__required-indicator{color:var(--boreal-icon-danger-base);font-weight:var(--boreal-typography-font-weight-regular)}.bds-typography__info-icon{color:var(--boreal-icon-default-light)}.bds-typography--heading,.bds-typography--subheading{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:var(--boreal-spacing-3xs)}.bds-typography--label{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;gap:var(--boreal-spacing-3xs)}.bds-typography--display{display:block}.bds-typography--caption,.bds-typography--helper,.bds-typography--link{display:inline-block}.bds-typography--caption{font-size:var(--boreal-typography-font-size-xs);font-weight:var(--boreal-typography-font-weight-regular);line-height:var(--boreal-typography-line-height-md);color:var(--boreal-text-default-light)}.bds-typography--helper{font-size:var(--boreal-typography-font-size-xs);font-weight:var(--boreal-typography-font-weight-regular);line-height:var(--boreal-typography-line-height-sm);color:var(--boreal-text-default-light)}.bds-typography--link{font-size:var(--boreal-typography-font-size-sm);font-weight:var(--boreal-typography-font-weight-regular);line-height:var(--boreal-typography-line-height-md);color:var(--boreal-text-primary-base);text-decoration:none}.bds-typography--link:hover{text-decoration:underline}.bds-typography--link:visited{color:var(--boreal-text-primary-base)}.bds-typography--link:active{color:var(--boreal-text-primary-dark)}.bds-typography--link.bds-typography--size-sm{font-size:var(--boreal-typography-font-size-xs)}.bds-typography--link.bds-typography--size-md{font-size:var(--boreal-typography-font-size-sm)}.bds-typography--code{font-family:var(--boreal-typography-font-family-secondary);font-size:var(--boreal-typography-font-size-xs);font-weight:var(--boreal-typography-font-weight-regular);color:var(--boreal-text-default);line-height:var(--boreal-typography-line-height-md);overflow-wrap:break-word;background-color:var(--boreal-bg-neutral);padding:var(--boreal-spacing-3xs) var(--boreal-spacing-xs);border-radius:var(--boreal-radius-xs);display:inline;box-decoration-break:clone;-webkit-box-decoration-break:clone}.bds-typography--label{font-size:var(--boreal-typography-font-size-xs);font-weight:var(--boreal-typography-font-weight-semibold);line-height:var(--boreal-typography-line-height-md);color:var(--boreal-text-default-darker)}.bds-typography--display{font-weight:var(--boreal-typography-font-weight-regular);color:var(--boreal-text-default)}.bds-typography--display.bds-typography--size-sm{font-size:var(--boreal-typography-font-size-xl);line-height:var(--boreal-typography-line-height-xl)}.bds-typography--display.bds-typography--size-md{font-size:var(--boreal-typography-font-size-2xl);line-height:var(--boreal-typography-line-height-2xl)}.bds-typography--display.bds-typography--size-lg{font-size:var(--boreal-typography-font-size-3xl);line-height:var(--boreal-typography-line-height-3xl);font-weight:var(--boreal-typography-font-weight-light)}.bds-typography--display.bds-typography--size-xl{font-size:var(--boreal-typography-font-size-4xl);line-height:var(--boreal-typography-line-height-4xl);font-weight:var(--boreal-typography-font-weight-light)}.bds-typography--heading{font-size:var(--boreal-typography-font-size-lg);line-height:var(--boreal-typography-line-height-lg);font-weight:var(--boreal-typography-font-weight-regular);color:var(--boreal-text-default)}.bds-typography h1.bds-typography--heading{font-weight:var(--boreal-typography-font-weight-regular);font-size:var(--boreal-typography-font-size-4xl);line-height:var(--boreal-typography-line-height-4xl)}.bds-typography h2.bds-typography--heading{font-weight:var(--boreal-typography-font-weight-regular);font-size:var(--boreal-typography-font-size-3xl);line-height:var(--boreal-typography-line-height-3xl)}.bds-typography h3.bds-typography--heading{font-weight:var(--boreal-typography-font-weight-regular);font-size:var(--boreal-typography-font-size-2xl);line-height:var(--boreal-typography-line-height-2xl)}.bds-typography h4.bds-typography--heading{font-weight:var(--boreal-typography-font-weight-regular);font-size:var(--boreal-typography-font-size-xl);line-height:var(--boreal-typography-line-height-xl)}.bds-typography h5.bds-typography--heading{font-weight:var(--boreal-typography-font-weight-regular);font-size:var(--boreal-typography-font-size-lg);line-height:var(--boreal-typography-line-height-lg)}.bds-typography h6.bds-typography--heading{font-size:var(--boreal-typography-font-size-md);font-weight:var(--boreal-typography-font-weight-semibold);line-height:var(--boreal-typography-line-height-md)}.bds-typography--subheading{font-size:var(--boreal-typography-font-size-md);line-height:var(--boreal-typography-line-height-md);font-weight:var(--boreal-typography-font-weight-semibold)}.bds-typography--align-start{text-align:start}.bds-typography--align-center{text-align:center}.bds-typography--align-end{text-align:end}.bds-typography--align-inherit{text-align:inherit}.bds-typography--error{color:var(--boreal-text-danger-base)}.bds-typography--disabled{color:var(--boreal-text-disabled);pointer-events:none;cursor:not-allowed}.bds-typography--disabled .bds-typography__required-indicator{color:var(--boreal-text-danger-light)}.bds-typography--ellipsis{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}.bds-typography--ellipsis-multiline{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;white-space:normal;width:100%}`;
|
|
65
|
+
|
|
66
|
+
const BdsTypography = class {
|
|
67
|
+
constructor(hostRef) {
|
|
68
|
+
index.registerInstance(this, hostRef);
|
|
69
|
+
this.inheritedAttributes = {};
|
|
70
|
+
/** Typography visual variant. */
|
|
71
|
+
this.variant = VARIANT_TYPOGRAPHY.DISPLAY;
|
|
72
|
+
/** Typography size token. */
|
|
73
|
+
this.size = SIZES.M;
|
|
74
|
+
/** Visual state (if supported by variant). */
|
|
75
|
+
this.state = attributes.STATES.DEFAULT;
|
|
76
|
+
/** Additional custom CSS class. */
|
|
77
|
+
this.customClass = '';
|
|
78
|
+
/** HTML tag used for rendering. */
|
|
79
|
+
this.element = TAG_ELEMENT.P;
|
|
80
|
+
/** Text alignment. */
|
|
81
|
+
this.align = ALIGNMENT.START;
|
|
82
|
+
/** Enables text ellipsis. */
|
|
83
|
+
this.ellipsis = false;
|
|
84
|
+
/** Max lines when ellipsis is enabled. */
|
|
85
|
+
this.maxLines = 1;
|
|
86
|
+
/** Tooltip text (variant must support it). */
|
|
87
|
+
this.tooltipText = '';
|
|
88
|
+
/** Marks the field as required. */
|
|
89
|
+
this.isRequired = false;
|
|
90
|
+
/** For attribute when rendered as a label. */
|
|
91
|
+
this.htmlFor = undefined;
|
|
92
|
+
/** Link href when rendered as anchor. */
|
|
93
|
+
this.href = null;
|
|
94
|
+
/** Anchor target. */
|
|
95
|
+
this.target = null;
|
|
96
|
+
/** Enables download behavior for anchor. */
|
|
97
|
+
this.isDownloadable = false;
|
|
98
|
+
/** Suggested download filename. */
|
|
99
|
+
this.filename = FILENAME;
|
|
100
|
+
/** Sanitized href for security. */
|
|
101
|
+
this.sanitizedHref = '';
|
|
102
|
+
}
|
|
103
|
+
async updateSanitizedHref() {
|
|
104
|
+
if (this.getTagName === 'a' && this.href !== null) {
|
|
105
|
+
const { sanitizeUrl } = await Promise.resolve().then(function () { return require('./index-CD9v53WJ.js'); }).then(function (n) { return n.index; });
|
|
106
|
+
this.sanitizedHref = sanitizeUrl(this.href);
|
|
107
|
+
}
|
|
108
|
+
else
|
|
109
|
+
this.sanitizedHref = '';
|
|
110
|
+
}
|
|
111
|
+
async componentWillLoad() {
|
|
112
|
+
if (this.getTagName === TAG_ELEMENT.A && this.href !== null)
|
|
113
|
+
await this.updateSanitizedHref();
|
|
114
|
+
this.inheritedAttributes = {
|
|
115
|
+
...attributes.inheritAriaAttributes(this.el),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
get getTagName() {
|
|
119
|
+
if (this.variant === VARIANT_TYPOGRAPHY.LINK)
|
|
120
|
+
return TAG_ELEMENT.A;
|
|
121
|
+
return this.element.toLowerCase();
|
|
122
|
+
}
|
|
123
|
+
getVariantConfig() {
|
|
124
|
+
return VARIANT_CONFIG[this.variant] ?? {};
|
|
125
|
+
}
|
|
126
|
+
getAccessibilityTags() {
|
|
127
|
+
const { isRequired = null } = this.getVariantConfig();
|
|
128
|
+
const isInteractiveTag = ['a', 'label'].includes(this.getTagName);
|
|
129
|
+
return {
|
|
130
|
+
'aria-required': this.isRequired && isRequired,
|
|
131
|
+
'aria-disabled': this.state === attributes.STATES.DISABLED && isInteractiveTag,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
getVariantStateStyles() {
|
|
135
|
+
const config = this.getVariantConfig();
|
|
136
|
+
return {
|
|
137
|
+
[`bds-typography--${this.variant}`]: true,
|
|
138
|
+
[`bds-typography--align-${this.align}`]: true,
|
|
139
|
+
[`bds-typography--${this.state}`]: !!(config?.states && config?.states.includes(this.state)),
|
|
140
|
+
[`bds-typography--size-${this.size}`]: !!(config?.size && config?.size.includes(this.size)),
|
|
141
|
+
'bds-typography--required': !!(config?.isRequired && this.isRequired),
|
|
142
|
+
'bds-typography--ellipsis': this.ellipsis && this.maxLines <= 1,
|
|
143
|
+
'bds-typography--ellipsis-multiline': this.ellipsis && this.maxLines > 1,
|
|
144
|
+
[this.customClass]: this.customClass !== '',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
render() {
|
|
148
|
+
const TagName = this.getTagName;
|
|
149
|
+
const attributes = {
|
|
150
|
+
...getAttributesByTag(this, TagName),
|
|
151
|
+
...this.inheritedAttributes,
|
|
152
|
+
...this.getAccessibilityTags(),
|
|
153
|
+
};
|
|
154
|
+
const classes = this.getVariantStateStyles();
|
|
155
|
+
const { canUseTooltip = null, isRequired = null } = this.getVariantConfig();
|
|
156
|
+
return (index.h(index.Host, { key: '6091692b1cb6bf1d3295f0834c8d25425633d65a', class: "bds-typography" }, index.h(TagName, { key: '0cc91c35fa1cc36c99101a79fae0c8b5cf44de43', class: classes, style: { webkitLineClamp: this.maxLines }, ...attributes }, index.h("slot", { key: '973848fba8211cb5ef869e0e48fb1806bd5efdec' }), this.isRequired && isRequired && (index.h("em", { key: 'dd89574e9dedd55905ae4c7bcd57604f26fbd03b', class: "bds-typography__required-indicator", "aria-hidden": "true" }, "*")), this.tooltipText && canUseTooltip && index.h("em", { key: '473b0de17bd095b97d54d24d2f3aa75f8a8e4922', class: "bds-typography__info-icon bds-icon-info-circle" }))));
|
|
157
|
+
}
|
|
158
|
+
get el() { return index.getElement(this); }
|
|
159
|
+
static get watchers() { return {
|
|
160
|
+
"href": [{
|
|
161
|
+
"updateSanitizedHref": 0
|
|
162
|
+
}]
|
|
163
|
+
}; }
|
|
164
|
+
};
|
|
165
|
+
BdsTypography.style = bdsTypographyCss();
|
|
166
|
+
|
|
167
|
+
exports.bds_typography = BdsTypography;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-Cdb66Tqj.js');
|
|
4
|
+
var appGlobals = require('./app-globals-V2Kpy_OQ.js');
|
|
5
|
+
|
|
6
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
|
+
/*
|
|
8
|
+
Stencil Client Patch Browser v4.42.1 | MIT Licensed | https://stenciljs.com
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
var patchBrowser = () => {
|
|
12
|
+
{
|
|
13
|
+
patchCloneNodeFix(index.H.prototype);
|
|
14
|
+
}
|
|
15
|
+
const importMeta = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('boreal-web-components.cjs.js', document.baseURI).href));
|
|
16
|
+
const opts = {};
|
|
17
|
+
if (importMeta !== "") {
|
|
18
|
+
opts.resourcesUrl = new URL(".", importMeta).href;
|
|
19
|
+
}
|
|
20
|
+
return index.promiseResolve(opts);
|
|
21
|
+
};
|
|
22
|
+
var patchCloneNodeFix = (HTMLElementPrototype) => {
|
|
23
|
+
const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;
|
|
24
|
+
HTMLElementPrototype.cloneNode = function(deep) {
|
|
25
|
+
if (this.nodeName === "TEMPLATE") {
|
|
26
|
+
return nativeCloneNodeFn.call(this, deep);
|
|
27
|
+
}
|
|
28
|
+
const clonedNode = nativeCloneNodeFn.call(this, false);
|
|
29
|
+
const srcChildNodes = this.childNodes;
|
|
30
|
+
if (deep) {
|
|
31
|
+
for (let i = 0; i < srcChildNodes.length; i++) {
|
|
32
|
+
if (srcChildNodes[i].nodeType !== 2) {
|
|
33
|
+
clonedNode.appendChild(srcChildNodes[i].cloneNode(true));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return clonedNode;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
patchBrowser().then(async (options) => {
|
|
42
|
+
await appGlobals.globalScripts();
|
|
43
|
+
return index.bootstrapLazy([["bds-banner.cjs",[[260,"bds-banner",{"idComponent":[1,"id-component"],"variant":[1],"enableClose":[4,"enable-close"],"isClosing":[32],"isOpen":[32],"closeBanner":[64]}]]],["bds-typography.cjs",[[260,"bds-typography",{"variant":[513],"size":[513],"state":[513],"customClass":[1,"custom-class"],"element":[1],"align":[1],"ellipsis":[4],"maxLines":[2,"max-lines"],"tooltipText":[1,"tooltip-text"],"isRequired":[516,"is-required"],"htmlFor":[1,"html-for"],"href":[1],"target":[1],"isDownloadable":[4,"is-downloadable"],"filename":[1],"sanitizedHref":[32]},null,{"href":[{"updateSanitizedHref":0}]}]]],["my-component.cjs",[[0,"my-component",{"first":[1],"middle":[1],"last":[1]}]]]], options);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
exports.setNonce = index.setNonce;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _mergeNamespaces(n, m) {
|
|
4
|
+
m.forEach(function (e) {
|
|
5
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
6
|
+
if (k !== 'default' && !(k in n)) {
|
|
7
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
8
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return e[k]; }
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
return Object.freeze(n);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var dist = {};
|
|
19
|
+
|
|
20
|
+
var constants = {};
|
|
21
|
+
|
|
22
|
+
var hasRequiredConstants;
|
|
23
|
+
|
|
24
|
+
function requireConstants () {
|
|
25
|
+
if (hasRequiredConstants) return constants;
|
|
26
|
+
hasRequiredConstants = 1;
|
|
27
|
+
Object.defineProperty(constants, "__esModule", { value: true });
|
|
28
|
+
constants.BLANK_URL = constants.relativeFirstCharacters = constants.whitespaceEscapeCharsRegex = constants.urlSchemeRegex = constants.ctrlCharactersRegex = constants.htmlCtrlEntityRegex = constants.htmlEntitiesRegex = constants.invalidProtocolRegex = void 0;
|
|
29
|
+
constants.invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im;
|
|
30
|
+
constants.htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g;
|
|
31
|
+
constants.htmlCtrlEntityRegex = /&(newline|tab);/gi;
|
|
32
|
+
constants.ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim;
|
|
33
|
+
constants.urlSchemeRegex = /^.+(:|:)/gim;
|
|
34
|
+
constants.whitespaceEscapeCharsRegex = /(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;
|
|
35
|
+
constants.relativeFirstCharacters = [".", "/"];
|
|
36
|
+
constants.BLANK_URL = "about:blank";
|
|
37
|
+
return constants;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
var hasRequiredDist;
|
|
41
|
+
|
|
42
|
+
function requireDist () {
|
|
43
|
+
if (hasRequiredDist) return dist;
|
|
44
|
+
hasRequiredDist = 1;
|
|
45
|
+
Object.defineProperty(dist, "__esModule", { value: true });
|
|
46
|
+
dist.sanitizeUrl = sanitizeUrl;
|
|
47
|
+
var constants_1 = requireConstants();
|
|
48
|
+
function isRelativeUrlWithoutProtocol(url) {
|
|
49
|
+
return constants_1.relativeFirstCharacters.indexOf(url[0]) > -1;
|
|
50
|
+
}
|
|
51
|
+
function decodeHtmlCharacters(str) {
|
|
52
|
+
var removedNullByte = str.replace(constants_1.ctrlCharactersRegex, "");
|
|
53
|
+
return removedNullByte.replace(constants_1.htmlEntitiesRegex, function (match, dec) {
|
|
54
|
+
return String.fromCharCode(dec);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function isValidUrl(url) {
|
|
58
|
+
return URL.canParse(url);
|
|
59
|
+
}
|
|
60
|
+
function decodeURI(uri) {
|
|
61
|
+
try {
|
|
62
|
+
return decodeURIComponent(uri);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
// Ignoring error
|
|
66
|
+
// It is possible that the URI contains a `%` not associated
|
|
67
|
+
// with URI/URL-encoding.
|
|
68
|
+
return uri;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function sanitizeUrl(url) {
|
|
72
|
+
if (!url) {
|
|
73
|
+
return constants_1.BLANK_URL;
|
|
74
|
+
}
|
|
75
|
+
var charsToDecode;
|
|
76
|
+
var decodedUrl = decodeURI(url.trim());
|
|
77
|
+
do {
|
|
78
|
+
decodedUrl = decodeHtmlCharacters(decodedUrl)
|
|
79
|
+
.replace(constants_1.htmlCtrlEntityRegex, "")
|
|
80
|
+
.replace(constants_1.ctrlCharactersRegex, "")
|
|
81
|
+
.replace(constants_1.whitespaceEscapeCharsRegex, "")
|
|
82
|
+
.trim();
|
|
83
|
+
decodedUrl = decodeURI(decodedUrl);
|
|
84
|
+
charsToDecode =
|
|
85
|
+
decodedUrl.match(constants_1.ctrlCharactersRegex) ||
|
|
86
|
+
decodedUrl.match(constants_1.htmlEntitiesRegex) ||
|
|
87
|
+
decodedUrl.match(constants_1.htmlCtrlEntityRegex) ||
|
|
88
|
+
decodedUrl.match(constants_1.whitespaceEscapeCharsRegex);
|
|
89
|
+
} while (charsToDecode && charsToDecode.length > 0);
|
|
90
|
+
var sanitizedUrl = decodedUrl;
|
|
91
|
+
if (!sanitizedUrl) {
|
|
92
|
+
return constants_1.BLANK_URL;
|
|
93
|
+
}
|
|
94
|
+
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
|
95
|
+
return sanitizedUrl;
|
|
96
|
+
}
|
|
97
|
+
// Remove any leading whitespace before checking the URL scheme
|
|
98
|
+
var trimmedUrl = sanitizedUrl.trimStart();
|
|
99
|
+
var urlSchemeParseResults = trimmedUrl.match(constants_1.urlSchemeRegex);
|
|
100
|
+
if (!urlSchemeParseResults) {
|
|
101
|
+
return sanitizedUrl;
|
|
102
|
+
}
|
|
103
|
+
var urlScheme = urlSchemeParseResults[0].toLowerCase().trim();
|
|
104
|
+
if (constants_1.invalidProtocolRegex.test(urlScheme)) {
|
|
105
|
+
return constants_1.BLANK_URL;
|
|
106
|
+
}
|
|
107
|
+
var backSanitized = trimmedUrl.replace(/\\/g, "/");
|
|
108
|
+
// Handle special cases for mailto: and custom deep-link protocols
|
|
109
|
+
if (urlScheme === "mailto:" || urlScheme.includes("://")) {
|
|
110
|
+
return backSanitized;
|
|
111
|
+
}
|
|
112
|
+
// For http and https URLs, perform additional validation
|
|
113
|
+
if (urlScheme === "http:" || urlScheme === "https:") {
|
|
114
|
+
if (!isValidUrl(backSanitized)) {
|
|
115
|
+
return constants_1.BLANK_URL;
|
|
116
|
+
}
|
|
117
|
+
var url_1 = new URL(backSanitized);
|
|
118
|
+
url_1.protocol = url_1.protocol.toLowerCase();
|
|
119
|
+
url_1.hostname = url_1.hostname.toLowerCase();
|
|
120
|
+
return url_1.toString();
|
|
121
|
+
}
|
|
122
|
+
return backSanitized;
|
|
123
|
+
}
|
|
124
|
+
return dist;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
var distExports = requireDist();
|
|
128
|
+
|
|
129
|
+
var index = /*#__PURE__*/_mergeNamespaces({
|
|
130
|
+
__proto__: null
|
|
131
|
+
}, [distExports]);
|
|
132
|
+
|
|
133
|
+
exports.index = index;
|