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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/dist/cjs/app-globals-6f6b30a8.js.map +1 -1
  2. package/dist/cjs/index-88d5cf20.js +2 -2
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{ontario-accordion_43.cjs.entry.js → ontario-accordion_44.cjs.entry.js} +358 -85
  5. package/dist/cjs/ontario-accordion_44.cjs.entry.js.map +1 -0
  6. package/dist/cjs/ontario-design-system-components.cjs.js +1 -1
  7. package/dist/collection/collection-manifest.json +1 -0
  8. package/dist/collection/components/ontario-card/ontario-card-types.js +29 -2
  9. package/dist/collection/components/ontario-card/ontario-card-types.js.map +1 -1
  10. package/dist/collection/components/ontario-card/ontario-card.css +252 -34
  11. package/dist/collection/components/ontario-card/ontario-card.js +102 -78
  12. package/dist/collection/components/ontario-card/ontario-card.js.map +1 -1
  13. package/dist/collection/components/ontario-card/test/ontario-cards.spec.js +23 -13
  14. package/dist/collection/components/ontario-card/test/ontario-cards.spec.js.map +1 -1
  15. package/dist/collection/components/ontario-date-input/test/ontario-date-input.spec.js +58 -0
  16. package/dist/collection/components/ontario-date-input/test/ontario-date-input.spec.js.map +1 -1
  17. package/dist/collection/components/ontario-date-input/utils/date-validation-utils.js +14 -4
  18. package/dist/collection/components/ontario-date-input/utils/date-validation-utils.js.map +1 -1
  19. package/dist/collection/components/ontario-header/service-ontario-header.css +0 -3
  20. package/dist/collection/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
  21. package/dist/collection/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
  22. package/dist/collection/components/ontario-search-box/ontario-search-box.css +823 -0
  23. package/dist/collection/components/ontario-search-box/ontario-search-box.js +584 -0
  24. package/dist/collection/components/ontario-search-box/ontario-search-box.js.map +1 -0
  25. package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js +20 -0
  26. package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js.map +1 -0
  27. package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js +19 -0
  28. package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js.map +1 -0
  29. package/dist/collection/components/ontario-step-indicator/ontario-step-indicator.js +5 -5
  30. package/dist/collection/components/ontario-table/ontario-table.js +5 -5
  31. package/dist/collection/components/ontario-textarea/ontario-textarea.js +3 -3
  32. package/dist/collection/fonts/open-sans-400/LICENSE.txt +0 -0
  33. package/dist/collection/fonts/open-sans-400/open-sans-400.eot +0 -0
  34. package/dist/collection/fonts/open-sans-400/open-sans-400.svg +0 -0
  35. package/dist/collection/fonts/open-sans-400/open-sans-400.ttf +0 -0
  36. package/dist/collection/fonts/open-sans-400/open-sans-400.woff +0 -0
  37. package/dist/collection/fonts/open-sans-400/open-sans-400.woff2 +0 -0
  38. package/dist/collection/fonts/open-sans-700/LICENSE.txt +0 -0
  39. package/dist/collection/fonts/open-sans-700/open-sans-700.eot +0 -0
  40. package/dist/collection/fonts/open-sans-700/open-sans-700.svg +0 -0
  41. package/dist/collection/fonts/open-sans-700/open-sans-700.ttf +0 -0
  42. package/dist/collection/utils/common/input/input.js +3 -0
  43. package/dist/collection/utils/common/input/input.js.map +1 -1
  44. package/dist/collection/utils/common/input-caption/input-caption.js +5 -3
  45. package/dist/collection/utils/common/input-caption/input-caption.js.map +1 -1
  46. package/dist/collection/utils/helper/utils.js +4 -2
  47. package/dist/collection/utils/helper/utils.js.map +1 -1
  48. package/dist/collection/utils/helper/utils.spec.js +99 -1
  49. package/dist/collection/utils/helper/utils.spec.js.map +1 -1
  50. package/dist/components/error-message.js +1 -324
  51. package/dist/components/error-message.js.map +1 -1
  52. package/dist/components/event-handler.js +330 -0
  53. package/dist/components/event-handler.js.map +1 -0
  54. package/dist/components/input.js +3 -0
  55. package/dist/components/input.js.map +1 -1
  56. package/dist/components/ontario-card.js +116 -64
  57. package/dist/components/ontario-card.js.map +1 -1
  58. package/dist/components/ontario-checkboxes.js +2 -1
  59. package/dist/components/ontario-checkboxes.js.map +1 -1
  60. package/dist/components/ontario-date-input.js +15 -4
  61. package/dist/components/ontario-date-input.js.map +1 -1
  62. package/dist/components/ontario-dropdown-list.js +2 -1
  63. package/dist/components/ontario-dropdown-list.js.map +1 -1
  64. package/dist/components/ontario-header.js +4 -6
  65. package/dist/components/ontario-header.js.map +1 -1
  66. package/dist/components/ontario-icon-search2.js +6 -0
  67. package/dist/components/ontario-icon-search2.js.map +1 -0
  68. package/dist/components/ontario-input.js +2 -1
  69. package/dist/components/ontario-input.js.map +1 -1
  70. package/dist/components/ontario-radio-buttons.js +2 -1
  71. package/dist/components/ontario-radio-buttons.js.map +1 -1
  72. package/dist/components/ontario-search-box.d.ts +11 -0
  73. package/dist/components/ontario-search-box.js +269 -0
  74. package/dist/components/ontario-search-box.js.map +1 -0
  75. package/dist/components/ontario-step-indicator.js +5 -5
  76. package/dist/components/ontario-table.js +5 -5
  77. package/dist/components/ontario-textarea.js +5 -4
  78. package/dist/components/ontario-textarea.js.map +1 -1
  79. package/dist/components/utils.js +4 -2
  80. package/dist/components/utils.js.map +1 -1
  81. package/dist/esm/app-globals-70748594.js.map +1 -1
  82. package/dist/esm/index-603026f7.js +2 -2
  83. package/dist/esm/loader.js +1 -1
  84. package/dist/esm/{ontario-accordion_43.entry.js → ontario-accordion_44.entry.js} +358 -85
  85. package/dist/esm/ontario-accordion_44.entry.js.map +1 -0
  86. package/dist/esm/ontario-design-system-components.js +1 -1
  87. package/dist/esm/polyfills/core-js.js +0 -0
  88. package/dist/esm/polyfills/dom.js +0 -0
  89. package/dist/esm/polyfills/es5-html-element.js +0 -0
  90. package/dist/esm/polyfills/index.js +0 -0
  91. package/dist/esm/polyfills/system.js +0 -0
  92. package/dist/ontario-design-system-components/fonts/open-sans-400/LICENSE.txt +0 -0
  93. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.eot +0 -0
  94. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.svg +0 -0
  95. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.ttf +0 -0
  96. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.woff +0 -0
  97. package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.woff2 +0 -0
  98. package/dist/ontario-design-system-components/fonts/open-sans-700/LICENSE.txt +0 -0
  99. package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.eot +0 -0
  100. package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.svg +0 -0
  101. package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.ttf +0 -0
  102. package/dist/ontario-design-system-components/ontario-design-system-components.esm.js +1 -1
  103. package/dist/ontario-design-system-components/ontario-design-system-components.esm.js.map +1 -1
  104. package/dist/ontario-design-system-components/p-103a233b.js.map +1 -1
  105. package/dist/ontario-design-system-components/{p-abe58ec9.entry.js → p-ac4e76b2.entry.js} +1927 -1728
  106. package/dist/ontario-design-system-components/p-ac4e76b2.entry.js.map +1 -0
  107. package/dist/types/components/ontario-card/ontario-card-types.d.ts +4 -4
  108. package/dist/types/components/ontario-card/ontario-card.d.ts +40 -29
  109. package/dist/types/components/ontario-date-input/utils/date-validation-utils.d.ts +14 -0
  110. package/dist/types/components/ontario-search-box/ontario-search-box.d.ts +180 -0
  111. package/dist/types/components.d.ts +199 -16
  112. package/dist/types/utils/common/input/input.d.ts +2 -1
  113. package/dist/types/utils/common/input-caption/input-caption.d.ts +7 -1
  114. package/package.json +3 -3
  115. package/src/components/ontario-card/ontario-card-types.tsx +33 -4
  116. package/src/components/ontario-card/ontario-card.scss +54 -40
  117. package/src/components/ontario-card/ontario-card.tsx +94 -68
  118. package/src/components/ontario-card/readme.md +57 -27
  119. package/src/components/ontario-card/test/__snapshots__/ontario-cards.spec.tsx.snap +66 -0
  120. package/src/components/ontario-card/test/ontario-cards.spec.tsx +27 -13
  121. package/src/components/ontario-card-collection/readme.md +13 -13
  122. package/src/components/ontario-checkbox/ontario-checkboxes.scss +0 -1
  123. package/src/components/ontario-date-input/test/ontario-date-input.spec.tsx +76 -0
  124. package/src/components/ontario-date-input/utils/date-validation-utils.ts +18 -4
  125. package/src/components/ontario-header/service-ontario-header.scss +0 -4
  126. package/src/components/ontario-hint-text/readme.md +2 -0
  127. package/src/components/ontario-radio-buttons/ontario-radio-buttons.scss +0 -1
  128. package/src/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
  129. package/src/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
  130. package/src/components/ontario-search-box/ontario-search-box.scss +141 -0
  131. package/src/components/ontario-search-box/ontario-search-box.tsx +341 -0
  132. package/src/components/ontario-search-box/readme.md +132 -0
  133. package/src/components/ontario-search-box/test/__snapshots__/ontario-search-box.spec.tsx.snap +35 -0
  134. package/src/components/ontario-search-box/test/ontario-search-box.e2e.ts +21 -0
  135. package/src/components/ontario-search-box/test/ontario-search-box.spec.tsx +22 -0
  136. package/src/components.d.ts +199 -16
  137. package/src/config.json +1 -4
  138. package/src/index.html +287 -52
  139. package/src/utils/common/input/input.tsx +4 -1
  140. package/src/utils/common/input-caption/input-caption.tsx +9 -3
  141. package/src/utils/helper/utils.spec.ts +127 -1
  142. package/src/utils/helper/utils.ts +4 -2
  143. package/www/build/ontario-design-system-components.esm.js +1 -1
  144. package/www/build/ontario-design-system-components.esm.js.map +1 -1
  145. package/www/build/p-103a233b.js.map +1 -1
  146. package/www/build/{p-abe58ec9.entry.js → p-ac4e76b2.entry.js} +1927 -1728
  147. package/www/build/p-ac4e76b2.entry.js.map +1 -0
  148. package/www/build/{p-fdc9ab6d.js → p-c9a9b857.js} +1 -1
  149. package/www/fonts/open-sans-400/LICENSE.txt +0 -0
  150. package/www/fonts/open-sans-400/open-sans-400.eot +0 -0
  151. package/www/fonts/open-sans-400/open-sans-400.svg +0 -0
  152. package/www/fonts/open-sans-400/open-sans-400.ttf +0 -0
  153. package/www/fonts/open-sans-400/open-sans-400.woff +0 -0
  154. package/www/fonts/open-sans-400/open-sans-400.woff2 +0 -0
  155. package/www/fonts/open-sans-700/LICENSE.txt +0 -0
  156. package/www/fonts/open-sans-700/open-sans-700.eot +0 -0
  157. package/www/fonts/open-sans-700/open-sans-700.svg +0 -0
  158. package/www/fonts/open-sans-700/open-sans-700.ttf +0 -0
  159. package/www/index.html +261 -52
  160. package/dist/cjs/ontario-accordion_43.cjs.entry.js.map +0 -1
  161. package/dist/esm/ontario-accordion_43.entry.js.map +0 -1
  162. package/dist/ontario-design-system-components/p-abe58ec9.entry.js.map +0 -1
  163. package/www/build/p-abe58ec9.entry.js.map +0 -1
