@xanui/core 1.2.43 → 1.2.45

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 (167) hide show
  1. package/AppRoot/AppRootProvider.cjs +20 -0
  2. package/AppRoot/AppRootProvider.cjs.map +1 -0
  3. package/AppRoot/AppRootProvider.js +7 -10
  4. package/AppRoot/AppRootProvider.js.map +1 -1
  5. package/AppRoot/Renderar.cjs +89 -0
  6. package/AppRoot/Renderar.cjs.map +1 -0
  7. package/AppRoot/Renderar.d.ts +1 -0
  8. package/AppRoot/Renderar.js +52 -20
  9. package/AppRoot/Renderar.js.map +1 -1
  10. package/AppRoot/index.cjs +45 -0
  11. package/AppRoot/index.cjs.map +1 -0
  12. package/AppRoot/index.js +25 -24
  13. package/AppRoot/index.js.map +1 -1
  14. package/Document/index.cjs +21 -0
  15. package/Document/index.cjs.map +1 -0
  16. package/Document/index.d.ts +7 -1
  17. package/Document/index.js +8 -11
  18. package/Document/index.js.map +1 -1
  19. package/Iframe/index.cjs +45 -0
  20. package/Iframe/{index.mjs.map → index.cjs.map} +1 -1
  21. package/Iframe/index.js +23 -25
  22. package/Iframe/index.js.map +1 -1
  23. package/Tag/ServerStyleTag.cjs +13 -0
  24. package/Tag/{ServerStyleTag.mjs.map → ServerStyleTag.cjs.map} +1 -1
  25. package/Tag/ServerStyleTag.js +3 -5
  26. package/Tag/ServerStyleTag.js.map +1 -1
  27. package/Tag/{cssPropList.mjs → cssPropList.cjs} +4 -2
  28. package/Tag/cssPropList.cjs.map +1 -0
  29. package/Tag/cssPropList.js +1 -3
  30. package/Tag/cssPropList.js.map +1 -1
  31. package/Tag/index.cjs +40 -0
  32. package/Tag/{index.mjs.map → index.cjs.map} +1 -1
  33. package/Tag/index.js +10 -31
  34. package/Tag/index.js.map +1 -1
  35. package/Tag/{useTagProps.mjs → useTagProps.cjs} +18 -16
  36. package/Tag/useTagProps.cjs.map +1 -0
  37. package/Tag/useTagProps.js +15 -17
  38. package/Tag/useTagProps.js.map +1 -1
  39. package/Transition/index.cjs +29 -0
  40. package/Transition/{index.mjs.map → index.cjs.map} +1 -1
  41. package/Transition/index.js +13 -15
  42. package/Transition/index.js.map +1 -1
  43. package/breakpoint/BreakpointProvider.cjs +49 -0
  44. package/breakpoint/BreakpointProvider.cjs.map +1 -0
  45. package/breakpoint/BreakpointProvider.js +27 -24
  46. package/breakpoint/BreakpointProvider.js.map +1 -1
  47. package/breakpoint/useBreakpoint.cjs +24 -0
  48. package/breakpoint/{useBreakpoint.mjs.map → useBreakpoint.cjs.map} +1 -1
  49. package/breakpoint/useBreakpoint.js +7 -9
  50. package/breakpoint/useBreakpoint.js.map +1 -1
  51. package/breakpoint/{useBreakpointProps.mjs → useBreakpointProps.cjs} +8 -6
  52. package/breakpoint/useBreakpointProps.cjs.map +1 -0
  53. package/breakpoint/useBreakpointProps.js +5 -7
  54. package/breakpoint/useBreakpointProps.js.map +1 -1
  55. package/css/CSSCacheProvider.cjs +34 -0
  56. package/css/{CSSCacheProvider.mjs.map → CSSCacheProvider.cjs.map} +1 -1
  57. package/css/CSSCacheProvider.js +10 -15
  58. package/css/CSSCacheProvider.js.map +1 -1
  59. package/css/{aliases.mjs → aliases.cjs} +4 -2
  60. package/css/aliases.cjs.map +1 -0
  61. package/css/aliases.js +1 -3
  62. package/css/aliases.js.map +1 -1
  63. package/css/{getProps.mjs → getProps.cjs} +4 -2
  64. package/css/{getProps.mjs.map → getProps.cjs.map} +1 -1
  65. package/css/getProps.js +1 -3
  66. package/css/getProps.js.map +1 -1
  67. package/css/{getValue.mjs → getValue.cjs} +4 -2
  68. package/css/{getValue.mjs.map → getValue.cjs.map} +1 -1
  69. package/css/getValue.js +1 -3
  70. package/css/getValue.js.map +1 -1
  71. package/css/{index.mjs → index.cjs} +15 -7
  72. package/css/index.cjs.map +1 -0
  73. package/css/index.js +6 -14
  74. package/css/index.js.map +1 -1
  75. package/hooks/{useAnimation.mjs → useAnimation.cjs} +16 -11
  76. package/hooks/{useAnimation.mjs.map → useAnimation.cjs.map} +1 -1
  77. package/hooks/useAnimation.js +10 -15
  78. package/hooks/useAnimation.js.map +1 -1
  79. package/hooks/{useColorTemplate.mjs → useColorTemplate.cjs} +4 -2
  80. package/hooks/{useColorTemplate.mjs.map → useColorTemplate.cjs.map} +1 -1
  81. package/hooks/useColorTemplate.js +1 -3
  82. package/hooks/useColorTemplate.js.map +1 -1
  83. package/hooks/useInterface.cjs +19 -0
  84. package/hooks/useInterface.cjs.map +1 -0
  85. package/hooks/useInterface.js +7 -9
  86. package/hooks/useInterface.js.map +1 -1
  87. package/hooks/{useMergeRefs.mjs → useMergeRefs.cjs} +6 -4
  88. package/hooks/{useMergeRefs.mjs.map → useMergeRefs.cjs.map} +1 -1
  89. package/hooks/useMergeRefs.js +3 -5
  90. package/hooks/useMergeRefs.js.map +1 -1
  91. package/hooks/usePortal.cjs +69 -0
  92. package/hooks/usePortal.cjs.map +1 -0
  93. package/hooks/usePortal.js +29 -32
  94. package/hooks/usePortal.js.map +1 -1
  95. package/hooks/useTransition/{index.mjs → index.cjs} +29 -27
  96. package/hooks/useTransition/index.cjs.map +1 -0
  97. package/hooks/useTransition/index.js +26 -28
  98. package/hooks/useTransition/index.js.map +1 -1
  99. package/hooks/useTransition/{variants.mjs → variants.cjs} +17 -2
  100. package/hooks/useTransition/{variants.mjs.map → variants.cjs.map} +1 -1
  101. package/hooks/useTransition/variants.js +1 -16
  102. package/hooks/useTransition/variants.js.map +1 -1
  103. package/index.cjs +64 -0
  104. package/index.cjs.map +1 -0
  105. package/index.js +25 -63
  106. package/index.js.map +1 -1
  107. package/package.json +4 -11
  108. package/theme/{ThemeCssVars.mjs → ThemeCssVars.cjs} +4 -2
  109. package/theme/{ThemeCssVars.mjs.map → ThemeCssVars.cjs.map} +1 -1
  110. package/theme/ThemeCssVars.js +1 -3
  111. package/theme/ThemeCssVars.js.map +1 -1
  112. package/theme/{ThemeDefaultOptions.mjs → ThemeDefaultOptions.cjs} +11 -5
  113. package/theme/{ThemeDefaultOptions.mjs.map → ThemeDefaultOptions.cjs.map} +1 -1
  114. package/theme/ThemeDefaultOptions.js +4 -10
  115. package/theme/ThemeDefaultOptions.js.map +1 -1
  116. package/theme/{ThemeProvider.mjs → ThemeProvider.cjs} +52 -31
  117. package/theme/ThemeProvider.cjs.map +1 -0
  118. package/theme/ThemeProvider.js +30 -51
  119. package/theme/ThemeProvider.js.map +1 -1
  120. package/theme/{core.mjs → core.cjs} +12 -6
  121. package/theme/core.cjs.map +1 -0
  122. package/theme/core.js +5 -11
  123. package/theme/core.js.map +1 -1
  124. package/theme/createTheme.cjs +27 -0
  125. package/theme/{createTheme.mjs.map → createTheme.cjs.map} +1 -1
  126. package/theme/createTheme.js +10 -12
  127. package/theme/createTheme.js.map +1 -1
  128. package/theme/{createThemeSwitcher.mjs → createThemeSwitcher.cjs} +8 -6
  129. package/theme/{createThemeSwitcher.mjs.map → createThemeSwitcher.cjs.map} +1 -1
  130. package/theme/createThemeSwitcher.js +5 -7
  131. package/theme/createThemeSwitcher.js.map +1 -1
  132. package/theme/index.cjs +15 -0
  133. package/theme/{index.mjs.map → index.cjs.map} +1 -1
  134. package/theme/index.js +6 -11
  135. package/theme/index.js.map +1 -1
  136. package/AppRoot/AppRootProvider.mjs +0 -17
  137. package/AppRoot/AppRootProvider.mjs.map +0 -1
  138. package/AppRoot/Renderar.mjs +0 -51
  139. package/AppRoot/Renderar.mjs.map +0 -1
  140. package/AppRoot/index.mjs +0 -40
  141. package/AppRoot/index.mjs.map +0 -1
  142. package/Document/index.mjs +0 -18
  143. package/Document/index.mjs.map +0 -1
  144. package/Iframe/index.mjs +0 -43
  145. package/Tag/ServerStyleTag.mjs +0 -11
  146. package/Tag/cssPropList.mjs.map +0 -1
  147. package/Tag/index.mjs +0 -19
  148. package/Tag/useTagProps.mjs.map +0 -1
  149. package/Transition/index.mjs +0 -27
  150. package/breakpoint/BreakpointProvider.mjs +0 -40
  151. package/breakpoint/BreakpointProvider.mjs.map +0 -1
  152. package/breakpoint/useBreakpoint.mjs +0 -22
  153. package/breakpoint/useBreakpointProps.mjs.map +0 -1
  154. package/css/CSSCacheProvider.mjs +0 -29
  155. package/css/aliases.mjs.map +0 -1
  156. package/css/index.mjs.map +0 -1
  157. package/hooks/useInterface.mjs +0 -17
  158. package/hooks/useInterface.mjs.map +0 -1
  159. package/hooks/usePortal.mjs +0 -68
  160. package/hooks/usePortal.mjs.map +0 -1
  161. package/hooks/useTransition/index.mjs.map +0 -1
  162. package/index.mjs +0 -26
  163. package/index.mjs.map +0 -1
  164. package/theme/ThemeProvider.mjs.map +0 -1
  165. package/theme/core.mjs.map +0 -1
  166. package/theme/createTheme.mjs +0 -25
  167. package/theme/index.mjs +0 -10
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+
6
+ const AppRootContext = React.createContext(null);
7
+ const AppRootProvider = ({ element, children }) => {
8
+ return (jsxRuntime.jsx(AppRootContext.Provider, { value: element, children: children }));
9
+ };
10
+ const useAppRootElement = () => {
11
+ const context = React.useContext(AppRootContext);
12
+ if (typeof window === 'undefined') {
13
+ return null;
14
+ }
15
+ return context();
16
+ };
17
+
18
+ exports.AppRootProvider = AppRootProvider;
19
+ exports.useAppRootElement = useAppRootElement;
20
+ //# sourceMappingURL=AppRootProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppRootProvider.cjs","sources":["../../src/AppRoot/AppRootProvider.tsx"],"sourcesContent":["import React from \"react\";\r\n\r\nconst AppRootContext = React.createContext<(() => HTMLElement | null) | null>(null);\r\n\r\nexport const AppRootProvider: React.FC<{ element: () => HTMLElement | null; children: React.ReactNode }> = ({ element, children }) => {\r\n return (\r\n <AppRootContext.Provider value={element}>\r\n {children}\r\n </AppRootContext.Provider>\r\n );\r\n}\r\n\r\nexport const useAppRootElement = (): HTMLElement => {\r\n const context = React.useContext(AppRootContext);\r\n if (typeof window === 'undefined') {\r\n return null as any;\r\n }\r\n\r\n return context!() as HTMLElement\r\n}\r\n"],"names":["_jsx"],"mappings":";;;;;AAEA,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAoC,IAAI,CAAC;AAE5E,MAAM,eAAe,GAA+E,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAI;AAClI,IAAA,QACGA,cAAA,CAAC,cAAc,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,OAAO,EAAA,QAAA,EACnC,QAAQ,EAAA,CACc;AAEhC;AAEO,MAAM,iBAAiB,GAAG,MAAkB;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;AAChD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,QAAA,OAAO,IAAW;IACrB;IAEA,OAAO,OAAQ,EAAiB;AACnC;;;;;"}
@@ -1,20 +1,17 @@
1
- 'use strict';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import React__default from 'react';
2
3
 
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
-
6
- const AppRootContext = React.createContext(null);
4
+ const AppRootContext = React__default.createContext(null);
7
5
  const AppRootProvider = ({ element, children }) => {
8
- return (jsxRuntime.jsx(AppRootContext.Provider, { value: element, children: children }));
6
+ return (jsx(AppRootContext.Provider, { value: element, children: children }));
9
7
  };
