@tamagui/portal 1.0.1-beta.21 → 1.0.1-beta.211

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 (43) hide show
  1. package/dist/cjs/GorhomPortal.js +266 -0
  2. package/dist/cjs/GorhomPortal.js.map +7 -0
  3. package/dist/cjs/Portal.js +19 -31
  4. package/dist/cjs/Portal.js.map +2 -2
  5. package/dist/cjs/Portal.native.js +66 -0
  6. package/dist/cjs/Portal.native.js.map +7 -0
  7. package/dist/cjs/PortalProps.js +17 -0
  8. package/dist/cjs/PortalProps.js.map +7 -0
  9. package/dist/cjs/index.js +2 -0
  10. package/dist/cjs/index.js.map +2 -2
  11. package/dist/esm/GorhomPortal.js +237 -0
  12. package/dist/esm/GorhomPortal.js.map +7 -0
  13. package/dist/esm/Portal.js +11 -15
  14. package/dist/esm/Portal.js.map +2 -2
  15. package/dist/esm/Portal.native.js +36 -0
  16. package/dist/esm/Portal.native.js.map +7 -0
  17. package/dist/esm/PortalProps.js +1 -0
  18. package/dist/esm/PortalProps.js.map +7 -0
  19. package/dist/esm/index.js +1 -0
  20. package/dist/esm/index.js.map +2 -2
  21. package/dist/jsx/GorhomPortal.js +223 -0
  22. package/dist/jsx/GorhomPortal.js.map +7 -0
  23. package/dist/jsx/Portal.js +6 -12
  24. package/dist/jsx/Portal.js.map +7 -0
  25. package/dist/jsx/Portal.native.js +21 -0
  26. package/dist/jsx/Portal.native.js.map +7 -0
  27. package/dist/jsx/PortalProps.js +1 -0
  28. package/dist/jsx/PortalProps.js.map +7 -0
  29. package/dist/jsx/index.js +2 -0
  30. package/dist/jsx/index.js.map +7 -0
  31. package/package.json +9 -7
  32. package/src/GorhomPortal.tsx +402 -0
  33. package/src/Portal.native.tsx +40 -0
  34. package/src/Portal.tsx +37 -0
  35. package/src/PortalProps.tsx +6 -0
  36. package/src/index.tsx +2 -0
  37. package/types/GorhomPortal.d.ts +106 -0
  38. package/types/Portal.d.ts +3 -3
  39. package/types/Portal.native.d.ts +3 -0
  40. package/types/PortalProps.d.ts +6 -0
  41. package/types/index.d.ts +1 -0
  42. package/types/Portal.d.ts.map +0 -1
  43. package/types/index.d.ts.map +0 -1
