File size: 5,520 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import { defineSlotRecipe } from "../def"

export const treeViewSlotRecipe = defineSlotRecipe({
  slots: [
    "branch",
    "branchContent",
    "branchControl",
    "branchIndentGuide",
    "branchIndicator",
    "branchText",
    "branchTrigger",
    "item",
    "itemIndicator",
    "itemText",
    "label",
    "nodeCheckbox",
    "root",
    "tree",
  ],
  className: "tree-view",
  base: {
    root: {
      width: "full",
      display: "flex",
      flexDirection: "column",
      gap: "2",
    },
    tree: {
      display: "flex",
      flexDirection: "column",
      "--tree-item-gap": "spacing.2",
      _icon: {
        boxSize: "var(--tree-icon-size)",
      },
    },
    label: {
      fontWeight: "medium",
      textStyle: "sm",
    },
    branch: {
      position: "relative",
    },
    branchContent: {
      position: "relative",
    },
    branchIndentGuide: {
      height: "100%",
      width: "1px",
      bg: "border",
      position: "absolute",
      "--tree-depth": "calc(var(--depth) - 1)",
      "--tree-indentation-offset":
        "calc(var(--tree-indentation) * var(--tree-depth))",
      "--tree-offset":
        "calc(var(--tree-padding-inline) + var(--tree-indentation-offset))",
      "--tree-icon-offset": "calc(var(--tree-icon-size) * 0.5 * var(--depth))",
      insetInlineStart: "calc(var(--tree-offset) + var(--tree-icon-offset))",
      zIndex: "1",
    },
    branchIndicator: {
      color: "fg.muted",
      transformOrigin: "center",
      transitionDuration: "normal",
      transitionProperty: "transform",
      transitionTimingFunction: "default",
      _open: {
        transform: "rotate(90deg)",
      },
    },
    branchTrigger: {
      display: "inline-flex",
      alignItems: "center",
      justifyContent: "center",
    },
    branchControl: {
      display: "flex",
      alignItems: "center",
      gap: "var(--tree-item-gap)",
      rounded: "l2",
      userSelect: "none",
      position: "relative",
      "--tree-depth": "calc(var(--depth) - 1)",
      "--tree-indentation-offset":
        "calc(var(--tree-indentation) * var(--tree-depth))",
      "--tree-icon-offset":
        "calc(var(--tree-icon-size) * var(--tree-depth) * 0.5)",
      "--tree-offset":
        "calc(var(--tree-padding-inline) + var(--tree-indentation-offset) + var(--tree-icon-offset))",
      ps: "var(--tree-offset)",
      pe: "var(--tree-padding-inline)",
      py: "var(--tree-padding-block)",
      focusVisibleRing: "inside",
      focusRingColor: "border.emphasized",
      focusRingWidth: "2px",
      "&:hover, &:focus-visible": {
        bg: "bg.muted",
      },
      _disabled: {
        layerStyle: "disabled",
      },
    },
    item: {
      display: "flex",
      alignItems: "center",
      gap: "var(--tree-item-gap)",
      rounded: "l2",
      userSelect: "none",
      position: "relative",
      "--tree-depth": "calc(var(--depth) - 1)",
      "--tree-indentation-offset":
        "calc(var(--tree-indentation) * var(--tree-depth))",
      "--tree-icon-offset":
        "calc(var(--tree-icon-size) * var(--tree-depth) * 0.5)",
      "--tree-offset":
        "calc(var(--tree-padding-inline) + var(--tree-indentation-offset) + var(--tree-icon-offset))",
      ps: "var(--tree-offset)",
      pe: "var(--tree-padding-inline)",
      py: "var(--tree-padding-block)",
      focusVisibleRing: "inside",
      focusRingColor: "border.emphasized",
      focusRingWidth: "2px",
      "&:hover, &:focus-visible": {
        bg: "bg.muted",
      },
      _disabled: {
        layerStyle: "disabled",
      },
    },
    itemText: {
      flex: "1",
    },
    branchText: {
      flex: "1",
    },
    nodeCheckbox: {
      display: "inline-flex",
    },
  },
  variants: {
    size: {
      md: {
        tree: {
          textStyle: "sm",
          "--tree-indentation": "spacing.4",
          "--tree-padding-inline": "spacing.3",
          "--tree-padding-block": "spacing.1.5",
          "--tree-icon-size": "spacing.4",
        },
      },
      sm: {
        tree: {
          textStyle: "sm",
          "--tree-indentation": "spacing.4",
          "--tree-padding-inline": "spacing.3",
          "--tree-padding-block": "spacing.1",
          "--tree-icon-size": "spacing.3",
        },
      },
      xs: {
        tree: {
          textStyle: "xs",
          "--tree-indentation": "spacing.4",
          "--tree-padding-inline": "spacing.2",
          "--tree-padding-block": "spacing.1",
          "--tree-icon-size": "spacing.3",
        },
      },
    },
    variant: {
      subtle: {
        branchControl: {
          _selected: {
            bg: "colorPalette.subtle",
            color: "colorPalette.fg",
          },
        },
        item: {
          _selected: {
            bg: "colorPalette.subtle",
            color: "colorPalette.fg",
          },
        },
      },
      solid: {
        branchControl: {
          _selected: {
            layerStyle: "fill.solid",
          },
        },
        item: {
          _selected: {
            layerStyle: "fill.solid",
          },
        },
      },
    },
    animateContent: {
      true: {
        branchContent: {
          _open: {
            animationName: "expand-height, fade-in",
            animationDuration: "moderate",
          },
          _closed: {
            animationName: "collapse-height, fade-out",
            animationDuration: "moderate",
          },
        },
      },
    },
  },
  defaultVariants: {
    size: "md",
    variant: "subtle",
  },
})