@xanui/core 1.2.42 → 1.2.44

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 (174) hide show
  1. package/AppRoot/{context.js → AppRootProvider.cjs} +1 -1
  2. package/AppRoot/AppRootProvider.cjs.map +1 -0
  3. package/AppRoot/{context.mjs → AppRootProvider.js} +1 -1
  4. package/AppRoot/AppRootProvider.js.map +1 -0
  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 +43 -0
  11. package/AppRoot/index.cjs.map +1 -0
  12. package/AppRoot/index.d.ts +2 -2
  13. package/AppRoot/index.js +24 -106
  14. package/AppRoot/index.js.map +1 -1
  15. package/Document/index.cjs +21 -0
  16. package/Document/index.cjs.map +1 -0
  17. package/Document/index.d.ts +7 -1
  18. package/Document/index.js +8 -11
  19. package/Document/index.js.map +1 -1
  20. package/Iframe/index.cjs +45 -0
  21. package/Iframe/index.cjs.map +1 -0
  22. package/Iframe/index.d.ts +1 -0
  23. package/Iframe/index.js +23 -25
  24. package/Iframe/index.js.map +1 -1
  25. package/Tag/ServerStyleTag.cjs +13 -0
  26. package/Tag/{ServerStyleTag.mjs.map → ServerStyleTag.cjs.map} +1 -1
  27. package/Tag/ServerStyleTag.js +3 -5
  28. package/Tag/ServerStyleTag.js.map +1 -1
  29. package/Tag/{cssPropList.mjs → cssPropList.cjs} +4 -2
  30. package/Tag/cssPropList.cjs.map +1 -0
  31. package/Tag/cssPropList.js +1 -3
  32. package/Tag/cssPropList.js.map +1 -1
  33. package/Tag/index.cjs +40 -0
  34. package/Tag/{index.mjs.map → index.cjs.map} +1 -1
  35. package/Tag/index.js +10 -31
  36. package/Tag/index.js.map +1 -1
  37. package/Tag/{useTagProps.mjs → useTagProps.cjs} +18 -13
  38. package/Tag/useTagProps.cjs.map +1 -0
  39. package/Tag/useTagProps.js +15 -14
  40. package/Tag/useTagProps.js.map +1 -1
  41. package/Transition/index.cjs +29 -0
  42. package/Transition/{index.mjs.map → index.cjs.map} +1 -1
  43. package/Transition/index.js +13 -15
  44. package/Transition/index.js.map +1 -1
  45. package/breakpoint/BreakpointProvider.cjs +43 -0
  46. package/breakpoint/{BreakpointProvider.mjs.map → BreakpointProvider.cjs.map} +1 -1
  47. package/breakpoint/BreakpointProvider.js +13 -16
  48. package/breakpoint/BreakpointProvider.js.map +1 -1
  49. package/breakpoint/useBreakpoint.cjs +24 -0
  50. package/breakpoint/{useBreakpoint.mjs.map → useBreakpoint.cjs.map} +1 -1
  51. package/breakpoint/useBreakpoint.js +7 -9
  52. package/breakpoint/useBreakpoint.js.map +1 -1
  53. package/breakpoint/{useBreakpointProps.mjs → useBreakpointProps.cjs} +8 -6
  54. package/breakpoint/useBreakpointProps.cjs.map +1 -0
  55. package/breakpoint/useBreakpointProps.js +5 -7
  56. package/breakpoint/useBreakpointProps.js.map +1 -1
  57. package/css/CSSCacheProvider.cjs +34 -0
  58. package/css/CSSCacheProvider.cjs.map +1 -0
  59. package/css/CSSCacheProvider.d.ts +7 -0
  60. package/css/CSSCacheProvider.js +29 -0
  61. package/css/CSSCacheProvider.js.map +1 -0
  62. package/css/{aliases.mjs → aliases.cjs} +4 -2
  63. package/css/aliases.cjs.map +1 -0
  64. package/css/aliases.js +1 -3
  65. package/css/aliases.js.map +1 -1
  66. package/css/{getProps.mjs → getProps.cjs} +4 -2
  67. package/css/{getProps.mjs.map → getProps.cjs.map} +1 -1
  68. package/css/getProps.js +1 -3
  69. package/css/getProps.js.map +1 -1
  70. package/css/{getValue.mjs → getValue.cjs} +4 -2
  71. package/css/{getValue.mjs.map → getValue.cjs.map} +1 -1
  72. package/css/getValue.js +1 -3
  73. package/css/getValue.js.map +1 -1
  74. package/css/{index.mjs → index.cjs} +15 -7
  75. package/css/index.cjs.map +1 -0
  76. package/css/index.js +6 -14
  77. package/css/index.js.map +1 -1
  78. package/hooks/{useAnimation.mjs → useAnimation.cjs} +18 -6
  79. package/hooks/useAnimation.cjs.map +1 -0
  80. package/hooks/useAnimation.js +12 -10
  81. package/hooks/useAnimation.js.map +1 -1
  82. package/hooks/{useColorTemplate.mjs → useColorTemplate.cjs} +4 -2
  83. package/hooks/{useColorTemplate.mjs.map → useColorTemplate.cjs.map} +1 -1
  84. package/hooks/useColorTemplate.js +1 -3
  85. package/hooks/useColorTemplate.js.map +1 -1
  86. package/hooks/useInterface.cjs +19 -0
  87. package/hooks/useInterface.cjs.map +1 -0
  88. package/hooks/useInterface.js +7 -9
  89. package/hooks/useInterface.js.map +1 -1
  90. package/hooks/{useMergeRefs.mjs → useMergeRefs.cjs} +6 -4
  91. package/hooks/{useMergeRefs.mjs.map → useMergeRefs.cjs.map} +1 -1
  92. package/hooks/useMergeRefs.js +3 -5
  93. package/hooks/useMergeRefs.js.map +1 -1
  94. package/hooks/usePortal.cjs +66 -0
  95. package/hooks/usePortal.cjs.map +1 -0
  96. package/hooks/usePortal.js +24 -30
  97. package/hooks/usePortal.js.map +1 -1
  98. package/hooks/useTransition/{index.mjs → index.cjs} +29 -25
  99. package/hooks/useTransition/index.cjs.map +1 -0
  100. package/hooks/useTransition/index.js +26 -26
  101. package/hooks/useTransition/index.js.map +1 -1
  102. package/hooks/useTransition/{variants.mjs → variants.cjs} +17 -2
  103. package/hooks/useTransition/{variants.mjs.map → variants.cjs.map} +1 -1
  104. package/hooks/useTransition/variants.js +1 -16
  105. package/hooks/useTransition/variants.js.map +1 -1
  106. package/index.cjs +64 -0
  107. package/index.cjs.map +1 -0
  108. package/index.d.ts +3 -2
  109. package/index.js +25 -60
  110. package/index.js.map +1 -1
  111. package/package.json +5 -12
  112. package/theme/{ThemeCssVars.mjs → ThemeCssVars.cjs} +4 -2
  113. package/theme/{ThemeCssVars.mjs.map → ThemeCssVars.cjs.map} +1 -1
  114. package/theme/ThemeCssVars.js +1 -3
  115. package/theme/ThemeCssVars.js.map +1 -1
  116. package/theme/{ThemeDefaultOptions.mjs → ThemeDefaultOptions.cjs} +11 -5
  117. package/theme/{ThemeDefaultOptions.mjs.map → ThemeDefaultOptions.cjs.map} +1 -1
  118. package/theme/ThemeDefaultOptions.js +4 -10
  119. package/theme/ThemeDefaultOptions.js.map +1 -1
  120. package/theme/ThemeProvider.cjs +154 -0
  121. package/theme/ThemeProvider.cjs.map +1 -0
  122. package/theme/ThemeProvider.d.ts +3 -1
  123. package/theme/ThemeProvider.js +109 -41
  124. package/theme/ThemeProvider.js.map +1 -1
  125. package/theme/{core.mjs → core.cjs} +12 -6
  126. package/theme/core.cjs.map +1 -0
  127. package/theme/core.js +5 -11
  128. package/theme/core.js.map +1 -1
  129. package/theme/createTheme.cjs +27 -0
  130. package/theme/{createTheme.mjs.map → createTheme.cjs.map} +1 -1
  131. package/theme/createTheme.js +10 -12
  132. package/theme/createTheme.js.map +1 -1
  133. package/theme/{createThemeSwitcher.mjs → createThemeSwitcher.cjs} +8 -6
  134. package/theme/{createThemeSwitcher.mjs.map → createThemeSwitcher.cjs.map} +1 -1
  135. package/theme/createThemeSwitcher.js +5 -7
  136. package/theme/createThemeSwitcher.js.map +1 -1
  137. package/theme/index.cjs +15 -0
  138. package/theme/{index.mjs.map → index.cjs.map} +1 -1
  139. package/theme/index.js +6 -11
  140. package/theme/index.js.map +1 -1
  141. package/AppRoot/Renderar.mjs +0 -51
  142. package/AppRoot/Renderar.mjs.map +0 -1
  143. package/AppRoot/context.js.map +0 -1
  144. package/AppRoot/context.mjs.map +0 -1
  145. package/AppRoot/index.mjs +0 -118
  146. package/AppRoot/index.mjs.map +0 -1
  147. package/Document/index.mjs +0 -18
  148. package/Document/index.mjs.map +0 -1
  149. package/Iframe/index.mjs +0 -43
  150. package/Iframe/index.mjs.map +0 -1
  151. package/Tag/ServerStyleTag.mjs +0 -11
  152. package/Tag/cssPropList.mjs.map +0 -1
  153. package/Tag/index.mjs +0 -19
  154. package/Tag/useTagProps.mjs.map +0 -1
  155. package/Transition/index.mjs +0 -27
  156. package/breakpoint/BreakpointProvider.mjs +0 -40
  157. package/breakpoint/useBreakpoint.mjs +0 -22
  158. package/breakpoint/useBreakpointProps.mjs.map +0 -1
  159. package/css/aliases.mjs.map +0 -1
  160. package/css/index.mjs.map +0 -1
  161. package/hooks/useAnimation.mjs.map +0 -1
  162. package/hooks/useInterface.mjs +0 -17
  163. package/hooks/useInterface.mjs.map +0 -1
  164. package/hooks/usePortal.mjs +0 -68
  165. package/hooks/usePortal.mjs.map +0 -1
  166. package/hooks/useTransition/index.mjs.map +0 -1
  167. package/index.mjs +0 -25
  168. package/index.mjs.map +0 -1
  169. package/theme/ThemeProvider.mjs +0 -44
  170. package/theme/ThemeProvider.mjs.map +0 -1
  171. package/theme/core.mjs.map +0 -1
  172. package/theme/createTheme.mjs +0 -25
  173. package/theme/index.mjs +0 -10
  174. /package/AppRoot/{context.d.ts → AppRootProvider.d.ts} +0 -0
