@omnigrid/react 0.1.6 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
3
  import { DomPool } from "@omnigrid/core";
4
4
  import { contentToReactNode } from "./content";
@@ -484,7 +484,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
484
484
  const deepestDepth = hasGroups ? (viewportData.columnGroupDepth.get(item.index) ?? -1) : -1;
485
485
  const gapRows = headerRowCount - 1 - deepestDepth;
486
486
  const fullHeight = gapRows > 0;
487
- return (_jsx("div", { role: "columnheader", className: `omnigrid-header-cell${fullHeight ? " omnigrid-header-cell-full-height" : ""}`, "data-sort": item.column.sortState, "data-sortable": item.column.sortable === true ? "true" : undefined, "aria-sort": item.column.sortState === "asc" ? "ascending" : item.column.sortState === "desc" ? "descending" : "none", onClick: (event) => item.column.stopHeaderClick
487
+ return (_jsx("div", { role: "columnheader", className: `omnigrid-header-cell${fullHeight ? " omnigrid-header-cell-full-height" : ""}`, "data-sort": item.column.sortState, "data-sort-index": item.column.sortIndex, "data-sortable": item.column.sortable === true ? "true" : undefined, "aria-sort": item.column.sortState === "asc" ? "ascending" : item.column.sortState === "desc" ? "descending" : "none", onClick: (event) => item.column.stopHeaderClick
488
488
  ? event.stopPropagation()
489
489
  : grid.headerClick(item.column.id, event.shiftKey || event.ctrlKey || event.metaKey), onKeyDown: (event) => {
490
490
  if (event.key === "Enter" || event.key === " ")
@@ -499,14 +499,15 @@ 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), {
505
506
  registry: slotComponentsRef.current,
506
507
  context: buildRenderContext,
507
- })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "omnigrid-header-label", children: item.column.header ?? item.column.id }), _jsx("span", { className: "omnigrid-header-tools", children: item.column.sortState && (_jsx("span", { className: "omnigrid-sort-indicator", "aria-hidden": "true", children: contentToReactNode(item.column.sortState === "asc"
508
- ? grid.icons.get("arrow-up")
509
- : grid.icons.get("arrow-down"), { registry: slotComponentsRef.current, context: buildRenderContext }) })) })] })) }, item.column.id));
508
+ })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "omnigrid-header-label", children: item.column.header ?? item.column.id }), _jsx("span", { className: "omnigrid-header-tools", children: item.column.sortState && (_jsxs("span", { className: "omnigrid-sort-indicator", "aria-hidden": "true", children: [contentToReactNode(item.column.sortState === "asc"
509
+ ? grid.icons.get("arrow-up")
510
+ : grid.icons.get("arrow-down"), { registry: slotComponentsRef.current, context: buildRenderContext }), item.column.sortIndex !== undefined && (_jsx("span", { className: "omnigrid-sort-priority", children: item.column.sortIndex }))] })) })] })) }, item.column.id));
510
511
  });
511
512
  const renderGroupCells = (depth, columns, originX) => computeGroupSegments(viewportData.columnGroups, columns, depth, originX).map((segment, index) => (_jsx("div", { role: "columnheader", className: "omnigrid-header-cell omnigrid-header-group-cell", "aria-colspan": segment.columnCount, title: segment.group.header ?? segment.group.id, style: {
512
513
  alignItems: "center",
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 (eventName === "click")
97
+ if (["click", "pointerdown", "pointermove", "pointerup", "dblclick"].includes(eventName)) {
62
98
  nativeEvent.preventDefault();
99
+ }
63
100
  nativeEvent.stopPropagation();
64
- handler(context, { value: nativeEvent.currentTarget.value, key: nativeEvent.key });
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))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/react",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "React adapter and renderer for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",