@elliemae/ds-codeeditor 3.32.2-next.1 → 3.33.0-next.1
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 +143 -0
- package/dist/cjs/DSCodeEditor.js.map +7 -0
- package/dist/cjs/components/DSCodeEditorForm.js +202 -0
- package/dist/cjs/components/DSCodeEditorForm.js.map +7 -0
- package/dist/cjs/components/DSCodeEditorImpl.js +108 -0
- package/dist/cjs/components/DSCodeEditorImpl.js.map +7 -0
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/DSCodeEditor.js +113 -0
- package/dist/esm/DSCodeEditor.js.map +7 -0
- package/dist/esm/components/DSCodeEditorForm.js +172 -0
- package/dist/esm/components/DSCodeEditorForm.js.map +7 -0
- package/dist/esm/components/DSCodeEditorImpl.js +78 -0
- package/dist/esm/components/DSCodeEditorImpl.js.map +7 -0
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/types/DSCodeEditor.d.ts +70 -0
- package/dist/types/components/DSCodeEditorForm.d.ts +7 -0
- package/dist/types/components/DSCodeEditorImpl.d.ts +8 -0
- package/dist/types/index.d.ts +1 -2
- package/package.json +10 -3
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var DSCodeEditor_exports = {};
|
|
30
|
+
__export(DSCodeEditor_exports, {
|
|
31
|
+
CodeEditorWithSchema: () => CodeEditorWithSchema,
|
|
32
|
+
DSCodeEditor: () => DSCodeEditor,
|
|
33
|
+
default: () => DSCodeEditor_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(DSCodeEditor_exports);
|
|
36
|
+
var React = __toESM(require("react"));
|
|
37
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
var import_react = require("react");
|
|
39
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
40
|
+
var import_ds_modal = require("@elliemae/ds-modal");
|
|
41
|
+
var import_react_ace = __toESM(require("react-ace"));
|
|
42
|
+
var import_DSCodeEditorForm = __toESM(require("./components/DSCodeEditorForm.js"));
|
|
43
|
+
var import_mode_javascript = require("ace-builds/src-noconflict/mode-javascript.js");
|
|
44
|
+
var import_theme_tomorrow = require("ace-builds/src-noconflict/theme-tomorrow.js");
|
|
45
|
+
const DSCodeEditor = ({
|
|
46
|
+
containerProps = {},
|
|
47
|
+
value: defaultValue = "",
|
|
48
|
+
onSave = () => null,
|
|
49
|
+
onClose = () => null,
|
|
50
|
+
onReject = () => null,
|
|
51
|
+
onChange = () => null,
|
|
52
|
+
isOpen = false,
|
|
53
|
+
fileName = "",
|
|
54
|
+
confirmLabel = "Save",
|
|
55
|
+
maxLines = 20,
|
|
56
|
+
minLines = 20,
|
|
57
|
+
modalTitle = "Javascript Editor",
|
|
58
|
+
modalType = "confirm",
|
|
59
|
+
rejectLabel = "Close",
|
|
60
|
+
size = "large",
|
|
61
|
+
style = {},
|
|
62
|
+
useModal = true,
|
|
63
|
+
showHeader = true,
|
|
64
|
+
showSyntaxChecks = true
|
|
65
|
+
}) => {
|
|
66
|
+
const [{ value, errors }, setState] = (0, import_react.useState)({
|
|
67
|
+
value: defaultValue,
|
|
68
|
+
errors: []
|
|
69
|
+
});
|
|
70
|
+
const reactAceComponent = (0, import_react.useRef)();
|
|
71
|
+
const Comp = import_react_ace.default?.default ?? import_react_ace.default;
|
|
72
|
+
const editor = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
73
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DSCodeEditorForm.default, { fileName, reactAceComponent }),
|
|
74
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
75
|
+
Comp,
|
|
76
|
+
{
|
|
77
|
+
ref: reactAceComponent,
|
|
78
|
+
editorProps: { $blockScrolling: true },
|
|
79
|
+
maxLines,
|
|
80
|
+
minLines,
|
|
81
|
+
mode: "javascript",
|
|
82
|
+
name: "ace-code-edior",
|
|
83
|
+
onChange: (val) => {
|
|
84
|
+
setState({ errors, value: val });
|
|
85
|
+
onChange(val, errors);
|
|
86
|
+
},
|
|
87
|
+
onValidate: (annotations) => setState({ value, errors: annotations }),
|
|
88
|
+
theme: "tomorrow",
|
|
89
|
+
setOptions: {
|
|
90
|
+
useWorker: showSyntaxChecks
|
|
91
|
+
},
|
|
92
|
+
value
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
] });
|
|
96
|
+
if (!useModal)
|
|
97
|
+
return editor;
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
+
import_ds_modal.DSModal,
|
|
100
|
+
{
|
|
101
|
+
centered: false,
|
|
102
|
+
confirmLabel,
|
|
103
|
+
containerProps,
|
|
104
|
+
isOpen,
|
|
105
|
+
modalTitle,
|
|
106
|
+
modalType,
|
|
107
|
+
onClose: () => onClose(value, fileName, errors),
|
|
108
|
+
onConfirm: () => onSave(value, fileName, errors),
|
|
109
|
+
onReject: () => onReject(value, fileName, errors),
|
|
110
|
+
rejectLabel,
|
|
111
|
+
size,
|
|
112
|
+
style,
|
|
113
|
+
children: editor
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
const codeEditorProps = {
|
|
118
|
+
containerProps: import_ds_props_helpers.PropTypes.object.description("Set of Properties attached to the main container"),
|
|
119
|
+
value: import_ds_props_helpers.PropTypes.string.description("editors content").isRequired,
|
|
120
|
+
onSave: import_ds_props_helpers.PropTypes.func.description("function called when the user press save"),
|
|
121
|
+
onClose: import_ds_props_helpers.PropTypes.func.description("function called when the user closes the modal"),
|
|
122
|
+
onReject: import_ds_props_helpers.PropTypes.func.description("function called when is rejected"),
|
|
123
|
+
onChange: import_ds_props_helpers.PropTypes.func.description("function executed when code editor value changes").isRequired,
|
|
124
|
+
isOpen: import_ds_props_helpers.PropTypes.bool.description("Whether the modal is opened or not").defaultValue(false),
|
|
125
|
+
fileName: import_ds_props_helpers.PropTypes.string.description("File name to open in the editor"),
|
|
126
|
+
maxLines: import_ds_props_helpers.PropTypes.number.description("Max lines in the editor content").defaultValue(20),
|
|
127
|
+
minLines: import_ds_props_helpers.PropTypes.number.description("Min lines in the editor content").defaultValue(20),
|
|
128
|
+
modalTitle: import_ds_props_helpers.PropTypes.string.description("Modal title").defaultValue("Javascript Editor"),
|
|
129
|
+
confirmLabel: import_ds_props_helpers.PropTypes.string.description("Customize modal confirm label").defaultValue("Save"),
|
|
130
|
+
rejectLabel: import_ds_props_helpers.PropTypes.string.description("Customize modal rejection label").defaultValue("Close"),
|
|
131
|
+
modalType: import_ds_props_helpers.PropTypes.oneOf(import_ds_modal.modalTypes).description("Modal type").defaultValue("confirm"),
|
|
132
|
+
size: import_ds_props_helpers.PropTypes.oneOf(["xsmall", "small", "medium", "large", "xlarge"]).description("modal size").defaultValue("large"),
|
|
133
|
+
style: import_ds_props_helpers.PropTypes.object.description("css inline style"),
|
|
134
|
+
useModal: import_ds_props_helpers.PropTypes.bool.description("whether to use code editor inside modal or not").defaultValue(true),
|
|
135
|
+
showHeader: import_ds_props_helpers.PropTypes.bool.description("show editors header").defaultValue(true),
|
|
136
|
+
showSyntaxChecks: import_ds_props_helpers.PropTypes.bool.description("show syntax warnings and checks").defaultValue(true)
|
|
137
|
+
};
|
|
138
|
+
DSCodeEditor.propTypes = codeEditorProps;
|
|
139
|
+
DSCodeEditor.displayName = "DSCodeEditor";
|
|
140
|
+
const CodeEditorWithSchema = (0, import_ds_props_helpers.describe)(DSCodeEditor);
|
|
141
|
+
CodeEditorWithSchema.propTypes = codeEditorProps;
|
|
142
|
+
var DSCodeEditor_default = DSCodeEditor;
|
|
143
|
+
//# sourceMappingURL=DSCodeEditor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/DSCodeEditor.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { useState, useRef } from 'react';\nimport { describe, PropTypes } from '@elliemae/ds-props-helpers';\nimport { DSModal, modalTypes } from '@elliemae/ds-modal';\nimport { default as AceEditor } from 'react-ace';\nimport DSCodeEditorForm from './components/DSCodeEditorForm.js';\nimport 'ace-builds/src-noconflict/mode-javascript.js';\nimport 'ace-builds/src-noconflict/theme-tomorrow.js';\nconst DSCodeEditor = ({\n containerProps = {},\n value: defaultValue = '',\n onSave = () => null,\n onClose = () => null,\n onReject = () => null,\n onChange = () => null,\n isOpen = false,\n fileName = '',\n confirmLabel = 'Save',\n maxLines = 20,\n minLines = 20,\n modalTitle = 'Javascript Editor',\n modalType = 'confirm',\n rejectLabel = 'Close',\n size = 'large',\n style = {},\n useModal = true,\n showHeader = true,\n showSyntaxChecks = true,\n}) => {\n const [{ value, errors }, setState] = useState({\n value: defaultValue,\n errors: [],\n });\n const reactAceComponent = useRef();\n\n const Comp = (AceEditor as any)?.default ?? AceEditor;\n const editor = (\n <>\n {showHeader && <DSCodeEditorForm fileName={fileName} reactAceComponent={reactAceComponent} />}\n <Comp\n ref={reactAceComponent}\n editorProps={{ $blockScrolling: true }}\n maxLines={maxLines}\n minLines={minLines}\n mode=\"javascript\"\n name=\"ace-code-edior\"\n onChange={(val) => {\n setState({ errors, value: val });\n onChange(val, errors);\n }}\n onValidate={(annotations) => setState({ value, errors: annotations })}\n theme=\"tomorrow\"\n setOptions={{\n useWorker: showSyntaxChecks,\n }}\n value={value}\n />\n </>\n );\n if (!useModal) return editor;\n return (\n <DSModal\n centered={false}\n confirmLabel={confirmLabel}\n containerProps={containerProps}\n isOpen={isOpen}\n modalTitle={modalTitle}\n modalType={modalType}\n onClose={() => onClose(value, fileName, errors)}\n onConfirm={() => onSave(value, fileName, errors)}\n onReject={() => onReject(value, fileName, errors)}\n rejectLabel={rejectLabel}\n size={size}\n style={style}\n >\n {editor}\n </DSModal>\n );\n};\n\nconst codeEditorProps = {\n containerProps: PropTypes.object.description('Set of Properties attached to the main container'),\n value: PropTypes.string.description('editors content').isRequired,\n onSave: PropTypes.func.description('function called when the user press save'),\n onClose: PropTypes.func.description('function called when the user closes the modal'),\n onReject: PropTypes.func.description('function called when is rejected'),\n onChange: PropTypes.func.description('function executed when code editor value changes').isRequired,\n isOpen: PropTypes.bool.description('Whether the modal is opened or not').defaultValue(false),\n fileName: PropTypes.string.description('File name to open in the editor'),\n maxLines: PropTypes.number.description('Max lines in the editor content').defaultValue(20),\n minLines: PropTypes.number.description('Min lines in the editor content').defaultValue(20),\n modalTitle: PropTypes.string.description('Modal title').defaultValue('Javascript Editor'),\n confirmLabel: PropTypes.string.description('Customize modal confirm label').defaultValue('Save'),\n rejectLabel: PropTypes.string.description('Customize modal rejection label').defaultValue('Close'),\n modalType: PropTypes.oneOf(modalTypes).description('Modal type').defaultValue('confirm'),\n size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge'])\n .description('modal size')\n .defaultValue('large'),\n style: PropTypes.object.description('css inline style'),\n useModal: PropTypes.bool.description('whether to use code editor inside modal or not').defaultValue(true),\n showHeader: PropTypes.bool.description('show editors header').defaultValue(true),\n showSyntaxChecks: PropTypes.bool.description('show syntax warnings and checks').defaultValue(true),\n};\n\nDSCodeEditor.propTypes = codeEditorProps;\nDSCodeEditor.displayName = 'DSCodeEditor';\nconst CodeEditorWithSchema = describe(DSCodeEditor);\nCodeEditorWithSchema.propTypes = codeEditorProps;\n\nexport { CodeEditorWithSchema, DSCodeEditor };\nexport default DSCodeEditor;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADqCnB;AApCJ,mBAAwC;AACxC,8BAAoC;AACpC,sBAAoC;AACpC,uBAAqC;AACrC,8BAA6B;AAC7B,6BAAO;AACP,4BAAO;AACP,MAAM,eAAe,CAAC;AAAA,EACpB,iBAAiB,CAAC;AAAA,EAClB,OAAO,eAAe;AAAA,EACtB,SAAS,MAAM;AAAA,EACf,UAAU,MAAM;AAAA,EAChB,WAAW,MAAM;AAAA,EACjB,WAAW,MAAM;AAAA,EACjB,SAAS;AAAA,EACT,WAAW;AAAA,EAC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c;AAC3B,MAAM,2BAAuB,kCAAS,YAAY;AAClD,qBAAqB,YAAY;AAGjC,IAAO,uBAAQ;",
|
|
6
|
+
"names": ["AceEditor", "DSCodeEditorForm"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var DSCodeEditorForm_exports = {};
|
|
30
|
+
__export(DSCodeEditorForm_exports, {
|
|
31
|
+
default: () => DSCodeEditorForm_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(DSCodeEditorForm_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_ds_button = require("@elliemae/ds-button");
|
|
38
|
+
var import_ds_form = require("@elliemae/ds-form");
|
|
39
|
+
var import_ds_classnames = require("@elliemae/ds-classnames");
|
|
40
|
+
var import_ds_icons = require("@elliemae/ds-icons");
|
|
41
|
+
const blockName = "code-editor";
|
|
42
|
+
const { cssClassName, classNameBlock } = (0, import_ds_classnames.convertPropToCssClassName)(blockName);
|
|
43
|
+
const CheckOptionsGroup = (0, import_ds_classnames.aggregatedClasses)("div")(`${blockName}-options-group`);
|
|
44
|
+
class DSCodeEditorForm extends import_react.Component {
|
|
45
|
+
constructor(props) {
|
|
46
|
+
super(props);
|
|
47
|
+
this.state = {
|
|
48
|
+
find: false,
|
|
49
|
+
replace: false,
|
|
50
|
+
isCaseSensitive: false,
|
|
51
|
+
isWholeWord: false,
|
|
52
|
+
filteredText: "",
|
|
53
|
+
replaceText: ""
|
|
54
|
+
};
|
|
55
|
+
this.searchWord = this.searchWord.bind(this);
|
|
56
|
+
}
|
|
57
|
+
searchWord(isReplace, all) {
|
|
58
|
+
const {
|
|
59
|
+
reactAceComponent: {
|
|
60
|
+
current: { editor }
|
|
61
|
+
}
|
|
62
|
+
} = this.props;
|
|
63
|
+
const { isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;
|
|
64
|
+
const options = {
|
|
65
|
+
backwards: false,
|
|
66
|
+
wrap: true,
|
|
67
|
+
caseSensitive: isCaseSensitive,
|
|
68
|
+
wholeWord: isWholeWord,
|
|
69
|
+
regExp: true
|
|
70
|
+
};
|
|
71
|
+
editor.find(filteredText, options);
|
|
72
|
+
const selectedContent = editor.getSelectedText();
|
|
73
|
+
if (isReplace && replaceText && selectedContent) {
|
|
74
|
+
if (all) {
|
|
75
|
+
editor.findAll(filteredText, options);
|
|
76
|
+
editor.replaceAll(replaceText);
|
|
77
|
+
} else {
|
|
78
|
+
const range = editor.selection.getRange();
|
|
79
|
+
editor.session.replace(range, replaceText);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
render() {
|
|
84
|
+
const { fileName } = this.props;
|
|
85
|
+
const { find, replace, isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;
|
|
86
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `${cssClassName}`, children: [
|
|
87
|
+
fileName ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: classNameBlock("file-name"), children: [
|
|
88
|
+
"File Name: ",
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
90
|
+
" ",
|
|
91
|
+
fileName,
|
|
92
|
+
" "
|
|
93
|
+
] })
|
|
94
|
+
] }) : null,
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: classNameBlock("find-replace-btn"), children: [
|
|
96
|
+
!find && !replace ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_button.DSButton, { buttonType: "secondary", labelText: "Find", onClick: () => this.setState({ find: true }), size: "m" }) : null,
|
|
97
|
+
!replace ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
|
+
import_ds_button.DSButton,
|
|
99
|
+
{
|
|
100
|
+
buttonType: "secondary",
|
|
101
|
+
labelText: "Find & Replace",
|
|
102
|
+
onClick: () => this.setState({ replace: true }),
|
|
103
|
+
size: "m"
|
|
104
|
+
}
|
|
105
|
+
) : null
|
|
106
|
+
] }),
|
|
107
|
+
find || replace ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ds_form.DSInputGroup, { className: classNameBlock("find"), children: [
|
|
108
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
109
|
+
import_ds_form.DSTextBox,
|
|
110
|
+
{
|
|
111
|
+
className: "find-word",
|
|
112
|
+
fluidWidth: false,
|
|
113
|
+
id: "find-textbox",
|
|
114
|
+
onChange: (e) => this.setState({ filteredText: e.currentTarget.value }),
|
|
115
|
+
placeholder: "Find",
|
|
116
|
+
rightComponent: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: classNameBlock("next-back-btn"), children: [
|
|
117
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_button.DSButton, { icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.ChevronSmallLeft, {}), size: "m" }),
|
|
118
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_button.DSButton, { icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_icons.ChevronSmallRight, {}), onClick: () => this.searchWord(), size: "m" })
|
|
119
|
+
] }),
|
|
120
|
+
value: filteredText
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CheckOptionsGroup, { children: [
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
+
import_ds_form.DSCheckbox,
|
|
126
|
+
{
|
|
127
|
+
checked: isCaseSensitive,
|
|
128
|
+
id: "case-sensitive-check",
|
|
129
|
+
labelText: "Case Sensitive",
|
|
130
|
+
name: "case-sensitive-check",
|
|
131
|
+
onChange: () => this.setState({ isCaseSensitive: !isCaseSensitive })
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
135
|
+
import_ds_form.DSCheckbox,
|
|
136
|
+
{
|
|
137
|
+
checked: isWholeWord,
|
|
138
|
+
id: "whole-word-check",
|
|
139
|
+
labelText: "Whole Word",
|
|
140
|
+
name: "whole-word-check",
|
|
141
|
+
onChange: () => this.setState({ isWholeWord: !isWholeWord })
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
145
|
+
import_ds_form.DSCheckbox,
|
|
146
|
+
{
|
|
147
|
+
checked: replace,
|
|
148
|
+
id: "replace-check",
|
|
149
|
+
labelText: "Replace",
|
|
150
|
+
name: "replace-check",
|
|
151
|
+
onChange: () => this.setState({ replace: !replace })
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
] }),
|
|
155
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
156
|
+
import_ds_button.DSButton,
|
|
157
|
+
{
|
|
158
|
+
buttonType: "secondary",
|
|
159
|
+
labelText: "Done",
|
|
160
|
+
onClick: () => this.setState({ replace: false, find: false }),
|
|
161
|
+
size: "m"
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
] }) : null,
|
|
165
|
+
replace ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: classNameBlock("replace"), children: [
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
|
+
import_ds_form.DSTextBox,
|
|
168
|
+
{
|
|
169
|
+
className: "find-word",
|
|
170
|
+
fluidWidth: false,
|
|
171
|
+
id: "replace-textbox",
|
|
172
|
+
onChange: (e) => this.setState({ replaceText: e.currentTarget.value }),
|
|
173
|
+
placeholder: "Replace",
|
|
174
|
+
value: replaceText
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: classNameBlock("replace-btns"), children: [
|
|
178
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
179
|
+
import_ds_button.DSButton,
|
|
180
|
+
{
|
|
181
|
+
buttonType: "secondary",
|
|
182
|
+
labelText: "Replace",
|
|
183
|
+
onClick: () => this.searchWord(true, false),
|
|
184
|
+
size: "m"
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
188
|
+
import_ds_button.DSButton,
|
|
189
|
+
{
|
|
190
|
+
buttonType: "secondary",
|
|
191
|
+
labelText: "Replace All",
|
|
192
|
+
onClick: () => this.searchWord(true, true),
|
|
193
|
+
size: "m"
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] })
|
|
197
|
+
] }) : null
|
|
198
|
+
] });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
var DSCodeEditorForm_default = DSCodeEditorForm;
|
|
202
|
+
//# sourceMappingURL=DSCodeEditorForm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/DSCodeEditorForm.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable react/prop-types */\n/* eslint-disable max-lines */\nimport React, { Component } from 'react';\nimport { DSButton } from '@elliemae/ds-button';\nimport { DSCheckbox, DSTextBox, DSInputGroup } from '@elliemae/ds-form';\nimport { convertPropToCssClassName, aggregatedClasses } from '@elliemae/ds-classnames';\nimport { ChevronSmallLeft, ChevronSmallRight } from '@elliemae/ds-icons';\n\nconst blockName = 'code-editor';\n\nconst { cssClassName, classNameBlock } = convertPropToCssClassName(blockName);\n\nconst CheckOptionsGroup = aggregatedClasses('div')(`${blockName}-options-group`);\n\nclass DSCodeEditorForm extends Component {\n constructor(props) {\n super(props);\n this.state = {\n find: false,\n replace: false,\n isCaseSensitive: false,\n isWholeWord: false,\n filteredText: '',\n replaceText: '',\n };\n\n this.searchWord = this.searchWord.bind(this);\n }\n\n searchWord(isReplace, all) {\n const {\n reactAceComponent: {\n current: { editor },\n },\n } = this.props;\n const { isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;\n const options = {\n backwards: false,\n wrap: true,\n caseSensitive: isCaseSensitive,\n wholeWord: isWholeWord,\n regExp: true,\n };\n editor.find(filteredText, options);\n const selectedContent = editor.getSelectedText();\n if (isReplace && replaceText && selectedContent) {\n if (all) {\n editor.findAll(filteredText, options);\n editor.replaceAll(replaceText);\n } else {\n const range = editor.selection.getRange();\n editor.session.replace(range, replaceText);\n }\n }\n }\n\n render() {\n const { fileName } = this.props;\n\n const { find, replace, isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;\n return (\n <div className={`${cssClassName}`}>\n {fileName ? (\n <div className={classNameBlock('file-name')}>\n File Name: <span> {fileName} </span>\n </div>\n ) : null}\n <div className={classNameBlock('find-replace-btn')}>\n {!find && !replace ? (\n <DSButton buttonType=\"secondary\" labelText=\"Find\" onClick={() => this.setState({ find: true })} size=\"m\" />\n ) : null}\n {!replace ? (\n <DSButton\n buttonType=\"secondary\"\n labelText=\"Find & Replace\"\n onClick={() => this.setState({ replace: true })}\n size=\"m\"\n />\n ) : null}\n </div>\n {find || replace ? (\n <DSInputGroup className={classNameBlock('find')}>\n <DSTextBox\n className=\"find-word\"\n fluidWidth={false}\n id=\"find-textbox\"\n onChange={(e) => this.setState({ filteredText: e.currentTarget.value })}\n placeholder=\"Find\"\n rightComponent={\n <div className={classNameBlock('next-back-btn')}>\n <DSButton icon={<ChevronSmallLeft />} size=\"m\" />\n <DSButton icon={<ChevronSmallRight />} onClick={() => this.searchWord()} size=\"m\" />\n </div>\n }\n value={filteredText}\n />\n <CheckOptionsGroup>\n <DSCheckbox\n checked={isCaseSensitive}\n id=\"case-sensitive-check\"\n labelText=\"Case Sensitive\"\n name=\"case-sensitive-check\"\n onChange={() => this.setState({ isCaseSensitive: !isCaseSensitive })}\n />\n <DSCheckbox\n checked={isWholeWord}\n id=\"whole-word-check\"\n labelText=\"Whole Word\"\n name=\"whole-word-check\"\n onChange={() => this.setState({ isWholeWord: !isWholeWord })}\n />\n <DSCheckbox\n checked={replace}\n id=\"replace-check\"\n labelText=\"Replace\"\n name=\"replace-check\"\n onChange={() => this.setState({ replace: !replace })}\n />\n </CheckOptionsGroup>\n <DSButton\n buttonType=\"secondary\"\n labelText=\"Done\"\n onClick={() => this.setState({ replace: false, find: false })}\n size=\"m\"\n />\n </DSInputGroup>\n ) : null}\n {replace ? (\n <div className={classNameBlock('replace')}>\n <DSTextBox\n className=\"find-word\"\n fluidWidth={false}\n id=\"replace-textbox\"\n onChange={(e) => this.setState({ replaceText: e.currentTarget.value })}\n placeholder=\"Replace\"\n value={replaceText}\n />\n <div className={classNameBlock('replace-btns')}>\n <DSButton\n buttonType=\"secondary\"\n labelText=\"Replace\"\n onClick={() => this.searchWord(true, false)}\n size=\"m\"\n />\n <DSButton\n buttonType=\"secondary\"\n labelText=\"Replace All\"\n onClick={() => this.searchWord(true, true)}\n size=\"m\"\n />\n </div>\n </div>\n ) : null}\n </div>\n );\n }\n}\n\nexport default DSCodeEditorForm;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADgEA;AA9DvB,mBAAiC;AACjC,uBAAyB;AACzB,qBAAoD;AACpD,2BAA6D;AAC7D,sBAAoD;AAEpD,MAAM,YAAY;AAElB,MAAM,EAAE,cAAc,eAAe,QAAI,gDAA0B,SAAS;AAE5E,MAAM,wBAAoB,wCAAkB,KAAK,EAAE,GAAG,yBAAyB;AAE/E,MAAM,yBAAyB,uBAAU;AAAA,EACvC,YAAY,OAAO;AACjB,UAAM,KAAK;AACX,SAAK,QAAQ;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,iBAAiB;AAAA,MACjB,aAAa;AAAA,MACb,cAAc;AAAA,MACd,aAAa;AAAA,IACf;AAEA,SAAK,aAAa,KAAK,WAAW,KAAK,IAAI;AAAA,EAC7C;AAAA,EAEA,WAAW,WAAW,KAAK;AACzB,UAAM;AAAA,MACJ,mBAAmB;AAAA,QACjB,SAAS,EAAE,OAAO;AAAA,MACpB;AAAA,IACF,IAAI,KAAK;AACT,UAAM,EAAE,iBAAiB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AA,YACC,WAAU;AAAA,YACV,YAAY;AAAA,YACZ,IAAG;AAAA,YACH,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,aAAa,EAAE,cAAc,MAAM,CAAC;AAAA,YACrE,aAAY;AAAA,YACZ,OAAO;AAAA;AAAA,QACT;AAAA,QACA,6CAAC,SAAI,WAAW,eAAe,cAAc,GAC3C;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,YAAW;AAAA,cACX,WAAU;AAAA,cACV,SAAS,MAAM,KAAK,WAAW,MAAM,KAAK;AAAA,cAC1C,MAAK;AAAA;AAAA,UACP;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,YAAW;AAAA,cACX,WAAU;AAAA,cACV,SAAS,MAAM,KAAK,WAAW,MAAM,IAAI;AAAA,cACzC,MAAK;AAAA;AAAA,UACP;AAAA,WACF;AAAA,SACF,IACE;AAAA,OACN;AAAA,EAEJ;AACF;AAEA,IAAO,2BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var DSCodeEditorImpl_exports = {};
|
|
30
|
+
__export(DSCodeEditorImpl_exports, {
|
|
31
|
+
default: () => DSCodeEditorImpl_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(DSCodeEditorImpl_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_react_ace = __toESM(require("react-ace"));
|
|
38
|
+
var import_ds_modal = require("@elliemae/ds-modal");
|
|
39
|
+
var import_DSCodeEditorForm = __toESM(require("./DSCodeEditorForm.js"));
|
|
40
|
+
var import_mode_javascript = require("ace-builds/src-noconflict/mode-javascript.js");
|
|
41
|
+
var import_theme_tomorrow = require("ace-builds/src-noconflict/theme-tomorrow.js");
|
|
42
|
+
class DSCodeEditorImpl extends import_react.Component {
|
|
43
|
+
constructor(props) {
|
|
44
|
+
super(props);
|
|
45
|
+
this.state = {
|
|
46
|
+
value: props.value,
|
|
47
|
+
errors: []
|
|
48
|
+
};
|
|
49
|
+
this.reactAceComponent = import_react.default.createRef();
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
const {
|
|
53
|
+
onSave,
|
|
54
|
+
onClose,
|
|
55
|
+
onReject,
|
|
56
|
+
isOpen,
|
|
57
|
+
fileName,
|
|
58
|
+
confirmLabel,
|
|
59
|
+
maxLines,
|
|
60
|
+
minLines,
|
|
61
|
+
modalTitle,
|
|
62
|
+
modalType,
|
|
63
|
+
rejectLabel,
|
|
64
|
+
size,
|
|
65
|
+
style,
|
|
66
|
+
containerProps
|
|
67
|
+
} = this.props;
|
|
68
|
+
const { value, errors } = this.state;
|
|
69
|
+
const Comp = import_react_ace.default?.default ?? import_react_ace.default;
|
|
70
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
71
|
+
import_ds_modal.DSModal,
|
|
72
|
+
{
|
|
73
|
+
centered: false,
|
|
74
|
+
confirmLabel,
|
|
75
|
+
containerProps,
|
|
76
|
+
isOpen,
|
|
77
|
+
modalTitle,
|
|
78
|
+
modalType,
|
|
79
|
+
onClose: () => onClose(value, fileName, errors),
|
|
80
|
+
onConfirm: () => onSave(value, fileName, errors),
|
|
81
|
+
onReject: () => onReject(value, fileName, errors),
|
|
82
|
+
rejectLabel,
|
|
83
|
+
size,
|
|
84
|
+
style,
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DSCodeEditorForm.default, { fileName, reactAceComponent: this.reactAceComponent }),
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
88
|
+
Comp,
|
|
89
|
+
{
|
|
90
|
+
ref: this.reactAceComponent,
|
|
91
|
+
editorProps: { $blockScrolling: true },
|
|
92
|
+
maxLines,
|
|
93
|
+
minLines,
|
|
94
|
+
mode: "javascript",
|
|
95
|
+
name: "ace-code-edior",
|
|
96
|
+
onChange: (val) => this.setState({ value: val }),
|
|
97
|
+
onValidate: (annotations) => this.setState({ errors: annotations }),
|
|
98
|
+
theme: "tomorrow",
|
|
99
|
+
value
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
var DSCodeEditorImpl_default = DSCodeEditorImpl;
|
|
108
|
+
//# sourceMappingURL=DSCodeEditorImpl.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/DSCodeEditorImpl.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { Component } from 'react';\nimport { default as AceEditor } from 'react-ace';\nimport { DSModal } from '@elliemae/ds-modal';\nimport DSCodeEditorForm from './DSCodeEditorForm.js';\nimport 'ace-builds/src-noconflict/mode-javascript.js';\nimport 'ace-builds/src-noconflict/theme-tomorrow.js';\n\nclass DSCodeEditorImpl extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: props.value,\n errors: [],\n };\n this.reactAceComponent = React.createRef();\n }\n\n render() {\n const {\n onSave,\n onClose,\n onReject,\n isOpen,\n fileName,\n confirmLabel,\n maxLines,\n minLines,\n modalTitle,\n modalType,\n rejectLabel,\n size,\n style,\n containerProps,\n } = this.props;\n\n const { value, errors } = this.state;\n const Comp = (AceEditor as any)?.default ?? AceEditor;\n return (\n <DSModal\n centered={false}\n confirmLabel={confirmLabel}\n containerProps={containerProps}\n isOpen={isOpen}\n modalTitle={modalTitle}\n modalType={modalType}\n onClose={() => onClose(value, fileName, errors)}\n onConfirm={() => onSave(value, fileName, errors)}\n onReject={() => onReject(value, fileName, errors)}\n rejectLabel={rejectLabel}\n size={size}\n style={style}\n >\n <DSCodeEditorForm fileName={fileName} reactAceComponent={this.reactAceComponent} />\n <Comp\n ref={this.reactAceComponent}\n editorProps={{ $blockScrolling: true }}\n maxLines={maxLines}\n minLines={minLines}\n mode=\"javascript\"\n name=\"ace-code-edior\"\n onChange={(val) => this.setState({ value: val })}\n onValidate={(annotations) => this.setState({ errors: annotations })}\n theme=\"tomorrow\"\n value={value}\n />\n </DSModal>\n );\n }\n}\n\nexport default DS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AAA,cACL,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,cAC/C,YAAY,CAAC,gBAAgB,KAAK,SAAS,EAAE,QAAQ,YAAY,CAAC;AAAA,cAClE,OAAM;AAAA,cACN;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,IAAO,2BAAQ;",
|
|
6
|
+
"names": ["React", "AceEditor", "DSCodeEditorForm"]
|
|
7
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -17,7 +17,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
22
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -29,10 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
29
|
var src_exports = {};
|
|
31
30
|
__export(src_exports, {
|
|
32
|
-
|
|
31
|
+
CodeEditorWithSchema: () => import_DSCodeEditor.CodeEditorWithSchema,
|
|
32
|
+
DSCodeEditor: () => import_DSCodeEditor.DSCodeEditor,
|
|
33
|
+
default: () => import_DSCodeEditor.default
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(src_exports);
|
|
35
36
|
var React = __toESM(require("react"));
|
|
36
|
-
|
|
37
|
-
var import_ds_legacy_codeeditor = __toESM(require("@elliemae/ds-legacy-codeeditor"));
|
|
37
|
+
var import_DSCodeEditor = __toESM(require("./DSCodeEditor.js"));
|
|
38
38
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export { default, DSCodeEditor, CodeEditorWithSchema } from './DSCodeEditor.js';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAA4D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef } from "react";
|
|
4
|
+
import { describe, PropTypes } from "@elliemae/ds-props-helpers";
|
|
5
|
+
import { DSModal, modalTypes } from "@elliemae/ds-modal";
|
|
6
|
+
import { default as AceEditor } from "react-ace";
|
|
7
|
+
import DSCodeEditorForm from "./components/DSCodeEditorForm.js";
|
|
8
|
+
import "ace-builds/src-noconflict/mode-javascript.js";
|
|
9
|
+
import "ace-builds/src-noconflict/theme-tomorrow.js";
|
|
10
|
+
const DSCodeEditor = ({
|
|
11
|
+
containerProps = {},
|
|
12
|
+
value: defaultValue = "",
|
|
13
|
+
onSave = () => null,
|
|
14
|
+
onClose = () => null,
|
|
15
|
+
onReject = () => null,
|
|
16
|
+
onChange = () => null,
|
|
17
|
+
isOpen = false,
|
|
18
|
+
fileName = "",
|
|
19
|
+
confirmLabel = "Save",
|
|
20
|
+
maxLines = 20,
|
|
21
|
+
minLines = 20,
|
|
22
|
+
modalTitle = "Javascript Editor",
|
|
23
|
+
modalType = "confirm",
|
|
24
|
+
rejectLabel = "Close",
|
|
25
|
+
size = "large",
|
|
26
|
+
style = {},
|
|
27
|
+
useModal = true,
|
|
28
|
+
showHeader = true,
|
|
29
|
+
showSyntaxChecks = true
|
|
30
|
+
}) => {
|
|
31
|
+
const [{ value, errors }, setState] = useState({
|
|
32
|
+
value: defaultValue,
|
|
33
|
+
errors: []
|
|
34
|
+
});
|
|
35
|
+
const reactAceComponent = useRef();
|
|
36
|
+
const Comp = AceEditor?.default ?? AceEditor;
|
|
37
|
+
const editor = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
38
|
+
showHeader && /* @__PURE__ */ jsx(DSCodeEditorForm, { fileName, reactAceComponent }),
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
Comp,
|
|
41
|
+
{
|
|
42
|
+
ref: reactAceComponent,
|
|
43
|
+
editorProps: { $blockScrolling: true },
|
|
44
|
+
maxLines,
|
|
45
|
+
minLines,
|
|
46
|
+
mode: "javascript",
|
|
47
|
+
name: "ace-code-edior",
|
|
48
|
+
onChange: (val) => {
|
|
49
|
+
setState({ errors, value: val });
|
|
50
|
+
onChange(val, errors);
|
|
51
|
+
},
|
|
52
|
+
onValidate: (annotations) => setState({ value, errors: annotations }),
|
|
53
|
+
theme: "tomorrow",
|
|
54
|
+
setOptions: {
|
|
55
|
+
useWorker: showSyntaxChecks
|
|
56
|
+
},
|
|
57
|
+
value
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] });
|
|
61
|
+
if (!useModal)
|
|
62
|
+
return editor;
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
DSModal,
|
|
65
|
+
{
|
|
66
|
+
centered: false,
|
|
67
|
+
confirmLabel,
|
|
68
|
+
containerProps,
|
|
69
|
+
isOpen,
|
|
70
|
+
modalTitle,
|
|
71
|
+
modalType,
|
|
72
|
+
onClose: () => onClose(value, fileName, errors),
|
|
73
|
+
onConfirm: () => onSave(value, fileName, errors),
|
|
74
|
+
onReject: () => onReject(value, fileName, errors),
|
|
75
|
+
rejectLabel,
|
|
76
|
+
size,
|
|
77
|
+
style,
|
|
78
|
+
children: editor
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
const codeEditorProps = {
|
|
83
|
+
containerProps: PropTypes.object.description("Set of Properties attached to the main container"),
|
|
84
|
+
value: PropTypes.string.description("editors content").isRequired,
|
|
85
|
+
onSave: PropTypes.func.description("function called when the user press save"),
|
|
86
|
+
onClose: PropTypes.func.description("function called when the user closes the modal"),
|
|
87
|
+
onReject: PropTypes.func.description("function called when is rejected"),
|
|
88
|
+
onChange: PropTypes.func.description("function executed when code editor value changes").isRequired,
|
|
89
|
+
isOpen: PropTypes.bool.description("Whether the modal is opened or not").defaultValue(false),
|
|
90
|
+
fileName: PropTypes.string.description("File name to open in the editor"),
|
|
91
|
+
maxLines: PropTypes.number.description("Max lines in the editor content").defaultValue(20),
|
|
92
|
+
minLines: PropTypes.number.description("Min lines in the editor content").defaultValue(20),
|
|
93
|
+
modalTitle: PropTypes.string.description("Modal title").defaultValue("Javascript Editor"),
|
|
94
|
+
confirmLabel: PropTypes.string.description("Customize modal confirm label").defaultValue("Save"),
|
|
95
|
+
rejectLabel: PropTypes.string.description("Customize modal rejection label").defaultValue("Close"),
|
|
96
|
+
modalType: PropTypes.oneOf(modalTypes).description("Modal type").defaultValue("confirm"),
|
|
97
|
+
size: PropTypes.oneOf(["xsmall", "small", "medium", "large", "xlarge"]).description("modal size").defaultValue("large"),
|
|
98
|
+
style: PropTypes.object.description("css inline style"),
|
|
99
|
+
useModal: PropTypes.bool.description("whether to use code editor inside modal or not").defaultValue(true),
|
|
100
|
+
showHeader: PropTypes.bool.description("show editors header").defaultValue(true),
|
|
101
|
+
showSyntaxChecks: PropTypes.bool.description("show syntax warnings and checks").defaultValue(true)
|
|
102
|
+
};
|
|
103
|
+
DSCodeEditor.propTypes = codeEditorProps;
|
|
104
|
+
DSCodeEditor.displayName = "DSCodeEditor";
|
|
105
|
+
const CodeEditorWithSchema = describe(DSCodeEditor);
|
|
106
|
+
CodeEditorWithSchema.propTypes = codeEditorProps;
|
|
107
|
+
var DSCodeEditor_default = DSCodeEditor;
|
|
108
|
+
export {
|
|
109
|
+
CodeEditorWithSchema,
|
|
110
|
+
DSCodeEditor,
|
|
111
|
+
DSCodeEditor_default as default
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=DSCodeEditor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSCodeEditor.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useState, useRef } from 'react';\nimport { describe, PropTypes } from '@elliemae/ds-props-helpers';\nimport { DSModal, modalTypes } from '@elliemae/ds-modal';\nimport { default as AceEditor } from 'react-ace';\nimport DSCodeEditorForm from './components/DSCodeEditorForm.js';\nimport 'ace-builds/src-noconflict/mode-javascript.js';\nimport 'ace-builds/src-noconflict/theme-tomorrow.js';\nconst DSCodeEditor = ({\n containerProps = {},\n value: defaultValue = '',\n onSave = () => null,\n onClose = () => null,\n onReject = () => null,\n onChange = () => null,\n isOpen = false,\n fileName = '',\n confirmLabel = 'Save',\n maxLines = 20,\n minLines = 20,\n modalTitle = 'Javascript Editor',\n modalType = 'confirm',\n rejectLabel = 'Close',\n size = 'large',\n style = {},\n useModal = true,\n showHeader = true,\n showSyntaxChecks = true,\n}) => {\n const [{ value, errors }, setState] = useState({\n value: defaultValue,\n errors: [],\n });\n const reactAceComponent = useRef();\n\n const Comp = (AceEditor as any)?.default ?? AceEditor;\n const editor = (\n <>\n {showHeader && <DSCodeEditorForm fileName={fileName} reactAceComponent={reactAceComponent} />}\n <Comp\n ref={reactAceComponent}\n editorProps={{ $blockScrolling: true }}\n maxLines={maxLines}\n minLines={minLines}\n mode=\"javascript\"\n name=\"ace-code-edior\"\n onChange={(val) => {\n setState({ errors, value: val });\n onChange(val, errors);\n }}\n onValidate={(annotations) => setState({ value, errors: annotations })}\n theme=\"tomorrow\"\n setOptions={{\n useWorker: showSyntaxChecks,\n }}\n value={value}\n />\n </>\n );\n if (!useModal) return editor;\n return (\n <DSModal\n centered={false}\n confirmLabel={confirmLabel}\n containerProps={containerProps}\n isOpen={isOpen}\n modalTitle={modalTitle}\n modalType={modalType}\n onClose={() => onClose(value, fileName, errors)}\n onConfirm={() => onSave(value, fileName, errors)}\n onReject={() => onReject(value, fileName, errors)}\n rejectLabel={rejectLabel}\n size={size}\n style={style}\n >\n {editor}\n </DSModal>\n );\n};\n\nconst codeEditorProps = {\n containerProps: PropTypes.object.description('Set of Properties attached to the main container'),\n value: PropTypes.string.description('editors content').isRequired,\n onSave: PropTypes.func.description('function called when the user press save'),\n onClose: PropTypes.func.description('function called when the user closes the modal'),\n onReject: PropTypes.func.description('function called when is rejected'),\n onChange: PropTypes.func.description('function executed when code editor value changes').isRequired,\n isOpen: PropTypes.bool.description('Whether the modal is opened or not').defaultValue(false),\n fileName: PropTypes.string.description('File name to open in the editor'),\n maxLines: PropTypes.number.description('Max lines in the editor content').defaultValue(20),\n minLines: PropTypes.number.description('Min lines in the editor content').defaultValue(20),\n modalTitle: PropTypes.string.description('Modal title').defaultValue('Javascript Editor'),\n confirmLabel: PropTypes.string.description('Customize modal confirm label').defaultValue('Save'),\n rejectLabel: PropTypes.string.description('Customize modal rejection label').defaultValue('Close'),\n modalType: PropTypes.oneOf(modalTypes).description('Modal type').defaultValue('confirm'),\n size: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge'])\n .description('modal size')\n .defaultValue('large'),\n style: PropTypes.object.description('css inline style'),\n useModal: PropTypes.bool.description('whether to use code editor inside modal or not').defaultValue(true),\n showHeader: PropTypes.bool.description('show editors header').defaultValue(true),\n showSyntaxChecks: PropTypes.bool.description('show syntax warnings and checks').defaultValue(true),\n};\n\nDSCodeEditor.propTypes = codeEditorProps;\nDSCodeEditor.displayName = 'DSCodeEditor';\nconst CodeEditorWithSchema = describe(DSCodeEditor);\nCodeEditorWithSchema.propTypes = codeEditorProps;\n\nexport { CodeEditorWithSchema, DSCodeEditor };\nexport default DSCodeEditor;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACqCnB,mBACiB,KADjB;AApCJ,SAAgB,UAAU,cAAc;AACxC,SAAS,UAAU,iBAAiB;AACpC,SAAS,SAAS,kBAAkB;AACpC,SAAS,WAAW,iBAAiB;AACrC,OAAO,sBAAsB;AAC7B,OAAO;AACP,OAAO;AACP,MAAM,eAAe,CAAC;AAAA,EACpB,iBAAiB,CAAC;AAAA,EAClB,OAAO,eAAe;AAAA,EACtB,SAAS,MAAM;AAAA,EACf,UAAU,MAAM;AAAA,EAChB,WAAW,MAAM;AAAA,EACjB,WAAW,MAAM;AAAA,EACjB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,eAAe;AAAA,EACf,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,OAAO;AAAA,EACP,QAAQ,CAAC;AAAA,EACT,WAAW;AAAA,EACX,aAAa;AAAA,EACb,mBAAmB;AACrB,MAAM;AACJ,QAAM,CAAC,EAAE,OAAO,OAAO,GAAG,QAAQ,IAAI,SAAS;AAAA,IAC7C,OAAO;AAAA,IACP,QAAQ,CAAC;AAAA,EACX,CAAC;AACD,QAAM,oBAAoB,OAAO;AAEjC,QAAM,OAAQ,WAAmB,WAAW;AAC5C,QAAM,SACJ,iCACG;AAAA,kBAAc,oBAAC,oBAAiB,UAAoB,mBAAsC;AAAA,IAC3F;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,aAAa,EAAE,iBAAiB,KAAK;AAAA,QACrC;AAAA,QACA;AAAA,QACA,MAAK;AAAA,QACL,MAAK;AAAA,QACL,UAAU,CAAC,QAAQ;AACjB,mBAAS,EAAE,QAAQ,OAAO,IAAI,CAAC;AAC/B,mBAAS,KAAK,MAAM;AA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AiC,EAAE,aAAa,OAAO;AAAA,EACjG,WAAW,UAAU,MAAM,UAAU,EAAE,YAAY,YAAY,EAAE,aAAa,SAAS;AAAA,EACvF,MAAM,UAAU,MAAM,CAAC,UAAU,SAAS,UAAU,SAAS,QAAQ,CAAC,EACnE,YAAY,YAAY,EACxB,aAAa,OAAO;AAAA,EACvB,OAAO,UAAU,OAAO,YAAY,kBAAkB;AAAA,EACtD,UAAU,UAAU,KAAK,YAAY,gDAAgD,EAAE,aAAa,IAAI;AAAA,EACxG,YAAY,UAAU,KAAK,YAAY,qBAAqB,EAAE,aAAa,IAAI;AAAA,EAC/E,kBAAkB,UAAU,KAAK,YAAY,iCAAiC,EAAE,aAAa,IAAI;AACnG;AAEA,aAAa,YAAY;AACzB,aAAa,cAAc;AAC3B,MAAM,uBAAuB,SAAS,YAAY;AAClD,qBAAqB,YAAY;AAGjC,IAAO,uBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Component } from "react";
|
|
4
|
+
import { DSButton } from "@elliemae/ds-button";
|
|
5
|
+
import { DSCheckbox, DSTextBox, DSInputGroup } from "@elliemae/ds-form";
|
|
6
|
+
import { convertPropToCssClassName, aggregatedClasses } from "@elliemae/ds-classnames";
|
|
7
|
+
import { ChevronSmallLeft, ChevronSmallRight } from "@elliemae/ds-icons";
|
|
8
|
+
const blockName = "code-editor";
|
|
9
|
+
const { cssClassName, classNameBlock } = convertPropToCssClassName(blockName);
|
|
10
|
+
const CheckOptionsGroup = aggregatedClasses("div")(`${blockName}-options-group`);
|
|
11
|
+
class DSCodeEditorForm extends Component {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.state = {
|
|
15
|
+
find: false,
|
|
16
|
+
replace: false,
|
|
17
|
+
isCaseSensitive: false,
|
|
18
|
+
isWholeWord: false,
|
|
19
|
+
filteredText: "",
|
|
20
|
+
replaceText: ""
|
|
21
|
+
};
|
|
22
|
+
this.searchWord = this.searchWord.bind(this);
|
|
23
|
+
}
|
|
24
|
+
searchWord(isReplace, all) {
|
|
25
|
+
const {
|
|
26
|
+
reactAceComponent: {
|
|
27
|
+
current: { editor }
|
|
28
|
+
}
|
|
29
|
+
} = this.props;
|
|
30
|
+
const { isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;
|
|
31
|
+
const options = {
|
|
32
|
+
backwards: false,
|
|
33
|
+
wrap: true,
|
|
34
|
+
caseSensitive: isCaseSensitive,
|
|
35
|
+
wholeWord: isWholeWord,
|
|
36
|
+
regExp: true
|
|
37
|
+
};
|
|
38
|
+
editor.find(filteredText, options);
|
|
39
|
+
const selectedContent = editor.getSelectedText();
|
|
40
|
+
if (isReplace && replaceText && selectedContent) {
|
|
41
|
+
if (all) {
|
|
42
|
+
editor.findAll(filteredText, options);
|
|
43
|
+
editor.replaceAll(replaceText);
|
|
44
|
+
} else {
|
|
45
|
+
const range = editor.selection.getRange();
|
|
46
|
+
editor.session.replace(range, replaceText);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
const { fileName } = this.props;
|
|
52
|
+
const { find, replace, isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;
|
|
53
|
+
return /* @__PURE__ */ jsxs("div", { className: `${cssClassName}`, children: [
|
|
54
|
+
fileName ? /* @__PURE__ */ jsxs("div", { className: classNameBlock("file-name"), children: [
|
|
55
|
+
"File Name: ",
|
|
56
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
57
|
+
" ",
|
|
58
|
+
fileName,
|
|
59
|
+
" "
|
|
60
|
+
] })
|
|
61
|
+
] }) : null,
|
|
62
|
+
/* @__PURE__ */ jsxs("div", { className: classNameBlock("find-replace-btn"), children: [
|
|
63
|
+
!find && !replace ? /* @__PURE__ */ jsx(DSButton, { buttonType: "secondary", labelText: "Find", onClick: () => this.setState({ find: true }), size: "m" }) : null,
|
|
64
|
+
!replace ? /* @__PURE__ */ jsx(
|
|
65
|
+
DSButton,
|
|
66
|
+
{
|
|
67
|
+
buttonType: "secondary",
|
|
68
|
+
labelText: "Find & Replace",
|
|
69
|
+
onClick: () => this.setState({ replace: true }),
|
|
70
|
+
size: "m"
|
|
71
|
+
}
|
|
72
|
+
) : null
|
|
73
|
+
] }),
|
|
74
|
+
find || replace ? /* @__PURE__ */ jsxs(DSInputGroup, { className: classNameBlock("find"), children: [
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
DSTextBox,
|
|
77
|
+
{
|
|
78
|
+
className: "find-word",
|
|
79
|
+
fluidWidth: false,
|
|
80
|
+
id: "find-textbox",
|
|
81
|
+
onChange: (e) => this.setState({ filteredText: e.currentTarget.value }),
|
|
82
|
+
placeholder: "Find",
|
|
83
|
+
rightComponent: /* @__PURE__ */ jsxs("div", { className: classNameBlock("next-back-btn"), children: [
|
|
84
|
+
/* @__PURE__ */ jsx(DSButton, { icon: /* @__PURE__ */ jsx(ChevronSmallLeft, {}), size: "m" }),
|
|
85
|
+
/* @__PURE__ */ jsx(DSButton, { icon: /* @__PURE__ */ jsx(ChevronSmallRight, {}), onClick: () => this.searchWord(), size: "m" })
|
|
86
|
+
] }),
|
|
87
|
+
value: filteredText
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ jsxs(CheckOptionsGroup, { children: [
|
|
91
|
+
/* @__PURE__ */ jsx(
|
|
92
|
+
DSCheckbox,
|
|
93
|
+
{
|
|
94
|
+
checked: isCaseSensitive,
|
|
95
|
+
id: "case-sensitive-check",
|
|
96
|
+
labelText: "Case Sensitive",
|
|
97
|
+
name: "case-sensitive-check",
|
|
98
|
+
onChange: () => this.setState({ isCaseSensitive: !isCaseSensitive })
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsx(
|
|
102
|
+
DSCheckbox,
|
|
103
|
+
{
|
|
104
|
+
checked: isWholeWord,
|
|
105
|
+
id: "whole-word-check",
|
|
106
|
+
labelText: "Whole Word",
|
|
107
|
+
name: "whole-word-check",
|
|
108
|
+
onChange: () => this.setState({ isWholeWord: !isWholeWord })
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ jsx(
|
|
112
|
+
DSCheckbox,
|
|
113
|
+
{
|
|
114
|
+
checked: replace,
|
|
115
|
+
id: "replace-check",
|
|
116
|
+
labelText: "Replace",
|
|
117
|
+
name: "replace-check",
|
|
118
|
+
onChange: () => this.setState({ replace: !replace })
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
] }),
|
|
122
|
+
/* @__PURE__ */ jsx(
|
|
123
|
+
DSButton,
|
|
124
|
+
{
|
|
125
|
+
buttonType: "secondary",
|
|
126
|
+
labelText: "Done",
|
|
127
|
+
onClick: () => this.setState({ replace: false, find: false }),
|
|
128
|
+
size: "m"
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
] }) : null,
|
|
132
|
+
replace ? /* @__PURE__ */ jsxs("div", { className: classNameBlock("replace"), children: [
|
|
133
|
+
/* @__PURE__ */ jsx(
|
|
134
|
+
DSTextBox,
|
|
135
|
+
{
|
|
136
|
+
className: "find-word",
|
|
137
|
+
fluidWidth: false,
|
|
138
|
+
id: "replace-textbox",
|
|
139
|
+
onChange: (e) => this.setState({ replaceText: e.currentTarget.value }),
|
|
140
|
+
placeholder: "Replace",
|
|
141
|
+
value: replaceText
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ jsxs("div", { className: classNameBlock("replace-btns"), children: [
|
|
145
|
+
/* @__PURE__ */ jsx(
|
|
146
|
+
DSButton,
|
|
147
|
+
{
|
|
148
|
+
buttonType: "secondary",
|
|
149
|
+
labelText: "Replace",
|
|
150
|
+
onClick: () => this.searchWord(true, false),
|
|
151
|
+
size: "m"
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ jsx(
|
|
155
|
+
DSButton,
|
|
156
|
+
{
|
|
157
|
+
buttonType: "secondary",
|
|
158
|
+
labelText: "Replace All",
|
|
159
|
+
onClick: () => this.searchWord(true, true),
|
|
160
|
+
size: "m"
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
] })
|
|
164
|
+
] }) : null
|
|
165
|
+
] });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
var DSCodeEditorForm_default = DSCodeEditorForm;
|
|
169
|
+
export {
|
|
170
|
+
DSCodeEditorForm_default as default
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=DSCodeEditorForm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/DSCodeEditorForm.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\n/* eslint-disable max-lines */\nimport React, { Component } from 'react';\nimport { DSButton } from '@elliemae/ds-button';\nimport { DSCheckbox, DSTextBox, DSInputGroup } from '@elliemae/ds-form';\nimport { convertPropToCssClassName, aggregatedClasses } from '@elliemae/ds-classnames';\nimport { ChevronSmallLeft, ChevronSmallRight } from '@elliemae/ds-icons';\n\nconst blockName = 'code-editor';\n\nconst { cssClassName, classNameBlock } = convertPropToCssClassName(blockName);\n\nconst CheckOptionsGroup = aggregatedClasses('div')(`${blockName}-options-group`);\n\nclass DSCodeEditorForm extends Component {\n constructor(props) {\n super(props);\n this.state = {\n find: false,\n replace: false,\n isCaseSensitive: false,\n isWholeWord: false,\n filteredText: '',\n replaceText: '',\n };\n\n this.searchWord = this.searchWord.bind(this);\n }\n\n searchWord(isReplace, all) {\n const {\n reactAceComponent: {\n current: { editor },\n },\n } = this.props;\n const { isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;\n const options = {\n backwards: false,\n wrap: true,\n caseSensitive: isCaseSensitive,\n wholeWord: isWholeWord,\n regExp: true,\n };\n editor.find(filteredText, options);\n const selectedContent = editor.getSelectedText();\n if (isReplace && replaceText && selectedContent) {\n if (all) {\n editor.findAll(filteredText, options);\n editor.replaceAll(replaceText);\n } else {\n const range = editor.selection.getRange();\n editor.session.replace(range, replaceText);\n }\n }\n }\n\n render() {\n const { fileName } = this.props;\n\n const { find, replace, isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;\n return (\n <div className={`${cssClassName}`}>\n {fileName ? (\n <div className={classNameBlock('file-name')}>\n File Name: <span> {fileName} </span>\n </div>\n ) : null}\n <div className={classNameBlock('find-replace-btn')}>\n {!find && !replace ? (\n <DSButton buttonType=\"secondary\" labelText=\"Find\" onClick={() => this.setState({ find: true })} size=\"m\" />\n ) : null}\n {!replace ? (\n <DSButton\n buttonType=\"secondary\"\n labelText=\"Find & Replace\"\n onClick={() => this.setState({ replace: true })}\n size=\"m\"\n />\n ) : null}\n </div>\n {find || replace ? (\n <DSInputGroup className={classNameBlock('find')}>\n <DSTextBox\n className=\"find-word\"\n fluidWidth={false}\n id=\"find-textbox\"\n onChange={(e) => this.setState({ filteredText: e.currentTarget.value })}\n placeholder=\"Find\"\n rightComponent={\n <div className={classNameBlock('next-back-btn')}>\n <DSButton icon={<ChevronSmallLeft />} size=\"m\" />\n <DSButton icon={<ChevronSmallRight />} onClick={() => this.searchWord()} size=\"m\" />\n </div>\n }\n value={filteredText}\n />\n <CheckOptionsGroup>\n <DSCheckbox\n checked={isCaseSensitive}\n id=\"case-sensitive-check\"\n labelText=\"Case Sensitive\"\n name=\"case-sensitive-check\"\n onChange={() => this.setState({ isCaseSensitive: !isCaseSensitive })}\n />\n <DSCheckbox\n checked={isWholeWord}\n id=\"whole-word-check\"\n labelText=\"Whole Word\"\n name=\"whole-word-check\"\n onChange={() => this.setState({ isWholeWord: !isWholeWord })}\n />\n <DSCheckbox\n checked={replace}\n id=\"replace-check\"\n labelText=\"Replace\"\n name=\"replace-check\"\n onChange={() => this.setState({ replace: !replace })}\n />\n </CheckOptionsGroup>\n <DSButton\n buttonType=\"secondary\"\n labelText=\"Done\"\n onClick={() => this.setState({ replace: false, find: false })}\n size=\"m\"\n />\n </DSInputGroup>\n ) : null}\n {replace ? (\n <div className={classNameBlock('replace')}>\n <DSTextBox\n className=\"find-word\"\n fluidWidth={false}\n id=\"replace-textbox\"\n onChange={(e) => this.setState({ replaceText: e.currentTarget.value })}\n placeholder=\"Replace\"\n value={replaceText}\n />\n <div className={classNameBlock('replace-btns')}>\n <DSButton\n buttonType=\"secondary\"\n labelText=\"Replace\"\n onClick={() => this.searchWord(true, false)}\n size=\"m\"\n />\n <DSButton\n buttonType=\"secondary\"\n labelText=\"Replace All\"\n onClick={() => this.searchWord(true, true)}\n size=\"m\"\n />\n </div>\n </div>\n ) : null}\n </div>\n );\n }\n}\n\nexport default DSCodeEditorForm;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACgEA,SAKX,KALW;AA9DvB,SAAgB,iBAAiB;AACjC,SAAS,gBAAgB;AACzB,SAAS,YAAY,WAAW,oBAAoB;AACpD,SAAS,2BAA2B,yBAAyB;AAC7D,SAAS,kBAAkB,yBAAyB;AAEpD,MAAM,YAAY;AAElB,MAAM,EAAE,cAAc,eAAe,IAAI,0BAA0B,SAAS;AAE5E,MAAM,oBAAoB,kBAAkB,KAAK,EAAE,GAAG,yBAAyB;AAE/E,MAAM,yBAAyB,UAAU;AAAA,EACvC,YAAY,OAAO;AACjB,UAAM,KAAK;AACX,SAAK,QAAQ;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,iBAAiB;AAAA,MACjB,aAAa;AAAA,MACb,cAAc;AAAA,MACd,aAAa;AAAA,IACf;AAEA,SAAK,aAAa,KAAK,WAAW,KAAK,IAAI;AAAA,EAC7C;AAAA,EAEA,WAAW,WAAW,KAAK;AACzB,UAAM;AAAA,MACJ,mBAAmB;AAAA,QACjB,SAAS,EAAE,OAAO;AA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I,WAAW,eAAe,SAAS,GACtC;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,YAAY;AAAA,YACZ,IAAG;AAAA,YACH,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,aAAa,EAAE,cAAc,MAAM,CAAC;AAAA,YACrE,aAAY;AAAA,YACZ,OAAO;AAAA;AAAA,QACT;AAAA,QACA,qBAAC,SAAI,WAAW,eAAe,cAAc,GAC3C;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,YAAW;AAAA,cACX,WAAU;AAAA,cACV,SAAS,MAAM,KAAK,WAAW,MAAM,KAAK;AAAA,cAC1C,MAAK;AAAA;AAAA,UACP;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,YAAW;AAAA,cACX,WAAU;AAAA,cACV,SAAS,MAAM,KAAK,WAAW,MAAM,IAAI;AAAA,cACzC,MAAK;AAAA;AAAA,UACP;AAAA,WACF;AAAA,SACF,IACE;AAAA,OACN;AAAA,EAEJ;AACF;AAEA,IAAO,2BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React2, { Component } from "react";
|
|
4
|
+
import { default as AceEditor } from "react-ace";
|
|
5
|
+
import { DSModal } from "@elliemae/ds-modal";
|
|
6
|
+
import DSCodeEditorForm from "./DSCodeEditorForm.js";
|
|
7
|
+
import "ace-builds/src-noconflict/mode-javascript.js";
|
|
8
|
+
import "ace-builds/src-noconflict/theme-tomorrow.js";
|
|
9
|
+
class DSCodeEditorImpl extends Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.state = {
|
|
13
|
+
value: props.value,
|
|
14
|
+
errors: []
|
|
15
|
+
};
|
|
16
|
+
this.reactAceComponent = React2.createRef();
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
const {
|
|
20
|
+
onSave,
|
|
21
|
+
onClose,
|
|
22
|
+
onReject,
|
|
23
|
+
isOpen,
|
|
24
|
+
fileName,
|
|
25
|
+
confirmLabel,
|
|
26
|
+
maxLines,
|
|
27
|
+
minLines,
|
|
28
|
+
modalTitle,
|
|
29
|
+
modalType,
|
|
30
|
+
rejectLabel,
|
|
31
|
+
size,
|
|
32
|
+
style,
|
|
33
|
+
containerProps
|
|
34
|
+
} = this.props;
|
|
35
|
+
const { value, errors } = this.state;
|
|
36
|
+
const Comp = AceEditor?.default ?? AceEditor;
|
|
37
|
+
return /* @__PURE__ */ jsxs(
|
|
38
|
+
DSModal,
|
|
39
|
+
{
|
|
40
|
+
centered: false,
|
|
41
|
+
confirmLabel,
|
|
42
|
+
containerProps,
|
|
43
|
+
isOpen,
|
|
44
|
+
modalTitle,
|
|
45
|
+
modalType,
|
|
46
|
+
onClose: () => onClose(value, fileName, errors),
|
|
47
|
+
onConfirm: () => onSave(value, fileName, errors),
|
|
48
|
+
onReject: () => onReject(value, fileName, errors),
|
|
49
|
+
rejectLabel,
|
|
50
|
+
size,
|
|
51
|
+
style,
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsx(DSCodeEditorForm, { fileName, reactAceComponent: this.reactAceComponent }),
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
Comp,
|
|
56
|
+
{
|
|
57
|
+
ref: this.reactAceComponent,
|
|
58
|
+
editorProps: { $blockScrolling: true },
|
|
59
|
+
maxLines,
|
|
60
|
+
minLines,
|
|
61
|
+
mode: "javascript",
|
|
62
|
+
name: "ace-code-edior",
|
|
63
|
+
onChange: (val) => this.setState({ value: val }),
|
|
64
|
+
onValidate: (annotations) => this.setState({ errors: annotations }),
|
|
65
|
+
theme: "tomorrow",
|
|
66
|
+
value
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
var DSCodeEditorImpl_default = DSCodeEditorImpl;
|
|
75
|
+
export {
|
|
76
|
+
DSCodeEditorImpl_default as default
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=DSCodeEditorImpl.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/DSCodeEditorImpl.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { Component } from 'react';\nimport { default as AceEditor } from 'react-ace';\nimport { DSModal } from '@elliemae/ds-modal';\nimport DSCodeEditorForm from './DSCodeEditorForm.js';\nimport 'ace-builds/src-noconflict/mode-javascript.js';\nimport 'ace-builds/src-noconflict/theme-tomorrow.js';\n\nclass DSCodeEditorImpl extends Component {\n constructor(props) {\n super(props);\n this.state = {\n value: props.value,\n errors: [],\n };\n this.reactAceComponent = React.createRef();\n }\n\n render() {\n const {\n onSave,\n onClose,\n onReject,\n isOpen,\n fileName,\n confirmLabel,\n maxLines,\n minLines,\n modalTitle,\n modalType,\n rejectLabel,\n size,\n style,\n containerProps,\n } = this.props;\n\n const { value, errors } = this.state;\n const Comp = (AceEditor as any)?.default ?? AceEditor;\n return (\n <DSModal\n centered={false}\n confirmLabel={confirmLabel}\n containerProps={containerProps}\n isOpen={isOpen}\n modalTitle={modalTitle}\n modalType={modalType}\n onClose={() => onClose(value, fileName, errors)}\n onConfirm={() => onSave(value, fileName, errors)}\n onReject={() => onReject(value, fileName, errors)}\n rejectLabel={rejectLabel}\n size={size}\n style={style}\n >\n <DSCodeEditorForm fileName={fileName} reactAceComponent={this.reactAceComponent} />\n <Comp\n ref={this.reactAceComponent}\n editorProps={{ $blockScrolling: true }}\n maxLines={maxLines}\n minLines={minLines}\n mode=\"javascript\"\n name=\"ace-code-edior\"\n onChange={(val) => this.setState({ value: val })}\n onValidate={(annotations) => this.setState({ errors: annotations })}\n theme=\"tomorrow\"\n value={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S,EAAE,OAAO,IAAI,CAAC;AAAA,cAC/C,YAAY,CAAC,gBAAgB,KAAK,SAAS,EAAE,QAAQ,YAAY,CAAC;AAAA,cAClE,OAAM;AAAA,cACN;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,IAAO,2BAAQ;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { default as default2 } from "@elliemae/ds-legacy-codeeditor";
|
|
2
|
+
import { default as default2, DSCodeEditor, CodeEditorWithSchema } from "./DSCodeEditor.js";
|
|
4
3
|
export {
|
|
4
|
+
CodeEditorWithSchema,
|
|
5
|
+
DSCodeEditor,
|
|
5
6
|
default2 as default
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default, DSCodeEditor, CodeEditorWithSchema } from './DSCodeEditor.js';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,WAAAA,UAAS,cAAc,4BAA4B;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import 'ace-builds/src-noconflict/mode-javascript.js';
|
|
2
|
+
import 'ace-builds/src-noconflict/theme-tomorrow.js';
|
|
3
|
+
declare const DSCodeEditor: {
|
|
4
|
+
({ containerProps, value: defaultValue, onSave, onClose, onReject, onChange, isOpen, fileName, confirmLabel, maxLines, minLines, modalTitle, modalType, rejectLabel, size, style, useModal, showHeader, showSyntaxChecks, }: {
|
|
5
|
+
containerProps?: {} | undefined;
|
|
6
|
+
value?: string | undefined;
|
|
7
|
+
onSave?: (() => null) | undefined;
|
|
8
|
+
onClose?: (() => null) | undefined;
|
|
9
|
+
onReject?: (() => null) | undefined;
|
|
10
|
+
onChange?: (() => null) | undefined;
|
|
11
|
+
isOpen?: boolean | undefined;
|
|
12
|
+
fileName?: string | undefined;
|
|
13
|
+
confirmLabel?: string | undefined;
|
|
14
|
+
maxLines?: number | undefined;
|
|
15
|
+
minLines?: number | undefined;
|
|
16
|
+
modalTitle?: string | undefined;
|
|
17
|
+
modalType?: string | undefined;
|
|
18
|
+
rejectLabel?: string | undefined;
|
|
19
|
+
size?: string | undefined;
|
|
20
|
+
style?: {} | undefined;
|
|
21
|
+
useModal?: boolean | undefined;
|
|
22
|
+
showHeader?: boolean | undefined;
|
|
23
|
+
showSyntaxChecks?: boolean | undefined;
|
|
24
|
+
}): import("react/jsx-runtime.js").JSX.Element;
|
|
25
|
+
propTypes: {
|
|
26
|
+
containerProps: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
27
|
+
value: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
28
|
+
onSave: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
29
|
+
onClose: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
30
|
+
onReject: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
31
|
+
onChange: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
32
|
+
isOpen: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
33
|
+
fileName: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
34
|
+
maxLines: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
35
|
+
minLines: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
36
|
+
modalTitle: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
37
|
+
confirmLabel: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
38
|
+
rejectLabel: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
39
|
+
modalType: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
40
|
+
size: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
41
|
+
style: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
42
|
+
useModal: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
43
|
+
showHeader: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
44
|
+
showSyntaxChecks: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").ReactDescT;
|
|
45
|
+
};
|
|
46
|
+
displayName: string;
|
|
47
|
+
};
|
|
48
|
+
declare const CodeEditorWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<{
|
|
49
|
+
containerProps?: {} | undefined;
|
|
50
|
+
value?: string | undefined;
|
|
51
|
+
onSave?: (() => null) | undefined;
|
|
52
|
+
onClose?: (() => null) | undefined;
|
|
53
|
+
onReject?: (() => null) | undefined;
|
|
54
|
+
onChange?: (() => null) | undefined;
|
|
55
|
+
isOpen?: boolean | undefined;
|
|
56
|
+
fileName?: string | undefined;
|
|
57
|
+
confirmLabel?: string | undefined;
|
|
58
|
+
maxLines?: number | undefined;
|
|
59
|
+
minLines?: number | undefined;
|
|
60
|
+
modalTitle?: string | undefined;
|
|
61
|
+
modalType?: string | undefined;
|
|
62
|
+
rejectLabel?: string | undefined;
|
|
63
|
+
size?: string | undefined;
|
|
64
|
+
style?: {} | undefined;
|
|
65
|
+
useModal?: boolean | undefined;
|
|
66
|
+
showHeader?: boolean | undefined;
|
|
67
|
+
showSyntaxChecks?: boolean | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
export { CodeEditorWithSchema, DSCodeEditor };
|
|
70
|
+
export default DSCodeEditor;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import 'ace-builds/src-noconflict/mode-javascript.js';
|
|
3
|
+
import 'ace-builds/src-noconflict/theme-tomorrow.js';
|
|
4
|
+
declare class DSCodeEditorImpl extends Component {
|
|
5
|
+
constructor(props: any);
|
|
6
|
+
render(): import("react/jsx-runtime.js").JSX.Element;
|
|
7
|
+
}
|
|
8
|
+
export default DSCodeEditorImpl;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { default } from '@elliemae/ds-legacy-codeeditor';
|
|
1
|
+
export { default, DSCodeEditor, CodeEditorWithSchema } from './DSCodeEditor.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-codeeditor",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.33.0-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Code Editor",
|
|
6
6
|
"files": [
|
|
@@ -35,12 +35,19 @@
|
|
|
35
35
|
"indent": 4
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"
|
|
38
|
+
"ace-builds": "~1.16.0",
|
|
39
|
+
"react-ace": "~10.1.0",
|
|
40
|
+
"@elliemae/ds-button": "3.33.0-next.1",
|
|
41
|
+
"@elliemae/ds-classnames": "3.33.0-next.1",
|
|
42
|
+
"@elliemae/ds-icons": "3.33.0-next.1",
|
|
43
|
+
"@elliemae/ds-props-helpers": "3.33.0-next.1",
|
|
44
|
+
"@elliemae/ds-form": "3.33.0-next.1",
|
|
45
|
+
"@elliemae/ds-modal": "3.33.0-next.1"
|
|
39
46
|
},
|
|
40
47
|
"devDependencies": {
|
|
41
48
|
"@elliemae/pui-cli": "~9.0.0-next.31",
|
|
42
49
|
"styled-components": "~5.3.9",
|
|
43
|
-
"@elliemae/ds-monorepo-devops": "3.
|
|
50
|
+
"@elliemae/ds-monorepo-devops": "3.33.0-next.1"
|
|
44
51
|
},
|
|
45
52
|
"peerDependencies": {
|
|
46
53
|
"lodash": "^4.17.21",
|