@xyd-js/components 0.1.0-build.168

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 (314) hide show
  1. package/.idea/git_toolbox_blame.xml +6 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/.idea/xyd-components.iml +12 -0
  5. package/CHANGELOG.md +1369 -0
  6. package/LICENSE +21 -0
  7. package/README.md +3 -0
  8. package/TODO.md +1 -0
  9. package/coder.ts +1 -0
  10. package/content.ts +1 -0
  11. package/dist/Button-BLA2ghHZ.js +2 -0
  12. package/dist/Button-BLA2ghHZ.js.map +1 -0
  13. package/dist/Button-BTJ2hIal.js +2 -0
  14. package/dist/Button-BTJ2hIal.js.map +1 -0
  15. package/dist/Button-r4BCrEjy.js +2 -0
  16. package/dist/Button-r4BCrEjy.js.map +1 -0
  17. package/dist/CodeSample-BZ5tvyWY.js +2 -0
  18. package/dist/CodeSample-BZ5tvyWY.js.map +1 -0
  19. package/dist/CodeSample-BqXDbWdi.js +2 -0
  20. package/dist/CodeSample-BqXDbWdi.js.map +1 -0
  21. package/dist/CodeSample-Cqv86IdN.js +2 -0
  22. package/dist/CodeSample-Cqv86IdN.js.map +1 -0
  23. package/dist/Icon--77MqplU.js +2 -0
  24. package/dist/Icon--77MqplU.js.map +1 -0
  25. package/dist/Icon-DbNmvK_Q.js +2 -0
  26. package/dist/Icon-DbNmvK_Q.js.map +1 -0
  27. package/dist/Icon-uVIU1LW6.js +2 -0
  28. package/dist/Icon-uVIU1LW6.js.map +1 -0
  29. package/dist/PageFirstSlide-BDNmCTiJ.js +2 -0
  30. package/dist/PageFirstSlide-BDNmCTiJ.js.map +1 -0
  31. package/dist/PageFirstSlide-BpZ42bEU.js +2 -0
  32. package/dist/PageFirstSlide-BpZ42bEU.js.map +1 -0
  33. package/dist/PageFirstSlide-CqxiyK57.js +2 -0
  34. package/dist/PageFirstSlide-CqxiyK57.js.map +1 -0
  35. package/dist/TabsAnalytics-B_JYpawG.js +2 -0
  36. package/dist/TabsAnalytics-B_JYpawG.js.map +1 -0
  37. package/dist/TabsAnalytics-DAOfTZgv.js +2 -0
  38. package/dist/TabsAnalytics-DAOfTZgv.js.map +1 -0
  39. package/dist/TabsAnalytics-Dhyadlbu.js +2 -0
  40. package/dist/TabsAnalytics-Dhyadlbu.js.map +1 -0
  41. package/dist/Update-53fEhmjh.js +2 -0
  42. package/dist/Update-53fEhmjh.js.map +1 -0
  43. package/dist/Update-CFi6uapq.js +2 -0
  44. package/dist/Update-CFi6uapq.js.map +1 -0
  45. package/dist/Update-CiMIOgZi.js +2 -0
  46. package/dist/Update-CiMIOgZi.js.map +1 -0
  47. package/dist/VideoGuide-C0K9fFar.js +2 -0
  48. package/dist/VideoGuide-C0K9fFar.js.map +1 -0
  49. package/dist/VideoGuide-CJYkuLst.js +2 -0
  50. package/dist/VideoGuide-CJYkuLst.js.map +1 -0
  51. package/dist/VideoGuide-DBY-EyxG.js +2 -0
  52. package/dist/VideoGuide-DBY-EyxG.js.map +1 -0
  53. package/dist/_rollupPluginBabelHelpers-CvhQFv1t.js +4 -0
  54. package/dist/_rollupPluginBabelHelpers-CvhQFv1t.js.map +1 -0
  55. package/dist/_rollupPluginBabelHelpers-DSwDY1Dm.js +4 -0
  56. package/dist/_rollupPluginBabelHelpers-DSwDY1Dm.js.map +1 -0
  57. package/dist/_rollupPluginBabelHelpers-Dc-ocx4G.js +4 -0
  58. package/dist/_rollupPluginBabelHelpers-Dc-ocx4G.js.map +1 -0
  59. package/dist/coder/themes/classic.css +57 -0
  60. package/dist/coder/themes/classic.d.ts +96 -0
  61. package/dist/coder/themes/classic.js +2 -0
  62. package/dist/coder/themes/classic.js.map +1 -0
  63. package/dist/coder/themes/cosmo.css +64 -0
  64. package/dist/coder/themes/cosmo.d.ts +96 -0
  65. package/dist/coder/themes/cosmo.js +2 -0
  66. package/dist/coder/themes/cosmo.js.map +1 -0
  67. package/dist/coder.d.ts +94 -0
  68. package/dist/coder.js +2 -0
  69. package/dist/coder.js.map +1 -0
  70. package/dist/content.d.ts +411 -0
  71. package/dist/content.js +2 -0
  72. package/dist/content.js.map +1 -0
  73. package/dist/index.css +282 -0
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.js +2 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/layouts.d.ts +33 -0
  78. package/dist/layouts.js +2 -0
  79. package/dist/layouts.js.map +1 -0
  80. package/dist/pages.d.ts +176 -0
  81. package/dist/pages.js +2 -0
  82. package/dist/pages.js.map +1 -0
  83. package/dist/system.d.ts +45 -0
  84. package/dist/system.js +2 -0
  85. package/dist/system.js.map +1 -0
  86. package/dist/useUXClick-DK3cTAMR.js +2 -0
  87. package/dist/useUXClick-DK3cTAMR.js.map +1 -0
  88. package/dist/useUXClick-DO6qBcRy.js +2 -0
  89. package/dist/useUXClick-DO6qBcRy.js.map +1 -0
  90. package/dist/useUXClick-NwpsiuK9.js +2 -0
  91. package/dist/useUXClick-NwpsiuK9.js.map +1 -0
  92. package/dist/useUXEvents-CJtgGV4R.js +2 -0
  93. package/dist/useUXEvents-CJtgGV4R.js.map +1 -0
  94. package/dist/useUXEvents-Cxgl7xb-.js +2 -0
  95. package/dist/useUXEvents-Cxgl7xb-.js.map +1 -0
  96. package/dist/useUXEvents-XqAGxoEj.js +2 -0
  97. package/dist/useUXEvents-XqAGxoEj.js.map +1 -0
  98. package/dist/useUXScrollDepth-3rk3Z95r.js +2 -0
  99. package/dist/useUXScrollDepth-3rk3Z95r.js.map +1 -0
  100. package/dist/useUXScrollDepth-BwK-XOBg.js +2 -0
  101. package/dist/useUXScrollDepth-BwK-XOBg.js.map +1 -0
  102. package/dist/useUXScrollDepth-DKre7PBz.js +2 -0
  103. package/dist/useUXScrollDepth-DKre7PBz.js.map +1 -0
  104. package/dist/uxsdk.d.ts +53 -0
  105. package/dist/uxsdk.js +2 -0
  106. package/dist/uxsdk.js.map +1 -0
  107. package/dist/views.d.ts +18 -0
  108. package/dist/views.js +2 -0
  109. package/dist/views.js.map +1 -0
  110. package/dist/writer.d.ts +580 -0
  111. package/dist/writer.js +2 -0
  112. package/dist/writer.js.map +1 -0
  113. package/docs/.nojekyll +1 -0
  114. package/docs/assets/hierarchy.js +1 -0
  115. package/docs/assets/highlight.css +22 -0
  116. package/docs/assets/icons.js +18 -0
  117. package/docs/assets/icons.svg +1 -0
  118. package/docs/assets/main.js +60 -0
  119. package/docs/assets/navigation.js +1 -0
  120. package/docs/assets/search.js +1 -0
  121. package/docs/assets/style.css +1640 -0
  122. package/docs/functions/GuideCard.html +6 -0
  123. package/docs/hierarchy.html +1 -0
  124. package/docs/index.html +2 -0
  125. package/docs/interfaces/GuideCardProps.html +18 -0
  126. package/docs/modules.html +1 -0
  127. package/index.ts +0 -0
  128. package/layouts.ts +1 -0
  129. package/output.txt +13 -0
  130. package/package.json +81 -0
  131. package/pages.ts +1 -0
  132. package/postcss.config.cjs +5 -0
  133. package/rollup.config.js +195 -0
  134. package/src/coder/Code/Code.styles.tsx +151 -0
  135. package/src/coder/Code/Code.tsx +171 -0
  136. package/src/coder/Code/CodeLoader.tsx +10 -0
  137. package/src/coder/Code/annotations.tsx +51 -0
  138. package/src/coder/Code/highlight.ts +208 -0
  139. package/src/coder/Code/index.ts +16 -0
  140. package/src/coder/CodeCopy/CodeCopy.styles.tsx +21 -0
  141. package/src/coder/CodeCopy/CodeCopy.tsx +36 -0
  142. package/src/coder/CodeCopy/index.ts +7 -0
  143. package/src/coder/CodeSample/CodeSample.tsx +118 -0
  144. package/src/coder/CodeSample/CodeSampleAnalytics.tsx +112 -0
  145. package/src/coder/CodeSample/index.ts +11 -0
  146. package/src/coder/CodeSample/withLocalStored.tsx +50 -0
  147. package/src/coder/CodeTabs/CodeTabs.styles.tsx +126 -0
  148. package/src/coder/CodeTabs/CodeTabs.tsx +128 -0
  149. package/src/coder/CodeTabs/index.ts +6 -0
  150. package/src/coder/CodeTheme/CodeTheme.tsx +126 -0
  151. package/src/coder/CodeTheme/index.ts +7 -0
  152. package/src/coder/CoderProvider.tsx +26 -0
  153. package/src/coder/README.md +1 -0
  154. package/src/coder/hooks/highlight.ts +182 -0
  155. package/src/coder/index.ts +37 -0
  156. package/src/coder/themes/classic.css +57 -0
  157. package/src/coder/themes/classic.ts +270 -0
  158. package/src/coder/themes/cosmo.css +64 -0
  159. package/src/coder/themes/cosmo.ts +264 -0
  160. package/src/content/AppearanceDecorator.styles.tsx +11 -0
  161. package/src/content/ContentDecoator.styles.tsx +180 -0
  162. package/src/content/ContentDecorator.tsx +17 -0
  163. package/src/content/GridDecorator.styles.tsx +86 -0
  164. package/src/content/GridDecorator.tsx +23 -0
  165. package/src/content/ReactContent.tsx +671 -0
  166. package/src/content/TODO.md +1 -0
  167. package/src/content/index.ts +13 -0
  168. package/src/kit/Loader/Loader.styles.tsx +53 -0
  169. package/src/kit/Loader/Loader.tsx +22 -0
  170. package/src/kit/TODO.md +2 -0
  171. package/src/kit/index.ts +1 -0
  172. package/src/layouts/LayoutPrimary/LayoutPrimary.styles.tsx +325 -0
  173. package/src/layouts/LayoutPrimary/LayoutPrimary.tsx +252 -0
  174. package/src/layouts/LayoutPrimary/index.ts +3 -0
  175. package/src/layouts/index.ts +6 -0
  176. package/src/pages/PageBlogHome/PageBlogHome.styles.tsx +67 -0
  177. package/src/pages/PageBlogHome/PageBlogHome.tsx +64 -0
  178. package/src/pages/PageBlogHome/index.ts +3 -0
  179. package/src/pages/PageBlogHome/types.ts +35 -0
  180. package/src/pages/PageBlogPost/PageBlogPost.styles.tsx +4 -0
  181. package/src/pages/PageBlogPost/PageBlogPost.tsx +9 -0
  182. package/src/pages/PageBlogPost/index.ts +3 -0
  183. package/src/pages/PageFirstSlide/PageFirstSlide.styles.tsx +134 -0
  184. package/src/pages/PageFirstSlide/PageFirstSlide.tsx +56 -0
  185. package/src/pages/PageFirstSlide/index.ts +1 -0
  186. package/src/pages/PageFirstSlide/types.ts +67 -0
  187. package/src/pages/PageHome/PageHome.styles.tsx +51 -0
  188. package/src/pages/PageHome/PageHome.tsx +62 -0
  189. package/src/pages/PageHome/index.ts +3 -0
  190. package/src/pages/PageHome/types.ts +79 -0
  191. package/src/pages/index.ts +7 -0
  192. package/src/system/Baseline/Baseline.styles.tsx +128 -0
  193. package/src/system/Baseline/Baseline.tsx +40 -0
  194. package/src/system/Baseline/bun.svg +1 -0
  195. package/src/system/Baseline/check.svg +1 -0
  196. package/src/system/Baseline/index.ts +1 -0
  197. package/src/system/Baseline/logo.svg +1 -0
  198. package/src/system/Baseline/node.svg +7 -0
  199. package/src/system/Baseline/npm.svg +5 -0
  200. package/src/system/Baseline/pnpm.svg +1 -0
  201. package/src/system/Footer/Footer.styles.tsx +213 -0
  202. package/src/system/Footer/Footer.tsx +105 -0
  203. package/src/system/Footer/index.ts +1 -0
  204. package/src/system/SearchButton/SearchButton.styles.tsx +89 -0
  205. package/src/system/SearchButton/SearchButton.tsx +118 -0
  206. package/src/system/SearchButton/index.ts +1 -0
  207. package/src/system/index.ts +3 -0
  208. package/src/utils/useStyle.ts +19 -0
  209. package/src/uxsdk/const.ts +1 -0
  210. package/src/uxsdk/index.ts +21 -0
  211. package/src/uxsdk/useUXClick.ts +21 -0
  212. package/src/uxsdk/useUXEvents.ts +105 -0
  213. package/src/uxsdk/useUXScrollDepth.ts +49 -0
  214. package/src/uxsdk/useUXUnreachableElementTracker.ts +100 -0
  215. package/src/views/HomeView/HomeView.styles.tsx +37 -0
  216. package/src/views/HomeView/HomeView.tsx +34 -0
  217. package/src/views/HomeView/index.ts +3 -0
  218. package/src/writer/Anchor/Anchor.styles.tsx +26 -0
  219. package/src/writer/Anchor/Anchor.tsx +51 -0
  220. package/src/writer/Anchor/index.tsx +1 -0
  221. package/src/writer/Badge/Badge.styles.tsx +44 -0
  222. package/src/writer/Badge/Badge.tsx +47 -0
  223. package/src/writer/Badge/index.ts +7 -0
  224. package/src/writer/Banner/Banner.styles.tsx +111 -0
  225. package/src/writer/Banner/Banner.tsx +151 -0
  226. package/src/writer/Banner/index.ts +1 -0
  227. package/src/writer/Blockquote/Blockquote.styles.tsx +20 -0
  228. package/src/writer/Blockquote/Blockquote.tsx +38 -0
  229. package/src/writer/Blockquote/index.ts +7 -0
  230. package/src/writer/BlogCard/BlogCard.styles.tsx +4 -0
  231. package/src/writer/BlogCard/BlogCard.tsx +9 -0
  232. package/src/writer/BlogCard/index.ts +3 -0
  233. package/src/writer/Breadcrumbs/Breadcrumbs.styles.ts +24 -0
  234. package/src/writer/Breadcrumbs/Breadcrumbs.tsx +57 -0
  235. package/src/writer/Breadcrumbs/index.ts +7 -0
  236. package/src/writer/Button/Button.styles.tsx +149 -0
  237. package/src/writer/Button/Button.tsx +82 -0
  238. package/src/writer/Button/index.ts +2 -0
  239. package/src/writer/Callout/Callout.styles.tsx +102 -0
  240. package/src/writer/Callout/Callout.tsx +166 -0
  241. package/src/writer/Callout/index.tsx +3 -0
  242. package/src/writer/Card/Card.styles.tsx +110 -0
  243. package/src/writer/Card/Card.tsx +94 -0
  244. package/src/writer/Card/index.ts +1 -0
  245. package/src/writer/Code/Code.styles.tsx +16 -0
  246. package/src/writer/Code/Code.tsx +16 -0
  247. package/src/writer/Code/index.ts +3 -0
  248. package/src/writer/ColorSchemeButton/ColorSchemeButton.tsx +191 -0
  249. package/src/writer/ColorSchemeButton/index.ts +1 -0
  250. package/src/writer/Details/Details.styles.tsx +101 -0
  251. package/src/writer/Details/Details.tsx +168 -0
  252. package/src/writer/Details/DetailsProps.tsx +34 -0
  253. package/src/writer/Details/index.ts +6 -0
  254. package/src/writer/GuideCard/GuideCard.styles.tsx +129 -0
  255. package/src/writer/GuideCard/GuideCard.tsx +123 -0
  256. package/src/writer/GuideCard/index.ts +1 -0
  257. package/src/writer/Heading/Heading.styles.tsx +93 -0
  258. package/src/writer/Heading/Heading.tsx +123 -0
  259. package/src/writer/Heading/index.ts +7 -0
  260. package/src/writer/Hr/Hr.styles.tsx +7 -0
  261. package/src/writer/Hr/Hr.tsx +10 -0
  262. package/src/writer/Hr/index.ts +3 -0
  263. package/src/writer/Icon/Icon.styles.tsx +15 -0
  264. package/src/writer/Icon/Icon.tsx +99 -0
  265. package/src/writer/Icon/index.ts +1 -0
  266. package/src/writer/IconSocial/IconSocial.tsx +107 -0
  267. package/src/writer/IconSocial/index.ts +1 -0
  268. package/src/writer/Image/Image.styles.tsx +9 -0
  269. package/src/writer/Image/Image.tsx +35 -0
  270. package/src/writer/Image/index.ts +1 -0
  271. package/src/writer/List/List.styles.tsx +47 -0
  272. package/src/writer/List/List.tsx +29 -0
  273. package/src/writer/List/index.ts +4 -0
  274. package/src/writer/NavLinks/NavLinks.styles.ts +32 -0
  275. package/src/writer/NavLinks/NavLinks.tsx +95 -0
  276. package/src/writer/NavLinks/index.ts +7 -0
  277. package/src/writer/Pre/Pre.styles.tsx +13 -0
  278. package/src/writer/Pre/Pre.tsx +14 -0
  279. package/src/writer/Pre/index.ts +3 -0
  280. package/src/writer/README.md +1 -0
  281. package/src/writer/Steps/Steps.styles.tsx +91 -0
  282. package/src/writer/Steps/Steps.tsx +75 -0
  283. package/src/writer/Steps/index.ts +5 -0
  284. package/src/writer/Table/Table.styles.tsx +100 -0
  285. package/src/writer/Table/Table.tsx +158 -0
  286. package/src/writer/Table/index.ts +3 -0
  287. package/src/writer/Tabs/Tabs.tsx +67 -0
  288. package/src/writer/Tabs/TabsAnalytics.tsx +25 -0
  289. package/src/writer/Tabs/TabsPrimary.styles.tsx +187 -0
  290. package/src/writer/Tabs/TabsPrimary.tsx +215 -0
  291. package/src/writer/Tabs/TabsProps.tsx +13 -0
  292. package/src/writer/Tabs/TabsSecondary.styles.tsx +78 -0
  293. package/src/writer/Tabs/TabsSecondary.tsx +176 -0
  294. package/src/writer/Tabs/index.ts +2 -0
  295. package/src/writer/Tabs/useValueChange.ts +84 -0
  296. package/src/writer/Text/Text.styles.tsx +66 -0
  297. package/src/writer/Text/Text.tsx +79 -0
  298. package/src/writer/Text/index.ts +3 -0
  299. package/src/writer/TocCard/TocCard.module.css +44 -0
  300. package/src/writer/TocCard/TocCard.tsx +42 -0
  301. package/src/writer/TocCard/index.ts +3 -0
  302. package/src/writer/Update/Update.styles.tsx +33 -0
  303. package/src/writer/Update/Update.tsx +37 -0
  304. package/src/writer/Update/index.ts +1 -0
  305. package/src/writer/VideoGuide/VideoGuide.module.css +105 -0
  306. package/src/writer/VideoGuide/VideoGuide.tsx +75 -0
  307. package/src/writer/VideoGuide/index.ts +1 -0
  308. package/src/writer/index.ts +53 -0
  309. package/system.ts +1 -0
  310. package/tsconfig.json +46 -0
  311. package/types.d.ts +52 -0
  312. package/uxsdk.ts +1 -0
  313. package/views.ts +2 -0
  314. package/writer.ts +1 -0
