@omnigrid/react 0.1.19 → 0.1.20

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
@@ -65,7 +65,6 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
65
65
  const rowsLayerRef = useRef(null);
66
66
  const pinnedLeftRowsLayerRef = useRef(null);
67
67
  const pinnedRightRowsLayerRef = useRef(null);
68
- const [isMeasured, setIsMeasured] = useState(false);
69
68
  /** Space taken by the viewport's native scrollbars; body slots stay clear of it. */
70
69
  const [scrollbarInsets, setScrollbarInsets] = useState({ right: 0, bottom: 0 });
71
70
  const scrollFrameRef = useRef({ id: 0, top: 0, left: 0, lastTop: 0, lastTime: 0 });
@@ -453,7 +452,6 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
453
452
  if (width === 0 || height === 0)
454
453
  return;
455
454
  grid.setViewport({ width, height });
456
- setIsMeasured(true);
457
455
  }, [grid, syncScrollbarInsets]);
458
456
  useEffect(() => {
459
457
  const element = viewportRef.current;
@@ -471,7 +469,6 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
471
469
  if (width === 0 || height === 0)
472
470
  return;
473
471
  grid.setViewport({ width, height });
474
- setIsMeasured(true);
475
472
  });
476
473
  observer.observe(element, { box: "content-box" });
477
474
  measureViewport();
@@ -483,12 +480,12 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
483
480
  syncScrollbarInsets(viewportRef.current);
484
481
  });
485
482
  useLayoutEffect(() => {
486
- if (!isMeasured || autoHeight)
483
+ if (autoHeight)
487
484
  return;
488
485
  // Scrollbar and gutter changes alter clientWidth; sync it before paint
489
486
  // so columns remain aligned when an overlay locks vertical scrolling.
490
487
  measureViewport();
491
- }, [autoHeight, hasVerticalOverflow, isMeasured, measureViewport, overlayScope]);
488
+ }, [autoHeight, hasVerticalOverflow, measureViewport, overlayScope]);
492
489
  useEffect(() => {
493
490
  const unsubscribe = grid.on("scrollTo", (position) => {
494
491
  const element = viewportRef.current;
@@ -584,15 +581,6 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
584
581
  syncPool(true, skipContentBind);
585
582
  });
586
583
  };
587
- if (!isMeasured) {
588
- return (_jsx("div", { ref: viewportRef, className: viewportClassName, style: {
589
- ...viewportStyle,
590
- overflowX: "auto",
591
- overflowY: autoHeight ? "hidden" : "auto",
592
- position: "relative",
593
- scrollbarGutter: verticalScrollbarGutter,
594
- } }));
595
- }
596
584
  /** Resolves headless slot content into a ReactNode (see contentToReactNode). */
597
585
  const resolveSlotContent = (mount, context) => {
598
586
  const raw = typeof mount.content === "function" ? mount.content(context) : mount.content;
@@ -615,7 +603,8 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
615
603
  const groups = renderSlotGroups(mounts, context);
616
604
  if (groups.every((group) => group === null))
617
605
  return null;
618
- return (_jsx("div", { className: `omnigrid-slot omnigrid-slot-${slot}`, children: groups }));
606
+ const slotClass = slot === "down" ? "omnigrid-slot omnigrid-slot-bottom omnigrid-slot-down" : `omnigrid-slot omnigrid-slot-${slot}`;
607
+ return (_jsx("div", { className: slotClass, children: groups }));
619
608
  };
620
609
  /** Renders slots that overlay the table body (absolute positioning, no layout shift). */
621
610
  const renderBodySlot = (slot) => {
package/dist/content.d.ts CHANGED
@@ -31,5 +31,7 @@ export declare function hasRenderableContent(content: ReactNode): boolean;
31
31
  * - `SlotComponentContent` → component from the adapter registry;
32
32
  * - `SlotHtmlContent` → `<div dangerouslySetInnerHTML>`;
33
33
  * - anything else → passthrough (ReactNode from cellRenderer).
34
+ *
35
+ * Control `icon` names are resolved through the grid's icon registry.
34
36
  */
35
37
  export declare function contentToReactNode<T>(content: unknown, bridge: ContentBridge<T>): ReactNode;
package/dist/content.js CHANGED
@@ -126,6 +126,19 @@ function slotNodeToReact(node, bridge) {
126
126
  });
127
127
  return createElement(node.tag, props, children);
128
128
  }
