@vuu-ui/vuu-layout 0.5.15 → 0.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/LICENSE +201 -0
  2. package/cjs/index.js +20 -0
  3. package/cjs/index.js.map +7 -0
  4. package/esm/index.js +20 -0
  5. package/esm/index.js.map +7 -0
  6. package/index.css +2 -0
  7. package/index.css.map +7 -0
  8. package/package.json +16 -10
  9. package/types/Component.d.ts +7 -0
  10. package/types/DraggableLayout.d.ts +6 -0
  11. package/types/chest-of-drawers/Chest.d.ts +10 -0
  12. package/types/chest-of-drawers/Drawer.d.ts +18 -0
  13. package/{src/chest-of-drawers/index.ts → types/chest-of-drawers/index.d.ts} +0 -0
  14. package/types/common-types.d.ts +8 -0
  15. package/types/debug.d.ts +2 -0
  16. package/types/drag-drop/BoxModel.d.ts +143 -0
  17. package/types/drag-drop/DragState.d.ts +46 -0
  18. package/types/drag-drop/Draggable.d.ts +23 -0
  19. package/types/drag-drop/DropMenu.d.ts +10 -0
  20. package/types/drag-drop/DropTarget.d.ts +61 -0
  21. package/types/drag-drop/DropTargetRenderer.d.ts +18 -0
  22. package/types/drag-drop/dragDropTypes.d.ts +51 -0
  23. package/{src/drag-drop/index.ts → types/drag-drop/index.d.ts} +0 -1
  24. package/types/editable-label/EditableLabel.d.ts +9 -0
  25. package/{src/editable-label/index.ts → types/editable-label/index.d.ts} +0 -0
  26. package/types/flexbox/Flexbox.d.ts +5 -0
  27. package/types/flexbox/FlexboxLayout.d.ts +6 -0
  28. package/types/flexbox/FluidGrid.d.ts +7 -0
  29. package/types/flexbox/FluidGridLayout.d.ts +6 -0
  30. package/types/flexbox/Splitter.d.ts +13 -0
  31. package/types/flexbox/flexbox-utils.d.ts +12 -0
  32. package/types/flexbox/flexboxTypes.d.ts +51 -0
  33. package/{src/flexbox/index.ts → types/flexbox/index.d.ts} +0 -1
  34. package/types/flexbox/useResponsiveSizing.d.ts +10 -0
  35. package/types/flexbox/useSplitterResizing.d.ts +2 -0
  36. package/{src/index.ts → types/index.d.ts} +0 -1
  37. package/types/layout-action.d.ts +21 -0
  38. package/types/layout-header/ActionButton.d.ts +8 -0
  39. package/types/layout-header/Header.d.ts +13 -0
  40. package/{src/layout-header/index.ts → types/layout-header/index.d.ts} +0 -0
  41. package/types/layout-provider/LayoutProvider.d.ts +14 -0
  42. package/types/layout-provider/LayoutProviderContext.d.ts +8 -0
  43. package/{src/layout-provider/index.ts → types/layout-provider/index.d.ts} +0 -1
  44. package/types/layout-provider/useLayoutDragDrop.d.ts +4 -0
  45. package/types/layout-reducer/flexUtils.d.ts +22 -0
  46. package/{src/layout-reducer/index.ts → types/layout-reducer/index.d.ts} +0 -1
  47. package/types/layout-reducer/insert-layout-element.d.ts +8 -0
  48. package/types/layout-reducer/layout-reducer.d.ts +3 -0
  49. package/types/layout-reducer/layoutTypes.d.ts +130 -0
  50. package/types/layout-reducer/layoutUtils.d.ts +28 -0
  51. package/types/layout-reducer/remove-layout-element.d.ts +3 -0
  52. package/types/layout-reducer/replace-layout-element.d.ts +6 -0
  53. package/types/layout-reducer/resize-flex-children.d.ts +3 -0
  54. package/types/layout-reducer/wrap-layout-element.d.ts +9 -0
  55. package/types/layout-view/View.d.ts +5 -0
  56. package/types/layout-view/ViewContext.d.ts +18 -0
  57. package/{src/layout-view/index.ts → types/layout-view/index.d.ts} +0 -1
  58. package/types/layout-view/useView.d.ts +21 -0
  59. package/types/layout-view/useViewActionDispatcher.d.ts +8 -0
  60. package/types/layout-view/useViewResize.d.ts +7 -0
  61. package/types/layout-view/viewTypes.d.ts +18 -0
  62. package/types/palette/Palette.d.ts +18 -0
  63. package/types/palette/PaletteSalt.d.ts +14 -0
  64. package/{src/palette/index.ts → types/palette/index.d.ts} +0 -1
  65. package/types/placeholder/Placeholder.d.ts +12 -0
  66. package/{src/placeholder/index.ts → types/placeholder/index.d.ts} +0 -0
  67. package/types/registry/ComponentRegistry.d.ts +14 -0
  68. package/{src/registry/index.ts → types/registry/index.d.ts} +0 -0
  69. package/types/responsive/breakpoints.d.ts +4 -0
  70. package/{src/responsive/index.ts → types/responsive/index.d.ts} +0 -0
  71. package/types/responsive/measureMinimumNodeSize.d.ts +1 -0
  72. package/types/responsive/overflowUtils.d.ts +2 -0
  73. package/types/responsive/use-breakpoints.d.ts +7 -0
  74. package/types/responsive/useResizeObserver.d.ts +12 -0
  75. package/types/responsive/utils.d.ts +6 -0
  76. package/types/stack/Stack.d.ts +4 -0
  77. package/types/stack/StackLayout.d.ts +7 -0
  78. package/{src/stack/index.ts → types/stack/index.d.ts} +0 -1
  79. package/types/stack/stackTypes.d.ts +20 -0
  80. package/types/tabs/TabPanel.d.ts +7 -0
  81. package/{src/tabs/index.ts → types/tabs/index.d.ts} +0 -0
  82. package/types/tools/config-wrapper/ConfigWrapper.d.ts +2 -0
  83. package/{src/tools/config-wrapper/index.ts → types/tools/config-wrapper/index.d.ts} +0 -0
  84. package/types/tools/devtools-box/layout-configurator.d.ts +31 -0
  85. package/types/tools/devtools-tree/layout-tree-viewer.d.ts +5 -0
  86. package/{src/tools/index.ts → types/tools/index.d.ts} +0 -1
  87. package/types/use-persistent-state.d.ts +11 -0
  88. package/{src/utils/index.ts → types/utils/index.d.ts} +0 -0
  89. package/types/utils/pathUtils.d.ts +18 -0
  90. package/types/utils/propUtils.d.ts +5 -0
  91. package/types/utils/refUtils.d.ts +2 -0
  92. package/types/utils/styleUtils.d.ts +3 -0
  93. package/types/utils/typeOf.d.ts +4 -0
  94. package/src/Component.css +0 -0
  95. package/src/Component.tsx +0 -20
  96. package/src/DraggableLayout.css +0 -18
  97. package/src/DraggableLayout.tsx +0 -26
  98. package/src/__tests__/flexbox-utils.spec.js +0 -90
  99. package/src/chest-of-drawers/Chest.css +0 -36
  100. package/src/chest-of-drawers/Chest.tsx +0 -42
  101. package/src/chest-of-drawers/Drawer.css +0 -159
  102. package/src/chest-of-drawers/Drawer.tsx +0 -118
  103. package/src/common-types.ts +0 -9
  104. package/src/debug.ts +0 -16
  105. package/src/drag-drop/BoxModel.ts +0 -551
  106. package/src/drag-drop/DragState.ts +0 -219
  107. package/src/drag-drop/Draggable.ts +0 -282
  108. package/src/drag-drop/DropMenu.css +0 -71
  109. package/src/drag-drop/DropMenu.tsx +0 -61
  110. package/src/drag-drop/DropTarget.ts +0 -393
  111. package/src/drag-drop/DropTargetRenderer.css +0 -40
  112. package/src/drag-drop/DropTargetRenderer.tsx +0 -277
  113. package/src/drag-drop/dragDropTypes.ts +0 -47
  114. package/src/editable-label/EditableLabel.css +0 -28
  115. package/src/editable-label/EditableLabel.tsx +0 -99
  116. package/src/flexbox/Flexbox.css +0 -45
  117. package/src/flexbox/Flexbox.tsx +0 -70
  118. package/src/flexbox/FlexboxLayout.tsx +0 -28
  119. package/src/flexbox/FluidGrid.css +0 -134
  120. package/src/flexbox/FluidGrid.tsx +0 -82
  121. package/src/flexbox/FluidGridLayout.tsx +0 -9
  122. package/src/flexbox/Splitter.css +0 -140
  123. package/src/flexbox/Splitter.tsx +0 -127
  124. package/src/flexbox/flexbox-utils.ts +0 -128
  125. package/src/flexbox/flexboxTypes.ts +0 -68
  126. package/src/flexbox/useResponsiveSizing.ts +0 -82
  127. package/src/flexbox/useSplitterResizing.ts +0 -270
  128. package/src/layout-action.ts +0 -21
  129. package/src/layout-header/ActionButton.tsx +0 -23
  130. package/src/layout-header/Header.css +0 -8
  131. package/src/layout-header/Header.tsx +0 -216
  132. package/src/layout-provider/LayoutProvider.tsx +0 -161
  133. package/src/layout-provider/LayoutProviderContext.ts +0 -17
  134. package/src/layout-provider/useLayoutDragDrop.ts +0 -210
  135. package/src/layout-reducer/flexUtils.ts +0 -276
  136. package/src/layout-reducer/insert-layout-element.ts +0 -365
  137. package/src/layout-reducer/layout-reducer.ts +0 -237
  138. package/src/layout-reducer/layoutTypes.ts +0 -159
  139. package/src/layout-reducer/layoutUtils.ts +0 -288
  140. package/src/layout-reducer/remove-layout-element.ts +0 -226
  141. package/src/layout-reducer/replace-layout-element.ts +0 -113
  142. package/src/layout-reducer/resize-flex-children.ts +0 -55
  143. package/src/layout-reducer/wrap-layout-element.ts +0 -307
  144. package/src/layout-view/View.css +0 -61
  145. package/src/layout-view/View.tsx +0 -143
  146. package/src/layout-view/ViewContext.ts +0 -30
  147. package/src/layout-view/useView.tsx +0 -104
  148. package/src/layout-view/useViewActionDispatcher.ts +0 -123
  149. package/src/layout-view/useViewResize.ts +0 -53
  150. package/src/layout-view/viewTypes.ts +0 -35
  151. package/src/palette/Palette.css +0 -33
  152. package/src/palette/Palette.tsx +0 -140
  153. package/src/palette/PaletteSalt.css +0 -9
  154. package/src/palette/PaletteSalt.tsx +0 -79
  155. package/src/placeholder/Placeholder.css +0 -10
  156. package/src/placeholder/Placeholder.tsx +0 -38
  157. package/src/registry/ComponentRegistry.ts +0 -44
  158. package/src/responsive/breakpoints.ts +0 -62
  159. package/src/responsive/measureMinimumNodeSize.ts +0 -23
  160. package/src/responsive/overflowUtils.js +0 -14
  161. package/src/responsive/use-breakpoints.ts +0 -101
  162. package/src/responsive/useResizeObserver.ts +0 -154
  163. package/src/responsive/utils.ts +0 -37
  164. package/src/stack/Stack.css +0 -39
  165. package/src/stack/Stack.tsx +0 -173
  166. package/src/stack/StackLayout.tsx +0 -119
  167. package/src/stack/stackTypes.ts +0 -22
  168. package/src/tabs/TabPanel.css +0 -12
  169. package/src/tabs/TabPanel.tsx +0 -17
  170. package/src/tools/config-wrapper/ConfigWrapper.tsx +0 -55
  171. package/src/tools/devtools-box/layout-configurator.css +0 -112
  172. package/src/tools/devtools-box/layout-configurator.jsx +0 -369
  173. package/src/tools/devtools-tree/layout-tree-viewer.css +0 -15
  174. package/src/tools/devtools-tree/layout-tree-viewer.jsx +0 -36
  175. package/src/use-persistent-state.ts +0 -112
  176. package/src/utils/pathUtils.ts +0 -283
  177. package/src/utils/propUtils.ts +0 -26
  178. package/src/utils/refUtils.ts +0 -16
  179. package/src/utils/styleUtils.ts +0 -13
  180. package/src/utils/typeOf.ts +0 -25
  181. package/tsconfig-emit-types.json +0 -11
