@ongov/ontario-design-system-component-library 4.3.1-alpha.1 → 5.0.0-alpha.3

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.
Files changed (163) hide show
  1. package/dist/cjs/app-globals-6f6b30a8.js.map +1 -1
  2. package/dist/cjs/index-88d5cf20.js +2 -2
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{ontario-accordion_43.cjs.entry.js → ontario-accordion_44.cjs.entry.js} +358 -85
  5. package/dist/cjs/ontario-accordion_44.cjs.entry.js.map +1 -0
  6. package/dist/cjs/ontario-design-system-components.cjs.js +1 -1
  7. package/dist/collection/collection-manifest.json +1 -0
  8. package/dist/collection/components/ontario-card/ontario-card-types.js +29 -2
  9. package/dist/collection/components/ontario-card/ontario-card-types.js.map +1 -1
  10. package/dist/collection/components/ontario-card/ontario-card.css +252 -34
  11. package/dist/collection/components/ontario-card/ontario-card.js +102 -78
  12. package/dist/collection/components/ontario-card/ontario-card.js.map +1 -1
  13. package/dist/collection/components/ontario-card/test/ontario-cards.spec.js +23 -13
  14. package/dist/collection/components/ontario-card/test/ontario-cards.spec.js.map +1 -1
  15. package/dist/collection/components/ontario-date-input/test/ontario-date-input.spec.js +58 -0
  16. package/dist/collection/components/ontario-date-input/test/ontario-date-input.spec.js.map +1 -1
  17. package/dist/collection/components/ontario-date-input/utils/date-validation-utils.js +14 -4
  18. package/dist/collection/components/ontario-date-input/utils/date-validation-utils.js.map +1 -1
  19. package/dist/collection/components/ontario-header/service-ontario-header.css +0 -3
  20. package/dist/collection/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
  21. package/dist/collection/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
  22. package/dist/collection/components/ontario-search-box/ontario-search-box.css +823 -0
  23. package/dist/collection/components/ontario-search-box/ontario-search-box.js +584 -0
  24. package/dist/collection/components/ontario-search-box/ontario-search-box.js.map +1 -0
  25. package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js +20 -0
  26. package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js.map +1 -0
  27. package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js +19 -0
  28. package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js.map +1 -0
  29. package/dist/collection/components/ontario-step-indicator/ontario-step-indicator.js +5 -5
  30. package/dist/collection/components/ontario-table/ontario-table.js +5 -5
  31. package/dist/collection/components/ontario-textarea/ontario-textarea.js +3 -3
  32. package/dist/collection/fonts/open-sans-400/LICENSE.txt +0 -0
  33. package/dist/collection/fonts/open-sans-400/open-sans-400.eot +0 -0
  34. package/dist/collection/fonts/open-sans-400/open-sans-400.svg +0 -0
  35. package/dist/collection/fonts/open-sans-400/open-sans-400.ttf +0 -0
  36. package/dist/collection/fonts/open-sans-400/open-sans-400.woff +0 -0
  37. package/dist/collection/fonts/open-sans-400/open-sans-400.woff2 +0 -0
  38. package/dist/collection/fonts/open-sans-700/LICENSE.txt +0 -0
  39. package/dist/collection/fonts/open-sans-700/open-sans-700.eot +0 -0
  40. package/dist/collection/fonts/open-sans-700/open-sans-700.svg +0 -0
  41. package/dist/collection/fonts/open-sans-700/open-sans-700.ttf +0 -0
  42. package/dist/collection/utils/common/input/input.js +3 -0
  43. package/dist/collection/utils/common/input/input.js.map +1 -1
  44. package/dist/collection/utils/common/input-caption/input-caption.js +5 -3
  45. package/dist/collection/utils/common/input-caption/input-caption.js.map +1 -1
  46. package/dist/collection/utils/helper/utils.js +4 -2
  47. package/dist/collection/utils/helper/utils.js.map +1 -1
  48. package/dist/collection/utils/helper/utils.spec.js +99 -1
  49. package/dist/collection/utils/helper/utils.spec.js.map +1 -1
  50. package/dist/components/error-message.js +1 -324
  51. package/dist/components/error-message.js.map +1 -1
  52. package/dist/components/event-handler.js +330 -0
  53. package/dist/components/event-handler.js.map +1 -0
  54. package/dist/components/input.js +3 -0
  55. package/dist/components/input.js.map +1 -1
  56. package/dist/components/ontario-card.js +116 -64
  57. package/dist/components/ontario-card.js.map +1 -1
  58. package/dist/components/ontario-checkboxes.js +2 -1
  59. package/dist/components/ontario-checkboxes.js.map +1 -1
  60. package/dist/components/ontario-date-input.js +15 -4
  61. package/dist/components/ontario-date-input.js.map +1 -1
  62. package/dist/components/ontario-dropdown-list.js +2 -1
  63. package/dist/components/ontario-dropdown-list.js.map +1 -1
  64. package/dist/components/ontario-header.js +4 -6
  65. package/dist/components/ontario-header.js.map +1 -1
  66. package/dist/components/ontario-icon-search2.js +6 -0
  67. package/dist/components/ontario-icon-search2.js.map +1 -0
  68. package/dist/components/ontario-input.js +2 -1
  69. package/dist/components/ontario-input.js.map +1 -1
  70. package/dist/components/ontario-radio-buttons.js +2 -1
  71. package/dist/components/ontario-radio-buttons.js.map +1 -1
  72. package/dist/components/ontario-search-box.d.ts +11 -0
  73. package/dist/components/ontario-search-box.js +269 -0
  74. package/dist/components/ontario-search-box.js.map +1 -0
  75. package/dist/components/ontario-step-indicator.js +5 -5
  76. package/dist/components/ontario-table.js +5 -5
  77. package/dist/components/ontario-textarea.js +5 -4
  78. package/dist/components/ontario-textarea.js.map +1 -1
  79. package/dist/components/utils.js +4 -2
  80. package/dist/components/utils.js.map +1 -1
  81. package/dist/esm/app-globals-70748594.js.map +1 -1
  82. package/dist/esm/index-603026f7.js +2 -2
  83. package/dist/esm/loader.js +1 -1
  84. package/dist/esm/{ontario-accordion_43.entry.js → ontario-accordion_44.entry.js} +358 -85
  85. package/dist/esm/ontario-accordion_44.entry.js.map +1 -0
  86. package/dist/esm/ontario-design-system-components.js +1 -1
  87. package/dist/esm/polyfills/core-js.js +0 -0
  88. package/dist/esm/polyfills/dom.js +0 -0
  89. package/dist/esm/polyfills/es5-html-element.js +0 -0
  90. package/dist/esm/polyfills/index.js +0 -0
  91. package/dist/esm/polyfills/system.js +0 -0
  92. package/dist/ontario-design-system-components/fonts/open-sans-400/LICENSE.txt +0 -0
  93. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.eot +0 -0
  94. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.svg +0 -0
  95. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.ttf +0 -0
  96. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.woff +0 -0
  97. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.woff2 +0 -0
  98. package/dist/ontario-design-system-components/fonts/open-sans-700/LICENSE.txt +0 -0
  99. package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.eot +0 -0
  100. package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.svg +0 -0
  101. package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.ttf +0 -0
  102. package/dist/ontario-design-system-components/ontario-design-system-components.esm.js +1 -1
  103. package/dist/ontario-design-system-components/ontario-design-system-components.esm.js.map +1 -1
  104. package/dist/ontario-design-system-components/p-103a233b.js.map +1 -1
  105. package/dist/ontario-design-system-components/{p-abe58ec9.entry.js → p-ac4e76b2.entry.js} +1927 -1728
  106. package/dist/ontario-design-system-components/p-ac4e76b2.entry.js.map +1 -0
  107. package/dist/types/components/ontario-card/ontario-card-types.d.ts +4 -4
  108. package/dist/types/components/ontario-card/ontario-card.d.ts +40 -29
  109. package/dist/types/components/ontario-date-input/utils/date-validation-utils.d.ts +14 -0
  110. package/dist/types/components/ontario-search-box/ontario-search-box.d.ts +180 -0
  111. package/dist/types/components.d.ts +199 -16
  112. package/dist/types/utils/common/input/input.d.ts +2 -1
  113. package/dist/types/utils/common/input-caption/input-caption.d.ts +7 -1
  114. package/package.json +3 -3
  115. package/src/components/ontario-card/ontario-card-types.tsx +33 -4
  116. package/src/components/ontario-card/ontario-card.scss +54 -40
  117. package/src/components/ontario-card/ontario-card.tsx +94 -68
  118. package/src/components/ontario-card/readme.md +57 -27
  119. package/src/components/ontario-card/test/__snapshots__/ontario-cards.spec.tsx.snap +66 -0
  120. package/src/components/ontario-card/test/ontario-cards.spec.tsx +27 -13
  121. package/src/components/ontario-card-collection/readme.md +13 -13
  122. package/src/components/ontario-checkbox/ontario-checkboxes.scss +0 -1
  123. package/src/components/ontario-date-input/test/ontario-date-input.spec.tsx +76 -0
  124. package/src/components/ontario-date-input/utils/date-validation-utils.ts +18 -4
  125. package/src/components/ontario-header/service-ontario-header.scss +0 -4
  126. package/src/components/ontario-hint-text/readme.md +2 -0
  127. package/src/components/ontario-radio-buttons/ontario-radio-buttons.scss +0 -1
  128. package/src/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
  129. package/src/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
  130. package/src/components/ontario-search-box/ontario-search-box.scss +141 -0
  131. package/src/components/ontario-search-box/ontario-search-box.tsx +341 -0
  132. package/src/components/ontario-search-box/readme.md +132 -0
  133. package/src/components/ontario-search-box/test/__snapshots__/ontario-search-box.spec.tsx.snap +35 -0
  134. package/src/components/ontario-search-box/test/ontario-search-box.e2e.ts +21 -0
  135. package/src/components/ontario-search-box/test/ontario-search-box.spec.tsx +22 -0
  136. package/src/components.d.ts +199 -16
  137. package/src/config.json +1 -4
  138. package/src/index.html +287 -52
  139. package/src/utils/common/input/input.tsx +4 -1
  140. package/src/utils/common/input-caption/input-caption.tsx +9 -3
  141. package/src/utils/helper/utils.spec.ts +127 -1
  142. package/src/utils/helper/utils.ts +4 -2
  143. package/www/build/ontario-design-system-components.esm.js +1 -1
  144. package/www/build/ontario-design-system-components.esm.js.map +1 -1
  145. package/www/build/p-103a233b.js.map +1 -1
  146. package/www/build/{p-abe58ec9.entry.js → p-ac4e76b2.entry.js} +1927 -1728
  147. package/www/build/p-ac4e76b2.entry.js.map +1 -0
  148. package/www/build/{p-fdc9ab6d.js → p-c9a9b857.js} +1 -1
  149. package/www/fonts/open-sans-400/LICENSE.txt +0 -0
  150. package/www/fonts/open-sans-400/open-sans-400.eot +0 -0
  151. package/www/fonts/open-sans-400/open-sans-400.svg +0 -0
  152. package/www/fonts/open-sans-400/open-sans-400.ttf +0 -0
  153. package/www/fonts/open-sans-400/open-sans-400.woff +0 -0
  154. package/www/fonts/open-sans-400/open-sans-400.woff2 +0 -0
  155. package/www/fonts/open-sans-700/LICENSE.txt +0 -0
  156. package/www/fonts/open-sans-700/open-sans-700.eot +0 -0
  157. package/www/fonts/open-sans-700/open-sans-700.svg +0 -0
  158. package/www/fonts/open-sans-700/open-sans-700.ttf +0 -0
  159. package/www/index.html +261 -52
  160. package/dist/cjs/ontario-accordion_43.cjs.entry.js.map +0 -1
  161. package/dist/esm/ontario-accordion_43.entry.js.map +0 -1
  162. package/dist/ontario-design-system-components/p-abe58ec9.entry.js.map +0 -1
  163. package/www/build/p-abe58ec9.entry.js.map +0 -1
@@ -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
 
337
- export { ErrorMessage as E, InputCaption as I, EventType as a, emitEvent as e, handleInputEvent as h };
14
+ export { ErrorMessage as E };
338
15
 
339
16
  //# sourceMappingURL=error-message.js.map
@@ -1 +1 @@
1
- {"file":"error-message.js","mappings":";;;;;AAAA,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC7B,u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uBAAL,KAAK,CAAE,KAAK;SACnB,CAAC,CAAC;QAEH,mBAAmB,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;KAClD;IAED,IAAI,SAAS,KAAK,SAAS,CAAC,IAAI,EAAE;QACjC,cAAc,CAAC,IAAI,CAAC;YACnB,EAAE,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,EAAE;YACb,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK;SACnB,CAAC,CAAC;QAEH,kBAAkB,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;KAChD;AACF,EAAE;AAEF;;;;;;;MAOa,SAAS,GAAG,CAAC,OAAoB,EAAE,IAAY,EAAE,MAAY;IACzE,OAAO,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AACzF;;MChFa,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/common/input-caption/input-caption.enum.ts","src/utils/common/input-caption/input-caption.tsx","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}