@omnigrid/react 0.1.7 → 0.1.8
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/OmniGrid.js +1 -0
- package/dist/content.js +45 -2
- package/package.json +1 -1
package/dist/OmniGrid.js
CHANGED
|
@@ -499,6 +499,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
499
499
|
left: Math.round(item.offset - originX),
|
|
500
500
|
top: fullHeight ? -(gapRows * rowHeight) : 0,
|
|
501
501
|
bottom: 0,
|
|
502
|
+
touchAction: "none",
|
|
502
503
|
whiteSpace: "nowrap",
|
|
503
504
|
width: item.width,
|
|
504
505
|
}, children: item.column.headerRenderer ? (contentToReactNode(item.column.headerRenderer(item.column), {
|
package/dist/content.js
CHANGED
|
@@ -33,6 +33,10 @@ const SLOT_NODE_EVENTS = {
|
|
|
33
33
|
click: "onClick",
|
|
34
34
|
change: "onChange",
|
|
35
35
|
keydown: "onKeyDown",
|
|
36
|
+
pointerdown: "onPointerDown",
|
|
37
|
+
pointermove: "onPointerMove",
|
|
38
|
+
pointerup: "onPointerUp",
|
|
39
|
+
dblclick: "onDoubleClick",
|
|
36
40
|
};
|
|
37
41
|
const SLOT_NODE_ATTRS = {
|
|
38
42
|
class: "className",
|
|
@@ -40,11 +44,43 @@ const SLOT_NODE_ATTRS = {
|
|
|
40
44
|
readonly: "readOnly",
|
|
41
45
|
};
|
|
42
46
|
const VOID_TAGS = new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
47
|
+
function parseStyleAttribute(rawValue) {
|
|
48
|
+
if (rawValue === undefined || rawValue === null || typeof rawValue === "boolean")
|
|
49
|
+
return undefined;
|
|
50
|
+
const value = String(rawValue).trim();
|
|
51
|
+
if (!value)
|
|
52
|
+
return undefined;
|
|
53
|
+
const style = {};
|
|
54
|
+
for (const entry of value.split(";")) {
|
|
55
|
+
const trimmed = entry.trim();
|
|
56
|
+
if (!trimmed)
|
|
57
|
+
continue;
|
|
58
|
+
const index = trimmed.indexOf(":");
|
|
59
|
+
if (index === -1)
|
|
60
|
+
continue;
|
|
61
|
+
const cssName = trimmed.slice(0, index).trim();
|
|
62
|
+
const cssValue = trimmed.slice(index + 1).trim();
|
|
63
|
+
if (!cssName || !cssValue)
|
|
64
|
+
continue;
|
|
65
|
+
const camelName = cssName
|
|
66
|
+
.split("-")
|
|
67
|
+
.map((part, idx) => (idx === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1)))
|
|
68
|
+
.join("");
|
|
69
|
+
style[camelName] = cssValue;
|
|
70
|
+
}
|
|
71
|
+
return Object.keys(style).length ? style : undefined;
|
|
72
|
+
}
|
|
43
73
|
function slotNodeToReact(node, bridge) {
|
|
44
74
|
const context = bridge.context();
|
|
45
75
|
const props = {};
|
|
46
76
|
for (const [name, rawValue] of Object.entries(node.attrs ?? {})) {
|
|
47
77
|
const key = SLOT_NODE_ATTRS[name] ?? name;
|
|
78
|
+
if (name === "style") {
|
|
79
|
+
const parsedStyle = parseStyleAttribute(rawValue);
|
|
80
|
+
if (parsedStyle)
|
|
81
|
+
props.style = parsedStyle;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
48
84
|
if (typeof rawValue === "boolean") {
|
|
49
85
|
if (rawValue)
|
|
50
86
|
props[key] = true;
|
|
@@ -58,10 +94,17 @@ function slotNodeToReact(node, bridge) {
|
|
|
58
94
|
if (!reactEvent || !handler)
|
|
59
95
|
continue;
|
|
60
96
|
props[reactEvent] = (nativeEvent) => {
|
|
61
|
-
if (
|
|
97
|
+
if (["click", "pointerdown", "pointermove", "pointerup", "dblclick"].includes(eventName)) {
|
|
62
98
|
nativeEvent.preventDefault();
|
|
99
|
+
}
|
|
63
100
|
nativeEvent.stopPropagation();
|
|
64
|
-
handler(context, {
|
|
101
|
+
handler(context, {
|
|
102
|
+
value: nativeEvent.currentTarget.value,
|
|
103
|
+
key: nativeEvent.key,
|
|
104
|
+
clientX: nativeEvent.clientX,
|
|
105
|
+
clientY: nativeEvent.clientY,
|
|
106
|
+
button: nativeEvent.button,
|
|
107
|
+
});
|
|
65
108
|
};
|
|
66
109
|
}
|
|
67
110
|
if (VOID_TAGS.has(node.tag))
|