10
8
  const useAppRootElement = () => {
11
- const context = React.useContext(AppRootContext);
9
+ const context = React__default.useContext(AppRootContext);
12
10
  if (typeof window === 'undefined') {
13
11
  return null;
14
12
  }
15
- return context;
13
+ return context();
16
14
  };
17
15
 
18
- exports.AppRootProvider = AppRootProvider;
19
- exports.useAppRootElement = useAppRootElement;
16
+ export { AppRootProvider, useAppRootElement };
20
17
  //# sourceMappingURL=AppRootProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppRootProvider.js","sources":["../../src/AppRoot/AppRootProvider.tsx"],"sourcesContent":["import React from \"react\";\r\n\r\nconst AppRootContext = React.createContext<HTMLElement | null>(null);\r\n\r\nexport const AppRootProvider: React.FC<{ element: HTMLElement | null; children: React.ReactNode }> = ({ element, children }) => {\r\n return (\r\n <AppRootContext.Provider value={element}>\r\n {children}\r\n </AppRootContext.Provider>\r\n );\r\n}\r\n\r\nexport const useAppRootElement = (): HTMLElement => {\r\n const context = React.useContext(AppRootContext);\r\n if (typeof window === 'undefined') {\r\n return null as any;\r\n }\r\n return context as HTMLElement\r\n}\r\n"],"names":["_jsx"],"mappings":";;;;;AAEA,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAqB,IAAI,CAAC;AAE7D,MAAM,eAAe,GAAyE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAI;AAC5H,IAAA,QACGA,cAAA,CAAC,cAAc,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,OAAO,EAAA,QAAA,EACnC,QAAQ,EAAA,CACc;AAEhC;AAEO,MAAM,iBAAiB,GAAG,MAAkB;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;AAChD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,QAAA,OAAO,IAAW;IACrB;AACA,IAAA,OAAO,OAAsB;AAChC;;;;;"}
