simple-table-core 2.4.2 → 2.4.4

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.
Files changed (51) hide show
  1. package/dist/{Animate-a00b8653.js → Animate-85a426a3.js} +2 -2
  2. package/dist/Animate-85a426a3.js.map +1 -0
  3. package/dist/DatePicker-9d5825ee.js +2 -0
  4. package/dist/DatePicker-9d5825ee.js.map +1 -0
  5. package/dist/cjs/{Animate-b6372d93.js → Animate-18759d53.js} +2 -2
  6. package/dist/cjs/Animate-18759d53.js.map +1 -0
  7. package/dist/cjs/DatePicker-3d0a5721.js +2 -0
  8. package/dist/cjs/DatePicker-3d0a5721.js.map +1 -0
  9. package/dist/cjs/components/simple-table/table-column-editor/columnEditorUtils.d.ts +1 -0
  10. package/dist/cjs/context/TableContext.d.ts +2 -9
  11. package/dist/cjs/hooks/useDragHandler.d.ts +5 -1
  12. package/dist/cjs/hooks/useQuickFilter.d.ts +14 -0
  13. package/dist/cjs/hooks/useTableAPI.d.ts +3 -1
  14. package/dist/cjs/index-63f4ad95.js +2 -0
  15. package/dist/cjs/index-63f4ad95.js.map +1 -0
  16. package/dist/cjs/index.d.ts +2 -1
  17. package/dist/cjs/index.js +1 -1
  18. package/dist/cjs/types/HeaderObject.d.ts +3 -0
  19. package/dist/cjs/types/QuickFilterTypes.d.ts +21 -0
  20. package/dist/cjs/types/SimpleTableProps.d.ts +2 -0
  21. package/dist/cjs/types/TableRefType.d.ts +2 -0
  22. package/dist/cjs/types/TableRow.d.ts +1 -0
  23. package/dist/cjs/utils/quickFilterUtils.d.ts +14 -0
  24. package/dist/cjs/utils/rowUtils.d.ts +27 -0
  25. package/dist/components/simple-table/table-column-editor/columnEditorUtils.d.ts +1 -0
  26. package/dist/context/TableContext.d.ts +2 -9
  27. package/dist/hooks/useDragHandler.d.ts +5 -1
  28. package/dist/hooks/useQuickFilter.d.ts +14 -0
  29. package/dist/hooks/useTableAPI.d.ts +3 -1
  30. package/dist/index-57a11501.js +2 -0
  31. package/dist/index-57a11501.js.map +1 -0
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.es.js +1 -1
  34. package/dist/types/HeaderObject.d.ts +3 -0
  35. package/dist/types/QuickFilterTypes.d.ts +21 -0
  36. package/dist/types/SimpleTableProps.d.ts +2 -0
  37. package/dist/types/TableRefType.d.ts +2 -0
  38. package/dist/types/TableRow.d.ts +1 -0
  39. package/dist/utils/quickFilterUtils.d.ts +14 -0
  40. package/dist/utils/rowUtils.d.ts +27 -0
  41. package/package.json +4 -1
  42. package/dist/Animate-a00b8653.js.map +0 -1
  43. package/dist/DatePicker-91f87634.js +0 -2
  44. package/dist/DatePicker-91f87634.js.map +0 -1
  45. package/dist/cjs/Animate-b6372d93.js.map +0 -1
  46. package/dist/cjs/DatePicker-7bfd609b.js +0 -2
  47. package/dist/cjs/DatePicker-7bfd609b.js.map +0 -1
  48. package/dist/cjs/index-e0379c0f.js +0 -2
  49. package/dist/cjs/index-e0379c0f.js.map +0 -1
  50. package/dist/index-fe1a2c58.js +0 -2
  51. package/dist/index-fe1a2c58.js.map +0 -1
package/dist/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- export{h as AngleDownIcon,i as AngleLeftIcon,j as AngleRightIcon,k as AngleUpIcon,l as AscIcon,B as BarChart,C as CheckIcon,g as DEFAULT_COLUMN_EDITOR_CONFIG,e as DEFAULT_CUSTOM_THEME,D as DefaultEmptyState,m as DescIcon,n as DragIcon,F as FilterIcon,L as LineAreaChart,o as SelectIcon,S as SimpleTable,r as rowIdToString}from"./index-fe1a2c58.js";import"react/jsx-runtime";import"react";
1
+ export{h as AngleDownIcon,i as AngleLeftIcon,j as AngleRightIcon,k as AngleUpIcon,l as AscIcon,B as BarChart,C as CheckIcon,g as DEFAULT_COLUMN_EDITOR_CONFIG,e as DEFAULT_CUSTOM_THEME,D as DefaultEmptyState,m as DescIcon,n as DragIcon,F as FilterIcon,L as LineAreaChart,o as SelectIcon,S as SimpleTable,r as rowIdToString}from"./index-57a11501.js";import"react/jsx-runtime";import"react";
2
2
  //# sourceMappingURL=index.es.js.map
