@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
@@ -32,17 +32,17 @@ export class OntarioStepIndicator {
32
32
  render() {
33
33
  return h(
34
34
  'div',
35
- { key: '8d853372c036d2dc56e4075fa5ba6c9e8f8ed36f', class: 'ontario-step-indicator' },
35
+ { key: '83d9f9953680f3e84f11fcb85d6aca4a050932ca', class: 'ontario-step-indicator' },
36
36
  h(
37
37
  'div',
38
- { key: '1893a801bc9e624a1fb6cf55d4fbdb60368a0657', class: 'ontario-row' },
38
+ { key: '84b130dd8af2cc708cea2f45799d04161699d703', class: 'ontario-row' },
39
39
  h(
40
40
  'div',
41
- { key: 'a2ac5f0c1c48756d5110a6d605c263ac26b8229b', class: 'ontario-columns ontario-small-12' },
41
+ { key: '12457c0b09eede669f39f7d0c9b1ebbc5dbcc6e6', class: 'ontario-columns ontario-small-12' },
42
42
  h(
43
43
  'div',
44
44
  {
45
- key: '97ec6e22254d71cec885a1a0889eda3736739a52',
45
+ key: 'a422636fc6c8d666d4e60aacf883d7b45ccddfb6',
46
46
  class: `ontario-step-indicator--with-back-button--${this.showBackButton}`,
47
47
  },
48
48
  this.showBackButton === true &&
@@ -82,7 +82,7 @@ export class OntarioStepIndicator {
82
82
  this.numberOfSteps,
83
83
  ),
84
84
  ),
85
- h('hr', { key: '7d8d1cb75517980327bbf2095fd1149b6c41e3a2' }),
85
+ h('hr', { key: '23f2d86c4d1406d607fd7f5dbb5d54450a6cd5fa' }),
86
86
  ),
87
87
  ),
88
88
  );
@@ -150,26 +150,26 @@ export class OntarioTable {
150
150
  const columns = extractValuesByKey(this.tableColumnsState, 'key');
151
151
  return h(
152
152
  'div',
153
- { key: '0a6d7c55af2732b9799e9d08b93469c07fe670a6', class: 'ontario-table-container' },
153
+ { key: 'ce676d443d6f54e6eac8c7e035ac8c192b6be473', class: 'ontario-table-container' },
154
154
  h(
155
155
  'div',
156
156
  {
157
- key: '775159ebeabc19d6a44aa59a8ad6a28879c1ac2b',
157
+ key: '0baf35972c5c3c2382103bc765007be2e76cea15',
158
158
  class: 'ontario-table-scroll--wrapper',
159
159
  ref: (el) => (this.tableScrollWrapper = el),
160
160
  },
161
161
  h('div', {
162
- key: 'eb29663f922ddfc895201f84b1c42809f1180d69',
162
+ key: '348d83ea103a82da6c29fa94f87ee1ff45b8d485',
163
163
  class: 'ontario-table-scroll--div',
164
164
  ref: (el) => (this.tableScrollDiv = el),
165
165
  }),
166
166
  ),
167
167
  h(
168
168
  'div',
169
- { key: 'e9f98cb3babe7c15a99e0f478d7f1cd076090610', class: 'ontario-table-div', ref: (el) => (this.table = el) },
169
+ { key: 'd7c72699f19d0fe8144551e8754878b42d76cb71', class: 'ontario-table-div', ref: (el) => (this.table = el) },
170
170
  h(
171
171
  'table',
172
- { key: 'cefb954da377c35d836b63f075e9d197934fa6fe', class: this.getTableClasses() },
172
+ { key: '3c3f6bb5bbb75e0673509a1a377e224de64176f2', class: this.getTableClasses() },
173
173
  this.caption && h('caption', null, this.caption),
174
174
  this.tableColumnsState &&
175
175
  h(
@@ -170,7 +170,7 @@ export class OntarioTextarea {
170
170
  return h(
171
171
  'div',
172
172
  {
173
- key: 'c5fb67c54eba0560e63e6291e15fc7dad9bc863f',
173
+ key: '63372c743a7ac103d5bec0fdcb5f1f8623d588e3',
174
174
  class: `ontario-form-group ${error ? 'ontario-textarea--error' : ''}`,
175
175
  },
176
176
  this.captionState.getCaption(this.getId(), !!this.internalHintExpander),
@@ -180,9 +180,9 @@ export class OntarioTextarea {
180
180
  hintContentType: this.internalHintText.hintContentType,
181
181
  ref: (el) => (this.hintTextRef = el),
182
182
  }),
183
- h(ErrorMessage, { key: '30484b78a53895e736e4a6531de6d3e3caa20d87', message: this.errorMessage, error: error }),
183
+ h(ErrorMessage, { key: '90cece114c1b84a2996d25cb1a9a0548eab7d10a', message: this.errorMessage, error: error }),
184
184
  h('textarea', {
185
- 'key': '2e184ceba27a2d3b099545c81a346b611f3cf38f',
185
+ 'key': 'c6bc6014372f7f4839c9ce5070a484ac253c92e6',
186
186
  'aria-describedby': this.hintTextId,
187
187
  'class': this.getClass(),
188
188
  'id': this.getId(),
File without changes
File without changes
@@ -26,6 +26,7 @@ export const Input = (_a) => {
26
26
  onChange,
27
27
  onBlur,
28
28
  onFocus,
29
+ onClick,
29
30
  ariaInvalid,
30
31
  ariaDescribedBy,
31
32
  ref,
@@ -46,6 +47,7 @@ export const Input = (_a) => {
46
47
  'onChange',
47
48
  'onBlur',
48
49
  'onFocus',
50
+ 'onClick',
49
51
  'ariaInvalid',
50
52
  'ariaDescribedBy',
51
53
  'ref',
@@ -69,6 +71,7 @@ export const Input = (_a) => {
69
71
  'onChange': onChange,
70
72
  'onBlur': onBlur,
71
73
  'onFocus': onFocus,
74
+ 'onClick': onClick,
72
75
  'inputMode': inputMode,
73
76
  'ref': ref,
74
77
  'aria-invalid': ariaInvalid,
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../src/utils/common/input/input.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAuB,CAAC,EAAE,MAAM,eAAe,CAAC;AAuBvD,MAAM,CAAC,MAAM,KAAK,GAAoC,CAAC,EAoBtD,EAAE,EAAE;QApBkD,EACtD,YAAY,EACZ,SAAS,EACT,EAAE,EACF,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,EACP,WAAW,EACX,eAAe,EACf,GAAG,EACH,SAAS,OAET,EADG,KAAK,cAnB8C,iNAoBtD,CADQ;IAER,OAAO,CACN,2BACC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,CAAC,CAAC,QAAQ,EACpB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,GAAG,kBACM,WAAW,sBACP,eAAe,IAC7B,KAAK,EACR,CACF,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { FunctionalComponent, h } from '@stencil/core';\n\nexport type InputProps = {\n\tautoComplete?: string;\n\tclassName?: string;\n\tid: string;\n\tname?: string;\n\ttype: string;\n\tvalue?: string | number;\n\tchecked?: boolean;\n\trequired?: boolean;\n\tinputMode?: string;\n\tplaceholder?: string;\n\tariaInvalid?: boolean;\n\tariaDescribedBy?: string;\n\tonKeyDown?: ((event: Event) => void) | undefined;\n\tonInput?: ((event: Event) => void) | undefined;\n\tonChange?: ((event: Event) => void) | undefined;\n\tonBlur?: ((event: Event) => void) | undefined;\n\tonFocus?: ((event: Event) => void) | undefined;\n\tref?: (el: any) => HTMLElement;\n};\n\nexport const Input: FunctionalComponent<InputProps> = ({\n\tautoComplete,\n\tclassName,\n\tid,\n\tname,\n\tplaceholder,\n\ttype,\n\tvalue,\n\tchecked,\n\trequired,\n\tonKeyDown,\n\tonInput,\n\tonChange,\n\tonBlur,\n\tonFocus,\n\tariaInvalid,\n\tariaDescribedBy,\n\tref,\n\tinputMode,\n\t...props\n}) => {\n\treturn (\n\t\t<input\n\t\t\tautoComplete={autoComplete}\n\t\t\tclass={className}\n\t\t\tid={id}\n\t\t\tname={name}\n\t\t\ttype={type}\n\t\t\tvalue={value}\n\t\t\tchecked={checked}\n\t\t\tplaceholder={placeholder}\n\t\t\trequired={!!required}\n\t\t\tonKeyDown={onKeyDown}\n\t\t\tonInput={onInput}\n\t\t\tonChange={onChange}\n\t\t\tonBlur={onBlur}\n\t\t\tonFocus={onFocus}\n\t\t\tinputMode={inputMode}\n\t\t\tref={ref}\n\t\t\taria-invalid={ariaInvalid}\n\t\t\taria-describedby={ariaDescribedBy}\n\t\t\t{...props}\n\t\t/>\n\t);\n};\n"]}
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../src/utils/common/input/input.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAuB,CAAC,EAAE,MAAM,eAAe,CAAC;AAwBvD,MAAM,CAAC,MAAM,KAAK,GAAoC,CAAC,EAqBtD,EAAE,EAAE;QArBkD,EACtD,YAAY,EACZ,SAAS,EACT,EAAE,EACF,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,EACP,OAAO,EACP,WAAW,EACX,eAAe,EACf,GAAG,EACH,SAAS,OAET,EADG,KAAK,cApB8C,4NAqBtD,CADQ;IAER,OAAO,CACN,2BACC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,CAAC,CAAC,QAAQ,EACpB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,GAAG,kBACM,WAAW,sBACP,eAAe,IAC7B,KAAK,EACR,CACF,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { FunctionalComponent, h } from '@stencil/core';\n\nexport type InputProps = {\n\tautoComplete?: string;\n\tclassName?: string;\n\tid: string;\n\tname?: string;\n\ttype: string;\n\tvalue?: string | number;\n\tchecked?: boolean;\n\trequired?: boolean;\n\tinputMode?: string;\n\tplaceholder?: string;\n\tariaInvalid?: boolean;\n\tariaDescribedBy?: string;\n\tonKeyDown?: ((event: Event) => void) | undefined;\n\tonInput?: ((event: Event) => void) | undefined;\n\tonChange?: ((event: Event) => void) | undefined;\n\tonBlur?: ((event: Event) => void) | undefined;\n\tonFocus?: ((event: Event) => void) | undefined;\n\tonClick?: ((event: Event) => void) | undefined;\n\tref?: (el: HTMLInputElement) => HTMLElement;\n};\n\nexport const Input: FunctionalComponent<InputProps> = ({\n\tautoComplete,\n\tclassName,\n\tid,\n\tname,\n\tplaceholder,\n\ttype,\n\tvalue,\n\tchecked,\n\trequired,\n\tonKeyDown,\n\tonInput,\n\tonChange,\n\tonBlur,\n\tonFocus,\n\tonClick,\n\tariaInvalid,\n\tariaDescribedBy,\n\tref,\n\tinputMode,\n\t...props\n}) => {\n\treturn (\n\t\t<input\n\t\t\tautoComplete={autoComplete}\n\t\t\tclass={className}\n\t\t\tid={id}\n\t\t\tname={name}\n\t\t\ttype={type}\n\t\t\tvalue={value}\n\t\t\tchecked={checked}\n\t\t\tplaceholder={placeholder}\n\t\t\trequired={!!required}\n\t\t\tonKeyDown={onKeyDown}\n\t\t\tonInput={onInput}\n\t\t\tonChange={onChange}\n\t\t\tonBlur={onBlur}\n\t\t\tonFocus={onFocus}\n\t\t\tonClick={onClick}\n\t\t\tinputMode={inputMode}\n\t\t\tref={ref}\n\t\t\taria-invalid={ariaInvalid}\n\t\t\taria-describedby={ariaDescribedBy}\n\t\t\t{...props}\n\t\t/>\n\t);\n};\n"]}
@@ -25,23 +25,25 @@ export class InputCaption {
25
25
  /**
26
26
  * Return the `<label>` element for text inputs
27
27
  * @param captionFor Set the `htmlFor` attribute
28
+ * @param hasHintExpander Indicate whether the component the label is for has a hint expander or not
29
+ * @param disableRequiredFlag Disable the required/optional label text _(only use in highly special cases)_
28
30
  * @returns element containing the caption for the input
29
31
  */
30
- this.getCaption = (captionFor, hasHintExpander = false) => {
32
+ this.getCaption = (captionFor, hasHintExpander = false, disableRequiredFlag = false) => {
31
33
  const captionText = this.captionText && this.captionText.toLowerCase();
32
34
  const captionContent = this.isLegend
33
35
  ? h(
34
36
  'legend',
35
37
  { class: this.getClass() },
36
38
  this.captionType === 'heading' ? h('h1', null, this.captionText) : this.captionText,
37
- this.getRequiredFlagElement(),
39
+ !disableRequiredFlag && this.getRequiredFlagElement(),
38
40
  hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false),
39
41
  )
40
42
  : h(
41
43
  'label',
42
44
  { htmlFor: captionFor, class: this.getClass() },
43
45
  this.captionText,
44
- this.getRequiredFlagElement(),
46
+ !disableRequiredFlag && this.getRequiredFlagElement(),
45
47
  hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false),
46
48
  );
47
49
  // with `this.captionType` already set to one of the enum values, the comparison no longer needs the `toLowerCase()` transform
@@ -1 +1 @@
1
- {"version":3,"file":"input-caption.js","sourceRoot":"","sources":["../../../../src/utils/common/input-caption/input-caption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAe,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,MAAM,OAAO,YAAY;IA+BxB;;;;OAIG;IACH,YACC,gBAAw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qBACvC,cAAc,CAAC,IAAI,CAAC;qBACpB,gBAAgB,CAAC,SAAS,CAAC;qBAC3B,cAAc,CAAC,sBAAsB,CAAC;qBACtC,gBAAgB,CAAC,WAAW,CAAC;qBAC7B,cAAc,CAAC,kBAAkB,CAAC,CAAC;gBACrC,MAAM;QACR,CAAC;QAED,OAAO,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["import { h } from '@stencil/core';\nimport { CaptionType, CaptionTypes } from './input-caption.types';\nimport { MessageContentType } from './input-caption.enum';\nimport { CaptionInfo, Caption } from './caption.interface';\nimport { ConsoleMessageClass } from '../../console-message/console-message';\n\nexport class InputCaption implements CaptionInfo {\n\t/**\n\t * The text to display as caption.\n\t */\n\tcaptionText: string;\n\n\t/**\n\t * The type of caption to render.\n\t */\n\tcaptionType?: CaptionType = 'default';\n\n\t/**\n\t * Determine whether the input field is required.\n\t */\n\trequired?: boolean = false;\n\n\t/**\n\t * Determine whether the rendered element is a `<label>` or `<legend>`.\n\t */\n\tisLegend?: boolean = false;\n\n\t/**\n\t * Name of the component instantiating the class.\n\t * This is used for validation warning message.\n\t */\n\tcomponentTagName: string;\n\n\tlanguage: any = 'en';\n\n\ttranslations: any;\n\n\t/**\n\t * Set the class members\n\t * Output a console warning message if the provided `label` type is incorrect\n\t * @param caption object containing the essential data to configure the input label\n\t */\n\tconstructor(\n\t\tcomponentTagName: string,\n\t\tcaption: Caption | string,\n\t\ttranslations: any,\n\t\tlanguage: any,\n\t\tisLegend: boolean = false,\n\t\trequired: boolean = false,\n\t) {\n\t\tlet captionObject: Caption;\n\n\t\tif (typeof caption === 'string') {\n\t\t\ttry {\n\t\t\t\tcaptionObject = JSON.parse(caption) as Caption;\n\t\t\t} catch {\n\t\t\t\tcaptionObject = { captionText: caption, captionType: 'default' };\n\t\t\t}\n\t\t} else {\n\t\t\tcaptionObject = caption;\n\t\t}\n\n\t\tthis.componentTagName = componentTagName.toLocaleLowerCase();\n\t\tthis.captionText = captionObject?.captionText;\n\t\tthis.captionType =\n\t\t\t(captionObject?.captionType && CaptionTypes.find((type) => type === captionObject.captionType?.toLowerCase())) ||\n\t\t\t'default';\n\t\tthis.required = required;\n\t\tthis.isLegend = isLegend;\n\t\tthis.translations = translations;\n\t\tthis.language = language;\n\n\t\tthis.validateCaption(this);\n\t}\n\n\t/**\n\t * Return the `<label>` element for text inputs\n\t * @param captionFor Set the `htmlFor` attribute\n\t * @returns element containing the caption for the input\n\t */\n\tgetCaption = (captionFor?: string | undefined, hasHintExpander: boolean = false): HTMLElement => {\n\t\tconst captionText = this.captionText && this.captionText.toLowerCase();\n\t\tconst captionContent = this.isLegend ? (\n\t\t\t<legend class={this.getClass()}>\n\t\t\t\t{this.captionType === 'heading' ? <h1>{this.captionText}</h1> : this.captionText}\n\t\t\t\t{this.getRequiredFlagElement()}\n\t\t\t\t{hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false)}\n\t\t\t</legend>\n\t\t) : (\n\t\t\t<label htmlFor={captionFor} class={this.getClass()}>\n\t\t\t\t{this.captionText}\n\t\t\t\t{this.getRequiredFlagElement()}\n\t\t\t\t{hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false)}\n\t\t\t</label>\n\t\t);\n\n\t\t// with `this.captionType` already set to one of the enum values, the comparison no longer needs the `toLowerCase()` transform\n\t\treturn this.captionType === 'heading' && !this.isLegend ? <h1>{captionContent}</h1> : captionContent;\n\t};\n\n\tgetHintExpanderAccessibilityText(captionText: string, hasHintExpanderOnOption: boolean = false): HTMLElement {\n\t\tconst multipleOptionsMessage = (\n\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t{this.translations.accessibility.moreInfo[this.language]} \"{captionText.toLowerCase()}\"{' '}\n\t\t\t\t{this.translations.accessibility.checkboxHintExpander[this.language]}\n\t\t\t</span>\n\t\t);\n\n\t\tconst singleOptionMessage = (\n\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t{this.translations.accessibility.moreInfo[this.language]} \"{captionText.toLowerCase()}\"{' '}\n\t\t\t\t{this.translations.accessibility.singleHintExpander[this.language]}\n\t\t\t</span>\n\t\t);\n\t\treturn this.componentTagName === 'ontario-checkboxes'\n\t\t\t? !hasHintExpanderOnOption\n\t\t\t\t? multipleOptionsMessage\n\t\t\t\t: singleOptionMessage\n\t\t\t: singleOptionMessage;\n\t}\n\n\t/**\n\t * Determines which flag text to use between `required` and `optional`\n\t * @returns `required` or `optional` flag text\n\t */\n\tprivate getRequiredFlagText(): string {\n\t\treturn this.required\n\t\t\t? this.translations && `(${this.translations.required[this.language]})`\n\t\t\t: this.translations && `(${this.translations.optional[this.language]})`;\n\t}\n\n\t/**\n\t * Get the HTML for the required/optional flag.\n\t * @returns CSS class for the label/legend.\n\t */\n\tprivate getRequiredFlagElement(): HTMLElement {\n\t\treturn <span class=\"ontario-label__flag\">{this.getRequiredFlagText()}</span>;\n\t}\n\n\t/**\n\t * Get the CSS class for the `label` element.\n\t * @returns CSS class for the `label` element.\n\t */\n\tprivate getClass(): string {\n\t\treturn this.captionType === 'large' || this.captionType === 'heading'\n\t\t\t? this.isLegend\n\t\t\t\t? `ontario-fieldset__legend ontario-fieldset__legend--${this.captionType}`\n\t\t\t\t: `ontario-label ontario-label--${this.captionType}`\n\t\t\t: this.isLegend\n\t\t\t? 'ontario-fieldset__legend'\n\t\t\t: 'ontario-label';\n\t}\n\n\t/**\n\t * Validate caption input by user and output warning message to the console if:\n\t * 1. the `caption` object is not provided\n\t * 2. the `captionText` property of the `caption` object is not provided\n\t * 3. the `captionText` property of the `caption` object is empty or contain only spaces\n\t * 4. the `captionType` property of the `caption` object is not provided\n\t * 5. the `captionType` property of the `caption` object is incorrect\n\t */\n\tprivate validateCaption(caption?: InputCaption) {\n\t\tlet messageType;\n\n\t\t// undefined `caption` object\n\t\tif (!caption || Object.keys(caption).length <= 0) {\n\t\t\tmessageType = MessageContentType.UndefinedCaptionObject;\n\t\t} else {\n\t\t\t// undefined `captionText` property\n\t\t\tif (!caption.captionText) {\n\t\t\t\tmessageType = MessageContentType.UndefinedCaptionText;\n\t\t\t} else {\n\t\t\t\t// `captionText` that is empty or contains only spaces\n\t\t\t\tif (/^\\s*$/.test(caption.captionText)) {\n\t\t\t\t\tmessageType = MessageContentType.EmptyCaptionText;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// undefined `captionType`\n\t\t\tif (!caption.captionType) {\n\t\t\t\tmessageType = MessageContentType.UndefinedCaptionType;\n\t\t\t} else {\n\t\t\t\t// incorrect `captionType`\n\t\t\t\tif (!CaptionTypes.includes(caption?.captionType?.toLowerCase() as CaptionType)) {\n\t\t\t\t\tmessageType = MessageContentType.IncorrectCaptionType;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (messageType) {\n\t\t\tconst message = new ConsoleMessageClass().addDesignSystemTag();\n\n\t\t\tif (messageType !== MessageContentType.UndefinedCaptionObject) {\n\t\t\t\tmessage\n\t\t\t\t\t.addMonospaceText(\n\t\t\t\t\t\t` ${\n\t\t\t\t\t\t\tmessageType === MessageContentType.EmptyCaptionText ||\n\t\t\t\t\t\t\tmessageType === MessageContentType.UndefinedCaptionText\n\t\t\t\t\t\t\t\t? 'caption or captionText'\n\t\t\t\t\t\t\t\t: 'captionType'\n\t\t\t\t\t\t} `,\n\t\t\t\t\t)\n\t\t\t\t\t.addRegularText('object or property of');\n\t\t\t}\n\n\t\t\tmessage.addMonospaceText(' caption ').addRegularText('object on').addMonospaceText(` ${this.componentTagName} `);\n\t\t\tthis.printConsoleMessage(messageType, message, this.getRequiredFlagText());\n\t\t}\n\t}\n\n\t/**\n\t * Generate the content of warning message to be printed to the console\n\t * @param messageType determine the content of warning message to output\n\t * @param componentTagName the tag name of the component that's emitting the warning message\n\t * @param requiredFlagText accepts a string value to be used as the required flag text and defaults to `(optional)` if not set\n\t * @returns an array of `ConsoleMessage` objects containing the message and associated styles to be printed to the console\n\t */\n\tprivate printConsoleMessage(\n\t\tmessageType: MessageContentType,\n\t\tmessage: ConsoleMessageClass,\n\t\trequiredFlagText: string = '(optional)',\n\t) {\n\t\tswitch (messageType) {\n\t\t\t// undefinedCaptionObject example: caption object on <ontario-input> is required but not defined. A blank followed by a (optional) flag is assumed.\n\t\t\t// undefinedCaptionText example: captionText property of caption object on <ontario-input> is required but not defined. A blank followed by a (optional) flag is assumed.\n\t\t\t// EmptyCaptionText example: captionText property of caption object on <ontario-input> is empty or contains only spaces. A blank followed by a (optional) flag is assumed.\n\t\t\tcase MessageContentType.UndefinedCaptionObject:\n\t\t\tcase MessageContentType.UndefinedCaptionText:\n\t\t\tcase MessageContentType.EmptyCaptionText:\n\t\t\t\tmessage\n\t\t\t\t\t.addRegularText(\n\t\t\t\t\t\t`${\n\t\t\t\t\t\t\tmessageType === MessageContentType.EmptyCaptionText\n\t\t\t\t\t\t\t\t? 'is empty or contains only spaces'\n\t\t\t\t\t\t\t\t: 'is required but not defined'\n\t\t\t\t\t\t}. A blank followed by a`,\n\t\t\t\t\t)\n\t\t\t\t\t.addMonospaceText(` ${requiredFlagText} `)\n\t\t\t\t\t.addRegularText('flag is assumed.');\n\t\t\t\tbreak;\n\n\t\t\t// UndefinedCaptionType example: captionType property of caption object on <ontario-input> is not defined. The default type is assumed.\n\t\t\tcase MessageContentType.UndefinedCaptionType:\n\t\t\t\tmessage.addRegularText('is not defined. The').addMonospaceText(' default ').addRegularText('type is assumed.');\n\t\t\t\tbreak;\n\n\t\t\t// IncorrectCaptionType example: captionType property of caption object on <ontario-input> was set to an incorrect type; only default, heading or large type is allowed. The default type is assumed.\n\t\t\tcase MessageContentType.IncorrectCaptionType:\n\t\t\t\tmessage\n\t\t\t\t\t.addRegularText('was set to an incorrect type; only')\n\t\t\t\t\t.addMonospaceText(' default, heading, ')\n\t\t\t\t\t.addRegularText('or')\n\t\t\t\t\t.addMonospaceText(' large ')\n\t\t\t\t\t.addRegularText('type is allowed. The')\n\t\t\t\t\t.addMonospaceText(' default ')\n\t\t\t\t\t.addRegularText('type is assumed.');\n\t\t\t\tbreak;\n\t\t}\n\n\t\tmessage.printMessage();\n\t}\n}\n"]}
1
+ {"version":3,"file":"input-caption.js","sourceRoot":"","sources":["../../../../src/utils/common/input-caption/input-caption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAe,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,MAAM,OAAO,YAAY;IA+BxB;;;;OAIG;IACH,YACC,gBAAwB,EACxB,OAAyB,EACzB,YAAiB,EACjB,QAAa,EACb,WAAoB,KAAK,EACzB,WAAoB,KAAK;QApC1B;;WAEG;QACH,gBAAW,GAAiB,SAAS,CAAC;QAEtC;;WAEG;QACH,aAAQ,GAAa,KAAK,CAAC;QAE3B;;WAEG;QACH,aAAQ,GAAa,KAAK,CAAC;QAQ3B,aAAQ,GAAQ,IAAI,CAAC;QA0CrB;;;;;;WAMG;QACH,eAAU,GAAG,CACZ,UAA+B,EAC/B,kBAA2B,KAAK,EAChC,sBAA+B,KAAK,EACtB,EAAE;YAChB,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;YACvE,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CACtC,cAAQ,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE;gBAC5B,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,cAAK,IAAI,CAAC,WAAW,CAAM,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW;gBAC/E,CAAC,mBAAmB,IAAI,IAAI,CAAC,sBAAsB,EAAE;gBACrD,eAAe,IAAI,IAAI,CAAC,gCAAgC,CAAC,WAAW,EAAE,KAAK,CAAC,CACrE,CACT,CAAC,CAAC,CAAC,CACH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kC;oBACpC,CAAC,CAAC,6BACJ,yBAAyB,CACzB;qBACA,gBAAgB,CAAC,IAAI,gBAAgB,GAAG,CAAC;qBACzC,cAAc,CAAC,kBAAkB,CAAC,CAAC;gBACrC,MAAM;YAEP,uIAAuI;YACvI,KAAK,kBAAkB,CAAC,oBAAoB;gBAC3C,OAAO,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;gBAC/G,MAAM;YAEP,qMAAqM;YACrM,KAAK,kBAAkB,CAAC,oBAAoB;gBAC3C,OAAO;qBACL,cAAc,CAAC,oCAAoC,CAAC;qBACpD,gBAAgB,CAAC,qBAAqB,CAAC;qBACvC,cAAc,CAAC,IAAI,CAAC;qBACpB,gBAAgB,CAAC,SAAS,CAAC;qBAC3B,cAAc,CAAC,sBAAsB,CAAC;qBACtC,gBAAgB,CAAC,WAAW,CAAC;qBAC7B,cAAc,CAAC,kBAAkB,CAAC,CAAC;gBACrC,MAAM;QACR,CAAC;QAED,OAAO,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["import { h } from '@stencil/core';\nimport { CaptionType, CaptionTypes } from './input-caption.types';\nimport { MessageContentType } from './input-caption.enum';\nimport { CaptionInfo, Caption } from './caption.interface';\nimport { ConsoleMessageClass } from '../../console-message/console-message';\n\nexport class InputCaption implements CaptionInfo {\n\t/**\n\t * The text to display as caption.\n\t */\n\tcaptionText: string;\n\n\t/**\n\t * The type of caption to render.\n\t */\n\tcaptionType?: CaptionType = 'default';\n\n\t/**\n\t * Determine whether the input field is required.\n\t */\n\trequired?: boolean = false;\n\n\t/**\n\t * Determine whether the rendered element is a `<label>` or `<legend>`.\n\t */\n\tisLegend?: boolean = false;\n\n\t/**\n\t * Name of the component instantiating the class.\n\t * This is used for validation warning message.\n\t */\n\tcomponentTagName: string;\n\n\tlanguage: any = 'en';\n\n\ttranslations: any;\n\n\t/**\n\t * Set the class members\n\t * Output a console warning message if the provided `label` type is incorrect\n\t * @param caption object containing the essential data to configure the input label\n\t */\n\tconstructor(\n\t\tcomponentTagName: string,\n\t\tcaption: Caption | string,\n\t\ttranslations: any,\n\t\tlanguage: any,\n\t\tisLegend: boolean = false,\n\t\trequired: boolean = false,\n\t) {\n\t\tlet captionObject: Caption;\n\n\t\tif (typeof caption === 'string') {\n\t\t\ttry {\n\t\t\t\tcaptionObject = JSON.parse(caption) as Caption;\n\t\t\t} catch {\n\t\t\t\tcaptionObject = { captionText: caption, captionType: 'default' };\n\t\t\t}\n\t\t} else {\n\t\t\tcaptionObject = caption;\n\t\t}\n\n\t\tthis.componentTagName = componentTagName.toLocaleLowerCase();\n\t\tthis.captionText = captionObject?.captionText;\n\t\tthis.captionType =\n\t\t\t(captionObject?.captionType && CaptionTypes.find((type) => type === captionObject.captionType?.toLowerCase())) ||\n\t\t\t'default';\n\t\tthis.required = required;\n\t\tthis.isLegend = isLegend;\n\t\tthis.translations = translations;\n\t\tthis.language = language;\n\n\t\tthis.validateCaption(this);\n\t}\n\n\t/**\n\t * Return the `<label>` element for text inputs\n\t * @param captionFor Set the `htmlFor` attribute\n\t * @param hasHintExpander Indicate whether the component the label is for has a hint expander or not\n\t * @param disableRequiredFlag Disable the required/optional label text _(only use in highly special cases)_\n\t * @returns element containing the caption for the input\n\t */\n\tgetCaption = (\n\t\tcaptionFor?: string | undefined,\n\t\thasHintExpander: boolean = false,\n\t\tdisableRequiredFlag: boolean = false,\n\t): HTMLElement => {\n\t\tconst captionText = this.captionText && this.captionText.toLowerCase();\n\t\tconst captionContent = this.isLegend ? (\n\t\t\t<legend class={this.getClass()}>\n\t\t\t\t{this.captionType === 'heading' ? <h1>{this.captionText}</h1> : this.captionText}\n\t\t\t\t{!disableRequiredFlag && this.getRequiredFlagElement()}\n\t\t\t\t{hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false)}\n\t\t\t</legend>\n\t\t) : (\n\t\t\t<label htmlFor={captionFor} class={this.getClass()}>\n\t\t\t\t{this.captionText}\n\t\t\t\t{!disableRequiredFlag && this.getRequiredFlagElement()}\n\t\t\t\t{hasHintExpander && this.getHintExpanderAccessibilityText(captionText, false)}\n\t\t\t</label>\n\t\t);\n\n\t\t// with `this.captionType` already set to one of the enum values, the comparison no longer needs the `toLowerCase()` transform\n\t\treturn this.captionType === 'heading' && !this.isLegend ? <h1>{captionContent}</h1> : captionContent;\n\t};\n\n\tgetHintExpanderAccessibilityText(captionText: string, hasHintExpanderOnOption: boolean = false): HTMLElement {\n\t\tconst multipleOptionsMessage = (\n\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t{this.translations.accessibility.moreInfo[this.language]} \"{captionText.toLowerCase()}\"{' '}\n\t\t\t\t{this.translations.accessibility.checkboxHintExpander[this.language]}\n\t\t\t</span>\n\t\t);\n\n\t\tconst singleOptionMessage = (\n\t\t\t<span class=\"ontario-show-for-sr\">\n\t\t\t\t{this.translations.accessibility.moreInfo[this.language]} \"{captionText.toLowerCase()}\"{' '}\n\t\t\t\t{this.translations.accessibility.singleHintExpander[this.language]}\n\t\t\t</span>\n\t\t);\n\t\treturn this.componentTagName === 'ontario-checkboxes'\n\t\t\t? !hasHintExpanderOnOption\n\t\t\t\t? multipleOptionsMessage\n\t\t\t\t: singleOptionMessage\n\t\t\t: singleOptionMessage;\n\t}\n\n\t/**\n\t * Determines which flag text to use between `required` and `optional`\n\t * @returns `required` or `optional` flag text\n\t */\n\tprivate getRequiredFlagText(): string {\n\t\treturn this.required\n\t\t\t? this.translations && `(${this.translations.required[this.language]})`\n\t\t\t: this.translations && `(${this.translations.optional[this.language]})`;\n\t}\n\n\t/**\n\t * Get the HTML for the required/optional flag.\n\t * @returns CSS class for the label/legend.\n\t */\n\tprivate getRequiredFlagElement(): HTMLElement {\n\t\treturn <span class=\"ontario-label__flag\">{this.getRequiredFlagText()}</span>;\n\t}\n\n\t/**\n\t * Get the CSS class for the `label` element.\n\t * @returns CSS class for the `label` element.\n\t */\n\tprivate getClass(): string {\n\t\treturn this.captionType === 'large' || this.captionType === 'heading'\n\t\t\t? this.isLegend\n\t\t\t\t? `ontario-fieldset__legend ontario-fieldset__legend--${this.captionType}`\n\t\t\t\t: `ontario-label ontario-label--${this.captionType}`\n\t\t\t: this.isLegend\n\t\t\t? 'ontario-fieldset__legend'\n\t\t\t: 'ontario-label';\n\t}\n\n\t/**\n\t * Validate caption input by user and output warning message to the console if:\n\t * 1. the `caption` object is not provided\n\t * 2. the `captionText` property of the `caption` object is not provided\n\t * 3. the `captionText` property of the `caption` object is empty or contain only spaces\n\t * 4. the `captionType` property of the `caption` object is not provided\n\t * 5. the `captionType` property of the `caption` object is incorrect\n\t */\n\tprivate validateCaption(caption?: InputCaption) {\n\t\tlet messageType;\n\n\t\t// undefined `caption` object\n\t\tif (!caption || Object.keys(caption).length <= 0) {\n\t\t\tmessageType = MessageContentType.UndefinedCaptionObject;\n\t\t} else {\n\t\t\t// undefined `captionText` property\n\t\t\tif (!caption.captionText) {\n\t\t\t\tmessageType = MessageContentType.UndefinedCaptionText;\n\t\t\t} else {\n\t\t\t\t// `captionText` that is empty or contains only spaces\n\t\t\t\tif (/^\\s*$/.test(caption.captionText)) {\n\t\t\t\t\tmessageType = MessageContentType.EmptyCaptionText;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// undefined `captionType`\n\t\t\tif (!caption.captionType) {\n\t\t\t\tmessageType = MessageContentType.UndefinedCaptionType;\n\t\t\t} else {\n\t\t\t\t// incorrect `captionType`\n\t\t\t\tif (!CaptionTypes.includes(caption?.captionType?.toLowerCase() as CaptionType)) {\n\t\t\t\t\tmessageType = MessageContentType.IncorrectCaptionType;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (messageType) {\n\t\t\tconst message = new ConsoleMessageClass().addDesignSystemTag();\n\n\t\t\tif (messageType !== MessageContentType.UndefinedCaptionObject) {\n\t\t\t\tmessage\n\t\t\t\t\t.addMonospaceText(\n\t\t\t\t\t\t` ${\n\t\t\t\t\t\t\tmessageType === MessageContentType.EmptyCaptionText ||\n\t\t\t\t\t\t\tmessageType === MessageContentType.UndefinedCaptionText\n\t\t\t\t\t\t\t\t? 'caption or captionText'\n\t\t\t\t\t\t\t\t: 'captionType'\n\t\t\t\t\t\t} `,\n\t\t\t\t\t)\n\t\t\t\t\t.addRegularText('object or property of');\n\t\t\t}\n\n\t\t\tmessage.addMonospaceText(' caption ').addRegularText('object on').addMonospaceText(` ${this.componentTagName} `);\n\t\t\tthis.printConsoleMessage(messageType, message, this.getRequiredFlagText());\n\t\t}\n\t}\n\n\t/**\n\t * Generate the content of warning message to be printed to the console\n\t * @param messageType determine the content of warning message to output\n\t * @param componentTagName the tag name of the component that's emitting the warning message\n\t * @param requiredFlagText accepts a string value to be used as the required flag text and defaults to `(optional)` if not set\n\t * @returns an array of `ConsoleMessage` objects containing the message and associated styles to be printed to the console\n\t */\n\tprivate printConsoleMessage(\n\t\tmessageType: MessageContentType,\n\t\tmessage: ConsoleMessageClass,\n\t\trequiredFlagText: string = '(optional)',\n\t) {\n\t\tswitch (messageType) {\n\t\t\t// undefinedCaptionObject example: caption object on <ontario-input> is required but not defined. A blank followed by a (optional) flag is assumed.\n\t\t\t// undefinedCaptionText example: captionText property of caption object on <ontario-input> is required but not defined. A blank followed by a (optional) flag is assumed.\n\t\t\t// EmptyCaptionText example: captionText property of caption object on <ontario-input> is empty or contains only spaces. A blank followed by a (optional) flag is assumed.\n\t\t\tcase MessageContentType.UndefinedCaptionObject:\n\t\t\tcase MessageContentType.UndefinedCaptionText:\n\t\t\tcase MessageContentType.EmptyCaptionText:\n\t\t\t\tmessage\n\t\t\t\t\t.addRegularText(\n\t\t\t\t\t\t`${\n\t\t\t\t\t\t\tmessageType === MessageContentType.EmptyCaptionText\n\t\t\t\t\t\t\t\t? 'is empty or contains only spaces'\n\t\t\t\t\t\t\t\t: 'is required but not defined'\n\t\t\t\t\t\t}. A blank followed by a`,\n\t\t\t\t\t)\n\t\t\t\t\t.addMonospaceText(` ${requiredFlagText} `)\n\t\t\t\t\t.addRegularText('flag is assumed.');\n\t\t\t\tbreak;\n\n\t\t\t// UndefinedCaptionType example: captionType property of caption object on <ontario-input> is not defined. The default type is assumed.\n\t\t\tcase MessageContentType.UndefinedCaptionType:\n\t\t\t\tmessage.addRegularText('is not defined. The').addMonospaceText(' default ').addRegularText('type is assumed.');\n\t\t\t\tbreak;\n\n\t\t\t// IncorrectCaptionType example: captionType property of caption object on <ontario-input> was set to an incorrect type; only default, heading or large type is allowed. The default type is assumed.\n\t\t\tcase MessageContentType.IncorrectCaptionType:\n\t\t\t\tmessage\n\t\t\t\t\t.addRegularText('was set to an incorrect type; only')\n\t\t\t\t\t.addMonospaceText(' default, heading, ')\n\t\t\t\t\t.addRegularText('or')\n\t\t\t\t\t.addMonospaceText(' large ')\n\t\t\t\t\t.addRegularText('type is allowed. The')\n\t\t\t\t\t.addMonospaceText(' default ')\n\t\t\t\t\t.addRegularText('type is assumed.');\n\t\t\t\tbreak;\n\t\t}\n\n\t\tmessage.printMessage();\n\t}\n}\n"]}
@@ -56,7 +56,8 @@ export function removeObjectsBySpecificKey(objects, key, value) {
56
56
  * @returns {boolean}
57
57
  */
58
58
  export function isNumber(value) {
59
- return isNaN(Number(value)) === true;
59
+ if (value === undefined || value === null) return false;
60
+ return isNaN(Number(value)) === false;
60
61
  }
61
62
  export function isEmpty(str) {
62
63
  return !str || (str === null || str === void 0 ? void 0 : str.length) <= 0;
@@ -69,7 +70,8 @@ export function isEmpty(str) {
69
70
  * @returns {string[]}
70
71
  */
71
72
  export function retrieveEnumKeys(enumObject) {
72
- return Object.keys(enumObject).filter(isNumber);
73
+ if (enumObject === undefined || enumObject === null) return new Array(0);
74
+ return Object.keys(enumObject).filter((key) => !isNumber(key));
73
75
  }
74
76
  /**
75
77
  * Prints an array as a comma delimited list, with the last element being preceded by a conjunction.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils/helper/utils.ts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AC,UAAU,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,GAAe,EAAE,kBAA+B,KAAK;IAC/E,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,CACrB,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,eAAe,GAAG,CAAC,GAAG,KAAK,CAChG,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB;IACjC,OAAO,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { Conjunction } from './utils-types';\n\nexport function format(first: string | undefined, middle: string | undefined, last: string | undefined): string {\n\treturn (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');\n}\n\nexport function hasMultipleTrueValues<T>(arr: T[], key: keyof T): boolean {\n\tlet count = 0;\n\n\tfor (const obj of arr) {\n\t\tif (obj[key] === true || obj[key] === 'true') {\n\t\t\tcount++;\n\t\t\tif (count > 1) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n\nexport function extractValuesByKey<T>(objects: T[], key: keyof T): Array<T[keyof T]> {\n\treturn objects.map((obj) => obj[key]);\n}\n\nexport function organizeObjectKeys(data: any[], columns: string[]): any[] {\n\treturn data.map((item) => {\n\t\tconst newData: any = {};\n\t\tconst otherKeys: any = {};\n\n\t\t// Iterate through each key in the item\n\t\tObject.keys(item).forEach((key) => {\n\t\t\tif (key === 'data') {\n\t\t\t\t// Organize keys in the 'data' object\n\t\t\t\tcolumns.forEach((column) => {\n\t\t\t\t\tif (column in item.data) {\n\t\t\t\t\t\tnewData[column] = item.data[column];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Preserve other keys\n\t\t\t\totherKeys[key] = item[key];\n\t\t\t}\n\t\t});\n\n\t\treturn { data: newData, ...otherKeys };\n\t});\n}\n\nexport function removeObjectsBySpecificKey<T>(objects: T[], key: keyof T, value: boolean | 'true'): [T[], T[]] {\n\tconst removedObjects: T[] = [];\n\tconst filteredObjects = objects.filter((obj) => {\n\t\tif (obj[key] === value) {\n\t\t\tremovedObjects.push(obj);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t});\n\treturn [filteredObjects, removedObjects];\n}\n\n/**\n * Takes an input value and determines whether or not it is a number.\n *\n * @param {string | number} value - The value you would like to test against.\n *\n * @returns {boolean}\n */\nexport function isNumber(value: string | number): boolean {\n\treturn isNaN(Number(value)) === true;\n}\n\nexport function isEmpty(str: string | undefined | null): boolean {\n\treturn !str || str?.length <= 0;\n}\n\n/**\n * Retrieves the keys from an enum and lists them in an array.\n *\n * @param {object} enumObject - The enum you wish to get the keys of.\n *\n * @returns {string[]}\n */\nexport function retrieveEnumKeys(enumObject: object): string[] {\n\treturn Object.keys(enumObject).filter(isNumber);\n}\n\n/**\n * Prints an array as a comma delimited list, with the last element being preceded by a conjunction.\n * As per ontario.ca content guidelines, there is no Oxford comma.\n *\n * @param {Array<any>} arr - The array that you wish to print.\n * @param {Conjunction} conjunctionType - Whether you want the sentence to end with 'and value.' or 'or value.'\n *\n * @returns {string}\n */\nexport function printArray(arr: Array<any>, conjunctionType: Conjunction = 'and'): string {\n\treturn [...arr].reduce(\n\t\t(text, value, i, array) => text + (i < array.length - 1 ? ', ' : ` ${conjunctionType} `) + value,\n\t);\n}\n\n/**\n * Grabs the HTML element of the page.\n *\n * More targetted than document.documentElement as the documentElement could\n * in theory be any element that is the top level. e.g. <div> if the page is not\n * set up to be semantically correct.\n *\n * @returns {HTMLElement}\n */\nexport function getRootHTMLElement(): HTMLElement {\n\treturn document.getElementsByTag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aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,KAAI,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IAClD,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,IAAI,KAAK,CAAS,CAAC,CAAC,CAAC;IACjF,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,GAAe,EAAE,kBAA+B,KAAK;IAC/E,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,CACrB,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,eAAe,GAAG,CAAC,GAAG,KAAK,CAChG,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB;IACjC,OAAO,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { Conjunction } from './utils-types';\n\nexport function format(first: string | undefined, middle: string | undefined, last: string | undefined): string {\n\treturn (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');\n}\n\nexport function hasMultipleTrueValues<T>(arr: T[], key: keyof T): boolean {\n\tlet count = 0;\n\n\tfor (const obj of arr) {\n\t\tif (obj[key] === true || obj[key] === 'true') {\n\t\t\tcount++;\n\t\t\tif (count > 1) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n\nexport function extractValuesByKey<T>(objects: T[], key: keyof T): Array<T[keyof T]> {\n\treturn objects.map((obj) => obj[key]);\n}\n\nexport function organizeObjectKeys(data: any[], columns: string[]): any[] {\n\treturn data.map((item) => {\n\t\tconst newData: any = {};\n\t\tconst otherKeys: any = {};\n\n\t\t// Iterate through each key in the item\n\t\tObject.keys(item).forEach((key) => {\n\t\t\tif (key === 'data') {\n\t\t\t\t// Organize keys in the 'data' object\n\t\t\t\tcolumns.forEach((column) => {\n\t\t\t\t\tif (column in item.data) {\n\t\t\t\t\t\tnewData[column] = item.data[column];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Preserve other keys\n\t\t\t\totherKeys[key] = item[key];\n\t\t\t}\n\t\t});\n\n\t\treturn { data: newData, ...otherKeys };\n\t});\n}\n\nexport function removeObjectsBySpecificKey<T>(objects: T[], key: keyof T, value: boolean | 'true'): [T[], T[]] {\n\tconst removedObjects: T[] = [];\n\tconst filteredObjects = objects.filter((obj) => {\n\t\tif (obj[key] === value) {\n\t\t\tremovedObjects.push(obj);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t});\n\treturn [filteredObjects, removedObjects];\n}\n\n/**\n * Takes an input value and determines whether or not it is a number.\n *\n * @param {string | number} value - The value you would like to test against.\n *\n * @returns {boolean}\n */\nexport function isNumber(value: string | number): boolean {\n\tif (value === undefined || value === null) return false;\n\treturn isNaN(Number(value)) === false;\n}\n\nexport function isEmpty(str: string | undefined | null): boolean {\n\treturn !str || str?.length <= 0;\n}\n\n/**\n * Retrieves the keys from an enum and lists them in an array.\n *\n * @param {object} enumObject - The enum you wish to get the keys of.\n *\n * @returns {string[]}\n */\nexport function retrieveEnumKeys(enumObject: object): string[] {\n\tif (enumObject === undefined || enumObject === null) return new Array<string>(0);\n\treturn Object.keys(enumObject).filter((key) => !isNumber(key));\n}\n\n/**\n * Prints an array as a comma delimited list, with the last element being preceded by a conjunction.\n * As per ontario.ca content guidelines, there is no Oxford comma.\n *\n * @param {Array<any>} arr - The array that you wish to print.\n * @param {Conjunction} conjunctionType - Whether you want the sentence to end with 'and value.' or 'or value.'\n *\n * @returns {string}\n */\nexport function printArray(arr: Array<any>, conjunctionType: Conjunction = 'and'): string {\n\treturn [...arr].reduce(\n\t\t(text, value, i, array) => text + (i < array.length - 1 ? ', ' : ` ${conjunctionType} `) + value,\n\t);\n}\n\n/**\n * Grabs the HTML element of the page.\n *\n * More targetted than document.documentElement as the documentElement could\n * in theory be any element that is the top level. e.g. <div> if the page is not\n * set up to be semantically correct.\n *\n * @returns {HTMLElement}\n */\nexport function getRootHTMLElement(): HTMLElement {\n\treturn document.getElementsByTagName('html')[0];\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { format } from './utils';
1
+ import { format, isNumber, retrieveEnumKeys } from './utils';
2
2
  describe('format', () => {
3
3
  it('returns empty string for no names defined', () => {
4
4
  expect(format(undefined, undefined, undefined)).toEqual('');
@@ -13,4 +13,102 @@ describe('format', () => {
13
13
  expect(format('Joseph', 'Quincy', 'Publique')).toEqual('Joseph Quincy Publique');
14
14
  });
15
15
  });
16
+ describe('isNumber', () => {
17
+ it('should return false if value is undefined', () => {
18
+ const value = undefined;
19
+ const result = isNumber(value);
20
+ expect(result).toEqual(false);
21
+ });
22
+ it('should return false if value that is null', () => {
23
+ const value = null;
24
+ const result = isNumber(value);
25
+ expect(result).toEqual(false);
26
+ });
27
+ it('should return true if value is a number', () => {
28
+ const value = 2000;
29
+ const result = isNumber(value);
30
+ expect(result).toEqual(true);
31
+ });
32
+ it('should return true if value is a number as a string', () => {
33
+ const value = '2000';
34
+ const result = isNumber(value);
35
+ expect(result).toEqual(true);
36
+ });
37
+ it('should return false if value is not a number string', () => {
38
+ const value = 'two-thousand';
39
+ const result = isNumber(value);
40
+ expect(result).toEqual(false);
41
+ });
42
+ });
43
+ describe('isNumber', () => {
44
+ it('should return false if value is undefined', () => {
45
+ const value = undefined;
46
+ const result = isNumber(value);
47
+ expect(result).toEqual(false);
48
+ });
49
+ it('should return false if value that is null', () => {
50
+ const value = null;
51
+ const result = isNumber(value);
52
+ expect(result).toEqual(false);
53
+ });
54
+ it('should return true if value is a number', () => {
55
+ const value = 2000;
56
+ const result = isNumber(value);
57
+ expect(result).toEqual(true);
58
+ });
59
+ it('should return true if value is a number as a string', () => {
60
+ const value = '2000';
61
+ const result = isNumber(value);
62
+ expect(result).toEqual(true);
63
+ });
64
+ it('should return false if value is not a number string', () => {
65
+ const value = 'two-thousand';
66
+ const result = isNumber(value);
67
+ expect(result).toEqual(false);
68
+ });
69
+ });
70
+ var ColourEnumNumeric;
71
+ (function (ColourEnumNumeric) {
72
+ ColourEnumNumeric[(ColourEnumNumeric['RED'] = 0)] = 'RED';
73
+ ColourEnumNumeric[(ColourEnumNumeric['ORANGE'] = 1)] = 'ORANGE';
74
+ ColourEnumNumeric[(ColourEnumNumeric['YELLOW'] = 2)] = 'YELLOW';
75
+ ColourEnumNumeric[(ColourEnumNumeric['GREEN'] = 3)] = 'GREEN';
76
+ ColourEnumNumeric[(ColourEnumNumeric['BLUE'] = 4)] = 'BLUE';
77
+ ColourEnumNumeric[(ColourEnumNumeric['INDIGO'] = 5)] = 'INDIGO';
78
+ ColourEnumNumeric[(ColourEnumNumeric['VIOLET'] = 6)] = 'VIOLET';
79
+ })(ColourEnumNumeric || (ColourEnumNumeric = {}));
80
+ var ColourEnumString;
81
+ (function (ColourEnumString) {
82
+ ColourEnumString['red'] = 'Red';
83
+ ColourEnumString['orange'] = 'Orange';
84
+ ColourEnumString['yellow'] = 'Yellow';
85
+ ColourEnumString['green'] = 'Green';
86
+ ColourEnumString['blue'] = 'Blue';
87
+ ColourEnumString['indigo'] = 'Indigo';
88
+ ColourEnumString['violet'] = 'Violet';
89
+ })(ColourEnumString || (ColourEnumString = {}));
90
+ describe('retrieveEnumKeys', () => {
91
+ it('should return empty array if enumObject is undefined', () => {
92
+ const expectedResult = new Array(0);
93
+ const enumObject = undefined;
94
+ const result = retrieveEnumKeys(enumObject);
95
+ expect(result).toEqual(expectedResult);
96
+ });
97
+ it('should return empty array if enumObject is null', () => {
98
+ const expectedResult = new Array(0);
99
+ const enumObject = null;
100
+ const result = retrieveEnumKeys(enumObject);
101
+ expect(result).toEqual(expectedResult);
102
+ });
103
+ it('should return keys from numerical enum', () => {
104
+ const expectedResult = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'INDIGO', 'VIOLET'];
105
+ const result = retrieveEnumKeys(ColourEnumNumeric);
106
+ expect(result).toEqual(expectedResult);
107
+ });
108
+ it('should return keys from string enum', () => {
109
+ const expectedResult = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];
110
+ const result = retrieveEnumKeys(ColourEnumString);
111
+ expect(result).toEqual(expectedResult);
112
+ });
113
+ });
16
114
  //# sourceMappingURL=utils.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../../src/utils/helper/utils.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACnC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACvC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { format } from './utils';\n\ndescribe('format', () => {\n\tit('returns empty string for no names defined', () => {\n\t\texpect(format(undefined, undefined, undefined)).toEqual('');\n\t});\n\n\tit('formats just first names', () => {\n\t\texpect(format('Joseph', undefined, undefined)).toEqual('Joseph');\n\t});\n\n\tit('formats first and last names', () => {\n\t\texpect(format('Joseph', undefined, 'Publique')).toEqual('Joseph Publique');\n\t});\n\n\tit('formats first, middle and last names', () => {\n\t\texpect(format('Joseph', 'Quincy', 'Publique')).toEqual('Joseph Quincy Publique');\n\t});\n});\n"]}
1
+ {"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../../src/utils/helper/utils.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE7D,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACpD,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACnC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACvC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,i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AC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QACjD,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAExF,MAAM,MAAM,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QACnD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC9C,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAExF,MAAM,MAAM,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { format, isNumber, retrieveEnumKeys } from './utils';\n\ndescribe('format', () => {\n\tit('returns empty string for no names defined', () => {\n\t\texpect(format(undefined, undefined, undefined)).toEqual('');\n\t});\n\n\tit('formats just first names', () => {\n\t\texpect(format('Joseph', undefined, undefined)).toEqual('Joseph');\n\t});\n\n\tit('formats first and last names', () => {\n\t\texpect(format('Joseph', undefined, 'Publique')).toEqual('Joseph Publique');\n\t});\n\n\tit('formats first, middle and last names', () => {\n\t\texpect(format('Joseph', 'Quincy', 'Publique')).toEqual('Joseph Quincy Publique');\n\t});\n});\n\ndescribe('isNumber', () => {\n\tit('should return false if value is undefined', () => {\n\t\tconst value: any = undefined;\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(false);\n\t});\n\n\tit('should return false if value that is null', () => {\n\t\tconst value: any = null;\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(false);\n\t});\n\n\tit('should return true if value is a number', () => {\n\t\tconst value: number = 2000;\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(true);\n\t});\n\n\tit('should return true if value is a number as a string', () => {\n\t\tconst value: string = '2000';\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(true);\n\t});\n\n\tit('should return false if value is not a number string', () => {\n\t\tconst value: string = 'two-thousand';\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(false);\n\t});\n});\n\ndescribe('isNumber', () => {\n\tit('should return false if value is undefined', () => {\n\t\tconst value: any = undefined;\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(false);\n\t});\n\n\tit('should return false if value that is null', () => {\n\t\tconst value: any = null;\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(false);\n\t});\n\n\tit('should return true if value is a number', () => {\n\t\tconst value: number = 2000;\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(true);\n\t});\n\n\tit('should return true if value is a number as a string', () => {\n\t\tconst value: string = '2000';\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(true);\n\t});\n\n\tit('should return false if value is not a number string', () => {\n\t\tconst value: string = 'two-thousand';\n\n\t\tconst result = isNumber(value);\n\t\texpect(result).toEqual(false);\n\t});\n});\n\nenum ColourEnumNumeric {\n\tRED,\n\tORANGE,\n\tYELLOW,\n\tGREEN,\n\tBLUE,\n\tINDIGO,\n\tVIOLET,\n}\n\nenum ColourEnumString {\n\t'red' = 'Red',\n\t'orange' = 'Orange',\n\t'yellow' = 'Yellow',\n\t'green' = 'Green',\n\t'blue' = 'Blue',\n\t'indigo' = 'Indigo',\n\t'violet' = 'Violet',\n}\n\ndescribe('retrieveEnumKeys', () => {\n\tit('should return empty array if enumObject is undefined', () => {\n\t\tconst expectedResult = new Array<string>(0);\n\t\tconst enumObject: any = undefined;\n\n\t\tconst result = retrieveEnumKeys(enumObject);\n\t\texpect(result).toEqual(expectedResult);\n\t});\n\n\tit('should return empty array if enumObject is null', () => {\n\t\tconst expectedResult = new Array<string>(0);\n\t\tconst enumObject: any = null;\n\n\t\tconst result = retrieveEnumKeys(enumObject);\n\t\texpect(result).toEqual(expectedResult);\n\t});\n\n\tit('should return keys from numerical enum', () => {\n\t\tconst expectedResult = ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'INDIGO', 'VIOLET'];\n\n\t\tconst result = retrieveEnumKeys(ColourEnumNumeric);\n\t\texpect(result).toEqual(expectedResult);\n\t});\n\n\tit('should return keys from string enum', () => {\n\t\tconst expectedResult = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'];\n\n\t\tconst result = retrieveEnumKeys(ColourEnumString);\n\t\texpect(result).toEqual(expectedResult);\n\t});\n});\n"]}