129
+ /**
130
+ * Builds an icon resolver backed by the grid's `IconRegistry` so control
131
+ * descriptors can declare `icon: "filter"` (and friends) as plain names.
132
+ * Unknown names resolve to `null` instead of throwing, keeping slot renders stable.
133
+ */
134
+ function createIconResolver(bridge) {
135
+ return (name) => {
136
+ const context = bridge.context();
137
+ if (!context.api.icons.has(name))
138
+ return null;
139
+ return slotNodeToReact(context.api.icons.get(name), bridge);
140
+ };
141
+ }
129
142
  /**
130
143
  * Materialises the core's headless content into a ReactNode:
131
144
  * - `string | number | boolean` → scalar;
@@ -135,6 +148,8 @@ function slotNodeToReact(node, bridge) {
135
148
  * - `SlotComponentContent` → component from the adapter registry;
136
149
  * - `SlotHtmlContent` → `<div dangerouslySetInnerHTML>`;
137
150
  * - anything else → passthrough (ReactNode from cellRenderer).
151
+ *
152
+ * Control `icon` names are resolved through the grid's icon registry.
138
153
  */
139
154
  export function contentToReactNode(content, bridge) {
140
155
  if (content == null)
@@ -144,7 +159,7 @@ export function contentToReactNode(content, bridge) {
144
159
  if (isCheckboxControl(content))
145
160
  return renderCheckboxControl(content);
146
161
  if (isUIControlDescriptor(content))
147
- return renderControl(content);
162
+ return renderControl(content, createIconResolver(bridge));
148
163
  if (isSlotNodeContent(content))
149
164
  return slotNodeToReact(content, bridge);
150
165
  if (isSlotComponentContent(content)) {
@@ -15,5 +15,7 @@ export declare function DebouncedInput({ descriptor }: DebouncedInputProps): Rea
15
15
  * Renders one framework-agnostic control descriptor with native HTML elements.
16
16
  * Descriptor `id`s become React keys, so re-describing a popup updates
17
17
  * elements in place instead of remounting them.
18
+ * @param descriptor - Control descriptor to materialise.
19
+ * @param resolveIcon - Optional resolver mapping `descriptor.icon` names to nodes; backed by the grid icon registry.
18
20
  */
19
- export declare function renderControl(descriptor: UIControlDescriptor): ReactNode;
21
+ export declare function renderControl(descriptor: UIControlDescriptor, resolveIcon?: (name: string) => ReactNode): ReactNode;
package/dist/controls.js CHANGED
@@ -62,7 +62,7 @@ export function DebouncedInput({ descriptor }) {
62
62
  value: local,
63
63
  placeholder: descriptor.placeholder,
64
64
  disabled: descriptor.disabled,
65
- "aria-label": descriptor.label ?? descriptor.placeholder,
65
+ "aria-label": descriptor.ariaLabel ?? descriptor.label ?? descriptor.placeholder,
66
66
  onChange: handleChange,
67
67
  onBlur: flush,
68
68
  onKeyDown: handleKeyDown,
@@ -74,12 +74,14 @@ export function DebouncedInput({ descriptor }) {
74
74
  onClick: handleClear,
75
75
  }, "×"));
76
76
  }
77
- function withLabel(descriptor, field, inline = false) {
77
+ function withLabel(descriptor, field, inline = false, resolveIcon) {
78
78
  const className = ["omnigrid-control", `omnigrid-control-${descriptor.type}`].join(" ");
79
+ const icon = descriptor.icon && resolveIcon ? resolveIcon(descriptor.icon) : null;
80
+ const body = icon ? createElement("div", { className: "omnigrid-control-body" }, icon, field) : field;
79
81
  if (!descriptor.label)
80
- return createElement("div", { key: descriptor.id, className }, field);
82
+ return createElement("div", { key: descriptor.id, className }, body);
81
83
  const label = createElement("span", { className: "omnigrid-control-label" }, descriptor.label);
82
- return inline ? createElement("label", { key: descriptor.id, className }, field, label) : createElement("label", { key: descriptor.id, className }, label, field);
84
+ return inline ? createElement("label", { key: descriptor.id, className }, body, label) : createElement("label", { key: descriptor.id, className }, label, body);
83
85
  }
84
86
  /**
85
87
  * Custom-styled, keyboard-navigable drop-down select. Replaces the native
@@ -221,7 +223,7 @@ function SelectControl({ descriptor }) {
221
223
  ref: listboxRef,
222
224
  id: listboxId,
223
225
  role: "listbox",
224
- "aria-label": descriptor.label,
226
+ "aria-label": descriptor.ariaLabel ?? descriptor.label,
225
227
  "data-omnigrid-filter-trigger": "",
226
228
  className: "omnigrid-select-listbox",
227
229
  onKeyDown: handleListboxKeyDown,
@@ -263,7 +265,7 @@ function SelectControl({ descriptor }) {
263
265
  "aria-haspopup": "listbox",
264
266
  "aria-expanded": isOpen,
265
267
  "aria-controls": listboxId,
266
- "aria-label": descriptor.label,
268
+ "aria-label": descriptor.ariaLabel ?? descriptor.label,
267
269
  className: ["omnigrid-select-button", descriptor.disabled ? "omnigrid-select-button-disabled" : null]
268
270
  .filter(Boolean)
269
271
  .join(" "),
@@ -337,17 +339,19 @@ function MultiSelectControl({ descriptor }) {
337
339
  * Renders one framework-agnostic control descriptor with native HTML elements.
338
340
  * Descriptor `id`s become React keys, so re-describing a popup updates
339
341
  * elements in place instead of remounting them.
342
+ * @param descriptor - Control descriptor to materialise.
343
+ * @param resolveIcon - Optional resolver mapping `descriptor.icon` names to nodes; backed by the grid icon registry.
340
344
  */
341
- export function renderControl(descriptor) {
345
+ export function renderControl(descriptor, resolveIcon) {
342
346
  switch (descriptor.type) {
343
347
  case "text":
344
348
  case "number":
345
349
  case "date":
346
- return withLabel(descriptor, createElement(DebouncedInput, { descriptor }));
350
+ return withLabel(descriptor, createElement(DebouncedInput, { descriptor }), false, resolveIcon);
347
351
  case "select":
348
- return withLabel(descriptor, createElement(SelectControl, { descriptor }));
352
+ return withLabel(descriptor, createElement(SelectControl, { descriptor }), false, resolveIcon);
349
353
  case "multi-select":
350
- return withLabel(descriptor, createElement(MultiSelectControl, { descriptor }));
354
+ return withLabel(descriptor, createElement(MultiSelectControl, { descriptor }), false, resolveIcon);
351
355
  case "checkbox":
352
356
  return withLabel(descriptor, createElement("input", {
353
357
  type: "checkbox",
@@ -355,7 +359,7 @@ export function renderControl(descriptor) {
355
359
  checked: descriptor.checked,
356
360
  disabled: descriptor.disabled,
357
361
  onChange: (event) => descriptor.onChange(event.target.checked),
358
- }), true);
362
+ }), true, resolveIcon);
359
363
  case "button":
360
364
  return createElement("button", {
361
365
  key: descriptor.id,
@@ -374,7 +378,7 @@ export function renderControl(descriptor) {
374
378
  className: ["omnigrid-control", "omnigrid-control-group", descriptor.direction === "row" ? "omnigrid-control-group-row" : null, descriptor.className]
375
379
  .filter(Boolean)
376
380
  .join(" "),
377
- }, descriptor.children.map(renderControl));
381
+ }, descriptor.children.map((child) => renderControl(child, resolveIcon)));
378
382
  default:
379
383
  return null;
380
384
  }
package/dist/popup.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createElement, useEffect, useLayoutEffect, useRef, useState } from "react";
2
- import { renderControl } from "./controls";
2
+ import { contentToReactNode } from "./content";
3
3
  const VIEWPORT_MARGIN = 8;
