@lumx/react 3.1.4 → 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.
Files changed (144) hide show
  1. package/_internal/types.d.ts +16 -5
  2. package/index.d.ts +51 -4
  3. package/index.js +621 -417
  4. package/index.js.map +1 -1
  5. package/package.json +3 -3
  6. package/src/components/alert-dialog/AlertDialog.stories.tsx +96 -165
  7. package/src/components/alert-dialog/AlertDialog.test.tsx +15 -23
  8. package/src/components/avatar/Avatar.stories.tsx +91 -62
  9. package/src/components/avatar/Avatar.test.tsx +9 -24
  10. package/src/components/badge/Badge.stories.tsx +63 -38
  11. package/src/components/button/Button.stories.tsx +147 -139
  12. package/src/components/button/IconButton.stories.tsx +45 -0
  13. package/src/components/checkbox/Checkbox.stories.tsx +37 -30
  14. package/src/components/chip/Chip.stories.tsx +77 -15
  15. package/src/components/comment-block/CommentBlock.stories.tsx +90 -25
  16. package/src/components/comment-block/CommentBlock.test.tsx +12 -17
  17. package/src/components/date-picker/DatePickerField.stories.tsx +52 -83
  18. package/src/components/dialog/Dialog.stories.tsx +132 -240
  19. package/src/components/dialog/Dialog.test.tsx +6 -30
  20. package/src/components/dialog/Dialog.tsx +17 -3
  21. package/src/components/dropdown/Dropdown.stories.tsx +1 -186
  22. package/src/components/flag/Flag.stories.tsx +33 -18
  23. package/src/components/flag/Flag.test.tsx +1 -8
  24. package/src/components/flex-box/FlexBox.stories.tsx +151 -238
  25. package/src/components/flex-box/FlexBox.test.tsx +9 -49
  26. package/src/components/generic-block/GenericBlock.stories.jsx +1 -1
  27. package/src/components/grid-column/GridColumn.stories.tsx +46 -0
  28. package/src/components/heading/Heading.stories.tsx +57 -95
  29. package/src/components/icon/Icon.stories.tsx +67 -70
  30. package/src/components/image-block/ImageBlock.stories.tsx +103 -47
  31. package/src/components/image-block/ImageBlock.test.tsx +12 -17
  32. package/src/components/inline-list/InlineList.stories.tsx +45 -29
  33. package/src/components/input-helper/InputHelper.stories.tsx +31 -25
  34. package/src/components/input-label/InputLabel.stories.tsx +33 -10
  35. package/src/components/lightbox/Lightbox.stories.tsx +39 -77
  36. package/src/components/lightbox/Lightbox.test.tsx +12 -17
  37. package/src/components/link/Link.stories.tsx +98 -128
  38. package/src/components/link-preview/LinkPreview.stories.tsx +48 -75
  39. package/src/components/list/List.stories.tsx +59 -84
  40. package/src/components/list/List.test.tsx +8 -17
  41. package/src/components/list/ListDivider.stories.tsx +9 -4
  42. package/src/components/list/ListDivider.test.tsx +12 -17
  43. package/src/components/list/ListItem.stories.tsx +97 -59
  44. package/src/components/list/ListItem.test.tsx +12 -17
  45. package/src/components/list/ListSubheader.stories.tsx +8 -5
  46. package/src/components/list/ListSubheader.test.tsx +12 -18
  47. package/src/components/message/Message.stories.tsx +51 -22
  48. package/src/components/mosaic/Mosaic.stories.tsx +78 -74
  49. package/src/components/mosaic/Mosaic.test.tsx +0 -31
  50. package/src/components/navigation/Navigation.stories.tsx +67 -0
  51. package/src/components/navigation/Navigation.test.tsx +58 -0
  52. package/src/components/navigation/Navigation.tsx +62 -0
  53. package/src/components/navigation/NavigationItem.test.tsx +37 -0
  54. package/src/components/navigation/NavigationItem.tsx +89 -0
  55. package/src/components/navigation/NavigationSection.test.tsx +126 -0
  56. package/src/components/navigation/NavigationSection.tsx +109 -0
  57. package/src/components/navigation/context.tsx +6 -0
  58. package/src/components/navigation/index.ts +1 -0
  59. package/src/components/notification/Notifications.stories.tsx +52 -47
  60. package/src/components/popover/Popover.stories.tsx +68 -201
  61. package/src/components/popover-dialog/PopoverDialog.stories.tsx +26 -65
  62. package/src/components/post-block/PostBlock.test.tsx +12 -17
  63. package/src/components/progress/ProgressCircular.stories.tsx +24 -12
  64. package/src/components/progress/ProgressLinear.stories.tsx +6 -2
  65. package/src/components/radio-button/RadioButton.stories.tsx +35 -24
  66. package/src/components/select/Select.stories.tsx +19 -23
  67. package/src/components/skeleton/SkeletonCircle.stories.tsx +37 -21
  68. package/src/components/skeleton/SkeletonCircle.test.tsx +12 -17
  69. package/src/components/skeleton/SkeletonRectangle.stories.tsx +74 -99
  70. package/src/components/skeleton/SkeletonRectangle.test.tsx +12 -17
  71. package/src/components/skeleton/SkeletonTypography.test.tsx +12 -17
  72. package/src/components/slider/Slider.stories.tsx +41 -25
  73. package/src/components/slider/Slider.test.tsx +12 -18
  74. package/src/components/slideshow/Slideshow.stories.tsx +31 -61
  75. package/src/components/slideshow/Slideshow.test.tsx +15 -23
  76. package/src/components/slideshow/SlideshowControls.stories.tsx +4 -6
  77. package/src/components/switch/Switch.stories.tsx +35 -32
  78. package/src/components/table/Table.test.tsx +12 -17
  79. package/src/components/tabs/Tabs.stories.tsx +4 -3
  80. package/src/components/text/Text.stories.tsx +130 -0
  81. package/src/components/text-field/TextField.stories.tsx +114 -148
  82. package/src/components/thumbnail/Thumbnail.stories.tsx +106 -255
  83. package/src/components/thumbnail/Thumbnail.test.tsx +12 -35
  84. package/src/components/tooltip/Tooltip.stories.tsx +51 -136
  85. package/src/components/user-block/UserBlock.stories.tsx +67 -56
  86. package/src/components/user-block/UserBlock.test.tsx +1 -5
  87. package/src/index.ts +1 -0
  88. package/src/stories/controls/color.ts +6 -0
  89. package/src/stories/controls/element.ts +6 -0
  90. package/src/stories/controls/focusPoint.ts +1 -0
  91. package/src/stories/controls/icons.ts +6 -0
  92. package/src/stories/{knobs → controls}/image.ts +6 -16
  93. package/src/stories/controls/selectArgType.ts +4 -0
  94. package/src/stories/controls/theme.ts +3 -0
  95. package/src/stories/controls/typography.ts +5 -0
  96. package/src/stories/controls/withUndefined.ts +1 -0
  97. package/src/stories/decorators/withChromaticForceScreenSize.tsx +8 -0
  98. package/src/stories/decorators/withCombinations.tsx +99 -0
  99. package/src/stories/decorators/withNestedProps.tsx +23 -0
  100. package/src/stories/{withResizableBox.tsx → decorators/withResizableBox.tsx} +6 -10
  101. package/src/stories/decorators/withValueOnChange.tsx +18 -0
  102. package/src/stories/decorators/withWrapper.tsx +19 -0
  103. package/src/stories/utils/CustomLink.tsx +8 -2
  104. package/src/stories/{knobs → utils}/lorem.ts +9 -9
  105. package/src/testing/utils/commonTestsSuiteRTL.ts +2 -3
  106. package/src/testing/utils/index.ts +0 -2
  107. package/src/untypped-modules.d.ts +0 -2
  108. package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
  109. package/src/utils/ThemeContext.ts +4 -0
  110. package/src/utils/forwardRefPolymorphic.ts +9 -0
  111. package/src/utils/type.ts +28 -4
  112. package/src/components/alert-dialog/__snapshots__/AlertDialog.test.tsx.snap +0 -551
  113. package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +0 -681
  114. package/src/components/comment-block/__snapshots__/CommentBlock.test.tsx.snap +0 -92
  115. package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +0 -960
  116. package/src/components/expansion-panel/ExpansionPanel.stories.tsx +0 -65
  117. package/src/components/flag/__snapshots__/Flag.test.tsx.snap +0 -133
  118. package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +0 -492
  119. package/src/components/grid-column/GridColumn.stories.jsx +0 -56
  120. package/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +0 -64
  121. package/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +0 -194
  122. package/src/components/list/__snapshots__/List.test.tsx.snap +0 -360
  123. package/src/components/list/__snapshots__/ListDivider.test.tsx.snap +0 -7
  124. package/src/components/list/__snapshots__/ListItem.test.tsx.snap +0 -160
  125. package/src/components/list/__snapshots__/ListSubheader.test.tsx.snap +0 -9
  126. package/src/components/mosaic/__snapshots__/Mosaic.test.tsx.snap +0 -357
  127. package/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +0 -139
  128. package/src/components/skeleton/__snapshots__/SkeletonCircle.test.tsx.snap +0 -54
  129. package/src/components/skeleton/__snapshots__/SkeletonRectangle.test.tsx.snap +0 -177
  130. package/src/components/skeleton/__snapshots__/SkeletonTypography.test.tsx.snap +0 -174
  131. package/src/components/slider/__snapshots__/Slider.test.tsx.snap +0 -122
  132. package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +0 -157
  133. package/src/components/table/__snapshots__/Table.test.tsx.snap +0 -263
  134. package/src/components/text/Text.stories.jsx +0 -75
  135. package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +0 -130
  136. package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +0 -362
  137. package/src/stories/chromaticForceScreenSize.tsx +0 -7
  138. package/src/stories/knobs/buttonKnob.ts +0 -9
  139. package/src/stories/knobs/emphasisKnob.ts +0 -8
  140. package/src/stories/knobs/enumKnob.ts +0 -14
  141. package/src/stories/knobs/focusKnob.ts +0 -3
  142. package/src/stories/knobs/sizeKnob.ts +0 -5
  143. package/src/stories/knobs/thumbnailsKnob.ts +0 -9
  144. 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, Emphasis, Size } from '@lumx/react';
