versacall-dashboards-library-react 2.0.39 → 2.0.41

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 (99) hide show
  1. package/dist/components/DashboardsCell/DashboardsCell.js +54 -104
  2. package/dist/components/DashboardsCell/index.js +2 -4
  3. package/dist/components/DashboardsCellContent/DashboardsCellContent.js +29 -62
  4. package/dist/components/DashboardsCellContent/index.js +2 -4
  5. package/dist/components/DashboardsCellFindAndReplace/DashboardsCellFindAndReplace.js +27 -57
  6. package/dist/components/DashboardsCellFindAndReplace/index.js +2 -4
  7. package/dist/components/DashboardsCellGlobalActions/DashboardsCellGlobalActions.js +151 -155
  8. package/dist/components/DashboardsCellGlobalActions/index.js +2 -4
  9. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditions.js +463 -563
  10. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditionsNestable.js +109 -199
  11. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditionsOld.js +87 -173
  12. package/dist/components/DashboardsCellGlobalConditions/index.js +2 -4
  13. package/dist/components/DashboardsCellGlobalStyles/DashboardsCellGlobalStyles.js +28 -78
  14. package/dist/components/DashboardsCellGlobalStyles/index.js +2 -4
  15. package/dist/components/DashboardsCellMergeUnmerge/DashboardsCellMergeUnmerge.js +33 -65
  16. package/dist/components/DashboardsCellMergeUnmerge/index.js +2 -4
  17. package/dist/components/DashboardsCellPosition/DashboardsCellPosition.js +5 -11
  18. package/dist/components/DashboardsCellPosition/index.js +2 -4
  19. package/dist/components/DashboardsCellSize/DashboardsCellSize.js +7 -16
  20. package/dist/components/DashboardsCellSize/index.js +2 -4
  21. package/dist/components/DashboardsCellStyle/DashboardsCellStyle.js +5 -21
  22. package/dist/components/DashboardsCellStyle/index.js +2 -4
  23. package/dist/components/DashboardsCellStyleAlignItems/DashboardsCellStyleAlignItems.js +12 -28
  24. package/dist/components/DashboardsCellStyleAlignItems/index.js +2 -4
  25. package/dist/components/DashboardsCellStyleBackgroundColor/DashboardsCellStyleBackgroundColor.js +15 -52
  26. package/dist/components/DashboardsCellStyleBackgroundColor/index.js +2 -4
  27. package/dist/components/DashboardsCellStyleClear/DashboardsCellStyleClear.js +4 -12
  28. package/dist/components/DashboardsCellStyleClear/index.js +2 -4
  29. package/dist/components/DashboardsCellStyleColor/DashboardsCellStyleColor.js +15 -52
  30. package/dist/components/DashboardsCellStyleColor/index.js +2 -4
  31. package/dist/components/DashboardsCellStyleDisplay/DashboardsCellStyleDisplay.js +6 -15
  32. package/dist/components/DashboardsCellStyleDisplay/index.js +2 -4
  33. package/dist/components/DashboardsCellStyleFontFamily/DashboardsCellStyleFontFamily.js +6 -15
  34. package/dist/components/DashboardsCellStyleFontFamily/index.js +2 -4
  35. package/dist/components/DashboardsCellStyleFontSize/DashboardsCellStyleFontSize.js +8 -19
  36. package/dist/components/DashboardsCellStyleFontSize/index.js +2 -4
  37. package/dist/components/DashboardsCellStyleJustifyContent/DashboardsCellStyleJustifyContent.js +12 -28
  38. package/dist/components/DashboardsCellStyleJustifyContent/index.js +2 -4
  39. package/dist/components/DashboardsCellStyleObjectFit/DashboardsCellStyleObjectFit.js +6 -15
  40. package/dist/components/DashboardsCellStyleObjectFit/index.js +2 -4
  41. package/dist/components/DashboardsCellStylePadding/DashboardsCellStylePadding.js +7 -16
  42. package/dist/components/DashboardsCellStylePadding/index.js +2 -4
  43. package/dist/components/DashboardsCellStyleWeightStyleDecoration/DashboardsCellStyleWeightStyleDecoration.js +12 -28
  44. package/dist/components/DashboardsCellStyleWeightStyleDecoration/index.js +2 -4
  45. package/dist/components/DashboardsCopyAndPaste/DashboardsCopyAndPaste.js +19 -40
  46. package/dist/components/DashboardsCopyAndPaste/index.js +2 -4
  47. package/dist/components/DashboardsEditor/DashboardsEditor.js +34 -68
  48. package/dist/components/DashboardsEditor/index.js +2 -4
  49. package/dist/components/DashboardsGlobalStylesPicker/DashboardsGlobalStylesPicker.js +13 -25
  50. package/dist/components/DashboardsGlobalStylesPicker/index.js +2 -4
  51. package/dist/components/DashboardsGrid/DashboardsGrid.js +21 -33
  52. package/dist/components/DashboardsGrid/index.js +2 -4
  53. package/dist/components/DashboardsMainFreehand/DashboardsMainFreehand.js +65 -130
  54. package/dist/components/DashboardsMainFreehand/index.js +2 -4
  55. package/dist/components/DashboardsMainMessaging/DashboardsMainMessaging.js +86 -203
  56. package/dist/components/DashboardsMainMessaging/index.js +2 -4
  57. package/dist/components/DashboardsMainTable/DashboardsMainTable.js +94 -208
  58. package/dist/components/DashboardsMainTable/index.js +2 -4
  59. package/dist/components/DashboardsPreview/DashboardsPreview.js +18 -32
  60. package/dist/components/DashboardsPreview/index.js +2 -4
  61. package/dist/components/DashboardsRatio/DashboardsRatio.js +18 -64
  62. package/dist/components/DashboardsRatio/DashboardsRatioOld.js +12 -27
  63. package/dist/components/DashboardsRatio/index.js +2 -4
  64. package/dist/components/DashboardsStatusBar/DashboardsStatusBar.js +16 -30
  65. package/dist/components/DashboardsStatusBar/index.js +2 -4
  66. package/dist/components/DashboardsUndoRedo/DashboardsUndoRedo.js +13 -42
  67. package/dist/components/DashboardsUndoRedo/index.js +2 -4
  68. package/dist/components/DashboardsViewer/DashboardsViewer.js +12 -19
  69. package/dist/components/DashboardsViewer/index.js +2 -4
  70. package/dist/components/DashboardsWidthHeight/DashboardsWidthHeight.js +8 -18
  71. package/dist/components/DashboardsWidthHeight/index.js +2 -4
  72. package/dist/components/WidgetParameters/WidgetParameters.js +32 -74
  73. package/dist/components/WidgetParameters/index.js +2 -4
  74. package/dist/components/index.js +41 -77
  75. package/dist/constants/defaultFreehandCell.js +2 -3
  76. package/dist/constants/defaultFreehandDashboard.js +2 -3
  77. package/dist/constants/defaultMessagingDashboard.js +2 -3
  78. package/dist/constants/defaultStyle.js +2 -3
  79. package/dist/constants/defaultTableCell.js +2 -3
  80. package/dist/constants/defaultTableDashboard.js +2 -3
  81. package/dist/constants/index.js +7 -14
  82. package/dist/functions/addTranslations.js +7 -14
  83. package/dist/functions/calculateDashboardVariables.js +24 -48
  84. package/dist/functions/convertColorObject.js +0 -1
  85. package/dist/functions/convertColorString.js +2 -4
  86. package/dist/functions/convertPercentToInt.js +0 -1
  87. package/dist/functions/convertSecondsToElapsedTime.js +8 -13
  88. package/dist/functions/generateFreehandCell.js +3 -6
  89. package/dist/functions/generateFreehandDashboard.js +2 -6
  90. package/dist/functions/generateMessagingDashboard.js +1 -3
  91. package/dist/functions/generateSelected.js +1 -4
  92. package/dist/functions/generateTableCell.js +1 -3
  93. package/dist/functions/generateTableDashboard.js +7 -15
  94. package/dist/functions/index.js +15 -30
  95. package/dist/functions/mergeSelected.js +3 -5
  96. package/dist/functions/sortCells.js +0 -5
  97. package/dist/index.js +3 -9
  98. package/dist/translations/en.json +2 -1
  99. package/package.json +2 -2
