@kubuild/editor 0.1.2 → 0.1.3

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
@@ -3156,15 +3156,18 @@ var TableSpreadsheetEditor = ({
3156
3156
  setIsImportModalOpen(false);
3157
3157
  setCsvInputText("");
3158
3158
  };
3159
- const [pos, setPos] = useState6({ x: 260, y: 120 });
3159
+ const [pos, setPos] = useState6(() => ({
3160
+ x: typeof window !== "undefined" ? Math.max(10, Math.min(window.innerWidth - 400, 20)) : 20,
3161
+ y: 120
3162
+ }));
3160
3163
  const [isDragging, setIsDragging] = useState6(false);
3161
3164
  const dragStartRef = useRef4({
3162
3165
  startX: 0,
3163
3166
  startY: 0,
3164
- posX: 260,
3167
+ posX: 20,
3165
3168
  posY: 120
3166
3169
  });
3167
- const handleHeaderMouseDown = (e) => {
3170
+ const handleHeaderPointerDown = (e) => {
3168
3171
  if (e.target.closest("button, input, select, textarea")) return;
3169
3172
  setIsDragging(true);
3170
3173
  dragStartRef.current = {
@@ -3176,22 +3179,26 @@ var TableSpreadsheetEditor = ({
3176
3179
  };
3177
3180
  useEffect2(() => {
3178
3181
  if (!isDragging) return;
3179
- const handleMouseMove = (e) => {
3182
+ const handlePointerMove = (e) => {
3180
3183
  const dx = e.clientX - dragStartRef.current.startX;
3181
3184
  const dy = e.clientY - dragStartRef.current.startY;
3185
+ const maxX = Math.max(8, window.innerWidth - 320);
3186
+ const maxY = Math.max(8, window.innerHeight - 100);
3182
3187
  setPos({
3183
- x: Math.max(10, Math.min(window.innerWidth - 350, dragStartRef.current.posX + dx)),
3184
- y: Math.max(10, Math.min(window.innerHeight - 150, dragStartRef.current.posY + dy))
3188
+ x: Math.max(8, Math.min(maxX, dragStartRef.current.posX + dx)),
3189
+ y: Math.max(8, Math.min(maxY, dragStartRef.current.posY + dy))
3185
3190
  });
3186
3191
  };
3187
- const handleMouseUp = () => {
3192
+ const handlePointerUp = () => {
3188
3193
  setIsDragging(false);
3189
3194
  };
3190
- window.addEventListener("mousemove", handleMouseMove);
3191
- window.addEventListener("mouseup", handleMouseUp);
3195
+ window.addEventListener("pointermove", handlePointerMove);
3196
+ window.addEventListener("pointerup", handlePointerUp);
3197
+ window.addEventListener("pointercancel", handlePointerUp);
3192
3198
  return () => {
3193
- window.removeEventListener("mousemove", handleMouseMove);
3194
- window.removeEventListener("mouseup", handleMouseUp);
3199
+ window.removeEventListener("pointermove", handlePointerMove);
3200
+ window.removeEventListener("pointerup", handlePointerUp);
3201
+ window.removeEventListener("pointercancel", handlePointerUp);
3195
3202
  };
3196
3203
  }, [isDragging]);
3197
3204
  if (!tableNode) return null;
@@ -3745,9 +3752,9 @@ var TableSpreadsheetEditor = ({
3745
3752
  /* @__PURE__ */ jsx10(
3746
3753
  "div",
3747
3754
  {
3748
- style: { left: `${pos.x}px`, top: `${pos.y}px` },
3749
- onMouseDown: handleHeaderMouseDown,
3750
- className: `fixed z-40 min-w-[380px] max-w-[620px] bg-white/95 backdrop-blur-md rounded-xl shadow-2xl border border-slate-300 flex flex-col max-h-[460px] overflow-hidden ${className}`,
3755
+ style: { left: `${pos.x}px`, top: `${pos.y}px`, touchAction: "none" },
3756
+ onPointerDown: handleHeaderPointerDown,
3757
+ className: `fixed z-40 min-w-[320px] sm:min-w-[380px] max-w-[620px] bg-white/95 backdrop-blur-md rounded-xl shadow-2xl border border-slate-300 flex flex-col max-h-[460px] overflow-hidden cursor-grab active:cursor-grabbing touch-none ${className}`,
3751
3758
  children: content
3752
3759
  }
3753
3760
  )
@@ -6812,16 +6819,19 @@ var LayersPanel = ({ registry, className }) => {
6812
6819
  const [expandedIds, setExpandedIds] = useState13(() => /* @__PURE__ */ new Set([document2.document.id]));
6813
6820
  const [draggingId, setDraggingId] = useState13(null);
6814
6821
  const [dropCandidate, setDropCandidate] = useState13(null);
6815
- const [pos, setPos] = useState13({ x: 280, y: 70 });
6822
+ const [pos, setPos] = useState13(() => ({
6823
+ x: typeof window !== "undefined" ? Math.max(12, Math.min(window.innerWidth - 300, 24)) : 24,
6824
+ y: 70
6825
+ }));
6816
6826
  const [isDraggingWindow, setIsDraggingWindow] = useState13(false);
6817
6827
  const dragStartRef = useRef9({
6818
6828
  startX: 0,
6819
6829
  startY: 0,
6820
- posX: 280,
6830
+ posX: 24,
6821
6831
  posY: 70
6822
6832
  });
6823
- const handleHeaderMouseDown = (e) => {
6824
- if (e.target.closest("button")) return;
6833
+ const handleHeaderPointerDown = (e) => {
6834
+ if (e.target.closest("button, input, select, textarea")) return;
6825
6835
  setIsDraggingWindow(true);
6826
6836
  dragStartRef.current = {
6827
6837
  startX: e.clientX,
@@ -6832,22 +6842,26 @@ var LayersPanel = ({ registry, className }) => {
6832
6842
  };
6833
6843
  useEffect9(() => {
6834
6844
  if (!isDraggingWindow) return;
6835
- const handleMouseMove = (e) => {
6845
+ const handlePointerMove = (e) => {
6836
6846
  const dx = e.clientX - dragStartRef.current.startX;
6837
6847
  const dy = e.clientY - dragStartRef.current.startY;
6848
+ const maxX = Math.max(8, window.innerWidth - 296);
6849
+ const maxY = Math.max(8, window.innerHeight - 100);
6838
6850
  setPos({
6839
- x: Math.max(10, Math.min(window.innerWidth - 280, dragStartRef.current.posX + dx)),
6840
- y: Math.max(10, Math.min(window.innerHeight - 120, dragStartRef.current.posY + dy))
6851
+ x: Math.max(8, Math.min(maxX, dragStartRef.current.posX + dx)),
6852
+ y: Math.max(8, Math.min(maxY, dragStartRef.current.posY + dy))
6841
6853
  });
6842
6854
  };
6843
- const handleMouseUp = () => {
6855
+ const handlePointerUp = () => {
6844
6856
  setIsDraggingWindow(false);
6845
6857
  };
6846
- window.addEventListener("mousemove", handleMouseMove);
6847
- window.addEventListener("mouseup", handleMouseUp);
6858
+ window.addEventListener("pointermove", handlePointerMove);
6859
+ window.addEventListener("pointerup", handlePointerUp);
6860
+ window.addEventListener("pointercancel", handlePointerUp);
6848
6861
  return () => {
6849
- window.removeEventListener("mousemove", handleMouseMove);
6850
- window.removeEventListener("mouseup", handleMouseUp);
6862
+ window.removeEventListener("pointermove", handlePointerMove);
6863
+ window.removeEventListener("pointerup", handlePointerUp);
6864
+ window.removeEventListener("pointercancel", handlePointerUp);
6851
6865
  };
6852
6866
  }, [isDraggingWindow]);
6853
6867
  useEffect9(() => {
@@ -6998,8 +7012,9 @@ var LayersPanel = ({ registry, className }) => {
6998
7012
  const header = /* @__PURE__ */ jsxs17(
6999
7013
  "div",
7000
7014
  {
7001
- onMouseDown: isFloating ? handleHeaderMouseDown : void 0,
7002
- className: `flex items-center justify-between px-3 py-2 border-b border-slate-200/90 select-none ${isFloating ? "cursor-grab active:cursor-grabbing bg-slate-50/90 rounded-t-xl" : "bg-slate-50"}`,
7015
+ onPointerDown: isFloating ? handleHeaderPointerDown : void 0,
7016
+ style: { touchAction: isFloating ? "none" : "auto" },
7017
+ className: `flex items-center justify-between px-3 py-2 border-b border-slate-200/90 select-none ${isFloating ? "cursor-grab active:cursor-grabbing bg-slate-50/90 rounded-t-xl touch-none" : "bg-slate-50"}`,
7003
7018
  children: [
7004
7019
  /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-1.5 font-semibold text-xs text-slate-700", children: [
7005
7020
  isFloating && /* @__PURE__ */ jsx18(GripVertical, { className: "w-3 h-3 text-slate-400 mr-0.5", "aria-hidden": "true" }),