@sustaina/shared-ui 1.3.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.d.mts CHANGED
@@ -3,10 +3,10 @@ import * as React$1 from 'react';
3
3
  import React__default, { CSSProperties, ReactNode } from 'react';
4
4
  import { FieldValues, FieldPath, ControllerProps, UseFormGetFieldState } from 'react-hook-form';
5
5
  import { Header, RowData as RowData$1, Column as Column$1, Table as Table$1, ColumnDef, ColumnFiltersState, OnChangeFn, FilterFnOption, SortingState, ColumnOrderState, VisibilityState, ColumnPinningState, GroupingState, GroupingOptions, ColumnResizeMode, RowSelectionState, Row, ExpandedState, HeaderGroup, Cell, HeaderContext } from '@tanstack/react-table';
6
+ import * as zustand from 'zustand';
6
7
  import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
7
8
  import { VariantProps } from 'class-variance-authority';
8
9
  import { ClassValue } from 'clsx';
9
- import * as zustand from 'zustand';
10
10
 
11
11
  type FormErrorMessageProps = React__default.ComponentProps<"p"> & {
12
12
  errorClassName?: string;
@@ -259,6 +259,19 @@ type HeaderCellProps<TData = any, TValue = any> = {
259
259
  };
260
260
  declare const HeaderCell: ({ rootClassName, labelClassName, context, label, sorterProps }: HeaderCellProps) => react_jsx_runtime.JSX.Element;
261
261
 
262
+ declare const PreventPageLeave: ({ children }: React__default.PropsWithChildren) => React__default.ReactNode;
263
+
264
+ type PreventPageLeaveStore = {
265
+ isPreventing: boolean;
266
+ setPreventing: (value: boolean) => void;
267
+ };
268
+ declare const usePreventPageLeaveStore: zustand.UseBoundStore<zustand.StoreApi<PreventPageLeaveStore>>;
269
+
270
+ type UsePreventPageLeaveOptions = {
271
+ isPrevening: boolean;
272
+ };
273
+ declare const usePreventPageLeave: ({ isPrevening }: UsePreventPageLeaveOptions) => void;
274
+
262
275
  declare const buttonVariants: (props?: ({
263
276
  variant?: "link" | "default" | "outline" | "cancel" | "destructive" | "secondary" | "ghost" | "defaultSelect" | "defaultOutline" | null | undefined;
264
277
  size?: "default" | "option" | "icon" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-md" | "icon-lg" | null | undefined;
@@ -473,4 +486,4 @@ type Breakpoints = {
473
486
  };
474
487
  declare const useScreenSize: (breakpoints?: Breakpoints) => UseScreenSizeResult;
475
488
 
476
- 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 DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, 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, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, useScreenSize };
489
+ 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 DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, 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 SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
package/dist/index.d.ts CHANGED
@@ -3,10 +3,10 @@ import * as React$1 from 'react';
3
3
  import React__default, { CSSProperties, ReactNode } from 'react';
4
4
  import { FieldValues, FieldPath, ControllerProps, UseFormGetFieldState } from 'react-hook-form';
5
5
  import { Header, RowData as RowData$1, Column as Column$1, Table as Table$1, ColumnDef, ColumnFiltersState, OnChangeFn, FilterFnOption, SortingState, ColumnOrderState, VisibilityState, ColumnPinningState, GroupingState, GroupingOptions, ColumnResizeMode, RowSelectionState, Row, ExpandedState, HeaderGroup, Cell, HeaderContext } from '@tanstack/react-table';
6
+ import * as zustand from 'zustand';
6
7
  import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
7
8
  import { VariantProps } from 'class-variance-authority';
8
9
  import { ClassValue } from 'clsx';
9
- import * as zustand from 'zustand';
10
10
 
11
11
  type FormErrorMessageProps = React__default.ComponentProps<"p"> & {
12
12
  errorClassName?: string;
@@ -259,6 +259,19 @@ type HeaderCellProps<TData = any, TValue = any> = {
259
259
  };
260
260
  declare const HeaderCell: ({ rootClassName, labelClassName, context, label, sorterProps }: HeaderCellProps) => react_jsx_runtime.JSX.Element;
261
261
 
262
+ declare const PreventPageLeave: ({ children }: React__default.PropsWithChildren) => React__default.ReactNode;
263
+
264
+ type PreventPageLeaveStore = {
265
+ isPreventing: boolean;
266
+ setPreventing: (value: boolean) => void;
267
+ };
268
+ declare const usePreventPageLeaveStore: zustand.UseBoundStore<zustand.StoreApi<PreventPageLeaveStore>>;
269
+
270
+ type UsePreventPageLeaveOptions = {
271
+ isPrevening: boolean;
272
+ };
273
+ declare const usePreventPageLeave: ({ isPrevening }: UsePreventPageLeaveOptions) => void;
274
+
262
275
  declare const buttonVariants: (props?: ({
263
276
  variant?: "link" | "default" | "outline" | "cancel" | "destructive" | "secondary" | "ghost" | "defaultSelect" | "defaultOutline" | null | undefined;
264
277
  size?: "default" | "option" | "icon" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-md" | "icon-lg" | null | undefined;
@@ -473,4 +486,4 @@ type Breakpoints = {
473
486
  };
474
487
  declare const useScreenSize: (breakpoints?: Breakpoints) => UseScreenSizeResult;
475
488
 
476
- 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 DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, 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, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, useScreenSize };
489
+ 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 DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, 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 SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
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 }) {
@@ -1621,7 +1653,7 @@ var GridSettingsModal = ({
1621
1653
  onClose,
1622
1654
  onSaveColumns
1623
1655
  }) => {
1624
- const [isDragging, setIsDragging] = React3.useState(false);
1656
+ const [isDragging, setIsDragging] = React4.useState(false);
1625
1657
  const form = reactHookForm.useForm({
1626
1658
  resolver: t2(GridSettingsSchema),
1627
1659
  defaultValues: { columns: currentColumns },
@@ -1633,7 +1665,7 @@ var GridSettingsModal = ({
1633
1665
  name: "columns",
1634
1666
  keyName: "fieldId"
1635
1667
  });
1636
- React3.useEffect(() => {
1668
+ React4.useEffect(() => {
1637
1669
  if (isOpen) {
1638
1670
  form.reset({ columns: currentColumns });
1639
1671
  }
@@ -1799,7 +1831,7 @@ var InfoIcon = (props) => {
1799
1831
  }
1800
1832
  );
1801
1833
  };
1802
- var InfoIcon_default = React3__namespace.default.memo(InfoIcon);
1834
+ var InfoIcon_default = React4__namespace.default.memo(InfoIcon);
1803
1835
  function TooltipProvider2({
1804
1836
  delayDuration = 0,
1805
1837
  ...props
@@ -1868,7 +1900,7 @@ var Navbar = ({
1868
1900
  }) => {
1869
1901
  const { isMobile, isTablet, isDesktop } = useScreenSize_default();
1870
1902
  const Icon3 = lucideReact.CircleHelp;
1871
- const shouldShowSeparator = !separatorDisable && React3.isValidElement(searchButton);
1903
+ const shouldShowSeparator = !separatorDisable && React4.isValidElement(searchButton);
1872
1904
  return /* @__PURE__ */ jsxRuntime.jsxs(
1873
1905
  "nav",
1874
1906
  {
@@ -1879,8 +1911,8 @@ var Navbar = ({
1879
1911
  children: [
1880
1912
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5", children: [
1881
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: [
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 })
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 })
1884
1916
  ] }),
1885
1917
  tooltipTitle && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
1886
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" }) }) }),
@@ -1908,10 +1940,10 @@ var Navbar = ({
1908
1940
  className: cn("flex flex-col gap-4 max-w-sm text-sm text-gray-700", className),
1909
1941
  children: [
1910
1942
  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" }),
1943
+ React4.isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsxRuntime.jsx(Icon3, { size: 32, "aria-hidden": "true" }),
1912
1944
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-bold", children: tooltipTitle })
1913
1945
  ] }),
1914
- React3.isValidElement(tooltipdescription) ? tooltipdescription : ""
1946
+ React4.isValidElement(tooltipdescription) ? tooltipdescription : ""
1915
1947
  ]
1916
1948
  }
1917
1949
  ),
@@ -1965,15 +1997,15 @@ var Navbar = ({
1965
1997
  }
1966
1998
  ),
1967
1999
  shouldShowSeparator && /* @__PURE__ */ jsxRuntime.jsx("div", { role: "separator", className: "ml-1 w-[1px] h-10 bg-white" }),
1968
- React3.isValidElement(searchButton) ? searchButton : ""
2000
+ React4.isValidElement(searchButton) ? searchButton : ""
1969
2001
  ] })
1970
2002
  ]
1971
2003
  }
1972
2004
  );
1973
2005
  };
1974
- var navbar_default = React3__namespace.default.memo(Navbar);
2006
+ var navbar_default = React4__namespace.default.memo(Navbar);
1975
2007
  var ExpandCollapse = ({ title, children, portalId }) => {
1976
- const [isOpen, setIsOpen] = React3.useState(false);
2008
+ const [isOpen, setIsOpen] = React4.useState(false);
1977
2009
  const Panel = /* @__PURE__ */ jsxRuntime.jsx(
1978
2010
  "div",
1979
2011
  {
@@ -2054,30 +2086,30 @@ function makeNewRow(fields) {
2054
2086
  return { id: crypto.randomUUID(), fieldName: first.name, operator: op, value: "" };
2055
2087
  }
2056
2088
  function useAdvanceSearch({ fields, limitRows }) {
2057
- const [rows, setRows] = React3.useState([makeNewRow(fields)]);
2058
- const updateRows = React3.useCallback((next) => {
2089
+ const [rows, setRows] = React4.useState([makeNewRow(fields)]);
2090
+ const updateRows = React4.useCallback((next) => {
2059
2091
  setRows(next);
2060
2092
  }, []);
2061
- const operatorsForField = React3.useCallback(
2093
+ const operatorsForField = React4.useCallback(
2062
2094
  (fieldName) => {
2063
2095
  const t3 = getFieldType(fields, fieldName);
2064
2096
  return OPERATOR_MAP[t3];
2065
2097
  },
2066
2098
  [fields]
2067
2099
  );
2068
- const addRow = React3.useCallback(() => {
2100
+ const addRow = React4.useCallback(() => {
2069
2101
  if (!limitRows || rows.length < limitRows) {
2070
2102
  updateRows([...rows, makeNewRow(fields)]);
2071
2103
  }
2072
2104
  }, [rows, fields, updateRows, limitRows]);
2073
- const removeRow = React3.useCallback(
2105
+ const removeRow = React4.useCallback(
2074
2106
  (id) => {
2075
2107
  if (rows.length === 1) return;
2076
2108
  updateRows(rows.filter((r2) => r2.id !== id));
2077
2109
  },
2078
2110
  [rows, updateRows]
2079
2111
  );
2080
- const clearRow = React3.useCallback(
2112
+ const clearRow = React4.useCallback(
2081
2113
  (id) => {
2082
2114
  updateRows(
2083
2115
  rows.map((r2) => {
@@ -2089,10 +2121,10 @@ function useAdvanceSearch({ fields, limitRows }) {
2089
2121
  },
2090
2122
  [rows, fields, updateRows]
2091
2123
  );
2092
- const clearAllRow = React3.useCallback(() => {
2124
+ const clearAllRow = React4.useCallback(() => {
2093
2125
  updateRows([makeNewRow(fields)]);
2094
2126
  }, [fields, updateRows]);
2095
- const changeField = React3.useCallback(
2127
+ const changeField = React4.useCallback(
2096
2128
  (id, fieldName) => {
2097
2129
  const nextOp = firstOperatorFor(fields, fieldName);
2098
2130
  updateRows(
@@ -2104,7 +2136,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2104
2136
  },
2105
2137
  [rows, fields, updateRows]
2106
2138
  );
2107
- const changeOperator = React3.useCallback(
2139
+ const changeOperator = React4.useCallback(
2108
2140
  (id, operator) => {
2109
2141
  updateRows(
2110
2142
  rows.map((r2) => {
@@ -2118,7 +2150,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2118
2150
  },
2119
2151
  [rows, updateRows]
2120
2152
  );
2121
- const changeValue = React3.useCallback(
2153
+ const changeValue = React4.useCallback(
2122
2154
  (id, which, val) => {
2123
2155
  updateRows(
2124
2156
  rows.map((r2) => {
@@ -2130,7 +2162,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2130
2162
  },
2131
2163
  [rows, updateRows]
2132
2164
  );
2133
- const fieldOptions = React3.useMemo(
2165
+ const fieldOptions = React4.useMemo(
2134
2166
  () => fields.map((f) => ({
2135
2167
  value: f.name,
2136
2168
  label: f.label ?? f.name
@@ -2182,7 +2214,7 @@ function useAdvanceSearch({ fields, limitRows }) {
2182
2214
  return { [row.fieldName]: row.value };
2183
2215
  }
2184
2216
  };
2185
- const buildParam = React3.useMemo(() => {
2217
+ const buildParam = React4.useMemo(() => {
2186
2218
  const andConditions = rows.map((r2) => r2.value ? rowToFilter(r2) : null).filter(Boolean);
2187
2219
  return { AND: andConditions };
2188
2220
  }, [rows]);
@@ -2506,13 +2538,13 @@ function DatePicker({
2506
2538
  className,
2507
2539
  ...props
2508
2540
  }) {
2509
- const today = React3__namespace.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
2510
- const [displayed, setDisplayed] = React3__namespace.useState(
2541
+ const today = React4__namespace.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
2542
+ const [displayed, setDisplayed] = React4__namespace.useState(
2511
2543
  selectedDate ? new Date(selectedDate) : /* @__PURE__ */ new Date()
2512
2544
  );
2513
2545
  minDate = clampToDay(minDate);
2514
2546
  maxDate = clampToDay(maxDate);
2515
- const disabledSet = React3__namespace.useMemo(() => {
2547
+ const disabledSet = React4__namespace.useMemo(() => {
2516
2548
  const s2 = /* @__PURE__ */ new Set();
2517
2549
  disabledDates?.forEach((d) => s2.add(startOfDay(d).toISOString()));
2518
2550
  return s2;
@@ -2521,7 +2553,7 @@ function DatePicker({
2521
2553
  const displayMonth = displayed.getMonth();
2522
2554
  const monthLabel = callbacks?.monthLabel?.(displayYear, displayMonth) ?? new Intl.DateTimeFormat(void 0, { month: "short" }).format(displayed);
2523
2555
  const yearLabel = callbacks?.yearLabel?.(displayYear) ?? String(displayYear);
2524
- const weekdays = React3__namespace.useMemo(() => {
2556
+ const weekdays = React4__namespace.useMemo(() => {
2525
2557
  const labels = [];
2526
2558
  for (let i2 = 0; i2 < 7; i2++) {
2527
2559
  const idx = i2;
@@ -2530,7 +2562,7 @@ function DatePicker({
2530
2562
  }
2531
2563
  return labels;
2532
2564
  }, [callbacks]);
2533
- const grid = React3__namespace.useMemo(() => buildCalendarGrid(displayed, true), [displayed]);
2565
+ const grid = React4__namespace.useMemo(() => buildCalendarGrid(displayed, true), [displayed]);
2534
2566
  const isDateDisabled = (date) => {
2535
2567
  const d = startOfDay(date);
2536
2568
  if (minDate && d < minDate) return true;
@@ -2609,7 +2641,7 @@ function DatePicker({
2609
2641
  ] });
2610
2642
  }
2611
2643
  var TagsInput = ({ value = [], onChange, onClear, error }) => {
2612
- const [inputValue, setInputValue] = React3.useState("");
2644
+ const [inputValue, setInputValue] = React4.useState("");
2613
2645
  const addTag = (val) => {
2614
2646
  const trimmed = val.trim();
2615
2647
  if (!trimmed) return;
@@ -4413,15 +4445,15 @@ function Label4({ className, ...props }) {
4413
4445
  );
4414
4446
  }
4415
4447
  var Form2 = reactHookForm.FormProvider;
4416
- var FormFieldContext3 = React3__namespace.createContext({});
4448
+ var FormFieldContext3 = React4__namespace.createContext({});
4417
4449
  var FormField3 = ({
4418
4450
  ...props
4419
4451
  }) => {
4420
4452
  return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext3.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
4421
4453
  };
4422
4454
  var useFormField3 = () => {
4423
- const fieldContext = React3__namespace.useContext(FormFieldContext3);
4424
- const itemContext = React3__namespace.useContext(FormItemContext3);
4455
+ const fieldContext = React4__namespace.useContext(FormFieldContext3);
4456
+ const itemContext = React4__namespace.useContext(FormItemContext3);
4425
4457
  const { getFieldState } = reactHookForm.useFormContext();
4426
4458
  const formState = reactHookForm.useFormState({ name: fieldContext.name });
4427
4459
  const fieldState = getFieldState(fieldContext.name, formState);
@@ -4438,9 +4470,9 @@ var useFormField3 = () => {
4438
4470
  ...fieldState
4439
4471
  };
4440
4472
  };
4441
- var FormItemContext3 = React3__namespace.createContext({});
4473
+ var FormItemContext3 = React4__namespace.createContext({});
4442
4474
  function FormItem3({ className, ...props }) {
4443
- const id = React3__namespace.useId();
4475
+ const id = React4__namespace.useId();
4444
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 }) });
4445
4477
  }
4446
4478
  function FormControl2({ ...props }) {
@@ -4472,7 +4504,7 @@ var AdvanceSearchRow = ({
4472
4504
  const { control } = form;
4473
4505
  const fieldSchema = fields.find((f) => f.name === row.fieldName);
4474
4506
  const fieldType = fieldSchema?.type ?? "text";
4475
- React3__namespace.default.useEffect(() => {
4507
+ React4__namespace.default.useEffect(() => {
4476
4508
  if (operators && operators.length > 0 && !operators.includes(row.operator)) {
4477
4509
  onChangeOperator(operators[0]);
4478
4510
  }
@@ -4483,8 +4515,8 @@ var AdvanceSearchRow = ({
4483
4515
  const isLookup = fieldType === "lookup";
4484
4516
  const isNumber = fieldType === "number";
4485
4517
  const isDate2 = fieldType === "date" || fieldType === "datetime";
4486
- const [openDateValue1, setOpenDateValue1] = React3__namespace.default.useState(false);
4487
- 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);
4488
4520
  const toDateFromISO = (v) => {
4489
4521
  if (!v) return void 0;
4490
4522
  try {
@@ -4723,7 +4755,7 @@ var AdvanceSearch = ({
4723
4755
  onSearch,
4724
4756
  onClear
4725
4757
  }) => {
4726
- const fieldsData = React3.useMemo(() => fields || [], [fields]);
4758
+ const fieldsData = React4.useMemo(() => fields || [], [fields]);
4727
4759
  const {
4728
4760
  rows,
4729
4761
  addRow,
@@ -4741,7 +4773,7 @@ var AdvanceSearch = ({
4741
4773
  defaultValues: {}
4742
4774
  });
4743
4775
  const { handleSubmit, unregister, resetField, getValues, setValue } = form;
4744
- const onSubmit = React3.useCallback(() => {
4776
+ const onSubmit = React4.useCallback(() => {
4745
4777
  const currentValues = getValues();
4746
4778
  const param = {
4747
4779
  AND: rows.map((r2) => {
@@ -5057,6 +5089,7 @@ exports.GridSettingsModal = GridSettingsModal_default;
5057
5089
  exports.HeaderCell = HeaderCell_default;
5058
5090
  exports.Navbar = navbar_default;
5059
5091
  exports.NumberInput = NumberInput;
5092
+ exports.PreventPageLeave = PreventPageLeave_default;
5060
5093
  exports.TextInput = TextInput;
5061
5094
  exports.booleanToSelectValue = booleanToSelectValue;
5062
5095
  exports.buttonVariants = buttonVariants;
@@ -5070,6 +5103,8 @@ exports.useGridSettingsStore = useGridSettingsStore;
5070
5103
  exports.useHover = useHover_default;
5071
5104
  exports.useIntersectionObserver = useIntersectionObserver_default;
5072
5105
  exports.useMediaQuery = useMediaQuery_default;
5106
+ exports.usePreventPageLeave = usePreventPageLeave_default;
5107
+ exports.usePreventPageLeaveStore = usePreventPageLeaveStore_default;
5073
5108
  exports.useScreenSize = useScreenSize_default;
5074
5109
  //# sourceMappingURL=index.js.map
5075
5110
  //# sourceMappingURL=index.js.map