@vuu-ui/vuu-layout 0.7.6-debug → 0.8.0-debug
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/cjs/index.js +63 -6
- package/cjs/index.js.map +2 -2
- package/esm/index.js +71 -10
- package/esm/index.js.map +3 -3
- package/index.css +6 -1
- package/index.css.map +2 -2
- package/package.json +3 -3
- package/types/flexbox/Splitter.d.ts +3 -3
- package/types/layout-action.d.ts +1 -0
- package/types/layout-reducer/layoutTypes.d.ts +22 -1
- package/types/layout-reducer/resize-flex-children.d.ts +3 -2
- package/LICENSE +0 -201
package/esm/index.js
CHANGED
|
@@ -137,7 +137,7 @@ var Component_default = Component;
|
|
|
137
137
|
registerComponent("Component", Component);
|
|
138
138
|
|
|
139
139
|
// src/utils/pathUtils.ts
|
|
140
|
-
import React2 from "react";
|
|
140
|
+
import React2, { isValidElement } from "react";
|
|
141
141
|
|
|
142
142
|
// src/utils/propUtils.ts
|
|
143
143
|
var NO_PROPS = {};
|
|
@@ -251,7 +251,30 @@ function followPathToComponent(component, path) {
|
|
|
251
251
|
children = getChildren(child);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
+
var findTargetById = (source, id, throwIfNotFound = true) => {
|
|
255
|
+
const { children, id: idProp } = source.props;
|
|
256
|
+
if (idProp === id) {
|
|
257
|
+
return source;
|
|
258
|
+
}
|
|
259
|
+
if (React2.Children.count(children) > 0) {
|
|
260
|
+
const childArray = isValidElement(children) ? [children] : children;
|
|
261
|
+
for (const child of childArray) {
|
|
262
|
+
if (isValidElement(child)) {
|
|
263
|
+
const target = findTargetById(child, id, false);
|
|
264
|
+
if (target) {
|
|
265
|
+
return target;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (throwIfNotFound === true) {
|
|
271
|
+
throw Error(`pathUtils.findTargetById id #${id} not found in source`);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
254
274
|
function followPath(source, path, throwIfNotFound = false) {
|
|
275
|
+
if (path.startsWith("#")) {
|
|
276
|
+
return findTargetById(source, path.slice(1), throwIfNotFound);
|
|
277
|
+
}
|
|
255
278
|
const { "data-path": dataPath, path: sourcePath = dataPath } = getProps(source);
|
|
256
279
|
if (path.indexOf(sourcePath) !== 0) {
|
|
257
280
|
throw Error(
|
|
@@ -1730,7 +1753,11 @@ registerComponent("Placeholder", Placeholder);
|
|
|
1730
1753
|
|
|
1731
1754
|
// src/flexbox/Splitter.tsx
|
|
1732
1755
|
import cx5 from "classnames";
|
|
1733
|
-
import React3, {
|
|
1756
|
+
import React3, {
|
|
1757
|
+
useCallback as useCallback2,
|
|
1758
|
+
useRef,
|
|
1759
|
+
useState
|
|
1760
|
+
} from "react";
|
|
1734
1761
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1735
1762
|
var Splitter = React3.memo(function Splitter2({
|
|
1736
1763
|
column,
|
|
@@ -2409,6 +2436,7 @@ var Action = {
|
|
|
2409
2436
|
FOCUS: "focus",
|
|
2410
2437
|
FOCUS_SPLITTER: "focus-splitter",
|
|
2411
2438
|
INITIALIZE: "initialize",
|
|
2439
|
+
LAYOUT_RESIZE: "layout-resize",
|
|
2412
2440
|
MAXIMIZE: "maximize",
|
|
2413
2441
|
MINIMIZE: "minimize",
|
|
2414
2442
|
REMOVE: "remove",
|
|
@@ -2954,12 +2982,15 @@ var LayoutActionType = {
|
|
|
2954
2982
|
ADD: "add",
|
|
2955
2983
|
DRAG_START: "drag-start",
|
|
2956
2984
|
DRAG_DROP: "drag-drop",
|
|
2985
|
+
LAYOUT_RESIZE: "layout-resize",
|
|
2957
2986
|
MAXIMIZE: "maximize",
|
|
2958
2987
|
MINIMIZE: "minimize",
|
|
2959
2988
|
REMOVE: "remove",
|
|
2960
2989
|
REPLACE: "replace",
|
|
2961
2990
|
RESTORE: "restore",
|
|
2962
2991
|
SAVE: "save",
|
|
2992
|
+
SET_PROP: "set-prop",
|
|
2993
|
+
SET_PROPS: "set-props",
|
|
2963
2994
|
SET_TITLE: "set-title",
|
|
2964
2995
|
SPLITTER_RESIZE: "splitter-resize",
|
|
2965
2996
|
SWITCH_TAB: "switch-tab",
|
|
@@ -3242,12 +3273,26 @@ var allOtherChildrenArePlaceholders = (children, path) => children.every(
|
|
|
3242
3273
|
|
|
3243
3274
|
// src/layout-reducer/resize-flex-children.ts
|
|
3244
3275
|
import React10 from "react";
|
|
3276
|
+
function resizeFlexChild(layoutRoot, { path, size }) {
|
|
3277
|
+
const target = followPath(layoutRoot, path, true);
|
|
3278
|
+
const { style } = getProps(target);
|
|
3279
|
+
const newStyle = {
|
|
3280
|
+
...style,
|
|
3281
|
+
width: size
|
|
3282
|
+
};
|
|
3283
|
+
const replacement = React10.cloneElement(target, { style: newStyle });
|
|
3284
|
+
return swapChild(layoutRoot, target, replacement);
|
|
3285
|
+
}
|
|
3245
3286
|
function resizeFlexChildren(layoutRoot, { path, sizes }) {
|
|
3246
3287
|
const target = followPath(layoutRoot, path, true);
|
|
3247
3288
|
const { children, style } = getProps(target);
|
|
3248
3289
|
const dimension = style.flexDirection === "column" ? "height" : "width";
|
|
3249
3290
|
const replacementChildren = applySizesToChildren(children, sizes, dimension);
|
|
3250
|
-
const replacement = React10.cloneElement(
|
|
3291
|
+
const replacement = React10.cloneElement(
|
|
3292
|
+
target,
|
|
3293
|
+
void 0,
|
|
3294
|
+
replacementChildren
|
|
3295
|
+
);
|
|
3251
3296
|
return swapChild(layoutRoot, target, replacement);
|
|
3252
3297
|
}
|
|
3253
3298
|
function applySizesToChildren(children, sizes, dimension) {
|
|
@@ -3497,10 +3542,21 @@ var layoutReducer = (state, action) => {
|
|
|
3497
3542
|
return removeChild(state, action);
|
|
3498
3543
|
case LayoutActionType.REPLACE:
|
|
3499
3544
|
return replaceChild(state, action);
|
|
3545
|
+
case LayoutActionType.SET_PROP:
|
|
3546
|
+
return setProp(state, action);
|
|
3547
|
+
case LayoutActionType.SET_PROPS:
|
|
3548
|
+
return setProps(state, action);
|
|
3500
3549
|
case LayoutActionType.SET_TITLE:
|
|
3501
|
-
return
|
|
3550
|
+
return setProp(state, {
|
|
3551
|
+
type: "set-prop",
|
|
3552
|
+
path: action.path,
|
|
3553
|
+
propName: "title",
|
|
3554
|
+
propValue: action.title
|
|
3555
|
+
});
|
|
3502
3556
|
case LayoutActionType.SPLITTER_RESIZE:
|
|
3503
3557
|
return resizeFlexChildren(state, action);
|
|
3558
|
+
case LayoutActionType.LAYOUT_RESIZE:
|
|
3559
|
+
return resizeFlexChild(state, action);
|
|
3504
3560
|
case LayoutActionType.SWITCH_TAB:
|
|
3505
3561
|
return switchTab(state, action);
|
|
3506
3562
|
default:
|
|
@@ -3514,13 +3570,18 @@ var switchTab = (state, { path, nextIdx }) => {
|
|
|
3514
3570
|
});
|
|
3515
3571
|
return swapChild(state, target, replacement);
|
|
3516
3572
|
};
|
|
3517
|
-
var
|
|
3573
|
+
var setProp = (state, { path, propName, propValue }) => {
|
|
3518
3574
|
const target = followPath(state, path, true);
|
|
3519
3575
|
const replacement = React12.cloneElement(target, {
|
|
3520
|
-
|
|
3576
|
+
[propName]: propValue
|
|
3521
3577
|
});
|
|
3522
3578
|
return swapChild(state, target, replacement);
|
|
3523
3579
|
};
|
|
3580
|
+
var setProps = (state, { path, props }) => {
|
|
3581
|
+
const target = followPath(state, path, true);
|
|
3582
|
+
const replacement = React12.cloneElement(target, props);
|
|
3583
|
+
return swapChild(state, target, replacement);
|
|
3584
|
+
};
|
|
3524
3585
|
var setChildProps = (state, { path, type }) => {
|
|
3525
3586
|
if (path) {
|
|
3526
3587
|
const target = followPath(state, path, true);
|
|
@@ -4200,7 +4261,7 @@ var extractResponsiveProps = (props) => {
|
|
|
4200
4261
|
import { getUniqueId as getUniqueId2 } from "@vuu-ui/vuu-utils";
|
|
4201
4262
|
import {
|
|
4202
4263
|
cloneElement as cloneElement2,
|
|
4203
|
-
isValidElement,
|
|
4264
|
+
isValidElement as isValidElement2,
|
|
4204
4265
|
useCallback as useCallback10,
|
|
4205
4266
|
useMemo as useMemo2,
|
|
4206
4267
|
useRef as useRef7
|
|
@@ -4219,7 +4280,7 @@ var useResponsiveSizing = ({
|
|
|
4219
4280
|
const isColumn = (style == null ? void 0 : style.flexDirection) === "column";
|
|
4220
4281
|
const dimension = isColumn ? "height" : "width";
|
|
4221
4282
|
const children = useMemo2(
|
|
4222
|
-
() => Array.isArray(childrenProp) ? childrenProp :
|
|
4283
|
+
() => Array.isArray(childrenProp) ? childrenProp : isValidElement2(childrenProp) ? [childrenProp] : [],
|
|
4223
4284
|
[childrenProp]
|
|
4224
4285
|
);
|
|
4225
4286
|
const buildContent2 = useCallback10(
|
|
@@ -5096,7 +5157,7 @@ var Stack = forwardRef6(function Stack2({
|
|
|
5096
5157
|
draggable: true,
|
|
5097
5158
|
id: rootId,
|
|
5098
5159
|
label: getTabLabel(child2, idx),
|
|
5099
|
-
closeable,
|
|
5160
|
+
closeable: closeable && (TabstripProps == null ? void 0 : TabstripProps.enableCloseTab) !== false,
|
|
5100
5161
|
editable: (TabstripProps == null ? void 0 : TabstripProps.enableRenameTab) !== false
|
|
5101
5162
|
},
|
|
5102
5163
|
childId != null ? childId : idx
|
|
@@ -5129,6 +5190,7 @@ var Stack = forwardRef6(function Stack2({
|
|
|
5129
5190
|
Tabstrip,
|
|
5130
5191
|
{
|
|
5131
5192
|
...TabstripProps,
|
|
5193
|
+
activeTabIndex: (_a = TabstripProps == null ? void 0 : TabstripProps.activeTabIndex) != null ? _a : child === null ? -1 : active,
|
|
5132
5194
|
enableRenameTab: (TabstripProps == null ? void 0 : TabstripProps.enableRenameTab) !== false,
|
|
5133
5195
|
enableAddTab,
|
|
5134
5196
|
enableCloseTab: enableCloseTabs,
|
|
@@ -5138,7 +5200,6 @@ var Stack = forwardRef6(function Stack2({
|
|
|
5138
5200
|
onCloseTab: handleTabClose,
|
|
5139
5201
|
onExitEditMode: handleExitEditMode,
|
|
5140
5202
|
onMouseDown: handleMouseDown,
|
|
5141
|
-
activeTabIndex: (_a = TabstripProps == null ? void 0 : TabstripProps.activeTabIndex) != null ? _a : child === null ? -1 : active,
|
|
5142
5203
|
children: renderTabs()
|
|
5143
5204
|
}
|
|
5144
5205
|
)
|