@arpproject/recrate 0.1.26 → 0.1.27

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 (2) hide show
  1. package/dist/recrate.es.js +38 -21
  2. package/package.json +1 -1
@@ -110714,6 +110714,11 @@ const findTabForProperty = (tabs, property) => tabs.find((tab) => {
110714
110714
  return (_a2 = tab == null ? void 0 : tab.inputs) == null ? void 0 : _a2.some((input) => (input == null ? void 0 : input.name) === property);
110715
110715
  }) ?? tabs.find((tab) => ["overflow", "other"].includes(String((tab == null ? void 0 : tab.name) || "").toLowerCase()));
110716
110716
  const getPendingAddedProfileStorageKey = (entityId) => `recrate.pending-added-profile-tab.${entityId}`;
110717
+ const DEFAULT_TAB_PANE_WIDTH = 240;
110718
+ const ICON_TAB_PANE_WIDTH = 80;
110719
+ const MIN_LABEL_TAB_PANE_WIDTH = 100;
110720
+ const MAX_LABEL_TAB_PANE_WIDTH = 250;
110721
+ const clampLabelTabPaneWidth = (width) => Math.max(MIN_LABEL_TAB_PANE_WIDTH, Math.min(MAX_LABEL_TAB_PANE_WIDTH, Math.round(width)));
110717
110722
  const readPendingAddedProfileTabKeys = (entityId) => {
110718
110723
  if (typeof window === "undefined") return null;
110719
110724
  try {
@@ -110748,7 +110753,7 @@ const clearPendingAddedProfileTabKeys = (entityId) => {
110748
110753
  }
110749
110754
  };
110750
110755
  const RenderEntity = forwardRef((props, ref) => {
110751
- var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k;
110756
+ var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m;
110752
110757
  const { entity, onLoadEntity, onSaveCrate, onSaveEntityTemplate, onWarning, onError, onAddNewProfileRequest, onRemoveProfile } = props;
110753
110758
  const state = useStateStore();
110754
110759
  const profileManager = useContext(ProfileManagerContext);
@@ -110768,14 +110773,15 @@ const RenderEntity = forwardRef((props, ref) => {
110768
110773
  const [hoveredTabKey, setHoveredTabKey] = useState(null);
110769
110774
  const initialTabPaneWidth = useMemo$1(() => {
110770
110775
  const raw = localStorage.getItem("recrate.verticalTabWidth");
110771
- const n2 = raw ? parseInt(raw, 10) : 240;
110772
- return Math.max(100, Math.min(250, isNaN(n2) ? 240 : n2));
110776
+ const n2 = raw ? parseInt(raw, 10) : DEFAULT_TAB_PANE_WIDTH;
110777
+ return clampLabelTabPaneWidth(isNaN(n2) ? DEFAULT_TAB_PANE_WIDTH : n2);
110773
110778
  }, []);
110774
110779
  const [tabPaneWidth, setTabPaneWidth] = useState(initialTabPaneWidth);
110780
+ const labelTabPaneWidthRef = useRef(initialTabPaneWidth);
110775
110781
  const persistTabWidth = useMemo$1(() => debounce((w2) => {
110776
- const minClamp = iconView ? 80 : 100;
110777
- const maxClamp = 250;
110778
- const clamped = Math.max(minClamp, Math.min(maxClamp, Math.round(w2)));
110782
+ if (iconView) return;
110783
+ const clamped = clampLabelTabPaneWidth(w2);
110784
+ labelTabPaneWidthRef.current = clamped;
110779
110785
  localStorage.setItem("recrate.verticalTabWidth", String(clamped));
110780
110786
  }, 200), [iconView]);
110781
110787
  const [scrollViewportHeight, setScrollViewportHeight] = useState(0);
@@ -111027,8 +111033,18 @@ const RenderEntity = forwardRef((props, ref) => {
111027
111033
  if (typeof ((_b2 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _b2.showAddPanel) === "boolean") setShowAddPanel(navState.uiState.showAddPanel);
111028
111034
  if (typeof ((_c2 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _c2.reverseSidebarVisible) === "boolean") setReverseSidebarVisible(navState.uiState.reverseSidebarVisible);
111029
111035
  if (typeof ((_d2 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _d2.highlightRequiredProperties) === "boolean") setHighlightRequiredProperties(navState.uiState.highlightRequiredProperties);
111030
- if (typeof ((_e3 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _e3.iconView) === "boolean") setIconView(navState.uiState.iconView);
111031
- if (typeof ((_f2 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _f2.tabPaneWidth) === "number") setTabPaneWidth(navState.uiState.tabPaneWidth);
111036
+ if (typeof ((_e3 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _e3.iconView) === "boolean") {
111037
+ setIconView(navState.uiState.iconView);
111038
+ }
111039
+ if (typeof ((_f2 = navState == null ? void 0 : navState.uiState) == null ? void 0 : _f2.tabPaneWidth) === "number") {
111040
+ if (navState.uiState.iconView) {
111041
+ setTabPaneWidth(ICON_TAB_PANE_WIDTH);
111042
+ } else {
111043
+ const restoredWidth = clampLabelTabPaneWidth(navState.uiState.tabPaneWidth);
111044
+ labelTabPaneWidthRef.current = restoredWidth;
111045
+ setTabPaneWidth(restoredWidth);
111046
+ }
111047
+ }
111032
111048
  if (isCurrentHistoryEntity) {
111033
111049
  if (layout.renderTabs) {
111034
111050
  state.editorState.update({ id: entity2["@id"], tab: nextActiveTab });
@@ -111441,13 +111457,14 @@ const RenderEntity = forwardRef((props, ref) => {
111441
111457
  };
111442
111458
  const toggleIconView = () => {
111443
111459
  if (!iconView) {
111460
+ labelTabPaneWidthRef.current = clampLabelTabPaneWidth(tabPaneWidth);
111444
111461
  setIconView(true);
111445
- setTabPaneWidth(80);
111446
- localStorage.setItem("recrate.verticalTabWidth", "80");
111462
+ setTabPaneWidth(ICON_TAB_PANE_WIDTH);
111447
111463
  } else {
111464
+ const restoredWidth = clampLabelTabPaneWidth(labelTabPaneWidthRef.current || DEFAULT_TAB_PANE_WIDTH);
111448
111465
  setIconView(false);
111449
- setTabPaneWidth(250);
111450
- localStorage.setItem("recrate.verticalTabWidth", "250");
111466
+ setTabPaneWidth(restoredWidth);
111467
+ localStorage.setItem("recrate.verticalTabWidth", String(restoredWidth));
111451
111468
  }
111452
111469
  };
111453
111470
  const addProfileTabLabel = /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip2, { title: t2("add_profile_button_tooltip"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -111667,7 +111684,7 @@ const RenderEntity = forwardRef((props, ref) => {
111667
111684
  setTabPaneWidth(w2);
111668
111685
  persistTabWidth(w2);
111669
111686
  }, children: [
111670
- ((_e2 = state.configuration) == null ? void 0 : _e2.tabLocation) === "left" && /* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { minSize: iconView ? 80 : 100, maxSize: iconView ? 80 : 250, preferredSize: iconView ? 80 : tabPaneWidth, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative group h-full border-r border-slate-200", children: [
111687
+ ((_e2 = state.configuration) == null ? void 0 : _e2.tabLocation) === "left" && /* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { minSize: iconView ? ICON_TAB_PANE_WIDTH : MIN_LABEL_TAB_PANE_WIDTH, maxSize: iconView ? ICON_TAB_PANE_WIDTH : MAX_LABEL_TAB_PANE_WIDTH, preferredSize: iconView ? ICON_TAB_PANE_WIDTH : tabPaneWidth, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative group h-full border-r border-slate-200", children: [
111671
111688
  renderProfileActionRail(),
111672
111689
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute right-0 top-0 bottom-0 w-1 bg-slate-300 opacity-0 group-hover:opacity-100" })
111673
111690
  ] }) }),
@@ -111728,11 +111745,11 @@ const RenderEntity = forwardRef((props, ref) => {
111728
111745
  return null;
111729
111746
  })
111730
111747
  ] }) }),
111731
- ((_g = state.configuration) == null ? void 0 : _g.tabLocation) === "right" && /* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { minSize: iconView ? 80 : 100, maxSize: iconView ? 80 : 250, preferredSize: iconView ? 80 : tabPaneWidth, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative group h-full border-l border-slate-200", children: [
111748
+ ((_g = state.configuration) == null ? void 0 : _g.tabLocation) === "right" && /* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { minSize: iconView ? ICON_TAB_PANE_WIDTH : MIN_LABEL_TAB_PANE_WIDTH, maxSize: iconView ? ICON_TAB_PANE_WIDTH : MAX_LABEL_TAB_PANE_WIDTH, preferredSize: iconView ? ICON_TAB_PANE_WIDTH : tabPaneWidth, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative group h-full border-l border-slate-200", children: [
111732
111749
  renderProfileActionRail(),
111733
111750
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-0 top-0 bottom-0 w-1 bg-slate-300 opacity-0 group-hover:opacity-100" })
111734
111751
  ] }) })
111735
- ] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: contentContainerRef, className: "flex min-h-0 overflow-hidden", style: {
111752
+ ] }, `untabbed-${(_h = state.configuration) == null ? void 0 : _h.tabLocation}-${iconView ? "icon" : "label"}`) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: contentContainerRef, className: "flex min-h-0 overflow-hidden", style: {
111736
111753
  flexDirection: "column",
111737
111754
  height: scrollViewportHeight ? `${scrollViewportHeight}px` : "calc(100vh - 200px)"
111738
111755
  }, children: [
@@ -111757,7 +111774,7 @@ const RenderEntity = forwardRef((props, ref) => {
111757
111774
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(EntityId, { entity: contextEntity, onUpdate: handleUpdateEntity })
111758
111775
  }
111759
111776
  ),
111760
- !((_h = state.configuration) == null ? void 0 : _h.readonly) && missingRequiredData && /* @__PURE__ */ jsxRuntimeExports.jsx(
111777
+ !((_i = state.configuration) == null ? void 0 : _i.readonly) && missingRequiredData && /* @__PURE__ */ jsxRuntimeExports.jsx(
111761
111778
  "button",
111762
111779
  {
111763
111780
  className: "bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded",
@@ -111812,12 +111829,12 @@ const RenderEntity = forwardRef((props, ref) => {
111812
111829
  setTabPaneWidth(w2);
111813
111830
  persistTabWidth(w2);
111814
111831
  }, children: [
111815
- /* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { minSize: iconView ? 80 : 100, maxSize: iconView ? 80 : 250, preferredSize: iconView ? 80 : tabPaneWidth, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative group h-full", children: [
111832
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { minSize: iconView ? ICON_TAB_PANE_WIDTH : MIN_LABEL_TAB_PANE_WIDTH, maxSize: iconView ? ICON_TAB_PANE_WIDTH : MAX_LABEL_TAB_PANE_WIDTH, preferredSize: iconView ? ICON_TAB_PANE_WIDTH : tabPaneWidth, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative group h-full", children: [
111816
111833
  renderProfileTabRail(),
111817
111834
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute right-0 top-0 bottom-0 w-1 bg-slate-300 opacity-0 group-hover:opacity-100" })
111818
111835
  ] }) }),
111819
111836
  /* @__PURE__ */ jsxRuntimeExports.jsx(Ve.Pane, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: activeContentRef, className: "describo-editor-scroll h-full overflow-y-auto scroll-smooth min-h-0 p-3", children: [
111820
- !((_i = state.configuration) == null ? void 0 : _i.readonly) && ((_j = tabs.find((t22) => t22.name === activeTab)) == null ? void 0 : _j.missingRequiredData) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-red-600 float-right mb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
111837
+ !((_j = state.configuration) == null ? void 0 : _j.readonly) && ((_k = tabs.find((t22) => t22.name === activeTab)) == null ? void 0 : _k.missingRequiredData) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-red-600 float-right mb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
111821
111838
  "button",
111822
111839
  {
111823
111840
  className: "bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded text-sm",
@@ -111841,7 +111858,7 @@ const RenderEntity = forwardRef((props, ref) => {
111841
111858
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(EntityName, { entity: contextEntity, onUpdate: handleUpdateEntity })
111842
111859
  }
111843
111860
  ),
111844
- (_k = tabs.find((tab) => tab.name === "about")) == null ? void 0 : _k.inputs.map((input) => {
111861
+ (_l = tabs.find((tab) => tab.name === "about")) == null ? void 0 : _l.inputs.map((input) => {
111845
111862
  if (!["@id", "@type", "name", "@reverse"].includes(input.name)) {
111846
111863
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
111847
111864
  "div",
@@ -111908,7 +111925,7 @@ const RenderEntity = forwardRef((props, ref) => {
111908
111925
  return null;
111909
111926
  })
111910
111927
  ] }) })
111911
- ] }) })
111928
+ ] }, `tabbed-${(_m = state.configuration) == null ? void 0 : _m.tabLocation}-${iconView ? "icon" : "label"}`) })
111912
111929
  ] }),
111913
111930
  /* @__PURE__ */ jsxRuntimeExports.jsx(
111914
111931
  Drawer2,
@@ -120255,7 +120272,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
120255
120272
  }) : null
120256
120273
  );
120257
120274
  var CacheProvider = EmotionCacheContext.Provider;
120258
- const version = "0.1.25";
120275
+ const version = "0.1.27";
120259
120276
  const pkg = {
120260
120277
  version
120261
120278
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arpproject/recrate",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "type": "module",
5
5
  "main": "./dist/recrate.es.js",
6
6
  "module": "./dist/recrate.es.js",