@vuu-ui/vuu-layout 2.1.19-beta.1 → 2.1.19-beta.2
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 +12 -13
- package/src/Component.js +14 -0
- package/src/LayoutContainer.css.js +24 -0
- package/src/LayoutContainer.js +26 -0
- package/src/debug.js +16 -0
- package/src/dock-layout/DockLayout.css.js +36 -0
- package/src/dock-layout/DockLayout.js +43 -0
- package/src/dock-layout/Drawer.css.js +150 -0
- package/src/dock-layout/Drawer.js +82 -0
- package/src/dock-layout/index.js +2 -0
- package/src/drag-drop/BoxModel.js +337 -0
- package/src/drag-drop/DragState.js +119 -0
- package/src/drag-drop/Draggable.js +140 -0
- package/src/drag-drop/DropTarget.js +286 -0
- package/src/drag-drop/DropTargetRenderer.js +275 -0
- package/src/drag-drop/dragDropTypes.js +0 -0
- package/src/drag-drop/index.js +3 -0
- package/src/flexbox/Flexbox.css.js +45 -0
- package/src/flexbox/Flexbox.js +45 -0
- package/src/flexbox/FlexboxLayout.js +27 -0
- package/src/flexbox/Splitter.css.js +57 -0
- package/src/flexbox/Splitter.js +112 -0
- package/src/flexbox/flexbox-utils.js +92 -0
- package/src/flexbox/flexboxTypes.js +0 -0
- package/src/flexbox/index.js +2 -0
- package/src/flexbox/useSplitterResizing.js +181 -0
- package/src/index.js +20 -0
- package/src/layout-action.js +20 -0
- package/src/layout-header/ActionButton.js +15 -0
- package/src/layout-header/Header.css.js +32 -0
- package/src/layout-header/Header.js +99 -0
- package/src/layout-header/index.js +1 -0
- package/src/layout-header/useHeader.js +76 -0
- package/src/layout-provider/LayoutProvider.js +242 -0
- package/src/layout-provider/LayoutProviderContext.js +13 -0
- package/src/layout-provider/index.js +2 -0
- package/src/layout-provider/useLayoutDragDrop.js +147 -0
- package/src/layout-reducer/flexUtils.js +186 -0
- package/src/layout-reducer/index.js +4 -0
- package/src/layout-reducer/insert-layout-element.js +179 -0
- package/src/layout-reducer/layout-reducer.js +121 -0
- package/src/layout-reducer/layoutTypes.js +34 -0
- package/src/layout-reducer/layoutUtils.js +178 -0
- package/src/layout-reducer/move-layout-element.js +18 -0
- package/src/layout-reducer/remove-layout-element.js +161 -0
- package/src/layout-reducer/replace-layout-element.js +70 -0
- package/src/layout-reducer/resize-flex-children.js +48 -0
- package/src/layout-reducer/wrap-layout-element.js +134 -0
- package/src/layout-view/View.css.js +76 -0
- package/src/layout-view/View.js +116 -0
- package/src/layout-view/useView.js +69 -0
- package/src/layout-view/useViewBroadcastChannel.js +29 -0
- package/src/layout-view/useViewResize.js +27 -0
- package/src/layout-view/viewTypes.js +0 -0
- package/src/layout-view-actions/ViewContext.js +11 -0
- package/src/layout-view-actions/useViewActionDispatcher.js +116 -0
- package/src/layout-view-actions/useViewContributions.js +31 -0
- package/src/palette/Palette.css.js +31 -0
- package/src/palette/Palette.js +85 -0
- package/src/palette/index.js +1 -0
- package/src/placeholder/LayoutStartPanel.css.js +35 -0
- package/src/placeholder/LayoutStartPanel.js +57 -0
- package/src/placeholder/Placeholder.css.js +20 -0
- package/src/placeholder/Placeholder.js +33 -0
- package/src/placeholder/index.js +1 -0
- package/src/responsive/index.js +2 -0
- package/src/responsive/measureMinimumNodeSize.js +24 -0
- package/src/responsive/useResizeObserver.js +109 -0
- package/src/responsive/utils.js +27 -0
- package/src/stack/Stack.css.js +44 -0
- package/src/stack/Stack.js +98 -0
- package/src/stack/StackLayout.js +116 -0
- package/src/stack/index.js +3 -0
- package/src/stack/stackTypes.js +0 -0
- package/src/tabs/TabPanel.css.js +17 -0
- package/src/tabs/TabPanel.js +11 -0
- package/src/tabs/index.js +1 -0
- package/src/tools/config-wrapper/ConfigWrapper.js +55 -0
- package/src/tools/config-wrapper/index.js +1 -0
- package/src/tools/devtools-box/layout-configurator.css.js +113 -0
- package/src/tools/devtools-tree/layout-tree-viewer.css.js +17 -0
- package/src/tools/index.js +3 -0
- package/src/use-persistent-state.js +43 -0
- package/src/utils/index.js +5 -0
- package/src/utils/pathUtils.js +212 -0
- package/src/utils/propUtils.js +15 -0
- package/src/utils/refUtils.js +5 -0
- package/src/utils/styleUtils.js +9 -0
- package/src/utils/typeOf.js +15 -0
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.1.19-beta.
|
|
2
|
+
"version": "2.1.19-beta.2",
|
|
3
3
|
"description": "VUU Layout Components",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "heswell",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@vuu-ui/vuu-data-types": "2.1.19-beta.
|
|
10
|
-
"@vuu-ui/vuu-filter-types": "2.1.19-beta.
|
|
9
|
+
"@vuu-ui/vuu-data-types": "2.1.19-beta.2",
|
|
10
|
+
"@vuu-ui/vuu-filter-types": "2.1.19-beta.2"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@salt-ds/core": "1.54.1",
|
|
14
14
|
"@salt-ds/styles": "0.2.1",
|
|
15
15
|
"@salt-ds/window": "0.1.1",
|
|
16
|
-
"@vuu-ui/vuu-data-react": "2.1.19-beta.
|
|
17
|
-
"@vuu-ui/vuu-datatable": "2.1.19-beta.
|
|
18
|
-
"@vuu-ui/vuu-filters": "2.1.19-beta.
|
|
19
|
-
"@vuu-ui/vuu-popups": "2.1.19-beta.
|
|
20
|
-
"@vuu-ui/vuu-table": "2.1.19-beta.
|
|
21
|
-
"@vuu-ui/vuu-ui-controls": "2.1.19-beta.
|
|
22
|
-
"@vuu-ui/vuu-utils": "2.1.19-beta.
|
|
16
|
+
"@vuu-ui/vuu-data-react": "2.1.19-beta.2",
|
|
17
|
+
"@vuu-ui/vuu-datatable": "2.1.19-beta.2",
|
|
18
|
+
"@vuu-ui/vuu-filters": "2.1.19-beta.2",
|
|
19
|
+
"@vuu-ui/vuu-popups": "2.1.19-beta.2",
|
|
20
|
+
"@vuu-ui/vuu-table": "2.1.19-beta.2",
|
|
21
|
+
"@vuu-ui/vuu-ui-controls": "2.1.19-beta.2",
|
|
22
|
+
"@vuu-ui/vuu-utils": "2.1.19-beta.2"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"clsx": "^2.0.0",
|
|
@@ -29,13 +29,12 @@
|
|
|
29
29
|
"sideEffects": false,
|
|
30
30
|
"files": [
|
|
31
31
|
"README.md",
|
|
32
|
-
"
|
|
33
|
-
"cjs",
|
|
32
|
+
"src",
|
|
34
33
|
"/types"
|
|
35
34
|
],
|
|
36
35
|
"exports": {
|
|
37
36
|
".": {
|
|
38
|
-
"import": "./index.js",
|
|
37
|
+
"import": "./src/index.js",
|
|
39
38
|
"types": "./types/index.d.ts"
|
|
40
39
|
}
|
|
41
40
|
},
|
package/src/Component.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { registerComponent } from "@vuu-ui/vuu-utils";
|
|
4
|
+
const Component_Component = /*#__PURE__*/ forwardRef(function({ resizeable, ...props }, ref) {
|
|
5
|
+
return /*#__PURE__*/ jsx("div", {
|
|
6
|
+
...props,
|
|
7
|
+
className: "Component",
|
|
8
|
+
ref: ref
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
Component_Component.displayName = "Component";
|
|
12
|
+
var src_Component = Component_Component;
|
|
13
|
+
registerComponent("Component", Component_Component, "component");
|
|
14
|
+
export default src_Component;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
.vuuLayoutContainer {
|
|
3
|
+
outline: none;
|
|
4
|
+
display: inline-block;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
[data-dragging="true"] {
|
|
8
|
+
z-index: 100;
|
|
9
|
+
position: absolute !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.vuuSimpleDraggableWrapper {
|
|
13
|
+
background-color: #fff;
|
|
14
|
+
box-shadow: 0 6px 10px #0003;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.vuuSimpleDraggableWrapper > * {
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
`;
|
|
24
|
+
export default css;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { registerComponent } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
4
|
+
import { useWindow } from "@salt-ds/window";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import LayoutContainer_0 from "./LayoutContainer.css";
|
|
8
|
+
const LayoutContainer_LayoutContainer = /*#__PURE__*/ forwardRef(function({ children, className: classNameProp, dropTarget, resizeable: _, ...htmlAttributes }, forwardedRef) {
|
|
9
|
+
const targetWindow = useWindow();
|
|
10
|
+
useComponentCssInjection({
|
|
11
|
+
testId: "vuu-layout-container",
|
|
12
|
+
css: LayoutContainer_0,
|
|
13
|
+
window: targetWindow
|
|
14
|
+
});
|
|
15
|
+
const className = clsx("vuuLayoutContainer", classNameProp);
|
|
16
|
+
return /*#__PURE__*/ jsx("div", {
|
|
17
|
+
className: className,
|
|
18
|
+
ref: forwardedRef,
|
|
19
|
+
...htmlAttributes,
|
|
20
|
+
children: children
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
const componentName = "LayoutContainer";
|
|
24
|
+
LayoutContainer_LayoutContainer.displayName = componentName;
|
|
25
|
+
registerComponent(componentName, LayoutContainer_LayoutContainer, "container");
|
|
26
|
+
export { LayoutContainer_LayoutContainer as LayoutContainer };
|
package/src/debug.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { typeOf } from "./utils/index.js";
|
|
2
|
+
const tree = (el, depth = 0)=>{
|
|
3
|
+
const type = typeOf(el);
|
|
4
|
+
const spaces = " ";
|
|
5
|
+
let str = `\n${spaces.slice(0, depth)}${type}`;
|
|
6
|
+
if ("View" !== type) {
|
|
7
|
+
const els = el.props.children || [];
|
|
8
|
+
(Array.isArray(els) ? els : [
|
|
9
|
+
els
|
|
10
|
+
]).forEach((child)=>{
|
|
11
|
+
str += tree(child, depth + 1);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return str;
|
|
15
|
+
};
|
|
16
|
+
export { tree };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
.vuuDockLayout {
|
|
3
|
+
--chest-bg: var(--hw-chest-bg, inherit);
|
|
4
|
+
--drawer-bg: var(--hw-drawer-bg, inherit);
|
|
5
|
+
--drawer-size: var(--hw-drawer-size, 200px);
|
|
6
|
+
--drawer-peek-size: var(--hw-drawer-peek-size, 32px);
|
|
7
|
+
--drawer-transition-duration: var(--hw-drawer-transition-duration, .4s);
|
|
8
|
+
background-color: var(--chest-bg);
|
|
9
|
+
display: flex;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.vuuDockLayout-horizontal {
|
|
13
|
+
flex-direction: row;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.vuuDockLayout-vertical {
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.vuuDockLayout-content {
|
|
21
|
+
background-color: var(--chest-bg);
|
|
22
|
+
flex-grow: 1;
|
|
23
|
+
flex-shrink: 1;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
align-items: center;
|
|
26
|
+
display: flex;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.vuuDockLayout-horizontal .vuuDockLayout-content, .vuuDockLayout-vertical .vuuDockLayout-content {
|
|
31
|
+
flex-basis: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
`;
|
|
36
|
+
export default css;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { asReactElements, partition, registerComponent } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
5
|
+
import { useWindow } from "@salt-ds/window";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import Drawer from "./Drawer.js";
|
|
8
|
+
import DockLayout from "./DockLayout.css";
|
|
9
|
+
const isDrawer = (component)=>component.type === Drawer;
|
|
10
|
+
const isVertical = (element)=>element.props.position && element.props.position.match(/top|bottom/);
|
|
11
|
+
const classBase = "vuuDockLayout";
|
|
12
|
+
const DockLayout_DockLayout = (props)=>{
|
|
13
|
+
const targetWindow = useWindow();
|
|
14
|
+
useComponentCssInjection({
|
|
15
|
+
testId: "vuu-dock-layput",
|
|
16
|
+
css: DockLayout,
|
|
17
|
+
window: targetWindow
|
|
18
|
+
});
|
|
19
|
+
const { children, className: classNameProp, id, style } = props;
|
|
20
|
+
const childElements = useMemo(()=>asReactElements(children), [
|
|
21
|
+
children
|
|
22
|
+
]);
|
|
23
|
+
const [drawers, content] = partition(childElements, isDrawer);
|
|
24
|
+
const [verticalDrawers, horizontalDrawers] = partition(drawers, isVertical);
|
|
25
|
+
const orientation = 0 === verticalDrawers.length ? "horizontal" : 0 === horizontalDrawers.length ? "vertical" : "both";
|
|
26
|
+
const className = clsx(classBase, classNameProp, `${classBase}-${orientation}`);
|
|
27
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
28
|
+
className: className,
|
|
29
|
+
id: id,
|
|
30
|
+
style: style,
|
|
31
|
+
children: [
|
|
32
|
+
drawers,
|
|
33
|
+
/*#__PURE__*/ jsx("div", {
|
|
34
|
+
className: `${classBase}-content`,
|
|
35
|
+
children: content
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
DockLayout_DockLayout.displayName = "DockLayout";
|
|
41
|
+
var dock_layout_DockLayout = DockLayout_DockLayout;
|
|
42
|
+
registerComponent("DockLayout", DockLayout_DockLayout, "container");
|
|
43
|
+
export default dock_layout_DockLayout;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
const css = `
|
|
2
|
+
.vuuDrawer {
|
|
3
|
+
--drawer-leading-edge-border: solid 1px var(--salt-container-primary-borderColor, none);
|
|
4
|
+
--vuu-close-icon-svg: var(--svg-chevron-double-right);
|
|
5
|
+
transition: flex-basis;
|
|
6
|
+
transition-duration: var(--drawer-transition-duration);
|
|
7
|
+
z-index: 1;
|
|
8
|
+
flex: 1 1 0;
|
|
9
|
+
min-width: 0;
|
|
10
|
+
min-height: 0;
|
|
11
|
+
display: flex;
|
|
12
|
+
position: relative;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.vuuDrawer-peekaboo {
|
|
16
|
+
flex-basis: var(--drawer-peek-size);
|
|
17
|
+
flex-grow: 0;
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.vuuDrawer-inline.vuuDrawer-open {
|
|
22
|
+
flex-basis: var(--drawer-size);
|
|
23
|
+
flex-grow: 0;
|
|
24
|
+
flex-shrink: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.vuuDrawer-liner {
|
|
28
|
+
background-color: var(--drawer-bg);
|
|
29
|
+
position: relative;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.vuuDrawer-content {
|
|
34
|
+
height: 100%;
|
|
35
|
+
top: 0;
|
|
36
|
+
right: var(--drawer-peek-size);
|
|
37
|
+
transition: right;
|
|
38
|
+
transition-duration: var(--drawer-transition-duration);
|
|
39
|
+
flex: 100%;
|
|
40
|
+
width: 100%;
|
|
41
|
+
position: absolute;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.vuuDrawer-open .vuuDrawer-content {
|
|
46
|
+
right: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.vuuDrawer-left {
|
|
50
|
+
border-right: var(--drawer-leading-edge-border);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.vuuDrawer-right {
|
|
54
|
+
border-left: var(--drawer-leading-edge-border);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.vuuDrawer-top {
|
|
58
|
+
border-bottom: var(--drawer-leading-edge-border);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.vuuDrawer-bottom {
|
|
62
|
+
border-top: var(--drawer-leading-edge-border);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.vuuDrawer-left .vuuDrawer-liner, .vuuDrawer-right .vuuDrawer-liner {
|
|
66
|
+
height: 100%;
|
|
67
|
+
transition: width;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.vuuDrawer-top .vuuDrawer-liner, .vuuDrawer-bottom .vuuDrawer-liner {
|
|
71
|
+
width: 100%;
|
|
72
|
+
transition: height;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.vuuDrawer-inline .vuuDrawer-liner {
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 100%;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.vuuDrawer-over .vuuDrawer-liner {
|
|
81
|
+
transition-duration: .4s;
|
|
82
|
+
position: absolute;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.vuuDrawer-over.vuuDrawer-left .vuuDrawer-liner {
|
|
86
|
+
width: 0;
|
|
87
|
+
top: 0;
|
|
88
|
+
left: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.vuuDrawer-over.vuuDrawer-right .vuuDrawer-liner {
|
|
92
|
+
width: 0;
|
|
93
|
+
top: 0;
|
|
94
|
+
right: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.vuuDrawer-over.vuuDrawer-top .vuuDrawer-liner {
|
|
98
|
+
height: 0;
|
|
99
|
+
top: 0;
|
|
100
|
+
left: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.vuuDrawer-over.vuuDrawer-bottom .vuuDrawer-liner {
|
|
104
|
+
height: 0;
|
|
105
|
+
bottom: 0;
|
|
106
|
+
left: 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.vuuDrawer-left.vuuDrawer-over.vuuDrawer-peekaboo .vuuDrawer-liner, .vuuDrawer-right.vuuDrawer-over.vuuDrawer-peekaboo .vuuDrawer-liner {
|
|
110
|
+
width: var(--drawer-peek-size);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.vuuDrawer-top.vuuDrawer-over.vuuDrawer-peekaboo .vuuDrawer-liner, .vuuDrawer-bottom.vuuDrawer-over.vuuDrawer-peekaboo .vuuDrawer-liner {
|
|
114
|
+
height: var(--drawer-peek-size);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.vuuDrawer-left.vuuDrawer-over.vuuDrawer-open .vuuDrawer-liner, .vuuDrawer-right.vuuDrawer-over.vuuDrawer-open .vuuDrawer-liner {
|
|
118
|
+
width: var(--drawer-size);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.vuuDrawer-top.vuuDrawer-over.vuuDrawer-open .vuuDrawer-liner, .vuuDrawer-bottom.vuuDrawer-over.vuuDrawer-open .vuuDrawer-liner {
|
|
122
|
+
height: var(--drawer-size);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.vuuDrawer-top, .vuuDrawer-left {
|
|
126
|
+
order: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.vuuDrawer-bottom, .vuuDrawer-right {
|
|
130
|
+
order: 99;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.vuuDrawer-left, .vuuDrawer-right {
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.vuuToggleButton-container {
|
|
138
|
+
--saltButton-height: 28px;
|
|
139
|
+
--saltButton-width: 28px;
|
|
140
|
+
--vuu-icon-size: 12px;
|
|
141
|
+
flex: 0 0 28px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.vuuDrawer-open {
|
|
145
|
+
--vuu-close-icon-svg: var(--svg-chevron-double-left);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
`;
|
|
150
|
+
export default css;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, useControlled } from "@salt-ds/core";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { useComponentCssInjection } from "@salt-ds/styles";
|
|
5
|
+
import { useWindow } from "@salt-ds/window";
|
|
6
|
+
import { useCallback } from "react";
|
|
7
|
+
import Drawer from "./Drawer.css";
|
|
8
|
+
const classBase = "vuuDrawer";
|
|
9
|
+
const sizeAttribute = (value)=>"string" == typeof value ? value : value + "px";
|
|
10
|
+
const getStyle = (styleProp, sizeOpen, sizeClosed)=>{
|
|
11
|
+
const hasSizeOpen = void 0 !== sizeOpen;
|
|
12
|
+
const hasSizeClosed = void 0 !== sizeClosed;
|
|
13
|
+
if (!styleProp && !hasSizeClosed && !hasSizeOpen) return;
|
|
14
|
+
if (!hasSizeClosed && !hasSizeOpen) return styleProp;
|
|
15
|
+
return {
|
|
16
|
+
...styleProp,
|
|
17
|
+
"--drawer-size": hasSizeOpen ? sizeAttribute(sizeOpen) : void 0,
|
|
18
|
+
"--drawer-peek-size": hasSizeClosed ? sizeAttribute(sizeClosed) : void 0
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const Drawer_Drawer = ({ children, className: classNameProp, clickToOpen, defaultOpen, sizeOpen, sizeClosed, style: styleProp, open: openProp, position = "left", inline, onClick, peekaboo = false, toggleButton, ...props })=>{
|
|
22
|
+
const targetWindow = useWindow();
|
|
23
|
+
useComponentCssInjection({
|
|
24
|
+
testId: "vuu-drawer",
|
|
25
|
+
css: Drawer,
|
|
26
|
+
window: targetWindow
|
|
27
|
+
});
|
|
28
|
+
const [open, setOpen] = useControlled({
|
|
29
|
+
controlled: openProp,
|
|
30
|
+
default: defaultOpen ?? false,
|
|
31
|
+
name: "Drawer",
|
|
32
|
+
state: "open"
|
|
33
|
+
});
|
|
34
|
+
const className = clsx(classBase, classNameProp, `${classBase}-${position}`, {
|
|
35
|
+
[`${classBase}-open`]: open,
|
|
36
|
+
[`${classBase}-inline`]: inline,
|
|
37
|
+
[`${classBase}-over`]: !inline,
|
|
38
|
+
[`${classBase}-peekaboo`]: peekaboo
|
|
39
|
+
});
|
|
40
|
+
const toggleDrawer = useCallback(()=>{
|
|
41
|
+
setOpen(!open);
|
|
42
|
+
}, [
|
|
43
|
+
open,
|
|
44
|
+
setOpen
|
|
45
|
+
]);
|
|
46
|
+
const style = getStyle(styleProp, sizeOpen, sizeClosed);
|
|
47
|
+
const handleClick = clickToOpen ? toggleDrawer : onClick;
|
|
48
|
+
const renderToggleButton = ()=>/*#__PURE__*/ jsx("div", {
|
|
49
|
+
className: clsx("vuuToggleButton-container"),
|
|
50
|
+
children: open ? /*#__PURE__*/ jsx(Button, {
|
|
51
|
+
"aria-label": "close",
|
|
52
|
+
onClick: toggleDrawer,
|
|
53
|
+
"data-icon": "close",
|
|
54
|
+
variant: "secondary"
|
|
55
|
+
}) : /*#__PURE__*/ jsx(Button, {
|
|
56
|
+
"aria-label": "open",
|
|
57
|
+
onClick: toggleDrawer,
|
|
58
|
+
"data-icon": "close",
|
|
59
|
+
variant: "secondary"
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
63
|
+
...props,
|
|
64
|
+
className: className,
|
|
65
|
+
onClick: handleClick,
|
|
66
|
+
style: style,
|
|
67
|
+
children: [
|
|
68
|
+
"start" == toggleButton ? renderToggleButton() : null,
|
|
69
|
+
/*#__PURE__*/ jsx("div", {
|
|
70
|
+
className: `${classBase}-liner`,
|
|
71
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
72
|
+
className: `${classBase}-content`,
|
|
73
|
+
children: children
|
|
74
|
+
})
|
|
75
|
+
}),
|
|
76
|
+
"end" == toggleButton ? renderToggleButton() : null
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
Drawer_Drawer.displayName = "Drawer";
|
|
81
|
+
var dock_layout_Drawer = Drawer_Drawer;
|
|
82
|
+
export default dock_layout_Drawer;
|