numori-ui 0.3.0 → 0.5.0
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/CHANGELOG.md +148 -0
- package/README.md +36 -34
- package/dist/components/AppShell.js +234 -0
- package/dist/components/AppShell.js.map +1 -0
- package/dist/components/Banner.js +29 -32
- package/dist/components/Banner.js.map +1 -1
- package/dist/components/Button.js +10 -19
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.js +15 -9
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Checkbox.js +13 -9
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/CopyField.js +195 -0
- package/dist/components/CopyField.js.map +1 -0
- package/dist/components/DescriptionList.js +116 -0
- package/dist/components/DescriptionList.js.map +1 -0
- package/dist/components/Dropdown.js +10 -3
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/DropdownSubmenu.js +5 -3
- package/dist/components/DropdownSubmenu.js.map +1 -1
- package/dist/components/EmptyState.js +123 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/FileInput.js +12 -4
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/FormField.js +43 -13
- package/dist/components/FormField.js.map +1 -1
- package/dist/components/IconTile.js +5 -9
- package/dist/components/IconTile.js.map +1 -1
- package/dist/components/Input.js +21 -7
- package/dist/components/Input.js.map +1 -1
- package/dist/components/ListMenuItem.js +38 -31
- package/dist/components/ListMenuItem.js.map +1 -1
- package/dist/components/Numpad.js +4 -4
- package/dist/components/Numpad.js.map +1 -1
- package/dist/components/PageHeader.js +106 -0
- package/dist/components/PageHeader.js.map +1 -0
- package/dist/components/Pagination.js +236 -0
- package/dist/components/Pagination.js.map +1 -0
- package/dist/components/Popup.js +9 -3
- package/dist/components/Popup.js.map +1 -1
- package/dist/components/Radio.js +2 -7
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Segmented.js +109 -27
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +16 -5
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Sidebar.js +69 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/SidebarGroup.js +50 -0
- package/dist/components/SidebarGroup.js.map +1 -0
- package/dist/components/SidebarItem.js +167 -0
- package/dist/components/SidebarItem.js.map +1 -0
- package/dist/components/StatCard.js +185 -0
- package/dist/components/StatCard.js.map +1 -0
- package/dist/components/Table.js +306 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/Tabs.js +216 -0
- package/dist/components/Tabs.js.map +1 -0
- package/dist/components/Toggle.js +11 -2
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/index.js +91 -76
- package/dist/components/index.js.map +1 -1
- package/dist/composables/useMergedClasses.js +52 -0
- package/dist/composables/useMergedClasses.js.map +1 -0
- package/dist/icons/mdi.js +11 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.js +47 -37
- package/dist/index.js.map +1 -1
- package/dist/internal/controlSizes.js +21 -0
- package/dist/internal/controlSizes.js.map +1 -0
- package/dist/internal/formField.js +26 -0
- package/dist/internal/formField.js.map +1 -0
- package/dist/internal/menu.js +20 -0
- package/dist/internal/menu.js.map +1 -0
- package/dist/manifest.js +12 -2
- package/dist/manifest.js.map +1 -1
- package/package.json +2 -1
- package/src/components/AppShell.vue +231 -0
- package/src/components/Banner.vue +20 -9
- package/src/components/Button.vue +12 -19
- package/src/components/Card.vue +11 -12
- package/src/components/Checkbox.vue +7 -10
- package/src/components/CopyField.vue +178 -0
- package/src/components/DescriptionList.vue +114 -0
- package/src/components/Dropdown.vue +14 -2
- package/src/components/DropdownSubmenu.vue +4 -2
- package/src/components/EmptyState.vue +107 -0
- package/src/components/FileInput.vue +19 -4
- package/src/components/FormField.vue +37 -4
- package/src/components/IconTile.vue +4 -9
- package/src/components/Input.vue +15 -6
- package/src/components/ListMenuItem.vue +21 -5
- package/src/components/Numpad.vue +7 -4
- package/src/components/PageHeader.vue +102 -0
- package/src/components/Pagination.vue +199 -0
- package/src/components/Popup.vue +6 -2
- package/src/components/Radio.vue +2 -10
- package/src/components/Segmented.vue +113 -38
- package/src/components/Select.vue +16 -2
- package/src/components/Sidebar.vue +61 -0
- package/src/components/SidebarGroup.vue +43 -0
- package/src/components/SidebarItem.vue +159 -0
- package/src/components/StatCard.vue +165 -0
- package/src/components/Table.vue +323 -0
- package/src/components/Tabs.vue +217 -0
- package/src/components/Toggle.vue +5 -0
- package/src/components/index.js +36 -11
- package/src/composables/useMergedClasses.js +49 -0
- package/src/icons/mdi.js +11 -0
- package/src/internal/controlSizes.js +17 -0
- package/src/internal/formField.js +23 -0
- package/src/internal/menu.js +16 -0
- package/src/manifest.js +12 -2
- package/dist/components/ButtonsGroup.js +0 -153
- package/dist/components/ButtonsGroup.js.map +0 -1
- package/dist/components/ComparisonTable.js +0 -152
- package/dist/components/ComparisonTable.js.map +0 -1
- package/src/components/ButtonsGroup.vue +0 -140
- package/src/components/ComparisonTable.vue +0 -141
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nav :aria-label="label" :class="mergedClasses" v-bind="restAttrs">
|
|
3
|
+
<div
|
|
4
|
+
v-if="$slots.header"
|
|
5
|
+
class="flex h-14 shrink-0 items-center gap-2 border-b border-gray-200 px-4 dark:border-gray-800"
|
|
6
|
+
>
|
|
7
|
+
<slot name="header" />
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class="min-h-0 flex-1 space-y-0.5 overflow-y-auto px-3 py-4">
|
|
11
|
+
<slot />
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<div v-if="$slots.footer" class="shrink-0 border-t border-gray-200 p-3 dark:border-gray-800">
|
|
15
|
+
<slot name="footer" />
|
|
16
|
+
</div>
|
|
17
|
+
</nav>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup>
|
|
21
|
+
/**
|
|
22
|
+
* UiSidebar — vertical navigation for an application, with a brand header,
|
|
23
|
+
* a scrolling list of items and a pinned footer.
|
|
24
|
+
*
|
|
25
|
+
* Fills the height of its container, so it is usually placed in
|
|
26
|
+
* `UiAppShell`'s `#sidebar` slot, which handles the pinned / off-canvas
|
|
27
|
+
* behaviour. Fill it with `UiSidebarItem`s, grouped under headings with
|
|
28
|
+
* `UiSidebarGroup` when the list grows.
|
|
29
|
+
*
|
|
30
|
+
* Renders a `<nav>` landmark; give each one on a page a distinct `label`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* <UiSidebar label="Main">
|
|
34
|
+
* <template #header><strong>Numori CRDT</strong></template>
|
|
35
|
+
* <UiSidebarItem icon="mdi:view-grid" href="/" active>Dashboard</UiSidebarItem>
|
|
36
|
+
* <UiSidebarGroup label="Manage">
|
|
37
|
+
* <UiSidebarItem icon="mdi:sync" href="/apps">Apps</UiSidebarItem>
|
|
38
|
+
* <UiSidebarItem icon="mdi:account-group" href="/users">Users</UiSidebarItem>
|
|
39
|
+
* </UiSidebarGroup>
|
|
40
|
+
* <template #footer>Signed in as ada</template>
|
|
41
|
+
* </UiSidebar>
|
|
42
|
+
*
|
|
43
|
+
* @slot default — Navigation items and groups.
|
|
44
|
+
* @slot header — Brand area at the top, the same height as the shell's top bar.
|
|
45
|
+
* @slot footer — Pinned content at the bottom (account, version, etc.).
|
|
46
|
+
*/
|
|
47
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
48
|
+
|
|
49
|
+
defineProps({
|
|
50
|
+
/**
|
|
51
|
+
* Accessible name of the navigation landmark.
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @default 'Main'
|
|
54
|
+
*/
|
|
55
|
+
label: { type: String, default: 'Main' },
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
defineOptions({ inheritAttrs: false })
|
|
59
|
+
|
|
60
|
+
const { mergedClasses, restAttrs } = useMergedClasses('flex h-full min-h-0 w-full flex-col')
|
|
61
|
+
</script>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div role="group" :aria-labelledby="label ? headingId : undefined" class="pt-5 first:pt-0">
|
|
3
|
+
<p
|
|
4
|
+
v-if="label"
|
|
5
|
+
:id="headingId"
|
|
6
|
+
class="px-3 pb-1.5 text-xs font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"
|
|
7
|
+
>
|
|
8
|
+
{{ label }}
|
|
9
|
+
</p>
|
|
10
|
+
<div class="space-y-0.5">
|
|
11
|
+
<slot />
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup>
|
|
17
|
+
/**
|
|
18
|
+
* UiSidebarGroup — a labelled section of a `UiSidebar`.
|
|
19
|
+
*
|
|
20
|
+
* Groups related `UiSidebarItem`s under a small uppercase heading, which is
|
|
21
|
+
* also the group's accessible name.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* <UiSidebarGroup label="Manage">
|
|
25
|
+
* <UiSidebarItem icon="mdi:sync" href="/apps">Apps</UiSidebarItem>
|
|
26
|
+
* <UiSidebarItem icon="mdi:account-group" href="/users">Users</UiSidebarItem>
|
|
27
|
+
* </UiSidebarGroup>
|
|
28
|
+
*
|
|
29
|
+
* @slot default — The group's items.
|
|
30
|
+
*/
|
|
31
|
+
import { useId } from 'vue'
|
|
32
|
+
|
|
33
|
+
defineProps({
|
|
34
|
+
/**
|
|
35
|
+
* Heading shown above the items.
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @default ''
|
|
38
|
+
*/
|
|
39
|
+
label: { type: String, default: '' },
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const headingId = useId()
|
|
43
|
+
</script>
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="resolvedTag"
|
|
4
|
+
v-bind="{ ...linkAttrs, ...restAttrs }"
|
|
5
|
+
:class="mergedClasses"
|
|
6
|
+
:aria-current="active ? 'page' : undefined"
|
|
7
|
+
:aria-disabled="disabled ? 'true' : undefined"
|
|
8
|
+
@click="onClick"
|
|
9
|
+
>
|
|
10
|
+
<UiIcon
|
|
11
|
+
v-if="icon"
|
|
12
|
+
:name="icon"
|
|
13
|
+
class="size-[18px] shrink-0"
|
|
14
|
+
:class="
|
|
15
|
+
active
|
|
16
|
+
? 'text-primary-600 dark:text-primary-400'
|
|
17
|
+
: 'text-gray-400 group-hover:text-gray-600 dark:text-gray-500 dark:group-hover:text-gray-300'
|
|
18
|
+
"
|
|
19
|
+
/>
|
|
20
|
+
<span class="min-w-0 flex-1 truncate"><slot /></span>
|
|
21
|
+
<slot name="suffix">
|
|
22
|
+
<span
|
|
23
|
+
v-if="hasBadge"
|
|
24
|
+
class="ml-auto inline-flex min-w-5 items-center justify-center rounded-full px-1.5 text-xs font-semibold tabular-nums"
|
|
25
|
+
:class="
|
|
26
|
+
active
|
|
27
|
+
? 'bg-primary-100 text-primary-700 dark:bg-primary-400/20 dark:text-primary-200'
|
|
28
|
+
: 'bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300'
|
|
29
|
+
"
|
|
30
|
+
>{{ badge }}</span
|
|
31
|
+
>
|
|
32
|
+
</slot>
|
|
33
|
+
</component>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup>
|
|
37
|
+
/**
|
|
38
|
+
* UiSidebarItem — one navigation entry in a `UiSidebar`.
|
|
39
|
+
*
|
|
40
|
+
* Router-agnostic. Pass `to` to render through a globally registered
|
|
41
|
+
* `RouterLink` (or set `tag="NuxtLink"`), `href` for a plain anchor, or neither
|
|
42
|
+
* for a `<button>` that only emits `click`. The current page is marked with
|
|
43
|
+
* `active`, which also sets `aria-current="page"` — the item does not inspect
|
|
44
|
+
* the route itself, so any router (or none) works.
|
|
45
|
+
*
|
|
46
|
+
* Choosing an item inside a `UiAppShell` closes the shell's mobile drawer.
|
|
47
|
+
*
|
|
48
|
+
* @example With vue-router
|
|
49
|
+
* <UiSidebarItem icon="mdi:sync" to="/apps" :active="route.path.startsWith('/apps')">
|
|
50
|
+
* Apps
|
|
51
|
+
* </UiSidebarItem>
|
|
52
|
+
*
|
|
53
|
+
* @example With a count badge
|
|
54
|
+
* <UiSidebarItem icon="mdi:account-group" href="/users" :badge="3">Users</UiSidebarItem>
|
|
55
|
+
*
|
|
56
|
+
* @emits {MouseEvent} click — The item was chosen (not emitted while disabled).
|
|
57
|
+
*
|
|
58
|
+
* @slot default — Label.
|
|
59
|
+
* @slot suffix — Trailing content, replacing the badge.
|
|
60
|
+
*/
|
|
61
|
+
import { computed, inject } from 'vue'
|
|
62
|
+
import UiIcon from '../icons/Icon.vue'
|
|
63
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
64
|
+
|
|
65
|
+
const props = defineProps({
|
|
66
|
+
/**
|
|
67
|
+
* Element or component to render. Defaults to `RouterLink` when `to` is
|
|
68
|
+
* set, `a` when `href` is set, and `button` otherwise.
|
|
69
|
+
* @type {string}
|
|
70
|
+
* @default ''
|
|
71
|
+
*/
|
|
72
|
+
tag: { type: String, default: '' },
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Router location, passed to the link component.
|
|
76
|
+
* @type {string | object}
|
|
77
|
+
* @default undefined
|
|
78
|
+
*/
|
|
79
|
+
to: { type: [String, Object], default: undefined },
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Plain link target.
|
|
83
|
+
* @type {string}
|
|
84
|
+
* @default ''
|
|
85
|
+
*/
|
|
86
|
+
href: { type: String, default: '' },
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* MDI icon shown before the label.
|
|
90
|
+
* @type {string}
|
|
91
|
+
* @default ''
|
|
92
|
+
*/
|
|
93
|
+
icon: { type: String, default: '' },
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Mark as the current page.
|
|
97
|
+
* @type {boolean}
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
active: { type: Boolean, default: false },
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Count or short label shown at the end of the row. Empty hides it.
|
|
104
|
+
* @type {string | number}
|
|
105
|
+
* @default ''
|
|
106
|
+
*/
|
|
107
|
+
badge: { type: [String, Number], default: '' },
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Dim the item and ignore clicks.
|
|
111
|
+
* @type {boolean}
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
114
|
+
disabled: { type: Boolean, default: false },
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
const emit = defineEmits(['click'])
|
|
118
|
+
|
|
119
|
+
defineOptions({ inheritAttrs: false })
|
|
120
|
+
|
|
121
|
+
const shell = inject('numori-ui:app-shell', null)
|
|
122
|
+
|
|
123
|
+
const resolvedTag = computed(() => {
|
|
124
|
+
if (props.tag) return props.tag
|
|
125
|
+
if (props.to !== undefined) return 'RouterLink'
|
|
126
|
+
if (props.href) return 'a'
|
|
127
|
+
return 'button'
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
const linkAttrs = computed(() => {
|
|
131
|
+
if (resolvedTag.value === 'button') return { type: 'button', disabled: props.disabled }
|
|
132
|
+
if (resolvedTag.value === 'a') return { href: props.disabled ? undefined : props.href }
|
|
133
|
+
return { to: props.to }
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const hasBadge = computed(() => props.badge !== '' && props.badge !== null)
|
|
137
|
+
|
|
138
|
+
function onClick(event) {
|
|
139
|
+
if (props.disabled) {
|
|
140
|
+
event.preventDefault()
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
emit('click', event)
|
|
144
|
+
shell?.close()
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const internalClasses = computed(() =>
|
|
148
|
+
[
|
|
149
|
+
'group flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors',
|
|
150
|
+
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 dark:focus-visible:outline-primary-400',
|
|
151
|
+
props.active
|
|
152
|
+
? 'bg-primary-50 text-primary-700 dark:bg-primary-400/10 dark:text-primary-200'
|
|
153
|
+
: 'text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100',
|
|
154
|
+
props.disabled ? 'pointer-events-none opacity-40' : 'cursor-pointer',
|
|
155
|
+
].join(' '),
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)
|
|
159
|
+
</script>
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<UiCard padding="sm" :aria-busy="loading ? 'true' : undefined">
|
|
3
|
+
<div class="flex items-start justify-between gap-3">
|
|
4
|
+
<div class="min-w-0">
|
|
5
|
+
<p class="truncate text-sm font-medium text-gray-500 dark:text-gray-400">{{ label }}</p>
|
|
6
|
+
<p
|
|
7
|
+
class="mt-1 text-2xl font-semibold tracking-tight text-gray-900 tabular-nums dark:text-gray-50"
|
|
8
|
+
>
|
|
9
|
+
<span
|
|
10
|
+
v-if="loading"
|
|
11
|
+
class="inline-block h-7 w-16 animate-pulse rounded-md bg-gray-200 align-middle motion-reduce:animate-none dark:bg-gray-800"
|
|
12
|
+
aria-hidden="true"
|
|
13
|
+
/>
|
|
14
|
+
<slot v-else name="value">{{ value }}</slot>
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
<span
|
|
18
|
+
v-if="icon"
|
|
19
|
+
class="inline-flex size-9 shrink-0 items-center justify-center rounded-xl"
|
|
20
|
+
:class="toneClass"
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
>
|
|
23
|
+
<UiIcon :name="icon" class="size-5" />
|
|
24
|
+
</span>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div
|
|
28
|
+
v-if="hint || delta || $slots.default"
|
|
29
|
+
class="mt-3 flex flex-wrap items-center gap-2 text-xs"
|
|
30
|
+
>
|
|
31
|
+
<span v-if="delta" class="inline-flex items-center gap-1 font-medium" :class="deltaClass">
|
|
32
|
+
<UiIcon :name="trendIcon" class="size-3.5" />
|
|
33
|
+
{{ delta }}
|
|
34
|
+
</span>
|
|
35
|
+
<span v-if="hint" class="text-gray-500 dark:text-gray-400">{{ hint }}</span>
|
|
36
|
+
<slot />
|
|
37
|
+
</div>
|
|
38
|
+
</UiCard>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script setup>
|
|
42
|
+
/**
|
|
43
|
+
* UiStatCard — a single headline number for dashboards: label, value, an
|
|
44
|
+
* optional tinted icon, a trend delta and a hint line.
|
|
45
|
+
*
|
|
46
|
+
* Built on `UiCard`, so external classes merge onto the card surface. While
|
|
47
|
+
* `loading`, the value is replaced by a pulsing placeholder of the same height
|
|
48
|
+
* so a grid of cards doesn't jump when data arrives.
|
|
49
|
+
*
|
|
50
|
+
* The delta's colour follows `trend` (up is green, down is red) unless
|
|
51
|
+
* `deltaColor` says otherwise — for metrics where going up is bad, such as
|
|
52
|
+
* error counts, pass `delta-color="red"` with `trend="up"`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* <div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
|
56
|
+
* <UiStatCard label="Connections" :value="128" icon="mdi:lan-connect" />
|
|
57
|
+
* <UiStatCard label="Documents" value="4,210" icon="mdi:file-document-outline" color="success" />
|
|
58
|
+
* <UiStatCard label="Access denials" :value="3" trend="up" delta="+2" delta-color="red" hint="last hour" />
|
|
59
|
+
* </div>
|
|
60
|
+
*
|
|
61
|
+
* @slot value — Rich value content (overrides `value`).
|
|
62
|
+
* @slot default — Extra content in the footer line.
|
|
63
|
+
*/
|
|
64
|
+
import { computed } from 'vue'
|
|
65
|
+
import UiCard from './Card.vue'
|
|
66
|
+
import UiIcon from '../icons/Icon.vue'
|
|
67
|
+
|
|
68
|
+
const props = defineProps({
|
|
69
|
+
/**
|
|
70
|
+
* What the number measures.
|
|
71
|
+
* @type {string}
|
|
72
|
+
* @default ''
|
|
73
|
+
*/
|
|
74
|
+
label: { type: String, default: '' },
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The number (or pre-formatted string).
|
|
78
|
+
* @type {string | number}
|
|
79
|
+
* @default ''
|
|
80
|
+
*/
|
|
81
|
+
value: { type: [String, Number], default: '' },
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Secondary line, such as a time window or a unit.
|
|
85
|
+
* @type {string}
|
|
86
|
+
* @default ''
|
|
87
|
+
*/
|
|
88
|
+
hint: { type: String, default: '' },
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* MDI icon in a tinted tile.
|
|
92
|
+
* @type {string}
|
|
93
|
+
* @default ''
|
|
94
|
+
*/
|
|
95
|
+
icon: { type: String, default: '' },
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Icon tile tint.
|
|
99
|
+
* @type {string}
|
|
100
|
+
* @default 'primary'
|
|
101
|
+
* @values 'primary' | 'success' | 'warning' | 'error' | 'gray'
|
|
102
|
+
*/
|
|
103
|
+
color: { type: String, default: 'primary' },
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Change to show next to the hint, e.g. `'+12%'`. Empty hides it.
|
|
107
|
+
* @type {string}
|
|
108
|
+
* @default ''
|
|
109
|
+
*/
|
|
110
|
+
delta: { type: String, default: '' },
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Direction of the change, which picks the arrow.
|
|
114
|
+
* @type {string}
|
|
115
|
+
* @default 'flat'
|
|
116
|
+
* @values 'up' | 'down' | 'flat'
|
|
117
|
+
*/
|
|
118
|
+
trend: { type: String, default: 'flat' },
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Delta colour. `'auto'` makes up green and down red.
|
|
122
|
+
* @type {string}
|
|
123
|
+
* @default 'auto'
|
|
124
|
+
* @values 'auto' | 'green' | 'red' | 'gray'
|
|
125
|
+
*/
|
|
126
|
+
deltaColor: { type: String, default: 'auto' },
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Show a placeholder instead of the value.
|
|
130
|
+
* @type {boolean}
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
loading: { type: Boolean, default: false },
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const toneClass = computed(
|
|
137
|
+
() =>
|
|
138
|
+
({
|
|
139
|
+
primary: 'bg-primary-50 text-primary-600 dark:bg-primary-400/10 dark:text-primary-300',
|
|
140
|
+
success: 'bg-success-50 text-success-700 dark:bg-success-400/10 dark:text-success-300',
|
|
141
|
+
warning: 'bg-warning-50 text-warning-700 dark:bg-warning-400/10 dark:text-warning-300',
|
|
142
|
+
error: 'bg-red-50 text-red-600 dark:bg-red-400/10 dark:text-red-300',
|
|
143
|
+
gray: 'bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400',
|
|
144
|
+
})[props.color] ??
|
|
145
|
+
'bg-primary-50 text-primary-600 dark:bg-primary-400/10 dark:text-primary-300',
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
const trendIcon = computed(
|
|
149
|
+
() =>
|
|
150
|
+
({ up: 'mdi:trending-up', down: 'mdi:trending-down' })[props.trend] ?? 'mdi:trending-neutral',
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
const deltaClass = computed(() => {
|
|
154
|
+
const tone =
|
|
155
|
+
props.deltaColor === 'auto'
|
|
156
|
+
? { up: 'green', down: 'red' }[props.trend] || 'gray'
|
|
157
|
+
: props.deltaColor
|
|
158
|
+
return (
|
|
159
|
+
{
|
|
160
|
+
green: 'text-success-700 dark:text-success-400',
|
|
161
|
+
red: 'text-red-600 dark:text-red-400',
|
|
162
|
+
}[tone] ?? 'text-gray-500 dark:text-gray-400'
|
|
163
|
+
)
|
|
164
|
+
})
|
|
165
|
+
</script>
|