@desynova-digital/components 9.0.4 → 9.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,7 +12,7 @@ var _templateObject = _taggedTemplateLiteral(['\n background: transparent;\n f
|
|
|
12
12
|
_templateObject2 = _taggedTemplateLiteral(['\n background: none;\n border: none;\n cursor: pointer;\n position: absolute;\n right: 0;\n top: 5px;\n &:focus {\n outline: none;\n }\n'], ['\n background: none;\n border: none;\n cursor: pointer;\n position: absolute;\n right: 0;\n top: 5px;\n &:focus {\n outline: none;\n }\n']),
|
|
13
13
|
_templateObject3 = _taggedTemplateLiteral(['\n position: absolute;\n right: 0px;\n top: 0px;\n background-color: #303f51;\n border-radius: 12px;\n font-size: 12px;\n padding: 5px 10px;\n color: #ffffff;\n'], ['\n position: absolute;\n right: 0px;\n top: 0px;\n background-color: #303f51;\n border-radius: 12px;\n font-size: 12px;\n padding: 5px 10px;\n color: #ffffff;\n']),
|
|
14
14
|
_templateObject4 = _taggedTemplateLiteral(['\n color: ', ';\n padding-top: 5px;\n display: inline-block;\n font-size: 12px;\n font-family: inherit;\n width: 100%;\n text-align: left;\n'], ['\n color: ', ';\n padding-top: 5px;\n display: inline-block;\n font-size: 12px;\n font-family: inherit;\n width: 100%;\n text-align: left;\n']),
|
|
15
|
-
_templateObject5 = _taggedTemplateLiteral(['\nwhite-space: nowrap;\n width:100%\n box-sizing: border-box;\n border-bottom: 1px solid ', ';\n \n\n font-family: "SFUIText-Medium";\n font-size: 14px;\n color: ', ';\n\n display: inline-block;\n position: relative;\n padding: ', ';\n &:hover {\n border-color: ', ';\n }\n\n &:focus-within {\n border-color: ', ';\n }\n\n &::placeholder {\n color: ', ';\n opacity: ', ';\n transition: 0.2s ease all;\n }\n\n &:focus-within::placeholder {\n color: ', ';\n opacity: ', ';\n }\n\n
|
|
15
|
+
_templateObject5 = _taggedTemplateLiteral(['\nwhite-space: nowrap;\n width:100%\n box-sizing: border-box;\n border-bottom: 1px solid ', ';\n \n\n font-family: "SFUIText-Medium";\n font-size: 14px;\n color: ', ';\n\n display: inline-block;\n position: relative;\n padding: ', ';\n &:hover {\n border-color: ', ';\n }\n\n &:focus-within {\n border-color: ', ';\n }\n\n &::placeholder {\n color: ', ';\n opacity: ', ';\n transition: 0.2s ease all;\n }\n\n &:focus-within::placeholder {\n color: ', ';\n opacity: ', ';\n }\n\n'], ['\nwhite-space: nowrap;\n width:100%\n box-sizing: border-box;\n border-bottom: 1px solid ', ';\n \n\n font-family: "SFUIText-Medium";\n font-size: 14px;\n color: ', ';\n\n display: inline-block;\n position: relative;\n padding: ', ';\n &:hover {\n border-color: ', ';\n }\n\n &:focus-within {\n border-color: ', ';\n }\n\n &::placeholder {\n color: ', ';\n opacity: ', ';\n transition: 0.2s ease all;\n }\n\n &:focus-within::placeholder {\n color: ', ';\n opacity: ', ';\n }\n\n']);
|
|
16
16
|
|
|
17
17
|
var _react = require('react');
|
|
18
18
|
|
|
@@ -36,10 +36,6 @@ var _icon = require('../icon');
|
|
|
36
36
|
|
|
37
37
|
var _icon2 = _interopRequireDefault(_icon);
|
|
38
38
|
|
|
39
|
-
var _immutable = require('immutable');
|
|
40
|
-
|
|
41
|
-
var _immutable2 = _interopRequireDefault(_immutable);
|
|
42
|
-
|
|
43
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
44
40
|
|
|
45
41
|
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
|
@@ -87,7 +83,18 @@ var DraftInputText = function DraftInputText(_ref) {
|
|
|
87
83
|
editorState = _useState8[0],
|
|
88
84
|
setEditorState = _useState8[1];
|
|
89
85
|
|
|
86
|
+
var _useState9 = (0, _react.useState)(null),
|
|
87
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
88
|
+
listScrollTop = _useState10[0],
|
|
89
|
+
setListScrollTop = _useState10[1];
|
|
90
|
+
|
|
90
91
|
var contentLength = editorState.getCurrentContent().getPlainText('').length;
|
|
92
|
+
var scrollObject = localStorage.getItem('scrollObject');
|
|
93
|
+
|
|
94
|
+
if (scrollObject && JSON.parse(scrollObject).tableListScrollTop !== listScrollTop) {
|
|
95
|
+
setListScrollTop(JSON.parse(scrollObject).tableListScrollTop);
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
if (props.error && props.error.length > 0) {
|
|
92
99
|
var errorMesssage = props.error;
|
|
93
100
|
}
|
|
@@ -100,21 +107,26 @@ var DraftInputText = function DraftInputText(_ref) {
|
|
|
100
107
|
var passwordButton = props.passwordButton;
|
|
101
108
|
}
|
|
102
109
|
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @param {string} command string representing the keyboard command being invoked
|
|
113
|
+
* @param {object} editorState represents the current state of the editor, including the content, selection, and various editor properties.
|
|
114
|
+
* @returns new Editor State with applied styling
|
|
115
|
+
*/
|
|
103
116
|
var handleKeyCommand = function handleKeyCommand(command, editorState) {
|
|
104
|
-
|
|
105
|
-
props.onKeyDownFn();
|
|
106
|
-
return 'Entered Pressed';
|
|
107
|
-
} else {
|
|
108
|
-
var newState = _draftJs.RichUtils.handleKeyCommand(editorState, command);
|
|
117
|
+
var newState = _draftJs.RichUtils.handleKeyCommand(editorState, command);
|
|
109
118
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
return 'not-handled';
|
|
119
|
+
if (newState) {
|
|
120
|
+
setEditorState(newState);
|
|
121
|
+
return 'handled';
|
|
115
122
|
}
|
|
123
|
+
return 'not-handled';
|
|
116
124
|
};
|
|
117
125
|
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
* @returns Return the length of text in editor in a synchronous way
|
|
129
|
+
*/
|
|
118
130
|
var _getLengthOfSelectedText = function _getLengthOfSelectedText() {
|
|
119
131
|
var currentSelection = editorState.getSelection();
|
|
120
132
|
if (currentSelection.isCollapsed()) return 0;
|
|
@@ -129,24 +141,52 @@ var DraftInputText = function DraftInputText(_ref) {
|
|
|
129
141
|
}, 0);
|
|
130
142
|
};
|
|
131
143
|
|
|
132
|
-
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @param {string} text The text that is pasted in the editor
|
|
147
|
+
* @param {string} position tells whether we have to check for inserted text or pasted text
|
|
148
|
+
* @returns whether pasting or inserting text is feasible
|
|
149
|
+
*/
|
|
150
|
+
var _handleInput = function _handleInput(text, position) {
|
|
133
151
|
var currentContent = editorState.getCurrentContent();
|
|
134
152
|
var currentContentLength = currentContent.getPlainText('').length;
|
|
135
153
|
var selectedTextLength = _getLengthOfSelectedText();
|
|
136
154
|
|
|
137
|
-
if (
|
|
138
|
-
if (currentContentLength - selectedTextLength +
|
|
155
|
+
if (position === 'before') {
|
|
156
|
+
if (currentContentLength - selectedTextLength + text.length > maxLength - 1) {
|
|
139
157
|
console.log('You can type a maximum of ten characters');
|
|
140
158
|
return 'handled';
|
|
141
159
|
}
|
|
142
|
-
} else {
|
|
143
|
-
if (currentContentLength +
|
|
160
|
+
} else if (position === 'after') {
|
|
161
|
+
if (currentContentLength + text.length - selectedTextLength > maxLength) {
|
|
144
162
|
console.log('You can type a maximum of ten characters');
|
|
145
163
|
return 'handled';
|
|
146
164
|
}
|
|
147
165
|
}
|
|
148
166
|
};
|
|
149
167
|
|
|
168
|
+
/**
|
|
169
|
+
*
|
|
170
|
+
* @returns calls the function to check before typing the text does not exceed maximum length
|
|
171
|
+
*/
|
|
172
|
+
var _handleBeforeInput = function _handleBeforeInput() {
|
|
173
|
+
return _handleInput('', 'before');
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
*
|
|
178
|
+
* @param {string} pastedText the text that is copy pasted in our editor
|
|
179
|
+
* @returns calls the function to check copying the text does not exceed maximum length
|
|
180
|
+
*/
|
|
181
|
+
var _handlePastedText = function _handlePastedText(pastedText) {
|
|
182
|
+
return _handleInput(pastedText, 'after');
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
*
|
|
187
|
+
* @param {object} newEditorState the newstate of editor when we type any text in our editor
|
|
188
|
+
* @returns the new state of editor
|
|
189
|
+
*/
|
|
150
190
|
var _handleChange = function _handleChange(newEditorState) {
|
|
151
191
|
var contentState = newEditorState.getCurrentContent();
|
|
152
192
|
var text = contentState.getPlainText();
|
|
@@ -158,6 +198,11 @@ var DraftInputText = function DraftInputText(_ref) {
|
|
|
158
198
|
}
|
|
159
199
|
};
|
|
160
200
|
|
|
201
|
+
/**
|
|
202
|
+
*
|
|
203
|
+
* @param {string} htmlString the string that is passed to the parent
|
|
204
|
+
* @returns removes the default <p> tag of draftjs
|
|
205
|
+
*/
|
|
161
206
|
var removeOuterPTag = function removeOuterPTag(htmlString) {
|
|
162
207
|
var regex = /^<p>(.*?)<\/p>$/;
|
|
163
208
|
var match = htmlString.match(regex);
|
|
@@ -189,8 +234,7 @@ var DraftInputText = function DraftInputText(_ref) {
|
|
|
189
234
|
}, [value]);
|
|
190
235
|
|
|
191
236
|
(0, _react.useEffect)(function () {
|
|
192
|
-
|
|
193
|
-
if (scrollObject && scrollObject.tableListScrollTop) {
|
|
237
|
+
if (listScrollTop !== null) {
|
|
194
238
|
if (!props.simpleEdit) {
|
|
195
239
|
setDiff(true);
|
|
196
240
|
value = undefined;
|
|
@@ -199,7 +243,7 @@ var DraftInputText = function DraftInputText(_ref) {
|
|
|
199
243
|
});
|
|
200
244
|
}
|
|
201
245
|
}
|
|
202
|
-
}, [
|
|
246
|
+
}, [listScrollTop]);
|
|
203
247
|
|
|
204
248
|
return _react2.default.createElement(
|
|
205
249
|
DraftInputTextDiv,
|
|
@@ -217,8 +261,8 @@ var DraftInputText = function DraftInputText(_ref) {
|
|
|
217
261
|
_react2.default.createElement(_draftJs.Editor, {
|
|
218
262
|
editorState: editorState,
|
|
219
263
|
onChange: _handleChange,
|
|
220
|
-
handleBeforeInput:
|
|
221
|
-
handlePastedText:
|
|
264
|
+
handleBeforeInput: _handleBeforeInput,
|
|
265
|
+
handlePastedText: _handlePastedText,
|
|
222
266
|
handleKeyCommand: handleKeyCommand,
|
|
223
267
|
onFocus: function onFocus() {
|
|
224
268
|
return setFocus(true);
|
|
@@ -310,8 +354,6 @@ var RichTextEditorContainer = _styledComponents2.default.div(_templateObject5, f
|
|
|
310
354
|
return props.theme === 'light' ? _tokens.colors.light.inputCommon.placeholder : _tokens.colors.dark.inputCommon.placeholder;
|
|
311
355
|
}, function (props) {
|
|
312
356
|
return props.label ? '1' : '1';
|
|
313
|
-
}, function (props) {
|
|
314
|
-
return props.fieldType === 'inputField' && '\n .public-DraftStyleDefault-block.public-DraftStyleDefault-ltr {\n display: inline-block;\n overflow: hidden;\n white-space: nowrap;\n width: 100%;\n }\n ';
|
|
315
357
|
});
|
|
316
358
|
|
|
317
359
|
DraftInputText.propTypes = {
|
|
@@ -344,7 +386,7 @@ DraftInputText.propTypes = {
|
|
|
344
386
|
};
|
|
345
387
|
|
|
346
388
|
DraftInputText.defaultProps = {
|
|
347
|
-
fieldType: '
|
|
389
|
+
fieldType: 'textArea',
|
|
348
390
|
readOnly: false,
|
|
349
391
|
code: false,
|
|
350
392
|
error: null,
|
|
@@ -21,7 +21,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
21
|
null,
|
|
22
22
|
_react2.default.createElement(_components.DraftInputText, {
|
|
23
23
|
inputWidth: 300,
|
|
24
|
-
fieldType: '
|
|
24
|
+
fieldType: 'inputField',
|
|
25
25
|
showLengthCount: true,
|
|
26
26
|
type: 'text',
|
|
27
27
|
label: 'First Name',
|
|
@@ -133,7 +133,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
133
133
|
label: 'First Name',
|
|
134
134
|
showLengthCount: true,
|
|
135
135
|
value: 'Lorem ',
|
|
136
|
-
maxLength:
|
|
136
|
+
maxLength: 200,
|
|
137
137
|
onChange: function onChange(e) {
|
|
138
138
|
return console.log(e.html, e.size);
|
|
139
139
|
},
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@desynova-digital/components",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.6",
|
|
4
4
|
"description": "Components for Desynova Digital",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "desynova-digital",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": "desynova-digital",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@desynova-digital/tokens": "9.0.
|
|
10
|
+
"@desynova-digital/tokens": "9.0.6",
|
|
11
11
|
"prop-types": "^15.7.2",
|
|
12
12
|
"styled-components": "^4.3.2"
|
|
13
13
|
},
|