@machinemetrics/mm-react-components 0.2.3-27 → 0.2.3-29
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/ui/sheet-banner.d.ts +10 -0
- package/dist/components/ui/sheet-banner.d.ts.map +1 -0
- package/dist/components/ui/sheet.d.ts +7 -1
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sonner.d.ts +1 -0
- package/dist/components/ui/sonner.d.ts.map +1 -1
- package/dist/components/ui/tabs.d.ts +16 -2
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/mm-react-components.css +1 -1
- package/dist/mm-react-components.es.js +188 -101
- package/dist/mm-react-components.es.js.map +1 -1
- package/dist/mm-react-components.umd.js +9 -9
- package/dist/mm-react-components.umd.js.map +1 -1
- package/dist/preview/SheetBannerPreview.d.ts +2 -0
- package/dist/preview/SheetBannerPreview.d.ts.map +1 -0
- package/dist/preview/SheetPreview.d.ts.map +1 -1
- package/dist/preview/TabsPreview.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -10340,6 +10340,32 @@ var Content$3 = DialogContent$1;
|
|
|
10340
10340
|
var Title = DialogTitle$1;
|
|
10341
10341
|
var Description = DialogDescription$1;
|
|
10342
10342
|
var Close = DialogClose$1;
|
|
10343
|
+
const SheetBanner = React.forwardRef(
|
|
10344
|
+
({ variant, icon, text: text2, additionalText, className, ...props }, ref) => {
|
|
10345
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
10346
|
+
"div",
|
|
10347
|
+
{
|
|
10348
|
+
ref,
|
|
10349
|
+
"data-slot": "sheet-banner",
|
|
10350
|
+
className: cn$1(
|
|
10351
|
+
"sheet-banner",
|
|
10352
|
+
variant === "shared" ? "sheet-banner-shared" : "sheet-banner-company",
|
|
10353
|
+
className
|
|
10354
|
+
),
|
|
10355
|
+
...props,
|
|
10356
|
+
children: [
|
|
10357
|
+
icon,
|
|
10358
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sheet-banner-text", children: text2 }),
|
|
10359
|
+
additionalText && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
10360
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sheet-banner-text", children: "|" }),
|
|
10361
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sheet-banner-text", children: additionalText })
|
|
10362
|
+
] })
|
|
10363
|
+
]
|
|
10364
|
+
}
|
|
10365
|
+
);
|
|
10366
|
+
}
|
|
10367
|
+
);
|
|
10368
|
+
SheetBanner.displayName = "SheetBanner";
|
|
10343
10369
|
function Sheet({ ...props }) {
|
|
10344
10370
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Root$9, { "data-slot": "sheet", ...props });
|
|
10345
10371
|
}
|
|
@@ -10425,6 +10451,11 @@ function SheetContent({
|
|
|
10425
10451
|
side = "right",
|
|
10426
10452
|
showCloseButton = true,
|
|
10427
10453
|
closeButtonPosition = "corner",
|
|
10454
|
+
showBanner = false,
|
|
10455
|
+
bannerVariant,
|
|
10456
|
+
bannerIcon,
|
|
10457
|
+
bannerText,
|
|
10458
|
+
bannerAdditionalText,
|
|
10428
10459
|
...props
|
|
10429
10460
|
}) {
|
|
10430
10461
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(SheetPortal, { children: [
|
|
@@ -10434,7 +10465,8 @@ function SheetContent({
|
|
|
10434
10465
|
{
|
|
10435
10466
|
"data-slot": "sheet-content",
|
|
10436
10467
|
className: cn$1(
|
|
10437
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col
|
|
10468
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 outline-none",
|
|
10469
|
+
showBanner ? "gap-0" : "gap-4",
|
|
10438
10470
|
side === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
|
|
10439
10471
|
side === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
|
|
10440
10472
|
side === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
|
|
@@ -10443,12 +10475,24 @@ function SheetContent({
|
|
|
10443
10475
|
),
|
|
10444
10476
|
...props,
|
|
10445
10477
|
children: [
|
|
10478
|
+
showBanner && bannerVariant && bannerIcon && bannerText && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
10479
|
+
SheetBanner,
|
|
10480
|
+
{
|
|
10481
|
+
variant: bannerVariant,
|
|
10482
|
+
icon: bannerIcon,
|
|
10483
|
+
text: bannerText,
|
|
10484
|
+
additionalText: bannerAdditionalText
|
|
10485
|
+
}
|
|
10486
|
+
),
|
|
10446
10487
|
children,
|
|
10447
10488
|
showCloseButton && closeButtonPosition === "corner" && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
10448
10489
|
Close,
|
|
10449
10490
|
{
|
|
10450
10491
|
"data-slot": "sheet-close",
|
|
10451
|
-
className:
|
|
10492
|
+
className: cn$1(
|
|
10493
|
+
"absolute right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:outline-none disabled:pointer-events-none",
|
|
10494
|
+
showBanner ? "top-12" : "top-4"
|
|
10495
|
+
),
|
|
10452
10496
|
children: [
|
|
10453
10497
|
/* @__PURE__ */ jsxRuntimeExports.jsx(X$1, { className: "size-4" }),
|
|
10454
10498
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Close" })
|
|
@@ -11230,16 +11274,60 @@ var Root2$4 = Tabs$1;
|
|
|
11230
11274
|
var List = TabsList$1;
|
|
11231
11275
|
var Trigger$3 = TabsTrigger$1;
|
|
11232
11276
|
var Content$2 = TabsContent$1;
|
|
11277
|
+
const TabsContext = React__default.createContext(void 0);
|
|
11278
|
+
function useTabsValue() {
|
|
11279
|
+
return React__default.useContext(TabsContext);
|
|
11280
|
+
}
|
|
11233
11281
|
function Tabs({
|
|
11234
11282
|
className,
|
|
11283
|
+
sharedContent,
|
|
11284
|
+
value: controlledValue,
|
|
11285
|
+
defaultValue: defaultValue2,
|
|
11286
|
+
onValueChange,
|
|
11287
|
+
children,
|
|
11235
11288
|
...props
|
|
11236
11289
|
}) {
|
|
11290
|
+
const [internalValue, setInternalValue] = React__default.useState(
|
|
11291
|
+
defaultValue2
|
|
11292
|
+
);
|
|
11293
|
+
const currentValue = controlledValue ?? internalValue;
|
|
11294
|
+
const handleValueChange = React__default.useCallback(
|
|
11295
|
+
(newValue) => {
|
|
11296
|
+
if (controlledValue === void 0) {
|
|
11297
|
+
setInternalValue(newValue);
|
|
11298
|
+
}
|
|
11299
|
+
onValueChange?.(newValue);
|
|
11300
|
+
},
|
|
11301
|
+
[controlledValue, onValueChange]
|
|
11302
|
+
);
|
|
11303
|
+
const contextValue = React__default.useMemo(() => currentValue, [currentValue]);
|
|
11304
|
+
if (sharedContent !== void 0) {
|
|
11305
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
11306
|
+
Root2$4,
|
|
11307
|
+
{
|
|
11308
|
+
"data-slot": "tabs",
|
|
11309
|
+
className: cn$1("flex flex-col gap-2", className),
|
|
11310
|
+
value: currentValue,
|
|
11311
|
+
defaultValue: defaultValue2,
|
|
11312
|
+
onValueChange: handleValueChange,
|
|
11313
|
+
...props,
|
|
11314
|
+
children: [
|
|
11315
|
+
children,
|
|
11316
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-slot": "tabs-shared-content", className: "flex-1 outline-none", children: typeof sharedContent === "function" ? sharedContent(currentValue) : sharedContent })
|
|
11317
|
+
]
|
|
11318
|
+
}
|
|
11319
|
+
) });
|
|
11320
|
+
}
|
|
11237
11321
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11238
11322
|
Root2$4,
|
|
11239
11323
|
{
|
|
11240
11324
|
"data-slot": "tabs",
|
|
11241
11325
|
className: cn$1("flex flex-col gap-2", className),
|
|
11242
|
-
|
|
11326
|
+
value: controlledValue,
|
|
11327
|
+
defaultValue: defaultValue2,
|
|
11328
|
+
onValueChange,
|
|
11329
|
+
...props,
|
|
11330
|
+
children
|
|
11243
11331
|
}
|
|
11244
11332
|
);
|
|
11245
11333
|
}
|
|
@@ -43166,31 +43254,31 @@ class Observer {
|
|
|
43166
43254
|
var _data_id;
|
|
43167
43255
|
const { message: message2, ...rest } = data;
|
|
43168
43256
|
const id = typeof (data == null ? void 0 : data.id) === "number" || ((_data_id = data.id) == null ? void 0 : _data_id.length) > 0 ? data.id : toastsCounter++;
|
|
43169
|
-
const alreadyExists = this.toasts.find((
|
|
43170
|
-
return
|
|
43257
|
+
const alreadyExists = this.toasts.find((toast2) => {
|
|
43258
|
+
return toast2.id === id;
|
|
43171
43259
|
});
|
|
43172
43260
|
const dismissible = data.dismissible === void 0 ? true : data.dismissible;
|
|
43173
43261
|
if (this.dismissedToasts.has(id)) {
|
|
43174
43262
|
this.dismissedToasts.delete(id);
|
|
43175
43263
|
}
|
|
43176
43264
|
if (alreadyExists) {
|
|
43177
|
-
this.toasts = this.toasts.map((
|
|
43178
|
-
if (
|
|
43265
|
+
this.toasts = this.toasts.map((toast2) => {
|
|
43266
|
+
if (toast2.id === id) {
|
|
43179
43267
|
this.publish({
|
|
43180
|
-
...
|
|
43268
|
+
...toast2,
|
|
43181
43269
|
...data,
|
|
43182
43270
|
id,
|
|
43183
43271
|
title: message2
|
|
43184
43272
|
});
|
|
43185
43273
|
return {
|
|
43186
|
-
...
|
|
43274
|
+
...toast2,
|
|
43187
43275
|
...data,
|
|
43188
43276
|
id,
|
|
43189
43277
|
dismissible,
|
|
43190
43278
|
title: message2
|
|
43191
43279
|
};
|
|
43192
43280
|
}
|
|
43193
|
-
return
|
|
43281
|
+
return toast2;
|
|
43194
43282
|
});
|
|
43195
43283
|
} else {
|
|
43196
43284
|
this.addToast({
|
|
@@ -43210,9 +43298,9 @@ class Observer {
|
|
|
43210
43298
|
dismiss: true
|
|
43211
43299
|
})));
|
|
43212
43300
|
} else {
|
|
43213
|
-
this.toasts.forEach((
|
|
43301
|
+
this.toasts.forEach((toast2) => {
|
|
43214
43302
|
this.subscribers.forEach((subscriber) => subscriber({
|
|
43215
|
-
id:
|
|
43303
|
+
id: toast2.id,
|
|
43216
43304
|
dismiss: true
|
|
43217
43305
|
}));
|
|
43218
43306
|
});
|
|
@@ -43381,7 +43469,7 @@ class Observer {
|
|
|
43381
43469
|
return id;
|
|
43382
43470
|
};
|
|
43383
43471
|
this.getActiveToasts = () => {
|
|
43384
|
-
return this.toasts.filter((
|
|
43472
|
+
return this.toasts.filter((toast2) => !this.dismissedToasts.has(toast2.id));
|
|
43385
43473
|
};
|
|
43386
43474
|
this.subscribers = [];
|
|
43387
43475
|
this.toasts = [];
|
|
@@ -43404,7 +43492,7 @@ const isHttpResponse = (data) => {
|
|
|
43404
43492
|
const basicToast = toastFunction;
|
|
43405
43493
|
const getHistory = () => ToastState.toasts;
|
|
43406
43494
|
const getToasts = () => ToastState.getActiveToasts();
|
|
43407
|
-
Object.assign(basicToast, {
|
|
43495
|
+
const toast = Object.assign(basicToast, {
|
|
43408
43496
|
success: ToastState.success,
|
|
43409
43497
|
info: ToastState.info,
|
|
43410
43498
|
warning: ToastState.warning,
|
|
@@ -43446,7 +43534,7 @@ function getDefaultSwipeDirections(position) {
|
|
|
43446
43534
|
}
|
|
43447
43535
|
const Toast = (props) => {
|
|
43448
43536
|
var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
|
|
43449
|
-
const { invert: ToasterInvert, toast, unstyled, interacting, setHeights, visibleToasts, heights, index: index2, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = "", descriptionClassName = "", duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = "Close toast" } = props;
|
|
43537
|
+
const { invert: ToasterInvert, toast: toast2, unstyled, interacting, setHeights, visibleToasts, heights, index: index2, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = "", descriptionClassName = "", duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = "Close toast" } = props;
|
|
43450
43538
|
const [swipeDirection, setSwipeDirection] = React__default.useState(null);
|
|
43451
43539
|
const [swipeOutDirection, setSwipeOutDirection] = React__default.useState(null);
|
|
43452
43540
|
const [mounted, setMounted] = React__default.useState(false);
|
|
@@ -43456,28 +43544,28 @@ const Toast = (props) => {
|
|
|
43456
43544
|
const [isSwiped, setIsSwiped] = React__default.useState(false);
|
|
43457
43545
|
const [offsetBeforeRemove, setOffsetBeforeRemove] = React__default.useState(0);
|
|
43458
43546
|
const [initialHeight, setInitialHeight] = React__default.useState(0);
|
|
43459
|
-
const remainingTime = React__default.useRef(
|
|
43547
|
+
const remainingTime = React__default.useRef(toast2.duration || durationFromToaster || TOAST_LIFETIME);
|
|
43460
43548
|
const dragStartTime = React__default.useRef(null);
|
|
43461
43549
|
const toastRef = React__default.useRef(null);
|
|
43462
43550
|
const isFront = index2 === 0;
|
|
43463
43551
|
const isVisible = index2 + 1 <= visibleToasts;
|
|
43464
|
-
const toastType =
|
|
43465
|
-
const dismissible =
|
|
43466
|
-
const toastClassname =
|
|
43467
|
-
const toastDescriptionClassname =
|
|
43468
|
-
const heightIndex = React__default.useMemo(() => heights.findIndex((height) => height.toastId ===
|
|
43552
|
+
const toastType = toast2.type;
|
|
43553
|
+
const dismissible = toast2.dismissible !== false;
|
|
43554
|
+
const toastClassname = toast2.className || "";
|
|
43555
|
+
const toastDescriptionClassname = toast2.descriptionClassName || "";
|
|
43556
|
+
const heightIndex = React__default.useMemo(() => heights.findIndex((height) => height.toastId === toast2.id) || 0, [
|
|
43469
43557
|
heights,
|
|
43470
|
-
|
|
43558
|
+
toast2.id
|
|
43471
43559
|
]);
|
|
43472
43560
|
const closeButton = React__default.useMemo(() => {
|
|
43473
43561
|
var _toast_closeButton;
|
|
43474
|
-
return (_toast_closeButton =
|
|
43562
|
+
return (_toast_closeButton = toast2.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
|
|
43475
43563
|
}, [
|
|
43476
|
-
|
|
43564
|
+
toast2.closeButton,
|
|
43477
43565
|
closeButtonFromToaster
|
|
43478
43566
|
]);
|
|
43479
|
-
const duration = React__default.useMemo(() =>
|
|
43480
|
-
|
|
43567
|
+
const duration = React__default.useMemo(() => toast2.duration || durationFromToaster || TOAST_LIFETIME, [
|
|
43568
|
+
toast2.duration,
|
|
43481
43569
|
durationFromToaster
|
|
43482
43570
|
]);
|
|
43483
43571
|
const closeTimerStartTimeRef = React__default.useRef(0);
|
|
@@ -43497,7 +43585,7 @@ const Toast = (props) => {
|
|
|
43497
43585
|
heightIndex
|
|
43498
43586
|
]);
|
|
43499
43587
|
const isDocumentHidden = useIsDocumentHidden();
|
|
43500
|
-
const invert =
|
|
43588
|
+
const invert = toast2.invert || ToasterInvert;
|
|
43501
43589
|
const disabled = toastType === "loading";
|
|
43502
43590
|
offset2.current = React__default.useMemo(() => heightIndex * gap + toastsHeightBefore, [
|
|
43503
43591
|
heightIndex,
|
|
@@ -43518,17 +43606,17 @@ const Toast = (props) => {
|
|
|
43518
43606
|
setInitialHeight(height);
|
|
43519
43607
|
setHeights((h) => [
|
|
43520
43608
|
{
|
|
43521
|
-
toastId:
|
|
43609
|
+
toastId: toast2.id,
|
|
43522
43610
|
height,
|
|
43523
|
-
position:
|
|
43611
|
+
position: toast2.position
|
|
43524
43612
|
},
|
|
43525
43613
|
...h
|
|
43526
43614
|
]);
|
|
43527
|
-
return () => setHeights((h) => h.filter((height2) => height2.toastId !==
|
|
43615
|
+
return () => setHeights((h) => h.filter((height2) => height2.toastId !== toast2.id));
|
|
43528
43616
|
}
|
|
43529
43617
|
}, [
|
|
43530
43618
|
setHeights,
|
|
43531
|
-
|
|
43619
|
+
toast2.id
|
|
43532
43620
|
]);
|
|
43533
43621
|
React__default.useLayoutEffect(() => {
|
|
43534
43622
|
if (!mounted) return;
|
|
@@ -43539,18 +43627,18 @@ const Toast = (props) => {
|
|
|
43539
43627
|
toastNode.style.height = originalHeight;
|
|
43540
43628
|
setInitialHeight(newHeight);
|
|
43541
43629
|
setHeights((heights2) => {
|
|
43542
|
-
const alreadyExists = heights2.find((height) => height.toastId ===
|
|
43630
|
+
const alreadyExists = heights2.find((height) => height.toastId === toast2.id);
|
|
43543
43631
|
if (!alreadyExists) {
|
|
43544
43632
|
return [
|
|
43545
43633
|
{
|
|
43546
|
-
toastId:
|
|
43634
|
+
toastId: toast2.id,
|
|
43547
43635
|
height: newHeight,
|
|
43548
|
-
position:
|
|
43636
|
+
position: toast2.position
|
|
43549
43637
|
},
|
|
43550
43638
|
...heights2
|
|
43551
43639
|
];
|
|
43552
43640
|
} else {
|
|
43553
|
-
return heights2.map((height) => height.toastId ===
|
|
43641
|
+
return heights2.map((height) => height.toastId === toast2.id ? {
|
|
43554
43642
|
...height,
|
|
43555
43643
|
height: newHeight
|
|
43556
43644
|
} : height);
|
|
@@ -43558,29 +43646,29 @@ const Toast = (props) => {
|
|
|
43558
43646
|
});
|
|
43559
43647
|
}, [
|
|
43560
43648
|
mounted,
|
|
43561
|
-
|
|
43562
|
-
|
|
43649
|
+
toast2.title,
|
|
43650
|
+
toast2.description,
|
|
43563
43651
|
setHeights,
|
|
43564
|
-
|
|
43565
|
-
|
|
43566
|
-
|
|
43567
|
-
|
|
43652
|
+
toast2.id,
|
|
43653
|
+
toast2.jsx,
|
|
43654
|
+
toast2.action,
|
|
43655
|
+
toast2.cancel
|
|
43568
43656
|
]);
|
|
43569
43657
|
const deleteToast = React__default.useCallback(() => {
|
|
43570
43658
|
setRemoved(true);
|
|
43571
43659
|
setOffsetBeforeRemove(offset2.current);
|
|
43572
|
-
setHeights((h) => h.filter((height) => height.toastId !==
|
|
43660
|
+
setHeights((h) => h.filter((height) => height.toastId !== toast2.id));
|
|
43573
43661
|
setTimeout(() => {
|
|
43574
|
-
removeToast(
|
|
43662
|
+
removeToast(toast2);
|
|
43575
43663
|
}, TIME_BEFORE_UNMOUNT);
|
|
43576
43664
|
}, [
|
|
43577
|
-
|
|
43665
|
+
toast2,
|
|
43578
43666
|
removeToast,
|
|
43579
43667
|
setHeights,
|
|
43580
43668
|
offset2
|
|
43581
43669
|
]);
|
|
43582
43670
|
React__default.useEffect(() => {
|
|
43583
|
-
if (
|
|
43671
|
+
if (toast2.promise && toastType === "loading" || toast2.duration === Infinity || toast2.type === "loading") return;
|
|
43584
43672
|
let timeoutId;
|
|
43585
43673
|
const pauseTimer = () => {
|
|
43586
43674
|
if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
|
|
@@ -43593,7 +43681,7 @@ const Toast = (props) => {
|
|
|
43593
43681
|
if (remainingTime.current === Infinity) return;
|
|
43594
43682
|
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
43595
43683
|
timeoutId = setTimeout(() => {
|
|
43596
|
-
|
|
43684
|
+
toast2.onAutoClose == null ? void 0 : toast2.onAutoClose.call(toast2, toast2);
|
|
43597
43685
|
deleteToast();
|
|
43598
43686
|
}, remainingTime.current);
|
|
43599
43687
|
};
|
|
@@ -43606,45 +43694,45 @@ const Toast = (props) => {
|
|
|
43606
43694
|
}, [
|
|
43607
43695
|
expanded,
|
|
43608
43696
|
interacting,
|
|
43609
|
-
|
|
43697
|
+
toast2,
|
|
43610
43698
|
toastType,
|
|
43611
43699
|
isDocumentHidden,
|
|
43612
43700
|
deleteToast
|
|
43613
43701
|
]);
|
|
43614
43702
|
React__default.useEffect(() => {
|
|
43615
|
-
if (
|
|
43703
|
+
if (toast2.delete) {
|
|
43616
43704
|
deleteToast();
|
|
43617
|
-
|
|
43705
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
43618
43706
|
}
|
|
43619
43707
|
}, [
|
|
43620
43708
|
deleteToast,
|
|
43621
|
-
|
|
43709
|
+
toast2.delete
|
|
43622
43710
|
]);
|
|
43623
43711
|
function getLoadingIcon() {
|
|
43624
43712
|
var _toast_classNames9;
|
|
43625
43713
|
if (icons == null ? void 0 : icons.loading) {
|
|
43626
43714
|
var _toast_classNames12;
|
|
43627
43715
|
return /* @__PURE__ */ React__default.createElement("div", {
|
|
43628
|
-
className: cn(classNames == null ? void 0 : classNames.loader,
|
|
43716
|
+
className: cn(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames12 = toast2.classNames) == null ? void 0 : _toast_classNames12.loader, "sonner-loader"),
|
|
43629
43717
|
"data-visible": toastType === "loading"
|
|
43630
43718
|
}, icons.loading);
|
|
43631
43719
|
}
|
|
43632
43720
|
return /* @__PURE__ */ React__default.createElement(Loader, {
|
|
43633
|
-
className: cn(classNames == null ? void 0 : classNames.loader,
|
|
43721
|
+
className: cn(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames9 = toast2.classNames) == null ? void 0 : _toast_classNames9.loader),
|
|
43634
43722
|
visible: toastType === "loading"
|
|
43635
43723
|
});
|
|
43636
43724
|
}
|
|
43637
|
-
const icon =
|
|
43725
|
+
const icon = toast2.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
|
|
43638
43726
|
var _toast_richColors, _icons_close;
|
|
43639
43727
|
return /* @__PURE__ */ React__default.createElement("li", {
|
|
43640
43728
|
tabIndex: 0,
|
|
43641
43729
|
ref: toastRef,
|
|
43642
|
-
className: cn(className, toastClassname, classNames == null ? void 0 : classNames.toast,
|
|
43730
|
+
className: cn(className, toastClassname, classNames == null ? void 0 : classNames.toast, toast2 == null ? void 0 : (_toast_classNames = toast2.classNames) == null ? void 0 : _toast_classNames.toast, classNames == null ? void 0 : classNames.default, classNames == null ? void 0 : classNames[toastType], toast2 == null ? void 0 : (_toast_classNames1 = toast2.classNames) == null ? void 0 : _toast_classNames1[toastType]),
|
|
43643
43731
|
"data-sonner-toast": "",
|
|
43644
|
-
"data-rich-colors": (_toast_richColors =
|
|
43645
|
-
"data-styled": !Boolean(
|
|
43732
|
+
"data-rich-colors": (_toast_richColors = toast2.richColors) != null ? _toast_richColors : defaultRichColors,
|
|
43733
|
+
"data-styled": !Boolean(toast2.jsx || toast2.unstyled || unstyled),
|
|
43646
43734
|
"data-mounted": mounted,
|
|
43647
|
-
"data-promise": Boolean(
|
|
43735
|
+
"data-promise": Boolean(toast2.promise),
|
|
43648
43736
|
"data-swiped": isSwiped,
|
|
43649
43737
|
"data-removed": removed,
|
|
43650
43738
|
"data-visible": isVisible,
|
|
@@ -43659,7 +43747,7 @@ const Toast = (props) => {
|
|
|
43659
43747
|
"data-swipe-out": swipeOut,
|
|
43660
43748
|
"data-swipe-direction": swipeOutDirection,
|
|
43661
43749
|
"data-expanded": Boolean(expanded || expandByDefault && mounted),
|
|
43662
|
-
"data-testid":
|
|
43750
|
+
"data-testid": toast2.testId,
|
|
43663
43751
|
style: {
|
|
43664
43752
|
"--index": index2,
|
|
43665
43753
|
"--toasts-before": index2,
|
|
@@ -43667,7 +43755,7 @@ const Toast = (props) => {
|
|
|
43667
43755
|
"--offset": `${removed ? offsetBeforeRemove : offset2.current}px`,
|
|
43668
43756
|
"--initial-height": expandByDefault ? "auto" : `${initialHeight}px`,
|
|
43669
43757
|
...style,
|
|
43670
|
-
...
|
|
43758
|
+
...toast2.style
|
|
43671
43759
|
},
|
|
43672
43760
|
onDragEnd: () => {
|
|
43673
43761
|
setSwiping(false);
|
|
@@ -43698,7 +43786,7 @@ const Toast = (props) => {
|
|
|
43698
43786
|
const velocity = Math.abs(swipeAmount) / timeTaken;
|
|
43699
43787
|
if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
|
|
43700
43788
|
setOffsetBeforeRemove(offset2.current);
|
|
43701
|
-
|
|
43789
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
43702
43790
|
if (swipeDirection === "x") {
|
|
43703
43791
|
setSwipeOutDirection(swipeAmountX > 0 ? "right" : "left");
|
|
43704
43792
|
} else {
|
|
@@ -43761,51 +43849,51 @@ const Toast = (props) => {
|
|
|
43761
43849
|
(_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
|
|
43762
43850
|
(_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
|
|
43763
43851
|
}
|
|
43764
|
-
}, closeButton && !
|
|
43852
|
+
}, closeButton && !toast2.jsx && toastType !== "loading" ? /* @__PURE__ */ React__default.createElement("button", {
|
|
43765
43853
|
"aria-label": closeButtonAriaLabel,
|
|
43766
43854
|
"data-disabled": disabled,
|
|
43767
43855
|
"data-close-button": true,
|
|
43768
43856
|
onClick: disabled || !dismissible ? () => {
|
|
43769
43857
|
} : () => {
|
|
43770
43858
|
deleteToast();
|
|
43771
|
-
|
|
43859
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
43772
43860
|
},
|
|
43773
|
-
className: cn(classNames == null ? void 0 : classNames.closeButton,
|
|
43774
|
-
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType ||
|
|
43861
|
+
className: cn(classNames == null ? void 0 : classNames.closeButton, toast2 == null ? void 0 : (_toast_classNames2 = toast2.classNames) == null ? void 0 : _toast_classNames2.closeButton)
|
|
43862
|
+
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast2.icon || toast2.promise) && toast2.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast2.icon) ? /* @__PURE__ */ React__default.createElement("div", {
|
|
43775
43863
|
"data-icon": "",
|
|
43776
|
-
className: cn(classNames == null ? void 0 : classNames.icon,
|
|
43777
|
-
},
|
|
43864
|
+
className: cn(classNames == null ? void 0 : classNames.icon, toast2 == null ? void 0 : (_toast_classNames3 = toast2.classNames) == null ? void 0 : _toast_classNames3.icon)
|
|
43865
|
+
}, toast2.promise || toast2.type === "loading" && !toast2.icon ? toast2.icon || getLoadingIcon() : null, toast2.type !== "loading" ? icon : null) : null, /* @__PURE__ */ React__default.createElement("div", {
|
|
43778
43866
|
"data-content": "",
|
|
43779
|
-
className: cn(classNames == null ? void 0 : classNames.content,
|
|
43867
|
+
className: cn(classNames == null ? void 0 : classNames.content, toast2 == null ? void 0 : (_toast_classNames4 = toast2.classNames) == null ? void 0 : _toast_classNames4.content)
|
|
43780
43868
|
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
43781
43869
|
"data-title": "",
|
|
43782
|
-
className: cn(classNames == null ? void 0 : classNames.title,
|
|
43783
|
-
},
|
|
43870
|
+
className: cn(classNames == null ? void 0 : classNames.title, toast2 == null ? void 0 : (_toast_classNames5 = toast2.classNames) == null ? void 0 : _toast_classNames5.title)
|
|
43871
|
+
}, toast2.jsx ? toast2.jsx : typeof toast2.title === "function" ? toast2.title() : toast2.title), toast2.description ? /* @__PURE__ */ React__default.createElement("div", {
|
|
43784
43872
|
"data-description": "",
|
|
43785
|
-
className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description,
|
|
43786
|
-
}, typeof
|
|
43873
|
+
className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description, toast2 == null ? void 0 : (_toast_classNames6 = toast2.classNames) == null ? void 0 : _toast_classNames6.description)
|
|
43874
|
+
}, typeof toast2.description === "function" ? toast2.description() : toast2.description) : null), /* @__PURE__ */ React__default.isValidElement(toast2.cancel) ? toast2.cancel : toast2.cancel && isAction(toast2.cancel) ? /* @__PURE__ */ React__default.createElement("button", {
|
|
43787
43875
|
"data-button": true,
|
|
43788
43876
|
"data-cancel": true,
|
|
43789
|
-
style:
|
|
43877
|
+
style: toast2.cancelButtonStyle || cancelButtonStyle,
|
|
43790
43878
|
onClick: (event) => {
|
|
43791
|
-
if (!isAction(
|
|
43879
|
+
if (!isAction(toast2.cancel)) return;
|
|
43792
43880
|
if (!dismissible) return;
|
|
43793
|
-
|
|
43881
|
+
toast2.cancel.onClick == null ? void 0 : toast2.cancel.onClick.call(toast2.cancel, event);
|
|
43794
43882
|
deleteToast();
|
|
43795
43883
|
},
|
|
43796
|
-
className: cn(classNames == null ? void 0 : classNames.cancelButton,
|
|
43797
|
-
},
|
|
43884
|
+
className: cn(classNames == null ? void 0 : classNames.cancelButton, toast2 == null ? void 0 : (_toast_classNames7 = toast2.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
|
|
43885
|
+
}, toast2.cancel.label) : null, /* @__PURE__ */ React__default.isValidElement(toast2.action) ? toast2.action : toast2.action && isAction(toast2.action) ? /* @__PURE__ */ React__default.createElement("button", {
|
|
43798
43886
|
"data-button": true,
|
|
43799
43887
|
"data-action": true,
|
|
43800
|
-
style:
|
|
43888
|
+
style: toast2.actionButtonStyle || actionButtonStyle,
|
|
43801
43889
|
onClick: (event) => {
|
|
43802
|
-
if (!isAction(
|
|
43803
|
-
|
|
43890
|
+
if (!isAction(toast2.action)) return;
|
|
43891
|
+
toast2.action.onClick == null ? void 0 : toast2.action.onClick.call(toast2.action, event);
|
|
43804
43892
|
if (event.defaultPrevented) return;
|
|
43805
43893
|
deleteToast();
|
|
43806
43894
|
},
|
|
43807
|
-
className: cn(classNames == null ? void 0 : classNames.actionButton,
|
|
43808
|
-
},
|
|
43895
|
+
className: cn(classNames == null ? void 0 : classNames.actionButton, toast2 == null ? void 0 : (_toast_classNames8 = toast2.classNames) == null ? void 0 : _toast_classNames8.actionButton)
|
|
43896
|
+
}, toast2.action.label) : null);
|
|
43809
43897
|
};
|
|
43810
43898
|
function getDocumentDirection() {
|
|
43811
43899
|
if (typeof window === "undefined") return "ltr";
|
|
@@ -43864,9 +43952,9 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
43864
43952
|
const [toasts, setToasts] = React__default.useState([]);
|
|
43865
43953
|
const filteredToasts = React__default.useMemo(() => {
|
|
43866
43954
|
if (id) {
|
|
43867
|
-
return toasts.filter((
|
|
43955
|
+
return toasts.filter((toast2) => toast2.toasterId === id);
|
|
43868
43956
|
}
|
|
43869
|
-
return toasts.filter((
|
|
43957
|
+
return toasts.filter((toast2) => !toast2.toasterId);
|
|
43870
43958
|
}, [
|
|
43871
43959
|
toasts,
|
|
43872
43960
|
id
|
|
@@ -43874,7 +43962,7 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
43874
43962
|
const possiblePositions = React__default.useMemo(() => {
|
|
43875
43963
|
return Array.from(new Set([
|
|
43876
43964
|
position
|
|
43877
|
-
].concat(filteredToasts.filter((
|
|
43965
|
+
].concat(filteredToasts.filter((toast2) => toast2.position).map((toast2) => toast2.position))));
|
|
43878
43966
|
}, [
|
|
43879
43967
|
filteredToasts,
|
|
43880
43968
|
position
|
|
@@ -43890,17 +43978,17 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
43890
43978
|
const removeToast = React__default.useCallback((toastToRemove) => {
|
|
43891
43979
|
setToasts((toasts2) => {
|
|
43892
43980
|
var _toasts_find;
|
|
43893
|
-
if (!((_toasts_find = toasts2.find((
|
|
43981
|
+
if (!((_toasts_find = toasts2.find((toast2) => toast2.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) {
|
|
43894
43982
|
ToastState.dismiss(toastToRemove.id);
|
|
43895
43983
|
}
|
|
43896
43984
|
return toasts2.filter(({ id: id2 }) => id2 !== toastToRemove.id);
|
|
43897
43985
|
});
|
|
43898
43986
|
}, []);
|
|
43899
43987
|
React__default.useEffect(() => {
|
|
43900
|
-
return ToastState.subscribe((
|
|
43901
|
-
if (
|
|
43988
|
+
return ToastState.subscribe((toast2) => {
|
|
43989
|
+
if (toast2.dismiss) {
|
|
43902
43990
|
requestAnimationFrame(() => {
|
|
43903
|
-
setToasts((toasts2) => toasts2.map((t) => t.id ===
|
|
43991
|
+
setToasts((toasts2) => toasts2.map((t) => t.id === toast2.id ? {
|
|
43904
43992
|
...t,
|
|
43905
43993
|
delete: true
|
|
43906
43994
|
} : t));
|
|
@@ -43910,19 +43998,19 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
43910
43998
|
setTimeout(() => {
|
|
43911
43999
|
ReactDOM__default.flushSync(() => {
|
|
43912
44000
|
setToasts((toasts2) => {
|
|
43913
|
-
const indexOfExistingToast = toasts2.findIndex((t) => t.id ===
|
|
44001
|
+
const indexOfExistingToast = toasts2.findIndex((t) => t.id === toast2.id);
|
|
43914
44002
|
if (indexOfExistingToast !== -1) {
|
|
43915
44003
|
return [
|
|
43916
44004
|
...toasts2.slice(0, indexOfExistingToast),
|
|
43917
44005
|
{
|
|
43918
44006
|
...toasts2[indexOfExistingToast],
|
|
43919
|
-
...
|
|
44007
|
+
...toast2
|
|
43920
44008
|
},
|
|
43921
44009
|
...toasts2.slice(indexOfExistingToast + 1)
|
|
43922
44010
|
];
|
|
43923
44011
|
}
|
|
43924
44012
|
return [
|
|
43925
|
-
|
|
44013
|
+
toast2,
|
|
43926
44014
|
...toasts2
|
|
43927
44015
|
];
|
|
43928
44016
|
});
|
|
@@ -44074,13 +44162,13 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
44074
44162
|
setInteracting(true);
|
|
44075
44163
|
},
|
|
44076
44164
|
onPointerUp: () => setInteracting(false)
|
|
44077
|
-
}, filteredToasts.filter((
|
|
44165
|
+
}, filteredToasts.filter((toast2) => !toast2.position && index2 === 0 || toast2.position === position2).map((toast2, index3) => {
|
|
44078
44166
|
var _toastOptions_duration, _toastOptions_closeButton;
|
|
44079
44167
|
return /* @__PURE__ */ React__default.createElement(Toast, {
|
|
44080
|
-
key:
|
|
44168
|
+
key: toast2.id,
|
|
44081
44169
|
icons,
|
|
44082
44170
|
index: index3,
|
|
44083
|
-
toast,
|
|
44171
|
+
toast: toast2,
|
|
44084
44172
|
defaultRichColors: richColors,
|
|
44085
44173
|
duration: (_toastOptions_duration = toastOptions == null ? void 0 : toastOptions.duration) != null ? _toastOptions_duration : duration,
|
|
44086
44174
|
className: toastOptions == null ? void 0 : toastOptions.className,
|
|
@@ -44097,8 +44185,8 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
44097
44185
|
actionButtonStyle: toastOptions == null ? void 0 : toastOptions.actionButtonStyle,
|
|
44098
44186
|
closeButtonAriaLabel: toastOptions == null ? void 0 : toastOptions.closeButtonAriaLabel,
|
|
44099
44187
|
removeToast,
|
|
44100
|
-
toasts: filteredToasts.filter((t) => t.position ==
|
|
44101
|
-
heights: heights.filter((h) => h.position ==
|
|
44188
|
+
toasts: filteredToasts.filter((t) => t.position == toast2.position),
|
|
44189
|
+
heights: heights.filter((h) => h.position == toast2.position),
|
|
44102
44190
|
setHeights,
|
|
44103
44191
|
expandByDefault: expand,
|
|
44104
44192
|
gap,
|
|
@@ -44134,13 +44222,9 @@ const Toaster$1 = ({ ...props }) => {
|
|
|
44134
44222
|
);
|
|
44135
44223
|
};
|
|
44136
44224
|
const Toaster2 = ({ ...props }) => {
|
|
44137
|
-
const { theme = "system" } = z();
|
|
44138
44225
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
44139
44226
|
Toaster$1,
|
|
44140
44227
|
{
|
|
44141
|
-
theme,
|
|
44142
|
-
className: "toaster group",
|
|
44143
|
-
icons: void 0,
|
|
44144
44228
|
style: {
|
|
44145
44229
|
"--normal-bg": "var(--popover)",
|
|
44146
44230
|
"--normal-text": "var(--popover-foreground)",
|
|
@@ -45722,6 +45806,7 @@ export {
|
|
|
45722
45806
|
SelectValue,
|
|
45723
45807
|
Separator,
|
|
45724
45808
|
Sheet,
|
|
45809
|
+
SheetBanner,
|
|
45725
45810
|
SheetClose,
|
|
45726
45811
|
SheetCloseButton,
|
|
45727
45812
|
SheetContent,
|
|
@@ -45778,11 +45863,13 @@ export {
|
|
|
45778
45863
|
isDarkModeActive,
|
|
45779
45864
|
resolveColumnOrder,
|
|
45780
45865
|
resolveColumnVisibility,
|
|
45866
|
+
toast,
|
|
45781
45867
|
toggleCarbideTheme,
|
|
45782
45868
|
toggleDarkMode,
|
|
45783
45869
|
useBreakpoint,
|
|
45784
45870
|
useDataTableState,
|
|
45785
45871
|
useFormField,
|
|
45786
|
-
useTableController
|
|
45872
|
+
useTableController,
|
|
45873
|
+
useTabsValue
|
|
45787
45874
|
};
|
|
45788
45875
|
//# sourceMappingURL=mm-react-components.es.js.map
|