@instructure/ui-list 10.16.1-snapshot-0 → 10.16.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.
- package/CHANGELOG.md +1 -1
- package/es/InlineList/InlineListItem/__new-tests__/InlineListItem.test.js +12 -8
- package/es/InlineList/InlineListItem/index.js +11 -8
- package/es/InlineList/__examples__/InlineList.examples.js +8 -8
- package/es/InlineList/__new-tests__/InlineList.test.js +59 -12
- package/es/InlineList/index.js +7 -4
- package/es/List/ListItem/__new-tests__/ListItem.test.js +8 -5
- package/es/List/ListItem/index.js +7 -5
- package/es/List/__examples__/List.examples.js +8 -8
- package/es/List/__new-tests__/List.test.js +47 -9
- package/es/List/index.js +7 -5
- package/lib/InlineList/InlineListItem/__new-tests__/InlineListItem.test.js +15 -12
- package/lib/InlineList/InlineListItem/index.js +9 -7
- package/lib/InlineList/__examples__/InlineList.examples.js +8 -9
- package/lib/InlineList/__new-tests__/InlineList.test.js +62 -16
- package/lib/InlineList/index.js +7 -5
- package/lib/List/ListItem/__new-tests__/ListItem.test.js +11 -9
- package/lib/List/ListItem/index.js +6 -4
- package/lib/List/__examples__/List.examples.js +8 -9
- package/lib/List/__new-tests__/List.test.js +50 -13
- package/lib/List/index.js +6 -4
- package/package.json +13 -13
- package/src/InlineList/InlineListItem/__new-tests__/InlineListItem.test.tsx +0 -1
- package/src/InlineList/InlineListItem/index.tsx +2 -2
- package/src/InlineList/__examples__/InlineList.examples.tsx +0 -2
- package/src/InlineList/__new-tests__/InlineList.test.tsx +0 -1
- package/src/InlineList/index.tsx +1 -1
- package/src/List/ListItem/__new-tests__/ListItem.test.tsx +0 -1
- package/src/List/ListItem/index.tsx +1 -2
- package/src/List/__examples__/List.examples.tsx +0 -2
- package/src/List/__new-tests__/List.test.tsx +0 -1
- package/src/List/index.tsx +1 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/InlineList/InlineListItem/__new-tests__/InlineListItem.test.d.ts.map +1 -1
- package/types/InlineList/InlineListItem/index.d.ts +1 -3
- package/types/InlineList/InlineListItem/index.d.ts.map +1 -1
- package/types/InlineList/__examples__/InlineList.examples.d.ts.map +1 -1
- package/types/InlineList/__new-tests__/InlineList.test.d.ts.map +1 -1
- package/types/InlineList/index.d.ts +3 -3
- package/types/InlineList/index.d.ts.map +1 -1
- package/types/List/ListItem/__new-tests__/ListItem.test.d.ts.map +1 -1
- package/types/List/ListItem/index.d.ts +1 -3
- package/types/List/ListItem/index.d.ts.map +1 -1
- package/types/List/__examples__/List.examples.d.ts.map +1 -1
- package/types/List/__new-tests__/List.test.d.ts.map +1 -1
- package/types/List/index.d.ts +1 -3
- package/types/List/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.16.1
|
|
6
|
+
## [10.16.1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1) (2025-04-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-list
|
|
9
9
|
|
|
@@ -23,30 +23,34 @@ var _InlineListItem, _InlineListItem2;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import '@testing-library/jest-dom';
|
|
28
27
|
import { render, screen } from '@testing-library/react';
|
|
29
28
|
import { vi } from 'vitest';
|
|
30
29
|
import { InlineListItem } from '../index';
|
|
30
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
31
31
|
describe('<InlineListItem />', () => {
|
|
32
32
|
it('should render children', async () => {
|
|
33
|
-
render(_InlineListItem || (_InlineListItem =
|
|
33
|
+
render(_InlineListItem || (_InlineListItem = _jsx(InlineListItem, {
|
|
34
|
+
children: "hello"
|
|
35
|
+
})));
|
|
34
36
|
const listItem = screen.getByRole('listitem');
|
|
35
37
|
expect(listItem).toHaveTextContent('hello');
|
|
36
38
|
});
|
|
37
39
|
it('should render delimiter', async () => {
|
|
38
|
-
const _render = render(_InlineListItem2 || (_InlineListItem2 =
|
|
39
|
-
delimiter: "slash"
|
|
40
|
-
|
|
40
|
+
const _render = render(_InlineListItem2 || (_InlineListItem2 = _jsx(InlineListItem, {
|
|
41
|
+
delimiter: "slash",
|
|
42
|
+
children: "List item"
|
|
43
|
+
}))),
|
|
41
44
|
container = _render.container;
|
|
42
45
|
const listItem = container.querySelector('span[class$="delimiter"]');
|
|
43
46
|
expect(listItem).toHaveAttribute('aria-hidden', 'true');
|
|
44
47
|
});
|
|
45
48
|
it('should call elementRef', async () => {
|
|
46
49
|
const elementRef = vi.fn();
|
|
47
|
-
render(
|
|
48
|
-
elementRef: elementRef
|
|
49
|
-
|
|
50
|
+
render(_jsx(InlineListItem, {
|
|
51
|
+
elementRef: elementRef,
|
|
52
|
+
children: "List item"
|
|
53
|
+
}));
|
|
50
54
|
const listItem = screen.getByRole('listitem');
|
|
51
55
|
expect(elementRef).toHaveBeenCalledWith(listItem);
|
|
52
56
|
});
|
|
@@ -24,15 +24,16 @@ var _dec, _dec2, _class, _InlineListItem;
|
|
|
24
24
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
import { Component } from 'react';
|
|
29
29
|
import { View } from '@instructure/ui-view';
|
|
30
30
|
import { testable } from '@instructure/ui-testable';
|
|
31
31
|
import { passthroughProps } from '@instructure/ui-react-utils';
|
|
32
|
-
import { withStyle
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
33
33
|
import generateStyle from './styles';
|
|
34
34
|
import generateComponentTheme from './theme';
|
|
35
35
|
import { propTypes, allowedProps } from './props';
|
|
36
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
36
37
|
/**
|
|
37
38
|
---
|
|
38
39
|
parent: InlineList
|
|
@@ -70,18 +71,20 @@ let InlineListItem = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
70
71
|
spacing = _this$props3.spacing,
|
|
71
72
|
styles = _this$props3.styles,
|
|
72
73
|
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
73
|
-
return
|
|
74
|
+
return _jsxs(View, {
|
|
75
|
+
...passthroughProps(rest),
|
|
74
76
|
css: styles === null || styles === void 0 ? void 0 : styles.inlineListItem,
|
|
75
77
|
as: "li",
|
|
76
78
|
margin: margin,
|
|
77
79
|
padding: padding,
|
|
78
80
|
display: "inline-block",
|
|
79
81
|
maxWidth: "100%",
|
|
80
|
-
elementRef: this.handleRef
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
elementRef: this.handleRef,
|
|
83
|
+
children: [children, _jsx("span", {
|
|
84
|
+
css: styles === null || styles === void 0 ? void 0 : styles.delimiter,
|
|
85
|
+
"aria-hidden": "true"
|
|
86
|
+
})]
|
|
87
|
+
});
|
|
85
88
|
}
|
|
86
89
|
}, _InlineListItem.displayName = "InlineListItem", _InlineListItem.componentId = 'InlineList.Item', _InlineListItem.propTypes = propTypes, _InlineListItem.allowedProps = allowedProps, _InlineListItem.defaultProps = {
|
|
87
90
|
padding: 'none',
|
|
@@ -23,19 +23,19 @@ var _InlineList$Item, _InlineList$Item2, _InlineList$Item3;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { InlineList } from '../index';
|
|
27
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
28
28
|
export default {
|
|
29
29
|
sectionProp: 'size',
|
|
30
30
|
getComponentProps: () => {
|
|
31
31
|
return {
|
|
32
|
-
children: [_InlineList$Item || (_InlineList$Item =
|
|
33
|
-
|
|
34
|
-
}, "
|
|
35
|
-
|
|
36
|
-
}, "
|
|
37
|
-
|
|
38
|
-
}, "
|
|
32
|
+
children: [_InlineList$Item || (_InlineList$Item = _jsx(InlineList.Item, {
|
|
33
|
+
children: "Oranges"
|
|
34
|
+
}, "1")), _InlineList$Item2 || (_InlineList$Item2 = _jsx(InlineList.Item, {
|
|
35
|
+
children: "Pineapples"
|
|
36
|
+
}, "2")), _InlineList$Item3 || (_InlineList$Item3 = _jsx(InlineList.Item, {
|
|
37
|
+
children: "Bananas"
|
|
38
|
+
}, "3"))]
|
|
39
39
|
};
|
|
40
40
|
},
|
|
41
41
|
filter: props => {
|
|
@@ -23,12 +23,12 @@ var _InlineList, _InlineList2, _InlineList3, _InlineList4, _InlineList5;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import '@testing-library/jest-dom';
|
|
28
27
|
import { render, screen } from '@testing-library/react';
|
|
29
28
|
import { vi } from 'vitest';
|
|
30
29
|
import { InlineList } from '../index';
|
|
31
30
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
31
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
32
32
|
describe('<InlineList />', () => {
|
|
33
33
|
let consoleWarningMock;
|
|
34
34
|
let consoleErrorMock;
|
|
@@ -42,14 +42,33 @@ describe('<InlineList />', () => {
|
|
|
42
42
|
consoleErrorMock.mockRestore();
|
|
43
43
|
});
|
|
44
44
|
it('should render list items and filter out null/falsy children', async () => {
|
|
45
|
-
render(_InlineList || (_InlineList =
|
|
45
|
+
render(_InlineList || (_InlineList = _jsxs(InlineList, {
|
|
46
|
+
children: [_jsx(InlineList.Item, {
|
|
47
|
+
children: "List item 1"
|
|
48
|
+
}), _jsx(InlineList.Item, {
|
|
49
|
+
children: "List item 2"
|
|
50
|
+
}), _jsx(InlineList.Item, {
|
|
51
|
+
children: "List item 3"
|
|
52
|
+
}), _jsx(InlineList.Item, {
|
|
53
|
+
children: "List item 4"
|
|
54
|
+
}), null, false]
|
|
55
|
+
})));
|
|
46
56
|
const listItems = screen.getAllByRole('listitem');
|
|
47
57
|
expect(listItems.length).toEqual(4);
|
|
48
58
|
});
|
|
49
59
|
it('should render a delimiter when delimiter="pipe"', async () => {
|
|
50
|
-
const _render = render(_InlineList2 || (_InlineList2 =
|
|
51
|
-
delimiter: "pipe"
|
|
52
|
-
|
|
60
|
+
const _render = render(_InlineList2 || (_InlineList2 = _jsxs(InlineList, {
|
|
61
|
+
delimiter: "pipe",
|
|
62
|
+
children: [_jsx(InlineList.Item, {
|
|
63
|
+
children: "List item 1"
|
|
64
|
+
}), _jsx(InlineList.Item, {
|
|
65
|
+
children: "List item 2"
|
|
66
|
+
}), _jsx(InlineList.Item, {
|
|
67
|
+
children: "List item 3"
|
|
68
|
+
}), _jsx(InlineList.Item, {
|
|
69
|
+
children: "List item 4"
|
|
70
|
+
})]
|
|
71
|
+
}))),
|
|
53
72
|
container = _render.container;
|
|
54
73
|
const delimiters = container.querySelectorAll('span[aria-hidden="true"]');
|
|
55
74
|
expect(delimiters.length).toEqual(4);
|
|
@@ -58,22 +77,50 @@ describe('<InlineList />', () => {
|
|
|
58
77
|
});
|
|
59
78
|
});
|
|
60
79
|
it('should warn when itemSpacing is set when delimiter is set to anything other than none', async () => {
|
|
61
|
-
render(_InlineList3 || (_InlineList3 =
|
|
80
|
+
render(_InlineList3 || (_InlineList3 = _jsxs(InlineList, {
|
|
62
81
|
delimiter: "pipe",
|
|
63
|
-
itemSpacing: "large"
|
|
64
|
-
|
|
82
|
+
itemSpacing: "large",
|
|
83
|
+
children: [_jsx(InlineList.Item, {
|
|
84
|
+
children: "List item 1"
|
|
85
|
+
}), _jsx(InlineList.Item, {
|
|
86
|
+
children: "List item 2"
|
|
87
|
+
}), _jsx(InlineList.Item, {
|
|
88
|
+
children: "List item 3"
|
|
89
|
+
}), _jsx(InlineList.Item, {
|
|
90
|
+
children: "List item 4"
|
|
91
|
+
})]
|
|
92
|
+
})));
|
|
65
93
|
const warning = `Warning: [InlineList] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`;
|
|
66
94
|
expect(consoleErrorMock.mock.calls[0][0]).toBe(warning);
|
|
67
95
|
});
|
|
68
96
|
it('should render an ordered list', async () => {
|
|
69
|
-
render(_InlineList4 || (_InlineList4 =
|
|
70
|
-
as: "ol"
|
|
71
|
-
|
|
97
|
+
render(_InlineList4 || (_InlineList4 = _jsxs(InlineList, {
|
|
98
|
+
as: "ol",
|
|
99
|
+
children: [_jsx(InlineList.Item, {
|
|
100
|
+
children: "List item 1"
|
|
101
|
+
}), _jsx(InlineList.Item, {
|
|
102
|
+
children: "List item 2"
|
|
103
|
+
}), _jsx(InlineList.Item, {
|
|
104
|
+
children: "List item 3"
|
|
105
|
+
}), _jsx(InlineList.Item, {
|
|
106
|
+
children: "List item 4"
|
|
107
|
+
})]
|
|
108
|
+
})));
|
|
72
109
|
const list = screen.getByRole('list');
|
|
73
110
|
expect(list.tagName).toBe('OL');
|
|
74
111
|
});
|
|
75
112
|
it('should meet a11y standards', async () => {
|
|
76
|
-
const _render2 = render(_InlineList5 || (_InlineList5 =
|
|
113
|
+
const _render2 = render(_InlineList5 || (_InlineList5 = _jsxs(InlineList, {
|
|
114
|
+
children: [_jsx(InlineList.Item, {
|
|
115
|
+
children: "List item 1"
|
|
116
|
+
}), _jsx(InlineList.Item, {
|
|
117
|
+
children: "List item 2"
|
|
118
|
+
}), _jsx(InlineList.Item, {
|
|
119
|
+
children: "List item 3"
|
|
120
|
+
}), _jsx(InlineList.Item, {
|
|
121
|
+
children: "List item 4"
|
|
122
|
+
})]
|
|
123
|
+
}))),
|
|
77
124
|
container = _render2.container;
|
|
78
125
|
const axeCheck = await runAxeCheck(container);
|
|
79
126
|
expect(axeCheck).toBe(true);
|
package/es/InlineList/index.js
CHANGED
|
@@ -24,12 +24,13 @@ var _dec, _class, _InlineList;
|
|
|
24
24
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
|
-
import
|
|
27
|
+
import { Children, Component } from 'react';
|
|
28
28
|
import { View } from '@instructure/ui-view';
|
|
29
29
|
import { passthroughProps, safeCloneElement } from '@instructure/ui-react-utils';
|
|
30
30
|
import { testable } from '@instructure/ui-testable';
|
|
31
31
|
import { InlineListItem } from './InlineListItem';
|
|
32
32
|
import { propTypes, allowedProps } from './props';
|
|
33
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
33
34
|
/**
|
|
34
35
|
---
|
|
35
36
|
category: components
|
|
@@ -65,13 +66,15 @@ let InlineList = (_dec = testable(), _dec(_class = (_InlineList = class InlineLi
|
|
|
65
66
|
margin = _this$props.margin,
|
|
66
67
|
elementRef = _this$props.elementRef,
|
|
67
68
|
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
68
|
-
return
|
|
69
|
+
return _jsx(View, {
|
|
70
|
+
...passthroughProps(rest),
|
|
69
71
|
as: as,
|
|
70
72
|
margin: margin,
|
|
71
73
|
padding: "0",
|
|
72
74
|
elementRef: this.handleRef,
|
|
73
|
-
display: "block"
|
|
74
|
-
|
|
75
|
+
display: "block",
|
|
76
|
+
children: this.renderChildren()
|
|
77
|
+
});
|
|
75
78
|
}
|
|
76
79
|
}, _InlineList.displayName = "InlineList", _InlineList.propTypes = propTypes, _InlineList.allowedProps = allowedProps, _InlineList.defaultProps = {
|
|
77
80
|
itemSpacing: 'none',
|
|
@@ -23,22 +23,25 @@ var _ListItem;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import '@testing-library/jest-dom';
|
|
28
27
|
import { render, screen } from '@testing-library/react';
|
|
29
28
|
import { vi } from 'vitest';
|
|
30
29
|
import { ListItem } from '../index';
|
|
30
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
31
31
|
describe('<ListItem />', () => {
|
|
32
32
|
it('should render children', async () => {
|
|
33
|
-
render(_ListItem || (_ListItem =
|
|
33
|
+
render(_ListItem || (_ListItem = _jsx(ListItem, {
|
|
34
|
+
children: "hello"
|
|
35
|
+
})));
|
|
34
36
|
const listItem = screen.getByRole('listitem');
|
|
35
37
|
expect(listItem).toHaveTextContent('hello');
|
|
36
38
|
});
|
|
37
39
|
it('should call elementRef', async () => {
|
|
38
40
|
const elementRef = vi.fn();
|
|
39
|
-
render(
|
|
40
|
-
elementRef: elementRef
|
|
41
|
-
|
|
41
|
+
render(_jsx(ListItem, {
|
|
42
|
+
elementRef: elementRef,
|
|
43
|
+
children: "List item"
|
|
44
|
+
}));
|
|
42
45
|
const listItem = screen.getByRole('listitem');
|
|
43
46
|
expect(elementRef).toHaveBeenCalledWith(listItem);
|
|
44
47
|
});
|
|
@@ -25,15 +25,15 @@ var _dec, _dec2, _class, _ListItem;
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
/** @jsx jsx */
|
|
29
28
|
import { Component } from 'react';
|
|
30
29
|
import { View } from '@instructure/ui-view';
|
|
31
30
|
import { testable } from '@instructure/ui-testable';
|
|
32
31
|
import { passthroughProps } from '@instructure/ui-react-utils';
|
|
33
|
-
import { withStyle
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
34
33
|
import generateStyle from './styles';
|
|
35
34
|
import generateComponentTheme from './theme';
|
|
36
35
|
import { propTypes, allowedProps } from './props';
|
|
36
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
37
37
|
/**
|
|
38
38
|
---
|
|
39
39
|
parent: List
|
|
@@ -71,14 +71,16 @@ let ListItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
71
71
|
children = _this$props3.children,
|
|
72
72
|
styles = _this$props3.styles,
|
|
73
73
|
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
74
|
-
return
|
|
74
|
+
return _jsx(View, {
|
|
75
|
+
...passthroughProps(rest),
|
|
75
76
|
css: styles === null || styles === void 0 ? void 0 : styles.listItem,
|
|
76
77
|
as: "li",
|
|
77
78
|
margin: margin,
|
|
78
79
|
padding: padding,
|
|
79
80
|
maxWidth: "100%",
|
|
80
|
-
elementRef: this.handleRef
|
|
81
|
-
|
|
81
|
+
elementRef: this.handleRef,
|
|
82
|
+
children: children
|
|
83
|
+
});
|
|
82
84
|
}
|
|
83
85
|
}, _ListItem.displayName = "ListItem", _ListItem.componentId = 'List.Item', _ListItem.propTypes = propTypes, _ListItem.allowedProps = allowedProps, _ListItem.defaultProps = {
|
|
84
86
|
padding: 'none',
|
|
@@ -23,19 +23,19 @@ var _List$Item, _List$Item2, _List$Item3;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { List } from '../index';
|
|
27
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
28
28
|
export default {
|
|
29
29
|
sectionProp: 'size',
|
|
30
30
|
getComponentProps: () => {
|
|
31
31
|
return {
|
|
32
|
-
children: [_List$Item || (_List$Item =
|
|
33
|
-
|
|
34
|
-
}, "
|
|
35
|
-
|
|
36
|
-
}, "
|
|
37
|
-
|
|
38
|
-
}, "
|
|
32
|
+
children: [_List$Item || (_List$Item = _jsx(List.Item, {
|
|
33
|
+
children: "Oranges"
|
|
34
|
+
}, "1")), _List$Item2 || (_List$Item2 = _jsx(List.Item, {
|
|
35
|
+
children: "Pineapples"
|
|
36
|
+
}, "2")), _List$Item3 || (_List$Item3 = _jsx(List.Item, {
|
|
37
|
+
children: "Bananas"
|
|
38
|
+
}, "3"))]
|
|
39
39
|
};
|
|
40
40
|
},
|
|
41
41
|
filter: props => {
|
|
@@ -23,12 +23,12 @@ var _List, _List2, _List3, _List4;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import '@testing-library/jest-dom';
|
|
28
27
|
import { render, screen } from '@testing-library/react';
|
|
29
28
|
import { vi } from 'vitest';
|
|
30
29
|
import { List } from '../index';
|
|
31
30
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
31
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
32
32
|
describe('<List />', () => {
|
|
33
33
|
let consoleWarningMock;
|
|
34
34
|
let consoleErrorMock;
|
|
@@ -42,27 +42,65 @@ describe('<List />', () => {
|
|
|
42
42
|
consoleErrorMock.mockRestore();
|
|
43
43
|
});
|
|
44
44
|
it('should render list items and filter out null/falsy children', async () => {
|
|
45
|
-
render(_List || (_List =
|
|
45
|
+
render(_List || (_List = _jsxs(List, {
|
|
46
|
+
children: [_jsx(List.Item, {
|
|
47
|
+
children: "List item 1"
|
|
48
|
+
}), _jsx(List.Item, {
|
|
49
|
+
children: "List item 2"
|
|
50
|
+
}), _jsx(List.Item, {
|
|
51
|
+
children: "List item 3"
|
|
52
|
+
}), _jsx(List.Item, {
|
|
53
|
+
children: "List item 4"
|
|
54
|
+
}), null, false]
|
|
55
|
+
})));
|
|
46
56
|
const listItems = screen.getAllByRole('listitem');
|
|
47
57
|
expect(listItems.length).toEqual(4);
|
|
48
58
|
});
|
|
49
59
|
it('should warn when itemSpacing is set when delimiter is set to anything other than none', async () => {
|
|
50
|
-
render(_List2 || (_List2 =
|
|
60
|
+
render(_List2 || (_List2 = _jsxs(List, {
|
|
51
61
|
delimiter: "dashed",
|
|
52
|
-
itemSpacing: "large"
|
|
53
|
-
|
|
62
|
+
itemSpacing: "large",
|
|
63
|
+
children: [_jsx(List.Item, {
|
|
64
|
+
children: "List item 1"
|
|
65
|
+
}), _jsx(List.Item, {
|
|
66
|
+
children: "List item 2"
|
|
67
|
+
}), _jsx(List.Item, {
|
|
68
|
+
children: "List item 3"
|
|
69
|
+
}), _jsx(List.Item, {
|
|
70
|
+
children: "List item 4"
|
|
71
|
+
})]
|
|
72
|
+
})));
|
|
54
73
|
const warning = `Warning: [List] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`;
|
|
55
74
|
expect(consoleErrorMock.mock.calls[0][0]).toBe(warning);
|
|
56
75
|
});
|
|
57
76
|
it('should render an ordered list', async () => {
|
|
58
|
-
render(_List3 || (_List3 =
|
|
59
|
-
as: "ol"
|
|
60
|
-
|
|
77
|
+
render(_List3 || (_List3 = _jsxs(List, {
|
|
78
|
+
as: "ol",
|
|
79
|
+
children: [_jsx(List.Item, {
|
|
80
|
+
children: "List item 1"
|
|
81
|
+
}), _jsx(List.Item, {
|
|
82
|
+
children: "List item 2"
|
|
83
|
+
}), _jsx(List.Item, {
|
|
84
|
+
children: "List item 3"
|
|
85
|
+
}), _jsx(List.Item, {
|
|
86
|
+
children: "List item 4"
|
|
87
|
+
})]
|
|
88
|
+
})));
|
|
61
89
|
const list = screen.getByRole('list');
|
|
62
90
|
expect(list.tagName).toBe('OL');
|
|
63
91
|
});
|
|
64
92
|
it('should meet a11y standards', async () => {
|
|
65
|
-
const _render = render(_List4 || (_List4 =
|
|
93
|
+
const _render = render(_List4 || (_List4 = _jsxs(List, {
|
|
94
|
+
children: [_jsx(List.Item, {
|
|
95
|
+
children: "List item 1"
|
|
96
|
+
}), _jsx(List.Item, {
|
|
97
|
+
children: "List item 2"
|
|
98
|
+
}), _jsx(List.Item, {
|
|
99
|
+
children: "List item 3"
|
|
100
|
+
}), _jsx(List.Item, {
|
|
101
|
+
children: "List item 4"
|
|
102
|
+
})]
|
|
103
|
+
}))),
|
|
66
104
|
container = _render.container;
|
|
67
105
|
const axeCheck = await runAxeCheck(container);
|
|
68
106
|
expect(axeCheck).toBe(true);
|
package/es/List/index.js
CHANGED
|
@@ -25,16 +25,16 @@ var _dec, _dec2, _class, _List;
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
/** @jsx jsx */
|
|
29
28
|
import { Children, Component } from 'react';
|
|
30
29
|
import { View } from '@instructure/ui-view';
|
|
31
30
|
import { passthroughProps, safeCloneElement } from '@instructure/ui-react-utils';
|
|
32
31
|
import { testable } from '@instructure/ui-testable';
|
|
33
32
|
import { ListItem } from './ListItem';
|
|
34
|
-
import { withStyle
|
|
33
|
+
import { withStyle } from '@instructure/emotion';
|
|
35
34
|
import generateStyle from './styles';
|
|
36
35
|
import generateComponentTheme from './theme';
|
|
37
36
|
import { propTypes, allowedProps } from './props';
|
|
37
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
38
38
|
/**
|
|
39
39
|
---
|
|
40
40
|
category: components
|
|
@@ -80,13 +80,15 @@ let List = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
80
80
|
elementRef = _this$props3.elementRef,
|
|
81
81
|
styles = _this$props3.styles,
|
|
82
82
|
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
83
|
-
return
|
|
83
|
+
return _jsx(View, {
|
|
84
|
+
...passthroughProps(rest),
|
|
84
85
|
css: styles === null || styles === void 0 ? void 0 : styles.list,
|
|
85
86
|
as: as,
|
|
86
87
|
margin: margin,
|
|
87
88
|
elementRef: this.handleRef,
|
|
88
|
-
display: "block"
|
|
89
|
-
|
|
89
|
+
display: "block",
|
|
90
|
+
children: this.renderChildren()
|
|
91
|
+
});
|
|
90
92
|
}
|
|
91
93
|
}, _List.displayName = "List", _List.componentId = 'List', _List.propTypes = propTypes, _List.allowedProps = allowedProps, _List.defaultProps = {
|
|
92
94
|
as: 'ul',
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _react = _interopRequireDefault(require("react"));
|
|
5
3
|
require("@testing-library/jest-dom");
|
|
6
|
-
var
|
|
4
|
+
var _react = require("@testing-library/react");
|
|
7
5
|
var _vitest = require("vitest");
|
|
8
6
|
var _index = require("../index");
|
|
7
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
8
|
var _InlineListItem, _InlineListItem2;
|
|
10
9
|
/*
|
|
11
10
|
* The MIT License (MIT)
|
|
@@ -32,24 +31,28 @@ var _InlineListItem, _InlineListItem2;
|
|
|
32
31
|
*/
|
|
33
32
|
describe('<InlineListItem />', () => {
|
|
34
33
|
it('should render children', async () => {
|
|
35
|
-
(0,
|
|
36
|
-
|
|
34
|
+
(0, _react.render)(_InlineListItem || (_InlineListItem = (0, _jsxRuntime.jsx)(_index.InlineListItem, {
|
|
35
|
+
children: "hello"
|
|
36
|
+
})));
|
|
37
|
+
const listItem = _react.screen.getByRole('listitem');
|
|
37
38
|
expect(listItem).toHaveTextContent('hello');
|
|
38
39
|
});
|
|
39
40
|
it('should render delimiter', async () => {
|
|
40
|
-
const _render = (0,
|
|
41
|
-
delimiter: "slash"
|
|
42
|
-
|
|
41
|
+
const _render = (0, _react.render)(_InlineListItem2 || (_InlineListItem2 = (0, _jsxRuntime.jsx)(_index.InlineListItem, {
|
|
42
|
+
delimiter: "slash",
|
|
43
|
+
children: "List item"
|
|
44
|
+
}))),
|
|
43
45
|
container = _render.container;
|
|
44
46
|
const listItem = container.querySelector('span[class$="delimiter"]');
|
|
45
47
|
expect(listItem).toHaveAttribute('aria-hidden', 'true');
|
|
46
48
|
});
|
|
47
49
|
it('should call elementRef', async () => {
|
|
48
50
|
const elementRef = _vitest.vi.fn();
|
|
49
|
-
(0,
|
|
50
|
-
elementRef: elementRef
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
(0, _react.render)((0, _jsxRuntime.jsx)(_index.InlineListItem, {
|
|
52
|
+
elementRef: elementRef,
|
|
53
|
+
children: "List item"
|
|
54
|
+
}));
|
|
55
|
+
const listItem = _react.screen.getByRole('listitem');
|
|
53
56
|
expect(elementRef).toHaveBeenCalledWith(listItem);
|
|
54
57
|
});
|
|
55
58
|
});
|
|
@@ -14,6 +14,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
14
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
15
15
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
16
16
|
var _props = require("./props");
|
|
17
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
18
|
const _excluded = ["delimiter", "size", "margin", "padding", "elementRef", "children", "spacing", "styles"];
|
|
18
19
|
var _dec, _dec2, _class, _InlineListItem;
|
|
19
20
|
/*
|
|
@@ -39,7 +40,6 @@ var _dec, _dec2, _class, _InlineListItem;
|
|
|
39
40
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
40
41
|
* SOFTWARE.
|
|
41
42
|
*/
|
|
42
|
-
/** @jsx jsx */
|
|
43
43
|
/**
|
|
44
44
|
---
|
|
45
45
|
parent: InlineList
|
|
@@ -77,18 +77,20 @@ let InlineListItem = exports.InlineListItem = (_dec = (0, _emotion.withStyle)(_s
|
|
|
77
77
|
spacing = _this$props3.spacing,
|
|
78
78
|
styles = _this$props3.styles,
|
|
79
79
|
rest = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
80
|
-
return (0,
|
|
80
|
+
return (0, _jsxRuntime.jsxs)(_View.View, {
|
|
81
|
+
...(0, _passthroughProps.passthroughProps)(rest),
|
|
81
82
|
css: styles === null || styles === void 0 ? void 0 : styles.inlineListItem,
|
|
82
83
|
as: "li",
|
|
83
84
|
margin: margin,
|
|
84
85
|
padding: padding,
|
|
85
86
|
display: "inline-block",
|
|
86
87
|
maxWidth: "100%",
|
|
87
|
-
elementRef: this.handleRef
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
elementRef: this.handleRef,
|
|
89
|
+
children: [children, (0, _jsxRuntime.jsx)("span", {
|
|
90
|
+
css: styles === null || styles === void 0 ? void 0 : styles.delimiter,
|
|
91
|
+
"aria-hidden": "true"
|
|
92
|
+
})]
|
|
93
|
+
});
|
|
92
94
|
}
|
|
93
95
|
}, _InlineListItem.displayName = "InlineListItem", _InlineListItem.componentId = 'InlineList.Item', _InlineListItem.propTypes = _props.propTypes, _InlineListItem.allowedProps = _props.allowedProps, _InlineListItem.defaultProps = {
|
|
94
96
|
padding: 'none',
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
7
|
var _index = require("../index");
|
|
8
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
9
|
var _InlineList$Item, _InlineList$Item2, _InlineList$Item3;
|
|
11
10
|
/*
|
|
12
11
|
* The MIT License (MIT)
|
|
@@ -35,13 +34,13 @@ var _default = exports.default = {
|
|
|
35
34
|
sectionProp: 'size',
|
|
36
35
|
getComponentProps: () => {
|
|
37
36
|
return {
|
|
38
|
-
children: [_InlineList$Item || (_InlineList$Item =
|
|
39
|
-
|
|
40
|
-
}, "
|
|
41
|
-
|
|
42
|
-
}, "
|
|
43
|
-
|
|
44
|
-
}, "
|
|
37
|
+
children: [_InlineList$Item || (_InlineList$Item = (0, _jsxRuntime.jsx)(_index.InlineList.Item, {
|
|
38
|
+
children: "Oranges"
|
|
39
|
+
}, "1")), _InlineList$Item2 || (_InlineList$Item2 = (0, _jsxRuntime.jsx)(_index.InlineList.Item, {
|
|
40
|
+
children: "Pineapples"
|
|
41
|
+
}, "2")), _InlineList$Item3 || (_InlineList$Item3 = (0, _jsxRuntime.jsx)(_index.InlineList.Item, {
|
|
42
|
+
children: "Bananas"
|
|
43
|
+
}, "3"))]
|
|
45
44
|
};
|
|
46
45
|
},
|
|
47
46
|
filter: props => {
|