@sustaina/shared-ui 1.33.2 → 1.34.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,7 +1,7 @@
1
- import * as AccordionPrimitive from '@radix-ui/react-accordion';
2
1
  import clsx2, { clsx } from 'clsx';
3
2
  import { twMerge } from 'tailwind-merge';
4
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import * as AccordionPrimitive from '@radix-ui/react-accordion';
5
5
  import * as React26 from 'react';
6
6
  import React26__default, { forwardRef, useRef, useMemo, useCallback, useState, isValidElement, useEffect, useLayoutEffect, createElement } from 'react';
7
7
  import { CircleX, Undo, Redo, Bold, Italic, Underline, Strikethrough, Code, Pilcrow, Heading1, Heading2, Heading3, List as List$1, ListOrdered, Quote, CodeSquare, Link, Link2Off, Image as Image$1, AlignLeft, AlignCenter, AlignRight, CircleHelp, ChevronDown, X, Check, XIcon, SearchIcon, ChevronRight, CheckIcon, Triangle, CalendarIcon, Search, ChevronUp, PanelLeftIcon, Minimize2, Maximize2, Plus, ChevronLeft, CircleUserRound, MoreVertical, Bug, GripVertical, Info, CircleMinus, Minus } from 'lucide-react';
@@ -737,6 +737,120 @@ var SuiWarningIcon = (props) => /* @__PURE__ */ jsxs(
737
737
  }
738
738
  );
739
739
  var warning_default = SuiWarningIcon;
