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

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 (78) hide show
  1. package/dist/cjs/app-globals-6f6b30a8.js.map +1 -1
  2. package/dist/cjs/ontario-accordion_44.cjs.entry.js +19 -7
  3. package/dist/cjs/ontario-accordion_44.cjs.entry.js.map +1 -1
  4. package/dist/collection/components/ontario-date-input/test/ontario-date-input.spec.js +58 -0
  5. package/dist/collection/components/ontario-date-input/test/ontario-date-input.spec.js.map +1 -1
  6. package/dist/collection/components/ontario-date-input/utils/date-validation-utils.js +14 -4
  7. package/dist/collection/components/ontario-date-input/utils/date-validation-utils.js.map +1 -1
  8. package/dist/collection/components/ontario-footer/test/ontario-footer.spec.js +4 -4
  9. package/dist/collection/components/ontario-footer/test/ontario-footer.spec.js.map +1 -1
  10. package/dist/collection/fonts/open-sans-400/LICENSE.txt +0 -0
  11. package/dist/collection/fonts/open-sans-400/open-sans-400.eot +0 -0
  12. package/dist/collection/fonts/open-sans-400/open-sans-400.svg +0 -0
  13. package/dist/collection/fonts/open-sans-400/open-sans-400.ttf +0 -0
  14. package/dist/collection/fonts/open-sans-400/open-sans-400.woff +0 -0
  15. package/dist/collection/fonts/open-sans-400/open-sans-400.woff2 +0 -0
  16. package/dist/collection/fonts/open-sans-700/LICENSE.txt +0 -0
  17. package/dist/collection/fonts/open-sans-700/open-sans-700.eot +0 -0
  18. package/dist/collection/fonts/open-sans-700/open-sans-700.svg +0 -0
  19. package/dist/collection/fonts/open-sans-700/open-sans-700.ttf +0 -0
  20. package/dist/collection/utils/helper/utils.js +4 -2
  21. package/dist/collection/utils/helper/utils.js.map +1 -1
  22. package/dist/collection/utils/helper/utils.spec.js +99 -1
  23. package/dist/collection/utils/helper/utils.spec.js.map +1 -1
  24. package/dist/components/ontario-date-input.js +13 -3
  25. package/dist/components/ontario-date-input.js.map +1 -1
  26. package/dist/components/ontario-header.js +2 -2
  27. package/dist/components/ontario-header.js.map +1 -1
  28. package/dist/components/utils.js +4 -2
  29. package/dist/components/utils.js.map +1 -1
  30. package/dist/esm/app-globals-70748594.js.map +1 -1
  31. package/dist/esm/ontario-accordion_44.entry.js +19 -7
  32. package/dist/esm/ontario-accordion_44.entry.js.map +1 -1
  33. package/dist/esm/polyfills/core-js.js +0 -0
  34. package/dist/esm/polyfills/dom.js +0 -0
  35. package/dist/esm/polyfills/es5-html-element.js +0 -0
  36. package/dist/esm/polyfills/index.js +0 -0
  37. package/dist/esm/polyfills/system.js +0 -0
  38. package/dist/ontario-design-system-components/fonts/open-sans-400/LICENSE.txt +0 -0
  39. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.eot +0 -0
  40. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.svg +0 -0
  41. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.ttf +0 -0
  42. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.woff +0 -0
  43. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.woff2 +0 -0
  44. package/dist/ontario-design-system-components/fonts/open-sans-700/LICENSE.txt +0 -0
  45. package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.eot +0 -0
  46. package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.svg +0 -0
  47. package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.ttf +0 -0
  48. package/dist/ontario-design-system-components/ontario-design-system-components.esm.js +1 -1
  49. package/dist/ontario-design-system-components/p-103a233b.js.map +1 -1
  50. package/dist/ontario-design-system-components/{p-9c3a1be9.entry.js → p-ac4e76b2.entry.js} +8 -6
  51. package/dist/ontario-design-system-components/p-ac4e76b2.entry.js.map +1 -0
  52. package/dist/types/components/ontario-date-input/utils/date-validation-utils.d.ts +14 -0
  53. package/package.json +3 -3
  54. package/src/components/ontario-date-input/test/ontario-date-input.spec.tsx +76 -0
  55. package/src/components/ontario-date-input/utils/date-validation-utils.ts +18 -4
  56. package/src/components/ontario-footer/test/ontario-footer.spec.tsx +4 -4
  57. package/src/components/ontario-header/ontario-header.scss +4 -4
  58. package/src/config.json +1 -4
  59. package/src/utils/helper/utils.spec.ts +127 -1
  60. package/src/utils/helper/utils.ts +4 -2
  61. package/www/build/ontario-design-system-components.esm.js +1 -1
  62. package/www/build/p-103a233b.js.map +1 -1
  63. package/www/build/{p-9c3a1be9.entry.js → p-ac4e76b2.entry.js} +8 -6
  64. package/www/build/p-ac4e76b2.entry.js.map +1 -0
  65. package/www/build/{p-84035ac3.js → p-c9a9b857.js} +1 -1
  66. package/www/fonts/open-sans-400/LICENSE.txt +0 -0
  67. package/www/fonts/open-sans-400/open-sans-400.eot +0 -0
  68. package/www/fonts/open-sans-400/open-sans-400.svg +0 -0
  69. package/www/fonts/open-sans-400/open-sans-400.ttf +0 -0
  70. package/www/fonts/open-sans-400/open-sans-400.woff +0 -0
  71. package/www/fonts/open-sans-400/open-sans-400.woff2 +0 -0
  72. package/www/fonts/open-sans-700/LICENSE.txt +0 -0
  73. package/www/fonts/open-sans-700/open-sans-700.eot +0 -0
  74. package/www/fonts/open-sans-700/open-sans-700.svg +0 -0
  75. package/www/fonts/open-sans-700/open-sans-700.ttf +0 -0
  76. package/www/index.html +2 -2
  77. package/dist/ontario-design-system-components/p-9c3a1be9.entry.js.map +0 -1
  78. package/www/build/p-9c3a1be9.entry.js.map +0 -1
