@elliemae/ds-codeeditor 3.0.0-next.1 → 3.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { Component } from "react";
|
|
3
|
+
import DSButton from "@elliemae/ds-button";
|
|
4
|
+
import { DSCheckbox, DSTextBox, DSInputGroup } from "@elliemae/ds-form";
|
|
5
|
+
import { convertPropToCssClassName, aggregatedClasses } from "@elliemae/ds-classnames";
|
|
6
|
+
import { ChevronSmallLeft, ChevronSmallRight } from "@elliemae/ds-icons";
|
|
7
|
+
const blockName = "code-editor";
|
|
8
|
+
const { cssClassName, classNameBlock } = convertPropToCssClassName(blockName);
|
|
9
|
+
const CheckOptionsGroup = aggregatedClasses("div")(`${blockName}-options-group`);
|
|
10
|
+
class DSCodeEditorForm extends Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.state = {
|
|
14
|
+
find: false,
|
|
15
|
+
replace: false,
|
|
16
|
+
isCaseSensitive: false,
|
|
17
|
+
isWholeWord: false,
|
|
18
|
+
filteredText: "",
|
|
19
|
+
replaceText: ""
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
searchWord(isReplace, all) {
|
|
23
|
+
const {
|
|
24
|
+
reactAceComponent: {
|
|
25
|
+
current: { editor }
|
|
26
|
+
}
|
|
27
|
+
} = this.props;
|
|
28
|
+
const { isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;
|
|
29
|
+
const options = {
|
|
30
|
+
backwards: false,
|
|
31
|
+
wrap: true,
|
|
32
|
+
caseSensitive: isCaseSensitive,
|
|
33
|
+
wholeWord: isWholeWord,
|
|
34
|
+
regExp: true
|
|
35
|
+
};
|
|
36
|
+
editor.find(filteredText, options);
|
|
37
|
+
const selectedContent = editor.getSelectedText();
|
|
38
|
+
if (isReplace && replaceText && selectedContent) {
|
|
39
|
+
if (all) {
|
|
40
|
+
editor.findAll(filteredText, options);
|
|
41
|
+
editor.replaceAll(replaceText);
|
|
42
|
+
} else {
|
|
43
|
+
const range = editor.selection.getRange();
|
|
44
|
+
editor.session.replace(range, replaceText);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
render() {
|
|
49
|
+
const { fileName } = this.props;
|
|
50
|
+
const { find, replace, isCaseSensitive, isWholeWord, filteredText, replaceText } = this.state;
|
|
51
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
52
|
+
className: `${cssClassName}`
|
|
53
|
+
}, fileName ? /* @__PURE__ */ React2.createElement("div", {
|
|
54
|
+
className: classNameBlock("file-name")
|
|
55
|
+
}, "File Name: ", /* @__PURE__ */ React2.createElement("span", null, " ", fileName, " ")) : null, /* @__PURE__ */ React2.createElement("div", {
|
|
56
|
+
className: classNameBlock("find-replace-btn")
|
|
57
|
+
}, !find && !replace ? /* @__PURE__ */ React2.createElement(DSButton, {
|
|
58
|
+
buttonType: "secondary",
|
|
59
|
+
labelText: "Find",
|
|
60
|
+
onClick: () => this.setState({ find: true }),
|
|
61
|
+
size: "m"
|
|
62
|
+
}) : null, !replace ? /* @__PURE__ */ React2.createElement(DSButton, {
|
|
63
|
+
buttonType: "secondary",
|
|
64
|
+
labelText: "Find & Replace",
|
|
65
|
+
onClick: () => this.setState({ replace: true }),
|
|
66
|
+
size: "m"
|
|
67
|
+
}) : null), find || replace ? /* @__PURE__ */ React2.createElement(DSInputGroup, {
|
|
68
|
+
className: classNameBlock("find")
|
|
69
|
+
}, /* @__PURE__ */ React2.createElement(DSTextBox, {
|
|
70
|
+
className: "find-word",
|
|
71
|
+
fluidWidth: false,
|
|
72
|
+
id: "find-textbox",
|
|
73
|
+
onChange: (e) => this.setState({ filteredText: e.currentTarget.value }),
|
|
74
|
+
placeholder: "Find",
|
|
75
|
+
rightComponent: /* @__PURE__ */ React2.createElement("div", {
|
|
76
|
+
className: classNameBlock("next-back-btn")
|
|
77
|
+
}, /* @__PURE__ */ React2.createElement(DSButton, {
|
|
78
|
+
icon: /* @__PURE__ */ React2.createElement(ChevronSmallLeft, null),
|
|
79
|
+
size: "m"
|
|
80
|
+
}), /* @__PURE__ */ React2.createElement(DSButton, {
|
|
81
|
+
icon: /* @__PURE__ */ React2.createElement(ChevronSmallRight, null),
|
|
82
|
+
onClick: () => this.searchWord(),
|
|
83
|
+
size: "m"
|
|
84
|
+
})),
|
|
85
|
+
value: filteredText
|
|
86
|
+
}), /* @__PURE__ */ React2.createElement(CheckOptionsGroup, null, /* @__PURE__ */ React2.createElement(DSCheckbox, {
|
|
87
|
+
checked: isCaseSensitive,
|
|
88
|
+
id: "case-sensitive-check",
|
|
89
|
+
labelText: "Case Sensitive",
|
|
90
|
+
name: "case-sensitive-check",
|
|
91
|
+
onChange: () => this.setState({ isCaseSensitive: !isCaseSensitive })
|
|
92
|
+
}), /* @__PURE__ */ React2.createElement(DSCheckbox, {
|
|
93
|
+
checked: isWholeWord,
|
|
94
|
+
id: "whole-word-check",
|
|
95
|
+
labelText: "Whole Word",
|
|
96
|
+
name: "whole-word-check",
|
|
97
|
+
onChange: () => this.setState({ isWholeWord: !isWholeWord })
|
|
98
|
+
}), /* @__PURE__ */ React2.createElement(DSCheckbox, {
|
|
99
|
+
checked: replace,
|
|
100
|
+
id: "replace-check",
|
|
101
|
+
labelText: "Replace",
|
|
102
|
+
name: "replace-check",
|
|
103
|
+
onChange: () => this.setState({ replace: !replace })
|
|
104
|
+
})), /* @__PURE__ */ React2.createElement(DSButton, {
|
|
105
|
+
buttonType: "secondary",
|
|
106
|
+
labelText: "Done",
|
|
107
|
+
onClick: () => this.setState({ replace: false, find: false }),
|
|
108
|
+
size: "m"
|
|
109
|
+
})) : null, replace ? /* @__PURE__ */ React2.createElement("div", {
|
|
110
|
+
className: classNameBlock("replace")
|
|
111
|
+
}, /* @__PURE__ */ React2.createElement(DSTextBox, {
|
|
112
|
+
className: "find-word",
|
|
113
|
+
fluidWidth: false,
|
|
114
|
+
id: "replace-textbox",
|
|
115
|
+
onChange: (e) => this.setState({ replaceText: e.currentTarget.value }),
|
|
116
|
+
placeholder: "Replace",
|
|
117
|
+
value: replaceText
|
|
118
|
+
}), /* @__PURE__ */ React2.createElement("div", {
|
|
119
|
+
className: classNameBlock("replace-btns")
|
|
120
|
+
}, /* @__PURE__ */ React2.createElement(DSButton, {
|
|
121
|
+
buttonType: "secondary",
|
|
122
|
+
labelText: "Replace",
|
|
123
|
+
onClick: () => this.searchWord(true, false),
|
|
124
|
+
size: "m"
|
|
125
|
+
}), /* @__PURE__ */ React2.createElement(DSButton, {
|
|
126
|
+
buttonType: "secondary",
|
|
127
|
+
labelText: "Replace All",
|
|
128
|
+
onClick: () => this.searchWord(true, true),
|
|
129
|
+
size: "m"
|
|
130
|
+
}))) : null);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
var DSCodeEditorForm_default = DSCodeEditorForm;
|
|
134
|
+
export {
|
|
135
|
+
DSCodeEditorForm_default as default
|
|
136
|
+
};
|
|
137
|
+
//# 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\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;ACEA;AACA;AACA;AACA;AACA;AAEA,MAAM,YAAY;AAElB,MAAM,EAAE,cAAc,mBAAmB,0BAA0B;AAEnE,MAAM,oBAAoB,kBAAkB,OAAO,GAAG;AAEtD,+BAA+B,UAAU;AAAA,EACvC,YAAY,OAAO;AACjB,UAAM;AACN,SAAK,QAAQ;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,iBAAiB;AAAA,MACjB,aAAa;AAAA,MACb,cAAc;AAAA,MACd,aAAa;AAAA;AAAA;AAAA,EAIjB,WAAW,WAAW,KAAK;AACzB,UAAM;AAAA,MACJ,mBAAmB;AAAA,QACjB,SAAS,EAAE;AAAA;AAAA,QAEX,KAAK;AACT,UAAM,EAAE,iBAAiB,aAAa,cAAc,gBAAgB,KAAK;AACzE,UAAM,UAAU;AAAA,MACd,WAAW;AAAA,MACX,MAAM;AAAA,MACN,eAAe;AAAA,MACf,WAAW;AAAA,MACX,QAAQ;AAAA;AAEV,WAAO,KAAK,cAAc;AAC1B,UAAM,kBAAkB,OAAO;AAC/B,QAAI,aAAa,eAAe,iBAAiB;AAC/C,UAAI,KAAK;AACP,eAAO,QAAQ,cAAc;AAC7B,eAAO,WAAW;AAAA,aACb;AACL,cA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
|
+
import AceEditor from "react-ace";
|
|
4
|
+
import DSModal from "@elliemae/ds-modal";
|
|
5
|
+
import DSCodeEditorForm from "./DSCodeEditorForm";
|
|
6
|
+
import "brace/mode/javascript.js";
|
|
7
|
+
import "brace/theme/tomorrow.js";
|
|
8
|
+
class DSCodeEditorImpl extends Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.state = {
|
|
12
|
+
value: props.value,
|
|
13
|
+
errors: []
|
|
14
|
+
};
|
|
15
|
+
this.reactAceComponent = React2.createRef();
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
const {
|
|
19
|
+
onSave,
|
|
20
|
+
onClose,
|
|
21
|
+
onReject,
|
|
22
|
+
isOpen,
|
|
23
|
+
fileName,
|
|
24
|
+
confirmLabel,
|
|
25
|
+
maxLines,
|
|
26
|
+
minLines,
|
|
27
|
+
modalTitle,
|
|
28
|
+
modalType,
|
|
29
|
+
rejectLabel,
|
|
30
|
+
size,
|
|
31
|
+
style,
|
|
32
|
+
containerProps
|
|
33
|
+
} = this.props;
|
|
34
|
+
const { value, errors } = this.state;
|
|
35
|
+
return /* @__PURE__ */ React2.createElement(DSModal, {
|
|
36
|
+
centered: false,
|
|
37
|
+
confirmLabel,
|
|
38
|
+
containerProps,
|
|
39
|
+
isOpen,
|
|
40
|
+
modalTitle,
|
|
41
|
+
modalType,
|
|
42
|
+
onClose: () => onClose(value, fileName, errors),
|
|
43
|
+
onConfirm: () => onSave(value, fileName, errors),
|
|
44
|
+
onReject: () => onReject(value, fileName, errors),
|
|
45
|
+
rejectLabel,
|
|
46
|
+
size,
|
|
47
|
+
style
|
|
48
|
+
}, /* @__PURE__ */ React2.createElement(DSCodeEditorForm, {
|
|
49
|
+
fileName,
|
|
50
|
+
reactAceComponent: this.reactAceComponent
|
|
51
|
+
}), /* @__PURE__ */ React2.createElement(AceEditor, {
|
|
52
|
+
ref: this.reactAceComponent,
|
|
53
|
+
editorProps: { $blockScrolling: true },
|
|
54
|
+
maxLines,
|
|
55
|
+
minLines,
|
|
56
|
+
mode: "javascript",
|
|
57
|
+
name: "ace-code-edior",
|
|
58
|
+
onChange: (val) => this.setState({ value: val }),
|
|
59
|
+
onValidate: (annotations) => this.setState({ errors: annotations }),
|
|
60
|
+
theme: "tomorrow",
|
|
61
|
+
value
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
var DSCodeEditorImpl_default = DSCodeEditorImpl;
|
|
66
|
+
export {
|
|
67
|
+
DSCodeEditorImpl_default as default
|
|
68
|
+
};
|
|
69
|
+
//# 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 AceEditor from 'react-ace';\nimport DSModal from '@elliemae/ds-modal';\nimport DSCodeEditorForm from './DSCodeEditorForm';\nimport 'brace/mode/javascript.js';\nimport 'brace/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 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\n fileName={fileName}\n reactAceComponent={this.reactAceComponent}\n />\n <AceEditor\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 DSCodeEditorImpl;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AAEA,+BAA+B,UAAU;AAAA,EACvC,YAAY,OAAO;AACjB,UAAM;AACN,SAAK,QAAQ;AAAA,MACX,OAAO,MAAM;AAAA,MACb,QAAQ;AAAA;AAEV,SAAK,oBAAoB,OAAM;AAAA;AAAA,EAGjC,SAAS;AACP,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACE,KAAK;AAET,UAAM,EAAE,OAAO,WAAW,KAAK;AAC/B,WACE,qCAAC,SAAD;AAAA,MACE,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,MAAM,QAAQ,OAAO,UAAU;AAAA,MACxC,WAAW,MAAM,OAAO,OAAO,UAAU;AAAA,MACzC,UAAU,MAAM,SAAS,OAAO,UAAU;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,OAEA,qCAAC,kBAAD;AAAA,MACE;AAAA,MACA,mBAAmB,KAAK;AAAA,QAE1B,qCAAC,WAAD;AAAA,MACE,KAAK,KAAK;AAAA,MACV,aAAa,EAAE,iBAAiB;AAAA,MAChC;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MACL,MAAK;AAAA,MACL,UAAU,SAAO,KAAK,SAAS,EAAE,OAAO;AAAA,MACxC,YAAY,iBAAe,KAAK,SAAS,EAAE,QAAQ;AAAA,MACnD,OAAM;AAAA,MACN;AAAA;AAAA;AAAA;AAOV,IAAO,2BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default, CodeEditorWithSchema } from './DSCodeEditor';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-codeeditor",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Code Editor",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
|
-
"import": "./esm/index.js",
|
|
12
|
-
"require": "./cjs/index.js"
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
13
16
|
},
|
|
14
17
|
"./DSCodeEditor": {
|
|
15
|
-
"import": "./esm/DSCodeEditor.js",
|
|
16
|
-
"require": "./cjs/DSCodeEditor.js"
|
|
18
|
+
"import": "./dist/esm/DSCodeEditor.js",
|
|
19
|
+
"require": "./dist/cjs/DSCodeEditor.js"
|
|
17
20
|
},
|
|
18
21
|
"./components/DSCodeEditorImpl": {
|
|
19
|
-
"import": "./esm/components/DSCodeEditorImpl.js",
|
|
20
|
-
"require": "./cjs/components/DSCodeEditorImpl.js"
|
|
22
|
+
"import": "./dist/esm/components/DSCodeEditorImpl.js",
|
|
23
|
+
"require": "./dist/cjs/components/DSCodeEditorImpl.js"
|
|
21
24
|
},
|
|
22
25
|
"./components/DSCodeEditorForm": {
|
|
23
|
-
"import": "./esm/components/DSCodeEditorForm.js",
|
|
24
|
-
"require": "./cjs/components/DSCodeEditorForm.js"
|
|
26
|
+
"import": "./dist/esm/components/DSCodeEditorForm.js",
|
|
27
|
+
"require": "./dist/cjs/components/DSCodeEditorForm.js"
|
|
25
28
|
}
|
|
26
29
|
},
|
|
27
30
|
"sideEffects": [
|
|
@@ -33,22 +36,22 @@
|
|
|
33
36
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
34
37
|
},
|
|
35
38
|
"engines": {
|
|
36
|
-
"
|
|
37
|
-
"node": ">=
|
|
39
|
+
"pnpm": ">=6",
|
|
40
|
+
"node": ">=16"
|
|
38
41
|
},
|
|
39
42
|
"author": "ICE MT",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"jestSonar": {
|
|
44
|
+
"sonar56x": true,
|
|
45
|
+
"reportPath": "reports",
|
|
46
|
+
"reportFile": "tests.xml",
|
|
47
|
+
"indent": 4
|
|
45
48
|
},
|
|
46
49
|
"dependencies": {
|
|
47
|
-
"@elliemae/ds-button": "3.0.0-next.
|
|
48
|
-
"@elliemae/ds-classnames": "3.0.0-next.
|
|
49
|
-
"@elliemae/ds-form": "3.0.0-next.
|
|
50
|
-
"@elliemae/ds-icons": "3.0.0-next.
|
|
51
|
-
"@elliemae/ds-modal": "3.0.0-next.
|
|
50
|
+
"@elliemae/ds-button": "3.0.0-next.5",
|
|
51
|
+
"@elliemae/ds-classnames": "3.0.0-next.5",
|
|
52
|
+
"@elliemae/ds-form": "3.0.0-next.5",
|
|
53
|
+
"@elliemae/ds-icons": "3.0.0-next.5",
|
|
54
|
+
"@elliemae/ds-modal": "3.0.0-next.5",
|
|
52
55
|
"brace": "~0.11.1",
|
|
53
56
|
"react-ace": "~6.6.0",
|
|
54
57
|
"react-desc": "~4.1.3"
|
|
@@ -60,7 +63,13 @@
|
|
|
60
63
|
},
|
|
61
64
|
"publishConfig": {
|
|
62
65
|
"access": "public",
|
|
63
|
-
"
|
|
64
|
-
|
|
66
|
+
"typeSafety": false
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
70
|
+
"test": "node ../../scripts/testing/test.mjs",
|
|
71
|
+
"lint": "node ../../scripts/lint.mjs",
|
|
72
|
+
"dts": "node ../../scripts/dts.mjs",
|
|
73
|
+
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
65
74
|
}
|
|
66
75
|
}
|
package/cjs/DSCodeEditor.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var reactDesc = require('react-desc');
|
|
9
|
-
var DSModal = require('@elliemae/ds-modal');
|
|
10
|
-
var AceEditor = require('react-ace');
|
|
11
|
-
var DSCodeEditorForm = require('./components/DSCodeEditorForm.js');
|
|
12
|
-
require('brace/mode/javascript.js');
|
|
13
|
-
require('brace/theme/tomorrow.js');
|
|
14
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
15
|
-
|
|
16
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
-
|
|
18
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
19
|
-
var DSModal__default = /*#__PURE__*/_interopDefaultLegacy(DSModal);
|
|
20
|
-
var AceEditor__default = /*#__PURE__*/_interopDefaultLegacy(AceEditor);
|
|
21
|
-
|
|
22
|
-
const DSCodeEditor = _ref => {
|
|
23
|
-
let {
|
|
24
|
-
containerProps = {},
|
|
25
|
-
value: defaultValue = '',
|
|
26
|
-
onSave = () => null,
|
|
27
|
-
onClose = () => null,
|
|
28
|
-
onReject = () => null,
|
|
29
|
-
onChange = () => null,
|
|
30
|
-
isOpen = false,
|
|
31
|
-
fileName = '',
|
|
32
|
-
confirmLabel = 'Save',
|
|
33
|
-
maxLines = 20,
|
|
34
|
-
minLines = 20,
|
|
35
|
-
modalTitle = 'Javascript Editor',
|
|
36
|
-
modalType = 'confirm',
|
|
37
|
-
rejectLabel = 'Close',
|
|
38
|
-
size = 'large',
|
|
39
|
-
style = {},
|
|
40
|
-
useModal = true,
|
|
41
|
-
showHeader = true,
|
|
42
|
-
showSyntaxChecks = true
|
|
43
|
-
} = _ref;
|
|
44
|
-
const [{
|
|
45
|
-
value,
|
|
46
|
-
errors
|
|
47
|
-
}, setState] = React.useState({
|
|
48
|
-
value: defaultValue,
|
|
49
|
-
errors: []
|
|
50
|
-
});
|
|
51
|
-
const reactAceComponent = React.useRef();
|
|
52
|
-
|
|
53
|
-
const editor = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
54
|
-
children: [showHeader && /*#__PURE__*/_jsx__default["default"](DSCodeEditorForm, {
|
|
55
|
-
fileName: fileName,
|
|
56
|
-
reactAceComponent: reactAceComponent
|
|
57
|
-
}), /*#__PURE__*/jsxRuntime.jsx(AceEditor__default["default"], {
|
|
58
|
-
ref: reactAceComponent,
|
|
59
|
-
editorProps: {
|
|
60
|
-
$blockScrolling: true
|
|
61
|
-
},
|
|
62
|
-
maxLines: maxLines,
|
|
63
|
-
minLines: minLines,
|
|
64
|
-
mode: "javascript",
|
|
65
|
-
name: "ace-code-edior",
|
|
66
|
-
onChange: val => {
|
|
67
|
-
setState({
|
|
68
|
-
errors,
|
|
69
|
-
value: val
|
|
70
|
-
});
|
|
71
|
-
onChange(val, errors);
|
|
72
|
-
},
|
|
73
|
-
onValidate: annotations => setState({
|
|
74
|
-
value,
|
|
75
|
-
errors: annotations
|
|
76
|
-
}),
|
|
77
|
-
theme: "tomorrow",
|
|
78
|
-
setOptions: {
|
|
79
|
-
useWorker: showSyntaxChecks
|
|
80
|
-
},
|
|
81
|
-
value: value
|
|
82
|
-
})]
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
if (!useModal) return editor;
|
|
86
|
-
return /*#__PURE__*/_jsx__default["default"](DSModal__default["default"], {
|
|
87
|
-
centered: false,
|
|
88
|
-
confirmLabel: confirmLabel,
|
|
89
|
-
containerProps: containerProps,
|
|
90
|
-
isOpen: isOpen,
|
|
91
|
-
modalTitle: modalTitle,
|
|
92
|
-
modalType: modalType,
|
|
93
|
-
onClose: () => onClose(value, fileName, errors),
|
|
94
|
-
onConfirm: () => onSave(value, fileName, errors),
|
|
95
|
-
onReject: () => onReject(value, fileName, errors),
|
|
96
|
-
rejectLabel: rejectLabel,
|
|
97
|
-
size: size,
|
|
98
|
-
style: style
|
|
99
|
-
}, void 0, editor);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const codeEditorProps = {
|
|
103
|
-
containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container'),
|
|
104
|
-
value: reactDesc.PropTypes.string.description('editors content').isRequired,
|
|
105
|
-
onSave: reactDesc.PropTypes.func.description('function called when the user press save'),
|
|
106
|
-
onClose: reactDesc.PropTypes.func.description('function called when the user closes the modal'),
|
|
107
|
-
onReject: reactDesc.PropTypes.func.description('function called when is rejected'),
|
|
108
|
-
onChange: reactDesc.PropTypes.func.description('function executed when code editor value changes').isRequired,
|
|
109
|
-
isOpen: reactDesc.PropTypes.bool.description('Whether the modal is opened or not').defaultValue(false),
|
|
110
|
-
fileName: reactDesc.PropTypes.string.description('File name to open in the editor'),
|
|
111
|
-
maxLines: reactDesc.PropTypes.number.description('Max lines in the editor content').defaultValue(20),
|
|
112
|
-
minLines: reactDesc.PropTypes.number.description('Min lines in the editor content').defaultValue(20),
|
|
113
|
-
modalTitle: reactDesc.PropTypes.string.description('Modal title').defaultValue('Javascript Editor'),
|
|
114
|
-
confirmLabel: reactDesc.PropTypes.string.description('Customize modal confirm label').defaultValue('Save'),
|
|
115
|
-
rejectLabel: reactDesc.PropTypes.string.description('Customize modal rejection label').defaultValue('Close'),
|
|
116
|
-
modalType: reactDesc.PropTypes.oneOf(DSModal.modalTypes).description('Modal type').defaultValue('confirm'),
|
|
117
|
-
size: reactDesc.PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge']).description('modal size').defaultValue('large'),
|
|
118
|
-
style: reactDesc.PropTypes.object.description('css inline style'),
|
|
119
|
-
useModal: reactDesc.PropTypes.bool.description('whether to use code editor inside modal or not').defaultValue(true),
|
|
120
|
-
showHeader: reactDesc.PropTypes.bool.description('show editors header').defaultValue(true),
|
|
121
|
-
showSyntaxChecks: reactDesc.PropTypes.bool.description('show syntax warnings and checks').defaultValue(true)
|
|
122
|
-
};
|
|
123
|
-
const CodeEditorWithSchema = reactDesc.describe(DSCodeEditor);
|
|
124
|
-
CodeEditorWithSchema.propTypes = codeEditorProps;
|
|
125
|
-
|
|
126
|
-
exports.CodeEditorWithSchema = CodeEditorWithSchema;
|
|
127
|
-
exports["default"] = DSCodeEditor;
|