@openviking/react 0.1.6 → 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 (94) hide show
  1. package/README.md +2 -0
  2. package/dist/2~0.js +6 -5
  3. package/dist/3c~0.js +10 -4
  4. package/dist/3~0.js +18 -8
  5. package/dist/ae~0.js +8 -1
  6. package/dist/ark-message-list-view~0.js +9 -4
  7. package/dist/a~0.js +12 -6
  8. package/dist/c7r~0.js +50 -0
  9. package/dist/ck~0.js +3 -0
  10. package/dist/client/paths.d.ts +6 -0
  11. package/dist/client/provider.d.ts +6 -1
  12. package/dist/components/agent-connect/style.css +222 -35
  13. package/dist/components/directory-tour/style.css +221 -21
  14. package/dist/components/directory-tour.js +1 -1
  15. package/dist/components/experience-dashboard/style.css +227 -12
  16. package/dist/components/experience-dashboard.js +1 -1
  17. package/dist/components/file-browser-entries/style.css +325 -80
  18. package/dist/components/file-preview/style.css +221 -76
  19. package/dist/components/file-tree/file-tree-toolbar.d.ts +3 -3
  20. package/dist/components/file-tree/locales/en-US.d.ts +3 -0
  21. package/dist/components/file-tree/locales/zh-CN.d.ts +3 -0
  22. package/dist/components/file-tree/style.css +311 -86
  23. package/dist/components/file-tree/types.d.ts +13 -4
  24. package/dist/components/scope-switcher/style.css +366 -37
  25. package/dist/components/scope-switcher.js +1 -1
  26. package/dist/components/style.css +3329 -640
  27. package/dist/components/tui/style.css +267 -35
  28. package/dist/components/viking-bot/interaction/style.css +143 -22
  29. package/dist/components/viking-bot/style.css +945 -295
  30. package/dist/components/wiki-dashboard/style.css +227 -12
  31. package/dist/c~0.js +16 -8
  32. package/dist/ep~0.js +345 -0
  33. package/dist/e~0.js +33 -328
  34. package/dist/fj~0.js +8 -4
  35. package/dist/fl~0.js +709 -0
  36. package/dist/f~0.js +302 -663
  37. package/dist/index.js +3 -3
  38. package/dist/lk~0.js +6 -3
  39. package/dist/l~0.js +1874 -437
  40. package/dist/modules/console/style.css +1471 -351
  41. package/dist/modules/file-browser/acl/acl-add-principal.d.ts +12 -0
  42. package/dist/modules/file-browser/acl/acl-candidate.d.ts +8 -0
  43. package/dist/modules/file-browser/acl/acl-client.d.ts +13 -0
  44. package/dist/modules/file-browser/acl/acl-confirmation.d.ts +6 -0
  45. package/dist/modules/file-browser/acl/acl-entry.d.ts +13 -0
  46. package/dist/modules/file-browser/acl/acl-labels.d.ts +47 -0
  47. package/dist/modules/file-browser/acl/acl-menu.d.ts +10 -0
  48. package/dist/modules/file-browser/acl/acl-modal.d.ts +17 -0
  49. package/dist/modules/file-browser/acl/acl-model.d.ts +17 -0
  50. package/dist/modules/file-browser/acl/acl-principal-tabs.d.ts +6 -0
  51. package/dist/modules/file-browser/acl/acl-tag.d.ts +7 -0
  52. package/dist/modules/file-browser/acl/locales/en-US.d.ts +44 -0
  53. package/dist/modules/file-browser/acl/locales/zh-CN.d.ts +44 -0
  54. package/dist/modules/file-browser/acl/use-acl-principals.d.ts +17 -0
  55. package/dist/modules/file-browser/acl/use-acl-report.d.ts +27 -0
  56. package/dist/modules/file-browser/acl-types.d.ts +86 -0
  57. package/dist/modules/file-browser/dashboard-model.d.ts +3 -0
  58. package/dist/modules/file-browser/file-browser-detail.d.ts +4 -1
  59. package/dist/modules/file-browser/file-browser-labels.d.ts +1 -1
  60. package/dist/modules/file-browser/file-browser-search.d.ts +20 -0
  61. package/dist/modules/file-browser/file-browser-toolbar.d.ts +3 -10
  62. package/dist/modules/file-browser/file-browser-tree-pane.d.ts +2 -6
  63. package/dist/modules/file-browser/file-browser.d.ts +1 -1
  64. package/dist/modules/file-browser/fs-directories.d.ts +1 -0
  65. package/dist/modules/file-browser/fs-model.d.ts +3 -1
  66. package/dist/modules/file-browser/index.d.ts +1 -0
  67. package/dist/modules/file-browser/locales/en-US.d.ts +5 -0
  68. package/dist/modules/file-browser/locales/zh-CN.d.ts +5 -0
  69. package/dist/modules/file-browser/style.css +2409 -603
  70. package/dist/modules/file-browser/types.d.ts +20 -20
  71. package/dist/modules/file-browser/use-file-browser-acl.d.ts +15 -0
  72. package/dist/modules/file-browser/use-file-browser.d.ts +5 -7
  73. package/dist/modules/file-browser/use-fs-tree.d.ts +1 -0
  74. package/dist/modules/scope-cascade/style.css +535 -37
  75. package/dist/modules/style.css +12227 -8757
  76. package/dist/n~0.js +60 -36
  77. package/dist/rt~0.js +107 -4
  78. package/dist/r~0.js +1 -1
  79. package/dist/shared/components/button/button.d.ts +20 -0
  80. package/dist/shared/components/input/input.d.ts +17 -0
  81. package/dist/shared/components/modal/locales/en-US.d.ts +4 -0
  82. package/dist/shared/components/modal/locales/zh-CN.d.ts +4 -0
  83. package/dist/shared/components/modal/modal.d.ts +2 -0
  84. package/dist/shared/components/modal/types.d.ts +18 -0
  85. package/dist/shared/components/overlay/lock-body-scroll.d.ts +1 -0
  86. package/dist/style.css +7776 -1571
  87. package/dist/s~0.js +16 -0
  88. package/dist/u~0.js +15 -6
  89. package/dist/viking-bot-composer~0.js +29 -11
  90. package/dist/viking-bot-interaction~0.js +2 -1
  91. package/package.json +3 -2
  92. package/dist/fi~0.js +0 -354
  93. package/dist/modules/file-browser/fs-selection.d.ts +0 -4
  94. package/dist/o~0.js +0 -106
