@sustaina/shared-ui 1.2.0 → 1.4.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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React3 = require('react');
3
+ var React4 = require('react');
4
4
  var reactHookForm = require('react-hook-form');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var clsx3 = require('clsx');
@@ -41,7 +41,7 @@ function _interopNamespace(e) {
41
41
  return Object.freeze(n);
42
42
  }
43
43
 
44
- var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
44
+ var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
45
45
  var clsx3__default = /*#__PURE__*/_interopDefault(clsx3);
46
46
  var LabelPrimitive2__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive2);
47
47
  var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
@@ -50,20 +50,20 @@ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitiv
50
50
  var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
51
51
 
52
52
  // src/components/form/form-controls/use-form-field.ts
53
- var FormFieldContext = React3.createContext({});
53
+ var FormFieldContext = React4.createContext({});
54
54
  function FormField(props) {
55
55
  return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
56
56
  }
57
- var FormItemContext = React3.createContext({});
57
+ var FormItemContext = React4.createContext({});
58
58
  function FormItem({ children, ...props }) {
59
- const formItemId = React3.useId();
59
+ const formItemId = React4.useId();
60
60
  return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext, { value: { id: formItemId }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ...props, children }) });
61
61
  }
62
62
 
63
63
  // src/components/form/form-controls/use-form-field.ts