4
+ import { Button, CommentBlock } from '@lumx/react';
4
5
  import { IconButton } from '@lumx/react/components/button/IconButton';
5
- import { avatarImageKnob } from '@lumx/react/stories/knobs/image';
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 { title: 'LumX components/comment-block/CommentBlock' };
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
- export const WithHeaderActions = ({ theme }: any) => (
10
- <CommentBlock
11
- hasActions
12
- actions={[
13
- <Button key="button0" theme={theme} emphasis={Emphasis.low} size={Size.s} leftIcon={mdiHeart}>
14
- 24 likes
15
- </Button>,
16
- <Button key="button1" theme={theme} emphasis={Emphasis.low} size={Size.s} leftIcon={mdiReply}>
17
- Reply
18
- </Button>,
19
- ]}
20
- theme={theme}
21
- avatarProps={{ image: avatarImageKnob(), alt: 'Avatar' }}
22
- date="5 days"
23
- fullDate="Monday, March 30, 2021 at 4:06 PM"
24
- name="Emmitt O. Lum"
25
- text="All the rumors have finally died down and many skeptics have tightened their lips, the iPod does support video format now on its fifth generation."
26
- headerActions={
27
- <IconButton label="Actions" icon={mdiDotsHorizontal} theme={theme} emphasis={Emphasis.low} size={Size.s} />
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 { mount, shallow } from 'enzyme';
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
- * Mounts the component and returns common DOM elements / data needed in multiple tests further down.
13
- */
14
- const setup = (props: Partial<CommentBlockProps> = {}, shallowRendering = true) => {
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
- commonTestsSuite(setup, { className: 'wrapper', prop: 'wrapper' }, { className: CLASSNAME });
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
- export default { title: 'LumX components/date-picker/DatePickerField' };
6
-
7
- export const Simple = ({ theme }: any) => {
8
- const [value, setValue] = useState<Date | undefined>();
9
-
10
- return (
11
- <DatePickerField
12
- locale="fr"
13
- label="Start date"
14
- placeholder="Pick a date"
15
- theme={theme}
16
- onChange={setValue}
17
- value={value}
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
- export const WithDefaultValue = ({ theme }: any) => {
25
- const [value, setValue] = useState<Date | undefined>(new Date('2020-05-18'));
26
-
27
- return (
28
- <DatePickerField
29
- locale="fr"
30
- label="Start date"
31
- placeholder="Pick a date"
32
- theme={theme}
33
- onChange={setValue}
34
- value={value}
35
- nextButtonProps={{ label: 'Next month' }}
36
- previousButtonProps={{ label: 'Previous month' }}
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
- export const WithErrorAndHelper = ({ theme }: any) => {
42
- const [value, setValue] = useState<Date | undefined>(new Date('2020-05-18'));
43
-
44
- return (
45
- <DatePickerField
46
- locale="fr"
47
- label="Start date"
48
- placeholder="Pick a date"
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
- export const CustomMonth = ({ theme }: any) => {
61
- const [value, setValue] = useState<Date | undefined>();
62
-
63
- return (
64
- <DatePickerField
65
- locale="fr"
66
- label="Initialized to 2019 July"
67
- placeholder="Pick a date"
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
- export const With28FebruarySelected = ({ theme }: any) => {
79
- const [value, setValue] = useState<Date | undefined>(new Date('2019-02-28'));
80
-
81
- return (
82
- <DatePickerField
83
- locale="fr"
84
- label="Start date"
85
- placeholder="Pick a date"
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
  };