@samline/notify 1.0.1 → 2.0.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/{LICENSE → LICENSE.md} +2 -2
  2. package/README.md +27 -160
  3. package/dist/_runtime.d.mts +87 -0
  4. package/dist/_runtime.d.ts +87 -0
  5. package/dist/_runtime.js +97 -0
  6. package/dist/_runtime.mjs +83 -0
  7. package/dist/browser/assets-client-B-VVPPYQ.js +114 -0
  8. package/dist/browser/assets-client-CUzxHubR.mjs +108 -0
  9. package/dist/browser/index-client-BBOQyMFk.mjs +173 -0
  10. package/dist/browser/index-client-Czb7hTpD.js +181 -0
  11. package/dist/browser/index.d.mts +134 -0
  12. package/dist/browser/index.d.ts +134 -0
  13. package/dist/browser/index.js +34 -0
  14. package/dist/browser/index.mjs +26 -0
  15. package/dist/browser/render-client-CjcQoukB.js +981 -0
  16. package/dist/browser/render-client-bGRSTd-L.mjs +974 -0
  17. package/dist/core/index.d.mts +68 -0
  18. package/dist/core/index.d.ts +68 -0
  19. package/dist/core/index.js +1 -0
  20. package/dist/core/index.mjs +1 -0
  21. package/dist/index.d.mts +131 -0
  22. package/dist/index.d.ts +131 -0
  23. package/dist/index.js +1240 -0
  24. package/dist/index.mjs +1228 -0
  25. package/dist/react/index.d.mts +158 -0
  26. package/dist/react/index.d.ts +158 -0
  27. package/dist/react/index.js +1116 -0
  28. package/dist/react/index.mjs +1107 -0
  29. package/dist/styles.css +612 -364
  30. package/dist/svelte/assets-client-B-VVPPYQ.js +114 -0
  31. package/dist/svelte/assets-client-CUzxHubR.mjs +108 -0
  32. package/dist/svelte/index-client-DbXbWMIe.js +177 -0
  33. package/dist/svelte/index-client-Dj_WfPK9.mjs +170 -0
  34. package/dist/svelte/index.d.mts +14 -0
  35. package/dist/svelte/index.d.ts +14 -0
  36. package/dist/svelte/index.js +43 -0
  37. package/dist/svelte/index.mjs +36 -0
  38. package/dist/svelte/render-client-CjcQoukB.js +981 -0
  39. package/dist/svelte/render-client-bGRSTd-L.mjs +974 -0
  40. package/dist/vue/assets-client-B-VVPPYQ.js +114 -0
  41. package/dist/vue/assets-client-CUzxHubR.mjs +108 -0
  42. package/dist/vue/index-client-DbXbWMIe.js +177 -0
  43. package/dist/vue/index-client-Dj_WfPK9.mjs +170 -0
  44. package/dist/vue/index.d.mts +50 -0
  45. package/dist/vue/index.d.ts +50 -0
  46. package/dist/vue/index.js +110 -0
  47. package/dist/vue/index.mjs +104 -0
  48. package/dist/vue/render-client-CjcQoukB.js +981 -0
  49. package/dist/vue/render-client-bGRSTd-L.mjs +974 -0
  50. package/package.json +140 -95
  51. package/dist/browser-notify.js +0 -68
  52. package/dist/cc-2Yt7NqMX.mjs +0 -21
  53. package/dist/cc-B6peeNak.mjs +0 -33
  54. package/dist/cc-BWuAzFJ6.js +0 -12
  55. package/dist/cc-CaBHsjUt.js +0 -34
  56. package/dist/cc-DGff5sSY.js +0 -21
  57. package/dist/cc-he3fHS3P.mjs +0 -12
  58. package/dist/notify.d.mts +0 -44
  59. package/dist/notify.d.mts.map +0 -1
  60. package/dist/notify.d.ts +0 -44
  61. package/dist/notify.d.ts.map +0 -1
  62. package/dist/notify.js +0 -90
  63. package/dist/notify.mjs +0 -87
  64. package/dist/react-notify-12s-7LOZlSBi.js +0 -1068
  65. package/dist/react-notify-12s-BjWbwTu8.mjs +0 -1066
  66. package/dist/react.d.mts +0 -66
  67. package/dist/react.d.mts.map +0 -1
  68. package/dist/react.d.ts +0 -66
  69. package/dist/react.d.ts.map +0 -1
  70. package/dist/react.js +0 -18
  71. package/dist/react.mjs +0 -10
  72. package/dist/svelte.d.mts +0 -45
  73. package/dist/svelte.d.mts.map +0 -1
  74. package/dist/svelte.d.ts +0 -45
  75. package/dist/svelte.d.ts.map +0 -1
  76. package/dist/svelte.js +0 -168
  77. package/dist/svelte.mjs +0 -165
  78. package/dist/vue.d.mts +0 -103
  79. package/dist/vue.d.mts.map +0 -1
  80. package/dist/vue.d.ts +0 -103
  81. package/dist/vue.d.ts.map +0 -1
  82. package/dist/vue.js +0 -2099
  83. package/dist/vue.mjs +0 -2096