740
+ var TrashIcon = ({
741
+ size = 16,
742
+ color = "currentColor",
743
+ className,
744
+ ...props
745
+ }) => /* @__PURE__ */ jsxs(
746
+ "svg",
747
+ {
748
+ viewBox: "0 0 17 15",
749
+ xmlns: "http://www.w3.org/2000/svg",
750
+ width: size,
751
+ height: size,
752
+ fill: "none",
753
+ className,
754
+ ...props,
755
+ children: [
756
+ /* @__PURE__ */ jsxs("g", { clipPath: "url(#clip0_336_302483)", children: [
757
+ /* @__PURE__ */ jsx(
758
+ "path",
759
+ {
760
+ d: "M3.49371 2.12043C3.38318 1.44249 3.66212 0.708651 4.43068 0.529533C4.94459 0.409578 7.77168 0.42749 8.38456 0.492081C9.25207 0.583811 9.64966 1.36813 9.5125 2.12097C10.3748 2.22627 11.9484 1.85067 12.6087 2.44664C13.1053 2.89498 13.1452 3.75638 12.64 4.21232C12.2707 4.54558 12.1422 4.28179 12.0664 4.92282C11.7412 7.68938 11.6509 10.4907 11.3494 13.2605C11.2452 13.9135 10.7718 14.3401 10.0646 14.3895C7.73175 14.5534 5.1836 14.2619 2.8276 14.3873C2.09203 14.2587 1.75116 13.8364 1.64178 13.1655L0.878435 4.54558C0.710025 4.38221 0.481427 4.33281 0.310702 4.15532C-0.221151 3.60006 -0.0434807 2.66593 0.639999 2.29358C0.702502 2.25938 0.998811 2.12043 1.03411 2.12043H3.49371ZM4.30394 2.12043H8.70228C8.71964 1.8333 8.70691 1.36813 8.32321 1.30951C7.19122 1.38116 5.90586 1.20367 4.79238 1.30246C4.28831 1.34696 4.29815 1.71931 4.30394 2.12043ZM12.0415 3.0589C12.0172 3.03068 11.8812 2.9574 11.8419 2.94926L1.26329 2.93243C0.749379 2.95794 0.749379 3.72598 1.26329 3.75149H11.7429C12.1029 3.75312 12.2429 3.29338 12.0415 3.0589ZM11.2487 4.56295H1.75753L2.51508 13.1612C2.5608 13.4597 2.68754 13.5498 2.9989 13.5759C5.22817 13.762 7.7468 13.4293 10.0073 13.5759L10.3823 13.4391L11.2487 4.56295Z",
761
+ fill: color
762
+ }
763
+ ),
764
+ /* @__PURE__ */ jsx(
765
+ "path",
766
+ {
767
+ d: "M4.22952 5.50209C4.41761 5.72137 4.34006 6.27067 4.36263 6.54477C4.51599 8.36961 4.73649 10.3719 4.77121 12.1892C4.78568 12.9404 3.98125 12.8953 3.90254 12.4047C3.84698 10.417 3.54836 8.42443 3.49164 6.43947C3.48586 6.23159 3.45576 5.67469 3.54894 5.52542C3.66411 5.34088 4.08426 5.33274 4.22952 5.50263V5.50209Z",
768
+ fill: color
769
+ }
770
+ ),
771
+ /* @__PURE__ */ jsx(
772
+ "path",
773
+ {
774
+ d: "M9.43711 5.50146C9.55575 5.63933 9.52045 6.22879 9.51466 6.43776C9.45852 8.42272 9.15932 10.4153 9.10376 12.4029C9.02447 12.8936 8.21946 12.9381 8.23509 12.1875C8.27213 10.3681 8.48973 8.37007 8.64367 6.54306C8.67492 6.17234 8.50941 5.28598 9.18941 5.37771C9.24497 5.38531 9.40412 5.46238 9.43711 5.50092V5.50146Z",
775
+ fill: color
776
+ }
777
+ ),
778
+ /* @__PURE__ */ jsx(
779
+ "path",
780
+ {
781
+ d: "M6.83313 5.50252C6.90547 5.58611 6.90142 5.68218 6.91068 5.78314C7.10224 7.89891 6.76253 10.266 6.90837 12.4083C6.88985 12.8822 6.11551 12.8806 6.09814 12.4083L6.15312 5.52478C6.31575 5.34783 6.6734 5.31689 6.83313 5.50252Z",
782
+ fill: color
783
+ }
784
+ )
785
+ ] }),
786
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: "clip0_3678_200811", children: /* @__PURE__ */ jsx("rect", { width: "17", height: "15", fill: "white", transform: "translate(0.728516 0.726562)" }) }) })
787
+ ]
788
+ }
789
+ );
790
+ var trash_default = TrashIcon;
791
+ var AuditFooter = ({
792
+ createdAt,
793
+ createdBy,
794
+ updatedAt,
795
+ updatedBy,
796
+ onDelete,
797
+ canDelete = true,
798
+ emptyValue = "-",
799
+ labels,
800
+ classNames,
801
+ formatters,
802
+ deleteAriaLabel = "Delete",
803
+ deleteIcon
804
+ }) => {
805
+ const resolvedLabels = {
806
+ createdOn: "Created on :",
807
+ createdAtTime: "at Time :",
808
+ createdBy: "by :",
809
+ updatedOn: "Last Update :",
810
+ updatedAtTime: "at Time :",
811
+ updatedBy: "by :",
812
+ ...labels
813
+ };
814
+ const dateFormatter = formatters?.date ?? ((value) => formatISODate(value, "DD/MM/YYYY"));
815
+ const timeFormatter = formatters?.time ?? ((value) => formatISODate(value, "H:i"));
816
+ const userFormatter = formatters?.user ?? ((value) => value ?? emptyValue);
817
+ const resolvedDeleteIcon = deleteIcon ?? /* @__PURE__ */ jsx(trash_default, { className: "w-5 h-5" });
818
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full h-14 mt-12 justify-between items-end px-3", classNames?.root), children: [
819
+ /* @__PURE__ */ jsxs(
820
+ "div",
821
+ {
822
+ className: cn(
823
+ "grid grid-cols-[auto_1fr_auto_1fr] gap-x-3 gap-y-1 text-[10px]",
824
+ classNames?.grid
825
+ ),
826
+ children: [
827
+ /* @__PURE__ */ jsx("p", { className: cn("font-bold italic text-[#3B4256]", classNames?.label), children: resolvedLabels.createdOn }),
828
+ /* @__PURE__ */ jsx("p", { className: classNames?.value, children: createdAt ? dateFormatter(createdAt) : emptyValue }),
829
+ /* @__PURE__ */ jsx("p", { className: cn("font-bold italic text-[#3B4256]", classNames?.label), children: resolvedLabels.createdAtTime }),
830
+ /* @__PURE__ */ jsx("p", { className: classNames?.value, children: createdAt ? timeFormatter(createdAt) : emptyValue }),
831
+ /* @__PURE__ */ jsx("p", { className: cn("font-bold italic text-[#3B4256]", classNames?.label), children: resolvedLabels.createdBy }),
832
+ /* @__PURE__ */ jsx("p", { className: cn("col-span-3", classNames?.value), children: userFormatter(createdBy) }),
833
+ /* @__PURE__ */ jsx("p", { className: cn("font-bold italic text-[#3B4256]", classNames?.label), children: resolvedLabels.updatedOn }),
834
+ /* @__PURE__ */ jsx("p", { className: classNames?.value, children: updatedAt ? dateFormatter(updatedAt) : emptyValue }),
835
+ /* @__PURE__ */ jsx("p", { className: cn("font-bold italic text-[#3B4256]", classNames?.label), children: resolvedLabels.updatedAtTime }),
836
+ /* @__PURE__ */ jsx("p", { className: classNames?.value, children: updatedAt ? timeFormatter(updatedAt) : emptyValue }),
837
+ /* @__PURE__ */ jsx("p", { className: cn("font-bold italic text-[#3B4256]", classNames?.label), children: resolvedLabels.updatedBy }),
838
+ /* @__PURE__ */ jsx("p", { className: cn("col-span-3", classNames?.value), children: userFormatter(updatedBy) })
839
+ ]
840
+ }
841
+ ),
842
+ onDelete && /* @__PURE__ */ jsx(
843
+ "div",
844
+ {
845
+ className: canDelete ? cn("w-5 h-5 cursor-pointer text-red-500", classNames?.deleteButton) : cn("w-5 h-5 text-gray-300 cursor-not-allowed", classNames?.deleteButtonDisabled),
846
+ onClick: canDelete ? onDelete : void 0,
847
+ "aria-label": deleteAriaLabel,
848
+ role: "button",
849
+ children: resolvedDeleteIcon
850
+ }
851
+ )
852
+ ] });
853
+ };
740
854
  function Accordion({ ...props }) {
741
855
  return /* @__PURE__ */ jsx(AccordionPrimitive.Root, { "data-slot": "accordion", ...props });
742
856
  }
