@xyd-js/atlas 0.1.0-xyd.15 → 0.1.0-xyd.18

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 (79) hide show
  1. package/.storybook/index.css +1 -2
  2. package/.storybook/preview.ts +1 -2
  3. package/CHANGELOG.md +31 -0
  4. package/dist/Update-BlhP2VFR-COLbZvRj.js +4 -0
  5. package/dist/Update-BlhP2VFR-COLbZvRj.js.map +1 -0
  6. package/dist/Update-CMM38Snc-COLbZvRj.js +4 -0
  7. package/dist/Update-CMM38Snc-COLbZvRj.js.map +1 -0
  8. package/dist/Update-D5e_yqty-COLbZvRj.js +4 -0
  9. package/dist/Update-D5e_yqty-COLbZvRj.js.map +1 -0
  10. package/dist/index.css +47 -58
  11. package/dist/index.d.ts +30 -11
  12. package/dist/index.js +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/styles.css +89 -0
  15. package/dist/tokens.css +5 -2
  16. package/dist/xydPlugin.d.ts +5 -0
  17. package/dist/xydPlugin.js +2 -0
  18. package/dist/xydPlugin.js.map +1 -0
  19. package/index.ts +2 -1
  20. package/package.json +13 -9
  21. package/packages/xyd-plugin/SidebarItem.tsx +27 -0
  22. package/packages/xyd-plugin/index.ts +19 -0
  23. package/rollup.config.js +27 -25
  24. package/src/components/ApiRef/ApiRefItem/ApiRefItem.styles.tsx +60 -17
  25. package/src/components/ApiRef/ApiRefItem/ApiRefItem.tsx +508 -49
  26. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.styles.tsx +73 -16
  27. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.tsx +574 -56
  28. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.styles.tsx +2 -1
  29. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.tsx +37 -19
  30. package/src/components/Atlas/Atlas.styles.tsx +1 -1
  31. package/src/components/Atlas/Atlas.tsx +35 -19
  32. package/src/components/Atlas/AtlasContext.tsx +47 -0
  33. package/src/components/Atlas/AtlasDecorator.styles.ts +22 -0
  34. package/src/components/Atlas/AtlasDecorator.tsx +15 -0
  35. package/src/components/Atlas/AtlasLazy/AtlasLazy.tsx +2 -2
  36. package/src/components/Atlas/AtlasPrimary.tsx +21 -0
  37. package/src/components/Atlas/AtlasSecondary.tsx +148 -0
  38. package/src/components/Atlas/index.ts +6 -2
  39. package/src/components/Atlas/types.ts +11 -0
  40. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.styles.tsx +4 -5
  41. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.tsx +6 -8
  42. package/src/components/Code/index.ts +0 -4
  43. package/src/components/Icon/index.tsx +384 -0
  44. package/src/styles/styles.css +89 -0
  45. package/src/styles/tokens.css +5 -2
  46. package/src/utils/mdx.ts +0 -29
  47. package/tsconfig.json +6 -2
  48. package/types.d.ts +22 -0
  49. package/dist/CodeSample-B9VUhTKF-DJ2leksk.js +0 -2
  50. package/dist/CodeSample-B9VUhTKF-DJ2leksk.js.map +0 -1
  51. package/dist/CodeSample-BSXeFy0x-DJ2leksk.js +0 -2
  52. package/dist/CodeSample-BSXeFy0x-DJ2leksk.js.map +0 -1
  53. package/dist/CodeSample-BwP208sQ-DJ2leksk.js +0 -2
  54. package/dist/CodeSample-BwP208sQ-DJ2leksk.js.map +0 -1
  55. package/dist/CodeSample-CK-CQYrV-DJ2leksk.js +0 -2
  56. package/dist/CodeSample-CK-CQYrV-DJ2leksk.js.map +0 -1
  57. package/dist/CodeSample-CUemtj_W-DJ2leksk.js +0 -2
  58. package/dist/CodeSample-CUemtj_W-DJ2leksk.js.map +0 -1
  59. package/dist/CodeSample-D0iKih-A-DJ2leksk.js +0 -2
  60. package/dist/CodeSample-D0iKih-A-DJ2leksk.js.map +0 -1
  61. package/dist/CodeSample-D33vTa6M-DJ2leksk.js +0 -2
  62. package/dist/CodeSample-D33vTa6M-DJ2leksk.js.map +0 -1
  63. package/dist/CodeSample-DUSx2KBt-DJ2leksk.js +0 -2
  64. package/dist/CodeSample-DUSx2KBt-DJ2leksk.js.map +0 -1
  65. package/dist/CodeSample-P4yxkHPW-DJ2leksk.js +0 -2
  66. package/dist/CodeSample-P4yxkHPW-DJ2leksk.js.map +0 -1
  67. package/dist/atlas-index.d.ts +0 -15
  68. package/dist/atlas-index.js +0 -2
  69. package/dist/atlas-index.js.map +0 -1
  70. package/packages/atlas-index/AtlasIndex.tsx +0 -79
  71. package/packages/atlas-index/index.ts +0 -3
  72. package/src/components/Code/CodeCopy/CodeCopy.styles.tsx +0 -17
  73. package/src/components/Code/CodeCopy/CodeCopy.tsx +0 -30
  74. package/src/components/Code/CodeCopy/index.ts +0 -7
  75. package/src/components/Code/CodeSample/CodeSample.styles.tsx +0 -131
  76. package/src/components/Code/CodeSample/CodeSample.tsx +0 -143
  77. package/src/components/Code/CodeSample/index.ts +0 -8
  78. package/src/components/Code/CodeSample/withLocalStored.tsx +0 -52
  79. package/src/components/Code/default-theme.ts +0 -266