1
+ {"version":3,"file":"AppRootProvider.js","sources":["../../src/AppRoot/AppRootProvider.tsx"],"sourcesContent":["import React from \"react\";\r\n\r\nconst AppRootContext = React.createContext<(() => HTMLElement | null) | null>(null);\r\n\r\nexport const AppRootProvider: React.FC<{ element: () => HTMLElement | null; children: React.ReactNode }> = ({ element, children }) => {\r\n return (\r\n <AppRootContext.Provider value={element}>\r\n {children}\r\n </AppRootContext.Provider>\r\n );\r\n}\r\n\r\nexport const useAppRootElement = (): HTMLElement => {\r\n const context = React.useContext(AppRootContext);\r\n if (typeof window === 'undefined') {\r\n return null as any;\r\n }\r\n\r\n return context!() as HTMLElement\r\n}\r\n"],"names":["React","_jsx"],"mappings":";;;AAEA,MAAM,cAAc,GAAGA,cAAK,CAAC,aAAa,CAAoC,IAAI,CAAC;AAE5E,MAAM,eAAe,GAA+E,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAI;AAClI,IAAA,QACGC,GAAA,CAAC,cAAc,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,OAAO,EAAA,QAAA,EACnC,QAAQ,EAAA,CACc;AAEhC;AAEO,MAAM,iBAAiB,GAAG,MAAkB;IAChD,MAAM,OAAO,GAAGD,cAAK,CAAC,UAAU,CAAC,cAAc,CAAC;AAChD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,QAAA,OAAO,IAAW;IACrB;IAEA,OAAO,OAAQ,EAAiB;AACnC;;;;"}
@@ -0,0 +1,89 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var index = require('../Document/index.cjs');
6
+
7
+ const State = new Map();
8
+ const Dispatch = new Map();
9
+ class Renderar {
10
+ static render(component, props) {
11
+ const docid = Renderar.doc.id;
12
+ let components = State.get(docid) || [];
13
+ components.push({ component, props });
14
+ State.set(Renderar.doc.id, components);
15
+ const dispatch = Dispatch.get(docid);
16
+ if (dispatch) {
17
+ dispatch();
18
+ }
19
+ return {
20
+ unrender: () => {
21
+ this.unrender(component);
22
+ },
23
+ updateProps: (newProps) => {
24
+ this.updateProps(component, newProps);
25
+ }
26
+ };
27
+ }
28
+ static unrender(component) {
29
+ const docid = Renderar.doc.id;
30
+ let components = State.get(docid) || [];
31
+ const index = components.findIndex((c) => c.component === component);
32
+ if (index > -1) {
33
+ components.splice(index, 1);
34
+ const dispatch = Dispatch.get(docid);
35
+ if (dispatch) {
36
+ dispatch();
37
+ }
38
+ }
39
+ }
40
+ static updateProps(component, props) {
41
+ const docid = Renderar.doc.id;
42
+ let components = State.get(docid) || [];
43
+ const storedComponent = components.find((c) => c.component === component);
44
+ if (storedComponent) {
45
+ storedComponent.props = Object.assign(Object.assign({}, storedComponent.props), props);
46
+ }
47
+ const dispatch = Dispatch.get(docid);
48
+ if (dispatch) {
49
+ dispatch();
50
+ }
51
+ }
52
+ }
53
+ const RenderRenderar = () => {
54
+ const [, setState] = React.useState(0);
55
+ const doc = index.useDocument();
56
+ React.useMemo(() => {
57
+ const render = Renderar.render;
58
+ const unrender = Renderar.unrender;
59
+ const updateProps = Renderar.updateProps;
60
+ Renderar.render = ((component, props) => {
61
+ Renderar.doc = doc;
62
+ render(component, Object.assign(Object.assign({}, props), { $doc: doc }));
63
+ Renderar.doc = null;
64
+ });
65
+ Renderar.unrender = ((component) => {
66
+ Renderar.doc = doc;
67
+ unrender(component);
68
+ Renderar.doc = null;
69
+ });
70
+ Renderar.updateProps = ((component, props) => {
71
+ Renderar.doc = doc;
72
+ updateProps(component, props);
73
+ Renderar.doc = null;
74
+ });
75
+ }, [doc.id]);
76
+ if (!Dispatch.has(doc.id)) {
77
+ Dispatch.set(doc.id, () => {
78
+ setState((prev) => prev + 1);
79
+ });
80
+ }
81
+ const components = State.get(doc.id) || [];
82
+ return components.map(({ component: Component, props }, index) => {
83
+ return jsxRuntime.jsx(Component, Object.assign({}, props), index);
84
+ });
85
+ };
86
+
87
+ exports.RenderRenderar = RenderRenderar;
88
+ exports.Renderar = Renderar;
89
+ //# sourceMappingURL=Renderar.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Renderar.cjs","sources":["../../src/AppRoot/Renderar.tsx"],"sourcesContent":["import React, { ReactElement, useMemo } from \"react\";\r\nimport { DocumentID, useDocument } from \"../Document\";\r\n\r\ntype StoredComponent = {\r\n component: React.FunctionComponent<any>;\r\n props: any;\r\n};\r\n\r\nconst State = new Map<DocumentID, StoredComponent[]>()\r\nconst Dispatch = new Map<DocumentID, Function>()\r\n\r\nexport class Renderar {\r\n static doc: any\r\n static render(component: React.FunctionComponent, props?: any) {\r\n const docid = Renderar.doc.id\r\n let components = State.get(docid) || []\r\n components.push({ component, props })\r\n State.set(Renderar.doc.id, components)\r\n const dispatch = Dispatch.get(docid)\r\n if (dispatch) {\r\n dispatch()\r\n }\r\n\r\n return {\r\n unrender: () => {\r\n this.unrender(component);\r\n },\r\n updateProps: (newProps: any) => {\r\n this.updateProps(component, newProps);\r\n }\r\n };\r\n }\r\n\r\n static unrender(component: React.FunctionComponent) {\r\n const docid = Renderar.doc.id\r\n let components = State.get(docid) || []\r\n\r\n const index = components.findIndex((c) => c.component === component);\r\n if (index > -1) {\r\n components.splice(index, 1);\r\n const dispatch = Dispatch.get(docid)\r\n if (dispatch) {\r\n dispatch()\r\n }\r\n }\r\n }\r\n\r\n static updateProps(component: React.FunctionComponent, props: any) {\r\n const docid = Renderar.doc.id\r\n let components = State.get(docid) || []\r\n\r\n const storedComponent = components.find((c) => c.component === component);\r\n if (storedComponent) {\r\n storedComponent.props = { ...storedComponent.props, ...props };\r\n }\r\n const dispatch = Dispatch.get(docid)\r\n if (dispatch) {\r\n dispatch()\r\n }\r\n }\r\n}\r\n\r\nexport const RenderRenderar = () => {\r\n const [, setState] = React.useState(0);\r\n const doc = useDocument()\r\n\r\n useMemo(() => {\r\n const render = Renderar.render\r\n const unrender = Renderar.unrender\r\n const updateProps = Renderar.updateProps\r\n Renderar.render = ((component: React.FunctionComponent, props?: any) => {\r\n Renderar.doc = doc\r\n render(component, { ...props, $doc: doc })\r\n Renderar.doc = null\r\n }) as any\r\n\r\n Renderar.unrender = ((component: React.FunctionComponent) => {\r\n Renderar.doc = doc\r\n unrender(component)\r\n Renderar.doc = null\r\n }) as any\r\n\r\n Renderar.updateProps = ((component: React.FunctionComponent, props: any) => {\r\n Renderar.doc = doc\r\n updateProps(component, props)\r\n Renderar.doc = null\r\n }) as any\r\n\r\n }, [doc.id])\r\n\r\n if (!Dispatch.has(doc.id)) {\r\n Dispatch.set(doc.id, () => {\r\n setState((prev) => prev + 1);\r\n })\r\n }\r\n const components = State.get(doc.id) || []\r\n\r\n return components.map(({ component: Component, props }, index): ReactElement => {\r\n return <Component key={index} {...props} />;\r\n });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4
+ static doc: any;
4
5
  static render(component: React__default.FunctionComponent, props?: any): {
5
6
  unrender: () => void;
6
7
  updateProps: (newProps: any) => void;
@@ -1,13 +1,16 @@
1
- 'use strict';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import React__default, { useMemo } from 'react';
3
+ import { useDocument } from '../Document/index.js';
2
4
 
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
-
6
- const Components = [];
7
- let dispatch = null;
5
+ const State = new Map();
6
+ const Dispatch = new Map();
8
7
  class Renderar {
9
8
  static render(component, props) {
10
- Components.push({ component, props });
9
+ const docid = Renderar.doc.id;
10
+ let components = State.get(docid) || [];
11
+ components.push({ component, props });
12
+ State.set(Renderar.doc.id, components);
13
+ const dispatch = Dispatch.get(docid);
11
14
  if (dispatch) {
12
15
  dispatch();
13
16
  }
@@ -21,34 +24,63 @@ class Renderar {
21
24
  };
22
25
  }
23
26
  static unrender(component) {
24
- const index = Components.findIndex((c) => c.component === component);
27
+ const docid = Renderar.doc.id;
28
+ let components = State.get(docid) || [];
29
+ const index = components.findIndex((c) => c.component === component);
25
30
  if (index > -1) {
26
- Components.splice(index, 1);
27
- if (dispatch)
31
+ components.splice(index, 1);
32
+ const dispatch = Dispatch.get(docid);
33
+ if (dispatch) {
28
34
  dispatch();
35
+ }
29
36
  }
30
37
  }
31
38
  static updateProps(component, props) {
32
- const storedComponent = Components.find((c) => c.component === component);
39
+ const docid = Renderar.doc.id;
40
+ let components = State.get(docid) || [];
41
+ const storedComponent = components.find((c) => c.component === component);
33
42
  if (storedComponent) {
34
43
  storedComponent.props = Object.assign(Object.assign({}, storedComponent.props), props);
35
44
  }
36
- if (dispatch)
45
+ const dispatch = Dispatch.get(docid);
46
+ if (dispatch) {
37
47
  dispatch();
48
+ }
38
49
  }
39
50
  }
40
51
  const RenderRenderar = () => {
41
- const [, setState] = React.useState(0);
42
- if (!dispatch) {
43
- dispatch = () => {
52
+ const [, setState] = React__default.useState(0);
53
+ const doc = useDocument();
54
+ useMemo(() => {
55
+ const render = Renderar.render;
56
+ const unrender = Renderar.unrender;
57
+ const updateProps = Renderar.updateProps;
58
+ Renderar.render = ((component, props) => {
59
+ Renderar.doc = doc;
60
+ render(component, Object.assign(Object.assign({}, props), { $doc: doc }));
61
+ Renderar.doc = null;
62
+ });
63
+ Renderar.unrender = ((component) => {
64
+ Renderar.doc = doc;
65
+ unrender(component);
66
+ Renderar.doc = null;
67
+ });
68
+ Renderar.updateProps = ((component, props) => {
69
+ Renderar.doc = doc;
70
+ updateProps(component, props);
71
+ Renderar.doc = null;
72
+ });
73
+ }, [doc.id]);
74
+ if (!Dispatch.has(doc.id)) {
75
+ Dispatch.set(doc.id, () => {
44
76
  setState((prev) => prev + 1);
45
- };
77
+ });
46
78
  }
47
- return Components.map(({ component: Component, props }, index) => {
48
- return jsxRuntime.jsx(Component, Object.assign({}, props), index);
79
+ const components = State.get(doc.id) || [];
80
+ return components.map(({ component: Component, props }, index) => {
81
+ return jsx(Component, Object.assign({}, props), index);
49
82
  });
50
83
  };
51
84
 
52
- exports.RenderRenderar = RenderRenderar;
53
- exports.Renderar = Renderar;
85
+ export { RenderRenderar, Renderar };
54
86
  //# sourceMappingURL=Renderar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Renderar.js","sources":["../../src/AppRoot/Renderar.tsx"],"sourcesContent":["import React, { ReactElement } from \"react\";\r\n\r\ntype StoredComponent = {\r\n component: React.FunctionComponent<any>;\r\n props: any;\r\n};\r\n\r\nconst Components: StoredComponent[] = [];\r\nlet dispatch: (() => void) | null = null;\r\n\r\nexport class Renderar {\r\n static render(component: React.FunctionComponent, props?: any) {\r\n Components.push({ component, props });\r\n\r\n if (dispatch) {\r\n dispatch();\r\n }\r\n\r\n return {\r\n unrender: () => {\r\n this.unrender(component);\r\n },\r\n updateProps: (newProps: any) => {\r\n this.updateProps(component, newProps);\r\n }\r\n };\r\n }\r\n\r\n static unrender(component: React.FunctionComponent) {\r\n const index = Components.findIndex((c) => c.component === component);\r\n if (index > -1) {\r\n Components.splice(index, 1);\r\n if (dispatch) dispatch();\r\n }\r\n }\r\n\r\n static updateProps(component: React.FunctionComponent, props: any) {\r\n const storedComponent = Components.find((c) => c.component === component);\r\n if (storedComponent) {\r\n storedComponent.props = { ...storedComponent.props, ...props };\r\n }\r\n if (dispatch) dispatch();\r\n }\r\n}\r\n\r\nexport const RenderRenderar = () => {\r\n const [, setState] = React.useState(0);\r\n\r\n if (!dispatch) {\r\n dispatch = () => {\r\n setState((prev) => prev + 1);\r\n };\r\n }\r\n\r\n return Components.map(({ component: Component, props }, index): ReactElement => {\r\n return <Component key={index} {...props} />;\r\n });\r\n};\r\n"],"names":["_jsx"],"mappings":";;;;;AAOA,MAAM,UAAU,GAAsB,EAAE;AACxC,IAAI,QAAQ,GAAwB,IAAI;MAE3B,QAAQ,CAAA;AAClB,IAAA,OAAO,MAAM,CAAC,SAAkC,EAAE,KAAW,EAAA;QAC1D,UAAU,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAErC,IAAI,QAAQ,EAAE;AACX,YAAA,QAAQ,EAAE;QACb;QAEA,OAAO;YACJ,QAAQ,EAAE,MAAK;AACZ,gBAAA,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC3B,CAAC;AACD,YAAA,WAAW,EAAE,CAAC,QAAa,KAAI;AAC5B,gBAAA,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC;YACxC;SACF;IACJ;IAEA,OAAO,QAAQ,CAAC,SAAkC,EAAA;AAC/C,QAAA,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC;AACpE,QAAA,IAAI,KAAK,GAAG,EAAE,EAAE;AACb,YAAA,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AAC3B,YAAA,IAAI,QAAQ;AAAE,gBAAA,QAAQ,EAAE;QAC3B;IACH;AAEA,IAAA,OAAO,WAAW,CAAC,SAAkC,EAAE,KAAU,EAAA;AAC9D,QAAA,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC;QACzE,IAAI,eAAe,EAAE;YAClB,eAAe,CAAC,KAAK,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,eAAe,CAAC,KAAK,CAAA,EAAK,KAAK,CAAE;QACjE;AACA,QAAA,IAAI,QAAQ;AAAE,YAAA,QAAQ,EAAE;IAC3B;AACF;AAEM,MAAM,cAAc,GAAG,MAAK;IAChC,MAAM,GAAG,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEtC,IAAI,CAAC,QAAQ,EAAE;QACZ,QAAQ,GAAG,MAAK;YACb,QAAQ,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,CAAC;AAC/B,QAAA,CAAC;IACJ;AAEA,IAAA,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,KAAK,KAAkB;AAC5E,QAAA,OAAOA,eAAC,SAAS,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAiB,KAAK,CAAA,EAAhB,KAAK,CAAe;AAC9C,IAAA,CAAC,CAAC;AACL;;;;;"}
1
+ {"version":3,"file":"Renderar.js","sources":["../../src/AppRoot/Renderar.tsx"],"sourcesContent":["import React, { ReactElement, useMemo } from \"react\";\r\nimport { DocumentID, useDocument } from \"../Document\";\r\n\r\ntype StoredComponent = {\r\n component: React.FunctionComponent<any>;\r\n props: any;\r\n};\r\n\r\nconst State = new Map<DocumentID, StoredComponent[]>()\r\nconst Dispatch = new Map<DocumentID, Function>()\r\n\r\nexport class Renderar {\r\n static doc: any\r\n static render(component: React.FunctionComponent, props?: any) {\r\n const docid = Renderar.doc.id\r\n let components = State.get(docid) || []\r\n components.push({ component, props })\r\n State.set(Renderar.doc.id, components)\r\n const dispatch = Dispatch.get(docid)\r\n if (dispatch) {\r\n dispatch()\r\n }\r\n\r\n return {\r\n unrender: () => {\r\n this.unrender(component);\r\n },\r\n updateProps: (newProps: any) => {\r\n this.updateProps(component, newProps);\r\n }\r\n };\r\n }\r\n\r\n static unrender(component: React.FunctionComponent) {\r\n const docid = Renderar.doc.id\r\n let components = State.get(docid) || []\r\n\r\n const index = components.findIndex((c) => c.component === component);\r\n if (index > -1) {\r\n components.splice(index, 1);\r\n const dispatch = Dispatch.get(docid)\r\n if (dispatch) {\r\n dispatch()\r\n }\r\n }\r\n }\r\n\r\n static updateProps(component: React.FunctionComponent, props: any) {\r\n const docid = Renderar.doc.id\r\n let components = State.get(docid) || []\r\n\r\n const storedComponent = components.find((c) => c.component === component);\r\n if (storedComponent) {\r\n storedComponent.props = { ...storedComponent.props, ...props };\r\n }\r\n const dispatch = Dispatch.get(docid)\r\n if (dispatch) {\r\n dispatch()\r\n }\r\n }\r\n}\r\n\r\nexport const RenderRenderar = () => {\r\n const [, setState] = React.useState(0);\r\n const doc = useDocument()\r\n\r\n useMemo(() => {\r\n const render = Renderar.render\r\n const unrender = Renderar.unrender\r\n const updateProps = Renderar.updateProps\r\n Renderar.render = ((component: React.FunctionComponent, props?: any) => {\r\n Renderar.doc = doc\r\n render(component, { ...props, $doc: doc })\r\n Renderar.doc = null\r\n }) as any\r\n\r\n Renderar.unrender = ((component: React.FunctionComponent) => {\r\n Renderar.doc = doc\r\n unrender(component)\r\n Renderar.doc = null\r\n }) as any\r\n\r\n Renderar.updateProps = ((component: React.FunctionComponent, props: any) => {\r\n Renderar.doc = doc\r\n updateProps(component, props)\r\n Renderar.doc = null\r\n }) as any\r\n\r\n }, [doc.id])\r\n\r\n if (!Dispatch.has(doc.id)) {\r\n Dispatch.set(doc.id, () => {\r\n setState((prev) => prev + 1);\r\n })\r\n }\r\n const components = State.get(doc.id) || []\r\n\r\n return components.map(({ component: Component, props }, index): ReactElement => {\r\n return <Component key={index} {...props} />;\r\n });\r\n}\r\n"],"names":["React","_jsx"],"mappings":";;;;AAQA,MAAM,KAAK,GAAG,IAAI,GAAG,EAAiC;AACtD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAwB;MAEnC,QAAQ,CAAA;AAElB,IAAA,OAAO,MAAM,CAAC,SAAkC,EAAE,KAAW,EAAA;AAC1D,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC7B,IAAI,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE;QACvC,UAAU,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QACrC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC;QACtC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;QACpC,IAAI,QAAQ,EAAE;AACX,YAAA,QAAQ,EAAE;QACb;QAEA,OAAO;YACJ,QAAQ,EAAE,MAAK;AACZ,gBAAA,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC3B,CAAC;AACD,YAAA,WAAW,EAAE,CAAC,QAAa,KAAI;AAC5B,gBAAA,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC;YACxC;SACF;IACJ;IAEA,OAAO,QAAQ,CAAC,SAAkC,EAAA;AAC/C,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC7B,IAAI,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE;AAEvC,QAAA,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC;AACpE,QAAA,IAAI,KAAK,GAAG,EAAE,EAAE;AACb,YAAA,UAAU,CAAC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@@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var tslib = require('tslib');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var React = require('react');
7
+ require('../theme/core.cjs');
8
+ require('../css/getValue.cjs');
9
+ require('oncss');
10
+ var ThemeProvider = require('../theme/ThemeProvider.cjs');
11
+ require('react-state-bucket');
12
+ var BreakpointProvider = require('../breakpoint/BreakpointProvider.cjs');
13
+ var Renderar = require('./Renderar.cjs');
14
+ var index = require('../Document/index.cjs');
15
+ var AppRootProvider = require('./AppRootProvider.cjs');
16
+ var useMergeRefs = require('../hooks/useMergeRefs.cjs');
17
+ var CSSCacheProvider = require('../css/CSSCacheProvider.cjs');
18
+
19
+ const AppRoot = React.forwardRef((_a, ref) => {
20
+ var { children, noScrollbarCss, CSSCacheId, theme, document: _document } = _a, props = tslib.__rest(_a, ["children", "noScrollbarCss", "CSSCacheId", "theme", "document"]);
21
+ noScrollbarCss !== null && noScrollbarCss !== void 0 ? noScrollbarCss : (noScrollbarCss = false);
22
+ _document !== null && _document !== void 0 ? _document : (_document = document);
23
+ const docid = React.useId();
24
+ const csscacheId = React.useId();
25
+ CSSCacheId !== null && CSSCacheId !== void 0 ? CSSCacheId : (CSSCacheId = csscacheId);
26
+ const [visibility, setVisibility] = React.useState("hidden");
27
+ const [doc, setDoc] = React.useState(_document !== null && _document !== void 0 ? _document : (_document = document));
28
+ const rootRef = React.useRef(null);
29
+ const mergeRef = useMergeRefs(rootRef, ref);
30
+ // console.log(_document);
31
+ React.useEffect(() => {
32
+ setVisibility("visible");
33
+ // move oncss style tags to head
34
+ if (typeof _document === 'undefined')
35
+ return;
36
+ const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));
37
+ styles.forEach((style) => {
38
+ _document.head.appendChild(style);
39
+ });
40
+ }, []);
41
+ return (jsxRuntime.jsx(index.DocumentProvider, { document: doc, id: docid, children: jsxRuntime.jsx(CSSCacheProvider.CSSCacheProvider, { cacheId: CSSCacheId, children: jsxRuntime.jsx(AppRootProvider.AppRootProvider, { element: () => rootRef.current, children: jsxRuntime.jsx(ThemeProvider, Object.assign({ theme: theme }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign({}, props.sx), (visibility === "hidden" ? { visibility: "hidden" } : {})), children: jsxRuntime.jsxs(BreakpointProvider.BreakpointProvider, { children: [children, jsxRuntime.jsx(Renderar.RenderRenderar, {})] }) })) }) }) }));
42
+ });
43
+
44
+ module.exports = AppRoot;
45
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\r\nimport React, { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';\r\nimport { TagComponentType } from '../Tag/types';\r\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\r\nimport { BreakpointProvider } from '../breakpoint';\r\nimport { RenderRenderar } from './Renderar';\r\nimport { DocumentProvider } from '../Document';\r\nimport { AppRootProvider } from './AppRootProvider';\r\nimport useMergeRefs from '../hooks/useMergeRefs';\r\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\r\n\r\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\r\n noScrollbarCss?: boolean;\r\n document?: Document;\r\n CSSCacheId?: string;\r\n}\r\n\r\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, noScrollbarCss, CSSCacheId, theme, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\r\n noScrollbarCss ??= false\r\n _document ??= document\r\n const docid = useId()\r\n\r\n const csscacheId = useId()\r\n CSSCacheId ??= csscacheId\r\n\r\n const [visibility, setVisibility] = React.useState<string>(\"hidden\");\r\n const [doc, setDoc] = useState(_document ??= document)\r\n const rootRef = useRef(null)\r\n const mergeRef = useMergeRefs(rootRef, ref)\r\n // console.log(_document);\r\n\r\n useEffect(() => {\r\n setVisibility(\"visible\");\r\n\r\n // move oncss style tags to head\r\n if (typeof _document === 'undefined') return;\r\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\r\n styles.forEach((style) => {\r\n _document.head.appendChild(style);\r\n });\r\n }, [])\r\n\r\n return (\r\n <DocumentProvider document={doc} id={docid}>\r\n <CSSCacheProvider cacheId={CSSCacheId}>\r\n <AppRootProvider element={() => rootRef.current}>\r\n <ThemeProvider\r\n theme={theme}\r\n {...props}\r\n ref={mergeRef}\r\n isRoot\r\n sx={{\r\n ...props.sx,\r\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {})\r\n }}\r\n >\r\n <BreakpointProvider>\r\n {children}\r\n <RenderRenderar />\r\n </BreakpointProvider>\r\n </ThemeProvider>\r\n </AppRootProvider>\r\n </CSSCacheProvider>\r\n </DocumentProvider>\r\n )\r\n})\r\n\r\nexport default AppRoot\r\n\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAiBA;AAAsE;;;AAGnE;AAEA;;AAGA;AACA;AACA;;;;;;;;AASG;AACA;AACG;AACH;;AAGH;AAuBH;;"}
package/AppRoot/index.js CHANGED
@@ -1,31 +1,32 @@
1
1
  "use client";
2
- 'use strict';
2
+ import { __rest } from 'tslib';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import React__default, { useId, useState, useRef, useEffect } from 'react';
5
+ import '../theme/core.js';
6
+ import '../css/getValue.js';
7
+ import 'oncss';
8
+ import ThemeProvider from '../theme/ThemeProvider.js';
9
+ import 'react-state-bucket';
10
+ import { BreakpointProvider } from '../breakpoint/BreakpointProvider.js';
11
+ import { RenderRenderar } from './Renderar.js';
12
+ import { DocumentProvider } from '../Document/index.js';
13
+ import { AppRootProvider } from './AppRootProvider.js';
14
+ import useMergeRefs from '../hooks/useMergeRefs.js';
15
+ import { CSSCacheProvider } from '../css/CSSCacheProvider.js';
3
16
 
4
- var tslib = require('tslib');
5
- var jsxRuntime = require('react/jsx-runtime');
6
- var React = require('react');
7
- require('../theme/core.js');
8
- require('../css/getValue.js');
9
- require('oncss');
10
- var ThemeProvider = require('../theme/ThemeProvider.js');
11
- require('react-state-bucket');
12
- var BreakpointProvider = require('../breakpoint/BreakpointProvider.js');
13
- var Renderar = require('./Renderar.js');
14
- var index = require('../Document/index.js');
15
- var AppRootProvider = require('./AppRootProvider.js');
16
- var useMergeRefs = require('../hooks/useMergeRefs.js');
17
- var CSSCacheProvider = require('../css/CSSCacheProvider.js');
18
-
19
- const AppRoot = React.forwardRef((_a, ref) => {
20
- var { children, noScrollbarCss, CSSCacheId, theme, document: _document } = _a, props = tslib.__rest(_a, ["children", "noScrollbarCss", "CSSCacheId", "theme", "document"]);
17
+ const AppRoot = React__default.forwardRef((_a, ref) => {
18
+ var { children, noScrollbarCss, CSSCacheId, theme, document: _document } = _a, props = __rest(_a, ["children", "noScrollbarCss", "CSSCacheId", "theme", "document"]);
21
19
  noScrollbarCss !== null && noScrollbarCss !== void 0 ? noScrollbarCss : (noScrollbarCss = false);
22
20
  _document !== null && _document !== void 0 ? _document : (_document = document);
23
- const csscacheId = React.useId();
21
+ const docid = useId();
22
+ const csscacheId = useId();
24
23
  CSSCacheId !== null && CSSCacheId !== void 0 ? CSSCacheId : (CSSCacheId = csscacheId);
25
- const [visibility, setVisibility] = React.useState("hidden");
26
- const rootRef = React.useRef(null);
24
+ const [visibility, setVisibility] = React__default.useState("hidden");
25
+ const [doc, setDoc] = useState(_document !== null && _document !== void 0 ? _document : (_document = document));
26
+ const rootRef = useRef(null);
27
27
  const mergeRef = useMergeRefs(rootRef, ref);
28
- React.useEffect(() => {
28
+ // console.log(_document);
29
+ useEffect(() => {
29
30
  setVisibility("visible");
30
31
  // move oncss style tags to head
31
32
  if (typeof _document === 'undefined')
@@ -35,8 +36,8 @@ const AppRoot = React.forwardRef((_a, ref) => {
35
36
  _document.head.appendChild(style);
36
37
  });
37
38
  }, []);
38
- return (jsxRuntime.jsx(index.DocumentProvider, { document: _document, children: jsxRuntime.jsx(CSSCacheProvider.CSSCacheProvider, { cacheId: CSSCacheId, children: jsxRuntime.jsx(AppRootProvider.AppRootProvider, { element: rootRef.current, children: jsxRuntime.jsx(ThemeProvider, Object.assign({ ref: mergeRef, theme: theme }, props, { isRoot: true, sx: Object.assign(Object.assign({}, props.sx), (visibility === "hidden" ? { visibility: "hidden" } : {})), children: jsxRuntime.jsxs(BreakpointProvider.BreakpointProvider, { children: [children, jsxRuntime.jsx(Renderar.RenderRenderar, {})] }) })) }) }) }));
39
+ return (jsx(DocumentProvider, { document: doc, id: docid, children: jsx(CSSCacheProvider, { cacheId: CSSCacheId, children: jsx(AppRootProvider, { element: () => rootRef.current, children: jsx(ThemeProvider, Object.assign({ theme: theme }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign({}, props.sx), (visibility === "hidden" ? { visibility: "hidden" } : {})), children: jsxs(BreakpointProvider, { children: [children, jsx(RenderRenderar, {})] }) })) }) }) }));
39
40
  });
40
41
 
41
- module.exports = AppRoot;
42
+ export { AppRoot as default };
42
43
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\r\nimport React, { useEffect, useId, useRef } from 'react';\r\nimport { TagComponentType } from '../Tag/types';\r\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\r\nimport { BreakpointProvider } from '../breakpoint';\r\nimport { RenderRenderar } from './Renderar';\r\nimport { DocumentProvider } from '../Document';\r\nimport { AppRootProvider } from './AppRootProvider';\r\nimport useMergeRefs from '../hooks/useMergeRefs';\r\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\r\n\r\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\r\n noScrollbarCss?: boolean;\r\n document?: Document;\r\n CSSCacheId?: string;\r\n}\r\n\r\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, noScrollbarCss, CSSCacheId, theme, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\r\n noScrollbarCss ??= false\r\n _document ??= document\r\n const csscacheId = useId()\r\n CSSCacheId ??= csscacheId\r\n\r\n const [visibility, setVisibility] = React.useState<string>(\"hidden\");\r\n const rootRef = useRef(null)\r\n const mergeRef = useMergeRefs(rootRef, ref)\r\n\r\n useEffect(() => {\r\n setVisibility(\"visible\");\r\n\r\n // move oncss style tags to head\r\n if (typeof _document === 'undefined') return;\r\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\r\n styles.forEach((style) => {\r\n _document.head.appendChild(style);\r\n });\r\n }, [])\r\n\r\n return (\r\n <DocumentProvider document={_document}>\r\n <CSSCacheProvider cacheId={CSSCacheId}>\r\n <AppRootProvider element={rootRef.current}>\r\n <ThemeProvider\r\n ref={mergeRef}\r\n theme={theme}\r\n {...props}\r\n isRoot\r\n sx={{\r\n ...props.sx,\r\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {})\r\n }}\r\n >\r\n <BreakpointProvider>\r\n {children}\r\n <RenderRenderar />\r\n </BreakpointProvider>\r\n </ThemeProvider>\r\n </AppRootProvider>\r\n </CSSCacheProvider>\r\n </DocumentProvider>\r\n )\r\n})\r\n\r\nexport default AppRoot\r\n\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAiBA;AAAsE;;;AAGnE;;AAGA;AACA;;;;;;;AAQG;AACA;AACG;AACH;;AAGH;AAuBH;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\r\nimport React, { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';\r\nimport { TagComponentType } from '../Tag/types';\r\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\r\nimport { BreakpointProvider } from '../breakpoint';\r\nimport { RenderRenderar } from './Renderar';\r\nimport { DocumentProvider } from '../Document';\r\nimport { AppRootProvider } from './AppRootProvider';\r\nimport useMergeRefs from '../hooks/useMergeRefs';\r\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\r\n\r\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\r\n noScrollbarCss?: boolean;\r\n document?: Document;\r\n CSSCacheId?: string;\r\n}\r\n\r\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, noScrollbarCss, CSSCacheId, theme, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\r\n noScrollbarCss ??= false\r\n _document ??= document\r\n const docid = useId()\r\n\r\n const csscacheId = useId()\r\n CSSCacheId ??= csscacheId\r\n\r\n const [visibility, setVisibility] = React.useState<string>(\"hidden\");\r\n const [doc, setDoc] = useState(_document ??= document)\r\n const rootRef = useRef(null)\r\n const mergeRef = useMergeRefs(rootRef, ref)\r\n // console.log(_document);\r\n\r\n useEffect(() => {\r\n setVisibility(\"visible\");\r\n\r\n // move oncss style tags to head\r\n if (typeof _document === 'undefined') return;\r\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\r\n styles.forEach((style) => {\r\n _document.head.appendChild(style);\r\n });\r\n }, [])\r\n\r\n return (\r\n <DocumentProvider document={doc} id={docid}>\r\n <CSSCacheProvider cacheId={CSSCacheId}>\r\n <AppRootProvider element={() => rootRef.current}>\r\n <ThemeProvider\r\n theme={theme}\r\n {...props}\r\n ref={mergeRef}\r\n isRoot\r\n sx={{\r\n ...props.sx,\r\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {})\r\n }}\r\n >\r\n <BreakpointProvider>\r\n {children}\r\n <RenderRenderar />\r\n </BreakpointProvider>\r\n </ThemeProvider>\r\n </AppRootProvider>\r\n </CSSCacheProvider>\r\n </DocumentProvider>\r\n )\r\n})\r\n\r\nexport default AppRoot\r\n\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiBA;AAAsE;;;AAGnE;AAEA;;AAGA;AACA;AACA;;;;;;;;AASG;AACA;AACG;AACH;;AAGH;AAuBH;;"}
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+
7
+ const DocumentContext = React.createContext(null);
8
+ const DocumentProvider = ({ document, id, children }) => {
9
+ return (jsxRuntime.jsx(DocumentContext.Provider, { value: { document, id }, children: children }));
10
+ };
11
+ const useDocument = () => {
12
+ const context = React.useContext(DocumentContext);
13
+ if (typeof window === 'undefined') {
14
+ return null;
15
+ }
16
+ return context;
17
+ };
18
+
19
+ exports.DocumentProvider = DocumentProvider;
20
+ exports.useDocument = useDocument;
21
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/Document/index.tsx"],"sourcesContent":["'use client'\r\nimport React, { useContext, createContext } from \"react\";\r\n\r\n\r\nexport type DocumentID = string\r\nexport type DocumentContextValue = { document: Document; id: DocumentID }\r\nconst DocumentContext = createContext<DocumentContextValue | null>(null);\r\n\r\nexport const DocumentProvider: React.FC<{ children: React.ReactNode } & DocumentContextValue> = ({ document, id, children }) => {\r\n return (\r\n <DocumentContext.Provider value={{ document, id }}>\r\n {children}\r\n </DocumentContext.Provider>\r\n );\r\n}\r\n\r\nexport const useDocument = (): DocumentContextValue => {\r\n const context = useContext(DocumentContext);\r\n if (typeof window === 'undefined') {\r\n return null as any;\r\n }\r\n\r\n return context as DocumentContextValue\r\n}"],"names":[],"mappings":";;;;;;AAMA;AAEO;AACJ;AAKH;AAEO;AACJ;AACA;AACG;;AAGH;AACH;;;"}
@@ -1,3 +1,9 @@
1
- declare const useDocument: () => Document;
1
+ type DocumentID = string;
2
+ type DocumentContextValue = {
3
+ document: Document;
4
+ id: DocumentID;
5
+ };
6
+ declare const useDocument: () => DocumentContextValue;
2
7
 
3
8
  export { useDocument };
9
+ export type { DocumentContextValue, DocumentID };
package/Document/index.js CHANGED
@@ -1,21 +1,18 @@
1
1
  "use client";
2
- 'use strict';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { createContext, useContext } from 'react';
3
4
 
4
- var jsxRuntime = require('react/jsx-runtime');
5
- var React = require('react');
6
-
7
- const DocumentContext = React.createContext(null);
8
- const DocumentProvider = ({ document, children }) => {
9
- return (jsxRuntime.jsx(DocumentContext.Provider, { value: document, children: children }));
5
+ const DocumentContext = createContext(null);
6
+ const DocumentProvider = ({ document, id, children }) => {
7
+ return (jsx(DocumentContext.Provider, { value: { document, id }, children: children }));
10
8
  };
11
9
  const useDocument = () => {
12
- const context = React.useContext(DocumentContext);
10
+ const context = useContext(DocumentContext);
13
11
  if (typeof window === 'undefined') {
14
12
  return null;
15
13
  }
16
- return context || document;
14
+ return context;
17
15
  };
18
16
 
19
- exports.DocumentProvider = DocumentProvider;
20
- exports.useDocument = useDocument;
17
+ export { DocumentProvider, useDocument };
21
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/Document/index.tsx"],"sourcesContent":["'use client'\r\nimport React from \"react\";\r\n\r\nconst DocumentContext = React.createContext<Document | null>(null);\r\n\r\nexport const DocumentProvider: React.FC<{ document: Document; children: React.ReactNode }> = ({ document, children }) => {\r\n return (\r\n <DocumentContext.Provider value={document}>\r\n {children}\r\n </DocumentContext.Provider>\r\n );\r\n}\r\n\r\nexport const useDocument = (): Document => {\r\n const context = React.useContext(DocumentContext);\r\n if (typeof window === 'undefined') {\r\n return null as any;\r\n }\r\n return context || document;\r\n}"],"names":[],"mappings":";;;;;;AAGA;AAEO;AACJ;AAKH;AAEO;;AAEJ;AACG;;;AAGN;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/Document/index.tsx"],"sourcesContent":["'use client'\r\nimport React, { useContext, createContext } from \"react\";\r\n\r\n\r\nexport type DocumentID = string\r\nexport type DocumentContextValue = { document: Document; id: DocumentID }\r\nconst DocumentContext = createContext<DocumentContextValue | null>(null);\r\n\r\nexport const DocumentProvider: React.FC<{ children: React.ReactNode } & DocumentContextValue> = ({ document, id, children }) => {\r\n return (\r\n <DocumentContext.Provider value={{ document, id }}>\r\n {children}\r\n </DocumentContext.Provider>\r\n );\r\n}\r\n\r\nexport const useDocument = (): DocumentContextValue => {\r\n const context = useContext(DocumentContext);\r\n if (typeof window === 'undefined') {\r\n return null as any;\r\n }\r\n\r\n return context as DocumentContextValue\r\n}"],"names":[],"mappings":";;;;AAMA;AAEO;AACJ;AAKH;AAEO;AACJ;AACA;AACG;;AAGH;AACH;;"}
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var tslib = require('tslib');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var React = require('react');
7
+ var core = require('../theme/core.cjs');
8
+ require('../css/getValue.cjs');
9
+ require('oncss');
10
+ require('../theme/ThemeProvider.cjs');
11
+ require('react-state-bucket');
12
+ var index$1 = require('../Tag/index.cjs');
13
+ var reactDom = require('react-dom');
14
+ var index$2 = require('../AppRoot/index.cjs');
15
+ var useMergeRefs = require('../hooks/useMergeRefs.cjs');
16
+
17
+ const IframeContext = React.createContext({
18
+ document: null,
19
+ window: null,
20
+ });
21
+ const Iframe = (_a, ref) => {
22
+ var { children, sxr, theme, CSSCacheId } = _a, props = tslib.__rest(_a, ["children", "sxr", "theme", "CSSCacheId"]);
23
+ const [doc, setDoc] = React.useState(null);
24
+ const iframeRef = React.useRef(null);
25
+ const _ref = useMergeRefs(iframeRef, ref);
26
+ const parentTheme = core.useTheme();
27
+ theme !== null && theme !== void 0 ? theme : (theme = parentTheme.name);
28
+ React.useEffect(() => {
29
+ if (!iframeRef.current)
30
+ return;
31
+ const iframe = iframeRef.current;
32
+ const onLoad = () => setDoc(iframe.contentDocument);
33
+ iframe.addEventListener("load", onLoad);
34
+ return () => iframe.removeEventListener("load", onLoad);
35
+ }, []);
36
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(index$1, Object.assign({}, props, { component: "iframe", sxr: Object.assign({ border: 'none', width: "100%", height: "100%", p: 0, m: 0 }, sxr), ref: _ref, srcDoc: "<!DOCTYPE html><html><head></head><body></body></html>" })), doc &&
37
+ reactDom.createPortal(jsxRuntime.jsx(IframeContext.Provider, { value: {
38
+ document: doc,
39
+ window: doc.defaultView,
40
+ }, children: jsxRuntime.jsx(index$2, { theme: theme, document: doc, CSSCacheId: CSSCacheId, children: children }) }), doc.body)] }));
41
+ };
42
+ var index = React.forwardRef(Iframe);
43
+
44
+ module.exports = index;
45
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/Iframe/index.tsx"],"sourcesContent":["'use client'\r\nimport React, { createContext, useEffect, useRef, useState } from \"react\";\r\nimport { useTheme } from \"../theme\";\r\nimport Tag from \"../Tag\";\r\nimport { createPortal } from \"react-dom\";\r\nimport AppRoot from \"../AppRoot\";\r\nimport { TagPropsRoot } from \"../Tag/types\";\r\nimport useMergeRefs from \"../hooks/useMergeRefs\";\r\n\r\nconst IframeContext = createContext<{ document: Document | null; window: Window | null; }>({\r\n document: null,\r\n window: null,\r\n});\r\n\r\n\r\nexport type IframeProps = Omit<TagPropsRoot<\"iframe\">, \"component\"> & {\r\n theme?: string;\r\n CSSCacheId?: string;\r\n}\r\n\r\nconst Iframe = ({ children, sxr, theme, CSSCacheId, ...props }: IframeProps, ref: React.Ref<HTMLIFrameElement>) => {\r\n const [doc, setDoc] = useState<Document | null>(null);\r\n const iframeRef = useRef<HTMLIFrameElement>(null);\r\n const _ref = useMergeRefs(iframeRef, ref)\r\n const parentTheme = useTheme()\r\n theme ??= parentTheme.name\r\n\r\n useEffect(() => {\r\n if (!iframeRef.current) return;\r\n const iframe = iframeRef.current;\r\n const onLoad = () => setDoc(iframe.contentDocument);\r\n iframe.addEventListener(\"load\", onLoad);\r\n return () => iframe.removeEventListener(\"load\", onLoad);\r\n }, []);\r\n\r\n return (\r\n <>\r\n <Tag\r\n {...props}\r\n component={\"iframe\"}\r\n sxr={{\r\n border: 'none',\r\n width: \"100%\",\r\n height: \"100%\",\r\n p: 0,\r\n m: 0,\r\n ...sxr\r\n }}\r\n ref={_ref}\r\n srcDoc={\"<!DOCTYPE html><html><head></head><body></body></html>\"}\r\n />\r\n {doc &&\r\n createPortal(\r\n <IframeContext.Provider\r\n value={{\r\n document: doc,\r\n window: doc.defaultView,\r\n }}\r\n >\r\n <AppRoot theme={theme} document={doc as Document} CSSCacheId={CSSCacheId}>\r\n {children}\r\n </AppRoot>\r\n </IframeContext.Provider>,\r\n doc.body\r\n )}\r\n </>\r\n );\r\n}\r\n\r\nexport default React.forwardRef(Iframe)"],"names":[],"mappings":";;;;;;;;;;;;;;AASA;AACG;AACA;AACF;AAQD;AAAgB;;AAEb;;AAEA;;;;;AAKG;;AAEA;;;;AAqBM;AAGS;;;AAYrB;AAEA;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/Iframe/index.tsx"],"sourcesContent":["'use client'\r\nimport React, { createContext, useEffect, useRef, useState } from \"react\";\r\nimport { useTheme } from \"../theme\";\r\nimport Tag from \"../Tag\";\r\nimport { createPortal } from \"react-dom\";\r\nimport AppRoot from \"../AppRoot\";\r\nimport { TagPropsRoot } from \"../Tag/types\";\r\nimport useMergeRefs from \"../hooks/useMergeRefs\";\r\n\r\nconst IframeContext = createContext<{ document: Document | null; window: Window | null; }>({\r\n document: null,\r\n window: null,\r\n});\r\n\r\n\r\nexport type IframeProps = Omit<TagPropsRoot<\"iframe\">, \"component\"> & {\r\n theme?: string;\r\n CSSCacheId?: string;\r\n}\r\n\r\nconst Iframe = ({ children, sxr, theme, CSSCacheId, ...props }: IframeProps, ref: React.Ref<HTMLIFrameElement>) => {\r\n const [doc, setDoc] = useState<Document | null>(null);\r\n const iframeRef = useRef<HTMLIFrameElement>(null);\r\n const _ref = useMergeRefs(iframeRef, ref)\r\n const parentTheme = useTheme()\r\n theme ??= parentTheme.name\r\n\r\n useEffect(() => {\r\n if (!iframeRef.current) return;\r\n const iframe = iframeRef.current;\r\n const onLoad = () => setDoc(iframe.contentDocument);\r\n iframe.addEventListener(\"load\", onLoad);\r\n return () => iframe.removeEventListener(\"load\", onLoad);\r\n }, []);\r\n\r\n return (\r\n <>\r\n <Tag\r\n {...props}\r\n component={\"iframe\"}\r\n sxr={{\r\n border: 'none',\r\n width: \"100%\",\r\n height: \"100%\",\r\n p: 0,\r\n m: 0,\r\n ...sxr\r\n }}\r\n ref={_ref}\r\n srcDoc={\"<!DOCTYPE html><html><head></head><body></body></html>\"}\r\n />\r\n {doc &&\r\n createPortal(\r\n <IframeContext.Provider\r\n value={{\r\n document: doc,\r\n window: doc.defaultView,\r\n }}\r\n >\r\n <AppRoot theme={theme} document={doc as Document} CSSCacheId={CSSCacheId}>\r\n {children}\r\n </AppRoot>\r\n </IframeContext.Provider>,\r\n doc.body\r\n )}\r\n </>\r\n );\r\n}\r\n\r\nexport default React.forwardRef(Iframe)"],"names":[],"mappings":";;;;;;;;;;;;;;;;AASA;AACG;AACA;AACF;AAQD;AAAgB;;AAEb;;AAEA;;;;;AAKG;;AAEA;;;;AAqBM;AAGS;;;AAYrB;AAEA;;"}