@@ -4,100 +4,68 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
9
  var _styles = require("@material-ui/core/styles");
13
-
14
10
  var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
15
-
16
11
  var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
17
-
18
12
  var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
19
-
20
13
  var _Switch = _interopRequireDefault(require("@material-ui/core/Switch"));
21
-
22
14
  var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
23
-
24
15
  var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
25
-
26
16
  var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
27
-
28
17
  var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
29
-
30
18
  var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));
31
-
32
19
  var _Tabs = _interopRequireDefault(require("@material-ui/core/Tabs"));
33
-
34
20
  var _Tab = _interopRequireDefault(require("@material-ui/core/Tab"));
35
-
36
21
  var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
37
-
38
22
  var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
39
-
40
23
  var _ArrowDownward = _interopRequireDefault(require("@material-ui/icons/ArrowDownward"));
41
-
42
24
  var _ArrowUpward = _interopRequireDefault(require("@material-ui/icons/ArrowUpward"));
43
-
44
25
  var _FileCopy = _interopRequireDefault(require("@material-ui/icons/FileCopy"));
45
-
46
26
  var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
47
-
48
27
  var _Add = _interopRequireDefault(require("@material-ui/icons/Add"));
49
-
50
28
  var _MoreVert = _interopRequireDefault(require("@material-ui/icons/MoreVert"));
51
-
52
29
  var _OpenWith = _interopRequireDefault(require("@material-ui/icons/OpenWith"));
53
-
54
30
  var _CallSplit = _interopRequireDefault(require("@material-ui/icons/CallSplit"));
55
-
56
31
  var _reactBeautifulDnd = require("react-beautiful-dnd");
57
-
58
32
  var _reactIntl = require("react-intl");
59
-
60
33
  var _versacallCoreLibraryReact = require("versacall-core-library-react");
61
-
62
34
  var _DashboardsCellGlobalStyles = _interopRequireDefault(require("../DashboardsCellGlobalStyles"));
63
-
64
35
  var _DashboardsCellContent = _interopRequireDefault(require("../DashboardsCellContent"));
65
-
66
36
  var _DashboardsCellStyle = _interopRequireDefault(require("../DashboardsCellStyle"));
67
-
68
37
  var _DashboardsPreview = _interopRequireDefault(require("../DashboardsPreview"));
69
-
70
38
  var _DashboardsCell = _interopRequireDefault(require("../DashboardsCell"));
71
-
72
39
  require("react-nestable-fork/dist/Nestable/Nestable.css");
