@sustaina/shared-ui 1.6.4 → 1.7.1

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
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
3
  import React__default, { CSSProperties, ReactNode } from 'react';
4
4
  import { FieldValues, FieldPath, ControllerProps, UseFormGetFieldState } from 'react-hook-form';
5
- import { Header, RowData as RowData$1, Column as Column$1, Table as Table$1, ColumnDef, ColumnFiltersState, OnChangeFn, FilterFnOption, SortingState, ColumnOrderState, VisibilityState, ColumnPinningState, GroupingState, GroupingOptions, ColumnResizeMode, RowSelectionState, Row, ExpandedState, HeaderGroup, Cell, HeaderContext } from '@tanstack/react-table';
5
+ import { Header, RowData as RowData$1, Column as Column$1, Table as Table$1, ColumnDef, ColumnFiltersState, OnChangeFn, FilterFnOption, SortingState, ColumnOrderState, VisibilityState, ColumnPinningState, GroupingState, GroupingOptions, ColumnResizeMode, RowSelectionState, Row, ExpandedState, Cell, HeaderGroup, HeaderContext } from '@tanstack/react-table';
6
6
  import * as zustand from 'zustand';
7
7
  import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
8
8
  import { VariantProps } from 'class-variance-authority';
@@ -56,6 +56,8 @@ declare function Table({ className, ...props }: React$1.ComponentProps<"table">)
56
56
  declare function TableHeader({ className, ...props }: React$1.ComponentProps<"thead">): react_jsx_runtime.JSX.Element;
57
57
  declare function TableBody({ className, ...props }: React$1.ComponentProps<"tbody">): react_jsx_runtime.JSX.Element;
58
58
  declare function TableRow({ className, ...props }: React$1.ComponentProps<"tr">): react_jsx_runtime.JSX.Element;
59
+ declare function TableHead({ className, ...props }: React$1.ComponentProps<"th">): react_jsx_runtime.JSX.Element;
60
+ declare function TableCell({ className, ...props }: React$1.ComponentProps<"td">): react_jsx_runtime.JSX.Element;
59
61
 
