@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
@@ -1,238 +1,734 @@
1
1
  /*
2
- * The toast theme.
2
+ * The toast stylesheet.
3
3
  *
4
- * GENERATED from src/react/toast-styles.ts by scripts/sync-recipes.mjs - edit that file, not
5
- * this one. It exists as a stylesheet as well as a string because <Toaster /> injects the
6
- * theme itself, and this is the same look for anyone who would rather import it, copy it
7
- * with `enigma add toast --copy`, or fork it outright.
8
- *
9
- * Every value is a custom property on [data-enigma-toaster]: override them there, or on
10
- * :root, and you have a different toast without touching a selector.
4
+ * GENERATED from src/react/toast/styles.ts by scripts/sync-recipes.mjs - edit that file, not
5
+ * this one. It exists as a stylesheet as well as a string because the component injects it,
6
+ * and this is the same sheet for anyone who would rather import it, copy it with
7
+ * `enigma add toast --copy`, or fork it outright.
11
8
  */
12
- [data-enigma-toaster] {
13
- --enigma-toast-width: 356px;
14
- --enigma-toast-edge: 24px;
15
- --enigma-toast-gap: 14px;
16
- --enigma-toast-peek: 14px;
17
- --enigma-toast-scale-step: 0.06;
18
- --enigma-toast-radius: 12px;
19
- --enigma-toast-enter: 420ms;
20
- --enigma-toast-exit: 350ms;
21
-
22
- --enigma-toast-bg: #101010;
23
- --enigma-toast-border: #2a2a2a;
24
- --enigma-toast-text: #f5f5f5;
25
- --enigma-toast-muted: #a3a3a3;
26
- --enigma-toast-shadow: 0 6px 22px rgb(0 0 0 / 34%);
27
-
28
- --enigma-toast-success: hsl(150 80% 72%);
29
- --enigma-toast-success-bg: hsl(150 38% 9%);
30
- --enigma-toast-success-border: hsl(147 55% 18%);
31
- --enigma-toast-error: hsl(358 100% 82%);
32
- --enigma-toast-error-bg: hsl(358 42% 12%);
33
- --enigma-toast-error-border: hsl(357 55% 24%);
34
- --enigma-toast-info: hsl(216 87% 74%);
35
- --enigma-toast-info-bg: hsl(215 45% 11%);
36
- --enigma-toast-info-border: hsl(223 50% 24%);
37
- --enigma-toast-warning: hsl(46 87% 70%);
38
- --enigma-toast-warning-bg: hsl(40 55% 9%);
39
- --enigma-toast-warning-border: hsl(40 55% 20%);
9
+ :where(html[dir="ltr"]),
10
+ :where([data-toastcmp-toaster][dir="ltr"]) {
11
+ --toast-icon-margin-start: -3px;
12
+ --toast-icon-margin-end: 4px;
13
+ --toast-svg-margin-start: -1px;
14
+ --toast-svg-margin-end: 0px;
15
+ --toast-button-margin-start: auto;
16
+ --toast-button-margin-end: 0;
17
+ --toast-close-button-start: 0;
18
+ --toast-close-button-end: unset;
19
+ --toast-close-button-transform: translate(-35%, -35%);
20
+ }
40
21
 
22
+ :where(html[dir="rtl"]),
23
+ :where([data-toastcmp-toaster][dir="rtl"]) {
24
+ --toast-icon-margin-start: 4px;
25
+ --toast-icon-margin-end: -3px;
26
+ --toast-svg-margin-start: 0px;
27
+ --toast-svg-margin-end: -1px;
28
+ --toast-button-margin-start: 0;
29
+ --toast-button-margin-end: auto;
30
+ --toast-close-button-start: unset;
31
+ --toast-close-button-end: 0;
32
+ --toast-close-button-transform: translate(35%, -35%);
33
+ }
34
+
35
+ :where([data-toastcmp-toaster]) {
41
36
  position: fixed;
42
- z-index: 999999;
43
- width: var(--enigma-toast-width);
44
- margin: 0;
37
+ width: var(--width);
38
+ font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial,
39
+ Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
40
+ --gray1: hsl(0, 0%, 99%);
41
+ --gray2: hsl(0, 0%, 97.3%);
42
+ --gray3: hsl(0, 0%, 95.1%);
43
+ --gray4: hsl(0, 0%, 93%);
44
+ --gray5: hsl(0, 0%, 90.9%);
45
+ --gray6: hsl(0, 0%, 88.7%);
46
+ --gray7: hsl(0, 0%, 85.8%);
47
+ --gray8: hsl(0, 0%, 78%);
48
+ --gray9: hsl(0, 0%, 56.1%);
49
+ --gray10: hsl(0, 0%, 52.3%);
50
+ --gray11: hsl(0, 0%, 43.5%);
51
+ --gray12: hsl(0, 0%, 9%);
52
+ --border-radius: 8px;
53
+ box-sizing: border-box;
45
54
  padding: 0;
55
+ margin: 0;
46
56
  list-style: none;
47
57
  outline: none;
48
- font-family: inherit;
49
- font-size: 13px;
50
- /* The stack is a positioning context: every toast is absolute inside it, which is what
51
- lets the ones behind be clipped to the front one's height. */
52
- transition: transform 350ms ease;
53
- }
54
-
55
- @media (prefers-color-scheme: light) {
56
- [data-enigma-toaster] {
57
- --enigma-toast-bg: #ffffff;
58
- --enigma-toast-border: #e5e5e5;
59
- --enigma-toast-text: #171717;
60
- --enigma-toast-muted: #737373;
61
- --enigma-toast-shadow: 0 6px 22px rgb(0 0 0 / 12%);
62
- --enigma-toast-success-bg: hsl(143 85% 96%);
63
- --enigma-toast-success-border: hsl(145 92% 87%);
64
- --enigma-toast-success: hsl(140 100% 27%);
65
- --enigma-toast-error-bg: hsl(359 100% 97%);
66
- --enigma-toast-error-border: hsl(359 100% 94%);
67
- --enigma-toast-error: hsl(360 100% 45%);
68
- --enigma-toast-info-bg: hsl(208 100% 97%);
69
- --enigma-toast-info-border: hsl(221 91% 93%);
70
- --enigma-toast-info: hsl(210 92% 45%);
71
- --enigma-toast-warning-bg: hsl(49 100% 97%);
72
- --enigma-toast-warning-border: hsl(49 91% 84%);
73
- --enigma-toast-warning: hsl(31 92% 45%);
74
- }
75
- }
76
-
77
- [data-enigma-toaster][data-position^="top"] { top: var(--enigma-toast-edge); }
78
- [data-enigma-toaster][data-position^="bottom"] { bottom: var(--enigma-toast-edge); }
79
- [data-enigma-toaster][data-position$="-right"] { right: var(--enigma-toast-edge); }
80
- [data-enigma-toaster][data-position$="-left"] { left: var(--enigma-toast-edge); }
81
- [data-enigma-toaster][data-position$="-center"] { left: 50%; transform: translateX(-50%); }
82
- /* The whole stack lifts a little when it fans out, so the front toast does not sit on the
83
- exact pixel it did a moment ago. */
84
- [data-enigma-toaster][data-expanded][data-position^="bottom"] { transform: translateY(-6px); }
85
- [data-enigma-toaster][data-expanded][data-position^="top"] { transform: translateY(6px); }
86
- [data-enigma-toaster][data-expanded][data-position="bottom-center"] { transform: translateX(-50%) translateY(-6px); }
87
- [data-enigma-toaster][data-expanded][data-position="top-center"] { transform: translateX(-50%) translateY(6px); }
88
-
89
- [data-enigma-toast] {
90
- position: absolute;
91
- left: 0;
92
- right: 0;
93
- width: 100%;
94
- box-sizing: border-box;
95
- display: flex;
96
- align-items: center;
97
- gap: 10px;
98
- padding: 15px 16px;
99
- color: var(--enigma-toast-text);
100
- background: var(--enigma-toast-bg);
101
- border: 1px solid var(--enigma-toast-border);
102
- border-radius: var(--enigma-toast-radius);
103
- box-shadow: var(--enigma-toast-shadow);
104
- overflow-wrap: anywhere;
105
- touch-action: none;
106
- outline: none;
107
- z-index: var(--enigma-toast-z, 1);
108
- transition:
109
- transform var(--enigma-toast-enter) cubic-bezier(0.21, 1.02, 0.73, 1),
110
- opacity var(--enigma-toast-exit),
111
- height 350ms;
58
+ z-index: 999999999;
59
+ transition: transform 400ms ease;
112
60
  }
113
61
 
114
- [data-enigma-toaster][data-position^="bottom"] [data-enigma-toast] { bottom: 0; transform-origin: bottom center; }
115
- [data-enigma-toaster][data-position^="top"] [data-enigma-toast] { top: 0; transform-origin: top center; }
62
+ :where([data-toastcmp-toaster][data-lifted="true"]) {
63
+ transform: translateY(-10px);
64
+ }
116
65
 
117
- /* Enter from off screen, in the direction the stack is pinned to. */
118
- [data-enigma-toaster][data-position^="bottom"] [data-enigma-toast] { transform: translateY(110%); opacity: 0; }
119
- [data-enigma-toaster][data-position^="top"] [data-enigma-toast] { transform: translateY(-110%); opacity: 0; }
120
- /* Scoped to the toaster so it OUTRANKS the enter rules above, which are scoped the same
121
- way: at equal specificity the later rule wins, and a mounted toast that lost this one sat
122
- at its entry offset forever - visible, and 110% of its own height off the bottom. */
123
- [data-enigma-toaster] [data-enigma-toast][data-mounted] { opacity: 1; transform: translateY(0); }
66
+ @media (hover: none) and (pointer: coarse) {
67
+ :where([data-toastcmp-toaster][data-lifted="true"]) {
68
+ transform: none;
69
+ }
70
+ }
124
71
 
125
- /* Collapsed: the ones behind are clipped to the FRONT toast's height and scaled back, so
126
- the stack reads as depth rather than as a list. Their content is hidden but present -
127
- removing it would make the box jump when the stack expands. */
128
- [data-enigma-toaster]:not([data-expanded]) [data-enigma-toast][data-mounted]:not([data-front]) {
129
- height: var(--enigma-toast-front-height);
130
- transform: translateY(calc(var(--enigma-toast-before) * var(--enigma-toast-peek) * -1))
131
- scale(calc(1 - var(--enigma-toast-before) * var(--enigma-toast-scale-step)));
72
+ :where([data-toastcmp-toaster][data-x-position="right"]) {
73
+ right: var(--offset-right);
132
74
  }
133
- [data-enigma-toaster][data-position^="top"]:not([data-expanded]) [data-enigma-toast][data-mounted]:not([data-front]) {
134
- transform: translateY(calc(var(--enigma-toast-before) * var(--enigma-toast-peek)))
135
- scale(calc(1 - var(--enigma-toast-before) * var(--enigma-toast-scale-step)));
75
+
76
+ :where([data-toastcmp-toaster][data-x-position="left"]) {
77
+ left: var(--offset-left);
136
78
  }
137
- [data-enigma-toaster]:not([data-expanded]) [data-enigma-toast]:not([data-front]) > * { opacity: 0; }
138
- [data-enigma-toast] > * { transition: opacity 350ms; }
139
79
 
140
- /* Expanded: each toast is lifted by the summed height of the ones in front of it. */
141
- [data-enigma-toaster][data-expanded][data-position^="bottom"] [data-enigma-toast][data-mounted] {
142
- transform: translateY(calc(var(--enigma-toast-offset) * -1));
80
+ :where([data-toastcmp-toaster][data-x-position="center"]) {
81
+ left: 50%;
82
+ transform: translateX(-50%);
143
83
  }
144
- [data-enigma-toaster][data-expanded][data-position^="top"] [data-enigma-toast][data-mounted] {
145
- transform: translateY(var(--enigma-toast-offset));
84
+
85
+ :where([data-toastcmp-toaster][data-y-position="top"]) {
86
+ top: var(--offset-top);
146
87
  }
147
88
 
148
- /* Past the visible count it is still in the DOM, still counted, and not on screen. */
149
- [data-enigma-toast][data-hidden] { opacity: 0; pointer-events: none; }
89
+ :where([data-toastcmp-toaster][data-y-position="bottom"]) {
90
+ bottom: var(--offset-bottom);
91
+ }
150
92
 
151
- [data-enigma-toast][data-state="leaving"] { opacity: 0; }
152
- [data-enigma-toaster]:not([data-expanded]) [data-enigma-toast][data-state="leaving"] { transform: translateY(150%) scale(0.9); }
153
- [data-enigma-toaster][data-expanded][data-position^="bottom"] [data-enigma-toast][data-state="leaving"] {
154
- transform: translateY(calc(var(--enigma-toast-offset) * -1 + 110%));
93
+ :where([data-toastcmp-toast]) {
94
+ --y: translateY(100%);
95
+ --lift-amount: calc(var(--lift) * var(--gap));
96
+ z-index: var(--z-index);
97
+ position: absolute;
98
+ opacity: 0;
99
+ transform: var(--y);
100
+ filter: blur(0);
101
+ /* https://stackoverflow.com/questions/48124372/pointermove-event-not-working-with-touch-why-not */
102
+ touch-action: none;
103
+ transition: transform 400ms, opacity 400ms, height 400ms, box-shadow 200ms;
104
+ box-sizing: border-box;
105
+ outline: none;
106
+ overflow-wrap: anywhere;
155
107
  }
156
108
 
157
- /* While a finger is down the toast tracks it exactly: a transition here would lag behind the
158
- pointer, which reads as a broken gesture rather than a smooth one. */
159
- [data-enigma-toast][data-swiping] {
160
- transition: opacity 200ms;
161
- transform: translateX(var(--enigma-toast-swipe, 0px));
109
+ :where([data-toastcmp-toast][data-styled="true"]) {
110
+ padding: 16px;
111
+ background: var(--normal-bg);
112
+ border: 1px solid var(--normal-border);
113
+ color: var(--normal-text);
114
+ border-radius: var(--border-radius);
115
+ box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
116
+ width: var(--width);
117
+ font-size: 13px;
118
+ display: flex;
119
+ align-items: center;
120
+ gap: 6px;
162
121
  }
163
122
 
164
- [data-enigma-toast]:focus-visible { box-shadow: var(--enigma-toast-shadow), 0 0 0 2px var(--enigma-toast-info); }
123
+ :where([data-toastcmp-toast]:focus-visible) {
124
+ box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(0, 0, 0, 0.2);
125
+ }
165
126
 
166
- [data-enigma-toast][data-tone="success"] {
167
- color: var(--enigma-toast-success);
168
- background: var(--enigma-toast-success-bg);
169
- border-color: var(--enigma-toast-success-border);
127
+ :where([data-toastcmp-toast][data-y-position="top"]) {
128
+ top: 0;
129
+ --y: translateY(-100%);
130
+ --lift: 1;
131
+ --lift-amount: calc(1 * var(--gap));
170
132
  }
171
- [data-enigma-toast][data-tone="error"] {
172
- color: var(--enigma-toast-error);
173
- background: var(--enigma-toast-error-bg);
174
- border-color: var(--enigma-toast-error-border);
133
+
134
+ :where([data-toastcmp-toast][data-y-position="bottom"]) {
135
+ bottom: 0;
136
+ --y: translateY(100%);
137
+ --lift: -1;
138
+ --lift-amount: calc(var(--lift) * var(--gap));
175
139
  }
176
- [data-enigma-toast][data-tone="info"] {
177
- color: var(--enigma-toast-info);
178
- background: var(--enigma-toast-info-bg);
179
- border-color: var(--enigma-toast-info-border);
140
+
141
+ :where([data-toastcmp-toast]) :where([data-description]) {
142
+ font-weight: 400;
143
+ line-height: 1.4;
144
+ color: inherit;
180
145
  }
181
- [data-enigma-toast][data-tone="warning"] {
182
- color: var(--enigma-toast-warning);
183
- background: var(--enigma-toast-warning-bg);
184
- border-color: var(--enigma-toast-warning-border);
146
+
147
+ :where([data-toastcmp-toast]) :where([data-title]) {
148
+ font-weight: 500;
149
+ line-height: 1.5;
150
+ color: inherit;
185
151
  }
186
152
 
187
- [data-enigma-toast-icon] { display: flex; flex-shrink: 0; width: 20px; height: 20px; }
188
- [data-enigma-toast-icon] svg { width: 20px; height: 20px; display: block; }
189
- [data-enigma-toast-icon][data-tone="loading"] svg { animation: enigma-toast-spin 900ms linear infinite; }
190
- @keyframes enigma-toast-spin { to { transform: rotate(360deg); } }
153
+ :where([data-toastcmp-toast]) :where([data-icon]) {
154
+ display: flex;
155
+ height: 16px;
156
+ width: 16px;
157
+ position: relative;
158
+ justify-content: flex-start;
159
+ align-items: center;
160
+ flex-shrink: 0;
161
+ margin-left: var(--toast-icon-margin-start);
162
+ margin-right: var(--toast-icon-margin-end);
163
+ }
191
164
 
192
- [data-enigma-toast-content] { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
193
- [data-enigma-toast-title] { margin: 0; font-weight: 600; line-height: 1.4; }
194
- [data-enigma-toast-body] { margin: 0; font-size: 12px; line-height: 1.45; opacity: 0.75; }
165
+ :where([data-toastcmp-toast][data-promise="true"]) :where([data-icon])>svg {
166
+ opacity: 0;
167
+ transform: scale(0.8);
168
+ transform-origin: center;
169
+ animation: toastcmp-fade-in 300ms ease forwards;
170
+ }
195
171
 
196
- [data-enigma-toast-action] {
172
+ :where([data-toastcmp-toast]) :where([data-icon])>* {
197
173
  flex-shrink: 0;
198
- padding: 5px 10px;
199
- font: inherit;
174
+ }
175
+
176
+ :where([data-toastcmp-toast]) :where([data-icon]) svg {
177
+ margin-left: var(--toast-svg-margin-start);
178
+ margin-right: var(--toast-svg-margin-end);
179
+ }
180
+
181
+ :where([data-toastcmp-toast]) :where([data-content]) {
182
+ display: flex;
183
+ flex-direction: column;
184
+ gap: 2px;
185
+ }
186
+
187
+ [data-toastcmp-toast][data-styled="true"] [data-button] {
188
+ border-radius: 4px;
189
+ padding-left: 8px;
190
+ padding-right: 8px;
191
+ height: 24px;
200
192
  font-size: 12px;
201
- font-weight: 600;
202
- color: var(--enigma-toast-bg);
203
- background: currentColor;
204
- border: 0;
205
- border-radius: 6px;
193
+ color: var(--normal-bg);
194
+ background: var(--normal-text);
195
+ margin-left: var(--toast-button-margin-start);
196
+ margin-right: var(--toast-button-margin-end);
197
+ border: none;
206
198
  cursor: pointer;
199
+ outline: none;
200
+ display: flex;
201
+ align-items: center;
202
+ flex-shrink: 0;
203
+ transition: opacity 400ms, box-shadow 200ms;
207
204
  }
208
205
 
209
- [data-enigma-toast-close] {
210
- flex-shrink: 0;
211
- display: grid;
212
- place-items: center;
213
- width: 20px;
206
+ :where([data-toastcmp-toast]) :where([data-button]):focus-visible {
207
+ box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
208
+ }
209
+
210
+ :where([data-toastcmp-toast]) :where([data-button]):first-of-type {
211
+ margin-left: var(--toast-button-margin-start);
212
+ margin-right: var(--toast-button-margin-end);
213
+ }
214
+
215
+ :where([data-toastcmp-toast]) :where([data-cancel]) {
216
+ color: var(--normal-text);
217
+ background: rgba(0, 0, 0, 0.08);
218
+ }
219
+
220
+ :where([data-toastcmp-toast][data-theme="dark"]) :where([data-cancel]) {
221
+ background: rgba(255, 255, 255, 0.3);
222
+ }
223
+
224
+ :where([data-toastcmp-toast]) :where([data-close-button]) {
225
+ position: absolute;
226
+ left: var(--toast-close-button-start);
227
+ right: var(--toast-close-button-end);
228
+ top: 0;
214
229
  height: 20px;
230
+ width: 20px;
231
+ display: flex;
232
+ justify-content: center;
233
+ align-items: center;
215
234
  padding: 0;
216
- color: inherit;
217
- background: none;
218
- border: 0;
219
- border-radius: 5px;
235
+ color: var(--gray12);
236
+ border: 1px solid var(--gray4);
237
+ transform: var(--toast-close-button-transform);
238
+ border-radius: 50%;
220
239
  cursor: pointer;
221
- /* Shown on hover or focus, so it never covers the message while it is being read - but
222
- always reachable by keyboard, which display:none would take away. */
240
+ z-index: 1;
241
+ transition: opacity 100ms, background 200ms, border-color 200ms;
242
+ }
243
+
244
+ [data-toastcmp-toast] [data-close-button] {
245
+ background: var(--gray1);
246
+ }
247
+
248
+ :where([data-toastcmp-toast]) :where([data-close-button]):focus-visible {
249
+ box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(0, 0, 0, 0.2);
250
+ }
251
+
252
+ :where([data-toastcmp-toast]) :where([data-disabled="true"]) {
253
+ cursor: not-allowed;
254
+ }
255
+
256
+ :where([data-toastcmp-toast]):hover :where([data-close-button]):hover {
257
+ background: var(--gray2);
258
+ border-color: var(--gray5);
259
+ }
260
+
261
+ /* Leave a ghost div to avoid setting hover to false when swiping out */
262
+ :where([data-toastcmp-toast][data-swiping="true"])::before {
263
+ content: "";
264
+ position: absolute;
265
+ left: -50%;
266
+ right: -50%;
267
+ height: 100%;
268
+ z-index: -1;
269
+ }
270
+
271
+ :where([data-toastcmp-toast][data-y-position="top"][data-swiping="true"])::before {
272
+ /* y 50% needed to distribute height additional height evenly */
273
+ bottom: 50%;
274
+ transform: scaleY(3) translateY(50%);
275
+ }
276
+
277
+ :where([data-toastcmp-toast][data-y-position="bottom"][data-swiping="true"])::before {
278
+ /* y -50% needed to distribute height additional height evenly */
279
+ top: 50%;
280
+ transform: scaleY(3) translateY(-50%);
281
+ }
282
+
283
+ /* Leave a ghost div to avoid setting hover to false when transitioning out */
284
+ :where([data-toastcmp-toast][data-swiping="false"][data-removed="true"])::before {
285
+ content: "";
286
+ position: absolute;
287
+ inset: 0;
288
+ transform: scaleY(2);
289
+ }
290
+
291
+ /* Needed to avoid setting hover to false when inbetween toasts */
292
+ :where([data-toastcmp-toast])::after {
293
+ content: "";
294
+ position: absolute;
295
+ left: 0;
296
+ height: calc(var(--gap) + 1px);
297
+ bottom: 100%;
298
+ width: 100%;
299
+ }
300
+
301
+ :where([data-toastcmp-toast][data-mounted="true"]) {
302
+ --y: translateY(0);
303
+ opacity: 1;
304
+ }
305
+
306
+ :where([data-toastcmp-toast][data-expanded="false"][data-front="false"]) {
307
+ --scale: var(--toasts-before) * 0.05 + 1;
308
+ --y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));
309
+ height: var(--front-toast-height);
310
+ }
311
+
312
+ :where([data-toastcmp-toast])>* {
313
+ transition: opacity 400ms;
314
+ }
315
+
316
+ :where([data-toastcmp-toast][data-expanded="false"][data-front="false"][data-styled="true"])>* {
317
+ opacity: 0;
318
+ }
319
+
320
+ :where([data-toastcmp-toast][data-visible="false"]) {
321
+ opacity: 0;
322
+ pointer-events: none;
323
+ }
324
+
325
+ :where([data-toastcmp-toast][data-mounted="true"][data-expanded="true"]) {
326
+ --y: translateY(calc(var(--lift) * var(--offset)));
327
+ height: var(--initial-height);
328
+ }
329
+
330
+ :where([data-toastcmp-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]) {
331
+ --y: translateY(calc(var(--lift) * -100%));
332
+ opacity: 0;
333
+ }
334
+
335
+ :where([data-toastcmp-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]) {
336
+ --y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));
223
337
  opacity: 0;
224
- transition: opacity 120ms ease-out;
225
338
  }
226
- [data-enigma-toast]:hover [data-enigma-toast-close],
227
- [data-enigma-toast-close]:focus-visible { opacity: 0.7; }
228
- [data-enigma-toast-close]:hover { opacity: 1; }
339
+
340
+ :where([data-toastcmp-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]) {
341
+ --y: translateY(40%);
342
+ opacity: 0;
343
+ transition: transform 500ms, opacity 200ms;
344
+ }
345
+
346
+ /* Bump up the height to make sure hover state doesn"t get set to false */
347
+ :where([data-toastcmp-toast][data-removed="true"][data-front="false"])::before {
348
+ height: calc(var(--initial-height) + 20%);
349
+ }
350
+
351
+ [data-toastcmp-toast][data-swiping="true"] {
352
+ transform: var(--y) translateY(var(--swipe-amount-y, 0px)) translateX(var(--swipe-amount-x, 0px));
353
+ transition: none;
354
+ }
355
+
356
+ [data-toastcmp-toast][data-swiped="true"] {
357
+ user-select: none;
358
+ }
359
+
360
+ [data-toastcmp-toast][data-swipe-out="true"][data-y-position="bottom"],
361
+ [data-toastcmp-toast][data-swipe-out="true"][data-y-position="top"] {
362
+ animation-duration: 200ms;
363
+ animation-timing-function: ease-out;
364
+ animation-fill-mode: forwards;
365
+ }
366
+
367
+ [data-toastcmp-toast][data-swipe-out="true"][data-swipe-direction="left"] {
368
+ animation-name: swipe-out-left;
369
+ }
370
+
371
+ [data-toastcmp-toast][data-swipe-out="true"][data-swipe-direction="right"] {
372
+ animation-name: swipe-out-right;
373
+ }
374
+
375
+ [data-toastcmp-toast][data-swipe-out="true"][data-swipe-direction="up"] {
376
+ animation-name: swipe-out-up;
377
+ }
378
+
379
+ [data-toastcmp-toast][data-swipe-out="true"][data-swipe-direction="down"] {
380
+ animation-name: swipe-out-down;
381
+ }
382
+
383
+ @keyframes swipe-out-left {
384
+ from {
385
+ transform: var(--y) translateX(var(--swipe-amount-x));
386
+ opacity: 1;
387
+ }
388
+
389
+ to {
390
+ transform: var(--y) translateX(calc(var(--swipe-amount-x) - 100%));
391
+ opacity: 0;
392
+ }
393
+ }
394
+
395
+ @keyframes swipe-out-right {
396
+ from {
397
+ transform: var(--y) translateX(var(--swipe-amount-x));
398
+ opacity: 1;
399
+ }
400
+
401
+ to {
402
+ transform: var(--y) translateX(calc(var(--swipe-amount-x) + 100%));
403
+ opacity: 0;
404
+ }
405
+ }
406
+
407
+ @keyframes swipe-out-up {
408
+ from {
409
+ transform: var(--y) translateY(var(--swipe-amount-y));
410
+ opacity: 1;
411
+ }
412
+
413
+ to {
414
+ transform: var(--y) translateY(calc(var(--swipe-amount-y) - 100%));
415
+ opacity: 0;
416
+ }
417
+ }
418
+
419
+ @keyframes swipe-out-down {
420
+ from {
421
+ transform: var(--y) translateY(var(--swipe-amount-y));
422
+ opacity: 1;
423
+ }
424
+
425
+ to {
426
+ transform: var(--y) translateY(calc(var(--swipe-amount-y) + 100%));
427
+ opacity: 0;
428
+ }
429
+ }
229
430
 
230
431
  @media (max-width: 600px) {
231
- [data-enigma-toaster] { right: 14px; left: 14px; width: auto; }
432
+ [data-toastcmp-toaster] {
433
+ position: fixed;
434
+ right: var(--mobile-offset-right);
435
+ left: var(--mobile-offset-left);
436
+ width: 100%;
437
+ }
438
+
439
+ [data-toastcmp-toaster][dir="rtl"] {
440
+ left: calc(var(--mobile-offset-left) * -1);
441
+ }
442
+
443
+ [data-toastcmp-toaster] [data-toastcmp-toast] {
444
+ left: 0;
445
+ right: 0;
446
+ width: calc(100% - var(--mobile-offset-left) * 2);
447
+ }
448
+
449
+ [data-toastcmp-toaster][data-x-position="left"] {
450
+ left: var(--mobile-offset-left);
451
+ }
452
+
453
+ [data-toastcmp-toaster][data-y-position="bottom"] {
454
+ bottom: var(--mobile-offset-bottom);
455
+ }
456
+
457
+ [data-toastcmp-toaster][data-y-position="top"] {
458
+ top: var(--mobile-offset-top);
459
+ }
460
+
461
+ [data-toastcmp-toaster][data-x-position="center"] {
462
+ left: var(--mobile-offset-left);
463
+ right: var(--mobile-offset-right);
464
+ transform: none;
465
+ }
466
+ }
467
+
468
+ [data-toastcmp-toaster][data-theme="light"] {
469
+ --normal-bg: #fff;
470
+ --normal-border: var(--gray4);
471
+ --normal-text: var(--gray12);
472
+
473
+ --success-bg: hsl(143, 85%, 96%);
474
+ --success-border: hsl(145, 92%, 91%);
475
+ --success-text: hsl(140, 100%, 27%);
476
+
477
+ --info-bg: hsl(208, 100%, 97%);
478
+ --info-border: hsl(221, 91%, 91%);
479
+ --info-text: hsl(210, 92%, 45%);
480
+
481
+ --warning-bg: hsl(49, 100%, 97%);
482
+ --warning-border: hsl(49, 91%, 91%);
483
+ --warning-text: hsl(31, 92%, 45%);
484
+
485
+ --error-bg: hsl(359, 100%, 97%);
486
+ --error-border: hsl(359, 100%, 94%);
487
+ --error-text: hsl(360, 100%, 45%);
488
+ }
489
+
490
+ [data-toastcmp-toaster][data-theme="light"] [data-toastcmp-toast][data-invert="true"] {
491
+ --normal-bg: #000;
492
+ --normal-border: hsl(0, 0%, 20%);
493
+ --normal-text: var(--gray1);
494
+ }
495
+
496
+ [data-toastcmp-toaster][data-theme="dark"] [data-toastcmp-toast][data-invert="true"] {
497
+ --normal-bg: #fff;
498
+ --normal-border: var(--gray3);
499
+ --normal-text: var(--gray12);
500
+ }
501
+
502
+ [data-toastcmp-toaster][data-theme="dark"] {
503
+ --normal-bg: #000;
504
+ --normal-bg-hover: hsl(0, 0%, 12%);
505
+ --normal-border: hsl(0, 0%, 20%);
506
+ --normal-border-hover: hsl(0, 0%, 25%);
507
+ --normal-text: var(--gray1);
508
+
509
+ --success-bg: hsl(150, 100%, 6%);
510
+ --success-border: hsl(147, 100%, 12%);
511
+ --success-text: hsl(150, 86%, 65%);
512
+
513
+ --info-bg: hsl(215, 100%, 6%);
514
+ --info-border: hsl(223, 100%, 12%);
515
+ --info-text: hsl(216, 87%, 65%);
516
+
517
+ --warning-bg: hsl(64, 100%, 6%);
518
+ --warning-border: hsl(60, 100%, 12%);
519
+ --warning-text: hsl(46, 87%, 65%);
520
+
521
+ --error-bg: hsl(358, 76%, 10%);
522
+ --error-border: hsl(357, 89%, 16%);
523
+ --error-text: hsl(358, 100%, 81%);
524
+ }
525
+
526
+ [data-toastcmp-toaster][data-theme="dark"] [data-toastcmp-toast] [data-close-button] {
527
+ background: var(--normal-bg);
528
+ border-color: var(--normal-border);
529
+ color: var(--normal-text);
530
+ }
531
+
532
+ [data-toastcmp-toaster][data-theme="dark"] [data-toastcmp-toast] [data-close-button]:hover {
533
+ background: var(--normal-bg-hover);
534
+ border-color: var(--normal-border-hover);
535
+ }
536
+
537
+ [data-rich-colors="true"][data-toastcmp-toast][data-type="success"] {
538
+ background: var(--success-bg);
539
+ border-color: var(--success-border);
540
+ color: var(--success-text);
541
+ }
542
+
543
+ [data-rich-colors="true"][data-toastcmp-toast][data-type="success"] [data-close-button] {
544
+ background: var(--success-bg);
545
+ border-color: var(--success-border);
546
+ color: var(--success-text);
547
+ }
548
+
549
+ [data-rich-colors="true"][data-toastcmp-toast][data-type="info"] {
550
+ background: var(--info-bg);
551
+ border-color: var(--info-border);
552
+ color: var(--info-text);
553
+ }
554
+
555
+ [data-rich-colors="true"][data-toastcmp-toast][data-type="info"] [data-close-button] {
556
+ background: var(--info-bg);
557
+ border-color: var(--info-border);
558
+ color: var(--info-text);
232
559
  }
233
560
 
234
- @media (prefers-reduced-motion: reduce) {
235
- /* The movement goes, the state change stays: a toast still appears and still leaves. */
236
- [data-enigma-toast], [data-enigma-toast] > * { transition: opacity 200ms !important; }
237
- [data-enigma-toast][data-mounted] { transform: none !important; }
561
+ [data-rich-colors="true"][data-toastcmp-toast][data-type="warning"] {
562
+ background: var(--warning-bg);
563
+ border-color: var(--warning-border);
564
+ color: var(--warning-text);
238
565
  }
566
+
567
+ [data-rich-colors="true"][data-toastcmp-toast][data-type="warning"] [data-close-button] {
568
+ background: var(--warning-bg);
569
+ border-color: var(--warning-border);
570
+ color: var(--warning-text);
571
+ }
572
+
573
+ [data-rich-colors="true"][data-toastcmp-toast][data-type="error"] {
574
+ background: var(--error-bg);
575
+ border-color: var(--error-border);
576
+ color: var(--error-text);
577
+ }
578
+
579
+ [data-rich-colors="true"][data-toastcmp-toast][data-type="error"] [data-close-button] {
580
+ background: var(--error-bg);
581
+ border-color: var(--error-border);
582
+ color: var(--error-text);
583
+ }
584
+
585
+ .toastcmp-loading-wrapper {
586
+ --size: 16px;
587
+ height: var(--size);
588
+ width: var(--size);
589
+ position: absolute;
590
+ inset: 0;
591
+ z-index: 10;
592
+ }
593
+
594
+ .toastcmp-loading-wrapper[data-visible="false"] {
595
+ transform-origin: center;
596
+ animation: toastcmp-fade-out 0.2s ease forwards;
597
+ }
598
+
599
+ .toastcmp-spinner {
600
+ position: relative;
601
+ top: 50%;
602
+ left: 50%;
603
+ height: var(--size);
604
+ width: var(--size);
605
+ }
606
+
607
+ .toastcmp-loading-bar {
608
+ animation: toastcmp-spin 1.2s linear infinite;
609
+ background: var(--gray11);
610
+ border-radius: 6px;
611
+ height: 8%;
612
+ left: -10%;
613
+ position: absolute;
614
+ top: -3.9%;
615
+ width: 24%;
616
+ }
617
+
618
+ .toastcmp-loading-bar:nth-child(1) {
619
+ animation-delay: -1.2s;
620
+ transform: rotate(0.0001deg) translate(146%);
621
+ }
622
+
623
+ .toastcmp-loading-bar:nth-child(2) {
624
+ animation-delay: -1.1s;
625
+ transform: rotate(30deg) translate(146%);
626
+ }
627
+
628
+ .toastcmp-loading-bar:nth-child(3) {
629
+ animation-delay: -1s;
630
+ transform: rotate(60deg) translate(146%);
631
+ }
632
+
633
+ .toastcmp-loading-bar:nth-child(4) {
634
+ animation-delay: -0.9s;
635
+ transform: rotate(90deg) translate(146%);
636
+ }
637
+
638
+ .toastcmp-loading-bar:nth-child(5) {
639
+ animation-delay: -0.8s;
640
+ transform: rotate(120deg) translate(146%);
641
+ }
642
+
643
+ .toastcmp-loading-bar:nth-child(6) {
644
+ animation-delay: -0.7s;
645
+ transform: rotate(150deg) translate(146%);
646
+ }
647
+
648
+ .toastcmp-loading-bar:nth-child(7) {
649
+ animation-delay: -0.6s;
650
+ transform: rotate(180deg) translate(146%);
651
+ }
652
+
653
+ .toastcmp-loading-bar:nth-child(8) {
654
+ animation-delay: -0.5s;
655
+ transform: rotate(210deg) translate(146%);
656
+ }
657
+
658
+ .toastcmp-loading-bar:nth-child(9) {
659
+ animation-delay: -0.4s;
660
+ transform: rotate(240deg) translate(146%);
661
+ }
662
+
663
+ .toastcmp-loading-bar:nth-child(10) {
664
+ animation-delay: -0.3s;
665
+ transform: rotate(270deg) translate(146%);
666
+ }
667
+
668
+ .toastcmp-loading-bar:nth-child(11) {
669
+ animation-delay: -0.2s;
670
+ transform: rotate(300deg) translate(146%);
671
+ }
672
+
673
+ .toastcmp-loading-bar:nth-child(12) {
674
+ animation-delay: -0.1s;
675
+ transform: rotate(330deg) translate(146%);
676
+ }
677
+
678
+ @keyframes toastcmp-fade-in {
679
+ 0% {
680
+ opacity: 0;
681
+ transform: scale(0.8);
682
+ }
683
+
684
+ 100% {
685
+ opacity: 1;
686
+ transform: scale(1);
687
+ }
688
+ }
689
+
690
+ @keyframes toastcmp-fade-out {
691
+ 0% {
692
+ opacity: 1;
693
+ transform: scale(1);
694
+ }
695
+
696
+ 100% {
697
+ opacity: 0;
698
+ transform: scale(0.8);
699
+ }
700
+ }
701
+
702
+ @keyframes toastcmp-spin {
703
+ 0% {
704
+ opacity: 1;
705
+ }
706
+
707
+ 100% {
708
+ opacity: 0.15;
709
+ }
710
+ }
711
+
712
+ @media (prefers-reduced-motion) {
713
+
714
+ [data-toastcmp-toast],
715
+ [data-toastcmp-toast]>*,
716
+ .toastcmp-loading-bar {
717
+ transition: none !important;
718
+ animation: none !important;
719
+ }
720
+ }
721
+
722
+ .toastcmp-loader {
723
+ position: absolute;
724
+ top: 50%;
725
+ left: 50%;
726
+ transform: translate(-50%, -50%);
727
+ transform-origin: center;
728
+ transition: opacity 200ms, transform 200ms;
729
+ }
730
+
731
+ .toastcmp-loader[data-visible="false"] {
732
+ opacity: 0;
733
+ transform: scale(0.8) translate(-50%, -50%);
734
+ }