@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.
Files changed (80) hide show
  1. package/atoms/avatar/avatar.js +1 -1
  2. package/atoms/avatar/avatar.story.js +46 -14
  3. package/atoms/badge/badge.js +13 -13
  4. package/atoms/badge/badge.story.js +91 -29
  5. package/atoms/button/button.js +81 -85
  6. package/atoms/button/button.story.js +342 -2
  7. package/atoms/card/card.js +43 -39
  8. package/atoms/card/card.story.js +74 -48
  9. package/atoms/cardStack/cardStack.js +182 -155
  10. package/atoms/cardStack/cardStack.story.js +131 -18
  11. package/atoms/cardV2/cardV2.js +23 -23
  12. package/atoms/cardV2/cardV2.story.js +196 -45
  13. package/atoms/cardV2/content.js +109 -87
  14. package/atoms/cardV2/thumbnail.js +85 -72
  15. package/atoms/cardV2/timeline.js +119 -107
  16. package/atoms/checkbox/checkbox.js +41 -32
  17. package/atoms/checkbox/checkbox.story.js +220 -99
  18. package/atoms/customSelect/customSelect.story.js +820 -582
  19. package/atoms/datePicker/datePicker.js +77 -83
  20. package/atoms/datePicker/datePicker.story.js +167 -1
  21. package/atoms/dateTime/dateTime.story.js +26 -1
  22. package/atoms/draftInputText/draftInputText.js +358 -0
  23. package/atoms/draftInputText/draftInputText.story.js +251 -0
  24. package/atoms/draftInputText/index.js +13 -0
  25. package/atoms/dropdown/dropdown.story.js +146 -18
  26. package/atoms/dropdownList/dropdownList.story.js +1598 -1091
  27. package/atoms/graphs/barGraph/barGraph.js +143 -130
  28. package/atoms/graphs/barGraph/barGraph.story.js +74 -40
  29. package/atoms/graphs/circleDonut/circleDonut.story.js +374 -220
  30. package/atoms/graphs/circleGraph/circleGraph.js +84 -80
  31. package/atoms/graphs/circleGraph/circleGraph.story.js +38 -26
  32. package/atoms/graphs/circleNested/circleNested.story.js +98 -103
  33. package/atoms/graphs/pieChart/pieChart.story.js +160 -81
  34. package/atoms/graphs/verticalBarGraph/verticalBarGraph.story.js +30 -28
  35. package/atoms/icon/icon.story.js +220 -163
  36. package/atoms/inputText/inputText.js +52 -49
  37. package/atoms/label/label.js +29 -29
  38. package/atoms/label/label.story.js +42 -30
  39. package/atoms/loader/CircleLoader.js +13 -4
  40. package/atoms/loader/CircleLoader.jsx +10 -4
  41. package/atoms/loader/ThreeDotLoader.js +8 -4
  42. package/atoms/loader/ThreeDotLoader.jsx +4 -4
  43. package/atoms/loader/loader.js +29 -30
  44. package/atoms/loader/loader.story.js +38 -23
  45. package/atoms/loader/spinningLoader.js +7 -4
  46. package/atoms/loader/spinningLoader.jsx +5 -5
  47. package/atoms/popup/popup.js +11 -11
  48. package/atoms/popup/popup.story.js +36 -4
  49. package/atoms/radio/radio.story.js +140 -2
  50. package/atoms/sideBar/sidebar.js +19 -5
  51. package/atoms/sideBar/sidebar.jsx +13 -8
  52. package/atoms/switch/switch.js +72 -66
  53. package/atoms/switch/switch.story.js +323 -78
  54. package/atoms/tag/tag.js +39 -39
  55. package/atoms/tag/tag.story.js +83 -2
  56. package/atoms/textarea/textarea.js +36 -34
  57. package/atoms/timeCodeInput/timCodeInput.story.js +10 -9
  58. package/atoms/timeCodeInput/timeCodeInput.js +108 -100
  59. package/atoms/timer/timer.js +127 -126
  60. package/atoms/toast/toast.js +24 -14
  61. package/atoms/toast/toast.story.js +22 -0
  62. package/atoms/videoCard/videoCard.js +226 -203
  63. package/atoms/videoCard/videoCard.story.js +547 -186
  64. package/components.js +69 -66
  65. package/index.js +5 -4
  66. package/molecules/carousel/carousel.js +55 -67
  67. package/molecules/filter/filter.js +133 -106
  68. package/molecules/filter/filter.story.js +215 -173
  69. package/molecules/graphCard/graphCard.js +34 -24
  70. package/molecules/graphCard/graphCard.story.js +169 -82
  71. package/molecules/graphDetailCard/graphDetailCard.js +207 -182
  72. package/molecules/pageHeader/pageHeader.js +3 -2
  73. package/molecules/pageHeader/pageHeader.story.js +40 -18
  74. package/molecules/pagination/pagination.js +66 -14
  75. package/molecules/pagination/pagination.story.js +24 -2
  76. package/molecules/table/table.js +368 -316
  77. package/molecules/table/table.story.js +404 -208
  78. package/molecules/tabs/tabs.js +15 -6
  79. package/molecules/tabs/tabs.story.js +26 -0
  80. package/package.json +2 -2
