@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/components/molecules/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
- package/dist/components/molecules/ConfirmDialog/ConfirmDialog.types.d.ts +3 -0
- package/dist/components/molecules/ConfirmDialog/ConfirmDialog.types.d.ts.map +1 -1
- package/dist/components/molecules/DateInput/DateInput.d.ts.map +1 -1
- package/dist/index.cjs.js +21 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +21 -10
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/ConfirmDialog/ConfirmDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"ConfirmDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/ConfirmDialog/ConfirmDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAoE/C,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
2
|
+
import type { LucideIcon } from 'lucide-react';
|
|
2
3
|
export interface ConfirmDialogInfo {
|
|
3
4
|
invoiceNumber?: string;
|
|
4
5
|
invoiceDate?: string;
|
|
@@ -18,6 +19,8 @@ export interface ConfirmDialogProps {
|
|
|
18
19
|
confirmLabel?: string;
|
|
19
20
|
cancelLabel?: string;
|
|
20
21
|
confirmVariant?: 'default' | 'destructive' | 'secondary' | 'outline';
|
|
22
|
+
/** Icon shown in the header badge and confirm button. Defaults to `Trash2`. Only rendered for the `destructive` variant. */
|
|
23
|
+
icon?: LucideIcon;
|
|
21
24
|
disabled?: boolean;
|
|
22
25
|
/** Receives `refundToWallet` when applicable (the Cancel Invoice flow). */
|
|
23
26
|
onConfirm: (refundToWallet?: boolean) => Promise<void> | void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmDialog.types.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/ConfirmDialog/ConfirmDialog.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmDialog.types.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/ConfirmDialog/ConfirmDialog.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC;IACrE,4HAA4H;IAC5H,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,SAAS,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CACtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/DateInput/DateInput.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,4CAA4C,CAAC;AACpD,OAAO,yBAAyB,CAAC;AAEjC,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,SAAS,EACT,GAAG,EACH,GAAG,EACH,QAAQ,EACR,WAA2B,GAC5B,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/DateInput/DateInput.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,4CAA4C,CAAC;AACpD,OAAO,yBAAyB,CAAC;AAEjC,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,SAAS,EACT,GAAG,EACH,GAAG,EACH,QAAQ,EACR,WAA2B,GAC5B,EAAE,cAAc,2CA+GhB"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -12576,7 +12576,7 @@ var Popover$1 = (props) => {
|
|
|
12576
12576
|
};
|
|
12577
12577
|
Popover$1.displayName = POPOVER_NAME;
|
|
12578
12578
|
var ANCHOR_NAME$2 = "PopoverAnchor";
|
|
12579
|
-
var PopoverAnchor = React__namespace.forwardRef(
|
|
12579
|
+
var PopoverAnchor$1 = React__namespace.forwardRef(
|
|
12580
12580
|
(props, forwardedRef) => {
|
|
12581
12581
|
const { __scopePopover, ...anchorProps } = props;
|
|
12582
12582
|
const context = usePopoverContext(ANCHOR_NAME$2, __scopePopover);
|
|
@@ -12589,7 +12589,7 @@ var PopoverAnchor = React__namespace.forwardRef(
|
|
|
12589
12589
|
return /* @__PURE__ */ jsxRuntime.jsx(Anchor$1, { ...popperScope, ...anchorProps, ref: forwardedRef });
|
|
12590
12590
|
}
|
|
12591
12591
|
);
|
|
12592
|
-
PopoverAnchor.displayName = ANCHOR_NAME$2;
|
|
12592
|
+
PopoverAnchor$1.displayName = ANCHOR_NAME$2;
|
|
12593
12593
|
var TRIGGER_NAME$5 = "PopoverTrigger";
|
|
12594
12594
|
var PopoverTrigger$1 = React__namespace.forwardRef(
|
|
12595
12595
|
(props, forwardedRef) => {
|
|
@@ -12809,6 +12809,7 @@ function getState$2(open) {
|
|
|
12809
12809
|
return open ? "open" : "closed";
|
|
12810
12810
|
}
|
|
12811
12811
|
var Root2$3 = Popover$1;
|
|
12812
|
+
var Anchor2$1 = PopoverAnchor$1;
|
|
12812
12813
|
var Trigger$4 = PopoverTrigger$1;
|
|
12813
12814
|
var Portal$4 = PopoverPortal;
|
|
12814
12815
|
var Content2$4 = PopoverContent$1;
|
|
@@ -12822,6 +12823,9 @@ function PopoverTrigger({ ...props }) {
|
|
|
12822
12823
|
function PopoverContent({ className, align = 'center', sideOffset = 8, ...props }) {
|
|
12823
12824
|
return (jsxRuntime.jsx(Portal$4, { children: jsxRuntime.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 }) }));
|
|
12824
12825
|
}
|
|
12826
|
+
function PopoverAnchor({ ...props }) {
|
|
12827
|
+
return jsxRuntime.jsx(Anchor2$1, { "data-slot": "popover-anchor", ...props });
|
|
12828
|
+
}
|
|
12825
12829
|
|
|
12826
12830
|
const SCROLL_THRESHOLD = 50;
|
|
12827
12831
|
function useSearchableSelect({ selectedItem, onChange, getOptionKey, getOptionLabel, getOptionSubLabel, fetchPage, staticOptions, filterFn, preSelectedId, resolveById, pageSize, debounceMs, }) {
|
|
@@ -20950,14 +20954,14 @@ function useRefundToWallet(open) {
|
|
|
20950
20954
|
return { refundToWallet, setRefundToWallet };
|
|
20951
20955
|
}
|
|
20952
20956
|
|
|
20953
|
-
const ConfirmDialog = ({ open, onOpenChange, title, description, info, confirmLabel = 'Yes', cancelLabel = 'Cancel', confirmVariant = 'default', disabled = false, onConfirm, onCancel, }) => {
|
|
20957
|
+
const ConfirmDialog = ({ open, onOpenChange, title, description, info, confirmLabel = 'Yes', cancelLabel = 'Cancel', confirmVariant = 'default', icon: Icon = Trash2, disabled = false, onConfirm, onCancel, }) => {
|
|
20954
20958
|
const { refundToWallet, setRefundToWallet } = useRefundToWallet(open);
|
|
20955
|
-
return (jsxRuntime.jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: jsxRuntime.jsxs(DialogContent, { children: [jsxRuntime.jsxs(DialogHeader, { children: [jsxRuntime.jsxs(DialogTitle, { className: "flex items-center gap-2", children: [confirmVariant === 'destructive' && (jsxRuntime.jsx("span", { className: "inline-flex h-
|
|
20959
|
+
return (jsxRuntime.jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: jsxRuntime.jsxs(DialogContent, { className: "gap-3 p-5", children: [jsxRuntime.jsxs(DialogHeader, { className: "gap-1.5", children: [jsxRuntime.jsxs(DialogTitle, { className: "flex items-center gap-2", children: [confirmVariant === 'destructive' && (jsxRuntime.jsx("span", { className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-destructive/10", children: jsxRuntime.jsx(Icon, { className: "h-3.5 w-3.5 text-destructive" }) })), jsxRuntime.jsx("span", { children: title })] }), description && jsxRuntime.jsx(DialogDescription, { children: description }), info && (jsxRuntime.jsx(InfoCard, { info: info, title: title, refundToWallet: refundToWallet, onRefundChange: setRefundToWallet }))] }), jsxRuntime.jsxs(DialogFooter, { className: "mt-1", children: [jsxRuntime.jsx(Button$1, { variant: "outline", onClick: () => {
|
|
20956
20960
|
onCancel?.();
|
|
20957
20961
|
onOpenChange(false);
|
|
20958
20962
|
}, disabled: disabled, children: cancelLabel }), jsxRuntime.jsxs(Button$1, { variant: confirmVariant, onClick: async () => {
|
|
20959
20963
|
await onConfirm(title === 'Cancel Invoice' ? refundToWallet : undefined);
|
|
20960
|
-
}, disabled: disabled,
|
|
20964
|
+
}, disabled: disabled, children: [confirmVariant === 'destructive' && (jsxRuntime.jsx(Icon, { className: "h-4 w-4", "aria-hidden": true })), disabled ? 'Please wait...' : confirmLabel] })] })] }) }));
|
|
20961
20965
|
};
|
|
20962
20966
|
|
|
20963
20967
|
/** Class builder for a segment button in the `segmented` variant. */
|
|
@@ -34747,11 +34751,18 @@ function DatePickerHeader({ monthDate, changeYear, changeMonth, decreaseMonth, i
|
|
|
34747
34751
|
function DateInput({ value, onChange, onBlur, name, className, min, max, disabled, placeholder = 'Select date', }) {
|
|
34748
34752
|
const [open, setOpen] = React.useState(false);
|
|
34749
34753
|
const { minDate, maxDate, minYear, maxYear } = computeDateBounds(min, max);
|
|
34750
|
-
|
|
34751
|
-
|
|
34752
|
-
|
|
34753
|
-
|
|
34754
|
-
|
|
34754
|
+
// NOTE: We drive `open` ourselves from the button's onClick instead of using
|
|
34755
|
+
// Radix's <PopoverTrigger> toggle. When this Popover is nested inside the
|
|
34756
|
+
// modal <SlideOut> (Radix Dialog), the trigger's built-in toggle does not
|
|
34757
|
+
// fire in Safari, so the calendar never opened. Using <PopoverAnchor> (pure
|
|
34758
|
+
// positioning, no event handlers) + a single controlled toggle is the one
|
|
34759
|
+
// source of truth — no double-fire, and it works across browsers. `modal`
|
|
34760
|
+
// lets the open popover own pointer events above the dialog so the calendar
|
|
34761
|
+
// (portalled to <body>) stays clickable.
|
|
34762
|
+
return (jsxRuntime.jsxs(Popover, { open: open, onOpenChange: setOpen, modal: true, children: [jsxRuntime.jsx(PopoverAnchor, { asChild: true, children: jsxRuntime.jsxs("button", { type: "button", name: name, onBlur: onBlur, disabled: disabled, "aria-haspopup": "dialog", "aria-expanded": open, onClick: () => {
|
|
34763
|
+
if (!disabled)
|
|
34764
|
+
setOpen((prev) => !prev);
|
|
34765
|
+
}, "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: [jsxRuntime.jsx("span", { className: cn('truncate text-sm md:text-sm', value ? 'text-foreground' : 'text-placeholder'), children: value ? moment(value).format('DD/MM/YYYY') : placeholder }), jsxRuntime.jsx("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground", children: jsxRuntime.jsx(CalendarDays, { className: "h-4 w-4 stroke-[1.75]" }) })] }) }), jsxRuntime.jsx(PopoverContent, { align: "start", className: "date-range-picker-popover w-auto p-4", children: jsxRuntime.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) => {
|
|
34755
34766
|
onChange(date ?? undefined);
|
|
34756
34767
|
if (date)
|
|
34757
34768
|
setOpen(false);
|