@caratlogic/design-system 0.0.7 → 0.0.8

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.esm.js CHANGED
@@ -12556,7 +12556,7 @@ var Popover$1 = (props) => {
12556
12556
  };
12557
12557
  Popover$1.displayName = POPOVER_NAME;
12558
12558
  var ANCHOR_NAME$2 = "PopoverAnchor";
12559
- var PopoverAnchor = React.forwardRef(
12559
+ var PopoverAnchor$1 = React.forwardRef(
12560
12560
  (props, forwardedRef) => {
12561
12561
  const { __scopePopover, ...anchorProps } = props;
12562
12562
  const context = usePopoverContext(ANCHOR_NAME$2, __scopePopover);
@@ -12569,7 +12569,7 @@ var PopoverAnchor = React.forwardRef(
12569
12569
  return /* @__PURE__ */ jsx(Anchor$1, { ...popperScope, ...anchorProps, ref: forwardedRef });
12570
12570
  }
12571
12571
  );
12572
- PopoverAnchor.displayName = ANCHOR_NAME$2;
12572
+ PopoverAnchor$1.displayName = ANCHOR_NAME$2;
12573
12573
  var TRIGGER_NAME$5 = "PopoverTrigger";
12574
12574
  var PopoverTrigger$1 = React.forwardRef(
12575
12575
  (props, forwardedRef) => {
@@ -12789,6 +12789,7 @@ function getState$2(open) {
12789
12789
  return open ? "open" : "closed";
12790
12790
  }
12791
12791
  var Root2$3 = Popover$1;
12792
+ var Anchor2$1 = PopoverAnchor$1;
12792
12793
  var Trigger$4 = PopoverTrigger$1;
12793
12794
  var Portal$4 = PopoverPortal;
12794
12795
  var Content2$4 = PopoverContent$1;
@@ -12802,6 +12803,9 @@ function PopoverTrigger({ ...props }) {
12802
12803
  function PopoverContent({ className, align = 'center', sideOffset = 8, ...props }) {
12803
12804
  return (jsx(Portal$4, { children: jsx(Content2$4, { "data-slot": "popover-content", align: align, sideOffset: sideOffset, className: cn('bg-popover text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden', className), ...props }) }));
12804
12805
  }
12806
+ function PopoverAnchor({ ...props }) {
12807
+ return jsx(Anchor2$1, { "data-slot": "popover-anchor", ...props });
12808
+ }
12805
12809
 
12806
12810
  const SCROLL_THRESHOLD = 50;
12807
12811
  function useSearchableSelect({ selectedItem, onChange, getOptionKey, getOptionLabel, getOptionSubLabel, fetchPage, staticOptions, filterFn, preSelectedId, resolveById, pageSize, debounceMs, }) {
@@ -20930,14 +20934,14 @@ function useRefundToWallet(open) {
20930
20934
  return { refundToWallet, setRefundToWallet };
20931
20935
  }
20932
20936
 
20933
- const ConfirmDialog = ({ open, onOpenChange, title, description, info, confirmLabel = 'Yes', cancelLabel = 'Cancel', confirmVariant = 'default', disabled = false, onConfirm, onCancel, }) => {
20937
+ const ConfirmDialog = ({ open, onOpenChange, title, description, info, confirmLabel = 'Yes', cancelLabel = 'Cancel', confirmVariant = 'default', icon: Icon = Trash2, disabled = false, onConfirm, onCancel, }) => {
20934
20938
  const { refundToWallet, setRefundToWallet } = useRefundToWallet(open);
20935
- return (jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: jsxs(DialogContent, { children: [jsxs(DialogHeader, { children: [jsxs(DialogTitle, { className: "flex items-center gap-2", children: [confirmVariant === 'destructive' && (jsx("span", { className: "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-destructive/10", children: jsx(Trash2, { className: "h-4 w-4 text-destructive" }) })), jsx("span", { children: title })] }), description && (jsx(DialogDescription, { className: "mt-2", children: description })), info && (jsx(InfoCard, { info: info, title: title, refundToWallet: refundToWallet, onRefundChange: setRefundToWallet }))] }), jsxs(DialogFooter, { className: "mt-4", children: [jsx(Button$1, { variant: "outline", onClick: () => {
20939
+ return (jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: jsxs(DialogContent, { className: "gap-3 p-5", children: [jsxs(DialogHeader, { className: "gap-1.5", children: [jsxs(DialogTitle, { className: "flex items-center gap-2", children: [confirmVariant === 'destructive' && (jsx("span", { className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-destructive/10", children: jsx(Icon, { className: "h-3.5 w-3.5 text-destructive" }) })), jsx("span", { children: title })] }), description && jsx(DialogDescription, { children: description }), info && (jsx(InfoCard, { info: info, title: title, refundToWallet: refundToWallet, onRefundChange: setRefundToWallet }))] }), jsxs(DialogFooter, { className: "mt-1", children: [jsx(Button$1, { variant: "outline", onClick: () => {
20936
20940
  onCancel?.();
20937
20941
  onOpenChange(false);
20938
20942
  }, disabled: disabled, children: cancelLabel }), jsxs(Button$1, { variant: confirmVariant, onClick: async () => {
20939
20943
  await onConfirm(title === 'Cancel Invoice' ? refundToWallet : undefined);
20940
- }, disabled: disabled, className: "ml-3", children: [confirmVariant === 'destructive' && (jsx(Trash2, { className: "mr-1.5 h-4 w-4", "aria-hidden": true })), disabled ? 'Please wait...' : confirmLabel] })] })] }) }));
20944
+ }, disabled: disabled, children: [confirmVariant === 'destructive' && (jsx(Icon, { className: "h-4 w-4", "aria-hidden": true })), disabled ? 'Please wait...' : confirmLabel] })] })] }) }));
20941
20945
  };
20942
20946
 
20943
20947
  /** Class builder for a segment button in the `segmented` variant. */
@@ -34727,11 +34731,18 @@ function DatePickerHeader({ monthDate, changeYear, changeMonth, decreaseMonth, i
34727
34731
  function DateInput({ value, onChange, onBlur, name, className, min, max, disabled, placeholder = 'Select date', }) {
34728
34732
  const [open, setOpen] = useState(false);
34729
34733
  const { minDate, maxDate, minYear, maxYear } = computeDateBounds(min, max);
34730
- const openPicker = () => {
34731
- if (!disabled)
34732
- setOpen(true);
34733
- };
34734
- return (jsxs(Popover, { open: open, onOpenChange: setOpen, children: [jsx(PopoverTrigger, { asChild: true, children: jsxs("button", { type: "button", name: name, onBlur: onBlur, onClick: openPicker, disabled: disabled, "data-slot": "input", "data-empty": !value || undefined, className: cn('border-input-border flex h-9 w-full min-w-0 cursor-pointer items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-1 text-left shadow-[0_1px_2px_0_#0000000d] transition-[color,box-shadow] outline-none', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]', 'aria-invalid:ring-destructive/20 aria-invalid:border-destructive', disabled && 'cursor-not-allowed bg-muted text-label', className), children: [jsx("span", { className: cn('truncate text-sm md:text-sm', value ? 'text-foreground' : 'text-placeholder'), children: value ? moment(value).format('DD/MM/YYYY') : placeholder }), jsx("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground", children: jsx(CalendarDays, { className: "h-4 w-4 stroke-[1.75]" }) })] }) }), jsx(PopoverContent, { align: "start", className: "date-range-picker-popover w-auto p-4", children: jsx(DatePicker, { inline: true, selected: value ?? null, minDate: minDate ? moment(minDate, 'YYYY-MM-DD').toDate() : undefined, maxDate: maxDate ? moment(maxDate, 'YYYY-MM-DD').toDate() : undefined, onChange: (date) => {
34734
+ // NOTE: We drive `open` ourselves from the button's onClick instead of using
34735
+ // Radix's <PopoverTrigger> toggle. When this Popover is nested inside the
34736
+ // modal <SlideOut> (Radix Dialog), the trigger's built-in toggle does not
34737
+ // fire in Safari, so the calendar never opened. Using <PopoverAnchor> (pure
34738
+ // positioning, no event handlers) + a single controlled toggle is the one
34739
+ // source of truth — no double-fire, and it works across browsers. `modal`
34740
+ // lets the open popover own pointer events above the dialog so the calendar
34741
+ // (portalled to <body>) stays clickable.
34742
+ return (jsxs(Popover, { open: open, onOpenChange: setOpen, modal: true, children: [jsx(PopoverAnchor, { asChild: true, children: jsxs("button", { type: "button", name: name, onBlur: onBlur, disabled: disabled, "aria-haspopup": "dialog", "aria-expanded": open, onClick: () => {
34743
+ if (!disabled)
34744
+ setOpen((prev) => !prev);
34745
+ }, "data-slot": "input", "data-empty": !value || undefined, className: cn('border-input-border flex h-9 w-full min-w-0 cursor-pointer items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-1 text-left shadow-[0_1px_2px_0_#0000000d] transition-[color,box-shadow] outline-none', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]', 'aria-invalid:ring-destructive/20 aria-invalid:border-destructive', disabled && 'cursor-not-allowed bg-muted text-label', className), children: [jsx("span", { className: cn('truncate text-sm md:text-sm', value ? 'text-foreground' : 'text-placeholder'), children: value ? moment(value).format('DD/MM/YYYY') : placeholder }), jsx("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground", children: jsx(CalendarDays, { className: "h-4 w-4 stroke-[1.75]" }) })] }) }), jsx(PopoverContent, { align: "start", className: "date-range-picker-popover w-auto p-4", children: jsx(DatePicker, { inline: true, selected: value ?? null, minDate: minDate ? moment(minDate, 'YYYY-MM-DD').toDate() : undefined, maxDate: maxDate ? moment(maxDate, 'YYYY-MM-DD').toDate() : undefined, onChange: (date) => {
34735
34746
  onChange(date ?? undefined);
34736
34747
  if (date)
34737
34748
  setOpen(false);