@quirekit/ui 0.0.1 → 0.0.3
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/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/dist/{chat-BAee3Pg0.mjs → chat-BSVF78Hu.mjs} +91 -76
- package/dist/chat-BSVF78Hu.mjs.map +1 -0
- package/dist/chat.d.mts +2 -2
- package/dist/chat.mjs +1 -1
- package/dist/{code-block-D1kd-gAB.mjs → code-block-pXaSN9eY.mjs} +2 -2
- package/dist/{code-block-D1kd-gAB.mjs.map → code-block-pXaSN9eY.mjs.map} +1 -1
- package/dist/{html-sandbox-BYIni0q6.mjs → html-sandbox-CMsenGYi.mjs} +2 -2
- package/dist/{html-sandbox-BYIni0q6.mjs.map → html-sandbox-CMsenGYi.mjs.map} +1 -1
- package/dist/html-sandbox.mjs +1 -1
- package/dist/{index-Su5SBM61.d.mts → index-Bf9CudSF.d.mts} +20 -3
- package/dist/index-Bf9CudSF.d.mts.map +1 -0
- package/dist/{index-OJPxl6Iz.d.mts → index-DZc5z5s2.d.mts} +2 -2
- package/dist/{index-OJPxl6Iz.d.mts.map → index-DZc5z5s2.d.mts.map} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +17 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{model-CeJjdZm_.mjs → model-D4-FbKXY.mjs} +2 -2
- package/dist/{model-CeJjdZm_.mjs.map → model-D4-FbKXY.mjs.map} +1 -1
- package/dist/{resolve-CGFbhFiM.mjs → resolve-BwTfY4PS.mjs} +2 -2
- package/dist/{resolve-CGFbhFiM.mjs.map → resolve-BwTfY4PS.mjs.map} +1 -1
- package/dist/style.css +13 -0
- package/dist/vue.d.mts +643 -580
- package/dist/vue.d.mts.map +1 -1
- package/dist/vue.mjs +1164 -1026
- package/dist/vue.mjs.map +1 -1
- package/package.json +6 -3
- package/src/components/accordion/index.ts +2 -1
- package/src/components/accordion/types.ts +3 -0
- package/src/components/segmented/create.ts +1 -1
- package/src/components/segmented/index.ts +1 -0
- package/src/components/segmented/types.ts +4 -1
- package/src/components/select/types.ts +2 -0
- package/src/components/toolbar/types.ts +2 -0
- package/src/drag-cursor/hold.test.ts +13 -0
- package/src/drag-cursor/hold.ts +12 -0
- package/src/drag-cursor/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/vue/accordion/accordion.vue +7 -3
- package/src/vue/block-handle/block-handle.test.ts +30 -0
- package/src/vue/block-handle/block-handle.vue +27 -0
- package/src/vue/block-handle/index.ts +3 -0
- package/src/vue/block-handle/presentation.ts +23 -0
- package/src/vue/block-handle/types.ts +14 -0
- package/src/vue/code-block/theme-surface.vue +4 -1
- package/src/vue/comment/action.vue +33 -0
- package/src/vue/comment/comment.test.ts +5 -0
- package/src/vue/comment/index.ts +1 -0
- package/src/vue/comment/message.vue +18 -7
- package/src/vue/comment/thread.vue +24 -10
- package/src/vue/file-upload/file-upload.vue +1 -1
- package/src/vue/image-preview/theme-surface.vue +4 -1
- package/src/vue/index.ts +1 -0
- package/src/vue/kbd/labels.ts +9 -0
- package/src/vue/prose/mapping/native.ts +1 -1
- package/src/vue/prose/mapping/rich.ts +2 -1
- package/src/vue/schema-form/controls/registry.ts +1 -1
- package/src/vue/schema-form/tree.ts +1 -1
- package/src/vue/segmented/segmented.vue +5 -0
- package/src/vue/select/select.vue +2 -0
- package/src/vue/select/shortcut.test.ts +18 -0
- package/src/vue/shared/task/trigger.vue +1 -1
- package/src/vue/tags-input/tags-input.vue +1 -1
- package/src/vue/theme-provider/portal.vue +4 -1
- package/src/vue/theme-provider/surface.vue +4 -1
- package/src/vue/toolbar/items/control.vue +1 -0
- package/src/vue/toolbar/presentation/tooltip.vue +3 -1
- package/src/vue/toolbar/toolbar-action.vue +4 -1
- package/src/vue/toolbar/toolbar-disclosure.vue +4 -1
- package/src/vue/toolbar/toolbar-selector.vue +4 -1
- package/src/vue/toolbar/toolbar-toggle.vue +4 -1
- package/src/vue/tooltip/content.vue +6 -1
- package/src/vue/tooltip/shortcut.test.ts +27 -0
- package/dist/chat-BAee3Pg0.mjs.map +0 -1
- package/dist/index-Su5SBM61.d.mts.map +0 -1
|
@@ -94,7 +94,7 @@ function findButton(nodes: readonly VNode[]): VNode | undefined {
|
|
|
94
94
|
|
|
95
95
|
// As-child normally lets child attributes win. This component has no DOM of its
|
|
96
96
|
// own; cloning keeps the original button while making task identity authoritative.
|
|
97
|
-
const SlotButton = defineComponent({
|
|
97
|
+
const SlotButton = /* @__PURE__ */ defineComponent({
|
|
98
98
|
name: "TaskTriggerSlot",
|
|
99
99
|
inheritAttrs: false,
|
|
100
100
|
setup(_props, { attrs }) {
|
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
} from "./context";
|
|
10
10
|
import QuireThemeSurface from "./surface.vue";
|
|
11
11
|
|
|
12
|
-
export default
|
|
12
|
+
// The SFC compiler drops an annotation on `export default`, so the pure call is on its own declaration.
|
|
13
|
+
const ThemePortal = /* @__PURE__ */ defineComponent({
|
|
13
14
|
name: "QuireThemePortal",
|
|
14
15
|
inheritAttrs: false,
|
|
15
16
|
/**
|
|
@@ -33,4 +34,6 @@ export default defineComponent({
|
|
|
33
34
|
: h(QuireThemeSurface, { layout: "bridge" }, context.slots);
|
|
34
35
|
},
|
|
35
36
|
});
|
|
37
|
+
|
|
38
|
+
export default ThemePortal;
|
|
36
39
|
</script>
|
|
@@ -4,7 +4,8 @@ import { trackQuireKitInputModality } from "../../components/control/modality";
|
|
|
4
4
|
import { quireKitThemeKey } from "./context";
|
|
5
5
|
import { resolveThemeSurfaceStyle } from "./styles";
|
|
6
6
|
|
|
7
|
-
export default
|
|
7
|
+
// The SFC compiler drops an annotation on `export default`, so the pure call is on its own declaration.
|
|
8
|
+
const ThemeSurface = /* @__PURE__ */ defineComponent({
|
|
8
9
|
name: "QuireThemeSurface",
|
|
9
10
|
inheritAttrs: false,
|
|
10
11
|
props: {
|
|
@@ -33,4 +34,6 @@ export default defineComponent({
|
|
|
33
34
|
}, context.slots.default?.()) : context.slots.default?.();
|
|
34
35
|
},
|
|
35
36
|
});
|
|
37
|
+
|
|
38
|
+
export default ThemeSurface;
|
|
36
39
|
</script>
|
|
@@ -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"
|
|
@@ -12,6 +12,8 @@ interface Props {
|
|
|
12
12
|
readonly toggleOnClick?: boolean;
|
|
13
13
|
/** Tooltip explanation; defaults to the accessible label. */
|
|
14
14
|
readonly tooltip?: string | false;
|
|
15
|
+
/** Keys shown beside the tooltip text in reading order; display only. */
|
|
16
|
+
readonly shortcut?: readonly string[];
|
|
15
17
|
/** Reason displayed while this control is unavailable. */
|
|
16
18
|
readonly disabledReason?: string;
|
|
17
19
|
/** Show a compact indicator beside the icon or visible label. */
|
|
@@ -56,6 +58,7 @@ const {
|
|
|
56
58
|
disabled = false,
|
|
57
59
|
describedBy,
|
|
58
60
|
tooltip = undefined,
|
|
61
|
+
shortcut,
|
|
59
62
|
disabledReason,
|
|
60
63
|
indicator = false
|
|
61
64
|
} = defineProps<Props>();
|
|
@@ -93,7 +96,7 @@ function guardDisabledActivation(event: MouseEvent): void {
|
|
|
93
96
|
</script>
|
|
94
97
|
|
|
95
98
|
<template>
|
|
96
|
-
<ToolbarTooltip :trigger-id="typeof $attrs.id === 'string' ? $attrs.id : item.id" :label="label" :tooltip="tooltip" :disabled-reason="disabledReason" :subject-disabled="disabled" :suppressed="expanded && popup !== false">
|
|
99
|
+
<ToolbarTooltip :trigger-id="typeof $attrs.id === 'string' ? $attrs.id : item.id" :label="label" :tooltip="tooltip" :shortcut="shortcut" :disabled-reason="disabledReason" :subject-disabled="disabled" :suppressed="expanded && popup !== false">
|
|
97
100
|
<button
|
|
98
101
|
:id="item.id"
|
|
99
102
|
v-bind="$attrs"
|
|
@@ -12,6 +12,8 @@ interface Props {
|
|
|
12
12
|
readonly toggleOnClick?: boolean;
|
|
13
13
|
/** Tooltip explanation; defaults to the accessible label. */
|
|
14
14
|
readonly tooltip?: string | false;
|
|
15
|
+
/** Keys shown beside the tooltip text in reading order; display only. */
|
|
16
|
+
readonly shortcut?: readonly string[];
|
|
15
17
|
/** Reason displayed while this control is unavailable. */
|
|
16
18
|
readonly disabledReason?: string;
|
|
17
19
|
/** Accessible action name. */
|
|
@@ -54,6 +56,7 @@ const {
|
|
|
54
56
|
disabled = false,
|
|
55
57
|
describedBy,
|
|
56
58
|
tooltip = undefined,
|
|
59
|
+
shortcut,
|
|
57
60
|
disabledReason
|
|
58
61
|
} = defineProps<Props>();
|
|
59
62
|
const emit = defineEmits<Emits>();
|
|
@@ -90,7 +93,7 @@ function guardDisabledActivation(event: MouseEvent): void {
|
|
|
90
93
|
</script>
|
|
91
94
|
|
|
92
95
|
<template>
|
|
93
|
-
<ToolbarTooltip :trigger-id="typeof $attrs.id === 'string' ? $attrs.id : item.id" :label="label" :tooltip="tooltip" :disabled-reason="disabledReason" :subject-disabled="disabled" :suppressed="expanded">
|
|
96
|
+
<ToolbarTooltip :trigger-id="typeof $attrs.id === 'string' ? $attrs.id : item.id" :label="label" :tooltip="tooltip" :shortcut="shortcut" :disabled-reason="disabledReason" :subject-disabled="disabled" :suppressed="expanded">
|
|
94
97
|
<button
|
|
95
98
|
:id="item.id"
|
|
96
99
|
v-bind="$attrs"
|
|
@@ -8,6 +8,8 @@ import { useToolbarItem } from "./use-toolbar-item";
|
|
|
8
8
|
interface Props {
|
|
9
9
|
/** Tooltip explanation; defaults to the accessible label. */
|
|
10
10
|
readonly tooltip?: string | false;
|
|
11
|
+
/** Keys shown beside the tooltip text in reading order; display only. */
|
|
12
|
+
readonly shortcut?: readonly string[];
|
|
11
13
|
/** Reason displayed while this control is unavailable. */
|
|
12
14
|
readonly disabledReason?: string;
|
|
13
15
|
/** Optional visible text beside the icon. */
|
|
@@ -41,6 +43,7 @@ const {
|
|
|
41
43
|
disabled = false,
|
|
42
44
|
describedBy,
|
|
43
45
|
tooltip = undefined,
|
|
46
|
+
shortcut,
|
|
44
47
|
disabledReason
|
|
45
48
|
} = defineProps<Props>();
|
|
46
49
|
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"
|
|
@@ -5,11 +5,14 @@ import { computed, onMounted, ref, useAttrs } from "vue";
|
|
|
5
5
|
import { Tooltip, useTooltipContext } from "@ark-ui/vue/tooltip";
|
|
6
6
|
import { resolveTooltipContent } from "../../components/tooltip";
|
|
7
7
|
import { useModalPortal } from "../shared/surface/use-modal-portal";
|
|
8
|
+
import { chordText, keyLabel } from "../kbd/labels";
|
|
8
9
|
|
|
9
10
|
/** Tooltip Content 的公开属性。 */
|
|
10
11
|
interface Props {
|
|
11
12
|
/** 普通提示标签或快捷键说明。 */
|
|
12
13
|
readonly content?: string;
|
|
14
|
+
/** 显示在提示文字后的快捷键,按阅读顺序列出;仅展示,不注册按键。 */
|
|
15
|
+
readonly shortcut?: readonly string[];
|
|
13
16
|
/** 控件不可用时替换普通提示的原因说明。 */
|
|
14
17
|
readonly disabledReason?: string;
|
|
15
18
|
/** 被提示的控件是否不可用。 */
|
|
@@ -55,6 +58,8 @@ const resolvedContent = computed(() =>
|
|
|
55
58
|
: { disabledReason: props.disabledReason })
|
|
56
59
|
})
|
|
57
60
|
);
|
|
61
|
+
const shortcutText = computed(() =>
|
|
62
|
+
props.shortcut?.length && !(props.subjectDisabled && props.disabledReason) ? chordText(props.shortcut) : "");
|
|
58
63
|
</script>
|
|
59
64
|
|
|
60
65
|
<template>
|
|
@@ -89,7 +94,7 @@ const resolvedContent = computed(() =>
|
|
|
89
94
|
/>
|
|
90
95
|
</Tooltip.Arrow>
|
|
91
96
|
<slot :content="resolvedContent">
|
|
92
|
-
{{ resolvedContent }}
|
|
97
|
+
{{ resolvedContent }}<kbd v-if="shortcutText" class="qk-tooltip__shortcut" :aria-label="keyLabel(shortcut!)">{{ shortcutText }}</kbd>
|
|
93
98
|
</slot>
|
|
94
99
|
</Tooltip.Content>
|
|
95
100
|
</Tooltip.Positioner>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { createApp, h, nextTick } from "vue";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import TooltipRoot from "./root.vue";
|
|
5
|
+
import TooltipTrigger from "./trigger.vue";
|
|
6
|
+
import TooltipContent from "./content.vue";
|
|
7
|
+
|
|
8
|
+
/** @param props - Content properties. @returns The open tooltip's content element. */
|
|
9
|
+
async function content(props: Record<string, unknown>): Promise<HTMLElement> {
|
|
10
|
+
const host = document.createElement("div"); document.body.append(host);
|
|
11
|
+
const app = createApp({ render: () => h(TooltipRoot, { open: true }, { default: () => [
|
|
12
|
+
h(TooltipTrigger, { asChild: true }, () => h("button", "Bold")), h(TooltipContent, { portalled: false, ...props }),
|
|
13
|
+
] }) });
|
|
14
|
+
app.mount(host); await nextTick(); await nextTick();
|
|
15
|
+
return host.querySelector<HTMLElement>('[data-part="content"]')!;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
it("shows a chord after the explanation and hides it behind a disabled reason", async () => {
|
|
19
|
+
const mac = await content({ content: "Bold", shortcut: ["⇧", "⌘", "B"] });
|
|
20
|
+
expect(mac.textContent).toContain("Bold");
|
|
21
|
+
expect(mac.querySelector("kbd.qk-tooltip__shortcut")?.textContent).toBe("⇧⌘B");
|
|
22
|
+
expect(mac.querySelector("kbd")?.getAttribute("aria-label")).toBe("Shift + Command + B");
|
|
23
|
+
const other = await content({ content: "Bold", shortcut: ["Ctrl", "B"] });
|
|
24
|
+
expect(other.querySelector("kbd")?.textContent).toBe("Ctrl+B");
|
|
25
|
+
const disabled = await content({ content: "Bold", shortcut: ["Ctrl", "B"], subjectDisabled: true, disabledReason: "Select text" });
|
|
26
|
+
expect(disabled.querySelector("kbd")).toBeNull();
|
|
27
|
+
});
|