@xyd-js/components 0.1.0-xyd.2 → 0.1.0-xyd.4
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.
- package/CHANGELOG.md +19 -0
- package/dist/{CTABanner-DVtDluuG.js → CTABanner-BX0sOkvP.js} +1 -1
- package/dist/{CTABanner-DVtDluuG.js.map → CTABanner-BX0sOkvP.js.map} +1 -1
- package/dist/CTABanner-Bgr79Lqe.js +2 -0
- package/dist/CTABanner-Bgr79Lqe.js.map +1 -0
- package/dist/CodeSample-BpsiUFZH.js +2 -0
- package/dist/CodeSample-BpsiUFZH.js.map +1 -0
- package/dist/CodeSample-OEtiPDdW.js +2 -0
- package/dist/CodeSample-OEtiPDdW.js.map +1 -0
- package/dist/{HomeView-JIjSATBR.js → HomeView-BaQ94VA7.js} +1 -1
- package/dist/{HomeView-JIjSATBR.js.map → HomeView-BaQ94VA7.js.map} +1 -1
- package/dist/HomeView-Byqn8qbO.js +2 -0
- package/dist/HomeView-Byqn8qbO.js.map +1 -0
- package/dist/{UnderlineNav-Ck16YRuC.js → UnderlineNav-C4GtpoH_.js} +2 -2
- package/dist/{UnderlineNav-Ck16YRuC.js.map → UnderlineNav-C4GtpoH_.js.map} +1 -1
- package/dist/UnderlineNav-CTBRVoit.js +2 -0
- package/dist/UnderlineNav-CTBRVoit.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-DzVepvvn.js +2 -0
- package/dist/_rollupPluginBabelHelpers-DzVepvvn.js.map +1 -0
- package/dist/_rollupPluginBabelHelpers-NA6nV2VK.js +2 -0
- package/dist/_rollupPluginBabelHelpers-NA6nV2VK.js.map +1 -0
- package/dist/brand.d.ts +2 -1
- package/dist/brand.js +1 -1
- package/dist/coder/themes/cosmo-light.d.ts +5 -0
- package/dist/coder/themes/cosmo-light.js +2 -0
- package/dist/coder/themes/cosmo-light.js.map +1 -0
- package/dist/coder.d.ts +50 -3
- package/dist/coder.js +1 -1
- package/dist/coder.js.map +1 -1
- package/dist/content.d.ts +46 -6
- package/dist/content.js +1 -1
- package/dist/content.js.map +1 -1
- package/dist/index-B_8erDHC.js +2 -0
- package/dist/index-B_8erDHC.js.map +1 -0
- package/dist/index-DBY3gRcL.js +2 -0
- package/dist/index-DBY3gRcL.js.map +1 -0
- package/dist/index.css +50 -48
- package/dist/index.d.ts +1 -1
- package/dist/layouts.d.ts +2 -1
- package/dist/layouts.js +1 -1
- package/dist/layouts.js.map +1 -1
- package/dist/pages.d.ts +2 -1
- package/dist/pages.js +1 -1
- package/dist/pages.js.map +1 -1
- package/dist/{tslib.es6-DNxqyfMY.js → tslib.es6-COc5mhWS.js} +1 -1
- package/dist/tslib.es6-COc5mhWS.js.map +1 -0
- package/dist/tslib.es6-D-wQFpKV.js +2 -0
- package/dist/tslib.es6-D-wQFpKV.js.map +1 -0
- package/dist/views.d.ts +2 -1
- package/dist/views.js +1 -1
- package/dist/writer.d.ts +14 -2
- package/dist/writer.js +1 -1
- package/dist/writer.js.map +1 -1
- package/package.json +5 -2
- package/rollup.config.js +24 -3
- package/src/coder/Code/Code.styles.tsx +50 -0
- package/src/coder/Code/Code.tsx +79 -0
- package/src/coder/Code/annotations.tsx +31 -0
- package/src/coder/Code/highlight.ts +170 -0
- package/src/coder/Code/index.ts +12 -0
- package/src/coder/CodeSample/CodeSample.tsx +30 -133
- package/src/coder/CodeSample/index.ts +0 -1
- package/src/coder/CodeSample/withLocalStored.tsx +1 -1
- package/src/coder/{CodeSample/CodeSample.styles.tsx → CodeTabs/CodeTabs.styles.tsx} +0 -48
- package/src/coder/CodeTabs/CodeTabs.tsx +82 -0
- package/src/coder/CodeTabs/index.ts +6 -0
- package/src/coder/CodeTheme/CodeTheme.tsx +78 -0
- package/src/coder/CodeTheme/index.ts +8 -0
- package/src/coder/index.ts +31 -1
- package/src/coder/{CodeSample/default-theme.ts → themes/cosmo-light.ts} +3 -2
- package/src/content/Content/Content.tsx +1 -0
- package/src/content/Content.tsx +35 -1
- package/src/pages/index.ts +1 -0
- package/src/views/index.ts +1 -0
- package/src/writer/Badge/Badge.styles.tsx +4 -0
- package/src/writer/Badge/Badge.tsx +3 -1
- package/src/writer/Icon/index.tsx +230 -0
- package/dist/CodeSample-CB5kEkeK.js +0 -2
- package/dist/CodeSample-CB5kEkeK.js.map +0 -1
- package/dist/_rollupPluginBabelHelpers-DFryr8Hb.js +0 -2
- package/dist/_rollupPluginBabelHelpers-DFryr8Hb.js.map +0 -1
- package/dist/index-CCn_Wv4c.js +0 -2
- package/dist/index-CCn_Wv4c.js.map +0 -1
- package/dist/tslib.es6-DNxqyfMY.js.map +0 -1
package/dist/views.d.ts
CHANGED
package/dist/views.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{H as HomeView}from"./HomeView-
|
|
1
|
+
export{H as HomeView}from"./HomeView-Byqn8qbO.js";import"react";
|
|
2
2
|
//# sourceMappingURL=views.js.map
|
package/dist/writer.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import React, { ReactElement } from 'react';
|
|
|
3
3
|
interface BadgeProps {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
size?: "sm";
|
|
6
|
-
kind?: "warning";
|
|
6
|
+
kind?: "warning" | "info";
|
|
7
7
|
}
|
|
8
8
|
declare function Badge({ children, size, kind }: BadgeProps): React.JSX.Element;
|
|
9
9
|
|
|
@@ -78,6 +78,17 @@ declare function IconMetrics(): React.JSX.Element;
|
|
|
78
78
|
declare function IconFunnels(): React.JSX.Element;
|
|
79
79
|
declare function IconCode(): React.JSX.Element;
|
|
80
80
|
declare function IconCustomEvent(): React.JSX.Element;
|
|
81
|
+
declare function IconAlert(): React.JSX.Element;
|
|
82
|
+
declare function IconBrowser(): React.JSX.Element;
|
|
83
|
+
declare function IconREST(): React.JSX.Element;
|
|
84
|
+
declare function IconGraphQL(): React.JSX.Element;
|
|
85
|
+
declare function IconWebhooks(): React.JSX.Element;
|
|
86
|
+
declare function IconJSBrowser(): React.JSX.Element;
|
|
87
|
+
declare function IconJSNode(): React.JSX.Element;
|
|
88
|
+
declare function IconStorybook(): React.JSX.Element;
|
|
89
|
+
declare function IconReactRouter(): React.JSX.Element;
|
|
90
|
+
declare function IconNextJS(): React.JSX.Element;
|
|
91
|
+
declare function IconAppTemplate(): React.JSX.Element;
|
|
81
92
|
|
|
82
93
|
interface NavLinksProps {
|
|
83
94
|
prev?: {
|
|
@@ -154,4 +165,5 @@ interface UnderlineNavItemProps {
|
|
|
154
165
|
href?: string;
|
|
155
166
|
}
|
|
156
167
|
|
|
157
|
-
export { Badge,
|
|
168
|
+
export { Badge, Blockquote, Breadcrumbs, Callout, Code, Details, GuideCard, Heading, Hr, IconAlert, IconAppTemplate, IconBrowser, IconCode, IconCustomEvent, IconFunnels, IconGraphQL, IconJSBrowser, IconJSNode, IconMetrics, IconNextJS, IconREST, IconReactRouter, IconSessionReplay, IconStorybook, IconWebhooks, NavLinks, Pre, Steps, Table, Tabs, UnderlineNav };
|
|
169
|
+
export type { BadgeProps, BlockquoteProps, BreadcrumbsProps, CalloutProps, CodeProps, DetailsProps, HeadingProps, HrProps, NavLinksProps, PreProps, StepsProps, TableProps, TableTdProps, TableThProps, TableTrProps, TabsProps$1 as TabsProps };
|
package/dist/writer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{b as Badge,B as Blockquote,c as Callout,C as Code,D as Details,a as Heading,H as Hr,m as IconAlert,I as IconAppTemplate,l as IconBrowser,o as IconCode,n as IconCustomEvent,p as IconFunnels,j as IconGraphQL,h as IconJSBrowser,g as IconJSNode,q as IconMetrics,d as IconNextJS,k as IconREST,e as IconReactRouter,r as IconSessionReplay,f as IconStorybook,i as IconWebhooks}from"./index-DBY3gRcL.js";import{_ as t}from"./tslib.es6-COc5mhWS.js";import s,{Fragment as u}from"react";import{ArrowRightIcon as v,ArrowLeftIcon as E}from"@radix-ui/react-icons";export{G as GuideCard,S as Steps,T as Table,a as Tabs,U as UnderlineNav}from"./UnderlineNav-CTBRVoit.js";import"./_rollupPluginBabelHelpers-NA6nV2VK.js";import"@radix-ui/react-tabs";import"lucide-react";var x="hwgsk4h",N="i1b95bxl",w="i1a3fa93",y="i1dl7ywj";function R(e){var a=e.children,r=t(e,["children"]);return s.createElement("a",Object.assign({},r),a)}function J(e){return s.createElement("div",{className:x},e.items.map((function(a,t){var r=t===e.items.length-1;return s.createElement(u,{key:a.href+a.title},t>0&&s.createElement(v,{className:N}),s.createElement("div",{className:"\n ".concat(w,"\n ").concat(r&&y,"\n "),title:a.title},a.href&&!r?s.createElement(R,{href:a.href},a.title):a.title))})))}var A="h1xhrk1",O="l1elq7ab",_="i1mmatje";function F(e){var a=e.children,r=t(e,["children"]);return s.createElement("a",Object.assign({},r),a)}function L(e){return s.createElement("div",{className:A},e.prev?s.createElement(F,{href:e.prev.href,title:e.prev.title,className:O},s.createElement(E,{className:_}),e.prev.title):s.createElement("div",null),e.next&&s.createElement(F,{href:e.next.href,title:e.next.title,className:O},e.next.title,s.createElement(v,{className:_})))}var M="h1vb39qj";function P(e){var a=e.children;return s.createElement("pre",{className:M},a)}export{J as Breadcrumbs,L as NavLinks,P as Pre};
|
|
2
2
|
//# sourceMappingURL=writer.js.map
|
package/dist/writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.js","sources":["../src/writer/Breadcrumbs/Breadcrumbs.styles.ts","../src/writer/Breadcrumbs/Breadcrumbs.tsx","../src/writer/NavLinks/NavLinks.styles.ts","../src/writer/NavLinks/NavLinks.tsx","../src/writer/Pre/Pre.styles.tsx","../src/writer/Pre/Pre.tsx"],"sourcesContent":["import {css} from \"@linaria/core\";\n\nexport const $breadcrumbs = {\n host: css`\n display: flex;\n overflow: hidden;\n margin-top: 0.375rem;\n gap: 0.25rem;\n align-items: center;\n font-size: 0.875rem;\n line-height: 1.25rem;\n color: #6B7280;\n `,\n icon: css`\n shrink: 0;\n width: 0.875rem;\n `,\n item: css`\n white-space: nowrap;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 300ms;\n `,\n item$$active: css`\n color: #000;\n font-weight: bold;\n `\n};\n","import React, {Fragment} from 'react'\nimport type {ReactElement} from 'react'\nimport {ArrowRightIcon} from '@radix-ui/react-icons'\n\nimport {$breadcrumbs} from './Breadcrumbs.styles'\n\nfunction Anchor({children, ...rest}) {\n return <a {...rest}>\n {children}\n </a>\n}\n\nexport interface BreadcrumbsProps {\n items: {\n title: string\n href?: string\n }[]\n}\n\nexport function Breadcrumbs(props: BreadcrumbsProps): ReactElement {\n return (\n <div className={$breadcrumbs.host}>\n {props.items.map((item, index) => {\n const lastActive = index === props.items.length - 1\n\n return (\n <Fragment key={item.href + item.title}>\n {index > 0 && <ArrowRightIcon className={$breadcrumbs.icon}/>}\n <div className={`\n ${$breadcrumbs.item}\n ${lastActive && $breadcrumbs.item$$active}\n `}\n title={item.title}\n >\n {item.href && !lastActive ? (\n <Anchor href={item.href}>{item.title}</Anchor>\n ) : (\n item.title\n )}\n </div>\n </Fragment>\n )\n })}\n </div>\n )\n}\n","import {css} from \"@linaria/core\";\n\nexport const $navLinks = {\n host: css`\n display: flex;\n padding-top: 2rem;\n margin-top: 2rem;\n margin-bottom: 2rem;\n justify-content: space-between;\n align-items: center;\n border-top-width: 1px;\n `,\n link: css`\n display: flex;\n padding-top: 1rem;\n padding-bottom: 1rem;\n gap: 0.25rem;\n align-items: center;\n font-size: 1rem;\n line-height: 1.5rem;\n font-weight: 500;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 300ms;\n max-width: 50%;\n `,\n icon: css`\n display: inline;\n height: 1.25rem;\n flex-shrink: 0;\n `,\n};\n","import React from \"react\"\nimport {ArrowLeftIcon, ArrowRightIcon} from '@radix-ui/react-icons'\n\nimport {$navLinks} from \"./NavLinks.styles\";\n\nfunction Anchor({children, ...rest}) {\n return <a {...rest}>\n {children}\n </a>\n}\n\nexport interface NavLinksProps {\n prev?: {\n title: string\n href: string\n }\n next?: {\n title: string\n href: string\n }\n}\n\nexport function NavLinks(props: NavLinksProps) {\n return (\n <div className={$navLinks.host}>\n {props.prev ? (\n <Anchor\n href={props.prev.href}\n title={props.prev.title}\n className={$navLinks.link}\n >\n <ArrowLeftIcon className={$navLinks.icon}/>\n {props.prev.title}\n </Anchor>\n ) : <div/>}\n {props.next && (\n <Anchor\n href={props.next.href}\n title={props.next.title}\n className={$navLinks.link}\n >\n {props.next.title}\n <ArrowRightIcon className={$navLinks.icon}/>\n </Anchor>\n )}\n </div>\n )\n}\n","import {css} from \"@linaria/core\";\n\nexport const $pre = {\n host: css`\n margin-top: 0;\n border-radius: 6px;\n padding: 16px;\n border: 0;\n\n background-color: rgb(246, 248, 250);\n overflow: auto;\n `\n}","import React from \"react\"\n\nimport {$pre} from \"./Pre.styles\"\n\nexport interface PreProps {\n children: React.ReactNode\n}\n\nexport function Pre({children}: PreProps) {\n return <pre className={$pre.host}>\n {children}\n </pre>\n}"],"names":["$breadcrumbs","Anchor","_a","children","rest","__rest","React","createElement","Object","assign","Breadcrumbs","props","className","items","map","item","index","lastActive","length","Fragment","key","href","title","ArrowRightIcon","concat","$navLinks","NavLinks","prev","ArrowLeftIcon","next","$pre","Pre","_ref"],"mappings":"
|
|
1
|
+
{"version":3,"file":"writer.js","sources":["../src/writer/Breadcrumbs/Breadcrumbs.styles.ts","../src/writer/Breadcrumbs/Breadcrumbs.tsx","../src/writer/NavLinks/NavLinks.styles.ts","../src/writer/NavLinks/NavLinks.tsx","../src/writer/Pre/Pre.styles.tsx","../src/writer/Pre/Pre.tsx"],"sourcesContent":["import {css} from \"@linaria/core\";\n\nexport const $breadcrumbs = {\n host: css`\n display: flex;\n overflow: hidden;\n margin-top: 0.375rem;\n gap: 0.25rem;\n align-items: center;\n font-size: 0.875rem;\n line-height: 1.25rem;\n color: #6B7280;\n `,\n icon: css`\n shrink: 0;\n width: 0.875rem;\n `,\n item: css`\n white-space: nowrap;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 300ms;\n `,\n item$$active: css`\n color: #000;\n font-weight: bold;\n `\n};\n","import React, {Fragment} from 'react'\nimport type {ReactElement} from 'react'\nimport {ArrowRightIcon} from '@radix-ui/react-icons'\n\nimport {$breadcrumbs} from './Breadcrumbs.styles'\n\nfunction Anchor({children, ...rest}) {\n return <a {...rest}>\n {children}\n </a>\n}\n\nexport interface BreadcrumbsProps {\n items: {\n title: string\n href?: string\n }[]\n}\n\nexport function Breadcrumbs(props: BreadcrumbsProps): ReactElement {\n return (\n <div className={$breadcrumbs.host}>\n {props.items.map((item, index) => {\n const lastActive = index === props.items.length - 1\n\n return (\n <Fragment key={item.href + item.title}>\n {index > 0 && <ArrowRightIcon className={$breadcrumbs.icon}/>}\n <div className={`\n ${$breadcrumbs.item}\n ${lastActive && $breadcrumbs.item$$active}\n `}\n title={item.title}\n >\n {item.href && !lastActive ? (\n <Anchor href={item.href}>{item.title}</Anchor>\n ) : (\n item.title\n )}\n </div>\n </Fragment>\n )\n })}\n </div>\n )\n}\n","import {css} from \"@linaria/core\";\n\nexport const $navLinks = {\n host: css`\n display: flex;\n padding-top: 2rem;\n margin-top: 2rem;\n margin-bottom: 2rem;\n justify-content: space-between;\n align-items: center;\n border-top-width: 1px;\n `,\n link: css`\n display: flex;\n padding-top: 1rem;\n padding-bottom: 1rem;\n gap: 0.25rem;\n align-items: center;\n font-size: 1rem;\n line-height: 1.5rem;\n font-weight: 500;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 300ms;\n max-width: 50%;\n `,\n icon: css`\n display: inline;\n height: 1.25rem;\n flex-shrink: 0;\n `,\n};\n","import React from \"react\"\nimport {ArrowLeftIcon, ArrowRightIcon} from '@radix-ui/react-icons'\n\nimport {$navLinks} from \"./NavLinks.styles\";\n\nfunction Anchor({children, ...rest}) {\n return <a {...rest}>\n {children}\n </a>\n}\n\nexport interface NavLinksProps {\n prev?: {\n title: string\n href: string\n }\n next?: {\n title: string\n href: string\n }\n}\n\nexport function NavLinks(props: NavLinksProps) {\n return (\n <div className={$navLinks.host}>\n {props.prev ? (\n <Anchor\n href={props.prev.href}\n title={props.prev.title}\n className={$navLinks.link}\n >\n <ArrowLeftIcon className={$navLinks.icon}/>\n {props.prev.title}\n </Anchor>\n ) : <div/>}\n {props.next && (\n <Anchor\n href={props.next.href}\n title={props.next.title}\n className={$navLinks.link}\n >\n {props.next.title}\n <ArrowRightIcon className={$navLinks.icon}/>\n </Anchor>\n )}\n </div>\n )\n}\n","import {css} from \"@linaria/core\";\n\nexport const $pre = {\n host: css`\n margin-top: 0;\n border-radius: 6px;\n padding: 16px;\n border: 0;\n\n background-color: rgb(246, 248, 250);\n overflow: auto;\n `\n}","import React from \"react\"\n\nimport {$pre} from \"./Pre.styles\"\n\nexport interface PreProps {\n children: React.ReactNode\n}\n\nexport function Pre({children}: PreProps) {\n return <pre className={$pre.host}>\n {children}\n </pre>\n}"],"names":["$breadcrumbs","Anchor","_a","children","rest","__rest","React","createElement","Object","assign","Breadcrumbs","props","className","items","map","item","index","lastActive","length","Fragment","key","href","title","ArrowRightIcon","concat","$navLinks","NavLinks","prev","ArrowLeftIcon","next","$pre","Pre","_ref"],"mappings":"uvBAEO,IAAMA,EAUR,UAVQA,EAcR,WAdQA,EAoBR,WApBQA,EAqBG,WCjBhB,SAASC,EAAOC,GAAA,IAACC,EAAkBD,EAAlBC,SAAaC,EAAIC,EAAAH,EAAlB,cACZ,OAAOI,EAAOC,cAAA,IAAAC,OAAAC,OAAA,CAAA,EAAAL,GACTD,EAET,CASM,SAAUO,EAAYC,GACxB,OACIL,EAAKC,cAAA,MAAA,CAAAK,UAAWZ,GACXW,EAAME,MAAMC,KAAI,SAACC,EAAMC,GACpB,IAAMC,EAAaD,IAAUL,EAAME,MAAMK,OAAS,EAElD,OACIZ,EAAAC,cAACY,EAAQ,CAACC,IAAKL,EAAKM,KAAON,EAAKO,OAC3BN,EAAQ,GAAKV,EAACC,cAAAgB,EAAe,CAAAX,UAAWZ,IACzCM,EAAAC,cAAA,MAAA,CAAKK,UAASY,iCAAAA,OACRxB,EAAiB,kCAAAwB,OACjBP,GAAcjB,EACnB,8BACIsB,MAAOP,EAAKO,OAEZP,EAAKM,OAASJ,EACXX,EAAAC,cAACN,EAAO,CAAAoB,KAAMN,EAAKM,MAAON,EAAKO,OAE/BP,EAAKO,OAKzB,IAGZ,CC3CO,IAAMG,EASR,UATQA,EAuBR,WAvBQA,EAwBL,WCrBR,SAASxB,EAAOC,GAAA,IAACC,EAAkBD,EAAlBC,SAAaC,EAAIC,EAAAH,EAAlB,cACZ,OAAOI,EAAOC,cAAA,IAAAC,OAAAC,OAAA,CAAA,EAAAL,GACTD,EAET,CAaM,SAAUuB,EAASf,GACrB,OACIL,EAAKC,cAAA,MAAA,CAAAK,UAAWa,GACXd,EAAMgB,KACHrB,EAACC,cAAAN,EACG,CAAAoB,KAAMV,EAAMgB,KAAKN,KACjBC,MAAOX,EAAMgB,KAAKL,MAClBV,UAAWa,GAEXnB,EAAAC,cAACqB,EAAc,CAAAhB,UAAWa,IACzBd,EAAMgB,KAAKL,OAEhBhB,EAAMC,cAAA,MAAA,MACTI,EAAMkB,MACHvB,EAAAC,cAACN,EAAM,CACHoB,KAAMV,EAAMkB,KAAKR,KACjBC,MAAOX,EAAMkB,KAAKP,MAClBV,UAAWa,GAEVd,EAAMkB,KAAKP,MACZhB,EAAAC,cAACgB,EAAc,CAACX,UAAWa,KAK/C,CC7CO,IAAMK,EACL,WCKQ,SAAAC,EAAGC,GAAqB,IAAnB7B,EAAQ6B,EAAR7B,SACjB,OAAOG,EAAAC,cAAA,MAAA,CAAKK,UAAWkB,GAClB3B,EAET"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyd-js/components",
|
|
3
|
-
"version": "0.1.0-xyd.
|
|
3
|
+
"version": "0.1.0-xyd.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
},
|
|
32
32
|
"./writer": {
|
|
33
33
|
"import": "./dist/writer.js"
|
|
34
|
+
},
|
|
35
|
+
"./coder/themes/*": {
|
|
36
|
+
"import": "./dist/coder/themes/*"
|
|
34
37
|
}
|
|
35
38
|
},
|
|
36
39
|
"dependencies": {
|
|
@@ -40,7 +43,7 @@
|
|
|
40
43
|
"codehike": "^1.0.3"
|
|
41
44
|
},
|
|
42
45
|
"peerDependencies": {
|
|
43
|
-
"react": "^
|
|
46
|
+
"react": "^19.0.0",
|
|
44
47
|
"@code-hike/lighter": "^1.0.1"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
package/rollup.config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
3
4
|
|
|
4
5
|
import resolve from '@rollup/plugin-node-resolve';
|
|
5
6
|
import commonjs from '@rollup/plugin-commonjs';
|
|
@@ -25,6 +26,16 @@ const external = [
|
|
|
25
26
|
...Object.keys(devDependencies),
|
|
26
27
|
];
|
|
27
28
|
|
|
29
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
30
|
+
const __dirname = path.dirname(__filename);
|
|
31
|
+
|
|
32
|
+
const themesDir = path.resolve(__dirname, 'src/coder/themes');
|
|
33
|
+
const themes = fs.readdirSync(themesDir).reduce((acc, file) => {
|
|
34
|
+
const themeName = path.basename(file, path.extname(file));
|
|
35
|
+
acc[`coder/themes/${themeName}`] = path.join(themesDir, file);
|
|
36
|
+
return acc;
|
|
37
|
+
}, {});
|
|
38
|
+
|
|
28
39
|
export default [
|
|
29
40
|
{
|
|
30
41
|
input: {
|
|
@@ -36,6 +47,7 @@ export default [
|
|
|
36
47
|
pages: 'src/pages/index.ts',
|
|
37
48
|
views: 'src/views/index.ts',
|
|
38
49
|
writer: 'writer.ts',
|
|
50
|
+
...themes
|
|
39
51
|
},
|
|
40
52
|
output: [
|
|
41
53
|
{
|
|
@@ -150,5 +162,14 @@ export default [
|
|
|
150
162
|
},
|
|
151
163
|
plugins: [dts()],
|
|
152
164
|
external
|
|
153
|
-
}
|
|
165
|
+
},
|
|
166
|
+
...Object.keys(themes).map(theme => ({
|
|
167
|
+
input: themes[theme],
|
|
168
|
+
output: {
|
|
169
|
+
file: `dist/${theme}.d.ts`,
|
|
170
|
+
format: 'es',
|
|
171
|
+
},
|
|
172
|
+
plugins: [dts()],
|
|
173
|
+
external
|
|
174
|
+
}))
|
|
154
175
|
];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {css} from "@linaria/core";
|
|
2
|
+
|
|
3
|
+
export const $mark = {
|
|
4
|
+
host: css`
|
|
5
|
+
display: flex;
|
|
6
|
+
border-left-width: 4px;
|
|
7
|
+
border-color: transparent;
|
|
8
|
+
margin: 4px 0;
|
|
9
|
+
`,
|
|
10
|
+
line: css`
|
|
11
|
+
flex: 1 1 0%;
|
|
12
|
+
`,
|
|
13
|
+
$$annotated: css`
|
|
14
|
+
border-color: #60A5FA;
|
|
15
|
+
background-color: #EEF2FF;
|
|
16
|
+
`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const $lineNumber = {
|
|
20
|
+
host: css`
|
|
21
|
+
margin: 0 12px 0px 4px;
|
|
22
|
+
//text-align: right;
|
|
23
|
+
user-select: none;
|
|
24
|
+
opacity: 0.5;
|
|
25
|
+
`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const $code = {
|
|
29
|
+
host: css`
|
|
30
|
+
max-height: 400px;
|
|
31
|
+
background: linear-gradient(45deg, rgb(247, 247, 248) 0%, rgb(247, 247, 248) 100%) !important;
|
|
32
|
+
|
|
33
|
+
margin: 0;
|
|
34
|
+
padding: 8px 16px;
|
|
35
|
+
|
|
36
|
+
border-top: 1px solid rgb(236, 236, 241);
|
|
37
|
+
border-bottom-left-radius: 10px;
|
|
38
|
+
border-bottom-right-radius: 10px;
|
|
39
|
+
|
|
40
|
+
font-size: 12px;
|
|
41
|
+
line-height: 20px;
|
|
42
|
+
white-space: pre-wrap;
|
|
43
|
+
word-break: break-all;
|
|
44
|
+
|
|
45
|
+
overflow-y: scroll;
|
|
46
|
+
`,
|
|
47
|
+
host$$full: css`
|
|
48
|
+
max-height: 100%;
|
|
49
|
+
`
|
|
50
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, {Suspense} from "react";
|
|
2
|
+
import type {HighlightedCode, AnnotationHandler} from "codehike/code";
|
|
3
|
+
import {InnerLine, Pre} from "codehike/code";
|
|
4
|
+
import {Theme} from "@code-hike/lighter";
|
|
5
|
+
|
|
6
|
+
import {CodeTheme, type CodeThemeBlockProps} from "../CodeTheme";
|
|
7
|
+
import {$lineNumber, $mark, $code} from "./Code.styles.tsx";
|
|
8
|
+
|
|
9
|
+
export interface CodeProps {
|
|
10
|
+
codeblocks: CodeThemeBlockProps[];
|
|
11
|
+
theme?: Theme
|
|
12
|
+
children: React.ReactNode
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function Code(props: CodeProps) {
|
|
16
|
+
return <Suspense fallback={<$Loading/>}>
|
|
17
|
+
<CodeTheme codeblocks={props.codeblocks} theme={props.theme}>
|
|
18
|
+
{props.children}
|
|
19
|
+
</CodeTheme>
|
|
20
|
+
</Suspense>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function $Loading() {
|
|
24
|
+
return <>
|
|
25
|
+
loading...
|
|
26
|
+
</>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// TODO: fix any
|
|
30
|
+
Code.LineNumber = function LineNumber(props: any) {
|
|
31
|
+
if (!props.children || !props.children.length) {
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
<span
|
|
37
|
+
style={{minWidth: `${props.width}ch`}}
|
|
38
|
+
className={$lineNumber.host}
|
|
39
|
+
>
|
|
40
|
+
{props.lineNumber}
|
|
41
|
+
</span>
|
|
42
|
+
<InnerLine merge={props}/>
|
|
43
|
+
</>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// TODO: fix any
|
|
48
|
+
Code.Mark = function Mark(props: any) {
|
|
49
|
+
return <div className={`${$mark.host} ${props.annotation && $mark.$$annotated}`}>
|
|
50
|
+
<InnerLine
|
|
51
|
+
merge={props}
|
|
52
|
+
className={$mark.line}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// TODO: fix any
|
|
58
|
+
Code.Bg = function CodeLine(props: any) {
|
|
59
|
+
return <span className={`${props.annotation && $mark.$$annotated}`}>
|
|
60
|
+
{props.children}
|
|
61
|
+
</span>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
Code.Pre = function CodePre(props: {
|
|
65
|
+
codeblock: HighlightedCode,
|
|
66
|
+
size?: "full",
|
|
67
|
+
handlers: AnnotationHandler[]
|
|
68
|
+
}
|
|
69
|
+
) {
|
|
70
|
+
return <Pre
|
|
71
|
+
className={`
|
|
72
|
+
${$code.host}
|
|
73
|
+
${props?.size === "full" && $code.host$$full}
|
|
74
|
+
`}
|
|
75
|
+
style={props.codeblock?.style || props.codeblock?.style}
|
|
76
|
+
code={props.codeblock}
|
|
77
|
+
handlers={props.handlers}
|
|
78
|
+
/>
|
|
79
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {AnnotationHandler} from "codehike/code";
|
|
3
|
+
|
|
4
|
+
import {Code} from "./Code.tsx";
|
|
5
|
+
|
|
6
|
+
const markAnnotation: AnnotationHandler = {
|
|
7
|
+
name: "mark",
|
|
8
|
+
Line: (props) => {
|
|
9
|
+
return <Code.Mark {...props}/>
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const bgAnnotation: AnnotationHandler = {
|
|
14
|
+
name: "bg",
|
|
15
|
+
Inline: (props) => {
|
|
16
|
+
return <Code.Bg {...props}/>
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const lineNumberAnnotation: AnnotationHandler = {
|
|
21
|
+
name: "line-numbers",
|
|
22
|
+
Line: ({annotation, ...props}) => {
|
|
23
|
+
return <Code.LineNumber {...props}/>
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const annotations = {
|
|
28
|
+
mark: markAnnotation,
|
|
29
|
+
bg: bgAnnotation,
|
|
30
|
+
lineNumbers: lineNumberAnnotation
|
|
31
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CodeAnnotation,
|
|
3
|
+
type RawCode,
|
|
4
|
+
type HighlightedCode,
|
|
5
|
+
type Token
|
|
6
|
+
} from 'codehike/code';
|
|
7
|
+
import {
|
|
8
|
+
type Lines,
|
|
9
|
+
type Tokens,
|
|
10
|
+
highlightSync as lighter,
|
|
11
|
+
LANG_NAMES,
|
|
12
|
+
type Theme
|
|
13
|
+
} from '@code-hike/lighter';
|
|
14
|
+
|
|
15
|
+
type Whitespace = string
|
|
16
|
+
|
|
17
|
+
type AnyToken = Token | Whitespace
|
|
18
|
+
|
|
19
|
+
function isWhitespace(token: Token | Whitespace): token is Whitespace {
|
|
20
|
+
return typeof token === 'string';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function highlight(
|
|
24
|
+
data: RawCode,
|
|
25
|
+
theme: Theme,
|
|
26
|
+
lang: string
|
|
27
|
+
): HighlightedCode {
|
|
28
|
+
if (!LANG_NAMES.includes(lang)) {
|
|
29
|
+
console.warn(`Unknown language "${lang}"`);
|
|
30
|
+
lang = 'txt';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
lines,
|
|
35
|
+
lang: lighterLang,
|
|
36
|
+
style
|
|
37
|
+
} = lighter(data.value, lang, theme as any, {
|
|
38
|
+
annotations: [],
|
|
39
|
+
scopes: false // true for better token transitions, but breaks css themes
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const tokens = joinLines(lines);
|
|
43
|
+
// split surrounding whitespace for each token
|
|
44
|
+
const splitTokens = splitWhitespace(tokens);
|
|
45
|
+
// join consecutive whitespace tokens
|
|
46
|
+
const joinedTokens = joinWhitespace(splitTokens);
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
...data,
|
|
50
|
+
code: data.value,
|
|
51
|
+
tokens: joinedTokens,
|
|
52
|
+
lang: lighterLang,
|
|
53
|
+
annotations: [], // TODO: in the future
|
|
54
|
+
// annotations: compatAnnotations(annotations),
|
|
55
|
+
themeName: typeof theme === 'string' ? theme : theme?.name || 'unknown',
|
|
56
|
+
style
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function compatAnnotations(annotations: any[]): CodeAnnotation[] {
|
|
61
|
+
const newAnnotations: CodeAnnotation[] = [];
|
|
62
|
+
for (const a of annotations) {
|
|
63
|
+
const {name, query, ranges} = a;
|
|
64
|
+
for (const r of ranges) {
|
|
65
|
+
if (r.lineNumber) {
|
|
66
|
+
const {lineNumber, fromColumn, toColumn} = r;
|
|
67
|
+
newAnnotations.push({
|
|
68
|
+
name,
|
|
69
|
+
query,
|
|
70
|
+
lineNumber,
|
|
71
|
+
fromColumn,
|
|
72
|
+
toColumn
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
const {fromLineNumber, toLineNumber} = r;
|
|
76
|
+
newAnnotations.push({
|
|
77
|
+
name,
|
|
78
|
+
query,
|
|
79
|
+
fromLineNumber,
|
|
80
|
+
toLineNumber
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return newAnnotations;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// group the Lines into one array
|
|
89
|
+
function joinLines(lines: Lines): AnyToken[] {
|
|
90
|
+
const joinedTokens: AnyToken[] = [];
|
|
91
|
+
lines.forEach((lineOrGroup, i) => {
|
|
92
|
+
if ('lines' in lineOrGroup) {
|
|
93
|
+
throw new Error('Shouldnt be groups');
|
|
94
|
+
} else {
|
|
95
|
+
const tokens = joinTokens(lineOrGroup.tokens);
|
|
96
|
+
joinedTokens.push(...tokens);
|
|
97
|
+
if (i < lines.length - 1) {
|
|
98
|
+
joinedTokens.push('\n');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return joinedTokens;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function joinTokens(tokens: Tokens): AnyToken[] {
|
|
106
|
+
return tokens.map((tokenOrGroup) => {
|
|
107
|
+
if ('tokens' in tokenOrGroup) {
|
|
108
|
+
throw new Error('Shouldnt be groups');
|
|
109
|
+
} else {
|
|
110
|
+
const t = [tokenOrGroup.content] as Token;
|
|
111
|
+
const {color, ...rest} = tokenOrGroup.style || {};
|
|
112
|
+
t.push(color);
|
|
113
|
+
if (Object.keys(rest).length) {
|
|
114
|
+
t.push(rest);
|
|
115
|
+
}
|
|
116
|
+
return t;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function splitWhitespace(tokens: AnyToken[]) {
|
|
122
|
+
const ejected: AnyToken[] = [];
|
|
123
|
+
tokens.forEach((tokenOrGroup) => {
|
|
124
|
+
if (isWhitespace(tokenOrGroup)) {
|
|
125
|
+
ejected.push(tokenOrGroup);
|
|
126
|
+
} else {
|
|
127
|
+
const [before, content, after] = splitSurroundingWhitespace(
|
|
128
|
+
tokenOrGroup[0]
|
|
129
|
+
);
|
|
130
|
+
if (before?.length) {
|
|
131
|
+
ejected.push(before);
|
|
132
|
+
}
|
|
133
|
+
if (content.length) {
|
|
134
|
+
const copy = [...tokenOrGroup] as Token;
|
|
135
|
+
copy[0] = content;
|
|
136
|
+
ejected.push(copy);
|
|
137
|
+
}
|
|
138
|
+
if (after?.length) {
|
|
139
|
+
ejected.push(after);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return ejected;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function joinWhitespace(tokens: AnyToken[]) {
|
|
147
|
+
const joinedTokens: AnyToken[] = [];
|
|
148
|
+
tokens.forEach((tokenOrGroup) => {
|
|
149
|
+
if (isWhitespace(tokenOrGroup)) {
|
|
150
|
+
let last = joinedTokens[joinedTokens.length - 1];
|
|
151
|
+
if (last && isWhitespace(last)) {
|
|
152
|
+
joinedTokens[joinedTokens.length - 1] += tokenOrGroup;
|
|
153
|
+
} else if (tokenOrGroup !== '') {
|
|
154
|
+
joinedTokens.push(tokenOrGroup);
|
|
155
|
+
}
|
|
156
|
+
} else if (tokenOrGroup[0].length > 0) {
|
|
157
|
+
joinedTokens.push(tokenOrGroup);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return joinedTokens;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// splits " \t foo bar \n" into [" \t ","foo bar"," \n"]
|
|
164
|
+
// "foo bar" -> ["","foo bar",""]
|
|
165
|
+
function splitSurroundingWhitespace(content: string) {
|
|
166
|
+
const trimmed = content.trim();
|
|
167
|
+
const before = content.slice(0, content.indexOf(trimmed));
|
|
168
|
+
const after = content.slice(content.indexOf(trimmed) + trimmed.length);
|
|
169
|
+
return [before, trimmed, after];
|
|
170
|
+
}
|