@@ -1,79 +0,0 @@
1
- import * as React from "react"
2
-
3
- import type {Reference} from "@xyd-js/uniform";
4
- import {
5
- Heading,
6
- TableV2,
7
- Details,
8
- Code,
9
-
10
- IconQuote
11
- } from "@xyd-js/components/writer";
12
- import {
13
- helperContent
14
- } from "@xyd-js/components/content";
15
-
16
- import {MDXReference, mdxValue} from "@/utils/mdx";
17
-
18
- const {Content} = helperContent()
19
-
20
- // TODO: interface should be imported from somewhere
21
- interface CodeSourceContext {
22
- fileName: string;
23
- fileFullPath: string;
24
- sourcecode: string;
25
- }
26
-
27
- interface AtlasIndexProps {
28
- data: MDXReference<Reference<CodeSourceContext>>
29
- }
30
-
31
- export function AtlasIndex({data}: AtlasIndexProps) {
32
- return <Content>
33
- <Heading size={1}>
34
- {mdxValue(data.title)}
35
- </Heading>
36
-
37
- <p>
38
- {data.description.children}
39
- </p>
40
-
41
- {
42
- mdxValue(data.context?.fileName) && <Details
43
- label=""
44
- kind="tertiary"
45
- title={<>
46
- Source code in <Code>{mdxValue(data.context.fileFullPath)}</Code>
47
- </>}
48
- icon={<IconQuote/>}>
49
- {data.context.sourcecode.children}
50
- </Details>
51
- }
52
-
53
- {
54
- data.definitions.map((definition, index) => {
55
- return <>
56
- <Heading size={2}>
57
- {mdxValue(definition.title)}
58
- </Heading>
59
- <TableV2 key={index}>
60
- <TableV2.Head>
61
- <TableV2.Tr>
62
- <TableV2.Th>Type</TableV2.Th>
63
- <TableV2.Th>Description</TableV2.Th>
64
- </TableV2.Tr>
65
- </TableV2.Head>
66
- {definition.properties?.map((property, propIndex) => (
67
- <TableV2.Tr key={propIndex}>
68
- <TableV2.Td>
69
- <Code>{mdxValue(property.name) || mdxValue(property.type)}</Code>
70
- </TableV2.Td>
71
- <TableV2.Td muted>{property?.children}</TableV2.Td>
72
- </TableV2.Tr>
73
- ))}
74
- </TableV2>
75
- </>
76
- })
77
- }
78
- </Content>
79
- }
@@ -1,3 +0,0 @@
1
- export {
2
- AtlasIndex
3
- } from "./AtlasIndex"
@@ -1,17 +0,0 @@
1
- import {css} from "@linaria/core";
2
-
3
- export const CodeCopyHost = css`
4
- display: flex;
5
- align-items: center;
6
- justify-content: center;
7
-
8
- padding: 8px;
9
-
10
- border-radius: 6px;
11
-
12
- cursor: pointer;
13
-
14
- &:hover {
15
- background: var(--XydAtlas-Component-Code-Copy__color-background--active);
16
- }
17
- `;
@@ -1,30 +0,0 @@
1
- import React, {useState} from "react"
2
- import {Copy, CopyCheck, CheckCheck} from "lucide-react"
3
-
4
- import * as cn from "./CodeCopy.styles"
5
-
6
- export interface CodeCopyProps {
7
- text: string
8
- }
9
-
10
- export function CodeCopy({text}: CodeCopyProps) {
11
- const [copied, setCopied] = useState(false)
12
-
13
- function onClick() {
14
- navigator.clipboard.writeText(text)
15
- setCopied(true)
16
- setTimeout(() => {
17
- setCopied(false)
18
- }, 1200)
19
- }
20
-
21
- return (
22
- <button
23
- aria-label="Copy to clipboard"
24
- onClick={onClick}
25
- className={cn.CodeCopyHost}
26
- >
27
- {copied ? <CheckCheck size={16}/> : <Copy size={16}/>}
28
- </button>
29
- )
30
- }
@@ -1,7 +0,0 @@
1
- export {
2
- CodeCopy
3
- } from "./CodeCopy"
4
-
5
- export type {
6
- CodeCopyProps
7
- } from "./CodeCopy"
@@ -1,131 +0,0 @@
1
- import {css} from "@linaria/core";
2
-
3
- export const CodeSampleHost = css`
4
- flex: 1 1 0;
5
- overflow: hidden;
6
- min-width: 0;
7
- max-width: 512px;
8
-
9
- border: 1px solid var(--XydAtlas-Component-Code-Sample__color-border);
10
- border-radius: 16px;
11
- `;
12
-
13
- export const CodeSampleLanguagesHost = css`
14
- display: flex;
15
- flex: 1 1 0%;
16
- padding: 8px 0px;
17
-
18
- background: linear-gradient(45deg, rgb(247, 247, 248) 0%, rgb(247, 247, 248) 100%) !important;
19
-
20
- border-top-right-radius: 10px;
21
- border-top-left-radius: 10px;
22
- border-bottom: 0px;
23
-
24
- min-width: 0;
25
- `;
26
-
27
- export const CodeSampleLanguagesList = css`
28
- display: flex;
29
- flex-grow: 1;
30
- justify-content: end;
31
- gap: 8px;
32
- padding: 0 10px;
33
- `;
34
-
35
- export const CodeSampleLanguagesButton = css`
36
- all: unset;
37
-
38
- cursor: pointer;
39
-
40
- display: flex;
41
- align-items: center;
42
- justify-content: center;
43
-
44
- border-radius: 6px;
45
- padding: 6px;
46
-
47
- font-size: 14px;
48
- color: var(--XydAtlas-Component-Code-Sample__color);
49
-
50
- &[data-state="active"] {
51
- color: var(--XydAtlas-Component-Code-Sample__color--active);
52
- border-bottom: 1px solid var(--XydAtlas-Component-Code-Sample__color--active);
53
- border-bottom-left-radius: 0px;
54
- border-bottom-right-radius: 0px;
55
- }
56
-
57
- &:hover {
58
- transition: ease-in 0.1s;
59
- background: var(--XydAtlas-Component-Code-Sample__color-background);
60
- }
61
- `;
62
-
63
- export const CodeSampleLanguagesDescription = css`
64
- display: flex;
65
- align-items: center;
66
- gap: 4px;
67
-
68
- font-size: 14px;
69
- color: var(--XydAtlas-Component-Code-Sample__color);
70
-
71
- margin-left: 4px;
72
- margin-right: 4px;
73
- `;
74
-
75
- export const CodeSampleLanguagesDescriptionItem = css`
76
- display: flex;
77
- padding-left: 16px;
78
- padding-right: 16px;
79
- flex: 1 1 0%;
80
- gap: 16px;
81
- border-radius: 4px;
82
- `;
83
-
84
- export const CodeSampleLanguagesCopy = css`
85
- display: flex;
86
- padding-left: 8px;
87
- padding-right: 8px;
88
- align-items: center;
89
- `;
90
-
91
- export const CodeSampleCodeHost = css`
92
- max-height: 400px;
93
- background: linear-gradient(45deg, rgb(247, 247, 248) 0%, rgb(247, 247, 248) 100%) !important;
94
-
95
- margin: 0;
96
- padding: 8px 16px;
97
-
98
- border-top: 1px solid var(--XydAtlas-Component-Code-Sample__color-border);
99
- border-bottom-left-radius: 10px;
100
- border-bottom-right-radius: 10px;
101
-
102
- font-size: 14px;
103
- line-height: 20px;
104
- white-space: pre-wrap;
105
- word-break: break-all;
106
-
107
- overflow-y: scroll;
108
- `;
109
-
110
- export const CodeSampleMarkHost = css`
111
- display: flex;
112
- border-left-width: 4px;
113
- border-color: transparent;
114
- margin: 4px 0;
115
- `;
116
-
117
- export const CodeSampleMarkLine = css`
118
- flex: 1 1 0%;
119
- `;
120
-
121
- export const CodeSampleMarkAnnotated = css`
122
- border-color: var(--XydAtlas-Component-Code-Sample__color-markBorder--active);
123
- background-color: var(--XydAtlas-Component-Code-Sample__color-markBackground--active);
124
- `;
125
-
126
- export const CodeSampleLineNumberHost = css`
127
- margin: 0 4px;
128
- //text-align: right;
129
- user-select: none;
130
- opacity: 0.5;
131
- `;
@@ -1,143 +0,0 @@
1
- import React, {useEffect, useState} from "react";
2
- import * as TabsPrimitive from "@radix-ui/react-tabs"; // TODO: remove and use separation
3
- import {
4
- AnnotationHandler,
5
- InnerLine,
6
- Pre,
7
- highlight,
8
- HighlightedCode,
9
- } from "codehike/code"
10
-
11
- import {
12
- CodeCopy,
13
- } from "@/components/Code";
14
- import {theme as defaultTheme} from "@/components/Code/default-theme" // TODO: support multiple themes
15
- import {withLocalStored} from "@/components/Code/CodeSample/withLocalStored";
16
- import * as cn from "./CodeSample.styles";
17
- import {CodeLoader} from "@xyd-js/components/coder";
18
-
19
- // TODO: try to use codehiki in build time / ASYNC !!! - we need rr server-components
20
- // TODO: separate highlight
21
-
22
- export interface MDXCodeSampleBlock {
23
- /** This is the raw code. May include annotation comments. */
24
- value: string;
25
- /** The programming language. */
26
- lang: string;
27
- /** Metadata string (the content after the language name in a markdown codeblock). */
28
- meta: string;
29
- }
30
-
31
- export interface CodeSampleProps {
32
- name: string;
33
- description: string;
34
- codeblocks: MDXCodeSampleBlock[];
35
- }
36
-
37
- const $$LocalStoredTab = withLocalStored(TabsPrimitive.Root);
38
-
39
- export function CodeSample(props: CodeSampleProps) {
40
- const [highlighted, setHighlighted] = useState<HighlightedCode[]>([]);
41
-
42
- useEffect(() => {
43
- async function fetchHighlight() {
44
- const result = await Promise.all(
45
- props.codeblocks?.map((codeblock) => highlight(codeblock, defaultTheme))
46
- );
47
-
48
- setHighlighted(result);
49
- }
50
-
51
- fetchHighlight();
52
- }, [props.codeblocks]);
53
-
54
- if (highlighted.length === 0) {
55
- return <CodeLoader/>
56
- }
57
-
58
- if (!highlighted) {
59
- return <CodeLoader/>
60
- }
61
-
62
- return (
63
- <$$LocalStoredTab
64
- className={cn.CodeSampleHost}
65
- style={highlighted[0]?.style}
66
- localStorageKey={`preferredLanguage[${name}]`}
67
- defaultValue={highlighted[0]?.meta}
68
- >
69
- <div className={cn.CodeSampleLanguagesHost}>
70
- <$Description description={props.description}/>
71
-
72
- <TabsPrimitive.List className={cn.CodeSampleLanguagesList}>
73
- {props.codeblocks?.map(({meta}, i) => (
74
- <TabsPrimitive.Trigger value={meta!} key={i} className={cn.CodeSampleLanguagesButton}>
75
- {meta}
76
- </TabsPrimitive.Trigger>
77
- ))}
78
- </TabsPrimitive.List>
79
-
80
- <div className={cn.CodeSampleLanguagesCopy}>
81
- {props.codeblocks?.map((codeblock, i) => (
82
- <TabsPrimitive.Content value={codeblock.meta!} asChild key={i}>
83
- <CodeCopy text={codeblock.value}/>
84
- </TabsPrimitive.Content>
85
- ))}
86
- </div>
87
- </div>
88
-
89
- {highlighted?.map((codeblock, i) => (
90
- <TabsPrimitive.Content value={codeblock.meta} key={i}>
91
- <Pre
92
- className={cn.CodeSampleCodeHost}
93
- style={codeblock?.style || codeblock?.style}
94
- code={codeblock}
95
- handlers={[mark, lineNumber]}
96
- />
97
- </TabsPrimitive.Content>
98
- ))}
99
- </$$LocalStoredTab>
100
- )
101
- }
102
-
103
- function $Description(props: { description: string }) {
104
- return <div className={cn.CodeSampleLanguagesDescription}>
105
- <div className={cn.CodeSampleLanguagesDescriptionItem}>
106
- {props.description}
107
- </div>
108
- </div>
109
- }
110
-
111
- const mark: AnnotationHandler = {
112
- name: "Mark",
113
- Line: ({annotation, ...props}) => {
114
- return (
115
- <div className={`${cn.CodeSampleMarkHost} ${annotation && cn.CodeSampleMarkAnnotated}`}>
116
- <InnerLine
117
- merge={props}
118
- className={cn.CodeSampleMarkLine}
119
- />
120
- </div>
121
- )
122
- },
123
- }
124
-
125
- const lineNumber: AnnotationHandler = {
126
- name: "LineNumber",
127
- Line: ({annotation, ...props}) => {
128
- const width = props.totalLines.toString().length + 1
129
-
130
- return (
131
- <>
132
- <span
133
- style={{minWidth: `${width}ch`}}
134
- className={cn.CodeSampleLineNumberHost}
135
- >
136
- {props.lineNumber}
137
- </span>
138
- <InnerLine merge={props}/>
139
- </>
140
- )
141
- },
142
- }
143
-
@@ -1,8 +0,0 @@
1
- export {
2
- CodeSample,
3
- } from './CodeSample';
4
-
5
- export type {
6
- CodeSampleProps,
7
- MDXCodeSampleBlock,
8
- } from "./CodeSample";
@@ -1,52 +0,0 @@
1
- import React, {useState, useEffect} from "react"
2
-
3
- export interface CodeTabsProps {
4
- localStorageKey: string
5
- defaultValue: string
6
- className: string
7
- style: any
8
-
9
- children: React.ReactNode
10
- }
11
-
12
- // TODO: interface
13
- export function withLocalStored(Component: any) {
14
- return function LocalStored(props: CodeTabsProps) {
15
- const [value, setValue] = useState(
16
- typeof localStorage !== "undefined"
17
- ? localStorage?.getItem(props.localStorageKey) || props.defaultValue
18
- : props.defaultValue,
19
- )
20
-
21
- useEffect(() => {
22
- const handler = (e: StorageEvent) => {
23
- if (e.key === props.localStorageKey) {
24
- setValue(e.newValue || props.defaultValue)
25
- }
26
- }
27
- window.addEventListener("storage", handler)
28
- return () => {
29
- window.removeEventListener("storage", handler)
30
- }
31
- }, [props.localStorageKey])
32
-
33
- function onValueChange(value: string) {
34
- localStorage.setItem(props.localStorageKey, value)
35
- window.dispatchEvent(
36
- new StorageEvent("storage", {
37
- key: props.localStorageKey,
38
- newValue: value,
39
- }),
40
- )
41
- }
42
-
43
- return (
44
- <Component
45
- onValueChange={onValueChange}
46
- value={value}
47
- >
48
- {props.children}
49
- </Component>
50
- )
51
- }
52
- }