@homebound/beam 3.106.0 → 3.108.0
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.cjs +58 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +88 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11883,7 +11883,7 @@ function MenuItemImpl(props) {
|
|
|
11883
11883
|
}
|
|
11884
11884
|
function renderMenuItem(menuItem, isSelected, isDisabled) {
|
|
11885
11885
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "df w100 aic jcsb gap2", children: [
|
|
11886
|
-
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "df aic", children: maybeWrapInLink(menuItem.onClick, isIconMenuItem(menuItem) ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(IconMenuItem, { ...menuItem }) : isImageMenuItem(menuItem) ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ImageMenuItem, { ...menuItem }) : menuItem.label, isDisabled) }),
|
|
11886
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "df aic", children: maybeWrapInLink(menuItem.onClick, menuItem.ai ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(AiMenuItem, { label: menuItem.label, isDisabled }) : isIconMenuItem(menuItem) ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(IconMenuItem, { ...menuItem }) : isImageMenuItem(menuItem) ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ImageMenuItem, { ...menuItem }) : menuItem.label, isDisabled) }),
|
|
11887
11887
|
isSelected && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Icon, { icon: "check", color: isDisabled ? "--b-text-disabled" /* TextDisabled */ : "--b-selection-indicator" /* SelectionIndicator */ })
|
|
11888
11888
|
] });
|
|
11889
11889
|
}
|
|
@@ -11899,6 +11899,21 @@ function ImageMenuItem(item) {
|
|
|
11899
11899
|
label
|
|
11900
11900
|
] });
|
|
11901
11901
|
}
|
|
11902
|
+
function AiMenuItem({
|
|
11903
|
+
label,
|
|
11904
|
+
isDisabled
|
|
11905
|
+
}) {
|
|
11906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
11907
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "df aic jcc fs0 h_24px w_24px mr2", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Icon, { icon: "aiStar", inc: 2.125 }) }),
|
|
11908
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { ...(0, import_runtime35.trussProps)({
|
|
11909
|
+
...!isDisabled ? {
|
|
11910
|
+
color: ["color_var", {
|
|
11911
|
+
"--color": (0, import_runtime35.maybeCssVar)("rgba(124, 58, 237, 1)" /* Purple600 */)
|
|
11912
|
+
}]
|
|
11913
|
+
} : {}
|
|
11914
|
+
}), children: label })
|
|
11915
|
+
] });
|
|
11916
|
+
}
|
|
11902
11917
|
function IconMenuItem(item) {
|
|
11903
11918
|
const {
|
|
11904
11919
|
icon,
|
|
@@ -21759,7 +21774,8 @@ function DnDGrid(props) {
|
|
|
21759
21774
|
children,
|
|
21760
21775
|
gridStyles,
|
|
21761
21776
|
onReorder,
|
|
21762
|
-
activeItemStyles
|
|
21777
|
+
activeItemStyles,
|
|
21778
|
+
lockAxis
|
|
21763
21779
|
} = props;
|
|
21764
21780
|
const gridEl = (0, import_react107.useRef)(null);
|
|
21765
21781
|
const dragEl = (0, import_react107.useRef)();
|
|
@@ -21826,15 +21842,15 @@ function DnDGrid(props) {
|
|
|
21826
21842
|
const clientY = "clientY" in e ? e.clientY : e.touches[0].clientY;
|
|
21827
21843
|
const left = dragEl.current.style.left ? parseInt(dragEl.current.style.left) : 0;
|
|
21828
21844
|
const top = dragEl.current.style.top ? parseInt(dragEl.current.style.top) : 0;
|
|
21829
|
-
const x = clientX - transformFrom.current.x - left;
|
|
21830
|
-
const y = clientY - transformFrom.current.y - top;
|
|
21845
|
+
const x = lockAxis === "y" ? 0 : clientX - transformFrom.current.x - left;
|
|
21846
|
+
const y = lockAxis === "x" ? 0 : clientY - transformFrom.current.y - top;
|
|
21831
21847
|
dragEl.current.style.transform = `translate(${x}px, ${y}px)`;
|
|
21832
21848
|
const maybeTarget = "touches" in e ? document.elementFromPoint(clientX, clientY) : e.target;
|
|
21833
21849
|
const target = maybeTarget instanceof HTMLElement ? maybeTarget?.closest(`[${gridItemIdKey}]`) : void 0;
|
|
21834
21850
|
if (target instanceof HTMLElement && target !== cloneEl.current && target !== dragEl.current) {
|
|
21835
21851
|
const targetPos = target.getBoundingClientRect();
|
|
21836
21852
|
const clonePos = cloneEl.current.getBoundingClientRect();
|
|
21837
|
-
const useYAxis = Math.abs(targetPos.top - clonePos.top) >= Math.abs(targetPos.left - clonePos.left);
|
|
21853
|
+
const useYAxis = lockAxis === "y" ? true : lockAxis === "x" ? false : Math.abs(targetPos.top - clonePos.top) >= Math.abs(targetPos.left - clonePos.left);
|
|
21838
21854
|
const isHalfwayPassedTarget = useYAxis ? (clientY - targetPos.top) / (targetPos.bottom - targetPos.top) > 0.5 : (clientX - targetPos.left) / (targetPos.right - targetPos.left) > 0.5;
|
|
21839
21855
|
const shouldInsert = isHalfwayPassedTarget && target.nextSibling !== cloneEl.current || !isHalfwayPassedTarget && target.previousSibling !== cloneEl.current;
|
|
21840
21856
|
if (shouldInsert) {
|
|
@@ -21842,7 +21858,18 @@ function DnDGrid(props) {
|
|
|
21842
21858
|
}
|
|
21843
21859
|
}
|
|
21844
21860
|
}
|
|
21845
|
-
}, []);
|
|
21861
|
+
}, [lockAxis]);
|
|
21862
|
+
const onDragEnd = (0, import_react107.useCallback)((e) => {
|
|
21863
|
+
if (!reorderViaKeyboard.current && dragEl.current && cloneEl.current && gridEl.current) {
|
|
21864
|
+
e.preventDefault();
|
|
21865
|
+
cloneEl.current.replaceWith(dragEl.current);
|
|
21866
|
+
gridEl.current.querySelectorAll(`[${gridCloneKey}]`).forEach((el) => el.remove());
|
|
21867
|
+
gridEl.current.style.cursor = "auto";
|
|
21868
|
+
cloneEl.current = void 0;
|
|
21869
|
+
commitReorder();
|
|
21870
|
+
removePointerDragListeners(onMove, onDragEnd);
|
|
21871
|
+
}
|
|
21872
|
+
}, [commitReorder, onMove]);
|
|
21846
21873
|
const onDragStart = (0, import_react107.useCallback)((e) => {
|
|
21847
21874
|
if (!reorderViaKeyboard.current && dragEl.current && gridEl.current) {
|
|
21848
21875
|
const rect = dragEl.current.getBoundingClientRect();
|
|
@@ -21868,22 +21895,12 @@ function DnDGrid(props) {
|
|
|
21868
21895
|
dragEl.current.style.width = `${rect.width}px`;
|
|
21869
21896
|
dragEl.current.style.height = `${rect.height}px`;
|
|
21870
21897
|
gridEl.current.style.cursor = "grabbing";
|
|
21871
|
-
|
|
21872
|
-
gridEl.current.addEventListener("touchmove", onMove);
|
|
21898
|
+
addPointerDragListeners(onMove, onDragEnd);
|
|
21873
21899
|
}
|
|
21874
|
-
}, [initReorder, onMove]);
|
|
21875
|
-
|
|
21876
|
-
|
|
21877
|
-
|
|
21878
|
-
cloneEl.current.replaceWith(dragEl.current);
|
|
21879
|
-
gridEl.current.querySelectorAll(`[${gridCloneKey}]`).forEach((el) => el.remove());
|
|
21880
|
-
gridEl.current.style.cursor = "auto";
|
|
21881
|
-
cloneEl.current = void 0;
|
|
21882
|
-
commitReorder();
|
|
21883
|
-
gridEl.current.removeEventListener("mousemove", onMove);
|
|
21884
|
-
gridEl.current.removeEventListener("touchmove", onMove);
|
|
21885
|
-
}
|
|
21886
|
-
}, [commitReorder, onMove]);
|
|
21900
|
+
}, [initReorder, onMove, onDragEnd]);
|
|
21901
|
+
(0, import_react107.useEffect)(() => {
|
|
21902
|
+
return () => removePointerDragListeners(onMove, onDragEnd);
|
|
21903
|
+
}, [onMove, onDragEnd]);
|
|
21887
21904
|
const onDragHandleKeyDown = (0, import_react107.useCallback)((e) => {
|
|
21888
21905
|
const moveHandle = e.target;
|
|
21889
21906
|
if (dragEl.current instanceof HTMLElement && moveHandle instanceof HTMLElement && gridEl.current) {
|
|
@@ -21917,8 +21934,8 @@ function DnDGrid(props) {
|
|
|
21917
21934
|
document.removeEventListener("pointerdown", cancelReorder);
|
|
21918
21935
|
return;
|
|
21919
21936
|
}
|
|
21920
|
-
const movingLeft =
|
|
21921
|
-
const movingRight =
|
|
21937
|
+
const movingLeft = lockAxis !== "x" && e.key === "ArrowUp" || lockAxis !== "y" && e.key === "ArrowLeft";
|
|
21938
|
+
const movingRight = lockAxis !== "x" && e.key === "ArrowDown" || lockAxis !== "y" && e.key === "ArrowRight";
|
|
21922
21939
|
if (movingLeft || movingRight) {
|
|
21923
21940
|
e.preventDefault();
|
|
21924
21941
|
const gridItems = getGridItems();
|
|
@@ -21931,7 +21948,7 @@ function DnDGrid(props) {
|
|
|
21931
21948
|
moveHandle.focus();
|
|
21932
21949
|
}
|
|
21933
21950
|
}
|
|
21934
|
-
}, [cancelReorder, commitReorder, initReorder, getGridItems]);
|
|
21951
|
+
}, [cancelReorder, commitReorder, initReorder, getGridItems, lockAxis]);
|
|
21935
21952
|
return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(DnDGridContext.Provider, { value: {
|
|
21936
21953
|
dragEl,
|
|
21937
21954
|
onDragHandleKeyDown
|
|
@@ -21945,6 +21962,22 @@ function DnDGrid(props) {
|
|
|
21945
21962
|
}
|
|
21946
21963
|
var gridItemIdKey = "dndgrid-itemid";
|
|
21947
21964
|
var gridCloneKey = "dndgrid-clone";
|
|
21965
|
+
function addPointerDragListeners(onMove, onEnd) {
|
|
21966
|
+
document.addEventListener("mousemove", onMove);
|
|
21967
|
+
document.addEventListener("touchmove", onMove);
|
|
21968
|
+
document.addEventListener("mouseup", onEnd);
|
|
21969
|
+
document.addEventListener("touchend", onEnd);
|
|
21970
|
+
document.addEventListener("pointercancel", onEnd);
|
|
21971
|
+
document.addEventListener("touchcancel", onEnd);
|
|
21972
|
+
}
|
|
21973
|
+
function removePointerDragListeners(onMove, onEnd) {
|
|
21974
|
+
document.removeEventListener("mousemove", onMove);
|
|
21975
|
+
document.removeEventListener("touchmove", onMove);
|
|
21976
|
+
document.removeEventListener("mouseup", onEnd);
|
|
21977
|
+
document.removeEventListener("touchend", onEnd);
|
|
21978
|
+
document.removeEventListener("pointercancel", onEnd);
|
|
21979
|
+
document.removeEventListener("touchcancel", onEnd);
|
|
21980
|
+
}
|
|
21948
21981
|
function applyActiveStyles(el, activeStyles3) {
|
|
21949
21982
|
const {
|
|
21950
21983
|
className,
|
|
@@ -22333,7 +22366,7 @@ function DraggableChildren(props) {
|
|
|
22333
22366
|
}
|
|
22334
22367
|
});
|
|
22335
22368
|
};
|
|
22336
|
-
return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DnDGrid, { onReorder: handleReorder, gridStyles: {
|
|
22369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(DnDGrid, { onReorder: handleReorder, lockAxis: "y", gridStyles: {
|
|
22337
22370
|
gridTemplateColumns: "gtc_minmax_0_1fr",
|
|
22338
22371
|
gap: "gap3"
|
|
22339
22372
|
}, children: sorted.map((child) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(FormSectionChild, { ...child, ...tid }, child.id)) });
|