@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.
Files changed (143) hide show
  1. package/_internal/types.d.ts +16 -5
  2. package/index.d.ts +45 -4
  3. package/index.js +609 -411
  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 +131 -293
  19. package/src/components/dialog/Dialog.test.tsx +0 -32
  20. package/src/components/dropdown/Dropdown.stories.tsx +1 -186
  21. package/src/components/flag/Flag.stories.tsx +33 -18
  22. package/src/components/flag/Flag.test.tsx +1 -8
  23. package/src/components/flex-box/FlexBox.stories.tsx +151 -238
  24. package/src/components/flex-box/FlexBox.test.tsx +9 -49
  25. package/src/components/generic-block/GenericBlock.stories.jsx +1 -1
  26. package/src/components/grid-column/GridColumn.stories.tsx +46 -0
  27. package/src/components/heading/Heading.stories.tsx +57 -95
  28. package/src/components/icon/Icon.stories.tsx +67 -70
  29. package/src/components/image-block/ImageBlock.stories.tsx +103 -47
  30. package/src/components/image-block/ImageBlock.test.tsx +12 -17
  31. package/src/components/inline-list/InlineList.stories.tsx +45 -29
  32. package/src/components/input-helper/InputHelper.stories.tsx +31 -25
  33. package/src/components/input-label/InputLabel.stories.tsx +33 -10
  34. package/src/components/lightbox/Lightbox.stories.tsx +39 -77
  35. package/src/components/lightbox/Lightbox.test.tsx +12 -17
  36. package/src/components/link/Link.stories.tsx +98 -128
  37. package/src/components/link-preview/LinkPreview.stories.tsx +48 -75
  38. package/src/components/list/List.stories.tsx +59 -84
  39. package/src/components/list/List.test.tsx +8 -17
  40. package/src/components/list/ListDivider.stories.tsx +9 -4
  41. package/src/components/list/ListDivider.test.tsx +12 -17
  42. package/src/components/list/ListItem.stories.tsx +97 -59
  43. package/src/components/list/ListItem.test.tsx +12 -17
  44. package/src/components/list/ListSubheader.stories.tsx +8 -5
  45. package/src/components/list/ListSubheader.test.tsx +12 -18
  46. package/src/components/message/Message.stories.tsx +51 -22
  47. package/src/components/mosaic/Mosaic.stories.tsx +78 -74
  48. package/src/components/mosaic/Mosaic.test.tsx +0 -31
  49. package/src/components/navigation/Navigation.stories.tsx +67 -0
  50. package/src/components/navigation/Navigation.test.tsx +58 -0
  51. package/src/components/navigation/Navigation.tsx +62 -0
  52. package/src/components/navigation/NavigationItem.test.tsx +37 -0
  53. package/src/components/navigation/NavigationItem.tsx +89 -0
  54. package/src/components/navigation/NavigationSection.test.tsx +126 -0
  55. package/src/components/navigation/NavigationSection.tsx +109 -0
  56. package/src/components/navigation/context.tsx +6 -0
  57. package/src/components/navigation/index.ts +1 -0
  58. package/src/components/notification/Notifications.stories.tsx +52 -47
  59. package/src/components/popover/Popover.stories.tsx +68 -201
  60. package/src/components/popover-dialog/PopoverDialog.stories.tsx +26 -65
  61. package/src/components/post-block/PostBlock.test.tsx +12 -17
  62. package/src/components/progress/ProgressCircular.stories.tsx +24 -12
  63. package/src/components/progress/ProgressLinear.stories.tsx +6 -2
  64. package/src/components/radio-button/RadioButton.stories.tsx +35 -24
  65. package/src/components/select/Select.stories.tsx +19 -23
  66. package/src/components/skeleton/SkeletonCircle.stories.tsx +37 -21
  67. package/src/components/skeleton/SkeletonCircle.test.tsx +12 -17
  68. package/src/components/skeleton/SkeletonRectangle.stories.tsx +74 -99
  69. package/src/components/skeleton/SkeletonRectangle.test.tsx +12 -17
  70. package/src/components/skeleton/SkeletonTypography.test.tsx +12 -17
  71. package/src/components/slider/Slider.stories.tsx +41 -25
  72. package/src/components/slider/Slider.test.tsx +12 -18
  73. package/src/components/slideshow/Slideshow.stories.tsx +31 -61
  74. package/src/components/slideshow/Slideshow.test.tsx +15 -23
  75. package/src/components/slideshow/SlideshowControls.stories.tsx +4 -6
  76. package/src/components/switch/Switch.stories.tsx +35 -32
  77. package/src/components/table/Table.test.tsx +12 -17
  78. package/src/components/tabs/Tabs.stories.tsx +4 -3
  79. package/src/components/text/Text.stories.tsx +130 -0
  80. package/src/components/text-field/TextField.stories.tsx +114 -148
  81. package/src/components/thumbnail/Thumbnail.stories.tsx +106 -255
  82. package/src/components/thumbnail/Thumbnail.test.tsx +12 -35
  83. package/src/components/tooltip/Tooltip.stories.tsx +51 -136
  84. package/src/components/user-block/UserBlock.stories.tsx +67 -56
  85. package/src/components/user-block/UserBlock.test.tsx +1 -5
  86. package/src/index.ts +1 -0
  87. package/src/stories/controls/color.ts +6 -0
  88. package/src/stories/controls/element.ts +6 -0
  89. package/src/stories/controls/focusPoint.ts +1 -0
  90. package/src/stories/controls/icons.ts +6 -0
  91. package/src/stories/{knobs → controls}/image.ts +6 -16
  92. package/src/stories/controls/selectArgType.ts +4 -0
  93. package/src/stories/controls/theme.ts +3 -0
  94. package/src/stories/controls/typography.ts +5 -0
  95. package/src/stories/controls/withUndefined.ts +1 -0
  96. package/src/stories/decorators/withChromaticForceScreenSize.tsx +8 -0
  97. package/src/stories/decorators/withCombinations.tsx +99 -0
  98. package/src/stories/decorators/withNestedProps.tsx +23 -0
  99. package/src/stories/{withResizableBox.tsx → decorators/withResizableBox.tsx} +6 -10
  100. package/src/stories/decorators/withValueOnChange.tsx +18 -0
  101. package/src/stories/decorators/withWrapper.tsx +19 -0
  102. package/src/stories/utils/CustomLink.tsx +8 -2
  103. package/src/stories/{knobs → utils}/lorem.ts +9 -9
  104. package/src/testing/utils/commonTestsSuiteRTL.ts +2 -3
  105. package/src/testing/utils/index.ts +0 -2
  106. package/src/untypped-modules.d.ts +0 -2
  107. package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
  108. package/src/utils/ThemeContext.ts +4 -0
  109. package/src/utils/forwardRefPolymorphic.ts +9 -0
  110. package/src/utils/type.ts +28 -4
  111. package/src/components/alert-dialog/__snapshots__/AlertDialog.test.tsx.snap +0 -558
  112. package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +0 -681
  113. package/src/components/comment-block/__snapshots__/CommentBlock.test.tsx.snap +0 -92
  114. package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +0 -1133
  115. package/src/components/expansion-panel/ExpansionPanel.stories.tsx +0 -65
  116. package/src/components/flag/__snapshots__/Flag.test.tsx.snap +0 -133
  117. package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +0 -492
  118. package/src/components/grid-column/GridColumn.stories.jsx +0 -56
  119. package/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +0 -64
  120. package/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +0 -194
  121. package/src/components/list/__snapshots__/List.test.tsx.snap +0 -360
  122. package/src/components/list/__snapshots__/ListDivider.test.tsx.snap +0 -7
  123. package/src/components/list/__snapshots__/ListItem.test.tsx.snap +0 -160
  124. package/src/components/list/__snapshots__/ListSubheader.test.tsx.snap +0 -9
  125. package/src/components/mosaic/__snapshots__/Mosaic.test.tsx.snap +0 -357
  126. package/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +0 -139
  127. package/src/components/skeleton/__snapshots__/SkeletonCircle.test.tsx.snap +0 -54
  128. package/src/components/skeleton/__snapshots__/SkeletonRectangle.test.tsx.snap +0 -177
  129. package/src/components/skeleton/__snapshots__/SkeletonTypography.test.tsx.snap +0 -174
  130. package/src/components/slider/__snapshots__/Slider.test.tsx.snap +0 -122
  131. package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +0 -157
  132. package/src/components/table/__snapshots__/Table.test.tsx.snap +0 -263
  133. package/src/components/text/Text.stories.jsx +0 -75
  134. package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +0 -130
  135. package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +0 -362
  136. package/src/stories/chromaticForceScreenSize.tsx +0 -7
  137. package/src/stories/knobs/buttonKnob.ts +0 -9
  138. package/src/stories/knobs/emphasisKnob.ts +0 -8
  139. package/src/stories/knobs/enumKnob.ts +0 -14
  140. package/src/stories/knobs/focusKnob.ts +0 -3
  141. package/src/stories/knobs/sizeKnob.ts +0 -5
  142. package/src/stories/knobs/thumbnailsKnob.ts +0 -9
  143. package/src/testing/utils/itShouldRenderStories.tsx +0 -103
