@enigmax/primitives 0.21.0 → 0.23.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.
Files changed (83) hide show
  1. package/dist/chunk-3BQVOOAM.js +388 -0
  2. package/dist/{chunk-QQFNAKMY.js → chunk-45UHLZYT.js} +1 -1
  3. package/dist/chunk-4VUHQFAT.js +130 -0
  4. package/dist/{chunk-D5A2ZMAG.js → chunk-4ZPMP47J.js} +6 -1
  5. package/dist/chunk-DSBYVA7V.js +713 -0
  6. package/dist/{chunk-FWVWX67R.js → chunk-FGBIZDV2.js} +3 -3
  7. package/dist/{chunk-R4ZAEE7V.js → chunk-KEVZ5XQV.js} +1 -1
  8. package/dist/chunk-N6PDHMAX.js +213 -0
  9. package/dist/chunk-NONGREXC.js +248 -0
  10. package/dist/chunk-VKL3DEIQ.js +804 -0
  11. package/dist/chunk-WPTBURIC.js +1627 -0
  12. package/dist/chunk-WSQC3PCC.js +466 -0
  13. package/dist/context-menu-D3FtTn7v.d.ts +174 -0
  14. package/dist/{index-dTdAbOWl.d.ts → index-DQNnohoo.d.ts} +1 -1
  15. package/dist/index.d.ts +5 -1
  16. package/dist/index.js +8 -4
  17. package/dist/keys-D2zJs1uB.d.ts +100 -0
  18. package/dist/next/index.d.ts +12 -5
  19. package/dist/next/index.js +21 -14
  20. package/dist/react/button.d.ts +2 -2
  21. package/dist/react/context-menu.d.ts +202 -0
  22. package/dist/react/context-menu.js +6 -0
  23. package/dist/react/index.d.ts +11 -4
  24. package/dist/react/index.js +20 -13
  25. package/dist/react/input.d.ts +2 -2
  26. package/dist/react/input.js +1 -1
  27. package/dist/react/palette.d.ts +1 -1
  28. package/dist/react/palette.js +3 -3
  29. package/dist/react/search.d.ts +1 -1
  30. package/dist/react/search.js +2 -2
  31. package/dist/react/select.d.ts +217 -0
  32. package/dist/react/select.js +7 -0
  33. package/dist/react/selection.d.ts +104 -0
  34. package/dist/react/selection.js +4 -0
  35. package/dist/react/slot.d.ts +2 -2
  36. package/dist/react/toast.d.ts +165 -32
  37. package/dist/react/toast.js +1 -1
  38. package/dist/react-router/index.d.ts +12 -5
  39. package/dist/react-router/index.js +21 -14
  40. package/dist/search/index.d.ts +2 -2
  41. package/dist/search/index.js +1 -1
  42. package/dist/{search-DXxY8SEH.d.ts → search-DYgqRp37.d.ts} +20 -3
  43. package/dist/{search-UQEXAPQB.js → search-PBZORZ7P.js} +1 -1
  44. package/dist/select-ClSy-J1f.d.ts +100 -0
  45. package/dist/selection-B_pmzHpy.d.ts +150 -0
  46. package/package.json +21 -2
  47. package/recipes/context-menu/styles.css +177 -0
  48. package/recipes/input/styles.css +9 -0
  49. package/recipes/palette/styles.css +3 -0
  50. package/recipes/search/tailwind.tsx +3 -2
  51. package/recipes/select/styles.css +230 -0
  52. package/recipes/toast/styles.css +688 -192
  53. package/registry.json +434 -29
  54. package/src/core/context-menu.ts +694 -0
  55. package/src/core/keys.ts +264 -0
  56. package/src/core/search.ts +25 -1
  57. package/src/core/select.ts +404 -0
  58. package/src/core/selection.ts +648 -0
  59. package/src/index.ts +60 -1
  60. package/src/react/context-menu/context.ts +57 -0
  61. package/src/react/context-menu/index.tsx +94 -0
  62. package/src/react/context-menu/root.tsx +846 -0
  63. package/src/react/context-menu/styles.ts +186 -0
  64. package/src/react/index.ts +70 -2
  65. package/src/react/palette/root.tsx +2 -2
  66. package/src/react/select/context.ts +56 -0
  67. package/src/react/select/index.tsx +96 -0
  68. package/src/react/select/root.tsx +839 -0
  69. package/src/react/select/styles.ts +238 -0
  70. package/src/react/selection/index.tsx +115 -0
  71. package/src/react/selection/use-selection.ts +260 -0
  72. package/src/react/toast/NOTICE +20 -0
  73. package/src/react/toast/assets.tsx +85 -0
  74. package/src/react/toast/cn.ts +10 -0
  75. package/src/react/toast/hooks.ts +13 -0
  76. package/src/react/toast/index.tsx +736 -0
  77. package/src/react/toast/state.ts +207 -0
  78. package/src/react/toast/styles.ts +738 -0
  79. package/src/react/toast/types.ts +193 -0
  80. package/src/react/toaster.tsx +76 -341
  81. package/dist/chunk-JCCL7XKC.js +0 -465
  82. package/src/react/toast-styles.ts +0 -247
  83. /package/dist/{chunk-U3V4EHOB.js → chunk-3HDEZ2E7.js} +0 -0
@@ -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
+ };