@sustaina/shared-ui 1.6.3 → 1.7.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
@@ -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
  }
@@ -348,7 +364,7 @@ type NavbarBaseProps = {
348
364
  searchButton?: React__default.ReactNode;
349
365
  separatorDisable?: boolean;
350
366
  };
351
- type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title" | "headImageURL">;
367
+ type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title">;
352
368
  declare const _default: React__default.MemoExoticComponent<({ className, title, subTitle, headImageURL, headImageURLClassName, tooltipContentClassName, tooltipTitle, tooltipIcon, tooltipdescription, tooltipDescriptionWrapperClassName, mainButtonText, mainButtonClassName, mainButtonDisable, subButtonText, subButtonClassName, subButtonDisable, onMainButtonClick, onSubButtonClick, separatorDisable, searchButton }: NavbarProps) => react_jsx_runtime.JSX.Element>;
353
369
 
354
370
  type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup" | "uuid";
@@ -398,8 +414,9 @@ interface DialogAlertProps {
398
414
  showCancel?: boolean;
399
415
  align?: "start" | "center" | "end";
400
416
  outlet?: React__default.ReactNode | null;
417
+ persistent?: boolean;
401
418
  }
402
- declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet }: DialogAlertProps): react_jsx_runtime.JSX.Element;
419
+ declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet, persistent }: DialogAlertProps): react_jsx_runtime.JSX.Element;
403
420
 
404
421
  declare function isDefined(value: any): boolean;
405
422
  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
  }
@@ -348,7 +364,7 @@ type NavbarBaseProps = {
348
364
  searchButton?: React__default.ReactNode;
349
365
  separatorDisable?: boolean;
350
366
  };
351
- type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title" | "headImageURL">;
367
+ type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title">;
352
368
  declare const _default: React__default.MemoExoticComponent<({ className, title, subTitle, headImageURL, headImageURLClassName, tooltipContentClassName, tooltipTitle, tooltipIcon, tooltipdescription, tooltipDescriptionWrapperClassName, mainButtonText, mainButtonClassName, mainButtonDisable, subButtonText, subButtonClassName, subButtonDisable, onMainButtonClick, onSubButtonClick, separatorDisable, searchButton }: NavbarProps) => react_jsx_runtime.JSX.Element>;
353
369
 
354
370
  type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup" | "uuid";
@@ -398,8 +414,9 @@ interface DialogAlertProps {
398
414
  showCancel?: boolean;
399
415
  align?: "start" | "center" | "end";
400
416
  outlet?: React__default.ReactNode | null;
417
+ persistent?: boolean;
401
418
  }
402
- declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet }: DialogAlertProps): react_jsx_runtime.JSX.Element;
419
+ declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet, persistent }: DialogAlertProps): react_jsx_runtime.JSX.Element;
403
420
 
404
421
  declare function isDefined(value: any): boolean;
405
422
  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())
@@ -1954,10 +1969,10 @@ var Navbar = ({
1954
1969
  subTitle,
1955
1970
  headImageURL = "",
1956
1971
  headImageURLClassName,
1957
- tooltipContentClassName = "md:w-[350px] lg:w-[420px]",
1972
+ tooltipContentClassName = "w-[450px] lg:!w-[630px]",
1958
1973
  tooltipTitle,
1959
1974
  tooltipIcon,
1960
- tooltipdescription = [],
1975
+ tooltipdescription,
1961
1976
  tooltipDescriptionWrapperClassName,
1962
1977
  mainButtonText,
1963
1978
  mainButtonClassName,
@@ -1986,19 +2001,18 @@ var Navbar = ({
1986
2001
  React4.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: title }),
1987
2002
  React4.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-sm font-semibold", children: subTitle })
1988
2003
  ] }),
1989
- tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { delayDuration: 700, children: [
2004
+ tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
1990
2005
  /* @__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
2006
  /* @__PURE__ */ jsxRuntime.jsxs(
1992
2007
  TooltipContent2,
1993
2008
  {
1994
2009
  forceMount: true,
1995
2010
  side: isDesktop ? "right" : "bottom",
1996
- sideOffset: 8,
1997
2011
  align: "start",
1998
2012
  avoidCollisions: false,
1999
2013
  className: cn(
2000
- "bg-background text-foreground border border-black",
2001
- "transition-all duration-150 ease-out origin-top",
2014
+ "bg-white border border-black p-6",
2015
+ "transition-all duration-150 ease-out origin-top top-1 left-4",
2002
2016
  "data-[state=closed]:opacity-0 data-[state=open]:opacity-100",
2003
2017
  "data-[state=closed]:scale-95 data-[state=open]:scale-100",
2004
2018
  { "mt-5": isDesktop },
@@ -2011,7 +2025,7 @@ var Navbar = ({
2011
2025
  role: "tooltip",
2012
2026
  "aria-label": tooltipTitle,
2013
2027
  className: cn(
2014
- "flex flex-col gap-4 max-w-sm text-sm text-gray-700",
2028
+ "flex flex-col gap-4 text-sm text-black text-pretty",
2015
2029
  tooltipDescriptionWrapperClassName
2016
2030
  ),
2017
2031
  children: [
@@ -2019,7 +2033,7 @@ var Navbar = ({
2019
2033
  React4.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
2020
2034
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-bold", children: tooltipTitle })
2021
2035
  ] }),
2022
- React4.isValidElement(tooltipdescription) ? tooltipdescription : ""
2036
+ React4.isValidElement(tooltipdescription) && tooltipdescription
2023
2037
  ]
2024
2038
  }
2025
2039
  ),
@@ -5245,7 +5259,8 @@ function DialogAlert({
5245
5259
  onCancel,
5246
5260
  showCancel = true,
5247
5261
  align = "center",
5248
- outlet
5262
+ outlet,
5263
+ persistent = false
5249
5264
  }) {
5250
5265
  const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
5251
5266
  const handleCancel = React4.useCallback(() => {
@@ -5255,7 +5270,8 @@ function DialogAlert({
5255
5270
  const handleConfirm = React4.useCallback(() => {
5256
5271
  onConfirm?.();
5257
5272
  }, [onConfirm]);
5258
- return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", children: [
5273
+ return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange: persistent ? () => {
5274
+ } : onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
5259
5275
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader2, { children: [
5260
5276
  title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: variantClass(variant), children: title }),
5261
5277
  description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: description })