@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.
Files changed (148) hide show
  1. package/dist/cjs/index-88d5cf20.js +2 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/{ontario-accordion_43.cjs.entry.js → ontario-accordion_44.cjs.entry.js} +738 -296
  4. package/dist/cjs/ontario-accordion_44.cjs.entry.js.map +1 -0
  5. package/dist/cjs/ontario-design-system-components.cjs.js +1 -1
  6. package/dist/collection/collection-manifest.json +1 -0
  7. package/dist/collection/components/ontario-card/ontario-card-types.js +29 -2
  8. package/dist/collection/components/ontario-card/ontario-card-types.js.map +1 -1
  9. package/dist/collection/components/ontario-card/ontario-card.css +257 -31
  10. package/dist/collection/components/ontario-card/ontario-card.js +104 -80
  11. package/dist/collection/components/ontario-card/ontario-card.js.map +1 -1
  12. package/dist/collection/components/ontario-card/test/ontario-cards.spec.js +23 -13
  13. package/dist/collection/components/ontario-card/test/ontario-cards.spec.js.map +1 -1
  14. package/dist/collection/components/ontario-header/ontario-header.js +17 -3
  15. package/dist/collection/components/ontario-header/ontario-header.js.map +1 -1
  16. package/dist/collection/components/ontario-header/service-ontario-header.css +0 -3
  17. package/dist/collection/components/ontario-header/test/ontario-header.spec.js +3 -3
  18. package/dist/collection/components/ontario-header/test/ontario-header.spec.js.map +1 -1
  19. package/dist/collection/components/ontario-language-toggle/ontario-language-toggle.js +193 -47
  20. package/dist/collection/components/ontario-language-toggle/ontario-language-toggle.js.map +1 -1
  21. package/dist/collection/components/ontario-language-toggle/test/ontario-language-toggle.spec.js +16 -3
  22. package/dist/collection/components/ontario-language-toggle/test/ontario-language-toggle.spec.js.map +1 -1
  23. package/dist/collection/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
  24. package/dist/collection/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
  25. package/dist/collection/components/ontario-search-box/ontario-search-box.css +823 -0
  26. package/dist/collection/components/ontario-search-box/ontario-search-box.js +584 -0
  27. package/dist/collection/components/ontario-search-box/ontario-search-box.js.map +1 -0
  28. package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js +20 -0
  29. package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js.map +1 -0
  30. package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js +19 -0
  31. package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js.map +1 -0
  32. package/dist/collection/components/ontario-step-indicator/ontario-step-indicator.js +5 -5
  33. package/dist/collection/components/ontario-table/ontario-table.js +5 -5
  34. package/dist/collection/components/ontario-textarea/ontario-textarea.js +3 -3
  35. package/dist/collection/i18n/global.i18n.json +172 -162
  36. package/dist/collection/utils/common/input/input.js +3 -0
  37. package/dist/collection/utils/common/input/input.js.map +1 -1
  38. package/dist/collection/utils/common/input-caption/input-caption.js +5 -3
  39. package/dist/collection/utils/common/input-caption/input-caption.js.map +1 -1
  40. package/dist/collection/utils/common/language-types.js +1 -1
  41. package/dist/collection/utils/common/language-types.js.map +1 -1
  42. package/dist/collection/utils/helper/utils-types.js +2 -0
  43. package/dist/collection/utils/helper/utils-types.js.map +1 -0
  44. package/dist/collection/utils/helper/utils.js +26 -0
  45. package/dist/collection/utils/helper/utils.js.map +1 -1
  46. package/dist/components/error-message.js +1 -324
  47. package/dist/components/error-message.js.map +1 -1
  48. package/dist/components/event-handler.js +330 -0
  49. package/dist/components/event-handler.js.map +1 -0
  50. package/dist/components/global.i18n.js +184 -173
  51. package/dist/components/global.i18n.js.map +1 -1
  52. package/dist/components/input.js +3 -0
  53. package/dist/components/input.js.map +1 -1
  54. package/dist/components/ontario-card.js +118 -66
  55. package/dist/components/ontario-card.js.map +1 -1
  56. package/dist/components/ontario-checkboxes.js +2 -1
  57. package/dist/components/ontario-checkboxes.js.map +1 -1
  58. package/dist/components/ontario-date-input.js +2 -1
  59. package/dist/components/ontario-date-input.js.map +1 -1
  60. package/dist/components/ontario-dropdown-list.js +2 -1
  61. package/dist/components/ontario-dropdown-list.js.map +1 -1
  62. package/dist/components/ontario-header.js +13 -7
  63. package/dist/components/ontario-header.js.map +1 -1
  64. package/dist/components/ontario-icon-search2.js +6 -0
  65. package/dist/components/ontario-icon-search2.js.map +1 -0
  66. package/dist/components/ontario-input.js +2 -1
  67. package/dist/components/ontario-input.js.map +1 -1
  68. package/dist/components/ontario-language-toggle2.js +180 -37
  69. package/dist/components/ontario-language-toggle2.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 +28 -0
  80. package/dist/components/utils.js.map +1 -1
  81. package/dist/esm/index-603026f7.js +2 -2
  82. package/dist/esm/loader.js +1 -1
  83. package/dist/esm/{ontario-accordion_43.entry.js → ontario-accordion_44.entry.js} +738 -296
  84. package/dist/esm/ontario-accordion_44.entry.js.map +1 -0
  85. package/dist/esm/ontario-design-system-components.js +1 -1
  86. package/dist/ontario-design-system-components/i18n/global.i18n.json +172 -162
  87. package/dist/ontario-design-system-components/ontario-design-system-components.esm.js +1 -1
  88. package/dist/ontario-design-system-components/ontario-design-system-components.esm.js.map +1 -1
  89. package/dist/ontario-design-system-components/{p-cff41424.entry.js → p-9c3a1be9.entry.js} +2204 -1918
  90. package/dist/ontario-design-system-components/p-9c3a1be9.entry.js.map +1 -0
  91. package/dist/types/components/ontario-card/ontario-card-types.d.ts +4 -4
  92. package/dist/types/components/ontario-card/ontario-card.d.ts +40 -29
  93. package/dist/types/components/ontario-header/ontario-header.d.ts +13 -2
  94. package/dist/types/components/ontario-language-toggle/ontario-language-toggle.d.ts +75 -8
  95. package/dist/types/components/ontario-search-box/ontario-search-box.d.ts +180 -0
  96. package/dist/types/components.d.ts +211 -22
  97. package/dist/types/utils/common/input/input.d.ts +2 -1
  98. package/dist/types/utils/common/input-caption/input-caption.d.ts +7 -1
  99. package/dist/types/utils/common/language-types.d.ts +2 -1
  100. package/dist/types/utils/helper/utils-types.d.ts +2 -0
  101. package/dist/types/utils/helper/utils.d.ts +21 -0
  102. package/package.json +3 -3
  103. package/src/components/ontario-card/ontario-card-types.tsx +33 -4
  104. package/src/components/ontario-card/ontario-card.scss +59 -38
  105. package/src/components/ontario-card/ontario-card.tsx +98 -70
  106. package/src/components/ontario-card/readme.md +57 -27
  107. package/src/components/ontario-card/test/__snapshots__/ontario-cards.spec.tsx.snap +66 -0
  108. package/src/components/ontario-card/test/ontario-cards.spec.tsx +27 -13
  109. package/src/components/ontario-card-collection/readme.md +13 -13
  110. package/src/components/ontario-checkbox/ontario-checkboxes.scss +0 -1
  111. package/src/components/ontario-header/ontario-header.tsx +13 -4
  112. package/src/components/ontario-header/service-ontario-header.scss +0 -4
  113. package/src/components/ontario-header/test/ontario-header.spec.tsx +3 -3
  114. package/src/components/ontario-hint-text/readme.md +2 -0
  115. package/src/components/ontario-language-toggle/ontario-language-toggle.tsx +192 -45
  116. package/src/components/ontario-language-toggle/readme.md +10 -10
  117. package/src/components/ontario-language-toggle/test/__snapshots__/ontario-language-toggle.spec.tsx.snap +1 -1
  118. package/src/components/ontario-language-toggle/test/ontario-language-toggle.spec.tsx +17 -3
  119. package/src/components/ontario-radio-buttons/ontario-radio-buttons.scss +0 -1
  120. package/src/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
  121. package/src/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
  122. package/src/components/ontario-search-box/ontario-search-box.scss +141 -0
  123. package/src/components/ontario-search-box/ontario-search-box.tsx +341 -0
  124. package/src/components/ontario-search-box/readme.md +132 -0
  125. package/src/components/ontario-search-box/test/__snapshots__/ontario-search-box.spec.tsx.snap +35 -0
  126. package/src/components/ontario-search-box/test/ontario-search-box.e2e.ts +21 -0
  127. package/src/components/ontario-search-box/test/ontario-search-box.spec.tsx +22 -0
  128. package/src/components.d.ts +211 -22
  129. package/src/french.html +37 -0
  130. package/src/index.html +292 -38
  131. package/src/translations/global.i18n.json +172 -162
  132. package/src/utils/common/input/input.tsx +4 -1
  133. package/src/utils/common/input-caption/input-caption.tsx +9 -3
  134. package/src/utils/common/language-types.ts +2 -1
  135. package/src/utils/helper/utils-types.ts +2 -0
  136. package/src/utils/helper/utils.ts +30 -0
  137. package/www/build/ontario-design-system-components.esm.js +1 -1
  138. package/www/build/ontario-design-system-components.esm.js.map +1 -1
  139. package/www/build/{p-b61db0f6.js → p-84035ac3.js} +1 -1
  140. package/www/build/{p-cff41424.entry.js → p-9c3a1be9.entry.js} +2204 -1918
  141. package/www/build/p-9c3a1be9.entry.js.map +1 -0
  142. package/www/french.html +37 -0
  143. package/www/i18n/global.i18n.json +172 -162
  144. package/www/index.html +266 -38
  145. package/dist/cjs/ontario-accordion_43.cjs.entry.js.map +0 -1
  146. package/dist/esm/ontario-accordion_43.entry.js.map +0 -1
  147. package/dist/ontario-design-system-components/p-cff41424.entry.js.map +0 -1
  148. package/www/build/p-cff41424.entry.js.map +0 -1
