@lumx/react 3.1.5 → 3.2.1-alpha.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 +632 -423
- 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/Popover.tsx +7 -9
- 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/select/SelectMultiple.stories.tsx +105 -2
- package/src/components/select/WithSelectContext.tsx +10 -4
- 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/hooks/useFocusTrap.ts +2 -2
- 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,30 +1,95 @@
|
|
|
1
|
+
/* eslint-disable react/jsx-key,react/display-name */
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { mdiDotsHorizontal, mdiHeart, mdiReply } from '@lumx/icons';
|
|
3
|
-
import { Button, CommentBlock
|
|
4
|
+
import { Button, CommentBlock } from '@lumx/react';
|
|
4
5
|
import { IconButton } from '@lumx/react/components/button/IconButton';
|
|
5
|
-
import {
|
|
6
|
+
import { withNestedProps } from '@lumx/react/stories/decorators/withNestedProps';
|
|
7
|
+
import { avatarImageArgType, AVATAR_IMAGES } from '@lumx/react/stories/controls/image';
|
|
8
|
+
import { loremIpsum } from '@lumx/react/stories/utils/lorem';
|
|
6
9
|
|
|
7
|
-
export default {
|
|
10
|
+
export default {
|
|
11
|
+
title: 'LumX components/comment-block/CommentBlock',
|
|
12
|
+
component: CommentBlock,
|
|
13
|
+
decorators: [withNestedProps()],
|
|
14
|
+
args: {
|
|
15
|
+
'avatarProps.image': AVATAR_IMAGES.avatar1,
|
|
16
|
+
},
|
|
17
|
+
argTypes: {
|
|
18
|
+
'avatarProps.image': avatarImageArgType,
|
|
19
|
+
actions: { control: false },
|
|
20
|
+
headerActions: { control: false },
|
|
21
|
+
children: { control: false },
|
|
22
|
+
},
|
|
23
|
+
};
|
|
8
24
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Minimal comment block
|
|
27
|
+
*/
|
|
28
|
+
export const Minimal = {
|
|
29
|
+
args: {
|
|
30
|
+
text: loremIpsum('short'),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Full-featured comment block
|
|
36
|
+
*/
|
|
37
|
+
export const FullFeatured = {
|
|
38
|
+
args: {
|
|
39
|
+
name: 'Emmitt O. Lum',
|
|
40
|
+
text: loremIpsum('short'),
|
|
41
|
+
date: '5 days ago',
|
|
42
|
+
fullDate: 'Monday, March 30, 2021 at 4:06 PM',
|
|
43
|
+
hasActions: true,
|
|
44
|
+
},
|
|
45
|
+
render: ({ theme, ...props }: any) => (
|
|
46
|
+
<CommentBlock
|
|
47
|
+
theme={theme}
|
|
48
|
+
{...props}
|
|
49
|
+
actions={[
|
|
50
|
+
<Button theme={theme} emphasis="low" size="s" leftIcon={mdiHeart}>
|
|
51
|
+
24 likes
|
|
52
|
+
</Button>,
|
|
53
|
+
<Button theme={theme} emphasis="low" size="s" leftIcon={mdiReply}>
|
|
54
|
+
Reply
|
|
55
|
+
</Button>,
|
|
56
|
+
]}
|
|
57
|
+
headerActions={
|
|
58
|
+
<IconButton label="Actions" icon={mdiDotsHorizontal} theme={theme} emphasis="low" size="s" />
|
|
59
|
+
}
|
|
60
|
+
/>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Marked as relevant
|
|
66
|
+
*/
|
|
67
|
+
export const Relevant = {
|
|
68
|
+
...FullFeatured,
|
|
69
|
+
args: { ...FullFeatured.args, isRelevant: true },
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Comment thread
|
|
74
|
+
*/
|
|
75
|
+
export const Thread = {
|
|
76
|
+
...FullFeatured,
|
|
77
|
+
args: {
|
|
78
|
+
...FullFeatured.args,
|
|
79
|
+
isOpen: true,
|
|
80
|
+
children: [
|
|
81
|
+
<CommentBlock
|
|
82
|
+
avatarProps={{ image: AVATAR_IMAGES.avatar2, alt: '' }}
|
|
83
|
+
name="John Doe"
|
|
84
|
+
date="5 days ago"
|
|
85
|
+
text={loremIpsum('tiny')}
|
|
86
|
+
/>,
|
|
87
|
+
<CommentBlock
|
|
88
|
+
avatarProps={{ image: AVATAR_IMAGES.avatar4, alt: '' }}
|
|
89
|
+
name="Jane Doe"
|
|
90
|
+
date="5 days ago"
|
|
91
|
+
text={loremIpsum('tiny')}
|
|
92
|
+
/>,
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import 'jest-enzyme';
|
|
4
|
-
import { commonTestsSuite, itShouldRenderStories } from '@lumx/react/testing/utils';
|
|
2
|
+
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
5
3
|
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { CommentBlock, CommentBlockProps } from './CommentBlock';
|
|
7
|
-
import * as stories from './CommentBlock.stories';
|
|
8
7
|
|
|
9
8
|
const CLASSNAME = CommentBlock.className as string;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const renderer: any = shallowRendering ? shallow : mount;
|
|
16
|
-
const wrapper: any = renderer(<CommentBlock {...(props as any)} />);
|
|
17
|
-
return { props, wrapper };
|
|
10
|
+
const setup = (props: Partial<CommentBlockProps> = {}) => {
|
|
11
|
+
render(<CommentBlock {...(props as any)} />);
|
|
12
|
+
const commentBlock = queryByClassName(document.body, CLASSNAME);
|
|
13
|
+
return { props, commentBlock };
|
|
18
14
|
};
|
|
19
15
|
|
|
20
16
|
describe(`<${CommentBlock.displayName}>`, () => {
|
|
21
|
-
// 1. Test render via snapshot.
|
|
22
|
-
describe('Snapshots and structure', () => {
|
|
23
|
-
itShouldRenderStories(stories, CommentBlock);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
17
|
// Common tests suite.
|
|
27
|
-
|
|
18
|
+
commonTestsSuiteRTL(setup, {
|
|
19
|
+
baseClassName: CLASSNAME,
|
|
20
|
+
forwardClassName: 'commentBlock',
|
|
21
|
+
forwardAttributes: 'commentBlock',
|
|
22
|
+
});
|
|
28
23
|
});
|
|
@@ -1,93 +1,62 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
|
|
3
1
|
import { DatePickerField } from '@lumx/react';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
nextButtonProps={{ label: 'Next month' }}
|
|
19
|
-
previousButtonProps={{ label: 'Previous month' }}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
2
|
+
import { withValueOnChange } from '@lumx/react/stories/decorators/withValueOnChange';
|
|
3
|
+
import { withNestedProps } from '@lumx/react/stories/decorators/withNestedProps';
|
|
4
|
+
import { loremIpsum } from '@lumx/react/stories/utils/lorem';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'LumX components/date-picker/DatePickerField',
|
|
8
|
+
component: DatePickerField,
|
|
9
|
+
args: {
|
|
10
|
+
...DatePickerField.defaultProps,
|
|
11
|
+
locale: 'fr',
|
|
12
|
+
'nextButtonProps.label': 'Next month',
|
|
13
|
+
'previousButtonProps.label': 'Previous month',
|
|
14
|
+
},
|
|
15
|
+
decorators: [withValueOnChange(), withNestedProps()],
|
|
22
16
|
};
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
18
|
+
/**
|
|
19
|
+
* Default date picker fields with only the required fields
|
|
20
|
+
*/
|
|
21
|
+
export const Default = {};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* With label, placeholder and helper
|
|
25
|
+
*/
|
|
26
|
+
export const LabelPlaceholderAndHelper = {
|
|
27
|
+
args: {
|
|
28
|
+
label: 'Date picker label',
|
|
29
|
+
placeholder: 'Pick a date',
|
|
30
|
+
helper: loremIpsum('tiny'),
|
|
31
|
+
},
|
|
39
32
|
};
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
theme={theme}
|
|
50
|
-
onChange={setValue}
|
|
51
|
-
value={value}
|
|
52
|
-
hasError
|
|
53
|
-
helper="Helper"
|
|
54
|
-
nextButtonProps={{ label: 'Next month' }}
|
|
55
|
-
previousButtonProps={{ label: 'Previous month' }}
|
|
56
|
-
/>
|
|
57
|
-
);
|
|
34
|
+
/**
|
|
35
|
+
* Error state
|
|
36
|
+
*/
|
|
37
|
+
export const Error = {
|
|
38
|
+
args: {
|
|
39
|
+
...LabelPlaceholderAndHelper.args,
|
|
40
|
+
hasError: true,
|
|
41
|
+
},
|
|
58
42
|
};
|
|
59
43
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
theme={theme}
|
|
69
|
-
onChange={setValue}
|
|
70
|
-
value={value}
|
|
71
|
-
defaultMonth={new Date('2019-07-14')}
|
|
72
|
-
nextButtonProps={{ label: 'Next month' }}
|
|
73
|
-
previousButtonProps={{ label: 'Previous month' }}
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
44
|
+
/**
|
|
45
|
+
* With default value selected
|
|
46
|
+
*/
|
|
47
|
+
export const DefaultValue = {
|
|
48
|
+
args: {
|
|
49
|
+
...LabelPlaceholderAndHelper.args,
|
|
50
|
+
value: new Date('2019-02-28'),
|
|
51
|
+
},
|
|
76
52
|
};
|
|
77
53
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
theme={theme}
|
|
87
|
-
onChange={setValue}
|
|
88
|
-
value={value}
|
|
89
|
-
nextButtonProps={{ label: 'Next month' }}
|
|
90
|
-
previousButtonProps={{ label: 'Previous month' }}
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
54
|
+
/**
|
|
55
|
+
* With default month
|
|
56
|
+
*/
|
|
57
|
+
export const DefaultMonth = {
|
|
58
|
+
args: {
|
|
59
|
+
...LabelPlaceholderAndHelper.args,
|
|
60
|
+
defaultMonth: new Date('2019-07-14'),
|
|
61
|
+
},
|
|
93
62
|
};
|