64
64
  function useFormField(options) {
65
- const { name: formFieldName } = React3.useContext(FormFieldContext);
66
- const { id: formItemId } = React3.useContext(FormItemContext);
65
+ const { name: formFieldName } = React4.useContext(FormFieldContext);
66
+ const { id: formItemId } = React4.useContext(FormItemContext);
67
67
  const formContext = reactHookForm.useFormContext();
68
68
  if ((!formFieldName || !formItemId || !formContext) && options?.skipValidationIfNoContext) {
69
69
  return {
@@ -245,11 +245,11 @@ function renderContentSlot(slot, defaultWrapperProps) {
245
245
  return /* @__PURE__ */ jsxRuntime.jsx("div", { ...mergedProps, children: content });
246
246
  }
247
247
  var useHover = () => {
248
- const [hovering, setHovering] = React3.useState(false);
249
- const prevRef = React3.useRef(null);
250
- const onMouseEnter = React3.useCallback(() => setHovering(true), []);
251
- const onMouseLeave = React3.useCallback(() => setHovering(false), []);
252
- const nodeRefCallback = React3.useCallback(
248
+ const [hovering, setHovering] = React4.useState(false);
249
+ const prevRef = React4.useRef(null);
250
+ const onMouseEnter = React4.useCallback(() => setHovering(true), []);
251
+ const onMouseLeave = React4.useCallback(() => setHovering(false), []);
252
+ const nodeRefCallback = React4.useCallback(
253
253
  (node) => {
254
254
  if (prevRef.current) {
255
255
  prevRef.current.removeEventListener("mouseenter", onMouseEnter);
@@ -277,15 +277,15 @@ var useIntersectionObserver = ({
277
277
  initialIsIntersecting = false,
278
278
  onChange
279
279
  } = {}) => {
280
- const [ref, setRef] = React3.useState(null);
281
- const [state, setState] = React3.useState(() => ({
280
+ const [ref, setRef] = React4.useState(null);
281
+ const [state, setState] = React4.useState(() => ({
282
282
  isIntersecting: initialIsIntersecting,
283
283
  entry: void 0
284
284
  }));
285
- const callbackRef = React3.useRef(null);
285
+ const callbackRef = React4.useRef(null);
286
286
  callbackRef.current = onChange;
287
287
  const frozen = state.entry?.isIntersecting && freezeOnceVisible;
288
- React3.useEffect(() => {
288
+ React4.useEffect(() => {
289
289
  if (!ref) return;
290
290
  if (!("IntersectionObserver" in window)) return;
291
291
  if (frozen) return;
@@ -315,8 +315,8 @@ var useIntersectionObserver = ({
315
315
  frozen,
316
316
  freezeOnceVisible
317
317
  ]);
318
- const prevRef = React3.useRef(null);
319
- React3.useEffect(() => {
318
+ const prevRef = React4.useRef(null);
319
+ React4.useEffect(() => {
320
320
  if (!ref && state.entry?.target && !freezeOnceVisible && !frozen && prevRef.current !== state.entry.target) {
321
321
  prevRef.current = state.entry.target;
322
322
  setState({ isIntersecting: initialIsIntersecting, entry: void 0 });
@@ -333,8 +333,8 @@ var isValidMediaQueryString = (query) => {
333
333
  return query !== "not all";
334
334
  };
335
335
  var useMediaQuery = ({ query }) => {
336
- const [matches, setMatches] = React3.useState(false);
337
- React3.useEffect(() => {
336
+ const [matches, setMatches] = React4.useState(false);
337
+ React4.useEffect(() => {
338
338
  if (typeof window === "undefined") {
339
339
  return;
340
340
  }
@@ -582,9 +582,9 @@ var modelOptions = [
582
582
  "getCenterVisibleLeafColumns"
583
583
  ];
584
584
  var DataTableDevTool = ({ table }) => {
585
- const [open, setOpen] = React3.useState(false);
586
- const [visibleStates, setVisibleStates] = React3.useState([]);
587
- const [visibleModels, setVisibleModels] = React3.useState([]);
585
+ const [open, setOpen] = React4.useState(false);
586
+ const [visibleStates, setVisibleStates] = React4.useState([]);
587
+ const [visibleModels, setVisibleModels] = React4.useState([]);
588
588
  const tableState = table.getState();
589
589
  const toggleValue = (arr, value) => arr.includes(value) ? arr.filter((v) => v !== value) : [...arr, value];
590
590
  const getCircularReplacer = () => {
@@ -826,14 +826,14 @@ var DataTable = ({
826
826
  if (isDefined(tableRef) && !isDefined(tableRef?.current)) {
827
827
  tableRef.current = table;
828
828
  }
829
- const tableContainerRef = React3.useRef(null);
829
+ const tableContainerRef = React4.useRef(null);
830
830
  const isTableEmpty = table.getCoreRowModel().rows.length === 0;
831
831
  const isTableEmptyAfterFiltering = table.getRowModel().rows.length === 0;
832
832
  const isFiltering = table.getState().columnFilters.length > 0 || !!table.getState().globalFilter;
833
833
  const leftVisibleLeftColumns = table.getLeftVisibleLeafColumns();
834
834
  const centerVisibleLeafColumns = table.getCenterVisibleLeafColumns();
835
835
  const rightVisibleLeafColumns = table.getRightVisibleLeafColumns();
836
- const { isSomeColumnsFilterable, filterableColumns } = React3.useMemo(() => {
836
+ const { isSomeColumnsFilterable, filterableColumns } = React4.useMemo(() => {
837
837
  const mergedColumns = [
838
838
  ...leftVisibleLeftColumns,
839
839
  ...centerVisibleLeafColumns,
@@ -844,7 +844,7 @@ var DataTable = ({
844
844
  );
845
845
  return { isSomeColumnsFilterable: isSomeColumnsFilterable2, filterableColumns: mergedColumns };
846
846
  }, [centerVisibleLeafColumns, leftVisibleLeftColumns, rightVisibleLeafColumns]);
847
- const fetchMoreOnScrollReached = React3.useCallback(
847
+ const fetchMoreOnScrollReached = React4.useCallback(
848
848
  (containerRefElement) => {
849
849
  if (!scrollFetch?.enabled) {
850
850
  return;
@@ -860,7 +860,7 @@ var DataTable = ({
860
860
  // eslint-disable-next-line react-hooks/exhaustive-deps
861
861
  [scrollFetch?.enabled, scrollFetch?.isFetchingMore, scrollFetch?.hasMore, scrollFetch?.fetchMore]
862
862
  );
863
- React3.useEffect(() => {
863
+ React4.useEffect(() => {
864
864
  fetchMoreOnScrollReached(tableContainerRef.current);
865
865
  }, [fetchMoreOnScrollReached]);
866
866
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -945,7 +945,7 @@ var DataTable = ({
945
945
  ),
946
946
  /* @__PURE__ */ jsxRuntime.jsx(TableBody, { ...components?.tableBodyProps, children: table.getRowModel().rows.map((row) => {
947
947
  const tableDataRowProps = typeof components?.tableDataRowProps === "function" ? components.tableDataRowProps({ row, table }) || {} : components?.tableDataRowProps || {};
948
- return /* @__PURE__ */ React3.createElement(
948
+ return /* @__PURE__ */ React4.createElement(
949
949
  TableRow,
950
950
  {
951
951
  ...tableDataRowProps,
@@ -1009,6 +1009,38 @@ var DataTable = ({
1009
1009
  );
1010
1010
  };
1011
1011
  var DataTable_default = DataTable;
1012
+ var usePreventPageLeaveStore = zustand.create((set) => ({
1013
+ isPreventing: false,
1014
+ setPreventing: (value) => set({ isPreventing: value })
1015
+ }));
1016
+ var usePreventPageLeaveStore_default = usePreventPageLeaveStore;
1017
+
1018
+ // src/components/prevent-page-leave/PreventPageLeave.tsx
1019
+ var PreventPageLeave = ({ children }) => {
1020
+ const { isPreventing } = usePreventPageLeaveStore();
1021
+ React4.useEffect(() => {
1022
+ if (!isPreventing || typeof window === "undefined") {
1023
+ return;
1024
+ }
1025
+ function beforeUnload(event) {
1026
+ event.preventDefault();
1027
+ event.returnValue = true;
1028
+ }
1029
+ window.addEventListener("beforeunload", beforeUnload);
1030
+ return () => {
1031
+ window.removeEventListener("beforeunload", beforeUnload);
1032
+ };
1033
+ }, [isPreventing]);
1034
+ return children;
1035
+ };
1036
+ var PreventPageLeave_default = PreventPageLeave;
1037
+ var usePreventPageLeave = ({ isPrevening }) => {
1038
+ const setPreventing = usePreventPageLeaveStore_default((state) => state.setPreventing);
1039
+ React4.useEffect(() => {
1040
+ setPreventing(isPrevening);
1041
+ }, [isPrevening, setPreventing]);
1042
+ };
1043
+ var usePreventPageLeave_default = usePreventPageLeave;
1012
1044
  var buttonVariants = classVarianceAuthority.cva(
1013
1045
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive cursor-pointer",
1014
1046
  {
@@ -1132,15 +1164,15 @@ var t2 = function(o3, t3, s2) {
1132
1164
  };
1133
1165
  };
1134
1166
  var Form = reactHookForm.FormProvider;
1135
- var FormFieldContext2 = React3__namespace.createContext({});
1167
+ var FormFieldContext2 = React4__namespace.createContext({});
1136
1168
  var FormField2 = ({
1137
1169
  ...props
1138
1170
  }) => {
1139
1171
  return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext2.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
1140
1172
  };
1141
1173
  var useFormField2 = () => {
1142
- const fieldContext = React3__namespace.useContext(FormFieldContext2);
1143
- const itemContext = React3__namespace.useContext(FormItemContext2);
1174
+ const fieldContext = React4__namespace.useContext(FormFieldContext2);
1175
+ const itemContext = React4__namespace.useContext(FormItemContext2);
1144
1176
  const { getFieldState } = reactHookForm.useFormContext();
1145
1177
  const formState = reactHookForm.useFormState({ name: fieldContext.name });
1146
1178
  const fieldState = getFieldState(fieldContext.name, formState);
@@ -1157,9 +1189,9 @@ var useFormField2 = () => {
1157
1189
  ...fieldState
1158
1190
  };
1159
1191
  };
1160
- var FormItemContext2 = React3__namespace.createContext({});
1192
+ var FormItemContext2 = React4__namespace.createContext({});
1161
1193
  function FormItem2({ className, ...props }) {
1162
- const id = React3__namespace.useId();
1194
+ const id = React4__namespace.useId();
1163
1195
  return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext2.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "form-item", className: cn("grid gap-2", className), ...props }) });
1164
1196
  }
1165
1197
  function FormControl({ ...props }) {
@@ -1505,7 +1537,9 @@ function SortableRow({
1505
1537
  children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Choose column..." })
1506
1538
  }
1507
1539
  ) }),
1508
- /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.filter((i2) => i2.id === field.value || !currentColumns?.some((c) => c.id === i2.id)).sort(
1540
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.filter(
1541
+ (i2) => i2.id === field.value || !currentColumns?.some((c, idx) => c.id === i2.id && idx !== index)
1542
+ ).sort(
1509
1543
  (a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
1510
1544
  ).map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
1511
1545
  SelectItem,
@@ -1619,7 +1653,7 @@ var GridSettingsModal = ({
1619
1653
  onClose,
1620
1654
  onSaveColumns
1621
1655
  }) => {
1622
- const [isDragging, setIsDragging] = React3.useState(false);
1656
+ const [isDragging, setIsDragging] = React4.useState(false);
1623
1657
  const form = reactHookForm.useForm({
1624
1658
  resolver: t2(GridSettingsSchema),
1625
1659
  defaultValues: { columns: currentColumns },
@@ -1631,7 +1665,7 @@ var GridSettingsModal = ({
1631
1665
  name: "columns",
1632
1666
  keyName: "fieldId"
1633
1667
  });
1634
- React3.useEffect(() => {
1668
+ React4.useEffect(() => {
1635
1669
  if (isOpen) {
1636
1670
  form.reset({ columns: currentColumns });
1637
1671
  }
@@ -1719,16 +1753,16 @@ var GridSettingsModal = ({
1719
1753
  {
1720
1754
  items: fields?.slice(1).map((c) => c?.fieldId),
1721
1755
  strategy: sortable.verticalListSortingStrategy,
1722
- children: fields?.slice(1).map((col, index) => /* @__PURE__ */ jsxRuntime.jsx(
1756
+ children: fields?.slice(1).map((col, index2) => /* @__PURE__ */ jsxRuntime.jsx(
1723
1757
  SortableRow,
1724
1758
  {
1725
1759
  value: col?.fieldId,
1726
1760
  control,
1727
- name: `columns.${index + 1}.id`,
1761
+ name: `columns.${index2 + 1}.id`,
1728
1762
  isDragging,
1729
1763
  availableColumns,
1730
1764
  currentColumns: fields,
1731
- onRemove: () => remove(index + 1)
1765
+ onRemove: () => remove(index2 + 1)
1732
1766
  },
1733
1767
  col?.fieldId
1734
1768
  ))
@@ -1797,7 +1831,7 @@ var InfoIcon = (props) => {
1797
1831
  }
1798
1832
  );
1799
1833
  };
1800
- var InfoIcon_default = React3__namespace.default.memo(InfoIcon);
1834
+ var InfoIcon_default = React4__namespace.default.memo(InfoIcon);
1801
1835
  function TooltipProvider2({
1802
1836
  delayDuration = 0,
1803
1837
  ...props
@@ -1861,10 +1895,12 @@ var Navbar = ({
1861
1895
  subButtonDisable = false,
1862
1896
  onMainButtonClick,
1863
1897
  onSubButtonClick,
1898
+ separatorDisable = false,
1864
1899
  searchButton
1865
1900
  }) => {
1866
1901
  const { isMobile, isTablet, isDesktop } = useScreenSize_default();
1867
1902
  const Icon3 = lucideReact.CircleHelp;
1903
+ const shouldShowSeparator = !separatorDisable && React4.isValidElement(searchButton);
1868
1904
  return /* @__PURE__ */ jsxRuntime.jsxs(
1869
1905
  "nav",
1870
1906
  {
@@ -1875,8 +1911,8 @@ var Navbar = ({
1875
1911
  children: [
1876
1912
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5", children: [
1877
1913
  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: [
1878
- React3.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-4xl font-bold", children: title }),
1879
- React3.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: subTitle })
1914
+ React4.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-4xl font-bold", children: title }),
1915
+ React4.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: subTitle })
1880
1916
  ] }),
1881
1917
  tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
1882
1918
  /* @__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" }) }) }),
@@ -1904,10 +1940,10 @@ var Navbar = ({
1904
1940
  className: cn("flex flex-col gap-4 max-w-sm text-sm text-gray-700", className),
1905
1941
  children: [
1906
1942
  tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1907
- React3.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
1943
+ React4.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
1908
1944
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-bold", children: tooltipTitle })
1909
1945
  ] }),
1910
- React3.isValidElement(tooltipdescription) ? tooltipdescription : ""
1946
+ React4.isValidElement(tooltipdescription) ? tooltipdescription : ""
1911
1947
  ]
1912
1948
  }
1913
1949
  ),
@@ -1960,16 +1996,16 @@ var Navbar = ({
1960
1996
  children: subButtonText
1961
1997
  }
1962
1998
  ),
1963
- React3.isValidElement(searchButton) ? /* @__PURE__ */ jsxRuntime.jsx("div", { role: "separator", className: "ml-1 w-[1px] h-10 bg-white" }) : "",
1964
- React3.isValidElement(searchButton) ? searchButton : ""
1999
+ shouldShowSeparator && /* @__PURE__ */ jsxRuntime.jsx("div", { role: "separator", className: "ml-1 w-[1px] h-10 bg-white" }),
2000
+ React4.isValidElement(searchButton) ? searchButton : ""
1965
2001
  ] })
1966
2002
  ]
1967
2003
  }
1968
2004
  );
1969
2005
  };
1970
- var navbar_default = React3__namespace.default.memo(Navbar);
2006
+ var navbar_default = React4__namespace.default.memo(Navbar);
1971
2007
  var ExpandCollapse = ({ title, children, portalId }) => {
1972
- const [isOpen, setIsOpen] = React3.useState(false);
2008
+ const [isOpen, setIsOpen] = React4.useState(false);
1973
2009
  const Panel = /* @__PURE__ */ jsxRuntime.jsx(
1974
2010
  "div",
1975
2011
  {
@@ -2050,30 +2086,30 @@ function makeNewRow(fields) {
2050
2086
  return { id: crypto.randomUUID(), fieldName: first.name, operator: op, value: "" };
2051
2087
  }
2052
2088
  function useAdvanceSearch({ fields, limitRows }) {
2053
- const [rows, setRows] = React3.useState([makeNewRow(fields)]);
2054
- const updateRows = React3.useCallback((next) => {
2089
+ const [rows, setRows] = React4.useState([makeNewRow(fields)]);
2090
+ const updateRows = React4.useCallback((next) => {
2055
2091
  setRows(next);
2056
2092
  }, []);
2057
- const operatorsForField = React3.useCallback(
2093
+ const operatorsForField = React4.useCallback(
2058
2094
  (fieldName) => {
2059
2095
  const t3 = getFieldType(fields, fieldName);
2060
2096
  return OPERATOR_MAP[t3];
2061
2097
  },
2062
2098
  [fields]
2063
2099
  );
2064
- const addRow = React3.useCallback(() => {
2100
+ const addRow = React4.useCallback(() => {
2065
2101
  if (!limitRows || rows.length < limitRows) {
2066
2102
  updateRows([...rows, makeNewRow(fields)]);
2067
2103
  }
2068
2104
  }, [rows, fields, updateRows, limitRows]);
2069
- const removeRow = React3.useCallback(
2105
+ const removeRow = React4.useCallback(
2070
2106
  (id) => {
2071
2107
  if (rows.length === 1) return;
2072
2108
  updateRows(rows.filter((r2) => r2.id !== id));
2073
2109
  },
2074
2110
  [rows, updateRows]
2075
2111
  );
2076
- const clearRow = React3.useCallback(
2112
+ const clearRow = React4.useCallback(
2077
2113
  (id) => {
2078
2114
  updateRows(
2079
2115
  rows.map((r2) => {
@@ -2085,10 +2121,10 @@ function useAdvanceSearch({ fields, limitRows }) {
2085
2121
  },
2086
2122
  [rows, fields, updateRows]
2087
2123
  );
2088
- const clearAllRow = React3.useCallback(() => {
2124
+ const clearAllRow = React4.useCallback(() => {
2089
2125
  updateRows([makeNewRow(fields)]);
2090
2126
  }, [fields, updateRows]);
2091
- const changeField = React3.useCallback(
2127
+ const changeField = React4.useCallback(
2092
2128
  (id, fieldName) => {
2093
2129
  const nextOp = firstOperatorFor(fields, fieldName);
2094
2130
  updateRows(
@@ -2100,7 +2136,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2100
2136
  },
2101
2137
  [rows, fields, updateRows]
2102
2138
  );
2103
- const changeOperator = React3.useCallback(
2139
+ const changeOperator = React4.useCallback(
2104
2140
  (id, operator) => {
2105
2141
  updateRows(
2106
2142
  rows.map((r2) => {
@@ -2114,7 +2150,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2114
2150
  },
2115
2151
  [rows, updateRows]
2116
2152
  );
2117
- const changeValue = React3.useCallback(
2153
+ const changeValue = React4.useCallback(
2118
2154
  (id, which, val) => {
2119
2155
  updateRows(
2120
2156
  rows.map((r2) => {
@@ -2126,7 +2162,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2126
2162
  },
2127
2163
  [rows, updateRows]
2128
2164
  );
2129
- const fieldOptions = React3.useMemo(
2165
+ const fieldOptions = React4.useMemo(
2130
2166
  () => fields.map((f) => ({
2131
2167
  value: f.name,
2132
2168
  label: f.label ?? f.name
@@ -2178,7 +2214,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2178
2214
  return { [row.fieldName]: row.value };
2179
2215
  }
2180
2216
  };
2181
- const buildParam = React3.useMemo(() => {
2217
+ const buildParam = React4.useMemo(() => {
2182
2218
  const andConditions = rows.map((r2) => r2.value ? rowToFilter(r2) : null).filter(Boolean);
2183
2219
  return { AND: andConditions };
2184
2220
  }, [rows]);
@@ -2502,13 +2538,13 @@ function DatePicker({
2502
2538
  className,
2503
2539
  ...props
2504
2540
  }) {
2505
- const today = React3__namespace.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
2506
- const [displayed, setDisplayed] = React3__namespace.useState(
2541
+ const today = React4__namespace.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
2542
+ const [displayed, setDisplayed] = React4__namespace.useState(
2507
2543
  selectedDate ? new Date(selectedDate) : /* @__PURE__ */ new Date()
2508
2544
  );
2509
2545
  minDate = clampToDay(minDate);
2510
2546
  maxDate = clampToDay(maxDate);
2511
- const disabledSet = React3__namespace.useMemo(() => {
2547
+ const disabledSet = React4__namespace.useMemo(() => {
2512
2548
  const s2 = /* @__PURE__ */ new Set();
2513
2549
  disabledDates?.forEach((d) => s2.add(startOfDay(d).toISOString()));
2514
2550
  return s2;
@@ -2517,7 +2553,7 @@ function DatePicker({
2517
2553
  const displayMonth = displayed.getMonth();
2518
2554
  const monthLabel = callbacks?.monthLabel?.(displayYear, displayMonth) ?? new Intl.DateTimeFormat(void 0, { month: "short" }).format(displayed);
2519
2555
  const yearLabel = callbacks?.yearLabel?.(displayYear) ?? String(displayYear);
2520
- const weekdays = React3__namespace.useMemo(() => {
2556
+ const weekdays = React4__namespace.useMemo(() => {
2521
2557
  const labels = [];
2522
2558
  for (let i2 = 0; i2 < 7; i2++) {
2523
2559
  const idx = i2;
@@ -2526,7 +2562,7 @@ function DatePicker({
2526
2562
  }
2527
2563
  return labels;
2528
2564
  }, [callbacks]);
2529
- const grid = React3__namespace.useMemo(() => buildCalendarGrid(displayed, true), [displayed]);
2565
+ const grid = React4__namespace.useMemo(() => buildCalendarGrid(displayed, true), [displayed]);
2530
2566
  const isDateDisabled = (date) => {
2531
2567
  const d = startOfDay(date);
2532
2568
  if (minDate && d < minDate) return true;
@@ -2605,7 +2641,7 @@ function DatePicker({
2605
2641
  ] });
2606
2642
  }
2607
2643
  var TagsInput = ({ value = [], onChange, onClear, error }) => {
2608
- const [inputValue, setInputValue] = React3.useState("");
2644
+ const [inputValue, setInputValue] = React4.useState("");
2609
2645
  const addTag = (val) => {
2610
2646
  const trimmed = val.trim();
2611
2647
  if (!trimmed) return;
@@ -2613,8 +2649,8 @@ var TagsInput = ({ value = [], onChange, onClear, error }) => {
2613
2649
  onChange([...value, trimmed]);
2614
2650
  setInputValue("");
2615
2651
  };
2616
- const removeTag = (index) => {
2617
- const newTags = value.filter((_, i2) => i2 !== index);
2652
+ const removeTag = (index2) => {
2653
+ const newTags = value.filter((_, i2) => i2 !== index2);
2618
2654
  onChange(newTags);
2619
2655
  };
2620
2656
  const handleKeyDown = (e2) => {
@@ -2953,8 +2989,8 @@ function buildLocalizeFn(args) {
2953
2989
  const width = options?.width ? String(options.width) : args.defaultWidth;
2954
2990
  valuesArray = args.values[width] || args.values[defaultWidth];
2955
2991
  }
2956
- const index = args.argumentCallback ? args.argumentCallback(value) : value;
2957
- return valuesArray[index];
2992
+ const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
2993
+ return valuesArray[index2];
2958
2994
  };
2959
2995
  }
2960
2996
 
@@ -3274,7 +3310,7 @@ var match = {
3274
3310
  defaultMatchWidth: "wide",
3275
3311
  parsePatterns: parseQuarterPatterns,
3276
3312
  defaultParseWidth: "any",
3277
- valueCallback: (index) => index + 1
3313
+ valueCallback: (index2) => index2 + 1
3278
3314
  }),
3279
3315
  month: buildMatchFn({
3280
3316
  matchPatterns: matchMonthPatterns,
@@ -4409,15 +4445,15 @@ function Label4({ className, ...props }) {
4409
4445
  );
4410
4446
  }
4411
4447
  var Form2 = reactHookForm.FormProvider;
4412
- var FormFieldContext3 = React3__namespace.createContext({});
4448
+ var FormFieldContext3 = React4__namespace.createContext({});
4413
4449
  var FormField3 = ({
4414
4450
  ...props
4415
4451
  }) => {
4416
4452
  return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext3.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
4417
4453
  };
4418
4454
  var useFormField3 = () => {
4419
- const fieldContext = React3__namespace.useContext(FormFieldContext3);
4420
- const itemContext = React3__namespace.useContext(FormItemContext3);
4455
+ const fieldContext = React4__namespace.useContext(FormFieldContext3);
4456
+ const itemContext = React4__namespace.useContext(FormItemContext3);
4421
4457
  const { getFieldState } = reactHookForm.useFormContext();
4422
4458
  const formState = reactHookForm.useFormState({ name: fieldContext.name });
4423
4459
  const fieldState = getFieldState(fieldContext.name, formState);
@@ -4434,9 +4470,9 @@ var useFormField3 = () => {
4434
4470
  ...fieldState
4435
4471
  };
4436
4472
  };
4437
- var FormItemContext3 = React3__namespace.createContext({});
4473
+ var FormItemContext3 = React4__namespace.createContext({});
4438
4474
  function FormItem3({ className, ...props }) {
4439
- const id = React3__namespace.useId();
4475
+ const id = React4__namespace.useId();
4440
4476
  return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext3.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "form-item", className: cn2("grid gap-2", className), ...props }) });
4441
4477
  }
4442
4478
  function FormControl2({ ...props }) {
@@ -4468,7 +4504,7 @@ var AdvanceSearchRow = ({
4468
4504
  const { control } = form;
4469
4505
  const fieldSchema = fields.find((f) => f.name === row.fieldName);
4470
4506
  const fieldType = fieldSchema?.type ?? "text";
4471
- React3__namespace.default.useEffect(() => {
4507
+ React4__namespace.default.useEffect(() => {
4472
4508
  if (operators && operators.length > 0 && !operators.includes(row.operator)) {
4473
4509
  onChangeOperator(operators[0]);
4474
4510
  }
@@ -4479,8 +4515,8 @@ var AdvanceSearchRow = ({
4479
4515
  const isLookup = fieldType === "lookup";
4480
4516
  const isNumber = fieldType === "number";
4481
4517
  const isDate2 = fieldType === "date" || fieldType === "datetime";
4482
- const [openDateValue1, setOpenDateValue1] = React3__namespace.default.useState(false);
4483
- const [openDateValue2, setOpenDateValue2] = React3__namespace.default.useState(false);
4518
+ const [openDateValue1, setOpenDateValue1] = React4__namespace.default.useState(false);
4519
+ const [openDateValue2, setOpenDateValue2] = React4__namespace.default.useState(false);
4484
4520
  const toDateFromISO = (v) => {
4485
4521
  if (!v) return void 0;
4486
4522
  try {
@@ -4716,9 +4752,10 @@ var AdvanceSearch = ({
4716
4752
  portalId,
4717
4753
  iconColor = "#ffffff",
4718
4754
  limitRows = 4,
4719
- onSearch
4755
+ onSearch,
4756
+ onClear
4720
4757
  }) => {
4721
- const fieldsData = React3.useMemo(() => fields || [], [fields]);
4758
+ const fieldsData = React4.useMemo(() => fields || [], [fields]);
4722
4759
  const {
4723
4760
  rows,
4724
4761
  addRow,
@@ -4736,7 +4773,7 @@ var AdvanceSearch = ({
4736
4773
  defaultValues: {}
4737
4774
  });
4738
4775
  const { handleSubmit, unregister, resetField, getValues, setValue } = form;
4739
- const onSubmit = React3.useCallback(() => {
4776
+ const onSubmit = React4.useCallback(() => {
4740
4777
  const currentValues = getValues();
4741
4778
  const param = {
4742
4779
  AND: rows.map((r2) => {
@@ -4759,6 +4796,8 @@ var AdvanceSearch = ({
4759
4796
  return { [r2.fieldName]: { startsWith: val1 } };
4760
4797
  case "endsWith":
4761
4798
  return { [r2.fieldName]: { endsWith: val1 } };
4799
+ case "equals":
4800
+ return { [r2.fieldName]: { equals: val1 } };
4762
4801
  case "notEquals":
4763
4802
  return { [r2.fieldName]: { not: val1 } };
4764
4803
  case "gt":
@@ -4785,8 +4824,12 @@ var AdvanceSearch = ({
4785
4824
  return { [r2.fieldName]: { hasEvery: String(val1).split(",") } };
4786
4825
  case "containsOnly":
4787
4826
  return { [r2.fieldName]: { equals: String(val1).split(",") } };
4788
- default:
4789
- return { [r2.fieldName]: val1 };
4827
+ case "on":
4828
+ return { [r2.fieldName]: { on: val1 } };
4829
+ case "after":
4830
+ return { [r2.fieldName]: { after: val1 } };
4831
+ case "before":
4832
+ return { [r2.fieldName]: { before: val1 } };
4790
4833
  }
4791
4834
  }).filter(Boolean)
4792
4835
  };
@@ -4842,7 +4885,7 @@ var AdvanceSearch = ({
4842
4885
  onClick: () => {
4843
4886
  clearAllRow();
4844
4887
  Object.keys(getValues()).forEach((k) => resetField(k));
4845
- onSubmit();
4888
+ if (onClear) onClear();
4846
4889
  },
4847
4890
  children: "Clear Search"
4848
4891
  }
@@ -5046,6 +5089,7 @@ exports.GridSettingsModal = GridSettingsModal_default;
5046
5089
  exports.HeaderCell = HeaderCell_default;
5047
5090
  exports.Navbar = navbar_default;
5048
5091
  exports.NumberInput = NumberInput;
5092
+ exports.PreventPageLeave = PreventPageLeave_default;
5049
5093
  exports.TextInput = TextInput;
5050
5094
  exports.booleanToSelectValue = booleanToSelectValue;
5051
5095
  exports.buttonVariants = buttonVariants;
@@ -5059,6 +5103,8 @@ exports.useGridSettingsStore = useGridSettingsStore;
5059
5103
  exports.useHover = useHover_default;
5060
5104
  exports.useIntersectionObserver = useIntersectionObserver_default;
5061
5105
  exports.useMediaQuery = useMediaQuery_default;
5106
+ exports.usePreventPageLeave = usePreventPageLeave_default;
5107
+ exports.usePreventPageLeaveStore = usePreventPageLeaveStore_default;
5062
5108
  exports.useScreenSize = useScreenSize_default;
5063
5109
  //# sourceMappingURL=index.js.map
5064
5110
  //# sourceMappingURL=index.js.map