@vuu-ui/vuu-layout 2.1.17 → 2.1.19-beta.1
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/package.json +14 -16
- package/types/dock-layout/DockLayout.d.ts +4 -4
- package/types/dock-layout/Drawer.d.ts +4 -4
- package/types/drag-drop/BoxModel.d.ts +7 -7
- package/types/flexbox/FlexboxLayout.d.ts +4 -4
- package/types/flexbox/Splitter.d.ts +1 -1
- package/types/layout-reducer/layoutUtils.d.ts +1 -1
- package/types/layout-reducer/remove-layout-element.d.ts +1 -1
- package/types/layout-reducer/replace-layout-element.d.ts +2 -2
- package/types/layout-reducer/resize-flex-children.d.ts +2 -2
- package/types/layout-view/useView.d.ts +1 -1
- package/types/placeholder/Placeholder.d.ts +4 -4
- package/types/responsive/overflowUtils.d.ts +2 -2
- package/types/stack/StackLayout.d.ts +4 -4
- package/types/tools/devtools-box/layout-configurator.d.ts +26 -26
- package/types/tools/devtools-tree/layout-tree-viewer.d.ts +2 -2
- package/types/utils/pathUtils.d.ts +1 -1
- package/cjs/Component.js +0 -14
- package/cjs/Component.js.map +0 -1
- package/cjs/LayoutContainer.css.js +0 -6
- package/cjs/LayoutContainer.css.js.map +0 -1
- package/cjs/LayoutContainer.js +0 -33
- package/cjs/LayoutContainer.js.map +0 -1
- package/cjs/dock-layout/DockLayout.css.js +0 -6
- package/cjs/dock-layout/DockLayout.css.js.map +0 -1
- package/cjs/dock-layout/DockLayout.js +0 -41
- package/cjs/dock-layout/DockLayout.js.map +0 -1
- package/cjs/dock-layout/Drawer.css.js +0 -6
- package/cjs/dock-layout/Drawer.css.js.map +0 -1
- package/cjs/dock-layout/Drawer.js +0 -95
- package/cjs/dock-layout/Drawer.js.map +0 -1
- package/cjs/drag-drop/BoxModel.js +0 -416
- package/cjs/drag-drop/BoxModel.js.map +0 -1
- package/cjs/drag-drop/DragState.js +0 -161
- package/cjs/drag-drop/DragState.js.map +0 -1
- package/cjs/drag-drop/Draggable.js +0 -192
- package/cjs/drag-drop/Draggable.js.map +0 -1
- package/cjs/drag-drop/DropTarget.js +0 -257
- package/cjs/drag-drop/DropTarget.js.map +0 -1
- package/cjs/drag-drop/DropTargetRenderer.js +0 -218
- package/cjs/drag-drop/DropTargetRenderer.js.map +0 -1
- package/cjs/flexbox/Flexbox.css.js +0 -6
- package/cjs/flexbox/Flexbox.css.js.map +0 -1
- package/cjs/flexbox/Flexbox.js +0 -69
- package/cjs/flexbox/Flexbox.js.map +0 -1
- package/cjs/flexbox/FlexboxLayout.js +0 -30
- package/cjs/flexbox/FlexboxLayout.js.map +0 -1
- package/cjs/flexbox/Splitter.css.js +0 -6
- package/cjs/flexbox/Splitter.css.js.map +0 -1
- package/cjs/flexbox/Splitter.js +0 -122
- package/cjs/flexbox/Splitter.js.map +0 -1
- package/cjs/flexbox/flexbox-utils.js +0 -95
- package/cjs/flexbox/flexbox-utils.js.map +0 -1
- package/cjs/flexbox/useSplitterResizing.js +0 -197
- package/cjs/flexbox/useSplitterResizing.js.map +0 -1
- package/cjs/index.js +0 -122
- package/cjs/index.js.map +0 -1
- package/cjs/layout-action.js +0 -24
- package/cjs/layout-action.js.map +0 -1
- package/cjs/layout-header/Header.css.js +0 -6
- package/cjs/layout-header/Header.css.js.map +0 -1
- package/cjs/layout-header/Header.js +0 -152
- package/cjs/layout-header/Header.js.map +0 -1
- package/cjs/layout-header/useHeader.js +0 -85
- package/cjs/layout-header/useHeader.js.map +0 -1
- package/cjs/layout-provider/LayoutProvider.js +0 -304
- package/cjs/layout-provider/LayoutProvider.js.map +0 -1
- package/cjs/layout-provider/LayoutProviderContext.js +0 -23
- package/cjs/layout-provider/LayoutProviderContext.js.map +0 -1
- package/cjs/layout-provider/useLayoutDragDrop.js +0 -177
- package/cjs/layout-provider/useLayoutDragDrop.js.map +0 -1
- package/cjs/layout-reducer/flexUtils.js +0 -227
- package/cjs/layout-reducer/flexUtils.js.map +0 -1
- package/cjs/layout-reducer/insert-layout-element.js +0 -286
- package/cjs/layout-reducer/insert-layout-element.js.map +0 -1
- package/cjs/layout-reducer/layout-reducer.js +0 -202
- package/cjs/layout-reducer/layout-reducer.js.map +0 -1
- package/cjs/layout-reducer/layoutTypes.js +0 -40
- package/cjs/layout-reducer/layoutTypes.js.map +0 -1
- package/cjs/layout-reducer/layoutUtils.js +0 -237
- package/cjs/layout-reducer/layoutUtils.js.map +0 -1
- package/cjs/layout-reducer/move-layout-element.js +0 -31
- package/cjs/layout-reducer/move-layout-element.js.map +0 -1
- package/cjs/layout-reducer/remove-layout-element.js +0 -237
- package/cjs/layout-reducer/remove-layout-element.js.map +0 -1
- package/cjs/layout-reducer/replace-layout-element.js +0 -96
- package/cjs/layout-reducer/replace-layout-element.js.map +0 -1
- package/cjs/layout-reducer/resize-flex-children.js +0 -62
- package/cjs/layout-reducer/resize-flex-children.js.map +0 -1
- package/cjs/layout-reducer/wrap-layout-element.js +0 -211
- package/cjs/layout-reducer/wrap-layout-element.js.map +0 -1
- package/cjs/layout-view/View.css.js +0 -6
- package/cjs/layout-view/View.css.js.map +0 -1
- package/cjs/layout-view/View.js +0 -160
- package/cjs/layout-view/View.js.map +0 -1
- package/cjs/layout-view/useView.js +0 -75
- package/cjs/layout-view/useView.js.map +0 -1
- package/cjs/layout-view/useViewBroadcastChannel.js +0 -35
- package/cjs/layout-view/useViewBroadcastChannel.js.map +0 -1
- package/cjs/layout-view/useViewResize.js +0 -42
- package/cjs/layout-view/useViewResize.js.map +0 -1
- package/cjs/layout-view-actions/ViewContext.js +0 -16
- package/cjs/layout-view-actions/ViewContext.js.map +0 -1
- package/cjs/layout-view-actions/useViewActionDispatcher.js +0 -112
- package/cjs/layout-view-actions/useViewActionDispatcher.js.map +0 -1
- package/cjs/layout-view-actions/useViewContributions.js +0 -33
- package/cjs/layout-view-actions/useViewContributions.js.map +0 -1
- package/cjs/palette/Palette.css.js +0 -6
- package/cjs/palette/Palette.css.js.map +0 -1
- package/cjs/palette/Palette.js +0 -115
- package/cjs/palette/Palette.js.map +0 -1
- package/cjs/placeholder/LayoutStartPanel.css.js +0 -6
- package/cjs/placeholder/LayoutStartPanel.css.js.map +0 -1
- package/cjs/placeholder/LayoutStartPanel.js +0 -56
- package/cjs/placeholder/LayoutStartPanel.js.map +0 -1
- package/cjs/placeholder/Placeholder.css.js +0 -6
- package/cjs/placeholder/Placeholder.css.js.map +0 -1
- package/cjs/placeholder/Placeholder.js +0 -34
- package/cjs/placeholder/Placeholder.js.map +0 -1
- package/cjs/responsive/useResizeObserver.js +0 -118
- package/cjs/responsive/useResizeObserver.js.map +0 -1
- package/cjs/responsive/utils.js +0 -34
- package/cjs/responsive/utils.js.map +0 -1
- package/cjs/stack/Stack.css.js +0 -6
- package/cjs/stack/Stack.css.js.map +0 -1
- package/cjs/stack/Stack.js +0 -150
- package/cjs/stack/Stack.js.map +0 -1
- package/cjs/stack/StackLayout.js +0 -116
- package/cjs/stack/StackLayout.js.map +0 -1
- package/cjs/use-persistent-state.js +0 -63
- package/cjs/use-persistent-state.js.map +0 -1
- package/cjs/utils/pathUtils.js +0 -293
- package/cjs/utils/pathUtils.js.map +0 -1
- package/cjs/utils/propUtils.js +0 -27
- package/cjs/utils/propUtils.js.map +0 -1
- package/cjs/utils/refUtils.js +0 -12
- package/cjs/utils/refUtils.js.map +0 -1
- package/cjs/utils/styleUtils.js +0 -15
- package/cjs/utils/styleUtils.js.map +0 -1
- package/cjs/utils/typeOf.js +0 -27
- package/cjs/utils/typeOf.js.map +0 -1
- package/esm/Component.js +0 -12
- package/esm/Component.js.map +0 -1
- package/esm/LayoutContainer.css.js +0 -4
- package/esm/LayoutContainer.css.js.map +0 -1
- package/esm/LayoutContainer.js +0 -31
- package/esm/LayoutContainer.js.map +0 -1
- package/esm/dock-layout/DockLayout.css.js +0 -4
- package/esm/dock-layout/DockLayout.css.js.map +0 -1
- package/esm/dock-layout/DockLayout.js +0 -39
- package/esm/dock-layout/DockLayout.js.map +0 -1
- package/esm/dock-layout/Drawer.css.js +0 -4
- package/esm/dock-layout/Drawer.css.js.map +0 -1
- package/esm/dock-layout/Drawer.js +0 -93
- package/esm/dock-layout/Drawer.js.map +0 -1
- package/esm/drag-drop/BoxModel.js +0 -409
- package/esm/drag-drop/BoxModel.js.map +0 -1
- package/esm/drag-drop/DragState.js +0 -159
- package/esm/drag-drop/DragState.js.map +0 -1
- package/esm/drag-drop/Draggable.js +0 -190
- package/esm/drag-drop/Draggable.js.map +0 -1
- package/esm/drag-drop/DropTarget.js +0 -253
- package/esm/drag-drop/DropTarget.js.map +0 -1
- package/esm/drag-drop/DropTargetRenderer.js +0 -216
- package/esm/drag-drop/DropTargetRenderer.js.map +0 -1
- package/esm/flexbox/Flexbox.css.js +0 -4
- package/esm/flexbox/Flexbox.css.js.map +0 -1
- package/esm/flexbox/Flexbox.js +0 -67
- package/esm/flexbox/Flexbox.js.map +0 -1
- package/esm/flexbox/FlexboxLayout.js +0 -28
- package/esm/flexbox/FlexboxLayout.js.map +0 -1
- package/esm/flexbox/Splitter.css.js +0 -4
- package/esm/flexbox/Splitter.css.js.map +0 -1
- package/esm/flexbox/Splitter.js +0 -120
- package/esm/flexbox/Splitter.js.map +0 -1
- package/esm/flexbox/flexbox-utils.js +0 -89
- package/esm/flexbox/flexbox-utils.js.map +0 -1
- package/esm/flexbox/useSplitterResizing.js +0 -195
- package/esm/flexbox/useSplitterResizing.js.map +0 -1
- package/esm/index.js +0 -33
- package/esm/index.js.map +0 -1
- package/esm/layout-action.js +0 -22
- package/esm/layout-action.js.map +0 -1
- package/esm/layout-header/Header.css.js +0 -4
- package/esm/layout-header/Header.css.js.map +0 -1
- package/esm/layout-header/Header.js +0 -150
- package/esm/layout-header/Header.js.map +0 -1
- package/esm/layout-header/useHeader.js +0 -83
- package/esm/layout-header/useHeader.js.map +0 -1
- package/esm/layout-provider/LayoutProvider.js +0 -297
- package/esm/layout-provider/LayoutProvider.js.map +0 -1
- package/esm/layout-provider/LayoutProviderContext.js +0 -20
- package/esm/layout-provider/LayoutProviderContext.js.map +0 -1
- package/esm/layout-provider/useLayoutDragDrop.js +0 -175
- package/esm/layout-provider/useLayoutDragDrop.js.map +0 -1
- package/esm/layout-reducer/flexUtils.js +0 -218
- package/esm/layout-reducer/flexUtils.js.map +0 -1
- package/esm/layout-reducer/insert-layout-element.js +0 -282
- package/esm/layout-reducer/insert-layout-element.js.map +0 -1
- package/esm/layout-reducer/layout-reducer.js +0 -200
- package/esm/layout-reducer/layout-reducer.js.map +0 -1
- package/esm/layout-reducer/layoutTypes.js +0 -36
- package/esm/layout-reducer/layoutTypes.js.map +0 -1
- package/esm/layout-reducer/layoutUtils.js +0 -226
- package/esm/layout-reducer/layoutUtils.js.map +0 -1
- package/esm/layout-reducer/move-layout-element.js +0 -29
- package/esm/layout-reducer/move-layout-element.js.map +0 -1
- package/esm/layout-reducer/remove-layout-element.js +0 -235
- package/esm/layout-reducer/remove-layout-element.js.map +0 -1
- package/esm/layout-reducer/replace-layout-element.js +0 -92
- package/esm/layout-reducer/replace-layout-element.js.map +0 -1
- package/esm/layout-reducer/resize-flex-children.js +0 -59
- package/esm/layout-reducer/resize-flex-children.js.map +0 -1
- package/esm/layout-reducer/wrap-layout-element.js +0 -209
- package/esm/layout-reducer/wrap-layout-element.js.map +0 -1
- package/esm/layout-view/View.css.js +0 -4
- package/esm/layout-view/View.css.js.map +0 -1
- package/esm/layout-view/View.js +0 -158
- package/esm/layout-view/View.js.map +0 -1
- package/esm/layout-view/useView.js +0 -73
- package/esm/layout-view/useView.js.map +0 -1
- package/esm/layout-view/useViewBroadcastChannel.js +0 -33
- package/esm/layout-view/useViewBroadcastChannel.js.map +0 -1
- package/esm/layout-view/useViewResize.js +0 -40
- package/esm/layout-view/useViewResize.js.map +0 -1
- package/esm/layout-view-actions/ViewContext.js +0 -12
- package/esm/layout-view-actions/ViewContext.js.map +0 -1
- package/esm/layout-view-actions/useViewActionDispatcher.js +0 -110
- package/esm/layout-view-actions/useViewActionDispatcher.js.map +0 -1
- package/esm/layout-view-actions/useViewContributions.js +0 -31
- package/esm/layout-view-actions/useViewContributions.js.map +0 -1
- package/esm/palette/Palette.css.js +0 -4
- package/esm/palette/Palette.css.js.map +0 -1
- package/esm/palette/Palette.js +0 -112
- package/esm/palette/Palette.js.map +0 -1
- package/esm/placeholder/LayoutStartPanel.css.js +0 -4
- package/esm/placeholder/LayoutStartPanel.css.js.map +0 -1
- package/esm/placeholder/LayoutStartPanel.js +0 -54
- package/esm/placeholder/LayoutStartPanel.js.map +0 -1
- package/esm/placeholder/Placeholder.css.js +0 -4
- package/esm/placeholder/Placeholder.css.js.map +0 -1
- package/esm/placeholder/Placeholder.js +0 -32
- package/esm/placeholder/Placeholder.js.map +0 -1
- package/esm/responsive/useResizeObserver.js +0 -112
- package/esm/responsive/useResizeObserver.js.map +0 -1
- package/esm/responsive/utils.js +0 -31
- package/esm/responsive/utils.js.map +0 -1
- package/esm/stack/Stack.css.js +0 -4
- package/esm/stack/Stack.css.js.map +0 -1
- package/esm/stack/Stack.js +0 -148
- package/esm/stack/Stack.js.map +0 -1
- package/esm/stack/StackLayout.js +0 -114
- package/esm/stack/StackLayout.js.map +0 -1
- package/esm/use-persistent-state.js +0 -58
- package/esm/use-persistent-state.js.map +0 -1
- package/esm/utils/pathUtils.js +0 -280
- package/esm/utils/pathUtils.js.map +0 -1
- package/esm/utils/propUtils.js +0 -23
- package/esm/utils/propUtils.js.map +0 -1
- package/esm/utils/refUtils.js +0 -10
- package/esm/utils/refUtils.js.map +0 -1
- package/esm/utils/styleUtils.js +0 -13
- package/esm/utils/styleUtils.js.map +0 -1
- package/esm/utils/typeOf.js +0 -23
- package/esm/utils/typeOf.js.map +0 -1
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useResizeObserver, WidthHeight } from '../responsive/useResizeObserver.js';
|
|
2
|
-
import { useRef, useCallback } from 'react';
|
|
3
|
-
|
|
4
|
-
const NO_MEASUREMENT = [];
|
|
5
|
-
const useViewResize = ({
|
|
6
|
-
mainRef,
|
|
7
|
-
resize = "responsive",
|
|
8
|
-
rootRef
|
|
9
|
-
}) => {
|
|
10
|
-
const deferResize = resize === "defer";
|
|
11
|
-
const mainSize = useRef({});
|
|
12
|
-
const resizeHandle = useRef(void 0);
|
|
13
|
-
const setMainSize = useCallback(() => {
|
|
14
|
-
if (mainRef.current) {
|
|
15
|
-
mainRef.current.style.height = mainSize.current.height + "px";
|
|
16
|
-
mainRef.current.style.width = mainSize.current.width + "px";
|
|
17
|
-
}
|
|
18
|
-
resizeHandle.current = void 0;
|
|
19
|
-
}, [mainRef]);
|
|
20
|
-
const onResize = useCallback(
|
|
21
|
-
({ height, width }) => {
|
|
22
|
-
mainSize.current.height = height;
|
|
23
|
-
mainSize.current.width = width;
|
|
24
|
-
if (resizeHandle.current !== null) {
|
|
25
|
-
clearTimeout(resizeHandle.current);
|
|
26
|
-
}
|
|
27
|
-
resizeHandle.current = window.setTimeout(setMainSize, 40);
|
|
28
|
-
},
|
|
29
|
-
[setMainSize]
|
|
30
|
-
);
|
|
31
|
-
useResizeObserver(
|
|
32
|
-
rootRef,
|
|
33
|
-
deferResize ? WidthHeight : NO_MEASUREMENT,
|
|
34
|
-
onResize,
|
|
35
|
-
deferResize
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { useViewResize };
|
|
40
|
-
//# sourceMappingURL=useViewResize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useViewResize.js","sources":["../../../../packages/vuu-layout/src/layout-view/useViewResize.ts"],"sourcesContent":["import { ResizeHandler } from \"@vuu-ui/vuu-ui-controls\";\nimport { useResizeObserver, WidthHeight } from \"../responsive\";\nimport { RefObject, useCallback, useRef } from \"react\";\n\nconst NO_MEASUREMENT: string[] = [];\n\ntype size = {\n height?: number;\n width?: number;\n};\n\nexport interface ViewResizeHookProps {\n mainRef: RefObject<HTMLDivElement | null>;\n resize?: \"defer\" | \"responsive\";\n rootRef: RefObject<HTMLDivElement | null>;\n}\n\nexport const useViewResize = ({\n mainRef,\n resize = \"responsive\",\n rootRef,\n}: ViewResizeHookProps) => {\n const deferResize = resize === \"defer\";\n\n const mainSize = useRef<size>({});\n const resizeHandle = useRef<number>(undefined);\n\n const setMainSize = useCallback(() => {\n if (mainRef.current) {\n mainRef.current.style.height = mainSize.current.height + \"px\";\n mainRef.current.style.width = mainSize.current.width + \"px\";\n }\n resizeHandle.current = undefined;\n }, [mainRef]);\n\n const onResize = useCallback<ResizeHandler>(\n ({ height, width }) => {\n mainSize.current.height = height;\n mainSize.current.width = width;\n if (resizeHandle.current !== null) {\n clearTimeout(resizeHandle.current);\n }\n resizeHandle.current = window.setTimeout(setMainSize, 40);\n },\n [setMainSize],\n );\n\n useResizeObserver(\n rootRef,\n deferResize ? WidthHeight : NO_MEASUREMENT,\n onResize,\n deferResize,\n );\n};\n"],"names":[],"mappings":";;;AAIA,MAAM,iBAA2B,EAAC;AAa3B,MAAM,gBAAgB,CAAC;AAAA,EAC5B,OAAA;AAAA,EACA,MAAS,GAAA,YAAA;AAAA,EACT;AACF,CAA2B,KAAA;AACzB,EAAA,MAAM,cAAc,MAAW,KAAA,OAAA;AAE/B,EAAM,MAAA,QAAA,GAAW,MAAa,CAAA,EAAE,CAAA;AAChC,EAAM,MAAA,YAAA,GAAe,OAAe,KAAS,CAAA,CAAA;AAE7C,EAAM,MAAA,WAAA,GAAc,YAAY,MAAM;AACpC,IAAA,IAAI,QAAQ,OAAS,EAAA;AACnB,MAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,CAAM,MAAS,GAAA,QAAA,CAAS,QAAQ,MAAS,GAAA,IAAA;AACzD,MAAA,OAAA,CAAQ,OAAQ,CAAA,KAAA,CAAM,KAAQ,GAAA,QAAA,CAAS,QAAQ,KAAQ,GAAA,IAAA;AAAA;AAEzD,IAAA,YAAA,CAAa,OAAU,GAAA,KAAA,CAAA;AAAA,GACzB,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAA,MAAM,QAAW,GAAA,WAAA;AAAA,IACf,CAAC,EAAE,MAAQ,EAAA,KAAA,EAAY,KAAA;AACrB,MAAA,QAAA,CAAS,QAAQ,MAAS,GAAA,MAAA;AAC1B,MAAA,QAAA,CAAS,QAAQ,KAAQ,GAAA,KAAA;AACzB,MAAI,IAAA,YAAA,CAAa,YAAY,IAAM,EAAA;AACjC,QAAA,YAAA,CAAa,aAAa,OAAO,CAAA;AAAA;AAEnC,MAAA,YAAA,CAAa,OAAU,GAAA,MAAA,CAAO,UAAW,CAAA,WAAA,EAAa,EAAE,CAAA;AAAA,KAC1D;AAAA,IACA,CAAC,WAAW;AAAA,GACd;AAEA,EAAA,iBAAA;AAAA,IACE,OAAA;AAAA,IACA,cAAc,WAAc,GAAA,cAAA;AAAA,IAC5B,QAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
const NO_CONTEXT = { dispatch: null };
|
|
4
|
-
const ViewContext = React.createContext(NO_CONTEXT);
|
|
5
|
-
const useViewDispatch = () => {
|
|
6
|
-
const context = useContext(ViewContext);
|
|
7
|
-
return context?.dispatch ?? null;
|
|
8
|
-
};
|
|
9
|
-
const useViewContext = () => useContext(ViewContext);
|
|
10
|
-
|
|
11
|
-
export { ViewContext, useViewContext, useViewDispatch };
|
|
12
|
-
//# sourceMappingURL=ViewContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ViewContext.js","sources":["../../../../packages/vuu-layout/src/layout-view-actions/ViewContext.ts"],"sourcesContent":["import React, { SyntheticEvent, useContext } from \"react\";\nimport { ViewAction } from \"../layout-view/viewTypes\";\n\nexport type QueryResponse = { [key: string]: unknown };\n\nexport type ConfigChangeHandler = (config: {\n [key: string]: unknown;\n type: string;\n}) => void;\n\nexport type ViewDispatch = <Action extends ViewAction = ViewAction>(\n action: Action,\n evt?: SyntheticEvent,\n) => Promise<boolean | QueryResponse | void>;\n\n/**\n * This API is available to any Feature hosted within Vuu (as all Features are wrapped\n * with View component). It offers metadata about the View as well as access to the\n * Vuu persistencew API;\n */\nexport interface ViewContextAPI {\n /**\n * dispatcher for View actions. These are a subset of LayoutActions, specifically for\n * View manipulation\n */\n dispatch?: ViewDispatch | null;\n id?: string;\n load?: <T = unknown>(key?: string) => T;\n onConfigChange?: ConfigChangeHandler;\n path?: string;\n purge?: (key: string) => void;\n save?: (state: unknown, key: string) => void;\n setComponentProps: (props: { [key: string]: unknown }) => void;\n title?: string;\n}\n\nconst NO_CONTEXT = { dispatch: null } as ViewContextAPI;\nexport const ViewContext = React.createContext<ViewContextAPI>(NO_CONTEXT);\n\nexport const useViewDispatch = () => {\n const context = useContext(ViewContext);\n return context?.dispatch ?? null;\n};\n\nexport const useViewContext = () => useContext(ViewContext);\n"],"names":[],"mappings":";;AAoCA,MAAM,UAAA,GAAa,EAAE,QAAA,EAAU,IAAK,EAAA;AACvB,MAAA,WAAA,GAAc,KAAM,CAAA,aAAA,CAA8B,UAAU;AAElE,MAAM,kBAAkB,MAAM;AACnC,EAAM,MAAA,OAAA,GAAU,WAAW,WAAW,CAAA;AACtC,EAAA,OAAO,SAAS,QAAY,IAAA,IAAA;AAC9B;AAEa,MAAA,cAAA,GAAiB,MAAM,UAAA,CAAW,WAAW;;;;"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { useSessionDataSource } from '@vuu-ui/vuu-data-react';
|
|
2
|
-
import { useCallback } from 'react';
|
|
3
|
-
import { useLayoutProviderDispatch } from '../layout-provider/LayoutProvider.js';
|
|
4
|
-
import { useViewBroadcastChannel } from '../layout-view/useViewBroadcastChannel.js';
|
|
5
|
-
import { usePersistentState } from '../use-persistent-state.js';
|
|
6
|
-
import { useViewContributions } from './useViewContributions.js';
|
|
7
|
-
|
|
8
|
-
const useViewActionDispatcher = (id, rootRef, viewPath, dropTargets) => {
|
|
9
|
-
const { purgeState } = usePersistentState();
|
|
10
|
-
const { clearDataSource: clearDataSourceFromSessionState } = useSessionDataSource();
|
|
11
|
-
const { clearContributions, contributions, updateContributions } = useViewContributions({ sessionKey: id });
|
|
12
|
-
const dispatchLayoutAction = useLayoutProviderDispatch();
|
|
13
|
-
const unsubscribeAndClearState = useCallback(() => {
|
|
14
|
-
clearDataSourceFromSessionState(id, true);
|
|
15
|
-
purgeState(id);
|
|
16
|
-
}, [clearDataSourceFromSessionState, id, purgeState]);
|
|
17
|
-
const handleRemove = useCallback(() => {
|
|
18
|
-
unsubscribeAndClearState();
|
|
19
|
-
dispatchLayoutAction({ type: "remove", path: viewPath });
|
|
20
|
-
}, [unsubscribeAndClearState, dispatchLayoutAction, viewPath]);
|
|
21
|
-
const handleMouseDown = useCallback(
|
|
22
|
-
async (evt, index, preDragActivity) => {
|
|
23
|
-
evt.stopPropagation();
|
|
24
|
-
const dragRect = rootRef.current?.getBoundingClientRect();
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
dispatchLayoutAction({
|
|
27
|
-
type: "drag-start",
|
|
28
|
-
evt,
|
|
29
|
-
path: index === void 0 ? viewPath : `${viewPath}.${index}`,
|
|
30
|
-
dragRect,
|
|
31
|
-
preDragActivity,
|
|
32
|
-
dropTargets,
|
|
33
|
-
resolveDragStart: resolve,
|
|
34
|
-
rejectDragStart: reject
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
[rootRef, dispatchLayoutAction, viewPath, dropTargets]
|
|
39
|
-
);
|
|
40
|
-
const handleMessageReceived = useCallback(
|
|
41
|
-
(message) => {
|
|
42
|
-
switch (message.type) {
|
|
43
|
-
case "highlight-on":
|
|
44
|
-
rootRef?.current?.classList.add("vuuHighlighted");
|
|
45
|
-
break;
|
|
46
|
-
case "highlight-off":
|
|
47
|
-
rootRef?.current?.classList.remove("vuuHighlighted");
|
|
48
|
-
break;
|
|
49
|
-
case "layout-closed":
|
|
50
|
-
unsubscribeAndClearState();
|
|
51
|
-
break;
|
|
52
|
-
default:
|
|
53
|
-
console.log(`received ${message.type} message`);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
[rootRef, unsubscribeAndClearState]
|
|
57
|
-
);
|
|
58
|
-
const sendMessage = useViewBroadcastChannel(
|
|
59
|
-
id,
|
|
60
|
-
viewPath,
|
|
61
|
-
handleMessageReceived
|
|
62
|
-
);
|
|
63
|
-
const dispatchAction = useCallback(
|
|
64
|
-
async (action, evt) => {
|
|
65
|
-
const { type } = action;
|
|
66
|
-
switch (type) {
|
|
67
|
-
case "collapse":
|
|
68
|
-
case "expand":
|
|
69
|
-
return dispatchLayoutAction({ type, path: action.path ?? viewPath });
|
|
70
|
-
case "remove":
|
|
71
|
-
return handleRemove();
|
|
72
|
-
case "mousedown":
|
|
73
|
-
return handleMouseDown(
|
|
74
|
-
evt,
|
|
75
|
-
action.index,
|
|
76
|
-
action.preDragActivity
|
|
77
|
-
);
|
|
78
|
-
case "add-toolbar-contribution":
|
|
79
|
-
return updateContributions(action.location, action.content);
|
|
80
|
-
case "remove-toolbar-contribution":
|
|
81
|
-
return clearContributions();
|
|
82
|
-
case "query":
|
|
83
|
-
return dispatchLayoutAction({
|
|
84
|
-
type,
|
|
85
|
-
path: action.path,
|
|
86
|
-
query: action.query
|
|
87
|
-
});
|
|
88
|
-
case "broadcast-message":
|
|
89
|
-
sendMessage(action.message);
|
|
90
|
-
break;
|
|
91
|
-
default: {
|
|
92
|
-
return void 0;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
[
|
|
97
|
-
dispatchLayoutAction,
|
|
98
|
-
viewPath,
|
|
99
|
-
handleRemove,
|
|
100
|
-
handleMouseDown,
|
|
101
|
-
updateContributions,
|
|
102
|
-
clearContributions,
|
|
103
|
-
sendMessage
|
|
104
|
-
]
|
|
105
|
-
);
|
|
106
|
-
return [dispatchAction, contributions];
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export { useViewActionDispatcher };
|
|
110
|
-
//# sourceMappingURL=useViewActionDispatcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useViewActionDispatcher.js","sources":["../../../../packages/vuu-layout/src/layout-view-actions/useViewActionDispatcher.ts"],"sourcesContent":["import { useSessionDataSource } from \"@vuu-ui/vuu-data-react\";\nimport { RefObject, SyntheticEvent, useCallback } from \"react\";\nimport { useLayoutProviderDispatch } from \"../layout-provider/LayoutProvider\";\nimport { DragStartAction } from \"../layout-reducer\";\nimport {\n BroadcastMessageHandler,\n useViewBroadcastChannel,\n} from \"../layout-view/useViewBroadcastChannel\";\nimport { usePersistentState } from \"../use-persistent-state\";\nimport { useViewContributions } from \"./useViewContributions\";\nimport { QueryResponse, ViewDispatch } from \"./ViewContext\";\nimport { Contribution, ViewAction } from \"../layout-view/viewTypes\";\n\nexport const useViewActionDispatcher = (\n id: string,\n rootRef: RefObject<HTMLDivElement | null>,\n viewPath?: string,\n dropTargets?: string[],\n): [ViewDispatch, Contribution[] | undefined] => {\n const { purgeState } = usePersistentState();\n\n const { clearDataSource: clearDataSourceFromSessionState } =\n useSessionDataSource();\n\n const { clearContributions, contributions, updateContributions } =\n useViewContributions({ sessionKey: id });\n\n const dispatchLayoutAction = useLayoutProviderDispatch();\n\n // This assumes datasource has been stored in session state\n // we should extend to accommodate multiple dataSources\n const unsubscribeAndClearState = useCallback(() => {\n clearDataSourceFromSessionState(id, true);\n purgeState(id);\n }, [clearDataSourceFromSessionState, id, purgeState]);\n\n const handleRemove = useCallback(() => {\n unsubscribeAndClearState();\n dispatchLayoutAction({ type: \"remove\", path: viewPath });\n }, [unsubscribeAndClearState, dispatchLayoutAction, viewPath]);\n\n const handleMouseDown = useCallback(\n async (\n evt: MouseEvent,\n index: number,\n preDragActivity: unknown,\n ): Promise<boolean> => {\n evt.stopPropagation();\n const dragRect = rootRef.current?.getBoundingClientRect();\n return new Promise((resolve, reject) => {\n dispatchLayoutAction({\n type: \"drag-start\",\n evt,\n path: index === undefined ? viewPath : `${viewPath}.${index}`,\n dragRect,\n preDragActivity,\n dropTargets,\n resolveDragStart: resolve,\n rejectDragStart: reject,\n } as DragStartAction);\n });\n },\n [rootRef, dispatchLayoutAction, viewPath, dropTargets],\n );\n\n const handleMessageReceived = useCallback<BroadcastMessageHandler>(\n (message) => {\n switch (message.type) {\n case \"highlight-on\":\n rootRef?.current?.classList.add(\"vuuHighlighted\");\n break;\n case \"highlight-off\":\n rootRef?.current?.classList.remove(\"vuuHighlighted\");\n break;\n case \"layout-closed\":\n unsubscribeAndClearState();\n break;\n default:\n console.log(`received ${message.type} message`);\n }\n },\n [rootRef, unsubscribeAndClearState],\n );\n\n const sendMessage = useViewBroadcastChannel(\n id,\n viewPath,\n handleMessageReceived,\n );\n\n const dispatchAction = useCallback(\n async <A extends ViewAction = ViewAction>(\n action: A,\n evt?: MouseEvent | SyntheticEvent,\n ): Promise<boolean | QueryResponse | void> => {\n const { type } = action;\n switch (type) {\n case \"collapse\":\n case \"expand\":\n return dispatchLayoutAction({ type, path: action.path ?? viewPath });\n case \"remove\":\n return handleRemove();\n case \"mousedown\":\n // TODO fix types\n return handleMouseDown(\n evt as MouseEvent,\n action.index as number,\n action.preDragActivity,\n );\n case \"add-toolbar-contribution\":\n return updateContributions(action.location, action.content);\n case \"remove-toolbar-contribution\":\n return clearContributions();\n case \"query\":\n return dispatchLayoutAction({\n type,\n path: action.path,\n query: action.query,\n });\n case \"broadcast-message\":\n sendMessage(action.message);\n break;\n\n default: {\n return undefined;\n }\n }\n },\n [\n dispatchLayoutAction,\n viewPath,\n handleRemove,\n handleMouseDown,\n updateContributions,\n clearContributions,\n sendMessage,\n ],\n );\n\n return [dispatchAction, contributions];\n};\n"],"names":[],"mappings":";;;;;;;AAaO,MAAM,uBAA0B,GAAA,CACrC,EACA,EAAA,OAAA,EACA,UACA,WAC+C,KAAA;AAC/C,EAAM,MAAA,EAAE,UAAW,EAAA,GAAI,kBAAmB,EAAA;AAE1C,EAAA,MAAM,EAAE,eAAA,EAAiB,+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AAAA,QAC5D,KAAK,6BAAA;AACH,UAAA,OAAO,kBAAmB,EAAA;AAAA,QAC5B,KAAK,OAAA;AACH,UAAA,OAAO,oBAAqB,CAAA;AAAA,YAC1B,IAAA;AAAA,YACA,MAAM,MAAO,CAAA,IAAA;AAAA,YACb,OAAO,MAAO,CAAA;AAAA,WACf,CAAA;AAAA,QACH,KAAK,mBAAA;AACH,UAAA,WAAA,CAAY,OAAO,OAAO,CAAA;AAC1B,UAAA;AAAA,QAEF,SAAS;AACP,UAAO,OAAA,KAAA,CAAA;AAAA;AACT;AACF,KACF;AAAA,IACA;AAAA,MACE,oBAAA;AAAA,MACA,QAAA;AAAA,MACA,YAAA;AAAA,MACA,eAAA;AAAA,MACA,mBAAA;AAAA,MACA,kBAAA;AAAA,MACA;AAAA;AACF,GACF;AAEA,EAAO,OAAA,CAAC,gBAAgB,aAAa,CAAA;AACvC;;;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
const sessionState = /* @__PURE__ */ new Map();
|
|
4
|
-
const EMPTY_ARRAY = [];
|
|
5
|
-
const useViewContributions = ({
|
|
6
|
-
sessionKey
|
|
7
|
-
}) => {
|
|
8
|
-
const [contributions, setContributions] = useState(EMPTY_ARRAY);
|
|
9
|
-
const updateContributions = useCallback(
|
|
10
|
-
(location, content) => {
|
|
11
|
-
const updatedContributions = contributions.concat([
|
|
12
|
-
{ location, content }
|
|
13
|
-
]);
|
|
14
|
-
sessionState.set(sessionKey, updatedContributions);
|
|
15
|
-
setContributions(updatedContributions);
|
|
16
|
-
},
|
|
17
|
-
[contributions, sessionKey]
|
|
18
|
-
);
|
|
19
|
-
const clearContributions = useCallback(() => {
|
|
20
|
-
sessionState.delete(sessionKey);
|
|
21
|
-
setContributions([]);
|
|
22
|
-
}, [sessionKey]);
|
|
23
|
-
return {
|
|
24
|
-
clearContributions,
|
|
25
|
-
contributions,
|
|
26
|
-
updateContributions
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { useViewContributions };
|
|
31
|
-
//# sourceMappingURL=useViewContributions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useViewContributions.js","sources":["../../../../packages/vuu-layout/src/layout-view-actions/useViewContributions.ts"],"sourcesContent":["import { ReactElement, useCallback, useState } from \"react\";\nimport type {\n Contribution,\n ContributionLocation,\n} from \"../layout-view/viewTypes\";\n\nconst sessionState = new Map<string, Contribution[]>();\n\nconst EMPTY_ARRAY: Contribution[] = [];\n\nexport const useViewContributions = ({\n sessionKey,\n}: {\n sessionKey: string;\n}) => {\n const [contributions, setContributions] =\n useState<Contribution[]>(EMPTY_ARRAY);\n\n const updateContributions = useCallback(\n (location: ContributionLocation, content: ReactElement) => {\n const updatedContributions = contributions.concat([\n { location, content },\n ]);\n sessionState.set(sessionKey, updatedContributions);\n setContributions(updatedContributions);\n },\n [contributions, sessionKey],\n );\n\n const clearContributions = useCallback(() => {\n sessionState.delete(sessionKey);\n setContributions([]);\n }, [sessionKey]);\n\n return {\n clearContributions,\n contributions,\n updateContributions,\n };\n};\n"],"names":[],"mappings":";;AAMA,MAAM,YAAA,uBAAmB,GAA4B,EAAA;AAErD,MAAM,cAA8B,EAAC;AAE9B,MAAM,uBAAuB,CAAC;AAAA,EACnC;AACF,CAEM,KAAA;AACJ,EAAA,MAAM,CAAC,aAAA,EAAe,gBAAgB,CAAA,GACpC,SAAyB,WAAW,CAAA;AAEtC,EAAA,MAAM,mBAAsB,GAAA,WAAA;AAAA,IAC1B,CAAC,UAAgC,OAA0B,KAAA;AACzD,MAAM,MAAA,oBAAA,GAAuB,cAAc,MAAO,CAAA;AAAA,QAChD,EAAE,UAAU,OAAQ;AAAA,OACrB,CAAA;AACD,MAAa,YAAA,CAAA,GAAA,CAAI,YAAY,oBAAoB,CAAA;AACjD,MAAA,gBAAA,CAAiB,oBAAoB,CAAA;AAAA,KACvC;AAAA,IACA,CAAC,eAAe,UAAU;AAAA,GAC5B;AAEA,EAAM,MAAA,kBAAA,GAAqB,YAAY,MAAM;AAC3C,IAAA,YAAA,CAAa,OAAO,UAAU,CAAA;AAC9B,IAAA,gBAAA,CAAiB,EAAE,CAAA;AAAA,GACrB,EAAG,CAAC,UAAU,CAAC,CAAA;AAEf,EAAO,OAAA;AAAA,IACL,kBAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var paletteCss = ".vuuPalette {\n --vuuList-borderStyle: none;\n}\n\n.vuuPalette-horizontal {\n align-items: center;\n display: flex;\n}\n\n.vuuPaletteItem {\n --vuu-icon-color: var(--salt-content-secondary-foreground);\n --list-item-text-padding: 0 0 0 calc(var(--salt-size-unit) * 3);\n font-size: 12px;\n font-weight: 600;\n gap: var(--salt-spacing-200);\n padding-left: 12px;\n}\n\n.vuuSimpleDraggableWrapper > .vuuPaletteItem {\n --vuu-icon-color: var(--salt-selectable-foreground);\n}\n\n.salt-theme .vuuPaletteItem {\n font-size: 11px;\n font-weight: normal;\n}\n";
|
|
2
|
-
|
|
3
|
-
export { paletteCss as default };
|
|
4
|
-
//# sourceMappingURL=Palette.css.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Palette.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/esm/palette/Palette.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Option, ListBox } from '@salt-ds/core';
|
|
3
|
-
import { queryClosest, registerComponent, uuid } from '@vuu-ui/vuu-utils';
|
|
4
|
-
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
5
|
-
import { useWindow } from '@salt-ds/window';
|
|
6
|
-
import cx from 'clsx';
|
|
7
|
-
import { memo, useCallback, cloneElement } from 'react';
|
|
8
|
-
import { useLayoutProviderDispatch } from '../layout-provider/LayoutProvider.js';
|
|
9
|
-
import '../layout-provider/LayoutProviderContext.js';
|
|
10
|
-
import { View as MemoView } from '../layout-view/View.js';
|
|
11
|
-
import paletteCss from './Palette.css.js';
|
|
12
|
-
|
|
13
|
-
const classBase = "vuuPalette";
|
|
14
|
-
const clonePaletteItem = (paletteItem) => {
|
|
15
|
-
const dolly = paletteItem.cloneNode(true);
|
|
16
|
-
dolly.id = "";
|
|
17
|
-
delete dolly.dataset.idx;
|
|
18
|
-
return dolly;
|
|
19
|
-
};
|
|
20
|
-
const wrapInView = (component, viewProps) => {
|
|
21
|
-
const id = uuid();
|
|
22
|
-
return /* @__PURE__ */ jsx(MemoView, { id, ...viewProps, children: component }, id);
|
|
23
|
-
};
|
|
24
|
-
const PaletteItem = memo(
|
|
25
|
-
({
|
|
26
|
-
className,
|
|
27
|
-
component,
|
|
28
|
-
idx,
|
|
29
|
-
key,
|
|
30
|
-
value,
|
|
31
|
-
ViewProps,
|
|
32
|
-
...props
|
|
33
|
-
}) => {
|
|
34
|
-
const targetWindow = useWindow();
|
|
35
|
-
useComponentCssInjection({
|
|
36
|
-
testId: "vuu-palette",
|
|
37
|
-
css: paletteCss,
|
|
38
|
-
window: targetWindow
|
|
39
|
-
});
|
|
40
|
-
const dispatch = useLayoutProviderDispatch();
|
|
41
|
-
const handleMouseDown = useCallback(
|
|
42
|
-
(e) => {
|
|
43
|
-
const el = queryClosest(e.target, ".vuuPaletteItem", true);
|
|
44
|
-
const { height, left, top, width } = el.getBoundingClientRect();
|
|
45
|
-
dispatch({
|
|
46
|
-
dragRect: {
|
|
47
|
-
left,
|
|
48
|
-
top,
|
|
49
|
-
right: left + width,
|
|
50
|
-
bottom: top + 150,
|
|
51
|
-
width,
|
|
52
|
-
height
|
|
53
|
-
},
|
|
54
|
-
dragElement: clonePaletteItem(el),
|
|
55
|
-
evt: e.nativeEvent,
|
|
56
|
-
instructions: {
|
|
57
|
-
DoNotRemove: true,
|
|
58
|
-
DoNotTransform: true,
|
|
59
|
-
DriftHomeIfNoDropTarget: true,
|
|
60
|
-
RemoveDraggableOnDragEnd: true,
|
|
61
|
-
dragThreshold: 10
|
|
62
|
-
},
|
|
63
|
-
path: "*",
|
|
64
|
-
payload: wrapInView(component, ViewProps),
|
|
65
|
-
type: "drag-start"
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
[ViewProps, component, dispatch]
|
|
69
|
-
);
|
|
70
|
-
return /* @__PURE__ */ jsx(
|
|
71
|
-
Option,
|
|
72
|
-
{
|
|
73
|
-
className: cx("vuuPaletteItem", className),
|
|
74
|
-
"data-draggable": true,
|
|
75
|
-
"data-index": idx,
|
|
76
|
-
onMouseDown: handleMouseDown,
|
|
77
|
-
value,
|
|
78
|
-
...props
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
PaletteItem.displayName = "PaletteItem";
|
|
84
|
-
const Palette = ({
|
|
85
|
-
ListBoxProps: ListBoxProps2,
|
|
86
|
-
ViewProps,
|
|
87
|
-
children,
|
|
88
|
-
className,
|
|
89
|
-
orientation = "horizontal",
|
|
90
|
-
...props
|
|
91
|
-
}) => {
|
|
92
|
-
return /* @__PURE__ */ jsx(
|
|
93
|
-
ListBox,
|
|
94
|
-
{
|
|
95
|
-
...ListBoxProps2,
|
|
96
|
-
...props,
|
|
97
|
-
className: cx(classBase, className, `${classBase}-${orientation}`),
|
|
98
|
-
selected: [],
|
|
99
|
-
children: children.map(
|
|
100
|
-
(child, idx) => child.type === PaletteItem ? cloneElement(child, {
|
|
101
|
-
idx,
|
|
102
|
-
key: idx
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
-
}) : child
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
registerComponent("Palette", Palette, "view");
|
|
110
|
-
|
|
111
|
-
export { Palette, PaletteItem };
|
|
112
|
-
//# sourceMappingURL=Palette.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Palette.js","sources":["../../../../packages/vuu-layout/src/palette/Palette.tsx"],"sourcesContent":["import { ListBox, ListBoxProps, Option, OptionProps } from \"@salt-ds/core\";\nimport { queryClosest, registerComponent, uuid } from \"@vuu-ui/vuu-utils\";\n\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport cx from \"clsx\";\nimport {\n HTMLAttributes,\n MouseEventHandler,\n ReactElement,\n cloneElement,\n memo,\n useCallback,\n} from \"react\";\nimport { useLayoutProviderDispatch } from \"../layout-provider\";\nimport { View } from \"../layout-view/View\";\nimport type { ViewProps } from \"../layout-view/viewTypes\";\n\nimport paletteCss from \"./Palette.css\";\n\nconst classBase = \"vuuPalette\";\n\nconst clonePaletteItem = (paletteItem: HTMLElement) => {\n const dolly = paletteItem.cloneNode(true) as HTMLElement;\n dolly.id = \"\";\n delete dolly.dataset.idx;\n return dolly;\n};\n\nconst wrapInView = (\n component: ReactElement,\n viewProps?: Partial<ViewProps>,\n) => {\n const id = uuid();\n return (\n <View id={id} key={id} {...viewProps}>\n {component}\n </View>\n );\n};\nexport interface PaletteItemProps extends OptionProps {\n /**\n * This is the payload that will be created when the\n * palette item is dropped\n */\n ViewProps?: Pick<\n ViewProps,\n \"allowRename\" | \"closeable\" | \"header\" | \"resizeable\" | \"resize\" | \"title\"\n >;\n component: ReactElement;\n idx?: number;\n}\n\nexport const PaletteItem = memo(\n ({\n className,\n component,\n idx,\n key,\n value,\n ViewProps,\n ...props\n }: PaletteItemProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-palette\",\n css: paletteCss,\n window: targetWindow,\n });\n const dispatch = useLayoutProviderDispatch();\n\n const handleMouseDown = useCallback<MouseEventHandler<HTMLDivElement>>(\n (e) => {\n const el = queryClosest(e.target, \".vuuPaletteItem\", true);\n const { height, left, top, width } = el.getBoundingClientRect();\n\n dispatch({\n dragRect: {\n left,\n top,\n right: left + width,\n bottom: top + 150,\n width,\n height,\n },\n dragElement: clonePaletteItem(el),\n evt: e.nativeEvent,\n instructions: {\n DoNotRemove: true,\n DoNotTransform: true,\n DriftHomeIfNoDropTarget: true,\n RemoveDraggableOnDragEnd: true,\n dragThreshold: 10,\n },\n path: \"*\",\n payload: wrapInView(component, ViewProps),\n type: \"drag-start\",\n });\n },\n [ViewProps, component, dispatch],\n );\n\n return (\n <Option\n className={cx(\"vuuPaletteItem\", className)}\n data-draggable\n data-index={idx}\n onMouseDown={handleMouseDown}\n value={value}\n {...props}\n />\n );\n },\n);\n\nPaletteItem.displayName = \"PaletteItem\";\n\nexport interface PaletteProps\n extends Omit<\n HTMLAttributes<HTMLDivElement>,\n \"onDragStart\" | \"onDrop\" | \"onSelect\"\n > {\n ListBoxProps?: Partial<ListBoxProps>;\n ViewProps?: Partial<ViewProps>;\n children: ReactElement[];\n orientation: \"horizontal\" | \"vertical\";\n selection?: string;\n}\n\nexport const Palette = ({\n ListBoxProps,\n ViewProps,\n children,\n className,\n orientation = \"horizontal\",\n ...props\n}: PaletteProps) => {\n return (\n <ListBox\n {...ListBoxProps}\n {...props}\n className={cx(classBase, className, `${classBase}-${orientation}`)}\n selected={[]}\n >\n {children.map((child, idx) =>\n child.type === PaletteItem\n ? cloneElement(child, {\n idx,\n key: idx,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any)\n : child,\n )}\n </ListBox>\n );\n};\n\nregisterComponent(\"Palette\", Palette, \"view\");\n"],"names":["View","ListBoxProps"],"mappings":";;;;;;;;;;;;AAoBA,MAAM,SAAY,GAAA,YAAA;AAElB,MAAM,gBAAA,GAAmB,CAAC,WAA6B,KAAA;AACrD,EAAM,MAAA,KAAA,GAAQ,WAAY,CAAA,SAAA,CAAU,IAAI,CAAA;AACxC,EAAA,KAAA,CAAM,EAAK,GAAA,EAAA;AACX,EAAA,OAAO,MAAM,OAAQ,CAAA,GAAA;AACrB,EAAO,OAAA,KAAA;AACT,CAAA;AAEA,MAA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;;"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var layoutStartPanelCss = ".vuuLayoutStartPanel {\n align-items: center;\n flex: 0 0 auto !important;\n display: flex;\n flex-direction: column;\n font-weight: 700;\n gap: 12px;\n}\n\n.vuuLayoutStartPanel-title {\n color: var(--vuu-color-gray-80);\n font-size: 28px;\n line-height: 1.5;\n text-align: center;\n}\n\n.vuuLayoutStartPanel-text {\n color: var(--vuu-color-gray-50);\n font-size: 18px;\n line-height: 1.5;\n max-width: 460px;\n}\n\n.vuuLayoutStartPanel-addButton {\n --vuu-icon-size: 20px;\n --saltButton-borderRadius: 28px !important;\n --saltButton-height: 56px;\n --saltButton-width: 56px;\n box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);\n}";
|
|
2
|
-
|
|
3
|
-
export { layoutStartPanelCss as default };
|
|
4
|
-
//# sourceMappingURL=LayoutStartPanel.css.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutStartPanel.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { IconButton } from '@vuu-ui/vuu-ui-controls';
|
|
3
|
-
import { VuuShellLocation } from '@vuu-ui/vuu-utils';
|
|
4
|
-
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
5
|
-
import { useWindow } from '@salt-ds/window';
|
|
6
|
-
import { useState, useMemo } from 'react';
|
|
7
|
-
import { useViewContext } from '../layout-view-actions/ViewContext.js';
|
|
8
|
-
import layoutStartPanelCss from './LayoutStartPanel.css.js';
|
|
9
|
-
|
|
10
|
-
const classBase = "vuuLayoutStartPanel";
|
|
11
|
-
const LayoutStartPanel = (htmlAttributes) => {
|
|
12
|
-
const targetWindow = useWindow();
|
|
13
|
-
useComponentCssInjection({
|
|
14
|
-
testId: "vuu-layout-start-panel",
|
|
15
|
-
css: layoutStartPanelCss,
|
|
16
|
-
window: targetWindow
|
|
17
|
-
});
|
|
18
|
-
const { dispatch, path } = useViewContext();
|
|
19
|
-
const [displayState, setDisplayState] = useState();
|
|
20
|
-
useMemo(() => {
|
|
21
|
-
dispatch?.({
|
|
22
|
-
type: "query",
|
|
23
|
-
path,
|
|
24
|
-
query: "PARENT_CONTAINER"
|
|
25
|
-
}).then((response) => {
|
|
26
|
-
if (response?.parentContainerId === VuuShellLocation.Workspace) {
|
|
27
|
-
setDisplayState("initial");
|
|
28
|
-
} else {
|
|
29
|
-
setDisplayState("nested");
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}, [dispatch, path]);
|
|
33
|
-
if (displayState === void 0) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
const showInitialState = displayState === "initial";
|
|
37
|
-
return /* @__PURE__ */ jsxs("div", { ...htmlAttributes, className: classBase, children: [
|
|
38
|
-
showInitialState ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39
|
-
/* @__PURE__ */ jsx("div", { className: `${classBase}-title`, children: "Start by adding a table" }),
|
|
40
|
-
/* @__PURE__ */ jsx("div", { className: `${classBase}-text`, children: "To add a table, drag any of the Vuu Tables to this area or click the button below" })
|
|
41
|
-
] }) : null,
|
|
42
|
-
/* @__PURE__ */ jsx(
|
|
43
|
-
IconButton,
|
|
44
|
-
{
|
|
45
|
-
className: `${classBase}-addButton`,
|
|
46
|
-
icon: "add",
|
|
47
|
-
variant: "cta"
|
|
48
|
-
}
|
|
49
|
-
)
|
|
50
|
-
] });
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { LayoutStartPanel };
|
|
54
|
-
//# sourceMappingURL=LayoutStartPanel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutStartPanel.js","sources":["../../../../packages/vuu-layout/src/placeholder/LayoutStartPanel.tsx"],"sourcesContent":["import { IconButton } from \"@vuu-ui/vuu-ui-controls\";\nimport { VuuShellLocation } from \"@vuu-ui/vuu-utils\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { HTMLAttributes, useMemo, useState } from \"react\";\nimport {\n QueryResponse,\n useViewContext,\n} from \"../layout-view-actions/ViewContext\";\n\nimport layoutStartPanelCss from \"./LayoutStartPanel.css\";\n\nconst classBase = \"vuuLayoutStartPanel\";\n\nexport interface LayoutStartPanelProps extends HTMLAttributes<HTMLDivElement> {\n label?: string;\n}\n\nexport const LayoutStartPanel = (htmlAttributes: LayoutStartPanelProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-layout-start-panel\",\n css: layoutStartPanelCss,\n window: targetWindow,\n });\n\n const { dispatch, path } = useViewContext();\n const [displayState, setDisplayState] = useState<\n \"initial\" | \"nested\" | undefined\n >();\n\n useMemo(() => {\n dispatch?.({\n type: \"query\",\n path,\n query: \"PARENT_CONTAINER\",\n }).then((response) => {\n if (\n (response as QueryResponse)?.parentContainerId ===\n VuuShellLocation.Workspace\n ) {\n setDisplayState(\"initial\");\n } else {\n setDisplayState(\"nested\");\n }\n });\n }, [dispatch, path]);\n\n if (displayState === undefined) {\n return null;\n }\n\n const showInitialState = displayState === \"initial\";\n\n return (\n <div {...htmlAttributes} className={classBase}>\n {showInitialState ? (\n <>\n <div className={`${classBase}-title`}>Start by adding a table</div>\n <div className={`${classBase}-text`}>\n To add a table, drag any of the Vuu Tables to this area or click the\n button below\n </div>\n </>\n ) : null}\n <IconButton\n className={`${classBase}-addButton`}\n icon=\"add\"\n variant=\"cta\"\n />\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAYA,MAAM,SAAY,GAAA,qBAAA;AAML,MAAA,gBAAA,GAAmB,CAAC,cAA0C,KAAA;AACzE,EAAA,MAAM,eAAe,SAAU,EAAA;AAC/B,EAAyB,wBAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,wBAAA;AAAA,IACR,GAAK,EAAA,mBAAA;AAAA,IACL,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AAA,KAAA;AAAA,QACL,OAAQ,EAAA;AAAA;AAAA;AACV,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var placeholderCss = ".vuuPlaceholder {\n --vuuView-justify: center;\n align-items: center;\n display: flex;\n flex-basis: 0;\n flex-grow: 1;\n flex-shrink: 1;\n}\n\n.vuuPlaceholder-nested {\n background-color: red;\n}\n\n.vuuPlaceholder-shim {\n flex-grow: 0;\n flex-shrink: 0;\n}\n";
|
|
2
|
-
|
|
3
|
-
export { placeholderCss as default };
|
|
4
|
-
//# sourceMappingURL=Placeholder.css.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Placeholder.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import cx from 'clsx';
|
|
3
|
-
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
4
|
-
import { useWindow } from '@salt-ds/window';
|
|
5
|
-
import { registerComponent } from '@vuu-ui/vuu-utils';
|
|
6
|
-
import { LayoutStartPanel } from './LayoutStartPanel.js';
|
|
7
|
-
import { View as MemoView } from '../layout-view/View.js';
|
|
8
|
-
import placeholderCss from './Placeholder.css.js';
|
|
9
|
-
|
|
10
|
-
const classBase = "vuuPlaceholder";
|
|
11
|
-
const PlaceholderCore = ({ showStartMenu = true }) => {
|
|
12
|
-
return /* @__PURE__ */ jsx(Fragment, { children: showStartMenu ? /* @__PURE__ */ jsx(LayoutStartPanel, {}) : null });
|
|
13
|
-
};
|
|
14
|
-
const Placeholder = ({
|
|
15
|
-
className: classNameProp,
|
|
16
|
-
showStartMenu,
|
|
17
|
-
...viewProps
|
|
18
|
-
}) => {
|
|
19
|
-
const targetWindow = useWindow();
|
|
20
|
-
useComponentCssInjection({
|
|
21
|
-
testId: "vuu-placeholder",
|
|
22
|
-
css: placeholderCss,
|
|
23
|
-
window: targetWindow
|
|
24
|
-
});
|
|
25
|
-
const className = cx(classBase, classNameProp);
|
|
26
|
-
return /* @__PURE__ */ jsx(MemoView, { ...viewProps, className, "data-placeholder": true, resizeable: true, children: /* @__PURE__ */ jsx(PlaceholderCore, { showStartMenu }) });
|
|
27
|
-
};
|
|
28
|
-
Placeholder.displayName = "Placeholder";
|
|
29
|
-
registerComponent("Placeholder", Placeholder, "component");
|
|
30
|
-
|
|
31
|
-
export { Placeholder };
|
|
32
|
-
//# sourceMappingURL=Placeholder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Placeholder.js","sources":["../../../../packages/vuu-layout/src/placeholder/Placeholder.tsx"],"sourcesContent":["import cx from \"clsx\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { registerComponent } from \"@vuu-ui/vuu-utils\";\nimport { LayoutStartPanel } from \"./LayoutStartPanel\";\nimport { View } from \"../layout-view/View\";\nimport type { ViewProps } from \"../layout-view/viewTypes\";\n\nimport placeholderCss from \"./Placeholder.css\";\n\nconst classBase = \"vuuPlaceholder\";\n\nexport interface PlaceholderProps extends ViewProps {\n closeable?: boolean;\n flexFill?: boolean;\n resizeable?: boolean;\n showStartMenu?: boolean;\n /**\n * shim is only when we're dealing with intrinsically sized children, which is never\n * in an actual application. Intrinsic sizing is still experimental.\n */\n shim?: boolean;\n}\n\nconst PlaceholderCore = ({ showStartMenu = true }: PlaceholderProps) => {\n return <>{showStartMenu ? <LayoutStartPanel /> : null}</>;\n};\n\nexport const Placeholder = ({\n className: classNameProp,\n showStartMenu,\n ...viewProps\n}: PlaceholderProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-placeholder\",\n css: placeholderCss,\n window: targetWindow,\n });\n\n const className = cx(classBase, classNameProp);\n\n return (\n <View {...viewProps} className={className} data-placeholder resizeable>\n <PlaceholderCore showStartMenu={showStartMenu} />\n </View>\n );\n};\n\nPlaceholder.displayName = \"Placeholder\";\nregisterComponent(\"Placeholder\", Placeholder, \"component\");\n"],"names":["View"],"mappings":";;;;;;;;;AAUA,MAAM,SAAY,GAAA,gBAAA;AAclB,MAAM,eAAkB,GAAA,CAAC,EAAE,aAAA,GAAgB,MAA6B,KAAA;AACtE,EAAA,uBAAU,GAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA,aAAA,mBAAiB,GAAA,CAAA,gBAAA,EAAA,EAAiB,IAAK,IAAK,EAAA,CAAA;AACxD,CAAA;AAEO,MAAM,cAAc,CAAC;AAAA,EAC1B,SAAW,EAAA,aAAA;AAAA,EACX,aAAA;AAAA,EACA,GAAG;AACL,CAAwB,KAAA;AACtB,EAAA,MAAM,eAAe,SAAU,EAAA;AAC/B,EAAyB,wBAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,iBAAA;AAAA,IACR,GAAK,EAAA,cAAA;AAAA,IACL,MAAQ,EAAA;AAAA,GACT,CAAA;AAED,EAAM,MAAA,SAAA,GAAY,EAAG,CAAA,SAAA,EAAW,aAAa,CAAA;AAE7C,EAAA,uBACG,GAAA,CAAAA,QAAA,EAAA,EAAM,GAAG,SAAA,EAAW,SAAsB,EAAA,kBAAA,EAAgB,IAAC,EAAA,UAAA,EAAU,IACpE,EAAA,QAAA,kBAAA,GAAA,CAAC,eAAgB,EAAA,EAAA,aAAA,EAA8B,CACjD,EAAA,CAAA;AAEJ;AAEA,WAAA,CAAY,WAAc,GAAA,aAAA;AAC1B,iBAAkB,CAAA,aAAA,EAAe,aAAa,WAAW,CAAA;;;;"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { useRef, useCallback, useLayoutEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const WidthHeight = ["height", "width"];
|
|
4
|
-
const HeightOnly = ["height"];
|
|
5
|
-
const WidthOnly = ["width"];
|
|
6
|
-
const observedMap = /* @__PURE__ */ new WeakMap();
|
|
7
|
-
const getTargetSize = (element, contentRect, dimension) => {
|
|
8
|
-
switch (dimension) {
|
|
9
|
-
case "height":
|
|
10
|
-
return contentRect.height;
|
|
11
|
-
case "scrollHeight":
|
|
12
|
-
return element.scrollHeight;
|
|
13
|
-
case "scrollWidth":
|
|
14
|
-
return element.scrollWidth;
|
|
15
|
-
case "width":
|
|
16
|
-
return contentRect.width;
|
|
17
|
-
default:
|
|
18
|
-
return 0;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const resizeObserver = new ResizeObserver(
|
|
22
|
-
(entries) => {
|
|
23
|
-
for (const entry of entries) {
|
|
24
|
-
const { target, contentRect } = entry;
|
|
25
|
-
const observedTarget = observedMap.get(target);
|
|
26
|
-
if (observedTarget) {
|
|
27
|
-
const { onResize, measurements } = observedTarget;
|
|
28
|
-
let sizeChanged = false;
|
|
29
|
-
for (const [dimension, size] of Object.entries(measurements)) {
|
|
30
|
-
const newSize = getTargetSize(
|
|
31
|
-
target,
|
|
32
|
-
contentRect,
|
|
33
|
-
dimension
|
|
34
|
-
);
|
|
35
|
-
if (newSize !== size) {
|
|
36
|
-
sizeChanged = true;
|
|
37
|
-
measurements[dimension] = newSize;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (sizeChanged) {
|
|
41
|
-
onResize && onResize(measurements);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false) {
|
|
48
|
-
const dimensionsRef = useRef(dimensions);
|
|
49
|
-
const measure = useCallback((target) => {
|
|
50
|
-
const rect = target.getBoundingClientRect();
|
|
51
|
-
return dimensionsRef.current.reduce(
|
|
52
|
-
(map, dim) => {
|
|
53
|
-
map[dim] = getTargetSize(target, rect, dim);
|
|
54
|
-
return map;
|
|
55
|
-
},
|
|
56
|
-
{}
|
|
57
|
-
);
|
|
58
|
-
}, []);
|
|
59
|
-
useLayoutEffect(() => {
|
|
60
|
-
const target = ref.current;
|
|
61
|
-
let cleanedUp = false;
|
|
62
|
-
async function registerObserver() {
|
|
63
|
-
observedMap.set(target, { measurements: {} });
|
|
64
|
-
cleanedUp = false;
|
|
65
|
-
const { fonts } = document;
|
|
66
|
-
if (fonts) {
|
|
67
|
-
await fonts.ready;
|
|
68
|
-
}
|
|
69
|
-
if (!cleanedUp) {
|
|
70
|
-
const observedTarget = observedMap.get(target);
|
|
71
|
-
if (observedTarget) {
|
|
72
|
-
const measurements = measure(target);
|
|
73
|
-
observedTarget.measurements = measurements;
|
|
74
|
-
resizeObserver.observe(target);
|
|
75
|
-
if (reportInitialSize) {
|
|
76
|
-
onResize(measurements);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (target) {
|
|
82
|
-
if (observedMap.has(target)) {
|
|
83
|
-
throw Error(
|
|
84
|
-
"useResizeObserver attemping to observe same element twice"
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
void registerObserver();
|
|
88
|
-
}
|
|
89
|
-
return () => {
|
|
90
|
-
if (target && observedMap.has(target)) {
|
|
91
|
-
resizeObserver.unobserve(target);
|
|
92
|
-
observedMap.delete(target);
|
|
93
|
-
cleanedUp = true;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}, [ref, measure, reportInitialSize, onResize]);
|
|
97
|
-
useLayoutEffect(() => {
|
|
98
|
-
const target = ref.current;
|
|
99
|
-
const record = observedMap.get(target);
|
|
100
|
-
if (record) {
|
|
101
|
-
if (dimensionsRef.current !== dimensions) {
|
|
102
|
-
dimensionsRef.current = dimensions;
|
|
103
|
-
const measurements = measure(target);
|
|
104
|
-
record.measurements = measurements;
|
|
105
|
-
}
|
|
106
|
-
record.onResize = onResize;
|
|
107
|
-
}
|
|
108
|
-
}, [dimensions, measure, ref, onResize]);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export { HeightOnly, WidthHeight, WidthOnly, resizeObserver, useResizeObserver };
|
|
112
|
-
//# sourceMappingURL=useResizeObserver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.js","sources":["../../../../packages/vuu-layout/src/responsive/useResizeObserver.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax */\nimport { useCallback, useLayoutEffect, useRef, RefObject } from \"react\";\nexport const WidthHeight = [\"height\", \"width\"];\nexport const HeightOnly = [\"height\"];\nexport const WidthOnly = [\"width\"];\n\nexport type measurements<T = string | number> = {\n height?: T;\n scrollHeight?: T;\n scrollWidth?: T;\n width?: T;\n};\ntype measuredDimension = keyof measurements<number>;\n\nexport type ResizeHandler = (measurements: measurements<number>) => void;\n\ntype observedDetails = {\n onResize?: ResizeHandler;\n measurements: measurements<number>;\n};\nconst observedMap = new WeakMap<HTMLElement, observedDetails>();\n\nconst getTargetSize = (\n element: HTMLElement,\n contentRect: DOMRectReadOnly,\n dimension: measuredDimension\n): number => {\n switch (dimension) {\n case \"height\":\n return contentRect.height;\n case \"scrollHeight\":\n return element.scrollHeight;\n case \"scrollWidth\":\n return element.scrollWidth;\n case \"width\":\n return contentRect.width;\n default:\n return 0;\n }\n};\n\nexport const resizeObserver = new ResizeObserver(\n (entries: ResizeObserverEntry[]) => {\n for (const entry of entries) {\n const { target, contentRect } = entry;\n const observedTarget = observedMap.get(target as HTMLElement);\n if (observedTarget) {\n const { onResize, measurements } = observedTarget;\n let sizeChanged = false;\n for (const [dimension, size] of Object.entries(measurements)) {\n const newSize = getTargetSize(\n target as HTMLElement,\n contentRect,\n dimension as measuredDimension\n );\n if (newSize !== size) {\n sizeChanged = true;\n measurements[dimension as measuredDimension] = newSize;\n }\n }\n if (sizeChanged) {\n onResize && onResize(measurements);\n }\n }\n }\n }\n);\n\n// TODO use an optional lag (default to false) to ask to fire onResize\n// with initial size\n// Note asking for scrollHeight alone will not trigger onResize, this is only triggered by height,\n// with scrollHeight returned as an auxilliary value\nexport function useResizeObserver(\n ref: RefObject<Element | HTMLElement | null>,\n dimensions: string[],\n onResize: ResizeHandler,\n reportInitialSize = false\n): void {\n const dimensionsRef = useRef(dimensions);\n const measure = useCallback((target: HTMLElement): measurements<number> => {\n const rect = target.getBoundingClientRect();\n return dimensionsRef.current.reduce(\n (map: { [key: string]: number }, dim) => {\n map[dim] = getTargetSize(target, rect, dim as measuredDimension);\n return map;\n },\n {}\n );\n }, []);\n\n // TODO use ref to store resizeHandler here\n // resize handler registered with REsizeObserver will never change\n // use ref to store user onResize callback here\n // resizeHandler will call user callback.current\n\n // Keep this effect separate in case user inadvertently passes different\n // dimensions or callback instance each time - we only ever want to\n // initiate new observation when ref changes.\n useLayoutEffect(() => {\n const target = ref.current as HTMLElement;\n let cleanedUp = false;\n\n async function registerObserver() {\n // Create the map entry immediately. useEffect may fire below\n // before fonts are ready and attempt to update entry\n observedMap.set(target, { measurements: {} as measurements<number> });\n cleanedUp = false;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { fonts } = document as any;\n if (fonts) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n await fonts.ready;\n }\n if (!cleanedUp) {\n const observedTarget = observedMap.get(target);\n if (observedTarget) {\n const measurements = measure(target);\n observedTarget.measurements = measurements;\n resizeObserver.observe(target);\n if (reportInitialSize) {\n onResize(measurements);\n }\n }\n }\n }\n\n if (target) {\n // TODO might we want multiple callers to attach a listener to the same element ?\n if (observedMap.has(target)) {\n throw Error(\n \"useResizeObserver attemping to observe same element twice\"\n );\n }\n void registerObserver();\n }\n return () => {\n if (target && observedMap.has(target)) {\n resizeObserver.unobserve(target);\n observedMap.delete(target);\n cleanedUp = true;\n }\n };\n }, [ref, measure, reportInitialSize, onResize]);\n\n useLayoutEffect(() => {\n const target = ref.current as HTMLElement;\n const record = observedMap.get(target);\n if (record) {\n if (dimensionsRef.current !== dimensions) {\n dimensionsRef.current = dimensions;\n const measurements = measure(target);\n record.measurements = measurements;\n }\n // Might not have changed, but no harm ...\n record.onResize = onResize;\n }\n }, [dimensions, measure, ref, onResize]);\n\n // TODO might be a good idea to ref and return the current measurememnts. That way, derived hooks\n // e.g useBreakpoints don't have to measure and client cn make onResize callback simpler\n}\n"],"names":[],"mappings":";;AAEa,MAAA,WAAA,GAAc,CAAC,QAAA,EAAU,OAAO;AAChC,MAAA,UAAA,GAAa,CAAC,QAAQ;AACtB,MAAA,SAAA,GAAY,CAAC,OAAO;AAgBjC,MAAM,WAAA,uBAAkB,OAAsC,EAAA;AAE9D,MAAM,aAAgB,GAAA,CACpB,OACA,EAAA,WAAA,EACA,SACW,KAAA;AACX,EAAA,QAAQ,SAAW;AAAA,IACjB,KAAK,QAAA;AACH,MAAA,OAAO,WAAY,CAAA,MAAA;AAAA,IACrB,KAAK,cAAA;AACH,MAAA,OAAO,OAAQ,CAAA,YAAA;AAAA,IACjB,KAAK,aAAA;AACH,MAAA,OAAO,OAAQ,CAAA,WAAA;AAAA,IACjB,KAAK,OAAA;AACH,MAAA,OAAO,WAAY,CAAA,KAAA;AAAA,IACrB;AACE,MAAO,OAAA,CAAA;AAAA;AAEb,CAAA;AAEO,MAAM,iBAAiB,IAAI,cAAA;AAAA,EAChC,CAAC,OAAmC,KAAA;AAClC,IAAA,KAAA,MAAW,SAAS,OAAS,EAAA;AAC3B,MAAM,MAAA,EAAE,MAAQ,EAAA,WAAA,EAAgB,GAAA,KAAA;AAChC,MAAM,MAAA,cAAA,GAAiB,WAAY,CAAA,GAAA,CAAI,MAAqB,CAAA;AAC5D,MAAA,IAAI,cAAgB,EAAA;AAClB,QAAM,MAAA,EAAE,QAAU,EAAA,YAAA,EAAiB,GAAA,cAAA;AACnC,QAAA,IAAI,WAAc,GAAA,KAAA;AAClB,QAAA,KAAA,MAAW,CAAC,SAAW,EAAA,IAAI,KAAK,MAAO,CAAA,OAAA,CAAQ,YAAY,CAAG,EAAA;AAC5D,UAAA,MAAM,OAAU,GAAA,aAAA;AAAA,YACd,MAAA;AAAA,YACA,WAAA;AAAA,YACA;AAAA,WACF;AACA,UAAA,IAAI,YAAY,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