@@ -17,4 +17,4 @@ const useAppRootElement = () => {
17
17
 
18
18
  exports.AppRootProvider = AppRootProvider;
19
19
  exports.useAppRootElement = useAppRootElement;
20
- //# sourceMappingURL=context.js.map
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);\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;;;;;"}
@@ -14,4 +14,4 @@ const useAppRootElement = () => {
14
14
  };
15
15
 
16
16
  export { AppRootProvider, useAppRootElement };
17
- //# sourceMappingURL=context.mjs.map
17
+ //# sourceMappingURL=AppRootProvider.js.map
@@ -0,0 +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":["React","_jsx"],"mappings":";;;AAEA,MAAM,cAAc,GAAGA,cAAK,CAAC,aAAa,CAAqB,IAAI,CAAC;AAE7D,MAAM,eAAe,GAAyE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAI;AAC5H,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;AACA,IAAA,OAAO,OAAsB;AAChC;;;;"}
@@ -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 });\r\n}\r\n"],"names":["useDocument","useMemo","_jsx"],"mappings":";;;;;;AAQA,MAAM,KAAK,GAAG,IAAI,GAAG,EAAiC;AACtD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAwB;MAEnC,QAAQ,CAAA;AAElB,IAAA,OAAO,MAAM,CAAC,SAAk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C,GAAG,GAAG,GAAG;YAClB,QAAQ,CAAC,SAAS,CAAC;AACnB,YAAA,QAAQ,CAAC,GAAG,GAAG,IAAI;AACtB,QAAA,CAAC,CAAQ;QAET,QAAQ,CAAC,WAAW,IAAI,CAAC,SAAkC,EAAE,KAAU,KAAI;AACxE,YAAA,QAAQ,CAAC,GAAG,GAAG,GAAG;AAClB,YAAA,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC;AAC7B,YAAA,QAAQ,CAAC,GAAG,GAAG,IAAI;AACtB,QAAA,CAAC,CAAQ;AAEZ,IAAA,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEZ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACxB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,MAAK;YACvB,QAAQ,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,CAAC;AAC/B,QAAA,CAAC,CAAC;IACL;AACA,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE;AAE1C,IAAA,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,KAAK,KAAkB;AAC5E,QAAA,OAAOC,eAAC,SAAS,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAiB,KAAK,CAAA,EAAhB,KAAK,CAAe;AAC9C,IAAA,CAAC,CAAC;AACL;;;;;"}
@@ -1,6 +1,7 @@
1
1
  import React__default from 'react';
