@geektr.cloud/acrux-ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +21 -2
- package/package.json +70 -3
- package/src/components/acrux-ui/actions/ConfirmPopover.vue +107 -0
- package/src/components/acrux-ui/actions/FormShell.vue +96 -0
- package/src/components/acrux-ui/actions/RemovalButton.vue +65 -0
- package/src/components/acrux-ui/actions/Stepper.vue +116 -0
- package/src/components/acrux-ui/actions/form.ts +36 -0
- package/src/components/acrux-ui/actions/index.ts +70 -0
- package/src/components/acrux-ui/actions/stepper.ts +65 -0
- package/src/components/acrux-ui/actions/utils.ts +138 -0
- package/src/components/acrux-ui/base/CopyBtn.vue +85 -0
- package/src/components/acrux-ui/base/EmptyValue.vue +25 -0
- package/src/components/acrux-ui/base/Icon.vue +44 -0
- package/src/components/acrux-ui/base/IconBtn.vue +51 -0
- package/src/components/acrux-ui/base/Text.vue +85 -0
- package/src/components/acrux-ui/base/VSeparator.vue +21 -0
- package/src/components/acrux-ui/base/async.ts +35 -0
- package/src/components/acrux-ui/base/index.ts +7 -0
- package/src/components/acrux-ui/display/AsyncError.vue +46 -0
- package/src/components/acrux-ui/display/CodeBlock.vue +91 -0
- package/src/components/acrux-ui/display/CopyTag.vue +51 -0
- package/src/components/acrux-ui/display/DataView.ts +47 -0
- package/src/components/acrux-ui/display/DateFormatter.vue +61 -0
- package/src/components/acrux-ui/display/Disclosure.vue +45 -0
- package/src/components/acrux-ui/display/Link.vue +81 -0
- package/src/components/acrux-ui/display/MultiLine.vue +29 -0
- package/src/components/acrux-ui/display/Notice.vue +71 -0
- package/src/components/acrux-ui/display/Pem.vue +165 -0
- package/src/components/acrux-ui/display/QrBtn.vue +117 -0
- package/src/components/acrux-ui/display/QrModal.vue +76 -0
- package/src/components/acrux-ui/display/Route.vue +52 -0
- package/src/components/acrux-ui/display/Token.vue +106 -0
- package/src/components/acrux-ui/display/UUID.vue +46 -0
- package/src/components/acrux-ui/display/index.ts +17 -0
- package/src/components/acrux-ui/display/pem.ts +100 -0
- package/src/components/acrux-ui/display/qr.ts +20 -0
- package/src/components/acrux-ui/fields/EntitySelect.vue +253 -0
- package/src/components/acrux-ui/fields/FieldError.vue +11 -0
- package/src/components/acrux-ui/fields/JsonTextArea.vue +105 -0
- package/src/components/acrux-ui/fields/MultiLineInput.vue +145 -0
- package/src/components/acrux-ui/fields/Select.vue +106 -0
- package/src/components/acrux-ui/fields/fieldAccessibility.ts +38 -0
- package/src/components/acrux-ui/fields/index.ts +4 -0
- package/src/components/acrux-ui/page/BackButton.vue +70 -0
- package/src/components/acrux-ui/page/PageDetail.vue +125 -0
- package/src/components/acrux-ui/page/PageEntry.vue +130 -0
- package/src/components/acrux-ui/page/PageState.vue +108 -0
- package/src/components/acrux-ui/page/index.ts +3 -0
- package/src/components/acrux-ui/page/pageState.ts +18 -0
- package/src/components/ui/alert/Alert.vue +17 -0
- package/src/components/ui/alert/AlertAction.vue +17 -0
- package/src/components/ui/alert/AlertDescription.vue +22 -0
- package/src/components/ui/alert/AlertTitle.vue +22 -0
- package/src/components/ui/alert/index.ts +25 -0
- package/src/components/ui/badge/Badge.vue +29 -0
- package/src/components/ui/badge/index.ts +25 -0
- package/src/components/ui/button/Button.vue +31 -0
- package/src/components/ui/button/index.ts +39 -0
- package/src/components/ui/card/Card.vue +29 -0
- package/src/components/ui/card/CardAction.vue +17 -0
- package/src/components/ui/card/CardContent.vue +14 -0
- package/src/components/ui/card/CardDescription.vue +14 -0
- package/src/components/ui/card/CardFooter.vue +17 -0
- package/src/components/ui/card/CardHeader.vue +22 -0
- package/src/components/ui/card/CardTitle.vue +14 -0
- package/src/components/ui/card/index.ts +7 -0
- package/src/components/ui/collapsible/Collapsible.vue +15 -0
- package/src/components/ui/collapsible/CollapsibleContent.vue +12 -0
- package/src/components/ui/collapsible/CollapsibleTrigger.vue +12 -0
- package/src/components/ui/collapsible/index.ts +3 -0
- package/src/components/ui/combobox/Combobox.vue +15 -0
- package/src/components/ui/combobox/ComboboxAnchor.vue +19 -0
- package/src/components/ui/combobox/ComboboxEmpty.vue +26 -0
- package/src/components/ui/combobox/ComboboxInput.vue +40 -0
- package/src/components/ui/combobox/ComboboxItem.vue +29 -0
- package/src/components/ui/combobox/ComboboxList.vue +38 -0
- package/src/components/ui/combobox/ComboboxViewport.vue +28 -0
- package/src/components/ui/combobox/index.ts +9 -0
- package/src/components/ui/empty/Empty.vue +22 -0
- package/src/components/ui/empty/EmptyContent.vue +17 -0
- package/src/components/ui/empty/EmptyDescription.vue +22 -0
- package/src/components/ui/empty/EmptyHeader.vue +14 -0
- package/src/components/ui/empty/EmptyMedia.vue +22 -0
- package/src/components/ui/empty/EmptyTitle.vue +14 -0
- package/src/components/ui/empty/index.ts +26 -0
- package/src/components/ui/field/Field.vue +27 -0
- package/src/components/ui/field/FieldContent.vue +17 -0
- package/src/components/ui/field/FieldDescription.vue +24 -0
- package/src/components/ui/field/FieldError.vue +50 -0
- package/src/components/ui/field/FieldGroup.vue +22 -0
- package/src/components/ui/field/FieldLabel.vue +24 -0
- package/src/components/ui/field/FieldLegend.vue +24 -0
- package/src/components/ui/field/FieldSeparator.vue +26 -0
- package/src/components/ui/field/FieldSet.vue +22 -0
- package/src/components/ui/field/FieldTitle.vue +22 -0
- package/src/components/ui/field/index.ts +30 -0
- package/src/components/ui/input/Input.vue +33 -0
- package/src/components/ui/input/index.ts +1 -0
- package/src/components/ui/input-group/InputGroup.vue +23 -0
- package/src/components/ui/input-group/InputGroupAddon.vue +39 -0
- package/src/components/ui/input-group/InputGroupButton.vue +22 -0
- package/src/components/ui/input-group/InputGroupInput.vue +21 -0
- package/src/components/ui/input-group/InputGroupText.vue +21 -0
- package/src/components/ui/input-group/InputGroupTextarea.vue +21 -0
- package/src/components/ui/input-group/index.ts +53 -0
- package/src/components/ui/label/Label.vue +26 -0
- package/src/components/ui/label/index.ts +1 -0
- package/src/components/ui/popover/Popover.vue +15 -0
- package/src/components/ui/popover/PopoverAnchor.vue +12 -0
- package/src/components/ui/popover/PopoverContent.vue +38 -0
- package/src/components/ui/popover/PopoverDescription.vue +14 -0
- package/src/components/ui/popover/PopoverHeader.vue +14 -0
- package/src/components/ui/popover/PopoverTitle.vue +14 -0
- package/src/components/ui/popover/PopoverTrigger.vue +12 -0
- package/src/components/ui/popover/index.ts +7 -0
- package/src/components/ui/select/Select.vue +15 -0
- package/src/components/ui/select/SelectContent.vue +53 -0
- package/src/components/ui/select/SelectGroup.vue +17 -0
- package/src/components/ui/select/SelectItem.vue +40 -0
- package/src/components/ui/select/SelectItemText.vue +12 -0
- package/src/components/ui/select/SelectLabel.vue +14 -0
- package/src/components/ui/select/SelectScrollDownButton.vue +32 -0
- package/src/components/ui/select/SelectScrollUpButton.vue +32 -0
- package/src/components/ui/select/SelectSeparator.vue +19 -0
- package/src/components/ui/select/SelectTrigger.vue +36 -0
- package/src/components/ui/select/SelectValue.vue +12 -0
- package/src/components/ui/select/index.ts +11 -0
- package/src/components/ui/separator/Separator.vue +27 -0
- package/src/components/ui/separator/index.ts +1 -0
- package/src/components/ui/skeleton/Skeleton.vue +14 -0
- package/src/components/ui/skeleton/index.ts +1 -0
- package/src/components/ui/spinner/Spinner.vue +14 -0
- package/src/components/ui/spinner/index.ts +1 -0
- package/src/components/ui/switch/Switch.vue +47 -0
- package/src/components/ui/switch/index.ts +1 -0
- package/src/components/ui/table/Table.vue +24 -0
- package/src/components/ui/table/TableBody.vue +14 -0
- package/src/components/ui/table/TableCaption.vue +14 -0
- package/src/components/ui/table/TableCell.vue +17 -0
- package/src/components/ui/table/TableEmpty.vue +32 -0
- package/src/components/ui/table/TableFooter.vue +14 -0
- package/src/components/ui/table/TableHead.vue +29 -0
- package/src/components/ui/table/TableHeader.vue +14 -0
- package/src/components/ui/table/TableRow.vue +22 -0
- package/src/components/ui/table/index.ts +9 -0
- package/src/components/ui/tags-input/TagsInput.vue +31 -0
- package/src/components/ui/tags-input/TagsInputInput.vue +20 -0
- package/src/components/ui/tags-input/TagsInputItem.vue +28 -0
- package/src/components/ui/tags-input/TagsInputItemDelete.vue +23 -0
- package/src/components/ui/tags-input/TagsInputItemText.vue +17 -0
- package/src/components/ui/tags-input/index.ts +5 -0
- package/src/components/ui/textarea/Textarea.vue +33 -0
- package/src/components/ui/textarea/index.ts +1 -0
- package/src/index.ts +5 -0
- package/src/testing/renderer.ts +99 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Component } from "vue";
|
|
2
|
+
import { createRenderer, nextTick, ssrContextKey } from "vue";
|
|
3
|
+
|
|
4
|
+
export interface TestNode {
|
|
5
|
+
type: string;
|
|
6
|
+
text: string;
|
|
7
|
+
props: Record<string, unknown>;
|
|
8
|
+
children: TestNode[];
|
|
9
|
+
parent: TestNode | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const createNode = (type: string, text = ""): TestNode => ({ type, text, props: {}, children: [], parent: null });
|
|
13
|
+
|
|
14
|
+
const remove = (child: TestNode) => {
|
|
15
|
+
const parent = child.parent;
|
|
16
|
+
if (!parent) return;
|
|
17
|
+
const index = parent.children.indexOf(child);
|
|
18
|
+
if (index >= 0) parent.children.splice(index, 1);
|
|
19
|
+
child.parent = null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const renderer = createRenderer<TestNode, TestNode>({
|
|
23
|
+
patchProp(element, key, _previous, next) {
|
|
24
|
+
if (next === undefined || next === null) delete element.props[key];
|
|
25
|
+
else element.props[key] = next;
|
|
26
|
+
},
|
|
27
|
+
insert(child, parent, anchor) {
|
|
28
|
+
remove(child);
|
|
29
|
+
child.parent = parent;
|
|
30
|
+
if (anchor) {
|
|
31
|
+
const index = parent.children.indexOf(anchor);
|
|
32
|
+
parent.children.splice(index < 0 ? parent.children.length : index, 0, child);
|
|
33
|
+
} else {
|
|
34
|
+
parent.children.push(child);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
remove,
|
|
38
|
+
createElement: (type) => createNode(type),
|
|
39
|
+
createText: (text) => createNode("#text", text),
|
|
40
|
+
createComment: (text) => createNode("#comment", text),
|
|
41
|
+
setText(node, text) {
|
|
42
|
+
node.text = text;
|
|
43
|
+
},
|
|
44
|
+
setElementText(element, text) {
|
|
45
|
+
for (const child of element.children) child.parent = null;
|
|
46
|
+
element.children = [];
|
|
47
|
+
if (!text) return;
|
|
48
|
+
const child = createNode("#text", text);
|
|
49
|
+
child.parent = element;
|
|
50
|
+
element.children.push(child);
|
|
51
|
+
},
|
|
52
|
+
parentNode: (node) => node.parent,
|
|
53
|
+
nextSibling(node) {
|
|
54
|
+
if (!node.parent) return null;
|
|
55
|
+
const index = node.parent.children.indexOf(node);
|
|
56
|
+
return node.parent.children[index + 1] ?? null;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export const mountTestComponent = (component: Component, props: Record<string, unknown> = {}) => {
|
|
61
|
+
const root = createNode("root");
|
|
62
|
+
const app = renderer.createApp(component, props);
|
|
63
|
+
// Vitest 以 SSR 模式转换 SFC;client renderer 仍需最小 modules context。
|
|
64
|
+
app.provide(ssrContextKey, { modules: new Set<string>() });
|
|
65
|
+
app.mount(root);
|
|
66
|
+
return { app, root };
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const flushTestRender = async () => {
|
|
70
|
+
for (let index = 0; index < 5; index += 1) {
|
|
71
|
+
await Promise.resolve();
|
|
72
|
+
await nextTick();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const testText = (node: TestNode): string => {
|
|
77
|
+
if (node.type === "#text") return node.text;
|
|
78
|
+
return node.children.map(testText).join("");
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const findTestNodes = (node: TestNode, predicate: (candidate: TestNode) => boolean): TestNode[] => [
|
|
82
|
+
...(predicate(node) ? [node] : []),
|
|
83
|
+
...node.children.flatMap((child) => findTestNodes(child, predicate)),
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
export const findTestButton = (root: TestNode, label: string) => {
|
|
87
|
+
const button = findTestNodes(root, (node) => node.type === "button" && testText(node).includes(label))[0];
|
|
88
|
+
if (!button) throw new Error(`Button not found: ${label}`);
|
|
89
|
+
return button;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const clickTestNode = async (node: TestNode) => {
|
|
93
|
+
const handler = node.props.onClick;
|
|
94
|
+
const handlers = Array.isArray(handler) ? handler : [handler];
|
|
95
|
+
for (const callback of handlers) {
|
|
96
|
+
if (typeof callback === "function") await callback({});
|
|
97
|
+
}
|
|
98
|
+
await flushTestRender();
|
|
99
|
+
};
|