@sustaina/shared-ui 1.3.0 → 1.4.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.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 }) {
@@ -1450,7 +1482,6 @@ function TooltipContent({
1450
1482
  }
1451
1483
  function SortableRow({
1452
1484
  availableColumns,
1453
- currentColumns,
1454
1485
  control,
1455
1486
  name,
1456
1487
  value,
@@ -1466,88 +1497,86 @@ function SortableRow({
1466
1497
  transition
1467
1498
  };
1468
1499
  const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
1469
- const options = availableColumns.map((col) => ({
1470
- id: col.id,
1471
- label: capitalize(col.id)
1472
- }));
1500
+ const currentFormColumns = reactHookForm.useWatch({ control, name: "columns" });
1473
1501
  return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setNodeRef, style, className: "flex items-center rounded-md bg-white", children: /* @__PURE__ */ jsxRuntime.jsx(
1474
1502
  FormField2,
1475
1503
  {
1476
1504
  control,
1477
1505
  name,
1478
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem2, { className: "flex-1", children: [
1479
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1480
- /* @__PURE__ */ jsxRuntime.jsx(
1481
- lucideReact.GripVertical,
1482
- {
1483
- ...attributes,
1484
- ...listeners,
1485
- className: cn(
1486
- "h-5 w-5 text-[#B9B9B9] focus:outline-none cursor-grab",
1487
- name == "columns.0.id" && "opacity-0 pointer-events-none"
1488
- )
1489
- }
1490
- ),
1491
- /* @__PURE__ */ jsxRuntime.jsxs(
1492
- Select,
1493
- {
1494
- value: field.value,
1495
- onValueChange: field.onChange,
1496
- disabled: name == "columns.0.id",
1497
- children: [
1498
- /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
1499
- SelectTrigger,
1500
- {
1501
- className: cn(
1502
- "w-full border-[#DDDDDD] data-[disabled]:opacity-100 aria-invalid:border-[#BB0B0E]",
1503
- name == "columns.0.id" ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
1504
- ),
1505
- children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Choose column..." })
1506
- }
1507
- ) }),
1508
- /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.filter(
1509
- (i2) => i2.id === field.value || !currentColumns?.some((c, idx) => c.id === i2.id && idx !== index)
1510
- ).sort(
1511
- (a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
1512
- ).map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
1513
- SelectItem,
1514
- {
1515
- value: opt.id,
1516
- className: cn(
1517
- "focus:bg-[#e8edea]",
1518
- opt.id === field.value ? "font-bold bg-[#dae5de] focus:bg-[#dae5de]" : ""
1519
- ),
1520
- children: opt.label
1521
- },
1522
- opt.id
1523
- )) })
1524
- ]
1525
- }
1526
- ),
1527
- name == "columns.0.id" ? /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
1528
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: "h-5 w-5", stroke: "white", fill: "#8B8B8B" }) }),
1506
+ render: ({ field }) => {
1507
+ 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) }));
1508
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormItem2, { className: "flex-1", children: [
1509
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1529
1510
  /* @__PURE__ */ jsxRuntime.jsx(
1530
- TooltipContent,
1511
+ lucideReact.GripVertical,
1531
1512
  {
1532
- align: "start",
1533
- alignOffset: 10,
1534
- className: "bg-[#8B8B8B] rounded-none",
1535
- arrowClassName: "!hidden",
1536
- children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Column cannot be removed." })
1513
+ ...attributes,
1514
+ ...listeners,
1515
+ className: cn(
1516
+ "h-5 w-5 text-[#B9B9B9] focus:outline-none cursor-grab",
1517
+ name == "columns.0.id" && "opacity-0 pointer-events-none"
1518
+ )
1519
+ }
1520
+ ),
1521
+ /* @__PURE__ */ jsxRuntime.jsxs(
1522
+ Select,
1523
+ {
1524
+ value: field.value,
1525
+ onValueChange: field.onChange,
1526
+ disabled: name == "columns.0.id",
1527
+ children: [
1528
+ /* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
1529
+ SelectTrigger,
1530
+ {
1531
+ className: cn(
1532
+ "w-full border-[#DDDDDD] data-[disabled]:opacity-100 aria-invalid:border-[#BB0B0E]",
1533
+ name == "columns.0.id" ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
1534
+ ),
1535
+ children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Choose column..." })
1536
+ }
1537
+ ) }),
1538
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.sort(
1539
+ (a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
1540
+ ).map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
1541
+ SelectItem,
1542
+ {
1543
+ value: opt.id,
1544
+ className: cn(
1545
+ "focus:bg-[#e8edea]",
1546
+ opt.id === field.value ? "font-bold bg-[#dae5de] focus:bg-[#dae5de]" : ""
1547
+ ),
1548
+ children: opt.label
1549
+ },
1550
+ opt.id
1551
+ )) })
1552
+ ]
1553
+ }
1554
+ ),
1555
+ name == "columns.0.id" ? /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
1556
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: "h-5 w-5", stroke: "white", fill: "#8B8B8B" }) }),
1557
+ /* @__PURE__ */ jsxRuntime.jsx(
1558
+ TooltipContent,
1559
+ {
1560
+ align: "start",
1561
+ alignOffset: 10,
1562
+ className: "bg-[#8B8B8B] rounded-none",
1563
+ arrowClassName: "!hidden",
1564
+ children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Column cannot be removed." })
1565
+ }
1566
+ )
1567
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
1568
+ lucideReact.CircleMinus,
1569
+ {
1570
+ onClick: onRemove,
1571
+ className: "h-5 w-5 cursor-pointer",
1572
+ stroke: "white",
1573
+ fill: "#C32A2C"
1537
1574
  }
1538
1575
  )
1539
- ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
1540
- lucideReact.CircleMinus,
1541
- {
1542
- onClick: onRemove,
1543
- className: "h-5 w-5 cursor-pointer",
1544
- stroke: "white",
1545
- fill: "#C32A2C"
1546
- }
1547
- )
1548
- ] }),
1549
- !isDragging && /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]") })
1550
- ] })
1576
+ ] }),
1577
+ !isDragging && /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]") })
1578
+ ] });
1579
+ }
1551
1580
  }