2
2
 
3
3
  declare class Renderar {
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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AAI,CAAC,SAAkC,KAAI;AACzD,YAAA,QAAQ,CAAC,GAAG,GAAG,GAAG;YAClB,QAAQ,CAAC,SAAS,CAAC;AACnB,YAAA,QAAQ,CAAC,GAAG,GAAG,IAAI;AACtB,QAAA,CAAC,CAAQ;QAET,QAAQ,CAAC,WAAW,IAAI,CAAC,SAAkC,EAAE,KAAU,KAAI;AACxE,YAAA,QAAQ,CAAC,GAAG,GAAG,GAAG;AAClB,YAAA,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC;AAC7B,YAAA,QAAQ,CAAC,GAAG,GAAG,IAAI;AACtB,QAAA,CAAC,CAAQ;AAEZ,IAAA,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEZ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACxB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,MAAK;YACvB,QAAQ,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,CAAC;AAC/B,QAAA,CAAC,CAAC;IACL;AACA,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE;AAE1C,IAAA,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,KAAK,KAAkB;AAC5E,QAAA,OAAOC,IAAC,SAAS,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAiB,KAAK,CAAA,EAAhB,KAAK,CAAe;AAC9C,IAAA,CAAC,CAAC;AACL;;;;"}
@@ -0,0 +1,43 @@
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 rootRef = React.useRef(null);
28
+ const mergeRef = useMergeRefs(rootRef, ref);
29
+ React.useEffect(() => {
30
+ setVisibility("visible");
31
+ // move oncss style tags to head
32
+ if (typeof _document === 'undefined')
33
+ return;
34
+ const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));
35
+ styles.forEach((style) => {
36
+ _document.head.appendChild(style);
37
+ });
38
+ }, []);
39
+ return (jsxRuntime.jsx(index.DocumentProvider, { document: _document, id: docid, 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, {})] }) })) }) }) }));
40
+ });
41
+
42
+ module.exports = AppRoot;
43
+ //# 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, 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 docid = useId()\r\n\r\n const csscacheId = useId()\r\n CSSCacheId ??= csscacheId\r\n\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} id={docid}>\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;AAEA;;AAIA;AACA;;;;;;;AAQG;AACA;AACG;AACH;;AAGH;AAuBH;;"}
@@ -5,9 +5,9 @@ import { ThemeProviderProps } from '../theme/ThemeProvider.js';
5
5
  type AppRootProps<T extends TagComponentType = "div"> = ThemeProviderProps<T> & {
6
6
  noScrollbarCss?: boolean;
7
7
  document?: Document;
8
+ CSSCacheId?: string;
8
9
  };