@@ -5453,9 +5567,13 @@ function DialogAlert({
5453
5567
  onOpenChange(false);
5454
5568
  }, [onCancel, onOpenChange]);
5455
5569
  const handleConfirm = useCallback(() => {
5456
- onConfirm?.();
5570
+ let func = onConfirm;
5571
+ if (variant === "success" && showCancel === false) {
5572
+ func = onConfirm ?? onCancel;
5573
+ }
5574
+ func?.();
5457
5575
  onOpenChange(false);
5458
- }, [onConfirm, onOpenChange]);
5576
+ }, [onCancel, onConfirm, onOpenChange, showCancel, variant]);
5459
5577
  return /* @__PURE__ */ jsx(Dialog2, { open, onOpenChange: persistent ? () => {
5460
5578
  } : onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
5461
5579
  /* @__PURE__ */ jsxs(DialogHeader2, { children: [
@@ -10344,10 +10462,7 @@ var Truncated = ({
10344
10462
  rows: lineClampLines ?? 1,
10345
10463
  expanded: false,
10346
10464
  miscDeps: [truncationClass],
10347
- onEllipsis: (s) => {
10348
- console.log("\u{1F680} ~ Truncated ~ s:", s);
10349
- setIsTruncated(s);
10350
- },
10465
+ onEllipsis: setIsTruncated,
10351
10466
  children: () => normalizedChildren
10352
10467
  }
10353
10468
  ) });
@@ -10377,10 +10492,10 @@ var Truncated = ({
10377
10492
  {
10378
10493
  side: tooltipSide,
10379
10494
  className: cn(
10380
- "text-white bg-[#8B8B8B] max-w-xs sm:max-w-md wrap-break-word shadow-lg",
10495
+ "text-white bg-sus-secondary-gray-10 max-w-xs sm:max-w-md wrap-break-word shadow-lg",
10381
10496
  tooltipContentClassName
10382
10497
  ),
10383
- arrowClassName: cn("bg-[#8B8B8B] fill-[#8B8B8B]", tooltipArrowClassName),
10498
+ arrowClassName: cn("bg-sus-secondary-gray-10 fill-sus-secondary-gray-10", tooltipArrowClassName),
10384
10499
  ...tooltipContentRest,
10385
10500
  children: tooltipContent
10386
10501
  }
@@ -11197,7 +11312,66 @@ var ComboboxInner = ({
11197
11312
  };
11198
11313
  var Combobox = React26.forwardRef(ComboboxInner);
11199
11314
  var Combobox_default = Combobox;
11315
+ var TruncatedMouseEnterDiv = ({
11316
+ value,
11317
+ className,
11318
+ tooltipProps,
11319
+ tooltipContentProps,
11320
+ arrowClassName
11321
+ }) => {
11322
+ const textRef = useRef(null);
11323
+ const [isTruncated, setIsTruncated] = useState(false);
11324
+ const checkTruncation = () => {
11325
+ if (textRef.current) {
11326
+ const { scrollWidth, clientWidth } = textRef.current;
11327
+ setIsTruncated(scrollWidth > clientWidth);
11328
+ }
11329
+ };
11330
+ const {
11331
+ className: tooltipContentClassName,
11332
+ side: tooltipContentSide,
11333
+ sideOffset: tooltipContentSideOffset,
11334
+ ...tooltipContentRest
11335
+ } = tooltipContentProps ?? {};
11336
+ return /* @__PURE__ */ jsxs(Tooltip2, { open: isTruncated, ...tooltipProps, children: [
11337
+ /* @__PURE__ */ jsx(TooltipTrigger2, { asChild: true, children: /* @__PURE__ */ jsx(
11338
+ "div",
11339
+ {
11340
+ ref: textRef,
11341
+ onMouseEnter: checkTruncation,
11342
+ onMouseLeave: () => setIsTruncated(false),
11343
+ className: cn("truncate", className),
11344
+ children: value
11345
+ }
11346
+ ) }),
11347
+ /* @__PURE__ */ jsxs(
11348
+ TooltipContent2,
11349
+ {
11350
+ side: tooltipContentSide ?? "bottom",
11351
+ className: cn(
11352
+ "text-white bg-sus-secondary-gray-10 max-w-xs sm:max-w-md wrap-break-word shadow-lg",
11353
+ tooltipContentClassName
11354
+ ),
11355
+ sideOffset: tooltipContentSideOffset ?? 10,
11356
+ ...tooltipContentRest,
11357
+ children: [
11358
+ /* @__PURE__ */ jsx(
11359
+ TooltipArrow,
11360
+ {
11361
+ className: cn(
11362
+ "bg-sus-secondary-gray-10 fill-sus-secondary-gray-10 z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]",
11363
+ arrowClassName
11364
+ )
11365
+ }
11366
+ ),
11367
+ value
11368
+ ]
11369
+ }
11370
+ )
11371
+ ] });
11372
+ };
11373
+ var truncatedMouseEnterDiv_default = TruncatedMouseEnterDiv;
11200
11374
 
11201
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionMenu, AdvanceSearch_default as AdvanceSearch, arrow_default as ArrowIcon, Button, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Combobox_default as Combobox, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CropperModal, CropperModalError, DIALOG_ALERT_I18N_SUBNAMESPACE, DIALOG_ALERT_TEMPLATES, DataTable_default as DataTable, DatePicker2 as DatePicker, Dialog, DialogAlert, DialogAlertProvider, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, filters_default as FiltersIcon, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormulaEditor, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, Image2 as Image, Input, InputNumber_default as InputNumber, Label2 as Label, List_default as List, container_default as ListContainer, header_default as ListHeader, table_default as ListTable, LookupSelect, MonthPicker2 as MonthPicker, navbar_default as Navbar, not_found_default as NotFoundIcon, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave_default as PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Spinner, calendar_default as SuiCalendarIcon, calendar2_default as SuiCalendarIcon2, check_default as SuiCheckIcon, dots_vertical_default as SuiDotsVerticalIcon, empty_data_default as SuiEmptyDataIcon, expand_default as SuiExpandIcon, filter_default as SuiFilterIcon, setting_default as SuiSettingIcon, triangle_down_default as SuiTriangleDownIcon, warning_default as SuiWarningIcon, Switch, Textarea, Tooltip2 as Tooltip, TooltipArrow, TooltipContent2 as TooltipContent, TooltipProvider2 as TooltipProvider, TooltipTrigger2 as TooltipTrigger, truncated_default as Truncated, ui_exports as UI, VirtualizedCommand_default as VirtualizedCommand, booleanToSelectValue, buildPrefixMap, buttonVariants, cn, compareAlphanumeric, debounce, defaultOperatorShortcuts, defaultOperators, formatISODate, getDialogAlertControls, inputVariants, isDefined, isEmptyObject, isValidParentheses, mapTokensToOutput, parseFormula, parseFormulaToToken, resetVisibleTableState, selectValueToBoolean, spinnerVariants, splitOperators, stripNullishObject, throttle, tokenizeFormulaString, useControllableState_default as useControllableState, useFormField, useGridSettingsStore_default as useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useIsomorphicLayoutEffect, useMediaQuery_default as useMediaQuery, usePreventPageLeave_default as usePreventPageLeave, usePreventPageLeaveStore_default as usePreventPageLeaveStore, useScreenSize_default as useScreenSize, useSidebar, useTruncated_default as useTruncated, validateTokenPrefixes };
11375
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionMenu, AdvanceSearch_default as AdvanceSearch, arrow_default as ArrowIcon, AuditFooter, Button, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Combobox_default as Combobox, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CropperModal, CropperModalError, DIALOG_ALERT_I18N_SUBNAMESPACE, DIALOG_ALERT_TEMPLATES, DataTable_default as DataTable, DatePicker2 as DatePicker, Dialog, DialogAlert, DialogAlertProvider, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, filters_default as FiltersIcon, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormulaEditor, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, Image2 as Image, Input, InputNumber_default as InputNumber, Label2 as Label, List_default as List, container_default as ListContainer, header_default as ListHeader, table_default as ListTable, LookupSelect, MonthPicker2 as MonthPicker, navbar_default as Navbar, not_found_default as NotFoundIcon, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave_default as PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator2 as Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Spinner, calendar_default as SuiCalendarIcon, calendar2_default as SuiCalendarIcon2, check_default as SuiCheckIcon, dots_vertical_default as SuiDotsVerticalIcon, empty_data_default as SuiEmptyDataIcon, expand_default as SuiExpandIcon, filter_default as SuiFilterIcon, setting_default as SuiSettingIcon, triangle_down_default as SuiTriangleDownIcon, warning_default as SuiWarningIcon, Switch, Textarea, Tooltip2 as Tooltip, TooltipArrow, TooltipContent2 as TooltipContent, TooltipProvider2 as TooltipProvider, TooltipTrigger2 as TooltipTrigger, trash_default as TrashIcon, truncated_default as Truncated, truncatedMouseEnterDiv_default as TruncatedMouseEnterDiv, ui_exports as UI, VirtualizedCommand_default as VirtualizedCommand, booleanToSelectValue, buildPrefixMap, buttonVariants, cn, compareAlphanumeric, debounce, defaultOperatorShortcuts, defaultOperators, formatISODate, getDialogAlertControls, inputVariants, isDefined, isEmptyObject, isValidParentheses, mapTokensToOutput, parseFormula, parseFormulaToToken, resetVisibleTableState, selectValueToBoolean, spinnerVariants, splitOperators, stripNullishObject, throttle, tokenizeFormulaString, useControllableState_default as useControllableState, useFormField, useGridSettingsStore_default as useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useIsomorphicLayoutEffect, useMediaQuery_default as useMediaQuery, usePreventPageLeave_default as usePreventPageLeave, usePreventPageLeaveStore_default as usePreventPageLeaveStore, useScreenSize_default as useScreenSize, useSidebar, useTruncated_default as useTruncated, validateTokenPrefixes };
11202
11376
  //# sourceMappingURL=index.mjs.map
11203
11377
  //# sourceMappingURL=index.mjs.map