@jpmorganchase/mosaic-components 0.1.0-beta.11 → 0.1.0-beta.13
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/.turbo/turbo-build.log +2 -4
- package/CHANGELOG.md +26 -0
- package/README.md +0 -5
- package/dist/Accordion/index.d.ts +1 -1
- package/dist/Accordion/index.js +1 -1
- package/dist/AudioPlayer/index.js +1 -1
- package/dist/Button.d.ts +2 -2
- package/dist/Button.js +1 -1
- package/dist/EditionFilterView/index.d.ts +1 -1
- package/dist/EditionFilterView/index.js +1 -1
- package/dist/EditionTileLink/index.d.ts +1 -1
- package/dist/EditionTileLink/index.js +1 -1
- package/dist/Feature/FeatureActions/index.d.ts +1 -1
- package/dist/Feature/FeatureActions/index.js +1 -1
- package/dist/Feature/FeatureEyebrow/index.js +1 -1
- package/dist/Feature/index.js +1 -1
- package/dist/FilterToolbar/ContentArea/index.d.ts +1 -1
- package/dist/FilterToolbar/ContentArea/index.js +1 -1
- package/dist/FilterToolbar/PillGroup/index.d.ts +1 -1
- package/dist/FilterToolbar/PillGroup/index.js +1 -1
- package/dist/FilterToolbar/Toolbar.d.ts +1 -1
- package/dist/FilterToolbar/Toolbar.js +1 -1
- package/dist/FilterToolbar/index.js +1 -1
- package/dist/FilterView/ContentArea/index.d.ts +1 -1
- package/dist/FilterView/ContentArea/index.js +1 -1
- package/dist/FilterView/FilterView.d.ts +5 -5
- package/dist/FilterView/FilterView.js +1 -1
- package/dist/FilterView/NoResults/index.d.ts +1 -1
- package/dist/FilterView/NoResults/index.js +1 -1
- package/dist/FilterView/Pagination/index.d.ts +1 -1
- package/dist/FilterView/Pagination/index.js +1 -1
- package/dist/FilterView/Pagination/usePagination.d.ts +1 -1
- package/dist/FilterView/Pagination/usePagination.js +1 -1
- package/dist/FilterView/ResultCount/index.d.ts +1 -1
- package/dist/FilterView/ResultCount/index.js +1 -1
- package/dist/FilterView/index.js +1 -1
- package/dist/FormattedContent.d.ts +1 -1
- package/dist/FormattedContent.js +1 -1
- package/dist/HelpLinks/index.d.ts +1 -1
- package/dist/HelpLinks/index.js +1 -1
- package/dist/Hero/index.d.ts +1 -1
- package/dist/Hero/index.js +1 -1
- package/dist/Icon/index.d.ts +1 -1
- package/dist/Impact/index.d.ts +1 -1
- package/dist/Impact/index.js +1 -1
- package/dist/Link/index.js +1 -1
- package/dist/LinkButton.d.ts +2 -2
- package/dist/LinkButton.js +1 -1
- package/dist/List/ListItem.d.ts +1 -1
- package/dist/List/ListItem.js +1 -1
- package/dist/List/OrderedList.d.ts +1 -1
- package/dist/List/OrderedList.js +1 -1
- package/dist/List/UnorderedList.d.ts +1 -1
- package/dist/List/index.js +1 -1
- package/dist/Markdown/AnchorHeading/index.d.ts +2 -2
- package/dist/Markdown/AnchorHeading/index.js +1 -1
- package/dist/Markdown/BlockQuote/index.d.ts +1 -1
- package/dist/Markdown/BlockQuote/index.js +1 -1
- package/dist/Markdown/Heading.d.ts +7 -7
- package/dist/Markdown/Heading.js +1 -1
- package/dist/Markdown/InlineCode.d.ts +1 -1
- package/dist/Markdown/InlineCode.js +1 -1
- package/dist/Markdown/Link.d.ts +1 -1
- package/dist/Markdown/Link.js +1 -1
- package/dist/Markdown/Pre/index.d.ts +1 -1
- package/dist/Markdown/Pre/index.js +1 -1
- package/dist/Markdown/Table.d.ts +1 -1
- package/dist/Markdown/Table.js +1 -1
- package/dist/Markdown/Tbody.d.ts +1 -1
- package/dist/Markdown/Td.d.ts +2 -2
- package/dist/Markdown/Td.js +1 -1
- package/dist/Markdown/Th.d.ts +2 -2
- package/dist/Markdown/Th.js +1 -1
- package/dist/Markdown/Thead.d.ts +1 -1
- package/dist/Markdown/ThematicBreak/index.d.ts +1 -1
- package/dist/Markdown/Tr.d.ts +1 -1
- package/dist/Markdown/Tr.js +1 -1
- package/dist/Markdown/index.d.ts +106 -106
- package/dist/Markdown/index.js +1 -1
- package/dist/Markdown/markdownElements.d.ts +24 -24
- package/dist/Markdown/markdownElements.js +1 -1
- package/dist/Markdown/withMarkdownSpacing/index.d.ts +1 -1
- package/dist/Markdown/withMarkdownSpacing/index.js +1 -1
- package/dist/PageFilterView/index.js +1 -1
- package/dist/ReactLive/index.js +1 -1
- package/dist/SecondaryNavbar/index.d.ts +1 -1
- package/dist/SecondaryNavbar/index.js +1 -1
- package/dist/SectionHeading/index.js +1 -1
- package/dist/StickyHeader/index.d.ts +2 -2
- package/dist/StickyHeader/index.js +1 -1
- package/dist/Story/index.js +1 -1
- package/dist/Tabs/index.js +1 -1
- package/dist/TabsBase/TabsBase.d.ts +2 -2
- package/dist/TabsBase/TabsBase.js +1 -1
- package/dist/TabsBase/TabsButton.d.ts +2 -2
- package/dist/TabsBase/TabsLink.d.ts +1 -1
- package/dist/TabsBase/TabsLink.js +1 -1
- package/dist/TabsBase/index.js +1 -1
- package/dist/Tag/index.d.ts +1 -1
- package/dist/Tag/index.js +1 -1
- package/dist/ThemeProvider.js +1 -1
- package/dist/TileButton/index.d.ts +2 -2
- package/dist/TileButton/index.js +1 -1
- package/dist/TileContent/index.d.ts +1 -1
- package/dist/TileContent/index.js +1 -1
- package/dist/TileContentLabel/index.d.ts +3 -3
- package/dist/TileContentLabel/index.js +1 -1
- package/dist/TileLink/index.d.ts +2 -2
- package/dist/TileLink/index.js +1 -1
- package/dist/Typography/index.d.ts +38 -38
- package/dist/Typography/index.js +1 -1
- package/dist/Typography/withStyledTypography.d.ts +1 -1
- package/dist/Typography/withStyledTypography.js +1 -1
- package/dist/VideoPlayer/index.d.ts +1 -1
- package/dist/VideoPlayer/index.js +1 -1
- package/dist/chunk-26CX265J.js +1 -0
- package/dist/chunk-2ARWROO7.js +1 -0
- package/dist/chunk-2NXJRMPC.js +1 -0
- package/dist/chunk-2UXB3US3.js +1 -0
- package/dist/{chunk-7AKIGM4A.js → chunk-3T7QSWYG.js} +1 -1
- package/dist/chunk-47GPIIMM.js +1 -0
- package/dist/{chunk-KX3SXK2F.js → chunk-5U2Z6OEZ.js} +1 -1
- package/dist/{chunk-VROQRL3K.js → chunk-6HJPHCCS.js} +1 -1
- package/dist/{chunk-AZUFJ6VU.js → chunk-6UHHRIWA.js} +1 -1
- package/dist/{chunk-WRJSODGW.js → chunk-74RXQCVJ.js} +1 -1
- package/dist/chunk-B4I3UZSP.js +1 -0
- package/dist/{chunk-GMHXY34G.js → chunk-BAPU7HJ3.js} +1 -1
- package/dist/{chunk-XYZBCTIZ.js → chunk-BDI7IUAH.js} +1 -1
- package/dist/chunk-C2ZQQ7ZP.js +1 -0
- package/dist/chunk-C3Y4QQBE.js +1 -0
- package/dist/chunk-C4ENGERB.js +1 -0
- package/dist/chunk-C7JCZWVX.js +1 -0
- package/dist/chunk-CAHJ6PGZ.js +1 -0
- package/dist/chunk-CQLDUURH.js +1 -0
- package/dist/{chunk-CK3NOI7N.js → chunk-DPPALZDI.js} +1 -1
- package/dist/chunk-F3JFIKJC.js +1 -0
- package/dist/chunk-FKYZJPEO.js +1 -0
- package/dist/{chunk-5NKWGBQZ.js → chunk-G6AWA3FJ.js} +1 -1
- package/dist/chunk-GJ5OMOUR.js +1 -0
- package/dist/chunk-GMT5W53B.js +1 -0
- package/dist/{chunk-FJZG23C4.js → chunk-HY2GMO45.js} +1 -1
- package/dist/chunk-INYGBORN.js +1 -0
- package/dist/{chunk-THZHIJBQ.js → chunk-J7GJCVCD.js} +1 -1
- package/dist/chunk-JYIIMASI.js +1 -0
- package/dist/{chunk-GSGQC5H5.js → chunk-KYGDER56.js} +2 -2
- package/dist/{chunk-C252LIKT.js → chunk-LSV5QSPJ.js} +1 -1
- package/dist/{chunk-ZAUKECSD.js → chunk-NEKXUNC3.js} +1 -1
- package/dist/chunk-NHM5P6ZU.js +1 -0
- package/dist/{chunk-F6WIBZNK.js → chunk-NMLOOQZH.js} +1 -1
- package/dist/chunk-ORZHJDLF.js +1 -0
- package/dist/{chunk-SS3XUXOS.js → chunk-OZP4XJN4.js} +1 -1
- package/dist/chunk-P2Q72DAZ.js +1 -0
- package/dist/chunk-P7S3HLKN.js +1 -0
- package/dist/{chunk-VIQKAFRZ.js → chunk-PLHKMRZS.js} +1 -1
- package/dist/{chunk-BZH4QVWW.js → chunk-PYXBOKWW.js} +1 -1
- package/dist/chunk-QRIBS5XE.js +1 -0
- package/dist/chunk-RDGUE62K.js +1 -0
- package/dist/chunk-RPIX3WSX.js +1 -0
- package/dist/{chunk-TBLQRXJC.js → chunk-SHY5O66X.js} +1 -1
- package/dist/{chunk-7W3FVLQG.js → chunk-USHSPVAQ.js} +1 -1
- package/dist/{chunk-U3L7YGSF.js → chunk-VIF3F37A.js} +1 -1
- package/dist/chunk-W2PUIPEP.js +1 -0
- package/dist/{chunk-GHEBJRO3.js → chunk-ZEM3WI5Y.js} +1 -1
- package/dist/chunk-ZJD6TG4Z.js +1 -0
- package/dist/{chunk-FUUUTGVL.js → chunk-ZQEOC5MI.js} +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.d.ts +0 -1
- package/dist/styles.js +1 -1
- package/package.json +22 -16
- package/src/Accordion/index.tsx +5 -1
- package/src/Button.tsx +6 -1
- package/src/EditionFilterView/index.tsx +1 -1
- package/src/EditionTileLink/index.tsx +4 -5
- package/src/Feature/FeatureActions/index.tsx +5 -1
- package/src/FilterToolbar/ContentArea/index.tsx +3 -5
- package/src/FilterToolbar/PillGroup/index.tsx +3 -1
- package/src/FilterToolbar/Toolbar.tsx +2 -5
- package/src/FilterView/ContentArea/index.tsx +3 -6
- package/src/FilterView/NoResults/index.tsx +1 -1
- package/src/FilterView/Pagination/index.tsx +1 -1
- package/src/FilterView/Pagination/usePagination.ts +1 -1
- package/src/FilterView/ResultCount/index.tsx +3 -1
- package/src/FormattedContent.tsx +1 -1
- package/src/HelpLinks/index.tsx +2 -2
- package/src/Hero/index.tsx +1 -1
- package/src/Icon/index.tsx +6 -1
- package/src/Impact/index.tsx +1 -1
- package/src/Label/styles.css.ts +1 -1
- package/src/LinkButton.tsx +1 -1
- package/src/List/ListItem.tsx +1 -1
- package/src/List/OrderedList.tsx +4 -1
- package/src/List/UnorderedList.tsx +1 -1
- package/src/Markdown/AnchorHeading/index.tsx +2 -2
- package/src/Markdown/BlockQuote/index.tsx +4 -1
- package/src/Markdown/InlineCode.tsx +4 -3
- package/src/Markdown/Link.tsx +1 -1
- package/src/Markdown/Pre/index.tsx +21 -23
- package/src/Markdown/Table.tsx +1 -1
- package/src/Markdown/Tbody.tsx +1 -1
- package/src/Markdown/Td.tsx +2 -2
- package/src/Markdown/Th.tsx +2 -2
- package/src/Markdown/Thead.tsx +1 -1
- package/src/Markdown/ThematicBreak/index.tsx +3 -3
- package/src/Markdown/Tr.tsx +1 -1
- package/src/Markdown/withMarkdownSpacing/index.tsx +3 -3
- package/src/SecondaryNavbar/index.tsx +1 -1
- package/src/StickyHeader/index.tsx +1 -1
- package/src/TabsBase/TabsBase.tsx +1 -1
- package/src/TabsBase/TabsButton.tsx +1 -1
- package/src/TabsBase/TabsLink.tsx +1 -1
- package/src/Tag/index.tsx +1 -1
- package/src/ThemeProvider.tsx +15 -12
- package/src/TileButton/index.tsx +1 -1
- package/src/TileContent/index.tsx +4 -2
- package/src/TileContentLabel/index.tsx +3 -3
- package/src/TileLink/index.tsx +1 -1
- package/src/Typography/withStyledTypography.tsx +5 -2
- package/src/VideoPlayer/index.tsx +5 -2
- package/src/__tests__/ReactLive.test.tsx +4 -3
- package/src/index.tsx +0 -3
- package/src/styles.ts +0 -1
- package/dist/ColorModeProvider.d.ts +0 -16
- package/dist/ColorModeProvider.js +0 -1
- package/dist/chunk-3R4QYYQ4.js +0 -1
- package/dist/chunk-42WFLOC6.js +0 -1
- package/dist/chunk-4W6HT3B4.js +0 -1
- package/dist/chunk-6464SWDK.js +0 -1
- package/dist/chunk-6CR2UHLM.js +0 -1
- package/dist/chunk-7OWUJHAN.js +0 -1
- package/dist/chunk-BUHTZKLI.js +0 -1
- package/dist/chunk-CUOEKXWQ.js +0 -1
- package/dist/chunk-DBAOAJMH.js +0 -1
- package/dist/chunk-ETW7NOZJ.js +0 -1
- package/dist/chunk-H5M4JDKA.js +0 -1
- package/dist/chunk-HLJ5MAIP.js +0 -1
- package/dist/chunk-HNI5K3YJ.js +0 -1
- package/dist/chunk-HOA24BWP.js +0 -1
- package/dist/chunk-JS3RLRUL.js +0 -1
- package/dist/chunk-LTWUYEB2.js +0 -1
- package/dist/chunk-NOY2XYXH.js +0 -1
- package/dist/chunk-OG67L3OV.js +0 -1
- package/dist/chunk-OUSBK7KV.js +0 -1
- package/dist/chunk-QQRJOQDC.js +0 -1
- package/dist/chunk-ROI2EB7Y.js +0 -1
- package/dist/chunk-U2VVI5ES.js +0 -1
- package/dist/chunk-US5YZNOL.js +0 -1
- package/dist/chunk-XTLNI7GW.js +0 -1
- package/dist/chunk-Y7KOFQIK.js +0 -1
- package/dist/chunk-YHDUTISD.js +0 -1
- package/dist/chunk-YQLFGUES.js +0 -1
- package/dist/chunk-YTOBFDVN.js +0 -1
- package/dist/labs/Diagram.d.ts +0 -6
- package/dist/labs/Sitemap/drawTree.d.ts +0 -74
- package/dist/labs/Sitemap/index.d.ts +0 -10
- package/dist/labs/Sitemap/styles.css.d.ts +0 -6
- package/dist/labs/index.d.ts +0 -9
- package/dist-labs/Diagram.js +0 -1
- package/dist-labs/Sitemap/drawTree.js +0 -1
- package/dist-labs/Sitemap/index.css +0 -1
- package/dist-labs/Sitemap/index.js +0 -1
- package/dist-labs/Sitemap/styles.css.css +0 -1
- package/dist-labs/Sitemap/styles.css.js +0 -1
- package/dist-labs/index.css +0 -1
- package/dist-labs/index.js +0 -1
- package/src/ColorModeProvider.tsx +0 -70
- package/src/labs/Diagram.tsx +0 -26
- package/src/labs/Sitemap/drawTree.ts +0 -163
- package/src/labs/Sitemap/index.tsx +0 -223
- package/src/labs/Sitemap/styles.css.ts +0 -24
- package/src/labs/index.ts +0 -13
package/dist/chunk-YTOBFDVN.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as r}from"./chunk-UTPSJF3Y.js";import o from"react";import{Accordion as i,AccordionSection as m,AccordionSummary as s,AccordionDetails as l}from"@salt-ds/lab";import{AccordionSection as u,AccordionSummary as P,AccordionDetails as N}from"@salt-ds/lab";var S=({children:a,panels:e,...t})=>{let n=a;return e&&(n=e.map((c,d)=>o.createElement(m,{defaultExpanded:c.expanded,key:`panelItem-${d}`},o.createElement(s,{className:r.summary},c.summary),o.createElement(l,{role:"tabpanel",className:r.content},c.content)))),o.createElement(i,{maxExpandedItems:1,...t},n)};export{S as a,u as b,P as c,N as d};
|
package/dist/labs/Diagram.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
export declare function drawTree(root: any, {
|
|
2
|
-
/**
|
|
3
|
-
* label: given a node d, returns the display name
|
|
4
|
-
*/
|
|
5
|
-
label,
|
|
6
|
-
/**
|
|
7
|
-
* title: given a node d, returns its hover text
|
|
8
|
-
*/
|
|
9
|
-
title,
|
|
10
|
-
/**
|
|
11
|
-
* width: outer width, in pixels
|
|
12
|
-
*/
|
|
13
|
-
width,
|
|
14
|
-
/**
|
|
15
|
-
* height: outer height, in pixels
|
|
16
|
-
*/
|
|
17
|
-
height,
|
|
18
|
-
/**
|
|
19
|
-
* radius: radius of nodes
|
|
20
|
-
*/
|
|
21
|
-
r,
|
|
22
|
-
/**
|
|
23
|
-
* padding: horizontal padding for first and last column
|
|
24
|
-
*/
|
|
25
|
-
padding,
|
|
26
|
-
/**
|
|
27
|
-
* fill: fill for nodes
|
|
28
|
-
*/
|
|
29
|
-
fill,
|
|
30
|
-
/**
|
|
31
|
-
* stroke: stroke for links
|
|
32
|
-
*/
|
|
33
|
-
stroke,
|
|
34
|
-
/**
|
|
35
|
-
* strokeWidth: stroke width for links
|
|
36
|
-
*/
|
|
37
|
-
strokeWidth,
|
|
38
|
-
/**
|
|
39
|
-
* strokeOpacity: stroke opacity for links
|
|
40
|
-
*/
|
|
41
|
-
strokeOpacity,
|
|
42
|
-
/**
|
|
43
|
-
* strokeLinejoin: stroke line join for links
|
|
44
|
-
*/
|
|
45
|
-
strokeLinejoin,
|
|
46
|
-
/**
|
|
47
|
-
* strokeLinecap: stroke line cap for links
|
|
48
|
-
*/
|
|
49
|
-
strokeLinecap,
|
|
50
|
-
/**
|
|
51
|
-
* halo: color of label halo
|
|
52
|
-
*/
|
|
53
|
-
halo,
|
|
54
|
-
/**
|
|
55
|
-
* haloWidth: padding around the labels
|
|
56
|
-
*/
|
|
57
|
-
haloWidth }?: {
|
|
58
|
-
label?: ((data: any, node: any) => string) | null;
|
|
59
|
-
title?: ((data: any, node: any) => string) | null;
|
|
60
|
-
link?: ((data: any, node: any) => string) | null;
|
|
61
|
-
linkTarget?: string;
|
|
62
|
-
width?: number;
|
|
63
|
-
height?: number;
|
|
64
|
-
r?: number;
|
|
65
|
-
padding?: number;
|
|
66
|
-
fill?: string;
|
|
67
|
-
stroke?: string;
|
|
68
|
-
strokeWidth?: number;
|
|
69
|
-
strokeOpacity?: number;
|
|
70
|
-
strokeLinejoin?: string;
|
|
71
|
-
strokeLinecap?: string;
|
|
72
|
-
halo?: string;
|
|
73
|
-
haloWidth?: number;
|
|
74
|
-
}): any;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface SitemapProps {
|
|
3
|
-
/** Additional class name for overrides */
|
|
4
|
-
className?: string;
|
|
5
|
-
/** The url of the file system */
|
|
6
|
-
href: string;
|
|
7
|
-
/** Initial namespace filters */
|
|
8
|
-
initialNamespaceFilters?: string[];
|
|
9
|
-
}
|
|
10
|
-
export declare const Sitemap: React.FC<SitemapProps>;
|
package/dist/labs/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { SitemapProps } from './Sitemap';
|
|
3
|
-
import type { DiagramProps } from './Diagram';
|
|
4
|
-
export * from './Diagram';
|
|
5
|
-
export * from './Sitemap';
|
|
6
|
-
export declare const getLabMarkdownComponents: () => {
|
|
7
|
-
Diagram: import("react").FC<DiagramProps>;
|
|
8
|
-
Sitemap: import("react").FC<SitemapProps>;
|
|
9
|
-
};
|
package/dist-labs/Diagram.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import r,{useEffect as n}from"react";import{Mermaid as i}from"mdx-mermaid/lib/Mermaid";import m from"warning";var a;function c({className:o,...e}){return n(()=>{m(a,"Diagram component is an alpha Lab component and not ready for Production use"),a=!0},[]),r.createElement("div",{className:o},r.createElement(i,{...e}))}export{c as Diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import*as e from"d3";function H(n,{label:c=null,title:u=null,width:r=640,height:f=void 0,r:y=3,padding:p=1,fill:m="#999",stroke:h="#555",strokeWidth:b=1.5,strokeOpacity:w=.4,strokeLinejoin:v=void 0,strokeLinecap:j=void 0,halo:z="#fff",haloWidth:L=3}={}){let _=n.descendants(),k=c==null?null:_.map(t=>c(t.data,t)),i=20,g=r/(n.height+p);e.tree().nodeSize([i,g])(n);let a=1/0,l=-a;n.each(t=>{t.x>l&&(l=t.x),t.x<a&&(a=t.x)});let x=f===void 0?l-a+i*2:f,s=e.create("svg").attr("viewBox",[-g*p/2,a-i,r,x]).attr("width",r).attr("height",x).attr("style","max-width: 100%; height: auto; overflow: visible;").attr("font-family","sans-serif").attr("font-size",10);s.append("g").attr("fill","none").attr("stroke",h).attr("stroke-opacity",w).attr("stroke-linecap",j).attr("stroke-linejoin",v).attr("stroke-width",b).selectAll("path").data(n.links()).join("path").attr("d",e.linkHorizontal().x(t=>t.y).y(t=>t.x));let d=s.append("g").selectAll("a").data(n.descendants()).join("a").attr("transform",t=>`translate(${t.y},${t.x})`);return d.append("circle").attr("fill",t=>t.children?h:m).attr("r",y),u!=null&&d.append("title").text(t=>u(t.data,t)),k&&d.append("text").attr("dy","0.32em").attr("x",t=>t.children?-6:6).attr("text-anchor",t=>t.children?"end":"start").attr("paint-order","stroke").attr("stroke",z).attr("stroke-width",L).text((t,o)=>k[o]).on("click",(t,o)=>{let{data:A}=o.data;window.open(A.link,"_blank")}).style("cursor","pointer"),s}export{H as drawTree};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.pk1hfu0{display:flex;justify-content:flex-end}.pk1hfu1{display:flex;align-items:center;gap:var(--space-vertical-x4);flex-direction:column}.pk1hfu2{margin:auto 0}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import c,{useEffect as at,useRef as K,useState as T}from"react";import*as b from"d3";import{Dropdown as ot,DropdownButton as it,Spinner as st}from"@salt-ds/lab";import pt from"warning";import M from"react";import{icons as B}from"@jpmorganchase/mosaic-theme";var z={small:"_12vahby0",medium:"_12vahby1",large:"_12vahby2"};var _={tick:"successTick"},W=({className:e,name:n,size:a="small",...o})=>{if(n==="none")return null;let i=n;if(_[n]&&(console.warn(`icon ${n} has been deprecated and should be replaced by ${_[n]}`),console.warn(`icon ${n} will be removed after March 2023`),i=_[n]),!B||!B[i])throw new Error(`icon ${i} is not supported`);let s=B[i];return M.createElement("span",{className:e,...o},M.createElement(s,{className:z[a]}))};import*as C from"d3";function q(e,{label:n=null,title:a=null,width:o=640,height:i=void 0,r:s=3,padding:l=1,fill:S="#999",stroke:d="#555",strokeWidth:m=1.5,strokeOpacity:h=.4,strokeLinejoin:y=void 0,strokeLinecap:I=void 0,halo:j="#fff",haloWidth:L=3}={}){let A=e.descendants(),H=n==null?null:A.map(r=>n(r.data,r)),p=20,u=o/(e.height+l);C.tree().nodeSize([p,u])(e);let x=1/0,g=-x;e.each(r=>{r.x>g&&(g=r.x),r.x<x&&(x=r.x)});let E=i===void 0?g-x+p*2:i,k=C.create("svg").attr("viewBox",[-u*l/2,x-p,o,E]).attr("width",o).attr("height",E).attr("style","max-width: 100%; height: auto; overflow: visible;").attr("font-family","sans-serif").attr("font-size",10);k.append("g").attr("fill","none").attr("stroke",d).attr("stroke-opacity",h).attr("stroke-linecap",I).attr("stroke-linejoin",y).attr("stroke-width",m).selectAll("path").data(e.links()).join("path").attr("d",C.linkHorizontal().x(r=>r.y).y(r=>r.x));let w=k.append("g").selectAll("a").data(e.descendants()).join("a").attr("transform",r=>`translate(${r.y},${r.x})`);return w.append("circle").attr("fill",r=>r.children?d:S).attr("r",s),a!=null&&w.append("title").text(r=>a(r.data,r)),H&&w.append("text").attr("dy","0.32em").attr("x",r=>r.children?-6:6).attr("text-anchor",r=>r.children?"end":"start").attr("paint-order","stroke").attr("stroke",j).attr("stroke-width",L).text((r,$)=>H[$]).on("click",(r,$)=>{let{data:X}=$.data;window.open(X.link,"_blank")}).style("cursor","pointer"),k}var O={toolbar:"pk1hfu0",feedback:"pk1hfu1 pdl72e80 pdl72e81 pdl72e82 pdl72e83 pdl72ebk pdl72ebl pdl72ebm pdl72ebn pdl72edg pdl72edh pdl72edi pdl72edj pdl72e9w pdl72e9x pdl72e9y pdl72e9z",pageCount:"pk1hfu2 pdl72e9s pdl72e9t pdl72e9u pdl72e9v"};import{action as f,amount as et,caption as N,emphasis as G,eyebrow as nt,heading as v,paragraph as P,subtitle as F,watermark as rt}from"@jpmorganchase/mosaic-theme";import Z from"react";import R from"classnames";import tt from"hoist-non-react-statics";import Y from"react";var D=function({component:n="p",children:a,...o}){return Y.createElement(n,{...o},a)};function t(e,n="p",a={}){let o=({className:i,...s})=>Z.createElement(D,{className:R(e,i),component:n,...a,...s});return tt(o,D),o}var jt=t(f({variant:"action1"})),Lt=t(f({variant:"action2"})),$t=t(f({variant:"action3"})),Bt=t(f({variant:"action4"})),_t=t(f({variant:"action5"})),Dt=t(f({variant:"action6"})),zt=t(f({variant:"action7"})),Mt=t(f({variant:"action8"})),Wt=t(v({variant:"heading0"}),"h1"),qt=t(v({variant:"heading1"}),"h1"),Gt=t(v({variant:"heading2"}),"h2"),Jt=t(v({variant:"heading3"}),"h3"),Kt=t(v({variant:"heading4"}),"h4"),Qt=t(v({variant:"heading5"}),"h5"),Ut=t(v({variant:"heading6"}),"h6"),Vt=t(P({variant:"paragraph1"})),Xt=t(P({variant:"paragraph2"})),Yt=t(P({variant:"paragraph3"})),Zt=t(P({variant:"paragraph4"})),Rt=t(P({variant:"paragraph5"})),te=t(P({variant:"paragraph6"})),ee=t(N({variant:"caption1"})),J=t(N({variant:"caption2"})),ne=t(N({variant:"caption3"})),re=t(N({variant:"caption4"})),ae=t(N({variant:"caption5"})),oe=t(N({variant:"caption6"})),ie=t(F({variant:"subtitle1"})),se=t(F({variant:"subtitle2"})),pe=t(F({variant:"subtitle3"})),ce=t(F({variant:"subtitle4"})),le=t(F({variant:"subtitle5"})),de=t(F({variant:"subtitle6"})),me=t(et()),ue=t(nt()),ge=t(rt({variant:"regular"})),fe=t(G({variant:"regular"}),"span"),he=t(G({variant:"strong"}),"span");var Q,U=(e,n)=>{let a=s=>{if(!n.length)return!0;let l=s.match(/\/([^/]*)/);if(!l)return!1;let S=l[1];return n.indexOf(S)!==-1},o=s=>lt(s)&&a(s);return e.filter(o)},V=(e,n)=>{if(!n?.current)throw new Error("no container ref defined for sitemap");b.select(n.current).html(""),b.select(n.current).append(()=>q(ct(e),{label:a=>a.name.substring(a.name.lastIndexOf("/")+1),link:a=>a.link,width:1152}).node())},ct=e=>{let n=e.reduce((a,o)=>{let i=o.split("/"),s=i.reduce((l,S,d)=>{if(d===0)return l;let m=i.slice(0,d+1).join("/");if(/\/index$/.test(m)||a.some(I=>I.name===m))return l;let y;return d<=1?y="/":y=m.substring(0,m.lastIndexOf("/")),[...l,{name:m,parent:y,data:{name:m,link:o}}]},[]);return[...a,...s]},[{name:"/",parent:void 0,data:{name:"root",link:"/"}}]);return b.stratify().id(a=>a.name).parentId(a=>a.parent)(n)},lt=e=>/\/[^.]*$/.test(e),dt=e=>!e||e.length===0?"All":e.length===1?e[0]:`${e.length} Items Selected`,mt=()=>c.createElement(W,{name:"chevronDown"}),Te=({href:e,initialNamespaceFilters:n=[],...a})=>{let o=K(null),i=K(),[s,l]=T(!0),[,S]=T(!1),[d,m]=T(),[h,y]=T(n),[I,j]=T([]),[L,A]=T(0);at(()=>{if(pt(Q,"Sitemap component is an alpha Lab component and is not ready for Production use"),Q=!0,!i.current)b.json(e).then(p=>{let{slugs:u}=p;l(!1);let x=u.reduce((g,E)=>{let k=E.match(/\/([^/]*)/);if(!k)return g;let w=k[1];return g.indexOf(w)===-1&&g.push(w),g},[]);return i.current=u,j(x),u}).finally(()=>{if(i.current){let p=U(i.current,h);V(p,o),A(p.length)}}).catch(p=>{console.error(p),l(!1),m(p.message)});else{let p=U(i.current,h);V(p,o),A(p.length)}},[e,h]);let H=(p,u)=>{y(u)};return c.createElement("div",{...a},c.createElement("div",{className:O.toolbar},s?null:c.createElement(c.Fragment,null,c.createElement(J,{className:O.pageCount},"Number of pages: ",L),c.createElement(ot,{triggerComponent:c.createElement(it,{IconComponent:mt,label:dt(h)}),width:200,onOpenChange:S,onSelectionChange:H,selectionStrategy:"multiple",source:I}))),c.createElement("div",{className:O.feedback},!d&&s?c.createElement(c.Fragment,null,c.createElement(st,{size:"large"}),"Loading Map"):null,d?c.createElement(c.Fragment,null,"An error occurred: ",d):null),!s&&!d?c.createElement("div",{ref:o}):null)};export{Te as Sitemap};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.pk1hfu0{display:flex;justify-content:flex-end}.pk1hfu1{display:flex;align-items:center;gap:var(--space-vertical-x4);flex-direction:column}.pk1hfu2{margin:auto 0}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var l={toolbar:"pk1hfu0",feedback:"pk1hfu1 pdl72e80 pdl72e81 pdl72e82 pdl72e83 pdl72ebk pdl72ebl pdl72ebm pdl72ebn pdl72edg pdl72edh pdl72edi pdl72edj pdl72e9w pdl72e9x pdl72e9y pdl72e9z",pageCount:"pk1hfu2 pdl72e9s pdl72e9t pdl72e9u pdl72e9v"};export{l as default};
|
package/dist-labs/index.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.pk1hfu0{display:flex;justify-content:flex-end}.pk1hfu1{display:flex;align-items:center;gap:var(--space-vertical-x4);flex-direction:column}.pk1hfu2{margin:auto 0}
|
package/dist-labs/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import rt from"react";import ot from"classnames";import at from"hoist-non-react-statics";var j={none:"pdl72e4 pdl72e5 pdl72e6 pdl72e7",regular:"pdl72eo pdl72ep pdl72eq pdl72er",inline:"pdl72ecs pdl72ect pdl72ecu pdl72ecv"};function $(e,n="regular",r=!1){let a=({className:i="",spacing:s,...l})=>rt.createElement(e,{className:ot(j[s||n],i,{[j.inline]:r}),...l});return at(a,e),a}import W,{useEffect as it}from"react";import{Mermaid as st}from"mdx-mermaid/lib/Mermaid";import pt from"warning";var q;function G({className:e,...n}){return it(()=>{pt(q,"Diagram component is an alpha Lab component and not ready for Production use"),q=!0},[]),W.createElement("div",{className:e},W.createElement(st,{...n}))}import c,{useEffect as ht,useRef as Y,useState as F}from"react";import*as b from"d3";import{Dropdown as xt,DropdownButton as yt,Spinner as vt}from"@salt-ds/lab";import bt from"warning";import K from"react";import{icons as B}from"@jpmorganchase/mosaic-theme";var J={small:"_12vahby0",medium:"_12vahby1",large:"_12vahby2"};var _={tick:"successTick"},Q=({className:e,name:n,size:r="small",...a})=>{if(n==="none")return null;let i=n;if(_[n]&&(console.warn(`icon ${n} has been deprecated and should be replaced by ${_[n]}`),console.warn(`icon ${n} will be removed after March 2023`),i=_[n]),!B||!B[i])throw new Error(`icon ${i} is not supported`);let s=B[i];return K.createElement("span",{className:e,...a},K.createElement(s,{className:J[r]}))};import*as P from"d3";function U(e,{label:n=null,title:r=null,width:a=640,height:i=void 0,r:s=3,padding:l=1,fill:S="#999",stroke:d="#555",strokeWidth:m=1.5,strokeOpacity:h=.4,strokeLinejoin:x=void 0,strokeLinecap:I=void 0,halo:E="#fff",haloWidth:L=3}={}){let D=e.descendants(),M=n==null?null:D.map(o=>n(o.data,o)),p=20,u=a/(e.height+l);P.tree().nodeSize([p,u])(e);let y=1/0,f=-y;e.each(o=>{o.x>f&&(f=o.x),o.x<y&&(y=o.x)});let A=i===void 0?f-y+p*2:i,w=P.create("svg").attr("viewBox",[-u*l/2,y-p,a,A]).attr("width",a).attr("height",A).attr("style","max-width: 100%; height: auto; overflow: visible;").attr("font-family","sans-serif").attr("font-size",10);w.append("g").attr("fill","none").attr("stroke",d).attr("stroke-opacity",h).attr("stroke-linecap",I).attr("stroke-linejoin",x).attr("stroke-width",m).selectAll("path").data(e.links()).join("path").attr("d",P.linkHorizontal().x(o=>o.y).y(o=>o.x));let k=w.append("g").selectAll("a").data(e.descendants()).join("a").attr("transform",o=>`translate(${o.y},${o.x})`);return k.append("circle").attr("fill",o=>o.children?d:S).attr("r",s),r!=null&&k.append("title").text(o=>r(o.data,o)),M&&k.append("text").attr("dy","0.32em").attr("x",o=>o.children?-6:6).attr("text-anchor",o=>o.children?"end":"start").attr("paint-order","stroke").attr("stroke",E).attr("stroke-width",L).text((o,O)=>M[O]).on("click",(o,O)=>{let{data:nt}=O.data;window.open(nt.link,"_blank")}).style("cursor","pointer"),w}var H={toolbar:"pk1hfu0",feedback:"pk1hfu1 pdl72e80 pdl72e81 pdl72e82 pdl72e83 pdl72ebk pdl72ebl pdl72ebm pdl72ebn pdl72edg pdl72edh pdl72edi pdl72edj pdl72e9w pdl72e9x pdl72e9y pdl72e9z",pageCount:"pk1hfu2 pdl72e9s pdl72e9t pdl72e9u pdl72e9v"};import{action as g,amount as ut,caption as C,emphasis as V,eyebrow as ft,heading as v,paragraph as N,subtitle as T,watermark as gt}from"@jpmorganchase/mosaic-theme";import lt from"react";import dt from"classnames";import mt from"hoist-non-react-statics";import ct from"react";var z=function({component:n="p",children:r,...a}){return ct.createElement(n,{...a},r)};function t(e,n="p",r={}){let a=({className:i,...s})=>lt.createElement(z,{className:dt(e,i),component:n,...r,...s});return mt(a,z),a}var re=t(g({variant:"action1"})),oe=t(g({variant:"action2"})),ae=t(g({variant:"action3"})),ie=t(g({variant:"action4"})),se=t(g({variant:"action5"})),pe=t(g({variant:"action6"})),ce=t(g({variant:"action7"})),le=t(g({variant:"action8"})),de=t(v({variant:"heading0"}),"h1"),me=t(v({variant:"heading1"}),"h1"),ue=t(v({variant:"heading2"}),"h2"),fe=t(v({variant:"heading3"}),"h3"),ge=t(v({variant:"heading4"}),"h4"),he=t(v({variant:"heading5"}),"h5"),xe=t(v({variant:"heading6"}),"h6"),ye=t(N({variant:"paragraph1"})),ve=t(N({variant:"paragraph2"})),be=t(N({variant:"paragraph3"})),Se=t(N({variant:"paragraph4"})),we=t(N({variant:"paragraph5"})),ke=t(N({variant:"paragraph6"})),Pe=t(C({variant:"caption1"})),X=t(C({variant:"caption2"})),Ce=t(C({variant:"caption3"})),Ne=t(C({variant:"caption4"})),Te=t(C({variant:"caption5"})),Fe=t(C({variant:"caption6"})),Ie=t(T({variant:"subtitle1"})),De=t(T({variant:"subtitle2"})),Me=t(T({variant:"subtitle3"})),Ae=t(T({variant:"subtitle4"})),He=t(T({variant:"subtitle5"})),Ee=t(T({variant:"subtitle6"})),Le=t(ut()),Oe=t(ft()),je=t(gt({variant:"regular"})),$e=t(V({variant:"regular"}),"span"),Be=t(V({variant:"strong"}),"span");var Z,R=(e,n)=>{let r=s=>{if(!n.length)return!0;let l=s.match(/\/([^/]*)/);if(!l)return!1;let S=l[1];return n.indexOf(S)!==-1},a=s=>wt(s)&&r(s);return e.filter(a)},tt=(e,n)=>{if(!n?.current)throw new Error("no container ref defined for sitemap");b.select(n.current).html(""),b.select(n.current).append(()=>U(St(e),{label:r=>r.name.substring(r.name.lastIndexOf("/")+1),link:r=>r.link,width:1152}).node())},St=e=>{let n=e.reduce((r,a)=>{let i=a.split("/"),s=i.reduce((l,S,d)=>{if(d===0)return l;let m=i.slice(0,d+1).join("/");if(/\/index$/.test(m)||r.some(I=>I.name===m))return l;let x;return d<=1?x="/":x=m.substring(0,m.lastIndexOf("/")),[...l,{name:m,parent:x,data:{name:m,link:a}}]},[]);return[...r,...s]},[{name:"/",parent:void 0,data:{name:"root",link:"/"}}]);return b.stratify().id(r=>r.name).parentId(r=>r.parent)(n)},wt=e=>/\/[^.]*$/.test(e),kt=e=>!e||e.length===0?"All":e.length===1?e[0]:`${e.length} Items Selected`,Pt=()=>c.createElement(Q,{name:"chevronDown"}),et=({href:e,initialNamespaceFilters:n=[],...r})=>{let a=Y(null),i=Y(),[s,l]=F(!0),[,S]=F(!1),[d,m]=F(),[h,x]=F(n),[I,E]=F([]),[L,D]=F(0);ht(()=>{if(bt(Z,"Sitemap component is an alpha Lab component and is not ready for Production use"),Z=!0,!i.current)b.json(e).then(p=>{let{slugs:u}=p;l(!1);let y=u.reduce((f,A)=>{let w=A.match(/\/([^/]*)/);if(!w)return f;let k=w[1];return f.indexOf(k)===-1&&f.push(k),f},[]);return i.current=u,E(y),u}).finally(()=>{if(i.current){let p=R(i.current,h);tt(p,a),D(p.length)}}).catch(p=>{console.error(p),l(!1),m(p.message)});else{let p=R(i.current,h);tt(p,a),D(p.length)}},[e,h]);let M=(p,u)=>{x(u)};return c.createElement("div",{...r},c.createElement("div",{className:H.toolbar},s?null:c.createElement(c.Fragment,null,c.createElement(X,{className:H.pageCount},"Number of pages: ",L),c.createElement(xt,{triggerComponent:c.createElement(yt,{IconComponent:Pt,label:kt(h)}),width:200,onOpenChange:S,onSelectionChange:M,selectionStrategy:"multiple",source:I}))),c.createElement("div",{className:H.feedback},!d&&s?c.createElement(c.Fragment,null,c.createElement(vt,{size:"large"}),"Loading Map"):null,d?c.createElement(c.Fragment,null,"An error occurred: ",d):null),!s&&!d?c.createElement("div",{ref:a}):null)};var en=()=>({Diagram:$(G),Sitemap:$(et)});export{G as Diagram,et as Sitemap,en as getLabMarkdownComponents};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState, createContext, ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
export const lightMode = 'light';
|
|
4
|
-
export const darkMode = 'dark';
|
|
5
|
-
|
|
6
|
-
export type ColorMode = 'dark' | 'light';
|
|
7
|
-
export const themePrefKey = 'mosaic-theme-pref';
|
|
8
|
-
|
|
9
|
-
interface ColorModeContextValues {
|
|
10
|
-
colorMode: ColorMode;
|
|
11
|
-
setColorMode: (colorMode: ColorMode) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const ColorModeContext = createContext<ColorModeContextValues>({
|
|
15
|
-
colorMode: 'light',
|
|
16
|
-
setColorMode: () => undefined
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export function useColorMode(): ColorMode {
|
|
20
|
-
const context = React.useContext(ColorModeContext);
|
|
21
|
-
if (context === undefined) {
|
|
22
|
-
throw new Error('useColorMode must be used within a ColorModeContext');
|
|
23
|
-
}
|
|
24
|
-
return context.colorMode;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function ColorModeProvider({
|
|
28
|
-
children,
|
|
29
|
-
defaultColorMode = lightMode
|
|
30
|
-
}: {
|
|
31
|
-
children: ReactNode;
|
|
32
|
-
defaultColorMode?: ColorMode;
|
|
33
|
-
}) {
|
|
34
|
-
const [colorMode, setColorMode] = useState<ColorMode>(defaultColorMode);
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
let nextColorMode;
|
|
38
|
-
try {
|
|
39
|
-
const chosenMode = localStorage.getItem(themePrefKey);
|
|
40
|
-
const prefersDarkMode = matchMedia('(prefers-color-scheme:dark)').matches
|
|
41
|
-
? 'dark'
|
|
42
|
-
: defaultColorMode;
|
|
43
|
-
// Precedence rules
|
|
44
|
-
// 1. respect user's choice
|
|
45
|
-
// 2. respect user's OS/browser color choice
|
|
46
|
-
// 3. defaultColorMode
|
|
47
|
-
nextColorMode = (chosenMode || prefersDarkMode || defaultColorMode) as ColorMode;
|
|
48
|
-
setColorMode(nextColorMode);
|
|
49
|
-
} catch (e) {
|
|
50
|
-
console.error(`Could not set default color mode to ${nextColorMode}`);
|
|
51
|
-
}
|
|
52
|
-
}, [defaultColorMode]);
|
|
53
|
-
|
|
54
|
-
const value = useMemo(
|
|
55
|
-
() => ({
|
|
56
|
-
colorMode,
|
|
57
|
-
setColorMode: (nextColorMode: ColorMode) => {
|
|
58
|
-
setColorMode(nextColorMode);
|
|
59
|
-
try {
|
|
60
|
-
localStorage.setItem(themePrefKey, nextColorMode);
|
|
61
|
-
} catch (e) {
|
|
62
|
-
console.error(`Could not persist default color mode ${nextColorMode} in local storage`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}),
|
|
66
|
-
[colorMode, setColorMode]
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
return <ColorModeContext.Provider value={value}>{children}</ColorModeContext.Provider>;
|
|
70
|
-
}
|
package/src/labs/Diagram.tsx
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import { Mermaid, MermaidProps } from 'mdx-mermaid/lib/Mermaid';
|
|
3
|
-
import warning from 'warning';
|
|
4
|
-
|
|
5
|
-
let warnOnce: boolean;
|
|
6
|
-
|
|
7
|
-
export interface DiagramProps extends MermaidProps {
|
|
8
|
-
/* Mermaid diagram refer to https://sjwall.github.io/mdx-mermaid/docs/intro/ */
|
|
9
|
-
className?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function Diagram({ className, ...rest }: DiagramProps) {
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
warning(
|
|
15
|
-
warnOnce,
|
|
16
|
-
'Diagram component is an alpha Lab component and not ready for Production use'
|
|
17
|
-
);
|
|
18
|
-
warnOnce = true;
|
|
19
|
-
}, []);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<div className={className}>
|
|
23
|
-
<Mermaid {...rest} />
|
|
24
|
-
</div>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
// TODO - enable TS for this file
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
import * as d3 from 'd3';
|
|
4
|
-
|
|
5
|
-
// Forked from https://observablehq.com/@d3/tree
|
|
6
|
-
export function drawTree(
|
|
7
|
-
root: any,
|
|
8
|
-
{
|
|
9
|
-
/**
|
|
10
|
-
* label: given a node d, returns the display name
|
|
11
|
-
*/
|
|
12
|
-
label = null,
|
|
13
|
-
/**
|
|
14
|
-
* title: given a node d, returns its hover text
|
|
15
|
-
*/
|
|
16
|
-
title = null,
|
|
17
|
-
/**
|
|
18
|
-
* width: outer width, in pixels
|
|
19
|
-
*/
|
|
20
|
-
width = 640,
|
|
21
|
-
/**
|
|
22
|
-
* height: outer height, in pixels
|
|
23
|
-
*/
|
|
24
|
-
height = undefined,
|
|
25
|
-
/**
|
|
26
|
-
* radius: radius of nodes
|
|
27
|
-
*/
|
|
28
|
-
r = 3,
|
|
29
|
-
/**
|
|
30
|
-
* padding: horizontal padding for first and last column
|
|
31
|
-
*/
|
|
32
|
-
padding = 1,
|
|
33
|
-
/**
|
|
34
|
-
* fill: fill for nodes
|
|
35
|
-
*/
|
|
36
|
-
fill = '#999',
|
|
37
|
-
/**
|
|
38
|
-
* stroke: stroke for links
|
|
39
|
-
*/
|
|
40
|
-
stroke = '#555',
|
|
41
|
-
/**
|
|
42
|
-
* strokeWidth: stroke width for links
|
|
43
|
-
*/
|
|
44
|
-
strokeWidth = 1.5,
|
|
45
|
-
/**
|
|
46
|
-
* strokeOpacity: stroke opacity for links
|
|
47
|
-
*/
|
|
48
|
-
strokeOpacity = 0.4,
|
|
49
|
-
/**
|
|
50
|
-
* strokeLinejoin: stroke line join for links
|
|
51
|
-
*/
|
|
52
|
-
strokeLinejoin = undefined,
|
|
53
|
-
/**
|
|
54
|
-
* strokeLinecap: stroke line cap for links
|
|
55
|
-
*/
|
|
56
|
-
strokeLinecap = undefined,
|
|
57
|
-
/**
|
|
58
|
-
* halo: color of label halo
|
|
59
|
-
*/
|
|
60
|
-
halo = '#fff',
|
|
61
|
-
/**
|
|
62
|
-
* haloWidth: padding around the labels
|
|
63
|
-
*/
|
|
64
|
-
haloWidth = 3
|
|
65
|
-
}: {
|
|
66
|
-
label?: ((data: any, node: any) => string) | null;
|
|
67
|
-
title?: ((data: any, node: any) => string) | null;
|
|
68
|
-
link?: ((data: any, node: any) => string) | null;
|
|
69
|
-
linkTarget?: string;
|
|
70
|
-
width?: number;
|
|
71
|
-
height?: number;
|
|
72
|
-
r?: number;
|
|
73
|
-
padding?: number;
|
|
74
|
-
fill?: string;
|
|
75
|
-
stroke?: string;
|
|
76
|
-
strokeWidth?: number;
|
|
77
|
-
strokeOpacity?: number;
|
|
78
|
-
strokeLinejoin?: string;
|
|
79
|
-
strokeLinecap?: string;
|
|
80
|
-
halo?: string;
|
|
81
|
-
haloWidth?: number;
|
|
82
|
-
} = {}
|
|
83
|
-
) {
|
|
84
|
-
// Compute labels and titles.
|
|
85
|
-
const descendants = root.descendants();
|
|
86
|
-
const L = label == null ? null : descendants.map(d => label(d.data, d));
|
|
87
|
-
|
|
88
|
-
// Compute the layout.
|
|
89
|
-
const dx = 20;
|
|
90
|
-
const dy = width / (root.height + padding);
|
|
91
|
-
d3.tree().nodeSize([dx, dy])(root);
|
|
92
|
-
|
|
93
|
-
// Center the tree.
|
|
94
|
-
let x0 = Infinity;
|
|
95
|
-
let x1 = -x0;
|
|
96
|
-
root.each(d => {
|
|
97
|
-
if (d.x > x1) x1 = d.x;
|
|
98
|
-
if (d.x < x0) x0 = d.x;
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Compute the default height.
|
|
102
|
-
const computedHeight = height === undefined ? x1 - x0 + dx * 2 : height;
|
|
103
|
-
|
|
104
|
-
const svg = d3
|
|
105
|
-
.create('svg')
|
|
106
|
-
.attr('viewBox', [(-dy * padding) / 2, x0 - dx, width, computedHeight])
|
|
107
|
-
.attr('width', width)
|
|
108
|
-
.attr('height', computedHeight)
|
|
109
|
-
.attr('style', 'max-width: 100%; height: auto; overflow: visible;')
|
|
110
|
-
.attr('font-family', 'sans-serif')
|
|
111
|
-
.attr('font-size', 10);
|
|
112
|
-
|
|
113
|
-
svg
|
|
114
|
-
.append('g')
|
|
115
|
-
.attr('fill', 'none')
|
|
116
|
-
.attr('stroke', stroke)
|
|
117
|
-
.attr('stroke-opacity', strokeOpacity)
|
|
118
|
-
.attr('stroke-linecap', strokeLinecap)
|
|
119
|
-
.attr('stroke-linejoin', strokeLinejoin)
|
|
120
|
-
.attr('stroke-width', strokeWidth)
|
|
121
|
-
.selectAll('path')
|
|
122
|
-
.data(root.links())
|
|
123
|
-
.join('path')
|
|
124
|
-
.attr(
|
|
125
|
-
'd',
|
|
126
|
-
d3
|
|
127
|
-
.linkHorizontal()
|
|
128
|
-
.x(d => d.y)
|
|
129
|
-
.y(d => d.x)
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
const node = svg
|
|
133
|
-
.append('g')
|
|
134
|
-
.selectAll('a')
|
|
135
|
-
.data(root.descendants())
|
|
136
|
-
.join('a')
|
|
137
|
-
.attr('transform', d => `translate(${d.y},${d.x})`);
|
|
138
|
-
|
|
139
|
-
node
|
|
140
|
-
.append('circle')
|
|
141
|
-
.attr('fill', d => (d.children ? stroke : fill))
|
|
142
|
-
.attr('r', r);
|
|
143
|
-
|
|
144
|
-
if (title != null) node.append('title').text(d => title(d.data, d));
|
|
145
|
-
|
|
146
|
-
if (L) {
|
|
147
|
-
node
|
|
148
|
-
.append('text')
|
|
149
|
-
.attr('dy', '0.32em')
|
|
150
|
-
.attr('x', d => (d.children ? -6 : 6))
|
|
151
|
-
.attr('text-anchor', d => (d.children ? 'end' : 'start'))
|
|
152
|
-
.attr('paint-order', 'stroke')
|
|
153
|
-
.attr('stroke', halo)
|
|
154
|
-
.attr('stroke-width', haloWidth)
|
|
155
|
-
.text((_d, i) => L[i])
|
|
156
|
-
.on('click', (_event, clickedNode) => {
|
|
157
|
-
const { data: userdata } = clickedNode.data;
|
|
158
|
-
window.open(userdata.link, '_blank');
|
|
159
|
-
})
|
|
160
|
-
.style('cursor', 'pointer');
|
|
161
|
-
}
|
|
162
|
-
return svg;
|
|
163
|
-
}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import React, { RefObject, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import * as d3 from 'd3';
|
|
3
|
-
import { Dropdown, DropdownButton, SelectionChangeHandler, Spinner } from '@salt-ds/lab';
|
|
4
|
-
import warning from 'warning';
|
|
5
|
-
import { Icon } from '../../Icon';
|
|
6
|
-
|
|
7
|
-
import { drawTree } from './drawTree';
|
|
8
|
-
import styles from './styles.css';
|
|
9
|
-
import { Caption2 } from '../../Typography';
|
|
10
|
-
|
|
11
|
-
let warnOnce: boolean;
|
|
12
|
-
|
|
13
|
-
export interface SitemapProps {
|
|
14
|
-
/** Additional class name for overrides */
|
|
15
|
-
className?: string;
|
|
16
|
-
/** The url of the file system */
|
|
17
|
-
href: string;
|
|
18
|
-
/** Initial namespace filters */
|
|
19
|
-
initialNamespaceFilters?: string[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const filterPaths = (slugs: string[], namespaceFilters: string[]) => {
|
|
23
|
-
const namespaceFilter = (pagePath: string) => {
|
|
24
|
-
if (!namespaceFilters.length) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
const pageNamespaceMatches = pagePath.match(/\/([^/]*)/);
|
|
28
|
-
if (!pageNamespaceMatches) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
const pageNamespace = pageNamespaceMatches[1];
|
|
32
|
-
return namespaceFilters.indexOf(pageNamespace) !== -1;
|
|
33
|
-
};
|
|
34
|
-
const customFilter = (pagePath: string) =>
|
|
35
|
-
dottedFileFilter(pagePath) && namespaceFilter(pagePath);
|
|
36
|
-
const filteredPaths = slugs.filter(customFilter);
|
|
37
|
-
return filteredPaths;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const drawSitemap = (filteredPaths: string[], containerRef: RefObject<HTMLDivElement>) => {
|
|
41
|
-
if (!containerRef?.current) {
|
|
42
|
-
throw new Error('no container ref defined for sitemap');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
d3.select(containerRef.current).html('');
|
|
46
|
-
d3.select(containerRef.current).append(() =>
|
|
47
|
-
drawTree(parseFileSystem(filteredPaths), {
|
|
48
|
-
label: node => node.name.substring(node.name.lastIndexOf('/') + 1),
|
|
49
|
-
link: node => node.link,
|
|
50
|
-
width: 1152
|
|
51
|
-
}).node()
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
type FileSystemBase = {
|
|
56
|
-
name: string;
|
|
57
|
-
parent: string | undefined;
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
-
data: any;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
interface FileSystemItem extends FileSystemBase {
|
|
63
|
-
children: FileSystemItem[];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const parseFileSystem = (fileSystem: any) => {
|
|
67
|
-
// We create an node in the hieracy for entry in the file-system
|
|
68
|
-
// hierachyData is of the form
|
|
69
|
-
// [...{ name: <node name>, parent: <node name>, { data: <node data object> }]
|
|
70
|
-
const hierachyData = fileSystem.reduce(
|
|
71
|
-
(result: FileSystemBase[], path: string) => {
|
|
72
|
-
const pathParts = path.split('/');
|
|
73
|
-
const flattenedPaths = pathParts.reduce<FileSystemBase[]>(
|
|
74
|
-
(partsResults, _path: string, pathIndex: number) => {
|
|
75
|
-
if (pathIndex === 0) {
|
|
76
|
-
return partsResults;
|
|
77
|
-
}
|
|
78
|
-
const name = pathParts.slice(0, pathIndex + 1).join('/');
|
|
79
|
-
const isIndex = /\/index$/.test(name);
|
|
80
|
-
// Ignore indexes, as the node is represented by the directory
|
|
81
|
-
// Ignore duplicates
|
|
82
|
-
if (
|
|
83
|
-
isIndex ||
|
|
84
|
-
result.some((existingItem: FileSystemBase) => existingItem.name === name)
|
|
85
|
-
) {
|
|
86
|
-
return partsResults;
|
|
87
|
-
}
|
|
88
|
-
let parent;
|
|
89
|
-
// If a namespace then parent is root
|
|
90
|
-
if (pathIndex <= 1) {
|
|
91
|
-
parent = '/';
|
|
92
|
-
} else {
|
|
93
|
-
parent = name.substring(0, name.lastIndexOf('/'));
|
|
94
|
-
}
|
|
95
|
-
// Add node specific data as required to
|
|
96
|
-
// { ... data: { <node data> } }
|
|
97
|
-
return [...partsResults, { name, parent, data: { name, link: path } }];
|
|
98
|
-
},
|
|
99
|
-
[]
|
|
100
|
-
);
|
|
101
|
-
return [...result, ...flattenedPaths];
|
|
102
|
-
},
|
|
103
|
-
[{ name: '/', parent: undefined, data: { name: 'root', link: '/' } }]
|
|
104
|
-
);
|
|
105
|
-
return d3
|
|
106
|
-
.stratify()
|
|
107
|
-
.id((data: FileSystemItem) => data.name)
|
|
108
|
-
.parentId((data: FileSystemItem) => data.parent)(hierachyData);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const dottedFileFilter = (pagePath: string) => /\/[^.]*$/.test(pagePath);
|
|
112
|
-
|
|
113
|
-
const filterButtonLabel = (selectedItems: string[] | undefined) => {
|
|
114
|
-
if (!selectedItems || selectedItems.length === 0) {
|
|
115
|
-
return 'All';
|
|
116
|
-
}
|
|
117
|
-
if (selectedItems.length === 1) {
|
|
118
|
-
return selectedItems[0];
|
|
119
|
-
}
|
|
120
|
-
return `${selectedItems.length} Items Selected`;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const DropdownIcon = () => <Icon name="chevronDown" />;
|
|
124
|
-
|
|
125
|
-
export const Sitemap: React.FC<SitemapProps> = ({
|
|
126
|
-
href,
|
|
127
|
-
initialNamespaceFilters = [],
|
|
128
|
-
...rest
|
|
129
|
-
}: SitemapProps) => {
|
|
130
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
131
|
-
const dataRef = useRef<string[]>();
|
|
132
|
-
const [loading, setLoading] = useState<boolean>(true);
|
|
133
|
-
const [, setIsOpen] = useState(false);
|
|
134
|
-
const [error, setError] = useState<string>();
|
|
135
|
-
const [namespaceFilters, setNamespaceFilters] = useState<string[]>(initialNamespaceFilters);
|
|
136
|
-
const [namespaces, setNamespaces] = useState<string[]>([]);
|
|
137
|
-
const [pageCount, setPageCount] = useState(0);
|
|
138
|
-
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
warning(
|
|
141
|
-
warnOnce,
|
|
142
|
-
'Sitemap component is an alpha Lab component and is not ready for Production use'
|
|
143
|
-
);
|
|
144
|
-
warnOnce = true;
|
|
145
|
-
|
|
146
|
-
if (!dataRef.current) {
|
|
147
|
-
d3.json(href)
|
|
148
|
-
.then((siteJSON: any) => {
|
|
149
|
-
const { slugs } = siteJSON;
|
|
150
|
-
setLoading(false);
|
|
151
|
-
const loadedNamespaces = slugs.reduce((namespaceResult, pagePath) => {
|
|
152
|
-
const pageNamespaceMatches = pagePath.match(/\/([^/]*)/);
|
|
153
|
-
if (!pageNamespaceMatches) {
|
|
154
|
-
return namespaceResult;
|
|
155
|
-
}
|
|
156
|
-
const pageNamespace: string = pageNamespaceMatches[1];
|
|
157
|
-
if (namespaceResult.indexOf(pageNamespace) === -1) {
|
|
158
|
-
namespaceResult.push(pageNamespace);
|
|
159
|
-
}
|
|
160
|
-
return namespaceResult;
|
|
161
|
-
}, []);
|
|
162
|
-
dataRef.current = slugs;
|
|
163
|
-
setNamespaces(loadedNamespaces);
|
|
164
|
-
return slugs;
|
|
165
|
-
})
|
|
166
|
-
.finally(() => {
|
|
167
|
-
if (dataRef.current) {
|
|
168
|
-
const filteredPaths = filterPaths(dataRef.current, namespaceFilters);
|
|
169
|
-
drawSitemap(filteredPaths, containerRef);
|
|
170
|
-
setPageCount(filteredPaths.length);
|
|
171
|
-
}
|
|
172
|
-
})
|
|
173
|
-
.catch((loadingError: Error) => {
|
|
174
|
-
console.error(loadingError);
|
|
175
|
-
setLoading(false);
|
|
176
|
-
setError(loadingError.message);
|
|
177
|
-
});
|
|
178
|
-
} else {
|
|
179
|
-
const filteredPaths = filterPaths(dataRef.current, namespaceFilters);
|
|
180
|
-
drawSitemap(filteredPaths, containerRef);
|
|
181
|
-
setPageCount(filteredPaths.length);
|
|
182
|
-
}
|
|
183
|
-
}, [href, namespaceFilters]);
|
|
184
|
-
|
|
185
|
-
const handleSelect: SelectionChangeHandler<string, 'multiple'> = (_e, selectedItems) => {
|
|
186
|
-
setNamespaceFilters(selectedItems);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
return (
|
|
190
|
-
<div {...rest}>
|
|
191
|
-
<div className={styles.toolbar}>
|
|
192
|
-
{!loading ? (
|
|
193
|
-
<>
|
|
194
|
-
<Caption2 className={styles.pageCount}>Number of pages: {pageCount}</Caption2>
|
|
195
|
-
<Dropdown
|
|
196
|
-
triggerComponent={
|
|
197
|
-
<DropdownButton
|
|
198
|
-
IconComponent={DropdownIcon}
|
|
199
|
-
label={filterButtonLabel(namespaceFilters)}
|
|
200
|
-
/>
|
|
201
|
-
}
|
|
202
|
-
width={200}
|
|
203
|
-
onOpenChange={setIsOpen}
|
|
204
|
-
onSelectionChange={handleSelect}
|
|
205
|
-
selectionStrategy="multiple"
|
|
206
|
-
source={namespaces}
|
|
207
|
-
/>
|
|
208
|
-
</>
|
|
209
|
-
) : null}
|
|
210
|
-
</div>
|
|
211
|
-
<div className={styles.feedback}>
|
|
212
|
-
{!error && loading ? (
|
|
213
|
-
<>
|
|
214
|
-
<Spinner size="large" />
|
|
215
|
-
Loading Map
|
|
216
|
-
</>
|
|
217
|
-
) : null}
|
|
218
|
-
{error ? <>An error occurred: {error}</> : null}
|
|
219
|
-
</div>
|
|
220
|
-
{!loading && !error ? <div ref={containerRef} /> : null}
|
|
221
|
-
</div>
|
|
222
|
-
);
|
|
223
|
-
};
|