schummar-table 0.45.3 → 0.46.1

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.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ComponentType, ReactNode, HTMLProps } from 'react';
4
- import { T as TableTheme, C as CommonFilterProps, a as TableProps, F as FilterImplementation, M as MemoizedTableTheme, I as Id, b as TableItem, c as InternalTableState, P as PartialTableTheme } from './types-DKqBJ_4v.cjs';
5
- export { e as Column, f as FunctionWithDeps, g as InternalColumn, S as Sort, h as SortDirection, d as TableStateStorage } from './types-DKqBJ_4v.cjs';
4
+ import { T as TableTheme, C as CommonFilterProps, a as TableProps, b as TableRef, F as FilterImplementation, M as MemoizedTableTheme, I as Id, c as TableItem, d as InternalTableState, P as PartialTableTheme } from './types-CJnecNQy.cjs';
5
+ export { f as Column, g as FunctionWithDeps, h as InternalColumn, S as Sort, i as SortDirection, e as TableStateStorage } from './types-CJnecNQy.cjs';
6
6
  import { Store } from 'schummar-state/react';
7
7
  import { E as ExporterEntry } from './exporter-u6SatTo6.cjs';
8
8
  import '@emotion/react';
@@ -145,7 +145,7 @@ declare function SelectFilter<TItem, TColumnValue, TFilterBy>({ options: provide
145
145
  virtual?: VirtualListProps<unknown>['virtual'];
146
146
  } & CommonFilterProps<TItem, TColumnValue, TFilterBy, Set<TFilterBy>>): JSX.Element;
147
147
 
148
- declare function Table<T>(props: TableProps<T>): JSX.Element;
148
+ declare const Table: React.ForwardRefExoticComponent<TableProps<unknown> & React.RefAttributes<TableRef>>;
149
149
 
150
150
  declare function TextFilter<TItem, TColumnValue>({ compare, filterBy, placeholder, ...props }: {
151
151
  /** Custom comparison function. Should return true if an item value matches the current filter value.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _emotion_react_jsx_runtime from '@emotion/react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { ComponentType, ReactNode, HTMLProps } from 'react';
4
- import { T as TableTheme, C as CommonFilterProps, a as TableProps, F as FilterImplementation, M as MemoizedTableTheme, I as Id, b as TableItem, c as InternalTableState, P as PartialTableTheme } from './types-cAzUt-yT.js';
5
- export { e as Column, f as FunctionWithDeps, g as InternalColumn, S as Sort, h as SortDirection, d as TableStateStorage } from './types-cAzUt-yT.js';
4
+ import { T as TableTheme, C as CommonFilterProps, a as TableProps, b as TableRef, F as FilterImplementation, M as MemoizedTableTheme, I as Id, c as TableItem, d as InternalTableState, P as PartialTableTheme } from './types-CIq7O-SN.js';
5
+ export { f as Column, g as FunctionWithDeps, h as InternalColumn, S as Sort, i as SortDirection, e as TableStateStorage } from './types-CIq7O-SN.js';
6
6
  import { Store } from 'schummar-state/react';
7
7
  import { E as ExporterEntry } from './exporter-u6SatTo6.js';
8
8
  import '@emotion/react';
@@ -145,7 +145,7 @@ declare function SelectFilter<TItem, TColumnValue, TFilterBy>({ options: provide
145
145
  virtual?: VirtualListProps<unknown>['virtual'];
146
146
  } & CommonFilterProps<TItem, TColumnValue, TFilterBy, Set<TFilterBy>>): JSX.Element;
147
147
 
148
- declare function Table<T>(props: TableProps<T>): JSX.Element;
148
+ declare const Table: React.ForwardRefExoticComponent<TableProps<unknown> & React.RefAttributes<TableRef>>;
149
149
 
150
150
  declare function TextFilter<TItem, TColumnValue>({ compare, filterBy, placeholder, ...props }: {
151
151
  /** Custom comparison function. Should return true if an item value matches the current filter value.
package/dist/index.js CHANGED
@@ -2441,7 +2441,50 @@ function SelectFilter(_a) {
2441
2441
  }
2442
2442
 
2443
2443
  // src/components/table.tsx
2444
- import { memo as memo3, useEffect as useEffect15, useLayoutEffect as useLayoutEffect6, useState as useState15 } from "react";
2444
+ import { forwardRef as forwardRef2, memo as memo3, useEffect as useEffect15, useLayoutEffect as useLayoutEffect6, useState as useState15 } from "react";
2445
+
2446
+ // src/hooks/useTableRef.ts
2447
+ import { useImperativeHandle } from "react";
2448
+ function useTableRef(table, ref) {
2449
+ useImperativeHandle(
2450
+ ref,
2451
+ () => ({
2452
+ getSort() {
2453
+ return table.getState().sort;
2454
+ },
2455
+ setSort(sort) {
2456
+ table.update((state) => {
2457
+ state.sort = sort;
2458
+ });
2459
+ },
2460
+ getSelection() {
2461
+ return table.getState().selection;
2462
+ },
2463
+ setSelection(selection) {
2464
+ table.update((state) => {
2465
+ state.selection = selection;
2466
+ });
2467
+ },
2468
+ getExpanded() {
2469
+ return table.getState().expanded;
2470
+ },
2471
+ setExpanded(expanded) {
2472
+ table.update((state) => {
2473
+ state.expanded = expanded;
2474
+ });
2475
+ },
2476
+ getHiddenColumns() {
2477
+ return table.getState().hiddenColumns;
2478
+ },
2479
+ setHiddenColumns(hidden) {
2480
+ table.update((state) => {
2481
+ state.hiddenColumns = hidden;
2482
+ });
2483
+ }
2484
+ }),
2485
+ [table]
2486
+ );
2487
+ }
2445
2488
 
2446
2489
  // src/internalState/tableStateStorage.ts
2447
2490
  import { useEffect as useEffect5, useState as useState10 } from "react";
@@ -4255,9 +4298,11 @@ function Virtualized(_a) {
4255
4298
 
4256
4299
  // src/components/table.tsx
4257
4300
  import { Fragment as Fragment9, jsx as jsx35, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
4258
- function Table(props) {
4301
+ var Table = forwardRef2(_Table);
4302
+ function _Table(props, ref) {
4259
4303
  const [table, resetState] = useTableState(props);
4260
4304
  const [isHydrated, clearStorage] = useTableStateStorage(table);
4305
+ useTableRef(table, ref);
4261
4306
  function reset() {
4262
4307
  return __async(this, null, function* () {
4263
4308
  yield clearStorage();