@desynova-digital/components 9.0.26 → 9.1.0

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 (170) hide show
  1. package/_helpers/globals.js +9 -10
  2. package/_helpers/pagination.js +10 -15
  3. package/_helpers/story-example.js +16 -39
  4. package/_helpers/story-helpers.js +15 -14
  5. package/_helpers/story-stack.js +22 -43
  6. package/_helpers/uniqueId.js +2 -5
  7. package/_helpers/utils.js +28 -4
  8. package/atoms/avatar/avatar.js +19 -42
  9. package/atoms/avatar/avatar.story.js +25 -58
  10. package/atoms/avatar/index.js +13 -11
  11. package/atoms/badge/badge.js +14 -37
  12. package/atoms/badge/badge.story.js +45 -103
  13. package/atoms/badge/index.js +12 -10
  14. package/atoms/button/button.js +85 -161
  15. package/atoms/button/button.story.js +354 -508
  16. package/atoms/button/index.js +5 -9
  17. package/atoms/card/card.js +26 -55
  18. package/atoms/card/card.story.js +39 -88
  19. package/atoms/card/index.js +12 -10
  20. package/atoms/cardStack/cardStack.js +88 -147
  21. package/atoms/cardStack/cardStack.story.js +106 -210
  22. package/atoms/cardStack/index.js +12 -10
  23. package/atoms/cardV2/cardV2.js +57 -106
  24. package/atoms/cardV2/cardV2.story.js +184 -232
  25. package/atoms/cardV2/content.js +154 -256
  26. package/atoms/cardV2/index.js +4 -8
  27. package/atoms/cardV2/thumbnail.js +138 -208
  28. package/atoms/cardV2/timeline.js +167 -123
  29. package/atoms/checkbox/checkbox.js +85 -157
  30. package/atoms/checkbox/checkbox.story.js +237 -365
  31. package/atoms/checkbox/index.js +4 -9
  32. package/atoms/customSelect/customSelect.js +136 -215
  33. package/atoms/customSelect/customSelect.story.js +745 -851
  34. package/atoms/customSelect/index.js +4 -8
  35. package/atoms/datePicker/datePicker.js +299 -431
  36. package/atoms/datePicker/datePicker.story.js +453 -501
  37. package/atoms/datePicker/index.js +4 -8
  38. package/atoms/dateTime/dateTime.js +3 -6
  39. package/atoms/dateTime/dateTime.story.js +17 -63
  40. package/atoms/dateTime/index.js +5 -9
  41. package/atoms/draftInputText/draftInputText.js +121 -189
  42. package/atoms/draftInputText/draftInputText.story.js +200 -249
  43. package/atoms/draftInputText/index.js +5 -9
  44. package/atoms/dropdown/dropdown.js +38 -66
  45. package/atoms/dropdown/dropdown.story.js +102 -262
  46. package/atoms/dropdown/index.js +4 -8
  47. package/atoms/dropdownList/dropdownList.js +78 -108
  48. package/atoms/dropdownList/dropdownList.story.js +1546 -1621
  49. package/atoms/dropdownList/index.js +4 -8
  50. package/atoms/graphs/barGraph/barGraph.js +95 -146
  51. package/atoms/graphs/barGraph/barGraph.story.js +65 -87
  52. package/atoms/graphs/barGraph/index.js +4 -8
  53. package/atoms/graphs/circleDonut/circleDonut.js +177 -229
  54. package/atoms/graphs/circleDonut/circleDonut.story.js +328 -394
  55. package/atoms/graphs/circleDonut/index.js +5 -9
  56. package/atoms/graphs/circleGraph/circleGraph.js +60 -90
  57. package/atoms/graphs/circleGraph/circleGraph.story.js +36 -54
  58. package/atoms/graphs/circleGraph/index.js +4 -8
  59. package/atoms/graphs/circleNested/circleNested.js +216 -262
  60. package/atoms/graphs/circleNested/circleNested.story.js +91 -116
  61. package/atoms/graphs/circleNested/index.js +5 -9
  62. package/atoms/graphs/pieChart/index.js +4 -8
  63. package/atoms/graphs/pieChart/pieChart.js +162 -191
  64. package/atoms/graphs/pieChart/pieChart.story.js +147 -176
  65. package/atoms/graphs/verticalBarGraph/index.js +5 -9
  66. package/atoms/graphs/verticalBarGraph/verticalBarGraph.js +75 -98
  67. package/atoms/graphs/verticalBarGraph/verticalBarGraph.story.js +26 -45
  68. package/atoms/icon/icon.js +41 -72
  69. package/atoms/icon/icon.story.js +831 -260
  70. package/atoms/icon/index.js +19 -12
  71. package/atoms/image/image.js +18 -32
  72. package/atoms/image/image.story.js +10 -19
  73. package/atoms/image/index.js +4 -8
  74. package/atoms/inputText/index.js +4 -8
  75. package/atoms/inputText/inputText.js +86 -131
  76. package/atoms/inputText/inputText.story.js +191 -255
  77. package/atoms/label/index.js +4 -8
  78. package/atoms/label/label.js +25 -50
  79. package/atoms/label/label.story.js +42 -83
  80. package/atoms/loader/CircleLoader.js +29 -63
  81. package/atoms/loader/ShimmerComponent/CollabShimmerCard.js +39 -50
  82. package/atoms/loader/ShimmerComponent/CollabShimmerCardTray.js +41 -42
  83. package/atoms/loader/ShimmerComponent/FiltersShimmer.js +30 -30
  84. package/atoms/loader/ShimmerComponent/GraphDetailShimmer.js +21 -34
  85. package/atoms/loader/ShimmerComponent/GraphTitleShimmer.js +30 -34
  86. package/atoms/loader/ShimmerComponent/GraphsComponentShimmer.js +23 -32
  87. package/atoms/loader/ShimmerComponent/Shimmer.js +24 -32
  88. package/atoms/loader/ThreeDotLoader.js +14 -29
  89. package/atoms/loader/index.js +13 -11
  90. package/atoms/loader/loader.js +34 -58
  91. package/atoms/loader/loader.story.js +48 -52
  92. package/atoms/loader/spinningLoader.js +23 -34
  93. package/atoms/popup/index.js +5 -9
  94. package/atoms/popup/popup.js +123 -208
  95. package/atoms/popup/popup.story.js +97 -131
  96. package/atoms/radio/index.js +18 -11
  97. package/atoms/radio/radio.js +58 -112
  98. package/atoms/radio/radio.story.js +197 -420
  99. package/atoms/select/index.js +4 -8
  100. package/atoms/select/select.js +48 -86
  101. package/atoms/sideBar/index.js +5 -9
  102. package/atoms/sideBar/sidebar.js +89 -140
  103. package/atoms/switch/index.js +4 -8
  104. package/atoms/switch/switch.js +56 -86
  105. package/atoms/switch/switch.story.js +268 -415
  106. package/atoms/tag/index.js +12 -10
  107. package/atoms/tag/tag.js +29 -63
  108. package/atoms/tag/tag.story.js +135 -209
  109. package/atoms/textarea/index.js +5 -9
  110. package/atoms/textarea/textarea.js +55 -99
  111. package/atoms/textarea/textarea.story.js +48 -41
  112. package/atoms/thematicBreak/index.js +12 -10
  113. package/atoms/thematicBreak/thematicBreak.js +20 -38
  114. package/atoms/thematicBreak/thematicBreak.story.js +25 -37
  115. package/atoms/timeCodeInput/index.js +4 -8
  116. package/atoms/timeCodeInput/timCodeInput.story.js +21 -35
  117. package/atoms/timeCodeInput/timeCodeInput.js +33 -51
  118. package/atoms/timer/index.js +5 -9
  119. package/atoms/timer/timer.js +57 -108
  120. package/atoms/timer/timer.story.js +13 -26
  121. package/atoms/toast/index.js +5 -9
  122. package/atoms/toast/toast.js +81 -116
  123. package/atoms/toast/toast.story.js +50 -76
  124. package/atoms/videoCard/index.js +12 -10
  125. package/atoms/videoCard/videoCard.js +265 -447
  126. package/atoms/videoCard/videoCard.story.js +495 -710
  127. package/components.js +411 -294
  128. package/index.js +350 -61
  129. package/molecules/carousel/carousel.js +121 -207
  130. package/molecules/carousel/carousel.story.js +240 -223
  131. package/molecules/carousel/index.js +5 -9
  132. package/molecules/errorScreen/CollabErrorScreen.js +35 -66
  133. package/molecules/errorScreen/TableErrorScreen.js +109 -102
  134. package/molecules/errorScreen/TableErrorScreen.jsx +7 -6
  135. package/molecules/errorScreen/errorScreen.js +41 -94
  136. package/molecules/filter/constants.js +1 -0
  137. package/molecules/filter/filter.js +378 -562
  138. package/molecules/filter/filter.story.js +79 -104
  139. package/molecules/filter/index.js +5 -9
  140. package/molecules/graphCard/graphCard.js +97 -193
  141. package/molecules/graphCard/graphCard.story.js +159 -191
  142. package/molecules/graphCard/index.js +4 -8
  143. package/molecules/graphCard/loader.js +28 -68
  144. package/molecules/graphDetailCard/graphDetailCard.js +115 -183
  145. package/molecules/graphDetailCard/graphDetailCard.story.js +218 -254
  146. package/molecules/graphDetailCard/index.js +5 -9
  147. package/molecules/pageHeader/index.js +12 -10
  148. package/molecules/pageHeader/pageHeader.js +38 -79
  149. package/molecules/pageHeader/pageHeader.story.js +34 -55
  150. package/molecules/pagination/index.js +4 -8
  151. package/molecules/pagination/pagination.js +126 -202
  152. package/molecules/pagination/pagination.story.js +40 -52
  153. package/molecules/richTextInput/RichTextInput.js +354 -0
  154. package/molecules/richTextInput/RichTextInput.story.js +50 -0
  155. package/molecules/richTextInput/index.js +9 -0
  156. package/molecules/table/index.js +4 -8
  157. package/molecules/table/table-column.js +10 -16
  158. package/molecules/table/table-header.js +31 -72
  159. package/molecules/table/table.js +743 -1075
  160. package/molecules/table/table.story.js +274 -304
  161. package/molecules/tabs/index.js +4 -8
  162. package/molecules/tabs/tabs.js +112 -184
  163. package/molecules/tabs/tabs.story.js +66 -133
  164. package/molecules/videoCardList/index.js +4 -8
  165. package/molecules/videoCardList/videoCardList.js +24 -41
  166. package/molecules/videoCardList/videoCardList.story.js +449 -664
  167. package/molecules/videoPlayer/index.js +4 -8
  168. package/molecules/videoPlayer/videoPlayer.js +1019 -1097
  169. package/molecules/videoPlayer/videoPlayer.story.js +10 -21
  170. package/package.json +2 -2
