@gobolt/genesis 0.4.9 → 0.4.11

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,4 @@
1
+ import { default as React } from 'react';
1
2
  import { PaginationStyle } from './TableControls/CustomPagination';
2
3
  import { ColumnType } from 'antd/es/table';
3
4
  export interface TablePaginationProps<T> {
@@ -5,9 +6,10 @@ export interface TablePaginationProps<T> {
5
6
  dataSource: T[];
6
7
  rowSelection?: any;
7
8
  onChange?: (...arguments_: any[]) => void;
9
+ onRowClick?: (record: T, index: number, event: React.MouseEvent) => void;
8
10
  paginationStyle?: PaginationStyle;
9
11
  pageSize?: number;
10
12
  isMainContentCell?: boolean;
11
13
  }
12
- declare const TablePagination: <T extends Record<string, any>>({ columns, dataSource, rowSelection, onChange, paginationStyle, pageSize, isMainContentCell, }: TablePaginationProps<T>) => import("react/jsx-runtime").JSX.Element;
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;
13
15
  export default TablePagination;
package/dist/index.cjs CHANGED
@@ -77647,8 +77647,10 @@ const Tooltip2 = ({
77647
77647
  }
77648
77648
  ) }),
77649
77649
  open: isVisible2,
77650
- overlayStyle: {
77651
- pointerEvents: "none"
77650
+ styles: {
77651
+ root: {
77652
+ pointerEvents: "none"
77653
+ }
77652
77654
  },
77653
77655
  children: children2
77654
77656
  }
@@ -83525,6 +83527,12 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83525
83527
  background-color: ${components2.tableCell.selected} !important;
83526
83528
  color: #fff !important;
83527
83529
  }
83530
+
83531
+ .ant-table-tbody > tr.ant-table-row-pressed > td,
83532
+ .ant-table-tbody > tr.ant-table-row-pressed > .ant-table-cell {
83533
+ background-color: ${components2.tableCell.selected} !important;
83534
+ color: #fff !important;
83535
+ }
83528
83536
  `;
83529
83537
  };
83530
83538
  const Table$1 = styled(ForwardTable)`