73
-
74
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
75
-
76
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
77
-
78
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
79
-
80
- function _extends() { _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; }; return _extends.apply(this, arguments); }
81
-
82
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
83
-
84
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
85
-
86
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
87
-
88
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
89
-
90
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 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"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
91
-
92
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
93
-
94
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
95
-
96
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
97
-
98
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
99
-
100
- var muiStyles = () => ({
40
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
41
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
42
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
43
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
44
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
45
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
46
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
47
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
48
+ // Constants
49
+ const OPERATOR_OPTIONS = [{
50
+ value: '===',
51
+ label: '='
52
+ }, {
53
+ value: '>',
54
+ label: '>'
55
+ }, {
56
+ value: '<',
57
+ label: '<'
58
+ }, {
59
+ value: '!==',
60
+ label: "".concat(String.fromCharCode(0x2260))
61
+ }, {
62
+ value: '>=',
63
+ label: "".concat(String.fromCharCode(0x2265))
64
+ }, {
65
+ value: '<=',
66
+ label: "".concat(String.fromCharCode(0x2264))
67
+ }];
68
+ const muiStyles = () => ({
101
69
  dialog: {
102
70
  backgroundColor: '#eff4f8'
103
71
  },
@@ -124,8 +92,7 @@ var muiStyles = () => ({
124
92
  color: '#ffffff'
125
93
  }
126
94
  });
127
-
128
- var style = {
95
+ const style = {
129
96
  root: {
130
97
  position: 'relative',
131
98
  display: 'flex',
@@ -133,7 +100,6 @@ var style = {
133
100
  height: '76vh',
134
101
  padding: 16,
135
102
  paddingBottom: 0,
136
- // backgroundColor: '#e6e6e6',
137
103
  overflow: 'hidden'
138
104
  },
139
105
  fullHeight: {
@@ -141,7 +107,6 @@ var style = {
141
107
  overflow: 'hidden'
142
108
  },
143
109
  paper: {
144
- // display: 'block',
145
110
  boxSizing: 'border-box',
146
111
  padding: 16,
147
112
  overflow: 'hidden'
@@ -156,7 +121,6 @@ var style = {
156
121
  },
157
122
  scroll: {
158
123
  position: 'absolute',
159
- // display: 'block',
160
124
  width: '100%',
161
125
  maxHeight: '100%',
162
126
  overflow: 'auto',
@@ -170,7 +134,7 @@ var style = {
170
134
  styleBox: {
171
135
  borderStyle: 'solid',
172
136
  borderWidth: 1,
173
- borderColor: 'rgba(0, 0, 0, 0.23',
137
+ borderColor: 'rgba(0, 0, 0, 0.23)',
174
138
  borderRadius: 4,
175
139
  padding: 16,
176
140
  marginBottom: 16,
@@ -190,28 +154,8 @@ var style = {
190
154
  textTransform: 'uppercase'
191
155
  }
192
156
  };
193
- var operatorOptions = [{
194
- value: '===',
195
- label: '='
196
- }, {
197
- value: '>',
198
- label: '>'
199
- }, {
200
- value: '<',
201
- label: '<'
202
- }, {
203
- value: '!==',
204
- label: "".concat(String.fromCharCode(0x2260))
205
- }, {
206
- value: '>=',
207
- label: "".concat(String.fromCharCode(0x2265))
208
- }, {
209
- value: '<=',
210
- label: "".concat(String.fromCharCode(0x2264))
211
- }];
212
-
213
- var formatCondition = original => {
214
- var formatted = original;
157
+ const formatCondition = original => {
158
+ let formatted = original;
215
159
  formatted = formatted.replace('===', '=');
216
160
  formatted = formatted.replace('!==', String.fromCharCode(0x2260));
217
161
  formatted = formatted.replace('>=', String.fromCharCode(0x2265));
@@ -220,518 +164,449 @@ var formatCondition = original => {
220
164
  formatted = formatted.replace('||', 'OR');
221
165
  return formatted;
222
166
  };
223
-
224
- var tabStyle = active => ({
225
- // border: active ? '2px solid #008bcc' : '',
167
+ const tabStyle = active => ({
226
168
  color: active ? 'black' : 'white',
227
- backgroundColor: active ? '#55b7dc' : '#496b78' // borderRadius: '3px',
228
-
169
+ backgroundColor: active ? '#55b7dc' : '#496b78'
229
170
  });
230
-
231
- var contentPreviewCustomCell = ({
232
- row
233
- }) => /*#__PURE__*/_react.default.createElement("div", {
234
- style: {
235
- width: 120
236
- }
237
- }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
238
- width: "120px",
239
- height: "100px",
240
- padding: "10px"
241
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
242
- cell: {
243
- content: row.content,
244
- custom: {
245
- viewWidth: 120,
246
- viewHeight: 100,
247
- style: {}
171
+ const contentPreviewCustomCell = _ref => {
172
+ let {
173
+ row
174
+ } = _ref;
175
+ return /*#__PURE__*/_react.default.createElement("div", {
176
+ style: {
177
+ width: 120
248
178
  }
249
- }
250
- })));
251
- /* const conditionCustomCell = ({ row }) => {
252
- let newCondition = row.condition;
253
- if (newCondition.split(' ').length === 3) {
254
- operatorOptions.forEach(option => {
255
- newCondition = newCondition.replace(new RegExp(option.value, 'g'), option.label);
256
- });
257
- }
258
- return newCondition;
259
- }; */
260
- // const grid = 8;
261
-
262
-
263
- var getItemStyle = (isDragging, draggableStyle) => _objectSpread({
264
- // some basic styles to make the items look a bit nicer
179
+ }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
180
+ width: "120px",
181
+ height: "100px",
182
+ padding: "10px"
183
+ }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
184
+ cell: {
185
+ content: row.content,
186
+ custom: {
187
+ viewWidth: 120,
188
+ viewHeight: 100,
189
+ style: {}
190
+ }
191
+ }
192
+ })));
193
+ };
194
+ const getItemStyle = (isDragging, draggableStyle) => _objectSpread({
265
195
  userSelect: 'none',
266
- // padding: grid * 2,
267
- // margin: `0 0 ${grid}px 0`,
268
196
  marginBottom: 10
269
197
  }, draggableStyle);
270
-
271
- var getListStyle = isDraggingOver => ({// background: isDraggingOver ? 'lightblue' : 'lightgrey',
272
- // padding: grid,
273
- // width: 250,
274
- }); // a little function to help us with reordering the result
275
-
276
-
277
- var reorder = (list, startIndex, endIndex) => {
278
- var result = Array.from(list);
279
-
280
- var _result$splice = result.splice(startIndex, 1),
281
- _result$splice2 = _slicedToArray(_result$splice, 1),
282
- removed = _result$splice2[0];
283
-
198
+ const getListStyle = () => ({
199
+ // Empty object for now, can be extended if needed
200
+ });
201
+ const reorder = (list, startIndex, endIndex) => {
202
+ const result = Array.from(list);
203
+ const [removed] = result.splice(startIndex, 1);
284
204
  result.splice(endIndex, 0, removed);
285
205
  return result;
286
206
  };
287
-
288
- var determineIfAdvanced = condition => {
289
- // console.log('determinIfAdvanced', condition);
207
+ const determineIfAdvanced = condition => {
290
208
  if (condition) {
291
- var split = condition.split(/[ ,]+/);
292
-
209
+ const split = condition.split(/[ ,]+/);
293
210
  if (split.length === 3) {
294
- var operator = operatorOptions.find(x => x.value === split[1]);
295
-
211
+ const operator = OPERATOR_OPTIONS.find(x => x.value === split[1]);
296
212
  if (operator) {
297
213
  return false;
298
214
  }
299
215
  }
300
216
  }
301
-
302
217
  return true;
303
218
  };
304
-
305
219
  class DashboardsCellGlobalConditions extends _react.Component {
306
220
  constructor(props) {
307
221
  super(props);
308
- this.state = {
309
- open: false,
310
- tabIndex: 0,
311
- conditionIndex: null,
312
- menuIndex: null,
313
- menuAnchorEl: null,
314
- advanced: false
315
- /* styleColumns: [
316
- {
317
- id: 'condition', style: { paddingRight: 0 }, label: props.intl.formatMessage({ id: '__condition' }), customCell: custom => conditionCustomCell(custom),
318
- },
319
- {
320
- id: 'preview', style: { paddingRight: 0 }, label: props.intl.formatMessage({ id: '__preview' }), customCell: custom => this.stylePreviewCustomCell(custom),
321
- },
322
- {
323
- id: 'actions', style: { textAlign: 'right' }, label: props.intl.formatMessage({ id: '__actions' }), customCell: custom => this.actionsCustomCell(custom),
324
- }
325
- ],
326
- conditionColumns: [
327
- {
328
- id: 'condition', style: { paddingRight: 0 }, label: props.intl.formatMessage({ id: '__condition' }), customCell: custom => conditionCustomCell(custom),
329
- },
330
- {
331
- id: 'type', style: { paddingRight: 0 }, label: props.intl.formatMessage({ id: '__type' }), customCell: custom => this.contentTypeCustomCell(custom),
332
- },
333
- {
334
- id: 'preview', style: { paddingRight: 0 }, label: props.intl.formatMessage({ id: '__preview' }), customCell: custom => contentPreviewCustomCell(custom),
335
- },
336
- {
337
- id: 'actions', style: { textAlign: 'right' }, label: props.intl.formatMessage({ id: '__actions' }), customCell: custom => this.actionsCustomCell(custom),
338
- }
339
- ], */
340
-
341
- };
342
- }
343
-
344
- stylePreviewCustomCell({
345
- row
346
- }) {
347
- var _this = this;
348
-
349
- var newCell = JSON.parse(JSON.stringify(row));
350
- newCell.custom = {
351
- viewWidth: 120,
352
- viewHeight: 120,
353
- style: {}
354
- };
355
-
356
- if (this.props.styles.length > 0 && row.styleIds && row.styleIds.length > 0) {
357
- var _loop = function _loop(i) {
358
- var findStyle = _this.props.styles.find(searchStyle => searchStyle.id === newCell.styleIds[i]);
359
-
360
- if (findStyle) {
361
- newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), findStyle.options);
362
- }
222
+ _defineProperty(this, "stylePreviewCustomCell", _ref2 => {
223
+ let {
224
+ row
225
+ } = _ref2;
226
+ const newCell = _objectSpread({}, row);
227
+ newCell.custom = {
228
+ viewWidth: 120,
229
+ viewHeight: 120,
230
+ style: {}
363
231
  };
364
-
365
- for (var i = 0; i < newCell.styleIds.length; i++) {
366
- _loop(i);
367
- }
368
- }
369
-
370
- newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), newCell.style);
371
- return /*#__PURE__*/_react.default.createElement("div", {
372
- style: {
373
- width: 120
374
- }
375
- }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
376
- width: "120px",
377
- height: "100px",
378
- padding: "10px"
379
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
380
- cell: {
381
- content: {
382
- type: 'text',
383
- text: 'Hello'
384
- },
385
- custom: newCell.custom
386
- }
387
- })));
388
- }
389
-
390
- contentTypeCustomCell({
391
- row
392
- }) {
393
- return /*#__PURE__*/_react.default.createElement("span", null, this.props.intl.formatMessage({
394
- id: "__".concat(row.content.type)
395
- }));
396
- }
397
-
398
- actionsCustomCell({
399
- row
400
- }) {
401
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, row.index !== '0' && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
402
- onClick: e => {
403
- e.stopPropagation();
404
- this.moveCondition(row.index, -1);
405
- }
406
- }, /*#__PURE__*/_react.default.createElement(_ArrowUpward.default, null)), row.index !== String(this.props.value[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].length - 1) && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
407
- onClick: e => {
408
- e.stopPropagation();
409
- this.moveCondition(row.index, 1);
410
- }
411
- }, /*#__PURE__*/_react.default.createElement(_ArrowDownward.default, null)), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
412
- onClick: e => {
413
- e.stopPropagation();
414
- this.copyCondition(row);
415
- }
416
- }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
417
- title: this.props.intl.formatMessage({
418
- id: '__copy'
419
- })
420
- }, /*#__PURE__*/_react.default.createElement(_FileCopy.default, null))), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
421
- onClick: e => {
422
- e.stopPropagation();
423
- this.deleteCondition(row.index);
424
- }
425
- }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
426
- title: this.props.intl.formatMessage({
427
- id: '__delete'
428
- })
429
- }, /*#__PURE__*/_react.default.createElement(_Delete.default, null))));
430
- }
431
-
432
- updateCondition(change) {
433
- var _this$state = this.state,
434
- conditionIndex = _this$state.conditionIndex,
435
- tabIndex = _this$state.tabIndex; // console.log(`conditionIndex = ${conditionIndex}`);
436
-
437
- var updatedValue = _objectSpread({}, this.props.value); // console.log('updatedValue', updatedValue);
438
- // const conditions = updatedValue[`${typeCondition}Conditions`];
439
-
440
-
441
- var conditions = tabIndex === 1 ? updatedValue.contentConditions : updatedValue.styleConditions; // const conditions = JSON.parse(JSON.stringify(this.props.value[`${this.state.typeCondition}Conditions`]));
442
-
443
- if (this.state.advanced) {
444
- conditions[conditionIndex].condition = change.value;
445
- } else {
446
- var split = conditions[conditionIndex].condition.split(/[ ,]+/);
447
- var segment1 = split[0];
448
- var segment2 = split.length > 1 ? split[1] : '===';
449
- var segment3 = split.length > 2 ? split[2] : '0';
450
-
451
- switch (change.stringIndex) {
452
- case 0:
453
- conditions[conditionIndex].condition = "".concat(change.value, " ").concat(segment2, " ").concat(segment3);
454
- break;
455
-
456
- case 1:
457
- conditions[conditionIndex].condition = "".concat(segment1, " ").concat(change.value, " ").concat(segment3);
458
- break;
459
-
460
- case 2:
461
- conditions[conditionIndex].condition = "".concat(segment1, " ").concat(segment2, " ").concat(change.value);
462
- break;
463
-
464
- default:
465
- conditions[conditionIndex].condition = "".concat(segment1, " ").concat(segment2, " ").concat(segment3);
466
- break;
232
+ if (this.props.styles.length > 0 && row.styleIds && row.styleIds.length > 0) {
233
+ for (let i = 0; i < newCell.styleIds.length; i++) {
234
+ const findStyle = this.props.styles.find(searchStyle => searchStyle.id === newCell.styleIds[i]);
235
+ if (findStyle) {
236
+ newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), findStyle.options);
237
+ }
238
+ }
467
239
  }
468
- } // this.props.updateValue({ [`${this.state.typeCondition}Conditions`]: conditions });
469
-
470
-
471
- this.props.updateValue({
472
- styleConditions: updatedValue.styleConditions,
473
- contentConditions: updatedValue.contentConditions
240
+ newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), newCell.style);
241
+ return /*#__PURE__*/_react.default.createElement("div", {
242
+ style: {
243
+ width: 120
244
+ }
245
+ }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
246
+ width: "120px",
247
+ height: "100px",
248
+ padding: "10px"
249
+ }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
250
+ cell: {
251
+ content: {
252
+ type: 'text',
253
+ text: 'Hello'
254
+ },
255
+ custom: newCell.custom
256
+ }
257
+ })));
474
258
  });
