@underverse-ui/underverse 1.0.103 → 1.0.105

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,8 +1,8 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "1.0.103",
3
+ "version": "1.0.105",
4
4
  "sourceEntry": "src/index.ts",
5
- "totalExports": 225,
5
+ "totalExports": 230,
6
6
  "exports": [
7
7
  {
8
8
  "name": "*",
@@ -100,6 +100,13 @@
100
100
  "reexport": true,
101
101
  "local": false
102
102
  },
103
+ {
104
+ "name": "BottomSheetProps",
105
+ "kind": "type",
106
+ "source": "./components/Sheet",
107
+ "reexport": true,
108
+ "local": false
109
+ },
103
110
  {
104
111
  "name": "Breadcrumb",
105
112
  "kind": "value",
@@ -536,6 +543,13 @@
536
543
  "reexport": true,
537
544
  "local": false
538
545
  },
546
+ {
547
+ "name": "DrawerProps",
548
+ "kind": "type",
549
+ "source": "./components/Sheet",
550
+ "reexport": true,
551
+ "local": false
552
+ },
539
553
  {
540
554
  "name": "DropdownMenu",
541
555
  "kind": "value",
@@ -1101,6 +1115,13 @@
1101
1115
  "reexport": true,
1102
1116
  "local": false
1103
1117
  },
1118
+ {
1119
+ "name": "SheetProps",
1120
+ "kind": "type",
1121
+ "source": "./components/Sheet",
1122
+ "reexport": true,
1123
+ "local": false
1124
+ },
1104
1125
  {
1105
1126
  "name": "SidebarSheet",
1106
1127
  "kind": "value",
@@ -1108,6 +1129,13 @@
1108
1129
  "reexport": true,
1109
1130
  "local": false
1110
1131
  },
1132
+ {
1133
+ "name": "SidebarSheetProps",
1134
+ "kind": "type",
1135
+ "source": "./components/Sheet",
1136
+ "reexport": true,
1137
+ "local": false
1138
+ },
1111
1139
  {
1112
1140
  "name": "SimplePagination",
1113
1141
  "kind": "value",
@@ -1151,6 +1179,13 @@
1151
1179
  "reexport": true,
1152
1180
  "local": false
1153
1181
  },
1182
+ {
1183
+ "name": "SlideOverProps",
1184
+ "kind": "type",
1185
+ "source": "./components/Sheet",
1186
+ "reexport": true,
1187
+ "local": false
1188
+ },
1154
1189
  {
1155
1190
  "name": "Slider",
1156
1191
  "kind": "value",
package/dist/index.cjs CHANGED
@@ -6267,11 +6267,21 @@ var Sheet = ({
6267
6267
  closeOnEscape = true,
6268
6268
  header,
6269
6269
  footer,
6270
- overlayOpacity
6270
+ overlayOpacity,
6271
+ resizable = false,
6272
+ minSize = 280,
6273
+ maxSize,
6274
+ onResize
6271
6275
  }) => {
6272
6276
  const [mounted, setMounted] = React19.useState(false);
6273
6277
  const [isAnimating, setIsAnimating] = React19.useState(true);
6274
6278
  const [isVisible, setIsVisible] = React19.useState(false);
6279
+ const [isResizing, setIsResizing] = React19.useState(false);
6280
+ const [sheetSize, setSheetSize] = React19.useState(null);
6281
+ const sheetRef = React19.useRef(null);
6282
+ const resizeStateRef = React19.useRef(null);
6283
+ const isHorizontalSheet = side === "left" || side === "right";
6284
+ const canResize = resizable && size !== "full";
6275
6285
  React19.useEffect(() => {
6276
6286
  setMounted(true);
6277
6287
  }, []);
@@ -6318,6 +6328,68 @@ var Sheet = ({
6318
6328
  const handleClose = () => {
6319
6329
  onOpenChange(false);
6320
6330
  };
6331
+ const clampResizeSize = React19.useCallback((nextSize) => {
6332
+ const viewportSize = isHorizontalSheet ? window.innerWidth : window.innerHeight;
6333
+ const resolvedMaxSize = maxSize ?? Math.round(viewportSize * 0.9);
6334
+ return Math.min(Math.max(nextSize, minSize), resolvedMaxSize);
6335
+ }, [isHorizontalSheet, maxSize, minSize]);
6336
+ const endResize = React19.useCallback(() => {
6337
+ if (!resizeStateRef.current) return;
6338
+ resizeStateRef.current = null;
6339
+ setIsResizing(false);
6340
+ document.body.style.cursor = "";
6341
+ document.body.style.userSelect = "";
6342
+ }, []);
6343
+ const handleResizePointerMove = React19.useCallback((event) => {
6344
+ const resizeState = resizeStateRef.current;
6345
+ if (!resizeState || event.pointerId !== resizeState.pointerId) return;
6346
+ const delta = isHorizontalSheet ? side === "right" ? resizeState.startClientX - event.clientX : event.clientX - resizeState.startClientX : side === "bottom" ? resizeState.startClientY - event.clientY : event.clientY - resizeState.startClientY;
6347
+ const nextSize = clampResizeSize(Math.round(resizeState.startSize + delta));
6348
+ setSheetSize(nextSize);
6349
+ onResize?.(nextSize);
6350
+ }, [clampResizeSize, isHorizontalSheet, onResize, side]);
6351
+ const handleResizePointerUp = React19.useCallback((event) => {
6352
+ const resizeState = resizeStateRef.current;
6353
+ if (!resizeState || event.pointerId !== resizeState.pointerId) return;
6354
+ endResize();
6355
+ }, [endResize]);
6356
+ React19.useEffect(() => {
6357
+ if (!isResizing) return void 0;
6358
+ window.addEventListener("pointermove", handleResizePointerMove);
6359
+ window.addEventListener("pointerup", handleResizePointerUp);
6360
+ window.addEventListener("pointercancel", handleResizePointerUp);
6361
+ return () => {
6362
+ window.removeEventListener("pointermove", handleResizePointerMove);
6363
+ window.removeEventListener("pointerup", handleResizePointerUp);
6364
+ window.removeEventListener("pointercancel", handleResizePointerUp);
6365
+ };
6366
+ }, [handleResizePointerMove, handleResizePointerUp, isResizing]);
6367
+ React19.useEffect(() => {
6368
+ if (!open) endResize();
6369
+ }, [endResize, open]);
6370
+ React19.useEffect(() => endResize, [endResize]);
6371
+ const handleResizePointerDown = (event) => {
6372
+ if (!canResize || !sheetRef.current) return;
6373
+ const rect = sheetRef.current.getBoundingClientRect();
6374
+ const startSize = isHorizontalSheet ? rect.width : rect.height;
6375
+ resizeStateRef.current = {
6376
+ pointerId: event.pointerId,
6377
+ startClientX: event.clientX,
6378
+ startClientY: event.clientY,
6379
+ startSize
6380
+ };
6381
+ setIsResizing(true);
6382
+ event.currentTarget.setPointerCapture(event.pointerId);
6383
+ document.body.style.cursor = isHorizontalSheet ? "col-resize" : "row-resize";
6384
+ document.body.style.userSelect = "none";
6385
+ event.preventDefault();
6386
+ event.stopPropagation();
6387
+ };
6388
+ const sheetInlineStyle = {
6389
+ transform: open && !isAnimating ? "translate(0, 0)" : side === "right" ? "translateX(100%)" : side === "left" ? "translateX(-100%)" : side === "top" ? "translateY(-100%)" : "translateY(100%)",
6390
+ transition: "transform 300ms cubic-bezier(0.4, 0, 0.2, 1)",
6391
+ ...sheetSize !== null ? isHorizontalSheet ? { width: `${sheetSize}px` } : { height: `${sheetSize}px` } : {}
6392
+ };
6321
6393
  if (!mounted || !open && !isVisible) return null;
6322
6394
  const sheetContent = /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "fixed inset-0 z-50", children: [
6323
6395
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
@@ -6335,6 +6407,7 @@ var Sheet = ({
6335
6407
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
6336
6408
  "div",
6337
6409
  {
6410
+ ref: sheetRef,
6338
6411
  className: cn(
6339
6412
  "fixed flex flex-col bg-background text-foreground shadow-2xl",
6340
6413
  "border-border/50 transition-all duration-300 ease-out",
@@ -6349,11 +6422,28 @@ var Sheet = ({
6349
6422
  open && !isAnimating ? animationStyles[side].animate : animationStyles[side].initial,
6350
6423
  className
6351
6424
  ),
6352
- style: {
6353
- transform: open && !isAnimating ? "translate(0, 0)" : side === "right" ? "translateX(100%)" : side === "left" ? "translateX(-100%)" : side === "top" ? "translateY(-100%)" : "translateY(100%)",
6354
- transition: "transform 300ms cubic-bezier(0.4, 0, 0.2, 1)"
6355
- },
6425
+ style: sheetInlineStyle,
6356
6426
  children: [
6427
+ canResize && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
6428
+ "button",
6429
+ {
6430
+ type: "button",
6431
+ "aria-label": "Resize sheet",
6432
+ className: cn(
6433
+ "absolute z-10 bg-transparent outline-none transition-colors",
6434
+ "after:absolute after:rounded-full after:bg-border after:opacity-0 after:transition-opacity hover:after:opacity-100 focus-visible:after:opacity-100",
6435
+ isHorizontalSheet ? "top-0 h-full w-3 cursor-col-resize after:top-1/2 after:h-12 after:w-1 after:-translate-y-1/2" : "left-0 h-3 w-full cursor-row-resize after:left-1/2 after:h-1 after:w-12 after:-translate-x-1/2",
6436
+ side === "right" && "-left-1.5 after:left-1/2",
6437
+ side === "left" && "-right-1.5 after:right-1/2",
6438
+ side === "bottom" && "-top-1.5 after:top-1/2",
6439
+ side === "top" && "-bottom-1.5 after:bottom-1/2"
6440
+ ),
6441
+ onPointerDown: handleResizePointerDown,
6442
+ onPointerMove: (event) => handleResizePointerMove(event.nativeEvent),
6443
+ onPointerUp: (event) => handleResizePointerUp(event.nativeEvent),
6444
+ onPointerCancel: (event) => handleResizePointerUp(event.nativeEvent)
6445
+ }
6446
+ ),
6357
6447
  (title || description || header || showClose) && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "shrink-0 border-b border-border/50", children: header || /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex items-center justify-between p-4", children: [
6358
6448
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex-1", children: [
6359
6449
  title && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h2", { className: "text-lg font-semibold text-foreground", children: title }),
@@ -32224,6 +32314,7 @@ function useUEditorTableInteractions(editor) {
32224
32314
  const activeTableCellHighlightRef = (0, import_react53.useRef)(null);
32225
32315
  const hoveredTableCellRef = (0, import_react53.useRef)(null);
32226
32316
  const activeTableCellRef = (0, import_react53.useRef)(null);
32317
+ const suppressActiveCellHighlightRef = (0, import_react53.useRef)(false);
32227
32318
  const tableLayoutSyncFrameRef = (0, import_react53.useRef)(null);
32228
32319
  const setEditorResizeCursor = import_react53.default.useCallback((cursor) => {
32229
32320
  const proseMirror = editorContentRef.current?.querySelector(".ProseMirror");
@@ -32254,7 +32345,7 @@ function useUEditorTableInteractions(editor) {
32254
32345
  const surface = editorContentRef.current;
32255
32346
  const highlight = activeTableCellHighlightRef.current;
32256
32347
  if (!highlight) return;
32257
- if (!surface || !cell) {
32348
+ if (suppressActiveCellHighlightRef.current || !surface || !cell) {
32258
32349
  highlight.style.display = "none";
32259
32350
  return;
32260
32351
  }
@@ -32414,16 +32505,31 @@ function useUEditorTableInteractions(editor) {
32414
32505
  const row = cell.closest("tr");
32415
32506
  const table = cell.closest("table");
32416
32507
  if (!(row instanceof HTMLTableRowElement) || !(table instanceof HTMLTableElement)) return;
32417
- beginResize(event, table, row, cell);
32508
+ if (beginResize(event, table, row, cell)) {
32509
+ suppressActiveCellHighlightRef.current = true;
32510
+ updateActiveCellHighlight(null);
32511
+ }
32418
32512
  };
32419
32513
  const handlePointerMove = (event) => {
32420
32514
  handleRowResizePointerMove(event);
32421
32515
  };
32422
32516
  const handlePointerUp = (event) => {
32517
+ const wasRowResizing = isRowResizing();
32423
32518
  handleRowResizePointerUp(event);
32519
+ if (wasRowResizing) {
32520
+ suppressActiveCellHighlightRef.current = false;
32521
+ requestAnimationFrame(() => {
32522
+ updateActiveCellHighlight(activeTableCellRef.current);
32523
+ });
32524
+ }
32424
32525
  };
32425
32526
  const handleWindowBlur = () => {
32527
+ const wasRowResizing = isRowResizing();
32426
32528
  cancelResize();
32529
+ if (wasRowResizing) {
32530
+ suppressActiveCellHighlightRef.current = false;
32531
+ updateActiveCellHighlight(activeTableCellRef.current);
32532
+ }
32427
32533
  };
32428
32534
  proseMirror.addEventListener("mousemove", handleEditorMouseMove);
32429
32535
  proseMirror.addEventListener("mouseleave", handleEditorMouseLeave);
@@ -32467,6 +32573,7 @@ function useUEditorTableInteractions(editor) {
32467
32573
  tableLayoutSyncFrameRef.current = null;
32468
32574
  }
32469
32575
  cleanupRowResize();
32576
+ suppressActiveCellHighlightRef.current = false;
32470
32577
  document.body.style.cursor = "";
32471
32578
  clearActiveTableCell();
32472
32579
  clearHoveredTableCell();
@@ -32685,6 +32792,7 @@ var UEditor = import_react54.default.forwardRef(({
32685
32792
  {
32686
32793
  ref: activeTableCellHighlightRef,
32687
32794
  "aria-hidden": "true",
32795
+ "data-ueditor-active-cell-highlight": "",
32688
32796
  className: "pointer-events-none hidden absolute z-20 rounded-[2px] border-2 border-primary bg-primary/10 transition-[left,top,width,height] duration-100"
32689
32797
  }
32690
32798
  ),