@openviking/react 0.1.5 → 0.1.7

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.
Files changed (145) hide show
  1. package/README.md +15 -11
  2. package/dist/2~0.js +6 -5
  3. package/dist/37~0.js +27 -0
  4. package/dist/3c~0.js +24 -12
  5. package/dist/3~0.js +19 -9
  6. package/dist/ae~0.js +8 -1
  7. package/dist/ark-message-list-view~0.js +9 -4
  8. package/dist/a~0.js +13 -7
  9. package/dist/c7r~0.js +50 -0
  10. package/dist/ck~0.js +7 -0
  11. package/dist/client/paths.d.ts +10 -0
  12. package/dist/client/provider.d.ts +6 -1
  13. package/dist/components/agent-connect/style.css +268 -37
  14. package/dist/components/directory-tour/style.css +265 -21
  15. package/dist/components/directory-tour.js +1 -1
  16. package/dist/components/experience-dashboard/dashboard-tabs.d.ts +11 -0
  17. package/dist/components/experience-dashboard/experience-dashboard.d.ts +2 -0
  18. package/dist/components/experience-dashboard/experience-impact.d.ts +11 -0
  19. package/dist/components/experience-dashboard/experience-list.d.ts +9 -0
  20. package/dist/components/experience-dashboard/experience-pagination.d.ts +8 -0
  21. package/dist/components/experience-dashboard/experience-tests.d.ts +6 -0
  22. package/dist/components/experience-dashboard/experience-trajectories.d.ts +6 -0
  23. package/dist/components/experience-dashboard/index.d.ts +2 -0
  24. package/dist/components/experience-dashboard/labels.d.ts +2 -0
  25. package/dist/components/experience-dashboard/style.css +914 -0
  26. package/dist/components/experience-dashboard/style.js +0 -0
  27. package/dist/components/experience-dashboard/types.d.ts +106 -0
  28. package/dist/components/experience-dashboard.js +1 -0
  29. package/dist/components/file-browser-entries/style.css +463 -86
  30. package/dist/components/file-preview/style.css +267 -78
  31. package/dist/components/file-tree/file-tree-toolbar.d.ts +3 -3
  32. package/dist/components/file-tree/locales/en-US.d.ts +3 -0
  33. package/dist/components/file-tree/locales/zh-CN.d.ts +3 -0
  34. package/dist/components/file-tree/style.css +372 -88
  35. package/dist/components/file-tree/types.d.ts +13 -4
  36. package/dist/components/scope-switcher/style.css +412 -39
  37. package/dist/components/style.css +9326 -4553
  38. package/dist/components/tui/style.css +385 -67
  39. package/dist/components/viking-bot/interaction/style.css +143 -22
  40. package/dist/components/viking-bot/style.css +1075 -278
  41. package/dist/components/wiki-dashboard/index.d.ts +2 -0
  42. package/dist/components/wiki-dashboard/labels.d.ts +2 -0
  43. package/dist/components/wiki-dashboard/style.css +956 -0
  44. package/dist/components/wiki-dashboard/style.js +0 -0
  45. package/dist/components/wiki-dashboard/types.d.ts +92 -0
  46. package/dist/components/wiki-dashboard/wiki-action-button.d.ts +9 -0
  47. package/dist/components/wiki-dashboard/wiki-conflict-card.d.ts +15 -0
  48. package/dist/components/wiki-dashboard/wiki-dashboard.d.ts +2 -0
  49. package/dist/components/wiki-dashboard/wiki-file-icon.d.ts +3 -0
  50. package/dist/components/wiki-dashboard/wiki-severity-filter.d.ts +8 -0
  51. package/dist/components/wiki-dashboard.js +1 -0
  52. package/dist/c~0.js +16 -8
  53. package/dist/ep~0.js +345 -0
  54. package/dist/e~0.js +33 -328
  55. package/dist/fj~0.js +507 -0
  56. package/dist/fl~0.js +709 -0
  57. package/dist/f~0.js +12 -27
  58. package/dist/icons/index.d.ts +28 -0
  59. package/dist/icons.js +1 -1
  60. package/dist/index.d.ts +4 -0
  61. package/dist/index.js +3 -1
  62. package/dist/k~0.js +277 -1
  63. package/dist/lk~0.js +56 -14
  64. package/dist/l~0.js +2786 -446
  65. package/dist/modules/console/index.d.ts +1 -2
  66. package/dist/modules/console/style.css +1787 -346
  67. package/dist/modules/console.js +1 -1
  68. package/dist/modules/file-browser/acl/acl-add-principal.d.ts +12 -0
  69. package/dist/modules/file-browser/acl/acl-candidate.d.ts +8 -0
  70. package/dist/modules/file-browser/acl/acl-client.d.ts +13 -0
  71. package/dist/modules/file-browser/acl/acl-confirmation.d.ts +6 -0
  72. package/dist/modules/file-browser/acl/acl-entry.d.ts +13 -0
  73. package/dist/modules/file-browser/acl/acl-labels.d.ts +47 -0
  74. package/dist/modules/file-browser/acl/acl-menu.d.ts +10 -0
  75. package/dist/modules/file-browser/acl/acl-modal.d.ts +17 -0
  76. package/dist/modules/file-browser/acl/acl-model.d.ts +17 -0
  77. package/dist/modules/file-browser/acl/acl-principal-tabs.d.ts +6 -0
  78. package/dist/modules/file-browser/acl/acl-tag.d.ts +7 -0
  79. package/dist/modules/file-browser/acl/locales/en-US.d.ts +44 -0
  80. package/dist/modules/file-browser/acl/locales/zh-CN.d.ts +44 -0
  81. package/dist/modules/file-browser/acl/use-acl-principals.d.ts +17 -0
  82. package/dist/modules/file-browser/acl/use-acl-report.d.ts +27 -0
  83. package/dist/modules/file-browser/acl-types.d.ts +86 -0
  84. package/dist/modules/file-browser/dashboard-data.d.ts +9 -0
  85. package/dist/modules/file-browser/dashboard-indicator.d.ts +8 -0
  86. package/dist/modules/file-browser/dashboard-labels.d.ts +9 -0
  87. package/dist/modules/file-browser/dashboard-model.d.ts +17 -0
  88. package/dist/modules/file-browser/dashboard-resource.d.ts +12 -0
  89. package/dist/modules/file-browser/experience-dashboard-pane.d.ts +8 -0
  90. package/dist/modules/file-browser/experience-data.d.ts +31 -0
  91. package/dist/modules/file-browser/file-browser-detail.d.ts +4 -1
  92. package/dist/modules/file-browser/file-browser-labels.d.ts +1 -1
  93. package/dist/modules/file-browser/file-browser-search.d.ts +20 -0
  94. package/dist/modules/file-browser/file-browser-toolbar.d.ts +3 -10
  95. package/dist/modules/file-browser/file-browser-tree-pane.d.ts +4 -7
  96. package/dist/modules/file-browser/file-browser.d.ts +1 -1
  97. package/dist/modules/file-browser/fs-directories.d.ts +9 -0
  98. package/dist/modules/file-browser/fs-lines.d.ts +36 -0
  99. package/dist/modules/file-browser/fs-memory-fields.d.ts +65 -0
  100. package/dist/modules/file-browser/fs-model.d.ts +15 -3
  101. package/dist/modules/file-browser/fs-read-file.d.ts +14 -0
  102. package/dist/modules/file-browser/index.d.ts +3 -2
  103. package/dist/modules/file-browser/locales/en-US.d.ts +5 -0
  104. package/dist/modules/file-browser/locales/zh-CN.d.ts +5 -0
  105. package/dist/modules/file-browser/style.css +4033 -483
  106. package/dist/modules/file-browser/types.d.ts +82 -20
  107. package/dist/modules/file-browser/use-browser-dashboards.d.ts +31 -0
  108. package/dist/modules/file-browser/use-dashboard-query.d.ts +9 -0
  109. package/dist/modules/file-browser/use-experience-dashboard.d.ts +27 -0
  110. package/dist/modules/file-browser/use-file-browser-acl.d.ts +15 -0
  111. package/dist/modules/file-browser/use-file-browser.d.ts +6 -51
  112. package/dist/modules/file-browser/use-fs-tree.d.ts +3 -0
  113. package/dist/modules/file-browser/use-wiki-dashboard.d.ts +17 -0
  114. package/dist/modules/file-browser/wiki-conflicts.d.ts +12 -0
  115. package/dist/modules/file-browser/wiki-dashboard-pane.d.ts +14 -0
  116. package/dist/modules/file-browser.js +1 -1
  117. package/dist/modules/scope-cascade/controller.d.ts +2 -2
  118. package/dist/modules/scope-cascade/index.d.ts +1 -2
  119. package/dist/modules/scope-cascade/scope-cascade.d.ts +1 -1
  120. package/dist/modules/scope-cascade/style.css +581 -39
  121. package/dist/modules/scope-cascade/types.d.ts +8 -3
  122. package/dist/modules/scope-cascade/use-scope-cascade.d.ts +2 -2
  123. package/dist/modules/scope-cascade.js +1 -1
  124. package/dist/modules/style.css +13589 -7966
  125. package/dist/n~0.js +73 -165
  126. package/dist/rt~0.js +255 -0
  127. package/dist/r~0.js +18 -39
  128. package/dist/shared/components/button/button.d.ts +20 -0
  129. package/dist/shared/components/input/input.d.ts +17 -0
  130. package/dist/shared/components/modal/locales/en-US.d.ts +4 -0
  131. package/dist/shared/components/modal/locales/zh-CN.d.ts +4 -0
  132. package/dist/shared/components/modal/modal.d.ts +2 -0
  133. package/dist/shared/components/modal/types.d.ts +18 -0
  134. package/dist/shared/components/overlay/lock-body-scroll.d.ts +1 -0
  135. package/dist/shared/components/popover/popover.d.ts +1 -1
  136. package/dist/shared/components/popover/types.d.ts +7 -1
  137. package/dist/shared/dashboard/dashboard-state.d.ts +12 -0
  138. package/dist/static/image/dashboard-background.png +0 -0
  139. package/dist/style.css +16088 -5602
  140. package/dist/s~0.js +16 -0
  141. package/dist/u~0.js +15 -6
  142. package/dist/viking-bot-composer~0.js +30 -12
  143. package/dist/viking-bot-interaction~0.js +2 -1
  144. package/package.json +14 -3
  145. package/dist/o~0.js +0 -106
