@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.
- package/dist/cjs/app-globals-6f6b30a8.js.map +1 -1
- package/dist/cjs/index-88d5cf20.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{ontario-accordion_43.cjs.entry.js → ontario-accordion_44.cjs.entry.js} +358 -85
- package/dist/cjs/ontario-accordion_44.cjs.entry.js.map +1 -0
- package/dist/cjs/ontario-design-system-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/ontario-card/ontario-card-types.js +29 -2
- package/dist/collection/components/ontario-card/ontario-card-types.js.map +1 -1
- package/dist/collection/components/ontario-card/ontario-card.css +252 -34
- package/dist/collection/components/ontario-card/ontario-card.js +102 -78
- package/dist/collection/components/ontario-card/ontario-card.js.map +1 -1
- package/dist/collection/components/ontario-card/test/ontario-cards.spec.js +23 -13
- package/dist/collection/components/ontario-card/test/ontario-cards.spec.js.map +1 -1
- package/dist/collection/components/ontario-date-input/test/ontario-date-input.spec.js +58 -0
- package/dist/collection/components/ontario-date-input/test/ontario-date-input.spec.js.map +1 -1
- package/dist/collection/components/ontario-date-input/utils/date-validation-utils.js +14 -4
- package/dist/collection/components/ontario-date-input/utils/date-validation-utils.js.map +1 -1
- package/dist/collection/components/ontario-header/service-ontario-header.css +0 -3
- package/dist/collection/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
- package/dist/collection/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
- package/dist/collection/components/ontario-search-box/ontario-search-box.css +823 -0
- package/dist/collection/components/ontario-search-box/ontario-search-box.js +584 -0
- package/dist/collection/components/ontario-search-box/ontario-search-box.js.map +1 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js +20 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.e2e.js.map +1 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js +19 -0
- package/dist/collection/components/ontario-search-box/test/ontario-search-box.spec.js.map +1 -0
- package/dist/collection/components/ontario-step-indicator/ontario-step-indicator.js +5 -5
- package/dist/collection/components/ontario-table/ontario-table.js +5 -5
- package/dist/collection/components/ontario-textarea/ontario-textarea.js +3 -3
- package/dist/collection/fonts/open-sans-400/LICENSE.txt +0 -0
- package/dist/collection/fonts/open-sans-400/open-sans-400.eot +0 -0
- package/dist/collection/fonts/open-sans-400/open-sans-400.svg +0 -0
- package/dist/collection/fonts/open-sans-400/open-sans-400.ttf +0 -0
- package/dist/collection/fonts/open-sans-400/open-sans-400.woff +0 -0
- package/dist/collection/fonts/open-sans-400/open-sans-400.woff2 +0 -0
- package/dist/collection/fonts/open-sans-700/LICENSE.txt +0 -0
- package/dist/collection/fonts/open-sans-700/open-sans-700.eot +0 -0
- package/dist/collection/fonts/open-sans-700/open-sans-700.svg +0 -0
- package/dist/collection/fonts/open-sans-700/open-sans-700.ttf +0 -0
- package/dist/collection/utils/common/input/input.js +3 -0
- package/dist/collection/utils/common/input/input.js.map +1 -1
- package/dist/collection/utils/common/input-caption/input-caption.js +5 -3
- package/dist/collection/utils/common/input-caption/input-caption.js.map +1 -1
- package/dist/collection/utils/helper/utils.js +4 -2
- package/dist/collection/utils/helper/utils.js.map +1 -1
- package/dist/collection/utils/helper/utils.spec.js +99 -1
- package/dist/collection/utils/helper/utils.spec.js.map +1 -1
- package/dist/components/error-message.js +1 -324
- package/dist/components/error-message.js.map +1 -1
- package/dist/components/event-handler.js +330 -0
- package/dist/components/event-handler.js.map +1 -0
- package/dist/components/input.js +3 -0
- package/dist/components/input.js.map +1 -1
- package/dist/components/ontario-card.js +116 -64
- package/dist/components/ontario-card.js.map +1 -1
- package/dist/components/ontario-checkboxes.js +2 -1
- package/dist/components/ontario-checkboxes.js.map +1 -1
- package/dist/components/ontario-date-input.js +15 -4
- package/dist/components/ontario-date-input.js.map +1 -1
- package/dist/components/ontario-dropdown-list.js +2 -1
- package/dist/components/ontario-dropdown-list.js.map +1 -1
- package/dist/components/ontario-header.js +4 -6
- package/dist/components/ontario-header.js.map +1 -1
- package/dist/components/ontario-icon-search2.js +6 -0
- package/dist/components/ontario-icon-search2.js.map +1 -0
- package/dist/components/ontario-input.js +2 -1
- package/dist/components/ontario-input.js.map +1 -1
- package/dist/components/ontario-radio-buttons.js +2 -1
- package/dist/components/ontario-radio-buttons.js.map +1 -1
- package/dist/components/ontario-search-box.d.ts +11 -0
- package/dist/components/ontario-search-box.js +269 -0
- package/dist/components/ontario-search-box.js.map +1 -0
- package/dist/components/ontario-step-indicator.js +5 -5
- package/dist/components/ontario-table.js +5 -5
- package/dist/components/ontario-textarea.js +5 -4
- package/dist/components/ontario-textarea.js.map +1 -1
- package/dist/components/utils.js +4 -2
- package/dist/components/utils.js.map +1 -1
- package/dist/esm/app-globals-70748594.js.map +1 -1
- package/dist/esm/index-603026f7.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{ontario-accordion_43.entry.js → ontario-accordion_44.entry.js} +358 -85
- package/dist/esm/ontario-accordion_44.entry.js.map +1 -0
- package/dist/esm/ontario-design-system-components.js +1 -1
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-400/LICENSE.txt +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.eot +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.svg +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.ttf +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.woff +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-400/open-sans-400.woff2 +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-700/LICENSE.txt +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.eot +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.svg +0 -0
- package/dist/ontario-design-system-components/fonts/open-sans-700/open-sans-700.ttf +0 -0
- package/dist/ontario-design-system-components/ontario-design-system-components.esm.js +1 -1
- package/dist/ontario-design-system-components/ontario-design-system-components.esm.js.map +1 -1
- package/dist/ontario-design-system-components/p-103a233b.js.map +1 -1
- package/dist/ontario-design-system-components/{p-abe58ec9.entry.js → p-ac4e76b2.entry.js} +1927 -1728
- package/dist/ontario-design-system-components/p-ac4e76b2.entry.js.map +1 -0
- package/dist/types/components/ontario-card/ontario-card-types.d.ts +4 -4
- package/dist/types/components/ontario-card/ontario-card.d.ts +40 -29
- package/dist/types/components/ontario-date-input/utils/date-validation-utils.d.ts +14 -0
- package/dist/types/components/ontario-search-box/ontario-search-box.d.ts +180 -0
- package/dist/types/components.d.ts +199 -16
- package/dist/types/utils/common/input/input.d.ts +2 -1
- package/dist/types/utils/common/input-caption/input-caption.d.ts +7 -1
- package/package.json +3 -3
- package/src/components/ontario-card/ontario-card-types.tsx +33 -4
- package/src/components/ontario-card/ontario-card.scss +54 -40
- package/src/components/ontario-card/ontario-card.tsx +94 -68
- package/src/components/ontario-card/readme.md +57 -27
- package/src/components/ontario-card/test/__snapshots__/ontario-cards.spec.tsx.snap +66 -0
- package/src/components/ontario-card/test/ontario-cards.spec.tsx +27 -13
- package/src/components/ontario-card-collection/readme.md +13 -13
- package/src/components/ontario-checkbox/ontario-checkboxes.scss +0 -1
- package/src/components/ontario-date-input/test/ontario-date-input.spec.tsx +76 -0
- package/src/components/ontario-date-input/utils/date-validation-utils.ts +18 -4
- package/src/components/ontario-header/service-ontario-header.scss +0 -4
- package/src/components/ontario-hint-text/readme.md +2 -0
- package/src/components/ontario-radio-buttons/ontario-radio-buttons.scss +0 -1
- package/src/components/ontario-search-box/assets/ontario-icon-close.svg +1 -0
- package/src/components/ontario-search-box/assets/ontario-logo--mobile.svg +6 -0
- package/src/components/ontario-search-box/ontario-search-box.scss +141 -0
- package/src/components/ontario-search-box/ontario-search-box.tsx +341 -0
- package/src/components/ontario-search-box/readme.md +132 -0
- package/src/components/ontario-search-box/test/__snapshots__/ontario-search-box.spec.tsx.snap +35 -0
- package/src/components/ontario-search-box/test/ontario-search-box.e2e.ts +21 -0
- package/src/components/ontario-search-box/test/ontario-search-box.spec.tsx +22 -0
- package/src/components.d.ts +199 -16
- package/src/config.json +1 -4
- package/src/index.html +287 -52
- package/src/utils/common/input/input.tsx +4 -1
- package/src/utils/common/input-caption/input-caption.tsx +9 -3
- package/src/utils/helper/utils.spec.ts +127 -1
- package/src/utils/helper/utils.ts +4 -2
- package/www/build/ontario-design-system-components.esm.js +1 -1
- package/www/build/ontario-design-system-components.esm.js.map +1 -1
- package/www/build/p-103a233b.js.map +1 -1
- package/www/build/{p-abe58ec9.entry.js → p-ac4e76b2.entry.js} +1927 -1728
- package/www/build/p-ac4e76b2.entry.js.map +1 -0
- package/www/build/{p-fdc9ab6d.js → p-c9a9b857.js} +1 -1
- package/www/fonts/open-sans-400/LICENSE.txt +0 -0
- package/www/fonts/open-sans-400/open-sans-400.eot +0 -0
- package/www/fonts/open-sans-400/open-sans-400.svg +0 -0
- package/www/fonts/open-sans-400/open-sans-400.ttf +0 -0
- package/www/fonts/open-sans-400/open-sans-400.woff +0 -0
- package/www/fonts/open-sans-400/open-sans-400.woff2 +0 -0
- package/www/fonts/open-sans-700/LICENSE.txt +0 -0
- package/www/fonts/open-sans-700/open-sans-700.eot +0 -0
- package/www/fonts/open-sans-700/open-sans-700.svg +0 -0
- package/www/fonts/open-sans-700/open-sans-700.ttf +0 -0
- package/www/index.html +261 -52
- package/dist/cjs/ontario-accordion_43.cjs.entry.js.map +0 -1
- package/dist/esm/ontario-accordion_43.entry.js.map +0 -1
- package/dist/ontario-design-system-components/p-abe58ec9.entry.js.map +0 -1
- package/www/build/p-abe58ec9.entry.js.map +0 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ontario-card renders 1`] = `
|
|
4
|
+
<ontario-card>
|
|
5
|
+
<mock:shadow-root>
|
|
6
|
+
<li class="ontario-card ontario-card--position-vertical ontario-card__card-type--basic ontario-card__description-false">
|
|
7
|
+
<div class="ontario-card__text-container">
|
|
8
|
+
<h2 class="ontario-card__heading">
|
|
9
|
+
<a href="#"></a>
|
|
10
|
+
</h2>
|
|
11
|
+
</div>
|
|
12
|
+
</li>
|
|
13
|
+
</mock:shadow-root>
|
|
14
|
+
</ontario-card>
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
exports[`ontario-card should render a description 1`] = `
|
|
18
|
+
<ontario-card description="Lorem ipsum">
|
|
19
|
+
<mock:shadow-root>
|
|
20
|
+
<li class="ontario-card ontario-card--position-vertical ontario-card__card-type--basic">
|
|
21
|
+
<div class="ontario-card__text-container">
|
|
22
|
+
<h2 class="ontario-card__heading">
|
|
23
|
+
<a href="#"></a>
|
|
24
|
+
</h2>
|
|
25
|
+
<div class="ontario-card__description">
|
|
26
|
+
<p>
|
|
27
|
+
Lorem ipsum
|
|
28
|
+
</p>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</li>
|
|
32
|
+
</mock:shadow-root>
|
|
33
|
+
</ontario-card>
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
exports[`ontario-card should render a header colour on the label 1`] = `
|
|
37
|
+
<ontario-card header-colour="sky" label="Card Title 1">
|
|
38
|
+
<mock:shadow-root>
|
|
39
|
+
<li class="ontario-card ontario-card--position-vertical ontario-card__background--sky ontario-card__card-type--basic ontario-card__description-false">
|
|
40
|
+
<div class="ontario-card__text-container">
|
|
41
|
+
<h2 class="ontario-card__heading ontario-card__heading--sky">
|
|
42
|
+
<a href="#">
|
|
43
|
+
Card Title 1
|
|
44
|
+
</a>
|
|
45
|
+
</h2>
|
|
46
|
+
</div>
|
|
47
|
+
</li>
|
|
48
|
+
</mock:shadow-root>
|
|
49
|
+
</ontario-card>
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
exports[`ontario-card should render a label 1`] = `
|
|
53
|
+
<ontario-card label="Card Title 1">
|
|
54
|
+
<mock:shadow-root>
|
|
55
|
+
<li class="ontario-card ontario-card--position-vertical ontario-card__card-type--basic ontario-card__description-false">
|
|
56
|
+
<div class="ontario-card__text-container">
|
|
57
|
+
<h2 class="ontario-card__heading">
|
|
58
|
+
<a href="#">
|
|
59
|
+
Card Title 1
|
|
60
|
+
</a>
|
|
61
|
+
</h2>
|
|
62
|
+
</div>
|
|
63
|
+
</li>
|
|
64
|
+
</mock:shadow-root>
|
|
65
|
+
</ontario-card>
|
|
66
|
+
`;
|
|
@@ -7,18 +7,32 @@ describe('ontario-card', () => {
|
|
|
7
7
|
components: [OntarioCard],
|
|
8
8
|
html: `<ontario-card></ontario-card>`,
|
|
9
9
|
});
|
|
10
|
-
expect(page.root).
|
|
11
|
-
<ontario-card>
|
|
12
|
-
<mock:shadow-root>
|
|
13
|
-
<li class="ontario-card ontario-card__card-type--basic ontario-card__header-type--default ontario-card__description-false">
|
|
14
|
-
<div class="ontario-card__text-container">
|
|
15
|
-
<h2 class="ontario-card__heading">
|
|
16
|
-
<a href="#"></a>
|
|
17
|
-
</h2>
|
|
18
|
-
</div>
|
|
19
|
-
</li>
|
|
20
|
-
</mock:shadow-root>
|
|
21
|
-
</ontario-card>
|
|
22
|
-
`);
|
|
10
|
+
expect(page.root).toMatchSnapshot();
|
|
23
11
|
});
|
|
12
|
+
|
|
13
|
+
it('should render a label', async () => {
|
|
14
|
+
const page = await newSpecPage({
|
|
15
|
+
components: [OntarioCard],
|
|
16
|
+
html: `<ontario-card label="Card Title 1"></ontario-card>`,
|
|
17
|
+
});
|
|
18
|
+
expect(page.root).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should render a header colour on the label', async () => {
|
|
22
|
+
const page = await newSpecPage({
|
|
23
|
+
components: [OntarioCard],
|
|
24
|
+
html: `<ontario-card label="Card Title 1" header-colour="sky"></ontario-card>`,
|
|
25
|
+
});
|
|
26
|
+
expect(page.root).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should render a description', async () => {
|
|
30
|
+
const page = await newSpecPage({
|
|
31
|
+
components: [OntarioCard],
|
|
32
|
+
html: `<ontario-card description="Lorem ipsum"></ontario-card>`,
|
|
33
|
+
});
|
|
34
|
+
expect(page.root).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Don't think we can test images unless we point to a local path
|
|
24
38
|
});
|
|
@@ -20,9 +20,9 @@ Example of a bare-bones `ontario-card-collection` component, with a `cardsPerRow
|
|
|
20
20
|
```html
|
|
21
21
|
<ontario-card-collection cards-per-row="2">
|
|
22
22
|
<ontario-card
|
|
23
|
-
|
|
23
|
+
layout="horizontal"
|
|
24
24
|
label="Card Title 1"
|
|
25
|
-
image="https://picsum.photos/
|
|
25
|
+
image="https://picsum.photos/300/225"
|
|
26
26
|
card-link="https://google.ca"
|
|
27
27
|
horizontal-image-position-type="left"
|
|
28
28
|
horizontal-image-size-type="one-fourth"
|
|
@@ -30,9 +30,9 @@ Example of a bare-bones `ontario-card-collection` component, with a `cardsPerRow
|
|
|
30
30
|
>
|
|
31
31
|
</ontario-card>
|
|
32
32
|
<ontario-card
|
|
33
|
-
|
|
33
|
+
layout="horizontal"
|
|
34
34
|
label="Card Title 2"
|
|
35
|
-
image="https://picsum.photos/
|
|
35
|
+
image="https://picsum.photos/300/225"
|
|
36
36
|
horizontal-image-position-type="left"
|
|
37
37
|
horizontal-image-size-type="one-fourth"
|
|
38
38
|
description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
|
|
@@ -43,21 +43,21 @@ Example of a bare-bones `ontario-card-collection` component, with a `cardsPerRow
|
|
|
43
43
|
|
|
44
44
|
<OntarioCardCollection cards-per-row="2">
|
|
45
45
|
<OntarioCard
|
|
46
|
-
|
|
46
|
+
layout="horizontal"
|
|
47
47
|
label="Card Title 1"
|
|
48
|
-
image="https://picsum.photos/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
image="https://picsum.photos/300/225"
|
|
49
|
+
cardLink="https://google.ca"
|
|
50
|
+
horizontalImagePositionType="left"
|
|
51
|
+
horizontalImageSizeType="one-fourth"
|
|
52
52
|
description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
|
|
53
53
|
>
|
|
54
54
|
</OntarioCard>
|
|
55
55
|
<OntarioCard
|
|
56
|
-
|
|
56
|
+
layout="horizontal"
|
|
57
57
|
label="Card Title 2"
|
|
58
|
-
image="https://picsum.photos/
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
image="https://picsum.photos/300/225"
|
|
59
|
+
horizontalImagePositionType="left"
|
|
60
|
+
horizontalImageSizeType="one-fourth"
|
|
61
61
|
description="Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum"
|
|
62
62
|
>
|
|
63
63
|
</OntarioCard>
|
|
@@ -16,7 +16,6 @@ $ontario-checkboxes-size: globalFunctions.px-to-rem(28);
|
|
|
16
16
|
$ontario-checkboxes-size-mobile: globalFunctions.px-to-rem(32);
|
|
17
17
|
$ontario-checkbox-border-size: globalFunctions.px-to-rem(2);
|
|
18
18
|
$ontario-checkbox-box-shadow-outline: globalFunctions.px-to-rem(4);
|
|
19
|
-
$ontario-input-border-width: 0.125rem;
|
|
20
19
|
|
|
21
20
|
:host {
|
|
22
21
|
--checkbox-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M0 2.667C0 1.194 1.194 0 2.667 0h18.667C22.806 0 24 1.194 24 2.667v18.667C24 22.806 22.806 24 21.333 24H2.667C1.194 24 0 22.806 0 21.333V2.667z' fill='%231a1a1a'/%3E%3Cpath d='M2.667 12.616l6.667 6.718 12-12.092-1.88-1.908L9.333 15.53l-4.787-4.8-1.88 1.894z' fill='%23fff'/%3E%3C/svg%3E");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { newSpecPage } from '@stencil/core/testing';
|
|
2
2
|
import { OntarioDateInput } from '../ontario-date-input';
|
|
3
|
+
import { isInvalidYear } from '../utils';
|
|
3
4
|
|
|
4
5
|
describe('ontario-date-input', () => {
|
|
5
6
|
it('renders deafult state', async () => {
|
|
@@ -120,3 +121,78 @@ describe('ontario-date-input', () => {
|
|
|
120
121
|
`);
|
|
121
122
|
});
|
|
122
123
|
});
|
|
124
|
+
|
|
125
|
+
describe('date-validation-utils', () => {
|
|
126
|
+
it('is invalid year value - undefined string', () => {
|
|
127
|
+
// Note: Type system doesn't like `undefined` as `any` lets us force it for testing purposes
|
|
128
|
+
const value: any = undefined;
|
|
129
|
+
|
|
130
|
+
const isInvalidYearResult = isInvalidYear(value);
|
|
131
|
+
expect(isInvalidYearResult).toEqual(true);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('is invalid year value - null string', () => {
|
|
135
|
+
// Note: Type system doesn't like `null` as `any` lets us force it for testing purposes
|
|
136
|
+
const value: any = null;
|
|
137
|
+
|
|
138
|
+
const isInvalidYearResult = isInvalidYear(value);
|
|
139
|
+
expect(isInvalidYearResult).toEqual(true);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('is invalid year value - empty string', () => {
|
|
143
|
+
const value = ''; // Empty string
|
|
144
|
+
|
|
145
|
+
const isInvalidYearResult = isInvalidYear(value);
|
|
146
|
+
expect(isInvalidYearResult).toEqual(true);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('is invalid year value - written out number', () => {
|
|
150
|
+
const value = 'two-thousand';
|
|
151
|
+
|
|
152
|
+
const isInvalidYearResult = isInvalidYear(value);
|
|
153
|
+
expect(isInvalidYearResult).toEqual(true);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('is valid year value', () => {
|
|
157
|
+
const value = '2000';
|
|
158
|
+
|
|
159
|
+
const isValidYear = !isInvalidYear(value);
|
|
160
|
+
expect(isValidYear).toEqual(true);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('is valid year when in range', () => {
|
|
164
|
+
const value = '2000';
|
|
165
|
+
const minYear = 1;
|
|
166
|
+
const maxYear = 9999;
|
|
167
|
+
|
|
168
|
+
const isValidYear = !isInvalidYear(value, minYear, maxYear);
|
|
169
|
+
expect(isValidYear).toEqual(true);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('is valid year when in range but is minYear', () => {
|
|
173
|
+
const value = '2000';
|
|
174
|
+
const minYear = 2000;
|
|
175
|
+
const maxYear = 9999;
|
|
176
|
+
|
|
177
|
+
const isValidYear = !isInvalidYear(value, minYear, maxYear);
|
|
178
|
+
expect(isValidYear).toEqual(true);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('is valid year when in range but is maxYear', () => {
|
|
182
|
+
const value = '2000';
|
|
183
|
+
const minYear = 1;
|
|
184
|
+
const maxYear = 2000;
|
|
185
|
+
|
|
186
|
+
const isValidYear = !isInvalidYear(value, minYear, maxYear);
|
|
187
|
+
expect(isValidYear).toEqual(true);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('is invalid year when out of range', () => {
|
|
191
|
+
const value = '2000';
|
|
192
|
+
const minYear = 1;
|
|
193
|
+
const maxYear = 1999;
|
|
194
|
+
|
|
195
|
+
const isValidYear = !isInvalidYear(value, minYear, maxYear);
|
|
196
|
+
expect(isValidYear).toEqual(false);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
@@ -35,17 +35,31 @@ const isInvalidMonth = (value: string) => {
|
|
|
35
35
|
return month < MONTH_MIN_VALUE || month > MONTH_MAX_VALUE;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
*
|
|
38
|
+
/**
|
|
39
|
+
* Valid value year against minimum and maximum year range (defaulted if not provided.)
|
|
40
|
+
*
|
|
41
|
+
* Year field should be a number and not written out; it has no concept of positive and negative.
|
|
42
|
+
*
|
|
43
|
+
* Suggestion:
|
|
44
|
+
* - `< 0` B.C.E.
|
|
45
|
+
* - `>= 0` A.C.E.
|
|
46
|
+
*
|
|
47
|
+
* @param value value to check for validity
|
|
48
|
+
* @param minYear minimum valid year to validate against
|
|
49
|
+
* @param maxYear maximum valid year to validate against
|
|
40
50
|
*/
|
|
41
|
-
const isInvalidYear = (
|
|
51
|
+
export const isInvalidYear = (
|
|
52
|
+
value: string | number,
|
|
53
|
+
minYear: number = YEAR_MIN_VALUE,
|
|
54
|
+
maxYear: number = YEAR_MAX_VALUE,
|
|
55
|
+
) => {
|
|
42
56
|
if (!isNumber(value)) {
|
|
43
57
|
return true;
|
|
44
58
|
}
|
|
45
59
|
|
|
46
60
|
const year = Number(value);
|
|
47
61
|
|
|
48
|
-
return year
|
|
62
|
+
return year < minYear || year > maxYear;
|
|
49
63
|
};
|
|
50
64
|
|
|
51
65
|
type GetDateErrorArg = {
|
|
@@ -67,6 +67,7 @@ Promise<string | undefined>
|
|
|
67
67
|
- [ontario-dropdown-list](../ontario-dropdown-list)
|
|
68
68
|
- [ontario-input](../ontario-input)
|
|
69
69
|
- [ontario-radio-buttons](../ontario-radio-buttons)
|
|
70
|
+
- [ontario-search-box](../ontario-search-box)
|
|
70
71
|
- [ontario-textarea](../ontario-textarea)
|
|
71
72
|
|
|
72
73
|
### Graph
|
|
@@ -77,6 +78,7 @@ graph TD;
|
|
|
77
78
|
ontario-dropdown-list --> ontario-hint-text
|
|
78
79
|
ontario-input --> ontario-hint-text
|
|
79
80
|
ontario-radio-buttons --> ontario-hint-text
|
|
81
|
+
ontario-search-box --> ontario-hint-text
|
|
80
82
|
ontario-textarea --> ontario-hint-text
|
|
81
83
|
style ontario-hint-text fill:#f9f,stroke:#333,stroke-width:4px
|
|
82
84
|
```
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
$ontario-radios-size: 32px;
|
|
20
20
|
$ontario-radios-size-mobile: 36px;
|
|
21
21
|
$ontario-input-offset: math.div((globalVariables.$touch-target-size - $ontario-radios-size), 2);
|
|
22
|
-
$ontario-input-border-width: 0.125rem;
|
|
23
22
|
|
|
24
23
|
.ontario-radios__item {
|
|
25
24
|
position: relative;
|
|
@@ -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>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="46" height="46" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 46 46" fill="none" xmlns:v="https://vecta.io/nano" tabindex="-1">
|
|
2
|
+
<path d="M23 0C7.36 0 0 7.36 0 23s7.36 23 23 23 23-7.36 23-23S38.64 0 23 0" fill="#fff" />
|
|
3
|
+
<path fill-rule="evenodd"
|
|
4
|
+
d="M23 13.223c4.728-3.178 10.58-3.613 15.69-1.153l.18.128-.026.18a16.08 16.08 0 0 1-2.07 6.765c-1.405 2.41-3.4 4.408-5.8 5.79h-.025a15.71 15.71 0 0 0-.365.191c-.188.1-.38.203-.58.296.383 5.69-2.172 10.994-6.85 14.197L23 39.72l-.153-.102a15.76 15.76 0 0 1-4.805-5.176 16.12 16.12 0 0 1-2.095-7.944v-.026c0-.333.025-.692.05-1.05-5.086-2.51-8.382-7.38-8.817-13.043l-.026-.18.153-.077c2.147-1.05 4.523-1.59 6.874-1.59 2.786 0 5.494.743 7.897 2.127h.026a17.21 17.21 0 0 1 .895.564zm5.93 8.56c1.763-1.025 3.27-2.46 4.37-4.33.51-.897.894-1.82 1.176-2.69-2.888-.666-5.8-.23-8.433 1.204.23.307.383.64.537 1.076s.18 1.025.05 1.512c-.05.205-.153.4-.256.615h0c-.51.87-1.584 1.512-2.913 1.922.51-1.59-.307-2.998-1.33-3.895-.51-.46-1.1-.846-1.687-1.204a12.29 12.29 0 0 0-5.929-1.614 12.52 12.52 0 0 0-2.964.359c.894 2.844 2.71 5.15 5.265 6.714.153-.36.358-.64.664-1s.792-.666 1.278-.794a2.94 2.94 0 0 1 .664-.077c.997 0 2.096.615 3.118 1.563-1.6.36-2.428 1.768-2.683 3.1-.128.692-.204 1.384-.204 2.076 0 2.024.486 4.075 1.56 5.945.486.87 1.125 1.69 1.79 2.383 2.02-2.204 3.092-4.946 3.17-7.944-.41.05-.74 0-1.2-.077s-.97-.384-1.33-.718c-.153-.154-.307-.333-.41-.538-.51-.897-.51-2.153-.204-3.51 1.124 1.23 2.734 1.256 4.012.794a10.52 10.52 0 0 0 1.891-.871z"
|
|
5
|
+
fill="#000" />
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/1-variables/global.variables' as globalVariables;
|
|
3
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/1-variables/spacing.variables' as spacing;
|
|
4
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/1-variables/colours.variables' as colours;
|
|
5
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/1-variables/breakpoints.variables' as breakpoints;
|
|
6
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/1-variables/typography.variables' as typography;
|
|
7
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/1-variables/line-heights.variables' as lineheight;
|
|
8
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/1-variables/font-weights.variables' as fontWeights;
|
|
9
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/2-tools/functions/global.functions' as globalFunctions;
|
|
10
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/2-tools/placeholder/focus.placeholders' as
|
|
11
|
+
focusPlaceholders;
|
|
12
|
+
@use '@ongov/ontario-design-system-global-styles/dist/styles/scss/4-elements/_global.elements.scss';
|
|
13
|
+
@use '../../styles/form.scss';
|
|
14
|
+
|
|
15
|
+
$ontario-input-height: globalFunctions.px-to-rem(48);
|
|
16
|
+
$ontario-search-icon-size: 2rem;
|
|
17
|
+
$ontario-reset-icon-size: 1.5rem;
|
|
18
|
+
$ontario-search-button-width: 5rem;
|
|
19
|
+
$ontario-search-button-width--mobile: 3rem;
|
|
20
|
+
$ontario-search-input-padding: 8.5rem;
|
|
21
|
+
$ontario-search-input-padding--mobile: 7.75rem;
|
|
22
|
+
$ontario-search-desktop-width: 34rem;
|
|
23
|
+
$ontario-search-mobile-width: 20.5rem;
|
|
24
|
+
|
|
25
|
+
.ontario-search__container {
|
|
26
|
+
max-width: $ontario-search-desktop-width;
|
|
27
|
+
margin-bottom: spacing.$spacing-7;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.ontario-search__input-container {
|
|
31
|
+
position: relative;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ontario-search__input.ontario-input {
|
|
35
|
+
border: 2px solid colours.$ontario-colour-black;
|
|
36
|
+
margin-bottom: spacing.$spacing-0;
|
|
37
|
+
height: $ontario-input-height;
|
|
38
|
+
padding-left: spacing.$spacing-3;
|
|
39
|
+
padding-right: $ontario-search-input-padding;
|
|
40
|
+
width: 100%;
|
|
41
|
+
|
|
42
|
+
&:invalid + input[type='reset'] {
|
|
43
|
+
display: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&:focus {
|
|
47
|
+
@extend %ontario-focus;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
input[type='reset'].ontario-search__reset {
|
|
52
|
+
position: absolute;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
top: spacing.$spacing-3;
|
|
56
|
+
right: $ontario-search-button-width + spacing.$spacing-4;
|
|
57
|
+
height: $ontario-reset-icon-size;
|
|
58
|
+
width: $ontario-reset-icon-size;
|
|
59
|
+
color: colours.$ontario-colour-black;
|
|
60
|
+
margin: spacing.$spacing-0;
|
|
61
|
+
padding: spacing.$spacing-1;
|
|
62
|
+
background-size: $ontario-reset-icon-size;
|
|
63
|
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+PHBhdGggZD0iTTE5IDYuNEwxNy42IDUgMTIgMTAuNiA2LjQgNSA1IDYuNGw1LjYgNS42TDUgMTcuNiA2LjQgMTlsNS42LTUuNiA1LjYgNS42IDEuNC0xLjQtNS42LTUuNkwxOSA2LjR6IiBmaWxsPSIjMDAwIi8+PC9zdmc+);
|
|
64
|
+
background-position: center center;
|
|
65
|
+
background-repeat: no-repeat;
|
|
66
|
+
background-color: transparent;
|
|
67
|
+
outline: none;
|
|
68
|
+
border: none;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
|
|
71
|
+
&:focus {
|
|
72
|
+
box-shadow: inset 0 0 0 globalVariables.$global-radius colours.$ontario-colour-focus;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@media screen and (max-width: breakpoints.$small-breakpoint) {
|
|
76
|
+
right: $ontario-search-button-width--mobile + spacing.$spacing-7;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.ontario-search__submit {
|
|
81
|
+
border: 0;
|
|
82
|
+
border-radius: 0 3px 3px 0;
|
|
83
|
+
background-color: colours.$ontario-colour-link;
|
|
84
|
+
color: colours.$ontario-colour-black;
|
|
85
|
+
|
|
86
|
+
display: flex;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
align-items: center;
|
|
89
|
+
|
|
90
|
+
font-family: typography.$ontario-font-open-sans;
|
|
91
|
+
font-weight: fontWeights.$ontario-font-weights-semi-bold;
|
|
92
|
+
font-size: 1.125rem;
|
|
93
|
+
width: $ontario-search-button-width;
|
|
94
|
+
line-height: lineheight.$ontario-line-height-8;
|
|
95
|
+
|
|
96
|
+
position: absolute;
|
|
97
|
+
right: spacing.$spacing-0;
|
|
98
|
+
bottom: spacing.$spacing-0;
|
|
99
|
+
top: spacing.$spacing-0;
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
|
|
102
|
+
&:hover {
|
|
103
|
+
background-color: colours.$ontario-colour-link--hover;
|
|
104
|
+
color: colours.$ontario-colour-white;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&:focus {
|
|
108
|
+
outline: none;
|
|
109
|
+
box-shadow: 0 0 0 globalVariables.$global-radius colours.$ontario-colour-focus;
|
|
110
|
+
background-color: colours.$ontario-colour-link--hover;
|
|
111
|
+
color: colours.$ontario-colour-white;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&:active {
|
|
115
|
+
background-color: colours.$ontario-colour-link--active;
|
|
116
|
+
color: colours.$ontario-colour-white;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
svg {
|
|
120
|
+
fill: colours.$ontario-colour-white;
|
|
121
|
+
margin-right: spacing.$spacing-0;
|
|
122
|
+
margin-bottom: spacing.$spacing-0;
|
|
123
|
+
width: $ontario-search-icon-size;
|
|
124
|
+
height: $ontario-search-icon-size;
|
|
125
|
+
display: inline-block;
|
|
126
|
+
vertical-align: middle;
|
|
127
|
+
overflow: hidden;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@media screen and (max-width: breakpoints.$small-breakpoint) {
|
|
131
|
+
width: $ontario-search-button-width--mobile;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// remove default cancel button for input with type="search"
|
|
136
|
+
input[type='search'].ontario-search__input::-webkit-search-decoration,
|
|
137
|
+
input[type='search'].ontario-search__input::-webkit-search-cancel-button,
|
|
138
|
+
input[type='search'].ontario-search__input::-webkit-search-results-button,
|
|
139
|
+
input[type='search'].ontario-search__input::-webkit-search-results-decoration {
|
|
140
|
+
-webkit-appearance: none;
|
|
141
|
+
}
|