60
62
  type ColumnResizerProps = {
61
63
  header: Header<any, any>;
@@ -185,11 +187,24 @@ type DataTableComponentProps<TData> = {
185
187
  containerProps?: React.ComponentProps<typeof TableContainer>;
186
188
  tableProps?: React.ComponentProps<typeof Table>;
187
189
  tableHeaderProps?: React.ComponentProps<typeof TableHeader>;
190
+ tableHeadCellProps?: React.ComponentProps<typeof TableHead> | ((info: {
191
+ header: Header<TData, unknown>;
192
+ table: Table$1<TData>;
193
+ }) => React.ComponentProps<typeof TableHead>);
188
194
  tableBodyProps?: React.ComponentProps<typeof TableBody>;
189
195
  tableDataRowProps?: React.ComponentProps<typeof TableRow> | ((info: {
190
196
  row: Row<TData>;
191
197
  table: Table$1<TData>;
192
198
  }) => React.ComponentProps<typeof TableRow>);
199
+ tableDataCellProps?: React.ComponentProps<typeof TableCell> | ((info: {
200
+ row: Row<TData>;
201
+ cell: Cell<TData, unknown>;
202
+ table: Table$1<TData>;
203
+ }) => React.ComponentProps<typeof TableCell>);
204
+ tableFilterCellProps?: React.ComponentProps<typeof TableCell> | ((info: {
205
+ column: Column$1<TData>;
206
+ table: Table$1<TData>;
207
+ }) => React.ComponentProps<typeof TableCell>);
193
208
  columnResizerProps?: Omit<ColumnResizerProps, "header">;
194
209
  };
195
210
  type ContentSlot = {
@@ -248,6 +263,7 @@ declare module "@tanstack/react-table" {
248
263
  interface ColumnMeta<TData extends RowData> {
249
264
  headerProps?: React.ComponentProps<"th">;
250
265
  cellProps?: React.ComponentProps<"td">;
266
+ filterCellProps?: React.ComponentProps<"td">;
251
267
  useColumnSizing?: boolean;
252
268
  renderColumnFilter?: (props: DataTableColumnFilterProps<TData>) => ReactNode;
253
269
  }
@@ -298,6 +314,7 @@ declare function Button({ className, variant, size, active, asChild, ...props }:
298
314
 
299
315
  type Column = {
300
316
  id: string;
317
+ label?: string;
301
318
  };
302
319
  type GridPayload<TColumn extends {
303
320
  id: string;
@@ -398,8 +415,9 @@ interface DialogAlertProps {
398
415
  showCancel?: boolean;
399
416
  align?: "start" | "center" | "end";
400
417
  outlet?: React__default.ReactNode | null;
418
+ persistent?: boolean;
401
419
  }
402
- declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet }: DialogAlertProps): react_jsx_runtime.JSX.Element;
420
+ declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet, persistent }: DialogAlertProps): react_jsx_runtime.JSX.Element;
403
421
 
404
422
  declare function isDefined(value: any): boolean;
405
423
  declare function isEmptyObject(value: any): boolean;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
3
  import React__default, { CSSProperties, ReactNode } from 'react';
4
4
  import { FieldValues, FieldPath, ControllerProps, UseFormGetFieldState } from 'react-hook-form';
5
- import { Header, RowData as RowData$1, Column as Column$1, Table as Table$1, ColumnDef, ColumnFiltersState, OnChangeFn, FilterFnOption, SortingState, ColumnOrderState, VisibilityState, ColumnPinningState, GroupingState, GroupingOptions, ColumnResizeMode, RowSelectionState, Row, ExpandedState, HeaderGroup, Cell, HeaderContext } from '@tanstack/react-table';
5
+ import { Header, RowData as RowData$1, Column as Column$1, Table as Table$1, ColumnDef, ColumnFiltersState, OnChangeFn, FilterFnOption, SortingState, ColumnOrderState, VisibilityState, ColumnPinningState, GroupingState, GroupingOptions, ColumnResizeMode, RowSelectionState, Row, ExpandedState, Cell, HeaderGroup, HeaderContext } from '@tanstack/react-table';
6
6
  import * as zustand from 'zustand';
7
7
  import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
8
8
  import { VariantProps } from 'class-variance-authority';
@@ -56,6 +56,8 @@ declare function Table({ className, ...props }: React$1.ComponentProps<"table">)
56
56
  declare function TableHeader({ className, ...props }: React$1.ComponentProps<"thead">): react_jsx_runtime.JSX.Element;
57
57
  declare function TableBody({ className, ...props }: React$1.ComponentProps<"tbody">): react_jsx_runtime.JSX.Element;
58
58
  declare function TableRow({ className, ...props }: React$1.ComponentProps<"tr">): react_jsx_runtime.JSX.Element;
59
+ declare function TableHead({ className, ...props }: React$1.ComponentProps<"th">): react_jsx_runtime.JSX.Element;
60
+ declare function TableCell({ className, ...props }: React$1.ComponentProps<"td">): react_jsx_runtime.JSX.Element;
59
61
 
60
62
  type ColumnResizerProps = {
61
63
  header: Header<any, any>;
@@ -185,11 +187,24 @@ type DataTableComponentProps<TData> = {
185
187
  containerProps?: React.ComponentProps<typeof TableContainer>;
186
188
  tableProps?: React.ComponentProps<typeof Table>;
187
189
  tableHeaderProps?: React.ComponentProps<typeof TableHeader>;
190
+ tableHeadCellProps?: React.ComponentProps<typeof TableHead> | ((info: {
191
+ header: Header<TData, unknown>;
192
+ table: Table$1<TData>;
193
+ }) => React.ComponentProps<typeof TableHead>);
188
194
  tableBodyProps?: React.ComponentProps<typeof TableBody>;
189
195
  tableDataRowProps?: React.ComponentProps<typeof TableRow> | ((info: {
190
196
  row: Row<TData>;
191
197
  table: Table$1<TData>;
192
198
  }) => React.ComponentProps<typeof TableRow>);
199
+ tableDataCellProps?: React.ComponentProps<typeof TableCell> | ((info: {
200
+ row: Row<TData>;
201
+ cell: Cell<TData, unknown>;
202
+ table: Table$1<TData>;
203
+ }) => React.ComponentProps<typeof TableCell>);
204
+ tableFilterCellProps?: React.ComponentProps<typeof TableCell> | ((info: {
205
+ column: Column$1<TData>;
206
+ table: Table$1<TData>;
207
+ }) => React.ComponentProps<typeof TableCell>);
193
208
  columnResizerProps?: Omit<ColumnResizerProps, "header">;
194
209
  };
195
210
  type ContentSlot = {
@@ -248,6 +263,7 @@ declare module "@tanstack/react-table" {
248
263
  interface ColumnMeta<TData extends RowData> {
249
264
  headerProps?: React.ComponentProps<"th">;
250
265
  cellProps?: React.ComponentProps<"td">;
266
+ filterCellProps?: React.ComponentProps<"td">;
251
267
  useColumnSizing?: boolean;
252
268
  renderColumnFilter?: (props: DataTableColumnFilterProps<TData>) => ReactNode;
253
269
  }
@@ -298,6 +314,7 @@ declare function Button({ className, variant, size, active, asChild, ...props }:
298
314
 
299
315
  type Column = {
300
316
  id: string;
317
+ label?: string;
301
318
  };
302
319
  type GridPayload<TColumn extends {
303
320
  id: string;
@@ -398,8 +415,9 @@ interface DialogAlertProps {
398
415
  showCancel?: boolean;
399
416
  align?: "start" | "center" | "end";
400
417
  outlet?: React__default.ReactNode | null;
418
+ persistent?: boolean;
401
419
  }
402
- declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet }: DialogAlertProps): react_jsx_runtime.JSX.Element;
420
+ declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet, persistent }: DialogAlertProps): react_jsx_runtime.JSX.Element;
403
421
 
404
422
  declare function isDefined(value: any): boolean;
405
423
  declare function isEmptyObject(value: any): boolean;
package/dist/index.js CHANGED
@@ -960,17 +960,24 @@ var DataTable = ({
960
960
  return /* @__PURE__ */ jsxRuntime.jsx(TableRow, { children: headerGroup.headers.map((header) => {
961
961
  const { classes, style } = getColumnPinningStyles(header.column);
962
962
  const useColumnSizing = header.column.columnDef?.meta?.useColumnSizing ?? columnResizing?.enabled ?? false;
963
+ const tableHeadCellProps = typeof components?.tableHeadCellProps === "function" ? components?.tableHeadCellProps({ header, table }) : components?.tableHeadCellProps;
963
964
  return /* @__PURE__ */ jsxRuntime.jsxs(
964
965
  TableHead,
965
966
  {
966
967
  colSpan: header.colSpan,
968
+ ...tableHeadCellProps,
967
969
  ...header.column.columnDef?.meta?.headerProps,
968
- className: cn(classes, header.column.columnDef?.meta?.headerProps?.className),
970
+ className: cn(
971
+ classes,
972
+ tableHeadCellProps?.className,
973
+ header.column.columnDef?.meta?.headerProps?.className
974
+ ),
969
975
  style: {
970
976
  ...style,
971
977
  width: useColumnSizing ? header.column.getSize() : void 0,
972
978
  minWidth: useColumnSizing ? header.column.columnDef.minSize : void 0,
973
979
  maxWidth: useColumnSizing ? header.column.columnDef.maxSize : void 0,
980
+ ...tableHeadCellProps?.style,
974
981
  ...header.column.columnDef?.meta?.headerProps?.style
975
982
  },
976
983
  children: [
@@ -985,14 +992,17 @@ var DataTable = ({
985
992
  isSomeColumnsFilterable && /* @__PURE__ */ jsxRuntime.jsx(TableRow, { children: filterableColumns.map((column) => {
986
993
  const { classes, style } = getColumnPinningStyles(column);
987
994
  const useColumnSizing = column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? false;
995
+ const tableFilterCellProps = typeof components?.tableFilterCellProps === "function" ? components?.tableFilterCellProps({ column, table }) : components?.tableFilterCellProps;
988
996
  return /* @__PURE__ */ jsxRuntime.jsx(
989
997
  TableCell,
990
998
  {
991
- ...column.columnDef?.meta?.cellProps,
999
+ ...tableFilterCellProps,
1000
+ ...column.columnDef?.meta?.filterCellProps,
992
1001
  className: cn(
993
1002
  "bg-white border-b",
994
1003
  classes,
995
- column.columnDef?.meta?.cellProps?.className
1004
+ tableFilterCellProps?.className,
1005
+ column.columnDef?.meta?.filterCellProps?.className
996
1006
  ),
997
1007
  style: {
998
1008
  // TODO: should we separate styles for filter or use same columns styles
@@ -1000,7 +1010,8 @@ var DataTable = ({
1000
1010
  width: useColumnSizing ? column.getSize() : void 0,
1001
1011
  minWidth: useColumnSizing ? column.columnDef.minSize : void 0,
1002
1012
  maxWidth: useColumnSizing ? column.columnDef.maxSize : void 0,
1003
- ...column.columnDef?.meta?.cellProps?.style
1013
+ ...tableFilterCellProps?.style,
1014
+ ...column.columnDef?.meta?.filterCellProps?.style
1004
1015
  },
1005
1016
  children: column.getCanFilter() && column.columnDef.meta?.renderColumnFilter?.({
1006
1017
  column,
@@ -1032,9 +1043,11 @@ var DataTable = ({
1032
1043
  row.getVisibleCells().map((cell) => {
1033
1044
  const { classes, style } = getColumnPinningStyles(cell.column);
1034
1045
  const useColumnSizing = cell.column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? false;
1046
+ const tableDataCellProps = typeof components?.tableDataCellProps === "function" ? components?.tableDataCellProps({ row, cell, table }) : components?.tableDataCellProps;
1035
1047
  return /* @__PURE__ */ jsxRuntime.jsx(
1036
1048
  TableCell,
1037
1049
  {
1050
+ ...tableDataCellProps,
1038
1051
  ...cell.column.columnDef?.meta?.cellProps,
1039
1052
  className: cn(
1040
1053
  {
@@ -1042,6 +1055,7 @@ var DataTable = ({
1042
1055
  "bg-white group-hover:bg-[#eff5f1]": !row.getIsSelected()
1043
1056
  },
1044
1057
  classes,
1058
+ tableDataCellProps?.className,
1045
1059
  cell.column.columnDef?.meta?.cellProps?.className
1046
1060
  ),
1047
1061
  style: {
@@ -1049,6 +1063,7 @@ var DataTable = ({
1049
1063
  width: useColumnSizing ? cell.column.getSize() : void 0,
1050
1064
  minWidth: useColumnSizing ? cell.column.columnDef.minSize : void 0,
1051
1065
  maxWidth: useColumnSizing ? cell.column.columnDef.maxSize : void 0,
1066
+ ...tableDataCellProps?.style,
1052
1067
  ...cell.column.columnDef?.meta?.cellProps?.style
1053
1068
  },
1054
1069
  children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
@@ -1565,10 +1580,13 @@ function SortableRow({
1565
1580
  id: value,
1566
1581
  disabled: name == "columns.0.id"
1567
1582
  });
1568
- const style = {
1569
- transform: utilities.CSS.Transform.toString(transform),
1570
- transition
1571
- };
1583
+ const style = React4__namespace.useMemo(
1584
+ () => ({
1585
+ transform: utilities.CSS.Transform.toString(transform),
1586
+ transition
1587
+ }),
1588
+ [transform, transition]
1589
+ );
1572
1590
  const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
1573
1591
  const currentFormColumns = reactHookForm.useWatch({ control, name: "columns" });
1574
1592
  return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setNodeRef, style, className: "flex items-center rounded-md bg-white", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -1577,7 +1595,7 @@ function SortableRow({
1577
1595
  control,
1578
1596
  name,
1579
1597
  render: ({ field }) => {
1580
- const options = availableColumns.filter((col) => col.id === field.value || !currentFormColumns?.some((c) => c.id === col.id)).map((col) => ({ id: col.id, label: capitalize(col.id) }));
1598
+ const options = availableColumns.filter((col) => col.id === field.value || !currentFormColumns?.some((c) => c.id === col.id)).map((col) => ({ id: col.id, label: col?.label ? col.label : capitalize(col.id) }));
1581
1599
  return /* @__PURE__ */ jsxRuntime.jsxs(FormItem2, { className: "flex-1", children: [
1582
1600
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1583
1601
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1986,7 +2004,7 @@ var Navbar = ({
1986
2004
  React4.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: title }),
1987
2005
  React4.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-sm font-semibold", children: subTitle })
1988
2006
  ] }),
1989
- tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { delayDuration: 700, children: [
2007
+ tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
1990
2008
  /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "text-white hover:opacity-80", children: /* @__PURE__ */ jsxRuntime.jsx(InfoIcon_default, { className: "w-4" }) }) }),
1991
2009
  /* @__PURE__ */ jsxRuntime.jsxs(
1992
2010
  TooltipContent2,
@@ -5244,7 +5262,8 @@ function DialogAlert({
5244
5262
  onCancel,
5245
5263
  showCancel = true,
5246
5264
  align = "center",
5247
- outlet
5265
+ outlet,
5266
+ persistent = false
5248
5267
  }) {
5249
5268
  const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
5250
5269
  const handleCancel = React4.useCallback(() => {
@@ -5254,7 +5273,8 @@ function DialogAlert({
5254
5273
  const handleConfirm = React4.useCallback(() => {
5255
5274
  onConfirm?.();
5256
5275
  }, [onConfirm]);
5257
- return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", children: [
5276
+ return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange: persistent ? () => {
5277
+ } : onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
5258
5278
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader2, { children: [
5259
5279
  title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: variantClass(variant), children: title }),
5260
5280
  description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: description })