@datarobot/design-system 29.1.1 → 29.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/cjs/datetime-range-picker/datetime-range-picker-panel.d.ts +2 -1
  2. package/cjs/datetime-range-picker/datetime-range-picker-panel.js +1 -0
  3. package/cjs/floating-panel/constants.js +3 -1
  4. package/cjs/floating-panel/draggable-area.d.ts +1 -0
  5. package/cjs/floating-panel/draggable-area.js +9 -46
  6. package/cjs/floating-panel/floating-panel-collapse-button.d.ts +5 -0
  7. package/cjs/floating-panel/floating-panel-collapse-button.js +36 -0
  8. package/cjs/floating-panel/floating-panel-dock-button.js +1 -0
  9. package/cjs/floating-panel/floating-panel-drag-handle.js +1 -9
  10. package/cjs/floating-panel/floating-panel-header.js +49 -20
  11. package/cjs/floating-panel/floating-panel.d.ts +8 -0
  12. package/cjs/floating-panel/floating-panel.js +8 -4
  13. package/cjs/floating-panel/types.d.ts +8 -0
  14. package/cjs/floating-panel/types.js +9 -1
  15. package/cjs/floating-panel/use-draggable-area.d.ts +17 -0
  16. package/cjs/floating-panel/use-draggable-area.js +70 -0
  17. package/cjs/floating-panel/use-floating-panel-state.d.ts +6 -2
  18. package/cjs/floating-panel/use-floating-panel-state.js +224 -84
  19. package/cjs/hooks/use-analytics/use-analytics.test.js +0 -10
  20. package/esm/datetime-range-picker/datetime-range-picker-panel.d.ts +2 -1
  21. package/esm/datetime-range-picker/datetime-range-picker-panel.js +1 -0
  22. package/esm/floating-panel/constants.js +3 -1
  23. package/esm/floating-panel/draggable-area.d.ts +1 -0
  24. package/esm/floating-panel/draggable-area.js +8 -45
  25. package/esm/floating-panel/floating-panel-collapse-button.d.ts +5 -0
  26. package/esm/floating-panel/floating-panel-collapse-button.js +29 -0
  27. package/esm/floating-panel/floating-panel-dock-button.js +2 -1
  28. package/esm/floating-panel/floating-panel-drag-handle.js +1 -9
  29. package/esm/floating-panel/floating-panel-header.js +50 -21
  30. package/esm/floating-panel/floating-panel.d.ts +8 -0
  31. package/esm/floating-panel/floating-panel.js +8 -4
  32. package/esm/floating-panel/types.d.ts +8 -0
  33. package/esm/floating-panel/types.js +7 -1
  34. package/esm/floating-panel/use-draggable-area.d.ts +17 -0
  35. package/esm/floating-panel/use-draggable-area.js +64 -0
  36. package/esm/floating-panel/use-floating-panel-state.d.ts +6 -2
  37. package/esm/floating-panel/use-floating-panel-state.js +226 -86
  38. package/esm/hooks/use-analytics/use-analytics.test.js +0 -10
  39. package/js/139/139.min.js +1 -1
  40. package/js/244/244.min.js +1 -1
  41. package/js/633/633.min.js +1 -1
  42. package/js/784/784.min.js +1 -1
  43. package/js/86/86.min.js +1 -1
  44. package/js/bundle/bundle.js +467 -191
  45. package/js/bundle/bundle.min.js +1 -1
  46. package/js/bundle/index.d.ts +18 -1
  47. package/js/src_locales_es_419_translation_json/src_locales_es_419_translation_json.js +1 -1
  48. package/js/src_locales_fr_translation_json/src_locales_fr_translation_json.js +1 -1
  49. package/js/src_locales_ja_translation_json/src_locales_ja_translation_json.js +1 -1
  50. package/js/src_locales_ko_translation_json/src_locales_ko_translation_json.js +1 -1
  51. package/js/src_locales_pt_BR_translation_json/src_locales_pt_BR_translation_json.js +1 -1
  52. package/locales/es_419/translation.json +5 -1
  53. package/locales/fr/translation.json +5 -1
  54. package/locales/ja/translation.json +5 -1
  55. package/locales/ko/translation.json +5 -1
  56. package/locales/pt_BR/translation.json +5 -1
  57. package/package.json +1 -1
  58. package/styles/index.css +1 -0
  59. package/styles/index.min.css +1 -1