@@ -0,0 +1,584 @@
1
+ import { h } from '@stencil/core';
2
+ import { Input } from '../../utils/common/input/input';
3
+ import OntarioIconSearch from '../ontario-icon/assets/ontario-icon-search.svg';
4
+ import { handleInputEvent } from '../../utils/events/event-handler';
5
+ import { EventType } from '../../utils/events/event-handler.interface';
6
+ import { InputCaption } from '../../utils/common/input-caption/input-caption';
7
+ import { default as translations } from '../../translations/global.i18n.json';
8
+ import { constructHintTextObject } from '../../utils/components/hints/hints';
9
+ export class OntarioSearchBox {
10
+ constructor() {
11
+ /**
12
+ * when the reset button is clicked this function gets called
13
+ */
14
+ this.handleFocus = () => {
15
+ this.setFocus(this.inputFieldRef);
16
+ };
17
+ this.language = 'en';
18
+ this.elementId = undefined;
19
+ this.value = undefined;
20
+ this.caption = undefined;
21
+ this.required = false;
22
+ this.performSearch = undefined;
23
+ this.hintText = undefined;
24
+ this.customOnInput = undefined;
25
+ this.customOnChange = undefined;
26
+ this.customOnBlur = undefined;
27
+ this.customOnFocus = undefined;
28
+ this.internalHintText = undefined;
29
+ this.captionState = undefined;
30
+ this.hintTextId = undefined;
31
+ }
32
+ /**
33
+ * Watch for changes to the `hintText` prop.
34
+ *
35
+ * If a `hintText` prop is passed, the `constructHintTextObject` function will convert it to the correct format, and set the result to the `internalHintText` state.
36
+ */
37
+ parseHintText() {
38
+ if (this.hintText) {
39
+ const hintTextObject = constructHintTextObject(this.hintText);
40
+ this.internalHintText = hintTextObject;
41
+ }
42
+ }
43
+ /**
44
+ * Watch for changes to the `caption` prop.
45
+ *
46
+ * The caption will be run through the InputCaption constructor to convert it to the correct format, and set the result to the `captionState` state.
47
+ * @param newValue: Caption | string
48
+ */
49
+ updateCaptionState(newValue) {
50
+ this.captionState = new InputCaption(
51
+ this.element.tagName,
52
+ newValue,
53
+ translations,
54
+ this.language,
55
+ false,
56
+ this.required,
57
+ );
58
+ }
59
+ /**
60
+ * Watch for changes to the `language` prop to render either the English or French translations
61
+ */
62
+ updateLanguage() {
63
+ this.updateCaptionState(this.caption);
64
+ }
65
+ /**
66
+ * If a `hintText` prop is passed, the id generated from it will be set to the internal `hintTextId` state to match with the select `aria-describedBy` attribute.
67
+ */
68
+ async componentDidLoad() {
69
+ var _a;
70
+ this.hintTextId = await ((_a = this.hintTextRef) === null || _a === void 0 ? void 0 : _a.getHintTextId());
71
+ }
72
+ componentWillLoad() {
73
+ this.elementId = this.elementId;
74
+ this.parseHintText();
75
+ this.updateCaptionState(this.caption);
76
+ }
77
+ /**
78
+ * Function to handle input events and the information pertaining to the input to emit.
79
+ */
80
+ handleEvent(event, eventType) {
81
+ var _a, _b, _c;
82
+ const input = event.target;
83
+ // Update the component value to match the value of the input element.
84
+ this.value = input === null || input === void 0 ? void 0 : input.value;
85
+ (_b = (_a = this.internals) === null || _a === void 0 ? void 0 : _a.setFormValue) === null || _b === void 0
86
+ ? void 0
87
+ : _b.call(_a, (_c = this.value) !== null && _c !== void 0 ? _c : '');
88
+ handleInputEvent(
89
+ event,
90
+ eventType,
91
+ input,
92
+ this.inputOnChange,
93
+ this.inputOnFocus,
94
+ this.inputOnBlur,
95
+ this.inputOnInput,
96
+ 'input',
97
+ this.customOnChange,
98
+ this.customOnFocus,
99
+ this.customOnBlur,
100
+ this.customOnInput,
101
+ this.element,
102
+ );
103
+ }
104
+ /**
105
+ * handleSearch function is called when the search submit button is clicked
106
+ */
107
+ async handleSearch(event) {
108
+ event.preventDefault();
109
+ this.searchOnSubmit.emit(this.value);
110
+ this.performSearch && (await this.performSearch(this.value));
111
+ }
112
+ getId() {
113
+ var _a;
114
+ return (_a = this.elementId) !== null && _a !== void 0 ? _a : '';
115
+ }
116
+ getValue() {
117
+ var _a;
118
+ return (_a = this.value) !== null && _a !== void 0 ? _a : '';
119
+ }
120
+ /**
121
+ *This function ensures that the focus returns to the search input field when the reset button is clicked.
122
+ */
123
+ setFocus(inputRef) {
124
+ if (inputRef) {
125
+ inputRef.focus();
126
+ }
127
+ }
128
+ render() {
129
+ const searchInputFieldId = 'ontario-search-input-field';
130
+ return h(
131
+ 'form',
132
+ {
133
+ key: 'd38c48ed5a4e2301afa130f1557ea721ac9b7909',
134
+ name: 'searchForm',
135
+ id: 'ontario-search-form-container',
136
+ class:
137
+ 'ontario-search__container ontario-columns ontario-small-10 ontario-medium-offset-3 ontario-medium-6 ontario-large-offset-0 ontario-large-6',
138
+ novalidate: true,
139
+ },
140
+ this.captionState.getCaption(searchInputFieldId, false, true) /* Note the _required_ text is disabled */,
141
+ this.internalHintText &&
142
+ h('ontario-hint-text', {
143
+ hint: this.internalHintText.hint,
144
+ hintContentType: this.internalHintText.hintContentType,
145
+ ref: (el) => (this.hintTextRef = el),
146
+ }),
147
+ h(
148
+ 'div',
149
+ { key: '2d495d8e26c97c92ffdf8e3e7f0828224d74825c', class: 'ontario-search__input-container' },
150
+ h(Input, {
151
+ 'key': '38f2cdf8f04aa749958c619174ca40ee32b1d2f4',
152
+ 'aria-describedBy': this.hintTextId,
153
+ 'type': 'search',
154
+ 'name': 'search',
155
+ 'id': searchInputFieldId,
156
+ 'autoComplete': 'off',
157
+ 'aria-autocomplete': 'none',
158
+ 'className': 'ontario-search__input ontario-input',
159
+ 'required': true,
160
+ 'ref': (el) => (this.inputFieldRef = el),
161
+ 'onInput': (e) => this.handleEvent(e, EventType.Input),
162
+ 'onChange': (e) => this.handleEvent(e, EventType.Change),
163
+ 'onBlur': (e) => this.handleEvent(e, EventType.Blur),
164
+ 'onFocus': (e) => this.handleEvent(e, EventType.Focus),
165
+ 'value': this.getValue(),
166
+ }),
167
+ h(Input, {
168
+ key: '20395baddaa5943e9f300eee043b97994e63c0af',
169
+ className: 'ontario-search__reset',
170
+ id: 'ontario-search-reset',
171
+ type: 'reset',
172
+ value: '',
173
+ onClick: () => this.handleFocus(),
174
+ }),
175
+ h(
176
+ 'button',
177
+ {
178
+ key: '89fe9b0762da6f292348b8a4e895bc9637d7253c',
179
+ class: 'ontario-search__submit',
180
+ type: 'submit',
181
+ id: 'ontario-search-box__submit',
182
+ onClick: (e) => this.handleSearch(e),
183
+ },
184
+ h('span', { key: '1091746da37710e5addeeb77780ad92aac33950f', innerHTML: OntarioIconSearch }),
185
+ ),
186
+ ),
187
+ );
188
+ }
189
+ static get is() {
190
+ return 'ontario-search-box';
191
+ }
192
+ static get encapsulation() {
193
+ return 'shadow';
194
+ }
195
+ static get originalStyleUrls() {
196
+ return {
197
+ $: ['ontario-search-box.scss'],
198
+ };
199
+ }
200
+ static get styleUrls() {
201
+ return {
202
+ $: ['ontario-search-box.css'],
203
+ };
204
+ }
205
+ static get properties() {
206
+ return {
207
+ language: {
208
+ type: 'string',
209
+ mutable: true,
210
+ complexType: {
211
+ original: 'Language',
212
+ resolved: '"en" | "fr" | undefined',
213
+ references: {
214
+ Language: {
215
+ location: 'import',
216
+ path: '../../utils/common/language-types',
217
+ id: 'src/utils/common/language-types.ts::Language',
218
+ },
219
+ },
220
+ },
221
+ required: false,
222
+ optional: true,
223
+ docs: {
224
+ tags: [],
225
+ text: 'The language of the component.\nThis is used for translations. If none is passed, it will default to English.',
226
+ },
227
+ attribute: 'language',
228
+ reflect: false,
229
+ defaultValue: "'en'",
230
+ },
231
+ elementId: {
232
+ type: 'string',
233
+ mutable: true,
234
+ complexType: {
235
+ original: 'string',
236
+ resolved: 'string | undefined',
237
+ references: {},
238
+ },
239
+ required: false,
240
+ optional: true,
241
+ docs: {
242
+ tags: [],
243
+ text: 'The unique identifier of the search-box component. This is optional - if no ID is passed, one will be generated.',
244
+ },
245
+ attribute: 'element-id',
246
+ reflect: false,
247
+ },
248
+ value: {
249
+ type: 'string',
250
+ mutable: true,
251
+ complexType: {
252
+ original: 'string',
253
+ resolved: 'string | undefined',
254
+ references: {},
255
+ },
256
+ required: false,
257
+ optional: true,
258
+ docs: {
259
+ tags: [],
260
+ text: 'The value of the search term.\nThis is optional.',
261
+ },
262
+ attribute: 'value',
263
+ reflect: false,
264
+ },
265
+ caption: {
266
+ type: 'string',
267
+ mutable: false,
268
+ complexType: {
269
+ original: 'Caption | string',
270
+ resolved: 'Caption | string',
271
+ references: {
272
+ Caption: {
273
+ location: 'import',
274
+ path: '../../utils/common/input-caption/caption.interface',
275
+ id: 'src/utils/common/input-caption/caption.interface.ts::Caption',
276
+ },
277
+ },
278
+ },
279
+ required: false,
280
+ optional: false,
281
+ docs: {
282
+ tags: [
283
+ {
284
+ name: 'example',
285
+ text: '<ontario-search-box\n\u00A0 \u00A0 \u00A0caption=\'{\n\t\t"captionText": "Search directory",\n\t\t"captionType": "default"\n\t\t}\'\n\trequired = "true"\n>\n</ontario-search-box>',
286
+ },
287
+ ],
288
+ text: 'The text to display as the input label',
289
+ },
290
+ attribute: 'caption',
291
+ reflect: false,
292
+ },
293
+ required: {
294
+ type: 'boolean',
295
+ mutable: false,
296
+ complexType: {
297
+ original: 'boolean',
298
+ resolved: 'boolean | undefined',
299
+ references: {},
300
+ },
301
+ required: false,
302
+ optional: true,
303
+ docs: {
304
+ tags: [],
305
+ text: 'This is used to determine whether the dropdown list is required or not.\nThis prop gets passed to the InputCaption utility to display either an optional or required flag in the label.\nIf no prop is set, it will default to false (optional).',
306
+ },
307
+ attribute: 'required',
308
+ reflect: false,
309
+ defaultValue: 'false',
310
+ },
311
+ performSearch: {
312
+ type: 'unknown',
313
+ mutable: false,
314
+ complexType: {
315
+ original: '(value?: string) => Promise<void>',
316
+ resolved: '((value?: string | undefined) => Promise<void>) | undefined',
317
+ references: {
318
+ Promise: {
319
+ location: 'global',
320
+ id: 'global::Promise',
321
+ },
322
+ },
323
+ },
324
+ required: false,
325
+ optional: true,
326
+ docs: {
327
+ tags: [
328
+ {
329
+ name: 'example',
330
+ text: "<ontario-search-box\n id=\"ontario-search-box\"\n caption='Search directory'\n></ontario-search-box>\n\n<script>\nwindow.addEventListener('load', () => {\n\tconst searchBox = document.getElementById('ontario-search-box');\n\tsearchBox.performSearch = async (value) => {\n\t\t\tconsole.log('Performing search with value:', value);\n\t};\n});\n</script>",
331
+ },
332
+ ],
333
+ text: 'This Function to perform a search operation.\nThis function will be called when the search submit button is triggered.\nThe value argument is used for as search term to use for the search operation. This parameter is optional.\nThe performSearch prop can be set dynamically using JavaScript, allowing you to define custom search functionality when the search form is submitted.',
334
+ },
335
+ },
336
+ hintText: {
337
+ type: 'string',
338
+ mutable: false,
339
+ complexType: {
340
+ original: 'string | Hint',
341
+ resolved: 'Hint | string | undefined',
342
+ references: {
343
+ Hint: {
344
+ location: 'import',
345
+ path: '../../utils/common/common.interface',
346
+ id: 'src/utils/common/common.interface.ts::Hint',
347
+ },
348
+ },
349
+ },
350
+ required: false,
351
+ optional: true,
352
+ docs: {
353
+ tags: [],
354
+ text: 'Used to include the ontario-hint-text component for the search-box.\nThis is optional.',
355
+ },
356
+ attribute: 'hint-text',
357
+ reflect: false,
358
+ },
359
+ customOnInput: {
360
+ type: 'unknown',
361
+ mutable: false,
362
+ complexType: {
363
+ original: '(event: globalThis.Event) => void',
364
+ resolved: '((event: Event) => void) | undefined',
365
+ references: {
366
+ globalThis: {
367
+ location: 'global',
368
+ id: 'global::globalThis',
369
+ },
370
+ },
371
+ },
372
+ required: false,
373
+ optional: true,
374
+ docs: {
375
+ tags: [],
376
+ text: 'Used to add a custom function to the input onInput event.',
377
+ },
378
+ },
379
+ customOnChange: {
380
+ type: 'unknown',
381
+ mutable: false,
382
+ complexType: {
383
+ original: '(event: globalThis.Event) => void',
384
+ resolved: '((event: Event) => void) | undefined',
385
+ references: {
386
+ globalThis: {
387
+ location: 'global',
388
+ id: 'global::globalThis',
389
+ },
390
+ },
391
+ },
392
+ required: false,
393
+ optional: true,
394
+ docs: {
395
+ tags: [],
396
+ text: 'Used to add a custom function to the input onChange event.',
397
+ },
398
+ },
399
+ customOnBlur: {
400
+ type: 'unknown',
401
+ mutable: false,
402
+ complexType: {
403
+ original: '(event: globalThis.Event) => void',
404
+ resolved: '((event: Event) => void) | undefined',
405
+ references: {
406
+ globalThis: {
407
+ location: 'global',
408
+ id: 'global::globalThis',
409
+ },
410
+ },
411
+ },
412
+ required: false,
413
+ optional: true,
414
+ docs: {
415
+ tags: [],
416
+ text: 'Used to add a custom function to the input onBlur event.',
417
+ },
418
+ },
419
+ customOnFocus: {
420
+ type: 'unknown',
421
+ mutable: false,
422
+ complexType: {
423
+ original: '(event: globalThis.Event) => void',
424
+ resolved: '((event: Event) => void) | undefined',
425
+ references: {
426
+ globalThis: {
427
+ location: 'global',
428
+ id: 'global::globalThis',
429
+ },
430
+ },
431
+ },
432
+ required: false,
433
+ optional: true,
434
+ docs: {
435
+ tags: [],
436
+ text: 'Used to add a custom function to the input onFocus event.',
437
+ },
438
+ },
439
+ };
440
+ }
441
+ static get states() {
442
+ return {
443
+ internalHintText: {},
444
+ captionState: {},
445
+ hintTextId: {},
446
+ };
447
+ }
448
+ static get events() {
449
+ return [
450
+ {
451
+ method: 'searchOnSubmit',
452
+ name: 'searchOnSubmit',
453
+ bubbles: true,
454
+ cancelable: true,
455
+ composed: true,
456
+ docs: {
457
+ tags: [
458
+ {
459
+ name: 'example',
460
+ text: "<script>\n\tdocument.getElementById('ontario-search-box').addEventListener('searchOnSubmit', (event) => {\n \t\tconst searchValue = event.detail;\n\t\tconsole.log('Search submitted with value:', searchValue);\n };\n\t</script>",
461
+ },
462
+ ],
463
+ text: 'Emitted when the search is submitted.\nBelow is an example on how to hook into the event to get the event details.',
464
+ },
465
+ complexType: {
466
+ original: 'string',
467
+ resolved: 'string',
468
+ references: {},
469
+ },
470
+ },
471
+ {
472
+ method: 'inputOnInput',
473
+ name: 'inputOnInput',
474
+ bubbles: true,
475
+ cancelable: true,
476
+ composed: true,
477
+ docs: {
478
+ tags: [],
479
+ text: 'Emitted when a input \u00A0occurs when an input has been changed.',
480
+ },
481
+ complexType: {
482
+ original: 'InputInputEvent',
483
+ resolved: 'InputInteractionEvent & { inputType?: string | undefined; }',
484
+ references: {
485
+ InputInputEvent: {
486
+ location: 'import',
487
+ path: '../../utils/events/event-handler.interface',
488
+ id: 'src/utils/events/event-handler.interface.ts::InputInputEvent',
489
+ },
490
+ },
491
+ },
492
+ },
493
+ {
494
+ method: 'inputOnChange',
495
+ name: 'inputOnChange',
496
+ bubbles: true,
497
+ cancelable: true,
498
+ composed: true,
499
+ docs: {
500
+ tags: [],
501
+ text: 'Emitted when a keyboard input or mouse event occurs when an input has been changed.',
502
+ },
503
+ complexType: {
504
+ original: 'InputInteractionEvent',
505
+ resolved: '{ id?: string | undefined; value?: string | undefined; }',
506
+ references: {
507
+ InputInteractionEvent: {
508
+ location: 'import',
509
+ path: '../../utils/events/event-handler.interface',
510
+ id: 'src/utils/events/event-handler.interface.ts::InputInteractionEvent',
511
+ },
512
+ },
513
+ },
514
+ },
515
+ {
516
+ method: 'inputOnBlur',
517
+ name: 'inputOnBlur',
518
+ bubbles: true,
519
+ cancelable: true,
520
+ composed: true,
521
+ docs: {
522
+ tags: [],
523
+ text: 'Emitted when a keyboard input event occurs when an input has lost focus.',
524
+ },
525
+ complexType: {
526
+ original: 'InputFocusBlurEvent',
527
+ resolved: 'InputInteractionEvent & { focused: boolean; }',
528
+ references: {
529
+ InputFocusBlurEvent: {
530
+ location: 'import',
531
+ path: '../../utils/events/event-handler.interface',
532
+ id: 'src/utils/events/event-handler.interface.ts::InputFocusBlurEvent',
533
+ },
534
+ },
535
+ },
536
+ },
537
+ {
538
+ method: 'inputOnFocus',
539
+ name: 'inputOnFocus',
540
+ bubbles: true,
541
+ cancelable: true,
542
+ composed: true,
543
+ docs: {
544
+ tags: [],
545
+ text: 'Emitted when a keyboard input event occurs when an input has gained focus.',
546
+ },
547
+ complexType: {
548
+ original: 'InputFocusBlurEvent',
549
+ resolved: 'InputInteractionEvent & { focused: boolean; }',
550
+ references: {
551
+ InputFocusBlurEvent: {
552
+ location: 'import',
553
+ path: '../../utils/events/event-handler.interface',
554
+ id: 'src/utils/events/event-handler.interface.ts::InputFocusBlurEvent',
555
+ },
556
+ },
557
+ },
558
+ },
559
+ ];
560
+ }
561
+ static get elementRef() {
562
+ return 'element';
563
+ }
564
+ static get watchers() {
565
+ return [
566
+ {
567
+ propName: 'hintText',
568
+ methodName: 'parseHintText',
569
+ },
570
+ {
571
+ propName: 'caption',
572
+ methodName: 'updateCaptionState',
573
+ },
574
+ {
575
+ propName: 'language',
576
+ methodName: 'updateLanguage',
577
+ },
578
+ ];
579
+ }
580
+ static get attachInternalsMemberName() {
581
+ return 'internals';
582
+ }
583
+ }
584
+ //# sourceMappingURL=ontario-search-box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ontario-search-box.js","sourceRoot":"","sources":["../../../src/components/ontario-search-box/ontario-search-box.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI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il/core';\nimport { Input } from '../../utils/common/input/input';\nimport { Language } from '../../utils/common/language-types';\nimport OntarioIconSearch from '../ontario-icon/assets/ontario-icon-search.svg';\nimport { Hint } from '../../utils/common/common.interface';\nimport { handleInputEvent } from '../../utils/events/event-handler';\nimport {\n\tInputFocusBlurEvent,\n\tEventType,\n\tInputInteractionEvent,\n\tInputInputEvent,\n} from '../../utils/events/event-handler.interface';\nimport { Caption } from '../../utils/common/input-caption/caption.interface';\nimport { InputCaption } from '../../utils/common/input-caption/input-caption';\nimport { default as translations } from '../../translations/global.i18n.json';\nimport { constructHintTextObject } from '../../utils/components/hints/hints';\n\n@Component({\n\ttag: 'ontario-search-box',\n\tstyleUrl: 'ontario-search-box.scss',\n\tshadow: true,\n})\nexport class OntarioSearchBox {\n\t@Element() element: HTMLElement;\n\t@AttachInternals() internals: ElementInternals;\n\n\t/**\n\t * This Ref is used get a direct reference to the hint text element\n\t */\n\tprivate hintTextRef?: HTMLOntarioHintTextElement;\n\n\t/**\n\t * This Ref is used get a direct reference to the search input element\n\t */\n\tprivate inputFieldRef?: HTMLInputElement;\n\n\t/**\n\t * The language of the component.\n\t * This is used for translations. If none is passed, it will default to English.\n\t */\n\t@Prop({ mutable: true }) language?: Language = 'en';\n\n\t/**\n\t * The unique identifier of the search-box component. This is optional - if no ID is passed, one will be generated.\n\t */\n\t@Prop({ mutable: true }) elementId?: string;\n\n\t/**\n\t * The value of the search term.\n\t * This is optional.\n\t */\n\t@Prop({ mutable: true }) value?: string;\n\n\t/**\n\t* The text to display as the input label\n\t*\n\t* @example\n\t* <ontario-search-box\n\t*      caption='{\n\t\t\t\t\t\"captionText\": \"Search directory\",\n\t\t\t\t\t\"captionType\": \"default\"\n\t\t\t\t\t}'\n\t\t\t\trequired = \"true\"\n\t>\n\t</ontario-search-box>\n\t*/\n\t@Prop() caption: Caption | string;\n\n\t/**\n\t * This is used to determine whether the dropdown list is required or not.\n\t * This prop gets passed to the InputCaption utility to display either an optional or required flag in the label.\n\t * If no prop is set, it will default to false (optional).\n\t */\n\t@Prop() required?: boolean = false;\n\n\t/**\n\t * This Function to perform a search operation.\n\t * This function will be called when the search submit button is triggered.\n\t * The value argument is used for as search term to use for the search operation. This parameter is optional.\n\t * The performSearch prop can be set dynamically using JavaScript, allowing you to define custom search functionality when the search form is submitted.\n\t *\n\t * @example\n\t * <ontario-search-box\n\t *\t id=\"ontario-search-box\"\n\t *\t caption='Search directory'\n\t * ></ontario-search-box>\n\t *\n\t * <script>\n\t *\twindow.addEventListener('load', () => {\n\t *\t\tconst searchBox = document.getElementById('ontario-search-box');\n\t *\t\tsearchBox.performSearch = async (value) => {\n\t * \t\t\tconsole.log('Performing search with value:', value);\n\t *\t\t};\n\t *\t});\n\t * </script>\n\t */\n\t@Prop() performSearch?: (value?: string) => Promise<void>;\n\n\t/**\n\t * Used to include the ontario-hint-text component for the search-box.\n\t * This is optional.\n\t */\n\t@Prop() hintText?: string | Hint;\n\n\t/**\n\t * Used to add a custom function to the input onInput event.\n\t */\n\t@Prop() customOnInput?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Used to add a custom function to the input onChange event.\n\t */\n\t@Prop() customOnChange?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Used to add a custom function to the input onBlur event.\n\t */\n\t@Prop() customOnBlur?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Used to add a custom function to the input onFocus event.\n\t */\n\t@Prop() customOnFocus?: (event: globalThis.Event) => void;\n\n\t/**\n\t * Emitted when the search is submitted.\n\t * Below is an example on how to hook into the event to get the event details.\n\t *\n\t * @example\n\t *\t<script>\n\t *\t\tdocument.getElementById('ontario-search-box').addEventListener('searchOnSubmit', (event) => {\n\t *\t \t\tconst searchValue = event.detail;\n\t *\t\t\tconsole.log('Search submitted with value:', searchValue);\n\t *\t };\n\t * \t</script>\n\t */\n\t@Event() searchOnSubmit: EventEmitter<string>;\n\n\t/**\n\t * Emitted when a input  occurs when an input has been changed.\n\t */\n\t@Event() inputOnInput: EventEmitter<InputInputEvent>;\n\n\t/**\n\t * Emitted when a keyboard input or mouse event occurs when an input has been changed.\n\t */\n\t@Event() inputOnChange: EventEmitter<InputInteractionEvent>;\n\n\t/**\n\t * Emitted when a keyboard input event occurs when an input has lost focus.\n\t */\n\t@Event() inputOnBlur: EventEmitter<InputFocusBlurEvent>;\n\n\t/**\n\t * Emitted when a keyboard input event occurs when an input has gained focus.\n\t */\n\t@Event() inputOnFocus: EventEmitter<InputFocusBlurEvent>;\n\n\t/**\n\t * The hint text options are re-assigned to the internalHintText array.\n\t */\n\t@State() private internalHintText: Hint;\n\n\t/**\n\t * Instantiate an InputCaption object for internal logic use\n\t */\n\t@State() private captionState: InputCaption;\n\n\t/**\n\t * Used for the `aria-describedby` value of the dropdown list. This will match with the id of the hint text.\n\t */\n\t@State() hintTextId: string | null | undefined;\n\n\t/**\n\t * Watch for changes to the `hintText` prop.\n\t *\n\t * If a `hintText` prop is passed, the `constructHintTextObject` function will convert it to the correct format, and set the result to the `internalHintText` state.\n\t */\n\t@Watch('hintText')\n\tprivate parseHintText() {\n\t\tif (this.hintText) {\n\t\t\tconst hintTextObject = constructHintTextObject(this.hintText);\n\t\t\tthis.internalHintText = hintTextObject;\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `caption` prop.\n\t *\n\t * The caption will be run through the InputCaption constructor to convert it to the correct format, and set the result to the `captionState` state.\n\t * @param newValue: Caption | string\n\t */\n\t@Watch('caption')\n\tprivate updateCaptionState(newValue: Caption | string) {\n\t\tthis.captionState = new InputCaption(\n\t\t\tthis.element.tagName,\n\t\t\tnewValue,\n\t\t\ttranslations,\n\t\t\tthis.language,\n\t\t\tfalse,\n\t\t\tthis.required,\n\t\t);\n\t}\n\n\t/**\n\t * Watch for changes to the `language` prop to render either the English or French translations\n\t */\n\t@Watch('language')\n\tupdateLanguage() {\n\t\tthis.updateCaptionState(this.caption);\n\t}\n\n\t/**\n\t * If a `hintText` prop is passed, the id generated from it will be set to the internal `hintTextId` state to match with the select `aria-describedBy` attribute.\n\t */\n\tasync componentDidLoad() {\n\t\tthis.hintTextId = await this.hintTextRef?.getHintTextId();\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.elementId = this.elementId;\n\t\tthis.parseHintText();\n\t\tthis.updateCaptionState(this.caption);\n\t}\n\n\t/**\n\t * Function to handle input events and the information pertaining to the input to emit.\n\t */\n\tprivate handleEvent(event: globalThis.Event, eventType: EventType) {\n\t\tconst input = event.target as HTMLInputElement | null;\n\n\t\t// Update the component value to match the value of the input element.\n\t\tthis.value = input?.value;\n\n\t\tthis.internals?.setFormValue?.(this.value ?? '');\n\n\t\thandleInputEvent(\n\t\t\tevent,\n\t\t\teventType,\n\t\t\tinput,\n\t\t\tthis.inputOnChange,\n\t\t\tthis.inputOnFocus,\n\t\t\tthis.inputOnBlur,\n\t\t\tthis.inputOnInput,\n\t\t\t'input',\n\t\t\tthis.customOnChange,\n\t\t\tthis.customOnFocus,\n\t\t\tthis.customOnBlur,\n\t\t\tthis.customOnInput,\n\t\t\tthis.element,\n\t\t);\n\t}\n\n\t/**\n\t * handleSearch function is called when the search submit button is clicked\n\t */\n\tasync handleSearch(event: MouseEvent) {\n\t\tevent.preventDefault();\n\t\tthis.searchOnSubmit.emit(this.value);\n\t\tthis.performSearch && (await this.performSearch(this.value));\n\t}\n\n\tpublic getId(): string {\n\t\treturn this.elementId ?? '';\n\t}\n\n\tprivate getValue(): string | number {\n\t\treturn this.value ?? '';\n\t}\n\n\t/**\n\t *This function ensures that the focus returns to the search input field when the reset button is clicked.\n\t */\n\tprivate setFocus(inputRef?: HTMLInputElement) {\n\t\tif (inputRef) {\n\t\t\tinputRef.focus();\n\t\t}\n\t}\n\n\t/**\n\t * when the reset button is clicked this function gets called\n\t */\n\thandleFocus = () => {\n\t\tthis.setFocus(this.inputFieldRef);\n\t};\n\n\trender() {\n\t\tconst searchInputFieldId: string = 'ontario-search-input-field';\n\t\treturn (\n\t\t\t<form\n\t\t\t\tname=\"searchForm\"\n\t\t\t\tid=\"ontario-search-form-container\"\n\t\t\t\tclass=\"ontario-search__container ontario-columns ontario-small-10 ontario-medium-offset-3 ontario-medium-6 ontario-large-offset-0 ontario-large-6\"\n\t\t\t\tnovalidate\n\t\t\t>\n\t\t\t\t{this.captionState.getCaption(searchInputFieldId, false, true) /* Note the _required_ text is disabled */}\n\t\t\t\t{this.internalHintText && (\n\t\t\t\t\t<ontario-hint-text\n\t\t\t\t\t\thint={this.internalHintText.hint}\n\t\t\t\t\t\thintContentType={this.internalHintText.hintContentType}\n\t\t\t\t\t\tref={(el) => (this.hintTextRef = el)}\n\t\t\t\t\t></ontario-hint-text>\n\t\t\t\t)}\n\n\t\t\t\t<div class=\"ontario-search__input-container\">\n\t\t\t\t\t<Input\n\t\t\t\t\t\taria-describedBy={this.hintTextId}\n\t\t\t\t\t\ttype=\"search\"\n\t\t\t\t\t\tname=\"search\"\n\t\t\t\t\t\tid={searchInputFieldId}\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\taria-autocomplete=\"none\"\n\t\t\t\t\t\tclassName=\"ontario-search__input ontario-input\"\n\t\t\t\t\t\trequired={true}\n\t\t\t\t\t\tref={(el) => (this.inputFieldRef = el)}\n\t\t\t\t\t\tonInput={(e) => this.handleEvent(e, EventType.Input)}\n\t\t\t\t\t\tonChange={(e) => this.handleEvent(e, EventType.Change)}\n\t\t\t\t\t\tonBlur={(e) => this.handleEvent(e, EventType.Blur)}\n\t\t\t\t\t\tonFocus={(e) => this.handleEvent(e, EventType.Focus)}\n\t\t\t\t\t\tvalue={this.getValue()}\n\t\t\t\t\t></Input>\n\t\t\t\t\t<Input\n\t\t\t\t\t\tclassName=\"ontario-search__reset\"\n\t\t\t\t\t\tid=\"ontario-search-reset\"\n\t\t\t\t\t\ttype=\"reset\"\n\t\t\t\t\t\tvalue=\"\"\n\t\t\t\t\t\tonClick={() => this.handleFocus()}\n\t\t\t\t\t></Input>\n\t\t\t\t\t<button\n\t\t\t\t\t\tclass=\"ontario-search__submit\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\tid=\"ontario-search-box__submit\"\n\t\t\t\t\t\tonClick={(e) => this.handleSearch(e)}\n\t\t\t\t\t>\n\t\t\t\t\t\t<span innerHTML={OntarioIconSearch} />\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</form>\n\t\t);\n\t}\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { newE2EPage } from '@stencil/core/testing';
2
+ describe('ontario-search-box', () => {
3
+ //checks if the component has hydrated class
4
+ it('renders', async () => {
5
+ const page = await newE2EPage();
6
+ await page.setContent(`<ontario-search-box></ontario-search-box>`);
7
+ const element = await page.find('ontario-search-box');
8
+ expect(element).toHaveClass('hydrated');
9
+ });
10
+ it('checks the onclick event', async () => {
11
+ const page = await newE2EPage();
12
+ await page.setContent('<ontario-search-box></ontario-search-box>');
13
+ const changedEvent = await page.spyOnEvent('click');
14
+ const component = await page.find('ontario-search-box >>> #ontario-search-submit');
15
+ component.click();
16
+ await page.waitForChanges();
17
+ expect(changedEvent).toHaveReceivedEventTimes(1);
18
+ });
19
+ });
20
+ //# sourceMappingURL=ontario-search-box.e2e.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ontario-search-box.e2e.js","sourceRoot":"","sources":["../../../../src/components/ontario-search-box/test/ontario-search-box.e2e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IACnC,4CAA4C;IAC5C,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACxB,MAAM,IAAI,GAAG,MAAM,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,CAAC,UAAU,CAAC,2CAA2C,CAAC,CAAC;QACnE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACtD,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,IAAI,GAAG,MAAM,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,CAAC,UAAU,CAAC,2CAA2C,CAAC,CAAC;QACnE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACpD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;QACnF,SAAS,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,MAAM,CAAC,YAAY,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { newE2EPage } from '@stencil/core/testing';\n\ndescribe('ontario-search-box', () => {\n\t//checks if the component has hydrated class\n\tit('renders', async () => {\n\t\tconst page = await newE2EPage();\n\t\tawait page.setContent(`<ontario-search-box></ontario-search-box>`);\n\t\tconst element = await page.find('ontario-search-box');\n\t\texpect(element).toHaveClass('hydrated');\n\t});\n\n\tit('checks the onclick event', async () => {\n\t\tconst page = await newE2EPage();\n\t\tawait page.setContent('<ontario-search-box></ontario-search-box>');\n\t\tconst changedEvent = await page.spyOnEvent('click');\n\t\tconst component = await page.find('ontario-search-box >>> #ontario-search-submit');\n\t\tcomponent.click();\n\t\tawait page.waitForChanges();\n\t\texpect(changedEvent).toHaveReceivedEventTimes(1);\n\t});\n});\n"]}
@@ -0,0 +1,19 @@
1
+ import { newSpecPage } from '@stencil/core/testing';
2
+ import { OntarioSearchBox } from '../ontario-search-box';
3
+ describe('ontario-search-box', () => {
4
+ it('should render the expected html', async () => {
5
+ const page = await newSpecPage({
6
+ components: [OntarioSearchBox],
7
+ html: `<ontario-search-box id="ontario-search-box" class="hydrated"></ontario-search-box>`,
8
+ });
9
+ expect(page.root).toMatchSnapshot();
10
+ });
11
+ it('should render a default search box element', async () => {
12
+ const page = await newSpecPage({
13
+ components: [OntarioSearchBox],
14
+ html: `<ontario-search-box></ontario-search-box>`,
15
+ });
16
+ expect(page.root).toMatchSnapshot();
17
+ });
18
+ });
19
+ //# sourceMappingURL=ontario-search-box.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ontario-search-box.spec.js","sourceRoot":"","sources":["../../../../src/components/ontario-search-box/test/ontario-search-box.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,gBAAgB,CAAC;YAC9B,IAAI,EAAE,oFAAoF;SAC1F,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC3D,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,gBAAgB,CAAC;YAC9B,IAAI,EAAE,2CAA2C;SACjD,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { OntarioSearchBox } from '../ontario-search-box';\n\ndescribe('ontario-search-box', () => {\n\tit('should render the expected html', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioSearchBox],\n\t\t\thtml: `<ontario-search-box id=\"ontario-search-box\" class=\"hydrated\"></ontario-search-box>`,\n\t\t});\n\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n\n\tit('should render a default search box element', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioSearchBox],\n\t\t\thtml: `<ontario-search-box></ontario-search-box>`,\n\t\t});\n\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n});\n"]}