@gobolt/genesis 0.4.9 → 0.4.10

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,43 @@ function Table({
84091
84102
  return rest.scroll;
84092
84103
  }, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
84093
84104
  const tableDataSource = isMaterializedView ? materializedData : dataSource;
84105
+ const handleRowMouseDown = React__namespace.useCallback(
84106
+ (record, index2, event) => {
84107
+ const target = event.target;
84108
+ const isInteractiveElement = target.closest(
84109
+ 'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
84110
+ );
84111
+ if (isInteractiveElement) {
84112
+ return;
84113
+ }
84114
+ const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84115
+ setPressedRowKey(recordKey);
84116
+ },
84117
+ [rowKey]
84118
+ );
84119
+ const handleRowMouseUp = React__namespace.useCallback(
84120
+ (record, index2, event) => {
84121
+ setPressedRowKey(null);
84122
+ },
84123
+ []
84124
+ );
84094
84125
  const handleRowClick = React__namespace.useCallback(
84095
84126
  (record, index2, event) => {
84096
84127
  console.log("Row clicked:", record, "index:", index2);
84097
84128
  const target = event.target;
84098
84129
  const isInteractiveElement = target.closest(
84099
- 'button, a, input, select, textarea, [role="button"], [onclick]'
84130
+ 'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
84100
84131
  );
84101
84132
  console.log("Is interactive element:", isInteractiveElement);
84102
84133
  if (isInteractiveElement) {
84103
- console.log("Skipping row selection due to interactive element");
84104
- return;
84105
- }
84106
- if (!rowSelection || !rowSelection.onChange) {
84107
- console.log("No row selection or onChange handler");
84134
+ console.log("Skipping row click due to interactive element");
84108
84135
  return;
84109
84136
  }
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
- }
84137
+ if (onRowClick) {
84138
+ onRowClick(record, index2, event);
84116
84139
  }
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
84140
  },
84131
- [rowSelection, rowKey, tableDataSource, selectedRowKeys]
84141
+ [onRowClick]
84132
84142
  );
