@khencahyo13/notifin-react 1.2.1
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/README.md +223 -0
- package/dist/core/__tests__/notifin.test.d.ts +2 -0
- package/dist/core/__tests__/notifin.test.d.ts.map +1 -0
- package/dist/core/inject-style.d.ts +2 -0
- package/dist/core/inject-style.d.ts.map +1 -0
- package/dist/core/notifin.d.ts +3 -0
- package/dist/core/notifin.d.ts.map +1 -0
- package/dist/core/store.d.ts +30 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/types.d.ts +87 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/use-notifin.d.ts +2 -0
- package/dist/core/use-notifin.d.ts.map +1 -0
- package/dist/core/utils.d.ts +3 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/e2e/consumer.test.d.ts +2 -0
- package/dist/e2e/consumer.test.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/notifin.cjs +6 -0
- package/dist/notifin.css +1 -0
- package/dist/notifin.js +749 -0
- package/dist/provider/icons.d.ts +16 -0
- package/dist/provider/icons.d.ts.map +1 -0
- package/dist/provider/notifin.d.ts +3 -0
- package/dist/provider/notifin.d.ts.map +1 -0
- package/package.json +85 -0
package/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Notifin
|
|
2
|
+
|
|
3
|
+
Function-first alert dialog library for React, built on Radix Alert Dialog primitives with bundled styles and optional theme overrides.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @khencahyo13/notifin-react
|
|
9
|
+
# or: npm i @khencahyo13/notifin-react
|
|
10
|
+
# or: yarn add @khencahyo13/notifin-react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peer dependency: `react` and `react-dom` version `>=18`.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Mount host once in app root:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { Notifin } from '@khencahyo13/notifin-react';
|
|
21
|
+
|
|
22
|
+
export function AppLayout() {
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<Notifin />
|
|
26
|
+
{/* your app */}
|
|
27
|
+
</>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Call notifications anywhere:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { notifin } from '@khencahyo13/notifin-react';
|
|
36
|
+
|
|
37
|
+
notifin('Saved draft');
|
|
38
|
+
notifin.success('Profile updated');
|
|
39
|
+
notifin.error('Upload failed', {
|
|
40
|
+
description: 'Please retry in a few seconds.',
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`Notifin` props:
|
|
45
|
+
|
|
46
|
+
- `colorScheme?: 'system' | 'light' | 'dark'` (default `system`)
|
|
47
|
+
- `motion?: 'subtle' | 'slide' | 'scale' | 'bounce' | 'none'` (default `subtle`)
|
|
48
|
+
- `showQueueCount?: boolean` (default `true`)
|
|
49
|
+
- `theme?: { icons?, dialogToneClasses?, iconToneClasses?, schemes? }`
|
|
50
|
+
|
|
51
|
+
## Custom Theme
|
|
52
|
+
|
|
53
|
+
You can override per-type visuals with the `theme` prop on `Notifin`. You can also override default icons using any icon package (for example: Lucide, Tabler, Heroicons, custom SVG).
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { Notifin } from '@khencahyo13/notifin-react';
|
|
57
|
+
|
|
58
|
+
function RocketIcon({ className }: { className?: string }) {
|
|
59
|
+
return (
|
|
60
|
+
<svg
|
|
61
|
+
className={className}
|
|
62
|
+
fill="none"
|
|
63
|
+
stroke="currentColor"
|
|
64
|
+
viewBox="0 0 24 24"
|
|
65
|
+
>
|
|
66
|
+
<path d="M5 19c2.5 0 4.5-2 4.5-4.5v-1l5-5c2-2 4.5-2 5.5-2-.1 1-.1 3.5-2 5.5l-5 5h-1C9 17 7 19 7 21" />
|
|
67
|
+
<circle cx="14.5" cy="9.5" r="1.5" />
|
|
68
|
+
</svg>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function AppLayout() {
|
|
73
|
+
return (
|
|
74
|
+
<Notifin
|
|
75
|
+
theme={{
|
|
76
|
+
dialogToneClasses: {
|
|
77
|
+
success:
|
|
78
|
+
'border-emerald-300 bg-emerald-50 text-emerald-950',
|
|
79
|
+
error: 'border-rose-300 bg-rose-50 text-rose-950',
|
|
80
|
+
},
|
|
81
|
+
iconToneClasses: {
|
|
82
|
+
success:
|
|
83
|
+
'border-emerald-400 bg-emerald-100 text-emerald-700',
|
|
84
|
+
error: 'border-rose-400 bg-rose-100 text-rose-700',
|
|
85
|
+
},
|
|
86
|
+
icons: {
|
|
87
|
+
success: RocketIcon,
|
|
88
|
+
},
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Theme shape:
|
|
96
|
+
|
|
97
|
+
- `theme.dialogToneClasses`: partial map of `default | success | error | warning | info | loading` to class string for dialog container.
|
|
98
|
+
- `theme.iconToneClasses`: partial map of `default | success | error | warning | info | loading` to class string for icon chip.
|
|
99
|
+
- `theme.icons`: partial map of `default | success | error | warning | info | loading` to custom React icon component.
|
|
100
|
+
- `theme.schemes.light` / `theme.schemes.dark`: per-color-scheme override for `dialogToneClasses`, `iconToneClasses`, plus optional `className` for content root.
|
|
101
|
+
|
|
102
|
+
Motion presets:
|
|
103
|
+
|
|
104
|
+
- `subtle`: fade + gentle zoom
|
|
105
|
+
- `slide`: fade + slight vertical slide
|
|
106
|
+
- `scale`: fade + stronger scale
|
|
107
|
+
- `bounce`: fade + spring-like bounce
|
|
108
|
+
- `none`: no animation
|
|
109
|
+
|
|
110
|
+
Example per-scheme theme:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<Notifin
|
|
114
|
+
colorScheme="system"
|
|
115
|
+
theme={{
|
|
116
|
+
schemes: {
|
|
117
|
+
light: {
|
|
118
|
+
dialogToneClasses: {
|
|
119
|
+
error: 'border-rose-300 bg-white text-rose-900',
|
|
120
|
+
},
|
|
121
|
+
iconToneClasses: {
|
|
122
|
+
error: 'border-rose-400 bg-rose-50 text-rose-700',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
dark: {
|
|
126
|
+
className: 'ring-1 ring-white/10',
|
|
127
|
+
dialogToneClasses: {
|
|
128
|
+
error: 'border-rose-900 bg-zinc-900 text-rose-200',
|
|
129
|
+
},
|
|
130
|
+
iconToneClasses: {
|
|
131
|
+
error: 'border-rose-800 bg-rose-950/40 text-rose-300',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
}}
|
|
136
|
+
/>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
With actions:
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
notifin.warning('Delete this item?', {
|
|
143
|
+
description: 'This action cannot be undone.',
|
|
144
|
+
action: {
|
|
145
|
+
label: 'Delete',
|
|
146
|
+
onClick: () => console.log('delete'),
|
|
147
|
+
},
|
|
148
|
+
cancel: {
|
|
149
|
+
label: 'Cancel',
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Promise helper:
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
await notifin.promise(saveProfile(), {
|
|
158
|
+
loading: {
|
|
159
|
+
title: 'Saving profile...',
|
|
160
|
+
description: 'Please wait',
|
|
161
|
+
},
|
|
162
|
+
success: () => 'Profile saved',
|
|
163
|
+
error: () => 'Failed to save profile',
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## API
|
|
168
|
+
|
|
169
|
+
- `notifin(title, options?)` -> returns `id`
|
|
170
|
+
- `notifin.success(title, options?)` -> returns `id`
|
|
171
|
+
- `notifin.error(title, options?)` -> returns `id`
|
|
172
|
+
- `notifin.warning(title, options?)` -> returns `id`
|
|
173
|
+
- `notifin.info(title, options?)` -> returns `id`
|
|
174
|
+
- `notifin.loading(title, options?)` -> returns `id`
|
|
175
|
+
- `notifin.update(id, options)`
|
|
176
|
+
- `notifin.dismiss(id?)`
|
|
177
|
+
- `notifin.promise(promise, messages)`
|
|
178
|
+
|
|
179
|
+
## Notes
|
|
180
|
+
|
|
181
|
+
- Powered by `@radix-ui/react-alert-dialog`.
|
|
182
|
+
- Styles are injected automatically when you import from `@khencahyo13/notifin-react`.
|
|
183
|
+
- Optional: import `@khencahyo13/notifin-react/style.css` manually if you prefer explicit CSS loading.
|
|
184
|
+
- Built-in dark theme support via `colorScheme` (`system`, `light`, `dark`).
|
|
185
|
+
- No Tailwind setup is required.
|
|
186
|
+
- `@radix-ui/react-alert-dialog` and `@radix-ui/react-visually-hidden` are already included by this package, so no manual install is needed.
|
|
187
|
+
- `Notifin` must be mounted for dialogs to render.
|
|
188
|
+
- Calling `notifin` API methods without a mounted `<Notifin />` will throw an error to prevent silent failures.
|
|
189
|
+
- Dialogs are queued; one dialog is shown at a time.
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
This project is licensed under the `ISC` license.
|
|
194
|
+
|
|
195
|
+
## Contributing
|
|
196
|
+
|
|
197
|
+
Contributions are welcome.
|
|
198
|
+
|
|
199
|
+
1. Fork this repository.
|
|
200
|
+
2. Create a feature/fix branch.
|
|
201
|
+
3. Make your changes with tests and documentation updates.
|
|
202
|
+
4. Open a pull request with clear context and change summary.
|
|
203
|
+
|
|
204
|
+
Before submitting, run:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
pnpm lint
|
|
208
|
+
pnpm typecheck
|
|
209
|
+
pnpm test
|
|
210
|
+
pnpm prettier:fix
|
|
211
|
+
pnpm test:e2e
|
|
212
|
+
pnpm build
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Bug Report
|
|
216
|
+
|
|
217
|
+
If you find a bug, please open an issue and include:
|
|
218
|
+
|
|
219
|
+
- package version (`@khencahyo13/notifin-react`)
|
|
220
|
+
- React version
|
|
221
|
+
- minimal reproduction (repo or code snippet)
|
|
222
|
+
- expected vs actual behavior
|
|
223
|
+
- screenshots/error logs (if available)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifin.test.d.ts","sourceRoot":"","sources":["../../../src/core/__tests__/notifin.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-style.d.ts","sourceRoot":"","sources":["../../src/core/inject-style.ts"],"names":[],"mappings":"AAMA,wBAAgB,mBAAmB,SAgBlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifin.d.ts","sourceRoot":"","sources":["../../src/core/notifin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,SAAS,EAKZ,MAAM,SAAS,CAAC;AA0CjB,eAAO,MAAM,OAAO,EAAE,SAsErB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NotifinItem, NotifinShowOptions, NotifinSnapshot, NotifinType } from './types';
|
|
2
|
+
type Listener = () => void;
|
|
3
|
+
type DialogPatch = Partial<Omit<NotifinItem, 'createdAt' | 'id'>>;
|
|
4
|
+
declare class NotifinStore {
|
|
5
|
+
private listeners;
|
|
6
|
+
private dialogs;
|
|
7
|
+
private order;
|
|
8
|
+
private activeId;
|
|
9
|
+
private snapshot;
|
|
10
|
+
private removeTimeouts;
|
|
11
|
+
private durationTimeouts;
|
|
12
|
+
private hostCount;
|
|
13
|
+
subscribe(listener: Listener): () => boolean;
|
|
14
|
+
registerHost(): () => void;
|
|
15
|
+
hasHost(): boolean;
|
|
16
|
+
getSnapshot(): NotifinSnapshot;
|
|
17
|
+
create(type: NotifinType, title: string, options?: NotifinShowOptions): string;
|
|
18
|
+
update(id: string, patch: DialogPatch): void;
|
|
19
|
+
dismiss(id?: string): void;
|
|
20
|
+
private dismissActive;
|
|
21
|
+
private removeImmediately;
|
|
22
|
+
private promoteNext;
|
|
23
|
+
private startDurationTimer;
|
|
24
|
+
private clearDurationTimer;
|
|
25
|
+
private clearRemoveTimer;
|
|
26
|
+
private emit;
|
|
27
|
+
}
|
|
28
|
+
export declare const notifinStore: NotifinStore;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/core/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,WAAW,EACd,MAAM,SAAS,CAAC;AASjB,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAC3B,KAAK,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC;AAElE,cAAM,YAAY;IACd,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,QAAQ,CAGd;IACF,OAAO,CAAC,cAAc,CAAoD;IAC1E,OAAO,CAAC,gBAAgB,CAAoD;IAC5E,OAAO,CAAC,SAAS,CAAK;IAEtB,SAAS,CAAC,QAAQ,EAAE,QAAQ;IAK5B,YAAY;IAQZ,OAAO;IAIP,WAAW,IAAI,eAAe;IAI9B,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB;IAqCzE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAsBrC,OAAO,CAAC,EAAE,CAAC,EAAE,MAAM;IAgBnB,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,IAAI;CAcf;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
export type NotifinType = 'default' | 'error' | 'info' | 'loading' | 'success' | 'warning';
|
|
3
|
+
export interface NotifinAction {
|
|
4
|
+
label: string;
|
|
5
|
+
onClick?: () => Promise<void> | void;
|
|
6
|
+
}
|
|
7
|
+
export interface NotifinShowOptions {
|
|
8
|
+
action?: NotifinAction;
|
|
9
|
+
allowEscapeClose?: boolean;
|
|
10
|
+
cancel?: NotifinAction;
|
|
11
|
+
description?: string;
|
|
12
|
+
dismissible?: boolean;
|
|
13
|
+
duration?: number;
|
|
14
|
+
id?: string;
|
|
15
|
+
onDismiss?: () => void;
|
|
16
|
+
title?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface NotifinItem extends Required<Pick<NotifinShowOptions, 'dismissible'>> {
|
|
19
|
+
action?: NotifinAction;
|
|
20
|
+
allowEscapeClose?: boolean;
|
|
21
|
+
cancel?: NotifinAction;
|
|
22
|
+
createdAt: number;
|
|
23
|
+
description?: string;
|
|
24
|
+
duration?: number;
|
|
25
|
+
id: string;
|
|
26
|
+
onDismiss?: () => void;
|
|
27
|
+
open: boolean;
|
|
28
|
+
title: string;
|
|
29
|
+
type: NotifinType;
|
|
30
|
+
}
|
|
31
|
+
export interface NotifinSnapshot {
|
|
32
|
+
current: NotifinItem | null;
|
|
33
|
+
pendingCount: number;
|
|
34
|
+
}
|
|
35
|
+
export interface NotifinPromiseMessages<TData = unknown> {
|
|
36
|
+
error: ((error: unknown) => NotifinShowOptions | string) | string;
|
|
37
|
+
loading: NotifinShowOptions | string;
|
|
38
|
+
success: ((data: TData) => NotifinShowOptions | string) | string;
|
|
39
|
+
}
|
|
40
|
+
export interface NotifinUpdateOptions extends Partial<NotifinShowOptions> {
|
|
41
|
+
title?: string;
|
|
42
|
+
type?: NotifinType;
|
|
43
|
+
}
|
|
44
|
+
export interface NotifinFn {
|
|
45
|
+
(title: string, options?: NotifinShowOptions): string;
|
|
46
|
+
dismiss: (id?: string) => void;
|
|
47
|
+
error: (title: string, options?: NotifinShowOptions) => string;
|
|
48
|
+
info: (title: string, options?: NotifinShowOptions) => string;
|
|
49
|
+
loading: (title: string, options?: NotifinShowOptions) => string;
|
|
50
|
+
promise: <TData>(promise: Promise<TData>, messages: NotifinPromiseMessages<TData>) => Promise<TData>;
|
|
51
|
+
success: (title: string, options?: NotifinShowOptions) => string;
|
|
52
|
+
update: (id: string, options: NotifinUpdateOptions) => void;
|
|
53
|
+
warning: (title: string, options?: NotifinShowOptions) => string;
|
|
54
|
+
}
|
|
55
|
+
export type NotifinIconComponent = ComponentType<{
|
|
56
|
+
className?: string;
|
|
57
|
+
}>;
|
|
58
|
+
export type NotifinThemeClassMap = Record<NotifinType, string>;
|
|
59
|
+
export type NotifinThemeIcons = Record<NotifinType, NotifinIconComponent>;
|
|
60
|
+
export type NotifinColorScheme = 'dark' | 'light' | 'system';
|
|
61
|
+
export type NotifinMotionPreset = 'bounce' | 'none' | 'scale' | 'slide' | 'subtle';
|
|
62
|
+
export interface NotifinSchemeThemeConfig {
|
|
63
|
+
className?: string;
|
|
64
|
+
dialogToneClasses?: Partial<NotifinThemeClassMap>;
|
|
65
|
+
iconToneClasses?: Partial<NotifinThemeClassMap>;
|
|
66
|
+
}
|
|
67
|
+
export interface NotifinThemeConfig {
|
|
68
|
+
dialogToneClasses?: Partial<NotifinThemeClassMap>;
|
|
69
|
+
icons?: Partial<NotifinThemeIcons>;
|
|
70
|
+
iconToneClasses?: Partial<NotifinThemeClassMap>;
|
|
71
|
+
schemes?: Partial<Record<'dark' | 'light', NotifinSchemeThemeConfig>>;
|
|
72
|
+
}
|
|
73
|
+
export interface NotifinProps {
|
|
74
|
+
colorScheme?: NotifinColorScheme;
|
|
75
|
+
motion?: NotifinMotionPreset;
|
|
76
|
+
showQueueCount?: boolean;
|
|
77
|
+
theme?: NotifinThemeConfig;
|
|
78
|
+
}
|
|
79
|
+
export interface NotifinBodyProps {
|
|
80
|
+
dialog: NotifinItem;
|
|
81
|
+
dialogToneClasses: NotifinThemeClassMap;
|
|
82
|
+
icons: NotifinThemeIcons;
|
|
83
|
+
iconToneClasses: NotifinThemeClassMap;
|
|
84
|
+
pendingCount: number;
|
|
85
|
+
showQueueCount: boolean;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-notifin.d.ts","sourceRoot":"","sources":["../../src/core/use-notifin.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,sCAM9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAC;AAG7C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumer.test.d.ts","sourceRoot":"","sources":["../../src/e2e/consumer.test.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { notifin } from './core/notifin';
|
|
2
|
+
export type { NotifinAction, NotifinBodyProps, NotifinColorScheme, NotifinFn, NotifinIconComponent, NotifinItem, NotifinMotionPreset, NotifinPromiseMessages, NotifinProps, NotifinSchemeThemeConfig, NotifinShowOptions, NotifinThemeClassMap, NotifinThemeConfig, NotifinThemeIcons, NotifinType, NotifinUpdateOptions, } from './core/types';
|
|
3
|
+
export { Notifin } from './provider/notifin';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,YAAY,EACR,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,oBAAoB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/notifin.cjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react"),de=require("@radix-ui/react-alert-dialog"),ue=require("@radix-ui/react-visually-hidden"),me=require("clsx"),he=require("tailwind-merge");function be(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(n,o,s.get?s:{enumerable:!0,get:()=>t[o]})}}return n.default=t,Object.freeze(n)}const b=be(de),pe=":root{--nf-overlay-bg: rgb(0 0 0 / .5);--nf-content-width: min(92vw, 24rem);--nf-content-max-height: 90dvh;--nf-content-radius: .75rem;--nf-content-padding: 1rem;--nf-content-shadow: 0 20px 30px -12px rgb(0 0 0 / .25);--nf-text-title-size: 1rem;--nf-text-title-weight: 600;--nf-text-description-size: .875rem;--nf-text-pending-size: .75rem;--nf-icon-wrap-size: 1.75rem;--nf-icon-size: 1rem;--nf-button-height: 2rem;--nf-button-radius: .375rem;--nf-button-padding-x: 1rem;--nf-button-font-size: .875rem;--nf-button-min-width-sm: 6rem;--nf-focus-ring: 0 0 0 2px #a3a3a3}.nf-icon-wrap{flex-shrink:0;display:flex;width:var(--nf-icon-wrap-size);height:var(--nf-icon-wrap-size);align-items:center;justify-content:center;border:1px solid transparent;border-radius:9999px}.nf-icon{width:var(--nf-icon-size);height:var(--nf-icon-size)}.nf-icon-spin{animation:nf-spin 1s linear infinite}.nf-title{margin:0;font-size:var(--nf-text-title-size);font-weight:var(--nf-text-title-weight);line-height:1.35;word-break:break-word}.nf-description{margin:0;color:#525252;font-size:var(--nf-text-description-size);line-height:1.45;word-break:break-word}.nf-pending{color:#737373;font-size:var(--nf-text-pending-size)}.nf-button{height:var(--nf-button-height);width:100%;min-width:0;display:inline-flex;align-items:center;justify-content:center;padding:0 var(--nf-button-padding-x);border-radius:var(--nf-button-radius);border:1px solid transparent;font-size:var(--nf-button-font-size);font-weight:500;line-height:1;cursor:pointer;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.nf-button:focus-visible{outline:none;box-shadow:var(--nf-focus-ring)}.nf-button:disabled{cursor:not-allowed;opacity:.6}.nf-button-cancel{border-color:#d4d4d4;background:#fff;color:#404040}.nf-button-cancel:hover:not(:disabled){background:#f5f5f5}.nf-button-action{color:#fff}@media(min-width:640px){.nf-button{width:auto;min-width:var(--nf-button-min-width-sm)}}.nf-title-row{display:flex;align-items:center;gap:.5rem}.nf-actions{display:flex;width:100%;align-items:center;gap:.5rem}@media(min-width:640px){.nf-actions{justify-content:flex-end}}.nf-overlay{position:fixed;inset:0;z-index:50;background:var(--nf-overlay-bg)}.nf-content{position:fixed;top:50%;left:50%;z-index:50;width:var(--nf-content-width);max-height:var(--nf-content-max-height);overflow-y:auto;transform:translate(-50%,-50%);border:1px solid transparent;border-radius:var(--nf-content-radius);padding:var(--nf-content-padding);box-shadow:var(--nf-content-shadow);outline:none}.nf-header{display:grid;gap:.375rem}.nf-footer{margin-top:1rem;display:grid;gap:.5rem}.nf-action-default{background:#171717}.nf-action-default:hover:not(:disabled){background:#262626}.nf-action-error{background:#dc2626}.nf-action-error:hover:not(:disabled){background:#b91c1c}.nf-action-info{background:#2563eb}.nf-action-info:hover:not(:disabled){background:#1d4ed8}.nf-action-success{background:#16a34a}.nf-action-success:hover:not(:disabled){background:#15803d}.nf-action-warning{background:#ca8a04}.nf-action-warning:hover:not(:disabled){background:#a16207}.nf-dialog-tone-default{border-color:#e5e5e5;background:#fff;color:#0a0a0a}.nf-dialog-tone-error{border-color:#fecaca;background:#fff;color:#7f1d1d}.nf-dialog-tone-info{border-color:#bfdbfe;background:#fff;color:#1e3a8a}.nf-dialog-tone-loading{border-color:#e5e5e5;background:#fff;color:#0a0a0a}.nf-dialog-tone-success{border-color:#bbf7d0;background:#fff;color:#14532d}.nf-dialog-tone-warning{border-color:#fde68a;background:#fff;color:#713f12}.nf-icon-tone-default{border-color:#e5e5e5;background:#f5f5f5;color:#404040}.nf-icon-tone-error{border-color:#fca5a5;background:#fef2f2;color:#dc2626}.nf-icon-tone-info{border-color:#93c5fd;background:#eff6ff;color:#2563eb}.nf-icon-tone-loading{border-color:#e5e5e5;background:#f5f5f5;color:#525252}.nf-icon-tone-success{border-color:#86efac;background:#f0fdf4;color:#16a34a}.nf-icon-tone-warning{border-color:#fcd34d;background:#fefce8;color:#ca8a04}.nf-scheme-dark{--nf-overlay-bg: rgb(0 0 0 / .72);--nf-content-shadow: 0 20px 35px -14px rgb(0 0 0 / .7);--nf-focus-ring: 0 0 0 2px #525252}.nf-scheme-dark.nf-dialog-tone-default,.nf-scheme-dark.nf-dialog-tone-loading{border-color:#404040;background:#171717;color:#fafafa}.nf-scheme-dark.nf-dialog-tone-error{border-color:#7f1d1d;background:#1f1416;color:#fecaca}.nf-scheme-dark.nf-dialog-tone-info{border-color:#1e3a8a;background:#111827;color:#bfdbfe}.nf-scheme-dark.nf-dialog-tone-success{border-color:#14532d;background:#0d1f14;color:#bbf7d0}.nf-scheme-dark.nf-dialog-tone-warning{border-color:#713f12;background:#22180b;color:#fde68a}.nf-scheme-dark .nf-description{color:#d4d4d4}.nf-scheme-dark .nf-pending{color:#a3a3a3}.nf-scheme-dark .nf-button-cancel{border-color:#525252;background:#262626;color:#f5f5f5}.nf-scheme-dark .nf-button-cancel:hover:not(:disabled){background:#333}.nf-scheme-dark .nf-icon-tone-default,.nf-scheme-dark .nf-icon-tone-loading{border-color:#525252;background:#262626;color:#d4d4d4}.nf-scheme-dark .nf-icon-tone-error{border-color:#7f1d1d;background:#2b1318;color:#f87171}.nf-scheme-dark .nf-icon-tone-info{border-color:#1d4ed8;background:#172554;color:#93c5fd}.nf-scheme-dark .nf-icon-tone-success{border-color:#166534;background:#13271a;color:#86efac}.nf-scheme-dark .nf-icon-tone-warning{border-color:#92400e;background:#2c2110;color:#facc15}.nf-overlay:not(.nf-motion-none)[data-state=open]{animation:nf-fade-in .2s ease-out both}.nf-overlay:not(.nf-motion-none)[data-state=closed]{animation:nf-fade-out .2s ease-in both}.nf-content.nf-motion-subtle[data-state=open]{animation:nf-fade-in .2s ease-out both,nf-zoom-in-subtle .2s ease-out both}.nf-content.nf-motion-subtle[data-state=closed]{animation:nf-fade-out .2s ease-in both,nf-zoom-out-subtle .2s ease-in both}.nf-content.nf-motion-slide[data-state=open]{animation:nf-fade-in .22s ease-out both,nf-slide-in-top .22s ease-out both}.nf-content.nf-motion-slide[data-state=closed]{animation:nf-fade-out .18s ease-in both,nf-slide-out-top .2s ease-in both}.nf-content.nf-motion-scale[data-state=open]{animation:nf-fade-in .2s ease-out both,nf-scale-in .2s ease-out both}.nf-content.nf-motion-scale[data-state=closed]{animation:nf-fade-out .18s ease-in both,nf-scale-out .18s ease-in both}.nf-content.nf-motion-bounce[data-state=open]{animation:nf-fade-in .24s ease-out both,nf-bounce-in .24s cubic-bezier(.2,.8,.2,1) both}.nf-content.nf-motion-bounce[data-state=closed]{animation:nf-fade-out .18s ease-in both,nf-bounce-out .18s ease-in both}.nf-content.nf-motion-none,.nf-overlay.nf-motion-none{animation:none!important;transition:none!important}@media(prefers-reduced-motion:reduce){.nf-overlay,.nf-content,.nf-icon-spin{animation:none!important;transition:none!important}}@keyframes nf-fade-in{0%{opacity:0}to{opacity:1}}@keyframes nf-fade-out{0%{opacity:1}to{opacity:0}}@keyframes nf-zoom-in-subtle{0%{transform:translate(-50%,-50%) scale(.95)}to{transform:translate(-50%,-50%) scale(1)}}@keyframes nf-zoom-out-subtle{0%{transform:translate(-50%,-50%) scale(1)}to{transform:translate(-50%,-50%) scale(.95)}}@keyframes nf-slide-in-top{0%{transform:translate(-50%,calc(-50% - 8px))}to{transform:translate(-50%,-50%)}}@keyframes nf-slide-out-top{0%{transform:translate(-50%,-50%)}to{transform:translate(-50%,calc(-50% - 8px))}}@keyframes nf-scale-in{0%{transform:translate(-50%,-50%) scale(.9)}to{transform:translate(-50%,-50%) scale(1)}}@keyframes nf-scale-out{0%{transform:translate(-50%,-50%) scale(1)}to{transform:translate(-50%,-50%) scale(.9)}}@keyframes nf-bounce-in{0%{transform:translate(-50%,calc(-50% - 12px)) scale(.92)}60%{transform:translate(-50%,-50%) scale(1.03)}to{transform:translate(-50%,-50%) scale(1)}}@keyframes nf-bounce-out{0%{transform:translate(-50%,-50%) scale(1)}to{transform:translate(-50%,calc(-50% - 8px)) scale(.95)}}@keyframes nf-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}",H="notifin-style";let L=!1;function ge(){if(L||typeof document>"u")return;if(document.getElementById(H)){L=!0;return}const t=document.createElement("style");t.id=H,t.textContent=pe,document.head.appendChild(t),L=!0}const ve=120,ke=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`;class xe{constructor(){this.listeners=new Set,this.dialogs=new Map,this.order=[],this.activeId=null,this.snapshot={current:null,pendingCount:0},this.removeTimeouts=new Map,this.durationTimeouts=new Map,this.hostCount=0}subscribe(n){return this.listeners.add(n),()=>this.listeners.delete(n)}registerHost(){return this.hostCount+=1,()=>{this.hostCount=Math.max(0,this.hostCount-1)}}hasHost(){return this.hostCount>0}getSnapshot(){return this.snapshot}create(n,o,s={}){const r=s.id??ke(),c=this.dialogs.get(r),l=this.activeId===r||this.activeId===null,m={action:s.action,allowEscapeClose:s.allowEscapeClose,cancel:s.cancel,createdAt:c?.createdAt??Date.now(),description:s.description,dismissible:s.dismissible??!0,duration:s.duration,id:r,onDismiss:s.onDismiss,open:l,title:o,type:n};return this.clearDurationTimer(r),this.clearRemoveTimer(r),this.dialogs.set(r,m),this.order.includes(r)||this.order.push(r),this.activeId===null&&(this.activeId=r,this.startDurationTimer(r)),this.emit(),r}update(n,o){const s=this.dialogs.get(n);if(!s)return;const r={...s,...o,createdAt:s.createdAt,id:n};this.dialogs.set(n,r),this.activeId===n&&this.startDurationTimer(n),this.emit()}dismiss(n){if(!n){this.activeId&&this.dismissActive(this.activeId);return}if(this.activeId===n){this.dismissActive(n);return}this.removeImmediately(n)}dismissActive(n){const o=this.dialogs.get(n);if(!o||!o.open)return;this.clearDurationTimer(n),this.dialogs.set(n,{...o,open:!1}),this.emit();const s=setTimeout(()=>{this.removeImmediately(n),this.promoteNext()},ve);this.removeTimeouts.set(n,s)}removeImmediately(n){const o=this.dialogs.get(n);o&&(this.clearDurationTimer(n),this.clearRemoveTimer(n),this.dialogs.delete(n),this.order=this.order.filter(s=>s!==n),this.activeId===n&&(this.activeId=null),o.onDismiss?.(),this.emit())}promoteNext(){if(this.activeId!==null)return;const n=this.order[0];if(!n)return;const o=this.dialogs.get(n);if(!o){this.order.shift(),this.promoteNext();return}this.activeId=n,this.dialogs.set(n,{...o,open:!0}),this.startDurationTimer(n),this.emit()}startDurationTimer(n){this.clearDurationTimer(n);const o=this.dialogs.get(n);if(!o?.duration||this.activeId!==n)return;const s=setTimeout(()=>this.dismiss(n),o.duration);this.durationTimeouts.set(n,s)}clearDurationTimer(n){const o=this.durationTimeouts.get(n);o&&(clearTimeout(o),this.durationTimeouts.delete(n))}clearRemoveTimer(n){const o=this.removeTimeouts.get(n);o&&(clearTimeout(o),this.removeTimeouts.delete(n))}emit(){const n=this.activeId?this.dialogs.get(this.activeId)??null:null,o=Math.max(this.order.length-(n?1:0),0);this.snapshot={current:n,pendingCount:o};for(const s of this.listeners)s()}}const h=new xe;function $(){if(!h.hasHost())throw new Error("[notifin] <Notifin /> is not mounted. Render <Notifin /> once in your app root before calling notifin(...).")}function Y(t){return typeof t=="string"?{title:t}:t}function J(t,n){return typeof t=="function"?t(n):t}function g(t,n,o){return $(),h.create(t,n,o)}const ye=Object.assign((t,n)=>g("default",t,n),{dismiss:t=>{$(),h.dismiss(t)},error:(t,n)=>g("error",t,n),info:(t,n)=>g("info",t,n),loading:(t,n)=>g("loading",t,{dismissible:!1,...n}),async promise(t,n){const o=Y(n.loading),s=g("loading",o.title??"Loading...",{dismissible:!1,...o});try{const r=await t,c=J(n.success,r),l=Y(c);return h.update(s,{...l,dismissible:l.dismissible??!0,open:!0,title:l.title??"Success",type:"success"}),r}catch(r){const c=J(n.error,r),l=Y(c);throw h.update(s,{...l,dismissible:l.dismissible??!0,open:!0,title:l.title??"Something went wrong",type:"error"}),r}},success:(t,n)=>g("success",t,n),update:(t,n)=>{$(),h.update(t,{...n,title:n.title,type:n.type})},warning:(t,n)=>g("warning",t,n)});var N={exports:{}},_={};var G;function we(){if(G)return _;G=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(s,r,c){var l=null;if(c!==void 0&&(l=""+c),r.key!==void 0&&(l=""+r.key),"key"in r){c={};for(var m in r)m!=="key"&&(c[m]=r[m])}else c=r;return r=c.ref,{$$typeof:t,type:s,key:l,ref:r!==void 0?r:null,props:c}}return _.Fragment=n,_.jsx=o,_.jsxs=o,_}var R={};var X;function Te(){return X||(X=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case ee:return"Profiler";case K:return"StrictMode";case re:return"Suspense";case se:return"SuspenseList";case ae:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case A:return"Portal";case te:return e.displayName||"Context";case ne:return(e._context.displayName||"Context")+".Consumer";case oe:var i=e.render;return e=e.displayName,e||(e=i.displayName||i.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ie:return i=e.displayName||null,i!==null?i:t(e.type)||"Memo";case I:i=e._payload,e=e._init;try{return t(e(i))}catch{}}return null}function n(e){return""+e}function o(e){try{n(e);var i=!1}catch{i=!0}if(i){i=console;var f=i.error,d=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return f.call(i,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",d),n(e)}}function s(e){if(e===O)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===I)return"<...>";try{var i=t(e);return i?"<"+i+">":"<...>"}catch{return"<...>"}}function r(){var e=P.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function l(e){if(W.call(e,"key")){var i=Object.getOwnPropertyDescriptor(e,"key").get;if(i&&i.isReactWarning)return!1}return e.key!==void 0}function m(e,i){function f(){F||(F=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",i))}f.isReactWarning=!0,Object.defineProperty(e,"key",{get:f,configurable:!0})}function E(){var e=t(this.type);return U[e]||(U[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function j(e,i,f,d,S,z){var u=f.ref;return e={$$typeof:C,type:e,key:i,props:f,_owner:d},(u!==void 0?u:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:E}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:z}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function v(e,i,f,d,S,z){var u=i.children;if(u!==void 0)if(d)if(le(u)){for(d=0;d<u.length;d++)p(u[d]);Object.freeze&&Object.freeze(u)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(u);if(W.call(i,"key")){u=t(e);var y=Object.keys(i).filter(function(fe){return fe!=="key"});d=0<y.length?"{key: someKey, "+y.join(": ..., ")+": ...}":"{key: someKey}",V[u+d]||(y=0<y.length?"{"+y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,d,u,y,u),V[u+d]=!0)}if(u=null,f!==void 0&&(o(f),u=""+f),l(i)&&(o(i.key),u=""+i.key),"key"in i){f={};for(var M in i)M!=="key"&&(f[M]=i[M])}else f=i;return u&&m(f,typeof e=="function"?e.displayName||e.name||"Unknown":e),j(e,u,f,r(),S,z)}function p(e){k(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===I&&(e._payload.status==="fulfilled"?k(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function k(e){return typeof e=="object"&&e!==null&&e.$$typeof===C}var x=T,C=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),ee=Symbol.for("react.profiler"),ne=Symbol.for("react.consumer"),te=Symbol.for("react.context"),oe=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),se=Symbol.for("react.suspense_list"),ie=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),P=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,le=Array.isArray,D=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(e){return e()}};var F,U={},q=x.react_stack_bottom_frame.bind(x,c)(),B=D(s(c)),V={};R.Fragment=O,R.jsx=function(e,i,f){var d=1e4>P.recentlyCreatedOwnerStacks++;return v(e,i,f,!1,d?Error("react-stack-top-frame"):q,d?D(s(e)):B)},R.jsxs=function(e,i,f){var d=1e4>P.recentlyCreatedOwnerStacks++;return v(e,i,f,!0,d?Error("react-stack-top-frame"):q,d?D(s(e)):B)}})()),R}var Q;function Ee(){return Q||(Q=1,process.env.NODE_ENV==="production"?N.exports=we():N.exports=Te()),N.exports}var a=Ee();function je(){return T.useSyncExternalStore(t=>h.subscribe(t),()=>h.getSnapshot(),()=>h.getSnapshot())}function w(...t){return he.twMerge(me.clsx(t))}function _e({className:t}){return a.jsxs("svg",{className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"m9 12 2 2 4-4"})]})}function Re({className:t}){return a.jsxs("svg",{className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),a.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})}function Ce({className:t}){return a.jsxs("svg",{className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"m15 9-6 6"}),a.jsx("path",{d:"m9 9 6 6"})]})}function Z({className:t}){return a.jsxs("svg",{className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"M12 16v-4"}),a.jsx("path",{d:"M12 8h.01"})]})}function Se({className:t}){return a.jsx("svg",{className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:a.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}const Ne={default:Z,error:Ce,info:Z,loading:Se,success:_e,warning:Re},Ae={default:"nf-dialog-tone-default",error:"nf-dialog-tone-error",info:"nf-dialog-tone-info",loading:"nf-dialog-tone-loading",success:"nf-dialog-tone-success",warning:"nf-dialog-tone-warning"},Oe={default:"nf-icon-tone-default",error:"nf-icon-tone-error",info:"nf-icon-tone-info",loading:"nf-icon-tone-loading",success:"nf-icon-tone-success",warning:"nf-icon-tone-warning"},Ie={bounce:"nf-motion-bounce",none:"nf-motion-none",scale:"nf-motion-scale",slide:"nf-motion-slide",subtle:"nf-motion-subtle"};function Pe({colorScheme:t,motion:n="subtle",showQueueCount:o=!0,theme:s}){const{current:r,pendingCount:c}=je(),l=De(t),m=s?.schemes?.[l],E=Ie[n];T.useEffect(()=>h.registerHost(),[]);const j={...Ne,...s?.icons},v={...Ae,...s?.dialogToneClasses,...m?.dialogToneClasses},p={...Oe,...s?.iconToneClasses,...m?.iconToneClasses};return a.jsx(b.Root,{onOpenChange:k=>{!k&&r?.dismissible&&h.dismiss(r.id)},open:!!r?.open,children:r?a.jsx(ze,{dialog:r,dialogToneClasses:v,icons:j,iconToneClasses:p,pendingCount:c,scheme:l,motionClassName:E,schemeClassName:m?.className,showQueueCount:o}):null})}function De(t){const n=t??"system",[o,s]=T.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches);return T.useEffect(()=>{if(n!=="system"||typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia("(prefers-color-scheme: dark)"),c=l=>s(l.matches);return s(r.matches),r.addEventListener("change",c),()=>r.removeEventListener("change",c)},[n]),T.useMemo(()=>n==="dark"?"dark":n==="light"?"light":o?"dark":"light",[o,n])}function ze({dialog:t,dialogToneClasses:n,icons:o,iconToneClasses:s,pendingCount:r,scheme:c,motionClassName:l,schemeClassName:m,showQueueCount:E}){const j=o[t.type],v=!!t.action||t.dismissible,p=t.type==="loading",k=n[t.type],x=s[t.type],C=w(t.type==="error"&&"nf-action-error",t.type==="info"&&"nf-action-info",t.type==="success"&&"nf-action-success",t.type==="warning"&&"nf-action-warning",(t.type==="default"||t.type==="loading")&&"nf-action-default");return a.jsxs(b.Portal,{children:[a.jsx(b.Overlay,{className:w("nf-overlay",l)}),a.jsxs(b.Content,{className:w("nf-content",l,c==="dark"&&"nf-scheme-dark",k,m),onEscapeKeyDown:A=>{(!t.dismissible||!t.allowEscapeClose)&&A.preventDefault()},children:[a.jsxs("div",{className:"nf-header",children:[a.jsxs("div",{className:"nf-title-row",children:[a.jsx("div",{className:w("nf-icon-wrap",x),children:a.jsx(j,{className:w("nf-icon",t.type==="loading"&&"nf-icon-spin")})}),a.jsx(b.Title,{className:"nf-title",children:t.title})]}),a.jsx(b.Description,{"aria-live":t.type==="error"?"assertive":"polite",className:"nf-description",children:t.description?t.description:a.jsx(ue.Root,{children:"Notification dialog"})})]}),a.jsxs("div",{className:"nf-footer",children:[E&&r>0?a.jsxs("div",{className:"nf-pending",children:[r," pending"]}):null,a.jsxs("div",{className:"nf-actions",children:[t.cancel?a.jsx(b.Cancel,{asChild:!0,children:a.jsx("button",{className:"nf-button nf-button-cancel",disabled:p,onClick:()=>{t.cancel?.onClick?.(),h.dismiss(t.id)},type:"button",children:t.cancel.label})}):null,v?a.jsx(b.Action,{asChild:!0,children:a.jsx("button",{className:w("nf-button nf-button-action",C),disabled:p,onClick:()=>{t.action?.onClick?.(),h.dismiss(t.id)},type:"button",children:t.action?.label??"OK"})}):null]})]})]})]})}ge();exports.Notifin=Pe;exports.notifin=ye;
|
package/dist/notifin.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--nf-overlay-bg: rgb(0 0 0 / .5);--nf-content-width: min(92vw, 24rem);--nf-content-max-height: 90dvh;--nf-content-radius: .75rem;--nf-content-padding: 1rem;--nf-content-shadow: 0 20px 30px -12px rgb(0 0 0 / .25);--nf-text-title-size: 1rem;--nf-text-title-weight: 600;--nf-text-description-size: .875rem;--nf-text-pending-size: .75rem;--nf-icon-wrap-size: 1.75rem;--nf-icon-size: 1rem;--nf-button-height: 2rem;--nf-button-radius: .375rem;--nf-button-padding-x: 1rem;--nf-button-font-size: .875rem;--nf-button-min-width-sm: 6rem;--nf-focus-ring: 0 0 0 2px #a3a3a3}.nf-icon-wrap{flex-shrink:0;display:flex;width:var(--nf-icon-wrap-size);height:var(--nf-icon-wrap-size);align-items:center;justify-content:center;border:1px solid transparent;border-radius:9999px}.nf-icon{width:var(--nf-icon-size);height:var(--nf-icon-size)}.nf-icon-spin{animation:nf-spin 1s linear infinite}.nf-title{margin:0;font-size:var(--nf-text-title-size);font-weight:var(--nf-text-title-weight);line-height:1.35;word-break:break-word}.nf-description{margin:0;color:#525252;font-size:var(--nf-text-description-size);line-height:1.45;word-break:break-word}.nf-pending{color:#737373;font-size:var(--nf-text-pending-size)}.nf-button{height:var(--nf-button-height);width:100%;min-width:0;display:inline-flex;align-items:center;justify-content:center;padding:0 var(--nf-button-padding-x);border-radius:var(--nf-button-radius);border:1px solid transparent;font-size:var(--nf-button-font-size);font-weight:500;line-height:1;cursor:pointer;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.nf-button:focus-visible{outline:none;box-shadow:var(--nf-focus-ring)}.nf-button:disabled{cursor:not-allowed;opacity:.6}.nf-button-cancel{border-color:#d4d4d4;background:#fff;color:#404040}.nf-button-cancel:hover:not(:disabled){background:#f5f5f5}.nf-button-action{color:#fff}@media(min-width:640px){.nf-button{width:auto;min-width:var(--nf-button-min-width-sm)}}.nf-title-row{display:flex;align-items:center;gap:.5rem}.nf-actions{display:flex;width:100%;align-items:center;gap:.5rem}@media(min-width:640px){.nf-actions{justify-content:flex-end}}.nf-overlay{position:fixed;inset:0;z-index:50;background:var(--nf-overlay-bg)}.nf-content{position:fixed;top:50%;left:50%;z-index:50;width:var(--nf-content-width);max-height:var(--nf-content-max-height);overflow-y:auto;transform:translate(-50%,-50%);border:1px solid transparent;border-radius:var(--nf-content-radius);padding:var(--nf-content-padding);box-shadow:var(--nf-content-shadow);outline:none}.nf-header{display:grid;gap:.375rem}.nf-footer{margin-top:1rem;display:grid;gap:.5rem}.nf-action-default{background:#171717}.nf-action-default:hover:not(:disabled){background:#262626}.nf-action-error{background:#dc2626}.nf-action-error:hover:not(:disabled){background:#b91c1c}.nf-action-info{background:#2563eb}.nf-action-info:hover:not(:disabled){background:#1d4ed8}.nf-action-success{background:#16a34a}.nf-action-success:hover:not(:disabled){background:#15803d}.nf-action-warning{background:#ca8a04}.nf-action-warning:hover:not(:disabled){background:#a16207}.nf-dialog-tone-default{border-color:#e5e5e5;background:#fff;color:#0a0a0a}.nf-dialog-tone-error{border-color:#fecaca;background:#fff;color:#7f1d1d}.nf-dialog-tone-info{border-color:#bfdbfe;background:#fff;color:#1e3a8a}.nf-dialog-tone-loading{border-color:#e5e5e5;background:#fff;color:#0a0a0a}.nf-dialog-tone-success{border-color:#bbf7d0;background:#fff;color:#14532d}.nf-dialog-tone-warning{border-color:#fde68a;background:#fff;color:#713f12}.nf-icon-tone-default{border-color:#e5e5e5;background:#f5f5f5;color:#404040}.nf-icon-tone-error{border-color:#fca5a5;background:#fef2f2;color:#dc2626}.nf-icon-tone-info{border-color:#93c5fd;background:#eff6ff;color:#2563eb}.nf-icon-tone-loading{border-color:#e5e5e5;background:#f5f5f5;color:#525252}.nf-icon-tone-success{border-color:#86efac;background:#f0fdf4;color:#16a34a}.nf-icon-tone-warning{border-color:#fcd34d;background:#fefce8;color:#ca8a04}.nf-scheme-dark{--nf-overlay-bg: rgb(0 0 0 / .72);--nf-content-shadow: 0 20px 35px -14px rgb(0 0 0 / .7);--nf-focus-ring: 0 0 0 2px #525252}.nf-scheme-dark.nf-dialog-tone-default,.nf-scheme-dark.nf-dialog-tone-loading{border-color:#404040;background:#171717;color:#fafafa}.nf-scheme-dark.nf-dialog-tone-error{border-color:#7f1d1d;background:#1f1416;color:#fecaca}.nf-scheme-dark.nf-dialog-tone-info{border-color:#1e3a8a;background:#111827;color:#bfdbfe}.nf-scheme-dark.nf-dialog-tone-success{border-color:#14532d;background:#0d1f14;color:#bbf7d0}.nf-scheme-dark.nf-dialog-tone-warning{border-color:#713f12;background:#22180b;color:#fde68a}.nf-scheme-dark .nf-description{color:#d4d4d4}.nf-scheme-dark .nf-pending{color:#a3a3a3}.nf-scheme-dark .nf-button-cancel{border-color:#525252;background:#262626;color:#f5f5f5}.nf-scheme-dark .nf-button-cancel:hover:not(:disabled){background:#333}.nf-scheme-dark .nf-icon-tone-default,.nf-scheme-dark .nf-icon-tone-loading{border-color:#525252;background:#262626;color:#d4d4d4}.nf-scheme-dark .nf-icon-tone-error{border-color:#7f1d1d;background:#2b1318;color:#f87171}.nf-scheme-dark .nf-icon-tone-info{border-color:#1d4ed8;background:#172554;color:#93c5fd}.nf-scheme-dark .nf-icon-tone-success{border-color:#166534;background:#13271a;color:#86efac}.nf-scheme-dark .nf-icon-tone-warning{border-color:#92400e;background:#2c2110;color:#facc15}.nf-overlay:not(.nf-motion-none)[data-state=open]{animation:nf-fade-in .2s ease-out both}.nf-overlay:not(.nf-motion-none)[data-state=closed]{animation:nf-fade-out .2s ease-in both}.nf-content.nf-motion-subtle[data-state=open]{animation:nf-fade-in .2s ease-out both,nf-zoom-in-subtle .2s ease-out both}.nf-content.nf-motion-subtle[data-state=closed]{animation:nf-fade-out .2s ease-in both,nf-zoom-out-subtle .2s ease-in both}.nf-content.nf-motion-slide[data-state=open]{animation:nf-fade-in .22s ease-out both,nf-slide-in-top .22s ease-out both}.nf-content.nf-motion-slide[data-state=closed]{animation:nf-fade-out .18s ease-in both,nf-slide-out-top .2s ease-in both}.nf-content.nf-motion-scale[data-state=open]{animation:nf-fade-in .2s ease-out both,nf-scale-in .2s ease-out both}.nf-content.nf-motion-scale[data-state=closed]{animation:nf-fade-out .18s ease-in both,nf-scale-out .18s ease-in both}.nf-content.nf-motion-bounce[data-state=open]{animation:nf-fade-in .24s ease-out both,nf-bounce-in .24s cubic-bezier(.2,.8,.2,1) both}.nf-content.nf-motion-bounce[data-state=closed]{animation:nf-fade-out .18s ease-in both,nf-bounce-out .18s ease-in both}.nf-content.nf-motion-none,.nf-overlay.nf-motion-none{animation:none!important;transition:none!important}@media(prefers-reduced-motion:reduce){.nf-overlay,.nf-content,.nf-icon-spin{animation:none!important;transition:none!important}}@keyframes nf-fade-in{0%{opacity:0}to{opacity:1}}@keyframes nf-fade-out{0%{opacity:1}to{opacity:0}}@keyframes nf-zoom-in-subtle{0%{transform:translate(-50%,-50%) scale(.95)}to{transform:translate(-50%,-50%) scale(1)}}@keyframes nf-zoom-out-subtle{0%{transform:translate(-50%,-50%) scale(1)}to{transform:translate(-50%,-50%) scale(.95)}}@keyframes nf-slide-in-top{0%{transform:translate(-50%,calc(-50% - 8px))}to{transform:translate(-50%,-50%)}}@keyframes nf-slide-out-top{0%{transform:translate(-50%,-50%)}to{transform:translate(-50%,calc(-50% - 8px))}}@keyframes nf-scale-in{0%{transform:translate(-50%,-50%) scale(.9)}to{transform:translate(-50%,-50%) scale(1)}}@keyframes nf-scale-out{0%{transform:translate(-50%,-50%) scale(1)}to{transform:translate(-50%,-50%) scale(.9)}}@keyframes nf-bounce-in{0%{transform:translate(-50%,calc(-50% - 12px)) scale(.92)}60%{transform:translate(-50%,-50%) scale(1.03)}to{transform:translate(-50%,-50%) scale(1)}}@keyframes nf-bounce-out{0%{transform:translate(-50%,-50%) scale(1)}to{transform:translate(-50%,calc(-50% - 8px)) scale(.95)}}@keyframes nf-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|