@ongov/ontario-design-system-component-library 4.3.0 → 5.0.0-alpha.1
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/dist/cjs/index-88d5cf20.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{ontario-accordion_43.cjs.entry.js → ontario-accordion_44.cjs.entry.js} +738 -296
- package/dist/cjs/ontario-accordion_44.cjs.entry.js.map +1 -0
- package/dist/cjs/ontario-design-system-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/ontario-card/ontario-card-types.js +29 -2
- package/dist/collection/components/ontario-card/ontario-card-types.js.map +1 -1
- package/dist/collection/components/ontario-card/ontario-card.css +257 -31
- package/dist/collection/components/ontario-card/ontario-card.js +104 -80
- package/dist/collection/components/ontario-card/ontario-card.js.map +1 -1
- package/dist/collection/components/ontario-card/test/ontario-cards.spec.js +23 -13
- package/dist/collection/components/ontario-card/test/ontario-cards.spec.js.map +1 -1
- package/dist/collection/components/ontario-header/ontario-header.js +17 -3
- package/dist/collection/components/ontario-header/ontario-header.js.map +1 -1
- package/dist/collection/components/ontario-header/service-ontario-header.css +0 -3
- package/dist/collection/components/ontario-header/test/ontario-header.spec.js +3 -3
- package/dist/collection/components/ontario-header/test/ontario-header.spec.js.map +1 -1
- package/dist/collection/components/ontario-language-toggle/ontario-language-toggle.js +193 -47
- package/dist/collection/components/ontario-language-toggle/ontario-language-toggle.js.map +1 -1
- package/dist/collection/components/ontario-language-toggle/test/ontario-language-toggle.spec.js +16 -3
- package/dist/collection/components/ontario-language-toggle/test/ontario-language-toggle.spec.js.map +1 -1
- package/dist/collection/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
- package/dist/collection/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
- package/dist/collection/components/ontario-search-box/ontario-search-box.css +823 -0
- package/dist/collection/components/ontario-search-box/ontario-search-box.js +584 -0
- package/dist/collection/components/ontario-search-box/ontario-search-box.js.map +1 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js +20 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js.map +1 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js +19 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js.map +1 -0
- package/dist/collection/components/ontario-step-indicator/ontario-step-indicator.js +5 -5
- package/dist/collection/components/ontario-table/ontario-table.js +5 -5
- package/dist/collection/components/ontario-textarea/ontario-textarea.js +3 -3
- package/dist/collection/i18n/global.i18n.json +172 -162
- package/dist/collection/utils/common/input/input.js +3 -0
- package/dist/collection/utils/common/input/input.js.map +1 -1
- package/dist/collection/utils/common/input-caption/input-caption.js +5 -3
- package/dist/collection/utils/common/input-caption/input-caption.js.map +1 -1
- package/dist/collection/utils/common/language-types.js +1 -1
- package/dist/collection/utils/common/language-types.js.map +1 -1
- package/dist/collection/utils/helper/utils-types.js +2 -0
- package/dist/collection/utils/helper/utils-types.js.map +1 -0
- package/dist/collection/utils/helper/utils.js +26 -0
- package/dist/collection/utils/helper/utils.js.map +1 -1
- package/dist/components/error-message.js +1 -324
- package/dist/components/error-message.js.map +1 -1
- package/dist/components/event-handler.js +330 -0
- package/dist/components/event-handler.js.map +1 -0
- package/dist/components/global.i18n.js +184 -173
- package/dist/components/global.i18n.js.map +1 -1
- package/dist/components/input.js +3 -0
- package/dist/components/input.js.map +1 -1
- package/dist/components/ontario-card.js +118 -66
- package/dist/components/ontario-card.js.map +1 -1
- package/dist/components/ontario-checkboxes.js +2 -1
- package/dist/components/ontario-checkboxes.js.map +1 -1
- package/dist/components/ontario-date-input.js +2 -1
- package/dist/components/ontario-date-input.js.map +1 -1
- package/dist/components/ontario-dropdown-list.js +2 -1
- package/dist/components/ontario-dropdown-list.js.map +1 -1
- package/dist/components/ontario-header.js +13 -7
- package/dist/components/ontario-header.js.map +1 -1
- package/dist/components/ontario-icon-search2.js +6 -0
- package/dist/components/ontario-icon-search2.js.map +1 -0
- package/dist/components/ontario-input.js +2 -1
- package/dist/components/ontario-input.js.map +1 -1
- package/dist/components/ontario-language-toggle2.js +180 -37
- package/dist/components/ontario-language-toggle2.js.map +1 -1
- package/dist/components/ontario-radio-buttons.js +2 -1
- package/dist/components/ontario-radio-buttons.js.map +1 -1
- package/dist/components/ontario-search-box.d.ts +11 -0
- package/dist/components/ontario-search-box.js +269 -0
- package/dist/components/ontario-search-box.js.map +1 -0
- package/dist/components/ontario-step-indicator.js +5 -5
- package/dist/components/ontario-table.js +5 -5
- package/dist/components/ontario-textarea.js +5 -4
- package/dist/components/ontario-textarea.js.map +1 -1
- package/dist/components/utils.js +28 -0
- package/dist/components/utils.js.map +1 -1
- package/dist/esm/index-603026f7.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{ontario-accordion_43.entry.js → ontario-accordion_44.entry.js} +738 -296
- package/dist/esm/ontario-accordion_44.entry.js.map +1 -0
- package/dist/esm/ontario-design-system-components.js +1 -1
- package/dist/ontario-design-system-components/i18n/global.i18n.json +172 -162
- package/dist/ontario-design-system-components/ontario-design-system-components.esm.js +1 -1
- package/dist/ontario-design-system-components/ontario-design-system-components.esm.js.map +1 -1
- package/dist/ontario-design-system-components/{p-cff41424.entry.js → p-9c3a1be9.entry.js} +2204 -1918
- package/dist/ontario-design-system-components/p-9c3a1be9.entry.js.map +1 -0
- package/dist/types/components/ontario-card/ontario-card-types.d.ts +4 -4
- package/dist/types/components/ontario-card/ontario-card.d.ts +40 -29
- package/dist/types/components/ontario-header/ontario-header.d.ts +13 -2
- package/dist/types/components/ontario-language-toggle/ontario-language-toggle.d.ts +75 -8
- package/dist/types/components/ontario-search-box/ontario-search-box.d.ts +180 -0
- package/dist/types/components.d.ts +211 -22
- package/dist/types/utils/common/input/input.d.ts +2 -1
- package/dist/types/utils/common/input-caption/input-caption.d.ts +7 -1
- package/dist/types/utils/common/language-types.d.ts +2 -1
- package/dist/types/utils/helper/utils-types.d.ts +2 -0
- package/dist/types/utils/helper/utils.d.ts +21 -0
- package/package.json +3 -3
- package/src/components/ontario-card/ontario-card-types.tsx +33 -4
- package/src/components/ontario-card/ontario-card.scss +59 -38
- package/src/components/ontario-card/ontario-card.tsx +98 -70
- package/src/components/ontario-card/readme.md +57 -27
- package/src/components/ontario-card/test/__snapshots__/ontario-cards.spec.tsx.snap +66 -0
- package/src/components/ontario-card/test/ontario-cards.spec.tsx +27 -13
- package/src/components/ontario-card-collection/readme.md +13 -13
- package/src/components/ontario-checkbox/ontario-checkboxes.scss +0 -1
- package/src/components/ontario-header/ontario-header.tsx +13 -4
- package/src/components/ontario-header/service-ontario-header.scss +0 -4
- package/src/components/ontario-header/test/ontario-header.spec.tsx +3 -3
- package/src/components/ontario-hint-text/readme.md +2 -0
- package/src/components/ontario-language-toggle/ontario-language-toggle.tsx +192 -45
- package/src/components/ontario-language-toggle/readme.md +10 -10
- package/src/components/ontario-language-toggle/test/__snapshots__/ontario-language-toggle.spec.tsx.snap +1 -1
- package/src/components/ontario-language-toggle/test/ontario-language-toggle.spec.tsx +17 -3
- package/src/components/ontario-radio-buttons/ontario-radio-buttons.scss +0 -1
- package/src/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
- package/src/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
- package/src/components/ontario-search-box/ontario-search-box.scss +141 -0
- package/src/components/ontario-search-box/ontario-search-box.tsx +341 -0
- package/src/components/ontario-search-box/readme.md +132 -0
- package/src/components/ontario-search-box/test/__snapshots__/ontario-search-box.spec.tsx.snap +35 -0
- package/src/components/ontario-search-box/test/ontario-search-box.e2e.ts +21 -0
- package/src/components/ontario-search-box/test/ontario-search-box.spec.tsx +22 -0
- package/src/components.d.ts +211 -22
- package/src/french.html +37 -0
- package/src/index.html +292 -38
- package/src/translations/global.i18n.json +172 -162
- package/src/utils/common/input/input.tsx +4 -1
- package/src/utils/common/input-caption/input-caption.tsx +9 -3
- package/src/utils/common/language-types.ts +2 -1
- package/src/utils/helper/utils-types.ts +2 -0
- package/src/utils/helper/utils.ts +30 -0
- package/www/build/ontario-design-system-components.esm.js +1 -1
- package/www/build/ontario-design-system-components.esm.js.map +1 -1
- package/www/build/{p-b61db0f6.js → p-84035ac3.js} +1 -1
- package/www/build/{p-cff41424.entry.js → p-9c3a1be9.entry.js} +2204 -1918
- package/www/build/p-9c3a1be9.entry.js.map +1 -0
- package/www/french.html +37 -0
- package/www/i18n/global.i18n.json +172 -162
- package/www/index.html +266 -38
- package/dist/cjs/ontario-accordion_43.cjs.entry.js.map +0 -1
- package/dist/esm/ontario-accordion_43.entry.js.map +0 -1
- package/dist/ontario-design-system-components/p-cff41424.entry.js.map +0 -1
- package/www/build/p-cff41424.entry.js.map +0 -1
|
@@ -71,4 +71,30 @@ export function isEmpty(str) {
|
|
|
71
71
|
export function retrieveEnumKeys(enumObject) {
|
|
72
72
|
return Object.keys(enumObject).filter(isNumber);
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Prints an array as a comma delimited list, with the last element being preceded by a conjunction.
|
|
76
|
+
* As per ontario.ca content guidelines, there is no Oxford comma.
|
|
77
|
+
*
|
|
78
|
+
* @param {Array<any>} arr - The array that you wish to print.
|
|
79
|
+
* @param {Conjunction} conjunctionType - Whether you want the sentence to end with 'and value.' or 'or value.'
|
|
80
|
+
*
|
|
81
|
+
* @returns {string}
|
|
82
|
+
*/
|
|
83
|
+
export function printArray(arr, conjunctionType = 'and') {
|
|
84
|
+
return [...arr].reduce(
|
|
85
|
+
(text, value, i, array) => text + (i < array.length - 1 ? ', ' : ` ${conjunctionType} `) + value,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Grabs the HTML element of the page.
|
|
90
|
+
*
|
|
91
|
+
* More targetted than document.documentElement as the documentElement could
|
|
92
|
+
* in theory be any element that is the top level. e.g. <div> if the page is not
|
|
93
|
+
* set up to be semantically correct.
|
|
94
|
+
*
|
|
95
|
+
* @returns {HTMLElement}
|
|
96
|
+
*/
|
|
97
|
+
export function getRootHTMLElement() {
|
|
98
|
+
return document.getElementsByTagName('html')[0];
|
|
99
|
+
}
|
|
74
100
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/helper/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/helper/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,MAAM,CAAC,KAAyB,EAAE,MAA0B,EAAE,IAAwB;IACrG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAI,GAAQ,EAAE,GAAY;IAC9D,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,MAAM,EAAE,CAAC;YAC9C,KAAK,EAAE,CAAC;YACR,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAI,OAAY,EAAE,GAAY;IAC/D,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAW,EAAE,OAAiB;IAChE,OAAO,IA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CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,GAA8B;IACrD,OAAO,CAAC,GAAG,IAAI,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,KAAI,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IAClD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,GAAe,EAAE,kBAA+B,KAAK;IAC/E,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,CACrB,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,eAAe,GAAG,CAAC,GAAG,KAAK,CAChG,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB;IACjC,OAAO,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { Conjunction } from './utils-types';\n\nexport function format(first: string | undefined, middle: string | undefined, last: string | undefined): string {\n\treturn (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');\n}\n\nexport function hasMultipleTrueValues<T>(arr: T[], key: keyof T): boolean {\n\tlet count = 0;\n\n\tfor (const obj of arr) {\n\t\tif (obj[key] === true || obj[key] === 'true') {\n\t\t\tcount++;\n\t\t\tif (count > 1) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n\nexport function extractValuesByKey<T>(objects: T[], key: keyof T): Array<T[keyof T]> {\n\treturn objects.map((obj) => obj[key]);\n}\n\nexport function organizeObjectKeys(data: any[], columns: string[]): any[] {\n\treturn data.map((item) => {\n\t\tconst newData: any = {};\n\t\tconst otherKeys: any = {};\n\n\t\t// Iterate through each key in the item\n\t\tObject.keys(item).forEach((key) => {\n\t\t\tif (key === 'data') {\n\t\t\t\t// Organize keys in the 'data' object\n\t\t\t\tcolumns.forEach((column) => {\n\t\t\t\t\tif (column in item.data) {\n\t\t\t\t\t\tnewData[column] = item.data[column];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Preserve other keys\n\t\t\t\totherKeys[key] = item[key];\n\t\t\t}\n\t\t});\n\n\t\treturn { data: newData, ...otherKeys };\n\t});\n}\n\nexport function removeObjectsBySpecificKey<T>(objects: T[], key: keyof T, value: boolean | 'true'): [T[], T[]] {\n\tconst removedObjects: T[] = [];\n\tconst filteredObjects = objects.filter((obj) => {\n\t\tif (obj[key] === value) {\n\t\t\tremovedObjects.push(obj);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t});\n\treturn [filteredObjects, removedObjects];\n}\n\n/**\n * Takes an input value and determines whether or not it is a number.\n *\n * @param {string | number} value - The value you would like to test against.\n *\n * @returns {boolean}\n */\nexport function isNumber(value: string | number): boolean {\n\treturn isNaN(Number(value)) === true;\n}\n\nexport function isEmpty(str: string | undefined | null): boolean {\n\treturn !str || str?.length <= 0;\n}\n\n/**\n * Retrieves the keys from an enum and lists them in an array.\n *\n * @param {object} enumObject - The enum you wish to get the keys of.\n *\n * @returns {string[]}\n */\nexport function retrieveEnumKeys(enumObject: object): string[] {\n\treturn Object.keys(enumObject).filter(isNumber);\n}\n\n/**\n * Prints an array as a comma delimited list, with the last element being preceded by a conjunction.\n * As per ontario.ca content guidelines, there is no Oxford comma.\n *\n * @param {Array<any>} arr - The array that you wish to print.\n * @param {Conjunction} conjunctionType - Whether you want the sentence to end with 'and value.' or 'or value.'\n *\n * @returns {string}\n */\nexport function printArray(arr: Array<any>, conjunctionType: Conjunction = 'and'): string {\n\treturn [...arr].reduce(\n\t\t(text, value, i, array) => text + (i < array.length - 1 ? ', ' : ` ${conjunctionType} `) + value,\n\t);\n}\n\n/**\n * Grabs the HTML element of the page.\n *\n * More targetted than document.documentElement as the documentElement could\n * in theory be any element that is the top level. e.g. <div> if the page is not\n * set up to be semantically correct.\n *\n * @returns {HTMLElement}\n */\nexport function getRootHTMLElement(): HTMLElement {\n\treturn document.getElementsByTagName('html')[0];\n}\n"]}
|
|
@@ -1,329 +1,6 @@
|
|
|
1
1
|
import { h } from '@stencil/core/internal/client';
|
|
2
|
-
import { C as CaptionTypes } from './input-caption.types.js';
|
|
3
|
-
import { C as ConsoleMessageClass } from './console-message.js';
|
|
4
2
|
import { i as isEmpty } from './utils.js';
|
|
5
3
|
|
|
6
|
-
var MessageContentType;
|
|
7
|
-
(function (MessageContentType) {
|
|
8
|
-
MessageContentType['UndefinedCaptionObject'] = 'undefinedCaptionObject';
|
|
9
|
-
MessageContentType['UndefinedCaptionText'] = 'undefinedCaption';
|
|
10
|
-
MessageContentType['EmptyCaptionText'] = 'emptyCaption';
|
|
11
|
-
MessageContentType['UndefinedCaptionType'] = 'undefinedCaptionType';
|
|
12
|
-
MessageContentType['IncorrectCaptionType'] = 'incorrectCaptionType';
|
|
13
|
-
})(MessageContentType || (MessageContentType = {}));
|
|
14
|
-
|
|
15
|
-
class InputCaption {
|
|
16
|
-
/**
|
|
17
|
-
* Set the class members
|
|
18
|
-
* Output a console warning message if the provided `label` type is incorrect
|
|
19
|
-
* @param caption object containing the essential data to configure the input label
|
|
20
|
-
*/
|
|
21
|
-
constructor(componentTagName, caption, translations, language, isLegend = false, required = false) {
|
|
22
|
-
/**
|
|
23
|
-
* The type of caption to render.
|
|
24
|
-
*/
|
|
25
|
-
this.captionType = 'default';
|
|
26
|
-
/**
|
|
27
|
-
* Determine whether the input field is required.
|
|
28
|
-
*/
|
|
29
|
-
this.required = false;
|
|
30
|
-
/**
|
|
31
|
-
* Determine whether the rendered element is a `<label>` or `<legend>`.
|
|
32
|
-
*/
|
|
33
|
-
this.isLegend = false;
|
|
34
|
-
this.language = 'en';
|
|
35
|
-
/**
|
|
36
|
-
* Return the `<label>` element for text inputs
|
|
37
|
-
* @param captionFor Set the `htmlFor` attribute
|
|
38
|
-
* @returns element containing the caption for the input
|
|
39
|
-
*/
|
|
40
|
-
this.getCaption = (captionFor, hasHintExpander = false) => {
|
|
41
|
-
const captionText = this.captionText && this.captionText.toLowerCase();
|
|
42
|
-
const captionContent = this.isLegend
|
|
43
|
-
? h(
|
|
44
|
-
'legend',
|
|
45
|
-
{ class: this.getClass() },
|
|
46
|
-
this.captionType === 'heading' ? h('h1', null, this.captionText) : this.captionText,
|
|
47
|
-
this.getRequiredFlagElement(),
|
|
48
|
-
hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false),
|
|
49
|
-
)
|
|
50
|
-
: h(
|
|
51
|
-
'label',
|
|
52
|
-
{ htmlFor: captionFor, class: this.getClass() },
|
|
53
|
-
this.captionText,
|
|
54
|
-
this.getRequiredFlagElement(),
|
|
55
|
-
hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false),
|
|
56
|
-
);
|
|
57
|
-
// with `this.captionType` already set to one of the enum values, the comparison no longer needs the `toLowerCase()` transform
|
|
58
|
-
return this.captionType === 'heading' && !this.isLegend ? h('h1', null, captionContent) : captionContent;
|
|
59
|
-
};
|
|
60
|
-
let captionObject;
|
|
61
|
-
if (typeof caption === 'string') {
|
|
62
|
-
try {
|
|
63
|
-
captionObject = JSON.parse(caption);
|
|
64
|
-
} catch (_a) {
|
|
65
|
-
captionObject = { captionText: caption, captionType: 'default' };
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
captionObject = caption;
|
|
69
|
-
}
|
|
70
|
-
this.componentTagName = componentTagName.toLocaleLowerCase();
|
|
71
|
-
this.captionText = captionObject === null || captionObject === void 0 ? void 0 : captionObject.captionText;
|
|
72
|
-
this.captionType =
|
|
73
|
-
((captionObject === null || captionObject === void 0 ? void 0 : captionObject.captionType) &&
|
|
74
|
-
CaptionTypes.find((type) => {
|
|
75
|
-
var _a;
|
|
76
|
-
return type === ((_a = captionObject.captionType) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
77
|
-
})) ||
|
|
78
|
-
'default';
|
|
79
|
-
this.required = required;
|
|
80
|
-
this.isLegend = isLegend;
|
|
81
|
-
this.translations = translations;
|
|
82
|
-
this.language = language;
|
|
83
|
-
this.validateCaption(this);
|
|
84
|
-
}
|
|
85
|
-
getHintExpanderAccessibilityText(captionText, hasHintExpanderOnOption = false) {
|
|
86
|
-
const multipleOptionsMessage = h(
|
|
87
|
-
'span',
|
|
88
|
-
{ class: 'ontario-show-for-sr' },
|
|
89
|
-
this.translations.accessibility.moreInfo[this.language],
|
|
90
|
-
' "',
|
|
91
|
-
captionText.toLowerCase(),
|
|
92
|
-
'"',
|
|
93
|
-
' ',
|
|
94
|
-
this.translations.accessibility.checkboxHintExpander[this.language],
|
|
95
|
-
);
|
|
96
|
-
const singleOptionMessage = h(
|
|
97
|
-
'span',
|
|
98
|
-
{ class: 'ontario-show-for-sr' },
|
|
99
|
-
this.translations.accessibility.moreInfo[this.language],
|
|
100
|
-
' "',
|
|
101
|
-
captionText.toLowerCase(),
|
|
102
|
-
'"',
|
|
103
|
-
' ',
|
|
104
|
-
this.translations.accessibility.singleHintExpander[this.language],
|
|
105
|
-
);
|
|
106
|
-
return this.componentTagName === 'ontario-checkboxes'
|
|
107
|
-
? !hasHintExpanderOnOption
|
|
108
|
-
? multipleOptionsMessage
|
|
109
|
-
: singleOptionMessage
|
|
110
|
-
: singleOptionMessage;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Determines which flag text to use between `required` and `optional`
|
|
114
|
-
* @returns `required` or `optional` flag text
|
|
115
|
-
*/
|
|
116
|
-
getRequiredFlagText() {
|
|
117
|
-
return this.required
|
|
118
|
-
? this.translations && `(${this.translations.required[this.language]})`
|
|
119
|
-
: this.translations && `(${this.translations.optional[this.language]})`;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Get the HTML for the required/optional flag.
|
|
123
|
-
* @returns CSS class for the label/legend.
|
|
124
|
-
*/
|
|
125
|
-
getRequiredFlagElement() {
|
|
126
|
-
return h('span', { class: 'ontario-label__flag' }, this.getRequiredFlagText());
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Get the CSS class for the `label` element.
|
|
130
|
-
* @returns CSS class for the `label` element.
|
|
131
|
-
*/
|
|
132
|
-
getClass() {
|
|
133
|
-
return this.captionType === 'large' || this.captionType === 'heading'
|
|
134
|
-
? this.isLegend
|
|
135
|
-
? `ontario-fieldset__legend ontario-fieldset__legend--${this.captionType}`
|
|
136
|
-
: `ontario-label ontario-label--${this.captionType}`
|
|
137
|
-
: this.isLegend
|
|
138
|
-
? 'ontario-fieldset__legend'
|
|
139
|
-
: 'ontario-label';
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Validate caption input by user and output warning message to the console if:
|
|
143
|
-
* 1. the `caption` object is not provided
|
|
144
|
-
* 2. the `captionText` property of the `caption` object is not provided
|
|
145
|
-
* 3. the `captionText` property of the `caption` object is empty or contain only spaces
|
|
146
|
-
* 4. the `captionType` property of the `caption` object is not provided
|
|
147
|
-
* 5. the `captionType` property of the `caption` object is incorrect
|
|
148
|
-
*/
|
|
149
|
-
validateCaption(caption) {
|
|
150
|
-
var _a;
|
|
151
|
-
let messageType;
|
|
152
|
-
// undefined `caption` object
|
|
153
|
-
if (!caption || Object.keys(caption).length <= 0) {
|
|
154
|
-
messageType = MessageContentType.UndefinedCaptionObject;
|
|
155
|
-
} else {
|
|
156
|
-
// undefined `captionText` property
|
|
157
|
-
if (!caption.captionText) {
|
|
158
|
-
messageType = MessageContentType.UndefinedCaptionText;
|
|
159
|
-
} else {
|
|
160
|
-
// `captionText` that is empty or contains only spaces
|
|
161
|
-
if (/^\s*$/.test(caption.captionText)) {
|
|
162
|
-
messageType = MessageContentType.EmptyCaptionText;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
// undefined `captionType`
|
|
166
|
-
if (!caption.captionType) {
|
|
167
|
-
messageType = MessageContentType.UndefinedCaptionType;
|
|
168
|
-
} else {
|
|
169
|
-
// incorrect `captionType`
|
|
170
|
-
if (
|
|
171
|
-
!CaptionTypes.includes(
|
|
172
|
-
(_a = caption === null || caption === void 0 ? void 0 : caption.captionType) === null || _a === void 0
|
|
173
|
-
? void 0
|
|
174
|
-
: _a.toLowerCase(),
|
|
175
|
-
)
|
|
176
|
-
) {
|
|
177
|
-
messageType = MessageContentType.IncorrectCaptionType;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (messageType) {
|
|
182
|
-
const message = new ConsoleMessageClass().addDesignSystemTag();
|
|
183
|
-
if (messageType !== MessageContentType.UndefinedCaptionObject) {
|
|
184
|
-
message
|
|
185
|
-
.addMonospaceText(
|
|
186
|
-
` ${
|
|
187
|
-
messageType === MessageContentType.EmptyCaptionText ||
|
|
188
|
-
messageType === MessageContentType.UndefinedCaptionText
|
|
189
|
-
? 'caption or captionText'
|
|
190
|
-
: 'captionType'
|
|
191
|
-
} `,
|
|
192
|
-
)
|
|
193
|
-
.addRegularText('object or property of');
|
|
194
|
-
}
|
|
195
|
-
message.addMonospaceText(' caption ').addRegularText('object on').addMonospaceText(` ${this.componentTagName} `);
|
|
196
|
-
this.printConsoleMessage(messageType, message, this.getRequiredFlagText());
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Generate the content of warning message to be printed to the console
|
|
201
|
-
* @param messageType determine the content of warning message to output
|
|
202
|
-
* @param componentTagName the tag name of the component that's emitting the warning message
|
|
203
|
-
* @param requiredFlagText accepts a string value to be used as the required flag text and defaults to `(optional)` if not set
|
|
204
|
-
* @returns an array of `ConsoleMessage` objects containing the message and associated styles to be printed to the console
|
|
205
|
-
*/
|
|
206
|
-
printConsoleMessage(messageType, message, requiredFlagText = '(optional)') {
|
|
207
|
-
switch (messageType) {
|
|
208
|
-
// undefinedCaptionObject example: caption object on <ontario-input> is required but not defined. A blank followed by a (optional) flag is assumed.
|
|
209
|
-
// undefinedCaptionText example: captionText property of caption object on <ontario-input> is required but not defined. A blank followed by a (optional) flag is assumed.
|
|
210
|
-
// EmptyCaptionText example: captionText property of caption object on <ontario-input> is empty or contains only spaces. A blank followed by a (optional) flag is assumed.
|
|
211
|
-
case MessageContentType.UndefinedCaptionObject:
|
|
212
|
-
case MessageContentType.UndefinedCaptionText:
|
|
213
|
-
case MessageContentType.EmptyCaptionText:
|
|
214
|
-
message
|
|
215
|
-
.addRegularText(
|
|
216
|
-
`${
|
|
217
|
-
messageType === MessageContentType.EmptyCaptionText
|
|
218
|
-
? 'is empty or contains only spaces'
|
|
219
|
-
: 'is required but not defined'
|
|
220
|
-
}. A blank followed by a`,
|
|
221
|
-
)
|
|
222
|
-
.addMonospaceText(` ${requiredFlagText} `)
|
|
223
|
-
.addRegularText('flag is assumed.');
|
|
224
|
-
break;
|
|
225
|
-
// UndefinedCaptionType example: captionType property of caption object on <ontario-input> is not defined. The default type is assumed.
|
|
226
|
-
case MessageContentType.UndefinedCaptionType:
|
|
227
|
-
message.addRegularText('is not defined. The').addMonospaceText(' default ').addRegularText('type is assumed.');
|
|
228
|
-
break;
|
|
229
|
-
// IncorrectCaptionType example: captionType property of caption object on <ontario-input> was set to an incorrect type; only default, heading or large type is allowed. The default type is assumed.
|
|
230
|
-
case MessageContentType.IncorrectCaptionType:
|
|
231
|
-
message
|
|
232
|
-
.addRegularText('was set to an incorrect type; only')
|
|
233
|
-
.addMonospaceText(' default, heading, ')
|
|
234
|
-
.addRegularText('or')
|
|
235
|
-
.addMonospaceText(' large ')
|
|
236
|
-
.addRegularText('type is allowed. The')
|
|
237
|
-
.addMonospaceText(' default ')
|
|
238
|
-
.addRegularText('type is assumed.');
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
message.printMessage();
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
var EventType;
|
|
246
|
-
(function (EventType) {
|
|
247
|
-
EventType['Change'] = 'change';
|
|
248
|
-
EventType['Blur'] = 'blur';
|
|
249
|
-
EventType['Focus'] = 'focus';
|
|
250
|
-
EventType['Input'] = 'input';
|
|
251
|
-
})(EventType || (EventType = {}));
|
|
252
|
-
|
|
253
|
-
const handleInputEvent = (
|
|
254
|
-
event,
|
|
255
|
-
eventType,
|
|
256
|
-
input,
|
|
257
|
-
inputChangeEvent,
|
|
258
|
-
inputFocusEvent,
|
|
259
|
-
inputBlurEvent,
|
|
260
|
-
inputInputEvent,
|
|
261
|
-
type,
|
|
262
|
-
customChangeFunction,
|
|
263
|
-
customFocusFunction,
|
|
264
|
-
customBlurFunction,
|
|
265
|
-
customInputFunction,
|
|
266
|
-
hostElement,
|
|
267
|
-
) => {
|
|
268
|
-
var _a;
|
|
269
|
-
if (eventType === EventType.Input) {
|
|
270
|
-
inputInputEvent === null || inputInputEvent === void 0
|
|
271
|
-
? void 0
|
|
272
|
-
: inputInputEvent.emit({
|
|
273
|
-
id: input === null || input === void 0 ? void 0 : input.id,
|
|
274
|
-
value: (_a = event.data) !== null && _a !== void 0 ? _a : undefined,
|
|
275
|
-
inputType: event.inputType,
|
|
276
|
-
});
|
|
277
|
-
customInputFunction && customInputFunction(event);
|
|
278
|
-
}
|
|
279
|
-
if (eventType === EventType.Change) {
|
|
280
|
-
if (type === 'radio' || type === 'checkbox') {
|
|
281
|
-
if (input instanceof HTMLInputElement) {
|
|
282
|
-
inputChangeEvent.emit({
|
|
283
|
-
checked: input === null || input === void 0 ? void 0 : input.checked,
|
|
284
|
-
id: input === null || input === void 0 ? void 0 : input.id,
|
|
285
|
-
value: input === null || input === void 0 ? void 0 : input.value,
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
} else {
|
|
289
|
-
inputChangeEvent.emit({
|
|
290
|
-
id: input === null || input === void 0 ? void 0 : input.id,
|
|
291
|
-
value: input === null || input === void 0 ? void 0 : input.value,
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
customChangeFunction && customChangeFunction(event);
|
|
295
|
-
// Note: Change events don't have composable set to true and don't cross the ShadowDOM boundary.
|
|
296
|
-
// This will emit an event so the normal `onChange` event pattern is maintained.
|
|
297
|
-
hostElement && emitEvent(hostElement, eventType, event);
|
|
298
|
-
}
|
|
299
|
-
if (eventType === EventType.Focus) {
|
|
300
|
-
inputFocusEvent.emit({
|
|
301
|
-
id: input === null || input === void 0 ? void 0 : input.id,
|
|
302
|
-
focused: true,
|
|
303
|
-
value: input === null || input === void 0 ? void 0 : input.value,
|
|
304
|
-
});
|
|
305
|
-
customFocusFunction && customFocusFunction(event);
|
|
306
|
-
}
|
|
307
|
-
if (eventType === EventType.Blur) {
|
|
308
|
-
inputBlurEvent.emit({
|
|
309
|
-
id: input === null || input === void 0 ? void 0 : input.id,
|
|
310
|
-
focused: false,
|
|
311
|
-
value: input === null || input === void 0 ? void 0 : input.value,
|
|
312
|
-
});
|
|
313
|
-
customBlurFunction && customBlurFunction(event);
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
/**
|
|
317
|
-
* Emit a custom event that can be subscribed to by an event listener.
|
|
318
|
-
*
|
|
319
|
-
* @param element Component host element, see https://stenciljs.com/docs/host-element
|
|
320
|
-
* @param name name of the event
|
|
321
|
-
* @param detail any relevant details, like the original event
|
|
322
|
-
*/
|
|
323
|
-
const emitEvent = (element, name, detail) => {
|
|
324
|
-
element.dispatchEvent(new CustomEvent(name, { composed: true, bubbles: true, detail }));
|
|
325
|
-
};
|
|
326
|
-
|
|
327
4
|
const ErrorMessage = ({ message, error = false }) => {
|
|
328
5
|
const hideError = !error || isEmpty(message);
|
|
329
6
|
return h(
|
|
@@ -334,6 +11,6 @@ const ErrorMessage = ({ message, error = false }) => {
|
|
|
334
11
|
);
|
|
335
12
|
};
|
|
336
13
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","src/utils/events/event-handler.interface.ts","src/utils/events/event-handler.ts","src/utils/components/error-message/error-message.tsx"],"sourcesContent":["export enum MessageContentType {\n\tUndefinedCaptionObject = 'undefinedCaptionObject',\n\tUndefinedCaptionText = 'undefinedCaption',\n\tEmptyCaptionText = 'emptyCaption',\n\tUndefinedCaptionType = 'undefinedCaptionType',\n\tIncorrectCaptionType = 'incorrectCaptionType',\n}\n","import { h } from '@stencil/core';\nimport { CaptionType, CaptionTypes } from './input-caption.types';\nimport { MessageContentType } from './input-caption.enum';\nimport { CaptionInfo, Caption } from './caption.interface';\nimport { ConsoleMessageClass } from '../../console-message/console-message';\n\nexport class InputCaption implements CaptionInfo {\n\t/**\n\t * The text to display as caption.\n\t */\n\tcaptionText: string;\n\n\t/**\n\t * The type of caption to render.\n\t */\n\tcaptionType?: CaptionType = 'default';\n\n\t/**\n\t * Determine whether the input field is required.\n\t */\n\trequired?: boolean = false;\n\n\t/**\n\t * Determine whether the rendered element is a `<label>` or `<legend>`.\n\t */\n\tisLegend?: boolean = false;\n\n\t/**\n\t * Name of the component instantiating the class.\n\t * This is used for validation warning message.\n\t */\n\tcomponentTagName: string;\n\n\tlanguage: any = 'en';\n\n\ttranslations: any;\n\n\t/**\n\t * Set the class members\n\t * Output a console warning message if the provided `label` type is incorrect\n\t * @param caption object containing the essential data to configure the input label\n\t */\n\tconstructor(\n\t\tcomponentTagName: string,\n\t\tcaption: Caption | string,\n\t\ttranslations: any,\n\t\tlanguage: any,\n\t\tisLegend: boolean = false,\n\t\trequired: boolean = false,\n\t) {\n\t\tlet captionObject: Caption;\n\n\t\tif (typeof caption === 'string') {\n\t\t\ttry {\n\t\t\t\tcaptionObject = JSON.parse(caption) as Caption;\n\t\t\t} catch {\n\t\t\t\tcaptionObject = { captionText: caption, captionType: 'default' };\n\t\t\t}\n\t\t} else {\n\t\t\tcaptionObject = caption;\n\t\t}\n\n\t\tthis.componentTagName = componentTagName.toLocaleLowerCase();\n\t\tthis.captionText = captionObject?.captionText;\n\t\tthis.captionType =\n\t\t\t(captionObject?.captionType && CaptionTypes.find((type) => type === captionObject.captionType?.toLowerCase())) ||\n\t\t\t'default';\n\t\tthis.required = required;\n\t\tthis.isLegend = isLegend;\n\t\tthis.translations = translations;\n\t\tthis.language = language;\n\n\t\tthis.validateCaption(this);\n\t}\n\n\t/**\n\t * Return the `<label>` element for text inputs\n\t * @param captionFor Set the `htmlFor` attribute\n\t * @returns element containing the caption for the input\n\t */\n\tgetCaption = (captionFor?: string | undefined, hasHintExpander: boolean = false): HTMLElement => {\n\t\tconst captionText = this.captionText && this.captionText.toLowerCase();\n\t\tconst captionContent = this.isLegend ? (\n\t\t\t<legend class={this.getClass()}>\n\t\t\t\t{this.captionType === 'heading' ? <h1>{this.captionText}</h1> : this.captionText}\n\t\t\t\t{this.getRequiredFlagElement()}\n\t\t\t\t{hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false)}\n\t\t\t</legend>\n\t\t) : (\n\t\t\t<label htmlFor={captionFor} class={this.getClass()}>\n\t\t\t\t{this.captionText}\n\t\t\t\t{this.getRequiredFlagElement()}\n\t\t\t\t{hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false)}\n\t\t\t</label>\n\t\t);\n\n\t\t// with `this.captionType` already set to one of the enum values, the comparison no longer needs the `toLowerCase()` transform\n\t\treturn this.captionType === 'heading' && !this.isLegend ? <h1>{captionContent}</h1> : captionContent;\n\t};\n\n\tgetHintExpanderAccessibilityText(captionText: string, hasHintExpanderOnOption: boolean = false): HTMLElement {\n\t\tconst multipleOptionsMessage = (\n\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t{this.translations.accessibility.moreInfo[this.language]} \"{captionText.toLowerCase()}\"{' '}\n\t\t\t\t{this.translations.accessibility.checkboxHintExpander[this.language]}\n\t\t\t</span>\n\t\t);\n\n\t\tconst singleOptionMessage = (\n\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t{this.translations.accessibility.moreInfo[this.language]} \"{captionText.toLowerCase()}\"{' '}\n\t\t\t\t{this.translations.accessibility.singleHintExpander[this.language]}\n\t\t\t</span>\n\t\t);\n\t\treturn this.componentTagName === 'ontario-checkboxes'\n\t\t\t? !hasHintExpanderOnOption\n\t\t\t\t? multipleOptionsMessage\n\t\t\t\t: singleOptionMessage\n\t\t\t: singleOptionMessage;\n\t}\n\n\t/**\n\t * Determines which flag text to use between `required` and `optional`\n\t * @returns `required` or `optional` flag text\n\t */\n\tprivate getRequiredFlagText(): string {\n\t\treturn this.required\n\t\t\t? this.translations && `(${this.translations.required[this.language]})`\n\t\t\t: this.translations && `(${this.translations.optional[this.language]})`;\n\t}\n\n\t/**\n\t * Get the HTML for the required/optional flag.\n\t * @returns CSS class for the label/legend.\n\t */\n\tprivate getRequiredFlagElement(): HTMLElement {\n\t\treturn <span class=\"ontario-label__flag\">{this.getRequiredFlagText()}</span>;\n\t}\n\n\t/**\n\t * Get the CSS class for the `label` element.\n\t * @returns CSS class for the `label` element.\n\t */\n\tprivate getClass(): string {\n\t\treturn this.captionType === 'large' || this.captionType === 'heading'\n\t\t\t? this.isLegend\n\t\t\t\t? `ontario-fieldset__legend ontario-fieldset__legend--${this.captionType}`\n\t\t\t\t: `ontario-label ontario-label--${this.captionType}`\n\t\t\t: this.isLegend\n\t\t\t? 'ontario-fieldset__legend'\n\t\t\t: 'ontario-label';\n\t}\n\n\t/**\n\t * Validate caption input by user and output warning message to the console if:\n\t * 1. the `caption` object is not provided\n\t * 2. the `captionText` property of the `caption` object is not provided\n\t * 3. the `captionText` property of the `caption` object is empty or contain only spaces\n\t * 4. the `captionType` property of the `caption` object is not provided\n\t * 5. the `captionType` property of the `caption` object is incorrect\n\t */\n\tprivate validateCaption(caption?: InputCaption) {\n\t\tlet messageType;\n\n\t\t// undefined `caption` object\n\t\tif (!caption || Object.keys(caption).length <= 0) {\n\t\t\tmessageType = MessageContentType.UndefinedCaptionObject;\n\t\t} else {\n\t\t\t// undefined `captionText` property\n\t\t\tif (!caption.captionText) {\n\t\t\t\tmessageType = MessageContentType.UndefinedCaptionText;\n\t\t\t} else {\n\t\t\t\t// `captionText` that is empty or contains only spaces\n\t\t\t\tif (/^\\s*$/.test(caption.captionText)) {\n\t\t\t\t\tmessageType = MessageContentType.EmptyCaptionText;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// undefined `captionType`\n\t\t\tif (!caption.captionType) {\n\t\t\t\tmessageType = MessageContentType.UndefinedCaptionType;\n\t\t\t} else {\n\t\t\t\t// incorrect `captionType`\n\t\t\t\tif (!CaptionTypes.includes(caption?.captionType?.toLowerCase() as CaptionType)) {\n\t\t\t\t\tmessageType = MessageContentType.IncorrectCaptionType;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (messageType) {\n\t\t\tconst message = new ConsoleMessageClass().addDesignSystemTag();\n\n\t\t\tif (messageType !== MessageContentType.UndefinedCaptionObject) {\n\t\t\t\tmessage\n\t\t\t\t\t.addMonospaceText(\n\t\t\t\t\t\t` ${\n\t\t\t\t\t\t\tmessageType === MessageContentType.EmptyCaptionText ||\n\t\t\t\t\t\t\tmessageType === MessageContentType.UndefinedCaptionText\n\t\t\t\t\t\t\t\t? 'caption or captionText'\n\t\t\t\t\t\t\t\t: 'captionType'\n\t\t\t\t\t\t} `,\n\t\t\t\t\t)\n\t\t\t\t\t.addRegularText('object or property of');\n\t\t\t}\n\n\t\t\tmessage.addMonospaceText(' caption ').addRegularText('object on').addMonospaceText(` ${this.componentTagName} `);\n\t\t\tthis.printConsoleMessage(messageType, message, this.getRequiredFlagText());\n\t\t}\n\t}\n\n\t/**\n\t * Generate the content of warning message to be printed to the console\n\t * @param messageType determine the content of warning message to output\n\t * @param componentTagName the tag name of the component that's emitting the warning message\n\t * @param requiredFlagText accepts a string value to be used as the required flag text and defaults to `(optional)` if not set\n\t * @returns an array of `ConsoleMessage` objects containing the message and associated styles to be printed to the console\n\t */\n\tprivate printConsoleMessage(\n\t\tmessageType: MessageContentType,\n\t\tmessage: ConsoleMessageClass,\n\t\trequiredFlagText: string = '(optional)',\n\t) {\n\t\tswitch (messageType) {\n\t\t\t// undefinedCaptionObject example: caption object on <ontario-input> is required but not defined. A blank followed by a (optional) flag is assumed.\n\t\t\t// undefinedCaptionText example: captionText property of caption object on <ontario-input> is required but not defined. A blank followed by a (optional) flag is assumed.\n\t\t\t// EmptyCaptionText example: captionText property of caption object on <ontario-input> is empty or contains only spaces. A blank followed by a (optional) flag is assumed.\n\t\t\tcase MessageContentType.UndefinedCaptionObject:\n\t\t\tcase MessageContentType.UndefinedCaptionText:\n\t\t\tcase MessageContentType.EmptyCaptionText:\n\t\t\t\tmessage\n\t\t\t\t\t.addRegularText(\n\t\t\t\t\t\t`${\n\t\t\t\t\t\t\tmessageType === MessageContentType.EmptyCaptionText\n\t\t\t\t\t\t\t\t? 'is empty or contains only spaces'\n\t\t\t\t\t\t\t\t: 'is required but not defined'\n\t\t\t\t\t\t}. A blank followed by a`,\n\t\t\t\t\t)\n\t\t\t\t\t.addMonospaceText(` ${requiredFlagText} `)\n\t\t\t\t\t.addRegularText('flag is assumed.');\n\t\t\t\tbreak;\n\n\t\t\t// UndefinedCaptionType example: captionType property of caption object on <ontario-input> is not defined. The default type is assumed.\n\t\t\tcase MessageContentType.UndefinedCaptionType:\n\t\t\t\tmessage.addRegularText('is not defined. The').addMonospaceText(' default ').addRegularText('type is assumed.');\n\t\t\t\tbreak;\n\n\t\t\t// IncorrectCaptionType example: captionType property of caption object on <ontario-input> was set to an incorrect type; only default, heading or large type is allowed. The default type is assumed.\n\t\t\tcase MessageContentType.IncorrectCaptionType:\n\t\t\t\tmessage\n\t\t\t\t\t.addRegularText('was set to an incorrect type; only')\n\t\t\t\t\t.addMonospaceText(' default, heading, ')\n\t\t\t\t\t.addRegularText('or')\n\t\t\t\t\t.addMonospaceText(' large ')\n\t\t\t\t\t.addRegularText('type is allowed. The')\n\t\t\t\t\t.addMonospaceText(' default ')\n\t\t\t\t\t.addRegularText('type is assumed.');\n\t\t\t\tbreak;\n\t\t}\n\n\t\tmessage.printMessage();\n\t}\n}\n","export enum EventType {\n\tChange = 'change',\n\tBlur = 'blur',\n\tFocus = 'focus',\n\tInput = 'input',\n}\n\nexport type InputInteractionEvent = {\n\tid?: string;\n\tvalue?: string;\n};\n\nexport type InputInputEvent = InputInteractionEvent & {\n\tinputType?: string;\n};\n\nexport type RadioAndCheckboxChangeEvent = InputInteractionEvent & {\n\tchecked: boolean;\n};\n\nexport type InputFocusBlurEvent = InputInteractionEvent & {\n\tfocused: boolean;\n};\n\nexport type InputType = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null;\n","import { EventEmitter } from '@stencil/core';\nimport {\n\tInputType,\n\tEventType,\n\tInputFocusBlurEvent,\n\tInputInteractionEvent,\n\tRadioAndCheckboxChangeEvent,\n\tInputInputEvent,\n} from './event-handler.interface';\n\nexport const handleInputEvent = (\n\tevent: Event,\n\teventType: EventType,\n\tinput: InputType,\n\tinputChangeEvent: EventEmitter<InputInteractionEvent | RadioAndCheckboxChangeEvent>,\n\tinputFocusEvent: EventEmitter<InputFocusBlurEvent>,\n\tinputBlurEvent: EventEmitter<InputFocusBlurEvent>,\n\tinputInputEvent?: EventEmitter<InputInputEvent>,\n\ttype?: string,\n\tcustomChangeFunction?: (event: Event) => void,\n\tcustomFocusFunction?: (event: Event) => void,\n\tcustomBlurFunction?: (event: Event) => void,\n\tcustomInputFunction?: (event: Event) => void,\n\thostElement?: HTMLElement,\n) => {\n\tif (eventType === EventType.Input) {\n\t\tinputInputEvent?.emit({\n\t\t\tid: input?.id,\n\t\t\tvalue: (event as InputEvent).data ?? undefined,\n\t\t\tinputType: (event as InputEvent).inputType,\n\t\t});\n\n\t\tcustomInputFunction && customInputFunction(event);\n\t}\n\n\tif (eventType === EventType.Change) {\n\t\tif (type === 'radio' || type === 'checkbox') {\n\t\t\tif (input instanceof HTMLInputElement) {\n\t\t\t\tinputChangeEvent.emit({\n\t\t\t\t\tchecked: input?.checked,\n\t\t\t\t\tid: input?.id,\n\t\t\t\t\tvalue: input?.value,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tinputChangeEvent.emit({\n\t\t\t\tid: input?.id,\n\t\t\t\tvalue: input?.value,\n\t\t\t});\n\t\t}\n\n\t\tcustomChangeFunction && customChangeFunction(event);\n\n\t\t// Note: Change events don't have composable set to true and don't cross the ShadowDOM boundary.\n\t\t// This will emit an event so the normal `onChange` event pattern is maintained.\n\t\thostElement && emitEvent(hostElement, eventType, event);\n\t}\n\n\tif (eventType === EventType.Focus) {\n\t\tinputFocusEvent.emit({\n\t\t\tid: input?.id,\n\t\t\tfocused: true,\n\t\t\tvalue: input?.value,\n\t\t});\n\n\t\tcustomFocusFunction && customFocusFunction(event);\n\t}\n\n\tif (eventType === EventType.Blur) {\n\t\tinputBlurEvent.emit({\n\t\t\tid: input?.id,\n\t\t\tfocused: false,\n\t\t\tvalue: input?.value,\n\t\t});\n\n\t\tcustomBlurFunction && customBlurFunction(event);\n\t}\n};\n\n/**\n * Emit a custom event that can be subscribed to by an event listener.\n *\n * @param element Component host element, see https://stenciljs.com/docs/host-element\n * @param name name of the event\n * @param detail any relevant details, like the original event\n */\nexport const emitEvent = (element: HTMLElement, name: string, detail?: any) => {\n\telement.dispatchEvent(new CustomEvent(name, { composed: true, bubbles: true, detail }));\n};\n","import { FunctionalComponent, h } from '@stencil/core';\nimport { isEmpty } from '../../../utils/helper/utils';\n\nexport type ErrorMessageProps = {\n\terror?: boolean;\n\tmessage?: string;\n};\n\nexport const ErrorMessage: FunctionalComponent<ErrorMessageProps> = ({ message, error = false }) => {\n\tconst hideError = !error || isEmpty(message);\n\n\treturn (\n\t\t<div role=\"alert\" class={`ontario-error-messaging ${hideError ? 'ontario-error__hidden' : ''}`}>\n\t\t\t<ontario-icon-alert-error></ontario-icon-alert-error>\n\t\t\t<div class=\"ontario-error-messaging__content\">{message}</div>\n\t\t</div>\n\t);\n};\n"],"version":3}
|
|
1
|
+
{"file":"error-message.js","mappings":";;;MAQa,YAAY,GAA2C,CAAC,EAAE,OAAO,EAAE,KAAK,GAAG,KAAK,EAAE;IAC9F,MAAM,SAAS,GAAG,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAE7C,QACC,WAAK,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,2BAA2B,SAAS,GAAG,uBAAuB,GAAG,EAAE,EAAE;QAC7F,mCAAqD;QACrD,WAAK,KAAK,EAAC,kCAAkC,IAAE,OAAO,CAAO,CACxD,EACL;AACH;;;;","names":[],"sources":["src/utils/components/error-message/error-message.tsx"],"sourcesContent":["import { FunctionalComponent, h } from '@stencil/core';\nimport { isEmpty } from '../../../utils/helper/utils';\n\nexport type ErrorMessageProps = {\n\terror?: boolean;\n\tmessage?: string;\n};\n\nexport const ErrorMessage: FunctionalComponent<ErrorMessageProps> = ({ message, error = false }) => {\n\tconst hideError = !error || isEmpty(message);\n\n\treturn (\n\t\t<div role=\"alert\" class={`ontario-error-messaging ${hideError ? 'ontario-error__hidden' : ''}`}>\n\t\t\t<ontario-icon-alert-error></ontario-icon-alert-error>\n\t\t\t<div class=\"ontario-error-messaging__content\">{message}</div>\n\t\t</div>\n\t);\n};\n"],"version":3}
|