@gobolt/genesis 0.4.32 → 0.4.33

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.
@@ -1,3 +1,3 @@
1
1
  import { InfiniteScrollTableProps } from './types';
2
- declare const InfiniteScrollTable: <T>({ columns: initialColumns, fetchService, title, scrollHeight, scrollWidth, useWindowScroll, onChange, rowSelection, onRowClick, onRowSelectionChange, onDataChange, filterFn, }: InfiniteScrollTableProps<T>) => import("react/jsx-runtime").JSX.Element;
2
+ declare const InfiniteScrollTable: <T>({ columns: initialColumns, fetchService, title, scrollHeight, scrollWidth, useWindowScroll, onChange, rowSelection, onRowClick, onRowSelectionChange, onDataChange, filterFn, hasBulkSelection, }: InfiniteScrollTableProps<T>) => import("react/jsx-runtime").JSX.Element;
3
3
  export default InfiniteScrollTable;
@@ -54,6 +54,7 @@ export interface TableProps<T extends Record<string, any>> {
54
54
  index: number;
55
55
  error: Error;
56
56
  }) => void;
57
+ hasBulkSelection?: boolean;
57
58
  }
58
59
  export type TablePaginationType = {
59
60
  pageSize?: number;
@@ -67,5 +68,5 @@ export type SorterResult<T> = {
67
68
  field?: keyof T | string | React.Key | readonly React.Key[];
68
69
  columnKey?: React.Key;
69
70
  };
70
- declare function Table<T extends Record<string, any>>({ columns, dataSource, rowKey, size, onChange, rowSelection, onRowClick, onRowSelectionChange, onDataChange, pagination, isMainContentCell, isInfiniteScroll, infiniteScrollConfig, enableRowKeyValidation, onRowKeyError, ...rest }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
71
+ declare function Table<T extends Record<string, any>>({ columns, dataSource, rowKey, size, onChange, rowSelection, onRowClick, onRowSelectionChange, onDataChange, pagination, isMainContentCell, isInfiniteScroll, infiniteScrollConfig, enableRowKeyValidation, onRowKeyError, hasBulkSelection, ...rest }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
71
72
  export default Table;
@@ -10,6 +10,7 @@ export interface TablePaginationProps<T> {
10
10
  paginationStyle?: PaginationStyle;
11
11
  pageSize?: number;
12
12
  isMainContentCell?: boolean;
13
+ hasBulkSelection?: boolean;
13
14
  }
14
- declare const TablePagination: <T extends Record<string, any>>({ columns, dataSource, rowSelection, onChange, onRowClick, paginationStyle, pageSize, isMainContentCell, }: TablePaginationProps<T>) => import("react/jsx-runtime").JSX.Element;
15
+ declare const TablePagination: <T extends Record<string, any>>({ columns, dataSource, rowSelection, onChange, onRowClick, paginationStyle, pageSize, isMainContentCell, hasBulkSelection, }: TablePaginationProps<T>) => import("react/jsx-runtime").JSX.Element;
15
16
  export default TablePagination;
@@ -15,8 +15,9 @@ export type UseTableConfig = {
15
15
  hasFilter?: boolean;
16
16
  disableAutoFetch?: boolean;
17
17
  dataSource?: any[];
18
+ hasBulkSelection?: boolean;
18
19
  };
19
- export declare const useTable: <T extends Record<string, any>>(useTableConfig: any) => {
20
+ export declare const useTable: <T extends Record<string, any>>(useTableConfig: UseTableConfig) => {
20
21
  dataSource: (T & {
21
22
  isSelected: boolean;
22
23
  })[];
@@ -30,7 +31,7 @@ export declare const useTable: <T extends Record<string, any>>(useTableConfig: a
30
31
  disabled?: boolean;
31
32
  name?: string;
32
33
  };
33
- };
34
+ } | undefined;
34
35
  selectedRows: T[];
35
36
  selectedRowKeys: import('react').Key[];
36
37
  hasSettings: boolean;
@@ -16,6 +16,7 @@ export interface TableWithControlsProps {
16
16
  onRowClick?: (record: Record<string, any>, index: number, event: React.MouseEvent) => void;
17
17
  onRowSelectionChange?: (setSelectedRowKeys: (keys: React.Key[]) => void) => void;
18
18
  onDataChange?: (data: Record<string, any>[]) => void;
19
+ hasBulkSelection?: boolean;
19
20
  }
20
- declare const TableWithControls: ({ tableData, tableControlsData, onChange, onRowClick, onRowSelectionChange, onDataChange, tableType, isInfiniteScroll, infiniteScrollConfig, paginationStyle, }: TableWithControlsProps) => import("react/jsx-runtime").JSX.Element;
21
+ declare const TableWithControls: ({ tableData, tableControlsData, onChange, onRowClick, onRowSelectionChange, onDataChange, tableType, isInfiniteScroll, infiniteScrollConfig, paginationStyle, hasBulkSelection, }: TableWithControlsProps) => import("react/jsx-runtime").JSX.Element;
21
22
  export default TableWithControls;
@@ -30,7 +30,7 @@ export declare const useTableWithControls: (tableConfig: UseTableConfig) => {
30
30
  disabled?: boolean;
31
31
  name?: string;
32
32
  };
33
- };
33
+ } | undefined;
34
34
  selectedRows: Record<string, any>[];
35
35
  selectedRowKeys: import('react').Key[];
36
36
  updateDataSource: (newDataSource: Record<string, any>[]) => void;
package/dist/index.cjs CHANGED
@@ -84825,7 +84825,8 @@ const InfiniteScrollTable = ({
84825
84825
  onRowClick,
84826
84826
  onRowSelectionChange,
84827
84827
  onDataChange,
84828
- filterFn
84828
+ filterFn,
84829
+ hasBulkSelection = true
84829
84830
  }) => {
84830
84831
  const observer = React.useRef();
84831
84832
  const [scrollableNode, setScrollableNode] = React.useState(
@@ -85002,7 +85003,7 @@ const InfiniteScrollTable = ({
85002
85003
  scroll: useWindowScroll ? { x: scrollWidth } : { y: scrollHeight, x: scrollWidth },
85003
85004
  onChange: () => {
85004
85005
  },
85005
- rowSelection: finalRowSelection,
85006
+ ...hasBulkSelection ? { rowSelection: finalRowSelection } : {},
85006
85007
  onRow: (record, index2) => {
85007
85008
  const rowProps = {};
85008
85009
  if (index2 === dataSource.length - 1) {
@@ -85108,6 +85109,7 @@ function Table({
85108
85109
  infiniteScrollConfig,
85109
85110
  enableRowKeyValidation = process.env.NODE_ENV === "development",
85110
85111
  onRowKeyError,
85112
+ hasBulkSelection = true,
85111
85113
  ...rest
85112
85114
  }) {
85113
85115
  const [selectedRowKeys, setSelectedRowKeys] = React__namespace.useState([]);
@@ -85160,7 +85162,8 @@ function Table({
85160
85162
  useWindowScroll: infiniteScrollConfig.useWindowScroll,
85161
85163
  onChange: isInfiniteScroll ? onChange : onChange,
85162
85164
  onRowSelectionChange,
85163
- onDataChange
85165
+ onDataChange,
85166
+ hasBulkSelection
85164
85167
  }
85165
85168
  );
85166
85169
  }
@@ -85284,7 +85287,7 @@ function Table({
85284
85287
  locale: { emptyText: "No Data" },
85285
85288
  size,
85286
85289
  onChange,
85287
- rowSelection: enhancedRowSelection,
85290
+ ...hasBulkSelection ? { rowSelection: enhancedRowSelection } : {},
85288
85291
  onRow: (record, index2) => {
85289
85292
  const isDisabled = rowSelection?.getCheckboxProps?.(record)?.disabled ?? false;
85290
85293
  const recordKey = getRowKey(
@@ -85323,7 +85326,8 @@ const TablePagination = ({
85323
85326
  onRowClick,
85324
85327
  paginationStyle = PaginationStyle.SIMPLE,
85325
85328
  pageSize = 10,
85326
- isMainContentCell
85329
+ isMainContentCell,
85330
+ hasBulkSelection = true
85327
85331
  }) => {
85328
85332
  const [current, setCurrent] = React.useState(1);
85329
85333
  const total = dataSource.length;
@@ -85337,7 +85341,7 @@ const TablePagination = ({
85337
85341
  {
85338
85342
  columns,
85339
85343
  dataSource: paginatedData,
85340
- rowSelection,
85344
+ ...hasBulkSelection ? { rowSelection } : {},
85341
85345
  onChange,
85342
85346
  onRowClick,
85343
85347
  pagination: false,
@@ -85389,7 +85393,8 @@ const useTable = (useTableConfig) => {
85389
85393
  hasSettings = true,
85390
85394
  hasFilter = true,
85391
85395
  disableAutoFetch = false,
85392
- dataSource: initialDataSource = []
85396
+ dataSource: initialDataSource = [],
85397
+ hasBulkSelection = true
85393
85398
  } = useTableConfig;
85394
85399
  const [originalData, setOriginalData] = React.useState(initialDataSource);
85395
85400
  const [data, setData] = React.useState({
@@ -85407,6 +85412,11 @@ const useTable = (useTableConfig) => {
85407
85412
  if (disableAutoFetch) {
85408
85413
  isDisabledRef.current = true;
85409
85414
  setLoading(false);
85415
+ setData({
85416
+ dataSource: initialDataSource,
85417
+ columns,
85418
+ error: null
85419
+ });
85410
85420
  return;
85411
85421
  }
85412
85422
  if (hasFetchedRef.current || hasErrored || isDisabledRef.current) {
@@ -85485,12 +85495,12 @@ const useTable = (useTableConfig) => {
85485
85495
  isDisabledRef.current = false;
85486
85496
  setLoading(true);
85487
85497
  }, []);
85488
- const rowSelection = {
85498
+ const rowSelection = hasBulkSelection ? {
85489
85499
  type: selectionType,
85490
85500
  selectedRowKeys,
85491
85501
  onChange: handleRowSelection,
85492
85502
  getCheckboxProps: disableRowSelection
85493
- };
85503
+ } : void 0;
85494
85504
  const enhancedDataSource = React.useMemo(() => {
85495
85505
  return data.dataSource.map((record) => {
85496
85506
  const isSelected = selectedRowKeys.includes(record.id);
@@ -85862,7 +85872,8 @@ const TableWithControls = ({
85862
85872
  tableType = "table",
85863
85873
  isInfiniteScroll,
85864
85874
  infiniteScrollConfig,
85865
- paginationStyle
85875
+ paginationStyle,
85876
+ hasBulkSelection = true
85866
85877
  }) => {
85867
85878
  const [infiniteScrollData, setInfiniteScrollData] = React.useState({
85868
85879
  totalPages: 0,
@@ -85921,7 +85932,8 @@ const TableWithControls = ({
85921
85932
  scrollWidth: infiniteScrollConfig.scrollWidth,
85922
85933
  useWindowScroll: infiniteScrollConfig.useWindowScroll,
85923
85934
  onChange: onInfiniteScrollTableChange,
85924
- rowSelection,
85935
+ ...hasBulkSelection ? { rowSelection } : {},
85936
+ hasBulkSelection,
85925
85937
  onRowClick: tableOnRowClick || onRowClick,
85926
85938
  onRowSelectionChange,
85927
85939
  onDataChange
@@ -85934,7 +85946,7 @@ const TableWithControls = ({
85934
85946
  {
85935
85947
  dataSource,
85936
85948
  columns,
85937
- rowSelection,
85949
+ ...hasBulkSelection ? { rowSelection } : {},
85938
85950
  onChange: onTableChange,
85939
85951
  onRowClick,
85940
85952
  paginationStyle
@@ -85948,7 +85960,7 @@ const TableWithControls = ({
85948
85960
  {
85949
85961
  dataSource,
85950
85962
  columns,
85951
- rowSelection,
85963
+ ...hasBulkSelection ? { rowSelection } : {},
85952
85964
  onChange: onTableChange,
85953
85965
  onRowClick,
85954
85966
  onRowSelectionChange
package/dist/index.js CHANGED
@@ -84807,7 +84807,8 @@ const InfiniteScrollTable = ({
84807
84807
  onRowClick,
84808
84808
  onRowSelectionChange,
84809
84809
  onDataChange,
84810
- filterFn
84810
+ filterFn,
84811
+ hasBulkSelection = true
84811
84812
  }) => {
84812
84813
  const observer = useRef();
84813
84814
  const [scrollableNode, setScrollableNode] = useState(
@@ -84984,7 +84985,7 @@ const InfiniteScrollTable = ({
84984
84985
  scroll: useWindowScroll ? { x: scrollWidth } : { y: scrollHeight, x: scrollWidth },
84985
84986
  onChange: () => {
84986
84987
  },
84987
- rowSelection: finalRowSelection,
84988
+ ...hasBulkSelection ? { rowSelection: finalRowSelection } : {},
84988
84989
  onRow: (record, index2) => {
84989
84990
  const rowProps = {};
84990
84991
  if (index2 === dataSource.length - 1) {
@@ -85090,6 +85091,7 @@ function Table({
85090
85091
  infiniteScrollConfig,
85091
85092
  enableRowKeyValidation = process.env.NODE_ENV === "development",
85092
85093
  onRowKeyError,
85094
+ hasBulkSelection = true,
85093
85095
  ...rest
85094
85096
  }) {
85095
85097
  const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
@@ -85142,7 +85144,8 @@ function Table({
85142
85144
  useWindowScroll: infiniteScrollConfig.useWindowScroll,
85143
85145
  onChange: isInfiniteScroll ? onChange : onChange,
85144
85146
  onRowSelectionChange,
85145
- onDataChange
85147
+ onDataChange,
85148
+ hasBulkSelection
85146
85149
  }
85147
85150
  );
85148
85151
  }
@@ -85266,7 +85269,7 @@ function Table({
85266
85269
  locale: { emptyText: "No Data" },
85267
85270
  size,
85268
85271
  onChange,
85269
- rowSelection: enhancedRowSelection,
85272
+ ...hasBulkSelection ? { rowSelection: enhancedRowSelection } : {},
85270
85273
  onRow: (record, index2) => {
85271
85274
  const isDisabled = rowSelection?.getCheckboxProps?.(record)?.disabled ?? false;
85272
85275
  const recordKey = getRowKey(
@@ -85305,7 +85308,8 @@ const TablePagination = ({
85305
85308
  onRowClick,
85306
85309
  paginationStyle = PaginationStyle.SIMPLE,
85307
85310
  pageSize = 10,
85308
- isMainContentCell
85311
+ isMainContentCell,
85312
+ hasBulkSelection = true
85309
85313
  }) => {
85310
85314
  const [current, setCurrent] = useState(1);
85311
85315
  const total = dataSource.length;
@@ -85319,7 +85323,7 @@ const TablePagination = ({
85319
85323
  {
85320
85324
  columns,
85321
85325
  dataSource: paginatedData,
85322
- rowSelection,
85326
+ ...hasBulkSelection ? { rowSelection } : {},
85323
85327
  onChange,
85324
85328
  onRowClick,
85325
85329
  pagination: false,
@@ -85371,7 +85375,8 @@ const useTable = (useTableConfig) => {
85371
85375
  hasSettings = true,
85372
85376
  hasFilter = true,
85373
85377
  disableAutoFetch = false,
85374
- dataSource: initialDataSource = []
85378
+ dataSource: initialDataSource = [],
85379
+ hasBulkSelection = true
85375
85380
  } = useTableConfig;
85376
85381
  const [originalData, setOriginalData] = useState(initialDataSource);
85377
85382
  const [data, setData] = useState({
@@ -85389,6 +85394,11 @@ const useTable = (useTableConfig) => {
85389
85394
  if (disableAutoFetch) {
85390
85395
  isDisabledRef.current = true;
85391
85396
  setLoading(false);
85397
+ setData({
85398
+ dataSource: initialDataSource,
85399
+ columns,
85400
+ error: null
85401
+ });
85392
85402
  return;
85393
85403
  }
85394
85404
  if (hasFetchedRef.current || hasErrored || isDisabledRef.current) {
@@ -85467,12 +85477,12 @@ const useTable = (useTableConfig) => {
85467
85477
  isDisabledRef.current = false;
85468
85478
  setLoading(true);
85469
85479
  }, []);
85470
- const rowSelection = {
85480
+ const rowSelection = hasBulkSelection ? {
85471
85481
  type: selectionType,
85472
85482
  selectedRowKeys,
85473
85483
  onChange: handleRowSelection,
85474
85484
  getCheckboxProps: disableRowSelection
85475
- };
85485
+ } : void 0;
85476
85486
  const enhancedDataSource = useMemo$1(() => {
85477
85487
  return data.dataSource.map((record) => {
85478
85488
  const isSelected = selectedRowKeys.includes(record.id);
@@ -85844,7 +85854,8 @@ const TableWithControls = ({
85844
85854
  tableType = "table",
85845
85855
  isInfiniteScroll,
85846
85856
  infiniteScrollConfig,
85847
- paginationStyle
85857
+ paginationStyle,
85858
+ hasBulkSelection = true
85848
85859
  }) => {
85849
85860
  const [infiniteScrollData, setInfiniteScrollData] = useState({
85850
85861
  totalPages: 0,
@@ -85903,7 +85914,8 @@ const TableWithControls = ({
85903
85914
  scrollWidth: infiniteScrollConfig.scrollWidth,
85904
85915
  useWindowScroll: infiniteScrollConfig.useWindowScroll,
85905
85916
  onChange: onInfiniteScrollTableChange,
85906
- rowSelection,
85917
+ ...hasBulkSelection ? { rowSelection } : {},
85918
+ hasBulkSelection,
85907
85919
  onRowClick: tableOnRowClick || onRowClick,
85908
85920
  onRowSelectionChange,
85909
85921
  onDataChange
@@ -85916,7 +85928,7 @@ const TableWithControls = ({
85916
85928
  {
85917
85929
  dataSource,
85918
85930
  columns,
85919
- rowSelection,
85931
+ ...hasBulkSelection ? { rowSelection } : {},
85920
85932
  onChange: onTableChange,
85921
85933
  onRowClick,
85922
85934
  paginationStyle
@@ -85930,7 +85942,7 @@ const TableWithControls = ({
85930
85942
  {
85931
85943
  dataSource,
85932
85944
  columns,
85933
- rowSelection,
85945
+ ...hasBulkSelection ? { rowSelection } : {},
85934
85946
  onChange: onTableChange,
85935
85947
  onRowClick,
85936
85948
  onRowSelectionChange
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobolt/genesis",
3
- "version": "0.4.32",
3
+ "version": "0.4.33",
4
4
  "description": "genesis design system",
5
5
  "author": "gobolt",
6
6
  "license": "MIT",