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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","names":[],"sources":["../../src/components/Avatar.vue"],"sourcesContent":["<template>\n <!-- Circular avatar container with image or fallback icon -->\n <div\n class=\"rounded-full flex items-center justify-center overflow-hidden shrink-0\"\n :class=\"[sizeClass, bgClass, ringClass]\"\n >\n <img
|
|
1
|
+
{"version":3,"file":"Avatar.js","names":[],"sources":["../../src/components/Avatar.vue"],"sourcesContent":["<template>\n <!-- Circular avatar container with an image, initials or a fallback icon -->\n <div\n class=\"rounded-full flex items-center justify-center overflow-hidden shrink-0\"\n :class=\"[sizeClass, bgClass, ringClass]\"\n :role=\"showImage ? undefined : 'img'\"\n :aria-label=\"showImage ? undefined : alt\"\n >\n <img\n v-if=\"showImage\"\n ref=\"imgRef\"\n :src=\"src\"\n :alt=\"alt\"\n class=\"w-full h-full object-cover\"\n @error=\"failed = true\"\n />\n <span\n v-else-if=\"shownInitials\"\n class=\"font-semibold leading-none tracking-tight select-none\"\n :class=\"textSizeClass\"\n aria-hidden=\"true\"\n >{{ shownInitials }}</span\n >\n <UiIcon v-else :name=\"fallbackIcon\" :class=\"iconSizeClass\" aria-hidden=\"true\" />\n </div>\n</template>\n\n<script setup>\n/**\n * UiAvatar — Circular avatar component displaying an image, initials or a fallback icon.\n *\n * When a `src` URL is provided, renders a cover-fit image; if the image fails\n * to load, it falls back rather than showing a broken-image glyph. Without an\n * image it shows `initials` (at most two characters, upper-cased), and without\n * those a configurable fallback icon, on a colored background. Supports five\n * sizes, two color themes for the fallback state, and an optional ring border.\n *\n * Without an image the avatar is exposed as `role=\"img\"` named by `alt`, so\n * pass the person's name there rather than the default.\n *\n * @example Image avatar\n * <UiAvatar src=\"/img/user.jpg\" alt=\"Jane Doe\" size=\"lg\" />\n *\n * @example Initials\n * <UiAvatar initials=\"JD\" alt=\"Jane Doe\" />\n *\n * @example Fallback icon avatar with ring\n * <UiAvatar size=\"md\" color=\"primary\" ring />\n *\n * @example Small gray avatar with custom icon\n * <UiAvatar size=\"sm\" color=\"gray\" fallback-icon=\"mdi:account-group\" />\n */\nimport { computed, onMounted, ref, watch } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\n\nconst props = defineProps({\n /**\n * Image source URL. When empty (or it fails to load), initials or the\n * fallback icon are shown.\n * @type {string}\n * @default ''\n */\n src: { type: String, default: '' },\n /**\n * Alt text for the avatar image (accessibility), and the accessible name\n * when initials or the icon are shown.\n * @type {string}\n * @default 'Avatar'\n */\n alt: { type: String, default: 'Avatar' },\n /**\n * Initials shown when there is no image. Trimmed to two characters and\n * upper-cased.\n * @type {string}\n * @default ''\n */\n initials: { type: String, default: '' },\n /**\n * Avatar size controlling width, height, and icon dimensions.\n * @type {string}\n * @default 'md'\n * @values 'xs' (24px) | 'sm' (32px) | 'md' (36px) | 'lg' (48px) | 'xl' (64px)\n */\n size: { type: String, default: 'md' },\n /**\n * MDI icon name used when there is neither an image nor initials.\n * @type {string}\n * @default 'mdi:account'\n */\n fallbackIcon: { type: String, default: 'mdi:account' },\n /**\n * Background color theme for the fallback icon state.\n * @type {string}\n * @default 'primary'\n * @values 'primary' | 'gray'\n */\n color: { type: String, default: 'primary' },\n /**\n * Show a ring border around the avatar for emphasis.\n * @type {boolean}\n * @default false\n */\n ring: { type: Boolean, default: false },\n})\n\n// A failed load falls back to initials or the icon; a new src retries.\nconst failed = ref(false)\nconst imgRef = ref(null)\nwatch(\n () => props.src,\n () => (failed.value = false),\n)\n// Server-rendered images can fail before hydration attaches `@error`, so the\n// event is never seen. Check once on mount for an image that already failed.\nonMounted(() => {\n const img = imgRef.value\n if (img && img.complete && img.naturalWidth === 0) failed.value = true\n})\nconst showImage = computed(() => !!props.src && !failed.value)\n\nconst shownInitials = computed(() => [...props.initials.trim()].slice(0, 2).join('').toUpperCase())\n\nconst sizeClass = computed(() => {\n const map = { xs: 'w-6 h-6', sm: 'w-8 h-8', md: 'w-9 h-9', lg: 'w-12 h-12', xl: 'w-16 h-16' }\n return map[props.size] || map.md\n})\n\nconst iconSizeClass = computed(() => {\n const map = { xs: 'w-3 h-3', sm: 'w-4 h-4', md: 'w-5 h-5', lg: 'w-6 h-6', xl: 'w-8 h-8' }\n return map[props.size] || map.md\n})\n\nconst textSizeClass = computed(() => {\n const map = { xs: 'text-[10px]', sm: 'text-xs', md: 'text-sm', lg: 'text-base', xl: 'text-xl' }\n return map[props.size] || map.md\n})\n\n// Only apply background color when not showing an image\nconst bgClass = computed(() => {\n if (showImage.value) return ''\n const map = {\n primary: 'bg-primary-100 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400',\n gray: 'bg-gray-200 dark:bg-gray-700 text-gray-500 dark:text-gray-400',\n }\n return map[props.color] || map.primary\n})\n\nconst ringClass = computed(() =>\n props.ring ? 'ring-2 ring-primary-200 dark:ring-primary-800 shadow-sm' : '',\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDA,MAAM,QAAQ;EAmDd,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,SAAS,IAAI,IAAI;EACvB,YACQ,MAAM,WACL,OAAO,QAAQ,KACxB;EAGA,gBAAgB;GACd,MAAM,MAAM,OAAO;GACnB,IAAI,OAAO,IAAI,YAAY,IAAI,iBAAiB,GAAG,OAAO,QAAQ;EACpE,CAAC;EACD,MAAM,YAAY,eAAe,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,KAAK;EAE7D,MAAM,gBAAgB,eAAe,CAAC,GAAG,MAAM,SAAS,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC;EAElG,MAAM,YAAY,eAAe;GAC/B,MAAM,MAAM;IAAE,IAAI;IAAW,IAAI;IAAW,IAAI;IAAW,IAAI;IAAa,IAAI;GAAY;GAC5F,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAED,MAAM,gBAAgB,eAAe;GACnC,MAAM,MAAM;IAAE,IAAI;IAAW,IAAI;IAAW,IAAI;IAAW,IAAI;IAAW,IAAI;GAAU;GACxF,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAED,MAAM,gBAAgB,eAAe;GACnC,MAAM,MAAM;IAAE,IAAI;IAAe,IAAI;IAAW,IAAI;IAAW,IAAI;IAAa,IAAI;GAAU;GAC9F,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAGD,MAAM,UAAU,eAAe;GAC7B,IAAI,UAAU,OAAO,OAAO;GAC5B,MAAM,MAAM;IACV,SAAS;IACT,MAAM;GACR;GACA,OAAO,IAAI,MAAM,UAAU,IAAI;EACjC,CAAC;EAED,MAAM,YAAY,eAChB,MAAM,OAAO,4DAA4D,EAC3E;;GAnJE,OAAA,UAAA,GAAA,mBAsBM,OAAA;IArBJ,OAAK,eAAA,CAAC,0EAAwE;KACrE,UAAA;KAAW,QAAA;KAAS,UAAA;IAAS,CAAA,CAAA;IACrC,MAAM,UAAA,QAAY,KAAA,IAAS;IAC3B,cAAY,UAAA,QAAY,KAAA,IAAY,QAAA;GAG7B,GAAA,CAAA,UAAA,SADR,UAAA,GAAA,mBAOE,OAAA;;IALI,SAAA;IAAJ,KAAI;IACH,KAAK,QAAA;IACL,KAAK,QAAA;IACN,OAAM;IACL,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,OAAA,QAAM;GAGH,GAAA,MAAA,IAAA,UAAA,KAAA,cAAA,SADb,UAAA,GAAA,mBAMC,QAAA;;IAJC,OAAK,eAAA,CAAC,yDACE,cAAA,KAAa,CAAA;IACrB,eAAY;GACR,GAAA,gBAAA,cAAA,KAAa,GAAA,CAAA,MAEnB,UAAA,GAAA,YAAgF,aAAA;;IAAhE,MAAM,QAAA;IAAe,OAAK,eAAE,cAAA,KAAa;IAAE,eAAY"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { checkableSizeClass } from "../internal/controlSizes.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useFormField } from "../internal/formField.js";
|
|
3
|
+
import { computed, createElementBlock, normalizeClass, openBlock, unref } from "vue";
|
|
3
4
|
//#region src/components/Checkbox.vue
|
|
4
|
-
var _hoisted_1 = [
|
|
5
|
+
var _hoisted_1 = [
|
|
6
|
+
"id",
|
|
7
|
+
"aria-describedby",
|
|
8
|
+
"checked",
|
|
9
|
+
"disabled"
|
|
10
|
+
];
|
|
5
11
|
var _sfc_main = {
|
|
6
12
|
__name: "Checkbox",
|
|
7
13
|
props: {
|
|
@@ -66,6 +72,7 @@ var _sfc_main = {
|
|
|
66
72
|
*/
|
|
67
73
|
const props = __props;
|
|
68
74
|
const emit = __emit;
|
|
75
|
+
const field = useFormField();
|
|
69
76
|
const sizeClass = computed(() => checkableSizeClass(props.size));
|
|
70
77
|
function onChange(e) {
|
|
71
78
|
emit("update:modelValue", e.target.checked);
|
|
@@ -73,7 +80,9 @@ var _sfc_main = {
|
|
|
73
80
|
}
|
|
74
81
|
return (_ctx, _cache) => {
|
|
75
82
|
return openBlock(), createElementBlock("input", {
|
|
83
|
+
id: unref(field)?.controlId.value,
|
|
76
84
|
type: "checkbox",
|
|
85
|
+
"aria-describedby": unref(field)?.describedBy.value,
|
|
77
86
|
checked: __props.modelValue ?? __props.checked,
|
|
78
87
|
disabled: __props.disabled,
|
|
79
88
|
class: normalizeClass(["rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500", sizeClass.value]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.vue"],"sourcesContent":["<template>\n <input\n type=\"checkbox\"\n :checked=\"modelValue ?? checked\"\n :disabled=\"disabled\"\n class=\"rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500\"\n :class=\"sizeClass\"\n @change=\"onChange\"\n />\n</template>\n\n<script setup>\n/**\n * UiCheckbox — Simple styled checkbox input with configurable size.\n *\n * Wraps a native `<input type=\"checkbox\">` with consistent Tailwind styling,\n * primary color accent, and focus ring. Supports both v-model (`modelValue`)\n * and uncontrolled (`checked`) usage patterns.\n *\n * @example Basic v-model checkbox\n * <UiCheckbox v-model=\"agreed\" />\n *\n * @example Small disabled checkbox\n * <UiCheckbox v-model=\"locked\" size=\"sm\" disabled />\n *\n * @example Uncontrolled with checked prop\n * <UiCheckbox :checked=\"true\" @change=\"handleChange\" />\n *\n * @emits {boolean} update:modelValue — Emitted when the checked state changes (v-model)\n * @emits {Event} change — Emitted with the native change event\n */\nimport { computed } from 'vue'\nimport { checkableSizeClass } from '../internal/controlSizes.js'\nconst props = defineProps({\n /**\n * Controlled checked state (v-model). Takes priority over `checked` when defined.\n * @type {boolean}\n * @default undefined\n */\n modelValue: { type: Boolean, default: undefined },\n\n /**\n * Uncontrolled initial checked state (used when modelValue is undefined).\n * @type {boolean}\n * @default false\n */\n checked: { type: Boolean, default: false },\n\n /**\n * Disabled state — dims the checkbox and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Checkbox size controlling width and height.\n * @type {string}\n * @default 'md'\n * @values 'sm' (3.5×3.5) | 'md' (4×4) | 'lg' (5×5)\n */\n size: { type: String, default: 'md' },\n})\n\nconst emit = defineEmits(['update:modelValue', 'change'])\n\nconst sizeClass = computed(() => checkableSizeClass(props.size))\n\nfunction onChange(e) {\n emit('update:modelValue', e.target.checked)\n emit('change', e)\n}\n</script>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.vue"],"sourcesContent":["<template>\n <input\n :id=\"field?.controlId.value\"\n type=\"checkbox\"\n :aria-describedby=\"field?.describedBy.value\"\n :checked=\"modelValue ?? checked\"\n :disabled=\"disabled\"\n class=\"rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500\"\n :class=\"sizeClass\"\n @change=\"onChange\"\n />\n</template>\n\n<script setup>\n/**\n * UiCheckbox — Simple styled checkbox input with configurable size.\n *\n * Wraps a native `<input type=\"checkbox\">` with consistent Tailwind styling,\n * primary color accent, and focus ring. Supports both v-model (`modelValue`)\n * and uncontrolled (`checked`) usage patterns.\n *\n * @example Basic v-model checkbox\n * <UiCheckbox v-model=\"agreed\" />\n *\n * @example Small disabled checkbox\n * <UiCheckbox v-model=\"locked\" size=\"sm\" disabled />\n *\n * @example Uncontrolled with checked prop\n * <UiCheckbox :checked=\"true\" @change=\"handleChange\" />\n *\n * @emits {boolean} update:modelValue — Emitted when the checked state changes (v-model)\n * @emits {Event} change — Emitted with the native change event\n */\nimport { computed } from 'vue'\nimport { checkableSizeClass } from '../internal/controlSizes.js'\nimport { useFormField } from '../internal/formField.js'\nconst props = defineProps({\n /**\n * Controlled checked state (v-model). Takes priority over `checked` when defined.\n * @type {boolean}\n * @default undefined\n */\n modelValue: { type: Boolean, default: undefined },\n\n /**\n * Uncontrolled initial checked state (used when modelValue is undefined).\n * @type {boolean}\n * @default false\n */\n checked: { type: Boolean, default: false },\n\n /**\n * Disabled state — dims the checkbox and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Checkbox size controlling width and height.\n * @type {string}\n * @default 'md'\n * @values 'sm' (3.5×3.5) | 'md' (4×4) | 'lg' (5×5)\n */\n size: { type: String, default: 'md' },\n})\n\nconst emit = defineEmits(['update:modelValue', 'change'])\n\nconst field = useFormField()\n\nconst sizeClass = computed(() => checkableSizeClass(props.size))\n\nfunction onChange(e) {\n emit('update:modelValue', e.target.checked)\n emit('change', e)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoCA,MAAM,QAAQ;EA+Bd,MAAM,OAAO;EAEb,MAAM,QAAQ,aAAa;EAE3B,MAAM,YAAY,eAAe,mBAAmB,MAAM,IAAI,CAAC;EAE/D,SAAS,SAAS,GAAG;GACnB,KAAK,qBAAqB,EAAE,OAAO,OAAO;GAC1C,KAAK,UAAU,CAAC;EAClB;;GA3EE,OAAA,UAAA,GAAA,mBASE,SAAA;IARC,IAAI,MAAA,KAAA,CAAK,EAAE,UAAU;IACtB,MAAK;IACJ,oBAAkB,MAAA,KAAA,CAAK,EAAE,YAAY;IACrC,SAAS,QAAA,cAAc,QAAA;IACvB,UAAU,QAAA;IACX,OAAK,eAAA,CAAC,wFACE,UAAA,KAAS,CAAA;IACR"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { useMergedClasses } from "../composables/useMergedClasses.js";
|
|
3
|
+
import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, mergeProps, normalizeClass, openBlock, ref, toDisplayString, unref, watch } from "vue";
|
|
4
|
+
//#region src/components/CopyField.vue
|
|
5
|
+
var _hoisted_1 = ["aria-label"];
|
|
6
|
+
var _hoisted_2 = ["aria-label", "aria-pressed"];
|
|
7
|
+
var _hoisted_3 = ["aria-label"];
|
|
8
|
+
var _hoisted_4 = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "hidden sm:inline"
|
|
11
|
+
};
|
|
12
|
+
var buttonClass = "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";
|
|
13
|
+
var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
14
|
+
__name: "CopyField",
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* The text to show and copy.
|
|
18
|
+
* @type {string}
|
|
19
|
+
*/
|
|
20
|
+
value: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Mask the value until revealed.
|
|
26
|
+
* @type {boolean}
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
secret: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Revealed state of a secret, for `v-model:revealed`.
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
revealed: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Monospace text.
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
mono: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: true
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Wrap long values onto several lines instead of truncating.
|
|
53
|
+
* @type {boolean}
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
wrap: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Control size.
|
|
62
|
+
* @type {string}
|
|
63
|
+
* @default 'md'
|
|
64
|
+
* @values 'sm' | 'md'
|
|
65
|
+
*/
|
|
66
|
+
size: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: "md"
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Show the copy label beside the icon (from `sm` up).
|
|
72
|
+
* @type {boolean}
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
showCopyText: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
79
|
+
/** @type {string} @default 'Copy' */
|
|
80
|
+
copyLabel: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: "Copy"
|
|
83
|
+
},
|
|
84
|
+
/** @type {string} @default 'Copied' */
|
|
85
|
+
copiedLabel: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: "Copied"
|
|
88
|
+
},
|
|
89
|
+
/** @type {string} @default 'Reveal' */
|
|
90
|
+
revealLabel: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: "Reveal"
|
|
93
|
+
},
|
|
94
|
+
/** @type {string} @default 'Hide' */
|
|
95
|
+
hideLabel: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: "Hide"
|
|
98
|
+
},
|
|
99
|
+
/** Accessible text read in place of a masked value. @type {string} @default 'Hidden value' */
|
|
100
|
+
hiddenLabel: {
|
|
101
|
+
type: String,
|
|
102
|
+
default: "Hidden value"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
emits: ["copy", "update:revealed"],
|
|
106
|
+
setup(__props, { emit: __emit }) {
|
|
107
|
+
/**
|
|
108
|
+
* UiCopyField — a read-only value with a copy button, and optional masking for
|
|
109
|
+
* secrets.
|
|
110
|
+
*
|
|
111
|
+
* For connect URLs, ids, API keys and generated secrets. With `secret`, the
|
|
112
|
+
* value is masked until revealed and the real text is not in the DOM while it
|
|
113
|
+
* is masked, so a screen share or a screenshot does not leak it. Copying works
|
|
114
|
+
* either way.
|
|
115
|
+
*
|
|
116
|
+
* Copy uses the async Clipboard API and fails silently when unavailable (an
|
|
117
|
+
* insecure context or denied permission). Every label is a prop, so nothing
|
|
118
|
+
* is baked into one language.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* <UiFormField label="Connect URL">
|
|
122
|
+
* <UiCopyField value="wss://crdt.numori.app/notes" />
|
|
123
|
+
* </UiFormField>
|
|
124
|
+
*
|
|
125
|
+
* @example A secret shown once
|
|
126
|
+
* <UiCopyField :value="signingKey" secret @copy="markCopied" />
|
|
127
|
+
*
|
|
128
|
+
* @emits {string} copy — The value was copied.
|
|
129
|
+
* @emits {boolean} update:revealed — The secret was revealed or hidden.
|
|
130
|
+
*/
|
|
131
|
+
const props = __props;
|
|
132
|
+
const emit = __emit;
|
|
133
|
+
const isRevealed = ref(props.revealed);
|
|
134
|
+
watch(() => props.revealed, (value) => {
|
|
135
|
+
isRevealed.value = value;
|
|
136
|
+
});
|
|
137
|
+
const masked = computed(() => props.secret && !isRevealed.value);
|
|
138
|
+
const mask = computed(() => "•".repeat(Math.min(Math.max(props.value.length, 8), 24)));
|
|
139
|
+
function toggleReveal() {
|
|
140
|
+
isRevealed.value = !isRevealed.value;
|
|
141
|
+
emit("update:revealed", isRevealed.value);
|
|
142
|
+
}
|
|
143
|
+
const copied = ref(false);
|
|
144
|
+
let timer = null;
|
|
145
|
+
async function copy() {
|
|
146
|
+
try {
|
|
147
|
+
await navigator.clipboard.writeText(props.value);
|
|
148
|
+
copied.value = true;
|
|
149
|
+
emit("copy", props.value);
|
|
150
|
+
clearTimeout(timer);
|
|
151
|
+
timer = setTimeout(() => {
|
|
152
|
+
copied.value = false;
|
|
153
|
+
}, 1600);
|
|
154
|
+
} catch {}
|
|
155
|
+
}
|
|
156
|
+
const { mergedClasses, restAttrs } = useMergedClasses("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");
|
|
157
|
+
return (_ctx, _cache) => {
|
|
158
|
+
return openBlock(), createElementBlock("div", mergeProps({ class: unref(mergedClasses) }, unref(restAttrs)), [
|
|
159
|
+
createElementVNode("span", {
|
|
160
|
+
class: normalizeClass(["min-w-0 flex-1 px-3 text-gray-800 select-all dark:text-gray-200", [
|
|
161
|
+
__props.size === "sm" ? "py-1.5 text-xs" : "py-2 text-sm",
|
|
162
|
+
__props.mono ? "font-mono" : "",
|
|
163
|
+
__props.wrap ? "break-all whitespace-pre-wrap" : "truncate",
|
|
164
|
+
masked.value ? "tracking-widest text-gray-500 select-none dark:text-gray-400" : ""
|
|
165
|
+
]]),
|
|
166
|
+
"aria-label": masked.value ? __props.hiddenLabel : void 0
|
|
167
|
+
}, toDisplayString(masked.value ? mask.value : __props.value), 11, _hoisted_1),
|
|
168
|
+
__props.secret ? (openBlock(), createElementBlock("button", {
|
|
169
|
+
key: 0,
|
|
170
|
+
type: "button",
|
|
171
|
+
class: normalizeClass(buttonClass),
|
|
172
|
+
"aria-label": masked.value ? __props.revealLabel : __props.hideLabel,
|
|
173
|
+
"aria-pressed": masked.value ? "false" : "true",
|
|
174
|
+
onClick: toggleReveal
|
|
175
|
+
}, [createVNode(_sfc_main$1, {
|
|
176
|
+
name: masked.value ? "mdi:eye-outline" : "mdi:eye-off-outline",
|
|
177
|
+
class: "size-4"
|
|
178
|
+
}, null, 8, ["name"])], 8, _hoisted_2)) : createCommentVNode("", true),
|
|
179
|
+
createElementVNode("button", {
|
|
180
|
+
type: "button",
|
|
181
|
+
class: normalizeClass(buttonClass),
|
|
182
|
+
"aria-label": copied.value ? __props.copiedLabel : __props.copyLabel,
|
|
183
|
+
onClick: copy
|
|
184
|
+
}, [createVNode(_sfc_main$1, {
|
|
185
|
+
name: copied.value ? "mdi:check" : "mdi:content-copy",
|
|
186
|
+
class: normalizeClass(["size-4", copied.value ? "text-success-600 dark:text-success-400" : ""])
|
|
187
|
+
}, null, 8, ["name", "class"]), __props.showCopyText ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(copied.value ? __props.copiedLabel : __props.copyLabel), 1)) : createCommentVNode("", true)], 8, _hoisted_3)
|
|
188
|
+
], 16);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
//#endregion
|
|
193
|
+
export { _sfc_main as default };
|
|
194
|
+
|
|
195
|
+
//# sourceMappingURL=CopyField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyField.js","names":[],"sources":["../../src/components/CopyField.vue"],"sourcesContent":["<template>\n <div :class=\"mergedClasses\" v-bind=\"restAttrs\">\n <span\n class=\"min-w-0 flex-1 px-3 text-gray-800 select-all dark:text-gray-200\"\n :class=\"[\n size === 'sm' ? 'py-1.5 text-xs' : 'py-2 text-sm',\n mono ? 'font-mono' : '',\n wrap ? 'break-all whitespace-pre-wrap' : 'truncate',\n masked ? 'tracking-widest text-gray-500 select-none dark:text-gray-400' : '',\n ]\"\n :aria-label=\"masked ? hiddenLabel : undefined\"\n >{{ masked ? mask : value }}</span\n >\n\n <button\n v-if=\"secret\"\n type=\"button\"\n :class=\"buttonClass\"\n :aria-label=\"masked ? revealLabel : hideLabel\"\n :aria-pressed=\"masked ? 'false' : 'true'\"\n @click=\"toggleReveal\"\n >\n <UiIcon :name=\"masked ? 'mdi:eye-outline' : 'mdi:eye-off-outline'\" class=\"size-4\" />\n </button>\n\n <button\n type=\"button\"\n :class=\"buttonClass\"\n :aria-label=\"copied ? copiedLabel : copyLabel\"\n @click=\"copy\"\n >\n <UiIcon\n :name=\"copied ? 'mdi:check' : 'mdi:content-copy'\"\n class=\"size-4\"\n :class=\"copied ? 'text-success-600 dark:text-success-400' : ''\"\n />\n <span v-if=\"showCopyText\" class=\"hidden sm:inline\">{{\n copied ? copiedLabel : copyLabel\n }}</span>\n </button>\n </div>\n</template>\n\n<script setup>\n/**\n * UiCopyField — a read-only value with a copy button, and optional masking for\n * secrets.\n *\n * For connect URLs, ids, API keys and generated secrets. With `secret`, the\n * value is masked until revealed and the real text is not in the DOM while it\n * is masked, so a screen share or a screenshot does not leak it. Copying works\n * either way.\n *\n * Copy uses the async Clipboard API and fails silently when unavailable (an\n * insecure context or denied permission). Every label is a prop, so nothing\n * is baked into one language.\n *\n * @example\n * <UiFormField label=\"Connect URL\">\n * <UiCopyField value=\"wss://crdt.numori.app/notes\" />\n * </UiFormField>\n *\n * @example A secret shown once\n * <UiCopyField :value=\"signingKey\" secret @copy=\"markCopied\" />\n *\n * @emits {string} copy — The value was copied.\n * @emits {boolean} update:revealed — The secret was revealed or hidden.\n */\nimport { computed, ref, watch } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nimport { useMergedClasses } from '../composables/useMergedClasses.js'\n\nconst props = defineProps({\n /**\n * The text to show and copy.\n * @type {string}\n */\n value: { type: String, required: true },\n\n /**\n * Mask the value until revealed.\n * @type {boolean}\n * @default false\n */\n secret: { type: Boolean, default: false },\n\n /**\n * Revealed state of a secret, for `v-model:revealed`.\n * @type {boolean}\n * @default false\n */\n revealed: { type: Boolean, default: false },\n\n /**\n * Monospace text.\n * @type {boolean}\n * @default true\n */\n mono: { type: Boolean, default: true },\n\n /**\n * Wrap long values onto several lines instead of truncating.\n * @type {boolean}\n * @default false\n */\n wrap: { type: Boolean, default: false },\n\n /**\n * Control size.\n * @type {string}\n * @default 'md'\n * @values 'sm' | 'md'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Show the copy label beside the icon (from `sm` up).\n * @type {boolean}\n * @default false\n */\n showCopyText: { type: Boolean, default: false },\n\n /** @type {string} @default 'Copy' */\n copyLabel: { type: String, default: 'Copy' },\n /** @type {string} @default 'Copied' */\n copiedLabel: { type: String, default: 'Copied' },\n /** @type {string} @default 'Reveal' */\n revealLabel: { type: String, default: 'Reveal' },\n /** @type {string} @default 'Hide' */\n hideLabel: { type: String, default: 'Hide' },\n /** Accessible text read in place of a masked value. @type {string} @default 'Hidden value' */\n hiddenLabel: { type: String, default: 'Hidden value' },\n})\n\nconst emit = defineEmits(['copy', 'update:revealed'])\n\ndefineOptions({ inheritAttrs: false })\n\nconst isRevealed = ref(props.revealed)\nwatch(\n () => props.revealed,\n (value) => {\n isRevealed.value = value\n },\n)\n\nconst masked = computed(() => props.secret && !isRevealed.value)\nconst mask = computed(() => '•'.repeat(Math.min(Math.max(props.value.length, 8), 24)))\n\nfunction toggleReveal() {\n isRevealed.value = !isRevealed.value\n emit('update:revealed', isRevealed.value)\n}\n\nconst copied = ref(false)\nlet timer = null\n\nasync function copy() {\n try {\n await navigator.clipboard.writeText(props.value)\n copied.value = true\n emit('copy', props.value)\n clearTimeout(timer)\n timer = setTimeout(() => {\n copied.value = false\n }, 1600)\n } catch {\n // Clipboard unavailable; the value is still selectable by hand.\n }\n}\n\nconst buttonClass =\n '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'\n\nconst { mergedClasses, restAttrs } = useMergedClasses(\n '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',\n)\n</script>\n"],"mappings":";;;;;;;;;;;AA2KA,IAAM,cACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EApGF,MAAM,QAAQ;EA8Dd,MAAM,OAAO;EAIb,MAAM,aAAa,IAAI,MAAM,QAAQ;EACrC,YACQ,MAAM,WACX,UAAU;GACT,WAAW,QAAQ;EACrB,CACF;EAEA,MAAM,SAAS,eAAe,MAAM,UAAU,CAAC,WAAW,KAAK;EAC/D,MAAM,OAAO,eAAe,IAAI,OAAO,KAAK,IAAI,KAAK,IAAI,MAAM,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;EAErF,SAAS,eAAe;GACtB,WAAW,QAAQ,CAAC,WAAW;GAC/B,KAAK,mBAAmB,WAAW,KAAK;EAC1C;EAEA,MAAM,SAAS,IAAI,KAAK;EACxB,IAAI,QAAQ;EAEZ,eAAe,OAAO;GACpB,IAAI;IACF,MAAM,UAAU,UAAU,UAAU,MAAM,KAAK;IAC/C,OAAO,QAAQ;IACf,KAAK,QAAQ,MAAM,KAAK;IACxB,aAAa,KAAK;IAClB,QAAQ,iBAAiB;KACvB,OAAO,QAAQ;IACjB,GAAG,IAAI;GACT,QAAQ,CAER;EACF;EAKA,MAAM,EAAE,eAAe,cAAc,iBACnC,yIACF;;GA/KE,OAAA,UAAA,GAAA,mBAuCM,OAvCN,WAuCM,EAvCA,OAAO,MAAA,aAAA,EAAa,GAAU,MAAA,SAAA,CAAS,GAAA;IAC3C,mBAUC,QAAA;KATC,OAAK,eAAA,CAAC,mEAAiE;MACrD,QAAA,SAAI,OAAA,mBAAA;MAAuD,QAAA,OAAI,cAAA;MAA6B,QAAA,OAAI,kCAAA;MAAyD,OAAA,QAAM,iEAAA;;KAMhL,cAAY,OAAA,QAAS,QAAA,cAAc,KAAA;IAChC,GAAA,gBAAA,OAAA,QAAS,KAAA,QAAO,QAAA,KAAK,GAAA,IAAA,UAAA;IAInB,QAAA,UADR,UAAA,GAAA,mBASS,UAAA;;KAPP,MAAK;KACJ,OAAK,eAAE,WAAW;KAClB,cAAY,OAAA,QAAS,QAAA,cAAc,QAAA;KACnC,gBAAc,OAAA,QAAM,UAAA;KACpB,SAAO;IAER,GAAA,CAAA,YAAoF,aAAA;KAA3E,MAAM,OAAA,QAAM,oBAAA;KAA8C,OAAM;;IAG3E,mBAcS,UAAA;KAbP,MAAK;KACJ,OAAK,eAAE,WAAW;KAClB,cAAY,OAAA,QAAS,QAAA,cAAc,QAAA;KACnC,SAAO;IAER,GAAA,CAAA,YAIE,aAAA;KAHC,MAAM,OAAA,QAAM,cAAA;KACb,OAAK,eAAA,CAAC,UACE,OAAA,QAAM,2CAAA,EAAA,CAAA;IAEJ,GAAA,MAAA,GAAA,CAAA,QAAA,OAAA,CAAA,GAAA,QAAA,gBAAZ,UAAA,GAAA,mBAES,QAFT,YAES,gBADP,OAAA,QAAS,QAAA,cAAc,QAAA,SAAS,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,GAAA,GAAA,UAAA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useMergedClasses } from "../composables/useMergedClasses.js";
|
|
2
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, mergeProps, normalizeClass, openBlock, renderList, renderSlot, toDisplayString, unref } from "vue";
|
|
3
|
+
//#region src/components/DescriptionList.vue
|
|
4
|
+
var _hoisted_1 = { class: "text-sm font-medium text-gray-500 dark:text-gray-400" };
|
|
5
|
+
var _hoisted_2 = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "mt-0.5 block text-xs font-normal text-gray-400 dark:text-gray-500"
|
|
8
|
+
};
|
|
9
|
+
var _hoisted_3 = {
|
|
10
|
+
key: 0,
|
|
11
|
+
class: "text-gray-400 dark:text-gray-500"
|
|
12
|
+
};
|
|
13
|
+
var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
14
|
+
__name: "DescriptionList",
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* Pairs to show. Each is `{ label, value, key?, hint?, mono? }`; `mono`
|
|
18
|
+
* renders the value in a monospace font that breaks anywhere (ids, keys).
|
|
19
|
+
* @type {Array<{ label: string, value?: unknown, key?: string, hint?: string, mono?: boolean }>}
|
|
20
|
+
*/
|
|
21
|
+
items: {
|
|
22
|
+
type: Array,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Arrangement of each pair.
|
|
27
|
+
* @type {string}
|
|
28
|
+
* @default 'inline'
|
|
29
|
+
* @values 'inline' | 'stacked' | 'grid'
|
|
30
|
+
*/
|
|
31
|
+
layout: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "inline"
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Dividers between rows (ignored by `grid`).
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
divided: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Shown in place of an empty value.
|
|
46
|
+
* @type {string}
|
|
47
|
+
* @default '—'
|
|
48
|
+
*/
|
|
49
|
+
emptyText: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: "—"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
setup(__props) {
|
|
55
|
+
/**
|
|
56
|
+
* UiDescriptionList — label / value pairs, such as a record's details or a
|
|
57
|
+
* service's settings, rendered as a real `<dl>`.
|
|
58
|
+
*
|
|
59
|
+
* Three layouts:
|
|
60
|
+
* - `inline` (default): label in a narrow left column, value beside it, one
|
|
61
|
+
* pair per row with dividers. Stacks on narrow screens.
|
|
62
|
+
* - `stacked`: label above value, one pair per row.
|
|
63
|
+
* - `grid`: label above value, pairs flowing into two columns.
|
|
64
|
+
*
|
|
65
|
+
* Empty values (`null`, `undefined`, `''`) render `emptyText` so a missing
|
|
66
|
+
* setting reads as deliberate rather than as a rendering bug. Use the `#value`
|
|
67
|
+
* slot to render badges, links or copy fields.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* <UiDescriptionList
|
|
71
|
+
* :items="[
|
|
72
|
+
* { label: 'App id', value: 'notes', mono: true },
|
|
73
|
+
* { label: 'Storage', value: 'postgres' },
|
|
74
|
+
* { label: 'Audience', value: null, hint: 'Optional app/aud claim' },
|
|
75
|
+
* ]"
|
|
76
|
+
* />
|
|
77
|
+
*
|
|
78
|
+
* @example Custom value rendering
|
|
79
|
+
* <UiDescriptionList :items="items">
|
|
80
|
+
* <template #value="{ item, value }">
|
|
81
|
+
* <UiBadge v-if="item.key === 'status'" color="green">{{ value }}</UiBadge>
|
|
82
|
+
* <template v-else>{{ value }}</template>
|
|
83
|
+
* </template>
|
|
84
|
+
* </UiDescriptionList>
|
|
85
|
+
*
|
|
86
|
+
* @slot value — Custom value content. Scope: `{ item, value }`.
|
|
87
|
+
*/
|
|
88
|
+
const props = __props;
|
|
89
|
+
const isEmpty = (value) => value === null || value === void 0 || value === "";
|
|
90
|
+
const rowClass = computed(() => {
|
|
91
|
+
if (props.layout === "grid") return "";
|
|
92
|
+
if (props.layout === "stacked") return "py-3 first:pt-0 last:pb-0";
|
|
93
|
+
return "py-3 first:pt-0 last:pb-0 sm:grid sm:grid-cols-3 sm:gap-4";
|
|
94
|
+
});
|
|
95
|
+
const internalClasses = computed(() => {
|
|
96
|
+
if (props.layout === "grid") return "grid gap-x-6 gap-y-4 sm:grid-cols-2";
|
|
97
|
+
return props.divided ? "divide-y divide-gray-100 dark:divide-gray-800" : "";
|
|
98
|
+
});
|
|
99
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value);
|
|
100
|
+
return (_ctx, _cache) => {
|
|
101
|
+
return openBlock(), createElementBlock("dl", mergeProps({ class: unref(mergedClasses) }, unref(restAttrs)), [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, index) => {
|
|
102
|
+
return openBlock(), createElementBlock("div", {
|
|
103
|
+
key: item.key ?? item.label ?? index,
|
|
104
|
+
class: normalizeClass(rowClass.value)
|
|
105
|
+
}, [createElementVNode("dt", _hoisted_1, [createTextVNode(toDisplayString(item.label) + " ", 1), item.hint ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(item.hint), 1)) : createCommentVNode("", true)]), createElementVNode("dd", { class: normalizeClass(["min-w-0 text-sm text-gray-900 dark:text-gray-100", [item.mono ? "font-mono text-[13px] break-all" : "break-words", __props.layout === "inline" ? "mt-1 sm:col-span-2 sm:mt-0" : "mt-1"]]) }, [renderSlot(_ctx.$slots, "value", {
|
|
106
|
+
item,
|
|
107
|
+
value: item.value
|
|
108
|
+
}, () => [isEmpty(item.value) ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(__props.emptyText), 1)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(item.value), 1)], 64))])], 2)], 2);
|
|
109
|
+
}), 128))], 16);
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
//#endregion
|
|
114
|
+
export { _sfc_main as default };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=DescriptionList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DescriptionList.js","names":[],"sources":["../../src/components/DescriptionList.vue"],"sourcesContent":["<template>\n <dl :class=\"mergedClasses\" v-bind=\"restAttrs\">\n <div v-for=\"(item, index) in items\" :key=\"item.key ?? item.label ?? index\" :class=\"rowClass\">\n <dt class=\"text-sm font-medium text-gray-500 dark:text-gray-400\">\n {{ item.label }}\n <span\n v-if=\"item.hint\"\n class=\"mt-0.5 block text-xs font-normal text-gray-400 dark:text-gray-500\"\n >{{ item.hint }}</span\n >\n </dt>\n <dd\n class=\"min-w-0 text-sm text-gray-900 dark:text-gray-100\"\n :class=\"[\n item.mono ? 'font-mono text-[13px] break-all' : 'break-words',\n layout === 'inline' ? 'mt-1 sm:col-span-2 sm:mt-0' : 'mt-1',\n ]\"\n >\n <slot name=\"value\" :item=\"item\" :value=\"item.value\">\n <span v-if=\"isEmpty(item.value)\" class=\"text-gray-400 dark:text-gray-500\">{{\n emptyText\n }}</span>\n <template v-else>{{ item.value }}</template>\n </slot>\n </dd>\n </div>\n </dl>\n</template>\n\n<script setup>\n/**\n * UiDescriptionList — label / value pairs, such as a record's details or a\n * service's settings, rendered as a real `<dl>`.\n *\n * Three layouts:\n * - `inline` (default): label in a narrow left column, value beside it, one\n * pair per row with dividers. Stacks on narrow screens.\n * - `stacked`: label above value, one pair per row.\n * - `grid`: label above value, pairs flowing into two columns.\n *\n * Empty values (`null`, `undefined`, `''`) render `emptyText` so a missing\n * setting reads as deliberate rather than as a rendering bug. Use the `#value`\n * slot to render badges, links or copy fields.\n *\n * @example\n * <UiDescriptionList\n * :items=\"[\n * { label: 'App id', value: 'notes', mono: true },\n * { label: 'Storage', value: 'postgres' },\n * { label: 'Audience', value: null, hint: 'Optional app/aud claim' },\n * ]\"\n * />\n *\n * @example Custom value rendering\n * <UiDescriptionList :items=\"items\">\n * <template #value=\"{ item, value }\">\n * <UiBadge v-if=\"item.key === 'status'\" color=\"green\">{{ value }}</UiBadge>\n * <template v-else>{{ value }}</template>\n * </template>\n * </UiDescriptionList>\n *\n * @slot value — Custom value content. Scope: `{ item, value }`.\n */\nimport { computed } from 'vue'\nimport { useMergedClasses } from '../composables/useMergedClasses.js'\n\nconst props = defineProps({\n /**\n * Pairs to show. Each is `{ label, value, key?, hint?, mono? }`; `mono`\n * renders the value in a monospace font that breaks anywhere (ids, keys).\n * @type {Array<{ label: string, value?: unknown, key?: string, hint?: string, mono?: boolean }>}\n */\n items: { type: Array, required: true },\n\n /**\n * Arrangement of each pair.\n * @type {string}\n * @default 'inline'\n * @values 'inline' | 'stacked' | 'grid'\n */\n layout: { type: String, default: 'inline' },\n\n /**\n * Dividers between rows (ignored by `grid`).\n * @type {boolean}\n * @default true\n */\n divided: { type: Boolean, default: true },\n\n /**\n * Shown in place of an empty value.\n * @type {string}\n * @default '—'\n */\n emptyText: { type: String, default: '—' },\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst isEmpty = (value) => value === null || value === undefined || value === ''\n\nconst rowClass = computed(() => {\n if (props.layout === 'grid') return ''\n if (props.layout === 'stacked') return 'py-3 first:pt-0 last:pb-0'\n return 'py-3 first:pt-0 last:pb-0 sm:grid sm:grid-cols-3 sm:gap-4'\n})\n\nconst internalClasses = computed(() => {\n if (props.layout === 'grid') return 'grid gap-x-6 gap-y-4 sm:grid-cols-2'\n return props.divided ? 'divide-y divide-gray-100 dark:divide-gray-800' : ''\n})\n\nconst { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkEA,MAAM,QAAQ;EAiCd,MAAM,WAAW,UAAU,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU;EAE9E,MAAM,WAAW,eAAe;GAC9B,IAAI,MAAM,WAAW,QAAQ,OAAO;GACpC,IAAI,MAAM,WAAW,WAAW,OAAO;GACvC,OAAO;EACT,CAAC;EAED,MAAM,kBAAkB,eAAe;GACrC,IAAI,MAAM,WAAW,QAAQ,OAAO;GACpC,OAAO,MAAM,UAAU,kDAAkD;EAC3E,CAAC;EAED,MAAM,EAAE,eAAe,cAAc,uBAAuB,gBAAgB,KAAK;;GA/G/E,OAAA,UAAA,GAAA,mBAyBK,MAzBL,WAyBK,EAzBA,OAAO,MAAA,aAAA,EAAa,GAAU,MAAA,SAAA,CAAS,GAAA,EAC1C,UAAA,IAAA,GAAA,mBAuBM,UAAA,MAAA,WAvBuB,QAAA,QAAhB,MAAM,UAAK;IAAxB,OAAA,UAAA,GAAA,mBAuBM,OAAA;KAvB+B,KAAK,KAAK,OAAO,KAAK,SAAS;KAAQ,OAAK,eAAE,SAAA,KAAQ;IACzF,GAAA,CAAA,mBAOK,MAPL,YAOK,CANA,gBAAA,gBAAA,KAAK,KAAK,IAAG,KAChB,CAAA,GACQ,KAAK,QADb,UAAA,GAAA,mBAIC,QAJD,YAIC,gBADK,KAAK,IAAI,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA,GAGjB,mBAaK,MAAA,EAZH,OAAK,eAAA,CAAC,oDAAkD,CACpC,KAAK,OAAI,oCAAA,eAAgE,QAAA,WAAM,WAAA,+BAAA,MAAA,CAAA,CAAA,EAAA,GAAA,CAKnG,WAKO,KAAA,QAAA,SAAA;KALmB;KAAO,OAAO,KAAK;IAA7C,SAKO,CAJO,QAAQ,KAAK,KAAK,KAA9B,UAAA,GAAA,mBAES,QAFT,YAES,gBADP,QAAA,SAAS,GAAA,CAAA,MAEX,UAAA,GAAA,mBAA4C,UAAA,EAAA,KAAA,EAAA,GAAA,CAAxB,gBAAA,gBAAA,KAAK,KAAK,GAAA,CAAA,CAAA,GAAA,EAAA,EAAA,CAAA,CAAA,GAAA,CAAA,CAAA,GAAA,CAAA"}
|
|
@@ -128,7 +128,9 @@ var _sfc_main = {
|
|
|
128
128
|
};
|
|
129
129
|
onClickOutside(containerRef, close);
|
|
130
130
|
useEventListener(globalThis.document, "keydown", (e) => {
|
|
131
|
-
if (e.key
|
|
131
|
+
if (e.key !== "Escape" || !isOpen.value) return;
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
close();
|
|
132
134
|
});
|
|
133
135
|
__expose({
|
|
134
136
|
isOpen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","names":[],"sources":["../../src/components/Dropdown.vue"],"sourcesContent":["<template>\n <div ref=\"containerRef\" class=\"relative\">\n <!-- Trigger slot: receives { open, toggle } for controlling the dropdown -->\n <slot name=\"trigger\" :open=\"isOpen\" :toggle=\"toggle\" />\n\n <!-- Dropdown panel with animated enter/leave transitions -->\n <Transition\n :enter-active-class=\"transitionClasses.enterActive\"\n :enter-from-class=\"transitionClasses.enterFrom\"\n :enter-to-class=\"transitionClasses.enterTo\"\n :leave-active-class=\"transitionClasses.leaveActive\"\n :leave-from-class=\"transitionClasses.leaveFrom\"\n :leave-to-class=\"transitionClasses.leaveTo\"\n >\n <div v-show=\"isOpen\" :class=\"panelClasses\" :style=\"{ transformOrigin: panelOrigin }\">\n <slot :close=\"close\" />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiDropdown — Headless dropdown menu with configurable alignment, direction, and transitions.\n *\n * Uses a trigger slot that receives `open` state and `toggle` function, and a default\n * slot for menu content that receives a `close` function. Closes on outside click and\n * Escape key. Supports both downward and upward drop directions with matching transitions.\n * Exposes `isOpen`, `toggle()`, and `close()` for programmatic control.\n *\n * @example Basic dropdown with button trigger\n * <UiDropdown>\n * <template #trigger=\"{ toggle }\">\n * <UiButton @click=\"toggle\">Menu</UiButton>\n * </template>\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiDropdown>\n *\n * @example Right-aligned, drop-up\n * <UiDropdown align=\"right\" drop=\"up\" width=\"w-48\">\n * <template #trigger=\"{ toggle }\">\n * <UiButton variant=\"ghost\" icon-only @click=\"toggle\">\n * <UiIcon name=\"mdi:dots-vertical\" class=\"w-5 h-5\" />\n * </UiButton>\n * </template>\n * <slot />\n * </UiDropdown>\n *\n * @emits {void} open — Emitted when the dropdown opens\n * @emits {void} close — Emitted when the dropdown closes\n *\n * @slot trigger — Trigger element that opens the dropdown. Receives { open: boolean, toggle: Function }\n * @slot default — Dropdown menu content. Receives { close: Function }\n *\n * @see UiDropdownItem — Standard menu item for use inside this dropdown\n * @see UiDropdownSubmenu — Nested submenu for this dropdown\n */\nimport { ref, computed } from 'vue'\nimport { onClickOutside } from '../composables/onClickOutside.js'\nimport { useEventListener } from '../composables/useEventListener.js'\nimport { MENU_PANEL_CLASS } from '../internal/menu.js'\nconst props = defineProps({\n /**\n * Width class applied to the dropdown panel.\n * @type {string}\n * @default 'w-56'\n * @example 'w-48', 'w-64', 'w-72'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Horizontal alignment of the panel relative to the trigger.\n * @type {string}\n * @default 'left'\n * @values 'left' | 'right'\n */\n align: { type: String, default: 'left' },\n\n /**\n * Drop direction — 'down' opens below the trigger, 'up' opens above.\n * @type {string}\n * @default 'down'\n * @values 'down' | 'up'\n */\n drop: { type: String, default: 'down' },\n\n /**\n * Override all default panel classes (bg, border, rounded, shadow).\n * When set, the built-in panel styling is completely replaced.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['open', 'close'])\n\nconst isOpen = ref(false)\nconst containerRef = ref(null)\n\n// Build panel positioning/styling classes, or use custom override\nconst panelClasses = computed(() => {\n if (props.panelClass) return props.panelClass\n const align = props.align === 'right' ? 'right-0' : 'left-0'\n const dropDir = props.drop === 'up' ? 'bottom-full mb-1' : 'mt-1'\n // `p-1` (not just `py-1`) insets the rows so their rounded hover highlight\n // reads as a chip with breathing room from the panel edge.\n return `absolute z-50 ${MENU_PANEL_CLASS} p-1 ${props.width} ${align} ${dropDir}`\n})\n\n// Inline transform-origin (not a Tailwind class, so it needs no build step to\n// take effect): the panel scales in from the corner nearest the trigger rather\n// than drifting in from its centre.\nconst panelOrigin = computed(() => {\n const y = props.drop === 'up' ? 'bottom' : 'top'\n const x = props.align === 'right' ? 'right' : 'left'\n return `${y} ${x}`\n})\n\n// Use slide-up transition for drop=\"up\", scale transition for drop=\"down\"\nconst transitionClasses = computed(() => {\n if (props.drop === 'up') {\n return {\n enterActive: 'transition ease-out duration-150',\n enterFrom: 'opacity-0 translate-y-1',\n enterTo: 'opacity-100 translate-y-0',\n leaveActive: 'transition ease-in duration-100',\n leaveFrom: 'opacity-100 translate-y-0',\n leaveTo: 'opacity-0 translate-y-1',\n }\n }\n return {\n enterActive: 'transition duration-100 ease-out',\n enterFrom: 'opacity-0 scale-95',\n enterTo: 'opacity-100 scale-100',\n leaveActive: 'transition duration-75 ease-in',\n leaveFrom: 'opacity-100 scale-100',\n leaveTo: 'opacity-0 scale-95',\n }\n})\n\nconst toggle = () => {\n isOpen.value = !isOpen.value\n emit(isOpen.value ? 'open' : 'close')\n}\n\nconst close = () => {\n if (isOpen.value) {\n isOpen.value = false\n emit('close')\n }\n}\n\nonClickOutside(containerRef, close)\n\nuseEventListener(globalThis.document, 'keydown', (e) => {\n if (e.key
|
|
1
|
+
{"version":3,"file":"Dropdown.js","names":[],"sources":["../../src/components/Dropdown.vue"],"sourcesContent":["<template>\n <div ref=\"containerRef\" class=\"relative\">\n <!-- Trigger slot: receives { open, toggle } for controlling the dropdown -->\n <slot name=\"trigger\" :open=\"isOpen\" :toggle=\"toggle\" />\n\n <!-- Dropdown panel with animated enter/leave transitions -->\n <Transition\n :enter-active-class=\"transitionClasses.enterActive\"\n :enter-from-class=\"transitionClasses.enterFrom\"\n :enter-to-class=\"transitionClasses.enterTo\"\n :leave-active-class=\"transitionClasses.leaveActive\"\n :leave-from-class=\"transitionClasses.leaveFrom\"\n :leave-to-class=\"transitionClasses.leaveTo\"\n >\n <div v-show=\"isOpen\" :class=\"panelClasses\" :style=\"{ transformOrigin: panelOrigin }\">\n <slot :close=\"close\" />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiDropdown — Headless dropdown menu with configurable alignment, direction, and transitions.\n *\n * Uses a trigger slot that receives `open` state and `toggle` function, and a default\n * slot for menu content that receives a `close` function. Closes on outside click and\n * Escape key. Supports both downward and upward drop directions with matching transitions.\n * Exposes `isOpen`, `toggle()`, and `close()` for programmatic control.\n *\n * @example Basic dropdown with button trigger\n * <UiDropdown>\n * <template #trigger=\"{ toggle }\">\n * <UiButton @click=\"toggle\">Menu</UiButton>\n * </template>\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiDropdown>\n *\n * @example Right-aligned, drop-up\n * <UiDropdown align=\"right\" drop=\"up\" width=\"w-48\">\n * <template #trigger=\"{ toggle }\">\n * <UiButton variant=\"ghost\" icon-only @click=\"toggle\">\n * <UiIcon name=\"mdi:dots-vertical\" class=\"w-5 h-5\" />\n * </UiButton>\n * </template>\n * <slot />\n * </UiDropdown>\n *\n * @emits {void} open — Emitted when the dropdown opens\n * @emits {void} close — Emitted when the dropdown closes\n *\n * @slot trigger — Trigger element that opens the dropdown. Receives { open: boolean, toggle: Function }\n * @slot default — Dropdown menu content. Receives { close: Function }\n *\n * @see UiDropdownItem — Standard menu item for use inside this dropdown\n * @see UiDropdownSubmenu — Nested submenu for this dropdown\n */\nimport { ref, computed } from 'vue'\nimport { onClickOutside } from '../composables/onClickOutside.js'\nimport { useEventListener } from '../composables/useEventListener.js'\nimport { MENU_PANEL_CLASS } from '../internal/menu.js'\nconst props = defineProps({\n /**\n * Width class applied to the dropdown panel.\n * @type {string}\n * @default 'w-56'\n * @example 'w-48', 'w-64', 'w-72'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Horizontal alignment of the panel relative to the trigger.\n * @type {string}\n * @default 'left'\n * @values 'left' | 'right'\n */\n align: { type: String, default: 'left' },\n\n /**\n * Drop direction — 'down' opens below the trigger, 'up' opens above.\n * @type {string}\n * @default 'down'\n * @values 'down' | 'up'\n */\n drop: { type: String, default: 'down' },\n\n /**\n * Override all default panel classes (bg, border, rounded, shadow).\n * When set, the built-in panel styling is completely replaced.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['open', 'close'])\n\nconst isOpen = ref(false)\nconst containerRef = ref(null)\n\n// Build panel positioning/styling classes, or use custom override\nconst panelClasses = computed(() => {\n if (props.panelClass) return props.panelClass\n const align = props.align === 'right' ? 'right-0' : 'left-0'\n const dropDir = props.drop === 'up' ? 'bottom-full mb-1' : 'mt-1'\n // `p-1` (not just `py-1`) insets the rows so their rounded hover highlight\n // reads as a chip with breathing room from the panel edge.\n return `absolute z-50 ${MENU_PANEL_CLASS} p-1 ${props.width} ${align} ${dropDir}`\n})\n\n// Inline transform-origin (not a Tailwind class, so it needs no build step to\n// take effect): the panel scales in from the corner nearest the trigger rather\n// than drifting in from its centre.\nconst panelOrigin = computed(() => {\n const y = props.drop === 'up' ? 'bottom' : 'top'\n const x = props.align === 'right' ? 'right' : 'left'\n return `${y} ${x}`\n})\n\n// Use slide-up transition for drop=\"up\", scale transition for drop=\"down\"\nconst transitionClasses = computed(() => {\n if (props.drop === 'up') {\n return {\n enterActive: 'transition ease-out duration-150',\n enterFrom: 'opacity-0 translate-y-1',\n enterTo: 'opacity-100 translate-y-0',\n leaveActive: 'transition ease-in duration-100',\n leaveFrom: 'opacity-100 translate-y-0',\n leaveTo: 'opacity-0 translate-y-1',\n }\n }\n return {\n enterActive: 'transition duration-100 ease-out',\n enterFrom: 'opacity-0 scale-95',\n enterTo: 'opacity-100 scale-100',\n leaveActive: 'transition duration-75 ease-in',\n leaveFrom: 'opacity-100 scale-100',\n leaveTo: 'opacity-0 scale-95',\n }\n})\n\nconst toggle = () => {\n isOpen.value = !isOpen.value\n emit(isOpen.value ? 'open' : 'close')\n}\n\nconst close = () => {\n if (isOpen.value) {\n isOpen.value = false\n emit('close')\n }\n}\n\nonClickOutside(containerRef, close)\n\nuseEventListener(globalThis.document, 'keydown', (e) => {\n if (e.key !== 'Escape' || !isOpen.value) return\n // Claim the key so an enclosing UiModal does not close too.\n e.preventDefault()\n close()\n})\n\ndefineExpose({ isOpen, toggle, close })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8DA,MAAM,QAAQ;EAkCd,MAAM,OAAO;EAEb,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,eAAe,IAAI,IAAI;EAG7B,MAAM,eAAe,eAAe;GAClC,IAAI,MAAM,YAAY,OAAO,MAAM;GACnC,MAAM,QAAQ,MAAM,UAAU,UAAU,YAAY;GACpD,MAAM,UAAU,MAAM,SAAS,OAAO,qBAAqB;GAG3D,OAAO,iBAAiB,iBAAiB,OAAO,MAAM,MAAM,GAAG,MAAM,GAAG;EAC1E,CAAC;EAKD,MAAM,cAAc,eAAe;GAGjC,OAAO,GAFG,MAAM,SAAS,OAAO,WAAW,MAE/B,GADF,MAAM,UAAU,UAAU,UAAU;EAEhD,CAAC;EAGD,MAAM,oBAAoB,eAAe;GACvC,IAAI,MAAM,SAAS,MACjB,OAAO;IACL,aAAa;IACb,WAAW;IACX,SAAS;IACT,aAAa;IACb,WAAW;IACX,SAAS;GACX;GAEF,OAAO;IACL,aAAa;IACb,WAAW;IACX,SAAS;IACT,aAAa;IACb,WAAW;IACX,SAAS;GACX;EACF,CAAC;EAED,MAAM,eAAe;GACnB,OAAO,QAAQ,CAAC,OAAO;GACvB,KAAK,OAAO,QAAQ,SAAS,OAAO;EACtC;EAEA,MAAM,cAAc;GAClB,IAAI,OAAO,OAAO;IAChB,OAAO,QAAQ;IACf,KAAK,OAAO;GACd;EACF;EAEA,eAAe,cAAc,KAAK;EAElC,iBAAiB,WAAW,UAAU,YAAY,MAAM;GACtD,IAAI,EAAE,QAAQ,YAAY,CAAC,OAAO,OAAO;GAEzC,EAAE,eAAe;GACjB,MAAM;EACR,CAAC;EAED,SAAa;GAAE;GAAQ;GAAQ;EAAM,CAAC;;GAlKpC,OAAA,UAAA,GAAA,mBAiBM,OAAA;IAjBG,SAAA;IAAJ,KAAI;IAAe,OAAM;GAE5B,GAAA,CAAA,WAAuD,KAAA,QAAA,WAAA;IAAjC,MAAM,OAAA;IAAiB;GAG7C,CAAA,GAAA,YAWa,YAAA;IAVV,sBAAoB,kBAAA,MAAkB;IACtC,oBAAkB,kBAAA,MAAkB;IACpC,kBAAgB,kBAAA,MAAkB;IAClC,sBAAoB,kBAAA,MAAkB;IACtC,oBAAkB,kBAAA,MAAkB;IACpC,kBAAgB,kBAAA,MAAkB;;IAEnC,SAAA,cAEM,CAFN,eAAA,mBAEM,OAAA;KAFgB,OAAK,eAAE,aAAA,KAAY;KAAG,OAAK,eAAA,EAAA,iBAAqB,YAAA,MAAW,CAAA;IAC/E,GAAA,CAAA,WAAuB,KAAA,QAAA,WAAA,EAAT,MAAK,CAAA,CAAA,GAAA,CAAA,GAAA,CADR,CAAA,OAAA,OAAA,KAAM,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { useMergedClasses } from "../composables/useMergedClasses.js";
|
|
3
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, mergeProps, openBlock, renderSlot, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
|
|
4
|
+
//#region src/components/EmptyState.vue
|
|
5
|
+
var _hoisted_1 = {
|
|
6
|
+
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",
|
|
7
|
+
"aria-hidden": "true"
|
|
8
|
+
};
|
|
9
|
+
var _hoisted_2 = {
|
|
10
|
+
key: 0,
|
|
11
|
+
class: "mx-auto mt-1 max-w-sm text-sm text-gray-500 dark:text-gray-400"
|
|
12
|
+
};
|
|
13
|
+
var _hoisted_3 = {
|
|
14
|
+
key: 1,
|
|
15
|
+
class: "mt-5 flex flex-wrap justify-center gap-2"
|
|
16
|
+
};
|
|
17
|
+
var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
18
|
+
__name: "EmptyState",
|
|
19
|
+
props: {
|
|
20
|
+
/**
|
|
21
|
+
* Short statement of the state, e.g. "No apps yet".
|
|
22
|
+
* @type {string}
|
|
23
|
+
* @default ''
|
|
24
|
+
*/
|
|
25
|
+
title: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: ""
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* One line explaining why, or what to do.
|
|
31
|
+
* @type {string}
|
|
32
|
+
* @default ''
|
|
33
|
+
*/
|
|
34
|
+
description: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ""
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* MDI icon.
|
|
40
|
+
* @type {string}
|
|
41
|
+
* @default 'mdi:inbox-outline'
|
|
42
|
+
*/
|
|
43
|
+
icon: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: "mdi:inbox-outline"
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Tighter vertical padding, for use inside cards and tables.
|
|
49
|
+
* @type {boolean}
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
compact: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Dashed outline around the state, for standalone use on a page.
|
|
58
|
+
* @type {boolean}
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
bordered: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Element used for the title.
|
|
67
|
+
* @type {string}
|
|
68
|
+
* @default 'h3'
|
|
69
|
+
* @values 'h2' | 'h3' | 'h4' | 'p'
|
|
70
|
+
*/
|
|
71
|
+
headingTag: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: "h3"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
setup(__props) {
|
|
77
|
+
/**
|
|
78
|
+
* UiEmptyState — what a list, table or page shows when there is nothing in it
|
|
79
|
+
* yet: an icon, a short title, one line of explanation and the action that
|
|
80
|
+
* fixes it.
|
|
81
|
+
*
|
|
82
|
+
* Say why it is empty and what to do next, rather than only that it is empty.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* <UiEmptyState
|
|
86
|
+
* icon="mdi:sync"
|
|
87
|
+
* title="No apps yet"
|
|
88
|
+
* description="Register an app to give its clients a place to sync."
|
|
89
|
+
* >
|
|
90
|
+
* <UiButton><UiIcon name="mdi:plus" class="size-4" />New app</UiButton>
|
|
91
|
+
* </UiEmptyState>
|
|
92
|
+
*
|
|
93
|
+
* @slot default — Actions.
|
|
94
|
+
* @slot icon — Custom icon content.
|
|
95
|
+
* @slot description — Rich description (overrides `description`).
|
|
96
|
+
*/
|
|
97
|
+
const props = __props;
|
|
98
|
+
const internalClasses = computed(() => [
|
|
99
|
+
"text-center",
|
|
100
|
+
props.compact ? "px-4 py-6" : "px-6 py-12",
|
|
101
|
+
props.bordered ? "rounded-2xl border-2 border-dashed border-gray-200 dark:border-gray-700" : ""
|
|
102
|
+
].filter(Boolean).join(" "));
|
|
103
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value);
|
|
104
|
+
return (_ctx, _cache) => {
|
|
105
|
+
return openBlock(), createElementBlock("div", mergeProps({ class: unref(mergedClasses) }, unref(restAttrs)), [
|
|
106
|
+
createElementVNode("div", _hoisted_1, [renderSlot(_ctx.$slots, "icon", {}, () => [createVNode(_sfc_main$1, {
|
|
107
|
+
name: __props.icon,
|
|
108
|
+
class: "size-6"
|
|
109
|
+
}, null, 8, ["name"])])]),
|
|
110
|
+
(openBlock(), createBlock(resolveDynamicComponent(__props.headingTag), { class: "mt-4 text-sm font-semibold text-gray-900 dark:text-gray-100" }, {
|
|
111
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.title), 1)]),
|
|
112
|
+
_: 1
|
|
113
|
+
})),
|
|
114
|
+
__props.description || _ctx.$slots.description ? (openBlock(), createElementBlock("p", _hoisted_2, [renderSlot(_ctx.$slots, "description", {}, () => [createTextVNode(toDisplayString(__props.description), 1)])])) : createCommentVNode("", true),
|
|
115
|
+
_ctx.$slots.default ? (openBlock(), createElementBlock("div", _hoisted_3, [renderSlot(_ctx.$slots, "default")])) : createCommentVNode("", true)
|
|
116
|
+
], 16);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
//#endregion
|
|
121
|
+
export { _sfc_main as default };
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=EmptyState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmptyState.js","names":["$slots"],"sources":["../../src/components/EmptyState.vue"],"sourcesContent":["<template>\n <div :class=\"mergedClasses\" v-bind=\"restAttrs\">\n <div\n 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\"\n aria-hidden=\"true\"\n >\n <slot name=\"icon\"><UiIcon :name=\"icon\" class=\"size-6\" /></slot>\n </div>\n <component :is=\"headingTag\" class=\"mt-4 text-sm font-semibold text-gray-900 dark:text-gray-100\">\n {{ title }}\n </component>\n <p\n v-if=\"description || $slots.description\"\n class=\"mx-auto mt-1 max-w-sm text-sm text-gray-500 dark:text-gray-400\"\n >\n <slot name=\"description\">{{ description }}</slot>\n </p>\n <div v-if=\"$slots.default\" class=\"mt-5 flex flex-wrap justify-center gap-2\">\n <slot />\n </div>\n </div>\n</template>\n\n<script setup>\n/**\n * UiEmptyState — what a list, table or page shows when there is nothing in it\n * yet: an icon, a short title, one line of explanation and the action that\n * fixes it.\n *\n * Say why it is empty and what to do next, rather than only that it is empty.\n *\n * @example\n * <UiEmptyState\n * icon=\"mdi:sync\"\n * title=\"No apps yet\"\n * description=\"Register an app to give its clients a place to sync.\"\n * >\n * <UiButton><UiIcon name=\"mdi:plus\" class=\"size-4\" />New app</UiButton>\n * </UiEmptyState>\n *\n * @slot default — Actions.\n * @slot icon — Custom icon content.\n * @slot description — Rich description (overrides `description`).\n */\nimport { computed } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nimport { useMergedClasses } from '../composables/useMergedClasses.js'\n\nconst props = defineProps({\n /**\n * Short statement of the state, e.g. \"No apps yet\".\n * @type {string}\n * @default ''\n */\n title: { type: String, default: '' },\n\n /**\n * One line explaining why, or what to do.\n * @type {string}\n * @default ''\n */\n description: { type: String, default: '' },\n\n /**\n * MDI icon.\n * @type {string}\n * @default 'mdi:inbox-outline'\n */\n icon: { type: String, default: 'mdi:inbox-outline' },\n\n /**\n * Tighter vertical padding, for use inside cards and tables.\n * @type {boolean}\n * @default false\n */\n compact: { type: Boolean, default: false },\n\n /**\n * Dashed outline around the state, for standalone use on a page.\n * @type {boolean}\n * @default false\n */\n bordered: { type: Boolean, default: false },\n\n /**\n * Element used for the title.\n * @type {string}\n * @default 'h3'\n * @values 'h2' | 'h3' | 'h4' | 'p'\n */\n headingTag: { type: String, default: 'h3' },\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst internalClasses = computed(() =>\n [\n 'text-center',\n props.compact ? 'px-4 py-6' : 'px-6 py-12',\n props.bordered ? 'rounded-2xl border-2 border-dashed border-gray-200 dark:border-gray-700' : '',\n ]\n .filter(Boolean)\n .join(' '),\n)\n\nconst { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDA,MAAM,QAAQ;EA+Cd,MAAM,kBAAkB,eACtB;GACE;GACA,MAAM,UAAU,cAAc;GAC9B,MAAM,WAAW,4EAA4E;EAC/F,CAAA,CACG,OAAO,OAAO,CAAA,CACd,KAAK,GAAG,CACb;EAEA,MAAM,EAAE,eAAe,cAAc,uBAAuB,gBAAgB,KAAK;;GAxG/E,OAAA,UAAA,GAAA,mBAmBM,OAnBN,WAmBM,EAnBA,OAAO,MAAA,aAAA,EAAa,GAAU,MAAA,SAAA,CAAS,GAAA;IAC3C,mBAKM,OALN,YAKM,CADJ,WAA+D,KAAA,QAAA,QAAA,CAAA,SAAA,CAA7C,YAAsC,aAAA;KAA7B,MAAM,QAAA;KAAM,OAAM;;KAE/C,UAAA,GAAA,YAEY,wBAFI,QAAA,UAAU,GAAA,EAAE,OAAM,8DAA6D,GAAA;KAC7F,SAAA,cAAW,CAAR,gBAAA,gBAAA,QAAA,KAAK,GAAA,CAAA,CAAA,CAAA;;;IAGF,QAAA,eAAeA,KAAAA,OAAO,eAD9B,UAAA,GAAA,mBAKI,KALJ,YAKI,CADF,WAAiD,KAAA,QAAA,eAAA,CAAA,SAAA,CAArB,gBAAA,gBAAA,QAAA,WAAW,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;IAE9BA,KAAAA,OAAO,WAAlB,UAAA,GAAA,mBAEM,OAFN,YAEM,CADJ,WAAQ,KAAA,QAAA,SAAA,CAAA,CAAA,KAAA,mBAAA,IAAA,IAAA"}
|