@chayns-components/navigation 5.0.65 → 5.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.
- package/lib/cjs/components/navigation-layout/NavigationLayout.constants.js +14 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.constants.js.map +1 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.context.js +26 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.context.js.map +1 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.js +105 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.js.map +1 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.styles.js +74 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.styles.js.map +1 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.types.js +6 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.types.js.map +1 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.utils.js +261 -0
- package/lib/cjs/components/navigation-layout/NavigationLayout.utils.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-header/NavigationHeader.js +31 -0
- package/lib/cjs/components/navigation-layout/navigation-header/NavigationHeader.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-header/NavigationHeader.styles.js +30 -0
- package/lib/cjs/components/navigation-layout/navigation-header/NavigationHeader.styles.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-header/NavigationHeader.types.js +6 -0
- package/lib/cjs/components/navigation-layout/navigation-header/NavigationHeader.types.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.js +71 -0
- package/lib/cjs/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.styles.js +19 -0
- package/lib/cjs/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.styles.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.context.js +26 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.context.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.js +140 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.styles.js +89 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.styles.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.types.js +6 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.types.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.utils.js +83 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/NavigationSidebar.utils.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.js +17 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.styles.js +19 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.styles.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.context.js +26 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.context.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.hooks.js +129 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.hooks.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.js +79 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.styles.js +69 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.styles.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.hooks.js +265 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.hooks.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.js +193 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.styles.js +132 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.styles.js.map +1 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.utils.js +78 -0
- package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.utils.js.map +1 -0
- package/lib/cjs/components/split-layout/SplitLayout.js +90 -0
- package/lib/cjs/components/split-layout/SplitLayout.js.map +1 -0
- package/lib/cjs/components/split-layout/SplitLayout.styles.js +44 -0
- package/lib/cjs/components/split-layout/SplitLayout.styles.js.map +1 -0
- package/lib/cjs/components/split-layout/SplitLayout.types.js +12 -0
- package/lib/cjs/components/split-layout/SplitLayout.types.js.map +1 -0
- package/lib/cjs/components/split-layout/SplitLayout.utils.js +25 -0
- package/lib/cjs/components/split-layout/SplitLayout.utils.js.map +1 -0
- package/lib/cjs/components/split-layout/resize-handle/ResizeHandle.hooks.js +63 -0
- package/lib/cjs/components/split-layout/resize-handle/ResizeHandle.hooks.js.map +1 -0
- package/lib/cjs/components/split-layout/resize-handle/ResizeHandle.js +34 -0
- package/lib/cjs/components/split-layout/resize-handle/ResizeHandle.js.map +1 -0
- package/lib/cjs/components/split-layout/resize-handle/ResizeHandle.styles.js +58 -0
- package/lib/cjs/components/split-layout/resize-handle/ResizeHandle.styles.js.map +1 -0
- package/lib/cjs/components/user-image/UserImage.js +38 -0
- package/lib/cjs/components/user-image/UserImage.js.map +1 -0
- package/lib/cjs/components/user-image/UserImage.types.js +6 -0
- package/lib/cjs/components/user-image/UserImage.types.js.map +1 -0
- package/lib/cjs/components/user-image/userImage.styles.js +27 -0
- package/lib/cjs/components/user-image/userImage.styles.js.map +1 -0
- package/lib/cjs/index.js +49 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/components/navigation-layout/NavigationLayout.constants.js +8 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.constants.js.map +1 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.context.js +17 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.context.js.map +1 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.js +97 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.js.map +1 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.styles.js +67 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.styles.js.map +1 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.types.js +2 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.types.js.map +1 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.utils.js +251 -0
- package/lib/esm/components/navigation-layout/NavigationLayout.utils.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-header/NavigationHeader.js +24 -0
- package/lib/esm/components/navigation-layout/navigation-header/NavigationHeader.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-header/NavigationHeader.styles.js +23 -0
- package/lib/esm/components/navigation-layout/navigation-header/NavigationHeader.styles.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-header/NavigationHeader.types.js +2 -0
- package/lib/esm/components/navigation-layout/navigation-header/NavigationHeader.types.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.js +64 -0
- package/lib/esm/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.styles.js +12 -0
- package/lib/esm/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.styles.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.context.js +17 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.context.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.js +132 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.styles.js +82 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.styles.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.types.js +2 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.types.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.utils.js +73 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/NavigationSidebar.utils.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.js +10 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.styles.js +12 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.styles.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.context.js +17 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.context.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.hooks.js +119 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.hooks.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.js +71 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.styles.js +62 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.styles.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.hooks.js +257 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.hooks.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.js +186 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.styles.js +126 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.styles.js.map +1 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.utils.js +67 -0
- package/lib/esm/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.utils.js.map +1 -0
- package/lib/esm/components/split-layout/SplitLayout.js +80 -0
- package/lib/esm/components/split-layout/SplitLayout.js.map +1 -0
- package/lib/esm/components/split-layout/SplitLayout.styles.js +37 -0
- package/lib/esm/components/split-layout/SplitLayout.styles.js.map +1 -0
- package/lib/esm/components/split-layout/SplitLayout.types.js +6 -0
- package/lib/esm/components/split-layout/SplitLayout.types.js.map +1 -0
- package/lib/esm/components/split-layout/SplitLayout.utils.js +17 -0
- package/lib/esm/components/split-layout/SplitLayout.utils.js.map +1 -0
- package/lib/esm/components/split-layout/resize-handle/ResizeHandle.hooks.js +54 -0
- package/lib/esm/components/split-layout/resize-handle/ResizeHandle.hooks.js.map +1 -0
- package/lib/esm/components/split-layout/resize-handle/ResizeHandle.js +27 -0
- package/lib/esm/components/split-layout/resize-handle/ResizeHandle.js.map +1 -0
- package/lib/esm/components/split-layout/resize-handle/ResizeHandle.styles.js +52 -0
- package/lib/esm/components/split-layout/resize-handle/ResizeHandle.styles.js.map +1 -0
- package/lib/esm/components/user-image/UserImage.js +31 -0
- package/lib/esm/components/user-image/UserImage.js.map +1 -0
- package/lib/esm/components/user-image/UserImage.types.js +2 -0
- package/lib/esm/components/user-image/UserImage.types.js.map +1 -0
- package/lib/esm/components/user-image/userImage.styles.js +20 -0
- package/lib/esm/components/user-image/userImage.styles.js.map +1 -0
- package/lib/esm/index.js +15 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/types/components/navigation-layout/NavigationLayout.constants.d.ts +7 -0
- package/lib/types/components/navigation-layout/NavigationLayout.context.d.ts +15 -0
- package/lib/types/components/navigation-layout/NavigationLayout.d.ts +4 -0
- package/lib/types/components/navigation-layout/NavigationLayout.styles.d.ts +19 -0
- package/lib/types/components/navigation-layout/NavigationLayout.types.d.ts +125 -0
- package/lib/types/components/navigation-layout/NavigationLayout.utils.d.ts +22 -0
- package/lib/types/components/navigation-layout/navigation-header/NavigationHeader.d.ts +4 -0
- package/lib/types/components/navigation-layout/navigation-header/NavigationHeader.styles.d.ts +9 -0
- package/lib/types/components/navigation-layout/navigation-header/NavigationHeader.types.d.ts +10 -0
- package/lib/types/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.d.ts +8 -0
- package/lib/types/components/navigation-layout/navigation-header/menu-toggle/MenuToggle.styles.d.ts +3 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/NavigationSidebar.context.d.ts +19 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/NavigationSidebar.d.ts +4 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/NavigationSidebar.styles.d.ts +27 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/NavigationSidebar.types.d.ts +54 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/NavigationSidebar.utils.d.ts +22 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.d.ts +6 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-divider/SidebarDivider.styles.d.ts +6 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.context.d.ts +22 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.d.ts +9 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.hooks.d.ts +26 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.styles.d.ts +9 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.d.ts +10 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.hooks.d.ts +51 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.styles.d.ts +24 -0
- package/lib/types/components/navigation-layout/navigation-sidebar/sidebar-group/sidebar-item/SidebarItem.utils.d.ts +23 -0
- package/lib/types/components/split-layout/SplitLayout.d.ts +4 -0
- package/lib/types/components/split-layout/SplitLayout.styles.d.ts +12 -0
- package/lib/types/components/split-layout/SplitLayout.types.d.ts +19 -0
- package/lib/types/components/split-layout/SplitLayout.utils.d.ts +8 -0
- package/lib/types/components/split-layout/resize-handle/ResizeHandle.d.ts +11 -0
- package/lib/types/components/split-layout/resize-handle/ResizeHandle.hooks.d.ts +9 -0
- package/lib/types/components/split-layout/resize-handle/ResizeHandle.styles.d.ts +15 -0
- package/lib/types/components/user-image/UserImage.d.ts +4 -0
- package/lib/types/components/user-image/UserImage.types.d.ts +8 -0
- package/lib/types/components/user-image/userImage.styles.d.ts +10 -0
- package/lib/types/index.d.ts +10 -2
- package/package.json +3 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSidebarGroupReorderContext = exports.SidebarGroupReorderProvider = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
9
|
+
const SidebarGroupReorderContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
10
|
+
const SidebarGroupReorderProvider = ({
|
|
11
|
+
children,
|
|
12
|
+
value
|
|
13
|
+
}) => /*#__PURE__*/_react.default.createElement(SidebarGroupReorderContext.Provider, {
|
|
14
|
+
value: value
|
|
15
|
+
}, children);
|
|
16
|
+
exports.SidebarGroupReorderProvider = SidebarGroupReorderProvider;
|
|
17
|
+
SidebarGroupReorderProvider.displayName = 'SidebarGroupReorderProvider';
|
|
18
|
+
const useSidebarGroupReorderContext = () => {
|
|
19
|
+
const context = (0, _react.useContext)(SidebarGroupReorderContext);
|
|
20
|
+
if (!context) {
|
|
21
|
+
throw new Error('useSidebarGroupReorderContext must be used within SidebarGroupReorderProvider.');
|
|
22
|
+
}
|
|
23
|
+
return context;
|
|
24
|
+
};
|
|
25
|
+
exports.useSidebarGroupReorderContext = useSidebarGroupReorderContext;
|
|
26
|
+
//# sourceMappingURL=SidebarGroup.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarGroup.context.js","names":["_react","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SidebarGroupReorderContext","createContext","SidebarGroupReorderProvider","children","value","createElement","Provider","exports","displayName","useSidebarGroupReorderContext","context","useContext","Error"],"sources":["../../../../../../src/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.context.tsx"],"sourcesContent":["import React, { ReactNode, createContext, useContext } from 'react';\nimport {\n NavigationLayoutItem,\n NavigationLayoutItemReorderSource,\n NavigationLayoutItemReorderTarget,\n} from '../../NavigationLayout.types';\n\ninterface SidebarGroupReorderContextValue {\n draggedItemId?: NavigationLayoutItem['id'];\n dropTarget: NavigationLayoutItemReorderTarget | null;\n isDragging: boolean;\n isReorderEnabled: boolean;\n onDragEnd: VoidFunction;\n onDragStart: (\n event: React.DragEvent<HTMLDivElement>,\n item: NavigationLayoutItemReorderSource,\n ) => void;\n onDrop: (target: NavigationLayoutItemReorderTarget) => void;\n onDropTargetChange: (target: NavigationLayoutItemReorderTarget) => void;\n}\n\ninterface SidebarGroupReorderProviderProps {\n children: ReactNode;\n value: SidebarGroupReorderContextValue;\n}\n\nconst SidebarGroupReorderContext = createContext<SidebarGroupReorderContextValue | null>(null);\n\nexport const SidebarGroupReorderProvider = ({\n children,\n value,\n}: SidebarGroupReorderProviderProps) => (\n <SidebarGroupReorderContext.Provider value={value}>\n {children}\n </SidebarGroupReorderContext.Provider>\n);\n\nSidebarGroupReorderProvider.displayName = 'SidebarGroupReorderProvider';\n\nexport const useSidebarGroupReorderContext = (): SidebarGroupReorderContextValue => {\n const context = useContext(SidebarGroupReorderContext);\n\n if (!context) {\n throw new Error(\n 'useSidebarGroupReorderContext must be used within SidebarGroupReorderProvider.',\n );\n }\n\n return context;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAoE,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CA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AU,EAACX,0BAA0B,CAAC;EAEtD,IAAI,CAACU,OAAO,EAAE;IACV,MAAM,IAAIE,KAAK,CACX,gFACJ,CAAC;EACL;EAEA,OAAOF,OAAO;AAClB,CAAC;AAACH,OAAA,CAAAE,6BAAA,GAAAA,6BAAA","ignoreList":[]}
|
package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.hooks.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSidebarGroupReorder = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _NavigationLayout = require("../../NavigationLayout.utils");
|
|
9
|
+
const setDragMoveEffect = event => {
|
|
10
|
+
const {
|
|
11
|
+
dataTransfer
|
|
12
|
+
} = event;
|
|
13
|
+
dataTransfer.dropEffect = 'move';
|
|
14
|
+
};
|
|
15
|
+
const useSidebarGroupReorder = ({
|
|
16
|
+
groupId,
|
|
17
|
+
isCompact,
|
|
18
|
+
isReorderable,
|
|
19
|
+
items,
|
|
20
|
+
onItemReorder
|
|
21
|
+
}) => {
|
|
22
|
+
const [draggedItem, setDraggedItem] = (0, _react.useState)(null);
|
|
23
|
+
const [dropTarget, setDropTarget] = (0, _react.useState)(null);
|
|
24
|
+
const isReorderEnabled = (0, _react.useMemo)(() => Boolean(isReorderable && !isCompact && typeof onItemReorder === 'function'), [isCompact, isReorderable, onItemReorder]);
|
|
25
|
+
const resetDragState = (0, _react.useCallback)(() => {
|
|
26
|
+
setDraggedItem(null);
|
|
27
|
+
setDropTarget(null);
|
|
28
|
+
}, []);
|
|
29
|
+
const createReorderEvent = (0, _react.useCallback)(target => {
|
|
30
|
+
if (!draggedItem) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
groupId,
|
|
35
|
+
itemId: draggedItem.itemId,
|
|
36
|
+
source: draggedItem,
|
|
37
|
+
target
|
|
38
|
+
};
|
|
39
|
+
}, [draggedItem, groupId]);
|
|
40
|
+
const handleDragStart = (0, _react.useCallback)((event, item) => {
|
|
41
|
+
if (!isReorderEnabled) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const {
|
|
45
|
+
dataTransfer
|
|
46
|
+
} = event;
|
|
47
|
+
dataTransfer.effectAllowed = 'move';
|
|
48
|
+
dataTransfer.setData('text/plain', item.itemId);
|
|
49
|
+
setDraggedItem(item);
|
|
50
|
+
setDropTarget(null);
|
|
51
|
+
}, [isReorderEnabled]);
|
|
52
|
+
const handleDropTargetChange = (0, _react.useCallback)(target => {
|
|
53
|
+
const nextEvent = createReorderEvent(target);
|
|
54
|
+
if (!nextEvent || !(0, _NavigationLayout.isNavigationLayoutItemReorderEventValid)({
|
|
55
|
+
items,
|
|
56
|
+
event: nextEvent
|
|
57
|
+
})) {
|
|
58
|
+
setDropTarget(null);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setDropTarget(target);
|
|
62
|
+
}, [createReorderEvent, items]);
|
|
63
|
+
const handleDrop = (0, _react.useCallback)(target => {
|
|
64
|
+
const nextEvent = createReorderEvent(target);
|
|
65
|
+
if (!nextEvent || typeof onItemReorder !== 'function' || !(0, _NavigationLayout.isNavigationLayoutItemReorderEventValid)({
|
|
66
|
+
items,
|
|
67
|
+
event: nextEvent
|
|
68
|
+
})) {
|
|
69
|
+
resetDragState();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
onItemReorder(nextEvent);
|
|
73
|
+
resetDragState();
|
|
74
|
+
}, [createReorderEvent, items, onItemReorder, resetDragState]);
|
|
75
|
+
const groupEndTarget = (0, _react.useMemo)(() => {
|
|
76
|
+
var _items;
|
|
77
|
+
return {
|
|
78
|
+
itemId: (_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.id,
|
|
79
|
+
parentIds: [],
|
|
80
|
+
index: items.length,
|
|
81
|
+
placement: 'after'
|
|
82
|
+
};
|
|
83
|
+
}, [items]);
|
|
84
|
+
const isGroupEndTargetActive = (0, _react.useMemo)(() => (0, _NavigationLayout.isNavigationLayoutReorderTargetEqual)({
|
|
85
|
+
targetA: dropTarget,
|
|
86
|
+
targetB: groupEndTarget
|
|
87
|
+
}), [dropTarget, groupEndTarget]);
|
|
88
|
+
const handleGroupEndDragOver = (0, _react.useCallback)(event => {
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
setDragMoveEffect(event);
|
|
91
|
+
handleDropTargetChange(groupEndTarget);
|
|
92
|
+
}, [groupEndTarget, handleDropTargetChange]);
|
|
93
|
+
const handleGroupEndDrop = (0, _react.useCallback)(event => {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
event.stopPropagation();
|
|
96
|
+
handleDrop(groupEndTarget);
|
|
97
|
+
}, [groupEndTarget, handleDrop]);
|
|
98
|
+
const handleGroupDragOver = (0, _react.useCallback)(event => {
|
|
99
|
+
if (!dropTarget) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
setDragMoveEffect(event);
|
|
104
|
+
}, [dropTarget]);
|
|
105
|
+
const handleGroupDrop = (0, _react.useCallback)(event => {
|
|
106
|
+
if (!dropTarget) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
handleDrop(dropTarget);
|
|
111
|
+
}, [dropTarget, handleDrop]);
|
|
112
|
+
return {
|
|
113
|
+
draggedItemId: draggedItem === null || draggedItem === void 0 ? void 0 : draggedItem.itemId,
|
|
114
|
+
dropTarget,
|
|
115
|
+
isDragging: draggedItem !== null,
|
|
116
|
+
isGroupEndTargetActive,
|
|
117
|
+
isReorderEnabled,
|
|
118
|
+
handleDragEnd: resetDragState,
|
|
119
|
+
handleDragStart,
|
|
120
|
+
handleDrop,
|
|
121
|
+
handleDropTargetChange,
|
|
122
|
+
handleGroupDragOver,
|
|
123
|
+
handleGroupDrop,
|
|
124
|
+
handleGroupEndDragOver,
|
|
125
|
+
handleGroupEndDrop
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
exports.useSidebarGroupReorder = useSidebarGroupReorder;
|
|
129
|
+
//# sourceMappingURL=SidebarGroup.hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarGroup.hooks.js","names":["_react","require","_NavigationLayout","setDragMoveEffect","event","dataTransfer","dropEffect","useSidebarGroupReorder","groupId","isCompact","isReorderable","items","onItemReorder","draggedItem","setDraggedItem","useState","dropTarget","setDropTarget","isReorderEnabled","useMemo","Boolean","resetDragState","useCallback","createReorderEvent","target","itemId","source","handleDragStart","item","effectAllowed","setData","handleDropTargetChange","nextEvent","isNavigationLayoutItemReorderEventValid","handleDrop","groupEndTarget","_items","length","id","parentIds","index","placement","isGroupEndTargetActive","isNavigationLayoutReorderTargetEqual","targetA","targetB","handleGroupEndDragOver","preventDefault","handleGroupEndDrop","stopPropagation","handleGroupDragOver","handleGroupDrop","draggedItemId","isDragging","handleDragEnd","exports"],"sources":["../../../../../../src/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.hooks.ts"],"sourcesContent":["import React, { useCallback, useMemo, useState } from 'react';\nimport {\n NavigationLayoutGroup,\n NavigationLayoutItem,\n NavigationLayoutItemReorderEvent,\n NavigationLayoutItemReorderSource,\n NavigationLayoutItemReorderTarget,\n NavigationLayoutProps,\n} from '../../NavigationLayout.types';\nimport {\n isNavigationLayoutItemReorderEventValid,\n isNavigationLayoutReorderTargetEqual,\n} from '../../NavigationLayout.utils';\n\ninterface UseSidebarGroupReorderOptions {\n groupId: NavigationLayoutGroup['id'];\n isCompact: boolean;\n isReorderable?: NavigationLayoutGroup['isReorderable'];\n items: NavigationLayoutItem[];\n onItemReorder?: NavigationLayoutProps['onItemReorder'];\n}\n\ninterface UseSidebarGroupReorderResult {\n draggedItemId?: NavigationLayoutItem['id'];\n dropTarget: NavigationLayoutItemReorderTarget | null;\n isDragging: boolean;\n isGroupEndTargetActive: boolean;\n isReorderEnabled: boolean;\n handleDragEnd: VoidFunction;\n handleDragStart: (\n event: React.DragEvent<HTMLDivElement>,\n item: NavigationLayoutItemReorderSource,\n ) => void;\n handleDrop: (target: NavigationLayoutItemReorderTarget) => void;\n handleDropTargetChange: (target: NavigationLayoutItemReorderTarget) => void;\n handleGroupDragOver: (event: React.DragEvent<HTMLDivElement>) => void;\n handleGroupDrop: (event: React.DragEvent<HTMLDivElement>) => void;\n handleGroupEndDragOver: (event: React.DragEvent<HTMLDivElement>) => void;\n handleGroupEndDrop: (event: React.DragEvent<HTMLDivElement>) => void;\n}\n\nconst setDragMoveEffect = (event: React.DragEvent<HTMLDivElement>): void => {\n const { dataTransfer } = event;\n\n dataTransfer.dropEffect = 'move';\n};\n\nexport const useSidebarGroupReorder = ({\n groupId,\n isCompact,\n isReorderable,\n items,\n onItemReorder,\n}: UseSidebarGroupReorderOptions): UseSidebarGroupReorderResult => {\n const [draggedItem, setDraggedItem] = useState<NavigationLayoutItemReorderSource | null>(null);\n const [dropTarget, setDropTarget] = useState<NavigationLayoutItemReorderTarget | null>(null);\n\n const isReorderEnabled = useMemo(\n () => Boolean(isReorderable && !isCompact && typeof onItemReorder === 'function'),\n [isCompact, isReorderable, onItemReorder],\n );\n\n const resetDragState = useCallback((): void => {\n setDraggedItem(null);\n setDropTarget(null);\n }, []);\n\n const createReorderEvent = useCallback(\n (target: NavigationLayoutItemReorderTarget): NavigationLayoutItemReorderEvent | null => {\n if (!draggedItem) {\n return null;\n }\n\n return {\n groupId,\n itemId: draggedItem.itemId,\n source: draggedItem,\n target,\n };\n },\n [draggedItem, groupId],\n );\n\n const handleDragStart = useCallback(\n (event: React.DragEvent<HTMLDivElement>, item: NavigationLayoutItemReorderSource): void => {\n if (!isReorderEnabled) {\n return;\n }\n\n const { dataTransfer } = event;\n\n dataTransfer.effectAllowed = 'move';\n dataTransfer.setData('text/plain', item.itemId);\n\n setDraggedItem(item);\n setDropTarget(null);\n },\n [isReorderEnabled],\n );\n\n const handleDropTargetChange = useCallback(\n (target: NavigationLayoutItemReorderTarget): void => {\n const nextEvent = createReorderEvent(target);\n\n if (\n !nextEvent ||\n !isNavigationLayoutItemReorderEventValid({ items, event: nextEvent })\n ) {\n setDropTarget(null);\n\n return;\n }\n\n setDropTarget(target);\n },\n [createReorderEvent, items],\n );\n\n const handleDrop = useCallback(\n (target: NavigationLayoutItemReorderTarget): void => {\n const nextEvent = createReorderEvent(target);\n\n if (\n !nextEvent ||\n typeof onItemReorder !== 'function' ||\n !isNavigationLayoutItemReorderEventValid({ items, event: nextEvent })\n ) {\n resetDragState();\n\n return;\n }\n\n onItemReorder(nextEvent);\n resetDragState();\n },\n [createReorderEvent, items, onItemReorder, resetDragState],\n );\n\n const groupEndTarget = useMemo<NavigationLayoutItemReorderTarget>(\n () => ({\n itemId: items[items.length - 1]?.id,\n parentIds: [],\n index: items.length,\n placement: 'after',\n }),\n [items],\n );\n\n const isGroupEndTargetActive = useMemo(\n () =>\n isNavigationLayoutReorderTargetEqual({\n targetA: dropTarget,\n targetB: groupEndTarget,\n }),\n [dropTarget, groupEndTarget],\n );\n\n const handleGroupEndDragOver = useCallback(\n (event: React.DragEvent<HTMLDivElement>): void => {\n event.preventDefault();\n setDragMoveEffect(event);\n handleDropTargetChange(groupEndTarget);\n },\n [groupEndTarget, handleDropTargetChange],\n );\n\n const handleGroupEndDrop = useCallback(\n (event: React.DragEvent<HTMLDivElement>): void => {\n event.preventDefault();\n event.stopPropagation();\n handleDrop(groupEndTarget);\n },\n [groupEndTarget, handleDrop],\n );\n\n const handleGroupDragOver = useCallback(\n (event: React.DragEvent<HTMLDivElement>): void => {\n if (!dropTarget) {\n return;\n }\n\n event.preventDefault();\n setDragMoveEffect(event);\n },\n [dropTarget],\n );\n\n const handleGroupDrop = useCallback(\n (event: React.DragEvent<HTMLDivElement>): void => {\n if (!dropTarget) {\n return;\n }\n\n event.preventDefault();\n handleDrop(dropTarget);\n },\n [dropTarget, handleDrop],\n );\n\n return {\n draggedItemId: draggedItem?.itemId,\n dropTarget,\n isDragging: draggedItem !== null,\n isGroupEndTargetActive,\n isReorderEnabled,\n handleDragEnd: resetDragState,\n handleDragStart,\n handleDrop,\n handleDropTargetChange,\n handleGroupDragOver,\n handleGroupDrop,\n handleGroupEndDragOver,\n handleGroupEndDrop,\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,iBAAA,GAAAD,OAAA;AAgCA,MAAME,iBAAiB,GAAIC,KAAsC,IAAW;EACxE,MAAM;IAAEC;EAAa,CAAC,GAAGD,KAAK;EAE9BC,YAAY,CAACC,UAAU,GAAG,MAAM;AACpC,CAAC;AAEM,MAAMC,sBAAsB,GAAGA,CAAC;EACnCC,OAAO;EACPC,SAAS;EACTC,aAAa;EACbC,KAAK;EACLC;AAC2B,CAAC,KAAmC;EAC/D,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAC,eAAQ,EAA2C,IAAI,CAAC;EAC9F,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAF,eAAQ,EAA2C,IAAI,CAAC;EAE5F,MAAMG,gBAAgB,GAAG,IAAAC,cAAO,EAC5B,MAAMC,OAAO,CAACV,aAAa,IAAI,CAACD,SAAS,IAAI,OAAOG,aAAa,KAAK,UAAU,CAAC,EACjF,CAACH,SAAS,EAAEC,aAAa,EAAEE,aAAa,CAC5C,CAAC;EAED,MAAMS,cAAc,GAAG,IAAAC,kBAAW,EAAC,MAAY;IAC3CR,cAAc,CAAC,IAAI,CAAC;IACpBG,aAAa,CAAC,IAAI,CAAC;EACvB,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMM,kBAAkB,GAAG,IAAAD,kBAAW,EACjCE,MAAyC,IAA8C;IACpF,IAAI,CAACX,WAAW,EAAE;MACd,OAAO,IAAI;IACf;IAEA,OAAO;MACHL,OAAO;MACPiB,MAAM,EAAEZ,WAA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tB5C,iBAAiB,CAACC,KAAK,CAAC;EAC5B,CAAC,EACD,CAACY,UAAU,CACf,CAAC;EAED,MAAMmC,eAAe,GAAG,IAAA7B,kBAAW,EAC9BlB,KAAsC,IAAW;IAC9C,IAAI,CAACY,UAAU,EAAE;MACb;IACJ;IAEAZ,KAAK,CAAC2C,cAAc,CAAC,CAAC;IACtBb,UAAU,CAAClB,UAAU,CAAC;EAC1B,CAAC,EACD,CAACA,UAAU,EAAEkB,UAAU,CAC3B,CAAC;EAED,OAAO;IACHkB,aAAa,EAAEvC,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEY,MAAM;IAClCT,UAAU;IACVqC,UAAU,EAAExC,WAAW,KAAK,IAAI;IAChC6B,sBAAsB;IACtBxB,gBAAgB;IAChBoC,aAAa,EAAEjC,cAAc;IAC7BM,eAAe;IACfO,UAAU;IACVH,sBAAsB;IACtBmB,mBAAmB;IACnBC,eAAe;IACfL,sBAAsB;IACtBE;EACJ,CAAC;AACL,CAAC;AAACO,OAAA,CAAAhD,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _SidebarGroup = require("./SidebarGroup.styles");
|
|
9
|
+
var _SidebarItem = _interopRequireDefault(require("./sidebar-item/SidebarItem"));
|
|
10
|
+
var _SidebarGroup2 = require("./SidebarGroup.context");
|
|
11
|
+
var _SidebarGroup3 = require("./SidebarGroup.hooks");
|
|
12
|
+
var _NavigationSidebar = require("../NavigationSidebar.context");
|
|
13
|
+
var _NavigationLayout = require("../../NavigationLayout.context");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
+
const SidebarGroup = ({
|
|
17
|
+
groupId,
|
|
18
|
+
items,
|
|
19
|
+
isReorderable
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
isCompact
|
|
23
|
+
} = (0, _NavigationSidebar.useNavigationSidebarContext)();
|
|
24
|
+
const {
|
|
25
|
+
onItemReorder
|
|
26
|
+
} = (0, _NavigationLayout.useNavigationLayoutContext)();
|
|
27
|
+
const {
|
|
28
|
+
draggedItemId,
|
|
29
|
+
dropTarget,
|
|
30
|
+
isDragging,
|
|
31
|
+
isGroupEndTargetActive,
|
|
32
|
+
isReorderEnabled,
|
|
33
|
+
handleDragEnd,
|
|
34
|
+
handleDragStart,
|
|
35
|
+
handleDrop,
|
|
36
|
+
handleDropTargetChange,
|
|
37
|
+
handleGroupDragOver,
|
|
38
|
+
handleGroupDrop,
|
|
39
|
+
handleGroupEndDragOver,
|
|
40
|
+
handleGroupEndDrop
|
|
41
|
+
} = (0, _SidebarGroup3.useSidebarGroupReorder)({
|
|
42
|
+
groupId,
|
|
43
|
+
isCompact,
|
|
44
|
+
isReorderable,
|
|
45
|
+
items,
|
|
46
|
+
onItemReorder
|
|
47
|
+
});
|
|
48
|
+
const contextValue = (0, _react.useMemo)(() => ({
|
|
49
|
+
draggedItemId,
|
|
50
|
+
dropTarget,
|
|
51
|
+
isDragging,
|
|
52
|
+
isReorderEnabled,
|
|
53
|
+
onDragEnd: handleDragEnd,
|
|
54
|
+
onDragStart: handleDragStart,
|
|
55
|
+
onDrop: handleDrop,
|
|
56
|
+
onDropTargetChange: handleDropTargetChange
|
|
57
|
+
}), [draggedItemId, dropTarget, handleDragEnd, handleDragStart, handleDrop, handleDropTargetChange, isDragging, isReorderEnabled]);
|
|
58
|
+
const content = (0, _react.useMemo)(() => items.map((item, index) => /*#__PURE__*/_react.default.createElement(_SidebarItem.default, {
|
|
59
|
+
key: item.id,
|
|
60
|
+
item: item,
|
|
61
|
+
index: index,
|
|
62
|
+
parentIds: []
|
|
63
|
+
})), [items]);
|
|
64
|
+
return /*#__PURE__*/_react.default.createElement(_SidebarGroup2.SidebarGroupReorderProvider, {
|
|
65
|
+
value: contextValue
|
|
66
|
+
}, /*#__PURE__*/_react.default.createElement(_SidebarGroup.StyledSidebarGroup, {
|
|
67
|
+
onDragOver: handleGroupDragOver,
|
|
68
|
+
onDrop: handleGroupDrop
|
|
69
|
+
}, content, isReorderEnabled && /*#__PURE__*/_react.default.createElement(_SidebarGroup.StyledSidebarDropZone, {
|
|
70
|
+
$isActive: isGroupEndTargetActive,
|
|
71
|
+
$isDragging: isDragging,
|
|
72
|
+
$placement: "after",
|
|
73
|
+
onDragOver: handleGroupEndDragOver,
|
|
74
|
+
onDrop: handleGroupEndDrop
|
|
75
|
+
})));
|
|
76
|
+
};
|
|
77
|
+
SidebarGroup.displayName = 'SidebarGroup';
|
|
78
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(SidebarGroup);
|
|
79
|
+
//# sourceMappingURL=SidebarGroup.js.map
|
package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarGroup.js","names":["_react","_interopRequireWildcard","require","_SidebarGroup","_SidebarItem","_interopRequireDefault","_SidebarGroup2","_SidebarGroup3","_NavigationSidebar","_NavigationLayout","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","SidebarGroup","groupId","items","isReorderable","isCompact","useNavigationSidebarContext","onItemReorder","useNavigationLayoutContext","draggedItemId","dropTarget","isDragging","isGroupEndTargetActive","isReorderEnabled","handleDragEnd","handleDragStart","handleDrop","handleDropTargetChange","handleGroupDragOver","handleGroupDrop","handleGroupEndDragOver","handleGroupEndDrop","useSidebarGroupReorder","contextValue","useMemo","onDragEnd","onDragStart","onDrop","onDropTargetChange","content","map","item","index","createElement","key","id","parentIds","SidebarGroupReorderProvider","value","StyledSidebarGroup","onDragOver","StyledSidebarDropZone","$isActive","$isDragging","$placement","displayName","_default","exports","memo"],"sources":["../../../../../../src/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.tsx"],"sourcesContent":["import React, { FC, memo, useMemo } from 'react';\nimport { StyledSidebarDropZone, StyledSidebarGroup } from './SidebarGroup.styles';\nimport { NavigationLayoutGroup, NavigationLayoutItem } from '../../NavigationLayout.types';\nimport SidebarItem from './sidebar-item/SidebarItem';\nimport { SidebarGroupReorderProvider } from './SidebarGroup.context';\nimport { useSidebarGroupReorder } from './SidebarGroup.hooks';\nimport { useNavigationSidebarContext } from '../NavigationSidebar.context';\nimport { useNavigationLayoutContext } from '../../NavigationLayout.context';\n\ninterface SidebarGroupProps {\n groupId: NavigationLayoutGroup['id'];\n items: NavigationLayoutItem[];\n isReorderable?: NavigationLayoutGroup['isReorderable'];\n}\n\nconst SidebarGroup: FC<SidebarGroupProps> = ({ groupId, items, isReorderable }) => {\n const { isCompact } = useNavigationSidebarContext();\n const { onItemReorder } = useNavigationLayoutContext();\n const {\n draggedItemId,\n dropTarget,\n isDragging,\n isGroupEndTargetActive,\n isReorderEnabled,\n handleDragEnd,\n handleDragStart,\n handleDrop,\n handleDropTargetChange,\n handleGroupDragOver,\n handleGroupDrop,\n handleGroupEndDragOver,\n handleGroupEndDrop,\n } = useSidebarGroupReorder({\n groupId,\n isCompact,\n isReorderable,\n items,\n onItemReorder,\n });\n\n const contextValue = useMemo(\n () => ({\n draggedItemId,\n dropTarget,\n isDragging,\n isReorderEnabled,\n onDragEnd: handleDragEnd,\n onDragStart: handleDragStart,\n onDrop: handleDrop,\n onDropTargetChange: handleDropTargetChange,\n }),\n [\n draggedItemId,\n dropTarget,\n handleDragEnd,\n handleDragStart,\n handleDrop,\n handleDropTargetChange,\n isDragging,\n isReorderEnabled,\n ],\n );\n\n const content = useMemo(\n () =>\n items.map((item, index) => (\n <SidebarItem key={item.id} item={item} index={index} parentIds={[]} />\n )),\n [items],\n );\n\n return (\n <SidebarGroupReorderProvider value={contextValue}>\n <StyledSidebarGroup onDragOver={handleGroupDragOver} onDrop={handleGroupDrop}>\n {content}\n {isReorderEnabled && (\n <StyledSidebarDropZone\n $isActive={isGroupEndTargetActive}\n $isDragging={isDragging}\n $placement=\"after\"\n onDragOver={handleGroupEndDragOver}\n onDrop={handleGroupEndDrop}\n />\n )}\n </StyledSidebarGroup>\n </SidebarGroupReorderProvider>\n );\n};\n\nSidebarGroup.displayName = 'SidebarGroup';\n\nexport default memo(SidebarGroup);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAA4E,SAAAG,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAS,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,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AEDpB,YAAY,CAAC4C,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA/D,OAAA,gBAE3B,IAAAgE,WAAI,EAAC/C,YAAY,CAAC","ignoreList":[]}
|
package/lib/cjs/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.styles.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledSidebarGroup = exports.StyledSidebarDropZone = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const StyledSidebarGroup = exports.StyledSidebarGroup = _styledComponents.default.div`
|
|
10
|
+
position: relative;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: 2px;
|
|
14
|
+
`;
|
|
15
|
+
const StyledSidebarDropZone = exports.StyledSidebarDropZone = _styledComponents.default.div`
|
|
16
|
+
position: absolute;
|
|
17
|
+
left: ${({
|
|
18
|
+
$depth = 0
|
|
19
|
+
}) => $depth * 8}px;
|
|
20
|
+
right: 0;
|
|
21
|
+
height: 24px;
|
|
22
|
+
z-index: 1;
|
|
23
|
+
pointer-events: ${({
|
|
24
|
+
$isDragging
|
|
25
|
+
}) => $isDragging ? 'auto' : 'none'};
|
|
26
|
+
|
|
27
|
+
${({
|
|
28
|
+
$placement = 'before'
|
|
29
|
+
}) => {
|
|
30
|
+
if ($placement === 'after') {
|
|
31
|
+
return `
|
|
32
|
+
top: 100%;
|
|
33
|
+
transform: translateY(-50%);
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
if ($placement === 'inside') {
|
|
37
|
+
return `
|
|
38
|
+
top: 42px;
|
|
39
|
+
transform: translateY(-50%);
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
return `
|
|
43
|
+
top: 0;
|
|
44
|
+
transform: translateY(-50%);
|
|
45
|
+
`;
|
|
46
|
+
}}
|
|
47
|
+
|
|
48
|
+
&::after {
|
|
49
|
+
content: '';
|
|
50
|
+
position: absolute;
|
|
51
|
+
left: 0;
|
|
52
|
+
right: 0;
|
|
53
|
+
top: 50%;
|
|
54
|
+
height: 2px;
|
|
55
|
+
transform: translateY(-50%);
|
|
56
|
+
border-radius: 999px;
|
|
57
|
+
background-color: ${({
|
|
58
|
+
$isActive
|
|
59
|
+
}) => $isActive ? 'rgba(255, 255, 255, 0.9)' : 'transparent'};
|
|
60
|
+
box-shadow: ${({
|
|
61
|
+
$isActive
|
|
62
|
+
}) => $isActive ? '0 0 0 1px rgba(255, 255, 255, 0.25)' : 'none'};
|
|
63
|
+
opacity: ${({
|
|
64
|
+
$isActive
|
|
65
|
+
}) => $isActive ? 1 : 0};
|
|
66
|
+
transition: opacity 0.15s ease;
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
//# sourceMappingURL=SidebarGroup.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarGroup.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledSidebarGroup","exports","styled","div","StyledSidebarDropZone","$depth","$isDragging","$placement","$isActive"],"sources":["../../../../../../src/components/navigation-layout/navigation-sidebar/sidebar-group/SidebarGroup.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledSidebarGroup = styled.div`\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 2px;\n`;\n\ninterface StyledSidebarDropZoneProps {\n $depth?: number;\n $isActive: boolean;\n $isDragging: boolean;\n $placement?: 'before' | 'after' | 'inside';\n}\n\nexport const StyledSidebarDropZone = styled.div<StyledSidebarDropZoneProps>`\n position: absolute;\n left: ${({ $depth = 0 }) => $depth * 8}px;\n right: 0;\n height: 24px;\n z-index: 1;\n pointer-events: ${({ $isDragging }) => ($isDragging ? 'auto' : 'none')};\n\n ${({ $placement = 'before' }) => {\n if ($placement === 'after') {\n return `\n top: 100%;\n transform: translateY(-50%);\n `;\n }\n\n if ($placement === 'inside') {\n return `\n top: 42px;\n transform: translateY(-50%);\n `;\n }\n\n return `\n top: 0;\n transform: translateY(-50%);\n `;\n }}\n\n &::after {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 50%;\n height: 2px;\n transform: translateY(-50%);\n border-radius: 999px;\n background-color: ${({ $isActive }) =>\n $isActive ? 'rgba(255, 255, 255, 0.9)' : 'transparent'};\n box-shadow: ${({ $isActive }) =>\n $isActive ? '0 0 0 1px rgba(255, 255, 255, 0.25)' : 'none'};\n opacity: ${({ $isActive }) => ($isActive ? 1 : 0)};\n transition: opacity 0.15s ease;\n }\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhC,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAGE,yBAAM,CAACC,GAAG;AAC5C;AACA;AACA;AACA;AACA,CAAC;AASM,MAAMC,qBAAqB,GAAAH,OAAA,CAAAG,qBAAA,GAAGF,yBAAM,CAACC,GAA+B;AAC3E;AACA,YAAY,CAAC;EAAEE,MAAM,GAAG;AAAE,CAAC,KAAKA,MAAM,GAAG,CAAC;AAC1C;AACA;AACA;AACA,sBAAsB,CAAC;EAAEC;AAAY,CAAC,KAAMA,WAAW,GAAG,MAAM,GAAG,MAAO;AAC1E;AACA,MAAM,CAAC;EAAEC,UAAU,GAAG;AAAS,CAAC,KAAK;EAC7B,IAAIA,UAAU,KAAK,OAAO,EAAE;IACxB,OAAO;AACnB;AACA;AACA,aAAa;EACL;EAEA,IAAIA,UAAU,KAAK,QAAQ,EAAE;IACzB,OAAO;AACnB;AACA;AACA,aAAa;EACL;EAEA,OAAO;AACf;AACA;AACA,SAAS;AACL,CAAC;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,CAAC;EAAEC;AAAU,CAAC,KAC9BA,SAAS,GAAG,0BAA0B,GAAG,aAAa;AAClE,sBAAsB,CAAC;EAAEA;AAAU,CAAC,KACxBA,SAAS,GAAG,qCAAqC,GAAG,MAAM;AACtE,mBAAmB,CAAC;EAAEA;AAAU,CAAC,KAAMA,SAAS,GAAG,CAAC,GAAG,CAAE;AACzD;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSidebarItemReorder = exports.useSidebarItemPopup = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _SidebarItem = require("./SidebarItem.utils");
|
|
9
|
+
var _NavigationLayout = require("../../../NavigationLayout.utils");
|
|
10
|
+
const setDragMoveEffect = event => {
|
|
11
|
+
const {
|
|
12
|
+
dataTransfer
|
|
13
|
+
} = event;
|
|
14
|
+
dataTransfer.dropEffect = 'move';
|
|
15
|
+
};
|
|
16
|
+
const resolveSidebarContainer = item => {
|
|
17
|
+
if (!item) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return item.closest('[data-navigation-sidebar-root="true"]') ?? document.getElementById('sidebar');
|
|
21
|
+
};
|
|
22
|
+
const useSidebarItemPopup = ({
|
|
23
|
+
isDisabled,
|
|
24
|
+
shouldShowCollapsedLabel
|
|
25
|
+
}) => {
|
|
26
|
+
const [coordinates, setCoordinates] = (0, _react.useState)(null);
|
|
27
|
+
const [isHovered, setIsHovered] = (0, _react.useState)(false);
|
|
28
|
+
const [popupContainer, setPopupContainer] = (0, _react.useState)(null);
|
|
29
|
+
const animationFrameIdRef = (0, _react.useRef)(null);
|
|
30
|
+
const lastCoordinatesRef = (0, _react.useRef)(null);
|
|
31
|
+
const itemRef = (0, _react.useRef)(null);
|
|
32
|
+
const resetCoordinates = (0, _react.useCallback)(() => {
|
|
33
|
+
lastCoordinatesRef.current = null;
|
|
34
|
+
setCoordinates(null);
|
|
35
|
+
}, []);
|
|
36
|
+
const resolvePopupContainer = (0, _react.useCallback)(() => {
|
|
37
|
+
const nextContainer = resolveSidebarContainer(itemRef.current);
|
|
38
|
+
setPopupContainer(previousContainer => previousContainer === nextContainer ? previousContainer : nextContainer);
|
|
39
|
+
return nextContainer;
|
|
40
|
+
}, []);
|
|
41
|
+
const updateCoordinates = (0, _react.useCallback)(() => {
|
|
42
|
+
const nextContainer = popupContainer ?? resolvePopupContainer();
|
|
43
|
+
const itemElement = itemRef.current;
|
|
44
|
+
if (!nextContainer || !itemElement) {
|
|
45
|
+
resetCoordinates();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const nextCoordinates = (0, _SidebarItem.getSidebarItemPopupCoordinates)({
|
|
49
|
+
container: nextContainer,
|
|
50
|
+
item: itemElement
|
|
51
|
+
});
|
|
52
|
+
if ((0, _SidebarItem.areCoordinatesEqual)({
|
|
53
|
+
coordinatesA: lastCoordinatesRef.current,
|
|
54
|
+
coordinatesB: nextCoordinates
|
|
55
|
+
})) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
lastCoordinatesRef.current = nextCoordinates;
|
|
59
|
+
setCoordinates(nextCoordinates);
|
|
60
|
+
}, [popupContainer, resetCoordinates, resolvePopupContainer]);
|
|
61
|
+
const scheduleCoordinatesUpdate = (0, _react.useCallback)(() => {
|
|
62
|
+
if (animationFrameIdRef.current !== null) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
animationFrameIdRef.current = requestAnimationFrame(() => {
|
|
66
|
+
animationFrameIdRef.current = null;
|
|
67
|
+
updateCoordinates();
|
|
68
|
+
});
|
|
69
|
+
}, [updateCoordinates]);
|
|
70
|
+
const handleMouseEnter = (0, _react.useCallback)(() => {
|
|
71
|
+
resolvePopupContainer();
|
|
72
|
+
setIsHovered(true);
|
|
73
|
+
scheduleCoordinatesUpdate();
|
|
74
|
+
}, [resolvePopupContainer, scheduleCoordinatesUpdate]);
|
|
75
|
+
const handleMouseLeave = (0, _react.useCallback)(() => {
|
|
76
|
+
setIsHovered(false);
|
|
77
|
+
resetCoordinates();
|
|
78
|
+
}, [resetCoordinates]);
|
|
79
|
+
(0, _react.useEffect)(() => {
|
|
80
|
+
resolvePopupContainer();
|
|
81
|
+
}, [resolvePopupContainer]);
|
|
82
|
+
(0, _react.useEffect)(() => {
|
|
83
|
+
if (!isHovered || isDisabled || !shouldShowCollapsedLabel) {
|
|
84
|
+
resetCoordinates();
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
const nextContainer = popupContainer ?? resolvePopupContainer();
|
|
88
|
+
const itemElement = itemRef.current;
|
|
89
|
+
if (!nextContainer || !itemElement) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
scheduleCoordinatesUpdate();
|
|
93
|
+
const resizeObserver = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => {
|
|
94
|
+
scheduleCoordinatesUpdate();
|
|
95
|
+
});
|
|
96
|
+
resizeObserver === null || resizeObserver === void 0 || resizeObserver.observe(nextContainer);
|
|
97
|
+
resizeObserver === null || resizeObserver === void 0 || resizeObserver.observe(itemElement);
|
|
98
|
+
const scrollableElements = (0, _SidebarItem.getScrollableAncestorElements)({
|
|
99
|
+
element: itemElement,
|
|
100
|
+
boundaryElement: nextContainer
|
|
101
|
+
});
|
|
102
|
+
scrollableElements.forEach(element => {
|
|
103
|
+
element.addEventListener('scroll', scheduleCoordinatesUpdate, {
|
|
104
|
+
passive: true
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
window.addEventListener('resize', scheduleCoordinatesUpdate);
|
|
108
|
+
return () => {
|
|
109
|
+
scrollableElements.forEach(element => {
|
|
110
|
+
element.removeEventListener('scroll', scheduleCoordinatesUpdate);
|
|
111
|
+
});
|
|
112
|
+
window.removeEventListener('resize', scheduleCoordinatesUpdate);
|
|
113
|
+
resizeObserver === null || resizeObserver === void 0 || resizeObserver.disconnect();
|
|
114
|
+
if (animationFrameIdRef.current !== null) {
|
|
115
|
+
cancelAnimationFrame(animationFrameIdRef.current);
|
|
116
|
+
animationFrameIdRef.current = null;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}, [isDisabled, isHovered, popupContainer, resetCoordinates, resolvePopupContainer, scheduleCoordinatesUpdate, shouldShowCollapsedLabel]);
|
|
120
|
+
return {
|
|
121
|
+
coordinates,
|
|
122
|
+
handleMouseEnter,
|
|
123
|
+
handleMouseLeave,
|
|
124
|
+
isHovered,
|
|
125
|
+
itemRef,
|
|
126
|
+
popupContainer,
|
|
127
|
+
shouldRenderPopup: !isDisabled && !!shouldShowCollapsedLabel && isHovered && !!coordinates
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
exports.useSidebarItemPopup = useSidebarItemPopup;
|
|
131
|
+
const useSidebarItemReorder = ({
|
|
132
|
+
childItems,
|
|
133
|
+
draggedItemId,
|
|
134
|
+
dropTarget,
|
|
135
|
+
id,
|
|
136
|
+
index,
|
|
137
|
+
isDisabled,
|
|
138
|
+
isReorderEnabled,
|
|
139
|
+
onDragEnd,
|
|
140
|
+
onDragStart,
|
|
141
|
+
onDrop,
|
|
142
|
+
onDropInside,
|
|
143
|
+
onDropTargetChange,
|
|
144
|
+
parentIds
|
|
145
|
+
}) => {
|
|
146
|
+
const childParentIds = (0, _react.useMemo)(() => [...parentIds, id], [id, parentIds]);
|
|
147
|
+
const canDragItem = isReorderEnabled && !isDisabled;
|
|
148
|
+
const canDropInsideItem = isReorderEnabled && !isDisabled;
|
|
149
|
+
const currentItem = (0, _react.useMemo)(() => ({
|
|
150
|
+
itemId: id,
|
|
151
|
+
parentIds,
|
|
152
|
+
index
|
|
153
|
+
}), [id, index, parentIds]);
|
|
154
|
+
const beforeTarget = (0, _react.useMemo)(() => ({
|
|
155
|
+
itemId: id,
|
|
156
|
+
parentIds,
|
|
157
|
+
index,
|
|
158
|
+
placement: 'before'
|
|
159
|
+
}), [id, index, parentIds]);
|
|
160
|
+
const insideTarget = (0, _react.useMemo)(() => ({
|
|
161
|
+
itemId: id,
|
|
162
|
+
parentIds: childParentIds,
|
|
163
|
+
index: (childItems === null || childItems === void 0 ? void 0 : childItems.length) ?? 0,
|
|
164
|
+
placement: 'inside'
|
|
165
|
+
}), [childItems, childParentIds, id]);
|
|
166
|
+
const childListEndTarget = (0, _react.useMemo)(() => {
|
|
167
|
+
const lastChild = childItems === null || childItems === void 0 ? void 0 : childItems[childItems.length - 1];
|
|
168
|
+
if (!lastChild) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
itemId: lastChild.id,
|
|
173
|
+
parentIds: childParentIds,
|
|
174
|
+
index: childItems.length,
|
|
175
|
+
placement: 'after'
|
|
176
|
+
};
|
|
177
|
+
}, [childItems, childParentIds]);
|
|
178
|
+
const isBeforeDropTargetActive = (0, _react.useMemo)(() => (0, _NavigationLayout.isNavigationLayoutReorderTargetEqual)({
|
|
179
|
+
targetA: dropTarget,
|
|
180
|
+
targetB: beforeTarget
|
|
181
|
+
}), [beforeTarget, dropTarget]);
|
|
182
|
+
const isInsideDropTargetActive = (0, _react.useMemo)(() => (0, _NavigationLayout.isNavigationLayoutReorderTargetEqual)({
|
|
183
|
+
targetA: dropTarget,
|
|
184
|
+
targetB: insideTarget
|
|
185
|
+
}), [dropTarget, insideTarget]);
|
|
186
|
+
const isChildListEndTargetActive = (0, _react.useMemo)(() => (0, _NavigationLayout.isNavigationLayoutReorderTargetEqual)({
|
|
187
|
+
targetA: dropTarget,
|
|
188
|
+
targetB: childListEndTarget
|
|
189
|
+
}), [childListEndTarget, dropTarget]);
|
|
190
|
+
const handleDragStart = (0, _react.useCallback)(event => {
|
|
191
|
+
if (!canDragItem) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
onDragStart(event, currentItem);
|
|
195
|
+
}, [canDragItem, currentItem, onDragStart]);
|
|
196
|
+
const handleResolvedDragEnd = (0, _react.useCallback)(() => {
|
|
197
|
+
if (!canDragItem) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
onDragEnd();
|
|
201
|
+
}, [canDragItem, onDragEnd]);
|
|
202
|
+
const handleBeforeDragOver = (0, _react.useCallback)(event => {
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
setDragMoveEffect(event);
|
|
205
|
+
onDropTargetChange(beforeTarget);
|
|
206
|
+
}, [beforeTarget, onDropTargetChange]);
|
|
207
|
+
const handleBeforeDrop = (0, _react.useCallback)(event => {
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
event.stopPropagation();
|
|
210
|
+
onDrop(beforeTarget);
|
|
211
|
+
}, [beforeTarget, onDrop]);
|
|
212
|
+
const handleInsideDragOver = (0, _react.useCallback)(event => {
|
|
213
|
+
if (!canDropInsideItem) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
event.preventDefault();
|
|
217
|
+
setDragMoveEffect(event);
|
|
218
|
+
onDropTargetChange(insideTarget);
|
|
219
|
+
}, [canDropInsideItem, insideTarget, onDropTargetChange]);
|
|
220
|
+
const handleInsideDrop = (0, _react.useCallback)(event => {
|
|
221
|
+
if (!canDropInsideItem) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
event.preventDefault();
|
|
225
|
+
event.stopPropagation();
|
|
226
|
+
onDropInside === null || onDropInside === void 0 || onDropInside();
|
|
227
|
+
onDrop(insideTarget);
|
|
228
|
+
}, [canDropInsideItem, insideTarget, onDrop, onDropInside]);
|
|
229
|
+
const handleChildListEndDragOver = (0, _react.useCallback)(event => {
|
|
230
|
+
if (!childListEndTarget) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
event.preventDefault();
|
|
234
|
+
setDragMoveEffect(event);
|
|
235
|
+
onDropTargetChange(childListEndTarget);
|
|
236
|
+
}, [childListEndTarget, onDropTargetChange]);
|
|
237
|
+
const handleChildListEndDrop = (0, _react.useCallback)(event => {
|
|
238
|
+
if (!childListEndTarget) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
event.preventDefault();
|
|
242
|
+
event.stopPropagation();
|
|
243
|
+
onDrop(childListEndTarget);
|
|
244
|
+
}, [childListEndTarget, onDrop]);
|
|
245
|
+
return {
|
|
246
|
+
canDragItem,
|
|
247
|
+
canDropInsideItem,
|
|
248
|
+
childParentIds,
|
|
249
|
+
childListEndTarget,
|
|
250
|
+
handleBeforeDragOver,
|
|
251
|
+
handleBeforeDrop,
|
|
252
|
+
handleChildListEndDragOver,
|
|
253
|
+
handleChildListEndDrop,
|
|
254
|
+
handleDragEnd: handleResolvedDragEnd,
|
|
255
|
+
handleDragStart,
|
|
256
|
+
handleInsideDragOver,
|
|
257
|
+
handleInsideDrop,
|
|
258
|
+
isBeforeDropTargetActive,
|
|
259
|
+
isChildListEndTargetActive,
|
|
260
|
+
isDragging: draggedItemId === id,
|
|
261
|
+
isInsideDropTargetActive
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
exports.useSidebarItemReorder = useSidebarItemReorder;
|
|
265
|
+
//# sourceMappingURL=SidebarItem.hooks.js.map
|