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