@@ -1,55 +1,43 @@
1
- 'use strict';
2
-
3
- var _react = require('react');
4
-
5
- var _react2 = _interopRequireDefault(_react);
6
-
7
- var _react3 = require('@storybook/react');
8
-
9
- var _storyHelpers = require('../../_helpers/story-helpers');
10
-
11
- var _components = require('../../components');
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- (0, _react3.storiesOf)('Pagination').add('default', function () {
16
- return _react2.default.createElement(
17
- _storyHelpers.Example,
18
- null,
19
- _react2.default.createElement(_components.Pagination, { items: 20372, perPage: 10, page: 3, onPageChanged: function onPageChanged(page) {
20
- return alert(page);
21
- } })
22
- );
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@storybook/react");
6
+ var _storyHelpers = require("../../_helpers/story-helpers");
7
+ var _components = require("../../components");
8
+ (0, _react2.storiesOf)('Pagination').add('default', function () {
9
+ return /*#__PURE__*/_react["default"].createElement(_storyHelpers.Example, null, /*#__PURE__*/_react["default"].createElement(_components.Pagination, {
10
+ items: 20372,
11
+ perPage: 10,
12
+ page: 3,
13
+ onPageChanged: function onPageChanged(page) {
14
+ return alert(page);
15
+ }
16
+ }));
23
17
  });
24
-
25
- (0, _react3.storiesOf)('Pagination').add('dark', function () {
26
- return _react2.default.createElement(
27
- _storyHelpers.Example,
28
- { background: 'dark' },
29
- _react2.default.createElement(_components.Pagination, {
30
- theme: 'dark',
31
- items: 20372,
32
- perPage: 10,
33
- page: 3,
34
- onPageChanged: function onPageChanged(page) {
35
- return alert(page);
36
- }
37
- })
38
- );
18
+ (0, _react2.storiesOf)('Pagination').add('dark', function () {
19
+ return /*#__PURE__*/_react["default"].createElement(_storyHelpers.Example, {
20
+ background: "dark"
21
+ }, /*#__PURE__*/_react["default"].createElement(_components.Pagination, {
22
+ theme: 'dark',
23
+ items: 20372,
24
+ perPage: 10,
25
+ page: 3,
26
+ onPageChanged: function onPageChanged(page) {
27
+ return alert(page);
28
+ }
29
+ }));
39
30
  });
40
-
41
- (0, _react3.storiesOf)('Pagination').add('nexc', function () {
42
- return _react2.default.createElement(
43
- _storyHelpers.Example,
44
- { background: 'dark' },
45
- _react2.default.createElement(_components.Pagination, {
46
- theme: 'nexc',
47
- items: 20372,
48
- perPage: 10,
49
- page: 3,
50
- onPageChanged: function onPageChanged(page) {
51
- return alert(page);
52
- }
53
- })
54
- );
31
+ (0, _react2.storiesOf)('Pagination').add('nexc', function () {
32
+ return /*#__PURE__*/_react["default"].createElement(_storyHelpers.Example, {
33
+ background: "dark"
34
+ }, /*#__PURE__*/_react["default"].createElement(_components.Pagination, {
35
+ theme: 'nexc',
36
+ items: 20372,
37
+ perPage: 10,
38
+ page: 3,
39
+ onPageChanged: function onPageChanged(page) {
40
+ return alert(page);
41
+ }
42
+ }));
55
43
  });
@@ -0,0 +1,354 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
+ var _react = _interopRequireWildcard(require("react"));
14
+ var _quill = _interopRequireDefault(require("quill"));
15
+ var _propTypes = _interopRequireDefault(require("prop-types"));
16
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
17
+ var _tokens = require("@desynova-digital/tokens");
18
+ var _lodash = require("lodash");
19
+ var _utils = require("../../_helpers/utils");
20
+ var _excluded = ["maxLength", "defaultValue", "label", "showLengthCount", "errorMessage", "value", "autoFocus", "onChange", "handleSave", "editType"];
21
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
22
+ 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); }
23
+ 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; }
24
+ var RichTextInputDiv = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n i,\n em {\n font-style: italic;\n }\n strong {\n font-weight: bold;\n }\n .quill-editor-content {\n white-space: pre-wrap; /* Preserve whitespace and line breaks */\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 .ql-container.ql-snow {\n border: none;\n position: relative;\n }\n .ql-editor {\n padding: 0;\n }\n\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"])));
25
+ var CountWrapper = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\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"])));
26
+ var RichTextInputError = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\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"])), function (props) {
27
+ return _tokens.colors[props.theme].inputError.color;
28
+ });
29
+ var RichTextInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
30
+ var maxLength = _ref.maxLength,
31
+ defaultValue = _ref.defaultValue,
32
+ label = _ref.label,
33
+ showLengthCount = _ref.showLengthCount,
34
+ errorMessage = _ref.errorMessage,
35
+ value = _ref.value,
36
+ autoFocus = _ref.autoFocus,
37
+ onChange = _ref.onChange,
38
+ handleSave = _ref.handleSave,
39
+ editType = _ref.editType,
40
+ props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
41
+ var _useState = (0, _react.useState)(false),
42
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
43
+ focus = _useState2[0],
44
+ setFocus = _useState2[1];
45
+ var _useState3 = (0, _react.useState)(0),
46
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
47
+ charCount = _useState4[0],
48
+ setCharCount = _useState4[1];
49
+ var quillRef = (0, _react.useRef)(null);
50
+ var quillInstance = (0, _react.useRef)(null);
51
+ var clickedKey = (0, _react.useRef)("");
52
+ (0, _react.useImperativeHandle)(ref, function () {
53
+ return {
54
+ getEditorContent: function getEditorContent() {
55
+ if (quillInstance.current) {
56
+ var html = quillInstance.current.root.innerHTML;
57
+ return changeEmToI(html);
58
+ }
59
+ return "";
60
+ },
61
+ setEditorContent: function setEditorContent(content) {
62
+ if (quillInstance.current) {
63
+ var delta = quillInstance.current.clipboard.convert(content); // Convert HTML to Quill's Delta format
64
+ quillInstance.current.setContents(delta); // Set the content in Quill editor
65
+ }
66
+ }
67
+ };
68
+ });
69
+
70
+ /**
71
+ *
72
+ * @param {*} str
73
+ * @returns
74
+ */
75
+ var changeEmToI = function changeEmToI(str) {
76
+ var updatedStr = str.replace(/\n/g, "").replace(/<br\s*\/?>/gi, "").replace(/<\/?p>/gi, "").replace(/<[/]?em>/g, function (match) {
77
+ return match === "<em>" ? "<i>" : "</i>";
78
+ });
79
+
80
+ // Remove surrounding <p> tags if present
81
+ var regex = /^<p(?:[^>]*?)>(.*?)<\/p>$/;
82
+ var match = updatedStr.match(regex);
83
+ return match ? match[1] : updatedStr;
84
+ };
85
+
86
+ // Initialize Quill
87
+ (0, _react.useEffect)(function () {
88
+ if (!(quillInstance !== null && quillInstance !== void 0 && quillInstance.current)) {
89
+ var quill = new _quill["default"](quillRef.current, {
90
+ theme: "snow",
91
+ modules: {
92
+ toolbar: false,
93
+ keyboard: {
94
+ bindings: {
95
+ // This will overwrite the default binding for Tab
96
+ tab: {
97
+ key: 9,
98
+ // Tab key
99
+ handler: function handler() {
100
+ var currentEditor = quillInstance.current.root;
101
+ var editors = document.querySelectorAll(".ql-editor");
102
+ var currentIndex = Array.from(editors).indexOf(currentEditor);
103
+ if (editType === "mainEdit" && currentIndex !== -1 && currentIndex < editors.length - 1) {
104
+ editors[currentIndex + 1].focus();
105
+ }
106
+ }
107
+ },
108
+ // This will handle Shift + Tab
109
+ shiftTab: {
110
+ key: 9,
111
+ // Tab key
112
+ shiftKey: true,
113
+ // Shift key combination
114
+ handler: function handler() {
115
+ var currentEditor = quillInstance.current.root;
116
+ var editors = document.querySelectorAll(".ql-editor");
117
+ var currentIndex = Array.from(editors).indexOf(currentEditor);
118
+ if (editType === "mainEdit" && currentIndex !== -1 && currentIndex > 0) {
119
+ editors[currentIndex - 1].focus(); // Move focus to the previous editor
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ });
127
+ quillInstance.current = quill;
128
+ }
129
+ var handleFocus = function handleFocus() {
130
+ var length = quillInstance.current.getLength();
131
+ quillInstance.current.setSelection(length - 1, 0);
132
+ };
133
+ var editorRoot = quillInstance.current.root;
134
+ editorRoot.addEventListener("focus", handleFocus);
135
+ var updateCharCount = function updateCharCount() {
136
+ var text = quillInstance.current.getText().replace(/\n/g, "");
137
+ var characterCount = text.length;
138
+ setCharCount(characterCount);
139
+ var selection = quillInstance.current.getSelection();
140
+ if (selection) {
141
+ if (maxLength && characterCount > maxLength) {
142
+ var excessCharacters = characterCount - maxLength;
143
+ var startDeleteIndex = selection.index - excessCharacters;
144
+ var safeDeleteIndex = Math.max(0, startDeleteIndex);
145
+ quillInstance.current.deleteText(safeDeleteIndex, excessCharacters);
146
+ text = quillInstance.current.getText().replace(/\n/g, "");
147
+ characterCount = text.length;
148
+ }
149
+ setCharCount(characterCount);
150
+ var html = quillInstance.current.getSemanticHTML();
151
+ html = changeEmToI(html);
152
+ if (onChange && clickedKey.current !== "enter") {
153
+ onChange({
154
+ target: {
155
+ value: html,
156
+ count: characterCount
157
+ }
158
+ });
159
+ }
160
+ }
161
+ };
162
+ quillInstance.current.on("text-change", updateCharCount);
163
+ var editorContainer = quillInstance.current.root;
164
+ editorContainer.classList.add("quill-editor-content");
165
+ return function () {
166
+ quillInstance.current.off("text-change", updateCharCount);
167
+ quillRef.current.innerHTML = "";
168
+ editorRoot.removeEventListener("focus", handleFocus);
169
+ };
170
+ }, []);
171
+
172
+ // eslint-disable-next-line consistent-return
173
+
174
+ // Handles Save on Enter functionality
175
+ (0, _react.useEffect)(function () {
176
+ if (quillInstance.current) {
177
+ var editorContainer = quillInstance.current.root;
178
+
179
+ // Debounced handleSave to prevent rapid triggering
180
+ var debouncedHandleSave = (0, _lodash.debounce)(function (html) {
181
+ handleSave(html);
182
+ }, 0);
183
+ var handleKeyDown = function handleKeyDown(event) {
184
+ if (event.key === "Enter") {
185
+ event.preventDefault();
186
+ var html = quillInstance.current.getSemanticHTML();
187
+ html = changeEmToI(html);
188
+ clickedKey.current = "enter";
189
+ debouncedHandleSave(html);
190
+ } else if (event.key === "Backspace" || event.key === "Delete") {
191
+ clickedKey.current = "backspace";
192
+ } else {
193
+ clickedKey.current = "";
194
+ }
195
+ };
196
+ editorContainer.addEventListener("keydown", handleKeyDown);
197
+ return function () {
198
+ editorContainer.removeEventListener("keydown", handleKeyDown);
199
+ debouncedHandleSave.cancel(); // Clean up debounce
200
+ };
201
+ }
202
+ }, [quillInstance.current]);
203
+
204
+ // Handles cusrsor positions for different cases
205
+ (0, _react.useEffect)(function () {
206
+ if (quillInstance.current && value !== quillInstance.current.root.innerHTML) {
207
+ var currentContent = changeEmToI((0, _utils.cleanHtml)(quillInstance.current.root.innerHTML));
208
+ if (value && currentContent !== value) {
209
+ var selection = quillInstance.current.getSelection(); // Capture cursor position
210
+
211
+ var content = changeEmToI(value) || "";
212
+ quillInstance.current.clipboard.dangerouslyPasteHTML(content); // Insert HTML content in Quill editor
213
+ var textLength = quillInstance.current.getLength();
214
+ if (selection && selection.index !== 0) {
215
+ quillInstance.current.setSelection(selection.index, selection.length); // Restore previous cursor position
216
+ } else if (selection && selection.index === 0 && clickedKey.current === "backspace") {
217
+ quillInstance.current.setSelection(0, 0); // Keep cursor at start when pressing backspace
218
+ } else {
219
+ quillInstance.current.setSelection(charCount || textLength - 1, (selection === null || selection === void 0 ? void 0 : selection.length) || 0); // Move cursor right for other cases
220
+
221
+ if (editType === "mainEdit" && !selection) {
222
+ quillInstance.current.blur();
223
+ // Select the first video element
224
+ var videoElement = document.getElementsByTagName("video")[0];
225
+ // Add a tabindex attribute to make it focusable
226
+ videoElement.setAttribute("tabindex", "0");
227
+ videoElement.focus();
228
+ }
229
+ }
230
+ }
231
+ }
232
+ }, [value]);
233
+
234
+ // handles focus for autoFocus feature
235
+ (0, _react.useEffect)(function () {
236
+ if (quillInstance.current && autoFocus) {
237
+ setTimeout(function () {
238
+ quillInstance.current.focus();
239
+ }, 0);
240
+ }
241
+ }, [autoFocus, quillInstance.current]);
242
+ return /*#__PURE__*/_react["default"].createElement(RichTextInputDiv, {
243
+ theme: props.theme,
244
+ inputWidth: props.inputWidth
245
+ }, /*#__PURE__*/_react["default"].createElement(RichTextEditorContainer, (0, _extends2["default"])({
246
+ type: "text",
247
+ value: value,
248
+ defaultValue: defaultValue
249
+ }, props, {
250
+ maxLength: maxLength || "",
251
+ showLengthCount: showLengthCount || false
252
+ }), /*#__PURE__*/_react["default"].createElement("div", {
253
+ ref: quillRef
254
+ })), label && quillInstance.current && /*#__PURE__*/_react["default"].createElement("label", {
255
+ htmlFor: props.id,
256
+ className: charCount || focus ? "floaton" : ""
257
+ }, "".concat(label).concat(props.required ? "*" : "")), errorMessage && /*#__PURE__*/_react["default"].createElement(RichTextInputError, {
258
+ value: value,
259
+ theme: props.theme,
260
+ error: props.error
261
+ }, errorMessage), maxLength && showLengthCount && quillInstance.current && /*#__PURE__*/_react["default"].createElement(CountWrapper, null, charCount, "/", maxLength));
262
+ });
263
+
264
+ /**
265
+ *
266
+ * @param {*} props
267
+ * @returns
268
+ */
269
+ var returnPadding = function returnPadding(props) {
270
+ var digitCount = props.maxLength.toString().length;
271
+ switch (digitCount) {
272
+ case 0:
273
+ return "7px 0px 2px 0px";
274
+ case 1:
275
+ return "7px 40px 2px 0px";
276
+ case 2:
277
+ return "7px 60px 2px 0px";
278
+ case 3:
279
+ return "7px 75px 2px 0px";
280
+ case 4:
281
+ return "7px 90px 2px 0px";
282
+ case 5:
283
+ return "7px 110px 2px 0px";
284
+ default:
285
+ return "7px 0px 2px 0px";
286
+ }
287
+ };
288
+ var RichTextEditorContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 48px;\n overflow-y: scroll;\n ::-webkit-scrollbar {\n width: 0; /* Remove scrollbar space */\n background: transparent; /* Optional: just make scrollbar invisible */\n }\n white-space: nowrap;\n width: 100%;\n text-wrap: wrap;\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"])), function (props) {
289
+ return props.theme === "light" ? _tokens.colors.light.inputCommon.border : _tokens.colors.dark.inputCommon.border;
290
+ }, function (props) {
291
+ return props.theme === "light" ? _tokens.colors.light.inputCommon.color : _tokens.colors.dark.inputCommon.color;
292
+ }, function (props) {
293
+ return returnPadding(props || "");
294
+ }, function (props) {
295
+ return props.theme === "light" ? _tokens.colors.light.inputCommon.borderHover : _tokens.colors.dark.inputCommon.borderHover;
296
+ }, function (props) {
297
+ return props.theme === "light" ? _tokens.colors.light.inputCommon.borderHover : _tokens.colors.dark.inputCommon.borderHover;
298
+ }, function (props) {
299
+ return props.theme === "light" ? _tokens.colors.light.inputCommon.placeholder : _tokens.colors.dark.inputCommon.placeholder;
300
+ }, function (props) {
301
+ return props.label ? "0" : "1";
302
+ }, function (props) {
303
+ return props.theme === "light" ? _tokens.colors.light.inputCommon.placeholder : _tokens.colors.dark.inputCommon.placeholder;
304
+ }, function (props) {
305
+ return props.label ? "1" : "1";
306
+ });
307
+ RichTextInput.propTypes = {
308
+ masked: _propTypes["default"].bool,
309
+ /** Make input readOnly if it does not validate constraint */
310
+ readOnly: _propTypes["default"].bool,
311
+ /** Use when the expected input is code */
312
+ code: _propTypes["default"].bool,
313
+ /** Pass hasError to show error state */
314
+ hasError: _propTypes["default"].bool,
315
+ /** Pass error string directly to show error state */
316
+ error: _propTypes["default"].string,
317
+ /** onChange transparently passed to the input */
318
+ onChange: _propTypes["default"].func,
319
+ onKeyDownFn: _propTypes["default"].func,
320
+ handleSave: _propTypes["default"].func,
321
+ /** Text to display when the input is empty */
322
+ placeholder: _propTypes["default"].string,
323
+ /** The default value for the field */
324
+ defaultValue: _propTypes["default"].string,
325
+ /** The (HTML) type for the input. */
326
+ type: _propTypes["default"].string,
327
+ value: _propTypes["default"].string,
328
+ /** The (HTML) maxLength for the input. */
329
+ maxLength: _propTypes["default"].number,
330
+ inputWidth: _propTypes["default"].number,
331
+ showLengthCount: _propTypes["default"].bool,
332
+ label: _propTypes["default"].string,
333
+ errorMessage: _propTypes["default"].string,
334
+ editType: _propTypes["default"].string,
335
+ id: _propTypes["default"].string,
336
+ simpleEdit: _propTypes["default"].bool,
337
+ required: _propTypes["default"].bool,
338
+ autoFocus: _propTypes["default"].bool,
339
+ theme: _propTypes["default"].oneOf(["light", "dark", "nexc"]),
340
+ fieldType: _propTypes["default"].oneOf(["inputField", "textArea"])
341
+ };
342
+ RichTextInput.defaultProps = {
343
+ autoFocus: false,
344
+ fieldType: "textArea",
345
+ readOnly: false,
346
+ code: false,
347
+ error: null,
348
+ onChange: null,
349
+ type: "text",
350
+ theme: "light",
351
+ showLengthCount: false,
352
+ simpleEdit: false
353
+ };
354
+ var _default = exports["default"] = RichTextInput;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@storybook/react");
6
+ var _storyHelpers = require("../../_helpers/story-helpers");
7
+ var _components = require("../../components");
8
+ var _this = void 0;
9
+ (0, _react2.storiesOf)("RichTextInput").add("light theme", function () {
10
+ return /*#__PURE__*/_react["default"].createElement(_storyHelpers.Example, {
11
+ title: "Appearances"
12
+ }, /*#__PURE__*/_react["default"].createElement(_storyHelpers.Stack, null, /*#__PURE__*/_react["default"].createElement(_components.RichTextInput, {
13
+ inputWidth: 300,
14
+ fieldType: "inputField",
15
+ showLengthCount: true,
16
+ type: "text",
17
+ label: "First Name",
18
+ onKeyPress: function onKeyPress(e) {
19
+ return _this.value = e;
20
+ },
21
+ onChange: function onChange(e) {
22
+ return console.log(e.html, e.size);
23
+ },
24
+ placeholder: "Enter Name max 10",
25
+ maxLength: 1000,
26
+ value: "asd",
27
+ required: true
28
+ })));
29
+ });
30
+ (0, _react2.storiesOf)("DraftInputText").add("dark theme", function () {
31
+ return /*#__PURE__*/_react["default"].createElement(_storyHelpers.Example, {
32
+ title: "Appearances"
33
+ }, /*#__PURE__*/_react["default"].createElement(_storyHelpers.Stack, null, /*#__PURE__*/_react["default"].createElement(_components.RichTextInput, {
34
+ inputWidth: 300,
35
+ fieldType: "inputField",
36
+ showLengthCount: true,
37
+ type: "text",
38
+ label: "First Name",
39
+ onKeyPress: function onKeyPress(e) {
40
+ return _this.value = e;
41
+ },
42
+ onChange: function onChange(e) {
43
+ return console.log(e.html, e.size);
44
+ },
45
+ placeholder: "Enter Name max 10",
46
+ maxLength: 1000,
47
+ value: "asd",
48
+ required: true
49
+ })));
50
+ });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _RichTextInput = _interopRequireDefault(require("./RichTextInput"));
9
+ var _default = exports["default"] = _RichTextInput["default"];
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
-
7
- var _table = require("./table");
8
-
9
- var _table2 = _interopRequireDefault(_table);
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
- exports.default = _table2.default;
7
+ exports["default"] = void 0;
8
+ var _table = _interopRequireDefault(require("./table"));
9
+ var _default = exports["default"] = _table["default"];
@@ -1,27 +1,21 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
-
7
- var _propTypes = require("prop-types");
8
-
9
- var _propTypes2 = _interopRequireDefault(_propTypes);
10
-
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
7
+ exports["default"] = void 0;
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
9
  // The table column isn't actually rendered; it's just used to capture props.
14
10
  var TableColumn = function TableColumn(props) {
15
11
  return null;
16
12
  };
17
-
18
13
  TableColumn.propTypes = {
19
- field: _propTypes2.default.string.isRequired,
20
- title: _propTypes2.default.string,
21
- width: _propTypes2.default.string,
22
- sortable: _propTypes2.default.bool,
23
- sort: _propTypes2.default.oneOf(["asc", "desc"]),
24
- comparator: _propTypes2.default.func
14
+ field: _propTypes["default"].string.isRequired,
15
+ title: _propTypes["default"].string,
16
+ width: _propTypes["default"].string,
17
+ sortable: _propTypes["default"].bool,
18
+ sort: _propTypes["default"].oneOf(["asc", "desc"]),
19
+ comparator: _propTypes["default"].func
25
20
  };
26
-
27
- exports.default = TableColumn;
21
+ var _default = exports["default"] = TableColumn;