@@ -0,0 +1,106 @@
1
+ import { ReactNode } from 'react';
2
+ import React from 'react';
3
+ declare enum ACTIONS {
4
+ REGISTER_HOST = 0,
5
+ DEREGISTER_HOST = 1,
6
+ ADD_UPDATE_PORTAL = 2,
7
+ REMOVE_PORTAL = 3
8
+ }
9
+ declare const INITIAL_STATE: {};
10
+ export { ACTIONS, INITIAL_STATE };
11
+ export interface AddUpdatePortalAction {
12
+ type: ACTIONS;
13
+ hostName: string;
14
+ portalName: string;
15
+ node: ReactNode;
16
+ }
17
+ export interface RemovePortalAction {
18
+ type: ACTIONS;
19
+ hostName: string;
20
+ portalName: string;
21
+ }
22
+ export interface RegisterHostAction {
23
+ type: ACTIONS;
24
+ hostName: string;
25
+ }
26
+ export interface UnregisterHostAction {
27
+ type: ACTIONS;
28
+ hostName: string;
29
+ }
30
+ export declare type ActionTypes = AddUpdatePortalAction | RemovePortalAction | RegisterHostAction | UnregisterHostAction;
31
+ export declare const usePortal: (hostName?: string) => {
32
+ registerHost: () => void;
33
+ deregisterHost: () => void;
34
+ addPortal: (name: string, node: ReactNode) => void;
35
+ updatePortal: (name: string, node: ReactNode) => void;
36
+ removePortal: (name: string) => void;
37
+ };
38
+ export interface PortalProviderProps {
39
+ /**
40
+ * Defines whether to add a default root host or not.
41
+ *
42
+ * @default true
43
+ * @type boolean
44
+ */
45
+ shouldAddRootHost?: boolean;
46
+ /**
47
+ * Defines the root portal host name.
48
+ *
49
+ * @default "root"
50
+ * @type string
51
+ */
52
+ rootHostName?: string;
53
+ children: ReactNode | ReactNode[];
54
+ }
55
+ export declare const PortalProvider: React.MemoExoticComponent<({ rootHostName, shouldAddRootHost, children, }: PortalProviderProps) => JSX.Element>;
56
+ export interface PortalHostProps {
57
+ /**
58
+ * Host's key or name to be used as an identifier.
59
+ * @type string
60
+ */
61
+ name: string;
62
+ }
63
+ export declare const PortalHost: React.MemoExoticComponent<({ name }: PortalHostProps) => JSX.Element>;
64
+ export interface PortalItemProps {
65
+ /**
66
+ * Portal's key or name to be used as an identifier.
67
+ * @type string
68
+ * @default nanoid generated unique key.
69
+ */
70
+ name?: string;
71
+ /**
72
+ * Host's name to teleport the portal content to.
73
+ * @type string
74
+ * @default 'root'
75
+ */
76
+ hostName?: string;
77
+ /**
78
+ * Override internal mounting functionality, this is useful
79
+ * if you want to trigger any action before mounting the portal content.
80
+ * @type (mount?: () => void) => void
81
+ * @default undefined
82
+ */
83
+ handleOnMount?: (mount: () => void) => void;
84
+ /**
85
+ * Override internal un-mounting functionality, this is useful
86
+ * if you want to trigger any action before un-mounting the portal content.
87
+ * @type (unmount?: () => void) => void
88
+ * @default undefined
89
+ */
90
+ handleOnUnmount?: (unmount: () => void) => void;
91
+ /**
92
+ * Override internal updating functionality, this is useful
93
+ * if you want to trigger any action before updating the portal content.
94
+ * @type (update?: () => void) => void
95
+ * @default undefined
96
+ */
97
+ handleOnUpdate?: (update: () => void) => void;
98
+ /**
99
+ * Portal's content.
100
+ * @type ReactNode
101
+ * @default undefined
102
+ */
103
+ children?: ReactNode | ReactNode[];
104
+ }
105
+ export declare const PortalItem: React.MemoExoticComponent<({ name, hostName, handleOnMount, handleOnUnmount, handleOnUpdate, children, }: PortalItemProps) => null>;
106
+ //# sourceMappingURL=GorhomPortal.d.ts.map
package/types/Portal.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
2
1
  import '@tamagui/polyfill-dev';
3
- import { YStackProps } from '@tamagui/stacks';
4
- export declare const Portal: (props: YStackProps) => JSX.Element | null;
2
+ import * as React from 'react';
3
+ import { PortalProps } from './PortalProps';
4
+ export declare const Portal: ({ host, ...props }: PortalProps) => React.ReactPortal | null;
5
5
  //# sourceMappingURL=Portal.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { PortalProps } from './PortalProps';
2
+ export declare const Portal: (props: PortalProps) => any;
3
+ //# sourceMappingURL=Portal.native.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { YStackProps } from '@tamagui/stacks';
2
+ export declare type PortalProps = YStackProps & {
3
+ host?: any;
4
+ inactive?: boolean;
5
+ };
6
+ //# sourceMappingURL=PortalProps.d.ts.map
package/types/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './Portal';
2
+ export * from './GorhomPortal';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../src/Portal.tsx"],"names":[],"mappings":";AAAA,OAAO,uBAAuB,CAAA;AAG9B,OAAO,EAAU,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMrD,eAAO,MAAM,MAAM,UAAW,WAAW,uBAgBxC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}