@elliemae/ds-codeeditor 2.3.0-alpha.6 → 2.3.0-next.0

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.
@@ -0,0 +1,182 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import 'core-js/modules/esnext.async-iterator.find.js';
3
+ import 'core-js/modules/esnext.iterator.constructor.js';
4
+ import 'core-js/modules/esnext.iterator.find.js';
5
+ import 'core-js/modules/es.string.replace.js';
6
+ import 'core-js/modules/es.string.replace-all.js';
7
+ import { Component } from 'react';
8
+ import DSButton from '@elliemae/ds-button';
9
+ import { DSInputGroup, DSTextBox, DSCheckbox } from '@elliemae/ds-form';
10
+ import { convertPropToCssClassName, aggregatedClasses } from '@elliemae/ds-classnames';
11
+ import { ChevronSmallLeft, ChevronSmallRight } from '@elliemae/ds-icons';
12
+
13
+ var _DSButton, _ChevronSmallRight;
14
+ const blockName = 'code-editor';
15
+ const {
16
+ cssClassName,
17
+ classNameBlock
18
+ } = convertPropToCssClassName(blockName);
19
+ const CheckOptionsGroup = aggregatedClasses('div')("".concat(blockName, "-options-group"));
20
+
21
+ class DSCodeEditorForm extends Component {
22
+ constructor(props) {
23
+ super(props);
24
+ this.state = {
25
+ find: false,
26
+ replace: false,
27
+ isCaseSensitive: false,
28
+ isWholeWord: false,
29
+ filteredText: '',
30
+ replaceText: ''
31
+ };
32
+ }
33
+
34
+ searchWord(isReplace, all) {
35
+ const {
36
+ reactAceComponent: {
37
+ current: {
38
+ editor
39
+ }
40
+ }
41
+ } = this.props;
42
+ const {
43
+ isCaseSensitive,
44
+ isWholeWord,
45
+ filteredText,
46
+ replaceText
47
+ } = this.state;
48
+ const options = {
49
+ backwards: false,
50
+ wrap: true,
51
+ caseSensitive: isCaseSensitive,
52
+ wholeWord: isWholeWord,
53
+ regExp: true
54
+ };
55
+ editor.find(filteredText, options);
56
+ const selectedContent = editor.getSelectedText();
57
+
58
+ if (isReplace && replaceText && selectedContent) {
59
+ if (all) {
60
+ editor.findAll(filteredText, options);
61
+ editor.replaceAll(replaceText);
62
+ } else {
63
+ const range = editor.selection.getRange();
64
+ editor.session.replace(range, replaceText);
65
+ }
66
+ }
67
+ }
68
+
69
+ render() {
70
+ const {
71
+ fileName
72
+ } = this.props;
73
+ const {
74
+ find,
75
+ replace,
76
+ isCaseSensitive,
77
+ isWholeWord,
78
+ filteredText,
79
+ replaceText
80
+ } = this.state;
81
+ return /*#__PURE__*/_jsx("div", {
82
+ className: "".concat(cssClassName)
83
+ }, void 0, fileName ? /*#__PURE__*/_jsx("div", {
84
+ className: classNameBlock('file-name')
85
+ }, void 0, "File Name: ", /*#__PURE__*/_jsx("span", {}, void 0, " ", fileName, " ")) : null, /*#__PURE__*/_jsx("div", {
86
+ className: classNameBlock('find-replace-btn')
87
+ }, void 0, !find && !replace ? /*#__PURE__*/_jsx(DSButton, {
88
+ buttonType: "secondary",
89
+ labelText: "Find",
90
+ onClick: () => this.setState({
91
+ find: true
92
+ }),
93
+ size: "m"
94
+ }) : null, !replace ? /*#__PURE__*/_jsx(DSButton, {
95
+ buttonType: "secondary",
96
+ labelText: "Find & Replace",
97
+ onClick: () => this.setState({
98
+ replace: true
99
+ }),
100
+ size: "m"
101
+ }) : null), find || replace ? /*#__PURE__*/_jsx(DSInputGroup, {
102
+ className: classNameBlock('find')
103
+ }, void 0, /*#__PURE__*/_jsx(DSTextBox, {
104
+ className: "find-word",
105
+ fluidWidth: false,
106
+ id: "find-textbox",
107
+ onChange: e => this.setState({
108
+ filteredText: e.currentTarget.value
109
+ }),
110
+ placeholder: "Find",
111
+ rightComponent: /*#__PURE__*/_jsx("div", {
112
+ className: classNameBlock('next-back-btn')
113
+ }, void 0, _DSButton || (_DSButton = /*#__PURE__*/_jsx(DSButton, {
114
+ icon: /*#__PURE__*/_jsx(ChevronSmallLeft, {}),
115
+ size: "m"
116
+ })), /*#__PURE__*/_jsx(DSButton, {
117
+ icon: _ChevronSmallRight || (_ChevronSmallRight = /*#__PURE__*/_jsx(ChevronSmallRight, {})),
118
+ onClick: () => this.searchWord(),
119
+ size: "m"
120
+ })),
121
+ value: filteredText
122
+ }), /*#__PURE__*/_jsx(CheckOptionsGroup, {}, void 0, /*#__PURE__*/_jsx(DSCheckbox, {
123
+ checked: isCaseSensitive,
124
+ id: "case-sensitive-check",
125
+ labelText: "Case Sensitive",
126
+ name: "case-sensitive-check",
127
+ onChange: () => this.setState({
128
+ isCaseSensitive: !isCaseSensitive
129
+ })
130
+ }), /*#__PURE__*/_jsx(DSCheckbox, {
131
+ checked: isWholeWord,
132
+ id: "whole-word-check",
133
+ labelText: "Whole Word",
134
+ name: "whole-word-check",
135
+ onChange: () => this.setState({
136
+ isWholeWord: !isWholeWord
137
+ })
138
+ }), /*#__PURE__*/_jsx(DSCheckbox, {
139
+ checked: replace,
140
+ id: "replace-check",
141
+ labelText: "Replace",
142
+ name: "replace-check",
143
+ onChange: () => this.setState({
144
+ replace: !replace
145
+ })
146
+ })), /*#__PURE__*/_jsx(DSButton, {
147
+ buttonType: "secondary",
148
+ labelText: "Done",
149
+ onClick: () => this.setState({
150
+ replace: false,
151
+ find: false
152
+ }),
153
+ size: "m"
154
+ })) : null, replace ? /*#__PURE__*/_jsx("div", {
155
+ className: classNameBlock('replace')
156
+ }, void 0, /*#__PURE__*/_jsx(DSTextBox, {
157
+ className: "find-word",
158
+ fluidWidth: false,
159
+ id: "replace-textbox",
160
+ onChange: e => this.setState({
161
+ replaceText: e.currentTarget.value
162
+ }),
163
+ placeholder: "Replace",
164
+ value: replaceText
165
+ }), /*#__PURE__*/_jsx("div", {
166
+ className: classNameBlock('replace-btns')
167
+ }, void 0, /*#__PURE__*/_jsx(DSButton, {
168
+ buttonType: "secondary",
169
+ labelText: "Replace",
170
+ onClick: () => this.searchWord(true, false),
171
+ size: "m"
172
+ }), /*#__PURE__*/_jsx(DSButton, {
173
+ buttonType: "secondary",
174
+ labelText: "Replace All",
175
+ onClick: () => this.searchWord(true, true),
176
+ size: "m"
177
+ }))) : null);
178
+ }
179
+
180
+ }
181
+
182
+ export { DSCodeEditorForm as default };
@@ -0,0 +1,79 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import React, { Component } from 'react';
3
+ import AceEditor from 'react-ace';
4
+ import DSModal from '@elliemae/ds-modal';
5
+ import DSCodeEditorForm from './DSCodeEditorForm.js';
6
+ import 'brace/mode/javascript.js';
7
+ import 'brace/theme/tomorrow.js';
8
+ import { jsx } from 'react/jsx-runtime';
9
+
10
+ class DSCodeEditorImpl extends Component {
11
+ constructor(props) {
12
+ super(props);
13
+ this.state = {
14
+ value: props.value,
15
+ errors: []
16
+ };
17
+ this.reactAceComponent = /*#__PURE__*/React.createRef();
18
+ }
19
+
20
+ render() {
21
+ const {
22
+ onSave,
23
+ onClose,
24
+ onReject,
25
+ isOpen,
26
+ fileName,
27
+ confirmLabel,
28
+ maxLines,
29
+ minLines,
30
+ modalTitle,
31
+ modalType,
32
+ rejectLabel,
33
+ size,
34
+ style,
35
+ containerProps
36
+ } = this.props;
37
+ const {
38
+ value,
39
+ errors
40
+ } = this.state;
41
+ return /*#__PURE__*/_jsx(DSModal, {
42
+ centered: false,
43
+ confirmLabel: confirmLabel,
44
+ containerProps: containerProps,
45
+ isOpen: isOpen,
46
+ modalTitle: modalTitle,
47
+ modalType: modalType,
48
+ onClose: () => onClose(value, fileName, errors),
49
+ onConfirm: () => onSave(value, fileName, errors),
50
+ onReject: () => onReject(value, fileName, errors),
51
+ rejectLabel: rejectLabel,
52
+ size: size,
53
+ style: style
54
+ }, void 0, /*#__PURE__*/_jsx(DSCodeEditorForm, {
55
+ fileName: fileName,
56
+ reactAceComponent: this.reactAceComponent
57
+ }), /*#__PURE__*/jsx(AceEditor, {
58
+ ref: this.reactAceComponent,
59
+ editorProps: {
60
+ $blockScrolling: true
61
+ },
62
+ maxLines: maxLines,
63
+ minLines: minLines,
64
+ mode: "javascript",
65
+ name: "ace-code-edior",
66
+ onChange: val => this.setState({
67
+ value: val
68
+ }),
69
+ onValidate: annotations => this.setState({
70
+ errors: annotations
71
+ }),
72
+ theme: "tomorrow",
73
+ value: value
74
+ }));
75
+ }
76
+
77
+ }
78
+
79
+ export { DSCodeEditorImpl as default };
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ export { CodeEditorWithSchema, default } from './DSCodeEditor.js';
package/package.json CHANGED
@@ -1,30 +1,27 @@
1
1
  {
2
2
  "name": "@elliemae/ds-codeeditor",
3
- "version": "2.3.0-alpha.6",
3
+ "version": "2.3.0-next.0",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Code Editor",
6
- "files": [
7
- "dist"
8
- ],
9
- "module": "./dist/esm/index.js",
10
- "main": "./dist/cjs/index.js",
11
- "types": "./dist/types/index.d.ts",
6
+ "module": "./esm/index.js",
7
+ "main": "./cjs/index.js",
8
+ "types": "./types/index.d.ts",
12
9
  "exports": {
13
10
  ".": {
14
- "import": "./dist/esm/index.js",
15
- "require": "./dist/cjs/index.js"
11
+ "import": "./esm/index.js",
12
+ "require": "./cjs/index.js"
16
13
  },
17
14
  "./DSCodeEditor": {
18
- "import": "./dist/esm/DSCodeEditor.js",
19
- "require": "./dist/cjs/DSCodeEditor.js"
15
+ "import": "./esm/DSCodeEditor.js",
16
+ "require": "./cjs/DSCodeEditor.js"
20
17
  },
21
18
  "./components/DSCodeEditorImpl": {
22
- "import": "./dist/esm/components/DSCodeEditorImpl.js",
23
- "require": "./dist/cjs/components/DSCodeEditorImpl.js"
19
+ "import": "./esm/components/DSCodeEditorImpl.js",
20
+ "require": "./cjs/components/DSCodeEditorImpl.js"
24
21
  },
25
22
  "./components/DSCodeEditorForm": {
26
- "import": "./dist/esm/components/DSCodeEditorForm.js",
27
- "require": "./dist/cjs/components/DSCodeEditorForm.js"
23
+ "import": "./esm/components/DSCodeEditorForm.js",
24
+ "require": "./cjs/components/DSCodeEditorForm.js"
28
25
  }
29
26
  },
30
27
  "sideEffects": [
@@ -36,16 +33,22 @@
36
33
  "url": "https://git.elliemae.io/platform-ui/dimsum.git"
37
34
  },
38
35
  "engines": {
39
- "pnpm": ">=6",
40
- "node": ">=16"
36
+ "npm": ">=7",
37
+ "node": ">=14"
41
38
  },
42
39
  "author": "ICE MT",
40
+ "scripts": {
41
+ "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
42
+ "prebuild": "exit 0",
43
+ "predev": "exit 0",
44
+ "build": "node ../../scripts/build/build.js"
45
+ },
43
46
  "dependencies": {
44
- "@elliemae/ds-button": "2.3.0-alpha.6",
45
- "@elliemae/ds-classnames": "2.3.0-alpha.6",
46
- "@elliemae/ds-form": "2.3.0-alpha.6",
47
- "@elliemae/ds-icons": "2.3.0-alpha.6",
48
- "@elliemae/ds-modal": "2.3.0-alpha.6",
47
+ "@elliemae/ds-button": "2.3.0-next.0",
48
+ "@elliemae/ds-classnames": "2.3.0-next.0",
49
+ "@elliemae/ds-form": "2.3.0-next.0",
50
+ "@elliemae/ds-icons": "2.3.0-next.0",
51
+ "@elliemae/ds-modal": "2.3.0-next.0",
49
52
  "brace": "~0.11.1",
50
53
  "react-ace": "~6.6.0",
51
54
  "react-desc": "~4.1.3"
@@ -57,12 +60,7 @@
57
60
  },
58
61
  "publishConfig": {
59
62
  "access": "public",
60
- "typeSafety": false
61
- },
62
- "scripts": {
63
- "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
64
- "prebuild": "exit 0",
65
- "predev": "exit 0",
66
- "build": "node ../../scripts/build/build.js"
63
+ "directory": "dist",
64
+ "generateSubmodules": true
67
65
  }
68
66
  }