package/dist/fj~0.js ADDED
@@ -0,0 +1,507 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useId, useRef, useState } from "react";
3
+ import { mergeLabels } from "./nx~0.js";
4
+ import { getFileTypeColor, getFileTypeIcon, WikiWarningIcon, WikiSuccessIcon, WikiEditIcon, WikiDiscussIcon, WikiHistoryIcon, resolveFileTypeIconKey } from "./k~0.js";
5
+ import { Tooltip } from "./rt~0.js";
6
+ import { button_Button } from "./e~0.js";
7
+ import { Popover } from "./r~0.js";
8
+ import { useLocale } from "./28~0.js";
9
+ import { DashboardState } from "./37~0.js";
10
+ const en = {
11
+ title: 'Generation results',
12
+ pendingLabel: 'Pending',
13
+ discuss: 'VikingBot discussion',
14
+ conflicts: 'All conflicts',
15
+ conflictFiles: 'Conflicting files',
16
+ pending: 'Pending conflicts',
17
+ all: 'All',
18
+ severity: 'Severity',
19
+ high: 'High',
20
+ medium: 'Medium',
21
+ low: 'Low',
22
+ fixed: 'Fixed',
23
+ reason: 'Reason',
24
+ file: 'File',
25
+ empty: 'No matching conflicts',
26
+ loading: 'Loading…',
27
+ failed: 'Could not load conflicts',
28
+ retry: 'Retry',
29
+ open: 'Open',
30
+ edit: 'Manual edit',
31
+ solution: 'Solution',
32
+ occurred: 'Detected',
33
+ fixedAt: 'Resolved',
34
+ evidence: 'Resolution basis',
35
+ history: 'Resolution history',
36
+ historyHint: 'View the resolution plan and evidence',
37
+ unavailable: 'Action unavailable',
38
+ limited: 'Showing up to 100 conflicting files'
39
+ };
40
+ const zh = {
41
+ title: '生成效果',
42
+ pendingLabel: '待确认',
43
+ discuss: 'VikingBot 对话',
44
+ conflicts: '全部冲突',
45
+ conflictFiles: '冲突文件数',
46
+ pending: '待确认冲突',
47
+ all: '全部',
48
+ severity: '严重程度',
49
+ high: '严重',
50
+ medium: '中等',
51
+ low: '普通',
52
+ fixed: '已修复',
53
+ reason: '原因',
54
+ file: '文件',
55
+ empty: '暂无符合条件的冲突',
56
+ loading: '加载中…',
57
+ failed: '冲突加载失败',
58
+ retry: '重试',
59
+ open: '打开',
60
+ edit: '人工修改',
61
+ solution: '修复方案',
62
+ occurred: '检测时间',
63
+ fixedAt: '修复时间',
64
+ evidence: '修复依据',
65
+ history: '修复回溯',
66
+ historyHint: '查看修复方案与依据',
67
+ unavailable: '当前不可操作',
68
+ limited: '最多展示 100 个存在待确认冲突的文件'
69
+ };
70
+ const wikiLabels = (locale, labels)=>mergeLabels('zh-CN' === locale ? zh : en, labels);
71
+ function WikiFileIcon({ name }) {
72
+ const Icon = getFileTypeIcon(name);
73
+ const key = resolveFileTypeIconKey(name);
74
+ return /*#__PURE__*/ jsx(Icon, {
75
+ "aria-hidden": "true",
76
+ className: "ov-wiki-dashboard__file-icon",
77
+ style: {
78
+ '--ov-ui-wiki-icon-light': getFileTypeColor(key, 'light'),
79
+ '--ov-ui-wiki-icon-dark': getFileTypeColor(key, 'dark')
80
+ }
81
+ });
82
+ }
83
+ function WikiActionButton({ label, hint, onClick, children, ...aria }) {
84
+ return /*#__PURE__*/ jsx(Tooltip, {
85
+ content: hint,
86
+ children: /*#__PURE__*/ jsx(button_Button, {
87
+ size: "mini",
88
+ type: "text",
89
+ iconOnly: true,
90
+ ...aria,
91
+ htmlType: "button",
92
+ "aria-label": label,
93
+ "aria-disabled": !onClick || void 0,
94
+ "aria-description": onClick ? void 0 : hint,
95
+ onClick: ()=>onClick?.(),
96
+ children: children
97
+ })
98
+ });
99
+ }
100
+ function WikiConflictCard({ conflict, path, labels: t, editDisabledReason, discussDisabledReason, onOpenUri, onEdit, onDiscuss }) {
101
+ const [expanded, setExpanded] = useState(false);
102
+ const id = useId();
103
+ const fixed = 'fixed' === conflict.state;
104
+ const StatusIcon = fixed ? WikiSuccessIcon : WikiWarningIcon;
105
+ return /*#__PURE__*/ jsxs("article", {
106
+ className: "ov-wiki-dashboard__conflict",
107
+ children: [
108
+ /*#__PURE__*/ jsxs("div", {
109
+ className: `ov-wiki-dashboard__conflict-row${path ? '' : ' ov-wiki-dashboard__conflict-row--without-path'}`,
110
+ children: [
111
+ /*#__PURE__*/ jsxs("span", {
112
+ className: `ov-wiki-dashboard__status ov-wiki-dashboard__status--${conflict.state}`,
113
+ children: [
114
+ /*#__PURE__*/ jsx(StatusIcon, {
115
+ width: 14,
116
+ height: 14
117
+ }),
118
+ fixed ? t.fixed : t.pendingLabel
119
+ ]
120
+ }),
121
+ /*#__PURE__*/ jsxs("div", {
122
+ className: "ov-wiki-dashboard__issue",
123
+ children: [
124
+ /*#__PURE__*/ jsx("button", {
125
+ type: "button",
126
+ "aria-expanded": expanded,
127
+ "aria-controls": id,
128
+ title: conflict.description,
129
+ onClick: ()=>setExpanded(!expanded),
130
+ children: conflict.description
131
+ }),
132
+ /*#__PURE__*/ jsx("p", {
133
+ title: conflict.reason,
134
+ children: conflict.reason
135
+ }),
136
+ fixed && conflict.fixPlan ? /*#__PURE__*/ jsxs("span", {
137
+ className: "ov-wiki-dashboard__solution",
138
+ children: [
139
+ t.solution,
140
+ ": ",
141
+ conflict.fixPlan
142
+ ]
143
+ }) : null
144
+ ]
145
+ }),
146
+ path ? /*#__PURE__*/ jsxs("div", {
147
+ className: "ov-wiki-dashboard__path",
148
+ children: [
149
+ /*#__PURE__*/ jsx(WikiFileIcon, {
150
+ name: path
151
+ }),
152
+ /*#__PURE__*/ jsx("button", {
153
+ type: "button",
154
+ className: "ov-wiki-dashboard__link",
155
+ title: path,
156
+ disabled: !onOpenUri,
157
+ onClick: ()=>onOpenUri?.(),
158
+ children: path
159
+ })
160
+ ]
161
+ }) : null,
162
+ /*#__PURE__*/ jsx("span", {
163
+ className: `ov-wiki-dashboard__severity ov-wiki-dashboard__severity--${conflict.severity}`,
164
+ children: t[conflict.severity]
165
+ }),
166
+ /*#__PURE__*/ jsx("div", {
167
+ className: "ov-wiki-dashboard__actions",
168
+ children: fixed ? /*#__PURE__*/ jsx(WikiActionButton, {
169
+ label: t.history,
170
+ hint: t.historyHint,
171
+ "aria-expanded": expanded,
172
+ "aria-controls": id,
173
+ onClick: ()=>setExpanded(!expanded),
174
+ children: /*#__PURE__*/ jsx(WikiHistoryIcon, {
175
+ width: 14,
176
+ height: 14
177
+ })
178
+ }) : /*#__PURE__*/ jsxs(Fragment, {
179
+ children: [
180
+ /*#__PURE__*/ jsx(WikiActionButton, {
181
+ label: `${t.edit}: ${conflict.description}`,
182
+ hint: onEdit ? t.edit : editDisabledReason || t.unavailable,
183
+ onClick: onEdit ? ()=>onEdit(conflict) : void 0,
184
+ children: /*#__PURE__*/ jsx(WikiEditIcon, {
185
+ width: 14,
186
+ height: 14
187
+ })
188
+ }),
189
+ /*#__PURE__*/ jsx(WikiActionButton, {
190
+ label: `${t.discuss}: ${conflict.description}`,
191
+ hint: onDiscuss ? t.discuss : discussDisabledReason || t.unavailable,
192
+ onClick: onDiscuss ? ()=>onDiscuss(conflict) : void 0,
193
+ children: /*#__PURE__*/ jsx(WikiDiscussIcon, {
194
+ width: 14,
195
+ height: 14
196
+ })
197
+ })
198
+ ]
199
+ })
200
+ })
201
+ ]
202
+ }),
203
+ /*#__PURE__*/ jsx("div", {
204
+ id: id,
205
+ hidden: !expanded,
206
+ className: "ov-wiki-dashboard__evidence",
207
+ children: /*#__PURE__*/ jsxs("dl", {
208
+ children: [
209
+ /*#__PURE__*/ jsx("dt", {
210
+ children: t.reason
211
+ }),
212
+ /*#__PURE__*/ jsx("dd", {
213
+ children: conflict.reason || '—'
214
+ }),
215
+ /*#__PURE__*/ jsx("dt", {
216
+ children: t.occurred
217
+ }),
218
+ /*#__PURE__*/ jsx("dd", {
219
+ children: /*#__PURE__*/ jsx("time", {
220
+ dateTime: new Date(1000 * conflict.beginTime).toISOString(),
221
+ children: new Date(1000 * conflict.beginTime).toISOString()
222
+ })
223
+ }),
224
+ /*#__PURE__*/ jsx("dt", {
225
+ children: t.fixedAt
226
+ }),
227
+ /*#__PURE__*/ jsx("dd", {
228
+ children: null === conflict.fixTime ? '—' : /*#__PURE__*/ jsx("time", {
229
+ dateTime: new Date(1000 * conflict.fixTime).toISOString(),
230
+ children: new Date(1000 * conflict.fixTime).toISOString()
231
+ })
232
+ }),
233
+ /*#__PURE__*/ jsx("dt", {
234
+ children: t.solution
235
+ }),
236
+ /*#__PURE__*/ jsx("dd", {
237
+ children: conflict.fixPlan || '—'
238
+ }),
239
+ /*#__PURE__*/ jsx("dt", {
240
+ children: t.evidence
241
+ }),
242
+ /*#__PURE__*/ jsx("dd", {
243
+ children: conflict.resolutionBasis || '—'
244
+ })
245
+ ]
246
+ })
247
+ })
248
+ ]
249
+ });
250
+ }
251
+ const SvgSeverityFilter = (props)=>/*#__PURE__*/ jsx("svg", {
252
+ xmlns: "http://www.w3.org/2000/svg",
253
+ width: 14,
254
+ height: 14,
255
+ fill: "none",
256
+ overflow: "visible",
257
+ preserveAspectRatio: "none",
258
+ style: {
259
+ display: "block"
260
+ },
261
+ viewBox: "0 0 14 14",
262
+ ...props,
263
+ children: /*#__PURE__*/ jsx("g", {
264
+ fill: "currentColor",
265
+ children: /*#__PURE__*/ jsx("path", {
266
+ d: "M11.375 9.917a1.458 1.458 0 1 0-2.916-.001 1.458 1.458 0 0 0 2.916 0m.875 0a2.333 2.333 0 1 1-2.77-2.293V2.188a.437.437 0 1 1 .874 0v5.436a2.33 2.33 0 0 1 1.896 2.293M5.542 5.25a1.458 1.458 0 1 0-2.916-.001 1.458 1.458 0 0 0 2.916.001m.875 0c0 1.14-.816 2.087-1.896 2.292v4.27a.438.438 0 0 1-.875 0v-4.27a2.333 2.333 0 0 1 0-4.584v-.77a.438.438 0 0 1 .875 0v.77A2.33 2.33 0 0 1 6.417 5.25"
267
+ })
268
+ })
269
+ });
270
+ const severity_filterreact = SvgSeverityFilter;
271
+ const SvgFilterChevron = (props)=>/*#__PURE__*/ jsx("svg", {
272
+ xmlns: "http://www.w3.org/2000/svg",
273
+ width: 14,
274
+ height: 14,
275
+ fill: "none",
276
+ overflow: "visible",
277
+ preserveAspectRatio: "none",
278
+ style: {
279
+ display: "block"
280
+ },
281
+ viewBox: "0 0 14 14",
282
+ ...props,
283
+ children: /*#__PURE__*/ jsx("path", {
284
+ fill: "currentColor",
285
+ d: "M9.607 5.232a.437.437 0 1 1 .619.619L7.309 8.768a.437.437 0 0 1-.618 0L3.774 5.85a.437.437 0 1 1 .619-.619L7 7.84z"
286
+ })
287
+ });
288
+ const filter_chevronreact = SvgFilterChevron;
289
+ const values = [
290
+ 'all',
291
+ 'high',
292
+ 'medium',
293
+ 'low'
294
+ ];
295
+ function WikiSeverityFilter({ value, onChange, labels: t }) {
296
+ const [open, setOpen] = useState(false);
297
+ const trigger = useRef(null);
298
+ const id = useId();
299
+ const focusSelected = useCallback((node)=>{
300
+ node?.querySelector('[aria-selected="true"]')?.focus();
301
+ }, []);
302
+ const close = ()=>{
303
+ setOpen(false);
304
+ trigger.current?.focus();
305
+ };
306
+ return /*#__PURE__*/ jsx(Popover, {
307
+ trigger: "click",
308
+ placement: "bottom",
309
+ open: open,
310
+ onOpenChange: setOpen,
311
+ role: "presentation",
312
+ className: "ov-wiki-dashboard__severity-popover",
313
+ content: /*#__PURE__*/ jsx("div", {
314
+ ref: focusSelected,
315
+ id: id,
316
+ role: "listbox",
317
+ tabIndex: -1,
318
+ "aria-label": t.severity,
319
+ className: "ov-wiki-dashboard__severity-menu",
320
+ onBlur: (event)=>{
321
+ if (!event.currentTarget.contains(event.relatedTarget) && event.relatedTarget !== trigger.current) setOpen(false);
322
+ },
323
+ onKeyDown: (event)=>{
324
+ if ('Escape' === event.key || 'Tab' === event.key) {
325
+ if ('Escape' === event.key) event.preventDefault();
326
+ close();
327
+ return;
328
+ }
329
+ if (![
330
+ 'ArrowDown',
331
+ 'ArrowUp',
332
+ 'Home',
333
+ 'End'
334
+ ].includes(event.key)) return;
335
+ event.preventDefault();
336
+ const options = [
337
+ ...event.currentTarget.querySelectorAll('[role="option"]')
338
+ ];
339
+ const index = options.indexOf(event.target);
340
+ const next = 'Home' === event.key ? 0 : 'End' === event.key ? options.length - 1 : (index + ('ArrowDown' === event.key ? 1 : -1) + options.length) % options.length;
341
+ options[next]?.focus();
342
+ },
343
+ children: values.map((severity)=>/*#__PURE__*/ jsx("button", {
344
+ type: "button",
345
+ role: "option",
346
+ "aria-selected": value === severity,
347
+ tabIndex: value === severity ? 0 : -1,
348
+ onClick: ()=>{
349
+ onChange(severity);
350
+ close();
351
+ },
352
+ children: t[severity]
353
+ }, severity))
354
+ }),
355
+ children: /*#__PURE__*/ jsxs("button", {
356
+ type: "button",
357
+ "aria-haspopup": "listbox",
358
+ "aria-controls": open ? id : void 0,
359
+ "aria-expanded": open,
360
+ "aria-label": `${t.severity}: ${t[value]}`,
361
+ className: "ov-wiki-dashboard__severity-filter",
362
+ onClick: (event)=>{
363
+ trigger.current = event.currentTarget;
364
+ },
365
+ onKeyDown: (event)=>{
366
+ trigger.current = event.currentTarget;
367
+ if ('ArrowDown' === event.key || 'ArrowUp' === event.key) {
368
+ event.preventDefault();
369
+ setOpen(true);
370
+ }
371
+ },
372
+ children: [
373
+ /*#__PURE__*/ jsx(severity_filterreact, {
374
+ "aria-hidden": "true"
375
+ }),
376
+ /*#__PURE__*/ jsx("span", {
377
+ children: t.severity
378
+ }),
379
+ /*#__PURE__*/ jsx("span", {
380
+ className: "ov-wiki-dashboard__filter-value",
381
+ children: t[value]
382
+ }),
383
+ /*#__PURE__*/ jsx(filter_chevronreact, {
384
+ "aria-hidden": "true"
385
+ })
386
+ ]
387
+ })
388
+ });
389
+ }
390
+ function WikiDashboard(props) {
391
+ const { kind, data, editDisabledReason, discussDisabledReason, locale: localeProp, onOpenUri, onOpenDashboard, onEdit, onDiscuss, labels, loading, error, onRetry, className, ...rest } = props;
392
+ const locale = useLocale(localeProp);
393
+ const t = wikiLabels(locale, labels);
394
+ const [severity, setSeverity] = useState('all');
395
+ const conflicts = 'file' === kind ? data?.conflicts.filter((item)=>'all' === severity || item.severity === severity) ?? [] : [];
396
+ const count = data ? 'file' === kind ? data.conflicts.filter((item)=>'unfixed' === item.state).length : data.conflictFileCount : void 0;
397
+ return /*#__PURE__*/ jsxs("div", {
398
+ ...rest,
399
+ className: [
400
+ 'ov-wiki-dashboard',
401
+ className
402
+ ].filter(Boolean).join(' '),
403
+ children: [
404
+ /*#__PURE__*/ jsx("header", {
405
+ className: "ov-wiki-dashboard__header",
406
+ children: /*#__PURE__*/ jsx("h2", {
407
+ children: t.title
408
+ })
409
+ }),
410
+ /*#__PURE__*/ jsxs("div", {
411
+ className: "ov-wiki-dashboard__body",
412
+ children: [
413
+ /*#__PURE__*/ jsx("dl", {
414
+ className: "ov-wiki-dashboard__statistics",
415
+ children: /*#__PURE__*/ jsxs("div", {
416
+ children: [
417
+ /*#__PURE__*/ jsx(WikiWarningIcon, {
418
+ width: 14,
419
+ height: 14
420
+ }),
421
+ /*#__PURE__*/ jsx("dd", {
422
+ children: void 0 === count ? '—' : 'directory' === kind && count >= 100 ? '99+' : `${count}${'directory' === kind && data?.limited ? '+' : ''}`
423
+ }),
424
+ /*#__PURE__*/ jsx("dt", {
425
+ children: 'file' === kind ? t.pending : t.conflictFiles
426
+ })
427
+ ]
428
+ })
429
+ }),
430
+ /*#__PURE__*/ jsxs("div", {
431
+ className: "ov-wiki-dashboard__toolbar",
432
+ children: [
433
+ /*#__PURE__*/ jsx("h3", {
434
+ children: t.conflicts
435
+ }),
436
+ 'file' === kind ? /*#__PURE__*/ jsx(WikiSeverityFilter, {
437
+ value: severity,
438
+ onChange: setSeverity,
439
+ labels: t
440
+ }) : null
441
+ ]
442
+ }),
443
+ 'file' === kind && conflicts.length ? /*#__PURE__*/ jsx("div", {
444
+ className: "ov-wiki-dashboard__conflicts",
445
+ role: "region",
446
+ "aria-label": t.conflicts,
447
+ tabIndex: 0,
448
+ children: conflicts.map((conflict)=>/*#__PURE__*/ jsx(WikiConflictCard, {
449
+ conflict: conflict,
450
+ path: data?.path,
451
+ labels: t,
452
+ editDisabledReason: editDisabledReason,
453
+ discussDisabledReason: discussDisabledReason,
454
+ onOpenUri: onOpenUri,
455
+ onEdit: onEdit,
456
+ onDiscuss: onDiscuss
457
+ }, conflict.id))
458
+ }) : 'directory' === kind && data?.files.length ? /*#__PURE__*/ jsx("ul", {
459
+ className: "ov-wiki-dashboard__files",
460
+ children: data.files.map((file)=>/*#__PURE__*/ jsxs("li", {
461
+ children: [
462
+ /*#__PURE__*/ jsx(WikiFileIcon, {
463
+ name: file
464
+ }),
465
+ /*#__PURE__*/ jsxs("button", {
466
+ type: "button",
467
+ className: "ov-wiki-dashboard__link",
468
+ disabled: !onOpenDashboard && !onOpenUri,
469
+ onClick: ()=>(onOpenDashboard ?? onOpenUri)?.(file),
470
+ children: [
471
+ /*#__PURE__*/ jsx("span", {
472
+ children: file.split('/').pop()
473
+ }),
474
+ /*#__PURE__*/ jsx("span", {
475
+ className: "ov-wiki-dashboard__file-uri",
476
+ children: file
477
+ })
478
+ ]
479
+ }),
480
+ onEdit ? /*#__PURE__*/ jsx(button_Button, {
481
+ size: "small",
482
+ onClick: ()=>onEdit(file),
483
+ children: t.edit
484
+ }) : null
485
+ ]
486
+ }, file))
487
+ }) : /*#__PURE__*/ jsx(DashboardState, {
488
+ state: {
489
+ loading,
490
+ error,
491
+ onRetry
492
+ },
493
+ empty: t.empty,
494
+ loading: t.loading,
495
+ failed: t.failed,
496
+ retry: t.retry
497
+ }),
498
+ 'directory' === kind && data?.limited ? /*#__PURE__*/ jsx("p", {
499
+ className: "ov-wiki-dashboard__limited",
500
+ children: t.limited
501
+ }) : null
502
+ ]
503
+ })
504
+ ]
505
+ });
506
+ }
507
+ export { WikiDashboard };