@instructure/ui-source-code-editor 8.53.3-snapshot-1 → 8.53.3-snapshot-5

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,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-snapshot-1](https://github.com/instructure/instructure-ui/compare/v8.53.2...v8.53.3-snapshot-1) (2024-02-20)
6
+ ## [8.53.3-snapshot-5](https://github.com/instructure/instructure-ui/compare/v8.53.2...v8.53.3-snapshot-5) (2024-02-21)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-source-code-editor
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-source-code-editor:** make search panel work with older react versions ([a9b1f1a](https://github.com/instructure/instructure-ui/commit/a9b1f1ab5dd620cc93a59909d395387537e16895))
9
12
 
10
13
 
11
14
 
@@ -29,12 +29,7 @@ import { setSearchQuery, search, findNext, findPrevious, SearchQuery, closeSearc
29
29
  import { TextInput } from '@instructure/ui-text-input';
30
30
  import { IconButton } from '@instructure/ui-buttons';
31
31
  import { IconArrowOpenDownLine, IconArrowOpenUpLine, IconSearchLine } from '@instructure/ui-icons';
32
- let reactdom;
33
- try {
34
- reactdom = require('react-dom/client');
35
- } catch {
36
- reactdom = require('react-dom');
37
- }
32
+ import ReactDOM from 'react-dom';
38
33
  function SearchPanel({
39
34
  view,
40
35
  searchConfig
@@ -100,16 +95,21 @@ function SearchPanel({
100
95
  export default function customSearch(searchConfig) {
101
96
  return searchConfig ? search({
102
97
  createPanel: view => {
98
+ var _SearchPanel;
103
99
  const dom = document.createElement('div');
104
100
  dom.style.padding = '8px';
105
- if ('createRoot' in reactdom) {
106
- const root = reactdom.createRoot(dom);
107
- root.render( /*#__PURE__*/React.createElement(SearchPanel, {
108
- view: view,
109
- searchConfig: searchConfig
110
- }));
101
+ const reactVersionMajor = Number(React.version.split('.')[0]);
102
+ if (reactVersionMajor >= 18) {
103
+ // webpack tries to evaluate imports compile time which would lead to an error on older react versions
104
+ import( /* webpackIgnore: true */'react-dom/client').then(r => {
105
+ const root = r.createRoot(dom);
106
+ root.render(_SearchPanel || (_SearchPanel = /*#__PURE__*/React.createElement(SearchPanel, {
107
+ view: view,
108
+ searchConfig: searchConfig
109
+ })));
110
+ }).catch(e => {});
111
111
  } else {
112
- reactdom.render( /*#__PURE__*/React.createElement(SearchPanel, {
112
+ ReactDOM.render( /*#__PURE__*/React.createElement(SearchPanel, {
113
113
  view: view,
114
114
  searchConfig: searchConfig
115
115
  }), dom);
@@ -1,19 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireWildcard3 = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = customSearch;
9
+ var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime/helpers/interopRequireWildcard"));
9
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _react = _interopRequireWildcard(require("react"));
11
+ var _react = _interopRequireWildcard3(require("react"));
11
12
  var _search = require("@codemirror/search");
12
13
  var _TextInput = require("@instructure/ui-text-input/lib/TextInput");
13
14
  var _IconButton = require("@instructure/ui-buttons/lib/IconButton");
14
15
  var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/IconArrowOpenDownLine.js");
15
16
  var _IconArrowOpenUpLine2 = require("@instructure/ui-icons/lib/IconArrowOpenUpLine.js");
16
17
  var _IconSearchLine2 = require("@instructure/ui-icons/lib/IconSearchLine.js");
18
+ var _reactDom = _interopRequireDefault(require("react-dom"));
17
19
  var _IconSearchLine, _IconArrowOpenDownLin, _IconArrowOpenUpLine;
18
20
  /*
19
21
  * The MIT License (MIT)
@@ -38,12 +40,6 @@ var _IconSearchLine, _IconArrowOpenDownLin, _IconArrowOpenUpLine;
38
40
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
41
  * SOFTWARE.
40
42
  */
41
- let reactdom;
42
- try {
43
- reactdom = require('react-dom/client');
44
- } catch {
45
- reactdom = require('react-dom');
46
- }
47
43
  function SearchPanel({
48
44
  view,
49
45
  searchConfig
@@ -109,16 +105,21 @@ function SearchPanel({
109
105
  function customSearch(searchConfig) {
110
106
  return searchConfig ? (0, _search.search)({
111
107
  createPanel: view => {
108
+ var _SearchPanel;
112
109
  const dom = document.createElement('div');
113
110
  dom.style.padding = '8px';
114
- if ('createRoot' in reactdom) {
115
- const root = reactdom.createRoot(dom);
116
- root.render( /*#__PURE__*/_react.default.createElement(SearchPanel, {
117
- view: view,
118
- searchConfig: searchConfig
119
- }));
111
+ const reactVersionMajor = Number(_react.default.version.split('.')[0]);
112
+ if (reactVersionMajor >= 18) {
113
+ // webpack tries to evaluate imports compile time which would lead to an error on older react versions
114
+ Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require( /* webpackIgnore: true */'react-dom/client'))).then(r => {
115
+ const root = r.createRoot(dom);
116
+ root.render(_SearchPanel || (_SearchPanel = /*#__PURE__*/_react.default.createElement(SearchPanel, {
117
+ view: view,
118
+ searchConfig: searchConfig
119
+ })));
120
+ }).catch(e => {});
120
121
  } else {
121
- reactdom.render( /*#__PURE__*/_react.default.createElement(SearchPanel, {
122
+ _reactDom.default.render( /*#__PURE__*/_react.default.createElement(SearchPanel, {
122
123
  view: view,
123
124
  searchConfig: searchConfig
124
125
  }), dom);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-source-code-editor",
3
- "version": "8.53.3-snapshot-1",
3
+ "version": "8.53.3-snapshot-5",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "8.53.3-snapshot-1",
27
- "@instructure/ui-test-queries": "8.53.3-snapshot-1",
28
- "@instructure/ui-test-utils": "8.53.3-snapshot-1",
26
+ "@instructure/ui-babel-preset": "8.53.3-snapshot-5",
27
+ "@instructure/ui-test-queries": "8.53.3-snapshot-5",
28
+ "@instructure/ui-test-utils": "8.53.3-snapshot-5",
29
29
  "@testing-library/jest-dom": "^6.1.4",
30
30
  "@testing-library/react": "^14.0.0"
31
31
  },
@@ -44,20 +44,20 @@
44
44
  "@codemirror/search": "^6.5.4",
45
45
  "@codemirror/state": "^6.3.0",
46
46
  "@codemirror/view": "^6.21.3",
47
- "@instructure/emotion": "8.53.3-snapshot-1",
48
- "@instructure/shared-types": "8.53.3-snapshot-1",
49
- "@instructure/ui-a11y-content": "8.53.3-snapshot-1",
50
- "@instructure/ui-buttons": "8.53.3-snapshot-1",
51
- "@instructure/ui-dom-utils": "8.53.3-snapshot-1",
52
- "@instructure/ui-i18n": "8.53.3-snapshot-1",
53
- "@instructure/ui-icons": "8.53.3-snapshot-1",
54
- "@instructure/ui-prop-types": "8.53.3-snapshot-1",
55
- "@instructure/ui-react-utils": "8.53.3-snapshot-1",
56
- "@instructure/ui-test-locator": "8.53.3-snapshot-1",
57
- "@instructure/ui-testable": "8.53.3-snapshot-1",
58
- "@instructure/ui-text-input": "8.53.3-snapshot-1",
59
- "@instructure/ui-themes": "8.53.3-snapshot-1",
60
- "@instructure/ui-utils": "8.53.3-snapshot-1",
47
+ "@instructure/emotion": "8.53.3-snapshot-5",
48
+ "@instructure/shared-types": "8.53.3-snapshot-5",
49
+ "@instructure/ui-a11y-content": "8.53.3-snapshot-5",
50
+ "@instructure/ui-buttons": "8.53.3-snapshot-5",
51
+ "@instructure/ui-dom-utils": "8.53.3-snapshot-5",
52
+ "@instructure/ui-i18n": "8.53.3-snapshot-5",
53
+ "@instructure/ui-icons": "8.53.3-snapshot-5",
54
+ "@instructure/ui-prop-types": "8.53.3-snapshot-5",
55
+ "@instructure/ui-react-utils": "8.53.3-snapshot-5",
56
+ "@instructure/ui-test-locator": "8.53.3-snapshot-5",
57
+ "@instructure/ui-testable": "8.53.3-snapshot-5",
58
+ "@instructure/ui-text-input": "8.53.3-snapshot-5",
59
+ "@instructure/ui-themes": "8.53.3-snapshot-5",
60
+ "@instructure/ui-utils": "8.53.3-snapshot-5",
61
61
  "@lezer/highlight": "1.1.6",
62
62
  "prop-types": "^15.8.1"
63
63
  },
@@ -40,12 +40,7 @@ import {
40
40
  IconSearchLine
41
41
  } from '@instructure/ui-icons'
42
42
 
43
- let reactdom: any
44
- try {
45
- reactdom = require('react-dom/client')
46
- } catch {
47
- reactdom = require('react-dom')
48
- }
43
+ import ReactDOM from 'react-dom'
49
44
 
50
45
  export type SearchConfig = {
51
46
  placeholder: string
@@ -144,11 +139,21 @@ export default function customSearch(searchConfig: SearchConfig | undefined) {
144
139
  createPanel: (view) => {
145
140
  const dom = document.createElement('div')
146
141
  dom.style.padding = '8px'
147
- if ('createRoot' in reactdom) {
148
- const root = reactdom.createRoot(dom)
149
- root.render(<SearchPanel view={view} searchConfig={searchConfig} />)
142
+ const reactVersionMajor = Number(React.version.split('.')[0])
143
+ if (reactVersionMajor >= 18) {
144
+ // webpack tries to evaluate imports compile time which would lead to an error on older react versions
145
+ import(/* webpackIgnore: true */ 'react-dom/client')
146
+ .then((r) => {
147
+ const root = r.createRoot(dom)
148
+ root.render(
149
+ <SearchPanel view={view} searchConfig={searchConfig} />
150
+ )
151
+ })
152
+ .catch((e) => {
153
+ console.error(e)
154
+ })
150
155
  } else {
151
- reactdom.render(
156
+ ReactDOM.render(
152
157
  <SearchPanel view={view} searchConfig={searchConfig} />,
153
158
  dom
154
159
  )