@@ -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
- { onClick: function onClick(evt) {
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
- "use strict";
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(["\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"]);
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("react");
14
+ var _react = require('react');
15
15
 
16
16
  var _react2 = _interopRequireDefault(_react);
17
17
 
18
- var _styledComponents = require("styled-components");
18
+ var _styledComponents = require('styled-components');
19
19
 
20
20
  var _styledComponents2 = _interopRequireDefault(_styledComponents);
21
21
 
22
- var _propTypes = require("prop-types");
22
+ var _propTypes = require('prop-types');
23
23
 
24
24
  var _propTypes2 = _interopRequireDefault(_propTypes);
25
25
 
26
- var _tokens = require("@desynova-digital/tokens");
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, ["defaultValue", "maxLength", "showLengthCount", "type"]);
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
- "label",
85
+ 'label',
84
86
  {
85
87
  htmlFor: props.id,
86
- className: props.value && props.value.length > 0 ? "floaton" : ""
88
+ className: props.value && props.value.length > 0 ? 'floaton' : ''
87
89
  },
88
- "" + props.label + (props.isRequired ? "*" : "")
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 "7px 0px 2px 0px";
112
+ return '7px 0px 2px 0px';
111
113
  case 1:
112
- return "7px 20px 2px 0px";
114
+ return '7px 20px 2px 0px';
113
115
  case 2:
114
- return "7px 40px 2px 0px";
116
+ return '7px 40px 2px 0px';
115
117
  case 3:
116
- return "7px 65px 2px 0px";
118
+ return '7px 65px 2px 0px';
117
119
  case 4:
118
- return "7px 85px 2px 0px";
120
+ return '7px 85px 2px 0px';
119
121
  case 5:
120
- return "7px 100px 2px 0px";
122
+ return '7px 100px 2px 0px';
121
123
  default:
122
- return "7px 0px 2px 0px";
124
+ return '7px 0px 2px 0px';
123
125
  }
