nuxt-ui-tools 1.24.0 → 1.25.1
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 +96 -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 +136 -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 +184 -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 +241 -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 +144 -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 +179 -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 +154 -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 +75 -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 +195 -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 +103 -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 +301 -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 +336 -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 +302 -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 +153 -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 +268 -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 +189 -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 +136 -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 +141 -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 +238 -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 +27 -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 +71 -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 +36 -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 +11 -0
- package/dist/runtime/display/components/parts/display-record-media.vue +61 -0
- package/dist/runtime/display/components/parts/display-record-media.vue.d.ts +11 -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/directives/reveal-truncated.d.ts +10 -0
- package/dist/runtime/display/directives/reveal-truncated.js +31 -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 +52 -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 +34 -0
- package/dist/runtime/display/types/blocks/person.js +0 -0
- package/dist/runtime/display/types/blocks/record.d.ts +44 -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 +60 -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 +80 -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 +11 -0
- package/dist/runtime/display/utils/config.js +17 -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/links.d.ts +12 -0
- package/dist/runtime/display/utils/links.js +9 -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 +17 -4
- 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,28 @@
|
|
|
1
|
+
import type { DisplayBlockBase, DisplayContent, DisplayRevealable, DisplaySurface } from '../shared.js';
|
|
2
|
+
export type DisplayTableSlot = 'root' | 'scroller' | 'table' | 'head' | 'headCell' | 'row' | 'cell' | 'foot' | 'footCell' | 'meta' | 'empty' | 'more';
|
|
3
|
+
export interface DisplayTableColumn {
|
|
4
|
+
key: string;
|
|
5
|
+
label: DisplayContent;
|
|
6
|
+
/** Tabular figures aligned to the end. */
|
|
7
|
+
numeric?: boolean;
|
|
8
|
+
/** Defaults to `end` for numeric columns, `start` otherwise. */
|
|
9
|
+
align?: 'start' | 'center' | 'end';
|
|
10
|
+
/** CSS width, such as `8rem` or `30%`. */
|
|
11
|
+
width?: string;
|
|
12
|
+
mono?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type DisplayTableRow = Readonly<Record<string, DisplayContent>>;
|
|
15
|
+
export interface DisplayTableProps extends DisplayBlockBase<DisplayTableSlot>, DisplayRevealable {
|
|
16
|
+
columns: readonly DisplayTableColumn[];
|
|
17
|
+
rows: readonly DisplayTableRow[];
|
|
18
|
+
/** Totals or averages pinned under the rows. */
|
|
19
|
+
footer?: DisplayTableRow;
|
|
20
|
+
/** Line under the table, at the start. */
|
|
21
|
+
caption?: DisplayContent;
|
|
22
|
+
/** Line under the table, at the end. */
|
|
23
|
+
note?: DisplayContent;
|
|
24
|
+
/** Scrolls the rows past this height, with the header and footer pinned (px or CSS length). */
|
|
25
|
+
maxHeight?: number | string;
|
|
26
|
+
/** Defaults to `bordered`. */
|
|
27
|
+
surface?: DisplaySurface;
|
|
28
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DisplayBlockBase, DisplayContent, DisplayTone } from '../shared.js';
|
|
2
|
+
export type DisplayTextAppearance = 'body' | 'lead' | 'muted' | 'caption' | 'quote' | 'legal' | 'prose';
|
|
3
|
+
export type DisplayTextSlot = 'root' | 'header' | 'icon' | 'title' | 'paragraph' | 'footer' | 'toggle';
|
|
4
|
+
export interface DisplayTextProps extends DisplayBlockBase<DisplayTextSlot> {
|
|
5
|
+
/** Defaults to `body`. `prose` styles rich content: links, lists, bold, inline code. */
|
|
6
|
+
appearance?: DisplayTextAppearance;
|
|
7
|
+
text?: DisplayContent;
|
|
8
|
+
/** Several paragraphs, drawn after `text`. */
|
|
9
|
+
paragraphs?: readonly DisplayContent[];
|
|
10
|
+
/** Heading of a `legal` block. */
|
|
11
|
+
title?: DisplayContent;
|
|
12
|
+
/** Icon before the `legal` title or the `caption` text. */
|
|
13
|
+
icon?: string;
|
|
14
|
+
/** `quote` attribution, such as the author's name. */
|
|
15
|
+
author?: DisplayContent;
|
|
16
|
+
/** Second part of the attribution line, such as a date. */
|
|
17
|
+
meta?: DisplayContent;
|
|
18
|
+
/** Accent of the `quote` bar and the `legal` rule. Defaults to `primary` and `neutral`. */
|
|
19
|
+
tone?: DisplayTone;
|
|
20
|
+
/** Clamps the text to this many lines with a "Read more" toggle when it overflows. */
|
|
21
|
+
maxLines?: number;
|
|
22
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DisplayAvatar, DisplayBlockBase, DisplayContent, DisplayDate, DisplayRevealable, DisplayText, DisplayTone } from '../shared.js';
|
|
2
|
+
export type DisplayTimelineState = 'done' | 'current' | 'upcoming';
|
|
3
|
+
export type DisplayTimelineSlot = 'root' | 'item' | 'marker' | 'connector' | 'body' | 'title' | 'time' | 'description' | 'actor' | 'now' | 'more' | 'empty';
|
|
4
|
+
export interface DisplayTimelineItem {
|
|
5
|
+
title: DisplayContent;
|
|
6
|
+
description?: DisplayContent;
|
|
7
|
+
/** Orders `schedule` items against `now` and fills `time` when it is not set. */
|
|
8
|
+
date?: DisplayDate;
|
|
9
|
+
/** Text of the time, such as `12 oct.`. Defaults to the formatted `date`. */
|
|
10
|
+
time?: DisplayText;
|
|
11
|
+
icon?: string;
|
|
12
|
+
/** Defaults to `neutral`. */
|
|
13
|
+
tone?: DisplayTone;
|
|
14
|
+
actor?: {
|
|
15
|
+
name: DisplayText;
|
|
16
|
+
avatar?: DisplayAvatar;
|
|
17
|
+
};
|
|
18
|
+
/** Defaults from `date` against `now` when there is a date, `done` otherwise. */
|
|
19
|
+
state?: DisplayTimelineState;
|
|
20
|
+
}
|
|
21
|
+
export interface DisplayTimelineProps extends DisplayBlockBase<DisplayTimelineSlot>, DisplayRevealable {
|
|
22
|
+
/**
|
|
23
|
+
* `vertical` lists events with dots, `log` is a dense list with times and actors, `pipeline`
|
|
24
|
+
* draws stages in a row, and `schedule` lists planned events with a "today" marker.
|
|
25
|
+
* Defaults to `vertical`.
|
|
26
|
+
*/
|
|
27
|
+
variant?: 'vertical' | 'log' | 'pipeline' | 'schedule';
|
|
28
|
+
items: readonly DisplayTimelineItem[];
|
|
29
|
+
/** `pipeline`: index of the current stage, for items without a `state`. */
|
|
30
|
+
current?: number;
|
|
31
|
+
/** Defaults to the current time. */
|
|
32
|
+
now?: DisplayDate;
|
|
33
|
+
/** `schedule` marker text. Defaults to "Today" and the date. */
|
|
34
|
+
nowLabel?: DisplayText;
|
|
35
|
+
/** Format of the times built from dates. Defaults to day and short month, plus the time in `log`. */
|
|
36
|
+
dateFormat?: Intl.DateTimeFormatOptions;
|
|
37
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { DisplayKind, DisplayPropsMap, DisplayUiMap } from './registry.js';
|
|
2
|
+
import type { DisplayBuiltinTone, DisplayChipUi, DisplayToneRegistry } from './shared.js';
|
|
3
|
+
/**
|
|
4
|
+
* Colors of a tone, as CSS colors. Only `color` is needed for a new tone: the ink defaults to it,
|
|
5
|
+
* the soft background and the line mix it into the page background.
|
|
6
|
+
*/
|
|
7
|
+
export interface DisplayToneColors {
|
|
8
|
+
/** Solid fill: bars, dots, current steps. */
|
|
9
|
+
color?: string;
|
|
10
|
+
/** Text and icons drawn on the page. */
|
|
11
|
+
ink?: string;
|
|
12
|
+
/** Tinted background. */
|
|
13
|
+
soft?: string;
|
|
14
|
+
/** Border. */
|
|
15
|
+
line?: string;
|
|
16
|
+
/** Text on the solid fill. */
|
|
17
|
+
contrast?: string;
|
|
18
|
+
}
|
|
19
|
+
/** A tone registered or restyled in `appConfig.nuxtUiTools.display.tones`. */
|
|
20
|
+
export interface DisplayToneDefinition extends DisplayToneColors {
|
|
21
|
+
/** Colors used in dark mode, over the light ones. */
|
|
22
|
+
dark?: DisplayToneColors;
|
|
23
|
+
}
|
|
24
|
+
/** Tones by name: new ones need `color`; a built-in tone takes only the colors it changes. */
|
|
25
|
+
export type DisplayToneDefinitions = Record<Extract<keyof DisplayToneRegistry, string>, DisplayToneDefinition & {
|
|
26
|
+
color: string;
|
|
27
|
+
}> & Partial<Record<DisplayBuiltinTone, DisplayToneDefinition>>;
|
|
28
|
+
/** Named default props per kind, picked with `preset`. */
|
|
29
|
+
export type DisplayPresets = {
|
|
30
|
+
[K in DisplayKind]?: Readonly<Record<string, Partial<DisplayPropsMap[K]>>>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* App-wide display defaults, from `appConfig.nuxtUiTools.display`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* export default defineAppConfig({
|
|
38
|
+
* nuxtUiTools: {
|
|
39
|
+
* display: {
|
|
40
|
+
* presets: { text: { legal: { appearance: 'legal', icon: 'i-lucide-shield' } } },
|
|
41
|
+
* tones: { violet: { color: 'var(--color-violet-500)' }, primary: { ink: '#b85e00' } },
|
|
42
|
+
* ui: { facts: { label: 'text-muted', value: 'font-semibold' } },
|
|
43
|
+
* },
|
|
44
|
+
* },
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export interface DisplayUiConfig {
|
|
49
|
+
presets?: DisplayPresets;
|
|
50
|
+
/** Extra tones, and color changes to the built-in ones. Register new names in `DisplayToneRegistry`. */
|
|
51
|
+
tones?: Partial<DisplayToneDefinitions>;
|
|
52
|
+
/**
|
|
53
|
+
* Slot classes per kind, plus `chip`: the `UBadge` slots of every chip the blocks draw (facts
|
|
54
|
+
* chips, record badges, list chips…), so chips match the app's badge style. Tones still color
|
|
55
|
+
* them: leave colors out of these classes.
|
|
56
|
+
*/
|
|
57
|
+
ui?: Partial<DisplayUiMap> & {
|
|
58
|
+
chip?: DisplayChipUi;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type * from './blocks/accordion';
|
|
2
|
+
export type * from './blocks/alert';
|
|
3
|
+
export type * from './blocks/breakdown';
|
|
4
|
+
export type * from './blocks/chart';
|
|
5
|
+
export type * from './blocks/code';
|
|
6
|
+
export type * from './blocks/date';
|
|
7
|
+
export type * from './blocks/diff';
|
|
8
|
+
export type * from './blocks/empty';
|
|
9
|
+
export type * from './blocks/facts';
|
|
10
|
+
export type * from './blocks/heading';
|
|
11
|
+
export type * from './blocks/list';
|
|
12
|
+
export type * from './blocks/media';
|
|
13
|
+
export type * from './blocks/meter';
|
|
14
|
+
export type * from './blocks/person';
|
|
15
|
+
export type * from './blocks/record';
|
|
16
|
+
export type * from './blocks/stat';
|
|
17
|
+
export type * from './blocks/table';
|
|
18
|
+
export type * from './blocks/text';
|
|
19
|
+
export type * from './blocks/timeline';
|
|
20
|
+
export type * from './config';
|
|
21
|
+
export type * from './registry';
|
|
22
|
+
export type * from './shared';
|
|
File without changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { DisplayAccordionProps } from './blocks/accordion.js';
|
|
2
|
+
import type { DisplayAlertProps } from './blocks/alert.js';
|
|
3
|
+
import type { DisplayBreakdownProps } from './blocks/breakdown.js';
|
|
4
|
+
import type { DisplayChartProps } from './blocks/chart.js';
|
|
5
|
+
import type { DisplayCodeProps } from './blocks/code.js';
|
|
6
|
+
import type { DisplayDateProps } from './blocks/date.js';
|
|
7
|
+
import type { DisplayDiffProps } from './blocks/diff.js';
|
|
8
|
+
import type { DisplayEmptyProps } from './blocks/empty.js';
|
|
9
|
+
import type { DisplayFactsProps } from './blocks/facts.js';
|
|
10
|
+
import type { DisplayHeadingProps } from './blocks/heading.js';
|
|
11
|
+
import type { DisplayListProps } from './blocks/list.js';
|
|
12
|
+
import type { DisplayMediaProps } from './blocks/media.js';
|
|
13
|
+
import type { DisplayMeterProps } from './blocks/meter.js';
|
|
14
|
+
import type { DisplayPersonProps } from './blocks/person.js';
|
|
15
|
+
import type { DisplayRecordProps } from './blocks/record.js';
|
|
16
|
+
import type { DisplayStatProps } from './blocks/stat.js';
|
|
17
|
+
import type { DisplayTableProps } from './blocks/table.js';
|
|
18
|
+
import type { DisplayTextProps } from './blocks/text.js';
|
|
19
|
+
import type { DisplayTimelineProps } from './blocks/timeline.js';
|
|
20
|
+
/** Props of every display block, by kind. */
|
|
21
|
+
export interface DisplayPropsMap {
|
|
22
|
+
heading: DisplayHeadingProps;
|
|
23
|
+
text: DisplayTextProps;
|
|
24
|
+
alert: DisplayAlertProps;
|
|
25
|
+
facts: DisplayFactsProps;
|
|
26
|
+
stat: DisplayStatProps;
|
|
27
|
+
breakdown: DisplayBreakdownProps;
|
|
28
|
+
meter: DisplayMeterProps;
|
|
29
|
+
chart: DisplayChartProps;
|
|
30
|
+
table: DisplayTableProps;
|
|
31
|
+
diff: DisplayDiffProps;
|
|
32
|
+
record: DisplayRecordProps;
|
|
33
|
+
person: DisplayPersonProps;
|
|
34
|
+
list: DisplayListProps;
|
|
35
|
+
timeline: DisplayTimelineProps;
|
|
36
|
+
date: DisplayDateProps;
|
|
37
|
+
media: DisplayMediaProps;
|
|
38
|
+
code: DisplayCodeProps;
|
|
39
|
+
empty: DisplayEmptyProps;
|
|
40
|
+
accordion: DisplayAccordionProps;
|
|
41
|
+
}
|
|
42
|
+
export type DisplayKind = keyof DisplayPropsMap;
|
|
43
|
+
/** Slot classes of every display block, by kind. */
|
|
44
|
+
export type DisplayUiMap = {
|
|
45
|
+
[K in DisplayKind]: NonNullable<DisplayPropsMap[K]['ui']>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* One display block: its kind, its props, and optionally a preset from
|
|
49
|
+
* `appConfig.nuxtUiTools.display.presets` whose props the given ones override.
|
|
50
|
+
*/
|
|
51
|
+
export type DisplaySpec = {
|
|
52
|
+
[K in DisplayKind]: {
|
|
53
|
+
display: K;
|
|
54
|
+
props: DisplayPropsMap[K];
|
|
55
|
+
preset?: string;
|
|
56
|
+
};
|
|
57
|
+
}[DisplayKind];
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { AvatarProps } from '@nuxt/ui/components/Avatar.vue';
|
|
2
|
+
import type { BadgeProps } from '@nuxt/ui/components/Badge.vue';
|
|
3
|
+
import type { ButtonProps } from '@nuxt/ui/components/Button.vue';
|
|
4
|
+
import type { LazyRenderableValue, LazyTextValue, MaybePromise } from '../../shared/types/utils.js';
|
|
5
|
+
/** Tones every app has: the Nuxt UI colors. */
|
|
6
|
+
export type DisplayBuiltinTone = 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error' | 'neutral';
|
|
7
|
+
/**
|
|
8
|
+
* Extra tones an app registers in `appConfig.nuxtUiTools.display.tones`. Augment it so those
|
|
9
|
+
* names type-check wherever a tone is accepted:
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* declare module '#ui-tools/display' {
|
|
14
|
+
* interface DisplayToneRegistry {
|
|
15
|
+
* violet: true
|
|
16
|
+
* teal: true
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export interface DisplayToneRegistry {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Color role of a block or one of its parts: a built-in tone or a registered one. Each tone reads
|
|
25
|
+
* the `--nut-display-<tone>`, `-ink`, `-soft`, `-line` and `-contrast` variables, so an app
|
|
26
|
+
* restyles a tone in CSS.
|
|
27
|
+
*/
|
|
28
|
+
export type DisplayTone = DisplayBuiltinTone | Extract<keyof DisplayToneRegistry, string>;
|
|
29
|
+
/** Box drawn around a block: none, a tinted background, a border, or a raised card. */
|
|
30
|
+
export type DisplaySurface = 'plain' | 'muted' | 'bordered' | 'elevated';
|
|
31
|
+
export type DisplaySize = 'sm' | 'md' | 'lg';
|
|
32
|
+
/** Text, or a lazy translation such as `() => t('key')`. */
|
|
33
|
+
export type DisplayText = LazyTextValue;
|
|
34
|
+
/** Text, a lazy translation, a VNode, or a render function. */
|
|
35
|
+
export type DisplayContent = LazyRenderableValue;
|
|
36
|
+
/**
|
|
37
|
+
* A link, or a function returning it, such as a signed URL fetched on demand. A function runs only
|
|
38
|
+
* when the link is used (opened, previewed or downloaded), with the button showing its progress.
|
|
39
|
+
*/
|
|
40
|
+
export type DisplayUrl = string | (() => MaybePromise<string>);
|
|
41
|
+
/**
|
|
42
|
+
* Where a block link opens. Absolute http(s) links default to `_blank`, others to the same tab;
|
|
43
|
+
* `null` keeps an absolute link in the same tab.
|
|
44
|
+
*/
|
|
45
|
+
export type DisplayLinkTarget = '_blank' | '_self' | '_parent' | '_top' | (string & {});
|
|
46
|
+
/** Date accepted by date-aware blocks: a `Date`, an ISO string, or epoch milliseconds. */
|
|
47
|
+
export type DisplayDate = Date | string | number;
|
|
48
|
+
/** Button rendered by a block, with every `UButton` prop. */
|
|
49
|
+
export interface DisplayAction extends Omit<ButtonProps, 'label'> {
|
|
50
|
+
label?: DisplayText;
|
|
51
|
+
}
|
|
52
|
+
/** Badge rendered by a block, with every `UBadge` prop. `tone` is a shorthand for `color`. */
|
|
53
|
+
export interface DisplayChip extends Omit<BadgeProps, 'label'> {
|
|
54
|
+
label: DisplayText;
|
|
55
|
+
tone?: DisplayTone;
|
|
56
|
+
}
|
|
57
|
+
/** The `UBadge` slots of a chip. */
|
|
58
|
+
export type DisplayChipSlot = 'base' | 'label' | 'leadingIcon' | 'leadingAvatar' | 'leadingAvatarSize' | 'trailingIcon';
|
|
59
|
+
/** Classes per `UBadge` slot of every chip, from `appConfig.nuxtUiTools.display.ui.chip`. */
|
|
60
|
+
export type DisplayChipUi = DisplayUiSlots<DisplayChipSlot>;
|
|
61
|
+
/** Avatar with every `UAvatar` prop. Without `src`, the initials of `alt` show. */
|
|
62
|
+
export type DisplayAvatar = AvatarProps;
|
|
63
|
+
/** Slot classes of a block: every key is optional and merged over the defaults. */
|
|
64
|
+
export type DisplayUiSlots<TSlot extends string> = Partial<Record<TSlot, string>>;
|
|
65
|
+
/** Props every block accepts. */
|
|
66
|
+
export interface DisplayBlockBase<TSlot extends string> {
|
|
67
|
+
/** Draws the block's skeleton instead of its content. */
|
|
68
|
+
loading?: boolean;
|
|
69
|
+
/** Class overrides per slot, merged over `appConfig.nuxtUiTools.display.ui.<kind>`. */
|
|
70
|
+
ui?: DisplayUiSlots<TSlot>;
|
|
71
|
+
}
|
|
72
|
+
/** Props of blocks listing items, which fold after `max` and reveal `step` more at a time. */
|
|
73
|
+
export interface DisplayRevealable {
|
|
74
|
+
/** Items shown before the "show more" button. */
|
|
75
|
+
max?: number;
|
|
76
|
+
/** Items each "show more" reveals. Defaults to everything left. */
|
|
77
|
+
step?: number;
|
|
78
|
+
/** Shown when there is nothing to list. Defaults to a localized "Nothing to show". */
|
|
79
|
+
empty?: DisplayContent;
|
|
80
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DisplayUiSlots } from '../types/index.js';
|
|
2
|
+
/** Merges each slot's defaults with the app config and the block `ui`, later layers winning. */
|
|
3
|
+
export declare function resolveDisplayClasses<TSlot extends string>(defaults: Record<TSlot, string>, ...layers: (DisplayUiSlots<TSlot> | undefined)[]): Record<TSlot, string>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { twMerge } from "tailwind-merge";
|
|
2
|
+
export function resolveDisplayClasses(defaults, ...layers) {
|
|
3
|
+
const resolved = { ...defaults };
|
|
4
|
+
for (const key in defaults)
|
|
5
|
+
resolved[key] = twMerge(defaults[key], ...layers.map((layer) => layer?.[key]));
|
|
6
|
+
return resolved;
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AppConfig } from 'nuxt/schema';
|
|
2
|
+
import type { DisplayKind, DisplayPropsMap, DisplayUiConfig, DisplayUiSlots } from '../types/index.js';
|
|
3
|
+
/** `appConfig.nuxtUiTools.display`, or an empty config. */
|
|
4
|
+
export declare function resolveAppDisplayConfig(config: Pick<AppConfig, 'nuxtUiTools'>): DisplayUiConfig;
|
|
5
|
+
/**
|
|
6
|
+
* The props of a block over the defaults of its preset; an unknown preset changes nothing. Slot
|
|
7
|
+
* classes merge per slot, the block's over the preset's, like the other props.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyDisplayPreset<TKind extends DisplayKind>(kind: TKind, props: DisplayPropsMap[TKind], preset: string | undefined, config: DisplayUiConfig): DisplayPropsMap[TKind];
|
|
10
|
+
/** Two slot class maps merged per slot with tailwind-merge, `over` winning conflicts. */
|
|
11
|
+
export declare function mergeDisplaySlots(base: DisplayUiSlots<string> | undefined, over: DisplayUiSlots<string> | undefined): DisplayUiSlots<string> | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { twMerge } from "tailwind-merge";
|
|
2
|
+
export function resolveAppDisplayConfig(config) {
|
|
3
|
+
return config.nuxtUiTools?.display ?? {};
|
|
4
|
+
}
|
|
5
|
+
export function applyDisplayPreset(kind, props, preset, config) {
|
|
6
|
+
const defaults = preset === void 0 ? void 0 : config.presets?.[kind]?.[preset];
|
|
7
|
+
if (!defaults) return props;
|
|
8
|
+
const merged = { ...defaults, ...props };
|
|
9
|
+
const ui = mergeDisplaySlots(defaults.ui, props.ui);
|
|
10
|
+
return ui ? { ...merged, ui } : merged;
|
|
11
|
+
}
|
|
12
|
+
export function mergeDisplaySlots(base, over) {
|
|
13
|
+
if (!base || !over) return base ?? over;
|
|
14
|
+
const merged = { ...base };
|
|
15
|
+
for (const [slot, classes] of Object.entries(over)) merged[slot] = twMerge(base[slot], classes);
|
|
16
|
+
return merged;
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DisplayContent, DisplayText } from '../types/index.js';
|
|
2
|
+
/** `undefined`, `null`, `false` and `''` count as empty; a render function never does. */
|
|
3
|
+
export declare function isDisplayContentEmpty(content: DisplayContent | undefined): content is false | void | "" | null | undefined;
|
|
4
|
+
/** The string of a text or lazy text, or `undefined`. */
|
|
5
|
+
export declare function resolveDisplayText(value: DisplayText | undefined): string | undefined;
|
|
6
|
+
/** The string of content that is plain text, such as a `value` a copy button can copy. */
|
|
7
|
+
export declare function displayContentText(content: DisplayContent | undefined): string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isFunction, isNumber, isString } from "../../shared/utils/predicate.js";
|
|
2
|
+
export function isDisplayContentEmpty(content) {
|
|
3
|
+
return content === void 0 || content === null || content === "" || content === false;
|
|
4
|
+
}
|
|
5
|
+
export function resolveDisplayText(value) {
|
|
6
|
+
if (isFunction(value)) return String(value());
|
|
7
|
+
if (isString(value) || isNumber(value)) return String(value);
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
export function displayContentText(content) {
|
|
11
|
+
if (isString(content) || isNumber(content)) return String(content);
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DisplayDate } from '../types/index.js';
|
|
2
|
+
/** A valid `Date`, or `null` for missing and unparsable input. */
|
|
3
|
+
export declare function toDisplayDate(value: DisplayDate | undefined | null): Date | null;
|
|
4
|
+
/** Calendar days from `from` to `to`, ignoring the time of day. */
|
|
5
|
+
export declare function calendarDaysBetween(from: Date, to: Date): number;
|
|
6
|
+
export declare function formatDisplayDate(date: Date, locale: string, options: Intl.DateTimeFormatOptions): string;
|
|
7
|
+
/** "Tomorrow", "In 3 days", "2 days ago", capitalized like a sentence. */
|
|
8
|
+
export declare function formatRelativeDays(days: number, locale: string): string;
|
|
9
|
+
/** "3 days", "1 day". */
|
|
10
|
+
export declare function formatDayCount(days: number, locale: string): string;
|
|
11
|
+
/** Parts of a calendar leaf: "OCT.", "24", "thu.". */
|
|
12
|
+
export declare function calendarLeaf(date: Date, locale: string): {
|
|
13
|
+
day: string;
|
|
14
|
+
month: string;
|
|
15
|
+
weekday: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isDate, isNumber, isString } from "../../shared/utils/predicate.js";
|
|
2
|
+
const DAY = 864e5;
|
|
3
|
+
export function toDisplayDate(value) {
|
|
4
|
+
if (isDate(value)) return Number.isNaN(value.getTime()) ? null : value;
|
|
5
|
+
if (isString(value) || isNumber(value)) {
|
|
6
|
+
const date = new Date(value);
|
|
7
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
export function calendarDaysBetween(from, to) {
|
|
12
|
+
const start = Date.UTC(from.getFullYear(), from.getMonth(), from.getDate());
|
|
13
|
+
const end = Date.UTC(to.getFullYear(), to.getMonth(), to.getDate());
|
|
14
|
+
return Math.round((end - start) / DAY);
|
|
15
|
+
}
|
|
16
|
+
export function formatDisplayDate(date, locale, options) {
|
|
17
|
+
return new Intl.DateTimeFormat(locale, options).format(date);
|
|
18
|
+
}
|
|
19
|
+
export function formatRelativeDays(days, locale) {
|
|
20
|
+
const text = new Intl.RelativeTimeFormat(locale, { numeric: "auto" }).format(days, "day");
|
|
21
|
+
return text.charAt(0).toLocaleUpperCase(locale) + text.slice(1);
|
|
22
|
+
}
|
|
23
|
+
export function formatDayCount(days, locale) {
|
|
24
|
+
return new Intl.NumberFormat(locale, { style: "unit", unit: "day", unitDisplay: "long" }).format(
|
|
25
|
+
days
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
export function calendarLeaf(date, locale) {
|
|
29
|
+
return {
|
|
30
|
+
day: formatDisplayDate(date, locale, { day: "numeric" }),
|
|
31
|
+
month: formatDisplayDate(date, locale, { month: "short" }).toLocaleUpperCase(locale),
|
|
32
|
+
weekday: formatDisplayDate(date, locale, { weekday: "short" })
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type JsonTokenKind = 'key' | 'string' | 'number' | 'literal' | 'punctuation' | 'space';
|
|
2
|
+
export interface JsonToken {
|
|
3
|
+
kind: JsonTokenKind;
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
/** Splits JSON text into tokens for highlighting; unknown characters pass through as punctuation. */
|
|
7
|
+
export declare function tokenizeJson(source: string): JsonToken[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const TOKEN = /("(?:\\.|[^"\\])*")(\s*:)?|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|\b(true|false|null)\b|([{}[\],:])|(\s+)|(.)/gu;
|
|
2
|
+
export function tokenizeJson(source) {
|
|
3
|
+
const tokens = [];
|
|
4
|
+
for (const match of source.matchAll(TOKEN)) {
|
|
5
|
+
const [, text, colon, number, literal, punctuation, space, other] = match;
|
|
6
|
+
if (text !== void 0) {
|
|
7
|
+
tokens.push({ kind: colon ? "key" : "string", text });
|
|
8
|
+
if (colon) tokens.push({ kind: "punctuation", text: colon });
|
|
9
|
+
} else if (number !== void 0) tokens.push({ kind: "number", text: number });
|
|
10
|
+
else if (literal !== void 0) tokens.push({ kind: "literal", text: literal });
|
|
11
|
+
else if (space !== void 0) tokens.push({ kind: "space", text: space });
|
|
12
|
+
else tokens.push({ kind: "punctuation", text: punctuation ?? other ?? "" });
|
|
13
|
+
}
|
|
14
|
+
return tokens;
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DisplayLinkTarget } from '../types/index.js';
|
|
2
|
+
/** Whether a link leaves the app: an absolute http(s) address (route objects never do). */
|
|
3
|
+
export declare function isExternalLink<TTo>(to: TTo): to is TTo & string;
|
|
4
|
+
/**
|
|
5
|
+
* Attributes of a block link: an absolute http(s) address opens in a new tab unless `target` says
|
|
6
|
+
* otherwise, and a new tab never gets access to the app (`noopener noreferrer`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function displayLinkAttrs(to: string, target?: DisplayLinkTarget | null): {
|
|
9
|
+
rel: string | undefined;
|
|
10
|
+
target: DisplayLinkTarget | undefined;
|
|
11
|
+
to: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isString } from "../../shared/utils/predicate.js";
|
|
2
|
+
const ABSOLUTE = /^https?:\/\//iu;
|
|
3
|
+
export function isExternalLink(to) {
|
|
4
|
+
return isString(to) && ABSOLUTE.test(to);
|
|
5
|
+
}
|
|
6
|
+
export function displayLinkAttrs(to, target) {
|
|
7
|
+
const resolved = target === void 0 ? isExternalLink(to) ? "_blank" : void 0 : target ?? void 0;
|
|
8
|
+
return { rel: resolved === "_blank" ? "noopener noreferrer" : void 0, target: resolved, to };
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DisplayMeterProps, DisplayTone } from '../types/index.js';
|
|
2
|
+
/** Share of `max` filled by `value`, between 0 and 1. */
|
|
3
|
+
export declare function meterShare(value: number, max: number): number;
|
|
4
|
+
/** The tone of a filled share: `error` and `warning` from their thresholds, else the given tone. */
|
|
5
|
+
export declare function meterTone(share: number, tone: DisplayTone | undefined, thresholds: DisplayMeterProps['thresholds']): DisplayTone;
|
|
6
|
+
/** Percent widths of parts sharing a track, summing to at most 100. */
|
|
7
|
+
export declare function partWidths(values: readonly number[], max: number): number[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function meterShare(value, max) {
|
|
2
|
+
if (!Number.isFinite(value) || !Number.isFinite(max) || max <= 0) return 0;
|
|
3
|
+
return Math.min(1, Math.max(0, value / max));
|
|
4
|
+
}
|
|
5
|
+
export function meterTone(share, tone, thresholds) {
|
|
6
|
+
const percent = share * 100;
|
|
7
|
+
if (thresholds?.error !== void 0 && percent >= thresholds.error) return "error";
|
|
8
|
+
if (thresholds?.warning !== void 0 && percent >= thresholds.warning) return "warning";
|
|
9
|
+
return tone ?? "primary";
|
|
10
|
+
}
|
|
11
|
+
export function partWidths(values, max) {
|
|
12
|
+
return values.map((value) => meterShare(value, max) * 100);
|
|
13
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type DisplaySkeletonLayout = 'lines' | 'rows' | 'tiles' | 'card' | 'media' | 'ring' | 'block';
|
|
2
|
+
/** The component drawing each display kind. */
|
|
3
|
+
export declare const DISPLAY_BLOCKS: {
|
|
4
|
+
readonly accordion: import("vue").DefineComponent<import("../types/index.js").DisplayAccordionProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayAccordionProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
readonly alert: import("vue").DefineComponent<import("../types/index.js").DisplayAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayAlertProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
readonly breakdown: import("vue").DefineComponent<import("../types/index.js").DisplayBreakdownProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayBreakdownProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
readonly chart: import("vue").DefineComponent<import("../types/index.js").DisplayChartProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayChartProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
readonly code: import("vue").DefineComponent<import("../types/index.js").DisplayCodeProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayCodeProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
readonly date: import("vue").DefineComponent<import("../types/index.js").DisplayDateProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayDateProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
readonly diff: import("vue").DefineComponent<import("../types/index.js").DisplayDiffProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayDiffProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
readonly empty: import("vue").DefineComponent<import("../types/index.js").DisplayEmptyProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayEmptyProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
readonly facts: import("vue").DefineComponent<import("../types/index.js").DisplayFactsProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayFactsProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
readonly heading: import("vue").DefineComponent<import("../types/index.js").DisplayHeadingProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayHeadingProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
readonly list: import("vue").DefineComponent<import("../types/index.js").DisplayListProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayListProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
readonly media: import("vue").DefineComponent<import("../types/index.js").DisplayMediaProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayMediaProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
readonly meter: import("vue").DefineComponent<import("../types/index.js").DisplayMeterProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayMeterProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
17
|
+
readonly person: import("vue").DefineComponent<import("../types/index.js").DisplayPersonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayPersonProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
readonly record: import("vue").DefineComponent<import("../types/index.js").DisplayRecordProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayRecordProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
|
+
readonly stat: import("vue").DefineComponent<import("../types/index.js").DisplayStatProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayStatProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
|
+
readonly table: import("vue").DefineComponent<import("../types/index.js").DisplayTableProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayTableProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
readonly text: import("vue").DefineComponent<import("../types/index.js").DisplayTextProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayTextProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
|
+
readonly timeline: import("vue").DefineComponent<import("../types/index.js").DisplayTimelineProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("../types/index.js").DisplayTimelineProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
23
|
+
};
|
|
24
|
+
/** Kinds in a stable order, for docs and pickers. */
|
|
25
|
+
export declare const DISPLAY_KINDS: readonly (keyof import("../types/index.js").DisplayPropsMap)[];
|
|
26
|
+
/** Skeleton drawn for each kind while its props load. */
|
|
27
|
+
export declare const DISPLAY_SKELETON_LAYOUTS: {
|
|
28
|
+
readonly accordion: "rows";
|
|
29
|
+
readonly alert: "block";
|
|
30
|
+
readonly breakdown: "rows";
|
|
31
|
+
readonly chart: "block";
|
|
32
|
+
readonly code: "block";
|
|
33
|
+
readonly date: "card";
|
|
34
|
+
readonly diff: "rows";
|
|
35
|
+
readonly empty: "block";
|
|
36
|
+
readonly facts: "rows";
|
|
37
|
+
readonly heading: "lines";
|
|
38
|
+
readonly list: "lines";
|
|
39
|
+
readonly media: "media";
|
|
40
|
+
readonly meter: "lines";
|
|
41
|
+
readonly person: "card";
|
|
42
|
+
readonly record: "card";
|
|
43
|
+
readonly stat: "lines";
|
|
44
|
+
readonly table: "rows";
|
|
45
|
+
readonly text: "lines";
|
|
46
|
+
readonly timeline: "lines";
|
|
47
|
+
};
|