@xyd-js/atlas 0.1.0-xyd.4 → 0.1.0-xyd.57

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 (87) hide show
  1. package/.storybook/index.css +1 -27
  2. package/.storybook/preview.ts +1 -2
  3. package/CHANGELOG.md +554 -0
  4. package/LICENSE +21 -0
  5. package/dist/Update-48mkPPHi-COLbZvRj.js +4 -0
  6. package/dist/Update-48mkPPHi-COLbZvRj.js.map +1 -0
  7. package/dist/Update-6IvrCbUn-COLbZvRj.js +4 -0
  8. package/dist/Update-6IvrCbUn-COLbZvRj.js.map +1 -0
  9. package/dist/Update-B31SkKLO-COLbZvRj.js +4 -0
  10. package/dist/Update-B31SkKLO-COLbZvRj.js.map +1 -0
  11. package/dist/Update-BDC6jF5Q-COLbZvRj.js +4 -0
  12. package/dist/Update-BDC6jF5Q-COLbZvRj.js.map +1 -0
  13. package/dist/Update-BdhhXj2D-COLbZvRj.js +4 -0
  14. package/dist/Update-BdhhXj2D-COLbZvRj.js.map +1 -0
  15. package/dist/Update-BzuP6PUF-COLbZvRj.js +4 -0
  16. package/dist/Update-BzuP6PUF-COLbZvRj.js.map +1 -0
  17. package/dist/Update-C-w0Og8S-COLbZvRj.js +4 -0
  18. package/dist/Update-C-w0Og8S-COLbZvRj.js.map +1 -0
  19. package/dist/Update-CRZyUhwE-COLbZvRj.js +4 -0
  20. package/dist/Update-CRZyUhwE-COLbZvRj.js.map +1 -0
  21. package/dist/Update-Cmw6WVrs-COLbZvRj.js +4 -0
  22. package/dist/Update-Cmw6WVrs-COLbZvRj.js.map +1 -0
  23. package/dist/Update-D5pUmk9V-COLbZvRj.js +4 -0
  24. package/dist/Update-D5pUmk9V-COLbZvRj.js.map +1 -0
  25. package/dist/Update-D7tzid9y-COLbZvRj.js +4 -0
  26. package/dist/Update-D7tzid9y-COLbZvRj.js.map +1 -0
  27. package/dist/Update-DDQewhuu-COLbZvRj.js +4 -0
  28. package/dist/Update-DDQewhuu-COLbZvRj.js.map +1 -0
  29. package/dist/Update-DPeHa_01-COLbZvRj.js +4 -0
  30. package/dist/Update-DPeHa_01-COLbZvRj.js.map +1 -0
  31. package/dist/Update-DUFcLP3--COLbZvRj.js +4 -0
  32. package/dist/Update-DUFcLP3--COLbZvRj.js.map +1 -0
  33. package/dist/Update-DbvzJGdB-COLbZvRj.js +4 -0
  34. package/dist/Update-DbvzJGdB-COLbZvRj.js.map +1 -0
  35. package/dist/Update-SFXhorqS-COLbZvRj.js +4 -0
  36. package/dist/Update-SFXhorqS-COLbZvRj.js.map +1 -0
  37. package/dist/Update-b8FT7xsG-COLbZvRj.js +4 -0
  38. package/dist/Update-b8FT7xsG-COLbZvRj.js.map +1 -0
  39. package/dist/index.css +43 -53
  40. package/dist/index.d.ts +30 -10
  41. package/dist/index.js +2 -1
  42. package/dist/index.js.map +1 -0
  43. package/dist/styles.css +89 -0
  44. package/dist/tokens.css +60 -0
  45. package/dist/xydPlugin.d.ts +5 -0
  46. package/dist/xydPlugin.js +2 -0
  47. package/dist/xydPlugin.js.map +1 -0
  48. package/index.ts +1 -2
  49. package/package.json +27 -21
  50. package/packages/xyd-plugin/SidebarItem.tsx +27 -0
  51. package/packages/xyd-plugin/index.ts +20 -0
  52. package/rollup.config.js +66 -21
  53. package/src/components/ApiRef/ApiRefItem/ApiRefItem.styles.tsx +95 -63
  54. package/src/components/ApiRef/ApiRefItem/ApiRefItem.tsx +512 -52
  55. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.styles.tsx +186 -138
  56. package/src/components/ApiRef/ApiRefProperties/ApiRefProperties.tsx +590 -59
  57. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.styles.tsx +19 -23
  58. package/src/components/ApiRef/ApiRefSamples/ApiRefSamples.tsx +39 -24
  59. package/src/components/Atlas/Atlas.styles.tsx +3 -5
  60. package/src/components/Atlas/Atlas.tsx +35 -17
  61. package/src/components/Atlas/AtlasContext.tsx +47 -0
  62. package/src/components/Atlas/AtlasDecorator.styles.ts +22 -0
  63. package/src/components/Atlas/AtlasDecorator.tsx +15 -0
  64. package/src/components/Atlas/AtlasLazy/AtlasLazy.styles.tsx +7 -8
  65. package/src/components/Atlas/AtlasLazy/AtlasLazy.tsx +5 -8
  66. package/src/components/Atlas/AtlasPrimary.tsx +21 -0
  67. package/src/components/Atlas/AtlasSecondary.tsx +148 -0
  68. package/src/components/Atlas/index.ts +6 -2
  69. package/src/components/Atlas/types.ts +11 -0
  70. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.styles.tsx +56 -65
  71. package/src/components/Code/CodeSampleButtons/CodeSampleButtons.tsx +20 -29
  72. package/src/components/Code/index.ts +0 -4
  73. package/src/components/Icon/index.tsx +384 -0
  74. package/src/docs/AtlasExample/todo-app.uniform.json +1 -1
  75. package/src/styles/styles.css +89 -0
  76. package/src/styles/tokens.css +60 -0
  77. package/src/utils/mdx.ts +0 -29
  78. package/tsconfig.json +9 -2
  79. package/types.d.ts +22 -0
  80. package/src/components/Code/CodeCopy/CodeCopy.style.tsx +0 -21
  81. package/src/components/Code/CodeCopy/CodeCopy.tsx +0 -32
  82. package/src/components/Code/CodeCopy/index.ts +0 -7
  83. package/src/components/Code/CodeSample/CodeSample.styles.tsx +0 -134
  84. package/src/components/Code/CodeSample/CodeSample.tsx +0 -149
  85. package/src/components/Code/CodeSample/index.ts +0 -8
  86. package/src/components/Code/CodeSample/withLocalStored.tsx +0 -52
  87. package/src/components/Code/default-theme.ts +0 -266
