nuxt-ui-tools 1.24.0 → 1.25.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/dist/module.d.mts +3 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +8 -0
- package/dist/runtime/display/components/blocks/display-accordion.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-accordion.vue +93 -0
- package/dist/runtime/display/components/blocks/display-accordion.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-alert.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-alert.vue +133 -0
- package/dist/runtime/display/components/blocks/display-alert.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-breakdown.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-breakdown.vue +178 -0
- package/dist/runtime/display/components/blocks/display-breakdown.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-chart.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-chart.vue +237 -0
- package/dist/runtime/display/components/blocks/display-chart.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-code.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-code.vue +143 -0
- package/dist/runtime/display/components/blocks/display-code.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-date.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-date.vue +174 -0
- package/dist/runtime/display/components/blocks/display-date.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-diff.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-diff.vue +142 -0
- package/dist/runtime/display/components/blocks/display-diff.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-empty.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-empty.vue +74 -0
- package/dist/runtime/display/components/blocks/display-empty.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-facts.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-facts.vue +180 -0
- package/dist/runtime/display/components/blocks/display-facts.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-heading.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-heading.vue +96 -0
- package/dist/runtime/display/components/blocks/display-heading.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-list.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-list.vue +295 -0
- package/dist/runtime/display/components/blocks/display-list.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-media.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-media.vue +326 -0
- package/dist/runtime/display/components/blocks/display-media.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-meter.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-meter.vue +301 -0
- package/dist/runtime/display/components/blocks/display-meter.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-person.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-person.vue +146 -0
- package/dist/runtime/display/components/blocks/display-person.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-record.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-record.vue +208 -0
- package/dist/runtime/display/components/blocks/display-record.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-stat.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-stat.vue +178 -0
- package/dist/runtime/display/components/blocks/display-stat.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-table.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-table.vue +132 -0
- package/dist/runtime/display/components/blocks/display-table.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-text.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-text.vue +135 -0
- package/dist/runtime/display/components/blocks/display-text.vue.d.ts +4 -0
- package/dist/runtime/display/components/blocks/display-timeline.d.vue.ts +4 -0
- package/dist/runtime/display/components/blocks/display-timeline.vue +232 -0
- package/dist/runtime/display/components/blocks/display-timeline.vue.d.ts +4 -0
- package/dist/runtime/display/components/display.d.vue.ts +24 -0
- package/dist/runtime/display/components/display.vue +21 -0
- package/dist/runtime/display/components/display.vue.d.ts +24 -0
- package/dist/runtime/display/components/parts/display-actions.d.vue.ts +9 -0
- package/dist/runtime/display/components/parts/display-actions.vue +24 -0
- package/dist/runtime/display/components/parts/display-actions.vue.d.ts +9 -0
- package/dist/runtime/display/components/parts/display-chip.d.vue.ts +11 -0
- package/dist/runtime/display/components/parts/display-chip.vue +45 -0
- package/dist/runtime/display/components/parts/display-chip.vue.d.ts +11 -0
- package/dist/runtime/display/components/parts/display-copy.d.vue.ts +6 -0
- package/dist/runtime/display/components/parts/display-copy.vue +27 -0
- package/dist/runtime/display/components/parts/display-copy.vue.d.ts +6 -0
- package/dist/runtime/display/components/parts/display-empty-line.d.vue.ts +7 -0
- package/dist/runtime/display/components/parts/display-empty-line.vue +21 -0
- package/dist/runtime/display/components/parts/display-empty-line.vue.d.ts +7 -0
- package/dist/runtime/display/components/parts/display-fact-value.d.vue.ts +7 -0
- package/dist/runtime/display/components/parts/display-fact-value.vue +35 -0
- package/dist/runtime/display/components/parts/display-fact-value.vue.d.ts +7 -0
- package/dist/runtime/display/components/parts/display-load-error.d.vue.ts +7 -0
- package/dist/runtime/display/components/parts/display-load-error.vue +29 -0
- package/dist/runtime/display/components/parts/display-load-error.vue.d.ts +7 -0
- package/dist/runtime/display/components/parts/display-more.d.vue.ts +10 -0
- package/dist/runtime/display/components/parts/display-more.vue +23 -0
- package/dist/runtime/display/components/parts/display-more.vue.d.ts +10 -0
- package/dist/runtime/display/components/parts/display-record-media.d.vue.ts +9 -0
- package/dist/runtime/display/components/parts/display-record-media.vue +59 -0
- package/dist/runtime/display/components/parts/display-record-media.vue.d.ts +9 -0
- package/dist/runtime/display/components/parts/display-render.d.ts +10 -0
- package/dist/runtime/display/components/parts/display-render.js +5 -0
- package/dist/runtime/display/components/parts/display-skeleton.d.vue.ts +7 -0
- package/dist/runtime/display/components/parts/display-skeleton.vue +67 -0
- package/dist/runtime/display/components/parts/display-skeleton.vue.d.ts +7 -0
- package/dist/runtime/display/composables/use-display-config.d.ts +6 -0
- package/dist/runtime/display/composables/use-display-config.js +11 -0
- package/dist/runtime/display/composables/use-display-file-preview.d.ts +9 -0
- package/dist/runtime/display/composables/use-display-file-preview.js +11 -0
- package/dist/runtime/display/composables/use-display-icons.d.ts +8 -0
- package/dist/runtime/display/composables/use-display-icons.js +62 -0
- package/dist/runtime/display/composables/use-display-locale.d.ts +5 -0
- package/dist/runtime/display/composables/use-display-locale.js +5 -0
- package/dist/runtime/display/composables/use-display-number.d.ts +2 -0
- package/dist/runtime/display/composables/use-display-number.js +7 -0
- package/dist/runtime/display/composables/use-display-reveal.d.ts +14 -0
- package/dist/runtime/display/composables/use-display-reveal.js +15 -0
- package/dist/runtime/display/composables/use-display-url.d.ts +26 -0
- package/dist/runtime/display/composables/use-display-url.js +46 -0
- package/dist/runtime/display/index.d.ts +4 -0
- package/dist/runtime/display/index.js +3 -0
- package/dist/runtime/display/plugins/display-tones.d.ts +3 -0
- package/dist/runtime/display/plugins/display-tones.js +17 -0
- package/dist/runtime/display/types/blocks/accordion.d.ts +18 -0
- package/dist/runtime/display/types/blocks/accordion.js +0 -0
- package/dist/runtime/display/types/blocks/alert.d.ts +31 -0
- package/dist/runtime/display/types/blocks/alert.js +0 -0
- package/dist/runtime/display/types/blocks/breakdown.d.ts +36 -0
- package/dist/runtime/display/types/blocks/breakdown.js +0 -0
- package/dist/runtime/display/types/blocks/chart.d.ts +23 -0
- package/dist/runtime/display/types/blocks/chart.js +0 -0
- package/dist/runtime/display/types/blocks/code.d.ts +21 -0
- package/dist/runtime/display/types/blocks/code.js +0 -0
- package/dist/runtime/display/types/blocks/date.d.ts +27 -0
- package/dist/runtime/display/types/blocks/date.js +0 -0
- package/dist/runtime/display/types/blocks/diff.d.ts +20 -0
- package/dist/runtime/display/types/blocks/diff.js +0 -0
- package/dist/runtime/display/types/blocks/empty.d.ts +13 -0
- package/dist/runtime/display/types/blocks/empty.js +0 -0
- package/dist/runtime/display/types/blocks/facts.d.ts +50 -0
- package/dist/runtime/display/types/blocks/facts.js +0 -0
- package/dist/runtime/display/types/blocks/heading.d.ts +19 -0
- package/dist/runtime/display/types/blocks/heading.js +0 -0
- package/dist/runtime/display/types/blocks/list.d.ts +36 -0
- package/dist/runtime/display/types/blocks/list.js +0 -0
- package/dist/runtime/display/types/blocks/media.d.ts +42 -0
- package/dist/runtime/display/types/blocks/media.js +0 -0
- package/dist/runtime/display/types/blocks/meter.d.ts +48 -0
- package/dist/runtime/display/types/blocks/meter.js +0 -0
- package/dist/runtime/display/types/blocks/person.d.ts +32 -0
- package/dist/runtime/display/types/blocks/person.js +0 -0
- package/dist/runtime/display/types/blocks/record.d.ts +42 -0
- package/dist/runtime/display/types/blocks/record.js +0 -0
- package/dist/runtime/display/types/blocks/stat.d.ts +44 -0
- package/dist/runtime/display/types/blocks/stat.js +0 -0
- package/dist/runtime/display/types/blocks/table.d.ts +28 -0
- package/dist/runtime/display/types/blocks/table.js +0 -0
- package/dist/runtime/display/types/blocks/text.d.ts +22 -0
- package/dist/runtime/display/types/blocks/text.js +0 -0
- package/dist/runtime/display/types/blocks/timeline.d.ts +37 -0
- package/dist/runtime/display/types/blocks/timeline.js +0 -0
- package/dist/runtime/display/types/config.d.ts +53 -0
- package/dist/runtime/display/types/config.js +0 -0
- package/dist/runtime/display/types/index.d.ts +22 -0
- package/dist/runtime/display/types/index.js +0 -0
- package/dist/runtime/display/types/registry.d.ts +57 -0
- package/dist/runtime/display/types/registry.js +0 -0
- package/dist/runtime/display/types/shared.d.ts +71 -0
- package/dist/runtime/display/types/shared.js +0 -0
- package/dist/runtime/display/utils/classes.d.ts +3 -0
- package/dist/runtime/display/utils/classes.js +7 -0
- package/dist/runtime/display/utils/config.d.ts +6 -0
- package/dist/runtime/display/utils/config.js +7 -0
- package/dist/runtime/display/utils/content.d.ts +7 -0
- package/dist/runtime/display/utils/content.js +13 -0
- package/dist/runtime/display/utils/dates.d.ts +16 -0
- package/dist/runtime/display/utils/dates.js +34 -0
- package/dist/runtime/display/utils/json.d.ts +7 -0
- package/dist/runtime/display/utils/json.js +15 -0
- package/dist/runtime/display/utils/meter.d.ts +7 -0
- package/dist/runtime/display/utils/meter.js +13 -0
- package/dist/runtime/display/utils/registry.d.ts +47 -0
- package/dist/runtime/display/utils/registry.js +64 -0
- package/dist/runtime/display/utils/tone-css.d.ts +7 -0
- package/dist/runtime/display/utils/tone-css.js +38 -0
- package/dist/runtime/display/utils/tone.d.ts +26 -0
- package/dist/runtime/display/utils/tone.js +38 -0
- package/dist/runtime/display/utils/urls.d.ts +10 -0
- package/dist/runtime/display/utils/urls.js +33 -0
- package/dist/runtime/file-preview/components/shell/file-preview-stage.vue +5 -3
- package/dist/runtime/file-preview/composables/use-file-preview-source.d.ts +7 -0
- package/dist/runtime/file-preview/composables/use-file-preview-source.js +7 -1
- package/dist/runtime/file-preview/index.d.ts +1 -0
- package/dist/runtime/file-preview/index.js +1 -0
- package/dist/runtime/file-preview/types/file.d.ts +9 -0
- package/dist/runtime/file-preview/utils/errors.d.ts +30 -0
- package/dist/runtime/file-preview/utils/errors.js +26 -0
- package/dist/runtime/form/components/utils/form-file-preview.vue +7 -2
- package/dist/runtime/form/composables/use-form-root.js +2 -0
- package/dist/runtime/form/composables/use-form-runtime.js +7 -2
- package/dist/runtime/form/fields/index.d.ts +5 -0
- package/dist/runtime/form/fields/info/component.vue +51 -19
- package/dist/runtime/form/fields/info/config.d.ts +5 -0
- package/dist/runtime/form/fields/info/config.js +2 -1
- package/dist/runtime/form/fields/info/types.d.ts +78 -4
- package/dist/runtime/form/fields/info/use-info-display.d.ts +20 -0
- package/dist/runtime/form/fields/info/use-info-display.js +82 -0
- package/dist/runtime/form/fields/upload/upload-item.vue +10 -2
- package/dist/runtime/form/types/api.d.ts +6 -0
- package/dist/runtime/form/types/runtime.d.ts +2 -0
- package/dist/runtime/form/utils/dynamic.d.ts +6 -0
- package/dist/runtime/form/utils/dynamic.js +7 -0
- package/dist/runtime/i18n/locales/en.js +27 -0
- package/dist/runtime/i18n/locales/fr.js +27 -0
- package/dist/runtime/i18n/types.d.ts +35 -0
- package/dist/runtime/shared/styles/tokens.css +1 -1
- package/dist/runtime/shared/utils/file.d.ts +1 -1
- package/dist/runtime/table/utils/data-list-ui.d.ts +1 -1
- package/package.json +16 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UIcon from "@nuxt/ui/components/Icon.vue";
|
|
3
|
+
import { useResizeObserver } from "@vueuse/core";
|
|
4
|
+
import { computed, ref, useTemplateRef } from "vue";
|
|
5
|
+
import { useDisplayAppUi } from "../../composables/use-display-config";
|
|
6
|
+
import { useDisplayLocale } from "../../composables/use-display-locale";
|
|
7
|
+
import { resolveDisplayClasses } from "../../utils/classes";
|
|
8
|
+
import { isDisplayContentEmpty } from "../../utils/content";
|
|
9
|
+
import { displayToneClass } from "../../utils/tone";
|
|
10
|
+
import DisplayRender from "../parts/display-render";
|
|
11
|
+
import DisplaySkeleton from "../parts/display-skeleton.vue";
|
|
12
|
+
const {
|
|
13
|
+
appearance = "body",
|
|
14
|
+
text = void 0,
|
|
15
|
+
paragraphs = void 0,
|
|
16
|
+
title = void 0,
|
|
17
|
+
icon = void 0,
|
|
18
|
+
author = void 0,
|
|
19
|
+
meta = void 0,
|
|
20
|
+
tone = void 0,
|
|
21
|
+
maxLines = void 0,
|
|
22
|
+
loading = false,
|
|
23
|
+
ui = void 0
|
|
24
|
+
} = defineProps({
|
|
25
|
+
appearance: { type: String, required: false },
|
|
26
|
+
text: { type: [String, Number, Function, Object, Boolean, null, Array], required: false, skipCheck: true },
|
|
27
|
+
paragraphs: { type: Array, required: false },
|
|
28
|
+
title: { type: [String, Number, Function, Object, Boolean, null, Array], required: false, skipCheck: true },
|
|
29
|
+
icon: { type: String, required: false },
|
|
30
|
+
author: { type: [String, Number, Function, Object, Boolean, null, Array], required: false, skipCheck: true },
|
|
31
|
+
meta: { type: [String, Number, Function, Object, Boolean, null, Array], required: false, skipCheck: true },
|
|
32
|
+
tone: { type: String, required: false },
|
|
33
|
+
maxLines: { type: Number, required: false },
|
|
34
|
+
loading: { type: Boolean, required: false },
|
|
35
|
+
ui: { type: Object, required: false }
|
|
36
|
+
});
|
|
37
|
+
const ROOT_CLASSES = {
|
|
38
|
+
body: "text-sm leading-relaxed text-default",
|
|
39
|
+
caption: "flex items-start gap-1.5 text-xs leading-snug text-dimmed",
|
|
40
|
+
lead: "text-base leading-snug text-highlighted",
|
|
41
|
+
legal: "rounded-e-[var(--nut-display-radius)] border border-s-[3px] border-muted border-s-[var(--nut-tone-line)] bg-elevated px-3.5 py-3",
|
|
42
|
+
muted: "text-sm leading-relaxed text-muted",
|
|
43
|
+
prose: "text-sm leading-relaxed text-default [&_a]:text-primary [&_a]:underline [&_a]:underline-offset-2 [&_b]:font-semibold [&_b]:text-highlighted [&_code]:rounded [&_code]:border [&_code]:border-muted [&_code]:bg-elevated [&_code]:px-1 [&_code]:text-[0.88em] [&_li]:my-0.5 [&_ol]:list-decimal [&_ol]:ps-5 [&_strong]:font-semibold [&_strong]:text-highlighted [&_ul]:list-disc [&_ul]:ps-5",
|
|
44
|
+
quote: "border-s-[3px] border-[var(--nut-tone)] ps-4"
|
|
45
|
+
};
|
|
46
|
+
const PARAGRAPH_CLASSES = {
|
|
47
|
+
body: "mt-2 first:mt-0",
|
|
48
|
+
caption: "",
|
|
49
|
+
lead: "mt-2 first:mt-0",
|
|
50
|
+
legal: "mt-1.5 text-xs leading-relaxed text-muted",
|
|
51
|
+
muted: "mt-2 first:mt-0",
|
|
52
|
+
prose: "mt-2 first:mt-0",
|
|
53
|
+
quote: "mt-2 text-[15px] leading-relaxed font-light text-highlighted first:mt-0"
|
|
54
|
+
};
|
|
55
|
+
const { t } = useDisplayLocale();
|
|
56
|
+
const appUi = useDisplayAppUi("text");
|
|
57
|
+
const body = useTemplateRef("body");
|
|
58
|
+
const expanded = ref(false);
|
|
59
|
+
const overflowing = ref(false);
|
|
60
|
+
const resolvedTone = computed(() => tone ?? (appearance === "quote" ? "primary" : "neutral"));
|
|
61
|
+
const blocks = computed(
|
|
62
|
+
() => [text, ...paragraphs ?? []].filter((content) => !isDisplayContentEmpty(content))
|
|
63
|
+
);
|
|
64
|
+
const clampStyle = computed(
|
|
65
|
+
() => maxLines && !expanded.value ? {
|
|
66
|
+
WebkitBoxOrient: "vertical",
|
|
67
|
+
WebkitLineClamp: maxLines,
|
|
68
|
+
display: "-webkit-box",
|
|
69
|
+
overflow: "hidden"
|
|
70
|
+
} : void 0
|
|
71
|
+
);
|
|
72
|
+
const classes = computed(
|
|
73
|
+
() => resolveDisplayClasses(
|
|
74
|
+
{
|
|
75
|
+
footer: "mt-2 text-xs text-muted",
|
|
76
|
+
header: "flex items-center gap-1.5 text-xs font-bold text-toned",
|
|
77
|
+
icon: appearance === "caption" ? "mt-px size-3.5 shrink-0" : "size-3.5 shrink-0",
|
|
78
|
+
paragraph: PARAGRAPH_CLASSES[appearance],
|
|
79
|
+
root: ROOT_CLASSES[appearance],
|
|
80
|
+
title: "min-w-0",
|
|
81
|
+
toggle: "mt-1 cursor-pointer text-xs font-semibold text-primary underline underline-offset-2"
|
|
82
|
+
},
|
|
83
|
+
appUi.value,
|
|
84
|
+
ui
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
useResizeObserver(body, () => {
|
|
88
|
+
const element = body.value;
|
|
89
|
+
if (element && !expanded.value)
|
|
90
|
+
overflowing.value = element.scrollHeight > element.clientHeight + 1;
|
|
91
|
+
});
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<template>
|
|
95
|
+
<DisplaySkeleton v-if="loading" :count="Math.max(blocks.length, 2)" />
|
|
96
|
+
<div
|
|
97
|
+
v-else
|
|
98
|
+
:class="[classes.root, displayToneClass(resolvedTone)]"
|
|
99
|
+
:data-appearance="appearance"
|
|
100
|
+
data-display="text"
|
|
101
|
+
>
|
|
102
|
+
<div
|
|
103
|
+
v-if="appearance === 'legal' && (!isDisplayContentEmpty(title) || icon)"
|
|
104
|
+
:class="classes.header"
|
|
105
|
+
>
|
|
106
|
+
<UIcon v-if="icon" :name="icon" :class="classes.icon" />
|
|
107
|
+
<span :class="classes.title"><DisplayRender :content="title" /></span>
|
|
108
|
+
</div>
|
|
109
|
+
<UIcon v-if="appearance === 'caption' && icon" :name="icon" :class="classes.icon" />
|
|
110
|
+
<div ref="body" :style="clampStyle">
|
|
111
|
+
<div v-for="(content, index) in blocks" :key="index" :class="classes.paragraph">
|
|
112
|
+
<DisplayRender :content="content" />
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
<button
|
|
116
|
+
v-if="maxLines && (overflowing || expanded)"
|
|
117
|
+
type="button"
|
|
118
|
+
:class="classes.toggle"
|
|
119
|
+
:aria-expanded="expanded"
|
|
120
|
+
@click="expanded = !expanded"
|
|
121
|
+
>
|
|
122
|
+
{{ expanded ? t("display.readLess") : t("display.readMore") }}
|
|
123
|
+
</button>
|
|
124
|
+
<div
|
|
125
|
+
v-if="
|
|
126
|
+
appearance === 'quote' && (!isDisplayContentEmpty(author) || !isDisplayContentEmpty(meta))
|
|
127
|
+
"
|
|
128
|
+
:class="classes.footer"
|
|
129
|
+
>
|
|
130
|
+
<DisplayRender :content="author" />
|
|
131
|
+
<template v-if="!isDisplayContentEmpty(author) && !isDisplayContentEmpty(meta)"> · </template>
|
|
132
|
+
<DisplayRender :content="meta" />
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</template>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DisplayTextProps } from '../../types/index.js';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<DisplayTextProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DisplayTextProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DisplayTimelineProps } from '../../types/index.js';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<DisplayTimelineProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DisplayTimelineProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UAvatar from "@nuxt/ui/components/Avatar.vue";
|
|
3
|
+
import UIcon from "@nuxt/ui/components/Icon.vue";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
import { useDisplayAppUi } from "../../composables/use-display-config";
|
|
6
|
+
import { useDisplayIcons } from "../../composables/use-display-icons";
|
|
7
|
+
import { useDisplayLocale } from "../../composables/use-display-locale";
|
|
8
|
+
import { useDisplayReveal } from "../../composables/use-display-reveal";
|
|
9
|
+
import { resolveDisplayClasses } from "../../utils/classes";
|
|
10
|
+
import { isDisplayContentEmpty, resolveDisplayText } from "../../utils/content";
|
|
11
|
+
import { formatDisplayDate, toDisplayDate } from "../../utils/dates";
|
|
12
|
+
import { displayToneClass, initialsOf, toneFromName } from "../../utils/tone";
|
|
13
|
+
import DisplayEmptyLine from "../parts/display-empty-line.vue";
|
|
14
|
+
import DisplayMore from "../parts/display-more.vue";
|
|
15
|
+
import DisplayRender from "../parts/display-render";
|
|
16
|
+
import DisplaySkeleton from "../parts/display-skeleton.vue";
|
|
17
|
+
const {
|
|
18
|
+
variant = "vertical",
|
|
19
|
+
items,
|
|
20
|
+
current = void 0,
|
|
21
|
+
now = void 0,
|
|
22
|
+
nowLabel = void 0,
|
|
23
|
+
dateFormat = void 0,
|
|
24
|
+
max = void 0,
|
|
25
|
+
step = void 0,
|
|
26
|
+
empty = void 0,
|
|
27
|
+
loading = false,
|
|
28
|
+
ui = void 0
|
|
29
|
+
} = defineProps({
|
|
30
|
+
variant: { type: String, required: false },
|
|
31
|
+
items: { type: Array, required: true },
|
|
32
|
+
current: { type: Number, required: false },
|
|
33
|
+
now: { type: [Date, String, Number], required: false },
|
|
34
|
+
nowLabel: { type: [String, Number, Function], required: false },
|
|
35
|
+
dateFormat: { type: null, required: false },
|
|
36
|
+
loading: { type: Boolean, required: false },
|
|
37
|
+
ui: { type: Object, required: false },
|
|
38
|
+
max: { type: Number, required: false },
|
|
39
|
+
step: { type: Number, required: false },
|
|
40
|
+
empty: { type: [String, Number, Function, Object, Boolean, null, Array], required: false, skipCheck: true }
|
|
41
|
+
});
|
|
42
|
+
const { t, code } = useDisplayLocale();
|
|
43
|
+
const icons = useDisplayIcons();
|
|
44
|
+
const appUi = useDisplayAppUi("timeline");
|
|
45
|
+
const reference = computed(() => toDisplayDate(now) ?? /* @__PURE__ */ new Date());
|
|
46
|
+
const entries = computed(
|
|
47
|
+
() => items.map((item, index) => {
|
|
48
|
+
const date = toDisplayDate(item.date);
|
|
49
|
+
return { ...item, resolvedState: stateOf(item, index, date), timeLabel: timeOf(item, date) };
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
const reveal = useDisplayReveal({ items: () => entries.value, max: () => max, step: () => step });
|
|
53
|
+
const nowIndex = computed(
|
|
54
|
+
() => variant === "schedule" ? reveal.visible.value.findIndex((entry) => entry.resolvedState === "upcoming") : -1
|
|
55
|
+
);
|
|
56
|
+
const nowText = computed(
|
|
57
|
+
() => resolveDisplayText(nowLabel) ?? `${t("display.today")} \xB7 ${formatDisplayDate(reference.value, code.value, { day: "numeric", month: "short" })}`
|
|
58
|
+
);
|
|
59
|
+
const classes = computed(
|
|
60
|
+
() => resolveDisplayClasses(
|
|
61
|
+
{
|
|
62
|
+
actor: "flex items-center gap-1.5",
|
|
63
|
+
body: "min-w-0",
|
|
64
|
+
connector: "absolute start-[7.5px] top-4 -bottom-px w-px bg-[var(--ui-border)]",
|
|
65
|
+
description: "mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted",
|
|
66
|
+
empty: "",
|
|
67
|
+
item: variant === "pipeline" ? "relative flex min-w-0 flex-1 flex-col items-center gap-1.5 text-center" : variant === "log" ? "flex items-center gap-2.5 px-3 py-1.5 text-sm" : "relative grid grid-cols-[1rem_minmax(0,1fr)] gap-x-3 pb-3.5 last:pb-0",
|
|
68
|
+
marker: variant === "pipeline" ? "relative z-[1] grid size-6 place-items-center rounded-full border-2 text-[10px] font-bold" : "relative z-[1] mt-1 ms-[3px] size-2.5 rounded-full",
|
|
69
|
+
more: "self-start",
|
|
70
|
+
now: "mb-3.5 flex items-center gap-2 text-[11px] font-bold tracking-[0.06em] text-[var(--nut-display-primary-ink)] uppercase before:h-0.5 before:w-4 before:rounded-full before:bg-[var(--nut-display-primary)] after:h-px after:flex-1 after:bg-[var(--nut-display-primary-line)]",
|
|
71
|
+
root: variant === "log" ? "flex min-w-0 flex-col divide-y divide-muted rounded-[var(--nut-display-radius)] border border-default" : "flex min-w-0 flex-col gap-2",
|
|
72
|
+
time: variant === "log" ? "w-11 shrink-0 font-mono text-[11px] text-dimmed" : "shrink-0 text-xs font-normal text-dimmed",
|
|
73
|
+
title: variant === "pipeline" ? "text-xs font-semibold text-highlighted" : "flex items-baseline justify-between gap-2 text-sm font-semibold text-highlighted"
|
|
74
|
+
},
|
|
75
|
+
appUi.value,
|
|
76
|
+
ui
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
function stateOf(item, index, date) {
|
|
80
|
+
if (item.state) return item.state;
|
|
81
|
+
if (variant === "pipeline" && current !== void 0)
|
|
82
|
+
return index < current ? "done" : index === current ? "current" : "upcoming";
|
|
83
|
+
if (date) return date.getTime() > reference.value.getTime() ? "upcoming" : "done";
|
|
84
|
+
return "done";
|
|
85
|
+
}
|
|
86
|
+
function timeOf(item, date) {
|
|
87
|
+
const text = resolveDisplayText(item.time);
|
|
88
|
+
if (text !== void 0 || !date) return text;
|
|
89
|
+
const options = dateFormat ?? (variant === "log" ? { hour: "2-digit", minute: "2-digit" } : { day: "numeric", month: "short" });
|
|
90
|
+
return formatDisplayDate(date, code.value, options);
|
|
91
|
+
}
|
|
92
|
+
function dotClass(state) {
|
|
93
|
+
if (state === "upcoming")
|
|
94
|
+
return "border-[1.5px] border-dashed border-[var(--ui-border-accented)] bg-default";
|
|
95
|
+
if (state === "current") return "bg-[var(--nut-tone)] ring-4 ring-[var(--nut-tone-soft)]";
|
|
96
|
+
return "bg-[var(--nut-tone)] ring-3 ring-[var(--nut-tone-soft)]";
|
|
97
|
+
}
|
|
98
|
+
function stageClass(state) {
|
|
99
|
+
if (state === "done") return "border-[var(--ui-bg-inverted)] bg-inverted text-inverted";
|
|
100
|
+
if (state === "current")
|
|
101
|
+
return "border-[var(--nut-tone)] bg-[var(--nut-tone)] text-[var(--nut-tone-contrast)] ring-4 ring-[var(--nut-tone-soft)]";
|
|
102
|
+
return "border-[var(--ui-border-accented)] bg-default text-dimmed";
|
|
103
|
+
}
|
|
104
|
+
function actorAvatar(name) {
|
|
105
|
+
return {
|
|
106
|
+
alt: name,
|
|
107
|
+
class: displayToneClass(toneFromName(name)),
|
|
108
|
+
size: "3xs",
|
|
109
|
+
text: initialsOf(name),
|
|
110
|
+
ui: {
|
|
111
|
+
fallback: "text-[8px] font-bold text-[var(--nut-tone-ink)]",
|
|
112
|
+
root: "bg-[var(--nut-tone-soft)]"
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<template>
|
|
119
|
+
<DisplaySkeleton v-if="loading" :count="Math.min(Math.max(items.length, 2), 5)" />
|
|
120
|
+
<DisplayEmptyLine v-else-if="!items.length" :content="empty" :class="classes.empty" />
|
|
121
|
+
<div
|
|
122
|
+
v-else-if="variant === 'log'"
|
|
123
|
+
:class="classes.root"
|
|
124
|
+
data-display="timeline"
|
|
125
|
+
data-variant="log"
|
|
126
|
+
>
|
|
127
|
+
<div v-for="(entry, index) in reveal.visible.value" :key="index" :class="classes.item">
|
|
128
|
+
<time :class="classes.time">{{ entry.timeLabel }}</time>
|
|
129
|
+
<UAvatar
|
|
130
|
+
v-if="entry.actor"
|
|
131
|
+
v-bind="actorAvatar(resolveDisplayText(entry.actor.name) ?? '')"
|
|
132
|
+
:src="entry.actor.avatar?.src"
|
|
133
|
+
class="shrink-0"
|
|
134
|
+
/>
|
|
135
|
+
<span class="min-w-0 flex-1 text-toned">
|
|
136
|
+
<b v-if="entry.actor" class="font-semibold text-highlighted">{{
|
|
137
|
+
resolveDisplayText(entry.actor.name)
|
|
138
|
+
}}</b>
|
|
139
|
+
{{ " " }}<DisplayRender :content="entry.title" />
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
<ol
|
|
144
|
+
v-else-if="variant === 'pipeline'"
|
|
145
|
+
class="m-0 flex list-none p-0"
|
|
146
|
+
data-display="timeline"
|
|
147
|
+
data-variant="pipeline"
|
|
148
|
+
>
|
|
149
|
+
<li
|
|
150
|
+
v-for="(entry, index) in entries"
|
|
151
|
+
:key="index"
|
|
152
|
+
:class="[classes.item, displayToneClass(entry.tone ?? 'primary')]"
|
|
153
|
+
:data-state="entry.resolvedState"
|
|
154
|
+
:aria-current="entry.resolvedState === 'current' ? 'step' : void 0"
|
|
155
|
+
>
|
|
156
|
+
<span
|
|
157
|
+
v-if="index > 0"
|
|
158
|
+
:class="[
|
|
159
|
+
'absolute top-[11px] -start-1/2 h-0.5 w-full',
|
|
160
|
+
entry.resolvedState === 'upcoming' ? 'bg-[var(--ui-border)]' : 'bg-inverted'
|
|
161
|
+
]"
|
|
162
|
+
aria-hidden="true"
|
|
163
|
+
/>
|
|
164
|
+
<span :class="[classes.marker, stageClass(entry.resolvedState)]">
|
|
165
|
+
<UIcon
|
|
166
|
+
v-if="entry.resolvedState === 'done'"
|
|
167
|
+
:name="entry.icon ?? icons.check"
|
|
168
|
+
class="size-3"
|
|
169
|
+
/>
|
|
170
|
+
<UIcon v-else-if="entry.icon" :name="entry.icon" class="size-3" />
|
|
171
|
+
<template v-else>{{ index + 1 }}</template>
|
|
172
|
+
</span>
|
|
173
|
+
<span
|
|
174
|
+
:class="[classes.title, entry.resolvedState === 'upcoming' ? 'font-medium text-muted' : '']"
|
|
175
|
+
>
|
|
176
|
+
<DisplayRender :content="entry.title" />
|
|
177
|
+
</span>
|
|
178
|
+
<span v-if="entry.timeLabel" :class="['-mt-1 text-[11px]', classes.time]">{{
|
|
179
|
+
entry.timeLabel
|
|
180
|
+
}}</span>
|
|
181
|
+
</li>
|
|
182
|
+
</ol>
|
|
183
|
+
<div v-else :class="classes.root" data-display="timeline" :data-variant="variant">
|
|
184
|
+
<ol class="m-0 list-none p-0">
|
|
185
|
+
<template v-for="(entry, index) in reveal.visible.value" :key="index">
|
|
186
|
+
<li v-if="index === nowIndex" :class="classes.now" data-display-now>{{ nowText }}</li>
|
|
187
|
+
<li
|
|
188
|
+
:class="[classes.item, displayToneClass(entry.tone ?? 'neutral')]"
|
|
189
|
+
:data-state="entry.resolvedState"
|
|
190
|
+
>
|
|
191
|
+
<span
|
|
192
|
+
v-if="index < reveal.visible.value.length - 1"
|
|
193
|
+
:class="[
|
|
194
|
+
classes.connector,
|
|
195
|
+
reveal.visible.value[index + 1]?.resolvedState === 'upcoming' ? 'bg-[repeating-linear-gradient(var(--ui-border-accented)_0_3px,transparent_3px_6px)]' : ''
|
|
196
|
+
]"
|
|
197
|
+
aria-hidden="true"
|
|
198
|
+
/>
|
|
199
|
+
<span :class="[classes.marker, dotClass(entry.resolvedState)]" aria-hidden="true" />
|
|
200
|
+
<div :class="classes.body">
|
|
201
|
+
<div :class="[classes.title, entry.resolvedState === 'upcoming' ? 'text-muted' : '']">
|
|
202
|
+
<span class="min-w-0"><DisplayRender :content="entry.title" /></span>
|
|
203
|
+
<time v-if="entry.timeLabel" :class="classes.time">{{ entry.timeLabel }}</time>
|
|
204
|
+
</div>
|
|
205
|
+
<div
|
|
206
|
+
v-if="entry.actor || !isDisplayContentEmpty(entry.description)"
|
|
207
|
+
:class="classes.description"
|
|
208
|
+
>
|
|
209
|
+
<span v-if="entry.actor" :class="classes.actor">
|
|
210
|
+
<UAvatar
|
|
211
|
+
v-bind="actorAvatar(resolveDisplayText(entry.actor.name) ?? '')"
|
|
212
|
+
:src="entry.actor.avatar?.src"
|
|
213
|
+
/>
|
|
214
|
+
{{ resolveDisplayText(entry.actor.name) }}
|
|
215
|
+
</span>
|
|
216
|
+
<template v-if="entry.actor && !isDisplayContentEmpty(entry.description)">
|
|
217
|
+
·
|
|
218
|
+
</template>
|
|
219
|
+
<DisplayRender :content="entry.description" />
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
</li>
|
|
223
|
+
</template>
|
|
224
|
+
</ol>
|
|
225
|
+
<DisplayMore
|
|
226
|
+
v-if="reveal.hidden.value"
|
|
227
|
+
:count="reveal.next.value"
|
|
228
|
+
:class="classes.more"
|
|
229
|
+
@reveal="reveal.reveal"
|
|
230
|
+
/>
|
|
231
|
+
</div>
|
|
232
|
+
</template>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DisplayTimelineProps } from '../../types/index.js';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<DisplayTimelineProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DisplayTimelineProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DisplayKind, DisplayPropsMap } from '../types/index.js';
|
|
2
|
+
declare const __VLS_export: <TKind extends DisplayKind>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<{
|
|
4
|
+
display: TKind;
|
|
5
|
+
props: DisplayPropsMap[TKind];
|
|
6
|
+
/** Name of a preset in `appConfig.nuxtUiTools.display.presets[display]`; `props` override it. */
|
|
7
|
+
preset?: string;
|
|
8
|
+
}> & (typeof globalThis extends {
|
|
9
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
10
|
+
} ? P : {});
|
|
11
|
+
expose: (exposed: {}) => void;
|
|
12
|
+
attrs: any;
|
|
13
|
+
slots: {};
|
|
14
|
+
emit: {};
|
|
15
|
+
}>) => import("vue").VNode & {
|
|
16
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
17
|
+
};
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
20
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
21
|
+
[K in keyof T]: T[K];
|
|
22
|
+
} : {
|
|
23
|
+
[K in keyof T as K]: T[K];
|
|
24
|
+
}) & {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useDisplayConfig } from "../composables/use-display-config";
|
|
4
|
+
import { applyDisplayPreset } from "../utils/config";
|
|
5
|
+
import { DISPLAY_BLOCKS } from "../utils/registry";
|
|
6
|
+
const {
|
|
7
|
+
display,
|
|
8
|
+
props: blockProps,
|
|
9
|
+
preset = void 0
|
|
10
|
+
} = defineProps({
|
|
11
|
+
display: { type: null, required: true },
|
|
12
|
+
props: { type: null, required: true },
|
|
13
|
+
preset: { type: String, required: false }
|
|
14
|
+
});
|
|
15
|
+
const config = useDisplayConfig();
|
|
16
|
+
const resolved = computed(() => applyDisplayPreset(display, blockProps, preset, config.value));
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<component :is="DISPLAY_BLOCKS[display]" v-bind="resolved" />
|
|
21
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DisplayKind, DisplayPropsMap } from '../types/index.js';
|
|
2
|
+
declare const __VLS_export: <TKind extends DisplayKind>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<{
|
|
4
|
+
display: TKind;
|
|
5
|
+
props: DisplayPropsMap[TKind];
|
|
6
|
+
/** Name of a preset in `appConfig.nuxtUiTools.display.presets[display]`; `props` override it. */
|
|
7
|
+
preset?: string;
|
|
8
|
+
}> & (typeof globalThis extends {
|
|
9
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
10
|
+
} ? P : {});
|
|
11
|
+
expose: (exposed: {}) => void;
|
|
12
|
+
attrs: any;
|
|
13
|
+
slots: {};
|
|
14
|
+
emit: {};
|
|
15
|
+
}>) => import("vue").VNode & {
|
|
16
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
17
|
+
};
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
20
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
21
|
+
[K in keyof T]: T[K];
|
|
22
|
+
} : {
|
|
23
|
+
[K in keyof T as K]: T[K];
|
|
24
|
+
}) & {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ButtonProps } from '@nuxt/ui/components/Button.vue';
|
|
2
|
+
import type { DisplayAction } from '../../types/index.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
actions: readonly DisplayAction[];
|
|
5
|
+
size?: ButtonProps['size'];
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UButton from "@nuxt/ui/components/Button.vue";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { resolveDisplayText } from "../../utils/content";
|
|
5
|
+
const { actions, size = "sm" } = defineProps({
|
|
6
|
+
actions: { type: Array, required: true },
|
|
7
|
+
size: { type: null, required: false }
|
|
8
|
+
});
|
|
9
|
+
const buttons = computed(
|
|
10
|
+
() => actions.map(({ label, ...action }) => ({
|
|
11
|
+
color: "neutral",
|
|
12
|
+
size,
|
|
13
|
+
variant: "outline",
|
|
14
|
+
...action,
|
|
15
|
+
label: resolveDisplayText(label)
|
|
16
|
+
}))
|
|
17
|
+
);
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div>
|
|
22
|
+
<UButton v-for="(button, index) in buttons" :key="index" v-bind="button" />
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ButtonProps } from '@nuxt/ui/components/Button.vue';
|
|
2
|
+
import type { DisplayAction } from '../../types/index.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
actions: readonly DisplayAction[];
|
|
5
|
+
size?: ButtonProps['size'];
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DisplayChip, DisplayContent, DisplayText } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
chip: Omit<DisplayChip, 'label'> & {
|
|
4
|
+
label?: DisplayText;
|
|
5
|
+
};
|
|
6
|
+
/** Rich content drawn instead of the label. */
|
|
7
|
+
content?: DisplayContent;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UBadge from "@nuxt/ui/components/Badge.vue";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { resolveDisplayText } from "../../utils/content";
|
|
5
|
+
import { displayToneClass, isBuiltinTone } from "../../utils/tone";
|
|
6
|
+
import DisplayRender from "./display-render";
|
|
7
|
+
const { chip, content = void 0 } = defineProps({
|
|
8
|
+
chip: { type: Object, required: true },
|
|
9
|
+
content: { type: [String, Number, Function, Object, Boolean, null, Array], required: false, skipCheck: true }
|
|
10
|
+
});
|
|
11
|
+
const SOFT = "bg-[var(--nut-tone-soft)] text-[var(--nut-tone-ink)] ring-0";
|
|
12
|
+
const VARIANT_CLASSES = [
|
|
13
|
+
[
|
|
14
|
+
"outline",
|
|
15
|
+
"bg-transparent text-[var(--nut-tone-ink)] ring ring-inset ring-[var(--nut-tone-line)]"
|
|
16
|
+
],
|
|
17
|
+
["solid", "bg-[var(--nut-tone)] text-[var(--nut-tone-contrast)] ring-0"],
|
|
18
|
+
[
|
|
19
|
+
"subtle",
|
|
20
|
+
"bg-[var(--nut-tone-soft)] text-[var(--nut-tone-ink)] ring ring-inset ring-[var(--nut-tone-line)]"
|
|
21
|
+
]
|
|
22
|
+
];
|
|
23
|
+
const badge = computed(() => {
|
|
24
|
+
const { label, tone, ...rest } = chip;
|
|
25
|
+
const variant = rest.variant ?? "soft";
|
|
26
|
+
const custom = tone !== void 0 && !isBuiltinTone(tone);
|
|
27
|
+
return {
|
|
28
|
+
...rest,
|
|
29
|
+
class: custom ? [displayToneClass(tone), variantClass(variant), rest.class] : rest.class,
|
|
30
|
+
color: custom ? "neutral" : rest.color ?? tone ?? "neutral",
|
|
31
|
+
label: content === void 0 ? resolveDisplayText(label) : void 0,
|
|
32
|
+
size: rest.size ?? "sm",
|
|
33
|
+
variant
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
function variantClass(variant) {
|
|
37
|
+
return VARIANT_CLASSES.find(([name]) => name === variant)?.[1] ?? SOFT;
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<UBadge v-bind="badge" :data-tone="chip.tone">
|
|
43
|
+
<DisplayRender v-if="content !== void 0" :content="content" />
|
|
44
|
+
</UBadge>
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DisplayChip, DisplayContent, DisplayText } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
chip: Omit<DisplayChip, 'label'> & {
|
|
4
|
+
label?: DisplayText;
|
|
5
|
+
};
|
|
6
|
+
/** Rich content drawn instead of the label. */
|
|
7
|
+
content?: DisplayContent;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
value: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UButton from "@nuxt/ui/components/Button.vue";
|
|
3
|
+
import { useClipboard } from "@vueuse/core";
|
|
4
|
+
import { useDisplayIcons } from "../../composables/use-display-icons";
|
|
5
|
+
import { useDisplayLocale } from "../../composables/use-display-locale";
|
|
6
|
+
const { value } = defineProps({
|
|
7
|
+
value: { type: String, required: true }
|
|
8
|
+
});
|
|
9
|
+
const { t } = useDisplayLocale();
|
|
10
|
+
const icons = useDisplayIcons();
|
|
11
|
+
const { copy, copied } = useClipboard({ copiedDuring: 1500, legacy: true });
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<UButton
|
|
16
|
+
:icon="copied ? icons.copyCheck : icons.copy"
|
|
17
|
+
:aria-label="copied ? t('display.copied') : t('display.copy')"
|
|
18
|
+
:title="copied ? t('display.copied') : t('display.copy')"
|
|
19
|
+
:class="copied ? 'text-success' : 'text-dimmed'"
|
|
20
|
+
color="neutral"
|
|
21
|
+
variant="ghost"
|
|
22
|
+
size="xs"
|
|
23
|
+
square
|
|
24
|
+
data-display-copy
|
|
25
|
+
@click.stop="copy(value)"
|
|
26
|
+
/>
|
|
27
|
+
</template>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
value: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DisplayContent } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
content?: DisplayContent;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UIcon from "@nuxt/ui/components/Icon.vue";
|
|
3
|
+
import { useDisplayIcons } from "../../composables/use-display-icons";
|
|
4
|
+
import { useDisplayLocale } from "../../composables/use-display-locale";
|
|
5
|
+
import DisplayRender from "./display-render";
|
|
6
|
+
const { content } = defineProps({
|
|
7
|
+
content: { type: [String, Number, Function, Object, Boolean, null, Array], required: false, skipCheck: true }
|
|
8
|
+
});
|
|
9
|
+
const { t } = useDisplayLocale();
|
|
10
|
+
const icons = useDisplayIcons();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<div
|
|
15
|
+
class="flex items-center justify-center gap-2 rounded-[var(--nut-display-radius)] border border-dashed border-accented px-4 py-4 text-sm text-muted"
|
|
16
|
+
data-display-empty
|
|
17
|
+
>
|
|
18
|
+
<UIcon :name="icons.empty" class="size-4 shrink-0 text-dimmed" />
|
|
19
|
+
<DisplayRender :content="content ?? t('display.empty')" />
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|