@desynova-digital/components 8.19.63 → 9.0.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/atoms/avatar/avatar.js +1 -1
- package/atoms/avatar/avatar.story.js +46 -14
- package/atoms/badge/badge.js +13 -13
- package/atoms/badge/badge.story.js +91 -29
- package/atoms/button/button.js +81 -85
- package/atoms/button/button.story.js +342 -2
- package/atoms/card/card.js +43 -39
- package/atoms/card/card.story.js +74 -48
- package/atoms/cardStack/cardStack.js +182 -155
- package/atoms/cardStack/cardStack.story.js +131 -18
- package/atoms/cardV2/cardV2.js +23 -23
- package/atoms/cardV2/cardV2.story.js +196 -45
- package/atoms/cardV2/content.js +109 -87
- package/atoms/cardV2/thumbnail.js +85 -72
- package/atoms/cardV2/timeline.js +119 -107
- package/atoms/checkbox/checkbox.js +41 -32
- package/atoms/checkbox/checkbox.story.js +220 -99
- package/atoms/customSelect/customSelect.story.js +820 -582
- package/atoms/datePicker/datePicker.js +77 -83
- package/atoms/datePicker/datePicker.story.js +167 -1
- package/atoms/dateTime/dateTime.story.js +26 -1
- package/atoms/draftInputText/draftInputText.js +358 -0
- package/atoms/draftInputText/draftInputText.story.js +251 -0
- package/atoms/draftInputText/index.js +13 -0
- package/atoms/dropdown/dropdown.story.js +146 -18
- package/atoms/dropdownList/dropdownList.story.js +1598 -1091
- package/atoms/graphs/barGraph/barGraph.js +143 -130
- package/atoms/graphs/barGraph/barGraph.story.js +74 -40
- package/atoms/graphs/circleDonut/circleDonut.story.js +374 -220
- package/atoms/graphs/circleGraph/circleGraph.js +84 -80
- package/atoms/graphs/circleGraph/circleGraph.story.js +38 -26
- package/atoms/graphs/circleNested/circleNested.story.js +98 -103
- package/atoms/graphs/pieChart/pieChart.story.js +160 -81
- package/atoms/graphs/verticalBarGraph/verticalBarGraph.story.js +30 -28
- package/atoms/icon/icon.story.js +220 -163
- package/atoms/inputText/inputText.js +52 -49
- package/atoms/label/label.js +29 -29
- package/atoms/label/label.story.js +42 -30
- package/atoms/loader/CircleLoader.js +13 -4
- package/atoms/loader/CircleLoader.jsx +10 -4
- package/atoms/loader/ThreeDotLoader.js +8 -4
- package/atoms/loader/ThreeDotLoader.jsx +4 -4
- package/atoms/loader/loader.js +29 -30
- package/atoms/loader/loader.story.js +38 -23
- package/atoms/loader/spinningLoader.js +7 -4
- package/atoms/loader/spinningLoader.jsx +5 -5
- package/atoms/popup/popup.js +11 -11
- package/atoms/popup/popup.story.js +36 -4
- package/atoms/radio/radio.story.js +140 -2
- package/atoms/sideBar/sidebar.js +19 -5
- package/atoms/sideBar/sidebar.jsx +13 -8
- package/atoms/switch/switch.js +72 -66
- package/atoms/switch/switch.story.js +323 -78
- package/atoms/tag/tag.js +39 -39
- package/atoms/tag/tag.story.js +83 -2
- package/atoms/textarea/textarea.js +36 -34
- package/atoms/timeCodeInput/timCodeInput.story.js +10 -9
- package/atoms/timeCodeInput/timeCodeInput.js +108 -100
- package/atoms/timer/timer.js +127 -126
- package/atoms/toast/toast.js +24 -14
- package/atoms/toast/toast.story.js +22 -0
- package/atoms/videoCard/videoCard.js +226 -203
- package/atoms/videoCard/videoCard.story.js +547 -186
- package/components.js +69 -66
- package/index.js +5 -4
- package/molecules/carousel/carousel.js +55 -67
- package/molecules/filter/filter.js +133 -106
- package/molecules/filter/filter.story.js +215 -173
- package/molecules/graphCard/graphCard.js +34 -24
- package/molecules/graphCard/graphCard.story.js +169 -82
- package/molecules/graphDetailCard/graphDetailCard.js +207 -182
- package/molecules/pageHeader/pageHeader.js +3 -2
- package/molecules/pageHeader/pageHeader.story.js +40 -18
- package/molecules/pagination/pagination.js +66 -14
- package/molecules/pagination/pagination.story.js +24 -2
- package/molecules/table/table.js +368 -316
- package/molecules/table/table.story.js +404 -208
- package/molecules/tabs/tabs.js +15 -6
- package/molecules/tabs/tabs.story.js +26 -0
- package/package.json +2 -2
|
@@ -32,7 +32,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
32
32
|
),
|
|
33
33
|
_react2.default.createElement(_components.DatePicker, {
|
|
34
34
|
label: 'from',
|
|
35
|
-
error:
|
|
35
|
+
error: 'Select date',
|
|
36
36
|
rangePicker: false,
|
|
37
37
|
minDate: null,
|
|
38
38
|
maxDate: null,
|
|
@@ -336,4 +336,170 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
336
336
|
)
|
|
337
337
|
)
|
|
338
338
|
);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
(0, _react3.storiesOf)('DatePicker').add('nexc theme', function () {
|
|
342
|
+
return _react2.default.createElement(
|
|
343
|
+
_storyHelpers.Example,
|
|
344
|
+
{ title: 'Appearances Light', background: 'dark' },
|
|
345
|
+
_react2.default.createElement(
|
|
346
|
+
_storyHelpers.Stack,
|
|
347
|
+
null,
|
|
348
|
+
_react2.default.createElement(
|
|
349
|
+
'div',
|
|
350
|
+
{ style: { width: '100%' } },
|
|
351
|
+
_react2.default.createElement(
|
|
352
|
+
'div',
|
|
353
|
+
{ style: { width: '200px', marginTop: '30px' } },
|
|
354
|
+
_react2.default.createElement(
|
|
355
|
+
'h5',
|
|
356
|
+
{ style: { fontWeight: 'bold' } },
|
|
357
|
+
'Simple Absoulte'
|
|
358
|
+
),
|
|
359
|
+
_react2.default.createElement(_components.DatePicker, {
|
|
360
|
+
theme: 'nexc',
|
|
361
|
+
label: 'from',
|
|
362
|
+
rangePicker: false,
|
|
363
|
+
minDate: null,
|
|
364
|
+
maxDate: null,
|
|
365
|
+
inline: false,
|
|
366
|
+
selected: null,
|
|
367
|
+
onSelectionChange: function onSelectionChange(date) {
|
|
368
|
+
console.log(date);
|
|
369
|
+
}
|
|
370
|
+
})
|
|
371
|
+
),
|
|
372
|
+
_react2.default.createElement(
|
|
373
|
+
'div',
|
|
374
|
+
{ style: { width: '300px', marginTop: '30px' } },
|
|
375
|
+
_react2.default.createElement(
|
|
376
|
+
'h5',
|
|
377
|
+
{ style: { fontWeight: 'bold' } },
|
|
378
|
+
'Simple Absoulte - default Selected'
|
|
379
|
+
),
|
|
380
|
+
_react2.default.createElement(_components.DatePicker, {
|
|
381
|
+
theme: 'nexc',
|
|
382
|
+
label: 'from',
|
|
383
|
+
rangePicker: false,
|
|
384
|
+
minDate: null,
|
|
385
|
+
maxDate: null,
|
|
386
|
+
inline: false,
|
|
387
|
+
selected: ['17/10/2018'],
|
|
388
|
+
onSelectionChange: function onSelectionChange(date) {
|
|
389
|
+
console.log(date);
|
|
390
|
+
}
|
|
391
|
+
})
|
|
392
|
+
),
|
|
393
|
+
_react2.default.createElement(
|
|
394
|
+
'div',
|
|
395
|
+
{ style: { width: '300px', marginTop: '30px' } },
|
|
396
|
+
_react2.default.createElement(
|
|
397
|
+
'h5',
|
|
398
|
+
{ style: { fontWeight: 'bold' } },
|
|
399
|
+
'Simple Inline '
|
|
400
|
+
),
|
|
401
|
+
_react2.default.createElement(_components.DatePicker, {
|
|
402
|
+
theme: 'nexc',
|
|
403
|
+
label: 'from',
|
|
404
|
+
rangePicker: false,
|
|
405
|
+
minDate: null,
|
|
406
|
+
maxDate: null,
|
|
407
|
+
inline: true,
|
|
408
|
+
selected: null,
|
|
409
|
+
onSelectionChange: function onSelectionChange(date) {
|
|
410
|
+
console.log(date);
|
|
411
|
+
}
|
|
412
|
+
})
|
|
413
|
+
),
|
|
414
|
+
_react2.default.createElement(
|
|
415
|
+
'div',
|
|
416
|
+
{ style: { width: '300px', marginTop: '30px' } },
|
|
417
|
+
_react2.default.createElement(
|
|
418
|
+
'h5',
|
|
419
|
+
{ style: { fontWeight: 'bold' } },
|
|
420
|
+
'Simple Inline - Default selected'
|
|
421
|
+
),
|
|
422
|
+
_react2.default.createElement(_components.DatePicker, {
|
|
423
|
+
theme: 'nexc',
|
|
424
|
+
label: 'from',
|
|
425
|
+
rangePicker: false,
|
|
426
|
+
minDate: null,
|
|
427
|
+
maxDate: null,
|
|
428
|
+
inline: true,
|
|
429
|
+
selected: ['17/8/2018'],
|
|
430
|
+
onSelectionChange: function onSelectionChange(date) {
|
|
431
|
+
console.log(date);
|
|
432
|
+
}
|
|
433
|
+
})
|
|
434
|
+
),
|
|
435
|
+
_react2.default.createElement(
|
|
436
|
+
'div',
|
|
437
|
+
{ style: { width: '300px', marginTop: '30px' } },
|
|
438
|
+
_react2.default.createElement(
|
|
439
|
+
'h5',
|
|
440
|
+
{ style: { fontWeight: 'bold' } },
|
|
441
|
+
'Simple Inline: Min - Max and disabled Dates',
|
|
442
|
+
_react2.default.createElement('br', null),
|
|
443
|
+
'15/06/2018 - 14/010/2018, ["15/08/2018","19/08/2018","22/8/2018"]'
|
|
444
|
+
),
|
|
445
|
+
_react2.default.createElement(_components.DatePicker, {
|
|
446
|
+
theme: 'nexc',
|
|
447
|
+
label: 'from',
|
|
448
|
+
rangePicker: false,
|
|
449
|
+
minDate: '15/06/2018',
|
|
450
|
+
maxDate: '14/10/2018',
|
|
451
|
+
disabledDates: ['15/08/2018', '19/08/2018', '22/8/2018'],
|
|
452
|
+
inline: true,
|
|
453
|
+
onSelectionChange: function onSelectionChange(date) {
|
|
454
|
+
console.log(date);
|
|
455
|
+
}
|
|
456
|
+
})
|
|
457
|
+
),
|
|
458
|
+
_react2.default.createElement(
|
|
459
|
+
'div',
|
|
460
|
+
{ style: { width: '300px', marginTop: '30px' } },
|
|
461
|
+
_react2.default.createElement(
|
|
462
|
+
'h5',
|
|
463
|
+
{ style: { fontWeight: 'bold' } },
|
|
464
|
+
'Date Range popup'
|
|
465
|
+
),
|
|
466
|
+
_react2.default.createElement(_components.DatePicker, {
|
|
467
|
+
theme: 'nexc',
|
|
468
|
+
label: 'from',
|
|
469
|
+
label2: 'to',
|
|
470
|
+
rangePicker: true,
|
|
471
|
+
minDate: null,
|
|
472
|
+
maxDate: null,
|
|
473
|
+
inline: false,
|
|
474
|
+
selected: null,
|
|
475
|
+
onSelectionChange: function onSelectionChange(date) {
|
|
476
|
+
console.log(date);
|
|
477
|
+
}
|
|
478
|
+
})
|
|
479
|
+
),
|
|
480
|
+
_react2.default.createElement(
|
|
481
|
+
'div',
|
|
482
|
+
{ style: { width: '300px', marginTop: '30px' } },
|
|
483
|
+
_react2.default.createElement(
|
|
484
|
+
'h5',
|
|
485
|
+
{ style: { fontWeight: 'bold' } },
|
|
486
|
+
'Date Range inline'
|
|
487
|
+
),
|
|
488
|
+
_react2.default.createElement(_components.DatePicker, {
|
|
489
|
+
theme: 'nexc',
|
|
490
|
+
label: 'from',
|
|
491
|
+
label2: 'to',
|
|
492
|
+
rangePicker: true,
|
|
493
|
+
minDate: null,
|
|
494
|
+
maxDate: null,
|
|
495
|
+
inline: true,
|
|
496
|
+
selected: null,
|
|
497
|
+
onSelectionChange: function onSelectionChange(date) {
|
|
498
|
+
console.log(date);
|
|
499
|
+
}
|
|
500
|
+
})
|
|
501
|
+
)
|
|
502
|
+
)
|
|
503
|
+
)
|
|
504
|
+
);
|
|
339
505
|
});
|
|
@@ -14,7 +14,7 @@ var _dateTime2 = _interopRequireDefault(_dateTime);
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
-
(0, _react3.storiesOf)('DateTime').add('
|
|
17
|
+
(0, _react3.storiesOf)('DateTime').add('light theme', function () {
|
|
18
18
|
return _react2.default.createElement(
|
|
19
19
|
_storyHelpers.Example,
|
|
20
20
|
{ title: 'DateTime', background: 'light' },
|
|
@@ -37,4 +37,29 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
37
37
|
)
|
|
38
38
|
)
|
|
39
39
|
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
(0, _react3.storiesOf)('DateTime').add('dark theme', function () {
|
|
43
|
+
return _react2.default.createElement(
|
|
44
|
+
_storyHelpers.Example,
|
|
45
|
+
{ title: 'DateTime', background: 'dark' },
|
|
46
|
+
_react2.default.createElement(
|
|
47
|
+
_storyHelpers.Stack,
|
|
48
|
+
null,
|
|
49
|
+
_react2.default.createElement(
|
|
50
|
+
'div',
|
|
51
|
+
null,
|
|
52
|
+
_react2.default.createElement(
|
|
53
|
+
'h1',
|
|
54
|
+
null,
|
|
55
|
+
_dateTime2.default.toDateString(1579176064345, 'mmm DD, YYYY')
|
|
56
|
+
),
|
|
57
|
+
_react2.default.createElement(
|
|
58
|
+
'h1',
|
|
59
|
+
null,
|
|
60
|
+
_dateTime2.default.toTimeString(1579176064345, 'HH:MM AP')
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
);
|
|
40
65
|
});
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
8
|
+
|
|
9
|
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
10
|
+
|
|
11
|
+
var _templateObject = _taggedTemplateLiteral(['\n background: transparent;\n font-family: \'SFUIText-Medium\';\n position: relative;\n width:92%;\n margin-bottom:10px;\n margin-top:10px\n display: block;\n > label {\n color: #999999;\n font-size: 14px;\n font-family: inherit;\n position: absolute;\n pointer-events: none;\n left: 0px;\n top: 5px;\n transition: 0.2s ease all;\n -moz-transition: 0.2s ease all;\n -webkit-transition: 0.2s ease all;\n }\n > div:focus ~ label {\n top: -10px;\n left: 0px;\n font-size: 10px;\n color: #999999;\n text-transform: capitalize;\n }\n > div ~ label.floaton {\n top: -10px;\n left: 0px;\n font-size: 10px;\n color: #999999;\n text-transform: capitalize;\n }\n'], ['\n background: transparent;\n font-family: \'SFUIText-Medium\';\n position: relative;\n width:92%;\n margin-bottom:10px;\n margin-top:10px\n display: block;\n > label {\n color: #999999;\n font-size: 14px;\n font-family: inherit;\n position: absolute;\n pointer-events: none;\n left: 0px;\n top: 5px;\n transition: 0.2s ease all;\n -moz-transition: 0.2s ease all;\n -webkit-transition: 0.2s ease all;\n }\n > div:focus ~ label {\n top: -10px;\n left: 0px;\n font-size: 10px;\n color: #999999;\n text-transform: capitalize;\n }\n > div ~ label.floaton {\n top: -10px;\n left: 0px;\n font-size: 10px;\n color: #999999;\n text-transform: capitalize;\n }\n']),
|
|
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
|
+
_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
|
+
_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 \n ', '\n\n\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 \n ', '\n\n\n \n\n']);
|
|
16
|
+
|
|
17
|
+
var _react = require('react');
|
|
18
|
+
|
|
19
|
+
var _react2 = _interopRequireDefault(_react);
|
|
20
|
+
|
|
21
|
+
var _draftJs = require('draft-js');
|
|
22
|
+
|
|
23
|
+
var _propTypes = require('prop-types');
|
|
24
|
+
|
|
25
|
+
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
26
|
+
|
|
27
|
+
var _styledComponents = require('styled-components');
|
|
28
|
+
|
|
29
|
+
var _styledComponents2 = _interopRequireDefault(_styledComponents);
|
|
30
|
+
|
|
31
|
+
var _tokens = require('@desynova-digital/tokens');
|
|
32
|
+
|
|
33
|
+
var _draftConvert = require('draft-convert');
|
|
34
|
+
|
|
35
|
+
var _icon = require('../icon');
|
|
36
|
+
|
|
37
|
+
var _icon2 = _interopRequireDefault(_icon);
|
|
38
|
+
|
|
39
|
+
var _immutable = require('immutable');
|
|
40
|
+
|
|
41
|
+
var _immutable2 = _interopRequireDefault(_immutable);
|
|
42
|
+
|
|
43
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
44
|
+
|
|
45
|
+
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; }
|
|
46
|
+
|
|
47
|
+
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
48
|
+
|
|
49
|
+
var DraftInputTextDiv = _styledComponents2.default.div(_templateObject);
|
|
50
|
+
|
|
51
|
+
var PasswordToggleButton = _styledComponents2.default.div(_templateObject2);
|
|
52
|
+
|
|
53
|
+
var CountWrappper = _styledComponents2.default.div(_templateObject3);
|
|
54
|
+
|
|
55
|
+
var DraftInputError = _styledComponents2.default.span(_templateObject4, function (props) {
|
|
56
|
+
return _tokens.colors[props.theme].inputError.color;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var DraftInputText = function DraftInputText(_ref) {
|
|
60
|
+
var maxLength = _ref.maxLength,
|
|
61
|
+
defaultValue = _ref.defaultValue,
|
|
62
|
+
type = _ref.type,
|
|
63
|
+
showLengthCount = _ref.showLengthCount,
|
|
64
|
+
label = _ref.label,
|
|
65
|
+
value = _ref.value,
|
|
66
|
+
props = _objectWithoutProperties(_ref, ['maxLength', 'defaultValue', 'type', 'showLengthCount', 'label', 'value']);
|
|
67
|
+
|
|
68
|
+
var _useState = (0, _react.useState)(true),
|
|
69
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
70
|
+
hidden = _useState2[0],
|
|
71
|
+
togglePassword = _useState2[1];
|
|
72
|
+
|
|
73
|
+
var _useState3 = (0, _react.useState)(true),
|
|
74
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
75
|
+
diff = _useState4[0],
|
|
76
|
+
setDiff = _useState4[1];
|
|
77
|
+
|
|
78
|
+
var _useState5 = (0, _react.useState)(false),
|
|
79
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
80
|
+
focus = _useState6[0],
|
|
81
|
+
setFocus = _useState6[1];
|
|
82
|
+
|
|
83
|
+
var _useState7 = (0, _react.useState)(function () {
|
|
84
|
+
return _draftJs.EditorState.createEmpty();
|
|
85
|
+
}),
|
|
86
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
87
|
+
editorState = _useState8[0],
|
|
88
|
+
setEditorState = _useState8[1];
|
|
89
|
+
|
|
90
|
+
var contentLength = editorState.getCurrentContent().getPlainText('').length;
|
|
91
|
+
if (props.error && props.error.length > 0) {
|
|
92
|
+
var errorMesssage = props.error;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (props.readOnly) {
|
|
96
|
+
props.disabled = true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (props.passwordButton) {
|
|
100
|
+
var passwordButton = props.passwordButton;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var handleKeyCommand = function handleKeyCommand(command, editorState) {
|
|
104
|
+
if (command === 'split-block') {
|
|
105
|
+
props.onKeyDownFn();
|
|
106
|
+
return 'Entered Pressed';
|
|
107
|
+
} else {
|
|
108
|
+
var newState = _draftJs.RichUtils.handleKeyCommand(editorState, command);
|
|
109
|
+
|
|
110
|
+
if (newState) {
|
|
111
|
+
setEditorState(newState);
|
|
112
|
+
return 'handled';
|
|
113
|
+
}
|
|
114
|
+
return 'not-handled';
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
var _getLengthOfSelectedText = function _getLengthOfSelectedText() {
|
|
119
|
+
var currentSelection = editorState.getSelection();
|
|
120
|
+
if (currentSelection.isCollapsed()) return 0;
|
|
121
|
+
|
|
122
|
+
var selectedBlocks = DraftJS.SelectionState.createEmpty(currentSelection.getStartKey()).merge({
|
|
123
|
+
focusKey: currentSelection.getEndKey(),
|
|
124
|
+
focusOffset: currentSelection.getEndOffset()
|
|
125
|
+
}).getBlocksAsArray();
|
|
126
|
+
|
|
127
|
+
return selectedBlocks.reduce(function (length, block) {
|
|
128
|
+
return length + block.getText().length;
|
|
129
|
+
}, 0);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
var _handleBeforeInputAndPastedText = function _handleBeforeInputAndPastedText(charsOrText, editorState) {
|
|
133
|
+
var currentContent = editorState.getCurrentContent();
|
|
134
|
+
var currentContentLength = currentContent.getPlainText('').length;
|
|
135
|
+
var selectedTextLength = _getLengthOfSelectedText();
|
|
136
|
+
|
|
137
|
+
if (charsOrText && typeof charsOrText === 'string') {
|
|
138
|
+
if (currentContentLength - selectedTextLength + charsOrText.length > maxLength) {
|
|
139
|
+
console.log('You can type a maximum of ten characters');
|
|
140
|
+
return 'handled';
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
if (currentContentLength + charsOrText.length - selectedTextLength > maxLength) {
|
|
144
|
+
console.log('You can type a maximum of ten characters');
|
|
145
|
+
return 'handled';
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
var _handleChange = function _handleChange(newEditorState) {
|
|
151
|
+
var contentState = newEditorState.getCurrentContent();
|
|
152
|
+
var text = contentState.getPlainText();
|
|
153
|
+
|
|
154
|
+
if (text.length <= maxLength) {
|
|
155
|
+
setEditorState(newEditorState);
|
|
156
|
+
} else {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
var removeOuterPTag = function removeOuterPTag(htmlString) {
|
|
162
|
+
var regex = /^<p>(.*?)<\/p>$/;
|
|
163
|
+
var match = htmlString.match(regex);
|
|
164
|
+
return match ? match[1] : htmlString;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
(0, _react.useEffect)(function () {
|
|
168
|
+
var html = (0, _draftConvert.convertToHTML)(editorState.getCurrentContent());
|
|
169
|
+
html = removeOuterPTag(html);
|
|
170
|
+
var obj = {
|
|
171
|
+
size: contentLength,
|
|
172
|
+
html: html
|
|
173
|
+
};
|
|
174
|
+
if (props.onChange) {
|
|
175
|
+
props.onChange(obj.html);
|
|
176
|
+
}
|
|
177
|
+
}, [editorState]);
|
|
178
|
+
|
|
179
|
+
(0, _react.useEffect)(function () {
|
|
180
|
+
if (diff && value !== '' && value !== undefined) {
|
|
181
|
+
setDiff(false);
|
|
182
|
+
setFocus(true);
|
|
183
|
+
var dummy = (0, _draftConvert.convertFromHTML)(value);
|
|
184
|
+
var newState = _draftJs.EditorState.createWithContent(dummy);
|
|
185
|
+
setEditorState(function () {
|
|
186
|
+
return _draftJs.EditorState.moveFocusToEnd(newState);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}, [value]);
|
|
190
|
+
|
|
191
|
+
(0, _react.useEffect)(function () {
|
|
192
|
+
var scrollObject = JSON.parse(localStorage.getItem('scrollObject'));
|
|
193
|
+
if (scrollObject && scrollObject.tableListScrollTop) {
|
|
194
|
+
if (!props.simpleEdit) {
|
|
195
|
+
setDiff(true);
|
|
196
|
+
value = undefined;
|
|
197
|
+
setEditorState(function () {
|
|
198
|
+
return _draftJs.EditorState.createEmpty();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}, [localStorage.getItem('scrollObject')]);
|
|
203
|
+
|
|
204
|
+
return _react2.default.createElement(
|
|
205
|
+
DraftInputTextDiv,
|
|
206
|
+
{ theme: props.theme, inputWidth: props.inputWidth },
|
|
207
|
+
_react2.default.createElement(
|
|
208
|
+
RichTextEditorContainer,
|
|
209
|
+
_extends({
|
|
210
|
+
type: hidden ? type : 'text',
|
|
211
|
+
value: value,
|
|
212
|
+
defaultValue: defaultValue
|
|
213
|
+
}, props, {
|
|
214
|
+
maxLength: maxLength || '',
|
|
215
|
+
showLengthCount: showLengthCount || false
|
|
216
|
+
}),
|
|
217
|
+
_react2.default.createElement(_draftJs.Editor, {
|
|
218
|
+
editorState: editorState,
|
|
219
|
+
onChange: _handleChange,
|
|
220
|
+
handleBeforeInput: _handleBeforeInputAndPastedText,
|
|
221
|
+
handlePastedText: _handleBeforeInputAndPastedText,
|
|
222
|
+
handleKeyCommand: handleKeyCommand,
|
|
223
|
+
onFocus: function onFocus() {
|
|
224
|
+
return setFocus(true);
|
|
225
|
+
},
|
|
226
|
+
onBlur: function onBlur() {
|
|
227
|
+
return setFocus(false);
|
|
228
|
+
},
|
|
229
|
+
handleReturn: function handleReturn(e) {
|
|
230
|
+
props.onKeyDownFn();
|
|
231
|
+
return 'handled';
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
),
|
|
235
|
+
label && _react2.default.createElement(
|
|
236
|
+
'label',
|
|
237
|
+
{
|
|
238
|
+
htmlFor: props.id,
|
|
239
|
+
className: editorState.getCurrentContent().hasText() || focus ? 'floaton' : ''
|
|
240
|
+
},
|
|
241
|
+
'' + label + (props.isRequired ? '*' : '')
|
|
242
|
+
),
|
|
243
|
+
errorMesssage ? _react2.default.createElement(
|
|
244
|
+
DraftInputError,
|
|
245
|
+
{ value: value, theme: props.theme, error: props.error },
|
|
246
|
+
errorMesssage
|
|
247
|
+
) : '',
|
|
248
|
+
maxLength && showLengthCount && _react2.default.createElement(
|
|
249
|
+
CountWrappper,
|
|
250
|
+
null,
|
|
251
|
+
contentLength,
|
|
252
|
+
'/',
|
|
253
|
+
maxLength
|
|
254
|
+
),
|
|
255
|
+
type == 'password' || passwordButton ? _react2.default.createElement(
|
|
256
|
+
PasswordToggleButton,
|
|
257
|
+
{
|
|
258
|
+
type: 'button',
|
|
259
|
+
className: 'password-toggle',
|
|
260
|
+
onClick: function onClick() {
|
|
261
|
+
return togglePassword(!hidden);
|
|
262
|
+
},
|
|
263
|
+
hiddenEye: errorMesssage ? true : false
|
|
264
|
+
},
|
|
265
|
+
hidden ? _react2.default.createElement(_icon2.default, { name: 'show-password', width: 18, height: 15, color: '#999' }) : _react2.default.createElement(_icon2.default, { name: 'hide-password', width: 18, height: 15, color: '#999' })
|
|
266
|
+
) : ''
|
|
267
|
+
);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
var returnPadding = function returnPadding(props) {
|
|
271
|
+
var digitCount = props.maxLength.toString().length;
|
|
272
|
+
|
|
273
|
+
if (props.type === 'password') {
|
|
274
|
+
return '7px 23px 2px 0px';
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
switch (digitCount) {
|
|
278
|
+
case 0:
|
|
279
|
+
return '7px 0px 2px 0px';
|
|
280
|
+
case 1:
|
|
281
|
+
return '7px 40px 2px 0px';
|
|
282
|
+
case 2:
|
|
283
|
+
return '7px 60px 2px 0px';
|
|
284
|
+
case 3:
|
|
285
|
+
return '7px 75px 2px 0px';
|
|
286
|
+
case 4:
|
|
287
|
+
return '7px 90px 2px 0px';
|
|
288
|
+
case 5:
|
|
289
|
+
return '7px 110px 2px 0px';
|
|
290
|
+
default:
|
|
291
|
+
return '7px 0px 2px 0px';
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
var RichTextEditorContainer = _styledComponents2.default.div(_templateObject5, function (props) {
|
|
296
|
+
return props.theme === 'light' ? _tokens.colors.light.inputCommon.border : _tokens.colors.dark.inputCommon.border;
|
|
297
|
+
}, function (props) {
|
|
298
|
+
return props.theme === 'light' ? _tokens.colors.light.inputCommon.color : _tokens.colors.dark.inputCommon.color;
|
|
299
|
+
}, function (props) {
|
|
300
|
+
return returnPadding(props || '');
|
|
301
|
+
}, function (props) {
|
|
302
|
+
return props.theme === 'light' ? _tokens.colors.light.inputCommon.borderHover : _tokens.colors.dark.inputCommon.borderHover;
|
|
303
|
+
}, function (props) {
|
|
304
|
+
return props.theme === 'light' ? _tokens.colors.light.inputCommon.borderHover : _tokens.colors.dark.inputCommon.borderHover;
|
|
305
|
+
}, function (props) {
|
|
306
|
+
return props.theme === 'light' ? _tokens.colors.light.inputCommon.placeholder : _tokens.colors.dark.inputCommon.placeholder;
|
|
307
|
+
}, function (props) {
|
|
308
|
+
return props.label ? '0' : '1';
|
|
309
|
+
}, function (props) {
|
|
310
|
+
return props.theme === 'light' ? _tokens.colors.light.inputCommon.placeholder : _tokens.colors.dark.inputCommon.placeholder;
|
|
311
|
+
}, function (props) {
|
|
312
|
+
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
|
+
});
|
|
316
|
+
|
|
317
|
+
DraftInputText.propTypes = {
|
|
318
|
+
masked: _propTypes2.default.bool,
|
|
319
|
+
/** Make input readOnly if it does not validate constraint */
|
|
320
|
+
readOnly: _propTypes2.default.bool,
|
|
321
|
+
/** Use when the expected input is code */
|
|
322
|
+
code: _propTypes2.default.bool,
|
|
323
|
+
/** Pass hasError to show error state */
|
|
324
|
+
hasError: _propTypes2.default.bool,
|
|
325
|
+
/** Pass error string directly to show error state */
|
|
326
|
+
error: _propTypes2.default.string,
|
|
327
|
+
/** onChange transparently passed to the input */
|
|
328
|
+
onChange: _propTypes2.default.func,
|
|
329
|
+
onKeyDownFn: _propTypes2.default.func,
|
|
330
|
+
/** Text to display when the input is empty */
|
|
331
|
+
placeholder: _propTypes2.default.string,
|
|
332
|
+
/** The default value for the field */
|
|
333
|
+
defaultValue: _propTypes2.default.string,
|
|
334
|
+
/** The (HTML) type for the input. */
|
|
335
|
+
type: _propTypes2.default.string,
|
|
336
|
+
value: _propTypes2.default.string,
|
|
337
|
+
/** The (HTML) maxLength for the input. */
|
|
338
|
+
maxLength: _propTypes2.default.number,
|
|
339
|
+
inputWidth: _propTypes2.default.number,
|
|
340
|
+
showLengthCount: _propTypes2.default.bool,
|
|
341
|
+
simpleEdit: _propTypes2.default.bool,
|
|
342
|
+
theme: _propTypes2.default.oneOf(['light', 'dark', 'nexc']),
|
|
343
|
+
fieldType: _propTypes2.default.oneOf(['inputField', 'textArea'])
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
DraftInputText.defaultProps = {
|
|
347
|
+
fieldType: 'inputField',
|
|
348
|
+
readOnly: false,
|
|
349
|
+
code: false,
|
|
350
|
+
error: null,
|
|
351
|
+
onChange: null,
|
|
352
|
+
type: 'text',
|
|
353
|
+
theme: 'light',
|
|
354
|
+
showLengthCount: false,
|
|
355
|
+
simpleEdit: false
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
exports.default = DraftInputText;
|