124
126
  } else {
125
- return "7px 0px 2px 0px";
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 ? "not-allowed" : "text";
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 ? "transparent" : function (props) {
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 ? "0" : "1";
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 ? "1" : "1";
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(["light", "dark"]),
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: "text",
210
+ type: 'text',
209
211
  maxLength: 50,
210
- theme: "light",
211
- value: "",
212
+ theme: 'light',
213
+ value: '',
212
214
  rows: 3,
213
215
  showLengthCount: false
214
216
  };
@@ -1,34 +1,35 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- var _react = require("react");
3
+ var _react = require('react');
4
4
 
5
5
  var _react2 = _interopRequireDefault(_react);
6
6
 
7
- var _react3 = require("@storybook/react");
7
+ var _react3 = require('@storybook/react');
8
8
 
9
- var _storyHelpers = require("../../_helpers/story-helpers");
9
+ var _storyHelpers = require('../../_helpers/story-helpers');
10
10
 
11
- var _timeCodeInput = require("./timeCodeInput");
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)("TimeCodeInput").add("dark theme", function () {
17
+ (0, _react3.storiesOf)('TimeCodeInput').add('dark theme', function () {
18
18
  return _react2.default.createElement(
19
19
  _storyHelpers.Example,
20
- { title: "Appearances" },
20
+ { title: 'Appearances' },
21
21
  _react2.default.createElement(
22
22
  _storyHelpers.Stack,
23
23
  null,
24
24
  _react2.default.createElement(_timeCodeInput2.default, {
25
- inputValue: "00:00:00:00" //time code input value
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
- value: true
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 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: rgb(0 206 198);\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: rgb(0 206 198);\n }\n width:', ';\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
- return props.isError ? '#FFFFFF' : '#ff0000';
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
- return props.width ? props.width : '72px';
32
+ return props.width ? props.width : '72px';
29
33
  });
30
34
 
31
35
  var TimeCodeInput = function TimeCodeInput(_ref) {
32
- var inputValue = _ref.inputValue,
33
- onFocus = _ref.onFocus,
34
- onKeyDown = _ref.onKeyDown,
35
- frameRate = _ref.frameRate,
36
- initialTime = _ref.initialTime,
37
- playerDuration = _ref.playerDuration,
38
- elementRef = _ref.elementRef,
39
- width = _ref.width;
40
-
41
- var _useState = (0, _react.useState)(inputValue || '00:00:00:00'),
42
- _useState2 = _slicedToArray(_useState, 2),
43
- customInputValue = _useState2[0],
44
- setCustomInputValue = _useState2[1];
45
-
46
- var _useState3 = (0, _react.useState)(true),
47
- _useState4 = _slicedToArray(_useState3, 2),
48
- isValid = _useState4[0],
49
- setIsValid = _useState4[1];
50
-
51
- var onTimePickerChange = function onTimePickerChange(value, e) {
52
- var inputTime = value;
53
- var formattedTime = inputTime;
54
- if (e && e.target && e.target.selectionStart !== undefined) {
55
- var cursorPosition = e.target.selectionStart;
56
- if ((cursorPosition === 2 || cursorPosition === 5 || cursorPosition === 8) && e.nativeEvent.inputType !== 'insertText' && inputTime.length >= 11) {
57
- formattedTime = inputTime;
58
- } else {
59
- var cleanedTime = inputTime.replace(/[^\d]/g, '');
60
- formattedTime = cleanedTime.replace(/(\d{2})(?=\d)/g, '$1:');
61
- }
62
- e.target.value = formattedTime;
63
- // Save the cursor position before modifying the value
64
- var newCursorPosition = cursorPosition;
65
-
66
- // Adjust cursor position if necessary
67
- if (inputTime.length >= formattedTime.length && inputTime[cursorPosition - 1] === ':') {
68
- // If a number before ":" is deleted, keep the cursor next to ":"
69
- newCursorPosition = cursorPosition;
70
- } else if (cursorPosition % 3 === 0 && cursorPosition !== 0) {
71
- // If the cursor is at a position that was just after adding a colon
72
- newCursorPosition = cursorPosition + 1;
73
- }
74
- e.target.setSelectionRange(newCursorPosition, newCursorPosition);
75
- setCustomInputValue(e.target.value);
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
- var checkIfTimeValid = function checkIfTimeValid(value) {
80
- var isValid = false;
81
- if (value) {
82
- var timeRegex = new RegExp("^(?:[0-5][0-9]):(?:[0-5][0-9]):(?:[0-5][0-9]):[0-9]{2}$");
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
- (0, _react.useEffect)(function () {
97
- var handleEscapeKey = function handleEscapeKey(event) {
98
- if (event.key === 'Escape') {
99
- setCustomInputValue(inputValue);
100
- setIsValid(true); // Reset to original
101
- document.activeElement.blur();
102
- }
103
- };
104
- checkIfTimeValid(inputValue);
105
- setCustomInputValue(inputValue);
106
- document.addEventListener('keydown', handleEscapeKey);
107
- return function () {
108
- document.removeEventListener('keydown', handleEscapeKey);
109
- };
110
- }, [inputValue]);
111
-
112
- (0, _react.useImperativeHandle)(elementRef, function () {
113
- return {
114
- checkValidity: function checkValidity() {
115
- return checkIfTimeValid(customInputValue);
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;