@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
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<UserBlock> Snapshots and structure should render story 'Clickable' 1`] = `
4
- Array [
4
+ [
5
5
  <div
6
6
  className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-m lumx-user-block--theme-light lumx-user-block--is-clickable"
7
7
  >
@@ -13,7 +13,7 @@ Array [
13
13
  size="m"
14
14
  theme="light"
15
15
  thumbnailProps={
16
- Object {
16
+ {
17
17
  "tabIndex": -1,
18
18
  }
19
19
  }
@@ -55,14 +55,14 @@ Array [
55
55
  className="lumx-user-block__avatar"
56
56
  image="/demo-assets/avatar1.jpg"
57
57
  linkProps={
58
- Object {
58
+ {
59
59
  "href": "https://example.com",
60
60
  }
61
61
  }
62
62
  size="m"
63
63
  theme="light"
64
64
  thumbnailProps={
65
- Object {
65
+ {
66
66
  "tabIndex": -1,
67
67
  }
68
68
  }
@@ -107,7 +107,7 @@ Array [
107
107
  size="m"
108
108
  theme="light"
109
109
  thumbnailProps={
110
- Object {
110
+ {
111
111
  "tabIndex": -1,
112
112
  }
113
113
  }
@@ -157,7 +157,7 @@ exports[`<UserBlock> Snapshots and structure should render story 'Default' 1`] =
157
157
  size="m"
158
158
  theme="light"
159
159
  thumbnailProps={
160
- Object {
160
+ {
161
161
  "tabIndex": -1,
162
162
  }
163
163
  }
@@ -191,7 +191,7 @@ exports[`<UserBlock> Snapshots and structure should render story 'Default' 1`] =
191
191
  `;
192
192
 
193
193
  exports[`<UserBlock> Snapshots and structure should render story 'Sizes' 1`] = `
194
- Array [
194
+ [
195
195
  <div
196
196
  className="lumx-user-block lumx-user-block--orientation-horizontal lumx-user-block--size-s lumx-user-block--theme-light"
197
197
  onMouseEnter={[Function]}
@@ -204,7 +204,7 @@ Array [
204
204
  size="s"
205
205
  theme="light"
206
206
  thumbnailProps={
207
- Object {
207
+ {
208
208
  "tabIndex": -1,
209
209
  }
210
210
  }
@@ -231,7 +231,7 @@ Array [
231
231
  size="m"
232
232
  theme="light"
233
233
  thumbnailProps={
234
- Object {
234
+ {
235
235
  "tabIndex": -1,
236
236
  }
237
237
  }
@@ -274,7 +274,7 @@ Array [
274
274
  size="l"
275
275
  theme="light"
276
276
  thumbnailProps={
277
- Object {
277
+ {
278
278
  "tabIndex": -1,
279
279
  }
280
280
  }
@@ -328,7 +328,7 @@ exports[`<UserBlock> Snapshots and structure should render story 'WithBadge' 1`]
328
328
  size="m"
329
329
  theme="light"
330
330
  thumbnailProps={
331
- Object {
331
+ {
332
332
  "tabIndex": -1,
333
333
  }
334
334
  }
@@ -4,4 +4,5 @@
4
4
  export default { title: 'LumX components/dropdown/Dropdown Demos' };
5
5
 
6
6
  export { App as Default } from './default';
7
+ export { App as Selects } from './selects';
7
8
  export { App as Target } from './target';
@@ -0,0 +1,55 @@
1
+ import isEmpty from 'lodash/isEmpty';
2
+
3
+ import { GenericProps } from '@lumx/react/utils/type';
4
+ import { queryByClassName } from '@lumx/react/testing/utils/queries';
5
+
6
+ interface CommonSetup {
7
+ props: GenericProps;
8
+ container: HTMLElement;
9
+ }
10
+
11
+ interface Options<S extends CommonSetup> {
12
+ baseClassName: string;
13
+ forwardClassName?: keyof S;
14
+ forwardAttributes?: keyof S;
15
+ }
16
+
17
+ type SetupFunction<S extends CommonSetup> = (props?: GenericProps) => S;
18
+
19
+ /**
20
+ * Common tests on components
21
+ * - Check base class name and class name forwarding
22
+ * - Check props forwarding
23
+ */
24
+ export function commonTestsSuiteRTL<S extends CommonSetup>(setup: SetupFunction<S>, options: Options<S>): void {
25
+ if (isEmpty(options)) {
26
+ return;
27
+ }
28
+ const { baseClassName, forwardClassName, forwardAttributes } = options;
29
+ describe('Common tests suite', () => {
30
+ it('should render with base class name', () => {
31
+ const { container } = setup();
32
+ expect(queryByClassName(container, baseClassName)).toBeInTheDocument();
33
+ });
34
+
35
+ if (forwardClassName) {
36
+ it('should forward any CSS class', () => {
37
+ const modifiedProps = {
38
+ className: 'component component--is-tested',
39
+ };
40
+ const wrappers = setup(modifiedProps);
41
+ expect(wrappers[forwardClassName]).toHaveClass(modifiedProps.className);
42
+ });
43
+ }
44
+
45
+ if (forwardAttributes) {
46
+ it('should forward any other prop', () => {
47
+ const modifiedProps = {
48
+ winter: 'is coming',
49
+ };
50
+ const wrappers = setup(modifiedProps);
51
+ expect(wrappers[forwardAttributes]).toHaveAttribute('winter', modifiedProps.winter);
52
+ });
53
+ }
54
+ });
55
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './commonTestsSuite';
2
+ export * from './commonTestsSuiteRTL';
2
3
 
3
4
  export * from './itShouldRenderStories';
@@ -0,0 +1,19 @@
1
+ import { buildQueries } from '@testing-library/react';
2
+
3
+ export const queryAllByClassName = (container: HTMLElement, className: string) =>
4
+ Array.from(container.getElementsByClassName(className) as HTMLCollectionOf<HTMLElement>);
5
+
6
+ export const [queryByClassName, getAllByClassName, getByClassName, findAllByClassName, findByClassName] = buildQueries(
7
+ queryAllByClassName,
8
+ (_, className) => `Multiple \`.${className}\` found`,
9
+ (_, className) => `No \`.${className}\` found`,
10
+ );
11
+
12
+ export const queryAllByTagName = (container: HTMLElement, tagName: string) =>
13
+ Array.from(container.getElementsByTagName(tagName) as HTMLCollectionOf<HTMLElement>);
14
+
15
+ export const [queryByTagName, getAllByTagName, getByTagName, findAllByTagName, findByTagName] = buildQueries(
16
+ queryAllByTagName,
17
+ (_, tagName) => `Multiple \`${tagName}\` found`,
18
+ (_, tagName) => `No \`${tagName}\` found`,
19
+ );
@@ -17,7 +17,7 @@ describe(getFocusableElements.name, () => {
17
17
  const element = htmlToElement(`<div><button /></div>`);
18
18
  const focusable = getFocusableElements(element);
19
19
  expect(focusable).toMatchInlineSnapshot(`
20
- Array [
20
+ [
21
21
  <button />,
22
22
  ]
23
23
  `);
@@ -28,7 +28,7 @@ describe(getFocusableElements.name, () => {
28
28
  const element = htmlToElement(`<div><input /></div>`);
29
29
  const focusable = getFocusableElements(element);
30
30
  expect(focusable).toMatchInlineSnapshot(`
31
- Array [
31
+ [
32
32
  <input />,
33
33
  ]
34
34
  `);
@@ -38,7 +38,7 @@ describe(getFocusableElements.name, () => {
38
38
  const element = htmlToElement(`<div><a href="#" /></div>`);
39
39
  const focusable = getFocusableElements(element);
40
40
  expect(focusable).toMatchInlineSnapshot(`
41
- Array [
41
+ [
42
42
  <a
43
43
  href="#"
44
44
  />,
@@ -50,7 +50,7 @@ describe(getFocusableElements.name, () => {
50
50
  const element = htmlToElement(`<div><textarea /></div>`);
51
51
  const focusable = getFocusableElements(element);
52
52
  expect(focusable).toMatchInlineSnapshot(`
53
- Array [
53
+ [
54
54
  <textarea>
55
55
  &lt;/div&gt;
56
56
  </textarea>,
@@ -62,7 +62,7 @@ describe(getFocusableElements.name, () => {
62
62
  const element = htmlToElement(`<div><span tabindex="0" /></div>`);
63
63
  const focusable = getFocusableElements(element);
64
64
  expect(focusable).toMatchInlineSnapshot(`
65
- Array [
65
+ [
66
66
  <span
67
67
  tabindex="0"
68
68
  />,
@@ -74,7 +74,7 @@ describe(getFocusableElements.name, () => {
74
74
  const element = htmlToElement(`<div><button disabled="false" /><button /></div>`);
75
75
  const focusable = getFocusableElements(element);
76
76
  expect(focusable).toMatchInlineSnapshot(`
77
- Array [
77
+ [
78
78
  <button
79
79
  disabled="false"
80
80
  />,
@@ -87,7 +87,7 @@ describe(getFocusableElements.name, () => {
87
87
  const element = htmlToElement(`<div><button aria-disabled="false" /><button /></div>`);
88
88
  const focusable = getFocusableElements(element);
89
89
  expect(focusable).toMatchInlineSnapshot(`
90
- Array [
90
+ [
91
91
  <button
92
92
  aria-disabled="false"
93
93
  />,
@@ -102,7 +102,7 @@ describe(getFocusableElements.name, () => {
102
102
  const element = htmlToElement(`<div><button disabled /><button /></div>`);
103
103
  const focusable = getFocusableElements(element);
104
104
  expect(focusable).toMatchInlineSnapshot(`
105
- Array [
105
+ [
106
106
  <button />,
107
107
  ]
108
108
  `);
@@ -112,7 +112,7 @@ describe(getFocusableElements.name, () => {
112
112
  const element = htmlToElement(`<div><button aria-disabled /><button /></div>`);
113
113
  const focusable = getFocusableElements(element);
114
114
  expect(focusable).toMatchInlineSnapshot(`
115
- Array [
115
+ [
116
116
  <button />,
117
117
  ]
118
118
  `);
@@ -122,7 +122,7 @@ describe(getFocusableElements.name, () => {
122
122
  const element = htmlToElement(`<div><button tabindex="-1" /><button /></div>`);
123
123
  const focusable = getFocusableElements(element);
124
124
  expect(focusable).toMatchInlineSnapshot(`
125
- Array [
125
+ [
126
126
  <button />,
127
127
  ]
128
128
  `);
@@ -132,7 +132,7 @@ describe(getFocusableElements.name, () => {
132
132
  const element = htmlToElement(`<div><input type="hidden" /><button /></div>`);
133
133
  const focusable = getFocusableElements(element);
134
134
  expect(focusable).toMatchInlineSnapshot(`
135
- Array [
135
+ [
136
136
  <button />,
137
137
  ]
138
138
  `);
@@ -142,7 +142,7 @@ describe(getFocusableElements.name, () => {
142
142
  const element = htmlToElement(`<div><input hidden /><button /></div>`);
143
143
  const focusable = getFocusableElements(element);
144
144
  expect(focusable).toMatchInlineSnapshot(`
145
- Array [
145
+ [
146
146
  <button />,
147
147
  ]
148
148
  `);