@noya-app/noya-designsystem 0.1.82 → 0.1.84

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/dist/index.js CHANGED
@@ -170,17 +170,17 @@ var require_with_selector_production = __commonJS({
170
170
  }
171
171
  var objectIs = "function" === typeof Object.is ? Object.is : is;
172
172
  var useSyncExternalStore3 = shim.useSyncExternalStore;
173
- var useRef95 = React321.useRef;
173
+ var useRef94 = React321.useRef;
174
174
  var useEffect61 = React321.useEffect;
175
- var useMemo157 = React321.useMemo;
175
+ var useMemo156 = React321.useMemo;
176
176
  var useDebugValue2 = React321.useDebugValue;
177
177
  exports2.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
178
- var instRef = useRef95(null);
178
+ var instRef = useRef94(null);
179
179
  if (null === instRef.current) {
180
180
  var inst = { hasValue: false, value: null };
181
181
  instRef.current = inst;
182
182
  } else inst = instRef.current;
183
- instRef = useMemo157(
183
+ instRef = useMemo156(
184
184
  function() {
185
185
  function memoizedSelector(nextSnapshot) {
186
186
  if (!hasMemo) {
@@ -237,14 +237,14 @@ var require_with_selector_development = __commonJS({
237
237
  return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
238
238
  }
239
239
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
240
- var React321 = require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef95 = React321.useRef, useEffect61 = React321.useEffect, useMemo157 = React321.useMemo, useDebugValue2 = React321.useDebugValue;
240
+ var React321 = require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef94 = React321.useRef, useEffect61 = React321.useEffect, useMemo156 = React321.useMemo, useDebugValue2 = React321.useDebugValue;
241
241
  exports2.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
242
- var instRef = useRef95(null);
242
+ var instRef = useRef94(null);
243
243
  if (null === instRef.current) {
244
244
  var inst = { hasValue: false, value: null };
245
245
  instRef.current = inst;
246
246
  } else inst = instRef.current;
247
- instRef = useMemo157(
247
+ instRef = useMemo156(
248
248
  function() {
249
249
  function memoizedSelector(nextSnapshot) {
250
250
  if (!hasMemo) {
@@ -22255,17 +22255,19 @@ var DialogProvider = function DialogProvider2({
22255
22255
  const inputRef = (0, import_react35.useRef)(null);
22256
22256
  const confirmButtonRef = (0, import_react35.useRef)(null);
22257
22257
  const dialogRef = (0, import_react35.useRef)(null);
22258
+ const contentsType = contents?.type;
22259
+ const contentsInstance = contents?.resolve;
22258
22260
  import_react35.default.useEffect(() => {
22259
- if (!contents) return;
22261
+ if (!contentsType || !contentsInstance) return;
22260
22262
  requestAnimationFrame(() => {
22261
- if (contents.type === "input") {
22263
+ if (contentsType === "input") {
22262
22264
  inputRef.current?.focus();
22263
22265
  inputRef.current?.setSelectionRange(0, inputRef.current.value.length);
22264
- } else if (contents.type === "confirmation") {
22266
+ } else if (contentsType === "confirmation") {
22265
22267
  confirmButtonRef.current?.focus();
22266
22268
  }
22267
22269
  });
22268
- }, [contents]);
22270
+ }, [contentsType, contentsInstance]);
22269
22271
  const containsElement = (0, import_react35.useCallback)((element) => {
22270
22272
  if (!dialogRef.current) return false;
22271
22273
  return dialogRef.current.containsElement(element);
@@ -31052,6 +31054,12 @@ function applySkinTone(emoji, skinTone) {
31052
31054
 
31053
31055
  // src/components/SegmentedControl.tsx
31054
31056
  var import_react81 = __toESM(require("react"));
31057
+ var CONTAINER_PADDING_X = "n-px-0.5";
31058
+ var CONTAINER_PADDING_X_PX = 4;
31059
+ var ITEM_PADDING = "n-px-input-padding-x";
31060
+ var ITEM_PADDING_PX = 16;
31061
+ var EXPANSION_THRESHOLD_PX = 20;
31062
+ var RESIZE_SETTLE_MS = 150;
31055
31063
  var SegmentedControlContext = (0, import_react81.createContext)({
31056
31064
  colorScheme: "primary"
31057
31065
  });
@@ -31065,7 +31073,14 @@ var SegmentedControlItem = (0, import_react81.forwardRef)(function SegmentedCont
31065
31073
  variant = "default",
31066
31074
  ...props
31067
31075
  }, forwardedRef) {
31068
- const { colorScheme, onSelect, itemWidth = "auto" } = (0, import_react81.useContext)(SegmentedControlContext);
31076
+ const {
31077
+ colorScheme,
31078
+ onSelect,
31079
+ itemWidth = "auto",
31080
+ isCompact
31081
+ } = (0, import_react81.useContext)(SegmentedControlContext);
31082
+ const showTitle = !(isCompact && icon);
31083
+ const effectiveTooltip = !showTitle && !tooltip ? title : tooltip;
31069
31084
  const handlePointerDown = (0, import_react81.useCallback)(
31070
31085
  (event2) => {
31071
31086
  if (disabled2) return;
@@ -31096,7 +31111,7 @@ var SegmentedControlItem = (0, import_react81.forwardRef)(function SegmentedCont
31096
31111
  // checked
31097
31112
  variant === "tabs" ? "data-[pressed]:n-text-primary" : variant === "buttons" ? "active:n-text-button-text-active active:n-bg-button-background-active data-[pressed]:n-text-button-text-active data-[pressed]:n-bg-button-background-active" : variant === "default" ? (
31098
31113
  // default variant: only text color, background handled by sliding indicator
31099
- colorScheme === "secondary" ? "data-[pressed]:n-text-white" : colorScheme === "primary" ? "data-[pressed]:n-text-white" : "data-[pressed]:n-text-segmented-control-item-active-text"
31114
+ colorScheme === "secondary" || colorScheme === "primary" ? "data-[pressed]:n-text-white" : "data-[pressed]:n-text-segmented-control-item-active-text"
31100
31115
  ) : colorScheme === "secondary" ? "data-[pressed]:n-bg-secondary data-[pressed]:n-text-white" : colorScheme === "primary" ? "data-[pressed]:n-bg-primary data-[pressed]:n-text-white" : "data-[pressed]:n-bg-segmented-control-item-active-background data-[pressed]:n-text-segmented-control-item-active-text",
31101
31116
  "focus-visible:n-z-interactable",
31102
31117
  // checked default (all colorSchemes) - hide separators near selected
@@ -31104,10 +31119,12 @@ var SegmentedControlItem = (0, import_react81.forwardRef)(function SegmentedCont
31104
31119
  // hover
31105
31120
  variant === "buttons" && "hover:n-bg-button-background-hover",
31106
31121
  // spacing and borders
31107
- "n-px-input-padding-x",
31122
+ ITEM_PADDING,
31108
31123
  variant === "default" ? "n-rounded after:n-content-[''] after:n-absolute after:n-right-0 after:n-top-0.5 after:n-bottom-0.5 after:n-w-px after:n-bg-divider last:after:n-hidden" : variant === "buttons" ? "n-rounded-sm n-max-w-fit" : "n-border-y-2 n-border-y-transparent data-[pressed]:n-border-b-primary",
31109
- // icon only buttons
31124
+ // icon only buttons (explicit or due to compact mode)
31110
31125
  variant === "buttons" && title === "" && icon && "n-min-w-input-height",
31126
+ // icon only in compact mode
31127
+ isCompact && icon && "n-min-w-input-height",
31111
31128
  className
31112
31129
  ),
31113
31130
  ...props
@@ -31121,34 +31138,24 @@ var SegmentedControlItem = (0, import_react81.forwardRef)(function SegmentedCont
31121
31138
  )
31122
31139
  },
31123
31140
  icon && renderIcon(icon),
31124
- title
31141
+ showTitle && title
31125
31142
  )
31126
31143
  );
31127
- return tooltip ? /* @__PURE__ */ import_react81.default.createElement(Tooltip, { content: tooltip }, itemElement) : itemElement;
31144
+ return effectiveTooltip ? /* @__PURE__ */ import_react81.default.createElement(Tooltip, { content: effectiveTooltip }, itemElement) : itemElement;
31128
31145
  });
31129
- var SegmentedControl = memoGeneric(function SegmentedControl2({
31130
- id: idProp,
31131
- value,
31132
- onValueChange,
31133
- colorScheme,
31134
- allowEmpty,
31135
- items,
31136
- variant = "default",
31137
- className,
31138
- style: style2,
31139
- itemWidth = "auto"
31146
+ function useIndicatorPosition({
31147
+ containerRef,
31148
+ itemRefs,
31149
+ selectedIndex,
31150
+ variant,
31151
+ itemCount,
31152
+ isCompact
31140
31153
  }) {
31141
- const { fieldId: id } = useLabel({ fieldId: idProp });
31142
31154
  const hasInitialized = (0, import_react81.useRef)(false);
31143
- const containerRef = (0, import_react81.useRef)(null);
31144
- const itemRefs = (0, import_react81.useRef)([]);
31155
+ const isResizingRef = (0, import_react81.useRef)(false);
31156
+ const resizeTimeoutRef = (0, import_react81.useRef)(void 0);
31145
31157
  const [indicatorStyle, setIndicatorStyle] = (0, import_react81.useState)(null);
31146
- const [resizeTrigger, setResizeTrigger] = (0, import_react81.useState)(0);
31147
- const selectedIndex = (0, import_react81.useMemo)(() => {
31148
- if (!value) return -1;
31149
- return items.findIndex((item) => item.value === value);
31150
- }, [value, items]);
31151
- (0, import_react81.useLayoutEffect)(() => {
31158
+ const measureIndicator = (0, import_react81.useCallback)(() => {
31152
31159
  if (variant !== "default" || selectedIndex < 0) {
31153
31160
  setIndicatorStyle(null);
31154
31161
  return;
@@ -31166,16 +31173,134 @@ var SegmentedControl = memoGeneric(function SegmentedControl2({
31166
31173
  width: itemRect.width
31167
31174
  });
31168
31175
  hasInitialized.current = true;
31169
- }, [selectedIndex, variant, items.length, resizeTrigger]);
31176
+ }, [containerRef, itemRefs, selectedIndex, variant, itemCount, isCompact]);
31177
+ (0, import_react81.useLayoutEffect)(measureIndicator, [measureIndicator]);
31170
31178
  (0, import_react81.useLayoutEffect)(() => {
31171
31179
  const container = containerRef.current;
31172
31180
  if (!container || variant !== "default") return;
31173
31181
  const observer = new ResizeObserver(() => {
31174
- setResizeTrigger((prev) => prev + 1);
31182
+ isResizingRef.current = true;
31183
+ clearTimeout(resizeTimeoutRef.current);
31184
+ resizeTimeoutRef.current = setTimeout(() => {
31185
+ isResizingRef.current = false;
31186
+ }, RESIZE_SETTLE_MS);
31187
+ measureIndicator();
31175
31188
  });
31176
31189
  observer.observe(container);
31177
- return () => observer.disconnect();
31178
- }, [variant]);
31190
+ return () => {
31191
+ observer.disconnect();
31192
+ clearTimeout(resizeTimeoutRef.current);
31193
+ };
31194
+ }, [containerRef, variant, measureIndicator]);
31195
+ return { indicatorStyle, hasInitialized, isResizingRef };
31196
+ }
31197
+ function useCompactMode({
31198
+ containerRef,
31199
+ itemRefs,
31200
+ variant,
31201
+ items,
31202
+ enabled
31203
+ }) {
31204
+ const containerSize = useSize(containerRef, "width");
31205
+ const expandedWidthRef = (0, import_react81.useRef)(null);
31206
+ const isCompactRef = (0, import_react81.useRef)(false);
31207
+ const [isCompact, setIsCompact] = (0, import_react81.useState)(false);
31208
+ const allItemsHaveIcons = (0, import_react81.useMemo)(
31209
+ () => items.every((item) => item.icon),
31210
+ [items]
31211
+ );
31212
+ const itemsKey = (0, import_react81.useMemo)(
31213
+ () => items.map((item) => `${item.value}-${item.icon}-${item.title}`).join("|"),
31214
+ [items]
31215
+ );
31216
+ (0, import_react81.useLayoutEffect)(() => {
31217
+ expandedWidthRef.current = null;
31218
+ isCompactRef.current = false;
31219
+ setIsCompact(false);
31220
+ }, [itemsKey]);
31221
+ (0, import_react81.useLayoutEffect)(() => {
31222
+ if (!enabled) return;
31223
+ const container = containerRef.current;
31224
+ if (!container || variant !== "default" || !allItemsHaveIcons) {
31225
+ return;
31226
+ }
31227
+ const validItems = itemRefs.current.filter(Boolean);
31228
+ if (validItems.length !== items.length) return;
31229
+ const availableWidth = (containerSize?.width ?? container.clientWidth) - CONTAINER_PADDING_X_PX;
31230
+ if (!isCompactRef.current) {
31231
+ const isOverflowing = validItems.some((item) => {
31232
+ const span = item.querySelector("span");
31233
+ if (!span) return false;
31234
+ const contentWidth = span.scrollWidth;
31235
+ const availableInButton = item.clientWidth - ITEM_PADDING_PX;
31236
+ return contentWidth >= availableInButton - 1;
31237
+ });
31238
+ if (isOverflowing) {
31239
+ const totalItemsWidth = validItems.reduce((sum, item) => {
31240
+ const span = item.querySelector("span");
31241
+ const contentWidth = span ? span.scrollWidth : 0;
31242
+ return sum + contentWidth + ITEM_PADDING_PX;
31243
+ }, 0);
31244
+ expandedWidthRef.current = totalItemsWidth;
31245
+ isCompactRef.current = true;
31246
+ setIsCompact(true);
31247
+ }
31248
+ } else {
31249
+ const expandedWidth = expandedWidthRef.current;
31250
+ if (!expandedWidth) return;
31251
+ if (availableWidth >= expandedWidth + EXPANSION_THRESHOLD_PX) {
31252
+ isCompactRef.current = false;
31253
+ expandedWidthRef.current = null;
31254
+ setIsCompact(false);
31255
+ }
31256
+ }
31257
+ }, [
31258
+ enabled,
31259
+ containerRef,
31260
+ itemRefs,
31261
+ variant,
31262
+ allItemsHaveIcons,
31263
+ containerSize?.width,
31264
+ itemsKey,
31265
+ items.length
31266
+ ]);
31267
+ return isCompact;
31268
+ }
31269
+ var SegmentedControl = memoGeneric(function SegmentedControl2({
31270
+ id: idProp,
31271
+ value,
31272
+ onValueChange,
31273
+ colorScheme,
31274
+ allowEmpty,
31275
+ items,
31276
+ variant = "default",
31277
+ className,
31278
+ style: style2,
31279
+ itemWidth = "auto",
31280
+ enableCompactMode = false
31281
+ }) {
31282
+ const { fieldId: id } = useLabel({ fieldId: idProp });
31283
+ const containerRef = (0, import_react81.useRef)(null);
31284
+ const itemRefs = (0, import_react81.useRef)([]);
31285
+ const selectedIndex = (0, import_react81.useMemo)(() => {
31286
+ if (!value) return -1;
31287
+ return items.findIndex((item) => item.value === value);
31288
+ }, [value, items]);
31289
+ const isCompact = useCompactMode({
31290
+ containerRef,
31291
+ itemRefs,
31292
+ variant,
31293
+ items,
31294
+ enabled: enableCompactMode
31295
+ });
31296
+ const { indicatorStyle, hasInitialized, isResizingRef } = useIndicatorPosition({
31297
+ containerRef,
31298
+ itemRefs,
31299
+ selectedIndex,
31300
+ variant,
31301
+ itemCount: items.length,
31302
+ isCompact
31303
+ });
31179
31304
  const handleSelect = (0, import_react81.useCallback)(
31180
31305
  (newValue) => {
31181
31306
  if (!allowEmpty && !newValue) return;
@@ -31188,8 +31313,8 @@ var SegmentedControl = memoGeneric(function SegmentedControl2({
31188
31313
  [handleSelect]
31189
31314
  );
31190
31315
  const contextValue = (0, import_react81.useMemo)(
31191
- () => ({ colorScheme, onSelect: handleSelect, itemWidth }),
31192
- [colorScheme, handleSelect, itemWidth]
31316
+ () => ({ colorScheme, onSelect: handleSelect, itemWidth, isCompact }),
31317
+ [colorScheme, handleSelect, itemWidth, isCompact]
31193
31318
  );
31194
31319
  const indicatorBgClass = colorScheme === "secondary" ? "n-bg-secondary" : colorScheme === "primary" ? "n-bg-primary" : "n-bg-segmented-control-item-active-background";
31195
31320
  return /* @__PURE__ */ import_react81.default.createElement(SegmentedControlContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react81.default.createElement(
@@ -31202,7 +31327,7 @@ var SegmentedControl = memoGeneric(function SegmentedControl2({
31202
31327
  className: cx(
31203
31328
  "n-appearance-none n-relative n-outline-none",
31204
31329
  variant === "default" && (itemWidth === "fit" ? "n-flex n-w-fit" : "n-grid"),
31205
- variant === "default" && "n-min-h-input-height n-bg-input-background n-rounded n-py-0.5 n-px-0.5",
31330
+ variant === "default" && `n-min-h-input-height n-bg-input-background n-rounded n-py-0.5 ${CONTAINER_PADDING_X}`,
31206
31331
  variant !== "default" && "n-flex",
31207
31332
  variant === "tabs" && "n-gap-1.5 n-min-h-[33px]",
31208
31333
  variant === "buttons" && "n-gap-1.5 n-min-h-input-height",
@@ -31221,7 +31346,7 @@ var SegmentedControl = memoGeneric(function SegmentedControl2({
31221
31346
  className: cx(
31222
31347
  "n-absolute n-top-0.5 n-bottom-0.5 n-rounded n-shadow-segment n-pointer-events-none",
31223
31348
  indicatorBgClass,
31224
- hasInitialized.current && "n-transition-[left,width] n-duration-200 n-ease-out"
31349
+ hasInitialized.current && !isResizingRef.current && "n-transition-[left,width] n-duration-200 n-ease-out"
31225
31350
  ),
31226
31351
  style: {
31227
31352
  left: indicatorStyle.left,
@@ -41367,15 +41492,6 @@ function OverlayToolbar({
41367
41492
  }
41368
41493
 
41369
41494
  // src/components/workspace/DrawerWorkspaceLayout.tsx
41370
- var import_react114 = __toESM(require("react"));
41371
-
41372
- // src/components/workspace/constants.ts
41373
- var EDITOR_PANEL_GROUP_ID = "editor-panel-group";
41374
- var LEFT_SIDEBAR_ID = "editor-1-left-sidebar";
41375
- var RIGHT_SIDEBAR_ID = "editor-3-right-sidebar";
41376
- var CONTENT_AREA_ID = "editor-2-content-area";
41377
-
41378
- // src/components/workspace/VerticalTabMenu.tsx
41379
41495
  var import_react113 = __toESM(require("react"));
41380
41496
 
41381
41497
  // src/components/Toolbar.tsx
@@ -41688,38 +41804,11 @@ function Toolbar({
41688
41804
  );
41689
41805
  }
41690
41806
 
41691
- // src/components/workspace/VerticalTabMenu.tsx
41692
- var VerticalTabMenu = memoGeneric(function VerticalTabMenu2({
41693
- items,
41694
- activeValue,
41695
- isSidebarCollapsed,
41696
- onChange,
41697
- tooltipSide
41698
- }) {
41699
- const style2 = (0, import_react113.useMemo)(() => {
41700
- return {
41701
- [cssVarNames.colors.inputBackground]: "transparent",
41702
- [cssVarNames.colors.buttonBackground]: "transparent"
41703
- };
41704
- }, []);
41705
- return /* @__PURE__ */ import_react113.default.createElement(
41706
- "div",
41707
- {
41708
- className: "n-w-[calc(var(--n-toolbar-height)+1px)] n-h-full n-bg-sidebar-background n-flex n-flex-col n-items-center n-py-3 n-gap-3",
41709
- style: style2
41710
- },
41711
- /* @__PURE__ */ import_react113.default.createElement(
41712
- ToolbarMenu,
41713
- {
41714
- items,
41715
- activeValue: isSidebarCollapsed ? void 0 : activeValue,
41716
- onSelectMenuItem: onChange,
41717
- tooltipSide,
41718
- displayFilter: "iconOnly"
41719
- }
41720
- )
41721
- );
41722
- });
41807
+ // src/components/workspace/constants.ts
41808
+ var EDITOR_PANEL_GROUP_ID = "editor-panel-group";
41809
+ var LEFT_SIDEBAR_ID = "editor-1-left-sidebar";
41810
+ var RIGHT_SIDEBAR_ID = "editor-3-right-sidebar";
41811
+ var CONTENT_AREA_ID = "editor-2-content-area";
41723
41812
 
41724
41813
  // src/components/workspace/DrawerWorkspaceLayout.tsx
41725
41814
  var DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout2({
@@ -41733,158 +41822,130 @@ var DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout2({
41733
41822
  rightTabItems,
41734
41823
  rightTabValue,
41735
41824
  onChangeRightTab,
41736
- onChangeLeftTab,
41737
- compactDrawerMenu
41825
+ onChangeLeftTab
41738
41826
  }) {
41739
- const portalContainer = (0, import_react114.useRef)(null);
41740
- const [{ leftSidebarCollapsed, rightSidebarCollapsed }, setLayoutState] = (0, import_react114.useState)({
41827
+ const [{ leftSidebarCollapsed, rightSidebarCollapsed }, setLayoutState] = (0, import_react113.useState)({
41741
41828
  leftSidebarCollapsed: true,
41742
41829
  rightSidebarCollapsed: true
41743
41830
  });
41744
- const allTabItems = (0, import_react114.useMemo)(
41831
+ import_react113.default.useImperativeHandle(
41832
+ leftSidebarRef,
41833
+ () => ({
41834
+ expand: () => setLayoutState((prev) => ({
41835
+ ...prev,
41836
+ leftSidebarCollapsed: false,
41837
+ rightSidebarCollapsed: true
41838
+ })),
41839
+ collapse: () => setLayoutState((prev) => ({ ...prev, leftSidebarCollapsed: true })),
41840
+ isExpanded: () => !leftSidebarCollapsed
41841
+ }),
41842
+ [leftSidebarCollapsed]
41843
+ );
41844
+ import_react113.default.useImperativeHandle(
41845
+ rightSidebarRef,
41846
+ () => ({
41847
+ expand: () => setLayoutState((prev) => ({
41848
+ ...prev,
41849
+ rightSidebarCollapsed: false,
41850
+ leftSidebarCollapsed: true
41851
+ })),
41852
+ collapse: () => setLayoutState((prev) => ({ ...prev, rightSidebarCollapsed: true })),
41853
+ isExpanded: () => !rightSidebarCollapsed
41854
+ }),
41855
+ [rightSidebarCollapsed]
41856
+ );
41857
+ const allTabItems = (0, import_react113.useMemo)(
41745
41858
  () => [
41746
41859
  ...leftPanel ? leftTabItems ?? [] : [],
41747
41860
  ...rightPanel ? rightTabItems ?? [] : []
41748
41861
  ],
41749
41862
  [leftTabItems, rightTabItems, leftPanel, rightPanel]
41750
41863
  );
41751
- const hasTabs = allTabItems.length > 0;
41752
- const allSelectableTabItems = (0, import_react114.useMemo)(
41864
+ const allSelectableTabItems = (0, import_react113.useMemo)(
41753
41865
  () => allTabItems.filter(isSelectableMenuItem),
41754
41866
  [allTabItems]
41755
41867
  );
41756
- const useCompactInToolbar = !!compactDrawerMenu && allSelectableTabItems.length <= 1;
41757
- const leftSelectableTabItems = (0, import_react114.useMemo)(
41868
+ const hasTabs = allSelectableTabItems.length > 0;
41869
+ const leftSelectableTabItems = (0, import_react113.useMemo)(
41758
41870
  () => (leftTabItems ?? []).filter(isSelectableMenuItem),
41759
41871
  [leftTabItems]
41760
41872
  );
41761
- const rightSelectableTabItems = (0, import_react114.useMemo)(
41873
+ const rightSelectableTabItems = (0, import_react113.useMemo)(
41762
41874
  () => (rightTabItems ?? []).filter(isSelectableMenuItem),
41763
41875
  [rightTabItems]
41764
41876
  );
41765
- const toggleSidebar = (ref) => {
41766
- if (ref.current?.isExpanded()) {
41767
- ref.current?.collapse();
41768
- } else {
41769
- ref.current?.expand();
41770
- }
41771
- };
41772
- const ensureExpanded = (ref) => {
41773
- if (!ref.current?.isExpanded()) {
41774
- ref.current?.expand();
41775
- }
41776
- };
41777
41877
  const handleSelectTab = (value) => {
41778
- if (leftSelectableTabItems.some((item) => item.value === value)) {
41779
- if (value === leftTabValue) {
41780
- toggleSidebar(leftSidebarRef);
41878
+ const isLeftItem = leftSelectableTabItems.some(
41879
+ (item) => item.value === value
41880
+ );
41881
+ const isRightItem = rightSelectableTabItems.some(
41882
+ (item) => item.value === value
41883
+ );
41884
+ if (isLeftItem) {
41885
+ if (value === leftTabValue && !leftSidebarCollapsed) {
41886
+ setLayoutState((prev) => ({ ...prev, leftSidebarCollapsed: true }));
41781
41887
  } else {
41782
- ensureExpanded(leftSidebarRef);
41888
+ setLayoutState({
41889
+ leftSidebarCollapsed: false,
41890
+ rightSidebarCollapsed: true
41891
+ });
41783
41892
  onChangeLeftTab?.(value);
41784
41893
  }
41785
- } else if (rightSelectableTabItems.some((item) => item.value === value)) {
41786
- if (value === rightTabValue) {
41787
- toggleSidebar(rightSidebarRef);
41894
+ } else if (isRightItem) {
41895
+ if (value === rightTabValue && !rightSidebarCollapsed) {
41896
+ setLayoutState((prev) => ({ ...prev, rightSidebarCollapsed: true }));
41788
41897
  } else {
41789
- ensureExpanded(rightSidebarRef);
41898
+ setLayoutState({
41899
+ leftSidebarCollapsed: true,
41900
+ rightSidebarCollapsed: false
41901
+ });
41790
41902
  onChangeRightTab?.(value);
41791
41903
  }
41792
41904
  }
41793
41905
  };
41794
- const { activeValue, isSidebarCollapsed } = leftSelectableTabItems.length > 0 && !leftSidebarCollapsed ? { activeValue: leftTabValue, isSidebarCollapsed: leftSidebarCollapsed } : rightSelectableTabItems.length > 0 && !rightSidebarCollapsed ? {
41795
- activeValue: rightTabValue,
41796
- isSidebarCollapsed: rightSidebarCollapsed
41797
- } : { activeValue: void 0, isSidebarCollapsed: true };
41798
- return /* @__PURE__ */ import_react114.default.createElement(
41906
+ const activeDrawerPanel = !leftSidebarCollapsed ? leftPanel : !rightSidebarCollapsed ? rightPanel : null;
41907
+ const isDrawerOpen = activeDrawerPanel !== null;
41908
+ const activeTabValue = !leftSidebarCollapsed ? leftTabValue : !rightSidebarCollapsed ? rightTabValue : void 0;
41909
+ const toolbarMenuItems = (0, import_react113.useMemo)(
41910
+ () => allSelectableTabItems.map((item) => ({
41911
+ ...item,
41912
+ checked: activeTabValue === item.value
41913
+ })),
41914
+ [allSelectableTabItems, activeTabValue]
41915
+ );
41916
+ return /* @__PURE__ */ import_react113.default.createElement(
41799
41917
  "div",
41800
41918
  {
41801
- ref: portalContainer,
41802
41919
  id: EDITOR_PANEL_GROUP_ID,
41803
- className: "n-flex n-flex-1 n-relative focus:n-outline-none"
41920
+ className: "n-flex n-flex-col n-flex-1 n-relative focus:n-outline-none"
41804
41921
  },
41805
- hasTabs && !useCompactInToolbar && /* @__PURE__ */ import_react114.default.createElement(import_react114.default.Fragment, null, /* @__PURE__ */ import_react114.default.createElement(
41806
- VerticalTabMenu,
41807
- {
41808
- tooltipSide: "right",
41809
- items: allTabItems,
41810
- activeValue,
41811
- isSidebarCollapsed,
41812
- onChange: (value) => handleSelectTab(value)
41813
- }
41814
- ), /* @__PURE__ */ import_react114.default.createElement(DividerVertical, { className: "n-h-full" })),
41815
- useCompactInToolbar && /* @__PURE__ */ import_react114.default.createElement("div", { className: "n-absolute n-top-0 n-left-0 n-h-[calc(var(--n-toolbar-height)+1px)] n-w-[calc(var(--n-toolbar-height)+1px)] n-bg-sidebar-background n-border-r n-border-b n-border-divider-strong n-z-10 n-flex n-items-center n-justify-center" }, allSelectableTabItems[0] && /* @__PURE__ */ import_react114.default.createElement(
41816
- Button,
41922
+ hasTabs && /* @__PURE__ */ import_react113.default.createElement(import_react113.default.Fragment, null, /* @__PURE__ */ import_react113.default.createElement(
41923
+ "div",
41817
41924
  {
41818
- variant: "none",
41819
- className: "n-rounded",
41925
+ className: "n-flex n-flex-row n-items-center n-gap-1 n-px-2 n-py-1.5 n-bg-sidebar-background n-flex-none",
41820
41926
  style: {
41821
- width: "var(--n-input-height)",
41822
- height: "var(--n-input-height)"
41823
- },
41824
- icon: allSelectableTabItems[0].icon,
41825
- tooltip: allSelectableTabItems[0].tooltip ?? allSelectableTabItems[0].title,
41826
- active: (() => {
41827
- const value = allSelectableTabItems[0].value;
41828
- const isLeftItem = leftSelectableTabItems.some(
41829
- (i) => i.value === value
41830
- );
41831
- const isRightItem = rightSelectableTabItems.some(
41832
- (i) => i.value === value
41833
- );
41834
- return isLeftItem ? !leftSidebarCollapsed : isRightItem ? !rightSidebarCollapsed : false;
41835
- })(),
41836
- onClick: () => {
41837
- const value = allSelectableTabItems[0].value;
41838
- handleSelectTab(value);
41839
- }
41840
- }
41841
- )),
41842
- /* @__PURE__ */ import_react114.default.createElement("div", { className: "n-flex-1 n-flex n-relative" }, centerPanel),
41843
- leftPanel && /* @__PURE__ */ import_react114.default.createElement(
41844
- Drawer,
41845
- {
41846
- modal: false,
41847
- ref: leftSidebarRef,
41848
- className: "n-flex-1",
41849
- style: useCompactInToolbar ? void 0 : { left: 48, maxWidth: "calc(100% - 48px)" },
41850
- overlayStyle: useCompactInToolbar ? void 0 : { left: 48 },
41851
- open: !leftSidebarCollapsed,
41852
- positioning: "absolute",
41853
- side: "left",
41854
- trigger: null,
41855
- portalContainer: portalContainer.current,
41856
- onOpenChange: (open2) => {
41857
- setLayoutState({
41858
- leftSidebarCollapsed: !open2,
41859
- rightSidebarCollapsed
41860
- });
41927
+ [cssVarNames.colors.inputBackground]: "transparent",
41928
+ [cssVarNames.colors.buttonBackground]: "transparent"
41861
41929
  }
41862
41930
  },
41863
- leftPanel
41864
- ),
41865
- rightPanel && /* @__PURE__ */ import_react114.default.createElement(
41866
- Drawer,
41867
- {
41868
- id: RIGHT_SIDEBAR_ID,
41869
- modal: false,
41870
- ref: rightSidebarRef,
41871
- className: "n-flex-1",
41872
- style: useCompactInToolbar ? void 0 : { left: 48, maxWidth: "calc(100% - 48px)" },
41873
- overlayStyle: useCompactInToolbar ? void 0 : { left: 48 },
41874
- open: !rightSidebarCollapsed,
41875
- positioning: "absolute",
41876
- side: "left",
41877
- trigger: null,
41878
- portalContainer: portalContainer.current,
41879
- onOpenChange: (open2) => {
41880
- setLayoutState({
41881
- leftSidebarCollapsed,
41882
- rightSidebarCollapsed: !open2
41883
- });
41931
+ /* @__PURE__ */ import_react113.default.createElement(
41932
+ ToolbarMenu,
41933
+ {
41934
+ items: toolbarMenuItems,
41935
+ onSelectMenuItem: handleSelectTab
41884
41936
  }
41885
- },
41886
- rightPanel
41887
- )
41937
+ )
41938
+ ), /* @__PURE__ */ import_react113.default.createElement(Divider, null)),
41939
+ /* @__PURE__ */ import_react113.default.createElement("div", { className: "n-flex-1 n-flex n-flex-col n-relative n-min-h-0" }, isDrawerOpen && /* @__PURE__ */ import_react113.default.createElement("div", { className: "n-absolute n-inset-0 n-z-20 n-flex n-flex-col" }, /* @__PURE__ */ import_react113.default.createElement("div", { className: "n-flex-none n-max-h-[50vh] n-overflow-auto n-bg-sidebar-background n-border-b n-border-divider-strong n-shadow-lg" }, activeDrawerPanel), /* @__PURE__ */ import_react113.default.createElement(
41940
+ "div",
41941
+ {
41942
+ className: "n-flex-1 n-bg-black/30",
41943
+ onClick: () => setLayoutState({
41944
+ leftSidebarCollapsed: true,
41945
+ rightSidebarCollapsed: true
41946
+ })
41947
+ }
41948
+ )), /* @__PURE__ */ import_react113.default.createElement("div", { className: "n-flex-1 n-flex n-relative n-min-h-0" }, centerPanel))
41888
41949
  );
41889
41950
  });
41890
41951
 
@@ -41892,15 +41953,15 @@ var DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout2({
41892
41953
  var import_react119 = __toESM(require("react"));
41893
41954
 
41894
41955
  // src/components/resizablePanels/Panel.tsx
41895
- var import_react116 = __toESM(require("react"));
41956
+ var import_react115 = __toESM(require("react"));
41896
41957
 
41897
41958
  // src/components/resizablePanels/PanelGroupContext.tsx
41898
- var import_react115 = require("react");
41899
- var PanelGroupContext = (0, import_react115.createContext)(
41959
+ var import_react114 = require("react");
41960
+ var PanelGroupContext = (0, import_react114.createContext)(
41900
41961
  null
41901
41962
  );
41902
41963
  function usePanelGroupContext() {
41903
- const context = (0, import_react115.useContext)(PanelGroupContext);
41964
+ const context = (0, import_react114.useContext)(PanelGroupContext);
41904
41965
  if (!context) {
41905
41966
  throw new Error("Panel must be used within a PanelGroup");
41906
41967
  }
@@ -41908,9 +41969,19 @@ function usePanelGroupContext() {
41908
41969
  }
41909
41970
 
41910
41971
  // src/components/resizablePanels/Panel.tsx
41911
- var Panel = (0, import_react116.forwardRef)(
41912
- function Panel2({ id: propId, order, className, defaultSize, minSize, maxSize, collapsible, defaultCollapsed, children }, ref) {
41913
- const generatedId = (0, import_react116.useId)();
41972
+ var Panel = (0, import_react115.forwardRef)(
41973
+ function Panel2({
41974
+ id: propId,
41975
+ order,
41976
+ className,
41977
+ defaultSize,
41978
+ minSize,
41979
+ maxSize,
41980
+ collapsible,
41981
+ defaultCollapsed,
41982
+ children
41983
+ }, ref) {
41984
+ const generatedId = (0, import_react115.useId)();
41914
41985
  const id = propId ?? generatedId;
41915
41986
  const context = usePanelGroupContext();
41916
41987
  const {
@@ -41921,7 +41992,7 @@ var Panel = (0, import_react116.forwardRef)(
41921
41992
  collapsePanel,
41922
41993
  isPanelExpanded
41923
41994
  } = context;
41924
- (0, import_react116.useEffect)(() => {
41995
+ (0, import_react115.useEffect)(() => {
41925
41996
  registerPanel({
41926
41997
  id,
41927
41998
  order,
@@ -41934,10 +42005,20 @@ var Panel = (0, import_react116.forwardRef)(
41934
42005
  return () => {
41935
42006
  unregisterPanel(id);
41936
42007
  };
41937
- }, [id, order, defaultSize, minSize, maxSize, collapsible, defaultCollapsed, registerPanel, unregisterPanel]);
42008
+ }, [
42009
+ id,
42010
+ order,
42011
+ defaultSize,
42012
+ minSize,
42013
+ maxSize,
42014
+ collapsible,
42015
+ defaultCollapsed,
42016
+ registerPanel,
42017
+ unregisterPanel
42018
+ ]);
41938
42019
  const size4 = getPanelSize(id);
41939
42020
  const isFlexPanel = defaultSize === void 0;
41940
- (0, import_react116.useImperativeHandle)(
42021
+ (0, import_react115.useImperativeHandle)(
41941
42022
  ref,
41942
42023
  () => ({
41943
42024
  expand: () => expandPanel(id),
@@ -41950,7 +42031,7 @@ var Panel = (0, import_react116.forwardRef)(
41950
42031
  if (size4 === 0 && !isFlexPanel) {
41951
42032
  return null;
41952
42033
  }
41953
- return /* @__PURE__ */ import_react116.default.createElement(
42034
+ return /* @__PURE__ */ import_react115.default.createElement(
41954
42035
  "div",
41955
42036
  {
41956
42037
  "data-panel-id": id,
@@ -41965,7 +42046,7 @@ var Panel = (0, import_react116.forwardRef)(
41965
42046
  );
41966
42047
 
41967
42048
  // src/components/resizablePanels/PanelGroup.tsx
41968
- var import_react117 = __toESM(require("react"));
42049
+ var import_react116 = __toESM(require("react"));
41969
42050
  function getStorageKey(autoSaveId) {
41970
42051
  return `noya-panels:${autoSaveId}`;
41971
42052
  }
@@ -41983,19 +42064,19 @@ function saveSizes(autoSaveId, sizes) {
41983
42064
  if (!autoSaveId) return;
41984
42065
  clientStorage.setItem(getStorageKey(autoSaveId), JSON.stringify(sizes));
41985
42066
  }
41986
- var PanelGroup = (0, import_react117.forwardRef)(
42067
+ var PanelGroup = (0, import_react116.forwardRef)(
41987
42068
  function PanelGroup2({ id, className, direction, autoSaveId, onLayout, children }, ref) {
41988
- const containerRef = (0, import_react117.useRef)(null);
42069
+ const containerRef = (0, import_react116.useRef)(null);
41989
42070
  const containerSize = useSize(containerRef);
41990
42071
  const containerWidth = containerSize?.width ?? 0;
41991
- const [panels, setPanels] = (0, import_react117.useState)(/* @__PURE__ */ new Map());
41992
- const panelsRef = (0, import_react117.useRef)(panels);
42072
+ const [panels, setPanels] = (0, import_react116.useState)(/* @__PURE__ */ new Map());
42073
+ const panelsRef = (0, import_react116.useRef)(panels);
41993
42074
  panelsRef.current = panels;
41994
- const [resizing, setResizing] = (0, import_react117.useState)(null);
41995
- const sortedPanels = (0, import_react117.useMemo)(() => {
42075
+ const [resizing, setResizing] = (0, import_react116.useState)(null);
42076
+ const sortedPanels = (0, import_react116.useMemo)(() => {
41996
42077
  return Array.from(panels.values()).sort((a, b) => a.order - b.order);
41997
42078
  }, [panels]);
41998
- const flexPanelId = (0, import_react117.useMemo)(() => {
42079
+ const flexPanelId = (0, import_react116.useMemo)(() => {
41999
42080
  for (const panel of sortedPanels) {
42000
42081
  if (panel.defaultSize === void 0) {
42001
42082
  return panel.id;
@@ -42003,7 +42084,7 @@ var PanelGroup = (0, import_react117.forwardRef)(
42003
42084
  }
42004
42085
  return null;
42005
42086
  }, [sortedPanels]);
42006
- const calculateLayout = (0, import_react117.useCallback)(
42087
+ const calculateLayout = (0, import_react116.useCallback)(
42007
42088
  (panelStates, width) => {
42008
42089
  if (width === 0) return panelStates;
42009
42090
  const sorted = Array.from(panelStates.values()).sort(
@@ -42028,25 +42109,30 @@ var PanelGroup = (0, import_react117.forwardRef)(
42028
42109
  },
42029
42110
  []
42030
42111
  );
42031
- (0, import_react117.useEffect)(() => {
42112
+ (0, import_react116.useEffect)(() => {
42032
42113
  if (containerWidth > 0 && panels.size > 0) {
42033
42114
  setPanels((prev) => calculateLayout(prev, containerWidth));
42034
42115
  }
42035
42116
  }, [containerWidth, calculateLayout, panels.size]);
42036
- (0, import_react117.useEffect)(() => {
42117
+ (0, import_react116.useEffect)(() => {
42037
42118
  if (onLayout && sortedPanels.length > 0) {
42038
42119
  const sizes = sortedPanels.map((p) => p.collapsed ? 0 : p.size);
42039
42120
  onLayout(sizes);
42040
42121
  }
42041
42122
  }, [onLayout, sortedPanels]);
42042
- const registerPanel = (0, import_react117.useCallback)(
42123
+ const registerPanel = (0, import_react116.useCallback)(
42043
42124
  (panel) => {
42044
42125
  setPanels((prev) => {
42045
42126
  const savedSizes = loadSavedSizes(autoSaveId);
42046
42127
  const savedSize = savedSizes?.[panel.id];
42047
42128
  const hasSavedSize = savedSize !== void 0;
42048
- const collapsed = hasSavedSize ? savedSize === 0 && !!panel.collapsible : !!panel.defaultCollapsed && !!panel.collapsible;
42049
- const initialSize = hasSavedSize ? savedSize : collapsed ? 0 : panel.defaultSize ?? 0;
42129
+ let collapsed;
42130
+ if (hasSavedSize) {
42131
+ collapsed = savedSize === 0 && !!panel.collapsible;
42132
+ } else {
42133
+ collapsed = !!panel.defaultCollapsed && !!panel.collapsible;
42134
+ }
42135
+ const initialSize = collapsed ? 0 : hasSavedSize ? savedSize : panel.defaultSize ?? 0;
42050
42136
  const newPanels = new Map(prev);
42051
42137
  newPanels.set(panel.id, {
42052
42138
  ...panel,
@@ -42059,26 +42145,26 @@ var PanelGroup = (0, import_react117.forwardRef)(
42059
42145
  },
42060
42146
  [autoSaveId, calculateLayout, containerWidth]
42061
42147
  );
42062
- const unregisterPanel = (0, import_react117.useCallback)((panelId) => {
42148
+ const unregisterPanel = (0, import_react116.useCallback)((panelId) => {
42063
42149
  setPanels((prev) => {
42064
42150
  const newPanels = new Map(prev);
42065
42151
  newPanels.delete(panelId);
42066
42152
  return newPanels;
42067
42153
  });
42068
42154
  }, []);
42069
- const getPanelSize = (0, import_react117.useCallback)(
42155
+ const getPanelSize = (0, import_react116.useCallback)(
42070
42156
  (panelId) => {
42071
42157
  return panels.get(panelId)?.size ?? 0;
42072
42158
  },
42073
42159
  [panels]
42074
42160
  );
42075
- const getPanelIndex = (0, import_react117.useCallback)(
42161
+ const getPanelIndex = (0, import_react116.useCallback)(
42076
42162
  (panelId) => {
42077
42163
  return sortedPanels.findIndex((p) => p.id === panelId);
42078
42164
  },
42079
42165
  [sortedPanels]
42080
42166
  );
42081
- const setPanelSize = (0, import_react117.useCallback)(
42167
+ const setPanelSize = (0, import_react116.useCallback)(
42082
42168
  (panelId, size4) => {
42083
42169
  setPanels((prev) => {
42084
42170
  const panel = prev.get(panelId);
@@ -42106,7 +42192,7 @@ var PanelGroup = (0, import_react117.forwardRef)(
42106
42192
  },
42107
42193
  [autoSaveId, calculateLayout, containerWidth]
42108
42194
  );
42109
- const expandPanel = (0, import_react117.useCallback)(
42195
+ const expandPanel = (0, import_react116.useCallback)(
42110
42196
  (panelId) => {
42111
42197
  setPanels((prev) => {
42112
42198
  const panel = prev.get(panelId);
@@ -42131,7 +42217,7 @@ var PanelGroup = (0, import_react117.forwardRef)(
42131
42217
  },
42132
42218
  [autoSaveId, calculateLayout, containerWidth]
42133
42219
  );
42134
- const collapsePanel = (0, import_react117.useCallback)(
42220
+ const collapsePanel = (0, import_react116.useCallback)(
42135
42221
  (panelId) => {
42136
42222
  setPanels((prev) => {
42137
42223
  const panel = prev.get(panelId);
@@ -42155,14 +42241,14 @@ var PanelGroup = (0, import_react117.forwardRef)(
42155
42241
  },
42156
42242
  [autoSaveId, calculateLayout, containerWidth]
42157
42243
  );
42158
- const isPanelExpanded = (0, import_react117.useCallback)(
42244
+ const isPanelExpanded = (0, import_react116.useCallback)(
42159
42245
  (panelId) => {
42160
42246
  const panel = panels.get(panelId);
42161
42247
  return panel ? !panel.collapsed : false;
42162
42248
  },
42163
42249
  [panels]
42164
42250
  );
42165
- const startResize = (0, import_react117.useCallback)(
42251
+ const startResize = (0, import_react116.useCallback)(
42166
42252
  (handleIndex, startX) => {
42167
42253
  const startSizes = sortedPanels.map((p) => p.size);
42168
42254
  setResizing({
@@ -42173,7 +42259,7 @@ var PanelGroup = (0, import_react117.forwardRef)(
42173
42259
  },
42174
42260
  [sortedPanels]
42175
42261
  );
42176
- (0, import_react117.useEffect)(() => {
42262
+ (0, import_react116.useEffect)(() => {
42177
42263
  if (!resizing) return;
42178
42264
  const handleMouseMove = (e) => {
42179
42265
  const delta = e.clientX - resizing.startX;
@@ -42262,7 +42348,7 @@ var PanelGroup = (0, import_react117.forwardRef)(
42262
42348
  containerWidth,
42263
42349
  flexPanelId
42264
42350
  ]);
42265
- (0, import_react117.useImperativeHandle)(ref, () => ({
42351
+ (0, import_react116.useImperativeHandle)(ref, () => ({
42266
42352
  getLayout: () => sortedPanels.map((p) => p.size),
42267
42353
  setLayout: (sizes) => {
42268
42354
  setPanels((prev) => {
@@ -42280,7 +42366,7 @@ var PanelGroup = (0, import_react117.forwardRef)(
42280
42366
  });
42281
42367
  }
42282
42368
  }));
42283
- const contextValue = (0, import_react117.useMemo)(
42369
+ const contextValue = (0, import_react116.useMemo)(
42284
42370
  () => ({
42285
42371
  registerPanel,
42286
42372
  unregisterPanel,
@@ -42306,7 +42392,7 @@ var PanelGroup = (0, import_react117.forwardRef)(
42306
42392
  containerWidth
42307
42393
  ]
42308
42394
  );
42309
- return /* @__PURE__ */ import_react117.default.createElement(PanelGroupContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react117.default.createElement(
42395
+ return /* @__PURE__ */ import_react116.default.createElement(PanelGroupContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react116.default.createElement(
42310
42396
  "div",
42311
42397
  {
42312
42398
  ref: containerRef,
@@ -42324,15 +42410,15 @@ var PanelGroup = (0, import_react117.forwardRef)(
42324
42410
  );
42325
42411
 
42326
42412
  // src/components/resizablePanels/PanelResizeHandle.tsx
42327
- var import_react118 = __toESM(require("react"));
42413
+ var import_react117 = __toESM(require("react"));
42328
42414
  function PanelResizeHandle({
42329
42415
  className,
42330
42416
  disabled: disabled2,
42331
42417
  index: index2
42332
42418
  }) {
42333
- const context = (0, import_react118.useContext)(PanelGroupContext);
42334
- const handleRef = (0, import_react118.useRef)(null);
42335
- const handleMouseDown = (0, import_react118.useCallback)(
42419
+ const context = (0, import_react117.useContext)(PanelGroupContext);
42420
+ const handleRef = (0, import_react117.useRef)(null);
42421
+ const handleMouseDown = (0, import_react117.useCallback)(
42336
42422
  (e) => {
42337
42423
  if (disabled2 || !context) return;
42338
42424
  e.preventDefault();
@@ -42343,7 +42429,7 @@ function PanelResizeHandle({
42343
42429
  if (!context) {
42344
42430
  return null;
42345
42431
  }
42346
- return /* @__PURE__ */ import_react118.default.createElement(
42432
+ return /* @__PURE__ */ import_react117.default.createElement(
42347
42433
  "div",
42348
42434
  {
42349
42435
  ref: handleRef,
@@ -42356,7 +42442,7 @@ function PanelResizeHandle({
42356
42442
  zIndex: 10
42357
42443
  }
42358
42444
  },
42359
- /* @__PURE__ */ import_react118.default.createElement(
42445
+ /* @__PURE__ */ import_react117.default.createElement(
42360
42446
  "div",
42361
42447
  {
42362
42448
  style: {
@@ -42372,6 +42458,32 @@ function PanelResizeHandle({
42372
42458
  );
42373
42459
  }
42374
42460
 
42461
+ // src/components/workspace/HorizontalTabBar.tsx
42462
+ var import_react118 = __toESM(require("react"));
42463
+ var HorizontalTabBar = memoGeneric(function HorizontalTabBar2({ items, activeValue, onChange }) {
42464
+ const selectableItems = items.filter(isSelectableMenuItem);
42465
+ if (selectableItems.length <= 1) {
42466
+ return null;
42467
+ }
42468
+ return /* @__PURE__ */ import_react118.default.createElement("div", { className: "n-flex n-flex-col n-bg-sidebar-background n-flex-none" }, /* @__PURE__ */ import_react118.default.createElement("div", { className: "n-flex n-flex-row n-px-3 n-py-3" }, /* @__PURE__ */ import_react118.default.createElement(
42469
+ SegmentedControl,
42470
+ {
42471
+ enableCompactMode: true,
42472
+ className: "n-flex-1",
42473
+ value: activeValue,
42474
+ onValueChange: onChange,
42475
+ variant: "default",
42476
+ items: selectableItems.map((item) => ({
42477
+ value: item.value,
42478
+ title: item.title,
42479
+ icon: item.icon,
42480
+ tooltip: item.tooltip,
42481
+ disabled: item.disabled
42482
+ }))
42483
+ }
42484
+ )));
42485
+ });
42486
+
42375
42487
  // src/components/workspace/PanelWorkspaceLayout.tsx
42376
42488
  var PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout2({
42377
42489
  leftPanel,
@@ -42388,30 +42500,54 @@ var PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout2({
42388
42500
  rightTabValue,
42389
42501
  onChangeLeftTab,
42390
42502
  onChangeRightTab,
42391
- compactDrawerMenu
42503
+ onLeftSidebarStateChange,
42504
+ onRightSidebarStateChange,
42505
+ shouldAutoSave = true
42392
42506
  }) {
42393
42507
  const panelGroupRef = (0, import_react119.useRef)(null);
42508
+ const containerRef = (0, import_react119.useRef)(null);
42394
42509
  const autoSaveId = (0, import_react119.useMemo)(() => {
42395
- return autoSavePrefix ? `${autoSavePrefix}--v3--${EDITOR_PANEL_GROUP_ID}` : Math.random().toString(36).substring(2, 15);
42396
- }, [autoSavePrefix]);
42510
+ if (!shouldAutoSave) return void 0;
42511
+ return autoSavePrefix ? `${autoSavePrefix}--v5--${EDITOR_PANEL_GROUP_ID}` : Math.random().toString(36).substring(2, 15);
42512
+ }, [autoSavePrefix, shouldAutoSave]);
42397
42513
  const [leftSidebarCollapsed, setLeftSidebarCollapsed] = (0, import_react119.useState)(
42398
42514
  leftSidebarOptions.defaultCollapsed ?? false
42399
42515
  );
42400
42516
  const [rightSidebarCollapsed, setRightSidebarCollapsed] = (0, import_react119.useState)(
42401
42517
  rightSidebarOptions.defaultCollapsed ?? false
42402
42518
  );
42519
+ const prevLeftSidebarState = (0, import_react119.useRef)(null);
42520
+ const prevRightSidebarState = (0, import_react119.useRef)(null);
42403
42521
  const handleLayoutChange = (0, import_react119.useCallback)(
42404
42522
  (sizes) => {
42405
42523
  const leftIndex = leftPanel ? 0 : -1;
42406
42524
  const rightIndex = rightPanel ? leftPanel ? 2 : 1 : -1;
42525
+ const containerWidth = containerRef.current?.clientWidth ?? 0;
42526
+ const sizesSum = sizes.reduce((a, b) => a + b, 0);
42527
+ if (containerWidth > 0 && sizesSum < containerWidth * 0.5 && sizesSum > 100) {
42528
+ return;
42529
+ }
42530
+ const isPixels = containerWidth > 0 && Math.abs(sizesSum - containerWidth) < Math.abs(sizesSum - 100);
42407
42531
  if (leftIndex >= 0) {
42408
- setLeftSidebarCollapsed(sizes[leftIndex] === 0);
42532
+ const collapsed = sizes[leftIndex] === 0;
42533
+ setLeftSidebarCollapsed(collapsed);
42534
+ const widthPixels = isPixels ? Math.round(sizes[leftIndex]) : containerWidth > 0 ? Math.round(sizes[leftIndex] / 100 * containerWidth) : 0;
42535
+ if (prevLeftSidebarState.current?.width !== widthPixels || prevLeftSidebarState.current?.collapsed !== collapsed) {
42536
+ prevLeftSidebarState.current = { width: widthPixels, collapsed };
42537
+ onLeftSidebarStateChange?.({ width: widthPixels, collapsed });
42538
+ }
42409
42539
  }
42410
42540
  if (rightIndex >= 0) {
42411
- setRightSidebarCollapsed(sizes[rightIndex] === 0);
42541
+ const collapsed = sizes[rightIndex] === 0;
42542
+ setRightSidebarCollapsed(collapsed);
42543
+ const widthPixels = isPixels ? Math.round(sizes[rightIndex]) : containerWidth > 0 ? Math.round(sizes[rightIndex] / 100 * containerWidth) : 0;
42544
+ if (prevRightSidebarState.current?.width !== widthPixels || prevRightSidebarState.current?.collapsed !== collapsed) {
42545
+ prevRightSidebarState.current = { width: widthPixels, collapsed };
42546
+ onRightSidebarStateChange?.({ width: widthPixels, collapsed });
42547
+ }
42412
42548
  }
42413
42549
  },
42414
- [leftPanel, rightPanel]
42550
+ [leftPanel, rightPanel, onLeftSidebarStateChange, onRightSidebarStateChange]
42415
42551
  );
42416
42552
  const handleLeftTabChange = (0, import_react119.useCallback)(
42417
42553
  (value) => {
@@ -42447,10 +42583,8 @@ var PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout2({
42447
42583
  },
42448
42584
  [onChangeRightTab, rightSidebarRef, rightTabValue]
42449
42585
  );
42450
- const showLeftTabs = !!leftSidebarOptions.showTabs && !!leftTabItems && // When compact drawer UI is enabled, only show the rail when the
42451
- // sidebar is collapsed (for large screens/panel layout).
42452
- (!compactDrawerMenu || leftSidebarCollapsed);
42453
- return /* @__PURE__ */ import_react119.default.createElement(
42586
+ const showLeftTabs = !!leftSidebarOptions.showTabs && !!leftTabItems;
42587
+ return /* @__PURE__ */ import_react119.default.createElement("div", { ref: containerRef, className: "n-flex n-flex-1" }, /* @__PURE__ */ import_react119.default.createElement(
42454
42588
  PanelGroup,
42455
42589
  {
42456
42590
  ref: panelGroupRef,
@@ -42460,20 +42594,11 @@ var PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout2({
42460
42594
  autoSaveId,
42461
42595
  onLayout: handleLayoutChange
42462
42596
  },
42463
- leftPanel && /* @__PURE__ */ import_react119.default.createElement(import_react119.default.Fragment, null, showLeftTabs && /* @__PURE__ */ import_react119.default.createElement(
42464
- VerticalTabMenu,
42465
- {
42466
- tooltipSide: "right",
42467
- items: leftTabItems,
42468
- activeValue: leftTabValue,
42469
- isSidebarCollapsed: leftSidebarCollapsed,
42470
- onChange: handleLeftTabChange
42471
- }
42472
- ), showLeftTabs && !leftSidebarCollapsed && /* @__PURE__ */ import_react119.default.createElement(DividerVertical, { className: "n-h-full" }), /* @__PURE__ */ import_react119.default.createElement(
42597
+ leftPanel && /* @__PURE__ */ import_react119.default.createElement(import_react119.default.Fragment, null, /* @__PURE__ */ import_react119.default.createElement(
42473
42598
  Panel,
42474
42599
  {
42475
42600
  id: LEFT_SIDEBAR_ID,
42476
- className: "n-relative",
42601
+ className: "n-relative n-workspace-sidebar",
42477
42602
  order: 1,
42478
42603
  ref: leftSidebarRef,
42479
42604
  defaultSize: leftSidebarOptions.initialSize,
@@ -42482,8 +42607,21 @@ var PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout2({
42482
42607
  collapsible: true,
42483
42608
  defaultCollapsed: leftSidebarOptions.defaultCollapsed
42484
42609
  },
42485
- leftSidebarCollapsed ? null : leftPanel
42486
- ), /* @__PURE__ */ import_react119.default.createElement(PanelResizeHandle, { index: 0, className: "n-cursor-col-resize n-w-px n-h-full n-bg-divider" })),
42610
+ leftSidebarCollapsed ? null : /* @__PURE__ */ import_react119.default.createElement("div", { className: "n-flex n-flex-col n-h-full" }, showLeftTabs && /* @__PURE__ */ import_react119.default.createElement(
42611
+ HorizontalTabBar,
42612
+ {
42613
+ items: leftTabItems,
42614
+ activeValue: leftTabValue,
42615
+ onChange: handleLeftTabChange
42616
+ }
42617
+ ), /* @__PURE__ */ import_react119.default.createElement("div", { className: "n-flex-1 n-relative n-min-h-0" }, leftPanel))
42618
+ ), /* @__PURE__ */ import_react119.default.createElement(
42619
+ PanelResizeHandle,
42620
+ {
42621
+ index: 0,
42622
+ className: `n-cursor-col-resize n-w-px n-h-full ${leftSidebarCollapsed ? "" : "n-bg-divider"}`
42623
+ }
42624
+ )),
42487
42625
  /* @__PURE__ */ import_react119.default.createElement(
42488
42626
  Panel,
42489
42627
  {
@@ -42493,11 +42631,17 @@ var PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout2({
42493
42631
  },
42494
42632
  centerPanel
42495
42633
  ),
42496
- rightPanel && /* @__PURE__ */ import_react119.default.createElement(import_react119.default.Fragment, null, /* @__PURE__ */ import_react119.default.createElement(PanelResizeHandle, { index: 1, className: "n-cursor-col-resize n-w-px n-h-full n-bg-divider" }), /* @__PURE__ */ import_react119.default.createElement(
42634
+ rightPanel && /* @__PURE__ */ import_react119.default.createElement(import_react119.default.Fragment, null, /* @__PURE__ */ import_react119.default.createElement(
42635
+ PanelResizeHandle,
42636
+ {
42637
+ index: 1,
42638
+ className: `n-cursor-col-resize n-w-px n-h-full ${rightSidebarCollapsed ? "" : "n-bg-divider"}`
42639
+ }
42640
+ ), /* @__PURE__ */ import_react119.default.createElement(
42497
42641
  Panel,
42498
42642
  {
42499
42643
  id: RIGHT_SIDEBAR_ID,
42500
- className: "n-relative",
42644
+ className: "n-relative n-workspace-sidebar",
42501
42645
  order: 3,
42502
42646
  ref: rightSidebarRef,
42503
42647
  minSize: rightSidebarOptions.minSize,
@@ -42506,18 +42650,16 @@ var PanelWorkspaceLayout = memoGeneric(function PanelWorkspaceLayout2({
42506
42650
  collapsible: true,
42507
42651
  defaultCollapsed: rightSidebarOptions.defaultCollapsed
42508
42652
  },
42509
- rightSidebarCollapsed ? null : rightPanel
42510
- ), rightSidebarOptions.showTabs && rightTabItems && !rightSidebarCollapsed && /* @__PURE__ */ import_react119.default.createElement(DividerVertical, { className: "n-h-full" }), rightSidebarOptions.showTabs && rightTabItems && /* @__PURE__ */ import_react119.default.createElement(
42511
- VerticalTabMenu,
42512
- {
42513
- tooltipSide: "left",
42514
- items: rightTabItems,
42515
- activeValue: rightTabValue,
42516
- isSidebarCollapsed: rightSidebarCollapsed,
42517
- onChange: handleRightTabChange
42518
- }
42653
+ rightSidebarCollapsed ? null : /* @__PURE__ */ import_react119.default.createElement("div", { className: "n-flex n-flex-col n-h-full" }, rightSidebarOptions.showTabs && rightTabItems && /* @__PURE__ */ import_react119.default.createElement(
42654
+ HorizontalTabBar,
42655
+ {
42656
+ items: rightTabItems,
42657
+ activeValue: rightTabValue,
42658
+ onChange: handleRightTabChange
42659
+ }
42660
+ ), /* @__PURE__ */ import_react119.default.createElement("div", { className: "n-flex-1 n-relative n-min-h-0" }, rightPanel))
42519
42661
  ))
42520
- );
42662
+ ));
42521
42663
  });
42522
42664
 
42523
42665
  // src/components/workspace/renderPanelChildren.tsx
@@ -42598,7 +42740,9 @@ var WorkspaceLayout = forwardRefGeneric(function WorkspaceLayout2({
42598
42740
  showTabs: rightShowTabs = true
42599
42741
  } = {},
42600
42742
  theme,
42601
- compactDrawerMenu
42743
+ onLeftSidebarStateChange,
42744
+ onRightSidebarStateChange,
42745
+ shouldAutoSave
42602
42746
  }, forwardedRef) {
42603
42747
  const containerRef = import_react121.default.useRef(null);
42604
42748
  const containerSize = useSize(containerRef);
@@ -42803,7 +42947,9 @@ var WorkspaceLayout = forwardRefGeneric(function WorkspaceLayout2({
42803
42947
  autoSavePrefix,
42804
42948
  leftSidebarRef,
42805
42949
  rightSidebarRef,
42806
- compactDrawerMenu
42950
+ onLeftSidebarStateChange,
42951
+ onRightSidebarStateChange,
42952
+ shouldAutoSave
42807
42953
  }
42808
42954
  ), isOverlay && /* @__PURE__ */ import_react121.default.createElement(
42809
42955
  OverlayToolbar,