@lumx/react 3.0.3 → 3.0.4-alpha.1

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 (52) hide show
  1. package/_internal/ClickAwayProvider.js +37 -232
  2. package/_internal/ClickAwayProvider.js.map +1 -1
  3. package/index.d.ts +10 -2
  4. package/index.js +4031 -4319
  5. package/index.js.map +1 -1
  6. package/package.json +28 -34
  7. package/src/components/alert-dialog/__snapshots__/AlertDialog.test.tsx.snap +23 -23
  8. package/src/components/autocomplete/Autocomplete.tsx +8 -0
  9. package/src/components/autocomplete/__snapshots__/Autocomplete.test.tsx.snap +4 -4
  10. package/src/components/autocomplete/__snapshots__/AutocompleteMultiple.test.tsx.snap +1 -1
  11. package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +6 -6
  12. package/src/components/button/__snapshots__/ButtonRoot.test.tsx.snap +1 -1
  13. package/src/components/button/index.ts +1 -0
  14. package/src/components/date-picker/__snapshots__/DatePicker.test.tsx.snap +2 -2
  15. package/src/components/date-picker/__snapshots__/DatePickerField.test.tsx.snap +2 -2
  16. package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +22 -22
  17. package/src/components/dropdown/Dropdown.tsx +2 -0
  18. package/src/components/dropdown/__snapshots__/Dropdown.test.tsx.snap +2 -2
  19. package/src/components/flag/__snapshots__/Flag.test.tsx.snap +1 -1
  20. package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +31 -31
  21. package/src/components/heading/Heading.test.tsx +32 -27
  22. package/src/components/icon/__snapshots__/Icon.test.tsx.snap +2 -2
  23. package/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +1 -1
  24. package/src/components/index.ts +5 -0
  25. package/src/components/inline-list/InlineList.tsx +3 -1
  26. package/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +7 -7
  27. package/src/components/list/__snapshots__/List.test.tsx.snap +13 -13
  28. package/src/components/notification/__snapshots__/Notification.test.tsx.snap +1 -1
  29. package/src/components/popover/__snapshots__/Popover.test.tsx.snap +52 -52
  30. package/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +4 -4
  31. package/src/components/progress-tracker/__snapshots__/ProgressTracker.test.tsx.snap +2 -2
  32. package/src/components/select/__snapshots__/Select.test.tsx.snap +2 -2
  33. package/src/components/select/__snapshots__/SelectMultiple.test.tsx.snap +6 -6
  34. package/src/components/skeleton/__snapshots__/SkeletonCircle.test.tsx.snap +1 -1
  35. package/src/components/skeleton/__snapshots__/SkeletonRectangle.test.tsx.snap +1 -1
  36. package/src/components/skeleton/__snapshots__/SkeletonTypography.test.tsx.snap +15 -15
  37. package/src/components/slider/__snapshots__/Slider.test.tsx.snap +4 -4
  38. package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +10 -10
  39. package/src/components/table/__snapshots__/Table.test.tsx.snap +1 -1
  40. package/src/components/text/Text.test.tsx +67 -35
  41. package/src/components/text/Text.tsx +8 -7
  42. package/src/components/text-field/TextField.test.tsx +75 -117
  43. package/src/components/text-field/__snapshots__/TextField.test.tsx.snap +12 -17
  44. package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +6 -6
  45. package/src/components/tooltip/__snapshots__/Tooltip.test.tsx.snap +6 -6
  46. package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +11 -11
  47. package/src/stories/generated/Dropdown/Demos.stories.tsx +1 -0
  48. package/src/testing/utils/commonTestsSuiteRTL.ts +55 -0
  49. package/src/testing/utils/index.ts +1 -0
  50. package/src/testing/utils/queries.ts +19 -0
  51. package/src/utils/focus/getFocusableElements.test.ts +12 -12
  52. package/types.d.ts +0 -2847