@@ -0,0 +1,118 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+
3
+ import * as cn from "./SearchButton.styles";
4
+
5
+ interface SearchButtonProps {
6
+ onClick?: () => void;
7
+ placeholder?: string;
8
+ shortcutKeys?: string[];
9
+ fullWidth?: boolean;
10
+ }
11
+
12
+ export function SearchButton({
13
+ shortcutKeys = ['⌘', 'K'],
14
+ ...props
15
+ }: SearchButtonProps) {
16
+ useShortcuts(shortcutKeys, () => props.onClick?.());
17
+
18
+ useEffect(() => {
19
+ // @ts-ignore - !!! FIX IN THE FUTURE !!! its a fix for loading virtual-component:Search twice? original and from plugin - check if exists on prod
20
+ window.__UNSAFE_xyd_search_button_inited = true
21
+
22
+ return () => {
23
+ // @ts-ignore
24
+ window.__UNSAFE_xyd_search_button_inited = false
25
+ }
26
+ }, [])
27
+
28
+ return (
29
+ <xyd-search-button
30
+ className={cn.SearchButton}
31
+ aria-label="Search"
32
+ onClick={props.onClick}
33
+ data-fullWidth={props.fullWidth}
34
+ >
35
+ <span part="container">
36
+ <svg
37
+ width={20}
38
+ height={20}
39
+ part="icon"
40
+ viewBox="0 0 20 20"
41
+ >
42
+ <path
43
+ d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z"
44
+ stroke="currentColor"
45
+ fill="none"
46
+ fillRule="evenodd"
47
+ strokeLinecap="round"
48
+ strokeLinejoin="round"
49
+ />
50
+ </svg>
51
+ <span part="placeholder">{props.placeholder || "Search"}</span>
52
+ </span>
53
+
54
+ {
55
+ shortcutKeys.length > 0 && (
56
+ <span part="keys">
57
+ {shortcutKeys.map((key, index) => (
58
+ <kbd key={`${key}-${index}`} part="key">{key}</kbd>
59
+ ))}
60
+ </span>
61
+ )
62
+ }
63
+ </xyd-search-button>
64
+ )
65
+ }
66
+
67
+ function useShortcuts(shortcutKeys: string[], onTrigger: () => void): void {
68
+ // Keep latest handler reference to avoid stale closures
69
+ const savedHandler = useRef(onTrigger);
70
+
71
+ useEffect(() => {
72
+ savedHandler.current = onTrigger;
73
+ }, [onTrigger]);
74
+
75
+ useEffect(() => {
76
+ // @ts-ignore
77
+ if (window.__UNSAFE_xyd_search_button_inited) {
78
+ return
79
+ }
80
+
81
+ const listener = (event: KeyboardEvent) => {
82
+ // For single key shortcuts
83
+ if (shortcutKeys.length === 1) {
84
+ if (event.key.toLowerCase() === shortcutKeys[0].toLowerCase()) {
85
+ event.preventDefault();
86
+
87
+ savedHandler.current();
88
+ }
89
+ return;
90
+ }
91
+
92
+ // For modifier combinations
93
+ if (shortcutKeys.length === 2) {
94
+ const [modifier, key] = shortcutKeys;
95
+ const pressedKey = event.key.toLowerCase();
96
+
97
+ const isModifierMatch =
98
+ (modifier === '⌘' && event.metaKey) ||
99
+ (modifier === 'Ctrl' && event.ctrlKey);
100
+
101
+ if (isModifierMatch && pressedKey === key.toLowerCase()) {
102
+ event.preventDefault();
103
+
104
+ savedHandler.current();
105
+ }
106
+ }
107
+ };
108
+
109
+ // Use capture phase and listen to both keydown and keyup
110
+ window.addEventListener('keydown', listener, { capture: true });
111
+ window.addEventListener('keyup', listener, { capture: true });
112
+
113
+ return () => {
114
+ window.removeEventListener('keydown', listener, { capture: true });
115
+ window.removeEventListener('keyup', listener, { capture: true });
116
+ };
117
+ }, []);
118
+ }
@@ -0,0 +1 @@
1
+ export { SearchButton } from "./SearchButton";
@@ -0,0 +1,3 @@
1
+ export { Baseline } from "./Baseline";
2
+ export { Footer } from "./Footer";
3
+ export { SearchButton } from "./SearchButton";
@@ -0,0 +1,19 @@
1
+ import {css} from '@linaria/core';
2
+
3
+ type StyleObject = Record<string, string>;
4
+ type StyleFunction = (strings: TemplateStringsArray, ...values: any[]) => string;
5
+
6
+ export function useStyle<T extends StyleObject>(component: { styles: T }) {
7
+ const styled = {} as Record<keyof T, StyleFunction>;
8
+
9
+ for (const key of Object.keys(component.styles)) {
10
+ styled[key as keyof T] = (strings: TemplateStringsArray, ...values: any[]) => {
11
+ const customStyles = css`
12
+ ${strings.reduce((result, str, i) => result + str + (values[i] || ''), '')}
13
+ `;
14
+ return `${component.styles[key]} ${customStyles}`;
15
+ };
16
+ }
17
+
18
+ return styled;
19
+ }
@@ -0,0 +1 @@
1
+ export const EVENT_COMPONENT_TAB_CHANGE = "components.tabs.change"
@@ -0,0 +1,21 @@
1
+ // TODO: move to uxsdk?
2
+
3
+ export {
4
+ EVENT_COMPONENT_TAB_CHANGE
5
+ } from "./const";
6
+
7
+ export {
8
+ useUXClick,
9
+ } from "./useUXClick";
10
+
11
+ export {
12
+ useUXScrollDepth,
13
+ } from "./useUXScrollDepth";
14
+
15
+ export {
16
+ useUXEvents,
17
+ } from "./useUXEvents";
18
+
19
+ export {
20
+ useUXUnreachableElementTracker,
21
+ } from "./useUXUnreachableElementTracker";
@@ -0,0 +1,21 @@
1
+ import React, {useState} from "react";
2
+
3
+ export function useUXClick(
4
+ openEvent: (data: any) => void,
5
+ closeEvent: (data: any) => void,
6
+ getData: () => any
7
+ ) {
8
+ const [open, setOpen] = useState(false);
9
+
10
+ return (event: React.MouseEvent) => {
11
+ const newOpen = !open;
12
+ setOpen(newOpen);
13
+
14
+ const data = getData();
15
+ if (newOpen) {
16
+ openEvent(data);
17
+ } else {
18
+ closeEvent(data);
19
+ }
20
+ };
21
+ }
@@ -0,0 +1,105 @@
1
+ import {defineEvents} from 'openux-js'
2
+
3
+ interface NodeCodeSample {
4
+ tab?: string
5
+ example?: string
6
+ code?: string
7
+ }
8
+
9
+ interface NodeFramework {
10
+ location: string
11
+ uniformRegion?: string
12
+ }
13
+
14
+ interface AnalyticsNodes {
15
+ CodeSample: NodeCodeSample
16
+ Framework: NodeFramework
17
+ }
18
+
19
+ // TODO: in the future + maybe better API
20
+ // TODO: how to share nodes between packages
21
+ // TODO: node abstraction?
22
+ // TODO: merge abstraction?
23
+ export const useUXEvents = defineEvents(({CodeSample, Framework}: AnalyticsNodes) => ({
24
+ docs: {
25
+ code: {
26
+ example_change({example}: { example: string }) {
27
+ return {
28
+ ...commonFrameworkProps({Framework}),
29
+ example: example,
30
+ }
31
+ },
32
+ tab_change({tab}: { tab: string }) {
33
+ return {
34
+ ...commonCodeSampleProps({CodeSample, Framework}),
35
+ tab: tab,
36
+ }
37
+ },
38
+ copy({code}: { code: string }) {
39
+ return {
40
+ ...commonCodeSampleProps({CodeSample, Framework}),
41
+ code: (code || "").slice(0, 100) + "...",
42
+ }
43
+ },
44
+ scroll_100() {
45
+ return {
46
+ ...commonCodeSampleProps({CodeSample, Framework}),
47
+ }
48
+ },
49
+ scroll_depth({depth}: { depth: number }) {
50
+ return {
51
+ ...commonCodeSampleProps({CodeSample, Framework}),
52
+ depth,
53
+ }
54
+ },
55
+ },
56
+
57
+ details: {
58
+ open({label}: { label: string }) {
59
+ return {
60
+ ...commonFrameworkProps({Framework}),
61
+ label: label,
62
+ }
63
+ },
64
+ close({label}: { label: string }) {
65
+ return {
66
+ ...commonFrameworkProps({Framework}),
67
+ label: label,
68
+ }
69
+ }
70
+ },
71
+
72
+ anchor: {
73
+ click({id}: { id: string }) {
74
+ return {
75
+ ...commonFrameworkProps({Framework}),
76
+ id: id,
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }))
82
+
83
+ function commonCodeSampleProps({
84
+ CodeSample,
85
+ Framework
86
+ }: {
87
+ CodeSample: NodeCodeSample | undefined
88
+ Framework: NodeFramework | undefined
89
+ }) {
90
+ return {
91
+ ...commonFrameworkProps({Framework}),
92
+ tab: CodeSample?.tab!,
93
+ example: CodeSample?.example!,
94
+ }
95
+ }
96
+
97
+ function commonFrameworkProps({
98
+ Framework
99
+ }: {
100
+ Framework: NodeFramework | undefined
101
+ }) {
102
+ return {
103
+ location: Framework?.location!,
104
+ }
105
+ }
@@ -0,0 +1,49 @@
1
+ import React, {useEffect, useRef} from "react";
2
+
3
+ export interface ScrollDepthOptions {
4
+ thresholds?: number[]; // Default: [25, 50, 75, 100]
5
+ onDepthReached?: (depth: number) => void;
6
+ }
7
+
8
+ export function useUXScrollDepth(
9
+ ref: React.RefObject<HTMLElement | null>,
10
+ options: ScrollDepthOptions = {}
11
+ ) {
12
+ const { thresholds = [25, 50, 75, 100], onDepthReached } = options;
13
+ const reachedDepthsRef = useRef<Set<number>>(new Set());
14
+
15
+ useEffect(() => {
16
+ if (!ref.current) {
17
+ return
18
+ }
19
+
20
+ function handleScroll() {
21
+ const element = ref.current;
22
+ if (!element) return;
23
+
24
+ const { scrollTop, scrollHeight, clientHeight } = element;
25
+
26
+ // Calculate current scroll percentage
27
+ const scrollableHeight = scrollHeight - clientHeight;
28
+ if (scrollableHeight <= 0) return;
29
+
30
+ const scrollPercentage = Math.round((scrollTop / scrollableHeight) * 100);
31
+
32
+ // Check which thresholds have been reached
33
+ thresholds.forEach(threshold => {
34
+ if (scrollPercentage >= threshold && !reachedDepthsRef.current.has(threshold)) {
35
+ reachedDepthsRef.current.add(threshold);
36
+ onDepthReached?.(threshold);
37
+ }
38
+ });
39
+ }
40
+
41
+ const element = ref.current;
42
+ element.addEventListener('scroll', handleScroll);
43
+
44
+ return () => {
45
+ element.removeEventListener('scroll', handleScroll);
46
+ };
47
+ }, [ref.current, thresholds, onDepthReached]);
48
+ }
49
+
@@ -0,0 +1,100 @@
1
+ import { useEffect, useRef, useCallback } from "react"
2
+
3
+ /**
4
+ * TODO: not ideal solution cuz sometimes has a bug but currently its enough
5
+ *
6
+ * This hook is used to track the hover and click events of an unreachable element.
7
+ */
8
+ export function useUXUnreachableElementTracker(
9
+ element: React.RefObject<HTMLElement | null>,
10
+ hoverCb: () => void,
11
+ clickCb: () => void
12
+ ) {
13
+ const hover = useRef(false)
14
+ const click = useRef(false)
15
+ const mouseLeaveTimeout = useRef<number | null>(null)
16
+
17
+ const lastHoverTime = useRef(0)
18
+ const DEBOUNCE_DELAY = 1000 // 1 second debounce
19
+ const MOUSE_LEAVE_DELAY = 50 // 50ms delay to allow visibilitychange to fire first
20
+
21
+ const handleMouseEnter = useCallback(() => {
22
+ const now = Date.now()
23
+ if (now - lastHoverTime.current > DEBOUNCE_DELAY) {
24
+ hover.current = true
25
+ lastHoverTime.current = now
26
+ hoverCb()
27
+ }
28
+ }, [hoverCb])
29
+
30
+ const handleMouseLeave = useCallback(() => {
31
+ // console.log("mouse leave")
32
+ // Clear any existing timeout
33
+ if (mouseLeaveTimeout.current) {
34
+ clearTimeout(mouseLeaveTimeout.current)
35
+ }
36
+
37
+ // Delay setting hover to false to allow visibilitychange to fire first
38
+ mouseLeaveTimeout.current = setTimeout(() => {
39
+ hover.current = false
40
+ mouseLeaveTimeout.current = null
41
+ }, MOUSE_LEAVE_DELAY)
42
+ }, [])
43
+
44
+ useEffect(() => {
45
+ if (!element.current) {
46
+ return
47
+ }
48
+
49
+ element.current.addEventListener("mouseenter", handleMouseEnter)
50
+ element.current.addEventListener("mouseleave", handleMouseLeave)
51
+
52
+ return () => {
53
+ if (element.current) {
54
+ element.current.removeEventListener("mouseenter", handleMouseEnter)
55
+ element.current.removeEventListener("mouseleave", handleMouseLeave)
56
+ }
57
+ // Clean up timeout on unmount
58
+ if (mouseLeaveTimeout.current) {
59
+ clearTimeout(mouseLeaveTimeout.current)
60
+ }
61
+ }
62
+
63
+ }, [element.current, handleMouseEnter, handleMouseLeave])
64
+
65
+ // detect visibility loss (e.g. new tab opened)
66
+ const handleVisibilityChange = useCallback(() => {
67
+ // Clear the mouseleave timeout since visibility change indicates a click
68
+ if (mouseLeaveTimeout.current) {
69
+ clearTimeout(mouseLeaveTimeout.current)
70
+ mouseLeaveTimeout.current = null
71
+ }
72
+
73
+ click.current = false
74
+ // console.log(hover, 7777)
75
+ if (hover.current) {
76
+ hover.current = false
77
+ click.current = true
78
+ clickCb()
79
+ }
80
+ }, [clickCb])
81
+
82
+ useEffect(() => {
83
+ // function handleBeforeUnload() {
84
+ // console.log(hover.current)
85
+ // console.log(111)
86
+ // }
87
+
88
+ // window.addEventListener('beforeunload', handleBeforeUnload);
89
+ document.addEventListener('visibilitychange', handleVisibilityChange);
90
+
91
+ return () => {
92
+ // window.removeEventListener('beforeunload', handleBeforeUnload)
93
+ document.removeEventListener('visibilitychange', handleVisibilityChange)
94
+ // Clean up timeout on unmount
95
+ if (mouseLeaveTimeout.current) {
96
+ clearTimeout(mouseLeaveTimeout.current)
97
+ }
98
+ }
99
+ }, [handleVisibilityChange]) // Add handleVisibilityChange back to dependencies since it's now memoized
100
+ }
@@ -0,0 +1,37 @@
1
+ import {css} from "@linaria/core";
2
+
3
+ export const HomeViewHost = css`
4
+ display: flex;
5
+ flex-direction: column;
6
+ min-height: 100vh;
7
+ `;
8
+
9
+ export const HomeViewBodyHost = css`
10
+ background: radial-gradient(circle, hsl(0 0% 9% / .3) 1px, transparent 1px);
11
+ backdrop-filter: sepia(10%);
12
+ background-size: 30px 30px;
13
+ padding: 60px;
14
+ flex: 1;
15
+ `;
16
+
17
+ export const HomeViewBodyHostSecondary = css`
18
+ background: repeating-linear-gradient(to right, hsl(0 0% 9% / .1), hsl(0 0% 9% / .1) 1px, transparent 1px, transparent 50px), repeating-linear-gradient(to bottom, hsl(0 0% 9% / .1), hsl(0 0% 9% / .1) 1px, transparent 1px, transparent 50px);
19
+ `;
20
+
21
+ export const HomeViewBodyContent = css`
22
+ width: 1200px;
23
+ margin: 0 auto;
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: 80px;
27
+
28
+ @media (max-width: 1200px) {
29
+ width: 100%;
30
+ padding: 0 20px;
31
+ }
32
+
33
+ @media (max-width: 768px) {
34
+ width: 100%;
35
+ padding: 0 10px;
36
+ }
37
+ `;
@@ -0,0 +1,34 @@
1
+ import React from "react"
2
+ import * as cn from "./HomeView.styles";
3
+
4
+ export interface HomeViewProps {
5
+ header: React.ReactNode
6
+ body: React.ReactNode
7
+ footer: React.ReactNode
8
+ }
9
+
10
+ export function HomeView({header, body, footer}: HomeViewProps) {
11
+ return <div className={cn.HomeViewHost}>
12
+ {header}
13
+ {body}
14
+ {footer}
15
+ </div>
16
+ }
17
+
18
+ export interface HomeViewBodyProps {
19
+ children: React.ReactNode
20
+ kind?: "secondary"
21
+ }
22
+
23
+ HomeView.Body = function HomeViewBody({children, kind}: HomeViewBodyProps) {
24
+ return <div className={`
25
+ ${cn.HomeViewBodyHost}
26
+ ${kind === "secondary" ? cn.HomeViewBodyHostSecondary : ""}
27
+ `}>
28
+ <div className={cn.HomeViewBodyContent}>
29
+ {children}
30
+ </div>
31
+ </div>
32
+ }
33
+
34
+
@@ -0,0 +1,3 @@
1
+ export type {HomeViewProps, HomeViewBodyProps} from "./HomeView";
2
+
3
+ export {HomeView} from "./HomeView";
@@ -0,0 +1,26 @@
1
+ import {css} from "@linaria/core";
2
+
3
+ export const AnchorHost = css`
4
+ @layer defaults {
5
+ &:has(code) {
6
+ --xyd-anchor-color: var(--color-text);
7
+ --xyd-anchor-color--hover: var(--color-text);
8
+
9
+ code {
10
+ text-decoration: underline;
11
+ }
12
+
13
+ &:hover {
14
+ code {
15
+ text-decoration-thickness: 2px;
16
+ }
17
+ }
18
+ }
19
+
20
+ color: var(--xyd-anchor-color);
21
+
22
+ &:hover {
23
+ color: var(--xyd-anchor-color--hover);
24
+ }
25
+ }
26
+ `;
@@ -0,0 +1,51 @@
1
+ import React, { forwardRef } from 'react'
2
+ import type { ComponentProps, ReactElement } from 'react'
3
+
4
+ import * as cn from "./Anchor.styles";
5
+
6
+ export type AnchorProps = Omit<ComponentProps<'a'>, 'ref'> & {
7
+ newWindow?: boolean
8
+ as?: React.ElementType
9
+ }
10
+
11
+ export const Anchor = forwardRef<HTMLAnchorElement, AnchorProps>(function (
12
+ { href = '', children, newWindow, as, ...props },
13
+ // ref is used in <NavbarMenu />
14
+ forwardedRef
15
+ ): ReactElement {
16
+ const Link = as || $Anchor
17
+
18
+ if (newWindow) {
19
+ return (
20
+ <Link
21
+ ref={forwardedRef}
22
+ href={href}
23
+ target="_blank"
24
+ rel="noreferrer"
25
+ className={cn.AnchorHost}
26
+ {...props}
27
+ >
28
+ {children}
29
+ </Link>
30
+ )
31
+ }
32
+
33
+ return (
34
+ <Link
35
+ ref={forwardedRef}
36
+ className={cn.AnchorHost}
37
+ href={href || undefined}
38
+ {...props}
39
+ >
40
+ {children}
41
+ </Link>
42
+ )
43
+ })
44
+
45
+ Anchor.displayName = 'Anchor'
46
+
47
+ function $Anchor({ children, ...rest }) {
48
+ return <a {...rest}>
49
+ {children}
50
+ </a>
51
+ }
@@ -0,0 +1 @@
1
+ export {Anchor} from "./Anchor";
@@ -0,0 +1,44 @@
1
+ import {css} from "@linaria/core";
2
+
3
+ export const BadgeHost = css`
4
+ @layer defaults {
5
+ display: inline-flex;
6
+ align-items: center;
7
+
8
+ /* Size variants */
9
+ &[data-size="xs"] {
10
+ height: 15px;
11
+ padding: 6px;
12
+ gap: 3px;
13
+ border-radius: 6px;
14
+ font-size: var(--xyd-font-size-xsmall);
15
+ }
16
+
17
+ &[data-size="sm"] {
18
+ height: 18px;
19
+ padding: 10px;
20
+ gap: 3px;
21
+ border-radius: 6px;
22
+ font-size: var(--xyd-font-size-xsmall);
23
+ }
24
+
25
+ /* Kind variants */
26
+ &[data-kind="default"] {
27
+ color: var(--xyd-badge-color--default);
28
+ background-color: var(--xyd-badge-bgcolor--default);
29
+ }
30
+ &[data-kind="warning"] {
31
+ color: var(--xyd-badge-color--warning);
32
+ background-color: var(--xyd-badge-bgcolor--warning);
33
+ }
34
+ &[data-kind="info"] {
35
+ color: var(--xyd-badge-color--info);
36
+ background-color: var(--xyd-badge-bgcolor--info);
37
+ }
38
+
39
+ [part="child"] {
40
+ position: relative;
41
+ }
42
+ }
43
+ `;
44
+