package/src/utils/mdx.ts CHANGED
@@ -1,31 +1,2 @@
1
1
  import React from "react";
2
2
 
3
- export type MDXReferenceWrapper<T> = {
4
- children: React.ReactNode;
5
- title: string;
6
- };
7
-
8
- export type MDXReference<T> = T extends object
9
- ? MDXReferenceWrapper<T> & {
10
- [K in keyof T]: MDXReference<T[K]>;
11
- }
12
- : MDXReferenceWrapper<T>;
13
-
14
- // TODO: unify xyd reference props with react
15
- export function mdxValue<T>(val: MDXReferenceWrapper<T> | null): string {
16
- if (!val) {
17
- return ""
18
- }
19
-
20
- if (val.title) {
21
- return val.title
22
- }
23
-
24
- // if we have case like below
25
- /*
26
- #### !!<key> <name>
27
-
28
- !<key> string
29
- */
30
- return val as unknown as string
31
- }
package/tsconfig.json CHANGED
@@ -12,9 +12,12 @@
12
12
  "src/utils/*"
13
13
  ]
14
14
  },
15
+ "typeRoots": [
16
+ "./types.d.ts"
17
+ ],
15
18
  "module": "esnext",
16
19
  "esModuleInterop": true,
17
- "moduleResolution": "node",
20
+ "moduleResolution": "bundler",
18
21
  "target": "ES6",
19
22
  "lib": [
20
23
  "dom",
@@ -35,10 +38,14 @@
35
38
  "src/**/*.ts",
36
39
  "src/**/*.tsx",
37
40
  "src/**/*.json",
41
+ "packages/**/*.ts",
42
+ "packages/**/*.tsx",
43
+ "packages/**/*.json",
38
44
  ".storybook/**/*.ts",
39
45
  ".storybook/**/*.tsx",
46
+ "types.d.ts"
40
47
  ],
41
48
  "exclude": [
42
49
  "node_modules"
43
50
  ]
