@instructure/ui-react-utils 8.53.3-pr-snapshot-8 → 8.53.3-pr-snapshot-1709124298948
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 +5 -2
- package/es/DeterministicIdContext/DeterministicIdContextProvider.js +3 -2
- package/es/DeterministicIdContext/withDeterministicId.js +3 -1
- package/es/__new-tests__/ComponentIdentifier.test.js +7 -6
- package/es/__new-tests__/DeterministicIdContext.test.js +12 -11
- package/es/__new-tests__/callRenderProp.test.js +11 -10
- package/es/__new-tests__/deprecated.test.js +18 -17
- package/es/__new-tests__/experimental.test.js +8 -7
- package/es/__new-tests__/hack.test.js +5 -4
- package/es/__new-tests__/safeCloneElement.test.js +7 -7
- package/es/ensureSingleChild.js +3 -2
- package/lib/DeterministicIdContext/DeterministicIdContextProvider.js +2 -3
- package/lib/DeterministicIdContext/withDeterministicId.js +4 -2
- package/lib/__new-tests__/ComponentIdentifier.test.js +7 -7
- package/lib/__new-tests__/DeterministicIdContext.test.js +12 -11
- package/lib/__new-tests__/callRenderProp.test.js +11 -10
- package/lib/__new-tests__/deprecated.test.js +18 -18
- package/lib/__new-tests__/experimental.test.js +8 -8
- package/lib/__new-tests__/hack.test.js +5 -5
- package/lib/__new-tests__/safeCloneElement.test.js +10 -11
- package/lib/ensureSingleChild.js +4 -5
- package/package.json +7 -7
- package/src/DeterministicIdContext/DeterministicIdContextProvider.tsx +1 -1
- package/src/__new-tests__/ComponentIdentifier.test.tsx +1 -1
- package/src/__new-tests__/deprecated.test.tsx +1 -1
- package/src/__new-tests__/experimental.test.tsx +1 -1
- package/src/__new-tests__/hack.test.tsx +1 -1
- package/src/__new-tests__/safeCloneElement.test.tsx +1 -1
- package/src/ensureSingleChild.tsx +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ComponentIdentifier.d.ts +2 -2
- package/types/ComponentIdentifier.d.ts.map +1 -1
- package/types/DeterministicIdContext/DeterministicIdContextProvider.d.ts +2 -2
- package/types/DeterministicIdContext/DeterministicIdContextProvider.d.ts.map +1 -1
- package/types/ensureSingleChild.d.ts +2 -2
- package/types/ensureSingleChild.d.ts.map +1 -1
- package/types/getElementType.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [8.53.3-pr-snapshot-
|
|
6
|
+
## [8.53.3-pr-snapshot-1709124298948](https://github.com/instructure/instructure-ui/compare/v8.53.2...v8.53.3-pr-snapshot-1709124298948) (2024-02-28)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **many:** remove emotion's jsx pragma ([7435d5c](https://github.com/instructure/instructure-ui/commit/7435d5c31ca6556a1f95c4dfde156d5a76aad7de))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
import { DeterministicIdContext, defaultDeterministicIDMap } from './DeterministicIdContext';
|
|
26
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
26
27
|
/**
|
|
27
28
|
* ---
|
|
28
29
|
* category: components/utilities
|
|
@@ -40,7 +41,7 @@ const DeterministicIdContextProvider = ({
|
|
|
40
41
|
children,
|
|
41
42
|
instanceCounterMap
|
|
42
43
|
}) => {
|
|
43
|
-
return
|
|
44
|
+
return ___EmotionJSX(DeterministicIdContext.Provider, {
|
|
44
45
|
value: instanceCounterMap
|
|
45
46
|
}, children);
|
|
46
47
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
/*
|
|
2
3
|
* The MIT License (MIT)
|
|
3
4
|
*
|
|
@@ -27,6 +28,7 @@ import { DeterministicIdContext } from './DeterministicIdContext';
|
|
|
27
28
|
import { decorator } from '@instructure/ui-decorator';
|
|
28
29
|
import { generateId } from '@instructure/ui-utils';
|
|
29
30
|
import { warn } from '@instructure/console';
|
|
31
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
30
32
|
/**
|
|
31
33
|
* This decorator is used to enable the decorated class to use the `DeterministicIdContext` which is needed
|
|
32
34
|
* for deterministic id generation.
|
|
@@ -43,7 +45,7 @@ const withDeterministicId = decorator(ComposedComponent => {
|
|
|
43
45
|
if (props.deterministicId) {
|
|
44
46
|
warn(false, `Manually passing the "deterministicId" property is not allowed on the ${componentName} component.\n`, props.deterministicId);
|
|
45
47
|
}
|
|
46
|
-
return
|
|
48
|
+
return ___EmotionJSX(ComposedComponent, _extends({
|
|
47
49
|
ref: ref,
|
|
48
50
|
deterministicId: deterministicId
|
|
49
51
|
}, props));
|
|
@@ -23,11 +23,12 @@ var _h;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import
|
|
26
|
+
import { Component } from 'react';
|
|
27
27
|
import PropTypes from 'prop-types';
|
|
28
28
|
import { render } from '@testing-library/react';
|
|
29
29
|
import '@testing-library/jest-dom';
|
|
30
30
|
import { ComponentIdentifier } from '../ComponentIdentifier';
|
|
31
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
31
32
|
describe('ComponentIdentifier', () => {
|
|
32
33
|
var _App;
|
|
33
34
|
beforeAll(() => {
|
|
@@ -42,7 +43,7 @@ describe('ComponentIdentifier', () => {
|
|
|
42
43
|
class App extends Component {
|
|
43
44
|
render() {
|
|
44
45
|
const trigger = ComponentIdentifier.pick(Trigger, this.props.children);
|
|
45
|
-
return
|
|
46
|
+
return ___EmotionJSX("div", null, _h || (_h = ___EmotionJSX("h2", null, "Trigger")), trigger);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
App.displayName = "App";
|
|
@@ -54,21 +55,21 @@ describe('ComponentIdentifier', () => {
|
|
|
54
55
|
};
|
|
55
56
|
it('should render only child', () => {
|
|
56
57
|
let buttonRef;
|
|
57
|
-
render(
|
|
58
|
+
render(___EmotionJSX(App, null, ___EmotionJSX(Trigger, null, ___EmotionJSX("button", {
|
|
58
59
|
ref: el => buttonRef = el
|
|
59
60
|
}, "Click Me"))));
|
|
60
61
|
expect(buttonRef.textContent).toEqual('Click Me');
|
|
61
62
|
});
|
|
62
63
|
it('should not error when no children provided', () => {
|
|
63
|
-
const renderApp = () => render(_App || (_App =
|
|
64
|
+
const renderApp = () => render(_App || (_App = ___EmotionJSX(App, null, ___EmotionJSX(Trigger, null))));
|
|
64
65
|
expect(renderApp).not.toThrow();
|
|
65
66
|
});
|
|
66
67
|
it('should pass props', () => {
|
|
67
68
|
let buttonRef;
|
|
68
69
|
const onClick = jest.fn();
|
|
69
|
-
render(
|
|
70
|
+
render(___EmotionJSX(App, null, ___EmotionJSX(Trigger, {
|
|
70
71
|
onClick: onClick
|
|
71
|
-
},
|
|
72
|
+
}, ___EmotionJSX("button", {
|
|
72
73
|
ref: el => buttonRef = el
|
|
73
74
|
}, "Click Me"))));
|
|
74
75
|
buttonRef.click();
|
|
@@ -27,9 +27,10 @@ import React from 'react';
|
|
|
27
27
|
import { render, screen } from '@testing-library/react';
|
|
28
28
|
import '@testing-library/jest-dom';
|
|
29
29
|
import { withDeterministicId, DeterministicIdContextProvider, generateInstanceCounterMap } from '../DeterministicIdContext';
|
|
30
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
30
31
|
let TestComponent = (_dec = withDeterministicId(), _dec(_class = (_class2 = class TestComponent extends React.Component {
|
|
31
32
|
render() {
|
|
32
|
-
return
|
|
33
|
+
return ___EmotionJSX("div", {
|
|
33
34
|
"data-testid": "test-component",
|
|
34
35
|
id: this.props.deterministicId()
|
|
35
36
|
}, this.props.children);
|
|
@@ -37,7 +38,7 @@ let TestComponent = (_dec = withDeterministicId(), _dec(_class = (_class2 = clas
|
|
|
37
38
|
}, _class2.displayName = "TestComponent", _class2)) || _class);
|
|
38
39
|
class WrapperComponent extends React.Component {
|
|
39
40
|
render() {
|
|
40
|
-
return _div || (_div =
|
|
41
|
+
return _div || (_div = ___EmotionJSX("div", null, ___EmotionJSX(TestComponent, null)));
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
WrapperComponent.displayName = "WrapperComponent";
|
|
@@ -47,22 +48,22 @@ const uniqueIds = el => {
|
|
|
47
48
|
};
|
|
48
49
|
describe('DeterministicIdContext', () => {
|
|
49
50
|
it('can be found and tested with ReactTestUtils', () => {
|
|
50
|
-
render(_WrapperComponent || (_WrapperComponent =
|
|
51
|
+
render(_WrapperComponent || (_WrapperComponent = ___EmotionJSX(WrapperComponent, null)));
|
|
51
52
|
const testComponent = screen.getByTestId('test-component');
|
|
52
53
|
expect(testComponent).toBeInTheDocument();
|
|
53
54
|
expect(testComponent.id).toBeDefined();
|
|
54
55
|
});
|
|
55
56
|
it('should generate unique ids without Provider wrapper', () => {
|
|
56
|
-
render(_div2 || (_div2 =
|
|
57
|
+
render(_div2 || (_div2 = ___EmotionJSX("div", {
|
|
57
58
|
"data-testid": "test-components"
|
|
58
|
-
},
|
|
59
|
+
}, ___EmotionJSX(TestComponent, null), ___EmotionJSX(TestComponent, null), ___EmotionJSX(TestComponent, null), ___EmotionJSX(TestComponent, null), ___EmotionJSX(TestComponent, null))));
|
|
59
60
|
const el = screen.getByTestId('test-components');
|
|
60
61
|
expect(uniqueIds(el)).toBe(true);
|
|
61
62
|
});
|
|
62
63
|
it('should generate unique ids when components are rendered both out and inside of provider', () => {
|
|
63
|
-
render(_div3 || (_div3 =
|
|
64
|
+
render(_div3 || (_div3 = ___EmotionJSX("div", {
|
|
64
65
|
"data-testid": "test-components"
|
|
65
|
-
},
|
|
66
|
+
}, ___EmotionJSX(DeterministicIdContextProvider, null, ___EmotionJSX(TestComponent, null), ___EmotionJSX(TestComponent, null), ___EmotionJSX(TestComponent, null)), ___EmotionJSX(TestComponent, null), ___EmotionJSX(TestComponent, null))));
|
|
66
67
|
const el = screen.getByTestId('test-components');
|
|
67
68
|
expect(uniqueIds(el)).toBe(true);
|
|
68
69
|
});
|
|
@@ -70,19 +71,19 @@ describe('DeterministicIdContext', () => {
|
|
|
70
71
|
const Wrapper = ({
|
|
71
72
|
children
|
|
72
73
|
}) => {
|
|
73
|
-
return
|
|
74
|
+
return ___EmotionJSX(DeterministicIdContextProvider, {
|
|
74
75
|
instanceCounterMap: generateInstanceCounterMap()
|
|
75
|
-
},
|
|
76
|
+
}, ___EmotionJSX("div", {
|
|
76
77
|
"data-testid": "wrapper"
|
|
77
78
|
}, children));
|
|
78
79
|
};
|
|
79
80
|
const children = [];
|
|
80
81
|
for (let i = 0; i < 10; i++) {
|
|
81
|
-
children.push(
|
|
82
|
+
children.push(___EmotionJSX(TestComponent, {
|
|
82
83
|
key: i
|
|
83
84
|
}));
|
|
84
85
|
}
|
|
85
|
-
render(
|
|
86
|
+
render(___EmotionJSX(Wrapper, null, children));
|
|
86
87
|
const el = screen.getByTestId('wrapper');
|
|
87
88
|
expect(uniqueIds(el)).toBe(true);
|
|
88
89
|
});
|
|
@@ -28,6 +28,7 @@ import PropTypes from 'prop-types';
|
|
|
28
28
|
import { render } from '@testing-library/react';
|
|
29
29
|
import '@testing-library/jest-dom';
|
|
30
30
|
import { callRenderProp } from '../callRenderProp';
|
|
31
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
31
32
|
describe('callRenderProp', () => {
|
|
32
33
|
it('strings', () => {
|
|
33
34
|
expect(callRenderProp('foo')).toEqual('foo');
|
|
@@ -44,18 +45,18 @@ describe('callRenderProp', () => {
|
|
|
44
45
|
expect(callRenderProp(false)).toEqual(false);
|
|
45
46
|
});
|
|
46
47
|
it('JSX literals', () => {
|
|
47
|
-
const Foo = () => _div || (_div =
|
|
48
|
-
expect(callRenderProp(
|
|
48
|
+
const Foo = () => _div || (_div = ___EmotionJSX("div", null, "hello"));
|
|
49
|
+
expect(callRenderProp(___EmotionJSX(Foo, null))).toStrictEqual(___EmotionJSX(Foo, null));
|
|
49
50
|
});
|
|
50
51
|
it('React classes', () => {
|
|
51
52
|
class Foo extends React.Component {
|
|
52
53
|
render() {
|
|
53
|
-
return _div2 || (_div2 =
|
|
54
|
+
return _div2 || (_div2 = ___EmotionJSX("div", null, "hello"));
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
Foo.displayName = "Foo";
|
|
57
58
|
const Result = callRenderProp(Foo);
|
|
58
|
-
expect(Result).toStrictEqual(
|
|
59
|
+
expect(Result).toStrictEqual(___EmotionJSX(Foo, null));
|
|
59
60
|
const _render = render(Result),
|
|
60
61
|
getByText = _render.getByText;
|
|
61
62
|
expect(getByText('hello')).toBeInTheDocument();
|
|
@@ -65,7 +66,7 @@ describe('callRenderProp', () => {
|
|
|
65
66
|
return 'some text';
|
|
66
67
|
};
|
|
67
68
|
const result = callRenderProp(Baz);
|
|
68
|
-
const _render2 = render(
|
|
69
|
+
const _render2 = render(___EmotionJSX("div", null, result)),
|
|
69
70
|
getByText = _render2.getByText;
|
|
70
71
|
expect(getByText('some text')).toBeInTheDocument();
|
|
71
72
|
});
|
|
@@ -81,7 +82,7 @@ describe('callRenderProp', () => {
|
|
|
81
82
|
// if it was a real untranspiled fat arrow function.
|
|
82
83
|
if (Baz.prototype) Baz.prototype = void 0;
|
|
83
84
|
const result = callRenderProp(Baz);
|
|
84
|
-
const _render3 = render(
|
|
85
|
+
const _render3 = render(___EmotionJSX("div", null, result)),
|
|
85
86
|
getByText = _render3.getByText;
|
|
86
87
|
expect(getByText('some text')).toBeInTheDocument();
|
|
87
88
|
});
|
|
@@ -89,18 +90,18 @@ describe('callRenderProp', () => {
|
|
|
89
90
|
it('should pass props correctly to functions', () => {
|
|
90
91
|
const someFunc = ({
|
|
91
92
|
shape
|
|
92
|
-
}) =>
|
|
93
|
+
}) => ___EmotionJSX("div", null, shape);
|
|
93
94
|
const result = callRenderProp(someFunc, {
|
|
94
95
|
shape: 'rectangle'
|
|
95
96
|
});
|
|
96
|
-
const _render4 = render(
|
|
97
|
+
const _render4 = render(___EmotionJSX("div", null, result)),
|
|
97
98
|
getByText = _render4.getByText;
|
|
98
99
|
expect(getByText('rectangle')).toBeInTheDocument();
|
|
99
100
|
});
|
|
100
101
|
it('should pass props correctly to React classes', () => {
|
|
101
102
|
class Foo extends React.Component {
|
|
102
103
|
render() {
|
|
103
|
-
return
|
|
104
|
+
return ___EmotionJSX("div", null, this.props.shape);
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
Foo.displayName = "Foo";
|
|
@@ -113,7 +114,7 @@ describe('callRenderProp', () => {
|
|
|
113
114
|
const result = callRenderProp(Foo, {
|
|
114
115
|
shape: 'rectangle'
|
|
115
116
|
});
|
|
116
|
-
const _render5 = render(
|
|
117
|
+
const _render5 = render(___EmotionJSX("div", null, result)),
|
|
117
118
|
getByText = _render5.getByText;
|
|
118
119
|
expect(getByText('rectangle')).toBeInTheDocument();
|
|
119
120
|
});
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import { Component } from 'react';
|
|
26
26
|
import PropTypes from 'prop-types';
|
|
27
27
|
import { render } from '@testing-library/react';
|
|
28
28
|
import '@testing-library/jest-dom';
|
|
29
29
|
import { deprecated } from '../deprecated';
|
|
30
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
30
31
|
class TestComponent extends Component {
|
|
31
32
|
render() {
|
|
32
|
-
return
|
|
33
|
+
return ___EmotionJSX("div", null, this.props.qux, " ", this.props.bar);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
TestComponent.displayName = "TestComponent";
|
|
@@ -50,7 +51,7 @@ describe('@deprecated', () => {
|
|
|
50
51
|
})(TestComponent);
|
|
51
52
|
it('should warn when suggesting new prop when using old prop', () => {
|
|
52
53
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
53
|
-
render(_DeprecatedComponent || (_DeprecatedComponent =
|
|
54
|
+
render(_DeprecatedComponent || (_DeprecatedComponent = ___EmotionJSX(DeprecatedComponent, {
|
|
54
55
|
foo: "Jane"
|
|
55
56
|
})));
|
|
56
57
|
const expectedWarningMessage = 'Warning: [TestComponent] `foo` is deprecated and will be removed in version 2.1.0. Use `bar` instead. ';
|
|
@@ -59,7 +60,7 @@ describe('@deprecated', () => {
|
|
|
59
60
|
});
|
|
60
61
|
it('should warn when using old prop with no new prop', () => {
|
|
61
62
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
62
|
-
render(_DeprecatedComponent2 || (_DeprecatedComponent2 =
|
|
63
|
+
render(_DeprecatedComponent2 || (_DeprecatedComponent2 = ___EmotionJSX(DeprecatedComponent, {
|
|
63
64
|
baz: "Goodbye"
|
|
64
65
|
})));
|
|
65
66
|
const expectedWarningMessage = 'Warning: [TestComponent] `baz` is deprecated and will be removed in version 2.1.0.';
|
|
@@ -68,7 +69,7 @@ describe('@deprecated', () => {
|
|
|
68
69
|
});
|
|
69
70
|
it('should not output a warning using new prop', () => {
|
|
70
71
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
71
|
-
render(_DeprecatedComponent3 || (_DeprecatedComponent3 =
|
|
72
|
+
render(_DeprecatedComponent3 || (_DeprecatedComponent3 = ___EmotionJSX(DeprecatedComponent, {
|
|
72
73
|
bar: "Jane"
|
|
73
74
|
})));
|
|
74
75
|
expect(consoleWarningSpy).not.toHaveBeenCalled();
|
|
@@ -80,7 +81,7 @@ describe('@deprecated', () => {
|
|
|
80
81
|
const DeprecatedComponent = deprecated('3.4.0')(TestComponent);
|
|
81
82
|
it('should warn that the entire component is deprecated if no old props are supplied', () => {
|
|
82
83
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
83
|
-
render(_DeprecatedComponent4 || (_DeprecatedComponent4 =
|
|
84
|
+
render(_DeprecatedComponent4 || (_DeprecatedComponent4 = ___EmotionJSX(DeprecatedComponent, null)));
|
|
84
85
|
const expectedWarningMessage = 'Warning: [TestComponent] is deprecated and will be removed in version 3.4.0.';
|
|
85
86
|
expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
|
|
86
87
|
consoleWarningSpy.mockRestore();
|
|
@@ -92,7 +93,7 @@ describe('@deprecated', () => {
|
|
|
92
93
|
it('should warn that the component is deprecated and output a warning that the package changed', () => {
|
|
93
94
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
94
95
|
const expectedWarningMessage = 'Warning: [TestComponent] is deprecated and will be removed in version 5.0.0. It has been moved from @instructure/ui-forms to @instructure/ui-number-input.';
|
|
95
|
-
render(_DeprecatedComponent5 || (_DeprecatedComponent5 =
|
|
96
|
+
render(_DeprecatedComponent5 || (_DeprecatedComponent5 = ___EmotionJSX(DeprecatedComponent, null)));
|
|
96
97
|
expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
|
|
97
98
|
consoleWarningSpy.mockRestore();
|
|
98
99
|
});
|
|
@@ -102,7 +103,7 @@ describe('@deprecated', () => {
|
|
|
102
103
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
103
104
|
class DeprecatedPropValueComponent extends Component {
|
|
104
105
|
render() {
|
|
105
|
-
return
|
|
106
|
+
return ___EmotionJSX("div", null, this.props.color);
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
|
|
@@ -112,7 +113,7 @@ describe('@deprecated', () => {
|
|
|
112
113
|
DeprecatedPropValueComponent.defaultProps = {
|
|
113
114
|
color: 'red'
|
|
114
115
|
};
|
|
115
|
-
render(
|
|
116
|
+
render(___EmotionJSX(DeprecatedPropValueComponent, {
|
|
116
117
|
color: "yellow"
|
|
117
118
|
}));
|
|
118
119
|
expect(consoleWarningSpy).not.toHaveBeenCalled();
|
|
@@ -123,7 +124,7 @@ describe('@deprecated', () => {
|
|
|
123
124
|
const color = 'orange';
|
|
124
125
|
class DeprecatedPropValueComponent extends Component {
|
|
125
126
|
render() {
|
|
126
|
-
return
|
|
127
|
+
return ___EmotionJSX("div", null, this.props.color);
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
|
|
@@ -133,7 +134,7 @@ describe('@deprecated', () => {
|
|
|
133
134
|
DeprecatedPropValueComponent.defaultProps = {
|
|
134
135
|
color: 'red'
|
|
135
136
|
};
|
|
136
|
-
render(
|
|
137
|
+
render(___EmotionJSX(DeprecatedPropValueComponent, {
|
|
137
138
|
color: color
|
|
138
139
|
}));
|
|
139
140
|
const expectedWarningMessage = `The '${color}' value for the \`color\` prop is deprecated.`;
|
|
@@ -146,7 +147,7 @@ describe('@deprecated', () => {
|
|
|
146
147
|
const message = 'It will be removed in v8.0.0.';
|
|
147
148
|
class DeprecatedPropValueComponent extends Component {
|
|
148
149
|
render() {
|
|
149
|
-
return
|
|
150
|
+
return ___EmotionJSX("div", null, this.props.color);
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
|
|
@@ -156,7 +157,7 @@ describe('@deprecated', () => {
|
|
|
156
157
|
DeprecatedPropValueComponent.defaultProps = {
|
|
157
158
|
color: 'red'
|
|
158
159
|
};
|
|
159
|
-
render(
|
|
160
|
+
render(___EmotionJSX(DeprecatedPropValueComponent, {
|
|
160
161
|
color: color
|
|
161
162
|
}));
|
|
162
163
|
const expectedWarningMessage = `The '${color}' value for the \`color\` prop is deprecated. ${message}`;
|
|
@@ -169,7 +170,7 @@ describe('@deprecated', () => {
|
|
|
169
170
|
const color = 'gold';
|
|
170
171
|
class DeprecatedPropValueComponent extends Component {
|
|
171
172
|
render() {
|
|
172
|
-
return
|
|
173
|
+
return ___EmotionJSX("div", null, this.props.color);
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
|
|
@@ -179,7 +180,7 @@ describe('@deprecated', () => {
|
|
|
179
180
|
DeprecatedPropValueComponent.defaultProps = {
|
|
180
181
|
color: 'red'
|
|
181
182
|
};
|
|
182
|
-
render(
|
|
183
|
+
render(___EmotionJSX(DeprecatedPropValueComponent, {
|
|
183
184
|
color: color
|
|
184
185
|
}));
|
|
185
186
|
const _messageMock$mock$cal = messageMock.mock.calls[0][0],
|
|
@@ -199,7 +200,7 @@ describe('@deprecated', () => {
|
|
|
199
200
|
const color = 'gold';
|
|
200
201
|
class DeprecatedPropValueComponent extends Component {
|
|
201
202
|
render() {
|
|
202
|
-
return
|
|
203
|
+
return ___EmotionJSX("div", null, this.props.color);
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
DeprecatedPropValueComponent.displayName = "DeprecatedPropValueComponent";
|
|
@@ -212,7 +213,7 @@ describe('@deprecated', () => {
|
|
|
212
213
|
DeprecatedPropValueComponent.defaultProps = {
|
|
213
214
|
color: 'red'
|
|
214
215
|
};
|
|
215
|
-
render(
|
|
216
|
+
render(___EmotionJSX(DeprecatedPropValueComponent, {
|
|
216
217
|
color: color
|
|
217
218
|
}));
|
|
218
219
|
const expectedWarningMessage = `The ${color} value for color has been deprecated. Use the FooBar component with the 'baz' prop set instead.`;
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import { Component } from 'react';
|
|
26
26
|
import PropTypes from 'prop-types';
|
|
27
27
|
import { render } from '@testing-library/react';
|
|
28
28
|
import '@testing-library/jest-dom';
|
|
29
29
|
import { experimental } from '../experimental';
|
|
30
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
30
31
|
class TestComponent extends Component {
|
|
31
32
|
render() {
|
|
32
|
-
return
|
|
33
|
+
return ___EmotionJSX("div", null, this.props.qux, " ", this.props.bar);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
TestComponent.displayName = "TestComponent";
|
|
@@ -47,7 +48,7 @@ describe('@experimental', () => {
|
|
|
47
48
|
const ExperimentalComponent = experimental(['bar'])(TestComponent);
|
|
48
49
|
it('should warn when using an experimental prop', () => {
|
|
49
50
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
50
|
-
render(_ExperimentalComponen || (_ExperimentalComponen =
|
|
51
|
+
render(_ExperimentalComponen || (_ExperimentalComponen = ___EmotionJSX(ExperimentalComponent, {
|
|
51
52
|
bar: "Jane"
|
|
52
53
|
})));
|
|
53
54
|
const expectedWarningMessage = 'Warning: [TestComponent] The `bar` prop is experimental and its API could change significantly in a future release.';
|
|
@@ -56,7 +57,7 @@ describe('@experimental', () => {
|
|
|
56
57
|
});
|
|
57
58
|
it('should not output a warning using a non-experimental prop', () => {
|
|
58
59
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
59
|
-
render(_ExperimentalComponen2 || (_ExperimentalComponen2 =
|
|
60
|
+
render(_ExperimentalComponen2 || (_ExperimentalComponen2 = ___EmotionJSX(ExperimentalComponent, {
|
|
60
61
|
qux: "Jane"
|
|
61
62
|
})));
|
|
62
63
|
expect(consoleWarningSpy).not.toHaveBeenCalled();
|
|
@@ -64,7 +65,7 @@ describe('@experimental', () => {
|
|
|
64
65
|
});
|
|
65
66
|
it('should not output a warning for an experimental prop when dangerously ignored', () => {
|
|
66
67
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
67
|
-
render(_ExperimentalComponen3 || (_ExperimentalComponen3 =
|
|
68
|
+
render(_ExperimentalComponen3 || (_ExperimentalComponen3 = ___EmotionJSX(ExperimentalComponent, {
|
|
68
69
|
qux: "Jane",
|
|
69
70
|
__dangerouslyIgnoreExperimentalWarnings: true
|
|
70
71
|
})));
|
|
@@ -77,14 +78,14 @@ describe('@experimental', () => {
|
|
|
77
78
|
const ExperimentalComponent = experimental()(TestComponent);
|
|
78
79
|
it('should warn that the entire component is experimental if no props are supplied', () => {
|
|
79
80
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
80
|
-
render(_ExperimentalComponen4 || (_ExperimentalComponen4 =
|
|
81
|
+
render(_ExperimentalComponen4 || (_ExperimentalComponen4 = ___EmotionJSX(ExperimentalComponent, null)));
|
|
81
82
|
const expectedWarningMessage = 'Warning: [TestComponent] is experimental and its API could change significantly in a future release.';
|
|
82
83
|
expect(consoleWarningSpy).toHaveBeenCalledWith(expect.stringContaining(expectedWarningMessage), expect.any(String));
|
|
83
84
|
consoleWarningSpy.mockRestore();
|
|
84
85
|
});
|
|
85
86
|
it('should not output a warning for a component when dangerously ignored', () => {
|
|
86
87
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
87
|
-
render(_ExperimentalComponen5 || (_ExperimentalComponen5 =
|
|
88
|
+
render(_ExperimentalComponen5 || (_ExperimentalComponen5 = ___EmotionJSX(ExperimentalComponent, {
|
|
88
89
|
__dangerouslyIgnoreExperimentalWarnings: true
|
|
89
90
|
})));
|
|
90
91
|
expect(consoleWarningSpy).not.toHaveBeenCalled();
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import { Component } from 'react';
|
|
26
26
|
import PropTypes from 'prop-types';
|
|
27
27
|
import { render } from '@testing-library/react';
|
|
28
28
|
import '@testing-library/jest-dom';
|
|
29
29
|
import { hack } from '../hack';
|
|
30
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
30
31
|
class TestComponent extends Component {
|
|
31
32
|
render() {
|
|
32
|
-
return
|
|
33
|
+
return ___EmotionJSX("div", null, this.props.qux, " ", this.props.bar);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
TestComponent.displayName = "TestComponent";
|
|
@@ -47,7 +48,7 @@ describe('@hack', () => {
|
|
|
47
48
|
const HackComponent = hack(['bar'])(TestComponent);
|
|
48
49
|
it('should warn when using an hack prop', () => {
|
|
49
50
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
50
|
-
render(_HackComponent || (_HackComponent =
|
|
51
|
+
render(_HackComponent || (_HackComponent = ___EmotionJSX(HackComponent, {
|
|
51
52
|
bar: "Jane"
|
|
52
53
|
})));
|
|
53
54
|
const expectedWarningMessage = 'Warning: [TestComponent] The `bar` prop is a temporary hack and will be removed in a future release.';
|
|
@@ -56,7 +57,7 @@ describe('@hack', () => {
|
|
|
56
57
|
});
|
|
57
58
|
it('should not output a warning using a non-hack prop', () => {
|
|
58
59
|
const consoleWarningSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
59
|
-
render(_HackComponent2 || (_HackComponent2 =
|
|
60
|
+
render(_HackComponent2 || (_HackComponent2 = ___EmotionJSX(HackComponent, {
|
|
60
61
|
qux: "Jane"
|
|
61
62
|
})));
|
|
62
63
|
expect(consoleWarningSpy).not.toHaveBeenCalled();
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import React from 'react';
|
|
26
25
|
import { createChainedFunction } from '@instructure/ui-utils';
|
|
27
26
|
import { render, screen } from '@testing-library/react';
|
|
28
27
|
import '@testing-library/jest-dom';
|
|
29
28
|
import { safeCloneElement } from '../safeCloneElement';
|
|
29
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
30
30
|
describe('safeCloneElement', () => {
|
|
31
31
|
const SafeClone = function ({
|
|
32
32
|
element,
|
|
@@ -38,8 +38,8 @@ describe('safeCloneElement', () => {
|
|
|
38
38
|
it('should preserve refs', () => {
|
|
39
39
|
const origRef = jest.fn();
|
|
40
40
|
const cloneRef = jest.fn();
|
|
41
|
-
render(
|
|
42
|
-
element:
|
|
41
|
+
render(___EmotionJSX(SafeClone, {
|
|
42
|
+
element: ___EmotionJSX("div", {
|
|
43
43
|
ref: origRef
|
|
44
44
|
}),
|
|
45
45
|
props: {
|
|
@@ -52,8 +52,8 @@ describe('safeCloneElement', () => {
|
|
|
52
52
|
it('should preserve event handlers', () => {
|
|
53
53
|
const onClickA = jest.fn();
|
|
54
54
|
const onClickB = jest.fn();
|
|
55
|
-
render(
|
|
56
|
-
element:
|
|
55
|
+
render(___EmotionJSX(SafeClone, {
|
|
56
|
+
element: ___EmotionJSX("button", {
|
|
57
57
|
onClick: onClickA
|
|
58
58
|
}),
|
|
59
59
|
props: {
|
|
@@ -69,8 +69,8 @@ describe('safeCloneElement', () => {
|
|
|
69
69
|
const onClickA = jest.fn();
|
|
70
70
|
const onClickB = jest.fn();
|
|
71
71
|
const onClickC = jest.fn();
|
|
72
|
-
render(
|
|
73
|
-
element:
|
|
72
|
+
render(___EmotionJSX(SafeClone, {
|
|
73
|
+
element: ___EmotionJSX("button", {
|
|
74
74
|
onClick: onClickA
|
|
75
75
|
}),
|
|
76
76
|
props: {
|
package/es/ensureSingleChild.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import { Children } from 'react';
|
|
26
26
|
import { safeCloneElement } from './safeCloneElement';
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -39,12 +39,13 @@ import { safeCloneElement } from './safeCloneElement';
|
|
|
39
39
|
* @param {Object} props - props for child
|
|
40
40
|
* @returns {ReactElement|null} cloned instance for a single child, or children wrapped in a span
|
|
41
41
|
*/
|
|
42
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
42
43
|
function ensureSingleChild(child, props = {}) {
|
|
43
44
|
const childCount = Children.count(child);
|
|
44
45
|
if (childCount === 0) {
|
|
45
46
|
return null;
|
|
46
47
|
} else if (typeof child === 'string' && child.length > 0 || childCount > 1) {
|
|
47
|
-
return
|
|
48
|
+
return ___EmotionJSX("span", props, child);
|
|
48
49
|
} else {
|
|
49
50
|
// TODO: check that we can only end up here if child is ReactElement
|
|
50
51
|
return safeCloneElement(Array.isArray(child) ? child[0] : child, props);
|
|
@@ -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.DeterministicIdContextProvider = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
7
|
var _DeterministicIdContext = require("./DeterministicIdContext");
|
|
8
|
+
var _react = require("@emotion/react");
|
|
10
9
|
/*
|
|
11
10
|
* The MIT License (MIT)
|
|
12
11
|
*
|
|
@@ -48,7 +47,7 @@ const DeterministicIdContextProvider = ({
|
|
|
48
47
|
children,
|
|
49
48
|
instanceCounterMap
|
|
50
49
|
}) => {
|
|
51
|
-
return
|
|
50
|
+
return (0, _react.jsx)(_DeterministicIdContext.DeterministicIdContext.Provider, {
|
|
52
51
|
value: instanceCounterMap
|
|
53
52
|
}, children);
|
|
54
53
|
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.withDeterministicId = exports.default = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
|
11
12
|
var _DeterministicIdContext = require("./DeterministicIdContext");
|
|
12
13
|
var _decorator = require("@instructure/ui-decorator/lib/decorator.js");
|
|
13
14
|
var _generateId = require("@instructure/ui-utils/lib/generateId.js");
|
|
14
15
|
var _console = require("@instructure/console");
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
15
17
|
/*
|
|
16
18
|
* The MIT License (MIT)
|
|
17
19
|
*
|
|
@@ -52,7 +54,7 @@ const withDeterministicId = exports.withDeterministicId = (0, _decorator.decorat
|
|
|
52
54
|
if (props.deterministicId) {
|
|
53
55
|
(0, _console.warn)(false, `Manually passing the "deterministicId" property is not allowed on the ${componentName} component.\n`, props.deterministicId);
|
|
54
56
|
}
|
|
55
|
-
return
|
|
57
|
+
return (0, _react2.jsx)(ComposedComponent, (0, _extends2.default)({
|
|
56
58
|
ref: ref,
|
|
57
59
|
deterministicId: deterministicId
|
|
58
60
|
}, props));
|