@hexdspace/react 0.0.11 → 0.0.12

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 (2) hide show
  1. package/dist/index.js +10 -51
  2. package/package.json +5 -4
package/dist/index.js CHANGED
@@ -103,52 +103,11 @@ var notifierController = new NotifierController(sendNotification, subscribe);
103
103
 
104
104
  // src/feature/notifier/infra/web/react/NotificationHost.tsx
105
105
  import { useCallback, useEffect, useMemo as useMemo2 } from "react";
106
- import { toast as toast2, ToastContainer } from "react-toastify";
106
+ import { cssTransition, Slide, toast as toast2, ToastContainer } from "react-toastify";
107
107
 
108
108
  // src/feature/notifier/entity/notification.ts
109
109
  var DEFAULT_NOTIFICATION_CHANNEL = "app.notifications";
110
110
 
111
- // src/feature/notifier/infra/web/react/CustomToastTransition.tsx
112
- import { cssTransition } from "react-toastify";
113
- var CUSTOM_TRANSITION_STYLE_ID = "hexd-toast-transition-styles";
114
- var CUSTOM_TRANSITION_STYLES = `
115
- @keyframes slideIn {
116
- from { transform: translateY(-20px); opacity: 0; }
117
- to { transform: translateY(0); opacity: 1; }
118
- }
119
-
120
- @keyframes slideOut {
121
- from { transform: translateY(0); opacity: 1; }
122
- to { transform: translateY(-20px); opacity: 0; }
123
- }
124
-
125
- .slideIn {
126
- animation: slideIn 0.35s forwards;
127
- }
128
-
129
- .slideOut {
130
- animation: slideOut 0.25s forwards;
131
- }
132
- `;
133
- var ensureCustomToastTransitionStyles = () => {
134
- if (typeof document === "undefined") return;
135
- if (document.getElementById(CUSTOM_TRANSITION_STYLE_ID)) return;
136
- const style = document.createElement("style");
137
- style.id = CUSTOM_TRANSITION_STYLE_ID;
138
- style.textContent = CUSTOM_TRANSITION_STYLES;
139
- document.head.appendChild(style);
140
- };
141
- var SlideUp = cssTransition({
142
- enter: "slideIn",
143
- exit: "slideOut",
144
- collapseDuration: 300
145
- });
146
- var buildToastTransition = (transition) => {
147
- ensureCustomToastTransitionStyles();
148
- if (!transition) return SlideUp;
149
- return cssTransition(transition);
150
- };
151
-
152
111
  // src/feature/notifier/infra/web/react/ToastContent.tsx
153
112
  import { useMemo, useState } from "react";
154
113
  import { toast } from "react-toastify";
@@ -327,12 +286,7 @@ var DEFAULT_THEME_BASE = {
327
286
  width: "min(24rem, calc(100vw - 2rem))",
328
287
  contentPadding: "0.5rem 0.75rem 1rem 0.5rem",
329
288
  bodyColumnGap: "0.75rem",
330
- bodyRowGap: "0.25rem",
331
- transition: {
332
- enter: "slideIn",
333
- exit: "slideOut",
334
- collapseDuration: 300
335
- }
289
+ bodyRowGap: "0.25rem"
336
290
  };
337
291
  function resolveToastTheme(theme) {
338
292
  return {
@@ -350,7 +304,7 @@ function resolveToastTheme(theme) {
350
304
  contentPadding: theme?.contentPadding ?? DEFAULT_THEME_BASE.contentPadding,
351
305
  bodyColumnGap: theme?.bodyColumnGap ?? DEFAULT_THEME_BASE.bodyColumnGap,
352
306
  bodyRowGap: theme?.bodyRowGap ?? DEFAULT_THEME_BASE.bodyRowGap,
353
- transition: theme?.transition ?? DEFAULT_THEME_BASE.transition,
307
+ transition: theme?.transition,
354
308
  action: {
355
309
  ...DEFAULT_ACTION_THEME,
356
310
  ...theme?.action ?? {}
@@ -372,6 +326,10 @@ var NotificationHost = ({ channel = DEFAULT_NOTIFICATION_CHANNEL, isDark, theme
372
326
  }
373
327
  return isDark() ? "dark" : "light";
374
328
  }, [isDark]);
329
+ const transition = useMemo2(() => {
330
+ const config = resolvedTheme.transition;
331
+ return config ? cssTransition(config) : Slide;
332
+ }, [resolvedTheme.transition]);
375
333
  const style = useMemo2(() => ({
376
334
  "--toastify-color-light": resolvedTheme.lightBg,
377
335
  "--toastify-text-color-light": resolvedTheme.lightText,
@@ -386,12 +344,13 @@ var NotificationHost = ({ channel = DEFAULT_NOTIFICATION_CHANNEL, isDark, theme
386
344
  "--toastify-toast-width": resolvedTheme.width
387
345
  }), [resolvedTheme]);
388
346
  const renderToast = useCallback((notification) => {
347
+ const variant = notification.variant ?? "info";
389
348
  toast2(/* @__PURE__ */ jsx2(ToastContent, { notification, theme: resolvedTheme, mode }), {
390
349
  toastId: notification.id,
391
- icon: false
350
+ icon: false,
351
+ type: variant
392
352
  });
393
353
  }, [mode, resolvedTheme]);
394
- const transition = useMemo2(() => buildToastTransition(resolvedTheme.transition), [resolvedTheme.transition]);
395
354
  useEffect(() => {
396
355
  let unsub;
397
356
  let disposed = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexdspace/react",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,9 +21,10 @@
21
21
  "dependencies": {
22
22
  "@tanstack/react-query": "^5.90.11",
23
23
  "lucide-react": "^0.555.0",
24
+ "react-router-dom": "^7.10.1",
24
25
  "react-toastify": "^11.0.5",
25
26
  "uuid": "^13.0.0",
26
- "@hexdspace/util": "0.0.1"
27
+ "@hexdspace/util": "0.0.24"
27
28
  },
28
29
  "peerDependencies": {
29
30
  "@tanstack/react-query": "^5.90.11",
@@ -31,8 +32,8 @@
31
32
  },
32
33
  "devDependencies": {
33
34
  "@tanstack/react-query": "^5.90.11",
34
- "react": "^19.2.0",
35
- "@types/react": "^19.2.7"
35
+ "@types/react": "^19.2.7",
36
+ "react": "^19.2.0"
36
37
  },
37
38
  "scripts": {
38
39
  "build": "tsup src/index.ts --dts --format esm --clean",