versacall-dashboards-library-react 2.0.39 → 2.0.40

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 (102) hide show
  1. package/package.json +2 -2
  2. package/dist/components/DashboardsCell/DashboardsCell.js +0 -267
  3. package/dist/components/DashboardsCell/index.js +0 -15
  4. package/dist/components/DashboardsCellContent/DashboardsCellContent.js +0 -438
  5. package/dist/components/DashboardsCellContent/index.js +0 -15
  6. package/dist/components/DashboardsCellFindAndReplace/DashboardsCellFindAndReplace.js +0 -190
  7. package/dist/components/DashboardsCellFindAndReplace/index.js +0 -15
  8. package/dist/components/DashboardsCellGlobalActions/DashboardsCellGlobalActions.js +0 -218
  9. package/dist/components/DashboardsCellGlobalActions/index.js +0 -15
  10. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditions.js +0 -1043
  11. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditionsNestable.js +0 -927
  12. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditionsOld.js +0 -816
  13. package/dist/components/DashboardsCellGlobalConditions/index.js +0 -15
  14. package/dist/components/DashboardsCellGlobalStyles/DashboardsCellGlobalStyles.js +0 -394
  15. package/dist/components/DashboardsCellGlobalStyles/index.js +0 -15
  16. package/dist/components/DashboardsCellMergeUnmerge/DashboardsCellMergeUnmerge.js +0 -152
  17. package/dist/components/DashboardsCellMergeUnmerge/index.js +0 -15
  18. package/dist/components/DashboardsCellPosition/DashboardsCellPosition.js +0 -85
  19. package/dist/components/DashboardsCellPosition/index.js +0 -15
  20. package/dist/components/DashboardsCellSize/DashboardsCellSize.js +0 -89
  21. package/dist/components/DashboardsCellSize/index.js +0 -15
  22. package/dist/components/DashboardsCellStyle/DashboardsCellStyle.js +0 -83
  23. package/dist/components/DashboardsCellStyle/index.js +0 -15
  24. package/dist/components/DashboardsCellStyleAlignItems/DashboardsCellStyleAlignItems.js +0 -152
  25. package/dist/components/DashboardsCellStyleAlignItems/index.js +0 -15
  26. package/dist/components/DashboardsCellStyleBackgroundColor/DashboardsCellStyleBackgroundColor.js +0 -198
  27. package/dist/components/DashboardsCellStyleBackgroundColor/index.js +0 -15
  28. package/dist/components/DashboardsCellStyleClear/DashboardsCellStyleClear.js +0 -50
  29. package/dist/components/DashboardsCellStyleClear/index.js +0 -15
  30. package/dist/components/DashboardsCellStyleColor/DashboardsCellStyleColor.js +0 -198
  31. package/dist/components/DashboardsCellStyleColor/index.js +0 -15
  32. package/dist/components/DashboardsCellStyleDisplay/DashboardsCellStyleDisplay.js +0 -65
  33. package/dist/components/DashboardsCellStyleDisplay/index.js +0 -15
  34. package/dist/components/DashboardsCellStyleFontFamily/DashboardsCellStyleFontFamily.js +0 -64
  35. package/dist/components/DashboardsCellStyleFontFamily/index.js +0 -15
  36. package/dist/components/DashboardsCellStyleFontSize/DashboardsCellStyleFontSize.js +0 -89
  37. package/dist/components/DashboardsCellStyleFontSize/index.js +0 -15
  38. package/dist/components/DashboardsCellStyleJustifyContent/DashboardsCellStyleJustifyContent.js +0 -152
  39. package/dist/components/DashboardsCellStyleJustifyContent/index.js +0 -15
  40. package/dist/components/DashboardsCellStyleObjectFit/DashboardsCellStyleObjectFit.js +0 -81
  41. package/dist/components/DashboardsCellStyleObjectFit/index.js +0 -15
  42. package/dist/components/DashboardsCellStylePadding/DashboardsCellStylePadding.js +0 -105
  43. package/dist/components/DashboardsCellStylePadding/index.js +0 -15
  44. package/dist/components/DashboardsCellStyleWeightStyleDecoration/DashboardsCellStyleWeightStyleDecoration.js +0 -154
  45. package/dist/components/DashboardsCellStyleWeightStyleDecoration/index.js +0 -15
  46. package/dist/components/DashboardsCopyAndPaste/DashboardsCopyAndPaste.js +0 -112
  47. package/dist/components/DashboardsCopyAndPaste/index.js +0 -15
  48. package/dist/components/DashboardsEditor/DashboardsEditor.js +0 -415
  49. package/dist/components/DashboardsEditor/index.js +0 -15
  50. package/dist/components/DashboardsGlobalStylesPicker/DashboardsGlobalStylesPicker.js +0 -90
  51. package/dist/components/DashboardsGlobalStylesPicker/index.js +0 -15
  52. package/dist/components/DashboardsGrid/DashboardsGrid.js +0 -139
  53. package/dist/components/DashboardsGrid/index.js +0 -15
  54. package/dist/components/DashboardsMainFreehand/DashboardsMainFreehand.js +0 -466
  55. package/dist/components/DashboardsMainFreehand/index.js +0 -15
  56. package/dist/components/DashboardsMainMessaging/DashboardsMainMessaging.js +0 -628
  57. package/dist/components/DashboardsMainMessaging/index.js +0 -15
  58. package/dist/components/DashboardsMainTable/DashboardsMainTable.js +0 -626
  59. package/dist/components/DashboardsMainTable/index.js +0 -15
  60. package/dist/components/DashboardsPreview/DashboardsPreview.js +0 -113
  61. package/dist/components/DashboardsPreview/index.js +0 -15
  62. package/dist/components/DashboardsRatio/DashboardsRatio.js +0 -288
  63. package/dist/components/DashboardsRatio/DashboardsRatioOld.js +0 -211
  64. package/dist/components/DashboardsRatio/index.js +0 -15
  65. package/dist/components/DashboardsStatusBar/DashboardsStatusBar.css +0 -1
  66. package/dist/components/DashboardsStatusBar/DashboardsStatusBar.js +0 -137
  67. package/dist/components/DashboardsStatusBar/index.js +0 -15
  68. package/dist/components/DashboardsUndoRedo/DashboardsUndoRedo.js +0 -144
  69. package/dist/components/DashboardsUndoRedo/index.js +0 -15
  70. package/dist/components/DashboardsViewer/DashboardsViewer.js +0 -74
  71. package/dist/components/DashboardsViewer/index.js +0 -15
  72. package/dist/components/DashboardsWidthHeight/DashboardsWidthHeight.js +0 -98
  73. package/dist/components/DashboardsWidthHeight/index.js +0 -15
  74. package/dist/components/WidgetParameters/WidgetParameters.js +0 -383
  75. package/dist/components/WidgetParameters/index.js +0 -15
  76. package/dist/components/index.js +0 -287
  77. package/dist/constants/defaultFreehandCell.js +0 -23
  78. package/dist/constants/defaultFreehandDashboard.js +0 -23
  79. package/dist/constants/defaultMessagingDashboard.js +0 -53
  80. package/dist/constants/defaultStyle.js +0 -11
  81. package/dist/constants/defaultTableCell.js +0 -27
  82. package/dist/constants/defaultTableDashboard.js +0 -25
  83. package/dist/constants/index.js +0 -55
  84. package/dist/functions/addTranslations.js +0 -28
  85. package/dist/functions/calculateDashboardVariables.js +0 -146
  86. package/dist/functions/convertColorObject.js +0 -10
  87. package/dist/functions/convertColorString.js +0 -26
  88. package/dist/functions/convertPercentToInt.js +0 -10
  89. package/dist/functions/convertSecondsToElapsedTime.js +0 -37
  90. package/dist/functions/generateFreehandCell.js +0 -24
  91. package/dist/functions/generateFreehandDashboard.js +0 -19
  92. package/dist/functions/generateMessagingDashboard.js +0 -14
  93. package/dist/functions/generateSelected.js +0 -18
  94. package/dist/functions/generateTableCell.js +0 -18
  95. package/dist/functions/generateTableDashboard.js +0 -37
  96. package/dist/functions/index.js +0 -119
  97. package/dist/functions/mergeSelected.js +0 -22
  98. package/dist/functions/sortCells.js +0 -26
  99. package/dist/images/BackgroundTransparency.png +0 -0
  100. package/dist/index.js +0 -44
  101. package/dist/translations/en.json +0 -11
  102. package/dist/translations/es.json +0 -3
