@datarobot/design-system 29.1.2 → 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.
- package/cjs/datetime-range-picker/datetime-range-picker-panel.d.ts +2 -1
- package/cjs/datetime-range-picker/datetime-range-picker-panel.js +1 -0
- package/cjs/floating-panel/constants.js +3 -1
- package/cjs/floating-panel/draggable-area.d.ts +1 -0
- package/cjs/floating-panel/draggable-area.js +9 -46
- package/cjs/floating-panel/floating-panel-collapse-button.d.ts +5 -0
- package/cjs/floating-panel/floating-panel-collapse-button.js +36 -0
- package/cjs/floating-panel/floating-panel-dock-button.js +1 -0
- package/cjs/floating-panel/floating-panel-drag-handle.js +1 -9
- package/cjs/floating-panel/floating-panel-header.js +49 -20
- package/cjs/floating-panel/floating-panel.d.ts +8 -0
- package/cjs/floating-panel/floating-panel.js +8 -4
- package/cjs/floating-panel/types.d.ts +8 -0
- package/cjs/floating-panel/types.js +9 -1
- package/cjs/floating-panel/use-draggable-area.d.ts +17 -0
- package/cjs/floating-panel/use-draggable-area.js +70 -0
- package/cjs/floating-panel/use-floating-panel-state.d.ts +6 -2
- package/cjs/floating-panel/use-floating-panel-state.js +224 -84
- package/esm/datetime-range-picker/datetime-range-picker-panel.d.ts +2 -1
- package/esm/datetime-range-picker/datetime-range-picker-panel.js +1 -0
- package/esm/floating-panel/constants.js +3 -1
- package/esm/floating-panel/draggable-area.d.ts +1 -0
- package/esm/floating-panel/draggable-area.js +8 -45
- package/esm/floating-panel/floating-panel-collapse-button.d.ts +5 -0
- package/esm/floating-panel/floating-panel-collapse-button.js +29 -0
- package/esm/floating-panel/floating-panel-dock-button.js +2 -1
- package/esm/floating-panel/floating-panel-drag-handle.js +1 -9
- package/esm/floating-panel/floating-panel-header.js +50 -21
- package/esm/floating-panel/floating-panel.d.ts +8 -0
- package/esm/floating-panel/floating-panel.js +8 -4
- package/esm/floating-panel/types.d.ts +8 -0
- package/esm/floating-panel/types.js +7 -1
- package/esm/floating-panel/use-draggable-area.d.ts +17 -0
- package/esm/floating-panel/use-draggable-area.js +64 -0
- package/esm/floating-panel/use-floating-panel-state.d.ts +6 -2
- package/esm/floating-panel/use-floating-panel-state.js +226 -86
- package/js/139/139.min.js +1 -1
- package/js/244/244.min.js +1 -1
- package/js/633/633.min.js +1 -1
- package/js/784/784.min.js +1 -1
- package/js/86/86.min.js +1 -1
- package/js/bundle/bundle.js +467 -191
- package/js/bundle/bundle.min.js +1 -1
- package/js/bundle/index.d.ts +18 -1
- package/js/src_locales_es_419_translation_json/src_locales_es_419_translation_json.js +1 -1
- package/js/src_locales_fr_translation_json/src_locales_fr_translation_json.js +1 -1
- package/js/src_locales_ja_translation_json/src_locales_ja_translation_json.js +1 -1
- package/js/src_locales_ko_translation_json/src_locales_ko_translation_json.js +1 -1
- package/js/src_locales_pt_BR_translation_json/src_locales_pt_BR_translation_json.js +1 -1
- package/locales/es_419/translation.json +5 -1
- package/locales/fr/translation.json +5 -1
- package/locales/ja/translation.json +5 -1
- package/locales/ko/translation.json +5 -1
- package/locales/pt_BR/translation.json +5 -1
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -27,6 +27,7 @@ let DATE_RANGE_ERROR_TYPES = exports.DATE_RANGE_ERROR_TYPES = /*#__PURE__*/funct
|
|
|
27
27
|
DATE_RANGE_ERROR_TYPES["START_AFTER_MAX"] = "START_AFTER_MAX";
|
|
28
28
|
DATE_RANGE_ERROR_TYPES["INVALID_START_DATE"] = "INVALID_START_DATE";
|
|
29
29
|
DATE_RANGE_ERROR_TYPES["INVALID_END_DATE"] = "INVALID_END_DATE";
|
|
30
|
+
DATE_RANGE_ERROR_TYPES["START_END_SAME"] = "START_END_SAME";
|
|
30
31
|
return DATE_RANGE_ERROR_TYPES;
|
|
31
32
|
}({});
|
|
32
33
|
const DATE_RANGE_INPUT_TYPES = exports.DATE_RANGE_INPUT_TYPES = {
|
|
@@ -11,9 +11,11 @@ const FloatingPanelContext = exports.FloatingPanelContext = /*#__PURE__*/(0, _re
|
|
|
11
11
|
onDrag: () => {},
|
|
12
12
|
onDragStart: () => {},
|
|
13
13
|
onDragEnd: () => {},
|
|
14
|
-
isDocked: false,
|
|
15
14
|
isMoving: false,
|
|
15
|
+
isDocked: false,
|
|
16
16
|
setIsDocked: () => {},
|
|
17
|
+
isCollapsed: false,
|
|
18
|
+
setIsCollapsed: () => {},
|
|
17
19
|
onMoveWithArrows: () => {},
|
|
18
20
|
getPosition: () => ({
|
|
19
21
|
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;
|
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DraggableArea = DraggableArea;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _useDraggableArea = require("./use-draggable-area");
|
|
8
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
-
function
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
11
|
function DraggableArea({
|
|
11
12
|
areaId,
|
|
12
13
|
testId,
|
|
@@ -17,50 +18,12 @@ function DraggableArea({
|
|
|
17
18
|
children = null,
|
|
18
19
|
...props
|
|
19
20
|
}) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
setIsDragging(true);
|
|
27
|
-
onDragStart(draggableEvent);
|
|
28
|
-
}, []);
|
|
29
|
-
(0, _react.useEffect)(() => {
|
|
30
|
-
if (!isDragging) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
function onDragHandler(e) {
|
|
34
|
-
const draggableEvent = Object.assign(e, {
|
|
35
|
-
areaId
|
|
36
|
-
});
|
|
37
|
-
e.preventDefault();
|
|
38
|
-
onDrag(draggableEvent);
|
|
39
|
-
}
|
|
40
|
-
function onDragEndHandler(e) {
|
|
41
|
-
const draggableEvent = Object.assign(e, {
|
|
42
|
-
areaId
|
|
43
|
-
});
|
|
44
|
-
e.preventDefault();
|
|
45
|
-
removeListeners();
|
|
46
|
-
setIsDragging(false);
|
|
47
|
-
onDragEnd(draggableEvent);
|
|
48
|
-
}
|
|
49
|
-
function onDragBlurHandler() {
|
|
50
|
-
setIsDragging(false);
|
|
51
|
-
onDragEnd(areaId);
|
|
52
|
-
removeListeners();
|
|
53
|
-
}
|
|
54
|
-
window.addEventListener('mousemove', onDragHandler);
|
|
55
|
-
window.addEventListener('mouseup', onDragEndHandler);
|
|
56
|
-
window.addEventListener('blur', onDragBlurHandler);
|
|
57
|
-
function removeListeners() {
|
|
58
|
-
window.removeEventListener('mousemove', onDragHandler);
|
|
59
|
-
window.removeEventListener('mouseup', onDragEndHandler);
|
|
60
|
-
window.removeEventListener('blur', onDragBlurHandler);
|
|
61
|
-
}
|
|
62
|
-
return removeListeners;
|
|
63
|
-
}, [isDragging, onDragStart, onDrag, onDragEnd, areaId]);
|
|
21
|
+
const onStart = (0, _useDraggableArea.useDraggableArea)({
|
|
22
|
+
areaId,
|
|
23
|
+
onDragStart,
|
|
24
|
+
onDrag,
|
|
25
|
+
onDragEnd
|
|
26
|
+
});
|
|
64
27
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
65
28
|
className: className,
|
|
66
29
|
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,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FloatingPanelCollapseButton = FloatingPanelCollapseButton;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _faChevronDown = require("@fortawesome/free-solid-svg-icons/faChevronDown");
|
|
9
|
+
var _faChevronUp = require("@fortawesome/free-solid-svg-icons/faChevronUp");
|
|
10
|
+
var _button = require("../button");
|
|
11
|
+
var _hooks = require("../hooks");
|
|
12
|
+
var _fontAwesomeIcon = require("../font-awesome-icon");
|
|
13
|
+
var _tooltip = require("../tooltip");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
function FloatingPanelCollapseButton({
|
|
17
|
+
isCollapsed,
|
|
18
|
+
setIsCollapsed
|
|
19
|
+
}) {
|
|
20
|
+
const {
|
|
21
|
+
t
|
|
22
|
+
} = (0, _hooks.useTranslation)();
|
|
23
|
+
const ariaLabel = isCollapsed ? t('Expand') : t('Collapse');
|
|
24
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
25
|
+
testId: "floating-panel-collapse-button",
|
|
26
|
+
accentType: _button.ACCENT_TYPES.ROUND_ICON,
|
|
27
|
+
onClick: () => setIsCollapsed(!isCollapsed),
|
|
28
|
+
"aria-label": ariaLabel,
|
|
29
|
+
tooltipText: ariaLabel,
|
|
30
|
+
tooltipPlacement: _tooltip.TOOLTIP_PLACEMENT_TYPES.TOP,
|
|
31
|
+
tooltipDelayType: _tooltip.TOOLTIP_DELAY_TYPES.SLOW,
|
|
32
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
|
|
33
|
+
icon: isCollapsed ? _faChevronUp.faChevronUp : _faChevronDown.faChevronDown
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -28,6 +28,7 @@ function FloatingPanelDockButton({
|
|
|
28
28
|
"aria-label": ariaLabel,
|
|
29
29
|
tooltipText: ariaLabel,
|
|
30
30
|
tooltipPlacement: _tooltip.TOOLTIP_PLACEMENT_TYPES.TOP,
|
|
31
|
+
tooltipDelayType: _tooltip.TOOLTIP_DELAY_TYPES.SLOW,
|
|
31
32
|
children: isDocked ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
|
|
32
33
|
icon: _faThumbtackSlash.faThumbtackSlash
|
|
33
34
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
|
|
@@ -24,16 +24,8 @@ function FloatingPanelDragHandle({
|
|
|
24
24
|
onDrag,
|
|
25
25
|
onDragStart,
|
|
26
26
|
onDragEnd,
|
|
27
|
-
onMoveWithArrows
|
|
28
|
-
isDocked
|
|
27
|
+
onMoveWithArrows
|
|
29
28
|
} = (0, _react.useContext)(_constants.FloatingPanelContext);
|
|
30
|
-
if (isDocked) {
|
|
31
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
32
|
-
className: "drag-handle disabled",
|
|
33
|
-
"test-id": "floating-area-drag-handle",
|
|
34
|
-
children: content
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
29
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_draggableArea.DraggableArea, {
|
|
38
30
|
tabIndex: 0,
|
|
39
31
|
testId: "floating-area-drag-handle",
|
|
@@ -11,6 +11,9 @@ var _fontAwesomeIcon = require("../font-awesome-icon");
|
|
|
11
11
|
var _useTranslation = require("../hooks/use-translation");
|
|
12
12
|
var _floatingPanelDockButton = require("./floating-panel-dock-button");
|
|
13
13
|
var _floatingPanelDragHandle = require("./floating-panel-drag-handle");
|
|
14
|
+
var _useDraggableArea = require("./use-draggable-area");
|
|
15
|
+
var _constants = require("./constants");
|
|
16
|
+
var _floatingPanelCollapseButton = require("./floating-panel-collapse-button");
|
|
14
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
19
|
const FloatingPanelHeader = exports.FloatingPanelHeader = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
@@ -24,26 +27,52 @@ const FloatingPanelHeader = exports.FloatingPanelHeader = /*#__PURE__*/(0, _reac
|
|
|
24
27
|
const {
|
|
25
28
|
t
|
|
26
29
|
} = (0, _useTranslation.useTranslation)();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
accentType: _button.ACCENT_TYPES.ROUND_ICON,
|
|
40
|
-
onClick: () => onClose(getPosition()),
|
|
41
|
-
"aria-label": t('Close'),
|
|
42
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
|
|
43
|
-
icon: _faXmark.faXmark
|
|
44
|
-
})
|
|
45
|
-
})]
|
|
46
|
-
})]
|
|
30
|
+
const {
|
|
31
|
+
onDrag,
|
|
32
|
+
onDragStart,
|
|
33
|
+
onDragEnd,
|
|
34
|
+
isCollapsed,
|
|
35
|
+
setIsCollapsed
|
|
36
|
+
} = (0, _react.useContext)(_constants.FloatingPanelContext);
|
|
37
|
+
const onStart = (0, _useDraggableArea.useDraggableArea)({
|
|
38
|
+
areaId: 'drag-header',
|
|
39
|
+
onDrag,
|
|
40
|
+
onDragStart,
|
|
41
|
+
onDragEnd
|
|
47
42
|
});
|
|
43
|
+
return (
|
|
44
|
+
/*#__PURE__*/
|
|
45
|
+
// FloatingPanelDragHandle is responsible for accessibility of the drag handle
|
|
46
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
47
|
+
(0, _jsxRuntime.jsxs)("header", {
|
|
48
|
+
ref: ref,
|
|
49
|
+
className: "floating-panel-header",
|
|
50
|
+
onMouseDown: onStart,
|
|
51
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingPanelDragHandle.FloatingPanelDragHandle, {
|
|
52
|
+
dragIcon: dragIcon
|
|
53
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
54
|
+
className: "actions",
|
|
55
|
+
onMouseDown: event => {
|
|
56
|
+
// Prevent dragging when clicking on action buttons
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
},
|
|
59
|
+
children: [actions, /*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingPanelCollapseButton.FloatingPanelCollapseButton, {
|
|
60
|
+
isCollapsed: isCollapsed,
|
|
61
|
+
setIsCollapsed: setIsCollapsed
|
|
62
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_floatingPanelDockButton.FloatingPanelDockButton, {
|
|
63
|
+
isDocked: isDocked,
|
|
64
|
+
setIsDocked: setIsDocked
|
|
65
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
66
|
+
testId: "floating-panel-close-action",
|
|
67
|
+
accentType: _button.ACCENT_TYPES.ROUND_ICON,
|
|
68
|
+
onClick: () => onClose(getPosition()),
|
|
69
|
+
"aria-label": t('Close'),
|
|
70
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
|
|
71
|
+
icon: _faXmark.faXmark
|
|
72
|
+
})
|
|
73
|
+
})]
|
|
74
|
+
})]
|
|
75
|
+
})
|
|
76
|
+
);
|
|
48
77
|
});
|
|
49
78
|
FloatingPanelHeader.displayName = 'FloatingPanelHeader';
|
|
@@ -49,6 +49,14 @@ export type FloatingPanelProps = {
|
|
|
49
49
|
* Use this to sync up the docked state with consumer when controlled outside
|
|
50
50
|
*/
|
|
51
51
|
setIsDocked?: Dispatch<SetStateAction<boolean>>;
|
|
52
|
+
/**
|
|
53
|
+
* Use this to control collapsed state outside the component
|
|
54
|
+
*/
|
|
55
|
+
isCollapsed?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Use this to sync up the collapsed state with consumer when controlled outside
|
|
58
|
+
*/
|
|
59
|
+
setIsCollapsed?: Dispatch<SetStateAction<boolean>>;
|
|
52
60
|
/**
|
|
53
61
|
* Use this in consumer to update `initialState` in order to preserve last position
|
|
54
62
|
*/
|
|
@@ -56,8 +56,9 @@ function FloatingPanel({
|
|
|
56
56
|
onResize,
|
|
57
57
|
onMovementStart,
|
|
58
58
|
onResizeEnd,
|
|
59
|
-
|
|
59
|
+
setPosition,
|
|
60
60
|
isDocked,
|
|
61
|
+
isCollapsed,
|
|
61
62
|
setIsDocked,
|
|
62
63
|
getPosition,
|
|
63
64
|
context
|
|
@@ -69,6 +70,8 @@ function FloatingPanel({
|
|
|
69
70
|
initialState,
|
|
70
71
|
isDocked: props.isDocked ?? false,
|
|
71
72
|
setIsDocked: props.setIsDocked ?? noop,
|
|
73
|
+
isCollapsed: props.isCollapsed ?? false,
|
|
74
|
+
setIsCollapsed: props.setIsCollapsed ?? noop,
|
|
72
75
|
containerElement,
|
|
73
76
|
pageContentElement: (0, _constants.getHtmlElement)(pageContentEl)
|
|
74
77
|
});
|
|
@@ -81,7 +84,7 @@ function FloatingPanel({
|
|
|
81
84
|
panelRef.current.focus();
|
|
82
85
|
if (initialState && !initialStateAppliedOnce.current) {
|
|
83
86
|
initialStateAppliedOnce.current = true;
|
|
84
|
-
return
|
|
87
|
+
return setPosition(initialState);
|
|
85
88
|
}
|
|
86
89
|
if (!anchorEl) {
|
|
87
90
|
return;
|
|
@@ -95,7 +98,7 @@ function FloatingPanel({
|
|
|
95
98
|
left,
|
|
96
99
|
top
|
|
97
100
|
} = panelRef.current.getBoundingClientRect();
|
|
98
|
-
|
|
101
|
+
setPosition(state => ({
|
|
99
102
|
...state,
|
|
100
103
|
left,
|
|
101
104
|
top
|
|
@@ -110,7 +113,8 @@ function FloatingPanel({
|
|
|
110
113
|
ref: panelRef,
|
|
111
114
|
"test-id": testId,
|
|
112
115
|
className: (0, _classnames.default)('floating-panel', {
|
|
113
|
-
docked: isDocked
|
|
116
|
+
docked: isDocked,
|
|
117
|
+
collapsed: isCollapsed
|
|
114
118
|
})
|
|
115
119
|
/* eslint-disable-next-line react/forbid-dom-props */,
|
|
116
120
|
style: style,
|
|
@@ -8,6 +8,12 @@ export type PanelState = {
|
|
|
8
8
|
export type DraggableEvent = MouseEvent & {
|
|
9
9
|
areaId: string;
|
|
10
10
|
};
|
|
11
|
+
export declare enum PANEL_STATE {
|
|
12
|
+
FLOATING = "floating",
|
|
13
|
+
COLLAPSED = "collapsed",
|
|
14
|
+
DOCKED = "docked",
|
|
15
|
+
TO_BE_DOCKED = "to-be-docked"
|
|
16
|
+
}
|
|
11
17
|
export type FloatingPanelContextType = {
|
|
12
18
|
onDrag: (event: DraggableEvent) => void;
|
|
13
19
|
onDragStart: (event: DraggableEvent) => void;
|
|
@@ -15,6 +21,8 @@ export type FloatingPanelContextType = {
|
|
|
15
21
|
onMoveWithArrows: (event: React.KeyboardEvent) => void;
|
|
16
22
|
isDocked: boolean;
|
|
17
23
|
setIsDocked: (docked: boolean) => void;
|
|
24
|
+
isCollapsed: boolean;
|
|
25
|
+
setIsCollapsed: (docked: boolean) => void;
|
|
18
26
|
isMoving: boolean;
|
|
19
27
|
getPosition: () => PanelState;
|
|
20
28
|
};
|
|
@@ -2,4 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
});
|
|
5
|
+
});
|
|
6
|
+
exports.PANEL_STATE = void 0;
|
|
7
|
+
let PANEL_STATE = exports.PANEL_STATE = /*#__PURE__*/function (PANEL_STATE) {
|
|
8
|
+
PANEL_STATE["FLOATING"] = "floating";
|
|
9
|
+
PANEL_STATE["COLLAPSED"] = "collapsed";
|
|
10
|
+
PANEL_STATE["DOCKED"] = "docked";
|
|
11
|
+
PANEL_STATE["TO_BE_DOCKED"] = "to-be-docked";
|
|
12
|
+
return PANEL_STATE;
|
|
13
|
+
}({});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DraggableEvent } from '@datarobot/design-system/floating-panel/types';
|
|
3
|
+
export type DraggableArea = {
|
|
4
|
+
areaId: string;
|
|
5
|
+
onDragStart?: (event: DraggableEvent) => void;
|
|
6
|
+
onDrag: (event: DraggableEvent) => void;
|
|
7
|
+
onDragEnd?: (event: DraggableEvent | string) => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param areaId
|
|
12
|
+
* @param onDragStart
|
|
13
|
+
* @param onDrag
|
|
14
|
+
* @param onDragEnd
|
|
15
|
+
* @returns onStart function to be used in onMouseDown event
|
|
16
|
+
*/
|
|
17
|
+
export declare function useDraggableArea({ areaId, onDragStart, onDrag, onDragEnd, }: DraggableArea): (e: React.MouseEvent<Element>) => void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDraggableArea = useDraggableArea;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param areaId
|
|
11
|
+
* @param onDragStart
|
|
12
|
+
* @param onDrag
|
|
13
|
+
* @param onDragEnd
|
|
14
|
+
* @returns onStart function to be used in onMouseDown event
|
|
15
|
+
*/
|
|
16
|
+
function useDraggableArea({
|
|
17
|
+
areaId,
|
|
18
|
+
onDragStart = () => {},
|
|
19
|
+
onDrag,
|
|
20
|
+
onDragEnd = () => {}
|
|
21
|
+
}) {
|
|
22
|
+
const [isDragging, setIsDragging] = (0, _react.useState)(false);
|
|
23
|
+
const onStart = e => {
|
|
24
|
+
const draggableEvent = Object.assign(e, {
|
|
25
|
+
areaId
|
|
26
|
+
});
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
setIsDragging(true);
|
|
30
|
+
onDragStart(draggableEvent);
|
|
31
|
+
};
|
|
32
|
+
(0, _react.useEffect)(() => {
|
|
33
|
+
if (!isDragging) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
function onDragHandler(e) {
|
|
37
|
+
const draggableEvent = Object.assign(e, {
|
|
38
|
+
areaId
|
|
39
|
+
});
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
onDrag(draggableEvent);
|
|
43
|
+
}
|
|
44
|
+
function onDragEndHandler(e) {
|
|
45
|
+
const draggableEvent = Object.assign(e, {
|
|
46
|
+
areaId
|
|
47
|
+
});
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
removeListeners();
|
|
51
|
+
setIsDragging(false);
|
|
52
|
+
onDragEnd(draggableEvent);
|
|
53
|
+
}
|
|
54
|
+
function onDragBlurHandler() {
|
|
55
|
+
setIsDragging(false);
|
|
56
|
+
onDragEnd(areaId);
|
|
57
|
+
removeListeners();
|
|
58
|
+
}
|
|
59
|
+
window.addEventListener('mousemove', onDragHandler);
|
|
60
|
+
window.addEventListener('mouseup', onDragEndHandler);
|
|
61
|
+
window.addEventListener('blur', onDragBlurHandler);
|
|
62
|
+
function removeListeners() {
|
|
63
|
+
window.removeEventListener('mousemove', onDragHandler);
|
|
64
|
+
window.removeEventListener('mouseup', onDragEndHandler);
|
|
65
|
+
window.removeEventListener('blur', onDragBlurHandler);
|
|
66
|
+
}
|
|
67
|
+
return removeListeners;
|
|
68
|
+
}, [isDragging, onDragStart, onDrag, onDragEnd, areaId]);
|
|
69
|
+
return onStart;
|
|
70
|
+
}
|
|
@@ -8,9 +8,11 @@ export type UseFloatingPanelHook = {
|
|
|
8
8
|
onResize: (event: DraggableEvent) => void;
|
|
9
9
|
onMovementStart: (event: DraggableEvent) => void;
|
|
10
10
|
onResizeEnd: (event: DraggableEvent | string) => void;
|
|
11
|
-
|
|
11
|
+
setPosition: Dispatch<SetStateAction<PanelState>>;
|
|
12
12
|
isDocked: boolean;
|
|
13
13
|
setIsDocked: (docked: boolean) => void;
|
|
14
|
+
isCollapsed: boolean;
|
|
15
|
+
setIsCollapsed: (collapsed: boolean) => void;
|
|
14
16
|
getPosition: () => PanelState;
|
|
15
17
|
};
|
|
16
18
|
export type UseFloatingPanelParams = {
|
|
@@ -20,8 +22,10 @@ export type UseFloatingPanelParams = {
|
|
|
20
22
|
maxHeight: number;
|
|
21
23
|
isDocked: boolean;
|
|
22
24
|
setIsDocked: Dispatch<SetStateAction<boolean>>;
|
|
25
|
+
isCollapsed: boolean;
|
|
26
|
+
setIsCollapsed: Dispatch<SetStateAction<boolean>>;
|
|
23
27
|
initialState?: PanelState;
|
|
24
28
|
containerElement: HTMLElement;
|
|
25
29
|
pageContentElement?: HTMLElement;
|
|
26
30
|
};
|
|
27
|
-
export declare function useFloatingPanelState({ minWidth, minHeight, maxWidth, maxHeight, isDocked: isDockedExternal, setIsDocked: setIsDockedExternal, initialState, containerElement, pageContentElement, }: UseFloatingPanelParams): UseFloatingPanelHook;
|
|
31
|
+
export declare function useFloatingPanelState({ minWidth, minHeight, maxWidth, maxHeight, isDocked: isDockedExternal, setIsDocked: setIsDockedExternal, isCollapsed: isCollapsedExternal, setIsCollapsed: setIsCollapsedExternal, initialState, containerElement, pageContentElement, }: UseFloatingPanelParams): UseFloatingPanelHook;
|