475
- }
476
-
477
- updateStyleIds(value) {
478
- var styleConditions = JSON.parse(JSON.stringify(this.props.value.styleConditions));
479
- styleConditions[this.state.conditionIndex].styleIds = value.styleIds;
480
- this.props.updateValue({
481
- styleConditions: styleConditions
259
+ _defineProperty(this, "contentTypeCustomCell", _ref3 => {
260
+ let {
261
+ row
262
+ } = _ref3;
263
+ return /*#__PURE__*/_react.default.createElement("span", null, this.props.intl.formatMessage({
264
+ id: "__".concat(row.content.type)
265
+ }));
482
266
  });
483
- }
484
-
485
- updateStyle(value) {
486
- var styleConditions = JSON.parse(JSON.stringify(this.props.value.styleConditions));
487
-
488
- if (Object.keys(value.style).length > 0) {
489
- styleConditions[this.state.conditionIndex].style = _objectSpread(_objectSpread({}, styleConditions[this.state.conditionIndex].style), value.style);
490
- Object.keys(styleConditions[this.state.conditionIndex].style).forEach(key => {
491
- if (styleConditions[this.state.conditionIndex].style[key] === 'delete') {
492
- delete styleConditions[this.state.conditionIndex].style[key];
267
+ _defineProperty(this, "actionsCustomCell", _ref4 => {
268
+ let {
269
+ row
270
+ } = _ref4;
271
+ const {
272
+ tabIndex
273
+ } = this.state;
274
+ const conditions = tabIndex === 0 ? this.props.value.styleConditions : this.props.value.contentConditions;
275
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, row.index !== 0 && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
276
+ onClick: e => {
277
+ e.stopPropagation();
278
+ this.moveCondition(row.index, -1);
279
+ },
280
+ "aria-label": this.props.intl.formatMessage({
281
+ id: '__move_up'
282
+ })
283
+ }, /*#__PURE__*/_react.default.createElement(_ArrowUpward.default, null)), row.index !== String(conditions.length - 1) && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
284
+ onClick: e => {
285
+ e.stopPropagation();
286
+ this.moveCondition(row.index, 1);
287
+ },
288
+ "aria-label": this.props.intl.formatMessage({
289
+ id: '__move_down'
290
+ })
291
+ }, /*#__PURE__*/_react.default.createElement(_ArrowDownward.default, null)), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
292
+ onClick: e => {
293
+ e.stopPropagation();
294
+ this.copyCondition(row);
295
+ },
296
+ "aria-label": this.props.intl.formatMessage({
297
+ id: '__copy'
298
+ })
299
+ }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
300
+ title: this.props.intl.formatMessage({
301
+ id: '__copy'
302
+ })
303
+ }, /*#__PURE__*/_react.default.createElement(_FileCopy.default, null))), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
304
+ onClick: e => {
305
+ e.stopPropagation();
306
+ this.deleteCondition(row.index);
307
+ },
308
+ "aria-label": this.props.intl.formatMessage({
309
+ id: '__delete'
310
+ })
311
+ }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
312
+ title: this.props.intl.formatMessage({
313
+ id: '__delete'
314
+ })
315
+ }, /*#__PURE__*/_react.default.createElement(_Delete.default, null))));
316
+ });
317
+ _defineProperty(this, "updateCondition", change => {
318
+ const {
319
+ conditionIndex,
320
+ tabIndex
321
+ } = this.state;
322
+ const updatedValue = _objectSpread({}, this.props.value);
323
+ const conditions = tabIndex === 1 ? updatedValue.contentConditions : updatedValue.styleConditions;
324
+ if (this.state.advanced) {
325
+ conditions[conditionIndex].condition = change.value;
326
+ } else {
327
+ const split = conditions[conditionIndex].condition.split(/[ ,]+/);
328
+ const segment1 = split[0];
329
+ const segment2 = split.length > 1 ? split[1] : '===';
330
+ const segment3 = split.length > 2 ? split[2] : '0';
331
+ switch (change.stringIndex) {
332
+ case 0:
333
+ conditions[conditionIndex].condition = "".concat(change.value, " ").concat(segment2, " ").concat(segment3);
334
+ break;
335
+ case 1:
336
+ conditions[conditionIndex].condition = "".concat(segment1, " ").concat(change.value, " ").concat(segment3);
337
+ break;
338
+ case 2:
339
+ conditions[conditionIndex].condition = "".concat(segment1, " ").concat(segment2, " ").concat(change.value);
340
+ break;
341
+ default:
342
+ conditions[conditionIndex].condition = "".concat(segment1, " ").concat(segment2, " ").concat(segment3);
343
+ break;
493
344
  }
345
+ }
346
+ this.props.updateValue({
347
+ styleConditions: updatedValue.styleConditions,
348
+ contentConditions: updatedValue.contentConditions
494
349
  });
495
- } else {
496
- styleConditions[this.state.conditionIndex].style = {};
497
- }
498
-
499
- this.props.updateValue({
500
- styleConditions: styleConditions
501
350
  });
502
- }
503
-
504
- updateContent(value) {
505
- var contentConditions = JSON.parse(JSON.stringify(this.props.value.contentConditions));
506
- contentConditions[this.state.conditionIndex].content = value.content;
507
- this.props.updateValue({
508
- contentConditions: contentConditions
351
+ _defineProperty(this, "updateStyleIds", value => {
352
+ const styleConditions = [...this.props.value.styleConditions];
353
+ styleConditions[this.state.conditionIndex].styleIds = value.styleIds;
354
+ this.props.updateValue({
355
+ styleConditions
356
+ });
509
357
  });
510
- }
511
-
512
- addCondition() {
513
- var conditions = JSON.parse(JSON.stringify(this.props.value));
514
- var index = null;
515
-
516
- if (this.state.tabIndex === 0) {
517
- conditions.styleConditions.push({
518
- condition: '1 > 0',
519
- style: {},
520
- styleIds: []
358
+ _defineProperty(this, "updateStyle", value => {
359
+ const styleConditions = [...this.props.value.styleConditions];
360
+ if (Object.keys(value.style).length > 0) {
361
+ styleConditions[this.state.conditionIndex].style = _objectSpread(_objectSpread({}, styleConditions[this.state.conditionIndex].style), value.style);
362
+ Object.keys(styleConditions[this.state.conditionIndex].style).forEach(key => {
363
+ if (styleConditions[this.state.conditionIndex].style[key] === 'delete') {
364
+ delete styleConditions[this.state.conditionIndex].style[key];
365
+ }
366
+ });
367
+ } else {
368
+ styleConditions[this.state.conditionIndex].style = {};
369
+ }
370
+ this.props.updateValue({
371
+ styleConditions
521
372
  });
522
- index = conditions.styleConditions.length - 1;
523
- } else {
524
- conditions.contentConditions.push({
525
- condition: '1 > 0',
526
- content: {
527
- type: 'text',
528
- text: ''
529
- }
373
+ });
374
+ _defineProperty(this, "updateContent", value => {
375
+ const contentConditions = [...this.props.value.contentConditions];
376
+ contentConditions[this.state.conditionIndex].content = value.content;
377
+ this.props.updateValue({
378
+ contentConditions
530
379
  });
531
- index = conditions.contentConditions.length - 1;
532
- }
533
-
534
- this.props.updateValue({
535
- styleConditions: conditions.styleConditions,
536
- contentConditions: conditions.contentConditions
537
380
  });
538
- this.setState({
539
- conditionIndex: index,
540
- advanced: false
381
+ _defineProperty(this, "addCondition", () => {
382
+ const conditions = _objectSpread({}, this.props.value);
383
+ let index = null;
384
+ if (this.state.tabIndex === 0) {
385
+ conditions.styleConditions.push({
386
+ condition: '1 > 0',
387
+ style: {},
388
+ styleIds: []
389
+ });
390
+ index = conditions.styleConditions.length - 1;
391
+ } else {
392
+ conditions.contentConditions.push({
393
+ condition: '1 > 0',
394
+ content: {
395
+ type: 'text',
396
+ text: ''
397
+ }
398
+ });
399
+ index = conditions.contentConditions.length - 1;
400
+ }
401
+ this.props.updateValue({
402
+ styleConditions: conditions.styleConditions,
403
+ contentConditions: conditions.contentConditions
404
+ });
405
+ this.setState({
406
+ conditionIndex: index,
407
+ advanced: false
408
+ });
541
409
  });
542
- }
543
-
544
- copyCondition(condition) {
545
- var newValue = JSON.parse(JSON.stringify(this.props.value));
546
- var newCondition = JSON.parse(JSON.stringify(condition));
547
- delete newCondition.index;
548
- var conditions = newValue[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'];
549
- conditions.push(newCondition);
550
- var advanced = determineIfAdvanced(newCondition.condition);
551
- this.props.updateValue({
552
- styleConditions: newValue.styleConditions,
553
- contentConditions: newValue.contentConditions
410
+ _defineProperty(this, "copyCondition", condition => {
411
+ const newValue = _objectSpread({}, this.props.value);
412
+ const newCondition = _objectSpread({}, condition);
413
+ delete newCondition.index;
414
+ const conditions = newValue[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'];
415
+ conditions.push(newCondition);
416
+ const advanced = determineIfAdvanced(newCondition.condition);
417
+ this.props.updateValue({
418
+ styleConditions: newValue.styleConditions,
419
+ contentConditions: newValue.contentConditions
420
+ });
421
+ this.setState(prevState => ({
422
+ conditionIndex: conditions.length - 1,
423
+ advanced
424
+ }));
554
425
  });
555
- this.setState(prevState => ({
556
- conditionIndex: conditions.length - 1,
557
- advanced: advanced
558
- }));
559
- }
560
-
561
- duplicateCondition(index) {
562
- var value = this.props.value;
563
- var tabIndex = this.state.tabIndex;
564
- var condition = value[tabIndex === 0 ? 'styleConditions' : 'contentConditions'][index];
565
- this.copyCondition(condition);
566
- }
567
-
568
- deleteCondition(index) {
569
- var conditions = JSON.parse(JSON.stringify(this.props.value));
570
- conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index), 1);
571
- this.props.updateValue({
572
- styleConditions: conditions.styleConditions,
573
- contentConditions: conditions.contentConditions
426
+ _defineProperty(this, "duplicateCondition", index => {
427
+ const {
428
+ value
429
+ } = this.props;
430
+ const {
431
+ tabIndex
432
+ } = this.state;
433
+ const condition = value[tabIndex === 0 ? 'styleConditions' : 'contentConditions'][index];
434
+ this.copyCondition(condition);
574
435
  });
575
- this.setState({
576
- conditionIndex: null,
577
- advanced: false
436
+ _defineProperty(this, "deleteCondition", index => {
437
+ const conditions = _objectSpread({}, this.props.value);
438
+ conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index), 1);
439
+ this.props.updateValue({
440
+ styleConditions: conditions.styleConditions,
441
+ contentConditions: conditions.contentConditions
442
+ });
443
+ this.setState({
444
+ conditionIndex: null,
445
+ advanced: false
446
+ });
578
447
  });
579
- }
580
-
581
- moveCondition(index, direction) {
582
- var conditions = JSON.parse(JSON.stringify(this.props.value));
583
-
584
- var _conditions$splice = conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index), 1),
585
- _conditions$splice2 = _slicedToArray(_conditions$splice, 1),
586
- removed = _conditions$splice2[0];
587
-
588
- conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index) + direction, 0, removed);
589
- this.props.updateValue({
590
- styleConditions: conditions.styleConditions,
591
- contentConditions: conditions.contentConditions
448
+ _defineProperty(this, "moveCondition", (index, direction) => {
449
+ const conditions = _objectSpread({}, this.props.value);
450
+ const conditionArray = conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'];
451
+ const [removed] = conditionArray.splice(Number(index), 1);
452
+ conditionArray.splice(Number(index) + direction, 0, removed);
453
+ this.props.updateValue({
454
+ styleConditions: conditions.styleConditions,
455
+ contentConditions: conditions.contentConditions
456
+ });
457
+ this.setState({
458
+ conditionIndex: null,
459
+ advanced: false
460
+ });
592
461
  });
593
- this.setState({
594
- conditionIndex: null,
595
- advanced: false
462
+ _defineProperty(this, "onDragEnd", result => {
463
+ const {
464
+ value
465
+ } = this.props;
466
+ const {
467
+ tabIndex
468
+ } = this.state;
469
+ if (!result.destination) {
470
+ return;
471
+ }
472
+ const items = reorder(tabIndex === 0 ? value.styleConditions : value.contentConditions, result.source.index, result.destination.index);
473
+ const newConditions = _objectSpread({}, value);
474
+ if (tabIndex === 0) {
475
+ newConditions.styleConditions = items;
476
+ } else {
477
+ newConditions.contentConditions = items;
478
+ }
479
+ this.props.updateValue({
480
+ styleConditions: newConditions.styleConditions,
481
+ contentConditions: newConditions.contentConditions
482
+ });
483
+ this.setState({
484
+ conditionIndex: result.destination.index
485
+ });
596
486
  });
597
- }
598
-
599
- onDragEnd(result) {
600
- var value = this.props.value;
601
- var tabIndex = this.state.tabIndex; // dropped outside the list
602
-
603
- if (!result.destination) {
604
- return;
605
- }
606
-
607
- var items = reorder(tabIndex === 0 ? value.styleConditions : value.contentConditions, result.source.index, result.destination.index);
608
-
609
- var newConditions = _objectSpread({}, value);
610
-
611
- if (tabIndex === 0) {
612
- newConditions.styleConditions = items;
613
- } else {
614
- newConditions.contentConditions = items;
615
- }
616
-
617
- this.props.updateValue({
618
- styleConditions: newConditions.styleConditions,
619
- contentConditions: newConditions.contentConditions
620
- }); // NOTE: The current conditionIndex kind of moves after a move...
621
- // This kind of does it but it just selects the moved cell.
622
-
623
- this.setState({
624
- conditionIndex: result.destination.index
487
+ _defineProperty(this, "selectCondition", index => {
488
+ const {
489
+ value
490
+ } = this.props;
491
+ const {
492
+ tabIndex
493
+ } = this.state;
494
+ const conditions = tabIndex === 1 ? value.contentConditions : value.styleConditions;
495
+ const condition = conditions[index];
496
+ const advanced = determineIfAdvanced(condition.condition);
497
+ this.setState({
498
+ conditionIndex: index,
499
+ advanced
500
+ });
625
501
  });
626
- }
627
-
628
- selectCondition(index) {
629
- var value = this.props.value;
630
- var tabIndex = this.state.tabIndex;
631
- var conditions = tabIndex === 1 ? value.contentConditions : value.styleConditions;
632
- var condition = conditions[index];
633
- var advanced = determineIfAdvanced(condition.condition);
634
- this.setState({
635
- conditionIndex: index,
636
- advanced: advanced
502
+ _defineProperty(this, "renderConditionCard", obj => {
503
+ const {
504
+ item,
505
+ handler
506
+ } = obj;
507
+ const {
508
+ classes,
509
+ intl
510
+ } = this.props;
511
+ const {
512
+ tabIndex,
513
+ conditionIndex
514
+ } = this.state;
515
+ const divStyle = {
516
+ border: '1px solid black',
517
+ padding: 10,
518
+ margin: 2,
519
+ display: 'flex',
520
+ alignItems: 'center',
521
+ backgroundColor: item.index === conditionIndex ? '#55b7dc' : '#ffffff'
522
+ };
523
+ return /*#__PURE__*/_react.default.createElement("div", {
524
+ role: "treeitem",
525
+ "aria-selected": item.index === conditionIndex,
526
+ style: divStyle,
527
+ className: classes.selectable,
528
+ onClick: () => this.selectCondition(item.index)
529
+ }, /*#__PURE__*/_react.default.createElement("span", {
530
+ style: {
531
+ marginRight: 20,
532
+ fontWeight: 'bold'
533
+ }
534
+ }, item.index === 0 ? 'IF' : 'ELSE IF'), /*#__PURE__*/_react.default.createElement("span", {
535
+ style: {
536
+ flexGrow: 1
537
+ }
538
+ }, determineIfAdvanced(item.condition) ? item.condition : formatCondition(item.condition)), tabIndex === 0 && this.stylePreviewCustomCell({
539
+ row: item
540
+ }), tabIndex === 1 && item.content && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
541
+ style: {
542
+ marginRight: 10
543
+ }
544
+ }, intl.formatMessage({
545
+ id: "__".concat(item.content.type)
546
+ })), contentPreviewCustomCell({
547
+ row: item
548
+ })), handler, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
549
+ onClick: e => {
550
+ e.stopPropagation();
551
+ this.setState({
552
+ menuIndex: item.index,
553
+ menuAnchorEl: e.currentTarget
554
+ });
555
+ },
556
+ "aria-label": intl.formatMessage({
557
+ id: '__more_options'
558
+ })
559
+ }, /*#__PURE__*/_react.default.createElement(_MoreVert.default, null)));
637
560
  });
638
- }
639
-
640
- renderConditionCard(obj) {
641
- var item = obj.item,
642
- handler = obj.handler;
643
- var _this$props = this.props,
644
- classes = _this$props.classes,
645
- intl = _this$props.intl;
646
- var _this$state2 = this.state,
647
- tabIndex = _this$state2.tabIndex,
648
- conditionIndex = _this$state2.conditionIndex;
649
- var divStyle = {
650
- border: '1px solid black',
651
- padding: 10,
652
- margin: 2,
653
- display: 'flex',
654
- alignItems: 'center',
655
- backgroundColor: item.index === conditionIndex ? '#55b7dc' : '#ffffff'
561
+ this.state = {
562
+ open: false,
563
+ tabIndex: 0,
564
+ conditionIndex: null,
565
+ menuIndex: null,
566
+ menuAnchorEl: null,
567
+ advanced: false
656
568
  };
657
- return /*#__PURE__*/_react.default.createElement("div", {
658
- role: "treeitem",
659
- "aria-hidden": true,
660
- style: divStyle,
661
- className: classes.selectable,
662
- onClick: () => this.selectCondition(item.index)
663
- }, /*#__PURE__*/_react.default.createElement("span", {
664
- style: {
665
- marginRight: 20,
666
- fontWeight: 'bold'
667
- }
668
- }, item.index === 0 ? 'IF' : 'ELSE IF'), /*#__PURE__*/_react.default.createElement("span", {
669
- style: {
670
- flexGrow: 1
671
- }
672
- }, determineIfAdvanced(item.condition) ? item.condition : formatCondition(item.condition)), tabIndex === 0 && this.stylePreviewCustomCell({
673
- row: item
674
- }), tabIndex === 1 && item.content && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
675
- style: {
676
- marginRight: 10
677
- }
678
- }, intl.formatMessage({
679
- id: "__".concat(item.content.type)
680
- })), contentPreviewCustomCell({
681
- row: item
682
- })), handler, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
683
- onClick: e => {
684
- e.stopPropagation();
685
- this.setState({
686
- menuIndex: item.index,
687
- menuAnchorEl: e.target
688
- });
689
- }
690
- }, /*#__PURE__*/_react.default.createElement(_MoreVert.default, null)));
691
569
  }
692
-
693
570
  render() {
694
- var _this$props2 = this.props,
695
- classes = _this$props2.classes,
696
- intl = _this$props2.intl,
697
- value = _this$props2.value,
698
- images = _this$props2.images,
699
- styles = _this$props2.styles,
700
- tags = _this$props2.tags,
701
- widgets = _this$props2.widgets,
702
- variables = _this$props2.variables;
703
- var _this$state3 = this.state,
704
- open = _this$state3.open,
705
- tabIndex = _this$state3.tabIndex,
706
- conditionIndex = _this$state3.conditionIndex,
707
- menuIndex = _this$state3.menuIndex,
708
- menuAnchorEl = _this$state3.menuAnchorEl,
709
- advanced = _this$state3.advanced;
710
- var currentCondition = null;
711
-
571
+ const {
572
+ classes,
573
+ intl,
574
+ value,
575
+ images,
576
+ styles,
577
+ tags,
578
+ widgets,
579
+ variables
580
+ } = this.props;
581
+ const {
582
+ open,
583
+ tabIndex,
584
+ conditionIndex,
585
+ menuIndex,
586
+ menuAnchorEl,
587
+ advanced
588
+ } = this.state;
589
+ let currentCondition = null;
712
590
  if (conditionIndex !== null) {
713
591
  currentCondition = tabIndex === 0 ? value.styleConditions[conditionIndex] : value.contentConditions[conditionIndex];
714
592
  }
715
-
716
- var totalConditions = value.styleConditions.length + value.contentConditions.length;
717
- var nestItems = [];
718
-
593
+ const totalConditions = value.styleConditions.length + value.contentConditions.length;
594
+ const nestItems = [];
719
595
  if (tabIndex === 0) {
720
596
  value.styleConditions.forEach((condition, index) => {
721
597
  nestItems.push(_objectSpread(_objectSpread({}, condition), {}, {
722
- index: index,
598
+ index,
723
599
  id: String(index)
724
600
  }));
725
601
  });
726
602
  } else {
727
603
  value.contentConditions.forEach((condition, index) => {
728
604
  nestItems.push(_objectSpread(_objectSpread({}, condition), {}, {
729
- index: index,
605
+ index,
730
606
  id: String(index)
731
607
  }));
732
608
  });
733
609
  }
734
-
735
610
  return /*#__PURE__*/_react.default.createElement(_Grid.default, {
736
611
  xs: 6,
737
612
  item: true
@@ -775,7 +650,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
775
650
  }, /*#__PURE__*/_react.default.createElement(_Button.default, {
776
651
  variant: "outlined",
777
652
  color: "primary",
778
- onClick: () => this.addCondition(),
653
+ onClick: this.addCondition,
779
654
  style: {
780
655
  marginRight: 10
781
656
  }
@@ -820,7 +695,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
820
695
  style: style.scroll,
821
696
  className: _versacallCoreLibraryReact.ScrollbarStyles.scroll
822
697
  }, /*#__PURE__*/_react.default.createElement(_reactBeautifulDnd.DragDropContext, {
823
- onDragEnd: obj => this.onDragEnd(obj)
698
+ onDragEnd: this.onDragEnd
824
699
  }, /*#__PURE__*/_react.default.createElement(_reactBeautifulDnd.Droppable, {
825
700
  droppableId: "conditions"
826
701
  }, (provided, snapshot) => /*#__PURE__*/_react.default.createElement("div", _extends({}, provided.droppableProps, {
@@ -835,7 +710,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
835
710
  }, dragProvided.draggableProps, {
836
711
  style: getItemStyle(dragSnapshot.isDragging, dragProvided.draggableProps.style)
837
712
  }), this.renderConditionCard({
838
- item: item,
713
+ item,
839
714
  handler: /*#__PURE__*/_react.default.createElement("div", dragProvided.dragHandleProps, /*#__PURE__*/_react.default.createElement(_OpenWith.default, {
840
715
  className: classes.anchor
841
716
  }))
@@ -867,7 +742,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
867
742
  xs: 4,
868
743
  item: true
869
744
  }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
870
- id: "name",
745
+ id: "condition-variable",
871
746
  options: variables,
872
747
  fullWidth: true,
873
748
  value: currentCondition.condition.split(/[ ,]+/)[0],
@@ -894,14 +769,14 @@ class DashboardsCellGlobalConditions extends _react.Component {
894
769
  }),
895
770
  fullWidth: true,
896
771
  select: true
897
- }, operatorOptions.map(operatorOption => /*#__PURE__*/_react.default.createElement("option", {
772
+ }, OPERATOR_OPTIONS.map(operatorOption => /*#__PURE__*/_react.default.createElement("option", {
898
773
  key: operatorOption.value,
899
774
  value: operatorOption.value
900
775
  }, operatorOption.label)))), /*#__PURE__*/_react.default.createElement(_Grid.default, {
901
776
  xs: 3,
902
777
  item: true
903
778
  }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
904
- id: "name",
779
+ id: "condition-value",
905
780
  options: variables,
906
781
  fullWidth: true,
907
782
  value: currentCondition.condition.split(/[ ,]+/)[2],
@@ -917,7 +792,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
917
792
  xs: 9,
918
793
  item: true
919
794
  }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
920
- id: "name",
795
+ id: "advanced-condition",
921
796
  options: variables,
922
797
  label: intl.formatMessage({
923
798
  id: '__advanced'
@@ -1016,19 +891,47 @@ class DashboardsCellGlobalConditions extends _react.Component {
1016
891
  id: "__duplicate"
1017
892
  })))));
1018
893
  }
1019
-
1020
894
  }
1021
-
1022
895
  DashboardsCellGlobalConditions.propTypes = {
1023
- classes: _propTypes.default.shape().isRequired,
1024
- intl: _propTypes.default.shape().isRequired,
1025
- value: _propTypes.default.shape().isRequired,
896
+ classes: _propTypes.default.shape({
897
+ dialog: _propTypes.default.string.isRequired,
898
+ icon: _propTypes.default.string.isRequired,
899
+ anchor: _propTypes.default.string.isRequired,
900
+ selectable: _propTypes.default.string.isRequired,
901
+ menuPaper: _propTypes.default.string.isRequired,
902
+ menuList: _propTypes.default.string.isRequired
903
+ }).isRequired,
904
+ intl: _propTypes.default.shape({
905
+ formatMessage: _propTypes.default.func.isRequired
906
+ }).isRequired,
907
+ value: _propTypes.default.shape({
908
+ styleConditions: _propTypes.default.arrayOf(_propTypes.default.shape({
909
+ condition: _propTypes.default.string.isRequired,
910
+ style: _propTypes.default.object,
911
+ styleIds: _propTypes.default.arrayOf(_propTypes.default.string)
912
+ })).isRequired,
913
+ contentConditions: _propTypes.default.arrayOf(_propTypes.default.shape({
914
+ condition: _propTypes.default.string.isRequired,
915
+ content: _propTypes.default.object
916
+ })).isRequired
917
+ }).isRequired,
1026
918
  updateValue: _propTypes.default.func.isRequired,
1027
- images: _propTypes.default.arrayOf(_propTypes.default.shape()),
1028
- styles: _propTypes.default.arrayOf(_propTypes.default.shape()),
1029
- tags: _propTypes.default.shape(),
1030
- widgets: _propTypes.default.arrayOf(_propTypes.default.shape()),
1031
- variables: _propTypes.default.arrayOf(_propTypes.default.shape())
919
+ images: _propTypes.default.arrayOf(_propTypes.default.shape({
920
+ id: _propTypes.default.string.isRequired,
921
+ fileName: _propTypes.default.string.isRequired
922
+ })),
923
+ styles: _propTypes.default.arrayOf(_propTypes.default.shape({
924
+ id: _propTypes.default.string.isRequired,
925
+ options: _propTypes.default.object
926
+ })),
927
+ tags: _propTypes.default.object,
928
+ widgets: _propTypes.default.arrayOf(_propTypes.default.shape({
929
+ id: _propTypes.default.string.isRequired,
930
+ name: _propTypes.default.string.isRequired
931
+ })),
932
+ variables: _propTypes.default.arrayOf(_propTypes.default.shape({
933
+ name: _propTypes.default.string.isRequired
934
+ }))
1032
935
  };
1033
936
  DashboardsCellGlobalConditions.defaultProps = {
1034
937
  images: [],
@@ -1037,7 +940,4 @@ DashboardsCellGlobalConditions.defaultProps = {
1037
940
  widgets: [],
1038
941
  variables: []
1039
942
  };
1040
-
1041
- var _default = (0, _reactIntl.injectIntl)((0, _styles.withStyles)(muiStyles)(DashboardsCellGlobalConditions));
1042
-
1043
- exports.default = _default;
943
+ var _default = exports.default = (0, _reactIntl.injectIntl)((0, _styles.withStyles)(muiStyles)(DashboardsCellGlobalConditions));