@instructure/ui-flex 10.12.1-snapshot-9 → 10.12.1-snapshot-10

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 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.12.1-snapshot-9](https://github.com/instructure/instructure-ui/compare/v10.12.0...v10.12.1-snapshot-9) (2025-03-06)
6
+ ## [10.12.1-snapshot-10](https://github.com/instructure/instructure-ui/compare/v10.12.0...v10.12.1-snapshot-10) (2025-03-06)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-flex
9
9
 
@@ -0,0 +1,57 @@
1
+ var _Item, _Item2;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import React from 'react';
27
+ import { render, waitFor } from '@testing-library/react';
28
+ import { vi } from 'vitest';
29
+ import '@testing-library/jest-dom';
30
+ import { runAxeCheck } from '@instructure/ui-axe-check';
31
+ import { Item } from '../index';
32
+ describe('<Item />', () => {
33
+ it('should render children', async () => {
34
+ const _render = render(_Item || (_Item = /*#__PURE__*/React.createElement(Item, null, "Flex item 1"))),
35
+ container = _render.container;
36
+ const item = container.querySelector('[class$="-flexItem"]');
37
+ expect(item).toBeInTheDocument();
38
+ expect(item).toHaveTextContent('Flex item 1');
39
+ });
40
+ it('should support an elementRef prop', async () => {
41
+ const elementRef = vi.fn();
42
+ const _render2 = render(/*#__PURE__*/React.createElement(Item, {
43
+ elementRef: elementRef
44
+ }, "Flex item 2")),
45
+ container = _render2.container;
46
+ const item = container.querySelector('[class$="-flexItem"]');
47
+ await waitFor(() => {
48
+ expect(elementRef).toHaveBeenCalledWith(item);
49
+ });
50
+ });
51
+ it('should meet a11y standards', async () => {
52
+ const _render3 = render(_Item2 || (_Item2 = /*#__PURE__*/React.createElement(Item, null, "Flex item 3"))),
53
+ container = _render3.container;
54
+ const axeCheck = await runAxeCheck(container);
55
+ expect(axeCheck).toBe(true);
56
+ });
57
+ });
@@ -0,0 +1,180 @@
1
+ var _Flex, _Flex2, _div, _Flex3, _Flex4, _Flex5, _Flex6, _Flex7, _Flex8, _Flex9, _Flex10, _Flex11, _Flex12, _Flex13, _Flex$Item, _Flex14;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import React from 'react';
27
+ import { render, screen, waitFor } from '@testing-library/react';
28
+ import { vi } from 'vitest';
29
+ import '@testing-library/jest-dom';
30
+ import { runAxeCheck } from '@instructure/ui-axe-check';
31
+ import { Flex } from '../index';
32
+ describe('<Flex />', () => {
33
+ it('should render Flex.Items as children', async () => {
34
+ const _render = render(_Flex || (_Flex = /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 3"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 4")))),
35
+ container = _render.container;
36
+ const flex = container.querySelector('[class$="-flex-flex"]');
37
+ expect(flex).toBeInTheDocument();
38
+ const items = flex === null || flex === void 0 ? void 0 : flex.querySelectorAll('[class$="-flexItem"]');
39
+ expect(items === null || items === void 0 ? void 0 : items.length).toBe(4);
40
+ });
41
+ it('should render other markup as children', async () => {
42
+ const _render2 = render(_Flex2 || (_Flex2 = /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement("div", null, "foo"), /*#__PURE__*/React.createElement("div", null, "bar"), /*#__PURE__*/React.createElement("div", null, "baz")))),
43
+ container = _render2.container;
44
+ const flex = container.querySelector('[class$="-flex-flex"]');
45
+ const childs = flex === null || flex === void 0 ? void 0 : flex.childNodes;
46
+ expect(childs === null || childs === void 0 ? void 0 : childs.length).toBe(3);
47
+ });
48
+ it('should render children when children is a function', async () => {
49
+ render(/*#__PURE__*/React.createElement(Flex, null, () => _div || (_div = /*#__PURE__*/React.createElement("div", null, "hello world"))));
50
+ const child = screen.getByText('hello world');
51
+ expect(child).toBeInTheDocument();
52
+ });
53
+ it('should render no markup if there are no children', async () => {
54
+ const _render3 = render(_Flex3 || (_Flex3 = /*#__PURE__*/React.createElement(Flex, null))),
55
+ container = _render3.container;
56
+ const flex = container.querySelector('[class$="-flex-flex"]');
57
+ expect(flex).not.toBeInTheDocument();
58
+ });
59
+ it('should accept width and height as props', async () => {
60
+ const _render4 = render(_Flex4 || (_Flex4 = /*#__PURE__*/React.createElement(Flex, {
61
+ width: "400px",
62
+ height: "200px"
63
+ }, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 3"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 4")))),
64
+ container = _render4.container;
65
+ const flex = container.querySelector('[class$="-flex-flex"]');
66
+ const flexStyle = window.getComputedStyle(flex);
67
+ expect(flexStyle.width).toBe('400px');
68
+ expect(flexStyle.height).toBe('200px');
69
+ });
70
+ it('should set flex-direction with the direction property', async () => {
71
+ const _render5 = render(_Flex5 || (_Flex5 = /*#__PURE__*/React.createElement(Flex, {
72
+ direction: "column"
73
+ }, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2")))),
74
+ container = _render5.container;
75
+ const flex = container.querySelector('[class$="-flex-flex"]');
76
+ const flexStyle = window.getComputedStyle(flex);
77
+ expect(flexStyle.flexDirection).toBe('column');
78
+ });
79
+ it('should render an inline-flex container with the display property', async () => {
80
+ const _render6 = render(_Flex6 || (_Flex6 = /*#__PURE__*/React.createElement(Flex, {
81
+ display: "inline-flex"
82
+ }, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2")))),
83
+ container = _render6.container;
84
+ const flex = container.querySelector('[class$="-inlineFlex-flex"]');
85
+ const flexStyle = window.getComputedStyle(flex);
86
+ expect(flexStyle.display).toBe('inline-flex');
87
+ });
88
+ it('should set align-items with the alignItems property', async () => {
89
+ const _render7 = render(_Flex7 || (_Flex7 = /*#__PURE__*/React.createElement(Flex, {
90
+ alignItems: "start"
91
+ }, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2")))),
92
+ container = _render7.container;
93
+ const flex = container.querySelector('[class$="-flex-flex"]');
94
+ const flexStyle = window.getComputedStyle(flex);
95
+ expect(flexStyle.alignItems).toBe('flex-start');
96
+ });
97
+ it('should set justify-content with the justifyItems property', async () => {
98
+ const _render8 = render(_Flex8 || (_Flex8 = /*#__PURE__*/React.createElement(Flex, {
99
+ justifyItems: "space-between"
100
+ }, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2")))),
101
+ container = _render8.container;
102
+ const flex = container.querySelector('[class$="-flex-flex"]');
103
+ const flexStyle = window.getComputedStyle(flex);
104
+ expect(flexStyle.justifyContent).toBe('space-between');
105
+ });
106
+ it('should set flex-wrap with the wrap property', async () => {
107
+ const _render9 = render(_Flex9 || (_Flex9 = /*#__PURE__*/React.createElement(Flex, {
108
+ wrap: "wrap"
109
+ }, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2")))),
110
+ container = _render9.container;
111
+ const flex = container.querySelector('[class$="-flex-flex"]');
112
+ const flexStyle = window.getComputedStyle(flex);
113
+ expect(flexStyle.flexWrap).toBe('wrap');
114
+ });
115
+ it('should let Flex.Items align themselves with the align property', async () => {
116
+ const _render10 = render(_Flex10 || (_Flex10 = /*#__PURE__*/React.createElement(Flex, {
117
+ alignItems: "end"
118
+ }, /*#__PURE__*/React.createElement(Flex.Item, {
119
+ align: "stretch"
120
+ }, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2")))),
121
+ container = _render10.container;
122
+ const flex = container.querySelector('[class$="-flex-flex"]');
123
+ const item = screen.getByText('Flex item 1');
124
+ const flexStyle = window.getComputedStyle(flex);
125
+ const itemStyle = window.getComputedStyle(item);
126
+ expect(flexStyle.alignItems).toBe('flex-end');
127
+ expect(itemStyle.alignSelf).toBe('stretch');
128
+ });
129
+ it('should let Flex.Items flex-grow with the shouldGrow property', async () => {
130
+ render(_Flex11 || (_Flex11 = /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, {
131
+ shouldGrow: true
132
+ }, "Flex item 2"))));
133
+ const item1 = screen.getByText('Flex item 1');
134
+ const item2 = screen.getByText('Flex item 2');
135
+ const item1Style = window.getComputedStyle(item1);
136
+ const item2Style = window.getComputedStyle(item2);
137
+ expect(item1Style.flexGrow).toBe('');
138
+ expect(item2Style.flexGrow).toBe('1');
139
+ });
140
+ it('should let Flex.Items flex-shrink with the shouldShrink property', async () => {
141
+ render(_Flex12 || (_Flex12 = /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, {
142
+ shouldShrink: true
143
+ }, "Flex item 2"))));
144
+ const item1 = screen.getByText('Flex item 1');
145
+ const item2 = screen.getByText('Flex item 2');
146
+ const item1Style = window.getComputedStyle(item1);
147
+ const item2Style = window.getComputedStyle(item2);
148
+ expect(item1Style.flexShrink).toBe('0');
149
+ expect(item2Style.flexShrink).toBe('1');
150
+ });
151
+ it('should set flex-basis and min-width on Flex.Items with the size property', async () => {
152
+ render(_Flex13 || (_Flex13 = /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2"), /*#__PURE__*/React.createElement(Flex.Item, {
153
+ size: "100px"
154
+ }, "Flex item 3"))));
155
+ const item2 = screen.getByText('Flex item 2');
156
+ const item3 = screen.getByText('Flex item 3');
157
+ const item2Style = window.getComputedStyle(item2);
158
+ const item3Style = window.getComputedStyle(item3);
159
+ expect(item2Style.flexBasis).toBe('');
160
+ expect(item3Style.flexBasis).toBe('100px');
161
+ expect(item3Style.minWidth).toBe('100px');
162
+ });
163
+ it('should support an elementRef prop', async () => {
164
+ const elementRef = vi.fn();
165
+ const _render11 = render(/*#__PURE__*/React.createElement(Flex, {
166
+ elementRef: elementRef
167
+ }, _Flex$Item || (_Flex$Item = /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item")))),
168
+ container = _render11.container;
169
+ const flex = container.querySelector('[class$="-flex-flex"]');
170
+ await waitFor(() => {
171
+ expect(elementRef).toHaveBeenCalledWith(flex);
172
+ });
173
+ });
174
+ it('should meet a11y standards', async () => {
175
+ const _render12 = render(_Flex14 || (_Flex14 = /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 1"), /*#__PURE__*/React.createElement(Flex.Item, null, "Flex item 2")))),
176
+ container = _render12.container;
177
+ const axeCheck = await runAxeCheck(container);
178
+ expect(axeCheck).toBe(true);
179
+ });
180
+ });
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ var _vitest = require("vitest");
7
+ require("@testing-library/jest-dom");
8
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
9
+ var _index = require("../index");
10
+ var _Item, _Item2;
11
+ /*
12
+ * The MIT License (MIT)
13
+ *
14
+ * Copyright (c) 2015 - present Instructure, Inc.
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ * of this software and associated documentation files (the "Software"), to deal
18
+ * in the Software without restriction, including without limitation the rights
19
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ * copies of the Software, and to permit persons to whom the Software is
21
+ * furnished to do so, subject to the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in all
24
+ * copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ * SOFTWARE.
33
+ */
34
+ describe('<Item />', () => {
35
+ it('should render children', async () => {
36
+ const _render = (0, _react2.render)(_Item || (_Item = /*#__PURE__*/_react.default.createElement(_index.Item, null, "Flex item 1"))),
37
+ container = _render.container;
38
+ const item = container.querySelector('[class$="-flexItem"]');
39
+ expect(item).toBeInTheDocument();
40
+ expect(item).toHaveTextContent('Flex item 1');
41
+ });
42
+ it('should support an elementRef prop', async () => {
43
+ const elementRef = _vitest.vi.fn();
44
+ const _render2 = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.Item, {
45
+ elementRef: elementRef
46
+ }, "Flex item 2")),
47
+ container = _render2.container;
48
+ const item = container.querySelector('[class$="-flexItem"]');
49
+ await (0, _react2.waitFor)(() => {
50
+ expect(elementRef).toHaveBeenCalledWith(item);
51
+ });
52
+ });
53
+ it('should meet a11y standards', async () => {
54
+ const _render3 = (0, _react2.render)(_Item2 || (_Item2 = /*#__PURE__*/_react.default.createElement(_index.Item, null, "Flex item 3"))),
55
+ container = _render3.container;
56
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
57
+ expect(axeCheck).toBe(true);
58
+ });
59
+ });
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ var _vitest = require("vitest");
7
+ require("@testing-library/jest-dom");
8
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
9
+ var _index = require("../index");
10
+ var _Flex, _Flex2, _div, _Flex3, _Flex4, _Flex5, _Flex6, _Flex7, _Flex8, _Flex9, _Flex10, _Flex11, _Flex12, _Flex13, _Flex$Item, _Flex14;
11
+ /*
12
+ * The MIT License (MIT)
13
+ *
14
+ * Copyright (c) 2015 - present Instructure, Inc.
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ * of this software and associated documentation files (the "Software"), to deal
18
+ * in the Software without restriction, including without limitation the rights
19
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ * copies of the Software, and to permit persons to whom the Software is
21
+ * furnished to do so, subject to the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in all
24
+ * copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ * SOFTWARE.
33
+ */
34
+ describe('<Flex />', () => {
35
+ it('should render Flex.Items as children', async () => {
36
+ const _render = (0, _react2.render)(_Flex || (_Flex = /*#__PURE__*/_react.default.createElement(_index.Flex, null, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 3"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 4")))),
37
+ container = _render.container;
38
+ const flex = container.querySelector('[class$="-flex-flex"]');
39
+ expect(flex).toBeInTheDocument();
40
+ const items = flex === null || flex === void 0 ? void 0 : flex.querySelectorAll('[class$="-flexItem"]');
41
+ expect(items === null || items === void 0 ? void 0 : items.length).toBe(4);
42
+ });
43
+ it('should render other markup as children', async () => {
44
+ const _render2 = (0, _react2.render)(_Flex2 || (_Flex2 = /*#__PURE__*/_react.default.createElement(_index.Flex, null, /*#__PURE__*/_react.default.createElement("div", null, "foo"), /*#__PURE__*/_react.default.createElement("div", null, "bar"), /*#__PURE__*/_react.default.createElement("div", null, "baz")))),
45
+ container = _render2.container;
46
+ const flex = container.querySelector('[class$="-flex-flex"]');
47
+ const childs = flex === null || flex === void 0 ? void 0 : flex.childNodes;
48
+ expect(childs === null || childs === void 0 ? void 0 : childs.length).toBe(3);
49
+ });
50
+ it('should render children when children is a function', async () => {
51
+ (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.Flex, null, () => _div || (_div = /*#__PURE__*/_react.default.createElement("div", null, "hello world"))));
52
+ const child = _react2.screen.getByText('hello world');
53
+ expect(child).toBeInTheDocument();
54
+ });
55
+ it('should render no markup if there are no children', async () => {
56
+ const _render3 = (0, _react2.render)(_Flex3 || (_Flex3 = /*#__PURE__*/_react.default.createElement(_index.Flex, null))),
57
+ container = _render3.container;
58
+ const flex = container.querySelector('[class$="-flex-flex"]');
59
+ expect(flex).not.toBeInTheDocument();
60
+ });
61
+ it('should accept width and height as props', async () => {
62
+ const _render4 = (0, _react2.render)(_Flex4 || (_Flex4 = /*#__PURE__*/_react.default.createElement(_index.Flex, {
63
+ width: "400px",
64
+ height: "200px"
65
+ }, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 3"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 4")))),
66
+ container = _render4.container;
67
+ const flex = container.querySelector('[class$="-flex-flex"]');
68
+ const flexStyle = window.getComputedStyle(flex);
69
+ expect(flexStyle.width).toBe('400px');
70
+ expect(flexStyle.height).toBe('200px');
71
+ });
72
+ it('should set flex-direction with the direction property', async () => {
73
+ const _render5 = (0, _react2.render)(_Flex5 || (_Flex5 = /*#__PURE__*/_react.default.createElement(_index.Flex, {
74
+ direction: "column"
75
+ }, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2")))),
76
+ container = _render5.container;
77
+ const flex = container.querySelector('[class$="-flex-flex"]');
78
+ const flexStyle = window.getComputedStyle(flex);
79
+ expect(flexStyle.flexDirection).toBe('column');
80
+ });
81
+ it('should render an inline-flex container with the display property', async () => {
82
+ const _render6 = (0, _react2.render)(_Flex6 || (_Flex6 = /*#__PURE__*/_react.default.createElement(_index.Flex, {
83
+ display: "inline-flex"
84
+ }, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2")))),
85
+ container = _render6.container;
86
+ const flex = container.querySelector('[class$="-inlineFlex-flex"]');
87
+ const flexStyle = window.getComputedStyle(flex);
88
+ expect(flexStyle.display).toBe('inline-flex');
89
+ });
90
+ it('should set align-items with the alignItems property', async () => {
91
+ const _render7 = (0, _react2.render)(_Flex7 || (_Flex7 = /*#__PURE__*/_react.default.createElement(_index.Flex, {
92
+ alignItems: "start"
93
+ }, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2")))),
94
+ container = _render7.container;
95
+ const flex = container.querySelector('[class$="-flex-flex"]');
96
+ const flexStyle = window.getComputedStyle(flex);
97
+ expect(flexStyle.alignItems).toBe('flex-start');
98
+ });
99
+ it('should set justify-content with the justifyItems property', async () => {
100
+ const _render8 = (0, _react2.render)(_Flex8 || (_Flex8 = /*#__PURE__*/_react.default.createElement(_index.Flex, {
101
+ justifyItems: "space-between"
102
+ }, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2")))),
103
+ container = _render8.container;
104
+ const flex = container.querySelector('[class$="-flex-flex"]');
105
+ const flexStyle = window.getComputedStyle(flex);
106
+ expect(flexStyle.justifyContent).toBe('space-between');
107
+ });
108
+ it('should set flex-wrap with the wrap property', async () => {
109
+ const _render9 = (0, _react2.render)(_Flex9 || (_Flex9 = /*#__PURE__*/_react.default.createElement(_index.Flex, {
110
+ wrap: "wrap"
111
+ }, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2")))),
112
+ container = _render9.container;
113
+ const flex = container.querySelector('[class$="-flex-flex"]');
114
+ const flexStyle = window.getComputedStyle(flex);
115
+ expect(flexStyle.flexWrap).toBe('wrap');
116
+ });
117
+ it('should let Flex.Items align themselves with the align property', async () => {
118
+ const _render10 = (0, _react2.render)(_Flex10 || (_Flex10 = /*#__PURE__*/_react.default.createElement(_index.Flex, {
119
+ alignItems: "end"
120
+ }, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, {
121
+ align: "stretch"
122
+ }, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2")))),
123
+ container = _render10.container;
124
+ const flex = container.querySelector('[class$="-flex-flex"]');
125
+ const item = _react2.screen.getByText('Flex item 1');
126
+ const flexStyle = window.getComputedStyle(flex);
127
+ const itemStyle = window.getComputedStyle(item);
128
+ expect(flexStyle.alignItems).toBe('flex-end');
129
+ expect(itemStyle.alignSelf).toBe('stretch');
130
+ });
131
+ it('should let Flex.Items flex-grow with the shouldGrow property', async () => {
132
+ (0, _react2.render)(_Flex11 || (_Flex11 = /*#__PURE__*/_react.default.createElement(_index.Flex, null, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, {
133
+ shouldGrow: true
134
+ }, "Flex item 2"))));
135
+ const item1 = _react2.screen.getByText('Flex item 1');
136
+ const item2 = _react2.screen.getByText('Flex item 2');
137
+ const item1Style = window.getComputedStyle(item1);
138
+ const item2Style = window.getComputedStyle(item2);
139
+ expect(item1Style.flexGrow).toBe('');
140
+ expect(item2Style.flexGrow).toBe('1');
141
+ });
142
+ it('should let Flex.Items flex-shrink with the shouldShrink property', async () => {
143
+ (0, _react2.render)(_Flex12 || (_Flex12 = /*#__PURE__*/_react.default.createElement(_index.Flex, null, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, {
144
+ shouldShrink: true
145
+ }, "Flex item 2"))));
146
+ const item1 = _react2.screen.getByText('Flex item 1');
147
+ const item2 = _react2.screen.getByText('Flex item 2');
148
+ const item1Style = window.getComputedStyle(item1);
149
+ const item2Style = window.getComputedStyle(item2);
150
+ expect(item1Style.flexShrink).toBe('0');
151
+ expect(item2Style.flexShrink).toBe('1');
152
+ });
153
+ it('should set flex-basis and min-width on Flex.Items with the size property', async () => {
154
+ (0, _react2.render)(_Flex13 || (_Flex13 = /*#__PURE__*/_react.default.createElement(_index.Flex, null, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, {
155
+ size: "100px"
156
+ }, "Flex item 3"))));
157
+ const item2 = _react2.screen.getByText('Flex item 2');
158
+ const item3 = _react2.screen.getByText('Flex item 3');
159
+ const item2Style = window.getComputedStyle(item2);
160
+ const item3Style = window.getComputedStyle(item3);
161
+ expect(item2Style.flexBasis).toBe('');
162
+ expect(item3Style.flexBasis).toBe('100px');
163
+ expect(item3Style.minWidth).toBe('100px');
164
+ });
165
+ it('should support an elementRef prop', async () => {
166
+ const elementRef = _vitest.vi.fn();
167
+ const _render11 = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.Flex, {
168
+ elementRef: elementRef
169
+ }, _Flex$Item || (_Flex$Item = /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item")))),
170
+ container = _render11.container;
171
+ const flex = container.querySelector('[class$="-flex-flex"]');
172
+ await (0, _react2.waitFor)(() => {
173
+ expect(elementRef).toHaveBeenCalledWith(flex);
174
+ });
175
+ });
176
+ it('should meet a11y standards', async () => {
177
+ const _render12 = (0, _react2.render)(_Flex14 || (_Flex14 = /*#__PURE__*/_react.default.createElement(_index.Flex, null, /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 1"), /*#__PURE__*/_react.default.createElement(_index.Flex.Item, null, "Flex item 2")))),
178
+ container = _render12.container;
179
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
180
+ expect(axeCheck).toBe(true);
181
+ });
182
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-flex",
3
- "version": "10.12.1-snapshot-9",
3
+ "version": "10.12.1-snapshot-10",
4
4
  "description": "A component that makes it easy to align content using flexbox CSS",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,17 +24,21 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.26.0",
27
- "@instructure/console": "10.12.1-snapshot-9",
28
- "@instructure/emotion": "10.12.1-snapshot-9",
29
- "@instructure/shared-types": "10.12.1-snapshot-9",
30
- "@instructure/ui-react-utils": "10.12.1-snapshot-9",
31
- "@instructure/ui-view": "10.12.1-snapshot-9",
27
+ "@instructure/console": "10.12.1-snapshot-10",
28
+ "@instructure/emotion": "10.12.1-snapshot-10",
29
+ "@instructure/shared-types": "10.12.1-snapshot-10",
30
+ "@instructure/ui-react-utils": "10.12.1-snapshot-10",
31
+ "@instructure/ui-view": "10.12.1-snapshot-10",
32
32
  "prop-types": "^15.8.1"
33
33
  },
34
34
  "devDependencies": {
35
- "@instructure/ui-babel-preset": "10.12.1-snapshot-9",
36
- "@instructure/ui-test-utils": "10.12.1-snapshot-9",
37
- "@instructure/ui-themes": "10.12.1-snapshot-9"
35
+ "@instructure/ui-axe-check": "10.12.1-snapshot-10",
36
+ "@instructure/ui-babel-preset": "10.12.1-snapshot-10",
37
+ "@instructure/ui-test-utils": "10.12.1-snapshot-10",
38
+ "@instructure/ui-themes": "10.12.1-snapshot-10",
39
+ "@testing-library/jest-dom": "^6.6.3",
40
+ "@testing-library/react": "^16.0.1",
41
+ "vitest": "^2.1.8"
38
42
  },
39
43
  "peerDependencies": {
40
44
  "react": ">=16.14 <=18"
@@ -0,0 +1,61 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import React from 'react'
26
+ import { render, waitFor } from '@testing-library/react'
27
+ import { vi } from 'vitest'
28
+
29
+ import '@testing-library/jest-dom'
30
+ import { runAxeCheck } from '@instructure/ui-axe-check'
31
+ import { Item } from '../index'
32
+
33
+ describe('<Item />', () => {
34
+ it('should render children', async () => {
35
+ const { container } = render(<Item>Flex item 1</Item>)
36
+ const item = container.querySelector('[class$="-flexItem"]')
37
+
38
+ expect(item).toBeInTheDocument()
39
+ expect(item).toHaveTextContent('Flex item 1')
40
+ })
41
+
42
+ it('should support an elementRef prop', async () => {
43
+ const elementRef = vi.fn()
44
+
45
+ const { container } = render(
46
+ <Item elementRef={elementRef}>Flex item 2</Item>
47
+ )
48
+ const item = container.querySelector('[class$="-flexItem"]')
49
+
50
+ await waitFor(() => {
51
+ expect(elementRef).toHaveBeenCalledWith(item)
52
+ })
53
+ })
54
+
55
+ it('should meet a11y standards', async () => {
56
+ const { container } = render(<Item>Flex item 3</Item>)
57
+ const axeCheck = await runAxeCheck(container)
58
+
59
+ expect(axeCheck).toBe(true)
60
+ })
61
+ })