@instructure/ui-source-code-editor 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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/SourceCodeEditor/v1/SearchPanel.js +6 -11
- package/es/SourceCodeEditor/v1/index.js +104 -94
- package/es/SourceCodeEditor/v1/styles.js +8 -6
- package/es/SourceCodeEditor/v1/theme.js +17 -16
- package/es/SourceCodeEditor/v2/SearchPanel.js +6 -11
- package/es/SourceCodeEditor/v2/index.js +104 -94
- package/es/SourceCodeEditor/v2/styles.js +8 -6
- package/lib/SourceCodeEditor/v1/SearchPanel.js +9 -14
- package/lib/SourceCodeEditor/v1/index.js +104 -94
- package/lib/SourceCodeEditor/v1/styles.js +8 -6
- package/lib/SourceCodeEditor/v1/theme.js +17 -16
- package/lib/SourceCodeEditor/v2/SearchPanel.js +9 -14
- package/lib/SourceCodeEditor/v2/index.js +104 -94
- package/lib/SourceCodeEditor/v2/styles.js +8 -6
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.SourceCodeEditor = void 0;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
8
|
var _react = require("react");
|
|
10
9
|
var _deepEqual = require("@instructure/ui-utils/lib/deepEqual.js");
|
|
11
10
|
var _state = require("@codemirror/state");
|
|
@@ -35,8 +34,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
35
34
|
var _customKeybinding = require("./customKeybinding");
|
|
36
35
|
var _props = require("./props");
|
|
37
36
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
38
|
-
|
|
39
|
-
var _dec, _dec2, _dec3, _class, _SourceCodeEditor;
|
|
37
|
+
var _dec, _dec2, _dec3, _class;
|
|
40
38
|
/*
|
|
41
39
|
* The MIT License (MIT)
|
|
42
40
|
*
|
|
@@ -66,7 +64,51 @@ var _dec, _dec2, _dec3, _class, _SourceCodeEditor;
|
|
|
66
64
|
category: components
|
|
67
65
|
---
|
|
68
66
|
**/
|
|
69
|
-
let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec3 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec(_class = _dec2(_class = _dec3(_class =
|
|
67
|
+
let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec3 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec(_class = _dec2(_class = _dec3(_class = class SourceCodeEditor extends _react.Component {
|
|
68
|
+
static displayName = "SourceCodeEditor";
|
|
69
|
+
static componentId = 'SourceCodeEditor';
|
|
70
|
+
static allowedProps = _props.allowedProps;
|
|
71
|
+
static defaultProps = {
|
|
72
|
+
language: 'jsx',
|
|
73
|
+
readOnly: false,
|
|
74
|
+
editable: true,
|
|
75
|
+
lineNumbers: false,
|
|
76
|
+
foldGutter: false,
|
|
77
|
+
highlightActiveLine: false,
|
|
78
|
+
highlightActiveLineGutter: false,
|
|
79
|
+
lineWrapping: false,
|
|
80
|
+
autofocus: false,
|
|
81
|
+
spellcheck: false,
|
|
82
|
+
rtlMoveVisually: true,
|
|
83
|
+
indentOnLoad: false,
|
|
84
|
+
indentWithTab: false,
|
|
85
|
+
defaultValue: '',
|
|
86
|
+
height: 'auto'
|
|
87
|
+
};
|
|
88
|
+
_id;
|
|
89
|
+
ref = null;
|
|
90
|
+
_containerRef;
|
|
91
|
+
_editorView;
|
|
92
|
+
_raf = [];
|
|
93
|
+
_newSelectionAfterValueChange;
|
|
94
|
+
handleRef = el => {
|
|
95
|
+
const {
|
|
96
|
+
elementRef
|
|
97
|
+
} = this.props;
|
|
98
|
+
this.ref = el;
|
|
99
|
+
if (typeof elementRef === 'function') {
|
|
100
|
+
elementRef(el);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
handleContainerRef = el => {
|
|
104
|
+
const {
|
|
105
|
+
containerRef
|
|
106
|
+
} = this.props;
|
|
107
|
+
this._containerRef = el || undefined;
|
|
108
|
+
if (typeof containerRef === 'function') {
|
|
109
|
+
containerRef(el);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
70
112
|
addAnimationFrame(callback) {
|
|
71
113
|
if (typeof callback === 'function') {
|
|
72
114
|
this._raf.push((0, _requestAnimationFrame.requestAnimationFrame)(callback));
|
|
@@ -78,21 +120,18 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
78
120
|
}
|
|
79
121
|
focus() {
|
|
80
122
|
this.addAnimationFrame(() => {
|
|
81
|
-
|
|
82
|
-
(_this$_editorView = this._editorView) === null || _this$_editorView === void 0 ? void 0 : _this$_editorView.focus();
|
|
123
|
+
this._editorView?.focus();
|
|
83
124
|
});
|
|
84
125
|
}
|
|
85
126
|
get hasFocus() {
|
|
86
|
-
|
|
87
|
-
return (_this$_editorView2 = this._editorView) === null || _this$_editorView2 === void 0 ? void 0 : _this$_editorView2.hasFocus;
|
|
127
|
+
return this._editorView?.hasFocus;
|
|
88
128
|
}
|
|
89
129
|
selectAll() {
|
|
90
130
|
if (this._editorView) {
|
|
91
131
|
this.addAnimationFrame(() => {
|
|
92
|
-
var _this$currentDocValue;
|
|
93
132
|
this.dispatchViewSelection({
|
|
94
133
|
anchor: 0,
|
|
95
|
-
head:
|
|
134
|
+
head: this.currentDocValue?.length
|
|
96
135
|
});
|
|
97
136
|
});
|
|
98
137
|
}
|
|
@@ -113,8 +152,7 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
113
152
|
(0, _commands.indentSelection)({
|
|
114
153
|
state: this._editorView.state,
|
|
115
154
|
dispatch: transaction => {
|
|
116
|
-
|
|
117
|
-
(_this$_editorView3 = this._editorView) === null || _this$_editorView3 === void 0 ? void 0 : _this$_editorView3.update([transaction]);
|
|
155
|
+
this._editorView?.update([transaction]);
|
|
118
156
|
}
|
|
119
157
|
});
|
|
120
158
|
}
|
|
@@ -156,10 +194,10 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
156
194
|
changes,
|
|
157
195
|
...(selection ? {
|
|
158
196
|
selection
|
|
159
|
-
} :
|
|
197
|
+
} : undefined),
|
|
160
198
|
...(userEvent ? {
|
|
161
199
|
userEvent
|
|
162
|
-
} :
|
|
200
|
+
} : undefined)
|
|
163
201
|
});
|
|
164
202
|
}
|
|
165
203
|
|
|
@@ -171,8 +209,7 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
171
209
|
});
|
|
172
210
|
}
|
|
173
211
|
get currentDocValue() {
|
|
174
|
-
|
|
175
|
-
return (_this$_editorView4 = this._editorView) === null || _this$_editorView4 === void 0 ? void 0 : _this$_editorView4.state.doc;
|
|
212
|
+
return this._editorView?.state.doc;
|
|
176
213
|
}
|
|
177
214
|
|
|
178
215
|
// when value is passed, the editor should be controlled
|
|
@@ -181,44 +218,16 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
181
218
|
}
|
|
182
219
|
constructor(props) {
|
|
183
220
|
super(props);
|
|
184
|
-
this._id = void 0;
|
|
185
|
-
this.ref = null;
|
|
186
|
-
this._containerRef = void 0;
|
|
187
|
-
this._editorView = void 0;
|
|
188
|
-
this._raf = [];
|
|
189
|
-
this._newSelectionAfterValueChange = void 0;
|
|
190
|
-
this.handleRef = el => {
|
|
191
|
-
const elementRef = this.props.elementRef;
|
|
192
|
-
this.ref = el;
|
|
193
|
-
if (typeof elementRef === 'function') {
|
|
194
|
-
elementRef(el);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
this.handleContainerRef = el => {
|
|
198
|
-
const containerRef = this.props.containerRef;
|
|
199
|
-
this._containerRef = el || void 0;
|
|
200
|
-
if (typeof containerRef === 'function') {
|
|
201
|
-
containerRef(el);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
this.assignAriaLabel = () => {
|
|
205
|
-
if (this._containerRef) {
|
|
206
|
-
const editorDiv = this._containerRef.querySelector('[role="textbox"]');
|
|
207
|
-
if (editorDiv) {
|
|
208
|
-
editorDiv.setAttribute('aria-labelledby', `${this._id}`);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
221
|
this._id = props.deterministicId();
|
|
213
222
|
}
|
|
214
223
|
componentDidMount() {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
const {
|
|
225
|
+
value,
|
|
226
|
+
defaultValue,
|
|
227
|
+
autofocus,
|
|
228
|
+
indentOnLoad
|
|
229
|
+
} = this.props;
|
|
230
|
+
this.props.makeStyles?.();
|
|
222
231
|
const state = _state.EditorState.create({
|
|
223
232
|
doc: value || defaultValue,
|
|
224
233
|
extensions: this.extensions
|
|
@@ -244,13 +253,11 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
244
253
|
this.assignAriaLabel();
|
|
245
254
|
}
|
|
246
255
|
componentWillUnmount() {
|
|
247
|
-
|
|
248
|
-
(_this$_editorView5 = this._editorView) === null || _this$_editorView5 === void 0 ? void 0 : _this$_editorView5.destroy();
|
|
256
|
+
this._editorView?.destroy();
|
|
249
257
|
this.cancelAnimationFrames();
|
|
250
258
|
}
|
|
251
259
|
componentDidUpdate(prevProps) {
|
|
252
|
-
|
|
253
|
-
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
260
|
+
this.props.makeStyles?.();
|
|
254
261
|
if (this._editorView) {
|
|
255
262
|
if (this.props.value !== prevProps.value) {
|
|
256
263
|
this.refreshEditorValue();
|
|
@@ -338,7 +345,9 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
338
345
|
return keymaps;
|
|
339
346
|
}
|
|
340
347
|
get commandKeybinding() {
|
|
341
|
-
const
|
|
348
|
+
const {
|
|
349
|
+
rtlMoveVisually
|
|
350
|
+
} = this.props;
|
|
342
351
|
if (this.direction === 'rtl' && !rtlMoveVisually) {
|
|
343
352
|
const overrideableKeys = _customKeybinding.rtlHorizontalArrowKeymap.map(binding => binding.key ? binding.key : binding.mac ? binding.mac : binding);
|
|
344
353
|
// we have to remove the binding we want to override from the original,
|
|
@@ -349,12 +358,14 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
349
358
|
return _commands.defaultKeymap;
|
|
350
359
|
}
|
|
351
360
|
get themeExtension() {
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
361
|
+
const {
|
|
362
|
+
styles
|
|
363
|
+
} = this.props;
|
|
364
|
+
if (!styles?.theme || !styles.highlightStyle) {
|
|
365
|
+
return undefined;
|
|
355
366
|
}
|
|
356
|
-
const theme = _view.EditorView.theme(styles
|
|
357
|
-
const highlightStyle = (0, _language.syntaxHighlighting)(_language.HighlightStyle.define(styles
|
|
367
|
+
const theme = _view.EditorView.theme(styles?.theme);
|
|
368
|
+
const highlightStyle = (0, _language.syntaxHighlighting)(_language.HighlightStyle.define(styles?.highlightStyle));
|
|
358
369
|
|
|
359
370
|
// see notes in props.ts
|
|
360
371
|
// if (darkTheme) {
|
|
@@ -365,7 +376,9 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
365
376
|
return [theme, highlightStyle];
|
|
366
377
|
}
|
|
367
378
|
get languageExtension() {
|
|
368
|
-
const
|
|
379
|
+
const {
|
|
380
|
+
language
|
|
381
|
+
} = this.props;
|
|
369
382
|
switch (language) {
|
|
370
383
|
case 'json':
|
|
371
384
|
return (0, _langJson.json)();
|
|
@@ -401,9 +414,10 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
401
414
|
}
|
|
402
415
|
}
|
|
403
416
|
callOnChangeHandler(newValue) {
|
|
404
|
-
const
|
|
405
|
-
onChange
|
|
406
|
-
value
|
|
417
|
+
const {
|
|
418
|
+
onChange,
|
|
419
|
+
value
|
|
420
|
+
} = this.props;
|
|
407
421
|
this.addAnimationFrame(() => {
|
|
408
422
|
if (typeof onChange === 'function' && newValue !== value) {
|
|
409
423
|
onChange(newValue);
|
|
@@ -436,9 +450,10 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
436
450
|
});
|
|
437
451
|
}
|
|
438
452
|
get focusListenerExtension() {
|
|
439
|
-
const
|
|
440
|
-
onFocus
|
|
441
|
-
onBlur
|
|
453
|
+
const {
|
|
454
|
+
onFocus,
|
|
455
|
+
onBlur
|
|
456
|
+
} = this.props;
|
|
442
457
|
return _view.EditorView.updateListener.of(update => {
|
|
443
458
|
if (update.focusChanged && this._editorView) {
|
|
444
459
|
if (this.hasFocus) {
|
|
@@ -472,7 +487,9 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
472
487
|
}
|
|
473
488
|
refreshEditorValue() {
|
|
474
489
|
if (!this._editorView) return;
|
|
475
|
-
const
|
|
490
|
+
const {
|
|
491
|
+
value
|
|
492
|
+
} = this.props;
|
|
476
493
|
const currentValue = this._editorView.state.doc.toString();
|
|
477
494
|
if (typeof value !== 'undefined' && currentValue !== value) {
|
|
478
495
|
let userEvent;
|
|
@@ -494,49 +511,42 @@ let SourceCodeEditor = exports.SourceCodeEditor = (_dec = (0, _withDeterministic
|
|
|
494
511
|
selection: this._newSelectionAfterValueChange,
|
|
495
512
|
userEvent: userEvent
|
|
496
513
|
});
|
|
497
|
-
this._newSelectionAfterValueChange =
|
|
514
|
+
this._newSelectionAfterValueChange = undefined;
|
|
498
515
|
}
|
|
499
516
|
if (this.props.indentOnLoad) {
|
|
500
517
|
this.indentAll();
|
|
501
518
|
}
|
|
502
519
|
}
|
|
520
|
+
assignAriaLabel = () => {
|
|
521
|
+
if (this._containerRef) {
|
|
522
|
+
const editorDiv = this._containerRef.querySelector('[role="textbox"]');
|
|
523
|
+
if (editorDiv) {
|
|
524
|
+
editorDiv.setAttribute('aria-labelledby', `${this._id}`);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
};
|
|
503
528
|
render() {
|
|
504
|
-
const
|
|
505
|
-
label
|
|
506
|
-
styles
|
|
507
|
-
restProps
|
|
529
|
+
const {
|
|
530
|
+
label,
|
|
531
|
+
styles,
|
|
532
|
+
...restProps
|
|
533
|
+
} = this.props;
|
|
508
534
|
return (0, _jsxRuntime.jsx)("div", {
|
|
509
535
|
"data-cid": "SourceCodeEditor",
|
|
510
536
|
ref: this.handleRef,
|
|
511
|
-
css: styles
|
|
537
|
+
css: styles?.codeEditor,
|
|
512
538
|
...(0, _passthroughProps.passthroughProps)((0, _omitProps.omitProps)(restProps, SourceCodeEditor.allowedProps)),
|
|
513
539
|
children: (0, _jsxRuntime.jsxs)("label", {
|
|
514
|
-
css: styles
|
|
540
|
+
css: styles?.label,
|
|
515
541
|
id: this._id,
|
|
516
542
|
children: [(0, _jsxRuntime.jsx)(_ScreenReaderContent.ScreenReaderContent, {
|
|
517
543
|
children: label
|
|
518
544
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
519
545
|
ref: this.handleContainerRef,
|
|
520
|
-
css: styles
|
|
546
|
+
css: styles?.codeEditorContainer
|
|
521
547
|
})]
|
|
522
548
|
})
|
|
523
549
|
});
|
|
524
550
|
}
|
|
525
|
-
}
|
|
526
|
-
language: 'jsx',
|
|
527
|
-
readOnly: false,
|
|
528
|
-
editable: true,
|
|
529
|
-
lineNumbers: false,
|
|
530
|
-
foldGutter: false,
|
|
531
|
-
highlightActiveLine: false,
|
|
532
|
-
highlightActiveLineGutter: false,
|
|
533
|
-
lineWrapping: false,
|
|
534
|
-
autofocus: false,
|
|
535
|
-
spellcheck: false,
|
|
536
|
-
rtlMoveVisually: true,
|
|
537
|
-
indentOnLoad: false,
|
|
538
|
-
indentWithTab: false,
|
|
539
|
-
defaultValue: '',
|
|
540
|
-
height: 'auto'
|
|
541
|
-
}, _SourceCodeEditor)) || _class) || _class) || _class);
|
|
551
|
+
}) || _class) || _class) || _class);
|
|
542
552
|
var _default = exports.default = SourceCodeEditor;
|
|
@@ -39,9 +39,11 @@ var _highlight = require("@lezer/highlight");
|
|
|
39
39
|
* @return {Object} The final style object, which will be used in the component
|
|
40
40
|
*/
|
|
41
41
|
const generateStyle = (componentTheme, props) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const {
|
|
43
|
+
attachment,
|
|
44
|
+
height,
|
|
45
|
+
width
|
|
46
|
+
} = props;
|
|
45
47
|
const attachmentBorderRadius = {
|
|
46
48
|
top: {
|
|
47
49
|
borderBottomLeftRadius: 0,
|
|
@@ -81,9 +83,9 @@ const generateStyle = (componentTheme, props) => {
|
|
|
81
83
|
label: 'codeEditorContainer',
|
|
82
84
|
height: '100%',
|
|
83
85
|
width: '100%',
|
|
84
|
-
borderColor: componentTheme
|
|
86
|
+
borderColor: componentTheme?.borderColor,
|
|
85
87
|
borderStyle: 'solid',
|
|
86
|
-
borderWidth: componentTheme
|
|
88
|
+
borderWidth: componentTheme?.borderWidth,
|
|
87
89
|
borderRadius: componentTheme.borderRadius,
|
|
88
90
|
marginBottom: '1rem',
|
|
89
91
|
...(attachment && {
|
|
@@ -117,7 +119,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
117
119
|
// are, for some reason, drawn behind the element content, which
|
|
118
120
|
// will cause things like the active line background to cover
|
|
119
121
|
// the outline (#297).
|
|
120
|
-
outline: `${componentTheme
|
|
122
|
+
outline: `${componentTheme?.borderWidth} solid ${componentTheme?.focusBorderColor}`
|
|
121
123
|
},
|
|
122
124
|
'.cm-content': {
|
|
123
125
|
padding: `${componentTheme.verticalPadding} 0`
|
|
@@ -34,23 +34,24 @@ exports.default = void 0;
|
|
|
34
34
|
* @return {Object} The final theme object with the overrides and component variables
|
|
35
35
|
*/
|
|
36
36
|
const generateComponentTheme = theme => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
borders
|
|
40
|
-
typography
|
|
41
|
-
spacing
|
|
37
|
+
const {
|
|
38
|
+
colors,
|
|
39
|
+
borders,
|
|
40
|
+
typography,
|
|
41
|
+
spacing
|
|
42
|
+
} = theme;
|
|
42
43
|
const componentVariables = {
|
|
43
|
-
fontFamily: typography
|
|
44
|
-
fontSize: typography
|
|
45
|
-
background: colors
|
|
46
|
-
color: colors
|
|
47
|
-
gutterBackground: colors
|
|
48
|
-
borderWidth: borders
|
|
49
|
-
borderColor: colors
|
|
50
|
-
borderRadius: borders
|
|
51
|
-
focusBorderColor: colors
|
|
52
|
-
horizontalPadding: spacing
|
|
53
|
-
verticalPadding: spacing
|
|
44
|
+
fontFamily: typography?.fontFamilyMonospace,
|
|
45
|
+
fontSize: typography?.fontSizeSmall,
|
|
46
|
+
background: colors?.contrasts?.white1010,
|
|
47
|
+
color: colors?.contrasts?.grey125125,
|
|
48
|
+
gutterBackground: colors?.contrasts?.grey1111,
|
|
49
|
+
borderWidth: borders?.widthSmall,
|
|
50
|
+
borderColor: colors?.contrasts?.grey3045,
|
|
51
|
+
borderRadius: borders?.radiusMedium,
|
|
52
|
+
focusBorderColor: colors?.contrasts?.blue4570,
|
|
53
|
+
horizontalPadding: spacing?.xSmall,
|
|
54
|
+
verticalPadding: spacing?.xxSmall
|
|
54
55
|
};
|
|
55
56
|
return {
|
|
56
57
|
...componentVariables
|
|
@@ -1,21 +1,18 @@
|
|
|
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 = customSearch;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
7
|
var _react = require("react");
|
|
10
8
|
var _search = require("@codemirror/search");
|
|
11
9
|
var _latest = require("@instructure/ui-text-input/latest");
|
|
12
10
|
var _latest2 = require("@instructure/ui-buttons/latest");
|
|
13
11
|
var _IconArrowOpenDownLine = require("@instructure/ui-icons/lib/generated/IconArrowOpenDownLine.js");
|
|
14
|
-
var
|
|
15
|
-
var
|
|
12
|
+
var _IconArrowOpenUpLine = require("@instructure/ui-icons/lib/generated/IconArrowOpenUpLine.js");
|
|
13
|
+
var _IconSearchLine = require("@instructure/ui-icons/lib/generated/IconSearchLine.js");
|
|
16
14
|
var _client = require("react-dom/client");
|
|
17
15
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
18
|
-
var _IconSearchLine, _IconArrowOpenDownLin, _IconArrowOpenUpLine;
|
|
19
16
|
/*
|
|
20
17
|
* The MIT License (MIT)
|
|
21
18
|
*
|
|
@@ -39,14 +36,12 @@ var _IconSearchLine, _IconArrowOpenDownLin, _IconArrowOpenUpLine;
|
|
|
39
36
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
40
37
|
* SOFTWARE.
|
|
41
38
|
*/
|
|
39
|
+
|
|
42
40
|
function SearchPanel({
|
|
43
41
|
view,
|
|
44
42
|
searchConfig
|
|
45
43
|
}) {
|
|
46
|
-
const
|
|
47
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
48
|
-
searchQueryStr = _useState2[0],
|
|
49
|
-
setSearchQueryStr = _useState2[1];
|
|
44
|
+
const [searchQueryStr, setSearchQueryStr] = (0, _react.useState)('');
|
|
50
45
|
const handleChange = (_e, value) => {
|
|
51
46
|
setSearchQueryStr(value);
|
|
52
47
|
handleHighlightSearch(value);
|
|
@@ -77,7 +72,7 @@ function SearchPanel({
|
|
|
77
72
|
return (0, _jsxRuntime.jsx)(_latest.TextInput, {
|
|
78
73
|
renderLabel: "",
|
|
79
74
|
inputRef: r => {
|
|
80
|
-
setTimeout(() => r
|
|
75
|
+
setTimeout(() => r?.focus(), 0);
|
|
81
76
|
},
|
|
82
77
|
size: "small",
|
|
83
78
|
display: "inline-block",
|
|
@@ -86,9 +81,9 @@ function SearchPanel({
|
|
|
86
81
|
onChange: handleChange,
|
|
87
82
|
onKeyDown: handleKeyDown,
|
|
88
83
|
onKeyUp: handleKeyUp,
|
|
89
|
-
renderBeforeInput:
|
|
84
|
+
renderBeforeInput: (0, _jsxRuntime.jsx)(_IconSearchLine.IconSearchLine, {
|
|
90
85
|
size: "x-small"
|
|
91
|
-
})
|
|
86
|
+
}),
|
|
92
87
|
renderAfterInput: (0, _jsxRuntime.jsxs)("span", {
|
|
93
88
|
children: [(0, _jsxRuntime.jsx)(_latest2.IconButton, {
|
|
94
89
|
size: "small",
|
|
@@ -96,14 +91,14 @@ function SearchPanel({
|
|
|
96
91
|
withBackground: false,
|
|
97
92
|
onClick: handleFindNext,
|
|
98
93
|
screenReaderLabel: searchConfig.nextResultLabel,
|
|
99
|
-
children:
|
|
94
|
+
children: (0, _jsxRuntime.jsx)(_IconArrowOpenDownLine.IconArrowOpenDownLine, {})
|
|
100
95
|
}), (0, _jsxRuntime.jsx)(_latest2.IconButton, {
|
|
101
96
|
size: "small",
|
|
102
97
|
withBorder: false,
|
|
103
98
|
withBackground: false,
|
|
104
99
|
onClick: handleFindPrev,
|
|
105
100
|
screenReaderLabel: searchConfig.prevResultLabel,
|
|
106
|
-
children:
|
|
101
|
+
children: (0, _jsxRuntime.jsx)(_IconArrowOpenUpLine.IconArrowOpenUpLine, {})
|
|
107
102
|
})]
|
|
108
103
|
})
|
|
109
104
|
});
|