@@ -60,6 +60,8 @@ export interface DropdownProps extends GenericProps {
60
60
  placement?: Placement;
61
61
  /** Whether the focus should be set on the list when the dropdown is open or not. */
62
62
  shouldFocusOnOpen?: boolean;
63
+ /** Whether the dropdown should be rendered into a DOM node that exists outside the DOM hierarchy of the parent component. */
64
+ usePortal?: boolean;
63
65
  /** Whether the focus should go back on the anchor when dropdown closes and focus is within. */
64
66
  focusAnchorOnClose?: boolean;
65
67
  /**
@@ -3,7 +3,7 @@
3
3
  exports[`<Dropdown> Snapshots and structure should render correctly 1`] = `
4
4
  <Popover
5
5
  anchorRef={
6
- Object {
6
+ {
7
7
  "current": null,
8
8
  }
9
9
  }
@@ -15,7 +15,7 @@ exports[`<Dropdown> Snapshots and structure should render correctly 1`] = `
15
15
  fitWithinViewportHeight={true}
16
16
  focusAnchorOnClose={true}
17
17
  focusElement={
18
- Object {
18
+ {
19
19
  "current": null,
20
20
  }
21
21
  }
@@ -13,7 +13,7 @@ exports[`<Flag /> Snapshots and structure should render story 'defaultProps' 1`]
13
13
  `;
14
14
 
15
15
  exports[`<Flag /> Snapshots and structure should render story 'withColor' 1`] = `
16
- Array [
16
+ [
17
17
  <div
18
18
  className="lumx-flag lumx-flag--color-blue"
19
19
  >
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<FlexBox> Snapshots and structure should render story 'Align' 1`] = `
4
- Array [
4
+ [
5
5
  <div
6
6
  className="lumx-flex-box lumx-flex-box--orientation-horizontal lumx-flex-box--v-align-center lumx-flex-box--h-align-center"
7
7
  >
@@ -9,7 +9,7 @@ Array [
9
9
  emphasis="high"
10
10
  size="m"
11
11
  style={
12
- Object {
12
+ {
13
13
  "height": 200,
14
14
  }
15
15
  }
@@ -19,7 +19,7 @@ Array [
19
19
  </Button>
20
20
  <FlexBox
21
21
  style={
22
- Object {
22
+ {
23
23
  "height": "fit-content",
24
24
  }
25
25
  }
@@ -30,7 +30,7 @@ Array [
30
30
  <div
31
31
  className="lumx-flex-box"
32
32
  style={
33
- Object {
33
+ {
34
34
  "height": "fit-content",
35
35
  }
36
36
  }
@@ -40,11 +40,27 @@ Array [
40
40
  ]
41
41
  `;
42
42
 
43
+ exports[`<FlexBox> Snapshots and structure should render story 'CustomizeElement' 1`] = `
44
+ <header
45
+ className="lumx-flex-box lumx-flex-box--orientation-horizontal lumx-flex-box--gap-regular"
46
+ >
47
+ <div>
48
+ Element 1
49
+ </div>
50
+ <div>
51
+ Element 2
52
+ </div>
53
+ <div>
54
+ Element 2
55
+ </div>
56
+ </header>
57
+ `;
58
+
43
59
  exports[`<FlexBox> Snapshots and structure should render story 'Distribution' 1`] = `
44
60
  <div
45
61
  className="lumx-flex-box lumx-flex-box--orientation-vertical lumx-flex-box--v-align-center lumx-flex-box--h-align-center lumx-flex-box--gap-regular"
46
62
  style={
47
- Object {
63
+ {
48
64
  "border": "1px solid red",
49
65
  "height": "300px",
50
66
  "width": "720px",
@@ -75,24 +91,8 @@ exports[`<FlexBox> Snapshots and structure should render story 'Distribution' 1`
75
91
  </div>
76
92
  `;
77
93
 
78
- exports[`<FlexBox> Snapshots and structure should render story 'CustomizeElement' 1`] = `
79
- <header
80
- className="lumx-flex-box lumx-flex-box--orientation-horizontal lumx-flex-box--gap-regular"
81
- >
82
- <div>
83
- Element 1
84
- </div>
85
- <div>
86
- Element 2
87
- </div>
88
- <div>
89
- Element 2
90
- </div>
91
- </header>
92
- `;
93
-
94
94
  exports[`<FlexBox> Snapshots and structure should render story 'Flex' 1`] = `
95
- Array [
95
+ [
96
96
  <div
97
97
  className="lumx-flex-box"
98
98
  >
@@ -141,7 +141,7 @@ Array [
141
141
  `;
142
142
 
143
143
  exports[`<FlexBox> Snapshots and structure should render story 'GapSizeFlex' 1`] = `
144
- Array [
144
+ [
145
145
  <div
146
146
  className="lumx-flex-box lumx-flex-box--orientation-vertical lumx-flex-box--gap-regular"
147
147
  >
@@ -221,11 +221,11 @@ Array [
221
221
  `;
222
222
 
223
223
  exports[`<FlexBox> Snapshots and structure should render story 'HorizontalFlex' 1`] = `
224
- Array [
224
+ [
225
225
  <div
226
226
  className="lumx-flex-box lumx-flex-box--orientation-horizontal"
227
227
  style={
228
- Object {
228
+ {
229
229
  "border": "1px solid red",
230
230
  "height": "300px",
231
231
  }
@@ -311,11 +311,11 @@ Array [
311
311
  `;
312
312
 
313
313
  exports[`<FlexBox> Snapshots and structure should render story 'NoShrinkFlex' 1`] = `
314
- Array [
314
+ [
315
315
  <div
316
316
  className="lumx-flex-box lumx-flex-box--orientation-horizontal"
317
317
  style={
318
- Object {
318
+ {
319
319
  "border": "1px solid red",
320
320
  "width": "150px",
321
321
  }
@@ -350,11 +350,11 @@ Array [
350
350
  `;
351
351
 
352
352
  exports[`<FlexBox> Snapshots and structure should render story 'VerticalFlex' 1`] = `
353
- Array [
353
+ [
354
354
  <div
355
355
  className="lumx-flex-box lumx-flex-box--orientation-vertical"
356
356
  style={
357
- Object {
357
+ {
358
358
  "border": "1px solid red",
359
359
  "height": "300px",
360
360
  }
@@ -440,11 +440,11 @@ Array [
440
440
  `;
441
441
 
442
442
  exports[`<FlexBox> Snapshots and structure should render story 'WrapFlex' 1`] = `
443
- Array [
443
+ [
444
444
  <div
445
445
  className="lumx-flex-box lumx-flex-box--orientation-horizontal lumx-flex-box--wrap"
446
446
  style={
447
- Object {
447
+ {
448
448
  "border": "1px solid red",
449
449
  "width": "150px",
450
450
  }
@@ -1,35 +1,37 @@
1
1
  import React from 'react';
2
2
 
3
- import { mount, shallow } from 'enzyme';
4
- import 'jest-enzyme';
3
+ import { render, screen } from '@testing-library/react';
5
4
 
6
- import { commonTestsSuite } from '@lumx/react/testing/utils';
5
+ import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
6
+ import { getByClassName } from '@lumx/react/testing/utils/queries';
7
7
  import { Heading, HeadingProps } from './Heading';
8
8
  import { HeadingLevelProvider } from './HeadingLevelProvider';
9
9
 
10
+ const CLASSNAME = Heading.className as string;
11
+
10
12
  const setup = (props: Partial<HeadingProps> = {}) => {
11
- const wrapper = shallow(<Heading {...props} />);
12
- return { props, wrapper };
13
+ const { container } = render(<Heading {...props} />);
14
+ return { props, container, element: getByClassName(container, CLASSNAME) };
13
15
  };
14
16
 
15
17
  describe(`<${Heading.displayName}>`, () => {
16
- describe('Snapshots and structure', () => {
18
+ describe('Render', () => {
17
19
  it('should render a Text component with h1 by default', () => {
18
- const { wrapper } = setup({ children: 'Some text' });
19
- expect(wrapper).toHaveDisplayName('Text');
20
- expect(wrapper).toHaveProp('as', 'h1');
21
- expect(wrapper.prop('className')).toBe(Heading.className);
20
+ setup({ children: 'Some text' });
21
+ const heading = screen.getByRole('heading', { level: 1, name: 'Some text' });
22
+ expect(heading).toBeInTheDocument();
23
+ expect(heading).toHaveClass(CLASSNAME);
22
24
  });
23
25
 
24
26
  it('should render with as', () => {
25
- const { wrapper } = setup({ children: 'Some text', as: 'h2' });
26
- expect(wrapper).toHaveDisplayName('Text');
27
- expect(wrapper).toHaveProp('as', 'h2');
28
- expect(wrapper.prop('className')).toBe(Heading.className);
27
+ setup({ children: 'Some text', as: 'h2' });
28
+ const heading = screen.getByRole('heading', { level: 2, name: 'Some text' });
29
+ expect(heading).toBeInTheDocument();
30
+ expect(heading).toHaveClass(CLASSNAME);
29
31
  });
30
32
 
31
33
  it('should correctly render levels nested in HeadingLevel', () => {
32
- const wrapper = mount(
34
+ render(
33
35
  <>
34
36
  <Heading>Level 1</Heading>
35
37
  <HeadingLevelProvider>
@@ -51,27 +53,30 @@ describe(`<${Heading.displayName}>`, () => {
51
53
  </HeadingLevelProvider>
52
54
  </HeadingLevelProvider>
53
55
  </HeadingLevelProvider>
54
- ,
55
56
  </>,
56
57
  );
57
58
 
58
- expect(wrapper.find('h1')).toHaveText('Level 1');
59
- expect(wrapper.find('h2')).toHaveText('Level 2');
60
- expect(wrapper.find('h3')).toHaveText('Level 3');
61
- expect(wrapper.find('h4')).toHaveText('Level 4');
59
+ expect(screen.getByRole('heading', { level: 1, name: 'Level 1' })).toBeInTheDocument();
60
+ expect(screen.getByRole('heading', { level: 2, name: 'Level 2' })).toBeInTheDocument();
61
+ expect(screen.getByRole('heading', { level: 3, name: 'Level 3' })).toBeInTheDocument();
62
+ expect(screen.getByRole('heading', { level: 4, name: 'Level 4' })).toBeInTheDocument();
62
63
 
63
- const h5 = wrapper.find('h5');
64
+ const h5 = screen.getAllByRole('heading', { level: 5 });
64
65
  expect(h5).toHaveLength(2);
65
- expect(h5.at(0)).toHaveText('Level 5 - 1');
66
- expect(h5.at(1)).toHaveText('Level 5 - 2');
66
+ expect(h5[0]).toHaveTextContent('Level 5 - 1');
67
+ expect(h5[1]).toHaveTextContent('Level 5 - 2');
67
68
  // There should be 2 h6 because it is the maximum value;
68
- const h6 = wrapper.find('h6');
69
+ const h6 = screen.getAllByRole('heading', { level: 6 });
69
70
  expect(h6).toHaveLength(2);
70
- expect(h6.at(0)).toHaveText('Level 6');
71
- expect(h6.at(1)).toHaveText('Level 7');
71
+ expect(h6[0]).toHaveTextContent('Level 6');
72
+ expect(h6[1]).toHaveTextContent('Level 7');
72
73
  });
73
74
  });
74
75
 
75
76
  // Common tests suite.
76
- commonTestsSuite(setup, { className: 'wrapper', prop: 'wrapper' }, { className: Heading.className });
77
+ commonTestsSuiteRTL(setup, {
78
+ baseClassName: CLASSNAME,
79
+ forwardClassName: 'element',
80
+ forwardAttributes: 'element',
81
+ });
77
82
  });
@@ -9,7 +9,7 @@ exports[`<Icon> Snapshots and structure should render color & color variant 1`]
9
9
  height="1em"
10
10
  preserveAspectRatio="xMidYMid meet"
11
11
  style={
12
- Object {
12
+ {
13
13
  "verticalAlign": "-0.125em",
14
14
  }
15
15
  }
@@ -33,7 +33,7 @@ exports[`<Icon> Snapshots and structure should render correctly 1`] = `
33
33
  height="1em"
34
34
  preserveAspectRatio="xMidYMid meet"
35
35
  style={
36
- Object {
36
+ {
37
37
  "verticalAlign": "-0.125em",
38
38
  }
39
39
  }
@@ -11,7 +11,7 @@ exports[`<ImageBlock> Snapshots and structure should render story 'DefaultImageB
11
11
  className="lumx-image-block__image"
12
12
  fallback="M19,3A2,2 0 0,1 21,5V11H19V13H19L17,13V15H15V17H13V19H11V21H5C3.89,21 3,20.1 3,19V5A2,2 0 0,1 5,3H19M21,15V19A2,2 0 0,1 19,21H19L15,21V19H17V17H19V15H21M19,8.5A0.5,0.5 0 0,0 18.5,8H5.5A0.5,0.5 0 0,0 5,8.5V15.5A0.5,0.5 0 0,0 5.5,16H11V15H13V13H15V11H17V9H19V8.5Z"
13
13
  focusPoint={
14
- Object {
14
+ {
15
15
  "x": 0,
16
16
  "y": 0,
17
17
  }
@@ -169,3 +169,8 @@ export const Kind = {
169
169
  error: 'error',
170
170
  } as const;
171
171
  export type Kind = ValueOf<typeof Kind>;
172
+
173
+ /**
174
+ * Re-exporting some utils types.
175
+ */
176
+ export type { HeadingElement, TextElement, GenericProps, Callback } from '../utils/type';
@@ -62,7 +62,9 @@ export const InlineList: Comp<InlineListProps> = forwardRef((props, ref) => {
62
62
  {Children.toArray(children).map((child, index) => {
63
63
  const key = (isValidElement(child) && child.key) || index;
64
64
  return (
65
- <li key={key} className={`${CLASSNAME}__item`}>
65
+ // We need to item is set as display: contents which removes the semantic.
66
+ // eslint-disable-next-line jsx-a11y/no-redundant-roles
67
+ <li key={key} role="listitem" className={`${CLASSNAME}__item`}>
66
68
  {index !== 0 && (
67
69
  <span className={`${CLASSNAME}__item-separator`} aria-hidden="true">
68
70
  {'\u00A0•\u00A0'}
@@ -8,7 +8,7 @@ exports[`<Lightbox> Snapshots and structure should render story 'Default' 1`] =
8
8
  aria-modal="true"
9
9
  className="lumx-lightbox lumx-lightbox--is-shown"
10
10
  style={
11
- Object {
11
+ {
12
12
  "zIndex": undefined,
13
13
  }
14
14
  }
@@ -27,9 +27,9 @@ exports[`<Lightbox> Snapshots and structure should render story 'Default' 1`] =
27
27
  <ClickAwayProvider
28
28
  callback={[Function]}
29
29
  childrenRefs={
30
- Object {
31
- "current": Array [
32
- Object {
30
+ {
31
+ "current": [
32
+ {
33
33
  "current": null,
34
34
  },
35
35
  ],
@@ -47,11 +47,11 @@ exports[`<Lightbox> Snapshots and structure should render story 'Default' 1`] =
47
47
  groupBy={1}
48
48
  interval={5000}
49
49
  slideshowControlsProps={
50
- Object {
51
- "nextButtonProps": Object {
50
+ {
51
+ "nextButtonProps": {
52
52
  "label": "Next",
53
53
  },
54
- "previousButtonProps": Object {
54
+ "previousButtonProps": {
55
55
  "label": "Previous",
56
56
  },
57
57
  }
@@ -15,7 +15,7 @@ exports[`<List> Snapshots and structure should render story 'AsLink' 1`] = `
15
15
  isHighlighted={false}
16
16
  key=".0"
17
17
  linkProps={
18
- Object {
18
+ {
19
19
  "href": "#",
20
20
  }
21
21
  }
@@ -40,7 +40,7 @@ exports[`<List> Snapshots and structure should render story 'AsLink' 1`] = `
40
40
  isHighlighted={false}
41
41
  key=".1"
42
42
  linkProps={
43
- Object {
43
+ {
44
44
  "href": "http://www.google.com",
45
45
  "target": "_blank",
46
46
  }
@@ -83,7 +83,7 @@ exports[`<List> Snapshots and structure should render story 'KeyboardNavigation'
83
83
  isHighlighted={false}
84
84
  key=".2"
85
85
  linkProps={
86
- Object {
86
+ {
87
87
  "href": "#",
88
88
  }
89
89
  }
@@ -111,7 +111,7 @@ exports[`<List> Snapshots and structure should render story 'KeyboardNavigation'
111
111
  isHighlighted={false}
112
112
  key=".3..2"
113
113
  linkProps={
114
- Object {
114
+ {
115
115
  "href": "#",
116
116
  }
117
117
  }
@@ -133,7 +133,7 @@ exports[`<List> Snapshots and structure should render story 'KeyboardNavigation'
133
133
  isDisabled={true}
134
134
  key=".4"
135
135
  linkProps={
136
- Object {
136
+ {
137
137
  "href": "#",
138
138
  }
139
139
  }
@@ -156,7 +156,7 @@ exports[`<List> Snapshots and structure should render story 'KeyboardNavigation'
156
156
  isHighlighted={false}
157
157
  key=".7:$1"
158
158
  linkProps={
159
- Object {
159
+ {
160
160
  "href": "#",
161
161
  }
162
162
  }
@@ -190,7 +190,7 @@ exports[`<List> Snapshots and structure should render story 'WithCustomChildren'
190
190
  `;
191
191
 
192
192
  exports[`<List> Snapshots and structure should render story 'WithItemPadding' 1`] = `
193
- Array [
193
+ [
194
194
  <ul
195
195
  className="lumx-list lumx-list--item-padding-big"
196
196
  tabIndex={-1}
@@ -200,7 +200,7 @@ Array [
200
200
  isHighlighted={false}
201
201
  key=".0"
202
202
  linkProps={
203
- Object {
203
+ {
204
204
  "href": "#",
205
205
  }
206
206
  }
@@ -225,7 +225,7 @@ Array [
225
225
  isHighlighted={false}
226
226
  key=".1"
227
227
  linkProps={
228
- Object {
228
+ {
229
229
  "href": "#",
230
230
  }
231
231
  }
@@ -255,7 +255,7 @@ Array [
255
255
  isHighlighted={false}
256
256
  key=".0"
257
257
  linkProps={
258
- Object {
258
+ {
259
259
  "href": "#",
260
260
  }
261
261
  }
@@ -280,7 +280,7 @@ Array [
280
280
  isHighlighted={false}
281
281
  key=".1"
282
282
  linkProps={
283
- Object {
283
+ {
284
284
  "href": "#",
285
285
  }
286
286
  }
@@ -310,7 +310,7 @@ Array [
310
310
  isHighlighted={false}
311
311
  key=".0"
312
312
  linkProps={
313
- Object {
313
+ {
314
314
  "href": "#",
315
315
  }
316
316
  }
@@ -335,7 +335,7 @@ Array [
335
335
  isHighlighted={false}
336
336
  key=".1"
337
337
  linkProps={
338
- Object {
338
+ {
339
339
  "href": "#",
340
340
  }
341
341
  }
@@ -9,7 +9,7 @@ exports[`<Notification> Snapshots and structure should render defaults 1`] = `
9
9
  onClick={[Function]}
10
10
  role="alert"
11
11
  style={
12
- Object {
12
+ {
13
13
  "zIndex": 9999,
14
14
  }
15
15
  }