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
package/dist/manifest.js
CHANGED
|
@@ -20,6 +20,7 @@ var DEFAULT_PREFIX = "Ui";
|
|
|
20
20
|
*/
|
|
21
21
|
var COMPONENT_NAMES = [
|
|
22
22
|
"Alert",
|
|
23
|
+
"AppShell",
|
|
23
24
|
"Avatar",
|
|
24
25
|
"Badge",
|
|
25
26
|
"Banner",
|
|
@@ -28,11 +29,14 @@ var COMPONENT_NAMES = [
|
|
|
28
29
|
"Card",
|
|
29
30
|
"Checkbox",
|
|
30
31
|
"CodeBlock",
|
|
32
|
+
"CopyField",
|
|
33
|
+
"DescriptionList",
|
|
31
34
|
"Divider",
|
|
32
35
|
"Dropdown",
|
|
33
36
|
"DropdownItem",
|
|
34
37
|
"DropdownRow",
|
|
35
38
|
"DropdownSubmenu",
|
|
39
|
+
"EmptyState",
|
|
36
40
|
"FileInput",
|
|
37
41
|
"FormField",
|
|
38
42
|
"IconTile",
|
|
@@ -42,6 +46,8 @@ var COMPONENT_NAMES = [
|
|
|
42
46
|
"ListMenuItem",
|
|
43
47
|
"Modal",
|
|
44
48
|
"Numpad",
|
|
49
|
+
"PageHeader",
|
|
50
|
+
"Pagination",
|
|
45
51
|
"Popup",
|
|
46
52
|
"ProgressBar",
|
|
47
53
|
"Prompt",
|
|
@@ -49,10 +55,15 @@ var COMPONENT_NAMES = [
|
|
|
49
55
|
"SectionHeading",
|
|
50
56
|
"Segmented",
|
|
51
57
|
"Select",
|
|
58
|
+
"Sidebar",
|
|
59
|
+
"SidebarGroup",
|
|
60
|
+
"SidebarItem",
|
|
52
61
|
"Slider",
|
|
53
62
|
"Spinner",
|
|
63
|
+
"StatCard",
|
|
54
64
|
"Stepper",
|
|
55
65
|
"Table",
|
|
66
|
+
"Tabs",
|
|
56
67
|
"ThemeToggle",
|
|
57
68
|
"Toast",
|
|
58
69
|
"Toggle",
|
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.js"],"sourcesContent":["/**\n * Component manifest — the single list of what Numori UI ships.\n *\n * Kept as plain data (no imports) so it can be consumed by things that must\n * not pull Vue or any `.vue` file into their graph: the Nuxt module and the\n * Vite plugin both run in Node at config time and only need names and paths.\n *\n * `src/components/index.js` holds the matching real imports for bundling. The\n * two are cross-checked by `scripts/verify.mjs`, so a component added in one\n * place and forgotten in the other fails the build rather than shipping\n * half-registered.\n */\n\n/** Default prefix for registered component names, e.g. `Ui` -> `<UiButton>`. */\nexport const DEFAULT_PREFIX = 'Ui'\n\n/**\n * Base names of every shipped component, without prefix or extension.\n * Order is alphabetical, matching the files on disk.\n * @type {string[]}\n */\nexport const COMPONENT_NAMES = [\n 'Alert',\n 'Avatar',\n 'Badge',\n 'Banner',\n 'Breadcrumb',\n 'Button',\n 'Card',\n 'Checkbox',\n 'CodeBlock',\n 'Divider',\n 'Dropdown',\n 'DropdownItem',\n 'DropdownRow',\n 'DropdownSubmenu',\n 'FileInput',\n 'FormField',\n 'IconTile',\n 'Input',\n 'Kbd',\n 'ListMenu',\n 'ListMenuItem',\n 'Modal',\n 'Numpad',\n 'Popup',\n 'ProgressBar',\n 'Prompt',\n 'Radio',\n 'SectionHeading',\n 'Segmented',\n 'Select',\n 'Slider',\n 'Spinner',\n 'Stepper',\n 'Table',\n 'ThemeToggle',\n 'Toast',\n 'Toggle',\n 'Tooltip',\n]\n\n/**\n * The icon component is listed separately: it lives outside `components/`\n * because it is the framework seam rather than a UI primitive, and the other\n * components import it directly by path.\n */\nexport const ICON_COMPONENT = { name: 'Icon', file: 'icons/Icon.vue' }\n\n/**\n * Every registerable component as `{ name, file }`, where `file` is relative\n * to `src/`. Includes the icon component.\n * @returns {Array<{ name: string, file: string }>}\n */\nexport function componentEntries() {\n return [\n ...COMPONENT_NAMES.map((name) => ({ name, file: `components/${name}.vue` })),\n ICON_COMPONENT,\n ]\n}\n\n/**\n * Apply a prefix to a base component name.\n *\n * The prefix must be non-empty; the entry points validate this. Registering\n * bare names breaks `Button`, whose root is `<component :is=\"tag\">` with `tag`\n * defaulting to `'button'` — Vue capitalises when resolving dynamic components,\n * so a registered `Button` would match its own root element and recurse.\n *\n * @param {string} name Base name, e.g. 'Button'.\n * @param {string} [prefix=DEFAULT_PREFIX] Prefix to apply, e.g. 'Ui' or 'N'.\n * @returns {string} e.g. 'UiButton'\n */\nexport function prefixed(name, prefix = DEFAULT_PREFIX) {\n return `${prefix || ''}${name}`\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,IAAa,iBAAiB;;;;;;AAO9B,IAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,IAAa,iBAAiB;CAAE,MAAM;CAAQ,MAAM;AAAiB;;;;;;AAOrE,SAAgB,mBAAmB;CACjC,OAAO,CACL,GAAG,gBAAgB,KAAK,UAAU;EAAE;EAAM,MAAM,cAAc,KAAK;CAAM,EAAE,GAC3E,cACF;AACF;;;;;;;;;;;;;AAcA,SAAgB,SAAS,MAAM,SAAA,MAAyB;CACtD,OAAO,GAAG,UAAU,KAAK;AAC3B"}
|
|
1
|
+
{"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.js"],"sourcesContent":["/**\n * Component manifest — the single list of what Numori UI ships.\n *\n * Kept as plain data (no imports) so it can be consumed by things that must\n * not pull Vue or any `.vue` file into their graph: the Nuxt module and the\n * Vite plugin both run in Node at config time and only need names and paths.\n *\n * `src/components/index.js` holds the matching real imports for bundling. The\n * two are cross-checked by `scripts/verify.mjs`, so a component added in one\n * place and forgotten in the other fails the build rather than shipping\n * half-registered.\n */\n\n/** Default prefix for registered component names, e.g. `Ui` -> `<UiButton>`. */\nexport const DEFAULT_PREFIX = 'Ui'\n\n/**\n * Base names of every shipped component, without prefix or extension.\n * Order is alphabetical, matching the files on disk.\n * @type {string[]}\n */\nexport const COMPONENT_NAMES = [\n 'Alert',\n 'AppShell',\n 'Avatar',\n 'Badge',\n 'Banner',\n 'Breadcrumb',\n 'Button',\n 'Card',\n 'Checkbox',\n 'CodeBlock',\n 'CopyField',\n 'DescriptionList',\n 'Divider',\n 'Dropdown',\n 'DropdownItem',\n 'DropdownRow',\n 'DropdownSubmenu',\n 'EmptyState',\n 'FileInput',\n 'FormField',\n 'IconTile',\n 'Input',\n 'Kbd',\n 'ListMenu',\n 'ListMenuItem',\n 'Modal',\n 'Numpad',\n 'PageHeader',\n 'Pagination',\n 'Popup',\n 'ProgressBar',\n 'Prompt',\n 'Radio',\n 'SectionHeading',\n 'Segmented',\n 'Select',\n 'Sidebar',\n 'SidebarGroup',\n 'SidebarItem',\n 'Slider',\n 'Spinner',\n 'StatCard',\n 'Stepper',\n 'Table',\n 'Tabs',\n 'ThemeToggle',\n 'Toast',\n 'Toggle',\n 'Tooltip',\n]\n\n/**\n * The icon component is listed separately: it lives outside `components/`\n * because it is the framework seam rather than a UI primitive, and the other\n * components import it directly by path.\n */\nexport const ICON_COMPONENT = { name: 'Icon', file: 'icons/Icon.vue' }\n\n/**\n * Every registerable component as `{ name, file }`, where `file` is relative\n * to `src/`. Includes the icon component.\n * @returns {Array<{ name: string, file: string }>}\n */\nexport function componentEntries() {\n return [\n ...COMPONENT_NAMES.map((name) => ({ name, file: `components/${name}.vue` })),\n ICON_COMPONENT,\n ]\n}\n\n/**\n * Apply a prefix to a base component name.\n *\n * The prefix must be non-empty; the entry points validate this. Registering\n * bare names breaks `Button`, whose root is `<component :is=\"tag\">` with `tag`\n * defaulting to `'button'` — Vue capitalises when resolving dynamic components,\n * so a registered `Button` would match its own root element and recurse.\n *\n * @param {string} name Base name, e.g. 'Button'.\n * @param {string} [prefix=DEFAULT_PREFIX] Prefix to apply, e.g. 'Ui' or 'N'.\n * @returns {string} e.g. 'UiButton'\n */\nexport function prefixed(name, prefix = DEFAULT_PREFIX) {\n return `${prefix || ''}${name}`\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,IAAa,iBAAiB;;;;;;AAO9B,IAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,IAAa,iBAAiB;CAAE,MAAM;CAAQ,MAAM;AAAiB;;;;;;AAOrE,SAAgB,mBAAmB;CACjC,OAAO,CACL,GAAG,gBAAgB,KAAK,UAAU;EAAE;EAAM,MAAM,cAAc,KAAK;CAAM,EAAE,GAC3E,cACF;AACF;;;;;;;;;;;;;AAcA,SAAgB,SAAS,MAAM,SAAA,MAAyB;CACtD,OAAO,GAAG,UAAU,KAAK;AAC3B"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="min-h-dvh bg-gray-50 text-gray-900 dark:bg-gray-950 dark:text-gray-100">
|
|
3
|
+
<!-- Skip link: the first tab stop jumps past the sidebar to the content. -->
|
|
4
|
+
<a
|
|
5
|
+
:href="`#${mainId}`"
|
|
6
|
+
class="sr-only focus:not-sr-only focus:fixed focus:top-3 focus:left-3 focus:z-[60] focus:rounded-lg focus:bg-white focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-card dark:focus:bg-gray-900"
|
|
7
|
+
>{{ skipLabel }}</a
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
<!-- Backdrop behind the off-canvas sidebar on small screens -->
|
|
11
|
+
<Transition
|
|
12
|
+
enter-active-class="transition-opacity duration-200 motion-reduce:transition-none"
|
|
13
|
+
enter-from-class="opacity-0"
|
|
14
|
+
leave-active-class="transition-opacity duration-200 motion-reduce:transition-none"
|
|
15
|
+
leave-to-class="opacity-0"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
v-if="hasSidebar && isOpen"
|
|
19
|
+
class="fixed inset-0 z-40 bg-gray-950/50 backdrop-blur-sm lg:hidden"
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
@click="close"
|
|
22
|
+
/>
|
|
23
|
+
</Transition>
|
|
24
|
+
|
|
25
|
+
<aside
|
|
26
|
+
v-if="hasSidebar"
|
|
27
|
+
:id="sidebarId"
|
|
28
|
+
class="fixed inset-y-0 left-0 z-50 flex flex-col border-r border-gray-200 bg-white transition-transform duration-200 ease-out motion-reduce:transition-none lg:translate-x-0 dark:border-gray-800 dark:bg-gray-900"
|
|
29
|
+
:class="[widthClass, isOpen ? 'translate-x-0' : '-translate-x-full']"
|
|
30
|
+
:inert="!isDesktop && !isOpen ? true : undefined"
|
|
31
|
+
>
|
|
32
|
+
<slot name="sidebar" :close="close" />
|
|
33
|
+
</aside>
|
|
34
|
+
|
|
35
|
+
<div class="flex min-h-dvh flex-col" :class="hasSidebar ? offsetClass : ''">
|
|
36
|
+
<header
|
|
37
|
+
v-if="$slots.header || hasSidebar"
|
|
38
|
+
class="sticky top-0 z-30 flex h-14 shrink-0 items-center gap-3 border-b border-gray-200 bg-white/80 px-4 backdrop-blur sm:px-6 dark:border-gray-800 dark:bg-gray-900/80"
|
|
39
|
+
>
|
|
40
|
+
<button
|
|
41
|
+
v-if="hasSidebar"
|
|
42
|
+
type="button"
|
|
43
|
+
class="-ml-1 inline-flex size-9 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 lg:hidden dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100"
|
|
44
|
+
:aria-label="menuLabel"
|
|
45
|
+
:aria-expanded="isOpen ? 'true' : 'false'"
|
|
46
|
+
:aria-controls="sidebarId"
|
|
47
|
+
@click="toggle"
|
|
48
|
+
>
|
|
49
|
+
<UiIcon name="mdi:menu" class="size-5" />
|
|
50
|
+
</button>
|
|
51
|
+
<div class="flex min-w-0 flex-1 items-center gap-3">
|
|
52
|
+
<slot name="header" :toggle="toggle" :open="isOpen" />
|
|
53
|
+
</div>
|
|
54
|
+
</header>
|
|
55
|
+
|
|
56
|
+
<main :id="mainId" tabindex="-1" class="flex-1 focus:outline-none">
|
|
57
|
+
<div :class="contentClass">
|
|
58
|
+
<slot />
|
|
59
|
+
</div>
|
|
60
|
+
</main>
|
|
61
|
+
|
|
62
|
+
<footer
|
|
63
|
+
v-if="$slots.footer"
|
|
64
|
+
class="border-t border-gray-200 px-4 py-4 text-sm text-gray-500 sm:px-6 dark:border-gray-800 dark:text-gray-400"
|
|
65
|
+
>
|
|
66
|
+
<slot name="footer" />
|
|
67
|
+
</footer>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script setup>
|
|
73
|
+
/**
|
|
74
|
+
* UiAppShell — the page frame for an application: a sidebar, a sticky top bar
|
|
75
|
+
* and a scrolling content area.
|
|
76
|
+
*
|
|
77
|
+
* On large screens (`lg` and up) the sidebar is pinned to the left and the
|
|
78
|
+
* content is offset beside it. Below that it becomes an off-canvas drawer,
|
|
79
|
+
* opened by a menu button the shell adds to the top bar, closed by the
|
|
80
|
+
* backdrop, by Escape, or by any `UiSidebarItem` being chosen. While the drawer
|
|
81
|
+
* is closed on a small screen the sidebar is `inert`, so keyboard users don't
|
|
82
|
+
* tab into links they can't see.
|
|
83
|
+
*
|
|
84
|
+
* The shell owns layout only. Put a `UiSidebar` in `#sidebar`, page chrome in
|
|
85
|
+
* `#header`, and the routed page in the default slot. A skip link to the main
|
|
86
|
+
* content is the first tab stop.
|
|
87
|
+
*
|
|
88
|
+
* The drawer state is uncontrolled by default; bind `v-model:open` to drive it
|
|
89
|
+
* yourself (e.g. to close it on route change).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* <UiAppShell>
|
|
93
|
+
* <template #sidebar>
|
|
94
|
+
* <UiSidebar label="Main">
|
|
95
|
+
* <template #header><strong>Numori CRDT</strong></template>
|
|
96
|
+
* <UiSidebarItem icon="mdi:view-grid" href="/" active>Dashboard</UiSidebarItem>
|
|
97
|
+
* <UiSidebarItem icon="mdi:sync" href="/apps">Apps</UiSidebarItem>
|
|
98
|
+
* </UiSidebar>
|
|
99
|
+
* </template>
|
|
100
|
+
* <template #header>
|
|
101
|
+
* <span class="flex-1" />
|
|
102
|
+
* <UiThemeToggle :is-dark="dark" @toggle="dark = !dark" />
|
|
103
|
+
* </template>
|
|
104
|
+
* <UiPageHeader title="Dashboard" />
|
|
105
|
+
* </UiAppShell>
|
|
106
|
+
*
|
|
107
|
+
* @emits {boolean} update:open — The drawer opened or closed (small screens).
|
|
108
|
+
*
|
|
109
|
+
* @slot sidebar — Sidebar content, usually a `UiSidebar`. Scope: `{ close }`.
|
|
110
|
+
* @slot header — Top bar content beside the menu button. Scope: `{ toggle, open }`.
|
|
111
|
+
* @slot default — Page content.
|
|
112
|
+
* @slot footer — Optional footer below the content.
|
|
113
|
+
*/
|
|
114
|
+
import { computed, onBeforeUnmount, onMounted, provide, ref, useId, useSlots } from 'vue'
|
|
115
|
+
import UiIcon from '../icons/Icon.vue'
|
|
116
|
+
|
|
117
|
+
const props = defineProps({
|
|
118
|
+
/**
|
|
119
|
+
* Drawer state on small screens, for `v-model:open`. Leave unset to let the
|
|
120
|
+
* shell manage it.
|
|
121
|
+
* @type {boolean}
|
|
122
|
+
* @default undefined
|
|
123
|
+
*/
|
|
124
|
+
open: { type: Boolean, default: undefined },
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Sidebar width.
|
|
128
|
+
* @type {string}
|
|
129
|
+
* @default 'md'
|
|
130
|
+
* @values 'sm' | 'md' | 'lg'
|
|
131
|
+
*/
|
|
132
|
+
sidebarWidth: { type: String, default: 'md' },
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Maximum width of the content column. `'none'` lets it fill the space.
|
|
136
|
+
* @type {string}
|
|
137
|
+
* @default '7xl'
|
|
138
|
+
* @values 'none' | '4xl' | '5xl' | '6xl' | '7xl'
|
|
139
|
+
*/
|
|
140
|
+
maxWidth: { type: String, default: '7xl' },
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Pad the content area. Turn off for full-bleed pages that lay out their own
|
|
144
|
+
* spacing.
|
|
145
|
+
* @type {boolean}
|
|
146
|
+
* @default true
|
|
147
|
+
*/
|
|
148
|
+
padded: { type: Boolean, default: true },
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Accessible label for the menu button that opens the drawer.
|
|
152
|
+
* @type {string}
|
|
153
|
+
* @default 'Open navigation'
|
|
154
|
+
*/
|
|
155
|
+
menuLabel: { type: String, default: 'Open navigation' },
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Text of the skip link (visible only when focused).
|
|
159
|
+
* @type {string}
|
|
160
|
+
* @default 'Skip to content'
|
|
161
|
+
*/
|
|
162
|
+
skipLabel: { type: String, default: 'Skip to content' },
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
const emit = defineEmits(['update:open'])
|
|
166
|
+
const slots = useSlots()
|
|
167
|
+
|
|
168
|
+
const baseId = useId()
|
|
169
|
+
const sidebarId = `${baseId}-sidebar`
|
|
170
|
+
const mainId = `${baseId}-main`
|
|
171
|
+
|
|
172
|
+
const hasSidebar = computed(() => !!slots.sidebar)
|
|
173
|
+
|
|
174
|
+
const internalOpen = ref(false)
|
|
175
|
+
const isOpen = computed(() => props.open ?? internalOpen.value)
|
|
176
|
+
|
|
177
|
+
function setOpen(value) {
|
|
178
|
+
internalOpen.value = value
|
|
179
|
+
emit('update:open', value)
|
|
180
|
+
}
|
|
181
|
+
const toggle = () => setOpen(!isOpen.value)
|
|
182
|
+
const close = () => {
|
|
183
|
+
if (isOpen.value) setOpen(false)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// UiSidebarItem closes the drawer when chosen, so navigation on a phone does
|
|
187
|
+
// not leave the drawer covering the page it just opened.
|
|
188
|
+
provide('numori-ui:app-shell', { close })
|
|
189
|
+
|
|
190
|
+
// Assume a desktop layout until mounted, so the server render never marks the
|
|
191
|
+
// sidebar inert on a screen where it is visible.
|
|
192
|
+
const isDesktop = ref(true)
|
|
193
|
+
let media = null
|
|
194
|
+
const onMedia = () => {
|
|
195
|
+
isDesktop.value = media.matches
|
|
196
|
+
if (media.matches) close()
|
|
197
|
+
}
|
|
198
|
+
const onKeydown = (event) => {
|
|
199
|
+
if (event.key === 'Escape' && isOpen.value) close()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
onMounted(() => {
|
|
203
|
+
media = window.matchMedia('(min-width: 64rem)')
|
|
204
|
+
onMedia()
|
|
205
|
+
media.addEventListener('change', onMedia)
|
|
206
|
+
window.addEventListener('keydown', onKeydown)
|
|
207
|
+
})
|
|
208
|
+
onBeforeUnmount(() => {
|
|
209
|
+
media?.removeEventListener('change', onMedia)
|
|
210
|
+
window.removeEventListener('keydown', onKeydown)
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
const widthClass = computed(
|
|
214
|
+
() => ({ sm: 'w-60', md: 'w-64', lg: 'w-72' })[props.sidebarWidth] ?? 'w-64',
|
|
215
|
+
)
|
|
216
|
+
const offsetClass = computed(
|
|
217
|
+
() => ({ sm: 'lg:pl-60', md: 'lg:pl-64', lg: 'lg:pl-72' })[props.sidebarWidth] ?? 'lg:pl-64',
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
const contentClass = computed(() => {
|
|
221
|
+
const width =
|
|
222
|
+
{
|
|
223
|
+
none: '',
|
|
224
|
+
'4xl': 'mx-auto max-w-4xl',
|
|
225
|
+
'5xl': 'mx-auto max-w-5xl',
|
|
226
|
+
'6xl': 'mx-auto max-w-6xl',
|
|
227
|
+
'7xl': 'mx-auto max-w-7xl',
|
|
228
|
+
}[props.maxWidth] ?? 'mx-auto max-w-7xl'
|
|
229
|
+
return [width, props.padded ? 'px-4 py-6 sm:px-6 lg:px-8 lg:py-8' : ''].filter(Boolean).join(' ')
|
|
230
|
+
})
|
|
231
|
+
</script>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<input
|
|
3
|
+
:id="field?.controlId.value"
|
|
3
4
|
type="checkbox"
|
|
5
|
+
:aria-describedby="field?.describedBy.value"
|
|
4
6
|
:checked="modelValue ?? checked"
|
|
5
7
|
:disabled="disabled"
|
|
6
8
|
class="rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500"
|
|
@@ -31,6 +33,7 @@
|
|
|
31
33
|
*/
|
|
32
34
|
import { computed } from 'vue'
|
|
33
35
|
import { checkableSizeClass } from '../internal/controlSizes.js'
|
|
36
|
+
import { useFormField } from '../internal/formField.js'
|
|
34
37
|
const props = defineProps({
|
|
35
38
|
/**
|
|
36
39
|
* Controlled checked state (v-model). Takes priority over `checked` when defined.
|
|
@@ -64,6 +67,8 @@ const props = defineProps({
|
|
|
64
67
|
|
|
65
68
|
const emit = defineEmits(['update:modelValue', 'change'])
|
|
66
69
|
|
|
70
|
+
const field = useFormField()
|
|
71
|
+
|
|
67
72
|
const sizeClass = computed(() => checkableSizeClass(props.size))
|
|
68
73
|
|
|
69
74
|
function onChange(e) {
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="mergedClasses" v-bind="restAttrs">
|
|
3
|
+
<span
|
|
4
|
+
class="min-w-0 flex-1 px-3 text-gray-800 select-all dark:text-gray-200"
|
|
5
|
+
:class="[
|
|
6
|
+
size === 'sm' ? 'py-1.5 text-xs' : 'py-2 text-sm',
|
|
7
|
+
mono ? 'font-mono' : '',
|
|
8
|
+
wrap ? 'break-all whitespace-pre-wrap' : 'truncate',
|
|
9
|
+
masked ? 'tracking-widest text-gray-500 select-none dark:text-gray-400' : '',
|
|
10
|
+
]"
|
|
11
|
+
:aria-label="masked ? hiddenLabel : undefined"
|
|
12
|
+
>{{ masked ? mask : value }}</span
|
|
13
|
+
>
|
|
14
|
+
|
|
15
|
+
<button
|
|
16
|
+
v-if="secret"
|
|
17
|
+
type="button"
|
|
18
|
+
:class="buttonClass"
|
|
19
|
+
:aria-label="masked ? revealLabel : hideLabel"
|
|
20
|
+
:aria-pressed="masked ? 'false' : 'true'"
|
|
21
|
+
@click="toggleReveal"
|
|
22
|
+
>
|
|
23
|
+
<UiIcon :name="masked ? 'mdi:eye-outline' : 'mdi:eye-off-outline'" class="size-4" />
|
|
24
|
+
</button>
|
|
25
|
+
|
|
26
|
+
<button
|
|
27
|
+
type="button"
|
|
28
|
+
:class="buttonClass"
|
|
29
|
+
:aria-label="copied ? copiedLabel : copyLabel"
|
|
30
|
+
@click="copy"
|
|
31
|
+
>
|
|
32
|
+
<UiIcon
|
|
33
|
+
:name="copied ? 'mdi:check' : 'mdi:content-copy'"
|
|
34
|
+
class="size-4"
|
|
35
|
+
:class="copied ? 'text-success-600 dark:text-success-400' : ''"
|
|
36
|
+
/>
|
|
37
|
+
<span v-if="showCopyText" class="hidden sm:inline">{{
|
|
38
|
+
copied ? copiedLabel : copyLabel
|
|
39
|
+
}}</span>
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup>
|
|
45
|
+
/**
|
|
46
|
+
* UiCopyField — a read-only value with a copy button, and optional masking for
|
|
47
|
+
* secrets.
|
|
48
|
+
*
|
|
49
|
+
* For connect URLs, ids, API keys and generated secrets. With `secret`, the
|
|
50
|
+
* value is masked until revealed and the real text is not in the DOM while it
|
|
51
|
+
* is masked, so a screen share or a screenshot does not leak it. Copying works
|
|
52
|
+
* either way.
|
|
53
|
+
*
|
|
54
|
+
* Copy uses the async Clipboard API and fails silently when unavailable (an
|
|
55
|
+
* insecure context or denied permission). Every label is a prop, so nothing
|
|
56
|
+
* is baked into one language.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* <UiFormField label="Connect URL">
|
|
60
|
+
* <UiCopyField value="wss://crdt.numori.app/notes" />
|
|
61
|
+
* </UiFormField>
|
|
62
|
+
*
|
|
63
|
+
* @example A secret shown once
|
|
64
|
+
* <UiCopyField :value="signingKey" secret @copy="markCopied" />
|
|
65
|
+
*
|
|
66
|
+
* @emits {string} copy — The value was copied.
|
|
67
|
+
* @emits {boolean} update:revealed — The secret was revealed or hidden.
|
|
68
|
+
*/
|
|
69
|
+
import { computed, ref, watch } from 'vue'
|
|
70
|
+
import UiIcon from '../icons/Icon.vue'
|
|
71
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
72
|
+
|
|
73
|
+
const props = defineProps({
|
|
74
|
+
/**
|
|
75
|
+
* The text to show and copy.
|
|
76
|
+
* @type {string}
|
|
77
|
+
*/
|
|
78
|
+
value: { type: String, required: true },
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Mask the value until revealed.
|
|
82
|
+
* @type {boolean}
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
secret: { type: Boolean, default: false },
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Revealed state of a secret, for `v-model:revealed`.
|
|
89
|
+
* @type {boolean}
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
revealed: { type: Boolean, default: false },
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Monospace text.
|
|
96
|
+
* @type {boolean}
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
99
|
+
mono: { type: Boolean, default: true },
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Wrap long values onto several lines instead of truncating.
|
|
103
|
+
* @type {boolean}
|
|
104
|
+
* @default false
|
|
105
|
+
*/
|
|
106
|
+
wrap: { type: Boolean, default: false },
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Control size.
|
|
110
|
+
* @type {string}
|
|
111
|
+
* @default 'md'
|
|
112
|
+
* @values 'sm' | 'md'
|
|
113
|
+
*/
|
|
114
|
+
size: { type: String, default: 'md' },
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Show the copy label beside the icon (from `sm` up).
|
|
118
|
+
* @type {boolean}
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
showCopyText: { type: Boolean, default: false },
|
|
122
|
+
|
|
123
|
+
/** @type {string} @default 'Copy' */
|
|
124
|
+
copyLabel: { type: String, default: 'Copy' },
|
|
125
|
+
/** @type {string} @default 'Copied' */
|
|
126
|
+
copiedLabel: { type: String, default: 'Copied' },
|
|
127
|
+
/** @type {string} @default 'Reveal' */
|
|
128
|
+
revealLabel: { type: String, default: 'Reveal' },
|
|
129
|
+
/** @type {string} @default 'Hide' */
|
|
130
|
+
hideLabel: { type: String, default: 'Hide' },
|
|
131
|
+
/** Accessible text read in place of a masked value. @type {string} @default 'Hidden value' */
|
|
132
|
+
hiddenLabel: { type: String, default: 'Hidden value' },
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const emit = defineEmits(['copy', 'update:revealed'])
|
|
136
|
+
|
|
137
|
+
defineOptions({ inheritAttrs: false })
|
|
138
|
+
|
|
139
|
+
const isRevealed = ref(props.revealed)
|
|
140
|
+
watch(
|
|
141
|
+
() => props.revealed,
|
|
142
|
+
(value) => {
|
|
143
|
+
isRevealed.value = value
|
|
144
|
+
},
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
const masked = computed(() => props.secret && !isRevealed.value)
|
|
148
|
+
const mask = computed(() => '•'.repeat(Math.min(Math.max(props.value.length, 8), 24)))
|
|
149
|
+
|
|
150
|
+
function toggleReveal() {
|
|
151
|
+
isRevealed.value = !isRevealed.value
|
|
152
|
+
emit('update:revealed', isRevealed.value)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const copied = ref(false)
|
|
156
|
+
let timer = null
|
|
157
|
+
|
|
158
|
+
async function copy() {
|
|
159
|
+
try {
|
|
160
|
+
await navigator.clipboard.writeText(props.value)
|
|
161
|
+
copied.value = true
|
|
162
|
+
emit('copy', props.value)
|
|
163
|
+
clearTimeout(timer)
|
|
164
|
+
timer = setTimeout(() => {
|
|
165
|
+
copied.value = false
|
|
166
|
+
}, 1600)
|
|
167
|
+
} catch {
|
|
168
|
+
// Clipboard unavailable; the value is still selectable by hand.
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const buttonClass =
|
|
173
|
+
'inline-flex shrink-0 items-center gap-1.5 border-l border-gray-200 px-3 text-xs font-medium text-gray-600 transition-colors hover:bg-white hover:text-gray-900 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-500 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100'
|
|
174
|
+
|
|
175
|
+
const { mergedClasses, restAttrs } = useMergedClasses(
|
|
176
|
+
'flex w-full min-w-0 items-stretch overflow-hidden rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-800/60',
|
|
177
|
+
)
|
|
178
|
+
</script>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dl :class="mergedClasses" v-bind="restAttrs">
|
|
3
|
+
<div v-for="(item, index) in items" :key="item.key ?? item.label ?? index" :class="rowClass">
|
|
4
|
+
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">
|
|
5
|
+
{{ item.label }}
|
|
6
|
+
<span
|
|
7
|
+
v-if="item.hint"
|
|
8
|
+
class="mt-0.5 block text-xs font-normal text-gray-400 dark:text-gray-500"
|
|
9
|
+
>{{ item.hint }}</span
|
|
10
|
+
>
|
|
11
|
+
</dt>
|
|
12
|
+
<dd
|
|
13
|
+
class="min-w-0 text-sm text-gray-900 dark:text-gray-100"
|
|
14
|
+
:class="[
|
|
15
|
+
item.mono ? 'font-mono text-[13px] break-all' : 'break-words',
|
|
16
|
+
layout === 'inline' ? 'mt-1 sm:col-span-2 sm:mt-0' : 'mt-1',
|
|
17
|
+
]"
|
|
18
|
+
>
|
|
19
|
+
<slot name="value" :item="item" :value="item.value">
|
|
20
|
+
<span v-if="isEmpty(item.value)" class="text-gray-400 dark:text-gray-500">{{
|
|
21
|
+
emptyText
|
|
22
|
+
}}</span>
|
|
23
|
+
<template v-else>{{ item.value }}</template>
|
|
24
|
+
</slot>
|
|
25
|
+
</dd>
|
|
26
|
+
</div>
|
|
27
|
+
</dl>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup>
|
|
31
|
+
/**
|
|
32
|
+
* UiDescriptionList — label / value pairs, such as a record's details or a
|
|
33
|
+
* service's settings, rendered as a real `<dl>`.
|
|
34
|
+
*
|
|
35
|
+
* Three layouts:
|
|
36
|
+
* - `inline` (default): label in a narrow left column, value beside it, one
|
|
37
|
+
* pair per row with dividers. Stacks on narrow screens.
|
|
38
|
+
* - `stacked`: label above value, one pair per row.
|
|
39
|
+
* - `grid`: label above value, pairs flowing into two columns.
|
|
40
|
+
*
|
|
41
|
+
* Empty values (`null`, `undefined`, `''`) render `emptyText` so a missing
|
|
42
|
+
* setting reads as deliberate rather than as a rendering bug. Use the `#value`
|
|
43
|
+
* slot to render badges, links or copy fields.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* <UiDescriptionList
|
|
47
|
+
* :items="[
|
|
48
|
+
* { label: 'App id', value: 'notes', mono: true },
|
|
49
|
+
* { label: 'Storage', value: 'postgres' },
|
|
50
|
+
* { label: 'Audience', value: null, hint: 'Optional app/aud claim' },
|
|
51
|
+
* ]"
|
|
52
|
+
* />
|
|
53
|
+
*
|
|
54
|
+
* @example Custom value rendering
|
|
55
|
+
* <UiDescriptionList :items="items">
|
|
56
|
+
* <template #value="{ item, value }">
|
|
57
|
+
* <UiBadge v-if="item.key === 'status'" color="green">{{ value }}</UiBadge>
|
|
58
|
+
* <template v-else>{{ value }}</template>
|
|
59
|
+
* </template>
|
|
60
|
+
* </UiDescriptionList>
|
|
61
|
+
*
|
|
62
|
+
* @slot value — Custom value content. Scope: `{ item, value }`.
|
|
63
|
+
*/
|
|
64
|
+
import { computed } from 'vue'
|
|
65
|
+
import { useMergedClasses } from '../composables/useMergedClasses.js'
|
|
66
|
+
|
|
67
|
+
const props = defineProps({
|
|
68
|
+
/**
|
|
69
|
+
* Pairs to show. Each is `{ label, value, key?, hint?, mono? }`; `mono`
|
|
70
|
+
* renders the value in a monospace font that breaks anywhere (ids, keys).
|
|
71
|
+
* @type {Array<{ label: string, value?: unknown, key?: string, hint?: string, mono?: boolean }>}
|
|
72
|
+
*/
|
|
73
|
+
items: { type: Array, required: true },
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Arrangement of each pair.
|
|
77
|
+
* @type {string}
|
|
78
|
+
* @default 'inline'
|
|
79
|
+
* @values 'inline' | 'stacked' | 'grid'
|
|
80
|
+
*/
|
|
81
|
+
layout: { type: String, default: 'inline' },
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Dividers between rows (ignored by `grid`).
|
|
85
|
+
* @type {boolean}
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
88
|
+
divided: { type: Boolean, default: true },
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Shown in place of an empty value.
|
|
92
|
+
* @type {string}
|
|
93
|
+
* @default '—'
|
|
94
|
+
*/
|
|
95
|
+
emptyText: { type: String, default: '—' },
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
defineOptions({ inheritAttrs: false })
|
|
99
|
+
|
|
100
|
+
const isEmpty = (value) => value === null || value === undefined || value === ''
|
|
101
|
+
|
|
102
|
+
const rowClass = computed(() => {
|
|
103
|
+
if (props.layout === 'grid') return ''
|
|
104
|
+
if (props.layout === 'stacked') return 'py-3 first:pt-0 last:pb-0'
|
|
105
|
+
return 'py-3 first:pt-0 last:pb-0 sm:grid sm:grid-cols-3 sm:gap-4'
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const internalClasses = computed(() => {
|
|
109
|
+
if (props.layout === 'grid') return 'grid gap-x-6 gap-y-4 sm:grid-cols-2'
|
|
110
|
+
return props.divided ? 'divide-y divide-gray-100 dark:divide-gray-800' : ''
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)
|
|
114
|
+
</script>
|