@pareto-engineering/design-system 4.0.0-alpha.20 → 4.0.0-alpha.21
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/dist/cjs/a/ContentTree/ContentTree.js +8 -2
- package/dist/cjs/a/ContentTree/common/Tree/Tree.js +12 -5
- package/dist/cjs/a/ContentTree/styles.scss +24 -14
- package/dist/es/a/ContentTree/ContentTree.js +8 -2
- package/dist/es/a/ContentTree/common/Tree/Tree.js +12 -5
- package/dist/es/a/ContentTree/styles.scss +24 -14
- package/package.json +2 -2
- package/src/ui/a/ContentTree/ContentTree.jsx +7 -3
- package/src/ui/a/ContentTree/common/Tree/Tree.jsx +19 -7
- package/src/ui/a/ContentTree/styles.scss +24 -14
- package/tests/__snapshots__/Storyshots.test.js.snap +1 -5
|
@@ -23,7 +23,8 @@ const ContentTree = _ref => {
|
|
|
23
23
|
className: userClassName,
|
|
24
24
|
style,
|
|
25
25
|
target,
|
|
26
|
-
selectors
|
|
26
|
+
selectors,
|
|
27
|
+
color
|
|
27
28
|
// ...otherProps
|
|
28
29
|
} = _ref;
|
|
29
30
|
(0, React.useInsertionEffect)(() => {
|
|
@@ -36,6 +37,7 @@ const ContentTree = _ref => {
|
|
|
36
37
|
style: style
|
|
37
38
|
// {...otherProps}
|
|
38
39
|
}, /*#__PURE__*/React.createElement(_common.Tree, {
|
|
40
|
+
color: color,
|
|
39
41
|
tree: contentTree
|
|
40
42
|
}));
|
|
41
43
|
};
|
|
@@ -61,7 +63,11 @@ ContentTree.propTypes = {
|
|
|
61
63
|
*/
|
|
62
64
|
target: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
63
65
|
current: _propTypes.default.node
|
|
64
|
-
})])
|
|
66
|
+
})]),
|
|
67
|
+
/**
|
|
68
|
+
* The color for the tree.
|
|
69
|
+
*/
|
|
70
|
+
color: _propTypes.default.string
|
|
65
71
|
};
|
|
66
72
|
ContentTree.defaultProps = {
|
|
67
73
|
selectors: ['h2', 'h3']
|
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
10
|
+
var _ = require("../../../..");
|
|
10
11
|
var _useFirstVisibleNode = _interopRequireDefault(require("../useFirstVisibleNode"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -27,7 +28,8 @@ const Tree = _ref => {
|
|
|
27
28
|
className: userClassName,
|
|
28
29
|
style,
|
|
29
30
|
tree,
|
|
30
|
-
displayDepth
|
|
31
|
+
displayDepth,
|
|
32
|
+
color
|
|
31
33
|
// ...otherProps
|
|
32
34
|
} = _ref;
|
|
33
35
|
// The nodeIds to be used to get the first visible node
|
|
@@ -62,11 +64,11 @@ const Tree = _ref => {
|
|
|
62
64
|
}, node.text)), node.children.length > 0 && /*#__PURE__*/React.createElement("ul", null, node.children.map(child => getNestedTree(child, depth - 1))));
|
|
63
65
|
};
|
|
64
66
|
const ContentTree = (0, React.useMemo)(() => tree.map(node => getNestedTree(node, displayDepth)), [tree]);
|
|
65
|
-
return /*#__PURE__*/React.createElement(
|
|
67
|
+
return ContentTree.length ? /*#__PURE__*/React.createElement(_.Card, {
|
|
66
68
|
id: id,
|
|
67
|
-
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
69
|
+
className: [baseClassName, componentClassName, userClassName, color && `x-${color}`].filter(e => e).join(' '),
|
|
68
70
|
style: style
|
|
69
|
-
}, ContentTree);
|
|
71
|
+
}, /*#__PURE__*/React.createElement(_.Card.Section, null, /*#__PURE__*/React.createElement("ul", null, ContentTree))) : null;
|
|
70
72
|
};
|
|
71
73
|
Tree.propTypes = {
|
|
72
74
|
/**
|
|
@@ -95,9 +97,14 @@ Tree.propTypes = {
|
|
|
95
97
|
/**
|
|
96
98
|
* The levels of the tree to display.
|
|
97
99
|
*/
|
|
98
|
-
displayDepth: _propTypes.default.number
|
|
100
|
+
displayDepth: _propTypes.default.number,
|
|
101
|
+
/**
|
|
102
|
+
* The color of the tree.
|
|
103
|
+
*/
|
|
104
|
+
color: _propTypes.default.string
|
|
99
105
|
};
|
|
100
106
|
Tree.defaultProps = {
|
|
107
|
+
color: 'interactive',
|
|
101
108
|
displayDepth: 4
|
|
102
109
|
};
|
|
103
110
|
var _default = Tree;
|
|
@@ -3,26 +3,38 @@
|
|
|
3
3
|
|
|
4
4
|
@use "@pareto-engineering/bem";
|
|
5
5
|
|
|
6
|
+
$default-dot-size: .5em;
|
|
6
7
|
$default-margin: 1em;
|
|
7
8
|
$default-padding: 1em;
|
|
8
9
|
|
|
9
10
|
.#{bem.$base}.content-tree {
|
|
10
|
-
|
|
11
|
-
list-style: none;
|
|
12
|
-
|
|
13
|
-
> li > p > a {
|
|
14
|
-
color: var(--paragraph);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.#{bem.$base}.tree {
|
|
19
|
-
padding: 0;
|
|
11
|
+
> .#{bem.$base}.tree {
|
|
20
12
|
position: sticky;
|
|
21
13
|
top: 0;
|
|
22
14
|
|
|
15
|
+
ul {
|
|
16
|
+
list-style: none;
|
|
17
|
+
padding: 0 $default-padding;
|
|
18
|
+
|
|
19
|
+
> li > p > a {
|
|
20
|
+
color: var(--paragraph);
|
|
21
|
+
text-decoration: none;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
23
25
|
.#{bem.$modifier-active} {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
font-weight: 700;
|
|
27
|
+
|
|
28
|
+
&::before {
|
|
29
|
+
background: var(--x);
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
content: "";
|
|
32
|
+
display: inline-block;
|
|
33
|
+
height: $default-dot-size;
|
|
34
|
+
margin-right: $default-margin;
|
|
35
|
+
text-align: center;
|
|
36
|
+
width: $default-dot-size;
|
|
37
|
+
}
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
li:not(:last-child) {
|
|
@@ -34,5 +46,3 @@ $default-padding: 1em;
|
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
|
-
|
|
38
|
-
|
|
@@ -17,7 +17,8 @@ const ContentTree = ({
|
|
|
17
17
|
className: userClassName,
|
|
18
18
|
style,
|
|
19
19
|
target,
|
|
20
|
-
selectors
|
|
20
|
+
selectors,
|
|
21
|
+
color
|
|
21
22
|
// ...otherProps
|
|
22
23
|
}) => {
|
|
23
24
|
useInsertionEffect(() => {
|
|
@@ -30,6 +31,7 @@ const ContentTree = ({
|
|
|
30
31
|
style: style
|
|
31
32
|
// {...otherProps}
|
|
32
33
|
}, /*#__PURE__*/React.createElement(Tree, {
|
|
34
|
+
color: color,
|
|
33
35
|
tree: contentTree
|
|
34
36
|
}));
|
|
35
37
|
};
|
|
@@ -55,7 +57,11 @@ ContentTree.propTypes = {
|
|
|
55
57
|
*/
|
|
56
58
|
target: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
57
59
|
current: PropTypes.node
|
|
58
|
-
})])
|
|
60
|
+
})]),
|
|
61
|
+
/**
|
|
62
|
+
* The color for the tree.
|
|
63
|
+
*/
|
|
64
|
+
color: PropTypes.string
|
|
59
65
|
};
|
|
60
66
|
ContentTree.defaultProps = {
|
|
61
67
|
selectors: ['h2', 'h3']
|
|
@@ -3,6 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useState, useEffect, useMemo } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import styleNames from '@pareto-engineering/bem/exports';
|
|
6
|
+
import { Card } from "../../../..";
|
|
6
7
|
|
|
7
8
|
// Local Definitions
|
|
8
9
|
|
|
@@ -18,7 +19,8 @@ const Tree = ({
|
|
|
18
19
|
className: userClassName,
|
|
19
20
|
style,
|
|
20
21
|
tree,
|
|
21
|
-
displayDepth
|
|
22
|
+
displayDepth,
|
|
23
|
+
color
|
|
22
24
|
// ...otherProps
|
|
23
25
|
}) => {
|
|
24
26
|
// The nodeIds to be used to get the first visible node
|
|
@@ -53,11 +55,11 @@ const Tree = ({
|
|
|
53
55
|
}, node.text)), node.children.length > 0 && /*#__PURE__*/React.createElement("ul", null, node.children.map(child => getNestedTree(child, depth - 1))));
|
|
54
56
|
};
|
|
55
57
|
const ContentTree = useMemo(() => tree.map(node => getNestedTree(node, displayDepth)), [tree]);
|
|
56
|
-
return /*#__PURE__*/React.createElement(
|
|
58
|
+
return ContentTree.length ? /*#__PURE__*/React.createElement(Card, {
|
|
57
59
|
id: id,
|
|
58
|
-
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
60
|
+
className: [baseClassName, componentClassName, userClassName, color && `x-${color}`].filter(e => e).join(' '),
|
|
59
61
|
style: style
|
|
60
|
-
}, ContentTree);
|
|
62
|
+
}, /*#__PURE__*/React.createElement(Card.Section, null, /*#__PURE__*/React.createElement("ul", null, ContentTree))) : null;
|
|
61
63
|
};
|
|
62
64
|
Tree.propTypes = {
|
|
63
65
|
/**
|
|
@@ -86,9 +88,14 @@ Tree.propTypes = {
|
|
|
86
88
|
/**
|
|
87
89
|
* The levels of the tree to display.
|
|
88
90
|
*/
|
|
89
|
-
displayDepth: PropTypes.number
|
|
91
|
+
displayDepth: PropTypes.number,
|
|
92
|
+
/**
|
|
93
|
+
* The color of the tree.
|
|
94
|
+
*/
|
|
95
|
+
color: PropTypes.string
|
|
90
96
|
};
|
|
91
97
|
Tree.defaultProps = {
|
|
98
|
+
color: 'interactive',
|
|
92
99
|
displayDepth: 4
|
|
93
100
|
};
|
|
94
101
|
export default Tree;
|
|
@@ -3,26 +3,38 @@
|
|
|
3
3
|
|
|
4
4
|
@use "@pareto-engineering/bem";
|
|
5
5
|
|
|
6
|
+
$default-dot-size: .5em;
|
|
6
7
|
$default-margin: 1em;
|
|
7
8
|
$default-padding: 1em;
|
|
8
9
|
|
|
9
10
|
.#{bem.$base}.content-tree {
|
|
10
|
-
|
|
11
|
-
list-style: none;
|
|
12
|
-
|
|
13
|
-
> li > p > a {
|
|
14
|
-
color: var(--paragraph);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.#{bem.$base}.tree {
|
|
19
|
-
padding: 0;
|
|
11
|
+
> .#{bem.$base}.tree {
|
|
20
12
|
position: sticky;
|
|
21
13
|
top: 0;
|
|
22
14
|
|
|
15
|
+
ul {
|
|
16
|
+
list-style: none;
|
|
17
|
+
padding: 0 $default-padding;
|
|
18
|
+
|
|
19
|
+
> li > p > a {
|
|
20
|
+
color: var(--paragraph);
|
|
21
|
+
text-decoration: none;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
23
25
|
.#{bem.$modifier-active} {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
font-weight: 700;
|
|
27
|
+
|
|
28
|
+
&::before {
|
|
29
|
+
background: var(--x);
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
content: "";
|
|
32
|
+
display: inline-block;
|
|
33
|
+
height: $default-dot-size;
|
|
34
|
+
margin-right: $default-margin;
|
|
35
|
+
text-align: center;
|
|
36
|
+
width: $default-dot-size;
|
|
37
|
+
}
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
li:not(:last-child) {
|
|
@@ -34,5 +46,3 @@ $default-padding: 1em;
|
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
|
-
|
|
38
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pareto-engineering/design-system",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.21",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/es/index.js",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"relay-test-utils": "^15.0.0"
|
|
68
68
|
},
|
|
69
69
|
"browserslist": "> 2%",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "470f5e6dbe7b4b4da5f6e066303e9a41a744583e"
|
|
71
71
|
}
|
|
@@ -23,6 +23,7 @@ const ContentTree = ({
|
|
|
23
23
|
style,
|
|
24
24
|
target,
|
|
25
25
|
selectors,
|
|
26
|
+
color,
|
|
26
27
|
// ...otherProps
|
|
27
28
|
}) => {
|
|
28
29
|
useInsertionEffect(() => {
|
|
@@ -35,9 +36,7 @@ const ContentTree = ({
|
|
|
35
36
|
<div
|
|
36
37
|
id={id}
|
|
37
38
|
className={[
|
|
38
|
-
|
|
39
39
|
baseClassName,
|
|
40
|
-
|
|
41
40
|
componentClassName,
|
|
42
41
|
userClassName,
|
|
43
42
|
]
|
|
@@ -46,7 +45,7 @@ const ContentTree = ({
|
|
|
46
45
|
style={style}
|
|
47
46
|
// {...otherProps}
|
|
48
47
|
>
|
|
49
|
-
<Tree tree={contentTree} />
|
|
48
|
+
<Tree color={color} tree={contentTree} />
|
|
50
49
|
</div>
|
|
51
50
|
)
|
|
52
51
|
}
|
|
@@ -79,6 +78,11 @@ ContentTree.propTypes = {
|
|
|
79
78
|
PropTypes.func,
|
|
80
79
|
PropTypes.shape({ current: PropTypes.node }),
|
|
81
80
|
]),
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The color for the tree.
|
|
84
|
+
*/
|
|
85
|
+
color:PropTypes.string,
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
ContentTree.defaultProps = {
|
|
@@ -7,6 +7,8 @@ import PropTypes from 'prop-types'
|
|
|
7
7
|
|
|
8
8
|
import styleNames from '@pareto-engineering/bem/exports'
|
|
9
9
|
|
|
10
|
+
import { Card } from 'ui'
|
|
11
|
+
|
|
10
12
|
// Local Definitions
|
|
11
13
|
|
|
12
14
|
import useFirstVisibleNode from '../useFirstVisibleNode'
|
|
@@ -24,6 +26,7 @@ const Tree = ({
|
|
|
24
26
|
style,
|
|
25
27
|
tree,
|
|
26
28
|
displayDepth,
|
|
29
|
+
color,
|
|
27
30
|
// ...otherProps
|
|
28
31
|
}) => {
|
|
29
32
|
// The nodeIds to be used to get the first visible node
|
|
@@ -80,23 +83,26 @@ const Tree = ({
|
|
|
80
83
|
[tree],
|
|
81
84
|
)
|
|
82
85
|
|
|
83
|
-
return (
|
|
84
|
-
<
|
|
86
|
+
return ContentTree.length ? (
|
|
87
|
+
<Card
|
|
85
88
|
id={id}
|
|
86
89
|
className={[
|
|
87
|
-
|
|
88
90
|
baseClassName,
|
|
89
|
-
|
|
90
91
|
componentClassName,
|
|
91
92
|
userClassName,
|
|
93
|
+
color && `x-${color}`,
|
|
92
94
|
]
|
|
93
95
|
.filter((e) => e)
|
|
94
96
|
.join(' ')}
|
|
95
97
|
style={style}
|
|
96
98
|
>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
<Card.Section>
|
|
100
|
+
<ul>
|
|
101
|
+
{ContentTree}
|
|
102
|
+
</ul>
|
|
103
|
+
</Card.Section>
|
|
104
|
+
</Card>
|
|
105
|
+
) : null
|
|
100
106
|
}
|
|
101
107
|
Tree.propTypes = {
|
|
102
108
|
/**
|
|
@@ -129,9 +135,15 @@ Tree.propTypes = {
|
|
|
129
135
|
* The levels of the tree to display.
|
|
130
136
|
*/
|
|
131
137
|
displayDepth:PropTypes.number,
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The color of the tree.
|
|
141
|
+
*/
|
|
142
|
+
color:PropTypes.string,
|
|
132
143
|
}
|
|
133
144
|
|
|
134
145
|
Tree.defaultProps = {
|
|
146
|
+
color :'interactive',
|
|
135
147
|
displayDepth:4,
|
|
136
148
|
}
|
|
137
149
|
|
|
@@ -3,26 +3,38 @@
|
|
|
3
3
|
|
|
4
4
|
@use "@pareto-engineering/bem";
|
|
5
5
|
|
|
6
|
+
$default-dot-size: .5em;
|
|
6
7
|
$default-margin: 1em;
|
|
7
8
|
$default-padding: 1em;
|
|
8
9
|
|
|
9
10
|
.#{bem.$base}.content-tree {
|
|
10
|
-
|
|
11
|
-
list-style: none;
|
|
12
|
-
|
|
13
|
-
> li > p > a {
|
|
14
|
-
color: var(--paragraph);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.#{bem.$base}.tree {
|
|
19
|
-
padding: 0;
|
|
11
|
+
> .#{bem.$base}.tree {
|
|
20
12
|
position: sticky;
|
|
21
13
|
top: 0;
|
|
22
14
|
|
|
15
|
+
ul {
|
|
16
|
+
list-style: none;
|
|
17
|
+
padding: 0 $default-padding;
|
|
18
|
+
|
|
19
|
+
> li > p > a {
|
|
20
|
+
color: var(--paragraph);
|
|
21
|
+
text-decoration: none;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
23
25
|
.#{bem.$modifier-active} {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
font-weight: 700;
|
|
27
|
+
|
|
28
|
+
&::before {
|
|
29
|
+
background: var(--x);
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
content: "";
|
|
32
|
+
display: inline-block;
|
|
33
|
+
height: $default-dot-size;
|
|
34
|
+
margin-right: $default-margin;
|
|
35
|
+
text-align: center;
|
|
36
|
+
width: $default-dot-size;
|
|
37
|
+
}
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
li:not(:last-child) {
|
|
@@ -34,5 +46,3 @@ $default-padding: 1em;
|
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
|
-
|
|
38
|
-
|