@quirekit/ui 0.0.1-alpha.4 → 0.0.2

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 (61) hide show
  1. package/README.md +2 -1
  2. package/README.zh-CN.md +2 -1
  3. package/dist/{chat-BAee3Pg0.mjs → chat-DaOlDJNQ.mjs} +87 -72
  4. package/dist/chat-DaOlDJNQ.mjs.map +1 -0
  5. package/dist/chat.d.mts +2 -2
  6. package/dist/chat.mjs +1 -1
  7. package/dist/{index-Su5SBM61.d.mts → index-Bf9CudSF.d.mts} +20 -3
  8. package/dist/index-Bf9CudSF.d.mts.map +1 -0
  9. package/dist/{index-HLNk4rQN.d.mts → index-DZc5z5s2.d.mts} +4 -4
  10. package/dist/{index-HLNk4rQN.d.mts.map → index-DZc5z5s2.d.mts.map} +1 -1
  11. package/dist/index.d.mts +2 -2
  12. package/dist/index.mjs +17 -3
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/{model-CeJjdZm_.mjs → model-D4-FbKXY.mjs} +2 -2
  15. package/dist/{model-CeJjdZm_.mjs.map → model-D4-FbKXY.mjs.map} +1 -1
  16. package/dist/{resolve-CGFbhFiM.mjs → resolve-BwTfY4PS.mjs} +2 -2
  17. package/dist/{resolve-CGFbhFiM.mjs.map → resolve-BwTfY4PS.mjs.map} +1 -1
  18. package/dist/style.css +13 -0
  19. package/dist/vue.d.mts +653 -590
  20. package/dist/vue.d.mts.map +1 -1
  21. package/dist/vue.mjs +1156 -1018
  22. package/dist/vue.mjs.map +1 -1
  23. package/package.json +6 -3
  24. package/src/components/accordion/index.ts +2 -1
  25. package/src/components/accordion/types.ts +3 -0
  26. package/src/components/segmented/create.ts +1 -1
  27. package/src/components/segmented/index.ts +1 -0
  28. package/src/components/segmented/types.ts +4 -1
  29. package/src/components/select/types.ts +2 -0
  30. package/src/components/toolbar/types.ts +2 -0
  31. package/src/drag-cursor/hold.test.ts +13 -0
  32. package/src/drag-cursor/hold.ts +12 -0
  33. package/src/drag-cursor/index.ts +1 -0
  34. package/src/index.ts +1 -0
  35. package/src/vue/accordion/accordion.vue +7 -3
  36. package/src/vue/block-handle/block-handle.test.ts +30 -0
  37. package/src/vue/block-handle/block-handle.vue +27 -0
  38. package/src/vue/block-handle/index.ts +3 -0
  39. package/src/vue/block-handle/presentation.ts +23 -0
  40. package/src/vue/block-handle/types.ts +14 -0
  41. package/src/vue/comment/action.vue +33 -0
  42. package/src/vue/comment/comment.test.ts +5 -0
  43. package/src/vue/comment/index.ts +1 -0
  44. package/src/vue/comment/message.vue +18 -7
  45. package/src/vue/comment/thread.vue +24 -10
  46. package/src/vue/dialog/theme.test.ts +1 -1
  47. package/src/vue/index.ts +1 -0
  48. package/src/vue/kbd/labels.ts +9 -0
  49. package/src/vue/segmented/segmented.vue +5 -0
  50. package/src/vue/select/select.vue +2 -0
  51. package/src/vue/select/shortcut.test.ts +18 -0
  52. package/src/vue/toolbar/items/control.vue +1 -0
  53. package/src/vue/toolbar/presentation/tooltip.vue +3 -1
  54. package/src/vue/toolbar/toolbar-action.vue +4 -1
  55. package/src/vue/toolbar/toolbar-disclosure.vue +4 -1
  56. package/src/vue/toolbar/toolbar-selector.vue +4 -1
  57. package/src/vue/toolbar/toolbar-toggle.vue +4 -1
  58. package/src/vue/tooltip/content.vue +6 -1
  59. package/src/vue/tooltip/shortcut.test.ts +27 -0
  60. package/dist/chat-BAee3Pg0.mjs.map +0 -1
  61. package/dist/index-Su5SBM61.d.mts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quirekit/ui",
3
- "version": "0.0.1-alpha.4",
3
+ "version": "0.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,9 @@
11
11
  "bugs": "https://github.com/quirekit/quirekit/issues",
12
12
  "description": "Framework-neutral browser UI primitives shared by QuireKit products and mounted views.",
13
13
  "type": "module",
14
- "sideEffects": false,
14
+ "sideEffects": [
15
+ "**/*.css"
16
+ ],
15
17
  "files": [
16
18
  "LICENSE.md",
17
19
  "THIRD_PARTY_NOTICES.md",
@@ -19,6 +21,7 @@
19
21
  "src"
20
22
  ],
