@vuu-ui/vuu-layout 0.6.25-debug → 0.6.26-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/esm/index.js CHANGED
@@ -1,7 +1,29 @@
1
- // src/chest-of-drawers/Chest.tsx
1
+ // src/dock-layout/DockLayout.tsx
2
+ import { partition } from "@vuu-ui/vuu-utils";
2
3
  import cx2 from "classnames";
3
4
 
4
- // src/chest-of-drawers/Drawer.tsx
5
+ // src/registry/ComponentRegistry.ts
6
+ var _containers = {};
7
+ var _views = {};
8
+ var ComponentRegistry = {};
9
+ function isContainer(componentType) {
10
+ return _containers[componentType] === true;
11
+ }
12
+ function isView(componentType) {
13
+ return _views[componentType] === true;
14
+ }
15
+ var isLayoutComponent = (type) => isContainer(type) || isView(type);
16
+ var isRegistered = (className) => !!ComponentRegistry[className];
17
+ function registerComponent(componentName2, component, type = "component") {
18
+ ComponentRegistry[componentName2] = component;
19
+ if (type === "container") {
20
+ _containers[componentName2] = true;
21
+ } else if (type === "view") {
22
+ _views[componentName2] = true;
23
+ }
24
+ }
25
+
26
+ // src/dock-layout/Drawer.tsx
5
27
  import { Button, useControlled } from "@salt-ds/core";
6
28
  import cx from "classnames";
7
29
  import { useCallback } from "react";
@@ -54,7 +76,6 @@ var Drawer = ({
54
76
  [`${classBase}-peekaboo`]: peekaboo
55
77
  });
56
78
  const toggleDrawer = useCallback(() => {
57
- console.log("toggleDrawer");
58
79
  setOpen(!open);
59
80
  }, [open, setOpen]);
60
81
  const style = getStyle(styleProp, sizeOpen, sizeClosed);
