@acvl/frontend-components 0.0.13 → 0.0.15
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/cjs/index.js +202 -3475
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/components/v1/datagrids/columns/index.d.ts +2 -2
- package/dist/cjs/types/src/components/v1/datagrids/index.d.ts +2 -2
- package/dist/cjs/types/src/components/v1/datagrids/wrappers/EditGridWrapper.d.ts +3 -1
- package/dist/cjs/types/src/components/v1/layout/shared/index.d.ts +1 -1
- package/dist/cjs/types/src/components/v1/lib/context/index.d.ts +1 -1
- package/dist/esm/index.js +205 -3478
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/components/v1/datagrids/columns/index.d.ts +2 -2
- package/dist/esm/types/src/components/v1/datagrids/index.d.ts +2 -2
- package/dist/esm/types/src/components/v1/datagrids/wrappers/EditGridWrapper.d.ts +3 -1
- package/dist/esm/types/src/components/v1/layout/shared/index.d.ts +1 -1
- package/dist/esm/types/src/components/v1/lib/context/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useTheme, useMediaQuery, Tooltip, IconButton, Button, Grid, FormGroup, FormHelperText as FormHelperText$1, Drawer, Box, Stack, CircularProgress, Typography as Typography$1, List as List$1, ListItem as ListItem$1, ListSubheader, styled as styled$1, LinearProgress, Autocomplete, Checkbox, Slider, Switch, InputAdornment as InputAdornment$1, ToggleButtonGroup, ToggleButton, Dialog, DialogTitle, DialogContent as DialogContent$1, DialogContentText, DialogActions as DialogActions$1, ButtonGroup, Menu, alpha as alpha$1, Link, Card, CardHeader, Avatar, CardContent, Divider as Divider$1, Popper, Grow as Grow$1, Paper, ClickAwayListener, Badge, TablePagination, NoSsr, tooltipClasses, Collapse, Fade as Fade$1, Slide, Zoom, Snackbar, lighten, createTheme as createTheme$1, responsiveFontSizes } from '@mui/material';
|
|
4
4
|
import EditIcon from '@mui/icons-material/Edit';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import React__default, { useCallback, useEffect, isValidElement, cloneElement, Children, createContext, useContext, useState, useMemo, useRef,
|
|
6
|
+
import React__default, { useCallback, useEffect, isValidElement, cloneElement, Children, createContext, useContext, useState, useMemo, useRef, useImperativeHandle, useLayoutEffect, Suspense, forwardRef } from 'react';
|
|
7
7
|
import { useNavigate, useLocation } from 'react-router-dom';
|
|
8
8
|
import DeleteIcon from '@mui/icons-material/Delete';
|
|
9
9
|
import { Controller, useForm, useWatch, useFieldArray, FormProvider } from 'react-hook-form';
|
|
@@ -65,7 +65,7 @@ import Tabs$1, { tabsClasses } from '@mui/material/Tabs';
|
|
|
65
65
|
import { createSvgIcon } from '@mui/material/utils';
|
|
66
66
|
import Button$1 from '@mui/material/Button';
|
|
67
67
|
import Fade from '@mui/material/Fade';
|
|
68
|
-
import ReactDOM
|
|
68
|
+
import ReactDOM from 'react-dom';
|
|
69
69
|
import ButtonBase from '@mui/material/ButtonBase';
|
|
70
70
|
import IconButton$1 from '@mui/material/IconButton';
|
|
71
71
|
import DialogActions from '@mui/material/DialogActions';
|
|
@@ -91,7 +91,8 @@ import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
|
91
91
|
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
92
92
|
import Pagination from '@mui/material/Pagination';
|
|
93
93
|
import { useSortable, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
94
|
-
import { CSS
|
|
94
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
95
|
+
import { useSensors, useSensor, PointerSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
95
96
|
import { restrictToVerticalAxis, restrictToWindowEdges, restrictToParentElement } from '@dnd-kit/modifiers';
|
|
96
97
|
import CloseIcon from '@mui/icons-material/Close';
|
|
97
98
|
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
@@ -7388,7 +7389,7 @@ function memoize(fn) {
|
|
|
7388
7389
|
};
|
|
7389
7390
|
}
|
|
7390
7391
|
|
|
7391
|
-
const properties
|
|
7392
|
+
const properties = {
|
|
7392
7393
|
m: 'margin',
|
|
7393
7394
|
p: 'padding'
|
|
7394
7395
|
};
|
|
@@ -7420,7 +7421,7 @@ const getCssProperties = memoize(prop => {
|
|
|
7420
7421
|
}
|
|
7421
7422
|
}
|
|
7422
7423
|
const [a, b] = prop.split('');
|
|
7423
|
-
const property = properties
|
|
7424
|
+
const property = properties[a];
|
|
7424
7425
|
const direction = directions[b] || '';
|
|
7425
7426
|
return Array.isArray(direction) ? direction.map(dir => property + dir) : [property + direction];
|
|
7426
7427
|
});
|
|
@@ -9467,7 +9468,7 @@ const _excluded$C = ["enableAccessibleFieldDOMStructure"],
|
|
|
9467
9468
|
_excluded6 = ["ownerState"],
|
|
9468
9469
|
_excluded7 = ["ownerState"],
|
|
9469
9470
|
_excluded8 = ["InputProps", "inputProps"];
|
|
9470
|
-
const noop$
|
|
9471
|
+
const noop$2 = () => {};
|
|
9471
9472
|
const cleanFieldResponse = _ref => {
|
|
9472
9473
|
let {
|
|
9473
9474
|
enableAccessibleFieldDOMStructure
|
|
@@ -9484,7 +9485,7 @@ const cleanFieldResponse = _ref => {
|
|
|
9484
9485
|
openPickerAriaLabel
|
|
9485
9486
|
} = fieldResponse,
|
|
9486
9487
|
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded2$6);
|
|
9487
|
-
const mergedInputProps = major >= 6 && other?.slotProps?.input ? mergeSlotProps(other?.slotProps?.input, InputProps) : noop$
|
|
9488
|
+
const mergedInputProps = major >= 6 && other?.slotProps?.input ? mergeSlotProps(other?.slotProps?.input, InputProps) : noop$2;
|
|
9488
9489
|
return {
|
|
9489
9490
|
clearable,
|
|
9490
9491
|
onClear,
|
|
@@ -9519,8 +9520,8 @@ const cleanFieldResponse = _ref => {
|
|
|
9519
9520
|
openPickerAriaLabel
|
|
9520
9521
|
} = fieldResponse,
|
|
9521
9522
|
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded3$1);
|
|
9522
|
-
const mergedInputProps = major >= 6 && other?.slotProps?.input ? mergeSlotProps(other?.slotProps?.input, InputProps) : noop$
|
|
9523
|
-
const mergedHtmlInputProps = major >= 6 && other?.slotProps?.htmlInput ? mergeSlotProps(other?.slotProps?.htmlInput, inputProps) : noop$
|
|
9523
|
+
const mergedInputProps = major >= 6 && other?.slotProps?.input ? mergeSlotProps(other?.slotProps?.input, InputProps) : noop$2;
|
|
9524
|
+
const mergedHtmlInputProps = major >= 6 && other?.slotProps?.htmlInput ? mergeSlotProps(other?.slotProps?.htmlInput, inputProps) : noop$2;
|
|
9524
9525
|
return {
|
|
9525
9526
|
clearable,
|
|
9526
9527
|
onClear,
|
|
@@ -11935,7 +11936,7 @@ Transition.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
11935
11936
|
onExited: PropTypes.func
|
|
11936
11937
|
} : {}; // Name the function so it is clearer in the documentation
|
|
11937
11938
|
|
|
11938
|
-
function noop$
|
|
11939
|
+
function noop$1() {}
|
|
11939
11940
|
|
|
11940
11941
|
Transition.defaultProps = {
|
|
11941
11942
|
in: false,
|
|
@@ -11944,12 +11945,12 @@ Transition.defaultProps = {
|
|
|
11944
11945
|
appear: false,
|
|
11945
11946
|
enter: true,
|
|
11946
11947
|
exit: true,
|
|
11947
|
-
onEnter: noop$
|
|
11948
|
-
onEntering: noop$
|
|
11949
|
-
onEntered: noop$
|
|
11950
|
-
onExit: noop$
|
|
11951
|
-
onExiting: noop$
|
|
11952
|
-
onExited: noop$
|
|
11948
|
+
onEnter: noop$1,
|
|
11949
|
+
onEntering: noop$1,
|
|
11950
|
+
onEntered: noop$1,
|
|
11951
|
+
onExit: noop$1,
|
|
11952
|
+
onExiting: noop$1,
|
|
11953
|
+
onExited: noop$1
|
|
11953
11954
|
};
|
|
11954
11955
|
Transition.UNMOUNTED = UNMOUNTED;
|
|
11955
11956
|
Transition.EXITED = EXITED;
|
|
@@ -12884,7 +12885,7 @@ const PickersDayFiller = styled('div', {
|
|
|
12884
12885
|
opacity: 0,
|
|
12885
12886
|
pointerEvents: 'none'
|
|
12886
12887
|
}));
|
|
12887
|
-
const noop
|
|
12888
|
+
const noop = () => {};
|
|
12888
12889
|
const PickersDayRaw = /*#__PURE__*/React.forwardRef(function PickersDay(inProps, forwardedRef) {
|
|
12889
12890
|
const props = useThemeProps({
|
|
12890
12891
|
props: inProps,
|
|
@@ -12897,11 +12898,11 @@ const PickersDayRaw = /*#__PURE__*/React.forwardRef(function PickersDay(inProps,
|
|
|
12897
12898
|
isAnimating,
|
|
12898
12899
|
onClick,
|
|
12899
12900
|
onDaySelect,
|
|
12900
|
-
onFocus = noop
|
|
12901
|
-
onBlur = noop
|
|
12902
|
-
onKeyDown = noop
|
|
12903
|
-
onMouseDown = noop
|
|
12904
|
-
onMouseEnter = noop
|
|
12901
|
+
onFocus = noop,
|
|
12902
|
+
onBlur = noop,
|
|
12903
|
+
onKeyDown = noop,
|
|
12904
|
+
onMouseDown = noop,
|
|
12905
|
+
onMouseEnter = noop,
|
|
12905
12906
|
children,
|
|
12906
12907
|
day,
|
|
12907
12908
|
selected,
|
|
@@ -26605,10 +26606,12 @@ const SaveCancelButton = (props) => {
|
|
|
26605
26606
|
...props.slotProps?.cancelBtn
|
|
26606
26607
|
} }), jsx(NormalOrIcon, { buttonProps: {
|
|
26607
26608
|
color: 'secondary',
|
|
26609
|
+
variant: 'contained',
|
|
26608
26610
|
startIcon: jsx(SaveIcon, {}),
|
|
26609
26611
|
type: 'submit',
|
|
26610
26612
|
form: 'formulario',
|
|
26611
26613
|
sx: { height: 1 },
|
|
26614
|
+
children: 'Guardar',
|
|
26612
26615
|
...props.slotProps?.saveBtn
|
|
26613
26616
|
} })] }));
|
|
26614
26617
|
};
|
|
@@ -27249,7 +27252,7 @@ function CustomPagination() {
|
|
|
27249
27252
|
}
|
|
27250
27253
|
|
|
27251
27254
|
const DraggableRow = (params) => {
|
|
27252
|
-
const { attributes, listeners, setNodeRef, transform, transition, } = useSortable({ id: params.rowId });
|
|
27255
|
+
const { attributes, listeners, setNodeRef, transform, transition, } = useSortable({ id: params.rowId.toString() });
|
|
27253
27256
|
const style = {
|
|
27254
27257
|
transform: CSS.Transform.toString(transform),
|
|
27255
27258
|
transition
|
|
@@ -27266,3458 +27269,179 @@ const DraggableRow = (params) => {
|
|
|
27266
27269
|
} }), jsx(GridRow, { ...params })] }));
|
|
27267
27270
|
};
|
|
27268
27271
|
|
|
27269
|
-
const
|
|
27270
|
-
|
|
27272
|
+
const EditGridWrapper = (props) => {
|
|
27273
|
+
const notifications = useNotifications();
|
|
27274
|
+
// ======================|| EDIT ||====================== //
|
|
27275
|
+
const [edit, setEdit] = useState(false);
|
|
27276
|
+
const [editMutation, { isLoading: loadingMutation }] = props.mutation();
|
|
27277
|
+
const [errors, setErrors] = useState({});
|
|
27278
|
+
const [rowModesModel, setRowModesModel] = useState({});
|
|
27279
|
+
const handleCancelarEdit = () => {
|
|
27280
|
+
setRowModesModel({});
|
|
27281
|
+
};
|
|
27282
|
+
const handleClickEdit = () => {
|
|
27283
|
+
if (edit)
|
|
27284
|
+
handleCancelarEdit();
|
|
27285
|
+
setEdit(prevState => !prevState);
|
|
27286
|
+
};
|
|
27287
|
+
const processRowUpdate = async (newRow, originalRow) => {
|
|
27288
|
+
const original_data = jsonForm({ submitData: originalRow });
|
|
27289
|
+
const data = jsonForm({ submitData: newRow, ...(props.parser ? { props: props.parser } : []) });
|
|
27290
|
+
if (isEqual$1(data, original_data))
|
|
27291
|
+
return originalRow;
|
|
27292
|
+
try {
|
|
27293
|
+
const result = await editMutation(data).unwrap();
|
|
27294
|
+
setErrors(prevState => produce(prevState, draft => {
|
|
27295
|
+
delete draft[newRow.id];
|
|
27296
|
+
}));
|
|
27297
|
+
if (props?.postAction)
|
|
27298
|
+
props.postAction(result);
|
|
27299
|
+
notifications.show(`Información actualizada!`, { severity: 'success' });
|
|
27300
|
+
return result.list;
|
|
27301
|
+
}
|
|
27302
|
+
catch (e) {
|
|
27303
|
+
setErrors(prevState => produce(prevState, draft => {
|
|
27304
|
+
draft[newRow.id] = get(e, 'data');
|
|
27305
|
+
}));
|
|
27306
|
+
notifications.show('Error actualizando información!', { severity: 'error' });
|
|
27307
|
+
}
|
|
27308
|
+
};
|
|
27309
|
+
// ===== || KEYDOWN || ===== //
|
|
27310
|
+
const handleKeyPress = useCallback((event) => {
|
|
27311
|
+
if (props.permission) {
|
|
27312
|
+
if (event.ctrlKey && event.shiftKey && event.key === 'E') {
|
|
27313
|
+
event.preventDefault();
|
|
27314
|
+
setEdit(true);
|
|
27315
|
+
}
|
|
27316
|
+
else if (event.key === 'Escape' && event.shiftKey && edit) {
|
|
27317
|
+
event.preventDefault();
|
|
27318
|
+
handleCancelarEdit();
|
|
27319
|
+
setEdit(false);
|
|
27320
|
+
}
|
|
27321
|
+
}
|
|
27322
|
+
}, [edit, props.permission]);
|
|
27323
|
+
useEffect(() => {
|
|
27324
|
+
document.addEventListener('keydown', handleKeyPress);
|
|
27325
|
+
return () => {
|
|
27326
|
+
document.removeEventListener('keydown', handleKeyPress);
|
|
27327
|
+
};
|
|
27328
|
+
}, [handleKeyPress]);
|
|
27329
|
+
// ========================= || DRAG N DROP || ========================= //
|
|
27330
|
+
const rowsIterator = props.baseGridRef?.current?.getRowModels().values();
|
|
27331
|
+
const rows = useMemo(() => {
|
|
27332
|
+
return rowsIterator ? Array.from(rowsIterator) : [];
|
|
27333
|
+
}, [rowsIterator]);
|
|
27334
|
+
const sensors = useSensors(useSensor(PointerSensor));
|
|
27335
|
+
const handleDragEnd = useCallback((event) => {
|
|
27336
|
+
const field = props.dnd?.field;
|
|
27337
|
+
if (!field)
|
|
27338
|
+
return;
|
|
27339
|
+
const { active, over } = event;
|
|
27340
|
+
if (over) {
|
|
27341
|
+
const activeRow = rows.find((row) => row.id == active.id);
|
|
27342
|
+
const overRow = rows.find((row) => row.id == over.id);
|
|
27343
|
+
const mutationArgs = { ...props.dnd?.args, id: activeRow.id };
|
|
27344
|
+
mutationArgs[field] = get(overRow, field);
|
|
27345
|
+
editMutation(mutationArgs);
|
|
27346
|
+
}
|
|
27347
|
+
}, [editMutation, props.dnd, rows]);
|
|
27348
|
+
// ===== || GRID PROPS || ===== //
|
|
27349
|
+
const editGridProps = mergeSettings({
|
|
27350
|
+
columns: props.columns({
|
|
27351
|
+
displayEdit: edit && props.permission,
|
|
27352
|
+
rowModesModel: rowModesModel,
|
|
27353
|
+
setRowModesModel: setRowModesModel,
|
|
27354
|
+
mutationErrors: errors,
|
|
27355
|
+
options: props.options,
|
|
27356
|
+
}),
|
|
27357
|
+
...(edit && props.dnd ? { slots: { row: DraggableRow } } : {}),
|
|
27358
|
+
slotProps: {
|
|
27359
|
+
toolbar: {
|
|
27360
|
+
extraButtons: [
|
|
27361
|
+
...(props.permission && !props.disabled ? [{
|
|
27362
|
+
label: edit ? 'Cancelar' : 'Editar',
|
|
27363
|
+
icon: edit ? CancelIcon : EditIcon,
|
|
27364
|
+
onClick: handleClickEdit,
|
|
27365
|
+
}] : []),
|
|
27366
|
+
]
|
|
27367
|
+
}
|
|
27368
|
+
},
|
|
27369
|
+
onRowEditStart: ({ reason, row }, event) => {
|
|
27370
|
+
if (!get(row, `obj_permissions.edit`) || (reason === GridRowEditStartReasons.cellDoubleClick && !edit)) {
|
|
27371
|
+
event.defaultMuiPrevented = true;
|
|
27372
|
+
}
|
|
27373
|
+
},
|
|
27374
|
+
// edit
|
|
27375
|
+
checkboxSelection: !edit,
|
|
27376
|
+
...(edit ? { onRowClick: undefined } : []),
|
|
27377
|
+
editMode: 'row',
|
|
27378
|
+
rowModesModel: rowModesModel,
|
|
27379
|
+
onRowModesModelChange: setRowModesModel,
|
|
27380
|
+
processRowUpdate: processRowUpdate,
|
|
27381
|
+
loadingParams: [loadingMutation],
|
|
27382
|
+
}, props.dataGridProps);
|
|
27383
|
+
const renderEditGrid = () => (jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, modifiers: [
|
|
27384
|
+
restrictToVerticalAxis,
|
|
27385
|
+
restrictToWindowEdges,
|
|
27386
|
+
restrictToParentElement
|
|
27387
|
+
], autoScroll: false, children: jsx(SortableContext, { items: rows ? rows.map((row) => row.id.toString()) : [], strategy: verticalListSortingStrategy, children: props.renderFunction({ ...props.renderFunctionProps, dataGridProps: editGridProps }) }) }));
|
|
27388
|
+
return renderEditGrid();
|
|
27271
27389
|
};
|
|
27272
|
-
function HiddenText(_ref) {
|
|
27273
|
-
let {
|
|
27274
|
-
id,
|
|
27275
|
-
value
|
|
27276
|
-
} = _ref;
|
|
27277
|
-
return React__default.createElement("div", {
|
|
27278
|
-
id: id,
|
|
27279
|
-
style: hiddenStyles
|
|
27280
|
-
}, value);
|
|
27281
|
-
}
|
|
27282
|
-
|
|
27283
|
-
function LiveRegion(_ref) {
|
|
27284
|
-
let {
|
|
27285
|
-
id,
|
|
27286
|
-
announcement,
|
|
27287
|
-
ariaLiveType = "assertive"
|
|
27288
|
-
} = _ref;
|
|
27289
|
-
// Hide element visually but keep it readable by screen readers
|
|
27290
|
-
const visuallyHidden = {
|
|
27291
|
-
position: 'fixed',
|
|
27292
|
-
top: 0,
|
|
27293
|
-
left: 0,
|
|
27294
|
-
width: 1,
|
|
27295
|
-
height: 1,
|
|
27296
|
-
margin: -1,
|
|
27297
|
-
border: 0,
|
|
27298
|
-
padding: 0,
|
|
27299
|
-
overflow: 'hidden',
|
|
27300
|
-
clip: 'rect(0 0 0 0)',
|
|
27301
|
-
clipPath: 'inset(100%)',
|
|
27302
|
-
whiteSpace: 'nowrap'
|
|
27303
|
-
};
|
|
27304
|
-
return React__default.createElement("div", {
|
|
27305
|
-
id: id,
|
|
27306
|
-
style: visuallyHidden,
|
|
27307
|
-
role: "status",
|
|
27308
|
-
"aria-live": ariaLiveType,
|
|
27309
|
-
"aria-atomic": true
|
|
27310
|
-
}, announcement);
|
|
27311
|
-
}
|
|
27312
|
-
|
|
27313
|
-
function useAnnouncement() {
|
|
27314
|
-
const [announcement, setAnnouncement] = useState('');
|
|
27315
|
-
const announce = useCallback(value => {
|
|
27316
|
-
if (value != null) {
|
|
27317
|
-
setAnnouncement(value);
|
|
27318
|
-
}
|
|
27319
|
-
}, []);
|
|
27320
|
-
return {
|
|
27321
|
-
announce,
|
|
27322
|
-
announcement
|
|
27323
|
-
};
|
|
27324
|
-
}
|
|
27325
|
-
|
|
27326
|
-
const DndMonitorContext = /*#__PURE__*/createContext(null);
|
|
27327
|
-
|
|
27328
|
-
function useDndMonitor(listener) {
|
|
27329
|
-
const registerListener = useContext(DndMonitorContext);
|
|
27330
|
-
useEffect(() => {
|
|
27331
|
-
if (!registerListener) {
|
|
27332
|
-
throw new Error('useDndMonitor must be used within a children of <DndContext>');
|
|
27333
|
-
}
|
|
27334
|
-
|
|
27335
|
-
const unsubscribe = registerListener(listener);
|
|
27336
|
-
return unsubscribe;
|
|
27337
|
-
}, [listener, registerListener]);
|
|
27338
|
-
}
|
|
27339
27390
|
|
|
27340
|
-
|
|
27341
|
-
|
|
27342
|
-
|
|
27343
|
-
|
|
27344
|
-
|
|
27345
|
-
|
|
27346
|
-
|
|
27347
|
-
|
|
27348
|
-
|
|
27349
|
-
|
|
27350
|
-
}
|
|
27351
|
-
|
|
27352
|
-
|
|
27353
|
-
|
|
27354
|
-
|
|
27355
|
-
|
|
27356
|
-
|
|
27357
|
-
|
|
27358
|
-
|
|
27359
|
-
|
|
27360
|
-
|
|
27361
|
-
|
|
27391
|
+
const editColumn = (props) => {
|
|
27392
|
+
if (!props)
|
|
27393
|
+
return [];
|
|
27394
|
+
if (!props.displayEdit)
|
|
27395
|
+
return [];
|
|
27396
|
+
const handleEditClick = (id) => () => {
|
|
27397
|
+
props.setRowModesModel({ ...props.rowModesModel, [id]: { mode: GridRowModes.Edit } });
|
|
27398
|
+
};
|
|
27399
|
+
const handleSaveClick = (id) => () => {
|
|
27400
|
+
props.setRowModesModel({ ...props.rowModesModel, [id]: { mode: GridRowModes.View } });
|
|
27401
|
+
};
|
|
27402
|
+
const handleCancelClick = (id) => () => {
|
|
27403
|
+
props.setRowModesModel({
|
|
27404
|
+
...props.rowModesModel,
|
|
27405
|
+
[id]: { mode: GridRowModes.View, ignoreModifications: true },
|
|
27406
|
+
});
|
|
27407
|
+
};
|
|
27408
|
+
return [{
|
|
27409
|
+
field: 'edit',
|
|
27410
|
+
headerName: 'Editar',
|
|
27411
|
+
type: 'actions',
|
|
27412
|
+
width: 80,
|
|
27413
|
+
cellClassName: 'actions',
|
|
27414
|
+
getActions: ({ id, row }) => {
|
|
27415
|
+
const canEdit = get$1(row, 'obj_permissions.edit');
|
|
27416
|
+
const isInEditMode = props.rowModesModel[id]?.mode === GridRowModes.Edit;
|
|
27417
|
+
if (isInEditMode) {
|
|
27418
|
+
return [
|
|
27419
|
+
jsx(GridActionsCellItem, { icon: jsx(SaveIcon, {}), label: 'Guardar', color: 'primary', onClick: handleSaveClick(id) }, 'save'),
|
|
27420
|
+
jsx(GridActionsCellItem, { icon: jsx(CancelIcon, {}), label: 'Cancelar', className: 'textPrimary', onClick: handleCancelClick(id), color: 'inherit' }, 'cancel'),
|
|
27421
|
+
];
|
|
27422
|
+
}
|
|
27423
|
+
return [
|
|
27424
|
+
jsx(GridActionsCellItem, { icon: jsx(EditIcon, { sx: { color: canEdit ? 'black' : 'inherit' } }), label: 'Editar', className: 'textPrimary', onClick: handleEditClick(id), disabled: !canEdit }, 'edit'),
|
|
27425
|
+
];
|
|
27426
|
+
}
|
|
27427
|
+
}];
|
|
27362
27428
|
};
|
|
27363
|
-
const defaultAnnouncements = {
|
|
27364
|
-
onDragStart(_ref) {
|
|
27365
|
-
let {
|
|
27366
|
-
active
|
|
27367
|
-
} = _ref;
|
|
27368
|
-
return "Picked up draggable item " + active.id + ".";
|
|
27369
|
-
},
|
|
27370
|
-
|
|
27371
|
-
onDragOver(_ref2) {
|
|
27372
|
-
let {
|
|
27373
|
-
active,
|
|
27374
|
-
over
|
|
27375
|
-
} = _ref2;
|
|
27376
|
-
|
|
27377
|
-
if (over) {
|
|
27378
|
-
return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
|
|
27379
|
-
}
|
|
27380
|
-
|
|
27381
|
-
return "Draggable item " + active.id + " is no longer over a droppable area.";
|
|
27382
|
-
},
|
|
27383
|
-
|
|
27384
|
-
onDragEnd(_ref3) {
|
|
27385
|
-
let {
|
|
27386
|
-
active,
|
|
27387
|
-
over
|
|
27388
|
-
} = _ref3;
|
|
27389
|
-
|
|
27390
|
-
if (over) {
|
|
27391
|
-
return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
|
|
27392
|
-
}
|
|
27393
|
-
|
|
27394
|
-
return "Draggable item " + active.id + " was dropped.";
|
|
27395
|
-
},
|
|
27396
|
-
|
|
27397
|
-
onDragCancel(_ref4) {
|
|
27398
|
-
let {
|
|
27399
|
-
active
|
|
27400
|
-
} = _ref4;
|
|
27401
|
-
return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
|
|
27402
|
-
}
|
|
27403
27429
|
|
|
27404
|
-
|
|
27405
|
-
|
|
27406
|
-
|
|
27407
|
-
|
|
27408
|
-
|
|
27409
|
-
|
|
27410
|
-
|
|
27411
|
-
|
|
27412
|
-
|
|
27413
|
-
|
|
27414
|
-
|
|
27415
|
-
|
|
27416
|
-
|
|
27417
|
-
|
|
27418
|
-
|
|
27419
|
-
useEffect(() => {
|
|
27420
|
-
setMounted(true);
|
|
27421
|
-
}, []);
|
|
27422
|
-
useDndMonitor(useMemo(() => ({
|
|
27423
|
-
onDragStart(_ref2) {
|
|
27424
|
-
let {
|
|
27425
|
-
active
|
|
27426
|
-
} = _ref2;
|
|
27427
|
-
announce(announcements.onDragStart({
|
|
27428
|
-
active
|
|
27429
|
-
}));
|
|
27430
|
-
},
|
|
27431
|
-
|
|
27432
|
-
onDragMove(_ref3) {
|
|
27433
|
-
let {
|
|
27434
|
-
active,
|
|
27435
|
-
over
|
|
27436
|
-
} = _ref3;
|
|
27437
|
-
|
|
27438
|
-
if (announcements.onDragMove) {
|
|
27439
|
-
announce(announcements.onDragMove({
|
|
27440
|
-
active,
|
|
27441
|
-
over
|
|
27442
|
-
}));
|
|
27443
|
-
}
|
|
27444
|
-
},
|
|
27445
|
-
|
|
27446
|
-
onDragOver(_ref4) {
|
|
27447
|
-
let {
|
|
27448
|
-
active,
|
|
27449
|
-
over
|
|
27450
|
-
} = _ref4;
|
|
27451
|
-
announce(announcements.onDragOver({
|
|
27452
|
-
active,
|
|
27453
|
-
over
|
|
27454
|
-
}));
|
|
27455
|
-
},
|
|
27456
|
-
|
|
27457
|
-
onDragEnd(_ref5) {
|
|
27458
|
-
let {
|
|
27459
|
-
active,
|
|
27460
|
-
over
|
|
27461
|
-
} = _ref5;
|
|
27462
|
-
announce(announcements.onDragEnd({
|
|
27463
|
-
active,
|
|
27464
|
-
over
|
|
27465
|
-
}));
|
|
27466
|
-
},
|
|
27467
|
-
|
|
27468
|
-
onDragCancel(_ref6) {
|
|
27469
|
-
let {
|
|
27470
|
-
active,
|
|
27471
|
-
over
|
|
27472
|
-
} = _ref6;
|
|
27473
|
-
announce(announcements.onDragCancel({
|
|
27474
|
-
active,
|
|
27475
|
-
over
|
|
27476
|
-
}));
|
|
27477
|
-
}
|
|
27478
|
-
|
|
27479
|
-
}), [announce, announcements]));
|
|
27480
|
-
|
|
27481
|
-
if (!mounted) {
|
|
27482
|
-
return null;
|
|
27483
|
-
}
|
|
27484
|
-
|
|
27485
|
-
const markup = React__default.createElement(React__default.Fragment, null, React__default.createElement(HiddenText, {
|
|
27486
|
-
id: hiddenTextDescribedById,
|
|
27487
|
-
value: screenReaderInstructions.draggable
|
|
27488
|
-
}), React__default.createElement(LiveRegion, {
|
|
27489
|
-
id: liveRegionId,
|
|
27490
|
-
announcement: announcement
|
|
27491
|
-
}));
|
|
27492
|
-
return container ? createPortal(markup, container) : markup;
|
|
27493
|
-
}
|
|
27494
|
-
|
|
27495
|
-
var Action;
|
|
27496
|
-
|
|
27497
|
-
(function (Action) {
|
|
27498
|
-
Action["DragStart"] = "dragStart";
|
|
27499
|
-
Action["DragMove"] = "dragMove";
|
|
27500
|
-
Action["DragEnd"] = "dragEnd";
|
|
27501
|
-
Action["DragCancel"] = "dragCancel";
|
|
27502
|
-
Action["DragOver"] = "dragOver";
|
|
27503
|
-
Action["RegisterDroppable"] = "registerDroppable";
|
|
27504
|
-
Action["SetDroppableDisabled"] = "setDroppableDisabled";
|
|
27505
|
-
Action["UnregisterDroppable"] = "unregisterDroppable";
|
|
27506
|
-
})(Action || (Action = {}));
|
|
27507
|
-
|
|
27508
|
-
function noop() {}
|
|
27509
|
-
|
|
27510
|
-
function useSensor(sensor, options) {
|
|
27511
|
-
return useMemo(() => ({
|
|
27512
|
-
sensor,
|
|
27513
|
-
options: {}
|
|
27514
|
-
}), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27515
|
-
[sensor, options]);
|
|
27516
|
-
}
|
|
27517
|
-
|
|
27518
|
-
function useSensors() {
|
|
27519
|
-
for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
27520
|
-
sensors[_key] = arguments[_key];
|
|
27521
|
-
}
|
|
27522
|
-
|
|
27523
|
-
return useMemo(() => [...sensors].filter(sensor => sensor != null), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27524
|
-
[...sensors]);
|
|
27525
|
-
}
|
|
27526
|
-
|
|
27527
|
-
const defaultCoordinates = /*#__PURE__*/Object.freeze({
|
|
27528
|
-
x: 0,
|
|
27529
|
-
y: 0
|
|
27530
|
-
});
|
|
27531
|
-
|
|
27532
|
-
/**
|
|
27533
|
-
* Returns the distance between two points
|
|
27534
|
-
*/
|
|
27535
|
-
function distanceBetween(p1, p2) {
|
|
27536
|
-
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
|
|
27537
|
-
}
|
|
27538
|
-
|
|
27539
|
-
/**
|
|
27540
|
-
* Sort collisions from smallest to greatest value
|
|
27541
|
-
*/
|
|
27542
|
-
function sortCollisionsAsc(_ref, _ref2) {
|
|
27543
|
-
let {
|
|
27544
|
-
data: {
|
|
27545
|
-
value: a
|
|
27546
|
-
}
|
|
27547
|
-
} = _ref;
|
|
27548
|
-
let {
|
|
27549
|
-
data: {
|
|
27550
|
-
value: b
|
|
27551
|
-
}
|
|
27552
|
-
} = _ref2;
|
|
27553
|
-
return a - b;
|
|
27554
|
-
}
|
|
27555
|
-
/**
|
|
27556
|
-
* Sort collisions from greatest to smallest value
|
|
27557
|
-
*/
|
|
27558
|
-
|
|
27559
|
-
function sortCollisionsDesc(_ref3, _ref4) {
|
|
27560
|
-
let {
|
|
27561
|
-
data: {
|
|
27562
|
-
value: a
|
|
27563
|
-
}
|
|
27564
|
-
} = _ref3;
|
|
27565
|
-
let {
|
|
27566
|
-
data: {
|
|
27567
|
-
value: b
|
|
27568
|
-
}
|
|
27569
|
-
} = _ref4;
|
|
27570
|
-
return b - a;
|
|
27571
|
-
}
|
|
27572
|
-
function getFirstCollision(collisions, property) {
|
|
27573
|
-
if (!collisions || collisions.length === 0) {
|
|
27574
|
-
return null;
|
|
27575
|
-
}
|
|
27576
|
-
|
|
27577
|
-
const [firstCollision] = collisions;
|
|
27578
|
-
return firstCollision[property] ;
|
|
27579
|
-
}
|
|
27580
|
-
|
|
27581
|
-
/**
|
|
27582
|
-
* Returns the coordinates of the center of a given ClientRect
|
|
27583
|
-
*/
|
|
27584
|
-
|
|
27585
|
-
function centerOfRectangle(rect, left, top) {
|
|
27586
|
-
if (left === void 0) {
|
|
27587
|
-
left = rect.left;
|
|
27588
|
-
}
|
|
27589
|
-
|
|
27590
|
-
if (top === void 0) {
|
|
27591
|
-
top = rect.top;
|
|
27592
|
-
}
|
|
27593
|
-
|
|
27594
|
-
return {
|
|
27595
|
-
x: left + rect.width * 0.5,
|
|
27596
|
-
y: top + rect.height * 0.5
|
|
27597
|
-
};
|
|
27598
|
-
}
|
|
27599
|
-
/**
|
|
27600
|
-
* Returns the closest rectangles from an array of rectangles to the center of a given
|
|
27601
|
-
* rectangle.
|
|
27602
|
-
*/
|
|
27603
|
-
|
|
27604
|
-
|
|
27605
|
-
const closestCenter = _ref => {
|
|
27606
|
-
let {
|
|
27607
|
-
collisionRect,
|
|
27608
|
-
droppableRects,
|
|
27609
|
-
droppableContainers
|
|
27610
|
-
} = _ref;
|
|
27611
|
-
const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top);
|
|
27612
|
-
const collisions = [];
|
|
27613
|
-
|
|
27614
|
-
for (const droppableContainer of droppableContainers) {
|
|
27615
|
-
const {
|
|
27616
|
-
id
|
|
27617
|
-
} = droppableContainer;
|
|
27618
|
-
const rect = droppableRects.get(id);
|
|
27619
|
-
|
|
27620
|
-
if (rect) {
|
|
27621
|
-
const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
|
|
27622
|
-
collisions.push({
|
|
27623
|
-
id,
|
|
27624
|
-
data: {
|
|
27625
|
-
droppableContainer,
|
|
27626
|
-
value: distBetween
|
|
27627
|
-
}
|
|
27628
|
-
});
|
|
27629
|
-
}
|
|
27630
|
-
}
|
|
27631
|
-
|
|
27632
|
-
return collisions.sort(sortCollisionsAsc);
|
|
27633
|
-
};
|
|
27634
|
-
|
|
27635
|
-
/**
|
|
27636
|
-
* Returns the intersecting rectangle area between two rectangles
|
|
27637
|
-
*/
|
|
27638
|
-
|
|
27639
|
-
function getIntersectionRatio(entry, target) {
|
|
27640
|
-
const top = Math.max(target.top, entry.top);
|
|
27641
|
-
const left = Math.max(target.left, entry.left);
|
|
27642
|
-
const right = Math.min(target.left + target.width, entry.left + entry.width);
|
|
27643
|
-
const bottom = Math.min(target.top + target.height, entry.top + entry.height);
|
|
27644
|
-
const width = right - left;
|
|
27645
|
-
const height = bottom - top;
|
|
27646
|
-
|
|
27647
|
-
if (left < right && top < bottom) {
|
|
27648
|
-
const targetArea = target.width * target.height;
|
|
27649
|
-
const entryArea = entry.width * entry.height;
|
|
27650
|
-
const intersectionArea = width * height;
|
|
27651
|
-
const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
|
|
27652
|
-
return Number(intersectionRatio.toFixed(4));
|
|
27653
|
-
} // Rectangles do not overlap, or overlap has an area of zero (edge/corner overlap)
|
|
27654
|
-
|
|
27655
|
-
|
|
27656
|
-
return 0;
|
|
27657
|
-
}
|
|
27658
|
-
/**
|
|
27659
|
-
* Returns the rectangles that has the greatest intersection area with a given
|
|
27660
|
-
* rectangle in an array of rectangles.
|
|
27661
|
-
*/
|
|
27662
|
-
|
|
27663
|
-
const rectIntersection = _ref => {
|
|
27664
|
-
let {
|
|
27665
|
-
collisionRect,
|
|
27666
|
-
droppableRects,
|
|
27667
|
-
droppableContainers
|
|
27668
|
-
} = _ref;
|
|
27669
|
-
const collisions = [];
|
|
27670
|
-
|
|
27671
|
-
for (const droppableContainer of droppableContainers) {
|
|
27672
|
-
const {
|
|
27673
|
-
id
|
|
27674
|
-
} = droppableContainer;
|
|
27675
|
-
const rect = droppableRects.get(id);
|
|
27676
|
-
|
|
27677
|
-
if (rect) {
|
|
27678
|
-
const intersectionRatio = getIntersectionRatio(rect, collisionRect);
|
|
27679
|
-
|
|
27680
|
-
if (intersectionRatio > 0) {
|
|
27681
|
-
collisions.push({
|
|
27682
|
-
id,
|
|
27683
|
-
data: {
|
|
27684
|
-
droppableContainer,
|
|
27685
|
-
value: intersectionRatio
|
|
27686
|
-
}
|
|
27687
|
-
});
|
|
27688
|
-
}
|
|
27689
|
-
}
|
|
27690
|
-
}
|
|
27691
|
-
|
|
27692
|
-
return collisions.sort(sortCollisionsDesc);
|
|
27693
|
-
};
|
|
27694
|
-
|
|
27695
|
-
function adjustScale(transform, rect1, rect2) {
|
|
27696
|
-
return { ...transform,
|
|
27697
|
-
scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
|
|
27698
|
-
scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
|
|
27699
|
-
};
|
|
27700
|
-
}
|
|
27701
|
-
|
|
27702
|
-
function getRectDelta(rect1, rect2) {
|
|
27703
|
-
return rect1 && rect2 ? {
|
|
27704
|
-
x: rect1.left - rect2.left,
|
|
27705
|
-
y: rect1.top - rect2.top
|
|
27706
|
-
} : defaultCoordinates;
|
|
27707
|
-
}
|
|
27708
|
-
|
|
27709
|
-
function createRectAdjustmentFn(modifier) {
|
|
27710
|
-
return function adjustClientRect(rect) {
|
|
27711
|
-
for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
27712
|
-
adjustments[_key - 1] = arguments[_key];
|
|
27713
|
-
}
|
|
27714
|
-
|
|
27715
|
-
return adjustments.reduce((acc, adjustment) => ({ ...acc,
|
|
27716
|
-
top: acc.top + modifier * adjustment.y,
|
|
27717
|
-
bottom: acc.bottom + modifier * adjustment.y,
|
|
27718
|
-
left: acc.left + modifier * adjustment.x,
|
|
27719
|
-
right: acc.right + modifier * adjustment.x
|
|
27720
|
-
}), { ...rect
|
|
27721
|
-
});
|
|
27722
|
-
};
|
|
27723
|
-
}
|
|
27724
|
-
const getAdjustedRect = /*#__PURE__*/createRectAdjustmentFn(1);
|
|
27725
|
-
|
|
27726
|
-
function parseTransform(transform) {
|
|
27727
|
-
if (transform.startsWith('matrix3d(')) {
|
|
27728
|
-
const transformArray = transform.slice(9, -1).split(/, /);
|
|
27729
|
-
return {
|
|
27730
|
-
x: +transformArray[12],
|
|
27731
|
-
y: +transformArray[13],
|
|
27732
|
-
scaleX: +transformArray[0],
|
|
27733
|
-
scaleY: +transformArray[5]
|
|
27734
|
-
};
|
|
27735
|
-
} else if (transform.startsWith('matrix(')) {
|
|
27736
|
-
const transformArray = transform.slice(7, -1).split(/, /);
|
|
27737
|
-
return {
|
|
27738
|
-
x: +transformArray[4],
|
|
27739
|
-
y: +transformArray[5],
|
|
27740
|
-
scaleX: +transformArray[0],
|
|
27741
|
-
scaleY: +transformArray[3]
|
|
27742
|
-
};
|
|
27743
|
-
}
|
|
27744
|
-
|
|
27745
|
-
return null;
|
|
27746
|
-
}
|
|
27747
|
-
|
|
27748
|
-
function inverseTransform(rect, transform, transformOrigin) {
|
|
27749
|
-
const parsedTransform = parseTransform(transform);
|
|
27750
|
-
|
|
27751
|
-
if (!parsedTransform) {
|
|
27752
|
-
return rect;
|
|
27753
|
-
}
|
|
27754
|
-
|
|
27755
|
-
const {
|
|
27756
|
-
scaleX,
|
|
27757
|
-
scaleY,
|
|
27758
|
-
x: translateX,
|
|
27759
|
-
y: translateY
|
|
27760
|
-
} = parsedTransform;
|
|
27761
|
-
const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
|
|
27762
|
-
const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(' ') + 1));
|
|
27763
|
-
const w = scaleX ? rect.width / scaleX : rect.width;
|
|
27764
|
-
const h = scaleY ? rect.height / scaleY : rect.height;
|
|
27765
|
-
return {
|
|
27766
|
-
width: w,
|
|
27767
|
-
height: h,
|
|
27768
|
-
top: y,
|
|
27769
|
-
right: x + w,
|
|
27770
|
-
bottom: y + h,
|
|
27771
|
-
left: x
|
|
27772
|
-
};
|
|
27773
|
-
}
|
|
27774
|
-
|
|
27775
|
-
const defaultOptions = {
|
|
27776
|
-
ignoreTransform: false
|
|
27777
|
-
};
|
|
27778
|
-
/**
|
|
27779
|
-
* Returns the bounding client rect of an element relative to the viewport.
|
|
27780
|
-
*/
|
|
27781
|
-
|
|
27782
|
-
function getClientRect(element, options) {
|
|
27783
|
-
if (options === void 0) {
|
|
27784
|
-
options = defaultOptions;
|
|
27785
|
-
}
|
|
27786
|
-
|
|
27787
|
-
let rect = element.getBoundingClientRect();
|
|
27788
|
-
|
|
27789
|
-
if (options.ignoreTransform) {
|
|
27790
|
-
const {
|
|
27791
|
-
transform,
|
|
27792
|
-
transformOrigin
|
|
27793
|
-
} = getWindow(element).getComputedStyle(element);
|
|
27794
|
-
|
|
27795
|
-
if (transform) {
|
|
27796
|
-
rect = inverseTransform(rect, transform, transformOrigin);
|
|
27797
|
-
}
|
|
27798
|
-
}
|
|
27799
|
-
|
|
27800
|
-
const {
|
|
27801
|
-
top,
|
|
27802
|
-
left,
|
|
27803
|
-
width,
|
|
27804
|
-
height,
|
|
27805
|
-
bottom,
|
|
27806
|
-
right
|
|
27807
|
-
} = rect;
|
|
27808
|
-
return {
|
|
27809
|
-
top,
|
|
27810
|
-
left,
|
|
27811
|
-
width,
|
|
27812
|
-
height,
|
|
27813
|
-
bottom,
|
|
27814
|
-
right
|
|
27815
|
-
};
|
|
27816
|
-
}
|
|
27817
|
-
/**
|
|
27818
|
-
* Returns the bounding client rect of an element relative to the viewport.
|
|
27819
|
-
*
|
|
27820
|
-
* @remarks
|
|
27821
|
-
* The ClientRect returned by this method does not take into account transforms
|
|
27822
|
-
* applied to the element it measures.
|
|
27823
|
-
*
|
|
27824
|
-
*/
|
|
27825
|
-
|
|
27826
|
-
function getTransformAgnosticClientRect(element) {
|
|
27827
|
-
return getClientRect(element, {
|
|
27828
|
-
ignoreTransform: true
|
|
27829
|
-
});
|
|
27830
|
-
}
|
|
27831
|
-
|
|
27832
|
-
function getWindowClientRect(element) {
|
|
27833
|
-
const width = element.innerWidth;
|
|
27834
|
-
const height = element.innerHeight;
|
|
27835
|
-
return {
|
|
27836
|
-
top: 0,
|
|
27837
|
-
left: 0,
|
|
27838
|
-
right: width,
|
|
27839
|
-
bottom: height,
|
|
27840
|
-
width,
|
|
27841
|
-
height
|
|
27842
|
-
};
|
|
27843
|
-
}
|
|
27844
|
-
|
|
27845
|
-
function isFixed(node, computedStyle) {
|
|
27846
|
-
if (computedStyle === void 0) {
|
|
27847
|
-
computedStyle = getWindow(node).getComputedStyle(node);
|
|
27848
|
-
}
|
|
27849
|
-
|
|
27850
|
-
return computedStyle.position === 'fixed';
|
|
27851
|
-
}
|
|
27852
|
-
|
|
27853
|
-
function isScrollable(element, computedStyle) {
|
|
27854
|
-
if (computedStyle === void 0) {
|
|
27855
|
-
computedStyle = getWindow(element).getComputedStyle(element);
|
|
27856
|
-
}
|
|
27857
|
-
|
|
27858
|
-
const overflowRegex = /(auto|scroll|overlay)/;
|
|
27859
|
-
const properties = ['overflow', 'overflowX', 'overflowY'];
|
|
27860
|
-
return properties.some(property => {
|
|
27861
|
-
const value = computedStyle[property];
|
|
27862
|
-
return typeof value === 'string' ? overflowRegex.test(value) : false;
|
|
27863
|
-
});
|
|
27864
|
-
}
|
|
27865
|
-
|
|
27866
|
-
function getScrollableAncestors(element, limit) {
|
|
27867
|
-
const scrollParents = [];
|
|
27868
|
-
|
|
27869
|
-
function findScrollableAncestors(node) {
|
|
27870
|
-
if (limit != null && scrollParents.length >= limit) {
|
|
27871
|
-
return scrollParents;
|
|
27872
|
-
}
|
|
27873
|
-
|
|
27874
|
-
if (!node) {
|
|
27875
|
-
return scrollParents;
|
|
27876
|
-
}
|
|
27877
|
-
|
|
27878
|
-
if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
|
|
27879
|
-
scrollParents.push(node.scrollingElement);
|
|
27880
|
-
return scrollParents;
|
|
27881
|
-
}
|
|
27882
|
-
|
|
27883
|
-
if (!isHTMLElement(node) || isSVGElement(node)) {
|
|
27884
|
-
return scrollParents;
|
|
27885
|
-
}
|
|
27886
|
-
|
|
27887
|
-
if (scrollParents.includes(node)) {
|
|
27888
|
-
return scrollParents;
|
|
27889
|
-
}
|
|
27890
|
-
|
|
27891
|
-
const computedStyle = getWindow(element).getComputedStyle(node);
|
|
27892
|
-
|
|
27893
|
-
if (node !== element) {
|
|
27894
|
-
if (isScrollable(node, computedStyle)) {
|
|
27895
|
-
scrollParents.push(node);
|
|
27896
|
-
}
|
|
27897
|
-
}
|
|
27898
|
-
|
|
27899
|
-
if (isFixed(node, computedStyle)) {
|
|
27900
|
-
return scrollParents;
|
|
27901
|
-
}
|
|
27902
|
-
|
|
27903
|
-
return findScrollableAncestors(node.parentNode);
|
|
27904
|
-
}
|
|
27905
|
-
|
|
27906
|
-
if (!element) {
|
|
27907
|
-
return scrollParents;
|
|
27908
|
-
}
|
|
27909
|
-
|
|
27910
|
-
return findScrollableAncestors(element);
|
|
27911
|
-
}
|
|
27912
|
-
function getFirstScrollableAncestor(node) {
|
|
27913
|
-
const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
|
|
27914
|
-
return firstScrollableAncestor != null ? firstScrollableAncestor : null;
|
|
27915
|
-
}
|
|
27916
|
-
|
|
27917
|
-
function getScrollableElement(element) {
|
|
27918
|
-
if (!canUseDOM || !element) {
|
|
27919
|
-
return null;
|
|
27920
|
-
}
|
|
27921
|
-
|
|
27922
|
-
if (isWindow(element)) {
|
|
27923
|
-
return element;
|
|
27924
|
-
}
|
|
27925
|
-
|
|
27926
|
-
if (!isNode(element)) {
|
|
27927
|
-
return null;
|
|
27928
|
-
}
|
|
27929
|
-
|
|
27930
|
-
if (isDocument(element) || element === getOwnerDocument(element).scrollingElement) {
|
|
27931
|
-
return window;
|
|
27932
|
-
}
|
|
27933
|
-
|
|
27934
|
-
if (isHTMLElement(element)) {
|
|
27935
|
-
return element;
|
|
27936
|
-
}
|
|
27937
|
-
|
|
27938
|
-
return null;
|
|
27939
|
-
}
|
|
27940
|
-
|
|
27941
|
-
function getScrollXCoordinate(element) {
|
|
27942
|
-
if (isWindow(element)) {
|
|
27943
|
-
return element.scrollX;
|
|
27944
|
-
}
|
|
27945
|
-
|
|
27946
|
-
return element.scrollLeft;
|
|
27947
|
-
}
|
|
27948
|
-
function getScrollYCoordinate(element) {
|
|
27949
|
-
if (isWindow(element)) {
|
|
27950
|
-
return element.scrollY;
|
|
27951
|
-
}
|
|
27952
|
-
|
|
27953
|
-
return element.scrollTop;
|
|
27954
|
-
}
|
|
27955
|
-
function getScrollCoordinates(element) {
|
|
27956
|
-
return {
|
|
27957
|
-
x: getScrollXCoordinate(element),
|
|
27958
|
-
y: getScrollYCoordinate(element)
|
|
27959
|
-
};
|
|
27960
|
-
}
|
|
27961
|
-
|
|
27962
|
-
var Direction;
|
|
27963
|
-
|
|
27964
|
-
(function (Direction) {
|
|
27965
|
-
Direction[Direction["Forward"] = 1] = "Forward";
|
|
27966
|
-
Direction[Direction["Backward"] = -1] = "Backward";
|
|
27967
|
-
})(Direction || (Direction = {}));
|
|
27968
|
-
|
|
27969
|
-
function isDocumentScrollingElement(element) {
|
|
27970
|
-
if (!canUseDOM || !element) {
|
|
27971
|
-
return false;
|
|
27972
|
-
}
|
|
27973
|
-
|
|
27974
|
-
return element === document.scrollingElement;
|
|
27975
|
-
}
|
|
27976
|
-
|
|
27977
|
-
function getScrollPosition(scrollingContainer) {
|
|
27978
|
-
const minScroll = {
|
|
27979
|
-
x: 0,
|
|
27980
|
-
y: 0
|
|
27981
|
-
};
|
|
27982
|
-
const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
|
|
27983
|
-
height: window.innerHeight,
|
|
27984
|
-
width: window.innerWidth
|
|
27985
|
-
} : {
|
|
27986
|
-
height: scrollingContainer.clientHeight,
|
|
27987
|
-
width: scrollingContainer.clientWidth
|
|
27988
|
-
};
|
|
27989
|
-
const maxScroll = {
|
|
27990
|
-
x: scrollingContainer.scrollWidth - dimensions.width,
|
|
27991
|
-
y: scrollingContainer.scrollHeight - dimensions.height
|
|
27992
|
-
};
|
|
27993
|
-
const isTop = scrollingContainer.scrollTop <= minScroll.y;
|
|
27994
|
-
const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
|
|
27995
|
-
const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
|
|
27996
|
-
const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
|
|
27997
|
-
return {
|
|
27998
|
-
isTop,
|
|
27999
|
-
isLeft,
|
|
28000
|
-
isBottom,
|
|
28001
|
-
isRight,
|
|
28002
|
-
maxScroll,
|
|
28003
|
-
minScroll
|
|
28004
|
-
};
|
|
28005
|
-
}
|
|
28006
|
-
|
|
28007
|
-
const defaultThreshold = {
|
|
28008
|
-
x: 0.2,
|
|
28009
|
-
y: 0.2
|
|
28010
|
-
};
|
|
28011
|
-
function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
|
|
28012
|
-
let {
|
|
28013
|
-
top,
|
|
28014
|
-
left,
|
|
28015
|
-
right,
|
|
28016
|
-
bottom
|
|
28017
|
-
} = _ref;
|
|
28018
|
-
|
|
28019
|
-
if (acceleration === void 0) {
|
|
28020
|
-
acceleration = 10;
|
|
28021
|
-
}
|
|
28022
|
-
|
|
28023
|
-
if (thresholdPercentage === void 0) {
|
|
28024
|
-
thresholdPercentage = defaultThreshold;
|
|
28025
|
-
}
|
|
28026
|
-
|
|
28027
|
-
const {
|
|
28028
|
-
isTop,
|
|
28029
|
-
isBottom,
|
|
28030
|
-
isLeft,
|
|
28031
|
-
isRight
|
|
28032
|
-
} = getScrollPosition(scrollContainer);
|
|
28033
|
-
const direction = {
|
|
28034
|
-
x: 0,
|
|
28035
|
-
y: 0
|
|
28036
|
-
};
|
|
28037
|
-
const speed = {
|
|
28038
|
-
x: 0,
|
|
28039
|
-
y: 0
|
|
28040
|
-
};
|
|
28041
|
-
const threshold = {
|
|
28042
|
-
height: scrollContainerRect.height * thresholdPercentage.y,
|
|
28043
|
-
width: scrollContainerRect.width * thresholdPercentage.x
|
|
28044
|
-
};
|
|
28045
|
-
|
|
28046
|
-
if (!isTop && top <= scrollContainerRect.top + threshold.height) {
|
|
28047
|
-
// Scroll Up
|
|
28048
|
-
direction.y = Direction.Backward;
|
|
28049
|
-
speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
|
|
28050
|
-
} else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
|
|
28051
|
-
// Scroll Down
|
|
28052
|
-
direction.y = Direction.Forward;
|
|
28053
|
-
speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
|
|
28054
|
-
}
|
|
28055
|
-
|
|
28056
|
-
if (!isRight && right >= scrollContainerRect.right - threshold.width) {
|
|
28057
|
-
// Scroll Right
|
|
28058
|
-
direction.x = Direction.Forward;
|
|
28059
|
-
speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
|
|
28060
|
-
} else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
|
|
28061
|
-
// Scroll Left
|
|
28062
|
-
direction.x = Direction.Backward;
|
|
28063
|
-
speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
|
|
28064
|
-
}
|
|
28065
|
-
|
|
28066
|
-
return {
|
|
28067
|
-
direction,
|
|
28068
|
-
speed
|
|
28069
|
-
};
|
|
28070
|
-
}
|
|
28071
|
-
|
|
28072
|
-
function getScrollElementRect(element) {
|
|
28073
|
-
if (element === document.scrollingElement) {
|
|
28074
|
-
const {
|
|
28075
|
-
innerWidth,
|
|
28076
|
-
innerHeight
|
|
28077
|
-
} = window;
|
|
28078
|
-
return {
|
|
28079
|
-
top: 0,
|
|
28080
|
-
left: 0,
|
|
28081
|
-
right: innerWidth,
|
|
28082
|
-
bottom: innerHeight,
|
|
28083
|
-
width: innerWidth,
|
|
28084
|
-
height: innerHeight
|
|
28085
|
-
};
|
|
28086
|
-
}
|
|
28087
|
-
|
|
28088
|
-
const {
|
|
28089
|
-
top,
|
|
28090
|
-
left,
|
|
28091
|
-
right,
|
|
28092
|
-
bottom
|
|
28093
|
-
} = element.getBoundingClientRect();
|
|
28094
|
-
return {
|
|
28095
|
-
top,
|
|
28096
|
-
left,
|
|
28097
|
-
right,
|
|
28098
|
-
bottom,
|
|
28099
|
-
width: element.clientWidth,
|
|
28100
|
-
height: element.clientHeight
|
|
28101
|
-
};
|
|
28102
|
-
}
|
|
28103
|
-
|
|
28104
|
-
function getScrollOffsets(scrollableAncestors) {
|
|
28105
|
-
return scrollableAncestors.reduce((acc, node) => {
|
|
28106
|
-
return add(acc, getScrollCoordinates(node));
|
|
28107
|
-
}, defaultCoordinates);
|
|
28108
|
-
}
|
|
28109
|
-
function getScrollXOffset(scrollableAncestors) {
|
|
28110
|
-
return scrollableAncestors.reduce((acc, node) => {
|
|
28111
|
-
return acc + getScrollXCoordinate(node);
|
|
28112
|
-
}, 0);
|
|
28113
|
-
}
|
|
28114
|
-
function getScrollYOffset(scrollableAncestors) {
|
|
28115
|
-
return scrollableAncestors.reduce((acc, node) => {
|
|
28116
|
-
return acc + getScrollYCoordinate(node);
|
|
28117
|
-
}, 0);
|
|
28118
|
-
}
|
|
28119
|
-
|
|
28120
|
-
function scrollIntoViewIfNeeded(element, measure) {
|
|
28121
|
-
if (measure === void 0) {
|
|
28122
|
-
measure = getClientRect;
|
|
28123
|
-
}
|
|
28124
|
-
|
|
28125
|
-
if (!element) {
|
|
28126
|
-
return;
|
|
28127
|
-
}
|
|
28128
|
-
|
|
28129
|
-
const {
|
|
28130
|
-
top,
|
|
28131
|
-
left,
|
|
28132
|
-
bottom,
|
|
28133
|
-
right
|
|
28134
|
-
} = measure(element);
|
|
28135
|
-
const firstScrollableAncestor = getFirstScrollableAncestor(element);
|
|
28136
|
-
|
|
28137
|
-
if (!firstScrollableAncestor) {
|
|
28138
|
-
return;
|
|
28139
|
-
}
|
|
28140
|
-
|
|
28141
|
-
if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
|
|
28142
|
-
element.scrollIntoView({
|
|
28143
|
-
block: 'center',
|
|
28144
|
-
inline: 'center'
|
|
28145
|
-
});
|
|
28146
|
-
}
|
|
28147
|
-
}
|
|
28148
|
-
|
|
28149
|
-
const properties = [['x', ['left', 'right'], getScrollXOffset], ['y', ['top', 'bottom'], getScrollYOffset]];
|
|
28150
|
-
class Rect {
|
|
28151
|
-
constructor(rect, element) {
|
|
28152
|
-
this.rect = void 0;
|
|
28153
|
-
this.width = void 0;
|
|
28154
|
-
this.height = void 0;
|
|
28155
|
-
this.top = void 0;
|
|
28156
|
-
this.bottom = void 0;
|
|
28157
|
-
this.right = void 0;
|
|
28158
|
-
this.left = void 0;
|
|
28159
|
-
const scrollableAncestors = getScrollableAncestors(element);
|
|
28160
|
-
const scrollOffsets = getScrollOffsets(scrollableAncestors);
|
|
28161
|
-
this.rect = { ...rect
|
|
28162
|
-
};
|
|
28163
|
-
this.width = rect.width;
|
|
28164
|
-
this.height = rect.height;
|
|
28165
|
-
|
|
28166
|
-
for (const [axis, keys, getScrollOffset] of properties) {
|
|
28167
|
-
for (const key of keys) {
|
|
28168
|
-
Object.defineProperty(this, key, {
|
|
28169
|
-
get: () => {
|
|
28170
|
-
const currentOffsets = getScrollOffset(scrollableAncestors);
|
|
28171
|
-
const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
|
|
28172
|
-
return this.rect[key] + scrollOffsetsDeltla;
|
|
28173
|
-
},
|
|
28174
|
-
enumerable: true
|
|
28175
|
-
});
|
|
28176
|
-
}
|
|
28177
|
-
}
|
|
28178
|
-
|
|
28179
|
-
Object.defineProperty(this, 'rect', {
|
|
28180
|
-
enumerable: false
|
|
28181
|
-
});
|
|
28182
|
-
}
|
|
28183
|
-
|
|
28184
|
-
}
|
|
28185
|
-
|
|
28186
|
-
class Listeners {
|
|
28187
|
-
constructor(target) {
|
|
28188
|
-
this.target = void 0;
|
|
28189
|
-
this.listeners = [];
|
|
28190
|
-
|
|
28191
|
-
this.removeAll = () => {
|
|
28192
|
-
this.listeners.forEach(listener => {
|
|
28193
|
-
var _this$target;
|
|
28194
|
-
|
|
28195
|
-
return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
|
|
28196
|
-
});
|
|
28197
|
-
};
|
|
28198
|
-
|
|
28199
|
-
this.target = target;
|
|
28200
|
-
}
|
|
28201
|
-
|
|
28202
|
-
add(eventName, handler, options) {
|
|
28203
|
-
var _this$target2;
|
|
28204
|
-
|
|
28205
|
-
(_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
|
|
28206
|
-
this.listeners.push([eventName, handler, options]);
|
|
28207
|
-
}
|
|
28208
|
-
|
|
28209
|
-
}
|
|
28210
|
-
|
|
28211
|
-
function getEventListenerTarget(target) {
|
|
28212
|
-
// If the `event.target` element is removed from the document events will still be targeted
|
|
28213
|
-
// at it, and hence won't always bubble up to the window or document anymore.
|
|
28214
|
-
// If there is any risk of an element being removed while it is being dragged,
|
|
28215
|
-
// the best practice is to attach the event listeners directly to the target.
|
|
28216
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
|
|
28217
|
-
const {
|
|
28218
|
-
EventTarget
|
|
28219
|
-
} = getWindow(target);
|
|
28220
|
-
return target instanceof EventTarget ? target : getOwnerDocument(target);
|
|
28221
|
-
}
|
|
28222
|
-
|
|
28223
|
-
function hasExceededDistance(delta, measurement) {
|
|
28224
|
-
const dx = Math.abs(delta.x);
|
|
28225
|
-
const dy = Math.abs(delta.y);
|
|
28226
|
-
|
|
28227
|
-
if (typeof measurement === 'number') {
|
|
28228
|
-
return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
|
|
28229
|
-
}
|
|
28230
|
-
|
|
28231
|
-
if ('x' in measurement && 'y' in measurement) {
|
|
28232
|
-
return dx > measurement.x && dy > measurement.y;
|
|
28233
|
-
}
|
|
28234
|
-
|
|
28235
|
-
if ('x' in measurement) {
|
|
28236
|
-
return dx > measurement.x;
|
|
28237
|
-
}
|
|
28238
|
-
|
|
28239
|
-
if ('y' in measurement) {
|
|
28240
|
-
return dy > measurement.y;
|
|
28241
|
-
}
|
|
28242
|
-
|
|
28243
|
-
return false;
|
|
28244
|
-
}
|
|
28245
|
-
|
|
28246
|
-
var EventName;
|
|
28247
|
-
|
|
28248
|
-
(function (EventName) {
|
|
28249
|
-
EventName["Click"] = "click";
|
|
28250
|
-
EventName["DragStart"] = "dragstart";
|
|
28251
|
-
EventName["Keydown"] = "keydown";
|
|
28252
|
-
EventName["ContextMenu"] = "contextmenu";
|
|
28253
|
-
EventName["Resize"] = "resize";
|
|
28254
|
-
EventName["SelectionChange"] = "selectionchange";
|
|
28255
|
-
EventName["VisibilityChange"] = "visibilitychange";
|
|
28256
|
-
})(EventName || (EventName = {}));
|
|
28257
|
-
|
|
28258
|
-
function preventDefault(event) {
|
|
28259
|
-
event.preventDefault();
|
|
28260
|
-
}
|
|
28261
|
-
function stopPropagation(event) {
|
|
28262
|
-
event.stopPropagation();
|
|
28263
|
-
}
|
|
28264
|
-
|
|
28265
|
-
var KeyboardCode;
|
|
28266
|
-
|
|
28267
|
-
(function (KeyboardCode) {
|
|
28268
|
-
KeyboardCode["Space"] = "Space";
|
|
28269
|
-
KeyboardCode["Down"] = "ArrowDown";
|
|
28270
|
-
KeyboardCode["Right"] = "ArrowRight";
|
|
28271
|
-
KeyboardCode["Left"] = "ArrowLeft";
|
|
28272
|
-
KeyboardCode["Up"] = "ArrowUp";
|
|
28273
|
-
KeyboardCode["Esc"] = "Escape";
|
|
28274
|
-
KeyboardCode["Enter"] = "Enter";
|
|
28275
|
-
KeyboardCode["Tab"] = "Tab";
|
|
28276
|
-
})(KeyboardCode || (KeyboardCode = {}));
|
|
28277
|
-
|
|
28278
|
-
const defaultKeyboardCodes = {
|
|
28279
|
-
start: [KeyboardCode.Space, KeyboardCode.Enter],
|
|
28280
|
-
cancel: [KeyboardCode.Esc],
|
|
28281
|
-
end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab]
|
|
28282
|
-
};
|
|
28283
|
-
const defaultKeyboardCoordinateGetter = (event, _ref) => {
|
|
28284
|
-
let {
|
|
28285
|
-
currentCoordinates
|
|
28286
|
-
} = _ref;
|
|
28287
|
-
|
|
28288
|
-
switch (event.code) {
|
|
28289
|
-
case KeyboardCode.Right:
|
|
28290
|
-
return { ...currentCoordinates,
|
|
28291
|
-
x: currentCoordinates.x + 25
|
|
28292
|
-
};
|
|
28293
|
-
|
|
28294
|
-
case KeyboardCode.Left:
|
|
28295
|
-
return { ...currentCoordinates,
|
|
28296
|
-
x: currentCoordinates.x - 25
|
|
28297
|
-
};
|
|
28298
|
-
|
|
28299
|
-
case KeyboardCode.Down:
|
|
28300
|
-
return { ...currentCoordinates,
|
|
28301
|
-
y: currentCoordinates.y + 25
|
|
28302
|
-
};
|
|
28303
|
-
|
|
28304
|
-
case KeyboardCode.Up:
|
|
28305
|
-
return { ...currentCoordinates,
|
|
28306
|
-
y: currentCoordinates.y - 25
|
|
28307
|
-
};
|
|
28308
|
-
}
|
|
28309
|
-
|
|
28310
|
-
return undefined;
|
|
28311
|
-
};
|
|
28312
|
-
|
|
28313
|
-
class KeyboardSensor {
|
|
28314
|
-
constructor(props) {
|
|
28315
|
-
this.props = void 0;
|
|
28316
|
-
this.autoScrollEnabled = false;
|
|
28317
|
-
this.referenceCoordinates = void 0;
|
|
28318
|
-
this.listeners = void 0;
|
|
28319
|
-
this.windowListeners = void 0;
|
|
28320
|
-
this.props = props;
|
|
28321
|
-
const {
|
|
28322
|
-
event: {
|
|
28323
|
-
target
|
|
28324
|
-
}
|
|
28325
|
-
} = props;
|
|
28326
|
-
this.props = props;
|
|
28327
|
-
this.listeners = new Listeners(getOwnerDocument(target));
|
|
28328
|
-
this.windowListeners = new Listeners(getWindow(target));
|
|
28329
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
28330
|
-
this.handleCancel = this.handleCancel.bind(this);
|
|
28331
|
-
this.attach();
|
|
28332
|
-
}
|
|
28333
|
-
|
|
28334
|
-
attach() {
|
|
28335
|
-
this.handleStart();
|
|
28336
|
-
this.windowListeners.add(EventName.Resize, this.handleCancel);
|
|
28337
|
-
this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
|
|
28338
|
-
setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
|
|
28339
|
-
}
|
|
28340
|
-
|
|
28341
|
-
handleStart() {
|
|
28342
|
-
const {
|
|
28343
|
-
activeNode,
|
|
28344
|
-
onStart
|
|
28345
|
-
} = this.props;
|
|
28346
|
-
const node = activeNode.node.current;
|
|
28347
|
-
|
|
28348
|
-
if (node) {
|
|
28349
|
-
scrollIntoViewIfNeeded(node);
|
|
28350
|
-
}
|
|
28351
|
-
|
|
28352
|
-
onStart(defaultCoordinates);
|
|
28353
|
-
}
|
|
28354
|
-
|
|
28355
|
-
handleKeyDown(event) {
|
|
28356
|
-
if (isKeyboardEvent(event)) {
|
|
28357
|
-
const {
|
|
28358
|
-
active,
|
|
28359
|
-
context,
|
|
28360
|
-
options
|
|
28361
|
-
} = this.props;
|
|
28362
|
-
const {
|
|
28363
|
-
keyboardCodes = defaultKeyboardCodes,
|
|
28364
|
-
coordinateGetter = defaultKeyboardCoordinateGetter,
|
|
28365
|
-
scrollBehavior = 'smooth'
|
|
28366
|
-
} = options;
|
|
28367
|
-
const {
|
|
28368
|
-
code
|
|
28369
|
-
} = event;
|
|
28370
|
-
|
|
28371
|
-
if (keyboardCodes.end.includes(code)) {
|
|
28372
|
-
this.handleEnd(event);
|
|
28373
|
-
return;
|
|
28374
|
-
}
|
|
28375
|
-
|
|
28376
|
-
if (keyboardCodes.cancel.includes(code)) {
|
|
28377
|
-
this.handleCancel(event);
|
|
28378
|
-
return;
|
|
28379
|
-
}
|
|
28380
|
-
|
|
28381
|
-
const {
|
|
28382
|
-
collisionRect
|
|
28383
|
-
} = context.current;
|
|
28384
|
-
const currentCoordinates = collisionRect ? {
|
|
28385
|
-
x: collisionRect.left,
|
|
28386
|
-
y: collisionRect.top
|
|
28387
|
-
} : defaultCoordinates;
|
|
28388
|
-
|
|
28389
|
-
if (!this.referenceCoordinates) {
|
|
28390
|
-
this.referenceCoordinates = currentCoordinates;
|
|
28391
|
-
}
|
|
28392
|
-
|
|
28393
|
-
const newCoordinates = coordinateGetter(event, {
|
|
28394
|
-
active,
|
|
28395
|
-
context: context.current,
|
|
28396
|
-
currentCoordinates
|
|
28397
|
-
});
|
|
28398
|
-
|
|
28399
|
-
if (newCoordinates) {
|
|
28400
|
-
const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
|
|
28401
|
-
const scrollDelta = {
|
|
28402
|
-
x: 0,
|
|
28403
|
-
y: 0
|
|
28404
|
-
};
|
|
28405
|
-
const {
|
|
28406
|
-
scrollableAncestors
|
|
28407
|
-
} = context.current;
|
|
28408
|
-
|
|
28409
|
-
for (const scrollContainer of scrollableAncestors) {
|
|
28410
|
-
const direction = event.code;
|
|
28411
|
-
const {
|
|
28412
|
-
isTop,
|
|
28413
|
-
isRight,
|
|
28414
|
-
isLeft,
|
|
28415
|
-
isBottom,
|
|
28416
|
-
maxScroll,
|
|
28417
|
-
minScroll
|
|
28418
|
-
} = getScrollPosition(scrollContainer);
|
|
28419
|
-
const scrollElementRect = getScrollElementRect(scrollContainer);
|
|
28420
|
-
const clampedCoordinates = {
|
|
28421
|
-
x: Math.min(direction === KeyboardCode.Right ? scrollElementRect.right - scrollElementRect.width / 2 : scrollElementRect.right, Math.max(direction === KeyboardCode.Right ? scrollElementRect.left : scrollElementRect.left + scrollElementRect.width / 2, newCoordinates.x)),
|
|
28422
|
-
y: Math.min(direction === KeyboardCode.Down ? scrollElementRect.bottom - scrollElementRect.height / 2 : scrollElementRect.bottom, Math.max(direction === KeyboardCode.Down ? scrollElementRect.top : scrollElementRect.top + scrollElementRect.height / 2, newCoordinates.y))
|
|
28423
|
-
};
|
|
28424
|
-
const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
|
|
28425
|
-
const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
|
|
28426
|
-
|
|
28427
|
-
if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
|
|
28428
|
-
const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
|
|
28429
|
-
const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
|
|
28430
|
-
|
|
28431
|
-
if (canScrollToNewCoordinates && !coordinatesDelta.y) {
|
|
28432
|
-
// We don't need to update coordinates, the scroll adjustment alone will trigger
|
|
28433
|
-
// logic to auto-detect the new container we are over
|
|
28434
|
-
scrollContainer.scrollTo({
|
|
28435
|
-
left: newScrollCoordinates,
|
|
28436
|
-
behavior: scrollBehavior
|
|
28437
|
-
});
|
|
28438
|
-
return;
|
|
28439
|
-
}
|
|
28440
|
-
|
|
28441
|
-
if (canScrollToNewCoordinates) {
|
|
28442
|
-
scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
|
|
28443
|
-
} else {
|
|
28444
|
-
scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
|
|
28445
|
-
}
|
|
28446
|
-
|
|
28447
|
-
if (scrollDelta.x) {
|
|
28448
|
-
scrollContainer.scrollBy({
|
|
28449
|
-
left: -scrollDelta.x,
|
|
28450
|
-
behavior: scrollBehavior
|
|
28451
|
-
});
|
|
28452
|
-
}
|
|
28453
|
-
|
|
28454
|
-
break;
|
|
28455
|
-
} else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
|
|
28456
|
-
const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
|
|
28457
|
-
const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
|
|
28458
|
-
|
|
28459
|
-
if (canScrollToNewCoordinates && !coordinatesDelta.x) {
|
|
28460
|
-
// We don't need to update coordinates, the scroll adjustment alone will trigger
|
|
28461
|
-
// logic to auto-detect the new container we are over
|
|
28462
|
-
scrollContainer.scrollTo({
|
|
28463
|
-
top: newScrollCoordinates,
|
|
28464
|
-
behavior: scrollBehavior
|
|
28465
|
-
});
|
|
28466
|
-
return;
|
|
28467
|
-
}
|
|
28468
|
-
|
|
28469
|
-
if (canScrollToNewCoordinates) {
|
|
28470
|
-
scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
|
|
28471
|
-
} else {
|
|
28472
|
-
scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
|
|
28473
|
-
}
|
|
28474
|
-
|
|
28475
|
-
if (scrollDelta.y) {
|
|
28476
|
-
scrollContainer.scrollBy({
|
|
28477
|
-
top: -scrollDelta.y,
|
|
28478
|
-
behavior: scrollBehavior
|
|
28479
|
-
});
|
|
28480
|
-
}
|
|
28481
|
-
|
|
28482
|
-
break;
|
|
28483
|
-
}
|
|
28484
|
-
}
|
|
28485
|
-
|
|
28486
|
-
this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
|
|
28487
|
-
}
|
|
28488
|
-
}
|
|
28489
|
-
}
|
|
28490
|
-
|
|
28491
|
-
handleMove(event, coordinates) {
|
|
28492
|
-
const {
|
|
28493
|
-
onMove
|
|
28494
|
-
} = this.props;
|
|
28495
|
-
event.preventDefault();
|
|
28496
|
-
onMove(coordinates);
|
|
28497
|
-
}
|
|
28498
|
-
|
|
28499
|
-
handleEnd(event) {
|
|
28500
|
-
const {
|
|
28501
|
-
onEnd
|
|
28502
|
-
} = this.props;
|
|
28503
|
-
event.preventDefault();
|
|
28504
|
-
this.detach();
|
|
28505
|
-
onEnd();
|
|
28506
|
-
}
|
|
28507
|
-
|
|
28508
|
-
handleCancel(event) {
|
|
28509
|
-
const {
|
|
28510
|
-
onCancel
|
|
28511
|
-
} = this.props;
|
|
28512
|
-
event.preventDefault();
|
|
28513
|
-
this.detach();
|
|
28514
|
-
onCancel();
|
|
28515
|
-
}
|
|
28516
|
-
|
|
28517
|
-
detach() {
|
|
28518
|
-
this.listeners.removeAll();
|
|
28519
|
-
this.windowListeners.removeAll();
|
|
28520
|
-
}
|
|
28521
|
-
|
|
28522
|
-
}
|
|
28523
|
-
KeyboardSensor.activators = [{
|
|
28524
|
-
eventName: 'onKeyDown',
|
|
28525
|
-
handler: (event, _ref, _ref2) => {
|
|
28526
|
-
let {
|
|
28527
|
-
keyboardCodes = defaultKeyboardCodes,
|
|
28528
|
-
onActivation
|
|
28529
|
-
} = _ref;
|
|
28530
|
-
let {
|
|
28531
|
-
active
|
|
28532
|
-
} = _ref2;
|
|
28533
|
-
const {
|
|
28534
|
-
code
|
|
28535
|
-
} = event.nativeEvent;
|
|
28536
|
-
|
|
28537
|
-
if (keyboardCodes.start.includes(code)) {
|
|
28538
|
-
const activator = active.activatorNode.current;
|
|
28539
|
-
|
|
28540
|
-
if (activator && event.target !== activator) {
|
|
28541
|
-
return false;
|
|
28542
|
-
}
|
|
28543
|
-
|
|
28544
|
-
event.preventDefault();
|
|
28545
|
-
onActivation == null ? void 0 : onActivation({
|
|
28546
|
-
event: event.nativeEvent
|
|
28547
|
-
});
|
|
28548
|
-
return true;
|
|
28549
|
-
}
|
|
28550
|
-
|
|
28551
|
-
return false;
|
|
28552
|
-
}
|
|
28553
|
-
}];
|
|
28554
|
-
|
|
28555
|
-
function isDistanceConstraint(constraint) {
|
|
28556
|
-
return Boolean(constraint && 'distance' in constraint);
|
|
28557
|
-
}
|
|
28558
|
-
|
|
28559
|
-
function isDelayConstraint(constraint) {
|
|
28560
|
-
return Boolean(constraint && 'delay' in constraint);
|
|
28561
|
-
}
|
|
28562
|
-
|
|
28563
|
-
class AbstractPointerSensor {
|
|
28564
|
-
constructor(props, events, listenerTarget) {
|
|
28565
|
-
var _getEventCoordinates;
|
|
28566
|
-
|
|
28567
|
-
if (listenerTarget === void 0) {
|
|
28568
|
-
listenerTarget = getEventListenerTarget(props.event.target);
|
|
28569
|
-
}
|
|
28570
|
-
|
|
28571
|
-
this.props = void 0;
|
|
28572
|
-
this.events = void 0;
|
|
28573
|
-
this.autoScrollEnabled = true;
|
|
28574
|
-
this.document = void 0;
|
|
28575
|
-
this.activated = false;
|
|
28576
|
-
this.initialCoordinates = void 0;
|
|
28577
|
-
this.timeoutId = null;
|
|
28578
|
-
this.listeners = void 0;
|
|
28579
|
-
this.documentListeners = void 0;
|
|
28580
|
-
this.windowListeners = void 0;
|
|
28581
|
-
this.props = props;
|
|
28582
|
-
this.events = events;
|
|
28583
|
-
const {
|
|
28584
|
-
event
|
|
28585
|
-
} = props;
|
|
28586
|
-
const {
|
|
28587
|
-
target
|
|
28588
|
-
} = event;
|
|
28589
|
-
this.props = props;
|
|
28590
|
-
this.events = events;
|
|
28591
|
-
this.document = getOwnerDocument(target);
|
|
28592
|
-
this.documentListeners = new Listeners(this.document);
|
|
28593
|
-
this.listeners = new Listeners(listenerTarget);
|
|
28594
|
-
this.windowListeners = new Listeners(getWindow(target));
|
|
28595
|
-
this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
|
|
28596
|
-
this.handleStart = this.handleStart.bind(this);
|
|
28597
|
-
this.handleMove = this.handleMove.bind(this);
|
|
28598
|
-
this.handleEnd = this.handleEnd.bind(this);
|
|
28599
|
-
this.handleCancel = this.handleCancel.bind(this);
|
|
28600
|
-
this.handleKeydown = this.handleKeydown.bind(this);
|
|
28601
|
-
this.removeTextSelection = this.removeTextSelection.bind(this);
|
|
28602
|
-
this.attach();
|
|
28603
|
-
}
|
|
28604
|
-
|
|
28605
|
-
attach() {
|
|
28606
|
-
const {
|
|
28607
|
-
events,
|
|
28608
|
-
props: {
|
|
28609
|
-
options: {
|
|
28610
|
-
activationConstraint,
|
|
28611
|
-
bypassActivationConstraint
|
|
28612
|
-
}
|
|
28613
|
-
}
|
|
28614
|
-
} = this;
|
|
28615
|
-
this.listeners.add(events.move.name, this.handleMove, {
|
|
28616
|
-
passive: false
|
|
28617
|
-
});
|
|
28618
|
-
this.listeners.add(events.end.name, this.handleEnd);
|
|
28619
|
-
|
|
28620
|
-
if (events.cancel) {
|
|
28621
|
-
this.listeners.add(events.cancel.name, this.handleCancel);
|
|
28622
|
-
}
|
|
28623
|
-
|
|
28624
|
-
this.windowListeners.add(EventName.Resize, this.handleCancel);
|
|
28625
|
-
this.windowListeners.add(EventName.DragStart, preventDefault);
|
|
28626
|
-
this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
|
|
28627
|
-
this.windowListeners.add(EventName.ContextMenu, preventDefault);
|
|
28628
|
-
this.documentListeners.add(EventName.Keydown, this.handleKeydown);
|
|
28629
|
-
|
|
28630
|
-
if (activationConstraint) {
|
|
28631
|
-
if (bypassActivationConstraint != null && bypassActivationConstraint({
|
|
28632
|
-
event: this.props.event,
|
|
28633
|
-
activeNode: this.props.activeNode,
|
|
28634
|
-
options: this.props.options
|
|
28635
|
-
})) {
|
|
28636
|
-
return this.handleStart();
|
|
28637
|
-
}
|
|
28638
|
-
|
|
28639
|
-
if (isDelayConstraint(activationConstraint)) {
|
|
28640
|
-
this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
|
|
28641
|
-
this.handlePending(activationConstraint);
|
|
28642
|
-
return;
|
|
28643
|
-
}
|
|
28644
|
-
|
|
28645
|
-
if (isDistanceConstraint(activationConstraint)) {
|
|
28646
|
-
this.handlePending(activationConstraint);
|
|
28647
|
-
return;
|
|
28648
|
-
}
|
|
28649
|
-
}
|
|
28650
|
-
|
|
28651
|
-
this.handleStart();
|
|
28652
|
-
}
|
|
28653
|
-
|
|
28654
|
-
detach() {
|
|
28655
|
-
this.listeners.removeAll();
|
|
28656
|
-
this.windowListeners.removeAll(); // Wait until the next event loop before removing document listeners
|
|
28657
|
-
// This is necessary because we listen for `click` and `selection` events on the document
|
|
28658
|
-
|
|
28659
|
-
setTimeout(this.documentListeners.removeAll, 50);
|
|
28660
|
-
|
|
28661
|
-
if (this.timeoutId !== null) {
|
|
28662
|
-
clearTimeout(this.timeoutId);
|
|
28663
|
-
this.timeoutId = null;
|
|
28664
|
-
}
|
|
28665
|
-
}
|
|
28666
|
-
|
|
28667
|
-
handlePending(constraint, offset) {
|
|
28668
|
-
const {
|
|
28669
|
-
active,
|
|
28670
|
-
onPending
|
|
28671
|
-
} = this.props;
|
|
28672
|
-
onPending(active, constraint, this.initialCoordinates, offset);
|
|
28673
|
-
}
|
|
28674
|
-
|
|
28675
|
-
handleStart() {
|
|
28676
|
-
const {
|
|
28677
|
-
initialCoordinates
|
|
28678
|
-
} = this;
|
|
28679
|
-
const {
|
|
28680
|
-
onStart
|
|
28681
|
-
} = this.props;
|
|
28682
|
-
|
|
28683
|
-
if (initialCoordinates) {
|
|
28684
|
-
this.activated = true; // Stop propagation of click events once activation constraints are met
|
|
28685
|
-
|
|
28686
|
-
this.documentListeners.add(EventName.Click, stopPropagation, {
|
|
28687
|
-
capture: true
|
|
28688
|
-
}); // Remove any text selection from the document
|
|
28689
|
-
|
|
28690
|
-
this.removeTextSelection(); // Prevent further text selection while dragging
|
|
28691
|
-
|
|
28692
|
-
this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
|
|
28693
|
-
onStart(initialCoordinates);
|
|
28694
|
-
}
|
|
28695
|
-
}
|
|
28696
|
-
|
|
28697
|
-
handleMove(event) {
|
|
28698
|
-
var _getEventCoordinates2;
|
|
28699
|
-
|
|
28700
|
-
const {
|
|
28701
|
-
activated,
|
|
28702
|
-
initialCoordinates,
|
|
28703
|
-
props
|
|
28704
|
-
} = this;
|
|
28705
|
-
const {
|
|
28706
|
-
onMove,
|
|
28707
|
-
options: {
|
|
28708
|
-
activationConstraint
|
|
28709
|
-
}
|
|
28710
|
-
} = props;
|
|
28711
|
-
|
|
28712
|
-
if (!initialCoordinates) {
|
|
28713
|
-
return;
|
|
28714
|
-
}
|
|
28715
|
-
|
|
28716
|
-
const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
|
|
28717
|
-
const delta = subtract(initialCoordinates, coordinates); // Constraint validation
|
|
28718
|
-
|
|
28719
|
-
if (!activated && activationConstraint) {
|
|
28720
|
-
if (isDistanceConstraint(activationConstraint)) {
|
|
28721
|
-
if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
|
|
28722
|
-
return this.handleCancel();
|
|
28723
|
-
}
|
|
28724
|
-
|
|
28725
|
-
if (hasExceededDistance(delta, activationConstraint.distance)) {
|
|
28726
|
-
return this.handleStart();
|
|
28727
|
-
}
|
|
28728
|
-
}
|
|
28729
|
-
|
|
28730
|
-
if (isDelayConstraint(activationConstraint)) {
|
|
28731
|
-
if (hasExceededDistance(delta, activationConstraint.tolerance)) {
|
|
28732
|
-
return this.handleCancel();
|
|
28733
|
-
}
|
|
28734
|
-
}
|
|
28735
|
-
|
|
28736
|
-
this.handlePending(activationConstraint, delta);
|
|
28737
|
-
return;
|
|
28738
|
-
}
|
|
28739
|
-
|
|
28740
|
-
if (event.cancelable) {
|
|
28741
|
-
event.preventDefault();
|
|
28742
|
-
}
|
|
28743
|
-
|
|
28744
|
-
onMove(coordinates);
|
|
28745
|
-
}
|
|
28746
|
-
|
|
28747
|
-
handleEnd() {
|
|
28748
|
-
const {
|
|
28749
|
-
onAbort,
|
|
28750
|
-
onEnd
|
|
28751
|
-
} = this.props;
|
|
28752
|
-
this.detach();
|
|
28753
|
-
|
|
28754
|
-
if (!this.activated) {
|
|
28755
|
-
onAbort(this.props.active);
|
|
28756
|
-
}
|
|
28757
|
-
|
|
28758
|
-
onEnd();
|
|
28759
|
-
}
|
|
28760
|
-
|
|
28761
|
-
handleCancel() {
|
|
28762
|
-
const {
|
|
28763
|
-
onAbort,
|
|
28764
|
-
onCancel
|
|
28765
|
-
} = this.props;
|
|
28766
|
-
this.detach();
|
|
28767
|
-
|
|
28768
|
-
if (!this.activated) {
|
|
28769
|
-
onAbort(this.props.active);
|
|
28770
|
-
}
|
|
28771
|
-
|
|
28772
|
-
onCancel();
|
|
28773
|
-
}
|
|
28774
|
-
|
|
28775
|
-
handleKeydown(event) {
|
|
28776
|
-
if (event.code === KeyboardCode.Esc) {
|
|
28777
|
-
this.handleCancel();
|
|
28778
|
-
}
|
|
28779
|
-
}
|
|
28780
|
-
|
|
28781
|
-
removeTextSelection() {
|
|
28782
|
-
var _this$document$getSel;
|
|
28783
|
-
|
|
28784
|
-
(_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
|
|
28785
|
-
}
|
|
28786
|
-
|
|
28787
|
-
}
|
|
28788
|
-
|
|
28789
|
-
const events = {
|
|
28790
|
-
cancel: {
|
|
28791
|
-
name: 'pointercancel'
|
|
28792
|
-
},
|
|
28793
|
-
move: {
|
|
28794
|
-
name: 'pointermove'
|
|
28795
|
-
},
|
|
28796
|
-
end: {
|
|
28797
|
-
name: 'pointerup'
|
|
28798
|
-
}
|
|
28799
|
-
};
|
|
28800
|
-
class PointerSensor extends AbstractPointerSensor {
|
|
28801
|
-
constructor(props) {
|
|
28802
|
-
const {
|
|
28803
|
-
event
|
|
28804
|
-
} = props; // Pointer events stop firing if the target is unmounted while dragging
|
|
28805
|
-
// Therefore we attach listeners to the owner document instead
|
|
28806
|
-
|
|
28807
|
-
const listenerTarget = getOwnerDocument(event.target);
|
|
28808
|
-
super(props, events, listenerTarget);
|
|
28809
|
-
}
|
|
28810
|
-
|
|
28811
|
-
}
|
|
28812
|
-
PointerSensor.activators = [{
|
|
28813
|
-
eventName: 'onPointerDown',
|
|
28814
|
-
handler: (_ref, _ref2) => {
|
|
28815
|
-
let {
|
|
28816
|
-
nativeEvent: event
|
|
28817
|
-
} = _ref;
|
|
28818
|
-
let {
|
|
28819
|
-
onActivation
|
|
28820
|
-
} = _ref2;
|
|
28821
|
-
|
|
28822
|
-
if (!event.isPrimary || event.button !== 0) {
|
|
28823
|
-
return false;
|
|
28824
|
-
}
|
|
28825
|
-
|
|
28826
|
-
onActivation == null ? void 0 : onActivation({
|
|
28827
|
-
event
|
|
28828
|
-
});
|
|
28829
|
-
return true;
|
|
28830
|
-
}
|
|
28831
|
-
}];
|
|
28832
|
-
|
|
28833
|
-
const events$1 = {
|
|
28834
|
-
move: {
|
|
28835
|
-
name: 'mousemove'
|
|
28836
|
-
},
|
|
28837
|
-
end: {
|
|
28838
|
-
name: 'mouseup'
|
|
28839
|
-
}
|
|
28840
|
-
};
|
|
28841
|
-
var MouseButton;
|
|
28842
|
-
|
|
28843
|
-
(function (MouseButton) {
|
|
28844
|
-
MouseButton[MouseButton["RightClick"] = 2] = "RightClick";
|
|
28845
|
-
})(MouseButton || (MouseButton = {}));
|
|
28846
|
-
|
|
28847
|
-
class MouseSensor extends AbstractPointerSensor {
|
|
28848
|
-
constructor(props) {
|
|
28849
|
-
super(props, events$1, getOwnerDocument(props.event.target));
|
|
28850
|
-
}
|
|
28851
|
-
|
|
28852
|
-
}
|
|
28853
|
-
MouseSensor.activators = [{
|
|
28854
|
-
eventName: 'onMouseDown',
|
|
28855
|
-
handler: (_ref, _ref2) => {
|
|
28856
|
-
let {
|
|
28857
|
-
nativeEvent: event
|
|
28858
|
-
} = _ref;
|
|
28859
|
-
let {
|
|
28860
|
-
onActivation
|
|
28861
|
-
} = _ref2;
|
|
28862
|
-
|
|
28863
|
-
if (event.button === MouseButton.RightClick) {
|
|
28864
|
-
return false;
|
|
28865
|
-
}
|
|
28866
|
-
|
|
28867
|
-
onActivation == null ? void 0 : onActivation({
|
|
28868
|
-
event
|
|
28869
|
-
});
|
|
28870
|
-
return true;
|
|
28871
|
-
}
|
|
28872
|
-
}];
|
|
28873
|
-
|
|
28874
|
-
const events$2 = {
|
|
28875
|
-
cancel: {
|
|
28876
|
-
name: 'touchcancel'
|
|
28877
|
-
},
|
|
28878
|
-
move: {
|
|
28879
|
-
name: 'touchmove'
|
|
28880
|
-
},
|
|
28881
|
-
end: {
|
|
28882
|
-
name: 'touchend'
|
|
28883
|
-
}
|
|
28884
|
-
};
|
|
28885
|
-
class TouchSensor extends AbstractPointerSensor {
|
|
28886
|
-
constructor(props) {
|
|
28887
|
-
super(props, events$2);
|
|
28888
|
-
}
|
|
28889
|
-
|
|
28890
|
-
static setup() {
|
|
28891
|
-
// Adding a non-capture and non-passive `touchmove` listener in order
|
|
28892
|
-
// to force `event.preventDefault()` calls to work in dynamically added
|
|
28893
|
-
// touchmove event handlers. This is required for iOS Safari.
|
|
28894
|
-
window.addEventListener(events$2.move.name, noop, {
|
|
28895
|
-
capture: false,
|
|
28896
|
-
passive: false
|
|
28897
|
-
});
|
|
28898
|
-
return function teardown() {
|
|
28899
|
-
window.removeEventListener(events$2.move.name, noop);
|
|
28900
|
-
}; // We create a new handler because the teardown function of another sensor
|
|
28901
|
-
// could remove our event listener if we use a referentially equal listener.
|
|
28902
|
-
|
|
28903
|
-
function noop() {}
|
|
28904
|
-
}
|
|
28905
|
-
|
|
28906
|
-
}
|
|
28907
|
-
TouchSensor.activators = [{
|
|
28908
|
-
eventName: 'onTouchStart',
|
|
28909
|
-
handler: (_ref, _ref2) => {
|
|
28910
|
-
let {
|
|
28911
|
-
nativeEvent: event
|
|
28912
|
-
} = _ref;
|
|
28913
|
-
let {
|
|
28914
|
-
onActivation
|
|
28915
|
-
} = _ref2;
|
|
28916
|
-
const {
|
|
28917
|
-
touches
|
|
28918
|
-
} = event;
|
|
28919
|
-
|
|
28920
|
-
if (touches.length > 1) {
|
|
28921
|
-
return false;
|
|
28922
|
-
}
|
|
28923
|
-
|
|
28924
|
-
onActivation == null ? void 0 : onActivation({
|
|
28925
|
-
event
|
|
28926
|
-
});
|
|
28927
|
-
return true;
|
|
28928
|
-
}
|
|
28929
|
-
}];
|
|
28930
|
-
|
|
28931
|
-
var AutoScrollActivator;
|
|
28932
|
-
|
|
28933
|
-
(function (AutoScrollActivator) {
|
|
28934
|
-
AutoScrollActivator[AutoScrollActivator["Pointer"] = 0] = "Pointer";
|
|
28935
|
-
AutoScrollActivator[AutoScrollActivator["DraggableRect"] = 1] = "DraggableRect";
|
|
28936
|
-
})(AutoScrollActivator || (AutoScrollActivator = {}));
|
|
28937
|
-
|
|
28938
|
-
var TraversalOrder;
|
|
28939
|
-
|
|
28940
|
-
(function (TraversalOrder) {
|
|
28941
|
-
TraversalOrder[TraversalOrder["TreeOrder"] = 0] = "TreeOrder";
|
|
28942
|
-
TraversalOrder[TraversalOrder["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
|
|
28943
|
-
})(TraversalOrder || (TraversalOrder = {}));
|
|
28944
|
-
|
|
28945
|
-
function useAutoScroller(_ref) {
|
|
28946
|
-
let {
|
|
28947
|
-
acceleration,
|
|
28948
|
-
activator = AutoScrollActivator.Pointer,
|
|
28949
|
-
canScroll,
|
|
28950
|
-
draggingRect,
|
|
28951
|
-
enabled,
|
|
28952
|
-
interval = 5,
|
|
28953
|
-
order = TraversalOrder.TreeOrder,
|
|
28954
|
-
pointerCoordinates,
|
|
28955
|
-
scrollableAncestors,
|
|
28956
|
-
scrollableAncestorRects,
|
|
28957
|
-
delta,
|
|
28958
|
-
threshold
|
|
28959
|
-
} = _ref;
|
|
28960
|
-
const scrollIntent = useScrollIntent({
|
|
28961
|
-
delta,
|
|
28962
|
-
disabled: !enabled
|
|
28963
|
-
});
|
|
28964
|
-
const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
|
|
28965
|
-
const scrollSpeed = useRef({
|
|
28966
|
-
x: 0,
|
|
28967
|
-
y: 0
|
|
28968
|
-
});
|
|
28969
|
-
const scrollDirection = useRef({
|
|
28970
|
-
x: 0,
|
|
28971
|
-
y: 0
|
|
28972
|
-
});
|
|
28973
|
-
const rect = useMemo(() => {
|
|
28974
|
-
switch (activator) {
|
|
28975
|
-
case AutoScrollActivator.Pointer:
|
|
28976
|
-
return pointerCoordinates ? {
|
|
28977
|
-
top: pointerCoordinates.y,
|
|
28978
|
-
bottom: pointerCoordinates.y,
|
|
28979
|
-
left: pointerCoordinates.x,
|
|
28980
|
-
right: pointerCoordinates.x
|
|
28981
|
-
} : null;
|
|
28982
|
-
|
|
28983
|
-
case AutoScrollActivator.DraggableRect:
|
|
28984
|
-
return draggingRect;
|
|
28985
|
-
}
|
|
28986
|
-
}, [activator, draggingRect, pointerCoordinates]);
|
|
28987
|
-
const scrollContainerRef = useRef(null);
|
|
28988
|
-
const autoScroll = useCallback(() => {
|
|
28989
|
-
const scrollContainer = scrollContainerRef.current;
|
|
28990
|
-
|
|
28991
|
-
if (!scrollContainer) {
|
|
28992
|
-
return;
|
|
28993
|
-
}
|
|
28994
|
-
|
|
28995
|
-
const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
|
|
28996
|
-
const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
|
|
28997
|
-
scrollContainer.scrollBy(scrollLeft, scrollTop);
|
|
28998
|
-
}, []);
|
|
28999
|
-
const sortedScrollableAncestors = useMemo(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
|
|
29000
|
-
useEffect(() => {
|
|
29001
|
-
if (!enabled || !scrollableAncestors.length || !rect) {
|
|
29002
|
-
clearAutoScrollInterval();
|
|
29003
|
-
return;
|
|
29004
|
-
}
|
|
29005
|
-
|
|
29006
|
-
for (const scrollContainer of sortedScrollableAncestors) {
|
|
29007
|
-
if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
|
|
29008
|
-
continue;
|
|
29009
|
-
}
|
|
29010
|
-
|
|
29011
|
-
const index = scrollableAncestors.indexOf(scrollContainer);
|
|
29012
|
-
const scrollContainerRect = scrollableAncestorRects[index];
|
|
29013
|
-
|
|
29014
|
-
if (!scrollContainerRect) {
|
|
29015
|
-
continue;
|
|
29016
|
-
}
|
|
29017
|
-
|
|
29018
|
-
const {
|
|
29019
|
-
direction,
|
|
29020
|
-
speed
|
|
29021
|
-
} = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
|
|
29022
|
-
|
|
29023
|
-
for (const axis of ['x', 'y']) {
|
|
29024
|
-
if (!scrollIntent[axis][direction[axis]]) {
|
|
29025
|
-
speed[axis] = 0;
|
|
29026
|
-
direction[axis] = 0;
|
|
29027
|
-
}
|
|
29028
|
-
}
|
|
29029
|
-
|
|
29030
|
-
if (speed.x > 0 || speed.y > 0) {
|
|
29031
|
-
clearAutoScrollInterval();
|
|
29032
|
-
scrollContainerRef.current = scrollContainer;
|
|
29033
|
-
setAutoScrollInterval(autoScroll, interval);
|
|
29034
|
-
scrollSpeed.current = speed;
|
|
29035
|
-
scrollDirection.current = direction;
|
|
29036
|
-
return;
|
|
29037
|
-
}
|
|
29038
|
-
}
|
|
29039
|
-
|
|
29040
|
-
scrollSpeed.current = {
|
|
29041
|
-
x: 0,
|
|
29042
|
-
y: 0
|
|
29043
|
-
};
|
|
29044
|
-
scrollDirection.current = {
|
|
29045
|
-
x: 0,
|
|
29046
|
-
y: 0
|
|
29047
|
-
};
|
|
29048
|
-
clearAutoScrollInterval();
|
|
29049
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29050
|
-
[acceleration, autoScroll, canScroll, clearAutoScrollInterval, enabled, interval, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29051
|
-
JSON.stringify(rect), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29052
|
-
JSON.stringify(scrollIntent), setAutoScrollInterval, scrollableAncestors, sortedScrollableAncestors, scrollableAncestorRects, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29053
|
-
JSON.stringify(threshold)]);
|
|
29054
|
-
}
|
|
29055
|
-
const defaultScrollIntent = {
|
|
29056
|
-
x: {
|
|
29057
|
-
[Direction.Backward]: false,
|
|
29058
|
-
[Direction.Forward]: false
|
|
29059
|
-
},
|
|
29060
|
-
y: {
|
|
29061
|
-
[Direction.Backward]: false,
|
|
29062
|
-
[Direction.Forward]: false
|
|
29063
|
-
}
|
|
29064
|
-
};
|
|
29065
|
-
|
|
29066
|
-
function useScrollIntent(_ref2) {
|
|
29067
|
-
let {
|
|
29068
|
-
delta,
|
|
29069
|
-
disabled
|
|
29070
|
-
} = _ref2;
|
|
29071
|
-
const previousDelta = usePrevious(delta);
|
|
29072
|
-
return useLazyMemo(previousIntent => {
|
|
29073
|
-
if (disabled || !previousDelta || !previousIntent) {
|
|
29074
|
-
// Reset scroll intent tracking when auto-scrolling is disabled
|
|
29075
|
-
return defaultScrollIntent;
|
|
29076
|
-
}
|
|
29077
|
-
|
|
29078
|
-
const direction = {
|
|
29079
|
-
x: Math.sign(delta.x - previousDelta.x),
|
|
29080
|
-
y: Math.sign(delta.y - previousDelta.y)
|
|
29081
|
-
}; // Keep track of the user intent to scroll in each direction for both axis
|
|
29082
|
-
|
|
29083
|
-
return {
|
|
29084
|
-
x: {
|
|
29085
|
-
[Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
|
|
29086
|
-
[Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
|
|
29087
|
-
},
|
|
29088
|
-
y: {
|
|
29089
|
-
[Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
|
|
29090
|
-
[Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
|
|
29091
|
-
}
|
|
29092
|
-
};
|
|
29093
|
-
}, [disabled, delta, previousDelta]);
|
|
29094
|
-
}
|
|
29095
|
-
|
|
29096
|
-
function useCachedNode(draggableNodes, id) {
|
|
29097
|
-
const draggableNode = id != null ? draggableNodes.get(id) : undefined;
|
|
29098
|
-
const node = draggableNode ? draggableNode.node.current : null;
|
|
29099
|
-
return useLazyMemo(cachedNode => {
|
|
29100
|
-
var _ref;
|
|
29101
|
-
|
|
29102
|
-
if (id == null) {
|
|
29103
|
-
return null;
|
|
29104
|
-
} // In some cases, the draggable node can unmount while dragging
|
|
29105
|
-
// This is the case for virtualized lists. In those situations,
|
|
29106
|
-
// we fall back to the last known value for that node.
|
|
29107
|
-
|
|
29108
|
-
|
|
29109
|
-
return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
|
|
29110
|
-
}, [node, id]);
|
|
29111
|
-
}
|
|
29112
|
-
|
|
29113
|
-
function useCombineActivators(sensors, getSyntheticHandler) {
|
|
29114
|
-
return useMemo(() => sensors.reduce((accumulator, sensor) => {
|
|
29115
|
-
const {
|
|
29116
|
-
sensor: Sensor
|
|
29117
|
-
} = sensor;
|
|
29118
|
-
const sensorActivators = Sensor.activators.map(activator => ({
|
|
29119
|
-
eventName: activator.eventName,
|
|
29120
|
-
handler: getSyntheticHandler(activator.handler, sensor)
|
|
29121
|
-
}));
|
|
29122
|
-
return [...accumulator, ...sensorActivators];
|
|
29123
|
-
}, []), [sensors, getSyntheticHandler]);
|
|
29124
|
-
}
|
|
29125
|
-
|
|
29126
|
-
var MeasuringStrategy;
|
|
29127
|
-
|
|
29128
|
-
(function (MeasuringStrategy) {
|
|
29129
|
-
MeasuringStrategy[MeasuringStrategy["Always"] = 0] = "Always";
|
|
29130
|
-
MeasuringStrategy[MeasuringStrategy["BeforeDragging"] = 1] = "BeforeDragging";
|
|
29131
|
-
MeasuringStrategy[MeasuringStrategy["WhileDragging"] = 2] = "WhileDragging";
|
|
29132
|
-
})(MeasuringStrategy || (MeasuringStrategy = {}));
|
|
29133
|
-
|
|
29134
|
-
var MeasuringFrequency;
|
|
29135
|
-
|
|
29136
|
-
(function (MeasuringFrequency) {
|
|
29137
|
-
MeasuringFrequency["Optimized"] = "optimized";
|
|
29138
|
-
})(MeasuringFrequency || (MeasuringFrequency = {}));
|
|
29139
|
-
|
|
29140
|
-
const defaultValue = /*#__PURE__*/new Map();
|
|
29141
|
-
function useDroppableMeasuring(containers, _ref) {
|
|
29142
|
-
let {
|
|
29143
|
-
dragging,
|
|
29144
|
-
dependencies,
|
|
29145
|
-
config
|
|
29146
|
-
} = _ref;
|
|
29147
|
-
const [queue, setQueue] = useState(null);
|
|
29148
|
-
const {
|
|
29149
|
-
frequency,
|
|
29150
|
-
measure,
|
|
29151
|
-
strategy
|
|
29152
|
-
} = config;
|
|
29153
|
-
const containersRef = useRef(containers);
|
|
29154
|
-
const disabled = isDisabled();
|
|
29155
|
-
const disabledRef = useLatestValue(disabled);
|
|
29156
|
-
const measureDroppableContainers = useCallback(function (ids) {
|
|
29157
|
-
if (ids === void 0) {
|
|
29158
|
-
ids = [];
|
|
29159
|
-
}
|
|
29160
|
-
|
|
29161
|
-
if (disabledRef.current) {
|
|
29162
|
-
return;
|
|
29163
|
-
}
|
|
29164
|
-
|
|
29165
|
-
setQueue(value => {
|
|
29166
|
-
if (value === null) {
|
|
29167
|
-
return ids;
|
|
29168
|
-
}
|
|
29169
|
-
|
|
29170
|
-
return value.concat(ids.filter(id => !value.includes(id)));
|
|
29171
|
-
});
|
|
29172
|
-
}, [disabledRef]);
|
|
29173
|
-
const timeoutId = useRef(null);
|
|
29174
|
-
const droppableRects = useLazyMemo(previousValue => {
|
|
29175
|
-
if (disabled && !dragging) {
|
|
29176
|
-
return defaultValue;
|
|
29177
|
-
}
|
|
29178
|
-
|
|
29179
|
-
if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
|
|
29180
|
-
const map = new Map();
|
|
29181
|
-
|
|
29182
|
-
for (let container of containers) {
|
|
29183
|
-
if (!container) {
|
|
29184
|
-
continue;
|
|
29185
|
-
}
|
|
29186
|
-
|
|
29187
|
-
if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
|
|
29188
|
-
// This container does not need to be re-measured
|
|
29189
|
-
map.set(container.id, container.rect.current);
|
|
29190
|
-
continue;
|
|
29191
|
-
}
|
|
29192
|
-
|
|
29193
|
-
const node = container.node.current;
|
|
29194
|
-
const rect = node ? new Rect(measure(node), node) : null;
|
|
29195
|
-
container.rect.current = rect;
|
|
29196
|
-
|
|
29197
|
-
if (rect) {
|
|
29198
|
-
map.set(container.id, rect);
|
|
29199
|
-
}
|
|
29200
|
-
}
|
|
29201
|
-
|
|
29202
|
-
return map;
|
|
29203
|
-
}
|
|
29204
|
-
|
|
29205
|
-
return previousValue;
|
|
29206
|
-
}, [containers, queue, dragging, disabled, measure]);
|
|
29207
|
-
useEffect(() => {
|
|
29208
|
-
containersRef.current = containers;
|
|
29209
|
-
}, [containers]);
|
|
29210
|
-
useEffect(() => {
|
|
29211
|
-
if (disabled) {
|
|
29212
|
-
return;
|
|
29213
|
-
}
|
|
29214
|
-
|
|
29215
|
-
measureDroppableContainers();
|
|
29216
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29217
|
-
[dragging, disabled]);
|
|
29218
|
-
useEffect(() => {
|
|
29219
|
-
if (queue && queue.length > 0) {
|
|
29220
|
-
setQueue(null);
|
|
29221
|
-
}
|
|
29222
|
-
}, //eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29223
|
-
[JSON.stringify(queue)]);
|
|
29224
|
-
useEffect(() => {
|
|
29225
|
-
if (disabled || typeof frequency !== 'number' || timeoutId.current !== null) {
|
|
29226
|
-
return;
|
|
29227
|
-
}
|
|
29228
|
-
|
|
29229
|
-
timeoutId.current = setTimeout(() => {
|
|
29230
|
-
measureDroppableContainers();
|
|
29231
|
-
timeoutId.current = null;
|
|
29232
|
-
}, frequency);
|
|
29233
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29234
|
-
[frequency, disabled, measureDroppableContainers, ...dependencies]);
|
|
29235
|
-
return {
|
|
29236
|
-
droppableRects,
|
|
29237
|
-
measureDroppableContainers,
|
|
29238
|
-
measuringScheduled: queue != null
|
|
29239
|
-
};
|
|
29240
|
-
|
|
29241
|
-
function isDisabled() {
|
|
29242
|
-
switch (strategy) {
|
|
29243
|
-
case MeasuringStrategy.Always:
|
|
29244
|
-
return false;
|
|
29245
|
-
|
|
29246
|
-
case MeasuringStrategy.BeforeDragging:
|
|
29247
|
-
return dragging;
|
|
29248
|
-
|
|
29249
|
-
default:
|
|
29250
|
-
return !dragging;
|
|
29251
|
-
}
|
|
29252
|
-
}
|
|
29253
|
-
}
|
|
29254
|
-
|
|
29255
|
-
function useInitialValue(value, computeFn) {
|
|
29256
|
-
return useLazyMemo(previousValue => {
|
|
29257
|
-
if (!value) {
|
|
29258
|
-
return null;
|
|
29259
|
-
}
|
|
29260
|
-
|
|
29261
|
-
if (previousValue) {
|
|
29262
|
-
return previousValue;
|
|
29263
|
-
}
|
|
29264
|
-
|
|
29265
|
-
return typeof computeFn === 'function' ? computeFn(value) : value;
|
|
29266
|
-
}, [computeFn, value]);
|
|
29267
|
-
}
|
|
29268
|
-
|
|
29269
|
-
function useInitialRect(node, measure) {
|
|
29270
|
-
return useInitialValue(node, measure);
|
|
29271
|
-
}
|
|
29272
|
-
|
|
29273
|
-
/**
|
|
29274
|
-
* Returns a new MutationObserver instance.
|
|
29275
|
-
* If `MutationObserver` is undefined in the execution environment, returns `undefined`.
|
|
29276
|
-
*/
|
|
29277
|
-
|
|
29278
|
-
function useMutationObserver(_ref) {
|
|
29279
|
-
let {
|
|
29280
|
-
callback,
|
|
29281
|
-
disabled
|
|
29282
|
-
} = _ref;
|
|
29283
|
-
const handleMutations = useEvent(callback);
|
|
29284
|
-
const mutationObserver = useMemo(() => {
|
|
29285
|
-
if (disabled || typeof window === 'undefined' || typeof window.MutationObserver === 'undefined') {
|
|
29286
|
-
return undefined;
|
|
29287
|
-
}
|
|
29288
|
-
|
|
29289
|
-
const {
|
|
29290
|
-
MutationObserver
|
|
29291
|
-
} = window;
|
|
29292
|
-
return new MutationObserver(handleMutations);
|
|
29293
|
-
}, [handleMutations, disabled]);
|
|
29294
|
-
useEffect(() => {
|
|
29295
|
-
return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
|
|
29296
|
-
}, [mutationObserver]);
|
|
29297
|
-
return mutationObserver;
|
|
29298
|
-
}
|
|
29299
|
-
|
|
29300
|
-
/**
|
|
29301
|
-
* Returns a new ResizeObserver instance bound to the `onResize` callback.
|
|
29302
|
-
* If `ResizeObserver` is undefined in the execution environment, returns `undefined`.
|
|
29303
|
-
*/
|
|
29304
|
-
|
|
29305
|
-
function useResizeObserver(_ref) {
|
|
29306
|
-
let {
|
|
29307
|
-
callback,
|
|
29308
|
-
disabled
|
|
29309
|
-
} = _ref;
|
|
29310
|
-
const handleResize = useEvent(callback);
|
|
29311
|
-
const resizeObserver = useMemo(() => {
|
|
29312
|
-
if (disabled || typeof window === 'undefined' || typeof window.ResizeObserver === 'undefined') {
|
|
29313
|
-
return undefined;
|
|
29314
|
-
}
|
|
29315
|
-
|
|
29316
|
-
const {
|
|
29317
|
-
ResizeObserver
|
|
29318
|
-
} = window;
|
|
29319
|
-
return new ResizeObserver(handleResize);
|
|
29320
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29321
|
-
[disabled]);
|
|
29322
|
-
useEffect(() => {
|
|
29323
|
-
return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
29324
|
-
}, [resizeObserver]);
|
|
29325
|
-
return resizeObserver;
|
|
29326
|
-
}
|
|
29327
|
-
|
|
29328
|
-
function defaultMeasure(element) {
|
|
29329
|
-
return new Rect(getClientRect(element), element);
|
|
29330
|
-
}
|
|
29331
|
-
|
|
29332
|
-
function useRect(element, measure, fallbackRect) {
|
|
29333
|
-
if (measure === void 0) {
|
|
29334
|
-
measure = defaultMeasure;
|
|
29335
|
-
}
|
|
29336
|
-
|
|
29337
|
-
const [rect, setRect] = useState(null);
|
|
29338
|
-
|
|
29339
|
-
function measureRect() {
|
|
29340
|
-
setRect(currentRect => {
|
|
29341
|
-
if (!element) {
|
|
29342
|
-
return null;
|
|
29343
|
-
}
|
|
29344
|
-
|
|
29345
|
-
if (element.isConnected === false) {
|
|
29346
|
-
var _ref;
|
|
29347
|
-
|
|
29348
|
-
// Fall back to last rect we measured if the element is
|
|
29349
|
-
// no longer connected to the DOM.
|
|
29350
|
-
return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
|
|
29351
|
-
}
|
|
29352
|
-
|
|
29353
|
-
const newRect = measure(element);
|
|
29354
|
-
|
|
29355
|
-
if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
|
|
29356
|
-
return currentRect;
|
|
29357
|
-
}
|
|
29358
|
-
|
|
29359
|
-
return newRect;
|
|
29360
|
-
});
|
|
29361
|
-
}
|
|
29362
|
-
|
|
29363
|
-
const mutationObserver = useMutationObserver({
|
|
29364
|
-
callback(records) {
|
|
29365
|
-
if (!element) {
|
|
29366
|
-
return;
|
|
29367
|
-
}
|
|
29368
|
-
|
|
29369
|
-
for (const record of records) {
|
|
29370
|
-
const {
|
|
29371
|
-
type,
|
|
29372
|
-
target
|
|
29373
|
-
} = record;
|
|
29374
|
-
|
|
29375
|
-
if (type === 'childList' && target instanceof HTMLElement && target.contains(element)) {
|
|
29376
|
-
measureRect();
|
|
29377
|
-
break;
|
|
29378
|
-
}
|
|
29379
|
-
}
|
|
29380
|
-
}
|
|
29381
|
-
|
|
29382
|
-
});
|
|
29383
|
-
const resizeObserver = useResizeObserver({
|
|
29384
|
-
callback: measureRect
|
|
29385
|
-
});
|
|
29386
|
-
useIsomorphicLayoutEffect(() => {
|
|
29387
|
-
measureRect();
|
|
29388
|
-
|
|
29389
|
-
if (element) {
|
|
29390
|
-
resizeObserver == null ? void 0 : resizeObserver.observe(element);
|
|
29391
|
-
mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
|
|
29392
|
-
childList: true,
|
|
29393
|
-
subtree: true
|
|
29394
|
-
});
|
|
29395
|
-
} else {
|
|
29396
|
-
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
29397
|
-
mutationObserver == null ? void 0 : mutationObserver.disconnect();
|
|
29398
|
-
}
|
|
29399
|
-
}, [element]);
|
|
29400
|
-
return rect;
|
|
29401
|
-
}
|
|
29402
|
-
|
|
29403
|
-
function useRectDelta(rect) {
|
|
29404
|
-
const initialRect = useInitialValue(rect);
|
|
29405
|
-
return getRectDelta(rect, initialRect);
|
|
29406
|
-
}
|
|
29407
|
-
|
|
29408
|
-
const defaultValue$1 = [];
|
|
29409
|
-
function useScrollableAncestors(node) {
|
|
29410
|
-
const previousNode = useRef(node);
|
|
29411
|
-
const ancestors = useLazyMemo(previousValue => {
|
|
29412
|
-
if (!node) {
|
|
29413
|
-
return defaultValue$1;
|
|
29414
|
-
}
|
|
29415
|
-
|
|
29416
|
-
if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
|
|
29417
|
-
return previousValue;
|
|
29418
|
-
}
|
|
29419
|
-
|
|
29420
|
-
return getScrollableAncestors(node);
|
|
29421
|
-
}, [node]);
|
|
29422
|
-
useEffect(() => {
|
|
29423
|
-
previousNode.current = node;
|
|
29424
|
-
}, [node]);
|
|
29425
|
-
return ancestors;
|
|
29426
|
-
}
|
|
29427
|
-
|
|
29428
|
-
function useScrollOffsets(elements) {
|
|
29429
|
-
const [scrollCoordinates, setScrollCoordinates] = useState(null);
|
|
29430
|
-
const prevElements = useRef(elements); // To-do: Throttle the handleScroll callback
|
|
29431
|
-
|
|
29432
|
-
const handleScroll = useCallback(event => {
|
|
29433
|
-
const scrollingElement = getScrollableElement(event.target);
|
|
29434
|
-
|
|
29435
|
-
if (!scrollingElement) {
|
|
29436
|
-
return;
|
|
29437
|
-
}
|
|
29438
|
-
|
|
29439
|
-
setScrollCoordinates(scrollCoordinates => {
|
|
29440
|
-
if (!scrollCoordinates) {
|
|
29441
|
-
return null;
|
|
29442
|
-
}
|
|
29443
|
-
|
|
29444
|
-
scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));
|
|
29445
|
-
return new Map(scrollCoordinates);
|
|
29446
|
-
});
|
|
29447
|
-
}, []);
|
|
29448
|
-
useEffect(() => {
|
|
29449
|
-
const previousElements = prevElements.current;
|
|
29450
|
-
|
|
29451
|
-
if (elements !== previousElements) {
|
|
29452
|
-
cleanup(previousElements);
|
|
29453
|
-
const entries = elements.map(element => {
|
|
29454
|
-
const scrollableElement = getScrollableElement(element);
|
|
29455
|
-
|
|
29456
|
-
if (scrollableElement) {
|
|
29457
|
-
scrollableElement.addEventListener('scroll', handleScroll, {
|
|
29458
|
-
passive: true
|
|
29459
|
-
});
|
|
29460
|
-
return [scrollableElement, getScrollCoordinates(scrollableElement)];
|
|
29461
|
-
}
|
|
29462
|
-
|
|
29463
|
-
return null;
|
|
29464
|
-
}).filter(entry => entry != null);
|
|
29465
|
-
setScrollCoordinates(entries.length ? new Map(entries) : null);
|
|
29466
|
-
prevElements.current = elements;
|
|
29467
|
-
}
|
|
29468
|
-
|
|
29469
|
-
return () => {
|
|
29470
|
-
cleanup(elements);
|
|
29471
|
-
cleanup(previousElements);
|
|
29472
|
-
};
|
|
29473
|
-
|
|
29474
|
-
function cleanup(elements) {
|
|
29475
|
-
elements.forEach(element => {
|
|
29476
|
-
const scrollableElement = getScrollableElement(element);
|
|
29477
|
-
scrollableElement == null ? void 0 : scrollableElement.removeEventListener('scroll', handleScroll);
|
|
29478
|
-
});
|
|
29479
|
-
}
|
|
29480
|
-
}, [handleScroll, elements]);
|
|
29481
|
-
return useMemo(() => {
|
|
29482
|
-
if (elements.length) {
|
|
29483
|
-
return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
|
|
29484
|
-
}
|
|
29485
|
-
|
|
29486
|
-
return defaultCoordinates;
|
|
29487
|
-
}, [elements, scrollCoordinates]);
|
|
29488
|
-
}
|
|
29489
|
-
|
|
29490
|
-
function useScrollOffsetsDelta(scrollOffsets, dependencies) {
|
|
29491
|
-
if (dependencies === void 0) {
|
|
29492
|
-
dependencies = [];
|
|
29493
|
-
}
|
|
29494
|
-
|
|
29495
|
-
const initialScrollOffsets = useRef(null);
|
|
29496
|
-
useEffect(() => {
|
|
29497
|
-
initialScrollOffsets.current = null;
|
|
29498
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29499
|
-
dependencies);
|
|
29500
|
-
useEffect(() => {
|
|
29501
|
-
const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
|
|
29502
|
-
|
|
29503
|
-
if (hasScrollOffsets && !initialScrollOffsets.current) {
|
|
29504
|
-
initialScrollOffsets.current = scrollOffsets;
|
|
29505
|
-
}
|
|
29506
|
-
|
|
29507
|
-
if (!hasScrollOffsets && initialScrollOffsets.current) {
|
|
29508
|
-
initialScrollOffsets.current = null;
|
|
29509
|
-
}
|
|
29510
|
-
}, [scrollOffsets]);
|
|
29511
|
-
return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
|
|
29512
|
-
}
|
|
29513
|
-
|
|
29514
|
-
function useSensorSetup(sensors) {
|
|
29515
|
-
useEffect(() => {
|
|
29516
|
-
if (!canUseDOM) {
|
|
29517
|
-
return;
|
|
29518
|
-
}
|
|
29519
|
-
|
|
29520
|
-
const teardownFns = sensors.map(_ref => {
|
|
29521
|
-
let {
|
|
29522
|
-
sensor
|
|
29523
|
-
} = _ref;
|
|
29524
|
-
return sensor.setup == null ? void 0 : sensor.setup();
|
|
29525
|
-
});
|
|
29526
|
-
return () => {
|
|
29527
|
-
for (const teardown of teardownFns) {
|
|
29528
|
-
teardown == null ? void 0 : teardown();
|
|
29529
|
-
}
|
|
29530
|
-
};
|
|
29531
|
-
}, // TO-DO: Sensors length could theoretically change which would not be a valid dependency
|
|
29532
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29533
|
-
sensors.map(_ref2 => {
|
|
29534
|
-
let {
|
|
29535
|
-
sensor
|
|
29536
|
-
} = _ref2;
|
|
29537
|
-
return sensor;
|
|
29538
|
-
}));
|
|
29539
|
-
}
|
|
29540
|
-
|
|
29541
|
-
function useWindowRect(element) {
|
|
29542
|
-
return useMemo(() => element ? getWindowClientRect(element) : null, [element]);
|
|
29543
|
-
}
|
|
29544
|
-
|
|
29545
|
-
const defaultValue$2 = [];
|
|
29546
|
-
function useRects(elements, measure) {
|
|
29547
|
-
if (measure === void 0) {
|
|
29548
|
-
measure = getClientRect;
|
|
29549
|
-
}
|
|
29550
|
-
|
|
29551
|
-
const [firstElement] = elements;
|
|
29552
|
-
const windowRect = useWindowRect(firstElement ? getWindow(firstElement) : null);
|
|
29553
|
-
const [rects, setRects] = useState(defaultValue$2);
|
|
29554
|
-
|
|
29555
|
-
function measureRects() {
|
|
29556
|
-
setRects(() => {
|
|
29557
|
-
if (!elements.length) {
|
|
29558
|
-
return defaultValue$2;
|
|
29559
|
-
}
|
|
29560
|
-
|
|
29561
|
-
return elements.map(element => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
|
|
29562
|
-
});
|
|
29563
|
-
}
|
|
29564
|
-
|
|
29565
|
-
const resizeObserver = useResizeObserver({
|
|
29566
|
-
callback: measureRects
|
|
29567
|
-
});
|
|
29568
|
-
useIsomorphicLayoutEffect(() => {
|
|
29569
|
-
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
29570
|
-
measureRects();
|
|
29571
|
-
elements.forEach(element => resizeObserver == null ? void 0 : resizeObserver.observe(element));
|
|
29572
|
-
}, [elements]);
|
|
29573
|
-
return rects;
|
|
29574
|
-
}
|
|
29575
|
-
|
|
29576
|
-
function getMeasurableNode(node) {
|
|
29577
|
-
if (!node) {
|
|
29578
|
-
return null;
|
|
29579
|
-
}
|
|
29580
|
-
|
|
29581
|
-
if (node.children.length > 1) {
|
|
29582
|
-
return node;
|
|
29583
|
-
}
|
|
29584
|
-
|
|
29585
|
-
const firstChild = node.children[0];
|
|
29586
|
-
return isHTMLElement(firstChild) ? firstChild : node;
|
|
29587
|
-
}
|
|
29588
|
-
|
|
29589
|
-
function useDragOverlayMeasuring(_ref) {
|
|
29590
|
-
let {
|
|
29591
|
-
measure
|
|
29592
|
-
} = _ref;
|
|
29593
|
-
const [rect, setRect] = useState(null);
|
|
29594
|
-
const handleResize = useCallback(entries => {
|
|
29595
|
-
for (const {
|
|
29596
|
-
target
|
|
29597
|
-
} of entries) {
|
|
29598
|
-
if (isHTMLElement(target)) {
|
|
29599
|
-
setRect(rect => {
|
|
29600
|
-
const newRect = measure(target);
|
|
29601
|
-
return rect ? { ...rect,
|
|
29602
|
-
width: newRect.width,
|
|
29603
|
-
height: newRect.height
|
|
29604
|
-
} : newRect;
|
|
29605
|
-
});
|
|
29606
|
-
break;
|
|
29607
|
-
}
|
|
29608
|
-
}
|
|
29609
|
-
}, [measure]);
|
|
29610
|
-
const resizeObserver = useResizeObserver({
|
|
29611
|
-
callback: handleResize
|
|
29612
|
-
});
|
|
29613
|
-
const handleNodeChange = useCallback(element => {
|
|
29614
|
-
const node = getMeasurableNode(element);
|
|
29615
|
-
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
29616
|
-
|
|
29617
|
-
if (node) {
|
|
29618
|
-
resizeObserver == null ? void 0 : resizeObserver.observe(node);
|
|
29619
|
-
}
|
|
29620
|
-
|
|
29621
|
-
setRect(node ? measure(node) : null);
|
|
29622
|
-
}, [measure, resizeObserver]);
|
|
29623
|
-
const [nodeRef, setRef] = useNodeRef(handleNodeChange);
|
|
29624
|
-
return useMemo(() => ({
|
|
29625
|
-
nodeRef,
|
|
29626
|
-
rect,
|
|
29627
|
-
setRef
|
|
29628
|
-
}), [rect, nodeRef, setRef]);
|
|
29629
|
-
}
|
|
29630
|
-
|
|
29631
|
-
const defaultSensors = [{
|
|
29632
|
-
sensor: PointerSensor,
|
|
29633
|
-
options: {}
|
|
29634
|
-
}, {
|
|
29635
|
-
sensor: KeyboardSensor,
|
|
29636
|
-
options: {}
|
|
29637
|
-
}];
|
|
29638
|
-
const defaultData = {
|
|
29639
|
-
current: {}
|
|
29640
|
-
};
|
|
29641
|
-
const defaultMeasuringConfiguration = {
|
|
29642
|
-
draggable: {
|
|
29643
|
-
measure: getTransformAgnosticClientRect
|
|
29644
|
-
},
|
|
29645
|
-
droppable: {
|
|
29646
|
-
measure: getTransformAgnosticClientRect,
|
|
29647
|
-
strategy: MeasuringStrategy.WhileDragging,
|
|
29648
|
-
frequency: MeasuringFrequency.Optimized
|
|
29649
|
-
},
|
|
29650
|
-
dragOverlay: {
|
|
29651
|
-
measure: getClientRect
|
|
29652
|
-
}
|
|
29653
|
-
};
|
|
29654
|
-
|
|
29655
|
-
class DroppableContainersMap extends Map {
|
|
29656
|
-
get(id) {
|
|
29657
|
-
var _super$get;
|
|
29658
|
-
|
|
29659
|
-
return id != null ? (_super$get = super.get(id)) != null ? _super$get : undefined : undefined;
|
|
29660
|
-
}
|
|
29661
|
-
|
|
29662
|
-
toArray() {
|
|
29663
|
-
return Array.from(this.values());
|
|
29664
|
-
}
|
|
29665
|
-
|
|
29666
|
-
getEnabled() {
|
|
29667
|
-
return this.toArray().filter(_ref => {
|
|
29668
|
-
let {
|
|
29669
|
-
disabled
|
|
29670
|
-
} = _ref;
|
|
29671
|
-
return !disabled;
|
|
29672
|
-
});
|
|
29673
|
-
}
|
|
29674
|
-
|
|
29675
|
-
getNodeFor(id) {
|
|
29676
|
-
var _this$get$node$curren, _this$get;
|
|
29677
|
-
|
|
29678
|
-
return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : undefined;
|
|
29679
|
-
}
|
|
29680
|
-
|
|
29681
|
-
}
|
|
29682
|
-
|
|
29683
|
-
const defaultPublicContext = {
|
|
29684
|
-
activatorEvent: null,
|
|
29685
|
-
active: null,
|
|
29686
|
-
activeNode: null,
|
|
29687
|
-
activeNodeRect: null,
|
|
29688
|
-
collisions: null,
|
|
29689
|
-
containerNodeRect: null,
|
|
29690
|
-
draggableNodes: /*#__PURE__*/new Map(),
|
|
29691
|
-
droppableRects: /*#__PURE__*/new Map(),
|
|
29692
|
-
droppableContainers: /*#__PURE__*/new DroppableContainersMap(),
|
|
29693
|
-
over: null,
|
|
29694
|
-
dragOverlay: {
|
|
29695
|
-
nodeRef: {
|
|
29696
|
-
current: null
|
|
29697
|
-
},
|
|
29698
|
-
rect: null,
|
|
29699
|
-
setRef: noop
|
|
29700
|
-
},
|
|
29701
|
-
scrollableAncestors: [],
|
|
29702
|
-
scrollableAncestorRects: [],
|
|
29703
|
-
measuringConfiguration: defaultMeasuringConfiguration,
|
|
29704
|
-
measureDroppableContainers: noop,
|
|
29705
|
-
windowRect: null,
|
|
29706
|
-
measuringScheduled: false
|
|
29707
|
-
};
|
|
29708
|
-
const defaultInternalContext = {
|
|
29709
|
-
activatorEvent: null,
|
|
29710
|
-
activators: [],
|
|
29711
|
-
active: null,
|
|
29712
|
-
activeNodeRect: null,
|
|
29713
|
-
ariaDescribedById: {
|
|
29714
|
-
draggable: ''
|
|
29715
|
-
},
|
|
29716
|
-
dispatch: noop,
|
|
29717
|
-
draggableNodes: /*#__PURE__*/new Map(),
|
|
29718
|
-
over: null,
|
|
29719
|
-
measureDroppableContainers: noop
|
|
29720
|
-
};
|
|
29721
|
-
const InternalContext = /*#__PURE__*/createContext(defaultInternalContext);
|
|
29722
|
-
const PublicContext = /*#__PURE__*/createContext(defaultPublicContext);
|
|
29723
|
-
|
|
29724
|
-
function getInitialState() {
|
|
29725
|
-
return {
|
|
29726
|
-
draggable: {
|
|
29727
|
-
active: null,
|
|
29728
|
-
initialCoordinates: {
|
|
29729
|
-
x: 0,
|
|
29730
|
-
y: 0
|
|
29731
|
-
},
|
|
29732
|
-
nodes: new Map(),
|
|
29733
|
-
translate: {
|
|
29734
|
-
x: 0,
|
|
29735
|
-
y: 0
|
|
29736
|
-
}
|
|
29737
|
-
},
|
|
29738
|
-
droppable: {
|
|
29739
|
-
containers: new DroppableContainersMap()
|
|
29740
|
-
}
|
|
29741
|
-
};
|
|
29742
|
-
}
|
|
29743
|
-
function reducer(state, action) {
|
|
29744
|
-
switch (action.type) {
|
|
29745
|
-
case Action.DragStart:
|
|
29746
|
-
return { ...state,
|
|
29747
|
-
draggable: { ...state.draggable,
|
|
29748
|
-
initialCoordinates: action.initialCoordinates,
|
|
29749
|
-
active: action.active
|
|
29750
|
-
}
|
|
29751
|
-
};
|
|
29752
|
-
|
|
29753
|
-
case Action.DragMove:
|
|
29754
|
-
if (state.draggable.active == null) {
|
|
29755
|
-
return state;
|
|
29756
|
-
}
|
|
29757
|
-
|
|
29758
|
-
return { ...state,
|
|
29759
|
-
draggable: { ...state.draggable,
|
|
29760
|
-
translate: {
|
|
29761
|
-
x: action.coordinates.x - state.draggable.initialCoordinates.x,
|
|
29762
|
-
y: action.coordinates.y - state.draggable.initialCoordinates.y
|
|
29763
|
-
}
|
|
29764
|
-
}
|
|
29765
|
-
};
|
|
29766
|
-
|
|
29767
|
-
case Action.DragEnd:
|
|
29768
|
-
case Action.DragCancel:
|
|
29769
|
-
return { ...state,
|
|
29770
|
-
draggable: { ...state.draggable,
|
|
29771
|
-
active: null,
|
|
29772
|
-
initialCoordinates: {
|
|
29773
|
-
x: 0,
|
|
29774
|
-
y: 0
|
|
29775
|
-
},
|
|
29776
|
-
translate: {
|
|
29777
|
-
x: 0,
|
|
29778
|
-
y: 0
|
|
29779
|
-
}
|
|
29780
|
-
}
|
|
29781
|
-
};
|
|
29782
|
-
|
|
29783
|
-
case Action.RegisterDroppable:
|
|
29784
|
-
{
|
|
29785
|
-
const {
|
|
29786
|
-
element
|
|
29787
|
-
} = action;
|
|
29788
|
-
const {
|
|
29789
|
-
id
|
|
29790
|
-
} = element;
|
|
29791
|
-
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
29792
|
-
containers.set(id, element);
|
|
29793
|
-
return { ...state,
|
|
29794
|
-
droppable: { ...state.droppable,
|
|
29795
|
-
containers
|
|
29796
|
-
}
|
|
29797
|
-
};
|
|
29798
|
-
}
|
|
29799
|
-
|
|
29800
|
-
case Action.SetDroppableDisabled:
|
|
29801
|
-
{
|
|
29802
|
-
const {
|
|
29803
|
-
id,
|
|
29804
|
-
key,
|
|
29805
|
-
disabled
|
|
29806
|
-
} = action;
|
|
29807
|
-
const element = state.droppable.containers.get(id);
|
|
29808
|
-
|
|
29809
|
-
if (!element || key !== element.key) {
|
|
29810
|
-
return state;
|
|
29811
|
-
}
|
|
29812
|
-
|
|
29813
|
-
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
29814
|
-
containers.set(id, { ...element,
|
|
29815
|
-
disabled
|
|
29816
|
-
});
|
|
29817
|
-
return { ...state,
|
|
29818
|
-
droppable: { ...state.droppable,
|
|
29819
|
-
containers
|
|
29820
|
-
}
|
|
29821
|
-
};
|
|
29822
|
-
}
|
|
29823
|
-
|
|
29824
|
-
case Action.UnregisterDroppable:
|
|
29825
|
-
{
|
|
29826
|
-
const {
|
|
29827
|
-
id,
|
|
29828
|
-
key
|
|
29829
|
-
} = action;
|
|
29830
|
-
const element = state.droppable.containers.get(id);
|
|
29831
|
-
|
|
29832
|
-
if (!element || key !== element.key) {
|
|
29833
|
-
return state;
|
|
29834
|
-
}
|
|
29835
|
-
|
|
29836
|
-
const containers = new DroppableContainersMap(state.droppable.containers);
|
|
29837
|
-
containers.delete(id);
|
|
29838
|
-
return { ...state,
|
|
29839
|
-
droppable: { ...state.droppable,
|
|
29840
|
-
containers
|
|
29841
|
-
}
|
|
29842
|
-
};
|
|
29843
|
-
}
|
|
29844
|
-
|
|
29845
|
-
default:
|
|
29846
|
-
{
|
|
29847
|
-
return state;
|
|
29848
|
-
}
|
|
29849
|
-
}
|
|
29850
|
-
}
|
|
29851
|
-
|
|
29852
|
-
function RestoreFocus(_ref) {
|
|
29853
|
-
let {
|
|
29854
|
-
disabled
|
|
29855
|
-
} = _ref;
|
|
29856
|
-
const {
|
|
29857
|
-
active,
|
|
29858
|
-
activatorEvent,
|
|
29859
|
-
draggableNodes
|
|
29860
|
-
} = useContext(InternalContext);
|
|
29861
|
-
const previousActivatorEvent = usePrevious(activatorEvent);
|
|
29862
|
-
const previousActiveId = usePrevious(active == null ? void 0 : active.id); // Restore keyboard focus on the activator node
|
|
29863
|
-
|
|
29864
|
-
useEffect(() => {
|
|
29865
|
-
if (disabled) {
|
|
29866
|
-
return;
|
|
29867
|
-
}
|
|
29868
|
-
|
|
29869
|
-
if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
|
|
29870
|
-
if (!isKeyboardEvent(previousActivatorEvent)) {
|
|
29871
|
-
return;
|
|
29872
|
-
}
|
|
29873
|
-
|
|
29874
|
-
if (document.activeElement === previousActivatorEvent.target) {
|
|
29875
|
-
// No need to restore focus
|
|
29876
|
-
return;
|
|
29877
|
-
}
|
|
29878
|
-
|
|
29879
|
-
const draggableNode = draggableNodes.get(previousActiveId);
|
|
29880
|
-
|
|
29881
|
-
if (!draggableNode) {
|
|
29882
|
-
return;
|
|
29883
|
-
}
|
|
29884
|
-
|
|
29885
|
-
const {
|
|
29886
|
-
activatorNode,
|
|
29887
|
-
node
|
|
29888
|
-
} = draggableNode;
|
|
29889
|
-
|
|
29890
|
-
if (!activatorNode.current && !node.current) {
|
|
29891
|
-
return;
|
|
29892
|
-
}
|
|
29893
|
-
|
|
29894
|
-
requestAnimationFrame(() => {
|
|
29895
|
-
for (const element of [activatorNode.current, node.current]) {
|
|
29896
|
-
if (!element) {
|
|
29897
|
-
continue;
|
|
29898
|
-
}
|
|
29899
|
-
|
|
29900
|
-
const focusableNode = findFirstFocusableNode(element);
|
|
29901
|
-
|
|
29902
|
-
if (focusableNode) {
|
|
29903
|
-
focusableNode.focus();
|
|
29904
|
-
break;
|
|
29905
|
-
}
|
|
29906
|
-
}
|
|
29907
|
-
});
|
|
29908
|
-
}
|
|
29909
|
-
}, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]);
|
|
29910
|
-
return null;
|
|
29911
|
-
}
|
|
29912
|
-
|
|
29913
|
-
function applyModifiers(modifiers, _ref) {
|
|
29914
|
-
let {
|
|
29915
|
-
transform,
|
|
29916
|
-
...args
|
|
29917
|
-
} = _ref;
|
|
29918
|
-
return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
|
|
29919
|
-
return modifier({
|
|
29920
|
-
transform: accumulator,
|
|
29921
|
-
...args
|
|
29922
|
-
});
|
|
29923
|
-
}, transform) : transform;
|
|
29924
|
-
}
|
|
29925
|
-
|
|
29926
|
-
function useMeasuringConfiguration(config) {
|
|
29927
|
-
return useMemo(() => ({
|
|
29928
|
-
draggable: { ...defaultMeasuringConfiguration.draggable,
|
|
29929
|
-
...(config == null ? void 0 : config.draggable)
|
|
29930
|
-
},
|
|
29931
|
-
droppable: { ...defaultMeasuringConfiguration.droppable,
|
|
29932
|
-
...(config == null ? void 0 : config.droppable)
|
|
29933
|
-
},
|
|
29934
|
-
dragOverlay: { ...defaultMeasuringConfiguration.dragOverlay,
|
|
29935
|
-
...(config == null ? void 0 : config.dragOverlay)
|
|
29936
|
-
}
|
|
29937
|
-
}), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29938
|
-
[config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]);
|
|
29939
|
-
}
|
|
29940
|
-
|
|
29941
|
-
function useLayoutShiftScrollCompensation(_ref) {
|
|
29942
|
-
let {
|
|
29943
|
-
activeNode,
|
|
29944
|
-
measure,
|
|
29945
|
-
initialRect,
|
|
29946
|
-
config = true
|
|
29947
|
-
} = _ref;
|
|
29948
|
-
const initialized = useRef(false);
|
|
29949
|
-
const {
|
|
29950
|
-
x,
|
|
29951
|
-
y
|
|
29952
|
-
} = typeof config === 'boolean' ? {
|
|
29953
|
-
x: config,
|
|
29954
|
-
y: config
|
|
29955
|
-
} : config;
|
|
29956
|
-
useIsomorphicLayoutEffect(() => {
|
|
29957
|
-
const disabled = !x && !y;
|
|
29958
|
-
|
|
29959
|
-
if (disabled || !activeNode) {
|
|
29960
|
-
initialized.current = false;
|
|
29961
|
-
return;
|
|
29962
|
-
}
|
|
29963
|
-
|
|
29964
|
-
if (initialized.current || !initialRect) {
|
|
29965
|
-
// Return early if layout shift scroll compensation was already attempted
|
|
29966
|
-
// or if there is no initialRect to compare to.
|
|
29967
|
-
return;
|
|
29968
|
-
} // Get the most up to date node ref for the active draggable
|
|
29969
|
-
|
|
29970
|
-
|
|
29971
|
-
const node = activeNode == null ? void 0 : activeNode.node.current;
|
|
29972
|
-
|
|
29973
|
-
if (!node || node.isConnected === false) {
|
|
29974
|
-
// Return early if there is no attached node ref or if the node is
|
|
29975
|
-
// disconnected from the document.
|
|
29976
|
-
return;
|
|
29977
|
-
}
|
|
29978
|
-
|
|
29979
|
-
const rect = measure(node);
|
|
29980
|
-
const rectDelta = getRectDelta(rect, initialRect);
|
|
29981
|
-
|
|
29982
|
-
if (!x) {
|
|
29983
|
-
rectDelta.x = 0;
|
|
29984
|
-
}
|
|
29985
|
-
|
|
29986
|
-
if (!y) {
|
|
29987
|
-
rectDelta.y = 0;
|
|
29988
|
-
} // Only perform layout shift scroll compensation once
|
|
29989
|
-
|
|
29990
|
-
|
|
29991
|
-
initialized.current = true;
|
|
29992
|
-
|
|
29993
|
-
if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
|
|
29994
|
-
const firstScrollableAncestor = getFirstScrollableAncestor(node);
|
|
29995
|
-
|
|
29996
|
-
if (firstScrollableAncestor) {
|
|
29997
|
-
firstScrollableAncestor.scrollBy({
|
|
29998
|
-
top: rectDelta.y,
|
|
29999
|
-
left: rectDelta.x
|
|
30000
|
-
});
|
|
30001
|
-
}
|
|
30002
|
-
}
|
|
30003
|
-
}, [activeNode, x, y, initialRect, measure]);
|
|
30004
|
-
}
|
|
30005
|
-
|
|
30006
|
-
const ActiveDraggableContext = /*#__PURE__*/createContext({ ...defaultCoordinates,
|
|
30007
|
-
scaleX: 1,
|
|
30008
|
-
scaleY: 1
|
|
30009
|
-
});
|
|
30010
|
-
var Status;
|
|
30011
|
-
|
|
30012
|
-
(function (Status) {
|
|
30013
|
-
Status[Status["Uninitialized"] = 0] = "Uninitialized";
|
|
30014
|
-
Status[Status["Initializing"] = 1] = "Initializing";
|
|
30015
|
-
Status[Status["Initialized"] = 2] = "Initialized";
|
|
30016
|
-
})(Status || (Status = {}));
|
|
30017
|
-
|
|
30018
|
-
const DndContext = /*#__PURE__*/memo(function DndContext(_ref) {
|
|
30019
|
-
var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
|
|
30020
|
-
|
|
30021
|
-
let {
|
|
30022
|
-
id,
|
|
30023
|
-
accessibility,
|
|
30024
|
-
autoScroll = true,
|
|
30025
|
-
children,
|
|
30026
|
-
sensors = defaultSensors,
|
|
30027
|
-
collisionDetection = rectIntersection,
|
|
30028
|
-
measuring,
|
|
30029
|
-
modifiers,
|
|
30030
|
-
...props
|
|
30031
|
-
} = _ref;
|
|
30032
|
-
const store = useReducer(reducer, undefined, getInitialState);
|
|
30033
|
-
const [state, dispatch] = store;
|
|
30034
|
-
const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
|
|
30035
|
-
const [status, setStatus] = useState(Status.Uninitialized);
|
|
30036
|
-
const isInitialized = status === Status.Initialized;
|
|
30037
|
-
const {
|
|
30038
|
-
draggable: {
|
|
30039
|
-
active: activeId,
|
|
30040
|
-
nodes: draggableNodes,
|
|
30041
|
-
translate
|
|
30042
|
-
},
|
|
30043
|
-
droppable: {
|
|
30044
|
-
containers: droppableContainers
|
|
30045
|
-
}
|
|
30046
|
-
} = state;
|
|
30047
|
-
const node = activeId != null ? draggableNodes.get(activeId) : null;
|
|
30048
|
-
const activeRects = useRef({
|
|
30049
|
-
initial: null,
|
|
30050
|
-
translated: null
|
|
30051
|
-
});
|
|
30052
|
-
const active = useMemo(() => {
|
|
30053
|
-
var _node$data;
|
|
30054
|
-
|
|
30055
|
-
return activeId != null ? {
|
|
30056
|
-
id: activeId,
|
|
30057
|
-
// It's possible for the active node to unmount while dragging
|
|
30058
|
-
data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
|
|
30059
|
-
rect: activeRects
|
|
30060
|
-
} : null;
|
|
30061
|
-
}, [activeId, node]);
|
|
30062
|
-
const activeRef = useRef(null);
|
|
30063
|
-
const [activeSensor, setActiveSensor] = useState(null);
|
|
30064
|
-
const [activatorEvent, setActivatorEvent] = useState(null);
|
|
30065
|
-
const latestProps = useLatestValue(props, Object.values(props));
|
|
30066
|
-
const draggableDescribedById = useUniqueId("DndDescribedBy", id);
|
|
30067
|
-
const enabledDroppableContainers = useMemo(() => droppableContainers.getEnabled(), [droppableContainers]);
|
|
30068
|
-
const measuringConfiguration = useMeasuringConfiguration(measuring);
|
|
30069
|
-
const {
|
|
30070
|
-
droppableRects,
|
|
30071
|
-
measureDroppableContainers,
|
|
30072
|
-
measuringScheduled
|
|
30073
|
-
} = useDroppableMeasuring(enabledDroppableContainers, {
|
|
30074
|
-
dragging: isInitialized,
|
|
30075
|
-
dependencies: [translate.x, translate.y],
|
|
30076
|
-
config: measuringConfiguration.droppable
|
|
30077
|
-
});
|
|
30078
|
-
const activeNode = useCachedNode(draggableNodes, activeId);
|
|
30079
|
-
const activationCoordinates = useMemo(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
|
|
30080
|
-
const autoScrollOptions = getAutoScrollerOptions();
|
|
30081
|
-
const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
|
|
30082
|
-
useLayoutShiftScrollCompensation({
|
|
30083
|
-
activeNode: activeId != null ? draggableNodes.get(activeId) : null,
|
|
30084
|
-
config: autoScrollOptions.layoutShiftCompensation,
|
|
30085
|
-
initialRect: initialActiveNodeRect,
|
|
30086
|
-
measure: measuringConfiguration.draggable.measure
|
|
30087
|
-
});
|
|
30088
|
-
const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
|
|
30089
|
-
const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
|
|
30090
|
-
const sensorContext = useRef({
|
|
30091
|
-
activatorEvent: null,
|
|
30092
|
-
active: null,
|
|
30093
|
-
activeNode,
|
|
30094
|
-
collisionRect: null,
|
|
30095
|
-
collisions: null,
|
|
30096
|
-
droppableRects,
|
|
30097
|
-
draggableNodes,
|
|
30098
|
-
draggingNode: null,
|
|
30099
|
-
draggingNodeRect: null,
|
|
30100
|
-
droppableContainers,
|
|
30101
|
-
over: null,
|
|
30102
|
-
scrollableAncestors: [],
|
|
30103
|
-
scrollAdjustedTranslate: null
|
|
30104
|
-
});
|
|
30105
|
-
const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
|
|
30106
|
-
const dragOverlay = useDragOverlayMeasuring({
|
|
30107
|
-
measure: measuringConfiguration.dragOverlay.measure
|
|
30108
|
-
}); // Use the rect of the drag overlay if it is mounted
|
|
30109
|
-
|
|
30110
|
-
const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
|
|
30111
|
-
const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
|
|
30112
|
-
const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect); // The delta between the previous and new position of the draggable node
|
|
30113
|
-
// is only relevant when there is no drag overlay
|
|
30114
|
-
|
|
30115
|
-
const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect); // Get the window rect of the dragging node
|
|
30116
|
-
|
|
30117
|
-
const windowRect = useWindowRect(draggingNode ? getWindow(draggingNode) : null); // Get scrollable ancestors of the dragging node
|
|
30118
|
-
|
|
30119
|
-
const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
|
|
30120
|
-
const scrollableAncestorRects = useRects(scrollableAncestors); // Apply modifiers
|
|
30121
|
-
|
|
30122
|
-
const modifiedTranslate = applyModifiers(modifiers, {
|
|
30123
|
-
transform: {
|
|
30124
|
-
x: translate.x - nodeRectDelta.x,
|
|
30125
|
-
y: translate.y - nodeRectDelta.y,
|
|
30126
|
-
scaleX: 1,
|
|
30127
|
-
scaleY: 1
|
|
30128
|
-
},
|
|
30129
|
-
activatorEvent,
|
|
30130
|
-
active,
|
|
30131
|
-
activeNodeRect,
|
|
30132
|
-
containerNodeRect,
|
|
30133
|
-
draggingNodeRect,
|
|
30134
|
-
over: sensorContext.current.over,
|
|
30135
|
-
overlayNodeRect: dragOverlay.rect,
|
|
30136
|
-
scrollableAncestors,
|
|
30137
|
-
scrollableAncestorRects,
|
|
30138
|
-
windowRect
|
|
30139
|
-
});
|
|
30140
|
-
const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
|
|
30141
|
-
const scrollOffsets = useScrollOffsets(scrollableAncestors); // Represents the scroll delta since dragging was initiated
|
|
30142
|
-
|
|
30143
|
-
const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets); // Represents the scroll delta since the last time the active node rect was measured
|
|
30144
|
-
|
|
30145
|
-
const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
|
|
30146
|
-
const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
|
|
30147
|
-
const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
|
|
30148
|
-
const collisions = active && collisionRect ? collisionDetection({
|
|
30149
|
-
active,
|
|
30150
|
-
collisionRect,
|
|
30151
|
-
droppableRects,
|
|
30152
|
-
droppableContainers: enabledDroppableContainers,
|
|
30153
|
-
pointerCoordinates
|
|
30154
|
-
}) : null;
|
|
30155
|
-
const overId = getFirstCollision(collisions, 'id');
|
|
30156
|
-
const [over, setOver] = useState(null); // When there is no drag overlay used, we need to account for the
|
|
30157
|
-
// window scroll delta
|
|
30158
|
-
|
|
30159
|
-
const appliedTranslate = usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta);
|
|
30160
|
-
const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
|
|
30161
|
-
const activeSensorRef = useRef(null);
|
|
30162
|
-
const instantiateSensor = useCallback((event, _ref2) => {
|
|
30163
|
-
let {
|
|
30164
|
-
sensor: Sensor,
|
|
30165
|
-
options
|
|
30166
|
-
} = _ref2;
|
|
30167
|
-
|
|
30168
|
-
if (activeRef.current == null) {
|
|
30169
|
-
return;
|
|
30170
|
-
}
|
|
30171
|
-
|
|
30172
|
-
const activeNode = draggableNodes.get(activeRef.current);
|
|
30173
|
-
|
|
30174
|
-
if (!activeNode) {
|
|
30175
|
-
return;
|
|
30176
|
-
}
|
|
30177
|
-
|
|
30178
|
-
const activatorEvent = event.nativeEvent;
|
|
30179
|
-
const sensorInstance = new Sensor({
|
|
30180
|
-
active: activeRef.current,
|
|
30181
|
-
activeNode,
|
|
30182
|
-
event: activatorEvent,
|
|
30183
|
-
options,
|
|
30184
|
-
// Sensors need to be instantiated with refs for arguments that change over time
|
|
30185
|
-
// otherwise they are frozen in time with the stale arguments
|
|
30186
|
-
context: sensorContext,
|
|
30187
|
-
|
|
30188
|
-
onAbort(id) {
|
|
30189
|
-
const draggableNode = draggableNodes.get(id);
|
|
30190
|
-
|
|
30191
|
-
if (!draggableNode) {
|
|
30192
|
-
return;
|
|
30193
|
-
}
|
|
30194
|
-
|
|
30195
|
-
const {
|
|
30196
|
-
onDragAbort
|
|
30197
|
-
} = latestProps.current;
|
|
30198
|
-
const event = {
|
|
30199
|
-
id
|
|
30200
|
-
};
|
|
30201
|
-
onDragAbort == null ? void 0 : onDragAbort(event);
|
|
30202
|
-
dispatchMonitorEvent({
|
|
30203
|
-
type: 'onDragAbort',
|
|
30204
|
-
event
|
|
30205
|
-
});
|
|
30206
|
-
},
|
|
30207
|
-
|
|
30208
|
-
onPending(id, constraint, initialCoordinates, offset) {
|
|
30209
|
-
const draggableNode = draggableNodes.get(id);
|
|
30210
|
-
|
|
30211
|
-
if (!draggableNode) {
|
|
30212
|
-
return;
|
|
30213
|
-
}
|
|
30214
|
-
|
|
30215
|
-
const {
|
|
30216
|
-
onDragPending
|
|
30217
|
-
} = latestProps.current;
|
|
30218
|
-
const event = {
|
|
30219
|
-
id,
|
|
30220
|
-
constraint,
|
|
30221
|
-
initialCoordinates,
|
|
30222
|
-
offset
|
|
30223
|
-
};
|
|
30224
|
-
onDragPending == null ? void 0 : onDragPending(event);
|
|
30225
|
-
dispatchMonitorEvent({
|
|
30226
|
-
type: 'onDragPending',
|
|
30227
|
-
event
|
|
30228
|
-
});
|
|
30229
|
-
},
|
|
30230
|
-
|
|
30231
|
-
onStart(initialCoordinates) {
|
|
30232
|
-
const id = activeRef.current;
|
|
30233
|
-
|
|
30234
|
-
if (id == null) {
|
|
30235
|
-
return;
|
|
30236
|
-
}
|
|
30237
|
-
|
|
30238
|
-
const draggableNode = draggableNodes.get(id);
|
|
30239
|
-
|
|
30240
|
-
if (!draggableNode) {
|
|
30241
|
-
return;
|
|
30242
|
-
}
|
|
30243
|
-
|
|
30244
|
-
const {
|
|
30245
|
-
onDragStart
|
|
30246
|
-
} = latestProps.current;
|
|
30247
|
-
const event = {
|
|
30248
|
-
activatorEvent,
|
|
30249
|
-
active: {
|
|
30250
|
-
id,
|
|
30251
|
-
data: draggableNode.data,
|
|
30252
|
-
rect: activeRects
|
|
30253
|
-
}
|
|
30254
|
-
};
|
|
30255
|
-
unstable_batchedUpdates(() => {
|
|
30256
|
-
onDragStart == null ? void 0 : onDragStart(event);
|
|
30257
|
-
setStatus(Status.Initializing);
|
|
30258
|
-
dispatch({
|
|
30259
|
-
type: Action.DragStart,
|
|
30260
|
-
initialCoordinates,
|
|
30261
|
-
active: id
|
|
30262
|
-
});
|
|
30263
|
-
dispatchMonitorEvent({
|
|
30264
|
-
type: 'onDragStart',
|
|
30265
|
-
event
|
|
30266
|
-
});
|
|
30267
|
-
setActiveSensor(activeSensorRef.current);
|
|
30268
|
-
setActivatorEvent(activatorEvent);
|
|
30269
|
-
});
|
|
30270
|
-
},
|
|
30271
|
-
|
|
30272
|
-
onMove(coordinates) {
|
|
30273
|
-
dispatch({
|
|
30274
|
-
type: Action.DragMove,
|
|
30275
|
-
coordinates
|
|
30276
|
-
});
|
|
30277
|
-
},
|
|
30278
|
-
|
|
30279
|
-
onEnd: createHandler(Action.DragEnd),
|
|
30280
|
-
onCancel: createHandler(Action.DragCancel)
|
|
30281
|
-
});
|
|
30282
|
-
activeSensorRef.current = sensorInstance;
|
|
30283
|
-
|
|
30284
|
-
function createHandler(type) {
|
|
30285
|
-
return async function handler() {
|
|
30286
|
-
const {
|
|
30287
|
-
active,
|
|
30288
|
-
collisions,
|
|
30289
|
-
over,
|
|
30290
|
-
scrollAdjustedTranslate
|
|
30291
|
-
} = sensorContext.current;
|
|
30292
|
-
let event = null;
|
|
30293
|
-
|
|
30294
|
-
if (active && scrollAdjustedTranslate) {
|
|
30295
|
-
const {
|
|
30296
|
-
cancelDrop
|
|
30297
|
-
} = latestProps.current;
|
|
30298
|
-
event = {
|
|
30299
|
-
activatorEvent,
|
|
30300
|
-
active: active,
|
|
30301
|
-
collisions,
|
|
30302
|
-
delta: scrollAdjustedTranslate,
|
|
30303
|
-
over
|
|
30304
|
-
};
|
|
30305
|
-
|
|
30306
|
-
if (type === Action.DragEnd && typeof cancelDrop === 'function') {
|
|
30307
|
-
const shouldCancel = await Promise.resolve(cancelDrop(event));
|
|
30308
|
-
|
|
30309
|
-
if (shouldCancel) {
|
|
30310
|
-
type = Action.DragCancel;
|
|
30311
|
-
}
|
|
30312
|
-
}
|
|
30313
|
-
}
|
|
30314
|
-
|
|
30315
|
-
activeRef.current = null;
|
|
30316
|
-
unstable_batchedUpdates(() => {
|
|
30317
|
-
dispatch({
|
|
30318
|
-
type
|
|
30319
|
-
});
|
|
30320
|
-
setStatus(Status.Uninitialized);
|
|
30321
|
-
setOver(null);
|
|
30322
|
-
setActiveSensor(null);
|
|
30323
|
-
setActivatorEvent(null);
|
|
30324
|
-
activeSensorRef.current = null;
|
|
30325
|
-
const eventName = type === Action.DragEnd ? 'onDragEnd' : 'onDragCancel';
|
|
30326
|
-
|
|
30327
|
-
if (event) {
|
|
30328
|
-
const handler = latestProps.current[eventName];
|
|
30329
|
-
handler == null ? void 0 : handler(event);
|
|
30330
|
-
dispatchMonitorEvent({
|
|
30331
|
-
type: eventName,
|
|
30332
|
-
event
|
|
30333
|
-
});
|
|
30334
|
-
}
|
|
30335
|
-
});
|
|
30336
|
-
};
|
|
30337
|
-
}
|
|
30338
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30339
|
-
[draggableNodes]);
|
|
30340
|
-
const bindActivatorToSensorInstantiator = useCallback((handler, sensor) => {
|
|
30341
|
-
return (event, active) => {
|
|
30342
|
-
const nativeEvent = event.nativeEvent;
|
|
30343
|
-
const activeDraggableNode = draggableNodes.get(active);
|
|
30344
|
-
|
|
30345
|
-
if ( // Another sensor is already instantiating
|
|
30346
|
-
activeRef.current !== null || // No active draggable
|
|
30347
|
-
!activeDraggableNode || // Event has already been captured
|
|
30348
|
-
nativeEvent.dndKit || nativeEvent.defaultPrevented) {
|
|
30349
|
-
return;
|
|
30350
|
-
}
|
|
30351
|
-
|
|
30352
|
-
const activationContext = {
|
|
30353
|
-
active: activeDraggableNode
|
|
30354
|
-
};
|
|
30355
|
-
const shouldActivate = handler(event, sensor.options, activationContext);
|
|
30356
|
-
|
|
30357
|
-
if (shouldActivate === true) {
|
|
30358
|
-
nativeEvent.dndKit = {
|
|
30359
|
-
capturedBy: sensor.sensor
|
|
30360
|
-
};
|
|
30361
|
-
activeRef.current = active;
|
|
30362
|
-
instantiateSensor(event, sensor);
|
|
30363
|
-
}
|
|
30364
|
-
};
|
|
30365
|
-
}, [draggableNodes, instantiateSensor]);
|
|
30366
|
-
const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
|
|
30367
|
-
useSensorSetup(sensors);
|
|
30368
|
-
useIsomorphicLayoutEffect(() => {
|
|
30369
|
-
if (activeNodeRect && status === Status.Initializing) {
|
|
30370
|
-
setStatus(Status.Initialized);
|
|
30371
|
-
}
|
|
30372
|
-
}, [activeNodeRect, status]);
|
|
30373
|
-
useEffect(() => {
|
|
30374
|
-
const {
|
|
30375
|
-
onDragMove
|
|
30376
|
-
} = latestProps.current;
|
|
30377
|
-
const {
|
|
30378
|
-
active,
|
|
30379
|
-
activatorEvent,
|
|
30380
|
-
collisions,
|
|
30381
|
-
over
|
|
30382
|
-
} = sensorContext.current;
|
|
30383
|
-
|
|
30384
|
-
if (!active || !activatorEvent) {
|
|
30385
|
-
return;
|
|
30386
|
-
}
|
|
30387
|
-
|
|
30388
|
-
const event = {
|
|
30389
|
-
active,
|
|
30390
|
-
activatorEvent,
|
|
30391
|
-
collisions,
|
|
30392
|
-
delta: {
|
|
30393
|
-
x: scrollAdjustedTranslate.x,
|
|
30394
|
-
y: scrollAdjustedTranslate.y
|
|
30395
|
-
},
|
|
30396
|
-
over
|
|
30397
|
-
};
|
|
30398
|
-
unstable_batchedUpdates(() => {
|
|
30399
|
-
onDragMove == null ? void 0 : onDragMove(event);
|
|
30400
|
-
dispatchMonitorEvent({
|
|
30401
|
-
type: 'onDragMove',
|
|
30402
|
-
event
|
|
30403
|
-
});
|
|
30404
|
-
});
|
|
30405
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30406
|
-
[scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]);
|
|
30407
|
-
useEffect(() => {
|
|
30408
|
-
const {
|
|
30409
|
-
active,
|
|
30410
|
-
activatorEvent,
|
|
30411
|
-
collisions,
|
|
30412
|
-
droppableContainers,
|
|
30413
|
-
scrollAdjustedTranslate
|
|
30414
|
-
} = sensorContext.current;
|
|
30415
|
-
|
|
30416
|
-
if (!active || activeRef.current == null || !activatorEvent || !scrollAdjustedTranslate) {
|
|
30417
|
-
return;
|
|
30418
|
-
}
|
|
30419
|
-
|
|
30420
|
-
const {
|
|
30421
|
-
onDragOver
|
|
30422
|
-
} = latestProps.current;
|
|
30423
|
-
const overContainer = droppableContainers.get(overId);
|
|
30424
|
-
const over = overContainer && overContainer.rect.current ? {
|
|
30425
|
-
id: overContainer.id,
|
|
30426
|
-
rect: overContainer.rect.current,
|
|
30427
|
-
data: overContainer.data,
|
|
30428
|
-
disabled: overContainer.disabled
|
|
30429
|
-
} : null;
|
|
30430
|
-
const event = {
|
|
30431
|
-
active,
|
|
30432
|
-
activatorEvent,
|
|
30433
|
-
collisions,
|
|
30434
|
-
delta: {
|
|
30435
|
-
x: scrollAdjustedTranslate.x,
|
|
30436
|
-
y: scrollAdjustedTranslate.y
|
|
30437
|
-
},
|
|
30438
|
-
over
|
|
30439
|
-
};
|
|
30440
|
-
unstable_batchedUpdates(() => {
|
|
30441
|
-
setOver(over);
|
|
30442
|
-
onDragOver == null ? void 0 : onDragOver(event);
|
|
30443
|
-
dispatchMonitorEvent({
|
|
30444
|
-
type: 'onDragOver',
|
|
30445
|
-
event
|
|
30446
|
-
});
|
|
30447
|
-
});
|
|
30448
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30449
|
-
[overId]);
|
|
30450
|
-
useIsomorphicLayoutEffect(() => {
|
|
30451
|
-
sensorContext.current = {
|
|
30452
|
-
activatorEvent,
|
|
30453
|
-
active,
|
|
30454
|
-
activeNode,
|
|
30455
|
-
collisionRect,
|
|
30456
|
-
collisions,
|
|
30457
|
-
droppableRects,
|
|
30458
|
-
draggableNodes,
|
|
30459
|
-
draggingNode,
|
|
30460
|
-
draggingNodeRect,
|
|
30461
|
-
droppableContainers,
|
|
30462
|
-
over,
|
|
30463
|
-
scrollableAncestors,
|
|
30464
|
-
scrollAdjustedTranslate
|
|
30465
|
-
};
|
|
30466
|
-
activeRects.current = {
|
|
30467
|
-
initial: draggingNodeRect,
|
|
30468
|
-
translated: collisionRect
|
|
30469
|
-
};
|
|
30470
|
-
}, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
|
|
30471
|
-
useAutoScroller({ ...autoScrollOptions,
|
|
30472
|
-
delta: translate,
|
|
30473
|
-
draggingRect: collisionRect,
|
|
30474
|
-
pointerCoordinates,
|
|
30475
|
-
scrollableAncestors,
|
|
30476
|
-
scrollableAncestorRects
|
|
30477
|
-
});
|
|
30478
|
-
const publicContext = useMemo(() => {
|
|
30479
|
-
const context = {
|
|
30480
|
-
active,
|
|
30481
|
-
activeNode,
|
|
30482
|
-
activeNodeRect,
|
|
30483
|
-
activatorEvent,
|
|
30484
|
-
collisions,
|
|
30485
|
-
containerNodeRect,
|
|
30486
|
-
dragOverlay,
|
|
30487
|
-
draggableNodes,
|
|
30488
|
-
droppableContainers,
|
|
30489
|
-
droppableRects,
|
|
30490
|
-
over,
|
|
30491
|
-
measureDroppableContainers,
|
|
30492
|
-
scrollableAncestors,
|
|
30493
|
-
scrollableAncestorRects,
|
|
30494
|
-
measuringConfiguration,
|
|
30495
|
-
measuringScheduled,
|
|
30496
|
-
windowRect
|
|
30497
|
-
};
|
|
30498
|
-
return context;
|
|
30499
|
-
}, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
|
|
30500
|
-
const internalContext = useMemo(() => {
|
|
30501
|
-
const context = {
|
|
30502
|
-
activatorEvent,
|
|
30503
|
-
activators,
|
|
30504
|
-
active,
|
|
30505
|
-
activeNodeRect,
|
|
30506
|
-
ariaDescribedById: {
|
|
30507
|
-
draggable: draggableDescribedById
|
|
30508
|
-
},
|
|
30509
|
-
dispatch,
|
|
30510
|
-
draggableNodes,
|
|
30511
|
-
over,
|
|
30512
|
-
measureDroppableContainers
|
|
30513
|
-
};
|
|
30514
|
-
return context;
|
|
30515
|
-
}, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
|
|
30516
|
-
return React__default.createElement(DndMonitorContext.Provider, {
|
|
30517
|
-
value: registerMonitorListener
|
|
30518
|
-
}, React__default.createElement(InternalContext.Provider, {
|
|
30519
|
-
value: internalContext
|
|
30520
|
-
}, React__default.createElement(PublicContext.Provider, {
|
|
30521
|
-
value: publicContext
|
|
30522
|
-
}, React__default.createElement(ActiveDraggableContext.Provider, {
|
|
30523
|
-
value: transform
|
|
30524
|
-
}, children)), React__default.createElement(RestoreFocus, {
|
|
30525
|
-
disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
|
|
30526
|
-
})), React__default.createElement(Accessibility, { ...accessibility,
|
|
30527
|
-
hiddenTextDescribedById: draggableDescribedById
|
|
30528
|
-
}));
|
|
30529
|
-
|
|
30530
|
-
function getAutoScrollerOptions() {
|
|
30531
|
-
const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
|
|
30532
|
-
const autoScrollGloballyDisabled = typeof autoScroll === 'object' ? autoScroll.enabled === false : autoScroll === false;
|
|
30533
|
-
const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
|
|
30534
|
-
|
|
30535
|
-
if (typeof autoScroll === 'object') {
|
|
30536
|
-
return { ...autoScroll,
|
|
30537
|
-
enabled
|
|
30538
|
-
};
|
|
30539
|
-
}
|
|
30540
|
-
|
|
30541
|
-
return {
|
|
30542
|
-
enabled
|
|
30543
|
-
};
|
|
30544
|
-
}
|
|
30545
|
-
});
|
|
30546
|
-
|
|
30547
|
-
const EditGridWrapper = (props) => {
|
|
30548
|
-
const notifications = useNotifications();
|
|
30549
|
-
const baseGridRef = useRef(null);
|
|
30550
|
-
// ======================|| EDIT ||====================== //
|
|
30551
|
-
const [edit, setEdit] = useState(false);
|
|
30552
|
-
const [editMutation, { isLoading: loadingMutation }] = props.mutation();
|
|
30553
|
-
const [errors, setErrors] = useState({});
|
|
30554
|
-
const [rowModesModel, setRowModesModel] = useState({});
|
|
30555
|
-
const handleCancelarEdit = () => {
|
|
30556
|
-
setRowModesModel({});
|
|
30557
|
-
};
|
|
30558
|
-
const handleClickEdit = () => {
|
|
30559
|
-
if (edit)
|
|
30560
|
-
handleCancelarEdit();
|
|
30561
|
-
setEdit(prevState => !prevState);
|
|
30562
|
-
};
|
|
30563
|
-
const processRowUpdate = async (newRow, originalRow) => {
|
|
30564
|
-
const original_data = jsonForm({ submitData: originalRow });
|
|
30565
|
-
const data = jsonForm({ submitData: newRow, ...(props.parser ? { props: props.parser } : []) });
|
|
30566
|
-
if (isEqual$1(data, original_data))
|
|
30567
|
-
return originalRow;
|
|
30568
|
-
try {
|
|
30569
|
-
const result = await editMutation(data).unwrap();
|
|
30570
|
-
setErrors(prevState => produce(prevState, draft => {
|
|
30571
|
-
delete draft[newRow.id];
|
|
30572
|
-
}));
|
|
30573
|
-
if (props?.postAction)
|
|
30574
|
-
props.postAction(result);
|
|
30575
|
-
notifications.show(`Información actualizada!`, { severity: 'success' });
|
|
30576
|
-
return result.list;
|
|
30577
|
-
}
|
|
30578
|
-
catch (e) {
|
|
30579
|
-
setErrors(prevState => produce(prevState, draft => {
|
|
30580
|
-
draft[newRow.id] = get(e, 'data');
|
|
30581
|
-
}));
|
|
30582
|
-
notifications.show('Error actualizando información!', { severity: 'error' });
|
|
30583
|
-
}
|
|
30584
|
-
};
|
|
30585
|
-
// ===== || KEYDOWN || ===== //
|
|
30586
|
-
const handleKeyPress = useCallback((event) => {
|
|
30587
|
-
if (props.permission) {
|
|
30588
|
-
if (event.ctrlKey && event.shiftKey && event.key === 'E') {
|
|
30589
|
-
event.preventDefault();
|
|
30590
|
-
setEdit(true);
|
|
30591
|
-
}
|
|
30592
|
-
else if (event.key === 'Escape' && event.shiftKey && edit) {
|
|
30593
|
-
event.preventDefault();
|
|
30594
|
-
handleCancelarEdit();
|
|
30595
|
-
setEdit(false);
|
|
30596
|
-
}
|
|
30597
|
-
}
|
|
30598
|
-
}, [edit, props.permission]);
|
|
30599
|
-
useEffect(() => {
|
|
30600
|
-
document.addEventListener('keydown', handleKeyPress);
|
|
30601
|
-
return () => {
|
|
30602
|
-
document.removeEventListener('keydown', handleKeyPress);
|
|
30603
|
-
};
|
|
30604
|
-
}, [handleKeyPress]);
|
|
30605
|
-
// ========================= || DRAG N DROP || ========================= //
|
|
30606
|
-
const rowsIterator = baseGridRef?.current?.getApi()?.getRowModels()?.values();
|
|
30607
|
-
const rows = useMemo(() => {
|
|
30608
|
-
return rowsIterator ? Array.from(rowsIterator) : [];
|
|
30609
|
-
}, [rowsIterator]);
|
|
30610
|
-
const sensors = useSensors(useSensor(PointerSensor));
|
|
30611
|
-
const handleDragEnd = useCallback((event) => {
|
|
30612
|
-
const field = props.dnd?.field;
|
|
30613
|
-
if (!field)
|
|
30614
|
-
return;
|
|
30615
|
-
const { active, over } = event;
|
|
30616
|
-
if (over) {
|
|
30617
|
-
const activeRow = rows.find((row) => row.id === active.id);
|
|
30618
|
-
const overRow = rows.find((row) => row.id === over.id);
|
|
30619
|
-
const mutationArgs = { ...props.dnd?.args, id: activeRow.id };
|
|
30620
|
-
mutationArgs[field] = get(overRow, field);
|
|
30621
|
-
editMutation(mutationArgs);
|
|
30622
|
-
}
|
|
30623
|
-
}, [editMutation, props.dnd, rows]);
|
|
30624
|
-
// ===== || GRID PROPS || ===== //
|
|
30625
|
-
const editGridProps = mergeSettings({
|
|
30626
|
-
columns: props.columns({
|
|
30627
|
-
displayEdit: edit && props.permission,
|
|
30628
|
-
rowModesModel: rowModesModel,
|
|
30629
|
-
setRowModesModel: setRowModesModel,
|
|
30630
|
-
mutationErrors: errors,
|
|
30631
|
-
options: props.options,
|
|
30632
|
-
}),
|
|
30633
|
-
...(edit && props.dnd ? { slots: { row: DraggableRow } } : []),
|
|
30634
|
-
slotProps: {
|
|
30635
|
-
toolbar: {
|
|
30636
|
-
extraButtons: [
|
|
30637
|
-
...(props.permission && !props.disabled ? [{
|
|
30638
|
-
label: edit ? 'Cancelar' : 'Editar',
|
|
30639
|
-
icon: edit ? CancelIcon : EditIcon,
|
|
30640
|
-
onClick: handleClickEdit,
|
|
30641
|
-
}] : []),
|
|
30642
|
-
]
|
|
30643
|
-
}
|
|
30644
|
-
},
|
|
30645
|
-
onRowEditStart: ({ reason, row }, event) => {
|
|
30646
|
-
if (!get(row, `obj_permissions.edit`) || (reason === GridRowEditStartReasons.cellDoubleClick && !edit)) {
|
|
30647
|
-
event.defaultMuiPrevented = true;
|
|
30648
|
-
}
|
|
30649
|
-
},
|
|
30650
|
-
// edit
|
|
30651
|
-
checkboxSelection: !edit,
|
|
30652
|
-
...(edit ? { onRowClick: undefined } : []),
|
|
30653
|
-
editMode: 'row',
|
|
30654
|
-
rowModesModel: rowModesModel,
|
|
30655
|
-
onRowModesModelChange: setRowModesModel,
|
|
30656
|
-
processRowUpdate: processRowUpdate,
|
|
30657
|
-
loadingParams: [loadingMutation],
|
|
30658
|
-
}, props.dataGridProps);
|
|
30659
|
-
const renderEditGrid = () => (jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, modifiers: [
|
|
30660
|
-
restrictToVerticalAxis,
|
|
30661
|
-
restrictToWindowEdges,
|
|
30662
|
-
restrictToParentElement
|
|
30663
|
-
], autoScroll: false, children: jsx(SortableContext, { items: rows ? rows.map((row) => row.id) : [], strategy: verticalListSortingStrategy, children: props.renderFunction({ ...props.renderFunctionProps, dataGridProps: editGridProps }) }) }));
|
|
30664
|
-
return renderEditGrid();
|
|
30665
|
-
};
|
|
30666
|
-
|
|
30667
|
-
const editColumn = (props) => {
|
|
30668
|
-
if (!props)
|
|
30669
|
-
return [];
|
|
30670
|
-
if (!props.displayEdit)
|
|
30671
|
-
return [];
|
|
30672
|
-
const handleEditClick = (id) => () => {
|
|
30673
|
-
props.setRowModesModel({ ...props.rowModesModel, [id]: { mode: GridRowModes.Edit } });
|
|
30674
|
-
};
|
|
30675
|
-
const handleSaveClick = (id) => () => {
|
|
30676
|
-
props.setRowModesModel({ ...props.rowModesModel, [id]: { mode: GridRowModes.View } });
|
|
30677
|
-
};
|
|
30678
|
-
const handleCancelClick = (id) => () => {
|
|
30679
|
-
props.setRowModesModel({
|
|
30680
|
-
...props.rowModesModel,
|
|
30681
|
-
[id]: { mode: GridRowModes.View, ignoreModifications: true },
|
|
30682
|
-
});
|
|
30683
|
-
};
|
|
30684
|
-
return [{
|
|
30685
|
-
field: 'edit',
|
|
30686
|
-
headerName: 'Editar',
|
|
30687
|
-
type: 'actions',
|
|
30688
|
-
width: 80,
|
|
30689
|
-
cellClassName: 'actions',
|
|
30690
|
-
getActions: ({ id, row }) => {
|
|
30691
|
-
const canEdit = get$1(row, 'obj_permissions.edit');
|
|
30692
|
-
const isInEditMode = props.rowModesModel[id]?.mode === GridRowModes.Edit;
|
|
30693
|
-
if (isInEditMode) {
|
|
30694
|
-
return [
|
|
30695
|
-
jsx(GridActionsCellItem, { icon: jsx(SaveIcon, {}), label: 'Guardar', color: 'primary', onClick: handleSaveClick(id) }, 'save'),
|
|
30696
|
-
jsx(GridActionsCellItem, { icon: jsx(CancelIcon, {}), label: 'Cancelar', className: 'textPrimary', onClick: handleCancelClick(id), color: 'inherit' }, 'cancel'),
|
|
30697
|
-
];
|
|
30698
|
-
}
|
|
30699
|
-
return [
|
|
30700
|
-
jsx(GridActionsCellItem, { icon: jsx(EditIcon, { sx: { color: canEdit ? 'black' : 'inherit' } }), label: 'Editar', className: 'textPrimary', onClick: handleEditClick(id), disabled: !canEdit }, 'edit'),
|
|
30701
|
-
];
|
|
30702
|
-
}
|
|
30703
|
-
}];
|
|
30704
|
-
};
|
|
30705
|
-
|
|
30706
|
-
const deleteColumn = (props) => {
|
|
30707
|
-
if (!props.displayDelete)
|
|
30708
|
-
return [];
|
|
30709
|
-
return [{
|
|
30710
|
-
field: 'delete',
|
|
30711
|
-
headerName: 'Eliminar',
|
|
30712
|
-
width: 80,
|
|
30713
|
-
cellClassName: 'actions',
|
|
30714
|
-
renderCell: ({ id, row }) => {
|
|
30715
|
-
const canDelete = get$1(row, `obj_permissions.delete`, false);
|
|
30716
|
-
return [
|
|
30717
|
-
jsx(GridActionsCellItem, { icon: jsx(DeleteIcon, {}), label: 'Eliminar', className: 'textPrimary', onClick: props.handleOpen(id), color: 'primary', disabled: !canDelete }, 'delete')
|
|
30718
|
-
];
|
|
30719
|
-
}
|
|
30720
|
-
}];
|
|
27430
|
+
const deleteColumn = (props) => {
|
|
27431
|
+
if (!props.displayDelete)
|
|
27432
|
+
return [];
|
|
27433
|
+
return [{
|
|
27434
|
+
field: 'delete',
|
|
27435
|
+
headerName: 'Eliminar',
|
|
27436
|
+
width: 80,
|
|
27437
|
+
cellClassName: 'actions',
|
|
27438
|
+
renderCell: ({ id, row }) => {
|
|
27439
|
+
const canDelete = get$1(row, `obj_permissions.delete`, false);
|
|
27440
|
+
return [
|
|
27441
|
+
jsx(GridActionsCellItem, { icon: jsx(DeleteIcon, {}), label: 'Eliminar', className: 'textPrimary', onClick: props.handleOpen(id), color: 'primary', disabled: !canDelete }, 'delete')
|
|
27442
|
+
];
|
|
27443
|
+
}
|
|
27444
|
+
}];
|
|
30721
27445
|
};
|
|
30722
27446
|
|
|
30723
27447
|
const DeleteGridWrapper = (props) => {
|
|
@@ -30969,6 +27693,11 @@ const Base = (props) => {
|
|
|
30969
27693
|
const dataGridProps = mergeSettings({
|
|
30970
27694
|
columns: [],
|
|
30971
27695
|
loadingParams: [isLoading, isFetching],
|
|
27696
|
+
slots: {
|
|
27697
|
+
toolbar: CustomToolbar,
|
|
27698
|
+
pagination: CustomPagination,
|
|
27699
|
+
noRowsOverlay: CustomNoRows,
|
|
27700
|
+
},
|
|
30972
27701
|
slotProps: {
|
|
30973
27702
|
baseCheckbox: {
|
|
30974
27703
|
size: 'small'
|
|
@@ -30997,15 +27726,12 @@ const Base = (props) => {
|
|
|
30997
27726
|
},
|
|
30998
27727
|
}, props.dataGridProps);
|
|
30999
27728
|
const renderDataGrid = ({ dataGridProps: renderDataGridProps }) => {
|
|
27729
|
+
// console.log(dataGridProps)
|
|
31000
27730
|
return (jsx(Box, { width: 1, minHeight: 300, height: 1,
|
|
31001
27731
|
// maxHeight={'calc(100% - 30px)'}
|
|
31002
|
-
display: 'flex', flexDirection: 'column', pb: 0, children: jsx(NoSsr, { children: jsx(DataGrid, { apiRef: apiRef,
|
|
27732
|
+
display: 'flex', flexDirection: 'column', pb: 0, children: jsx(NoSsr, { children: jsx(DataGrid, { apiRef: apiRef, rows: data?.results || [], loading: some(get(renderDataGridProps, 'loadingParams', []), function (x) {
|
|
31003
27733
|
return x;
|
|
31004
|
-
}),
|
|
31005
|
-
toolbar: CustomToolbar,
|
|
31006
|
-
pagination: CustomPagination,
|
|
31007
|
-
noRowsOverlay: CustomNoRows,
|
|
31008
|
-
},
|
|
27734
|
+
}),
|
|
31009
27735
|
// paginado //
|
|
31010
27736
|
pagination: true, paginationMode: 'server', paginationModel: paginationModel, onPaginationModelChange: setPaginationModel, pageSizeOptions: [50, 100, { value: -1, label: 'Todos' }],
|
|
31011
27737
|
// ordenado
|
|
@@ -31029,7 +27755,7 @@ const Base = (props) => {
|
|
|
31029
27755
|
// row count
|
|
31030
27756
|
rowCount: rowCount,
|
|
31031
27757
|
// settings
|
|
31032
|
-
|
|
27758
|
+
density: 'compact',
|
|
31033
27759
|
// striping
|
|
31034
27760
|
getRowClassName: (params) => params.indexRelativeToCurrentPage % 2 === 0 ? 'even' : 'odd', localeText: {
|
|
31035
27761
|
columnHeaderSortIconLabel: 'Ordenar',
|
|
@@ -31058,6 +27784,7 @@ const Base = (props) => {
|
|
|
31058
27784
|
renderFunction: renderFunction,
|
|
31059
27785
|
renderFunctionProps: renderProps,
|
|
31060
27786
|
dataGridProps: dataGridProps,
|
|
27787
|
+
baseGridRef: apiRef,
|
|
31061
27788
|
...props.api.edit
|
|
31062
27789
|
};
|
|
31063
27790
|
renderFunction = EditGridWrapper;
|