@lumx/react 3.1.5 → 3.2.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/_internal/types.d.ts +16 -5
- package/index.d.ts +45 -4
- package/index.js +609 -411
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/alert-dialog/AlertDialog.stories.tsx +96 -165
- package/src/components/alert-dialog/AlertDialog.test.tsx +15 -23
- package/src/components/avatar/Avatar.stories.tsx +91 -62
- package/src/components/avatar/Avatar.test.tsx +9 -24
- package/src/components/badge/Badge.stories.tsx +63 -38
- package/src/components/button/Button.stories.tsx +147 -139
- package/src/components/button/IconButton.stories.tsx +45 -0
- package/src/components/checkbox/Checkbox.stories.tsx +37 -30
- package/src/components/chip/Chip.stories.tsx +77 -15
- package/src/components/comment-block/CommentBlock.stories.tsx +90 -25
- package/src/components/comment-block/CommentBlock.test.tsx +12 -17
- package/src/components/date-picker/DatePickerField.stories.tsx +52 -83
- package/src/components/dialog/Dialog.stories.tsx +131 -293
- package/src/components/dialog/Dialog.test.tsx +0 -32
- package/src/components/dropdown/Dropdown.stories.tsx +1 -186
- package/src/components/flag/Flag.stories.tsx +33 -18
- package/src/components/flag/Flag.test.tsx +1 -8
- package/src/components/flex-box/FlexBox.stories.tsx +151 -238
- package/src/components/flex-box/FlexBox.test.tsx +9 -49
- package/src/components/generic-block/GenericBlock.stories.jsx +1 -1
- package/src/components/grid-column/GridColumn.stories.tsx +46 -0
- package/src/components/heading/Heading.stories.tsx +57 -95
- package/src/components/icon/Icon.stories.tsx +67 -70
- package/src/components/image-block/ImageBlock.stories.tsx +103 -47
- package/src/components/image-block/ImageBlock.test.tsx +12 -17
- package/src/components/inline-list/InlineList.stories.tsx +45 -29
- package/src/components/input-helper/InputHelper.stories.tsx +31 -25
- package/src/components/input-label/InputLabel.stories.tsx +33 -10
- package/src/components/lightbox/Lightbox.stories.tsx +39 -77
- package/src/components/lightbox/Lightbox.test.tsx +12 -17
- package/src/components/link/Link.stories.tsx +98 -128
- package/src/components/link-preview/LinkPreview.stories.tsx +48 -75
- package/src/components/list/List.stories.tsx +59 -84
- package/src/components/list/List.test.tsx +8 -17
- package/src/components/list/ListDivider.stories.tsx +9 -4
- package/src/components/list/ListDivider.test.tsx +12 -17
- package/src/components/list/ListItem.stories.tsx +97 -59
- package/src/components/list/ListItem.test.tsx +12 -17
- package/src/components/list/ListSubheader.stories.tsx +8 -5
- package/src/components/list/ListSubheader.test.tsx +12 -18
- package/src/components/message/Message.stories.tsx +51 -22
- package/src/components/mosaic/Mosaic.stories.tsx +78 -74
- package/src/components/mosaic/Mosaic.test.tsx +0 -31
- package/src/components/navigation/Navigation.stories.tsx +67 -0
- package/src/components/navigation/Navigation.test.tsx +58 -0
- package/src/components/navigation/Navigation.tsx +62 -0
- package/src/components/navigation/NavigationItem.test.tsx +37 -0
- package/src/components/navigation/NavigationItem.tsx +89 -0
- package/src/components/navigation/NavigationSection.test.tsx +126 -0
- package/src/components/navigation/NavigationSection.tsx +109 -0
- package/src/components/navigation/context.tsx +6 -0
- package/src/components/navigation/index.ts +1 -0
- package/src/components/notification/Notifications.stories.tsx +52 -47
- package/src/components/popover/Popover.stories.tsx +68 -201
- package/src/components/popover-dialog/PopoverDialog.stories.tsx +26 -65
- package/src/components/post-block/PostBlock.test.tsx +12 -17
- package/src/components/progress/ProgressCircular.stories.tsx +24 -12
- package/src/components/progress/ProgressLinear.stories.tsx +6 -2
- package/src/components/radio-button/RadioButton.stories.tsx +35 -24
- package/src/components/select/Select.stories.tsx +19 -23
- package/src/components/skeleton/SkeletonCircle.stories.tsx +37 -21
- package/src/components/skeleton/SkeletonCircle.test.tsx +12 -17
- package/src/components/skeleton/SkeletonRectangle.stories.tsx +74 -99
- package/src/components/skeleton/SkeletonRectangle.test.tsx +12 -17
- package/src/components/skeleton/SkeletonTypography.test.tsx +12 -17
- package/src/components/slider/Slider.stories.tsx +41 -25
- package/src/components/slider/Slider.test.tsx +12 -18
- package/src/components/slideshow/Slideshow.stories.tsx +31 -61
- package/src/components/slideshow/Slideshow.test.tsx +15 -23
- package/src/components/slideshow/SlideshowControls.stories.tsx +4 -6
- package/src/components/switch/Switch.stories.tsx +35 -32
- package/src/components/table/Table.test.tsx +12 -17
- package/src/components/tabs/Tabs.stories.tsx +4 -3
- package/src/components/text/Text.stories.tsx +130 -0
- package/src/components/text-field/TextField.stories.tsx +114 -148
- package/src/components/thumbnail/Thumbnail.stories.tsx +106 -255
- package/src/components/thumbnail/Thumbnail.test.tsx +12 -35
- package/src/components/tooltip/Tooltip.stories.tsx +51 -136
- package/src/components/user-block/UserBlock.stories.tsx +67 -56
- package/src/components/user-block/UserBlock.test.tsx +1 -5
- package/src/index.ts +1 -0
- package/src/stories/controls/color.ts +6 -0
- package/src/stories/controls/element.ts +6 -0
- package/src/stories/controls/focusPoint.ts +1 -0
- package/src/stories/controls/icons.ts +6 -0
- package/src/stories/{knobs → controls}/image.ts +6 -16
- package/src/stories/controls/selectArgType.ts +4 -0
- package/src/stories/controls/theme.ts +3 -0
- package/src/stories/controls/typography.ts +5 -0
- package/src/stories/controls/withUndefined.ts +1 -0
- package/src/stories/decorators/withChromaticForceScreenSize.tsx +8 -0
- package/src/stories/decorators/withCombinations.tsx +99 -0
- package/src/stories/decorators/withNestedProps.tsx +23 -0
- package/src/stories/{withResizableBox.tsx → decorators/withResizableBox.tsx} +6 -10
- package/src/stories/decorators/withValueOnChange.tsx +18 -0
- package/src/stories/decorators/withWrapper.tsx +19 -0
- package/src/stories/utils/CustomLink.tsx +8 -2
- package/src/stories/{knobs → utils}/lorem.ts +9 -9
- package/src/testing/utils/commonTestsSuiteRTL.ts +2 -3
- package/src/testing/utils/index.ts +0 -2
- package/src/untypped-modules.d.ts +0 -2
- package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
- package/src/utils/ThemeContext.ts +4 -0
- package/src/utils/forwardRefPolymorphic.ts +9 -0
- package/src/utils/type.ts +28 -4
- package/src/components/alert-dialog/__snapshots__/AlertDialog.test.tsx.snap +0 -558
- package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +0 -681
- package/src/components/comment-block/__snapshots__/CommentBlock.test.tsx.snap +0 -92
- package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +0 -1133
- package/src/components/expansion-panel/ExpansionPanel.stories.tsx +0 -65
- package/src/components/flag/__snapshots__/Flag.test.tsx.snap +0 -133
- package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +0 -492
- package/src/components/grid-column/GridColumn.stories.jsx +0 -56
- package/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +0 -64
- package/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +0 -194
- package/src/components/list/__snapshots__/List.test.tsx.snap +0 -360
- package/src/components/list/__snapshots__/ListDivider.test.tsx.snap +0 -7
- package/src/components/list/__snapshots__/ListItem.test.tsx.snap +0 -160
- package/src/components/list/__snapshots__/ListSubheader.test.tsx.snap +0 -9
- package/src/components/mosaic/__snapshots__/Mosaic.test.tsx.snap +0 -357
- package/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +0 -139
- package/src/components/skeleton/__snapshots__/SkeletonCircle.test.tsx.snap +0 -54
- package/src/components/skeleton/__snapshots__/SkeletonRectangle.test.tsx.snap +0 -177
- package/src/components/skeleton/__snapshots__/SkeletonTypography.test.tsx.snap +0 -174
- package/src/components/slider/__snapshots__/Slider.test.tsx.snap +0 -122
- package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +0 -157
- package/src/components/table/__snapshots__/Table.test.tsx.snap +0 -263
- package/src/components/text/Text.stories.jsx +0 -75
- package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +0 -130
- package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +0 -362
- package/src/stories/chromaticForceScreenSize.tsx +0 -7
- package/src/stories/knobs/buttonKnob.ts +0 -9
- package/src/stories/knobs/emphasisKnob.ts +0 -8
- package/src/stories/knobs/enumKnob.ts +0 -14
- package/src/stories/knobs/focusKnob.ts +0 -3
- package/src/stories/knobs/sizeKnob.ts +0 -5
- package/src/stories/knobs/thumbnailsKnob.ts +0 -9
- package/src/testing/utils/itShouldRenderStories.tsx +0 -103
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import { mdiAccount, mdiOpenInNew } from '@lumx/icons';
|
|
4
|
-
import { Icon, ListDivider, ListSubheader, Size } from '@lumx/react';
|
|
5
|
-
import {
|
|
6
|
-
import { select, text } from '@storybook/addon-knobs';
|
|
4
|
+
import { Icon, ListDivider, ListProps, ListSubheader, Size } from '@lumx/react';
|
|
5
|
+
import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
|
|
7
6
|
|
|
8
7
|
import { List } from './List';
|
|
9
8
|
import { ListItem } from './ListItem';
|
|
9
|
+
import ListItemStories from './ListItem.stories';
|
|
10
10
|
|
|
11
|
-
export default {
|
|
11
|
+
export default {
|
|
12
|
+
title: 'LumX components/list/List',
|
|
13
|
+
component: List,
|
|
14
|
+
args: List.defaultProps,
|
|
15
|
+
argTypes: {
|
|
16
|
+
itemPadding: getSelectArgType<ListProps['itemPadding']>([Size.big, Size.huge]),
|
|
17
|
+
onListItemSelected: { action: true },
|
|
18
|
+
'children.onItemSelected': { action: true },
|
|
19
|
+
'children.size': ListItemStories.argTypes.size,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const CustomListItem = (props: any) => <ListItem {...props}>Custom list item</ListItem>;
|
|
12
24
|
|
|
13
|
-
export const KeyboardNavigation = (
|
|
25
|
+
export const KeyboardNavigation = ({
|
|
26
|
+
'children.onItemSelected': childrenOnItemSelected,
|
|
27
|
+
'children.size': childrenSize,
|
|
28
|
+
...props
|
|
29
|
+
}: any) => {
|
|
14
30
|
const listRef = useRef<any>();
|
|
15
31
|
const firstItemRef = useRef<any>();
|
|
16
32
|
|
|
@@ -22,10 +38,6 @@ export const KeyboardNavigation = () => {
|
|
|
22
38
|
return firstItemRef.current?.focus();
|
|
23
39
|
};
|
|
24
40
|
|
|
25
|
-
const CustomListItem = () => {
|
|
26
|
-
return <ListItem onItemSelected={action('onItemSelected custom list item')}>Custom list item</ListItem>;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
41
|
return (
|
|
30
42
|
<>
|
|
31
43
|
<button type="button" onClick={focusList}>
|
|
@@ -34,27 +46,31 @@ export const KeyboardNavigation = () => {
|
|
|
34
46
|
<button type="button" onClick={focusFirsItem}>
|
|
35
47
|
focus first item
|
|
36
48
|
</button>
|
|
37
|
-
<List
|
|
38
|
-
<ListItem linkRef={firstItemRef} onItemSelected={
|
|
49
|
+
<List ref={listRef} {...props}>
|
|
50
|
+
<ListItem size={childrenSize} linkRef={firstItemRef} onItemSelected={childrenOnItemSelected}>
|
|
39
51
|
Clickable item 1
|
|
40
52
|
</ListItem>
|
|
41
53
|
<ListDivider />
|
|
42
|
-
<ListItem linkProps={{ href: '#' }}>
|
|
54
|
+
<ListItem size={childrenSize} linkProps={{ href: '#' }}>
|
|
55
|
+
Link item 1
|
|
56
|
+
</ListItem>
|
|
43
57
|
<>
|
|
44
|
-
<ListItem>Non clickable (=non navigable) item</ListItem>
|
|
58
|
+
<ListItem size={childrenSize}>Non clickable (=non navigable) item</ListItem>
|
|
45
59
|
<ListSubheader>Header</ListSubheader>
|
|
46
|
-
<ListItem linkProps={{ href: '#' }}>
|
|
60
|
+
<ListItem size={childrenSize} linkProps={{ href: '#' }}>
|
|
61
|
+
Link item 2
|
|
62
|
+
</ListItem>
|
|
47
63
|
<ListSubheader>Header</ListSubheader>
|
|
48
64
|
</>
|
|
49
|
-
<ListItem linkProps={{ href: '#' }} isDisabled>
|
|
65
|
+
<ListItem size={childrenSize} linkProps={{ href: '#' }} isDisabled>
|
|
50
66
|
Disabled link item
|
|
51
67
|
</ListItem>
|
|
52
|
-
<ListItem onItemSelected={
|
|
68
|
+
<ListItem size={childrenSize} onItemSelected={childrenOnItemSelected} isDisabled>
|
|
53
69
|
Disabled button item
|
|
54
70
|
</ListItem>
|
|
55
|
-
<CustomListItem />
|
|
71
|
+
<CustomListItem size={childrenSize} onItemSelected={childrenOnItemSelected} />
|
|
56
72
|
{[
|
|
57
|
-
<ListItem key="1" linkProps={{ href: '#' }}>
|
|
73
|
+
<ListItem size={childrenSize} key="1" linkProps={{ href: '#' }}>
|
|
58
74
|
Link item 4
|
|
59
75
|
</ListItem>,
|
|
60
76
|
]}
|
|
@@ -68,74 +84,33 @@ export const KeyboardNavigation = () => {
|
|
|
68
84
|
);
|
|
69
85
|
};
|
|
70
86
|
|
|
71
|
-
export const
|
|
72
|
-
|
|
73
|
-
const listItem = (
|
|
87
|
+
export const AsLink = () => (
|
|
88
|
+
<List>
|
|
74
89
|
<ListItem
|
|
90
|
+
before={<Icon icon={mdiAccount} />}
|
|
75
91
|
className="lumx-color-background-dark-L6"
|
|
76
|
-
|
|
77
|
-
linkProps={{ href: text('link href', '#') }}
|
|
92
|
+
linkProps={{ href: '#' }}
|
|
78
93
|
>
|
|
79
|
-
<
|
|
80
|
-
<div className="lumx-color-font-dark-L2">Secondary text</div>
|
|
94
|
+
<span>My first link</span>
|
|
81
95
|
</ListItem>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<List itemPadding={Size.big}>
|
|
92
|
-
{listItem}
|
|
93
|
-
{listItem}
|
|
94
|
-
</List>
|
|
95
|
-
Huge item padding:
|
|
96
|
-
<List itemPadding={Size.huge}>
|
|
97
|
-
{listItem}
|
|
98
|
-
{listItem}
|
|
99
|
-
</List>
|
|
100
|
-
</>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const AsLink = () => {
|
|
105
|
-
return (
|
|
106
|
-
<div className="demo-grid">
|
|
107
|
-
<List>
|
|
108
|
-
<ListItem
|
|
109
|
-
before={<Icon icon={mdiAccount} />}
|
|
110
|
-
className="lumx-color-background-dark-L6"
|
|
111
|
-
linkProps={{ href: '#' }}
|
|
112
|
-
>
|
|
113
|
-
<span>My first link</span>
|
|
114
|
-
</ListItem>
|
|
115
|
-
<ListItem
|
|
116
|
-
className="lumx-color-background-dark-L6"
|
|
117
|
-
after={<Icon icon={mdiOpenInNew} />}
|
|
118
|
-
linkProps={{ href: 'http://www.google.com', target: '_blank' }}
|
|
119
|
-
>
|
|
120
|
-
<span>Google</span>
|
|
121
|
-
</ListItem>
|
|
122
|
-
</List>
|
|
123
|
-
</div>
|
|
124
|
-
);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const WithCustomChildren = () => {
|
|
128
|
-
const CustomListItem = () => {
|
|
129
|
-
return <ListItem onItemSelected={action('onItemSelected custom list item')}>Custom list item</ListItem>;
|
|
130
|
-
};
|
|
96
|
+
<ListItem
|
|
97
|
+
className="lumx-color-background-dark-L6"
|
|
98
|
+
after={<Icon icon={mdiOpenInNew} />}
|
|
99
|
+
linkProps={{ href: 'https://example.com', target: '_blank' }}
|
|
100
|
+
>
|
|
101
|
+
<span>Google</span>
|
|
102
|
+
</ListItem>
|
|
103
|
+
</List>
|
|
104
|
+
);
|
|
131
105
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
106
|
+
export const WithCustomChildren = ({
|
|
107
|
+
'children.onItemSelected': childrenOnItemSelected,
|
|
108
|
+
'children.size': childrenSize,
|
|
109
|
+
...props
|
|
110
|
+
}: any) => (
|
|
111
|
+
<List {...props}>
|
|
112
|
+
<CustomListItem size={childrenSize} onItemSelected={childrenOnItemSelected} />
|
|
113
|
+
<CustomListItem size={childrenSize} onItemSelected={childrenOnItemSelected} />
|
|
114
|
+
<CustomListItem size={childrenSize} onItemSelected={childrenOnItemSelected} />
|
|
115
|
+
</List>
|
|
116
|
+
);
|
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import 'jest-enzyme';
|
|
5
|
-
import { commonTestsSuite, itShouldRenderStories } from '@lumx/react/testing/utils';
|
|
3
|
+
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
6
4
|
|
|
5
|
+
import { render } from '@testing-library/react';
|
|
6
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
7
7
|
import { List, ListProps } from './List';
|
|
8
|
-
import * as stories from './List.stories';
|
|
9
8
|
|
|
10
9
|
const CLASSNAME = List.className as string;
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const renderer: any = shallowRendering ? shallow : mount;
|
|
17
|
-
const wrapper: any = renderer(<List {...(props as any)} />);
|
|
18
|
-
return { props, wrapper };
|
|
11
|
+
const setup = (props: Partial<ListProps> = {}) => {
|
|
12
|
+
render(<List {...(props as any)} />);
|
|
13
|
+
const list = queryByClassName(document.body, CLASSNAME);
|
|
14
|
+
return { props, list };
|
|
19
15
|
};
|
|
20
16
|
|
|
21
17
|
describe(`<${List.displayName}>`, () => {
|
|
22
|
-
// 1. Test render via snapshot.
|
|
23
|
-
describe('Snapshots and structure', () => {
|
|
24
|
-
itShouldRenderStories(stories, List);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
18
|
// Common tests suite.
|
|
28
|
-
|
|
19
|
+
commonTestsSuiteRTL(setup, { baseClassName: CLASSNAME, forwardClassName: 'list', forwardAttributes: 'list' });
|
|
29
20
|
});
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
|
|
2
|
+
import { List } from '@lumx/react';
|
|
3
3
|
import { ListDivider } from './ListDivider';
|
|
4
4
|
|
|
5
|
-
export default {
|
|
5
|
+
export default {
|
|
6
|
+
title: 'LumX components/list/ListDivider',
|
|
7
|
+
component: ListDivider,
|
|
8
|
+
args: ListDivider.defaultProps,
|
|
9
|
+
decorators: [withWrapper({}, List)],
|
|
10
|
+
};
|
|
6
11
|
|
|
7
|
-
export const Default =
|
|
12
|
+
export const Default = {};
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import 'jest-enzyme';
|
|
5
|
-
import { commonTestsSuite, itShouldRenderStories } from '@lumx/react/testing/utils';
|
|
3
|
+
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
6
4
|
|
|
5
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
|
+
import { render } from '@testing-library/react';
|
|
7
7
|
import { ListDivider, ListDividerProps } from './ListDivider';
|
|
8
|
-
import * as stories from './ListDivider.stories';
|
|
9
8
|
|
|
10
9
|
const CLASSNAME = ListDivider.className as string;
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const renderer: any = shallowRendering ? shallow : mount;
|
|
17
|
-
const wrapper: any = renderer(<ListDivider {...(props as any)} />);
|
|
18
|
-
return { props, wrapper };
|
|
11
|
+
const setup = (props: Partial<ListDividerProps> = {}) => {
|
|
12
|
+
render(<ListDivider {...(props as any)} />);
|
|
13
|
+
const listDivider = queryByClassName(document.body, CLASSNAME);
|
|
14
|
+
return { props, listDivider };
|
|
19
15
|
};
|
|
20
16
|
|
|
21
17
|
describe(`<${ListDivider.displayName}>`, () => {
|
|
22
|
-
// 1. Test render via snapshot.
|
|
23
|
-
describe('Snapshots and structure', () => {
|
|
24
|
-
itShouldRenderStories(stories, ListDivider);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
18
|
// Common tests suite.
|
|
28
|
-
|
|
19
|
+
commonTestsSuiteRTL(setup, {
|
|
20
|
+
baseClassName: CLASSNAME,
|
|
21
|
+
forwardClassName: 'listDivider',
|
|
22
|
+
forwardAttributes: 'listDivider',
|
|
23
|
+
});
|
|
29
24
|
});
|
|
@@ -1,62 +1,100 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { Size } from '@lumx/react';
|
|
4
|
-
import { select, text } from '@storybook/addon-knobs';
|
|
5
|
-
import { action } from '@storybook/addon-actions';
|
|
1
|
+
import { List, ListItemSize, Size } from '@lumx/react';
|
|
6
2
|
|
|
3
|
+
import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
|
|
4
|
+
import { CustomLink } from '@lumx/react/stories/utils/CustomLink';
|
|
5
|
+
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
6
|
+
import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
|
|
7
7
|
import { ListItem } from './ListItem';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
export const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
9
|
+
const sizes: ListItemSize[] = [Size.tiny, Size.regular, Size.big];
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'LumX components/list/ListItem',
|
|
13
|
+
component: ListItem,
|
|
14
|
+
args: ListItem.defaultProps,
|
|
15
|
+
argTypes: {
|
|
16
|
+
size: getSelectArgType(sizes),
|
|
17
|
+
},
|
|
18
|
+
decorators: [withWrapper({}, List)],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Default list item with text
|
|
23
|
+
*/
|
|
24
|
+
export const NonClickable = {
|
|
25
|
+
args: { children: 'List item' },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Button list item (onClick)
|
|
30
|
+
*/
|
|
31
|
+
export const Button = {
|
|
32
|
+
args: {
|
|
33
|
+
children: 'List item button',
|
|
34
|
+
},
|
|
35
|
+
argTypes: {
|
|
36
|
+
onItemSelected: { action: true },
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Disabled button
|
|
42
|
+
*/
|
|
43
|
+
export const ButtonDisabled = {
|
|
44
|
+
...Button,
|
|
45
|
+
args: {
|
|
46
|
+
...Button.args,
|
|
47
|
+
isDisabled: true,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Link list item (href)
|
|
53
|
+
*/
|
|
54
|
+
export const Link = {
|
|
55
|
+
args: {
|
|
56
|
+
linkProps: { href: '#' },
|
|
57
|
+
children: 'List item link',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Disabled link
|
|
63
|
+
*/
|
|
64
|
+
export const LinkDisabled = {
|
|
65
|
+
args: {
|
|
66
|
+
...Link.args,
|
|
67
|
+
isDisabled: true,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Inject a custom link component
|
|
73
|
+
*/
|
|
74
|
+
export const CustomLink_ = {
|
|
75
|
+
args: {
|
|
76
|
+
linkAs: CustomLink,
|
|
77
|
+
children: 'List item custom link',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Combination of size and states
|
|
83
|
+
*/
|
|
84
|
+
export const SizeAndStates = {
|
|
85
|
+
...Button,
|
|
86
|
+
decorators: [
|
|
87
|
+
withWrapper({}, List),
|
|
88
|
+
withCombinations({
|
|
89
|
+
combinations: {
|
|
90
|
+
rows: { key: 'size', options: sizes },
|
|
91
|
+
cols: {
|
|
92
|
+
Default: {},
|
|
93
|
+
Disabled: { isDisabled: true },
|
|
94
|
+
Selected: { isSelected: true },
|
|
95
|
+
Highlighted: { isHighlighted: true },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
],
|
|
100
|
+
};
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import 'jest-enzyme';
|
|
5
|
-
import { commonTestsSuite, itShouldRenderStories } from '@lumx/react/testing/utils';
|
|
3
|
+
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
6
4
|
|
|
5
|
+
import { render } from '@testing-library/react';
|
|
6
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
7
7
|
import { ListItem, ListItemProps } from './ListItem';
|
|
8
|
-
import * as stories from './ListItem.stories';
|
|
9
8
|
|
|
10
9
|
const CLASSNAME = ListItem.className as string;
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const renderer: any = shallowRendering ? shallow : mount;
|
|
17
|
-
const wrapper: any = renderer(<ListItem {...(props as any)} />);
|
|
18
|
-
return { props, wrapper };
|
|
11
|
+
const setup = (props: Partial<ListItemProps> = {}) => {
|
|
12
|
+
render(<ListItem {...(props as any)} />);
|
|
13
|
+
const listItem = queryByClassName(document.body, CLASSNAME);
|
|
14
|
+
return { props, listItem };
|
|
19
15
|
};
|
|
20
16
|
|
|
21
17
|
describe(`<${ListItem.displayName}>`, () => {
|
|
22
|
-
// 1. Test render via snapshot.
|
|
23
|
-
describe('Snapshots and structure', () => {
|
|
24
|
-
itShouldRenderStories(stories, ListItem);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
18
|
// Common tests suite.
|
|
28
|
-
|
|
19
|
+
commonTestsSuiteRTL(setup, {
|
|
20
|
+
baseClassName: CLASSNAME,
|
|
21
|
+
forwardClassName: 'listItem',
|
|
22
|
+
forwardAttributes: 'listItem',
|
|
23
|
+
});
|
|
29
24
|
});
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { ListSubheader } from '@lumx/react';
|
|
4
|
-
import { text } from '@storybook/addon-knobs';
|
|
5
2
|
|
|
6
|
-
export default {
|
|
3
|
+
export default {
|
|
4
|
+
title: 'LumX components/list/ListSubheader',
|
|
5
|
+
component: ListSubheader,
|
|
6
|
+
args: ListSubheader.defaultProps,
|
|
7
|
+
};
|
|
7
8
|
|
|
8
|
-
export const Default =
|
|
9
|
+
export const Default = {
|
|
10
|
+
args: { children: 'List subheader text' },
|
|
11
|
+
};
|
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { commonTestsSuite, itShouldRenderStories } from '@lumx/react/testing/utils';
|
|
3
|
-
|
|
4
|
-
import { mount, shallow } from 'enzyme';
|
|
5
|
-
import 'jest-enzyme';
|
|
6
2
|
|
|
3
|
+
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
7
6
|
import { ListSubheader, ListSubheaderProps } from './ListSubheader';
|
|
8
|
-
import * as stories from './ListSubheader.stories';
|
|
9
7
|
|
|
10
8
|
const CLASSNAME = ListSubheader.className as string;
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const renderer: any = shallowRendering ? shallow : mount;
|
|
17
|
-
const wrapper: any = renderer(<ListSubheader {...(props as any)} />);
|
|
18
|
-
return { props, wrapper };
|
|
10
|
+
const setup = (props: Partial<ListSubheaderProps> = {}) => {
|
|
11
|
+
render(<ListSubheader {...(props as any)} />);
|
|
12
|
+
const listSubheader = queryByClassName(document.body, CLASSNAME);
|
|
13
|
+
return { props, listSubheader };
|
|
19
14
|
};
|
|
20
15
|
|
|
21
16
|
describe(`<${ListSubheader.displayName}>`, () => {
|
|
22
|
-
// 1. Test render via snapshot.
|
|
23
|
-
describe('Snapshots and structure', () => {
|
|
24
|
-
itShouldRenderStories(stories, ListSubheader);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
17
|
// Common tests suite.
|
|
28
|
-
|
|
18
|
+
commonTestsSuiteRTL(setup, {
|
|
19
|
+
baseClassName: CLASSNAME,
|
|
20
|
+
forwardClassName: 'listSubheader',
|
|
21
|
+
forwardAttributes: 'listSubheader',
|
|
22
|
+
});
|
|
29
23
|
});
|
|
@@ -1,27 +1,56 @@
|
|
|
1
1
|
import { Kind, Message } from '@lumx/react';
|
|
2
|
-
import { boolean, text } from '@storybook/addon-knobs';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { enumKnob } from '@lumx/react/stories/knobs/enumKnob';
|
|
5
2
|
import { mdiDelete } from '@lumx/icons/';
|
|
3
|
+
import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
|
|
4
|
+
import { loremIpsum } from '@lumx/react/stories/utils/lorem';
|
|
5
|
+
import { iconArgType } from '@lumx/react/stories/controls/icons';
|
|
6
|
+
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
7
|
+
import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
|
|
6
8
|
|
|
7
|
-
export default {
|
|
9
|
+
export default {
|
|
10
|
+
title: 'LumX components/message/Message',
|
|
11
|
+
component: Message,
|
|
12
|
+
argTypes: {
|
|
13
|
+
kind: getSelectArgType(Kind),
|
|
14
|
+
hasBackground: { control: 'boolean' },
|
|
15
|
+
icon: iconArgType,
|
|
16
|
+
},
|
|
17
|
+
args: { ...Message.defaultProps, children: loremIpsum('tiny') },
|
|
18
|
+
};
|
|
8
19
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
>
|
|
14
|
-
{text(
|
|
15
|
-
'Message',
|
|
16
|
-
`Message text quisque tincidunt lobortis dui non auctor.Donec porta,
|
|
17
|
-
ligula volutpat vehicula aliquet, dui sapien tempus felis, sed.`,
|
|
18
|
-
)}
|
|
19
|
-
</Message>
|
|
20
|
-
);
|
|
20
|
+
/**
|
|
21
|
+
* Default message
|
|
22
|
+
*/
|
|
23
|
+
export const Default = {};
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
/**
|
|
26
|
+
* All `kind` variants
|
|
27
|
+
*/
|
|
28
|
+
export const AllKinds = {
|
|
29
|
+
...Default,
|
|
30
|
+
decorators: [
|
|
31
|
+
withCombinations({
|
|
32
|
+
combinations: {
|
|
33
|
+
rows: { key: 'kind', options: withUndefined(Kind) },
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* All `kind` variants with `hasBackground`
|
|
41
|
+
*/
|
|
42
|
+
export const AllKindsWithBackground = {
|
|
43
|
+
...AllKinds,
|
|
44
|
+
args: {
|
|
45
|
+
hasBackground: true,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* With custom icon
|
|
51
|
+
*/
|
|
52
|
+
export const CustomIcon = {
|
|
53
|
+
args: {
|
|
54
|
+
icon: mdiDelete,
|
|
55
|
+
},
|
|
56
|
+
};
|