@robert-stackflow/oneui 0.6.8 → 0.6.17
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/CHANGELOG.md +62 -0
- package/README.md +255 -188
- package/components/AccountItem.module.css +103 -103
- package/components/Alert.d.ts +2 -9
- package/components/Alert.js +2 -40
- package/components/AppShell.d.ts +7 -7
- package/components/AppShell.js +37 -33
- package/components/AppShell.module.css +223 -271
- package/components/AppearanceSettings.js +25 -32
- package/components/Badge.module.css +30 -30
- package/components/Banner.d.ts +17 -0
- package/components/Banner.js +99 -0
- package/components/Banner.module.css +143 -0
- package/components/BarChart.module.css +35 -34
- package/components/Breadcrumb.module.css +97 -97
- package/components/Button.module.css +120 -120
- package/components/Cascader.js +1 -0
- package/components/CharacterPicker.js +2 -0
- package/components/Checkbox.module.css +95 -95
- package/components/Combobox.js +1 -0
- package/components/Combobox.module.css +6 -1
- package/components/CommandPalette.js +2 -2
- package/components/ContributionCalendar.module.css +121 -121
- package/components/Control.module.css +86 -86
- package/components/DataTable.d.ts +3 -2
- package/components/DataTable.js +92 -66
- package/components/DataTable.module.css +3 -31
- package/components/DatePicker.js +1 -0
- package/components/DateRangePicker.js +1 -0
- package/components/Dialog.d.ts +3 -1
- package/components/Dialog.js +11 -4
- package/components/Dialog.module.css +139 -97
- package/components/DialogVariants.d.ts +2 -1
- package/components/DialogVariants.js +35 -7
- package/components/HierarchyPicker.module.css +185 -181
- package/components/IconPicker.js +2 -0
- package/components/Indicator.module.css +83 -83
- package/components/Layout.module.css +82 -82
- package/components/Markdown.d.ts +13 -0
- package/components/Markdown.js +164 -0
- package/components/Markdown.module.css +227 -0
- package/components/MenuItem.module.css +172 -172
- package/components/MultiSelect.js +1 -0
- package/components/MultiSelect.module.css +2 -0
- package/components/NavBar.d.ts +20 -0
- package/components/NavBar.js +197 -0
- package/components/NavBar.module.css +130 -0
- package/components/NavigationSurface.module.css +27 -0
- package/components/Picker.module.css +7 -0
- package/components/Popover.d.ts +6 -1
- package/components/Popover.js +39 -13
- package/components/Popover.module.css +8 -0
- package/components/Progress.module.css +33 -33
- package/components/RadioGroup.module.css +87 -87
- package/components/RangeSlider.module.css +141 -141
- package/components/ResizablePanel.module.css +101 -101
- package/components/ResourceCard.module.css +98 -98
- package/components/SelectSettingRow.d.ts +7 -0
- package/components/SelectSettingRow.js +58 -0
- package/components/SettingRow.d.ts +9 -3
- package/components/SettingRow.js +32 -8
- package/components/SettingRow.module.css +17 -0
- package/components/SettingsLayout.d.ts +15 -3
- package/components/SettingsLayout.js +46 -29
- package/components/SideBar.d.ts +9 -0
- package/components/SideBar.js +30 -0
- package/components/SidebarNavigation.d.ts +24 -3
- package/components/SidebarNavigation.js +274 -47
- package/components/SidebarNavigation.module.css +266 -42
- package/components/Slider.module.css +19 -19
- package/components/Steps.module.css +176 -176
- package/components/Switch.d.ts +3 -1
- package/components/Switch.js +5 -1
- package/components/Switch.module.css +59 -59
- package/components/SwitchSettingRow.d.ts +7 -0
- package/components/SwitchSettingRow.js +45 -0
- package/components/Table.d.ts +8 -1
- package/components/Table.js +34 -17
- package/components/Table.module.css +87 -48
- package/components/TableMarkup.d.ts +2 -1
- package/components/TableMarkup.js +18 -1
- package/components/TableOfContents.d.ts +22 -0
- package/components/TableOfContents.js +462 -0
- package/components/TableOfContents.module.css +252 -0
- package/components/TextAreaSettingRow.d.ts +9 -0
- package/components/TextAreaSettingRow.js +47 -0
- package/components/TextSettingRow.d.ts +9 -0
- package/components/TextSettingRow.js +45 -0
- package/components/ThemePicker.module.css +178 -178
- package/components/ThemeProvider.js +2 -0
- package/components/TimeColumns.module.css +47 -47
- package/components/Timeline.module.css +202 -202
- package/components/Toast.d.ts +8 -1
- package/components/Toast.js +49 -17
- package/components/Toast.module.css +25 -0
- package/components/ToastProvider.d.ts +4 -1
- package/components/ToastProvider.js +67 -12
- package/components/TreeSelect.js +1 -0
- package/components/TreeTable.d.ts +3 -3
- package/components/TreeTable.js +12 -2
- package/components/TreeTable.module.css +57 -53
- package/components/createToaster.d.ts +2 -1
- package/components/createToaster.js +28 -14
- package/components/index.d.ts +18 -1
- package/components/index.js +24 -0
- package/components/motion.d.ts +1 -0
- package/components/motion.js +18 -6
- package/components/settingRowControl.d.ts +7 -0
- package/components/settingRowControl.js +15 -0
- package/package.json +57 -3
- package/styles/base.css +206 -206
- package/styles/blue.css +270 -268
- package/styles/minimal.css +1 -0
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
.item {
|
|
2
|
-
display: flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
gap: var(--menu-item-gap);
|
|
5
|
-
width: 100%;
|
|
6
|
-
min-width: 0;
|
|
7
|
-
min-height: var(--menu-item-height);
|
|
8
|
-
margin: 0;
|
|
9
|
-
padding: max(
|
|
10
|
-
4px,
|
|
11
|
-
calc((var(--menu-item-height) - var(--menu-item-line-height)) / 2)
|
|
12
|
-
)
|
|
13
|
-
var(--menu-item-padding-x);
|
|
14
|
-
border: 0;
|
|
15
|
-
border-radius: calc(var(--radius) - 4px);
|
|
16
|
-
background: transparent;
|
|
17
|
-
color: var(--fg);
|
|
18
|
-
text-align: left;
|
|
19
|
-
font-family: var(--ui-font);
|
|
20
|
-
font-size: var(--menu-item-font-size);
|
|
21
|
-
font-weight: 400;
|
|
22
|
-
line-height: var(--menu-item-line-height);
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
outline: none;
|
|
25
|
-
transition:
|
|
26
|
-
background-color var(--motion-hover),
|
|
27
|
-
color var(--motion-hover);
|
|
28
|
-
}
|
|
29
|
-
.item + .item {
|
|
30
|
-
margin-top: var(--menu-item-spacing);
|
|
31
|
-
}
|
|
32
|
-
@media (pointer: coarse) {
|
|
33
|
-
.item {
|
|
34
|
-
min-height: 44px;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
.item[data-selected="true"] {
|
|
38
|
-
background: var(--selected);
|
|
39
|
-
}
|
|
40
|
-
.item:where(:not(:disabled):not([aria-disabled="true"])):is(
|
|
41
|
-
:hover,
|
|
42
|
-
:focus-visible,
|
|
43
|
-
[data-active="true"],
|
|
44
|
-
[aria-expanded="true"]
|
|
45
|
-
) {
|
|
46
|
-
background: var(--hover);
|
|
47
|
-
}
|
|
48
|
-
.item[data-selected="true"]:where(
|
|
49
|
-
:not(:disabled):not([aria-disabled="true"])
|
|
50
|
-
):is(:hover, :focus-visible, [data-active="true"]) {
|
|
51
|
-
background: color-mix(in srgb, var(--selected) 75%, var(--hover));
|
|
52
|
-
}
|
|
53
|
-
.item:where(:not(:disabled):not([aria-disabled="true"])):active {
|
|
54
|
-
background: var(--selected);
|
|
55
|
-
}
|
|
56
|
-
.item:disabled,
|
|
57
|
-
.item[aria-disabled="true"] {
|
|
58
|
-
opacity: var(--menu-disabled-opacity);
|
|
59
|
-
cursor: not-allowed;
|
|
60
|
-
}
|
|
61
|
-
.item[data-tone="danger"] {
|
|
62
|
-
color: var(--danger);
|
|
63
|
-
}
|
|
64
|
-
.leading,
|
|
65
|
-
.trailing {
|
|
66
|
-
display: grid;
|
|
67
|
-
place-items: center;
|
|
68
|
-
flex: 0 0 var(--menu-item-icon-size);
|
|
69
|
-
width: var(--menu-item-icon-size);
|
|
70
|
-
height: var(--menu-item-icon-size);
|
|
71
|
-
}
|
|
72
|
-
.leading {
|
|
73
|
-
color: inherit;
|
|
74
|
-
opacity: 0.8;
|
|
75
|
-
}
|
|
76
|
-
.leading svg,
|
|
77
|
-
.trailing > svg {
|
|
78
|
-
width: var(--menu-item-icon-size);
|
|
79
|
-
height: var(--menu-item-icon-size);
|
|
80
|
-
stroke-width: 1.65;
|
|
81
|
-
}
|
|
82
|
-
.copy {
|
|
83
|
-
flex: 1;
|
|
84
|
-
min-width: 0;
|
|
85
|
-
display: flex;
|
|
86
|
-
flex-direction: column;
|
|
87
|
-
gap: 2px;
|
|
88
|
-
}
|
|
89
|
-
.label {
|
|
90
|
-
min-width: 0;
|
|
91
|
-
overflow: hidden;
|
|
92
|
-
text-overflow: ellipsis;
|
|
93
|
-
white-space: nowrap;
|
|
94
|
-
}
|
|
95
|
-
.description {
|
|
96
|
-
white-space: nowrap;
|
|
97
|
-
overflow: hidden;
|
|
98
|
-
text-overflow: ellipsis;
|
|
99
|
-
font-size: 11px;
|
|
100
|
-
font-weight: 400;
|
|
101
|
-
line-height: 14px;
|
|
102
|
-
color: var(--muted);
|
|
103
|
-
}
|
|
104
|
-
.shortcut {
|
|
105
|
-
flex-shrink: 0;
|
|
106
|
-
margin-left: auto;
|
|
107
|
-
padding: 0;
|
|
108
|
-
border: 0;
|
|
109
|
-
border-radius: 0;
|
|
110
|
-
background: transparent;
|
|
111
|
-
box-shadow: none;
|
|
112
|
-
font-family: var(--ui-font);
|
|
113
|
-
font-size: var(--menu-shortcut-font-size);
|
|
114
|
-
font-weight: 400;
|
|
115
|
-
line-height: var(--menu-shortcut-line-height);
|
|
116
|
-
font-variant-numeric: tabular-nums;
|
|
117
|
-
color: var(--muted);
|
|
118
|
-
white-space: nowrap;
|
|
119
|
-
text-align: right;
|
|
120
|
-
}
|
|
121
|
-
.shortcut ~ .trailing:empty {
|
|
122
|
-
display: none;
|
|
123
|
-
}
|
|
124
|
-
.check {
|
|
125
|
-
color: var(--accent);
|
|
126
|
-
}
|
|
127
|
-
.checkbox,
|
|
128
|
-
.radio {
|
|
129
|
-
display: grid;
|
|
130
|
-
place-items: center;
|
|
131
|
-
width: var(--menu-item-icon-size);
|
|
132
|
-
height: var(--menu-item-icon-size);
|
|
133
|
-
border: 1px solid color-mix(in srgb, var(--fg) 25%, var(--surface));
|
|
134
|
-
background: var(--field);
|
|
135
|
-
transition:
|
|
136
|
-
background var(--motion-hover),
|
|
137
|
-
border-color var(--motion-hover);
|
|
138
|
-
}
|
|
139
|
-
.checkbox {
|
|
140
|
-
border-radius: 4px;
|
|
141
|
-
}
|
|
142
|
-
.checkbox[data-checked="true"] {
|
|
143
|
-
background: var(--accent);
|
|
144
|
-
border-color: var(--accent);
|
|
145
|
-
color: var(--on-accent);
|
|
146
|
-
}
|
|
147
|
-
.checkbox svg {
|
|
148
|
-
width: 12px;
|
|
149
|
-
height: 12px;
|
|
150
|
-
stroke-width: 2;
|
|
151
|
-
}
|
|
152
|
-
.radio {
|
|
153
|
-
border-radius: 50%;
|
|
154
|
-
}
|
|
155
|
-
.radio i {
|
|
156
|
-
width: 6px;
|
|
157
|
-
height: 6px;
|
|
158
|
-
border-radius: 50%;
|
|
159
|
-
background: var(--accent);
|
|
160
|
-
transform: scale(0);
|
|
161
|
-
transition: transform var(--motion-press) var(--ease);
|
|
162
|
-
}
|
|
163
|
-
.radio[data-checked="true"] {
|
|
164
|
-
border-color: var(--accent);
|
|
165
|
-
}
|
|
166
|
-
.radio[data-checked="true"] i {
|
|
167
|
-
transform: scale(1);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.item:focus-visible {
|
|
171
|
-
outline: none;
|
|
172
|
-
}
|
|
1
|
+
.item {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: var(--menu-item-gap);
|
|
5
|
+
width: 100%;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
min-height: var(--menu-item-height);
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: max(
|
|
10
|
+
4px,
|
|
11
|
+
calc((var(--menu-item-height) - var(--menu-item-line-height)) / 2)
|
|
12
|
+
)
|
|
13
|
+
var(--menu-item-padding-x);
|
|
14
|
+
border: 0;
|
|
15
|
+
border-radius: calc(var(--radius) - 4px);
|
|
16
|
+
background: transparent;
|
|
17
|
+
color: var(--fg);
|
|
18
|
+
text-align: left;
|
|
19
|
+
font-family: var(--ui-font);
|
|
20
|
+
font-size: var(--menu-item-font-size);
|
|
21
|
+
font-weight: 400;
|
|
22
|
+
line-height: var(--menu-item-line-height);
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
outline: none;
|
|
25
|
+
transition:
|
|
26
|
+
background-color var(--motion-hover),
|
|
27
|
+
color var(--motion-hover);
|
|
28
|
+
}
|
|
29
|
+
.item + .item {
|
|
30
|
+
margin-top: var(--menu-item-spacing);
|
|
31
|
+
}
|
|
32
|
+
@media (pointer: coarse) {
|
|
33
|
+
.item {
|
|
34
|
+
min-height: 44px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
.item[data-selected="true"] {
|
|
38
|
+
background: var(--selected);
|
|
39
|
+
}
|
|
40
|
+
.item:where(:not(:disabled):not([aria-disabled="true"])):is(
|
|
41
|
+
:hover,
|
|
42
|
+
:focus-visible,
|
|
43
|
+
[data-active="true"],
|
|
44
|
+
[aria-expanded="true"]
|
|
45
|
+
) {
|
|
46
|
+
background: var(--hover);
|
|
47
|
+
}
|
|
48
|
+
.item[data-selected="true"]:where(
|
|
49
|
+
:not(:disabled):not([aria-disabled="true"])
|
|
50
|
+
):is(:hover, :focus-visible, [data-active="true"]) {
|
|
51
|
+
background: color-mix(in srgb, var(--selected) 75%, var(--hover));
|
|
52
|
+
}
|
|
53
|
+
.item:where(:not(:disabled):not([aria-disabled="true"])):active {
|
|
54
|
+
background: var(--selected);
|
|
55
|
+
}
|
|
56
|
+
.item:disabled,
|
|
57
|
+
.item[aria-disabled="true"] {
|
|
58
|
+
opacity: var(--menu-disabled-opacity);
|
|
59
|
+
cursor: not-allowed;
|
|
60
|
+
}
|
|
61
|
+
.item[data-tone="danger"] {
|
|
62
|
+
color: var(--danger);
|
|
63
|
+
}
|
|
64
|
+
.leading,
|
|
65
|
+
.trailing {
|
|
66
|
+
display: grid;
|
|
67
|
+
place-items: center;
|
|
68
|
+
flex: 0 0 var(--menu-item-icon-size);
|
|
69
|
+
width: var(--menu-item-icon-size);
|
|
70
|
+
height: var(--menu-item-icon-size);
|
|
71
|
+
}
|
|
72
|
+
.leading {
|
|
73
|
+
color: inherit;
|
|
74
|
+
opacity: 0.8;
|
|
75
|
+
}
|
|
76
|
+
.leading svg,
|
|
77
|
+
.trailing > svg {
|
|
78
|
+
width: var(--menu-item-icon-size);
|
|
79
|
+
height: var(--menu-item-icon-size);
|
|
80
|
+
stroke-width: 1.65;
|
|
81
|
+
}
|
|
82
|
+
.copy {
|
|
83
|
+
flex: 1;
|
|
84
|
+
min-width: 0;
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
gap: 2px;
|
|
88
|
+
}
|
|
89
|
+
.label {
|
|
90
|
+
min-width: 0;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
text-overflow: ellipsis;
|
|
93
|
+
white-space: nowrap;
|
|
94
|
+
}
|
|
95
|
+
.description {
|
|
96
|
+
white-space: nowrap;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
text-overflow: ellipsis;
|
|
99
|
+
font-size: 11px;
|
|
100
|
+
font-weight: 400;
|
|
101
|
+
line-height: 14px;
|
|
102
|
+
color: var(--muted);
|
|
103
|
+
}
|
|
104
|
+
.shortcut {
|
|
105
|
+
flex-shrink: 0;
|
|
106
|
+
margin-left: auto;
|
|
107
|
+
padding: 0;
|
|
108
|
+
border: 0;
|
|
109
|
+
border-radius: 0;
|
|
110
|
+
background: transparent;
|
|
111
|
+
box-shadow: none;
|
|
112
|
+
font-family: var(--ui-font);
|
|
113
|
+
font-size: var(--menu-shortcut-font-size);
|
|
114
|
+
font-weight: 400;
|
|
115
|
+
line-height: var(--menu-shortcut-line-height);
|
|
116
|
+
font-variant-numeric: tabular-nums;
|
|
117
|
+
color: var(--muted);
|
|
118
|
+
white-space: nowrap;
|
|
119
|
+
text-align: right;
|
|
120
|
+
}
|
|
121
|
+
.shortcut ~ .trailing:empty {
|
|
122
|
+
display: none;
|
|
123
|
+
}
|
|
124
|
+
.check {
|
|
125
|
+
color: var(--accent-ink, var(--accent));
|
|
126
|
+
}
|
|
127
|
+
.checkbox,
|
|
128
|
+
.radio {
|
|
129
|
+
display: grid;
|
|
130
|
+
place-items: center;
|
|
131
|
+
width: var(--menu-item-icon-size);
|
|
132
|
+
height: var(--menu-item-icon-size);
|
|
133
|
+
border: 1px solid color-mix(in srgb, var(--fg) 25%, var(--surface));
|
|
134
|
+
background: var(--field);
|
|
135
|
+
transition:
|
|
136
|
+
background var(--motion-hover),
|
|
137
|
+
border-color var(--motion-hover);
|
|
138
|
+
}
|
|
139
|
+
.checkbox {
|
|
140
|
+
border-radius: 4px;
|
|
141
|
+
}
|
|
142
|
+
.checkbox[data-checked="true"] {
|
|
143
|
+
background: var(--accent);
|
|
144
|
+
border-color: var(--accent);
|
|
145
|
+
color: var(--on-accent);
|
|
146
|
+
}
|
|
147
|
+
.checkbox svg {
|
|
148
|
+
width: 12px;
|
|
149
|
+
height: 12px;
|
|
150
|
+
stroke-width: 2;
|
|
151
|
+
}
|
|
152
|
+
.radio {
|
|
153
|
+
border-radius: 50%;
|
|
154
|
+
}
|
|
155
|
+
.radio i {
|
|
156
|
+
width: 6px;
|
|
157
|
+
height: 6px;
|
|
158
|
+
border-radius: 50%;
|
|
159
|
+
background: var(--accent-ink, var(--accent));
|
|
160
|
+
transform: scale(0);
|
|
161
|
+
transition: transform var(--motion-press) var(--ease);
|
|
162
|
+
}
|
|
163
|
+
.radio[data-checked="true"] {
|
|
164
|
+
border-color: var(--accent-ink, var(--accent));
|
|
165
|
+
}
|
|
166
|
+
.radio[data-checked="true"] i {
|
|
167
|
+
transform: scale(1);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.item:focus-visible {
|
|
171
|
+
outline: none;
|
|
172
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { NavigationItem } from "./SidebarNavigation";
|
|
3
|
+
export type NavBarItem = NavigationItem | {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
children: readonly NavigationItem[];
|
|
9
|
+
};
|
|
10
|
+
export type NavBarProps = {
|
|
11
|
+
items: readonly NavBarItem[];
|
|
12
|
+
active: string;
|
|
13
|
+
onNavigate?(path: string): void;
|
|
14
|
+
brand?: ReactNode;
|
|
15
|
+
homePath?: string;
|
|
16
|
+
actions?: ReactNode;
|
|
17
|
+
label?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function NavBar({ items, active, onNavigate, brand, homePath, actions, label, className, }: NavBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { ChevronDown, Menu as MenuIcon } from "lucide-react";
|
|
4
|
+
import { Drawer } from "./Drawer.js";
|
|
5
|
+
import { IconButton } from "./IconButton.js";
|
|
6
|
+
import { Popover } from "./Popover.js";
|
|
7
|
+
import { usePopover } from "./usePopover.js";
|
|
8
|
+
import { SideBar } from "./SideBar.js";
|
|
9
|
+
import s from "./NavBar.module.css";
|
|
10
|
+
function follow(event, path, onNavigate) {
|
|
11
|
+
if (!onNavigate || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
|
|
12
|
+
return;
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
onNavigate(path);
|
|
15
|
+
}
|
|
16
|
+
function NavBar({
|
|
17
|
+
items,
|
|
18
|
+
active,
|
|
19
|
+
onNavigate,
|
|
20
|
+
brand,
|
|
21
|
+
homePath = "/",
|
|
22
|
+
actions,
|
|
23
|
+
label = "\u9876\u90E8\u5BFC\u822A",
|
|
24
|
+
className = ""
|
|
25
|
+
}) {
|
|
26
|
+
const [mobile, setMobile] = useState(false);
|
|
27
|
+
return /* @__PURE__ */ jsxs("header", { className: `${s.bar} ${className}`, children: [
|
|
28
|
+
brand && /* @__PURE__ */ jsx(
|
|
29
|
+
"a",
|
|
30
|
+
{
|
|
31
|
+
className: s.brand,
|
|
32
|
+
href: homePath,
|
|
33
|
+
onClick: (event) => follow(event, homePath, onNavigate),
|
|
34
|
+
children: brand
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ jsx("nav", { "aria-label": label, className: s.links, children: items.map(
|
|
38
|
+
(item) => item.children?.length ? /* @__PURE__ */ jsx(
|
|
39
|
+
NavigationMenu,
|
|
40
|
+
{
|
|
41
|
+
item,
|
|
42
|
+
active,
|
|
43
|
+
onNavigate
|
|
44
|
+
},
|
|
45
|
+
item.id
|
|
46
|
+
) : /* @__PURE__ */ jsxs(
|
|
47
|
+
"a",
|
|
48
|
+
{
|
|
49
|
+
role: item.disabled ? "link" : void 0,
|
|
50
|
+
className: s.link,
|
|
51
|
+
href: item.disabled ? void 0 : "path" in item ? item.path : void 0,
|
|
52
|
+
"aria-disabled": item.disabled || void 0,
|
|
53
|
+
tabIndex: item.disabled ? -1 : void 0,
|
|
54
|
+
"aria-current": item.id === active ? "page" : void 0,
|
|
55
|
+
onClick: (event) => {
|
|
56
|
+
if (item.disabled) event.preventDefault();
|
|
57
|
+
else if ("path" in item) follow(event, item.path, onNavigate);
|
|
58
|
+
},
|
|
59
|
+
children: [
|
|
60
|
+
item.icon,
|
|
61
|
+
/* @__PURE__ */ jsx("span", { children: item.label })
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
item.id
|
|
65
|
+
)
|
|
66
|
+
) }),
|
|
67
|
+
/* @__PURE__ */ jsxs("div", { className: s.actions, children: [
|
|
68
|
+
actions,
|
|
69
|
+
/* @__PURE__ */ jsx("span", { className: s.mobileToggle, children: /* @__PURE__ */ jsx(
|
|
70
|
+
IconButton,
|
|
71
|
+
{
|
|
72
|
+
label: `\u6253\u5F00${label}`,
|
|
73
|
+
"aria-expanded": mobile,
|
|
74
|
+
onClick: () => setMobile(true),
|
|
75
|
+
children: /* @__PURE__ */ jsx(MenuIcon, { size: 19 })
|
|
76
|
+
}
|
|
77
|
+
) })
|
|
78
|
+
] }),
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
Drawer,
|
|
81
|
+
{
|
|
82
|
+
open: mobile,
|
|
83
|
+
onClose: () => setMobile(false),
|
|
84
|
+
title: label,
|
|
85
|
+
placement: "right",
|
|
86
|
+
size: 300,
|
|
87
|
+
children: /* @__PURE__ */ jsx(
|
|
88
|
+
SideBar,
|
|
89
|
+
{
|
|
90
|
+
label,
|
|
91
|
+
active,
|
|
92
|
+
groups: items.map((item) => ({
|
|
93
|
+
id: item.id,
|
|
94
|
+
label: item.children?.length ? item.label : void 0,
|
|
95
|
+
collapsible: false,
|
|
96
|
+
items: item.children?.length ? item.children : "path" in item ? [item] : []
|
|
97
|
+
})),
|
|
98
|
+
onNavigate: (path) => {
|
|
99
|
+
setMobile(false);
|
|
100
|
+
if (onNavigate) onNavigate(path);
|
|
101
|
+
else window.location.assign(path);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
] });
|
|
108
|
+
}
|
|
109
|
+
function NavigationMenu({
|
|
110
|
+
item,
|
|
111
|
+
active,
|
|
112
|
+
onNavigate
|
|
113
|
+
}) {
|
|
114
|
+
const pop = usePopover(Boolean(item.disabled));
|
|
115
|
+
const id = useId();
|
|
116
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
117
|
+
/* @__PURE__ */ jsxs(
|
|
118
|
+
"button",
|
|
119
|
+
{
|
|
120
|
+
type: "button",
|
|
121
|
+
className: s.link,
|
|
122
|
+
ref: pop.anchor,
|
|
123
|
+
disabled: item.disabled,
|
|
124
|
+
"aria-haspopup": "menu",
|
|
125
|
+
"aria-expanded": pop.open,
|
|
126
|
+
"aria-controls": id,
|
|
127
|
+
"data-selected": item.children?.some((entry) => entry.id === active) || void 0,
|
|
128
|
+
onClick: pop.toggle,
|
|
129
|
+
onKeyDown: (event) => {
|
|
130
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
pop.show();
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
children: [
|
|
136
|
+
item.icon,
|
|
137
|
+
/* @__PURE__ */ jsx("span", { children: item.label }),
|
|
138
|
+
/* @__PURE__ */ jsx(ChevronDown, { size: 14, className: s.chevron, "aria-hidden": "true" })
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ jsx(
|
|
143
|
+
Popover,
|
|
144
|
+
{
|
|
145
|
+
id,
|
|
146
|
+
open: pop.open,
|
|
147
|
+
onClose: pop.close,
|
|
148
|
+
anchor: pop.anchor,
|
|
149
|
+
label: item.label,
|
|
150
|
+
role: "menu",
|
|
151
|
+
onKeyDown: (event) => {
|
|
152
|
+
const entries = [
|
|
153
|
+
...event.currentTarget.querySelectorAll(
|
|
154
|
+
'a[href]:not([aria-disabled="true"])'
|
|
155
|
+
)
|
|
156
|
+
];
|
|
157
|
+
const index = entries.indexOf(
|
|
158
|
+
document.activeElement
|
|
159
|
+
);
|
|
160
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? entries.length - 1 : event.key === "ArrowDown" ? (index + 1) % entries.length : event.key === "ArrowUp" ? (index - 1 + entries.length) % entries.length : -1;
|
|
161
|
+
if (next >= 0) {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
entries[next]?.focus();
|
|
164
|
+
}
|
|
165
|
+
if (event.key === "Tab") pop.close();
|
|
166
|
+
},
|
|
167
|
+
children: item.children?.map((entry) => /* @__PURE__ */ jsxs(
|
|
168
|
+
"a",
|
|
169
|
+
{
|
|
170
|
+
role: "menuitem",
|
|
171
|
+
className: s.menuItem,
|
|
172
|
+
href: entry.disabled ? void 0 : entry.path,
|
|
173
|
+
"aria-disabled": entry.disabled || void 0,
|
|
174
|
+
tabIndex: entry.disabled ? -1 : 0,
|
|
175
|
+
"aria-current": active === entry.id ? "page" : void 0,
|
|
176
|
+
onClick: (event) => {
|
|
177
|
+
if (entry.disabled) {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
pop.closeAndFocus();
|
|
182
|
+
follow(event, entry.path, onNavigate);
|
|
183
|
+
},
|
|
184
|
+
children: [
|
|
185
|
+
entry.icon,
|
|
186
|
+
/* @__PURE__ */ jsx("span", { children: entry.label })
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
entry.id
|
|
190
|
+
))
|
|
191
|
+
}
|
|
192
|
+
)
|
|
193
|
+
] });
|
|
194
|
+
}
|
|
195
|
+
export {
|
|
196
|
+
NavBar
|
|
197
|
+
};
|