@sustaina/shared-ui 1.1.8 → 1.3.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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React3 from 'react';
2
2
  import React3__default, { createContext, isValidElement, useState, useEffect, useId, useContext, useRef, useCallback, useMemo, createElement } from 'react';
3
- import { Controller, useFormContext, useForm, FormProvider, get, set, appendErrors, useFormState } from 'react-hook-form';
3
+ import { Controller, useFormContext, useForm, useFieldArray, FormProvider, get, set, appendErrors, useFormState } from 'react-hook-form';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
  import clsx3, { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
@@ -11,7 +11,7 @@ import { Slot } from '@radix-ui/react-slot';
11
11
  import { cva } from 'class-variance-authority';
12
12
  import * as LabelPrimitive2 from '@radix-ui/react-label';
13
13
  import * as DialogPrimitive from '@radix-ui/react-dialog';
14
- import { SortableContext, verticalListSortingStrategy, arrayMove, useSortable } from '@dnd-kit/sortable';
14
+ import { SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
15
15
  import { CSS } from '@dnd-kit/utilities';
16
16
  import * as SelectPrimitive from '@radix-ui/react-select';
17
17
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
@@ -1420,19 +1420,17 @@ function TooltipContent({
1420
1420
  ) });
1421
1421
  }
1422
1422
  function SortableRow({
1423
- itemId,
1424
- index,
1425
- control,
1426
1423
  availableColumns,
1427
1424
  currentColumns,
1428
- disableDrag = false,
1429
- disableEdit = false,
1430
- hideFormMessage,
1431
- removeColumn
1425
+ control,
1426
+ name,
1427
+ value,
1428
+ isDragging,
1429
+ onRemove
1432
1430
  }) {
1433
1431
  const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
1434
- id: itemId,
1435
- disabled: disableDrag
1432
+ id: value,
1433
+ disabled: name == "columns.0.id"
1436
1434
  });
1437
1435
  const style = {
1438
1436
  transform: CSS.Transform.toString(transform),
@@ -1447,40 +1445,40 @@ function SortableRow({
1447
1445
  FormField2,
1448
1446
  {
1449
1447
  control,
1450
- name: `columns.${index}.id`,
1448
+ name,
1451
1449
  render: ({ field }) => /* @__PURE__ */ jsxs(FormItem2, { className: "flex-1", children: [
1452
1450
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1453
1451
  /* @__PURE__ */ jsx(
1454
1452
  GripVertical,
1455
1453
  {
1454
+ ...attributes,
1455
+ ...listeners,
1456
1456
  className: cn(
1457
1457
  "h-5 w-5 text-[#B9B9B9] focus:outline-none cursor-grab",
1458
- index == 0 && "opacity-0 pointer-events-none"
1459
- ),
1460
- ...attributes,
1461
- ...listeners
1458
+ name == "columns.0.id" && "opacity-0 pointer-events-none"
1459
+ )
1462
1460
  }
1463
1461
  ),
1464
1462
  /* @__PURE__ */ jsxs(
1465
1463
  Select,
1466
1464
  {
1467
1465
  value: field.value,
1468
- onValueChange: (val) => {
1469
- field.onChange(val);
1470
- },
1471
- disabled: disableEdit || index == 0,
1466
+ onValueChange: field.onChange,
1467
+ disabled: name == "columns.0.id",
1472
1468
  children: [
1473
1469
  /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
1474
1470
  SelectTrigger,
1475
1471
  {
1476
1472
  className: cn(
1477
1473
  "w-full border-[#DDDDDD] data-[disabled]:opacity-100 aria-invalid:border-[#BB0B0E]",
1478
- index == 0 ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
1474
+ name == "columns.0.id" ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
1479
1475
  ),
1480
1476
  children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Choose column..." })
1481
1477
  }
1482
1478
  ) }),
1483
- /* @__PURE__ */ jsx(SelectContent, { children: options.filter((i2) => i2.id === field.value || !currentColumns?.some((c) => c.id === i2.id)).sort(
1479
+ /* @__PURE__ */ jsx(SelectContent, { children: options.filter(
1480
+ (i2) => i2.id === field.value || !currentColumns?.some((c, idx) => c.id === i2.id && idx !== index)
1481
+ ).sort(
1484
1482
  (a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
1485
1483
  ).map((opt) => /* @__PURE__ */ jsx(
1486
1484
  SelectItem,
@@ -1497,7 +1495,7 @@ function SortableRow({
1497
1495
  ]
1498
1496
  }
1499
1497
  ),
1500
- index == 0 ? /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
1498
+ name == "columns.0.id" ? /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
1501
1499
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Info, { className: "h-5 w-5", stroke: "white", fill: "#8B8B8B" }) }),
1502
1500
  /* @__PURE__ */ jsx(
1503
1501
  TooltipContent,
@@ -1512,14 +1510,14 @@ function SortableRow({
1512
1510
  ] }) }) : /* @__PURE__ */ jsx(
1513
1511
  CircleMinus,
1514
1512
  {
1515
- onClick: () => index > 0 && removeColumn(index),
1513
+ onClick: onRemove,
1516
1514
  className: "h-5 w-5 cursor-pointer",
1517
1515
  stroke: "white",
1518
1516
  fill: "#C32A2C"
1519
1517
  }
1520
1518
  )
1521
1519
  ] }),
1522
- /* @__PURE__ */ jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]", hideFormMessage && "hidden") })
1520
+ !isDragging && /* @__PURE__ */ jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]") })
1523
1521
  ] })