package/package.json CHANGED
@@ -1,97 +1,142 @@
1
1
  {
2
- "name": "@samline/notify",
3
- "version": "1.0.1",
4
- "description": "A toast notification library designed to bring beautiful, animated notifications to React, Vue, Svelte, and Vanilla JS. Seamless integration across multiple frameworks.",
5
- "keywords": [
6
- "toast",
7
- "notification",
8
- "react",
9
- "vue",
10
- "svelte",
11
- "vanilla"
12
- ],
13
- "homepage": "https://github.com/samline/notify",
14
- "bugs": {
15
- "url": "https://github.com/samline/notify/issues"
16
- },
17
- "license": "MIT",
18
- "repository": {
19
- "type": "git",
20
- "url": "https://github.com/samline/notify"
21
- },
22
- "exports": {
23
- ".": {
24
- "import": {
25
- "types": "./dist/notify.d.mts",
26
- "default": "./dist/notify.mjs"
27
- },
28
- "require": {
29
- "types": "./dist/notify.d.ts",
30
- "default": "./dist/notify.js"
31
- },
32
- "default": "./dist/notify.js"
33
- },
34
- "./react": {
35
- "import": {
36
- "types": "./dist/react.d.mts",
37
- "default": "./dist/react.mjs"
38
- },
39
- "require": {
40
- "types": "./dist/react.d.ts",
41
- "default": "./dist/react.js"
42
- },
43
- "default": "./dist/react.js"
44
- },
45
- "./vue": {
46
- "import": {
47
- "types": "./dist/vue.d.mts",
48
- "default": "./dist/vue.mjs"
49
- },
50
- "require": {
51
- "types": "./dist/vue.d.ts",
52
- "default": "./dist/vue.js"
53
- },
54
- "default": "./dist/vue.js"
55
- },
56
- "./svelte": {
57
- "import": {
58
- "types": "./dist/svelte.d.mts",
59
- "default": "./dist/svelte.mjs"
60
- },
61
- "require": {
62
- "types": "./dist/svelte.d.ts",
63
- "default": "./dist/svelte.js"
64
- },
65
- "default": "./dist/svelte.js"
66
- }
67
- },
68
- "main": "./dist/notify.js",
69
- "types": "./dist/notify.d.ts",
70
- "files": [
71
- "dist"
72
- ],
73
- "scripts": {
74
- "build": "node scripts/build.js",
75
- "dev": "bunchee --watch",
76
- "test": "vitest run",
77
- "typecheck": "tsc --noEmit"
78
- },
79
- "peerDependencies": {
80
- "react": ">=18",
81
- "react-dom": ">=18"
82
- },
83
- "devDependencies": {
84
- "@testing-library/jest-dom": "^6.9.1",
85
- "@testing-library/react": "^16.3.2",
86
- "@types/react": "^19.2.14",
87
- "bunchee": "^6.9.4",
88
- "jsdom": "^29.0.1",
89
- "svelte": "^5.55.1",
90
- "typescript": "^5.9.3",
91
- "vitest": "^4.1.2",
92
- "vue": "^3.5.31"
93
- },
94
- "dependencies": {
95
- "motion": "^12.34.0"
96
- }
2
+ "name": "@samline/notify",
3
+ "version": "2.0.0",
4
+ "description": "A universal toast notification package for React, Vue, Svelte, vanilla JS, and browser/CDN usage.",
5
+ "exports": {
6
+ ".": {
7
+ "import": {
8
+ "types": "./dist/index.d.mts",
9
+ "default": "./dist/index.mjs"
10
+ },
11
+ "require": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./react": {
18
+ "import": {
19
+ "types": "./dist/react/index.d.mts",
20
+ "default": "./dist/react/index.mjs"
21
+ },
22
+ "require": {
23
+ "types": "./dist/react/index.d.ts",
24
+ "default": "./dist/react/index.js"
25
+ },
26
+ "default": "./dist/react/index.js"
27
+ },
28
+ "./core": {
29
+ "import": {
30
+ "types": "./dist/core/index.d.mts",
31
+ "default": "./dist/core/index.mjs"
32
+ },
33
+ "require": {
34
+ "types": "./dist/core/index.d.ts",
35
+ "default": "./dist/core/index.js"
36
+ },
37
+ "default": "./dist/core/index.js"
38
+ },
39
+ "./browser": {
40
+ "import": {
41
+ "types": "./dist/browser/index.d.mts",
42
+ "default": "./dist/browser/index.mjs"
43
+ },
44
+ "require": {
45
+ "types": "./dist/browser/index.d.ts",
46
+ "default": "./dist/browser/index.js"
47
+ },
48
+ "default": "./dist/browser/index.js"
49
+ },
50
+ "./vue": {
51
+ "import": {
52
+ "types": "./dist/vue/index.d.mts",
53
+ "default": "./dist/vue/index.mjs"
54
+ },
55
+ "require": {
56
+ "types": "./dist/vue/index.d.ts",
57
+ "default": "./dist/vue/index.js"
58
+ },
59
+ "default": "./dist/vue/index.js"
60
+ },
61
+ "./svelte": {
62
+ "import": {
63
+ "types": "./dist/svelte/index.d.mts",
64
+ "default": "./dist/svelte/index.mjs"
65
+ },
66
+ "require": {
67
+ "types": "./dist/svelte/index.d.ts",
68
+ "default": "./dist/svelte/index.js"
69
+ },
70
+ "default": "./dist/svelte/index.js"
71
+ },
72
+ "./styles.css": "./dist/styles.css",
73
+ "./dist/styles.css": "./dist/styles.css"
74
+ },
75
+ "main": "./dist/index.js",
76
+ "types": "./dist/index.d.ts",
77
+ "files": [
78
+ "dist"
79
+ ],
80
+ "scripts": {
81
+ "dev": "bun scripts/build.mjs --watch",
82
+ "build": "bun scripts/build.mjs",
83
+ "type-check": "bunx tsc --noEmit",
84
+ "format": "bunx prettier --write .",
85
+ "test": "bunx vitest run tests/runtime.test.ts tests/state.test.ts --environment node --globals",
86
+ "test:watch": "bunx vitest tests/runtime.test.ts tests/state.test.ts --environment node --globals"
87
+ },
88
+ "keywords": [
89
+ "react",
90
+ "vue",
91
+ "svelte",
92
+ "vanilla-js",
93
+ "browser",
94
+ "notifications",
95
+ "toast",
96
+ "snackbar",
97
+ "message"
98
+ ],
99
+ "author": "Emil Kowalski <e@emilkowal.ski>",
100
+ "license": "MIT",
101
+ "homepage": "https://github.com/samline/notify",
102
+ "repository": {
103
+ "type": "git",
104
+ "url": "git+https://github.com/samline/notify.git"
105
+ },
106
+ "bugs": {
107
+ "url": "https://github.com/samline/notify/issues"
108
+ },
109
+ "devDependencies": {
110
+ "@types/node": "^18.11.13",
111
+ "@types/react": "^18.0.26",
112
+ "bunchee": "6.3.3",
113
+ "prettier": "^2.8.4",
114
+ "react": "^18.2.0",
115
+ "react-dom": "^18.2.0",
116
+ "svelte": "^5.0.0",
117
+ "vue": "3.4.0",
118
+ "typescript": "^4.8.4",
119
+ "vitest": "^2.1.8"
120
+ },
121
+ "peerDependencies": {
122
+ "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc",
123
+ "react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc",
124
+ "vue": "^3.4.0",
125
+ "svelte": "^4.2.0 || ^5.0.0"
126
+ },
127
+ "peerDependenciesMeta": {
128
+ "react": {
129
+ "optional": true
130
+ },
131
+ "react-dom": {
132
+ "optional": true
133
+ },
134
+ "vue": {
135
+ "optional": true
136
+ },
137
+ "svelte": {
138
+ "optional": true
139
+ }
140
+ },
141
+ "packageManager": "bun@1.1.29"
97
142
  }
