@quirekit/ui 0.1.0 → 0.2.1
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/dist/{catalog-TxH_u9wJ.mjs → catalog-Dn7izrV5.mjs} +545 -18
- package/dist/catalog-Dn7izrV5.mjs.map +1 -0
- package/dist/{chat-CDuOfk3d.mjs → chat-1THPEdHw.mjs} +6 -6
- package/dist/chat-1THPEdHw.mjs.map +1 -0
- package/dist/chat.d.mts +2 -2
- package/dist/chat.mjs +1 -1
- package/dist/{code-block-5fEEwwMN.mjs → code-block-BLzjRjTb.mjs} +2 -2
- package/dist/{code-block-5fEEwwMN.mjs.map → code-block-BLzjRjTb.mjs.map} +1 -1
- package/dist/{html-sandbox-BJeg9mHs.mjs → html-sandbox-D9a7iXbU.mjs} +2 -2
- package/dist/{html-sandbox-BJeg9mHs.mjs.map → html-sandbox-D9a7iXbU.mjs.map} +1 -1
- package/dist/html-sandbox.mjs +1 -1
- package/dist/{index-BOSlg0Xl.d.mts → index-BkzB7Lb6.d.mts} +279 -6
- package/dist/index-BkzB7Lb6.d.mts.map +1 -0
- package/dist/{index-CtgUjd_A.d.mts → index-FDnUNAX_.d.mts} +27 -27
- package/dist/{index-CtgUjd_A.d.mts.map → index-FDnUNAX_.d.mts.map} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/{model-DvNHVLwg.mjs → model-BjGYjpa9.mjs} +3 -3
- package/dist/{model-DvNHVLwg.mjs.map → model-BjGYjpa9.mjs.map} +1 -1
- package/dist/{resolve-DlCNcx0Q.mjs → resolve-nFmJOtS9.mjs} +2 -2
- package/dist/{resolve-DlCNcx0Q.mjs.map → resolve-nFmJOtS9.mjs.map} +1 -1
- package/dist/vue.d.mts +180 -172
- package/dist/vue.d.mts.map +1 -1
- package/dist/vue.mjs +155 -62
- package/dist/vue.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/dialog/index.ts +1 -1
- package/src/components/dialog/types.ts +5 -2
- package/src/components/icon/custom/formatting.ts +3 -0
- package/src/components/icon/custom/insert.ts +30 -0
- package/src/components/icon/custom/mind-map.ts +28 -0
- package/src/components/icon/custom.ts +3 -1
- package/src/components/icon/lucide.ts +21 -1
- package/src/components/icon/metadata.ts +277 -0
- package/src/locale/components/icon-catalog/en.ts +86 -2
- package/src/locale/components/icon-catalog/zh-hans.ts +86 -2
- package/src/vue/dialog/content.vue +29 -5
- package/src/vue/dialog/size.test.ts +61 -0
- package/src/vue/scroll-area/scroll-area.test.ts +10 -0
- package/src/vue/scroll-area/scroll-area.vue +1 -1
- package/src/vue/select/select.test.ts +18 -0
- package/src/vue/select/select.vue +3 -0
- package/src/vue/slider/slider.test.ts +13 -0
- package/src/vue/slider/slider.vue +4 -2
- package/src/vue/splitter/splitter.vue +1 -1
- package/src/vue/toolbar/items/body.vue +5 -3
- package/src/vue/toolbar/items/memo.test.ts +49 -0
- package/src/vue/toolbar/items/memo.ts +24 -0
- package/src/vue/toolbar/toolbar-split-button.test.ts +2 -0
- package/src/vue/toolbar/toolbar-split-button.vue +1 -0
- package/dist/catalog-TxH_u9wJ.mjs.map +0 -1
- package/dist/chat-CDuOfk3d.mjs.map +0 -1
- package/dist/index-BOSlg0Xl.d.mts.map +0 -1
|
@@ -23,9 +23,24 @@ export const en: Messages = {
|
|
|
23
23
|
"table-structure": "Table · Structure",
|
|
24
24
|
"table-style": "Table · Borders and layout",
|
|
25
25
|
review: "Review and comments",
|
|
26
|
-
page: "Page and objects"
|
|
26
|
+
page: "Page and objects",
|
|
27
|
+
"object-tools": "Object tools",
|
|
28
|
+
presentation: "Presentation",
|
|
29
|
+
"mind-map": "Mind map"
|
|
27
30
|
},
|
|
28
31
|
icons: {
|
|
32
|
+
marqueeSelect: "Marquee select",
|
|
33
|
+
mindTopic: "Sibling topic",
|
|
34
|
+
mindSubtopic: "Subtopic",
|
|
35
|
+
mindParentTopic: "Parent topic",
|
|
36
|
+
mindFloatingTopic: "Floating topic",
|
|
37
|
+
mindRelation: "Relationship",
|
|
38
|
+
mindSummary: "Summary",
|
|
39
|
+
mindBoundary: "Boundary",
|
|
40
|
+
mindLayout: "Map structure",
|
|
41
|
+
mindStyle: "Topic style",
|
|
42
|
+
mindExpandBranch: "Expand branch",
|
|
43
|
+
mindCollapseBranch: "Collapse branch",
|
|
29
44
|
gitBranch: "Branch connection",
|
|
30
45
|
outlineColor: "Outline color",
|
|
31
46
|
tableOfContents: "Table of contents",
|
|
@@ -34,6 +49,13 @@ export const en: Messages = {
|
|
|
34
49
|
shapes: "Shapes",
|
|
35
50
|
pencilRuler: "Drawing tools",
|
|
36
51
|
whiteboard: "Whiteboard",
|
|
52
|
+
animation: "Animation",
|
|
53
|
+
animationEntrance: "Entrance animation",
|
|
54
|
+
animationEmphasis: "Emphasis animation",
|
|
55
|
+
animationExit: "Exit animation",
|
|
56
|
+
slideTransition: "Slide transition",
|
|
57
|
+
freehand: "Freehand",
|
|
58
|
+
editPoints: "Edit points",
|
|
37
59
|
textDiagram: "Text diagram",
|
|
38
60
|
documentOutline: "Document outline",
|
|
39
61
|
mindMap: "Mind map",
|
|
@@ -283,6 +305,9 @@ export const en: Messages = {
|
|
|
283
305
|
chartColumn: "Column chart",
|
|
284
306
|
chartLine: "Line chart",
|
|
285
307
|
chartPie: "Pie chart",
|
|
308
|
+
chartScatter: "Scatter chart",
|
|
309
|
+
chartRadar: "Radar chart",
|
|
310
|
+
qrCode: "QR code",
|
|
286
311
|
chartBar: "Bar chart",
|
|
287
312
|
keyboard: "Keyboard",
|
|
288
313
|
command: "Command",
|
|
@@ -349,14 +374,56 @@ export const en: Messages = {
|
|
|
349
374
|
listTodo: "To-do list",
|
|
350
375
|
listTree: "Multilevel list",
|
|
351
376
|
lineSpacing: "Line spacing",
|
|
377
|
+
lineNumbers: "Line numbers",
|
|
352
378
|
paragraph: "Paragraph mark",
|
|
353
379
|
paragraphSettings: "Paragraph settings",
|
|
354
380
|
textDirectionLtr: "Left to right",
|
|
355
381
|
textDirectionRtl: "Right to left",
|
|
382
|
+
textDirectionVertical: "Vertical text",
|
|
356
383
|
textWrap: "Word wrap",
|
|
357
384
|
wrapText: "Wrap text",
|
|
358
385
|
insert: "Insert content",
|
|
359
386
|
textBox: "Text box",
|
|
387
|
+
textBoxVertical: "Vertical text box",
|
|
388
|
+
designTheme: "Design theme",
|
|
389
|
+
shapeStyles: "Shape styles",
|
|
390
|
+
shapeEffects: "Shape effects",
|
|
391
|
+
changeShape: "Change shape",
|
|
392
|
+
gradientFill: "Gradient fill",
|
|
393
|
+
lineDash: "Line style",
|
|
394
|
+
lineWeight: "Line weight",
|
|
395
|
+
replaceImage: "Replace picture",
|
|
396
|
+
resetImage: "Reset picture",
|
|
397
|
+
cropToShape: "Crop to shape",
|
|
398
|
+
pictureStyles: "Picture styles",
|
|
399
|
+
pictureEffects: "Picture effects",
|
|
400
|
+
brightness: "Brightness",
|
|
401
|
+
contrast: "Contrast",
|
|
402
|
+
recolor: "Recolor",
|
|
403
|
+
transparency: "Transparency",
|
|
404
|
+
compressImage: "Compress pictures",
|
|
405
|
+
wordArtStyles: "WordArt styles",
|
|
406
|
+
textEffects: "Text effects",
|
|
407
|
+
characterSpacing: "Character spacing",
|
|
408
|
+
textAutoFit: "Autofit",
|
|
409
|
+
tableCellMargins: "Cell margins",
|
|
410
|
+
chartElements: "Chart elements",
|
|
411
|
+
chartQuickLayout: "Quick layout",
|
|
412
|
+
chartColors: "Change colors",
|
|
413
|
+
chartSwitchRowColumn: "Switch row/column",
|
|
414
|
+
colorScheme: "Color scheme",
|
|
415
|
+
backgroundStyle: "Background style",
|
|
416
|
+
slideSize: "Slide size",
|
|
417
|
+
slideSorter: "Slide sorter",
|
|
418
|
+
notesPage: "Notes page",
|
|
419
|
+
gridlines: "Gridlines",
|
|
420
|
+
guides: "Guides",
|
|
421
|
+
presenterView: "Presenter view",
|
|
422
|
+
laserPointer: "Laser pointer",
|
|
423
|
+
inkPen: "Pen",
|
|
424
|
+
inkHighlighter: "Highlighter",
|
|
425
|
+
eraser: "Eraser",
|
|
426
|
+
exportFile: "Export",
|
|
360
427
|
textCursor: "Text cursor",
|
|
361
428
|
textCursorInput: "Text input",
|
|
362
429
|
blockContentControl: "Block content control",
|
|
@@ -455,6 +522,23 @@ export const en: Messages = {
|
|
|
455
522
|
pipette: ["eyedropper"],
|
|
456
523
|
fontScript: ["East Asian and Latin"],
|
|
457
524
|
textDirectionLtr: ["text direction"],
|
|
458
|
-
textDirectionRtl: ["text direction"]
|
|
525
|
+
textDirectionRtl: ["text direction"],
|
|
526
|
+
textDirectionVertical: ["text direction", "vertical"],
|
|
527
|
+
textBoxVertical: ["vertical text box"],
|
|
528
|
+
textAutoFit: ["resize shape to fit text", "shrink text"],
|
|
529
|
+
designTheme: ["theme", "template"],
|
|
530
|
+
colorScheme: ["theme colors"],
|
|
531
|
+
backgroundStyle: ["background"],
|
|
532
|
+
slideSize: ["aspect ratio"],
|
|
533
|
+
slideSorter: ["thumbnails view"],
|
|
534
|
+
notesPage: ["speaker notes"],
|
|
535
|
+
gridlines: ["grid"],
|
|
536
|
+
guides: ["guide lines"],
|
|
537
|
+
presenterView: ["slide show"],
|
|
538
|
+
laserPointer: ["pointer"],
|
|
539
|
+
inkPen: ["ink"],
|
|
540
|
+
inkHighlighter: ["ink"],
|
|
541
|
+
eraser: ["erase"],
|
|
542
|
+
exportFile: ["export as PDF"]
|
|
459
543
|
}
|
|
460
544
|
};
|
|
@@ -23,9 +23,24 @@ export const zhCN: Messages = {
|
|
|
23
23
|
"table-structure": "表格 · 结构",
|
|
24
24
|
"table-style": "表格 · 边框与排列",
|
|
25
25
|
review: "修订与批注",
|
|
26
|
-
page: "页面与对象"
|
|
26
|
+
page: "页面与对象",
|
|
27
|
+
"object-tools": "对象工具",
|
|
28
|
+
presentation: "演示",
|
|
29
|
+
"mind-map": "思维导图"
|
|
27
30
|
},
|
|
28
31
|
icons: {
|
|
32
|
+
marqueeSelect: "框选",
|
|
33
|
+
mindTopic: "同级主题",
|
|
34
|
+
mindSubtopic: "子主题",
|
|
35
|
+
mindParentTopic: "父主题",
|
|
36
|
+
mindFloatingTopic: "自由主题",
|
|
37
|
+
mindRelation: "联系",
|
|
38
|
+
mindSummary: "概要",
|
|
39
|
+
mindBoundary: "外框",
|
|
40
|
+
mindLayout: "导图结构",
|
|
41
|
+
mindStyle: "主题样式",
|
|
42
|
+
mindExpandBranch: "展开分支",
|
|
43
|
+
mindCollapseBranch: "折叠分支",
|
|
29
44
|
gitBranch: "分支连接",
|
|
30
45
|
outlineColor: "轮廓颜色",
|
|
31
46
|
tableOfContents: "目录",
|
|
@@ -34,6 +49,13 @@ export const zhCN: Messages = {
|
|
|
34
49
|
shapes: "形状",
|
|
35
50
|
pencilRuler: "绘图工具",
|
|
36
51
|
whiteboard: "白板",
|
|
52
|
+
animation: "动画",
|
|
53
|
+
animationEntrance: "进入动画",
|
|
54
|
+
animationEmphasis: "强调动画",
|
|
55
|
+
animationExit: "退出动画",
|
|
56
|
+
slideTransition: "幻灯片切换",
|
|
57
|
+
freehand: "自由曲线",
|
|
58
|
+
editPoints: "编辑顶点",
|
|
37
59
|
textDiagram: "文本绘图",
|
|
38
60
|
documentOutline: "大纲",
|
|
39
61
|
mindMap: "思维导图",
|
|
@@ -283,6 +305,9 @@ export const zhCN: Messages = {
|
|
|
283
305
|
chartColumn: "柱状图",
|
|
284
306
|
chartLine: "折线图",
|
|
285
307
|
chartPie: "饼图",
|
|
308
|
+
chartScatter: "散点图",
|
|
309
|
+
chartRadar: "雷达图",
|
|
310
|
+
qrCode: "二维码",
|
|
286
311
|
chartBar: "条形图",
|
|
287
312
|
keyboard: "键盘",
|
|
288
313
|
command: "快捷命令",
|
|
@@ -349,14 +374,56 @@ export const zhCN: Messages = {
|
|
|
349
374
|
listTodo: "待办列表",
|
|
350
375
|
listTree: "多级列表",
|
|
351
376
|
lineSpacing: "行距",
|
|
377
|
+
lineNumbers: "行号",
|
|
352
378
|
paragraph: "段落标记",
|
|
353
379
|
paragraphSettings: "段落设置",
|
|
354
380
|
textDirectionLtr: "从左向右",
|
|
355
381
|
textDirectionRtl: "从右向左",
|
|
382
|
+
textDirectionVertical: "竖排文字",
|
|
356
383
|
textWrap: "自动换行",
|
|
357
384
|
wrapText: "折行",
|
|
358
385
|
insert: "插入内容",
|
|
359
386
|
textBox: "文本框",
|
|
387
|
+
textBoxVertical: "竖向文本框",
|
|
388
|
+
designTheme: "设计主题",
|
|
389
|
+
shapeStyles: "形状样式",
|
|
390
|
+
shapeEffects: "形状效果",
|
|
391
|
+
changeShape: "更改形状",
|
|
392
|
+
gradientFill: "渐变填充",
|
|
393
|
+
lineDash: "线条样式",
|
|
394
|
+
lineWeight: "线条粗细",
|
|
395
|
+
replaceImage: "替换图片",
|
|
396
|
+
resetImage: "重设图片",
|
|
397
|
+
cropToShape: "裁剪为形状",
|
|
398
|
+
pictureStyles: "图片样式",
|
|
399
|
+
pictureEffects: "图片效果",
|
|
400
|
+
brightness: "亮度",
|
|
401
|
+
contrast: "对比度",
|
|
402
|
+
recolor: "重新着色",
|
|
403
|
+
transparency: "透明度",
|
|
404
|
+
compressImage: "压缩图片",
|
|
405
|
+
wordArtStyles: "艺术字样式",
|
|
406
|
+
textEffects: "文本效果",
|
|
407
|
+
characterSpacing: "字符间距",
|
|
408
|
+
textAutoFit: "自动调整",
|
|
409
|
+
tableCellMargins: "单元格边距",
|
|
410
|
+
chartElements: "图表元素",
|
|
411
|
+
chartQuickLayout: "快速布局",
|
|
412
|
+
chartColors: "更改颜色",
|
|
413
|
+
chartSwitchRowColumn: "切换行列",
|
|
414
|
+
colorScheme: "配色方案",
|
|
415
|
+
backgroundStyle: "背景样式",
|
|
416
|
+
slideSize: "幻灯片大小",
|
|
417
|
+
slideSorter: "幻灯片浏览",
|
|
418
|
+
notesPage: "备注页",
|
|
419
|
+
gridlines: "网格线",
|
|
420
|
+
guides: "参考线",
|
|
421
|
+
presenterView: "演讲者视图",
|
|
422
|
+
laserPointer: "激光笔",
|
|
423
|
+
inkPen: "画笔",
|
|
424
|
+
inkHighlighter: "荧光笔",
|
|
425
|
+
eraser: "橡皮擦",
|
|
426
|
+
exportFile: "导出",
|
|
360
427
|
textCursor: "文本光标",
|
|
361
428
|
textCursorInput: "文本输入",
|
|
362
429
|
blockContentControl: "块内容控件",
|
|
@@ -455,6 +522,23 @@ export const zhCN: Messages = {
|
|
|
455
522
|
pipette: ["吸管"],
|
|
456
523
|
fontScript: ["中文与西文"],
|
|
457
524
|
textDirectionLtr: ["文字方向"],
|
|
458
|
-
textDirectionRtl: ["文字方向"]
|
|
525
|
+
textDirectionRtl: ["文字方向"],
|
|
526
|
+
textDirectionVertical: ["文字方向", "竖排"],
|
|
527
|
+
textBoxVertical: ["竖排文本框"],
|
|
528
|
+
textAutoFit: ["根据文字调整形状大小", "缩排文字"],
|
|
529
|
+
designTheme: ["主题", "模板"],
|
|
530
|
+
colorScheme: ["主题颜色", "配色"],
|
|
531
|
+
backgroundStyle: ["背景"],
|
|
532
|
+
slideSize: ["页面比例", "宽屏"],
|
|
533
|
+
slideSorter: ["缩略图视图"],
|
|
534
|
+
notesPage: ["演讲者备注"],
|
|
535
|
+
gridlines: ["网格"],
|
|
536
|
+
guides: ["辅助线"],
|
|
537
|
+
presenterView: ["放映"],
|
|
538
|
+
laserPointer: ["指示"],
|
|
539
|
+
inkPen: ["墨迹", "标注"],
|
|
540
|
+
inkHighlighter: ["墨迹", "标注"],
|
|
541
|
+
eraser: ["擦除"],
|
|
542
|
+
exportFile: ["导出为 PDF", "导出为图片"]
|
|
459
543
|
}
|
|
460
544
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import QuireThemePortal from "../theme-provider/portal.vue";
|
|
3
|
-
import { useAttrs, type StyleValue } from "vue";
|
|
3
|
+
import { computed, useAttrs, type StyleValue } from "vue";
|
|
4
4
|
import { Dialog, useDialogContext } from "@ark-ui/vue/dialog";
|
|
5
|
-
import type { QuireKitDialogSize } from "../../components/dialog/types";
|
|
5
|
+
import type { QuireKitDialogLength, QuireKitDialogSize } from "../../components/dialog/types";
|
|
6
6
|
import QuireIcon from "../icon/icon.vue";
|
|
7
7
|
import { useQuireKitMessages } from "../locale-provider/context";
|
|
8
8
|
|
|
@@ -14,8 +14,12 @@ interface Props {
|
|
|
14
14
|
readonly title: string;
|
|
15
15
|
/** 标题下的必要任务说明。 */
|
|
16
16
|
readonly description?: string;
|
|
17
|
-
/** small、medium、large
|
|
17
|
+
/** mini、small、medium、large 为固定宽高,max 占满视口只留四周边距,内容变化都不改变面板大小;auto 的高度随内容。 */
|
|
18
18
|
readonly size?: QuireKitDialogSize;
|
|
19
|
+
/** 自定义宽度,覆盖 size 的宽度;数字按像素。size 为 auto 且未设置时宽度随内容。 */
|
|
20
|
+
readonly width?: QuireKitDialogLength;
|
|
21
|
+
/** 自定义高度,覆盖 size 的高度;auto 表示随内容,最高不超过可用视口。 */
|
|
22
|
+
readonly height?: QuireKitDialogLength | "auto";
|
|
19
23
|
/** Portal 目标元素或选择器。 */
|
|
20
24
|
readonly portalTarget?: string | HTMLElement;
|
|
21
25
|
/** 是否把模态层传送到 Portal 目标。 */
|
|
@@ -42,7 +46,7 @@ interface Slots {
|
|
|
42
46
|
readonly footer?: () => unknown;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
withDefaults(defineProps<Props>(), {
|
|
49
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
46
50
|
as: "div",
|
|
47
51
|
size: "medium",
|
|
48
52
|
portalTarget: "body",
|
|
@@ -57,6 +61,25 @@ const attrs = useAttrs();
|
|
|
57
61
|
const text = useQuireKitMessages("dialog");
|
|
58
62
|
// Presence may retain exit frames; only the open layer may consume interaction.
|
|
59
63
|
const dialog = useDialogContext();
|
|
64
|
+
/** Size modifiers; auto dimensions fall back to the content while the viewport still caps them. */
|
|
65
|
+
const sizeClasses = computed(() => {
|
|
66
|
+
const autoHeight = props.height === "auto" || (props.size === "auto" && props.height === undefined);
|
|
67
|
+
const autoWidth = props.size === "auto" && props.width === undefined;
|
|
68
|
+
return [`qk-dialog__content--${props.size}`, autoHeight && "qk-dialog__content--auto-height", autoWidth && "qk-dialog__content--auto-width"];
|
|
69
|
+
});
|
|
70
|
+
/** Custom lengths override the preset through the variables the size recipe reads. */
|
|
71
|
+
const sizeStyle = computed(() => ({
|
|
72
|
+
...(props.width === undefined ? {} : { "--qk-dialog-width": cssLength(props.width) }),
|
|
73
|
+
...(props.height === undefined || props.height === "auto" ? {} : { "--qk-dialog-height": cssLength(props.height) })
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param value - Pixel count or CSS length.
|
|
78
|
+
* @returns CSS length.
|
|
79
|
+
*/
|
|
80
|
+
function cssLength(value: QuireKitDialogLength): string {
|
|
81
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
82
|
+
}
|
|
60
83
|
</script>
|
|
61
84
|
|
|
62
85
|
<template>
|
|
@@ -66,7 +89,8 @@ const dialog = useDialogContext();
|
|
|
66
89
|
<Dialog.Positioner :style="attrs.style as StyleValue" :inert="!dialog.open || undefined" class="qk-dialog__positioner">
|
|
67
90
|
<Dialog.Content as-child
|
|
68
91
|
v-bind="attrs"
|
|
69
|
-
:class="['qk-dialog__content',
|
|
92
|
+
:class="['qk-dialog__content', ...sizeClasses, busy && 'qk-dialog__content--busy']"
|
|
93
|
+
:style="sizeStyle"
|
|
70
94
|
:aria-busy="busy || undefined"
|
|
71
95
|
>
|
|
72
96
|
<component :is="as">
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { createApp, h, nextTick } from "vue";
|
|
3
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
4
|
+
import DialogRoot from "./root.vue";
|
|
5
|
+
import DialogContent from "./content.vue";
|
|
6
|
+
|
|
7
|
+
const cleanups: Array<() => void> = [];
|
|
8
|
+
afterEach(() => cleanups.splice(0).reverse().forEach(cleanup => cleanup()));
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Mounts an open dialog and returns its content surface.
|
|
12
|
+
* @param props - Content size props under test.
|
|
13
|
+
* @returns The rendered content element.
|
|
14
|
+
*/
|
|
15
|
+
async function render(props: Record<string, unknown>): Promise<HTMLElement> {
|
|
16
|
+
const host = document.createElement("div");
|
|
17
|
+
document.body.append(host);
|
|
18
|
+
const app = createApp({
|
|
19
|
+
render: () => h(DialogRoot, { open: true, modal: false, trapFocus: false, preventScroll: false, restoreFocus: false },
|
|
20
|
+
() => h(DialogContent, { title: "Dialog", ...props }, () => "Body"))
|
|
21
|
+
});
|
|
22
|
+
app.mount(host);
|
|
23
|
+
cleanups.push(() => { app.unmount(); host.remove(); });
|
|
24
|
+
await nextTick();
|
|
25
|
+
return document.querySelector<HTMLElement>(".qk-dialog__content")!;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("dialog size", () => {
|
|
29
|
+
it("defaults to the fixed medium preset", async () => {
|
|
30
|
+
const content = await render({});
|
|
31
|
+
expect(content.classList.contains("qk-dialog__content--medium")).toBe(true);
|
|
32
|
+
expect(content.classList.contains("qk-dialog__content--auto-height")).toBe(false);
|
|
33
|
+
expect(content.style.getPropertyValue("--qk-dialog-width")).toBe("");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("overrides preset dimensions with custom lengths", async () => {
|
|
37
|
+
const content = await render({ size: "small", width: 560, height: "70vh" });
|
|
38
|
+
expect(content.classList.contains("qk-dialog__content--small")).toBe(true);
|
|
39
|
+
expect(content.style.getPropertyValue("--qk-dialog-width")).toBe("560px");
|
|
40
|
+
expect(content.style.getPropertyValue("--qk-dialog-height")).toBe("70vh");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("lets a preset keep its width while the height follows the content", async () => {
|
|
44
|
+
const content = await render({ size: "mini", height: "auto" });
|
|
45
|
+
expect(content.classList.contains("qk-dialog__content--mini")).toBe(true);
|
|
46
|
+
expect(content.classList.contains("qk-dialog__content--auto-height")).toBe(true);
|
|
47
|
+
expect(content.style.getPropertyValue("--qk-dialog-height")).toBe("");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("sizes auto dialogs by their content unless a dimension is given", async () => {
|
|
51
|
+
const free = await render({ size: "auto" });
|
|
52
|
+
expect(free.classList.contains("qk-dialog__content--auto-width")).toBe(true);
|
|
53
|
+
expect(free.classList.contains("qk-dialog__content--auto-height")).toBe(true);
|
|
54
|
+
cleanups.splice(0).reverse().forEach(cleanup => cleanup());
|
|
55
|
+
|
|
56
|
+
const wide = await render({ size: "auto", width: 520 });
|
|
57
|
+
expect(wide.classList.contains("qk-dialog__content--auto-width")).toBe(false);
|
|
58
|
+
expect(wide.classList.contains("qk-dialog__content--auto-height")).toBe(true);
|
|
59
|
+
expect(wide.style.getPropertyValue("--qk-dialog-width")).toBe("520px");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -51,3 +51,13 @@ it('syncs the thumb once per frame without re-rendering slot content or writing
|
|
|
51
51
|
app.unmount(); host.remove();
|
|
52
52
|
globalThis.ResizeObserver = NativeObserver; globalThis.requestAnimationFrame = nativeFrame;
|
|
53
53
|
});
|
|
54
|
+
|
|
55
|
+
it('lets vertical content take the viewport width, so long rows truncate instead of being clipped', () => {
|
|
56
|
+
const host = document.createElement('div'); document.body.append(host);
|
|
57
|
+
const app = createApp({ render: () => [h(ScrollArea, { label: '纵向' }, () => '正文'), h(ScrollArea, { label: '横向', axis: 'horizontal' }, () => '正文')] });
|
|
58
|
+
app.mount(host);
|
|
59
|
+
const [vertical, horizontal] = [...host.querySelectorAll<HTMLElement>('.qk-scroll-area__content')];
|
|
60
|
+
expect(vertical!.style.minWidth).toBe('');
|
|
61
|
+
expect(horizontal!.style.minWidth).toBe('fit-content');
|
|
62
|
+
app.unmount(); host.remove();
|
|
63
|
+
});
|
|
@@ -142,7 +142,7 @@ defineExpose<Exposed>({ scrollTo, scrollToEdge, getViewportElement });
|
|
|
142
142
|
style="overflow: auto"
|
|
143
143
|
@scroll.passive="handleScroll"
|
|
144
144
|
>
|
|
145
|
-
<div ref="content" data-scope="scroll-area" data-part="content" role="presentation" :class="['qk-scroll-area__content', contentClass]" style="
|
|
145
|
+
<div ref="content" data-scope="scroll-area" data-part="content" role="presentation" :class="['qk-scroll-area__content', contentClass]" :style="axis === 'vertical' ? undefined : { minWidth: 'fit-content' }">
|
|
146
146
|
<slot />
|
|
147
147
|
</div>
|
|
148
148
|
</div>
|
|
@@ -76,3 +76,21 @@ describe("Select visibility and portal attributes", () => {
|
|
|
76
76
|
expect(trigger.getAttribute("aria-expanded")).toBe("false");
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
|
+
|
|
80
|
+
describe("Select leading content", () => {
|
|
81
|
+
it("places leading content before the value text and keeps it out of the accessible name", async () => {
|
|
82
|
+
const host = document.createElement("div");
|
|
83
|
+
document.body.append(host);
|
|
84
|
+
const app = createApp({
|
|
85
|
+
setup: () => () => h(Select, { label: "Provider", modelValue: "a", items: [{ label: "Alpha", value: "a" }], portalled: false },
|
|
86
|
+
{ leading: () => h("img", { class: "logo", alt: "" }) })
|
|
87
|
+
});
|
|
88
|
+
app.mount(host);
|
|
89
|
+
cleanups.push(() => { app.unmount(); host.remove(); });
|
|
90
|
+
await nextTick();
|
|
91
|
+
const leading = host.querySelector(".qk-select__leading")!;
|
|
92
|
+
expect(leading.getAttribute("aria-hidden")).toBe("true");
|
|
93
|
+
expect(leading.querySelector(".logo")).not.toBeNull();
|
|
94
|
+
expect(leading.nextElementSibling?.classList.contains("qk-select__value")).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -81,6 +81,8 @@ interface ItemSlotProps {
|
|
|
81
81
|
interface Slots {
|
|
82
82
|
/** 替换选项的可见内容,保留可访问名称。 */
|
|
83
83
|
readonly item?: (props: ItemSlotProps) => unknown;
|
|
84
|
+
/** 触发器中值文字前的内容,例如所选项的图标。 */
|
|
85
|
+
readonly leading?: () => unknown;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
const portal = useQuireOverlayHost();
|
|
@@ -185,6 +187,7 @@ function updateValue(values: string[]): void {
|
|
|
185
187
|
style="width: 100%"
|
|
186
188
|
:class="['qk-select__trigger', `qk-select__trigger--${size}`]"
|
|
187
189
|
>
|
|
190
|
+
<span v-if="$slots.leading" class="qk-select__leading" aria-hidden="true"><slot name="leading" /></span>
|
|
188
191
|
<Select.ValueText :placeholder="placeholder ?? text.placeholder" class="qk-select__value" />
|
|
189
192
|
<Select.Indicator class="qk-select__indicator">
|
|
190
193
|
<QuireIcon name="chevronDown" :size="16" />
|
|
@@ -50,3 +50,16 @@ describe("Slider native form state", () => {
|
|
|
50
50
|
expect(new FormData(form).getAll("pages[]")).toEqual(["20", "80"]);
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
describe("Slider label", () => {
|
|
55
|
+
it("keeps a hidden label as the thumb's name and drops the header row when nothing in it shows", async () => {
|
|
56
|
+
const host = document.createElement("div");
|
|
57
|
+
document.body.append(host);
|
|
58
|
+
const app = createApp(defineComponent({ setup: () => () => h(Slider, { label: "Duration", hideLabel: true, showValue: false, modelValue: [1] }) }));
|
|
59
|
+
app.mount(host);
|
|
60
|
+
cleanups.push(() => { app.unmount(); host.remove(); });
|
|
61
|
+
await nextTick();
|
|
62
|
+
expect(host.querySelector(".qk-slider__header")).toBeNull();
|
|
63
|
+
expect(host.querySelector("[role=slider]")?.getAttribute("aria-label")).toBe("Duration");
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -27,6 +27,8 @@ interface Props {
|
|
|
27
27
|
readonly origin?: QuireKitSliderOrigin;
|
|
28
28
|
/** 是否显示当前值文字。 */
|
|
29
29
|
readonly showValue?: boolean;
|
|
30
|
+
/** 只为辅助技术保留名称,不显示标签;外层已有字段名时使用。 */
|
|
31
|
+
readonly hideLabel?: boolean;
|
|
30
32
|
/** 当前值之后显示的单位。 */
|
|
31
33
|
readonly unit?: string;
|
|
32
34
|
/** 原生表单字段名。 */
|
|
@@ -90,8 +92,8 @@ function updateValues(nextValues: number[]): void {
|
|
|
90
92
|
:class="['qk-slider', `qk-slider--${orientation}`]"
|
|
91
93
|
@update:model-value="updateValues"
|
|
92
94
|
>
|
|
93
|
-
<div class="qk-slider__header">
|
|
94
|
-
<span class="qk-slider__label">{{ label }}</span>
|
|
95
|
+
<div v-if="!hideLabel || showValue" class="qk-slider__header">
|
|
96
|
+
<span :class="['qk-slider__label', hideLabel && 'sr-only']">{{ label }}</span>
|
|
95
97
|
<Slider.ValueText v-if="showValue" class="qk-slider__value">
|
|
96
98
|
{{ currentValues.join(" – ") }}{{ unit }}
|
|
97
99
|
</Slider.ValueText>
|
|
@@ -32,7 +32,7 @@ interface Props {
|
|
|
32
32
|
readonly handleVariant?: QuireKitSplitterHandleVariant;
|
|
33
33
|
/** 是否禁止全部调整柄交互。 */
|
|
34
34
|
readonly disabled?: boolean;
|
|
35
|
-
/**
|
|
35
|
+
/** 是否绘制外框、圆角与底色;作为应用外壳铺满窗口时关闭,面板外观由内容决定。 */
|
|
36
36
|
readonly bordered?: boolean;
|
|
37
37
|
/** Splitter 的可访问名称。 */
|
|
38
38
|
readonly label: string;
|
|
@@ -4,6 +4,7 @@ import type { QuireKitToolbarRendererScope, QuireKitToolbarRenderers } from "./t
|
|
|
4
4
|
import ToolbarItems from "./items.vue";
|
|
5
5
|
import QuireToolbarGroup from "../toolbar-group.vue";
|
|
6
6
|
import { toolbarCollapseKey } from "../collapse/units";
|
|
7
|
+
import { entryMemo, entryReadsContext } from "./memo";
|
|
7
8
|
|
|
8
9
|
defineProps<{
|
|
9
10
|
/** Legacy single-row contributions. */
|
|
@@ -33,9 +34,10 @@ const emit = defineEmits<{
|
|
|
33
34
|
|
|
34
35
|
<template>
|
|
35
36
|
<!-- One keyed anatomy retains open/focused controls across overflow modes.
|
|
36
|
-
Only collapse wrappers create boxes; other single-row modes flatten them.
|
|
37
|
+
Only collapse wrappers create boxes; other single-row modes flatten them.
|
|
38
|
+
v-memo skips entries the host kept by identity, so a change to a few entries patches only those. -->
|
|
37
39
|
<template v-if="rows === undefined">
|
|
38
|
-
<template v-for="item in (items ?? []).filter(entry => !entry.hidden)" :key="item.value">
|
|
40
|
+
<template v-for="item in (items ?? []).filter(entry => !entry.hidden)" :key="item.value" v-memo="entryMemo(item, context, [units, renderers, $slots.item, $slots.content])">
|
|
39
41
|
<QuireToolbarGroup v-if="item.kind === 'group'" :label="item.label">
|
|
40
42
|
<div v-for="child in (item.children ?? []).filter(entry => !entry.hidden)" :key="child.value" :class="units ? 'qk-toolbar__unit' : undefined" :style="units ? undefined : { display: 'contents' }" :data-qk-toolbar-unit="units ? toolbarCollapseKey(item, child) : undefined">
|
|
41
43
|
<ToolbarItems :items="[child]" :path="[item.value]" :disabled="!!item.disabled" :context="context" :renderers="renderers"
|
|
@@ -54,7 +56,7 @@ const emit = defineEmits<{
|
|
|
54
56
|
</div>
|
|
55
57
|
</template>
|
|
56
58
|
</template>
|
|
57
|
-
<template v-else v-for="row in rows" :key="row.value">
|
|
59
|
+
<template v-else v-for="row in rows" :key="row.value" v-memo="[row, row.items.some(entryReadsContext) ? context : undefined, renderers, $slots.item, $slots.content]">
|
|
58
60
|
<div v-if="!row.hidden && row.items.some(item => !item.hidden)" role="group" :aria-label="row.label" :data-qk-toolbar-row="row.value" class="qk-toolbar__row">
|
|
59
61
|
<ToolbarItems :items="row.items" :path="[row.value]" :disabled="row.disabled ?? false" :context="context" :renderers="renderers"
|
|
60
62
|
@execute="emit('execute', $event)" @open-change="emit('openChange', $event)">
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { createApp, defineComponent, h, nextTick, shallowRef } from "vue";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import type { QuireKitToolbarEntry } from "../../../components/toolbar/types";
|
|
5
|
+
import Toolbar from "../toolbar.vue";
|
|
6
|
+
import { entryReadsContext } from "./memo";
|
|
7
|
+
|
|
8
|
+
it("knows which entries read the host context", () => {
|
|
9
|
+
expect(entryReadsContext({ value: "cut", label: "Cut" })).toBe(false);
|
|
10
|
+
expect(entryReadsContext({ value: "bold", label: "Bold", kind: "toggle" })).toBe(false);
|
|
11
|
+
expect(entryReadsContext({ value: "size", label: "Size", kind: "custom", renderer: "size" })).toBe(true);
|
|
12
|
+
expect(entryReadsContext({ value: "font", label: "Font", kind: "group", children: [{ value: "cut", label: "Cut" }, { value: "color", label: "Color", kind: "split" }] })).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("patches only the entries that changed or read a changed context", async () => {
|
|
16
|
+
const host = document.createElement("div");
|
|
17
|
+
document.body.append(host);
|
|
18
|
+
const draws: string[] = [];
|
|
19
|
+
const Size = defineComponent({
|
|
20
|
+
props: { scope: { type: Object, required: true } },
|
|
21
|
+
setup: props => () => { draws.push("size"); return h("span", { "data-size": String((props.scope as { context: { size: number } }).context.size) }); }
|
|
22
|
+
});
|
|
23
|
+
const cut: QuireKitToolbarEntry = { value: "cut", label: "Cut" };
|
|
24
|
+
const size: QuireKitToolbarEntry = { value: "size", label: "Size", kind: "custom", renderer: "size" };
|
|
25
|
+
const items = shallowRef<QuireKitToolbarEntry[]>([cut, size, { value: "bold", label: "Bold", kind: "toggle", pressed: false }]);
|
|
26
|
+
const context = shallowRef({ size: 12 });
|
|
27
|
+
const renderers = { size: Size };
|
|
28
|
+
const app = createApp({ render: () => h(Toolbar, { label: "Format", items: items.value, context: context.value, renderers }) });
|
|
29
|
+
try {
|
|
30
|
+
app.mount(host);
|
|
31
|
+
await nextTick();
|
|
32
|
+
draws.length = 0;
|
|
33
|
+
// Only the toggle is a new entry: the custom control is not drawn again.
|
|
34
|
+
items.value = [cut, size, { value: "bold", label: "Bold", kind: "toggle", pressed: true }];
|
|
35
|
+
await nextTick();
|
|
36
|
+
expect(host.querySelector("[aria-pressed]")?.getAttribute("aria-pressed")).toBe("true");
|
|
37
|
+
expect(draws).toEqual([]);
|
|
38
|
+
// A new context reaches the custom control, which reads it.
|
|
39
|
+
context.value = { size: 14 };
|
|
40
|
+
await nextTick();
|
|
41
|
+
expect(draws).toEqual(["size"]);
|
|
42
|
+
expect(host.querySelector("[data-size]")?.getAttribute("data-size")).toBe("14");
|
|
43
|
+
// Entries rebuilt by the host are drawn again, as before.
|
|
44
|
+
items.value = [{ ...cut, disabled: true }, { ...size }, items.value[2]!];
|
|
45
|
+
await nextTick();
|
|
46
|
+
expect(draws).toEqual(["size", "size"]);
|
|
47
|
+
expect(host.querySelector("button")?.getAttribute("aria-disabled") ?? String(host.querySelector("button")?.disabled)).toMatch(/true/u);
|
|
48
|
+
} finally { app.unmount(); host.remove(); }
|
|
49
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { QuireKitToolbarEntry } from "../../../components/toolbar/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether an entry hands the host context to what it draws: custom renderers and popup bodies receive it in their
|
|
5
|
+
* scope, while plain actions, toggles and separators draw from the entry alone.
|
|
6
|
+
* @param entry - Configured entry.
|
|
7
|
+
* @returns Whether the entry, or one of its group children, reads the context.
|
|
8
|
+
*/
|
|
9
|
+
export function entryReadsContext(entry: QuireKitToolbarEntry): boolean {
|
|
10
|
+
if (entry.kind === "group") return (entry.children ?? []).some(entryReadsContext);
|
|
11
|
+
return entry.kind !== undefined && entry.kind !== "action" && entry.kind !== "toggle" && entry.kind !== "separator";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* What one top-level entry's rendering depends on, for `v-memo`: an entry the host kept by identity is not patched
|
|
16
|
+
* again when other entries or a context it does not read change.
|
|
17
|
+
* @param entry - Configured entry.
|
|
18
|
+
* @param context - Host context.
|
|
19
|
+
* @param shared - Values every entry depends on, such as renderers, slots and layout mode.
|
|
20
|
+
* @returns Memo dependencies.
|
|
21
|
+
*/
|
|
22
|
+
export function entryMemo(entry: QuireKitToolbarEntry, context: unknown, shared: readonly unknown[]): unknown[] {
|
|
23
|
+
return [entry, entryReadsContext(entry) ? context : undefined, ...shared];
|
|
24
|
+
}
|
|
@@ -37,6 +37,8 @@ it("keeps optional primary toggle state separate from disclosure and single exec
|
|
|
37
37
|
await nextTick();
|
|
38
38
|
expect(primary.getAttribute("aria-pressed")).toBe(String(pressed));
|
|
39
39
|
expect(disclosure.hasAttribute("aria-pressed")).toBe(false);
|
|
40
|
+
// The whole button shows the pressed state, not only its action half.
|
|
41
|
+
expect(primary.closest(".qk-toolbar__split")!.hasAttribute("data-pressed")).toBe(pressed !== false);
|
|
40
42
|
}
|
|
41
43
|
primary.focus();
|
|
42
44
|
primary.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowRight", bubbles: true }));
|
|
@@ -141,6 +141,7 @@ function handleDisclosure(next: boolean): void {
|
|
|
141
141
|
role="group"
|
|
142
142
|
:aria-label="label"
|
|
143
143
|
:data-state="expanded ? 'open' : 'closed'"
|
|
144
|
+
:data-pressed="pressed === true || pressed === 'mixed' ? '' : undefined"
|
|
144
145
|
class="qk-toolbar__split"
|
|
145
146
|
data-kind="split-button"
|
|
146
147
|
>
|