@sustaina/shared-ui 1.6.1 → 1.6.3

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
@@ -203,11 +203,22 @@ type DataTableStatusContent = {
203
203
  emptyData?: ContentSlot;
204
204
  emptyFilteredData?: ContentSlot;
205
205
  };
206
+ type ScrollInfo = {
207
+ scrollTop: number;
208
+ scrollHeight: number;
209
+ clientHeight: number;
210
+ scrollableHeight: number;
211
+ distanceToBottom: number;
212
+ ratioToBottom: number;
213
+ isTopReached: boolean;
214
+ isBottomReached: boolean;
215
+ };
206
216
  type DataTableScrollFetch = {
207
217
  enabled: boolean;
208
218
  fetchMore?: () => void;
209
219
  hasMore?: boolean;
210
220
  isFetchingMore?: boolean;
221
+ scrollThreshold?: number | ((info: ScrollInfo) => boolean);
211
222
  };
212
223
  type DataTableProps<TData extends RowData$1> = {
213
224
  data: TData[];
@@ -321,9 +332,11 @@ type NavbarBaseProps = {
321
332
  subTitle?: React__default.ReactNode;
322
333
  headImageURL?: string;
323
334
  headImageURLClassName?: string;
335
+ tooltipContentClassName?: string;
324
336
  tooltipTitle?: string;
325
337
  tooltipIcon?: React__default.ReactNode;
326
338
  tooltipdescription?: React__default.ReactNode;
339
+ tooltipDescriptionWrapperClassName?: string;
327
340
  mainButtonText?: React__default.ReactNode;
328
341
  mainButtonClassName?: string;
329
342
  mainButtonDisable?: boolean;
@@ -336,9 +349,9 @@ type NavbarBaseProps = {
336
349
  separatorDisable?: boolean;
337
350
  };
338
351
  type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title" | "headImageURL">;
339
- declare const _default: React__default.MemoExoticComponent<({ className, title, subTitle, headImageURL, headImageURLClassName, tooltipTitle, tooltipIcon, tooltipdescription, mainButtonText, mainButtonClassName, mainButtonDisable, subButtonText, subButtonClassName, subButtonDisable, onMainButtonClick, onSubButtonClick, separatorDisable, searchButton }: NavbarProps) => react_jsx_runtime.JSX.Element>;
352
+ 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>;
340
353
 
341
- type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup";
354
+ type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup" | "uuid";
342
355
  type Option = {
343
356
  value: string;
344
357
  label: string;
@@ -347,6 +360,7 @@ interface FieldSchemaBase<T extends FieldType> {
347
360
  name: string;
348
361
  type: T;
349
362
  label?: string;
363
+ multiTableSearch?: boolean;
350
364
  }
351
365
  interface DropdownFieldSchema extends FieldSchemaBase<"dropdown"> {
352
366
  options: Option[];
@@ -357,7 +371,8 @@ type DateFieldSchema = FieldSchemaBase<"date">;
357
371
  type DateTimeFieldSchema = FieldSchemaBase<"datetime">;
358
372
  type CheckboxFieldSchema = FieldSchemaBase<"checkbox">;
359
373
  type LookupFieldSchema = FieldSchemaBase<"lookup">;
360
- type FieldSchema = DropdownFieldSchema | TextFieldSchema | NumberFieldSchema | DateFieldSchema | DateTimeFieldSchema | CheckboxFieldSchema | LookupFieldSchema;
374
+ type UUIDFiledSchema = FieldSchemaBase<"uuid">;
375
+ type FieldSchema = DropdownFieldSchema | TextFieldSchema | NumberFieldSchema | DateFieldSchema | DateTimeFieldSchema | CheckboxFieldSchema | LookupFieldSchema | UUIDFiledSchema;
361
376
  interface AdvanceSearchProps {
362
377
  fields: FieldSchema[];
363
378
  portalId: string;
@@ -505,4 +520,4 @@ type UseTruncatedOptions<T> = {
505
520
  type UseTruncatedResult = boolean;
506
521
  declare const useTruncated: <T extends HTMLElement = any>({ elementRef, onChange, resizeDetectDelay }: UseTruncatedOptions<T>) => UseTruncatedResult;
507
522
 
508
- 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, DialogAlert, type DialogAlertProps, type DialogVariant, 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, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, getColumnIdFromTable, isDefined, isEmptyObject, renderContentSlot, selectValueToBoolean, stripNullishObject, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useTruncated };
523
+ 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, DialogAlert, type DialogAlertProps, type DialogVariant, 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 ScrollInfo, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, getColumnIdFromTable, isDefined, isEmptyObject, renderContentSlot, selectValueToBoolean, stripNullishObject, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useTruncated };
package/dist/index.d.ts CHANGED
@@ -203,11 +203,22 @@ type DataTableStatusContent = {
203
203
  emptyData?: ContentSlot;
204
204
  emptyFilteredData?: ContentSlot;
205
205
  };
206
+ type ScrollInfo = {
207
+ scrollTop: number;
208
+ scrollHeight: number;
209
+ clientHeight: number;
210
+ scrollableHeight: number;
211
+ distanceToBottom: number;
212
+ ratioToBottom: number;
213
+ isTopReached: boolean;
214
+ isBottomReached: boolean;
215
+ };
206
216
  type DataTableScrollFetch = {
207
217
  enabled: boolean;
208
218
  fetchMore?: () => void;
209
219
  hasMore?: boolean;
210
220
  isFetchingMore?: boolean;
221
+ scrollThreshold?: number | ((info: ScrollInfo) => boolean);
211
222
  };
212
223
  type DataTableProps<TData extends RowData$1> = {
213
224
  data: TData[];
@@ -321,9 +332,11 @@ type NavbarBaseProps = {
321
332
  subTitle?: React__default.ReactNode;
322
333
  headImageURL?: string;
323
334
  headImageURLClassName?: string;
335
+ tooltipContentClassName?: string;
324
336
  tooltipTitle?: string;
325
337
  tooltipIcon?: React__default.ReactNode;
326
338
  tooltipdescription?: React__default.ReactNode;
339
+ tooltipDescriptionWrapperClassName?: string;
327
340
  mainButtonText?: React__default.ReactNode;
328
341
  mainButtonClassName?: string;
329
342
  mainButtonDisable?: boolean;
@@ -336,9 +349,9 @@ type NavbarBaseProps = {
336
349
  separatorDisable?: boolean;
337
350
  };
338
351
  type NavbarProps = RequireAtLeastOne<NavbarBaseProps, "title" | "headImageURL">;
339
- declare const _default: React__default.MemoExoticComponent<({ className, title, subTitle, headImageURL, headImageURLClassName, tooltipTitle, tooltipIcon, tooltipdescription, mainButtonText, mainButtonClassName, mainButtonDisable, subButtonText, subButtonClassName, subButtonDisable, onMainButtonClick, onSubButtonClick, separatorDisable, searchButton }: NavbarProps) => react_jsx_runtime.JSX.Element>;
352
+ 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>;
340
353
 
341
- type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup";
354
+ type FieldType = "text" | "number" | "date" | "datetime" | "checkbox" | "dropdown" | "lookup" | "uuid";
342
355
  type Option = {
343
356
  value: string;
344
357
  label: string;
@@ -347,6 +360,7 @@ interface FieldSchemaBase<T extends FieldType> {
347
360
  name: string;
348
361
  type: T;
349
362
  label?: string;
363
+ multiTableSearch?: boolean;
350
364
  }
351
365
  interface DropdownFieldSchema extends FieldSchemaBase<"dropdown"> {
352
366
  options: Option[];
@@ -357,7 +371,8 @@ type DateFieldSchema = FieldSchemaBase<"date">;
357
371
  type DateTimeFieldSchema = FieldSchemaBase<"datetime">;
358
372
  type CheckboxFieldSchema = FieldSchemaBase<"checkbox">;
359
373
  type LookupFieldSchema = FieldSchemaBase<"lookup">;
360
- type FieldSchema = DropdownFieldSchema | TextFieldSchema | NumberFieldSchema | DateFieldSchema | DateTimeFieldSchema | CheckboxFieldSchema | LookupFieldSchema;
374
+ type UUIDFiledSchema = FieldSchemaBase<"uuid">;
375
+ type FieldSchema = DropdownFieldSchema | TextFieldSchema | NumberFieldSchema | DateFieldSchema | DateTimeFieldSchema | CheckboxFieldSchema | LookupFieldSchema | UUIDFiledSchema;
361
376
  interface AdvanceSearchProps {
362
377
  fields: FieldSchema[];
363
378
  portalId: string;
@@ -505,4 +520,4 @@ type UseTruncatedOptions<T> = {
505
520
  type UseTruncatedResult = boolean;
506
521
  declare const useTruncated: <T extends HTMLElement = any>({ elementRef, onChange, resizeDetectDelay }: UseTruncatedOptions<T>) => UseTruncatedResult;
507
522
 
508
- 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, DialogAlert, type DialogAlertProps, type DialogVariant, 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, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, getColumnIdFromTable, isDefined, isEmptyObject, renderContentSlot, selectValueToBoolean, stripNullishObject, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useTruncated };
523
+ 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, DialogAlert, type DialogAlertProps, type DialogVariant, 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 ScrollInfo, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, getColumnIdFromTable, isDefined, isEmptyObject, renderContentSlot, selectValueToBoolean, stripNullishObject, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useTruncated };
package/dist/index.js CHANGED
@@ -898,15 +898,33 @@ var DataTable = ({
898
898
  }, [centerVisibleLeafColumns, leftVisibleLeftColumns, rightVisibleLeafColumns]);
899
899
  const fetchMoreOnScrollReached = React4.useCallback(
900
900
  (containerRefElement) => {
901
- if (!scrollFetch?.enabled) {
901
+ if (!scrollFetch?.enabled || !containerRefElement || scrollFetch?.isFetchingMore || !scrollFetch?.hasMore || !scrollFetch?.fetchMore) {
902
902
  return;
903
903
  }
904
- if (containerRefElement) {
905
- const { scrollHeight, scrollTop, clientHeight } = containerRefElement;
906
- const threshold = 1.5;
907
- if (scrollHeight - scrollTop - clientHeight < clientHeight * threshold && !scrollFetch?.isFetchingMore && scrollFetch?.hasMore && scrollFetch?.fetchMore) {
908
- scrollFetch.fetchMore();
909
- }
904
+ const { scrollHeight, scrollTop, clientHeight } = containerRefElement;
905
+ const scrollableHeight = scrollHeight - clientHeight;
906
+ const distanceToBottom = scrollHeight - clientHeight - scrollTop;
907
+ const ratioToBottom = scrollableHeight > 0 ? scrollTop / scrollableHeight : 1;
908
+ const info = {
909
+ scrollTop,
910
+ scrollHeight,
911
+ clientHeight,
912
+ scrollableHeight,
913
+ distanceToBottom,
914
+ ratioToBottom,
915
+ isTopReached: scrollTop === 0,
916
+ isBottomReached: distanceToBottom <= 0
917
+ };
918
+ let shouldTrigger = false;
919
+ if (typeof scrollFetch.scrollThreshold === "number") {
920
+ shouldTrigger = info.ratioToBottom >= scrollFetch.scrollThreshold;
921
+ } else if (typeof scrollFetch.scrollThreshold === "function") {
922
+ shouldTrigger = scrollFetch.scrollThreshold(info);
923
+ } else {
924
+ shouldTrigger = info.ratioToBottom >= 0.7;
925
+ }
926
+ if (shouldTrigger) {
927
+ scrollFetch.fetchMore();
910
928
  }
911
929
  },
912
930
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1936,9 +1954,11 @@ var Navbar = ({
1936
1954
  subTitle,
1937
1955
  headImageURL = "",
1938
1956
  headImageURLClassName,
1957
+ tooltipContentClassName = "md:w-[350px] lg:w-[420px]",
1939
1958
  tooltipTitle,
1940
1959
  tooltipIcon,
1941
1960
  tooltipdescription = [],
1961
+ tooltipDescriptionWrapperClassName,
1942
1962
  mainButtonText,
1943
1963
  mainButtonClassName,
1944
1964
  mainButtonDisable = false,
@@ -1957,17 +1977,17 @@ var Navbar = ({
1957
1977
  "nav",
1958
1978
  {
1959
1979
  className: cn(
1960
- "py-5 px-8 w-full h-[5.3rem] bg-sus-primary-1 flex items-center justify-between",
1980
+ "py-3 px-8 w-full h-16 bg-sus-primary-1 flex items-center justify-between",
1961
1981
  className
1962
1982
  ),
1963
1983
  children: [
1964
1984
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5", children: [
1965
- headImageURL !== "" ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: headImageURL, alt: "", className: cn("w-full h-full", headImageURLClassName) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
1966
- React4.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-4xl font-bold", children: title }),
1967
- React4.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: subTitle })
1985
+ headImageURL !== "" ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: headImageURL, alt: "", className: cn("w-full h-full", headImageURLClassName) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
1986
+ React4.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: title }),
1987
+ React4.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-sm font-semibold", children: subTitle })
1968
1988
  ] }),
1969
- tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
1970
- /* @__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" }) }) }),
1989
+ tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { delayDuration: 700, children: [
1990
+ /* @__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" }) }) }),
1971
1991
  /* @__PURE__ */ jsxRuntime.jsxs(
1972
1992
  TooltipContent2,
1973
1993
  {
@@ -1977,11 +1997,12 @@ var Navbar = ({
1977
1997
  align: "start",
1978
1998
  avoidCollisions: false,
1979
1999
  className: cn(
1980
- "bg-background text-foreground border border-black md:w-[350px] lg:w-[420px]",
2000
+ "bg-background text-foreground border border-black",
1981
2001
  "transition-all duration-150 ease-out origin-top",
1982
2002
  "data-[state=closed]:opacity-0 data-[state=open]:opacity-100",
1983
2003
  "data-[state=closed]:scale-95 data-[state=open]:scale-100",
1984
- { "mt-5": isDesktop }
2004
+ { "mt-5": isDesktop },
2005
+ tooltipContentClassName
1985
2006
  ),
1986
2007
  children: [
1987
2008
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1989,7 +2010,10 @@ var Navbar = ({
1989
2010
  {
1990
2011
  role: "tooltip",
1991
2012
  "aria-label": tooltipTitle,
1992
- className: cn("flex flex-col gap-4 max-w-sm text-sm text-gray-700", className),
2013
+ className: cn(
2014
+ "flex flex-col gap-4 max-w-sm text-sm text-gray-700",
2015
+ tooltipDescriptionWrapperClassName
2016
+ ),
1993
2017
  children: [
1994
2018
  tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1995
2019
  React4.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
@@ -2094,6 +2118,7 @@ var ExpandCollapse_default = ExpandCollapse;
2094
2118
 
2095
2119
  // src/components/advanceSearch/operatorMap.ts
2096
2120
  var OPERATOR_MAP = {
2121
+ uuid: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
2097
2122
  text: [
2098
2123
  "contains",
2099
2124
  "equals",
@@ -2123,22 +2148,30 @@ function firstOperatorFor(fields, fieldName) {
2123
2148
  const t3 = getFieldType(fields, fieldName);
2124
2149
  return OPERATOR_MAP[t3][0];
2125
2150
  }
2126
- function makeNewRow(fields) {
2127
- const first = fields[0];
2128
- const op = OPERATOR_MAP[first.type][0];
2151
+ function makeNewRow(field) {
2152
+ const op = OPERATOR_MAP[field.type][0];
2129
2153
  if (op === "between") {
2130
2154
  return {
2131
2155
  id: crypto.randomUUID(),
2132
- fieldName: first.name,
2156
+ fieldName: field.name,
2157
+ fieldType: field.type,
2133
2158
  operator: "between",
2134
2159
  value: "",
2135
- value2: ""
2160
+ value2: "",
2161
+ multiTableSearch: field.multiTableSearch
2136
2162
  };
2137
2163
  }
2138
- return { id: crypto.randomUUID(), fieldName: first.name, operator: op, value: "" };
2164
+ return {
2165
+ id: crypto.randomUUID(),
2166
+ fieldName: field.name,
2167
+ fieldType: field.type,
2168
+ operator: op,
2169
+ value: "",
2170
+ multiTableSearch: field.multiTableSearch
2171
+ };
2139
2172
  }
2140
2173
  function useAdvanceSearch({ fields, limitRows }) {
2141
- const [rows, setRows] = React4.useState([makeNewRow(fields)]);
2174
+ const [rows, setRows] = React4.useState([makeNewRow(fields[0])]);
2142
2175
  const updateRows = React4.useCallback((next) => {
2143
2176
  setRows(next);
2144
2177
  }, []);
@@ -2151,7 +2184,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2151
2184
  );
2152
2185
  const addRow = React4.useCallback(() => {
2153
2186
  if (!limitRows || rows.length < limitRows) {
2154
- updateRows([...rows, makeNewRow(fields)]);
2187
+ updateRows([...rows, makeNewRow(fields[0])]);
2155
2188
  }
2156
2189
  }, [rows, fields, updateRows, limitRows]);
2157
2190
  const removeRow = React4.useCallback(
@@ -2167,22 +2200,29 @@ function useAdvanceSearch({ fields, limitRows }) {
2167
2200
  rows.map((r2) => {
2168
2201
  if (r2.id !== id) return r2;
2169
2202
  const nextOp = firstOperatorFor(fields, r2.fieldName);
2170
- return nextOp === "between" ? { id: r2.id, fieldName: r2.fieldName, operator: "between", value: "", value2: "" } : { id: r2.id, fieldName: r2.fieldName, operator: nextOp, value: "" };
2203
+ return nextOp === "between" ? {
2204
+ id: r2.id,
2205
+ fieldName: r2.fieldName,
2206
+ fieldType: r2.fieldType,
2207
+ operator: "between",
2208
+ value: "",
2209
+ value2: ""
2210
+ } : { id: r2.id, fieldName: r2.fieldName, fieldType: r2.fieldType, operator: nextOp, value: "" };
2171
2211
  })
2172
2212
  );
2173
2213
  },
2174
2214
  [rows, fields, updateRows]
2175
2215
  );
2176
2216
  const clearAllRow = React4.useCallback(() => {
2177
- updateRows([makeNewRow(fields)]);
2217
+ updateRows([makeNewRow(fields[0])]);
2178
2218
  }, [fields, updateRows]);
2179
2219
  const changeField = React4.useCallback(
2180
2220
  (id, fieldName) => {
2181
- const nextOp = firstOperatorFor(fields, fieldName);
2182
2221
  updateRows(
2183
2222
  rows.map((r2) => {
2184
2223
  if (r2.id !== id) return r2;
2185
- return nextOp === "between" ? { id: r2.id, fieldName, operator: "between", value: "", value2: "" } : { id: r2.id, fieldName, operator: nextOp, value: "" };
2224
+ const newRow = makeNewRow(fields.find((f) => f.name === fieldName) || fields[0]);
2225
+ return { ...newRow, id: r2.id };
2186
2226
  })
2187
2227
  );
2188
2228
  },
@@ -2194,9 +2234,24 @@ function useAdvanceSearch({ fields, limitRows }) {
2194
2234
  rows.map((r2) => {
2195
2235
  if (r2.id !== id) return r2;
2196
2236
  if (operator === "between") {
2197
- return { id: r2.id, fieldName: r2.fieldName, operator, value: "", value2: "" };
2237
+ return {
2238
+ id: r2.id,
2239
+ fieldName: r2.fieldName,
2240
+ fieldType: r2.fieldType,
2241
+ multiTableSearch: r2.multiTableSearch,
2242
+ operator,
2243
+ value: "",
2244
+ value2: ""
2245
+ };
2198
2246
  }
2199
- return { id: r2.id, fieldName: r2.fieldName, operator, value: "" };
2247
+ return {
2248
+ id: r2.id,
2249
+ fieldName: r2.fieldName,
2250
+ fieldType: r2.fieldType,
2251
+ multiTableSearch: r2.multiTableSearch,
2252
+ operator,
2253
+ value: ""
2254
+ };
2200
2255
  })
2201
2256
  );
2202
2257
  },
@@ -2221,55 +2276,16 @@ function useAdvanceSearch({ fields, limitRows }) {
2221
2276
  })),
2222
2277
  [fields]
2223
2278
  );
2224
- const rowToFilter = (row) => {
2225
- switch (row.operator) {
2226
- case "between":
2227
- return {
2228
- [row.fieldName]: {
2229
- gte: row.value,
2230
- lte: row.value2
2231
- }
2232
- };
2233
- case "contains":
2234
- return { [row.fieldName]: { contains: row.value } };
2235
- case "beginsWith":
2236
- return { [row.fieldName]: { startsWith: row.value } };
2237
- case "endsWith":
2238
- return { [row.fieldName]: { endsWith: row.value } };
2239
- case "notEquals":
2240
- return { [row.fieldName]: { not: row.value } };
2241
- case "gt":
2242
- return { [row.fieldName]: { gt: row.value } };
2243
- case "gte":
2244
- return { [row.fieldName]: { gte: row.value } };
2245
- case "lt":
2246
- return { [row.fieldName]: { lt: row.value } };
2247
- case "lte":
2248
- return { [row.fieldName]: { lte: row.value } };
2249
- case "is":
2250
- return { [row.fieldName]: row.value };
2251
- case "isNot":
2252
- return { [row.fieldName]: { not: row.value } };
2253
- case "notContains":
2254
- return { [row.fieldName]: { not: { contains: row.value } } };
2255
- case "notBeginsWith":
2256
- return { [row.fieldName]: { not: { startsWith: row.value } } };
2257
- case "notEndsWith":
2258
- return { [row.fieldName]: { not: { endsWith: row.value } } };
2259
- case "containsAny":
2260
- return { [row.fieldName]: { hasSome: row.value.split(",") } };
2261
- case "containsAll":
2262
- return { [row.fieldName]: { hasEvery: row.value.split(",") } };
2263
- case "containsOnly":
2264
- return { [row.fieldName]: { equals: row.value.split(",") } };
2265
- default:
2266
- return { [row.fieldName]: row.value };
2267
- }
2268
- };
2269
- const buildParam = React4.useMemo(() => {
2270
- const andConditions = rows.map((r2) => r2.value ? rowToFilter(r2) : null).filter(Boolean);
2271
- return { AND: andConditions };
2272
- }, [rows]);
2279
+ const buildFilter = React4.useCallback(
2280
+ (prismaFilter, options) => {
2281
+ return options?.multiTableSearch ? {
2282
+ some: {
2283
+ value: { ...prismaFilter, ...options?.insensitive ? { mode: "insensitive" } : void 0 }
2284
+ }
2285
+ } : prismaFilter;
2286
+ },
2287
+ []
2288
+ );
2273
2289
  return {
2274
2290
  rows,
2275
2291
  addRow,
@@ -2281,7 +2297,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2281
2297
  changeValue,
2282
2298
  operatorsForField,
2283
2299
  fieldOptions,
2284
- param: buildParam
2300
+ buildFilter
2285
2301
  };
2286
2302
  }
2287
2303
 
@@ -4807,7 +4823,10 @@ var AdvanceSearch = ({
4807
4823
  onSearch,
4808
4824
  onClear
4809
4825
  }) => {
4810
- const fieldsData = React4.useMemo(() => fields || [], [fields]);
4826
+ const fieldsData = React4.useMemo(() => {
4827
+ if (fields.length === 0) throw new Error("fields cannot be an empty array");
4828
+ return fields || [];
4829
+ }, [fields]);
4811
4830
  const {
4812
4831
  rows,
4813
4832
  addRow,
@@ -4817,7 +4836,8 @@ var AdvanceSearch = ({
4817
4836
  changeField,
4818
4837
  changeOperator,
4819
4838
  operatorsForField,
4820
- fieldOptions
4839
+ fieldOptions,
4840
+ buildFilter
4821
4841
  } = useAdvanceSearch({ fields: fieldsData, limitRows });
4822
4842
  const form = reactHookForm.useForm({
4823
4843
  mode: "onSubmit",
@@ -4829,66 +4849,181 @@ var AdvanceSearch = ({
4829
4849
  const currentValues = getValues();
4830
4850
  const param = {
4831
4851
  AND: rows.map((r2) => {
4832
- const val1 = currentValues[`value_${r2.id}`];
4852
+ let val1 = currentValues[`value_${r2.id}`];
4833
4853
  const val2 = currentValues[`value2_${r2.id}`];
4834
4854
  if (r2.operator === "between") {
4835
4855
  if (!val1 || !val2) return null;
4856
+ const start = new Date(val1);
4857
+ start.setHours(0, 0, 0, 0);
4858
+ const end = new Date(val2);
4859
+ end.setHours(23, 59, 59, 59);
4836
4860
  return {
4837
4861
  [r2.fieldName]: {
4838
- gte: val1,
4839
- lte: val2
4862
+ gte: start.toISOString(),
4863
+ lt: end.toISOString()
4840
4864
  }
4841
4865
  };
4842
4866
  }
4843
4867
  if (!val1) return null;
4868
+ val1 = r2.fieldType === "number" ? Number(val1) : val1;
4844
4869
  switch (r2.operator) {
4845
4870
  case "contains":
4846
- return { [r2.fieldName]: { contains: val1 } };
4871
+ return {
4872
+ [r2.fieldName]: buildFilter(
4873
+ { contains: val1 },
4874
+ {
4875
+ multiTableSearch: r2.multiTableSearch,
4876
+ insensitive: true
4877
+ }
4878
+ )
4879
+ };
4847
4880
  case "beginsWith":
4848
- return { [r2.fieldName]: { startsWith: val1 } };
4881
+ return {
4882
+ [r2.fieldName]: buildFilter(
4883
+ { startsWith: val1 },
4884
+ {
4885
+ multiTableSearch: r2.multiTableSearch,
4886
+ insensitive: true
4887
+ }
4888
+ )
4889
+ };
4849
4890
  case "endsWith":
4850
- return { [r2.fieldName]: { endsWith: val1 } };
4891
+ return {
4892
+ [r2.fieldName]: buildFilter(
4893
+ { endsWith: val1 },
4894
+ {
4895
+ multiTableSearch: r2.multiTableSearch,
4896
+ insensitive: true
4897
+ }
4898
+ )
4899
+ };
4851
4900
  case "equals":
4852
- return { [r2.fieldName]: { equals: val1 } };
4901
+ return {
4902
+ [r2.fieldName]: buildFilter(
4903
+ { equals: val1 },
4904
+ {
4905
+ multiTableSearch: r2.multiTableSearch,
4906
+ insensitive: true
4907
+ }
4908
+ )
4909
+ };
4853
4910
  case "notEquals":
4854
- return { [r2.fieldName]: { not: val1 } };
4911
+ return {
4912
+ [r2.fieldName]: buildFilter(
4913
+ { not: val1 },
4914
+ {
4915
+ multiTableSearch: r2.multiTableSearch,
4916
+ insensitive: true
4917
+ }
4918
+ )
4919
+ };
4855
4920
  case "gt":
4856
- return { [r2.fieldName]: { gt: val1 } };
4921
+ return {
4922
+ [r2.fieldName]: buildFilter({ gt: val1 }, { multiTableSearch: r2.multiTableSearch })
4923
+ };
4857
4924
  case "gte":
4858
- return { [r2.fieldName]: { gte: val1 } };
4925
+ return {
4926
+ [r2.fieldName]: buildFilter({ gte: val1 }, { multiTableSearch: r2.multiTableSearch })
4927
+ };
4859
4928
  case "lt":
4860
- return { [r2.fieldName]: { lt: val1 } };
4929
+ return {
4930
+ [r2.fieldName]: buildFilter({ lt: val1 }, { multiTableSearch: r2.multiTableSearch })
4931
+ };
4861
4932
  case "lte":
4862
- return { [r2.fieldName]: { lte: val1 } };
4933
+ return {
4934
+ [r2.fieldName]: buildFilter({ lte: val1 }, { multiTableSearch: r2.multiTableSearch })
4935
+ };
4863
4936
  case "is":
4864
4937
  return { [r2.fieldName]: val1 };
4865
4938
  case "isNot":
4866
4939
  return { [r2.fieldName]: { not: val1 } };
4867
4940
  case "notContains":
4868
- return { [r2.fieldName]: { not: { contains: val1 } } };
4941
+ return {
4942
+ [r2.fieldName]: buildFilter(
4943
+ { not: { contains: val1 } },
4944
+ {
4945
+ multiTableSearch: r2.multiTableSearch,
4946
+ insensitive: true
4947
+ }
4948
+ )
4949
+ };
4869
4950
  case "notBeginsWith":
4870
- return { [r2.fieldName]: { not: { startsWith: val1 } } };
4951
+ return {
4952
+ [r2.fieldName]: buildFilter(
4953
+ { not: { startsWith: val1 } },
4954
+ {
4955
+ multiTableSearch: r2.multiTableSearch,
4956
+ insensitive: true
4957
+ }
4958
+ )
4959
+ };
4871
4960
  case "notEndsWith":
4872
- return { [r2.fieldName]: { not: { endsWith: val1 } } };
4961
+ return {
4962
+ [r2.fieldName]: buildFilter(
4963
+ { not: { endsWith: val1 } },
4964
+ {
4965
+ multiTableSearch: r2.multiTableSearch,
4966
+ insensitive: true
4967
+ }
4968
+ )
4969
+ };
4873
4970
  case "containsAny":
4874
- return { [r2.fieldName]: { hasSome: String(val1).split(",") } };
4971
+ return {
4972
+ [r2.fieldName]: buildFilter(
4973
+ { hasSome: String(val1).split(",") },
4974
+ { multiTableSearch: r2.multiTableSearch }
4975
+ )
4976
+ };
4875
4977
  case "containsAll":
4876
- return { [r2.fieldName]: { hasEvery: String(val1).split(",") } };
4978
+ return {
4979
+ [r2.fieldName]: buildFilter(
4980
+ { hasEvery: String(val1).split(",") },
4981
+ { multiTableSearch: r2.multiTableSearch }
4982
+ )
4983
+ };
4877
4984
  case "containsOnly":
4878
- return { [r2.fieldName]: { equals: String(val1).split(",") } };
4879
- case "on":
4880
- return { [r2.fieldName]: { on: val1 } };
4985
+ return {
4986
+ [r2.fieldName]: buildFilter(
4987
+ { equals: String(val1).split(",") },
4988
+ {
4989
+ multiTableSearch: r2.multiTableSearch,
4990
+ insensitive: true
4991
+ }
4992
+ )
4993
+ };
4994
+ case "on": {
4995
+ const start = new Date(val1);
4996
+ start.setHours(0, 0, 0, 0);
4997
+ const end = new Date(val1);
4998
+ end.setHours(23, 59, 59, 59);
4999
+ return {
5000
+ [r2.fieldName]: buildFilter(
5001
+ { gte: start.toISOString(), lt: end.toISOString() },
5002
+ { multiTableSearch: r2.multiTableSearch }
5003
+ )
5004
+ };
5005
+ }
4881
5006
  case "after":
4882
- return { [r2.fieldName]: { after: val1 } };
5007
+ return {
5008
+ [r2.fieldName]: buildFilter(
5009
+ { gte: new Date(val1).toISOString() },
5010
+ { multiTableSearch: r2.multiTableSearch }
5011
+ )
5012
+ };
4883
5013
  case "before":
4884
- return { [r2.fieldName]: { before: val1 } };
5014
+ return {
5015
+ [r2.fieldName]: buildFilter(
5016
+ { lt: new Date(val1).toISOString() },
5017
+ { multiTableSearch: r2.multiTableSearch }
5018
+ )
5019
+ };
4885
5020
  }
4886
5021
  }).filter(Boolean)
4887
5022
  };
4888
5023
  if (onSearch) {
4889
5024
  onSearch(param);
4890
5025
  }
4891
- }, [getValues, rows, onSearch]);
5026
+ }, [buildFilter, getValues, rows, onSearch]);
4892
5027
  return /* @__PURE__ */ jsxRuntime.jsx(
4893
5028
  ExpandCollapse_default,
4894
5029
  {