@desynova-digital/components 9.1.7 → 9.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,19 +12,28 @@ var _react = _interopRequireWildcard(require("react"));
12
12
  var _styledComponents = _interopRequireDefault(require("styled-components"));
13
13
  var _utils = require("../../_helpers/utils");
14
14
  var _tokens = require("@desynova-digital/tokens");
15
- var _templateObject;
15
+ var _components = require("@desynova-digital/components");
16
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
16
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
18
- var StyledInput = _styledComponents["default"].input(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\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"])), function (props) {
19
- return props.isError ? '#FFFFFF' : '#ff0000';
19
+ var StyledInput = _styledComponents["default"].input(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\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 border-bottom:", ";\n padding-bottom: 1px; \n"])), function (props) {
20
+ return props.isError ? '#FFFFFF' : '#FF6C56';
20
21
  }, function (props) {
21
22
  return props.theme ? "".concat(_tokens.colors[props.theme].timeCodeInput.rgbthemeColor) : 'rgb(0 206 198)';
22
23
  }, function (props) {
23
24
  return props.width ? props.width : '72px';
25
+ }, function (props) {
26
+ var _props$name, _props$name2;
27
+ return !props.isError && ((_props$name = props.name) === null || _props$name === void 0 ? void 0 : _props$name.length) > 0 ? '1px solid #FF6C56' : ((_props$name2 = props.name) === null || _props$name2 === void 0 ? void 0 : _props$name2.length) > 0 ? '1px solid #303F51' : '0px';
24
28
  });
