@boomerang-io/carbon-addons-boomerang-react 4.6.14-beta.10 → 4.6.14-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/node_modules/.pnpm/@dnd-kit_sortable@8.0.0_@dnd-kit_core@6.3.1_react-dom@16.14.0_react@16.14.0__react@16.14.0__react@16.14.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.js +538 -0
- package/dist/cjs/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@16.14.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.js +138 -0
- package/dist/cjs/{components → src/components}/Creatable/Creatable.js +32 -3
- package/dist/cjs/{components → src/components}/DataDrivenInput/DataDrivenInput.js +11 -2
- package/dist/cjs/{components → src/components}/DynamicFormik/DynamicFormik.js +11 -1
- package/dist/cjs/{components → src/components}/Header/HeaderTeamSwitcher.js +13 -5
- package/dist/cjs/{constants → src/constants}/DataDrivenInputTypes.js +4 -0
- package/dist/esm/node_modules/.pnpm/@dnd-kit_sortable@8.0.0_@dnd-kit_core@6.3.1_react-dom@16.14.0_react@16.14.0__react@16.14.0__react@16.14.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.js +526 -0
- package/dist/esm/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@16.14.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.js +128 -0
- package/dist/esm/{components → src/components}/Creatable/Creatable.js +34 -5
- package/dist/esm/{components → src/components}/DataDrivenInput/DataDrivenInput.js +11 -2
- package/dist/esm/{components → src/components}/DynamicFormik/DynamicFormik.js +11 -1
- package/dist/esm/{components → src/components}/Header/HeaderTeamSwitcher.js +13 -5
- package/dist/esm/{constants → src/constants}/DataDrivenInputTypes.js +4 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +3 -2
- package/scss/components/Creatable/_creatable.scss +30 -1
- /package/dist/cjs/{components → src/components}/AboutPlatform/AboutPlatform.js +0 -0
- /package/dist/cjs/{components → src/components}/AdvantageSideNav/AdvantageSideNav.js +0 -0
- /package/dist/cjs/{components → src/components}/AutoSuggest/AutoSuggest.js +0 -0
- /package/dist/cjs/{components → src/components}/Avatar/Avatar.js +0 -0
- /package/dist/cjs/{components → src/components}/CheckboxList/CheckboxList.js +0 -0
- /package/dist/cjs/{components → src/components}/ComboBox/ComboBox.js +0 -0
- /package/dist/cjs/{components → src/components}/ComboBoxMultiSelect/ComboBoxMultiSelect.js +0 -0
- /package/dist/cjs/{components → src/components}/ComboBoxMultiSelect/MultiSelect.js +0 -0
- /package/dist/cjs/{components → src/components}/ComposedModal/ComposedModal.js +0 -0
- /package/dist/cjs/{components → src/components}/ConfirmModal/ConfirmModal.js +0 -0
- /package/dist/cjs/{components → src/components}/DateInput/DateInput.js +0 -0
- /package/dist/cjs/{components → src/components}/DecisionButtons/DecisionButtons.js +0 -0
- /package/dist/cjs/{components → src/components}/DelayedRender/DelayedRender.js +0 -0
- /package/dist/cjs/{components → src/components}/Error403/Error403.js +0 -0
- /package/dist/cjs/{components → src/components}/Error403/ForbiddenErrorBackground.js +0 -0
- /package/dist/cjs/{components → src/components}/Error403/GraphicWrangler/GraphicWrangler.js +0 -0
- /package/dist/cjs/{components → src/components}/Error404/Error404.js +0 -0
- /package/dist/cjs/{components → src/components}/Error404/GraphicLoch/GraphicLoch.js +0 -0
- /package/dist/cjs/{components → src/components}/Error404/NotFoundErrorBackground.js +0 -0
- /package/dist/cjs/{components → src/components}/ErrorBoundary/ErrorBoundary.js +0 -0
- /package/dist/cjs/{components → src/components}/ErrorDragon/ErrorDragon.js +0 -0
- /package/dist/cjs/{components → src/components}/ErrorDragon/assets/ErrorGraphic.js +0 -0
- /package/dist/cjs/{components → src/components}/ErrorFullPage/ErrorFullPage.js +0 -0
- /package/dist/cjs/{components → src/components}/ErrorMessage/ErrorMessage.js +0 -0
- /package/dist/cjs/{components → src/components}/ErrorPage/ErrorPage.js +0 -0
- /package/dist/cjs/{components → src/components}/ErrorPageCore/ErrorPageCore.js +0 -0
- /package/dist/cjs/{components → src/components}/ErrorPageCore/GenericErrorBackground.js +0 -0
- /package/dist/cjs/{components → src/components}/FeatureHeader/FeatureHeader.js +0 -0
- /package/dist/cjs/{components → src/components}/FeatureNavTab/FeatureNavTab.js +0 -0
- /package/dist/cjs/{components → src/components}/FeatureNavTabs/FeatureNavTabs.js +0 -0
- /package/dist/cjs/{components → src/components}/FeatureSideNav/FeatureSideNav.js +0 -0
- /package/dist/cjs/{components → src/components}/FeatureSideNav/FeatureSideNavFooter.js +0 -0
- /package/dist/cjs/{components → src/components}/FeatureSideNav/FeatureSideNavHeader.js +0 -0
- /package/dist/cjs/{components → src/components}/FeatureSideNav/FeatureSideNavLinks.js +0 -0
- /package/dist/cjs/{components → src/components}/FeatureSideNavLink/FeatureSideNavLink.js +0 -0
- /package/dist/cjs/{components → src/components}/Feedback/Feedback.js +0 -0
- /package/dist/cjs/{components → src/components}/FlowModal/FlowModal.js +0 -0
- /package/dist/cjs/{components → src/components}/FlowModal/FlowModalForm.js +0 -0
- /package/dist/cjs/{components → src/components}/Header/Header.js +0 -0
- /package/dist/cjs/{components → src/components}/Header/HeaderAppSwitcher.js +0 -0
- /package/dist/cjs/{components → src/components}/Header/HeaderMenu.js +0 -0
- /package/dist/cjs/{components → src/components}/Header/HeaderMenuItem.js +0 -0
- /package/dist/cjs/{components → src/components}/Header/UserRequests.js +0 -0
- /package/dist/cjs/{components → src/components}/ImageModal/ImageModal.js +0 -0
- /package/dist/cjs/{components → src/components}/Loading/Loading.js +0 -0
- /package/dist/cjs/{components → src/components}/MemberBar/MemberBar.js +0 -0
- /package/dist/cjs/{components → src/components}/Modal/Modal.js +0 -0
- /package/dist/cjs/{components → src/components}/ModalConfirmEdit/ModalConfirmArray.js +0 -0
- /package/dist/cjs/{components → src/components}/ModalConfirmEdit/ModalConfirmDetails.js +0 -0
- /package/dist/cjs/{components → src/components}/ModalConfirmEdit/ModalConfirmEdit.js +0 -0
- /package/dist/cjs/{components → src/components}/ModalForm/ModalForm.js +0 -0
- /package/dist/cjs/{components → src/components}/Notifications/NotificationsContainer.js +0 -0
- /package/dist/cjs/{components → src/components}/Notifications/ToastNotification.js +0 -0
- /package/dist/cjs/{components → src/components}/Notifications/notify.js +0 -0
- /package/dist/cjs/{components → src/components}/PlatformBanner/PlatformBanner.js +0 -0
- /package/dist/cjs/{components → src/components}/PlatformNotifications/PlatformNotification.js +0 -0
- /package/dist/cjs/{components → src/components}/PlatformNotifications/PlatformNotificationsContainer.js +0 -0
- /package/dist/cjs/{components → src/components}/Portal/Portal.js +0 -0
- /package/dist/cjs/{components → src/components}/PrivacyRedirect/PrivacyRedirect.js +0 -0
- /package/dist/cjs/{components → src/components}/PrivacyStatement/PrivacyStatement.js +0 -0
- /package/dist/cjs/{components → src/components}/ProfileSettings/ProfileSettings.js +0 -0
- /package/dist/cjs/{components → src/components}/ProtectedRoute/ProtectedRoute.js +0 -0
- /package/dist/cjs/{components → src/components}/RadioGroup/RadioGroup.js +0 -0
- /package/dist/cjs/{components → src/components}/RichTextArea/RichTextArea.js +0 -0
- /package/dist/cjs/{components → src/components}/SignOut/SignOut.js +0 -0
- /package/dist/cjs/{components → src/components}/SupportCenter/SupportCenter.js +0 -0
- /package/dist/cjs/{components → src/components}/TextArea/TextArea.js +0 -0
- /package/dist/cjs/{components → src/components}/TextInput/TextInput.js +0 -0
- /package/dist/cjs/{components → src/components}/Toggle/Toggle.js +0 -0
- /package/dist/cjs/{components → src/components}/TooltipHover/TooltipHover.js +0 -0
- /package/dist/cjs/{components → src/components}/UIShell/UIShell.js +0 -0
- /package/dist/cjs/{config → src/config}/servicesConfig.js +0 -0
- /package/dist/cjs/{constants → src/constants}/TeamTypes.js +0 -0
- /package/dist/cjs/{constants → src/constants}/UserType.js +0 -0
- /package/dist/cjs/{hooks → src/hooks}/useHeaderMenu.js +0 -0
- /package/dist/cjs/{hooks → src/hooks}/usePortal.js +0 -0
- /package/dist/cjs/{hooks → src/hooks}/useWindowSize.js +0 -0
- /package/dist/cjs/{index.js → src/index.js} +0 -0
- /package/dist/cjs/{internal → src/internal}/ListBox/ListBox.js +0 -0
- /package/dist/cjs/{internal → src/internal}/ListBox/ListBoxField.js +0 -0
- /package/dist/cjs/{internal → src/internal}/ListBox/ListBoxMenu.js +0 -0
- /package/dist/cjs/{internal → src/internal}/ListBox/ListBoxMenuIcon.js +0 -0
- /package/dist/cjs/{internal → src/internal}/ListBox/ListBoxMenuItem.js +0 -0
- /package/dist/cjs/{internal → src/internal}/ListBox/ListBoxSelection.js +0 -0
- /package/dist/cjs/{internal → src/internal}/ListBox/index.js +0 -0
- /package/dist/cjs/{internal → src/internal}/keyboard/keys.js +0 -0
- /package/dist/cjs/{internal → src/internal}/keyboard/match.js +0 -0
- /package/dist/cjs/{internal → src/internal}/settings.js +0 -0
- /package/dist/cjs/{tools → src/tools}/accessibility.js +0 -0
- /package/dist/cjs/{tools → src/tools}/createPropAdapter.js +0 -0
- /package/dist/cjs/{tools → src/tools}/isUrl.js +0 -0
- /package/dist/cjs/{tools → src/tools}/setupGetInstanceId.js +0 -0
- /package/dist/cjs/{tools → src/tools}/useSetState.js +0 -0
- /package/dist/cjs/{tools → src/tools}/yupAst/astGenerator.js +0 -0
- /package/dist/cjs/{tools → src/tools}/yupAst/customValidators.js +0 -0
- /package/dist/esm/{components → src/components}/AboutPlatform/AboutPlatform.js +0 -0
- /package/dist/esm/{components → src/components}/AdvantageSideNav/AdvantageSideNav.js +0 -0
- /package/dist/esm/{components → src/components}/AutoSuggest/AutoSuggest.js +0 -0
- /package/dist/esm/{components → src/components}/Avatar/Avatar.js +0 -0
- /package/dist/esm/{components → src/components}/CheckboxList/CheckboxList.js +0 -0
- /package/dist/esm/{components → src/components}/ComboBox/ComboBox.js +0 -0
- /package/dist/esm/{components → src/components}/ComboBoxMultiSelect/ComboBoxMultiSelect.js +0 -0
- /package/dist/esm/{components → src/components}/ComboBoxMultiSelect/MultiSelect.js +0 -0
- /package/dist/esm/{components → src/components}/ComposedModal/ComposedModal.js +0 -0
- /package/dist/esm/{components → src/components}/ConfirmModal/ConfirmModal.js +0 -0
- /package/dist/esm/{components → src/components}/DateInput/DateInput.js +0 -0
- /package/dist/esm/{components → src/components}/DecisionButtons/DecisionButtons.js +0 -0
- /package/dist/esm/{components → src/components}/DelayedRender/DelayedRender.js +0 -0
- /package/dist/esm/{components → src/components}/Error403/Error403.js +0 -0
- /package/dist/esm/{components → src/components}/Error403/ForbiddenErrorBackground.js +0 -0
- /package/dist/esm/{components → src/components}/Error403/GraphicWrangler/GraphicWrangler.js +0 -0
- /package/dist/esm/{components → src/components}/Error404/Error404.js +0 -0
- /package/dist/esm/{components → src/components}/Error404/GraphicLoch/GraphicLoch.js +0 -0
- /package/dist/esm/{components → src/components}/Error404/NotFoundErrorBackground.js +0 -0
- /package/dist/esm/{components → src/components}/ErrorBoundary/ErrorBoundary.js +0 -0
- /package/dist/esm/{components → src/components}/ErrorDragon/ErrorDragon.js +0 -0
- /package/dist/esm/{components → src/components}/ErrorDragon/assets/ErrorGraphic.js +0 -0
- /package/dist/esm/{components → src/components}/ErrorFullPage/ErrorFullPage.js +0 -0
- /package/dist/esm/{components → src/components}/ErrorMessage/ErrorMessage.js +0 -0
- /package/dist/esm/{components → src/components}/ErrorPage/ErrorPage.js +0 -0
- /package/dist/esm/{components → src/components}/ErrorPageCore/ErrorPageCore.js +0 -0
- /package/dist/esm/{components → src/components}/ErrorPageCore/GenericErrorBackground.js +0 -0
- /package/dist/esm/{components → src/components}/FeatureHeader/FeatureHeader.js +0 -0
- /package/dist/esm/{components → src/components}/FeatureNavTab/FeatureNavTab.js +0 -0
- /package/dist/esm/{components → src/components}/FeatureNavTabs/FeatureNavTabs.js +0 -0
- /package/dist/esm/{components → src/components}/FeatureSideNav/FeatureSideNav.js +0 -0
- /package/dist/esm/{components → src/components}/FeatureSideNav/FeatureSideNavFooter.js +0 -0
- /package/dist/esm/{components → src/components}/FeatureSideNav/FeatureSideNavHeader.js +0 -0
- /package/dist/esm/{components → src/components}/FeatureSideNav/FeatureSideNavLinks.js +0 -0
- /package/dist/esm/{components → src/components}/FeatureSideNavLink/FeatureSideNavLink.js +0 -0
- /package/dist/esm/{components → src/components}/Feedback/Feedback.js +0 -0
- /package/dist/esm/{components → src/components}/FlowModal/FlowModal.js +0 -0
- /package/dist/esm/{components → src/components}/FlowModal/FlowModalForm.js +0 -0
- /package/dist/esm/{components → src/components}/Header/Header.js +0 -0
- /package/dist/esm/{components → src/components}/Header/HeaderAppSwitcher.js +0 -0
- /package/dist/esm/{components → src/components}/Header/HeaderMenu.js +0 -0
- /package/dist/esm/{components → src/components}/Header/HeaderMenuItem.js +0 -0
- /package/dist/esm/{components → src/components}/Header/UserRequests.js +0 -0
- /package/dist/esm/{components → src/components}/ImageModal/ImageModal.js +0 -0
- /package/dist/esm/{components → src/components}/Loading/Loading.js +0 -0
- /package/dist/esm/{components → src/components}/MemberBar/MemberBar.js +0 -0
- /package/dist/esm/{components → src/components}/Modal/Modal.js +0 -0
- /package/dist/esm/{components → src/components}/ModalConfirmEdit/ModalConfirmArray.js +0 -0
- /package/dist/esm/{components → src/components}/ModalConfirmEdit/ModalConfirmDetails.js +0 -0
- /package/dist/esm/{components → src/components}/ModalConfirmEdit/ModalConfirmEdit.js +0 -0
- /package/dist/esm/{components → src/components}/ModalForm/ModalForm.js +0 -0
- /package/dist/esm/{components → src/components}/Notifications/NotificationsContainer.js +0 -0
- /package/dist/esm/{components → src/components}/Notifications/ToastNotification.js +0 -0
- /package/dist/esm/{components → src/components}/Notifications/notify.js +0 -0
- /package/dist/esm/{components → src/components}/PlatformBanner/PlatformBanner.js +0 -0
- /package/dist/esm/{components → src/components}/PlatformNotifications/PlatformNotification.js +0 -0
- /package/dist/esm/{components → src/components}/PlatformNotifications/PlatformNotificationsContainer.js +0 -0
- /package/dist/esm/{components → src/components}/Portal/Portal.js +0 -0
- /package/dist/esm/{components → src/components}/PrivacyRedirect/PrivacyRedirect.js +0 -0
- /package/dist/esm/{components → src/components}/PrivacyStatement/PrivacyStatement.js +0 -0
- /package/dist/esm/{components → src/components}/ProfileSettings/ProfileSettings.js +0 -0
- /package/dist/esm/{components → src/components}/ProtectedRoute/ProtectedRoute.js +0 -0
- /package/dist/esm/{components → src/components}/RadioGroup/RadioGroup.js +0 -0
- /package/dist/esm/{components → src/components}/RichTextArea/RichTextArea.js +0 -0
- /package/dist/esm/{components → src/components}/SignOut/SignOut.js +0 -0
- /package/dist/esm/{components → src/components}/SupportCenter/SupportCenter.js +0 -0
- /package/dist/esm/{components → src/components}/TextArea/TextArea.js +0 -0
- /package/dist/esm/{components → src/components}/TextInput/TextInput.js +0 -0
- /package/dist/esm/{components → src/components}/Toggle/Toggle.js +0 -0
- /package/dist/esm/{components → src/components}/TooltipHover/TooltipHover.js +0 -0
- /package/dist/esm/{components → src/components}/UIShell/UIShell.js +0 -0
- /package/dist/esm/{config → src/config}/servicesConfig.js +0 -0
- /package/dist/esm/{constants → src/constants}/TeamTypes.js +0 -0
- /package/dist/esm/{constants → src/constants}/UserType.js +0 -0
- /package/dist/esm/{hooks → src/hooks}/useHeaderMenu.js +0 -0
- /package/dist/esm/{hooks → src/hooks}/usePortal.js +0 -0
- /package/dist/esm/{hooks → src/hooks}/useWindowSize.js +0 -0
- /package/dist/esm/{index.js → src/index.js} +0 -0
- /package/dist/esm/{internal → src/internal}/ListBox/ListBox.js +0 -0
- /package/dist/esm/{internal → src/internal}/ListBox/ListBoxField.js +0 -0
- /package/dist/esm/{internal → src/internal}/ListBox/ListBoxMenu.js +0 -0
- /package/dist/esm/{internal → src/internal}/ListBox/ListBoxMenuIcon.js +0 -0
- /package/dist/esm/{internal → src/internal}/ListBox/ListBoxMenuItem.js +0 -0
- /package/dist/esm/{internal → src/internal}/ListBox/ListBoxSelection.js +0 -0
- /package/dist/esm/{internal → src/internal}/ListBox/index.js +0 -0
- /package/dist/esm/{internal → src/internal}/keyboard/keys.js +0 -0
- /package/dist/esm/{internal → src/internal}/keyboard/match.js +0 -0
- /package/dist/esm/{internal → src/internal}/settings.js +0 -0
- /package/dist/esm/{tools → src/tools}/accessibility.js +0 -0
- /package/dist/esm/{tools → src/tools}/createPropAdapter.js +0 -0
- /package/dist/esm/{tools → src/tools}/isUrl.js +0 -0
- /package/dist/esm/{tools → src/tools}/setupGetInstanceId.js +0 -0
- /package/dist/esm/{tools → src/tools}/useSetState.js +0 -0
- /package/dist/esm/{tools → src/tools}/yupAst/astGenerator.js +0 -0
- /package/dist/esm/{tools → src/tools}/yupAst/customValidators.js +0 -0
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var core = require('@dnd-kit/core');
|
|
5
|
+
var utilities_esm = require('../../../../../@dnd-kit_utilities@3.2.2_react@16.14.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Move an array item to a different position. Returns a new array with the item moved to the new position.
|
|
13
|
+
*/
|
|
14
|
+
function arrayMove(array, from, to) {
|
|
15
|
+
const newArray = array.slice();
|
|
16
|
+
newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
|
|
17
|
+
return newArray;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getSortedRects(items, rects) {
|
|
21
|
+
return items.reduce((accumulator, id, index) => {
|
|
22
|
+
const rect = rects.get(id);
|
|
23
|
+
|
|
24
|
+
if (rect) {
|
|
25
|
+
accumulator[index] = rect;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return accumulator;
|
|
29
|
+
}, Array(items.length));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isValidIndex(index) {
|
|
33
|
+
return index !== null && index >= 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function itemsEqual(a, b) {
|
|
37
|
+
if (a === b) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (a.length !== b.length) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for (let i = 0; i < a.length; i++) {
|
|
46
|
+
if (a[i] !== b[i]) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function normalizeDisabled(disabled) {
|
|
55
|
+
if (typeof disabled === 'boolean') {
|
|
56
|
+
return {
|
|
57
|
+
draggable: disabled,
|
|
58
|
+
droppable: disabled
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return disabled;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const rectSortingStrategy = _ref => {
|
|
66
|
+
let {
|
|
67
|
+
rects,
|
|
68
|
+
activeIndex,
|
|
69
|
+
overIndex,
|
|
70
|
+
index
|
|
71
|
+
} = _ref;
|
|
72
|
+
const newRects = arrayMove(rects, overIndex, activeIndex);
|
|
73
|
+
const oldRect = rects[index];
|
|
74
|
+
const newRect = newRects[index];
|
|
75
|
+
|
|
76
|
+
if (!newRect || !oldRect) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
x: newRect.left - oldRect.left,
|
|
82
|
+
y: newRect.top - oldRect.top,
|
|
83
|
+
scaleX: newRect.width / oldRect.width,
|
|
84
|
+
scaleY: newRect.height / oldRect.height
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// To-do: We should be calculating scale transformation
|
|
89
|
+
const defaultScale$1 = {
|
|
90
|
+
scaleX: 1,
|
|
91
|
+
scaleY: 1
|
|
92
|
+
};
|
|
93
|
+
const verticalListSortingStrategy = _ref => {
|
|
94
|
+
var _rects$activeIndex;
|
|
95
|
+
|
|
96
|
+
let {
|
|
97
|
+
activeIndex,
|
|
98
|
+
activeNodeRect: fallbackActiveRect,
|
|
99
|
+
index,
|
|
100
|
+
rects,
|
|
101
|
+
overIndex
|
|
102
|
+
} = _ref;
|
|
103
|
+
const activeNodeRect = (_rects$activeIndex = rects[activeIndex]) != null ? _rects$activeIndex : fallbackActiveRect;
|
|
104
|
+
|
|
105
|
+
if (!activeNodeRect) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (index === activeIndex) {
|
|
110
|
+
const overIndexRect = rects[overIndex];
|
|
111
|
+
|
|
112
|
+
if (!overIndexRect) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
x: 0,
|
|
118
|
+
y: activeIndex < overIndex ? overIndexRect.top + overIndexRect.height - (activeNodeRect.top + activeNodeRect.height) : overIndexRect.top - activeNodeRect.top,
|
|
119
|
+
...defaultScale$1
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const itemGap = getItemGap$1(rects, index, activeIndex);
|
|
124
|
+
|
|
125
|
+
if (index > activeIndex && index <= overIndex) {
|
|
126
|
+
return {
|
|
127
|
+
x: 0,
|
|
128
|
+
y: -activeNodeRect.height - itemGap,
|
|
129
|
+
...defaultScale$1
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (index < activeIndex && index >= overIndex) {
|
|
134
|
+
return {
|
|
135
|
+
x: 0,
|
|
136
|
+
y: activeNodeRect.height + itemGap,
|
|
137
|
+
...defaultScale$1
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
x: 0,
|
|
143
|
+
y: 0,
|
|
144
|
+
...defaultScale$1
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
function getItemGap$1(clientRects, index, activeIndex) {
|
|
149
|
+
const currentRect = clientRects[index];
|
|
150
|
+
const previousRect = clientRects[index - 1];
|
|
151
|
+
const nextRect = clientRects[index + 1];
|
|
152
|
+
|
|
153
|
+
if (!currentRect) {
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (activeIndex < index) {
|
|
158
|
+
return previousRect ? currentRect.top - (previousRect.top + previousRect.height) : nextRect ? nextRect.top - (currentRect.top + currentRect.height) : 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return nextRect ? nextRect.top - (currentRect.top + currentRect.height) : previousRect ? currentRect.top - (previousRect.top + previousRect.height) : 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const ID_PREFIX = 'Sortable';
|
|
165
|
+
const Context = /*#__PURE__*/React__default.default.createContext({
|
|
166
|
+
activeIndex: -1,
|
|
167
|
+
containerId: ID_PREFIX,
|
|
168
|
+
disableTransforms: false,
|
|
169
|
+
items: [],
|
|
170
|
+
overIndex: -1,
|
|
171
|
+
useDragOverlay: false,
|
|
172
|
+
sortedRects: [],
|
|
173
|
+
strategy: rectSortingStrategy,
|
|
174
|
+
disabled: {
|
|
175
|
+
draggable: false,
|
|
176
|
+
droppable: false
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
function SortableContext(_ref) {
|
|
180
|
+
let {
|
|
181
|
+
children,
|
|
182
|
+
id,
|
|
183
|
+
items: userDefinedItems,
|
|
184
|
+
strategy = rectSortingStrategy,
|
|
185
|
+
disabled: disabledProp = false
|
|
186
|
+
} = _ref;
|
|
187
|
+
const {
|
|
188
|
+
active,
|
|
189
|
+
dragOverlay,
|
|
190
|
+
droppableRects,
|
|
191
|
+
over,
|
|
192
|
+
measureDroppableContainers
|
|
193
|
+
} = core.useDndContext();
|
|
194
|
+
const containerId = utilities_esm.useUniqueId(ID_PREFIX, id);
|
|
195
|
+
const useDragOverlay = Boolean(dragOverlay.rect !== null);
|
|
196
|
+
const items = React.useMemo(() => userDefinedItems.map(item => typeof item === 'object' && 'id' in item ? item.id : item), [userDefinedItems]);
|
|
197
|
+
const isDragging = active != null;
|
|
198
|
+
const activeIndex = active ? items.indexOf(active.id) : -1;
|
|
199
|
+
const overIndex = over ? items.indexOf(over.id) : -1;
|
|
200
|
+
const previousItemsRef = React.useRef(items);
|
|
201
|
+
const itemsHaveChanged = !itemsEqual(items, previousItemsRef.current);
|
|
202
|
+
const disableTransforms = overIndex !== -1 && activeIndex === -1 || itemsHaveChanged;
|
|
203
|
+
const disabled = normalizeDisabled(disabledProp);
|
|
204
|
+
utilities_esm.useIsomorphicLayoutEffect(() => {
|
|
205
|
+
if (itemsHaveChanged && isDragging) {
|
|
206
|
+
measureDroppableContainers(items);
|
|
207
|
+
}
|
|
208
|
+
}, [itemsHaveChanged, items, isDragging, measureDroppableContainers]);
|
|
209
|
+
React.useEffect(() => {
|
|
210
|
+
previousItemsRef.current = items;
|
|
211
|
+
}, [items]);
|
|
212
|
+
const contextValue = React.useMemo(() => ({
|
|
213
|
+
activeIndex,
|
|
214
|
+
containerId,
|
|
215
|
+
disabled,
|
|
216
|
+
disableTransforms,
|
|
217
|
+
items,
|
|
218
|
+
overIndex,
|
|
219
|
+
useDragOverlay,
|
|
220
|
+
sortedRects: getSortedRects(items, droppableRects),
|
|
221
|
+
strategy
|
|
222
|
+
}), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
223
|
+
[activeIndex, containerId, disabled.draggable, disabled.droppable, disableTransforms, items, overIndex, droppableRects, useDragOverlay, strategy]);
|
|
224
|
+
return React__default.default.createElement(Context.Provider, {
|
|
225
|
+
value: contextValue
|
|
226
|
+
}, children);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const defaultNewIndexGetter = _ref => {
|
|
230
|
+
let {
|
|
231
|
+
id,
|
|
232
|
+
items,
|
|
233
|
+
activeIndex,
|
|
234
|
+
overIndex
|
|
235
|
+
} = _ref;
|
|
236
|
+
return arrayMove(items, activeIndex, overIndex).indexOf(id);
|
|
237
|
+
};
|
|
238
|
+
const defaultAnimateLayoutChanges = _ref2 => {
|
|
239
|
+
let {
|
|
240
|
+
containerId,
|
|
241
|
+
isSorting,
|
|
242
|
+
wasDragging,
|
|
243
|
+
index,
|
|
244
|
+
items,
|
|
245
|
+
newIndex,
|
|
246
|
+
previousItems,
|
|
247
|
+
previousContainerId,
|
|
248
|
+
transition
|
|
249
|
+
} = _ref2;
|
|
250
|
+
|
|
251
|
+
if (!transition || !wasDragging) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (previousItems !== items && index === newIndex) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (isSorting) {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return newIndex !== index && containerId === previousContainerId;
|
|
264
|
+
};
|
|
265
|
+
const defaultTransition = {
|
|
266
|
+
duration: 200,
|
|
267
|
+
easing: 'ease'
|
|
268
|
+
};
|
|
269
|
+
const transitionProperty = 'transform';
|
|
270
|
+
const disabledTransition = /*#__PURE__*/utilities_esm.CSS.Transition.toString({
|
|
271
|
+
property: transitionProperty,
|
|
272
|
+
duration: 0,
|
|
273
|
+
easing: 'linear'
|
|
274
|
+
});
|
|
275
|
+
const defaultAttributes = {
|
|
276
|
+
roleDescription: 'sortable'
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/*
|
|
280
|
+
* When the index of an item changes while sorting,
|
|
281
|
+
* we need to temporarily disable the transforms
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
function useDerivedTransform(_ref) {
|
|
285
|
+
let {
|
|
286
|
+
disabled,
|
|
287
|
+
index,
|
|
288
|
+
node,
|
|
289
|
+
rect
|
|
290
|
+
} = _ref;
|
|
291
|
+
const [derivedTransform, setDerivedtransform] = React.useState(null);
|
|
292
|
+
const previousIndex = React.useRef(index);
|
|
293
|
+
utilities_esm.useIsomorphicLayoutEffect(() => {
|
|
294
|
+
if (!disabled && index !== previousIndex.current && node.current) {
|
|
295
|
+
const initial = rect.current;
|
|
296
|
+
|
|
297
|
+
if (initial) {
|
|
298
|
+
const current = core.getClientRect(node.current, {
|
|
299
|
+
ignoreTransform: true
|
|
300
|
+
});
|
|
301
|
+
const delta = {
|
|
302
|
+
x: initial.left - current.left,
|
|
303
|
+
y: initial.top - current.top,
|
|
304
|
+
scaleX: initial.width / current.width,
|
|
305
|
+
scaleY: initial.height / current.height
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
if (delta.x || delta.y) {
|
|
309
|
+
setDerivedtransform(delta);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (index !== previousIndex.current) {
|
|
315
|
+
previousIndex.current = index;
|
|
316
|
+
}
|
|
317
|
+
}, [disabled, index, node, rect]);
|
|
318
|
+
React.useEffect(() => {
|
|
319
|
+
if (derivedTransform) {
|
|
320
|
+
setDerivedtransform(null);
|
|
321
|
+
}
|
|
322
|
+
}, [derivedTransform]);
|
|
323
|
+
return derivedTransform;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function useSortable(_ref) {
|
|
327
|
+
let {
|
|
328
|
+
animateLayoutChanges = defaultAnimateLayoutChanges,
|
|
329
|
+
attributes: userDefinedAttributes,
|
|
330
|
+
disabled: localDisabled,
|
|
331
|
+
data: customData,
|
|
332
|
+
getNewIndex = defaultNewIndexGetter,
|
|
333
|
+
id,
|
|
334
|
+
strategy: localStrategy,
|
|
335
|
+
resizeObserverConfig,
|
|
336
|
+
transition = defaultTransition
|
|
337
|
+
} = _ref;
|
|
338
|
+
const {
|
|
339
|
+
items,
|
|
340
|
+
containerId,
|
|
341
|
+
activeIndex,
|
|
342
|
+
disabled: globalDisabled,
|
|
343
|
+
disableTransforms,
|
|
344
|
+
sortedRects,
|
|
345
|
+
overIndex,
|
|
346
|
+
useDragOverlay,
|
|
347
|
+
strategy: globalStrategy
|
|
348
|
+
} = React.useContext(Context);
|
|
349
|
+
const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
|
|
350
|
+
const index = items.indexOf(id);
|
|
351
|
+
const data = React.useMemo(() => ({
|
|
352
|
+
sortable: {
|
|
353
|
+
containerId,
|
|
354
|
+
index,
|
|
355
|
+
items
|
|
356
|
+
},
|
|
357
|
+
...customData
|
|
358
|
+
}), [containerId, customData, index, items]);
|
|
359
|
+
const itemsAfterCurrentSortable = React.useMemo(() => items.slice(items.indexOf(id)), [items, id]);
|
|
360
|
+
const {
|
|
361
|
+
rect,
|
|
362
|
+
node,
|
|
363
|
+
isOver,
|
|
364
|
+
setNodeRef: setDroppableNodeRef
|
|
365
|
+
} = core.useDroppable({
|
|
366
|
+
id,
|
|
367
|
+
data,
|
|
368
|
+
disabled: disabled.droppable,
|
|
369
|
+
resizeObserverConfig: {
|
|
370
|
+
updateMeasurementsFor: itemsAfterCurrentSortable,
|
|
371
|
+
...resizeObserverConfig
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
const {
|
|
375
|
+
active,
|
|
376
|
+
activatorEvent,
|
|
377
|
+
activeNodeRect,
|
|
378
|
+
attributes,
|
|
379
|
+
setNodeRef: setDraggableNodeRef,
|
|
380
|
+
listeners,
|
|
381
|
+
isDragging,
|
|
382
|
+
over,
|
|
383
|
+
setActivatorNodeRef,
|
|
384
|
+
transform
|
|
385
|
+
} = core.useDraggable({
|
|
386
|
+
id,
|
|
387
|
+
data,
|
|
388
|
+
attributes: { ...defaultAttributes,
|
|
389
|
+
...userDefinedAttributes
|
|
390
|
+
},
|
|
391
|
+
disabled: disabled.draggable
|
|
392
|
+
});
|
|
393
|
+
const setNodeRef = utilities_esm.useCombinedRefs(setDroppableNodeRef, setDraggableNodeRef);
|
|
394
|
+
const isSorting = Boolean(active);
|
|
395
|
+
const displaceItem = isSorting && !disableTransforms && isValidIndex(activeIndex) && isValidIndex(overIndex);
|
|
396
|
+
const shouldDisplaceDragSource = !useDragOverlay && isDragging;
|
|
397
|
+
const dragSourceDisplacement = shouldDisplaceDragSource && displaceItem ? transform : null;
|
|
398
|
+
const strategy = localStrategy != null ? localStrategy : globalStrategy;
|
|
399
|
+
const finalTransform = displaceItem ? dragSourceDisplacement != null ? dragSourceDisplacement : strategy({
|
|
400
|
+
rects: sortedRects,
|
|
401
|
+
activeNodeRect,
|
|
402
|
+
activeIndex,
|
|
403
|
+
overIndex,
|
|
404
|
+
index
|
|
405
|
+
}) : null;
|
|
406
|
+
const newIndex = isValidIndex(activeIndex) && isValidIndex(overIndex) ? getNewIndex({
|
|
407
|
+
id,
|
|
408
|
+
items,
|
|
409
|
+
activeIndex,
|
|
410
|
+
overIndex
|
|
411
|
+
}) : index;
|
|
412
|
+
const activeId = active == null ? void 0 : active.id;
|
|
413
|
+
const previous = React.useRef({
|
|
414
|
+
activeId,
|
|
415
|
+
items,
|
|
416
|
+
newIndex,
|
|
417
|
+
containerId
|
|
418
|
+
});
|
|
419
|
+
const itemsHaveChanged = items !== previous.current.items;
|
|
420
|
+
const shouldAnimateLayoutChanges = animateLayoutChanges({
|
|
421
|
+
active,
|
|
422
|
+
containerId,
|
|
423
|
+
isDragging,
|
|
424
|
+
isSorting,
|
|
425
|
+
id,
|
|
426
|
+
index,
|
|
427
|
+
items,
|
|
428
|
+
newIndex: previous.current.newIndex,
|
|
429
|
+
previousItems: previous.current.items,
|
|
430
|
+
previousContainerId: previous.current.containerId,
|
|
431
|
+
transition,
|
|
432
|
+
wasDragging: previous.current.activeId != null
|
|
433
|
+
});
|
|
434
|
+
const derivedTransform = useDerivedTransform({
|
|
435
|
+
disabled: !shouldAnimateLayoutChanges,
|
|
436
|
+
index,
|
|
437
|
+
node,
|
|
438
|
+
rect
|
|
439
|
+
});
|
|
440
|
+
React.useEffect(() => {
|
|
441
|
+
if (isSorting && previous.current.newIndex !== newIndex) {
|
|
442
|
+
previous.current.newIndex = newIndex;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if (containerId !== previous.current.containerId) {
|
|
446
|
+
previous.current.containerId = containerId;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (items !== previous.current.items) {
|
|
450
|
+
previous.current.items = items;
|
|
451
|
+
}
|
|
452
|
+
}, [isSorting, newIndex, containerId, items]);
|
|
453
|
+
React.useEffect(() => {
|
|
454
|
+
if (activeId === previous.current.activeId) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (activeId && !previous.current.activeId) {
|
|
459
|
+
previous.current.activeId = activeId;
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const timeoutId = setTimeout(() => {
|
|
464
|
+
previous.current.activeId = activeId;
|
|
465
|
+
}, 50);
|
|
466
|
+
return () => clearTimeout(timeoutId);
|
|
467
|
+
}, [activeId]);
|
|
468
|
+
return {
|
|
469
|
+
active,
|
|
470
|
+
activeIndex,
|
|
471
|
+
attributes,
|
|
472
|
+
data,
|
|
473
|
+
rect,
|
|
474
|
+
index,
|
|
475
|
+
newIndex,
|
|
476
|
+
items,
|
|
477
|
+
isOver,
|
|
478
|
+
isSorting,
|
|
479
|
+
isDragging,
|
|
480
|
+
listeners,
|
|
481
|
+
node,
|
|
482
|
+
overIndex,
|
|
483
|
+
over,
|
|
484
|
+
setNodeRef,
|
|
485
|
+
setActivatorNodeRef,
|
|
486
|
+
setDroppableNodeRef,
|
|
487
|
+
setDraggableNodeRef,
|
|
488
|
+
transform: derivedTransform != null ? derivedTransform : finalTransform,
|
|
489
|
+
transition: getTransition()
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
function getTransition() {
|
|
493
|
+
if ( // Temporarily disable transitions for a single frame to set up derived transforms
|
|
494
|
+
derivedTransform || // Or to prevent items jumping to back to their "new" position when items change
|
|
495
|
+
itemsHaveChanged && previous.current.newIndex === index) {
|
|
496
|
+
return disabledTransition;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (shouldDisplaceDragSource && !utilities_esm.isKeyboardEvent(activatorEvent) || !transition) {
|
|
500
|
+
return undefined;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (isSorting || shouldAnimateLayoutChanges) {
|
|
504
|
+
return utilities_esm.CSS.Transition.toString({ ...transition,
|
|
505
|
+
property: transitionProperty
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return undefined;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function normalizeLocalDisabled(localDisabled, globalDisabled) {
|
|
514
|
+
var _localDisabled$dragga, _localDisabled$droppa;
|
|
515
|
+
|
|
516
|
+
if (typeof localDisabled === 'boolean') {
|
|
517
|
+
return {
|
|
518
|
+
draggable: localDisabled,
|
|
519
|
+
// Backwards compatibility
|
|
520
|
+
droppable: false
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return {
|
|
525
|
+
draggable: (_localDisabled$dragga = localDisabled == null ? void 0 : localDisabled.draggable) != null ? _localDisabled$dragga : globalDisabled.draggable,
|
|
526
|
+
droppable: (_localDisabled$droppa = localDisabled == null ? void 0 : localDisabled.droppable) != null ? _localDisabled$droppa : globalDisabled.droppable
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
[core.KeyboardCode.Down, core.KeyboardCode.Right, core.KeyboardCode.Up, core.KeyboardCode.Left];
|
|
531
|
+
|
|
532
|
+
exports.SortableContext = SortableContext;
|
|
533
|
+
exports.arrayMove = arrayMove;
|
|
534
|
+
exports.defaultAnimateLayoutChanges = defaultAnimateLayoutChanges;
|
|
535
|
+
exports.defaultNewIndexGetter = defaultNewIndexGetter;
|
|
536
|
+
exports.rectSortingStrategy = rectSortingStrategy;
|
|
537
|
+
exports.useSortable = useSortable;
|
|
538
|
+
exports.verticalListSortingStrategy = verticalListSortingStrategy;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function useCombinedRefs() {
|
|
6
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
7
|
+
refs[_key] = arguments[_key];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return React.useMemo(() => node => {
|
|
11
|
+
refs.forEach(ref => ref(node));
|
|
12
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
13
|
+
refs);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js
|
|
17
|
+
const canUseDOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
18
|
+
|
|
19
|
+
function isWindow(element) {
|
|
20
|
+
const elementString = Object.prototype.toString.call(element);
|
|
21
|
+
return elementString === '[object Window]' || // In Electron context the Window object serializes to [object global]
|
|
22
|
+
elementString === '[object global]';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isNode(node) {
|
|
26
|
+
return 'nodeType' in node;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getWindow(target) {
|
|
30
|
+
var _target$ownerDocument, _target$ownerDocument2;
|
|
31
|
+
|
|
32
|
+
if (!target) {
|
|
33
|
+
return window;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (isWindow(target)) {
|
|
37
|
+
return target;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!isNode(target)) {
|
|
41
|
+
return window;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (_target$ownerDocument = (_target$ownerDocument2 = target.ownerDocument) == null ? void 0 : _target$ownerDocument2.defaultView) != null ? _target$ownerDocument : window;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A hook that resolves to useEffect on the server and useLayoutEffect on the client
|
|
49
|
+
* @param callback {function} Callback function that is invoked when the dependencies of the hook change
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
const useIsomorphicLayoutEffect = canUseDOM ? React.useLayoutEffect : React.useEffect;
|
|
53
|
+
|
|
54
|
+
let ids = {};
|
|
55
|
+
function useUniqueId(prefix, value) {
|
|
56
|
+
return React.useMemo(() => {
|
|
57
|
+
if (value) {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const id = ids[prefix] == null ? 0 : ids[prefix] + 1;
|
|
62
|
+
ids[prefix] = id;
|
|
63
|
+
return prefix + "-" + id;
|
|
64
|
+
}, [prefix, value]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function isKeyboardEvent(event) {
|
|
68
|
+
if (!event) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
KeyboardEvent
|
|
74
|
+
} = getWindow(event.target);
|
|
75
|
+
return KeyboardEvent && event instanceof KeyboardEvent;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const CSS = /*#__PURE__*/Object.freeze({
|
|
79
|
+
Translate: {
|
|
80
|
+
toString(transform) {
|
|
81
|
+
if (!transform) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const {
|
|
86
|
+
x,
|
|
87
|
+
y
|
|
88
|
+
} = transform;
|
|
89
|
+
return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
},
|
|
93
|
+
Scale: {
|
|
94
|
+
toString(transform) {
|
|
95
|
+
if (!transform) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const {
|
|
100
|
+
scaleX,
|
|
101
|
+
scaleY
|
|
102
|
+
} = transform;
|
|
103
|
+
return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
},
|
|
107
|
+
Transform: {
|
|
108
|
+
toString(transform) {
|
|
109
|
+
if (!transform) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(' ');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
},
|
|
117
|
+
Transition: {
|
|
118
|
+
toString(_ref) {
|
|
119
|
+
let {
|
|
120
|
+
property,
|
|
121
|
+
duration,
|
|
122
|
+
easing
|
|
123
|
+
} = _ref;
|
|
124
|
+
return property + " " + duration + "ms " + easing;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
exports.CSS = CSS;
|
|
131
|
+
exports.canUseDOM = canUseDOM;
|
|
132
|
+
exports.getWindow = getWindow;
|
|
133
|
+
exports.isKeyboardEvent = isKeyboardEvent;
|
|
134
|
+
exports.isNode = isNode;
|
|
135
|
+
exports.isWindow = isWindow;
|
|
136
|
+
exports.useCombinedRefs = useCombinedRefs;
|
|
137
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
138
|
+
exports.useUniqueId = useUniqueId;
|