boottent-design 0.1.13 → 0.1.15

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 (32) hide show
  1. package/dist/boottent-design.hooks.cjs.js +1 -1
  2. package/dist/boottent-design.hooks.es.js +1 -1
  3. package/dist/boottent-design.main.cjs.js +1 -1
  4. package/dist/boottent-design.main.es.js +5 -5
  5. package/dist/boottent-design.provider.cjs.js +1 -1
  6. package/dist/boottent-design.provider.es.js +1 -1
  7. package/dist/boottent-design.ui.cjs.js +1 -1
  8. package/dist/boottent-design.ui.es.js +2 -2
  9. package/dist/boottent-design.utils.cjs.js +1 -1
  10. package/dist/boottent-design.utils.es.js +1 -1
  11. package/dist/{index-C9dzv_CG.cjs → index-BWKZX0-5.cjs} +1 -1
  12. package/dist/{index-eA7KeYI8.js → index-DZTfWalm.js} +1 -1
  13. package/dist/portal-manager-9WO01tNb.cjs +1 -0
  14. package/dist/portal-manager-nNJ4SIa2.js +95 -0
  15. package/dist/portal-provider-Cb0Fq_yq.cjs +1 -0
  16. package/dist/portal-provider-CkucnuYS.js +110 -0
  17. package/dist/{tooltip-Beq86Qug.js → tooltip-BYAvA36l.js} +596 -592
  18. package/dist/{tooltip-DWrSWVcc.cjs → tooltip-BeNesDLB.cjs} +5 -5
  19. package/dist/types/hooks.d.ts +14 -13
  20. package/dist/types/main.d.ts +36 -19
  21. package/dist/types/types.d.ts +25 -11
  22. package/dist/types/ui.d.ts +12 -10
  23. package/dist/types/utils.d.ts +24 -14
  24. package/dist/use-portal-B-W1cxuO.js +32 -0
  25. package/dist/use-portal-D6lcMQX5.cjs +1 -0
  26. package/package.json +1 -1
  27. package/dist/portal-manager-6YGufJVr.cjs +0 -1
  28. package/dist/portal-manager-CttMAZAu.js +0 -73
  29. package/dist/portal-provider-Bwzhqa3P.js +0 -106
  30. package/dist/portal-provider-DXVWgfhq.cjs +0 -1
  31. package/dist/use-portal-Ck3GPJQN.cjs +0 -1
  32. package/dist/use-portal-TiMPd_EZ.js +0 -17
@@ -1,4 +1,5 @@
1
1
  import { ClassProp } from 'class-variance-authority/types';
2
+ import { default as default_2 } from 'react';
2
3
  import * as React_2 from 'react';
3
4
  import * as ToastPrimitives from '@radix-ui/react-toast';
4
5
  import { VariantProps } from 'class-variance-authority';
