@ongov/ontario-design-system-component-library 4.3.0-alpha.3 → 4.3.1-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/loader.cjs.js +1 -1
- package/dist/cjs/ontario-accordion_43.cjs.entry.js +404 -223
- package/dist/cjs/ontario-accordion_43.cjs.entry.js.map +1 -1
- package/dist/cjs/ontario-design-system-components.cjs.js +1 -1
- package/dist/collection/components/ontario-card/ontario-card.css +13 -5
- package/dist/collection/components/ontario-card/ontario-card.js +10 -10
- package/dist/collection/components/ontario-card/ontario-card.js.map +1 -1
- package/dist/collection/components/ontario-card/test/ontario-cards.spec.js +1 -1
- 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/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/i18n/global.i18n.json +172 -162
- 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/global.i18n.js +184 -173
- package/dist/components/global.i18n.js.map +1 -1
- package/dist/components/ontario-card.js +11 -11
- package/dist/components/ontario-card.js.map +1 -1
- package/dist/components/ontario-header.js +11 -3
- package/dist/components/ontario-header.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/utils.js +28 -0
- package/dist/components/utils.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/ontario-accordion_43.entry.js +404 -223
- package/dist/esm/ontario-accordion_43.entry.js.map +1 -1
- 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-abe58ec9.entry.js} +697 -608
- package/dist/ontario-design-system-components/p-abe58ec9.entry.js.map +1 -0
- 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.d.ts +12 -6
- 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.scss +13 -6
- package/src/components/ontario-card/ontario-card.tsx +8 -6
- package/src/components/ontario-card/test/ontario-cards.spec.tsx +1 -1
- package/src/components/ontario-header/ontario-header.tsx +13 -4
- package/src/components/ontario-header/test/ontario-header.spec.tsx +3 -3
- 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.d.ts +12 -6
- package/src/french.html +37 -0
- package/src/index.html +19 -0
- package/src/translations/global.i18n.json +172 -162
- 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-cff41424.entry.js → p-abe58ec9.entry.js} +697 -608
- package/www/build/p-abe58ec9.entry.js.map +1 -0
- package/www/build/{p-b61db0f6.js → p-fdc9ab6d.js} +1 -1
- package/www/french.html +37 -0
- package/www/i18n/global.i18n.json +172 -162
- package/www/index.html +21 -2
- package/dist/ontario-design-system-components/p-cff41424.entry.js.map +0 -1
- package/www/build/p-cff41424.entry.js.map +0 -1
|
@@ -16,157 +16,57 @@ import {
|
|
|
16
16
|
} from './index-500b6334.js';
|
|
17
17
|
import { C as ConsoleMessageClass, a as ConsoleType } from './console-message-0b8e564e.js';
|
|
18
18
|
|
|
19
|
-
const required = {
|
|
20
|
-
en: 'required',
|
|
21
|
-
fr: 'obligatoire',
|
|
22
|
-
};
|
|
23
|
-
const optional = {
|
|
24
|
-
en: 'optional',
|
|
25
|
-
fr: 'facultative',
|
|
26
|
-
};
|
|
27
19
|
const accessibility = {
|
|
28
|
-
moreInfo: {
|
|
29
|
-
en: 'More information on',
|
|
30
|
-
fr: 'Des renseignements supplémentaires sur',
|
|
31
|
-
},
|
|
32
20
|
checkboxHintExpander: {
|
|
33
21
|
en: 'is available after the last checkbox item.',
|
|
34
22
|
fr: 'suivront à la dernière case à cocher.',
|
|
35
23
|
},
|
|
24
|
+
moreInfo: {
|
|
25
|
+
en: 'More information on',
|
|
26
|
+
fr: 'Des renseignements supplémentaires sur',
|
|
27
|
+
},
|
|
36
28
|
singleHintExpander: {
|
|
37
29
|
en: 'field is available in the next element.',
|
|
38
30
|
fr: 'suivront au prochain élément.',
|
|
39
31
|
},
|
|
40
32
|
};
|
|
41
|
-
const backToTop = {
|
|
42
|
-
top: {
|
|
43
|
-
en: 'Top',
|
|
44
|
-
fr: 'Haut',
|
|
45
|
-
},
|
|
46
|
-
ariaLabel: {
|
|
47
|
-
en: 'Scroll back to the top',
|
|
48
|
-
fr: 'Retour en haut de la page',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
const loading = {
|
|
52
|
-
en: 'Loading',
|
|
53
|
-
fr: 'Chargement',
|
|
54
|
-
};
|
|
55
|
-
const dropdownList = {
|
|
56
|
-
select: {
|
|
57
|
-
en: 'Select',
|
|
58
|
-
fr: 'Sélectionner',
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
const contactUs = {
|
|
62
|
-
en: 'Contact us',
|
|
63
|
-
fr: 'Contactez-nous',
|
|
64
|
-
};
|
|
65
33
|
const accessibilityLink = {
|
|
66
|
-
text: {
|
|
67
|
-
en: 'Accessibility',
|
|
68
|
-
fr: 'Accessibilité',
|
|
69
|
-
},
|
|
70
34
|
link: {
|
|
71
35
|
en: 'https://www.ontario.ca/page/accessibility',
|
|
72
36
|
fr: 'https://www.ontario.ca/fr/page/accessibilite',
|
|
73
37
|
},
|
|
74
|
-
};
|
|
75
|
-
const privacyLink = {
|
|
76
38
|
text: {
|
|
77
|
-
en: '
|
|
78
|
-
fr: '
|
|
79
|
-
},
|
|
80
|
-
link: {
|
|
81
|
-
en: 'https://www.ontario.ca/page/privacy-statement',
|
|
82
|
-
fr: 'https://www.ontario.ca/fr/page/declaration-concernant-la-protection-de-la-vie-privee',
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
const printerLink = {
|
|
86
|
-
text: {
|
|
87
|
-
en: "King's Printer for Ontario,",
|
|
88
|
-
fr: 'Imprimeur du Roi pour l’Ontario,',
|
|
89
|
-
},
|
|
90
|
-
link: {
|
|
91
|
-
en: 'https://www.ontario.ca/page/copyright-information',
|
|
92
|
-
fr: 'https://www.ontario.ca/fr/page/droits-dauteur',
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
const languageToggle = {
|
|
96
|
-
ariaLabel: {
|
|
97
|
-
en: 'Click to switch language to French',
|
|
98
|
-
fr: 'Cliquez pour changer de langue en anglais',
|
|
39
|
+
en: 'Accessibility',
|
|
40
|
+
fr: 'Accessibilité',
|
|
99
41
|
},
|
|
100
42
|
};
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
en: '
|
|
104
|
-
fr: '
|
|
105
|
-
},
|
|
106
|
-
step: {
|
|
107
|
-
en: 'Step',
|
|
108
|
-
fr: 'Étape',
|
|
43
|
+
const accordion = {
|
|
44
|
+
collapse: {
|
|
45
|
+
en: 'Collapse all',
|
|
46
|
+
fr: 'Réduire tout',
|
|
109
47
|
},
|
|
110
|
-
|
|
111
|
-
en: '
|
|
112
|
-
fr: '
|
|
48
|
+
expand: {
|
|
49
|
+
en: 'Expand all',
|
|
50
|
+
fr: 'Agrandir tout',
|
|
113
51
|
},
|
|
114
|
-
|
|
115
|
-
en: '
|
|
116
|
-
fr: '
|
|
52
|
+
expandCollapseAriaLabel: {
|
|
53
|
+
en: 'Expand or collapse the accordion',
|
|
54
|
+
fr: "Agrandissez ou réduisez l'accordéon",
|
|
117
55
|
},
|
|
118
56
|
};
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
en: '
|
|
122
|
-
fr: '
|
|
123
|
-
},
|
|
124
|
-
logoLink: {
|
|
125
|
-
en: 'https://www.ontario.ca/page/government-ontario',
|
|
126
|
-
fr: 'https://www.ontario.ca/fr/page/gouvernement-de-lontario',
|
|
127
|
-
},
|
|
128
|
-
logoAltText: {
|
|
129
|
-
en: 'Ontario.ca homepage',
|
|
130
|
-
fr: 'Page d’accueil Ontario.ca',
|
|
131
|
-
},
|
|
132
|
-
clearSearchField: {
|
|
133
|
-
en: 'Clear field',
|
|
134
|
-
fr: 'Vider le champ',
|
|
135
|
-
},
|
|
136
|
-
submit: {
|
|
137
|
-
en: 'Submit',
|
|
138
|
-
fr: 'Soumission',
|
|
139
|
-
},
|
|
140
|
-
search: {
|
|
141
|
-
en: 'Search',
|
|
142
|
-
fr: 'Rechercher',
|
|
143
|
-
},
|
|
144
|
-
serviceOntario: {
|
|
145
|
-
en: 'ServiceOntario',
|
|
146
|
-
fr: 'ServiceOntario',
|
|
147
|
-
},
|
|
148
|
-
openMenu: {
|
|
149
|
-
en: 'Show navigation menu',
|
|
150
|
-
fr: 'Ouvrir le menu de navigation',
|
|
151
|
-
},
|
|
152
|
-
closeMenu: {
|
|
153
|
-
en: 'Hide navigation menu',
|
|
154
|
-
fr: 'Fermer le menu de navigation',
|
|
155
|
-
},
|
|
156
|
-
close: {
|
|
157
|
-
en: 'close',
|
|
158
|
-
fr: 'fermer',
|
|
57
|
+
const backToTop = {
|
|
58
|
+
ariaLabel: {
|
|
59
|
+
en: 'Scroll back to the top',
|
|
60
|
+
fr: 'Retour en haut de la page',
|
|
159
61
|
},
|
|
160
|
-
|
|
161
|
-
en: '
|
|
162
|
-
fr: '
|
|
62
|
+
top: {
|
|
63
|
+
en: 'Top',
|
|
64
|
+
fr: 'Haut',
|
|
163
65
|
},
|
|
164
66
|
};
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
fr: 'Ce champ est obligatoire.',
|
|
169
|
-
},
|
|
67
|
+
const contactUs = {
|
|
68
|
+
en: 'Contact us',
|
|
69
|
+
fr: 'Contactez-nous',
|
|
170
70
|
};
|
|
171
71
|
const dateInput = {
|
|
172
72
|
caption: {
|
|
@@ -174,43 +74,23 @@ const dateInput = {
|
|
|
174
74
|
fr: 'Dates exactes',
|
|
175
75
|
},
|
|
176
76
|
day: {
|
|
177
|
-
label: {
|
|
178
|
-
en: 'Day',
|
|
179
|
-
fr: 'Jour',
|
|
180
|
-
},
|
|
181
77
|
accessibility: {
|
|
182
78
|
en: '4 digits',
|
|
183
79
|
fr: '4 chiffres',
|
|
184
80
|
},
|
|
185
|
-
},
|
|
186
|
-
month: {
|
|
187
|
-
label: {
|
|
188
|
-
en: 'Month',
|
|
189
|
-
fr: 'Mois',
|
|
190
|
-
},
|
|
191
|
-
accessibility: {
|
|
192
|
-
en: '1 or 2 digits',
|
|
193
|
-
fr: '1 ou 2 chiffres',
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
year: {
|
|
197
81
|
label: {
|
|
198
|
-
en: '
|
|
199
|
-
fr: '
|
|
200
|
-
},
|
|
201
|
-
accessibility: {
|
|
202
|
-
en: '1 or 2 digits',
|
|
203
|
-
fr: '1 ou 2 chiffres',
|
|
82
|
+
en: 'Day',
|
|
83
|
+
fr: 'Jour',
|
|
204
84
|
},
|
|
205
85
|
},
|
|
206
86
|
error: {
|
|
207
87
|
en: {
|
|
208
88
|
emptyDay: 'Enter the day.',
|
|
209
|
-
emptyMonth: 'Enter the month.',
|
|
210
|
-
emptyYear: 'Enter the year.',
|
|
211
89
|
emptyDayAndMonth: 'Enter the month and day.',
|
|
212
90
|
emptyDayAndYear: 'Enter the year and day.',
|
|
91
|
+
emptyMonth: 'Enter the month.',
|
|
213
92
|
emptyMonthAndYear: 'Enter the year and month.',
|
|
93
|
+
emptyYear: 'Enter the year.',
|
|
214
94
|
invalidDate: 'Enter a valid date.',
|
|
215
95
|
invalidDay: 'Enter a valid day.',
|
|
216
96
|
invalidMonth: 'Enter a valid month.',
|
|
@@ -218,49 +98,180 @@ const dateInput = {
|
|
|
218
98
|
},
|
|
219
99
|
fr: {
|
|
220
100
|
emptyDay: 'Saisissez le jour.',
|
|
221
|
-
emptyMonth: 'Saisissez le mois.',
|
|
222
|
-
emptyYear: 'Saisissez l’année.',
|
|
223
101
|
emptyDayAndMonth: 'Saisissez le mois et le jour.',
|
|
224
102
|
emptyDayAndYear: 'Saisissez l’année et le jour.',
|
|
103
|
+
emptyMonth: 'Saisissez le mois.',
|
|
225
104
|
emptyMonthAndYear: 'Saisissez l’année et le mois.',
|
|
105
|
+
emptyYear: 'Saisissez l’année.',
|
|
226
106
|
invalidDate: 'Saisissez une date valide.',
|
|
227
107
|
invalidDay: 'Saisissez un jour valide.',
|
|
228
108
|
invalidMonth: 'Saisissez un mois valide.',
|
|
229
109
|
invalidYear: 'Saisissez une année valide.',
|
|
230
110
|
},
|
|
231
111
|
},
|
|
112
|
+
month: {
|
|
113
|
+
accessibility: {
|
|
114
|
+
en: '1 or 2 digits',
|
|
115
|
+
fr: '1 ou 2 chiffres',
|
|
116
|
+
},
|
|
117
|
+
label: {
|
|
118
|
+
en: 'Month',
|
|
119
|
+
fr: 'Mois',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
year: {
|
|
123
|
+
accessibility: {
|
|
124
|
+
en: '1 or 2 digits',
|
|
125
|
+
fr: '1 ou 2 chiffres',
|
|
126
|
+
},
|
|
127
|
+
label: {
|
|
128
|
+
en: 'Year',
|
|
129
|
+
fr: 'Année',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
232
132
|
};
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
en: '
|
|
236
|
-
fr: '
|
|
133
|
+
const dropdownList = {
|
|
134
|
+
select: {
|
|
135
|
+
en: 'Select',
|
|
136
|
+
fr: 'Sélectionner',
|
|
237
137
|
},
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
138
|
+
};
|
|
139
|
+
const header = {
|
|
140
|
+
clearSearchField: {
|
|
141
|
+
en: 'Clear field',
|
|
142
|
+
fr: 'Vider le champ',
|
|
241
143
|
},
|
|
242
|
-
|
|
243
|
-
en: '
|
|
244
|
-
fr:
|
|
144
|
+
close: {
|
|
145
|
+
en: 'close',
|
|
146
|
+
fr: 'fermer',
|
|
147
|
+
},
|
|
148
|
+
closeMenu: {
|
|
149
|
+
en: 'Hide navigation menu',
|
|
150
|
+
fr: 'Fermer le menu de navigation',
|
|
151
|
+
},
|
|
152
|
+
closeSearch: {
|
|
153
|
+
en: 'Close search bar',
|
|
154
|
+
fr: 'Fermer la barre de recherche',
|
|
155
|
+
},
|
|
156
|
+
logoAltText: {
|
|
157
|
+
en: 'Ontario.ca homepage',
|
|
158
|
+
fr: 'Page d’accueil Ontario.ca',
|
|
159
|
+
},
|
|
160
|
+
logoLink: {
|
|
161
|
+
en: 'https://www.ontario.ca/page/government-ontario',
|
|
162
|
+
fr: 'https://www.ontario.ca/fr/page/gouvernement-de-lontario',
|
|
163
|
+
},
|
|
164
|
+
ontarioSearchURL: {
|
|
165
|
+
en: 'https://www.ontario.ca/search/search-results?query=',
|
|
166
|
+
fr: 'https://www.ontario.ca/fr/recherche/resultats-de-recherche/?query=',
|
|
167
|
+
},
|
|
168
|
+
openMenu: {
|
|
169
|
+
en: 'Show navigation menu',
|
|
170
|
+
fr: 'Ouvrir le menu de navigation',
|
|
171
|
+
},
|
|
172
|
+
search: {
|
|
173
|
+
en: 'Search',
|
|
174
|
+
fr: 'Rechercher',
|
|
175
|
+
},
|
|
176
|
+
serviceOntario: {
|
|
177
|
+
en: 'ServiceOntario',
|
|
178
|
+
fr: 'ServiceOntario',
|
|
179
|
+
},
|
|
180
|
+
submit: {
|
|
181
|
+
en: 'Submit',
|
|
182
|
+
fr: 'Soumission',
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
const input = {
|
|
186
|
+
requiredFieldError: {
|
|
187
|
+
en: 'This is a required field.',
|
|
188
|
+
fr: 'Ce champ est obligatoire.',
|
|
245
189
|
},
|
|
246
190
|
};
|
|
191
|
+
const languageToggle = {
|
|
192
|
+
ariaLabel: {
|
|
193
|
+
en: 'Click to switch the language to English',
|
|
194
|
+
fr: 'Cliquez pour changer la langue en français',
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
const loading = {
|
|
198
|
+
en: 'Loading',
|
|
199
|
+
fr: 'Chargement',
|
|
200
|
+
};
|
|
201
|
+
const optional = {
|
|
202
|
+
en: 'optional',
|
|
203
|
+
fr: 'facultative',
|
|
204
|
+
};
|
|
205
|
+
const printerLink = {
|
|
206
|
+
link: {
|
|
207
|
+
en: 'https://www.ontario.ca/page/copyright-information',
|
|
208
|
+
fr: 'https://www.ontario.ca/fr/page/droits-dauteur',
|
|
209
|
+
},
|
|
210
|
+
text: {
|
|
211
|
+
en: "King's Printer for Ontario,",
|
|
212
|
+
fr: 'Imprimeur du Roi pour l’Ontario,',
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
const privacyLink = {
|
|
216
|
+
link: {
|
|
217
|
+
en: 'https://www.ontario.ca/page/privacy-statement',
|
|
218
|
+
fr: 'https://www.ontario.ca/fr/page/declaration-concernant-la-protection-de-la-vie-privee',
|
|
219
|
+
},
|
|
220
|
+
text: {
|
|
221
|
+
en: 'Privacy',
|
|
222
|
+
fr: 'Confidentialité',
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
const stepIndicator = {
|
|
226
|
+
back: {
|
|
227
|
+
en: 'Back',
|
|
228
|
+
fr: 'Retour',
|
|
229
|
+
},
|
|
230
|
+
complete: {
|
|
231
|
+
en: 'complete',
|
|
232
|
+
fr: 'complet',
|
|
233
|
+
},
|
|
234
|
+
of: {
|
|
235
|
+
en: 'of',
|
|
236
|
+
fr: 'sur',
|
|
237
|
+
},
|
|
238
|
+
step: {
|
|
239
|
+
en: 'Step',
|
|
240
|
+
fr: 'Étape',
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
const siteLanguage = {
|
|
244
|
+
fullWord: {
|
|
245
|
+
en: 'English',
|
|
246
|
+
fr: 'Français',
|
|
247
|
+
},
|
|
248
|
+
abbreviation: {
|
|
249
|
+
en: 'en',
|
|
250
|
+
fr: 'fr',
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
const required = {
|
|
254
|
+
en: 'required',
|
|
255
|
+
fr: 'obligatoire',
|
|
256
|
+
};
|
|
247
257
|
const translations = {
|
|
248
|
-
required: required,
|
|
249
|
-
optional: optional,
|
|
250
258
|
accessibility: accessibility,
|
|
259
|
+
accessibilityLink: accessibilityLink,
|
|
260
|
+
accordion: accordion,
|
|
251
261
|
backToTop: backToTop,
|
|
252
|
-
loading: loading,
|
|
253
|
-
dropdownList: dropdownList,
|
|
254
262
|
contactUs: contactUs,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
printerLink: printerLink,
|
|
258
|
-
languageToggle: languageToggle,
|
|
259
|
-
stepIndicator: stepIndicator,
|
|
263
|
+
dateInput: dateInput,
|
|
264
|
+
dropdownList: dropdownList,
|
|
260
265
|
header: header,
|
|
261
266
|
input: input,
|
|
262
|
-
|
|
263
|
-
|
|
267
|
+
languageToggle: languageToggle,
|
|
268
|
+
loading: loading,
|
|
269
|
+
optional: optional,
|
|
270
|
+
printerLink: printerLink,
|
|
271
|
+
privacyLink: privacyLink,
|
|
272
|
+
stepIndicator: stepIndicator,
|
|
273
|
+
siteLanguage: siteLanguage,
|
|
274
|
+
required: required,
|
|
264
275
|
};
|
|
265
276
|
|
|
266
277
|
const ontarioAccordionCss =
|
|
@@ -785,6 +796,32 @@ function isEmpty(str) {
|
|
|
785
796
|
function retrieveEnumKeys(enumObject) {
|
|
786
797
|
return Object.keys(enumObject).filter(isNumber);
|
|
787
798
|
}
|
|
799
|
+
/**
|
|
800
|
+
* Prints an array as a comma delimited list, with the last element being preceded by a conjunction.
|
|
801
|
+
* As per ontario.ca content guidelines, there is no Oxford comma.
|
|
802
|
+
*
|
|
803
|
+
* @param {Array<any>} arr - The array that you wish to print.
|
|
804
|
+
* @param {Conjunction} conjunctionType - Whether you want the sentence to end with 'and value.' or 'or value.'
|
|
805
|
+
*
|
|
806
|
+
* @returns {string}
|
|
807
|
+
*/
|
|
808
|
+
function printArray(arr, conjunctionType = 'and') {
|
|
809
|
+
return [...arr].reduce(
|
|
810
|
+
(text, value, i, array) => text + (i < array.length - 1 ? ', ' : ` ${conjunctionType} `) + value,
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Grabs the HTML element of the page.
|
|
815
|
+
*
|
|
816
|
+
* More targetted than document.documentElement as the documentElement could
|
|
817
|
+
* in theory be any element that is the top level. e.g. <div> if the page is not
|
|
818
|
+
* set up to be semantically correct.
|
|
819
|
+
*
|
|
820
|
+
* @returns {HTMLElement}
|
|
821
|
+
*/
|
|
822
|
+
function getRootHTMLElement() {
|
|
823
|
+
return document.getElementsByTagName('html')[0];
|
|
824
|
+
}
|
|
788
825
|
|
|
789
826
|
var BadgeColourToClass;
|
|
790
827
|
(function (BadgeColourToClass) {
|
|
@@ -1284,7 +1321,7 @@ const CardTypes = ['basic', 'image', 'title', 'horizontal'];
|
|
|
1284
1321
|
const HeaderTypes = ['default', 'light', 'dark'];
|
|
1285
1322
|
|
|
1286
1323
|
const ontarioCardCss =
|
|
1287
|
-
'.ontario-card__heading{font-style:normal;font-weight:700;text-rendering:optimizeLegibility;margin-bottom:1rem;font-feature-settings:normal;font-family:"Raleway", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif}.ontario-card__heading{font-size:1.25rem;letter-spacing:0.03rem;line-height:1.5;margin:0 0 0.75rem 0;max-width:48rem}@media screen and (min-width: 40em){.ontario-card__heading{font-size:1.5rem;letter-spacing:0.0313rem;line-height:1.5}}.ontario-card{box-shadow:0rem 0.1875rem 0.5rem 0.0625rem rgba(0, 0, 0, 0.4);border-radius:4px;margin:0 2.5rem 2.5rem 0;padding:0;height:calc(100% - 2.5rem);list-style-type:none;transition:all 0.3s ease-in-out;position:relative;cursor:pointer}.ontario-card:hover{box-shadow:0rem 0.375rem 0.75rem 0.125rem rgba(0, 0, 0, 0.35)}.ontario-card:focus-within{box-shadow:0 0 0 4px #009ADB;outline:4px solid transparent;transition:box-shadow 0.1s ease-in-out}.ontario-card:active{box-shadow:0 0 0 4px #009ADB;background-color:#f2f2f2}@media screen and (max-width: 40em){.ontario-card{margin-bottom:3rem;width:100% !important;max-width:100%}}.ontario-card__card-type--horizontal{display:flex}@media screen and (max-width: 40em){.ontario-card__card-type--horizontal{width:100%;max-width:100%}}.ontario-card__card-type--horizontal .ontario-card__image-container,.ontario-card__card-type--horizontal .ontario-card__text-container{position:relative}.ontario-card__card-type--horizontal a:focus-within{box-shadow:none;outline:none}.ontario-card__card-type--horizontal a:active{box-shadow:none}.ontario-card__card-type--horizontal img{height:100%;position:absolute}.ontario-card__image-right{flex-direction:row-reverse}.ontario-card__heading{margin:0;border-radius:4px 4px 0 0;padding:1.25rem 1.5rem 0.5rem 1.5rem;transition:text-decoration 0.3s ease-in-out;background-color:#FFFFFF}.ontario-card:hover .ontario-card__heading{text-decoration-line:underline;text-decoration-color:#1a1a1a}.ontario-card__header-type--light .ontario-card__heading{background-color:#f2f2f2;padding-top:1rem;padding-bottom:1rem;padding-right:4rem;border-radius:4px 4px 0 0}.ontario-card__header-type--dark .ontario-card__heading{background-color:#1a1a1a;padding-top:1rem;padding-bottom:1rem;border-radius:4px 4px 0 0}.ontario-card__header-type--dark:hover .ontario-card__heading{text-decoration-line:underline;text-decoration-color:#FFFFFF}.ontario-
|
|
1324
|
+
'.ontario-card__heading{font-style:normal;font-weight:700;text-rendering:optimizeLegibility;margin-bottom:1rem;font-feature-settings:normal;font-family:"Raleway", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif}.ontario-card__heading{font-size:1.25rem;letter-spacing:0.03rem;line-height:1.5;margin:0 0 0.75rem 0;max-width:48rem}@media screen and (min-width: 40em){.ontario-card__heading{font-size:1.5rem;letter-spacing:0.0313rem;line-height:1.5}}.ontario-card{box-shadow:0rem 0.1875rem 0.5rem 0.0625rem rgba(0, 0, 0, 0.4);border-radius:4px;margin:0 2.5rem 2.5rem 0;padding:0;height:calc(100% - 2.5rem);list-style-type:none;transition:all 0.3s ease-in-out;position:relative;cursor:pointer}.ontario-card:hover{box-shadow:0rem 0.375rem 0.75rem 0.125rem rgba(0, 0, 0, 0.35)}.ontario-card:focus-within{box-shadow:0 0 0 4px #009ADB;outline:4px solid transparent;transition:box-shadow 0.1s ease-in-out}.ontario-card:active{box-shadow:0 0 0 4px #009ADB;background-color:#f2f2f2}@media screen and (max-width: 40em){.ontario-card{margin-bottom:3rem;width:100% !important;max-width:100%}}.ontario-card__header-type--dark.ontario-card__description-false{background-color:#1a1a1a}.ontario-card__header-type--light.ontario-card__description-false{background-color:#f2f2f2}.ontario-card--image-true{margin-top:-0.5rem}.ontario-card__card-type--horizontal{display:flex}@media screen and (max-width: 40em){.ontario-card__card-type--horizontal{width:100%;max-width:100%}}.ontario-card__card-type--horizontal .ontario-card__image-container,.ontario-card__card-type--horizontal .ontario-card__text-container{position:relative}.ontario-card__card-type--horizontal a:focus-within{box-shadow:none;outline:none}.ontario-card__card-type--horizontal a:active{box-shadow:none}.ontario-card__card-type--horizontal img{height:100%;position:absolute}.ontario-card__image-right{flex-direction:row-reverse}.ontario-card__heading{margin:0;border-radius:4px 4px 0 0;padding:1.25rem 1.5rem 0.5rem 1.5rem;transition:text-decoration 0.3s ease-in-out;background-color:#FFFFFF}.ontario-card:hover .ontario-card__heading{text-decoration-line:underline;text-decoration-color:#1a1a1a}.ontario-card__header-type--light .ontario-card__heading{background-color:#f2f2f2;padding-top:1rem;padding-bottom:1rem;padding-right:4rem;border-radius:4px 4px 0 0}.ontario-card__header-type--dark .ontario-card__heading{background-color:#1a1a1a;padding-top:1rem;padding-bottom:1rem;border-radius:4px 4px 0 0}.ontario-card__header-type--dark:hover .ontario-card__heading{text-decoration-line:underline;text-decoration-color:#FFFFFF}.ontario-card__heading a{color:#1a1a1a;text-decoration:none;outline:none}.ontario-card__header-type--dark .ontario-card__heading a{color:#FFFFFF}.ontario-card__heading a::after{content:"";position:absolute;left:0;top:0;right:0;bottom:0}.ontario-card__heading a:focus{box-shadow:none}.ontario-card__heading a:active{outline:none}@media screen and (max-width: 73em){.ontario-card__heading{font-size:1.25rem;padding-left:1rem;padding-right:1rem}}.ontario-card__card-type--horizontal .ontario-card__text-container{width:66.6%}.ontario-card__image-size-one-fourth .ontario-card__text-container{width:75%}.ontario-card--no-image .ontario-card__text-container{width:100%}.ontario-card__description{margin:0;padding:0.5rem 1.5rem 1.5rem 1.5rem;background-color:#FFFFFF;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.ontario-card__description p{margin-top:0}.ontario-card__description p:last-of-type{margin-bottom:0}.ontario-card__header-type--light .ontario-card__description,.ontario-card__header-type--dark .ontario-card__description{padding-top:1rem}@media screen and (max-width: 73em){.ontario-card__description{padding:0.5rem 1rem 1.5rem 1rem}.ontario-card__header-type--light .ontario-card__description,.ontario-card__header-type--dark .ontario-card__description{padding-top:1rem}}.ontario-card--position-vertical .ontario-card__image-container{margin-bottom:-0.5rem}.ontario-card__card-type--horizontal .ontario-card__image-container{width:33.3%}.ontario-card__image-size-one-fourth .ontario-card__image-container{width:25%}.ontario-card__image{width:100%;height:100%;object-fit:cover;background-size:100% 100%}.ontario-card--position-vertical .ontario-card__image{border-top-left-radius:4px;border-top-right-radius:4px}.ontario-card__image-right .ontario-card__image{border-top-right-radius:4px;border-bottom-right-radius:4px}.ontario-card__image-left .ontario-card__image{border-top-left-radius:4px;border-bottom-left-radius:4px}';
|
|
1288
1325
|
const OntarioCardStyle0 = ontarioCardCss;
|
|
1289
1326
|
|
|
1290
1327
|
const OntarioCard = class {
|
|
@@ -1372,12 +1409,12 @@ const OntarioCard = class {
|
|
|
1372
1409
|
* @returns the classes of the ontario cards based off the `cardType` and `headerType`.
|
|
1373
1410
|
*/
|
|
1374
1411
|
getClass() {
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
}
|
|
1412
|
+
const baseClass =
|
|
1413
|
+
this.cardTypeState === 'horizontal'
|
|
1414
|
+
? `ontario-card ontario-card__card-type--horizontal ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`
|
|
1415
|
+
: `ontario-card ontario-card__header-type--${this.headerTypeState} ontario-card__card-type--${this.cardTypeState}`;
|
|
1416
|
+
const descriptionClass = this.description ? '' : ' ontario-card__description-false';
|
|
1417
|
+
return `${baseClass}${descriptionClass}`;
|
|
1381
1418
|
}
|
|
1382
1419
|
getHref() {
|
|
1383
1420
|
return this.cardLink ? this.cardLink : '#';
|
|
@@ -1389,7 +1426,7 @@ const OntarioCard = class {
|
|
|
1389
1426
|
render() {
|
|
1390
1427
|
return h(
|
|
1391
1428
|
'li',
|
|
1392
|
-
{ key: '
|
|
1429
|
+
{ key: '606e74cea5d81cd31b355ffb1a71cf7450126cf4', class: this.getClass() },
|
|
1393
1430
|
this.image &&
|
|
1394
1431
|
h(
|
|
1395
1432
|
'div',
|
|
@@ -1403,16 +1440,16 @@ const OntarioCard = class {
|
|
|
1403
1440
|
h(
|
|
1404
1441
|
'div',
|
|
1405
1442
|
{
|
|
1406
|
-
key: '
|
|
1443
|
+
key: '7d71d14690d4e75dcf1e4ef5c0198183b27e4b39',
|
|
1407
1444
|
class: `ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`,
|
|
1408
1445
|
},
|
|
1409
1446
|
h(
|
|
1410
1447
|
'h2',
|
|
1411
|
-
{ key: '
|
|
1448
|
+
{ key: '4f6a337efa3986a5023f3c17e869f072aaef0e4f', class: 'ontario-card__heading' },
|
|
1412
1449
|
h(
|
|
1413
1450
|
'a',
|
|
1414
1451
|
{
|
|
1415
|
-
'key': '
|
|
1452
|
+
'key': '6efece75daafc95e43dca997e895dc88cab9194c',
|
|
1416
1453
|
'href': this.getHref(),
|
|
1417
1454
|
'aria-label': this.ariaLabelText,
|
|
1418
1455
|
},
|
|
@@ -4001,10 +4038,19 @@ const OntarioHeader = class {
|
|
|
4001
4038
|
if (this.menuToggle) this.menuToggle = !this.menuToggle;
|
|
4002
4039
|
}
|
|
4003
4040
|
/**
|
|
4004
|
-
* This listens for the `setAppLanguage` event sent from the
|
|
4041
|
+
* This listens for the `setAppLanguage` event sent from the language toggle when it is is connected to the DOM.
|
|
4042
|
+
* It is used for the initial language when the input component loads.
|
|
4005
4043
|
*/
|
|
4006
4044
|
handleSetAppLanguage(event) {
|
|
4007
4045
|
this.language = validateLanguage(event);
|
|
4046
|
+
this.parseMenuItems();
|
|
4047
|
+
}
|
|
4048
|
+
/**
|
|
4049
|
+
* This listens for the `headerLanguageToggled` event sent from the language toggle when it is is connected to the DOM.
|
|
4050
|
+
* It is used for changing the component language after the language toggle has been activated.
|
|
4051
|
+
*/
|
|
4052
|
+
handleLanguageToggle(event) {
|
|
4053
|
+
this.handleSetAppLanguage(event.detail.newLanguage);
|
|
4008
4054
|
}
|
|
4009
4055
|
/**
|
|
4010
4056
|
* Call to Ontario Menu API to fetch linksets to populate header component
|
|
@@ -4297,7 +4343,6 @@ const OntarioHeader = class {
|
|
|
4297
4343
|
: _b.englishLink,
|
|
4298
4344
|
size: 'default',
|
|
4299
4345
|
customLanguageToggle: this.customLanguageToggle,
|
|
4300
|
-
language: this.language,
|
|
4301
4346
|
}),
|
|
4302
4347
|
h(
|
|
4303
4348
|
'button',
|
|
@@ -4429,7 +4474,6 @@ const OntarioHeader = class {
|
|
|
4429
4474
|
? void 0
|
|
4430
4475
|
: _e.englishLink,
|
|
4431
4476
|
customLanguageToggle: this.customLanguageToggle,
|
|
4432
|
-
language: this.language,
|
|
4433
4477
|
}),
|
|
4434
4478
|
),
|
|
4435
4479
|
),
|
|
@@ -7248,6 +7292,8 @@ const OntarioInput = class {
|
|
|
7248
7292
|
};
|
|
7249
7293
|
OntarioInput.style = OntarioInputStyle0;
|
|
7250
7294
|
|
|
7295
|
+
const supportedLanguages = ['en', 'fr'];
|
|
7296
|
+
|
|
7251
7297
|
const ontarioLanguageToggleCss =
|
|
7252
7298
|
'.ontario-language-toggler:focus{box-shadow:0 0 0 4px #009ADB;outline:4px solid transparent;transition:box-shadow 0.1s ease-in-out}.ontario-hide{display:none !important}.ontario-invisible{visibility:hidden !important}@media screen and (max-width: 39.99875em){.ontario-hide-for-small-only{display:none !important}}@media screen and (max-width: 0em), screen and (min-width: 40em){.ontario-show-for-small-only{display:none !important}}@media print, screen and (min-width: 40em){.ontario-hide-for-medium{display:none !important}}@media screen and (max-width: 39.99875em){.ontario-show-for-medium{display:none !important}}@media screen and (min-width: 40em) and (max-width: 72.99875em){.ontario-hide-for-medium-only{display:none !important}}@media screen and (max-width: 39.99875em), screen and (min-width: 73em){.ontario-show-for-medium-only{display:none !important}}@media print, screen and (min-width: 73em){.ontario-hide-for-large{display:none !important}}@media screen and (max-width: 72.99875em){.ontario-show-for-large{display:none !important}}@media screen and (min-width: 73em) and (max-width: 95.99875em){.ontario-hide-for-large-only{display:none !important}}@media screen and (max-width: 72.99875em), screen and (min-width: 96em){.ontario-show-for-large-only{display:none !important}}.ontario-show-for-sr,.ontario-show-on-focus{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0, 0, 0, 0)}.ontario-show-on-focus:active,.ontario-show-on-focus:focus{position:static;width:auto;height:auto;overflow:visible;clip:auto}.ontario-show-for-landscape,.ontario-hide-for-portrait{display:block !important}@media screen and (orientation: landscape){.ontario-show-for-landscape,.ontario-hide-for-portrait{display:block !important}}@media screen and (orientation: portrait){.ontario-show-for-landscape,.ontario-hide-for-portrait{display:none !important}}.ontario-hide-for-landscape,.ontario-show-for-portrait{display:none !important}@media screen and (orientation: landscape){.ontario-hide-for-landscape,.ontario-show-for-portrait{display:none !important}}@media screen and (orientation: portrait){.ontario-hide-for-landscape,.ontario-show-for-portrait{display:block !important}}.ontario-language-toggler{background-color:#1a1a1a;border:none;border-radius:4px;box-sizing:border-box;box-shadow:none;color:#FFFFFF;cursor:pointer;display:flex;align-items:center;font-size:1.125rem;font-weight:600;font-family:"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;height:48px;line-height:1.5555555556;text-align:center;text-decoration:none}.ontario-language-toggler:hover{background-color:#4d4d4d}.ontario-language-toggler:active{background-color:#666666;color:#FFFFFF}.ontario-language-toggler:focus{background-color:#4d4d4d;color:#FFFFFF}.ontario-language-toggler:visited{color:#FFFFFF}.ontario-language-toggler abbr[title]{text-decoration:none}.ontario-language-toggler--default{padding:0.75rem}.ontario-language-toggler--small{font-size:1rem;line-height:1.375rem;height:auto;outline:none;padding:0.5rem 0.75rem}';
|
|
7253
7299
|
const OntarioLanguageToggleStyle0 = ontarioLanguageToggleCss;
|
|
@@ -7257,74 +7303,209 @@ const OntarioLanguageToggle = class {
|
|
|
7257
7303
|
registerInstance(this, hostRef);
|
|
7258
7304
|
this.setAppLanguage = createEvent(this, 'setAppLanguage', 7);
|
|
7259
7305
|
this.headerLanguageToggled = createEvent(this, 'headerLanguageToggled', 7);
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
}
|
|
7306
|
+
/*
|
|
7307
|
+
* Updates the <html> lang attribute based on component languageState.
|
|
7308
|
+
*/
|
|
7309
|
+
this.updateHTMLLang = () => {
|
|
7310
|
+
const htmlElement = getRootHTMLElement();
|
|
7311
|
+
if (htmlElement) {
|
|
7312
|
+
htmlElement.setAttribute('lang', this.languageState);
|
|
7268
7313
|
}
|
|
7269
|
-
return;
|
|
7270
7314
|
};
|
|
7271
7315
|
this.language = undefined;
|
|
7272
7316
|
this.size = 'default';
|
|
7273
7317
|
this.url = undefined;
|
|
7274
7318
|
this.customLanguageToggle = undefined;
|
|
7275
7319
|
this.translations = translations;
|
|
7320
|
+
this.languageState = undefined;
|
|
7321
|
+
this.oppositeLanguageLabel = undefined;
|
|
7276
7322
|
}
|
|
7277
|
-
|
|
7278
|
-
|
|
7323
|
+
/**
|
|
7324
|
+
* Updates the language and languageState props when changes to the language prop are detected.
|
|
7325
|
+
*/
|
|
7326
|
+
updateLanguage() {
|
|
7279
7327
|
if (this.language) {
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7328
|
+
if (!validateValueAgainstArray(this.language, supportedLanguages)) {
|
|
7329
|
+
this.showLanguageWarning(this.language);
|
|
7330
|
+
this.language = this.translations.siteLanguage.abbreviation.en;
|
|
7331
|
+
}
|
|
7332
|
+
this.languageState = this.language;
|
|
7333
|
+
}
|
|
7334
|
+
this.setAppLanguageHandler();
|
|
7335
|
+
}
|
|
7336
|
+
/**
|
|
7337
|
+
* This function sets the languageState (if not already set).
|
|
7338
|
+
*
|
|
7339
|
+
* It also emits the setAppLanguage() event, updates the component language label, and
|
|
7340
|
+
* updates the <html> tag lang attribute with the languageState value.
|
|
7341
|
+
*
|
|
7342
|
+
* It gets called by the connectedCallback() component lifecycle hook, and by the
|
|
7343
|
+
* updateLanguage() method, which is fired on the watch for the language prop.
|
|
7344
|
+
*/
|
|
7345
|
+
setAppLanguageHandler() {
|
|
7346
|
+
var _a;
|
|
7347
|
+
const defaultLang = this.translations.siteLanguage.abbreviation.en;
|
|
7348
|
+
const rootLang = (_a = getRootHTMLElement()) === null || _a === void 0 ? void 0 : _a.lang;
|
|
7349
|
+
// If languageState is not set, set it equal to the following cadence:
|
|
7350
|
+
// language prop value, <html> tag lang attribute, or default to "en"
|
|
7351
|
+
if (!this.languageState) {
|
|
7352
|
+
if (this.language) {
|
|
7353
|
+
this.languageState = this.language;
|
|
7354
|
+
} else if (rootLang) {
|
|
7355
|
+
if (validateValueAgainstArray(rootLang, supportedLanguages)) {
|
|
7356
|
+
this.languageState = rootLang;
|
|
7357
|
+
} else {
|
|
7358
|
+
this.showLanguageWarning(rootLang, 'document');
|
|
7359
|
+
this.languageState = defaultLang;
|
|
7360
|
+
}
|
|
7361
|
+
} else {
|
|
7362
|
+
this.languageState = defaultLang;
|
|
7363
|
+
}
|
|
7285
7364
|
}
|
|
7286
|
-
this.
|
|
7287
|
-
this.
|
|
7288
|
-
|
|
7365
|
+
this.setAppLanguage.emit(this.languageState);
|
|
7366
|
+
this.oppositeLanguageLabel = {
|
|
7367
|
+
fullWord: this.getOppositeLanguageFullWord(),
|
|
7368
|
+
abbreviation: this.getOppositeLanguageAbbrievation(),
|
|
7369
|
+
};
|
|
7370
|
+
this.updateHTMLLang();
|
|
7289
7371
|
}
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7372
|
+
/**
|
|
7373
|
+
* An event that emits to other components that the language toggle button has been toggled.
|
|
7374
|
+
*
|
|
7375
|
+
* @param {Language} oldLanguage - The language prior to the language toggle being pressed.
|
|
7376
|
+
* @param {globalThis.Event} event - event that triggered the function (e.g. onclick).
|
|
7377
|
+
*/
|
|
7378
|
+
handleHeaderLanguageToggled(oldLanguage, event) {
|
|
7379
|
+
this.languageState =
|
|
7380
|
+
oldLanguage === this.translations.siteLanguage.abbreviation.en
|
|
7381
|
+
? this.translations.siteLanguage.abbreviation.fr
|
|
7382
|
+
: this.translations.siteLanguage.abbreviation.en;
|
|
7383
|
+
this.headerLanguageToggled.emit({ oldLanguage: oldLanguage, newLanguage: this.languageState });
|
|
7384
|
+
this.updateHTMLLang();
|
|
7295
7385
|
if (this.customLanguageToggle && event) {
|
|
7296
7386
|
this.customLanguageToggle(event);
|
|
7297
7387
|
}
|
|
7298
7388
|
}
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7389
|
+
/**
|
|
7390
|
+
* Prints a warning message to the console about using an incorrect language for the component.
|
|
7391
|
+
*
|
|
7392
|
+
* @param {string} lang - The incorrect language that was received.
|
|
7393
|
+
* @param {string} type - prop/document | Where the incorrect language is coming from.
|
|
7394
|
+
*/
|
|
7395
|
+
showLanguageWarning(lang, type = 'prop') {
|
|
7396
|
+
const propOrDocumentMessage =
|
|
7397
|
+
type === 'prop' ? `The language prop value of ${lang} ` : `The HTML document lang attribute value of ${lang} `;
|
|
7398
|
+
const message = new ConsoleMessageClass();
|
|
7399
|
+
message
|
|
7400
|
+
.addDesignSystemTag()
|
|
7401
|
+
.addRegularText(propOrDocumentMessage)
|
|
7402
|
+
.addRegularText('is not a valid language value for the ')
|
|
7403
|
+
.addMonospaceText(' <ontario-language-toggle> ')
|
|
7404
|
+
.addRegularText(`component. Valid language values are ${printArray([...supportedLanguages])}. `)
|
|
7405
|
+
.addRegularText(`A default language value of ${this.translations.siteLanguage.abbreviation.en} will be applied.`)
|
|
7406
|
+
.printMessage();
|
|
7407
|
+
}
|
|
7408
|
+
/**
|
|
7409
|
+
* Returns abbreviated text for the opposite language.
|
|
7410
|
+
*
|
|
7411
|
+
* @returns {Language}
|
|
7412
|
+
*/
|
|
7413
|
+
getOppositeLanguageAbbrievation() {
|
|
7414
|
+
return this.languageState === this.translations.siteLanguage.abbreviation.en
|
|
7415
|
+
? this.translations.siteLanguage.abbreviation.fr
|
|
7416
|
+
: this.translations.siteLanguage.abbreviation.en;
|
|
7417
|
+
}
|
|
7418
|
+
/**
|
|
7419
|
+
* Returns full word text for the opposite language.
|
|
7420
|
+
*
|
|
7421
|
+
* @returns {string}
|
|
7422
|
+
*/
|
|
7423
|
+
getOppositeLanguageFullWord() {
|
|
7424
|
+
return this.languageState === this.translations.siteLanguage.abbreviation.en
|
|
7425
|
+
? this.translations.siteLanguage.fullWord.fr
|
|
7426
|
+
: this.translations.siteLanguage.fullWord.en;
|
|
7302
7427
|
}
|
|
7428
|
+
/**
|
|
7429
|
+
* Component life cycle hook.
|
|
7430
|
+
*
|
|
7431
|
+
* https://stenciljs.com/docs/component-lifecycle#connectedcallback
|
|
7432
|
+
*/
|
|
7303
7433
|
connectedCallback() {
|
|
7304
|
-
this.
|
|
7434
|
+
this.setAppLanguageHandler();
|
|
7435
|
+
}
|
|
7436
|
+
/**
|
|
7437
|
+
* Component life cycle hook.
|
|
7438
|
+
*
|
|
7439
|
+
* https://stenciljs.com/docs/component-lifecycle#componentdidload
|
|
7440
|
+
*/
|
|
7441
|
+
componentDidLoad() {
|
|
7442
|
+
/**
|
|
7443
|
+
* Creates a MutationObserver (a type of watch) on the <html> tag lang attribute.
|
|
7444
|
+
*
|
|
7445
|
+
* When changes occur, the oppositeLanguageLabel state variable regenerates.
|
|
7446
|
+
*
|
|
7447
|
+
* This is to act as a form of callback and create a subtle delay between page content
|
|
7448
|
+
* updating and the language toggle label updating.
|
|
7449
|
+
*/
|
|
7450
|
+
const observer = new MutationObserver((mutations) => {
|
|
7451
|
+
mutations.forEach((mutation) => {
|
|
7452
|
+
switch (mutation.type) {
|
|
7453
|
+
case 'attributes':
|
|
7454
|
+
switch (mutation.attributeName) {
|
|
7455
|
+
case 'lang':
|
|
7456
|
+
this.oppositeLanguageLabel = {
|
|
7457
|
+
fullWord: this.getOppositeLanguageFullWord(),
|
|
7458
|
+
abbreviation: this.getOppositeLanguageAbbrievation(),
|
|
7459
|
+
};
|
|
7460
|
+
break;
|
|
7461
|
+
}
|
|
7462
|
+
break;
|
|
7463
|
+
}
|
|
7464
|
+
});
|
|
7465
|
+
});
|
|
7466
|
+
// Only create/trigger the MutationObserver if the <html> element exists.
|
|
7467
|
+
if (getRootHTMLElement()) {
|
|
7468
|
+
const options = { attributes: true };
|
|
7469
|
+
observer.observe(getRootHTMLElement(), options);
|
|
7470
|
+
}
|
|
7305
7471
|
}
|
|
7306
7472
|
render() {
|
|
7307
|
-
|
|
7308
|
-
const abbreviatedLanguage = this.language === 'en' ? 'FR' : 'EN';
|
|
7473
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7309
7474
|
return h(
|
|
7310
7475
|
'a',
|
|
7311
7476
|
{
|
|
7312
|
-
'key': '
|
|
7477
|
+
'key': 'f43e42110b4272a268801c310a8d14e31342f426',
|
|
7478
|
+
'aria-label':
|
|
7479
|
+
this.translations.languageToggle.ariaLabel[
|
|
7480
|
+
`${(_a = this.oppositeLanguageLabel) === null || _a === void 0 ? void 0 : _a.abbreviation}`
|
|
7481
|
+
],
|
|
7313
7482
|
'class':
|
|
7314
7483
|
this.size === 'default'
|
|
7315
7484
|
? 'ontario-language-toggler ontario-language-toggler--default'
|
|
7316
7485
|
: 'ontario-language-toggler ontario-language-toggler--small',
|
|
7317
7486
|
'href': this.url ? this.url : '#',
|
|
7318
|
-
'
|
|
7319
|
-
'
|
|
7487
|
+
'hreflang': (_b = this.oppositeLanguageLabel) === null || _b === void 0 ? void 0 : _b.abbreviation,
|
|
7488
|
+
'lang': (_c = this.oppositeLanguageLabel) === null || _c === void 0 ? void 0 : _c.abbreviation,
|
|
7489
|
+
'onClick': (e) => this.handleHeaderLanguageToggled(this.languageState, e),
|
|
7320
7490
|
},
|
|
7321
7491
|
this.size === 'small'
|
|
7322
|
-
? h('span', null,
|
|
7492
|
+
? h('span', null, (_d = this.oppositeLanguageLabel) === null || _d === void 0 ? void 0 : _d.fullWord)
|
|
7323
7493
|
: h(
|
|
7324
7494
|
Fragment,
|
|
7325
7495
|
null,
|
|
7326
|
-
h(
|
|
7327
|
-
|
|
7496
|
+
h(
|
|
7497
|
+
'abbr',
|
|
7498
|
+
{
|
|
7499
|
+
title: (_e = this.oppositeLanguageLabel) === null || _e === void 0 ? void 0 : _e.fullWord,
|
|
7500
|
+
class: 'ontario-show-for-small-only',
|
|
7501
|
+
},
|
|
7502
|
+
(_f = this.oppositeLanguageLabel) === null || _f === void 0 ? void 0 : _f.abbreviation.toUpperCase(),
|
|
7503
|
+
),
|
|
7504
|
+
h(
|
|
7505
|
+
'span',
|
|
7506
|
+
{ class: 'ontario-show-for-medium' },
|
|
7507
|
+
(_g = this.oppositeLanguageLabel) === null || _g === void 0 ? void 0 : _g.fullWord,
|
|
7508
|
+
),
|
|
7328
7509
|
),
|
|
7329
7510
|
);
|
|
7330
7511
|
}
|