@bigbinary/neeto-fields-frontend 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/DeleteAlert-b92f7c05.js +763 -0
  2. package/dist/DeleteAlert-b92f7c05.js.map +1 -0
  3. package/dist/DeleteAlert-fbc41b31.js +780 -0
  4. package/dist/DeleteAlert-fbc41b31.js.map +1 -0
  5. package/dist/FieldDeleteAlert.js +22 -0
  6. package/dist/FieldDeleteAlert.js.map +1 -0
  7. package/dist/FieldInputs.js +58 -0
  8. package/dist/FieldInputs.js.map +1 -0
  9. package/dist/FieldValueInputWrapper-adbbc915.js +198 -0
  10. package/dist/FieldValueInputWrapper-adbbc915.js.map +1 -0
  11. package/dist/FieldValueInputWrapper-f1f2e095.js +189 -0
  12. package/dist/FieldValueInputWrapper-f1f2e095.js.map +1 -0
  13. package/dist/FieldValuesContainer.js +223 -0
  14. package/dist/FieldValuesContainer.js.map +1 -0
  15. package/dist/FieldsDashboard.js +5000 -0
  16. package/dist/FieldsDashboard.js.map +1 -0
  17. package/dist/FieldsPane.js +563 -0
  18. package/dist/FieldsPane.js.map +1 -0
  19. package/dist/InlineFieldValueInput.js +157 -0
  20. package/dist/InlineFieldValueInput.js.map +1 -0
  21. package/dist/_commonjsHelpers-1789f0cf.js +8 -0
  22. package/dist/_commonjsHelpers-1789f0cf.js.map +1 -0
  23. package/dist/_commonjsHelpers-b3309d7b.js +11 -0
  24. package/dist/_commonjsHelpers-b3309d7b.js.map +1 -0
  25. package/dist/cjs/FieldDeleteAlert.js +28 -0
  26. package/dist/cjs/FieldDeleteAlert.js.map +1 -0
  27. package/dist/cjs/FieldInputs.js +64 -0
  28. package/dist/cjs/FieldInputs.js.map +1 -0
  29. package/dist/cjs/FieldValuesContainer.js +232 -0
  30. package/dist/cjs/FieldValuesContainer.js.map +1 -0
  31. package/dist/{index.cjs.js → cjs/FieldsDashboard.js} +120 -3427
  32. package/dist/cjs/FieldsDashboard.js.map +1 -0
  33. package/dist/cjs/FieldsPane.js +598 -0
  34. package/dist/cjs/FieldsPane.js.map +1 -0
  35. package/dist/cjs/InlineFieldValueInput.js +164 -0
  36. package/dist/cjs/InlineFieldValueInput.js.map +1 -0
  37. package/dist/cjs/hooks.js +20 -0
  38. package/dist/cjs/hooks.js.map +1 -0
  39. package/dist/cjs/index.js +84 -0
  40. package/dist/cjs/index.js.map +1 -0
  41. package/dist/cjs/utils.js +34 -0
  42. package/dist/cjs/utils.js.map +1 -0
  43. package/dist/constants-0e6017ea.js +57 -0
  44. package/dist/constants-0e6017ea.js.map +1 -0
  45. package/dist/constants-c71008a3.js +64 -0
  46. package/dist/constants-c71008a3.js.map +1 -0
  47. package/dist/hooks.js +8 -0
  48. package/dist/hooks.js.map +1 -0
  49. package/dist/index-265f7913.js +117 -0
  50. package/dist/index-265f7913.js.map +1 -0
  51. package/dist/index-27e54c2c.js +130 -0
  52. package/dist/index-27e54c2c.js.map +1 -0
  53. package/dist/index.js +64 -8255
  54. package/dist/index.js.map +1 -1
  55. package/dist/query-0df5b2dd.js +13 -0
  56. package/dist/query-0df5b2dd.js.map +1 -0
  57. package/dist/query-1a62b3ac.js +10 -0
  58. package/dist/query-1a62b3ac.js.map +1 -0
  59. package/dist/slicedToArray-50f7cc19.js +46 -0
  60. package/dist/slicedToArray-50f7cc19.js.map +1 -0
  61. package/dist/slicedToArray-6198349b.js +44 -0
  62. package/dist/slicedToArray-6198349b.js.map +1 -0
  63. package/dist/useFieldsApi-14928ecf.js +161 -0
  64. package/dist/useFieldsApi-14928ecf.js.map +1 -0
  65. package/dist/useFieldsApi-5c114bac.js +149 -0
  66. package/dist/useFieldsApi-5c114bac.js.map +1 -0
  67. package/dist/utils-4812fc6c.js +1140 -0
  68. package/dist/utils-4812fc6c.js.map +1 -0
  69. package/dist/utils-85ed1903.js +1180 -0
  70. package/dist/utils-85ed1903.js.map +1 -0
  71. package/dist/utils.js +26 -0
  72. package/dist/utils.js.map +1 -0
  73. package/package.json +27 -13
  74. package/dist/index.cjs.js.map +0 -1