29
+ var CrossIconWrapper = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n margin-top: 5px;\n width: fit-content;\n &:hover {\n cursor: pointer;\n }\n svg path {\n fill: #FF6C56;\n }\n"])));
30
+ var StyledDiv = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n gap: 10px;\n"])));
31
+ var ErrorContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n color: #FF6C56;\n font-family: 'SFUIText-Regular';\n font-size: 12px;\n font-style: normal;\n font-weight: 500;\n line-height: 15px;\n"])));
32
+ var InputHeading = _styledComponents["default"].p(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n color: #afb2ba;\n font-size: 10px;\n text-transform: uppercase;\n margin-bottom: 8px;\n margin-top: 15px;\n"])));
25
33
  var TimeCodeInput = function TimeCodeInput(_ref) {
26
34
  var inputValue = _ref.inputValue,
27
35
  onFocus = _ref.onFocus,
36
+ onBlur = _ref.onBlur,
28
37
  onKeyDown = _ref.onKeyDown,
29
38
  frameRate = _ref.frameRate,
30
39
  initialTime = _ref.initialTime,
@@ -32,7 +41,19 @@ var TimeCodeInput = function TimeCodeInput(_ref) {
32
41
  elementRef = _ref.elementRef,
33
42
  width = _ref.width,
34
43
  _ref$theme = _ref.theme,
35
- theme = _ref$theme === void 0 ? 'dark' : _ref$theme;
44
+ theme = _ref$theme === void 0 ? 'dark' : _ref$theme,
45
+ customValidity = _ref.customValidity,
46
+ inputFieldType = _ref.inputFieldType,
47
+ customValidityFn = _ref.customValidityFn,
48
+ _ref$showCross = _ref.showCross,
49
+ showCross = _ref$showCross === void 0 ? false : _ref$showCross,
50
+ crossClicked = _ref.crossClicked,
51
+ _ref$showError = _ref.showError,
52
+ showError = _ref$showError === void 0 ? false : _ref$showError,
53
+ _ref$errorStatement = _ref.errorStatement,
54
+ errorStatement = _ref$errorStatement === void 0 ? '' : _ref$errorStatement,
55
+ updateFormDataExternally = _ref.updateFormDataExternally,
56
+ inputTitle = _ref.inputTitle;
36
57
  var _useState = (0, _react.useState)(inputValue || '00:00:00:00'),
37
58
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
38
59
  customInputValue = _useState2[0],
@@ -75,9 +96,13 @@ var TimeCodeInput = function TimeCodeInput(_ref) {
75
96
  if (timeRegex.test(value) && parseInt(value.split(':')[3]) <= frameRate && value.split(':')[3].length === 2) {
76
97
  var selectedValueTime = (0, _utils.timeToSeconds)(value, frameRate);
77
98
  var endTime = initialTime + playerDuration;
78
- if (selectedValueTime >= initialTime && selectedValueTime <= endTime) {
99
+ if (selectedValueTime >= initialTime && selectedValueTime <= endTime && !customValidity) {
79
100
  setIsValid(true);
80
101
  return true;
102
+ } else if (customValidity) {
103
+ var val = customValidityFn(inputFieldType, value);
104
+ setIsValid(val);
105
+ return val;
81
106
  }
82
107
  }
83
108
  }
@@ -92,7 +117,7 @@ var TimeCodeInput = function TimeCodeInput(_ref) {
92
117
  document.activeElement.blur();
93
118
  }
94
119
  };
95
- checkIfTimeValid(inputValue);
120
+ customValidity && inputValue && checkIfTimeValid(inputValue);
96
121
  setCustomInputValue(inputValue);
97
122
  document.addEventListener('keydown', handleEscapeKey);
98
123
  return function () {
@@ -103,22 +128,40 @@ var TimeCodeInput = function TimeCodeInput(_ref) {
103
128
  return {
104
129
  checkValidity: function checkValidity() {
105
130
  return checkIfTimeValid(customInputValue);
131
+ },
132
+ inputValue: customInputValue,
133
+ inputFieldType: inputFieldType,
134
+ returnValidity: function returnValidity() {
135
+ return isValid;
106
136
  }
107
137
  };
108
138
  });
109
- return /*#__PURE__*/_react["default"].createElement(StyledInput, {
139
+ var onChangeFn = function onChangeFn(e) {
140
+ onTimePickerChange(e.target.value, e);
141
+ checkIfTimeValid(e.target.value);
142
+ };
143
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(StyledDiv, null, inputTitle && /*#__PURE__*/_react["default"].createElement(InputHeading, null, inputTitle), showCross && /*#__PURE__*/_react["default"].createElement(CrossIconWrapper, {
144
+ onClick: crossClicked
145
+ }, /*#__PURE__*/_react["default"].createElement(_components.Icon, {
146
+ name: "cross",
147
+ width: 7,
148
+ height: 7
149
+ }))), /*#__PURE__*/_react["default"].createElement(StyledInput, {
150
+ name: inputFieldType,
110
151
  theme: theme,
111
152
  width: width,
112
153
  ref: elementRef,
113
154
  value: customInputValue,
114
155
  onFocus: onFocus,
156
+ onBlur: onBlur,
115
157
  onKeyDown: onKeyDown,
116
158
  onChange: function onChange(e) {
117
- onTimePickerChange(e.target.value, e);
118
- checkIfTimeValid(e.target.value);
159
+ return onChangeFn(e);
119
160
  },
120
161
  isError: isValid,
121
162
  maxLength: "11"
122
- });
163
+ }), showError && errorStatement.length > 0 && /*#__PURE__*/_react["default"].createElement(ErrorContainer, {
164
+ inputFieldType: inputFieldType
165
+ }, " ", errorStatement));
123
166
  };
124
167
  var _default = exports["default"] = TimeCodeInput;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@desynova-digital/components",
3
- "version": "9.1.7",
3
+ "version": "9.1.9",
4
4
  "description": "Components for Desynova Digital",
5
5
  "main": "index.js",
6
6
  "author": "desynova-digital",
7
7
  "license": "MIT",
8
8
  "repository": "desynova-digital",
9
9
  "dependencies": {
10
- "@desynova-digital/tokens": "9.1.7",
10
+ "@desynova-digital/tokens": "9.1.9",
11
11
  "prop-types": "^15.7.2",
12
12
  "styled-components": "^4.3.2"
13
13
  },