@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/cjs/index.js
CHANGED
|
@@ -360,7 +360,30 @@ function followPathToComponent(component, path) {
|
|
|
360
360
|
children = getChildren(child);
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
+
var findTargetById = (source, id, throwIfNotFound = true) => {
|
|
364
|
+
const { children, id: idProp } = source.props;
|
|
365
|
+
if (idProp === id) {
|
|
366
|
+
return source;
|
|
367
|
+
}
|
|
368
|
+
if (import_react3.default.Children.count(children) > 0) {
|
|
369
|
+
const childArray = (0, import_react3.isValidElement)(children) ? [children] : children;
|
|
370
|
+
for (const child of childArray) {
|
|
371
|
+
if ((0, import_react3.isValidElement)(child)) {
|
|
372
|
+
const target = findTargetById(child, id, false);
|
|
373
|
+
if (target) {
|
|
374
|
+
return target;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (throwIfNotFound === true) {
|
|
380
|
+
throw Error(`pathUtils.findTargetById id #${id} not found in source`);
|
|
381
|
+
}
|
|
382
|
+
};
|
|
363
383
|
function followPath(source, path, throwIfNotFound = false) {
|
|
384
|
+
if (path.startsWith("#")) {
|
|
385
|
+
return findTargetById(source, path.slice(1), throwIfNotFound);
|
|
386
|
+
}
|
|
364
387
|
const { "data-path": dataPath, path: sourcePath = dataPath } = getProps(source);
|
|
365
388
|
if (path.indexOf(sourcePath) !== 0) {
|
|
366
389
|
throw Error(
|
|
@@ -2513,6 +2536,7 @@ var Action = {
|
|
|
2513
2536
|
FOCUS: "focus",
|
|
2514
2537
|
FOCUS_SPLITTER: "focus-splitter",
|
|
2515
2538
|
INITIALIZE: "initialize",
|
|
2539
|
+
LAYOUT_RESIZE: "layout-resize",
|
|
2516
2540
|
MAXIMIZE: "maximize",
|
|
2517
2541
|
MINIMIZE: "minimize",
|
|
2518
2542
|
REMOVE: "remove",
|
|
@@ -3052,12 +3076,15 @@ var LayoutActionType = {
|
|
|
3052
3076
|
ADD: "add",
|
|
3053
3077
|
DRAG_START: "drag-start",
|
|
3054
3078
|
DRAG_DROP: "drag-drop",
|
|
3079
|
+
LAYOUT_RESIZE: "layout-resize",
|
|
3055
3080
|
MAXIMIZE: "maximize",
|
|
3056
3081
|
MINIMIZE: "minimize",
|
|
3057
3082
|
REMOVE: "remove",
|
|
3058
3083
|
REPLACE: "replace",
|
|
3059
3084
|
RESTORE: "restore",
|
|
3060
3085
|
SAVE: "save",
|
|
3086
|
+
SET_PROP: "set-prop",
|
|
3087
|
+
SET_PROPS: "set-props",
|
|
3061
3088
|
SET_TITLE: "set-title",
|
|
3062
3089
|
SPLITTER_RESIZE: "splitter-resize",
|
|
3063
3090
|
SWITCH_TAB: "switch-tab",
|
|
@@ -3340,12 +3367,26 @@ var allOtherChildrenArePlaceholders = (children, path) => children.every(
|
|
|
3340
3367
|
|
|
3341
3368
|
// src/layout-reducer/resize-flex-children.ts
|
|
3342
3369
|
var import_react14 = __toESM(require("react"));
|
|
3370
|
+
function resizeFlexChild(layoutRoot, { path, size }) {
|
|
3371
|
+
const target = followPath(layoutRoot, path, true);
|
|
3372
|
+
const { style } = getProps(target);
|
|
3373
|
+
const newStyle = {
|
|
3374
|
+
...style,
|
|
3375
|
+
width: size
|
|
3376
|
+
};
|
|
3377
|
+
const replacement = import_react14.default.cloneElement(target, { style: newStyle });
|
|
3378
|
+
return swapChild(layoutRoot, target, replacement);
|
|
3379
|
+
}
|
|
3343
3380
|
function resizeFlexChildren(layoutRoot, { path, sizes }) {
|
|
3344
3381
|
const target = followPath(layoutRoot, path, true);
|
|
3345
3382
|
const { children, style } = getProps(target);
|
|
3346
3383
|
const dimension = style.flexDirection === "column" ? "height" : "width";
|
|
3347
3384
|
const replacementChildren = applySizesToChildren(children, sizes, dimension);
|
|
3348
|
-
const replacement = import_react14.default.cloneElement(
|
|
3385
|
+
const replacement = import_react14.default.cloneElement(
|
|
3386
|
+
target,
|
|
3387
|
+
void 0,
|
|
3388
|
+
replacementChildren
|
|
3389
|
+
);
|
|
3349
3390
|
return swapChild(layoutRoot, target, replacement);
|
|
3350
3391
|
}
|
|
3351
3392
|
function applySizesToChildren(children, sizes, dimension) {
|
|
@@ -3595,10 +3636,21 @@ var layoutReducer = (state, action) => {
|
|
|
3595
3636
|
return removeChild(state, action);
|
|
3596
3637
|
case LayoutActionType.REPLACE:
|
|
3597
3638
|
return replaceChild(state, action);
|
|
3639
|
+
case LayoutActionType.SET_PROP:
|
|
3640
|
+
return setProp(state, action);
|
|
3641
|
+
case LayoutActionType.SET_PROPS:
|
|
3642
|
+
return setProps(state, action);
|
|
3598
3643
|
case LayoutActionType.SET_TITLE:
|
|
3599
|
-
return
|
|
3644
|
+
return setProp(state, {
|
|
3645
|
+
type: "set-prop",
|
|
3646
|
+
path: action.path,
|
|
3647
|
+
propName: "title",
|
|
3648
|
+
propValue: action.title
|
|
3649
|
+
});
|
|
3600
3650
|
case LayoutActionType.SPLITTER_RESIZE:
|
|
3601
3651
|
return resizeFlexChildren(state, action);
|
|
3652
|
+
case LayoutActionType.LAYOUT_RESIZE:
|
|
3653
|
+
return resizeFlexChild(state, action);
|
|
3602
3654
|
case LayoutActionType.SWITCH_TAB:
|
|
3603
3655
|
return switchTab(state, action);
|
|
3604
3656
|
default:
|
|
@@ -3612,13 +3664,18 @@ var switchTab = (state, { path, nextIdx }) => {
|
|
|
3612
3664
|
});
|
|
3613
3665
|
return swapChild(state, target, replacement);
|
|
3614
3666
|
};
|
|
3615
|
-
var
|
|
3667
|
+
var setProp = (state, { path, propName, propValue }) => {
|
|
3616
3668
|
const target = followPath(state, path, true);
|
|
3617
3669
|
const replacement = import_react16.default.cloneElement(target, {
|
|
3618
|
-
|
|
3670
|
+
[propName]: propValue
|
|
3619
3671
|
});
|
|
3620
3672
|
return swapChild(state, target, replacement);
|
|
3621
3673
|
};
|
|
3674
|
+
var setProps = (state, { path, props }) => {
|
|
3675
|
+
const target = followPath(state, path, true);
|
|
3676
|
+
const replacement = import_react16.default.cloneElement(target, props);
|
|
3677
|
+
return swapChild(state, target, replacement);
|
|
3678
|
+
};
|
|
3622
3679
|
var setChildProps = (state, { path, type }) => {
|
|
3623
3680
|
if (path) {
|
|
3624
3681
|
const target = followPath(state, path, true);
|
|
@@ -5164,7 +5221,7 @@ var Stack = (0, import_react32.forwardRef)(function Stack2({
|
|
|
5164
5221
|
draggable: true,
|
|
5165
5222
|
id: rootId,
|
|
5166
5223
|
label: getTabLabel(child2, idx),
|
|
5167
|
-
closeable,
|
|
5224
|
+
closeable: closeable && (TabstripProps == null ? void 0 : TabstripProps.enableCloseTab) !== false,
|
|
5168
5225
|
editable: (TabstripProps == null ? void 0 : TabstripProps.enableRenameTab) !== false
|
|
5169
5226
|
},
|
|
5170
5227
|
childId != null ? childId : idx
|
|
@@ -5197,6 +5254,7 @@ var Stack = (0, import_react32.forwardRef)(function Stack2({
|
|
|
5197
5254
|
import_salt_lab5.Tabstrip,
|
|
5198
5255
|
{
|
|
5199
5256
|
...TabstripProps,
|
|
5257
|
+
activeTabIndex: (_a = TabstripProps == null ? void 0 : TabstripProps.activeTabIndex) != null ? _a : child === null ? -1 : active,
|
|
5200
5258
|
enableRenameTab: (TabstripProps == null ? void 0 : TabstripProps.enableRenameTab) !== false,
|
|
5201
5259
|
enableAddTab,
|
|
5202
5260
|
enableCloseTab: enableCloseTabs,
|
|
@@ -5206,7 +5264,6 @@ var Stack = (0, import_react32.forwardRef)(function Stack2({
|
|
|
5206
5264
|
onCloseTab: handleTabClose,
|
|
5207
5265
|
onExitEditMode: handleExitEditMode,
|
|
5208
5266
|
onMouseDown: handleMouseDown,
|
|
5209
|
-
activeTabIndex: (_a = TabstripProps == null ? void 0 : TabstripProps.activeTabIndex) != null ? _a : child === null ? -1 : active,
|
|
5210
5267
|
children: renderTabs()
|
|
5211
5268
|
}
|
|
5212
5269
|
)
|