@bigbinary/neeto-atoms 1.0.7 → 1.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/ColorPicker-BPvxDGDM.js +276 -0
- package/dist/ColorPicker-BPvxDGDM.js.map +1 -0
- package/dist/{DataTable-Y4POx0WN.js → DataTable-BKe9K5XP.js} +136 -136
- package/dist/DataTable-BKe9K5XP.js.map +1 -0
- package/dist/cjs/ColorPicker-DN8aynGh.js +282 -0
- package/dist/cjs/ColorPicker-DN8aynGh.js.map +1 -0
- package/dist/cjs/{DataTable-DJw2SZ7b.js → DataTable-BQt_mXDX.js} +136 -136
- package/dist/cjs/DataTable-BQt_mXDX.js.map +1 -0
- package/dist/cjs/components/Accordion.js +49 -0
- package/dist/cjs/components/Accordion.js.map +1 -0
- package/dist/cjs/components/Alert.js +101 -0
- package/dist/cjs/components/Alert.js.map +1 -0
- package/dist/cjs/components/Badge.js +71 -0
- package/dist/cjs/components/Badge.js.map +1 -0
- package/dist/cjs/components/Button.js +121 -0
- package/dist/cjs/components/Button.js.map +1 -0
- package/dist/cjs/components/Checkbox.js +44 -0
- package/dist/cjs/components/Checkbox.js.map +1 -0
- package/dist/cjs/components/ColorPicker.js +34 -0
- package/dist/cjs/components/ColorPicker.js.map +1 -0
- package/dist/cjs/components/DataTable.js +3 -3
- package/dist/cjs/components/Dialog.js +88 -0
- package/dist/cjs/components/Dialog.js.map +1 -0
- package/dist/cjs/components/DropdownMenu.js +180 -0
- package/dist/cjs/components/DropdownMenu.js.map +1 -0
- package/dist/cjs/components/Input.js +167 -0
- package/dist/cjs/components/Input.js.map +1 -0
- package/dist/cjs/components/MultiSelect.js +13 -0
- package/dist/cjs/components/MultiSelect.js.map +1 -0
- package/dist/cjs/components/MultiSelectCombobox.js +3 -0
- package/dist/cjs/components/MultiSelectCombobox.js.map +1 -0
- package/dist/cjs/components/MultiSelectDropdown.js +37 -0
- package/dist/cjs/components/MultiSelectDropdown.js.map +1 -0
- package/dist/cjs/components/OptionItem.js +34 -0
- package/dist/cjs/components/OptionItem.js.map +1 -0
- package/dist/cjs/components/Popover.js +123 -0
- package/dist/cjs/components/Popover.js.map +1 -0
- package/dist/cjs/components/RadioGroup.js +63 -0
- package/dist/cjs/components/RadioGroup.js.map +1 -0
- package/dist/cjs/components/Select.js +3 -0
- package/dist/cjs/components/Select.js.map +1 -0
- package/dist/cjs/components/SelectFieldWrapper.js +33 -0
- package/dist/cjs/components/SelectFieldWrapper.js.map +1 -0
- package/dist/cjs/components/SelectOptions.js +43 -0
- package/dist/cjs/components/SelectOptions.js.map +1 -0
- package/dist/cjs/components/SelectTriggerContent.js +43 -0
- package/dist/cjs/components/SelectTriggerContent.js.map +1 -0
- package/dist/cjs/components/Sheet.js +90 -0
- package/dist/cjs/components/Sheet.js.map +1 -0
- package/dist/cjs/components/Switch.js +35 -0
- package/dist/cjs/components/Switch.js.map +1 -0
- package/dist/cjs/components/Tabs.js +74 -0
- package/dist/cjs/components/Tabs.js.map +1 -0
- package/dist/cjs/components/Textarea.js +89 -0
- package/dist/cjs/components/Textarea.js.map +1 -0
- package/dist/cjs/components/Toastr.js +133 -0
- package/dist/cjs/components/Toastr.js.map +1 -0
- package/dist/cjs/components/Tooltip.js +109 -0
- package/dist/cjs/components/Tooltip.js.map +1 -0
- package/dist/cjs/{primitives → components}/Typography.js +6 -6
- package/dist/cjs/components/Typography.js.map +1 -0
- package/dist/cjs/components/shared.js +8 -0
- package/dist/cjs/components/shared.js.map +1 -0
- package/dist/cjs/{dialog-DzNWLbJ6.js → dialog-CF2GBHOG.js} +2 -2
- package/dist/cjs/{dialog-DzNWLbJ6.js.map → dialog-CF2GBHOG.js.map} +1 -1
- package/dist/cjs/{index-DAds6mf_.js → index-BLGrl3PF.js} +31 -31
- package/dist/cjs/{index-DAds6mf_.js.map → index-BLGrl3PF.js.map} +1 -1
- package/dist/cjs/{index-BqCr1H3u.js → index-BiGm7NEA.js} +11 -11
- package/dist/cjs/{index-BqCr1H3u.js.map → index-BiGm7NEA.js.map} +1 -1
- package/dist/cjs/{index-CGet1HH4.js → index-PdtYHwPi.js} +66 -66
- package/dist/cjs/{index-CGet1HH4.js.map → index-PdtYHwPi.js.map} +1 -1
- package/dist/cjs/index-Vlwnyfvs.js +1145 -0
- package/dist/cjs/index-Vlwnyfvs.js.map +1 -0
- package/dist/cjs/{index-DR7GJU4J.js → index-hQmfI1O7.js} +17 -17
- package/dist/cjs/{index-DR7GJU4J.js.map → index-hQmfI1O7.js.map} +1 -1
- package/dist/cjs/index.js +463 -26
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/primitives/Accordion.js +16 -16
- package/dist/cjs/primitives/Accordion.js.map +1 -1
- package/dist/cjs/primitives/AlertDialog.js +1 -1
- package/dist/cjs/primitives/Badge.js +58 -6
- package/dist/cjs/primitives/Badge.js.map +1 -1
- package/dist/cjs/primitives/Chart.js +137 -137
- package/dist/cjs/primitives/Chart.js.map +1 -1
- package/dist/cjs/primitives/Collapsible.js +1 -1
- package/dist/cjs/primitives/Combobox.js +4 -4
- package/dist/cjs/primitives/Combobox.js.map +1 -1
- package/dist/cjs/primitives/Command.js +2 -2
- package/dist/cjs/primitives/ContextMenu.js +2 -2
- package/dist/cjs/primitives/Dialog.js +10 -6
- package/dist/cjs/primitives/Dialog.js.map +1 -1
- package/dist/cjs/primitives/Drawer.js +1 -1
- package/dist/cjs/primitives/DropdownMenu.js +38 -38
- package/dist/cjs/primitives/DropdownMenu.js.map +1 -1
- package/dist/cjs/primitives/HoverCard.js +16 -16
- package/dist/cjs/primitives/Menubar.js +2 -2
- package/dist/cjs/primitives/Popover.js +13 -13
- package/dist/cjs/primitives/RadioGroup.js +27 -26
- package/dist/cjs/primitives/RadioGroup.js.map +1 -1
- package/dist/cjs/primitives/Select.js +77 -77
- package/dist/cjs/primitives/Sheet.js +10 -6
- package/dist/cjs/primitives/Sheet.js.map +1 -1
- package/dist/cjs/primitives/Sidebar.js +3 -3
- package/dist/cjs/primitives/Sonner.js +12 -1138
- package/dist/cjs/primitives/Sonner.js.map +1 -1
- package/dist/cjs/primitives/Switch.js +4 -8
- package/dist/cjs/primitives/Switch.js.map +1 -1
- package/dist/cjs/primitives/Tabs.js +11 -11
- package/dist/cjs/primitives/ToggleGroup.js +1 -1
- package/dist/cjs/primitives/Tooltip.js +1 -1
- package/dist/cjs/primitives/index.js +9 -11
- package/dist/cjs/primitives/index.js.map +1 -1
- package/dist/cjs/renderIcon-fLF3odqg.js +26 -0
- package/dist/cjs/renderIcon-fLF3odqg.js.map +1 -0
- package/dist/cjs/{sheet-nHSYZxAA.js → sheet-CkCrHmVA.js} +2 -2
- package/dist/cjs/{sheet-nHSYZxAA.js.map → sheet-CkCrHmVA.js.map} +1 -1
- package/dist/cjs/{tooltip-CRkOMh1b.js → tooltip-C-568jEL.js} +17 -17
- package/dist/cjs/{tooltip-CRkOMh1b.js.map → tooltip-C-568jEL.js.map} +1 -1
- package/dist/cjs/useCreatableItems-BTHtd7uo.js +100 -0
- package/dist/cjs/useCreatableItems-BTHtd7uo.js.map +1 -0
- package/dist/cjs/{reselect-CeyIIDM-.js → with-selector-u4xTSzCv.js} +111 -111
- package/dist/cjs/with-selector-u4xTSzCv.js.map +1 -0
- package/dist/components/Accordion.d.ts +18 -0
- package/dist/components/Accordion.js +43 -0
- package/dist/components/Accordion.js.map +1 -0
- package/dist/components/Alert.d.ts +51 -0
- package/dist/components/Alert.js +99 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/Badge.d.ts +29 -0
- package/dist/components/Badge.js +69 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Button.d.ts +47 -0
- package/dist/components/Button.js +119 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/Checkbox.d.ts +16 -0
- package/dist/components/Checkbox.js +42 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/ColorPicker/ColorPicker.d.ts +4 -0
- package/dist/components/ColorPicker/Palette.d.ts +12 -0
- package/dist/components/ColorPicker/Target.d.ts +15 -0
- package/dist/components/ColorPicker/constants.d.ts +10 -0
- package/dist/components/ColorPicker/hooks/useEyeDropper.d.ts +15 -0
- package/dist/components/ColorPicker/hooks/useRecentlyUsedColors.d.ts +11 -0
- package/dist/components/ColorPicker/index.d.ts +2 -0
- package/dist/components/ColorPicker/types.d.ts +42 -0
- package/dist/components/ColorPicker/utils.d.ts +31 -0
- package/dist/components/ColorPicker.js +28 -0
- package/dist/components/ColorPicker.js.map +1 -0
- package/dist/components/DataTable.js +2 -2
- package/dist/components/Dialog.d.ts +56 -0
- package/dist/components/Dialog.js +86 -0
- package/dist/components/Dialog.js.map +1 -0
- package/dist/components/DropdownMenu/Divider.d.ts +3 -0
- package/dist/components/DropdownMenu/DropdownBase.d.ts +3 -0
- package/dist/components/DropdownMenu/Label.d.ts +7 -0
- package/dist/components/DropdownMenu/Menu.d.ts +7 -0
- package/dist/components/DropdownMenu/MenuItem.d.ts +10 -0
- package/dist/components/DropdownMenu/MenuItemButton.d.ts +4 -0
- package/dist/components/DropdownMenu/SplitTrigger.d.ts +13 -0
- package/dist/components/DropdownMenu/SubMenu.d.ts +10 -0
- package/dist/components/DropdownMenu/TriggerButton.d.ts +10 -0
- package/dist/components/DropdownMenu/constants.d.ts +7 -0
- package/dist/components/DropdownMenu/index.d.ts +16 -0
- package/dist/components/DropdownMenu/types.d.ts +88 -0
- package/dist/components/DropdownMenu.js +178 -0
- package/dist/components/DropdownMenu.js.map +1 -0
- package/dist/components/Input.d.ts +39 -0
- package/dist/components/Input.js +165 -0
- package/dist/components/Input.js.map +1 -0
- package/dist/components/MultiSelect.constants.d.ts +5 -0
- package/dist/components/MultiSelect.d.ts +4 -0
- package/dist/components/MultiSelect.js +4 -0
- package/dist/components/MultiSelect.js.map +1 -0
- package/dist/components/MultiSelect.types.d.ts +121 -0
- package/dist/components/MultiSelect.utils.d.ts +18 -0
- package/dist/components/MultiSelectCombobox.d.ts +3 -0
- package/dist/components/MultiSelectCombobox.js +2 -0
- package/dist/components/MultiSelectCombobox.js.map +1 -0
- package/dist/components/MultiSelectCombobox.types.d.ts +52 -0
- package/dist/components/MultiSelectDropdown.d.ts +9 -0
- package/dist/components/MultiSelectDropdown.js +35 -0
- package/dist/components/MultiSelectDropdown.js.map +1 -0
- package/dist/components/OptionItem.d.ts +9 -0
- package/dist/components/OptionItem.js +32 -0
- package/dist/components/OptionItem.js.map +1 -0
- package/dist/components/Popover.d.ts +47 -0
- package/dist/components/Popover.js +117 -0
- package/dist/components/Popover.js.map +1 -0
- package/dist/components/RadioGroup.d.ts +32 -0
- package/dist/components/RadioGroup.js +61 -0
- package/dist/components/RadioGroup.js.map +1 -0
- package/dist/components/Select.constants.d.ts +5 -0
- package/dist/components/Select.d.ts +4 -0
- package/dist/components/Select.js +2 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Select.types.d.ts +58 -0
- package/dist/components/SelectFieldWrapper.d.ts +18 -0
- package/dist/components/SelectFieldWrapper.js +31 -0
- package/dist/components/SelectFieldWrapper.js.map +1 -0
- package/dist/components/SelectOptions.d.ts +2 -0
- package/dist/components/SelectOptions.js +41 -0
- package/dist/components/SelectOptions.js.map +1 -0
- package/dist/components/SelectTriggerContent.d.ts +18 -0
- package/dist/components/SelectTriggerContent.js +41 -0
- package/dist/components/SelectTriggerContent.js.map +1 -0
- package/dist/components/Sheet.d.ts +54 -0
- package/dist/components/Sheet.js +88 -0
- package/dist/components/Sheet.js.map +1 -0
- package/dist/components/Switch.d.ts +18 -0
- package/dist/components/Switch.js +33 -0
- package/dist/components/Switch.js.map +1 -0
- package/dist/components/Tabs.d.ts +20 -0
- package/dist/components/Tabs.js +72 -0
- package/dist/components/Tabs.js.map +1 -0
- package/dist/components/Textarea.d.ts +36 -0
- package/dist/components/Textarea.js +87 -0
- package/dist/components/Textarea.js.map +1 -0
- package/dist/components/Toastr.d.ts +30 -0
- package/dist/components/Toastr.js +131 -0
- package/dist/components/Toastr.js.map +1 -0
- package/dist/components/Tooltip.d.ts +29 -0
- package/dist/components/Tooltip.js +103 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/{primitives → components}/Typography.d.ts +2 -2
- package/dist/{primitives → components}/Typography.js +6 -6
- package/dist/components/Typography.js.map +1 -0
- package/dist/components/shared.js +6 -0
- package/dist/components/shared.js.map +1 -0
- package/dist/components/shared.types.d.ts +16 -0
- package/dist/{dialog-C97DOTvO.js → dialog-Civ9r6wD.js} +3 -3
- package/dist/{dialog-C97DOTvO.js.map → dialog-Civ9r6wD.js.map} +1 -1
- package/dist/hooks/useAsyncOptions.d.ts +13 -0
- package/dist/hooks/useCreatableItems.d.ts +30 -0
- package/dist/hooks/useLazyLoadSentinel.d.ts +6 -0
- package/dist/hooks/useMultiSelectOptions.d.ts +15 -0
- package/dist/hooks/useMultiSelectState.d.ts +37 -0
- package/dist/hooks/useSelectState.d.ts +27 -0
- package/dist/{index-PF0ms7Xn.js → index-9HvIbmnI.js} +3 -3
- package/dist/{index-PF0ms7Xn.js.map → index-9HvIbmnI.js.map} +1 -1
- package/dist/index-D_roZz8G.js +1137 -0
- package/dist/index-D_roZz8G.js.map +1 -0
- package/dist/{index-BwxI_qgh.js → index-KzJfsx-e.js} +3 -3
- package/dist/{index-BwxI_qgh.js.map → index-KzJfsx-e.js.map} +1 -1
- package/dist/index.css +25 -1
- package/dist/index.d.ts +40 -0
- package/dist/index.js +440 -24
- package/dist/index.js.map +1 -1
- package/dist/{input-group-CDBpz6Pb.js → input-group-ytECR3Hw.js} +2 -2
- package/dist/{input-group-CDBpz6Pb.js.map → input-group-ytECR3Hw.js.map} +1 -1
- package/dist/lib/renderIcon.d.ts +5 -0
- package/dist/primitives/Accordion.js +1 -1
- package/dist/primitives/AlertDialog.js +1 -1
- package/dist/primitives/Badge.d.ts +13 -3
- package/dist/primitives/Badge.js +54 -2
- package/dist/primitives/Badge.js.map +1 -1
- package/dist/primitives/Chart.js +1 -1
- package/dist/primitives/Combobox.js +3 -3
- package/dist/primitives/Command.js +3 -3
- package/dist/primitives/ContextMenu.js +1 -1
- package/dist/primitives/Dialog.d.ts +11 -3
- package/dist/primitives/Dialog.js +11 -7
- package/dist/primitives/Dialog.js.map +1 -1
- package/dist/primitives/Drawer.js +1 -1
- package/dist/primitives/DropdownMenu.js +2 -2
- package/dist/primitives/InputGroup.js +1 -1
- package/dist/primitives/Menubar.js +1 -1
- package/dist/primitives/RadioGroup.d.ts +8 -3
- package/dist/primitives/RadioGroup.js +9 -8
- package/dist/primitives/RadioGroup.js.map +1 -1
- package/dist/primitives/Select.js +3 -3
- package/dist/primitives/Sheet.d.ts +12 -3
- package/dist/primitives/Sheet.js +11 -7
- package/dist/primitives/Sheet.js.map +1 -1
- package/dist/primitives/Sidebar.js +3 -3
- package/dist/primitives/Sonner.js +11 -1135
- package/dist/primitives/Sonner.js.map +1 -1
- package/dist/primitives/Switch.d.ts +6 -3
- package/dist/primitives/Switch.js +4 -8
- package/dist/primitives/Switch.js.map +1 -1
- package/dist/primitives/Tooltip.js +1 -1
- package/dist/primitives/index.d.ts +0 -1
- package/dist/primitives/index.js +8 -8
- package/dist/renderIcon-tlvMyboj.js +20 -0
- package/dist/renderIcon-tlvMyboj.js.map +1 -0
- package/dist/shadcn/components/typography.d.ts +4 -4
- package/dist/{sheet-D1ngftfX.js → sheet-COcn22fC.js} +3 -3
- package/dist/{sheet-D1ngftfX.js.map → sheet-COcn22fC.js.map} +1 -1
- package/dist/{tooltip-D5soNrAP.js → tooltip-DzjIJacP.js} +3 -3
- package/dist/{tooltip-D5soNrAP.js.map → tooltip-DzjIJacP.js.map} +1 -1
- package/dist/useCreatableItems-B0seQA1_.js +89 -0
- package/dist/useCreatableItems-B0seQA1_.js.map +1 -0
- package/dist/utils/fieldIds.d.ts +2 -0
- package/dist/utils/hyphenize.d.ts +1 -0
- package/dist/{reselect-CABQm5hA.js → with-selector--fY1NrB9.js} +111 -111
- package/dist/with-selector--fY1NrB9.js.map +1 -0
- package/package.json +2 -1
- package/dist/DataTable-Y4POx0WN.js.map +0 -1
- package/dist/cjs/DataTable-DJw2SZ7b.js.map +0 -1
- package/dist/cjs/primitives/Typography.js.map +0 -1
- package/dist/cjs/reselect-CeyIIDM-.js.map +0 -1
- package/dist/primitives/Typography.js.map +0 -1
- package/dist/reselect-CABQm5hA.js.map +0 -1
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var
|
|
5
|
+
var index = require('../index-Vlwnyfvs.js');
|
|
6
6
|
var loaderCircle = require('../loader-circle-Bw7zP2Gn.js');
|
|
7
7
|
var createLucideIcon = require('../createLucideIcon-D0tRgV6l.js');
|
|
8
|
-
|
|
9
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
require('react-dom');
|
|
10
9
|
|
|
11
10
|
function _interopNamespace(e) {
|
|
12
11
|
if (e && e.__esModule) return e;
|
|
@@ -27,7 +26,6 @@ function _interopNamespace(e) {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
30
|
-
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
31
29
|
|
|
32
30
|
/**
|
|
33
31
|
* @license lucide-react v0.577.0 - ISC
|
|
@@ -102,1141 +100,9 @@ const TriangleAlert = createLucideIcon.createLucideIcon("triangle-alert", __icon
|
|
|
102
100
|
|
|
103
101
|
var M=(e,i,s,u,m,a,l,h)=>{let d=document.documentElement,w=["light","dark"];function p(n){(Array.isArray(e)?e:[e]).forEach(y=>{let k=y==="class",S=k&&a?m.map(f=>a[f]||f):m;k?(d.classList.remove(...S),d.classList.add(a&&a[n]?a[n]:n)):d.setAttribute(y,n);}),R(n);}function R(n){h&&w.includes(n)&&(d.style.colorScheme=n);}function c(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(u)p(u);else try{let n=localStorage.getItem(i)||s,y=l&&n==="system"?c():n;p(y);}catch(n){}};var x=React__namespace.createContext(void 0),U={setTheme:e=>{},themes:[]},z=()=>{var e;return (e=React__namespace.useContext(x))!=null?e:U};React__namespace.memo(({forcedTheme:e,storageKey:i,attribute:s,enableSystem:u,enableColorScheme:m,defaultTheme:a,value:l,themes:h,nonce:d,scriptProps:w})=>{let p=JSON.stringify([s,i,a,e,h,l,u,m]).slice(1,-1);return React__namespace.createElement("script",{...w,suppressHydrationWarning:true,nonce:typeof window=="undefined"?d:"",dangerouslySetInnerHTML:{__html:`(${M.toString()})(${p})`}})});
|
|
104
102
|
|
|
105
|
-
function __insertCSS(code) {
|
|
106
|
-
if (typeof document == 'undefined') return
|
|
107
|
-
let head = document.head || document.getElementsByTagName('head')[0];
|
|
108
|
-
let style = document.createElement('style');
|
|
109
|
-
style.type = 'text/css';
|
|
110
|
-
head.appendChild(style)
|
|
111
|
-
;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const getAsset = (type)=>{
|
|
115
|
-
switch(type){
|
|
116
|
-
case 'success':
|
|
117
|
-
return SuccessIcon;
|
|
118
|
-
case 'info':
|
|
119
|
-
return InfoIcon;
|
|
120
|
-
case 'warning':
|
|
121
|
-
return WarningIcon;
|
|
122
|
-
case 'error':
|
|
123
|
-
return ErrorIcon;
|
|
124
|
-
default:
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const bars = Array(12).fill(0);
|
|
129
|
-
const Loader = ({ visible, className })=>{
|
|
130
|
-
return /*#__PURE__*/ React__namespace.default.createElement("div", {
|
|
131
|
-
className: [
|
|
132
|
-
'sonner-loading-wrapper',
|
|
133
|
-
className
|
|
134
|
-
].filter(Boolean).join(' '),
|
|
135
|
-
"data-visible": visible
|
|
136
|
-
}, /*#__PURE__*/ React__namespace.default.createElement("div", {
|
|
137
|
-
className: "sonner-spinner"
|
|
138
|
-
}, bars.map((_, i)=>/*#__PURE__*/ React__namespace.default.createElement("div", {
|
|
139
|
-
className: "sonner-loading-bar",
|
|
140
|
-
key: `spinner-bar-${i}`
|
|
141
|
-
}))));
|
|
142
|
-
};
|
|
143
|
-
const SuccessIcon = /*#__PURE__*/ React__namespace.default.createElement("svg", {
|
|
144
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
145
|
-
viewBox: "0 0 20 20",
|
|
146
|
-
fill: "currentColor",
|
|
147
|
-
height: "20",
|
|
148
|
-
width: "20"
|
|
149
|
-
}, /*#__PURE__*/ React__namespace.default.createElement("path", {
|
|
150
|
-
fillRule: "evenodd",
|
|
151
|
-
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
152
|
-
clipRule: "evenodd"
|
|
153
|
-
}));
|
|
154
|
-
const WarningIcon = /*#__PURE__*/ React__namespace.default.createElement("svg", {
|
|
155
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
156
|
-
viewBox: "0 0 24 24",
|
|
157
|
-
fill: "currentColor",
|
|
158
|
-
height: "20",
|
|
159
|
-
width: "20"
|
|
160
|
-
}, /*#__PURE__*/ React__namespace.default.createElement("path", {
|
|
161
|
-
fillRule: "evenodd",
|
|
162
|
-
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
163
|
-
clipRule: "evenodd"
|
|
164
|
-
}));
|
|
165
|
-
const InfoIcon = /*#__PURE__*/ React__namespace.default.createElement("svg", {
|
|
166
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
167
|
-
viewBox: "0 0 20 20",
|
|
168
|
-
fill: "currentColor",
|
|
169
|
-
height: "20",
|
|
170
|
-
width: "20"
|
|
171
|
-
}, /*#__PURE__*/ React__namespace.default.createElement("path", {
|
|
172
|
-
fillRule: "evenodd",
|
|
173
|
-
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
174
|
-
clipRule: "evenodd"
|
|
175
|
-
}));
|
|
176
|
-
const ErrorIcon = /*#__PURE__*/ React__namespace.default.createElement("svg", {
|
|
177
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
178
|
-
viewBox: "0 0 20 20",
|
|
179
|
-
fill: "currentColor",
|
|
180
|
-
height: "20",
|
|
181
|
-
width: "20"
|
|
182
|
-
}, /*#__PURE__*/ React__namespace.default.createElement("path", {
|
|
183
|
-
fillRule: "evenodd",
|
|
184
|
-
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
185
|
-
clipRule: "evenodd"
|
|
186
|
-
}));
|
|
187
|
-
const CloseIcon = /*#__PURE__*/ React__namespace.default.createElement("svg", {
|
|
188
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
189
|
-
width: "12",
|
|
190
|
-
height: "12",
|
|
191
|
-
viewBox: "0 0 24 24",
|
|
192
|
-
fill: "none",
|
|
193
|
-
stroke: "currentColor",
|
|
194
|
-
strokeWidth: "1.5",
|
|
195
|
-
strokeLinecap: "round",
|
|
196
|
-
strokeLinejoin: "round"
|
|
197
|
-
}, /*#__PURE__*/ React__namespace.default.createElement("line", {
|
|
198
|
-
x1: "18",
|
|
199
|
-
y1: "6",
|
|
200
|
-
x2: "6",
|
|
201
|
-
y2: "18"
|
|
202
|
-
}), /*#__PURE__*/ React__namespace.default.createElement("line", {
|
|
203
|
-
x1: "6",
|
|
204
|
-
y1: "6",
|
|
205
|
-
x2: "18",
|
|
206
|
-
y2: "18"
|
|
207
|
-
}));
|
|
208
|
-
|
|
209
|
-
const useIsDocumentHidden = ()=>{
|
|
210
|
-
const [isDocumentHidden, setIsDocumentHidden] = React__namespace.default.useState(document.hidden);
|
|
211
|
-
React__namespace.default.useEffect(()=>{
|
|
212
|
-
const callback = ()=>{
|
|
213
|
-
setIsDocumentHidden(document.hidden);
|
|
214
|
-
};
|
|
215
|
-
document.addEventListener('visibilitychange', callback);
|
|
216
|
-
return ()=>window.removeEventListener('visibilitychange', callback);
|
|
217
|
-
}, []);
|
|
218
|
-
return isDocumentHidden;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
let toastsCounter = 1;
|
|
222
|
-
class Observer {
|
|
223
|
-
constructor(){
|
|
224
|
-
// We use arrow functions to maintain the correct `this` reference
|
|
225
|
-
this.subscribe = (subscriber)=>{
|
|
226
|
-
this.subscribers.push(subscriber);
|
|
227
|
-
return ()=>{
|
|
228
|
-
const index = this.subscribers.indexOf(subscriber);
|
|
229
|
-
this.subscribers.splice(index, 1);
|
|
230
|
-
};
|
|
231
|
-
};
|
|
232
|
-
this.publish = (data)=>{
|
|
233
|
-
this.subscribers.forEach((subscriber)=>subscriber(data));
|
|
234
|
-
};
|
|
235
|
-
this.addToast = (data)=>{
|
|
236
|
-
this.publish(data);
|
|
237
|
-
this.toasts = [
|
|
238
|
-
...this.toasts,
|
|
239
|
-
data
|
|
240
|
-
];
|
|
241
|
-
};
|
|
242
|
-
this.create = (data)=>{
|
|
243
|
-
var _data_id;
|
|
244
|
-
const { message, ...rest } = data;
|
|
245
|
-
const id = typeof (data == null ? void 0 : data.id) === 'number' || ((_data_id = data.id) == null ? void 0 : _data_id.length) > 0 ? data.id : toastsCounter++;
|
|
246
|
-
const alreadyExists = this.toasts.find((toast)=>{
|
|
247
|
-
return toast.id === id;
|
|
248
|
-
});
|
|
249
|
-
const dismissible = data.dismissible === undefined ? true : data.dismissible;
|
|
250
|
-
if (this.dismissedToasts.has(id)) {
|
|
251
|
-
this.dismissedToasts.delete(id);
|
|
252
|
-
}
|
|
253
|
-
if (alreadyExists) {
|
|
254
|
-
this.toasts = this.toasts.map((toast)=>{
|
|
255
|
-
if (toast.id === id) {
|
|
256
|
-
this.publish({
|
|
257
|
-
...toast,
|
|
258
|
-
...data,
|
|
259
|
-
id,
|
|
260
|
-
title: message
|
|
261
|
-
});
|
|
262
|
-
return {
|
|
263
|
-
...toast,
|
|
264
|
-
...data,
|
|
265
|
-
id,
|
|
266
|
-
dismissible,
|
|
267
|
-
title: message
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
return toast;
|
|
271
|
-
});
|
|
272
|
-
} else {
|
|
273
|
-
this.addToast({
|
|
274
|
-
title: message,
|
|
275
|
-
...rest,
|
|
276
|
-
dismissible,
|
|
277
|
-
id
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
return id;
|
|
281
|
-
};
|
|
282
|
-
this.dismiss = (id)=>{
|
|
283
|
-
if (id) {
|
|
284
|
-
this.dismissedToasts.add(id);
|
|
285
|
-
requestAnimationFrame(()=>this.subscribers.forEach((subscriber)=>subscriber({
|
|
286
|
-
id,
|
|
287
|
-
dismiss: true
|
|
288
|
-
})));
|
|
289
|
-
} else {
|
|
290
|
-
this.toasts.forEach((toast)=>{
|
|
291
|
-
this.subscribers.forEach((subscriber)=>subscriber({
|
|
292
|
-
id: toast.id,
|
|
293
|
-
dismiss: true
|
|
294
|
-
}));
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
return id;
|
|
298
|
-
};
|
|
299
|
-
this.message = (message, data)=>{
|
|
300
|
-
return this.create({
|
|
301
|
-
...data,
|
|
302
|
-
message
|
|
303
|
-
});
|
|
304
|
-
};
|
|
305
|
-
this.error = (message, data)=>{
|
|
306
|
-
return this.create({
|
|
307
|
-
...data,
|
|
308
|
-
message,
|
|
309
|
-
type: 'error'
|
|
310
|
-
});
|
|
311
|
-
};
|
|
312
|
-
this.success = (message, data)=>{
|
|
313
|
-
return this.create({
|
|
314
|
-
...data,
|
|
315
|
-
type: 'success',
|
|
316
|
-
message
|
|
317
|
-
});
|
|
318
|
-
};
|
|
319
|
-
this.info = (message, data)=>{
|
|
320
|
-
return this.create({
|
|
321
|
-
...data,
|
|
322
|
-
type: 'info',
|
|
323
|
-
message
|
|
324
|
-
});
|
|
325
|
-
};
|
|
326
|
-
this.warning = (message, data)=>{
|
|
327
|
-
return this.create({
|
|
328
|
-
...data,
|
|
329
|
-
type: 'warning',
|
|
330
|
-
message
|
|
331
|
-
});
|
|
332
|
-
};
|
|
333
|
-
this.loading = (message, data)=>{
|
|
334
|
-
return this.create({
|
|
335
|
-
...data,
|
|
336
|
-
type: 'loading',
|
|
337
|
-
message
|
|
338
|
-
});
|
|
339
|
-
};
|
|
340
|
-
this.promise = (promise, data)=>{
|
|
341
|
-
if (!data) {
|
|
342
|
-
// Nothing to show
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
let id = undefined;
|
|
346
|
-
if (data.loading !== undefined) {
|
|
347
|
-
id = this.create({
|
|
348
|
-
...data,
|
|
349
|
-
promise,
|
|
350
|
-
type: 'loading',
|
|
351
|
-
message: data.loading,
|
|
352
|
-
description: typeof data.description !== 'function' ? data.description : undefined
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
const p = Promise.resolve(promise instanceof Function ? promise() : promise);
|
|
356
|
-
let shouldDismiss = id !== undefined;
|
|
357
|
-
let result;
|
|
358
|
-
const originalPromise = p.then(async (response)=>{
|
|
359
|
-
result = [
|
|
360
|
-
'resolve',
|
|
361
|
-
response
|
|
362
|
-
];
|
|
363
|
-
const isReactElementResponse = React__namespace.default.isValidElement(response);
|
|
364
|
-
if (isReactElementResponse) {
|
|
365
|
-
shouldDismiss = false;
|
|
366
|
-
this.create({
|
|
367
|
-
id,
|
|
368
|
-
type: 'default',
|
|
369
|
-
message: response
|
|
370
|
-
});
|
|
371
|
-
} else if (isHttpResponse(response) && !response.ok) {
|
|
372
|
-
shouldDismiss = false;
|
|
373
|
-
const promiseData = typeof data.error === 'function' ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
|
|
374
|
-
const description = typeof data.description === 'function' ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
|
|
375
|
-
const isExtendedResult = typeof promiseData === 'object' && !React__namespace.default.isValidElement(promiseData);
|
|
376
|
-
const toastSettings = isExtendedResult ? promiseData : {
|
|
377
|
-
message: promiseData
|
|
378
|
-
};
|
|
379
|
-
this.create({
|
|
380
|
-
id,
|
|
381
|
-
type: 'error',
|
|
382
|
-
description,
|
|
383
|
-
...toastSettings
|
|
384
|
-
});
|
|
385
|
-
} else if (response instanceof Error) {
|
|
386
|
-
shouldDismiss = false;
|
|
387
|
-
const promiseData = typeof data.error === 'function' ? await data.error(response) : data.error;
|
|
388
|
-
const description = typeof data.description === 'function' ? await data.description(response) : data.description;
|
|
389
|
-
const isExtendedResult = typeof promiseData === 'object' && !React__namespace.default.isValidElement(promiseData);
|
|
390
|
-
const toastSettings = isExtendedResult ? promiseData : {
|
|
391
|
-
message: promiseData
|
|
392
|
-
};
|
|
393
|
-
this.create({
|
|
394
|
-
id,
|
|
395
|
-
type: 'error',
|
|
396
|
-
description,
|
|
397
|
-
...toastSettings
|
|
398
|
-
});
|
|
399
|
-
} else if (data.success !== undefined) {
|
|
400
|
-
shouldDismiss = false;
|
|
401
|
-
const promiseData = typeof data.success === 'function' ? await data.success(response) : data.success;
|
|
402
|
-
const description = typeof data.description === 'function' ? await data.description(response) : data.description;
|
|
403
|
-
const isExtendedResult = typeof promiseData === 'object' && !React__namespace.default.isValidElement(promiseData);
|
|
404
|
-
const toastSettings = isExtendedResult ? promiseData : {
|
|
405
|
-
message: promiseData
|
|
406
|
-
};
|
|
407
|
-
this.create({
|
|
408
|
-
id,
|
|
409
|
-
type: 'success',
|
|
410
|
-
description,
|
|
411
|
-
...toastSettings
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
}).catch(async (error)=>{
|
|
415
|
-
result = [
|
|
416
|
-
'reject',
|
|
417
|
-
error
|
|
418
|
-
];
|
|
419
|
-
if (data.error !== undefined) {
|
|
420
|
-
shouldDismiss = false;
|
|
421
|
-
const promiseData = typeof data.error === 'function' ? await data.error(error) : data.error;
|
|
422
|
-
const description = typeof data.description === 'function' ? await data.description(error) : data.description;
|
|
423
|
-
const isExtendedResult = typeof promiseData === 'object' && !React__namespace.default.isValidElement(promiseData);
|
|
424
|
-
const toastSettings = isExtendedResult ? promiseData : {
|
|
425
|
-
message: promiseData
|
|
426
|
-
};
|
|
427
|
-
this.create({
|
|
428
|
-
id,
|
|
429
|
-
type: 'error',
|
|
430
|
-
description,
|
|
431
|
-
...toastSettings
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
}).finally(()=>{
|
|
435
|
-
if (shouldDismiss) {
|
|
436
|
-
// Toast is still in load state (and will be indefinitely — dismiss it)
|
|
437
|
-
this.dismiss(id);
|
|
438
|
-
id = undefined;
|
|
439
|
-
}
|
|
440
|
-
data.finally == null ? void 0 : data.finally.call(data);
|
|
441
|
-
});
|
|
442
|
-
const unwrap = ()=>new Promise((resolve, reject)=>originalPromise.then(()=>result[0] === 'reject' ? reject(result[1]) : resolve(result[1])).catch(reject));
|
|
443
|
-
if (typeof id !== 'string' && typeof id !== 'number') {
|
|
444
|
-
// cannot Object.assign on undefined
|
|
445
|
-
return {
|
|
446
|
-
unwrap
|
|
447
|
-
};
|
|
448
|
-
} else {
|
|
449
|
-
return Object.assign(id, {
|
|
450
|
-
unwrap
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
this.custom = (jsx, data)=>{
|
|
455
|
-
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
456
|
-
this.create({
|
|
457
|
-
jsx: jsx(id),
|
|
458
|
-
id,
|
|
459
|
-
...data
|
|
460
|
-
});
|
|
461
|
-
return id;
|
|
462
|
-
};
|
|
463
|
-
this.getActiveToasts = ()=>{
|
|
464
|
-
return this.toasts.filter((toast)=>!this.dismissedToasts.has(toast.id));
|
|
465
|
-
};
|
|
466
|
-
this.subscribers = [];
|
|
467
|
-
this.toasts = [];
|
|
468
|
-
this.dismissedToasts = new Set();
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
const ToastState = new Observer();
|
|
472
|
-
// bind this to the toast function
|
|
473
|
-
const toastFunction = (message, data)=>{
|
|
474
|
-
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
475
|
-
ToastState.addToast({
|
|
476
|
-
title: message,
|
|
477
|
-
...data,
|
|
478
|
-
id
|
|
479
|
-
});
|
|
480
|
-
return id;
|
|
481
|
-
};
|
|
482
|
-
const isHttpResponse = (data)=>{
|
|
483
|
-
return data && typeof data === 'object' && 'ok' in data && typeof data.ok === 'boolean' && 'status' in data && typeof data.status === 'number';
|
|
484
|
-
};
|
|
485
|
-
const basicToast = toastFunction;
|
|
486
|
-
const getHistory = ()=>ToastState.toasts;
|
|
487
|
-
const getToasts = ()=>ToastState.getActiveToasts();
|
|
488
|
-
// We use `Object.assign` to maintain the correct types as we would lose them otherwise
|
|
489
|
-
Object.assign(basicToast, {
|
|
490
|
-
success: ToastState.success,
|
|
491
|
-
info: ToastState.info,
|
|
492
|
-
warning: ToastState.warning,
|
|
493
|
-
error: ToastState.error,
|
|
494
|
-
custom: ToastState.custom,
|
|
495
|
-
message: ToastState.message,
|
|
496
|
-
promise: ToastState.promise,
|
|
497
|
-
dismiss: ToastState.dismiss,
|
|
498
|
-
loading: ToastState.loading
|
|
499
|
-
}, {
|
|
500
|
-
getHistory,
|
|
501
|
-
getToasts
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
__insertCSS("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
|
|
505
|
-
|
|
506
|
-
function isAction(action) {
|
|
507
|
-
return action.label !== undefined;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// Visible toasts amount
|
|
511
|
-
const VISIBLE_TOASTS_AMOUNT = 3;
|
|
512
|
-
// Viewport padding
|
|
513
|
-
const VIEWPORT_OFFSET = '24px';
|
|
514
|
-
// Mobile viewport padding
|
|
515
|
-
const MOBILE_VIEWPORT_OFFSET = '16px';
|
|
516
|
-
// Default lifetime of a toasts (in ms)
|
|
517
|
-
const TOAST_LIFETIME = 4000;
|
|
518
|
-
// Default toast width
|
|
519
|
-
const TOAST_WIDTH = 356;
|
|
520
|
-
// Default gap between toasts
|
|
521
|
-
const GAP = 14;
|
|
522
|
-
// Threshold to dismiss a toast
|
|
523
|
-
const SWIPE_THRESHOLD = 45;
|
|
524
|
-
// Equal to exit animation duration
|
|
525
|
-
const TIME_BEFORE_UNMOUNT = 200;
|
|
526
|
-
function cn(...classes) {
|
|
527
|
-
return classes.filter(Boolean).join(' ');
|
|
528
|
-
}
|
|
529
|
-
function getDefaultSwipeDirections(position) {
|
|
530
|
-
const [y, x] = position.split('-');
|
|
531
|
-
const directions = [];
|
|
532
|
-
if (y) {
|
|
533
|
-
directions.push(y);
|
|
534
|
-
}
|
|
535
|
-
if (x) {
|
|
536
|
-
directions.push(x);
|
|
537
|
-
}
|
|
538
|
-
return directions;
|
|
539
|
-
}
|
|
540
|
-
const Toast = (props)=>{
|
|
541
|
-
var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
|
|
542
|
-
const { invert: ToasterInvert, toast, unstyled, interacting, setHeights, visibleToasts, heights, index, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = '', descriptionClassName = '', duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = 'Close toast' } = props;
|
|
543
|
-
const [swipeDirection, setSwipeDirection] = React__namespace.default.useState(null);
|
|
544
|
-
const [swipeOutDirection, setSwipeOutDirection] = React__namespace.default.useState(null);
|
|
545
|
-
const [mounted, setMounted] = React__namespace.default.useState(false);
|
|
546
|
-
const [removed, setRemoved] = React__namespace.default.useState(false);
|
|
547
|
-
const [swiping, setSwiping] = React__namespace.default.useState(false);
|
|
548
|
-
const [swipeOut, setSwipeOut] = React__namespace.default.useState(false);
|
|
549
|
-
const [isSwiped, setIsSwiped] = React__namespace.default.useState(false);
|
|
550
|
-
const [offsetBeforeRemove, setOffsetBeforeRemove] = React__namespace.default.useState(0);
|
|
551
|
-
const [initialHeight, setInitialHeight] = React__namespace.default.useState(0);
|
|
552
|
-
const remainingTime = React__namespace.default.useRef(toast.duration || durationFromToaster || TOAST_LIFETIME);
|
|
553
|
-
const dragStartTime = React__namespace.default.useRef(null);
|
|
554
|
-
const toastRef = React__namespace.default.useRef(null);
|
|
555
|
-
const isFront = index === 0;
|
|
556
|
-
const isVisible = index + 1 <= visibleToasts;
|
|
557
|
-
const toastType = toast.type;
|
|
558
|
-
const dismissible = toast.dismissible !== false;
|
|
559
|
-
const toastClassname = toast.className || '';
|
|
560
|
-
const toastDescriptionClassname = toast.descriptionClassName || '';
|
|
561
|
-
// Height index is used to calculate the offset as it gets updated before the toast array, which means we can calculate the new layout faster.
|
|
562
|
-
const heightIndex = React__namespace.default.useMemo(()=>heights.findIndex((height)=>height.toastId === toast.id) || 0, [
|
|
563
|
-
heights,
|
|
564
|
-
toast.id
|
|
565
|
-
]);
|
|
566
|
-
const closeButton = React__namespace.default.useMemo(()=>{
|
|
567
|
-
var _toast_closeButton;
|
|
568
|
-
return (_toast_closeButton = toast.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
|
|
569
|
-
}, [
|
|
570
|
-
toast.closeButton,
|
|
571
|
-
closeButtonFromToaster
|
|
572
|
-
]);
|
|
573
|
-
const duration = React__namespace.default.useMemo(()=>toast.duration || durationFromToaster || TOAST_LIFETIME, [
|
|
574
|
-
toast.duration,
|
|
575
|
-
durationFromToaster
|
|
576
|
-
]);
|
|
577
|
-
const closeTimerStartTimeRef = React__namespace.default.useRef(0);
|
|
578
|
-
const offset = React__namespace.default.useRef(0);
|
|
579
|
-
const lastCloseTimerStartTimeRef = React__namespace.default.useRef(0);
|
|
580
|
-
const pointerStartRef = React__namespace.default.useRef(null);
|
|
581
|
-
const [y, x] = position.split('-');
|
|
582
|
-
const toastsHeightBefore = React__namespace.default.useMemo(()=>{
|
|
583
|
-
return heights.reduce((prev, curr, reducerIndex)=>{
|
|
584
|
-
// Calculate offset up until current toast
|
|
585
|
-
if (reducerIndex >= heightIndex) {
|
|
586
|
-
return prev;
|
|
587
|
-
}
|
|
588
|
-
return prev + curr.height;
|
|
589
|
-
}, 0);
|
|
590
|
-
}, [
|
|
591
|
-
heights,
|
|
592
|
-
heightIndex
|
|
593
|
-
]);
|
|
594
|
-
const isDocumentHidden = useIsDocumentHidden();
|
|
595
|
-
const invert = toast.invert || ToasterInvert;
|
|
596
|
-
const disabled = toastType === 'loading';
|
|
597
|
-
offset.current = React__namespace.default.useMemo(()=>heightIndex * gap + toastsHeightBefore, [
|
|
598
|
-
heightIndex,
|
|
599
|
-
toastsHeightBefore
|
|
600
|
-
]);
|
|
601
|
-
React__namespace.default.useEffect(()=>{
|
|
602
|
-
remainingTime.current = duration;
|
|
603
|
-
}, [
|
|
604
|
-
duration
|
|
605
|
-
]);
|
|
606
|
-
React__namespace.default.useEffect(()=>{
|
|
607
|
-
// Trigger enter animation without using CSS animation
|
|
608
|
-
setMounted(true);
|
|
609
|
-
}, []);
|
|
610
|
-
React__namespace.default.useEffect(()=>{
|
|
611
|
-
const toastNode = toastRef.current;
|
|
612
|
-
if (toastNode) {
|
|
613
|
-
const height = toastNode.getBoundingClientRect().height;
|
|
614
|
-
// Add toast height to heights array after the toast is mounted
|
|
615
|
-
setInitialHeight(height);
|
|
616
|
-
setHeights((h)=>[
|
|
617
|
-
{
|
|
618
|
-
toastId: toast.id,
|
|
619
|
-
height,
|
|
620
|
-
position: toast.position
|
|
621
|
-
},
|
|
622
|
-
...h
|
|
623
|
-
]);
|
|
624
|
-
return ()=>setHeights((h)=>h.filter((height)=>height.toastId !== toast.id));
|
|
625
|
-
}
|
|
626
|
-
}, [
|
|
627
|
-
setHeights,
|
|
628
|
-
toast.id
|
|
629
|
-
]);
|
|
630
|
-
React__namespace.default.useLayoutEffect(()=>{
|
|
631
|
-
// Keep height up to date with the content in case it updates
|
|
632
|
-
if (!mounted) return;
|
|
633
|
-
const toastNode = toastRef.current;
|
|
634
|
-
const originalHeight = toastNode.style.height;
|
|
635
|
-
toastNode.style.height = 'auto';
|
|
636
|
-
const newHeight = toastNode.getBoundingClientRect().height;
|
|
637
|
-
toastNode.style.height = originalHeight;
|
|
638
|
-
setInitialHeight(newHeight);
|
|
639
|
-
setHeights((heights)=>{
|
|
640
|
-
const alreadyExists = heights.find((height)=>height.toastId === toast.id);
|
|
641
|
-
if (!alreadyExists) {
|
|
642
|
-
return [
|
|
643
|
-
{
|
|
644
|
-
toastId: toast.id,
|
|
645
|
-
height: newHeight,
|
|
646
|
-
position: toast.position
|
|
647
|
-
},
|
|
648
|
-
...heights
|
|
649
|
-
];
|
|
650
|
-
} else {
|
|
651
|
-
return heights.map((height)=>height.toastId === toast.id ? {
|
|
652
|
-
...height,
|
|
653
|
-
height: newHeight
|
|
654
|
-
} : height);
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
}, [
|
|
658
|
-
mounted,
|
|
659
|
-
toast.title,
|
|
660
|
-
toast.description,
|
|
661
|
-
setHeights,
|
|
662
|
-
toast.id,
|
|
663
|
-
toast.jsx,
|
|
664
|
-
toast.action,
|
|
665
|
-
toast.cancel
|
|
666
|
-
]);
|
|
667
|
-
const deleteToast = React__namespace.default.useCallback(()=>{
|
|
668
|
-
// Save the offset for the exit swipe animation
|
|
669
|
-
setRemoved(true);
|
|
670
|
-
setOffsetBeforeRemove(offset.current);
|
|
671
|
-
setHeights((h)=>h.filter((height)=>height.toastId !== toast.id));
|
|
672
|
-
setTimeout(()=>{
|
|
673
|
-
removeToast(toast);
|
|
674
|
-
}, TIME_BEFORE_UNMOUNT);
|
|
675
|
-
}, [
|
|
676
|
-
toast,
|
|
677
|
-
removeToast,
|
|
678
|
-
setHeights,
|
|
679
|
-
offset
|
|
680
|
-
]);
|
|
681
|
-
React__namespace.default.useEffect(()=>{
|
|
682
|
-
if (toast.promise && toastType === 'loading' || toast.duration === Infinity || toast.type === 'loading') return;
|
|
683
|
-
let timeoutId;
|
|
684
|
-
// Pause the timer on each hover
|
|
685
|
-
const pauseTimer = ()=>{
|
|
686
|
-
if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
|
|
687
|
-
// Get the elapsed time since the timer started
|
|
688
|
-
const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current;
|
|
689
|
-
remainingTime.current = remainingTime.current - elapsedTime;
|
|
690
|
-
}
|
|
691
|
-
lastCloseTimerStartTimeRef.current = new Date().getTime();
|
|
692
|
-
};
|
|
693
|
-
const startTimer = ()=>{
|
|
694
|
-
// setTimeout(, Infinity) behaves as if the delay is 0.
|
|
695
|
-
// As a result, the toast would be closed immediately, giving the appearance that it was never rendered.
|
|
696
|
-
// See: https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#an-infinite-timeout
|
|
697
|
-
if (remainingTime.current === Infinity) return;
|
|
698
|
-
closeTimerStartTimeRef.current = new Date().getTime();
|
|
699
|
-
// Let the toast know it has started
|
|
700
|
-
timeoutId = setTimeout(()=>{
|
|
701
|
-
toast.onAutoClose == null ? void 0 : toast.onAutoClose.call(toast, toast);
|
|
702
|
-
deleteToast();
|
|
703
|
-
}, remainingTime.current);
|
|
704
|
-
};
|
|
705
|
-
if (expanded || interacting || isDocumentHidden) {
|
|
706
|
-
pauseTimer();
|
|
707
|
-
} else {
|
|
708
|
-
startTimer();
|
|
709
|
-
}
|
|
710
|
-
return ()=>clearTimeout(timeoutId);
|
|
711
|
-
}, [
|
|
712
|
-
expanded,
|
|
713
|
-
interacting,
|
|
714
|
-
toast,
|
|
715
|
-
toastType,
|
|
716
|
-
isDocumentHidden,
|
|
717
|
-
deleteToast
|
|
718
|
-
]);
|
|
719
|
-
React__namespace.default.useEffect(()=>{
|
|
720
|
-
if (toast.delete) {
|
|
721
|
-
deleteToast();
|
|
722
|
-
toast.onDismiss == null ? void 0 : toast.onDismiss.call(toast, toast);
|
|
723
|
-
}
|
|
724
|
-
}, [
|
|
725
|
-
deleteToast,
|
|
726
|
-
toast.delete
|
|
727
|
-
]);
|
|
728
|
-
function getLoadingIcon() {
|
|
729
|
-
var _toast_classNames;
|
|
730
|
-
if (icons == null ? void 0 : icons.loading) {
|
|
731
|
-
var _toast_classNames1;
|
|
732
|
-
return /*#__PURE__*/ React__namespace.default.createElement("div", {
|
|
733
|
-
className: cn(classNames == null ? void 0 : classNames.loader, toast == null ? void 0 : (_toast_classNames1 = toast.classNames) == null ? void 0 : _toast_classNames1.loader, 'sonner-loader'),
|
|
734
|
-
"data-visible": toastType === 'loading'
|
|
735
|
-
}, icons.loading);
|
|
736
|
-
}
|
|
737
|
-
return /*#__PURE__*/ React__namespace.default.createElement(Loader, {
|
|
738
|
-
className: cn(classNames == null ? void 0 : classNames.loader, toast == null ? void 0 : (_toast_classNames = toast.classNames) == null ? void 0 : _toast_classNames.loader),
|
|
739
|
-
visible: toastType === 'loading'
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
const icon = toast.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
|
|
743
|
-
var _toast_richColors, _icons_close;
|
|
744
|
-
return /*#__PURE__*/ React__namespace.default.createElement("li", {
|
|
745
|
-
tabIndex: 0,
|
|
746
|
-
ref: toastRef,
|
|
747
|
-
className: cn(className, toastClassname, classNames == null ? void 0 : classNames.toast, toast == null ? void 0 : (_toast_classNames = toast.classNames) == null ? void 0 : _toast_classNames.toast, classNames == null ? void 0 : classNames.default, classNames == null ? void 0 : classNames[toastType], toast == null ? void 0 : (_toast_classNames1 = toast.classNames) == null ? void 0 : _toast_classNames1[toastType]),
|
|
748
|
-
"data-sonner-toast": "",
|
|
749
|
-
"data-rich-colors": (_toast_richColors = toast.richColors) != null ? _toast_richColors : defaultRichColors,
|
|
750
|
-
"data-styled": !Boolean(toast.jsx || toast.unstyled || unstyled),
|
|
751
|
-
"data-mounted": mounted,
|
|
752
|
-
"data-promise": Boolean(toast.promise),
|
|
753
|
-
"data-swiped": isSwiped,
|
|
754
|
-
"data-removed": removed,
|
|
755
|
-
"data-visible": isVisible,
|
|
756
|
-
"data-y-position": y,
|
|
757
|
-
"data-x-position": x,
|
|
758
|
-
"data-index": index,
|
|
759
|
-
"data-front": isFront,
|
|
760
|
-
"data-swiping": swiping,
|
|
761
|
-
"data-dismissible": dismissible,
|
|
762
|
-
"data-type": toastType,
|
|
763
|
-
"data-invert": invert,
|
|
764
|
-
"data-swipe-out": swipeOut,
|
|
765
|
-
"data-swipe-direction": swipeOutDirection,
|
|
766
|
-
"data-expanded": Boolean(expanded || expandByDefault && mounted),
|
|
767
|
-
"data-testid": toast.testId,
|
|
768
|
-
style: {
|
|
769
|
-
'--index': index,
|
|
770
|
-
'--toasts-before': index,
|
|
771
|
-
'--z-index': toasts.length - index,
|
|
772
|
-
'--offset': `${removed ? offsetBeforeRemove : offset.current}px`,
|
|
773
|
-
'--initial-height': expandByDefault ? 'auto' : `${initialHeight}px`,
|
|
774
|
-
...style,
|
|
775
|
-
...toast.style
|
|
776
|
-
},
|
|
777
|
-
onDragEnd: ()=>{
|
|
778
|
-
setSwiping(false);
|
|
779
|
-
setSwipeDirection(null);
|
|
780
|
-
pointerStartRef.current = null;
|
|
781
|
-
},
|
|
782
|
-
onPointerDown: (event)=>{
|
|
783
|
-
if (event.button === 2) return; // Return early on right click
|
|
784
|
-
if (disabled || !dismissible) return;
|
|
785
|
-
dragStartTime.current = new Date();
|
|
786
|
-
setOffsetBeforeRemove(offset.current);
|
|
787
|
-
// Ensure we maintain correct pointer capture even when going outside of the toast (e.g. when swiping)
|
|
788
|
-
event.target.setPointerCapture(event.pointerId);
|
|
789
|
-
if (event.target.tagName === 'BUTTON') return;
|
|
790
|
-
setSwiping(true);
|
|
791
|
-
pointerStartRef.current = {
|
|
792
|
-
x: event.clientX,
|
|
793
|
-
y: event.clientY
|
|
794
|
-
};
|
|
795
|
-
},
|
|
796
|
-
onPointerUp: ()=>{
|
|
797
|
-
var _toastRef_current, _toastRef_current1, _dragStartTime_current;
|
|
798
|
-
if (swipeOut || !dismissible) return;
|
|
799
|
-
pointerStartRef.current = null;
|
|
800
|
-
const swipeAmountX = Number(((_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.getPropertyValue('--swipe-amount-x').replace('px', '')) || 0);
|
|
801
|
-
const swipeAmountY = Number(((_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.getPropertyValue('--swipe-amount-y').replace('px', '')) || 0);
|
|
802
|
-
const timeTaken = new Date().getTime() - ((_dragStartTime_current = dragStartTime.current) == null ? void 0 : _dragStartTime_current.getTime());
|
|
803
|
-
const swipeAmount = swipeDirection === 'x' ? swipeAmountX : swipeAmountY;
|
|
804
|
-
const velocity = Math.abs(swipeAmount) / timeTaken;
|
|
805
|
-
if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
|
|
806
|
-
setOffsetBeforeRemove(offset.current);
|
|
807
|
-
toast.onDismiss == null ? void 0 : toast.onDismiss.call(toast, toast);
|
|
808
|
-
if (swipeDirection === 'x') {
|
|
809
|
-
setSwipeOutDirection(swipeAmountX > 0 ? 'right' : 'left');
|
|
810
|
-
} else {
|
|
811
|
-
setSwipeOutDirection(swipeAmountY > 0 ? 'down' : 'up');
|
|
812
|
-
}
|
|
813
|
-
deleteToast();
|
|
814
|
-
setSwipeOut(true);
|
|
815
|
-
return;
|
|
816
|
-
} else {
|
|
817
|
-
var _toastRef_current2, _toastRef_current3;
|
|
818
|
-
(_toastRef_current2 = toastRef.current) == null ? void 0 : _toastRef_current2.style.setProperty('--swipe-amount-x', `0px`);
|
|
819
|
-
(_toastRef_current3 = toastRef.current) == null ? void 0 : _toastRef_current3.style.setProperty('--swipe-amount-y', `0px`);
|
|
820
|
-
}
|
|
821
|
-
setIsSwiped(false);
|
|
822
|
-
setSwiping(false);
|
|
823
|
-
setSwipeDirection(null);
|
|
824
|
-
},
|
|
825
|
-
onPointerMove: (event)=>{
|
|
826
|
-
var _window_getSelection, // Apply transform using both x and y values
|
|
827
|
-
_toastRef_current, _toastRef_current1;
|
|
828
|
-
if (!pointerStartRef.current || !dismissible) return;
|
|
829
|
-
const isHighlighted = ((_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString().length) > 0;
|
|
830
|
-
if (isHighlighted) return;
|
|
831
|
-
const yDelta = event.clientY - pointerStartRef.current.y;
|
|
832
|
-
const xDelta = event.clientX - pointerStartRef.current.x;
|
|
833
|
-
var _props_swipeDirections;
|
|
834
|
-
const swipeDirections = (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
|
|
835
|
-
// Determine swipe direction if not already locked
|
|
836
|
-
if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {
|
|
837
|
-
setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? 'x' : 'y');
|
|
838
|
-
}
|
|
839
|
-
let swipeAmount = {
|
|
840
|
-
x: 0,
|
|
841
|
-
y: 0
|
|
842
|
-
};
|
|
843
|
-
const getDampening = (delta)=>{
|
|
844
|
-
const factor = Math.abs(delta) / 20;
|
|
845
|
-
return 1 / (1.5 + factor);
|
|
846
|
-
};
|
|
847
|
-
// Only apply swipe in the locked direction
|
|
848
|
-
if (swipeDirection === 'y') {
|
|
849
|
-
// Handle vertical swipes
|
|
850
|
-
if (swipeDirections.includes('top') || swipeDirections.includes('bottom')) {
|
|
851
|
-
if (swipeDirections.includes('top') && yDelta < 0 || swipeDirections.includes('bottom') && yDelta > 0) {
|
|
852
|
-
swipeAmount.y = yDelta;
|
|
853
|
-
} else {
|
|
854
|
-
// Smoothly transition to dampened movement
|
|
855
|
-
const dampenedDelta = yDelta * getDampening(yDelta);
|
|
856
|
-
// Ensure we don't jump when transitioning to dampened movement
|
|
857
|
-
swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
} else if (swipeDirection === 'x') {
|
|
861
|
-
// Handle horizontal swipes
|
|
862
|
-
if (swipeDirections.includes('left') || swipeDirections.includes('right')) {
|
|
863
|
-
if (swipeDirections.includes('left') && xDelta < 0 || swipeDirections.includes('right') && xDelta > 0) {
|
|
864
|
-
swipeAmount.x = xDelta;
|
|
865
|
-
} else {
|
|
866
|
-
// Smoothly transition to dampened movement
|
|
867
|
-
const dampenedDelta = xDelta * getDampening(xDelta);
|
|
868
|
-
// Ensure we don't jump when transitioning to dampened movement
|
|
869
|
-
swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) {
|
|
874
|
-
setIsSwiped(true);
|
|
875
|
-
}
|
|
876
|
-
(_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.setProperty('--swipe-amount-x', `${swipeAmount.x}px`);
|
|
877
|
-
(_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.setProperty('--swipe-amount-y', `${swipeAmount.y}px`);
|
|
878
|
-
}
|
|
879
|
-
}, closeButton && !toast.jsx && toastType !== 'loading' ? /*#__PURE__*/ React__namespace.default.createElement("button", {
|
|
880
|
-
"aria-label": closeButtonAriaLabel,
|
|
881
|
-
"data-disabled": disabled,
|
|
882
|
-
"data-close-button": true,
|
|
883
|
-
onClick: disabled || !dismissible ? ()=>{} : ()=>{
|
|
884
|
-
deleteToast();
|
|
885
|
-
toast.onDismiss == null ? void 0 : toast.onDismiss.call(toast, toast);
|
|
886
|
-
},
|
|
887
|
-
className: cn(classNames == null ? void 0 : classNames.closeButton, toast == null ? void 0 : (_toast_classNames2 = toast.classNames) == null ? void 0 : _toast_classNames2.closeButton)
|
|
888
|
-
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast.icon || toast.promise) && toast.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast.icon) ? /*#__PURE__*/ React__namespace.default.createElement("div", {
|
|
889
|
-
"data-icon": "",
|
|
890
|
-
className: cn(classNames == null ? void 0 : classNames.icon, toast == null ? void 0 : (_toast_classNames3 = toast.classNames) == null ? void 0 : _toast_classNames3.icon)
|
|
891
|
-
}, toast.promise || toast.type === 'loading' && !toast.icon ? toast.icon || getLoadingIcon() : null, toast.type !== 'loading' ? icon : null) : null, /*#__PURE__*/ React__namespace.default.createElement("div", {
|
|
892
|
-
"data-content": "",
|
|
893
|
-
className: cn(classNames == null ? void 0 : classNames.content, toast == null ? void 0 : (_toast_classNames4 = toast.classNames) == null ? void 0 : _toast_classNames4.content)
|
|
894
|
-
}, /*#__PURE__*/ React__namespace.default.createElement("div", {
|
|
895
|
-
"data-title": "",
|
|
896
|
-
className: cn(classNames == null ? void 0 : classNames.title, toast == null ? void 0 : (_toast_classNames5 = toast.classNames) == null ? void 0 : _toast_classNames5.title)
|
|
897
|
-
}, toast.jsx ? toast.jsx : typeof toast.title === 'function' ? toast.title() : toast.title), toast.description ? /*#__PURE__*/ React__namespace.default.createElement("div", {
|
|
898
|
-
"data-description": "",
|
|
899
|
-
className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description, toast == null ? void 0 : (_toast_classNames6 = toast.classNames) == null ? void 0 : _toast_classNames6.description)
|
|
900
|
-
}, typeof toast.description === 'function' ? toast.description() : toast.description) : null), /*#__PURE__*/ React__namespace.default.isValidElement(toast.cancel) ? toast.cancel : toast.cancel && isAction(toast.cancel) ? /*#__PURE__*/ React__namespace.default.createElement("button", {
|
|
901
|
-
"data-button": true,
|
|
902
|
-
"data-cancel": true,
|
|
903
|
-
style: toast.cancelButtonStyle || cancelButtonStyle,
|
|
904
|
-
onClick: (event)=>{
|
|
905
|
-
// We need to check twice because typescript
|
|
906
|
-
if (!isAction(toast.cancel)) return;
|
|
907
|
-
if (!dismissible) return;
|
|
908
|
-
toast.cancel.onClick == null ? void 0 : toast.cancel.onClick.call(toast.cancel, event);
|
|
909
|
-
deleteToast();
|
|
910
|
-
},
|
|
911
|
-
className: cn(classNames == null ? void 0 : classNames.cancelButton, toast == null ? void 0 : (_toast_classNames7 = toast.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
|
|
912
|
-
}, toast.cancel.label) : null, /*#__PURE__*/ React__namespace.default.isValidElement(toast.action) ? toast.action : toast.action && isAction(toast.action) ? /*#__PURE__*/ React__namespace.default.createElement("button", {
|
|
913
|
-
"data-button": true,
|
|
914
|
-
"data-action": true,
|
|
915
|
-
style: toast.actionButtonStyle || actionButtonStyle,
|
|
916
|
-
onClick: (event)=>{
|
|
917
|
-
// We need to check twice because typescript
|
|
918
|
-
if (!isAction(toast.action)) return;
|
|
919
|
-
toast.action.onClick == null ? void 0 : toast.action.onClick.call(toast.action, event);
|
|
920
|
-
if (event.defaultPrevented) return;
|
|
921
|
-
deleteToast();
|
|
922
|
-
},
|
|
923
|
-
className: cn(classNames == null ? void 0 : classNames.actionButton, toast == null ? void 0 : (_toast_classNames8 = toast.classNames) == null ? void 0 : _toast_classNames8.actionButton)
|
|
924
|
-
}, toast.action.label) : null);
|
|
925
|
-
};
|
|
926
|
-
function getDocumentDirection() {
|
|
927
|
-
if (typeof window === 'undefined') return 'ltr';
|
|
928
|
-
if (typeof document === 'undefined') return 'ltr'; // For Fresh purpose
|
|
929
|
-
const dirAttribute = document.documentElement.getAttribute('dir');
|
|
930
|
-
if (dirAttribute === 'auto' || !dirAttribute) {
|
|
931
|
-
return window.getComputedStyle(document.documentElement).direction;
|
|
932
|
-
}
|
|
933
|
-
return dirAttribute;
|
|
934
|
-
}
|
|
935
|
-
function assignOffset(defaultOffset, mobileOffset) {
|
|
936
|
-
const styles = {};
|
|
937
|
-
[
|
|
938
|
-
defaultOffset,
|
|
939
|
-
mobileOffset
|
|
940
|
-
].forEach((offset, index)=>{
|
|
941
|
-
const isMobile = index === 1;
|
|
942
|
-
const prefix = isMobile ? '--mobile-offset' : '--offset';
|
|
943
|
-
const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
|
|
944
|
-
function assignAll(offset) {
|
|
945
|
-
[
|
|
946
|
-
'top',
|
|
947
|
-
'right',
|
|
948
|
-
'bottom',
|
|
949
|
-
'left'
|
|
950
|
-
].forEach((key)=>{
|
|
951
|
-
styles[`${prefix}-${key}`] = typeof offset === 'number' ? `${offset}px` : offset;
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
if (typeof offset === 'number' || typeof offset === 'string') {
|
|
955
|
-
assignAll(offset);
|
|
956
|
-
} else if (typeof offset === 'object') {
|
|
957
|
-
[
|
|
958
|
-
'top',
|
|
959
|
-
'right',
|
|
960
|
-
'bottom',
|
|
961
|
-
'left'
|
|
962
|
-
].forEach((key)=>{
|
|
963
|
-
if (offset[key] === undefined) {
|
|
964
|
-
styles[`${prefix}-${key}`] = defaultValue;
|
|
965
|
-
} else {
|
|
966
|
-
styles[`${prefix}-${key}`] = typeof offset[key] === 'number' ? `${offset[key]}px` : offset[key];
|
|
967
|
-
}
|
|
968
|
-
});
|
|
969
|
-
} else {
|
|
970
|
-
assignAll(defaultValue);
|
|
971
|
-
}
|
|
972
|
-
});
|
|
973
|
-
return styles;
|
|
974
|
-
}
|
|
975
|
-
const Toaster$2 = /*#__PURE__*/ React__namespace.default.forwardRef(function Toaster(props, ref) {
|
|
976
|
-
const { id, invert, position = 'bottom-right', hotkey = [
|
|
977
|
-
'altKey',
|
|
978
|
-
'KeyT'
|
|
979
|
-
], expand, closeButton, className, offset, mobileOffset, theme = 'light', richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, containerAriaLabel = 'Notifications' } = props;
|
|
980
|
-
const [toasts, setToasts] = React__namespace.default.useState([]);
|
|
981
|
-
const filteredToasts = React__namespace.default.useMemo(()=>{
|
|
982
|
-
if (id) {
|
|
983
|
-
return toasts.filter((toast)=>toast.toasterId === id);
|
|
984
|
-
}
|
|
985
|
-
return toasts.filter((toast)=>!toast.toasterId);
|
|
986
|
-
}, [
|
|
987
|
-
toasts,
|
|
988
|
-
id
|
|
989
|
-
]);
|
|
990
|
-
const possiblePositions = React__namespace.default.useMemo(()=>{
|
|
991
|
-
return Array.from(new Set([
|
|
992
|
-
position
|
|
993
|
-
].concat(filteredToasts.filter((toast)=>toast.position).map((toast)=>toast.position))));
|
|
994
|
-
}, [
|
|
995
|
-
filteredToasts,
|
|
996
|
-
position
|
|
997
|
-
]);
|
|
998
|
-
const [heights, setHeights] = React__namespace.default.useState([]);
|
|
999
|
-
const [expanded, setExpanded] = React__namespace.default.useState(false);
|
|
1000
|
-
const [interacting, setInteracting] = React__namespace.default.useState(false);
|
|
1001
|
-
const [actualTheme, setActualTheme] = React__namespace.default.useState(theme !== 'system' ? theme : typeof window !== 'undefined' ? window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' : 'light');
|
|
1002
|
-
const listRef = React__namespace.default.useRef(null);
|
|
1003
|
-
const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');
|
|
1004
|
-
const lastFocusedElementRef = React__namespace.default.useRef(null);
|
|
1005
|
-
const isFocusWithinRef = React__namespace.default.useRef(false);
|
|
1006
|
-
const removeToast = React__namespace.default.useCallback((toastToRemove)=>{
|
|
1007
|
-
setToasts((toasts)=>{
|
|
1008
|
-
var _toasts_find;
|
|
1009
|
-
if (!((_toasts_find = toasts.find((toast)=>toast.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) {
|
|
1010
|
-
ToastState.dismiss(toastToRemove.id);
|
|
1011
|
-
}
|
|
1012
|
-
return toasts.filter(({ id })=>id !== toastToRemove.id);
|
|
1013
|
-
});
|
|
1014
|
-
}, []);
|
|
1015
|
-
React__namespace.default.useEffect(()=>{
|
|
1016
|
-
return ToastState.subscribe((toast)=>{
|
|
1017
|
-
if (toast.dismiss) {
|
|
1018
|
-
// Prevent batching of other state updates
|
|
1019
|
-
requestAnimationFrame(()=>{
|
|
1020
|
-
setToasts((toasts)=>toasts.map((t)=>t.id === toast.id ? {
|
|
1021
|
-
...t,
|
|
1022
|
-
delete: true
|
|
1023
|
-
} : t));
|
|
1024
|
-
});
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
// Prevent batching, temp solution.
|
|
1028
|
-
setTimeout(()=>{
|
|
1029
|
-
ReactDOM__default.default.flushSync(()=>{
|
|
1030
|
-
setToasts((toasts)=>{
|
|
1031
|
-
const indexOfExistingToast = toasts.findIndex((t)=>t.id === toast.id);
|
|
1032
|
-
// Update the toast if it already exists
|
|
1033
|
-
if (indexOfExistingToast !== -1) {
|
|
1034
|
-
return [
|
|
1035
|
-
...toasts.slice(0, indexOfExistingToast),
|
|
1036
|
-
{
|
|
1037
|
-
...toasts[indexOfExistingToast],
|
|
1038
|
-
...toast
|
|
1039
|
-
},
|
|
1040
|
-
...toasts.slice(indexOfExistingToast + 1)
|
|
1041
|
-
];
|
|
1042
|
-
}
|
|
1043
|
-
return [
|
|
1044
|
-
toast,
|
|
1045
|
-
...toasts
|
|
1046
|
-
];
|
|
1047
|
-
});
|
|
1048
|
-
});
|
|
1049
|
-
});
|
|
1050
|
-
});
|
|
1051
|
-
}, [
|
|
1052
|
-
toasts
|
|
1053
|
-
]);
|
|
1054
|
-
React__namespace.default.useEffect(()=>{
|
|
1055
|
-
if (theme !== 'system') {
|
|
1056
|
-
setActualTheme(theme);
|
|
1057
|
-
return;
|
|
1058
|
-
}
|
|
1059
|
-
if (theme === 'system') {
|
|
1060
|
-
// check if current preference is dark
|
|
1061
|
-
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
1062
|
-
// it's currently dark
|
|
1063
|
-
setActualTheme('dark');
|
|
1064
|
-
} else {
|
|
1065
|
-
// it's not dark
|
|
1066
|
-
setActualTheme('light');
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
if (typeof window === 'undefined') return;
|
|
1070
|
-
const darkMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
1071
|
-
try {
|
|
1072
|
-
// Chrome & Firefox
|
|
1073
|
-
darkMediaQuery.addEventListener('change', ({ matches })=>{
|
|
1074
|
-
if (matches) {
|
|
1075
|
-
setActualTheme('dark');
|
|
1076
|
-
} else {
|
|
1077
|
-
setActualTheme('light');
|
|
1078
|
-
}
|
|
1079
|
-
});
|
|
1080
|
-
} catch (error) {
|
|
1081
|
-
// Safari < 14
|
|
1082
|
-
darkMediaQuery.addListener(({ matches })=>{
|
|
1083
|
-
try {
|
|
1084
|
-
if (matches) {
|
|
1085
|
-
setActualTheme('dark');
|
|
1086
|
-
} else {
|
|
1087
|
-
setActualTheme('light');
|
|
1088
|
-
}
|
|
1089
|
-
} catch (e) {
|
|
1090
|
-
console.error(e);
|
|
1091
|
-
}
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
|
-
}, [
|
|
1095
|
-
theme
|
|
1096
|
-
]);
|
|
1097
|
-
React__namespace.default.useEffect(()=>{
|
|
1098
|
-
// Ensure expanded is always false when no toasts are present / only one left
|
|
1099
|
-
if (toasts.length <= 1) {
|
|
1100
|
-
setExpanded(false);
|
|
1101
|
-
}
|
|
1102
|
-
}, [
|
|
1103
|
-
toasts
|
|
1104
|
-
]);
|
|
1105
|
-
React__namespace.default.useEffect(()=>{
|
|
1106
|
-
const handleKeyDown = (event)=>{
|
|
1107
|
-
var _listRef_current;
|
|
1108
|
-
const isHotkeyPressed = hotkey.every((key)=>event[key] || event.code === key);
|
|
1109
|
-
if (isHotkeyPressed) {
|
|
1110
|
-
var _listRef_current1;
|
|
1111
|
-
setExpanded(true);
|
|
1112
|
-
(_listRef_current1 = listRef.current) == null ? void 0 : _listRef_current1.focus();
|
|
1113
|
-
}
|
|
1114
|
-
if (event.code === 'Escape' && (document.activeElement === listRef.current || ((_listRef_current = listRef.current) == null ? void 0 : _listRef_current.contains(document.activeElement)))) {
|
|
1115
|
-
setExpanded(false);
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1118
|
-
document.addEventListener('keydown', handleKeyDown);
|
|
1119
|
-
return ()=>document.removeEventListener('keydown', handleKeyDown);
|
|
1120
|
-
}, [
|
|
1121
|
-
hotkey
|
|
1122
|
-
]);
|
|
1123
|
-
React__namespace.default.useEffect(()=>{
|
|
1124
|
-
if (listRef.current) {
|
|
1125
|
-
return ()=>{
|
|
1126
|
-
if (lastFocusedElementRef.current) {
|
|
1127
|
-
lastFocusedElementRef.current.focus({
|
|
1128
|
-
preventScroll: true
|
|
1129
|
-
});
|
|
1130
|
-
lastFocusedElementRef.current = null;
|
|
1131
|
-
isFocusWithinRef.current = false;
|
|
1132
|
-
}
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
}, [
|
|
1136
|
-
listRef.current
|
|
1137
|
-
]);
|
|
1138
|
-
return(// Remove item from normal navigation flow, only available via hotkey
|
|
1139
|
-
/*#__PURE__*/ React__namespace.default.createElement("section", {
|
|
1140
|
-
ref: ref,
|
|
1141
|
-
"aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
|
|
1142
|
-
tabIndex: -1,
|
|
1143
|
-
"aria-live": "polite",
|
|
1144
|
-
"aria-relevant": "additions text",
|
|
1145
|
-
"aria-atomic": "false",
|
|
1146
|
-
suppressHydrationWarning: true
|
|
1147
|
-
}, possiblePositions.map((position, index)=>{
|
|
1148
|
-
var _heights_;
|
|
1149
|
-
const [y, x] = position.split('-');
|
|
1150
|
-
if (!filteredToasts.length) return null;
|
|
1151
|
-
return /*#__PURE__*/ React__namespace.default.createElement("ol", {
|
|
1152
|
-
key: position,
|
|
1153
|
-
dir: dir === 'auto' ? getDocumentDirection() : dir,
|
|
1154
|
-
tabIndex: -1,
|
|
1155
|
-
ref: listRef,
|
|
1156
|
-
className: className,
|
|
1157
|
-
"data-sonner-toaster": true,
|
|
1158
|
-
"data-sonner-theme": actualTheme,
|
|
1159
|
-
"data-y-position": y,
|
|
1160
|
-
"data-x-position": x,
|
|
1161
|
-
style: {
|
|
1162
|
-
'--front-toast-height': `${((_heights_ = heights[0]) == null ? void 0 : _heights_.height) || 0}px`,
|
|
1163
|
-
'--width': `${TOAST_WIDTH}px`,
|
|
1164
|
-
'--gap': `${gap}px`,
|
|
1165
|
-
...style,
|
|
1166
|
-
...assignOffset(offset, mobileOffset)
|
|
1167
|
-
},
|
|
1168
|
-
onBlur: (event)=>{
|
|
1169
|
-
if (isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget)) {
|
|
1170
|
-
isFocusWithinRef.current = false;
|
|
1171
|
-
if (lastFocusedElementRef.current) {
|
|
1172
|
-
lastFocusedElementRef.current.focus({
|
|
1173
|
-
preventScroll: true
|
|
1174
|
-
});
|
|
1175
|
-
lastFocusedElementRef.current = null;
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
},
|
|
1179
|
-
onFocus: (event)=>{
|
|
1180
|
-
const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === 'false';
|
|
1181
|
-
if (isNotDismissible) return;
|
|
1182
|
-
if (!isFocusWithinRef.current) {
|
|
1183
|
-
isFocusWithinRef.current = true;
|
|
1184
|
-
lastFocusedElementRef.current = event.relatedTarget;
|
|
1185
|
-
}
|
|
1186
|
-
},
|
|
1187
|
-
onMouseEnter: ()=>setExpanded(true),
|
|
1188
|
-
onMouseMove: ()=>setExpanded(true),
|
|
1189
|
-
onMouseLeave: ()=>{
|
|
1190
|
-
// Avoid setting expanded to false when interacting with a toast, e.g. swiping
|
|
1191
|
-
if (!interacting) {
|
|
1192
|
-
setExpanded(false);
|
|
1193
|
-
}
|
|
1194
|
-
},
|
|
1195
|
-
onDragEnd: ()=>setExpanded(false),
|
|
1196
|
-
onPointerDown: (event)=>{
|
|
1197
|
-
const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === 'false';
|
|
1198
|
-
if (isNotDismissible) return;
|
|
1199
|
-
setInteracting(true);
|
|
1200
|
-
},
|
|
1201
|
-
onPointerUp: ()=>setInteracting(false)
|
|
1202
|
-
}, filteredToasts.filter((toast)=>!toast.position && index === 0 || toast.position === position).map((toast, index)=>{
|
|
1203
|
-
var _toastOptions_duration, _toastOptions_closeButton;
|
|
1204
|
-
return /*#__PURE__*/ React__namespace.default.createElement(Toast, {
|
|
1205
|
-
key: toast.id,
|
|
1206
|
-
icons: icons,
|
|
1207
|
-
index: index,
|
|
1208
|
-
toast: toast,
|
|
1209
|
-
defaultRichColors: richColors,
|
|
1210
|
-
duration: (_toastOptions_duration = toastOptions == null ? void 0 : toastOptions.duration) != null ? _toastOptions_duration : duration,
|
|
1211
|
-
className: toastOptions == null ? void 0 : toastOptions.className,
|
|
1212
|
-
descriptionClassName: toastOptions == null ? void 0 : toastOptions.descriptionClassName,
|
|
1213
|
-
invert: invert,
|
|
1214
|
-
visibleToasts: visibleToasts,
|
|
1215
|
-
closeButton: (_toastOptions_closeButton = toastOptions == null ? void 0 : toastOptions.closeButton) != null ? _toastOptions_closeButton : closeButton,
|
|
1216
|
-
interacting: interacting,
|
|
1217
|
-
position: position,
|
|
1218
|
-
style: toastOptions == null ? void 0 : toastOptions.style,
|
|
1219
|
-
unstyled: toastOptions == null ? void 0 : toastOptions.unstyled,
|
|
1220
|
-
classNames: toastOptions == null ? void 0 : toastOptions.classNames,
|
|
1221
|
-
cancelButtonStyle: toastOptions == null ? void 0 : toastOptions.cancelButtonStyle,
|
|
1222
|
-
actionButtonStyle: toastOptions == null ? void 0 : toastOptions.actionButtonStyle,
|
|
1223
|
-
closeButtonAriaLabel: toastOptions == null ? void 0 : toastOptions.closeButtonAriaLabel,
|
|
1224
|
-
removeToast: removeToast,
|
|
1225
|
-
toasts: filteredToasts.filter((t)=>t.position == toast.position),
|
|
1226
|
-
heights: heights.filter((h)=>h.position == toast.position),
|
|
1227
|
-
setHeights: setHeights,
|
|
1228
|
-
expandByDefault: expand,
|
|
1229
|
-
gap: gap,
|
|
1230
|
-
expanded: expanded,
|
|
1231
|
-
swipeDirections: props.swipeDirections
|
|
1232
|
-
});
|
|
1233
|
-
}));
|
|
1234
|
-
})));
|
|
1235
|
-
});
|
|
1236
|
-
|
|
1237
103
|
const Toaster$1 = ({ ...props }) => {
|
|
1238
104
|
const { theme = "system" } = z();
|
|
1239
|
-
return (jsxRuntime.jsx(Toaster
|
|
105
|
+
return (jsxRuntime.jsx(index.Toaster, { theme: theme, className: "toaster group", icons: {
|
|
1240
106
|
success: (jsxRuntime.jsx(CircleCheck, { className: "size-4" })),
|
|
1241
107
|
info: (jsxRuntime.jsx(Info, { className: "size-4" })),
|
|
1242
108
|
warning: (jsxRuntime.jsx(TriangleAlert, { className: "size-4" })),
|
|
@@ -1254,7 +120,15 @@ const Toaster$1 = ({ ...props }) => {
|
|
|
1254
120
|
}, ...props }));
|
|
1255
121
|
};
|
|
1256
122
|
|
|
1257
|
-
const Toaster = (props) => (jsxRuntime.jsx(Toaster$1, {
|
|
123
|
+
const Toaster = (props) => (jsxRuntime.jsx(Toaster$1, { toastOptions: {
|
|
124
|
+
classNames: {
|
|
125
|
+
toast: "cn-toast",
|
|
126
|
+
success: "!bg-success !text-success-foreground !border-success/30",
|
|
127
|
+
error: "!bg-error !text-error-foreground !border-error/30",
|
|
128
|
+
warning: "!bg-warning !text-warning-foreground !border-warning/30",
|
|
129
|
+
info: "!bg-info !text-info-foreground !border-info/30",
|
|
130
|
+
},
|
|
131
|
+
}, ...props }));
|
|
1258
132
|
|
|
1259
133
|
exports.Toaster = Toaster;
|
|
1260
134
|
//# sourceMappingURL=Sonner.js.map
|