@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.cjs
CHANGED
|
@@ -146,9 +146,9 @@ function Box({
|
|
|
146
146
|
style,
|
|
147
147
|
children
|
|
148
148
|
}) {
|
|
149
|
-
const
|
|
149
|
+
const Element2 = as ?? "div";
|
|
150
150
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
151
|
-
|
|
151
|
+
Element2,
|
|
152
152
|
{
|
|
153
153
|
onClick,
|
|
154
154
|
className: cx(
|
|
@@ -471,9 +471,9 @@ function Typography({
|
|
|
471
471
|
style,
|
|
472
472
|
children
|
|
473
473
|
}) {
|
|
474
|
-
const
|
|
474
|
+
const Element2 = as ?? DEFAULT_ELEMENT[variant];
|
|
475
475
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
476
|
-
|
|
476
|
+
Element2,
|
|
477
477
|
{
|
|
478
478
|
className: cx(
|
|
479
479
|
VARIANT_CLASS[variant],
|
|
@@ -5522,14 +5522,33 @@ function EditableCell({
|
|
|
5522
5522
|
onCellEdit
|
|
5523
5523
|
}) {
|
|
5524
5524
|
const [editing, setEditing] = React31.useState(false);
|
|
5525
|
+
const editRef = React31.useRef(null);
|
|
5525
5526
|
const value = row[col.keyBind];
|
|
5526
5527
|
const commit = (next) => {
|
|
5527
5528
|
setEditing(false);
|
|
5528
5529
|
onCellEdit?.({ row, key: col.keyBind, value: next, rowIndex });
|
|
5529
5530
|
};
|
|
5530
5531
|
const cancel = () => setEditing(false);
|
|
5532
|
+
React31.useEffect(() => {
|
|
5533
|
+
if (!editing || !col.editor) return;
|
|
5534
|
+
const onMouseDown = (e) => {
|
|
5535
|
+
const target = e.target;
|
|
5536
|
+
if (editRef.current && editRef.current.contains(target)) return;
|
|
5537
|
+
if (target instanceof Element && target.closest("[data-radix-popper-content-wrapper],[data-radix-portal]")) return;
|
|
5538
|
+
cancel();
|
|
5539
|
+
};
|
|
5540
|
+
const onKeyDown = (e) => {
|
|
5541
|
+
if (e.key === "Escape") cancel();
|
|
5542
|
+
};
|
|
5543
|
+
document.addEventListener("mousedown", onMouseDown);
|
|
5544
|
+
document.addEventListener("keydown", onKeyDown);
|
|
5545
|
+
return () => {
|
|
5546
|
+
document.removeEventListener("mousedown", onMouseDown);
|
|
5547
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
5548
|
+
};
|
|
5549
|
+
}, [editing, col.editor]);
|
|
5531
5550
|
if (editing) {
|
|
5532
|
-
if (col.editor) return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5551
|
+
if (col.editor) return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: editRef, className: "w-full", children: col.editor({ value, row, commit, cancel }) });
|
|
5533
5552
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5534
5553
|
"input",
|
|
5535
5554
|
{
|