@perses-dev/components 0.55.0-rc.1 → 0.56.0-beta.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/dist/AlignSelector/AlignSelector.js +115 -25
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/CodeEditor/CodeEditor.d.ts +19 -0
- package/dist/CodeEditor/CodeEditor.d.ts.map +1 -0
- package/dist/CodeEditor/CodeEditor.js +122 -0
- package/dist/CodeEditor/CodeEditor.js.map +1 -0
- package/dist/ColorPicker/ColorPicker.js +153 -61
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +147 -52
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +144 -41
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/DensitySelector/DensitySelector.js +53 -20
- package/dist/DensitySelector/DensitySelector.js.map +1 -1
- package/dist/Dialog/Dialog.d.ts +3 -2
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +202 -49
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +79 -27
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +184 -113
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +131 -52
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +51 -26
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js +75 -15
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.js +179 -90
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/ErrorAlert.js +14 -4
- package/dist/ErrorAlert.js.map +1 -1
- package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js +463 -190
- package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js.map +1 -1
- package/dist/FontSizeSelector/FontSizeSelector.js +82 -50
- package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
- package/dist/FormEditor/FormActions.js +88 -14
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormatControls/FormatControls.js +246 -99
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/FormatControls/UnitSelector.js +90 -25
- package/dist/FormatControls/UnitSelector.js.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +105 -42
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/JSONEditor.d.ts +2 -6
- package/dist/JSONEditor.d.ts.map +1 -1
- package/dist/JSONEditor.js +24 -37
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +77 -27
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +184 -82
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +54 -9
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +46 -16
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +184 -48
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +90 -48
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/Legend/legend-model.d.ts +2 -2
- package/dist/Legend/legend-model.d.ts.map +1 -1
- package/dist/Legend/legend-model.js.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js +148 -67
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/ModeSelector/ModeSelector.js +61 -19
- package/dist/ModeSelector/ModeSelector.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +20 -9
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +130 -54
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +17 -6
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +76 -28
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/Overlay/Overlay.js +71 -27
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +96 -38
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/RepeatGrid/RepeatGrid.js +117 -45
- package/dist/RepeatGrid/RepeatGrid.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +99 -38
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelector.js +51 -18
- package/dist/SortSelector/SortSelector.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +109 -25
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.js +46 -15
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +3 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +410 -158
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +15 -4
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.js +284 -107
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +101 -32
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +15 -4
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +15 -4
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.js +119 -62
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +33 -9
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +5 -4
- package/dist/Table/TableToolbar.d.ts.map +1 -1
- package/dist/Table/TableToolbar.js +172 -100
- package/dist/Table/TableToolbar.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts +11 -11
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +387 -219
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +27 -7
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +6 -5
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.js +57 -32
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js +115 -74
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +74 -53
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +44 -15
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +33 -1
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +137 -47
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +341 -174
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +368 -162
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +580 -209
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +189 -65
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +168 -78
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +38 -11
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +229 -72
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +73 -27
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +221 -121
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +44 -38
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeZoneSelector.js +131 -36
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +18 -7
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +830 -334
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +252 -90
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +170 -59
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +800 -322
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +218 -91
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/YAMLEditor/YAMLEditor.d.ts +12 -0
- package/dist/YAMLEditor/YAMLEditor.d.ts.map +1 -0
- package/dist/YAMLEditor/YAMLEditor.js +41 -0
- package/dist/YAMLEditor/YAMLEditor.js.map +1 -0
- package/dist/YAMLEditor/index.d.ts +2 -0
- package/dist/YAMLEditor/index.d.ts.map +1 -0
- package/dist/YAMLEditor/index.js +15 -0
- package/dist/YAMLEditor/index.js.map +1 -0
- package/dist/YAMLEditor/yaml-utils.d.ts +11 -0
- package/dist/YAMLEditor/yaml-utils.d.ts.map +1 -0
- package/dist/YAMLEditor/yaml-utils.js +52 -0
- package/dist/YAMLEditor/yaml-utils.js.map +1 -0
- package/dist/YAxisLabel.js +64 -20
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/context/ChartsProvider.js +32 -16
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js +110 -61
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js +170 -66
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.js +101 -44
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +35 -14
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +86 -25
- package/dist/controls/TextField.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/browser-storage.js +64 -34
- package/dist/utils/browser-storage.js.map +1 -1
- package/dist/utils/time-series-data.d.ts.map +1 -1
- package/dist/utils/time-series-data.js +5 -2
- package/dist/utils/time-series-data.js.map +1 -1
- package/package.json +13 -7
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c as _c } from "react-compiler-runtime";
|
|
2
3
|
// Copyright The Perses Authors
|
|
3
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -27,129 +28,199 @@ import { idle } from "./model.js";
|
|
|
27
28
|
* @param accessKey - The key to use to identify the elements (key of the object)
|
|
28
29
|
* @param axis - The axis to monitor the drag and drop on
|
|
29
30
|
* @param onChange - The function to call when a drop is detected
|
|
30
|
-
*/ export function useDragAndDropMonitor(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
*/ export function useDragAndDropMonitor(t0) {
|
|
32
|
+
const $ = _c(6);
|
|
33
|
+
const { elements, accessKey, axis: t1, onChange } = t0;
|
|
34
|
+
const axis = t1 === undefined ? "vertical" : t1;
|
|
35
|
+
let t2;
|
|
36
|
+
let t3;
|
|
37
|
+
if ($[0] !== accessKey || $[1] !== axis || $[2] !== elements || $[3] !== onChange) {
|
|
38
|
+
t2 = ()=>monitorForElements({
|
|
39
|
+
onDrop (t4) {
|
|
40
|
+
const { location, source } = t4;
|
|
41
|
+
const target = location.current.dropTargets[0];
|
|
42
|
+
if (!target) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const sourceData = source.data;
|
|
46
|
+
const targetData = target.data;
|
|
47
|
+
const indexOfSource = elements.findIndex((column)=>column[accessKey] === sourceData[accessKey]);
|
|
48
|
+
const indexOfTarget = elements.findIndex((column_0)=>column_0[accessKey] === targetData[accessKey]);
|
|
49
|
+
if (indexOfTarget < 0 || indexOfSource < 0) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const closestEdgeOfTarget = extractClosestEdge(targetData);
|
|
53
|
+
onChange(reorderWithEdge({
|
|
54
|
+
list: elements,
|
|
55
|
+
startIndex: indexOfSource,
|
|
56
|
+
indexOfTarget,
|
|
57
|
+
closestEdgeOfTarget,
|
|
58
|
+
axis
|
|
59
|
+
}));
|
|
44
60
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
});
|
|
62
|
+
t3 = [
|
|
63
|
+
accessKey,
|
|
64
|
+
axis,
|
|
65
|
+
elements,
|
|
66
|
+
onChange
|
|
67
|
+
];
|
|
68
|
+
$[0] = accessKey;
|
|
69
|
+
$[1] = axis;
|
|
70
|
+
$[2] = elements;
|
|
71
|
+
$[3] = onChange;
|
|
72
|
+
$[4] = t2;
|
|
73
|
+
$[5] = t3;
|
|
74
|
+
} else {
|
|
75
|
+
t2 = $[4];
|
|
76
|
+
t3 = $[5];
|
|
77
|
+
}
|
|
78
|
+
return useEffect(t2, t3);
|
|
61
79
|
}
|
|
62
80
|
/**
|
|
63
81
|
* This component wraps the children that should be draggable.
|
|
64
|
-
*/ export function DragAndDropElement(
|
|
82
|
+
*/ export function DragAndDropElement(t0) {
|
|
83
|
+
const $ = _c(17);
|
|
84
|
+
const { children, data, dragHandleRef } = t0;
|
|
65
85
|
const ref = useRef(null);
|
|
66
86
|
const [state, setState] = useState(idle);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
dragHandle: dragHandleRef?.current ?? undefined,
|
|
75
|
-
getInitialData () {
|
|
76
|
-
return data;
|
|
77
|
-
},
|
|
78
|
-
onDragStart () {
|
|
79
|
-
setState({
|
|
80
|
-
type: 'is-dragging'
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
onDrop () {
|
|
84
|
-
setState(idle);
|
|
87
|
+
let t1;
|
|
88
|
+
let t2;
|
|
89
|
+
if ($[0] !== data || $[1] !== dragHandleRef) {
|
|
90
|
+
t1 = ()=>{
|
|
91
|
+
const element = ref.current;
|
|
92
|
+
if (!element) {
|
|
93
|
+
return;
|
|
85
94
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
return combine(draggable({
|
|
96
|
+
element,
|
|
97
|
+
dragHandle: dragHandleRef?.current ?? undefined,
|
|
98
|
+
getInitialData () {
|
|
99
|
+
return data;
|
|
100
|
+
},
|
|
101
|
+
onDragStart () {
|
|
102
|
+
setState({
|
|
103
|
+
type: "is-dragging"
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
onDrop () {
|
|
107
|
+
setState(idle);
|
|
92
108
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
input,
|
|
100
|
-
allowedEdges: [
|
|
101
|
-
'top',
|
|
102
|
-
'bottom'
|
|
103
|
-
]
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
getIsSticky () {
|
|
107
|
-
return true;
|
|
108
|
-
},
|
|
109
|
-
onDragEnter ({ self }) {
|
|
110
|
-
const closestEdge = extractClosestEdge(self.data);
|
|
111
|
-
setState({
|
|
112
|
-
type: 'is-dragging-over',
|
|
113
|
-
closestEdge
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
onDrag ({ self }) {
|
|
117
|
-
const closestEdge = extractClosestEdge(self.data);
|
|
118
|
-
// Only need to update react state if nothing has changed.
|
|
119
|
-
// Prevents re-rendering.
|
|
120
|
-
setState((current)=>{
|
|
121
|
-
if (current.type === 'is-dragging-over' && current.closestEdge === closestEdge) {
|
|
122
|
-
return current;
|
|
109
|
+
}), dropTargetForElements({
|
|
110
|
+
element,
|
|
111
|
+
canDrop (t3) {
|
|
112
|
+
const { source } = t3;
|
|
113
|
+
if (source.element === element) {
|
|
114
|
+
return false;
|
|
123
115
|
}
|
|
124
|
-
return
|
|
125
|
-
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
getData (t4) {
|
|
119
|
+
const { input } = t4;
|
|
120
|
+
return attachClosestEdge(data, {
|
|
121
|
+
element,
|
|
122
|
+
input,
|
|
123
|
+
allowedEdges: [
|
|
124
|
+
"top",
|
|
125
|
+
"bottom"
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
getIsSticky () {
|
|
130
|
+
return true;
|
|
131
|
+
},
|
|
132
|
+
onDragEnter (t5) {
|
|
133
|
+
const { self } = t5;
|
|
134
|
+
const closestEdge = extractClosestEdge(self.data);
|
|
135
|
+
setState({
|
|
136
|
+
type: "is-dragging-over",
|
|
126
137
|
closestEdge
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
onDrag (t6) {
|
|
141
|
+
const { self: self_0 } = t6;
|
|
142
|
+
const closestEdge_0 = extractClosestEdge(self_0.data);
|
|
143
|
+
setState((current)=>{
|
|
144
|
+
if (current.type === "is-dragging-over" && current.closestEdge === closestEdge_0) {
|
|
145
|
+
return current;
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
type: "is-dragging-over",
|
|
149
|
+
closestEdge: closestEdge_0
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
onDragLeave () {
|
|
154
|
+
setState(idle);
|
|
155
|
+
},
|
|
156
|
+
onDrop () {
|
|
157
|
+
setState(idle);
|
|
158
|
+
}
|
|
159
|
+
}));
|
|
160
|
+
};
|
|
161
|
+
t2 = [
|
|
162
|
+
data,
|
|
163
|
+
dragHandleRef
|
|
164
|
+
];
|
|
165
|
+
$[0] = data;
|
|
166
|
+
$[1] = dragHandleRef;
|
|
167
|
+
$[2] = t1;
|
|
168
|
+
$[3] = t2;
|
|
169
|
+
} else {
|
|
170
|
+
t1 = $[2];
|
|
171
|
+
t2 = $[3];
|
|
172
|
+
}
|
|
173
|
+
useEffect(t1, t2);
|
|
174
|
+
const t3 = state.type === "is-dragging" ? 0.5 : "unset";
|
|
175
|
+
let t4;
|
|
176
|
+
if ($[4] !== t3) {
|
|
177
|
+
t4 = {
|
|
178
|
+
opacity: t3
|
|
179
|
+
};
|
|
180
|
+
$[4] = t3;
|
|
181
|
+
$[5] = t4;
|
|
182
|
+
} else {
|
|
183
|
+
t4 = $[5];
|
|
184
|
+
}
|
|
185
|
+
let t5;
|
|
186
|
+
if ($[6] !== state.closestEdge || $[7] !== state.type) {
|
|
187
|
+
t5 = state.type === "is-dragging-over" && state.closestEdge === "top" ? /*#__PURE__*/ _jsx(DropIndicator, {}) : null;
|
|
188
|
+
$[6] = state.closestEdge;
|
|
189
|
+
$[7] = state.type;
|
|
190
|
+
$[8] = t5;
|
|
191
|
+
} else {
|
|
192
|
+
t5 = $[8];
|
|
193
|
+
}
|
|
194
|
+
let t6;
|
|
195
|
+
if ($[9] !== state.closestEdge || $[10] !== state.type) {
|
|
196
|
+
t6 = state.type === "is-dragging-over" && state.closestEdge === "bottom" ? /*#__PURE__*/ _jsx(DropIndicator, {}) : null;
|
|
197
|
+
$[9] = state.closestEdge;
|
|
198
|
+
$[10] = state.type;
|
|
199
|
+
$[11] = t6;
|
|
200
|
+
} else {
|
|
201
|
+
t6 = $[11];
|
|
202
|
+
}
|
|
203
|
+
let t7;
|
|
204
|
+
if ($[12] !== children || $[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
|
|
205
|
+
t7 = /*#__PURE__*/ _jsxs(Stack, {
|
|
206
|
+
ref: ref,
|
|
207
|
+
spacing: 1,
|
|
208
|
+
style: t4,
|
|
209
|
+
children: [
|
|
210
|
+
t5,
|
|
211
|
+
children,
|
|
212
|
+
t6
|
|
213
|
+
]
|
|
214
|
+
});
|
|
215
|
+
$[12] = children;
|
|
216
|
+
$[13] = t4;
|
|
217
|
+
$[14] = t5;
|
|
218
|
+
$[15] = t6;
|
|
219
|
+
$[16] = t7;
|
|
220
|
+
} else {
|
|
221
|
+
t7 = $[16];
|
|
222
|
+
}
|
|
223
|
+
return t7;
|
|
153
224
|
}
|
|
154
225
|
|
|
155
226
|
//# sourceMappingURL=DragAndDropList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/DragAndDrop/DragAndDropList.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { attachClosestEdge, extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';\nimport { reorderWithEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge';\nimport { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';\nimport {\n monitorForElements,\n draggable,\n dropTargetForElements,\n} from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { Stack } from '@mui/material';\nimport type { ReactElement, ReactNode, RefObject } from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { DropIndicator } from './DropIndicator';\nimport type { State } from './model';\nimport { idle } from './model';\n\ninterface MonitorElementsProps {\n elements: Array<Record<string, unknown>>;\n accessKey: string;\n axis?: 'vertical' | 'horizontal';\n onChange: (elements: Array<Record<string, unknown>>) => void;\n}\n\n/**\n * This hook is responsible for monitoring the drag and drop of elements.\n * It will call the onChange function with the new order of elements when a drop is detected.\n *\n * @param elements - The list of elements to monitor\n * @param accessKey - The key to use to identify the elements (key of the object)\n * @param axis - The axis to monitor the drag and drop on\n * @param onChange - The function to call when a drop is detected\n */\nexport function useDragAndDropMonitor({\n elements,\n accessKey,\n axis = 'vertical',\n onChange,\n}: MonitorElementsProps): void {\n return useEffect(() => {\n return monitorForElements({\n onDrop({ location, source }) {\n const target = location.current.dropTargets[0];\n if (!target) {\n return;\n }\n\n const sourceData = source.data;\n const targetData = target.data;\n\n const indexOfSource = elements.findIndex((column) => column[accessKey] === sourceData[accessKey]);\n const indexOfTarget = elements.findIndex((column) => column[accessKey] === targetData[accessKey]);\n\n if (indexOfTarget < 0 || indexOfSource < 0) {\n return;\n }\n\n const closestEdgeOfTarget = extractClosestEdge(targetData);\n\n onChange(\n reorderWithEdge({\n list: elements,\n startIndex: indexOfSource,\n indexOfTarget,\n closestEdgeOfTarget,\n axis: axis,\n }),\n );\n },\n });\n }, [accessKey, axis, elements, onChange]);\n}\n\nexport interface DragAndDropElementProps {\n children: ReactNode;\n data: Record<string, unknown>;\n /**\n * Ref of the element used as drag handle (e.g. a `DragButton`). When provided, the drag can only be started from\n * this element. Otherwise, the drag can be started from anywhere in the element.\n */\n dragHandleRef?: RefObject<HTMLElement | null>;\n}\n\n/**\n * This component wraps the children that should be draggable.\n */\nexport function DragAndDropElement({ children, data, dragHandleRef }: DragAndDropElementProps): ReactElement {\n const ref = useRef<HTMLDivElement>(null);\n const [state, setState] = useState<State>(idle);\n\n useEffect(() => {\n const element = ref.current;\n if (!element) {\n return;\n }\n\n return combine(\n draggable({\n element,\n dragHandle: dragHandleRef?.current ?? undefined,\n getInitialData() {\n return data;\n },\n onDragStart() {\n setState({ type: 'is-dragging' });\n },\n onDrop() {\n setState(idle);\n },\n }),\n dropTargetForElements({\n element,\n canDrop({ source }) {\n // not allowing dropping on yourself\n if (source.element === element) {\n return false;\n }\n // only allowing tasks to be dropped on me\n return true;\n },\n getData({ input }) {\n return attachClosestEdge(data, {\n element,\n input,\n allowedEdges: ['top', 'bottom'],\n });\n },\n getIsSticky() {\n return true;\n },\n onDragEnter({ self }) {\n const closestEdge = extractClosestEdge(self.data);\n setState({ type: 'is-dragging-over', closestEdge });\n },\n onDrag({ self }) {\n const closestEdge = extractClosestEdge(self.data);\n\n // Only need to update react state if nothing has changed.\n // Prevents re-rendering.\n setState((current) => {\n if (current.type === 'is-dragging-over' && current.closestEdge === closestEdge) {\n return current;\n }\n return { type: 'is-dragging-over', closestEdge };\n });\n },\n onDragLeave() {\n setState(idle);\n },\n onDrop() {\n setState(idle);\n },\n }),\n );\n }, [data, dragHandleRef]);\n\n return (\n <Stack ref={ref} spacing={1} style={{ opacity: state.type === 'is-dragging' ? 0.5 : 'unset' }}>\n {state.type === 'is-dragging-over' && state.closestEdge === 'top' ? <DropIndicator /> : null}\n {children}\n {state.type === 'is-dragging-over' && state.closestEdge === 'bottom' ? <DropIndicator /> : null}\n </Stack>\n );\n}\n"],"names":["attachClosestEdge","extractClosestEdge","reorderWithEdge","combine","monitorForElements","draggable","dropTargetForElements","Stack","useEffect","useRef","useState","DropIndicator","idle"
|
|
1
|
+
{"version":3,"sources":["../../src/DragAndDrop/DragAndDropList.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { attachClosestEdge, extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';\nimport { reorderWithEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge';\nimport { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';\nimport {\n monitorForElements,\n draggable,\n dropTargetForElements,\n} from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { Stack } from '@mui/material';\nimport type { ReactElement, ReactNode, RefObject } from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { DropIndicator } from './DropIndicator';\nimport type { State } from './model';\nimport { idle } from './model';\n\ninterface MonitorElementsProps {\n elements: Array<Record<string, unknown>>;\n accessKey: string;\n axis?: 'vertical' | 'horizontal';\n onChange: (elements: Array<Record<string, unknown>>) => void;\n}\n\n/**\n * This hook is responsible for monitoring the drag and drop of elements.\n * It will call the onChange function with the new order of elements when a drop is detected.\n *\n * @param elements - The list of elements to monitor\n * @param accessKey - The key to use to identify the elements (key of the object)\n * @param axis - The axis to monitor the drag and drop on\n * @param onChange - The function to call when a drop is detected\n */\nexport function useDragAndDropMonitor({\n elements,\n accessKey,\n axis = 'vertical',\n onChange,\n}: MonitorElementsProps): void {\n return useEffect(() => {\n return monitorForElements({\n onDrop({ location, source }) {\n const target = location.current.dropTargets[0];\n if (!target) {\n return;\n }\n\n const sourceData = source.data;\n const targetData = target.data;\n\n const indexOfSource = elements.findIndex((column) => column[accessKey] === sourceData[accessKey]);\n const indexOfTarget = elements.findIndex((column) => column[accessKey] === targetData[accessKey]);\n\n if (indexOfTarget < 0 || indexOfSource < 0) {\n return;\n }\n\n const closestEdgeOfTarget = extractClosestEdge(targetData);\n\n onChange(\n reorderWithEdge({\n list: elements,\n startIndex: indexOfSource,\n indexOfTarget,\n closestEdgeOfTarget,\n axis: axis,\n }),\n );\n },\n });\n }, [accessKey, axis, elements, onChange]);\n}\n\nexport interface DragAndDropElementProps {\n children: ReactNode;\n data: Record<string, unknown>;\n /**\n * Ref of the element used as drag handle (e.g. a `DragButton`). When provided, the drag can only be started from\n * this element. Otherwise, the drag can be started from anywhere in the element.\n */\n dragHandleRef?: RefObject<HTMLElement | null>;\n}\n\n/**\n * This component wraps the children that should be draggable.\n */\nexport function DragAndDropElement({ children, data, dragHandleRef }: DragAndDropElementProps): ReactElement {\n const ref = useRef<HTMLDivElement>(null);\n const [state, setState] = useState<State>(idle);\n\n useEffect(() => {\n const element = ref.current;\n if (!element) {\n return;\n }\n\n return combine(\n draggable({\n element,\n dragHandle: dragHandleRef?.current ?? undefined,\n getInitialData() {\n return data;\n },\n onDragStart() {\n setState({ type: 'is-dragging' });\n },\n onDrop() {\n setState(idle);\n },\n }),\n dropTargetForElements({\n element,\n canDrop({ source }) {\n // not allowing dropping on yourself\n if (source.element === element) {\n return false;\n }\n // only allowing tasks to be dropped on me\n return true;\n },\n getData({ input }) {\n return attachClosestEdge(data, {\n element,\n input,\n allowedEdges: ['top', 'bottom'],\n });\n },\n getIsSticky() {\n return true;\n },\n onDragEnter({ self }) {\n const closestEdge = extractClosestEdge(self.data);\n setState({ type: 'is-dragging-over', closestEdge });\n },\n onDrag({ self }) {\n const closestEdge = extractClosestEdge(self.data);\n\n // Only need to update react state if nothing has changed.\n // Prevents re-rendering.\n setState((current) => {\n if (current.type === 'is-dragging-over' && current.closestEdge === closestEdge) {\n return current;\n }\n return { type: 'is-dragging-over', closestEdge };\n });\n },\n onDragLeave() {\n setState(idle);\n },\n onDrop() {\n setState(idle);\n },\n }),\n );\n }, [data, dragHandleRef]);\n\n return (\n <Stack ref={ref} spacing={1} style={{ opacity: state.type === 'is-dragging' ? 0.5 : 'unset' }}>\n {state.type === 'is-dragging-over' && state.closestEdge === 'top' ? <DropIndicator /> : null}\n {children}\n {state.type === 'is-dragging-over' && state.closestEdge === 'bottom' ? <DropIndicator /> : null}\n </Stack>\n );\n}\n"],"names":["attachClosestEdge","extractClosestEdge","reorderWithEdge","combine","monitorForElements","draggable","dropTargetForElements","Stack","useEffect","useRef","useState","DropIndicator","idle"],"mappings":";;AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,iBAAiB,EAAEC,kBAAkB,QAAQ,wDAAwD;AAC9G,SAASC,eAAe,QAAQ,kEAAkE;AAClG,SAASC,OAAO,QAAQ,4CAA4C;AACpE,SACEC,kBAAkB,EAClBC,SAAS,EACTC,qBAAqB,QAChB,oDAAoD;AAC3D,SAASC,KAAK,QAAQ,gBAAgB;AAEtC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAEpD,SAASC,aAAa,QAAQ,qBAAkB;AAEhD,SAASC,IAAI,QAAQ,aAAU;AAS/B;;;;;;;;CAQC,GACD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDP;;CAEC,GACD,OAAO"}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { c as _c } from "react-compiler-runtime";
|
|
14
15
|
import { IconButton, Menu, MenuItem } from "@mui/material";
|
|
15
16
|
import DragIcon from "mdi-material-ui/Drag";
|
|
16
17
|
import { useState, forwardRef } from "react";
|
|
@@ -38,62 +39,140 @@ export function handleMoveDown(element, elements) {
|
|
|
38
39
|
newElements.splice(index + 1, 0, element);
|
|
39
40
|
return newElements;
|
|
40
41
|
}
|
|
41
|
-
export const DragButton = /*#__PURE__*/ forwardRef(function DragButton(
|
|
42
|
+
export const DragButton = /*#__PURE__*/ forwardRef(function DragButton(t0, ref) {
|
|
43
|
+
const $ = _c(25);
|
|
44
|
+
let menuSx;
|
|
45
|
+
let onMoveDown;
|
|
46
|
+
let onMoveLeft;
|
|
47
|
+
let onMoveRight;
|
|
48
|
+
let onMoveUp;
|
|
49
|
+
let otherProps;
|
|
50
|
+
if ($[0] !== t0) {
|
|
51
|
+
({ onMoveUp, onMoveDown, onMoveLeft, onMoveRight, menuSx, ...otherProps } = t0);
|
|
52
|
+
$[0] = t0;
|
|
53
|
+
$[1] = menuSx;
|
|
54
|
+
$[2] = onMoveDown;
|
|
55
|
+
$[3] = onMoveLeft;
|
|
56
|
+
$[4] = onMoveRight;
|
|
57
|
+
$[5] = onMoveUp;
|
|
58
|
+
$[6] = otherProps;
|
|
59
|
+
} else {
|
|
60
|
+
menuSx = $[1];
|
|
61
|
+
onMoveDown = $[2];
|
|
62
|
+
onMoveLeft = $[3];
|
|
63
|
+
onMoveRight = $[4];
|
|
64
|
+
onMoveUp = $[5];
|
|
65
|
+
otherProps = $[6];
|
|
66
|
+
}
|
|
42
67
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
43
68
|
const open = Boolean(anchorEl);
|
|
44
|
-
|
|
45
|
-
|
|
69
|
+
let t1;
|
|
70
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
71
|
+
t1 = function handleClick(event) {
|
|
72
|
+
setAnchorEl(event.currentTarget);
|
|
73
|
+
};
|
|
74
|
+
$[7] = t1;
|
|
75
|
+
} else {
|
|
76
|
+
t1 = $[7];
|
|
77
|
+
}
|
|
78
|
+
const handleClick = t1;
|
|
79
|
+
let t2;
|
|
80
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
81
|
+
t2 = function handleMove(callback) {
|
|
82
|
+
setAnchorEl(null);
|
|
83
|
+
callback?.();
|
|
84
|
+
};
|
|
85
|
+
$[8] = t2;
|
|
86
|
+
} else {
|
|
87
|
+
t2 = $[8];
|
|
88
|
+
}
|
|
89
|
+
const handleMove = t2;
|
|
90
|
+
let t3;
|
|
91
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
92
|
+
t3 = /*#__PURE__*/ _jsx(DragIcon, {});
|
|
93
|
+
$[9] = t3;
|
|
94
|
+
} else {
|
|
95
|
+
t3 = $[9];
|
|
96
|
+
}
|
|
97
|
+
let t4;
|
|
98
|
+
if ($[10] !== open || $[11] !== otherProps || $[12] !== ref) {
|
|
99
|
+
t4 = /*#__PURE__*/ _jsx(IconButton, {
|
|
100
|
+
...otherProps,
|
|
101
|
+
ref: ref,
|
|
102
|
+
"aria-label": "move",
|
|
103
|
+
"aria-haspopup": true,
|
|
104
|
+
"aria-expanded": open,
|
|
105
|
+
size: "small",
|
|
106
|
+
onClick: handleClick,
|
|
107
|
+
children: t3
|
|
108
|
+
});
|
|
109
|
+
$[10] = open;
|
|
110
|
+
$[11] = otherProps;
|
|
111
|
+
$[12] = ref;
|
|
112
|
+
$[13] = t4;
|
|
113
|
+
} else {
|
|
114
|
+
t4 = $[13];
|
|
115
|
+
}
|
|
116
|
+
let t5;
|
|
117
|
+
if ($[14] !== anchorEl || $[15] !== menuSx || $[16] !== onMoveDown || $[17] !== onMoveLeft || $[18] !== onMoveRight || $[19] !== onMoveUp || $[20] !== open) {
|
|
118
|
+
t5 = (onMoveUp || onMoveDown || onMoveLeft || onMoveRight) && /*#__PURE__*/ _jsxs(Menu, {
|
|
119
|
+
id: "drag-button-menu",
|
|
120
|
+
MenuListProps: {
|
|
121
|
+
"aria-labelledby": "drag-button-menu"
|
|
122
|
+
},
|
|
123
|
+
anchorEl: anchorEl,
|
|
124
|
+
open: open,
|
|
125
|
+
onClose: ()=>handleMove(undefined),
|
|
126
|
+
sx: menuSx,
|
|
127
|
+
children: [
|
|
128
|
+
onMoveUp && /*#__PURE__*/ _jsx(MenuItem, {
|
|
129
|
+
onClick: ()=>handleMove(onMoveUp),
|
|
130
|
+
children: "Move Up"
|
|
131
|
+
}),
|
|
132
|
+
onMoveDown && /*#__PURE__*/ _jsx(MenuItem, {
|
|
133
|
+
onClick: ()=>handleMove(onMoveDown),
|
|
134
|
+
children: "Move Down"
|
|
135
|
+
}),
|
|
136
|
+
onMoveLeft && /*#__PURE__*/ _jsx(MenuItem, {
|
|
137
|
+
onClick: ()=>handleMove(onMoveLeft),
|
|
138
|
+
children: "Move Left"
|
|
139
|
+
}),
|
|
140
|
+
onMoveRight && /*#__PURE__*/ _jsx(MenuItem, {
|
|
141
|
+
onClick: ()=>handleMove(onMoveRight),
|
|
142
|
+
children: "Move Right"
|
|
143
|
+
}),
|
|
144
|
+
onMoveRight && /*#__PURE__*/ _jsx(MenuItem, {
|
|
145
|
+
onClick: ()=>handleMove(onMoveRight),
|
|
146
|
+
children: "Move Right"
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
$[14] = anchorEl;
|
|
151
|
+
$[15] = menuSx;
|
|
152
|
+
$[16] = onMoveDown;
|
|
153
|
+
$[17] = onMoveLeft;
|
|
154
|
+
$[18] = onMoveRight;
|
|
155
|
+
$[19] = onMoveUp;
|
|
156
|
+
$[20] = open;
|
|
157
|
+
$[21] = t5;
|
|
158
|
+
} else {
|
|
159
|
+
t5 = $[21];
|
|
46
160
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
161
|
+
let t6;
|
|
162
|
+
if ($[22] !== t4 || $[23] !== t5) {
|
|
163
|
+
t6 = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
164
|
+
children: [
|
|
165
|
+
t4,
|
|
166
|
+
t5
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
$[22] = t4;
|
|
170
|
+
$[23] = t5;
|
|
171
|
+
$[24] = t6;
|
|
172
|
+
} else {
|
|
173
|
+
t6 = $[24];
|
|
50
174
|
}
|
|
51
|
-
return
|
|
52
|
-
children: [
|
|
53
|
-
/*#__PURE__*/ _jsx(IconButton, {
|
|
54
|
-
...otherProps,
|
|
55
|
-
ref: ref,
|
|
56
|
-
"aria-label": "move",
|
|
57
|
-
"aria-haspopup": true,
|
|
58
|
-
"aria-expanded": open,
|
|
59
|
-
size: "small",
|
|
60
|
-
onClick: handleClick,
|
|
61
|
-
children: /*#__PURE__*/ _jsx(DragIcon, {})
|
|
62
|
-
}),
|
|
63
|
-
(onMoveUp || onMoveDown || onMoveLeft || onMoveRight) && /*#__PURE__*/ _jsxs(Menu, {
|
|
64
|
-
id: "drag-button-menu",
|
|
65
|
-
MenuListProps: {
|
|
66
|
-
'aria-labelledby': 'drag-button-menu'
|
|
67
|
-
},
|
|
68
|
-
anchorEl: anchorEl,
|
|
69
|
-
open: open,
|
|
70
|
-
onClose: ()=>handleMove(undefined),
|
|
71
|
-
sx: menuSx,
|
|
72
|
-
children: [
|
|
73
|
-
onMoveUp && /*#__PURE__*/ _jsx(MenuItem, {
|
|
74
|
-
onClick: ()=>handleMove(onMoveUp),
|
|
75
|
-
children: "Move Up"
|
|
76
|
-
}),
|
|
77
|
-
onMoveDown && /*#__PURE__*/ _jsx(MenuItem, {
|
|
78
|
-
onClick: ()=>handleMove(onMoveDown),
|
|
79
|
-
children: "Move Down"
|
|
80
|
-
}),
|
|
81
|
-
onMoveLeft && /*#__PURE__*/ _jsx(MenuItem, {
|
|
82
|
-
onClick: ()=>handleMove(onMoveLeft),
|
|
83
|
-
children: "Move Left"
|
|
84
|
-
}),
|
|
85
|
-
onMoveRight && /*#__PURE__*/ _jsx(MenuItem, {
|
|
86
|
-
onClick: ()=>handleMove(onMoveRight),
|
|
87
|
-
children: "Move Right"
|
|
88
|
-
}),
|
|
89
|
-
onMoveRight && /*#__PURE__*/ _jsx(MenuItem, {
|
|
90
|
-
onClick: ()=>handleMove(onMoveRight),
|
|
91
|
-
children: "Move Right"
|
|
92
|
-
})
|
|
93
|
-
]
|
|
94
|
-
})
|
|
95
|
-
]
|
|
96
|
-
});
|
|
175
|
+
return t6;
|
|
97
176
|
});
|
|
98
177
|
|
|
99
178
|
//# sourceMappingURL=DragButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/DragAndDrop/DragButton.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { IconButtonProps, MenuProps } from '@mui/material';\nimport { IconButton, Menu, MenuItem } from '@mui/material';\nimport DragIcon from 'mdi-material-ui/Drag';\nimport type { MouseEvent, ReactElement } from 'react';\nimport { useState, forwardRef } from 'react';\n\nexport function handleMoveUp<T>(element: T, elements: T[]): T[] {\n const index = elements.indexOf(element);\n if (index === 0) {\n return elements;\n }\n\n const newElements = [...elements];\n newElements.splice(index, 1);\n newElements.splice(index - 1, 0, element);\n return newElements;\n}\n\nexport function handleMoveDown<T>(element: T, elements: T[]): T[] {\n const index = elements.indexOf(element);\n if (index === elements.length - 1) {\n return elements;\n }\n\n const newElements = [...elements];\n newElements.splice(index, 1);\n newElements.splice(index + 1, 0, element);\n return newElements;\n}\n\nexport interface DragButtonProps extends IconButtonProps {\n onMoveUp?: () => void;\n onMoveDown?: () => void;\n onMoveLeft?: () => void;\n onMoveRight?: () => void;\n menuSx?: MenuProps['sx'];\n}\n\nexport const DragButton = forwardRef<HTMLButtonElement, DragButtonProps>(function DragButton(\n { onMoveUp, onMoveDown, onMoveLeft, onMoveRight, menuSx, ...otherProps }: DragButtonProps,\n ref,\n): ReactElement {\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n const open = Boolean(anchorEl);\n\n function handleClick(event: MouseEvent<HTMLElement>): void {\n setAnchorEl(event.currentTarget);\n }\n\n function handleMove(callback?: () => void): void {\n setAnchorEl(null);\n callback?.();\n }\n\n return (\n <>\n <IconButton\n {...otherProps}\n ref={ref}\n aria-label=\"move\"\n aria-haspopup={true}\n aria-expanded={open}\n size=\"small\"\n onClick={handleClick}\n >\n <DragIcon />\n </IconButton>\n {(onMoveUp || onMoveDown || onMoveLeft || onMoveRight) && (\n <Menu\n id=\"drag-button-menu\"\n MenuListProps={{\n 'aria-labelledby': 'drag-button-menu',\n }}\n anchorEl={anchorEl}\n open={open}\n onClose={() => handleMove(undefined)}\n sx={menuSx}\n >\n {onMoveUp && <MenuItem onClick={() => handleMove(onMoveUp)}>Move Up</MenuItem>}\n {onMoveDown && <MenuItem onClick={() => handleMove(onMoveDown)}>Move Down</MenuItem>}\n {onMoveLeft && <MenuItem onClick={() => handleMove(onMoveLeft)}>Move Left</MenuItem>}\n {onMoveRight && <MenuItem onClick={() => handleMove(onMoveRight)}>Move Right</MenuItem>}\n {onMoveRight && <MenuItem onClick={() => handleMove(onMoveRight)}>Move Right</MenuItem>}\n </Menu>\n )}\n </>\n );\n});\n"],"names":["IconButton","Menu","MenuItem","DragIcon","useState","forwardRef","handleMoveUp","element","elements","index","indexOf","newElements","splice","handleMoveDown","length","DragButton"
|
|
1
|
+
{"version":3,"sources":["../../src/DragAndDrop/DragButton.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { IconButtonProps, MenuProps } from '@mui/material';\nimport { IconButton, Menu, MenuItem } from '@mui/material';\nimport DragIcon from 'mdi-material-ui/Drag';\nimport type { MouseEvent, ReactElement } from 'react';\nimport { useState, forwardRef } from 'react';\n\nexport function handleMoveUp<T>(element: T, elements: T[]): T[] {\n const index = elements.indexOf(element);\n if (index === 0) {\n return elements;\n }\n\n const newElements = [...elements];\n newElements.splice(index, 1);\n newElements.splice(index - 1, 0, element);\n return newElements;\n}\n\nexport function handleMoveDown<T>(element: T, elements: T[]): T[] {\n const index = elements.indexOf(element);\n if (index === elements.length - 1) {\n return elements;\n }\n\n const newElements = [...elements];\n newElements.splice(index, 1);\n newElements.splice(index + 1, 0, element);\n return newElements;\n}\n\nexport interface DragButtonProps extends IconButtonProps {\n onMoveUp?: () => void;\n onMoveDown?: () => void;\n onMoveLeft?: () => void;\n onMoveRight?: () => void;\n menuSx?: MenuProps['sx'];\n}\n\nexport const DragButton = forwardRef<HTMLButtonElement, DragButtonProps>(function DragButton(\n { onMoveUp, onMoveDown, onMoveLeft, onMoveRight, menuSx, ...otherProps }: DragButtonProps,\n ref,\n): ReactElement {\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n const open = Boolean(anchorEl);\n\n function handleClick(event: MouseEvent<HTMLElement>): void {\n setAnchorEl(event.currentTarget);\n }\n\n function handleMove(callback?: () => void): void {\n setAnchorEl(null);\n callback?.();\n }\n\n return (\n <>\n <IconButton\n {...otherProps}\n ref={ref}\n aria-label=\"move\"\n aria-haspopup={true}\n aria-expanded={open}\n size=\"small\"\n onClick={handleClick}\n >\n <DragIcon />\n </IconButton>\n {(onMoveUp || onMoveDown || onMoveLeft || onMoveRight) && (\n <Menu\n id=\"drag-button-menu\"\n MenuListProps={{\n 'aria-labelledby': 'drag-button-menu',\n }}\n anchorEl={anchorEl}\n open={open}\n onClose={() => handleMove(undefined)}\n sx={menuSx}\n >\n {onMoveUp && <MenuItem onClick={() => handleMove(onMoveUp)}>Move Up</MenuItem>}\n {onMoveDown && <MenuItem onClick={() => handleMove(onMoveDown)}>Move Down</MenuItem>}\n {onMoveLeft && <MenuItem onClick={() => handleMove(onMoveLeft)}>Move Left</MenuItem>}\n {onMoveRight && <MenuItem onClick={() => handleMove(onMoveRight)}>Move Right</MenuItem>}\n {onMoveRight && <MenuItem onClick={() => handleMove(onMoveRight)}>Move Right</MenuItem>}\n </Menu>\n )}\n </>\n );\n});\n"],"names":["IconButton","Menu","MenuItem","DragIcon","useState","forwardRef","handleMoveUp","element","elements","index","indexOf","newElements","splice","handleMoveDown","length","DragButton"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAGjC,SAASA,UAAU,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,gBAAgB;AAC3D,OAAOC,cAAc,uBAAuB;AAE5C,SAASC,QAAQ,EAAEC,UAAU,QAAQ,QAAQ;AAE7C,OAAO,SAASC,aAAgBC,OAAO,EAAKC,QAAQ;IAClD,MAAMC,QAAQD,SAASE,OAAO,CAACH;IAC/B,IAAIE,UAAU,GAAG;QACf,OAAOD;IACT;IAEA,MAAMG,cAAc;WAAIH;KAAS;IACjCG,YAAYC,MAAM,CAACH,OAAO;IAC1BE,YAAYC,MAAM,CAACH,QAAQ,GAAG,GAAGF;IACjC,OAAOI;AACT;AAEA,OAAO,SAASE,eAAkBN,OAAO,EAAKC,QAAQ;IACpD,MAAMC,QAAQD,SAASE,OAAO,CAACH;IAC/B,IAAIE,UAAUD,SAASM,MAAM,GAAG,GAAG;QACjC,OAAON;IACT;IAEA,MAAMG,cAAc;WAAIH;KAAS;IACjCG,YAAYC,MAAM,CAACH,OAAO;IAC1BE,YAAYC,MAAM,CAACH,QAAQ,GAAG,GAAGF;IACjC,OAAOI;AACT;AAUA,OAAO,MAAMI,2BAAaV,WAA+C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDtE"}
|