numori-ui 0.4.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 +66 -0
- package/README.md +18 -19
- package/dist/components/AppShell.js +234 -0
- package/dist/components/AppShell.js.map +1 -0
- 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/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/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/Segmented.js +10 -2
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +10 -1
- 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 +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/index.js +97 -80
- package/dist/components/index.js.map +1 -1
- package/dist/icons/mdi.js +10 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +50 -39
- package/dist/index.js.map +1 -1
- package/dist/internal/formField.js +26 -0
- package/dist/internal/formField.js.map +1 -0
- package/dist/manifest.js +11 -0
- package/dist/manifest.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AppShell.vue +231 -0
- package/src/components/Checkbox.vue +5 -0
- package/src/components/CopyField.vue +178 -0
- package/src/components/DescriptionList.vue +114 -0
- package/src/components/EmptyState.vue +107 -0
- package/src/components/FormField.vue +37 -4
- package/src/components/Input.vue +9 -0
- package/src/components/PageHeader.vue +102 -0
- package/src/components/Pagination.vue +199 -0
- package/src/components/Segmented.vue +5 -0
- package/src/components/Select.vue +5 -0
- 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 +148 -18
- package/src/components/Tabs.vue +217 -0
- package/src/components/Toggle.vue +5 -0
- package/src/components/index.js +33 -5
- package/src/icons/mdi.js +10 -0
- package/src/internal/formField.js +23 -0
- package/src/manifest.js +11 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="mergedClasses" v-bind="restAttrs">
|
|
3
|
+
<div
|
|
4
|
+
class="mx-auto flex size-12 items-center justify-center rounded-2xl bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-500"
|
|
5
|
+
aria-hidden="true"
|
|
6
|
+
>
|
|
7
|
+
<slot name="icon"><UiIcon :name="icon" class="size-6" /></slot>
|
|
8
|
+
</div>
|
|
9
|
+
<component :is="headingTag" class="mt-4 text-sm font-semibold text-gray-900 dark:text-gray-100">
|
|
10
|
+
{{ title }}
|
|
11
|
+
</component>
|
|
12
|
+
<p
|
|
13
|
+
v-if="description || $slots.description"
|
|
14
|
+
class="mx-auto mt-1 max-w-sm text-sm text-gray-500 dark:text-gray-400"
|
|
15
|
+
>
|
|
16
|
+
<slot name="description">{{ description }}</slot>
|
|
17
|
+
</p>
|
|
18
|
+
<div v-if="$slots.default" class="mt-5 flex flex-wrap justify-center gap-2">
|
|
19
|
+
<slot />
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
/**
|
|
26
|
+
* UiEmptyState — what a list, table or page shows when there is nothing in it
|
|
27
|
+
* yet: an icon, a short title, one line of explanation and the action that
|
|
28
|
+
* fixes it.
|
|
29
|
+
*
|
|
30
|
+
* Say why it is empty and what to do next, rather than only that it is empty.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* <UiEmptyState
|
|
34
|
+
* icon="mdi:sync"
|
|
35
|
+
* title="No apps yet"
|
|
36
|
+
* description="Register an app to give its clients a place to sync."
|
|
37
|
+
* >
|
|
38
|
+
* <UiButton><UiIcon name="mdi:plus" class="size-4" />New app</UiButton>
|
|
39
|
+
* </UiEmptyState>
|
|
40
|
+
*
|
|
41
|
+
* @slot default — Actions.
|
|
42
|
+
* @slot icon — Custom icon content.
|
|
43
|
+
* @slot description — Rich description (overrides `description`).
|
|
44
|
+
*/
|
|
45
|
+
import { computed } from 'vue'
|
|
46
|
+
import UiIcon from '../icons/Icon.vue'
|
|
47
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
48
|
+
|
|
49
|
+
const props = defineProps({
|
|
50
|
+
/**
|
|
51
|
+
* Short statement of the state, e.g. "No apps yet".
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @default ''
|
|
54
|
+
*/
|
|
55
|
+
title: { type: String, default: '' },
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* One line explaining why, or what to do.
|
|
59
|
+
* @type {string}
|
|
60
|
+
* @default ''
|
|
61
|
+
*/
|
|
62
|
+
description: { type: String, default: '' },
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* MDI icon.
|
|
66
|
+
* @type {string}
|
|
67
|
+
* @default 'mdi:inbox-outline'
|
|
68
|
+
*/
|
|
69
|
+
icon: { type: String, default: 'mdi:inbox-outline' },
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Tighter vertical padding, for use inside cards and tables.
|
|
73
|
+
* @type {boolean}
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
compact: { type: Boolean, default: false },
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Dashed outline around the state, for standalone use on a page.
|
|
80
|
+
* @type {boolean}
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
bordered: { type: Boolean, default: false },
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Element used for the title.
|
|
87
|
+
* @type {string}
|
|
88
|
+
* @default 'h3'
|
|
89
|
+
* @values 'h2' | 'h3' | 'h4' | 'p'
|
|
90
|
+
*/
|
|
91
|
+
headingTag: { type: String, default: 'h3' },
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
defineOptions({ inheritAttrs: false })
|
|
95
|
+
|
|
96
|
+
const internalClasses = computed(() =>
|
|
97
|
+
[
|
|
98
|
+
'text-center',
|
|
99
|
+
props.compact ? 'px-4 py-6' : 'px-6 py-12',
|
|
100
|
+
props.bordered ? 'rounded-2xl border-2 border-dashed border-gray-200 dark:border-gray-700' : '',
|
|
101
|
+
]
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
.join(' '),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)
|
|
107
|
+
</script>
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<label v-if="label" :class="labelClasses">
|
|
3
|
+
<label v-if="label" :id="labelId" :for="controlId" :class="labelClasses">
|
|
4
4
|
{{ label }}
|
|
5
5
|
<span v-if="optional" class="font-normal text-gray-400 dark:text-gray-600">(optional)</span>
|
|
6
6
|
</label>
|
|
7
7
|
<slot />
|
|
8
|
-
<p v-if="hint" class="text-xs text-gray-500 dark:text-gray-500 mt-1">{{ hint }}</p>
|
|
9
|
-
<p v-if="error" class="text-xs text-red-600 dark:text-red-400 mt-1">
|
|
8
|
+
<p v-if="hint" :id="hintId" class="text-xs text-gray-500 dark:text-gray-500 mt-1">{{ hint }}</p>
|
|
9
|
+
<p v-if="error" :id="errorId" class="text-xs text-red-600 dark:text-red-400 mt-1">
|
|
10
|
+
{{ error }}
|
|
11
|
+
</p>
|
|
10
12
|
</div>
|
|
11
13
|
</template>
|
|
12
14
|
|
|
@@ -38,9 +40,15 @@
|
|
|
38
40
|
* <UiToggle v-model="ligatures" />
|
|
39
41
|
* </UiFormField>
|
|
40
42
|
*
|
|
43
|
+
* The label is associated with the control: UiInput, UiSelect, UiToggle,
|
|
44
|
+
* UiCheckbox and UiSegmented pick up the field's id, so the label, hint and
|
|
45
|
+
* error are announced by screen readers and clicking the label focuses the
|
|
46
|
+
* control. For any other control, give it the id passed as `for`.
|
|
47
|
+
*
|
|
41
48
|
* @slot default — Form control (e.g. UiInput, UiSelect, UiToggle)
|
|
42
49
|
*/
|
|
43
|
-
import { computed } from 'vue'
|
|
50
|
+
import { computed, provide, useId } from 'vue'
|
|
51
|
+
import { FORM_FIELD_KEY } from '../internal/formField.js'
|
|
44
52
|
const props = defineProps({
|
|
45
53
|
/**
|
|
46
54
|
* Label text displayed above the input.
|
|
@@ -76,6 +84,31 @@ const props = defineProps({
|
|
|
76
84
|
* @default false
|
|
77
85
|
*/
|
|
78
86
|
inline: { type: Boolean, default: false },
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Id of the control the label points at. Generated when omitted; set it
|
|
90
|
+
* when the control is not a Numori UI form component.
|
|
91
|
+
* @type {string}
|
|
92
|
+
* @default ''
|
|
93
|
+
*/
|
|
94
|
+
for: { type: String, default: '' },
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const uid = useId()
|
|
98
|
+
const controlId = computed(() => props.for || `${uid}-control`)
|
|
99
|
+
const labelId = `${uid}-label`
|
|
100
|
+
const hintId = `${uid}-hint`
|
|
101
|
+
const errorId = `${uid}-error`
|
|
102
|
+
|
|
103
|
+
provide(FORM_FIELD_KEY, {
|
|
104
|
+
controlId,
|
|
105
|
+
labelId,
|
|
106
|
+
describedBy: computed(
|
|
107
|
+
() =>
|
|
108
|
+
[props.hint ? hintId : null, props.error ? errorId : null].filter(Boolean).join(' ') ||
|
|
109
|
+
undefined,
|
|
110
|
+
),
|
|
111
|
+
invalid: computed(() => !!props.error),
|
|
79
112
|
})
|
|
80
113
|
|
|
81
114
|
const labelClasses = computed(() =>
|
package/src/components/Input.vue
CHANGED
|
@@ -43,7 +43,10 @@
|
|
|
43
43
|
<!-- Textarea mode: multi-line text input with custom scrollbar styling -->
|
|
44
44
|
<textarea
|
|
45
45
|
v-if="isTextarea"
|
|
46
|
+
:id="field?.controlId.value"
|
|
46
47
|
ref="inputRef"
|
|
48
|
+
:aria-describedby="field?.describedBy.value"
|
|
49
|
+
:aria-invalid="field?.invalid.value ? 'true' : undefined"
|
|
47
50
|
:value="modelValue"
|
|
48
51
|
:placeholder="placeholder"
|
|
49
52
|
:required="required"
|
|
@@ -71,7 +74,10 @@
|
|
|
71
74
|
|
|
72
75
|
<input
|
|
73
76
|
v-if="!isTextarea"
|
|
77
|
+
:id="field?.controlId.value"
|
|
74
78
|
ref="inputRef"
|
|
79
|
+
:aria-describedby="field?.describedBy.value"
|
|
80
|
+
:aria-invalid="field?.invalid.value ? 'true' : undefined"
|
|
75
81
|
:type="computedType"
|
|
76
82
|
:value="modelValue"
|
|
77
83
|
:placeholder="placeholder"
|
|
@@ -217,6 +223,7 @@
|
|
|
217
223
|
*/
|
|
218
224
|
import { ref, computed, watch, useSlots } from 'vue'
|
|
219
225
|
import UiIcon from '../icons/Icon.vue'
|
|
226
|
+
import { useFormField } from '../internal/formField.js'
|
|
220
227
|
const props = defineProps({
|
|
221
228
|
/**
|
|
222
229
|
* Bound value (v-model).
|
|
@@ -421,6 +428,8 @@ const props = defineProps({
|
|
|
421
428
|
|
|
422
429
|
const emit = defineEmits(['update:modelValue', 'validation'])
|
|
423
430
|
|
|
431
|
+
const field = useFormField()
|
|
432
|
+
|
|
424
433
|
const inputRef = ref(null)
|
|
425
434
|
const passwordVisible = ref(false)
|
|
426
435
|
const touched = ref(false)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="mergedClasses" v-bind="restAttrs">
|
|
3
|
+
<div v-if="$slots.breadcrumb" class="mb-3">
|
|
4
|
+
<slot name="breadcrumb" />
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
|
8
|
+
<div class="min-w-0 flex-1">
|
|
9
|
+
<div class="flex flex-wrap items-center gap-x-3 gap-y-2">
|
|
10
|
+
<component
|
|
11
|
+
:is="headingTag"
|
|
12
|
+
class="min-w-0 truncate text-2xl font-semibold tracking-tight text-gray-900 dark:text-gray-50"
|
|
13
|
+
>
|
|
14
|
+
<slot name="title">{{ title }}</slot>
|
|
15
|
+
</component>
|
|
16
|
+
<slot name="meta" />
|
|
17
|
+
</div>
|
|
18
|
+
<p
|
|
19
|
+
v-if="description || $slots.description"
|
|
20
|
+
class="mt-1 max-w-3xl text-sm text-gray-600 dark:text-gray-400"
|
|
21
|
+
>
|
|
22
|
+
<slot name="description">{{ description }}</slot>
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div v-if="$slots.actions" class="flex shrink-0 flex-wrap items-center gap-2">
|
|
27
|
+
<slot name="actions" />
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup>
|
|
34
|
+
/**
|
|
35
|
+
* UiPageHeader — the title block at the top of an application page: optional
|
|
36
|
+
* breadcrumb, heading, badges, a line of description and the page's actions.
|
|
37
|
+
*
|
|
38
|
+
* Actions sit to the right on wide screens and wrap below the title on narrow
|
|
39
|
+
* ones. The heading is an `<h1>` by default; lower it with `level` when the
|
|
40
|
+
* header sits inside a section that already has one.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* <UiPageHeader title="Apps" description="Every application that syncs through this service.">
|
|
44
|
+
* <template #actions>
|
|
45
|
+
* <UiButton><UiIcon name="mdi:plus" class="size-4" />New app</UiButton>
|
|
46
|
+
* </template>
|
|
47
|
+
* </UiPageHeader>
|
|
48
|
+
*
|
|
49
|
+
* @example With breadcrumb and a status badge
|
|
50
|
+
* <UiPageHeader title="notes">
|
|
51
|
+
* <template #breadcrumb><UiBreadcrumb :items="crumbs" /></template>
|
|
52
|
+
* <template #meta><UiBadge color="green">Active</UiBadge></template>
|
|
53
|
+
* </UiPageHeader>
|
|
54
|
+
*
|
|
55
|
+
* @slot title — Rich title content (overrides `title`).
|
|
56
|
+
* @slot meta — Inline content after the title, such as badges.
|
|
57
|
+
* @slot description — Rich description (overrides `description`).
|
|
58
|
+
* @slot breadcrumb — Content above the title, usually a `UiBreadcrumb`.
|
|
59
|
+
* @slot actions — Buttons for the page's primary actions.
|
|
60
|
+
*/
|
|
61
|
+
import { computed } from 'vue'
|
|
62
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
63
|
+
|
|
64
|
+
const props = defineProps({
|
|
65
|
+
/**
|
|
66
|
+
* Page title.
|
|
67
|
+
* @type {string}
|
|
68
|
+
* @default ''
|
|
69
|
+
*/
|
|
70
|
+
title: { type: String, default: '' },
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* One line explaining the page.
|
|
74
|
+
* @type {string}
|
|
75
|
+
* @default ''
|
|
76
|
+
*/
|
|
77
|
+
description: { type: String, default: '' },
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Heading level of the title.
|
|
81
|
+
* @type {number}
|
|
82
|
+
* @default 1
|
|
83
|
+
* @values 1 | 2 | 3
|
|
84
|
+
*/
|
|
85
|
+
level: { type: Number, default: 1 },
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Draw a rule below the header.
|
|
89
|
+
* @type {boolean}
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
bordered: { type: Boolean, default: false },
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
defineOptions({ inheritAttrs: false })
|
|
96
|
+
|
|
97
|
+
const headingTag = computed(() => `h${[1, 2, 3].includes(props.level) ? props.level : 1}`)
|
|
98
|
+
|
|
99
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() =>
|
|
100
|
+
props.bordered ? 'mb-6 border-b border-gray-200 pb-5 dark:border-gray-800' : 'mb-6',
|
|
101
|
+
)
|
|
102
|
+
</script>
|
|
@@ -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>
|
|
@@ -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' : '']"
|
|
@@ -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>
|