@@ -1,5 +1,19 @@
1
1
  import { DateValidatorReturnType } from '../ontario-date-input-interface';
2
2
  import { Translations } from '../../../translations';
3
+ /**
4
+ * Valid value year against minimum and maximum year range (defaulted if not provided.)
5
+ *
6
+ * Year field should be a number and not written out; it has no concept of positive and negative.
7
+ *
8
+ * Suggestion:
9
+ * - `< 0` B.C.E.
10
+ * - `>= 0` A.C.E.
11
+ *
12
+ * @param value value to check for validity
13
+ * @param minYear minimum valid year to validate against
14
+ * @param maxYear maximum valid year to validate against
15
+ */
16
+ export declare const isInvalidYear: (value: string | number, minYear?: number, maxYear?: number) => boolean;
3
17
  type GetDateErrorArg = {
4
18
  dayValue: string;
5
19
  monthValue: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ongov/ontario-design-system-component-library",
3
- "version": "5.0.0-alpha.1",
3
+ "version": "5.0.0-alpha.4",
4
4
  "private": false,
5
5
  "description": "Ontario Design System Component Library",
6
6
  "license": "Apache-2.0",
@@ -40,7 +40,7 @@
40
40
  "test:unit": "stencil test --spec"
41
41
  },
42
42
  "dependencies": {
43
- "@ongov/ontario-design-system-global-styles": "4.3.1-alpha.1",
43
+ "@ongov/ontario-design-system-global-styles": "5.0.0-alpha.3",
44
44
  "@stencil/core": "^4.12.2",
45
45
  "dotenv": "^16.3.1"
46
46
  },