1552
1581
  ) });
1553
1582
  }
@@ -1621,7 +1650,7 @@ var GridSettingsModal = ({
1621
1650
  onClose,
1622
1651
  onSaveColumns
1623
1652
  }) => {
1624
- const [isDragging, setIsDragging] = React3.useState(false);
1653
+ const [isDragging, setIsDragging] = React4.useState(false);
1625
1654
  const form = reactHookForm.useForm({
1626
1655
  resolver: t2(GridSettingsSchema),
1627
1656
  defaultValues: { columns: currentColumns },
@@ -1633,7 +1662,7 @@ var GridSettingsModal = ({
1633
1662
  name: "columns",
1634
1663
  keyName: "fieldId"
1635
1664
  });
1636
- React3.useEffect(() => {
1665
+ React4.useEffect(() => {
1637
1666
  if (isOpen) {
1638
1667
  form.reset({ columns: currentColumns });
1639
1668
  }
@@ -1701,8 +1730,7 @@ var GridSettingsModal = ({
1701
1730
  control,
1702
1731
  name: `columns.0.id`,
1703
1732
  isDragging,
1704
- availableColumns,
1705
- currentColumns: fields
1733
+ availableColumns
1706
1734
  },
1707
1735
  fields[0]?.fieldId
1708
1736
  ),
@@ -1721,16 +1749,15 @@ var GridSettingsModal = ({
1721
1749
  {
1722
1750
  items: fields?.slice(1).map((c) => c?.fieldId),
1723
1751
  strategy: sortable.verticalListSortingStrategy,
1724
- children: fields?.slice(1).map((col, index2) => /* @__PURE__ */ jsxRuntime.jsx(
1752
+ children: fields?.slice(1).map((col, index) => /* @__PURE__ */ jsxRuntime.jsx(
1725
1753
  SortableRow,
1726
1754
  {
1727
1755
  value: col?.fieldId,
1728
1756
  control,
1729
- name: `columns.${index2 + 1}.id`,
1757
+ name: `columns.${index + 1}.id`,
1730
1758
  isDragging,
1731
1759
  availableColumns,
1732
- currentColumns: fields,
1733
- onRemove: () => remove(index2 + 1)
1760
+ onRemove: () => remove(index + 1)
1734
1761
  },
1735
1762
  col?.fieldId
1736
1763
  ))
@@ -1799,7 +1826,7 @@ var InfoIcon = (props) => {
1799
1826
  }
1800
1827
  );
1801
1828
  };
1802
- var InfoIcon_default = React3__namespace.default.memo(InfoIcon);
1829
+ var InfoIcon_default = React4__namespace.default.memo(InfoIcon);
1803
1830
  function TooltipProvider2({
1804
1831
  delayDuration = 0,
1805
1832
  ...props
@@ -1868,7 +1895,7 @@ var Navbar = ({
1868
1895
  }) => {
1869
1896
  const { isMobile, isTablet, isDesktop } = useScreenSize_default();
1870
1897
  const Icon3 = lucideReact.CircleHelp;
1871
- const shouldShowSeparator = !separatorDisable && React3.isValidElement(searchButton);
1898
+ const shouldShowSeparator = !separatorDisable && React4.isValidElement(searchButton);
1872
1899
  return /* @__PURE__ */ jsxRuntime.jsxs(
1873
1900
  "nav",
1874
1901
  {
@@ -1879,8 +1906,8 @@ var Navbar = ({
1879
1906
  children: [
1880
1907
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5", children: [
1881
1908
  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: [
1882
- React3.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-4xl font-bold", children: title }),
1883
- React3.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: subTitle })
1909
+ React4.isValidElement(title) ? title : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-4xl font-bold", children: title }),
1910
+ React4.isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-white text-xl font-bold", children: subTitle })
1884
1911
  ] }),
1885
1912
  tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
1886
1913
  /* @__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" }) }) }),
@@ -1908,10 +1935,10 @@ var Navbar = ({
1908
1935
  className: cn("flex flex-col gap-4 max-w-sm text-sm text-gray-700", className),
1909
1936
  children: [
1910
1937
  tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1911
- React3.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
1938
+ React4.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
1912
1939
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-bold", children: tooltipTitle })
1913
1940
  ] }),
1914
- React3.isValidElement(tooltipdescription) ? tooltipdescription : ""
1941
+ React4.isValidElement(tooltipdescription) ? tooltipdescription : ""
1915
1942
  ]
1916
1943
  }
1917
1944
  ),
@@ -1965,15 +1992,15 @@ var Navbar = ({
1965
1992
  }
1966
1993
  ),
1967
1994
  shouldShowSeparator && /* @__PURE__ */ jsxRuntime.jsx("div", { role: "separator", className: "ml-1 w-[1px] h-10 bg-white" }),
1968
- React3.isValidElement(searchButton) ? searchButton : ""
1995
+ React4.isValidElement(searchButton) ? searchButton : ""
1969
1996
  ] })
1970
1997
  ]
1971
1998
  }
1972
1999
  );
1973
2000
  };
1974
- var navbar_default = React3__namespace.default.memo(Navbar);
2001
+ var navbar_default = React4__namespace.default.memo(Navbar);
1975
2002
  var ExpandCollapse = ({ title, children, portalId }) => {
1976
- const [isOpen, setIsOpen] = React3.useState(false);
2003
+ const [isOpen, setIsOpen] = React4.useState(false);
1977
2004
  const Panel = /* @__PURE__ */ jsxRuntime.jsx(
1978
2005
  "div",
1979
2006
  {
@@ -2054,30 +2081,30 @@ function makeNewRow(fields) {
2054
2081
  return { id: crypto.randomUUID(), fieldName: first.name, operator: op, value: "" };
2055
2082
  }
2056
2083
  function useAdvanceSearch({ fields, limitRows }) {
2057
- const [rows, setRows] = React3.useState([makeNewRow(fields)]);
2058
- const updateRows = React3.useCallback((next) => {
2084
+ const [rows, setRows] = React4.useState([makeNewRow(fields)]);
2085
+ const updateRows = React4.useCallback((next) => {
2059
2086
  setRows(next);
2060
2087
  }, []);
2061
- const operatorsForField = React3.useCallback(
2088
+ const operatorsForField = React4.useCallback(
2062
2089
  (fieldName) => {
2063
2090
  const t3 = getFieldType(fields, fieldName);
2064
2091
  return OPERATOR_MAP[t3];
2065
2092
  },
2066
2093
  [fields]
2067
2094
  );
2068
- const addRow = React3.useCallback(() => {
2095
+ const addRow = React4.useCallback(() => {
2069
2096
  if (!limitRows || rows.length < limitRows) {
2070
2097
  updateRows([...rows, makeNewRow(fields)]);
2071
2098
  }
2072
2099
  }, [rows, fields, updateRows, limitRows]);
2073
- const removeRow = React3.useCallback(
2100
+ const removeRow = React4.useCallback(
2074
2101
  (id) => {
2075
2102
  if (rows.length === 1) return;
2076
2103
  updateRows(rows.filter((r2) => r2.id !== id));
2077
2104
  },
2078
2105
  [rows, updateRows]
2079
2106
  );
2080
- const clearRow = React3.useCallback(
2107
+ const clearRow = React4.useCallback(
2081
2108
  (id) => {
2082
2109
  updateRows(
2083
2110
  rows.map((r2) => {
@@ -2089,10 +2116,10 @@ function useAdvanceSearch({ fields, limitRows }) {
2089
2116
  },
2090
2117
  [rows, fields, updateRows]
2091
2118
  );
2092
- const clearAllRow = React3.useCallback(() => {
2119
+ const clearAllRow = React4.useCallback(() => {
2093
2120
  updateRows([makeNewRow(fields)]);
2094
2121
  }, [fields, updateRows]);
2095
- const changeField = React3.useCallback(
2122
+ const changeField = React4.useCallback(
2096
2123
  (id, fieldName) => {
2097
2124
  const nextOp = firstOperatorFor(fields, fieldName);
2098
2125
  updateRows(
@@ -2104,7 +2131,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2104
2131
  },
2105
2132
  [rows, fields, updateRows]
2106
2133
  );
2107
- const changeOperator = React3.useCallback(
2134
+ const changeOperator = React4.useCallback(
2108
2135
  (id, operator) => {
2109
2136
  updateRows(
2110
2137
  rows.map((r2) => {
@@ -2118,7 +2145,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2118
2145
  },
2119
2146
  [rows, updateRows]
2120
2147
  );
2121
- const changeValue = React3.useCallback(
2148
+ const changeValue = React4.useCallback(
2122
2149
  (id, which, val) => {
2123
2150
  updateRows(
2124
2151
  rows.map((r2) => {
@@ -2130,7 +2157,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2130
2157
  },
2131
2158
  [rows, updateRows]
2132
2159
  );
2133
- const fieldOptions = React3.useMemo(
2160
+ const fieldOptions = React4.useMemo(
2134
2161
  () => fields.map((f) => ({
2135
2162
  value: f.name,
2136
2163
  label: f.label ?? f.name
@@ -2182,7 +2209,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2182
2209
  return { [row.fieldName]: row.value };
2183
2210
  }
2184
2211
  };
2185
- const buildParam = React3.useMemo(() => {
2212
+ const buildParam = React4.useMemo(() => {
2186
2213
  const andConditions = rows.map((r2) => r2.value ? rowToFilter(r2) : null).filter(Boolean);
2187
2214
  return { AND: andConditions };
2188
2215
  }, [rows]);
@@ -2506,13 +2533,13 @@ function DatePicker({
2506
2533
  className,
2507
2534
  ...props
2508
2535
  }) {
2509
- const today = React3__namespace.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
2510
- const [displayed, setDisplayed] = React3__namespace.useState(
2536
+ const today = React4__namespace.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
2537
+ const [displayed, setDisplayed] = React4__namespace.useState(
2511
2538
  selectedDate ? new Date(selectedDate) : /* @__PURE__ */ new Date()
2512
2539
  );
2513
2540
  minDate = clampToDay(minDate);
2514
2541
  maxDate = clampToDay(maxDate);
2515
- const disabledSet = React3__namespace.useMemo(() => {
2542
+ const disabledSet = React4__namespace.useMemo(() => {
2516
2543
  const s2 = /* @__PURE__ */ new Set();
2517
2544
  disabledDates?.forEach((d) => s2.add(startOfDay(d).toISOString()));
2518
2545
  return s2;
@@ -2521,7 +2548,7 @@ function DatePicker({
2521
2548
  const displayMonth = displayed.getMonth();
2522
2549
  const monthLabel = callbacks?.monthLabel?.(displayYear, displayMonth) ?? new Intl.DateTimeFormat(void 0, { month: "short" }).format(displayed);
2523
2550
  const yearLabel = callbacks?.yearLabel?.(displayYear) ?? String(displayYear);
2524
- const weekdays = React3__namespace.useMemo(() => {
2551
+ const weekdays = React4__namespace.useMemo(() => {
2525
2552
  const labels = [];
2526
2553
  for (let i2 = 0; i2 < 7; i2++) {
2527
2554
  const idx = i2;
@@ -2530,7 +2557,7 @@ function DatePicker({
2530
2557
  }
2531
2558
  return labels;
2532
2559
  }, [callbacks]);
2533
- const grid = React3__namespace.useMemo(() => buildCalendarGrid(displayed, true), [displayed]);
2560
+ const grid = React4__namespace.useMemo(() => buildCalendarGrid(displayed, true), [displayed]);
2534
2561
  const isDateDisabled = (date) => {
2535
2562
  const d = startOfDay(date);
2536
2563
  if (minDate && d < minDate) return true;
@@ -2609,7 +2636,7 @@ function DatePicker({
2609
2636
  ] });
2610
2637
  }
2611
2638
  var TagsInput = ({ value = [], onChange, onClear, error }) => {
2612
- const [inputValue, setInputValue] = React3.useState("");
2639
+ const [inputValue, setInputValue] = React4.useState("");
2613
2640
  const addTag = (val) => {
2614
2641
  const trimmed = val.trim();
2615
2642
  if (!trimmed) return;
@@ -2617,8 +2644,8 @@ var TagsInput = ({ value = [], onChange, onClear, error }) => {
2617
2644
  onChange([...value, trimmed]);
2618
2645
  setInputValue("");
2619
2646
  };
2620
- const removeTag = (index2) => {
2621
- const newTags = value.filter((_, i2) => i2 !== index2);
2647
+ const removeTag = (index) => {
2648
+ const newTags = value.filter((_, i2) => i2 !== index);
2622
2649
  onChange(newTags);
2623
2650
  };
2624
2651
  const handleKeyDown = (e2) => {
@@ -2957,8 +2984,8 @@ function buildLocalizeFn(args) {
2957
2984
  const width = options?.width ? String(options.width) : args.defaultWidth;
2958
2985
  valuesArray = args.values[width] || args.values[defaultWidth];
2959
2986
  }
2960
- const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
2961
- return valuesArray[index2];
2987
+ const index = args.argumentCallback ? args.argumentCallback(value) : value;
2988
+ return valuesArray[index];
2962
2989
  };
2963
2990
  }
2964
2991
 
@@ -3278,7 +3305,7 @@ var match = {
3278
3305
  defaultMatchWidth: "wide",
3279
3306
  parsePatterns: parseQuarterPatterns,
3280
3307
  defaultParseWidth: "any",
3281
- valueCallback: (index2) => index2 + 1
3308
+ valueCallback: (index) => index + 1
3282
3309
  }),
3283
3310
  month: buildMatchFn({
3284
3311
  matchPatterns: matchMonthPatterns,
@@ -4413,15 +4440,15 @@ function Label4({ className, ...props }) {
4413
4440
  );
4414
4441
  }
4415
4442
  var Form2 = reactHookForm.FormProvider;
4416
- var FormFieldContext3 = React3__namespace.createContext({});
4443
+ var FormFieldContext3 = React4__namespace.createContext({});
4417
4444
  var FormField3 = ({
4418
4445
  ...props
4419
4446
  }) => {
4420
4447
  return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext3.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
4421
4448
  };
4422
4449
  var useFormField3 = () => {
4423
- const fieldContext = React3__namespace.useContext(FormFieldContext3);
4424
- const itemContext = React3__namespace.useContext(FormItemContext3);
4450
+ const fieldContext = React4__namespace.useContext(FormFieldContext3);
4451
+ const itemContext = React4__namespace.useContext(FormItemContext3);
4425
4452
  const { getFieldState } = reactHookForm.useFormContext();
4426
4453
  const formState = reactHookForm.useFormState({ name: fieldContext.name });
4427
4454
  const fieldState = getFieldState(fieldContext.name, formState);
@@ -4438,9 +4465,9 @@ var useFormField3 = () => {
4438
4465
  ...fieldState
4439
4466
  };
4440
4467
  };
4441
- var FormItemContext3 = React3__namespace.createContext({});
4468
+ var FormItemContext3 = React4__namespace.createContext({});
4442
4469
  function FormItem3({ className, ...props }) {
4443
- const id = React3__namespace.useId();
4470
+ const id = React4__namespace.useId();
4444
4471
  return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext3.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "form-item", className: cn2("grid gap-2", className), ...props }) });
4445
4472
  }
4446
4473
  function FormControl2({ ...props }) {
@@ -4472,7 +4499,7 @@ var AdvanceSearchRow = ({
4472
4499
  const { control } = form;
4473
4500
  const fieldSchema = fields.find((f) => f.name === row.fieldName);
4474
4501
  const fieldType = fieldSchema?.type ?? "text";
4475
- React3__namespace.default.useEffect(() => {
4502
+ React4__namespace.default.useEffect(() => {
4476
4503
  if (operators && operators.length > 0 && !operators.includes(row.operator)) {
4477
4504
  onChangeOperator(operators[0]);
4478
4505
  }
@@ -4483,8 +4510,8 @@ var AdvanceSearchRow = ({
4483
4510
  const isLookup = fieldType === "lookup";
4484
4511
  const isNumber = fieldType === "number";
4485
4512
  const isDate2 = fieldType === "date" || fieldType === "datetime";
4486
- const [openDateValue1, setOpenDateValue1] = React3__namespace.default.useState(false);
4487
- const [openDateValue2, setOpenDateValue2] = React3__namespace.default.useState(false);
4513
+ const [openDateValue1, setOpenDateValue1] = React4__namespace.default.useState(false);
4514
+ const [openDateValue2, setOpenDateValue2] = React4__namespace.default.useState(false);
4488
4515
  const toDateFromISO = (v) => {
4489
4516
  if (!v) return void 0;
4490
4517
  try {
@@ -4723,7 +4750,7 @@ var AdvanceSearch = ({
4723
4750
  onSearch,
4724
4751
  onClear
4725
4752
  }) => {
4726
- const fieldsData = React3.useMemo(() => fields || [], [fields]);
4753
+ const fieldsData = React4.useMemo(() => fields || [], [fields]);
4727
4754
  const {
4728
4755
  rows,
4729
4756
  addRow,
@@ -4741,7 +4768,7 @@ var AdvanceSearch = ({
4741
4768
  defaultValues: {}
4742
4769
  });
4743
4770
  const { handleSubmit, unregister, resetField, getValues, setValue } = form;
4744
- const onSubmit = React3.useCallback(() => {
4771
+ const onSubmit = React4.useCallback(() => {
4745
4772
  const currentValues = getValues();
4746
4773
  const param = {
4747
4774
  AND: rows.map((r2) => {
@@ -5057,6 +5084,7 @@ exports.GridSettingsModal = GridSettingsModal_default;
5057
5084
  exports.HeaderCell = HeaderCell_default;
5058
5085
  exports.Navbar = navbar_default;
5059
5086
  exports.NumberInput = NumberInput;
5087
+ exports.PreventPageLeave = PreventPageLeave_default;
5060
5088
  exports.TextInput = TextInput;
5061
5089
  exports.booleanToSelectValue = booleanToSelectValue;
5062
5090
  exports.buttonVariants = buttonVariants;
@@ -5070,6 +5098,8 @@ exports.useGridSettingsStore = useGridSettingsStore;
5070
5098
  exports.useHover = useHover_default;
5071
5099
  exports.useIntersectionObserver = useIntersectionObserver_default;
5072
5100
  exports.useMediaQuery = useMediaQuery_default;
5101
+ exports.usePreventPageLeave = usePreventPageLeave_default;
5102
+ exports.usePreventPageLeaveStore = usePreventPageLeaveStore_default;
5073
5103
  exports.useScreenSize = useScreenSize_default;
5074
5104
  //# sourceMappingURL=index.js.map
5075
5105
  //# sourceMappingURL=index.js.map