@elastic/eui 113.3.0 → 114.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/button/split_button/split_button.js +13 -0
- package/es/components/button/split_button/split_button_actions.js +15 -0
- package/es/components/collapsible_nav/collapsible_nav.js +5 -0
- package/es/components/color_picker/color_picker.js +31 -8
- package/es/components/datagrid/utils/scrolling.js +39 -10
- package/es/components/flyout/_flyout_overlay.js +34 -4
- package/es/components/flyout/flyout.component.js +13 -9
- package/es/components/flyout/flyout.js +9 -1
- package/es/components/flyout/flyout.styles.js +2 -2
- package/es/components/flyout/flyout_menu.js +2 -1
- package/es/components/flyout/flyout_resizable.js +5 -0
- package/es/components/flyout/manager/actions.js +5 -2
- package/es/components/flyout/manager/flyout_child.js +1 -0
- package/es/components/flyout/manager/flyout_managed.js +5 -3
- package/es/components/flyout/manager/reducer.js +116 -57
- package/es/components/flyout/manager/store.js +13 -6
- package/es/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/es/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +172 -0
- package/es/components/overlay_mask/overlay_mask.js +10 -3
- package/es/components/tree_view/tree_view_item.styles.js +1 -1
- package/es/services/hooks/index.js +8 -8
- package/es/services/hooks/useIsPointerDown.js +6 -15
- package/es/services/index.js +1 -1
- package/eui.d.ts +83 -51
- package/i18ntokens.json +661 -643
- package/lib/components/button/split_button/split_button.js +13 -0
- package/lib/components/button/split_button/split_button_actions.js +15 -0
- package/lib/components/collapsible_nav/collapsible_nav.js +5 -0
- package/lib/components/color_picker/color_picker.js +30 -7
- package/lib/components/datagrid/utils/scrolling.js +37 -8
- package/lib/components/flyout/_flyout_overlay.js +33 -3
- package/lib/components/flyout/flyout.component.js +13 -9
- package/lib/components/flyout/flyout.js +9 -1
- package/lib/components/flyout/flyout.styles.js +2 -2
- package/lib/components/flyout/flyout_menu.js +2 -1
- package/lib/components/flyout/flyout_resizable.js +5 -0
- package/lib/components/flyout/manager/actions.js +5 -2
- package/lib/components/flyout/manager/flyout_child.js +1 -0
- package/lib/components/flyout/manager/flyout_managed.js +5 -3
- package/lib/components/flyout/manager/reducer.js +116 -57
- package/lib/components/flyout/manager/store.js +13 -6
- package/lib/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/lib/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
- package/lib/components/overlay_mask/overlay_mask.js +10 -3
- package/lib/components/tree_view/tree_view_item.styles.js +1 -1
- package/lib/services/hooks/index.js +60 -91
- package/lib/services/hooks/useIsPointerDown.js +7 -14
- package/lib/services/index.js +70 -11
- package/optimize/es/components/color_picker/color_picker.js +31 -8
- package/optimize/es/components/datagrid/utils/scrolling.js +39 -10
- package/optimize/es/components/flyout/_flyout_overlay.js +34 -4
- package/optimize/es/components/flyout/flyout.component.js +13 -9
- package/optimize/es/components/flyout/flyout.js +4 -1
- package/optimize/es/components/flyout/flyout.styles.js +2 -2
- package/optimize/es/components/flyout/flyout_menu.js +2 -1
- package/optimize/es/components/flyout/manager/actions.js +5 -2
- package/optimize/es/components/flyout/manager/flyout_managed.js +4 -3
- package/optimize/es/components/flyout/manager/reducer.js +116 -57
- package/optimize/es/components/flyout/manager/store.js +13 -6
- package/optimize/es/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/optimize/es/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +172 -0
- package/optimize/es/components/overlay_mask/overlay_mask.js +4 -2
- package/optimize/es/components/tree_view/tree_view_item.styles.js +1 -1
- package/optimize/es/services/hooks/index.js +8 -8
- package/optimize/es/services/hooks/useIsPointerDown.js +6 -10
- package/optimize/es/services/index.js +1 -1
- package/optimize/lib/components/color_picker/color_picker.js +30 -7
- package/optimize/lib/components/datagrid/utils/scrolling.js +37 -8
- package/optimize/lib/components/flyout/_flyout_overlay.js +33 -3
- package/optimize/lib/components/flyout/flyout.component.js +13 -9
- package/optimize/lib/components/flyout/flyout.js +4 -1
- package/optimize/lib/components/flyout/flyout.styles.js +2 -2
- package/optimize/lib/components/flyout/flyout_menu.js +2 -1
- package/optimize/lib/components/flyout/manager/actions.js +5 -2
- package/optimize/lib/components/flyout/manager/flyout_managed.js +4 -3
- package/optimize/lib/components/flyout/manager/reducer.js +116 -57
- package/optimize/lib/components/flyout/manager/store.js +13 -6
- package/optimize/lib/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/optimize/lib/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
- package/optimize/lib/components/overlay_mask/overlay_mask.js +4 -2
- package/optimize/lib/components/tree_view/tree_view_item.styles.js +1 -1
- package/optimize/lib/services/hooks/index.js +60 -91
- package/optimize/lib/services/hooks/useIsPointerDown.js +5 -10
- package/optimize/lib/services/index.js +70 -11
- package/package.json +4 -4
- package/test-env/components/button/split_button/split_button.js +13 -0
- package/test-env/components/button/split_button/split_button_actions.js +15 -0
- package/test-env/components/collapsible_nav/collapsible_nav.js +5 -0
- package/test-env/components/color_picker/color_picker.js +30 -7
- package/test-env/components/datagrid/utils/scrolling.js +37 -8
- package/test-env/components/flyout/_flyout_overlay.js +33 -3
- package/test-env/components/flyout/flyout.component.js +13 -9
- package/test-env/components/flyout/flyout.styles.js +2 -2
- package/test-env/components/flyout/flyout_menu.js +2 -1
- package/test-env/components/flyout/flyout_resizable.js +5 -0
- package/test-env/components/flyout/manager/actions.js +5 -2
- package/test-env/components/flyout/manager/flyout_child.js +1 -0
- package/test-env/components/flyout/manager/flyout_managed.js +5 -3
- package/test-env/components/flyout/manager/reducer.js +116 -57
- package/test-env/components/flyout/manager/store.js +13 -6
- package/test-env/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
- package/test-env/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
- package/test-env/components/overlay_mask/overlay_mask.js +10 -3
- package/test-env/components/tree_view/tree_view_item.styles.js +1 -1
- package/test-env/services/hooks/index.js +60 -91
- package/test-env/services/hooks/useIsPointerDown.js +5 -10
- package/test-env/services/index.js +70 -11
|
@@ -34,6 +34,28 @@ export var initialState = {
|
|
|
34
34
|
currentZIndex: 0,
|
|
35
35
|
unmanagedFlyouts: []
|
|
36
36
|
};
|
|
37
|
+
var addSessionFlyoutsToRemove = function addSessionFlyoutsToRemove(session, flyoutsToRemove) {
|
|
38
|
+
var _session$childHistory;
|
|
39
|
+
flyoutsToRemove.add(session.mainFlyoutId);
|
|
40
|
+
if (session.childFlyoutId) {
|
|
41
|
+
flyoutsToRemove.add(session.childFlyoutId);
|
|
42
|
+
}
|
|
43
|
+
((_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : []).forEach(function (e) {
|
|
44
|
+
return flyoutsToRemove.add(e.flyoutId);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
var moveHistoryGroupToTop = function moveHistoryGroupToTop(sessions, historyKey) {
|
|
48
|
+
var groupSessions = [];
|
|
49
|
+
var otherSessions = [];
|
|
50
|
+
sessions.forEach(function (session) {
|
|
51
|
+
if (session.historyKey === historyKey) {
|
|
52
|
+
groupSessions.push(session);
|
|
53
|
+
} else {
|
|
54
|
+
otherSessions.push(session);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return [].concat(otherSessions, groupSessions);
|
|
58
|
+
};
|
|
37
59
|
|
|
38
60
|
/**
|
|
39
61
|
* Reducer handling all flyout manager actions and state transitions.
|
|
@@ -82,6 +104,7 @@ export function flyoutManagerReducer() {
|
|
|
82
104
|
title = action.title,
|
|
83
105
|
level = action.level,
|
|
84
106
|
size = action.size,
|
|
107
|
+
historyKey = action.historyKey,
|
|
85
108
|
iconType = action.iconType,
|
|
86
109
|
minWidth = action.minWidth;
|
|
87
110
|
var isDuplicate = state.flyouts.some(function (f) {
|
|
@@ -108,7 +131,8 @@ export function flyoutManagerReducer() {
|
|
|
108
131
|
iconType: iconType,
|
|
109
132
|
childFlyoutId: null,
|
|
110
133
|
childHistory: [],
|
|
111
|
-
zIndex: state.currentZIndex
|
|
134
|
+
zIndex: state.currentZIndex,
|
|
135
|
+
historyKey: historyKey !== null && historyKey !== void 0 ? historyKey : Symbol()
|
|
112
136
|
};
|
|
113
137
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
114
138
|
sessions: [].concat(_toConsumableArray(state.sessions), [newSession]),
|
|
@@ -235,8 +259,8 @@ export function flyoutManagerReducer() {
|
|
|
235
259
|
});
|
|
236
260
|
}
|
|
237
261
|
var owningSessionIndex = state.sessions.findIndex(function (session) {
|
|
238
|
-
var _session$
|
|
239
|
-
return session.childFlyoutId === action.flyoutId || ((_session$
|
|
262
|
+
var _session$childHistory2;
|
|
263
|
+
return session.childFlyoutId === action.flyoutId || ((_session$childHistory2 = session.childHistory) !== null && _session$childHistory2 !== void 0 ? _session$childHistory2 : []).some(function (entry) {
|
|
240
264
|
return entry.flyoutId === action.flyoutId;
|
|
241
265
|
});
|
|
242
266
|
});
|
|
@@ -268,21 +292,37 @@ export function flyoutManagerReducer() {
|
|
|
268
292
|
});
|
|
269
293
|
}
|
|
270
294
|
|
|
271
|
-
// Unregister all flyouts.
|
|
295
|
+
// Unregister all flyouts (within the current history group only).
|
|
272
296
|
case ACTION_CLOSE_ALL:
|
|
273
297
|
{
|
|
274
298
|
if (state.sessions.length === 0) {
|
|
275
299
|
return state;
|
|
276
300
|
}
|
|
301
|
+
var _currentSessionIndex = state.sessions.length - 1;
|
|
302
|
+
var _currentSession = state.sessions[_currentSessionIndex];
|
|
303
|
+
var currentKey = _currentSession.historyKey;
|
|
277
304
|
|
|
278
|
-
//
|
|
305
|
+
// Remove all sessions that have the current historyKey (entire group)
|
|
306
|
+
var _newSessions = state.sessions.filter(function (s) {
|
|
307
|
+
return s.historyKey !== currentKey;
|
|
308
|
+
});
|
|
309
|
+
var _flyoutsToRemove = new Set();
|
|
310
|
+
state.sessions.forEach(function (session) {
|
|
311
|
+
if (session.historyKey === currentKey) {
|
|
312
|
+
addSessionFlyoutsToRemove(session, _flyoutsToRemove);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
var _newFlyouts3 = state.flyouts.filter(function (f) {
|
|
316
|
+
return !_flyoutsToRemove.has(f.flyoutId);
|
|
317
|
+
});
|
|
279
318
|
var _newCurrentZIndex2 = state.currentZIndex;
|
|
280
|
-
if (state.unmanagedFlyouts.length === 0) {
|
|
319
|
+
if (_newSessions.length === 0 && state.unmanagedFlyouts.length === 0) {
|
|
281
320
|
_newCurrentZIndex2 = 0;
|
|
282
321
|
}
|
|
283
|
-
return _objectSpread(_objectSpread({},
|
|
284
|
-
|
|
285
|
-
|
|
322
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
323
|
+
sessions: _newSessions,
|
|
324
|
+
flyouts: _newFlyouts3,
|
|
325
|
+
currentZIndex: _newCurrentZIndex2
|
|
286
326
|
});
|
|
287
327
|
}
|
|
288
328
|
|
|
@@ -294,8 +334,8 @@ export function flyoutManagerReducer() {
|
|
|
294
334
|
return state;
|
|
295
335
|
}
|
|
296
336
|
var _updatedSessions2 = _toConsumableArray(state.sessions);
|
|
297
|
-
var
|
|
298
|
-
_updatedSessions2[
|
|
337
|
+
var _currentSessionIndex2 = _updatedSessions2.length - 1;
|
|
338
|
+
_updatedSessions2[_currentSessionIndex2] = _objectSpread(_objectSpread({}, _updatedSessions2[_currentSessionIndex2]), {}, {
|
|
299
339
|
childFlyoutId: action.flyoutId
|
|
300
340
|
});
|
|
301
341
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -341,51 +381,50 @@ export function flyoutManagerReducer() {
|
|
|
341
381
|
});
|
|
342
382
|
}
|
|
343
383
|
|
|
344
|
-
// Go back: pop child history when any, else pop current session
|
|
384
|
+
// Go back: pop child history when any, else pop current session (only within same historyKey).
|
|
345
385
|
case ACTION_GO_BACK:
|
|
346
386
|
{
|
|
347
|
-
var
|
|
387
|
+
var _currentSession2$chil;
|
|
348
388
|
if (state.sessions.length === 0) {
|
|
349
389
|
return state;
|
|
350
390
|
}
|
|
351
|
-
var
|
|
352
|
-
var
|
|
353
|
-
var _childHistory = (
|
|
391
|
+
var _currentSessionIndex3 = state.sessions.length - 1;
|
|
392
|
+
var _currentSession2 = state.sessions[_currentSessionIndex3];
|
|
393
|
+
var _childHistory = (_currentSession2$chil = _currentSession2.childHistory) !== null && _currentSession2$chil !== void 0 ? _currentSession2$chil : [];
|
|
354
394
|
if (_childHistory.length > 0) {
|
|
355
395
|
// Pop one child: set current child to the last entry in history, remove the current child flyout
|
|
356
396
|
var popped = _childHistory[_childHistory.length - 1];
|
|
357
397
|
var newChildHistory = _childHistory.slice(0, -1);
|
|
358
398
|
var _updatedSessions3 = _toConsumableArray(state.sessions);
|
|
359
|
-
_updatedSessions3[
|
|
399
|
+
_updatedSessions3[_currentSessionIndex3] = _objectSpread(_objectSpread({}, _currentSession2), {}, {
|
|
360
400
|
childHistory: newChildHistory,
|
|
361
401
|
childFlyoutId: popped.flyoutId,
|
|
362
402
|
childTitle: popped.title,
|
|
363
403
|
childIconType: popped.iconType
|
|
364
404
|
});
|
|
365
|
-
var
|
|
366
|
-
return f.flyoutId !==
|
|
405
|
+
var _newFlyouts4 = state.flyouts.filter(function (f) {
|
|
406
|
+
return f.flyoutId !== _currentSession2.childFlyoutId;
|
|
367
407
|
});
|
|
368
408
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
369
409
|
sessions: _updatedSessions3,
|
|
370
|
-
flyouts:
|
|
410
|
+
flyouts: _newFlyouts4
|
|
371
411
|
});
|
|
372
412
|
}
|
|
373
413
|
|
|
374
414
|
// No child history: pop current session (main + all its children)
|
|
375
|
-
var
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
return _flyoutsToRemove.add(e.flyoutId);
|
|
415
|
+
var _flyoutsToRemove2 = new Set();
|
|
416
|
+
addSessionFlyoutsToRemove(_currentSession2, _flyoutsToRemove2);
|
|
417
|
+
var sessionsWithoutCurrent = state.sessions.slice(0, _currentSessionIndex3);
|
|
418
|
+
var hasRemainingInCurrentGroup = sessionsWithoutCurrent.some(function (s) {
|
|
419
|
+
return s.historyKey === _currentSession2.historyKey;
|
|
381
420
|
});
|
|
382
|
-
var
|
|
383
|
-
|
|
421
|
+
var _newSessions2 = hasRemainingInCurrentGroup ? moveHistoryGroupToTop(sessionsWithoutCurrent, _currentSession2.historyKey) : sessionsWithoutCurrent;
|
|
422
|
+
var _newFlyouts5 = state.flyouts.filter(function (f) {
|
|
423
|
+
return !_flyoutsToRemove2.has(f.flyoutId);
|
|
384
424
|
});
|
|
385
|
-
var _newSessions = state.sessions.slice(0, _currentSessionIndex2);
|
|
386
425
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
387
|
-
sessions:
|
|
388
|
-
flyouts:
|
|
426
|
+
sessions: _newSessions2,
|
|
427
|
+
flyouts: _newFlyouts5
|
|
389
428
|
});
|
|
390
429
|
}
|
|
391
430
|
|
|
@@ -394,11 +433,11 @@ export function flyoutManagerReducer() {
|
|
|
394
433
|
{
|
|
395
434
|
var _flyoutId3 = action.flyoutId,
|
|
396
435
|
_level = action.level;
|
|
397
|
-
var
|
|
436
|
+
var _currentSessionIndex4 = state.sessions.length - 1;
|
|
398
437
|
if (_level === LEVEL_CHILD && state.sessions.length > 0) {
|
|
399
|
-
var
|
|
400
|
-
var
|
|
401
|
-
var _childHistory2 = (
|
|
438
|
+
var _currentSession3$chil;
|
|
439
|
+
var _currentSession3 = state.sessions[_currentSessionIndex4];
|
|
440
|
+
var _childHistory2 = (_currentSession3$chil = _currentSession3.childHistory) !== null && _currentSession3$chil !== void 0 ? _currentSession3$chil : [];
|
|
402
441
|
var targetIndex = _childHistory2.findIndex(function (entry) {
|
|
403
442
|
return entry.flyoutId === _flyoutId3;
|
|
404
443
|
});
|
|
@@ -407,18 +446,18 @@ export function flyoutManagerReducer() {
|
|
|
407
446
|
}
|
|
408
447
|
var targetEntry = _childHistory2[targetIndex];
|
|
409
448
|
var _newChildHistory = _childHistory2.slice(0, targetIndex);
|
|
410
|
-
var
|
|
411
|
-
if (
|
|
412
|
-
|
|
449
|
+
var _flyoutsToRemove3 = new Set();
|
|
450
|
+
if (_currentSession3.childFlyoutId) {
|
|
451
|
+
_flyoutsToRemove3.add(_currentSession3.childFlyoutId);
|
|
413
452
|
}
|
|
414
453
|
_childHistory2.slice(targetIndex + 1).forEach(function (e) {
|
|
415
|
-
|
|
454
|
+
_flyoutsToRemove3.add(e.flyoutId);
|
|
416
455
|
});
|
|
417
|
-
var
|
|
418
|
-
return !
|
|
456
|
+
var _newFlyouts6 = state.flyouts.filter(function (f) {
|
|
457
|
+
return !_flyoutsToRemove3.has(f.flyoutId);
|
|
419
458
|
});
|
|
420
459
|
var _updatedSessions4 = _toConsumableArray(state.sessions);
|
|
421
|
-
_updatedSessions4[
|
|
460
|
+
_updatedSessions4[_currentSessionIndex4] = _objectSpread(_objectSpread({}, _currentSession3), {}, {
|
|
422
461
|
childHistory: _newChildHistory,
|
|
423
462
|
childFlyoutId: targetEntry.flyoutId,
|
|
424
463
|
childTitle: targetEntry.title,
|
|
@@ -426,7 +465,7 @@ export function flyoutManagerReducer() {
|
|
|
426
465
|
});
|
|
427
466
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
428
467
|
sessions: _updatedSessions4,
|
|
429
|
-
flyouts:
|
|
468
|
+
flyouts: _newFlyouts6
|
|
430
469
|
});
|
|
431
470
|
}
|
|
432
471
|
|
|
@@ -437,25 +476,45 @@ export function flyoutManagerReducer() {
|
|
|
437
476
|
if (targetSessionIndex === -1) {
|
|
438
477
|
return state; // Target flyout not found
|
|
439
478
|
}
|
|
479
|
+
var _currentSession4 = state.sessions[_currentSessionIndex4];
|
|
480
|
+
var targetSession = state.sessions[targetSessionIndex];
|
|
481
|
+
|
|
482
|
+
// Group-local navigation: keep other history groups, remove only newer sessions in target's group,
|
|
483
|
+
// then bring that group to the top.
|
|
484
|
+
if (targetSession.historyKey === _currentSession4.historyKey) {
|
|
485
|
+
var _flyoutsToRemove4 = new Set();
|
|
486
|
+
var sessionsAfterTargetInGroup = state.sessions.filter(function (session, index) {
|
|
487
|
+
return index > targetSessionIndex && session.historyKey === targetSession.historyKey;
|
|
488
|
+
});
|
|
489
|
+
sessionsAfterTargetInGroup.forEach(function (session) {
|
|
490
|
+
addSessionFlyoutsToRemove(session, _flyoutsToRemove4);
|
|
491
|
+
});
|
|
492
|
+
var sessionsWithoutRemoved = state.sessions.filter(function (session) {
|
|
493
|
+
return !sessionsAfterTargetInGroup.some(function (removed) {
|
|
494
|
+
return removed.mainFlyoutId === session.mainFlyoutId;
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
var reorderedSessions = moveHistoryGroupToTop(sessionsWithoutRemoved, targetSession.historyKey);
|
|
498
|
+
var _newFlyouts7 = state.flyouts.filter(function (f) {
|
|
499
|
+
return !_flyoutsToRemove4.has(f.flyoutId);
|
|
500
|
+
});
|
|
501
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
502
|
+
sessions: reorderedSessions,
|
|
503
|
+
flyouts: _newFlyouts7
|
|
504
|
+
});
|
|
505
|
+
}
|
|
440
506
|
var sessionsToClose = state.sessions.slice(targetSessionIndex + 1);
|
|
441
|
-
var
|
|
507
|
+
var _flyoutsToRemove5 = new Set();
|
|
442
508
|
sessionsToClose.forEach(function (session) {
|
|
443
|
-
|
|
444
|
-
_flyoutsToRemove3.add(session.mainFlyoutId);
|
|
445
|
-
if (session.childFlyoutId) {
|
|
446
|
-
_flyoutsToRemove3.add(session.childFlyoutId);
|
|
447
|
-
}
|
|
448
|
-
((_session$childHistory2 = session.childHistory) !== null && _session$childHistory2 !== void 0 ? _session$childHistory2 : []).forEach(function (e) {
|
|
449
|
-
return _flyoutsToRemove3.add(e.flyoutId);
|
|
450
|
-
});
|
|
509
|
+
addSessionFlyoutsToRemove(session, _flyoutsToRemove5);
|
|
451
510
|
});
|
|
452
|
-
var
|
|
453
|
-
return !
|
|
511
|
+
var _newFlyouts8 = state.flyouts.filter(function (f) {
|
|
512
|
+
return !_flyoutsToRemove5.has(f.flyoutId);
|
|
454
513
|
});
|
|
455
|
-
var
|
|
514
|
+
var _newSessions3 = state.sessions.slice(0, targetSessionIndex + 1);
|
|
456
515
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
457
|
-
sessions:
|
|
458
|
-
flyouts:
|
|
516
|
+
sessions: _newSessions3,
|
|
517
|
+
flyouts: _newFlyouts8
|
|
459
518
|
});
|
|
460
519
|
}
|
|
461
520
|
|
|
@@ -52,8 +52,15 @@ function createStore() {
|
|
|
52
52
|
var _currentSession$child;
|
|
53
53
|
var currentSessionIndex = currentState.sessions.length - 1;
|
|
54
54
|
var currentSession = currentSessionIndex >= 0 ? currentState.sessions[currentSessionIndex] : null;
|
|
55
|
+
if (!currentSession) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
55
58
|
var previousSessions = currentState.sessions.slice(0, currentSessionIndex);
|
|
56
|
-
|
|
59
|
+
// Only include sessions in the same history group (same historyKey reference)
|
|
60
|
+
var previousSessionsInGroup = previousSessions.filter(function (session) {
|
|
61
|
+
return session.historyKey === currentSession.historyKey;
|
|
62
|
+
});
|
|
63
|
+
var childHistory = (_currentSession$child = currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
|
|
57
64
|
var childItems = _toConsumableArray(childHistory).reverse().map(function (entry) {
|
|
58
65
|
return {
|
|
59
66
|
title: entry.title,
|
|
@@ -64,11 +71,11 @@ function createStore() {
|
|
|
64
71
|
};
|
|
65
72
|
});
|
|
66
73
|
|
|
67
|
-
// Previous sessions: list each session's current child then its child history
|
|
74
|
+
// Previous sessions (same group): list each session's current child then its child history
|
|
68
75
|
var previousSessionItems = [];
|
|
69
76
|
var _loop = function _loop() {
|
|
70
77
|
var _session$childHistory;
|
|
71
|
-
var session =
|
|
78
|
+
var session = previousSessionsInGroup[i];
|
|
72
79
|
var mainTitle = session.title;
|
|
73
80
|
var mainFlyoutId = session.mainFlyoutId;
|
|
74
81
|
var history = (_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : [];
|
|
@@ -106,7 +113,7 @@ function createStore() {
|
|
|
106
113
|
});
|
|
107
114
|
}
|
|
108
115
|
};
|
|
109
|
-
for (var i =
|
|
116
|
+
for (var i = previousSessionsInGroup.length - 1; i >= 0; i--) {
|
|
110
117
|
_loop();
|
|
111
118
|
}
|
|
112
119
|
return [].concat(_toConsumableArray(childItems), previousSessionItems);
|
|
@@ -145,8 +152,8 @@ function createStore() {
|
|
|
145
152
|
subscribe: subscribe,
|
|
146
153
|
subscribeToEvents: subscribeToEvents,
|
|
147
154
|
dispatch: dispatch,
|
|
148
|
-
addFlyout: function addFlyout(flyoutId, title, level, size, iconType, minWidth) {
|
|
149
|
-
return dispatch(addFlyoutAction(flyoutId, title, level, size, iconType, minWidth));
|
|
155
|
+
addFlyout: function addFlyout(flyoutId, title, level, size, historyKey, iconType, minWidth) {
|
|
156
|
+
return dispatch(addFlyoutAction(flyoutId, title, level, size, historyKey, iconType, minWidth));
|
|
150
157
|
},
|
|
151
158
|
closeFlyout: function closeFlyout(flyoutId) {
|
|
152
159
|
return dispatch(closeFlyoutAction(flyoutId));
|
|
@@ -24,6 +24,7 @@ import markdown from 'remark-parse-no-trim';
|
|
|
24
24
|
import emoji from 'remark-emoji';
|
|
25
25
|
import breaks from 'remark-breaks';
|
|
26
26
|
import highlight from '../remark/remark_prismjs';
|
|
27
|
+
import intrawordUnderscore from '../remark/remark_intraword_underscore';
|
|
27
28
|
import * as MarkdownTooltip from '../markdown_tooltip';
|
|
28
29
|
import * as MarkdownCheckbox from '../markdown_checkbox';
|
|
29
30
|
import { euiMarkdownLinkValidator, DEFAULT_OPTIONS as LINK_VALIDATOR_DEFAULTS } from '../markdown_link_validator';
|
|
@@ -40,7 +41,7 @@ export var getDefaultEuiMarkdownParsingPlugins = function getDefaultEuiMarkdownP
|
|
|
40
41
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
41
42
|
var exclude = _ref.exclude,
|
|
42
43
|
parsingConfig = _objectWithoutProperties(_ref, _excluded);
|
|
43
|
-
var parsingPlugins = [[markdown, {}], [highlight, {}]];
|
|
44
|
+
var parsingPlugins = [[markdown, {}], [highlight, {}], [intrawordUnderscore, {}]];
|
|
44
45
|
Object.entries(DEFAULT_PARSING_PLUGINS).forEach(function (_ref2) {
|
|
45
46
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
46
47
|
pluginName = _ref3[0],
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
+
/*
|
|
5
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
6
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
7
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
8
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
9
|
+
* Side Public License, v 1.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// Temporary workaround for https://github.com/elastic/eui/issues/9404
|
|
13
|
+
// remark-parse v8 doesn't implement the CommonMark rule that underscore
|
|
14
|
+
// emphasis delimiters flanked by alphanumerics on both sides (intraword)
|
|
15
|
+
// cannot open or close emphasis. This causes identifiers like
|
|
16
|
+
// `ABCD__PineappleCherry__e` to render with bold formatting.
|
|
17
|
+
// This plugin walks the parsed AST and reverses incorrectly applied
|
|
18
|
+
// emphasis/strong nodes when both sides are alphanumeric characters.
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line import/no-unresolved
|
|
21
|
+
|
|
22
|
+
var isTextNode = function isTextNode(node) {
|
|
23
|
+
return node.type === 'text';
|
|
24
|
+
};
|
|
25
|
+
var isEmphasisOrStrong = function isEmphasisOrStrong(node) {
|
|
26
|
+
return node.type === 'emphasis' || node.type === 'strong';
|
|
27
|
+
};
|
|
28
|
+
var isAlphanumeric = function isAlphanumeric(ch) {
|
|
29
|
+
return /[a-zA-Z0-9]/.test(ch);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Recursively converts an emphasis/strong node back into plain text
|
|
34
|
+
* with underscore delimiters restored.
|
|
35
|
+
*/
|
|
36
|
+
function flattenToText(node) {
|
|
37
|
+
var delimiter = node.type === 'emphasis' ? '_' : '__';
|
|
38
|
+
var inner = '';
|
|
39
|
+
var _iterator = _createForOfIteratorHelper(node.children),
|
|
40
|
+
_step;
|
|
41
|
+
try {
|
|
42
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
43
|
+
var child = _step.value;
|
|
44
|
+
if (isTextNode(child)) {
|
|
45
|
+
inner += child.value;
|
|
46
|
+
} else if (isEmphasisOrStrong(child)) {
|
|
47
|
+
inner += flattenToText(child);
|
|
48
|
+
} else {
|
|
49
|
+
// Contains non-text children (links, images, etc.) — leave emphasis intact
|
|
50
|
+
return delimiter + collectText(node) + delimiter;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_iterator.e(err);
|
|
55
|
+
} finally {
|
|
56
|
+
_iterator.f();
|
|
57
|
+
}
|
|
58
|
+
return delimiter + inner + delimiter;
|
|
59
|
+
}
|
|
60
|
+
function collectText(node) {
|
|
61
|
+
if (isTextNode(node)) return node.value;
|
|
62
|
+
if ('children' in node) {
|
|
63
|
+
return node.children.map(collectText).join('');
|
|
64
|
+
}
|
|
65
|
+
return '';
|
|
66
|
+
}
|
|
67
|
+
function processParent(parent, source) {
|
|
68
|
+
var modified = false;
|
|
69
|
+
var i = 0;
|
|
70
|
+
while (i < parent.children.length) {
|
|
71
|
+
var child = parent.children[i];
|
|
72
|
+
if (isEmphasisOrStrong(child) && isIntraword(parent, i, source)) {
|
|
73
|
+
var textValue = flattenToText(child);
|
|
74
|
+
var replacement = {
|
|
75
|
+
type: 'text',
|
|
76
|
+
value: textValue
|
|
77
|
+
};
|
|
78
|
+
parent.children.splice(i, 1, replacement);
|
|
79
|
+
modified = true;
|
|
80
|
+
// Don't advance — the replaced node may need to merge with neighbors
|
|
81
|
+
} else {
|
|
82
|
+
if ('children' in child) {
|
|
83
|
+
processParent(child, source);
|
|
84
|
+
}
|
|
85
|
+
i++;
|
|
86
|
+
}
|
|
87
|
+
if (modified) {
|
|
88
|
+
mergeAdjacentText(parent);
|
|
89
|
+
modified = false;
|
|
90
|
+
// After merging, restart scan since indices shifted
|
|
91
|
+
i = 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function getInnerText(node) {
|
|
96
|
+
if (isTextNode(node)) return node.value;
|
|
97
|
+
if ('children' in node) {
|
|
98
|
+
var children = node.children;
|
|
99
|
+
if (children.length > 0) return getInnerText(children[0]);
|
|
100
|
+
}
|
|
101
|
+
return '';
|
|
102
|
+
}
|
|
103
|
+
function getInnerTextEnd(node) {
|
|
104
|
+
if (isTextNode(node)) return node.value;
|
|
105
|
+
if ('children' in node) {
|
|
106
|
+
var children = node.children;
|
|
107
|
+
if (children.length > 0) return getInnerTextEnd(children[children.length - 1]);
|
|
108
|
+
}
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Checks whether the emphasis/strong node at `index` within `parent`
|
|
114
|
+
* is an intraword usage of underscore delimiters.
|
|
115
|
+
*
|
|
116
|
+
* A node is intraword when at least one side has an alphanumeric text
|
|
117
|
+
* neighbor AND the inner content on the corresponding delimiter side
|
|
118
|
+
* also touches word characters — proving the underscores are embedded
|
|
119
|
+
* in a word rather than used as formatting.
|
|
120
|
+
*/
|
|
121
|
+
function isIntraword(parent, index, source) {
|
|
122
|
+
var _node$position;
|
|
123
|
+
var node = parent.children[index];
|
|
124
|
+
|
|
125
|
+
// Verify the delimiter is `_` (not `*`) by inspecting the source
|
|
126
|
+
if (((_node$position = node.position) === null || _node$position === void 0 || (_node$position = _node$position.start) === null || _node$position === void 0 ? void 0 : _node$position.offset) != null) {
|
|
127
|
+
var ch = source[node.position.start.offset];
|
|
128
|
+
if (ch !== '_') return false;
|
|
129
|
+
}
|
|
130
|
+
var prev = index > 0 ? parent.children[index - 1] : null;
|
|
131
|
+
var next = index < parent.children.length - 1 ? parent.children[index + 1] : null;
|
|
132
|
+
var prevChar = prev != null && isTextNode(prev) && prev.value.length > 0 ? prev.value[prev.value.length - 1] : null;
|
|
133
|
+
var nextChar = next != null && isTextNode(next) && next.value.length > 0 ? next.value[0] : null;
|
|
134
|
+
var prevIsAlpha = prevChar != null && isAlphanumeric(prevChar);
|
|
135
|
+
var nextIsAlpha = nextChar != null && isAlphanumeric(nextChar);
|
|
136
|
+
|
|
137
|
+
// Both sides flanked by alphanumeric — classic intraword (e.g. `foo__bar__baz`)
|
|
138
|
+
if (prevIsAlpha && nextIsAlpha) return true;
|
|
139
|
+
|
|
140
|
+
// One-sided: prev is alpha or underscore, no alpha next — check inner text
|
|
141
|
+
// starts with alpha (e.g. `Lorem__ipsum__` or `Lorem__ipsum_`)
|
|
142
|
+
if (prevIsAlpha || prevChar === '_') {
|
|
143
|
+
var inner = getInnerText(node);
|
|
144
|
+
if (inner.length > 0 && isAlphanumeric(inner[0])) return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// One-sided: next is alpha or underscore, no alpha prev — check inner text
|
|
148
|
+
// ends with alpha (e.g. `__Lorem__ipsum` or `_Lorem__ipsum`)
|
|
149
|
+
if (nextIsAlpha || nextChar === '_') {
|
|
150
|
+
var _inner = getInnerTextEnd(node);
|
|
151
|
+
if (_inner.length > 0 && isAlphanumeric(_inner[_inner.length - 1])) return true;
|
|
152
|
+
}
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
function mergeAdjacentText(parent) {
|
|
156
|
+
var i = 0;
|
|
157
|
+
while (i < parent.children.length - 1) {
|
|
158
|
+
if (isTextNode(parent.children[i]) && isTextNode(parent.children[i + 1])) {
|
|
159
|
+
parent.children[i].value += parent.children[i + 1].value;
|
|
160
|
+
parent.children.splice(i + 1, 1);
|
|
161
|
+
} else {
|
|
162
|
+
i++;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
var attacher = function remarkIntrawordUnderscore() {
|
|
167
|
+
return function (tree, file) {
|
|
168
|
+
var source = String(file);
|
|
169
|
+
processParent(tree, source);
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export default attacher;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["className", "children", "headerZindexLocation", "maskRef"];
|
|
1
|
+
var _excluded = ["className", "children", "headerZindexLocation", "maskRef", "hasAnimation"];
|
|
2
2
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
4
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
@@ -35,6 +35,8 @@ export var EuiOverlayMask = function EuiOverlayMask(_ref) {
|
|
|
35
35
|
_ref$headerZindexLoca = _ref.headerZindexLocation,
|
|
36
36
|
headerZindexLocation = _ref$headerZindexLoca === void 0 ? 'above' : _ref$headerZindexLoca,
|
|
37
37
|
maskRef = _ref.maskRef,
|
|
38
|
+
_ref$hasAnimation = _ref.hasAnimation,
|
|
39
|
+
hasAnimation = _ref$hasAnimation === void 0 ? true : _ref$hasAnimation,
|
|
38
40
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
39
41
|
var hasRendered = useRef(false);
|
|
40
42
|
var _useState = useState(null),
|
|
@@ -46,7 +48,7 @@ export var EuiOverlayMask = function EuiOverlayMask(_ref) {
|
|
|
46
48
|
hasRendered.current = true;
|
|
47
49
|
}, []);
|
|
48
50
|
var styles = useEuiMemoizedStyles(euiOverlayMaskStyles);
|
|
49
|
-
var cssStyles = cx([styles.euiOverlayMask, styles["".concat(headerZindexLocation, "Header")], hasRendered.current && styles.noAnimation]);
|
|
51
|
+
var cssStyles = cx([styles.euiOverlayMask, styles["".concat(headerZindexLocation, "Header")], (hasRendered.current || !hasAnimation) && styles.noAnimation]);
|
|
50
52
|
useEffect(function () {
|
|
51
53
|
if (!overlayMaskNode) return;
|
|
52
54
|
keysOf(rest).forEach(function (key) {
|
|
@@ -105,5 +107,10 @@ EuiOverlayMask.propTypes = {
|
|
|
105
107
|
/**
|
|
106
108
|
* React ref to be passed to the wrapping container
|
|
107
109
|
*/
|
|
108
|
-
maskRef: PropTypes.oneOfType([PropTypes.any.isRequired, PropTypes.any.isRequired])
|
|
110
|
+
maskRef: PropTypes.oneOfType([PropTypes.any.isRequired, PropTypes.any.isRequired]),
|
|
111
|
+
/**
|
|
112
|
+
* If enabled, the mask will have a fade in animation.
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
hasAnimation: PropTypes.bool
|
|
109
116
|
};
|
|
@@ -26,7 +26,7 @@ export var euiTreeViewItemStyles = function euiTreeViewItemStyles(euiThemeContex
|
|
|
26
26
|
euiTreeView__node: _ref,
|
|
27
27
|
default: /*#__PURE__*/css(logicalCSS('max-height', defaultSize), " line-height:", defaultSize, ";;label:default;"),
|
|
28
28
|
compressed: /*#__PURE__*/css(logicalCSS('max-height', compressedSize), " line-height:", compressedSize, ";;label:compressed;"),
|
|
29
|
-
expanded: /*#__PURE__*/css(logicalCSS('max-height', '
|
|
29
|
+
expanded: /*#__PURE__*/css(logicalCSS('max-height', 'none'), ";;label:expanded;")
|
|
30
30
|
},
|
|
31
31
|
button: {
|
|
32
32
|
euiTreeView__nodeInner: /*#__PURE__*/css(logicalCSS('width', '100%'), " ", logicalCSS('padding-left', euiTheme.size.s), " ", logicalCSS('padding-right', euiTheme.size.xxs), " display:flex;align-items:center;&:focus{", euiFocusRing(euiThemeContext, 'inset'), ";}&:hover,&:active,&:focus{background-color:", euiTheme.components.treeViewItemBackgroundHover, ";};label:euiTreeView__nodeInner;"),
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* Side Public License, v 1.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
9
|
+
export { useDependentState } from './useDependentState';
|
|
10
|
+
export { useCombinedRefs, setMultipleRefs } from './useCombinedRefs';
|
|
11
|
+
export { useForceRender } from './useForceRender';
|
|
12
|
+
export { useLatest } from './useLatest';
|
|
13
|
+
export { useDeepEqual } from './useDeepEqual';
|
|
14
|
+
export { isMouseEvent, useMouseMove } from './useMouseMove';
|
|
15
|
+
export { useIsPointerDown } from './useIsPointerDown';
|
|
16
|
+
export { useUpdateEffect } from './useUpdateEffect';
|
|
17
17
|
export { useEuiDisabledElement } from './useEuiDisabledElement';
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
-
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."); }
|
|
3
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
1
|
/*
|
|
8
2
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
9
3
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -12,30 +6,27 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
|
12
6
|
* Side Public License, v 1.
|
|
13
7
|
*/
|
|
14
8
|
|
|
15
|
-
import {
|
|
9
|
+
import { useRef, useEffect } from 'react';
|
|
16
10
|
|
|
17
11
|
/**
|
|
18
12
|
* A hook that tracks whether the pointer is currently down/pressed.
|
|
19
13
|
* Useful for detecting text selection in progress.
|
|
20
14
|
*/
|
|
21
15
|
export function useIsPointerDown(container) {
|
|
22
|
-
var
|
|
23
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
-
isPointerDown = _useState2[0],
|
|
25
|
-
setIsPointerDown = _useState2[1];
|
|
16
|
+
var isPointerDownRef = useRef(false);
|
|
26
17
|
useEffect(function () {
|
|
27
18
|
var handlePointerDown = function handlePointerDown(event) {
|
|
28
19
|
if (container !== null && container !== void 0 && container.current && !container.current.contains(event.target)) {
|
|
29
20
|
return;
|
|
30
21
|
}
|
|
31
|
-
|
|
22
|
+
isPointerDownRef.current = true;
|
|
32
23
|
};
|
|
33
24
|
var handlePointerUpOrCancel = function handlePointerUpOrCancel() {
|
|
34
|
-
|
|
25
|
+
isPointerDownRef.current = false;
|
|
35
26
|
};
|
|
36
27
|
var handleVisibilityChange = function handleVisibilityChange() {
|
|
37
28
|
if (document.visibilityState === 'hidden') {
|
|
38
|
-
|
|
29
|
+
isPointerDownRef.current = false;
|
|
39
30
|
}
|
|
40
31
|
};
|
|
41
32
|
var controller = new AbortController();
|
|
@@ -53,5 +44,5 @@ export function useIsPointerDown(container) {
|
|
|
53
44
|
controller.abort();
|
|
54
45
|
};
|
|
55
46
|
}, [container]);
|
|
56
|
-
return
|
|
47
|
+
return isPointerDownRef;
|
|
57
48
|
}
|