21
23
  "exports": {
24
+ "./styles.css": "./dist/style.css",
22
25
  ".": {
23
26
  "types": "./dist/index.d.mts",
24
27
  "import": "./dist/index.mjs",
@@ -63,7 +66,7 @@
63
66
  "@internationalized/date": "3.12.3",
64
67
  "@tanstack/vue-table": "8.21.3",
65
68
  "vee-validate": "4.15.1",
66
- "@quirekit/html-sandbox": "0.0.1-alpha.4"
69
+ "@quirekit/html-sandbox": "0.0.2"
67
70
  },
68
71
  "scripts": {
69
72
  "build": "pnpm icons:generate && tsdown --config tsdown.config.ts",
@@ -1,5 +1,6 @@
1
1
  export type {
2
2
  QuireKitAccordionItem,
3
3
  QuireKitAccordionOrientation,
4
- QuireKitAccordionSize
4
+ QuireKitAccordionSize,
5
+ QuireKitAccordionVariant
5
6
  } from "./types";
@@ -4,6 +4,9 @@ export type QuireKitAccordionOrientation = "horizontal" | "vertical";
4
4
  /** Accordion 触发器的公开尺寸。 */
5
5
  export type QuireKitAccordionSize = "sm" | "md";
6
6
 
7
+ /** Accordion 的外框与条目边界外观。 */
8
+ export type QuireKitAccordionVariant = "outline" | "plain";
9
+
7
10
  /** Accordion 中一个稳定条目的框架无关合同。 */
8
11
  export interface QuireKitAccordionItem {
9
12
  /** 条目的稳定值,同时参与打开状态与 DOM 标识。 */
@@ -56,7 +56,7 @@ export function createSegmentedTokens(
56
56
  )
57
57
  }),
58
58
  trackInset: theme.borderWidth.focus,
59
- trackRadius: theme.radius.group,
59
+ trackRadius: `calc(${theme.radius.control} + ${theme.borderWidth.focus})`,
60
60
  indicatorRadius: theme.radius.control,
61
61
  trackBackground: theme.color.surface.hover,
62
62
  foreground: theme.color.text.secondary,
@@ -2,6 +2,7 @@ export { createSegmentedTokens } from "./create";
2
2
  export type {
3
3
  QuireKitSegmentedItem,
4
4
  QuireKitSegmentedOrientation,
5
+ QuireKitSegmentedShape,
5
6
  QuireKitSegmentedSize,
6
7
  QuireKitSegmentedSizeTokens,
7
8
  QuireKitSegmentedTokens
@@ -7,6 +7,9 @@ export type QuireKitSegmentedSize = QuireKitControlSize;
7
7
  /** Segmented Control 的排列方向。 */
8
8
  export type QuireKitSegmentedOrientation = "horizontal" | "vertical";
9
9
 
10
+ /** Segmented Control 轨道、选中片和选项共用的外形。 */
11
+ export type QuireKitSegmentedShape = "rounded" | "pill" | "square";
12
+
10
13
  /** 一个可被 Segmented Control 选择的稳定选项。 */
11
14
  export interface QuireKitSegmentedItem {
12
15
  /** 提交给表单和 v-model 的稳定语义值。 */
@@ -47,7 +50,7 @@ export interface QuireKitSegmentedTokens {
47
50
  >;
48
51
  /** 轨道与选中片之间的内缩距离。 */
49
52
  readonly trackInset: string;
50
- /** 轨道圆角。 */
53
+ /** 轨道圆角,默认由选中片圆角与轨道内缩距离配对。 */
51
54
  readonly trackRadius: string;
52
55
  /** 选中片圆角。 */
53
56
  readonly indicatorRadius: string;
@@ -23,4 +23,6 @@ export interface QuireKitSelectItem {
23
23
  readonly label: string;
24
24
  /** 是否禁止选择当前选项。 */
25
25
  readonly disabled?: boolean;
26
+ /** 选项后显示的快捷键,按阅读顺序列出;仅展示,不注册按键。 */
27
+ readonly shortcut?: readonly string[];
26
28
  }
@@ -205,6 +205,8 @@ export interface QuireKitToolbarEntry {
205
205
  readonly iconEmpty?: boolean;
206
206
  /** Tooltip explanation; defaults to label. False is for an enclosing compound tooltip owner. */
207
207
  readonly tooltip?: string | false;
208
+ /** Keyboard shortcut shown in the tooltip, in reading order such as `["⌘", "B"]`; display only, never registered. */
209
+ readonly shortcut?: readonly string[];
208
210
  /** Explanation shown while this entry is unavailable. */
209
211
  readonly disabledReason?: string;
210
212
  /** Native trigger data attributes; keyboard and interaction properties remain component-owned. */
@@ -0,0 +1,13 @@
1
+ // @vitest-environment happy-dom
2
+ import { expect, it } from "vitest";
3
+ import { holdQuireDragCursor } from "./hold";
4
+
5
+ it("adds one document-wide rule and removes it idempotently", () => {
6
+ const before = document.head.querySelectorAll("style").length;
7
+ const release = holdQuireDragCursor(document);
8
+ expect(document.head.querySelectorAll("style")).toHaveLength(before + 1);
9
+ expect(document.head.lastElementChild?.textContent).toContain("cursor: grabbing !important");
10
+ release();
11
+ release();
12
+ expect(document.head.querySelectorAll("style")).toHaveLength(before);
13
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shows the grabbing cursor across the document for one drag. Captured pointers
3
+ * otherwise keep whatever hover cursor the element under them last resolved.
4
+ * @param ownerDocument - Document containing the drag.
5
+ * @returns Idempotent release.
6
+ */
7
+ export function holdQuireDragCursor(ownerDocument: Document): () => void {
8
+ const style = ownerDocument.createElement("style");
9
+ style.textContent = "* { cursor: grabbing !important; }";
10
+ ownerDocument.head.append(style);
11
+ return () => style.remove();
12
+ }
@@ -0,0 +1 @@
1
+ export { holdQuireDragCursor } from "./hold";
package/src/index.ts CHANGED
@@ -27,3 +27,4 @@ export * from "./theme";
27
27
  export * from "./locale";
28
28
  export * from "./components";
29
29
  export * from "./selection-geometry";
30
+ export * from "./drag-cursor";
@@ -4,7 +4,8 @@ import { computed } from "vue";
4
4
  import type {
5
5
  QuireKitAccordionItem,
6
6
  QuireKitAccordionOrientation,
7
- QuireKitAccordionSize
7
+ QuireKitAccordionSize,
8
+ QuireKitAccordionVariant
8
9
  } from "../../components/accordion";
9
10
  import QuireIcon from "../icon/icon.vue";
10
11
 
@@ -24,6 +25,8 @@ interface Props {
24
25
  readonly orientation?: QuireKitAccordionOrientation;
25
26
  /** 触发器高度与排版尺寸。 */
26
27
  readonly size?: QuireKitAccordionSize;
28
+ /** outline 保留外框与分隔线;plain 通过间距组织条目。 */
29
+ readonly variant?: QuireKitAccordionVariant;
27
30
  /** 是否禁止整个 Accordion 的交互。 */
28
31
  readonly disabled?: boolean;
29
32
  /** 是否延迟挂载尚未展开过的内容。 */
@@ -62,6 +65,7 @@ const props = withDefaults(defineProps<Props>(), {
62
65
  collapsible: false,
63
66
  orientation: "vertical",
64
67
  size: "sm",
68
+ variant: "outline",
65
69
  disabled: false,
66
70
  lazyMount: false,
67
71
  unmountOnExit: false
@@ -98,7 +102,7 @@ function updateValue(value: string[]): void {
98
102
  :disabled="disabled"
99
103
  :lazy-mount="lazyMount"
100
104
  :unmount-on-exit="unmountOnExit"
101
- :class="['qk-accordion', `qk-accordion--${orientation}`]"
105
+ :class="['qk-accordion', `qk-accordion--${orientation}`, { 'qk-accordion--plain': variant === 'plain' }]"
102
106
  @update:model-value="updateValue"
103
107
  >
104
108
  <Accordion.Item
@@ -106,7 +110,7 @@ function updateValue(value: string[]): void {
106
110
  :key="item.value"
107
111
  :value="item.value"
108
112
  :disabled="item.disabled"
109
- class="qk-accordion__item"
113
+ :class="['qk-accordion__item', { 'qk-accordion__item--plain': variant === 'plain' }]"
110
114
  >
111
115
  <Accordion.ItemTrigger
112
116
  :class="['qk-accordion__trigger', `qk-accordion__trigger--${size}`]"
@@ -0,0 +1,30 @@
1
+ import { createSSRApp, h } from "vue";
2
+ import { renderToString } from "vue/server-renderer";
3
+ import { describe, expect, it } from "vitest";
4
+ import QuireBlockHandle from "./block-handle.vue";
5
+ import { quireBlockToneColor } from "./presentation";
6
+
7
+ /** @param props - Handle props and fallthrough attributes. @returns Server-rendered HTML. */
8
+ function render(props: Record<string, unknown>): Promise<string> {
9
+ return renderToString(createSSRApp({ render: () => h(QuireBlockHandle, props as never) }));
10
+ }
11
+
12
+ describe("QuireBlockHandle", () => {
13
+ it("colors only the type mark and keeps the grip muted", async () => {
14
+ const html = await render({ label: "拖动", icon: "table", tone: "teal" });
15
+ expect(html).toContain(`aria-label="拖动"`);
16
+ expect(html).toMatch(/qk-block-handle__type[^>]*style="color:\s*color-mix/);
17
+ expect(html).toMatch(/qk-block-handle__grip/);
18
+ });
19
+
20
+ it("prefers a text badge over the icon and forwards host attributes to the button", async () => {
21
+ const html = await render({ label: "拖动", icon: "heading", badge: "H2", tone: "blue", "data-block-handle": "", "aria-haspopup": "menu" });
22
+ expect(html).toContain(">H2<");
23
+ expect(html).toMatch(/<button[^>]*data-block-handle/);
24
+ expect(html).toMatch(/<button[^>]*aria-haspopup="menu"/);
25
+ });
26
+
27
+ it("falls back to a neutral mark", async () => {
28
+ expect(await render({ label: "拖动", icon: "layers" })).toContain(quireBlockToneColor("neutral"));
29
+ });
30
+ });
@@ -0,0 +1,27 @@
1
+ <script setup lang="ts">
2
+ import { computed } from "vue";
3
+ import QuireButton from "../button/button.vue";
4
+ import QuireIcon from "../icon/icon.vue";
5
+ import { quireBlockHandleWidth, quireBlockToneColor } from "./presentation";
6
+ import type { QuireBlockHandleProps } from "./types";
7
+
8
+ const props = withDefaults(defineProps<QuireBlockHandleProps>(), { tone: "neutral" });
9
+ const typeStyle = computed(() => ({ color: quireBlockToneColor(props.tone) }));
10
+ </script>
11
+ <template>
12
+ <QuireButton size="xs" color="neutral" variant="outline" class="qk-block-handle" :aria-label="label" :style="{ width: `${quireBlockHandleWidth}px` }">
13
+ <span class="qk-block-handle__content" aria-hidden="true">
14
+ <span class="qk-block-handle__type" :style="typeStyle"><span v-if="badge" class="qk-type-helper">{{ badge }}</span><QuireIcon v-else-if="icon" :name="icon" :size="16" /></span>
15
+ <QuireIcon name="gripVertical" :size="16" class="qk-block-handle__grip" />
16
+ </span>
17
+ </QuireButton>
18
+ </template>
19
+ <style scoped>
20
+ /* A quiet chip on the page: hairline edge, no fill until hover; the block type carries the color, the grip stays muted. */
21
+ .qk-block-handle { cursor: grab; touch-action: none; padding-inline: 1px 2px; border-radius: var(--qk-radius-group);
22
+ border-color: var(--qk-color-border-subtle); background: var(--qk-color-surface-page); box-shadow: none; }
23
+ .qk-block-handle:hover, .qk-block-handle[aria-expanded="true"] { background: var(--qk-color-surface-hover); }
24
+ .qk-block-handle__content { display: flex; align-items: center; justify-content: center; gap: 1px; }
25
+ .qk-block-handle__type { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; font-weight: var(--qk-type-heading-font-weight); }
26
+ .qk-block-handle__grip { color: var(--qk-color-text-placeholder); }
27
+ </style>
@@ -0,0 +1,3 @@
1
+ export { default as QuireBlockHandle } from "./block-handle.vue";
2
+ export { quireBlockHandleWidth, quireBlockToneColor } from "./presentation";
3
+ export type * from "./types";
@@ -0,0 +1,23 @@
1
+ import type { QuireBlockTone } from "./types";
2
+
3
+ /** Fixed handle width, so hosts can reserve its gutter before it mounts. */
4
+ export const quireBlockHandleWidth = 42;
5
+
6
+ /** Each tone derives from semantic feedback colors, so both schemes stay readable. */
7
+ const colors: Readonly<Record<QuireBlockTone, string>> = {
8
+ blue: "var(--qk-color-info-solid)",
9
+ indigo: "var(--qk-color-action-primary)",
10
+ green: "var(--qk-color-success-solid)",
11
+ orange: "var(--qk-color-warning-solid)",
12
+ teal: "color-mix(in oklab, var(--qk-color-info-solid), var(--qk-color-success-solid))",
13
+ purple: "color-mix(in oklab, var(--qk-color-info-solid), var(--qk-color-danger-solid))",
14
+ neutral: "var(--qk-color-icon-secondary)",
15
+ };
16
+
17
+ /**
18
+ * @param tone - Block color family.
19
+ * @returns CSS color usable inline, including in overlays outside the editor root.
20
+ */
21
+ export function quireBlockToneColor(tone: QuireBlockTone): string {
22
+ return colors[tone];
23
+ }
@@ -0,0 +1,14 @@
1
+ /** Color family of a block type, shared by handles and block menus. */
2
+ export type QuireBlockTone = "blue" | "indigo" | "green" | "orange" | "teal" | "purple" | "neutral";
3
+
4
+ /** Visible identity of the block a handle controls. */
5
+ export interface QuireBlockHandleProps {
6
+ /** Accessible name; the type mark itself is decorative. */
7
+ readonly label: string;
8
+ /** Registered icon name, used when no badge is given. */
9
+ readonly icon?: string | undefined;
10
+ /** Short text mark such as H1, preferred over the icon. */
11
+ readonly badge?: string | undefined;
12
+ /** Color family of the type mark. */
13
+ readonly tone?: QuireBlockTone | undefined;
14
+ }
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ import QuireIconButton from "../button/icon-button.vue";
3
+ import QuireIcon from "../icon/icon.vue";
4
+ import QuireTooltipContent from "../tooltip/content.vue";
5
+ import QuireTooltipRoot from "../tooltip/root.vue";
6
+ import QuireTooltipTrigger from "../tooltip/trigger.vue";
7
+
8
+ /** One icon command on a comment card, explained by a tooltip. */
9
+ interface Props {
10
+ /** Accessible name and tooltip text. */
11
+ readonly label: string;
12
+ /** Registered icon name. */
13
+ readonly icon: string;
14
+ /** Button color; defaults to the icon button's own. */
15
+ readonly color?: "neutral" | "success" | undefined;
16
+ /** Button emphasis; defaults to the icon button's own. */
17
+ readonly variant?: "ghost" | "soft" | undefined;
18
+ /** Whether the command is unavailable. */
19
+ readonly disabled?: boolean | undefined;
20
+ }
21
+
22
+ defineOptions({ inheritAttrs: false });
23
+ defineProps<Props>();
24
+ </script>
25
+
26
+ <template>
27
+ <QuireTooltipRoot placement="top">
28
+ <QuireTooltipTrigger as-child>
29
+ <QuireIconButton v-bind="{ ...$attrs, ...(color ? { color } : {}), ...(variant ? { variant } : {}) }" size="xs" :label="label" :disabled="disabled"><QuireIcon :name="icon" /></QuireIconButton>
30
+ </QuireTooltipTrigger>
31
+ <QuireTooltipContent :content="label" />
32
+ </QuireTooltipRoot>
33
+ </template>
@@ -30,6 +30,11 @@ describe("comment components", () => {
30
30
  expect(active).toContain('aria-label="回复"');
31
31
  });
32
32
 
33
+ it("places host actions in the card header", async () => {
34
+ const html = await renderToString(createSSRApp({ render: () => h(QuireLocaleProvider, { locale: "zh-CN" }, () => h(QuireCommentThread, { messages: [root], quote: "x" }, { actions: () => h("button", { "data-host-action": "" }) })) }));
35
+ expect(html.indexOf("data-host-action")).toBeGreaterThan(html.indexOf("qk-comment-thread__actions"));
36
+ });
37
+
33
38
  it("offers previous and next with the position only on the active card of a longer sequence", async () => {
34
39
  const active = await render(QuireCommentThread, { messages: [root], quote: "x", active: true, position: { index: 2, total: 5 } });
35
40
  expect(active).toContain('aria-label="上一条"');
@@ -1,3 +1,4 @@
1
+ export { default as QuireCommentAction } from "./action.vue";
1
2
  export { default as QuireCommentThread } from "./thread.vue";
2
3
  export { default as QuireCommentDraft } from "./draft.vue";
3
4
  export { default as QuireCommentRail } from "./rail.vue";
@@ -5,6 +5,10 @@ import QuireAvatar from "../avatar/avatar.vue";
5
5
  import QuireTag from "../tag/tag.vue";
6
6
  import QuireButton from "../button/button.vue";
7
7
  import QuireIconButton from "../button/icon-button.vue";
8
+ import QuireCommentAction from "./action.vue";
9
+ import QuireTooltipContent from "../tooltip/content.vue";
10
+ import QuireTooltipRoot from "../tooltip/root.vue";
11
+ import QuireTooltipTrigger from "../tooltip/trigger.vue";
8
12
  import QuireIcon from "../icon/icon.vue";
9
13
  import QuireMenu from "../menu/menu.vue";
10
14
  import { useQuireKitLocale, useQuireKitMessages } from "../locale-provider/context";
@@ -64,13 +68,20 @@ function save(): void { if (!props.busy && props.draft.trim()) emit("save", fiel
64
68
  <strong class="qk-comment-message__author">{{ message.author.name }}</strong>
65
69
  <QuireTag v-if="message.author.badge" size="xs" color="primary">{{ message.author.badge }}</QuireTag>
66
70
  <time class="qk-comment-thread__time" :datetime="message.time" :title="message.time">{{ formatCommentTime(message.time, locale) }}</time>
67
- <QuireIconButton v-if="actions.length === 1 && !editing" class="qk-comment-message__more" size="xs" :disabled="busy" :label="actions[0]!.label"
68
- :title="actions[0]!.label" @click="select(actions[0]!.value)"><QuireIcon :name="actions[0]!.icon!" /></QuireIconButton>
69
- <QuireMenu v-else-if="actions.length && !editing" :aria-label="text.moreActions" :items="actions" placement="bottom-end" @select="select">
70
- <template #trigger>
71
- <QuireIconButton class="qk-comment-message__more" size="xs" :label="text.moreActions" :title="text.moreActions"><QuireIcon name="moreHorizontal" /></QuireIconButton>
72
- </template>
73
- </QuireMenu>
71
+ <QuireCommentAction v-if="actions.length === 1 && !editing" class="qk-comment-message__more" :disabled="busy" :label="actions[0]!.label" :icon="actions[0]!.icon!"
72
+ @click="select(actions[0]!.value)" />
73
+ <QuireTooltipRoot v-else-if="actions.length && !editing" placement="top">
74
+ <QuireTooltipTrigger as-child>
75
+ <span class="qk-comment-message__menu">
76
+ <QuireMenu :aria-label="text.moreActions" :items="actions" placement="bottom-end" @select="select">
77
+ <template #trigger>
78
+ <QuireIconButton class="qk-comment-message__more" size="xs" :label="text.moreActions"><QuireIcon name="moreHorizontal" /></QuireIconButton>
79
+ </template>
80
+ </QuireMenu>
81
+ </span>
82
+ </QuireTooltipTrigger>
83
+ <QuireTooltipContent :content="text.moreActions" />
84
+ </QuireTooltipRoot>
74
85
  </div>
75
86
  <div v-if="editing && $slots.editor" class="qk-comment-message__editor"><slot name="editor" :message="message" /></div>
76
87
  <div v-else-if="editing" class="qk-comment-message__editor">
@@ -9,6 +9,10 @@ import QuireCard from "../card/card.vue";
9
9
  import QuireIcon from "../icon/icon.vue";
10
10
  import QuireMenu from "../menu/menu.vue";
11
11
  import { useQuireKitLocale, useQuireKitMessages } from "../locale-provider/context";
12
+ import QuireTooltipContent from "../tooltip/content.vue";
13
+ import QuireTooltipRoot from "../tooltip/root.vue";
14
+ import QuireTooltipTrigger from "../tooltip/trigger.vue";
15
+ import QuireCommentAction from "./action.vue";
12
16
  import CommentField from "./field.vue";
13
17
  import CommentMessage from "./message.vue";
14
18
  import { formatCommentTime } from "./presentation";
@@ -32,6 +36,8 @@ defineSlots<{
32
36
  body?: (props: { readonly message: QuireKitCommentMessage }) => unknown;
33
37
  /** Replaces the built-in plain-text editor, e.g. with a rich editor; the host saves and cancels through `editingId`. */
34
38
  editor?: (props: { readonly message: QuireKitCommentMessage }) => unknown;
39
+ /** Host controls placed before resolve in the card header, usually small icon buttons. */
40
+ actions?: () => unknown;
35
41
  }>();
36
42
  /** Message being edited; bind it to own editing, otherwise the card keeps it locally. */
37
43
  const editing = defineModel<string | null>("editingId", { default: null });
@@ -102,18 +108,26 @@ function cancelReply(): void { reply.value = ""; replying.value = false; }
102
108
  </button>
103
109
  <div class="qk-comment-thread__actions">
104
110
  <div v-if="stepping" class="qk-comment-thread__stepper">
105
- <QuireIconButton size="xs" :label="text.previous" :title="text.previous" @click="emit('previous')"><QuireIcon name="chevronUp" /></QuireIconButton>
111
+ <QuireCommentAction :label="text.previous" icon="chevronUp" @click="emit('previous')" />
106
112
  <span class="qk-comment-thread__position" :aria-label="text.position(position!.index, position!.total)">{{ position!.index }} / {{ position!.total }}</span>
107
- <QuireIconButton size="xs" :label="text.next" :title="text.next" @click="emit('next')"><QuireIcon name="chevronDown" /></QuireIconButton>
113
+ <QuireCommentAction :label="text.next" icon="chevronDown" @click="emit('next')" />
108
114
  </div>
109
- <QuireIconButton v-if="resolvable" size="xs" :color="resolved ? 'success' : 'neutral'" :variant="resolved ? 'soft' : 'ghost'"
110
- :disabled="busy" :label="resolved ? text.reopen : text.resolve" :title="resolved ? text.reopen : text.resolve" :aria-pressed="resolved"
111
- @click="resolved ? emit('reopen') : emit('resolve')"><QuireIcon name="circleCheck" /></QuireIconButton>
112
- <QuireMenu v-if="rootActions.length" :aria-label="text.moreActions" :items="rootActions" placement="bottom-end" @select="selectRoot">
113
- <template #trigger>
114
- <QuireIconButton size="xs" :label="text.moreActions" :title="text.moreActions"><QuireIcon name="moreHorizontal" /></QuireIconButton>
115
- </template>
116
- </QuireMenu>
115
+ <slot name="actions" />
116
+ <QuireCommentAction v-if="resolvable" :color="resolved ? 'success' : 'neutral'" :variant="resolved ? 'soft' : 'ghost'"
117
+ :disabled="busy" :label="resolved ? text.reopen : text.resolve" icon="circleCheck" :aria-pressed="resolved"
118
+ @click="resolved ? emit('reopen') : emit('resolve')" />
119
+ <QuireTooltipRoot v-if="rootActions.length" placement="top">
120
+ <QuireTooltipTrigger as-child>
121
+ <span class="qk-comment-thread__menu">
122
+ <QuireMenu :aria-label="text.moreActions" :items="rootActions" placement="bottom-end" @select="selectRoot">
123
+ <template #trigger>
124
+ <QuireIconButton size="xs" :label="text.moreActions"><QuireIcon name="moreHorizontal" /></QuireIconButton>
125
+ </template>
126
+ </QuireMenu>
127
+ </span>
128
+ </QuireTooltipTrigger>
129
+ <QuireTooltipContent :content="text.moreActions" />
130
+ </QuireTooltipRoot>
117
131
  </div>
118
132
  </div>
119
133
  </template>
@@ -149,7 +149,7 @@ it("keeps nested modal themes, labeling and later-opened hover outside backgroun
149
149
  await nextTick();
150
150
  expect(themeOwner(preview)!.style.getPropertyValue(colorName)).toBe(nestedTheme.value.color.selection.document);
151
151
  expect(themeOwner(dialog)!.style.getPropertyValue(colorName)).toBe(defaultTheme.color.selection.document);
152
- });
152
+ }, 15_000);
153
153
 
154
154
  it("keeps Toast resident under its theme scope instead of introducing a portal", async () => {
155
155
  const theme = shallowRef(defaultTheme);
package/src/vue/index.ts CHANGED
@@ -58,6 +58,7 @@ export * from "./candidate-list";
58
58
  export * from "./table";
59
59
 
60
60
  export * from "./badge";
61
+ export * from "./block-handle";
61
62
  export * from "./tag";
62
63
 
63
64
  export * from "./skeleton";
@@ -7,3 +7,12 @@ const keyNames: Readonly<Record<string, string>> = { "⌘": "Command", "⌥": "O
7
7
  export function keyLabel(keys: readonly string[]): string {
8
8
  return keys.map(key => keyNames[key] ?? key).join(" + ");
9
9
  }
10
+
11
+ /**
12
+ * Writes a shortcut as one inline chord for menus and tooltips.
13
+ * @param keys - Explicit key sequence supplied by the host.
14
+ * @returns Modifier symbols read as one chord (`⇧⌘S`); named keys keep separators (`Ctrl+Shift+S`).
15
+ */
16
+ export function chordText(keys: readonly string[]): string {
17
+ return keys.join(keys.slice(0, -1).every(key => /^[⌘⌥⌃⇧]$/u.test(key)) ? "" : "+");
18
+ }
@@ -5,6 +5,7 @@ import { guardRadioReadOnlyKey } from "../radio-group/keyboard";
5
5
  import type {
6
6
  QuireKitSegmentedItem,
7
7
  QuireKitSegmentedOrientation,
8
+ QuireKitSegmentedShape,
8
9
  QuireKitSegmentedSize
9
10
  } from "../../components/segmented";
10
11
 
@@ -22,6 +23,8 @@ interface Props {
22
23
  readonly form?: string;
23
24
  /** 同步约束高度、排版、间距和图标盒的公开尺寸。 */
24
25
  readonly size?: QuireKitSegmentedSize;
26
+ /** rounded 使用主题控件圆角;pill 使轨道与选中片两端呈半圆;square 为直角。 */
27
+ readonly shape?: QuireKitSegmentedShape;
25
28
  /** 选项排列和可访问方向;方向键遵循原生 radio 行为。 */
26
29
  readonly orientation?: QuireKitSegmentedOrientation;
27
30
  /** 是否让每个选项占据相同比例的可用空间。 */
@@ -53,6 +56,7 @@ const {
53
56
  name,
54
57
  form,
55
58
  size = "sm",
59
+ shape = "rounded",
56
60
  orientation = "horizontal",
57
61
  equal = false,
58
62
  disabled = false,
@@ -83,6 +87,7 @@ defineSlots<Slots>();
83
87
  'qk-segmented',
84
88
  `qk-segmented--${size}`,
85
89
  `qk-segmented--${orientation}`,
90
+ shape !== 'rounded' && `qk-segmented--${shape}`,
86
91
  equal && 'qk-segmented--equal'
87
92
  ]"
88
93
  @update:model-value="selectedValue = $event"
@@ -13,6 +13,7 @@ import type {
13
13
  QuireKitSelectSize
14
14
  } from "../../components/select";
15
15
  import QuireIcon from "../icon/icon.vue";
16
+ import { chordText, keyLabel } from "../kbd/labels";
16
17
  import { useModalPortal } from "../shared/surface/use-modal-portal";
17
18
  import { useQuireKitMessages } from "../locale-provider/context";
18
19
 
@@ -210,6 +211,7 @@ function updateValue(values: string[]): void {
210
211
  <Select.ItemText class="qk-select__item-label">
211
212
  <slot name="item" :item="item">{{ item.label }}</slot>
212
213
  </Select.ItemText>
214
+ <kbd v-if="item.shortcut?.length" class="qk-select__item-shortcut" :aria-label="keyLabel(item.shortcut)">{{ chordText(item.shortcut) }}</kbd>
213
215
  <Select.ItemIndicator class="qk-select__item-indicator">
214
216
  <QuireIcon name="check" :size="16" />
215
217
  </Select.ItemIndicator>
@@ -0,0 +1,18 @@
1
+ // @vitest-environment happy-dom
2
+ import { createApp, h, nextTick } from "vue";
3
+ import { expect, it } from "vitest";
4
+ import Select from "./select.vue";
5
+
6
+ it("shows an item's shortcut beside its label without changing the label text", async () => {
7
+ const host = document.createElement("div"); document.body.append(host);
8
+ const app = createApp({ setup: () => () => h(Select, { label: "Style", modelValue: "h1", open: true, portalled: false,
9
+ items: [{ label: "Heading 1", value: "h1", shortcut: ["⌥", "⌘", "1"] }, { label: "Paragraph", value: "p" }] }) });
10
+ app.mount(host); await nextTick(); await nextTick();
11
+ try {
12
+ const [first, second] = host.querySelectorAll(".qk-select__item");
13
+ expect(first!.querySelector(".qk-select__item-label")?.textContent?.trim()).toBe("Heading 1");
14
+ expect(first!.querySelector("kbd.qk-select__item-shortcut")?.textContent).toBe("⌥⌘1");
15
+ expect(first!.querySelector("kbd")?.getAttribute("aria-label")).toBe("Option + Command + 1");
16
+ expect(second!.querySelector("kbd")).toBeNull();
17
+ } finally { app.unmount(); host.remove(); }
18
+ });
@@ -47,6 +47,7 @@ const showLabels = inject(toolbarLabelsKey);
47
47
  const common = computed(() => ({
48
48
  ...props.item.attributes, label: props.item.label, disabled: unavailable.value,
49
49
  ...(props.item.tooltip === undefined ? {} : { tooltip: props.item.tooltip }),
50
+ ...(props.item.shortcut === undefined ? {} : { shortcut: props.item.shortcut }),
50
51
  ...(props.item.disabledReason === undefined ? {} : { disabledReason: props.item.disabledReason }),
51
52
  ...(props.item.describedBy === undefined ? {} : { describedBy: props.item.describedBy })
52
53
  }));
@@ -13,6 +13,8 @@ interface Props {
13
13
  readonly label: string;
14
14
  /** Override the label, or disable a tooltip owned by an enclosing compound control. */
15
15
  readonly tooltip?: string | false | undefined;
16
+ /** Keys shown beside the explanation; hidden while a disabled reason replaces it. */
17
+ readonly shortcut?: readonly string[] | undefined;
16
18
  /** Explanation displayed while the command is unavailable. */
17
19
  readonly disabledReason?: string | undefined;
18
20
  /** Current command availability, independent of tooltip availability. */
@@ -35,7 +37,7 @@ defineSlots<{
35
37
  <QuireTooltipTrigger as-child><slot /></QuireTooltipTrigger>
36
38
  <slot name="content">
37
39
  <QuireTooltipContent v-bind="{ ...(tooltip === false ? {} : { content: tooltip ?? label }),
38
- ...(disabledReason === undefined ? {} : { disabledReason }) }" :subject-disabled="subjectDisabled ?? false" />
40
+ ...(disabledReason === undefined ? {} : { disabledReason }), ...(shortcut?.length ? { shortcut } : {}) }" :subject-disabled="subjectDisabled ?? false" />
39
41
  </slot>
40
42
  </QuireTooltipRoot>
41
43
  </template>
@@ -7,6 +7,8 @@ import { useToolbarItem } from "./use-toolbar-item";
7
7
  interface Props {
8
8
  /** Tooltip explanation; defaults to the accessible label. */
9
9
  readonly tooltip?: string | false;
10
+ /** Keys shown beside the tooltip text in reading order; display only. */
11
+ readonly shortcut?: readonly string[];
10
12
  /** Reason displayed while this control is unavailable. */
11
13
  readonly disabledReason?: string;
12
14
  /** Optional visible text beside the icon. */
@@ -40,6 +42,7 @@ const {
40
42
  disabled = false,
41
43
  describedBy,
42
44
  tooltip = undefined,
45
+ shortcut,
43
46
  disabledReason
44
47
  } = defineProps<Props>();
45
48
  const emit = defineEmits<Emits>();
@@ -62,7 +65,7 @@ function activate(event: MouseEvent): void {
62
65
  </script>
63
66
 
64
67
  <template>
65
- <ToolbarTooltip :trigger-id="typeof $attrs.id === 'string' ? $attrs.id : item.id" :label="label" :tooltip="tooltip" :disabled-reason="disabledReason" :subject-disabled="disabled" >
68
+ <ToolbarTooltip :trigger-id="typeof $attrs.id === 'string' ? $attrs.id : item.id" :label="label" :tooltip="tooltip" :shortcut="shortcut" :disabled-reason="disabledReason" :subject-disabled="disabled" >
66
69
  <button
67
70
  :id="item.id"
68
71
  v-bind="$attrs"