1524
1522
  }
1525
1523
  ) });
@@ -1594,18 +1592,31 @@ var GridSettingsModal = ({
1594
1592
  onClose,
1595
1593
  onSaveColumns
1596
1594
  }) => {
1597
- const [hideFormMessage, setHideFormMessage] = useState(false);
1595
+ const [isDragging, setIsDragging] = useState(false);
1598
1596
  const form = useForm({
1599
1597
  resolver: t2(GridSettingsSchema),
1600
1598
  defaultValues: { columns: currentColumns },
1601
1599
  mode: "onChange"
1602
1600
  });
1601
+ const { control, trigger } = form;
1602
+ const { fields, append, remove, move } = useFieldArray({
1603
+ control,
1604
+ name: "columns",
1605
+ keyName: "fieldId"
1606
+ });
1603
1607
  useEffect(() => {
1604
1608
  if (isOpen) {
1605
1609
  form.reset({ columns: currentColumns });
1606
1610
  }
1607
1611
  }, [isOpen, currentColumns, form]);
1608
- const columns = form.watch("columns");
1612
+ const addColumn = async () => {
1613
+ const isValid2 = await trigger("columns");
1614
+ if (isValid2) {
1615
+ append({ id: "" });
1616
+ } else {
1617
+ return;
1618
+ }
1619
+ };
1609
1620
  const onSubmit = (data) => {
1610
1621
  const ordering = data.columns.map((i2) => i2.id);
1611
1622
  const visibility = Object.fromEntries(
@@ -1616,28 +1627,16 @@ var GridSettingsModal = ({
1616
1627
  onSaveColumns({ ordering, visibility, pinning });
1617
1628
  }
1618
1629
  };
1619
- const addColumn = async () => {
1620
- const isValid2 = await form.trigger("columns");
1621
- if (!isValid2) {
1622
- return;
1623
- }
1624
- form.setValue("columns", [...columns, { id: "" }], { shouldValidate: false });
1625
- };
1626
- const removeColumn = (index) => {
1627
- const newCols = [...columns];
1628
- newCols.splice(index, 1);
1629
- form.setValue("columns", newCols);
1630
- };
1631
1630
  const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
1632
- const handleDragEnd = (event) => {
1631
+ function handleDragEnd(event) {
1633
1632
  const { active, over } = event;
1634
1633
  if (!over || active.id === over.id) return;
1635
- const oldIndex = columns.findIndex((c) => c.id === active.id);
1636
- const newIndex = columns.findIndex((c) => c.id === over.id);
1637
- if (newIndex === 0) return;
1638
- const reordered = arrayMove(columns, oldIndex, newIndex);
1639
- form.setValue("columns", reordered, { shouldValidate: true });
1640
- };
1634
+ const oldIndex = fields.findIndex((f) => f.fieldId === active.id);
1635
+ const newIndex = fields.findIndex((f) => f.fieldId === over.id);
1636
+ if (oldIndex !== -1 && newIndex !== -1) {
1637
+ move(oldIndex, newIndex);
1638
+ }
1639
+ }
1641
1640
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-xl p-0 border-0", showCloseButton: false, children: [
1642
1641
  /* @__PURE__ */ jsx(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx(
1643
1642
  "button",
@@ -1669,43 +1668,42 @@ var GridSettingsModal = ({
1669
1668
  /* @__PURE__ */ jsx(
1670
1669
  SortableRow,
1671
1670
  {
1672
- itemId: columns[0]?.id,
1673
- index: 0,
1674
- control: form.control,
1671
+ value: fields[0]?.fieldId,
1672
+ control,
1673
+ name: `columns.0.id`,
1674
+ isDragging,
1675
1675
  availableColumns,
1676
- currentColumns: columns,
1677
- disableDrag: true,
1678
- disableEdit: true,
1679
- removeColumn
1680
- }
1676
+ currentColumns: fields
1677
+ },
1678
+ fields[0]?.fieldId
1681
1679
  ),
1682
1680
  /* @__PURE__ */ jsx(
1683
1681
  DndContext,
1684
1682
  {
1685
1683
  sensors,
1686
1684
  collisionDetection: closestCenter,
1687
- onDragStart: () => setHideFormMessage(true),
1685
+ onDragStart: () => setIsDragging(true),
1688
1686
  onDragEnd: (event) => {
1689
- setHideFormMessage(false);
1687
+ setIsDragging(false);
1690
1688
  handleDragEnd(event);
1691
1689
  },
1692
1690
  children: /* @__PURE__ */ jsx(
1693
1691
  SortableContext,
1694
1692
  {
1695
- items: columns?.slice(1).map((c) => c.id),
1693
+ items: fields?.slice(1).map((c) => c?.fieldId),
1696
1694
  strategy: verticalListSortingStrategy,
1697
- children: columns?.slice(1).map((item, index) => /* @__PURE__ */ jsx(
1695
+ children: fields?.slice(1).map((col, index2) => /* @__PURE__ */ jsx(
1698
1696
  SortableRow,
1699
1697
  {
1700
- itemId: item.id,
1701
- index: index + 1,
1702
- control: form.control,
1698
+ value: col?.fieldId,
1699
+ control,
1700
+ name: `columns.${index2 + 1}.id`,
1701
+ isDragging,
1703
1702
  availableColumns,
1704
- currentColumns: columns,
1705
- hideFormMessage,
1706
- removeColumn
1703
+ currentColumns: fields,
1704
+ onRemove: () => remove(index2 + 1)
1707
1705
  },
1708
- item.id + index
1706
+ col?.fieldId
1709
1707
  ))
1710
1708
  }
1711
1709
  )
@@ -1717,7 +1715,7 @@ var GridSettingsModal = ({
1717
1715
  type: "button",
1718
1716
  className: cn("bg-[#41875C99] text-white w-full rounded-t-lg", addButtonClassname),
1719
1717
  onClick: addColumn,
1720
- disabled: columns.length >= limit,
1718
+ disabled: fields.length >= limit,
1721
1719
  children: [
1722
1720
  /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 mr-1" }),
1723
1721
  " Add column"
@@ -1836,10 +1834,12 @@ var Navbar = ({
1836
1834
  subButtonDisable = false,
1837
1835
  onMainButtonClick,
1838
1836
  onSubButtonClick,
1837
+ separatorDisable = false,
1839
1838
  searchButton
1840
1839
  }) => {
1841
1840
  const { isMobile, isTablet, isDesktop } = useScreenSize_default();
1842
1841
  const Icon3 = CircleHelp;
1842
+ const shouldShowSeparator = !separatorDisable && isValidElement(searchButton);
1843
1843
  return /* @__PURE__ */ jsxs(
1844
1844
  "nav",
1845
1845
  {
@@ -1935,7 +1935,7 @@ var Navbar = ({
1935
1935
  children: subButtonText
1936
1936
  }
1937
1937
  ),
1938
- isValidElement(searchButton) ? /* @__PURE__ */ jsx("div", { role: "separator", className: "ml-1 w-[1px] h-10 bg-white" }) : "",
1938
+ shouldShowSeparator && /* @__PURE__ */ jsx("div", { role: "separator", className: "ml-1 w-[1px] h-10 bg-white" }),
1939
1939
  isValidElement(searchButton) ? searchButton : ""
1940
1940
  ] })
1941
1941
  ]
@@ -2588,8 +2588,8 @@ var TagsInput = ({ value = [], onChange, onClear, error }) => {
2588
2588
  onChange([...value, trimmed]);
2589
2589
  setInputValue("");
2590
2590
  };
2591
- const removeTag = (index) => {
2592
- const newTags = value.filter((_, i2) => i2 !== index);
2591
+ const removeTag = (index2) => {
2592
+ const newTags = value.filter((_, i2) => i2 !== index2);
2593
2593
  onChange(newTags);
2594
2594
  };
2595
2595
  const handleKeyDown = (e2) => {
@@ -2928,8 +2928,8 @@ function buildLocalizeFn(args) {
2928
2928
  const width = options?.width ? String(options.width) : args.defaultWidth;
2929
2929
  valuesArray = args.values[width] || args.values[defaultWidth];
2930
2930
  }
2931
- const index = args.argumentCallback ? args.argumentCallback(value) : value;
2932
- return valuesArray[index];
2931
+ const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
2932
+ return valuesArray[index2];
2933
2933
  };
2934
2934
  }
2935
2935
 
@@ -3249,7 +3249,7 @@ var match = {
3249
3249
  defaultMatchWidth: "wide",
3250
3250
  parsePatterns: parseQuarterPatterns,
3251
3251
  defaultParseWidth: "any",
3252
- valueCallback: (index) => index + 1
3252
+ valueCallback: (index2) => index2 + 1
3253
3253
  }),
3254
3254
  month: buildMatchFn({
3255
3255
  matchPatterns: matchMonthPatterns,
@@ -4691,7 +4691,8 @@ var AdvanceSearch = ({
4691
4691
  portalId,
4692
4692
  iconColor = "#ffffff",
4693
4693
  limitRows = 4,
4694
- onSearch
4694
+ onSearch,
4695
+ onClear
4695
4696
  }) => {
4696
4697
  const fieldsData = useMemo(() => fields || [], [fields]);
4697
4698
  const {
@@ -4734,6 +4735,8 @@ var AdvanceSearch = ({
4734
4735
  return { [r2.fieldName]: { startsWith: val1 } };
4735
4736
  case "endsWith":
4736
4737
  return { [r2.fieldName]: { endsWith: val1 } };
4738
+ case "equals":
4739
+ return { [r2.fieldName]: { equals: val1 } };
4737
4740
  case "notEquals":
4738
4741
  return { [r2.fieldName]: { not: val1 } };
4739
4742
  case "gt":
@@ -4760,8 +4763,12 @@ var AdvanceSearch = ({
4760
4763
  return { [r2.fieldName]: { hasEvery: String(val1).split(",") } };
4761
4764
  case "containsOnly":
4762
4765
  return { [r2.fieldName]: { equals: String(val1).split(",") } };
4763
- default:
4764
- return { [r2.fieldName]: val1 };
4766
+ case "on":
4767
+ return { [r2.fieldName]: { on: val1 } };
4768
+ case "after":
4769
+ return { [r2.fieldName]: { after: val1 } };
4770
+ case "before":
4771
+ return { [r2.fieldName]: { before: val1 } };
4765
4772
  }
4766
4773
  }).filter(Boolean)
4767
4774
  };
@@ -4817,6 +4824,7 @@ var AdvanceSearch = ({
4817
4824
  onClick: () => {
4818
4825
  clearAllRow();
4819
4826
  Object.keys(getValues()).forEach((k) => resetField(k));
4827
+ if (onClear) onClear();
4820
4828
  },
4821
4829
  children: "Clear Search"
4822
4830
  }
@@ -4836,7 +4844,176 @@ var AdvanceSearch = ({
4836
4844
  );
4837
4845
  };
4838
4846
  var AdvanceSearch_default = AdvanceSearch;
4847
+ function cn3(...inputs) {
4848
+ return twMerge(clsx(inputs));
4849
+ }
4850
+ function Dialog2({ ...props }) {
4851
+ return /* @__PURE__ */ jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
4852
+ }
4853
+ function DialogPortal2({ ...props }) {
4854
+ return /* @__PURE__ */ jsx(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
4855
+ }
4856
+ function DialogOverlay2({ className, ...props }) {
4857
+ return /* @__PURE__ */ jsx(
4858
+ DialogPrimitive.Overlay,
4859
+ {
4860
+ "data-slot": "dialog-overlay",
4861
+ className: cn3(
4862
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
4863
+ className
4864
+ ),
4865
+ ...props
4866
+ }
4867
+ );
4868
+ }
4869
+ function DialogContent2({
4870
+ className,
4871
+ children,
4872
+ showCloseButton = true,
4873
+ ...props
4874
+ }) {
4875
+ return /* @__PURE__ */ jsxs(DialogPortal2, { "data-slot": "dialog-portal", children: [
4876
+ /* @__PURE__ */ jsx(DialogOverlay2, {}),
4877
+ /* @__PURE__ */ jsxs(
4878
+ DialogPrimitive.Content,
4879
+ {
4880
+ "data-slot": "dialog-content",
4881
+ className: cn3(
4882
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
4883
+ className
4884
+ ),
4885
+ ...props,
4886
+ children: [
4887
+ children,
4888
+ showCloseButton && /* @__PURE__ */ jsxs(
4889
+ DialogPrimitive.Close,
4890
+ {
4891
+ "data-slot": "dialog-close",
4892
+ className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
4893
+ children: [
4894
+ /* @__PURE__ */ jsx(XIcon, {}),
4895
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
4896
+ ]
4897
+ }
4898
+ )
4899
+ ]
4900
+ }
4901
+ )
4902
+ ] });
4903
+ }
4904
+ function DialogHeader2({ className, ...props }) {
4905
+ return /* @__PURE__ */ jsx(
4906
+ "div",
4907
+ {
4908
+ "data-slot": "dialog-header",
4909
+ className: cn3("flex flex-col gap-2 text-center sm:text-left", className),
4910
+ ...props
4911
+ }
4912
+ );
4913
+ }
4914
+ function DialogTitle2({ className, ...props }) {
4915
+ return /* @__PURE__ */ jsx(
4916
+ DialogPrimitive.Title,
4917
+ {
4918
+ "data-slot": "dialog-title",
4919
+ className: cn3("text-lg leading-none font-semibold", className),
4920
+ ...props
4921
+ }
4922
+ );
4923
+ }
4924
+ function DialogDescription2({
4925
+ className,
4926
+ ...props
4927
+ }) {
4928
+ return /* @__PURE__ */ jsx(
4929
+ DialogPrimitive.Description,
4930
+ {
4931
+ "data-slot": "dialog-description",
4932
+ className: cn3("text-muted-foreground text-sm", className),
4933
+ ...props
4934
+ }
4935
+ );
4936
+ }
4937
+ var buttonVariants4 = cva(
4938
+ "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",
4939
+ {
4940
+ variants: {
4941
+ variant: {
4942
+ default: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
4943
+ cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
4944
+ outlineLeave: "border border-[#BB0B0E] bg-background shadow-xs hover:bg-accent hover:text-accent-foreground text-[#BB0B0E]"
4945
+ },
4946
+ size: {
4947
+ default: "h-9 px-4 has-[>svg]:px-3",
4948
+ option: "py-5 h-9 px-4 has-[>svg]:px-3",
4949
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
4950
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
4951
+ icon: "size-9",
4952
+ "icon-xs": "size-5",
4953
+ "icon-sm": "size-[22px]",
4954
+ "icon-md": "size-7",
4955
+ "icon-lg": "size-10"
4956
+ },
4957
+ active: {
4958
+ true: "bg-sus-primary-1 text-white",
4959
+ false: ""
4960
+ }
4961
+ },
4962
+ defaultVariants: {
4963
+ variant: "default",
4964
+ size: "default"
4965
+ }
4966
+ }
4967
+ );
4968
+ function Button4({
4969
+ className,
4970
+ variant,
4971
+ size,
4972
+ active,
4973
+ asChild = false,
4974
+ ...props
4975
+ }) {
4976
+ const Comp = asChild ? Slot : "button";
4977
+ return /* @__PURE__ */ jsx(
4978
+ Comp,
4979
+ {
4980
+ "data-slot": "button",
4981
+ className: cn3(buttonVariants4({ variant, size, className, active })),
4982
+ ...props
4983
+ }
4984
+ );
4985
+ }
4986
+ function ConfirmDialog({ dialogData, setDialog, onClose }) {
4987
+ const handleClose = () => {
4988
+ setDialog({ state: false });
4989
+ onClose?.();
4990
+ };
4991
+ const titleColor = {
4992
+ default: "text-[#000000]",
4993
+ success: "text-[#3f9e33]",
4994
+ error: "text-[#c63638]"
4995
+ };
4996
+ const showCloseBtn = dialogData.showCloseBtn ?? true;
4997
+ return /* @__PURE__ */ jsx(Dialog2, { open: dialogData.state, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(DialogContent2, { children: [
4998
+ /* @__PURE__ */ jsxs(DialogHeader2, { children: [
4999
+ /* @__PURE__ */ jsx(DialogTitle2, { className: cn3(titleColor[dialogData.variant || "default"], "font-bold"), children: dialogData.title || "" }),
5000
+ /* @__PURE__ */ jsx(DialogDescription2, { children: dialogData.description || "" })
5001
+ ] }),
5002
+ /* @__PURE__ */ jsxs("div", { className: "w-full flex justify-center py-5 gap-5", children: [
5003
+ showCloseBtn && /* @__PURE__ */ jsx(Button4, { variant: "cancel", onClick: handleClose, children: "Close" }),
5004
+ dialogData.btn && /* @__PURE__ */ jsx(
5005
+ Button4,
5006
+ {
5007
+ variant: dialogData.variantBtn || "default",
5008
+ disabled: dialogData.btnState === false,
5009
+ onClick: dialogData.onClickBtn,
5010
+ children: dialogData.btn
5011
+ }
5012
+ )
5013
+ ] })
5014
+ ] }) });
5015
+ }
4839
5016
 
4840
- export { AdvanceSearch_default as AdvanceSearch, Button, DataTable_default as DataTable, FormErrorMessage, FormField, FormFieldContext, FormItem, FormItemContext, FormLabel, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, navbar_default as Navbar, NumberInput, TextInput, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useMediaQuery_default as useMediaQuery, useScreenSize_default as useScreenSize };
5017
+ export { AdvanceSearch_default as AdvanceSearch, Button, DataTable_default as DataTable, ConfirmDialog as Dialog, FormErrorMessage, FormField, FormFieldContext, FormItem, FormItemContext, FormLabel, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, navbar_default as Navbar, NumberInput, TextInput, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useMediaQuery_default as useMediaQuery, useScreenSize_default as useScreenSize };
4841
5018
  //# sourceMappingURL=index.mjs.map
4842
5019
  //# sourceMappingURL=index.mjs.map