@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,130 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { computed, getCurrentInstance, useAttrs } from "vue";
|
|
4
|
+
import { Plus, RotateCcw } from "@lucide/vue";
|
|
5
|
+
import { cn } from "cn";
|
|
6
|
+
import { Button } from "../../ui/button";
|
|
7
|
+
import { Text } from "../base";
|
|
8
|
+
import PageState from "./PageState.vue";
|
|
9
|
+
import { hasPageListener } from "./pageState";
|
|
10
|
+
|
|
11
|
+
defineOptions({ inheritAttrs: false });
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(
|
|
14
|
+
defineProps<{
|
|
15
|
+
title: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
error?: unknown;
|
|
19
|
+
items?: unknown[] | null;
|
|
20
|
+
class?: HTMLAttributes["class"];
|
|
21
|
+
createLabel?: string;
|
|
22
|
+
refreshLabel?: string;
|
|
23
|
+
retryLabel?: string;
|
|
24
|
+
loadingLabel?: string;
|
|
25
|
+
emptyTitle?: string;
|
|
26
|
+
emptyDescription?: string;
|
|
27
|
+
errorTitle?: string;
|
|
28
|
+
}>(),
|
|
29
|
+
{
|
|
30
|
+
description: undefined,
|
|
31
|
+
loading: false,
|
|
32
|
+
error: undefined,
|
|
33
|
+
items: undefined,
|
|
34
|
+
class: undefined,
|
|
35
|
+
createLabel: "新建",
|
|
36
|
+
refreshLabel: "刷新",
|
|
37
|
+
retryLabel: "重试",
|
|
38
|
+
loadingLabel: "加载中",
|
|
39
|
+
emptyTitle: "暂无数据",
|
|
40
|
+
emptyDescription: undefined,
|
|
41
|
+
errorTitle: "获取失败",
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const emit = defineEmits<{
|
|
46
|
+
create: [];
|
|
47
|
+
retry: [];
|
|
48
|
+
}>();
|
|
49
|
+
|
|
50
|
+
const attrs = useAttrs();
|
|
51
|
+
const instance = getCurrentInstance();
|
|
52
|
+
|
|
53
|
+
const hasError = computed(() => Boolean(props.error));
|
|
54
|
+
const isEmpty = computed(() => props.items?.length === 0);
|
|
55
|
+
const hasCreate = () => hasPageListener(instance, "create");
|
|
56
|
+
const hasRetry = () => hasPageListener(instance, "retry");
|
|
57
|
+
const stateListeners = () => ({
|
|
58
|
+
onCreate: hasCreate() ? () => emit("create") : undefined,
|
|
59
|
+
onRetry: hasRetry() ? () => emit("retry") : undefined,
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template>
|
|
64
|
+
<section
|
|
65
|
+
v-bind="attrs"
|
|
66
|
+
data-slot="page-entry"
|
|
67
|
+
:aria-busy="loading ? 'true' : undefined"
|
|
68
|
+
:class="cn('mx-auto flex w-full min-w-0 max-w-5xl flex-col gap-4 px-4 py-8', props.class)"
|
|
69
|
+
>
|
|
70
|
+
<header data-slot="page-entry-header" class="flex flex-wrap items-start justify-between gap-x-4 gap-y-2">
|
|
71
|
+
<div class="min-w-0 flex-1">
|
|
72
|
+
<Text variant="h1" class="break-words">{{ title }}</Text>
|
|
73
|
+
<Text v-if="description" variant="lead" class="mt-1 break-words">
|
|
74
|
+
{{ description }}
|
|
75
|
+
</Text>
|
|
76
|
+
</div>
|
|
77
|
+
<div
|
|
78
|
+
v-if="$slots.actions || hasCreate() || (hasRetry() && !loading && !hasError)"
|
|
79
|
+
class="flex min-w-0 flex-wrap items-center justify-end gap-2"
|
|
80
|
+
>
|
|
81
|
+
<slot name="actions" />
|
|
82
|
+
<span
|
|
83
|
+
v-if="$slots.actions && (hasCreate() || (hasRetry() && !loading && !hasError))"
|
|
84
|
+
class="mx-1 h-6 w-px bg-border"
|
|
85
|
+
aria-hidden="true"
|
|
86
|
+
/>
|
|
87
|
+
<Button
|
|
88
|
+
v-if="hasRetry() && !loading && !hasError"
|
|
89
|
+
variant="secondary"
|
|
90
|
+
size="icon"
|
|
91
|
+
:aria-label="refreshLabel"
|
|
92
|
+
:title="refreshLabel"
|
|
93
|
+
@click="emit('retry')"
|
|
94
|
+
>
|
|
95
|
+
<RotateCcw aria-hidden="true" />
|
|
96
|
+
</Button>
|
|
97
|
+
<Button v-if="hasCreate()" size="icon" :aria-label="createLabel" :title="createLabel" @click="emit('create')">
|
|
98
|
+
<Plus aria-hidden="true" />
|
|
99
|
+
</Button>
|
|
100
|
+
</div>
|
|
101
|
+
</header>
|
|
102
|
+
|
|
103
|
+
<slot name="toolbar" />
|
|
104
|
+
|
|
105
|
+
<PageState
|
|
106
|
+
v-bind="stateListeners()"
|
|
107
|
+
name="page-entry"
|
|
108
|
+
:loading="loading"
|
|
109
|
+
:error="error"
|
|
110
|
+
:empty="isEmpty"
|
|
111
|
+
:create-label="createLabel"
|
|
112
|
+
:retry-label="retryLabel"
|
|
113
|
+
:loading-label="loadingLabel"
|
|
114
|
+
:empty-title="emptyTitle"
|
|
115
|
+
:empty-description="emptyDescription"
|
|
116
|
+
:error-title="errorTitle"
|
|
117
|
+
>
|
|
118
|
+
<template v-if="$slots.skeleton" #skeleton>
|
|
119
|
+
<slot name="skeleton" />
|
|
120
|
+
</template>
|
|
121
|
+
<template v-if="$slots.error" #error>
|
|
122
|
+
<slot name="error" />
|
|
123
|
+
</template>
|
|
124
|
+
<template v-if="$slots.empty" #empty>
|
|
125
|
+
<slot name="empty" />
|
|
126
|
+
</template>
|
|
127
|
+
<slot />
|
|
128
|
+
</PageState>
|
|
129
|
+
</section>
|
|
130
|
+
</template>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, getCurrentInstance } from "vue";
|
|
3
|
+
import { FileX, Inbox, Plus, RotateCcw } from "@lucide/vue";
|
|
4
|
+
import { Button } from "../../ui/button";
|
|
5
|
+
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../../ui/empty";
|
|
6
|
+
import { Skeleton } from "../../ui/skeleton";
|
|
7
|
+
import { hasPageListener, resolvePageErrorMessage } from "./pageState";
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(
|
|
10
|
+
defineProps<{
|
|
11
|
+
name: "page-entry" | "page-detail";
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
error?: unknown;
|
|
14
|
+
empty?: boolean;
|
|
15
|
+
createLabel?: string;
|
|
16
|
+
retryLabel: string;
|
|
17
|
+
loadingLabel: string;
|
|
18
|
+
emptyTitle: string;
|
|
19
|
+
emptyDescription?: string;
|
|
20
|
+
errorTitle: string;
|
|
21
|
+
}>(),
|
|
22
|
+
{
|
|
23
|
+
loading: false,
|
|
24
|
+
error: undefined,
|
|
25
|
+
empty: false,
|
|
26
|
+
createLabel: "新建",
|
|
27
|
+
emptyDescription: undefined,
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const emit = defineEmits<{
|
|
32
|
+
create: [];
|
|
33
|
+
retry: [];
|
|
34
|
+
}>();
|
|
35
|
+
|
|
36
|
+
const instance = getCurrentInstance();
|
|
37
|
+
const hasError = computed(() => Boolean(props.error));
|
|
38
|
+
const errorMessage = computed(() => resolvePageErrorMessage(props.error));
|
|
39
|
+
const hasCreate = () => hasPageListener(instance, "create");
|
|
40
|
+
const hasRetry = () => hasPageListener(instance, "retry");
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<div v-if="loading" :data-slot="`${name}-loading`" class="min-w-0">
|
|
45
|
+
<span role="status" class="sr-only">{{ loadingLabel }}</span>
|
|
46
|
+
<slot name="skeleton">
|
|
47
|
+
<div v-if="name === 'page-entry'" aria-hidden="true" class="flex flex-col gap-2">
|
|
48
|
+
<Skeleton class="h-9 w-full" />
|
|
49
|
+
<Skeleton v-for="i in 3" :key="i" class="h-12 w-full" />
|
|
50
|
+
</div>
|
|
51
|
+
<div v-else aria-hidden="true" class="flex flex-col gap-2">
|
|
52
|
+
<Skeleton class="h-8 w-1/3" />
|
|
53
|
+
<Skeleton v-for="i in 4" :key="i" class="h-5 w-full" />
|
|
54
|
+
</div>
|
|
55
|
+
</slot>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div v-else-if="hasError" :data-slot="`${name}-error`" role="alert" class="min-w-0">
|
|
59
|
+
<slot name="error">
|
|
60
|
+
<Empty class="py-16">
|
|
61
|
+
<EmptyHeader>
|
|
62
|
+
<EmptyMedia>
|
|
63
|
+
<FileX class="size-10 text-muted-foreground" aria-hidden="true" />
|
|
64
|
+
</EmptyMedia>
|
|
65
|
+
<EmptyTitle>{{ errorTitle }}</EmptyTitle>
|
|
66
|
+
<EmptyDescription v-if="errorMessage" class="text-destructive">
|
|
67
|
+
{{ errorMessage }}
|
|
68
|
+
</EmptyDescription>
|
|
69
|
+
</EmptyHeader>
|
|
70
|
+
<EmptyContent v-if="hasRetry()">
|
|
71
|
+
<Button variant="secondary" @click="emit('retry')">
|
|
72
|
+
<RotateCcw aria-hidden="true" />
|
|
73
|
+
{{ retryLabel }}
|
|
74
|
+
</Button>
|
|
75
|
+
</EmptyContent>
|
|
76
|
+
</Empty>
|
|
77
|
+
</slot>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<div v-else-if="empty" :data-slot="`${name}-empty`" class="min-w-0">
|
|
81
|
+
<slot name="empty">
|
|
82
|
+
<Empty class="py-16">
|
|
83
|
+
<EmptyHeader>
|
|
84
|
+
<EmptyMedia>
|
|
85
|
+
<Inbox class="size-10 text-muted-foreground" aria-hidden="true" />
|
|
86
|
+
</EmptyMedia>
|
|
87
|
+
<EmptyTitle>{{ emptyTitle }}</EmptyTitle>
|
|
88
|
+
<EmptyDescription v-if="emptyDescription">{{ emptyDescription }}</EmptyDescription>
|
|
89
|
+
</EmptyHeader>
|
|
90
|
+
<EmptyContent v-if="hasCreate()">
|
|
91
|
+
<Button variant="secondary" @click="emit('create')">
|
|
92
|
+
<Plus aria-hidden="true" />
|
|
93
|
+
{{ createLabel }}
|
|
94
|
+
</Button>
|
|
95
|
+
</EmptyContent>
|
|
96
|
+
</Empty>
|
|
97
|
+
</slot>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<div
|
|
101
|
+
v-else
|
|
102
|
+
:data-slot="`${name}-content`"
|
|
103
|
+
class="min-w-0"
|
|
104
|
+
:class="name === 'page-detail' ? 'flex flex-col gap-4' : undefined"
|
|
105
|
+
>
|
|
106
|
+
<slot />
|
|
107
|
+
</div>
|
|
108
|
+
</template>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentInternalInstance } from "vue";
|
|
2
|
+
|
|
3
|
+
export const resolvePageErrorMessage = (error: unknown) => {
|
|
4
|
+
if (error == null) return "";
|
|
5
|
+
if (error instanceof Error) return error.message;
|
|
6
|
+
if (typeof error === "string") return error;
|
|
7
|
+
if (typeof error === "object" && "message" in error && typeof error.message === "string") {
|
|
8
|
+
return error.message;
|
|
9
|
+
}
|
|
10
|
+
return String(error);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Declared emits are filtered out of useAttrs(), so read the raw vnode props.
|
|
14
|
+
export const hasPageListener = (instance: ComponentInternalInstance | null, name: "create" | "retry") => {
|
|
15
|
+
const suffix = `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
|
|
16
|
+
const listener = instance?.vnode.props?.[`on${suffix}`];
|
|
17
|
+
return Array.isArray(listener) ? listener.length > 0 : typeof listener === "function";
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import type { AlertVariants } from ".";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import { alertVariants } from ".";
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
class?: HTMLAttributes["class"];
|
|
9
|
+
variant?: AlertVariants["variant"];
|
|
10
|
+
}>();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<div data-slot="alert" :class="cn(alertVariants({ variant }), props.class)" role="alert">
|
|
15
|
+
<slot />
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div
|
|
12
|
+
data-slot="alert-action"
|
|
13
|
+
:class="cn('absolute top-[calc(--spacing(1.25))] right-[calc(--spacing(1.25))]', props.class)"
|
|
14
|
+
>
|
|
15
|
+
<slot />
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div
|
|
12
|
+
data-slot="alert-description"
|
|
13
|
+
:class="
|
|
14
|
+
cn(
|
|
15
|
+
'text-muted-foreground text-xs/relaxed text-balance md:text-pretty [&_p:not(:last-child)]:mb-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground',
|
|
16
|
+
props.class,
|
|
17
|
+
)
|
|
18
|
+
"
|
|
19
|
+
>
|
|
20
|
+
<slot />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div
|
|
12
|
+
data-slot="alert-title"
|
|
13
|
+
:class="
|
|
14
|
+
cn(
|
|
15
|
+
'font-medium group-has-[>svg]/alert:col-start-2 cn-font-heading [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground',
|
|
16
|
+
props.class,
|
|
17
|
+
)
|
|
18
|
+
"
|
|
19
|
+
>
|
|
20
|
+
<slot />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
export { default as Alert } from "./Alert.vue";
|
|
5
|
+
export { default as AlertAction } from "./AlertAction.vue";
|
|
6
|
+
export { default as AlertDescription } from "./AlertDescription.vue";
|
|
7
|
+
export { default as AlertTitle } from "./AlertTitle.vue";
|
|
8
|
+
|
|
9
|
+
export const alertVariants = cva(
|
|
10
|
+
"grid gap-0.5 rounded-none border px-2.5 py-2 text-left text-xs has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0 *:[svg]:text-current *:[svg:not([class*=size-])]:size-4 group/alert relative w-full",
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
variant: {
|
|
14
|
+
default: "bg-card text-card-foreground",
|
|
15
|
+
destructive:
|
|
16
|
+
"text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
variant: "default",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export type AlertVariants = VariantProps<typeof alertVariants>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PrimitiveProps } from "reka-ui";
|
|
3
|
+
import type { HTMLAttributes } from "vue";
|
|
4
|
+
import type { BadgeVariants } from ".";
|
|
5
|
+
import { reactiveOmit } from "@vueuse/core";
|
|
6
|
+
import { Primitive } from "reka-ui";
|
|
7
|
+
import { cn } from "cn";
|
|
8
|
+
import { badgeVariants } from ".";
|
|
9
|
+
|
|
10
|
+
const props = defineProps<
|
|
11
|
+
PrimitiveProps & {
|
|
12
|
+
variant?: BadgeVariants["variant"];
|
|
13
|
+
class?: HTMLAttributes["class"];
|
|
14
|
+
}
|
|
15
|
+
>();
|
|
16
|
+
|
|
17
|
+
const delegatedProps = reactiveOmit(props, "class");
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<Primitive
|
|
22
|
+
data-slot="badge"
|
|
23
|
+
:data-variant="variant"
|
|
24
|
+
:class="cn(badgeVariants({ variant }), props.class)"
|
|
25
|
+
v-bind="delegatedProps"
|
|
26
|
+
>
|
|
27
|
+
<slot />
|
|
28
|
+
</Primitive>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
export { default as Badge } from "./Badge.vue";
|
|
5
|
+
|
|
6
|
+
export const badgeVariants = cva(
|
|
7
|
+
"h-5 gap-1 rounded-none border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
12
|
+
secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
|
13
|
+
destructive:
|
|
14
|
+
"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",
|
|
15
|
+
outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
|
16
|
+
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
|
17
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: "default",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
export type BadgeVariants = VariantProps<typeof badgeVariants>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PrimitiveProps } from "reka-ui";
|
|
3
|
+
import type { HTMLAttributes } from "vue";
|
|
4
|
+
import type { ButtonVariants } from ".";
|
|
5
|
+
import { Primitive } from "reka-ui";
|
|
6
|
+
import { cn } from "cn";
|
|
7
|
+
import { buttonVariants } from ".";
|
|
8
|
+
|
|
9
|
+
interface Props extends PrimitiveProps {
|
|
10
|
+
variant?: ButtonVariants["variant"];
|
|
11
|
+
size?: ButtonVariants["size"];
|
|
12
|
+
class?: HTMLAttributes["class"];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
+
as: "button",
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<Primitive
|
|
22
|
+
data-slot="button"
|
|
23
|
+
:data-variant="variant"
|
|
24
|
+
:data-size="size"
|
|
25
|
+
:as="as"
|
|
26
|
+
:as-child="asChild"
|
|
27
|
+
:class="cn(buttonVariants({ variant, size }), props.class)"
|
|
28
|
+
>
|
|
29
|
+
<slot />
|
|
30
|
+
</Primitive>
|
|
31
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
|
|
4
|
+
export { default as Button } from "./Button.vue";
|
|
5
|
+
|
|
6
|
+
export const buttonVariants = cva(
|
|
7
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-none border border-transparent bg-clip-padding text-xs font-medium focus-visible:ring-1 aria-invalid:ring-1 active:not-aria-[haspopup]:translate-y-px [&_svg:not([class*=size-])]:size-4 group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-all outline-none select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
12
|
+
outline:
|
|
13
|
+
"border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground",
|
|
14
|
+
secondary:
|
|
15
|
+
"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
16
|
+
ghost:
|
|
17
|
+
"hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground",
|
|
18
|
+
destructive:
|
|
19
|
+
"bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30",
|
|
20
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
24
|
+
xs: "h-6 gap-1 rounded-none px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*=size-])]:size-3",
|
|
25
|
+
sm: "h-7 gap-1 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*=size-])]:size-3.5",
|
|
26
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
27
|
+
icon: "size-8",
|
|
28
|
+
"icon-xs": "size-6 rounded-none [&_svg:not([class*=size-])]:size-3",
|
|
29
|
+
"icon-sm": "size-7 rounded-none",
|
|
30
|
+
"icon-lg": "size-9",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: "default",
|
|
35
|
+
size: "default",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(
|
|
6
|
+
defineProps<{
|
|
7
|
+
class?: HTMLAttributes["class"];
|
|
8
|
+
size?: "default" | "sm";
|
|
9
|
+
}>(),
|
|
10
|
+
{
|
|
11
|
+
size: "default",
|
|
12
|
+
},
|
|
13
|
+
);
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div
|
|
18
|
+
data-slot="card"
|
|
19
|
+
:data-size="size"
|
|
20
|
+
:class="
|
|
21
|
+
cn(
|
|
22
|
+
'ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-none py-4 text-xs/relaxed ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-2 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-none *:[img:last-child]:rounded-none group/card flex flex-col',
|
|
23
|
+
props.class,
|
|
24
|
+
)
|
|
25
|
+
"
|
|
26
|
+
>
|
|
27
|
+
<slot />
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div
|
|
12
|
+
data-slot="card-action"
|
|
13
|
+
:class="cn('col-start-2 row-span-2 row-start-1 self-start justify-self-end', props.class)"
|
|
14
|
+
>
|
|
15
|
+
<slot />
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div data-slot="card-content" :class="cn('px-4 group-data-[size=sm]/card:px-3', props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div data-slot="card-description" :class="cn('text-muted-foreground text-xs/relaxed', props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div
|
|
12
|
+
data-slot="card-footer"
|
|
13
|
+
:class="cn('rounded-none border-t p-4 group-data-[size=sm]/card:p-3 flex items-center', props.class)"
|
|
14
|
+
>
|
|
15
|
+
<slot />
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div
|
|
12
|
+
data-slot="card-header"
|
|
13
|
+
:class="
|
|
14
|
+
cn(
|
|
15
|
+
'gap-1 rounded-none px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]',
|
|
16
|
+
props.class,
|
|
17
|
+
)
|
|
18
|
+
"
|
|
19
|
+
>
|
|
20
|
+
<slot />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "vue";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div data-slot="card-title" :class="cn('text-sm font-medium group-data-[size=sm]/card:text-sm', props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as Card } from "./Card.vue";
|
|
2
|
+
export { default as CardAction } from "./CardAction.vue";
|
|
3
|
+
export { default as CardContent } from "./CardContent.vue";
|
|
4
|
+
export { default as CardDescription } from "./CardDescription.vue";
|
|
5
|
+
export { default as CardFooter } from "./CardFooter.vue";
|
|
6
|
+
export { default as CardHeader } from "./CardHeader.vue";
|
|
7
|
+
export { default as CardTitle } from "./CardTitle.vue";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { CollapsibleRootEmits, CollapsibleRootProps } from "reka-ui";
|
|
3
|
+
import { CollapsibleRoot, useForwardPropsEmits } from "reka-ui";
|
|
4
|
+
|
|
5
|
+
const props = defineProps<CollapsibleRootProps>();
|
|
6
|
+
const emits = defineEmits<CollapsibleRootEmits>();
|
|
7
|
+
|
|
8
|
+
const forwarded = useForwardPropsEmits(props, emits);
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<CollapsibleRoot v-slot="slotProps" data-slot="collapsible" v-bind="forwarded">
|
|
13
|
+
<slot v-bind="slotProps" />
|
|
14
|
+
</CollapsibleRoot>
|
|
15
|
+
</template>
|