@@ -7,6 +7,7 @@ exports.useFloatingPanelState = useFloatingPanelState;
7
7
  var _react = require("react");
8
8
  var _hooks = require("../hooks");
9
9
  var _useFloatingPanelRoot = require("./use-floating-panel-root");
10
+ var _types = require("./types");
10
11
  var _constants = require("./constants");
11
12
  const step = 80;
12
13
  const dockAreaWidth = 26;
@@ -35,43 +36,112 @@ function useFloatingPanelState({
35
36
  maxHeight,
36
37
  isDocked: isDockedExternal,
37
38
  setIsDocked: setIsDockedExternal,
39
+ isCollapsed: isCollapsedExternal,
40
+ setIsCollapsed: setIsCollapsedExternal,
38
41
  initialState,
39
42
  containerElement,
40
43
  pageContentElement
41
44
  }) {
42
- const [isDocked, setIsDocked] = (0, _react.useState)(isDockedExternal);
45
+ const [state, setState] = (0, _react.useState)(() => {
46
+ if (isDockedExternal) {
47
+ return _types.PANEL_STATE.DOCKED;
48
+ }
49
+ if (isCollapsedExternal) {
50
+ return _types.PANEL_STATE.COLLAPSED;
51
+ }
52
+ return _types.PANEL_STATE.FLOATING;
53
+ });
43
54
  const [isMoving, setIsMoving] = (0, _react.useState)(false);
55
+ const isDocked = state === _types.PANEL_STATE.DOCKED;
56
+ const isCollapsed = state === _types.PANEL_STATE.COLLAPSED;
57
+ const [position, setPosition] = (0, _react.useState)(initialState ? {
58
+ top: initialState.top,
59
+ left: initialState.left,
60
+ width: between(initialState.width, minWidth, maxWidth),
61
+ height: between(initialState.height, minHeight, maxHeight)
62
+ } : {
63
+ top: 0,
64
+ left: 0,
65
+ width: minWidth,
66
+ height: minHeight
67
+ });
44
68
  const animationRef = (0, _react.useRef)(null);
45
69
  const headerRef = (0, _react.useRef)(null);
46
70
  const headerHeightRef = (0, _react.useRef)(36);
71
+ const lastActiveElementRef = (0, _react.useRef)();
47
72
  const panelRef = (0, _react.useRef)(null);
48
- const dragStartPositionsRef = (0, _react.useRef)();
49
- const isDockHighlightedRef = (0, _react.useRef)(false);
50
- const containerRef = (0, _react.useRef)(containerElement);
51
- const lastPositionRef = (0, _react.useRef)({
52
- top: 0,
73
+ const dragStartPositionsRef = (0, _react.useRef)({
74
+ width: minWidth,
75
+ height: minHeight,
53
76
  left: 0,
54
- width: 0,
55
- height: 0
56
- });
57
- const [state, setState] = (0, _react.useState)(initialState ? {
58
- top: initialState.top || lastPositionRef.current.top,
59
- left: initialState.left || lastPositionRef.current.left,
60
- width: between(initialState.width || lastPositionRef.current.width, minWidth, maxWidth),
61
- height: between(initialState.height || lastPositionRef.current.height, minHeight, maxHeight)
62
- } : {
63
77
  top: 0,
64
- left: 0,
65
- width: minWidth,
66
- height: minHeight
78
+ mouseX: 0,
79
+ mouseY: 0
67
80
  });
68
- lastPositionRef.current = state;
81
+ const containerRef = (0, _react.useRef)(containerElement);
82
+ const lastPositionRef = (0, _react.useRef)(position);
83
+ const lastExpandedPositionRef = (0, _react.useRef)(position);
84
+ const stateRef = (0, _react.useRef)(state);
85
+ stateRef.current = state;
86
+ lastPositionRef.current = position;
69
87
  containerRef.current = containerElement;
70
88
  const style = (0, _react.useMemo)(() => isDocked ? {} : {
71
- transform: `translate3d(${state.left}px, ${state.top}px, 0px)`,
72
- width: `${state.width}px`,
73
- height: `${state.height}px`
74
- }, [state, isDocked]);
89
+ transform: `translate3d(${position.left}px, ${position.top}px, 0px)`,
90
+ width: `${position.width}px`,
91
+ height: `${position.height}px`
92
+ }, [position, isDocked]);
93
+ const runStateTransition = (0, _react.useCallback)(nextState => {
94
+ setState(nextState);
95
+ const getKey = (from, to) => `${from}->${to}`;
96
+ const transitionPairs = {
97
+ [getKey(_types.PANEL_STATE.FLOATING, _types.PANEL_STATE.COLLAPSED)]: () => {
98
+ setIsCollapsedExternal(true);
99
+ },
100
+ [getKey(_types.PANEL_STATE.COLLAPSED, _types.PANEL_STATE.FLOATING)]: () => {
101
+ setIsCollapsedExternal(false);
102
+ },
103
+ [getKey(_types.PANEL_STATE.FLOATING, _types.PANEL_STATE.DOCKED)]: () => {
104
+ setIsDockedExternal(true);
105
+ },
106
+ [getKey(_types.PANEL_STATE.DOCKED, _types.PANEL_STATE.FLOATING)]: () => {
107
+ setIsDockedExternal(false);
108
+ setPosition(state => ({
109
+ ...state,
110
+ top: dragStartPositionsRef.current?.top,
111
+ left: dragStartPositionsRef.current?.left,
112
+ width: lastPositionRef.current.width,
113
+ height: lastPositionRef.current.height
114
+ }));
115
+ },
116
+ [getKey(_types.PANEL_STATE.COLLAPSED, _types.PANEL_STATE.DOCKED)]: () => {
117
+ setIsCollapsedExternal(false);
118
+ setIsDockedExternal(true);
119
+ },
120
+ [getKey(_types.PANEL_STATE.DOCKED, _types.PANEL_STATE.COLLAPSED)]: () => {
121
+ setIsCollapsedExternal(true);
122
+ setIsDockedExternal(false);
123
+ },
124
+ [getKey(_types.PANEL_STATE.FLOATING, _types.PANEL_STATE.TO_BE_DOCKED)]: () => {
125
+ toggleDockHighlight(true, containerRef.current);
126
+ },
127
+ [getKey(_types.PANEL_STATE.TO_BE_DOCKED, _types.PANEL_STATE.FLOATING)]: () => {
128
+ toggleDockHighlight(false, containerRef.current);
129
+ setIsDockedExternal(false);
130
+ },
131
+ [getKey(_types.PANEL_STATE.TO_BE_DOCKED, _types.PANEL_STATE.DOCKED)]: () => {
132
+ setIsDockedExternal(true);
133
+ toggleDockHighlight(false, containerRef.current);
134
+ },
135
+ [getKey(_types.PANEL_STATE.DOCKED, _types.PANEL_STATE.TO_BE_DOCKED)]: () => {
136
+ setIsDockedExternal(false);
137
+ toggleDockHighlight(true, containerRef.current);
138
+ }
139
+ };
140
+ const transition = transitionPairs[getKey(stateRef.current, nextState)];
141
+ if (transition) {
142
+ transition();
143
+ }
144
+ }, [setIsCollapsedExternal, setIsDockedExternal]);
75
145
  const onDrag = (0, _react.useCallback)(event => {
76
146
  if (animationRef.current) {
77
147
  return;
@@ -82,20 +152,11 @@ function useFloatingPanelState({
82
152
  const maxTop = window.innerHeight - headerHeightRef.current;
83
153
  const nextLeft = event.clientX - (start.mouseX - start.left);
84
154
  const nextTop = event.clientY - (start.mouseY - start.top);
85
- setState(state => {
86
- const nextState = {
87
- ...state,
88
- top: between(nextTop, 0, maxTop),
89
- left: between(nextLeft, 0, maxLeft)
90
- };
91
- const nextIsDockHighlighted = isInDockArea(nextState);
92
- // DOM manipulation, not state
93
- if (nextIsDockHighlighted !== isDockHighlightedRef.current) {
94
- toggleDockHighlight(nextIsDockHighlighted, containerRef.current);
95
- isDockHighlightedRef.current = nextIsDockHighlighted;
96
- }
97
- return nextState;
98
- });
155
+ setPosition(position => ({
156
+ ...position,
157
+ top: between(nextTop, 0, maxTop),
158
+ left: between(nextLeft, 0, maxLeft)
159
+ }));
99
160
  animationRef.current = null;
100
161
  });
101
162
  }, []);
@@ -113,27 +174,17 @@ function useFloatingPanelState({
113
174
  mouseX,
114
175
  mouseY
115
176
  };
116
- lastPositionRef.current = dragStartPositionsRef.current;
117
177
  setIsMoving(true);
118
- }, []);
178
+ if (!isCollapsed) {
179
+ lastExpandedPositionRef.current = dragStartPositionsRef.current;
180
+ }
181
+ }, [isCollapsed]);
119
182
  const onDragEnd = (0, _react.useCallback)(() => {
120
- if (isDockHighlightedRef.current) {
121
- const position = dragStartPositionsRef.current;
122
- setIsDocked(true);
123
- setIsDockedExternal(true);
124
- setState(state => {
125
- const nextState = {
126
- ...state,
127
- left: window.innerWidth - position.width - dockAreaWidth * 2
128
- };
129
- lastPositionRef.current = nextState;
130
- return nextState;
131
- });
132
- isDockHighlightedRef.current = false;
133
- toggleDockHighlight(false, containerRef.current);
183
+ if (state === _types.PANEL_STATE.TO_BE_DOCKED) {
184
+ runStateTransition(_types.PANEL_STATE.DOCKED);
134
185
  }
135
186
  setIsMoving(false);
136
- }, []);
187
+ }, [state, runStateTransition]);
137
188
  const onResize = (0, _react.useCallback)(e => {
138
189
  if (animationRef.current) {
139
190
  return;
@@ -157,9 +208,10 @@ function useFloatingPanelState({
157
208
  if (resize?.top) {
158
209
  const height = start.height - (e.pageY - start.mouseY);
159
210
  const nextTop = start.top + (e.pageY - start.mouseY);
160
- if (height > minHeight && height <= maxHeight && nextTop > 0) {
211
+ const nextTopLimited = between(0, nextTop, window.innerHeight - headerHeightRef.current);
212
+ if (height > minHeight && height <= maxHeight && nextTopLimited > 0) {
161
213
  statePatch.height = height;
162
- statePatch.top = nextTop;
214
+ statePatch.top = nextTopLimited;
163
215
  }
164
216
  }
165
217
  if (resize?.left) {
@@ -170,8 +222,8 @@ function useFloatingPanelState({
170
222
  }
171
223
  }
172
224
  if (Object.keys(statePatch).length) {
173
- setState(state => ({
174
- ...state,
225
+ setPosition(position => ({
226
+ ...position,
175
227
  ...statePatch
176
228
  }));
177
229
  }
@@ -180,22 +232,46 @@ function useFloatingPanelState({
180
232
  }, [minWidth, minHeight, maxWidth, maxHeight]);
181
233
  const onResizeEnd = (0, _react.useCallback)(() => {
182
234
  setIsMoving(false);
183
- }, []);
184
- const setIsDockedHandler = (0, _react.useCallback)(docked => {
185
- const element = panelRef.current;
186
- if (!element || docked === isDocked) {
187
- return;
235
+ const nextIsDockHighlighted = isInDockArea({
236
+ ...lastPositionRef.current
237
+ });
238
+ if (nextIsDockHighlighted && state !== _types.PANEL_STATE.DOCKED) {
239
+ runStateTransition(_types.PANEL_STATE.DOCKED);
188
240
  }
241
+ }, [state]);
242
+ const setIsDockedHandler = (0, _react.useCallback)(docked => {
189
243
  if (docked) {
190
- setIsDocked(true);
244
+ const element = panelRef.current;
245
+ dragStartPositionsRef.current = {
246
+ ...getPanelStateFromElement(element),
247
+ mouseX: 0,
248
+ mouseY: 0
249
+ };
250
+ runStateTransition(_types.PANEL_STATE.DOCKED);
191
251
  } else {
192
- setIsDocked(false);
252
+ runStateTransition(_types.PANEL_STATE.FLOATING);
253
+ }
254
+ }, [runStateTransition]);
255
+ const setIsCollapsedHandler = (0, _react.useCallback)(collapsed => {
256
+ if (collapsed === isCollapsed) {
257
+ return;
258
+ }
259
+ if (collapsed && !isDocked) {
260
+ lastExpandedPositionRef.current = getPanelStateFromElement(panelRef.current);
193
261
  }
194
- if (isDockedExternal !== docked) {
195
- setIsDockedExternal(docked);
262
+ if (collapsed) {
263
+ setPosition(position => ({
264
+ ...position,
265
+ top: window.innerHeight - headerHeightRef.current
266
+ }));
267
+ } else {
268
+ setPosition(position => ({
269
+ ...position,
270
+ ...lastExpandedPositionRef.current
271
+ }));
196
272
  }
197
- }, [isDockedExternal, isDocked, setIsDockedExternal]);
198
- const onMoveWithArrows = (0, _react.useCallback)(event => {
273
+ }, [isCollapsed, isDocked]);
274
+ const onMoveWithArrows = event => {
199
275
  if (!_constants.MOVE_KEYS_VALUES.includes(event.key)) {
200
276
  return;
201
277
  }
@@ -210,39 +286,75 @@ function useFloatingPanelState({
210
286
  const maxTop = window.innerHeight - headerHeightRef.current;
211
287
  const nextLeft = currentState.left + dx;
212
288
  const nextTop = currentState.top + dy;
213
- let shouldDockInsteadOfMove = false;
214
289
  const nextState = {
215
- ...state,
290
+ ...position,
216
291
  top: between(nextTop, 0, maxTop),
217
292
  left: between(nextLeft, 0, maxLeft)
218
293
  };
219
- shouldDockInsteadOfMove = isInDockArea(nextState) !== isDocked;
220
- if (shouldDockInsteadOfMove) {
221
- setIsDocked(true);
222
- setIsDockedExternal(true);
294
+ if (nextState.top === lastPositionRef.current.top && nextState.left === lastPositionRef.current.left) {
295
+ return;
296
+ }
297
+ const nextDocked = isInDockArea(nextState);
298
+ if (isDocked && nextDocked === isDocked) {
299
+ return;
300
+ }
301
+ if (nextDocked && !isDocked) {
302
+ dragStartPositionsRef.current = {
303
+ ...currentState,
304
+ mouseX: 0,
305
+ mouseY: 0
306
+ };
307
+ lastExpandedPositionRef.current = dragStartPositionsRef.current;
308
+ runStateTransition(_types.PANEL_STATE.DOCKED);
223
309
  } else {
224
- setState(nextState);
310
+ setPosition(nextState);
225
311
  }
226
- }, [isDocked, state, setIsDockedExternal]);
312
+ };
227
313
  const getPosition = (0, _react.useCallback)(() => {
228
314
  return lastPositionRef.current;
229
315
  }, []);
316
+
317
+ // state transition based on position
318
+ (0, _react.useEffect)(() => {
319
+ const nextCollapsed = isCollapsedPosition(position, headerHeightRef.current);
320
+ const nextIsDockHighlighted = isInDockArea(position);
321
+ if (nextCollapsed && state !== _types.PANEL_STATE.COLLAPSED) {
322
+ runStateTransition(_types.PANEL_STATE.COLLAPSED);
323
+ } else if (nextIsDockHighlighted && ![_types.PANEL_STATE.TO_BE_DOCKED, _types.PANEL_STATE.DOCKED].includes(state)) {
324
+ runStateTransition(_types.PANEL_STATE.TO_BE_DOCKED);
325
+ } else if (!nextCollapsed && !nextIsDockHighlighted && state !== _types.PANEL_STATE.FLOATING) {
326
+ runStateTransition(_types.PANEL_STATE.FLOATING);
327
+ }
328
+ }, [position]);
329
+
330
+ // sync up with external state changes
230
331
  (0, _react.useEffect)(() => {
231
332
  if (isDockedExternal !== isDocked) {
232
333
  setIsDockedHandler(isDockedExternal);
233
334
  }
234
335
  }, [isDockedExternal]);
336
+ (0, _react.useEffect)(() => {
337
+ if (isCollapsedExternal !== isCollapsed) {
338
+ setIsCollapsedHandler(isCollapsedExternal);
339
+ }
340
+ }, [isCollapsedExternal]);
235
341
 
236
342
  // update position on window resize
343
+ // initialise position and sizes
237
344
  (0, _react.useEffect)(() => {
238
345
  const header = headerRef.current;
239
346
  headerHeightRef.current = header.getBoundingClientRect().height;
347
+ dragStartPositionsRef.current = {
348
+ ...getPanelStateFromElement(panelRef.current),
349
+ mouseX: 0,
350
+ mouseY: 0
351
+ };
240
352
  const onResizeHandler = () => {
241
353
  const start = lastPositionRef.current;
242
354
  const maxLeft = window.innerWidth - start.width;
243
355
  const maxTop = window.innerHeight - headerHeightRef.current;
244
356
  if (start.left > maxLeft || start.top > maxTop) {
245
- setState(state => ({
357
+ setPosition(state => ({
246
358
  ...state,
247
359
  top: between(start.top, 0, maxTop),
248
360
  left: between(start.left, 0, maxLeft)
@@ -258,38 +370,63 @@ function useFloatingPanelState({
258
370
  }
259
371
  };
260
372
  }, []);
373
+
374
+ // this allows to return focus to the last active element
375
+ (0, _react.useLayoutEffect)(() => {
376
+ lastActiveElementRef.current = document.activeElement;
377
+ const onEscapeHandler = e => {
378
+ if (e.key === 'Escape') {
379
+ (lastActiveElementRef.current || document.body).focus();
380
+ }
381
+ };
382
+ window.addEventListener('keydown', onEscapeHandler);
383
+ return () => {
384
+ window.addEventListener('keydown', onEscapeHandler);
385
+ };
386
+ }, []);
261
387
  (0, _hooks.useFocusTrap)(panelRef);
262
388
  // update style according to content and header height
263
389
  (0, _useFloatingPanelRoot.useFloatingPanelRoot)({
264
390
  containerElement,
265
391
  pageContentElement
266
392
  });
267
- const context = (0, _react.useMemo)(() => ({
393
+ const context = {
268
394
  onDrag,
269
395
  onDragStart: onMovementStart,
270
396
  onDragEnd,
271
397
  onMoveWithArrows,
272
398
  isDocked,
273
399
  setIsDocked: setIsDockedHandler,
400
+ isCollapsed,
401
+ setIsCollapsed: setIsCollapsedHandler,
274
402
  getPosition,
275
403
  isMoving
276
- }), [isDocked, setIsDockedHandler, onDrag, onDragEnd, onMovementStart, onMoveWithArrows, getPosition, isMoving]);
277
- const api = {
404
+ };
405
+ return {
278
406
  style,
279
407
  panelRef,
280
408
  headerRef,
281
409
  onResize,
282
410
  onMovementStart,
283
411
  onResizeEnd,
284
- setState,
285
- context,
412
+ setPosition,
413
+ context: (0, _react.useMemo)(() => context, Object.values(context)),
286
414
  isDocked,
287
415
  setIsDocked: setIsDockedHandler,
416
+ isCollapsed,
417
+ setIsCollapsed: setIsCollapsedHandler,
288
418
  getPosition
289
419
  };
290
- return (0, _react.useMemo)(() => api, Object.values(api));
291
420
  }
292
421
  function getPanelStateFromElement(element) {
422
+ if (!element) {
423
+ return {
424
+ width: 0,
425
+ height: 0,
426
+ left: 0,
427
+ top: 0
428
+ };
429
+ }
293
430
  const bbox = element.getBoundingClientRect();
294
431
  return {
295
432
  width: bbox.width,
@@ -301,6 +438,9 @@ function getPanelStateFromElement(element) {
301
438
  function isInDockArea(panelPosition) {
302
439
  return panelPosition.left + panelPosition.width > window.innerWidth - dockAreaWidth;
303
440
  }
441
+ function isCollapsedPosition(panelPosition, headerHeight) {
442
+ return window.innerHeight - panelPosition.top <= headerHeight;
443
+ }
304
444
  function toggleDockHighlight(isDockHighlighted, element) {
305
445
  if (!element) {
306
446
  return;
@@ -94,15 +94,5 @@ describe('useAnalytics', function () {
94
94
  prop: 'value'
95
95
  }]);
96
96
  });
97
- it('should pass custom event to provider', function () {
98
- (0, _react.act)(() => hook.result.current.track({
99
- event: 'project_created',
100
- label: 'example_dataset',
101
- property: 'industry',
102
- value: 42
103
- }));
104
- expect(provider.getLastMediator().method).toEqual(_constants.ANALYTICS_METHODS.TRACK);
105
- expect(provider.getLastMediator().args).toEqual(['page.key', 'project_created', 'example_dataset', 'industry', 42, false]);
106
- });
107
97
  });
108
98
  });
@@ -10,7 +10,8 @@ export declare enum DATE_RANGE_ERROR_TYPES {
10
10
  END_AFTER_MIN = "END_AFTER_MIN",
11
11
  START_AFTER_MAX = "START_AFTER_MAX",
12
12
  INVALID_START_DATE = "INVALID_START_DATE",
13
- INVALID_END_DATE = "INVALID_END_DATE"
13
+ INVALID_END_DATE = "INVALID_END_DATE",
14
+ START_END_SAME = "START_END_SAME"
14
15
  }
15
16
  export type DateRangeErrors = {
16
17
  [DATE_RANGE_ERROR_TYPES.INVALID_DATETIME]?: string;
@@ -19,6 +19,7 @@ export let DATE_RANGE_ERROR_TYPES = /*#__PURE__*/function (DATE_RANGE_ERROR_TYPE
19
19
  DATE_RANGE_ERROR_TYPES["START_AFTER_MAX"] = "START_AFTER_MAX";
20
20
  DATE_RANGE_ERROR_TYPES["INVALID_START_DATE"] = "INVALID_START_DATE";
21
21
  DATE_RANGE_ERROR_TYPES["INVALID_END_DATE"] = "INVALID_END_DATE";
22
+ DATE_RANGE_ERROR_TYPES["START_END_SAME"] = "START_END_SAME";
22
23
  return DATE_RANGE_ERROR_TYPES;
23
24
  }({});
24
25
  export const DATE_RANGE_INPUT_TYPES = {
@@ -3,9 +3,11 @@ export const FloatingPanelContext = /*#__PURE__*/createContext({
3
3
  onDrag: () => {},
4
4
  onDragStart: () => {},
5
5
  onDragEnd: () => {},
6
- isDocked: false,
7
6
  isMoving: false,
7
+ isDocked: false,
8
8
  setIsDocked: () => {},
9
+ isCollapsed: false,
10
+ setIsCollapsed: () => {},
9
11
  onMoveWithArrows: () => {},
10
12
  getPosition: () => ({
11
13
  left: 0,
@@ -8,5 +8,6 @@ export type DraggableAreaProps = {
8
8
  onDragEnd?: (event: DraggableEvent | string) => void;
9
9
  children?: React.ReactNode;
10
10
  testId?: string;
11
+ tagName?: keyof JSX.IntrinsicElements;
11
12
  } & Omit<HTMLAttributes<HTMLDivElement>, 'onDragEnd' | 'onDrag' | 'onDragStart'>;
12
13
  export declare function DraggableArea({ areaId, testId, className, onDragStart, onDrag, onDragEnd, children, ...props }: DraggableAreaProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
- import React, { useCallback, useEffect, useState } from 'react';
1
+ import React from 'react';
2
+ import { useDraggableArea } from './use-draggable-area';
2
3
  import { jsx as _jsx } from "react/jsx-runtime";
3
4
  export function DraggableArea({
4
5
  areaId,
@@ -10,50 +11,12 @@ export function DraggableArea({
10
11
  children = null,
11
12
  ...props
12
13
  }) {
13
- const [isDragging, setIsDragging] = useState(false);
14
- const onStart = useCallback(e => {
15
- const draggableEvent = Object.assign(e, {
16
- areaId
17
- });
18
- e.preventDefault();
19
- setIsDragging(true);
20
- onDragStart(draggableEvent);
21
- }, []);
22
- useEffect(() => {
23
- if (!isDragging) {
24
- return;
25
- }
26
- function onDragHandler(e) {
27
- const draggableEvent = Object.assign(e, {
28
- areaId
29
- });
30
- e.preventDefault();
31
- onDrag(draggableEvent);
32
- }
33
- function onDragEndHandler(e) {
34
- const draggableEvent = Object.assign(e, {
35
- areaId
36
- });
37
- e.preventDefault();
38
- removeListeners();
39
- setIsDragging(false);
40
- onDragEnd(draggableEvent);
41
- }
42
- function onDragBlurHandler() {
43
- setIsDragging(false);
44
- onDragEnd(areaId);
45
- removeListeners();
46
- }
47
- window.addEventListener('mousemove', onDragHandler);
48
- window.addEventListener('mouseup', onDragEndHandler);
49
- window.addEventListener('blur', onDragBlurHandler);
50
- function removeListeners() {
51
- window.removeEventListener('mousemove', onDragHandler);
52
- window.removeEventListener('mouseup', onDragEndHandler);
53
- window.removeEventListener('blur', onDragBlurHandler);
54
- }
55
- return removeListeners;
56
- }, [isDragging, onDragStart, onDrag, onDragEnd, areaId]);
14
+ const onStart = useDraggableArea({
15
+ areaId,
16
+ onDragStart,
17
+ onDrag,
18
+ onDragEnd
19
+ });
57
20
  return /*#__PURE__*/_jsx("div", {
58
21
  className: className,
59
22
  onMouseDown: onStart,
@@ -0,0 +1,5 @@
1
+ export type FloatingPanelCollapseButtonProps = {
2
+ isCollapsed: boolean;
3
+ setIsCollapsed: (collapsed: boolean) => void;
4
+ };
5
+ export declare function FloatingPanelCollapseButton({ isCollapsed, setIsCollapsed, }: FloatingPanelCollapseButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { faChevronDown } from '@fortawesome/free-solid-svg-icons/faChevronDown';
3
+ import { faChevronUp } from '@fortawesome/free-solid-svg-icons/faChevronUp';
4
+ import { Button, ACCENT_TYPES } from '../button';
5
+ import { useTranslation } from '../hooks';
6
+ import { FontAwesomeIcon } from '../font-awesome-icon';
7
+ import { TOOLTIP_DELAY_TYPES, TOOLTIP_PLACEMENT_TYPES } from '../tooltip';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ export function FloatingPanelCollapseButton({
10
+ isCollapsed,
11
+ setIsCollapsed
12
+ }) {
13
+ const {
14
+ t
15
+ } = useTranslation();
16
+ const ariaLabel = isCollapsed ? t('Expand') : t('Collapse');
17
+ return /*#__PURE__*/_jsx(Button, {
18
+ testId: "floating-panel-collapse-button",
19
+ accentType: ACCENT_TYPES.ROUND_ICON,
20
+ onClick: () => setIsCollapsed(!isCollapsed),
21
+ "aria-label": ariaLabel,
22
+ tooltipText: ariaLabel,
23
+ tooltipPlacement: TOOLTIP_PLACEMENT_TYPES.TOP,
24
+ tooltipDelayType: TOOLTIP_DELAY_TYPES.SLOW,
25
+ children: /*#__PURE__*/_jsx(FontAwesomeIcon, {
26
+ icon: isCollapsed ? faChevronUp : faChevronDown
27
+ })
28
+ });
29
+ }
@@ -4,7 +4,7 @@ import { faThumbtack } from '@fortawesome/free-solid-svg-icons/faThumbtack';
4
4
  import { Button, ACCENT_TYPES } from '../button';
5
5
  import { useTranslation } from '../hooks';
6
6
  import { FontAwesomeIcon } from '../font-awesome-icon';
7
- import { TOOLTIP_PLACEMENT_TYPES } from '../tooltip';
7
+ import { TOOLTIP_DELAY_TYPES, TOOLTIP_PLACEMENT_TYPES } from '../tooltip';
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export function FloatingPanelDockButton({
10
10
  isDocked,
@@ -21,6 +21,7 @@ export function FloatingPanelDockButton({
21
21
  "aria-label": ariaLabel,
22
22
  tooltipText: ariaLabel,
23
23
  tooltipPlacement: TOOLTIP_PLACEMENT_TYPES.TOP,
24
+ tooltipDelayType: TOOLTIP_DELAY_TYPES.SLOW,
24
25
  children: isDocked ? /*#__PURE__*/_jsx(FontAwesomeIcon, {
25
26
  icon: faThumbtackSlash
26
27
  }) : /*#__PURE__*/_jsx(FontAwesomeIcon, {
@@ -17,16 +17,8 @@ export function FloatingPanelDragHandle({
17
17
  onDrag,
18
18
  onDragStart,
19
19
  onDragEnd,
20
- onMoveWithArrows,
21
- isDocked
20
+ onMoveWithArrows
22
21
  } = useContext(FloatingPanelContext);
23
- if (isDocked) {
24
- return /*#__PURE__*/_jsx("div", {
25
- className: "drag-handle disabled",
26
- "test-id": "floating-area-drag-handle",
27
- children: content
28
- });
29
- }
30
22
  return /*#__PURE__*/_jsx(DraggableArea, {
31
23
  tabIndex: 0,
32
24
  testId: "floating-area-drag-handle",