@@ -1,927 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _styles = require("@material-ui/core/styles");
13
-
14
- var _CardActionArea = _interopRequireDefault(require("@material-ui/core/CardActionArea"));
15
-
16
- var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
17
-
18
- var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
19
-
20
- var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
21
-
22
- var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
23
-
24
- var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
25
-
26
- var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
27
-
28
- var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));
29
-
30
- var _Tabs = _interopRequireDefault(require("@material-ui/core/Tabs"));
31
-
32
- var _Tab = _interopRequireDefault(require("@material-ui/core/Tab"));
33
-
34
- var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
35
-
36
- var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
37
-
38
- var _SettingsOutlined = _interopRequireDefault(require("@material-ui/icons/SettingsOutlined"));
39
-
40
- var _ArrowDownward = _interopRequireDefault(require("@material-ui/icons/ArrowDownward"));
41
-
42
- var _ArrowUpward = _interopRequireDefault(require("@material-ui/icons/ArrowUpward"));
43
-
44
- var _FileCopy = _interopRequireDefault(require("@material-ui/icons/FileCopy"));
45
-
46
- var _Settings = _interopRequireDefault(require("@material-ui/icons/Settings"));
47
-
48
- var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
49
-
50
- var _Add = _interopRequireDefault(require("@material-ui/icons/Add"));
51
-
52
- var _MoreVert = _interopRequireDefault(require("@material-ui/icons/MoreVert"));
53
-
54
- var _OpenWith = _interopRequireDefault(require("@material-ui/icons/OpenWith"));
55
-
56
- var _reactNestableFork = _interopRequireDefault(require("react-nestable-fork"));
57
-
58
- var _reactIntl = require("react-intl");
59
-
60
- var _versacallCoreLibraryReact = require("versacall-core-library-react");
61
-
62
- var _DashboardsCellGlobalStyles = _interopRequireDefault(require("../DashboardsCellGlobalStyles"));
63
-
64
- var _DashboardsCellContent = _interopRequireDefault(require("../DashboardsCellContent"));
65
-
66
- var _DashboardsCellStyle = _interopRequireDefault(require("../DashboardsCellStyle"));
67
-
68
- var _DashboardsPreview = _interopRequireDefault(require("../DashboardsPreview"));
69
-
70
- var _DashboardsCell = _interopRequireDefault(require("../DashboardsCell"));
71
-
72
- 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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
81
-
82
- 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."); }
83
-
84
- 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); }
85
-
86
- 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; }
87
-
88
- 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; }
89
-
90
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
91
-
92
- 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; }
93
-
94
- 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; }
95
-
96
- 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; }
97
-
98
- var muiStyles = () => ({
99
- dialog: {
100
- backgroundColor: '#eff4f8'
101
- },
102
- icon: {
103
- marginRight: 10
104
- },
105
- anchor: {
106
- marginLeft: 10,
107
- color: 'rgba(0, 0, 0, 0.54)',
108
- '&:hover': {
109
- cursor: 'grab'
110
- }
111
- },
112
- selectable: {
113
- '&:hover': {
114
- cursor: 'pointer'
115
- }
116
- }
117
- });
118
-
119
- var style = {
120
- root: {
121
- position: 'relative',
122
- display: 'flex',
123
- flexFlow: 'column',
124
- height: '76vh',
125
- padding: 16,
126
- paddingBottom: 0,
127
- // backgroundColor: '#e6e6e6',
128
- overflow: 'hidden'
129
- },
130
- fullHeight: {
131
- height: '100%',
132
- overflow: 'hidden'
133
- },
134
- paper: {
135
- // display: 'block',
136
- boxSizing: 'border-box',
137
- padding: 16,
138
- overflow: 'hidden'
139
- },
140
- block: {
141
- display: 'block',
142
- boxSizing: 'border-box'
143
- },
144
- scrollHolder: {
145
- position: 'relative',
146
- height: '100%'
147
- },
148
- scroll: {
149
- position: 'absolute',
150
- // display: 'block',
151
- width: '100%',
152
- maxHeight: '100%',
153
- overflow: 'auto',
154
- overflowY: 'auto'
155
- },
156
- fab: {
157
- position: 'absolute',
158
- right: 22,
159
- bottom: 4
160
- },
161
- styleBox: {
162
- borderStyle: 'solid',
163
- borderWidth: 1,
164
- borderColor: 'rgba(0, 0, 0, 0.23',
165
- borderRadius: 4,
166
- padding: 16,
167
- marginBottom: 16,
168
- marginTop: 16
169
- },
170
- button: {
171
- textAlign: 'center',
172
- textTransform: 'uppercase',
173
- color: 'rgba(0, 0, 0, 0.87)',
174
- padding: '12px 24px',
175
- border: '1px solid rgba(0, 0, 0, 0.23)',
176
- fontSize: '0.9375rem',
177
- borderRadius: '4px'
178
- },
179
- information: {
180
- padding: 16,
181
- textTransform: 'uppercase'
182
- }
183
- };
184
- var operatorOptions = [{
185
- value: '===',
186
- label: '='
187
- }, {
188
- value: '>',
189
- label: '>'
190
- }, {
191
- value: '<',
192
- label: '<'
193
- }, {
194
- value: '!==',
195
- label: "".concat(String.fromCharCode(0x2260))
196
- }, {
197
- value: '>=',
198
- label: "".concat(String.fromCharCode(0x2265))
199
- }, {
200
- value: '<=',
201
- label: "".concat(String.fromCharCode(0x2264))
202
- }];
203
-
204
- var formatCondition = original => {
205
- var formatted = original;
206
- formatted = formatted.replace('===', '=');
207
- formatted = formatted.replace('!==', String.fromCharCode(0x2260));
208
- formatted = formatted.replace('>=', String.fromCharCode(0x2265));
209
- formatted = formatted.replace('<=', String.fromCharCode(0x2264));
210
- formatted = formatted.replace('&&', 'AND');
211
- formatted = formatted.replace('||', 'OR');
212
- return formatted;
213
- };
214
-
215
- var tabStyle = active => ({
216
- // border: active ? '2px solid #008bcc' : '',
217
- color: active ? 'black' : 'white',
218
- backgroundColor: active ? '#55b7dc' : '#496b78' // borderRadius: '3px',
219
-
220
- });
221
-
222
- var contentPreviewCustomCell = ({
223
- row
224
- }) => /*#__PURE__*/_react.default.createElement("div", {
225
- style: {
226
- width: 120
227
- }
228
- }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
229
- width: "120px",
230
- height: "100px",
231
- padding: "10px"
232
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
233
- cell: {
234
- content: row.content,
235
- custom: {
236
- viewWidth: 120,
237
- viewHeight: 100,
238
- style: {}
239
- }
240
- }
241
- })));
242
-
243
- var conditionCustomCell = ({
244
- row
245
- }) => {
246
- var newCondition = row.condition;
247
-
248
- if (newCondition.split(' ').length === 3) {
249
- operatorOptions.forEach(option => {
250
- newCondition = newCondition.replace(new RegExp(option.value, 'g'), option.label);
251
- });
252
- }
253
-
254
- return newCondition;
255
- };
256
-
257
- class DashboardsCellGlobalConditions extends _react.Component {
258
- constructor(props) {
259
- super(props);
260
- this.state = {
261
- open: false,
262
- tabIndex: 0,
263
- conditionIndex: null,
264
- menuIndex: null,
265
- menuAnchorEl: null,
266
- advanced: false,
267
- typeCondition: '',
268
- styleColumns: [{
269
- id: 'condition',
270
- style: {
271
- paddingRight: 0
272
- },
273
- label: props.intl.formatMessage({
274
- id: '__condition'
275
- }),
276
- customCell: custom => conditionCustomCell(custom)
277
- }, {
278
- id: 'preview',
279
- style: {
280
- paddingRight: 0
281
- },
282
- label: props.intl.formatMessage({
283
- id: '__preview'
284
- }),
285
- customCell: custom => this.stylePreviewCustomCell(custom)
286
- }, {
287
- id: 'actions',
288
- style: {
289
- textAlign: 'right'
290
- },
291
- label: props.intl.formatMessage({
292
- id: '__actions'
293
- }),
294
- customCell: custom => this.actionsCustomCell(custom)
295
- }],
296
- conditionColumns: [{
297
- id: 'condition',
298
- style: {
299
- paddingRight: 0
300
- },
301
- label: props.intl.formatMessage({
302
- id: '__condition'
303
- }),
304
- customCell: custom => conditionCustomCell(custom)
305
- }, {
306
- id: 'type',
307
- style: {
308
- paddingRight: 0
309
- },
310
- label: props.intl.formatMessage({
311
- id: '__type'
312
- }),
313
- customCell: custom => this.contentTypeCustomCell(custom)
314
- }, {
315
- id: 'preview',
316
- style: {
317
- paddingRight: 0
318
- },
319
- label: props.intl.formatMessage({
320
- id: '__preview'
321
- }),
322
- customCell: custom => contentPreviewCustomCell(custom)
323
- }, {
324
- id: 'actions',
325
- style: {
326
- textAlign: 'right'
327
- },
328
- label: props.intl.formatMessage({
329
- id: '__actions'
330
- }),
331
- customCell: custom => this.actionsCustomCell(custom)
332
- }]
333
- };
334
- }
335
-
336
- stylePreviewCustomCell({
337
- row
338
- }) {
339
- var _this = this;
340
-
341
- var newCell = JSON.parse(JSON.stringify(row));
342
- newCell.custom = {
343
- viewWidth: 120,
344
- viewHeight: 120,
345
- style: {}
346
- };
347
-
348
- if (this.props.styles.length > 0 && row.styleIds && row.styleIds.length > 0) {
349
- var _loop = function _loop(i) {
350
- var findStyle = _this.props.styles.find(searchStyle => searchStyle.id === newCell.styleIds[i]);
351
-
352
- if (findStyle) {
353
- newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), findStyle.options);
354
- }
355
- };
356
-
357
- for (var i = 0; i < newCell.styleIds.length; i++) {
358
- _loop(i);
359
- }
360
- }
361
-
362
- newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), newCell.style);
363
- return /*#__PURE__*/_react.default.createElement("div", {
364
- style: {
365
- width: 120
366
- }
367
- }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
368
- width: "120px",
369
- height: "100px",
370
- padding: "10px"
371
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
372
- cell: {
373
- content: {
374
- type: 'text',
375
- text: 'Hello'
376
- },
377
- custom: newCell.custom
378
- }
379
- })));
380
- }
381
-
382
- contentTypeCustomCell({
383
- row
384
- }) {
385
- return /*#__PURE__*/_react.default.createElement("span", null, this.props.intl.formatMessage({
386
- id: "__".concat(row.content.type)
387
- }));
388
- }
389
-
390
- actionsCustomCell({
391
- row
392
- }) {
393
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, row.index !== '0' && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
394
- onClick: e => {
395
- e.stopPropagation();
396
- this.moveCondition(row.index, -1);
397
- }
398
- }, /*#__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, {
399
- onClick: e => {
400
- e.stopPropagation();
401
- this.moveCondition(row.index, 1);
402
- }
403
- }, /*#__PURE__*/_react.default.createElement(_ArrowDownward.default, null)), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
404
- onClick: e => {
405
- e.stopPropagation();
406
- this.copyCondition(row);
407
- }
408
- }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
409
- title: this.props.intl.formatMessage({
410
- id: '__copy'
411
- })
412
- }, /*#__PURE__*/_react.default.createElement(_FileCopy.default, null))), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
413
- onClick: e => {
414
- e.stopPropagation();
415
- this.deleteCondition(row.index);
416
- }
417
- }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
418
- title: this.props.intl.formatMessage({
419
- id: '__delete'
420
- })
421
- }, /*#__PURE__*/_react.default.createElement(_Delete.default, null))));
422
- }
423
-
424
- updateCondition(change) {
425
- var conditions = JSON.parse(JSON.stringify(this.props.value["".concat(this.state.typeCondition, "Conditions")]));
426
-
427
- if (this.state.advanced) {
428
- conditions[this.state.conditionIndex].condition = change.value;
429
- } else {
430
- var split = conditions[this.state.conditionIndex].condition.split(/[ ,]+/);
431
-
432
- switch (change.stringIndex) {
433
- case 0:
434
- conditions[this.state.conditionIndex].condition = "".concat(change.value, " ").concat(split[1], " ").concat(split[2]);
435
- break;
436
-
437
- case 1:
438
- conditions[this.state.conditionIndex].condition = "".concat(split[0], " ").concat(change.value, " ").concat(split[2]);
439
- break;
440
-
441
- case 2:
442
- conditions[this.state.conditionIndex].condition = "".concat(split[0], " ").concat(split[1], " ").concat(change.value);
443
- break;
444
-
445
- default:
446
- conditions[this.state.conditionIndex].condition = '1 > 0';
447
- break;
448
- }
449
- }
450
-
451
- this.props.updateValue({
452
- ["".concat(this.state.typeCondition, "Conditions")]: conditions
453
- });
454
- }
455
-
456
- updateStyleIds(value) {
457
- var styleConditions = JSON.parse(JSON.stringify(this.props.value.styleConditions));
458
- styleConditions[this.state.conditionIndex].styleIds = value.styleIds;
459
- this.props.updateValue({
460
- styleConditions: styleConditions
461
- });
462
- }
463
-
464
- updateStyle(value) {
465
- var styleConditions = JSON.parse(JSON.stringify(this.props.value.styleConditions));
466
-
467
- if (Object.keys(value.style).length > 0) {
468
- styleConditions[this.state.conditionIndex].style = _objectSpread(_objectSpread({}, styleConditions[this.state.conditionIndex].style), value.style);
469
- Object.keys(styleConditions[this.state.conditionIndex].style).forEach(key => {
470
- if (styleConditions[this.state.conditionIndex].style[key] === 'delete') {
471
- delete styleConditions[this.state.conditionIndex].style[key];
472
- }
473
- });
474
- } else {
475
- styleConditions[this.state.conditionIndex].style = {};
476
- }
477
-
478
- this.props.updateValue({
479
- styleConditions: styleConditions
480
- });
481
- }
482
-
483
- updateContent(value) {
484
- var contentConditions = JSON.parse(JSON.stringify(this.props.value.contentConditions));
485
- contentConditions[this.state.conditionIndex].content = value.content;
486
- this.props.updateValue({
487
- contentConditions: contentConditions
488
- });
489
- }
490
-
491
- addCondition() {
492
- var conditions = JSON.parse(JSON.stringify(this.props.value));
493
- var typeCondition = '';
494
- var index = null;
495
-
496
- if (this.state.tabIndex === 0) {
497
- conditions.styleConditions.push({
498
- condition: '1 > 0',
499
- style: {},
500
- styleIds: []
501
- });
502
- index = conditions.styleConditions.length - 1;
503
- typeCondition = 'style';
504
- } else {
505
- conditions.contentConditions.push({
506
- condition: '1 > 0',
507
- content: {
508
- type: 'text',
509
- text: ''
510
- }
511
- });
512
- index = conditions.contentConditions.length - 1;
513
- typeCondition = 'content';
514
- }
515
-
516
- this.props.updateValue({
517
- styleConditions: conditions.styleConditions,
518
- contentConditions: conditions.contentConditions
519
- });
520
- this.setState({
521
- conditionIndex: index,
522
- advanced: false,
523
- typeCondition: typeCondition
524
- });
525
- }
526
-
527
- copyCondition(condition) {
528
- var conditions = JSON.parse(JSON.stringify(this.props.value));
529
- var newCondition = JSON.parse(JSON.stringify(condition));
530
- delete newCondition.index;
531
- conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].push(newCondition);
532
- this.props.updateValue({
533
- styleConditions: conditions.styleConditions,
534
- contentConditions: conditions.contentConditions
535
- });
536
- this.setState(prevState => ({
537
- conditionIndex: "".concat(conditions[prevState.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].length),
538
- advanced: false
539
- }));
540
- }
541
-
542
- deleteCondition(index) {
543
- var conditions = JSON.parse(JSON.stringify(this.props.value));
544
- conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index), 1);
545
- this.props.updateValue({
546
- styleConditions: conditions.styleConditions,
547
- contentConditions: conditions.contentConditions
548
- });
549
- this.setState({
550
- conditionIndex: null,
551
- advanced: false
552
- });
553
- }
554
-
555
- moveCondition(index, direction) {
556
- var conditions = JSON.parse(JSON.stringify(this.props.value));
557
-
558
- var _conditions$splice = conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index), 1),
559
- _conditions$splice2 = _slicedToArray(_conditions$splice, 1),
560
- removed = _conditions$splice2[0];
561
-
562
- conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index) + direction, 0, removed);
563
- this.props.updateValue({
564
- styleConditions: conditions.styleConditions,
565
- contentConditions: conditions.contentConditions
566
- });
567
- this.setState({
568
- conditionIndex: null,
569
- advanced: false
570
- });
571
- }
572
-
573
- renderConditionCard(obj) {
574
- var item = obj.item,
575
- handler = obj.handler;
576
- var _this$props = this.props,
577
- classes = _this$props.classes,
578
- intl = _this$props.intl;
579
- var _this$state = this.state,
580
- tabIndex = _this$state.tabIndex,
581
- conditionIndex = _this$state.conditionIndex;
582
- var divStyle = {
583
- border: '1px solid black',
584
- padding: 10,
585
- margin: 2,
586
- display: 'flex',
587
- alignItems: 'center',
588
- backgroundColor: item.index === conditionIndex ? '#55b7dc' : '#ffffff'
589
- };
590
- return /*#__PURE__*/_react.default.createElement("div", {
591
- role: "treeitem",
592
- "aria-hidden": true,
593
- style: divStyle,
594
- className: classes.selectable,
595
- onClick: () => this.setState({
596
- conditionIndex: item.index
597
- })
598
- }, /*#__PURE__*/_react.default.createElement("span", {
599
- style: {
600
- marginRight: 10
601
- }
602
- }, item.index === 0 ? 'IF' : 'ELSE IF'), /*#__PURE__*/_react.default.createElement("span", {
603
- style: {
604
- flexGrow: 1
605
- }
606
- }, formatCondition(item.condition)), tabIndex === 0 && this.stylePreviewCustomCell({
607
- row: item
608
- }), tabIndex === 1 && item.content && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, intl.formatMessage({
609
- id: "__".concat(item.content.type)
610
- })), handler, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
611
- onClick: e => {
612
- e.stopPropagation();
613
- this.setState({
614
- menuIndex: item.index,
615
- menuAnchorEl: e.target
616
- });
617
- }
618
- }, /*#__PURE__*/_react.default.createElement(_MoreVert.default, null)));
619
- }
620
-
621
- renderConditionProperties() {
622
- var conditionIndex = this.state.conditionIndex;
623
- return /*#__PURE__*/_react.default.createElement(_Paper.default, null, "Properties go here");
624
- }
625
-
626
- render() {
627
- var _this$props2 = this.props,
628
- classes = _this$props2.classes,
629
- intl = _this$props2.intl,
630
- value = _this$props2.value,
631
- images = _this$props2.images,
632
- styles = _this$props2.styles,
633
- widgets = _this$props2.widgets,
634
- variables = _this$props2.variables;
635
- var _this$state2 = this.state,
636
- open = _this$state2.open,
637
- tabIndex = _this$state2.tabIndex,
638
- conditionIndex = _this$state2.conditionIndex,
639
- menuIndex = _this$state2.menuIndex,
640
- menuAnchorEl = _this$state2.menuAnchorEl,
641
- advanced = _this$state2.advanced,
642
- styleColumns = _this$state2.styleColumns,
643
- conditionColumns = _this$state2.conditionColumns;
644
- var currentCondition = null;
645
-
646
- if (conditionIndex !== null) {
647
- currentCondition = tabIndex === 0 ? value.styleConditions[conditionIndex] : value.contentConditions[conditionIndex];
648
- }
649
-
650
- var totalConditions = value.styleConditions.length + value.contentConditions.length;
651
- var nestItems = [];
652
-
653
- if (tabIndex === 0) {
654
- value.styleConditions.forEach((condition, index) => {
655
- nestItems.push(_objectSpread(_objectSpread({}, condition), {}, {
656
- index: index
657
- }));
658
- });
659
- } else {
660
- value.contentConditions.forEach((condition, index) => {
661
- nestItems.push(_objectSpread(_objectSpread({}, condition), {}, {
662
- index: index
663
- }));
664
- });
665
- }
666
-
667
- return /*#__PURE__*/_react.default.createElement(_Grid.default, {
668
- xs: 6,
669
- item: true
670
- }, /*#__PURE__*/_react.default.createElement(_CardActionArea.default, {
671
- onClick: () => this.setState({
672
- open: true
673
- })
674
- }, /*#__PURE__*/_react.default.createElement("div", {
675
- style: style.button
676
- }, "".concat(intl.formatMessage({
677
- id: '__conditions'
678
- })).concat(totalConditions > 0 ? " (".concat(totalConditions, ")") : '')), totalConditions > 0 && /*#__PURE__*/_react.default.createElement("div", {
679
- style: style.information
680
- }, value.styleConditions.length > 0 && /*#__PURE__*/_react.default.createElement("div", null, "".concat(intl.formatMessage({
681
- id: '__style'
682
- }), ": ").concat(value.styleConditions.length)), value.contentConditions.length > 0 && /*#__PURE__*/_react.default.createElement("div", null, "".concat(intl.formatMessage({
683
- id: '__content'
684
- }), ": ").concat(value.contentConditions.length)))), open && /*#__PURE__*/_react.default.createElement(_Dialog.default, {
685
- maxWidth: "xl",
686
- onClose: () => this.setState({
687
- open: false,
688
- conditionIndex: null,
689
- advanced: false
690
- }),
691
- fullWidth: true,
692
- open: true,
693
- classes: {
694
- paper: classes.dialog
695
- }
696
- }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreToolbar, {
697
- title: intl.formatMessage({
698
- id: '__conditions_editor'
699
- }),
700
- handleClose: () => this.setState({
701
- open: false,
702
- conditionIndex: null,
703
- advanced: false
704
- })
705
- }, /*#__PURE__*/_react.default.createElement(_Button.default, {
706
- variant: "outlined",
707
- color: "primary",
708
- onClick: () => this.addCondition(),
709
- style: {
710
- marginRight: 10
711
- }
712
- }, /*#__PURE__*/_react.default.createElement(_Add.default, {
713
- className: classes.icon
714
- }), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
715
- id: "__add_condition"
716
- })), /*#__PURE__*/_react.default.createElement(_Tabs.default, {
717
- value: tabIndex,
718
- onChange: (event, index) => this.setState({
719
- tabIndex: index,
720
- conditionIndex: null,
721
- advanced: false
722
- }),
723
- centered: true
724
- }, /*#__PURE__*/_react.default.createElement(_Tab.default, {
725
- id: "style",
726
- label: "".concat(intl.formatMessage({
727
- id: '__style'
728
- }), " (").concat(value.styleConditions.length, ")"),
729
- style: tabStyle(tabIndex === 0)
730
- }), /*#__PURE__*/_react.default.createElement(_Tab.default, {
731
- id: "content",
732
- label: "".concat(intl.formatMessage({
733
- id: '__content'
734
- }), " (").concat(value.contentConditions.length, ")"),
735
- style: tabStyle(tabIndex === 1)
736
- }))), /*#__PURE__*/_react.default.createElement("div", {
737
- style: style.root
738
- }, /*#__PURE__*/_react.default.createElement(_Grid.default, {
739
- spacing: 2,
740
- style: style.fullHeight,
741
- container: true
742
- }, /*#__PURE__*/_react.default.createElement(_Grid.default, {
743
- xs: 7,
744
- item: true
745
- }, /*#__PURE__*/_react.default.createElement("div", {
746
- style: _objectSpread(_objectSpread({}, style.paper), style.fullHeight)
747
- }, /*#__PURE__*/_react.default.createElement("div", {
748
- style: _objectSpread(_objectSpread({}, style.block), style.scrollHolder)
749
- }, /*#__PURE__*/_react.default.createElement("div", {
750
- style: style.scroll,
751
- className: _versacallCoreLibraryReact.ScrollbarStyles.scroll
752
- }, /*#__PURE__*/_react.default.createElement(_reactNestableFork.default, {
753
- group: "conditions",
754
- items: nestItems,
755
- renderItem: obj => this.renderConditionCard(obj),
756
- handler: /*#__PURE__*/_react.default.createElement(_OpenWith.default, {
757
- className: classes.anchor
758
- })
759
- }))))), /*#__PURE__*/_react.default.createElement(_Grid.default, {
760
- xs: 5,
761
- item: true
762
- }, /*#__PURE__*/_react.default.createElement("div", {
763
- style: _objectSpread(_objectSpread({}, style.paper), style.fullHeight)
764
- }, /*#__PURE__*/_react.default.createElement("div", {
765
- style: _objectSpread(_objectSpread({}, style.block), style.scrollHolder)
766
- }, currentCondition && /*#__PURE__*/_react.default.createElement(_Paper.default, {
767
- style: style.scroll,
768
- className: _versacallCoreLibraryReact.ScrollbarStyles.scroll
769
- }, /*#__PURE__*/_react.default.createElement("div", {
770
- style: {
771
- padding: 10
772
- }
773
- }, /*#__PURE__*/_react.default.createElement(_Grid.default, {
774
- spacing: 2,
775
- container: true
776
- }, /*#__PURE__*/_react.default.createElement(_Grid.default, {
777
- item: true,
778
- xs: 1,
779
- style: {
780
- paddingTop: 26,
781
- textAlign: 'center'
782
- }
783
- }, "IF"), !advanced && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Grid.default, {
784
- xs: 4,
785
- item: true
786
- }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
787
- id: "name",
788
- options: variables,
789
- fullWidth: true,
790
- value: currentCondition.condition.split(/[ ,]+/)[0],
791
- updateValue: e => this.updateCondition({
792
- value: e,
793
- stringIndex: 0
794
- }),
795
- selectOption: e => this.updateCondition({
796
- value: "~".concat(e.name),
797
- stringIndex: 0
798
- })
799
- })), /*#__PURE__*/_react.default.createElement(_Grid.default, {
800
- xs: 2,
801
- item: true
802
- }, /*#__PURE__*/_react.default.createElement(_TextField.default, {
803
- variant: "outlined",
804
- SelectProps: {
805
- native: true
806
- },
807
- value: currentCondition.condition.split(/[ ,]+/)[1],
808
- onChange: e => this.updateCondition({
809
- value: e.target.value,
810
- stringIndex: 1
811
- }),
812
- fullWidth: true,
813
- select: true
814
- }, operatorOptions.map(operatorOption => /*#__PURE__*/_react.default.createElement("option", {
815
- key: operatorOption.value,
816
- value: operatorOption.value
817
- }, operatorOption.label)))), /*#__PURE__*/_react.default.createElement(_Grid.default, {
818
- xs: 4,
819
- item: true
820
- }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
821
- id: "name",
822
- options: variables,
823
- fullWidth: true,
824
- value: currentCondition.condition.split(/[ ,]+/)[2],
825
- updateValue: e => this.updateCondition({
826
- value: e,
827
- stringIndex: 2
828
- }),
829
- selectOption: e => this.updateCondition({
830
- value: "~".concat(e.name),
831
- stringIndex: 2
832
- })
833
- }))), advanced && /*#__PURE__*/_react.default.createElement(_Grid.default, {
834
- xs: 10,
835
- item: true
836
- }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
837
- id: "name",
838
- options: variables,
839
- label: intl.formatMessage({
840
- id: '__advanced'
841
- }),
842
- fullWidth: true,
843
- value: currentCondition.condition,
844
- updateValue: e => this.updateCondition({
845
- value: e
846
- }),
847
- selectOption: e => this.updateCondition({
848
- value: "~".concat(e.name)
849
- })
850
- })), /*#__PURE__*/_react.default.createElement(_Grid.default, {
851
- align: "center",
852
- xs: 1,
853
- item: true
854
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
855
- style: {
856
- marginTop: 6
857
- },
858
- onClick: () => this.setState({
859
- advanced: !advanced
860
- })
861
- }, advanced ? /*#__PURE__*/_react.default.createElement(_Settings.default, null) : /*#__PURE__*/_react.default.createElement(_SettingsOutlined.default, null)))), tabIndex === 0 && currentCondition && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
862
- style: style.styleBox
863
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCellStyle.default, {
864
- style: currentCondition.style,
865
- updateStyle: content => this.updateStyle(content)
866
- })), /*#__PURE__*/_react.default.createElement(_Grid.default, {
867
- spacing: 2,
868
- container: true
869
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCellGlobalStyles.default, {
870
- styles: styles,
871
- value: currentCondition.styleIds,
872
- updateValue: content => this.updateStyleIds(content)
873
- }))), tabIndex === 1 && currentCondition && /*#__PURE__*/_react.default.createElement(_Grid.default, {
874
- spacing: 2,
875
- style: {
876
- marginTop: 8
877
- },
878
- container: true
879
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCellContent.default, {
880
- images: images,
881
- widgets: widgets,
882
- variables: variables,
883
- value: currentCondition.content,
884
- updateValue: content => this.updateContent(content)
885
- }))))))))), /*#__PURE__*/_react.default.createElement(_Menu.default, {
886
- id: "condition-action-menu",
887
- open: Boolean(menuAnchorEl),
888
- anchorEl: menuAnchorEl,
889
- onClose: () => this.setState({
890
- menuIndex: null,
891
- menuAnchorEl: null
892
- })
893
- }, /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
894
- onClick: () => {
895
- this.deleteCondition(menuIndex);
896
- this.setState({
897
- menuIndex: null,
898
- menuAnchorEl: null
899
- });
900
- }
901
- }, /*#__PURE__*/_react.default.createElement(_Delete.default, null), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
902
- id: "__delete"
903
- })))));
904
- }
905
-
906
- }
907
-
908
- DashboardsCellGlobalConditions.propTypes = {
909
- classes: _propTypes.default.shape().isRequired,
910
- intl: _propTypes.default.shape().isRequired,
911
- value: _propTypes.default.shape().isRequired,
912
- updateValue: _propTypes.default.func.isRequired,
913
- images: _propTypes.default.arrayOf(_propTypes.default.shape()),
914
- styles: _propTypes.default.arrayOf(_propTypes.default.shape()),
915
- widgets: _propTypes.default.arrayOf(_propTypes.default.shape()),
916
- variables: _propTypes.default.arrayOf(_propTypes.default.shape())
917
- };
918
- DashboardsCellGlobalConditions.defaultProps = {
919
- images: [],
920
- styles: [],
921
- widgets: [],
922
- variables: []
923
- };
924
-
925
- var _default = (0, _reactIntl.injectIntl)((0, _styles.withStyles)(muiStyles)(DashboardsCellGlobalConditions));
926
-
927
- exports.default = _default;