@enigmax/primitives 0.20.0 → 0.22.0
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/chunk-WPTBURIC.js +1627 -0
- package/dist/{index-dTdAbOWl.d.ts → index-BHpOZncw.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/next/index.d.ts +5 -5
- package/dist/next/index.js +1 -1
- package/dist/react/button.d.ts +2 -2
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.js +1 -1
- package/dist/react/input.d.ts +2 -2
- package/dist/react/palette.d.ts +1 -1
- package/dist/react/search.d.ts +1 -1
- package/dist/react/slot.d.ts +2 -2
- package/dist/react/toast.d.ts +168 -34
- package/dist/react/toast.js +2 -2
- package/dist/react-router/index.d.ts +5 -5
- package/dist/react-router/index.js +1 -1
- package/dist/search/index.d.ts +2 -2
- package/dist/{search-DXxY8SEH.d.ts → search-BD9-5O5U.d.ts} +7 -2
- package/package.json +1 -1
- package/recipes/toast/styles.css +697 -128
- package/registry.json +79 -26
- package/src/core/search.ts +6 -1
- package/src/react/index.ts +2 -1
- package/src/react/toast/NOTICE +20 -0
- package/src/react/toast/assets.tsx +85 -0
- package/src/react/toast/cn.ts +10 -0
- package/src/react/toast/hooks.ts +13 -0
- package/src/react/toast/index.tsx +736 -0
- package/src/react/toast/state.ts +207 -0
- package/src/react/toast/styles.ts +738 -0
- package/src/react/toast/types.ts +193 -0
- package/src/react/toaster.tsx +97 -209
- package/dist/chunk-ZCUFYBPB.js +0 -154
package/registry.json
CHANGED
|
@@ -711,16 +711,17 @@
|
|
|
711
711
|
{
|
|
712
712
|
"name": "toast",
|
|
713
713
|
"title": "Toast",
|
|
714
|
-
"description": "The notification queue with a renderer on top:
|
|
714
|
+
"description": "The notification queue with a renderer on top: the newest toast in front, the older ones stacked behind it and fanning out when the pointer arrives, swipe to dismiss, a pointer that stops the clock, and a toast that is still on screen while it animates out. It brings its own theme - a toast at the edge of the screen is the one component a forgotten stylesheet ruins rather than merely undresses.",
|
|
715
715
|
"targets": [
|
|
716
716
|
"react"
|
|
717
717
|
],
|
|
718
718
|
"entry": {
|
|
719
|
-
"react": "@enigmax/primitives/react"
|
|
719
|
+
"react": "@enigmax/primitives/react/toast"
|
|
720
720
|
},
|
|
721
721
|
"exports": {
|
|
722
722
|
"react": [
|
|
723
723
|
"Toaster",
|
|
724
|
+
"toast",
|
|
724
725
|
"useNotifications"
|
|
725
726
|
]
|
|
726
727
|
},
|
|
@@ -743,16 +744,60 @@
|
|
|
743
744
|
}
|
|
744
745
|
},
|
|
745
746
|
{
|
|
746
|
-
"path": "src/react/
|
|
747
|
-
"dest": "toast/
|
|
748
|
-
"main": true,
|
|
747
|
+
"path": "src/react/toast/types.ts",
|
|
748
|
+
"dest": "toast/vendor/types.ts",
|
|
749
749
|
"targets": [
|
|
750
750
|
"react"
|
|
751
|
-
]
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
751
|
+
]
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
"path": "src/react/toast/hooks.ts",
|
|
755
|
+
"dest": "toast/vendor/hooks.ts",
|
|
756
|
+
"targets": [
|
|
757
|
+
"react"
|
|
758
|
+
]
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"path": "src/react/toast/cn.ts",
|
|
762
|
+
"dest": "toast/vendor/cn.ts",
|
|
763
|
+
"targets": [
|
|
764
|
+
"react"
|
|
765
|
+
]
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
"path": "src/react/toast/assets.tsx",
|
|
769
|
+
"dest": "toast/vendor/assets.tsx",
|
|
770
|
+
"targets": [
|
|
771
|
+
"react"
|
|
772
|
+
]
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
"path": "src/react/toast/state.ts",
|
|
776
|
+
"dest": "toast/vendor/state.ts",
|
|
777
|
+
"targets": [
|
|
778
|
+
"react"
|
|
779
|
+
]
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"path": "src/react/toast/styles.ts",
|
|
783
|
+
"dest": "toast/vendor/styles.ts",
|
|
784
|
+
"targets": [
|
|
785
|
+
"react"
|
|
786
|
+
]
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
"path": "src/react/toast/index.tsx",
|
|
790
|
+
"dest": "toast/vendor/index.tsx",
|
|
791
|
+
"targets": [
|
|
792
|
+
"react"
|
|
793
|
+
]
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
"path": "src/react/toast/NOTICE",
|
|
797
|
+
"dest": "toast/vendor/NOTICE",
|
|
798
|
+
"targets": [
|
|
799
|
+
"react"
|
|
800
|
+
]
|
|
756
801
|
},
|
|
757
802
|
{
|
|
758
803
|
"path": "recipes/toast/styles.css",
|
|
@@ -763,30 +808,38 @@
|
|
|
763
808
|
"style": "css"
|
|
764
809
|
},
|
|
765
810
|
{
|
|
766
|
-
"path": "
|
|
767
|
-
"dest": "toast/
|
|
811
|
+
"path": "src/react/toaster.tsx",
|
|
812
|
+
"dest": "toast/index.tsx",
|
|
813
|
+
"main": true,
|
|
768
814
|
"targets": [
|
|
769
815
|
"react"
|
|
770
816
|
],
|
|
771
|
-
"style": "tailwind",
|
|
772
817
|
"rewrite": {
|
|
773
|
-
"
|
|
818
|
+
"@/react/toast/styles": "./vendor/styles",
|
|
819
|
+
"@/react/toast/state": "./vendor/state",
|
|
820
|
+
"@/react/toast/index": "./vendor/index",
|
|
821
|
+
"@/react/toast/types": "./vendor/types",
|
|
822
|
+
"@/react/use-notifications": "./use-notifications",
|
|
823
|
+
"@/core/notifications": "./notifications"
|
|
774
824
|
}
|
|
775
825
|
}
|
|
776
826
|
],
|
|
777
|
-
"styles":
|
|
827
|
+
"styles": true,
|
|
778
828
|
"themeHooks": [
|
|
779
|
-
"[data-
|
|
780
|
-
"[data-
|
|
781
|
-
"[data-
|
|
782
|
-
"[data-
|
|
783
|
-
"[data-
|
|
784
|
-
"[data-
|
|
785
|
-
"[data-
|
|
786
|
-
"[data-
|
|
787
|
-
"[data-
|
|
788
|
-
"[data-
|
|
789
|
-
"[data-
|
|
829
|
+
"[data-toastcmp-toaster]",
|
|
830
|
+
"[data-toastcmp-toaster][data-theme]",
|
|
831
|
+
"[data-toastcmp-toaster][data-lifted]",
|
|
832
|
+
"[data-toastcmp-toast]",
|
|
833
|
+
"[data-toastcmp-toast][data-type=error]",
|
|
834
|
+
"[data-toastcmp-toast][data-front]",
|
|
835
|
+
"[data-toastcmp-toast][data-mounted]",
|
|
836
|
+
"[data-toastcmp-toast][data-removed]",
|
|
837
|
+
"[data-toastcmp-toast][data-swiping]",
|
|
838
|
+
"[data-title]",
|
|
839
|
+
"[data-description]",
|
|
840
|
+
"[data-button]",
|
|
841
|
+
"[data-close-button]",
|
|
842
|
+
"[data-icon]"
|
|
790
843
|
],
|
|
791
844
|
"docs": "docs/notes/primitives.md#toast",
|
|
792
845
|
"recipes": [
|
package/src/core/search.ts
CHANGED
|
@@ -19,7 +19,12 @@ export interface SearchMatch<T> {
|
|
|
19
19
|
|
|
20
20
|
/** The shape of Fuse's constructor, declared here so the package need not depend on it. */
|
|
21
21
|
export interface FuseLike<T> {
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Readonly arrays, because Fuse's own signature returns them - and a mutable array is
|
|
24
|
+
* not assignable to one, so the stricter shape made `fuse={Fuse}` a type error at the
|
|
25
|
+
* call site while working perfectly at runtime.
|
|
26
|
+
*/
|
|
27
|
+
search(query: string): readonly { item: T; score?: number; matches?: readonly { key?: string; }[]; }[];
|
|
23
28
|
}
|
|
24
29
|
export type FuseConstructor = new <T>(items: readonly T[], options?: Record<string, unknown>) => FuseLike<T>;
|
|
25
30
|
|
package/src/react/index.ts
CHANGED
|
@@ -36,7 +36,8 @@ export {
|
|
|
36
36
|
type PasswordScore
|
|
37
37
|
} from "@/core/password";
|
|
38
38
|
export { useNotifications, createNotificationQueue, defaultQueue, type UseNotificationsResult } from "@/react/use-notifications";
|
|
39
|
-
export { Toaster,
|
|
39
|
+
export { Toaster, toast, useSonner, type ToasterProps } from "@/react/toaster";
|
|
40
|
+
export type { ToastT, ExternalToast, ToastClassnames, Action } from "@/react/toast/types";
|
|
40
41
|
export { useNetworkState } from "@/react/use-network-state";
|
|
41
42
|
export { type NetworkState } from "@/core/network";
|
|
42
43
|
export { RelativeTime, type RelativeTimeProps } from "@/react/relative-time";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The files in this directory are vendored, not written here.
|
|
2
|
+
|
|
3
|
+
They are the toast component from TPEOficial/dymo-saas
|
|
4
|
+
(src/components/internal/toast), itself derived from Sonner
|
|
5
|
+
(https://github.com/emilkowalski/sonner, MIT, Emil Kowalski), and they are kept
|
|
6
|
+
as close to verbatim as a library can keep them so the toast looks the same
|
|
7
|
+
everywhere it is used.
|
|
8
|
+
|
|
9
|
+
Three mechanical changes were unavoidable, and they are the only ones:
|
|
10
|
+
|
|
11
|
+
- `@/utils/cn` became `./cn`, a two-line local file: a package cannot resolve a
|
|
12
|
+
consumer's path alias.
|
|
13
|
+
- `import "./styles.css"` was removed. The stylesheet lives in `styles.ts` as a
|
|
14
|
+
string and `<Toaster />` injects it, because a package cannot assume its
|
|
15
|
+
consumer has a CSS-capable bundler - and a toast at the edge of the screen is
|
|
16
|
+
the one component a forgotten import ruins rather than merely undresses.
|
|
17
|
+
- `JSX.Element` became `React.JSX.Element` in assets.tsx, which is where React
|
|
18
|
+
19's types put it.
|
|
19
|
+
|
|
20
|
+
Refresh them from upstream rather than editing them here.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import type { ToastTypes } from "./types";
|
|
5
|
+
|
|
6
|
+
export const getAsset = (type: ToastTypes): React.JSX.Element | null => {
|
|
7
|
+
switch (type) {
|
|
8
|
+
case "success": return SuccessIcon;
|
|
9
|
+
case "info": return InfoIcon;
|
|
10
|
+
case "warning": return WarningIcon;
|
|
11
|
+
case "error": return ErrorIcon;
|
|
12
|
+
default: return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const bars = Array(12).fill(0);
|
|
17
|
+
|
|
18
|
+
export const Loader = ({ visible, className }: { visible: boolean, className?: string }) => {
|
|
19
|
+
return (
|
|
20
|
+
<div className={["toastcmp-loading-wrapper", className].filter(Boolean).join(" ")} data-visible={visible}>
|
|
21
|
+
<div className="toastcmp-spinner">
|
|
22
|
+
{bars.map((_, i) => (
|
|
23
|
+
<div className="toastcmp-loading-bar" key={`spinner-bar-${i}`} />
|
|
24
|
+
))}
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const SuccessIcon = (
|
|
31
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20">
|
|
32
|
+
<path
|
|
33
|
+
fillRule="evenodd"
|
|
34
|
+
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"
|
|
35
|
+
clipRule="evenodd"
|
|
36
|
+
/>
|
|
37
|
+
</svg>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const WarningIcon = (
|
|
41
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="20" width="20">
|
|
42
|
+
<path
|
|
43
|
+
fillRule="evenodd"
|
|
44
|
+
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"
|
|
45
|
+
clipRule="evenodd"
|
|
46
|
+
/>
|
|
47
|
+
</svg>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const InfoIcon = (
|
|
51
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20">
|
|
52
|
+
<path
|
|
53
|
+
fillRule="evenodd"
|
|
54
|
+
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"
|
|
55
|
+
clipRule="evenodd"
|
|
56
|
+
/>
|
|
57
|
+
</svg>
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const ErrorIcon = (
|
|
61
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20">
|
|
62
|
+
<path
|
|
63
|
+
fillRule="evenodd"
|
|
64
|
+
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"
|
|
65
|
+
clipRule="evenodd"
|
|
66
|
+
/>
|
|
67
|
+
</svg>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
export const CloseIcon = (
|
|
71
|
+
<svg
|
|
72
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
73
|
+
width="12"
|
|
74
|
+
height="12"
|
|
75
|
+
viewBox="0 0 24 24"
|
|
76
|
+
fill="none"
|
|
77
|
+
stroke="currentColor"
|
|
78
|
+
strokeWidth="1.5"
|
|
79
|
+
strokeLinecap="round"
|
|
80
|
+
strokeLinejoin="round"
|
|
81
|
+
>
|
|
82
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
83
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
84
|
+
</svg>
|
|
85
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The class-name joiner the vendored component imports.
|
|
3
|
+
*
|
|
4
|
+
* Its own file, and two lines, because the alternative is editing the component: everything
|
|
5
|
+
* in this directory is upstream's, kept as close to verbatim as a library can keep it, and
|
|
6
|
+
* one helper is a cheaper thing to supply than a diff to maintain.
|
|
7
|
+
*/
|
|
8
|
+
export function cn(...classes: (string | undefined | null | false)[]): string {
|
|
9
|
+
return classes.filter(Boolean).join(" ");
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export const useIsDocumentHidden = () => {
|
|
4
|
+
const [isDocumentHidden, setIsDocumentHidden] = React.useState(document.hidden);
|
|
5
|
+
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
const callback = () => setIsDocumentHidden(document.hidden);
|
|
8
|
+
document.addEventListener("visibilitychange", callback);
|
|
9
|
+
return () => window.removeEventListener("visibilitychange", callback);
|
|
10
|
+
}, []);
|
|
11
|
+
|
|
12
|
+
return isDocumentHidden;
|
|
13
|
+
};
|