@@ -1,61 +0,0 @@
1
- .vuuView {
2
- border-color: var(--vuuView-borderColor, var(--salt-container-primary-borderColor));
3
- border-width: var(--vuuView-borderWidth, 1px);
4
- border-style: var(--vuuView-borderStyle, none);
5
-
6
- display: flex;
7
- flex-direction: column;
8
- margin: var(--vuuView-margin, 0px);
9
- min-height: 50px;
10
- min-width: 50px;
11
- outline: none;
12
- overflow: hidden;
13
- position: relative;
14
- }
15
-
16
- .vuuView.focus-visible:after {
17
- content: '';
18
- position: absolute;
19
- top: 0;
20
- left: 0;
21
- right: 0;
22
- bottom: 0;
23
- border: dotted cornflowerblue 2px;
24
- }
25
-
26
- .vuuView.dragging {
27
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
28
- }
29
-
30
- .vuuView-main {
31
- /* height: var(--view-content-height);
32
- width: var(--view-content-width); */
33
- display: flex;
34
- flex-direction: var(--vuuView-flexDirection, column);
35
- flex-wrap: var(--vuuView-flex-wrap, nowrap);
36
- flex: 1;
37
- overflow: hidden;
38
- position: relative;
39
- }
40
-
41
- .vuuView-main > * {
42
- flex-basis: auto;
43
- flex-grow: var(--vuuView-flex-grow, 1);
44
- flex-shrink: var(--vuuView-flex-shrink, 1);
45
- }
46
-
47
- .vuuView-collapsed .vuuView-main {
48
- display: none;
49
- }
50
-
51
- .vuuView-collapsed + .Splitter {
52
- display: none;
53
- }
54
-
55
- .vuuView-collapsed .Toolbar-vertical {
56
- border-right: solid 1px var(--grey40);
57
- }
58
-
59
- .vuuView-collapsed .Toolbar-vertical .toolbar-title {
60
- display: none;
61
- }
@@ -1,143 +0,0 @@
1
- import { useForkRef, useIdMemo as useId } from "@salt-ds/core";
2
- import cx from "classnames";
3
- import React, { ForwardedRef, forwardRef, useMemo, useRef } from "react";
4
- import { Header } from "../layout-header/Header";
5
- import { registerComponent } from "../registry/ComponentRegistry";
6
- import { useView } from "./useView";
7
- import { useViewResize } from "./useViewResize";
8
- import { ViewContext } from "./ViewContext";
9
- import { ViewProps } from "./viewTypes";
10
-
11
- import "./View.css";
12
-
13
- const View = forwardRef(function View(
14
- props: ViewProps,
15
- forwardedRef: ForwardedRef<HTMLDivElement>
16
- ) {
17
- const {
18
- children,
19
- className,
20
- collapsed,
21
- closeable,
22
- "data-resizeable": dataResizeable,
23
- dropTargets,
24
- expanded,
25
- flexFill,
26
- id: idProp,
27
- header,
28
- orientation = "horizontal",
29
- path,
30
- resize = "responsive",
31
- resizeable = dataResizeable,
32
- tearOut,
33
- style = {},
34
- title: titleProp,
35
- ...restProps
36
- } = props;
37
-
38
- const id = useId(idProp);
39
- const rootRef = useRef<HTMLDivElement>(null);
40
- const mainRef = useRef<HTMLDivElement>(null);
41
-
42
- const {
43
- contributions,
44
- dispatchViewAction,
45
- load,
46
- loadSession,
47
- onConfigChange,
48
- onEditTitle,
49
- purge,
50
- restoredState,
51
- save,
52
- saveSession,
53
- title,
54
- } = useView({
55
- id,
56
- rootRef,
57
- path,
58
- dropTargets,
59
- title: titleProp,
60
- });
61
-
62
- useViewResize({ mainRef, resize, rootRef });
63
-
64
- const classBase = "vuuView";
65
-
66
- const getContent = () => {
67
- if (React.isValidElement(children) && restoredState) {
68
- return React.cloneElement(children, restoredState);
69
- }
70
- return children;
71
- };
72
-
73
- const viewContextValue = useMemo(
74
- () => ({
75
- dispatch: dispatchViewAction,
76
- id,
77
- path,
78
- title,
79
- load,
80
- loadSession,
81
- onConfigChange,
82
- purge,
83
- save,
84
- saveSession,
85
- }),
86
- [
87
- dispatchViewAction,
88
- id,
89
- load,
90
- loadSession,
91
- onConfigChange,
92
- path,
93
- purge,
94
- save,
95
- saveSession,
96
- title,
97
- ]
98
- );
99
-
100
- const headerProps = typeof header === "object" ? header : {};
101
-
102
- return (
103
- <div
104
- {...restProps}
105
- className={cx(classBase, className, {
106
- [`${classBase}-collapsed`]: collapsed,
107
- [`${classBase}-expanded`]: expanded,
108
- [`${classBase}-resize-defer`]: resize === "defer",
109
- })}
110
- data-resizeable={resizeable}
111
- id={id}
112
- ref={useForkRef(forwardedRef, rootRef)}
113
- style={style}
114
- tabIndex={-1}
115
- >
116
- <ViewContext.Provider value={viewContextValue}>
117
- {header ? (
118
- <Header
119
- {...headerProps}
120
- collapsed={collapsed}
121
- contributions={contributions}
122
- expanded={expanded}
123
- closeable={closeable}
124
- onEditTitle={onEditTitle}
125
- orientation={orientation}
126
- tearOut={tearOut}
127
- title={title}
128
- />
129
- ) : null}
130
- <div className={`${classBase}-main`} ref={mainRef}>
131
- {getContent()}
132
- </div>
133
- </ViewContext.Provider>
134
- </div>
135
- );
136
- });
137
- View.displayName = "View";
138
-
139
- const MemoView = React.memo(View) as React.FunctionComponent<ViewProps>;
140
- MemoView.displayName = "View";
141
- registerComponent("View", MemoView, "view");
142
-
143
- export { MemoView as View };
@@ -1,30 +0,0 @@
1
- import React, { SyntheticEvent, useContext } from "react";
2
- import { ViewAction } from "./viewTypes";
3
-
4
- export type ViewDispatch = <Action extends ViewAction = ViewAction>(
5
- action: Action,
6
- evt?: SyntheticEvent
7
- ) => Promise<boolean | void>;
8
-
9
- export interface ViewContextProps {
10
- dispatch?: ViewDispatch | null;
11
- id?: string;
12
- load?: (key?: string) => unknown;
13
- loadSession?: (key?: string) => unknown;
14
- onConfigChange?: (config: unknown) => void;
15
- path?: string;
16
- purge?: (key: string) => void;
17
- save?: (state: unknown, key: string) => void;
18
- saveSession?: (state: unknown, key: string) => void;
19
- title?: string;
20
- }
21
-
22
- const NO_CONTEXT = { dispatch: null } as ViewContextProps;
23
- export const ViewContext = React.createContext<ViewContextProps>(NO_CONTEXT);
24
-
25
- export const useViewDispatch = () => {
26
- const context = useContext(ViewContext);
27
- return context?.dispatch ?? null;
28
- };
29
-
30
- export const useViewContext = () => useContext(ViewContext);
@@ -1,104 +0,0 @@
1
- import { RefObject, useCallback, useMemo } from "react";
2
- import { useLayoutProviderDispatch } from "../layout-provider";
3
- import { usePersistentState } from "../use-persistent-state";
4
- import { useViewActionDispatcher } from "./useViewActionDispatcher";
5
-
6
- export interface ViewHookProps {
7
- id: string;
8
- rootRef: RefObject<HTMLDivElement>;
9
- path?: string;
10
- dropTargets?: string[];
11
- title?: string;
12
- }
13
-
14
- export const useView = ({
15
- id,
16
- rootRef,
17
- path,
18
- dropTargets,
19
- title: titleProp,
20
- }: ViewHookProps) => {
21
- const layoutDispatch = useLayoutProviderDispatch();
22
-
23
- const {
24
- loadState,
25
- loadSessionState,
26
- purgeState,
27
- saveState,
28
- saveSessionState,
29
- } = usePersistentState();
30
-
31
- const [dispatchViewAction, contributions] = useViewActionDispatcher(
32
- id,
33
- rootRef,
34
- path,
35
- dropTargets
36
- );
37
-
38
- const title = useMemo(
39
- () => loadState("view-title") ?? titleProp,
40
- [loadState, titleProp]
41
- );
42
-
43
- const onEditTitle = useCallback(
44
- (title: string) => {
45
- if (path) {
46
- layoutDispatch({ type: "set-title", path, title });
47
- }
48
- },
49
- [layoutDispatch, path]
50
- );
51
-
52
- const restoredState = useMemo(() => loadState(id), [id, loadState]);
53
-
54
- const load = useCallback(
55
- (key?: string) => loadState(id, key),
56
- [id, loadState]
57
- );
58
-
59
- const purge = useCallback(
60
- (key) => {
61
- purgeState(id, key);
62
- layoutDispatch({ type: "save" });
63
- },
64
- [id, layoutDispatch, purgeState]
65
- );
66
-
67
- const save = useCallback(
68
- (state, key) => {
69
- saveState(id, key, state);
70
- layoutDispatch({ type: "save" });
71
- },
72
- [id, layoutDispatch, saveState]
73
- );
74
- const loadSession = useCallback(
75
- (key?: string) => loadSessionState(id, key),
76
- [id, loadSessionState]
77
- );
78
- const saveSession = useCallback(
79
- (state, key) => saveSessionState(id, key, state),
80
- [id, saveSessionState]
81
- );
82
-
83
- const onConfigChange = useCallback(
84
- ({ type: key, ...config }) => {
85
- const { [key]: data } = config;
86
- save(data, key);
87
- },
88
- [save]
89
- );
90
-
91
- return {
92
- contributions,
93
- dispatchViewAction,
94
- load,
95
- loadSession,
96
- onConfigChange,
97
- onEditTitle,
98
- purge,
99
- restoredState,
100
- save,
101
- saveSession,
102
- title,
103
- };
104
- };
@@ -1,123 +0,0 @@
1
- import { DataSource } from "@vuu-ui/vuu-data";
2
- import {
3
- ReactElement,
4
- RefObject,
5
- SyntheticEvent,
6
- useCallback,
7
- useState,
8
- } from "react";
9
- import { useLayoutProviderDispatch } from "../layout-provider";
10
- import { DragStartAction } from "../layout-reducer";
11
- import { usePersistentState } from "../use-persistent-state";
12
- import { ViewDispatch } from "./ViewContext";
13
- import { ViewAction } from "./viewTypes";
14
-
15
- export type Contribution = {
16
- index?: number;
17
- location?: string;
18
- content: ReactElement;
19
- };
20
-
21
- export const useViewActionDispatcher = (
22
- id: string,
23
- root: RefObject<HTMLDivElement>,
24
- viewPath?: string,
25
- dropTargets?: string[]
26
- ): [ViewDispatch, Contribution[] | undefined] => {
27
- const { loadSessionState, purgeSessionState, purgeState, saveSessionState } =
28
- usePersistentState();
29
-
30
- const [contributions, setContributions] = useState<Contribution[]>(
31
- loadSessionState(id, "contributions") ?? []
32
- );
33
- const dispatchLayoutAction = useLayoutProviderDispatch();
34
- const updateContributions = useCallback(
35
- (location: string, content: ReactElement) => {
36
- const updatedContributions = contributions.concat([
37
- { location, content },
38
- ]);
39
- saveSessionState(id, "contributions", updatedContributions);
40
- setContributions(updatedContributions);
41
- },
42
- [contributions, id, saveSessionState]
43
- );
44
-
45
- const clearContributions = useCallback(() => {
46
- purgeSessionState(id, "contributions");
47
- setContributions([]);
48
- }, [id, purgeSessionState]);
49
-
50
- const handleRemove = useCallback(() => {
51
- const ds = loadSessionState(id, "data-source") as DataSource;
52
- if (ds) {
53
- ds.unsubscribe();
54
- }
55
- purgeSessionState(id);
56
- purgeState(id);
57
- dispatchLayoutAction({ type: "remove", path: viewPath });
58
- }, [
59
- dispatchLayoutAction,
60
- id,
61
- loadSessionState,
62
- purgeSessionState,
63
- purgeState,
64
- viewPath,
65
- ]);
66
-
67
- const handleMouseDown = useCallback(
68
- async (evt, index, preDragActivity): Promise<boolean> => {
69
- evt.stopPropagation();
70
- const dragRect = root.current?.getBoundingClientRect();
71
- return new Promise((resolve, reject) => {
72
- dispatchLayoutAction({
73
- type: "drag-start",
74
- evt,
75
- path: index === undefined ? viewPath : `${viewPath}.${index}`,
76
- dragRect,
77
- preDragActivity,
78
- dropTargets,
79
- resolveDragStart: resolve,
80
- rejectDragStart: reject,
81
- } as DragStartAction);
82
- });
83
- },
84
- [root, dispatchLayoutAction, viewPath, dropTargets]
85
- );
86
-
87
- const dispatchAction = useCallback(
88
- async <A extends ViewAction = ViewAction>(
89
- action: A,
90
- evt?: SyntheticEvent
91
- ): Promise<boolean | void> => {
92
- const { type } = action;
93
- switch (type) {
94
- case "maximize":
95
- case "minimize":
96
- case "restore":
97
- return dispatchLayoutAction({ type, path: action.path ?? viewPath });
98
- case "remove":
99
- return handleRemove();
100
- case "mousedown":
101
- console.log("2) ViewActionDispatch Hook dispatch Action mousedown");
102
- return handleMouseDown(evt, action.index, action.preDragActivity);
103
- case "add-toolbar-contribution":
104
- return updateContributions(action.location, action.content);
105
- case "remove-toolbar-contribution":
106
- return clearContributions();
107
- default: {
108
- return undefined;
109
- }
110
- }
111
- },
112
- [
113
- dispatchLayoutAction,
114
- viewPath,
115
- handleRemove,
116
- handleMouseDown,
117
- updateContributions,
118
- clearContributions,
119
- ]
120
- );
121
-
122
- return [dispatchAction, contributions];
123
- };
@@ -1,53 +0,0 @@
1
- import { useResizeObserver, WidthHeight } from "@heswell/salt-lab";
2
- import { RefObject, useCallback, useRef } from "react";
3
-
4
- const NO_MEASUREMENT: string[] = [];
5
-
6
- type size = {
7
- height?: number;
8
- width?: number;
9
- };
10
-
11
- export interface ViewResizeHookProps {
12
- mainRef: RefObject<HTMLDivElement>;
13
- resize?: "defer" | "responsive";
14
- rootRef: RefObject<HTMLDivElement>;
15
- }
16
-
17
- export const useViewResize = ({
18
- mainRef,
19
- resize = "responsive",
20
- rootRef,
21
- }: ViewResizeHookProps) => {
22
- const deferResize = resize === "defer";
23
-
24
- const mainSize = useRef<size>({});
25
- const resizeHandle = useRef<number>();
26
-
27
- const setMainSize = useCallback(() => {
28
- if (mainRef.current) {
29
- mainRef.current.style.height = mainSize.current.height + "px";
30
- mainRef.current.style.width = mainSize.current.width + "px";
31
- }
32
- resizeHandle.current = undefined;
33
- }, [mainRef]);
34
-
35
- const onResize = useCallback(
36
- ({ height, width }) => {
37
- mainSize.current.height = height;
38
- mainSize.current.width = width;
39
- if (resizeHandle.current !== null) {
40
- clearTimeout(resizeHandle.current);
41
- }
42
- resizeHandle.current = window.setTimeout(setMainSize, 40);
43
- },
44
- [setMainSize]
45
- );
46
-
47
- useResizeObserver(
48
- rootRef,
49
- deferResize ? WidthHeight : NO_MEASUREMENT,
50
- onResize,
51
- deferResize
52
- );
53
- };
@@ -1,35 +0,0 @@
1
- import { HTMLAttributes } from "react";
2
- import { HeaderProps } from "../layout-header";
3
- import {
4
- AddToolbarContributionViewAction, MaximizeAction,
5
- MinimizeAction,
6
- MousedownViewAction,
7
- RemoveAction, RemoveToolbarContributionViewAction, RestoreAction,
8
- TearoutAction
9
- } from "../layout-reducer";
10
-
11
- export type ViewAction =
12
- | MaximizeAction
13
- | MinimizeAction
14
- | MousedownViewAction
15
- | RemoveAction
16
- | RestoreAction
17
- | TearoutAction
18
- | AddToolbarContributionViewAction
19
- | RemoveToolbarContributionViewAction;
20
-
21
- export interface ViewProps extends HTMLAttributes<HTMLDivElement> {
22
- closeable?: boolean;
23
- collapsed?: boolean;
24
- "data-resizeable"?: boolean;
25
- dropTargets?: string[];
26
- expanded?: boolean;
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- flexFill?: any;
29
- header?: boolean | Partial<HeaderProps>;
30
- orientation?: "vertical" | "horizontal";
31
- path?: string;
32
- resize?: "defer" | "responsive";
33
- resizeable?: boolean;
34
- tearOut?: boolean;
35
- }
@@ -1,33 +0,0 @@
1
- .vuuPalette-horizontal {
2
- align-items: center;
3
- display: flex;
4
- }
5
-
6
- .vuuPaletteItem {
7
- --vuu-icon-color: var(--salt-separable-primary-borderColor);
8
- --vuu-icon-inset: calc(50% - 12px) auto auto -3px;
9
- --vuu-icon-height: 24px;
10
- --vuu-icon-width: 24px;
11
- --list-item-text-padding: 0 0 0 calc(var(--salt-size-unit) * 3);
12
- }
13
-
14
- .vuuPaletteItem[data-draggable]:after {
15
- height: 22px;
16
- width: 6px;
17
- content: "";
18
- position: absolute;
19
-
20
- background-image:
21
- linear-gradient(45deg, rgb(180, 183, 190) 25%, transparent 25%),
22
- linear-gradient(-45deg, rgb(180, 183, 190) 25%, transparent 25%),
23
- linear-gradient(45deg, transparent 75%, rgb(180, 183, 190) 25%),
24
- linear-gradient(-45deg, transparent 75%, rgb(180, 183, 190) 25%);
25
- background-size: 4px 4px;
26
- background-position: 0 0, 2px 0, 2px -2px, 0 2px;
27
-
28
- }
29
-
30
- .vuuSimpleDraggableWrapper > .vuuPaletteItem {
31
- --vuu-icon-color: var(--salt-selectable-foreground);
32
-
33
- }