@sproutsocial/seeds-react-tree 0.4.1 → 0.4.3
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 +9 -9
- package/CHANGELOG.md +23 -0
- package/dist/esm/index.js +106 -281
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +106 -281
- package/dist/index.js.map +1 -1
- package/dist/tree.css +318 -0
- package/package.json +11 -10
- package/src/Common/TreeSearchableSelectBase.tsx +36 -119
- package/src/Tree.stories.tsx +26 -0
- package/src/Tree.tsx +4 -4
- package/src/TreeCombobox.tsx +17 -71
- package/src/TreeItem.tsx +33 -22
- package/src/__tests__/Tree.test.tsx +61 -0
- package/src/cn.ts +28 -0
- package/src/tree.css +318 -0
- package/src/TreeStyles.tsx +0 -115
package/src/TreeStyles.tsx
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import styled, { css } from "styled-components";
|
|
2
|
-
|
|
3
|
-
export const TreeRoot = styled.ul`
|
|
4
|
-
list-style: none;
|
|
5
|
-
margin: 0;
|
|
6
|
-
padding: 0;
|
|
7
|
-
font-family: ${({ theme }) => theme.fontFamily};
|
|
8
|
-
font-size: ${({ theme }) => theme.typography[200].fontSize};
|
|
9
|
-
line-height: ${({ theme }) => theme.typography[200].lineHeight};
|
|
10
|
-
color: ${({ theme }) => theme.colors.text.body};
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
export const TreeItemRow = styled.div<{
|
|
14
|
-
$level: number;
|
|
15
|
-
$selected: boolean;
|
|
16
|
-
$disabled: boolean;
|
|
17
|
-
}>`
|
|
18
|
-
display: flex;
|
|
19
|
-
align-items: center;
|
|
20
|
-
gap: ${({ theme }) => theme.space[300]};
|
|
21
|
-
padding: ${({ theme }) => theme.space[300]};
|
|
22
|
-
padding-left: ${({ theme, $level }) =>
|
|
23
|
-
`calc(${theme.space[300]} + ${$level - 1} * ${theme.space[400]})`};
|
|
24
|
-
border-radius: ${({ theme }) => theme.radii[400]};
|
|
25
|
-
cursor: pointer;
|
|
26
|
-
user-select: none;
|
|
27
|
-
background: transparent;
|
|
28
|
-
transition: background-color ${({ theme }) => theme.duration.fast}
|
|
29
|
-
${({ theme }) => theme.easing.ease_in};
|
|
30
|
-
|
|
31
|
-
&:hover {
|
|
32
|
-
background: ${({ theme }) => theme.colors.listItem.background.hover};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
${({ $selected, theme }) =>
|
|
36
|
-
$selected &&
|
|
37
|
-
css`
|
|
38
|
-
background: ${theme.colors.listItem.background.hover};
|
|
39
|
-
font-weight: ${theme.fontWeights.semibold};
|
|
40
|
-
`}
|
|
41
|
-
|
|
42
|
-
${({ $disabled }) =>
|
|
43
|
-
$disabled &&
|
|
44
|
-
css`
|
|
45
|
-
opacity: 0.4;
|
|
46
|
-
cursor: not-allowed;
|
|
47
|
-
pointer-events: none;
|
|
48
|
-
`}
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
export const TreeItemEl = styled.li`
|
|
52
|
-
list-style: none;
|
|
53
|
-
outline: none;
|
|
54
|
-
|
|
55
|
-
/*
|
|
56
|
-
* Tree rows stack tightly, so the standard outset Seeds focusRing bleeds
|
|
57
|
-
* into adjacent rows. Use an inset outline so the ring is drawn just inside
|
|
58
|
-
* the row's edge and never overlaps siblings or children.
|
|
59
|
-
*
|
|
60
|
-
* The same ring is drawn when [data-treeitem-active] is set so combobox
|
|
61
|
-
* hosts that drive the tree via aria-activedescendant (no real DOM focus)
|
|
62
|
-
* still get a visible "active" indicator on the row.
|
|
63
|
-
*/
|
|
64
|
-
&:focus-visible > ${TreeItemRow}, &[data-treeitem-active] > ${TreeItemRow} {
|
|
65
|
-
outline: 2px solid
|
|
66
|
-
${({ theme }) => theme.colors.button.primary.background.base};
|
|
67
|
-
outline-offset: -2px;
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
70
|
-
|
|
71
|
-
export const TreeItemGroup = styled.ul`
|
|
72
|
-
list-style: none;
|
|
73
|
-
margin: 0;
|
|
74
|
-
padding: 0;
|
|
75
|
-
`;
|
|
76
|
-
|
|
77
|
-
export const TreeItemLabel = styled.span`
|
|
78
|
-
flex: 1;
|
|
79
|
-
min-width: 0;
|
|
80
|
-
overflow: hidden;
|
|
81
|
-
text-overflow: ellipsis;
|
|
82
|
-
white-space: nowrap;
|
|
83
|
-
`;
|
|
84
|
-
|
|
85
|
-
export const TreeItemIcon = styled.span`
|
|
86
|
-
display: inline-flex;
|
|
87
|
-
align-items: center;
|
|
88
|
-
flex-shrink: 0;
|
|
89
|
-
`;
|
|
90
|
-
|
|
91
|
-
export const TreeItemChevron = styled.button.attrs({
|
|
92
|
-
type: "button",
|
|
93
|
-
tabIndex: -1,
|
|
94
|
-
})<{ $expanded: boolean }>`
|
|
95
|
-
display: inline-flex;
|
|
96
|
-
align-items: center;
|
|
97
|
-
justify-content: center;
|
|
98
|
-
flex-shrink: 0;
|
|
99
|
-
width: ${({ theme }) => theme.space[500]};
|
|
100
|
-
height: ${({ theme }) => theme.space[500]};
|
|
101
|
-
padding: 0;
|
|
102
|
-
border: none;
|
|
103
|
-
background: transparent;
|
|
104
|
-
color: ${({ theme }) => theme.colors.icon.base};
|
|
105
|
-
cursor: pointer;
|
|
106
|
-
border-radius: ${({ theme }) => theme.radii[300]};
|
|
107
|
-
transition: transform ${({ theme }) => theme.duration.fast}
|
|
108
|
-
${({ theme }) => theme.easing.ease_in};
|
|
109
|
-
transform: ${({ $expanded }) =>
|
|
110
|
-
$expanded ? "rotate(0deg)" : "rotate(-90deg)"};
|
|
111
|
-
|
|
112
|
-
&:hover {
|
|
113
|
-
background: ${({ theme }) => theme.colors.listItem.background.hover};
|
|
114
|
-
}
|
|
115
|
-
`;
|