@icen.ai/ui 0.8.1 → 0.10.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.
- package/AGENTS.md +176 -75
- package/README.md +66 -88
- package/dist/base.css +208 -179
- package/dist/behaviors/accordion.mjs +8 -8
- package/dist/behaviors/ai-branch.d.mts +19 -0
- package/dist/behaviors/ai-branch.mjs +1133 -0
- package/dist/behaviors/ai-chat.d.mts +12 -10
- package/dist/behaviors/ai-chat.mjs +1125 -155
- package/dist/behaviors/ai-composer.d.mts +44 -12
- package/dist/behaviors/ai-composer.mjs +2084 -523
- package/dist/behaviors/ai-core.d.mts +1 -1
- package/dist/behaviors/ai-core.mjs +1016 -107
- package/dist/behaviors/ai-diff.mjs +1019 -127
- package/dist/behaviors/ai-feedback.d.mts +26 -0
- package/dist/behaviors/ai-feedback.mjs +1212 -0
- package/dist/behaviors/ai-panel.d.mts +21 -7
- package/dist/behaviors/ai-panel.mjs +1308 -264
- package/dist/behaviors/ai-provider.mjs +1003 -101
- package/dist/behaviors/ai-threads.d.mts +38 -0
- package/dist/behaviors/ai-threads.mjs +1233 -0
- package/dist/behaviors/ai-tool.d.mts +2 -2
- package/dist/behaviors/ai-tool.mjs +2042 -396
- package/dist/behaviors/ai-tools.d.mts +89 -16
- package/dist/behaviors/ai-tools.mjs +4453 -372
- package/dist/behaviors/autocomplete.d.mts +53 -0
- package/dist/behaviors/autocomplete.mjs +1600 -0
- package/dist/behaviors/back-top.d.mts +1 -1
- package/dist/behaviors/back-top.mjs +951 -14
- package/dist/behaviors/carousel.d.mts +1 -1
- package/dist/behaviors/carousel.mjs +906 -11
- package/dist/behaviors/cascader.d.mts +48 -0
- package/dist/behaviors/cascader.mjs +1853 -0
- package/dist/behaviors/charts.d.mts +174 -8
- package/dist/behaviors/charts.mjs +2632 -192
- package/dist/behaviors/code-block.d.mts +36 -0
- package/dist/behaviors/code-block.mjs +1611 -0
- package/dist/behaviors/command-palette.d.mts +9 -6
- package/dist/behaviors/command-palette.mjs +161 -59
- package/dist/behaviors/context-menu.d.mts +9 -8
- package/dist/behaviors/context-menu.mjs +1112 -44
- package/dist/behaviors/controls.d.mts +13 -13
- package/dist/behaviors/controls.mjs +989 -130
- package/dist/behaviors/copy.d.mts +21 -2
- package/dist/behaviors/copy.mjs +1206 -42
- package/dist/behaviors/datatable.d.mts +53 -3
- package/dist/behaviors/datatable.mjs +1963 -207
- package/dist/behaviors/date-picker.d.mts +0 -1
- package/dist/behaviors/date-picker.mjs +1340 -293
- package/dist/behaviors/design.d.mts +54 -0
- package/dist/behaviors/design.mjs +109 -0
- package/dist/behaviors/dropdown.d.mts +5 -6
- package/dist/behaviors/dropdown.mjs +262 -110
- package/dist/behaviors/events.d.mts +313 -3
- package/dist/behaviors/events.mjs +47 -2
- package/dist/behaviors/feedback.d.mts +30 -0
- package/dist/behaviors/feedback.mjs +296 -0
- package/dist/behaviors/focus.d.mts +8 -0
- package/dist/behaviors/focus.mjs +24 -0
- package/dist/behaviors/form-validate.d.mts +102 -0
- package/dist/behaviors/form-validate.mjs +6091 -0
- package/dist/behaviors/i18n.d.mts +789 -0
- package/dist/behaviors/i18n.mjs +1711 -0
- package/dist/behaviors/icons.d.mts +93 -0
- package/dist/behaviors/icons.mjs +113 -0
- package/dist/behaviors/input.d.mts +9 -1
- package/dist/behaviors/input.mjs +1056 -60
- package/dist/behaviors/kb-access.d.mts +34 -0
- package/dist/behaviors/kb-access.mjs +2459 -0
- package/dist/behaviors/kb-acl.d.mts +50 -0
- package/dist/behaviors/kb-acl.mjs +1345 -0
- package/dist/behaviors/kb-answer.d.mts +38 -0
- package/dist/behaviors/kb-answer.mjs +3707 -0
- package/dist/behaviors/kb-audit.d.mts +23 -0
- package/dist/behaviors/kb-audit.mjs +1297 -0
- package/dist/behaviors/kb-canvas.d.mts +44 -0
- package/dist/behaviors/kb-canvas.mjs +1512 -0
- package/dist/behaviors/kb-chain.d.mts +15 -0
- package/dist/behaviors/kb-chain.mjs +1192 -0
- package/dist/behaviors/kb-checkpoint.d.mts +16 -0
- package/dist/behaviors/kb-checkpoint.mjs +1492 -0
- package/dist/behaviors/kb-chunks.d.mts +31 -0
- package/dist/behaviors/kb-chunks.mjs +1414 -0
- package/dist/behaviors/kb-citation.d.mts +38 -0
- package/dist/behaviors/kb-citation.mjs +1699 -0
- package/dist/behaviors/kb-clarify.d.mts +20 -0
- package/dist/behaviors/kb-clarify.mjs +1176 -0
- package/dist/behaviors/kb-conflict.d.mts +22 -0
- package/dist/behaviors/kb-conflict.mjs +1206 -0
- package/dist/behaviors/kb-connector.d.mts +17 -0
- package/dist/behaviors/kb-connector.mjs +1303 -0
- package/dist/behaviors/kb-core.d.mts +534 -0
- package/dist/behaviors/kb-core.mjs +1805 -0
- package/dist/behaviors/kb-eval.d.mts +22 -0
- package/dist/behaviors/kb-eval.mjs +2235 -0
- package/dist/behaviors/kb-explain.d.mts +11 -0
- package/dist/behaviors/kb-explain.mjs +1165 -0
- package/dist/behaviors/kb-filter.d.mts +31 -0
- package/dist/behaviors/kb-filter.mjs +2417 -0
- package/dist/behaviors/kb-gap.d.mts +27 -0
- package/dist/behaviors/kb-gap.mjs +1195 -0
- package/dist/behaviors/kb-hittest.d.mts +34 -0
- package/dist/behaviors/kb-hittest.mjs +1352 -0
- package/dist/behaviors/kb-metadata.d.mts +29 -0
- package/dist/behaviors/kb-metadata.mjs +1248 -0
- package/dist/behaviors/kb-passage.d.mts +41 -0
- package/dist/behaviors/kb-passage.mjs +1469 -0
- package/dist/behaviors/kb-pipeline.d.mts +18 -0
- package/dist/behaviors/kb-pipeline.mjs +1301 -0
- package/dist/behaviors/kb-qa.d.mts +26 -0
- package/dist/behaviors/kb-qa.mjs +1260 -0
- package/dist/behaviors/kb-rerank.d.mts +20 -0
- package/dist/behaviors/kb-rerank.mjs +1248 -0
- package/dist/behaviors/kb-retrieval.d.mts +49 -0
- package/dist/behaviors/kb-retrieval.mjs +2585 -0
- package/dist/behaviors/kb-review.d.mts +44 -0
- package/dist/behaviors/kb-review.mjs +2282 -0
- package/dist/behaviors/kb-sandbox.d.mts +33 -0
- package/dist/behaviors/kb-sandbox.mjs +1247 -0
- package/dist/behaviors/kb-segment.d.mts +32 -0
- package/dist/behaviors/kb-segment.mjs +1431 -0
- package/dist/behaviors/kb-select.d.mts +24 -0
- package/dist/behaviors/kb-select.mjs +1989 -0
- package/dist/behaviors/kb-sources.d.mts +27 -0
- package/dist/behaviors/kb-sources.mjs +1287 -0
- package/dist/behaviors/kb-sql.d.mts +43 -0
- package/dist/behaviors/kb-sql.mjs +1865 -0
- package/dist/behaviors/kb-trace.d.mts +16 -0
- package/dist/behaviors/kb-trace.mjs +1328 -0
- package/dist/behaviors/kb-visibility.d.mts +44 -0
- package/dist/behaviors/kb-visibility.mjs +1331 -0
- package/dist/behaviors/kb-who-can.d.mts +32 -0
- package/dist/behaviors/kb-who-can.mjs +2216 -0
- package/dist/behaviors/mentions.d.mts +93 -0
- package/dist/behaviors/mentions.mjs +2152 -0
- package/dist/behaviors/modal.d.mts +4 -3
- package/dist/behaviors/modal.mjs +1055 -33
- package/dist/behaviors/nav.d.mts +1 -1
- package/dist/behaviors/nav.mjs +6 -6
- package/dist/behaviors/notification.d.mts +16 -8
- package/dist/behaviors/notification.mjs +1615 -265
- package/dist/behaviors/panel.d.mts +4 -0
- package/dist/behaviors/panel.mjs +994 -0
- package/dist/behaviors/popover.d.mts +28 -5
- package/dist/behaviors/popover.mjs +225 -24
- package/dist/behaviors/select.d.mts +5 -2
- package/dist/behaviors/select.mjs +1410 -117
- package/dist/behaviors/sidebar.d.mts +1 -1
- package/dist/behaviors/sidebar.mjs +13 -13
- package/dist/behaviors/slider.d.mts +1 -1
- package/dist/behaviors/slider.mjs +9 -9
- package/dist/behaviors/split-pane.d.mts +1 -1
- package/dist/behaviors/split-pane.mjs +7 -7
- package/dist/behaviors/suggestions.d.mts +27 -0
- package/dist/behaviors/suggestions.mjs +1089 -0
- package/dist/behaviors/svg-parse.d.mts +14 -0
- package/dist/behaviors/svg-parse.mjs +37 -0
- package/dist/behaviors/tabs.d.mts +2 -2
- package/dist/behaviors/tabs.mjs +25 -25
- package/dist/behaviors/tag-input.d.mts +23 -5
- package/dist/behaviors/tag-input.mjs +1359 -104
- package/dist/behaviors/theme-switcher.d.mts +24 -0
- package/dist/behaviors/theme-switcher.mjs +1981 -0
- package/dist/behaviors/theme.d.mts +15 -8
- package/dist/behaviors/theme.mjs +390 -28
- package/dist/behaviors/toast.d.mts +24 -25
- package/dist/behaviors/toast.mjs +1266 -88
- package/dist/behaviors/tooltip.d.mts +4 -0
- package/dist/behaviors/tooltip.mjs +378 -0
- package/dist/behaviors/tree-select.d.mts +69 -0
- package/dist/behaviors/tree-select.mjs +1907 -0
- package/dist/behaviors/tree.d.mts +1 -1
- package/dist/behaviors/tree.mjs +15 -15
- package/dist/behaviors/upload.d.mts +3 -2
- package/dist/behaviors/upload.mjs +1076 -66
- package/dist/cli.mjs +5 -6
- package/dist/components/ai-branch.mjs +3 -0
- package/dist/components/ai-chat.css +846 -458
- package/dist/components/ai-diff.css +153 -132
- package/dist/components/ai-feedback.mjs +3 -0
- package/dist/components/ai-panel.css +495 -270
- package/dist/components/ai-threads.mjs +3 -0
- package/dist/components/ai-tool.css +393 -238
- package/dist/components/autocomplete.css +61 -0
- package/dist/components/autocomplete.mjs +3 -0
- package/dist/components/back-top.css +34 -31
- package/dist/components/badge.css +44 -41
- package/dist/components/breadcrumb.css +67 -46
- package/dist/components/btn.css +80 -74
- package/dist/components/card.css +117 -106
- package/dist/components/cascader.css +311 -0
- package/dist/components/cascader.mjs +3 -0
- package/dist/components/chart-area.css +8 -2
- package/dist/components/chart-bar.css +95 -33
- package/dist/components/chart-gauge.css +14 -11
- package/dist/components/chart-graph.css +60 -0
- package/dist/components/chart-graph.mjs +4 -0
- package/dist/components/chart-heatmap.css +96 -90
- package/dist/components/chart-line.css +8 -3
- package/dist/components/chart-map.mjs +3 -0
- package/dist/components/chart-pie.css +9 -6
- package/dist/components/chart-radar.css +8 -5
- package/dist/components/chart-scatter.css +9 -6
- package/dist/components/chart-scatter.mjs +1 -1
- package/dist/components/chart-sparkline.css +5 -2
- package/dist/components/chart-stack.css +14 -11
- package/dist/components/charts.css +190 -67
- package/dist/components/charts.mjs +1 -0
- package/dist/components/code-block.css +418 -0
- package/dist/components/code-block.mjs +4 -0
- package/dist/components/command-palette.css +138 -117
- package/dist/components/content.css +257 -251
- package/dist/components/copy.css +72 -44
- package/dist/components/datatable.css +423 -181
- package/dist/components/date-picker.css +135 -104
- package/dist/components/empty.css +68 -65
- package/dist/components/feedback.css +201 -183
- package/dist/components/form-validate.css +120 -0
- package/dist/components/form-validate.mjs +3 -0
- package/dist/components/form.css +150 -127
- package/dist/components/icon.css +102 -0
- package/dist/components/icon.mjs +3 -0
- package/dist/components/input.css +159 -104
- package/dist/components/kb-access.mjs +4 -0
- package/dist/components/kb-acl.mjs +4 -0
- package/dist/components/kb-agent.css +496 -0
- package/dist/components/kb-answer.mjs +4 -0
- package/dist/components/kb-audit.mjs +4 -0
- package/dist/components/kb-canvas.mjs +4 -0
- package/dist/components/kb-chain.mjs +4 -0
- package/dist/components/kb-checkpoint.mjs +4 -0
- package/dist/components/kb-chunks.mjs +4 -0
- package/dist/components/kb-citation.mjs +4 -0
- package/dist/components/kb-clarify.mjs +4 -0
- package/dist/components/kb-conflict.mjs +4 -0
- package/dist/components/kb-connector.mjs +4 -0
- package/dist/components/kb-data.css +653 -0
- package/dist/components/kb-eval.mjs +4 -0
- package/dist/components/kb-explain.mjs +4 -0
- package/dist/components/kb-filter.mjs +4 -0
- package/dist/components/kb-gap.mjs +4 -0
- package/dist/components/kb-ground.css +578 -0
- package/dist/components/kb-hittest.mjs +4 -0
- package/dist/components/kb-ingest.css +882 -0
- package/dist/components/kb-metadata.mjs +4 -0
- package/dist/components/kb-ops.css +554 -0
- package/dist/components/kb-passage.mjs +4 -0
- package/dist/components/kb-perm.css +433 -0
- package/dist/components/kb-pipeline.mjs +4 -0
- package/dist/components/kb-qa.mjs +4 -0
- package/dist/components/kb-rerank.mjs +4 -0
- package/dist/components/kb-retrieval.mjs +4 -0
- package/dist/components/kb-review.mjs +4 -0
- package/dist/components/kb-sandbox.mjs +4 -0
- package/dist/components/kb-search.css +897 -0
- package/dist/components/kb-segment.mjs +4 -0
- package/dist/components/kb-sources.mjs +4 -0
- package/dist/components/kb-sql.mjs +4 -0
- package/dist/components/kb-trace.mjs +4 -0
- package/dist/components/kb-visibility.mjs +4 -0
- package/dist/components/kb-who-can.mjs +4 -0
- package/dist/components/kb.css +263 -0
- package/dist/components/kb.mjs +9 -0
- package/dist/components/layout.css +85 -82
- package/dist/components/material-chinese.css +73 -0
- package/dist/components/material-soviet.css +76 -0
- package/dist/components/material.css +275 -0
- package/dist/components/media.css +220 -166
- package/dist/components/mentions.css +189 -0
- package/dist/components/mentions.mjs +3 -0
- package/dist/components/menu.css +113 -105
- package/dist/components/modal.css +107 -112
- package/dist/components/nav.css +118 -115
- package/dist/components/notification.css +238 -174
- package/dist/components/pagination.css +56 -53
- package/dist/components/panel.css +66 -63
- package/dist/components/panel.mjs +1 -0
- package/dist/components/pill.css +81 -71
- package/dist/components/popover.css +67 -53
- package/dist/components/scroll-area.css +113 -110
- package/dist/components/segmented.css +146 -143
- package/dist/components/select.css +206 -186
- package/dist/components/sidebar.css +137 -127
- package/dist/components/slider.css +117 -114
- package/dist/components/split-pane.css +112 -109
- package/dist/components/stat.css +112 -106
- package/dist/components/steps.css +109 -103
- package/dist/components/switch.css +138 -134
- package/dist/components/table.css +131 -107
- package/dist/components/tabs.css +114 -108
- package/dist/components/tag-input.css +48 -133
- package/dist/components/tag.css +81 -71
- package/dist/components/theme-switcher.css +105 -0
- package/dist/components/theme-switcher.mjs +3 -0
- package/dist/components/toast.css +100 -86
- package/dist/components/toolbar.css +45 -42
- package/dist/components/tooltip.css +102 -43
- package/dist/components/tooltip.mjs +1 -0
- package/dist/components/tree-select.css +416 -0
- package/dist/components/tree-select.mjs +3 -0
- package/dist/components/upload.css +135 -92
- package/dist/fonts/LICENSES/ark-pixel/OFL.txt +96 -0
- package/dist/fonts/LICENSES/cubic-11/OFL.txt +108 -0
- package/dist/fonts/LICENSES/galmuri/LICENSE.txt +93 -0
- package/dist/fonts/OFL.txt +96 -0
- package/dist/fonts/README.md +14 -0
- package/dist/fonts/fusion-pixel-12px-zh-hans.woff2 +0 -0
- package/dist/index.d.mts +64 -15
- package/dist/index.mjs +28049 -8595
- package/dist/react.d.mts +91 -0
- package/dist/react.mjs +8208 -0
- package/dist/registry.json +454 -15
- package/dist/tokens/chinese.css +44 -0
- package/dist/tokens/colors.css +365 -1222
- package/dist/tokens/design.css +109 -0
- package/dist/tokens/dtcg.json +11198 -0
- package/dist/tokens/figma.variables.json +7017 -0
- package/dist/tokens/icon-masks.css +78 -0
- package/dist/tokens/pixel.css +50 -0
- package/dist/tokens/soviet.css +44 -0
- package/dist/tokens/style-profiles.css +36 -547
- package/dist/tokens/themes.json +308 -0
- package/dist/tokens/tokens-studio.json +6728 -0
- package/dist/tokens/typography.css +21 -18
- package/dist/tokens.css +1555 -1801
- package/dist/ui.css +16147 -8597
- package/dist/vue.d.mts +344 -0
- package/dist/vue.mjs +7781 -0
- package/docs/spec/ai-input-experience.md +75 -0
- package/docs/spec/ai-native.md +238 -147
- package/docs/spec/design-philosophy.md +189 -0
- package/docs/spec/design-primitives.md +196 -0
- package/docs/spec/kb-family.md +475 -0
- package/package.json +42 -7
- package/dist/retro-effects.css +0 -255
- package/dist/tokens/retro-effects.css +0 -255
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/** 编程命令条目(openCommandPalette 的 opts.items 元素类型)。 */
|
|
2
2
|
interface CommandPaletteCommand {
|
|
3
|
-
/** 条目名(.command-palette-item-label,textContent 渲染) */
|
|
3
|
+
/** 条目名(.icen-command-palette-item-label,textContent 渲染) */
|
|
4
4
|
label: string;
|
|
5
|
-
/** 副标题(.command-palette-item-hint) */
|
|
5
|
+
/** 副标题(.icen-command-palette-item-hint) */
|
|
6
6
|
hint?: string;
|
|
7
|
-
/** 额外搜索关键字(data-command-palette-keyword) */
|
|
7
|
+
/** 额外搜索关键字(data-icen-command-palette-keyword) */
|
|
8
8
|
keyword?: string;
|
|
9
9
|
/** 选中回调:先派 icen:menu-select,再执行本回调 */
|
|
10
10
|
onSelect?: () => void;
|
|
11
|
-
/** 选中后保持面板打开(data-command-palette-keep-open) */
|
|
11
|
+
/** 选中后保持面板打开(data-icen-command-palette-keep-open) */
|
|
12
12
|
keepOpen?: boolean;
|
|
13
13
|
/** 附加到条目元素的自定义属性(如 data-*) */
|
|
14
14
|
attrs?: Record<string, string>;
|
|
15
15
|
}
|
|
16
16
|
interface CommandPaletteOpenOptions {
|
|
17
|
-
/** 编程条目:传入时重建面板条目 DOM(替换面板内全部 .command-palette-group) */
|
|
17
|
+
/** 编程条目:传入时重建面板条目 DOM(替换面板内全部 .icen-command-palette-group) */
|
|
18
18
|
items?: CommandPaletteCommand[];
|
|
19
19
|
/** 覆盖默认 includes 过滤(query 为原始输入;空 query 仍视为匹配全部)。只作用于编程条目 */
|
|
20
20
|
filter?: (query: string, item: CommandPaletteCommand) => boolean;
|
|
@@ -29,8 +29,11 @@ declare function openCommandPalette(id: string, opts?: CommandPaletteOpenOptions
|
|
|
29
29
|
* 关闭指定 id 的命令面板(backdrop 已被外部移除时也照常复位状态/监听/滚动锁)。
|
|
30
30
|
* 关闭已打开的面板后从 document 广播 icen:command-palette-close;
|
|
31
31
|
* 关闭未被接管打开的面板(幂等空操作路径)不派发。
|
|
32
|
+
* 默认带一段可中断的淡出(hidden 延迟到落定);opts.immediate 供销毁/换页路径跳过。
|
|
32
33
|
*/
|
|
33
|
-
declare function closeCommandPalette(id: string
|
|
34
|
+
declare function closeCommandPalette(id: string, opts?: {
|
|
35
|
+
immediate?: boolean;
|
|
36
|
+
}): void;
|
|
34
37
|
/**
|
|
35
38
|
* 初始化:委托监听触发器 / 搜索 / 外点 / 全局快捷键。
|
|
36
39
|
* 返回销毁函数:摘除全部委托监听并复位幂等标记(销毁后可重新 init);
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
// src/behaviors/popover.ts
|
|
2
|
+
function revealPopoverItem(item, scrollport, opts = {}) {
|
|
3
|
+
if (typeof document === "undefined") return;
|
|
4
|
+
if (opts.focus) item.focus({ preventScroll: true });
|
|
5
|
+
const rect = item.getBoundingClientRect(), bounds = scrollport.getBoundingClientRect();
|
|
6
|
+
const style = getComputedStyle(scrollport);
|
|
7
|
+
const inset = (value, extent) => {
|
|
8
|
+
const amount = Number.parseFloat(value) || 0;
|
|
9
|
+
return value.endsWith("%") ? amount * extent / 100 : amount;
|
|
10
|
+
};
|
|
11
|
+
if (opts.axis !== "inline") {
|
|
12
|
+
const top = bounds.top + scrollport.clientTop + inset(style.scrollPaddingTop, scrollport.clientHeight);
|
|
13
|
+
const bottom = bounds.top + scrollport.clientTop + scrollport.clientHeight - inset(style.scrollPaddingBottom, scrollport.clientHeight);
|
|
14
|
+
if (rect.top < top) scrollport.scrollTop -= top - rect.top;
|
|
15
|
+
else if (rect.bottom > bottom) scrollport.scrollTop += rect.bottom - bottom;
|
|
16
|
+
}
|
|
17
|
+
if (opts.axis === "inline" || opts.axis === "both") {
|
|
18
|
+
const left = bounds.left + scrollport.clientLeft + inset(style.scrollPaddingLeft, scrollport.clientWidth);
|
|
19
|
+
const right = bounds.left + scrollport.clientLeft + scrollport.clientWidth - inset(style.scrollPaddingRight, scrollport.clientWidth);
|
|
20
|
+
if (rect.left < left) scrollport.scrollLeft -= left - rect.left;
|
|
21
|
+
else if (rect.right > right) scrollport.scrollLeft += rect.right - right;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
2
24
|
var PANEL_SIZING_ATTRS = {
|
|
3
|
-
width: "data-panel-width",
|
|
4
|
-
minWidth: "data-panel-min",
|
|
5
|
-
maxWidth: "data-panel-max",
|
|
6
|
-
minHeight: "data-panel-min-height",
|
|
7
|
-
maxHeight: "data-panel-max-height"
|
|
25
|
+
width: "data-icen-panel-width",
|
|
26
|
+
minWidth: "data-icen-panel-min",
|
|
27
|
+
maxWidth: "data-icen-panel-max",
|
|
28
|
+
minHeight: "data-icen-panel-min-height",
|
|
29
|
+
maxHeight: "data-icen-panel-max-height"
|
|
8
30
|
};
|
|
9
31
|
function readPanelSizing(el) {
|
|
10
32
|
const out = {};
|
|
@@ -51,14 +73,31 @@ function emitMenuSelect(source, item) {
|
|
|
51
73
|
emitIcen(item, "icen:menu-select", {
|
|
52
74
|
source,
|
|
53
75
|
item,
|
|
54
|
-
value: item.dataset.
|
|
76
|
+
value: item.dataset.icenValue ?? "",
|
|
55
77
|
/* 优先专用 label 子元素(避开快捷键/图标文本混入),无则退整项文本 */
|
|
56
|
-
label: (item.querySelector(".menu-item-label, .command-item-label")?.textContent ?? item.textContent ?? "").trim().slice(0, 80)
|
|
78
|
+
label: (item.querySelector(".icen-menu-item-label, .command-item-label")?.textContent ?? item.textContent ?? "").trim().slice(0, 80)
|
|
57
79
|
});
|
|
58
80
|
}
|
|
59
81
|
|
|
60
|
-
// src/behaviors/
|
|
61
|
-
var FOCUSABLE = 'button
|
|
82
|
+
// src/behaviors/focus.ts
|
|
83
|
+
var FOCUSABLE = 'button, [href], input:not([type="hidden"]), select, textarea, icen-input, icen-select, icen-textarea, [tabindex], [contenteditable]:not([contenteditable="false"]), audio[controls], video[controls], details>summary';
|
|
84
|
+
function isAvailableForFocus(el) {
|
|
85
|
+
if (typeof document === "undefined" || !el.isConnected || el.matches(':disabled,[disabled],[aria-disabled="true"]')) return false;
|
|
86
|
+
if (el.closest('[hidden],[inert],[aria-hidden="true"]')) return false;
|
|
87
|
+
const closed = el.closest("details:not([open])");
|
|
88
|
+
if (closed && !closed.querySelector(":scope > summary")?.contains(el)) return false;
|
|
89
|
+
if (["hidden", "collapse"].includes(getComputedStyle(el).visibility)) return false;
|
|
90
|
+
for (let ancestor = el; ancestor; ancestor = ancestor.parentElement) {
|
|
91
|
+
if (getComputedStyle(ancestor).display === "none") return false;
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
function focusableWithin(root) {
|
|
96
|
+
if (typeof document === "undefined") return [];
|
|
97
|
+
return Array.from(root.querySelectorAll(FOCUSABLE)).filter((el) => {
|
|
98
|
+
return !(el.hasAttribute("tabindex") && el.tabIndex < 0) && isAvailableForFocus(el);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
62
101
|
|
|
63
102
|
// src/behaviors/command-palette.ts
|
|
64
103
|
var openId = null;
|
|
@@ -67,54 +106,56 @@ var prevBodyOverflow = "";
|
|
|
67
106
|
var keyHandler = null;
|
|
68
107
|
var globalKeyHandler = null;
|
|
69
108
|
var teardown = null;
|
|
109
|
+
var closingState = null;
|
|
110
|
+
var CP_EXIT_FALLBACK_MS = 240;
|
|
70
111
|
var programmaticCommands = /* @__PURE__ */ new WeakMap();
|
|
71
112
|
var customFilter = null;
|
|
72
113
|
function buildCommandItems(panel, commands) {
|
|
73
|
-
const body = panel.querySelector(".command-palette-body");
|
|
114
|
+
const body = panel.querySelector(".icen-command-palette-body");
|
|
74
115
|
if (!body) return;
|
|
75
|
-
body.querySelectorAll(".command-palette-group").forEach((g) => g.remove());
|
|
116
|
+
body.querySelectorAll(".icen-command-palette-group").forEach((g) => g.remove());
|
|
76
117
|
const group = document.createElement("div");
|
|
77
|
-
group.className = "command-palette-group";
|
|
118
|
+
group.className = "icen-command-palette-group";
|
|
78
119
|
for (const cmd of commands) group.appendChild(buildCommandItem(cmd));
|
|
79
|
-
const empty = body.querySelector(".command-palette-empty");
|
|
120
|
+
const empty = body.querySelector(".icen-command-palette-empty");
|
|
80
121
|
if (empty) body.insertBefore(group, empty);
|
|
81
122
|
else body.appendChild(group);
|
|
82
123
|
}
|
|
83
124
|
function buildCommandItem(cmd) {
|
|
84
125
|
const btn = document.createElement("button");
|
|
85
126
|
btn.type = "button";
|
|
86
|
-
btn.className = "command-palette-item";
|
|
127
|
+
btn.className = "icen-command-palette-item";
|
|
87
128
|
const label = document.createElement("span");
|
|
88
|
-
label.className = "command-palette-item-label";
|
|
129
|
+
label.className = "icen-command-palette-item-label";
|
|
89
130
|
label.textContent = cmd.label;
|
|
90
131
|
btn.appendChild(label);
|
|
91
132
|
if (cmd.hint) {
|
|
92
133
|
const hint = document.createElement("span");
|
|
93
|
-
hint.className = "command-palette-item-hint";
|
|
134
|
+
hint.className = "icen-command-palette-item-hint";
|
|
94
135
|
hint.textContent = cmd.hint;
|
|
95
136
|
btn.appendChild(hint);
|
|
96
137
|
}
|
|
97
|
-
if (cmd.keyword) btn.setAttribute("data-command-palette-keyword", cmd.keyword);
|
|
98
|
-
if (cmd.keepOpen) btn.setAttribute("data-command-palette-keep-open", "");
|
|
138
|
+
if (cmd.keyword) btn.setAttribute("data-icen-command-palette-keyword", cmd.keyword);
|
|
139
|
+
if (cmd.keepOpen) btn.setAttribute("data-icen-command-palette-keep-open", "");
|
|
99
140
|
if (cmd.attrs) {
|
|
100
141
|
for (const [name, value] of Object.entries(cmd.attrs)) btn.setAttribute(name, value);
|
|
101
142
|
}
|
|
102
143
|
programmaticCommands.set(btn, cmd);
|
|
103
144
|
btn.addEventListener("click", () => {
|
|
104
|
-
emitMenuSelect(btn.closest(".command-palette") ?? btn, btn);
|
|
145
|
+
emitMenuSelect(btn.closest(".icen-command-palette") ?? btn, btn);
|
|
105
146
|
cmd.onSelect?.();
|
|
106
147
|
});
|
|
107
148
|
return btn;
|
|
108
149
|
}
|
|
109
150
|
function findBackdrop(id) {
|
|
110
151
|
return document.querySelector(
|
|
111
|
-
`.command-palette-backdrop[data-command-palette="${CSS.escape(id)}"]`
|
|
152
|
+
`.icen-command-palette-backdrop[data-icen-command-palette="${CSS.escape(id)}"]`
|
|
112
153
|
);
|
|
113
154
|
}
|
|
114
155
|
function getVisibleItems(panel) {
|
|
115
156
|
return Array.from(
|
|
116
157
|
panel.querySelectorAll(
|
|
117
|
-
'.command-palette-item:not([hidden]):not([disabled]):not([aria-disabled="true"])'
|
|
158
|
+
'.icen-command-palette-item:not([hidden]):not([disabled]):not([aria-disabled="true"])'
|
|
118
159
|
)
|
|
119
160
|
).filter((el) => el.offsetParent !== null || el.getClientRects().length > 0);
|
|
120
161
|
}
|
|
@@ -123,38 +164,62 @@ function isDisabledItem(el) {
|
|
|
123
164
|
}
|
|
124
165
|
function setActive(panel, idx) {
|
|
125
166
|
const items = getVisibleItems(panel);
|
|
126
|
-
items.forEach((el, i) =>
|
|
167
|
+
items.forEach((el, i) => {
|
|
168
|
+
el.classList.toggle("is-active", i === idx);
|
|
169
|
+
el.setAttribute("aria-selected", String(i === idx));
|
|
170
|
+
});
|
|
127
171
|
const active = items[idx];
|
|
128
|
-
|
|
129
|
-
|
|
172
|
+
const input = panel.querySelector(".icen-command-palette-input");
|
|
173
|
+
if (input) {
|
|
174
|
+
if (active?.id) input.setAttribute("aria-activedescendant", active.id);
|
|
175
|
+
else input.removeAttribute("aria-activedescendant");
|
|
176
|
+
}
|
|
177
|
+
if (active) revealPopoverItem(active, panel.querySelector(".icen-command-palette-body") ?? panel);
|
|
178
|
+
}
|
|
179
|
+
var itemSequence = 0;
|
|
180
|
+
function paintComboboxSemantics(panel) {
|
|
181
|
+
const input = panel.querySelector(".icen-command-palette-input");
|
|
182
|
+
const body = panel.querySelector(".icen-command-palette-body");
|
|
183
|
+
if (body) {
|
|
184
|
+
if (!body.id) body.id = `icen-cp-body-${++itemSequence}`;
|
|
185
|
+
body.setAttribute("role", "listbox");
|
|
186
|
+
}
|
|
187
|
+
if (input) {
|
|
188
|
+
input.setAttribute("role", "combobox");
|
|
189
|
+
input.setAttribute("aria-expanded", "true");
|
|
190
|
+
if (body?.id) input.setAttribute("aria-controls", body.id);
|
|
130
191
|
}
|
|
192
|
+
panel.querySelectorAll(".icen-command-palette-item").forEach((item) => {
|
|
193
|
+
item.setAttribute("role", "option");
|
|
194
|
+
if (!item.id) item.id = `icen-cp-item-${++itemSequence}`;
|
|
195
|
+
});
|
|
131
196
|
}
|
|
132
197
|
function filterPanel(panel, query) {
|
|
133
198
|
const q = query.trim().toLowerCase();
|
|
134
199
|
let visibleCount = 0;
|
|
135
|
-
panel.querySelectorAll(".command-palette-item").forEach((item) => {
|
|
200
|
+
panel.querySelectorAll(".icen-command-palette-item").forEach((item) => {
|
|
136
201
|
if (isDisabledItem(item)) return;
|
|
137
202
|
const def = programmaticCommands.get(item);
|
|
138
203
|
let match;
|
|
139
204
|
if (def && customFilter) {
|
|
140
205
|
match = !q || customFilter(query, def);
|
|
141
206
|
} else {
|
|
142
|
-
const label = (item.querySelector(".command-palette-item-label")?.textContent ?? "").toLowerCase();
|
|
143
|
-
const hint = (item.querySelector(".command-palette-item-hint")?.textContent ?? "").toLowerCase();
|
|
144
|
-
const keyword = (item.dataset.
|
|
207
|
+
const label = (item.querySelector(".icen-command-palette-item-label")?.textContent ?? "").toLowerCase();
|
|
208
|
+
const hint = (item.querySelector(".icen-command-palette-item-hint")?.textContent ?? "").toLowerCase();
|
|
209
|
+
const keyword = (item.dataset.icenCommandPaletteKeyword ?? "").toLowerCase();
|
|
145
210
|
match = !q || label.includes(q) || hint.includes(q) || keyword.includes(q);
|
|
146
211
|
}
|
|
147
212
|
item.hidden = !match;
|
|
148
213
|
item.classList.remove("is-active");
|
|
149
214
|
if (match) visibleCount++;
|
|
150
215
|
});
|
|
151
|
-
panel.querySelectorAll(".command-palette-group").forEach((group) => {
|
|
152
|
-
const hasVisible = Array.from(group.querySelectorAll(".command-palette-item")).some(
|
|
216
|
+
panel.querySelectorAll(".icen-command-palette-group").forEach((group) => {
|
|
217
|
+
const hasVisible = Array.from(group.querySelectorAll(".icen-command-palette-item")).some(
|
|
153
218
|
(it) => !it.hidden
|
|
154
219
|
);
|
|
155
220
|
group.hidden = !hasVisible;
|
|
156
221
|
});
|
|
157
|
-
const empty = panel.querySelector(".command-palette-empty");
|
|
222
|
+
const empty = panel.querySelector(".icen-command-palette-empty");
|
|
158
223
|
if (empty) empty.hidden = visibleCount !== 0;
|
|
159
224
|
if (visibleCount > 0) setActive(panel, 0);
|
|
160
225
|
}
|
|
@@ -164,10 +229,10 @@ function openCommandPalette(id, opts) {
|
|
|
164
229
|
if (openId) closeCommandPalette(openId);
|
|
165
230
|
const backdrop = findBackdrop(id);
|
|
166
231
|
if (!backdrop) {
|
|
167
|
-
console.warn(`[@icen.ai/ui] command-palette: \u672A\u627E\u5230 data-command-palette="${id}" \u7684 .command-palette-backdrop\uFF0C\u5DF2\u8DF3\u8FC7\u6253\u5F00`);
|
|
232
|
+
console.warn(`[@icen.ai/ui] command-palette: \u672A\u627E\u5230 data-icen-command-palette="${id}" \u7684 .command-palette-backdrop\uFF0C\u5DF2\u8DF3\u8FC7\u6253\u5F00`);
|
|
168
233
|
return;
|
|
169
234
|
}
|
|
170
|
-
const panel = backdrop.querySelector(".command-palette");
|
|
235
|
+
const panel = backdrop.querySelector(".icen-command-palette");
|
|
171
236
|
if (!panel) return;
|
|
172
237
|
applyPanelSizing(panel, readPanelSizing(backdrop));
|
|
173
238
|
customFilter = opts?.filter ?? null;
|
|
@@ -175,10 +240,17 @@ function openCommandPalette(id, opts) {
|
|
|
175
240
|
if (backdrop.parentElement !== document.body) document.body.appendChild(backdrop);
|
|
176
241
|
restoreFocusTo = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
177
242
|
openId = id;
|
|
243
|
+
if (closingState) {
|
|
244
|
+
window.clearTimeout(closingState.timer);
|
|
245
|
+
closingState.backdrop.removeEventListener("transitionend", closingState.onEnd);
|
|
246
|
+
delete closingState.backdrop.dataset.icenState;
|
|
247
|
+
closingState = null;
|
|
248
|
+
}
|
|
178
249
|
backdrop.hidden = false;
|
|
250
|
+
paintComboboxSemantics(panel);
|
|
179
251
|
prevBodyOverflow = document.body.style.overflow;
|
|
180
252
|
document.body.style.overflow = "hidden";
|
|
181
|
-
const input = panel.querySelector(".command-palette-input");
|
|
253
|
+
const input = panel.querySelector(".icen-command-palette-input");
|
|
182
254
|
if (input) {
|
|
183
255
|
input.value = "";
|
|
184
256
|
input.focus();
|
|
@@ -187,8 +259,10 @@ function openCommandPalette(id, opts) {
|
|
|
187
259
|
}
|
|
188
260
|
filterPanel(panel, "");
|
|
189
261
|
keyHandler = (e) => {
|
|
262
|
+
if (e.defaultPrevented || e.isComposing || e.keyCode === 229) return;
|
|
190
263
|
if (e.key === "Escape") {
|
|
191
264
|
e.preventDefault();
|
|
265
|
+
e.stopPropagation();
|
|
192
266
|
closeCommandPalette(id);
|
|
193
267
|
return;
|
|
194
268
|
}
|
|
@@ -201,8 +275,15 @@ function openCommandPalette(id, opts) {
|
|
|
201
275
|
setActive(panel, next);
|
|
202
276
|
return;
|
|
203
277
|
}
|
|
278
|
+
if (e.key === "Home" || e.key === "End") {
|
|
279
|
+
e.preventDefault();
|
|
280
|
+
const items = getVisibleItems(panel);
|
|
281
|
+
if (items.length === 0) return;
|
|
282
|
+
setActive(panel, e.key === "Home" ? 0 : items.length - 1);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
204
285
|
if (e.key === "Enter") {
|
|
205
|
-
const active = panel.querySelector(".command-palette-item.is-active");
|
|
286
|
+
const active = panel.querySelector(".icen-command-palette-item.is-active");
|
|
206
287
|
if (active && !isDisabledItem(active)) {
|
|
207
288
|
e.preventDefault();
|
|
208
289
|
if (!programmaticCommands.has(active)) emitMenuSelect(panel, active);
|
|
@@ -212,9 +293,7 @@ function openCommandPalette(id, opts) {
|
|
|
212
293
|
}
|
|
213
294
|
if (e.key === "Tab") {
|
|
214
295
|
e.preventDefault();
|
|
215
|
-
const els =
|
|
216
|
-
(el) => !el.hidden && el.offsetParent !== null
|
|
217
|
-
);
|
|
296
|
+
const els = focusableWithin(panel);
|
|
218
297
|
if (els.length === 0) return;
|
|
219
298
|
const cur = els.findIndex((el) => el === document.activeElement);
|
|
220
299
|
const next = e.shiftKey ? (cur - 1 + els.length) % els.length : (cur + 1) % els.length;
|
|
@@ -224,10 +303,13 @@ function openCommandPalette(id, opts) {
|
|
|
224
303
|
window.addEventListener("keydown", keyHandler);
|
|
225
304
|
emitIcen(document, "icen:command-palette-open", {});
|
|
226
305
|
}
|
|
227
|
-
function closeCommandPalette(id) {
|
|
306
|
+
function closeCommandPalette(id, opts) {
|
|
228
307
|
if (typeof document === "undefined") return;
|
|
229
308
|
const backdrop = findBackdrop(id);
|
|
230
|
-
if (backdrop
|
|
309
|
+
if (backdrop && openId !== id) {
|
|
310
|
+
backdrop.hidden = true;
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
231
313
|
if (openId !== id) return;
|
|
232
314
|
openId = null;
|
|
233
315
|
if (keyHandler) {
|
|
@@ -238,6 +320,26 @@ function closeCommandPalette(id) {
|
|
|
238
320
|
if (restoreFocusTo && restoreFocusTo.isConnected) restoreFocusTo.focus();
|
|
239
321
|
restoreFocusTo = null;
|
|
240
322
|
emitIcen(document, "icen:command-palette-close", {});
|
|
323
|
+
if (!backdrop) return;
|
|
324
|
+
const calm = opts?.immediate || typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
325
|
+
if (calm || !backdrop.isConnected) {
|
|
326
|
+
backdrop.hidden = true;
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
backdrop.dataset.icenState = "closing";
|
|
330
|
+
const finalize = () => {
|
|
331
|
+
if (!closingState || closingState.backdrop !== backdrop) return;
|
|
332
|
+
window.clearTimeout(closingState.timer);
|
|
333
|
+
backdrop.removeEventListener("transitionend", closingState.onEnd);
|
|
334
|
+
closingState = null;
|
|
335
|
+
delete backdrop.dataset.icenState;
|
|
336
|
+
backdrop.hidden = true;
|
|
337
|
+
};
|
|
338
|
+
const onEnd = (event) => {
|
|
339
|
+
if (event.target === backdrop && event.propertyName === "opacity") finalize();
|
|
340
|
+
};
|
|
341
|
+
backdrop.addEventListener("transitionend", onEnd);
|
|
342
|
+
closingState = { id, backdrop, timer: window.setTimeout(finalize, CP_EXIT_FALLBACK_MS), onEnd };
|
|
241
343
|
}
|
|
242
344
|
function initCommandPalette(root) {
|
|
243
345
|
if (typeof document === "undefined") return () => {
|
|
@@ -245,38 +347,38 @@ function initCommandPalette(root) {
|
|
|
245
347
|
if (typeof window === "undefined") return () => {
|
|
246
348
|
};
|
|
247
349
|
const scope = root ?? document;
|
|
248
|
-
scope.querySelectorAll("[data-command-palette-open]").forEach((el) => el.setAttribute("aria-haspopup", "dialog"));
|
|
350
|
+
scope.querySelectorAll("[data-icen-command-palette-open]").forEach((el) => el.setAttribute("aria-haspopup", "dialog"));
|
|
249
351
|
if (teardown) return teardown;
|
|
250
352
|
const onClick = (e) => {
|
|
251
353
|
const target = e.target instanceof Element ? e.target : null;
|
|
252
354
|
if (!target) return;
|
|
253
|
-
const opener = target.closest("[data-command-palette-open]");
|
|
254
|
-
if (opener?.dataset.
|
|
255
|
-
openCommandPalette(opener.dataset.
|
|
355
|
+
const opener = target.closest("[data-icen-command-palette-open]");
|
|
356
|
+
if (opener?.dataset.icenCommandPaletteOpen) {
|
|
357
|
+
openCommandPalette(opener.dataset.icenCommandPaletteOpen);
|
|
256
358
|
return;
|
|
257
359
|
}
|
|
258
|
-
const item = target.closest(".command-palette-item");
|
|
360
|
+
const item = target.closest(".icen-command-palette-item");
|
|
259
361
|
if (item) {
|
|
260
|
-
const backdrop = item.closest("[data-command-palette]");
|
|
261
|
-
if (backdrop?.dataset.
|
|
262
|
-
const panelEl = item.closest(".command-palette");
|
|
362
|
+
const backdrop = item.closest("[data-icen-command-palette]");
|
|
363
|
+
if (backdrop?.dataset.icenCommandPalette) {
|
|
364
|
+
const panelEl = item.closest(".icen-command-palette");
|
|
263
365
|
if (panelEl && !programmaticCommands.has(item)) emitMenuSelect(panelEl, item);
|
|
264
|
-
if (!item.hasAttribute("data-command-palette-keep-open")) {
|
|
265
|
-
closeCommandPalette(backdrop.dataset.
|
|
366
|
+
if (!item.hasAttribute("data-icen-command-palette-keep-open")) {
|
|
367
|
+
closeCommandPalette(backdrop.dataset.icenCommandPalette);
|
|
266
368
|
}
|
|
267
369
|
}
|
|
268
370
|
return;
|
|
269
371
|
}
|
|
270
|
-
if (target instanceof HTMLElement && target.classList.contains("command-palette-backdrop") && target.dataset.
|
|
271
|
-
closeCommandPalette(target.dataset.
|
|
372
|
+
if (target instanceof HTMLElement && target.classList.contains("icen-command-palette-backdrop") && target.dataset.icenCommandPalette) {
|
|
373
|
+
closeCommandPalette(target.dataset.icenCommandPalette);
|
|
272
374
|
}
|
|
273
375
|
};
|
|
274
376
|
document.addEventListener("click", onClick);
|
|
275
377
|
const onInput = (e) => {
|
|
276
378
|
if (!(e.target instanceof HTMLElement)) return;
|
|
277
|
-
if (!e.target.matches(".command-palette-input")) return;
|
|
278
|
-
const backdrop = e.target.closest("[data-command-palette]");
|
|
279
|
-
const panel = backdrop?.querySelector(".command-palette");
|
|
379
|
+
if (!e.target.matches(".icen-command-palette-input")) return;
|
|
380
|
+
const backdrop = e.target.closest("[data-icen-command-palette]");
|
|
381
|
+
const panel = backdrop?.querySelector(".icen-command-palette");
|
|
280
382
|
if (panel) filterPanel(panel, e.target.value);
|
|
281
383
|
};
|
|
282
384
|
document.addEventListener("input", onInput);
|
|
@@ -284,12 +386,12 @@ function initCommandPalette(root) {
|
|
|
284
386
|
if (!(e.metaKey || e.ctrlKey)) return;
|
|
285
387
|
const key = e.key.toLowerCase();
|
|
286
388
|
const palettes = document.querySelectorAll(
|
|
287
|
-
".command-palette-backdrop[data-command-palette]"
|
|
389
|
+
".icen-command-palette-backdrop[data-icen-command-palette]"
|
|
288
390
|
);
|
|
289
391
|
for (const backdrop of Array.from(palettes)) {
|
|
290
|
-
const paletteKey = (backdrop.dataset.
|
|
392
|
+
const paletteKey = (backdrop.dataset.icenCommandPaletteKey ?? "k").toLowerCase();
|
|
291
393
|
if (paletteKey !== key) continue;
|
|
292
|
-
const id = backdrop.dataset.
|
|
394
|
+
const id = backdrop.dataset.icenCommandPalette;
|
|
293
395
|
if (!id) continue;
|
|
294
396
|
e.preventDefault();
|
|
295
397
|
if (openId === id) closeCommandPalette(id);
|
|
@@ -305,7 +407,7 @@ function initCommandPalette(root) {
|
|
|
305
407
|
window.removeEventListener("keydown", globalKeyHandler);
|
|
306
408
|
globalKeyHandler = null;
|
|
307
409
|
}
|
|
308
|
-
if (openId) closeCommandPalette(openId);
|
|
410
|
+
if (openId) closeCommandPalette(openId, { immediate: true });
|
|
309
411
|
teardown = null;
|
|
310
412
|
};
|
|
311
413
|
return teardown;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IconName } from './icons.js';
|
|
1
2
|
import { PanelSizing } from './popover.js';
|
|
2
3
|
|
|
3
4
|
interface ContextMenuEntry {
|
|
@@ -5,6 +6,8 @@ interface ContextMenuEntry {
|
|
|
5
6
|
subLabel?: string;
|
|
6
7
|
/** 可信 svg 字符串(唯一走 innerHTML 的字段) */
|
|
7
8
|
icon?: string;
|
|
9
|
+
/** Shared ICEN symbol (preferred over hand-written SVG). */
|
|
10
|
+
iconName?: IconName;
|
|
8
11
|
shortcut?: string;
|
|
9
12
|
danger?: boolean;
|
|
10
13
|
disabled?: boolean;
|
|
@@ -27,21 +30,19 @@ interface ContextMenuOptions {
|
|
|
27
30
|
/** 菜单选中统一事件(dropdown / context-menu / command-palette 同一契约)。
|
|
28
31
|
* 本模块为唯一定义点,dropdown / command-palette 改为 import 复用(收敛三份逐字拷贝)。 */
|
|
29
32
|
declare function emitMenuSelect(source: HTMLElement, item: HTMLElement): void;
|
|
30
|
-
/** 注册指定 id 的右键菜单项(对应 DOM 中的 [data-context-menu="id"])。 */
|
|
33
|
+
/** 注册指定 id 的右键菜单项(对应 DOM 中的 [data-icen-context-menu="id"])。 */
|
|
31
34
|
declare function registerContextMenu(id: string, items: ContextMenuItem[]): void;
|
|
35
|
+
/** Remove a registration and its retained host callbacks. */
|
|
36
|
+
declare function unregisterContextMenu(id: string): void;
|
|
32
37
|
/** 在 (x, y) 打开右键菜单(视口边缘自动翻转并 clamp)。
|
|
33
38
|
尺寸走全库统一 PanelSizing 契约:opts.sizing 直接传入(面板无固定宿主元素,
|
|
34
39
|
由调用方从其根元素 readPanelSizing 读入,如 datatable 行右键)。 */
|
|
35
40
|
declare function openContextMenu(x: number, y: number, items: ContextMenuItem[], opts?: {
|
|
36
41
|
sizing?: PanelSizing;
|
|
42
|
+
returnFocus?: HTMLElement;
|
|
37
43
|
}): void;
|
|
38
44
|
/** 关闭当前右键菜单(未打开时为 no-op)。 */
|
|
39
|
-
declare function closeContextMenu(): void;
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated 已更名 closeContextMenu(与全库浮层 close* 命名对齐);
|
|
42
|
-
* 本别名仅为兼容保留,下个大版本删除。
|
|
43
|
-
*/
|
|
44
|
-
declare function closeMenu(): void;
|
|
45
|
+
declare function closeContextMenu(restoreFocus?: boolean): void;
|
|
45
46
|
/**
|
|
46
47
|
* 启动全局右键菜单(重复调用安全)。
|
|
47
48
|
* opts.items 提供时替换内置默认菜单。
|
|
@@ -50,4 +51,4 @@ declare function closeMenu(): void;
|
|
|
50
51
|
*/
|
|
51
52
|
declare function initContextMenu(opts?: ContextMenuOptions): () => void;
|
|
52
53
|
|
|
53
|
-
export { type ContextMenuEntry, type ContextMenuHeader, type ContextMenuItem, type ContextMenuOptions, type ContextMenuSeparator, closeContextMenu,
|
|
54
|
+
export { type ContextMenuEntry, type ContextMenuHeader, type ContextMenuItem, type ContextMenuOptions, type ContextMenuSeparator, closeContextMenu, emitMenuSelect, initContextMenu, openContextMenu, registerContextMenu, unregisterContextMenu };
|