4
4
  function anchorStyle(popup) {
5
5
  const base = { position: "absolute", zIndex: 1000 };
@@ -66,6 +66,10 @@ export function PopupHost({ grid }) {
66
66
  }, [popup]);
67
67
  if (!popup)
68
68
  return null;
69
+ const bridge = {
70
+ registry: {},
71
+ context: () => ({ api: grid, state: grid.getState() }),
72
+ };
69
73
  return createElement("div", {
70
74
  key: popup.id,
71
75
  ref: elementRef,
@@ -73,5 +77,5 @@ export function PopupHost({ grid }) {
73
77
  "aria-label": popup.title ?? popup.id,
74
78
  className: ["omnigrid-popup", popup.className].filter(Boolean).join(" "),
75
79
  style: anchorStyle(popup),
76
- }, popup.title ? createElement("div", { className: "omnigrid-popup-title" }, popup.title) : null, popup.controls.map(renderControl));
80
+ }, popup.title ? createElement("div", { className: "omnigrid-popup-title" }, popup.title) : null, popup.controls.map((control) => contentToReactNode(control, bridge)));
77
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/react",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "React adapter and renderer for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",
@@ -45,6 +45,7 @@
45
45
  "@omnigrid/default-theme": "^0.1.0"
46
46
  },
47
47
  "devDependencies": {
48
+ "@omnigrid/quick-filter-plugin": "*",
48
49
  "@types/react": "^19.0.0",
49
50
  "@types/react-dom": "^19.0.0"
50
51
  },