@elliemae/ds-codeeditor 3.0.0-next.2 → 3.0.0-next.6
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/dist/cjs/DSCodeEditor.js +131 -0
- package/dist/cjs/DSCodeEditor.js.map +7 -0
- package/dist/cjs/components/DSCodeEditorForm.js +166 -0
- package/dist/cjs/components/DSCodeEditorForm.js.map +7 -0
- package/dist/cjs/components/DSCodeEditorImpl.js +98 -0
- package/dist/cjs/components/DSCodeEditorImpl.js.map +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/DSCodeEditor.js +102 -0
- package/dist/esm/DSCodeEditor.js.map +7 -0
- package/dist/esm/components/DSCodeEditorForm.js +137 -0
- package/dist/esm/components/DSCodeEditorForm.js.map +7 -0
- package/dist/esm/components/DSCodeEditorImpl.js +69 -0
- package/dist/esm/components/DSCodeEditorImpl.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/package.json +35 -26
- package/cjs/DSCodeEditor.js +0 -127
- package/cjs/components/DSCodeEditorForm.js +0 -189
- package/cjs/components/DSCodeEditorImpl.js +0 -88
- package/cjs/index.js +0 -10
- package/esm/DSCodeEditor.js +0 -116
- package/esm/components/DSCodeEditorForm.js +0 -182
- package/esm/components/DSCodeEditorImpl.js +0 -79
- package/esm/index.js +0 -1
- package/types/DSCodeEditor.d.ts +0 -127
- package/types/components/DSCodeEditorForm.d.ts +0 -7
- package/types/components/DSCodeEditorImpl.d.ts +0 -8
- package/types/index.d.ts +0 -1
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
-
require('core-js/modules/esnext.async-iterator.find.js');
|
|
5
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.find.js');
|
|
7
|
-
require('core-js/modules/es.string.replace.js');
|
|
8
|
-
require('core-js/modules/es.string.replace-all.js');
|
|
9
|
-
var React = require('react');
|
|
10
|
-
var DSButton = require('@elliemae/ds-button');
|
|
11
|
-
var dsForm = require('@elliemae/ds-form');
|
|
12
|
-
var dsClassnames = require('@elliemae/ds-classnames');
|
|
13
|
-
var dsIcons = require('@elliemae/ds-icons');
|
|
14
|
-
|
|
15
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
-
|
|
17
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
18
|
-
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
19
|
-
|
|
20
|
-
var _DSButton, _ChevronSmallRight;
|
|
21
|
-
const blockName = 'code-editor';
|
|
22
|
-
const {
|
|
23
|
-
cssClassName,
|
|
24
|
-
classNameBlock
|
|
25
|
-
} = dsClassnames.convertPropToCssClassName(blockName);
|
|
26
|
-
const CheckOptionsGroup = dsClassnames.aggregatedClasses('div')("".concat(blockName, "-options-group"));
|
|
27
|
-
|
|
28
|
-
class DSCodeEditorForm extends React.Component {
|
|
29
|
-
constructor(props) {
|
|
30
|
-
super(props);
|
|
31
|
-
this.state = {
|
|
32
|
-
find: false,
|
|
33
|
-
replace: false,
|
|
34
|
-
isCaseSensitive: false,
|
|
35
|
-
isWholeWord: false,
|
|
36
|
-
filteredText: '',
|
|
37
|
-
replaceText: ''
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
searchWord(isReplace, all) {
|
|
42
|
-
const {
|
|
43
|
-
reactAceComponent: {
|
|
44
|
-
current: {
|
|
45
|
-
editor
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
} = this.props;
|
|
49
|
-
const {
|
|
50
|
-
isCaseSensitive,
|
|
51
|
-
isWholeWord,
|
|
52
|
-
filteredText,
|
|
53
|
-
replaceText
|
|
54
|
-
} = this.state;
|
|
55
|
-
const options = {
|
|
56
|
-
backwards: false,
|
|
57
|
-
wrap: true,
|
|
58
|
-
caseSensitive: isCaseSensitive,
|
|
59
|
-
wholeWord: isWholeWord,
|
|
60
|
-
regExp: true
|
|
61
|
-
};
|
|
62
|
-
editor.find(filteredText, options);
|
|
63
|
-
const selectedContent = editor.getSelectedText();
|
|
64
|
-
|
|
65
|
-
if (isReplace && replaceText && selectedContent) {
|
|
66
|
-
if (all) {
|
|
67
|
-
editor.findAll(filteredText, options);
|
|
68
|
-
editor.replaceAll(replaceText);
|
|
69
|
-
} else {
|
|
70
|
-
const range = editor.selection.getRange();
|
|
71
|
-
editor.session.replace(range, replaceText);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
render() {
|
|
77
|
-
const {
|
|
78
|
-
fileName
|
|
79
|
-
} = this.props;
|
|
80
|
-
const {
|
|
81
|
-
find,
|
|
82
|
-
replace,
|
|
83
|
-
isCaseSensitive,
|
|
84
|
-
isWholeWord,
|
|
85
|
-
filteredText,
|
|
86
|
-
replaceText
|
|
87
|
-
} = this.state;
|
|
88
|
-
return /*#__PURE__*/_jsx__default["default"]("div", {
|
|
89
|
-
className: "".concat(cssClassName)
|
|
90
|
-
}, void 0, fileName ? /*#__PURE__*/_jsx__default["default"]("div", {
|
|
91
|
-
className: classNameBlock('file-name')
|
|
92
|
-
}, void 0, "File Name: ", /*#__PURE__*/_jsx__default["default"]("span", {}, void 0, " ", fileName, " ")) : null, /*#__PURE__*/_jsx__default["default"]("div", {
|
|
93
|
-
className: classNameBlock('find-replace-btn')
|
|
94
|
-
}, void 0, !find && !replace ? /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
95
|
-
buttonType: "secondary",
|
|
96
|
-
labelText: "Find",
|
|
97
|
-
onClick: () => this.setState({
|
|
98
|
-
find: true
|
|
99
|
-
}),
|
|
100
|
-
size: "m"
|
|
101
|
-
}) : null, !replace ? /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
102
|
-
buttonType: "secondary",
|
|
103
|
-
labelText: "Find & Replace",
|
|
104
|
-
onClick: () => this.setState({
|
|
105
|
-
replace: true
|
|
106
|
-
}),
|
|
107
|
-
size: "m"
|
|
108
|
-
}) : null), find || replace ? /*#__PURE__*/_jsx__default["default"](dsForm.DSInputGroup, {
|
|
109
|
-
className: classNameBlock('find')
|
|
110
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](dsForm.DSTextBox, {
|
|
111
|
-
className: "find-word",
|
|
112
|
-
fluidWidth: false,
|
|
113
|
-
id: "find-textbox",
|
|
114
|
-
onChange: e => this.setState({
|
|
115
|
-
filteredText: e.currentTarget.value
|
|
116
|
-
}),
|
|
117
|
-
placeholder: "Find",
|
|
118
|
-
rightComponent: /*#__PURE__*/_jsx__default["default"]("div", {
|
|
119
|
-
className: classNameBlock('next-back-btn')
|
|
120
|
-
}, void 0, _DSButton || (_DSButton = /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
121
|
-
icon: /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallLeft, {}),
|
|
122
|
-
size: "m"
|
|
123
|
-
})), /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
124
|
-
icon: _ChevronSmallRight || (_ChevronSmallRight = /*#__PURE__*/_jsx__default["default"](dsIcons.ChevronSmallRight, {})),
|
|
125
|
-
onClick: () => this.searchWord(),
|
|
126
|
-
size: "m"
|
|
127
|
-
})),
|
|
128
|
-
value: filteredText
|
|
129
|
-
}), /*#__PURE__*/_jsx__default["default"](CheckOptionsGroup, {}, void 0, /*#__PURE__*/_jsx__default["default"](dsForm.DSCheckbox, {
|
|
130
|
-
checked: isCaseSensitive,
|
|
131
|
-
id: "case-sensitive-check",
|
|
132
|
-
labelText: "Case Sensitive",
|
|
133
|
-
name: "case-sensitive-check",
|
|
134
|
-
onChange: () => this.setState({
|
|
135
|
-
isCaseSensitive: !isCaseSensitive
|
|
136
|
-
})
|
|
137
|
-
}), /*#__PURE__*/_jsx__default["default"](dsForm.DSCheckbox, {
|
|
138
|
-
checked: isWholeWord,
|
|
139
|
-
id: "whole-word-check",
|
|
140
|
-
labelText: "Whole Word",
|
|
141
|
-
name: "whole-word-check",
|
|
142
|
-
onChange: () => this.setState({
|
|
143
|
-
isWholeWord: !isWholeWord
|
|
144
|
-
})
|
|
145
|
-
}), /*#__PURE__*/_jsx__default["default"](dsForm.DSCheckbox, {
|
|
146
|
-
checked: replace,
|
|
147
|
-
id: "replace-check",
|
|
148
|
-
labelText: "Replace",
|
|
149
|
-
name: "replace-check",
|
|
150
|
-
onChange: () => this.setState({
|
|
151
|
-
replace: !replace
|
|
152
|
-
})
|
|
153
|
-
})), /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
154
|
-
buttonType: "secondary",
|
|
155
|
-
labelText: "Done",
|
|
156
|
-
onClick: () => this.setState({
|
|
157
|
-
replace: false,
|
|
158
|
-
find: false
|
|
159
|
-
}),
|
|
160
|
-
size: "m"
|
|
161
|
-
})) : null, replace ? /*#__PURE__*/_jsx__default["default"]("div", {
|
|
162
|
-
className: classNameBlock('replace')
|
|
163
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](dsForm.DSTextBox, {
|
|
164
|
-
className: "find-word",
|
|
165
|
-
fluidWidth: false,
|
|
166
|
-
id: "replace-textbox",
|
|
167
|
-
onChange: e => this.setState({
|
|
168
|
-
replaceText: e.currentTarget.value
|
|
169
|
-
}),
|
|
170
|
-
placeholder: "Replace",
|
|
171
|
-
value: replaceText
|
|
172
|
-
}), /*#__PURE__*/_jsx__default["default"]("div", {
|
|
173
|
-
className: classNameBlock('replace-btns')
|
|
174
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
175
|
-
buttonType: "secondary",
|
|
176
|
-
labelText: "Replace",
|
|
177
|
-
onClick: () => this.searchWord(true, false),
|
|
178
|
-
size: "m"
|
|
179
|
-
}), /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
180
|
-
buttonType: "secondary",
|
|
181
|
-
labelText: "Replace All",
|
|
182
|
-
onClick: () => this.searchWord(true, true),
|
|
183
|
-
size: "m"
|
|
184
|
-
}))) : null);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
module.exports = DSCodeEditorForm;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
-
var React = require('react');
|
|
5
|
-
var AceEditor = require('react-ace');
|
|
6
|
-
var DSModal = require('@elliemae/ds-modal');
|
|
7
|
-
var DSCodeEditorForm = require('./DSCodeEditorForm.js');
|
|
8
|
-
require('brace/mode/javascript.js');
|
|
9
|
-
require('brace/theme/tomorrow.js');
|
|
10
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
15
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
|
-
var AceEditor__default = /*#__PURE__*/_interopDefaultLegacy(AceEditor);
|
|
17
|
-
var DSModal__default = /*#__PURE__*/_interopDefaultLegacy(DSModal);
|
|
18
|
-
|
|
19
|
-
class DSCodeEditorImpl extends React.Component {
|
|
20
|
-
constructor(props) {
|
|
21
|
-
super(props);
|
|
22
|
-
this.state = {
|
|
23
|
-
value: props.value,
|
|
24
|
-
errors: []
|
|
25
|
-
};
|
|
26
|
-
this.reactAceComponent = /*#__PURE__*/React__default["default"].createRef();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
render() {
|
|
30
|
-
const {
|
|
31
|
-
onSave,
|
|
32
|
-
onClose,
|
|
33
|
-
onReject,
|
|
34
|
-
isOpen,
|
|
35
|
-
fileName,
|
|
36
|
-
confirmLabel,
|
|
37
|
-
maxLines,
|
|
38
|
-
minLines,
|
|
39
|
-
modalTitle,
|
|
40
|
-
modalType,
|
|
41
|
-
rejectLabel,
|
|
42
|
-
size,
|
|
43
|
-
style,
|
|
44
|
-
containerProps
|
|
45
|
-
} = this.props;
|
|
46
|
-
const {
|
|
47
|
-
value,
|
|
48
|
-
errors
|
|
49
|
-
} = this.state;
|
|
50
|
-
return /*#__PURE__*/_jsx__default["default"](DSModal__default["default"], {
|
|
51
|
-
centered: false,
|
|
52
|
-
confirmLabel: confirmLabel,
|
|
53
|
-
containerProps: containerProps,
|
|
54
|
-
isOpen: isOpen,
|
|
55
|
-
modalTitle: modalTitle,
|
|
56
|
-
modalType: modalType,
|
|
57
|
-
onClose: () => onClose(value, fileName, errors),
|
|
58
|
-
onConfirm: () => onSave(value, fileName, errors),
|
|
59
|
-
onReject: () => onReject(value, fileName, errors),
|
|
60
|
-
rejectLabel: rejectLabel,
|
|
61
|
-
size: size,
|
|
62
|
-
style: style
|
|
63
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](DSCodeEditorForm, {
|
|
64
|
-
fileName: fileName,
|
|
65
|
-
reactAceComponent: this.reactAceComponent
|
|
66
|
-
}), /*#__PURE__*/jsxRuntime.jsx(AceEditor__default["default"], {
|
|
67
|
-
ref: this.reactAceComponent,
|
|
68
|
-
editorProps: {
|
|
69
|
-
$blockScrolling: true
|
|
70
|
-
},
|
|
71
|
-
maxLines: maxLines,
|
|
72
|
-
minLines: minLines,
|
|
73
|
-
mode: "javascript",
|
|
74
|
-
name: "ace-code-edior",
|
|
75
|
-
onChange: val => this.setState({
|
|
76
|
-
value: val
|
|
77
|
-
}),
|
|
78
|
-
onValidate: annotations => this.setState({
|
|
79
|
-
errors: annotations
|
|
80
|
-
}),
|
|
81
|
-
theme: "tomorrow",
|
|
82
|
-
value: value
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
module.exports = DSCodeEditorImpl;
|
package/cjs/index.js
DELETED
package/esm/DSCodeEditor.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
-
import { useState, useRef } from 'react';
|
|
4
|
-
import { PropTypes, describe } from 'react-desc';
|
|
5
|
-
import DSModal, { modalTypes } from '@elliemae/ds-modal';
|
|
6
|
-
import AceEditor from 'react-ace';
|
|
7
|
-
import DSCodeEditorForm from './components/DSCodeEditorForm.js';
|
|
8
|
-
import 'brace/mode/javascript.js';
|
|
9
|
-
import 'brace/theme/tomorrow.js';
|
|
10
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
11
|
-
|
|
12
|
-
const DSCodeEditor = _ref => {
|
|
13
|
-
let {
|
|
14
|
-
containerProps = {},
|
|
15
|
-
value: defaultValue = '',
|
|
16
|
-
onSave = () => null,
|
|
17
|
-
onClose = () => null,
|
|
18
|
-
onReject = () => null,
|
|
19
|
-
onChange = () => null,
|
|
20
|
-
isOpen = false,
|
|
21
|
-
fileName = '',
|
|
22
|
-
confirmLabel = 'Save',
|
|
23
|
-
maxLines = 20,
|
|
24
|
-
minLines = 20,
|
|
25
|
-
modalTitle = 'Javascript Editor',
|
|
26
|
-
modalType = 'confirm',
|
|
27
|
-
rejectLabel = 'Close',
|
|
28
|
-
size = 'large',
|
|
29
|
-
style = {},
|
|
30
|
-
useModal = true,
|
|
31
|
-
showHeader = true,
|
|
32
|
-
showSyntaxChecks = true
|
|
33
|
-
} = _ref;
|
|
34
|
-
const [{
|
|
35
|
-
value,
|
|
36
|
-
errors
|
|
37
|
-
}, setState] = useState({
|
|
38
|
-
value: defaultValue,
|
|
39
|
-
errors: []
|
|
40
|
-
});
|
|
41
|
-
const reactAceComponent = useRef();
|
|
42
|
-
|
|
43
|
-
const editor = /*#__PURE__*/jsxs(Fragment, {
|
|
44
|
-
children: [showHeader && /*#__PURE__*/_jsx(DSCodeEditorForm, {
|
|
45
|
-
fileName: fileName,
|
|
46
|
-
reactAceComponent: reactAceComponent
|
|
47
|
-
}), /*#__PURE__*/jsx(AceEditor, {
|
|
48
|
-
ref: reactAceComponent,
|
|
49
|
-
editorProps: {
|
|
50
|
-
$blockScrolling: true
|
|
51
|
-
},
|
|
52
|
-
maxLines: maxLines,
|
|
53
|
-
minLines: minLines,
|
|
54
|
-
mode: "javascript",
|
|
55
|
-
name: "ace-code-edior",
|
|
56
|
-
onChange: val => {
|
|
57
|
-
setState({
|
|
58
|
-
errors,
|
|
59
|
-
value: val
|
|
60
|
-
});
|
|
61
|
-
onChange(val, errors);
|
|
62
|
-
},
|
|
63
|
-
onValidate: annotations => setState({
|
|
64
|
-
value,
|
|
65
|
-
errors: annotations
|
|
66
|
-
}),
|
|
67
|
-
theme: "tomorrow",
|
|
68
|
-
setOptions: {
|
|
69
|
-
useWorker: showSyntaxChecks
|
|
70
|
-
},
|
|
71
|
-
value: value
|
|
72
|
-
})]
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
if (!useModal) return editor;
|
|
76
|
-
return /*#__PURE__*/_jsx(DSModal, {
|
|
77
|
-
centered: false,
|
|
78
|
-
confirmLabel: confirmLabel,
|
|
79
|
-
containerProps: containerProps,
|
|
80
|
-
isOpen: isOpen,
|
|
81
|
-
modalTitle: modalTitle,
|
|
82
|
-
modalType: modalType,
|
|
83
|
-
onClose: () => onClose(value, fileName, errors),
|
|
84
|
-
onConfirm: () => onSave(value, fileName, errors),
|
|
85
|
-
onReject: () => onReject(value, fileName, errors),
|
|
86
|
-
rejectLabel: rejectLabel,
|
|
87
|
-
size: size,
|
|
88
|
-
style: style
|
|
89
|
-
}, void 0, editor);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const codeEditorProps = {
|
|
93
|
-
containerProps: PropTypes.object.description('Set of Properties attached to the main container'),
|
|
94
|
-
value: PropTypes.string.description('editors content').isRequired,
|
|
95
|
-
onSave: PropTypes.func.description('function called when the user press save'),
|
|
96
|
-
onClose: PropTypes.func.description('function called when the user closes the modal'),
|
|
97
|
-
onReject: PropTypes.func.description('function called when is rejected'),
|
|
98
|
-
onChange: PropTypes.func.description('function executed when code editor value changes').isRequired,
|
|
99
|
-
isOpen: PropTypes.bool.description('Whether the modal is opened or not').defaultValue(false),
|
|
100
|
-
fileName: PropTypes.string.description('File name to open in the editor'),
|
|
101
|
-
maxLines: PropTypes.number.description('Max lines in the editor content').defaultValue(20),
|
|
102
|
-
minLines: PropTypes.number.description('Min lines in the editor content').defaultValue(20),
|
|
103
|
-
modalTitle: PropTypes.string.description('Modal title').defaultValue('Javascript Editor'),
|
|
104
|
-
confirmLabel: PropTypes.string.description('Customize modal confirm label').defaultValue('Save'),
|
|
105
|
-
rejectLabel: PropTypes.string.description('Customize modal rejection label').defaultValue('Close'),
|
|
106
|
-
modalType: PropTypes.oneOf(modalTypes).description('Modal type').defaultValue('confirm'),
|
|
107
|
-
size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge']).description('modal size').defaultValue('large'),
|
|
108
|
-
style: PropTypes.object.description('css inline style'),
|
|
109
|
-
useModal: PropTypes.bool.description('whether to use code editor inside modal or not').defaultValue(true),
|
|
110
|
-
showHeader: PropTypes.bool.description('show editors header').defaultValue(true),
|
|
111
|
-
showSyntaxChecks: PropTypes.bool.description('show syntax warnings and checks').defaultValue(true)
|
|
112
|
-
};
|
|
113
|
-
const CodeEditorWithSchema = describe(DSCodeEditor);
|
|
114
|
-
CodeEditorWithSchema.propTypes = codeEditorProps;
|
|
115
|
-
|
|
116
|
-
export { CodeEditorWithSchema, DSCodeEditor as default };
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
-
import 'core-js/modules/esnext.iterator.find.js';
|
|
5
|
-
import 'core-js/modules/es.string.replace.js';
|
|
6
|
-
import 'core-js/modules/es.string.replace-all.js';
|
|
7
|
-
import { Component } from 'react';
|
|
8
|
-
import DSButton from '@elliemae/ds-button';
|
|
9
|
-
import { DSInputGroup, DSTextBox, DSCheckbox } from '@elliemae/ds-form';
|
|
10
|
-
import { convertPropToCssClassName, aggregatedClasses } from '@elliemae/ds-classnames';
|
|
11
|
-
import { ChevronSmallLeft, ChevronSmallRight } from '@elliemae/ds-icons';
|
|
12
|
-
|
|
13
|
-
var _DSButton, _ChevronSmallRight;
|
|
14
|
-
const blockName = 'code-editor';
|
|
15
|
-
const {
|
|
16
|
-
cssClassName,
|
|
17
|
-
classNameBlock
|
|
18
|
-
} = convertPropToCssClassName(blockName);
|
|
19
|
-
const CheckOptionsGroup = aggregatedClasses('div')("".concat(blockName, "-options-group"));
|
|
20
|
-
|
|
21
|
-
class DSCodeEditorForm extends Component {
|
|
22
|
-
constructor(props) {
|
|
23
|
-
super(props);
|
|
24
|
-
this.state = {
|
|
25
|
-
find: false,
|
|
26
|
-
replace: false,
|
|
27
|
-
isCaseSensitive: false,
|
|
28
|
-
isWholeWord: false,
|
|
29
|
-
filteredText: '',
|
|
30
|
-
replaceText: ''
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
searchWord(isReplace, all) {
|
|
35
|
-
const {
|
|
36
|
-
reactAceComponent: {
|
|
37
|
-
current: {
|
|
38
|
-
editor
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} = this.props;
|
|
42
|
-
const {
|
|
43
|
-
isCaseSensitive,
|
|
44
|
-
isWholeWord,
|
|
45
|
-
filteredText,
|
|
46
|
-
replaceText
|
|
47
|
-
} = this.state;
|
|
48
|
-
const options = {
|
|
49
|
-
backwards: false,
|
|
50
|
-
wrap: true,
|
|
51
|
-
caseSensitive: isCaseSensitive,
|
|
52
|
-
wholeWord: isWholeWord,
|
|
53
|
-
regExp: true
|
|
54
|
-
};
|
|
55
|
-
editor.find(filteredText, options);
|
|
56
|
-
const selectedContent = editor.getSelectedText();
|
|
57
|
-
|
|
58
|
-
if (isReplace && replaceText && selectedContent) {
|
|
59
|
-
if (all) {
|
|
60
|
-
editor.findAll(filteredText, options);
|
|
61
|
-
editor.replaceAll(replaceText);
|
|
62
|
-
} else {
|
|
63
|
-
const range = editor.selection.getRange();
|
|
64
|
-
editor.session.replace(range, replaceText);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
render() {
|
|
70
|
-
const {
|
|
71
|
-
fileName
|
|
72
|
-
} = this.props;
|
|
73
|
-
const {
|
|
74
|
-
find,
|
|
75
|
-
replace,
|
|
76
|
-
isCaseSensitive,
|
|
77
|
-
isWholeWord,
|
|
78
|
-
filteredText,
|
|
79
|
-
replaceText
|
|
80
|
-
} = this.state;
|
|
81
|
-
return /*#__PURE__*/_jsx("div", {
|
|
82
|
-
className: "".concat(cssClassName)
|
|
83
|
-
}, void 0, fileName ? /*#__PURE__*/_jsx("div", {
|
|
84
|
-
className: classNameBlock('file-name')
|
|
85
|
-
}, void 0, "File Name: ", /*#__PURE__*/_jsx("span", {}, void 0, " ", fileName, " ")) : null, /*#__PURE__*/_jsx("div", {
|
|
86
|
-
className: classNameBlock('find-replace-btn')
|
|
87
|
-
}, void 0, !find && !replace ? /*#__PURE__*/_jsx(DSButton, {
|
|
88
|
-
buttonType: "secondary",
|
|
89
|
-
labelText: "Find",
|
|
90
|
-
onClick: () => this.setState({
|
|
91
|
-
find: true
|
|
92
|
-
}),
|
|
93
|
-
size: "m"
|
|
94
|
-
}) : null, !replace ? /*#__PURE__*/_jsx(DSButton, {
|
|
95
|
-
buttonType: "secondary",
|
|
96
|
-
labelText: "Find & Replace",
|
|
97
|
-
onClick: () => this.setState({
|
|
98
|
-
replace: true
|
|
99
|
-
}),
|
|
100
|
-
size: "m"
|
|
101
|
-
}) : null), find || replace ? /*#__PURE__*/_jsx(DSInputGroup, {
|
|
102
|
-
className: classNameBlock('find')
|
|
103
|
-
}, void 0, /*#__PURE__*/_jsx(DSTextBox, {
|
|
104
|
-
className: "find-word",
|
|
105
|
-
fluidWidth: false,
|
|
106
|
-
id: "find-textbox",
|
|
107
|
-
onChange: e => this.setState({
|
|
108
|
-
filteredText: e.currentTarget.value
|
|
109
|
-
}),
|
|
110
|
-
placeholder: "Find",
|
|
111
|
-
rightComponent: /*#__PURE__*/_jsx("div", {
|
|
112
|
-
className: classNameBlock('next-back-btn')
|
|
113
|
-
}, void 0, _DSButton || (_DSButton = /*#__PURE__*/_jsx(DSButton, {
|
|
114
|
-
icon: /*#__PURE__*/_jsx(ChevronSmallLeft, {}),
|
|
115
|
-
size: "m"
|
|
116
|
-
})), /*#__PURE__*/_jsx(DSButton, {
|
|
117
|
-
icon: _ChevronSmallRight || (_ChevronSmallRight = /*#__PURE__*/_jsx(ChevronSmallRight, {})),
|
|
118
|
-
onClick: () => this.searchWord(),
|
|
119
|
-
size: "m"
|
|
120
|
-
})),
|
|
121
|
-
value: filteredText
|
|
122
|
-
}), /*#__PURE__*/_jsx(CheckOptionsGroup, {}, void 0, /*#__PURE__*/_jsx(DSCheckbox, {
|
|
123
|
-
checked: isCaseSensitive,
|
|
124
|
-
id: "case-sensitive-check",
|
|
125
|
-
labelText: "Case Sensitive",
|
|
126
|
-
name: "case-sensitive-check",
|
|
127
|
-
onChange: () => this.setState({
|
|
128
|
-
isCaseSensitive: !isCaseSensitive
|
|
129
|
-
})
|
|
130
|
-
}), /*#__PURE__*/_jsx(DSCheckbox, {
|
|
131
|
-
checked: isWholeWord,
|
|
132
|
-
id: "whole-word-check",
|
|
133
|
-
labelText: "Whole Word",
|
|
134
|
-
name: "whole-word-check",
|
|
135
|
-
onChange: () => this.setState({
|
|
136
|
-
isWholeWord: !isWholeWord
|
|
137
|
-
})
|
|
138
|
-
}), /*#__PURE__*/_jsx(DSCheckbox, {
|
|
139
|
-
checked: replace,
|
|
140
|
-
id: "replace-check",
|
|
141
|
-
labelText: "Replace",
|
|
142
|
-
name: "replace-check",
|
|
143
|
-
onChange: () => this.setState({
|
|
144
|
-
replace: !replace
|
|
145
|
-
})
|
|
146
|
-
})), /*#__PURE__*/_jsx(DSButton, {
|
|
147
|
-
buttonType: "secondary",
|
|
148
|
-
labelText: "Done",
|
|
149
|
-
onClick: () => this.setState({
|
|
150
|
-
replace: false,
|
|
151
|
-
find: false
|
|
152
|
-
}),
|
|
153
|
-
size: "m"
|
|
154
|
-
})) : null, replace ? /*#__PURE__*/_jsx("div", {
|
|
155
|
-
className: classNameBlock('replace')
|
|
156
|
-
}, void 0, /*#__PURE__*/_jsx(DSTextBox, {
|
|
157
|
-
className: "find-word",
|
|
158
|
-
fluidWidth: false,
|
|
159
|
-
id: "replace-textbox",
|
|
160
|
-
onChange: e => this.setState({
|
|
161
|
-
replaceText: e.currentTarget.value
|
|
162
|
-
}),
|
|
163
|
-
placeholder: "Replace",
|
|
164
|
-
value: replaceText
|
|
165
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
166
|
-
className: classNameBlock('replace-btns')
|
|
167
|
-
}, void 0, /*#__PURE__*/_jsx(DSButton, {
|
|
168
|
-
buttonType: "secondary",
|
|
169
|
-
labelText: "Replace",
|
|
170
|
-
onClick: () => this.searchWord(true, false),
|
|
171
|
-
size: "m"
|
|
172
|
-
}), /*#__PURE__*/_jsx(DSButton, {
|
|
173
|
-
buttonType: "secondary",
|
|
174
|
-
labelText: "Replace All",
|
|
175
|
-
onClick: () => this.searchWord(true, true),
|
|
176
|
-
size: "m"
|
|
177
|
-
}))) : null);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export { DSCodeEditorForm as default };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import React, { Component } from 'react';
|
|
3
|
-
import AceEditor from 'react-ace';
|
|
4
|
-
import DSModal from '@elliemae/ds-modal';
|
|
5
|
-
import DSCodeEditorForm from './DSCodeEditorForm.js';
|
|
6
|
-
import 'brace/mode/javascript.js';
|
|
7
|
-
import 'brace/theme/tomorrow.js';
|
|
8
|
-
import { jsx } from 'react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
class DSCodeEditorImpl extends Component {
|
|
11
|
-
constructor(props) {
|
|
12
|
-
super(props);
|
|
13
|
-
this.state = {
|
|
14
|
-
value: props.value,
|
|
15
|
-
errors: []
|
|
16
|
-
};
|
|
17
|
-
this.reactAceComponent = /*#__PURE__*/React.createRef();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
render() {
|
|
21
|
-
const {
|
|
22
|
-
onSave,
|
|
23
|
-
onClose,
|
|
24
|
-
onReject,
|
|
25
|
-
isOpen,
|
|
26
|
-
fileName,
|
|
27
|
-
confirmLabel,
|
|
28
|
-
maxLines,
|
|
29
|
-
minLines,
|
|
30
|
-
modalTitle,
|
|
31
|
-
modalType,
|
|
32
|
-
rejectLabel,
|
|
33
|
-
size,
|
|
34
|
-
style,
|
|
35
|
-
containerProps
|
|
36
|
-
} = this.props;
|
|
37
|
-
const {
|
|
38
|
-
value,
|
|
39
|
-
errors
|
|
40
|
-
} = this.state;
|
|
41
|
-
return /*#__PURE__*/_jsx(DSModal, {
|
|
42
|
-
centered: false,
|
|
43
|
-
confirmLabel: confirmLabel,
|
|
44
|
-
containerProps: containerProps,
|
|
45
|
-
isOpen: isOpen,
|
|
46
|
-
modalTitle: modalTitle,
|
|
47
|
-
modalType: modalType,
|
|
48
|
-
onClose: () => onClose(value, fileName, errors),
|
|
49
|
-
onConfirm: () => onSave(value, fileName, errors),
|
|
50
|
-
onReject: () => onReject(value, fileName, errors),
|
|
51
|
-
rejectLabel: rejectLabel,
|
|
52
|
-
size: size,
|
|
53
|
-
style: style
|
|
54
|
-
}, void 0, /*#__PURE__*/_jsx(DSCodeEditorForm, {
|
|
55
|
-
fileName: fileName,
|
|
56
|
-
reactAceComponent: this.reactAceComponent
|
|
57
|
-
}), /*#__PURE__*/jsx(AceEditor, {
|
|
58
|
-
ref: this.reactAceComponent,
|
|
59
|
-
editorProps: {
|
|
60
|
-
$blockScrolling: true
|
|
61
|
-
},
|
|
62
|
-
maxLines: maxLines,
|
|
63
|
-
minLines: minLines,
|
|
64
|
-
mode: "javascript",
|
|
65
|
-
name: "ace-code-edior",
|
|
66
|
-
onChange: val => this.setState({
|
|
67
|
-
value: val
|
|
68
|
-
}),
|
|
69
|
-
onValidate: annotations => this.setState({
|
|
70
|
-
errors: annotations
|
|
71
|
-
}),
|
|
72
|
-
theme: "tomorrow",
|
|
73
|
-
value: value
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export { DSCodeEditorImpl as default };
|
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CodeEditorWithSchema, default } from './DSCodeEditor.js';
|