@@ -6,7 +7,7 @@ import { VariantProps } from 'class-variance-authority';
6
7
  declare interface AlertProps {
7
8
  id?: string;
8
9
  title?: string;
9
- description: string | React.ReactNode;
10
+ description: string | default_2.ReactNode;
10
11
  confirmText?: string;
11
12
  onConfirm?: () => void;
12
13
  size?: "sm" | "md" | "lg" | "fit";
@@ -16,7 +17,7 @@ declare interface AlertProps {
16
17
  declare interface DialogProps {
17
18
  id?: string;
18
19
  title: string;
19
- content: string | React.ReactNode;
20
+ content: string | default_2.ReactNode;
20
21
  onConfirm?: () => void;
21
22
  onCancel?: () => void;
22
23
  onClose?: () => void;
@@ -24,15 +25,15 @@ declare interface DialogProps {
24
25
 
25
26
  declare interface ModalProps {
26
27
  id?: string;
27
- title: string;
28
- description?: string | React.ReactNode;
29
- subDescription?: string | React.ReactNode;
28
+ title?: string;
29
+ description: string | default_2.ReactNode;
30
+ subDescription?: string | default_2.ReactNode;
30
31
  size?: "sm" | "md" | "lg" | "fit";
31
32
  confirmText?: string;
32
33
  onConfirm?: () => void;
33
34
  cancelText?: string;
34
- onClose: () => void;
35
- contents?: React.ReactNode;
35
+ onClose?: () => void;
36
+ contents?: default_2.ReactNode;
36
37
  className?: string;
37
38
  }
38
39
 
@@ -43,10 +44,10 @@ declare const Toast: React_2.ForwardRefExoticComponent<Omit<ToastPrimitives.Toas
43
44
 
44
45
  declare type ToasterProps = ToastProps & ToastViewportProps & {
45
46
  id?: string;
46
- title?: React.ReactNode;
47
- description?: React.ReactNode;
47
+ title?: default_2.ReactNode;
48
+ description?: default_2.ReactNode;
48
49
  action?: () => void;
49
- actionText?: string | React.ReactNode;
50
+ actionText?: string | default_2.ReactNode;
50
51
  closeButton?: boolean;
51
52
  onClose?: () => void;
52
53
  };
@@ -63,10 +64,10 @@ declare type ToastViewportProps = React_2.ComponentPropsWithoutRef<typeof ToastV
63
64
 
64
65
  export declare const usePortal: () => {
65
66
  modal: (props: ModalProps) => string | null;
66
- toast: (props: ToasterProps) => string | null;
67
- alert: (props: AlertProps) => string | null;
67
+ toast: (props: ToasterProps | string) => string | null;
68
+ alert: (props: AlertProps | string) => string | null;
68
69
  dialog: (props: DialogProps) => string | null;
69
- getIsOpen: (id: string) => boolean | undefined;
70
+ getIsOpen: (id: string) => boolean;
70
71
  openPortals: string[];
71
72
  };
72
73
 
@@ -58,7 +58,7 @@ export declare interface AlertPortalOptions {
58
58
  export declare interface AlertProps {
59
59
  id?: string;
60
60
  title?: string;
61
- description: string | React.ReactNode;
61
+ description: string | default_2.ReactNode;
62
62
  confirmText?: string;
63
63
  onConfirm?: () => void;
64
64
  size?: "sm" | "md" | "lg" | "fit";
@@ -128,20 +128,22 @@ declare function Control({ size, fill, className, }: SvgIconType): JSX_2.Element
128
128
 
129
129
  declare function CopyLink(): JSX_2.Element;
130
130
 
131
- declare interface CustomDialogProps extends Omit<DialogProps, "onConfirm" | "onCancel" | "content"> {
131
+ export declare interface CustomDialogProps extends Omit<DialogProps, "onConfirm" | "onCancel" | "content"> {
132
132
  onConfirm?: () => void;
133
133
  onCancel?: () => void;
134
134
  confirmText?: string;
135
135
  cancelText?: string;
136
136
  size?: "sm" | "md" | "lg" | "fit";
137
- content?: React_2.ReactNode;
137
+ content?: default_2.ReactNode;
138
138
  description?: string;
139
139
  className?: string;
140
+ open?: boolean;
141
+ onOpenChange?: (open: boolean) => void;
140
142
  }
141
143
 
142
144
  declare function DefaultProfile({ size }: SvgIconType): JSX_2.Element;
143
145
 
144
- export declare const Dialog: React_2.ForwardRefExoticComponent<CustomDialogProps & React_2.RefAttributes<HTMLDivElement>>;
146
+ export declare const Dialog: default_2.ForwardRefExoticComponent<CustomDialogProps & default_2.RefAttributes<HTMLDivElement>>;
145
147
 
146
148
  export declare interface DialogPortalOptions {
147
149
  id: string;
@@ -152,7 +154,7 @@ export declare interface DialogPortalOptions {
152
154
  export declare interface DialogProps {
153
155
  id?: string;
154
156
  title: string;
155
- content: string | React.ReactNode;
157
+ content: string | default_2.ReactNode;
156
158
  onConfirm?: () => void;
157
159
  onCancel?: () => void;
158
160
  onClose?: () => void;
@@ -245,15 +247,15 @@ export declare interface ModalPortalOptions {
245
247
 
246
248
  export declare interface ModalProps {
247
249
  id?: string;
248
- title: string;
249
- description?: string | React.ReactNode;
250
- subDescription?: string | React.ReactNode;
250
+ title?: string;
251
+ description: string | default_2.ReactNode;
252
+ subDescription?: string | default_2.ReactNode;
251
253
  size?: "sm" | "md" | "lg" | "fit";
252
254
  confirmText?: string;
253
255
  onConfirm?: () => void;
254
256
  cancelText?: string;
255
- onClose: () => void;
256
- contents?: React.ReactNode;
257
+ onClose?: () => void;
258
+ contents?: default_2.ReactNode;
257
259
  className?: string;
258
260
  }
259
261
 
@@ -271,9 +273,11 @@ declare class PortalManager {
271
273
  private processQueue;
272
274
  private isPortalOpen;
273
275
  subscribe(listener: Listener): () => void;
274
- showPortal(type: PortalType, props: any): string | null;
276
+ showPortal<T extends PortalType>(type: T, props: PortalTypeMap[T] & {
277
+ id?: string;
278
+ }): string | null;
275
279
  setPortalOpen(id: string, isOpen: boolean): void;
276
- getIsPortalOpen(id: string): boolean | undefined;
280
+ getIsPortalOpen(id: string): boolean;
277
281
  getOpenPortals(): string[];
278
282
  private generateId;
279
283
  }
@@ -286,6 +290,13 @@ export declare const PortalProvider: () => JSX_2.Element;
286
290
 
287
291
  export declare type PortalType = "modal" | "toast" | "alert" | "dialog";
288
292
 
293
+ export declare interface PortalTypeMap {
294
+ modal: ModalProps;
295
+ toast: ToasterProps;
296
+ alert: AlertProps;
297
+ dialog: DialogProps;
298
+ }
299
+
289
300
  declare function Present({ size, fill, className, }: SvgIconType): JSX_2.Element;
290
301
 
291
302
  declare function Profile({ fill, className, size, }: SvgIconType): JSX_2.Element;
@@ -334,6 +345,12 @@ declare function Search({ size, fill }: SvgIconType): JSX_2.Element;
334
345
 
335
346
  declare function Share({ size, fill }: Props_2): JSX_2.Element;
336
347
 
348
+ export declare type SpecificPortalOptions<T extends PortalType> = {
349
+ id: string;
350
+ type: T;
351
+ props: PortalTypeMap[T];
352
+ };
353
+
337
354
  export declare const Stack: ({ className, type, ...props }: StackProps) => JSX_2.Element;
338
355
 
339
356
  declare type StackProps = BoxProps & {
@@ -387,10 +404,10 @@ export declare function toaster(): {
387
404
 
388
405
  export declare type ToasterProps = ToastProps & ToastViewportProps & {
389
406
  id?: string;
390
- title?: React.ReactNode;
391
- description?: React.ReactNode;
407
+ title?: default_2.ReactNode;
408
+ description?: default_2.ReactNode;
392
409
  action?: () => void;
393
- actionText?: string | React.ReactNode;
410
+ actionText?: string | default_2.ReactNode;
394
411
  closeButton?: boolean;
395
412
  onClose?: () => void;
396
413
  };
@@ -398,7 +415,7 @@ export declare type ToasterProps = ToastProps & ToastViewportProps & {
398
415
  export declare interface ToastPortalOptions {
399
416
  id: string;
400
417
  type: "toast";
401
- props: ToastProps;
418
+ props: ToasterProps;
402
419
  }
403
420
 
404
421
  declare type ToastPositionsType = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
@@ -432,10 +449,10 @@ export declare const TooltipProvider: React_2.FC<TooltipPrimitive.TooltipProvide
432
449
 
433
450
  export declare const usePortal: () => {
434
451
  modal: (props: ModalProps) => string | null;
435
- toast: (props: ToasterProps) => string | null;
436
- alert: (props: AlertProps) => string | null;
452
+ toast: (props: ToasterProps | string) => string | null;
453
+ alert: (props: AlertProps | string) => string | null;
437
454
  dialog: (props: DialogProps) => string | null;
438
- getIsOpen: (id: string) => boolean | undefined;
455
+ getIsOpen: (id: string) => boolean;
439
456
  openPortals: string[];
440
457
  };
441
458
 
@@ -1,4 +1,5 @@
1
1
  import { ClassProp } from 'class-variance-authority/types';
2
+ import { default as default_2 } from 'react';
2
3
  import * as React_2 from 'react';
3
4
  import * as ToastPrimitives from '@radix-ui/react-toast';
4
5
  import { VariantProps } from 'class-variance-authority';
@@ -12,7 +13,7 @@ export declare interface AlertPortalOptions {
12
13
  export declare interface AlertProps {
13
14
  id?: string;
14
15
  title?: string;
15
- description: string | React.ReactNode;
16
+ description: string | default_2.ReactNode;
16
17
  confirmText?: string;
17
18
  onConfirm?: () => void;
18
19
  size?: "sm" | "md" | "lg" | "fit";
@@ -28,7 +29,7 @@ export declare interface DialogPortalOptions {
28
29
  export declare interface DialogProps {
29
30
  id?: string;
30
31
  title: string;
31
- content: string | React.ReactNode;
32
+ content: string | default_2.ReactNode;
32
33
  onConfirm?: () => void;
33
34
  onCancel?: () => void;
34
35
  onClose?: () => void;
@@ -42,15 +43,15 @@ export declare interface ModalPortalOptions {
42
43
 
43
44
  export declare interface ModalProps {
44
45
  id?: string;
45
- title: string;
46
- description?: string | React.ReactNode;
47
- subDescription?: string | React.ReactNode;
46
+ title?: string;
47
+ description: string | default_2.ReactNode;
48
+ subDescription?: string | default_2.ReactNode;
48
49
  size?: "sm" | "md" | "lg" | "fit";
49
50
  confirmText?: string;
50
51
  onConfirm?: () => void;
51
52
  cancelText?: string;
52
- onClose: () => void;
53
- contents?: React.ReactNode;
53
+ onClose?: () => void;
54
+ contents?: default_2.ReactNode;
54
55
  className?: string;
55
56
  }
56
57
 
@@ -58,12 +59,25 @@ export declare type PortalOptions = ModalPortalOptions | ToastPortalOptions | Al
58
59
 
59
60
  export declare type PortalType = "modal" | "toast" | "alert" | "dialog";
60
61
 
62
+ export declare interface PortalTypeMap {
63
+ modal: ModalProps;
64
+ toast: ToasterProps;
65
+ alert: AlertProps;
66
+ dialog: DialogProps;
67
+ }
68
+
61
69
  export declare interface ReactIconProps {
62
70
  size?: number;
63
71
  color?: string;
64
72
  className?: string;
65
73
  }
66
74
 
75
+ export declare type SpecificPortalOptions<T extends PortalType> = {
76
+ id: string;
77
+ type: T;
78
+ props: PortalTypeMap[T];
79
+ };
80
+
67
81
  export declare type SvgIconType = {
68
82
  size?: string;
69
83
  fill?: string;
@@ -77,10 +91,10 @@ declare const Toast: React_2.ForwardRefExoticComponent<Omit<ToastPrimitives.Toas
77
91
 
78
92
  export declare type ToasterProps = ToastProps & ToastViewportProps & {
79
93
  id?: string;
80
- title?: React.ReactNode;
81
- description?: React.ReactNode;
94
+ title?: default_2.ReactNode;
95
+ description?: default_2.ReactNode;
82
96
  action?: () => void;
83
- actionText?: string | React.ReactNode;
97
+ actionText?: string | default_2.ReactNode;
84
98
  closeButton?: boolean;
85
99
  onClose?: () => void;
86
100
  };
@@ -88,7 +102,7 @@ export declare type ToasterProps = ToastProps & ToastViewportProps & {
88
102
  export declare interface ToastPortalOptions {
89
103
  id: string;
90
104
  type: "toast";
91
- props: ToastProps;
105
+ props: ToasterProps;
92
106
  }
93
107
 
94
108
  declare type ToastPositionsType = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
@@ -20,7 +20,7 @@ export declare const Alert: React_2.FC<AlertProps>;
20
20
  declare interface AlertProps {
21
21
  id?: string;
22
22
  title?: string;
23
- description: string | React.ReactNode;
23
+ description: string | default_2.ReactNode;
24
24
  confirmText?: string;
25
25
  onConfirm?: () => void;
26
26
  size?: "sm" | "md" | "lg" | "fit";
@@ -78,25 +78,27 @@ declare function Control({ size, fill, className, }: SvgIconType): JSX_2.Element
78
78
 
79
79
  declare function CopyLink(): JSX_2.Element;
80
80
 
81
- declare interface CustomDialogProps extends Omit<DialogProps, "onConfirm" | "onCancel" | "content"> {
81
+ export declare interface CustomDialogProps extends Omit<DialogProps, "onConfirm" | "onCancel" | "content"> {
82
82
  onConfirm?: () => void;
83
83
  onCancel?: () => void;
84
84
  confirmText?: string;
85
85
  cancelText?: string;
86
86
  size?: "sm" | "md" | "lg" | "fit";
87
- content?: React_2.ReactNode;
87
+ content?: default_2.ReactNode;
88
88
  description?: string;
89
89
  className?: string;
90
+ open?: boolean;
91
+ onOpenChange?: (open: boolean) => void;
90
92
  }
91
93
 
92
94
  declare function DefaultProfile({ size }: SvgIconType): JSX_2.Element;
93
95
 
94
- export declare const Dialog: React_2.ForwardRefExoticComponent<CustomDialogProps & React_2.RefAttributes<HTMLDivElement>>;
96
+ export declare const Dialog: default_2.ForwardRefExoticComponent<CustomDialogProps & default_2.RefAttributes<HTMLDivElement>>;
95
97
 
96
98
  declare interface DialogProps {
97
99
  id?: string;
98
100
  title: string;
99
- content: string | React.ReactNode;
101
+ content: string | default_2.ReactNode;
100
102
  onConfirm?: () => void;
101
103
  onCancel?: () => void;
102
104
  onClose?: () => void;
@@ -181,15 +183,15 @@ export declare const Modal: React_2.ForwardRefExoticComponent<ModalProps & React
181
183
 
182
184
  declare interface ModalProps {
183
185
  id?: string;
184
- title: string;
185
- description?: string | React.ReactNode;
186
- subDescription?: string | React.ReactNode;
186
+ title?: string;
187
+ description: string | default_2.ReactNode;
188
+ subDescription?: string | default_2.ReactNode;
187
189
  size?: "sm" | "md" | "lg" | "fit";
188
190
  confirmText?: string;
189
191
  onConfirm?: () => void;
190
192
  cancelText?: string;
191
- onClose: () => void;
192
- contents?: React.ReactNode;
193
+ onClose?: () => void;
194
+ contents?: default_2.ReactNode;
193
195
  className?: string;
194
196
  }
195
197
 
@@ -1,5 +1,6 @@
1
1
  import { ClassProp } from 'class-variance-authority/types';
2
2
  import { ClassValue } from 'clsx';
3
+ import { default as default_2 } from 'react';
3
4
  import * as React_2 from 'react';
4
5
  import * as ToastPrimitives from '@radix-ui/react-toast';
5
6
  import { VariantProps } from 'class-variance-authority';
@@ -36,7 +37,7 @@ declare interface AlertPortalOptions {
36
37
  declare interface AlertProps {
37
38
  id?: string;
38
39
  title?: string;
39
- description: string | React.ReactNode;
40
+ description: string | default_2.ReactNode;
40
41
  confirmText?: string;
41
42
  onConfirm?: () => void;
42
43
  size?: "sm" | "md" | "lg" | "fit";
@@ -54,7 +55,7 @@ declare interface DialogPortalOptions {
54
55
  declare interface DialogProps {
55
56
  id?: string;
56
57
  title: string;
57
- content: string | React.ReactNode;
58
+ content: string | default_2.ReactNode;
58
59
  onConfirm?: () => void;
59
60
  onCancel?: () => void;
60
61
  onClose?: () => void;
@@ -70,15 +71,15 @@ declare interface ModalPortalOptions {
70
71
 
71
72
  declare interface ModalProps {
72
73
  id?: string;
73
- title: string;
74
- description?: string | React.ReactNode;
75
- subDescription?: string | React.ReactNode;
74
+ title?: string;
75
+ description: string | default_2.ReactNode;
76
+ subDescription?: string | default_2.ReactNode;
76
77
  size?: "sm" | "md" | "lg" | "fit";
77
78
  confirmText?: string;
78
79
  onConfirm?: () => void;
79
80
  cancelText?: string;
80
- onClose: () => void;
81
- contents?: React.ReactNode;
81
+ onClose?: () => void;
82
+ contents?: default_2.ReactNode;
82
83
  className?: string;
83
84
  }
84
85
 
@@ -90,19 +91,28 @@ declare class PortalManager {
90
91
  private processQueue;
91
92
  private isPortalOpen;
92
93
  subscribe(listener: Listener): () => void;
93
- showPortal(type: PortalType, props: any): string | null;
94
+ showPortal<T extends PortalType>(type: T, props: PortalTypeMap[T] & {
95
+ id?: string;
96
+ }): string | null;
94
97
  setPortalOpen(id: string, isOpen: boolean): void;
95
- getIsPortalOpen(id: string): boolean | undefined;
98
+ getIsPortalOpen(id: string): boolean;
96
99
  getOpenPortals(): string[];
97
100
  private generateId;
98
101
  }
99
102
 
100
103
  export declare const portalManager: PortalManager;
101
104
 
102
- export declare type PortalOptions = ModalPortalOptions | ToastPortalOptions | AlertPortalOptions | DialogPortalOptions;
105
+ declare type PortalOptions = ModalPortalOptions | ToastPortalOptions | AlertPortalOptions | DialogPortalOptions;
103
106
 
104
107
  export declare type PortalType = "modal" | "toast" | "alert" | "dialog";
105
108
 
109
+ declare interface PortalTypeMap {
110
+ modal: ModalProps;
111
+ toast: ToasterProps;
112
+ alert: AlertProps;
113
+ dialog: DialogProps;
114
+ }
115
+
106
116
  export declare const reducer: (state: State, action: Action) => State;
107
117
 
108
118
  declare interface State {
@@ -130,10 +140,10 @@ export declare function toaster(): {
130
140
 
131
141
  declare type ToasterProps = ToastProps & ToastViewportProps & {
132
142
  id?: string;
133
- title?: React.ReactNode;
134
- description?: React.ReactNode;
143
+ title?: default_2.ReactNode;
144
+ description?: default_2.ReactNode;
135
145
  action?: () => void;
136
- actionText?: string | React.ReactNode;
146
+ actionText?: string | default_2.ReactNode;
137
147
  closeButton?: boolean;
138
148
  onClose?: () => void;
139
149
  };
@@ -141,7 +151,7 @@ declare type ToasterProps = ToastProps & ToastViewportProps & {
141
151
  declare interface ToastPortalOptions {
142
152
  id: string;
143
153
  type: "toast";
144
- props: ToastProps;
154
+ props: ToasterProps;
145
155
  }
146
156
 
147
157
  declare type ToastPositionsType = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
@@ -0,0 +1,32 @@
1
+ import { p as o } from "./portal-manager-nNJ4SIa2.js";
2
+ import { useState as c, useEffect as u } from "react";
3
+ const b = () => {
4
+ const [l, r] = c([]);
5
+ return u(() => {
6
+ const t = (n, a) => {
7
+ r(a ? (s) => s.includes(n.id) ? s : [...s, n.id] : (s) => s.filter((i) => i !== n.id));
8
+ }, e = o.subscribe(t);
9
+ return r(o.getOpenPortals()), () => {
10
+ e();
11
+ };
12
+ }, []), { modal: (t) => {
13
+ const { onClose: e = () => {
14
+ } } = t;
15
+ return o.showPortal("modal", { ...t, onClose: e });
16
+ }, toast: (t) => {
17
+ let e;
18
+ return typeof t == "string" ? e = { description: t } : e = t, o.showPortal("toast", e);
19
+ }, alert: (t) => {
20
+ let e;
21
+ return typeof t == "string" ? e = { description: t, onClose: () => {
22
+ } } : e = { ...t, onClose: t.onClose || (() => {
23
+ }) }, o.showPortal("alert", e);
24
+ }, dialog: (t) => {
25
+ const { onClose: e = () => {
26
+ } } = t;
27
+ return o.showPortal("dialog", { ...t, onClose: e });
28
+ }, getIsOpen: (t) => o.getIsPortalOpen(t), openPortals: l };
29
+ };
30
+ export {
31
+ b as u
32
+ };
@@ -0,0 +1 @@
1
+ "use strict";const r=require("./portal-manager-9WO01tNb.cjs"),s=require("react"),u=()=>{const[l,a]=s.useState([]);return s.useEffect(()=>{const t=(n,i)=>{a(i?o=>o.includes(n.id)?o:[...o,n.id]:o=>o.filter(c=>c!==n.id))},e=r.portalManager.subscribe(t);return a(r.portalManager.getOpenPortals()),()=>{e()}},[]),{modal:t=>{const{onClose:e=()=>{}}=t;return r.portalManager.showPortal("modal",{...t,onClose:e})},toast:t=>{let e;return typeof t=="string"?e={description:t}:e=t,r.portalManager.showPortal("toast",e)},alert:t=>{let e;return typeof t=="string"?e={description:t,onClose:()=>{}}:e={...t,onClose:t.onClose||(()=>{})},r.portalManager.showPortal("alert",e)},dialog:t=>{const{onClose:e=()=>{}}=t;return r.portalManager.showPortal("dialog",{...t,onClose:e})},getIsOpen:t=>r.portalManager.getIsPortalOpen(t),openPortals:l}};exports.usePortal=u;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "boottent-design",
3
3
  "private": false,
4
- "version": "0.1.13",
4
+ "version": "0.1.15",
5
5
  "description": "부트텐트 디자인시스템 라이브러리",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1 +0,0 @@
1
- "use strict";var o=Object.defineProperty;var l=(i,s,e)=>s in i?o(i,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[s]=e;var a=(i,s,e)=>l(i,typeof s!="symbol"?s+"":s,e);class h{constructor(){a(this,"listeners",[]);a(this,"portals",new Map);a(this,"queue",[]);a(this,"isProcessing",!1)}processQueue(){if(this.isProcessing||this.queue.length===0)return;this.isProcessing=!0;const s=this.queue.shift();s&&s(),this.isProcessing=!1,this.processQueue()}isPortalOpen(s){var e;return this.portals.has(s)&&((e=this.portals.get(s))==null?void 0:e.isOpen)}subscribe(s){return this.listeners.push(s),()=>{this.listeners=this.listeners.filter(e=>e!==s)}}showPortal(s,e){const t=e.id||this.generateId(s);if(this.isPortalOpen(t))return console.warn(`Portal with id "${t}" is already open.`),t;let r=null;switch(s){case"modal":r={id:t,type:s,props:e};break;case"toast":r={id:t,type:s,props:e};break;case"alert":r={id:t,type:s,props:e};break;case"dialog":r={id:t,type:s,props:e};break}return r&&(this.portals.set(t,{isOpen:!0,options:r}),this.queue.push(()=>{this.listeners.forEach(n=>n(r,!0))}),this.processQueue()),t}setPortalOpen(s,e){if(this.portals.has(s)){const t=this.portals.get(s);t.isOpen=e,this.portals.set(s,{...t}),this.queue.push(()=>{this.listeners.forEach(r=>r(t.options,e))}),this.processQueue()}}getIsPortalOpen(s){var e;return(e=this.portals.get(s))==null?void 0:e.isOpen}getOpenPortals(){return Array.from(this.portals.entries()).filter(([s,e])=>e.isOpen).map(([s,e])=>s)}generateId(s){return`${s}_${Date.now()}`}}const u=new h;exports.portalManager=u;
@@ -1,73 +0,0 @@
1
- var o = Object.defineProperty;
2
- var l = (i, s, e) => s in i ? o(i, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[s] = e;
3
- var a = (i, s, e) => l(i, typeof s != "symbol" ? s + "" : s, e);
4
- class h {
5
- constructor() {
6
- a(this, "listeners", []);
7
- a(this, "portals", /* @__PURE__ */ new Map());
8
- a(this, "queue", []);
9
- a(this, "isProcessing", !1);
10
- }
11
- processQueue() {
12
- if (this.isProcessing || this.queue.length === 0) return;
13
- this.isProcessing = !0;
14
- const s = this.queue.shift();
15
- s && s(), this.isProcessing = !1, this.processQueue();
16
- }
17
- isPortalOpen(s) {
18
- var e;
19
- return this.portals.has(s) && ((e = this.portals.get(s)) == null ? void 0 : e.isOpen);
20
- }
21
- subscribe(s) {
22
- return this.listeners.push(s), () => {
23
- this.listeners = this.listeners.filter((e) => e !== s);
24
- };
25
- }
26
- showPortal(s, e) {
27
- const t = e.id || this.generateId(s);
28
- if (this.isPortalOpen(t))
29
- return console.warn(`Portal with id "${t}" is already open.`), t;
30
- let r = null;
31
- switch (s) {
32
- case "modal":
33
- r = { id: t, type: s, props: e };
34
- break;
35
- case "toast":
36
- r = { id: t, type: s, props: e };
37
- break;
38
- case "alert":
39
- r = { id: t, type: s, props: e };
40
- break;
41
- case "dialog":
42
- r = { id: t, type: s, props: e };
43
- break;
44
- }
45
- return r && (this.portals.set(t, { isOpen: !0, options: r }), this.queue.push(() => {
46
- this.listeners.forEach((n) => n(r, !0));
47
- }), this.processQueue()), t;
48
- }
49
- setPortalOpen(s, e) {
50
- if (this.portals.has(s)) {
51
- const t = this.portals.get(s);
52
- t.isOpen = e, this.portals.set(s, { ...t }), this.queue.push(() => {
53
- this.listeners.forEach(
54
- (r) => r(t.options, e)
55
- );
56
- }), this.processQueue();
57
- }
58
- }
59
- getIsPortalOpen(s) {
60
- var e;
61
- return (e = this.portals.get(s)) == null ? void 0 : e.isOpen;
62
- }
63
- getOpenPortals() {
64
- return Array.from(this.portals.entries()).filter(([s, e]) => e.isOpen).map(([s, e]) => s);
65
- }
66
- generateId(s) {
67
- return `${s}_${Date.now()}`;
68
- }
69
- }
70
- const c = new h();
71
- export {
72
- c as p
73
- };