@inf-monkeys-tech/monkeys-design 0.4.32 → 0.4.33

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.
@@ -1,4 +1,4 @@
1
- import { forwardRef, useRef, useState, useEffect, useId, useMemo, createContext, useContext } from 'react';
1
+ import { forwardRef, useRef, useState, useEffect, useId, useMemo, createContext, useContext, useCallback } from 'react';
2
2
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
3
  import * as ContextMenu from '@radix-ui/react-context-menu';
4
4
 
@@ -363,7 +363,41 @@ var baseSlots = {
363
363
  tableEmptyActions: "mt-4 flex flex-wrap items-center justify-center gap-2",
364
364
  tableLoadingRow: "border-b border-border/60",
365
365
  tableLoadingCell: "px-3 py-2",
366
- tableLoadingSkeleton: "h-4 w-full rounded-md bg-muted/70"
366
+ tableLoadingSkeleton: "h-4 w-full rounded-md bg-muted/70",
367
+ layoutRoot: cn(
368
+ "grid min-w-0 overflow-hidden grid-rows-[auto_minmax(0,1fr)_auto] gap-3 rounded-lg border border-border/70 bg-background p-3 text-foreground",
369
+ motionBase
370
+ ),
371
+ layoutRootFull: "h-full min-h-0",
372
+ layoutHeader: "min-w-0",
373
+ layoutBody: "grid min-h-0 min-w-0 overflow-hidden gap-3",
374
+ layoutSidebar: "min-h-0 min-w-0 overflow-hidden",
375
+ layoutMain: "min-h-0 min-w-0 overflow-hidden",
376
+ layoutAside: "min-h-0 min-w-0 overflow-hidden",
377
+ layoutFooter: "min-w-0",
378
+ layoutPane: cn(
379
+ "h-full max-h-full min-h-0 min-w-0 overflow-hidden rounded-lg bg-background text-foreground",
380
+ motionBase
381
+ ),
382
+ layoutPaneScrollable: "overflow-auto",
383
+ layoutPaneBordered: "border border-border/70",
384
+ layoutPaneMuted: "bg-muted/25",
385
+ layoutPaneSoft: "bg-background/95 shadow-sm",
386
+ layoutPaneTransparent: "bg-transparent shadow-none",
387
+ layoutSplitRoot: "grid min-h-0 min-w-0 overflow-hidden",
388
+ layoutSplitHorizontal: "grid-flow-col",
389
+ layoutSplitVertical: "grid-flow-row",
390
+ layoutSplitPane: "min-h-0 min-w-0 overflow-hidden",
391
+ layoutSplitPrimary: "",
392
+ layoutSplitSecondary: "",
393
+ layoutResizeHandle: cn(
394
+ "group/resize relative z-10 flex shrink-0 items-center justify-center bg-transparent text-muted-foreground hover:bg-border/60 active:bg-border/70 focus-visible:bg-border/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30",
395
+ motionInteractive
396
+ ),
397
+ layoutResizeHandleHorizontal: "w-2 cursor-col-resize",
398
+ layoutResizeHandleVertical: "h-2 cursor-row-resize",
399
+ layoutResizeHandleDisabled: "cursor-default opacity-60",
400
+ layoutResizeHandleIndicator: "rounded-full bg-muted-foreground/45 group-hover/resize:bg-primary/70"
367
401
  };
