schummar-table 0.40.5 → 0.40.6

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, S as SerializableValue, a as TableProps, F as FilterImplementation, M as MemoizedTableTheme, I as Id, b as TableItem, c as InternalTableState, P as PartialTableTheme } from './types-CYMVvUGJ.cjs';
5
- export { e as Column, f as FunctionWithDeps, g as InternalColumn, h as Sort, i as SortDirection, d as TableStateStorage } from './types-CYMVvUGJ.cjs';
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-xTAreHv_.cjs';
5
+ export { e as Column, f as FunctionWithDeps, g as InternalColumn, S as Sort, h as SortDirection, d as TableStateStorage } from './types-xTAreHv_.cjs';
6
6
  import { Store } from 'schummar-state/react';
7
7
  import { E as ExporterEntry } from './exporter-u6SatTo6.cjs';
8
8
  import '@emotion/react';
@@ -92,16 +92,16 @@ declare function dateIntersect(a: Date | DateRange | null | undefined, b: Date |
92
92
  declare function dateClamp(date: Date, min?: Date, max?: Date): Date;
93
93
  declare function DatePicker(props: DatePickerProps): _emotion_react_jsx_runtime.JSX.Element;
94
94
 
95
- declare function DateFilter<T, V>({ locale, firstDayOfWeek, defaultDateInView, quickOptions, singleSelect, filterBy, minDate, maxDate, showCalendarWeek, ...props }: {
95
+ declare function DateFilter<TItem, TColumnValue>({ locale, firstDayOfWeek, defaultDateInView, quickOptions, singleSelect, filterBy, minDate, maxDate, showCalendarWeek, ...props }: {
96
96
  /** If enabled, only single days can be selected. Ranges otherwise. */
97
97
  singleSelect?: boolean;
98
- } & Pick<DatePickerProps, 'locale' | 'firstDayOfWeek' | 'defaultDateInView' | 'quickOptions' | 'minDate' | 'maxDate' | 'showCalendarWeek'> & CommonFilterProps<T, V, Date | DateRange | null, Date | DateRange | null>): JSX.Element;
98
+ } & Pick<DatePickerProps, 'locale' | 'firstDayOfWeek' | 'defaultDateInView' | 'quickOptions' | 'minDate' | 'maxDate' | 'showCalendarWeek'> & CommonFilterProps<TItem, TColumnValue, Date | DateRange | null, Date | DateRange | null>): JSX.Element;
99
99
 
100
100
  interface RangeFilterProps<T, V> extends CommonFilterProps<T, V, number | null, [number | null, number | null] | null> {
101
101
  min?: number;
102
102
  max?: number;
103
103
  }
104
- declare function RangeFilter<T, V>({ min, max, filterBy, ...props }: RangeFilterProps<T, V>): JSX.Element;
104
+ declare function RangeFilter<TItem, TColumnValue>({ min, max, filterBy, ...props }: RangeFilterProps<TItem, TColumnValue>): JSX.Element;
105
105
 
106
106
  interface VirtualListProps<T> extends Omit<HTMLProps<HTMLDivElement>, 'children'> {
107
107
  virtual?: boolean | {
@@ -116,13 +116,13 @@ interface VirtualListProps<T> extends Omit<HTMLProps<HTMLDivElement>, 'children'
116
116
  children: (item: T, index: number) => ReactNode;
117
117
  }
118
118
 
119
- declare function SelectFilter<T, V, F extends SerializableValue>({ options: providedOptions, stringValue, render, singleSelect, hideSearchField, hideResetButton, ...props }: {
119
+ declare function SelectFilter<TItem, TColumnValue, TFilterBy>({ options: providedOptions, stringValue, render, singleSelect, hideSearchField, hideResetButton, ...props }: {
120
120
  /** Which options are provided to select. By default all unique item values are used. */
121
- options?: F[];
121
+ options?: TFilterBy[];
122
122
  /** String representation of a value. Used to filter options via the text field. */
123
- stringValue?: (value: F) => string;
123
+ stringValue?: (value: TFilterBy) => string;
124
124
  /** Render values. By default a string representation of the value is used. */
125
- render?: (value: F) => ReactNode;
125
+ render?: (value: TFilterBy) => ReactNode;
126
126
  /** If enabled, only one option can be selected at a time. */
127
127
  singleSelect?: boolean;
128
128
  /** If enabled, the search field is hidden. */
@@ -132,24 +132,24 @@ declare function SelectFilter<T, V, F extends SerializableValue>({ options: prov
132
132
  /** Virtual list props.
133
133
  * @default true */
134
134
  virtual?: VirtualListProps<unknown>['virtual'];
135
- } & CommonFilterProps<T, V, F, Set<F>>): JSX.Element;
135
+ } & CommonFilterProps<TItem, TColumnValue, TFilterBy, Set<TFilterBy>>): JSX.Element;
136
136
 
137
137
  declare function Table<T>(props: TableProps<T>): JSX.Element;
138
138
 
139
- declare function TextFilter<T, V>({ compare, filterBy, placeholder, ...props }: {
139
+ declare function TextFilter<TItem, TColumnValue>({ compare, filterBy, placeholder, ...props }: {
140
140
  /** Custom comparison function. Should return true if an item value matches the current filter value.
141
141
  * By default a fuzzy text comparison is used.
142
142
  */
143
143
  compare?: (itemValue: string, filterValue: string) => boolean;
144
144
  placeholder?: string;
145
- } & CommonFilterProps<T, V, string, string>): JSX.Element;
145
+ } & CommonFilterProps<TItem, TColumnValue, string, string>): JSX.Element;
146
146
 
147
- declare function useFilter<T, V, F, S extends SerializableValue>(impl: FilterImplementation<T, V, F, S>): {
147
+ declare function useFilter<TItem, TColumnValue, TFilterBy, TFilterValue>(impl: FilterImplementation<TItem, TColumnValue, TFilterBy, TFilterValue>): {
148
148
  isActive: boolean;
149
149
  close: () => void;
150
- value: S | undefined;
151
- onChange: (value?: S) => void;
152
- filterBy: (value: V, item: T) => F | F[];
150
+ value: TFilterValue | undefined;
151
+ onChange: (value?: TFilterValue) => void;
152
+ filterBy: (value: TColumnValue, item: TItem) => TFilterBy | TFilterBy[];
153
153
  };
154
154
 
155
155
  declare function useTheme<T, S>(selector: (theme: MemoizedTableTheme<T>) => S): S;
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, S as SerializableValue, a as TableProps, F as FilterImplementation, M as MemoizedTableTheme, I as Id, b as TableItem, c as InternalTableState, P as PartialTableTheme } from './types-3d4ARU6a.js';
5
- export { e as Column, f as FunctionWithDeps, g as InternalColumn, h as Sort, i as SortDirection, d as TableStateStorage } from './types-3d4ARU6a.js';
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-DcnzwYBU.js';
5
+ export { e as Column, f as FunctionWithDeps, g as InternalColumn, S as Sort, h as SortDirection, d as TableStateStorage } from './types-DcnzwYBU.js';
6
6
  import { Store } from 'schummar-state/react';
7
7
  import { E as ExporterEntry } from './exporter-u6SatTo6.js';
8
8
  import '@emotion/react';
@@ -92,16 +92,16 @@ declare function dateIntersect(a: Date | DateRange | null | undefined, b: Date |
92
92
  declare function dateClamp(date: Date, min?: Date, max?: Date): Date;
93
93
  declare function DatePicker(props: DatePickerProps): _emotion_react_jsx_runtime.JSX.Element;
94
94
 
95
- declare function DateFilter<T, V>({ locale, firstDayOfWeek, defaultDateInView, quickOptions, singleSelect, filterBy, minDate, maxDate, showCalendarWeek, ...props }: {
95
+ declare function DateFilter<TItem, TColumnValue>({ locale, firstDayOfWeek, defaultDateInView, quickOptions, singleSelect, filterBy, minDate, maxDate, showCalendarWeek, ...props }: {
96
96
  /** If enabled, only single days can be selected. Ranges otherwise. */
97
97
  singleSelect?: boolean;
98
- } & Pick<DatePickerProps, 'locale' | 'firstDayOfWeek' | 'defaultDateInView' | 'quickOptions' | 'minDate' | 'maxDate' | 'showCalendarWeek'> & CommonFilterProps<T, V, Date | DateRange | null, Date | DateRange | null>): JSX.Element;
98
+ } & Pick<DatePickerProps, 'locale' | 'firstDayOfWeek' | 'defaultDateInView' | 'quickOptions' | 'minDate' | 'maxDate' | 'showCalendarWeek'> & CommonFilterProps<TItem, TColumnValue, Date | DateRange | null, Date | DateRange | null>): JSX.Element;
99
99
 
100
100
  interface RangeFilterProps<T, V> extends CommonFilterProps<T, V, number | null, [number | null, number | null] | null> {
101
101
  min?: number;
102
102
  max?: number;
103
103
  }
104
- declare function RangeFilter<T, V>({ min, max, filterBy, ...props }: RangeFilterProps<T, V>): JSX.Element;
104
+ declare function RangeFilter<TItem, TColumnValue>({ min, max, filterBy, ...props }: RangeFilterProps<TItem, TColumnValue>): JSX.Element;
105
105
 
106
106
  interface VirtualListProps<T> extends Omit<HTMLProps<HTMLDivElement>, 'children'> {
107
107
  virtual?: boolean | {
@@ -116,13 +116,13 @@ interface VirtualListProps<T> extends Omit<HTMLProps<HTMLDivElement>, 'children'
116
116
  children: (item: T, index: number) => ReactNode;
117
117
  }
118
118
 
119
- declare function SelectFilter<T, V, F extends SerializableValue>({ options: providedOptions, stringValue, render, singleSelect, hideSearchField, hideResetButton, ...props }: {
119
+ declare function SelectFilter<TItem, TColumnValue, TFilterBy>({ options: providedOptions, stringValue, render, singleSelect, hideSearchField, hideResetButton, ...props }: {
120
120
  /** Which options are provided to select. By default all unique item values are used. */
121
- options?: F[];
121
+ options?: TFilterBy[];
122
122
  /** String representation of a value. Used to filter options via the text field. */
123
- stringValue?: (value: F) => string;
123
+ stringValue?: (value: TFilterBy) => string;
124
124
  /** Render values. By default a string representation of the value is used. */
125
- render?: (value: F) => ReactNode;
125
+ render?: (value: TFilterBy) => ReactNode;
126
126
  /** If enabled, only one option can be selected at a time. */
127
127
  singleSelect?: boolean;
128
128
  /** If enabled, the search field is hidden. */
@@ -132,24 +132,24 @@ declare function SelectFilter<T, V, F extends SerializableValue>({ options: prov
132
132
  /** Virtual list props.
133
133
  * @default true */
134
134
  virtual?: VirtualListProps<unknown>['virtual'];
135
- } & CommonFilterProps<T, V, F, Set<F>>): JSX.Element;
135
+ } & CommonFilterProps<TItem, TColumnValue, TFilterBy, Set<TFilterBy>>): JSX.Element;
136
136
 
137
137
  declare function Table<T>(props: TableProps<T>): JSX.Element;
138
138
 
139
- declare function TextFilter<T, V>({ compare, filterBy, placeholder, ...props }: {
139
+ declare function TextFilter<TItem, TColumnValue>({ compare, filterBy, placeholder, ...props }: {
140
140
  /** Custom comparison function. Should return true if an item value matches the current filter value.
141
141
  * By default a fuzzy text comparison is used.
142
142
  */
143
143
  compare?: (itemValue: string, filterValue: string) => boolean;
144
144
  placeholder?: string;
145
- } & CommonFilterProps<T, V, string, string>): JSX.Element;
145
+ } & CommonFilterProps<TItem, TColumnValue, string, string>): JSX.Element;
146
146
 
147
- declare function useFilter<T, V, F, S extends SerializableValue>(impl: FilterImplementation<T, V, F, S>): {
147
+ declare function useFilter<TItem, TColumnValue, TFilterBy, TFilterValue>(impl: FilterImplementation<TItem, TColumnValue, TFilterBy, TFilterValue>): {
148
148
  isActive: boolean;
149
149
  close: () => void;
150
- value: S | undefined;
151
- onChange: (value?: S) => void;
152
- filterBy: (value: V, item: T) => F | F[];
150
+ value: TFilterValue | undefined;
151
+ onChange: (value?: TFilterValue) => void;
152
+ filterBy: (value: TColumnValue, item: TItem) => TFilterBy | TFilterBy[];
153
153
  };
154
154
 
155
155
  declare function useTheme<T, S>(selector: (theme: MemoizedTableTheme<T>) => S): S;
package/dist/index.js CHANGED
@@ -908,8 +908,8 @@ function AutoFocusTextField(props) {
908
908
 
909
909
  // src/hooks/useFilter.ts
910
910
  import { castDraft } from "immer";
911
- import { useContext as useContext5, useEffect, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useRef as useRef2, useState as useState3 } from "react";
912
911
  import { nanoid } from "nanoid";
912
+ import { useContext as useContext5, useEffect, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useRef as useRef2, useState as useState3 } from "react";
913
913
 
914
914
  // src/misc/debounce.ts
915
915
  function debounce(function_, ms) {
@@ -973,7 +973,9 @@ function useFilter(impl) {
973
973
  });
974
974
  };
975
975
  }, [table, columnId, impl]);
976
- const value = table.useState((state) => state.filterValues.get(columnId));
976
+ const value = table.useState(
977
+ (state) => state.filterValues.get(columnId)
978
+ );
977
979
  const [dirtyValue, setDirtyValue] = useState3();
978
980
  const implRef = useRef2(impl);
979
981
  useLayoutEffect2(() => {