84133
84143
  const enhancedRowSelection = React__namespace.useMemo(() => {
84134
84144
  if (!rowSelection) return;
@@ -84160,12 +84170,19 @@ function Table({
84160
84170
  rowSelection: enhancedRowSelection,
84161
84171
  onRow: (record, index2) => {
84162
84172
  const isDisabled = rowSelection?.getCheckboxProps?.(record)?.disabled ?? false;
84173
+ const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84174
+ const isPressed = pressedRowKey === recordKey;
84163
84175
  return {
84164
84176
  onClick: (event) => handleRowClick(record, index2 ?? 0, event),
84177
+ onMouseDown: (event) => handleRowMouseDown(record, index2 ?? 0, event),
84178
+ onMouseUp: (event) => handleRowMouseUp(record, index2 ?? 0, event),
84179
+ onMouseLeave: () => setPressedRowKey(null),
84180
+ // Clear pressed state when mouse leaves
84165
84181
  style: {
84166
- cursor: rowSelection && !isDisabled ? "pointer" : "default",
84182
+ cursor: onRowClick ? "pointer" : "default",
84167
84183
  opacity: isDisabled ? 0.6 : 1
84168
- }
84184
+ },
84185
+ className: isPressed ? "ant-table-row-pressed" : ""
84169
84186
  };
84170
84187
  },
84171
84188
  pagination: paginationConfig,
@@ -84181,6 +84198,7 @@ const TablePagination = ({
84181
84198
  dataSource,
84182
84199
  rowSelection,
84183
84200
  onChange,
84201
+ onRowClick,
84184
84202
  paginationStyle = PaginationStyle.SIMPLE,
84185
84203
  pageSize = 10,
84186
84204
  isMainContentCell
@@ -84199,6 +84217,7 @@ const TablePagination = ({
84199
84217
  dataSource: paginatedData,
84200
84218
  rowSelection,
84201
84219
  onChange,
84220
+ onRowClick,
84202
84221
  pagination: false,
84203
84222
  isMainContentCell
84204
84223
  }
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,43 @@ function Table({
84073
84084
  return rest.scroll;
84074
84085
  }, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
84075
84086
  const tableDataSource = isMaterializedView ? materializedData : dataSource;
84087
+ const handleRowMouseDown = React.useCallback(
84088
+ (record, index2, event) => {
84089
+ const target = event.target;
84090
+ const isInteractiveElement = target.closest(
84091
+ 'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
84092
+ );
84093
+ if (isInteractiveElement) {
84094
+ return;
84095
+ }
84096
+ const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84097
+ setPressedRowKey(recordKey);
84098
+ },
84099
+ [rowKey]
84100
+ );
84101
+ const handleRowMouseUp = React.useCallback(
84102
+ (record, index2, event) => {
84103
+ setPressedRowKey(null);
84104
+ },
84105
+ []
84106
+ );
84076
84107
  const handleRowClick = React.useCallback(
84077
84108
  (record, index2, event) => {
84078
84109
  console.log("Row clicked:", record, "index:", index2);
84079
84110
  const target = event.target;
84080
84111
  const isInteractiveElement = target.closest(
84081
- 'button, a, input, select, textarea, [role="button"], [onclick]'
84112
+ 'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
84082
84113
  );
84083
84114
  console.log("Is interactive element:", isInteractiveElement);
84084
84115
  if (isInteractiveElement) {
84085
- console.log("Skipping row selection due to interactive element");
84086
- return;
84087
- }
84088
- if (!rowSelection || !rowSelection.onChange) {
84089
- console.log("No row selection or onChange handler");
84116
+ console.log("Skipping row click due to interactive element");
84090
84117
  return;
84091
84118
  }
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
- }
84119
+ if (onRowClick) {
84120
+ onRowClick(record, index2, event);
84098
84121
  }
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
84122
  },
84113
- [rowSelection, rowKey, tableDataSource, selectedRowKeys]
84123
+ [onRowClick]
84114
84124
  );
84115
84125
  const enhancedRowSelection = React.useMemo(() => {
84116
84126
  if (!rowSelection) return;
@@ -84142,12 +84152,19 @@ function Table({
84142
84152
  rowSelection: enhancedRowSelection,
84143
84153
  onRow: (record, index2) => {
84144
84154
  const isDisabled = rowSelection?.getCheckboxProps?.(record)?.disabled ?? false;
84155
+ const recordKey = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
84156
+ const isPressed = pressedRowKey === recordKey;
84145
84157
  return {
84146
84158
  onClick: (event) => handleRowClick(record, index2 ?? 0, event),
84159
+ onMouseDown: (event) => handleRowMouseDown(record, index2 ?? 0, event),
84160
+ onMouseUp: (event) => handleRowMouseUp(record, index2 ?? 0, event),
84161
+ onMouseLeave: () => setPressedRowKey(null),
84162
+ // Clear pressed state when mouse leaves
84147
84163
  style: {
84148
- cursor: rowSelection && !isDisabled ? "pointer" : "default",
84164
+ cursor: onRowClick ? "pointer" : "default",
84149
84165
  opacity: isDisabled ? 0.6 : 1
84150
- }
84166
+ },
84167
+ className: isPressed ? "ant-table-row-pressed" : ""
84151
84168
  };
84152
84169
  },
84153
84170
  pagination: paginationConfig,
@@ -84163,6 +84180,7 @@ const TablePagination = ({
84163
84180
  dataSource,
84164
84181
  rowSelection,
84165
84182
  onChange,
84183
+ onRowClick,
84166
84184
  paginationStyle = PaginationStyle.SIMPLE,
84167
84185
  pageSize = 10,
84168
84186
  isMainContentCell
@@ -84181,6 +84199,7 @@ const TablePagination = ({
84181
84199
  dataSource: paginatedData,
84182
84200
  rowSelection,
84183
84201
  onChange,
84202
+ onRowClick,
84184
84203
  pagination: false,
84185
84204
  isMainContentCell
84186
84205
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobolt/genesis",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "genesis design system",
5
5
  "author": "gobolt",
6
6
  "license": "MIT",