368
402
  var densitySlots = {
369
403
  compact: {
@@ -437,7 +471,12 @@ var densitySlots = {
437
471
  tableCell: "px-2 py-1.5 text-xs",
438
472
  tableHeadLabel: "text-[11px]",
439
473
  tableHeadDescription: "text-[10px] leading-3",
440
- tableLoadingCell: "px-2 py-1.5"
474
+ tableLoadingCell: "px-2 py-1.5",
475
+ layoutRoot: "gap-2 p-2",
476
+ layoutBody: "gap-2",
477
+ layoutPane: "rounded-md text-xs",
478
+ layoutResizeHandleHorizontal: "w-1.5",
479
+ layoutResizeHandleVertical: "h-1.5"
441
480
  },
442
481
  default: {
443
482
  buttonBase: "h-9"
@@ -488,7 +527,12 @@ var densitySlots = {
488
527
  menuSubTrigger: "min-h-9 px-3 py-2",
489
528
  tableHead: "h-12 px-4 py-3",
490
529
  tableCell: "px-4 py-3",
491
- tableLoadingCell: "px-4 py-3"
530
+ tableLoadingCell: "px-4 py-3",
531
+ layoutRoot: "gap-4 p-4",
532
+ layoutBody: "gap-4",
533
+ layoutPane: "rounded-xl",
534
+ layoutResizeHandleHorizontal: "w-2.5",
535
+ layoutResizeHandleVertical: "h-2.5"
492
536
  }
493
537
  };
494
538
  var radiusSlots = {
@@ -532,7 +576,9 @@ var radiusSlots = {
532
576
  menuSubContent: "rounded-none",
533
577
  tableContainer: "rounded-none",
534
578
  tableEmptyIcon: "rounded-none",
535
- tableLoadingSkeleton: "rounded-none"
579
+ tableLoadingSkeleton: "rounded-none",
580
+ layoutRoot: "rounded-none",
581
+ layoutPane: "rounded-none"
536
582
  },
537
583
  sm: {
538
584
  buttonBase: "rounded-sm",
@@ -574,7 +620,9 @@ var radiusSlots = {
574
620
  menuSubContent: "rounded-sm",
575
621
  tableContainer: "rounded-sm",
576
622
  tableEmptyIcon: "rounded-sm",
577
- tableLoadingSkeleton: "rounded-sm"
623
+ tableLoadingSkeleton: "rounded-sm",
624
+ layoutRoot: "rounded-sm",
625
+ layoutPane: "rounded-sm"
578
626
  },
579
627
  md: {},
580
628
  lg: {
@@ -611,7 +659,9 @@ var radiusSlots = {
611
659
  menuSubContent: "rounded-lg",
612
660
  tableContainer: "rounded-xl",
613
661
  tableEmptyIcon: "rounded-xl",
614
- tableLoadingSkeleton: "rounded-lg"
662
+ tableLoadingSkeleton: "rounded-lg",
663
+ layoutRoot: "rounded-xl",
664
+ layoutPane: "rounded-xl"
615
665
  },
616
666
  xl: {
617
667
  buttonBase: "rounded-xl",
@@ -649,7 +699,9 @@ var radiusSlots = {
649
699
  menuSubContent: "rounded-xl",
650
700
  tableContainer: "rounded-2xl",
651
701
  tableEmptyIcon: "rounded-2xl",
652
- tableLoadingSkeleton: "rounded-xl"
702
+ tableLoadingSkeleton: "rounded-xl",
703
+ layoutRoot: "rounded-2xl",
704
+ layoutPane: "rounded-2xl"
653
705
  },
654
706
  full: {
655
707
  buttonBase: "rounded-full",
@@ -691,7 +743,9 @@ var radiusSlots = {
691
743
  menuSubContent: "rounded-2xl",
692
744
  tableContainer: "rounded-2xl",
693
745
  tableEmptyIcon: "rounded-full",
694
- tableLoadingSkeleton: "rounded-full"
746
+ tableLoadingSkeleton: "rounded-full",
747
+ layoutRoot: "rounded-2xl",
748
+ layoutPane: "rounded-2xl"
695
749
  }
696
750
  };
697
751
  var borderSlots = {
@@ -733,7 +787,10 @@ var borderSlots = {
733
787
  tableFooterBarAttached: "border-t border-transparent",
734
788
  tableRow: "border-transparent",
735
789
  tableEmptyRow: "border-transparent",
736
- tableLoadingRow: "border-transparent"
790
+ tableLoadingRow: "border-transparent",
791
+ layoutRoot: "border-transparent",
792
+ layoutPaneBordered: "border-transparent",
793
+ layoutResizeHandle: "bg-transparent hover:bg-transparent active:bg-transparent focus-visible:bg-transparent"
737
794
  },
738
795
  subtle: {
739
796
  buttonDefault: "border-border/60",
@@ -773,7 +830,9 @@ var borderSlots = {
773
830
  tableFooterBarAttached: "border-t border-border/60",
774
831
  tableRow: "border-border/50",
775
832
  tableEmptyRow: "border-border/50",
776
- tableLoadingRow: "border-border/50"
833
+ tableLoadingRow: "border-border/50",
834
+ layoutRoot: "border-border/60",
835
+ layoutPaneBordered: "border-border/60"
777
836
  },
778
837
  solid: {},
779
838
  strong: {
@@ -814,7 +873,10 @@ var borderSlots = {
814
873
  tableFooterBarAttached: "border-t border-foreground/20",
815
874
  tableRow: "border-foreground/15",
816
875
  tableEmptyRow: "border-foreground/15",
817
- tableLoadingRow: "border-foreground/15"
876
+ tableLoadingRow: "border-foreground/15",
877
+ layoutRoot: "border-foreground/20",
878
+ layoutPaneBordered: "border-foreground/20",
879
+ layoutResizeHandle: "hover:bg-foreground/15 active:bg-foreground/20 focus-visible:bg-foreground/15"
818
880
  }
819
881
  };
820
882
  var backgroundSlots = {
@@ -856,7 +918,11 @@ var backgroundSlots = {
856
918
  tableFooter: "bg-muted/35",
857
919
  tableFooterBar: "bg-muted/30 shadow-none",
858
920
  tableRowInteractive: "cursor-pointer hover:bg-muted/45",
859
- tableLoadingSkeleton: "bg-muted"
921
+ tableLoadingSkeleton: "bg-muted",
922
+ layoutRoot: "bg-card",
923
+ layoutPane: "bg-card",
924
+ layoutPaneMuted: "bg-muted/35",
925
+ layoutResizeHandle: "hover:bg-border/70 active:bg-border/80 focus-visible:bg-border/70"
860
926
  },
861
927
  soft: {
862
928
  buttonDefault: "bg-muted/30 hover:bg-muted/55",
@@ -892,7 +958,10 @@ var backgroundSlots = {
892
958
  tableFooter: "bg-muted/25",
893
959
  tableFooterBar: "bg-muted/25 shadow-none",
894
960
  tableRowInteractive: "cursor-pointer hover:bg-muted/35",
895
- tableLoadingSkeleton: "bg-muted/65"
961
+ tableLoadingSkeleton: "bg-muted/65",
962
+ layoutRoot: "bg-background/95 shadow-sm",
963
+ layoutPane: "bg-background/95 shadow-sm",
964
+ layoutPaneSoft: "bg-background/95 shadow-md"
896
965
  },
897
966
  glass: {
898
967
  buttonBase: "backdrop-blur-md",
@@ -953,7 +1022,13 @@ var backgroundSlots = {
953
1022
  tableRow: "border-white/10",
954
1023
  tableRowInteractive: "cursor-pointer hover:bg-white/[0.08]",
955
1024
  tableHeadLabel: "text-foreground",
956
- tableLoadingSkeleton: "bg-white/[0.16]"
1025
+ tableLoadingSkeleton: "bg-white/[0.16]",
1026
+ layoutRoot: "border-white/10 bg-white/[0.05] shadow-none backdrop-blur-md",
1027
+ layoutPane: "border-white/10 bg-white/[0.06] shadow-none backdrop-blur-md",
1028
+ layoutPaneMuted: "bg-white/[0.08]",
1029
+ layoutPaneSoft: "bg-white/[0.10] shadow-none backdrop-blur-md",
1030
+ layoutResizeHandle: "text-foreground/65 hover:bg-white/10 active:bg-white/15 focus-visible:bg-white/10",
1031
+ layoutResizeHandleIndicator: "bg-white/45 group-hover/resize:bg-white/75"
957
1032
  },
958
1033
  dark: {
959
1034
  buttonBase: "border-white/15 text-white shadow-lg backdrop-blur",
@@ -1082,7 +1157,13 @@ var backgroundSlots = {
1082
1157
  menuSubTrigger: "text-white focus:bg-white/[0.10] focus:text-white data-[highlighted]:bg-white/[0.10] data-[highlighted]:text-white data-[state=open]:bg-white/[0.12]",
1083
1158
  menuSubTriggerIcon: "text-white/55",
1084
1159
  menuSubContent: "border-white/10 bg-slate-950 text-white shadow-2xl",
1085
- tableLoadingSkeleton: "bg-white/[0.14]"
1160
+ tableLoadingSkeleton: "bg-white/[0.14]",
1161
+ layoutRoot: "border-white/10 bg-slate-950 text-white shadow-none",
1162
+ layoutPane: "border-white/10 bg-slate-950 text-white shadow-none",
1163
+ layoutPaneMuted: "bg-white/[0.06]",
1164
+ layoutPaneSoft: "bg-white/[0.08] shadow-none",
1165
+ layoutResizeHandle: "text-white/65 hover:bg-white/10 active:bg-white/15 focus-visible:bg-white/10",
1166
+ layoutResizeHandleIndicator: "bg-white/45 group-hover/resize:bg-white/75"
1086
1167
  }
1087
1168
  };
1088
1169
  var presetDefaults = {
@@ -2940,6 +3021,432 @@ var BaseInput = forwardRef(
2940
3021
  );
2941
3022
  }
2942
3023
  );
3024
+ var DEFAULT_SPLIT_SIZE = 50;
3025
+ var DEFAULT_MIN_SIZE = 20;
3026
+ var DEFAULT_MAX_SIZE = 80;
3027
+ var DEFAULT_KEYBOARD_STEP = 2.5;
3028
+ function toCssSize(value, fallback) {
3029
+ if (typeof value === "number") {
3030
+ if (!Number.isFinite(value) || value < 0) {
3031
+ throw new Error("BaseLayout size and gap props must be finite, non-negative numbers.");
3032
+ }
3033
+ return `${value}px`;
3034
+ }
3035
+ return value ?? fallback;
3036
+ }
3037
+ function assertPercent(name, value) {
3038
+ if (!Number.isFinite(value)) {
3039
+ throw new Error(`BaseLayoutSplit ${name} must be a finite number.`);
3040
+ }
3041
+ if (value < 0 || value > 100) {
3042
+ throw new Error(`BaseLayoutSplit ${name} must be between 0 and 100.`);
3043
+ }
3044
+ return value;
3045
+ }
3046
+ function clamp(value, min, max) {
3047
+ return Math.min(Math.max(value, min), max);
3048
+ }
3049
+ function resolveSplitBounds({
3050
+ minSize = DEFAULT_MIN_SIZE,
3051
+ maxSize = DEFAULT_MAX_SIZE,
3052
+ keyboardStep = DEFAULT_KEYBOARD_STEP
3053
+ }) {
3054
+ const min = assertPercent("minSize", minSize);
3055
+ const max = assertPercent("maxSize", maxSize);
3056
+ if (min > max) {
3057
+ throw new Error("BaseLayoutSplit minSize cannot be greater than maxSize.");
3058
+ }
3059
+ if (!Number.isFinite(keyboardStep) || keyboardStep <= 0) {
3060
+ throw new Error("BaseLayoutSplit keyboardStep must be a finite positive number.");
3061
+ }
3062
+ return { min, max, keyboardStep };
3063
+ }
3064
+ function resolveSplitSize(name, value, fallback, min, max) {
3065
+ return clamp(assertPercent(name, value ?? fallback), min, max);
3066
+ }
3067
+ function getSeparatorOrientation(orientation) {
3068
+ return orientation === "horizontal" ? "vertical" : "horizontal";
3069
+ }
3070
+ function BaseLayout({
3071
+ header,
3072
+ sidebar,
3073
+ aside,
3074
+ footer,
3075
+ children,
3076
+ sidebarSize,
3077
+ asideSize,
3078
+ gap,
3079
+ fullHeight,
3080
+ appearance,
3081
+ className,
3082
+ classNames,
3083
+ style,
3084
+ ...layoutProps
3085
+ }) {
3086
+ const theme = resolveBaseAppearance(appearance);
3087
+ const hasHeader = hasRenderableNode(header);
3088
+ const hasSidebar = hasRenderableNode(sidebar);
3089
+ const hasAside = hasRenderableNode(aside);
3090
+ const hasFooter = hasRenderableNode(footer);
3091
+ const bodyColumns = [
3092
+ hasSidebar ? "var(--base-layout-sidebar-size)" : void 0,
3093
+ "minmax(0, 1fr)",
3094
+ hasAside ? "var(--base-layout-aside-size)" : void 0
3095
+ ].filter(Boolean).join(" ");
3096
+ const layoutRows = [
3097
+ hasHeader ? "auto" : void 0,
3098
+ "minmax(0, 1fr)",
3099
+ hasFooter ? "auto" : void 0
3100
+ ].filter(Boolean).join(" ");
3101
+ const resolvedGap = gap !== void 0 ? toCssSize(gap, "0px") : void 0;
3102
+ const layoutStyle = {
3103
+ ...theme.styles.layout,
3104
+ "--base-layout-sidebar-size": toCssSize(sidebarSize, "16rem"),
3105
+ "--base-layout-aside-size": toCssSize(asideSize, "20rem"),
3106
+ gridTemplateRows: layoutRows,
3107
+ ...resolvedGap !== void 0 ? { gap: resolvedGap } : {},
3108
+ ...style
3109
+ };
3110
+ const bodyStyle = {
3111
+ ...theme.styles.layoutBody,
3112
+ gridTemplateColumns: bodyColumns,
3113
+ ...resolvedGap !== void 0 ? { gap: resolvedGap } : {}
3114
+ };
3115
+ return /* @__PURE__ */ jsxs(
3116
+ "div",
3117
+ {
3118
+ ...layoutProps,
3119
+ className: cn(
3120
+ theme.slots.layoutRoot,
3121
+ fullHeight && theme.slots.layoutRootFull,
3122
+ classNames?.root,
3123
+ className
3124
+ ),
3125
+ style: layoutStyle,
3126
+ children: [
3127
+ hasHeader ? /* @__PURE__ */ jsx(
3128
+ "div",
3129
+ {
3130
+ className: cn(theme.slots.layoutHeader, classNames?.header),
3131
+ style: theme.styles.layoutHeader,
3132
+ children: header
3133
+ }
3134
+ ) : null,
3135
+ /* @__PURE__ */ jsxs(
3136
+ "div",
3137
+ {
3138
+ className: cn(theme.slots.layoutBody, classNames?.body),
3139
+ style: bodyStyle,
3140
+ children: [
3141
+ hasSidebar ? /* @__PURE__ */ jsx(
3142
+ "aside",
3143
+ {
3144
+ className: cn(theme.slots.layoutSidebar, classNames?.sidebar),
3145
+ style: theme.styles.layoutSidebar,
3146
+ children: sidebar
3147
+ }
3148
+ ) : null,
3149
+ /* @__PURE__ */ jsx(
3150
+ "main",
3151
+ {
3152
+ className: cn(theme.slots.layoutMain, classNames?.main),
3153
+ style: theme.styles.layoutMain,
3154
+ children
3155
+ }
3156
+ ),
3157
+ hasAside ? /* @__PURE__ */ jsx(
3158
+ "aside",
3159
+ {
3160
+ className: cn(theme.slots.layoutAside, classNames?.aside),
3161
+ style: theme.styles.layoutAside,
3162
+ children: aside
3163
+ }
3164
+ ) : null
3165
+ ]
3166
+ }
3167
+ ),
3168
+ hasFooter ? /* @__PURE__ */ jsx(
3169
+ "div",
3170
+ {
3171
+ className: cn(theme.slots.layoutFooter, classNames?.footer),
3172
+ style: theme.styles.layoutFooter,
3173
+ children: footer
3174
+ }
3175
+ ) : null
3176
+ ]
3177
+ }
3178
+ );
3179
+ }
3180
+ function BaseLayoutPane({
3181
+ as = "div",
3182
+ scrollable = false,
3183
+ bordered = true,
3184
+ surface = "default",
3185
+ children,
3186
+ appearance,
3187
+ className,
3188
+ classNames,
3189
+ style,
3190
+ ...paneProps
3191
+ }) {
3192
+ const theme = resolveBaseAppearance(appearance);
3193
+ const Component = as;
3194
+ return /* @__PURE__ */ jsx(
3195
+ Component,
3196
+ {
3197
+ ...paneProps,
3198
+ className: cn(
3199
+ theme.slots.layoutPane,
3200
+ scrollable && theme.slots.layoutPaneScrollable,
3201
+ bordered && theme.slots.layoutPaneBordered,
3202
+ surface === "muted" && theme.slots.layoutPaneMuted,
3203
+ surface === "soft" && theme.slots.layoutPaneSoft,
3204
+ surface === "transparent" && theme.slots.layoutPaneTransparent,
3205
+ classNames?.root,
3206
+ className
3207
+ ),
3208
+ style: {
3209
+ ...theme.styles.layoutPane,
3210
+ ...style
3211
+ },
3212
+ children
3213
+ }
3214
+ );
3215
+ }
3216
+ function BaseLayoutResizeHandle({
3217
+ orientation = "horizontal",
3218
+ resizable = false,
3219
+ disabled = false,
3220
+ size,
3221
+ minSize,
3222
+ maxSize,
3223
+ label = "Resize panels",
3224
+ appearance,
3225
+ className,
3226
+ classNames,
3227
+ style,
3228
+ tabIndex,
3229
+ ...handleProps
3230
+ }) {
3231
+ const theme = resolveBaseAppearance(appearance);
3232
+ const interactive = resizable && !disabled;
3233
+ const separatorOrientation = getSeparatorOrientation(orientation);
3234
+ return /* @__PURE__ */ jsx(
3235
+ "div",
3236
+ {
3237
+ ...handleProps,
3238
+ role: interactive ? "separator" : void 0,
3239
+ "aria-label": interactive ? label : void 0,
3240
+ "aria-orientation": interactive ? separatorOrientation : void 0,
3241
+ "aria-valuemin": interactive ? minSize : void 0,
3242
+ "aria-valuemax": interactive ? maxSize : void 0,
3243
+ "aria-valuenow": interactive ? size : void 0,
3244
+ "aria-disabled": interactive ? void 0 : true,
3245
+ tabIndex: interactive ? tabIndex ?? 0 : void 0,
3246
+ className: cn(
3247
+ theme.slots.layoutResizeHandle,
3248
+ orientation === "horizontal" ? theme.slots.layoutResizeHandleHorizontal : theme.slots.layoutResizeHandleVertical,
3249
+ !interactive && theme.slots.layoutResizeHandleDisabled,
3250
+ classNames?.root,
3251
+ className
3252
+ ),
3253
+ style: {
3254
+ ...theme.styles.layoutResizeHandle,
3255
+ ...style
3256
+ },
3257
+ children: /* @__PURE__ */ jsx(
3258
+ "span",
3259
+ {
3260
+ "aria-hidden": "true",
3261
+ className: cn(
3262
+ theme.slots.layoutResizeHandleIndicator,
3263
+ orientation === "horizontal" ? "h-8 w-px" : "h-px w-8",
3264
+ classNames?.indicator
3265
+ )
3266
+ }
3267
+ )
3268
+ }
3269
+ );
3270
+ }
3271
+ function BaseLayoutSplit({
3272
+ orientation = "horizontal",
3273
+ primary,
3274
+ secondary,
3275
+ children,
3276
+ resizable = false,
3277
+ size,
3278
+ defaultSize,
3279
+ minSize,
3280
+ maxSize,
3281
+ gap,
3282
+ keyboardStep,
3283
+ resizeLabel,
3284
+ appearance,
3285
+ className,
3286
+ classNames,
3287
+ style,
3288
+ onSizeChange,
3289
+ ...splitProps
3290
+ }) {
3291
+ const theme = resolveBaseAppearance(appearance);
3292
+ const bounds = resolveSplitBounds({ minSize, maxSize, keyboardStep });
3293
+ const initialSize = resolveSplitSize(
3294
+ "defaultSize",
3295
+ defaultSize,
3296
+ DEFAULT_SPLIT_SIZE,
3297
+ bounds.min,
3298
+ bounds.max
3299
+ );
3300
+ const [uncontrolledSize, setUncontrolledSize] = useState(initialSize);
3301
+ const rootRef = useRef(null);
3302
+ const cleanupRef = useRef(null);
3303
+ const controlled = size !== void 0;
3304
+ const renderedSize = resolveSplitSize(
3305
+ "size",
3306
+ controlled ? size : uncontrolledSize,
3307
+ initialSize,
3308
+ bounds.min,
3309
+ bounds.max
3310
+ );
3311
+ const commitSize = useCallback(
3312
+ (nextSize) => {
3313
+ const clampedSize = clamp(nextSize, bounds.min, bounds.max);
3314
+ if (!controlled) {
3315
+ setUncontrolledSize(clampedSize);
3316
+ }
3317
+ onSizeChange?.(clampedSize);
3318
+ },
3319
+ [bounds.max, bounds.min, controlled, onSizeChange]
3320
+ );
3321
+ const updateFromPointer = useCallback(
3322
+ (event) => {
3323
+ const root = rootRef.current;
3324
+ if (!root) return;
3325
+ const rect = root.getBoundingClientRect();
3326
+ const total = orientation === "horizontal" ? rect.width : rect.height;
3327
+ if (total <= 0) return;
3328
+ const offset = orientation === "horizontal" ? event.clientX - rect.left : event.clientY - rect.top;
3329
+ commitSize(offset / total * 100);
3330
+ },
3331
+ [commitSize, orientation]
3332
+ );
3333
+ const stopResize = useCallback(() => {
3334
+ cleanupRef.current?.();
3335
+ cleanupRef.current = null;
3336
+ }, []);
3337
+ useEffect(() => stopResize, [stopResize]);
3338
+ const handlePointerDown = (event) => {
3339
+ if (!resizable) return;
3340
+ event.preventDefault();
3341
+ stopResize();
3342
+ updateFromPointer(event);
3343
+ const handleMove = (nextEvent) => {
3344
+ updateFromPointer(nextEvent);
3345
+ };
3346
+ const handleStop = () => {
3347
+ stopResize();
3348
+ };
3349
+ window.addEventListener("pointermove", handleMove);
3350
+ window.addEventListener("pointerup", handleStop, { once: true });
3351
+ window.addEventListener("pointercancel", handleStop, { once: true });
3352
+ cleanupRef.current = () => {
3353
+ window.removeEventListener("pointermove", handleMove);
3354
+ window.removeEventListener("pointerup", handleStop);
3355
+ window.removeEventListener("pointercancel", handleStop);
3356
+ };
3357
+ };
3358
+ const handleKeyDown = (event) => {
3359
+ if (!resizable) return;
3360
+ const step = event.shiftKey ? bounds.keyboardStep * 4 : bounds.keyboardStep;
3361
+ let nextSize;
3362
+ if (event.key === "Home") nextSize = bounds.min;
3363
+ if (event.key === "End") nextSize = bounds.max;
3364
+ if (orientation === "horizontal" && event.key === "ArrowLeft") {
3365
+ nextSize = renderedSize - step;
3366
+ }
3367
+ if (orientation === "horizontal" && event.key === "ArrowRight") {
3368
+ nextSize = renderedSize + step;
3369
+ }
3370
+ if (orientation === "vertical" && event.key === "ArrowUp") {
3371
+ nextSize = renderedSize - step;
3372
+ }
3373
+ if (orientation === "vertical" && event.key === "ArrowDown") {
3374
+ nextSize = renderedSize + step;
3375
+ }
3376
+ if (nextSize === void 0) return;
3377
+ event.preventDefault();
3378
+ commitSize(nextSize);
3379
+ };
3380
+ const resolvedGap = gap !== void 0 ? toCssSize(gap, "0px") : void 0;
3381
+ const resizeTrack = resolvedGap !== void 0 ? "var(--base-layout-split-gap)" : "auto";
3382
+ const resizeHandleStyle = resolvedGap !== void 0 ? orientation === "horizontal" ? { width: "var(--base-layout-split-gap)" } : { height: "var(--base-layout-split-gap)" } : void 0;
3383
+ const splitStyle = {
3384
+ ...theme.styles.layoutSplit,
3385
+ [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: resizable ? `${renderedSize}% ${resizeTrack} minmax(0, 1fr)` : `${renderedSize}% minmax(0, 1fr)`,
3386
+ ...resizable ? { gap: 0 } : {},
3387
+ ...resolvedGap !== void 0 ? {
3388
+ "--base-layout-split-gap": resolvedGap,
3389
+ ...resizable ? {} : { gap: resolvedGap }
3390
+ } : {},
3391
+ ...style
3392
+ };
3393
+ return /* @__PURE__ */ jsxs(
3394
+ "div",
3395
+ {
3396
+ ...splitProps,
3397
+ ref: rootRef,
3398
+ className: cn(
3399
+ theme.slots.layoutSplitRoot,
3400
+ orientation === "horizontal" ? theme.slots.layoutSplitHorizontal : theme.slots.layoutSplitVertical,
3401
+ classNames?.root,
3402
+ className
3403
+ ),
3404
+ style: splitStyle,
3405
+ children: [
3406
+ /* @__PURE__ */ jsx(
3407
+ "div",
3408
+ {
3409
+ className: cn(
3410
+ theme.slots.layoutSplitPane,
3411
+ theme.slots.layoutSplitPrimary,
3412
+ classNames?.primary
3413
+ ),
3414
+ style: theme.styles.layoutSplitPane,
3415
+ children: hasRenderableNode(primary) ? primary : children
3416
+ }
3417
+ ),
3418
+ resizable ? /* @__PURE__ */ jsx(
3419
+ BaseLayoutResizeHandle,
3420
+ {
3421
+ orientation,
3422
+ resizable: true,
3423
+ size: renderedSize,
3424
+ minSize: bounds.min,
3425
+ maxSize: bounds.max,
3426
+ label: resizeLabel,
3427
+ appearance,
3428
+ className: classNames?.handle,
3429
+ style: resizeHandleStyle,
3430
+ onPointerDown: handlePointerDown,
3431
+ onKeyDown: handleKeyDown
3432
+ }
3433
+ ) : null,
3434
+ /* @__PURE__ */ jsx(
3435
+ "div",
3436
+ {
3437
+ className: cn(
3438
+ theme.slots.layoutSplitPane,
3439
+ theme.slots.layoutSplitSecondary,
3440
+ classNames?.secondary
3441
+ ),
3442
+ style: theme.styles.layoutSplitPane,
3443
+ children: secondary
3444
+ }
3445
+ )
3446
+ ]
3447
+ }
3448
+ );
3449
+ }
2943
3450
  function DefaultLoadingIcon({ className }) {
2944
3451
  return /* @__PURE__ */ jsxs(
2945
3452
  "svg",
@@ -3229,7 +3736,7 @@ function BasePagination({
3229
3736
  function toFiniteNumber(value, fallback) {
3230
3737
  return Number.isFinite(value) ? Number(value) : fallback;
3231
3738
  }
3232
- function clamp(value, min, max) {
3739
+ function clamp2(value, min, max) {
3233
3740
  return Math.min(Math.max(value, min), max);
3234
3741
  }
3235
3742
  function BaseProgress({
@@ -3247,7 +3754,7 @@ function BaseProgress({
3247
3754
  }) {
3248
3755
  const theme = resolveBaseAppearance(appearance);
3249
3756
  const safeMax = Math.max(toFiniteNumber(max, 100), 1);
3250
- const safeValue = clamp(toFiniteNumber(value, 0), 0, safeMax);
3757
+ const safeValue = clamp2(toFiniteNumber(value, 0), 0, safeMax);
3251
3758
  const percent = safeValue / safeMax * 100;
3252
3759
  const renderedValue = valueFormatter?.(safeValue, safeMax) ?? `${Math.round(percent)}%`;
3253
3760
  const hasLabelRow = hasRenderableNode(label) || showValue;
@@ -4013,7 +4520,7 @@ function useBaseTableContext(appearance) {
4013
4520
  }
4014
4521
  };
4015
4522
  }
4016
- function toCssSize(value) {
4523
+ function toCssSize2(value) {
4017
4524
  if (value === void 0) return void 0;
4018
4525
  return typeof value === "number" ? `${value}px` : value;
4019
4526
  }
@@ -4226,7 +4733,7 @@ function BaseTableRow({
4226
4733
  }
4227
4734
  );
4228
4735
  }
4229
- function BaseTableHead({
4736
+ var BaseTableHead = forwardRef(function BaseTableHead2({
4230
4737
  columnId,
4231
4738
  align = "left",
4232
4739
  icon,
@@ -4254,10 +4761,18 @@ function BaseTableHead({
4254
4761
  onDragOver,
4255
4762
  onDrop,
4256
4763
  ...headProps
4257
- }) {
4764
+ }, forwardedRef) {
4258
4765
  const tableContext = useBaseTableContext(appearance);
4259
4766
  const { theme } = tableContext;
4260
4767
  const headRef = useRef(null);
4768
+ const setHeadRef = (node) => {
4769
+ headRef.current = node;
4770
+ if (typeof forwardedRef === "function") {
4771
+ forwardedRef(node);
4772
+ } else if (forwardedRef) {
4773
+ forwardedRef.current = node;
4774
+ }
4775
+ };
4261
4776
  const controlledWidth = columnId && tableContext.columnSizes?.[columnId] !== void 0 ? tableContext.columnSizes[columnId] : width;
4262
4777
  const canDrag = Boolean(
4263
4778
  columnId && draggable !== false && (draggable || tableContext.columnDragEnabled) && tableContext.columnOrder && tableContext.onColumnOrderChange
@@ -4412,7 +4927,7 @@ function BaseTableHead({
4412
4927
  "th",
4413
4928
  {
4414
4929
  ...headProps,
4415
- ref: headRef,
4930
+ ref: setHeadRef,
4416
4931
  scope: headProps.scope ?? "col",
4417
4932
  "aria-sort": ariaSort,
4418
4933
  className: cn(
@@ -4424,9 +4939,9 @@ function BaseTableHead({
4424
4939
  ),
4425
4940
  style: {
4426
4941
  ...theme.styles.tableHead,
4427
- width: toCssSize(controlledWidth),
4428
- minWidth: toCssSize(minWidth),
4429
- maxWidth: toCssSize(maxWidth),
4942
+ width: toCssSize2(controlledWidth),
4943
+ minWidth: toCssSize2(minWidth),
4944
+ maxWidth: toCssSize2(maxWidth),
4430
4945
  ...style
4431
4946
  },
4432
4947
  onDragOver: handleDragOver,
@@ -4447,7 +4962,7 @@ function BaseTableHead({
4447
4962
  ]
4448
4963
  }
4449
4964
  );
4450
- }
4965
+ });
4451
4966
  function BaseTableCell({
4452
4967
  align = "left",
4453
4968
  appearance,
@@ -4575,7 +5090,7 @@ function BaseTableLoading({
4575
5090
  classNames?.skeleton
4576
5091
  ),
4577
5092
  style: {
4578
- width: toCssSize(columnWidths[columnIndex])
5093
+ width: toCssSize2(columnWidths[columnIndex])
4579
5094
  }
4580
5095
  }
4581
5096
  )
@@ -4881,6 +5396,6 @@ function BaseToolbar({
4881
5396
  );
4882
5397
  }
4883
5398
 
4884
- export { BaseAccordion, BaseAvatar, BaseBadge, BaseBreadcrumb, BaseButton, BaseCheckbox, BaseContextMenu, BaseContextMenuCheckboxItem, BaseContextMenuContent, BaseContextMenuItem, BaseContextMenuLabel, BaseContextMenuRadioGroup, BaseContextMenuRadioItem, BaseContextMenuSeparator, BaseContextMenuSub, BaseContextMenuSubContent, BaseContextMenuSubTrigger, BaseContextMenuTrigger, BaseDescriptionList, BaseDialog, BaseDivider, BaseDropdownMenu, BaseEmptyState, BaseField, BaseInput, BaseLoadingState, BaseNotice, BasePagination, BasePanel, BaseProgress, BaseRadioGroup, BaseSectionHeader, BaseSegmentedControl, BaseSelect, BaseSkeleton, BaseSwitch, BaseTable, BaseTableBody, BaseTableCaption, BaseTableCell, BaseTableContainer, BaseTableEmpty, BaseTableFooter, BaseTableFooterBar, BaseTableHead, BaseTableHeader, BaseTableLoading, BaseTableRow, BaseTabs, BaseTextarea, BaseToolbar, BaseTooltip, cn, getBaseBadgeToneClassName, getBaseButtonToneClassName, getBaseMenuItemToneClassName, getBaseNoticeToneClassName, resolveBaseAppearance };
5399
+ export { BaseAccordion, BaseAvatar, BaseBadge, BaseBreadcrumb, BaseButton, BaseCheckbox, BaseContextMenu, BaseContextMenuCheckboxItem, BaseContextMenuContent, BaseContextMenuItem, BaseContextMenuLabel, BaseContextMenuRadioGroup, BaseContextMenuRadioItem, BaseContextMenuSeparator, BaseContextMenuSub, BaseContextMenuSubContent, BaseContextMenuSubTrigger, BaseContextMenuTrigger, BaseDescriptionList, BaseDialog, BaseDivider, BaseDropdownMenu, BaseEmptyState, BaseField, BaseInput, BaseLayout, BaseLayoutPane, BaseLayoutResizeHandle, BaseLayoutSplit, BaseLoadingState, BaseNotice, BasePagination, BasePanel, BaseProgress, BaseRadioGroup, BaseSectionHeader, BaseSegmentedControl, BaseSelect, BaseSkeleton, BaseSwitch, BaseTable, BaseTableBody, BaseTableCaption, BaseTableCell, BaseTableContainer, BaseTableEmpty, BaseTableFooter, BaseTableFooterBar, BaseTableHead, BaseTableHeader, BaseTableLoading, BaseTableRow, BaseTabs, BaseTextarea, BaseToolbar, BaseTooltip, cn, getBaseBadgeToneClassName, getBaseButtonToneClassName, getBaseMenuItemToneClassName, getBaseNoticeToneClassName, resolveBaseAppearance };
4885
5400
  //# sourceMappingURL=index.mjs.map
4886
5401
  //# sourceMappingURL=index.mjs.map