@ongov/ontario-design-system-component-library 4.3.0 → 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
|
@@ -6,157 +6,57 @@ const index = require('./index-88d5cf20.js');
|
|
|
6
6
|
const index$1 = require('./index-55e3f513.js');
|
|
7
7
|
const consoleMessage = require('./console-message-27a94faa.js');
|
|
8
8
|
|
|
9
|
-
const required = {
|
|
10
|
-
en: 'required',
|
|
11
|
-
fr: 'obligatoire',
|
|
12
|
-
};
|
|
13
|
-
const optional = {
|
|
14
|
-
en: 'optional',
|
|
15
|
-
fr: 'facultative',
|
|
16
|
-
};
|
|
17
9
|
const accessibility = {
|
|
18
|
-
moreInfo: {
|
|
19
|
-
en: 'More information on',
|
|
20
|
-
fr: 'Des renseignements supplémentaires sur',
|
|
21
|
-
},
|
|
22
10
|
checkboxHintExpander: {
|
|
23
11
|
en: 'is available after the last checkbox item.',
|
|
24
12
|
fr: 'suivront à la dernière case à cocher.',
|
|
25
13
|
},
|
|
14
|
+
moreInfo: {
|
|
15
|
+
en: 'More information on',
|
|
16
|
+
fr: 'Des renseignements supplémentaires sur',
|
|
17
|
+
},
|
|
26
18
|
singleHintExpander: {
|
|
27
19
|
en: 'field is available in the next element.',
|
|
28
20
|
fr: 'suivront au prochain élément.',
|
|
29
21
|
},
|
|
30
22
|
};
|
|
31
|
-
const backToTop = {
|
|
32
|
-
top: {
|
|
33
|
-
en: 'Top',
|
|
34
|
-
fr: 'Haut',
|
|
35
|
-
},
|
|
36
|
-
ariaLabel: {
|
|
37
|
-
en: 'Scroll back to the top',
|
|
38
|
-
fr: 'Retour en haut de la page',
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
const loading = {
|
|
42
|
-
en: 'Loading',
|
|
43
|
-
fr: 'Chargement',
|
|
44
|
-
};
|
|
45
|
-
const dropdownList = {
|
|
46
|
-
select: {
|
|
47
|
-
en: 'Select',
|
|
48
|
-
fr: 'Sélectionner',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
const contactUs = {
|
|
52
|
-
en: 'Contact us',
|
|
53
|
-
fr: 'Contactez-nous',
|
|
54
|
-
};
|
|
55
23
|
const accessibilityLink = {
|
|
56
|
-
text: {
|
|
57
|
-
en: 'Accessibility',
|
|
58
|
-
fr: 'Accessibilité',
|
|
59
|
-
},
|
|
60
24
|
link: {
|
|
61
25
|
en: 'https://www.ontario.ca/page/accessibility',
|
|
62
26
|
fr: 'https://www.ontario.ca/fr/page/accessibilite',
|
|
63
27
|
},
|
|
64
|
-
};
|
|
65
|
-
const privacyLink = {
|
|
66
28
|
text: {
|
|
67
|
-
en: '
|
|
68
|
-
fr: '
|
|
69
|
-
},
|
|
70
|
-
link: {
|
|
71
|
-
en: 'https://www.ontario.ca/page/privacy-statement',
|
|
72
|
-
fr: 'https://www.ontario.ca/fr/page/declaration-concernant-la-protection-de-la-vie-privee',
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
const printerLink = {
|
|
76
|
-
text: {
|
|
77
|
-
en: "King's Printer for Ontario,",
|
|
78
|
-
fr: 'Imprimeur du Roi pour l’Ontario,',
|
|
79
|
-
},
|
|
80
|
-
link: {
|
|
81
|
-
en: 'https://www.ontario.ca/page/copyright-information',
|
|
82
|
-
fr: 'https://www.ontario.ca/fr/page/droits-dauteur',
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
const languageToggle = {
|
|
86
|
-
ariaLabel: {
|
|
87
|
-
en: 'Click to switch language to French',
|
|
88
|
-
fr: 'Cliquez pour changer de langue en anglais',
|
|
29
|
+
en: 'Accessibility',
|
|
30
|
+
fr: 'Accessibilité',
|
|
89
31
|
},
|
|
90
32
|
};
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
en: '
|
|
94
|
-
fr: '
|
|
95
|
-
},
|
|
96
|
-
step: {
|
|
97
|
-
en: 'Step',
|
|
98
|
-
fr: 'Étape',
|
|
33
|
+
const accordion = {
|
|
34
|
+
collapse: {
|
|
35
|
+
en: 'Collapse all',
|
|
36
|
+
fr: 'Réduire tout',
|
|
99
37
|
},
|
|
100
|
-
|
|
101
|
-
en: '
|
|
102
|
-
fr: '
|
|
38
|
+
expand: {
|
|
39
|
+
en: 'Expand all',
|
|
40
|
+
fr: 'Agrandir tout',
|
|
103
41
|
},
|
|
104
|
-
|
|
105
|
-
en: '
|
|
106
|
-
fr: '
|
|
42
|
+
expandCollapseAriaLabel: {
|
|
43
|
+
en: 'Expand or collapse the accordion',
|
|
44
|
+
fr: "Agrandissez ou réduisez l'accordéon",
|
|
107
45
|
},
|
|
108
46
|
};
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
en: '
|
|
112
|
-
fr: '
|
|
113
|
-
},
|
|
114
|
-
logoLink: {
|
|
115
|
-
en: 'https://www.ontario.ca/page/government-ontario',
|
|
116
|
-
fr: 'https://www.ontario.ca/fr/page/gouvernement-de-lontario',
|
|
117
|
-
},
|
|
118
|
-
logoAltText: {
|
|
119
|
-
en: 'Ontario.ca homepage',
|
|
120
|
-
fr: 'Page d’accueil Ontario.ca',
|
|
121
|
-
},
|
|
122
|
-
clearSearchField: {
|
|
123
|
-
en: 'Clear field',
|
|
124
|
-
fr: 'Vider le champ',
|
|
125
|
-
},
|
|
126
|
-
submit: {
|
|
127
|
-
en: 'Submit',
|
|
128
|
-
fr: 'Soumission',
|
|
129
|
-
},
|
|
130
|
-
search: {
|
|
131
|
-
en: 'Search',
|
|
132
|
-
fr: 'Rechercher',
|
|
133
|
-
},
|
|
134
|
-
serviceOntario: {
|
|
135
|
-
en: 'ServiceOntario',
|
|
136
|
-
fr: 'ServiceOntario',
|
|
137
|
-
},
|
|
138
|
-
openMenu: {
|
|
139
|
-
en: 'Show navigation menu',
|
|
140
|
-
fr: 'Ouvrir le menu de navigation',
|
|
141
|
-
},
|
|
142
|
-
closeMenu: {
|
|
143
|
-
en: 'Hide navigation menu',
|
|
144
|
-
fr: 'Fermer le menu de navigation',
|
|
145
|
-
},
|
|
146
|
-
close: {
|
|
147
|
-
en: 'close',
|
|
148
|
-
fr: 'fermer',
|
|
47
|
+
const backToTop = {
|
|
48
|
+
ariaLabel: {
|
|
49
|
+
en: 'Scroll back to the top',
|
|
50
|
+
fr: 'Retour en haut de la page',
|
|
149
51
|
},
|
|
150
|
-
|
|
151
|
-
en: '
|
|
152
|
-
fr: '
|
|
52
|
+
top: {
|
|
53
|
+
en: 'Top',
|
|
54
|
+
fr: 'Haut',
|
|
153
55
|
},
|
|
154
56
|
};
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
fr: 'Ce champ est obligatoire.',
|
|
159
|
-
},
|
|
57
|
+
const contactUs = {
|
|
58
|
+
en: 'Contact us',
|
|
59
|
+
fr: 'Contactez-nous',
|
|
160
60
|
};
|
|
161
61
|
const dateInput = {
|
|
162
62
|
caption: {
|
|
@@ -164,43 +64,23 @@ const dateInput = {
|
|
|
164
64
|
fr: 'Dates exactes',
|
|
165
65
|
},
|
|
166
66
|
day: {
|
|
167
|
-
label: {
|
|
168
|
-
en: 'Day',
|
|
169
|
-
fr: 'Jour',
|
|
170
|
-
},
|
|
171
67
|
accessibility: {
|
|
172
68
|
en: '4 digits',
|
|
173
69
|
fr: '4 chiffres',
|
|
174
70
|
},
|
|
175
|
-
},
|
|
176
|
-
month: {
|
|
177
|
-
label: {
|
|
178
|
-
en: 'Month',
|
|
179
|
-
fr: 'Mois',
|
|
180
|
-
},
|
|
181
|
-
accessibility: {
|
|
182
|
-
en: '1 or 2 digits',
|
|
183
|
-
fr: '1 ou 2 chiffres',
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
year: {
|
|
187
71
|
label: {
|
|
188
|
-
en: '
|
|
189
|
-
fr: '
|
|
190
|
-
},
|
|
191
|
-
accessibility: {
|
|
192
|
-
en: '1 or 2 digits',
|
|
193
|
-
fr: '1 ou 2 chiffres',
|
|
72
|
+
en: 'Day',
|
|
73
|
+
fr: 'Jour',
|
|
194
74
|
},
|
|
195
75
|
},
|
|
196
76
|
error: {
|
|
197
77
|
en: {
|
|
198
78
|
emptyDay: 'Enter the day.',
|
|
199
|
-
emptyMonth: 'Enter the month.',
|
|
200
|
-
emptyYear: 'Enter the year.',
|
|
201
79
|
emptyDayAndMonth: 'Enter the month and day.',
|
|
202
80
|
emptyDayAndYear: 'Enter the year and day.',
|
|
81
|
+
emptyMonth: 'Enter the month.',
|
|
203
82
|
emptyMonthAndYear: 'Enter the year and month.',
|
|
83
|
+
emptyYear: 'Enter the year.',
|
|
204
84
|
invalidDate: 'Enter a valid date.',
|
|
205
85
|
invalidDay: 'Enter a valid day.',
|
|
206
86
|
invalidMonth: 'Enter a valid month.',
|
|
@@ -208,49 +88,180 @@ const dateInput = {
|
|
|
208
88
|
},
|
|
209
89
|
fr: {
|
|
210
90
|
emptyDay: 'Saisissez le jour.',
|
|
211
|
-
emptyMonth: 'Saisissez le mois.',
|
|
212
|
-
emptyYear: 'Saisissez l’année.',
|
|
213
91
|
emptyDayAndMonth: 'Saisissez le mois et le jour.',
|
|
214
92
|
emptyDayAndYear: 'Saisissez l’année et le jour.',
|
|
93
|
+
emptyMonth: 'Saisissez le mois.',
|
|
215
94
|
emptyMonthAndYear: 'Saisissez l’année et le mois.',
|
|
95
|
+
emptyYear: 'Saisissez l’année.',
|
|
216
96
|
invalidDate: 'Saisissez une date valide.',
|
|
217
97
|
invalidDay: 'Saisissez un jour valide.',
|
|
218
98
|
invalidMonth: 'Saisissez un mois valide.',
|
|
219
99
|
invalidYear: 'Saisissez une année valide.',
|
|
220
100
|
},
|
|
221
101
|
},
|
|
102
|
+
month: {
|
|
103
|
+
accessibility: {
|
|
104
|
+
en: '1 or 2 digits',
|
|
105
|
+
fr: '1 ou 2 chiffres',
|
|
106
|
+
},
|
|
107
|
+
label: {
|
|
108
|
+
en: 'Month',
|
|
109
|
+
fr: 'Mois',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
year: {
|
|
113
|
+
accessibility: {
|
|
114
|
+
en: '1 or 2 digits',
|
|
115
|
+
fr: '1 ou 2 chiffres',
|
|
116
|
+
},
|
|
117
|
+
label: {
|
|
118
|
+
en: 'Year',
|
|
119
|
+
fr: 'Année',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
222
122
|
};
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
en: '
|
|
226
|
-
fr: '
|
|
123
|
+
const dropdownList = {
|
|
124
|
+
select: {
|
|
125
|
+
en: 'Select',
|
|
126
|
+
fr: 'Sélectionner',
|
|
227
127
|
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
128
|
+
};
|
|
129
|
+
const header = {
|
|
130
|
+
clearSearchField: {
|
|
131
|
+
en: 'Clear field',
|
|
132
|
+
fr: 'Vider le champ',
|
|
231
133
|
},
|
|
232
|
-
|
|
233
|
-
en: '
|
|
234
|
-
fr:
|
|
134
|
+
close: {
|
|
135
|
+
en: 'close',
|
|
136
|
+
fr: 'fermer',
|
|
137
|
+
},
|
|
138
|
+
closeMenu: {
|
|
139
|
+
en: 'Hide navigation menu',
|
|
140
|
+
fr: 'Fermer le menu de navigation',
|
|
141
|
+
},
|
|
142
|
+
closeSearch: {
|
|
143
|
+
en: 'Close search bar',
|
|
144
|
+
fr: 'Fermer la barre de recherche',
|
|
145
|
+
},
|
|
146
|
+
logoAltText: {
|
|
147
|
+
en: 'Ontario.ca homepage',
|
|
148
|
+
fr: 'Page d’accueil Ontario.ca',
|
|
149
|
+
},
|
|
150
|
+
logoLink: {
|
|
151
|
+
en: 'https://www.ontario.ca/page/government-ontario',
|
|
152
|
+
fr: 'https://www.ontario.ca/fr/page/gouvernement-de-lontario',
|
|
153
|
+
},
|
|
154
|
+
ontarioSearchURL: {
|
|
155
|
+
en: 'https://www.ontario.ca/search/search-results?query=',
|
|
156
|
+
fr: 'https://www.ontario.ca/fr/recherche/resultats-de-recherche/?query=',
|
|
157
|
+
},
|
|
158
|
+
openMenu: {
|
|
159
|
+
en: 'Show navigation menu',
|
|
160
|
+
fr: 'Ouvrir le menu de navigation',
|
|
161
|
+
},
|
|
162
|
+
search: {
|
|
163
|
+
en: 'Search',
|
|
164
|
+
fr: 'Rechercher',
|
|
165
|
+
},
|
|
166
|
+
serviceOntario: {
|
|
167
|
+
en: 'ServiceOntario',
|
|
168
|
+
fr: 'ServiceOntario',
|
|
169
|
+
},
|
|
170
|
+
submit: {
|
|
171
|
+
en: 'Submit',
|
|
172
|
+
fr: 'Soumission',
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
const input = {
|
|
176
|
+
requiredFieldError: {
|
|
177
|
+
en: 'This is a required field.',
|
|
178
|
+
fr: 'Ce champ est obligatoire.',
|
|
235
179
|
},
|
|
236
180
|
};
|
|
181
|
+
const languageToggle = {
|
|
182
|
+
ariaLabel: {
|
|
183
|
+
en: 'Click to switch the language to English',
|
|
184
|
+
fr: 'Cliquez pour changer la langue en français',
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
const loading = {
|
|
188
|
+
en: 'Loading',
|
|
189
|
+
fr: 'Chargement',
|
|
190
|
+
};
|
|
191
|
+
const optional = {
|
|
192
|
+
en: 'optional',
|
|
193
|
+
fr: 'facultative',
|
|
194
|
+
};
|
|
195
|
+
const printerLink = {
|
|
196
|
+
link: {
|
|
197
|
+
en: 'https://www.ontario.ca/page/copyright-information',
|
|
198
|
+
fr: 'https://www.ontario.ca/fr/page/droits-dauteur',
|
|
199
|
+
},
|
|
200
|
+
text: {
|
|
201
|
+
en: "King's Printer for Ontario,",
|
|
202
|
+
fr: 'Imprimeur du Roi pour l’Ontario,',
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
const privacyLink = {
|
|
206
|
+
link: {
|
|
207
|
+
en: 'https://www.ontario.ca/page/privacy-statement',
|
|
208
|
+
fr: 'https://www.ontario.ca/fr/page/declaration-concernant-la-protection-de-la-vie-privee',
|
|
209
|
+
},
|
|
210
|
+
text: {
|
|
211
|
+
en: 'Privacy',
|
|
212
|
+
fr: 'Confidentialité',
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
const stepIndicator = {
|
|
216
|
+
back: {
|
|
217
|
+
en: 'Back',
|
|
218
|
+
fr: 'Retour',
|
|
219
|
+
},
|
|
220
|
+
complete: {
|
|
221
|
+
en: 'complete',
|
|
222
|
+
fr: 'complet',
|
|
223
|
+
},
|
|
224
|
+
of: {
|
|
225
|
+
en: 'of',
|
|
226
|
+
fr: 'sur',
|
|
227
|
+
},
|
|
228
|
+
step: {
|
|
229
|
+
en: 'Step',
|
|
230
|
+
fr: 'Étape',
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
const siteLanguage = {
|
|
234
|
+
fullWord: {
|
|
235
|
+
en: 'English',
|
|
236
|
+
fr: 'Français',
|
|
237
|
+
},
|
|
238
|
+
abbreviation: {
|
|
239
|
+
en: 'en',
|
|
240
|
+
fr: 'fr',
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
const required = {
|
|
244
|
+
en: 'required',
|
|
245
|
+
fr: 'obligatoire',
|
|
246
|
+
};
|
|
237
247
|
const translations = {
|
|
238
|
-
required: required,
|
|
239
|
-
optional: optional,
|
|
240
248
|
accessibility: accessibility,
|
|
249
|
+
accessibilityLink: accessibilityLink,
|
|
250
|
+
accordion: accordion,
|
|
241
251
|
backToTop: backToTop,
|
|
242
|
-
loading: loading,
|
|
243
|
-
dropdownList: dropdownList,
|
|
244
252
|
contactUs: contactUs,
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
printerLink: printerLink,
|
|
248
|
-
languageToggle: languageToggle,
|
|
249
|
-
stepIndicator: stepIndicator,
|
|
253
|
+
dateInput: dateInput,
|
|
254
|
+
dropdownList: dropdownList,
|
|
250
255
|
header: header,
|
|
251
256
|
input: input,
|
|
252
|
-
|
|
253
|
-
|
|
257
|
+
languageToggle: languageToggle,
|
|
258
|
+
loading: loading,
|
|
259
|
+
optional: optional,
|
|
260
|
+
printerLink: printerLink,
|
|
261
|
+
privacyLink: privacyLink,
|
|
262
|
+
stepIndicator: stepIndicator,
|
|
263
|
+
siteLanguage: siteLanguage,
|
|
264
|
+
required: required,
|
|
254
265
|
};
|
|
255
266
|
|
|
256
267
|
const ontarioAccordionCss =
|
|
@@ -775,6 +786,32 @@ function isEmpty(str) {
|
|
|
775
786
|
function retrieveEnumKeys(enumObject) {
|
|
776
787
|
return Object.keys(enumObject).filter(isNumber);
|
|
777
788
|
}
|
|
789
|
+
/**
|
|
790
|
+
* Prints an array as a comma delimited list, with the last element being preceded by a conjunction.
|
|
791
|
+
* As per ontario.ca content guidelines, there is no Oxford comma.
|
|
792
|
+
*
|
|
793
|
+
* @param {Array<any>} arr - The array that you wish to print.
|
|
794
|
+
* @param {Conjunction} conjunctionType - Whether you want the sentence to end with 'and value.' or 'or value.'
|
|
795
|
+
*
|
|
796
|
+
* @returns {string}
|
|
797
|
+
*/
|
|
798
|
+
function printArray(arr, conjunctionType = 'and') {
|
|
799
|
+
return [...arr].reduce(
|
|
800
|
+
(text, value, i, array) => text + (i < array.length - 1 ? ', ' : ` ${conjunctionType} `) + value,
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Grabs the HTML element of the page.
|
|
805
|
+
*
|
|
806
|
+
* More targetted than document.documentElement as the documentElement could
|
|
807
|
+
* in theory be any element that is the top level. e.g. <div> if the page is not
|
|
808
|
+
* set up to be semantically correct.
|
|
809
|
+
*
|
|
810
|
+
* @returns {HTMLElement}
|
|
811
|
+
*/
|
|
812
|
+
function getRootHTMLElement() {
|
|
813
|
+
return document.getElementsByTagName('html')[0];
|
|
814
|
+
}
|
|
778
815
|
|
|
779
816
|
var BadgeColourToClass;
|
|
780
817
|
(function (BadgeColourToClass) {
|
|
@@ -1274,7 +1311,7 @@ const CardTypes = ['basic', 'image', 'title', 'horizontal'];
|
|
|
1274
1311
|
const HeaderTypes = ['default', 'light', 'dark'];
|
|
1275
1312
|
|
|
1276
1313
|
const ontarioCardCss =
|
|
1277
|
-
'.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-
|
|
1314
|
+
'.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}';
|
|
1278
1315
|
const OntarioCardStyle0 = ontarioCardCss;
|
|
1279
1316
|
|
|
1280
1317
|
const OntarioCard = class {
|
|
@@ -1362,12 +1399,12 @@ const OntarioCard = class {
|
|
|
1362
1399
|
* @returns the classes of the ontario cards based off the `cardType` and `headerType`.
|
|
1363
1400
|
*/
|
|
1364
1401
|
getClass() {
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
}
|
|
1402
|
+
const baseClass =
|
|
1403
|
+
this.cardTypeState === 'horizontal'
|
|
1404
|
+
? `ontario-card ontario-card__card-type--horizontal ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`
|
|
1405
|
+
: `ontario-card ontario-card__header-type--${this.headerTypeState} ontario-card__card-type--${this.cardTypeState}`;
|
|
1406
|
+
const descriptionClass = this.description ? '' : ' ontario-card__description-false';
|
|
1407
|
+
return `${baseClass}${descriptionClass}`;
|
|
1371
1408
|
}
|
|
1372
1409
|
getHref() {
|
|
1373
1410
|
return this.cardLink ? this.cardLink : '#';
|
|
@@ -1379,7 +1416,7 @@ const OntarioCard = class {
|
|
|
1379
1416
|
render() {
|
|
1380
1417
|
return index.h(
|
|
1381
1418
|
'li',
|
|
1382
|
-
{ key: '
|
|
1419
|
+
{ key: '606e74cea5d81cd31b355ffb1a71cf7450126cf4', class: this.getClass() },
|
|
1383
1420
|
this.image &&
|
|
1384
1421
|
index.h(
|
|
1385
1422
|
'div',
|
|
@@ -1393,16 +1430,16 @@ const OntarioCard = class {
|
|
|
1393
1430
|
index.h(
|
|
1394
1431
|
'div',
|
|
1395
1432
|
{
|
|
1396
|
-
key: '
|
|
1433
|
+
key: '7d71d14690d4e75dcf1e4ef5c0198183b27e4b39',
|
|
1397
1434
|
class: `ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`,
|
|
1398
1435
|
},
|
|
1399
1436
|
index.h(
|
|
1400
1437
|
'h2',
|
|
1401
|
-
{ key: '
|
|
1438
|
+
{ key: '4f6a337efa3986a5023f3c17e869f072aaef0e4f', class: 'ontario-card__heading' },
|
|
1402
1439
|
index.h(
|
|
1403
1440
|
'a',
|
|
1404
1441
|
{
|
|
1405
|
-
'key': '
|
|
1442
|
+
'key': '6efece75daafc95e43dca997e895dc88cab9194c',
|
|
1406
1443
|
'href': this.getHref(),
|
|
1407
1444
|
'aria-label': this.ariaLabelText,
|
|
1408
1445
|
},
|
|
@@ -4021,10 +4058,19 @@ const OntarioHeader = class {
|
|
|
4021
4058
|
if (this.menuToggle) this.menuToggle = !this.menuToggle;
|
|
4022
4059
|
}
|
|
4023
4060
|
/**
|
|
4024
|
-
* This listens for the `setAppLanguage` event sent from the
|
|
4061
|
+
* This listens for the `setAppLanguage` event sent from the language toggle when it is is connected to the DOM.
|
|
4062
|
+
* It is used for the initial language when the input component loads.
|
|
4025
4063
|
*/
|
|
4026
4064
|
handleSetAppLanguage(event) {
|
|
4027
4065
|
this.language = index$1.validateLanguage(event);
|
|
4066
|
+
this.parseMenuItems();
|
|
4067
|
+
}
|
|
4068
|
+
/**
|
|
4069
|
+
* This listens for the `headerLanguageToggled` event sent from the language toggle when it is is connected to the DOM.
|
|
4070
|
+
* It is used for changing the component language after the language toggle has been activated.
|
|
4071
|
+
*/
|
|
4072
|
+
handleLanguageToggle(event) {
|
|
4073
|
+
this.handleSetAppLanguage(event.detail.newLanguage);
|
|
4028
4074
|
}
|
|
4029
4075
|
/**
|
|
4030
4076
|
* Call to Ontario Menu API to fetch linksets to populate header component
|
|
@@ -4321,7 +4367,6 @@ const OntarioHeader = class {
|
|
|
4321
4367
|
: _b.englishLink,
|
|
4322
4368
|
size: 'default',
|
|
4323
4369
|
customLanguageToggle: this.customLanguageToggle,
|
|
4324
|
-
language: this.language,
|
|
4325
4370
|
}),
|
|
4326
4371
|
index.h(
|
|
4327
4372
|
'button',
|
|
@@ -4453,7 +4498,6 @@ const OntarioHeader = class {
|
|
|
4453
4498
|
? void 0
|
|
4454
4499
|
: _e.englishLink,
|
|
4455
4500
|
customLanguageToggle: this.customLanguageToggle,
|
|
4456
|
-
language: this.language,
|
|
4457
4501
|
}),
|
|
4458
4502
|
),
|
|
4459
4503
|
),
|
|
@@ -7292,6 +7336,8 @@ const OntarioInput = class {
|
|
|
7292
7336
|
};
|
|
7293
7337
|
OntarioInput.style = OntarioInputStyle0;
|
|
7294
7338
|
|
|
7339
|
+
const supportedLanguages = ['en', 'fr'];
|
|
7340
|
+
|
|
7295
7341
|
const ontarioLanguageToggleCss =
|
|
7296
7342
|
'.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}';
|
|
7297
7343
|
const OntarioLanguageToggleStyle0 = ontarioLanguageToggleCss;
|
|
@@ -7301,74 +7347,209 @@ const OntarioLanguageToggle = class {
|
|
|
7301
7347
|
index.registerInstance(this, hostRef);
|
|
7302
7348
|
this.setAppLanguage = index.createEvent(this, 'setAppLanguage', 7);
|
|
7303
7349
|
this.headerLanguageToggled = index.createEvent(this, 'headerLanguageToggled', 7);
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
}
|
|
7350
|
+
/*
|
|
7351
|
+
* Updates the <html> lang attribute based on component languageState.
|
|
7352
|
+
*/
|
|
7353
|
+
this.updateHTMLLang = () => {
|
|
7354
|
+
const htmlElement = getRootHTMLElement();
|
|
7355
|
+
if (htmlElement) {
|
|
7356
|
+
htmlElement.setAttribute('lang', this.languageState);
|
|
7312
7357
|
}
|
|
7313
|
-
return;
|
|
7314
7358
|
};
|
|
7315
7359
|
this.language = undefined;
|
|
7316
7360
|
this.size = 'default';
|
|
7317
7361
|
this.url = undefined;
|
|
7318
7362
|
this.customLanguageToggle = undefined;
|
|
7319
7363
|
this.translations = translations;
|
|
7364
|
+
this.languageState = undefined;
|
|
7365
|
+
this.oppositeLanguageLabel = undefined;
|
|
7320
7366
|
}
|
|
7321
|
-
|
|
7322
|
-
|
|
7367
|
+
/**
|
|
7368
|
+
* Updates the language and languageState props when changes to the language prop are detected.
|
|
7369
|
+
*/
|
|
7370
|
+
updateLanguage() {
|
|
7323
7371
|
if (this.language) {
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7372
|
+
if (!index$1.validateValueAgainstArray(this.language, supportedLanguages)) {
|
|
7373
|
+
this.showLanguageWarning(this.language);
|
|
7374
|
+
this.language = this.translations.siteLanguage.abbreviation.en;
|
|
7375
|
+
}
|
|
7376
|
+
this.languageState = this.language;
|
|
7377
|
+
}
|
|
7378
|
+
this.setAppLanguageHandler();
|
|
7379
|
+
}
|
|
7380
|
+
/**
|
|
7381
|
+
* This function sets the languageState (if not already set).
|
|
7382
|
+
*
|
|
7383
|
+
* It also emits the setAppLanguage() event, updates the component language label, and
|
|
7384
|
+
* updates the <html> tag lang attribute with the languageState value.
|
|
7385
|
+
*
|
|
7386
|
+
* It gets called by the connectedCallback() component lifecycle hook, and by the
|
|
7387
|
+
* updateLanguage() method, which is fired on the watch for the language prop.
|
|
7388
|
+
*/
|
|
7389
|
+
setAppLanguageHandler() {
|
|
7390
|
+
var _a;
|
|
7391
|
+
const defaultLang = this.translations.siteLanguage.abbreviation.en;
|
|
7392
|
+
const rootLang = (_a = getRootHTMLElement()) === null || _a === void 0 ? void 0 : _a.lang;
|
|
7393
|
+
// If languageState is not set, set it equal to the following cadence:
|
|
7394
|
+
// language prop value, <html> tag lang attribute, or default to "en"
|
|
7395
|
+
if (!this.languageState) {
|
|
7396
|
+
if (this.language) {
|
|
7397
|
+
this.languageState = this.language;
|
|
7398
|
+
} else if (rootLang) {
|
|
7399
|
+
if (index$1.validateValueAgainstArray(rootLang, supportedLanguages)) {
|
|
7400
|
+
this.languageState = rootLang;
|
|
7401
|
+
} else {
|
|
7402
|
+
this.showLanguageWarning(rootLang, 'document');
|
|
7403
|
+
this.languageState = defaultLang;
|
|
7404
|
+
}
|
|
7405
|
+
} else {
|
|
7406
|
+
this.languageState = defaultLang;
|
|
7407
|
+
}
|
|
7329
7408
|
}
|
|
7330
|
-
this.
|
|
7331
|
-
this.
|
|
7332
|
-
|
|
7409
|
+
this.setAppLanguage.emit(this.languageState);
|
|
7410
|
+
this.oppositeLanguageLabel = {
|
|
7411
|
+
fullWord: this.getOppositeLanguageFullWord(),
|
|
7412
|
+
abbreviation: this.getOppositeLanguageAbbrievation(),
|
|
7413
|
+
};
|
|
7414
|
+
this.updateHTMLLang();
|
|
7333
7415
|
}
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7416
|
+
/**
|
|
7417
|
+
* An event that emits to other components that the language toggle button has been toggled.
|
|
7418
|
+
*
|
|
7419
|
+
* @param {Language} oldLanguage - The language prior to the language toggle being pressed.
|
|
7420
|
+
* @param {globalThis.Event} event - event that triggered the function (e.g. onclick).
|
|
7421
|
+
*/
|
|
7422
|
+
handleHeaderLanguageToggled(oldLanguage, event) {
|
|
7423
|
+
this.languageState =
|
|
7424
|
+
oldLanguage === this.translations.siteLanguage.abbreviation.en
|
|
7425
|
+
? this.translations.siteLanguage.abbreviation.fr
|
|
7426
|
+
: this.translations.siteLanguage.abbreviation.en;
|
|
7427
|
+
this.headerLanguageToggled.emit({ oldLanguage: oldLanguage, newLanguage: this.languageState });
|
|
7428
|
+
this.updateHTMLLang();
|
|
7339
7429
|
if (this.customLanguageToggle && event) {
|
|
7340
7430
|
this.customLanguageToggle(event);
|
|
7341
7431
|
}
|
|
7342
7432
|
}
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7433
|
+
/**
|
|
7434
|
+
* Prints a warning message to the console about using an incorrect language for the component.
|
|
7435
|
+
*
|
|
7436
|
+
* @param {string} lang - The incorrect language that was received.
|
|
7437
|
+
* @param {string} type - prop/document | Where the incorrect language is coming from.
|
|
7438
|
+
*/
|
|
7439
|
+
showLanguageWarning(lang, type = 'prop') {
|
|
7440
|
+
const propOrDocumentMessage =
|
|
7441
|
+
type === 'prop' ? `The language prop value of ${lang} ` : `The HTML document lang attribute value of ${lang} `;
|
|
7442
|
+
const message = new consoleMessage.ConsoleMessageClass();
|
|
7443
|
+
message
|
|
7444
|
+
.addDesignSystemTag()
|
|
7445
|
+
.addRegularText(propOrDocumentMessage)
|
|
7446
|
+
.addRegularText('is not a valid language value for the ')
|
|
7447
|
+
.addMonospaceText(' <ontario-language-toggle> ')
|
|
7448
|
+
.addRegularText(`component. Valid language values are ${printArray([...supportedLanguages])}. `)
|
|
7449
|
+
.addRegularText(`A default language value of ${this.translations.siteLanguage.abbreviation.en} will be applied.`)
|
|
7450
|
+
.printMessage();
|
|
7451
|
+
}
|
|
7452
|
+
/**
|
|
7453
|
+
* Returns abbreviated text for the opposite language.
|
|
7454
|
+
*
|
|
7455
|
+
* @returns {Language}
|
|
7456
|
+
*/
|
|
7457
|
+
getOppositeLanguageAbbrievation() {
|
|
7458
|
+
return this.languageState === this.translations.siteLanguage.abbreviation.en
|
|
7459
|
+
? this.translations.siteLanguage.abbreviation.fr
|
|
7460
|
+
: this.translations.siteLanguage.abbreviation.en;
|
|
7461
|
+
}
|
|
7462
|
+
/**
|
|
7463
|
+
* Returns full word text for the opposite language.
|
|
7464
|
+
*
|
|
7465
|
+
* @returns {string}
|
|
7466
|
+
*/
|
|
7467
|
+
getOppositeLanguageFullWord() {
|
|
7468
|
+
return this.languageState === this.translations.siteLanguage.abbreviation.en
|
|
7469
|
+
? this.translations.siteLanguage.fullWord.fr
|
|
7470
|
+
: this.translations.siteLanguage.fullWord.en;
|
|
7346
7471
|
}
|
|
7472
|
+
/**
|
|
7473
|
+
* Component life cycle hook.
|
|
7474
|
+
*
|
|
7475
|
+
* https://stenciljs.com/docs/component-lifecycle#connectedcallback
|
|
7476
|
+
*/
|
|
7347
7477
|
connectedCallback() {
|
|
7348
|
-
this.
|
|
7478
|
+
this.setAppLanguageHandler();
|
|
7479
|
+
}
|
|
7480
|
+
/**
|
|
7481
|
+
* Component life cycle hook.
|
|
7482
|
+
*
|
|
7483
|
+
* https://stenciljs.com/docs/component-lifecycle#componentdidload
|
|
7484
|
+
*/
|
|
7485
|
+
componentDidLoad() {
|
|
7486
|
+
/**
|
|
7487
|
+
* Creates a MutationObserver (a type of watch) on the <html> tag lang attribute.
|
|
7488
|
+
*
|
|
7489
|
+
* When changes occur, the oppositeLanguageLabel state variable regenerates.
|
|
7490
|
+
*
|
|
7491
|
+
* This is to act as a form of callback and create a subtle delay between page content
|
|
7492
|
+
* updating and the language toggle label updating.
|
|
7493
|
+
*/
|
|
7494
|
+
const observer = new MutationObserver((mutations) => {
|
|
7495
|
+
mutations.forEach((mutation) => {
|
|
7496
|
+
switch (mutation.type) {
|
|
7497
|
+
case 'attributes':
|
|
7498
|
+
switch (mutation.attributeName) {
|
|
7499
|
+
case 'lang':
|
|
7500
|
+
this.oppositeLanguageLabel = {
|
|
7501
|
+
fullWord: this.getOppositeLanguageFullWord(),
|
|
7502
|
+
abbreviation: this.getOppositeLanguageAbbrievation(),
|
|
7503
|
+
};
|
|
7504
|
+
break;
|
|
7505
|
+
}
|
|
7506
|
+
break;
|
|
7507
|
+
}
|
|
7508
|
+
});
|
|
7509
|
+
});
|
|
7510
|
+
// Only create/trigger the MutationObserver if the <html> element exists.
|
|
7511
|
+
if (getRootHTMLElement()) {
|
|
7512
|
+
const options = { attributes: true };
|
|
7513
|
+
observer.observe(getRootHTMLElement(), options);
|
|
7514
|
+
}
|
|
7349
7515
|
}
|
|
7350
7516
|
render() {
|
|
7351
|
-
|
|
7352
|
-
const abbreviatedLanguage = this.language === 'en' ? 'FR' : 'EN';
|
|
7517
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7353
7518
|
return index.h(
|
|
7354
7519
|
'a',
|
|
7355
7520
|
{
|
|
7356
|
-
'key': '
|
|
7521
|
+
'key': 'f43e42110b4272a268801c310a8d14e31342f426',
|
|
7522
|
+
'aria-label':
|
|
7523
|
+
this.translations.languageToggle.ariaLabel[
|
|
7524
|
+
`${(_a = this.oppositeLanguageLabel) === null || _a === void 0 ? void 0 : _a.abbreviation}`
|
|
7525
|
+
],
|
|
7357
7526
|
'class':
|
|
7358
7527
|
this.size === 'default'
|
|
7359
7528
|
? 'ontario-language-toggler ontario-language-toggler--default'
|
|
7360
7529
|
: 'ontario-language-toggler ontario-language-toggler--small',
|
|
7361
7530
|
'href': this.url ? this.url : '#',
|
|
7362
|
-
'
|
|
7363
|
-
'
|
|
7531
|
+
'hreflang': (_b = this.oppositeLanguageLabel) === null || _b === void 0 ? void 0 : _b.abbreviation,
|
|
7532
|
+
'lang': (_c = this.oppositeLanguageLabel) === null || _c === void 0 ? void 0 : _c.abbreviation,
|
|
7533
|
+
'onClick': (e) => this.handleHeaderLanguageToggled(this.languageState, e),
|
|
7364
7534
|
},
|
|
7365
7535
|
this.size === 'small'
|
|
7366
|
-
? index.h('span', null,
|
|
7536
|
+
? index.h('span', null, (_d = this.oppositeLanguageLabel) === null || _d === void 0 ? void 0 : _d.fullWord)
|
|
7367
7537
|
: index.h(
|
|
7368
7538
|
index.Fragment,
|
|
7369
7539
|
null,
|
|
7370
|
-
index.h(
|
|
7371
|
-
|
|
7540
|
+
index.h(
|
|
7541
|
+
'abbr',
|
|
7542
|
+
{
|
|
7543
|
+
title: (_e = this.oppositeLanguageLabel) === null || _e === void 0 ? void 0 : _e.fullWord,
|
|
7544
|
+
class: 'ontario-show-for-small-only',
|
|
7545
|
+
},
|
|
7546
|
+
(_f = this.oppositeLanguageLabel) === null || _f === void 0 ? void 0 : _f.abbreviation.toUpperCase(),
|
|
7547
|
+
),
|
|
7548
|
+
index.h(
|
|
7549
|
+
'span',
|
|
7550
|
+
{ class: 'ontario-show-for-medium' },
|
|
7551
|
+
(_g = this.oppositeLanguageLabel) === null || _g === void 0 ? void 0 : _g.fullWord,
|
|
7552
|
+
),
|
|
7372
7553
|
),
|
|
7373
7554
|
);
|
|
7374
7555
|
}
|