@geomak/ui 7.7.1 → 7.7.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.cjs +24 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -110,9 +110,9 @@ function Box({
|
|
|
110
110
|
style,
|
|
111
111
|
children
|
|
112
112
|
}) {
|
|
113
|
-
const
|
|
113
|
+
const Element2 = as ?? "div";
|
|
114
114
|
return /* @__PURE__ */ jsx(
|
|
115
|
-
|
|
115
|
+
Element2,
|
|
116
116
|
{
|
|
117
117
|
onClick,
|
|
118
118
|
className: cx(
|
|
@@ -435,9 +435,9 @@ function Typography({
|
|
|
435
435
|
style,
|
|
436
436
|
children
|
|
437
437
|
}) {
|
|
438
|
-
const
|
|
438
|
+
const Element2 = as ?? DEFAULT_ELEMENT[variant];
|
|
439
439
|
return /* @__PURE__ */ jsx(
|
|
440
|
-
|
|
440
|
+
Element2,
|
|
441
441
|
{
|
|
442
442
|
className: cx(
|
|
443
443
|
VARIANT_CLASS[variant],
|
|
@@ -5486,14 +5486,33 @@ function EditableCell({
|
|
|
5486
5486
|
onCellEdit
|
|
5487
5487
|
}) {
|
|
5488
5488
|
const [editing, setEditing] = useState(false);
|
|
5489
|
+
const editRef = useRef(null);
|
|
5489
5490
|
const value = row[col.keyBind];
|
|
5490
5491
|
const commit = (next) => {
|
|
5491
5492
|
setEditing(false);
|
|
5492
5493
|
onCellEdit?.({ row, key: col.keyBind, value: next, rowIndex });
|
|
5493
5494
|
};
|
|
5494
5495
|
const cancel = () => setEditing(false);
|
|
5496
|
+
useEffect(() => {
|
|
5497
|
+
if (!editing || !col.editor) return;
|
|
5498
|
+
const onMouseDown = (e) => {
|
|
5499
|
+
const target = e.target;
|
|
5500
|
+
if (editRef.current && editRef.current.contains(target)) return;
|
|
5501
|
+
if (target instanceof Element && target.closest("[data-radix-popper-content-wrapper],[data-radix-portal]")) return;
|
|
5502
|
+
cancel();
|
|
5503
|
+
};
|
|
5504
|
+
const onKeyDown = (e) => {
|
|
5505
|
+
if (e.key === "Escape") cancel();
|
|
5506
|
+
};
|
|
5507
|
+
document.addEventListener("mousedown", onMouseDown);
|
|
5508
|
+
document.addEventListener("keydown", onKeyDown);
|
|
5509
|
+
return () => {
|
|
5510
|
+
document.removeEventListener("mousedown", onMouseDown);
|
|
5511
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
5512
|
+
};
|
|
5513
|
+
}, [editing, col.editor]);
|
|
5495
5514
|
if (editing) {
|
|
5496
|
-
if (col.editor) return /* @__PURE__ */ jsx(
|
|
5515
|
+
if (col.editor) return /* @__PURE__ */ jsx("div", { ref: editRef, className: "w-full", children: col.editor({ value, row, commit, cancel }) });
|
|
5497
5516
|
return /* @__PURE__ */ jsx(
|
|
5498
5517
|
"input",
|
|
5499
5518
|
{
|