@@ -1,109 +1,135 @@
1
1
  import { h } from '@stencil/core';
2
- import { CardTypes, HeaderTypes } from './ontario-card-types';
2
+ import { HeaderColours, Layouts } from './ontario-card-types';
3
3
  import { validateValueAgainstArray } from '../../utils/validation/validation-functions';
4
4
  import { ConsoleMessageClass } from '../../utils/console-message/console-message';
5
+ import { printArray } from '../../utils/helper/utils';
5
6
  export class OntarioCard {
6
7
  constructor() {
7
8
  this.label = undefined;
8
9
  this.image = undefined;
9
10
  this.description = undefined;
10
11
  this.cardLink = undefined;
11
- this.cardType = 'basic';
12
- this.headerType = 'default';
12
+ this.layout = 'vertical';
13
+ this.headerColour = undefined;
13
14
  this.horizontalImagePositionType = 'left';
14
15
  this.horizontalImageSizeType = 'one-third';
15
16
  this.ariaLabelText = undefined;
16
- this.cardTypeState = undefined;
17
- this.headerTypeState = undefined;
17
+ this.layoutState = undefined;
18
18
  }
19
19
  /**
20
- * Watch for changes to the `cardType` property for validation purposes.
20
+ * Watch for changes to the `layout` property for validation purposes.
21
21
  *
22
- * If the user input doesn't match one of the array values then `cardType` will be set to its default (`basic`).
23
- * If a match is found in one of the array values then `cardType` will be set to the matching array key value.
22
+ * If the user input doesn't match one of the array values then `layout` will be set to its default (`vertical`).
23
+ * If a match is found in one of the array values then `layoutState` will be set to the matching array key value.
24
24
  */
25
- validateCardType() {
26
- const isValid = validateValueAgainstArray(this.cardType, CardTypes);
27
- if (isValid) {
28
- this.cardTypeState = this.cardType;
29
- } else {
30
- this.cardTypeState = this.warnDefaultCardType();
25
+ validateLayout() {
26
+ if (this.layout) {
27
+ const isValid = validateValueAgainstArray(this.layout, Layouts);
28
+ if (isValid) {
29
+ this.layoutState = this.layout;
30
+ } else {
31
+ this.warnDefaultLayout();
32
+ this.layoutState = 'vertical';
33
+ }
31
34
  }
32
35
  }
33
36
  /**
34
- * Watch for changes to the `headerType` property for validation purposes.
37
+ * Watch for changes to the `headerColour` property for validation purposes.
35
38
  *
36
- * If the user input doesn't match one of the array values then `headerType` will be set to its default (`default`).
37
- * If a match is found in one of the array values then `headerType` will be set to the matching array key value.
39
+ * If the user input doesn't match one of the array values then `headerColour` will be kept empty ('').
40
+ * If a match is found in one of the array values then `headerColour` will be set to the matching array key value.
38
41
  */
39
- validateHeaderType() {
40
- const isValid = validateValueAgainstArray(this.headerType, HeaderTypes);
41
- if (isValid) {
42
- this.headerTypeState = this.headerType;
43
- } else {
44
- this.headerTypeState = this.warnDefaultHeaderType();
42
+ validateHeaderColour() {
43
+ if (this.headerColour) {
44
+ const isValid = validateValueAgainstArray(this.headerColour, HeaderColours);
45
+ if (!isValid) {
46
+ this.warnDefaultHeaderColour();
47
+ this.headerColour = '';
48
+ }
45
49
  }
46
50
  }
47
51
  /**
48
- * Print the invalid `cardType` prop warning message.
49
- * @returns default type (basic).
52
+ * Print the invalid `layout` prop warning message.
50
53
  */
51
- warnDefaultCardType() {
54
+ warnDefaultLayout() {
52
55
  const message = new ConsoleMessageClass();
53
56
  message
54
57
  .addDesignSystemTag()
55
- .addMonospaceText(' card-type ')
58
+ .addMonospaceText(' layout ')
56
59
  .addRegularText('on')
57
60
  .addMonospaceText(' <ontario-card> ')
58
- .addRegularText('was set to an invalid type; only')
59
- .addMonospaceText(' basic, image, label, horizontal ')
60
- .addRegularText('are supported. The default type')
61
- .addMonospaceText(' basic ')
61
+ .addRegularText('was set to an invalid layout; only ')
62
+ .addMonospaceText(printArray([...Layouts]))
63
+ .addRegularText(' are supported. The default layout')
64
+ .addMonospaceText(' vertical ')
62
65
  .addRegularText('is assumed.')
63
66
  .printMessage();
64
- return 'basic';
65
67
  }
66
68
  /**
67
- * Print the invalid `headerType` prop warning message.
68
- * @returns default type (default).
69
+ * Print the invalid `headerColour` prop warning message.
69
70
  */
70
- warnDefaultHeaderType() {
71
+ warnDefaultHeaderColour() {
71
72
  const message = new ConsoleMessageClass();
72
73
  message
73
74
  .addDesignSystemTag()
74
- .addMonospaceText(' header-type ')
75
+ .addMonospaceText(' header-colour ')
75
76
  .addRegularText('on')
76
77
  .addMonospaceText(' <ontario-card> ')
77
- .addRegularText('was set to an invalid type; only')
78
- .addMonospaceText(' default, light, dark')
79
- .addRegularText('are supported. The default type')
80
- .addMonospaceText(' default ')
81
- .addRegularText('is assumed.')
78
+ .addRegularText('was set to an invalid colour; only ')
79
+ .addMonospaceText(printArray([...HeaderColours]))
80
+ .addRegularText(' are supported. ')
81
+ .addRegularText('No colour is assumed as the default.')
82
82
  .printMessage();
83
- return 'default';
84
83
  }
85
84
  /**
86
- * @returns the classes of the ontario cards based off the `cardType` and `headerType`.
85
+ * Returns the top level classes of the card.
86
+ *
87
+ * @returns {string}
87
88
  */
88
- getClass() {
89
+ getCardClasses() {
89
90
  const baseClass =
90
- this.cardTypeState === 'horizontal'
91
- ? `ontario-card ontario-card__card-type--horizontal ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`
92
- : `ontario-card ontario-card__header-type--${this.headerTypeState} ontario-card__card-type--${this.cardTypeState}`;
91
+ this.layoutState === 'horizontal'
92
+ ? `ontario-card ontario-card__card-type--${this.layoutState} ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`
93
+ : `ontario-card ontario-card__card-type--basic ontario-card--position-${this.layoutState}`;
93
94
  const descriptionClass = this.description ? '' : ' ontario-card__description-false';
94
- return `${baseClass}${descriptionClass}`;
95
+ const backgroundClass =
96
+ this.headerColour && !this.description ? `ontario-card__background--${this.headerColour}` : '';
97
+ return `${baseClass} ${descriptionClass} ${backgroundClass}`.trim();
95
98
  }
99
+ /**
100
+ * Returns the heading classes of the card.
101
+ *
102
+ * @returns {string}
103
+ */
104
+ getCardHeadingClasses() {
105
+ const baseClass = 'ontario-card__heading';
106
+ const backgroundClass =
107
+ this.headerColour && validateValueAgainstArray(this.headerColour, HeaderColours)
108
+ ? `ontario-card__heading--${this.headerColour}`
109
+ : '';
110
+ return `${baseClass} ${backgroundClass}`.trim();
111
+ }
112
+ /**
113
+ * Returns the url that the card links to.
114
+ *
115
+ * @returns {string}
116
+ */
96
117
  getHref() {
97
118
  return this.cardLink ? this.cardLink : '#';
98
119
  }
120
+ /**
121
+ * Component life cycle hook.
122
+ *
123
+ * https://stenciljs.com/docs/component-lifecycle#connectedcallback
124
+ */
99
125
  componentWillLoad() {
100
- this.validateCardType();
101
- this.validateHeaderType();
126
+ this.validateLayout();
127
+ this.validateHeaderColour();
102
128
  }
103
129
  render() {
104
130
  return h(
105
131
  'li',
106
- { key: '606e74cea5d81cd31b355ffb1a71cf7450126cf4', class: this.getClass() },
132
+ { key: 'e63b893390ea13ee21a2d47f7ef6c9b403c4d044', class: this.getCardClasses() },
107
133
  this.image &&
108
134
  h(
109
135
  'div',
@@ -117,16 +143,16 @@ export class OntarioCard {
117
143
  h(
118
144
  'div',
119
145
  {
120
- key: '7d71d14690d4e75dcf1e4ef5c0198183b27e4b39',
146
+ key: 'b6f0a2218840a76baf9c803c3f155733a00ee029',
121
147
  class: `ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`,
122
148
  },
123
149
  h(
124
150
  'h2',
125
- { key: '4f6a337efa3986a5023f3c17e869f072aaef0e4f', class: 'ontario-card__heading' },
151
+ { key: '063dc227db00f3faecec029dc82f5478910b65be', class: this.getCardHeadingClasses() },
126
152
  h(
127
153
  'a',
128
154
  {
129
- 'key': '6efece75daafc95e43dca997e895dc88cab9194c',
155
+ 'key': 'debb40036a708ad1a1852a85fa35db2d5f1e23cc',
130
156
  'href': this.getHref(),
131
157
  'aria-label': this.ariaLabelText,
132
158
  },
@@ -228,53 +254,52 @@ export class OntarioCard {
228
254
  attribute: 'card-link',
229
255
  reflect: false,
230
256
  },
231
- cardType: {
257
+ layout: {
232
258
  type: 'string',
233
259
  mutable: false,
234
260
  complexType: {
235
- original: 'CardType',
236
- resolved: '"basic" | "horizontal" | "image" | "title"',
261
+ original: 'Layout',
262
+ resolved: '"horizontal" | "vertical" | undefined',
237
263
  references: {
238
- CardType: {
264
+ Layout: {
239
265
  location: 'import',
240
266
  path: './ontario-card-types',
241
- id: 'src/components/ontario-card/ontario-card-types.tsx::CardType',
267
+ id: 'src/components/ontario-card/ontario-card-types.tsx::Layout',
242
268
  },
243
269
  },
244
270
  },
245
271
  required: false,
246
- optional: false,
272
+ optional: true,
247
273
  docs: {
248
274
  tags: [],
249
- text: "The type of card to render.\n\nIf no type is passed, it will default to 'basic'.",
275
+ text: "The layout oritnetation of the card.\n\nIf no type is passed, it will default to 'vertical'.",
250
276
  },
251
- attribute: 'card-type',
277
+ attribute: 'layout',
252
278
  reflect: false,
253
- defaultValue: "'basic'",
279
+ defaultValue: "'vertical'",
254
280
  },
255
- headerType: {
281
+ headerColour: {
256
282
  type: 'string',
257
283
  mutable: false,
258
284
  complexType: {
259
- original: 'HeaderType',
260
- resolved: '"dark" | "default" | "light"',
285
+ original: 'HeaderColour',
286
+ resolved: 'string | undefined',
261
287
  references: {
262
- HeaderType: {
288
+ HeaderColour: {
263
289
  location: 'import',
264
290
  path: './ontario-card-types',
265
- id: 'src/components/ontario-card/ontario-card-types.tsx::HeaderType',
291
+ id: 'src/components/ontario-card/ontario-card-types.tsx::HeaderColour',
266
292
  },
267
293
  },
268
294
  },
269
295
  required: false,
270
- optional: false,
296
+ optional: true,
271
297
  docs: {
272
298
  tags: [],
273
- text: "The type of header to render.\n\nIf no type is passed, it will default to 'default'.",
299
+ text: "Set the card's header colour.\n\nThis is optional.",
274
300
  },
275
- attribute: 'header-type',
301
+ attribute: 'header-colour',
276
302
  reflect: false,
277
- defaultValue: "'default'",
278
303
  },
279
304
  horizontalImagePositionType: {
280
305
  type: 'string',
@@ -355,8 +380,7 @@ export class OntarioCard {
355
380
  }
356
381
  static get states() {
357
382
  return {
358
- cardTypeState: {},
359
- headerTypeState: {},
383
+ layoutState: {},
360
384
  };
361
385
  }
362
386
  static get elementRef() {
@@ -365,12 +389,12 @@ export class OntarioCard {
365
389
  static get watchers() {
366
390
  return [
367
391
  {
368
- propName: 'cardType',
369
- methodName: 'validateCardType',
392
+ propName: 'layout',
393
+ methodName: 'validateLayout',
370
394
  },
371
395
  {
372
- propName: 'headerType',
373
- methodName: 'validateHeaderType',
396
+ propName: 'headerColour',
397
+ methodName: 'validateHeaderColour',
374
398
  },
375
399
  ];
376
400
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ontario-card.js","sourceRoot":"","sources":["../../../src/components/ontario-card/ontario-card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAEN,SAAS,EAET,WAAW,GAGX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAOlF,MAAM,OAAO,WAAW;;;;;;wBA2CM,OAAO;0BAOH,SAAS;2CAkB0B,MAAM;uCAkBd,WAAW;;;;;IAsBvE;;;;;OAKG;IAEH,gBAAgB;QACf,MAAM,OAAO,GAAG,yBAAyB,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACpE,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,GAAG,IAA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C,KAAK,CACR,CACA;gBACJ,IAAI,CAAC,WAAW,IAAI,CACpB,WAAK,KAAK,EAAC,2BAA2B;oBACrC,aAAI,IAAI,CAAC,WAAW,CAAK,CACpB,CACN,CACI,CACF,CACL,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACD","sourcesContent":["import { Component, Prop, Element, h, State, Watch } from '@stencil/core';\nimport {\n\tCardType,\n\tCardTypes,\n\tHeaderType,\n\tHeaderTypes,\n\tHorizontalImagePositionType,\n\tHorizontalImageSizeType,\n} from './ontario-card-types';\nimport { validateValueAgainstArray } from '../../utils/validation/validation-functions';\nimport { ConsoleMessageClass } from '../../utils/console-message/console-message';\n\n@Component({\n\ttag: 'ontario-card',\n\tstyleUrl: 'ontario-card.scss',\n\tshadow: true,\n})\nexport class OntarioCard {\n\t@Element() host: HTMLElement;\n\n\t/**\n\t * Text to be displayed within the header.\n\t *\n\t * @example\n\t *\t<ontario-card\n\t *\t\theader-type=\"dark\"\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\tdescription=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t */\n\t@Prop() label: string;\n\n\t/**\n\t * Image to be displayed within the card image container.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() image?: string;\n\n\t/**\n\t * Text to be displayed within the card description container.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() description?: string;\n\n\t/**\n\t * Action link for when the card is clicked.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() cardLink?: string;\n\n\t/**\n\t * The type of card to render.\n\t *\n\t * If no type is passed, it will default to 'basic'.\n\t *\n\t */\n\t@Prop() cardType: CardType = 'basic';\n\n\t/**\n\t * The type of header to render.\n\t *\n\t * If no type is passed, it will default to 'default'.\n\t */\n\t@Prop() headerType: HeaderType = 'default';\n\n\t/**\n\t * The position of the image when the card-type is set to 'horizontal'.\n\t *\n\t * This prop is only necessry when the card-type is set to 'horizontal'.\n\t *\n\t * @example\n\t * \t<ontario-card\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\timage=\"https://picsum.photos/200/300\"\n\t *\t\thorizontal-image-position-type=\"left\"\n\t *\t\thorizontal-image-size-type=\"one-fourth\"\n\t *\t description=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t *\t</ontario-card>\n\t */\n\t@Prop() horizontalImagePositionType?: HorizontalImagePositionType = 'left';\n\n\t/**\n\t * The size of the image when the card-type is set to 'horizontal'.\n\t *\n\t * This prop is only necessry when the card-type is set to 'horizontal'.\n\t *\n\t * @example\n\t * \t<ontario-card\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\timage=\"https://picsum.photos/200/300\"\n\t *\t\thorizontal-image-position-type=\"left\"\n\t *\t\thorizontal-image-size-type=\"one-fourth\"\n\t *\t description=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t *\t</ontario-card>\n\t */\n\t@Prop() horizontalImageSizeType?: HorizontalImageSizeType = 'one-third';\n\n\t/**\n\t * Provides more context as to what the card interaction is doing. This should only be used for accessibility purposes, if the card interaction requires more * * description than what the text provides.\n\t *\n\t * This is optional.\n\t *\n\t */\n\t@Prop() ariaLabelText?: string;\n\n\t/**\n\t * Mutable variable, for internal use only.\n\t * Set the card's type depending on validation result.\n\t */\n\t@State() private cardTypeState: string;\n\n\t/**\n\t * Mutable variable, for internal use only.\n\t * Set the card's header type depending on validation result.\n\t */\n\t@State() private headerTypeState: string;\n\n\t/**\n\t * Watch for changes to the `cardType` property for validation purposes.\n\t *\n\t * If the user input doesn't match one of the array values then `cardType` will be set to its default (`basic`).\n\t * If a match is found in one of the array values then `cardType` will be set to the matching array key value.\n\t */\n\t@Watch('cardType')\n\tvalidateCardType() {\n\t\tconst isValid = validateValueAgainstArray(this.cardType, CardTypes);\n\t\tif (isValid) {\n\t\t\tthis.cardTypeState = this.cardType;\n\t\t} else {\n\t\t\tthis.cardTypeState = this.warnDefaultCardType();\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `headerType` property for validation purposes.\n\t *\n\t * If the user input doesn't match one of the array values then `headerType` will be set to its default (`default`).\n\t * If a match is found in one of the array values then `headerType` will be set to the matching array key value.\n\t */\n\t@Watch('headerType')\n\tvalidateHeaderType() {\n\t\tconst isValid = validateValueAgainstArray(this.headerType, HeaderTypes);\n\t\tif (isValid) {\n\t\t\tthis.headerTypeState = this.headerType;\n\t\t} else {\n\t\t\tthis.headerTypeState = this.warnDefaultHeaderType();\n\t\t}\n\t}\n\n\t/**\n\t * Print the invalid `cardType` prop warning message.\n\t * @returns default type (basic).\n\t */\n\tprivate warnDefaultCardType(): CardType {\n\t\tconst message = new ConsoleMessageClass();\n\t\tmessage\n\t\t\t.addDesignSystemTag()\n\t\t\t.addMonospaceText(' card-type ')\n\t\t\t.addRegularText('on')\n\t\t\t.addMonospaceText(' <ontario-card> ')\n\t\t\t.addRegularText('was set to an invalid type; only')\n\t\t\t.addMonospaceText(' basic, image, label, horizontal ')\n\t\t\t.addRegularText('are supported. The default type')\n\t\t\t.addMonospaceText(' basic ')\n\t\t\t.addRegularText('is assumed.')\n\t\t\t.printMessage();\n\t\treturn 'basic';\n\t}\n\n\t/**\n\t * Print the invalid `headerType` prop warning message.\n\t * @returns default type (default).\n\t */\n\tprivate warnDefaultHeaderType(): HeaderType {\n\t\tconst message = new ConsoleMessageClass();\n\t\tmessage\n\t\t\t.addDesignSystemTag()\n\t\t\t.addMonospaceText(' header-type ')\n\t\t\t.addRegularText('on')\n\t\t\t.addMonospaceText(' <ontario-card> ')\n\t\t\t.addRegularText('was set to an invalid type; only')\n\t\t\t.addMonospaceText(' default, light, dark')\n\t\t\t.addRegularText('are supported. The default type')\n\t\t\t.addMonospaceText(' default ')\n\t\t\t.addRegularText('is assumed.')\n\t\t\t.printMessage();\n\t\treturn 'default';\n\t}\n\n\t/**\n\t * @returns the classes of the ontario cards based off the `cardType` and `headerType`.\n\t */\n\tprivate getClass() {\n\t\tconst baseClass =\n\t\t\tthis.cardTypeState === 'horizontal'\n\t\t\t\t? `ontario-card ontario-card__card-type--horizontal ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`\n\t\t\t\t: `ontario-card ontario-card__header-type--${this.headerTypeState} ontario-card__card-type--${this.cardTypeState}`;\n\n\t\tconst descriptionClass = this.description ? '' : ' ontario-card__description-false';\n\n\t\treturn `${baseClass}${descriptionClass}`;\n\t}\n\n\tprivate getHref() {\n\t\treturn this.cardLink ? this.cardLink : '#';\n\t}\n\n\tcomponentWillLoad() {\n\t\tthis.validateCardType();\n\t\tthis.validateHeaderType();\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<li class={this.getClass()}>\n\t\t\t\t{this.image && (\n\t\t\t\t\t<div class=\"ontario-card__image-container\">\n\t\t\t\t\t\t<a href={this.getHref()} aria-label={this.ariaLabelText}>\n\t\t\t\t\t\t\t<img class=\"ontario-card__image\" src={this.image} />\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<div class={`ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`}>\n\t\t\t\t\t<h2 class=\"ontario-card__heading\">\n\t\t\t\t\t\t<a href={this.getHref()} aria-label={this.ariaLabelText}>\n\t\t\t\t\t\t\t{this.label}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</h2>\n\t\t\t\t\t{this.description && (\n\t\t\t\t\t\t<div class=\"ontario-card__description\">\n\t\t\t\t\t\t\t<p>{this.description}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"ontario-card.js","sourceRoot":"","sources":["../../../src/components/ontario-card/ontario-card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAEN,aAAa,EAIb,OAAO,GACP,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAOtD,MAAM,OAAO,WAAW;;;;;;sBA2CG,UAAU;;2CAyBgC,MAAM;uCAkBd,WAAW;;;;IAgBvE;;;;;OAKG;IAEH,cAAc;QACb,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,OAAO,GAAG,yBAAyB,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAChE,IAAI,OAAO,EAAE,CAAC;gBACb,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBACzB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;YAC/B,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;;OAKG;IAEH,oBAAoB;QACnB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,OAAO,GAAG,yB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AAC,qBAAqB,EAAC,GAAG,EAAE,IAAI,CAAC,KAAK,GAAI,CACjD,CACC,CACN;YACD,4DAAK,KAAK,EAAE,gCAAgC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE,EAAE;gBACzF,2DAAI,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE;oBACtC,0DAAG,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,gBAAc,IAAI,CAAC,aAAa,IACrD,IAAI,CAAC,KAAK,CACR,CACA;gBACJ,IAAI,CAAC,WAAW,IAAI,CACpB,WAAK,KAAK,EAAC,2BAA2B;oBACrC,aAAI,IAAI,CAAC,WAAW,CAAK,CACpB,CACN,CACI,CACF,CACL,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACD","sourcesContent":["import { Component, Prop, Element, h, State, Watch } from '@stencil/core';\nimport {\n\tHeaderColour,\n\tHeaderColours,\n\tHorizontalImagePositionType,\n\tHorizontalImageSizeType,\n\tLayout,\n\tLayouts,\n} from './ontario-card-types';\nimport { validateValueAgainstArray } from '../../utils/validation/validation-functions';\nimport { ConsoleMessageClass } from '../../utils/console-message/console-message';\nimport { printArray } from '../../utils/helper/utils';\n\n@Component({\n\ttag: 'ontario-card',\n\tstyleUrl: 'ontario-card.scss',\n\tshadow: true,\n})\nexport class OntarioCard {\n\t@Element() host: HTMLElement;\n\n\t/**\n\t * Text to be displayed within the header.\n\t *\n\t * @example\n\t *\t<ontario-card\n\t *\t\theader-type=\"dark\"\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\tdescription=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t */\n\t@Prop() label: string;\n\n\t/**\n\t * Image to be displayed within the card image container.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() image?: string;\n\n\t/**\n\t * Text to be displayed within the card description container.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() description?: string;\n\n\t/**\n\t * Action link for when the card is clicked.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() cardLink?: string;\n\n\t/**\n\t * The layout oritnetation of the card.\n\t *\n\t * If no type is passed, it will default to 'vertical'.\n\t *\n\t */\n\t@Prop() layout?: Layout = 'vertical';\n\n\t/**\n\t * Set the card's header colour.\n\t *\n\t * This is optional.\n\t */\n\t@Prop() headerColour?: HeaderColour;\n\n\t/**\n\t * The position of the image when the card-type is set to 'horizontal'.\n\t *\n\t * This prop is only necessry when the card-type is set to 'horizontal'.\n\t *\n\t * @example\n\t * \t<ontario-card\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\timage=\"https://picsum.photos/200/300\"\n\t *\t\thorizontal-image-position-type=\"left\"\n\t *\t\thorizontal-image-size-type=\"one-fourth\"\n\t *\t description=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t *\t</ontario-card>\n\t */\n\t@Prop() horizontalImagePositionType?: HorizontalImagePositionType = 'left';\n\n\t/**\n\t * The size of the image when the card-type is set to 'horizontal'.\n\t *\n\t * This prop is only necessry when the card-type is set to 'horizontal'.\n\t *\n\t * @example\n\t * \t<ontario-card\n\t *\t\tcard-type=\"horizontal\"\n\t *\t\tlabel=\"Card Title 1\"\n\t *\t\timage=\"https://picsum.photos/200/300\"\n\t *\t\thorizontal-image-position-type=\"left\"\n\t *\t\thorizontal-image-size-type=\"one-fourth\"\n\t *\t description=\"Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum\"\n\t *\t>\n\t *\t</ontario-card>\n\t */\n\t@Prop() horizontalImageSizeType?: HorizontalImageSizeType = 'one-third';\n\n\t/**\n\t * Provides more context as to what the card interaction is doing. This should only be used for accessibility purposes, if the card interaction requires more * * description than what the text provides.\n\t *\n\t * This is optional.\n\t *\n\t */\n\t@Prop() ariaLabelText?: string;\n\n\t/**\n\t * Mutable variable, for internal use only.\n\t * Set the card's layout depending on validation result.\n\t */\n\t@State() private layoutState: string;\n\n\t/**\n\t * Watch for changes to the `layout` property for validation purposes.\n\t *\n\t * If the user input doesn't match one of the array values then `layout` will be set to its default (`vertical`).\n\t * If a match is found in one of the array values then `layoutState` will be set to the matching array key value.\n\t */\n\t@Watch('layout')\n\tvalidateLayout() {\n\t\tif (this.layout) {\n\t\t\tconst isValid = validateValueAgainstArray(this.layout, Layouts);\n\t\t\tif (isValid) {\n\t\t\t\tthis.layoutState = this.layout;\n\t\t\t} else {\n\t\t\t\tthis.warnDefaultLayout();\n\t\t\t\tthis.layoutState = 'vertical';\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Watch for changes to the `headerColour` property for validation purposes.\n\t *\n\t * If the user input doesn't match one of the array values then `headerColour` will be kept empty ('').\n\t * If a match is found in one of the array values then `headerColour` will be set to the matching array key value.\n\t */\n\t@Watch('headerColour')\n\tvalidateHeaderColour() {\n\t\tif (this.headerColour) {\n\t\t\tconst isValid = validateValueAgainstArray(this.headerColour, HeaderColours);\n\n\t\t\tif (!isValid) {\n\t\t\t\tthis.warnDefaultHeaderColour();\n\t\t\t\tthis.headerColour = '';\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Print the invalid `layout` prop warning message.\n\t */\n\tprivate warnDefaultLayout() {\n\t\tconst message = new ConsoleMessageClass();\n\t\tmessage\n\t\t\t.addDesignSystemTag()\n\t\t\t.addMonospaceText(' layout ')\n\t\t\t.addRegularText('on')\n\t\t\t.addMonospaceText(' <ontario-card> ')\n\t\t\t.addRegularText('was set to an invalid layout; only ')\n\t\t\t.addMonospaceText(printArray([...Layouts]))\n\t\t\t.addRegularText(' are supported. The default layout')\n\t\t\t.addMonospaceText(' vertical ')\n\t\t\t.addRegularText('is assumed.')\n\t\t\t.printMessage();\n\t}\n\n\t/**\n\t * Print the invalid `headerColour` prop warning message.\n\t */\n\tprivate warnDefaultHeaderColour() {\n\t\tconst message = new ConsoleMessageClass();\n\t\tmessage\n\t\t\t.addDesignSystemTag()\n\t\t\t.addMonospaceText(' header-colour ')\n\t\t\t.addRegularText('on')\n\t\t\t.addMonospaceText(' <ontario-card> ')\n\t\t\t.addRegularText('was set to an invalid colour; only ')\n\t\t\t.addMonospaceText(printArray([...HeaderColours]))\n\t\t\t.addRegularText(' are supported. ')\n\t\t\t.addRegularText('No colour is assumed as the default.')\n\t\t\t.printMessage();\n\t}\n\n\t/**\n\t * Returns the top level classes of the card.\n\t *\n\t * @returns {string}\n\t */\n\tprivate getCardClasses(): string {\n\t\tconst baseClass =\n\t\t\tthis.layoutState === 'horizontal'\n\t\t\t\t? `ontario-card ontario-card__card-type--${this.layoutState} ontario-card__image-${this.horizontalImagePositionType} ontario-card__image-size-${this.horizontalImageSizeType}`\n\t\t\t\t: `ontario-card ontario-card__card-type--basic ontario-card--position-${this.layoutState}`;\n\n\t\tconst descriptionClass = this.description ? '' : ' ontario-card__description-false';\n\n\t\tconst backgroundClass =\n\t\t\tthis.headerColour && !this.description ? `ontario-card__background--${this.headerColour}` : '';\n\n\t\treturn `${baseClass} ${descriptionClass} ${backgroundClass}`.trim();\n\t}\n\n\t/**\n\t * Returns the heading classes of the card.\n\t *\n\t * @returns {string}\n\t */\n\tprivate getCardHeadingClasses(): string {\n\t\tconst baseClass = 'ontario-card__heading';\n\n\t\tconst backgroundClass =\n\t\t\tthis.headerColour && validateValueAgainstArray(this.headerColour, HeaderColours)\n\t\t\t\t? `ontario-card__heading--${this.headerColour}`\n\t\t\t\t: '';\n\n\t\treturn `${baseClass} ${backgroundClass}`.trim();\n\t}\n\n\t/**\n\t * Returns the url that the card links to.\n\t *\n\t * @returns {string}\n\t */\n\tprivate getHref(): string {\n\t\treturn this.cardLink ? this.cardLink : '#';\n\t}\n\n\t/**\n\t * Component life cycle hook.\n\t *\n\t * https://stenciljs.com/docs/component-lifecycle#connectedcallback\n\t */\n\tcomponentWillLoad() {\n\t\tthis.validateLayout();\n\t\tthis.validateHeaderColour();\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<li class={this.getCardClasses()}>\n\t\t\t\t{this.image && (\n\t\t\t\t\t<div class=\"ontario-card__image-container\">\n\t\t\t\t\t\t<a href={this.getHref()} aria-label={this.ariaLabelText}>\n\t\t\t\t\t\t\t<img class=\"ontario-card__image\" src={this.image} />\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<div class={`ontario-card__text-container ${this.image ? 'ontario-card--image-true' : ''}`}>\n\t\t\t\t\t<h2 class={this.getCardHeadingClasses()}>\n\t\t\t\t\t\t<a href={this.getHref()} aria-label={this.ariaLabelText}>\n\t\t\t\t\t\t\t{this.label}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</h2>\n\t\t\t\t\t{this.description && (\n\t\t\t\t\t\t<div class=\"ontario-card__description\">\n\t\t\t\t\t\t\t<p>{this.description}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</li>\n\t\t);\n\t}\n}\n"]}
@@ -6,19 +6,29 @@ describe('ontario-card', () => {
6
6
  components: [OntarioCard],
7
7
  html: `<ontario-card></ontario-card>`,
8
8
  });
9
- expect(page.root).toEqualHtml(`
10
- <ontario-card>
11
- <mock:shadow-root>
12
- <li class="ontario-card ontario-card__card-type--basic ontario-card__header-type--default ontario-card__description-false">
13
- <div class="ontario-card__text-container">
14
- <h2 class="ontario-card__heading">
15
- <a href="#"></a>
16
- </h2>
17
- </div>
18
- </li>
19
- </mock:shadow-root>
20
- </ontario-card>
21
- `);
9
+ expect(page.root).toMatchSnapshot();
22
10
  });
11
+ it('should render a label', async () => {
12
+ const page = await newSpecPage({
13
+ components: [OntarioCard],
14
+ html: `<ontario-card label="Card Title 1"></ontario-card>`,
15
+ });
16
+ expect(page.root).toMatchSnapshot();
17
+ });
18
+ it('should render a header colour on the label', async () => {
19
+ const page = await newSpecPage({
20
+ components: [OntarioCard],
21
+ html: `<ontario-card label="Card Title 1" header-colour="sky"></ontario-card>`,
22
+ });
23
+ expect(page.root).toMatchSnapshot();
24
+ });
25
+ it('should render a description', async () => {
26
+ const page = await newSpecPage({
27
+ components: [OntarioCard],
28
+ html: `<ontario-card description="Lorem ipsum"></ontario-card>`,
29
+ });
30
+ expect(page.root).toMatchSnapshot();
31
+ });
32
+ // Don't think we can test images unless we point to a local path
23
33
  });
24
34
  //# sourceMappingURL=ontario-cards.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ontario-cards.spec.js","sourceRoot":"","sources":["../../../../src/components/ontario-card/test/ontario-cards.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACxB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,IAAI,EAAE,+BAA+B;SACrC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;;;;;KAY3B,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { OntarioCard } from '../ontario-card';\n\ndescribe('ontario-card', () => {\n\tit('renders', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioCard],\n\t\t\thtml: `<ontario-card></ontario-card>`,\n\t\t});\n\t\texpect(page.root).toEqualHtml(`\n <ontario-card>\n\t\t\t\t<mock:shadow-root>\n\t\t\t\t\t<li class=\"ontario-card ontario-card__card-type--basic ontario-card__header-type--default ontario-card__description-false\">\n\t\t\t\t\t\t<div class=\"ontario-card__text-container\">\n\t\t\t\t\t\t\t<h2 class=\"ontario-card__heading\">\n\t\t\t\t\t\t\t\t<a href=\"#\"></a>\n\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</li>\n\t\t\t\t</mock:shadow-root>\n </ontario-card>\n `);\n\t});\n});\n"]}
1
+ {"version":3,"file":"ontario-cards.spec.js","sourceRoot":"","sources":["../../../../src/components/ontario-card/test/ontario-cards.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACxB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,IAAI,EAAE,+BAA+B;SACrC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,IAAI,EAAE,oDAAoD;SAC1D,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC3D,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,IAAI,EAAE,wEAAwE;SAC9E,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,IAAI,EAAE,yDAAyD;SAC/D,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,iEAAiE;AAClE,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { OntarioCard } from '../ontario-card';\n\ndescribe('ontario-card', () => {\n\tit('renders', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioCard],\n\t\t\thtml: `<ontario-card></ontario-card>`,\n\t\t});\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n\n\tit('should render a label', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioCard],\n\t\t\thtml: `<ontario-card label=\"Card Title 1\"></ontario-card>`,\n\t\t});\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n\n\tit('should render a header colour on the label', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioCard],\n\t\t\thtml: `<ontario-card label=\"Card Title 1\" header-colour=\"sky\"></ontario-card>`,\n\t\t});\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n\n\tit('should render a description', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioCard],\n\t\t\thtml: `<ontario-card description=\"Lorem ipsum\"></ontario-card>`,\n\t\t});\n\t\texpect(page.root).toMatchSnapshot();\n\t});\n\n\t// Don't think we can test images unless we point to a local path\n});\n"]}
@@ -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
  describe('ontario-date-input', () => {
4
5
  it('renders deafult state', async () => {
5
6
  const page = await newSpecPage({
@@ -117,4 +118,61 @@ describe('ontario-date-input', () => {
117
118
  `);
118
119
  });
119
120
  });
121
+ describe('date-validation-utils', () => {
122
+ it('is invalid year value - undefined string', () => {
123
+ // Note: Type system doesn't like `undefined` as `any` lets us force it for testing purposes
124
+ const value = undefined;
125
+ const isInvalidYearResult = isInvalidYear(value);
126
+ expect(isInvalidYearResult).toEqual(true);
127
+ });
128
+ it('is invalid year value - null string', () => {
129
+ // Note: Type system doesn't like `null` as `any` lets us force it for testing purposes
130
+ const value = null;
131
+ const isInvalidYearResult = isInvalidYear(value);
132
+ expect(isInvalidYearResult).toEqual(true);
133
+ });
134
+ it('is invalid year value - empty string', () => {
135
+ const value = ''; // Empty string
136
+ const isInvalidYearResult = isInvalidYear(value);
137
+ expect(isInvalidYearResult).toEqual(true);
138
+ });
139
+ it('is invalid year value - written out number', () => {
140
+ const value = 'two-thousand';
141
+ const isInvalidYearResult = isInvalidYear(value);
142
+ expect(isInvalidYearResult).toEqual(true);
143
+ });
144
+ it('is valid year value', () => {
145
+ const value = '2000';
146
+ const isValidYear = !isInvalidYear(value);
147
+ expect(isValidYear).toEqual(true);
148
+ });
149
+ it('is valid year when in range', () => {
150
+ const value = '2000';
151
+ const minYear = 1;
152
+ const maxYear = 9999;
153
+ const isValidYear = !isInvalidYear(value, minYear, maxYear);
154
+ expect(isValidYear).toEqual(true);
155
+ });
156
+ it('is valid year when in range but is minYear', () => {
157
+ const value = '2000';
158
+ const minYear = 2000;
159
+ const maxYear = 9999;
160
+ const isValidYear = !isInvalidYear(value, minYear, maxYear);
161
+ expect(isValidYear).toEqual(true);
162
+ });
163
+ it('is valid year when in range but is maxYear', () => {
164
+ const value = '2000';
165
+ const minYear = 1;
166
+ const maxYear = 2000;
167
+ const isValidYear = !isInvalidYear(value, minYear, maxYear);
168
+ expect(isValidYear).toEqual(true);
169
+ });
170
+ it('is invalid year when out of range', () => {
171
+ const value = '2000';
172
+ const minYear = 1;
173
+ const maxYear = 1999;
174
+ const isValidYear = !isInvalidYear(value, minYear, maxYear);
175
+ expect(isValidYear).toEqual(false);
176
+ });
177
+ });
120
178
  //# sourceMappingURL=ontario-date-input.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ontario-date-input.spec.js","sourceRoot":"","sources":["../../../../src/components/ontario-date-input/test/ontario-date-input.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,gBAAgB,CAAC;YAC9B,IAAI,EAAE,sFAAsF;SAC5F,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgD3B,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC9B,UAAU,EAAE,CAAC,gBAAgB,CAAC;YAC9B,IAAI,EAAE;;;;;;;;;;;IAWL;SACD,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0C7B,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { OntarioDateInput } from '../ontario-date-input';\n\ndescribe('ontario-date-input', () => {\n\tit('renders deafult state', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioDateInput],\n\t\t\thtml: `<ontario-date-input language=\"en\" element-id=\"date-id-example\"></ontario-date-input>`,\n\t\t});\n\t\texpect(page.root).toEqualHtml(`\n\t\t\t<ontario-date-input element-id=\"date-id-example\" language=\"en\">\n\t\t\t\t<mock:shadow-root>\n\t\t\t\t\t<div class=\"ontario-form-group\">\n\t\t\t\t\t\t<fieldset class=\"ontario-fieldset\" role=\"group\">\n\t\t\t\t\t\t\t<legend class=\"ontario-fieldset__legend\">\n\t\t\t\t\t\t\t\tExact date\n\t\t\t\t\t\t\t\t<span class=\"ontario-label__flag\">\n\t\t\t\t\t\t\t\t\t(optional)\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</legend>\n\t\t\t\t\t\t\t<div class=\"ontario-error-messaging ontario-error__hidden\" role=\"alert\">\n\t\t\t\t\t\t\t\t<ontario-icon-alert-error></ontario-icon-alert-error>\n\t\t\t\t\t\t\t\t<div class=\"ontario-error-messaging__content\"></div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class=\"ontario-date__group\">\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"year-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tYear\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(1 or 2 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"year-date-id-example\" inputmode=\"numeric\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"month-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tMonth\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(1 or 2 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"month-date-id-example\" inputmode=\"numeric\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"day-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tDay\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(4 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"day-date-id-example\" inputmode=\"numeric\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</fieldset>\n\t\t\t\t\t</div>\n\t\t\t\t</mock:shadow-root>\n\t\t\t</ontario-date-input>\n `);\n\t});\n\n\tit('should render custom prop', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioDateInput],\n\t\t\thtml: `\n\t\t\t\t<ontario-date-input\n\t\t\t\t\telement-id=\"date-id-example\"\n\t\t\t\t\tplaceholder='{ \"day\": \"D\", \"month\": \"M\", \"year\": \"YY\" }'\n\t\t\t\t\tmin-year=\"500\"\n\t\t\t\t\tmax-year=\"1000\"\n\t\t\t\t\trequired=\"true\"\n\t\t\t\t\thint-text=\"Example 1990 12\"\n\t\t\t\t\tdate-options='[\"month\", \"year\"]'\n\t\t\t\t\tcaption='{ \"captionText\": \"Enter Date\", \"captionType\": \"default\" }'\n\t\t\t\t></ontario-date-input>\n\t\t\t`,\n\t\t});\n\n\t\texpect(page.root).toEqualHtml(`\n\t\t\t<ontario-date-input element-id=\"date-id-example\" caption=\"{ &quot;captionText&quot;: &quot;Enter Date&quot;, &quot;captionType&quot;: &quot;default&quot; }\" date-options=\"[&quot;month&quot;, &quot;year&quot;]\" hint-text=\"Example 1990 12\" max-year=\"1000\" min-year=\"500\" placeholder=\"{ &quot;day&quot;: &quot;D&quot;, &quot;month&quot;: &quot;M&quot;, &quot;year&quot;: &quot;YY&quot; }\" required=\"true\">\n\t\t\t\t<mock:shadow-root>\n\t\t\t\t\t<div class=\"ontario-form-group\">\n\t\t\t\t\t\t<fieldset class=\"ontario-fieldset\" role=\"group\">\n\t\t\t\t\t\t\t<legend class=\"ontario-fieldset__legend\">\n\t\t\t\t\t\t\t\tEnter Date\n\t\t\t\t\t\t\t\t<span class=\"ontario-label__flag\">\n\t\t\t\t\t\t\t\t\t(required)\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</legend>\n\t\t\t\t\t\t\t<p class=\"ontario-hint\" id=\"date-input-hint-date-id-example\">\n\t\t\t\t\t\t\t\tExample 1990 12\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<div class=\"ontario-error-messaging ontario-error__hidden\" role=\"alert\">\n\t\t\t\t\t\t\t\t<ontario-icon-alert-error></ontario-icon-alert-error>\n\t\t\t\t\t\t\t\t<div class=\"ontario-error-messaging__content\"></div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class=\"ontario-date__group\">\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"year-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tYear\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(1 or 2 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"year-date-id-example\" inputmode=\"numeric\" placeholder=\"YY\" required=\"\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"month-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tMonth\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(1 or 2 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"month-date-id-example\" inputmode=\"numeric\" placeholder=\"M\" required=\"\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</fieldset>\n\t\t\t\t\t</div>\n\t\t\t\t</mock:shadow-root>\n\t\t\t</ontario-date-input>\n\t\t`);\n\t});\n});\n"]}
1
+ {"version":3,"file":"ontario-date-input.spec.js","sourceRoot":"","sources":["../../../../src/components/ontario-date-input/test/ontario-date-input.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,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AM,OAAO,GAAG,IAAI,CAAC;QAErB,MAAM,WAAW,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACrD,MAAM,KAAK,GAAG,MAAM,CAAC;QACrB,MAAM,OAAO,GAAG,CAAC,CAAC;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC;QAErB,MAAM,WAAW,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC;QACrB,MAAM,OAAO,GAAG,CAAC,CAAC;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC;QAErB,MAAM,WAAW,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5D,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { OntarioDateInput } from '../ontario-date-input';\nimport { isInvalidYear } from '../utils';\n\ndescribe('ontario-date-input', () => {\n\tit('renders deafult state', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioDateInput],\n\t\t\thtml: `<ontario-date-input language=\"en\" element-id=\"date-id-example\"></ontario-date-input>`,\n\t\t});\n\t\texpect(page.root).toEqualHtml(`\n\t\t\t<ontario-date-input element-id=\"date-id-example\" language=\"en\">\n\t\t\t\t<mock:shadow-root>\n\t\t\t\t\t<div class=\"ontario-form-group\">\n\t\t\t\t\t\t<fieldset class=\"ontario-fieldset\" role=\"group\">\n\t\t\t\t\t\t\t<legend class=\"ontario-fieldset__legend\">\n\t\t\t\t\t\t\t\tExact date\n\t\t\t\t\t\t\t\t<span class=\"ontario-label__flag\">\n\t\t\t\t\t\t\t\t\t(optional)\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</legend>\n\t\t\t\t\t\t\t<div class=\"ontario-error-messaging ontario-error__hidden\" role=\"alert\">\n\t\t\t\t\t\t\t\t<ontario-icon-alert-error></ontario-icon-alert-error>\n\t\t\t\t\t\t\t\t<div class=\"ontario-error-messaging__content\"></div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class=\"ontario-date__group\">\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"year-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tYear\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(1 or 2 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"year-date-id-example\" inputmode=\"numeric\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"month-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tMonth\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(1 or 2 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"month-date-id-example\" inputmode=\"numeric\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"day-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tDay\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(4 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"day-date-id-example\" inputmode=\"numeric\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</fieldset>\n\t\t\t\t\t</div>\n\t\t\t\t</mock:shadow-root>\n\t\t\t</ontario-date-input>\n `);\n\t});\n\n\tit('should render custom prop', async () => {\n\t\tconst page = await newSpecPage({\n\t\t\tcomponents: [OntarioDateInput],\n\t\t\thtml: `\n\t\t\t\t<ontario-date-input\n\t\t\t\t\telement-id=\"date-id-example\"\n\t\t\t\t\tplaceholder='{ \"day\": \"D\", \"month\": \"M\", \"year\": \"YY\" }'\n\t\t\t\t\tmin-year=\"500\"\n\t\t\t\t\tmax-year=\"1000\"\n\t\t\t\t\trequired=\"true\"\n\t\t\t\t\thint-text=\"Example 1990 12\"\n\t\t\t\t\tdate-options='[\"month\", \"year\"]'\n\t\t\t\t\tcaption='{ \"captionText\": \"Enter Date\", \"captionType\": \"default\" }'\n\t\t\t\t></ontario-date-input>\n\t\t\t`,\n\t\t});\n\n\t\texpect(page.root).toEqualHtml(`\n\t\t\t<ontario-date-input element-id=\"date-id-example\" caption=\"{ &quot;captionText&quot;: &quot;Enter Date&quot;, &quot;captionType&quot;: &quot;default&quot; }\" date-options=\"[&quot;month&quot;, &quot;year&quot;]\" hint-text=\"Example 1990 12\" max-year=\"1000\" min-year=\"500\" placeholder=\"{ &quot;day&quot;: &quot;D&quot;, &quot;month&quot;: &quot;M&quot;, &quot;year&quot;: &quot;YY&quot; }\" required=\"true\">\n\t\t\t\t<mock:shadow-root>\n\t\t\t\t\t<div class=\"ontario-form-group\">\n\t\t\t\t\t\t<fieldset class=\"ontario-fieldset\" role=\"group\">\n\t\t\t\t\t\t\t<legend class=\"ontario-fieldset__legend\">\n\t\t\t\t\t\t\t\tEnter Date\n\t\t\t\t\t\t\t\t<span class=\"ontario-label__flag\">\n\t\t\t\t\t\t\t\t\t(required)\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</legend>\n\t\t\t\t\t\t\t<p class=\"ontario-hint\" id=\"date-input-hint-date-id-example\">\n\t\t\t\t\t\t\t\tExample 1990 12\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<div class=\"ontario-error-messaging ontario-error__hidden\" role=\"alert\">\n\t\t\t\t\t\t\t\t<ontario-icon-alert-error></ontario-icon-alert-error>\n\t\t\t\t\t\t\t\t<div class=\"ontario-error-messaging__content\"></div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class=\"ontario-date__group\">\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"year-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tYear\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(1 or 2 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"year-date-id-example\" inputmode=\"numeric\" placeholder=\"YY\" required=\"\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"ontario-date__group-input\">\n\t\t\t\t\t\t\t\t\t<label htmlfor=\"month-date-id-example\">\n\t\t\t\t\t\t\t\t\t\tMonth\n\t\t\t\t\t\t\t\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t\t\t\t\t\t\t\t(1 or 2 digits)\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<input aria-describedby=\"date-input-hint-date-id-example\" class=\"ontario-input ontario-input--4-char-width\" id=\"month-date-id-example\" inputmode=\"numeric\" placeholder=\"M\" required=\"\" type=\"text\">\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</fieldset>\n\t\t\t\t\t</div>\n\t\t\t\t</mock:shadow-root>\n\t\t\t</ontario-date-input>\n\t\t`);\n\t});\n});\n\ndescribe('date-validation-utils', () => {\n\tit('is invalid year value - undefined string', () => {\n\t\t// Note: Type system doesn't like `undefined` as `any` lets us force it for testing purposes\n\t\tconst value: any = undefined;\n\n\t\tconst isInvalidYearResult = isInvalidYear(value);\n\t\texpect(isInvalidYearResult).toEqual(true);\n\t});\n\n\tit('is invalid year value - null string', () => {\n\t\t// Note: Type system doesn't like `null` as `any` lets us force it for testing purposes\n\t\tconst value: any = null;\n\n\t\tconst isInvalidYearResult = isInvalidYear(value);\n\t\texpect(isInvalidYearResult).toEqual(true);\n\t});\n\n\tit('is invalid year value - empty string', () => {\n\t\tconst value = ''; // Empty string\n\n\t\tconst isInvalidYearResult = isInvalidYear(value);\n\t\texpect(isInvalidYearResult).toEqual(true);\n\t});\n\n\tit('is invalid year value - written out number', () => {\n\t\tconst value = 'two-thousand';\n\n\t\tconst isInvalidYearResult = isInvalidYear(value);\n\t\texpect(isInvalidYearResult).toEqual(true);\n\t});\n\n\tit('is valid year value', () => {\n\t\tconst value = '2000';\n\n\t\tconst isValidYear = !isInvalidYear(value);\n\t\texpect(isValidYear).toEqual(true);\n\t});\n\n\tit('is valid year when in range', () => {\n\t\tconst value = '2000';\n\t\tconst minYear = 1;\n\t\tconst maxYear = 9999;\n\n\t\tconst isValidYear = !isInvalidYear(value, minYear, maxYear);\n\t\texpect(isValidYear).toEqual(true);\n\t});\n\n\tit('is valid year when in range but is minYear', () => {\n\t\tconst value = '2000';\n\t\tconst minYear = 2000;\n\t\tconst maxYear = 9999;\n\n\t\tconst isValidYear = !isInvalidYear(value, minYear, maxYear);\n\t\texpect(isValidYear).toEqual(true);\n\t});\n\n\tit('is valid year when in range but is maxYear', () => {\n\t\tconst value = '2000';\n\t\tconst minYear = 1;\n\t\tconst maxYear = 2000;\n\n\t\tconst isValidYear = !isInvalidYear(value, minYear, maxYear);\n\t\texpect(isValidYear).toEqual(true);\n\t});\n\n\tit('is invalid year when out of range', () => {\n\t\tconst value = '2000';\n\t\tconst minYear = 1;\n\t\tconst maxYear = 1999;\n\n\t\tconst isValidYear = !isInvalidYear(value, minYear, maxYear);\n\t\texpect(isValidYear).toEqual(false);\n\t});\n});\n"]}
@@ -27,15 +27,25 @@ const isInvalidMonth = (value) => {
27
27
  const month = Number(value);
28
28
  return month < MONTH_MIN_VALUE || month > MONTH_MAX_VALUE;
29
29
  };
30
- /*
31
- * Year field should be a number, not negative, at length at least 4 digits
30
+ /**
31
+ * Valid value year against minimum and maximum year range (defaulted if not provided.)
32
+ *
33
+ * Year field should be a number and not written out; it has no concept of positive and negative.
34
+ *
35
+ * Suggestion:
36
+ * - `< 0` B.C.E.
37
+ * - `>= 0` A.C.E.
38
+ *
39
+ * @param value value to check for validity
40
+ * @param minYear minimum valid year to validate against
41
+ * @param maxYear maximum valid year to validate against
32
42
  */
33
- const isInvalidYear = (value, minYear = YEAR_MIN_VALUE, maxYear = YEAR_MAX_VALUE) => {
43
+ export const isInvalidYear = (value, minYear = YEAR_MIN_VALUE, maxYear = YEAR_MAX_VALUE) => {
34
44
  if (!isNumber(value)) {
35
45
  return true;
36
46
  }
37
47
  const year = Number(value);
38
- return year <= minYear || year > maxYear;
48
+ return year < minYear || year > maxYear;
39
49
  };
40
50
  /**
41
51
  * Helper function to get error message for birthdate validation
@@ -1 +1 @@
1
- {"version":3,"file":"date-validation-utils.js","sourceRoot":"","sources":["../../../../src/components/ontario-date-input/utils/date-validation-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE;IACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE1B,OAAO,GAAG,GAAG,aAAa,IAAI,GAAG,GAAG,aAAa,CAAC;AACnD,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;IACxC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE5B,OAAO,KAAK,GAAG,eAAe,IAAI,KAAK,GAAG,eAAe,CAAC;AAC3D,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,UAAkB,cAAc,EAAE,UAAkB,cAAc,EAAE,EAAE;IAC3G,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE3B,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI,GAAG,OAAO,CAAC;AAC1C,CAAC,CAAC;AAaF;;GAEG;AACH,MA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,IAAI,CAAC;YACpB,WAAW,GAAG,IAAI,CAAC;QACpB,CAAC;aAAM,IAAI,aAAa,EAAE,CAAC;YAC1B,KAAK,GAAG,WAAW,CAAC;YACpB,WAAW,GAAG,IAAI,CAAC;QACpB,CAAC;aAAM,IAAI,cAAc,EAAE,CAAC;YAC3B,KAAK,GAAG,YAAY,CAAC;YACrB,YAAY,GAAG,IAAI,CAAC;QACrB,CAAC;aAAM,IAAI,YAAY,EAAE,CAAC;YACzB,KAAK,GAAG,UAAU,CAAC;YACnB,UAAU,GAAG,IAAI,CAAC;QACnB,CAAC;IACF,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AACvE,CAAC,CAAC","sourcesContent":["import {\n\tDAY_MIN_VALUE,\n\tDAY_MAX_VALUE,\n\tMONTH_MIN_VALUE,\n\tMONTH_MAX_VALUE,\n\tYEAR_MIN_VALUE,\n\tYEAR_MAX_VALUE,\n} from '../constants';\nimport { DateValidatorReturnType } from '../ontario-date-input-interface';\nimport { isNumber, isEmpty } from '../../../utils/helper/utils';\nimport { Translations } from '../../../translations';\n/*\n * Day field should be a number, not negative, no greater than “31”\n */\nconst isInvalidDay = (value: string) => {\n\tif (!isNumber(value)) {\n\t\treturn true;\n\t}\n\n\tconst day = Number(value);\n\n\treturn day < DAY_MIN_VALUE || day > DAY_MAX_VALUE;\n};\n\n/*\n * Month field should be a number, not negative, no greater than “12”\n */\nconst isInvalidMonth = (value: string) => {\n\tif (!isNumber(value)) {\n\t\treturn true;\n\t}\n\n\tconst month = Number(value);\n\n\treturn month < MONTH_MIN_VALUE || month > MONTH_MAX_VALUE;\n};\n\n/*\n * Year field should be a number, not negative, at length at least 4 digits\n */\nconst isInvalidYear = (value: string, minYear: number = YEAR_MIN_VALUE, maxYear: number = YEAR_MAX_VALUE) => {\n\tif (!isNumber(value)) {\n\t\treturn true;\n\t}\n\n\tconst year = Number(value);\n\n\treturn year <= minYear || year > maxYear;\n};\n\ntype GetDateErrorArg = {\n\tdayValue: string;\n\tmonthValue: string;\n\tyearValue: string;\n\terrorMessages: Translations['dateInput']['error']['en'];\n\tminYear?: number;\n\tmaxYear?: number;\n\tdayVisible: boolean;\n\tmonthVisible: boolean;\n\tyearVisible: boolean;\n};\n/**\n * Helper function to get error message for birthdate validation\n */\nexport const getDateErrorMessage = ({\n\tdayValue,\n\tmonthValue,\n\tyearValue,\n\terrorMessages,\n\tminYear,\n\tmaxYear,\n\tdayVisible,\n\tmonthVisible,\n\tyearVisible,\n}: GetDateErrorArg): DateValidatorReturnType => {\n\tconst {\n\t\temptyDay,\n\t\temptyMonth,\n\t\temptyYear,\n\t\temptyDayAndMonth,\n\t\temptyDayAndYear,\n\t\temptyMonthAndYear,\n\t\tinvalidDate,\n\t\tinvalidDay,\n\t\tinvalidMonth,\n\t\tinvalidYear,\n\t} = errorMessages;\n\n\tlet error = '';\n\tlet dayInvalid = false;\n\tlet monthInvalid = false;\n\tlet yearInvalid = false;\n\n\tconst isDayEmpty = dayVisible && isEmpty(dayValue);\n\tconst isMonthEmpty = monthVisible && isEmpty(monthValue);\n\tconst isYearEmpty = yearVisible && isEmpty(yearValue);\n\t/*\n\t * If one ore more fields are valid but others are empty:\n\t * 1 field empty:\n\t * Day as empty - “Enter the day.”\n\t * Month as empty - “Enter the month.”\n\t * Year as empty - “Enter the year.”\n\t * 2 fields empty:\n\t * Month and day empty - “Enter the month and day.”\n\t * Year and day empty - “Enter the year and day.”\n\t * Year and month empty - “Enter the year and month.”\n\t */\n\tif (isDayEmpty && isMonthEmpty && isYearEmpty) {\n\t\terror = invalidDate;\n\t\tdayInvalid = true;\n\t\tmonthInvalid = true;\n\t\tyearInvalid = true;\n\t} else if (isDayEmpty && isMonthEmpty) {\n\t\terror = emptyDayAndMonth;\n\t\tdayInvalid = true;\n\t\tmonthInvalid = true;\n\t} else if (isDayEmpty && isYearEmpty) {\n\t\terror = emptyDayAndYear;\n\t\tdayInvalid = true;\n\t\tyearInvalid = true;\n\t} else if (isMonthEmpty && isYearEmpty) {\n\t\terror = emptyMonthAndYear;\n\t\tyearInvalid = true;\n\t\tmonthInvalid = true;\n\t} else if (isDayEmpty) {\n\t\terror = emptyDay;\n\t\tdayInvalid = true;\n\t} else if (isMonthEmpty) {\n\t\terror = emptyMonth;\n\t\tmonthInvalid = true;\n\t} else if (isYearEmpty) {\n\t\terror = emptyYear;\n\t\tyearInvalid = true;\n\t}\n\n\tconst isDayInvalid = dayVisible && isInvalidDay(dayValue);\n\tconst isMonthInvalid = monthVisible && isInvalidMonth(monthValue);\n\tconst isYearInvalid = yearVisible && isInvalidYear(yearValue, minYear, maxYear);\n\t/*\n\t * If only one error, specify where the error occurs\n\t * E.g. “Enter a valid day.”, “Enter a valid month.” Or “Enter a valid year.”\n\t * If 2 or more fields have error (or all 3), say “Enter a valid date.”\n\t * If one or more fields are invalid but the others are empty say: “Enter a valid date.”\n\t */\n\tif (isEmpty(error)) {\n\t\tif (isDayInvalid && isMonthInvalid && isYearInvalid) {\n\t\t\terror = invalidDate;\n\t\t\tdayInvalid = true;\n\t\t\tmonthInvalid = true;\n\t\t\tyearInvalid = true;\n\t\t} else if (isDayInvalid && isMonthInvalid) {\n\t\t\terror = invalidDate;\n\t\t\tdayInvalid = true;\n\t\t\tmonthInvalid = true;\n\t\t} else if (isDayInvalid && isYearInvalid) {\n\t\t\terror = invalidDate;\n\t\t\tdayInvalid = true;\n\t\t\tyearInvalid = true;\n\t\t} else if (isMonthInvalid && isYearInvalid) {\n\t\t\terror = invalidDate;\n\t\t\tmonthInvalid = true;\n\t\t\tyearInvalid = true;\n\t\t} else if (isYearInvalid) {\n\t\t\terror = invalidYear;\n\t\t\tyearInvalid = true;\n\t\t} else if (isMonthInvalid) {\n\t\t\terror = invalidMonth;\n\t\t\tmonthInvalid = true;\n\t\t} else if (isDayInvalid) {\n\t\t\terror = invalidDay;\n\t\t\tdayInvalid = true;\n\t\t}\n\t}\n\n\treturn { errorMessage: error, dayInvalid, monthInvalid, yearInvalid };\n};\n"]}
1
+ {"version":3,"file":"date-validation-utils.js","sourceRoot":"","sources":["../../../../src/components/ontario-date-input/utils/date-validation-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,GACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE;IACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE1B,OAAO,GAAG,GAAG,aAAa,IAAI,GAAG,GAAG,aAAa,CAAC;AACnD,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;IACxC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE5B,OAAO,KAAK,GAAG,eAAe,IAAI,KAAK,GAAG,eAAe,CAAC;AAC3D,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,KAAsB,EACtB,UAAkB,cAAc,EAChC,UAAkB,cAAc,EAC/B,EAAE;IACH,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE3B,OAAO,IAAI,GAAG,OAAO,IAAI,IAAI,GAAG,OAAO,CAAC;AACzC,CAAC,CAAC;AAaF;;GAEG;A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,GAAG,IAAI,CAAC;YACpB,WAAW,GAAG,IAAI,CAAC;QACpB,CAAC;aAAM,IAAI,aAAa,EAAE,CAAC;YAC1B,KAAK,GAAG,WAAW,CAAC;YACpB,WAAW,GAAG,IAAI,CAAC;QACpB,CAAC;aAAM,IAAI,cAAc,EAAE,CAAC;YAC3B,KAAK,GAAG,YAAY,CAAC;YACrB,YAAY,GAAG,IAAI,CAAC;QACrB,CAAC;aAAM,IAAI,YAAY,EAAE,CAAC;YACzB,KAAK,GAAG,UAAU,CAAC;YACnB,UAAU,GAAG,IAAI,CAAC;QACnB,CAAC;IACF,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AACvE,CAAC,CAAC","sourcesContent":["import {\n\tDAY_MIN_VALUE,\n\tDAY_MAX_VALUE,\n\tMONTH_MIN_VALUE,\n\tMONTH_MAX_VALUE,\n\tYEAR_MIN_VALUE,\n\tYEAR_MAX_VALUE,\n} from '../constants';\nimport { DateValidatorReturnType } from '../ontario-date-input-interface';\nimport { isNumber, isEmpty } from '../../../utils/helper/utils';\nimport { Translations } from '../../../translations';\n/*\n * Day field should be a number, not negative, no greater than “31”\n */\nconst isInvalidDay = (value: string) => {\n\tif (!isNumber(value)) {\n\t\treturn true;\n\t}\n\n\tconst day = Number(value);\n\n\treturn day < DAY_MIN_VALUE || day > DAY_MAX_VALUE;\n};\n\n/*\n * Month field should be a number, not negative, no greater than “12”\n */\nconst isInvalidMonth = (value: string) => {\n\tif (!isNumber(value)) {\n\t\treturn true;\n\t}\n\n\tconst month = Number(value);\n\n\treturn month < MONTH_MIN_VALUE || month > MONTH_MAX_VALUE;\n};\n\n/**\n * Valid value year against minimum and maximum year range (defaulted if not provided.)\n *\n * Year field should be a number and not written out; it has no concept of positive and negative.\n *\n * Suggestion:\n * - `< 0` B.C.E.\n * - `>= 0` A.C.E.\n *\n * @param value value to check for validity\n * @param minYear minimum valid year to validate against\n * @param maxYear maximum valid year to validate against\n */\nexport const isInvalidYear = (\n\tvalue: string | number,\n\tminYear: number = YEAR_MIN_VALUE,\n\tmaxYear: number = YEAR_MAX_VALUE,\n) => {\n\tif (!isNumber(value)) {\n\t\treturn true;\n\t}\n\n\tconst year = Number(value);\n\n\treturn year < minYear || year > maxYear;\n};\n\ntype GetDateErrorArg = {\n\tdayValue: string;\n\tmonthValue: string;\n\tyearValue: string;\n\terrorMessages: Translations['dateInput']['error']['en'];\n\tminYear?: number;\n\tmaxYear?: number;\n\tdayVisible: boolean;\n\tmonthVisible: boolean;\n\tyearVisible: boolean;\n};\n/**\n * Helper function to get error message for birthdate validation\n */\nexport const getDateErrorMessage = ({\n\tdayValue,\n\tmonthValue,\n\tyearValue,\n\terrorMessages,\n\tminYear,\n\tmaxYear,\n\tdayVisible,\n\tmonthVisible,\n\tyearVisible,\n}: GetDateErrorArg): DateValidatorReturnType => {\n\tconst {\n\t\temptyDay,\n\t\temptyMonth,\n\t\temptyYear,\n\t\temptyDayAndMonth,\n\t\temptyDayAndYear,\n\t\temptyMonthAndYear,\n\t\tinvalidDate,\n\t\tinvalidDay,\n\t\tinvalidMonth,\n\t\tinvalidYear,\n\t} = errorMessages;\n\n\tlet error = '';\n\tlet dayInvalid = false;\n\tlet monthInvalid = false;\n\tlet yearInvalid = false;\n\n\tconst isDayEmpty = dayVisible && isEmpty(dayValue);\n\tconst isMonthEmpty = monthVisible && isEmpty(monthValue);\n\tconst isYearEmpty = yearVisible && isEmpty(yearValue);\n\t/*\n\t * If one ore more fields are valid but others are empty:\n\t * 1 field empty:\n\t * Day as empty - “Enter the day.”\n\t * Month as empty - “Enter the month.”\n\t * Year as empty - “Enter the year.”\n\t * 2 fields empty:\n\t * Month and day empty - “Enter the month and day.”\n\t * Year and day empty - “Enter the year and day.”\n\t * Year and month empty - “Enter the year and month.”\n\t */\n\tif (isDayEmpty && isMonthEmpty && isYearEmpty) {\n\t\terror = invalidDate;\n\t\tdayInvalid = true;\n\t\tmonthInvalid = true;\n\t\tyearInvalid = true;\n\t} else if (isDayEmpty && isMonthEmpty) {\n\t\terror = emptyDayAndMonth;\n\t\tdayInvalid = true;\n\t\tmonthInvalid = true;\n\t} else if (isDayEmpty && isYearEmpty) {\n\t\terror = emptyDayAndYear;\n\t\tdayInvalid = true;\n\t\tyearInvalid = true;\n\t} else if (isMonthEmpty && isYearEmpty) {\n\t\terror = emptyMonthAndYear;\n\t\tyearInvalid = true;\n\t\tmonthInvalid = true;\n\t} else if (isDayEmpty) {\n\t\terror = emptyDay;\n\t\tdayInvalid = true;\n\t} else if (isMonthEmpty) {\n\t\terror = emptyMonth;\n\t\tmonthInvalid = true;\n\t} else if (isYearEmpty) {\n\t\terror = emptyYear;\n\t\tyearInvalid = true;\n\t}\n\n\tconst isDayInvalid = dayVisible && isInvalidDay(dayValue);\n\tconst isMonthInvalid = monthVisible && isInvalidMonth(monthValue);\n\tconst isYearInvalid = yearVisible && isInvalidYear(yearValue, minYear, maxYear);\n\t/*\n\t * If only one error, specify where the error occurs\n\t * E.g. “Enter a valid day.”, “Enter a valid month.” Or “Enter a valid year.”\n\t * If 2 or more fields have error (or all 3), say “Enter a valid date.”\n\t * If one or more fields are invalid but the others are empty say: “Enter a valid date.”\n\t */\n\tif (isEmpty(error)) {\n\t\tif (isDayInvalid && isMonthInvalid && isYearInvalid) {\n\t\t\terror = invalidDate;\n\t\t\tdayInvalid = true;\n\t\t\tmonthInvalid = true;\n\t\t\tyearInvalid = true;\n\t\t} else if (isDayInvalid && isMonthInvalid) {\n\t\t\terror = invalidDate;\n\t\t\tdayInvalid = true;\n\t\t\tmonthInvalid = true;\n\t\t} else if (isDayInvalid && isYearInvalid) {\n\t\t\terror = invalidDate;\n\t\t\tdayInvalid = true;\n\t\t\tyearInvalid = true;\n\t\t} else if (isMonthInvalid && isYearInvalid) {\n\t\t\terror = invalidDate;\n\t\t\tmonthInvalid = true;\n\t\t\tyearInvalid = true;\n\t\t} else if (isYearInvalid) {\n\t\t\terror = invalidYear;\n\t\t\tyearInvalid = true;\n\t\t} else if (isMonthInvalid) {\n\t\t\terror = invalidMonth;\n\t\t\tmonthInvalid = true;\n\t\t} else if (isDayInvalid) {\n\t\t\terror = invalidDay;\n\t\t\tdayInvalid = true;\n\t\t}\n\t}\n\n\treturn { errorMessage: error, dayInvalid, monthInvalid, yearInvalid };\n};\n"]}
@@ -2366,9 +2366,6 @@
2366
2366
  .ontario-service-subheader .ontario-header-button {
2367
2367
  display: flex;
2368
2368
  }
2369
- .ontario-service-subheader .ontario-header-button:last-of-type {
2370
- display: none;
2371
- }
2372
2369
 
2373
2370
  .ontario-service-subheader .ontario-header-button {
2374
2371
  background-color: #03713d;
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"><path d="M19 6.4L17.6 5 12 10.6 6.4 5 5 6.4l5.6 5.6L5 17.6 6.4 19l5.6-5.6 5.6 5.6 1.4-1.4-5.6-5.6L19 6.4z" fill="#000"/></svg>