nuxt-ui-tools 1.23.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 +32 -0
- package/dist/runtime/i18n/locales/fr.js +32 -0
- package/dist/runtime/i18n/types.d.ts +40 -0
- package/dist/runtime/shared/styles/tokens.css +1 -1
- package/dist/runtime/shared/utils/file.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-root.vue +2 -0
- package/dist/runtime/table/components/data-list/data-list-selection-actions.d.vue.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-selection-actions.vue +32 -5
- package/dist/runtime/table/components/data-list/data-list-selection-actions.vue.d.ts +1 -1
- package/dist/runtime/table/components/data-list/data-list-selection-sheet.d.vue.ts +10 -0
- package/dist/runtime/table/components/data-list/data-list-selection-sheet.vue +238 -0
- package/dist/runtime/table/components/data-list/data-list-selection-sheet.vue.d.ts +10 -0
- package/dist/runtime/table/components/grid/grid-renderer.vue +2 -0
- package/dist/runtime/table/components/summary/summary-renderer.vue +2 -0
- package/dist/runtime/table/components/table/table-renderer.vue +2 -0
- package/dist/runtime/table/components/utils/overlay-inset-spacer.d.vue.ts +3 -0
- package/dist/runtime/table/components/utils/overlay-inset-spacer.vue +13 -0
- package/dist/runtime/table/components/utils/overlay-inset-spacer.vue.d.ts +3 -0
- package/dist/runtime/table/composables/use-data-list-overlay-inset.d.ts +10 -0
- package/dist/runtime/table/composables/use-data-list-overlay-inset.js +11 -0
- package/dist/runtime/table/composables/use-table-actions.js +11 -2
- package/dist/runtime/table/constants/mobile.d.ts +0 -7
- package/dist/runtime/table/constants/mobile.js +0 -1
- package/dist/runtime/table/types/actions.d.ts +7 -0
- package/dist/runtime/table/types/data-list.d.ts +8 -1
- package/dist/runtime/table/utils/data-list-ui.d.ts +1 -1
- package/package.json +16 -1
|
@@ -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,7 @@
|
|
|
1
|
+
import type { DisplayFact } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
fact: DisplayFact;
|
|
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,35 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import ULink from "@nuxt/ui/components/Link.vue";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { isString } from "../../../shared/utils/predicate";
|
|
5
|
+
import { displayContentText, isDisplayContentEmpty } from "../../utils/content";
|
|
6
|
+
import DisplayChip from "./display-chip.vue";
|
|
7
|
+
import DisplayCopy from "./display-copy.vue";
|
|
8
|
+
import DisplayRender from "./display-render";
|
|
9
|
+
const { fact } = defineProps({
|
|
10
|
+
fact: { type: Object, required: true }
|
|
11
|
+
});
|
|
12
|
+
const copyValue = computed(
|
|
13
|
+
() => isString(fact.copy) ? fact.copy : fact.copy ? displayContentText(fact.value) : void 0
|
|
14
|
+
);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<span
|
|
19
|
+
v-if="fact.loading"
|
|
20
|
+
class="nut-dash-shimmer nut-dash-ghost inline-block h-3.5 w-20 max-w-full rounded"
|
|
21
|
+
aria-busy="true"
|
|
22
|
+
data-display-fact-loading
|
|
23
|
+
/>
|
|
24
|
+
<DisplayChip v-else-if="fact.chip" :chip="fact.chip" />
|
|
25
|
+
<span v-else-if="isDisplayContentEmpty(fact.value)" class="font-medium text-dimmed">—</span>
|
|
26
|
+
<ULink
|
|
27
|
+
v-else-if="fact.to"
|
|
28
|
+
:to="fact.to"
|
|
29
|
+
class="underline decoration-[var(--ui-border-accented)] underline-offset-2 hover:decoration-current"
|
|
30
|
+
>
|
|
31
|
+
<DisplayRender :content="fact.value" />
|
|
32
|
+
</ULink>
|
|
33
|
+
<DisplayRender v-else :content="fact.value" />
|
|
34
|
+
<DisplayCopy v-if="copyValue && !fact.loading" :value="copyValue" class="-my-1" />
|
|
35
|
+
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DisplayFact } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
fact: DisplayFact;
|
|
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,7 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
2
|
+
retry: () => any;
|
|
3
|
+
}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
|
|
4
|
+
onRetry?: (() => any) | undefined;
|
|
5
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UButton from "@nuxt/ui/components/Button.vue";
|
|
3
|
+
import UIcon from "@nuxt/ui/components/Icon.vue";
|
|
4
|
+
import { useDisplayIcons } from "../../composables/use-display-icons";
|
|
5
|
+
import { useDisplayLocale } from "../../composables/use-display-locale";
|
|
6
|
+
const emit = defineEmits(["retry"]);
|
|
7
|
+
const { t } = useDisplayLocale();
|
|
8
|
+
const icons = useDisplayIcons();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<div
|
|
13
|
+
class="nut-display-tone-error flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-[var(--nut-tone-ink)]"
|
|
14
|
+
role="alert"
|
|
15
|
+
data-display-error
|
|
16
|
+
>
|
|
17
|
+
<UIcon :name="icons.warning" class="size-4 shrink-0" />
|
|
18
|
+
<span>{{ t("display.loadError") }}</span>
|
|
19
|
+
<UButton
|
|
20
|
+
:label="t('display.retry')"
|
|
21
|
+
color="error"
|
|
22
|
+
variant="link"
|
|
23
|
+
size="sm"
|
|
24
|
+
class="p-0"
|
|
25
|
+
data-display-retry
|
|
26
|
+
@click="emit('retry')"
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
2
|
+
retry: () => any;
|
|
3
|
+
}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
|
|
4
|
+
onRetry?: (() => any) | undefined;
|
|
5
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
count: number;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
reveal: () => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
7
|
+
onReveal?: (() => any) | undefined;
|
|
8
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UButton from "@nuxt/ui/components/Button.vue";
|
|
3
|
+
import { useDisplayIcons } from "../../composables/use-display-icons";
|
|
4
|
+
import { useDisplayLocale } from "../../composables/use-display-locale";
|
|
5
|
+
const { count } = defineProps({
|
|
6
|
+
count: { type: Number, required: true }
|
|
7
|
+
});
|
|
8
|
+
const emit = defineEmits(["reveal"]);
|
|
9
|
+
const { t } = useDisplayLocale();
|
|
10
|
+
const icons = useDisplayIcons();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<UButton
|
|
15
|
+
:label="t('display.showMore', { count })"
|
|
16
|
+
:trailing-icon="icons.chevronDown"
|
|
17
|
+
color="neutral"
|
|
18
|
+
variant="ghost"
|
|
19
|
+
size="sm"
|
|
20
|
+
data-display-more
|
|
21
|
+
@click="emit('reveal')"
|
|
22
|
+
/>
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
count: number;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
reveal: () => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
7
|
+
onReveal?: (() => any) | undefined;
|
|
8
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DisplayRecordItem } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
item: DisplayRecordItem;
|
|
4
|
+
size?: 'sm' | 'md' | 'lg';
|
|
5
|
+
banner?: boolean;
|
|
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,59 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import UAvatar from "@nuxt/ui/components/Avatar.vue";
|
|
3
|
+
import UIcon from "@nuxt/ui/components/Icon.vue";
|
|
4
|
+
import { ref, watch } from "vue";
|
|
5
|
+
import { displayToneClass } from "../../utils/tone";
|
|
6
|
+
const {
|
|
7
|
+
item,
|
|
8
|
+
size = "md",
|
|
9
|
+
banner = false
|
|
10
|
+
} = defineProps({
|
|
11
|
+
item: { type: Object, required: true },
|
|
12
|
+
size: { type: String, required: false },
|
|
13
|
+
banner: { type: Boolean, required: false }
|
|
14
|
+
});
|
|
15
|
+
const BOX = { lg: "size-13", md: "size-10", sm: "size-8" };
|
|
16
|
+
const ICON = { lg: "size-6", md: "size-5", sm: "size-4" };
|
|
17
|
+
const AVATAR = { lg: "xl", md: "lg", sm: "md" };
|
|
18
|
+
const failed = ref(false);
|
|
19
|
+
watch(
|
|
20
|
+
() => item.image?.src,
|
|
21
|
+
() => {
|
|
22
|
+
failed.value = false;
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<img
|
|
29
|
+
v-if="item.image?.src && !failed"
|
|
30
|
+
:src="item.image.src"
|
|
31
|
+
:alt="item.image.alt ?? ''"
|
|
32
|
+
:class="[
|
|
33
|
+
'shrink-0 bg-elevated object-cover',
|
|
34
|
+
banner ? 'h-28 w-full' : `${BOX[size]} rounded-[var(--nut-display-radius)]`
|
|
35
|
+
]"
|
|
36
|
+
loading="lazy"
|
|
37
|
+
@error="failed = true"
|
|
38
|
+
/>
|
|
39
|
+
<UAvatar
|
|
40
|
+
v-else-if="item.avatar && !banner"
|
|
41
|
+
v-bind="item.avatar"
|
|
42
|
+
:size="item.avatar.size ?? AVATAR[size]"
|
|
43
|
+
class="shrink-0"
|
|
44
|
+
/>
|
|
45
|
+
<span
|
|
46
|
+
v-else-if="item.icon || item.image || banner"
|
|
47
|
+
:class="[
|
|
48
|
+
'grid shrink-0 place-items-center bg-[var(--nut-tone-soft)] text-[var(--nut-tone-ink)]',
|
|
49
|
+
displayToneClass(item.tone ?? 'primary'),
|
|
50
|
+
banner ? 'h-28 w-full' : `${BOX[size]} rounded-[var(--nut-display-radius)]`
|
|
51
|
+
]"
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
>
|
|
54
|
+
<UIcon
|
|
55
|
+
:name="item.icon ?? 'i-lucide-image'"
|
|
56
|
+
:class="banner ? 'size-8 opacity-70' : ICON[size]"
|
|
57
|
+
/>
|
|
58
|
+
</span>
|
|
59
|
+
</template>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DisplayRecordItem } from '../../types/index.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
item: DisplayRecordItem;
|
|
4
|
+
size?: 'sm' | 'md' | 'lg';
|
|
5
|
+
banner?: boolean;
|
|
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,10 @@
|
|
|
1
|
+
import type { FunctionalComponent } from 'vue';
|
|
2
|
+
import type { DisplayContent } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Renders text, a lazy translation, a VNode, or a render function. A function runs while this
|
|
5
|
+
* component renders, so its reactive reads belong to this component only.
|
|
6
|
+
*/
|
|
7
|
+
declare const DisplayRender: FunctionalComponent<{
|
|
8
|
+
content?: DisplayContent;
|
|
9
|
+
}>;
|
|
10
|
+
export default DisplayRender;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
layout?: 'lines' | 'rows' | 'tiles' | 'card' | 'media' | 'ring' | 'block';
|
|
3
|
+
count?: number;
|
|
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,67 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
const { layout = "lines", count = 3 } = defineProps({
|
|
3
|
+
layout: { type: String, required: false },
|
|
4
|
+
count: { type: Number, required: false }
|
|
5
|
+
});
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<div class="nut-dash-shimmer" aria-busy="true" data-display-skeleton>
|
|
10
|
+
<div v-if="layout === 'rows'" class="flex flex-col">
|
|
11
|
+
<div
|
|
12
|
+
v-for="index in count"
|
|
13
|
+
:key="index"
|
|
14
|
+
class="flex items-center justify-between gap-6 border-t border-muted py-3 first:border-t-0"
|
|
15
|
+
>
|
|
16
|
+
<span
|
|
17
|
+
class="nut-dash-ghost h-3 rounded"
|
|
18
|
+
:style="{ width: `${28 + index * 13 % 18}%` }"
|
|
19
|
+
/>
|
|
20
|
+
<span
|
|
21
|
+
class="nut-dash-ghost h-3 rounded"
|
|
22
|
+
:style="{ width: `${16 + index * 7 % 12}%` }"
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div
|
|
27
|
+
v-else-if="layout === 'tiles'"
|
|
28
|
+
class="grid grid-cols-[repeat(auto-fill,minmax(8rem,1fr))] gap-2"
|
|
29
|
+
>
|
|
30
|
+
<div
|
|
31
|
+
v-for="index in count"
|
|
32
|
+
:key="index"
|
|
33
|
+
class="nut-dash-ghost h-16 rounded-[var(--nut-display-radius)]"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
<div v-else-if="layout === 'card'" class="flex items-center gap-3">
|
|
37
|
+
<span class="nut-dash-ghost size-12 shrink-0 rounded-[var(--nut-display-radius)]" />
|
|
38
|
+
<div class="flex flex-1 flex-col gap-2">
|
|
39
|
+
<span class="nut-dash-ghost h-3 w-2/5 rounded" />
|
|
40
|
+
<span class="nut-dash-ghost h-3 w-3/5 rounded" />
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
<div
|
|
44
|
+
v-else-if="layout === 'media'"
|
|
45
|
+
class="nut-dash-ghost aspect-video rounded-[var(--nut-display-radius)]"
|
|
46
|
+
/>
|
|
47
|
+
<div v-else-if="layout === 'ring'" class="flex items-center gap-4">
|
|
48
|
+
<span class="nut-dash-ghost size-20 shrink-0 rounded-full" />
|
|
49
|
+
<div class="flex flex-1 flex-col gap-2">
|
|
50
|
+
<span class="nut-dash-ghost h-3 w-3/5 rounded" />
|
|
51
|
+
<span class="nut-dash-ghost h-3 w-2/5 rounded" />
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<div
|
|
55
|
+
v-else-if="layout === 'block'"
|
|
56
|
+
class="nut-dash-ghost h-24 rounded-[var(--nut-display-radius)]"
|
|
57
|
+
/>
|
|
58
|
+
<div v-else class="flex flex-col gap-2">
|
|
59
|
+
<span
|
|
60
|
+
v-for="index in count"
|
|
61
|
+
:key="index"
|
|
62
|
+
class="nut-dash-ghost h-3 rounded"
|
|
63
|
+
:style="{ width: index === count && count > 1 ? '55%' : `${92 - index * 9 % 20}%` }"
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
layout?: 'lines' | 'rows' | 'tiles' | 'card' | 'media' | 'ring' | 'block';
|
|
3
|
+
count?: number;
|
|
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,6 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
import type { DisplayKind, DisplayUiConfig, DisplayUiMap } from '../types/index.js';
|
|
3
|
+
/** `appConfig.nuxtUiTools.display`: presets and slot classes. */
|
|
4
|
+
export declare function useDisplayConfig(): ComputedRef<DisplayUiConfig>;
|
|
5
|
+
/** The app slot classes of one kind. */
|
|
6
|
+
export declare function useDisplayAppUi<TKind extends DisplayKind>(kind: TKind): ComputedRef<DisplayUiMap[TKind] | undefined>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useAppConfig } from "nuxt/app";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { resolveAppDisplayConfig } from "../utils/config.js";
|
|
4
|
+
export function useDisplayConfig() {
|
|
5
|
+
const appConfig = useAppConfig();
|
|
6
|
+
return computed(() => resolveAppDisplayConfig(appConfig));
|
|
7
|
+
}
|
|
8
|
+
export function useDisplayAppUi(kind) {
|
|
9
|
+
const config = useDisplayConfig();
|
|
10
|
+
return computed(() => config.value.ui?.[kind]);
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FilePreviewFile } from '../../file-preview/types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Opens files in the app's file preview when one is provided; returns `false` otherwise so the
|
|
4
|
+
* caller can fall back to a plain link.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useDisplayFilePreview(): {
|
|
7
|
+
available: boolean;
|
|
8
|
+
open: (files: readonly FilePreviewFile[], index?: number) => boolean;
|
|
9
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getCurrentInstance, inject } from "vue";
|
|
2
|
+
import { filePreviewApiKey } from "../../file-preview/composables/use-file-preview-api.js";
|
|
3
|
+
export function useDisplayFilePreview() {
|
|
4
|
+
const api = getCurrentInstance() ? inject(filePreviewApiKey, null) : null;
|
|
5
|
+
function open(files, index = 0) {
|
|
6
|
+
if (!api || !files.length) return false;
|
|
7
|
+
api.open(files, { index });
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return { available: Boolean(api), open };
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DisplayTone } from '../types/index.js';
|
|
2
|
+
declare const ICON_NAMES: readonly ["arrowDown", "arrowRight", "arrowUp", "check", "chevronDown", "chevronRight", "copy", "copyCheck", "empty", "error", "external", "eye", "eyeOff", "file", "info", "minus", "success", "warning"];
|
|
3
|
+
type DisplayIconName = (typeof ICON_NAMES)[number];
|
|
4
|
+
/** Icons of the blocks: `appConfig.ui.icons` when the app sets them, Lucide otherwise. */
|
|
5
|
+
export declare function useDisplayIcons(): import("vue").ComputedRef<Record<"empty" | "error" | "external" | "success" | "warning" | "info" | "check" | "copy" | "file" | "arrowDown" | "arrowRight" | "arrowUp" | "chevronDown" | "chevronRight" | "copyCheck" | "eye" | "eyeOff" | "minus", string>>;
|
|
6
|
+
/** Icon of a tone in alerts and statuses. */
|
|
7
|
+
export declare function toneIcon(icons: Record<DisplayIconName, string>, tone: DisplayTone): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useAppConfig } from "nuxt/app";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { isPlainObject, isString } from "../../shared/utils/predicate.js";
|
|
4
|
+
const ICON_NAMES = [
|
|
5
|
+
"arrowDown",
|
|
6
|
+
"arrowRight",
|
|
7
|
+
"arrowUp",
|
|
8
|
+
"check",
|
|
9
|
+
"chevronDown",
|
|
10
|
+
"chevronRight",
|
|
11
|
+
"copy",
|
|
12
|
+
"copyCheck",
|
|
13
|
+
"empty",
|
|
14
|
+
"error",
|
|
15
|
+
"external",
|
|
16
|
+
"eye",
|
|
17
|
+
"eyeOff",
|
|
18
|
+
"file",
|
|
19
|
+
"info",
|
|
20
|
+
"minus",
|
|
21
|
+
"success",
|
|
22
|
+
"warning"
|
|
23
|
+
];
|
|
24
|
+
const DEFAULT_ICONS = {
|
|
25
|
+
arrowDown: "i-lucide-arrow-down",
|
|
26
|
+
arrowRight: "i-lucide-arrow-right",
|
|
27
|
+
arrowUp: "i-lucide-arrow-up",
|
|
28
|
+
check: "i-lucide-check",
|
|
29
|
+
chevronDown: "i-lucide-chevron-down",
|
|
30
|
+
chevronRight: "i-lucide-chevron-right",
|
|
31
|
+
copy: "i-lucide-copy",
|
|
32
|
+
copyCheck: "i-lucide-copy-check",
|
|
33
|
+
empty: "i-lucide-inbox",
|
|
34
|
+
error: "i-lucide-circle-x",
|
|
35
|
+
external: "i-lucide-arrow-up-right",
|
|
36
|
+
eye: "i-lucide-eye",
|
|
37
|
+
eyeOff: "i-lucide-eye-off",
|
|
38
|
+
file: "i-lucide-file",
|
|
39
|
+
info: "i-lucide-info",
|
|
40
|
+
minus: "i-lucide-minus",
|
|
41
|
+
success: "i-lucide-circle-check",
|
|
42
|
+
warning: "i-lucide-triangle-alert"
|
|
43
|
+
};
|
|
44
|
+
export function useDisplayIcons() {
|
|
45
|
+
const appConfig = useAppConfig();
|
|
46
|
+
return computed(() => {
|
|
47
|
+
const ui = Object.getOwnPropertyDescriptor(appConfig, "ui")?.value;
|
|
48
|
+
const icons = isPlainObject(ui) && isPlainObject(ui.icons) ? ui.icons : void 0;
|
|
49
|
+
const resolved = { ...DEFAULT_ICONS };
|
|
50
|
+
for (const key of ICON_NAMES) {
|
|
51
|
+
const icon = icons?.[key];
|
|
52
|
+
if (isString(icon)) resolved[key] = icon;
|
|
53
|
+
}
|
|
54
|
+
return resolved;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export function toneIcon(icons, tone) {
|
|
58
|
+
if (tone === "success") return icons.success;
|
|
59
|
+
if (tone === "warning") return icons.warning;
|
|
60
|
+
if (tone === "error") return icons.error;
|
|
61
|
+
return icons.info;
|
|
62
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useDisplayLocale } from "./use-display-locale.js";
|
|
3
|
+
export function useDisplayNumber() {
|
|
4
|
+
const { code } = useDisplayLocale();
|
|
5
|
+
const formatter = computed(() => new Intl.NumberFormat(code.value, { maximumFractionDigits: 2 }));
|
|
6
|
+
return (value) => formatter.value.format(value);
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Folds a list after `max` items. Each `reveal()` shows `step` more, or everything left when
|
|
3
|
+
* there is no step.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useDisplayReveal<TItem>(params: {
|
|
6
|
+
items: () => readonly TItem[];
|
|
7
|
+
max: () => number | undefined;
|
|
8
|
+
step: () => number | undefined;
|
|
9
|
+
}): {
|
|
10
|
+
hidden: import("vue").ComputedRef<number>;
|
|
11
|
+
next: import("vue").ComputedRef<number>;
|
|
12
|
+
reveal: () => void;
|
|
13
|
+
visible: import("vue").ComputedRef<TItem[]>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
export function useDisplayReveal(params) {
|
|
3
|
+
const extra = ref(0);
|
|
4
|
+
const limit = computed(() => {
|
|
5
|
+
const max = params.max();
|
|
6
|
+
return max === void 0 ? Number.POSITIVE_INFINITY : max + extra.value;
|
|
7
|
+
});
|
|
8
|
+
const visible = computed(() => params.items().slice(0, limit.value));
|
|
9
|
+
const hidden = computed(() => Math.max(0, params.items().length - visible.value.length));
|
|
10
|
+
const next = computed(() => Math.min(hidden.value, params.step() ?? hidden.value));
|
|
11
|
+
function reveal() {
|
|
12
|
+
extra.value += next.value;
|
|
13
|
+
}
|
|
14
|
+
return { hidden, next, reveal, visible };
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DisplayUrl } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Runs link actions (open, download) one at a time per key: `pending` names the running one for
|
|
4
|
+
* its button's loading state, and `failed` keeps the last failure with a way to try it again.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useDisplayUrlActions(): {
|
|
7
|
+
failed: import("vue").ShallowRef<{
|
|
8
|
+
key: string;
|
|
9
|
+
retry: () => void;
|
|
10
|
+
} | null, {
|
|
11
|
+
key: string;
|
|
12
|
+
retry: () => void;
|
|
13
|
+
} | null>;
|
|
14
|
+
pending: import("vue").Ref<string | null, string | null>;
|
|
15
|
+
run: (key: string, action: () => Promise<void>) => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The address of a media file to show right away: a string as is, a function resolved when the
|
|
19
|
+
* block mounts and again when it changes. An older call never overwrites a newer one.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useResolvedDisplayUrl(source: () => DisplayUrl | undefined): {
|
|
22
|
+
failed: import("vue").Ref<boolean, boolean>;
|
|
23
|
+
pending: import("vue").Ref<boolean, boolean>;
|
|
24
|
+
retry: () => undefined;
|
|
25
|
+
url: import("vue").Ref<string | undefined, string | undefined>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ref, shallowRef, watch } from "vue";
|
|
2
|
+
import { isString } from "../../shared/utils/predicate.js";
|
|
3
|
+
export function useDisplayUrlActions() {
|
|
4
|
+
const pending = ref(null);
|
|
5
|
+
const failed = shallowRef(null);
|
|
6
|
+
async function run(key, action) {
|
|
7
|
+
if (pending.value === key) return;
|
|
8
|
+
pending.value = key;
|
|
9
|
+
failed.value = null;
|
|
10
|
+
try {
|
|
11
|
+
await action();
|
|
12
|
+
} catch {
|
|
13
|
+
failed.value = { key, retry: () => void run(key, action) };
|
|
14
|
+
} finally {
|
|
15
|
+
if (pending.value === key) pending.value = null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return { failed, pending, run };
|
|
19
|
+
}
|
|
20
|
+
export function useResolvedDisplayUrl(source) {
|
|
21
|
+
const url = ref(void 0);
|
|
22
|
+
const pending = ref(false);
|
|
23
|
+
const failed = ref(false);
|
|
24
|
+
let run = 0;
|
|
25
|
+
async function resolve(current) {
|
|
26
|
+
run += 1;
|
|
27
|
+
const own = run;
|
|
28
|
+
failed.value = false;
|
|
29
|
+
if (current === void 0 || isString(current)) {
|
|
30
|
+
url.value = current;
|
|
31
|
+
pending.value = false;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
pending.value = true;
|
|
35
|
+
try {
|
|
36
|
+
const resolved = await current();
|
|
37
|
+
if (own === run) url.value = resolved;
|
|
38
|
+
} catch {
|
|
39
|
+
if (own === run) failed.value = true;
|
|
40
|
+
} finally {
|
|
41
|
+
if (own === run) pending.value = false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
watch(source, (current) => void resolve(current), { immediate: true });
|
|
45
|
+
return { failed, pending, retry: () => void resolve(source()), url };
|
|
46
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useAppConfig, useHead } from "#app";
|
|
2
|
+
import { resolveAppDisplayConfig } from "../utils/config.js";
|
|
3
|
+
import { buildDisplayToneCss } from "../utils/tone-css.js";
|
|
4
|
+
export default defineNuxtPlugin({
|
|
5
|
+
name: "nuxt-ui-tools:display-tones",
|
|
6
|
+
setup() {
|
|
7
|
+
const appConfig = useAppConfig();
|
|
8
|
+
useHead({
|
|
9
|
+
style: [
|
|
10
|
+
{
|
|
11
|
+
key: "nut-display-tones",
|
|
12
|
+
textContent: () => buildDisplayToneCss(resolveAppDisplayConfig(appConfig).tones)
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|