primer_view_components 0.43.5 → 0.44.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/app/assets/javascripts/components/primer/alpha/tree_view/tree_view.d.ts +39 -0
- data/app/assets/javascripts/components/primer/alpha/tree_view/tree_view_icon_pair_element.d.ts +15 -0
- data/app/assets/javascripts/components/primer/alpha/tree_view/tree_view_include_fragment_element.d.ts +9 -0
- data/app/assets/javascripts/components/primer/alpha/tree_view/tree_view_roving_tab_index.d.ts +3 -0
- data/app/assets/javascripts/components/primer/alpha/tree_view/tree_view_sub_tree_node_element.d.ts +42 -0
- data/app/assets/javascripts/components/primer/primer.d.ts +4 -0
- data/app/assets/javascripts/components/primer/shared_events.d.ts +15 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/file_tree_view/directory_node.html.erb +5 -0
- data/app/components/primer/alpha/file_tree_view/directory_node.rb +24 -0
- data/app/components/primer/alpha/file_tree_view/file_node.html.erb +2 -0
- data/app/components/primer/alpha/file_tree_view/file_node.rb +14 -0
- data/app/components/primer/alpha/file_tree_view.rb +15 -0
- data/app/components/primer/alpha/skeleton_box.css +1 -0
- data/app/components/primer/alpha/skeleton_box.css.json +6 -0
- data/app/components/primer/alpha/skeleton_box.css.map +1 -0
- data/app/components/primer/alpha/skeleton_box.html.erb +1 -0
- data/app/components/primer/alpha/skeleton_box.pcss +30 -0
- data/app/components/primer/alpha/skeleton_box.rb +29 -0
- data/app/components/primer/alpha/tree_view/icon.html.erb +1 -0
- data/app/components/primer/alpha/tree_view/icon.rb +22 -0
- data/app/components/primer/alpha/tree_view/icon_pair.html.erb +13 -0
- data/app/components/primer/alpha/tree_view/icon_pair.rb +42 -0
- data/app/components/primer/alpha/tree_view/leading_action.html.erb +3 -0
- data/app/components/primer/alpha/tree_view/leading_action.rb +18 -0
- data/app/components/primer/alpha/tree_view/leaf_node.html.erb +18 -0
- data/app/components/primer/alpha/tree_view/leaf_node.rb +96 -0
- data/app/components/primer/alpha/tree_view/loading_failure_message.html.erb +13 -0
- data/app/components/primer/alpha/tree_view/loading_failure_message.rb +31 -0
- data/app/components/primer/alpha/tree_view/node.html.erb +32 -0
- data/app/components/primer/alpha/tree_view/node.rb +194 -0
- data/app/components/primer/alpha/tree_view/skeleton_loader.html.erb +23 -0
- data/app/components/primer/alpha/tree_view/skeleton_loader.rb +36 -0
- data/app/components/primer/alpha/tree_view/spinner_loader.html.erb +20 -0
- data/app/components/primer/alpha/tree_view/spinner_loader.rb +33 -0
- data/app/components/primer/alpha/tree_view/sub_tree.html.erb +21 -0
- data/app/components/primer/alpha/tree_view/sub_tree.rb +113 -0
- data/app/components/primer/alpha/tree_view/sub_tree_container.html.erb +3 -0
- data/app/components/primer/alpha/tree_view/sub_tree_container.rb +39 -0
- data/app/components/primer/alpha/tree_view/sub_tree_node.html.erb +49 -0
- data/app/components/primer/alpha/tree_view/sub_tree_node.rb +188 -0
- data/app/components/primer/alpha/tree_view/tree_view.d.ts +39 -0
- data/app/components/primer/alpha/tree_view/tree_view.js +363 -0
- data/app/components/primer/alpha/tree_view/tree_view.ts +396 -0
- data/app/components/primer/alpha/tree_view/tree_view_icon_pair_element.d.ts +15 -0
- data/app/components/primer/alpha/tree_view/tree_view_icon_pair_element.js +62 -0
- data/app/components/primer/alpha/tree_view/tree_view_icon_pair_element.ts +56 -0
- data/app/components/primer/alpha/tree_view/tree_view_include_fragment_element.d.ts +9 -0
- data/app/components/primer/alpha/tree_view/tree_view_include_fragment_element.js +28 -0
- data/app/components/primer/alpha/tree_view/tree_view_include_fragment_element.ts +28 -0
- data/app/components/primer/alpha/tree_view/tree_view_roving_tab_index.d.ts +3 -0
- data/app/components/primer/alpha/tree_view/tree_view_roving_tab_index.js +130 -0
- data/app/components/primer/alpha/tree_view/tree_view_roving_tab_index.ts +161 -0
- data/app/components/primer/alpha/tree_view/tree_view_sub_tree_node_element.d.ts +42 -0
- data/app/components/primer/alpha/tree_view/tree_view_sub_tree_node_element.js +418 -0
- data/app/components/primer/alpha/tree_view/tree_view_sub_tree_node_element.ts +470 -0
- data/app/components/primer/alpha/tree_view/visual.html.erb +14 -0
- data/app/components/primer/alpha/tree_view/visual.rb +27 -0
- data/app/components/primer/alpha/tree_view.css +1 -0
- data/app/components/primer/alpha/tree_view.css.json +52 -0
- data/app/components/primer/alpha/tree_view.css.map +1 -0
- data/app/components/primer/alpha/tree_view.html.erb +12 -0
- data/app/components/primer/alpha/tree_view.pcss +373 -0
- data/app/components/primer/alpha/tree_view.rb +439 -0
- data/app/components/primer/beta/breadcrumbs.css +1 -1
- data/app/components/primer/beta/breadcrumbs.css.json +0 -1
- data/app/components/primer/beta/breadcrumbs.css.map +1 -1
- data/app/components/primer/beta/breadcrumbs.pcss +2 -8
- data/app/components/primer/beta/progress_bar.css +1 -1
- data/app/components/primer/beta/progress_bar.css.map +1 -1
- data/app/components/primer/beta/progress_bar.pcss +3 -2
- data/app/components/primer/beta/relative_time.rb +3 -0
- data/app/components/primer/beta/spinner.html.erb +1 -1
- data/app/components/primer/beta/spinner.rb +2 -0
- data/app/components/primer/primer.d.ts +4 -0
- data/app/components/primer/primer.js +4 -0
- data/app/components/primer/primer.pcss +2 -0
- data/app/components/primer/primer.ts +4 -0
- data/app/components/primer/shared_events.d.ts +15 -0
- data/app/components/primer/shared_events.ts +19 -0
- data/app/controllers/primer/view_components/tree_view_items.json +293 -0
- data/app/controllers/primer/view_components/tree_view_items_controller.rb +55 -0
- data/app/forms/check_box_with_nested_form.rb +10 -10
- data/app/forms/radio_button_with_nested_form.rb +16 -16
- data/app/views/primer/view_components/tree_view_items/async_alpha.html_fragment.erb +23 -0
- data/app/views/primer/view_components/tree_view_items/index.html_fragment.erb +24 -0
- data/config/routes.rb +2 -0
- data/lib/primer/view_components/version.rb +2 -2
- data/previews/primer/alpha/file_tree_view_preview/default.html.erb +16 -0
- data/previews/primer/alpha/file_tree_view_preview/playground.html.erb +4 -0
- data/previews/primer/alpha/file_tree_view_preview.rb +69 -0
- data/previews/primer/alpha/skeleton_box_preview.rb +20 -0
- data/previews/primer/alpha/tree_view_preview/async_alpha.html.erb +12 -0
- data/previews/primer/alpha/tree_view_preview/buttons.html.erb +10 -0
- data/previews/primer/alpha/tree_view_preview/default.html.erb +24 -0
- data/previews/primer/alpha/tree_view_preview/empty.html.erb +10 -0
- data/previews/primer/alpha/tree_view_preview/form_input.html.erb +14 -0
- data/previews/primer/alpha/tree_view_preview/leaf_node_playground.html.erb +15 -0
- data/previews/primer/alpha/tree_view_preview/links.html.erb +17 -0
- data/previews/primer/alpha/tree_view_preview/loading_failure.html.erb +36 -0
- data/previews/primer/alpha/tree_view_preview/loading_skeleton.html.erb +12 -0
- data/previews/primer/alpha/tree_view_preview/loading_spinner.html.erb +12 -0
- data/previews/primer/alpha/tree_view_preview/playground.html.erb +4 -0
- data/previews/primer/alpha/tree_view_preview.rb +208 -0
- data/static/arguments.json +456 -0
- data/static/audited_at.json +17 -0
- data/static/classes.json +15 -0
- data/static/constants.json +101 -0
- data/static/info_arch.json +1410 -56
- data/static/previews.json +232 -0
- data/static/statuses.json +17 -0
- metadata +89 -8
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= form_with(url: primer_view_components.generic_form_submission_path(format: :json)) do |f| %>
|
2
|
+
<%= render(Primer::Alpha::Stack.new) do %>
|
3
|
+
<%= render(Primer::Alpha::TreeView.new(form_arguments: { builder: f, name: "folder_structure" })) do |tree| %>
|
4
|
+
<% tree.with_sub_tree(label: "src", expanded: expanded, select_variant: :multiple, value: 0) do |sub_tree| %>
|
5
|
+
<% sub_tree.with_leaf(label: "button.rb", select_variant: :multiple, value: 1) %>
|
6
|
+
<% sub_tree.with_leaf(label: "icon_button.rb", current: true, select_variant: :multiple, value: 2) %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% tree.with_leaf(label: "action_menu.rb", select_variant: :multiple, value: 3) %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= render(Primer::Alpha::SubmitButton.new(name: :submit, label: "Submit")) %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= render(Primer::Alpha::TreeView.new) do |tree| %>
|
2
|
+
<% tree.with_leaf(label: label, select_variant: select_variant, disabled: disabled) do |node| %>
|
3
|
+
<% if leading_visual_icon && leading_visual_icon != :none %>
|
4
|
+
<% node.with_leading_visual_icon(icon: leading_visual_icon) %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<% if trailing_visual_icon && trailing_visual_icon != :none %>
|
8
|
+
<% node.with_trailing_visual_icon(icon: trailing_visual_icon) %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<% if leading_action_icon && leading_action_icon != :none %>
|
12
|
+
<% node.with_leading_action_button(icon: leading_action_icon, aria: { label: "Leading action icon" }) %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div style="max-width: 400px">
|
2
|
+
<%= render(Primer::Alpha::TreeView.new(node_variant: :anchor)) do |tree_view| %>
|
3
|
+
<% tree_view.with_sub_tree(label: "Cloud Services", href: "https://en.wikipedia.org/wiki/Cloud_computing", target: "blank", expanded: expanded, disabled: disabled) do |sub_tree| %>
|
4
|
+
<% sub_tree.with_leaf(label: "OpenProject", href: "https://www.openproject.org", target: "blank", disabled: disabled) do |node| %>
|
5
|
+
<% node.with_trailing_visual_icon(icon: :"link-external") %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<% sub_tree.with_leaf(label: "Hetzner", href: "https://www.hetzner.com", target: "blank", disabled: disabled) do |node| %>
|
9
|
+
<% node.with_trailing_visual_icon(icon: :"link-external") %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% tree_view.with_leaf(label: "GitHub", href: "https://github.com", target: "blank", disabled: disabled) do |node| %>
|
14
|
+
<% node.with_trailing_visual_icon(icon: :"link-external") %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<% subject_id = SecureRandom.hex %>
|
2
|
+
|
3
|
+
<div style="max-width: 400px">
|
4
|
+
<%= render(Primer::Alpha::TreeView.new(data: { interaction_subject: subject_id })) do |tree_view| %>
|
5
|
+
<% tree_view.with_sub_tree(label: "primer") do |sub_tree| %>
|
6
|
+
<% sub_tree.with_leading_visual_icons do |icons| %>
|
7
|
+
<% icons.with_expanded_icon(icon: :"file-directory-open-fill", color: :accent) %>
|
8
|
+
<% icons.with_collapsed_icon(icon: :"file-directory-fill", color: :accent) %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<% sub_tree.with_loading_spinner(src: primer_view_components.tree_view_items_path(loader: "spinner", fail: true)) %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<script>
|
17
|
+
function ready(fn) {
|
18
|
+
if (document.readyState !== 'loading') {
|
19
|
+
fn()
|
20
|
+
} else {
|
21
|
+
document.addEventListener('DOMContentLoaded', fn)
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
ready(() => {
|
26
|
+
const subject = document.querySelector("[data-interaction-subject='<%= subject_id %>']")
|
27
|
+
if (!subject) return
|
28
|
+
|
29
|
+
const includeFragment = subject.querySelector('tree-view-include-fragment')
|
30
|
+
if (!includeFragment) return
|
31
|
+
|
32
|
+
includeFragment.addEventListener('loadend', (event) => {
|
33
|
+
subject.setAttribute('data-ready', 'true')
|
34
|
+
})
|
35
|
+
})
|
36
|
+
</script>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div style="max-width: 400px">
|
2
|
+
<%= render(Primer::Alpha::TreeView.new) do |tree_view| %>
|
3
|
+
<% tree_view.with_sub_tree(label: "primer") do |sub_tree| %>
|
4
|
+
<% sub_tree.with_leading_visual_icons do |icons| %>
|
5
|
+
<% icons.with_expanded_icon(icon: :"file-directory-open-fill", color: :accent) %>
|
6
|
+
<% icons.with_collapsed_icon(icon: :"file-directory-fill", color: :accent) %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% sub_tree.with_loading_skeleton(src: primer_view_components.tree_view_items_path(loader: "skeleton", fail: simulate_failure, empty: simulate_empty)) %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div style="max-width: 400px">
|
2
|
+
<%= render(Primer::Alpha::TreeView.new) do |tree_view| %>
|
3
|
+
<% tree_view.with_sub_tree(label: "primer") do |sub_tree| %>
|
4
|
+
<% sub_tree.with_leading_visual_icons do |icons| %>
|
5
|
+
<% icons.with_expanded_icon(icon: :"file-directory-open-fill", color: :accent) %>
|
6
|
+
<% icons.with_collapsed_icon(icon: :"file-directory-fill", color: :accent) %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% sub_tree.with_loading_spinner(src: primer_view_components.tree_view_items_path(loader: "spinner", fail: simulate_failure, empty: simulate_empty)) %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
@@ -0,0 +1,208 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# @label TreeView
|
6
|
+
class TreeViewPreview < ViewComponent::Preview
|
7
|
+
# @label Default
|
8
|
+
#
|
9
|
+
# @snapshot interactive
|
10
|
+
# @param expanded [Boolean] toggle
|
11
|
+
# @param disabled [Boolean] toggle
|
12
|
+
# @param select_variant [Symbol] select [multiple, none]
|
13
|
+
# @param select_strategy [Symbol] select [self, descendants, mixed_descendants]
|
14
|
+
def default(
|
15
|
+
expanded: false,
|
16
|
+
disabled: false,
|
17
|
+
select_variant: Primer::Alpha::TreeView::Node::DEFAULT_SELECT_VARIANT,
|
18
|
+
select_strategy: Primer::Alpha::TreeView::SubTreeNode::DEFAULT_SELECT_STRATEGY
|
19
|
+
)
|
20
|
+
render_with_template(locals: {
|
21
|
+
expanded: coerce_bool(expanded),
|
22
|
+
disabled: coerce_bool(disabled),
|
23
|
+
select_variant: select_variant.to_sym,
|
24
|
+
select_strategy: select_strategy.to_sym
|
25
|
+
})
|
26
|
+
end
|
27
|
+
|
28
|
+
# @label Playground
|
29
|
+
#
|
30
|
+
# @param expanded [Boolean] toggle
|
31
|
+
# @param select_variant [Symbol] select [multiple, none]
|
32
|
+
# @param select_strategy [Symbol] select [self, descendants, mixed_descendants]
|
33
|
+
def playground(
|
34
|
+
expanded: false,
|
35
|
+
select_variant: Primer::Alpha::TreeView::Node::DEFAULT_SELECT_VARIANT,
|
36
|
+
select_strategy: Primer::Alpha::TreeView::SubTreeNode::DEFAULT_SELECT_STRATEGY
|
37
|
+
)
|
38
|
+
render_with_template(locals: {
|
39
|
+
expanded: coerce_bool(expanded),
|
40
|
+
select_variant: select_variant.to_sym,
|
41
|
+
select_strategy: select_strategy.to_sym,
|
42
|
+
populate: -> (*args) { populate(*args) }
|
43
|
+
})
|
44
|
+
end
|
45
|
+
|
46
|
+
# @label Empty
|
47
|
+
#
|
48
|
+
# @snapshot interactive
|
49
|
+
def empty
|
50
|
+
end
|
51
|
+
|
52
|
+
# @label Loading failure
|
53
|
+
#
|
54
|
+
# @snapshot interactive
|
55
|
+
def loading_failure
|
56
|
+
end
|
57
|
+
|
58
|
+
# @label Loading spinner
|
59
|
+
#
|
60
|
+
# @snapshot interactive
|
61
|
+
# @param simulate_failure [Boolean] toggle
|
62
|
+
# @param simulate_empty [Boolean] toggle
|
63
|
+
def loading_spinner(simulate_failure: false, simulate_empty: false)
|
64
|
+
render_with_template(locals: {
|
65
|
+
simulate_failure: coerce_bool(simulate_failure),
|
66
|
+
simulate_empty: coerce_bool(simulate_empty),
|
67
|
+
})
|
68
|
+
end
|
69
|
+
|
70
|
+
# @label Loading skeleton
|
71
|
+
#
|
72
|
+
# @snapshot interactive
|
73
|
+
# @param simulate_failure [Boolean] toggle
|
74
|
+
# @param simulate_empty [Boolean] toggle
|
75
|
+
def loading_skeleton(simulate_failure: false, simulate_empty: false)
|
76
|
+
render_with_template(locals: {
|
77
|
+
simulate_failure: coerce_bool(simulate_failure),
|
78
|
+
simulate_empty: coerce_bool(simulate_empty)
|
79
|
+
})
|
80
|
+
end
|
81
|
+
|
82
|
+
# @label Async alpha
|
83
|
+
#
|
84
|
+
# @param action_menu_expanded [Boolean] toggle
|
85
|
+
def async_alpha(action_menu_expanded: false)
|
86
|
+
render_with_template(locals: {
|
87
|
+
action_menu_expanded: coerce_bool(action_menu_expanded)
|
88
|
+
})
|
89
|
+
end
|
90
|
+
|
91
|
+
# @label Leaf node playground
|
92
|
+
#
|
93
|
+
# @param label [String] text
|
94
|
+
# @param leading_visual_icon [Symbol] octicon
|
95
|
+
# @param leading_action_icon [Symbol] octicon
|
96
|
+
# @param trailing_visual_icon [Symbol] octicon
|
97
|
+
# @param select_variant [Symbol] select [multiple, none]
|
98
|
+
# @param disabled [Boolean] toggle
|
99
|
+
def leaf_node_playground(
|
100
|
+
label: "Leaf node",
|
101
|
+
leading_visual_icon: nil,
|
102
|
+
leading_action_icon: nil,
|
103
|
+
trailing_visual_icon: nil,
|
104
|
+
select_variant: Primer::Alpha::TreeView::Node::DEFAULT_SELECT_VARIANT,
|
105
|
+
disabled: false
|
106
|
+
)
|
107
|
+
render_with_template(locals: {
|
108
|
+
label: label,
|
109
|
+
leading_visual_icon: leading_visual_icon,
|
110
|
+
leading_action_icon: leading_action_icon,
|
111
|
+
trailing_visual_icon: trailing_visual_icon,
|
112
|
+
select_variant: select_variant.to_sym,
|
113
|
+
disabled: disabled
|
114
|
+
})
|
115
|
+
end
|
116
|
+
|
117
|
+
# @label Links
|
118
|
+
#
|
119
|
+
# @param expanded [Boolean] toggle
|
120
|
+
# @param disabled [Boolean] toggle
|
121
|
+
def links(expanded: false, disabled: false)
|
122
|
+
render_with_template(locals: {
|
123
|
+
expanded: coerce_bool(expanded),
|
124
|
+
disabled: coerce_bool(disabled)
|
125
|
+
})
|
126
|
+
end
|
127
|
+
|
128
|
+
# @label Buttons
|
129
|
+
#
|
130
|
+
# @param expanded [Boolean] toggle
|
131
|
+
# @param disabled [Boolean] toggle
|
132
|
+
def buttons(expanded: false, disabled: false)
|
133
|
+
render_with_template(locals: {
|
134
|
+
expanded: coerce_bool(expanded),
|
135
|
+
disabled: coerce_bool(disabled)
|
136
|
+
})
|
137
|
+
end
|
138
|
+
|
139
|
+
# @label Auto expansion
|
140
|
+
#
|
141
|
+
def auto_expansion
|
142
|
+
render(Primer::Alpha::TreeView.new) do |tree|
|
143
|
+
tree.with_sub_tree(label: "Level 1") do |level1|
|
144
|
+
level1.with_sub_tree(label: "Level 2") do |level2|
|
145
|
+
# marking this node as expanded should automatically expand all ancestors
|
146
|
+
level2.with_sub_tree(label: "Level 3", expanded: true) do |level3|
|
147
|
+
level3.with_leaf(label: "Level 4")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# @label Form input
|
155
|
+
#
|
156
|
+
# @param expanded [Boolean] toggle
|
157
|
+
def form_input(expanded: true)
|
158
|
+
render_with_template(locals: {
|
159
|
+
expanded: coerce_bool(expanded)
|
160
|
+
})
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
def coerce_bool(value)
|
166
|
+
case value
|
167
|
+
when true, false
|
168
|
+
value
|
169
|
+
when "true"
|
170
|
+
true
|
171
|
+
when "false"
|
172
|
+
false
|
173
|
+
else
|
174
|
+
false
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def populate(node, data, node_arguments)
|
179
|
+
return unless data
|
180
|
+
|
181
|
+
entries = (
|
182
|
+
data.fetch("children", {}).keys.map { |label, idx| [label, :directory] } +
|
183
|
+
data.fetch("files", []).map { |label| [label, :file] }
|
184
|
+
)
|
185
|
+
|
186
|
+
entries.sort_by!(&:first)
|
187
|
+
|
188
|
+
entries.each do |label, kind, idx|
|
189
|
+
case kind
|
190
|
+
when :directory
|
191
|
+
node.with_sub_tree(label: label, **node_arguments) do |sub_tree|
|
192
|
+
sub_tree.with_leading_visual_icons do |icons|
|
193
|
+
icons.with_expanded_icon(icon: :"file-directory-open-fill", color: :accent)
|
194
|
+
icons.with_collapsed_icon(icon: :"file-directory-fill", color: :accent)
|
195
|
+
end
|
196
|
+
|
197
|
+
populate(sub_tree, data["children"][label], node_arguments)
|
198
|
+
end
|
199
|
+
when :file
|
200
|
+
node.with_leaf(label: label, **node_arguments) do |leaf|
|
201
|
+
leaf.with_leading_visual_icon(icon: :file)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|