@@ -85,49 +106,25 @@ var Drawer = ({
85
106
  Drawer.displayName = "Drawer";
86
107
  var Drawer_default = Drawer;
87
108
 
88
- // src/chest-of-drawers/Chest.tsx
89
- import { partition } from "@vuu-ui/vuu-utils";
90
-
91
- // src/registry/ComponentRegistry.ts
92
- var _containers = {};
93
- var _views = {};
94
- var ComponentRegistry = {};
95
- function isContainer(componentType) {
96
- return _containers[componentType] === true;
97
- }
98
- function isView(componentType) {
99
- return _views[componentType] === true;
100
- }
101
- var isLayoutComponent = (type) => isContainer(type) || isView(type);
102
- var isRegistered = (className) => !!ComponentRegistry[className];
103
- function registerComponent(componentName2, component, type = "component") {
104
- ComponentRegistry[componentName2] = component;
105
- if (type === "container") {
106
- _containers[componentName2] = true;
107
- } else if (type === "view") {
108
- _views[componentName2] = true;
109
- }
110
- }
111
-
112
- // src/chest-of-drawers/Chest.tsx
109
+ // src/dock-layout/DockLayout.tsx
113
110
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
114
111
  var isDrawer = (component) => component.type === Drawer_default;
115
112
  var isVertical = ({ props: { position = "left" } }) => position.match(/top|bottom/);
116
- var Chest = (props) => {
113
+ var DockLayout = (props) => {
117
114
  const { children, className: classNameProp, id, style } = props;
118
- const classBase8 = "hwChest";
115
+ const classBase9 = "vuuDockLayout";
119
116
  const [drawers, content] = partition(children, isDrawer);
120
117
  const [verticalDrawers, horizontalDrawers] = partition(drawers, isVertical);
121
118
  const orientation = verticalDrawers.length === 0 ? "horizontal" : horizontalDrawers.length === 0 ? "vertical" : "both";
122
- const className = cx2(classBase8, classNameProp, `${classBase8}-${orientation}`);
119
+ const className = cx2(classBase9, classNameProp, `${classBase9}-${orientation}`);
123
120
  return /* @__PURE__ */ jsxs2("div", { className, id, style, children: [
124
121
  drawers,
125
- /* @__PURE__ */ jsx2("div", { className: `${classBase8}-content`, children: content })
122
+ /* @__PURE__ */ jsx2("div", { className: `${classBase9}-content`, children: content })
126
123
  ] });
127
124
  };
128
- Chest.displayName = "Chest";
129
- var Chest_default = Chest;
130
- registerComponent("Chest", Chest, "container");
125
+ DockLayout.displayName = "DockLayout";
126
+ var DockLayout_default = DockLayout;
127
+ registerComponent("DockLayout", DockLayout, "container");
131
128
 
132
129
  // src/Component.tsx
133
130
  import { forwardRef } from "react";
@@ -1679,6 +1676,8 @@ var DraggableLayout = forwardRef2(function DraggableLayout2({
1679
1676
  children,
1680
1677
  className: classNameProp,
1681
1678
  dropTarget,
1679
+ resizeable: _,
1680
+ // ignore, its just a marker used by the layout system
1682
1681
  ...htmlAttributes
1683
1682
  }, forwardedRef) {
1684
1683
  const className = classnames("DraggableLayout", classNameProp);
@@ -2129,7 +2128,7 @@ function getLeadingResizeablePos(contentMeta, idx) {
2129
2128
  function getTrailingResizeablePos(contentMeta, idx) {
2130
2129
  let pos = idx, resizeable = false;
2131
2130
  const count = contentMeta.length;
2132
- while (pos < count && !resizeable) {
2131
+ while (pos < count - 1 && !resizeable) {
2133
2132
  pos = pos + 1;
2134
2133
  resizeable = isResizeable(contentMeta, pos);
2135
2134
  }
@@ -4336,7 +4335,7 @@ registerComponent("FluidGrid", FluidGridLayout, "container");
4336
4335
  import classnames2 from "classnames";
4337
4336
  import React15, {
4338
4337
  useRef as useRef10,
4339
- useState as useState6
4338
+ useState as useState7
4340
4339
  } from "react";
4341
4340
 
4342
4341
  // src/layout-view/useViewActionDispatcher.ts
@@ -4440,8 +4439,10 @@ import { useForkRef as useForkRef3, useIdMemo as useId } from "@salt-ds/core";
4440
4439
  import cx8 from "classnames";
4441
4440
  import React14, {
4442
4441
  forwardRef as forwardRef5,
4442
+ useCallback as useCallback14,
4443
4443
  useMemo as useMemo4,
4444
- useRef as useRef9
4444
+ useRef as useRef9,
4445
+ useState as useState6
4445
4446
  } from "react";
4446
4447
 
4447
4448
  // src/layout-view/useView.tsx
@@ -4582,8 +4583,19 @@ var useViewContext = () => useContext2(ViewContext);
4582
4583
 
4583
4584
  // src/layout-view/View.tsx
4584
4585
  import { jsx as jsx14, jsxs as jsxs3 } from "react/jsx-runtime";
4586
+ var classBase6 = "vuuView";
4587
+ var getProps2 = (state, props) => {
4588
+ if (state && props) {
4589
+ return {
4590
+ ...state,
4591
+ ...props
4592
+ };
4593
+ } else
4594
+ return state || props;
4595
+ };
4585
4596
  var View = forwardRef5(function View2(props, forwardedRef) {
4586
4597
  const {
4598
+ Header: Header2 = Header,
4587
4599
  children,
4588
4600
  className,
4589
4601
  collapsed,
@@ -4606,6 +4618,7 @@ var View = forwardRef5(function View2(props, forwardedRef) {
4606
4618
  const id = useId(idProp);
4607
4619
  const rootRef = useRef9(null);
4608
4620
  const mainRef = useRef9(null);
4621
+ const [componentProps, _setComponentProps] = useState6();
4609
4622
  const {
4610
4623
  contributions,
4611
4624
  dispatchViewAction,
@@ -4626,10 +4639,15 @@ var View = forwardRef5(function View2(props, forwardedRef) {
4626
4639
  title: titleProp
4627
4640
  });
4628
4641
  useViewResize({ mainRef, resize, rootRef });
4629
- const classBase8 = "vuuView";
4642
+ const setComponentProps = useCallback14((props2) => {
4643
+ _setComponentProps(props2);
4644
+ }, []);
4630
4645
  const getContent = () => {
4631
- if (React14.isValidElement(children) && restoredState) {
4632
- return React14.cloneElement(children, restoredState);
4646
+ if (React14.isValidElement(children) && (restoredState || componentProps)) {
4647
+ return React14.cloneElement(
4648
+ children,
4649
+ getProps2(restoredState, componentProps)
4650
+ );
4633
4651
  }
4634
4652
  return children;
4635
4653
  };
@@ -4644,7 +4662,8 @@ var View = forwardRef5(function View2(props, forwardedRef) {
4644
4662
  onConfigChange,
4645
4663
  purge,
4646
4664
  save,
4647
- saveSession
4665
+ saveSession,
4666
+ setComponentProps
4648
4667
  }),
4649
4668
  [
4650
4669
  dispatchViewAction,
@@ -4656,6 +4675,7 @@ var View = forwardRef5(function View2(props, forwardedRef) {
4656
4675
  purge,
4657
4676
  save,
4658
4677
  saveSession,
4678
+ setComponentProps,
4659
4679
  title
4660
4680
  ]
4661
4681
  );
@@ -4664,10 +4684,10 @@ var View = forwardRef5(function View2(props, forwardedRef) {
4664
4684
  "div",
4665
4685
  {
4666
4686
  ...restProps,
4667
- className: cx8(classBase8, className, {
4668
- [`${classBase8}-collapsed`]: collapsed,
4669
- [`${classBase8}-expanded`]: expanded,
4670
- [`${classBase8}-resize-defer`]: resize === "defer"
4687
+ className: cx8(classBase6, className, {
4688
+ [`${classBase6}-collapsed`]: collapsed,
4689
+ [`${classBase6}-expanded`]: expanded,
4690
+ [`${classBase6}-resize-defer`]: resize === "defer"
4671
4691
  }),
4672
4692
  "data-resizeable": resizeable,
4673
4693
  id,
@@ -4676,7 +4696,7 @@ var View = forwardRef5(function View2(props, forwardedRef) {
4676
4696
  tabIndex: -1,
4677
4697
  children: /* @__PURE__ */ jsxs3(ViewContext.Provider, { value: viewContextValue, children: [
4678
4698
  header ? /* @__PURE__ */ jsx14(
4679
- Header,
4699
+ Header2,
4680
4700
  {
4681
4701
  ...headerProps,
4682
4702
  collapsed,
@@ -4689,7 +4709,7 @@ var View = forwardRef5(function View2(props, forwardedRef) {
4689
4709
  title
4690
4710
  }
4691
4711
  ) : null,
4692
- /* @__PURE__ */ jsx14("div", { className: `${classBase8}-main`, ref: mainRef, children: getContent() })
4712
+ /* @__PURE__ */ jsx14("div", { className: `${classBase6}-main`, ref: mainRef, children: getContent() })
4693
4713
  ] })
4694
4714
  }
4695
4715
  );
@@ -4720,11 +4740,11 @@ var Header = ({
4720
4740
  title = "Untitled"
4721
4741
  }) => {
4722
4742
  const labelFieldRef = useRef10(null);
4723
- const [value, setValue] = useState6(title);
4724
- const [editing, setEditing] = useState6(false);
4743
+ const [value, setValue] = useState7(title);
4744
+ const [editing, setEditing] = useState7(false);
4725
4745
  const viewDispatch = useViewDispatch();
4726
4746
  const handleClose = (evt) => viewDispatch == null ? void 0 : viewDispatch({ type: "remove" }, evt);
4727
- const classBase8 = "vuuHeader";
4747
+ const classBase9 = "vuuHeader";
4728
4748
  const handleTitleMouseDown = () => {
4729
4749
  var _a;
4730
4750
  (_a = labelFieldRef.current) == null ? void 0 : _a.focus();
@@ -4734,9 +4754,9 @@ var Header = ({
4734
4754
  };
4735
4755
  const orientation = collapsed || orientationProp;
4736
4756
  const className = classnames2(
4737
- classBase8,
4757
+ classBase9,
4738
4758
  classNameProp,
4739
- `${classBase8}-${orientation}`
4759
+ `${classBase9}-${orientation}`
4740
4760
  );
4741
4761
  const handleEnterEditMode = () => {
4742
4762
  setEditing(true);
@@ -4763,8 +4783,19 @@ var Header = ({
4763
4783
  viewDispatch == null ? void 0 : viewDispatch({ type: "mousedown" }, e);
4764
4784
  };
4765
4785
  const toolbarItems = [];
4766
- const contributedItems = [];
4786
+ const postTitleContributedItems = [];
4767
4787
  const actionButtons = [];
4788
+ contributions == null ? void 0 : contributions.forEach((contribution, i) => {
4789
+ switch (contribution.location) {
4790
+ case "pre-title":
4791
+ toolbarItems.push(React15.cloneElement(contribution.content, { key: i }));
4792
+ break;
4793
+ default:
4794
+ postTitleContributedItems.push(
4795
+ React15.cloneElement(contribution.content, { key: i })
4796
+ );
4797
+ }
4798
+ });
4768
4799
  title && toolbarItems.push(
4769
4800
  /* @__PURE__ */ jsx15(ToolbarField, { className: "vuuHeader-title", children: /* @__PURE__ */ jsx15(
4770
4801
  EditableLabel,
@@ -4782,9 +4813,6 @@ var Header = ({
4782
4813
  "title"
4783
4814
  ) }, "title")
4784
4815
  );
4785
- contributions == null ? void 0 : contributions.forEach((contribution, i) => {
4786
- contributedItems.push(React15.cloneElement(contribution.content, { key: i }));
4787
- });
4788
4816
  closeable && actionButtons.push(
4789
4817
  /* @__PURE__ */ jsxs4(
4790
4818
  ToolbarButton,
@@ -4799,8 +4827,8 @@ var Header = ({
4799
4827
  "close"
4800
4828
  )
4801
4829
  );
4802
- contributedItems.length > 0 && toolbarItems.push(
4803
- /* @__PURE__ */ jsx15(Tooltray, { "data-align-end": true, children: contributedItems }, "contributions")
4830
+ postTitleContributedItems.length > 0 && toolbarItems.push(
4831
+ /* @__PURE__ */ jsx15(Tooltray, { "data-align-end": true, children: postTitleContributedItems }, "contributions")
4804
4832
  );
4805
4833
  actionButtons.length > 0 && toolbarItems.push(
4806
4834
  /* @__PURE__ */ jsx15(Tooltray, { "data-align-end": true, children: actionButtons }, "actions")
@@ -4809,7 +4837,6 @@ var Header = ({
4809
4837
  Toolbar,
4810
4838
  {
4811
4839
  className,
4812
- id: "stevo",
4813
4840
  orientation: orientationProp,
4814
4841
  style,
4815
4842
  onMouseDown: handleMouseDown,
@@ -4861,7 +4888,7 @@ var Palette = ({
4861
4888
  ...props
4862
4889
  }) => {
4863
4890
  const dispatch = useLayoutProviderDispatch();
4864
- const classBase8 = "vuuPalette";
4891
+ const classBase9 = "vuuPalette";
4865
4892
  function handleMouseDown(evt) {
4866
4893
  var _a;
4867
4894
  const target = evt.target;
@@ -4908,7 +4935,7 @@ var Palette = ({
4908
4935
  {
4909
4936
  ...props,
4910
4937
  borderless: true,
4911
- className: cx9(classBase8, className, `${classBase8}-${orientation}`),
4938
+ className: cx9(classBase9, className, `${classBase9}-${orientation}`),
4912
4939
  maxHeight: 800,
4913
4940
  selected: null,
4914
4941
  children: children.map(
@@ -4927,7 +4954,7 @@ import { uuid as uuid6 } from "@vuu-ui/vuu-utils";
4927
4954
  import { List as List2, ListItem as ListItem2 } from "@heswell/salt-lab";
4928
4955
  import cx10 from "classnames";
4929
4956
  import { jsx as jsx17 } from "react/jsx-runtime";
4930
- var classBase6 = "vuuPalette";
4957
+ var classBase7 = "vuuPalette";
4931
4958
  var PaletteListItem = (props) => {
4932
4959
  const { children, ViewProps, label, onMouseDown, template, ...restProps } = props;
4933
4960
  const dispatch = useLayoutProviderDispatch();
@@ -4964,7 +4991,7 @@ var PaletteSalt = ({ className, ...props }) => {
4964
4991
  List2,
4965
4992
  {
4966
4993
  ...props,
4967
- className: cx10(classBase6, className),
4994
+ className: cx10(classBase7, className),
4968
4995
  height: "100%",
4969
4996
  selectionStrategy: "none"
4970
4997
  }
@@ -4978,10 +5005,10 @@ import { useIdMemo as useId2 } from "@salt-ds/core";
4978
5005
  import cx11 from "classnames";
4979
5006
  import React16, {
4980
5007
  forwardRef as forwardRef6,
4981
- useCallback as useCallback14
5008
+ useCallback as useCallback15
4982
5009
  } from "react";
4983
5010
  import { jsx as jsx18, jsxs as jsxs5 } from "react/jsx-runtime";
4984
- var classBase7 = "Tabs";
5011
+ var classBase8 = "Tabs";
4985
5012
  var getDefaultTabIcon = () => void 0;
4986
5013
  var getDefaultTabLabel = (component, tabIndex) => {
4987
5014
  var _a, _b;
@@ -5041,7 +5068,7 @@ var Stack = forwardRef6(function Stack2({
5041
5068
  onMouseDown == null ? void 0 : onMouseDown(e, tabIndex);
5042
5069
  }
5043
5070
  };
5044
- const handleExitEditMode = useCallback14(
5071
+ const handleExitEditMode = useCallback15(
5045
5072
  (_oldText, newText, _allowDeactivation, tabIndex) => {
5046
5073
  onTabEdit == null ? void 0 : onTabEdit(tabIndex, newText);
5047
5074
  },
@@ -5078,8 +5105,8 @@ var Stack = forwardRef6(function Stack2({
5078
5105
  return /* @__PURE__ */ jsxs5(
5079
5106
  "div",
5080
5107
  {
5081
- className: cx11(classBase7, classNameProp, {
5082
- [`${classBase7}-horizontal`]: (TabstripProps == null ? void 0 : TabstripProps.orientation) === "vertical"
5108
+ className: cx11(classBase8, classNameProp, {
5109
+ [`${classBase8}-horizontal`]: (TabstripProps == null ? void 0 : TabstripProps.orientation) === "vertical"
5083
5110
  }),
5084
5111
  style,
5085
5112
  id,
@@ -5221,12 +5248,12 @@ StackLayout.displayName = "Stack";
5221
5248
  registerComponent("Stack", StackLayout, "container");
5222
5249
 
5223
5250
  // src/tools/config-wrapper/ConfigWrapper.tsx
5224
- import React18, { useState as useState7 } from "react";
5251
+ import React18, { useState as useState8 } from "react";
5225
5252
  import { jsx as jsx20, jsxs as jsxs6 } from "react/jsx-runtime";
5226
5253
  var ConfigWrapper = ({ children }) => {
5227
5254
  const designMode = false;
5228
- const [layout, setLayout] = useState7(children);
5229
- const [selectedComponent, setSelectedComponent] = useState7(children);
5255
+ const [layout, setLayout] = useState8(children);
5256
+ const [selectedComponent, setSelectedComponent] = useState8(children);
5230
5257
  const handleSelection = (selectedPath) => {
5231
5258
  const targetComponent = followPathToComponent(layout, selectedPath);
5232
5259
  setSelectedComponent(targetComponent);
@@ -5606,10 +5633,10 @@ var LayoutTreeViewer = ({ layout, onSelect, style }) => {
5606
5633
  export {
5607
5634
  Action,
5608
5635
  BORDER_STYLES,
5609
- Chest_default as Chest,
5610
5636
  Component_default as Component,
5611
5637
  ComponentRegistry,
5612
5638
  ConfigWrapper,
5639
+ DockLayout_default as DockLayout,
5613
5640
  Draggable,
5614
5641
  DraggableLayout,
5615
5642
  Drawer_default as Drawer,