@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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { arrow, computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
2
|
+
import { Logger } from "../logger/Logger";
|
|
3
|
+
class FloatingAdapter {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor of the adapter.
|
|
6
|
+
* @param logger Inject the logger service to normalize the error messages.
|
|
7
|
+
*/
|
|
8
|
+
constructor(logger) {
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Compute the position of the floating element making it responsive to the reference element.
|
|
13
|
+
* @param {HTMLElement} reference The reference element to position the floating element. Could be a trigger element or a container.
|
|
14
|
+
* @param {HTMLElement} floating The floating element to position, Will be positioned relative to the reference element.
|
|
15
|
+
* @param {PositioningOptions} options Manage the logic of the positioning and some props that are own of the Floating UI library.
|
|
16
|
+
* @returns {Promise<PositioningResult>} The positioning result with the position and the placement.
|
|
17
|
+
*/
|
|
18
|
+
async computePosition(reference, floating, options) {
|
|
19
|
+
if (reference === undefined || reference === null)
|
|
20
|
+
this.logger.error('FloatingAdapter.computePosition', 'Reference element is required for positioning.');
|
|
21
|
+
if (floating === undefined || floating === null)
|
|
22
|
+
this.logger.error('FloatingAdapter.computePosition', 'Floating element is required for positioning.');
|
|
23
|
+
const { placement, offset: offsetValue, flip: enableFlip, shift: enableShift, arrow: arrowElement, strategy, } = options;
|
|
24
|
+
const middleware = [offset(offsetValue)];
|
|
25
|
+
if (enableFlip)
|
|
26
|
+
middleware.push(flip());
|
|
27
|
+
if (enableShift)
|
|
28
|
+
middleware.push(shift());
|
|
29
|
+
if (arrowElement !== undefined || arrowElement !== null)
|
|
30
|
+
middleware.push(arrow({ element: arrowElement }));
|
|
31
|
+
const result = await computePosition(reference, floating, {
|
|
32
|
+
placement,
|
|
33
|
+
middleware,
|
|
34
|
+
strategy,
|
|
35
|
+
})
|
|
36
|
+
.catch((err) => {
|
|
37
|
+
this.logger.error('FloatingAdapter.computePosition', err.message);
|
|
38
|
+
})
|
|
39
|
+
.then((res) => {
|
|
40
|
+
return res;
|
|
41
|
+
});
|
|
42
|
+
const { x, y, placement: computedPlacement, middlewareData } = result;
|
|
43
|
+
return {
|
|
44
|
+
x,
|
|
45
|
+
y,
|
|
46
|
+
placement: computedPlacement,
|
|
47
|
+
middlewareData,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Apply the position of the floating element to the element.
|
|
52
|
+
* @param {HTMLElement} element Is the floating element to apply the position.
|
|
53
|
+
* @param {PositioningResult} result Is the positioning result with the position and the placement.
|
|
54
|
+
*/
|
|
55
|
+
applyPosition(element, result) {
|
|
56
|
+
if (element === undefined || element === null)
|
|
57
|
+
this.logger.error('FloatingAdapter.applyPosition', 'Element is required to apply positioning.');
|
|
58
|
+
element.style.left = `${result.x}px`;
|
|
59
|
+
element.style.top = `${result.y}px`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Export a simple class to use the adapter.
|
|
64
|
+
* This class is responsible for handling the positioning logic exported to the mixin or some other floating logic.
|
|
65
|
+
*/
|
|
66
|
+
export class PositioningEngine extends FloatingAdapter {
|
|
67
|
+
constructor() {
|
|
68
|
+
const logger = new Logger();
|
|
69
|
+
super(logger);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default implementation of the logger service.
|
|
3
|
+
* This class is responsible for logging errors, warnings and messages to the DevTools console.
|
|
4
|
+
*/
|
|
5
|
+
export class Logger {
|
|
6
|
+
/**
|
|
7
|
+
* Throw a normalized error with the component name and the message.
|
|
8
|
+
* @param component Is the name of the component that is throwing the error.
|
|
9
|
+
* @param message Is the message of the error.
|
|
10
|
+
* @throws Error with the component name and the message.
|
|
11
|
+
* @example
|
|
12
|
+
* const logger = new Logger();
|
|
13
|
+
* logger.error('MyComponent', 'This is an error');
|
|
14
|
+
* // Throws an error with the message "[MyComponent]: This is an error"
|
|
15
|
+
*/
|
|
16
|
+
error(component, message) {
|
|
17
|
+
throw new Error(`[${component}]: ${message}`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Log a warning with the component name and the message.
|
|
21
|
+
* @param component Is the name of the component that is throwing the warning.
|
|
22
|
+
* @param message Is the message of the warning.
|
|
23
|
+
* @example
|
|
24
|
+
* const logger = new Logger();
|
|
25
|
+
* logger.warn('MyComponent', 'This is a warning');
|
|
26
|
+
* // Logs a warning with the message "[MyComponent]: This is a warning"
|
|
27
|
+
*/
|
|
28
|
+
warn(component, message) {
|
|
29
|
+
console.warn(`[${component}]: ${message}`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Log a message with the component name and the message.
|
|
33
|
+
* @param component Is the name of the component that is logging the message.
|
|
34
|
+
* @param message Is the message of the message.
|
|
35
|
+
* @example
|
|
36
|
+
* const logger = new Logger();
|
|
37
|
+
* logger.log('MyComponent', 'This is a message');
|
|
38
|
+
* // Logs a message with the message "[MyComponent]: This is a message"
|
|
39
|
+
* @example
|
|
40
|
+
* const logger = new Logger();
|
|
41
|
+
* logger.log('MyComponent', 'This is a message');
|
|
42
|
+
* // Logs a message with the message "[MyComponent]: This is a message"
|
|
43
|
+
*/
|
|
44
|
+
log(component, message) {
|
|
45
|
+
console.log(`[${component}]: ${message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Define the possible positions of the floating element.
|
|
3
|
+
* This could be used to position the floating element relative to the trigger element.
|
|
4
|
+
* Are blocked posittions like 'top-start', 'top-end', 'bottom-start', and 'bottom-end'.
|
|
5
|
+
*/
|
|
6
|
+
export const POSITION = {
|
|
7
|
+
TOP: 'top',
|
|
8
|
+
BOTTOM: 'bottom',
|
|
9
|
+
LEFT: 'left',
|
|
10
|
+
RIGHT: 'right',
|
|
11
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const STATES = {
|
|
2
|
+
DEFAULT: 'default',
|
|
3
|
+
ERROR: 'error',
|
|
4
|
+
DISABLED: 'disabled',
|
|
5
|
+
HOVER: 'hover',
|
|
6
|
+
ACTIVE: 'active',
|
|
7
|
+
FOCUS: 'focus',
|
|
8
|
+
VISITED: 'visited',
|
|
9
|
+
};
|
|
10
|
+
export const PROCESS_STATUS = {
|
|
11
|
+
NEUTRAL: 'neutral',
|
|
12
|
+
PENDING: 'pending',
|
|
13
|
+
IN_PROGRESS: 'in-progress',
|
|
14
|
+
COMPLETE: 'complete',
|
|
15
|
+
CANCEL: 'cancel',
|
|
16
|
+
};
|
|
17
|
+
export const STATUS_VARIANT = {
|
|
18
|
+
INFO: 'info',
|
|
19
|
+
SUCCESS: 'success',
|
|
20
|
+
WARNING: 'warning',
|
|
21
|
+
DANGER: 'danger',
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taken from StencilJS Ionic team
|
|
3
|
+
* This helper pass the attributes passed to components directly to the inner element
|
|
4
|
+
* e.g. <my-component aria-hidden="true">Text</my-component>
|
|
5
|
+
* will pass the aria-hidden to the inner element inside my-component
|
|
6
|
+
* <span { ...myComponentAttr }>Hidden</span>
|
|
7
|
+
*/
|
|
8
|
+
export const inheritAttributes = (el, attributes = []) => {
|
|
9
|
+
const attributeObject = {};
|
|
10
|
+
attributes.forEach(attr => {
|
|
11
|
+
if (el.hasAttribute(attr)) {
|
|
12
|
+
const value = el.getAttribute(attr);
|
|
13
|
+
if (value !== null) {
|
|
14
|
+
attributeObject[attr] = value;
|
|
15
|
+
}
|
|
16
|
+
el.removeAttribute(attr);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return attributeObject;
|
|
20
|
+
};
|
|
21
|
+
const ariaAttributes = [
|
|
22
|
+
'role',
|
|
23
|
+
'aria-activedescendant',
|
|
24
|
+
'aria-atomic',
|
|
25
|
+
'aria-autocomplete',
|
|
26
|
+
'aria-braillelabel',
|
|
27
|
+
'aria-brailleroledescription',
|
|
28
|
+
'aria-busy',
|
|
29
|
+
'aria-checked',
|
|
30
|
+
'aria-colcount',
|
|
31
|
+
'aria-colindex',
|
|
32
|
+
'aria-colindextext',
|
|
33
|
+
'aria-colspan',
|
|
34
|
+
'aria-controls',
|
|
35
|
+
'aria-current',
|
|
36
|
+
'aria-describedby',
|
|
37
|
+
'aria-description',
|
|
38
|
+
'aria-details',
|
|
39
|
+
'aria-disabled',
|
|
40
|
+
'aria-errormessage',
|
|
41
|
+
'aria-expanded',
|
|
42
|
+
'aria-flowto',
|
|
43
|
+
'aria-haspopup',
|
|
44
|
+
'aria-hidden',
|
|
45
|
+
'aria-invalid',
|
|
46
|
+
'aria-keyshortcuts',
|
|
47
|
+
'aria-label',
|
|
48
|
+
'aria-labelledby',
|
|
49
|
+
'aria-level',
|
|
50
|
+
'aria-live',
|
|
51
|
+
'aria-multiline',
|
|
52
|
+
'aria-multiselectable',
|
|
53
|
+
'aria-orientation',
|
|
54
|
+
'aria-owns',
|
|
55
|
+
'aria-placeholder',
|
|
56
|
+
'aria-posinset',
|
|
57
|
+
'aria-pressed',
|
|
58
|
+
'aria-readonly',
|
|
59
|
+
'aria-relevant',
|
|
60
|
+
'aria-required',
|
|
61
|
+
'aria-roledescription',
|
|
62
|
+
'aria-rowcount',
|
|
63
|
+
'aria-rowindex',
|
|
64
|
+
'aria-rowindextext',
|
|
65
|
+
'aria-rowspan',
|
|
66
|
+
'aria-selected',
|
|
67
|
+
'aria-setsize',
|
|
68
|
+
'aria-sort',
|
|
69
|
+
'aria-valuemax',
|
|
70
|
+
'aria-valuemin',
|
|
71
|
+
'aria-valuenow',
|
|
72
|
+
'aria-valuetext',
|
|
73
|
+
];
|
|
74
|
+
export const inheritAriaAttributes = (el, ignoreList) => {
|
|
75
|
+
let attributesToInherit = ariaAttributes;
|
|
76
|
+
if (ignoreList && ignoreList.length > 0) {
|
|
77
|
+
attributesToInherit = attributesToInherit.filter(attr => !ignoreList.includes(attr));
|
|
78
|
+
}
|
|
79
|
+
return inheritAttributes(el, attributesToInherit);
|
|
80
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './attributes';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralize list of events to add listeners to the component.
|
|
3
|
+
* Add Native or Custom events to the `EVENTS` object.
|
|
4
|
+
* This prevent typing errors when using the event name in the component, creating listeners, etc.
|
|
5
|
+
*/
|
|
6
|
+
export const EVENTS = {
|
|
7
|
+
Focus: 'focus',
|
|
8
|
+
Blur: 'blur',
|
|
9
|
+
Click: 'click',
|
|
10
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default keyboard keys.
|
|
3
|
+
* Add more keys to the `KEYBOARD` object to add more keyboard shortcuts.
|
|
4
|
+
* This prevents key name typing errors and provides a centralized definition of the keys available for implementation.
|
|
5
|
+
* Can use this page to find the keycodes: https://keycode.info/
|
|
6
|
+
*/
|
|
7
|
+
export const KEYBOARD = {
|
|
8
|
+
Enter: {
|
|
9
|
+
key: 'Enter',
|
|
10
|
+
code: 13,
|
|
11
|
+
},
|
|
12
|
+
Escape: {
|
|
13
|
+
key: 'Escape',
|
|
14
|
+
code: 32,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects whether a slot has assigned content in the host element's light DOM.
|
|
3
|
+
*
|
|
4
|
+
* Whitespace-only text nodes and comment nodes are ignored — only element nodes
|
|
5
|
+
* and non-empty text nodes are considered meaningful slot content.
|
|
6
|
+
*
|
|
7
|
+
* @param el - The host element to query.
|
|
8
|
+
* @param slotName - Named slot to check. Omit to check the default slot.
|
|
9
|
+
* @returns `true` if the slot has meaningful content, `false` otherwise.
|
|
10
|
+
*/
|
|
11
|
+
export function hasSlotContent(el, slotName) {
|
|
12
|
+
if (slotName !== undefined) {
|
|
13
|
+
return el.querySelector(`[slot="${slotName}"]`) !== null;
|
|
14
|
+
}
|
|
15
|
+
return Array.from(el.childNodes).some(node => {
|
|
16
|
+
if (node instanceof Element)
|
|
17
|
+
return node.slot === '';
|
|
18
|
+
if (node.nodeType === Node.TEXT_NODE)
|
|
19
|
+
return node.textContent?.trim() !== '';
|
|
20
|
+
return false;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './elements';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './internals';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the component's current value with the browser's form machinery.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `ElementInternals.setFormValue()` so the value appears in `FormData`
|
|
5
|
+
* under the component's `name` attribute when the form is submitted.
|
|
6
|
+
* Pass `null` to remove the component's contribution from `FormData`
|
|
7
|
+
* (e.g. an unchecked checkbox).
|
|
8
|
+
*
|
|
9
|
+
* @param internals - The component's `ElementInternals` instance (from `@AttachInternals()`).
|
|
10
|
+
* @param value - The value to register, or `null` to deregister.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Register a string value on every value change
|
|
15
|
+
* @Watch('value')
|
|
16
|
+
* onValueChange(next: string) {
|
|
17
|
+
* setFormValue(this.internals, next);
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // Deregister when unchecked
|
|
21
|
+
* setFormValue(this.internals, null);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function setFormValue(internals, value) {
|
|
25
|
+
internals.setFormValue(value);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Runs an array of validators against the host element and reports the combined
|
|
29
|
+
* result to `ElementInternals.setValidity()`.
|
|
30
|
+
*
|
|
31
|
+
* All validators are evaluated regardless of order. The first failing validator's
|
|
32
|
+
* message is used as the validation message, matching native browser behaviour
|
|
33
|
+
* (one message surfaced at a time). When all validators pass, the component is
|
|
34
|
+
* marked valid and any previous invalid state is cleared.
|
|
35
|
+
*
|
|
36
|
+
* @param internals - The component's `ElementInternals` instance (from `@AttachInternals()`).
|
|
37
|
+
* @param validators - Array of `IFormValidator` objects to evaluate.
|
|
38
|
+
* @param el - The host element passed to each validator's `isValid` function.
|
|
39
|
+
* @returns `true` if all validators pass, `false` if any fail.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* private get validators(): IFormValidator[] {
|
|
44
|
+
* return [
|
|
45
|
+
* {
|
|
46
|
+
* key: 'valueMissing',
|
|
47
|
+
* isValid: (el) => !(el as BdsTextField).required || (el as BdsTextField).value !== '',
|
|
48
|
+
* message: 'This field is required.',
|
|
49
|
+
* },
|
|
50
|
+
* {
|
|
51
|
+
* key: 'tooShort',
|
|
52
|
+
* isValid: (el) => {
|
|
53
|
+
* const { value, minLength } = el as BdsTextField;
|
|
54
|
+
* return minLength === undefined || value.length >= minLength;
|
|
55
|
+
* },
|
|
56
|
+
* message: `Minimum length not reached.`,
|
|
57
|
+
* },
|
|
58
|
+
* ];
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* private updateValidity() {
|
|
62
|
+
* runValidators(this.internals, this.validators, this.el);
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export function runValidators(internals, validators, el) {
|
|
67
|
+
const flags = {};
|
|
68
|
+
let firstMessage = '';
|
|
69
|
+
for (const { key, isValid, message } of validators) {
|
|
70
|
+
if (!isValid(el)) {
|
|
71
|
+
flags[key] = true;
|
|
72
|
+
if (firstMessage === '')
|
|
73
|
+
firstMessage = message;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const valid = Object.keys(flags).length === 0;
|
|
77
|
+
internals.setValidity(valid ? {} : flags, firstMessage);
|
|
78
|
+
return valid;
|
|
79
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure the given component instance has an auto-generated id if one wasn't provided.
|
|
3
|
+
* Designed to be called from `componentWillLoad` on a Stencil component.
|
|
4
|
+
*/
|
|
5
|
+
export function createId(component) {
|
|
6
|
+
if (!component.idComponent)
|
|
7
|
+
component.idComponent = `bds-${Math.random().toString(36).substr(2, 9)}`;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Components can spread the result into their host.
|
|
11
|
+
*/
|
|
12
|
+
export function getBaseAttributes(component) {
|
|
13
|
+
createId(component);
|
|
14
|
+
return {
|
|
15
|
+
id: component.idComponent,
|
|
16
|
+
};
|
|
17
|
+
}
|