@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
package/atoms/tag/tag.story.js
CHANGED
|
@@ -18,17 +18,38 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
{ title: 'Tag', background: 'white' },
|
|
19
19
|
_react2.default.createElement(
|
|
20
20
|
_components.Tag,
|
|
21
|
-
{
|
|
21
|
+
{
|
|
22
|
+
onClick: function onClick(evt) {
|
|
22
23
|
return alert('First tag was clicked!');
|
|
23
24
|
},
|
|
24
25
|
onRemove: function onRemove(evt) {
|
|
25
26
|
return alert('First tag was removed!');
|
|
26
|
-
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
27
29
|
'Example'
|
|
28
30
|
)
|
|
29
31
|
);
|
|
30
32
|
});
|
|
31
33
|
|
|
34
|
+
(0, _react3.storiesOf)('Tag').add('default nexc', function () {
|
|
35
|
+
return _react2.default.createElement(
|
|
36
|
+
_storyHelpers.Example,
|
|
37
|
+
{ title: 'Tag', background: 'white' },
|
|
38
|
+
_react2.default.createElement(
|
|
39
|
+
_components.Tag,
|
|
40
|
+
{
|
|
41
|
+
theme: 'nexc',
|
|
42
|
+
onClick: function onClick(evt) {
|
|
43
|
+
return alert('First tag was clicked!');
|
|
44
|
+
},
|
|
45
|
+
onRemove: function onRemove(evt) {
|
|
46
|
+
return alert('First tag was removed!');
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
'Example'
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
});
|
|
32
53
|
(0, _react3.storiesOf)('Tag').add('without remove callback', function () {
|
|
33
54
|
return _react2.default.createElement(
|
|
34
55
|
_storyHelpers.Example,
|
|
@@ -43,6 +64,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
43
64
|
);
|
|
44
65
|
});
|
|
45
66
|
|
|
67
|
+
(0, _react3.storiesOf)('Tag').add('without remove callback nexc ', function () {
|
|
68
|
+
return _react2.default.createElement(
|
|
69
|
+
_storyHelpers.Example,
|
|
70
|
+
{ title: 'Tag', background: 'white' },
|
|
71
|
+
_react2.default.createElement(
|
|
72
|
+
_components.Tag,
|
|
73
|
+
{ theme: 'nexc', onClick: function onClick(evt) {
|
|
74
|
+
return false;
|
|
75
|
+
} },
|
|
76
|
+
'Example'
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
46
81
|
(0, _react3.storiesOf)('Tag').add('tag group dark theme', function () {
|
|
47
82
|
return _react2.default.createElement(
|
|
48
83
|
_storyHelpers.Example,
|
|
@@ -133,4 +168,50 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
133
168
|
)
|
|
134
169
|
)
|
|
135
170
|
);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
(0, _react3.storiesOf)('Tag').add('tag group nexc theme', function () {
|
|
174
|
+
return _react2.default.createElement(
|
|
175
|
+
_storyHelpers.Example,
|
|
176
|
+
{ title: 'Tag', background: 'dark' },
|
|
177
|
+
_react2.default.createElement(
|
|
178
|
+
_components.Tag.Group,
|
|
179
|
+
null,
|
|
180
|
+
_react2.default.createElement(
|
|
181
|
+
_components.Tag,
|
|
182
|
+
{ theme: 'nexc', onRemove: function onRemove(evt) {
|
|
183
|
+
return false;
|
|
184
|
+
} },
|
|
185
|
+
'Thiruvananthapuram'
|
|
186
|
+
),
|
|
187
|
+
_react2.default.createElement(
|
|
188
|
+
_components.Tag,
|
|
189
|
+
{ theme: 'nexc', onRemove: function onRemove(evt) {
|
|
190
|
+
return false;
|
|
191
|
+
} },
|
|
192
|
+
'Week'
|
|
193
|
+
),
|
|
194
|
+
_react2.default.createElement(
|
|
195
|
+
_components.Tag,
|
|
196
|
+
{ theme: 'nexc', onRemove: function onRemove(evt) {
|
|
197
|
+
return false;
|
|
198
|
+
} },
|
|
199
|
+
'Vijaya HD'
|
|
200
|
+
),
|
|
201
|
+
_react2.default.createElement(
|
|
202
|
+
_components.Tag,
|
|
203
|
+
{ theme: 'nexc', onRemove: function onRemove(evt) {
|
|
204
|
+
return false;
|
|
205
|
+
} },
|
|
206
|
+
'Shows'
|
|
207
|
+
),
|
|
208
|
+
_react2.default.createElement(
|
|
209
|
+
_components.Tag,
|
|
210
|
+
{ theme: 'nexc', onRemove: function onRemove(evt) {
|
|
211
|
+
return false;
|
|
212
|
+
} },
|
|
213
|
+
'Clean'
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
);
|
|
136
217
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
@@ -6,24 +6,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
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
8
|
|
|
9
|
-
var _templateObject = _taggedTemplateLiteral([
|
|
10
|
-
_templateObject2 = _taggedTemplateLiteral([
|
|
11
|
-
_templateObject3 = _taggedTemplateLiteral([
|
|
12
|
-
_templateObject4 = _taggedTemplateLiteral([
|
|
9
|
+
var _templateObject = _taggedTemplateLiteral(['\n background: transparent;\n font-family: \'SFUIText-Medium\';\n position: relative;\n width: 100%;\n display: block;\n\n > label {\n color: ', ';\n font-size: 14px;\n\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 > textarea:focus ~ label {\n top: -10px;\n left: 0px;\n font-size: 10px;\n color: ', ';\n text-transform: capitalize;\n }\n\n > textarea ~ label.floaton {\n top: -10px;\n left: 0px;\n font-size: 10px;\n color: ', ';\n text-transform: capitalize;\n }\n'], ['\n background: transparent;\n font-family: \'SFUIText-Medium\';\n position: relative;\n width: 100%;\n display: block;\n\n > label {\n color: ', ';\n font-size: 14px;\n\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 > textarea:focus ~ label {\n top: -10px;\n left: 0px;\n font-size: 10px;\n color: ', ';\n text-transform: capitalize;\n }\n\n > textarea ~ label.floaton {\n top: -10px;\n left: 0px;\n font-size: 10px;\n color: ', ';\n text-transform: capitalize;\n }\n']),
|
|
10
|
+
_templateObject2 = _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']),
|
|
11
|
+
_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']),
|
|
12
|
+
_templateObject4 = _taggedTemplateLiteral(['\n width: 100%;\n box-sizing: border-box;\n\n background: ', ';\n\n border: none;\n border-radius: 0px;\n -webkit-appearance: none;\n border-bottom: 1px solid\n ', ';\n\n font-family: \'SFUIText-Medium\';\n color: ', ';\n\n cursor: ', ';\n\n font-size: 14px;\n padding: ', ';\n margin-top: 15px;\n display: block;\n\n &:hover {\n border-color: ', ';\n }\n &:disabled:hover {\n border-color: ', ';\n }\n &:disabled {\n border-color: ', ';\n color: ', ';\n }\n &:focus {\n outline: none;\n }\n &::placeholder {\n color: ', ';\n\n opacity: ', ';\n transition: 0.2s ease all;\n }\n\n &:focus::placeholder {\n color: ', ';\n\n opacity: ', ';\n }\n'], ['\n width: 100%;\n box-sizing: border-box;\n\n background: ', ';\n\n border: none;\n border-radius: 0px;\n -webkit-appearance: none;\n border-bottom: 1px solid\n ', ';\n\n font-family: \'SFUIText-Medium\';\n color: ', ';\n\n cursor: ', ';\n\n font-size: 14px;\n padding: ', ';\n margin-top: 15px;\n display: block;\n\n &:hover {\n border-color: ', ';\n }\n &:disabled:hover {\n border-color: ', ';\n }\n &:disabled {\n border-color: ', ';\n color: ', ';\n }\n &:focus {\n outline: none;\n }\n &::placeholder {\n color: ', ';\n\n opacity: ', ';\n transition: 0.2s ease all;\n }\n\n &:focus::placeholder {\n color: ', ';\n\n opacity: ', ';\n }\n']);
|
|
13
13
|
|
|
14
|
-
var _react = require(
|
|
14
|
+
var _react = require('react');
|
|
15
15
|
|
|
16
16
|
var _react2 = _interopRequireDefault(_react);
|
|
17
17
|
|
|
18
|
-
var _styledComponents = require(
|
|
18
|
+
var _styledComponents = require('styled-components');
|
|
19
19
|
|
|
20
20
|
var _styledComponents2 = _interopRequireDefault(_styledComponents);
|
|
21
21
|
|
|
22
|
-
var _propTypes = require(
|
|
22
|
+
var _propTypes = require('prop-types');
|
|
23
23
|
|
|
24
24
|
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
25
25
|
|
|
26
|
-
var _tokens = require(
|
|
26
|
+
var _tokens = require('@desynova-digital/tokens');
|
|
27
27
|
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
29
|
|
|
@@ -50,12 +50,13 @@ var Textarea = function Textarea(_ref) {
|
|
|
50
50
|
maxLength = _ref.maxLength,
|
|
51
51
|
showLengthCount = _ref.showLengthCount,
|
|
52
52
|
type = _ref.type,
|
|
53
|
-
props = _objectWithoutProperties(_ref, [
|
|
53
|
+
props = _objectWithoutProperties(_ref, ['defaultValue', 'maxLength', 'showLengthCount', 'type']);
|
|
54
54
|
|
|
55
55
|
if (props.masked) {
|
|
56
56
|
var length = defaultValue ? defaultValue.length : 8;
|
|
57
|
-
var maskedValue = new Array(length).join(
|
|
57
|
+
var maskedValue = new Array(length).join('•');
|
|
58
58
|
return _react2.default.createElement(Textarea.Element, _extends({
|
|
59
|
+
theme: props.theme,
|
|
59
60
|
value: props.value,
|
|
60
61
|
type: type
|
|
61
62
|
}, props, {
|
|
@@ -74,29 +75,30 @@ var Textarea = function Textarea(_ref) {
|
|
|
74
75
|
TextareaDiv,
|
|
75
76
|
{ theme: props.theme },
|
|
76
77
|
_react2.default.createElement(Textarea.Element, _extends({
|
|
78
|
+
theme: props.theme,
|
|
77
79
|
type: type,
|
|
78
80
|
value: props.value,
|
|
79
81
|
defaultValue: defaultValue,
|
|
80
82
|
maxLength: maxLength
|
|
81
83
|
}, props)),
|
|
82
84
|
props.label ? _react2.default.createElement(
|
|
83
|
-
|
|
85
|
+
'label',
|
|
84
86
|
{
|
|
85
87
|
htmlFor: props.id,
|
|
86
|
-
className: props.value && props.value.length > 0 ?
|
|
88
|
+
className: props.value && props.value.length > 0 ? 'floaton' : ''
|
|
87
89
|
},
|
|
88
|
-
|
|
89
|
-
) :
|
|
90
|
+
'' + props.label + (props.isRequired ? '*' : '')
|
|
91
|
+
) : '',
|
|
90
92
|
errorMesssage ? _react2.default.createElement(
|
|
91
93
|
InputError,
|
|
92
94
|
{ value: props.value, theme: props.theme, error: props.error },
|
|
93
95
|
errorMesssage
|
|
94
|
-
) :
|
|
96
|
+
) : '',
|
|
95
97
|
maxLength && showLengthCount && _react2.default.createElement(
|
|
96
98
|
CountWrappper,
|
|
97
99
|
null,
|
|
98
100
|
props.value.length,
|
|
99
|
-
|
|
101
|
+
'/',
|
|
100
102
|
maxLength
|
|
101
103
|
)
|
|
102
104
|
);
|
|
@@ -107,22 +109,22 @@ var returnPadding = function returnPadding(props) {
|
|
|
107
109
|
var digitCount = props.maxLength.toString().length;
|
|
108
110
|
switch (digitCount) {
|
|
109
111
|
case 0:
|
|
110
|
-
return
|
|
112
|
+
return '7px 0px 2px 0px';
|
|
111
113
|
case 1:
|
|
112
|
-
return
|
|
114
|
+
return '7px 20px 2px 0px';
|
|
113
115
|
case 2:
|
|
114
|
-
return
|
|
116
|
+
return '7px 40px 2px 0px';
|
|
115
117
|
case 3:
|
|
116
|
-
return
|
|
118
|
+
return '7px 65px 2px 0px';
|
|
117
119
|
case 4:
|
|
118
|
-
return
|
|
120
|
+
return '7px 85px 2px 0px';
|
|
119
121
|
case 5:
|
|
120
|
-
return
|
|
122
|
+
return '7px 100px 2px 0px';
|
|
121
123
|
default:
|
|
122
|
-
return
|
|
124
|
+
return '7px 0px 2px 0px';
|
|
123
125
|
}
|
|
124
126
|
} else {
|
|
125
|
-
return
|
|
127
|
+
return '7px 0px 2px 0px';
|
|
126
128
|
}
|
|
127
129
|
};
|
|
128
130
|
|
|
@@ -137,9 +139,9 @@ Textarea.Element = _styledComponents2.default.textarea(_templateObject4, functio
|
|
|
137
139
|
}, function (props) {
|
|
138
140
|
return _tokens.colors[props.theme].inputCommon.color;
|
|
139
141
|
}, function (props) {
|
|
140
|
-
return props.readOnly ?
|
|
142
|
+
return props.readOnly ? 'not-allowed' : 'text';
|
|
141
143
|
}, function (props) {
|
|
142
|
-
return returnPadding(props ||
|
|
144
|
+
return returnPadding(props || '');
|
|
143
145
|
}, function (props) {
|
|
144
146
|
if (props.error) {
|
|
145
147
|
return _tokens.colors[props.theme].inputError.borderHover;
|
|
@@ -153,11 +155,11 @@ Textarea.Element = _styledComponents2.default.textarea(_templateObject4, functio
|
|
|
153
155
|
}, function (props) {
|
|
154
156
|
return _tokens.colors[props.theme].inputCommon.colorDisabled;
|
|
155
157
|
}, function (props) {
|
|
156
|
-
return props.label ?
|
|
158
|
+
return props.label ? 'transparent' : function (props) {
|
|
157
159
|
return _tokens.colors[props.theme].inputCommon.placeholder;
|
|
158
160
|
};
|
|
159
161
|
}, function (props) {
|
|
160
|
-
return props.label ?
|
|
162
|
+
return props.label ? '0' : '1';
|
|
161
163
|
}, function (props) {
|
|
162
164
|
return props.placeholder ? function (props) {
|
|
163
165
|
return _tokens.colors[props.theme].inputCommon.placeholder;
|
|
@@ -165,7 +167,7 @@ Textarea.Element = _styledComponents2.default.textarea(_templateObject4, functio
|
|
|
165
167
|
return _tokens.colors[props.theme].inputCommon.placeholder;
|
|
166
168
|
};
|
|
167
169
|
}, function (props) {
|
|
168
|
-
return props.placeholder ?
|
|
170
|
+
return props.placeholder ? '1' : '1';
|
|
169
171
|
});
|
|
170
172
|
|
|
171
173
|
Textarea.propTypes = {
|
|
@@ -191,7 +193,7 @@ Textarea.propTypes = {
|
|
|
191
193
|
/** The (HTML) maxLength for the textarea. */
|
|
192
194
|
maxLength: _propTypes2.default.number,
|
|
193
195
|
|
|
194
|
-
theme: _propTypes2.default.oneOf([
|
|
196
|
+
theme: _propTypes2.default.oneOf(['light', 'dark', 'nexc']),
|
|
195
197
|
|
|
196
198
|
row: _propTypes2.default.number,
|
|
197
199
|
showLengthCount: _propTypes2.default.bool
|
|
@@ -205,10 +207,10 @@ Textarea.defaultProps = {
|
|
|
205
207
|
code: false,
|
|
206
208
|
error: null,
|
|
207
209
|
onChange: null,
|
|
208
|
-
type:
|
|
210
|
+
type: 'text',
|
|
209
211
|
maxLength: 50,
|
|
210
|
-
theme:
|
|
211
|
-
value:
|
|
212
|
+
theme: 'light',
|
|
213
|
+
value: '',
|
|
212
214
|
rows: 3,
|
|
213
215
|
showLengthCount: false
|
|
214
216
|
};
|
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
var _react = require(
|
|
3
|
+
var _react = require('react');
|
|
4
4
|
|
|
5
5
|
var _react2 = _interopRequireDefault(_react);
|
|
6
6
|
|
|
7
|
-
var _react3 = require(
|
|
7
|
+
var _react3 = require('@storybook/react');
|
|
8
8
|
|
|
9
|
-
var _storyHelpers = require(
|
|
9
|
+
var _storyHelpers = require('../../_helpers/story-helpers');
|
|
10
10
|
|
|
11
|
-
var _timeCodeInput = require(
|
|
11
|
+
var _timeCodeInput = require('./timeCodeInput');
|
|
12
12
|
|
|
13
13
|
var _timeCodeInput2 = _interopRequireDefault(_timeCodeInput);
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
-
(0, _react3.storiesOf)(
|
|
17
|
+
(0, _react3.storiesOf)('TimeCodeInput').add('dark theme', function () {
|
|
18
18
|
return _react2.default.createElement(
|
|
19
19
|
_storyHelpers.Example,
|
|
20
|
-
{ title:
|
|
20
|
+
{ title: 'Appearances' },
|
|
21
21
|
_react2.default.createElement(
|
|
22
22
|
_storyHelpers.Stack,
|
|
23
23
|
null,
|
|
24
24
|
_react2.default.createElement(_timeCodeInput2.default, {
|
|
25
|
-
inputValue:
|
|
25
|
+
inputValue: '00:00:00:00' //time code input value
|
|
26
26
|
, onFocus: function onFocus() {
|
|
27
27
|
//perform your function here eg pause the video that is playing
|
|
28
28
|
},
|
|
29
29
|
frameRate: '25',
|
|
30
30
|
initialTime: '00:00:00:00' || 0,
|
|
31
|
-
playerDuration: '00:23:35:03' || 0
|
|
31
|
+
playerDuration: '00:23:35:03' || 0
|
|
32
|
+
})
|
|
32
33
|
)
|
|
33
34
|
);
|
|
34
35
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
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"); } }; }();
|
|
8
8
|
|
|
9
|
-
var _templateObject = _taggedTemplateLiteral(['\n
|
|
9
|
+
var _templateObject = _taggedTemplateLiteral(['\n font-family: SFUIText-Regular;\n font-size: 12px;\n color: ', ';\n text-align: left;\n padding: 0;\n border: none;\n outline: none;\n background: transparent;\n &:hover {\n color: ', ';\n }\n width: ', ';\n'], ['\n font-family: SFUIText-Regular;\n font-size: 12px;\n color: ', ';\n text-align: left;\n padding: 0;\n border: none;\n outline: none;\n background: transparent;\n &:hover {\n color: ', ';\n }\n width: ', ';\n']);
|
|
10
10
|
|
|
11
11
|
var _react = require('react');
|
|
12
12
|
|
|
@@ -18,117 +18,125 @@ var _styledComponents2 = _interopRequireDefault(_styledComponents);
|
|
|
18
18
|
|
|
19
19
|
var _utils = require('../../_helpers/utils');
|
|
20
20
|
|
|
21
|
+
var _tokens = require('@desynova-digital/tokens');
|
|
22
|
+
|
|
21
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
24
|
|
|
23
25
|
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
24
26
|
|
|
25
27
|
var StyledInput = _styledComponents2.default.input(_templateObject, function (props) {
|
|
26
|
-
|
|
28
|
+
return props.isError ? '#FFFFFF' : '#ff0000';
|
|
29
|
+
}, function (props) {
|
|
30
|
+
return props.theme ? '' + _tokens.colors[props.theme].timeCodeInput.rgbthemeColor : 'rgb(0 206 198)';
|
|
27
31
|
}, function (props) {
|
|
28
|
-
|
|
32
|
+
return props.width ? props.width : '72px';
|
|
29
33
|
});
|
|
30
34
|
|
|
31
35
|
var TimeCodeInput = function TimeCodeInput(_ref) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
36
|
+
var inputValue = _ref.inputValue,
|
|
37
|
+
onFocus = _ref.onFocus,
|
|
38
|
+
onKeyDown = _ref.onKeyDown,
|
|
39
|
+
frameRate = _ref.frameRate,
|
|
40
|
+
initialTime = _ref.initialTime,
|
|
41
|
+
playerDuration = _ref.playerDuration,
|
|
42
|
+
elementRef = _ref.elementRef,
|
|
43
|
+
width = _ref.width,
|
|
44
|
+
_ref$theme = _ref.theme,
|
|
45
|
+
theme = _ref$theme === undefined ? 'dark' : _ref$theme;
|
|
46
|
+
|
|
47
|
+
var _useState = (0, _react.useState)(inputValue || '00:00:00:00'),
|
|
48
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
49
|
+
customInputValue = _useState2[0],
|
|
50
|
+
setCustomInputValue = _useState2[1];
|
|
51
|
+
|
|
52
|
+
var _useState3 = (0, _react.useState)(true),
|
|
53
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
54
|
+
isValid = _useState4[0],
|
|
55
|
+
setIsValid = _useState4[1];
|
|
56
|
+
|
|
57
|
+
var onTimePickerChange = function onTimePickerChange(value, e) {
|
|
58
|
+
var inputTime = value;
|
|
59
|
+
var formattedTime = inputTime;
|
|
60
|
+
if (e && e.target && e.target.selectionStart !== undefined) {
|
|
61
|
+
var cursorPosition = e.target.selectionStart;
|
|
62
|
+
if ((cursorPosition === 2 || cursorPosition === 5 || cursorPosition === 8) && e.nativeEvent.inputType !== 'insertText' && inputTime.length >= 11) {
|
|
63
|
+
formattedTime = inputTime;
|
|
64
|
+
} else {
|
|
65
|
+
var cleanedTime = inputTime.replace(/[^\d]/g, '');
|
|
66
|
+
formattedTime = cleanedTime.replace(/(\d{2})(?=\d)/g, '$1:');
|
|
67
|
+
}
|
|
68
|
+
e.target.value = formattedTime;
|
|
69
|
+
// Save the cursor position before modifying the value
|
|
70
|
+
var newCursorPosition = cursorPosition;
|
|
71
|
+
|
|
72
|
+
// Adjust cursor position if necessary
|
|
73
|
+
if (inputTime.length >= formattedTime.length && inputTime[cursorPosition - 1] === ':') {
|
|
74
|
+
// If a number before ":" is deleted, keep the cursor next to ":"
|
|
75
|
+
newCursorPosition = cursorPosition;
|
|
76
|
+
} else if (cursorPosition % 3 === 0 && cursorPosition !== 0) {
|
|
77
|
+
// If the cursor is at a position that was just after adding a colon
|
|
78
|
+
newCursorPosition = cursorPosition + 1;
|
|
79
|
+
}
|
|
80
|
+
e.target.setSelectionRange(newCursorPosition, newCursorPosition);
|
|
81
|
+
setCustomInputValue(e.target.value);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
var checkIfTimeValid = function checkIfTimeValid(value) {
|
|
86
|
+
var isValid = false;
|
|
87
|
+
if (value) {
|
|
88
|
+
var timeRegex = new RegExp('^(?:[0-5][0-9]):(?:[0-5][0-9]):(?:[0-5][0-9]):[0-9]{2}$');
|
|
89
|
+
if (timeRegex.test(value) && parseInt(value.split(':')[3]) <= frameRate && value.split(':')[3].length === 2) {
|
|
90
|
+
var selectedValueTime = (0, _utils.timeToSeconds)(value, frameRate);
|
|
91
|
+
var endTime = initialTime + playerDuration;
|
|
92
|
+
if (selectedValueTime >= initialTime && selectedValueTime <= endTime) {
|
|
93
|
+
setIsValid(true);
|
|
94
|
+
return true;
|
|
76
95
|
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
setIsValid(false);
|
|
99
|
+
return isValid;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
(0, _react.useEffect)(function () {
|
|
103
|
+
var handleEscapeKey = function handleEscapeKey(event) {
|
|
104
|
+
if (event.key === 'Escape') {
|
|
105
|
+
setCustomInputValue(inputValue);
|
|
106
|
+
setIsValid(true); // Reset to original
|
|
107
|
+
document.activeElement.blur();
|
|
108
|
+
}
|
|
77
109
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (timeRegex.test(value) && parseInt(value.split(':')[3]) <= frameRate && value.split(':')[3].length === 2) {
|
|
84
|
-
var selectedValueTime = (0, _utils.timeToSeconds)(value, frameRate);
|
|
85
|
-
var endTime = initialTime + playerDuration;
|
|
86
|
-
if (selectedValueTime >= initialTime && selectedValueTime <= endTime) {
|
|
87
|
-
setIsValid(true);
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
setIsValid(false);
|
|
93
|
-
return isValid;
|
|
110
|
+
checkIfTimeValid(inputValue);
|
|
111
|
+
setCustomInputValue(inputValue);
|
|
112
|
+
document.addEventListener('keydown', handleEscapeKey);
|
|
113
|
+
return function () {
|
|
114
|
+
document.removeEventListener('keydown', handleEscapeKey);
|
|
94
115
|
};
|
|
116
|
+
}, [inputValue]);
|
|
95
117
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
return _react2.default.createElement(StyledInput, {
|
|
121
|
-
width: width,
|
|
122
|
-
ref: elementRef,
|
|
123
|
-
value: customInputValue,
|
|
124
|
-
onFocus: onFocus,
|
|
125
|
-
onKeyDown: onKeyDown,
|
|
126
|
-
onChange: function onChange(e) {
|
|
127
|
-
onTimePickerChange(e.target.value, e);checkIfTimeValid(e.target.value);
|
|
128
|
-
},
|
|
129
|
-
isError: isValid,
|
|
130
|
-
maxLength: '11'
|
|
131
|
-
});
|
|
118
|
+
(0, _react.useImperativeHandle)(elementRef, function () {
|
|
119
|
+
return {
|
|
120
|
+
checkValidity: function checkValidity() {
|
|
121
|
+
return checkIfTimeValid(customInputValue);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return _react2.default.createElement(StyledInput, {
|
|
127
|
+
theme: theme,
|
|
128
|
+
width: width,
|
|
129
|
+
ref: elementRef,
|
|
130
|
+
value: customInputValue,
|
|
131
|
+
onFocus: onFocus,
|
|
132
|
+
onKeyDown: onKeyDown,
|
|
133
|
+
onChange: function onChange(e) {
|
|
134
|
+
onTimePickerChange(e.target.value, e);
|
|
135
|
+
checkIfTimeValid(e.target.value);
|
|
136
|
+
},
|
|
137
|
+
isError: isValid,
|
|
138
|
+
maxLength: '11'
|
|
139
|
+
});
|
|
132
140
|
};
|
|
133
141
|
|
|
134
142
|
exports.default = TimeCodeInput;
|