@@ -83989,6 +83997,9 @@ function Table({
83989
83997
  400
83990
83998
  );
83991
83999
  const [selectedRowKeys, setSelectedRowKeys] = React__namespace.useState([]);
84000
+ const [pressedRowKey, setPressedRowKey] = React__namespace.useState(
84001
+ null
84002
+ );
83992
84003
  const tableRef = React__namespace.useRef(null);
83993
84004
  const containerRef = React__namespace.useRef(null);
83994
84005
  React__namespace.useEffect(() => {
@@ -84091,44 +84102,85 @@ function Table({
84091
84102
  return rest.scroll;
84092
84103
  }, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
84093
84104
  const tableDataSource = isMaterializedView ? materializedData : dataSource;
84094
- const handleRowClick = React__namespace.useCallback(
84105
+ React__namespace.useEffect(() => {
84106
+ if (tableDataSource && tableDataSource.length > 0) {
84107
+ console.log(
84108
+ "Genesis Table - tableDataSource length:",
84109
+ tableDataSource.length
84110
+ );
84111
+ console.log("Genesis Table - rowKey type:", typeof rowKey);
84112
+ tableDataSource.slice(0, 3).map((record, index2) => {
84113
+ const key = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84114
+ console.log(
84115
+ `Genesis Table - Record ${index2} key:`,
84116
+ key,
84117
+ "Record:",
84118
+ record
84119
+ );
84120
+ return key;
84121
+ });
84122
+ const allKeys = tableDataSource.map(
84123
+ (record) => typeof rowKey === "function" ? rowKey(record) : record[rowKey]
84124
+ );
84125
+ const uniqueKeys = [...new Set(allKeys)];
84126
+ console.log(
84127
+ `Genesis Table - Total keys: ${allKeys.length}, Unique keys: ${uniqueKeys.length}`
84128
+ );
84129
+ if (allKeys.length !== uniqueKeys.length) {
84130
+ console.error("Genesis Table - DUPLICATE KEYS FOUND:", allKeys);
84131
+ const duplicates = allKeys.filter(
84132
+ (key, index2) => allKeys.indexOf(key) !== index2
84133
+ );
84134
+ console.error("Genesis Table - Duplicate keys:", [
84135
+ ...new Set(duplicates)
84136
+ ]);
84137
+ }
84138
+ }
84139
+ }, [tableDataSource, rowKey]);
84140
+ const handleRowMouseDown = React__namespace.useCallback(
84095
84141
  (record, index2, event) => {
84096
- console.log("Row clicked:", record, "index:", index2);
84097
84142
  const target = event.target;
84098
84143
  const isInteractiveElement = target.closest(
84099
- 'button, a, input, select, textarea, [role="button"], [onclick]'
84144
+ 'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
84100
84145
  );
84101
- console.log("Is interactive element:", isInteractiveElement);
84102
84146
  if (isInteractiveElement) {
84103
- console.log("Skipping row selection due to interactive element");
84104
84147
  return;
84105
84148
  }
84106
- if (!rowSelection || !rowSelection.onChange) {
84107
- console.log("No row selection or onChange handler");
84149
+ const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84150
+ setPressedRowKey(recordKey);
84151
+ },
84152
+ [rowKey]
84153
+ );
84154
+ const handleRowMouseUp = React__namespace.useCallback(
84155
+ (record, index2, event) => {
84156
+ setPressedRowKey(null);
84157
+ },
84158
+ []
84159
+ );
84160
+ const handleRowClick = React__namespace.useCallback(
84161
+ (record, index2, event) => {
84162
+ console.log("Genesis Table - Row clicked:", record, "index:", index2);
84163
+ console.log("Genesis Table - onRowClick function:", onRowClick);
84164
+ const target = event.target;
84165
+ const isInteractiveElement = target.closest(
84166
+ 'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
84167
+ );
84168
+ console.log("Genesis Table - Target element:", target);
84169
+ console.log("Genesis Table - Target tagName:", target.tagName);
84170
+ console.log("Genesis Table - Target className:", target.className);
84171
+ console.log("Genesis Table - Is interactive element:", isInteractiveElement);
84172
+ if (isInteractiveElement) {
84173
+ console.log("Genesis Table - Skipping row click due to interactive element");
84108
84174
  return;
84109
84175
  }
84110
- if (rowSelection.getCheckboxProps) {
84111
- const checkboxProps = rowSelection.getCheckboxProps(record);
84112
- if (checkboxProps.disabled) {
84113
- console.log("Row is disabled for selection:", record);
84114
- return;
84115
- }
84176
+ if (onRowClick) {
84177
+ console.log("Genesis Table - Calling onRowClick function");
84178
+ onRowClick(record, index2, event);
84179
+ } else {
84180
+ console.log("Genesis Table - onRowClick not provided");
84116
84181
  }
84117
- const currentSelectedKeys = selectedRowKeys;
84118
- const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84119
- console.log("Current selected keys:", currentSelectedKeys);
84120
- console.log("Record key:", recordKey);
84121
- const newSelectedKeys = currentSelectedKeys.includes(recordKey) ? currentSelectedKeys.filter((key) => key !== recordKey) : [...currentSelectedKeys, recordKey];
84122
- console.log("New selected keys:", newSelectedKeys);
84123
- setSelectedRowKeys(newSelectedKeys);
84124
- const selectedRows = tableDataSource.filter((record2) => {
84125
- const key = typeof rowKey === "function" ? rowKey(record2) : record2[rowKey];
84126
- return newSelectedKeys.includes(key);
84127
- });
84128
- console.log("Selected rows:", selectedRows);
84129
- rowSelection.onChange(newSelectedKeys, selectedRows);
84130
84182
  },
84131
- [rowSelection, rowKey, tableDataSource, selectedRowKeys]
84183
+ [onRowClick]
84132
84184
  );
84133
84185
  const enhancedRowSelection = React__namespace.useMemo(() => {
84134
84186
  if (!rowSelection) return;
@@ -84160,12 +84212,19 @@ function Table({
84160
84212
  rowSelection: enhancedRowSelection,
84161
84213
  onRow: (record, index2) => {
84162
84214
  const isDisabled = rowSelection?.getCheckboxProps?.(record)?.disabled ?? false;
84215
+ const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84216
+ const isPressed = pressedRowKey === recordKey;
84163
84217
  return {
84164
84218
  onClick: (event) => handleRowClick(record, index2 ?? 0, event),
84219
+ onMouseDown: (event) => handleRowMouseDown(record, index2 ?? 0, event),
84220
+ onMouseUp: (event) => handleRowMouseUp(record, index2 ?? 0, event),
84221
+ onMouseLeave: () => setPressedRowKey(null),
84222
+ // Clear pressed state when mouse leaves
84165
84223
  style: {
84166
- cursor: rowSelection && !isDisabled ? "pointer" : "default",
84224
+ cursor: onRowClick ? "pointer" : "default",
84167
84225
  opacity: isDisabled ? 0.6 : 1
84168
- }
84226
+ },
84227
+ className: isPressed ? "ant-table-row-pressed" : ""
84169
84228
  };
84170
84229
  },
84171
84230
  pagination: paginationConfig,
@@ -84181,6 +84240,7 @@ const TablePagination = ({
84181
84240
  dataSource,
84182
84241
  rowSelection,
84183
84242
  onChange,
84243
+ onRowClick,
84184
84244
  paginationStyle = PaginationStyle.SIMPLE,
84185
84245
  pageSize = 10,
84186
84246
  isMainContentCell
@@ -84199,6 +84259,7 @@ const TablePagination = ({
84199
84259
  dataSource: paginatedData,
84200
84260
  rowSelection,
84201
84261
  onChange,
84262
+ onRowClick,
84202
84263
  pagination: false,
84203
84264
  isMainContentCell
84204
84265
  }
package/dist/index.js CHANGED
@@ -77629,8 +77629,10 @@ const Tooltip2 = ({
77629
77629
  }
77630
77630
  ) }),
77631
77631
  open: isVisible2,
77632
- overlayStyle: {
77633
- pointerEvents: "none"
77632
+ styles: {
77633
+ root: {
77634
+ pointerEvents: "none"
77635
+ }
77634
77636
  },
77635
77637
  children: children2
77636
77638
  }
@@ -83507,6 +83509,12 @@ const getGenesisClass$1 = ({ colors: colors2, borderRadius: borderRadius2, sizin
83507
83509
  background-color: ${components2.tableCell.selected} !important;
83508
83510
  color: #fff !important;
83509
83511
  }
83512
+
83513
+ .ant-table-tbody > tr.ant-table-row-pressed > td,
83514
+ .ant-table-tbody > tr.ant-table-row-pressed > .ant-table-cell {
83515
+ background-color: ${components2.tableCell.selected} !important;
83516
+ color: #fff !important;
83517
+ }
83510
83518
  `;
83511
83519
  };
83512
83520
  const Table$1 = styled(ForwardTable)`
@@ -83971,6 +83979,9 @@ function Table({
83971
83979
  400
83972
83980
  );
83973
83981
  const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
83982
+ const [pressedRowKey, setPressedRowKey] = React.useState(
83983
+ null
83984
+ );
83974
83985
  const tableRef = React.useRef(null);
83975
83986
  const containerRef = React.useRef(null);
83976
83987
  React.useEffect(() => {
@@ -84073,44 +84084,85 @@ function Table({
84073
84084
  return rest.scroll;
84074
84085
  }, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
84075
84086
  const tableDataSource = isMaterializedView ? materializedData : dataSource;
84076
- const handleRowClick = React.useCallback(
84087
+ React.useEffect(() => {
84088
+ if (tableDataSource && tableDataSource.length > 0) {
84089
+ console.log(
84090
+ "Genesis Table - tableDataSource length:",
84091
+ tableDataSource.length
84092
+ );
84093
+ console.log("Genesis Table - rowKey type:", typeof rowKey);
84094
+ tableDataSource.slice(0, 3).map((record, index2) => {
84095
+ const key = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84096
+ console.log(
84097
+ `Genesis Table - Record ${index2} key:`,
84098
+ key,
84099
+ "Record:",
84100
+ record
84101
+ );
84102
+ return key;
84103
+ });
84104
+ const allKeys = tableDataSource.map(
84105
+ (record) => typeof rowKey === "function" ? rowKey(record) : record[rowKey]
84106
+ );
84107
+ const uniqueKeys = [...new Set(allKeys)];
84108
+ console.log(
84109
+ `Genesis Table - Total keys: ${allKeys.length}, Unique keys: ${uniqueKeys.length}`
84110
+ );
84111
+ if (allKeys.length !== uniqueKeys.length) {
84112
+ console.error("Genesis Table - DUPLICATE KEYS FOUND:", allKeys);
84113
+ const duplicates = allKeys.filter(
84114
+ (key, index2) => allKeys.indexOf(key) !== index2
84115
+ );
84116
+ console.error("Genesis Table - Duplicate keys:", [
84117
+ ...new Set(duplicates)
84118
+ ]);
84119
+ }
84120
+ }
84121
+ }, [tableDataSource, rowKey]);
84122
+ const handleRowMouseDown = React.useCallback(
84077
84123
  (record, index2, event) => {
84078
- console.log("Row clicked:", record, "index:", index2);
84079
84124
  const target = event.target;
84080
84125
  const isInteractiveElement = target.closest(
84081
- 'button, a, input, select, textarea, [role="button"], [onclick]'
84126
+ 'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
84082
84127
  );
84083
- console.log("Is interactive element:", isInteractiveElement);
84084
84128
  if (isInteractiveElement) {
84085
- console.log("Skipping row selection due to interactive element");
84086
84129
  return;
84087
84130
  }
84088
- if (!rowSelection || !rowSelection.onChange) {
84089
- console.log("No row selection or onChange handler");
84131
+ const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84132
+ setPressedRowKey(recordKey);
84133
+ },
84134
+ [rowKey]
84135
+ );
84136
+ const handleRowMouseUp = React.useCallback(
84137
+ (record, index2, event) => {
84138
+ setPressedRowKey(null);
84139
+ },
84140
+ []
84141
+ );
84142
+ const handleRowClick = React.useCallback(
84143
+ (record, index2, event) => {
84144
+ console.log("Genesis Table - Row clicked:", record, "index:", index2);
84145
+ console.log("Genesis Table - onRowClick function:", onRowClick);
84146
+ const target = event.target;
84147
+ const isInteractiveElement = target.closest(
84148
+ 'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
84149
+ );
84150
+ console.log("Genesis Table - Target element:", target);
84151
+ console.log("Genesis Table - Target tagName:", target.tagName);
84152
+ console.log("Genesis Table - Target className:", target.className);
84153
+ console.log("Genesis Table - Is interactive element:", isInteractiveElement);
84154
+ if (isInteractiveElement) {
84155
+ console.log("Genesis Table - Skipping row click due to interactive element");
84090
84156
  return;
84091
84157
  }
84092
- if (rowSelection.getCheckboxProps) {
84093
- const checkboxProps = rowSelection.getCheckboxProps(record);
84094
- if (checkboxProps.disabled) {
84095
- console.log("Row is disabled for selection:", record);
84096
- return;
84097
- }
84158
+ if (onRowClick) {
84159
+ console.log("Genesis Table - Calling onRowClick function");
84160
+ onRowClick(record, index2, event);
84161
+ } else {
84162
+ console.log("Genesis Table - onRowClick not provided");
84098
84163
  }
84099
- const currentSelectedKeys = selectedRowKeys;
84100
- const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84101
- console.log("Current selected keys:", currentSelectedKeys);
84102
- console.log("Record key:", recordKey);
84103
- const newSelectedKeys = currentSelectedKeys.includes(recordKey) ? currentSelectedKeys.filter((key) => key !== recordKey) : [...currentSelectedKeys, recordKey];
84104
- console.log("New selected keys:", newSelectedKeys);
84105
- setSelectedRowKeys(newSelectedKeys);
84106
- const selectedRows = tableDataSource.filter((record2) => {
84107
- const key = typeof rowKey === "function" ? rowKey(record2) : record2[rowKey];
84108
- return newSelectedKeys.includes(key);
84109
- });
84110
- console.log("Selected rows:", selectedRows);
84111
- rowSelection.onChange(newSelectedKeys, selectedRows);
84112
84164
  },
84113
- [rowSelection, rowKey, tableDataSource, selectedRowKeys]
84165
+ [onRowClick]
84114
84166
  );
84115
84167
  const enhancedRowSelection = React.useMemo(() => {
84116
84168
  if (!rowSelection) return;
@@ -84142,12 +84194,19 @@ function Table({
84142
84194
  rowSelection: enhancedRowSelection,
84143
84195
  onRow: (record, index2) => {
84144
84196
  const isDisabled = rowSelection?.getCheckboxProps?.(record)?.disabled ?? false;
84197
+ const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84198
+ const isPressed = pressedRowKey === recordKey;
84145
84199
  return {
84146
84200
  onClick: (event) => handleRowClick(record, index2 ?? 0, event),
84201
+ onMouseDown: (event) => handleRowMouseDown(record, index2 ?? 0, event),
84202
+ onMouseUp: (event) => handleRowMouseUp(record, index2 ?? 0, event),
84203
+ onMouseLeave: () => setPressedRowKey(null),
84204
+ // Clear pressed state when mouse leaves
84147
84205
  style: {
84148
- cursor: rowSelection && !isDisabled ? "pointer" : "default",
84206
+ cursor: onRowClick ? "pointer" : "default",
84149
84207
  opacity: isDisabled ? 0.6 : 1
84150
- }
84208
+ },
84209
+ className: isPressed ? "ant-table-row-pressed" : ""
84151
84210
  };
84152
84211
  },
84153
84212
  pagination: paginationConfig,
@@ -84163,6 +84222,7 @@ const TablePagination = ({
84163
84222
  dataSource,
84164
84223
  rowSelection,
84165
84224
  onChange,
84225
+ onRowClick,
84166
84226
  paginationStyle = PaginationStyle.SIMPLE,
84167
84227
  pageSize = 10,
84168
84228
  isMainContentCell
@@ -84181,6 +84241,7 @@ const TablePagination = ({
84181
84241
  dataSource: paginatedData,
84182
84242
  rowSelection,
84183
84243
  onChange,
84244
+ onRowClick,
84184
84245
  pagination: false,
84185
84246
  isMainContentCell
84186
84247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobolt/genesis",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "description": "genesis design system",
5
5
  "author": "gobolt",
6
6
  "license": "MIT",