package/dist/s~0.js ADDED
@@ -0,0 +1,16 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ const SvgChevronDown = (props)=>/*#__PURE__*/ jsx("svg", {
4
+ xmlns: "http://www.w3.org/2000/svg",
5
+ width: 14,
6
+ height: 14,
7
+ fill: "none",
8
+ viewBox: "0 0 14 14",
9
+ ...props,
10
+ children: /*#__PURE__*/ jsx("path", {
11
+ fill: "currentColor",
12
+ 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"
13
+ })
14
+ });
15
+ const chevron_downreact = SvgChevronDown;
16
+ export { chevron_downreact };
package/dist/u~0.js CHANGED
@@ -6,6 +6,7 @@ import rehype_sanitize from "rehype-sanitize";
6
6
  import remark_gfm from "remark-gfm";
7
7
  import { resolveLocale } from "./nx~0.js";
8
8
  import { checkreact } from "./0~0.js";
9
+ import { button_Button } from "./e~0.js";
9
10
  import { useLocale } from "./28~0.js";
10
11
  const SvgCodexDetail = (props)=>/*#__PURE__*/ jsxs("svg", {
11
12
  xmlns: "http://www.w3.org/2000/svg",
@@ -693,8 +694,11 @@ function AgentConnectCodeBlock({ display, copyText, language, locale, visibleBlo
693
694
  /*#__PURE__*/ jsxs("div", {
694
695
  className: "ov-agent-connect__code-actions",
695
696
  children: [
696
- hasKey ? /*#__PURE__*/ jsx("button", {
697
- type: "button",
697
+ hasKey ? /*#__PURE__*/ jsx(button_Button, {
698
+ size: "mini",
699
+ type: "text",
700
+ iconOnly: true,
701
+ htmlType: "button",
698
702
  "aria-pressed": revealed,
699
703
  "aria-label": revealLabel,
700
704
  title: revealLabel,
@@ -703,8 +707,11 @@ function AgentConnectCodeBlock({ display, copyText, language, locale, visibleBlo
703
707
  "aria-hidden": "true"
704
708
  })
705
709
  }) : null,
706
- /*#__PURE__*/ jsx("button", {
707
- type: "button",
710
+ /*#__PURE__*/ jsx(button_Button, {
711
+ size: "mini",
712
+ type: "text",
713
+ iconOnly: true,
714
+ htmlType: "button",
708
715
  disabled: 'pending' === status,
709
716
  "aria-label": copyLabel,
710
717
  title: copyLabel,
@@ -907,9 +914,11 @@ function AgentConnectInstructionsView({ instructions, apiKey, locale, agreementU
907
914
  className: "ov-agent-connect__instructions-title",
908
915
  children: labels.instructions
909
916
  }),
910
- /*#__PURE__*/ jsxs("button", {
917
+ /*#__PURE__*/ jsxs(button_Button, {
918
+ size: "mini",
919
+ type: "text",
911
920
  className: "ov-agent-connect__copy",
912
- type: "button",
921
+ htmlType: "button",
913
922
  disabled: 'pending' === status,
914
923
  onClick: ()=>void copy(),
915
924
  children: [
@@ -2,9 +2,11 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Sender } from "@ark-design/ui/sender";
3
3
  import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
4
4
  import { Tooltip } from "./rt~0.js";
5
+ import { button_Button } from "./e~0.js";
5
6
  import { VikingBotIcon } from "./lg~0.js";
6
7
  import { resolveVikingBotLabels, BotPopover, useQuickInput, QuickInputs } from "./c~0.js";
7
8
  import { usePortalTheme } from "./9~0.js";
9
+ import { input_Input } from "./c7r~0.js";
8
10
  import { FileTree as file_tree_FileTree } from "./n~0.js";
9
11
  import { useLocale } from "./28~0.js";
10
12
  const SvgSend = (props)=>/*#__PURE__*/ jsx("svg", {
@@ -34,9 +36,13 @@ const attachreact = SvgAttach;
34
36
  function VikingBotSubmit({ onSend, onStop, sending, tip, className, label, ...props }) {
35
37
  return /*#__PURE__*/ jsx(Tooltip, {
36
38
  content: tip ?? label,
37
- children: /*#__PURE__*/ jsx("button", {
39
+ children: /*#__PURE__*/ jsx(button_Button, {
38
40
  ...props,
39
- type: "button",
41
+ size: "default",
42
+ type: "primary",
43
+ shape: "circle",
44
+ iconOnly: true,
45
+ htmlType: "button",
40
46
  className: [
41
47
  'ov-viking-bot__submit',
42
48
  className
@@ -56,9 +62,12 @@ function VikingBotSubmit({ onSend, onStop, sending, tip, className, label, ...pr
56
62
  function VikingBotAttach({ label, ...props }) {
57
63
  return /*#__PURE__*/ jsx(Tooltip, {
58
64
  content: label,
59
- children: /*#__PURE__*/ jsx("button", {
65
+ children: /*#__PURE__*/ jsx(button_Button, {
60
66
  ...props,
61
- type: "button",
67
+ size: "mini",
68
+ type: "text",
69
+ iconOnly: true,
70
+ htmlType: "button",
62
71
  className: "ov-viking-bot__attach",
63
72
  "aria-label": label,
64
73
  children: /*#__PURE__*/ jsx(attachreact, {
@@ -106,8 +115,11 @@ function ComposerAttachments({ items, onRemove, disabled, labels }) {
106
115
  className: "ov-viking-bot__attachment-status",
107
116
  children: item.errorMessage ?? labels.toolError
108
117
  }) : null,
109
- onRemove ? /*#__PURE__*/ jsx("button", {
110
- type: "button",
118
+ onRemove ? /*#__PURE__*/ jsx(button_Button, {
119
+ size: "mini",
120
+ type: "text",
121
+ iconOnly: true,
122
+ htmlType: "button",
111
123
  "aria-label": `${labels.removeAttachment}: ${item.name}`,
112
124
  disabled: disabled,
113
125
  onClick: ()=>onRemove(item),
@@ -182,7 +194,7 @@ function ReferencePicker({ config, locale, query: externalQuery, editor, onSelec
182
194
  htmlFor: id,
183
195
  children: [
184
196
  labels.searchReferences,
185
- /*#__PURE__*/ jsx("input", {
197
+ /*#__PURE__*/ jsx(input_Input, {
186
198
  id: id,
187
199
  type: "search",
188
200
  value: search,
@@ -270,10 +282,13 @@ function ReferenceButton({ locale, config, disabled, labels, senderRef }) {
270
282
  trigger: (props)=>/*#__PURE__*/ jsx(Tooltip, {
271
283
  content: labels.reference,
272
284
  disabled: true === props['aria-expanded'],
273
- children: /*#__PURE__*/ jsx("button", {
285
+ children: /*#__PURE__*/ jsx(button_Button, {
274
286
  ...props,
287
+ size: "mini",
288
+ type: "text",
289
+ iconOnly: true,
275
290
  className: "ov-viking-bot__attach",
276
- type: "button",
291
+ htmlType: "button",
277
292
  "aria-label": labels.reference,
278
293
  disabled: disabled,
279
294
  children: "@"
@@ -304,8 +319,11 @@ function ReferenceTags({ config, labels, disabled }) {
304
319
  children: item.name
305
320
  })
306
321
  }),
307
- /*#__PURE__*/ jsx("button", {
308
- type: "button",
322
+ /*#__PURE__*/ jsx(button_Button, {
323
+ size: "mini",
324
+ type: "text",
325
+ iconOnly: true,
326
+ htmlType: "button",
309
327
  disabled: disabled,
310
328
  "aria-label": `${labels.removeReference}: ${item.name}`,
311
329
  onClick: ()=>config.onChange(config.selected.filter((entry)=>entry.uri !== item.uri)),
@@ -1,6 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { AskHuman } from "@ark-design/ui/ask-human";
3
3
  import { useState } from "react";
4
+ import { input_TextArea } from "./c7r~0.js";
4
5
  import { useLocale } from "./28~0.js";
5
6
  import { resolveInteractionLabels } from "./c7~0.js";
6
7
  const toFields = (request, other)=>{
@@ -185,7 +186,7 @@ const TextInput = ({ request, label, disabled, onChange })=>/*#__PURE__*/ jsxs(F
185
186
  request.description ? /*#__PURE__*/ jsx("p", {
186
187
  children: request.description
187
188
  }) : null,
188
- /*#__PURE__*/ jsx("textarea", {
189
+ /*#__PURE__*/ jsx(input_TextArea, {
189
190
  className: "ov-viking-bot__interaction-input",
190
191
  defaultValue: request.initialValue,
191
192
  disabled: disabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openviking/react",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -15,7 +15,8 @@
15
15
  "files": [
16
16
  "dist",
17
17
  "README.md",
18
- "LICENSE.arco-design"
18
+ "LICENSE.arco-design",
19
+ "!dist/docs/**"
19
20
  ],
20
21
  "sideEffects": [
21
22
  "**/*.css"
package/dist/fi~0.js DELETED
@@ -1,354 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { useCallback, useEffect, useId, useRef, useState } from "react";
3
- import { resolveLocale } from "./nx~0.js";
4
- import { checkreact } from "./0~0.js";
5
- import { searchreact } from "./p~0.js";
6
- import { useLocale, LocaleProvider } from "./28~0.js";
7
- const SvgChevronDown = (props)=>/*#__PURE__*/ jsx("svg", {
8
- xmlns: "http://www.w3.org/2000/svg",
9
- width: 14,
10
- height: 14,
11
- fill: "none",
12
- viewBox: "0 0 14 14",
13
- ...props,
14
- children: /*#__PURE__*/ jsx("path", {
15
- fill: "currentColor",
16
- 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"
17
- })
18
- });
19
- const chevron_downreact = SvgChevronDown;
20
- const messages = {
21
- loading: 'Loading…',
22
- searchPlaceholder: 'Search',
23
- empty: 'No options',
24
- noMatch: 'No matches',
25
- error: 'Unable to load options'
26
- };
27
- const en_US = messages;
28
- const zh_CN_messages = {
29
- loading: '加载中…',
30
- searchPlaceholder: '搜索',
31
- empty: '暂无选项',
32
- noMatch: '没有匹配项',
33
- error: '选项加载失败'
34
- };
35
- const zh_CN = zh_CN_messages;
36
- const LOCALES = {
37
- 'en-US': en_US,
38
- 'zh-CN': zh_CN
39
- };
40
- function resolveScopeLabels(locale = 'en-US', labels) {
41
- const defaults = resolveLocale(LOCALES, locale, labels);
42
- return {
43
- ...defaults,
44
- noMatch: labels?.noMatch ?? labels?.empty ?? defaults.noMatch
45
- };
46
- }
47
- function moveScopeFocus(event) {
48
- if (![
49
- 'ArrowDown',
50
- 'ArrowUp',
51
- 'Home',
52
- 'End'
53
- ].includes(event.key)) return;
54
- const target = event.target;
55
- const isSearch = target.matches('input.ov-scope-switcher__search');
56
- if (event.defaultPrevented || !target.matches('[role="option"]') && !isSearch || isSearch && !event.key.startsWith('Arrow')) return;
57
- const options = Array.from(event.currentTarget.querySelectorAll('[role="option"]:not([aria-disabled="true"])'));
58
- if (!options.length) return;
59
- event.preventDefault();
60
- const current = options.indexOf(document.activeElement);
61
- const next = 'Home' === event.key ? 0 : 'End' === event.key ? options.length - 1 : 'ArrowDown' === event.key ? (current + 1) % options.length : current < 0 ? options.length - 1 : (current - 1 + options.length) % options.length;
62
- options[next]?.focus();
63
- }
64
- function Highlight({ text, keyword }) {
65
- const needle = keyword.trim().toLocaleLowerCase();
66
- if (!needle) return /*#__PURE__*/ jsx(Fragment, {
67
- children: text
68
- });
69
- const haystack = text.toLocaleLowerCase();
70
- const parts = [];
71
- let cursor = 0;
72
- let hit = haystack.indexOf(needle);
73
- while(hit >= 0){
74
- if (hit > cursor) parts.push(text.slice(cursor, hit));
75
- const end = hit + needle.length;
76
- parts.push(/*#__PURE__*/ jsx("mark", {
77
- children: text.slice(hit, end)
78
- }, `${hit}-${end}`));
79
- cursor = end;
80
- hit = haystack.indexOf(needle, cursor);
81
- }
82
- if (cursor < text.length) parts.push(text.slice(cursor));
83
- return /*#__PURE__*/ jsx(Fragment, {
84
- children: parts
85
- });
86
- }
87
- function ScopePanel({ label, data, state, slots, actions, onSelect, labels }) {
88
- const focusPanel = useCallback((node)=>{
89
- const target = node?.querySelector('input') ?? node?.querySelector('[role="option"][aria-selected="true"]:not([aria-disabled="true"])') ?? node?.querySelector('[role="option"]:not([aria-disabled="true"])');
90
- (target ?? node)?.focus();
91
- }, []);
92
- const options = data.visibleOptions ?? data.options;
93
- const keyword = state?.searchKeyword ?? '';
94
- const hasKeyword = keyword.trim().length > 0;
95
- const searchVisible = actions?.onSearchKeywordChange && (hasKeyword || Math.max(options.length, data.options.length, data.total ?? 0) > 10);
96
- const search = searchVisible ? /*#__PURE__*/ jsxs("div", {
97
- className: "ov-scope-switcher__search-field",
98
- children: [
99
- /*#__PURE__*/ jsx(searchreact, {
100
- className: "ov-scope-switcher__search-icon"
101
- }),
102
- /*#__PURE__*/ jsx("input", {
103
- type: "search",
104
- className: "ov-scope-switcher__search",
105
- value: keyword,
106
- "aria-label": labels.searchPlaceholder,
107
- placeholder: labels.searchPlaceholder,
108
- onChange: (event)=>actions?.onSearchKeywordChange?.(event.currentTarget.value)
109
- })
110
- ]
111
- }) : null;
112
- let list;
113
- list = state?.loading ? /*#__PURE__*/ jsx("div", {
114
- className: "ov-scope-switcher__state",
115
- role: "status",
116
- children: labels.loading
117
- }) : state?.error ? /*#__PURE__*/ jsx("div", {
118
- className: "ov-scope-switcher__state",
119
- role: "alert",
120
- children: slots?.errorFallback ?? labels.error
121
- }) : options.length ? /*#__PURE__*/ jsx("div", {
122
- className: "ov-scope-switcher__list",
123
- role: "listbox",
124
- "aria-label": label,
125
- "aria-busy": state?.busy,
126
- onScroll: (event)=>{
127
- const { scrollTop, scrollHeight, clientHeight } = event.currentTarget;
128
- actions?.onScroll?.({
129
- scrollTop,
130
- scrollHeight,
131
- clientHeight
132
- });
133
- },
134
- children: options.map((option)=>{
135
- const selected = option.id === data.selectedId;
136
- const content = /*#__PURE__*/ jsxs(Fragment, {
137
- children: [
138
- option.icon && /*#__PURE__*/ jsx("span", {
139
- className: "ov-scope-switcher__icon",
140
- "aria-hidden": "true",
141
- children: option.icon
142
- }),
143
- /*#__PURE__*/ jsxs("span", {
144
- className: "ov-scope-switcher__option-text",
145
- children: [
146
- /*#__PURE__*/ jsx("span", {
147
- children: /*#__PURE__*/ jsx(Highlight, {
148
- text: option.label,
149
- keyword: keyword
150
- })
151
- }),
152
- option.description && /*#__PURE__*/ jsx("small", {
153
- children: option.description
154
- })
155
- ]
156
- }),
157
- selected && /*#__PURE__*/ jsx("span", {
158
- className: "ov-scope-switcher__check",
159
- "aria-hidden": "true",
160
- children: /*#__PURE__*/ jsx(checkreact, {})
161
- })
162
- ]
163
- });
164
- return /*#__PURE__*/ jsx("div", {
165
- tabIndex: option.disabled || state?.busy ? -1 : 0,
166
- role: "option",
167
- "aria-selected": selected,
168
- className: "ov-scope-switcher__option",
169
- title: option.label,
170
- "aria-disabled": option.disabled || state?.busy || void 0,
171
- onClick: (event)=>{
172
- const target = event.target;
173
- if (option.disabled || state?.busy || target.closest('button, a, input, select, textarea, [role="button"]')) return;
174
- onSelect(option);
175
- },
176
- onKeyDown: (event)=>{
177
- if (event.target !== event.currentTarget || option.disabled || state?.busy) return;
178
- if ('Enter' === event.key || ' ' === event.key) {
179
- event.preventDefault();
180
- onSelect(option);
181
- }
182
- },
183
- children: slots?.renderOption ? slots?.renderOption(content, option) : content
184
- }, option.id);
185
- })
186
- }, keyword) : /*#__PURE__*/ jsx("div", {
187
- className: "ov-scope-switcher__state",
188
- role: "status",
189
- children: slots?.emptyFallback ?? (hasKeyword ? labels.noMatch : labels.empty)
190
- });
191
- return /*#__PURE__*/ jsx("div", {
192
- role: "group",
193
- tabIndex: -1,
194
- ref: focusPanel,
195
- className: "ov-scope-switcher__panel-inner",
196
- onKeyDownCapture: moveScopeFocus,
197
- children: slots?.renderPanel ? slots?.renderPanel({
198
- search,
199
- list
200
- }) : /*#__PURE__*/ jsxs("div", {
201
- className: "ov-scope-switcher__panel-body",
202
- children: [
203
- search,
204
- list
205
- ]
206
- })
207
- });
208
- }
209
- function ScopeSelector(props) {
210
- const { identity, trigger: triggerContent } = props;
211
- const locale = useLocale(props.locale);
212
- const labels = resolveScopeLabels(locale, props.labels);
213
- const selectable = 'selectable' === props.kind ? props : void 0;
214
- const data = selectable?.data;
215
- const state = selectable?.state;
216
- const actions = selectable?.actions;
217
- const slots = selectable?.slots;
218
- const [localVisible, setLocalVisible] = useState(false);
219
- const root = useRef(null);
220
- const trigger = useRef(null);
221
- const restoreSelectionFocus = useRef(false);
222
- const panelId = useId();
223
- const open = void 0 !== selectable && (state?.visible ?? localVisible) && !state?.disabled;
224
- const onVisibleChange = actions?.onVisibleChange;
225
- const changeVisible = useCallback((visible)=>{
226
- setLocalVisible(visible);
227
- onVisibleChange?.(visible);
228
- }, [
229
- onVisibleChange
230
- ]);
231
- useEffect(()=>{
232
- if (!open) return;
233
- const dismiss = (event)=>{
234
- if (event.target instanceof Node && !root.current?.contains(event.target)) changeVisible(false);
235
- };
236
- const escape = (event)=>{
237
- if ('Escape' === event.key) {
238
- event.preventDefault();
239
- changeVisible(false);
240
- trigger.current?.focus();
241
- }
242
- };
243
- document.addEventListener('pointerdown', dismiss);
244
- document.addEventListener('keydown', escape);
245
- return ()=>{
246
- document.removeEventListener('pointerdown', dismiss);
247
- document.removeEventListener('keydown', escape);
248
- };
249
- }, [
250
- open,
251
- changeVisible
252
- ]);
253
- useEffect(()=>{
254
- if (open || !restoreSelectionFocus.current) return;
255
- restoreSelectionFocus.current = false;
256
- if (document.activeElement === document.body || root.current?.contains(document.activeElement)) trigger.current?.focus();
257
- }, [
258
- open
259
- ]);
260
- const selected = data?.options.find((o)=>o.id === data.selectedId);
261
- const label = triggerContent?.label ?? selected?.label ?? '';
262
- const icon = triggerContent?.icon ?? selected?.icon;
263
- const content = /*#__PURE__*/ jsxs(Fragment, {
264
- children: [
265
- icon && /*#__PURE__*/ jsx("span", {
266
- className: "ov-scope-switcher__icon",
267
- "aria-hidden": "true",
268
- children: icon
269
- }),
270
- /*#__PURE__*/ jsx("span", {
271
- className: "ov-scope-switcher__label",
272
- children: label
273
- }),
274
- identity.tag && /*#__PURE__*/ jsx("span", {
275
- className: "ov-scope-switcher__tag",
276
- children: identity.tag
277
- })
278
- ]
279
- });
280
- return /*#__PURE__*/ jsxs("div", {
281
- ref: root,
282
- role: "group",
283
- className: "ov-scope-switcher__level",
284
- onBlur: (event)=>{
285
- if (open && event.relatedTarget instanceof Node && !event.currentTarget.contains(event.relatedTarget)) changeVisible(false);
286
- },
287
- children: [
288
- void 0 === selectable ? /*#__PURE__*/ jsx("span", {
289
- className: "ov-scope-switcher__trigger",
290
- "aria-label": identity.ariaLabel,
291
- title: label,
292
- children: content
293
- }) : /*#__PURE__*/ jsxs("button", {
294
- ref: trigger,
295
- type: "button",
296
- className: "ov-scope-switcher__trigger",
297
- "aria-label": identity.ariaLabel,
298
- title: label,
299
- disabled: state?.disabled,
300
- "aria-expanded": open,
301
- "aria-haspopup": "dialog",
302
- "aria-controls": open ? panelId : void 0,
303
- onClick: ()=>changeVisible(!open),
304
- onKeyDown: (event)=>{
305
- if ('ArrowDown' === event.key || 'ArrowUp' === event.key) {
306
- event.preventDefault();
307
- if (open) root.current?.querySelector('[role="option"]:not([aria-disabled="true"])')?.focus();
308
- else changeVisible(true);
309
- }
310
- },
311
- children: [
312
- content,
313
- /*#__PURE__*/ jsx("span", {
314
- className: "ov-scope-switcher__arrow",
315
- "aria-hidden": "true",
316
- children: /*#__PURE__*/ jsx(chevron_downreact, {})
317
- })
318
- ]
319
- }),
320
- open && void 0 !== selectable && void 0 !== data && /*#__PURE__*/ jsx("div", {
321
- id: panelId,
322
- className: slots?.renderPanel ? 'ov-scope-switcher__panel ov-scope-switcher__panel--custom' : 'ov-scope-switcher__panel',
323
- role: "dialog",
324
- "aria-label": identity.ariaLabel ?? label,
325
- children: /*#__PURE__*/ jsx(ScopePanel, {
326
- label: identity.ariaLabel ?? label,
327
- data: data,
328
- state: state,
329
- slots: slots,
330
- actions: actions,
331
- onSelect: (option)=>{
332
- restoreSelectionFocus.current = true;
333
- changeVisible(false);
334
- actions?.onSelect?.(option);
335
- },
336
- labels: labels
337
- })
338
- })
339
- ]
340
- });
341
- }
342
- function ScopeSwitcher({ locale: localeProp, children, className = '', ...props }) {
343
- const locale = useLocale(localeProp);
344
- return /*#__PURE__*/ jsx(LocaleProvider, {
345
- locale: locale,
346
- children: /*#__PURE__*/ jsx("div", {
347
- lang: locale,
348
- ...props,
349
- className: `ov-scope-switcher ${className}`,
350
- children: children
351
- })
352
- });
353
- }
354
- export { ScopeSelector, ScopeSwitcher };
@@ -1,4 +0,0 @@
1
- /** Search results may repeat a URI; preserve the matching row's scoped identifier. */
2
- export declare function selectedRowId(uri: string | null, results: readonly {
3
- uri: string;
4
- }[] | null): string | null;
package/dist/o~0.js DELETED
@@ -1,106 +0,0 @@
1
- import { useEffect, useLayoutEffect, useState } from "react";
2
- const usePositionEffect = "u" < typeof window ? useEffect : useLayoutEffect;
3
- const OVERLAY_OFFSET = 6;
4
- const VIEWPORT_MARGIN = 8;
5
- const OPPOSITE = {
6
- top: 'bottom',
7
- bottom: 'top',
8
- left: 'right',
9
- right: 'left'
10
- };
11
- function resolvePosition(trigger, surface, placement, alignment = 'center') {
12
- const viewportWidth = window.innerWidth;
13
- const viewportHeight = window.innerHeight;
14
- const fits = (side)=>{
15
- if ('top' === side) return trigger.top - surface.height - OVERLAY_OFFSET >= VIEWPORT_MARGIN;
16
- if ('bottom' === side) return trigger.bottom + surface.height + OVERLAY_OFFSET <= viewportHeight - VIEWPORT_MARGIN;
17
- if ('left' === side) return trigger.left - surface.width - OVERLAY_OFFSET >= VIEWPORT_MARGIN;
18
- return trigger.right + surface.width + OVERLAY_OFFSET <= viewportWidth - VIEWPORT_MARGIN;
19
- };
20
- const side = fits(placement) || !fits(OPPOSITE[placement]) ? placement : OPPOSITE[placement];
21
- const clamp = (value, size, limit)=>Math.min(Math.max(value, VIEWPORT_MARGIN), limit - size - VIEWPORT_MARGIN);
22
- if ('top' === side || 'bottom' === side) {
23
- const top = 'top' === side ? trigger.top - surface.height - OVERLAY_OFFSET : trigger.bottom + OVERLAY_OFFSET;
24
- const left = 'end' === alignment ? trigger.right - surface.width : trigger.left + trigger.width / 2 - surface.width / 2;
25
- return {
26
- top: clamp(top, surface.height, viewportHeight),
27
- left: clamp(left, surface.width, viewportWidth),
28
- placement: side
29
- };
30
- }
31
- const left = 'left' === side ? trigger.left - surface.width - OVERLAY_OFFSET : trigger.right + OVERLAY_OFFSET;
32
- const top = trigger.top + trigger.height / 2 - surface.height / 2;
33
- return {
34
- top: clamp(top, surface.height, viewportHeight),
35
- left: clamp(left, surface.width, viewportWidth),
36
- placement: side
37
- };
38
- }
39
- function useOverlayPosition(open, triggerRef, surface, placement, alignment = 'center') {
40
- const [position, setPosition] = useState({
41
- top: 0,
42
- left: 0,
43
- placement
44
- });
45
- usePositionEffect(()=>{
46
- if (!open) return;
47
- const trigger = triggerRef.current;
48
- if (!trigger || !surface) return;
49
- const written = new Set();
50
- const syncTheme = ()=>{
51
- const triggerStyle = window.getComputedStyle(trigger);
52
- const seen = new Set();
53
- for (const name of Array.from(triggerStyle)){
54
- if (!name.startsWith('--ov-ui-color-')) continue;
55
- const value = triggerStyle.getPropertyValue(name).trim();
56
- if (value) {
57
- seen.add(name);
58
- surface.style.setProperty(name, value);
59
- }
60
- }
61
- for (const name of written)if (!seen.has(name)) surface.style.removeProperty(name);
62
- written.clear();
63
- seen.forEach((name)=>written.add(name));
64
- };
65
- syncTheme();
66
- const themeObserver = new MutationObserver(syncTheme);
67
- const observerOptions = {
68
- attributes: true,
69
- attributeFilter: [
70
- 'class',
71
- 'style',
72
- 'data-theme'
73
- ]
74
- };
75
- for(let node = trigger; node; node = node.parentElement)themeObserver.observe(node, observerOptions);
76
- const update = ()=>{
77
- const triggerRect = trigger.getBoundingClientRect();
78
- const surfaceRect = surface.getBoundingClientRect();
79
- const next = resolvePosition(triggerRect, {
80
- width: surfaceRect.width,
81
- height: surfaceRect.height
82
- }, placement, alignment);
83
- setPosition((previous)=>previous.top === next.top && previous.left === next.left && previous.placement === next.placement ? previous : next);
84
- };
85
- update();
86
- const observer = new ResizeObserver(update);
87
- observer.observe(surface);
88
- window.addEventListener('scroll', update, true);
89
- window.addEventListener('resize', update);
90
- return ()=>{
91
- observer.disconnect();
92
- themeObserver.disconnect();
93
- written.forEach((name)=>surface.style.removeProperty(name));
94
- window.removeEventListener('scroll', update, true);
95
- window.removeEventListener('resize', update);
96
- };
97
- }, [
98
- open,
99
- placement,
100
- surface,
101
- triggerRef,
102
- alignment
103
- ]);
104
- return position;
105
- }
106
- export { useOverlayPosition };