@atlaskit/task-decision 17.5.8 → 17.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/analytics/index.js +0 -2
- package/dist/cjs/api/TaskDecisionResource.js +11 -71
- package/dist/cjs/api/TaskDecisionUtils.js +6 -19
- package/dist/cjs/components/DecisionItem.js +6 -15
- package/dist/cjs/components/DecisionList.js +4 -24
- package/dist/cjs/components/Item.js +11 -38
- package/dist/cjs/components/ResourcedTaskItem.js +20 -52
- package/dist/cjs/components/TaskItem.js +14 -36
- package/dist/cjs/components/TaskList.js +6 -28
- package/dist/cjs/components/listStyle.js +0 -2
- package/dist/cjs/index.js +0 -8
- package/dist/cjs/type-helpers.js +2 -12
- package/dist/cjs/types.js +0 -4
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/api/TaskDecisionResource.js +15 -75
- package/dist/es2019/api/TaskDecisionUtils.js +0 -1
- package/dist/es2019/components/DecisionItem.js +1 -3
- package/dist/es2019/components/DecisionList.js +4 -5
- package/dist/es2019/components/Item.js +1 -12
- package/dist/es2019/components/ResourcedTaskItem.js +7 -22
- package/dist/es2019/components/TaskItem.js +3 -8
- package/dist/es2019/components/TaskList.js +3 -5
- package/dist/es2019/types.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/api/TaskDecisionResource.js +11 -74
- package/dist/esm/api/TaskDecisionUtils.js +6 -12
- package/dist/esm/components/DecisionItem.js +6 -8
- package/dist/esm/components/DecisionList.js +5 -15
- package/dist/esm/components/Item.js +12 -28
- package/dist/esm/components/ResourcedTaskItem.js +20 -46
- package/dist/esm/components/TaskItem.js +14 -21
- package/dist/esm/components/TaskList.js +6 -17
- package/dist/esm/type-helpers.js +2 -2
- package/dist/esm/types.js +1 -1
- package/dist/esm/version.json +1 -1
- package/package.json +2 -2
package/dist/es2019/types.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* Same as PubSub client types (don't want a direct dep though)
|
|
12
12
|
*/
|
|
13
|
-
export let PubSubSpecialEventType;
|
|
14
13
|
|
|
14
|
+
export let PubSubSpecialEventType;
|
|
15
15
|
(function (PubSubSpecialEventType) {
|
|
16
16
|
PubSubSpecialEventType["ERROR"] = "ERROR";
|
|
17
17
|
PubSubSpecialEventType["CONNECTED"] = "CONNECTED";
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
|
|
5
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
6
|
import uuid from 'uuid';
|
|
10
7
|
import { utils } from '@atlaskit/util-service-support';
|
|
11
8
|
import { convertServiceTaskToTask, convertServiceTaskStateToBaseItem, findIndex } from './TaskDecisionUtils';
|
|
@@ -25,54 +22,43 @@ export var ACTION_DECISION_FPS_EVENTS = 'avi:task-decision-service:*:*';
|
|
|
25
22
|
export var RecentUpdates = /*#__PURE__*/function () {
|
|
26
23
|
function RecentUpdates(pubSubClient) {
|
|
27
24
|
var _this = this;
|
|
28
|
-
|
|
29
25
|
_classCallCheck(this, RecentUpdates);
|
|
30
|
-
|
|
31
26
|
_defineProperty(this, "idsByContainer", new Map());
|
|
32
|
-
|
|
33
27
|
_defineProperty(this, "listenersById", new Map());
|
|
34
|
-
|
|
35
28
|
_defineProperty(this, "onPubSubEvent", function (_event, payload) {
|
|
36
29
|
var objectAri = payload.objectAri;
|
|
37
|
-
|
|
38
30
|
_this.notify({
|
|
39
31
|
objectAri: objectAri
|
|
40
32
|
});
|
|
41
33
|
});
|
|
42
|
-
|
|
43
34
|
this.pubSubClient = pubSubClient;
|
|
44
35
|
this.subscribeToPubSubEvents();
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
_createClass(RecentUpdates, [{
|
|
48
38
|
key: "subscribe",
|
|
49
39
|
value: function subscribe(objectAri, recentUpdatesListener) {
|
|
50
40
|
var id = uuid();
|
|
51
41
|
var containerIds = this.idsByContainer.get(objectAri);
|
|
52
|
-
|
|
53
42
|
if (!containerIds) {
|
|
54
43
|
containerIds = [];
|
|
55
44
|
this.idsByContainer.set(objectAri, containerIds);
|
|
56
45
|
}
|
|
57
|
-
|
|
58
46
|
containerIds.push(id);
|
|
59
47
|
this.listenersById.set(id, {
|
|
60
48
|
listener: recentUpdatesListener,
|
|
61
49
|
objectAri: objectAri
|
|
62
|
-
});
|
|
63
|
-
|
|
50
|
+
});
|
|
51
|
+
// Notify of id
|
|
64
52
|
recentUpdatesListener.id(id);
|
|
65
53
|
}
|
|
66
54
|
}, {
|
|
67
55
|
key: "unsubscribe",
|
|
68
56
|
value: function unsubscribe(unsubscribeId) {
|
|
69
57
|
var listenerDetail = this.listenersById.get(unsubscribeId);
|
|
70
|
-
|
|
71
58
|
if (listenerDetail) {
|
|
72
59
|
this.listenersById.delete(unsubscribeId);
|
|
73
60
|
var objectAri = listenerDetail.objectAri;
|
|
74
61
|
var idsToFilter = this.idsByContainer.get(objectAri);
|
|
75
|
-
|
|
76
62
|
if (idsToFilter) {
|
|
77
63
|
this.idsByContainer.set(objectAri, idsToFilter.filter(function (id) {
|
|
78
64
|
return id !== unsubscribeId;
|
|
@@ -84,14 +70,11 @@ export var RecentUpdates = /*#__PURE__*/function () {
|
|
|
84
70
|
key: "notify",
|
|
85
71
|
value: function notify(recentUpdateContext) {
|
|
86
72
|
var _this2 = this;
|
|
87
|
-
|
|
88
73
|
var objectAri = recentUpdateContext.objectAri;
|
|
89
74
|
var subscriberIds = this.idsByContainer.get(objectAri);
|
|
90
|
-
|
|
91
75
|
if (subscriberIds) {
|
|
92
76
|
subscriberIds.forEach(function (subscriberId) {
|
|
93
77
|
var listenerDetail = _this2.listenersById.get(subscriberId);
|
|
94
|
-
|
|
95
78
|
if (listenerDetail) {
|
|
96
79
|
var listener = listenerDetail.listener;
|
|
97
80
|
listener.recentUpdates(recentUpdateContext);
|
|
@@ -119,68 +102,49 @@ export var RecentUpdates = /*#__PURE__*/function () {
|
|
|
119
102
|
}
|
|
120
103
|
}
|
|
121
104
|
}]);
|
|
122
|
-
|
|
123
105
|
return RecentUpdates;
|
|
124
106
|
}();
|
|
125
107
|
export var ItemStateManager = /*#__PURE__*/function () {
|
|
126
108
|
function ItemStateManager(serviceConfig) {
|
|
127
109
|
var _this3 = this;
|
|
128
|
-
|
|
129
110
|
_classCallCheck(this, ItemStateManager);
|
|
130
|
-
|
|
131
111
|
_defineProperty(this, "debouncedTaskStateQuery", null);
|
|
132
|
-
|
|
133
112
|
_defineProperty(this, "debouncedTaskToggle", new Map());
|
|
134
|
-
|
|
135
113
|
_defineProperty(this, "subscribers", new Map());
|
|
136
|
-
|
|
137
114
|
_defineProperty(this, "trackedObjectKeys", new Map());
|
|
138
|
-
|
|
139
115
|
_defineProperty(this, "cachedItems", new Map());
|
|
140
|
-
|
|
141
116
|
_defineProperty(this, "batchedKeys", new Map());
|
|
142
|
-
|
|
143
117
|
_defineProperty(this, "onTaskUpdatedEvent", function (_event, payload) {
|
|
144
118
|
var objectAri = payload.objectAri,
|
|
145
|
-
|
|
119
|
+
localId = payload.localId;
|
|
146
120
|
var objectKey = {
|
|
147
121
|
objectAri: objectAri,
|
|
148
122
|
localId: localId
|
|
149
123
|
};
|
|
150
|
-
|
|
151
124
|
var cached = _this3.getCached(objectKey);
|
|
152
|
-
|
|
153
125
|
if (!cached) {
|
|
154
126
|
// ignore unknown task
|
|
155
127
|
return;
|
|
156
128
|
}
|
|
157
|
-
|
|
158
129
|
var lastUpdateDate = new Date(payload.lastUpdateDate);
|
|
159
|
-
|
|
160
130
|
if (lastUpdateDate > cached.lastUpdateDate) {
|
|
161
131
|
_this3.updateCache(convertServiceTaskStateToBaseItem(payload));
|
|
162
|
-
|
|
163
132
|
_this3.notifyUpdated(objectKey, payload.state);
|
|
164
|
-
|
|
165
133
|
return;
|
|
166
134
|
}
|
|
167
135
|
});
|
|
168
|
-
|
|
169
136
|
_defineProperty(this, "onReconnect", function () {
|
|
170
137
|
_this3.refreshAllTasks();
|
|
171
138
|
});
|
|
172
|
-
|
|
173
139
|
this.serviceConfig = serviceConfig;
|
|
174
140
|
this.subscribeToPubSubEvents();
|
|
175
141
|
}
|
|
176
|
-
|
|
177
142
|
_createClass(ItemStateManager, [{
|
|
178
143
|
key: "destroy",
|
|
179
144
|
value: function destroy() {
|
|
180
145
|
if (this.debouncedTaskStateQuery) {
|
|
181
146
|
clearTimeout(this.debouncedTaskStateQuery);
|
|
182
147
|
}
|
|
183
|
-
|
|
184
148
|
this.debouncedTaskToggle.forEach(function (timeout) {
|
|
185
149
|
clearTimeout(timeout);
|
|
186
150
|
});
|
|
@@ -190,22 +154,21 @@ export var ItemStateManager = /*#__PURE__*/function () {
|
|
|
190
154
|
key: "toggleTask",
|
|
191
155
|
value: function toggleTask(objectKey, state) {
|
|
192
156
|
var _this4 = this;
|
|
193
|
-
|
|
194
157
|
var stringKey = objectKeyToString(objectKey);
|
|
195
158
|
var timeout = this.debouncedTaskToggle.get(stringKey);
|
|
196
|
-
|
|
197
159
|
if (timeout) {
|
|
198
160
|
clearTimeout(timeout);
|
|
199
161
|
this.debouncedTaskToggle.delete(stringKey);
|
|
200
|
-
}
|
|
201
|
-
|
|
162
|
+
}
|
|
202
163
|
|
|
164
|
+
// Update cache optimistically
|
|
203
165
|
this.updateCache(_objectSpread(_objectSpread({}, objectKey), {}, {
|
|
204
166
|
lastUpdateDate: new Date(),
|
|
205
167
|
type: 'TASK',
|
|
206
168
|
state: state
|
|
207
|
-
}));
|
|
169
|
+
}));
|
|
208
170
|
|
|
171
|
+
// Optimistically notify subscribers that the task have been updated so that they can re-render accordingly
|
|
209
172
|
this.notifyUpdated(objectKey, state);
|
|
210
173
|
return new Promise(function (resolve, reject) {
|
|
211
174
|
_this4.debouncedTaskToggle.set(stringKey, window.setTimeout(function () {
|
|
@@ -223,22 +186,18 @@ export var ItemStateManager = /*#__PURE__*/function () {
|
|
|
223
186
|
};
|
|
224
187
|
utils.requestService(_this4.serviceConfig, options).then(convertServiceTaskToTask).then(function (task) {
|
|
225
188
|
_this4.updateCache(task);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
189
|
+
resolve(state);
|
|
190
|
+
// Notify subscribers that the task have been updated so that they can re-render accordingly
|
|
229
191
|
_this4.notifyUpdated(objectKey, state);
|
|
230
192
|
}).catch(function () {
|
|
231
193
|
// Undo optimistic change
|
|
232
194
|
var previousState = toggleTaskState(state);
|
|
233
|
-
|
|
234
195
|
_this4.updateCache(_objectSpread(_objectSpread({}, objectKey), {}, {
|
|
235
196
|
lastUpdateDate: new Date(),
|
|
236
197
|
type: 'TASK',
|
|
237
198
|
state: previousState
|
|
238
199
|
}));
|
|
239
|
-
|
|
240
200
|
_this4.notifyUpdated(objectKey, previousState);
|
|
241
|
-
|
|
242
201
|
reject();
|
|
243
202
|
});
|
|
244
203
|
}, 500));
|
|
@@ -259,17 +218,14 @@ export var ItemStateManager = /*#__PURE__*/function () {
|
|
|
259
218
|
this.subscribers.set(key, handlers);
|
|
260
219
|
this.trackedObjectKeys.set(key, objectKey);
|
|
261
220
|
var cached = this.getCached(objectKey);
|
|
262
|
-
|
|
263
221
|
if (cached) {
|
|
264
222
|
this.notifyUpdated(objectKey, cached.state);
|
|
265
223
|
return;
|
|
266
224
|
}
|
|
267
|
-
|
|
268
225
|
if (this.serviceConfig.disableServiceHydration && item) {
|
|
269
226
|
this.updateCache(item);
|
|
270
227
|
return;
|
|
271
228
|
}
|
|
272
|
-
|
|
273
229
|
this.queueItem(objectKey);
|
|
274
230
|
this.scheduleGetTaskState();
|
|
275
231
|
}
|
|
@@ -278,19 +234,15 @@ export var ItemStateManager = /*#__PURE__*/function () {
|
|
|
278
234
|
value: function unsubscribe(objectKey, handler) {
|
|
279
235
|
var key = objectKeyToString(objectKey);
|
|
280
236
|
var handlers = this.subscribers.get(key);
|
|
281
|
-
|
|
282
237
|
if (!handlers) {
|
|
283
238
|
return;
|
|
284
239
|
}
|
|
285
|
-
|
|
286
240
|
var index = findIndex(handlers, function (h) {
|
|
287
241
|
return h === handler;
|
|
288
242
|
});
|
|
289
|
-
|
|
290
243
|
if (index !== -1) {
|
|
291
244
|
handlers.splice(index, 1);
|
|
292
245
|
}
|
|
293
|
-
|
|
294
246
|
if (handlers.length === 0) {
|
|
295
247
|
this.subscribers.delete(key);
|
|
296
248
|
this.trackedObjectKeys.delete(key);
|
|
@@ -320,11 +272,9 @@ export var ItemStateManager = /*#__PURE__*/function () {
|
|
|
320
272
|
value: function notifyUpdated(objectKey, state) {
|
|
321
273
|
var key = objectKeyToString(objectKey);
|
|
322
274
|
var handlers = this.subscribers.get(key);
|
|
323
|
-
|
|
324
275
|
if (!handlers) {
|
|
325
276
|
return;
|
|
326
277
|
}
|
|
327
|
-
|
|
328
278
|
handlers.forEach(function (handler) {
|
|
329
279
|
handler(state);
|
|
330
280
|
});
|
|
@@ -365,11 +315,9 @@ export var ItemStateManager = /*#__PURE__*/function () {
|
|
|
365
315
|
key: "queueItem",
|
|
366
316
|
value: function queueItem(objectKey) {
|
|
367
317
|
var key = objectKeyToString(objectKey);
|
|
368
|
-
|
|
369
318
|
if (this.batchedKeys.get(key)) {
|
|
370
319
|
return;
|
|
371
320
|
}
|
|
372
|
-
|
|
373
321
|
this.batchedKeys.set(key, objectKey);
|
|
374
322
|
}
|
|
375
323
|
}, {
|
|
@@ -382,43 +330,34 @@ export var ItemStateManager = /*#__PURE__*/function () {
|
|
|
382
330
|
key: "scheduleGetTaskState",
|
|
383
331
|
value: function scheduleGetTaskState() {
|
|
384
332
|
var _this5 = this;
|
|
385
|
-
|
|
386
333
|
if (this.debouncedTaskStateQuery) {
|
|
387
334
|
clearTimeout(this.debouncedTaskStateQuery);
|
|
388
335
|
}
|
|
389
|
-
|
|
390
336
|
this.debouncedTaskStateQuery = window.setTimeout(function () {
|
|
391
337
|
_this5.getTaskState(Array.from(_this5.batchedKeys.values())).then(function (tasks) {
|
|
392
338
|
tasks.forEach(function (task) {
|
|
393
339
|
var objectAri = task.objectAri,
|
|
394
|
-
|
|
340
|
+
localId = task.localId;
|
|
395
341
|
var objectKey = {
|
|
396
342
|
objectAri: objectAri,
|
|
397
343
|
localId: localId
|
|
398
344
|
};
|
|
399
|
-
|
|
400
345
|
_this5.updateCache(convertServiceTaskStateToBaseItem(task));
|
|
401
|
-
|
|
402
346
|
_this5.dequeueItem(objectKey);
|
|
403
|
-
|
|
404
347
|
_this5.notifyUpdated(objectKey, task.state);
|
|
405
348
|
});
|
|
406
349
|
});
|
|
407
350
|
}, 1);
|
|
408
351
|
}
|
|
409
352
|
}]);
|
|
410
|
-
|
|
411
353
|
return ItemStateManager;
|
|
412
354
|
}();
|
|
413
|
-
|
|
414
355
|
var TaskDecisionResource = /*#__PURE__*/function () {
|
|
415
356
|
function TaskDecisionResource(serviceConfig) {
|
|
416
357
|
_classCallCheck(this, TaskDecisionResource);
|
|
417
|
-
|
|
418
358
|
this.recentUpdates = new RecentUpdates(serviceConfig.pubSubClient);
|
|
419
359
|
this.itemStateManager = new ItemStateManager(serviceConfig);
|
|
420
360
|
}
|
|
421
|
-
|
|
422
361
|
_createClass(TaskDecisionResource, [{
|
|
423
362
|
key: "unsubscribeRecentUpdates",
|
|
424
363
|
value: function unsubscribeRecentUpdates(id) {
|
|
@@ -445,11 +384,11 @@ var TaskDecisionResource = /*#__PURE__*/function () {
|
|
|
445
384
|
value: function unsubscribe(objectKey, handler) {
|
|
446
385
|
this.itemStateManager.unsubscribe(objectKey, handler);
|
|
447
386
|
}
|
|
387
|
+
|
|
448
388
|
/**
|
|
449
389
|
* Usually only needed for testing to ensure no outstanding requests
|
|
450
390
|
* are sent to a server (typically mocked).
|
|
451
391
|
*/
|
|
452
|
-
|
|
453
392
|
}, {
|
|
454
393
|
key: "destroy",
|
|
455
394
|
value: function destroy() {
|
|
@@ -457,8 +396,6 @@ var TaskDecisionResource = /*#__PURE__*/function () {
|
|
|
457
396
|
this.itemStateManager.destroy();
|
|
458
397
|
}
|
|
459
398
|
}]);
|
|
460
|
-
|
|
461
399
|
return TaskDecisionResource;
|
|
462
400
|
}();
|
|
463
|
-
|
|
464
401
|
export { TaskDecisionResource as default };
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["creationDate", "lastUpdateDate", "creatorId", "lastUpdaterId"],
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
_excluded2 = ["lastUpdateDate"];
|
|
6
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
-
|
|
8
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
-
|
|
10
7
|
export var convertServiceTaskToTask = function convertServiceTaskToTask(serviceTask) {
|
|
11
8
|
var creationDate = serviceTask.creationDate,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
lastUpdateDate = serviceTask.lastUpdateDate,
|
|
10
|
+
creatorId = serviceTask.creatorId,
|
|
11
|
+
lastUpdaterId = serviceTask.lastUpdaterId,
|
|
12
|
+
other = _objectWithoutProperties(serviceTask, _excluded);
|
|
17
13
|
return _objectSpread({
|
|
18
14
|
creationDate: creationDate && new Date(creationDate) || undefined,
|
|
19
15
|
lastUpdateDate: new Date(lastUpdateDate),
|
|
@@ -23,8 +19,7 @@ export var convertServiceTaskToTask = function convertServiceTaskToTask(serviceT
|
|
|
23
19
|
};
|
|
24
20
|
export var convertServiceTaskStateToBaseItem = function convertServiceTaskStateToBaseItem(serviceTaskInfo) {
|
|
25
21
|
var lastUpdateDate = serviceTaskInfo.lastUpdateDate,
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
other = _objectWithoutProperties(serviceTaskInfo, _excluded2);
|
|
28
23
|
return _objectSpread({
|
|
29
24
|
type: 'TASK',
|
|
30
25
|
lastUpdateDate: new Date(lastUpdateDate)
|
|
@@ -37,7 +32,6 @@ export var findIndex = function findIndex(array, predicate) {
|
|
|
37
32
|
index = i;
|
|
38
33
|
return true;
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
return false;
|
|
42
36
|
});
|
|
43
37
|
return index;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import DecisionIcon from '@atlaskit/icon/glyph/editor/decision';
|
|
4
5
|
import Item from './Item';
|
|
5
6
|
import { G200, G400, N100 } from '@atlaskit/theme/colors';
|
|
6
7
|
import { themed, useGlobalTheme } from '@atlaskit/theme/components';
|
|
7
8
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
8
|
-
|
|
9
9
|
var iconStyles = function iconStyles(showPlaceholder) {
|
|
10
10
|
return function (theme) {
|
|
11
11
|
return css({
|
|
@@ -25,14 +25,13 @@ var iconStyles = function iconStyles(showPlaceholder) {
|
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
|
|
29
28
|
var DecisionItem = function DecisionItem(_ref) {
|
|
30
29
|
var appearance = _ref.appearance,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
children = _ref.children,
|
|
31
|
+
contentRef = _ref.contentRef,
|
|
32
|
+
placeholder = _ref.placeholder,
|
|
33
|
+
showPlaceholder = _ref.showPlaceholder,
|
|
34
|
+
dataAttributes = _ref.dataAttributes;
|
|
36
35
|
var theme = useGlobalTheme();
|
|
37
36
|
var icon = jsx("span", {
|
|
38
37
|
contentEditable: false,
|
|
@@ -52,5 +51,4 @@ var DecisionItem = function DecisionItem(_ref) {
|
|
|
52
51
|
theme: theme
|
|
53
52
|
}, children);
|
|
54
53
|
};
|
|
55
|
-
|
|
56
54
|
export default DecisionItem;
|
|
@@ -3,50 +3,42 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
|
|
7
6
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
|
|
9
7
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
|
|
11
8
|
/** @jsx jsx */
|
|
9
|
+
|
|
12
10
|
import React from 'react';
|
|
13
11
|
import { PureComponent } from 'react';
|
|
14
12
|
import { jsx } from '@emotion/react';
|
|
15
13
|
import decisionListStyles from './listStyle';
|
|
16
|
-
|
|
17
14
|
var DecisionList = /*#__PURE__*/function (_PureComponent) {
|
|
18
15
|
_inherits(DecisionList, _PureComponent);
|
|
19
|
-
|
|
20
16
|
var _super = _createSuper(DecisionList);
|
|
21
|
-
|
|
22
17
|
function DecisionList() {
|
|
23
18
|
_classCallCheck(this, DecisionList);
|
|
24
|
-
|
|
25
19
|
return _super.apply(this, arguments);
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
_createClass(DecisionList, [{
|
|
29
22
|
key: "render",
|
|
30
23
|
value: function render() {
|
|
31
24
|
var children = this.props.children;
|
|
32
|
-
|
|
33
25
|
if (!children) {
|
|
34
26
|
return null;
|
|
35
|
-
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Data attributes are required for copy and paste from rendered content
|
|
36
30
|
// to the editor to preserve the decision.
|
|
37
31
|
// This allows the editor to differentiate between numbered and ordered lists,
|
|
38
32
|
// and action items, which all share the common `<li>` element.
|
|
39
33
|
// The value of `data-decision-local-id` should be discarded upon paste, with a
|
|
40
34
|
// a new uuid generated by the editor for the cloned content.
|
|
41
|
-
|
|
42
|
-
|
|
43
35
|
return jsx("ol", {
|
|
44
36
|
css: decisionListStyles,
|
|
45
37
|
"data-decision-list-local-id": "",
|
|
46
38
|
"data-node-type": "decisionList"
|
|
47
39
|
}, React.Children.map(children, function (child, idx) {
|
|
48
40
|
var _ref = child.props,
|
|
49
|
-
|
|
41
|
+
localId = _ref.localId;
|
|
50
42
|
return jsx("li", {
|
|
51
43
|
key: idx,
|
|
52
44
|
"data-decision-local-id": localId || '',
|
|
@@ -55,8 +47,6 @@ var DecisionList = /*#__PURE__*/function (_PureComponent) {
|
|
|
55
47
|
}));
|
|
56
48
|
}
|
|
57
49
|
}]);
|
|
58
|
-
|
|
59
50
|
return DecisionList;
|
|
60
51
|
}(PureComponent);
|
|
61
|
-
|
|
62
52
|
export { DecisionList as default };
|
|
@@ -5,12 +5,10 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
8
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
9
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
|
|
13
10
|
/** @jsx jsx */
|
|
11
|
+
|
|
14
12
|
import { PureComponent } from 'react';
|
|
15
13
|
import { css, jsx } from '@emotion/react';
|
|
16
14
|
import { themed } from '@atlaskit/theme/components';
|
|
@@ -28,7 +26,6 @@ var taskStyles = css({
|
|
|
28
26
|
padding: '6px 3px',
|
|
29
27
|
position: 'relative'
|
|
30
28
|
});
|
|
31
|
-
|
|
32
29
|
var decisionStyles = function decisionStyles(theme) {
|
|
33
30
|
return css({
|
|
34
31
|
display: 'flex',
|
|
@@ -49,7 +46,6 @@ var decisionStyles = function decisionStyles(theme) {
|
|
|
49
46
|
}
|
|
50
47
|
});
|
|
51
48
|
};
|
|
52
|
-
|
|
53
49
|
var placeHolderStyles = function placeHolderStyles(offset) {
|
|
54
50
|
return css({
|
|
55
51
|
margin: "0 0 0 ".concat(offset, "px"),
|
|
@@ -62,31 +58,24 @@ var placeHolderStyles = function placeHolderStyles(offset) {
|
|
|
62
58
|
maxWidth: 'calc(100% - 50px)'
|
|
63
59
|
});
|
|
64
60
|
};
|
|
65
|
-
|
|
66
61
|
var Item = /*#__PURE__*/function (_PureComponent) {
|
|
67
62
|
_inherits(Item, _PureComponent);
|
|
68
|
-
|
|
69
63
|
var _super = _createSuper(Item);
|
|
70
|
-
|
|
71
64
|
function Item() {
|
|
72
65
|
_classCallCheck(this, Item);
|
|
73
|
-
|
|
74
66
|
return _super.apply(this, arguments);
|
|
75
67
|
}
|
|
76
|
-
|
|
77
68
|
_createClass(Item, [{
|
|
78
69
|
key: "renderPlaceholder",
|
|
79
70
|
value: function renderPlaceholder() {
|
|
80
71
|
var _this$props = this.props,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
children = _this$props.children,
|
|
73
|
+
placeholder = _this$props.placeholder,
|
|
74
|
+
showPlaceholder = _this$props.showPlaceholder,
|
|
75
|
+
itemType = _this$props.itemType;
|
|
86
76
|
if (!showPlaceholder || !placeholder || children) {
|
|
87
77
|
return null;
|
|
88
78
|
}
|
|
89
|
-
|
|
90
79
|
var offset = gridSize() * (itemType === 'TASK' ? 3 : 3.5);
|
|
91
80
|
return jsx("span", {
|
|
92
81
|
"data-component": "placeholder",
|
|
@@ -98,14 +87,13 @@ var Item = /*#__PURE__*/function (_PureComponent) {
|
|
|
98
87
|
key: "renderMessageAppearance",
|
|
99
88
|
value: function renderMessageAppearance() {
|
|
100
89
|
var _this$props2 = this.props,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
90
|
+
contentRef = _this$props2.contentRef,
|
|
91
|
+
children = _this$props2.children,
|
|
92
|
+
icon = _this$props2.icon,
|
|
93
|
+
itemType = _this$props2.itemType,
|
|
94
|
+
checkBoxId = _this$props2.checkBoxId,
|
|
95
|
+
dataAttributes = _this$props2.dataAttributes,
|
|
96
|
+
theme = _this$props2.theme;
|
|
109
97
|
if (itemType === 'TASK') {
|
|
110
98
|
return jsx("div", {
|
|
111
99
|
css: taskStyles,
|
|
@@ -125,7 +113,6 @@ var Item = /*#__PURE__*/function (_PureComponent) {
|
|
|
125
113
|
ref: contentRef
|
|
126
114
|
}, dataAttributes), children));
|
|
127
115
|
}
|
|
128
|
-
|
|
129
116
|
return null;
|
|
130
117
|
}
|
|
131
118
|
}, {
|
|
@@ -134,12 +121,9 @@ var Item = /*#__PURE__*/function (_PureComponent) {
|
|
|
134
121
|
return this.renderMessageAppearance();
|
|
135
122
|
}
|
|
136
123
|
}]);
|
|
137
|
-
|
|
138
124
|
return Item;
|
|
139
125
|
}(PureComponent);
|
|
140
|
-
|
|
141
126
|
_defineProperty(Item, "defaultProps", {
|
|
142
127
|
appearance: 'inline'
|
|
143
128
|
});
|
|
144
|
-
|
|
145
129
|
export { Item as default };
|