@@ -1,68 +0,0 @@
1
- (() => {
2
- // src/core/notify-core.ts
3
- class NotifyCore {
4
- toasts = [];
5
- listeners = new Set;
6
- position = "top-right";
7
- options = undefined;
8
- idCounter = 0;
9
- generateId() {
10
- return `${++this.idCounter}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
11
- }
12
- subscribe(fn) {
13
- this.listeners.add(fn);
14
- fn(this.toasts);
15
- return () => this.listeners.delete(fn);
16
- }
17
- emit() {
18
- for (const fn of this.listeners)
19
- fn(this.toasts);
20
- }
21
- update(fn) {
22
- this.toasts = fn(this.toasts);
23
- this.emit();
24
- }
25
- dismiss(id) {
26
- const item = this.toasts.find((t) => t.id === id);
27
- if (!item || item.exiting)
28
- return;
29
- this.update((prev) => prev.map((t) => t.id === id ? { ...t, exiting: true } : t));
30
- setTimeout(() => this.update((prev) => prev.filter((t) => t.id !== id)), 600);
31
- }
32
- show(opts) {
33
- const id = opts.title ? `notify-${opts.title}` : "notify-default";
34
- const prevItem = this.toasts.find((t) => t.id === id);
35
- const instanceId = prevItem?.instanceId ?? this.generateId();
36
- const state = opts.type ?? prevItem?.type ?? "success";
37
- const item = {
38
- ...prevItem,
39
- ...opts,
40
- id,
41
- instanceId,
42
- type: state
43
- };
44
- this.update((prev) => {
45
- const filtered = prev.filter((t) => t.id !== id);
46
- return [...filtered, item];
47
- });
48
- return id;
49
- }
50
- getToasts() {
51
- return this.toasts;
52
- }
53
- }
54
- var notifyCore = new NotifyCore;
55
-
56
- // src/browser-notify.js
57
- var notifyApi = {
58
- show: (options) => notifyCore.show(options),
59
- dismiss: (id) => notifyCore.dismiss(id),
60
- clear: () => {
61
- for (const toast of notifyCore.getToasts()) {
62
- notifyCore.dismiss(toast.id);
63
- }
64
- },
65
- subscribe: (listener) => notifyCore.subscribe(listener)
66
- };
67
- window.notify = notifyApi;
68
- })();
@@ -1,21 +0,0 @@
1
- function __insertCSS(code) {
2
- if (!code || typeof document == 'undefined') return
3
- let head = document.head || document.getElementsByTagName('head')[0]
4
- let style = document.createElement('style')
5
- style.type = 'text/css'
6
- head.appendChild(style)
7
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
8
- }
9
-
10
- function _extends() {
11
- _extends = Object.assign || function assign(target) {
12
- for(var i = 1; i < arguments.length; i++){
13
- var source = arguments[i];
14
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
15
- }
16
- return target;
17
- };
18
- return _extends.apply(this, arguments);
19
- }
20
-
21
- export { _extends as _ };
@@ -1,33 +0,0 @@
1
- function __insertCSS(code) {
2
- if (!code || typeof document == 'undefined') return
3
- let head = document.head || document.getElementsByTagName('head')[0]
4
- let style = document.createElement('style')
5
- style.type = 'text/css'
6
- head.appendChild(style)
7
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
8
- }
9
-
10
- function _extends() {
11
- _extends = Object.assign || function assign(target) {
12
- for(var i = 1; i < arguments.length; i++){
13
- var source = arguments[i];
14
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
15
- }
16
- return target;
17
- };
18
- return _extends.apply(this, arguments);
19
- }
20
-
21
- function _object_without_properties_loose(source, excluded) {
22
- if (source == null) return {};
23
- var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
24
- for(i = 0; i < sourceKeys.length; i++){
25
- key = sourceKeys[i];
26
- if (excluded.indexOf(key) >= 0) continue;
27
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
28
- target[key] = source[key];
29
- }
30
- return target;
31
- }
32
-
33
- export { _extends as _, _object_without_properties_loose as a };
@@ -1,12 +0,0 @@
1
- function _extends() {
2
- _extends = Object.assign || function assign(target) {
3
- for(var i = 1; i < arguments.length; i++){
4
- var source = arguments[i];
5
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
6
- }
7
- return target;
8
- };
9
- return _extends.apply(this, arguments);
10
- }
11
-
12
- exports._extends = _extends;
@@ -1,34 +0,0 @@
1
- function __insertCSS(code) {
2
- if (!code || typeof document == 'undefined') return
3
- let head = document.head || document.getElementsByTagName('head')[0]
4
- let style = document.createElement('style')
5
- style.type = 'text/css'
6
- head.appendChild(style)
7
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
8
- }
9
-
10
- function _extends() {
11
- _extends = Object.assign || function assign(target) {
12
- for(var i = 1; i < arguments.length; i++){
13
- var source = arguments[i];
14
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
15
- }
16
- return target;
17
- };
18
- return _extends.apply(this, arguments);
19
- }
20
-
21
- function _object_without_properties_loose(source, excluded) {
22
- if (source == null) return {};
23
- var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
24
- for(i = 0; i < sourceKeys.length; i++){
25
- key = sourceKeys[i];
26
- if (excluded.indexOf(key) >= 0) continue;
27
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
28
- target[key] = source[key];
29
- }
30
- return target;
31
- }
32
-
33
- exports._extends = _extends;
34
- exports._object_without_properties_loose = _object_without_properties_loose;
@@ -1,21 +0,0 @@
1
- function __insertCSS(code) {
2
- if (!code || typeof document == 'undefined') return
3
- let head = document.head || document.getElementsByTagName('head')[0]
4
- let style = document.createElement('style')
5
- style.type = 'text/css'
6
- head.appendChild(style)
7
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
8
- }
9
-
10
- function _extends() {
11
- _extends = Object.assign || function assign(target) {
12
- for(var i = 1; i < arguments.length; i++){
13
- var source = arguments[i];
14
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
15
- }
16
- return target;
17
- };
18
- return _extends.apply(this, arguments);
19
- }
20
-
21
- exports._extends = _extends;
@@ -1,12 +0,0 @@
1
- function _extends() {
2
- _extends = Object.assign || function assign(target) {
3
- for(var i = 1; i < arguments.length; i++){
4
- var source = arguments[i];
5
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
6
- }
7
- return target;
8
- };
9
- return _extends.apply(this, arguments);
10
- }
11
-
12
- export { _extends as _ };
package/dist/notify.d.mts DELETED
@@ -1,44 +0,0 @@
1
- type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
2
- interface NotifyStyles {
3
- title?: string;
4
- description?: string;
5
- badge?: string;
6
- button?: string;
7
- }
8
- interface NotifyButton {
9
- title: string;
10
- onClick: () => void;
11
- }
12
- declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
13
- type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
14
- interface NotifyOptions {
15
- title?: string;
16
- description?: string;
17
- type?: NotifyState;
18
- position?: NotifyPosition;
19
- duration?: number | null;
20
- icon?: any;
21
- styles?: NotifyStyles;
22
- fill?: string;
23
- roundness?: number;
24
- autopilot?: boolean | {
25
- expand?: number;
26
- collapse?: number;
27
- };
28
- button?: NotifyButton;
29
- }
30
-
31
- interface NotifyItem extends NotifyOptions {
32
- id: string;
33
- instanceId: string;
34
- exiting?: boolean;
35
- autoExpandDelayMs?: number;
36
- autoCollapseDelayMs?: number;
37
- }
38
-
39
- declare function showNotifyToast(options: NotifyOptions): string;
40
- declare function onNotifyToastsChange(fn: (toasts: NotifyItem[]) => void): () => void;
41
-
42
- export { onNotifyToastsChange, showNotifyToast };
43
- export type { NotifyButton, NotifyOptions, NotifyPosition, NotifyState, NotifyStyles };
44
- //# sourceMappingURL=notify.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notify.d.mts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/vanilla-notify.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACPA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,oBAAoB,cAAc,UAAU;;;;","names":[]}
package/dist/notify.d.ts DELETED
@@ -1,44 +0,0 @@
1
- type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
2
- interface NotifyStyles {
3
- title?: string;
4
- description?: string;
5
- badge?: string;
6
- button?: string;
7
- }
8
- interface NotifyButton {
9
- title: string;
10
- onClick: () => void;
11
- }
12
- declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
13
- type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
14
- interface NotifyOptions {
15
- title?: string;
16
- description?: string;
17
- type?: NotifyState;
18
- position?: NotifyPosition;
19
- duration?: number | null;
20
- icon?: any;
21
- styles?: NotifyStyles;
22
- fill?: string;
23
- roundness?: number;
24
- autopilot?: boolean | {
25
- expand?: number;
26
- collapse?: number;
27
- };
28
- button?: NotifyButton;
29
- }
30
-
31
- interface NotifyItem extends NotifyOptions {
32
- id: string;
33
- instanceId: string;
34
- exiting?: boolean;
35
- autoExpandDelayMs?: number;
36
- autoCollapseDelayMs?: number;
37
- }
38
-
39
- declare function showNotifyToast(options: NotifyOptions): string;
40
- declare function onNotifyToastsChange(fn: (toasts: NotifyItem[]) => void): () => void;
41
-
42
- export { onNotifyToastsChange, showNotifyToast };
43
- export type { NotifyButton, NotifyOptions, NotifyPosition, NotifyState, NotifyStyles };
44
- //# sourceMappingURL=notify.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notify.d.ts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/vanilla-notify.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACPA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,oBAAoB,cAAc,UAAU;;;;","names":[]}
package/dist/notify.js DELETED
@@ -1,90 +0,0 @@
1
- function __insertCSS(code) {
2
- if (!code || typeof document == 'undefined') return
3
- let head = document.head || document.getElementsByTagName('head')[0]
4
- let style = document.createElement('style')
5
- style.type = 'text/css'
6
- head.appendChild(style)
7
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
8
- }
9
-
10
- Object.defineProperty(exports, '__esModule', { value: true });
11
-
12
- var cc = require('./cc-DGff5sSY.js');
13
-
14
- __insertCSS(":root{--notify-spring-easing:linear(\n\t\t0,\n\t\t0.002 0.6%,\n\t\t0.007 1.2%,\n\t\t0.015 1.8%,\n\t\t0.026 2.4%,\n\t\t0.041 3.1%,\n\t\t0.06 3.8%,\n\t\t0.108 5.3%,\n\t\t0.157 6.6%,\n\t\t0.214 8%,\n\t\t0.467 13.7%,\n\t\t0.577 16.3%,\n\t\t0.631 17.7%,\n\t\t0.682 19.1%,\n\t\t0.73 20.5%,\n\t\t0.771 21.8%,\n\t\t0.808 23.1%,\n\t\t0.844 24.5%,\n\t\t0.874 25.8%,\n\t\t0.903 27.2%,\n\t\t0.928 28.6%,\n\t\t0.952 30.1%,\n\t\t0.972 31.6%,\n\t\t0.988 33.1%,\n\t\t1.01 35.7%,\n\t\t1.025 38.5%,\n\t\t1.034 41.6%,\n\t\t1.038 45%,\n\t\t1.035 50.1%,\n\t\t1.012 64.2%,\n\t\t1.003 73%,\n\t\t0.999 83.7%,\n\t\t1\n\t);--notify-duration:600ms;--notify-height:40px;--notify-width:350px;--notify-state-success:oklch(0.723 0.219 142.136);--notify-state-loading:oklch(0.556 0 0);--notify-state-error:oklch(0.637 0.237 25.331);--notify-state-warning:oklch(0.795 0.184 86.047);--notify-state-info:oklch(0.685 0.169 237.323);--notify-state-action:oklch(0.623 0.214 259.815)}[data-notify-toast]{position:relative;cursor:pointer;pointer-events:auto;touch-action:none;border:0;background:0 0;padding:0;width:var(--notify-width);height:var(--_h,var(--notify-height));opacity:0;transform:translateZ(0) scale(.95);transform-origin:center;contain:layout style;overflow:visible}[data-notify-toast][data-state=loading]{cursor:default}[data-notify-toast][data-ready=true]{opacity:1;transform:translateZ(0) scale(1);transition:transform calc(var(--notify-duration) * .66) var(--notify-spring-easing),opacity calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-bottom calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-top calc(var(--notify-duration) * .66) var(--notify-spring-easing),height var(--notify-duration) var(--notify-spring-easing)}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){transform:translateY(6px) scale(.95)}[data-notify-toast][data-ready=true][data-exiting=true]{opacity:0;pointer-events:none}[data-notify-viewport][data-position^=top] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(6px) scale(.95)}[data-notify-canvas]{position:absolute;left:0;right:0;pointer-events:none;transform:translateZ(0);contain:layout style;overflow:visible}[data-sileo-canvas][data-edge=top]{bottom:0;transform:scaleY(-1) translateZ(0)}[data-sileo-canvas][data-edge=bottom]{top:0}[data-notify-svg]{overflow:visible}[data-notify-header]{position:absolute;z-index:20;display:flex;align-items:center;padding:.5rem;height:var(--sileo-height);overflow:hidden;left:var(--_px,0);transform:var(--_ht);max-width:var(--_pw)}[data-notify-toast][data-ready=true] [data-notify-header]{transition:transform var(--sileo-duration) var(--sileo-spring-easing),left var(--sileo-duration) var(--sileo-spring-easing),max-width var(--sileo-duration) var(--sileo-spring-easing)}[data-notify-header][data-edge=top]{bottom:0}[data-notify-header][data-edge=bottom]{top:0}[data-notify-header-stack]{position:relative;display:inline-flex;align-items:center;height:100%}[data-notify-header-inner]{display:flex;align-items:center;gap:.5rem;white-space:nowrap;opacity:1;filter:blur(0px);transform:translateZ(0)}[data-notify-header-inner][data-layer=current]{position:relative;z-index:1;animation:sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both}[data-notify-header-inner][data-exiting=true],[data-notify-header-inner][data-layer=current]:not(:only-child){will-change:opacity,filter}[data-notify-header-inner][data-layer=prev]{position:absolute;left:0;top:0;z-index:0;pointer-events:none}[data-notify-header-inner][data-exiting=true]{animation:notify-header-exit calc(var(--notify-duration) * .7) ease forwards}[data-notify-badge]{display:flex;height:24px;width:24px;flex-shrink:0;align-items:center;justify-content:center;padding:2px;box-sizing:border-box;border-radius:9999px;color:var(--sileo-tone,currentColor);background-color:var(--sileo-tone-bg,transparent)}[data-notify-title]{font-size:.825rem;line-height:1rem;font-weight:500;text-transform:capitalize;color:var(--sileo-tone,currentColor)}:is([data-notify-badge],[data-notify-title],[data-notify-button])[data-state]{--_c:var(--notify-state-success)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=loading]{--_c:var(--notify-state-loading)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=error]{--_c:var(--notify-state-error)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=warning]{--_c:var(--notify-state-warning)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=info]{--_c:var(--notify-state-info)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=action]{--_c:var(--notify-state-action)}:is([data-notify-badge],[data-notify-title])[data-state]{--notify-tone:var(--_c);--notify-tone-bg:color-mix(in oklch, var(--_c) 20%, transparent)}[data-notify-content]{position:absolute;left:0;z-index:10;width:100%;pointer-events:none;opacity:var(--_co, 0)}[data-notify-content]:not([data-visible=true]){content-visibility:hidden}[data-notify-toast][data-ready=true] [data-notify-content]{transition:opacity calc(var(--notify-duration) * .08) ease calc(var(--notify-duration) * .04)}[data-notify-content][data-edge=top]{top:0}[data-notify-content][data-edge=bottom]{top:var(--sileo-height)}[data-notify-content][data-visible=true]{pointer-events:auto}[data-notify-toast][data-ready=true] [data-notify-content][data-visible=true]{transition:opacity calc(var(--notify-duration) * .6) ease calc(var(--notify-duration) * .3)}[data-notify-description]{width:100%;text-align:left;padding:1rem;font-size:.875rem;line-height:1.25rem;contain:layout style paint;content-visibility:auto}[data-notify-button]{display:flex;align-items:center;justify-content:center;height:1.75rem;padding:0 .625rem;margin-top:.75rem;border-radius:9999px;border:0;font-size:.75rem;font-weight:500;cursor:pointer;color:var(--sileo-btn-color,currentColor);background-color:var(--sileo-btn-bg,transparent);transition:background-color 150ms ease}[data-notify-button]:hover{background-color:var(--sileo-btn-bg-hover,transparent)}[data-notify-button][data-state]{--notify-btn-color:var(--_c);--notify-btn-bg:color-mix(in oklch, var(--_c) 15%, transparent);--notify-btn-bg-hover:color-mix(in oklch, var(--_c) 25%, transparent)}[data-notify-icon=spin]{animation:notify-spin 1s linear infinite}@keyframes notify-spin{to{transform:rotate(360deg)}}@keyframes notify-header-enter{from{opacity:0;filter:blur(6px)}to{opacity:1;filter:blur(0px)}}@keyframes notify-header-exit{from{opacity:1;filter:blur(0px)}to{opacity:0;filter:blur(6px)}}[data-notify-viewport]{position:fixed;z-index:50;display:flex;gap:.75rem;padding:.75rem;pointer-events:none;max-width:calc(100vw - 1.5rem);contain:layout style}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){margin-bottom:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){margin-top:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=top]{top:0;flex-direction:column-reverse}[data-notify-viewport][data-position^=bottom]{bottom:0;flex-direction:column}[data-notify-viewport][data-position$=left]{left:0;align-items:flex-start}[data-notify-viewport][data-position$=right]{right:0;align-items:flex-end}[data-notify-viewport][data-position$=center]{left:50%;transform:translateX(-50%);align-items:center}@media (prefers-reduced-motion:no-preference){[data-notify-toast][data-ready=true]:hover,[data-notify-toast][data-ready=true][data-exiting=true]{will-change:transform,opacity,height}}@media (prefers-reduced-motion:reduce){[data-notify-viewport],[data-notify-viewport] *,[data-notify-viewport] ::after,[data-notify-viewport] ::before{animation-duration:0s;animation-iteration-count:1;transition-duration:0s}}[data-notify-viewport][data-theme=dark] [data-notify-description]{color:rgba(0,0,0,.5)}[data-notify-viewport][data-theme=light] [data-notify-description]{color:rgba(255,255,255,.5)}");
15
-
16
- // Notify logic (no React dependencies)
17
- // Provides toast management and utilities for VanillaJS, Vue, Svelte, etc.
18
- class NotifyCore {
19
- generateId() {
20
- return `${++this.idCounter}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
21
- }
22
- subscribe(fn) {
23
- this.listeners.add(fn);
24
- fn(this.toasts);
25
- return ()=>this.listeners.delete(fn);
26
- }
27
- emit() {
28
- for (const fn of this.listeners)fn(this.toasts);
29
- }
30
- update(fn) {
31
- this.toasts = fn(this.toasts);
32
- this.emit();
33
- }
34
- dismiss(id) {
35
- const item = this.toasts.find((t)=>t.id === id);
36
- if (!item || item.exiting) return;
37
- this.update((prev)=>prev.map((t)=>t.id === id ? cc._extends({}, t, {
38
- exiting: true
39
- }) : t));
40
- setTimeout(()=>this.update((prev)=>prev.filter((t)=>t.id !== id)), 600);
41
- }
42
- show(opts) {
43
- var _ref, _ref1, _opts_type;
44
- // Use a unique identifier based on options (e.g., the title or a generated key)
45
- // If not provided, use a default one
46
- const id = opts.title ? `notify-${opts.title}` : "notify-default";
47
- const prevItem = this.toasts.find((t)=>t.id === id);
48
- const instanceId = (_ref = prevItem == null ? void 0 : prevItem.instanceId) != null ? _ref : this.generateId();
49
- // Set the state correctly
50
- const state = (_ref1 = (_opts_type = opts.type) != null ? _opts_type : prevItem == null ? void 0 : prevItem.type) != null ? _ref1 : "success";
51
- const item = cc._extends({}, prevItem, opts, {
52
- id,
53
- instanceId,
54
- type: state
55
- });
56
- this.update((prev)=>{
57
- const filtered = prev.filter((t)=>t.id !== id);
58
- return [
59
- ...filtered,
60
- item
61
- ];
62
- });
63
- return id;
64
- }
65
- getToasts() {
66
- return this.toasts;
67
- }
68
- constructor(){
69
- this.toasts = [];
70
- this.listeners = new Set();
71
- this.position = "top-right";
72
- this.options = undefined;
73
- this.idCounter = 0;
74
- }
75
- }
76
- // Global instance for multiplatform usage
77
- const notifyCore = new NotifyCore();
78
-
79
- function showNotifyToast(options) {
80
- const id = notifyCore.show(options);
81
- // ...existing code...
82
- // Aquí iría la lógica para mostrar el toast en el DOM si aplica
83
- return id;
84
- }
85
- function onNotifyToastsChange(fn) {
86
- return notifyCore.subscribe(fn);
87
- }
88
-
89
- exports.onNotifyToastsChange = onNotifyToastsChange;
90
- exports.showNotifyToast = showNotifyToast;