@sustaina/shared-ui 1.4.1 → 1.5.0

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.mts CHANGED
@@ -143,11 +143,14 @@ type DataTableColumnGrouping = {
143
143
  customAggregationFns?: GroupingOptions["aggregationFns"];
144
144
  onGroupingChange?: OnChangeFn<GroupingState>;
145
145
  };
146
+ type RowClickType = "single" | "double";
146
147
  type DataTableRowClickHandler<TData extends RowData$1> = (rowData: TData, info: {
147
148
  event: React.MouseEvent<HTMLTableRowElement>;
148
149
  row: Row<TData>;
149
150
  table: Table$1<TData>;
151
+ clickType: RowClickType;
150
152
  }) => void;
153
+ type DataTableRowClickMode = "native" | "timeout";
151
154
  type DataTableRowIdKeyHandler<TData extends RowData$1> = (originalRow: TData, index: number, parent?: Row<TData>) => string;
152
155
  type DataTableHeaderCell<TData extends RowData$1> = {
153
156
  id: string;
@@ -486,4 +489,4 @@ type Breakpoints = {
486
489
  };
487
490
  declare const useScreenSize: (breakpoints?: Breakpoints) => UseScreenSizeResult;
488
491
 
489
- export { AdvanceSearch, type Breakpoints, Button, type Column, type ContentSlot, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, type FieldSchema, FormErrorMessage, type FormErrorMessageProps, FormField, FormFieldContext, type FormFieldContextValue, type FormFieldProps, FormItem, FormItemContext, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, _default as Navbar, type NavbarProps, NumberInput, type NumberInputProps, PreventPageLeave, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
492
+ export { AdvanceSearch, type Breakpoints, Button, type Column, type ContentSlot, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowClickMode, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, type FieldSchema, FormErrorMessage, type FormErrorMessageProps, FormField, FormFieldContext, type FormFieldContextValue, type FormFieldProps, FormItem, FormItemContext, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, _default as Navbar, type NavbarProps, NumberInput, type NumberInputProps, PreventPageLeave, type RowClickType, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
package/dist/index.d.ts CHANGED
@@ -143,11 +143,14 @@ type DataTableColumnGrouping = {
143
143
  customAggregationFns?: GroupingOptions["aggregationFns"];
144
144
  onGroupingChange?: OnChangeFn<GroupingState>;
145
145
  };
146
+ type RowClickType = "single" | "double";
146
147
  type DataTableRowClickHandler<TData extends RowData$1> = (rowData: TData, info: {
147
148
  event: React.MouseEvent<HTMLTableRowElement>;
148
149
  row: Row<TData>;
149
150
  table: Table$1<TData>;
151
+ clickType: RowClickType;
150
152
  }) => void;
153
+ type DataTableRowClickMode = "native" | "timeout";
151
154
  type DataTableRowIdKeyHandler<TData extends RowData$1> = (originalRow: TData, index: number, parent?: Row<TData>) => string;
152
155
  type DataTableHeaderCell<TData extends RowData$1> = {
153
156
  id: string;
@@ -486,4 +489,4 @@ type Breakpoints = {
486
489
  };
487
490
  declare const useScreenSize: (breakpoints?: Breakpoints) => UseScreenSizeResult;
488
491
 
489
- export { AdvanceSearch, type Breakpoints, Button, type Column, type ContentSlot, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, type FieldSchema, FormErrorMessage, type FormErrorMessageProps, FormField, FormFieldContext, type FormFieldContextValue, type FormFieldProps, FormItem, FormItemContext, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, _default as Navbar, type NavbarProps, NumberInput, type NumberInputProps, PreventPageLeave, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
492
+ export { AdvanceSearch, type Breakpoints, Button, type Column, type ContentSlot, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowClickMode, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, type FieldSchema, FormErrorMessage, type FormErrorMessageProps, FormField, FormFieldContext, type FormFieldContextValue, type FormFieldProps, FormItem, FormItemContext, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, _default as Navbar, type NavbarProps, NumberInput, type NumberInputProps, PreventPageLeave, type RowClickType, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
package/dist/index.js CHANGED
@@ -713,6 +713,15 @@ function getColumnPinningStyles(column) {
713
713
  };
714
714
  return { classes, style };
715
715
  }
716
+ function getRowClickHandlers(handler, { rowData, row, table }) {
717
+ const handleRowClick = (event, clickType) => {
718
+ handler(rowData, { event, row, table, clickType });
719
+ };
720
+ return {
721
+ onClick: (event) => handleRowClick(event, "single"),
722
+ onDoubleClick: (event) => handleRowClick(event, "double")
723
+ };
724
+ }
716
725
  var fallbackData = [];
717
726
  var DataTable = ({
718
727
  tableRef,
@@ -952,11 +961,12 @@ var DataTable = ({
952
961
  key: row.id,
953
962
  className: cn("group", tableDataRowProps?.className),
954
963
  "data-state": row.getIsSelected() ? "selected" : "non-selected",
955
- onClick: (event) => {
956
- if (typeof onRowClick === "function") {
957
- onRowClick(row.original, { event, row, table });
958
- }
959
- }
964
+ ...getRowClickHandlers(onRowClick ?? (() => {
965
+ }), {
966
+ rowData: row.original,
967
+ row,
968
+ table
969
+ })
960
970
  },
961
971
  row.getVisibleCells().map((cell) => {
962
972
  const { classes, style } = getColumnPinningStyles(cell.column);