@machinemetrics/mm-react-components 0.2.3-28 → 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/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 +2 -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 +141 -99
- 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/TabsPreview.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -11274,16 +11274,60 @@ var Root2$4 = Tabs$1;
|
|
|
11274
11274
|
var List = TabsList$1;
|
|
11275
11275
|
var Trigger$3 = TabsTrigger$1;
|
|
11276
11276
|
var Content$2 = TabsContent$1;
|
|
11277
|
+
const TabsContext = React__default.createContext(void 0);
|
|
11278
|
+
function useTabsValue() {
|
|
11279
|
+
return React__default.useContext(TabsContext);
|
|
11280
|
+
}
|
|
11277
11281
|
function Tabs({
|
|
11278
11282
|
className,
|
|
11283
|
+
sharedContent,
|
|
11284
|
+
value: controlledValue,
|
|
11285
|
+
defaultValue: defaultValue2,
|
|
11286
|
+
onValueChange,
|
|
11287
|
+
children,
|
|
11279
11288
|
...props
|
|
11280
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
|
+
}
|
|
11281
11321
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11282
11322
|
Root2$4,
|
|
11283
11323
|
{
|
|
11284
11324
|
"data-slot": "tabs",
|
|
11285
11325
|
className: cn$1("flex flex-col gap-2", className),
|
|
11286
|
-
|
|
11326
|
+
value: controlledValue,
|
|
11327
|
+
defaultValue: defaultValue2,
|
|
11328
|
+
onValueChange,
|
|
11329
|
+
...props,
|
|
11330
|
+
children
|
|
11287
11331
|
}
|
|
11288
11332
|
);
|
|
11289
11333
|
}
|
|
@@ -43210,31 +43254,31 @@ class Observer {
|
|
|
43210
43254
|
var _data_id;
|
|
43211
43255
|
const { message: message2, ...rest } = data;
|
|
43212
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++;
|
|
43213
|
-
const alreadyExists = this.toasts.find((
|
|
43214
|
-
return
|
|
43257
|
+
const alreadyExists = this.toasts.find((toast2) => {
|
|
43258
|
+
return toast2.id === id;
|
|
43215
43259
|
});
|
|
43216
43260
|
const dismissible = data.dismissible === void 0 ? true : data.dismissible;
|
|
43217
43261
|
if (this.dismissedToasts.has(id)) {
|
|
43218
43262
|
this.dismissedToasts.delete(id);
|
|
43219
43263
|
}
|
|
43220
43264
|
if (alreadyExists) {
|
|
43221
|
-
this.toasts = this.toasts.map((
|
|
43222
|
-
if (
|
|
43265
|
+
this.toasts = this.toasts.map((toast2) => {
|
|
43266
|
+
if (toast2.id === id) {
|
|
43223
43267
|
this.publish({
|
|
43224
|
-
...
|
|
43268
|
+
...toast2,
|
|
43225
43269
|
...data,
|
|
43226
43270
|
id,
|
|
43227
43271
|
title: message2
|
|
43228
43272
|
});
|
|
43229
43273
|
return {
|
|
43230
|
-
...
|
|
43274
|
+
...toast2,
|
|
43231
43275
|
...data,
|
|
43232
43276
|
id,
|
|
43233
43277
|
dismissible,
|
|
43234
43278
|
title: message2
|
|
43235
43279
|
};
|
|
43236
43280
|
}
|
|
43237
|
-
return
|
|
43281
|
+
return toast2;
|
|
43238
43282
|
});
|
|
43239
43283
|
} else {
|
|
43240
43284
|
this.addToast({
|
|
@@ -43254,9 +43298,9 @@ class Observer {
|
|
|
43254
43298
|
dismiss: true
|
|
43255
43299
|
})));
|
|
43256
43300
|
} else {
|
|
43257
|
-
this.toasts.forEach((
|
|
43301
|
+
this.toasts.forEach((toast2) => {
|
|
43258
43302
|
this.subscribers.forEach((subscriber) => subscriber({
|
|
43259
|
-
id:
|
|
43303
|
+
id: toast2.id,
|
|
43260
43304
|
dismiss: true
|
|
43261
43305
|
}));
|
|
43262
43306
|
});
|
|
@@ -43425,7 +43469,7 @@ class Observer {
|
|
|
43425
43469
|
return id;
|
|
43426
43470
|
};
|
|
43427
43471
|
this.getActiveToasts = () => {
|
|
43428
|
-
return this.toasts.filter((
|
|
43472
|
+
return this.toasts.filter((toast2) => !this.dismissedToasts.has(toast2.id));
|
|
43429
43473
|
};
|
|
43430
43474
|
this.subscribers = [];
|
|
43431
43475
|
this.toasts = [];
|
|
@@ -43448,7 +43492,7 @@ const isHttpResponse = (data) => {
|
|
|
43448
43492
|
const basicToast = toastFunction;
|
|
43449
43493
|
const getHistory = () => ToastState.toasts;
|
|
43450
43494
|
const getToasts = () => ToastState.getActiveToasts();
|
|
43451
|
-
Object.assign(basicToast, {
|
|
43495
|
+
const toast = Object.assign(basicToast, {
|
|
43452
43496
|
success: ToastState.success,
|
|
43453
43497
|
info: ToastState.info,
|
|
43454
43498
|
warning: ToastState.warning,
|
|
@@ -43490,7 +43534,7 @@ function getDefaultSwipeDirections(position) {
|
|
|
43490
43534
|
}
|
|
43491
43535
|
const Toast = (props) => {
|
|
43492
43536
|
var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
|
|
43493
|
-
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;
|
|
43494
43538
|
const [swipeDirection, setSwipeDirection] = React__default.useState(null);
|
|
43495
43539
|
const [swipeOutDirection, setSwipeOutDirection] = React__default.useState(null);
|
|
43496
43540
|
const [mounted, setMounted] = React__default.useState(false);
|
|
@@ -43500,28 +43544,28 @@ const Toast = (props) => {
|
|
|
43500
43544
|
const [isSwiped, setIsSwiped] = React__default.useState(false);
|
|
43501
43545
|
const [offsetBeforeRemove, setOffsetBeforeRemove] = React__default.useState(0);
|
|
43502
43546
|
const [initialHeight, setInitialHeight] = React__default.useState(0);
|
|
43503
|
-
const remainingTime = React__default.useRef(
|
|
43547
|
+
const remainingTime = React__default.useRef(toast2.duration || durationFromToaster || TOAST_LIFETIME);
|
|
43504
43548
|
const dragStartTime = React__default.useRef(null);
|
|
43505
43549
|
const toastRef = React__default.useRef(null);
|
|
43506
43550
|
const isFront = index2 === 0;
|
|
43507
43551
|
const isVisible = index2 + 1 <= visibleToasts;
|
|
43508
|
-
const toastType =
|
|
43509
|
-
const dismissible =
|
|
43510
|
-
const toastClassname =
|
|
43511
|
-
const toastDescriptionClassname =
|
|
43512
|
-
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, [
|
|
43513
43557
|
heights,
|
|
43514
|
-
|
|
43558
|
+
toast2.id
|
|
43515
43559
|
]);
|
|
43516
43560
|
const closeButton = React__default.useMemo(() => {
|
|
43517
43561
|
var _toast_closeButton;
|
|
43518
|
-
return (_toast_closeButton =
|
|
43562
|
+
return (_toast_closeButton = toast2.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
|
|
43519
43563
|
}, [
|
|
43520
|
-
|
|
43564
|
+
toast2.closeButton,
|
|
43521
43565
|
closeButtonFromToaster
|
|
43522
43566
|
]);
|
|
43523
|
-
const duration = React__default.useMemo(() =>
|
|
43524
|
-
|
|
43567
|
+
const duration = React__default.useMemo(() => toast2.duration || durationFromToaster || TOAST_LIFETIME, [
|
|
43568
|
+
toast2.duration,
|
|
43525
43569
|
durationFromToaster
|
|
43526
43570
|
]);
|
|
43527
43571
|
const closeTimerStartTimeRef = React__default.useRef(0);
|
|
@@ -43541,7 +43585,7 @@ const Toast = (props) => {
|
|
|
43541
43585
|
heightIndex
|
|
43542
43586
|
]);
|
|
43543
43587
|
const isDocumentHidden = useIsDocumentHidden();
|
|
43544
|
-
const invert =
|
|
43588
|
+
const invert = toast2.invert || ToasterInvert;
|
|
43545
43589
|
const disabled = toastType === "loading";
|
|
43546
43590
|
offset2.current = React__default.useMemo(() => heightIndex * gap + toastsHeightBefore, [
|
|
43547
43591
|
heightIndex,
|
|
@@ -43562,17 +43606,17 @@ const Toast = (props) => {
|
|
|
43562
43606
|
setInitialHeight(height);
|
|
43563
43607
|
setHeights((h) => [
|
|
43564
43608
|
{
|
|
43565
|
-
toastId:
|
|
43609
|
+
toastId: toast2.id,
|
|
43566
43610
|
height,
|
|
43567
|
-
position:
|
|
43611
|
+
position: toast2.position
|
|
43568
43612
|
},
|
|
43569
43613
|
...h
|
|
43570
43614
|
]);
|
|
43571
|
-
return () => setHeights((h) => h.filter((height2) => height2.toastId !==
|
|
43615
|
+
return () => setHeights((h) => h.filter((height2) => height2.toastId !== toast2.id));
|
|
43572
43616
|
}
|
|
43573
43617
|
}, [
|
|
43574
43618
|
setHeights,
|
|
43575
|
-
|
|
43619
|
+
toast2.id
|
|
43576
43620
|
]);
|
|
43577
43621
|
React__default.useLayoutEffect(() => {
|
|
43578
43622
|
if (!mounted) return;
|
|
@@ -43583,18 +43627,18 @@ const Toast = (props) => {
|
|
|
43583
43627
|
toastNode.style.height = originalHeight;
|
|
43584
43628
|
setInitialHeight(newHeight);
|
|
43585
43629
|
setHeights((heights2) => {
|
|
43586
|
-
const alreadyExists = heights2.find((height) => height.toastId ===
|
|
43630
|
+
const alreadyExists = heights2.find((height) => height.toastId === toast2.id);
|
|
43587
43631
|
if (!alreadyExists) {
|
|
43588
43632
|
return [
|
|
43589
43633
|
{
|
|
43590
|
-
toastId:
|
|
43634
|
+
toastId: toast2.id,
|
|
43591
43635
|
height: newHeight,
|
|
43592
|
-
position:
|
|
43636
|
+
position: toast2.position
|
|
43593
43637
|
},
|
|
43594
43638
|
...heights2
|
|
43595
43639
|
];
|
|
43596
43640
|
} else {
|
|
43597
|
-
return heights2.map((height) => height.toastId ===
|
|
43641
|
+
return heights2.map((height) => height.toastId === toast2.id ? {
|
|
43598
43642
|
...height,
|
|
43599
43643
|
height: newHeight
|
|
43600
43644
|
} : height);
|
|
@@ -43602,29 +43646,29 @@ const Toast = (props) => {
|
|
|
43602
43646
|
});
|
|
43603
43647
|
}, [
|
|
43604
43648
|
mounted,
|
|
43605
|
-
|
|
43606
|
-
|
|
43649
|
+
toast2.title,
|
|
43650
|
+
toast2.description,
|
|
43607
43651
|
setHeights,
|
|
43608
|
-
|
|
43609
|
-
|
|
43610
|
-
|
|
43611
|
-
|
|
43652
|
+
toast2.id,
|
|
43653
|
+
toast2.jsx,
|
|
43654
|
+
toast2.action,
|
|
43655
|
+
toast2.cancel
|
|
43612
43656
|
]);
|
|
43613
43657
|
const deleteToast = React__default.useCallback(() => {
|
|
43614
43658
|
setRemoved(true);
|
|
43615
43659
|
setOffsetBeforeRemove(offset2.current);
|
|
43616
|
-
setHeights((h) => h.filter((height) => height.toastId !==
|
|
43660
|
+
setHeights((h) => h.filter((height) => height.toastId !== toast2.id));
|
|
43617
43661
|
setTimeout(() => {
|
|
43618
|
-
removeToast(
|
|
43662
|
+
removeToast(toast2);
|
|
43619
43663
|
}, TIME_BEFORE_UNMOUNT);
|
|
43620
43664
|
}, [
|
|
43621
|
-
|
|
43665
|
+
toast2,
|
|
43622
43666
|
removeToast,
|
|
43623
43667
|
setHeights,
|
|
43624
43668
|
offset2
|
|
43625
43669
|
]);
|
|
43626
43670
|
React__default.useEffect(() => {
|
|
43627
|
-
if (
|
|
43671
|
+
if (toast2.promise && toastType === "loading" || toast2.duration === Infinity || toast2.type === "loading") return;
|
|
43628
43672
|
let timeoutId;
|
|
43629
43673
|
const pauseTimer = () => {
|
|
43630
43674
|
if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
|
|
@@ -43637,7 +43681,7 @@ const Toast = (props) => {
|
|
|
43637
43681
|
if (remainingTime.current === Infinity) return;
|
|
43638
43682
|
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
43639
43683
|
timeoutId = setTimeout(() => {
|
|
43640
|
-
|
|
43684
|
+
toast2.onAutoClose == null ? void 0 : toast2.onAutoClose.call(toast2, toast2);
|
|
43641
43685
|
deleteToast();
|
|
43642
43686
|
}, remainingTime.current);
|
|
43643
43687
|
};
|
|
@@ -43650,45 +43694,45 @@ const Toast = (props) => {
|
|
|
43650
43694
|
}, [
|
|
43651
43695
|
expanded,
|
|
43652
43696
|
interacting,
|
|
43653
|
-
|
|
43697
|
+
toast2,
|
|
43654
43698
|
toastType,
|
|
43655
43699
|
isDocumentHidden,
|
|
43656
43700
|
deleteToast
|
|
43657
43701
|
]);
|
|
43658
43702
|
React__default.useEffect(() => {
|
|
43659
|
-
if (
|
|
43703
|
+
if (toast2.delete) {
|
|
43660
43704
|
deleteToast();
|
|
43661
|
-
|
|
43705
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
43662
43706
|
}
|
|
43663
43707
|
}, [
|
|
43664
43708
|
deleteToast,
|
|
43665
|
-
|
|
43709
|
+
toast2.delete
|
|
43666
43710
|
]);
|
|
43667
43711
|
function getLoadingIcon() {
|
|
43668
43712
|
var _toast_classNames9;
|
|
43669
43713
|
if (icons == null ? void 0 : icons.loading) {
|
|
43670
43714
|
var _toast_classNames12;
|
|
43671
43715
|
return /* @__PURE__ */ React__default.createElement("div", {
|
|
43672
|
-
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"),
|
|
43673
43717
|
"data-visible": toastType === "loading"
|
|
43674
43718
|
}, icons.loading);
|
|
43675
43719
|
}
|
|
43676
43720
|
return /* @__PURE__ */ React__default.createElement(Loader, {
|
|
43677
|
-
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),
|
|
43678
43722
|
visible: toastType === "loading"
|
|
43679
43723
|
});
|
|
43680
43724
|
}
|
|
43681
|
-
const icon =
|
|
43725
|
+
const icon = toast2.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
|
|
43682
43726
|
var _toast_richColors, _icons_close;
|
|
43683
43727
|
return /* @__PURE__ */ React__default.createElement("li", {
|
|
43684
43728
|
tabIndex: 0,
|
|
43685
43729
|
ref: toastRef,
|
|
43686
|
-
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]),
|
|
43687
43731
|
"data-sonner-toast": "",
|
|
43688
|
-
"data-rich-colors": (_toast_richColors =
|
|
43689
|
-
"data-styled": !Boolean(
|
|
43732
|
+
"data-rich-colors": (_toast_richColors = toast2.richColors) != null ? _toast_richColors : defaultRichColors,
|
|
43733
|
+
"data-styled": !Boolean(toast2.jsx || toast2.unstyled || unstyled),
|
|
43690
43734
|
"data-mounted": mounted,
|
|
43691
|
-
"data-promise": Boolean(
|
|
43735
|
+
"data-promise": Boolean(toast2.promise),
|
|
43692
43736
|
"data-swiped": isSwiped,
|
|
43693
43737
|
"data-removed": removed,
|
|
43694
43738
|
"data-visible": isVisible,
|
|
@@ -43703,7 +43747,7 @@ const Toast = (props) => {
|
|
|
43703
43747
|
"data-swipe-out": swipeOut,
|
|
43704
43748
|
"data-swipe-direction": swipeOutDirection,
|
|
43705
43749
|
"data-expanded": Boolean(expanded || expandByDefault && mounted),
|
|
43706
|
-
"data-testid":
|
|
43750
|
+
"data-testid": toast2.testId,
|
|
43707
43751
|
style: {
|
|
43708
43752
|
"--index": index2,
|
|
43709
43753
|
"--toasts-before": index2,
|
|
@@ -43711,7 +43755,7 @@ const Toast = (props) => {
|
|
|
43711
43755
|
"--offset": `${removed ? offsetBeforeRemove : offset2.current}px`,
|
|
43712
43756
|
"--initial-height": expandByDefault ? "auto" : `${initialHeight}px`,
|
|
43713
43757
|
...style,
|
|
43714
|
-
...
|
|
43758
|
+
...toast2.style
|
|
43715
43759
|
},
|
|
43716
43760
|
onDragEnd: () => {
|
|
43717
43761
|
setSwiping(false);
|
|
@@ -43742,7 +43786,7 @@ const Toast = (props) => {
|
|
|
43742
43786
|
const velocity = Math.abs(swipeAmount) / timeTaken;
|
|
43743
43787
|
if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
|
|
43744
43788
|
setOffsetBeforeRemove(offset2.current);
|
|
43745
|
-
|
|
43789
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
43746
43790
|
if (swipeDirection === "x") {
|
|
43747
43791
|
setSwipeOutDirection(swipeAmountX > 0 ? "right" : "left");
|
|
43748
43792
|
} else {
|
|
@@ -43805,51 +43849,51 @@ const Toast = (props) => {
|
|
|
43805
43849
|
(_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
|
|
43806
43850
|
(_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
|
|
43807
43851
|
}
|
|
43808
|
-
}, closeButton && !
|
|
43852
|
+
}, closeButton && !toast2.jsx && toastType !== "loading" ? /* @__PURE__ */ React__default.createElement("button", {
|
|
43809
43853
|
"aria-label": closeButtonAriaLabel,
|
|
43810
43854
|
"data-disabled": disabled,
|
|
43811
43855
|
"data-close-button": true,
|
|
43812
43856
|
onClick: disabled || !dismissible ? () => {
|
|
43813
43857
|
} : () => {
|
|
43814
43858
|
deleteToast();
|
|
43815
|
-
|
|
43859
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
43816
43860
|
},
|
|
43817
|
-
className: cn(classNames == null ? void 0 : classNames.closeButton,
|
|
43818
|
-
}, (_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", {
|
|
43819
43863
|
"data-icon": "",
|
|
43820
|
-
className: cn(classNames == null ? void 0 : classNames.icon,
|
|
43821
|
-
},
|
|
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", {
|
|
43822
43866
|
"data-content": "",
|
|
43823
|
-
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)
|
|
43824
43868
|
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
43825
43869
|
"data-title": "",
|
|
43826
|
-
className: cn(classNames == null ? void 0 : classNames.title,
|
|
43827
|
-
},
|
|
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", {
|
|
43828
43872
|
"data-description": "",
|
|
43829
|
-
className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description,
|
|
43830
|
-
}, 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", {
|
|
43831
43875
|
"data-button": true,
|
|
43832
43876
|
"data-cancel": true,
|
|
43833
|
-
style:
|
|
43877
|
+
style: toast2.cancelButtonStyle || cancelButtonStyle,
|
|
43834
43878
|
onClick: (event) => {
|
|
43835
|
-
if (!isAction(
|
|
43879
|
+
if (!isAction(toast2.cancel)) return;
|
|
43836
43880
|
if (!dismissible) return;
|
|
43837
|
-
|
|
43881
|
+
toast2.cancel.onClick == null ? void 0 : toast2.cancel.onClick.call(toast2.cancel, event);
|
|
43838
43882
|
deleteToast();
|
|
43839
43883
|
},
|
|
43840
|
-
className: cn(classNames == null ? void 0 : classNames.cancelButton,
|
|
43841
|
-
},
|
|
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", {
|
|
43842
43886
|
"data-button": true,
|
|
43843
43887
|
"data-action": true,
|
|
43844
|
-
style:
|
|
43888
|
+
style: toast2.actionButtonStyle || actionButtonStyle,
|
|
43845
43889
|
onClick: (event) => {
|
|
43846
|
-
if (!isAction(
|
|
43847
|
-
|
|
43890
|
+
if (!isAction(toast2.action)) return;
|
|
43891
|
+
toast2.action.onClick == null ? void 0 : toast2.action.onClick.call(toast2.action, event);
|
|
43848
43892
|
if (event.defaultPrevented) return;
|
|
43849
43893
|
deleteToast();
|
|
43850
43894
|
},
|
|
43851
|
-
className: cn(classNames == null ? void 0 : classNames.actionButton,
|
|
43852
|
-
},
|
|
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);
|
|
43853
43897
|
};
|
|
43854
43898
|
function getDocumentDirection() {
|
|
43855
43899
|
if (typeof window === "undefined") return "ltr";
|
|
@@ -43908,9 +43952,9 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
43908
43952
|
const [toasts, setToasts] = React__default.useState([]);
|
|
43909
43953
|
const filteredToasts = React__default.useMemo(() => {
|
|
43910
43954
|
if (id) {
|
|
43911
|
-
return toasts.filter((
|
|
43955
|
+
return toasts.filter((toast2) => toast2.toasterId === id);
|
|
43912
43956
|
}
|
|
43913
|
-
return toasts.filter((
|
|
43957
|
+
return toasts.filter((toast2) => !toast2.toasterId);
|
|
43914
43958
|
}, [
|
|
43915
43959
|
toasts,
|
|
43916
43960
|
id
|
|
@@ -43918,7 +43962,7 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
43918
43962
|
const possiblePositions = React__default.useMemo(() => {
|
|
43919
43963
|
return Array.from(new Set([
|
|
43920
43964
|
position
|
|
43921
|
-
].concat(filteredToasts.filter((
|
|
43965
|
+
].concat(filteredToasts.filter((toast2) => toast2.position).map((toast2) => toast2.position))));
|
|
43922
43966
|
}, [
|
|
43923
43967
|
filteredToasts,
|
|
43924
43968
|
position
|
|
@@ -43934,17 +43978,17 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
43934
43978
|
const removeToast = React__default.useCallback((toastToRemove) => {
|
|
43935
43979
|
setToasts((toasts2) => {
|
|
43936
43980
|
var _toasts_find;
|
|
43937
|
-
if (!((_toasts_find = toasts2.find((
|
|
43981
|
+
if (!((_toasts_find = toasts2.find((toast2) => toast2.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) {
|
|
43938
43982
|
ToastState.dismiss(toastToRemove.id);
|
|
43939
43983
|
}
|
|
43940
43984
|
return toasts2.filter(({ id: id2 }) => id2 !== toastToRemove.id);
|
|
43941
43985
|
});
|
|
43942
43986
|
}, []);
|
|
43943
43987
|
React__default.useEffect(() => {
|
|
43944
|
-
return ToastState.subscribe((
|
|
43945
|
-
if (
|
|
43988
|
+
return ToastState.subscribe((toast2) => {
|
|
43989
|
+
if (toast2.dismiss) {
|
|
43946
43990
|
requestAnimationFrame(() => {
|
|
43947
|
-
setToasts((toasts2) => toasts2.map((t) => t.id ===
|
|
43991
|
+
setToasts((toasts2) => toasts2.map((t) => t.id === toast2.id ? {
|
|
43948
43992
|
...t,
|
|
43949
43993
|
delete: true
|
|
43950
43994
|
} : t));
|
|
@@ -43954,19 +43998,19 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
43954
43998
|
setTimeout(() => {
|
|
43955
43999
|
ReactDOM__default.flushSync(() => {
|
|
43956
44000
|
setToasts((toasts2) => {
|
|
43957
|
-
const indexOfExistingToast = toasts2.findIndex((t) => t.id ===
|
|
44001
|
+
const indexOfExistingToast = toasts2.findIndex((t) => t.id === toast2.id);
|
|
43958
44002
|
if (indexOfExistingToast !== -1) {
|
|
43959
44003
|
return [
|
|
43960
44004
|
...toasts2.slice(0, indexOfExistingToast),
|
|
43961
44005
|
{
|
|
43962
44006
|
...toasts2[indexOfExistingToast],
|
|
43963
|
-
...
|
|
44007
|
+
...toast2
|
|
43964
44008
|
},
|
|
43965
44009
|
...toasts2.slice(indexOfExistingToast + 1)
|
|
43966
44010
|
];
|
|
43967
44011
|
}
|
|
43968
44012
|
return [
|
|
43969
|
-
|
|
44013
|
+
toast2,
|
|
43970
44014
|
...toasts2
|
|
43971
44015
|
];
|
|
43972
44016
|
});
|
|
@@ -44118,13 +44162,13 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
44118
44162
|
setInteracting(true);
|
|
44119
44163
|
},
|
|
44120
44164
|
onPointerUp: () => setInteracting(false)
|
|
44121
|
-
}, filteredToasts.filter((
|
|
44165
|
+
}, filteredToasts.filter((toast2) => !toast2.position && index2 === 0 || toast2.position === position2).map((toast2, index3) => {
|
|
44122
44166
|
var _toastOptions_duration, _toastOptions_closeButton;
|
|
44123
44167
|
return /* @__PURE__ */ React__default.createElement(Toast, {
|
|
44124
|
-
key:
|
|
44168
|
+
key: toast2.id,
|
|
44125
44169
|
icons,
|
|
44126
44170
|
index: index3,
|
|
44127
|
-
toast,
|
|
44171
|
+
toast: toast2,
|
|
44128
44172
|
defaultRichColors: richColors,
|
|
44129
44173
|
duration: (_toastOptions_duration = toastOptions == null ? void 0 : toastOptions.duration) != null ? _toastOptions_duration : duration,
|
|
44130
44174
|
className: toastOptions == null ? void 0 : toastOptions.className,
|
|
@@ -44141,8 +44185,8 @@ const Toaster$2 = /* @__PURE__ */ React__default.forwardRef(function Toaster(pro
|
|
|
44141
44185
|
actionButtonStyle: toastOptions == null ? void 0 : toastOptions.actionButtonStyle,
|
|
44142
44186
|
closeButtonAriaLabel: toastOptions == null ? void 0 : toastOptions.closeButtonAriaLabel,
|
|
44143
44187
|
removeToast,
|
|
44144
|
-
toasts: filteredToasts.filter((t) => t.position ==
|
|
44145
|
-
heights: heights.filter((h) => h.position ==
|
|
44188
|
+
toasts: filteredToasts.filter((t) => t.position == toast2.position),
|
|
44189
|
+
heights: heights.filter((h) => h.position == toast2.position),
|
|
44146
44190
|
setHeights,
|
|
44147
44191
|
expandByDefault: expand,
|
|
44148
44192
|
gap,
|
|
@@ -44178,13 +44222,9 @@ const Toaster$1 = ({ ...props }) => {
|
|
|
44178
44222
|
);
|
|
44179
44223
|
};
|
|
44180
44224
|
const Toaster2 = ({ ...props }) => {
|
|
44181
|
-
const { theme = "system" } = z();
|
|
44182
44225
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
44183
44226
|
Toaster$1,
|
|
44184
44227
|
{
|
|
44185
|
-
theme,
|
|
44186
|
-
className: "toaster group",
|
|
44187
|
-
icons: void 0,
|
|
44188
44228
|
style: {
|
|
44189
44229
|
"--normal-bg": "var(--popover)",
|
|
44190
44230
|
"--normal-text": "var(--popover-foreground)",
|
|
@@ -45823,11 +45863,13 @@ export {
|
|
|
45823
45863
|
isDarkModeActive,
|
|
45824
45864
|
resolveColumnOrder,
|
|
45825
45865
|
resolveColumnVisibility,
|
|
45866
|
+
toast,
|
|
45826
45867
|
toggleCarbideTheme,
|
|
45827
45868
|
toggleDarkMode,
|
|
45828
45869
|
useBreakpoint,
|
|
45829
45870
|
useDataTableState,
|
|
45830
45871
|
useFormField,
|
|
45831
|
-
useTableController
|
|
45872
|
+
useTableController,
|
|
45873
|
+
useTabsValue
|
|
45832
45874
|
};
|
|
45833
45875
|
//# sourceMappingURL=mm-react-components.es.js.map
|