@@ -6,6 +6,7 @@ import { CellRenderer } from "./CellRendererProps";
6
6
  import { HeaderRenderer } from "./HeaderRendererProps";
7
7
  import CellValue from "./CellValue";
8
8
  import { SimpleTableProps } from "./SimpleTableProps";
9
+ import { QuickFilterGetter } from "./QuickFilterTypes";
9
10
  export type Accessor = keyof Row | string;
10
11
  export type ColumnType = "string" | "number" | "boolean" | "date" | "enum" | "lineAreaChart" | "barChart" | "other";
11
12
  export type ShowWhen = "parentCollapsed" | "parentExpanded" | "always";
@@ -79,6 +80,8 @@ type HeaderObject = {
79
80
  sortingOrder?: ("asc" | "desc" | null)[];
80
81
  nestedTable?: Omit<SimpleTableProps, "rows" | "loadingStateRenderer" | "errorStateRenderer" | "emptyStateRenderer" | "tableEmptyStateRenderer" | "expandIcon" | "filterIcon" | "sortUpIcon" | "sortDownIcon" | "nextIcon" | "prevIcon" | "headerCollapseIcon" | "headerExpandIcon">;
81
82
  pinned?: Pinned;
83
+ quickFilterable?: boolean;
84
+ quickFilterGetter?: QuickFilterGetter;
82
85
  singleRowChildren?: boolean;
83
86
  tooltip?: string;
84
87
  type?: ColumnType;
@@ -0,0 +1,21 @@
1
+ import { Accessor } from "./HeaderObject";
2
+ import Row from "./Row";
3
+ export type QuickFilterMode = "simple" | "smart";
4
+ export interface QuickFilterConfig {
5
+ text: string;
6
+ columns?: Accessor[];
7
+ caseSensitive?: boolean;
8
+ mode?: QuickFilterMode;
9
+ useFormattedValue?: boolean;
10
+ onChange?: (text: string) => void;
11
+ }
12
+ export interface QuickFilterGetterProps {
13
+ row: Row;
14
+ accessor: Accessor;
15
+ }
16
+ export type QuickFilterGetter = (props: QuickFilterGetterProps) => string;
17
+ export interface SmartFilterToken {
18
+ type: "word" | "phrase" | "negation" | "columnSpecific";
19
+ value: string;
20
+ column?: Accessor;
21
+ }
@@ -19,6 +19,7 @@ import { CustomThemeProps } from "./CustomTheme";
19
19
  import { GetRowId } from "./GetRowId";
20
20
  import { ColumnEditorConfig } from "./ColumnEditorConfig";
21
21
  import { IconsConfig } from "./IconsConfig";
22
+ import { QuickFilterConfig } from "./QuickFilterTypes";
22
23
  export interface SimpleTableProps {
23
24
  allowAnimations?: boolean;
24
25
  autoExpandColumns?: boolean;
@@ -75,6 +76,7 @@ export interface SimpleTableProps {
75
76
  onRowSelectionChange?: (props: RowSelectionChangeProps) => void;
76
77
  onSortChange?: (sort: SortColumn | null) => void;
77
78
  prevIcon?: ReactNode;
79
+ quickFilter?: QuickFilterConfig;
78
80
  rowButtons?: RowButton[];
79
81
  rowGrouping?: Accessor[];
80
82
  getRowId?: GetRowId;
@@ -64,6 +64,8 @@ type TableRefType = {
64
64
  applyColumnVisibility: (visibility: {
65
65
  [accessor: string]: boolean;
66
66
  }) => Promise<void>;
67
+ /** Set the quick filter text programmatically. Triggers the onChange callback if provided in quickFilter config. */
68
+ setQuickFilter: (text: string) => void;
67
69
  };
68
70
  export default TableRefType;
69
71
  export type { SetHeaderRenameProps, ExportToCSVProps };
@@ -13,6 +13,7 @@ type TableRow = {
13
13
  rowIndexPath?: number[];
14
14
  stateIndicator?: {
15
15
  parentRowId: string | number;
16
+ parentRow: Row;
16
17
  state: RowState;
17
18
  };
18
19
  isLoadingSkeleton?: boolean;
@@ -0,0 +1,14 @@
1
+ import { SmartFilterToken } from "../types/QuickFilterTypes";
2
+ /**
3
+ * Parses a smart filter query into tokens
4
+ * Supports:
5
+ * - Multi-word: "john engineer" → matches rows containing both "john" AND "engineer"
6
+ * - Phrase: "john doe" → matches exact phrase
7
+ * - Negation: -inactive → excludes rows containing "inactive"
8
+ * - Column-specific: name:john → searches only in name column
9
+ */
10
+ export declare const parseSmartFilter: (query: string) => SmartFilterToken[];
11
+ /**
12
+ * Checks if a value matches a simple filter (case-insensitive contains)
13
+ */
14
+ export declare const matchesSimpleFilter: (value: string, filterText: string, caseSensitive: boolean) => boolean;
@@ -20,6 +20,33 @@ export declare const calculateNestedGridHeight: ({ childRowCount, rowHeight, hea
20
20
  headerHeight: number;
21
21
  customTheme: CustomTheme;
22
22
  }) => number;
23
+ /**
24
+ * Calculate the final wrapper height for a nested grid, accounting for custom heights
25
+ *
26
+ * @param calculatedHeight - The default calculated height based on child rows
27
+ * @param customHeight - Optional custom height from nestedTable config (e.g., "200px" or 200)
28
+ * @param customTheme - Custom theme configuration for padding
29
+ * @returns Final height in pixels for the wrapper (includes padding)
30
+ */
31
+ export declare const calculateFinalNestedGridHeight: ({ calculatedHeight, customHeight, customTheme, }: {
32
+ calculatedHeight: number;
33
+ customHeight?: string | number | undefined;
34
+ customTheme: CustomTheme;
35
+ }) => number;
36
+ /**
37
+ * Calculate the inner height for a nested SimpleTable component
38
+ * This accounts for the padding that's applied to the wrapper
39
+ *
40
+ * @param calculatedHeight - The total height of the nested grid row (from calculateNestedGridHeight)
41
+ * @param customHeight - Optional custom height from nestedTable config (e.g., "200px")
42
+ * @param customTheme - Custom theme configuration for padding
43
+ * @returns Height value to pass to the nested SimpleTable (string with units)
44
+ */
45
+ export declare const calculateNestedTableHeight: ({ calculatedHeight, customHeight, customTheme, }: {
46
+ calculatedHeight: number;
47
+ customHeight?: string | number | undefined;
48
+ customTheme: CustomTheme;
49
+ }) => string;
23
50
  /**
24
51
  * Get a nested property value from an object using dot notation and array bracket notation
25
52
  * Examples:
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.4.2",
2
+ "version": "2.4.4",
3
3
  "main": "dist/cjs/index.js",
4
4
  "module": "dist/index.es.js",
5
5
  "types": "dist/index.d.ts",
@@ -9,6 +9,9 @@
9
9
  "build-storybook": "storybook build",
10
10
  "preview": "rollup -c -w",
11
11
  "test-storybook": "test-storybook",
12
+ "test-storybook:watch": "test-storybook --watch",
13
+ "test-storybook:coverage": "test-storybook --coverage",
14
+ "test-storybook:ci": "test-storybook --url http://localhost:6006",
12
15
  "version:patch": "npm version patch && git push && git push --tags",
13
16
  "version:minor": "npm version minor && git push && git push --tags",
14
17
  "version:major": "npm version major && git push && git push --tags"
@@ -1 +0,0 @@
1
- {"version":3,"file":"Animate-a00b8653.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import{u as e,b as n}from"./index-fe1a2c58.js";import{jsxs as t,Fragment as a,jsx as r}from"react/jsx-runtime";import{useState as c}from"react";var i=function(i){var d,o,s=i.onChange,l=i.onClose,u=i.value,f=e(),h=f.nextIcon,m=f.prevIcon,v=c(u||new Date),k=v[0],p=v[1],w=c("days"),y=w[0],D=w[1],N=function(e,n){return new Date(e,n+1,0).getDate()};return t("div",n({className:"st-datepicker"},{children:[t("div",n({className:"st-datepicker-header"},{children:["days"===y&&t(a,{children:[r("button",n({onClick:function(){p(new Date(k.getFullYear(),k.getMonth()-1,1))},className:"st-datepicker-nav-btn"},{children:m})),t("div",n({className:"st-datepicker-header-label",onClick:function(){return D("months")}},{children:[(o=k,o.toLocaleString("default",{month:"long"}))," ",k.getFullYear()]})),r("button",n({onClick:function(){p(new Date(k.getFullYear(),k.getMonth()+1,1))},className:"st-datepicker-nav-btn"},{children:h}))]}),"months"===y&&r("div",n({className:"st-datepicker-header-label",onClick:function(){return D("years")}},{children:k.getFullYear()})),"years"===y&&r("div",n({className:"st-datepicker-header-label"},{children:"Select Year"}))]})),t("div",n({className:"st-datepicker-grid st-datepicker-".concat(y,"-grid")},{children:["days"===y&&function(){var e=[],t=k.getFullYear(),a=k.getMonth(),c=N(t,a),i=function(e,n){return new Date(e,n,1).getDay()}(t,a),d=N(t,a-1);["Su","Mo","Tu","We","Th","Fr","Sa"].forEach(function(t,a){e.push(r("div",n({className:"st-datepicker-weekday"},{children:t}),"header-".concat(a)))});for(var o=function(t){var a=d-i+t+1;e.push(r("div",n({className:"st-datepicker-day other-month",onClick:function(){return function(e){var n=new Date(k.getFullYear(),k.getMonth()-1,e,12,0,0);p(n),s(n),null==l||l()}(a)}},{children:a}),"prev-".concat(a)))},f=0;i>f;f++)o(f);for(var h=function(c){var i=c===(new Date).getDate()&&a===(new Date).getMonth()&&t===(new Date).getFullYear(),d=new Date(u),o=c===d.getDate()&&a===d.getMonth()&&t===d.getFullYear();e.push(r("div",n({className:"st-datepicker-day ".concat(i?"today":""," ").concat(o?"selected":""),onClick:function(){return function(e){var n=k.getFullYear(),t=k.getMonth(),a=new Date(n,t,e,12,0,0);p(a),s(a),null==l||l()}(c)}},{children:c}),"day-".concat(c)))},m=1;c>=m;m++)h(m);var v=35-(i+c),w=function(t){e.push(r("div",n({className:"st-datepicker-day other-month",onClick:function(){return function(e){var n=new Date(k.getFullYear(),k.getMonth()+1,e,12,0,0);p(n),s(n),null==l||l()}(t)}},{children:t}),"next-".concat(t)))};for(m=1;v>=m;m++)w(m);return e}(),"months"===y&&(d=[],Array.from({length:12},function(e,n){return new Date(2e3,n,1).toLocaleString("default",{month:"short"})}).forEach(function(e,t){var a=t===k.getMonth();d.push(r("div",n({className:"st-datepicker-month ".concat(a?"selected":""),onClick:function(){return function(e){p(new Date(k.getFullYear(),e,1)),D("days")}(t)}},{children:e}),"month-".concat(t)))}),d),"years"===y&&function(){for(var e=[],t=k.getFullYear(),a=t-6,c=function(a){e.push(r("div",n({className:"st-datepicker-year ".concat(a===t?"selected":""),onClick:function(){return function(e){p(new Date(e,k.getMonth(),1)),D("months")}(a)}},{children:a}),"year-".concat(a)))},i=a;a+12>i;i++)c(i);return e}()]})),r("div",n({className:"st-datepicker-footer"},{children:r("button",n({className:"st-datepicker-today-btn",onClick:function(){var e=new Date,n=new Date(e.getFullYear(),e.getMonth(),e.getDate(),12,0,0);p(n),s(n),null==l||l()}},{children:"Today"}))}))]}))};export{i as default};
2
- //# sourceMappingURL=DatePicker-91f87634.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DatePicker-91f87634.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Animate-b6372d93.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";var e=require("./index-e0379c0f.js"),n=require("react/jsx-runtime"),t=require("react");exports.default=function(a){var r,c,i=a.onChange,d=a.onClose,s=a.value,l=e.useTableContext(),o=l.nextIcon,u=l.prevIcon,h=t.useState(s||new Date),f=h[0],v=h[1],k=t.useState("days"),m=k[0],p=k[1],w=function(e,n){return new Date(e,n+1,0).getDate()};return n.jsxs("div",e.__assign({className:"st-datepicker"},{children:[n.jsxs("div",e.__assign({className:"st-datepicker-header"},{children:["days"===m&&n.jsxs(n.Fragment,{children:[n.jsx("button",e.__assign({onClick:function(){v(new Date(f.getFullYear(),f.getMonth()-1,1))},className:"st-datepicker-nav-btn"},{children:u})),n.jsxs("div",e.__assign({className:"st-datepicker-header-label",onClick:function(){return p("months")}},{children:[(c=f,c.toLocaleString("default",{month:"long"}))," ",f.getFullYear()]})),n.jsx("button",e.__assign({onClick:function(){v(new Date(f.getFullYear(),f.getMonth()+1,1))},className:"st-datepicker-nav-btn"},{children:o}))]}),"months"===m&&n.jsx("div",e.__assign({className:"st-datepicker-header-label",onClick:function(){return p("years")}},{children:f.getFullYear()})),"years"===m&&n.jsx("div",e.__assign({className:"st-datepicker-header-label"},{children:"Select Year"}))]})),n.jsxs("div",e.__assign({className:"st-datepicker-grid st-datepicker-".concat(m,"-grid")},{children:["days"===m&&function(){var t=[],a=f.getFullYear(),r=f.getMonth(),c=w(a,r),l=function(e,n){return new Date(e,n,1).getDay()}(a,r),o=w(a,r-1);["Su","Mo","Tu","We","Th","Fr","Sa"].forEach(function(a,r){t.push(n.jsx("div",e.__assign({className:"st-datepicker-weekday"},{children:a}),"header-".concat(r)))});for(var u=function(a){var r=o-l+a+1;t.push(n.jsx("div",e.__assign({className:"st-datepicker-day other-month",onClick:function(){return function(e){var n=new Date(f.getFullYear(),f.getMonth()-1,e,12,0,0);v(n),i(n),null==d||d()}(r)}},{children:r}),"prev-".concat(r)))},h=0;l>h;h++)u(h);for(var k=function(c){var l=c===(new Date).getDate()&&r===(new Date).getMonth()&&a===(new Date).getFullYear(),o=new Date(s),u=c===o.getDate()&&r===o.getMonth()&&a===o.getFullYear();t.push(n.jsx("div",e.__assign({className:"st-datepicker-day ".concat(l?"today":""," ").concat(u?"selected":""),onClick:function(){return function(e){var n=f.getFullYear(),t=f.getMonth(),a=new Date(n,t,e,12,0,0);v(a),i(a),null==d||d()}(c)}},{children:c}),"day-".concat(c)))},m=1;c>=m;m++)k(m);var p=35-(l+c),y=function(a){t.push(n.jsx("div",e.__assign({className:"st-datepicker-day other-month",onClick:function(){return function(e){var n=new Date(f.getFullYear(),f.getMonth()+1,e,12,0,0);v(n),i(n),null==d||d()}(a)}},{children:a}),"next-".concat(a)))};for(m=1;p>=m;m++)y(m);return t}(),"months"===m&&(r=[],Array.from({length:12},function(e,n){return new Date(2e3,n,1).toLocaleString("default",{month:"short"})}).forEach(function(t,a){var c=a===f.getMonth();r.push(n.jsx("div",e.__assign({className:"st-datepicker-month ".concat(c?"selected":""),onClick:function(){return function(e){v(new Date(f.getFullYear(),e,1)),p("days")}(a)}},{children:t}),"month-".concat(a)))}),r),"years"===m&&function(){for(var t=[],a=f.getFullYear(),r=a-6,c=function(r){t.push(n.jsx("div",e.__assign({className:"st-datepicker-year ".concat(r===a?"selected":""),onClick:function(){return function(e){v(new Date(e,f.getMonth(),1)),p("months")}(r)}},{children:r}),"year-".concat(r)))},i=r;r+12>i;i++)c(i);return t}()]})),n.jsx("div",e.__assign({className:"st-datepicker-footer"},{children:n.jsx("button",e.__assign({className:"st-datepicker-today-btn",onClick:function(){var e=new Date,n=new Date(e.getFullYear(),e.getMonth(),e.getDate(),12,0,0);v(n),i(n),null==d||d()}},{children:"Today"}))}))]}))};
2
- //# sourceMappingURL=DatePicker-7bfd609b.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DatePicker-7bfd609b.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}