@@ -1,195 +1,10 @@
1
1
  import range from 'lodash/range';
2
2
  import React, { useRef, useState } from 'react';
3
3
 
4
- import { mdiHome } from '@lumx/icons';
5
- import {
6
- Alignment,
7
- Button,
8
- Dropdown,
9
- FlexBox,
10
- IconButton,
11
- List,
12
- ListItem,
13
- Orientation,
14
- Placement,
15
- Size,
16
- } from '@lumx/react';
4
+ import { Button, Dropdown, List, ListItem } from '@lumx/react';
17
5
 
18
6
  export default { title: 'LumX components/dropdown/Dropdown' };
19
7
 
20
- export const MatchAnchorWithMinWidth = () => {
21
- const buttonRef1 = useRef<any>(null);
22
- const buttonRef2 = useRef<any>(null);
23
- return (
24
- <>
25
- <div>Match anchor width only if the dropdown is smaller</div>
26
- <FlexBox orientation={Orientation.horizontal}>
27
- <IconButton label="Home" icon={mdiHome} ref={buttonRef1} />
28
- <Dropdown anchorRef={buttonRef1} isOpen>
29
- Big dropdown
30
- </Dropdown>
31
-
32
- <FlexBox marginAuto={Alignment.left}>
33
- <Button ref={buttonRef2}>Big button with long text</Button>
34
- </FlexBox>
35
- <Dropdown anchorRef={buttonRef2} isOpen>
36
- Small Dropdown
37
- </Dropdown>
38
- </FlexBox>
39
- </>
40
- );
41
- };
42
-
43
- export const LongPagePlacement = () => {
44
- const anchorFirstRef = React.useRef(null);
45
- const [isFirstOpen, setFirstIsOpen] = React.useState(false);
46
- const toggleFirstMenu = () => setFirstIsOpen(!isFirstOpen);
47
- const closeFirstMenu = () => setFirstIsOpen(false);
48
-
49
- const onFirstMenuSelected = (item: string) => () => {
50
- console.log('selected item', item);
51
- closeFirstMenu();
52
- };
53
-
54
- const anchorSecondRef = React.useRef(null);
55
- const [isSecondOpen, setSecondIsOpen] = React.useState(false);
56
- const toggleSecondMenu = () => setSecondIsOpen(!isSecondOpen);
57
- const closeSecondMenu = () => setSecondIsOpen(false);
58
-
59
- const onSecondMenuSelected = (item: string) => () => {
60
- console.log('selected item', item);
61
- closeSecondMenu();
62
- };
63
-
64
- const anchorThirdRef = React.useRef(null);
65
- const [isThirdOpen, setThirdIsOpen] = React.useState(false);
66
- const toggleThirdMenu = () => setThirdIsOpen(!isThirdOpen);
67
- const closeThirdMenu = () => setThirdIsOpen(false);
68
-
69
- const onThirdMenuSelected = (item: string) => () => {
70
- console.log('selected item', item);
71
- closeThirdMenu();
72
- };
73
-
74
- return (
75
- <div className="demo-grid">
76
- Scroll down and open the dropdown.
77
- <div style={{ marginTop: '100px' }}>
78
- <Button ref={anchorFirstRef} onClick={toggleFirstMenu}>
79
- First Menu
80
- </Button>
81
-
82
- <Dropdown
83
- closeOnClickAway
84
- closeOnEscape
85
- isOpen={isFirstOpen}
86
- onClose={closeFirstMenu}
87
- placement={Placement.BOTTOM_START}
88
- anchorRef={anchorFirstRef}
89
- >
90
- <List isClickable>
91
- <ListItem onItemSelected={onFirstMenuSelected('losangeles')} size={Size.tiny}>
92
- Los Angeles
93
- </ListItem>
94
-
95
- <ListItem onItemSelected={onFirstMenuSelected('monterrey')} size={Size.tiny}>
96
- Monterrey
97
- </ListItem>
98
-
99
- <ListItem onItemSelected={onFirstMenuSelected('georgetown')} size={Size.tiny}>
100
- Georgetown
101
- </ListItem>
102
-
103
- <ListItem onItemSelected={onFirstMenuSelected('cali')} size={Size.tiny}>
104
- Cali
105
- </ListItem>
106
-
107
- <ListItem onItemSelected={onFirstMenuSelected('trondheim')} size={Size.tiny}>
108
- Trondheim
109
- </ListItem>
110
- </List>
111
- </Dropdown>
112
- </div>
113
- <div style={{ marginTop: '1000px' }}>
114
- <Button ref={anchorSecondRef} onClick={toggleSecondMenu}>
115
- Second Menu
116
- </Button>
117
-
118
- <Dropdown
119
- closeOnClickAway
120
- closeOnEscape
121
- isOpen={isSecondOpen}
122
- onClose={closeSecondMenu}
123
- placement={Placement.BOTTOM_START}
124
- anchorRef={anchorSecondRef}
125
- >
126
- <List isClickable>
127
- <ListItem onItemSelected={onSecondMenuSelected('losangeles')} size={Size.tiny}>
128
- Los Angeles
129
- </ListItem>
130
-
131
- <ListItem onItemSelected={onSecondMenuSelected('monterrey')} size={Size.tiny}>
132
- Monterrey
133
- </ListItem>
134
-
135
- <ListItem onItemSelected={onSecondMenuSelected('georgetown')} size={Size.tiny}>
136
- Georgetown
137
- </ListItem>
138
-
139
- <ListItem onItemSelected={onSecondMenuSelected('cali')} size={Size.tiny}>
140
- Cali
141
- </ListItem>
142
-
143
- <ListItem onItemSelected={onSecondMenuSelected('trondheim')} size={Size.tiny}>
144
- Trondheim
145
- </ListItem>
146
- </List>
147
- </Dropdown>
148
- </div>
149
- <div style={{ marginTop: '2000px' }}>
150
- <Button ref={anchorThirdRef} onClick={toggleThirdMenu}>
151
- Third Menu
152
- </Button>
153
-
154
- <Dropdown
155
- closeOnClickAway
156
- closeOnEscape
157
- isOpen={isThirdOpen}
158
- onClose={closeThirdMenu}
159
- placement={Placement.BOTTOM_START}
160
- anchorRef={anchorThirdRef}
161
- >
162
- <List isClickable>
163
- <ListItem onItemSelected={onThirdMenuSelected('losangeles')} size={Size.tiny}>
164
- Los Angeles
165
- </ListItem>
166
-
167
- <ListItem onItemSelected={onThirdMenuSelected('monterrey')} size={Size.tiny}>
168
- Monterrey
169
- </ListItem>
170
-
171
- <ListItem onItemSelected={onThirdMenuSelected('georgetown')} size={Size.tiny}>
172
- Georgetown
173
- </ListItem>
174
-
175
- <ListItem onItemSelected={onThirdMenuSelected('cali')} size={Size.tiny}>
176
- Cali
177
- </ListItem>
178
-
179
- <ListItem onItemSelected={onThirdMenuSelected('trondheim')} size={Size.tiny}>
180
- Trondheim
181
- </ListItem>
182
- </List>
183
- </Dropdown>
184
- </div>
185
- </div>
186
- );
187
- };
188
- LongPagePlacement.parameters = {
189
- // Disables Chromatic snapshot (not relevant for this story).
190
- chromatic: { disable: true },
191
- };
192
-
193
8
  export const InfiniteScroll = () => {
194
9
  const buttonRef = useRef(null);
195
10
  const [items, setItems] = useState(range(10));
@@ -1,23 +1,38 @@
1
- import React from 'react';
2
- import { text } from '@storybook/addon-knobs';
3
-
4
1
  import { mdiHeart } from '@lumx/icons';
5
2
  import { ColorPalette, Flag } from '@lumx/react';
3
+ import { colorArgType } from '@lumx/react/stories/controls/color';
4
+ import { iconArgType } from '@lumx/react/stories/controls/icons';
5
+ import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
6
+ import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
7
+
8
+ export default {
9
+ title: 'LumX components/flag/Flag',
10
+ component: Flag,
11
+ argTypes: { color: colorArgType, icon: iconArgType },
12
+ args: { ...Flag.defaultProps, label: 'Label' },
13
+ };
14
+
15
+ /**
16
+ * Default flag with label
17
+ */
18
+ export const Default = {};
6
19
 
7
- export default { title: 'LumX components/flag/Flag' };
20
+ /**
21
+ * With icon
22
+ */
23
+ export const WithIcon = { args: { icon: mdiHeart } };
8
24
 
9
- export const defaultProps = ({ theme }: any) => <Flag label={text('Label', 'hearing')} theme={theme} />;
10
- export const withIcon = ({ theme }: any) => <Flag icon={mdiHeart} label={text('Label', 'hearing')} theme={theme} />;
11
- export const withColor = ({ theme }: any) => {
12
- return (
13
- <>
14
- <Flag color={ColorPalette.blue} icon={mdiHeart} label="blue" theme={theme} />
15
- <Flag color={ColorPalette.dark} icon={mdiHeart} label="dark" theme={theme} />
16
- <Flag color={ColorPalette.green} icon={mdiHeart} label="green" theme={theme} />
17
- <Flag color={ColorPalette.primary} icon={mdiHeart} label="primary" theme={theme} />
18
- <Flag color={ColorPalette.red} icon={mdiHeart} label="red" theme={theme} />
19
- <Flag color={ColorPalette.secondary} icon={mdiHeart} label="secondary" theme={theme} />
20
- <Flag color={ColorPalette.yellow} icon={mdiHeart} label="yellow" theme={theme} />
21
- </>
22
- );
25
+ /**
26
+ * All `color` variants
27
+ */
28
+ export const AllColors = {
29
+ ...WithIcon,
30
+ argTypes: { color: { control: false } },
31
+ decorators: [
32
+ withCombinations({
33
+ combinations: {
34
+ cols: { key: 'color', options: withUndefined(ColorPalette) },
35
+ },
36
+ }),
37
+ ],
23
38
  };
@@ -4,11 +4,10 @@ import React, { ReactElement } from 'react';
4
4
 
5
5
  import { ColorPalette, Theme } from '@lumx/react';
6
6
  import { mdiAbTesting } from '@lumx/icons';
7
- import { itShouldRenderStories, commonTestsSuite, Wrapper } from '@lumx/react/testing/utils';
7
+ import { commonTestsSuite, Wrapper } from '@lumx/react/testing/utils';
8
8
  import { getBasicClass } from '@lumx/react/utils/className';
9
9
 
10
10
  import { Flag, FlagProps } from './Flag';
11
- import * as stories from './Flag.stories';
12
11
 
13
12
  const CLASSNAME = Flag.className as string;
14
13
 
@@ -31,12 +30,6 @@ const setup = (propOverrides: Partial<FlagProps> = {}, shallowRendering = true)
31
30
  };
32
31
 
33
32
  describe(`<${Flag.displayName} />`, () => {
34
- // 1. Test render via snapshot (default state of component).
35
- describe('Snapshots and structure', () => {
36
- itShouldRenderStories(stories, Flag);
37
- });
38
-
39
- // 4. Test conditions (i.e. things that display or not in the UI based on props).
40
33
  describe('Conditions', () => {
41
34
  it('should use the icon', () => {
42
35
  const { iconEl } = setup({ icon: mdiAbTesting });