@@ -102,5 +102,5 @@
102
102
  "collection:main": "dist/collection/index.js",
103
103
  "es2015": "dist/esm/index.mjs",
104
104
  "es2017": "dist/esm/index.mjs",
105
- "gitHead": "2941db5cb66d3a161e359f36543b489922853b02"
105
+ "gitHead": "14b540375d2b095c2d61825af04a004708e4ff38"
106
106
  }
@@ -1,5 +1,6 @@
1
1
  import { newSpecPage } from '@stencil/core/testing';
2
2
  import { OntarioDateInput } from '../ontario-date-input';
3
+ import { isInvalidYear } from '../utils';
3
4
 
4
5
  describe('ontario-date-input', () => {
5
6
  it('renders deafult state', async () => {
@@ -120,3 +121,78 @@ describe('ontario-date-input', () => {
120
121
  `);
121
122
  });
122
123
  });
124
+
125
+ describe('date-validation-utils', () => {
126
+ it('is invalid year value - undefined string', () => {
127
+ // Note: Type system doesn't like `undefined` as `any` lets us force it for testing purposes
128
+ const value: any = undefined;
129
+
130
+ const isInvalidYearResult = isInvalidYear(value);
131
+ expect(isInvalidYearResult).toEqual(true);
132
+ });
133
+
134
+ it('is invalid year value - null string', () => {
135
+ // Note: Type system doesn't like `null` as `any` lets us force it for testing purposes
136
+ const value: any = null;
137
+
138
+ const isInvalidYearResult = isInvalidYear(value);
139
+ expect(isInvalidYearResult).toEqual(true);
140
+ });
141
+
142
+ it('is invalid year value - empty string', () => {
143
+ const value = ''; // Empty string
144
+
145
+ const isInvalidYearResult = isInvalidYear(value);
146
+ expect(isInvalidYearResult).toEqual(true);
147
+ });
148
+
149
+ it('is invalid year value - written out number', () => {
150
+ const value = 'two-thousand';
151
+
152
+ const isInvalidYearResult = isInvalidYear(value);
153
+ expect(isInvalidYearResult).toEqual(true);
154
+ });
155
+
156
+ it('is valid year value', () => {
157
+ const value = '2000';
158
+
159
+ const isValidYear = !isInvalidYear(value);
160
+ expect(isValidYear).toEqual(true);
161
+ });
162
+
163
+ it('is valid year when in range', () => {
164
+ const value = '2000';
165
+ const minYear = 1;
166
+ const maxYear = 9999;
167
+
168
+ const isValidYear = !isInvalidYear(value, minYear, maxYear);
169
+ expect(isValidYear).toEqual(true);
170
+ });
171
+
172
+ it('is valid year when in range but is minYear', () => {
173
+ const value = '2000';
174
+ const minYear = 2000;
175
+ const maxYear = 9999;
176
+
177
+ const isValidYear = !isInvalidYear(value, minYear, maxYear);
178
+ expect(isValidYear).toEqual(true);
179
+ });
180
+
181
+ it('is valid year when in range but is maxYear', () => {
182
+ const value = '2000';
183
+ const minYear = 1;
184
+ const maxYear = 2000;
185
+
186
+ const isValidYear = !isInvalidYear(value, minYear, maxYear);
187
+ expect(isValidYear).toEqual(true);
188
+ });
189
+
190
+ it('is invalid year when out of range', () => {
191
+ const value = '2000';
192
+ const minYear = 1;
193
+ const maxYear = 1999;
194
+
195
+ const isValidYear = !isInvalidYear(value, minYear, maxYear);
196
+ expect(isValidYear).toEqual(false);
197
+ });
198
+ });
@@ -35,17 +35,31 @@ const isInvalidMonth = (value: string) => {
35
35
  return month < MONTH_MIN_VALUE || month > MONTH_MAX_VALUE;
36
36
  };
37
37
 
38
- /*
39
- * Year field should be a number, not negative, at length at least 4 digits
38
+ /**
39
+ * Valid value year against minimum and maximum year range (defaulted if not provided.)
40
+ *
41
+ * Year field should be a number and not written out; it has no concept of positive and negative.
42
+ *
43
+ * Suggestion:
44
+ * - `< 0` B.C.E.
45
+ * - `>= 0` A.C.E.
46
+ *
47
+ * @param value value to check for validity
48
+ * @param minYear minimum valid year to validate against
49
+ * @param maxYear maximum valid year to validate against
40
50
  */
41
- const isInvalidYear = (value: string, minYear: number = YEAR_MIN_VALUE, maxYear: number = YEAR_MAX_VALUE) => {
51
+ export const isInvalidYear = (
52
+ value: string | number,
53
+ minYear: number = YEAR_MIN_VALUE,
54
+ maxYear: number = YEAR_MAX_VALUE,
55
+ ) => {
42
56
  if (!isNumber(value)) {
43
57
  return true;
44
58
  }
45
59
 
46
60
  const year = Number(value);
47
61
 
48
- return year <= minYear || year > maxYear;
62
+ return year < minYear || year > maxYear;
49
63
  };
50
64
 
51
65
  type GetDateErrorArg = {
@@ -58,7 +58,7 @@ describe('ontario-footer', () => {
58
58
  <li><a class="ontario-footer__link" href="https://www.ontario.ca/feedback/contact-us">Contact</a></li>
59
59
  </ul>
60
60
  <div class="ontario-footer__copyright">
61
- <a class="ontario-footer__link" href="https://www.ontario.ca/page/copyright-information">© King's Printer for Ontario, <span class="ontario-nbsp">2012–24</span></a>
61
+ <a class="ontario-footer__link" href="https://www.ontario.ca/page/copyright-information">© King's Printer for Ontario, <span class="ontario-nbsp">2012–25</span></a>
62
62
  </div>
63
63
  </div>
64
64
  </div>
@@ -201,7 +201,7 @@ describe('ontario-footer', () => {
201
201
  <li><a class="ontario-footer__link" href="https://www.ontario.ca/feedback/contact-us">Contact</a></li>
202
202
  </ul>
203
203
  <div class="ontario-footer__copyright">
204
- <a class="ontario-footer__link" href="https://www.ontario.ca/page/copyright-information">© King's Printer for Ontario, <span class="ontario-nbsp">2012–24</span></a>
204
+ <a class="ontario-footer__link" href="https://www.ontario.ca/page/copyright-information">© King's Printer for Ontario, <span class="ontario-nbsp">2012–25</span></a>
205
205
  </div>
206
206
  </div>
207
207
  </div>
@@ -370,7 +370,7 @@ describe('ontario-footer', () => {
370
370
  <li><a class="ontario-footer__link" href="https://www.ontario.ca/feedback/contact-us">Contact</a></li>
371
371
  </ul>
372
372
  <div class="ontario-footer__copyright">
373
- <a class="ontario-footer__link" href="https://www.ontario.ca/page/copyright-information">© King's Printer for Ontario, <span class="ontario-nbsp">2012–24</span></a>
373
+ <a class="ontario-footer__link" href="https://www.ontario.ca/page/copyright-information">© King's Printer for Ontario, <span class="ontario-nbsp">2012–25</span></a>
374
374
  </div>
375
375
  </div>
376
376
  </div>
@@ -549,7 +549,7 @@ describe('ontario-footer', () => {
549
549
  <li><a class="ontario-footer__link" href="https://www.ontario.ca/feedback/contact-us">Contact</a></li>
550
550
  </ul>
551
551
  <div class="ontario-footer__copyright">
552
- <a class="ontario-footer__link" href="https://www.ontario.ca/page/copyright-information">© King's Printer for Ontario, <span class="ontario-nbsp">2012–24</span></a>
552
+ <a class="ontario-footer__link" href="https://www.ontario.ca/page/copyright-information">© King's Printer for Ontario, <span class="ontario-nbsp">2012–25</span></a>
553
553
  </div>
554
554
  </div>
555
555
  </div>
@@ -14,8 +14,8 @@
14
14
  @use '@ongov/ontario-design-system-global-styles/dist/styles/scss/6-components/_text-inputs.component.scss';
15
15
  @use '@ongov/ontario-design-system-global-styles/dist/styles/scss/7-overrides/_visibility.overrides.scss';
16
16
 
17
- $ontario-search-input-padding: 7.2rem;
18
- $ontario-search-input-padding--mobile: 6.4rem;
17
+ $ontario-search-padding: 7.2rem;
18
+ $ontario-search-padding--mobile: 6.4rem;
19
19
 
20
20
  $ontario-header-logo-width: 180px;
21
21
  $ontario-header-logo-width--mobile: 45px;
@@ -304,7 +304,7 @@ $ontario-navigation-container-min-width: 290px;
304
304
  margin-bottom: spacing.$spacing-0;
305
305
  height: globalVariables.$standard-input-height;
306
306
  padding-left: spacing.$spacing-3;
307
- padding-right: $ontario-search-input-padding;
307
+ padding-right: $ontario-search-padding;
308
308
 
309
309
  &:invalid + input[type='reset'] {
310
310
  display: none;
@@ -346,7 +346,7 @@ $ontario-navigation-container-min-width: 290px;
346
346
 
347
347
  @media screen and (min-width: breakpoints.$small-breakpoint) and (max-width: breakpoints.$medium-breakpoint) {
348
348
  padding-left: spacing.$spacing-4;
349
- padding-right: $ontario-search-input-padding--mobile;
349
+ padding-right: $ontario-search-padding--mobile;
350
350
  }
351
351
  }
352
352
 
package/src/config.json CHANGED
@@ -1,4 +1 @@
1
- {
2
- "ONTARIO_HEADER_API_URL_EN": "https://www.ontario.ca/system/menu/main/linkset",
3
- "ONTARIO_HEADER_API_URL_FR": "https://www.ontario.ca/system/menu/main-fr/linkset"
4
- }
1
+ { "ONTARIO_HEADER_API_URL_EN": "", "ONTARIO_HEADER_API_URL_FR": "" }
@@ -1,4 +1,4 @@
1
- import { format } from './utils';
1
+ import { format, isNumber, retrieveEnumKeys } from './utils';
2
2
 
3
3
  describe('format', () => {
4
4
  it('returns empty string for no names defined', () => {
@@ -17,3 +17,129 @@ describe('format', () => {
17
17
  expect(format('Joseph', 'Quincy', 'Publique')).toEqual('Joseph Quincy Publique');
18
18
  });
19
19
  });
20
+
21
+ describe('isNumber', () => {
22
+ it('should return false if value is undefined', () => {
23
+ const value: any = undefined;
24
+
25
+ const result = isNumber(value);
26
+ expect(result).toEqual(false);
27
+ });
28
+
29
+ it('should return false if value that is null', () => {
30
+ const value: any = null;
31
+
32
+ const result = isNumber(value);
33
+ expect(result).toEqual(false);
34
+ });
35
+
36
+ it('should return true if value is a number', () => {
37
+ const value: number = 2000;
38
+
39
+ const result = isNumber(value);
40
+ expect(result).toEqual(true);
41
+ });
42
+
43
+ it('should return true if value is a number as a string', () => {
44
+ const value: string = '2000';
45
+
46
+ const result = isNumber(value);
47
+ expect(result).toEqual(true);
48
+ });
49
+
50
+ it('should return false if value is not a number string', () => {
51
+ const value: string = 'two-thousand';
52
+
53
+ const result = isNumber(value);
54
+ expect(result).toEqual(false);
55
+ });
56
+ });
57
+
58
+ describe('isNumber', () => {
59
+ it('should return false if value is undefined', () => {
60
+ const value: any = undefined;
61
+
62
+ const result = isNumber(value);
63
+ expect(result).toEqual(false);
64
+ });
65
+
66
+ it('should return false if value that is null', () => {
67
+ const value: any = null;
68
+
69
+ const result = isNumber(value);
70
+ expect(result).toEqual(false);
71
+ });
72
+
73
+ it('should return true if value is a number', () => {
74
+ const value: number = 2000;
75
+
76
+ const result = isNumber(value);
77
+ expect(result).toEqual(true);
78
+ });
79
+
80
+ it('should return true if value is a number as a string', () => {
81
+ const value: string = '2000';
82
+
83
+ const result = isNumber(value);
84
+ expect(result).toEqual(true);
85
+ });
86
+
87
+ it('should return false if value is not a number string', () => {
88
+ const value: string = 'two-thousand';
89
+
90
+ const result = isNumber(value);
91
+ expect(result).toEqual(false);
92
+ });
93
+ });
94
+
95
+ enum ColourEnumNumeric {
96
+ RED,
97
+ ORANGE,
98
+ YELLOW,
99
+ GREEN,
100
+ BLUE,
101
+ INDIGO,
102
+ VIOLET,
103
+ }
104
+
105
+ enum ColourEnumString {
106
+ 'red' = 'Red',
107
+ 'orange' = 'Orange',
108
+ 'yellow' = 'Yellow',
109
+ 'green' = 'Green',
110
+ 'blue' = 'Blue',
111
+ 'indigo' = 'Indigo',
112
+ 'violet' = 'Violet',
113
+ }
114
+
115
+ describe('retrieveEnumKeys', () => {
116
+ it('should return empty array if enumObject is undefined', () => {
117
+ const expectedResult = new Array<string>(0);
118
+ const enumObject: any = undefined;
119
+
120
+ const result = retrieveEnumKeys(enumObject);
121
+ expect(result).toEqual(expectedResult);
122
+ });
123
+
124
+ it('should return empty array if enumObject is null', () => {
125
+ const expectedResult = new Array<string>(0);
126
+ const enumObject: any = null;
127
+
128
+ const result = retrieveEnumKeys(enumObject);
129
+ expect(result).toEqual(expectedResult);
130
+ });
131
+
132
+ it('should return keys from numerical enum', () => {
133
+ const expectedResult = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'INDIGO', 'VIOLET'];
134
+
135
+ const result = retrieveEnumKeys(ColourEnumNumeric);
136
+ expect(result).toEqual(expectedResult);
137
+ });
138
+
139
+ it('should return keys from string enum', () => {
140
+ const expectedResult = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];
141
+
142
+ const result = retrieveEnumKeys(ColourEnumString);
143
+ expect(result).toEqual(expectedResult);
144
+ });
145
+ });
@@ -67,7 +67,8 @@ export function removeObjectsBySpecificKey<T>(objects: T[], key: keyof T, value:
67
67
  * @returns {boolean}
68
68
  */
69
69
  export function isNumber(value: string | number): boolean {
70
- return isNaN(Number(value)) === true;
70
+ if (value === undefined || value === null) return false;
71
+ return isNaN(Number(value)) === false;
71
72
  }
72
73
 
73
74
  export function isEmpty(str: string | undefined | null): boolean {
@@ -82,7 +83,8 @@ export function isEmpty(str: string | undefined | null): boolean {
82
83
  * @returns {string[]}
83
84
  */
84
85
  export function retrieveEnumKeys(enumObject: object): string[] {
85
- return Object.keys(enumObject).filter(isNumber);
86
+ if (enumObject === undefined || enumObject === null) return new Array<string>(0);
87
+ return Object.keys(enumObject).filter((key) => !isNumber(key));
86
88
  }
87
89
 
88
90
  /**