9
- declare const APP_ROOT_CLASSNAME = "xui-app-root";
10
10
  declare const AppRoot: React__default.ForwardRefExoticComponent<Omit<AppRootProps<TagComponentType>, "ref"> & React__default.RefAttributes<any>>;
11
11
 
12
- export { APP_ROOT_CLASSNAME, AppRoot as default };
12
+ export { AppRoot as default };
13
13
  export type { AppRootProps };
package/AppRoot/index.js CHANGED
@@ -1,111 +1,30 @@
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, 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
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var tslib = require('tslib');
7
- var jsxRuntime = require('react/jsx-runtime');
8
- var React = require('react');
9
- var index$1 = require('../theme/index.js');
10
- var BreakpointProvider = require('../breakpoint/BreakpointProvider.js');
11
- var index = require('../css/index.js');
12
- var Renderar = require('./Renderar.js');
13
- var ServerStyleTag = require('../Tag/ServerStyleTag.js');
14
- var index$2 = require('../Document/index.js');
15
- var context = require('./context.js');
16
- var useMergeRefs = require('../hooks/useMergeRefs.js');
17
- var ThemeProvider = require('../theme/ThemeProvider.js');
18
-
19
- const APP_ROOT_CLASSNAME = "xui-app-root";
20
- const AppRoot = React.forwardRef((_a, ref) => {
21
- var { children, noScrollbarCss, theme, document: _document } = _a, props = tslib.__rest(_a, ["children", "noScrollbarCss", "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"]);
22
19
  noScrollbarCss !== null && noScrollbarCss !== void 0 ? noScrollbarCss : (noScrollbarCss = false);
23
20
  _document !== null && _document !== void 0 ? _document : (_document = document);
24
- const [visibility, setVisibility] = React.useState("hidden");
25
- const rootRef = React.useRef(null);
21
+ const docid = useId();
22
+ const csscacheId = useId();
23
+ CSSCacheId !== null && CSSCacheId !== void 0 ? CSSCacheId : (CSSCacheId = csscacheId);
24
+ const [visibility, setVisibility] = React__default.useState("hidden");
25
+ const rootRef = useRef(null);
26
26
  const mergeRef = useMergeRefs(rootRef, ref);
27
- const scrollbarCss = React.useMemo(() => {
28
- if (noScrollbarCss)
29
- return;
30
- const cls = (cls) => `${index$1.themeRootClass(theme)} ${cls}`;
31
- let thumbSize = 6;
32
- let thumbColor = "var(--color-text-secondary)";
33
- let trackColor = "transparent";
34
- return index.css({
35
- "@global": {
36
- [cls('*::-webkit-scrollbar')]: {
37
- width: thumbSize,
38
- height: thumbSize,
39
- },
40
- [cls("*::-webkit-scrollbar-thumb")]: {
41
- backgroundColor: thumbColor,
42
- borderRadius: "6px",
43
- opacity: 0.6,
44
- },
45
- [cls("*::-webkit-scrollbar-thumb:hover")]: {
46
- backgroundColor: thumbColor,
47
- opacity: 0.0,
48
- },
49
- [cls("*::-webkit-scrollbar-track")]: {
50
- backgroundColor: trackColor,
51
- borderRadius: "6px",
52
- },
53
- }
54
- }, {
55
- injectStyle: typeof window !== 'undefined',
56
- container: _document,
57
- });
58
- }, [noScrollbarCss, theme]);
59
- const globalStyle = React.useMemo(() => {
60
- return index.css({
61
- "@global": {
62
- "*": {
63
- m: 0,
64
- p: 0,
65
- outline: "none",
66
- boxSizing: "border-box",
67
- verticalAlign: "baseline",
68
- },
69
- "html, body": {
70
- minHeight: "100%",
71
- "-webkit-font-smoothing": "antialiased",
72
- "-moz-osx-font-smoothing": "grayscale",
73
- },
74
- "img, picture, video, canvas, svg": {
75
- maxWidth: "100%",
76
- display: "block"
77
- },
78
- "input, button, textarea, select": {
79
- font: "inherit"
80
- },
81
- "table": {
82
- borderCollapse: "collapse",
83
- borderSpacing: 0,
84
- },
85
- "ol, ul": {
86
- listStyle: "none",
87
- padding: 0,
88
- margin: 0,
89
- },
90
- "a": {
91
- display: "inline-block",
92
- color: "inherit",
93
- textDecoration: "none",
94
- cursor: "pointer",
95
- "&:hover": {
96
- textDecoration: "underline"
97
- }
98
- },
99
- "p, h1, h2, h3, h4, h5, h6": {
100
- overflowWrap: "break-word",
101
- },
102
- }
103
- }, {
104
- injectStyle: typeof window !== 'undefined',
105
- container: _document,
106
- });
107
- }, []);
108
- React.useEffect(() => {
27
+ useEffect(() => {
109
28
  setVisibility("visible");
110
29
  // move oncss style tags to head
111
30
  if (typeof _document === 'undefined')
@@ -115,9 +34,8 @@ const AppRoot = React.forwardRef((_a, ref) => {
115
34
  _document.head.appendChild(style);
116
35
  });
117
36
  }, []);
118
- return (jsxRuntime.jsx(index$2.DocumentProvider, { document: _document, children: jsxRuntime.jsx(context.AppRootProvider, { element: rootRef.current, children: jsxRuntime.jsxs(ThemeProvider, Object.assign({ ref: mergeRef, theme: theme }, props, { sx: Object.assign(Object.assign({}, props.sx), (visibility === "hidden" ? { visibility: "hidden" } : {})), classNames: [APP_ROOT_CLASSNAME], children: [jsxRuntime.jsx(ServerStyleTag, { factory: globalStyle }), scrollbarCss && jsxRuntime.jsx(ServerStyleTag, { factory: scrollbarCss }), jsxRuntime.jsxs(BreakpointProvider.BreakpointProvider, { children: [children, jsxRuntime.jsx(Renderar.RenderRenderar, {})] })] })) }) }));
37
+ return (jsx(DocumentProvider, { document: _document, id: docid, children: jsx(CSSCacheProvider, { cacheId: CSSCacheId, children: jsx(AppRootProvider, { element: rootRef.current, children: jsx(ThemeProvider, Object.assign({ ref: mergeRef, theme: theme }, props, { isRoot: true, sx: Object.assign(Object.assign({}, props.sx), (visibility === "hidden" ? { visibility: "hidden" } : {})), children: jsxs(BreakpointProvider, { children: [children, jsx(RenderRenderar, {})] }) })) }) }) }));
119
38
  });
120
39
 
121
- exports.APP_ROOT_CLASSNAME = APP_ROOT_CLASSNAME;
122
- exports.default = AppRoot;
40
+ export { AppRoot as default };
123
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\r\nimport React, { useEffect, useMemo, useRef } from 'react';\r\nimport { TagComponentType } from '../Tag/types';\r\nimport { ThemeProvider, ThemeProviderProps, themeRootClass } from '../theme';\r\nimport { BreakpointProvider } from '../breakpoint';\r\nimport { css } from '../css';\r\nimport { RenderRenderar } from './Renderar';\r\nimport ServerStyleTag from '../Tag/ServerStyleTag';\r\nimport { DocumentProvider } from '../Document';\r\nimport { AppRootProvider } from './context';\r\nimport useMergeRefs from '../hooks/useMergeRefs';\r\n\r\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\r\n noScrollbarCss?: boolean;\r\n document?: Document;\r\n}\r\n\r\nexport const APP_ROOT_CLASSNAME = \"xui-app-root\"\r\n\r\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, noScrollbarCss, theme, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\r\n noScrollbarCss ??= false\r\n _document ??= document\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 const scrollbarCss: any = useMemo(() => {\r\n if (noScrollbarCss) return;\r\n const cls = (cls: string) => `${themeRootClass(theme)} ${cls}`\r\n let thumbSize = 6\r\n let thumbColor = \"var(--color-text-secondary)\"\r\n let trackColor = \"transparent\"\r\n\r\n return css({\r\n \"@global\": {\r\n [cls('*::-webkit-scrollbar')]: {\r\n width: thumbSize,\r\n height: thumbSize,\r\n },\r\n [cls(\"*::-webkit-scrollbar-thumb\")]: {\r\n backgroundColor: thumbColor,\r\n borderRadius: \"6px\",\r\n opacity: 0.6,\r\n },\r\n [cls(\"*::-webkit-scrollbar-thumb:hover\")]: {\r\n backgroundColor: thumbColor,\r\n opacity: 0.0,\r\n },\r\n [cls(\"*::-webkit-scrollbar-track\")]: {\r\n backgroundColor: trackColor,\r\n borderRadius: \"6px\",\r\n },\r\n }\r\n }, {\r\n injectStyle: typeof window !== 'undefined',\r\n container: _document,\r\n }) as any\r\n }, [noScrollbarCss, theme])\r\n\r\n const globalStyle = useMemo(() => {\r\n return css({\r\n \"@global\": {\r\n \"*\": {\r\n m: 0,\r\n p: 0,\r\n outline: \"none\",\r\n boxSizing: \"border-box\",\r\n verticalAlign: \"baseline\",\r\n },\r\n \"html, body\": {\r\n minHeight: \"100%\",\r\n \"-webkit-font-smoothing\": \"antialiased\",\r\n \"-moz-osx-font-smoothing\": \"grayscale\",\r\n } as any,\r\n \"img, picture, video, canvas, svg\": {\r\n maxWidth: \"100%\",\r\n display: \"block\"\r\n },\r\n \"input, button, textarea, select\": {\r\n font: \"inherit\"\r\n },\r\n \"table\": {\r\n borderCollapse: \"collapse\",\r\n borderSpacing: 0,\r\n },\r\n \"ol, ul\": {\r\n listStyle: \"none\",\r\n padding: 0,\r\n margin: 0,\r\n },\r\n \"a\": {\r\n display: \"inline-block\",\r\n color: \"inherit\",\r\n textDecoration: \"none\",\r\n cursor: \"pointer\",\r\n \"&:hover\": {\r\n textDecoration: \"underline\"\r\n }\r\n },\r\n \"p, h1, h2, h3, h4, h5, h6\": {\r\n overflowWrap: \"break-word\",\r\n },\r\n }\r\n }, {\r\n injectStyle: typeof window !== 'undefined',\r\n container: _document,\r\n })\r\n }, [])\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\r\n return (\r\n <DocumentProvider document={_document}>\r\n <AppRootProvider element={rootRef.current}>\r\n <ThemeProvider\r\n ref={mergeRef}\r\n theme={theme}\r\n {...props}\r\n sx={{\r\n ...props.sx,\r\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {})\r\n }}\r\n classNames={[APP_ROOT_CLASSNAME]}\r\n >\r\n <ServerStyleTag factory={globalStyle} />\r\n {\r\n scrollbarCss && <ServerStyleTag factory={scrollbarCss} />\r\n }\r\n <BreakpointProvider>\r\n {children}\r\n <RenderRenderar />\r\n </BreakpointProvider>\r\n </ThemeProvider>\r\n </AppRootProvider>\r\n </DocumentProvider>\r\n )\r\n})\r\n\r\nexport default AppRoot\r\n\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAiBO;AAEP;AAAsE;;;AAInE;AACA;;AAGA;AACG;;AACA;;;;AAKA;AACG;AACG;AACG;AACA;AACF;AACD;AACG;AACA;AACA;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACF;AACH;;AAED;AACA;AACF;AACJ;AAEA;AACG;AACG;AACG;AACG;AACA;AACA;AACA;AACA;AACF;AACD;AACG;AACA;AACA;AACK;AACR;AACG;AACA;AACF;AACD;AACG;AACF;AACD;AACG;AACA;AACF;AACD;AACG;AACA;AACA;AACF;AACD;AACG;AACA;AACA;AACA;AACA;AACG;AACF;AACH;AACD;AACG;AACF;AACH;;AAED;AACA;AACF;;;;;;;AAQD;AACA;AACG;AACH;;AAIH;AAyBH;;;"}
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 docid = useId()\r\n\r\n const csscacheId = useId()\r\n CSSCacheId ??= csscacheId\r\n\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} id={docid}>\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;AAEA;;AAIA;AACA;;;;;;;AAQG;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 return context as DocumentContextValue\r\n}"],"names":[],"mappings":";;;;;;AAMA;AAEO;AACJ;AAKH;AAEO;AACJ;AACA;AACG;;AAEH;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 return context as DocumentContextValue\r\n}"],"names":[],"mappings":";;;;AAMA;AAEO;AACJ;AAKH;AAEO;AACJ;AACA;AACG;;AAEH;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