@transferwise/components 46.13.0 → 46.14.0
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/build/index.esm.js +175 -346
- package/build/index.esm.js.map +1 -1
- package/build/index.js +148 -319
- package/build/index.js.map +1 -1
- package/build/main.css +6 -82
- package/build/styles/decision/Decision.css +6 -82
- package/build/styles/main.css +6 -82
- package/build/types/body/Body.d.ts +1 -1
- package/build/types/common/commonProps.d.ts +1 -1
- package/build/types/common/commonProps.d.ts.map +1 -1
- package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts +1 -1
- package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts.map +1 -1
- package/build/types/common/dateUtils/getDayNames/index.d.ts +1 -1
- package/build/types/common/dateUtils/getDayNames/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts +1 -1
- package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts.map +1 -1
- package/build/types/common/dateUtils/getMonthNames/index.d.ts +1 -1
- package/build/types/common/dateUtils/getMonthNames/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/index.d.ts +6 -6
- package/build/types/common/dateUtils/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isDateValid/index.d.ts +1 -1
- package/build/types/common/dateUtils/isDateValid/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts +2 -2
- package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts.map +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/index.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/index.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
- package/build/types/common/panel/Panel.d.ts +1 -1
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts +1 -1
- package/build/types/dateInput/DateInput.d.ts +30 -41
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/dateInput/DateInput.messages.d.ts +24 -33
- package/build/types/dateInput/DateInput.messages.d.ts.map +1 -1
- package/build/types/dateInput/index.d.ts +2 -2
- package/build/types/dateInput/index.d.ts.map +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts.map +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts.map +1 -1
- package/build/types/dateInput/utils/index.d.ts +1 -2
- package/build/types/dateInput/utils/index.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +1 -0
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/decision/Decision.d.ts +39 -52
- package/build/types/decision/Decision.d.ts.map +1 -1
- package/build/types/decision/index.d.ts +1 -2
- package/build/types/decision/index.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/promoCard/PromoCard.d.ts +1 -2
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/select/searchBox/SearchBox.d.ts +1 -1
- package/package.json +1 -1
- package/src/common/commonProps.ts +1 -1
- package/src/common/dateUtils/getDayNames/getDayNames.spec.js +2 -2
- package/src/common/dateUtils/getDayNames/{getDayNames.js → getDayNames.ts} +5 -2
- package/src/common/dateUtils/getMonthNames/getMonthNames.spec.js +9 -8
- package/src/common/dateUtils/getMonthNames/{getMonthNames.js → getMonthNames.ts} +5 -3
- package/src/common/dateUtils/isDateValid/{isDateValid.spec.js → isDateValid.spec.ts} +1 -1
- package/src/common/dateUtils/isDateValid/isDateValid.ts +13 -0
- package/src/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.spec.js +3 -7
- package/src/common/dateUtils/isMonthAndYearFormat/{isMonthAndYearFormat.js → isMonthAndYearFormat.ts} +1 -1
- package/src/common/dateUtils/isWithinRange/{isWithinRange.spec.js → isWithinRange.spec.ts} +0 -10
- package/src/common/dateUtils/isWithinRange/{isWithinRange.js → isWithinRange.ts} +1 -1
- package/src/common/dateUtils/moveToWithinRange/{moveToWithinRange.js → moveToWithinRange.ts} +2 -2
- package/src/dateInput/DateInput.spec.js +7 -56
- package/src/dateInput/DateInput.story.tsx +11 -8
- package/src/dateInput/{DateInput.js → DateInput.tsx} +116 -123
- package/src/dateInput/index.ts +2 -0
- package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.js → convertToLocalMidnight.ts} +1 -1
- package/src/dateInput/utils/{index.js → index.ts} +0 -1
- package/src/dateLookup/DateLookup.js +12 -1
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +12 -1
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +1 -0
- package/src/decision/Decision.css +6 -82
- package/src/decision/Decision.less +3 -41
- package/src/decision/Decision.spec.js +56 -61
- package/src/decision/{Decision.story.js → Decision.story.tsx} +5 -5
- package/src/decision/Decision.tsx +133 -0
- package/src/decision/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/main.css +6 -82
- package/src/promoCard/PromoCard.tsx +1 -2
- package/src/tile/Tile.js +1 -1
- package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts +0 -6
- package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts.map +0 -1
- package/build/types/dateInput/utils/explodeDate/index.d.ts +0 -2
- package/build/types/dateInput/utils/explodeDate/index.d.ts.map +0 -1
- package/build/types/decision/decisionEnums.d.ts +0 -9
- package/build/types/decision/decisionEnums.d.ts.map +0 -1
- package/build/types/sizeSwapper/SizeSwapper.d.ts +0 -3
- package/build/types/sizeSwapper/SizeSwapper.d.ts.map +0 -1
- package/build/types/sizeSwapper/index.d.ts +0 -2
- package/build/types/sizeSwapper/index.d.ts.map +0 -1
- package/src/common/dateUtils/isDateValid/isDateValid.js +0 -6
- package/src/dateInput/index.js +0 -3
- package/src/dateInput/utils/explodeDate/explodeDate.js +0 -7
- package/src/dateInput/utils/explodeDate/explodeDate.spec.js +0 -11
- package/src/dateInput/utils/explodeDate/index.js +0 -1
- package/src/decision/Decision.js +0 -148
- package/src/decision/decisionEnums.ts +0 -11
- package/src/decision/index.js +0 -2
- package/src/sizeSwapper/SizeSwapper.js +0 -69
- package/src/sizeSwapper/SizeSwapper.spec.js +0 -100
- package/src/sizeSwapper/SizeSwapper.story.js +0 -34
- package/src/sizeSwapper/index.js +0 -1
- /package/src/common/dateUtils/getDayNames/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/getMonthNames/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/isDateValid/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/isMonthAndYearFormat/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/isWithinRange/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/moveToWithinRange/{index.js → index.ts} +0 -0
- /package/src/dateInput/{DateInput.messages.js → DateInput.messages.ts} +0 -0
- /package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.spec.js → convertToLocalMidnight.spec.ts} +0 -0
- /package/src/dateInput/utils/convertToLocalMidnight/{index.js → index.ts} +0 -0
|
@@ -3,16 +3,16 @@ import '@testing-library/jest-dom';
|
|
|
3
3
|
|
|
4
4
|
import Avatar from '../avatar';
|
|
5
5
|
import { Breakpoint, Size } from '../common';
|
|
6
|
-
import {
|
|
6
|
+
import { mockMatchMedia } from '../mocks';
|
|
7
|
+
import { render, fireEvent, screen } from '../test-utils';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
import Decision from '.';
|
|
9
|
+
import Decision, { DecisionPresentation, DecisionType } from '.';
|
|
11
10
|
|
|
12
11
|
jest.mock('lodash.throttle', () => jest.fn((fn) => fn));
|
|
12
|
+
mockMatchMedia(jest);
|
|
13
13
|
|
|
14
14
|
describe('Decision', () => {
|
|
15
|
-
const
|
|
15
|
+
const commonProps = {
|
|
16
16
|
options: [
|
|
17
17
|
{
|
|
18
18
|
media: {
|
|
@@ -25,112 +25,107 @@ describe('Decision', () => {
|
|
|
25
25
|
onClick: jest.fn(),
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
|
-
presentation:
|
|
29
|
-
type:
|
|
28
|
+
presentation: DecisionPresentation.LIST_BLOCK,
|
|
29
|
+
type: DecisionType.NAVIGATION,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const initialInnerWidth = window.innerWidth;
|
|
32
33
|
const resetClientWidth = (width) => {
|
|
33
|
-
|
|
34
|
-
configurable: true,
|
|
35
|
-
value: width,
|
|
36
|
-
});
|
|
34
|
+
window.innerWidth = width;
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
afterAll(() => {
|
|
40
|
-
|
|
41
|
-
HTMLElement.prototype,
|
|
42
|
-
'clientWidth',
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
Object.defineProperty(HTMLElement.prototype, 'clientWidth', originalClientWidth);
|
|
38
|
+
window.innerWidth = initialInnerWidth;
|
|
46
39
|
});
|
|
47
40
|
|
|
48
|
-
let container;
|
|
49
41
|
beforeEach(() => {
|
|
50
42
|
resetClientWidth(Breakpoint.EXTRA_SMALL - 1);
|
|
51
43
|
});
|
|
52
44
|
|
|
53
|
-
describe(`when presentation is ${
|
|
54
|
-
|
|
55
|
-
({ container } = render(<Decision {...props} />));
|
|
56
|
-
});
|
|
45
|
+
describe(`when presentation is ${DecisionPresentation.LIST_BLOCK}`, () => {
|
|
46
|
+
const props = { ...commonProps };
|
|
57
47
|
|
|
58
48
|
it('renders only Navigation Option before first breakpoint', () => {
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
const { container } = render(<Decision {...props} />);
|
|
50
|
+
|
|
51
|
+
expect(getNavigationOption(container)).toBeInTheDocument();
|
|
52
|
+
expect(getTile(container)).not.toBeInTheDocument();
|
|
61
53
|
});
|
|
62
54
|
|
|
63
55
|
it('renders only Tile after first breakpoint', () => {
|
|
64
56
|
resetClientWidth(Breakpoint.SMALL);
|
|
65
|
-
|
|
57
|
+
const { container } = render(<Decision {...props} />);
|
|
66
58
|
|
|
67
|
-
expect(getNavigationOption()).not.toBeInTheDocument();
|
|
68
|
-
expect(getTile()).toBeInTheDocument();
|
|
69
|
-
expect(getTile()).not.toHaveClass('np-tile--small');
|
|
59
|
+
expect(getNavigationOption(container)).not.toBeInTheDocument();
|
|
60
|
+
expect(getTile(container)).toBeInTheDocument();
|
|
61
|
+
expect(getTile(container)).not.toHaveClass('np-tile--small');
|
|
70
62
|
});
|
|
71
63
|
});
|
|
72
64
|
|
|
73
|
-
describe(`when presentation is ${
|
|
74
|
-
|
|
75
|
-
({ container } = render(<Decision {...props} presentation={Presentation.LIST_BLOCK_GRID} />));
|
|
76
|
-
});
|
|
65
|
+
describe(`when presentation is ${DecisionPresentation.LIST_BLOCK_GRID}`, () => {
|
|
66
|
+
const props = { ...commonProps, presentation: DecisionPresentation.LIST_BLOCK_GRID };
|
|
77
67
|
|
|
78
68
|
it('renders only Navigation Option before first breakpoint', () => {
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
const { container } = render(<Decision {...props} />);
|
|
70
|
+
|
|
71
|
+
expect(getNavigationOption(container)).toBeInTheDocument();
|
|
72
|
+
expect(getTile(container)).not.toBeInTheDocument();
|
|
81
73
|
});
|
|
82
74
|
|
|
83
75
|
it('renders only Tile after first breakpoint', () => {
|
|
84
76
|
resetClientWidth(Breakpoint.SMALL);
|
|
85
|
-
|
|
77
|
+
const { container } = render(<Decision {...props} />);
|
|
86
78
|
|
|
87
|
-
expect(getNavigationOption()).not.toBeInTheDocument();
|
|
88
|
-
expect(getTile()).toBeInTheDocument();
|
|
89
|
-
expect(getTile()).not.toHaveClass('np-tile--small');
|
|
79
|
+
expect(getNavigationOption(container)).not.toBeInTheDocument();
|
|
80
|
+
expect(getTile(container)).toBeInTheDocument();
|
|
81
|
+
expect(getTile(container)).not.toHaveClass('np-tile--small');
|
|
90
82
|
});
|
|
91
83
|
|
|
92
84
|
it('renders container as a grid', () => {
|
|
93
85
|
resetClientWidth(Breakpoint.SMALL);
|
|
94
|
-
|
|
86
|
+
const { container } = render(<Decision {...props} />);
|
|
95
87
|
|
|
96
|
-
|
|
97
|
-
expect(
|
|
88
|
+
const decisionElement = container.querySelector('.np-decision');
|
|
89
|
+
expect(decisionElement).toHaveClass('np-decision--grid');
|
|
90
|
+
expect(decisionElement).toHaveClass('flex-wrap');
|
|
98
91
|
});
|
|
99
92
|
});
|
|
100
93
|
|
|
101
|
-
describe(`when presentation is ${
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
94
|
+
describe(`when presentation is ${DecisionPresentation.LIST_BLOCK} and size is Small`, () => {
|
|
95
|
+
const props = {
|
|
96
|
+
...commonProps,
|
|
97
|
+
presentation: DecisionPresentation.LIST_BLOCK,
|
|
98
|
+
size: Size.SMALL,
|
|
99
|
+
};
|
|
107
100
|
|
|
108
101
|
it('renders only Navigation Option before breakpoint', () => {
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
const { container } = render(<Decision {...props} />);
|
|
103
|
+
|
|
104
|
+
expect(getNavigationOption(container)).toBeInTheDocument();
|
|
105
|
+
expect(getTile(container)).not.toBeInTheDocument();
|
|
111
106
|
});
|
|
112
107
|
|
|
113
108
|
it('renders Small Tile after breakpoint', () => {
|
|
114
109
|
resetClientWidth(Breakpoint.EXTRA_SMALL);
|
|
115
|
-
|
|
110
|
+
const { container } = render(<Decision {...props} />);
|
|
116
111
|
|
|
117
|
-
expect(getNavigationOption()).not.toBeInTheDocument();
|
|
118
|
-
expect(getTile()).toBeInTheDocument();
|
|
119
|
-
expect(getTile()).toHaveClass('np-tile--small');
|
|
112
|
+
expect(getNavigationOption(container)).not.toBeInTheDocument();
|
|
113
|
+
expect(getTile(container)).toBeInTheDocument();
|
|
114
|
+
expect(getTile(container)).toHaveClass('np-tile--small');
|
|
120
115
|
});
|
|
121
116
|
});
|
|
122
117
|
|
|
123
|
-
describe(`when presentation is ${
|
|
124
|
-
|
|
125
|
-
({ container } = render(<Decision {...props} presentation={Presentation.LIST} />));
|
|
126
|
-
});
|
|
118
|
+
describe(`when presentation is ${DecisionPresentation.LIST}`, () => {
|
|
119
|
+
const props = { ...commonProps, presentation: DecisionPresentation.LIST };
|
|
127
120
|
|
|
128
121
|
it('renders Navigation Option before breakpoint', () => {
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
const { container } = render(<Decision {...props} />);
|
|
123
|
+
|
|
124
|
+
expect(getNavigationOption(container)).toBeInTheDocument();
|
|
125
|
+
expect(getTile(container)).not.toBeInTheDocument();
|
|
131
126
|
});
|
|
132
127
|
});
|
|
133
128
|
|
|
134
|
-
const getNavigationOption = () => container.querySelector('.np-navigation-option');
|
|
135
|
-
const getTile = () => container.querySelector('.np-tile');
|
|
129
|
+
const getNavigationOption = (container) => container.querySelector('.np-navigation-option');
|
|
130
|
+
const getTile = (container) => container.querySelector('.np-tile');
|
|
136
131
|
});
|
|
@@ -21,7 +21,7 @@ export const Basic = () => {
|
|
|
21
21
|
const disabled = boolean('disabled', false);
|
|
22
22
|
const showMediaCircleInList = boolean('showMediaCircleInList', true);
|
|
23
23
|
const isContainerAligned = boolean('isContainerAligned', false);
|
|
24
|
-
const size = select('size', [Size.MEDIUM, Size.SMALL]);
|
|
24
|
+
const size = select('size', [Size.MEDIUM, Size.SMALL], Size.MEDIUM);
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
27
|
<>
|
|
@@ -33,7 +33,7 @@ export const Basic = () => {
|
|
|
33
33
|
href: '#href1',
|
|
34
34
|
disabled,
|
|
35
35
|
media: {
|
|
36
|
-
block: <Illustration name="globe" alt=""
|
|
36
|
+
block: <Illustration name="globe" alt="" disablePadding />,
|
|
37
37
|
list: (
|
|
38
38
|
<Avatar size="md" type="initials">
|
|
39
39
|
HM
|
|
@@ -49,7 +49,7 @@ export const Basic = () => {
|
|
|
49
49
|
disabled,
|
|
50
50
|
href: '#href2',
|
|
51
51
|
media: {
|
|
52
|
-
block: <Illustration name="confetti" alt=""
|
|
52
|
+
block: <Illustration name="confetti" alt="" disablePadding />,
|
|
53
53
|
list: (
|
|
54
54
|
<Avatar size="md" type="initials">
|
|
55
55
|
HM
|
|
@@ -61,7 +61,7 @@ export const Basic = () => {
|
|
|
61
61
|
{
|
|
62
62
|
description: "I'm disabled and don't require an onClick or href.",
|
|
63
63
|
media: {
|
|
64
|
-
block: <Illustration name="briefcase" alt=""
|
|
64
|
+
block: <Illustration name="briefcase" alt="" disablePadding />,
|
|
65
65
|
list: (
|
|
66
66
|
<img
|
|
67
67
|
src="https://wise.com/public-resources/assets/illustrations/business_account_web_small.svg"
|
|
@@ -91,7 +91,7 @@ export const grid = () => {
|
|
|
91
91
|
DecisionPresentation.LIST_BLOCK_GRID,
|
|
92
92
|
);
|
|
93
93
|
const disabled = boolean('disabled', false);
|
|
94
|
-
const size = select('size', [Size.MEDIUM, Size.SMALL]);
|
|
94
|
+
const size = select('size', [Size.MEDIUM, Size.SMALL], Size.MEDIUM);
|
|
95
95
|
|
|
96
96
|
return (
|
|
97
97
|
<>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
|
|
3
|
+
import { Size, Breakpoint, SizeSmall, SizeMedium } from '../common';
|
|
4
|
+
import { useScreenSize } from '../common/hooks/useScreenSize';
|
|
5
|
+
import NavigationOption from '../navigationOption';
|
|
6
|
+
import Tile from '../tile';
|
|
7
|
+
|
|
8
|
+
interface DecisionOption {
|
|
9
|
+
description?: React.ReactNode;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
href?: string;
|
|
12
|
+
target?: React.HTMLAttributeAnchorTarget;
|
|
13
|
+
media: {
|
|
14
|
+
block: React.ReactNode;
|
|
15
|
+
list: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
18
|
+
title: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export enum DecisionPresentation {
|
|
22
|
+
LIST = 'LIST',
|
|
23
|
+
LIST_BLOCK = 'LIST_BLOCK',
|
|
24
|
+
LIST_BLOCK_GRID = 'LIST_BLOCK_GRID',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export enum DecisionType {
|
|
28
|
+
NAVIGATION = 'NAVIGATION',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DecisionProps {
|
|
32
|
+
/** A list of elements to be rendered */
|
|
33
|
+
options: DecisionOption[];
|
|
34
|
+
/** Handles the display mode of the component */
|
|
35
|
+
presentation?: `${DecisionPresentation}`;
|
|
36
|
+
/** Size currently affects only Tile dimension */
|
|
37
|
+
size?: SizeSmall | SizeMedium;
|
|
38
|
+
/** Decide which kind of element type needs to be rendered ex: Navigation Options or in the future Radio or Checkbox Options */
|
|
39
|
+
type?: `${DecisionType}`;
|
|
40
|
+
|
|
41
|
+
/** Display media in a circle in list presentation */
|
|
42
|
+
showMediaCircleInList?: boolean;
|
|
43
|
+
|
|
44
|
+
/** Sets navigation options to be aligned with the parent container */
|
|
45
|
+
isContainerAligned?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const Decision = ({
|
|
49
|
+
options,
|
|
50
|
+
presentation = DecisionPresentation.LIST,
|
|
51
|
+
size = Size.MEDIUM,
|
|
52
|
+
type = DecisionType.NAVIGATION,
|
|
53
|
+
showMediaCircleInList = true,
|
|
54
|
+
isContainerAligned = false,
|
|
55
|
+
}: DecisionProps) => {
|
|
56
|
+
const screenXs = useScreenSize(Breakpoint.EXTRA_SMALL);
|
|
57
|
+
const screenSm = useScreenSize(Breakpoint.SMALL);
|
|
58
|
+
|
|
59
|
+
if (type === DecisionType.NAVIGATION) {
|
|
60
|
+
const renderedOptions = options.map(
|
|
61
|
+
({ title, description, disabled, href, target, media: { list }, onClick }, key) => (
|
|
62
|
+
<NavigationOption
|
|
63
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
64
|
+
key={`nav-${key}`}
|
|
65
|
+
complex={false}
|
|
66
|
+
content={description}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
href={href}
|
|
69
|
+
target={target}
|
|
70
|
+
media={list}
|
|
71
|
+
showMediaAtAllSizes
|
|
72
|
+
showMediaCircle={showMediaCircleInList}
|
|
73
|
+
isContainerAligned={isContainerAligned}
|
|
74
|
+
title={title}
|
|
75
|
+
onClick={onClick}
|
|
76
|
+
/>
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (
|
|
81
|
+
presentation === DecisionPresentation.LIST_BLOCK ||
|
|
82
|
+
presentation === DecisionPresentation.LIST_BLOCK_GRID
|
|
83
|
+
) {
|
|
84
|
+
const isSmall = size === Size.SMALL;
|
|
85
|
+
const breakpoint = isSmall ? screenXs : screenSm;
|
|
86
|
+
|
|
87
|
+
const isGrid = presentation === DecisionPresentation.LIST_BLOCK_GRID;
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div
|
|
91
|
+
className={classNames(
|
|
92
|
+
'np-decision d-flex',
|
|
93
|
+
{
|
|
94
|
+
'np-decision--small': isSmall,
|
|
95
|
+
'np-decision--grid': isGrid,
|
|
96
|
+
},
|
|
97
|
+
breakpoint ? isGrid && 'flex-wrap' : 'flex-column',
|
|
98
|
+
)}
|
|
99
|
+
>
|
|
100
|
+
{breakpoint
|
|
101
|
+
? options.map(
|
|
102
|
+
(
|
|
103
|
+
{ description, disabled, href, target, media: { block }, onClick, title },
|
|
104
|
+
key,
|
|
105
|
+
) => (
|
|
106
|
+
<Tile
|
|
107
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
108
|
+
key={`tile-${key}`}
|
|
109
|
+
className={classNames(`np-decision__tile${isSmall ? '--small' : ''}`, {
|
|
110
|
+
'np-decision__tile--fixed-width': isGrid,
|
|
111
|
+
})}
|
|
112
|
+
description={description}
|
|
113
|
+
disabled={disabled}
|
|
114
|
+
href={href}
|
|
115
|
+
target={target}
|
|
116
|
+
media={block}
|
|
117
|
+
size={isSmall ? Size.SMALL : Size.MEDIUM}
|
|
118
|
+
title={title}
|
|
119
|
+
onClick={onClick}
|
|
120
|
+
/>
|
|
121
|
+
),
|
|
122
|
+
)
|
|
123
|
+
: renderedOptions}
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
// LIST
|
|
128
|
+
return <>{renderedOptions}</>;
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default Decision;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, DecisionPresentation, DecisionType } from './Decision';
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Types
|
|
3
3
|
*/
|
|
4
|
+
export type { DecisionProps } from './decision/Decision';
|
|
4
5
|
export type { InputProps } from './inputs/Input';
|
|
6
|
+
export type { DateInputProps } from './dateInput';
|
|
5
7
|
export type { InputWithDisplayFormatProps } from './inputWithDisplayFormat';
|
|
6
8
|
export type { InputGroupProps } from './inputs/InputGroup';
|
|
7
9
|
export type { SearchInputProps } from './inputs/SearchInput';
|
package/src/main.css
CHANGED
|
@@ -1598,95 +1598,19 @@ button.np-option {
|
|
|
1598
1598
|
.np-decision .decision {
|
|
1599
1599
|
display: flex;
|
|
1600
1600
|
}
|
|
1601
|
-
.np-decision__tile--small + .np-decision__tile--small {
|
|
1602
|
-
margin-left: 16px;
|
|
1603
|
-
margin-left: var(--size-16);
|
|
1604
|
-
}
|
|
1605
|
-
[dir="rtl"] .np-decision__tile--small + .np-decision__tile--small {
|
|
1606
|
-
margin-right: 16px;
|
|
1607
|
-
margin-right: var(--size-16);
|
|
1608
|
-
margin-left: 0;
|
|
1609
|
-
margin-left: initial;
|
|
1610
|
-
}
|
|
1611
|
-
.np-decision.np-decision--grid .np-decision__tile--small {
|
|
1612
|
-
margin-left: 0;
|
|
1613
|
-
margin-bottom: 16px !important;
|
|
1614
|
-
margin-bottom: var(--size-16) !important;
|
|
1615
|
-
}
|
|
1616
|
-
[dir="rtl"] .np-decision.np-decision--grid .np-decision__tile--small {
|
|
1617
|
-
margin-right: 0;
|
|
1618
|
-
margin-left: 0;
|
|
1619
|
-
margin-left: initial;
|
|
1620
|
-
}
|
|
1621
|
-
.np-decision.np-decision--grid .np-decision__tile--small:not(:last-of-type) {
|
|
1622
|
-
margin-right: 16px;
|
|
1623
|
-
margin-right: var(--size-16);
|
|
1624
|
-
}
|
|
1625
|
-
[dir="rtl"] .np-decision.np-decision--grid .np-decision__tile--small:not(:last-of-type) {
|
|
1626
|
-
margin-left: 16px;
|
|
1627
|
-
margin-left: var(--size-16);
|
|
1628
|
-
margin-right: 0;
|
|
1629
|
-
margin-right: initial;
|
|
1630
|
-
}
|
|
1631
|
-
.np-decision__tile + .np-decision__tile {
|
|
1632
|
-
margin-left: 24px;
|
|
1633
|
-
margin-left: var(--size-24);
|
|
1634
|
-
}
|
|
1635
|
-
[dir="rtl"] .np-decision__tile + .np-decision__tile {
|
|
1636
|
-
margin-right: 24px;
|
|
1637
|
-
margin-right: var(--size-24);
|
|
1638
|
-
margin-left: 0;
|
|
1639
|
-
margin-left: initial;
|
|
1640
|
-
}
|
|
1641
|
-
.np-decision .np-text-title-subsection {
|
|
1642
|
-
margin-bottom: 0;
|
|
1643
|
-
}
|
|
1644
1601
|
.np-decision__tile--small .np-text-title-subsection {
|
|
1645
1602
|
font-size: 1rem;
|
|
1646
1603
|
font-size: var(--font-size-16);
|
|
1647
1604
|
line-height: 1.2;
|
|
1648
1605
|
line-height: var(--line-height-title);
|
|
1649
|
-
margin-bottom: 0;
|
|
1650
|
-
}
|
|
1651
|
-
.np-decision.np-decision--grid .np-decision__tile {
|
|
1652
|
-
margin-left: 0;
|
|
1653
|
-
margin-bottom: 24px !important;
|
|
1654
|
-
margin-bottom: var(--size-24) !important;
|
|
1655
|
-
}
|
|
1656
|
-
[dir="rtl"] .np-decision.np-decision--grid .np-decision__tile {
|
|
1657
|
-
margin-right: 0;
|
|
1658
|
-
margin-left: 0;
|
|
1659
|
-
margin-left: initial;
|
|
1660
|
-
}
|
|
1661
|
-
.np-decision.np-decision--grid .np-decision__tile:not(:last-of-type) {
|
|
1662
|
-
margin-right: 24px;
|
|
1663
|
-
margin-right: var(--size-24);
|
|
1664
1606
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
margin-right: 0;
|
|
1669
|
-
margin-right: initial;
|
|
1670
|
-
}
|
|
1671
|
-
.np-decision.np-decision--grid .np-size-swapper {
|
|
1672
|
-
margin-right: calc(0 - 24px);
|
|
1673
|
-
margin-right: calc(0 - var(--size-24));
|
|
1674
|
-
}
|
|
1675
|
-
[dir="rtl"] .np-decision.np-decision--grid .np-size-swapper {
|
|
1676
|
-
margin-left: calc(0 - 24px);
|
|
1677
|
-
margin-left: calc(0 - var(--size-24));
|
|
1678
|
-
margin-right: 0;
|
|
1679
|
-
margin-right: initial;
|
|
1680
|
-
}
|
|
1681
|
-
.np-decision.np-decision--grid.np-decision--small .np-size-swapper {
|
|
1682
|
-
margin-right: calc(0 - 16px);
|
|
1683
|
-
margin-right: calc(0 - var(--size-16));
|
|
1607
|
+
.np-decision:not(.flex-column) {
|
|
1608
|
+
gap: 24px;
|
|
1609
|
+
gap: var(--size-24);
|
|
1684
1610
|
}
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
margin-right: 0;
|
|
1689
|
-
margin-right: initial;
|
|
1611
|
+
.np-decision:not(.flex-column).np-decision--small {
|
|
1612
|
+
gap: 16px;
|
|
1613
|
+
gap: var(--size-16);
|
|
1690
1614
|
}
|
|
1691
1615
|
.tw-definition-list__item dd {
|
|
1692
1616
|
word-break: break-all;
|
|
@@ -13,7 +13,6 @@ import { usePromoCardContext } from './PromoCardContext';
|
|
|
13
13
|
import PromoCardIndicator, { PromoCardIndicatorProps } from './PromoCardIndicator';
|
|
14
14
|
|
|
15
15
|
export type ReferenceType = React.Ref<HTMLInputElement>;
|
|
16
|
-
export type LinkTarget = '_blank' | '_parent' | '_self' | '_top';
|
|
17
16
|
export type RelatedTypes =
|
|
18
17
|
| ''
|
|
19
18
|
| 'alternate'
|
|
@@ -98,7 +97,7 @@ export interface PromoCardLinkProps extends PromoCardCommonProps, Omit<CardProps
|
|
|
98
97
|
rel?: RelatedTypes;
|
|
99
98
|
|
|
100
99
|
/** Optional prop to to display where the linked URL will show */
|
|
101
|
-
target?:
|
|
100
|
+
target?: React.HTMLAttributeAnchorTarget;
|
|
102
101
|
|
|
103
102
|
/** Only applies to role="radio" or "checkbox" */
|
|
104
103
|
defaultChecked?: never;
|
package/src/tile/Tile.js
CHANGED
|
@@ -65,7 +65,7 @@ Tile.propTypes = {
|
|
|
65
65
|
className: PropTypes.string,
|
|
66
66
|
description: PropTypes.node,
|
|
67
67
|
disabled: PropTypes.bool,
|
|
68
|
-
href: PropTypes.string
|
|
68
|
+
href: PropTypes.string,
|
|
69
69
|
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
70
70
|
/** Accepts only Avatar and images */
|
|
71
71
|
media: PropTypes.node.isRequired,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"explodeDate.d.ts","sourceRoot":"","sources":["../../../../../src/dateInput/utils/explodeDate/explodeDate.js"],"names":[],"mappings":"AAAO;;;;EAMN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/dateInput/utils/explodeDate/index.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decisionEnums.d.ts","sourceRoot":"","sources":["../../../src/decision/decisionEnums.ts"],"names":[],"mappings":"AACA,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb,UAAU,eAAe;IACzB,eAAe,oBAAoB;CACpC;AAGD,oBAAY,IAAI;IACd,UAAU,eAAe;CAC1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SizeSwapper.d.ts","sourceRoot":"","sources":["../../../src/sizeSwapper/SizeSwapper.js"],"names":[],"mappings":";AASA,yGAqCG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sizeSwapper/index.js"],"names":[],"mappings":""}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export const isDateValid = (date) => validDateObject(date) || validDateString(date);
|
|
2
|
-
|
|
3
|
-
export const validDateString = (dateString) =>
|
|
4
|
-
typeof dateString === 'string' && validDateObject(new Date(dateString));
|
|
5
|
-
|
|
6
|
-
const validDateObject = (dateObject) => dateObject instanceof Date && !isNaN(dateObject); // eslint-disable-line no-restricted-globals
|
package/src/dateInput/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { explodeDate } from './explodeDate';
|