numori-ui 0.4.0 → 0.6.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 +120 -0
- package/README.md +27 -20
- package/dist/components/AppShell.js +234 -0
- package/dist/components/AppShell.js.map +1 -0
- package/dist/components/Avatar.js +71 -19
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Checkbox.js +11 -2
- 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 +3 -1
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/EmptyState.js +123 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/FormField.js +43 -13
- package/dist/components/FormField.js.map +1 -1
- package/dist/components/Input.js +15 -1
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Modal.js +61 -4
- package/dist/components/Modal.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/Prompt.js +11 -6
- package/dist/components/Prompt.js.map +1 -1
- package/dist/components/Segmented.js +10 -2
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +11 -2
- 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/Skeleton.js +122 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/SplitPane.js +264 -0
- package/dist/components/SplitPane.js.map +1 -0
- package/dist/components/StatCard.js +185 -0
- package/dist/components/StatCard.js.map +1 -0
- package/dist/components/Table.js +182 -50
- package/dist/components/Table.js.map +1 -1
- 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/Tree.js +417 -0
- package/dist/components/Tree.js.map +1 -0
- package/dist/components/VirtualList.js +292 -0
- package/dist/components/VirtualList.js.map +1 -0
- package/dist/components/index.js +105 -81
- package/dist/components/index.js.map +1 -1
- package/dist/icons/mdi.js +12 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +54 -39
- package/dist/index.js.map +1 -1
- package/dist/internal/focusTrap.js +163 -0
- package/dist/internal/focusTrap.js.map +1 -0
- package/dist/internal/formField.js +26 -0
- package/dist/internal/formField.js.map +1 -0
- package/dist/manifest.js +16 -1
- package/dist/manifest.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AppShell.vue +231 -0
- package/src/components/Avatar.vue +69 -18
- package/src/components/Checkbox.vue +5 -0
- package/src/components/CopyField.vue +178 -0
- package/src/components/DescriptionList.vue +114 -0
- package/src/components/Dropdown.vue +4 -1
- package/src/components/EmptyState.vue +107 -0
- package/src/components/FormField.vue +37 -4
- package/src/components/Input.vue +9 -0
- package/src/components/Modal.vue +51 -3
- package/src/components/PageHeader.vue +102 -0
- package/src/components/Pagination.vue +199 -0
- package/src/components/Prompt.vue +14 -3
- package/src/components/Segmented.vue +5 -0
- package/src/components/Select.vue +6 -1
- package/src/components/Sidebar.vue +61 -0
- package/src/components/SidebarGroup.vue +43 -0
- package/src/components/SidebarItem.vue +159 -0
- package/src/components/Skeleton.vue +91 -0
- package/src/components/SplitPane.vue +264 -0
- package/src/components/StatCard.vue +165 -0
- package/src/components/Table.vue +148 -18
- package/src/components/Tabs.vue +217 -0
- package/src/components/Toggle.vue +5 -0
- package/src/components/Tree.vue +428 -0
- package/src/components/VirtualList.vue +250 -0
- package/src/components/index.js +45 -6
- package/src/icons/mdi.js +12 -0
- package/src/internal/focusTrap.js +185 -0
- package/src/internal/formField.js +23 -0
- package/src/manifest.js +15 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nav :aria-label="ariaLabel" class="flex flex-col items-center justify-between gap-3 sm:flex-row">
|
|
3
|
+
<p v-if="showSummary" class="text-sm text-gray-500 tabular-nums dark:text-gray-400">
|
|
4
|
+
{{ summaryText }}
|
|
5
|
+
</p>
|
|
6
|
+
<span v-else />
|
|
7
|
+
|
|
8
|
+
<ul v-if="pageCount > 1" class="flex items-center gap-1">
|
|
9
|
+
<li>
|
|
10
|
+
<button
|
|
11
|
+
type="button"
|
|
12
|
+
:class="navClass"
|
|
13
|
+
:disabled="current <= 1"
|
|
14
|
+
:aria-label="previousLabel"
|
|
15
|
+
@click="go(current - 1)"
|
|
16
|
+
>
|
|
17
|
+
<UiIcon name="mdi:chevron-left" class="size-4" />
|
|
18
|
+
</button>
|
|
19
|
+
</li>
|
|
20
|
+
<li
|
|
21
|
+
v-for="item in items"
|
|
22
|
+
:key="item.key"
|
|
23
|
+
:class="item.page === current ? '' : 'hidden sm:block'"
|
|
24
|
+
>
|
|
25
|
+
<span
|
|
26
|
+
v-if="item.type === 'gap'"
|
|
27
|
+
class="inline-flex size-9 items-center justify-center text-sm text-gray-400 dark:text-gray-500"
|
|
28
|
+
aria-hidden="true"
|
|
29
|
+
>…</span
|
|
30
|
+
>
|
|
31
|
+
<button
|
|
32
|
+
v-else
|
|
33
|
+
type="button"
|
|
34
|
+
:class="pageClass(item.page)"
|
|
35
|
+
:aria-current="item.page === current ? 'page' : undefined"
|
|
36
|
+
:aria-label="formatPageLabel(item.page)"
|
|
37
|
+
@click="go(item.page)"
|
|
38
|
+
>
|
|
39
|
+
{{ item.page }}
|
|
40
|
+
</button>
|
|
41
|
+
</li>
|
|
42
|
+
<li>
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
:class="navClass"
|
|
46
|
+
:disabled="current >= pageCount"
|
|
47
|
+
:aria-label="nextLabel"
|
|
48
|
+
@click="go(current + 1)"
|
|
49
|
+
>
|
|
50
|
+
<UiIcon name="mdi:chevron-right" class="size-4" />
|
|
51
|
+
</button>
|
|
52
|
+
</li>
|
|
53
|
+
</ul>
|
|
54
|
+
</nav>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<script setup>
|
|
58
|
+
/**
|
|
59
|
+
* UiPagination — page controls for a long list, with a "21–40 of 134" summary.
|
|
60
|
+
*
|
|
61
|
+
* Shows the first and last page, the current page and `siblings` pages either
|
|
62
|
+
* side of it, collapsing the rest into gaps, so the control stays the same
|
|
63
|
+
* width however many pages there are. On narrow screens only the current page
|
|
64
|
+
* and the arrows remain.
|
|
65
|
+
*
|
|
66
|
+
* Bind `v-model:page`; the component never fetches anything. All visible text
|
|
67
|
+
* is configurable for localisation.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* <UiPagination v-model:page="page" :page-size="20" :total="134" />
|
|
71
|
+
*
|
|
72
|
+
* @example Localised
|
|
73
|
+
* <UiPagination
|
|
74
|
+
* v-model:page="page"
|
|
75
|
+
* :total="total"
|
|
76
|
+
* previous-label="Anterior"
|
|
77
|
+
* next-label="Siguiente"
|
|
78
|
+
* :format-summary="(from, to, total) => `${from}–${to} de ${total}`"
|
|
79
|
+
* />
|
|
80
|
+
*
|
|
81
|
+
* @emits {number} update:page — The requested page (1-based).
|
|
82
|
+
*/
|
|
83
|
+
import { computed } from 'vue'
|
|
84
|
+
import UiIcon from '../icons/Icon.vue'
|
|
85
|
+
|
|
86
|
+
const props = defineProps({
|
|
87
|
+
/**
|
|
88
|
+
* Current page, 1-based.
|
|
89
|
+
* @type {number}
|
|
90
|
+
* @default 1
|
|
91
|
+
*/
|
|
92
|
+
page: { type: Number, default: 1 },
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Items per page.
|
|
96
|
+
* @type {number}
|
|
97
|
+
* @default 20
|
|
98
|
+
*/
|
|
99
|
+
pageSize: { type: Number, default: 20 },
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Total number of items.
|
|
103
|
+
* @type {number}
|
|
104
|
+
*/
|
|
105
|
+
total: { type: Number, required: true },
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Pages shown either side of the current one.
|
|
109
|
+
* @type {number}
|
|
110
|
+
* @default 1
|
|
111
|
+
*/
|
|
112
|
+
siblings: { type: Number, default: 1 },
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Show the "from–to of total" summary.
|
|
116
|
+
* @type {boolean}
|
|
117
|
+
* @default true
|
|
118
|
+
*/
|
|
119
|
+
showSummary: { type: Boolean, default: true },
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Builds the summary text from the 1-based range shown and the total.
|
|
123
|
+
* @type {(from: number, to: number, total: number) => string}
|
|
124
|
+
*/
|
|
125
|
+
formatSummary: {
|
|
126
|
+
type: Function,
|
|
127
|
+
default: (from, to, total) => (total === 0 ? 'No items' : `${from}–${to} of ${total}`),
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Builds each page button's accessible label.
|
|
132
|
+
* @type {(page: number) => string}
|
|
133
|
+
*/
|
|
134
|
+
formatPageLabel: { type: Function, default: (page) => `Page ${page}` },
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Accessible label of the previous button.
|
|
138
|
+
* @type {string}
|
|
139
|
+
* @default 'Previous page'
|
|
140
|
+
*/
|
|
141
|
+
previousLabel: { type: String, default: 'Previous page' },
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Accessible label of the next button.
|
|
145
|
+
* @type {string}
|
|
146
|
+
* @default 'Next page'
|
|
147
|
+
*/
|
|
148
|
+
nextLabel: { type: String, default: 'Next page' },
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Accessible name of the navigation landmark.
|
|
152
|
+
* @type {string}
|
|
153
|
+
* @default 'Pagination'
|
|
154
|
+
*/
|
|
155
|
+
ariaLabel: { type: String, default: 'Pagination' },
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
const emit = defineEmits(['update:page'])
|
|
159
|
+
|
|
160
|
+
const pageCount = computed(() =>
|
|
161
|
+
Math.max(1, Math.ceil(Math.max(0, props.total) / Math.max(1, props.pageSize))),
|
|
162
|
+
)
|
|
163
|
+
const current = computed(() => Math.min(Math.max(1, props.page), pageCount.value))
|
|
164
|
+
|
|
165
|
+
const summaryText = computed(() => {
|
|
166
|
+
const total = Math.max(0, props.total)
|
|
167
|
+
const from = total === 0 ? 0 : (current.value - 1) * props.pageSize + 1
|
|
168
|
+
const to = Math.min(total, current.value * props.pageSize)
|
|
169
|
+
return props.formatSummary(from, to, total)
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
/** First, last, current ± siblings, with gaps where pages are skipped. */
|
|
173
|
+
const items = computed(() => {
|
|
174
|
+
const last = pageCount.value
|
|
175
|
+
const start = Math.max(2, current.value - props.siblings)
|
|
176
|
+
const end = Math.min(last - 1, current.value + props.siblings)
|
|
177
|
+
const out = [{ type: 'page', page: 1, key: 'p1' }]
|
|
178
|
+
if (start > 2) out.push({ type: 'gap', key: 'gap-start' })
|
|
179
|
+
for (let p = start; p <= end; p++) out.push({ type: 'page', page: p, key: `p${p}` })
|
|
180
|
+
if (end < last - 1) out.push({ type: 'gap', key: 'gap-end' })
|
|
181
|
+
if (last > 1) out.push({ type: 'page', page: last, key: `p${last}` })
|
|
182
|
+
return out
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
function go(page) {
|
|
186
|
+
const next = Math.min(Math.max(1, page), pageCount.value)
|
|
187
|
+
if (next !== current.value) emit('update:page', next)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const buttonBase =
|
|
191
|
+
'inline-flex size-9 items-center justify-center rounded-lg text-sm font-medium tabular-nums transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500'
|
|
192
|
+
|
|
193
|
+
const navClass = `${buttonBase} text-gray-600 hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100`
|
|
194
|
+
|
|
195
|
+
const pageClass = (page) =>
|
|
196
|
+
page === current.value
|
|
197
|
+
? `${buttonBase} bg-primary-600 text-white dark:bg-primary-500 dark:text-gray-950`
|
|
198
|
+
: `${buttonBase} text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800`
|
|
199
|
+
</script>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
max-width="sm"
|
|
5
5
|
:fullscreen-mobile="fullscreenMobile"
|
|
6
6
|
:panel-class="panelClass"
|
|
7
|
+
:labelledby="titleId"
|
|
7
8
|
@close="handleClose"
|
|
8
9
|
>
|
|
9
10
|
<div
|
|
@@ -15,11 +16,20 @@
|
|
|
15
16
|
<div class="flex items-center justify-between p-4 pb-0 mb-3 shrink-0">
|
|
16
17
|
<div class="flex items-center gap-2">
|
|
17
18
|
<UiIcon v-if="icon" :name="icon" class="w-5 h-5" :class="iconColorClass" />
|
|
18
|
-
<h2
|
|
19
|
+
<h2
|
|
20
|
+
:id="titleId"
|
|
21
|
+
class="text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none"
|
|
22
|
+
>
|
|
19
23
|
{{ title }}
|
|
20
24
|
</h2>
|
|
21
25
|
</div>
|
|
22
|
-
<UiButton
|
|
26
|
+
<UiButton
|
|
27
|
+
variant="ghost"
|
|
28
|
+
color="gray"
|
|
29
|
+
icon-only
|
|
30
|
+
:aria-label="cancelLabel"
|
|
31
|
+
@click="handleClose"
|
|
32
|
+
>
|
|
23
33
|
<UiIcon name="mdi:close" class="block w-5 h-5" />
|
|
24
34
|
</UiButton>
|
|
25
35
|
</div>
|
|
@@ -87,7 +97,7 @@
|
|
|
87
97
|
* <UiInput v-model="name" @keydown.enter="save" />
|
|
88
98
|
* </UiPrompt>
|
|
89
99
|
*/
|
|
90
|
-
import { ref, computed, watch, nextTick, useSlots } from 'vue'
|
|
100
|
+
import { ref, computed, watch, nextTick, useSlots, useId } from 'vue'
|
|
91
101
|
import UiButton from './Button.vue'
|
|
92
102
|
import UiModal from './Modal.vue'
|
|
93
103
|
import UiIcon from '../icons/Icon.vue'
|
|
@@ -119,6 +129,7 @@ const props = defineProps({
|
|
|
119
129
|
const emit = defineEmits(['close', 'confirm'])
|
|
120
130
|
|
|
121
131
|
const confirmRef = ref(null)
|
|
132
|
+
const titleId = `${useId()}-title`
|
|
122
133
|
const hasCustomActions = computed(() => !!useSlots().actions)
|
|
123
134
|
|
|
124
135
|
const iconColorClass = computed(() => {
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
<div
|
|
3
3
|
role="group"
|
|
4
4
|
:aria-label="ariaLabel"
|
|
5
|
+
:aria-labelledby="ariaLabel ? undefined : field?.labelId"
|
|
6
|
+
:aria-describedby="field?.describedBy.value"
|
|
5
7
|
class="relative p-1"
|
|
6
8
|
:class="[
|
|
7
9
|
block ? 'grid w-full' : 'inline-grid',
|
|
@@ -98,6 +100,7 @@
|
|
|
98
100
|
*/
|
|
99
101
|
import { computed } from 'vue'
|
|
100
102
|
import UiIcon from '../icons/Icon.vue'
|
|
103
|
+
import { useFormField } from '../internal/formField.js'
|
|
101
104
|
|
|
102
105
|
const props = defineProps({
|
|
103
106
|
/**
|
|
@@ -163,6 +166,8 @@ const props = defineProps({
|
|
|
163
166
|
|
|
164
167
|
const emit = defineEmits(['update:modelValue'])
|
|
165
168
|
|
|
169
|
+
const field = useFormField()
|
|
170
|
+
|
|
166
171
|
const count = computed(() => props.options?.length || 1)
|
|
167
172
|
|
|
168
173
|
const isActive = (option) => option.value === props.modelValue
|
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
|
|
20
20
|
<!-- Trigger button: shows selected value, placeholder, or loading spinner -->
|
|
21
21
|
<button
|
|
22
|
+
:id="field?.controlId.value"
|
|
22
23
|
ref="triggerRef"
|
|
23
24
|
type="button"
|
|
25
|
+
:aria-describedby="field?.describedBy.value"
|
|
24
26
|
:disabled="disabled || loading"
|
|
25
27
|
:aria-label="ariaLabel"
|
|
26
28
|
:class="[triggerClasses, disabled || loading ? 'opacity-50 cursor-not-allowed' : '']"
|
|
@@ -76,7 +78,7 @@
|
|
|
76
78
|
type="text"
|
|
77
79
|
placeholder="Search..."
|
|
78
80
|
class="w-full px-2.5 py-1.5 text-sm border border-gray-200 dark:border-gray-700 rounded-md bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-300 outline-none focus:ring-1 focus:ring-primary-500 placeholder-gray-400"
|
|
79
|
-
@keydown.escape="close"
|
|
81
|
+
@keydown.escape.prevent="close"
|
|
80
82
|
@keydown.enter.prevent="selectFirst"
|
|
81
83
|
/>
|
|
82
84
|
</div>
|
|
@@ -174,6 +176,7 @@
|
|
|
174
176
|
import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'
|
|
175
177
|
import UiIcon from '../icons/Icon.vue'
|
|
176
178
|
import { MENU_PANEL_CLASS } from '../internal/menu.js'
|
|
179
|
+
import { useFormField } from '../internal/formField.js'
|
|
177
180
|
const props = defineProps({
|
|
178
181
|
/**
|
|
179
182
|
* Currently selected value (v-model).
|
|
@@ -258,6 +261,8 @@ const props = defineProps({
|
|
|
258
261
|
|
|
259
262
|
const emit = defineEmits(['update:modelValue'])
|
|
260
263
|
|
|
264
|
+
const field = useFormField()
|
|
265
|
+
|
|
261
266
|
const containerRef = ref(null)
|
|
262
267
|
const triggerRef = ref(null)
|
|
263
268
|
const searchRef = ref(null)
|
|
@@ -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,91 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="variant === 'text'" :class="['flex flex-col', gapClass]" v-bind="a11yAttrs">
|
|
3
|
+
<span v-if="label" class="sr-only">{{ label }}</span>
|
|
4
|
+
<div
|
|
5
|
+
v-for="line in lines"
|
|
6
|
+
:key="line"
|
|
7
|
+
:class="[baseClass, 'h-3 rounded-md', line === lines && lines > 1 ? 'w-3/5' : 'w-full']"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
/>
|
|
10
|
+
</div>
|
|
11
|
+
<div v-else :class="[baseClass, shapeClass]" v-bind="a11yAttrs">
|
|
12
|
+
<span v-if="label" class="sr-only">{{ label }}</span>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup>
|
|
17
|
+
/**
|
|
18
|
+
* UiSkeleton — a placeholder shaped like the content that is about to load.
|
|
19
|
+
*
|
|
20
|
+
* Three shapes: `text` (one or more lines, the last one shorter), `rect` and
|
|
21
|
+
* `circle`. Size the shape with ordinary classes — `class="h-24 w-full"`, or
|
|
22
|
+
* `class="size-9"` for an avatar-sized circle.
|
|
23
|
+
*
|
|
24
|
+
* The shimmer is a gentle pulse and stops for anyone who prefers reduced
|
|
25
|
+
* motion. Skeletons are decorative (`aria-hidden`) by default; give one a
|
|
26
|
+
* `label` and it becomes a polite status message instead, so a screen reader
|
|
27
|
+
* hears "Loading messages" once rather than nothing at all. Label one
|
|
28
|
+
* skeleton per region, not every line.
|
|
29
|
+
*
|
|
30
|
+
* @example A message row while it loads
|
|
31
|
+
* <div class="flex items-center gap-3">
|
|
32
|
+
* <UiSkeleton variant="circle" class="size-9" />
|
|
33
|
+
* <UiSkeleton :lines="2" class="flex-1" />
|
|
34
|
+
* </div>
|
|
35
|
+
*
|
|
36
|
+
* @example Announced to screen readers
|
|
37
|
+
* <UiSkeleton variant="rect" class="h-40" label="Loading message" />
|
|
38
|
+
*/
|
|
39
|
+
import { computed } from 'vue'
|
|
40
|
+
|
|
41
|
+
const props = defineProps({
|
|
42
|
+
/**
|
|
43
|
+
* Shape of the placeholder.
|
|
44
|
+
* @type {string}
|
|
45
|
+
* @default 'text'
|
|
46
|
+
* @values 'text' | 'rect' | 'circle'
|
|
47
|
+
*/
|
|
48
|
+
variant: { type: String, default: 'text' },
|
|
49
|
+
/**
|
|
50
|
+
* Number of lines for `variant="text"`.
|
|
51
|
+
* @type {number}
|
|
52
|
+
* @default 1
|
|
53
|
+
*/
|
|
54
|
+
lines: { type: Number, default: 1 },
|
|
55
|
+
/**
|
|
56
|
+
* Spacing between text lines.
|
|
57
|
+
* @type {string}
|
|
58
|
+
* @default 'md'
|
|
59
|
+
* @values 'sm' | 'md' | 'lg'
|
|
60
|
+
*/
|
|
61
|
+
gap: { type: String, default: 'md' },
|
|
62
|
+
/**
|
|
63
|
+
* Pulse while waiting. Always off under `prefers-reduced-motion`.
|
|
64
|
+
* @type {boolean}
|
|
65
|
+
* @default true
|
|
66
|
+
*/
|
|
67
|
+
animated: { type: Boolean, default: true },
|
|
68
|
+
/**
|
|
69
|
+
* Announce the placeholder as a loading status with this text. Empty keeps
|
|
70
|
+
* it hidden from assistive technology.
|
|
71
|
+
* @type {string}
|
|
72
|
+
* @default ''
|
|
73
|
+
*/
|
|
74
|
+
label: { type: String, default: '' },
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const baseClass = computed(() =>
|
|
78
|
+
[
|
|
79
|
+
'block bg-gray-200 dark:bg-gray-800',
|
|
80
|
+
props.animated ? 'animate-pulse motion-reduce:animate-none' : '',
|
|
81
|
+
].join(' '),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
const shapeClass = computed(() => (props.variant === 'circle' ? 'rounded-full' : 'rounded-lg'))
|
|
85
|
+
|
|
86
|
+
const gapClass = computed(() => ({ sm: 'gap-1.5', md: 'gap-2', lg: 'gap-3' })[props.gap] ?? 'gap-2')
|
|
87
|
+
|
|
88
|
+
const a11yAttrs = computed(() =>
|
|
89
|
+
props.label ? { role: 'status', 'aria-live': 'polite' } : { 'aria-hidden': 'true' },
|
|
90
|
+
)
|
|
91
|
+
</script>
|