44
- }
51
+ }
package/types.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import * as React from 'react'
2
+
3
+ declare global {
4
+ namespace React {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'atlas-decorator': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
8
+
9
+ 'atlas-apiref-item': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
10
+ 'atlas-apiref-item-showcase': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
11
+ 'atlas-apiref-samples': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
12
+ 'atlas-apiref-definitions': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
13
+ 'atlas-apiref-properties': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
14
+ 'atlas-apiref-variant': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
15
+ 'atlas-apiref-propname': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
16
+ 'atlas-apiref-proptype': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
17
+ 'atlas-apiref-propmeta': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
18
+ 'atlas-apiref-meta-info': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
19
+ }
20
+ }
21
+ }
22
+ }
@@ -1,21 +0,0 @@
1
- import {css} from "@linaria/core";
2
-
3
- export const $copy = {
4
- host: css`
5
- all: unset;
6
-
7
- cursor: pointer;
8
-
9
- display: flex;
10
- align-items: center;
11
- justify-content: center;
12
-
13
- border-radius: 6px;
14
- padding: 6px;
15
-
16
- &:hover {
17
- transition: ease-in 0.1s;
18
- background: var(--atlas-comp-code-copy-background--active);
19
- }
20
- `
21
- }
@@ -1,32 +0,0 @@
1
- import React, {useState} from "react"
2
- import {Copy, CopyCheck, CheckCheck} from "lucide-react"
3
-
4
- import {
5
- $copy
6
- } from "./CodeCopy.style"
7
-
8
- export interface CodeCopyProps {
9
- text: string
10
- }
11
-
12
- export function CodeCopy({text}: CodeCopyProps) {
13
- const [copied, setCopied] = useState(false)
14
-
15
- function onClick() {
16
- navigator.clipboard.writeText(text)
17
- setCopied(true)
18
- setTimeout(() => {
19
- setCopied(false)
20
- }, 1200)
21
- }
22
-
23
- return (
24
- <button
25
- aria-label="Copy to clipboard"
26
- onClick={onClick}
27
- className={$copy.host}
28
- >
29
- {copied ? <CheckCheck size={16}/> : <Copy size={16}/>}
30
- </button>
31
- )
32
- }
@@ -1,7 +0,0 @@
1
- export {
2
- CodeCopy
3
- } from "./CodeCopy"
4
-
5
- export type {
6
- CodeCopyProps
7
- } from "./CodeCopy"
@@ -1,134 +0,0 @@
1
- import {css} from "@linaria/core";
2
-
3
- export const $sample = {
4
- host: css`
5
- flex: 1 1 0;
6
- overflow: hidden;
7
- min-width: 0;
8
- max-width: 512px;
9
-
10
- border: 1px solid var(--atlas-comp-code-sample-border-color);
11
- border-radius: 16px;
12
- `,
13
- }
14
-
15
- export const $languages = {
16
- host: css`
17
- display: flex;
18
- flex: 1 1 0%;
19
- padding: 8px 0px;
20
-
21
- background: linear-gradient(45deg, rgb(247, 247, 248) 0%, rgb(247, 247, 248) 100%) !important;
22
-
23
- border-top-right-radius: 10px;
24
- border-top-left-radius: 10px;
25
- border-bottom: 0px;
26
-
27
- min-width: 0;
28
- `,
29
- list: css`
30
- display: flex;
31
- flex-grow: 1;
32
- justify-content: end;
33
- gap: 8px;
34
- padding: 0 10px;
35
- `,
36
- button: css`
37
- all: unset;
38
-
39
- cursor: pointer;
40
-
41
- display: flex;
42
- align-items: center;
43
- justify-content: center;
44
-
45
- border-radius: 6px;
46
- padding: 6px;
47
-
48
- font-size: 14px;
49
- color: var(--atlas-comp-code-sample-color);
50
-
51
- &[data-state="active"] {
52
- color: var(--atlas-comp-code-sample-color--active);
53
- border-bottom: 1px solid var(--atlas-comp-code-sample-color--active);
54
- border-bottom-left-radius: 0px;
55
- border-bottom-right-radius: 0px;
56
- }
57
-
58
- &:hover {
59
- transition: ease-in 0.1s;
60
- background: var(--atlas-comp-code-sample-background);
61
- }
62
- `,
63
- description: css`
64
- display: flex;
65
- align-items: center;
66
- gap: 4px;
67
-
68
- font-size: 14px;
69
- color: var(--atlas-comp-code-sample-color);
70
-
71
- margin-left: 4px;
72
- margin-right: 4px;
73
- `,
74
- description$item: css`
75
- display: flex;
76
- padding-left: 16px;
77
- padding-right: 16px;
78
- flex: 1 1 0%;
79
- gap: 16px;
80
- border-radius: 4px;
81
- `,
82
- copy: css`
83
- display: flex;
84
- padding-left: 8px;
85
- padding-right: 8px;
86
- align-items: center;
87
- `
88
- }
89
-
90
- export const $code = {
91
- host: 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(--atlas-comp-code-sample-border-color);
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
-
111
- export const $mark = {
112
- host: css`
113
- display: flex;
114
- border-left-width: 4px;
115
- border-color: transparent;
116
- margin: 4px 0;
117
- `,
118
- line: css`
119
- flex: 1 1 0%;
120
- `,
121
- $$annotated: css`
122
- border-color: var(--atlas-comp-code-sample-mark-border--active);
123
- background-color: var(--atlas-comp-code-sample-mark-background--active);
124
- `
125
- }
126
-
127
- export const $lineNumber = {
128
- host: css`
129
- margin: 0 4px;
130
- //text-align: right;
131
- user-select: none;
132
- opacity: 0.5;
133
- `
134
- }
@@ -1,149 +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 {
17
- $sample,
18
- $languages,
19
- $code,
20
- $mark,
21
- $lineNumber
22
- } from "./CodeSample.styles";
23
-
24
- // TODO: try to use codehiki in build time / ASYNC !!! - we need rr server-components
25
- // TODO: separate highlight
26
-
27
- export interface MDXCodeSampleBlock {
28
- /** This is the raw code. May include annotation comments. */
29
- value: string;
30
- /** The programming language. */
31
- lang: string;
32
- /** Metadata string (the content after the language name in a markdown codeblock). */
33
- meta: string;
34
- }
35
-
36
- export interface CodeSampleProps {
37
- name: string;
38
- description: string;
39
- codeblocks: MDXCodeSampleBlock[];
40
- }
41
-
42
- const $$LocalStoredTab = withLocalStored(TabsPrimitive.Root);
43
-
44
- export function CodeSample(props: CodeSampleProps) {
45
- const [highlighted, setHighlighted] = useState<HighlightedCode[]>([]);
46
-
47
- useEffect(() => {
48
- async function fetchHighlight() {
49
- const result = await Promise.all(
50
- props.codeblocks?.map((codeblock) => highlight(codeblock, defaultTheme))
51
- );
52
-
53
- setHighlighted(result);
54
- }
55
-
56
- fetchHighlight();
57
- }, [props.codeblocks]);
58
-
59
- if (highlighted.length === 0) {
60
- return <div>Loading</div>;
61
- }
62
-
63
- if (!highlighted) {
64
- return <div>Loading</div>;
65
- }
66
-
67
-
68
- return (
69
- <$$LocalStoredTab
70
- className={$sample.host}
71
- style={highlighted[0]?.style}
72
- localStorageKey={`preferredLanguage[${name}]`}
73
- defaultValue={highlighted[0]?.meta}
74
- >
75
- <div className={$languages.host}>
76
- <$Description description={props.description}/>
77
-
78
- <TabsPrimitive.List className={$languages.list}>
79
- {props.codeblocks?.map(({meta}, i) => (
80
- <TabsPrimitive.Trigger value={meta!} key={i} className={$languages.button}>
81
- {meta}
82
- </TabsPrimitive.Trigger>
83
- ))}
84
- </TabsPrimitive.List>
85
-
86
- <div className={$languages.copy}>
87
- {props.codeblocks?.map((codeblock, i) => (
88
- <TabsPrimitive.Content value={codeblock.meta!} asChild key={i}>
89
- <CodeCopy text={codeblock.value}/>
90
- </TabsPrimitive.Content>
91
- ))}
92
- </div>
93
- </div>
94
-
95
- {highlighted?.map((codeblock, i) => (
96
- <TabsPrimitive.Content value={codeblock.meta} key={i}>
97
- <Pre
98
- className={$code.host}
99
- style={codeblock?.style || codeblock?.style}
100
- code={codeblock}
101
- handlers={[mark, lineNumber]}
102
- />
103
- </TabsPrimitive.Content>
104
- ))}
105
- </$$LocalStoredTab>
106
- )
107
- }
108
-
109
- function $Description(props: { description: string }) {
110
- return <div className={$languages.description}>
111
- <div className={$languages.description$item}>
112
- {props.description}
113
- </div>
114
- </div>
115
- }
116
-
117
- const mark: AnnotationHandler = {
118
- name: "Mark",
119
- Line: ({annotation, ...props}) => {
120
- return (
121
- <div className={`${$mark.host} ${annotation && $mark.$$annotated}`}>
122
- <InnerLine
123
- merge={props}
124
- className={$mark.line}
125
- />
126
- </div>
127
- )
128
- },
129
- }
130
-
131
- const lineNumber: AnnotationHandler = {
132
- name: "LineNumber",
133
- Line: ({annotation, ...props}) => {
134
- const width = props.totalLines.toString().length + 1
135
-
136
- return (
137
- <>
138
- <span
139
- style={{minWidth: `${width}ch`}}
140
- className={$lineNumber.host}
141
- >
142
- {props.lineNumber}
143
- </span>
144
- <InnerLine merge={props}/>
145
- </>
146
- )
147
- },
148
- }
149
-
@@ -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
- }