@@ -0,0 +1,107 @@
1
+ /// <reference path="../../../../shared/typings/react-desc.d.ts" />
2
+ /// <reference types="react" />
3
+ import 'brace/mode/javascript.js';
4
+ import 'brace/theme/tomorrow.js';
5
+ declare const DSCodeEditor: {
6
+ ({ containerProps, value: defaultValue, onSave, onClose, onReject, onChange, isOpen, fileName, confirmLabel, maxLines, minLines, modalTitle, modalType, rejectLabel, size, style, useModal, showHeader, showSyntaxChecks, }: {
7
+ containerProps?: {} | undefined;
8
+ value?: string | undefined;
9
+ onSave?: (() => null) | undefined;
10
+ onClose?: (() => null) | undefined;
11
+ onReject?: (() => null) | undefined;
12
+ onChange?: (() => null) | undefined;
13
+ isOpen?: boolean | undefined;
14
+ fileName?: string | undefined;
15
+ confirmLabel?: string | undefined;
16
+ maxLines?: number | undefined;
17
+ minLines?: number | undefined;
18
+ modalTitle?: string | undefined;
19
+ modalType?: string | undefined;
20
+ rejectLabel?: string | undefined;
21
+ size?: string | undefined;
22
+ style?: {} | undefined;
23
+ useModal?: boolean | undefined;
24
+ showHeader?: boolean | undefined;
25
+ showSyntaxChecks?: boolean | undefined;
26
+ }): JSX.Element;
27
+ propTypes: {
28
+ containerProps: {
29
+ defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
30
+ deprecated: import("react-desc").PropTypesDescValidator;
31
+ };
32
+ isRequired: import("react-desc").PropTypesDescValue;
33
+ };
34
+ value: import("react-desc").PropTypesDescValue;
35
+ onSave: {
36
+ defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
37
+ deprecated: import("react-desc").PropTypesDescValidator;
38
+ };
39
+ isRequired: import("react-desc").PropTypesDescValue;
40
+ };
41
+ onClose: {
42
+ defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
43
+ deprecated: import("react-desc").PropTypesDescValidator;
44
+ };
45
+ isRequired: import("react-desc").PropTypesDescValue;
46
+ };
47
+ onReject: {
48
+ defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
49
+ deprecated: import("react-desc").PropTypesDescValidator;
50
+ };
51
+ isRequired: import("react-desc").PropTypesDescValue;
52
+ };
53
+ onChange: import("react-desc").PropTypesDescValue;
54
+ isOpen: {
55
+ deprecated: import("react-desc").PropTypesDescValidator;
56
+ };
57
+ fileName: {
58
+ defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
59
+ deprecated: import("react-desc").PropTypesDescValidator;
60
+ };
61
+ isRequired: import("react-desc").PropTypesDescValue;
62
+ };
63
+ maxLines: {
64
+ deprecated: import("react-desc").PropTypesDescValidator;
65
+ };
66
+ minLines: {
67
+ deprecated: import("react-desc").PropTypesDescValidator;
68
+ };
69
+ modalTitle: {
70
+ deprecated: import("react-desc").PropTypesDescValidator;
71
+ };
72
+ confirmLabel: {
73
+ deprecated: import("react-desc").PropTypesDescValidator;
74
+ };
75
+ rejectLabel: {
76
+ deprecated: import("react-desc").PropTypesDescValidator;
77
+ };
78
+ modalType: {
79
+ deprecated: import("react-desc").PropTypesDescValidator;
80
+ };
81
+ size: {
82
+ deprecated: import("react-desc").PropTypesDescValidator;
83
+ };
84
+ style: {
85
+ defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
86
+ deprecated: import("react-desc").PropTypesDescValidator;
87
+ };
88
+ isRequired: import("react-desc").PropTypesDescValue;
89
+ };
90
+ useModal: {
91
+ deprecated: import("react-desc").PropTypesDescValidator;
92
+ };
93
+ showHeader: {
94
+ deprecated: import("react-desc").PropTypesDescValidator;
95
+ };
96
+ showSyntaxChecks: {
97
+ deprecated: import("react-desc").PropTypesDescValidator;
98
+ };
99
+ };
100
+ };
101
+ declare const CodeEditorWithSchema: {
102
+ (props?: unknown): JSX.Element;
103
+ propTypes: unknown;
104
+ toTypescript: () => import("react-desc").TypescriptSchema;
105
+ };
106
+ export { CodeEditorWithSchema };
107
+ export default DSCodeEditor;
@@ -0,0 +1,7 @@
1
+ import { Component } from 'react';
2
+ declare class DSCodeEditorForm extends Component {
3
+ constructor(props: any);
4
+ searchWord(isReplace: any, all: any): void;
5
+ render(): JSX.Element;
6
+ }
7
+ export default DSCodeEditorForm;
@@ -0,0 +1,8 @@
1
+ import { Component } from 'react';
2
+ import 'brace/mode/javascript.js';
3
+ import 'brace/theme/tomorrow.js';
4
+ declare class DSCodeEditorImpl extends Component {
5
+ constructor(props: any);
6
+ render(): JSX.Element;
7
+ }
8
+ export default DSCodeEditorImpl;
@@ -0,0 +1 @@
1
+ export { default, CodeEditorWithSchema } from './DSCodeEditor';
@@ -1,131 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __reExport = (target, module2, copyDefault, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
- }
18
- return target;
19
- };
20
- var __toESM = (module2, isNodeMode) => {
21
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
- };
23
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
- return (module2, temp) => {
25
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
- };
27
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
- var DSCodeEditor_exports = {};
29
- __export(DSCodeEditor_exports, {
30
- CodeEditorWithSchema: () => CodeEditorWithSchema,
31
- default: () => DSCodeEditor_default
32
- });
33
- var React = __toESM(require("react"));
34
- var import_react = __toESM(require("react"));
35
- var import_react_desc = require("react-desc");
36
- var import_ds_modal = __toESM(require("@elliemae/ds-modal"));
37
- var import_react_ace = __toESM(require("react-ace"));
38
- var import_DSCodeEditorForm = __toESM(require("./components/DSCodeEditorForm"));
39
- var import_javascript = require("brace/mode/javascript.js");
40
- var import_tomorrow = require("brace/theme/tomorrow.js");
41
- const DSCodeEditor = ({
42
- containerProps = {},
43
- value: defaultValue = "",
44
- onSave = () => null,
45
- onClose = () => null,
46
- onReject = () => null,
47
- onChange = () => null,
48
- isOpen = false,
49
- fileName = "",
50
- confirmLabel = "Save",
51
- maxLines = 20,
52
- minLines = 20,
53
- modalTitle = "Javascript Editor",
54
- modalType = "confirm",
55
- rejectLabel = "Close",
56
- size = "large",
57
- style = {},
58
- useModal = true,
59
- showHeader = true,
60
- showSyntaxChecks = true
61
- }) => {
62
- const [{ value, errors }, setState] = (0, import_react.useState)({
63
- value: defaultValue,
64
- errors: []
65
- });
66
- const reactAceComponent = (0, import_react.useRef)();
67
- const editor = /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, showHeader && /* @__PURE__ */ import_react.default.createElement(import_DSCodeEditorForm.default, {
68
- fileName,
69
- reactAceComponent
70
- }), /* @__PURE__ */ import_react.default.createElement(import_react_ace.default, {
71
- ref: reactAceComponent,
72
- editorProps: { $blockScrolling: true },
73
- maxLines,
74
- minLines,
75
- mode: "javascript",
76
- name: "ace-code-edior",
77
- onChange: (val) => {
78
- setState({ errors, value: val });
79
- onChange(val, errors);
80
- },
81
- onValidate: (annotations) => setState({ value, errors: annotations }),
82
- theme: "tomorrow",
83
- setOptions: {
84
- useWorker: showSyntaxChecks
85
- },
86
- value
87
- }));
88
- if (!useModal)
89
- return editor;
90
- return /* @__PURE__ */ import_react.default.createElement(import_ds_modal.default, {
91
- centered: false,
92
- confirmLabel,
93
- containerProps,
94
- isOpen,
95
- modalTitle,
96
- modalType,
97
- onClose: () => onClose(value, fileName, errors),
98
- onConfirm: () => onSave(value, fileName, errors),
99
- onReject: () => onReject(value, fileName, errors),
100
- rejectLabel,
101
- size,
102
- style
103
- }, editor);
104
- };
105
- const codeEditorProps = {
106
- containerProps: import_react_desc.PropTypes.object.description("Set of Properties attached to the main container"),
107
- value: import_react_desc.PropTypes.string.description("editors content").isRequired,
108
- onSave: import_react_desc.PropTypes.func.description("function called when the user press save"),
109
- onClose: import_react_desc.PropTypes.func.description("function called when the user closes the modal"),
110
- onReject: import_react_desc.PropTypes.func.description("function called when is rejected"),
111
- onChange: import_react_desc.PropTypes.func.description("function executed when code editor value changes").isRequired,
112
- isOpen: import_react_desc.PropTypes.bool.description("Whether the modal is opened or not").defaultValue(false),
113
- fileName: import_react_desc.PropTypes.string.description("File name to open in the editor"),
114
- maxLines: import_react_desc.PropTypes.number.description("Max lines in the editor content").defaultValue(20),
115
- minLines: import_react_desc.PropTypes.number.description("Min lines in the editor content").defaultValue(20),
116
- modalTitle: import_react_desc.PropTypes.string.description("Modal title").defaultValue("Javascript Editor"),
117
- confirmLabel: import_react_desc.PropTypes.string.description("Customize modal confirm label").defaultValue("Save"),
118
- rejectLabel: import_react_desc.PropTypes.string.description("Customize modal rejection label").defaultValue("Close"),
119
- modalType: import_react_desc.PropTypes.oneOf(import_ds_modal.modalTypes).description("Modal type").defaultValue("confirm"),
120
- size: import_react_desc.PropTypes.oneOf(["xsmall", "small", "medium", "large", "xlarge"]).description("modal size").defaultValue("large"),
121
- style: import_react_desc.PropTypes.object.description("css inline style"),
122
- useModal: import_react_desc.PropTypes.bool.description("whether to use code editor inside modal or not").defaultValue(true),
123
- showHeader: import_react_desc.PropTypes.bool.description("show editors header").defaultValue(true),
124
- showSyntaxChecks: import_react_desc.PropTypes.bool.description("show syntax warnings and checks").defaultValue(true)
125
- };
126
- DSCodeEditor.propTypes = codeEditorProps;
127
- const CodeEditorWithSchema = (0, import_react_desc.describe)(DSCodeEditor);
128
- CodeEditorWithSchema.propTypes = codeEditorProps;
129
- var DSCodeEditor_default = DSCodeEditor;
130
- module.exports = __toCommonJS(DSCodeEditor_exports);
131
- //# sourceMappingURL=DSCodeEditor.js.map
@@ -1,7 +0,0 @@
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 'react-desc';\nimport DSModal, { modalTypes } from '@elliemae/ds-modal';\nimport AceEditor from 'react-ace';\nimport DSCodeEditorForm from './components/DSCodeEditorForm';\nimport 'brace/mode/javascript.js';\nimport 'brace/theme/tomorrow.js';\n\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 editor = (\n <>\n {showHeader && (\n <DSCodeEditorForm\n fileName={fileName}\n reactAceComponent={reactAceComponent}\n />\n )}\n <AceEditor\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(\n 'Set of Properties attached to the main container',\n ),\n value: PropTypes.string.description('editors content').isRequired,\n onSave: PropTypes.func.description(\n 'function called when the user press save',\n ),\n onClose: PropTypes.func.description(\n 'function called when the user closes the modal',\n ),\n onReject: PropTypes.func.description('function called when is rejected'),\n onChange: PropTypes.func.description(\n 'function executed when code editor value changes',\n ).isRequired,\n isOpen: PropTypes.bool\n .description('Whether the modal is opened or not')\n .defaultValue(false),\n fileName: PropTypes.string.description('File name to open in the editor'),\n maxLines: PropTypes.number\n .description('Max lines in the editor content')\n .defaultValue(20),\n minLines: PropTypes.number\n .description('Min lines in the editor content')\n .defaultValue(20),\n modalTitle: PropTypes.string\n .description('Modal title')\n .defaultValue('Javascript Editor'),\n confirmLabel: PropTypes.string\n .description('Customize modal confirm label')\n .defaultValue('Save'),\n rejectLabel: PropTypes.string\n .description('Customize modal rejection label')\n .defaultValue('Close'),\n modalType: PropTypes.oneOf(modalTypes)\n .description('Modal type')\n .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\n .description('whether to use code editor inside modal or not')\n .defaultValue(true),\n showHeader: PropTypes.bool\n .description('show editors header')\n .defaultValue(true),\n showSyntaxChecks: PropTypes.bool\n .description('show syntax warnings and checks')\n .defaultValue(true),\n};\n\nDSCodeEditor.propTypes = codeEditorProps;\n\nconst CodeEditorWithSchema = describe(DSCodeEditor);\nCodeEditorWithSchema.propTypes = codeEditorProps;\n\nexport { CodeEditorWithSchema };\nexport default DSCodeEditor;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAwC;AACxC,wBAAoC;AACpC,sBAAoC;AACpC,uBAAsB;AACtB,8BAA6B;AAC7B,wBAAO;AACP,sBAAO;AAEP,MAAM,eAAe,CAAC;AAAA,EACpB,iBAAiB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