@@ -0,0 +1,5000 @@
1
+ import { C as CONFIGS_URL, _ as _defineProperty, a as _objectWithoutProperties } from './index-265f7913.js';
2
+ import { capitalize, isPresent } from '@bigbinary/neeto-cist';
3
+ import { DEFAULT_PAGE_INDEX, DEFAULT_PAGE_SIZE, PLURAL } from '@bigbinary/neeto-commons-frontend/constants';
4
+ import Container from '@bigbinary/neeto-molecules/Container';
5
+ import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
6
+ import { isNil, any, isEmpty } from 'ramda';
7
+ import { useTranslation } from 'react-i18next';
8
+ import FieldsPane from './FieldsPane.js';
9
+ import { _ as _slicedToArray } from './slicedToArray-6198349b.js';
10
+ import React, { useState, useMemo, useEffect, useLayoutEffect, useRef, useCallback, createContext, memo, useReducer, useContext, createElement } from 'react';
11
+ import { useQuery, keepPreviousData } from '@tanstack/react-query';
12
+ import { useQueryParams, handleMetaClick, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
13
+ import { buildUrl, getQueryParams } from '@bigbinary/neeto-commons-frontend/utils';
14
+ import { buildFiltersFromURL, Bar } from '@bigbinary/neeto-filters-frontend';
15
+ import { useHistory } from 'react-router-dom';
16
+ import { F as FIELD_STATES, A as ALL_KINDS, D as DEFAULT_FIELD_STATE_TAXONOMY } from './constants-0e6017ea.js';
17
+ import { b as buildDefaultColumns, g as getResourceName, a as getDashBoardTitle, r as renderStateFilterTabs, c as renderMenuBarItems, d as renderNoDataHelpText, D as DeleteAlert } from './DeleteAlert-b92f7c05.js';
18
+ import axios from 'axios';
19
+ import { Q as QUERY_KEYS, D as DEFAULT_STALE_TIME } from './query-1a62b3ac.js';
20
+ import { u as useFetchFields, a as useDestroyField, b as useReorderFields } from './useFieldsApi-5c114bac.js';
21
+ import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
22
+ import NoData from '@bigbinary/neetoui/NoData';
23
+ import Table from '@bigbinary/neetoui/Table';
24
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
25
+ import NeetoUIHeader from '@bigbinary/neeto-molecules/Header';
26
+ import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
27
+ import Button from '@bigbinary/neetoui/Button';
28
+ import MenuBar from '@bigbinary/neeto-molecules/MenuBar';
29
+ import { unstable_batchedUpdates, createPortal } from 'react-dom';
30
+ import Pane from '@bigbinary/neetoui/Pane';
31
+ import Typography from '@bigbinary/neetoui/Typography';
32
+ import classnames from 'classnames';
33
+ import NeetoUISubHeader from '@bigbinary/neeto-molecules/SubHeader';
34
+ import '@bigbinary/neetoui/formik/Form';
35
+ import 'i18next';
36
+ import 'yup';
37
+ import '@bigbinary/neetoui/formik/ActionBlock';
38
+ import 'uuid';
39
+ import 'formik';
40
+ import '@bigbinary/neetoui/Label';
41
+ import '@bigbinary/neetoui/formik/Input';
42
+ import '@bigbinary/neetoui/formik/Select';
43
+ import '@bigbinary/neetoui/formik/Switch';
44
+ import '@bigbinary/neeto-icons/Delete';
45
+ import '@bigbinary/neetoui/Alert';
46
+ import '@bigbinary/neeto-molecules/MoreDropdown';
47
+ import '@bigbinary/neetoui/Tab';
48
+ import './_commonjsHelpers-1789f0cf.js';
49
+
50
+ var fetchConfigs = function fetchConfigs() {
51
+ return axios.get(CONFIGS_URL);
52
+ };
53
+ var configsApi = {
54
+ fetchConfigs: fetchConfigs
55
+ };
56
+
57
+ function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
58
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
59
+ var useFetchConfigs = function useFetchConfigs(options) {
60
+ return useQuery(_objectSpread$6({
61
+ queryKey: [QUERY_KEYS.CONFIGS],
62
+ queryFn: configsApi.fetchConfigs,
63
+ staleTime: DEFAULT_STALE_TIME
64
+ }, options));
65
+ };
66
+
67
+ function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
68
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
69
+ var useFieldsDashboard = function useFieldsDashboard(_ref) {
70
+ var buildColumnData = _ref.buildColumnData,
71
+ isOwnerBased = _ref.isOwnerBased,
72
+ fieldStatesTaxonomy = _ref.fieldStatesTaxonomy,
73
+ nameAliases = _ref.nameAliases,
74
+ title = _ref.title,
75
+ resources = _ref.resources,
76
+ showStateFilter = _ref.showStateFilter;
77
+ var _useState = useState(false),
78
+ _useState2 = _slicedToArray(_useState, 2),
79
+ isPaneOpen = _useState2[0],
80
+ setIsPaneOpen = _useState2[1];
81
+ var _useState3 = useState(false),
82
+ _useState4 = _slicedToArray(_useState3, 2),
83
+ isDeleteAlertOpen = _useState4[0],
84
+ setIsDeleteAlertOpen = _useState4[1];
85
+ var _useState5 = useState(false),
86
+ _useState6 = _slicedToArray(_useState5, 2),
87
+ isReorderPaneOpen = _useState6[0],
88
+ setIsReorderPaneOpen = _useState6[1];
89
+ var _useState7 = useState({}),
90
+ _useState8 = _slicedToArray(_useState7, 2),
91
+ selectedField = _useState8[0],
92
+ setSelectedField = _useState8[1];
93
+ var _useState9 = useState({
94
+ page: DEFAULT_PAGE_INDEX,
95
+ pageSize: DEFAULT_PAGE_SIZE
96
+ }),
97
+ _useState10 = _slicedToArray(_useState9, 2),
98
+ pageProps = _useState10[0],
99
+ setPageProps = _useState10[1];
100
+ var _useQueryParams = useQueryParams(),
101
+ searchTerm = _useQueryParams.searchTerm,
102
+ resource = _useQueryParams.resource,
103
+ state = _useQueryParams.state;
104
+ var history = useHistory();
105
+ var _useTranslation = useTranslation(),
106
+ t = _useTranslation.t;
107
+ var searchKeywordProps = {
108
+ key: "search_term",
109
+ node: "name",
110
+ value: searchTerm
111
+ };
112
+ var ownerId = isOwnerBased ? resource : undefined;
113
+ var _useFetchConfigs = useFetchConfigs({
114
+ enabled: !resources
115
+ }),
116
+ _useFetchConfigs$data = _useFetchConfigs.data,
117
+ _useFetchConfigs$data2 = _useFetchConfigs$data === void 0 ? {} : _useFetchConfigs$data,
118
+ _useFetchConfigs$data3 = _useFetchConfigs$data2.owners,
119
+ owners = _useFetchConfigs$data3 === void 0 ? [] : _useFetchConfigs$data3,
120
+ _useFetchConfigs$data4 = _useFetchConfigs$data2.resourceTypes,
121
+ resourceTypes = _useFetchConfigs$data4 === void 0 ? [] : _useFetchConfigs$data4,
122
+ isConfigsLoading = _useFetchConfigs.isLoading;
123
+ var filters = useMemo(function () {
124
+ return buildFiltersFromURL([searchKeywordProps]);
125
+ }, [searchTerm]);
126
+ var fieldParams = {
127
+ resourceType: !isOwnerBased ? resource : undefined,
128
+ ownerId: ownerId,
129
+ state: state || FIELD_STATES.active,
130
+ pageProps: pageProps,
131
+ filters: filters
132
+ };
133
+ var _useFetchFields = useFetchFields(fieldParams, {
134
+ enabled: !!resource,
135
+ placeholderData: keepPreviousData
136
+ }),
137
+ _useFetchFields$data = _useFetchFields.data,
138
+ _useFetchFields$data2 = _useFetchFields$data === void 0 ? {} : _useFetchFields$data,
139
+ _useFetchFields$data3 = _useFetchFields$data2.fields,
140
+ fields = _useFetchFields$data3 === void 0 ? [] : _useFetchFields$data3,
141
+ count = _useFetchFields$data2.count,
142
+ activeFieldsCount = _useFetchFields$data2.activeFieldsCount,
143
+ inactiveFieldsCount = _useFetchFields$data2.inactiveFieldsCount,
144
+ reorderable = _useFetchFields$data2.reorderable,
145
+ isFieldsLoading = _useFetchFields.isLoading,
146
+ isFieldsFetching = _useFetchFields.isFetching,
147
+ isFieldsFetched = _useFetchFields.isFetched;
148
+ var _useDestroyField = useDestroyField({
149
+ onSuccess: function onSuccess() {
150
+ setIsDeleteAlertOpen(false);
151
+ setSelectedField({});
152
+ }
153
+ }),
154
+ deleteField = _useDestroyField.mutate,
155
+ isDeleting = _useDestroyField.isPending;
156
+ var handleDelete = function handleDelete() {
157
+ deleteField({
158
+ fieldId: selectedField.id,
159
+ ownerId: ownerId
160
+ });
161
+ };
162
+ var handleClosePane = function handleClosePane() {
163
+ setIsPaneOpen(false);
164
+ setSelectedField({});
165
+ };
166
+ var handleEditButtonClick = function handleEditButtonClick(field) {
167
+ setSelectedField(field);
168
+ setIsPaneOpen(true);
169
+ };
170
+ var handleDeleteButtonClick = function handleDeleteButtonClick(field) {
171
+ setSelectedField(field);
172
+ setIsDeleteAlertOpen(true);
173
+ };
174
+ var handleAlertClose = function handleAlertClose() {
175
+ setIsDeleteAlertOpen(false);
176
+ setSelectedField({});
177
+ };
178
+ var handleReorderPaneClose = function handleReorderPaneClose() {
179
+ setIsReorderPaneOpen(false);
180
+ };
181
+ var defaultColumns = buildDefaultColumns({
182
+ onDeleteClick: handleDeleteButtonClick,
183
+ onEditClick: handleEditButtonClick
184
+ });
185
+ var columnData = buildColumnData({
186
+ onEditClick: handleEditButtonClick,
187
+ onDeleteClick: handleDeleteButtonClick,
188
+ defaultColumns: defaultColumns
189
+ });
190
+ var handleBlockClick = function handleBlockClick(params) {
191
+ return handleMetaClick(history, buildUrl("", _objectSpread$5({
192
+ resource: resource,
193
+ state: state
194
+ }, params)));
195
+ };
196
+ var menuItems = resources || (isOwnerBased ? owners : resourceTypes);
197
+ var handleURLWithDefaultValues = function handleURLWithDefaultValues() {
198
+ var queryParams = {
199
+ resource: resource,
200
+ state: state
201
+ };
202
+ if (!isConfigsLoading && isNil(resource)) {
203
+ var _menuItems$, _menuItems$2;
204
+ queryParams.resource = isOwnerBased ? menuItems === null || menuItems === void 0 || (_menuItems$ = menuItems[0]) === null || _menuItems$ === void 0 ? void 0 : _menuItems$.id : menuItems === null || menuItems === void 0 || (_menuItems$2 = menuItems[0]) === null || _menuItems$2 === void 0 ? void 0 : _menuItems$2.value;
205
+ }
206
+ if (!isConfigsLoading && isNil(state)) {
207
+ queryParams.state = FIELD_STATES.active;
208
+ }
209
+ if (!isConfigsLoading && any(isNil)([resource, state])) {
210
+ history.replace(buildUrl("", queryParams));
211
+ }
212
+ };
213
+ var isScreenLoading = isFieldsLoading || isConfigsLoading;
214
+ var showCountSubheader = count > 0 && !showStateFilter;
215
+ var searchInputProps = {
216
+ placeholder: t("neetoFields.placeholders.searchFields"),
217
+ className: "w-44"
218
+ };
219
+ var isSingleResource = menuItems.length === 1;
220
+ var isMenuBarNeeded = !isSingleResource && !isConfigsLoading;
221
+ var isSearchBarNeeded = state === FIELD_STATES.active ? activeFieldsCount > 0 : inactiveFieldsCount > 0;
222
+ var resourceName = useMemo(function () {
223
+ return getResourceName({
224
+ isOwnerBased: isOwnerBased,
225
+ nameAliases: nameAliases,
226
+ menuItems: menuItems,
227
+ selectedVal: resource
228
+ });
229
+ }, [menuItems, resource]);
230
+ var headerDisplayTitle = useMemo(function () {
231
+ return getDashBoardTitle({
232
+ resourceName: resourceName,
233
+ isSingleResource: isSingleResource,
234
+ title: title
235
+ });
236
+ }, [state, isSingleResource, resourceName]);
237
+ var stateFilterTabs = useMemo(function () {
238
+ return renderStateFilterTabs({
239
+ selectedState: state,
240
+ fieldStatesTaxonomy: fieldStatesTaxonomy,
241
+ activeFieldsCount: activeFieldsCount,
242
+ inactiveFieldsCount: inactiveFieldsCount,
243
+ handleBlockClick: handleBlockClick
244
+ });
245
+ }, [activeFieldsCount, inactiveFieldsCount, state]);
246
+ var menuBarItems = useMemo(function () {
247
+ return renderMenuBarItems({
248
+ isOwnerBased: isOwnerBased,
249
+ items: menuItems,
250
+ selectedMenu: resource,
251
+ handleBlockClick: handleBlockClick,
252
+ nameAliases: nameAliases,
253
+ title: title
254
+ });
255
+ }, [menuItems, resource]);
256
+ useEffect(function () {
257
+ handleURLWithDefaultValues();
258
+ }, [isConfigsLoading, resources, resource, state]);
259
+ useEffect(function () {
260
+ setPageProps({
261
+ page: DEFAULT_PAGE_INDEX,
262
+ pageSize: DEFAULT_PAGE_SIZE
263
+ });
264
+ }, [searchTerm, state, resource]);
265
+ return {
266
+ isPaneOpen: isPaneOpen,
267
+ setIsPaneOpen: setIsPaneOpen,
268
+ isDeleteAlertOpen: isDeleteAlertOpen,
269
+ isReorderPaneOpen: isReorderPaneOpen,
270
+ setIsReorderPaneOpen: setIsReorderPaneOpen,
271
+ fields: fields,
272
+ count: count,
273
+ columnData: columnData,
274
+ selectedField: selectedField,
275
+ selectedMenu: resource,
276
+ // resource will be ownerId if showOwnersInMenu is true, else it will be resourceType
277
+ ownerId: ownerId,
278
+ isDeleting: isDeleting,
279
+ isFieldsFetching: isFieldsFetching,
280
+ isFieldsFetched: isFieldsFetched,
281
+ isScreenLoading: isScreenLoading,
282
+ isMenuBarNeeded: isMenuBarNeeded,
283
+ showCountSubheader: showCountSubheader,
284
+ handleDelete: handleDelete,
285
+ handleAlertClose: handleAlertClose,
286
+ handleClosePane: handleClosePane,
287
+ handleReorderPaneClose: handleReorderPaneClose,
288
+ searchInputProps: isSearchBarNeeded ? searchInputProps : null,
289
+ searchKeywordProps: searchKeywordProps,
290
+ stateFilterTabs: stateFilterTabs,
291
+ menuBarItems: menuBarItems,
292
+ reorderable: reorderable,
293
+ headerDisplayTitle: headerDisplayTitle,
294
+ pageProps: pageProps,
295
+ setPageProps: setPageProps
296
+ };
297
+ };
298
+
299
+ function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
300
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
301
+ var FieldsTable = function FieldsTable(_ref) {
302
+ var totalCount = _ref.totalCount,
303
+ isFetched = _ref.isFetched,
304
+ isFetching = _ref.isFetching,
305
+ rowData = _ref.rowData,
306
+ columnData = _ref.columnData,
307
+ setIsPaneOpen = _ref.setIsPaneOpen,
308
+ helpDocUrl = _ref.helpDocUrl,
309
+ title = _ref.title,
310
+ pageProps = _ref.pageProps,
311
+ setPageProps = _ref.setPageProps,
312
+ showStateFilter = _ref.showStateFilter;
313
+ var _useTranslation = useTranslation(),
314
+ t = _useTranslation.t;
315
+ var showNoDataScreen = isFetched && isEmpty(rowData);
316
+ var _getQueryParams = getQueryParams(),
317
+ state = _getQueryParams.state;
318
+ title = title.toLocaleLowerCase();
319
+ var page = pageProps.page,
320
+ pageSize = pageProps.pageSize;
321
+ var noDataProps = {};
322
+ if (!isFetched && isEmpty(rowData)) {
323
+ return /*#__PURE__*/jsx(PageLoader, {});
324
+ }
325
+ if (helpDocUrl) {
326
+ noDataProps.helpText = renderNoDataHelpText(title, helpDocUrl);
327
+ }
328
+ if (FIELD_STATES.active === state) {
329
+ noDataProps.primaryButtonProps = {
330
+ label: t("neetoFields.labels.addField"),
331
+ onClick: function onClick() {
332
+ return setIsPaneOpen(true);
333
+ }
334
+ };
335
+ }
336
+ return /*#__PURE__*/jsx(TableWrapper, {
337
+ children: showNoDataScreen ? /*#__PURE__*/jsx("div", {
338
+ className: "flex h-full w-full items-center justify-center",
339
+ children: /*#__PURE__*/jsx(NoData, _objectSpread$4({
340
+ title: showStateFilter ? t("neetoFields.messages.noFieldsWithState", {
341
+ title: title,
342
+ state: state
343
+ }) : t("neetoFields.messages.noFields", {
344
+ title: title
345
+ })
346
+ }, noDataProps))
347
+ }) : /*#__PURE__*/jsx(Table, {
348
+ columnData: columnData,
349
+ rowData: rowData,
350
+ totalCount: totalCount,
351
+ fixedHeight: true,
352
+ allowRowClick: false,
353
+ currentPageNumber: page,
354
+ defaultPageSize: pageSize,
355
+ handlePageChange: function handlePageChange(page) {
356
+ return setPageProps(_objectSpread$4(_objectSpread$4({}, pageProps), {}, {
357
+ page: page
358
+ }));
359
+ },
360
+ loading: isFetching
361
+ })
362
+ });
363
+ };
364
+
365
+ var ActionBlock = function ActionBlock(_ref) {
366
+ var reorderable = _ref.reorderable,
367
+ setIsReorderPaneOpen = _ref.setIsReorderPaneOpen,
368
+ setIsPaneOpen = _ref.setIsPaneOpen;
369
+ var _useTranslation = useTranslation(),
370
+ t = _useTranslation.t;
371
+ return /*#__PURE__*/jsxs("div", {
372
+ className: "flex flex-shrink-0 items-center gap-3",
373
+ children: [/*#__PURE__*/jsx(Button, {
374
+ "data-cy": "neeto-fields-reorder-button",
375
+ disabled: !reorderable,
376
+ label: t("neetoFields.labels.reorder"),
377
+ style: "secondary",
378
+ onClick: function onClick() {
379
+ return setIsReorderPaneOpen(true);
380
+ }
381
+ }), /*#__PURE__*/jsx(Button, {
382
+ "data-cy": "neeto-fields-add-button",
383
+ label: t("neetoFields.labels.addField"),
384
+ onClick: function onClick() {
385
+ return setIsPaneOpen(true);
386
+ }
387
+ })]
388
+ });
389
+ };
390
+
391
+ var _excluded$1 = ["searchInputProps", "breadcrumbs", "title", "helpDocUrl", "helpDescription", "size"];
392
+ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
393
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
394
+ var Header = withT(function (_ref) {
395
+ var searchInputProps = _ref.searchInputProps,
396
+ breadcrumbs = _ref.breadcrumbs,
397
+ title = _ref.title,
398
+ helpDocUrl = _ref.helpDocUrl,
399
+ helpDescription = _ref.helpDescription,
400
+ size = _ref.size,
401
+ actionBlockProps = _objectWithoutProperties(_ref, _excluded$1);
402
+ return /*#__PURE__*/jsx(NeetoUIHeader, {
403
+ breadcrumbs: breadcrumbs,
404
+ size: size,
405
+ actionBlock: /*#__PURE__*/jsx(ActionBlock, _objectSpread$3({}, actionBlockProps)),
406
+ searchProps: searchInputProps,
407
+ title: /*#__PURE__*/jsxs("span", {
408
+ children: [title, (helpDocUrl || helpDescription) && /*#__PURE__*/jsx(HelpPopover, _objectSpread$3(_objectSpread$3(_objectSpread$3({
409
+ className: "ml-2 self-center"
410
+ }, helpDocUrl && {
411
+ title: title
412
+ }), helpDescription && {
413
+ description: helpDescription
414
+ }), helpDocUrl && {
415
+ helpLinkProps: {
416
+ href: helpDocUrl
417
+ }
418
+ }))]
419
+ })
420
+ });
421
+ });
422
+
423
+ var Menubar = function Menubar(_ref) {
424
+ var menuBarItems = _ref.menuBarItems,
425
+ title = _ref.title;
426
+ return /*#__PURE__*/jsx(MenuBar, {
427
+ showMenu: true,
428
+ title: title,
429
+ children: menuBarItems
430
+ });
431
+ };
432
+
433
+ function useCombinedRefs() {
434
+ for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
435
+ refs[_key] = arguments[_key];
436
+ }
437
+
438
+ return useMemo(() => node => {
439
+ refs.forEach(ref => ref(node));
440
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
441
+ refs);
442
+ }
443
+
444
+ // https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js
445
+ const canUseDOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
446
+
447
+ function isWindow(element) {
448
+ const elementString = Object.prototype.toString.call(element);
449
+ return elementString === '[object Window]' || // In Electron context the Window object serializes to [object global]
450
+ elementString === '[object global]';
451
+ }
452
+
453
+ function isNode(node) {
454
+ return 'nodeType' in node;
455
+ }
456
+
457
+ function getWindow(target) {
458
+ var _target$ownerDocument, _target$ownerDocument2;
459
+
460
+ if (!target) {
461
+ return window;
462
+ }
463
+
464
+ if (isWindow(target)) {
465
+ return target;
466
+ }
467
+
468
+ if (!isNode(target)) {
469
+ return window;
470
+ }
471
+
472
+ return (_target$ownerDocument = (_target$ownerDocument2 = target.ownerDocument) == null ? void 0 : _target$ownerDocument2.defaultView) != null ? _target$ownerDocument : window;
473
+ }
474
+
475
+ function isDocument(node) {
476
+ const {
477
+ Document
478
+ } = getWindow(node);
479
+ return node instanceof Document;
480
+ }
481
+
482
+ function isHTMLElement(node) {
483
+ if (isWindow(node)) {
484
+ return false;
485
+ }
486
+
487
+ return node instanceof getWindow(node).HTMLElement;
488
+ }
489
+
490
+ function isSVGElement(node) {
491
+ return node instanceof getWindow(node).SVGElement;
492
+ }
493
+
494
+ function getOwnerDocument(target) {
495
+ if (!target) {
496
+ return document;
497
+ }
498
+
499
+ if (isWindow(target)) {
500
+ return target.document;
501
+ }
502
+
503
+ if (!isNode(target)) {
504
+ return document;
505
+ }
506
+
507
+ if (isDocument(target)) {
508
+ return target;
509
+ }
510
+
511
+ if (isHTMLElement(target)) {
512
+ return target.ownerDocument;
513
+ }
514
+
515
+ return document;
516
+ }
517
+
518
+ /**
519
+ * A hook that resolves to useEffect on the server and useLayoutEffect on the client
520
+ * @param callback {function} Callback function that is invoked when the dependencies of the hook change
521
+ */
522
+
523
+ const useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
524
+
525
+ function useEvent(handler) {
526
+ const handlerRef = useRef(handler);
527
+ useIsomorphicLayoutEffect(() => {
528
+ handlerRef.current = handler;
529
+ });
530
+ return useCallback(function () {
531
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
532
+ args[_key] = arguments[_key];
533
+ }
534
+
535
+ return handlerRef.current == null ? void 0 : handlerRef.current(...args);
536
+ }, []);
537
+ }
538
+
539
+ function useInterval() {
540
+ const intervalRef = useRef(null);
541
+ const set = useCallback((listener, duration) => {
542
+ intervalRef.current = setInterval(listener, duration);
543
+ }, []);
544
+ const clear = useCallback(() => {
545
+ if (intervalRef.current !== null) {
546
+ clearInterval(intervalRef.current);
547
+ intervalRef.current = null;
548
+ }
549
+ }, []);
550
+ return [set, clear];
551
+ }
552
+
553
+ function useLatestValue(value, dependencies) {
554
+ if (dependencies === void 0) {
555
+ dependencies = [value];
556
+ }
557
+
558
+ const valueRef = useRef(value);
559
+ useIsomorphicLayoutEffect(() => {
560
+ if (valueRef.current !== value) {
561
+ valueRef.current = value;
562
+ }
563
+ }, dependencies);
564
+ return valueRef;
565
+ }
566
+
567
+ function useLazyMemo(callback, dependencies) {
568
+ const valueRef = useRef();
569
+ return useMemo(() => {
570
+ const newValue = callback(valueRef.current);
571
+ valueRef.current = newValue;
572
+ return newValue;
573
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
574
+ [...dependencies]);
575
+ }
576
+
577
+ function useNodeRef(onChange) {
578
+ const onChangeHandler = useEvent(onChange);
579
+ const node = useRef(null);
580
+ const setNodeRef = useCallback(element => {
581
+ if (element !== node.current) {
582
+ onChangeHandler == null ? void 0 : onChangeHandler(element, node.current);
583
+ }
584
+
585
+ node.current = element;
586
+ }, //eslint-disable-next-line
587
+ []);
588
+ return [node, setNodeRef];
589
+ }
590
+
591
+ function usePrevious(value) {
592
+ const ref = useRef();
593
+ useEffect(() => {
594
+ ref.current = value;
595
+ }, [value]);
596
+ return ref.current;
597
+ }
598
+
599
+ let ids = {};
600
+ function useUniqueId(prefix, value) {
601
+ return useMemo(() => {
602
+ if (value) {
603
+ return value;
604
+ }
605
+
606
+ const id = ids[prefix] == null ? 0 : ids[prefix] + 1;
607
+ ids[prefix] = id;
608
+ return prefix + "-" + id;
609
+ }, [prefix, value]);
610
+ }
611
+
612
+ function createAdjustmentFn(modifier) {
613
+ return function (object) {
614
+ for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
615
+ adjustments[_key - 1] = arguments[_key];
616
+ }
617
+
618
+ return adjustments.reduce((accumulator, adjustment) => {
619
+ const entries = Object.entries(adjustment);
620
+
621
+ for (const [key, valueAdjustment] of entries) {
622
+ const value = accumulator[key];
623
+
624
+ if (value != null) {
625
+ accumulator[key] = value + modifier * valueAdjustment;
626
+ }
627
+ }
628
+
629
+ return accumulator;
630
+ }, { ...object
631
+ });
632
+ };
633
+ }
634
+
635
+ const add = /*#__PURE__*/createAdjustmentFn(1);
636
+ const subtract = /*#__PURE__*/createAdjustmentFn(-1);
637
+
638
+ function hasViewportRelativeCoordinates(event) {
639
+ return 'clientX' in event && 'clientY' in event;
640
+ }
641
+
642
+ function isKeyboardEvent(event) {
643
+ if (!event) {
644
+ return false;
645
+ }
646
+
647
+ const {
648
+ KeyboardEvent
649
+ } = getWindow(event.target);
650
+ return KeyboardEvent && event instanceof KeyboardEvent;
651
+ }
652
+
653
+ function isTouchEvent(event) {
654
+ if (!event) {
655
+ return false;
656
+ }
657
+
658
+ const {
659
+ TouchEvent
660
+ } = getWindow(event.target);
661
+ return TouchEvent && event instanceof TouchEvent;
662
+ }
663
+
664
+ /**
665
+ * Returns the normalized x and y coordinates for mouse and touch events.
666
+ */
667
+
668
+ function getEventCoordinates(event) {
669
+ if (isTouchEvent(event)) {
670
+ if (event.touches && event.touches.length) {
671
+ const {
672
+ clientX: x,
673
+ clientY: y
674
+ } = event.touches[0];
675
+ return {
676
+ x,
677
+ y
678
+ };
679
+ } else if (event.changedTouches && event.changedTouches.length) {
680
+ const {
681
+ clientX: x,
682
+ clientY: y
683
+ } = event.changedTouches[0];
684
+ return {
685
+ x,
686
+ y
687
+ };
688
+ }
689
+ }
690
+
691
+ if (hasViewportRelativeCoordinates(event)) {
692
+ return {
693
+ x: event.clientX,
694
+ y: event.clientY
695
+ };
696
+ }
697
+
698
+ return null;
699
+ }
700
+
701
+ const CSS = /*#__PURE__*/Object.freeze({
702
+ Translate: {
703
+ toString(transform) {
704
+ if (!transform) {
705
+ return;
706
+ }
707
+
708
+ const {
709
+ x,
710
+ y
711
+ } = transform;
712
+ return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
713
+ }
714
+
715
+ },
716
+ Scale: {
717
+ toString(transform) {
718
+ if (!transform) {
719
+ return;
720
+ }
721
+
722
+ const {
723
+ scaleX,
724
+ scaleY
725
+ } = transform;
726
+ return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
727
+ }
728
+
729
+ },
730
+ Transform: {
731
+ toString(transform) {
732
+ if (!transform) {
733
+ return;
734
+ }
735
+
736
+ return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(' ');
737
+ }
738
+
739
+ },
740
+ Transition: {
741
+ toString(_ref) {
742
+ let {
743
+ property,
744
+ duration,
745
+ easing
746
+ } = _ref;
747
+ return property + " " + duration + "ms " + easing;
748
+ }
749
+
750
+ }
751
+ });
752
+
753
+ const SELECTOR = 'a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]';
754
+ function findFirstFocusableNode(element) {
755
+ if (element.matches(SELECTOR)) {
756
+ return element;
757
+ }
758
+
759
+ return element.querySelector(SELECTOR);
760
+ }
761
+
762
+ const hiddenStyles = {
763
+ display: 'none'
764
+ };
765
+ function HiddenText(_ref) {
766
+ let {
767
+ id,
768
+ value
769
+ } = _ref;
770
+ return React.createElement("div", {
771
+ id: id,
772
+ style: hiddenStyles
773
+ }, value);
774
+ }
775
+
776
+ const visuallyHidden = {
777
+ position: 'fixed',
778
+ width: 1,
779
+ height: 1,
780
+ margin: -1,
781
+ border: 0,
782
+ padding: 0,
783
+ overflow: 'hidden',
784
+ clip: 'rect(0 0 0 0)',
785
+ clipPath: 'inset(100%)',
786
+ whiteSpace: 'nowrap'
787
+ };
788
+ function LiveRegion(_ref) {
789
+ let {
790
+ id,
791
+ announcement
792
+ } = _ref;
793
+ return React.createElement("div", {
794
+ id: id,
795
+ style: visuallyHidden,
796
+ role: "status",
797
+ "aria-live": "assertive",
798
+ "aria-atomic": true
799
+ }, announcement);
800
+ }
801
+
802
+ function useAnnouncement() {
803
+ const [announcement, setAnnouncement] = useState('');
804
+ const announce = useCallback(value => {
805
+ if (value != null) {
806
+ setAnnouncement(value);
807
+ }
808
+ }, []);
809
+ return {
810
+ announce,
811
+ announcement
812
+ };
813
+ }
814
+
815
+ const DndMonitorContext = /*#__PURE__*/createContext(null);
816
+
817
+ function useDndMonitor(listener) {
818
+ const registerListener = useContext(DndMonitorContext);
819
+ useEffect(() => {
820
+ if (!registerListener) {
821
+ throw new Error('useDndMonitor must be used within a children of <DndContext>');
822
+ }
823
+
824
+ const unsubscribe = registerListener(listener);
825
+ return unsubscribe;
826
+ }, [listener, registerListener]);
827
+ }
828
+
829
+ function useDndMonitorProvider() {
830
+ const [listeners] = useState(() => new Set());
831
+ const registerListener = useCallback(listener => {
832
+ listeners.add(listener);
833
+ return () => listeners.delete(listener);
834
+ }, [listeners]);
835
+ const dispatch = useCallback(_ref => {
836
+ let {
837
+ type,
838
+ event
839
+ } = _ref;
840
+ listeners.forEach(listener => {
841
+ var _listener$type;
842
+
843
+ return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
844
+ });
845
+ }, [listeners]);
846
+ return [dispatch, registerListener];
847
+ }
848
+
849
+ const defaultScreenReaderInstructions = {
850
+ draggable: "\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "
851
+ };
852
+ const defaultAnnouncements = {
853
+ onDragStart(_ref) {
854
+ let {
855
+ active
856
+ } = _ref;
857
+ return "Picked up draggable item " + active.id + ".";
858
+ },
859
+
860
+ onDragOver(_ref2) {
861
+ let {
862
+ active,
863
+ over
864
+ } = _ref2;
865
+
866
+ if (over) {
867
+ return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
868
+ }
869
+
870
+ return "Draggable item " + active.id + " is no longer over a droppable area.";
871
+ },
872
+
873
+ onDragEnd(_ref3) {
874
+ let {
875
+ active,
876
+ over
877
+ } = _ref3;
878
+
879
+ if (over) {
880
+ return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
881
+ }
882
+
883
+ return "Draggable item " + active.id + " was dropped.";
884
+ },
885
+
886
+ onDragCancel(_ref4) {
887
+ let {
888
+ active
889
+ } = _ref4;
890
+ return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
891
+ }
892
+
893
+ };
894
+
895
+ function Accessibility(_ref) {
896
+ let {
897
+ announcements = defaultAnnouncements,
898
+ container,
899
+ hiddenTextDescribedById,
900
+ screenReaderInstructions = defaultScreenReaderInstructions
901
+ } = _ref;
902
+ const {
903
+ announce,
904
+ announcement
905
+ } = useAnnouncement();
906
+ const liveRegionId = useUniqueId("DndLiveRegion");
907
+ const [mounted, setMounted] = useState(false);
908
+ useEffect(() => {
909
+ setMounted(true);
910
+ }, []);
911
+ useDndMonitor(useMemo(() => ({
912
+ onDragStart(_ref2) {
913
+ let {
914
+ active
915
+ } = _ref2;
916
+ announce(announcements.onDragStart({
917
+ active
918
+ }));
919
+ },
920
+
921
+ onDragMove(_ref3) {
922
+ let {
923
+ active,
924
+ over
925
+ } = _ref3;
926
+
927
+ if (announcements.onDragMove) {
928
+ announce(announcements.onDragMove({
929
+ active,
930
+ over
931
+ }));
932
+ }
933
+ },
934
+
935
+ onDragOver(_ref4) {
936
+ let {
937
+ active,
938
+ over
939
+ } = _ref4;
940
+ announce(announcements.onDragOver({
941
+ active,
942
+ over
943
+ }));
944
+ },
945
+
946
+ onDragEnd(_ref5) {
947
+ let {
948
+ active,
949
+ over
950
+ } = _ref5;
951
+ announce(announcements.onDragEnd({
952
+ active,
953
+ over
954
+ }));
955
+ },
956
+
957
+ onDragCancel(_ref6) {
958
+ let {
959
+ active,
960
+ over
961
+ } = _ref6;
962
+ announce(announcements.onDragCancel({
963
+ active,
964
+ over
965
+ }));
966
+ }
967
+
968
+ }), [announce, announcements]));
969
+
970
+ if (!mounted) {
971
+ return null;
972
+ }
973
+
974
+ const markup = React.createElement(React.Fragment, null, React.createElement(HiddenText, {
975
+ id: hiddenTextDescribedById,
976
+ value: screenReaderInstructions.draggable
977
+ }), React.createElement(LiveRegion, {
978
+ id: liveRegionId,
979
+ announcement: announcement
980
+ }));
981
+ return container ? createPortal(markup, container) : markup;
982
+ }
983
+
984
+ var Action;
985
+
986
+ (function (Action) {
987
+ Action["DragStart"] = "dragStart";
988
+ Action["DragMove"] = "dragMove";
989
+ Action["DragEnd"] = "dragEnd";
990
+ Action["DragCancel"] = "dragCancel";
991
+ Action["DragOver"] = "dragOver";
992
+ Action["RegisterDroppable"] = "registerDroppable";
993
+ Action["SetDroppableDisabled"] = "setDroppableDisabled";
994
+ Action["UnregisterDroppable"] = "unregisterDroppable";
995
+ })(Action || (Action = {}));
996
+
997
+ function noop() {}
998
+
999
+ const defaultCoordinates = /*#__PURE__*/Object.freeze({
1000
+ x: 0,
1001
+ y: 0
1002
+ });
1003
+
1004
+ /**
1005
+ * Returns the distance between two points
1006
+ */
1007
+ function distanceBetween(p1, p2) {
1008
+ return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
1009
+ }
1010
+
1011
+ /**
1012
+ * Sort collisions from smallest to greatest value
1013
+ */
1014
+ function sortCollisionsAsc(_ref, _ref2) {
1015
+ let {
1016
+ data: {
1017
+ value: a
1018
+ }
1019
+ } = _ref;
1020
+ let {
1021
+ data: {
1022
+ value: b
1023
+ }
1024
+ } = _ref2;
1025
+ return a - b;
1026
+ }
1027
+ /**
1028
+ * Sort collisions from greatest to smallest value
1029
+ */
1030
+
1031
+ function sortCollisionsDesc(_ref3, _ref4) {
1032
+ let {
1033
+ data: {
1034
+ value: a
1035
+ }
1036
+ } = _ref3;
1037
+ let {
1038
+ data: {
1039
+ value: b
1040
+ }
1041
+ } = _ref4;
1042
+ return b - a;
1043
+ }
1044
+ function getFirstCollision(collisions, property) {
1045
+ if (!collisions || collisions.length === 0) {
1046
+ return null;
1047
+ }
1048
+
1049
+ const [firstCollision] = collisions;
1050
+ return property ? firstCollision[property] : firstCollision;
1051
+ }
1052
+
1053
+ /**
1054
+ * Returns the coordinates of the center of a given ClientRect
1055
+ */
1056
+
1057
+ function centerOfRectangle(rect, left, top) {
1058
+ if (left === void 0) {
1059
+ left = rect.left;
1060
+ }
1061
+
1062
+ if (top === void 0) {
1063
+ top = rect.top;
1064
+ }
1065
+
1066
+ return {
1067
+ x: left + rect.width * 0.5,
1068
+ y: top + rect.height * 0.5
1069
+ };
1070
+ }
1071
+ /**
1072
+ * Returns the closest rectangles from an array of rectangles to the center of a given
1073
+ * rectangle.
1074
+ */
1075
+
1076
+
1077
+ const closestCenter = _ref => {
1078
+ let {
1079
+ collisionRect,
1080
+ droppableRects,
1081
+ droppableContainers
1082
+ } = _ref;
1083
+ const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top);
1084
+ const collisions = [];
1085
+
1086
+ for (const droppableContainer of droppableContainers) {
1087
+ const {
1088
+ id
1089
+ } = droppableContainer;
1090
+ const rect = droppableRects.get(id);
1091
+
1092
+ if (rect) {
1093
+ const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
1094
+ collisions.push({
1095
+ id,
1096
+ data: {
1097
+ droppableContainer,
1098
+ value: distBetween
1099
+ }
1100
+ });
1101
+ }
1102
+ }
1103
+
1104
+ return collisions.sort(sortCollisionsAsc);
1105
+ };
1106
+
1107
+ /**
1108
+ * Returns the intersecting rectangle area between two rectangles
1109
+ */
1110
+
1111
+ function getIntersectionRatio(entry, target) {
1112
+ const top = Math.max(target.top, entry.top);
1113
+ const left = Math.max(target.left, entry.left);
1114
+ const right = Math.min(target.left + target.width, entry.left + entry.width);
1115
+ const bottom = Math.min(target.top + target.height, entry.top + entry.height);
1116
+ const width = right - left;
1117
+ const height = bottom - top;
1118
+
1119
+ if (left < right && top < bottom) {
1120
+ const targetArea = target.width * target.height;
1121
+ const entryArea = entry.width * entry.height;
1122
+ const intersectionArea = width * height;
1123
+ const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
1124
+ return Number(intersectionRatio.toFixed(4));
1125
+ } // Rectangles do not overlap, or overlap has an area of zero (edge/corner overlap)
1126
+
1127
+
1128
+ return 0;
1129
+ }
1130
+ /**
1131
+ * Returns the rectangles that has the greatest intersection area with a given
1132
+ * rectangle in an array of rectangles.
1133
+ */
1134
+
1135
+ const rectIntersection = _ref => {
1136
+ let {
1137
+ collisionRect,
1138
+ droppableRects,
1139
+ droppableContainers
1140
+ } = _ref;
1141
+ const collisions = [];
1142
+
1143
+ for (const droppableContainer of droppableContainers) {
1144
+ const {
1145
+ id
1146
+ } = droppableContainer;
1147
+ const rect = droppableRects.get(id);
1148
+
1149
+ if (rect) {
1150
+ const intersectionRatio = getIntersectionRatio(rect, collisionRect);
1151
+
1152
+ if (intersectionRatio > 0) {
1153
+ collisions.push({
1154
+ id,
1155
+ data: {
1156
+ droppableContainer,
1157
+ value: intersectionRatio
1158
+ }
1159
+ });
1160
+ }
1161
+ }
1162
+ }
1163
+
1164
+ return collisions.sort(sortCollisionsDesc);
1165
+ };
1166
+
1167
+ function adjustScale(transform, rect1, rect2) {
1168
+ return { ...transform,
1169
+ scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
1170
+ scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
1171
+ };
1172
+ }
1173
+
1174
+ function getRectDelta(rect1, rect2) {
1175
+ return rect1 && rect2 ? {
1176
+ x: rect1.left - rect2.left,
1177
+ y: rect1.top - rect2.top
1178
+ } : defaultCoordinates;
1179
+ }
1180
+
1181
+ function createRectAdjustmentFn(modifier) {
1182
+ return function adjustClientRect(rect) {
1183
+ for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1184
+ adjustments[_key - 1] = arguments[_key];
1185
+ }
1186
+
1187
+ return adjustments.reduce((acc, adjustment) => ({ ...acc,
1188
+ top: acc.top + modifier * adjustment.y,
1189
+ bottom: acc.bottom + modifier * adjustment.y,
1190
+ left: acc.left + modifier * adjustment.x,
1191
+ right: acc.right + modifier * adjustment.x
1192
+ }), { ...rect
1193
+ });
1194
+ };
1195
+ }
1196
+ const getAdjustedRect = /*#__PURE__*/createRectAdjustmentFn(1);
1197
+
1198
+ function parseTransform(transform) {
1199
+ if (transform.startsWith('matrix3d(')) {
1200
+ const transformArray = transform.slice(9, -1).split(/, /);
1201
+ return {
1202
+ x: +transformArray[12],
1203
+ y: +transformArray[13],
1204
+ scaleX: +transformArray[0],
1205
+ scaleY: +transformArray[5]
1206
+ };
1207
+ } else if (transform.startsWith('matrix(')) {
1208
+ const transformArray = transform.slice(7, -1).split(/, /);
1209
+ return {
1210
+ x: +transformArray[4],
1211
+ y: +transformArray[5],
1212
+ scaleX: +transformArray[0],
1213
+ scaleY: +transformArray[3]
1214
+ };
1215
+ }
1216
+
1217
+ return null;
1218
+ }
1219
+
1220
+ function inverseTransform(rect, transform, transformOrigin) {
1221
+ const parsedTransform = parseTransform(transform);
1222
+
1223
+ if (!parsedTransform) {
1224
+ return rect;
1225
+ }
1226
+
1227
+ const {
1228
+ scaleX,
1229
+ scaleY,
1230
+ x: translateX,
1231
+ y: translateY
1232
+ } = parsedTransform;
1233
+ const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
1234
+ const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(' ') + 1));
1235
+ const w = scaleX ? rect.width / scaleX : rect.width;
1236
+ const h = scaleY ? rect.height / scaleY : rect.height;
1237
+ return {
1238
+ width: w,
1239
+ height: h,
1240
+ top: y,
1241
+ right: x + w,
1242
+ bottom: y + h,
1243
+ left: x
1244
+ };
1245
+ }
1246
+
1247
+ const defaultOptions = {
1248
+ ignoreTransform: false
1249
+ };
1250
+ /**
1251
+ * Returns the bounding client rect of an element relative to the viewport.
1252
+ */
1253
+
1254
+ function getClientRect(element, options) {
1255
+ if (options === void 0) {
1256
+ options = defaultOptions;
1257
+ }
1258
+
1259
+ let rect = element.getBoundingClientRect();
1260
+
1261
+ if (options.ignoreTransform) {
1262
+ const {
1263
+ transform,
1264
+ transformOrigin
1265
+ } = getWindow(element).getComputedStyle(element);
1266
+
1267
+ if (transform) {
1268
+ rect = inverseTransform(rect, transform, transformOrigin);
1269
+ }
1270
+ }
1271
+
1272
+ const {
1273
+ top,
1274
+ left,
1275
+ width,
1276
+ height,
1277
+ bottom,
1278
+ right
1279
+ } = rect;
1280
+ return {
1281
+ top,
1282
+ left,
1283
+ width,
1284
+ height,
1285
+ bottom,
1286
+ right
1287
+ };
1288
+ }
1289
+ /**
1290
+ * Returns the bounding client rect of an element relative to the viewport.
1291
+ *
1292
+ * @remarks
1293
+ * The ClientRect returned by this method does not take into account transforms
1294
+ * applied to the element it measures.
1295
+ *
1296
+ */
1297
+
1298
+ function getTransformAgnosticClientRect(element) {
1299
+ return getClientRect(element, {
1300
+ ignoreTransform: true
1301
+ });
1302
+ }
1303
+
1304
+ function getWindowClientRect(element) {
1305
+ const width = element.innerWidth;
1306
+ const height = element.innerHeight;
1307
+ return {
1308
+ top: 0,
1309
+ left: 0,
1310
+ right: width,
1311
+ bottom: height,
1312
+ width,
1313
+ height
1314
+ };
1315
+ }
1316
+
1317
+ function isFixed(node, computedStyle) {
1318
+ if (computedStyle === void 0) {
1319
+ computedStyle = getWindow(node).getComputedStyle(node);
1320
+ }
1321
+
1322
+ return computedStyle.position === 'fixed';
1323
+ }
1324
+
1325
+ function isScrollable(element, computedStyle) {
1326
+ if (computedStyle === void 0) {
1327
+ computedStyle = getWindow(element).getComputedStyle(element);
1328
+ }
1329
+
1330
+ const overflowRegex = /(auto|scroll|overlay)/;
1331
+ const properties = ['overflow', 'overflowX', 'overflowY'];
1332
+ return properties.some(property => {
1333
+ const value = computedStyle[property];
1334
+ return typeof value === 'string' ? overflowRegex.test(value) : false;
1335
+ });
1336
+ }
1337
+
1338
+ function getScrollableAncestors(element, limit) {
1339
+ const scrollParents = [];
1340
+
1341
+ function findScrollableAncestors(node) {
1342
+ if (limit != null && scrollParents.length >= limit) {
1343
+ return scrollParents;
1344
+ }
1345
+
1346
+ if (!node) {
1347
+ return scrollParents;
1348
+ }
1349
+
1350
+ if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
1351
+ scrollParents.push(node.scrollingElement);
1352
+ return scrollParents;
1353
+ }
1354
+
1355
+ if (!isHTMLElement(node) || isSVGElement(node)) {
1356
+ return scrollParents;
1357
+ }
1358
+
1359
+ if (scrollParents.includes(node)) {
1360
+ return scrollParents;
1361
+ }
1362
+
1363
+ const computedStyle = getWindow(element).getComputedStyle(node);
1364
+
1365
+ if (node !== element) {
1366
+ if (isScrollable(node, computedStyle)) {
1367
+ scrollParents.push(node);
1368
+ }
1369
+ }
1370
+
1371
+ if (isFixed(node, computedStyle)) {
1372
+ return scrollParents;
1373
+ }
1374
+
1375
+ return findScrollableAncestors(node.parentNode);
1376
+ }
1377
+
1378
+ if (!element) {
1379
+ return scrollParents;
1380
+ }
1381
+
1382
+ return findScrollableAncestors(element);
1383
+ }
1384
+ function getFirstScrollableAncestor(node) {
1385
+ const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
1386
+ return firstScrollableAncestor != null ? firstScrollableAncestor : null;
1387
+ }
1388
+
1389
+ function getScrollableElement(element) {
1390
+ if (!canUseDOM || !element) {
1391
+ return null;
1392
+ }
1393
+
1394
+ if (isWindow(element)) {
1395
+ return element;
1396
+ }
1397
+
1398
+ if (!isNode(element)) {
1399
+ return null;
1400
+ }
1401
+
1402
+ if (isDocument(element) || element === getOwnerDocument(element).scrollingElement) {
1403
+ return window;
1404
+ }
1405
+
1406
+ if (isHTMLElement(element)) {
1407
+ return element;
1408
+ }
1409
+
1410
+ return null;
1411
+ }
1412
+
1413
+ function getScrollXCoordinate(element) {
1414
+ if (isWindow(element)) {
1415
+ return element.scrollX;
1416
+ }
1417
+
1418
+ return element.scrollLeft;
1419
+ }
1420
+ function getScrollYCoordinate(element) {
1421
+ if (isWindow(element)) {
1422
+ return element.scrollY;
1423
+ }
1424
+
1425
+ return element.scrollTop;
1426
+ }
1427
+ function getScrollCoordinates(element) {
1428
+ return {
1429
+ x: getScrollXCoordinate(element),
1430
+ y: getScrollYCoordinate(element)
1431
+ };
1432
+ }
1433
+
1434
+ var Direction;
1435
+
1436
+ (function (Direction) {
1437
+ Direction[Direction["Forward"] = 1] = "Forward";
1438
+ Direction[Direction["Backward"] = -1] = "Backward";
1439
+ })(Direction || (Direction = {}));
1440
+
1441
+ function isDocumentScrollingElement(element) {
1442
+ if (!canUseDOM || !element) {
1443
+ return false;
1444
+ }
1445
+
1446
+ return element === document.scrollingElement;
1447
+ }
1448
+
1449
+ function getScrollPosition(scrollingContainer) {
1450
+ const minScroll = {
1451
+ x: 0,
1452
+ y: 0
1453
+ };
1454
+ const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
1455
+ height: window.innerHeight,
1456
+ width: window.innerWidth
1457
+ } : {
1458
+ height: scrollingContainer.clientHeight,
1459
+ width: scrollingContainer.clientWidth
1460
+ };
1461
+ const maxScroll = {
1462
+ x: scrollingContainer.scrollWidth - dimensions.width,
1463
+ y: scrollingContainer.scrollHeight - dimensions.height
1464
+ };
1465
+ const isTop = scrollingContainer.scrollTop <= minScroll.y;
1466
+ const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
1467
+ const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
1468
+ const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
1469
+ return {
1470
+ isTop,
1471
+ isLeft,
1472
+ isBottom,
1473
+ isRight,
1474
+ maxScroll,
1475
+ minScroll
1476
+ };
1477
+ }
1478
+
1479
+ const defaultThreshold = {
1480
+ x: 0.2,
1481
+ y: 0.2
1482
+ };
1483
+ function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
1484
+ let {
1485
+ top,
1486
+ left,
1487
+ right,
1488
+ bottom
1489
+ } = _ref;
1490
+
1491
+ if (acceleration === void 0) {
1492
+ acceleration = 10;
1493
+ }
1494
+
1495
+ if (thresholdPercentage === void 0) {
1496
+ thresholdPercentage = defaultThreshold;
1497
+ }
1498
+
1499
+ const {
1500
+ isTop,
1501
+ isBottom,
1502
+ isLeft,
1503
+ isRight
1504
+ } = getScrollPosition(scrollContainer);
1505
+ const direction = {
1506
+ x: 0,
1507
+ y: 0
1508
+ };
1509
+ const speed = {
1510
+ x: 0,
1511
+ y: 0
1512
+ };
1513
+ const threshold = {
1514
+ height: scrollContainerRect.height * thresholdPercentage.y,
1515
+ width: scrollContainerRect.width * thresholdPercentage.x
1516
+ };
1517
+
1518
+ if (!isTop && top <= scrollContainerRect.top + threshold.height) {
1519
+ // Scroll Up
1520
+ direction.y = Direction.Backward;
1521
+ speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
1522
+ } else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
1523
+ // Scroll Down
1524
+ direction.y = Direction.Forward;
1525
+ speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
1526
+ }
1527
+
1528
+ if (!isRight && right >= scrollContainerRect.right - threshold.width) {
1529
+ // Scroll Right
1530
+ direction.x = Direction.Forward;
1531
+ speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
1532
+ } else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
1533
+ // Scroll Left
1534
+ direction.x = Direction.Backward;
1535
+ speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
1536
+ }
1537
+
1538
+ return {
1539
+ direction,
1540
+ speed
1541
+ };
1542
+ }
1543
+
1544
+ function getScrollElementRect(element) {
1545
+ if (element === document.scrollingElement) {
1546
+ const {
1547
+ innerWidth,
1548
+ innerHeight
1549
+ } = window;
1550
+ return {
1551
+ top: 0,
1552
+ left: 0,
1553
+ right: innerWidth,
1554
+ bottom: innerHeight,
1555
+ width: innerWidth,
1556
+ height: innerHeight
1557
+ };
1558
+ }
1559
+
1560
+ const {
1561
+ top,
1562
+ left,
1563
+ right,
1564
+ bottom
1565
+ } = element.getBoundingClientRect();
1566
+ return {
1567
+ top,
1568
+ left,
1569
+ right,
1570
+ bottom,
1571
+ width: element.clientWidth,
1572
+ height: element.clientHeight
1573
+ };
1574
+ }
1575
+
1576
+ function getScrollOffsets(scrollableAncestors) {
1577
+ return scrollableAncestors.reduce((acc, node) => {
1578
+ return add(acc, getScrollCoordinates(node));
1579
+ }, defaultCoordinates);
1580
+ }
1581
+ function getScrollXOffset(scrollableAncestors) {
1582
+ return scrollableAncestors.reduce((acc, node) => {
1583
+ return acc + getScrollXCoordinate(node);
1584
+ }, 0);
1585
+ }
1586
+ function getScrollYOffset(scrollableAncestors) {
1587
+ return scrollableAncestors.reduce((acc, node) => {
1588
+ return acc + getScrollYCoordinate(node);
1589
+ }, 0);
1590
+ }
1591
+
1592
+ function scrollIntoViewIfNeeded(element, measure) {
1593
+ if (measure === void 0) {
1594
+ measure = getClientRect;
1595
+ }
1596
+
1597
+ if (!element) {
1598
+ return;
1599
+ }
1600
+
1601
+ const {
1602
+ top,
1603
+ left,
1604
+ bottom,
1605
+ right
1606
+ } = measure(element);
1607
+ const firstScrollableAncestor = getFirstScrollableAncestor(element);
1608
+
1609
+ if (!firstScrollableAncestor) {
1610
+ return;
1611
+ }
1612
+
1613
+ if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
1614
+ element.scrollIntoView({
1615
+ block: 'center',
1616
+ inline: 'center'
1617
+ });
1618
+ }
1619
+ }
1620
+
1621
+ const properties = [['x', ['left', 'right'], getScrollXOffset], ['y', ['top', 'bottom'], getScrollYOffset]];
1622
+ class Rect {
1623
+ constructor(rect, element) {
1624
+ this.rect = void 0;
1625
+ this.width = void 0;
1626
+ this.height = void 0;
1627
+ this.top = void 0;
1628
+ this.bottom = void 0;
1629
+ this.right = void 0;
1630
+ this.left = void 0;
1631
+ const scrollableAncestors = getScrollableAncestors(element);
1632
+ const scrollOffsets = getScrollOffsets(scrollableAncestors);
1633
+ this.rect = { ...rect
1634
+ };
1635
+ this.width = rect.width;
1636
+ this.height = rect.height;
1637
+
1638
+ for (const [axis, keys, getScrollOffset] of properties) {
1639
+ for (const key of keys) {
1640
+ Object.defineProperty(this, key, {
1641
+ get: () => {
1642
+ const currentOffsets = getScrollOffset(scrollableAncestors);
1643
+ const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
1644
+ return this.rect[key] + scrollOffsetsDeltla;
1645
+ },
1646
+ enumerable: true
1647
+ });
1648
+ }
1649
+ }
1650
+
1651
+ Object.defineProperty(this, 'rect', {
1652
+ enumerable: false
1653
+ });
1654
+ }
1655
+
1656
+ }
1657
+
1658
+ class Listeners {
1659
+ constructor(target) {
1660
+ this.target = void 0;
1661
+ this.listeners = [];
1662
+
1663
+ this.removeAll = () => {
1664
+ this.listeners.forEach(listener => {
1665
+ var _this$target;
1666
+
1667
+ return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
1668
+ });
1669
+ };
1670
+
1671
+ this.target = target;
1672
+ }
1673
+
1674
+ add(eventName, handler, options) {
1675
+ var _this$target2;
1676
+
1677
+ (_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
1678
+ this.listeners.push([eventName, handler, options]);
1679
+ }
1680
+
1681
+ }
1682
+
1683
+ function getEventListenerTarget(target) {
1684
+ // If the `event.target` element is removed from the document events will still be targeted
1685
+ // at it, and hence won't always bubble up to the window or document anymore.
1686
+ // If there is any risk of an element being removed while it is being dragged,
1687
+ // the best practice is to attach the event listeners directly to the target.
1688
+ // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
1689
+ const {
1690
+ EventTarget
1691
+ } = getWindow(target);
1692
+ return target instanceof EventTarget ? target : getOwnerDocument(target);
1693
+ }
1694
+
1695
+ function hasExceededDistance(delta, measurement) {
1696
+ const dx = Math.abs(delta.x);
1697
+ const dy = Math.abs(delta.y);
1698
+
1699
+ if (typeof measurement === 'number') {
1700
+ return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
1701
+ }
1702
+
1703
+ if ('x' in measurement && 'y' in measurement) {
1704
+ return dx > measurement.x && dy > measurement.y;
1705
+ }
1706
+
1707
+ if ('x' in measurement) {
1708
+ return dx > measurement.x;
1709
+ }
1710
+
1711
+ if ('y' in measurement) {
1712
+ return dy > measurement.y;
1713
+ }
1714
+
1715
+ return false;
1716
+ }
1717
+
1718
+ var EventName;
1719
+
1720
+ (function (EventName) {
1721
+ EventName["Click"] = "click";
1722
+ EventName["DragStart"] = "dragstart";
1723
+ EventName["Keydown"] = "keydown";
1724
+ EventName["ContextMenu"] = "contextmenu";
1725
+ EventName["Resize"] = "resize";
1726
+ EventName["SelectionChange"] = "selectionchange";
1727
+ EventName["VisibilityChange"] = "visibilitychange";
1728
+ })(EventName || (EventName = {}));
1729
+
1730
+ function preventDefault(event) {
1731
+ event.preventDefault();
1732
+ }
1733
+ function stopPropagation(event) {
1734
+ event.stopPropagation();
1735
+ }
1736
+
1737
+ var KeyboardCode;
1738
+
1739
+ (function (KeyboardCode) {
1740
+ KeyboardCode["Space"] = "Space";
1741
+ KeyboardCode["Down"] = "ArrowDown";
1742
+ KeyboardCode["Right"] = "ArrowRight";
1743
+ KeyboardCode["Left"] = "ArrowLeft";
1744
+ KeyboardCode["Up"] = "ArrowUp";
1745
+ KeyboardCode["Esc"] = "Escape";
1746
+ KeyboardCode["Enter"] = "Enter";
1747
+ })(KeyboardCode || (KeyboardCode = {}));
1748
+
1749
+ const defaultKeyboardCodes = {
1750
+ start: [KeyboardCode.Space, KeyboardCode.Enter],
1751
+ cancel: [KeyboardCode.Esc],
1752
+ end: [KeyboardCode.Space, KeyboardCode.Enter]
1753
+ };
1754
+ const defaultKeyboardCoordinateGetter = (event, _ref) => {
1755
+ let {
1756
+ currentCoordinates
1757
+ } = _ref;
1758
+
1759
+ switch (event.code) {
1760
+ case KeyboardCode.Right:
1761
+ return { ...currentCoordinates,
1762
+ x: currentCoordinates.x + 25
1763
+ };
1764
+
1765
+ case KeyboardCode.Left:
1766
+ return { ...currentCoordinates,
1767
+ x: currentCoordinates.x - 25
1768
+ };
1769
+
1770
+ case KeyboardCode.Down:
1771
+ return { ...currentCoordinates,
1772
+ y: currentCoordinates.y + 25
1773
+ };
1774
+
1775
+ case KeyboardCode.Up:
1776
+ return { ...currentCoordinates,
1777
+ y: currentCoordinates.y - 25
1778
+ };
1779
+ }
1780
+
1781
+ return undefined;
1782
+ };
1783
+
1784
+ class KeyboardSensor {
1785
+ constructor(props) {
1786
+ this.props = void 0;
1787
+ this.autoScrollEnabled = false;
1788
+ this.referenceCoordinates = void 0;
1789
+ this.listeners = void 0;
1790
+ this.windowListeners = void 0;
1791
+ this.props = props;
1792
+ const {
1793
+ event: {
1794
+ target
1795
+ }
1796
+ } = props;
1797
+ this.props = props;
1798
+ this.listeners = new Listeners(getOwnerDocument(target));
1799
+ this.windowListeners = new Listeners(getWindow(target));
1800
+ this.handleKeyDown = this.handleKeyDown.bind(this);
1801
+ this.handleCancel = this.handleCancel.bind(this);
1802
+ this.attach();
1803
+ }
1804
+
1805
+ attach() {
1806
+ this.handleStart();
1807
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
1808
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
1809
+ setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
1810
+ }
1811
+
1812
+ handleStart() {
1813
+ const {
1814
+ activeNode,
1815
+ onStart
1816
+ } = this.props;
1817
+ const node = activeNode.node.current;
1818
+
1819
+ if (node) {
1820
+ scrollIntoViewIfNeeded(node);
1821
+ }
1822
+
1823
+ onStart(defaultCoordinates);
1824
+ }
1825
+
1826
+ handleKeyDown(event) {
1827
+ if (isKeyboardEvent(event)) {
1828
+ const {
1829
+ active,
1830
+ context,
1831
+ options
1832
+ } = this.props;
1833
+ const {
1834
+ keyboardCodes = defaultKeyboardCodes,
1835
+ coordinateGetter = defaultKeyboardCoordinateGetter,
1836
+ scrollBehavior = 'smooth'
1837
+ } = options;
1838
+ const {
1839
+ code
1840
+ } = event;
1841
+
1842
+ if (keyboardCodes.end.includes(code)) {
1843
+ this.handleEnd(event);
1844
+ return;
1845
+ }
1846
+
1847
+ if (keyboardCodes.cancel.includes(code)) {
1848
+ this.handleCancel(event);
1849
+ return;
1850
+ }
1851
+
1852
+ const {
1853
+ collisionRect
1854
+ } = context.current;
1855
+ const currentCoordinates = collisionRect ? {
1856
+ x: collisionRect.left,
1857
+ y: collisionRect.top
1858
+ } : defaultCoordinates;
1859
+
1860
+ if (!this.referenceCoordinates) {
1861
+ this.referenceCoordinates = currentCoordinates;
1862
+ }
1863
+
1864
+ const newCoordinates = coordinateGetter(event, {
1865
+ active,
1866
+ context: context.current,
1867
+ currentCoordinates
1868
+ });
1869
+
1870
+ if (newCoordinates) {
1871
+ const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
1872
+ const scrollDelta = {
1873
+ x: 0,
1874
+ y: 0
1875
+ };
1876
+ const {
1877
+ scrollableAncestors
1878
+ } = context.current;
1879
+
1880
+ for (const scrollContainer of scrollableAncestors) {
1881
+ const direction = event.code;
1882
+ const {
1883
+ isTop,
1884
+ isRight,
1885
+ isLeft,
1886
+ isBottom,
1887
+ maxScroll,
1888
+ minScroll
1889
+ } = getScrollPosition(scrollContainer);
1890
+ const scrollElementRect = getScrollElementRect(scrollContainer);
1891
+ const clampedCoordinates = {
1892
+ 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)),
1893
+ 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))
1894
+ };
1895
+ const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
1896
+ const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
1897
+
1898
+ if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
1899
+ const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
1900
+ const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
1901
+
1902
+ if (canScrollToNewCoordinates && !coordinatesDelta.y) {
1903
+ // We don't need to update coordinates, the scroll adjustment alone will trigger
1904
+ // logic to auto-detect the new container we are over
1905
+ scrollContainer.scrollTo({
1906
+ left: newScrollCoordinates,
1907
+ behavior: scrollBehavior
1908
+ });
1909
+ return;
1910
+ }
1911
+
1912
+ if (canScrollToNewCoordinates) {
1913
+ scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
1914
+ } else {
1915
+ scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
1916
+ }
1917
+
1918
+ if (scrollDelta.x) {
1919
+ scrollContainer.scrollBy({
1920
+ left: -scrollDelta.x,
1921
+ behavior: scrollBehavior
1922
+ });
1923
+ }
1924
+
1925
+ break;
1926
+ } else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
1927
+ const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
1928
+ const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
1929
+
1930
+ if (canScrollToNewCoordinates && !coordinatesDelta.x) {
1931
+ // We don't need to update coordinates, the scroll adjustment alone will trigger
1932
+ // logic to auto-detect the new container we are over
1933
+ scrollContainer.scrollTo({
1934
+ top: newScrollCoordinates,
1935
+ behavior: scrollBehavior
1936
+ });
1937
+ return;
1938
+ }
1939
+
1940
+ if (canScrollToNewCoordinates) {
1941
+ scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
1942
+ } else {
1943
+ scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
1944
+ }
1945
+
1946
+ if (scrollDelta.y) {
1947
+ scrollContainer.scrollBy({
1948
+ top: -scrollDelta.y,
1949
+ behavior: scrollBehavior
1950
+ });
1951
+ }
1952
+
1953
+ break;
1954
+ }
1955
+ }
1956
+
1957
+ this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
1958
+ }
1959
+ }
1960
+ }
1961
+
1962
+ handleMove(event, coordinates) {
1963
+ const {
1964
+ onMove
1965
+ } = this.props;
1966
+ event.preventDefault();
1967
+ onMove(coordinates);
1968
+ }
1969
+
1970
+ handleEnd(event) {
1971
+ const {
1972
+ onEnd
1973
+ } = this.props;
1974
+ event.preventDefault();
1975
+ this.detach();
1976
+ onEnd();
1977
+ }
1978
+
1979
+ handleCancel(event) {
1980
+ const {
1981
+ onCancel
1982
+ } = this.props;
1983
+ event.preventDefault();
1984
+ this.detach();
1985
+ onCancel();
1986
+ }
1987
+
1988
+ detach() {
1989
+ this.listeners.removeAll();
1990
+ this.windowListeners.removeAll();
1991
+ }
1992
+
1993
+ }
1994
+ KeyboardSensor.activators = [{
1995
+ eventName: 'onKeyDown',
1996
+ handler: (event, _ref, _ref2) => {
1997
+ let {
1998
+ keyboardCodes = defaultKeyboardCodes,
1999
+ onActivation
2000
+ } = _ref;
2001
+ let {
2002
+ active
2003
+ } = _ref2;
2004
+ const {
2005
+ code
2006
+ } = event.nativeEvent;
2007
+
2008
+ if (keyboardCodes.start.includes(code)) {
2009
+ const activator = active.activatorNode.current;
2010
+
2011
+ if (activator && event.target !== activator) {
2012
+ return false;
2013
+ }
2014
+
2015
+ event.preventDefault();
2016
+ onActivation == null ? void 0 : onActivation({
2017
+ event: event.nativeEvent
2018
+ });
2019
+ return true;
2020
+ }
2021
+
2022
+ return false;
2023
+ }
2024
+ }];
2025
+
2026
+ function isDistanceConstraint(constraint) {
2027
+ return Boolean(constraint && 'distance' in constraint);
2028
+ }
2029
+
2030
+ function isDelayConstraint(constraint) {
2031
+ return Boolean(constraint && 'delay' in constraint);
2032
+ }
2033
+
2034
+ class AbstractPointerSensor {
2035
+ constructor(props, events, listenerTarget) {
2036
+ var _getEventCoordinates;
2037
+
2038
+ if (listenerTarget === void 0) {
2039
+ listenerTarget = getEventListenerTarget(props.event.target);
2040
+ }
2041
+
2042
+ this.props = void 0;
2043
+ this.events = void 0;
2044
+ this.autoScrollEnabled = true;
2045
+ this.document = void 0;
2046
+ this.activated = false;
2047
+ this.initialCoordinates = void 0;
2048
+ this.timeoutId = null;
2049
+ this.listeners = void 0;
2050
+ this.documentListeners = void 0;
2051
+ this.windowListeners = void 0;
2052
+ this.props = props;
2053
+ this.events = events;
2054
+ const {
2055
+ event
2056
+ } = props;
2057
+ const {
2058
+ target
2059
+ } = event;
2060
+ this.props = props;
2061
+ this.events = events;
2062
+ this.document = getOwnerDocument(target);
2063
+ this.documentListeners = new Listeners(this.document);
2064
+ this.listeners = new Listeners(listenerTarget);
2065
+ this.windowListeners = new Listeners(getWindow(target));
2066
+ this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
2067
+ this.handleStart = this.handleStart.bind(this);
2068
+ this.handleMove = this.handleMove.bind(this);
2069
+ this.handleEnd = this.handleEnd.bind(this);
2070
+ this.handleCancel = this.handleCancel.bind(this);
2071
+ this.handleKeydown = this.handleKeydown.bind(this);
2072
+ this.removeTextSelection = this.removeTextSelection.bind(this);
2073
+ this.attach();
2074
+ }
2075
+
2076
+ attach() {
2077
+ const {
2078
+ events,
2079
+ props: {
2080
+ options: {
2081
+ activationConstraint
2082
+ }
2083
+ }
2084
+ } = this;
2085
+ this.listeners.add(events.move.name, this.handleMove, {
2086
+ passive: false
2087
+ });
2088
+ this.listeners.add(events.end.name, this.handleEnd);
2089
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
2090
+ this.windowListeners.add(EventName.DragStart, preventDefault);
2091
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
2092
+ this.windowListeners.add(EventName.ContextMenu, preventDefault);
2093
+ this.documentListeners.add(EventName.Keydown, this.handleKeydown);
2094
+
2095
+ if (activationConstraint) {
2096
+ if (isDistanceConstraint(activationConstraint)) {
2097
+ return;
2098
+ }
2099
+
2100
+ if (isDelayConstraint(activationConstraint)) {
2101
+ this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
2102
+ return;
2103
+ }
2104
+ }
2105
+
2106
+ this.handleStart();
2107
+ }
2108
+
2109
+ detach() {
2110
+ this.listeners.removeAll();
2111
+ this.windowListeners.removeAll(); // Wait until the next event loop before removing document listeners
2112
+ // This is necessary because we listen for `click` and `selection` events on the document
2113
+
2114
+ setTimeout(this.documentListeners.removeAll, 50);
2115
+
2116
+ if (this.timeoutId !== null) {
2117
+ clearTimeout(this.timeoutId);
2118
+ this.timeoutId = null;
2119
+ }
2120
+ }
2121
+
2122
+ handleStart() {
2123
+ const {
2124
+ initialCoordinates
2125
+ } = this;
2126
+ const {
2127
+ onStart
2128
+ } = this.props;
2129
+
2130
+ if (initialCoordinates) {
2131
+ this.activated = true; // Stop propagation of click events once activation constraints are met
2132
+
2133
+ this.documentListeners.add(EventName.Click, stopPropagation, {
2134
+ capture: true
2135
+ }); // Remove any text selection from the document
2136
+
2137
+ this.removeTextSelection(); // Prevent further text selection while dragging
2138
+
2139
+ this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
2140
+ onStart(initialCoordinates);
2141
+ }
2142
+ }
2143
+
2144
+ handleMove(event) {
2145
+ var _getEventCoordinates2;
2146
+
2147
+ const {
2148
+ activated,
2149
+ initialCoordinates,
2150
+ props
2151
+ } = this;
2152
+ const {
2153
+ onMove,
2154
+ options: {
2155
+ activationConstraint
2156
+ }
2157
+ } = props;
2158
+
2159
+ if (!initialCoordinates) {
2160
+ return;
2161
+ }
2162
+
2163
+ const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
2164
+ const delta = subtract(initialCoordinates, coordinates);
2165
+
2166
+ if (!activated && activationConstraint) {
2167
+ // Constraint validation
2168
+ if (isDelayConstraint(activationConstraint)) {
2169
+ if (hasExceededDistance(delta, activationConstraint.tolerance)) {
2170
+ return this.handleCancel();
2171
+ }
2172
+
2173
+ return;
2174
+ }
2175
+
2176
+ if (isDistanceConstraint(activationConstraint)) {
2177
+ if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
2178
+ return this.handleCancel();
2179
+ }
2180
+
2181
+ if (hasExceededDistance(delta, activationConstraint.distance)) {
2182
+ return this.handleStart();
2183
+ }
2184
+
2185
+ return;
2186
+ }
2187
+ }
2188
+
2189
+ if (event.cancelable) {
2190
+ event.preventDefault();
2191
+ }
2192
+
2193
+ onMove(coordinates);
2194
+ }
2195
+
2196
+ handleEnd() {
2197
+ const {
2198
+ onEnd
2199
+ } = this.props;
2200
+ this.detach();
2201
+ onEnd();
2202
+ }
2203
+
2204
+ handleCancel() {
2205
+ const {
2206
+ onCancel
2207
+ } = this.props;
2208
+ this.detach();
2209
+ onCancel();
2210
+ }
2211
+
2212
+ handleKeydown(event) {
2213
+ if (event.code === KeyboardCode.Esc) {
2214
+ this.handleCancel();
2215
+ }
2216
+ }
2217
+
2218
+ removeTextSelection() {
2219
+ var _this$document$getSel;
2220
+
2221
+ (_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
2222
+ }
2223
+
2224
+ }
2225
+
2226
+ const events = {
2227
+ move: {
2228
+ name: 'pointermove'
2229
+ },
2230
+ end: {
2231
+ name: 'pointerup'
2232
+ }
2233
+ };
2234
+ class PointerSensor extends AbstractPointerSensor {
2235
+ constructor(props) {
2236
+ const {
2237
+ event
2238
+ } = props; // Pointer events stop firing if the target is unmounted while dragging
2239
+ // Therefore we attach listeners to the owner document instead
2240
+
2241
+ const listenerTarget = getOwnerDocument(event.target);
2242
+ super(props, events, listenerTarget);
2243
+ }
2244
+
2245
+ }
2246
+ PointerSensor.activators = [{
2247
+ eventName: 'onPointerDown',
2248
+ handler: (_ref, _ref2) => {
2249
+ let {
2250
+ nativeEvent: event
2251
+ } = _ref;
2252
+ let {
2253
+ onActivation
2254
+ } = _ref2;
2255
+
2256
+ if (!event.isPrimary || event.button !== 0) {
2257
+ return false;
2258
+ }
2259
+
2260
+ onActivation == null ? void 0 : onActivation({
2261
+ event
2262
+ });
2263
+ return true;
2264
+ }
2265
+ }];
2266
+
2267
+ const events$1 = {
2268
+ move: {
2269
+ name: 'mousemove'
2270
+ },
2271
+ end: {
2272
+ name: 'mouseup'
2273
+ }
2274
+ };
2275
+ var MouseButton;
2276
+
2277
+ (function (MouseButton) {
2278
+ MouseButton[MouseButton["RightClick"] = 2] = "RightClick";
2279
+ })(MouseButton || (MouseButton = {}));
2280
+
2281
+ class MouseSensor extends AbstractPointerSensor {
2282
+ constructor(props) {
2283
+ super(props, events$1, getOwnerDocument(props.event.target));
2284
+ }
2285
+
2286
+ }
2287
+ MouseSensor.activators = [{
2288
+ eventName: 'onMouseDown',
2289
+ handler: (_ref, _ref2) => {
2290
+ let {
2291
+ nativeEvent: event
2292
+ } = _ref;
2293
+ let {
2294
+ onActivation
2295
+ } = _ref2;
2296
+
2297
+ if (event.button === MouseButton.RightClick) {
2298
+ return false;
2299
+ }
2300
+
2301
+ onActivation == null ? void 0 : onActivation({
2302
+ event
2303
+ });
2304
+ return true;
2305
+ }
2306
+ }];
2307
+
2308
+ const events$2 = {
2309
+ move: {
2310
+ name: 'touchmove'
2311
+ },
2312
+ end: {
2313
+ name: 'touchend'
2314
+ }
2315
+ };
2316
+ class TouchSensor extends AbstractPointerSensor {
2317
+ constructor(props) {
2318
+ super(props, events$2);
2319
+ }
2320
+
2321
+ static setup() {
2322
+ // Adding a non-capture and non-passive `touchmove` listener in order
2323
+ // to force `event.preventDefault()` calls to work in dynamically added
2324
+ // touchmove event handlers. This is required for iOS Safari.
2325
+ window.addEventListener(events$2.move.name, noop, {
2326
+ capture: false,
2327
+ passive: false
2328
+ });
2329
+ return function teardown() {
2330
+ window.removeEventListener(events$2.move.name, noop);
2331
+ }; // We create a new handler because the teardown function of another sensor
2332
+ // could remove our event listener if we use a referentially equal listener.
2333
+
2334
+ function noop() {}
2335
+ }
2336
+
2337
+ }
2338
+ TouchSensor.activators = [{
2339
+ eventName: 'onTouchStart',
2340
+ handler: (_ref, _ref2) => {
2341
+ let {
2342
+ nativeEvent: event
2343
+ } = _ref;
2344
+ let {
2345
+ onActivation
2346
+ } = _ref2;
2347
+ const {
2348
+ touches
2349
+ } = event;
2350
+
2351
+ if (touches.length > 1) {
2352
+ return false;
2353
+ }
2354
+
2355
+ onActivation == null ? void 0 : onActivation({
2356
+ event
2357
+ });
2358
+ return true;
2359
+ }
2360
+ }];
2361
+
2362
+ var AutoScrollActivator;
2363
+
2364
+ (function (AutoScrollActivator) {
2365
+ AutoScrollActivator[AutoScrollActivator["Pointer"] = 0] = "Pointer";
2366
+ AutoScrollActivator[AutoScrollActivator["DraggableRect"] = 1] = "DraggableRect";
2367
+ })(AutoScrollActivator || (AutoScrollActivator = {}));
2368
+
2369
+ var TraversalOrder;
2370
+
2371
+ (function (TraversalOrder) {
2372
+ TraversalOrder[TraversalOrder["TreeOrder"] = 0] = "TreeOrder";
2373
+ TraversalOrder[TraversalOrder["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
2374
+ })(TraversalOrder || (TraversalOrder = {}));
2375
+
2376
+ function useAutoScroller(_ref) {
2377
+ let {
2378
+ acceleration,
2379
+ activator = AutoScrollActivator.Pointer,
2380
+ canScroll,
2381
+ draggingRect,
2382
+ enabled,
2383
+ interval = 5,
2384
+ order = TraversalOrder.TreeOrder,
2385
+ pointerCoordinates,
2386
+ scrollableAncestors,
2387
+ scrollableAncestorRects,
2388
+ delta,
2389
+ threshold
2390
+ } = _ref;
2391
+ const scrollIntent = useScrollIntent({
2392
+ delta,
2393
+ disabled: !enabled
2394
+ });
2395
+ const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
2396
+ const scrollSpeed = useRef({
2397
+ x: 0,
2398
+ y: 0
2399
+ });
2400
+ const scrollDirection = useRef({
2401
+ x: 0,
2402
+ y: 0
2403
+ });
2404
+ const rect = useMemo(() => {
2405
+ switch (activator) {
2406
+ case AutoScrollActivator.Pointer:
2407
+ return pointerCoordinates ? {
2408
+ top: pointerCoordinates.y,
2409
+ bottom: pointerCoordinates.y,
2410
+ left: pointerCoordinates.x,
2411
+ right: pointerCoordinates.x
2412
+ } : null;
2413
+
2414
+ case AutoScrollActivator.DraggableRect:
2415
+ return draggingRect;
2416
+ }
2417
+ }, [activator, draggingRect, pointerCoordinates]);
2418
+ const scrollContainerRef = useRef(null);
2419
+ const autoScroll = useCallback(() => {
2420
+ const scrollContainer = scrollContainerRef.current;
2421
+
2422
+ if (!scrollContainer) {
2423
+ return;
2424
+ }
2425
+
2426
+ const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
2427
+ const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
2428
+ scrollContainer.scrollBy(scrollLeft, scrollTop);
2429
+ }, []);
2430
+ const sortedScrollableAncestors = useMemo(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
2431
+ useEffect(() => {
2432
+ if (!enabled || !scrollableAncestors.length || !rect) {
2433
+ clearAutoScrollInterval();
2434
+ return;
2435
+ }
2436
+
2437
+ for (const scrollContainer of sortedScrollableAncestors) {
2438
+ if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
2439
+ continue;
2440
+ }
2441
+
2442
+ const index = scrollableAncestors.indexOf(scrollContainer);
2443
+ const scrollContainerRect = scrollableAncestorRects[index];
2444
+
2445
+ if (!scrollContainerRect) {
2446
+ continue;
2447
+ }
2448
+
2449
+ const {
2450
+ direction,
2451
+ speed
2452
+ } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
2453
+
2454
+ for (const axis of ['x', 'y']) {
2455
+ if (!scrollIntent[axis][direction[axis]]) {
2456
+ speed[axis] = 0;
2457
+ direction[axis] = 0;
2458
+ }
2459
+ }
2460
+
2461
+ if (speed.x > 0 || speed.y > 0) {
2462
+ clearAutoScrollInterval();
2463
+ scrollContainerRef.current = scrollContainer;
2464
+ setAutoScrollInterval(autoScroll, interval);
2465
+ scrollSpeed.current = speed;
2466
+ scrollDirection.current = direction;
2467
+ return;
2468
+ }
2469
+ }
2470
+
2471
+ scrollSpeed.current = {
2472
+ x: 0,
2473
+ y: 0
2474
+ };
2475
+ scrollDirection.current = {
2476
+ x: 0,
2477
+ y: 0
2478
+ };
2479
+ clearAutoScrollInterval();
2480
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2481
+ [acceleration, autoScroll, canScroll, clearAutoScrollInterval, enabled, interval, // eslint-disable-next-line react-hooks/exhaustive-deps
2482
+ JSON.stringify(rect), // eslint-disable-next-line react-hooks/exhaustive-deps
2483
+ JSON.stringify(scrollIntent), setAutoScrollInterval, scrollableAncestors, sortedScrollableAncestors, scrollableAncestorRects, // eslint-disable-next-line react-hooks/exhaustive-deps
2484
+ JSON.stringify(threshold)]);
2485
+ }
2486
+ const defaultScrollIntent = {
2487
+ x: {
2488
+ [Direction.Backward]: false,
2489
+ [Direction.Forward]: false
2490
+ },
2491
+ y: {
2492
+ [Direction.Backward]: false,
2493
+ [Direction.Forward]: false
2494
+ }
2495
+ };
2496
+
2497
+ function useScrollIntent(_ref2) {
2498
+ let {
2499
+ delta,
2500
+ disabled
2501
+ } = _ref2;
2502
+ const previousDelta = usePrevious(delta);
2503
+ return useLazyMemo(previousIntent => {
2504
+ if (disabled || !previousDelta || !previousIntent) {
2505
+ // Reset scroll intent tracking when auto-scrolling is disabled
2506
+ return defaultScrollIntent;
2507
+ }
2508
+
2509
+ const direction = {
2510
+ x: Math.sign(delta.x - previousDelta.x),
2511
+ y: Math.sign(delta.y - previousDelta.y)
2512
+ }; // Keep track of the user intent to scroll in each direction for both axis
2513
+
2514
+ return {
2515
+ x: {
2516
+ [Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
2517
+ [Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
2518
+ },
2519
+ y: {
2520
+ [Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
2521
+ [Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
2522
+ }
2523
+ };
2524
+ }, [disabled, delta, previousDelta]);
2525
+ }
2526
+
2527
+ function useCachedNode(draggableNodes, id) {
2528
+ const draggableNode = id !== null ? draggableNodes.get(id) : undefined;
2529
+ const node = draggableNode ? draggableNode.node.current : null;
2530
+ return useLazyMemo(cachedNode => {
2531
+ var _ref;
2532
+
2533
+ if (id === null) {
2534
+ return null;
2535
+ } // In some cases, the draggable node can unmount while dragging
2536
+ // This is the case for virtualized lists. In those situations,
2537
+ // we fall back to the last known value for that node.
2538
+
2539
+
2540
+ return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
2541
+ }, [node, id]);
2542
+ }
2543
+
2544
+ function useCombineActivators(sensors, getSyntheticHandler) {
2545
+ return useMemo(() => sensors.reduce((accumulator, sensor) => {
2546
+ const {
2547
+ sensor: Sensor
2548
+ } = sensor;
2549
+ const sensorActivators = Sensor.activators.map(activator => ({
2550
+ eventName: activator.eventName,
2551
+ handler: getSyntheticHandler(activator.handler, sensor)
2552
+ }));
2553
+ return [...accumulator, ...sensorActivators];
2554
+ }, []), [sensors, getSyntheticHandler]);
2555
+ }
2556
+
2557
+ var MeasuringStrategy;
2558
+
2559
+ (function (MeasuringStrategy) {
2560
+ MeasuringStrategy[MeasuringStrategy["Always"] = 0] = "Always";
2561
+ MeasuringStrategy[MeasuringStrategy["BeforeDragging"] = 1] = "BeforeDragging";
2562
+ MeasuringStrategy[MeasuringStrategy["WhileDragging"] = 2] = "WhileDragging";
2563
+ })(MeasuringStrategy || (MeasuringStrategy = {}));
2564
+
2565
+ var MeasuringFrequency;
2566
+
2567
+ (function (MeasuringFrequency) {
2568
+ MeasuringFrequency["Optimized"] = "optimized";
2569
+ })(MeasuringFrequency || (MeasuringFrequency = {}));
2570
+
2571
+ const defaultValue = /*#__PURE__*/new Map();
2572
+ function useDroppableMeasuring(containers, _ref) {
2573
+ let {
2574
+ dragging,
2575
+ dependencies,
2576
+ config
2577
+ } = _ref;
2578
+ const [queue, setQueue] = useState(null);
2579
+ const {
2580
+ frequency,
2581
+ measure,
2582
+ strategy
2583
+ } = config;
2584
+ const containersRef = useRef(containers);
2585
+ const disabled = isDisabled();
2586
+ const disabledRef = useLatestValue(disabled);
2587
+ const measureDroppableContainers = useCallback(function (ids) {
2588
+ if (ids === void 0) {
2589
+ ids = [];
2590
+ }
2591
+
2592
+ if (disabledRef.current) {
2593
+ return;
2594
+ }
2595
+
2596
+ setQueue(value => {
2597
+ if (value === null) {
2598
+ return ids;
2599
+ }
2600
+
2601
+ return value.concat(ids.filter(id => !value.includes(id)));
2602
+ });
2603
+ }, [disabledRef]);
2604
+ const timeoutId = useRef(null);
2605
+ const droppableRects = useLazyMemo(previousValue => {
2606
+ if (disabled && !dragging) {
2607
+ return defaultValue;
2608
+ }
2609
+
2610
+ if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
2611
+ const map = new Map();
2612
+
2613
+ for (let container of containers) {
2614
+ if (!container) {
2615
+ continue;
2616
+ }
2617
+
2618
+ if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
2619
+ // This container does not need to be re-measured
2620
+ map.set(container.id, container.rect.current);
2621
+ continue;
2622
+ }
2623
+
2624
+ const node = container.node.current;
2625
+ const rect = node ? new Rect(measure(node), node) : null;
2626
+ container.rect.current = rect;
2627
+
2628
+ if (rect) {
2629
+ map.set(container.id, rect);
2630
+ }
2631
+ }
2632
+
2633
+ return map;
2634
+ }
2635
+
2636
+ return previousValue;
2637
+ }, [containers, queue, dragging, disabled, measure]);
2638
+ useEffect(() => {
2639
+ containersRef.current = containers;
2640
+ }, [containers]);
2641
+ useEffect(() => {
2642
+ if (disabled) {
2643
+ return;
2644
+ }
2645
+
2646
+ measureDroppableContainers();
2647
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2648
+ [dragging, disabled]);
2649
+ useEffect(() => {
2650
+ if (queue && queue.length > 0) {
2651
+ setQueue(null);
2652
+ }
2653
+ }, //eslint-disable-next-line react-hooks/exhaustive-deps
2654
+ [JSON.stringify(queue)]);
2655
+ useEffect(() => {
2656
+ if (disabled || typeof frequency !== 'number' || timeoutId.current !== null) {
2657
+ return;
2658
+ }
2659
+
2660
+ timeoutId.current = setTimeout(() => {
2661
+ measureDroppableContainers();
2662
+ timeoutId.current = null;
2663
+ }, frequency);
2664
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2665
+ [frequency, disabled, measureDroppableContainers, ...dependencies]);
2666
+ return {
2667
+ droppableRects,
2668
+ measureDroppableContainers,
2669
+ measuringScheduled: queue != null
2670
+ };
2671
+
2672
+ function isDisabled() {
2673
+ switch (strategy) {
2674
+ case MeasuringStrategy.Always:
2675
+ return false;
2676
+
2677
+ case MeasuringStrategy.BeforeDragging:
2678
+ return dragging;
2679
+
2680
+ default:
2681
+ return !dragging;
2682
+ }
2683
+ }
2684
+ }
2685
+
2686
+ function useInitialValue(value, computeFn) {
2687
+ return useLazyMemo(previousValue => {
2688
+ if (!value) {
2689
+ return null;
2690
+ }
2691
+
2692
+ if (previousValue) {
2693
+ return previousValue;
2694
+ }
2695
+
2696
+ return typeof computeFn === 'function' ? computeFn(value) : value;
2697
+ }, [computeFn, value]);
2698
+ }
2699
+
2700
+ function useInitialRect(node, measure) {
2701
+ return useInitialValue(node, measure);
2702
+ }
2703
+
2704
+ /**
2705
+ * Returns a new MutationObserver instance.
2706
+ * If `MutationObserver` is undefined in the execution environment, returns `undefined`.
2707
+ */
2708
+
2709
+ function useMutationObserver(_ref) {
2710
+ let {
2711
+ callback,
2712
+ disabled
2713
+ } = _ref;
2714
+ const handleMutations = useEvent(callback);
2715
+ const mutationObserver = useMemo(() => {
2716
+ if (disabled || typeof window === 'undefined' || typeof window.MutationObserver === 'undefined') {
2717
+ return undefined;
2718
+ }
2719
+
2720
+ const {
2721
+ MutationObserver
2722
+ } = window;
2723
+ return new MutationObserver(handleMutations);
2724
+ }, [handleMutations, disabled]);
2725
+ useEffect(() => {
2726
+ return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
2727
+ }, [mutationObserver]);
2728
+ return mutationObserver;
2729
+ }
2730
+
2731
+ /**
2732
+ * Returns a new ResizeObserver instance bound to the `onResize` callback.
2733
+ * If `ResizeObserver` is undefined in the execution environment, returns `undefined`.
2734
+ */
2735
+
2736
+ function useResizeObserver(_ref) {
2737
+ let {
2738
+ callback,
2739
+ disabled
2740
+ } = _ref;
2741
+ const handleResize = useEvent(callback);
2742
+ const resizeObserver = useMemo(() => {
2743
+ if (disabled || typeof window === 'undefined' || typeof window.ResizeObserver === 'undefined') {
2744
+ return undefined;
2745
+ }
2746
+
2747
+ const {
2748
+ ResizeObserver
2749
+ } = window;
2750
+ return new ResizeObserver(handleResize);
2751
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2752
+ [disabled]);
2753
+ useEffect(() => {
2754
+ return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
2755
+ }, [resizeObserver]);
2756
+ return resizeObserver;
2757
+ }
2758
+
2759
+ function defaultMeasure(element) {
2760
+ return new Rect(getClientRect(element), element);
2761
+ }
2762
+
2763
+ function useRect(element, measure, fallbackRect) {
2764
+ if (measure === void 0) {
2765
+ measure = defaultMeasure;
2766
+ }
2767
+
2768
+ const [rect, measureRect] = useReducer(reducer, null);
2769
+ const mutationObserver = useMutationObserver({
2770
+ callback(records) {
2771
+ if (!element) {
2772
+ return;
2773
+ }
2774
+
2775
+ for (const record of records) {
2776
+ const {
2777
+ type,
2778
+ target
2779
+ } = record;
2780
+
2781
+ if (type === 'childList' && target instanceof HTMLElement && target.contains(element)) {
2782
+ measureRect();
2783
+ break;
2784
+ }
2785
+ }
2786
+ }
2787
+
2788
+ });
2789
+ const resizeObserver = useResizeObserver({
2790
+ callback: measureRect
2791
+ });
2792
+ useIsomorphicLayoutEffect(() => {
2793
+ measureRect();
2794
+
2795
+ if (element) {
2796
+ resizeObserver == null ? void 0 : resizeObserver.observe(element);
2797
+ mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
2798
+ childList: true,
2799
+ subtree: true
2800
+ });
2801
+ } else {
2802
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2803
+ mutationObserver == null ? void 0 : mutationObserver.disconnect();
2804
+ }
2805
+ }, [element]);
2806
+ return rect;
2807
+
2808
+ function reducer(currentRect) {
2809
+ if (!element) {
2810
+ return null;
2811
+ }
2812
+
2813
+ if (element.isConnected === false) {
2814
+ var _ref;
2815
+
2816
+ // Fall back to last rect we measured if the element is
2817
+ // no longer connected to the DOM.
2818
+ return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
2819
+ }
2820
+
2821
+ const newRect = measure(element);
2822
+
2823
+ if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
2824
+ return currentRect;
2825
+ }
2826
+
2827
+ return newRect;
2828
+ }
2829
+ }
2830
+
2831
+ function useRectDelta(rect) {
2832
+ const initialRect = useInitialValue(rect);
2833
+ return getRectDelta(rect, initialRect);
2834
+ }
2835
+
2836
+ const defaultValue$1 = [];
2837
+ function useScrollableAncestors(node) {
2838
+ const previousNode = useRef(node);
2839
+ const ancestors = useLazyMemo(previousValue => {
2840
+ if (!node) {
2841
+ return defaultValue$1;
2842
+ }
2843
+
2844
+ if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
2845
+ return previousValue;
2846
+ }
2847
+
2848
+ return getScrollableAncestors(node);
2849
+ }, [node]);
2850
+ useEffect(() => {
2851
+ previousNode.current = node;
2852
+ }, [node]);
2853
+ return ancestors;
2854
+ }
2855
+
2856
+ function useScrollOffsets(elements) {
2857
+ const [scrollCoordinates, setScrollCoordinates] = useState(null);
2858
+ const prevElements = useRef(elements); // To-do: Throttle the handleScroll callback
2859
+
2860
+ const handleScroll = useCallback(event => {
2861
+ const scrollingElement = getScrollableElement(event.target);
2862
+
2863
+ if (!scrollingElement) {
2864
+ return;
2865
+ }
2866
+
2867
+ setScrollCoordinates(scrollCoordinates => {
2868
+ if (!scrollCoordinates) {
2869
+ return null;
2870
+ }
2871
+
2872
+ scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));
2873
+ return new Map(scrollCoordinates);
2874
+ });
2875
+ }, []);
2876
+ useEffect(() => {
2877
+ const previousElements = prevElements.current;
2878
+
2879
+ if (elements !== previousElements) {
2880
+ cleanup(previousElements);
2881
+ const entries = elements.map(element => {
2882
+ const scrollableElement = getScrollableElement(element);
2883
+
2884
+ if (scrollableElement) {
2885
+ scrollableElement.addEventListener('scroll', handleScroll, {
2886
+ passive: true
2887
+ });
2888
+ return [scrollableElement, getScrollCoordinates(scrollableElement)];
2889
+ }
2890
+
2891
+ return null;
2892
+ }).filter(entry => entry != null);
2893
+ setScrollCoordinates(entries.length ? new Map(entries) : null);
2894
+ prevElements.current = elements;
2895
+ }
2896
+
2897
+ return () => {
2898
+ cleanup(elements);
2899
+ cleanup(previousElements);
2900
+ };
2901
+
2902
+ function cleanup(elements) {
2903
+ elements.forEach(element => {
2904
+ const scrollableElement = getScrollableElement(element);
2905
+ scrollableElement == null ? void 0 : scrollableElement.removeEventListener('scroll', handleScroll);
2906
+ });
2907
+ }
2908
+ }, [handleScroll, elements]);
2909
+ return useMemo(() => {
2910
+ if (elements.length) {
2911
+ return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
2912
+ }
2913
+
2914
+ return defaultCoordinates;
2915
+ }, [elements, scrollCoordinates]);
2916
+ }
2917
+
2918
+ function useScrollOffsetsDelta(scrollOffsets, dependencies) {
2919
+ if (dependencies === void 0) {
2920
+ dependencies = [];
2921
+ }
2922
+
2923
+ const initialScrollOffsets = useRef(null);
2924
+ useEffect(() => {
2925
+ initialScrollOffsets.current = null;
2926
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2927
+ dependencies);
2928
+ useEffect(() => {
2929
+ const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
2930
+
2931
+ if (hasScrollOffsets && !initialScrollOffsets.current) {
2932
+ initialScrollOffsets.current = scrollOffsets;
2933
+ }
2934
+
2935
+ if (!hasScrollOffsets && initialScrollOffsets.current) {
2936
+ initialScrollOffsets.current = null;
2937
+ }
2938
+ }, [scrollOffsets]);
2939
+ return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
2940
+ }
2941
+
2942
+ function useSensorSetup(sensors) {
2943
+ useEffect(() => {
2944
+ if (!canUseDOM) {
2945
+ return;
2946
+ }
2947
+
2948
+ const teardownFns = sensors.map(_ref => {
2949
+ let {
2950
+ sensor
2951
+ } = _ref;
2952
+ return sensor.setup == null ? void 0 : sensor.setup();
2953
+ });
2954
+ return () => {
2955
+ for (const teardown of teardownFns) {
2956
+ teardown == null ? void 0 : teardown();
2957
+ }
2958
+ };
2959
+ }, // TO-DO: Sensors length could theoretically change which would not be a valid dependency
2960
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2961
+ sensors.map(_ref2 => {
2962
+ let {
2963
+ sensor
2964
+ } = _ref2;
2965
+ return sensor;
2966
+ }));
2967
+ }
2968
+
2969
+ function useSyntheticListeners(listeners, id) {
2970
+ return useMemo(() => {
2971
+ return listeners.reduce((acc, _ref) => {
2972
+ let {
2973
+ eventName,
2974
+ handler
2975
+ } = _ref;
2976
+
2977
+ acc[eventName] = event => {
2978
+ handler(event, id);
2979
+ };
2980
+
2981
+ return acc;
2982
+ }, {});
2983
+ }, [listeners, id]);
2984
+ }
2985
+
2986
+ function useWindowRect(element) {
2987
+ return useMemo(() => element ? getWindowClientRect(element) : null, [element]);
2988
+ }
2989
+
2990
+ const defaultValue$2 = [];
2991
+ function useRects(elements, measure) {
2992
+ if (measure === void 0) {
2993
+ measure = getClientRect;
2994
+ }
2995
+
2996
+ const [firstElement] = elements;
2997
+ const windowRect = useWindowRect(firstElement ? getWindow(firstElement) : null);
2998
+ const [rects, measureRects] = useReducer(reducer, defaultValue$2);
2999
+ const resizeObserver = useResizeObserver({
3000
+ callback: measureRects
3001
+ });
3002
+
3003
+ if (elements.length > 0 && rects === defaultValue$2) {
3004
+ measureRects();
3005
+ }
3006
+
3007
+ useIsomorphicLayoutEffect(() => {
3008
+ if (elements.length) {
3009
+ elements.forEach(element => resizeObserver == null ? void 0 : resizeObserver.observe(element));
3010
+ } else {
3011
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
3012
+ measureRects();
3013
+ }
3014
+ }, [elements]);
3015
+ return rects;
3016
+
3017
+ function reducer() {
3018
+ if (!elements.length) {
3019
+ return defaultValue$2;
3020
+ }
3021
+
3022
+ return elements.map(element => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
3023
+ }
3024
+ }
3025
+
3026
+ function getMeasurableNode(node) {
3027
+ if (!node) {
3028
+ return null;
3029
+ }
3030
+
3031
+ if (node.children.length > 1) {
3032
+ return node;
3033
+ }
3034
+
3035
+ const firstChild = node.children[0];
3036
+ return isHTMLElement(firstChild) ? firstChild : node;
3037
+ }
3038
+
3039
+ function useDragOverlayMeasuring(_ref) {
3040
+ let {
3041
+ measure
3042
+ } = _ref;
3043
+ const [rect, setRect] = useState(null);
3044
+ const handleResize = useCallback(entries => {
3045
+ for (const {
3046
+ target
3047
+ } of entries) {
3048
+ if (isHTMLElement(target)) {
3049
+ setRect(rect => {
3050
+ const newRect = measure(target);
3051
+ return rect ? { ...rect,
3052
+ width: newRect.width,
3053
+ height: newRect.height
3054
+ } : newRect;
3055
+ });
3056
+ break;
3057
+ }
3058
+ }
3059
+ }, [measure]);
3060
+ const resizeObserver = useResizeObserver({
3061
+ callback: handleResize
3062
+ });
3063
+ const handleNodeChange = useCallback(element => {
3064
+ const node = getMeasurableNode(element);
3065
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
3066
+
3067
+ if (node) {
3068
+ resizeObserver == null ? void 0 : resizeObserver.observe(node);
3069
+ }
3070
+
3071
+ setRect(node ? measure(node) : null);
3072
+ }, [measure, resizeObserver]);
3073
+ const [nodeRef, setRef] = useNodeRef(handleNodeChange);
3074
+ return useMemo(() => ({
3075
+ nodeRef,
3076
+ rect,
3077
+ setRef
3078
+ }), [rect, nodeRef, setRef]);
3079
+ }
3080
+
3081
+ const defaultSensors = [{
3082
+ sensor: PointerSensor,
3083
+ options: {}
3084
+ }, {
3085
+ sensor: KeyboardSensor,
3086
+ options: {}
3087
+ }];
3088
+ const defaultData = {
3089
+ current: {}
3090
+ };
3091
+ const defaultMeasuringConfiguration = {
3092
+ draggable: {
3093
+ measure: getTransformAgnosticClientRect
3094
+ },
3095
+ droppable: {
3096
+ measure: getTransformAgnosticClientRect,
3097
+ strategy: MeasuringStrategy.WhileDragging,
3098
+ frequency: MeasuringFrequency.Optimized
3099
+ },
3100
+ dragOverlay: {
3101
+ measure: getClientRect
3102
+ }
3103
+ };
3104
+
3105
+ class DroppableContainersMap extends Map {
3106
+ get(id) {
3107
+ var _super$get;
3108
+
3109
+ return id != null ? (_super$get = super.get(id)) != null ? _super$get : undefined : undefined;
3110
+ }
3111
+
3112
+ toArray() {
3113
+ return Array.from(this.values());
3114
+ }
3115
+
3116
+ getEnabled() {
3117
+ return this.toArray().filter(_ref => {
3118
+ let {
3119
+ disabled
3120
+ } = _ref;
3121
+ return !disabled;
3122
+ });
3123
+ }
3124
+
3125
+ getNodeFor(id) {
3126
+ var _this$get$node$curren, _this$get;
3127
+
3128
+ return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : undefined;
3129
+ }
3130
+
3131
+ }
3132
+
3133
+ const defaultPublicContext = {
3134
+ activatorEvent: null,
3135
+ active: null,
3136
+ activeNode: null,
3137
+ activeNodeRect: null,
3138
+ collisions: null,
3139
+ containerNodeRect: null,
3140
+ draggableNodes: /*#__PURE__*/new Map(),
3141
+ droppableRects: /*#__PURE__*/new Map(),
3142
+ droppableContainers: /*#__PURE__*/new DroppableContainersMap(),
3143
+ over: null,
3144
+ dragOverlay: {
3145
+ nodeRef: {
3146
+ current: null
3147
+ },
3148
+ rect: null,
3149
+ setRef: noop
3150
+ },
3151
+ scrollableAncestors: [],
3152
+ scrollableAncestorRects: [],
3153
+ measuringConfiguration: defaultMeasuringConfiguration,
3154
+ measureDroppableContainers: noop,
3155
+ windowRect: null,
3156
+ measuringScheduled: false
3157
+ };
3158
+ const defaultInternalContext = {
3159
+ activatorEvent: null,
3160
+ activators: [],
3161
+ active: null,
3162
+ activeNodeRect: null,
3163
+ ariaDescribedById: {
3164
+ draggable: ''
3165
+ },
3166
+ dispatch: noop,
3167
+ draggableNodes: /*#__PURE__*/new Map(),
3168
+ over: null,
3169
+ measureDroppableContainers: noop
3170
+ };
3171
+ const InternalContext = /*#__PURE__*/createContext(defaultInternalContext);
3172
+ const PublicContext = /*#__PURE__*/createContext(defaultPublicContext);
3173
+
3174
+ function getInitialState() {
3175
+ return {
3176
+ draggable: {
3177
+ active: null,
3178
+ initialCoordinates: {
3179
+ x: 0,
3180
+ y: 0
3181
+ },
3182
+ nodes: new Map(),
3183
+ translate: {
3184
+ x: 0,
3185
+ y: 0
3186
+ }
3187
+ },
3188
+ droppable: {
3189
+ containers: new DroppableContainersMap()
3190
+ }
3191
+ };
3192
+ }
3193
+ function reducer(state, action) {
3194
+ switch (action.type) {
3195
+ case Action.DragStart:
3196
+ return { ...state,
3197
+ draggable: { ...state.draggable,
3198
+ initialCoordinates: action.initialCoordinates,
3199
+ active: action.active
3200
+ }
3201
+ };
3202
+
3203
+ case Action.DragMove:
3204
+ if (!state.draggable.active) {
3205
+ return state;
3206
+ }
3207
+
3208
+ return { ...state,
3209
+ draggable: { ...state.draggable,
3210
+ translate: {
3211
+ x: action.coordinates.x - state.draggable.initialCoordinates.x,
3212
+ y: action.coordinates.y - state.draggable.initialCoordinates.y
3213
+ }
3214
+ }
3215
+ };
3216
+
3217
+ case Action.DragEnd:
3218
+ case Action.DragCancel:
3219
+ return { ...state,
3220
+ draggable: { ...state.draggable,
3221
+ active: null,
3222
+ initialCoordinates: {
3223
+ x: 0,
3224
+ y: 0
3225
+ },
3226
+ translate: {
3227
+ x: 0,
3228
+ y: 0
3229
+ }
3230
+ }
3231
+ };
3232
+
3233
+ case Action.RegisterDroppable:
3234
+ {
3235
+ const {
3236
+ element
3237
+ } = action;
3238
+ const {
3239
+ id
3240
+ } = element;
3241
+ const containers = new DroppableContainersMap(state.droppable.containers);
3242
+ containers.set(id, element);
3243
+ return { ...state,
3244
+ droppable: { ...state.droppable,
3245
+ containers
3246
+ }
3247
+ };
3248
+ }
3249
+
3250
+ case Action.SetDroppableDisabled:
3251
+ {
3252
+ const {
3253
+ id,
3254
+ key,
3255
+ disabled
3256
+ } = action;
3257
+ const element = state.droppable.containers.get(id);
3258
+
3259
+ if (!element || key !== element.key) {
3260
+ return state;
3261
+ }
3262
+
3263
+ const containers = new DroppableContainersMap(state.droppable.containers);
3264
+ containers.set(id, { ...element,
3265
+ disabled
3266
+ });
3267
+ return { ...state,
3268
+ droppable: { ...state.droppable,
3269
+ containers
3270
+ }
3271
+ };
3272
+ }
3273
+
3274
+ case Action.UnregisterDroppable:
3275
+ {
3276
+ const {
3277
+ id,
3278
+ key
3279
+ } = action;
3280
+ const element = state.droppable.containers.get(id);
3281
+
3282
+ if (!element || key !== element.key) {
3283
+ return state;
3284
+ }
3285
+
3286
+ const containers = new DroppableContainersMap(state.droppable.containers);
3287
+ containers.delete(id);
3288
+ return { ...state,
3289
+ droppable: { ...state.droppable,
3290
+ containers
3291
+ }
3292
+ };
3293
+ }
3294
+
3295
+ default:
3296
+ {
3297
+ return state;
3298
+ }
3299
+ }
3300
+ }
3301
+
3302
+ function RestoreFocus(_ref) {
3303
+ let {
3304
+ disabled
3305
+ } = _ref;
3306
+ const {
3307
+ active,
3308
+ activatorEvent,
3309
+ draggableNodes
3310
+ } = useContext(InternalContext);
3311
+ const previousActivatorEvent = usePrevious(activatorEvent);
3312
+ const previousActiveId = usePrevious(active == null ? void 0 : active.id); // Restore keyboard focus on the activator node
3313
+
3314
+ useEffect(() => {
3315
+ if (disabled) {
3316
+ return;
3317
+ }
3318
+
3319
+ if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
3320
+ if (!isKeyboardEvent(previousActivatorEvent)) {
3321
+ return;
3322
+ }
3323
+
3324
+ if (document.activeElement === previousActivatorEvent.target) {
3325
+ // No need to restore focus
3326
+ return;
3327
+ }
3328
+
3329
+ const draggableNode = draggableNodes.get(previousActiveId);
3330
+
3331
+ if (!draggableNode) {
3332
+ return;
3333
+ }
3334
+
3335
+ const {
3336
+ activatorNode,
3337
+ node
3338
+ } = draggableNode;
3339
+
3340
+ if (!activatorNode.current && !node.current) {
3341
+ return;
3342
+ }
3343
+
3344
+ requestAnimationFrame(() => {
3345
+ for (const element of [activatorNode.current, node.current]) {
3346
+ if (!element) {
3347
+ continue;
3348
+ }
3349
+
3350
+ const focusableNode = findFirstFocusableNode(element);
3351
+
3352
+ if (focusableNode) {
3353
+ focusableNode.focus();
3354
+ break;
3355
+ }
3356
+ }
3357
+ });
3358
+ }
3359
+ }, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]);
3360
+ return null;
3361
+ }
3362
+
3363
+ function applyModifiers(modifiers, _ref) {
3364
+ let {
3365
+ transform,
3366
+ ...args
3367
+ } = _ref;
3368
+ return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
3369
+ return modifier({
3370
+ transform: accumulator,
3371
+ ...args
3372
+ });
3373
+ }, transform) : transform;
3374
+ }
3375
+
3376
+ function useMeasuringConfiguration(config) {
3377
+ return useMemo(() => ({
3378
+ draggable: { ...defaultMeasuringConfiguration.draggable,
3379
+ ...(config == null ? void 0 : config.draggable)
3380
+ },
3381
+ droppable: { ...defaultMeasuringConfiguration.droppable,
3382
+ ...(config == null ? void 0 : config.droppable)
3383
+ },
3384
+ dragOverlay: { ...defaultMeasuringConfiguration.dragOverlay,
3385
+ ...(config == null ? void 0 : config.dragOverlay)
3386
+ }
3387
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
3388
+ [config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]);
3389
+ }
3390
+
3391
+ function useLayoutShiftScrollCompensation(_ref) {
3392
+ let {
3393
+ activeNode,
3394
+ measure,
3395
+ initialRect,
3396
+ config = true
3397
+ } = _ref;
3398
+ const initialized = useRef(false);
3399
+ const {
3400
+ x,
3401
+ y
3402
+ } = typeof config === 'boolean' ? {
3403
+ x: config,
3404
+ y: config
3405
+ } : config;
3406
+ useIsomorphicLayoutEffect(() => {
3407
+ const disabled = !x && !y;
3408
+
3409
+ if (disabled || !activeNode) {
3410
+ initialized.current = false;
3411
+ return;
3412
+ }
3413
+
3414
+ if (initialized.current || !initialRect) {
3415
+ // Return early if layout shift scroll compensation was already attempted
3416
+ // or if there is no initialRect to compare to.
3417
+ return;
3418
+ } // Get the most up to date node ref for the active draggable
3419
+
3420
+
3421
+ const node = activeNode == null ? void 0 : activeNode.node.current;
3422
+
3423
+ if (!node || node.isConnected === false) {
3424
+ // Return early if there is no attached node ref or if the node is
3425
+ // disconnected from the document.
3426
+ return;
3427
+ }
3428
+
3429
+ const rect = measure(node);
3430
+ const rectDelta = getRectDelta(rect, initialRect);
3431
+
3432
+ if (!x) {
3433
+ rectDelta.x = 0;
3434
+ }
3435
+
3436
+ if (!y) {
3437
+ rectDelta.y = 0;
3438
+ } // Only perform layout shift scroll compensation once
3439
+
3440
+
3441
+ initialized.current = true;
3442
+
3443
+ if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
3444
+ const firstScrollableAncestor = getFirstScrollableAncestor(node);
3445
+
3446
+ if (firstScrollableAncestor) {
3447
+ firstScrollableAncestor.scrollBy({
3448
+ top: rectDelta.y,
3449
+ left: rectDelta.x
3450
+ });
3451
+ }
3452
+ }
3453
+ }, [activeNode, x, y, initialRect, measure]);
3454
+ }
3455
+
3456
+ const ActiveDraggableContext = /*#__PURE__*/createContext({ ...defaultCoordinates,
3457
+ scaleX: 1,
3458
+ scaleY: 1
3459
+ });
3460
+ var Status;
3461
+
3462
+ (function (Status) {
3463
+ Status[Status["Uninitialized"] = 0] = "Uninitialized";
3464
+ Status[Status["Initializing"] = 1] = "Initializing";
3465
+ Status[Status["Initialized"] = 2] = "Initialized";
3466
+ })(Status || (Status = {}));
3467
+
3468
+ const DndContext = /*#__PURE__*/memo(function DndContext(_ref) {
3469
+ var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
3470
+
3471
+ let {
3472
+ id,
3473
+ accessibility,
3474
+ autoScroll = true,
3475
+ children,
3476
+ sensors = defaultSensors,
3477
+ collisionDetection = rectIntersection,
3478
+ measuring,
3479
+ modifiers,
3480
+ ...props
3481
+ } = _ref;
3482
+ const store = useReducer(reducer, undefined, getInitialState);
3483
+ const [state, dispatch] = store;
3484
+ const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
3485
+ const [status, setStatus] = useState(Status.Uninitialized);
3486
+ const isInitialized = status === Status.Initialized;
3487
+ const {
3488
+ draggable: {
3489
+ active: activeId,
3490
+ nodes: draggableNodes,
3491
+ translate
3492
+ },
3493
+ droppable: {
3494
+ containers: droppableContainers
3495
+ }
3496
+ } = state;
3497
+ const node = activeId ? draggableNodes.get(activeId) : null;
3498
+ const activeRects = useRef({
3499
+ initial: null,
3500
+ translated: null
3501
+ });
3502
+ const active = useMemo(() => {
3503
+ var _node$data;
3504
+
3505
+ return activeId != null ? {
3506
+ id: activeId,
3507
+ // It's possible for the active node to unmount while dragging
3508
+ data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
3509
+ rect: activeRects
3510
+ } : null;
3511
+ }, [activeId, node]);
3512
+ const activeRef = useRef(null);
3513
+ const [activeSensor, setActiveSensor] = useState(null);
3514
+ const [activatorEvent, setActivatorEvent] = useState(null);
3515
+ const latestProps = useLatestValue(props, Object.values(props));
3516
+ const draggableDescribedById = useUniqueId("DndDescribedBy", id);
3517
+ const enabledDroppableContainers = useMemo(() => droppableContainers.getEnabled(), [droppableContainers]);
3518
+ const measuringConfiguration = useMeasuringConfiguration(measuring);
3519
+ const {
3520
+ droppableRects,
3521
+ measureDroppableContainers,
3522
+ measuringScheduled
3523
+ } = useDroppableMeasuring(enabledDroppableContainers, {
3524
+ dragging: isInitialized,
3525
+ dependencies: [translate.x, translate.y],
3526
+ config: measuringConfiguration.droppable
3527
+ });
3528
+ const activeNode = useCachedNode(draggableNodes, activeId);
3529
+ const activationCoordinates = useMemo(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
3530
+ const autoScrollOptions = getAutoScrollerOptions();
3531
+ const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
3532
+ useLayoutShiftScrollCompensation({
3533
+ activeNode: activeId ? draggableNodes.get(activeId) : null,
3534
+ config: autoScrollOptions.layoutShiftCompensation,
3535
+ initialRect: initialActiveNodeRect,
3536
+ measure: measuringConfiguration.draggable.measure
3537
+ });
3538
+ const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
3539
+ const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
3540
+ const sensorContext = useRef({
3541
+ activatorEvent: null,
3542
+ active: null,
3543
+ activeNode,
3544
+ collisionRect: null,
3545
+ collisions: null,
3546
+ droppableRects,
3547
+ draggableNodes,
3548
+ draggingNode: null,
3549
+ draggingNodeRect: null,
3550
+ droppableContainers,
3551
+ over: null,
3552
+ scrollableAncestors: [],
3553
+ scrollAdjustedTranslate: null
3554
+ });
3555
+ const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
3556
+ const dragOverlay = useDragOverlayMeasuring({
3557
+ measure: measuringConfiguration.dragOverlay.measure
3558
+ }); // Use the rect of the drag overlay if it is mounted
3559
+
3560
+ const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
3561
+ const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
3562
+ const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect); // The delta between the previous and new position of the draggable node
3563
+ // is only relevant when there is no drag overlay
3564
+
3565
+ const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect); // Get the window rect of the dragging node
3566
+
3567
+ const windowRect = useWindowRect(draggingNode ? getWindow(draggingNode) : null); // Get scrollable ancestors of the dragging node
3568
+
3569
+ const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
3570
+ const scrollableAncestorRects = useRects(scrollableAncestors); // Apply modifiers
3571
+
3572
+ const modifiedTranslate = applyModifiers(modifiers, {
3573
+ transform: {
3574
+ x: translate.x - nodeRectDelta.x,
3575
+ y: translate.y - nodeRectDelta.y,
3576
+ scaleX: 1,
3577
+ scaleY: 1
3578
+ },
3579
+ activatorEvent,
3580
+ active,
3581
+ activeNodeRect,
3582
+ containerNodeRect,
3583
+ draggingNodeRect,
3584
+ over: sensorContext.current.over,
3585
+ overlayNodeRect: dragOverlay.rect,
3586
+ scrollableAncestors,
3587
+ scrollableAncestorRects,
3588
+ windowRect
3589
+ });
3590
+ const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
3591
+ const scrollOffsets = useScrollOffsets(scrollableAncestors); // Represents the scroll delta since dragging was initiated
3592
+
3593
+ const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets); // Represents the scroll delta since the last time the active node rect was measured
3594
+
3595
+ const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
3596
+ const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
3597
+ const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
3598
+ const collisions = active && collisionRect ? collisionDetection({
3599
+ active,
3600
+ collisionRect,
3601
+ droppableRects,
3602
+ droppableContainers: enabledDroppableContainers,
3603
+ pointerCoordinates
3604
+ }) : null;
3605
+ const overId = getFirstCollision(collisions, 'id');
3606
+ const [over, setOver] = useState(null); // When there is no drag overlay used, we need to account for the
3607
+ // window scroll delta
3608
+
3609
+ const appliedTranslate = usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta);
3610
+ const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
3611
+ const instantiateSensor = useCallback((event, _ref2) => {
3612
+ let {
3613
+ sensor: Sensor,
3614
+ options
3615
+ } = _ref2;
3616
+
3617
+ if (activeRef.current == null) {
3618
+ return;
3619
+ }
3620
+
3621
+ const activeNode = draggableNodes.get(activeRef.current);
3622
+
3623
+ if (!activeNode) {
3624
+ return;
3625
+ }
3626
+
3627
+ const activatorEvent = event.nativeEvent;
3628
+ const sensorInstance = new Sensor({
3629
+ active: activeRef.current,
3630
+ activeNode,
3631
+ event: activatorEvent,
3632
+ options,
3633
+ // Sensors need to be instantiated with refs for arguments that change over time
3634
+ // otherwise they are frozen in time with the stale arguments
3635
+ context: sensorContext,
3636
+
3637
+ onStart(initialCoordinates) {
3638
+ const id = activeRef.current;
3639
+
3640
+ if (id == null) {
3641
+ return;
3642
+ }
3643
+
3644
+ const draggableNode = draggableNodes.get(id);
3645
+
3646
+ if (!draggableNode) {
3647
+ return;
3648
+ }
3649
+
3650
+ const {
3651
+ onDragStart
3652
+ } = latestProps.current;
3653
+ const event = {
3654
+ active: {
3655
+ id,
3656
+ data: draggableNode.data,
3657
+ rect: activeRects
3658
+ }
3659
+ };
3660
+ unstable_batchedUpdates(() => {
3661
+ onDragStart == null ? void 0 : onDragStart(event);
3662
+ setStatus(Status.Initializing);
3663
+ dispatch({
3664
+ type: Action.DragStart,
3665
+ initialCoordinates,
3666
+ active: id
3667
+ });
3668
+ dispatchMonitorEvent({
3669
+ type: 'onDragStart',
3670
+ event
3671
+ });
3672
+ });
3673
+ },
3674
+
3675
+ onMove(coordinates) {
3676
+ dispatch({
3677
+ type: Action.DragMove,
3678
+ coordinates
3679
+ });
3680
+ },
3681
+
3682
+ onEnd: createHandler(Action.DragEnd),
3683
+ onCancel: createHandler(Action.DragCancel)
3684
+ });
3685
+ unstable_batchedUpdates(() => {
3686
+ setActiveSensor(sensorInstance);
3687
+ setActivatorEvent(event.nativeEvent);
3688
+ });
3689
+
3690
+ function createHandler(type) {
3691
+ return async function handler() {
3692
+ const {
3693
+ active,
3694
+ collisions,
3695
+ over,
3696
+ scrollAdjustedTranslate
3697
+ } = sensorContext.current;
3698
+ let event = null;
3699
+
3700
+ if (active && scrollAdjustedTranslate) {
3701
+ const {
3702
+ cancelDrop
3703
+ } = latestProps.current;
3704
+ event = {
3705
+ activatorEvent,
3706
+ active: active,
3707
+ collisions,
3708
+ delta: scrollAdjustedTranslate,
3709
+ over
3710
+ };
3711
+
3712
+ if (type === Action.DragEnd && typeof cancelDrop === 'function') {
3713
+ const shouldCancel = await Promise.resolve(cancelDrop(event));
3714
+
3715
+ if (shouldCancel) {
3716
+ type = Action.DragCancel;
3717
+ }
3718
+ }
3719
+ }
3720
+
3721
+ activeRef.current = null;
3722
+ unstable_batchedUpdates(() => {
3723
+ dispatch({
3724
+ type
3725
+ });
3726
+ setStatus(Status.Uninitialized);
3727
+ setOver(null);
3728
+ setActiveSensor(null);
3729
+ setActivatorEvent(null);
3730
+ const eventName = type === Action.DragEnd ? 'onDragEnd' : 'onDragCancel';
3731
+
3732
+ if (event) {
3733
+ const handler = latestProps.current[eventName];
3734
+ handler == null ? void 0 : handler(event);
3735
+ dispatchMonitorEvent({
3736
+ type: eventName,
3737
+ event
3738
+ });
3739
+ }
3740
+ });
3741
+ };
3742
+ }
3743
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3744
+ [draggableNodes]);
3745
+ const bindActivatorToSensorInstantiator = useCallback((handler, sensor) => {
3746
+ return (event, active) => {
3747
+ const nativeEvent = event.nativeEvent;
3748
+ const activeDraggableNode = draggableNodes.get(active);
3749
+
3750
+ if ( // Another sensor is already instantiating
3751
+ activeRef.current !== null || // No active draggable
3752
+ !activeDraggableNode || // Event has already been captured
3753
+ nativeEvent.dndKit || nativeEvent.defaultPrevented) {
3754
+ return;
3755
+ }
3756
+
3757
+ const activationContext = {
3758
+ active: activeDraggableNode
3759
+ };
3760
+ const shouldActivate = handler(event, sensor.options, activationContext);
3761
+
3762
+ if (shouldActivate === true) {
3763
+ nativeEvent.dndKit = {
3764
+ capturedBy: sensor.sensor
3765
+ };
3766
+ activeRef.current = active;
3767
+ instantiateSensor(event, sensor);
3768
+ }
3769
+ };
3770
+ }, [draggableNodes, instantiateSensor]);
3771
+ const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
3772
+ useSensorSetup(sensors);
3773
+ useIsomorphicLayoutEffect(() => {
3774
+ if (activeNodeRect && status === Status.Initializing) {
3775
+ setStatus(Status.Initialized);
3776
+ }
3777
+ }, [activeNodeRect, status]);
3778
+ useEffect(() => {
3779
+ const {
3780
+ onDragMove
3781
+ } = latestProps.current;
3782
+ const {
3783
+ active,
3784
+ activatorEvent,
3785
+ collisions,
3786
+ over
3787
+ } = sensorContext.current;
3788
+
3789
+ if (!active || !activatorEvent) {
3790
+ return;
3791
+ }
3792
+
3793
+ const event = {
3794
+ active,
3795
+ activatorEvent,
3796
+ collisions,
3797
+ delta: {
3798
+ x: scrollAdjustedTranslate.x,
3799
+ y: scrollAdjustedTranslate.y
3800
+ },
3801
+ over
3802
+ };
3803
+ unstable_batchedUpdates(() => {
3804
+ onDragMove == null ? void 0 : onDragMove(event);
3805
+ dispatchMonitorEvent({
3806
+ type: 'onDragMove',
3807
+ event
3808
+ });
3809
+ });
3810
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3811
+ [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]);
3812
+ useEffect(() => {
3813
+ const {
3814
+ active,
3815
+ activatorEvent,
3816
+ collisions,
3817
+ droppableContainers,
3818
+ scrollAdjustedTranslate
3819
+ } = sensorContext.current;
3820
+
3821
+ if (!active || activeRef.current == null || !activatorEvent || !scrollAdjustedTranslate) {
3822
+ return;
3823
+ }
3824
+
3825
+ const {
3826
+ onDragOver
3827
+ } = latestProps.current;
3828
+ const overContainer = droppableContainers.get(overId);
3829
+ const over = overContainer && overContainer.rect.current ? {
3830
+ id: overContainer.id,
3831
+ rect: overContainer.rect.current,
3832
+ data: overContainer.data,
3833
+ disabled: overContainer.disabled
3834
+ } : null;
3835
+ const event = {
3836
+ active,
3837
+ activatorEvent,
3838
+ collisions,
3839
+ delta: {
3840
+ x: scrollAdjustedTranslate.x,
3841
+ y: scrollAdjustedTranslate.y
3842
+ },
3843
+ over
3844
+ };
3845
+ unstable_batchedUpdates(() => {
3846
+ setOver(over);
3847
+ onDragOver == null ? void 0 : onDragOver(event);
3848
+ dispatchMonitorEvent({
3849
+ type: 'onDragOver',
3850
+ event
3851
+ });
3852
+ });
3853
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3854
+ [overId]);
3855
+ useIsomorphicLayoutEffect(() => {
3856
+ sensorContext.current = {
3857
+ activatorEvent,
3858
+ active,
3859
+ activeNode,
3860
+ collisionRect,
3861
+ collisions,
3862
+ droppableRects,
3863
+ draggableNodes,
3864
+ draggingNode,
3865
+ draggingNodeRect,
3866
+ droppableContainers,
3867
+ over,
3868
+ scrollableAncestors,
3869
+ scrollAdjustedTranslate
3870
+ };
3871
+ activeRects.current = {
3872
+ initial: draggingNodeRect,
3873
+ translated: collisionRect
3874
+ };
3875
+ }, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
3876
+ useAutoScroller({ ...autoScrollOptions,
3877
+ delta: translate,
3878
+ draggingRect: collisionRect,
3879
+ pointerCoordinates,
3880
+ scrollableAncestors,
3881
+ scrollableAncestorRects
3882
+ });
3883
+ const publicContext = useMemo(() => {
3884
+ const context = {
3885
+ active,
3886
+ activeNode,
3887
+ activeNodeRect,
3888
+ activatorEvent,
3889
+ collisions,
3890
+ containerNodeRect,
3891
+ dragOverlay,
3892
+ draggableNodes,
3893
+ droppableContainers,
3894
+ droppableRects,
3895
+ over,
3896
+ measureDroppableContainers,
3897
+ scrollableAncestors,
3898
+ scrollableAncestorRects,
3899
+ measuringConfiguration,
3900
+ measuringScheduled,
3901
+ windowRect
3902
+ };
3903
+ return context;
3904
+ }, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
3905
+ const internalContext = useMemo(() => {
3906
+ const context = {
3907
+ activatorEvent,
3908
+ activators,
3909
+ active,
3910
+ activeNodeRect,
3911
+ ariaDescribedById: {
3912
+ draggable: draggableDescribedById
3913
+ },
3914
+ dispatch,
3915
+ draggableNodes,
3916
+ over,
3917
+ measureDroppableContainers
3918
+ };
3919
+ return context;
3920
+ }, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
3921
+ return React.createElement(DndMonitorContext.Provider, {
3922
+ value: registerMonitorListener
3923
+ }, React.createElement(InternalContext.Provider, {
3924
+ value: internalContext
3925
+ }, React.createElement(PublicContext.Provider, {
3926
+ value: publicContext
3927
+ }, React.createElement(ActiveDraggableContext.Provider, {
3928
+ value: transform
3929
+ }, children)), React.createElement(RestoreFocus, {
3930
+ disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
3931
+ })), React.createElement(Accessibility, { ...accessibility,
3932
+ hiddenTextDescribedById: draggableDescribedById
3933
+ }));
3934
+
3935
+ function getAutoScrollerOptions() {
3936
+ const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
3937
+ const autoScrollGloballyDisabled = typeof autoScroll === 'object' ? autoScroll.enabled === false : autoScroll === false;
3938
+ const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
3939
+
3940
+ if (typeof autoScroll === 'object') {
3941
+ return { ...autoScroll,
3942
+ enabled
3943
+ };
3944
+ }
3945
+
3946
+ return {
3947
+ enabled
3948
+ };
3949
+ }
3950
+ });
3951
+
3952
+ const NullContext = /*#__PURE__*/createContext(null);
3953
+ const defaultRole = 'button';
3954
+ const ID_PREFIX$1 = 'Droppable';
3955
+ function useDraggable(_ref) {
3956
+ let {
3957
+ id,
3958
+ data,
3959
+ disabled = false,
3960
+ attributes
3961
+ } = _ref;
3962
+ const key = useUniqueId(ID_PREFIX$1);
3963
+ const {
3964
+ activators,
3965
+ activatorEvent,
3966
+ active,
3967
+ activeNodeRect,
3968
+ ariaDescribedById,
3969
+ draggableNodes,
3970
+ over
3971
+ } = useContext(InternalContext);
3972
+ const {
3973
+ role = defaultRole,
3974
+ roleDescription = 'draggable',
3975
+ tabIndex = 0
3976
+ } = attributes != null ? attributes : {};
3977
+ const isDragging = (active == null ? void 0 : active.id) === id;
3978
+ const transform = useContext(isDragging ? ActiveDraggableContext : NullContext);
3979
+ const [node, setNodeRef] = useNodeRef();
3980
+ const [activatorNode, setActivatorNodeRef] = useNodeRef();
3981
+ const listeners = useSyntheticListeners(activators, id);
3982
+ const dataRef = useLatestValue(data);
3983
+ useIsomorphicLayoutEffect(() => {
3984
+ draggableNodes.set(id, {
3985
+ id,
3986
+ key,
3987
+ node,
3988
+ activatorNode,
3989
+ data: dataRef
3990
+ });
3991
+ return () => {
3992
+ const node = draggableNodes.get(id);
3993
+
3994
+ if (node && node.key === key) {
3995
+ draggableNodes.delete(id);
3996
+ }
3997
+ };
3998
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3999
+ [draggableNodes, id]);
4000
+ const memoizedAttributes = useMemo(() => ({
4001
+ role,
4002
+ tabIndex,
4003
+ 'aria-disabled': disabled,
4004
+ 'aria-pressed': isDragging && role === defaultRole ? true : undefined,
4005
+ 'aria-roledescription': roleDescription,
4006
+ 'aria-describedby': ariaDescribedById.draggable
4007
+ }), [disabled, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]);
4008
+ return {
4009
+ active,
4010
+ activatorEvent,
4011
+ activeNodeRect,
4012
+ attributes: memoizedAttributes,
4013
+ isDragging,
4014
+ listeners: disabled ? undefined : listeners,
4015
+ node,
4016
+ over,
4017
+ setNodeRef,
4018
+ setActivatorNodeRef,
4019
+ transform
4020
+ };
4021
+ }
4022
+
4023
+ function useDndContext() {
4024
+ return useContext(PublicContext);
4025
+ }
4026
+
4027
+ const ID_PREFIX$1$1 = 'Droppable';
4028
+ const defaultResizeObserverConfig = {
4029
+ timeout: 25
4030
+ };
4031
+ function useDroppable(_ref) {
4032
+ let {
4033
+ data,
4034
+ disabled = false,
4035
+ id,
4036
+ resizeObserverConfig
4037
+ } = _ref;
4038
+ const key = useUniqueId(ID_PREFIX$1$1);
4039
+ const {
4040
+ active,
4041
+ dispatch,
4042
+ over,
4043
+ measureDroppableContainers
4044
+ } = useContext(InternalContext);
4045
+ const previous = useRef({
4046
+ disabled
4047
+ });
4048
+ const resizeObserverConnected = useRef(false);
4049
+ const rect = useRef(null);
4050
+ const callbackId = useRef(null);
4051
+ const {
4052
+ disabled: resizeObserverDisabled,
4053
+ updateMeasurementsFor,
4054
+ timeout: resizeObserverTimeout
4055
+ } = { ...defaultResizeObserverConfig,
4056
+ ...resizeObserverConfig
4057
+ };
4058
+ const ids = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
4059
+ const handleResize = useCallback(() => {
4060
+ if (!resizeObserverConnected.current) {
4061
+ // ResizeObserver invokes the `handleResize` callback as soon as `observe` is called,
4062
+ // assuming the element is rendered and displayed.
4063
+ resizeObserverConnected.current = true;
4064
+ return;
4065
+ }
4066
+
4067
+ if (callbackId.current != null) {
4068
+ clearTimeout(callbackId.current);
4069
+ }
4070
+
4071
+ callbackId.current = setTimeout(() => {
4072
+ measureDroppableContainers(Array.isArray(ids.current) ? ids.current : [ids.current]);
4073
+ callbackId.current = null;
4074
+ }, resizeObserverTimeout);
4075
+ }, //eslint-disable-next-line react-hooks/exhaustive-deps
4076
+ [resizeObserverTimeout]);
4077
+ const resizeObserver = useResizeObserver({
4078
+ callback: handleResize,
4079
+ disabled: resizeObserverDisabled || !active
4080
+ });
4081
+ const handleNodeChange = useCallback((newElement, previousElement) => {
4082
+ if (!resizeObserver) {
4083
+ return;
4084
+ }
4085
+
4086
+ if (previousElement) {
4087
+ resizeObserver.unobserve(previousElement);
4088
+ resizeObserverConnected.current = false;
4089
+ }
4090
+
4091
+ if (newElement) {
4092
+ resizeObserver.observe(newElement);
4093
+ }
4094
+ }, [resizeObserver]);
4095
+ const [nodeRef, setNodeRef] = useNodeRef(handleNodeChange);
4096
+ const dataRef = useLatestValue(data);
4097
+ useEffect(() => {
4098
+ if (!resizeObserver || !nodeRef.current) {
4099
+ return;
4100
+ }
4101
+
4102
+ resizeObserver.disconnect();
4103
+ resizeObserverConnected.current = false;
4104
+ resizeObserver.observe(nodeRef.current);
4105
+ }, [nodeRef, resizeObserver]);
4106
+ useIsomorphicLayoutEffect(() => {
4107
+ dispatch({
4108
+ type: Action.RegisterDroppable,
4109
+ element: {
4110
+ id,
4111
+ key,
4112
+ disabled,
4113
+ node: nodeRef,
4114
+ rect,
4115
+ data: dataRef
4116
+ }
4117
+ });
4118
+ return () => dispatch({
4119
+ type: Action.UnregisterDroppable,
4120
+ key,
4121
+ id
4122
+ });
4123
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
4124
+ [id]);
4125
+ useEffect(() => {
4126
+ if (disabled !== previous.current.disabled) {
4127
+ dispatch({
4128
+ type: Action.SetDroppableDisabled,
4129
+ id,
4130
+ key,
4131
+ disabled
4132
+ });
4133
+ previous.current.disabled = disabled;
4134
+ }
4135
+ }, [id, key, disabled, dispatch]);
4136
+ return {
4137
+ active,
4138
+ rect,
4139
+ isOver: (over == null ? void 0 : over.id) === id,
4140
+ node: nodeRef,
4141
+ over,
4142
+ setNodeRef
4143
+ };
4144
+ }
4145
+
4146
+ /**
4147
+ * Move an array item to a different position. Returns a new array with the item moved to the new position.
4148
+ */
4149
+ function arrayMove(array, from, to) {
4150
+ const newArray = array.slice();
4151
+ newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
4152
+ return newArray;
4153
+ }
4154
+
4155
+ function getSortedRects(items, rects) {
4156
+ return items.reduce((accumulator, id, index) => {
4157
+ const rect = rects.get(id);
4158
+
4159
+ if (rect) {
4160
+ accumulator[index] = rect;
4161
+ }
4162
+
4163
+ return accumulator;
4164
+ }, Array(items.length));
4165
+ }
4166
+
4167
+ function isValidIndex(index) {
4168
+ return index !== null && index >= 0;
4169
+ }
4170
+
4171
+ function itemsEqual(a, b) {
4172
+ if (a === b) {
4173
+ return true;
4174
+ }
4175
+
4176
+ if (a.length !== b.length) {
4177
+ return false;
4178
+ }
4179
+
4180
+ for (let i = 0; i < a.length; i++) {
4181
+ if (a[i] !== b[i]) {
4182
+ return false;
4183
+ }
4184
+ }
4185
+
4186
+ return true;
4187
+ }
4188
+
4189
+ function normalizeDisabled(disabled) {
4190
+ if (typeof disabled === 'boolean') {
4191
+ return {
4192
+ draggable: disabled,
4193
+ droppable: disabled
4194
+ };
4195
+ }
4196
+
4197
+ return disabled;
4198
+ }
4199
+
4200
+ const rectSortingStrategy = _ref => {
4201
+ let {
4202
+ rects,
4203
+ activeIndex,
4204
+ overIndex,
4205
+ index
4206
+ } = _ref;
4207
+ const newRects = arrayMove(rects, overIndex, activeIndex);
4208
+ const oldRect = rects[index];
4209
+ const newRect = newRects[index];
4210
+
4211
+ if (!newRect || !oldRect) {
4212
+ return null;
4213
+ }
4214
+
4215
+ return {
4216
+ x: newRect.left - oldRect.left,
4217
+ y: newRect.top - oldRect.top,
4218
+ scaleX: newRect.width / oldRect.width,
4219
+ scaleY: newRect.height / oldRect.height
4220
+ };
4221
+ };
4222
+
4223
+ // To-do: We should be calculating scale transformation
4224
+ const defaultScale$1 = {
4225
+ scaleX: 1,
4226
+ scaleY: 1
4227
+ };
4228
+ const verticalListSortingStrategy = _ref => {
4229
+ var _rects$activeIndex;
4230
+
4231
+ let {
4232
+ activeIndex,
4233
+ activeNodeRect: fallbackActiveRect,
4234
+ index,
4235
+ rects,
4236
+ overIndex
4237
+ } = _ref;
4238
+ const activeNodeRect = (_rects$activeIndex = rects[activeIndex]) != null ? _rects$activeIndex : fallbackActiveRect;
4239
+
4240
+ if (!activeNodeRect) {
4241
+ return null;
4242
+ }
4243
+
4244
+ if (index === activeIndex) {
4245
+ const overIndexRect = rects[overIndex];
4246
+
4247
+ if (!overIndexRect) {
4248
+ return null;
4249
+ }
4250
+
4251
+ return {
4252
+ x: 0,
4253
+ y: activeIndex < overIndex ? overIndexRect.top + overIndexRect.height - (activeNodeRect.top + activeNodeRect.height) : overIndexRect.top - activeNodeRect.top,
4254
+ ...defaultScale$1
4255
+ };
4256
+ }
4257
+
4258
+ const itemGap = getItemGap$1(rects, index, activeIndex);
4259
+
4260
+ if (index > activeIndex && index <= overIndex) {
4261
+ return {
4262
+ x: 0,
4263
+ y: -activeNodeRect.height - itemGap,
4264
+ ...defaultScale$1
4265
+ };
4266
+ }
4267
+
4268
+ if (index < activeIndex && index >= overIndex) {
4269
+ return {
4270
+ x: 0,
4271
+ y: activeNodeRect.height + itemGap,
4272
+ ...defaultScale$1
4273
+ };
4274
+ }
4275
+
4276
+ return {
4277
+ x: 0,
4278
+ y: 0,
4279
+ ...defaultScale$1
4280
+ };
4281
+ };
4282
+
4283
+ function getItemGap$1(clientRects, index, activeIndex) {
4284
+ const currentRect = clientRects[index];
4285
+ const previousRect = clientRects[index - 1];
4286
+ const nextRect = clientRects[index + 1];
4287
+
4288
+ if (!currentRect) {
4289
+ return 0;
4290
+ }
4291
+
4292
+ if (activeIndex < index) {
4293
+ return previousRect ? currentRect.top - (previousRect.top + previousRect.height) : nextRect ? nextRect.top - (currentRect.top + currentRect.height) : 0;
4294
+ }
4295
+
4296
+ return nextRect ? nextRect.top - (currentRect.top + currentRect.height) : previousRect ? currentRect.top - (previousRect.top + previousRect.height) : 0;
4297
+ }
4298
+
4299
+ const ID_PREFIX = 'Sortable';
4300
+ const Context = /*#__PURE__*/React.createContext({
4301
+ activeIndex: -1,
4302
+ containerId: ID_PREFIX,
4303
+ disableTransforms: false,
4304
+ items: [],
4305
+ overIndex: -1,
4306
+ useDragOverlay: false,
4307
+ sortedRects: [],
4308
+ strategy: rectSortingStrategy,
4309
+ disabled: {
4310
+ draggable: false,
4311
+ droppable: false
4312
+ }
4313
+ });
4314
+ function SortableContext(_ref) {
4315
+ let {
4316
+ children,
4317
+ id,
4318
+ items: userDefinedItems,
4319
+ strategy = rectSortingStrategy,
4320
+ disabled: disabledProp = false
4321
+ } = _ref;
4322
+ const {
4323
+ active,
4324
+ dragOverlay,
4325
+ droppableRects,
4326
+ over,
4327
+ measureDroppableContainers
4328
+ } = useDndContext();
4329
+ const containerId = useUniqueId(ID_PREFIX, id);
4330
+ const useDragOverlay = Boolean(dragOverlay.rect !== null);
4331
+ const items = useMemo(() => userDefinedItems.map(item => typeof item === 'object' && 'id' in item ? item.id : item), [userDefinedItems]);
4332
+ const isDragging = active != null;
4333
+ const activeIndex = active ? items.indexOf(active.id) : -1;
4334
+ const overIndex = over ? items.indexOf(over.id) : -1;
4335
+ const previousItemsRef = useRef(items);
4336
+ const itemsHaveChanged = !itemsEqual(items, previousItemsRef.current);
4337
+ const disableTransforms = overIndex !== -1 && activeIndex === -1 || itemsHaveChanged;
4338
+ const disabled = normalizeDisabled(disabledProp);
4339
+ useIsomorphicLayoutEffect(() => {
4340
+ if (itemsHaveChanged && isDragging) {
4341
+ measureDroppableContainers(items);
4342
+ }
4343
+ }, [itemsHaveChanged, items, isDragging, measureDroppableContainers]);
4344
+ useEffect(() => {
4345
+ previousItemsRef.current = items;
4346
+ }, [items]);
4347
+ const contextValue = useMemo(() => ({
4348
+ activeIndex,
4349
+ containerId,
4350
+ disabled,
4351
+ disableTransforms,
4352
+ items,
4353
+ overIndex,
4354
+ useDragOverlay,
4355
+ sortedRects: getSortedRects(items, droppableRects),
4356
+ strategy
4357
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
4358
+ [activeIndex, containerId, disabled.draggable, disabled.droppable, disableTransforms, items, overIndex, droppableRects, useDragOverlay, strategy]);
4359
+ return React.createElement(Context.Provider, {
4360
+ value: contextValue
4361
+ }, children);
4362
+ }
4363
+
4364
+ const defaultNewIndexGetter = _ref => {
4365
+ let {
4366
+ id,
4367
+ items,
4368
+ activeIndex,
4369
+ overIndex
4370
+ } = _ref;
4371
+ return arrayMove(items, activeIndex, overIndex).indexOf(id);
4372
+ };
4373
+ const defaultAnimateLayoutChanges = _ref2 => {
4374
+ let {
4375
+ containerId,
4376
+ isSorting,
4377
+ wasDragging,
4378
+ index,
4379
+ items,
4380
+ newIndex,
4381
+ previousItems,
4382
+ previousContainerId,
4383
+ transition
4384
+ } = _ref2;
4385
+
4386
+ if (!transition || !wasDragging) {
4387
+ return false;
4388
+ }
4389
+
4390
+ if (previousItems !== items && index === newIndex) {
4391
+ return false;
4392
+ }
4393
+
4394
+ if (isSorting) {
4395
+ return true;
4396
+ }
4397
+
4398
+ return newIndex !== index && containerId === previousContainerId;
4399
+ };
4400
+ const defaultTransition = {
4401
+ duration: 200,
4402
+ easing: 'ease'
4403
+ };
4404
+ const transitionProperty = 'transform';
4405
+ const disabledTransition = /*#__PURE__*/CSS.Transition.toString({
4406
+ property: transitionProperty,
4407
+ duration: 0,
4408
+ easing: 'linear'
4409
+ });
4410
+ const defaultAttributes = {
4411
+ roleDescription: 'sortable'
4412
+ };
4413
+
4414
+ /*
4415
+ * When the index of an item changes while sorting,
4416
+ * we need to temporarily disable the transforms
4417
+ */
4418
+
4419
+ function useDerivedTransform(_ref) {
4420
+ let {
4421
+ disabled,
4422
+ index,
4423
+ node,
4424
+ rect
4425
+ } = _ref;
4426
+ const [derivedTransform, setDerivedtransform] = useState(null);
4427
+ const previousIndex = useRef(index);
4428
+ useIsomorphicLayoutEffect(() => {
4429
+ if (!disabled && index !== previousIndex.current && node.current) {
4430
+ const initial = rect.current;
4431
+
4432
+ if (initial) {
4433
+ const current = getClientRect(node.current, {
4434
+ ignoreTransform: true
4435
+ });
4436
+ const delta = {
4437
+ x: initial.left - current.left,
4438
+ y: initial.top - current.top,
4439
+ scaleX: initial.width / current.width,
4440
+ scaleY: initial.height / current.height
4441
+ };
4442
+
4443
+ if (delta.x || delta.y) {
4444
+ setDerivedtransform(delta);
4445
+ }
4446
+ }
4447
+ }
4448
+
4449
+ if (index !== previousIndex.current) {
4450
+ previousIndex.current = index;
4451
+ }
4452
+ }, [disabled, index, node, rect]);
4453
+ useEffect(() => {
4454
+ if (derivedTransform) {
4455
+ setDerivedtransform(null);
4456
+ }
4457
+ }, [derivedTransform]);
4458
+ return derivedTransform;
4459
+ }
4460
+
4461
+ function useSortable(_ref) {
4462
+ let {
4463
+ animateLayoutChanges = defaultAnimateLayoutChanges,
4464
+ attributes: userDefinedAttributes,
4465
+ disabled: localDisabled,
4466
+ data: customData,
4467
+ getNewIndex = defaultNewIndexGetter,
4468
+ id,
4469
+ strategy: localStrategy,
4470
+ resizeObserverConfig,
4471
+ transition = defaultTransition
4472
+ } = _ref;
4473
+ const {
4474
+ items,
4475
+ containerId,
4476
+ activeIndex,
4477
+ disabled: globalDisabled,
4478
+ disableTransforms,
4479
+ sortedRects,
4480
+ overIndex,
4481
+ useDragOverlay,
4482
+ strategy: globalStrategy
4483
+ } = useContext(Context);
4484
+ const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
4485
+ const index = items.indexOf(id);
4486
+ const data = useMemo(() => ({
4487
+ sortable: {
4488
+ containerId,
4489
+ index,
4490
+ items
4491
+ },
4492
+ ...customData
4493
+ }), [containerId, customData, index, items]);
4494
+ const itemsAfterCurrentSortable = useMemo(() => items.slice(items.indexOf(id)), [items, id]);
4495
+ const {
4496
+ rect,
4497
+ node,
4498
+ isOver,
4499
+ setNodeRef: setDroppableNodeRef
4500
+ } = useDroppable({
4501
+ id,
4502
+ data,
4503
+ disabled: disabled.droppable,
4504
+ resizeObserverConfig: {
4505
+ updateMeasurementsFor: itemsAfterCurrentSortable,
4506
+ ...resizeObserverConfig
4507
+ }
4508
+ });
4509
+ const {
4510
+ active,
4511
+ activatorEvent,
4512
+ activeNodeRect,
4513
+ attributes,
4514
+ setNodeRef: setDraggableNodeRef,
4515
+ listeners,
4516
+ isDragging,
4517
+ over,
4518
+ setActivatorNodeRef,
4519
+ transform
4520
+ } = useDraggable({
4521
+ id,
4522
+ data,
4523
+ attributes: { ...defaultAttributes,
4524
+ ...userDefinedAttributes
4525
+ },
4526
+ disabled: disabled.draggable
4527
+ });
4528
+ const setNodeRef = useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
4529
+ const isSorting = Boolean(active);
4530
+ const displaceItem = isSorting && !disableTransforms && isValidIndex(activeIndex) && isValidIndex(overIndex);
4531
+ const shouldDisplaceDragSource = !useDragOverlay && isDragging;
4532
+ const dragSourceDisplacement = shouldDisplaceDragSource && displaceItem ? transform : null;
4533
+ const strategy = localStrategy != null ? localStrategy : globalStrategy;
4534
+ const finalTransform = displaceItem ? dragSourceDisplacement != null ? dragSourceDisplacement : strategy({
4535
+ rects: sortedRects,
4536
+ activeNodeRect,
4537
+ activeIndex,
4538
+ overIndex,
4539
+ index
4540
+ }) : null;
4541
+ const newIndex = isValidIndex(activeIndex) && isValidIndex(overIndex) ? getNewIndex({
4542
+ id,
4543
+ items,
4544
+ activeIndex,
4545
+ overIndex
4546
+ }) : index;
4547
+ const activeId = active == null ? void 0 : active.id;
4548
+ const previous = useRef({
4549
+ activeId,
4550
+ items,
4551
+ newIndex,
4552
+ containerId
4553
+ });
4554
+ const itemsHaveChanged = items !== previous.current.items;
4555
+ const shouldAnimateLayoutChanges = animateLayoutChanges({
4556
+ active,
4557
+ containerId,
4558
+ isDragging,
4559
+ isSorting,
4560
+ id,
4561
+ index,
4562
+ items,
4563
+ newIndex: previous.current.newIndex,
4564
+ previousItems: previous.current.items,
4565
+ previousContainerId: previous.current.containerId,
4566
+ transition,
4567
+ wasDragging: previous.current.activeId != null
4568
+ });
4569
+ const derivedTransform = useDerivedTransform({
4570
+ disabled: !shouldAnimateLayoutChanges,
4571
+ index,
4572
+ node,
4573
+ rect
4574
+ });
4575
+ useEffect(() => {
4576
+ if (isSorting && previous.current.newIndex !== newIndex) {
4577
+ previous.current.newIndex = newIndex;
4578
+ }
4579
+
4580
+ if (containerId !== previous.current.containerId) {
4581
+ previous.current.containerId = containerId;
4582
+ }
4583
+
4584
+ if (items !== previous.current.items) {
4585
+ previous.current.items = items;
4586
+ }
4587
+ }, [isSorting, newIndex, containerId, items]);
4588
+ useEffect(() => {
4589
+ if (activeId === previous.current.activeId) {
4590
+ return;
4591
+ }
4592
+
4593
+ if (activeId && !previous.current.activeId) {
4594
+ previous.current.activeId = activeId;
4595
+ return;
4596
+ }
4597
+
4598
+ const timeoutId = setTimeout(() => {
4599
+ previous.current.activeId = activeId;
4600
+ }, 50);
4601
+ return () => clearTimeout(timeoutId);
4602
+ }, [activeId]);
4603
+ return {
4604
+ active,
4605
+ activeIndex,
4606
+ attributes,
4607
+ data,
4608
+ rect,
4609
+ index,
4610
+ newIndex,
4611
+ items,
4612
+ isOver,
4613
+ isSorting,
4614
+ isDragging,
4615
+ listeners,
4616
+ node,
4617
+ overIndex,
4618
+ over,
4619
+ setNodeRef,
4620
+ setActivatorNodeRef,
4621
+ setDroppableNodeRef,
4622
+ setDraggableNodeRef,
4623
+ transform: derivedTransform != null ? derivedTransform : finalTransform,
4624
+ transition: getTransition()
4625
+ };
4626
+
4627
+ function getTransition() {
4628
+ if ( // Temporarily disable transitions for a single frame to set up derived transforms
4629
+ derivedTransform || // Or to prevent items jumping to back to their "new" position when items change
4630
+ itemsHaveChanged && previous.current.newIndex === index) {
4631
+ return disabledTransition;
4632
+ }
4633
+
4634
+ if (shouldDisplaceDragSource && !isKeyboardEvent(activatorEvent) || !transition) {
4635
+ return undefined;
4636
+ }
4637
+
4638
+ if (isSorting || shouldAnimateLayoutChanges) {
4639
+ return CSS.Transition.toString({ ...transition,
4640
+ property: transitionProperty
4641
+ });
4642
+ }
4643
+
4644
+ return undefined;
4645
+ }
4646
+ }
4647
+
4648
+ function normalizeLocalDisabled(localDisabled, globalDisabled) {
4649
+ var _localDisabled$dragga, _localDisabled$droppa;
4650
+
4651
+ if (typeof localDisabled === 'boolean') {
4652
+ return {
4653
+ draggable: localDisabled,
4654
+ // Backwards compatibility
4655
+ droppable: false
4656
+ };
4657
+ }
4658
+
4659
+ return {
4660
+ draggable: (_localDisabled$dragga = localDisabled == null ? void 0 : localDisabled.draggable) != null ? _localDisabled$dragga : globalDisabled.draggable,
4661
+ droppable: (_localDisabled$droppa = localDisabled == null ? void 0 : localDisabled.droppable) != null ? _localDisabled$droppa : globalDisabled.droppable
4662
+ };
4663
+ }
4664
+
4665
+ [KeyboardCode.Down, KeyboardCode.Right, KeyboardCode.Up, KeyboardCode.Left];
4666
+
4667
+ var _excluded = ["size"];
4668
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4669
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4670
+ var DragIcon = function DragIcon(_ref) {
4671
+ var _ref$size = _ref.size,
4672
+ size = _ref$size === void 0 ? 16 : _ref$size,
4673
+ otherProps = _objectWithoutProperties(_ref, _excluded);
4674
+ return /*#__PURE__*/jsx("svg", _objectSpread$2(_objectSpread$2({
4675
+ fill: "currentColor",
4676
+ height: size,
4677
+ viewBox: "0 -960 960 960",
4678
+ width: size,
4679
+ xmlns: "http://www.w3.org/2000/svg"
4680
+ }, otherProps), {}, {
4681
+ children: /*#__PURE__*/jsx("path", {
4682
+ d: "M360-160q-33 0-56.5-23.5T280-240q0-33 23.5-56.5T360-320q33 0 56.5 23.5T440-240q0 33-23.5 56.5T360-160zm240 0q-33 0-56.5-23.5T520-240q0-33 23.5-56.5T600-320q33 0 56.5 23.5T680-240q0 33-23.5 56.5T600-160zM360-400q-33 0-56.5-23.5T280-480q0-33 23.5-56.5T360-560q33 0 56.5 23.5T440-480q0 33-23.5 56.5T360-400zm240 0q-33 0-56.5-23.5T520-480q0-33 23.5-56.5T600-560q33 0 56.5 23.5T680-480q0 33-23.5 56.5T600-400zM360-640q-33 0-56.5-23.5T280-720q0-33 23.5-56.5T360-800q33 0 56.5 23.5T440-720q0 33-23.5 56.5T360-640zm240 0q-33 0-56.5-23.5T520-720q0-33 23.5-56.5T600-800q33 0 56.5 23.5T680-720q0 33-23.5 56.5T600-640z"
4683
+ })
4684
+ }));
4685
+ };
4686
+
4687
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4688
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4689
+ var FieldBlock = function FieldBlock(_ref) {
4690
+ var field = _ref.field,
4691
+ index = _ref.index;
4692
+ var _useSortable = useSortable({
4693
+ id: field.id,
4694
+ data: {
4695
+ index: index
4696
+ }
4697
+ }),
4698
+ attributes = _useSortable.attributes,
4699
+ listeners = _useSortable.listeners,
4700
+ setNodeRef = _useSortable.setNodeRef,
4701
+ transform = _useSortable.transform,
4702
+ isDragging = _useSortable.isDragging;
4703
+ var style = {
4704
+ transform: CSS.Transform.toString(transform)
4705
+ };
4706
+ return /*#__PURE__*/jsxs("div", _objectSpread$1(_objectSpread$1({
4707
+ ref: setNodeRef
4708
+ }, _objectSpread$1(_objectSpread$1({
4709
+ style: style
4710
+ }, attributes), listeners)), {}, {
4711
+ className: "neeto-ui-text-gray-800 group mb-3 flex w-full items-center gap-x-0.5 font-medium",
4712
+ "data-cy": "reorder-field-block",
4713
+ children: [/*#__PURE__*/jsx("div", {
4714
+ className: classnames("cursor-grab", {
4715
+ "cursor-grabbing": isDragging
4716
+ }),
4717
+ children: /*#__PURE__*/jsx(DragIcon, {})
4718
+ }), /*#__PURE__*/jsx("div", {
4719
+ className: "neeto-ui-border-gray-400 neeto-ui-bg-white neeto-ui-rounded neeto-ui-shadow-xs flex flex-grow items-center border border-solid p-3 transition-all duration-300 ease-in-out group-hover:bg-gray-200",
4720
+ children: /*#__PURE__*/jsx("div", {
4721
+ "data-cy": "reorder-field-block-name",
4722
+ children: field.name
4723
+ })
4724
+ })]
4725
+ }));
4726
+ };
4727
+ var FieldBlock$1 = /*#__PURE__*/memo(FieldBlock);
4728
+
4729
+ var ReorderPane = function ReorderPane(_ref) {
4730
+ var isOpen = _ref.isOpen,
4731
+ onClose = _ref.onClose,
4732
+ ownerId = _ref.ownerId;
4733
+ var _useState = useState([]),
4734
+ _useState2 = _slicedToArray(_useState, 2),
4735
+ fields = _useState2[0],
4736
+ setFields = _useState2[1];
4737
+ var initialStateRef = useRef([]);
4738
+ var _useTranslation = useTranslation(),
4739
+ t = _useTranslation.t;
4740
+ var _getQueryParams = getQueryParams(),
4741
+ resource = _getQueryParams.resource;
4742
+ var _useReorderFields = useReorderFields(),
4743
+ reorderField = _useReorderFields.mutate,
4744
+ isSubmitting = _useReorderFields.isPending;
4745
+ var fieldParams = {
4746
+ resourceType: isEmpty(ownerId) ? resource : undefined,
4747
+ ownerId: ownerId,
4748
+ state: FIELD_STATES.active,
4749
+ searchTerm: ""
4750
+ };
4751
+ var _useFetchFields = useFetchFields(fieldParams, {
4752
+ enabled: !!resource && isOpen
4753
+ }),
4754
+ _useFetchFields$data = _useFetchFields.data,
4755
+ _useFetchFields$data2 = _useFetchFields$data === void 0 ? {} : _useFetchFields$data,
4756
+ _useFetchFields$data3 = _useFetchFields$data2.fields,
4757
+ allFields = _useFetchFields$data3 === void 0 ? [] : _useFetchFields$data3;
4758
+ var handleDragEnd = function handleDragEnd(_ref2) {
4759
+ var active = _ref2.active,
4760
+ over = _ref2.over;
4761
+ if (active.id !== over.id) {
4762
+ setFields(function (fields) {
4763
+ return arrayMove(fields, active.data.current.index, over.data.current.index);
4764
+ });
4765
+ }
4766
+ };
4767
+ var handleReorderSave = function handleReorderSave() {
4768
+ var params = [];
4769
+ fields.map(function (field, index) {
4770
+ return field.id !== allFields[index].id && params.push({
4771
+ id: field.id,
4772
+ displayOrder: index + 1
4773
+ });
4774
+ });
4775
+ reorderField({
4776
+ ownerId: isEmpty(ownerId) ? undefined : ownerId,
4777
+ fields: params
4778
+ }, {
4779
+ onSuccess: onClose
4780
+ });
4781
+ };
4782
+ useEffect(function () {
4783
+ if (isEmpty(allFields)) return;
4784
+ setFields(allFields);
4785
+ initialStateRef.current = allFields;
4786
+ }, [allFields]);
4787
+ return /*#__PURE__*/jsxs(Pane, {
4788
+ isOpen: isOpen,
4789
+ onClose: onClose,
4790
+ children: [/*#__PURE__*/jsx(Pane.Header, {
4791
+ children: /*#__PURE__*/jsx(Typography, {
4792
+ "data-cy": "reorder-pane-header",
4793
+ style: "h2",
4794
+ weight: "semibold",
4795
+ children: t("neetoFields.titles.reorderFields")
4796
+ })
4797
+ }), /*#__PURE__*/jsxs(Pane.Body, {
4798
+ children: [/*#__PURE__*/jsx(Typography, {
4799
+ className: "mb-3",
4800
+ "data-cy": "reorder-pane-message",
4801
+ style: "body2",
4802
+ children: t("neetoFields.messages.reorderFields")
4803
+ }), /*#__PURE__*/jsx("div", {
4804
+ className: "flex w-full flex-col items-center",
4805
+ children: /*#__PURE__*/jsx(DndContext, {
4806
+ collisionDetection: closestCenter,
4807
+ onDragEnd: handleDragEnd,
4808
+ children: /*#__PURE__*/jsx(SortableContext, {
4809
+ items: fields,
4810
+ strategy: verticalListSortingStrategy,
4811
+ children: fields.map(function (field, index) {
4812
+ if (field.isSystem) return null;
4813
+ return /*#__PURE__*/createElement(FieldBlock$1, {
4814
+ field: field,
4815
+ index: index,
4816
+ key: index
4817
+ });
4818
+ })
4819
+ })
4820
+ })
4821
+ })]
4822
+ }), /*#__PURE__*/jsxs(Pane.Footer, {
4823
+ className: "flex items-center space-x-2",
4824
+ children: [/*#__PURE__*/jsx(Button, {
4825
+ "data-cy": "save-changes-button",
4826
+ disabled: initialStateRef.current === fields,
4827
+ label: t("neetoFields.labels.saveChanges"),
4828
+ loading: isSubmitting,
4829
+ onClick: handleReorderSave
4830
+ }), /*#__PURE__*/jsx(Button, {
4831
+ "data-cy": "cancel-button",
4832
+ label: t("neetoFields.labels.cancel"),
4833
+ style: "text",
4834
+ onClick: onClose
4835
+ })]
4836
+ })]
4837
+ });
4838
+ };
4839
+
4840
+ var Subheader = function Subheader(_ref) {
4841
+ var count = _ref.count,
4842
+ searchKeywordProps = _ref.searchKeywordProps;
4843
+ var _useTranslation = useTranslation(),
4844
+ t = _useTranslation.t;
4845
+ return /*#__PURE__*/jsx(NeetoUISubHeader, {
4846
+ leftActionBlock: /*#__PURE__*/jsxs(Fragment, {
4847
+ children: [/*#__PURE__*/jsx(Typography, {
4848
+ className: "neeto-ui-gray-800 mr-4 font-semibold",
4849
+ "data-cy": "neeto-fields-subheader-text",
4850
+ style: "h4",
4851
+ children: t("neetoFields.titles.fieldWithCount", {
4852
+ count: count
4853
+ })
4854
+ }), /*#__PURE__*/jsx(Bar, {
4855
+ keyword: searchKeywordProps
4856
+ })]
4857
+ })
4858
+ });
4859
+ };
4860
+
4861
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4862
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4863
+ var FieldsDashboard = function FieldsDashboard(_ref) {
4864
+ var _ref$rowData = _ref.rowData,
4865
+ rowData = _ref$rowData === void 0 ? [] : _ref$rowData,
4866
+ _ref$showOwnersInMenu = _ref.showOwnersInMenu,
4867
+ isOwnerBased = _ref$showOwnersInMenu === void 0 ? false : _ref$showOwnersInMenu,
4868
+ _ref$resourceType = _ref.resourceType,
4869
+ resourceType = _ref$resourceType === void 0 ? "" : _ref$resourceType,
4870
+ _ref$allowedKinds = _ref.allowedKinds,
4871
+ allowedKinds = _ref$allowedKinds === void 0 ? ALL_KINDS : _ref$allowedKinds,
4872
+ paneProps = _ref.paneProps,
4873
+ _ref$buildColumnData = _ref.buildColumnData,
4874
+ buildColumnData = _ref$buildColumnData === void 0 ? function (_ref2) {
4875
+ var _ref2$defaultColumns = _ref2.defaultColumns,
4876
+ defaultColumns = _ref2$defaultColumns === void 0 ? [] : _ref2$defaultColumns;
4877
+ return defaultColumns;
4878
+ } : _ref$buildColumnData,
4879
+ _ref$breadcrumbs = _ref.breadcrumbs,
4880
+ breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
4881
+ _ref$showStateFilter = _ref.showStateFilter,
4882
+ showStateFilter = _ref$showStateFilter === void 0 ? true : _ref$showStateFilter,
4883
+ _ref$fieldStatesTaxon = _ref.fieldStatesTaxonomy,
4884
+ fieldStatesTaxonomy = _ref$fieldStatesTaxon === void 0 ? DEFAULT_FIELD_STATE_TAXONOMY : _ref$fieldStatesTaxon,
4885
+ helpDocUrl = _ref.helpDocUrl,
4886
+ helpDescription = _ref.helpDescription,
4887
+ _ref$nameAliases = _ref.nameAliases,
4888
+ nameAliases = _ref$nameAliases === void 0 ? {} : _ref$nameAliases,
4889
+ headerTitle = _ref.headerTitle,
4890
+ resources = _ref.resources,
4891
+ _ref$headerSize = _ref.headerSize,
4892
+ headerSize = _ref$headerSize === void 0 ? "small" : _ref$headerSize;
4893
+ var _useTranslation = useTranslation(),
4894
+ t = _useTranslation.t;
4895
+ var title = capitalize(headerTitle || t("neetoFields.titles.field", PLURAL));
4896
+ var _useFieldsDashboard = useFieldsDashboard({
4897
+ buildColumnData: buildColumnData,
4898
+ isOwnerBased: isOwnerBased,
4899
+ fieldStatesTaxonomy: fieldStatesTaxonomy,
4900
+ nameAliases: nameAliases,
4901
+ title: title,
4902
+ resources: resources,
4903
+ showStateFilter: showStateFilter
4904
+ }),
4905
+ isPaneOpen = _useFieldsDashboard.isPaneOpen,
4906
+ setIsPaneOpen = _useFieldsDashboard.setIsPaneOpen,
4907
+ isDeleteAlertOpen = _useFieldsDashboard.isDeleteAlertOpen,
4908
+ isReorderPaneOpen = _useFieldsDashboard.isReorderPaneOpen,
4909
+ setIsReorderPaneOpen = _useFieldsDashboard.setIsReorderPaneOpen,
4910
+ fields = _useFieldsDashboard.fields,
4911
+ count = _useFieldsDashboard.count,
4912
+ columnData = _useFieldsDashboard.columnData,
4913
+ selectedField = _useFieldsDashboard.selectedField,
4914
+ selectedMenu = _useFieldsDashboard.selectedMenu,
4915
+ ownerId = _useFieldsDashboard.ownerId,
4916
+ isFieldsFetching = _useFieldsDashboard.isFieldsFetching,
4917
+ isFieldsFetched = _useFieldsDashboard.isFieldsFetched,
4918
+ isDeleting = _useFieldsDashboard.isDeleting,
4919
+ isScreenLoading = _useFieldsDashboard.isScreenLoading,
4920
+ isMenuBarNeeded = _useFieldsDashboard.isMenuBarNeeded,
4921
+ showCountSubheader = _useFieldsDashboard.showCountSubheader,
4922
+ handleDelete = _useFieldsDashboard.handleDelete,
4923
+ handleAlertClose = _useFieldsDashboard.handleAlertClose,
4924
+ handleClosePane = _useFieldsDashboard.handleClosePane,
4925
+ handleReorderPaneClose = _useFieldsDashboard.handleReorderPaneClose,
4926
+ searchInputProps = _useFieldsDashboard.searchInputProps,
4927
+ searchKeywordProps = _useFieldsDashboard.searchKeywordProps,
4928
+ stateFilterTabs = _useFieldsDashboard.stateFilterTabs,
4929
+ menuBarItems = _useFieldsDashboard.menuBarItems,
4930
+ reorderable = _useFieldsDashboard.reorderable,
4931
+ headerDisplayTitle = _useFieldsDashboard.headerDisplayTitle,
4932
+ pageProps = _useFieldsDashboard.pageProps,
4933
+ setPageProps = _useFieldsDashboard.setPageProps;
4934
+ var headerProps = {
4935
+ reorderable: reorderable,
4936
+ breadcrumbs: breadcrumbs,
4937
+ helpDocUrl: helpDocUrl,
4938
+ helpDescription: helpDescription,
4939
+ searchInputProps: searchInputProps,
4940
+ setIsPaneOpen: setIsPaneOpen,
4941
+ setIsReorderPaneOpen: setIsReorderPaneOpen,
4942
+ title: headerDisplayTitle,
4943
+ size: headerSize
4944
+ };
4945
+ var showSubheader = showCountSubheader || isPresent(searchKeywordProps.value);
4946
+ return /*#__PURE__*/jsxs(Fragment, {
4947
+ children: [isMenuBarNeeded && /*#__PURE__*/jsx(Menubar, {
4948
+ menuBarItems: menuBarItems,
4949
+ title: title
4950
+ }), /*#__PURE__*/jsxs(Container, {
4951
+ children: [/*#__PURE__*/jsx(Header, _objectSpread({}, headerProps)), showSubheader && /*#__PURE__*/jsx(Subheader, {
4952
+ count: count,
4953
+ searchKeywordProps: searchKeywordProps
4954
+ }), showStateFilter && stateFilterTabs, isScreenLoading ? /*#__PURE__*/jsx("div", {
4955
+ className: "flex h-screen w-full flex-grow items-center justify-center",
4956
+ children: /*#__PURE__*/jsx(PageLoader, {})
4957
+ }) : /*#__PURE__*/jsx(FieldsTable, {
4958
+ columnData: columnData,
4959
+ helpDescription: helpDescription,
4960
+ helpDocUrl: helpDocUrl,
4961
+ pageProps: pageProps,
4962
+ setIsPaneOpen: setIsPaneOpen,
4963
+ setPageProps: setPageProps,
4964
+ showStateFilter: showStateFilter,
4965
+ title: title,
4966
+ isFetched: isFieldsFetched,
4967
+ isFetching: isFieldsFetching,
4968
+ rowData: isEmpty(rowData) ? fields : rowData,
4969
+ totalCount: count
4970
+ }), /*#__PURE__*/jsx(FieldsPane, {
4971
+ allowedKinds: allowedKinds,
4972
+ selectedField: selectedField,
4973
+ additionalValidations: paneProps === null || paneProps === void 0 ? void 0 : paneProps.validations,
4974
+ hideRequiredSwitch: paneProps === null || paneProps === void 0 ? void 0 : paneProps.hideRequiredSwitch,
4975
+ initialValues: paneProps === null || paneProps === void 0 ? void 0 : paneProps.initialValues,
4976
+ isOpen: isPaneOpen,
4977
+ ownerId: isOwnerBased ? selectedMenu : "",
4978
+ resourceType: isOwnerBased ? resourceType : selectedMenu,
4979
+ onClose: handleClosePane,
4980
+ onMutationSuccess: paneProps === null || paneProps === void 0 ? void 0 : paneProps.onMutationSuccess,
4981
+ children: paneProps === null || paneProps === void 0 ? void 0 : paneProps.children
4982
+ })]
4983
+ }), /*#__PURE__*/jsx(ReorderPane, {
4984
+ isOpen: isReorderPaneOpen,
4985
+ ownerId: isOwnerBased ? selectedMenu : "",
4986
+ onClose: handleReorderPaneClose
4987
+ }), /*#__PURE__*/jsx(DeleteAlert, {
4988
+ handleAlertClose: handleAlertClose,
4989
+ handleDelete: handleDelete,
4990
+ isDeleteAlertOpen: isDeleteAlertOpen,
4991
+ isDeleting: isDeleting,
4992
+ ownerId: ownerId,
4993
+ selectedField: selectedField,
4994
+ resourceTypeName: isOwnerBased ? resourceType : selectedMenu
4995
+ })]
4996
+ });
4997
+ };
4998
+
4999
+ export { FieldsDashboard as default };
5000
+ //# sourceMappingURL=FieldsDashboard.js.map