@dskripchenko/ui 1.10.0 → 1.12.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/README.md +1 -1
- package/dist/components/Breadcrumb/UidBreadcrumb.vue.d.ts +25 -1
- package/dist/components/Markdown/UidMarkdown.vue.d.ts +43 -0
- package/dist/components/Markdown/blockRenderers.d.ts +36 -0
- package/dist/components/Markdown/index.d.ts +6 -0
- package/dist/components/Markdown/markdown.d.ts +71 -0
- package/dist/index.cjs +13 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +924 -422
- package/dist/locales/types.d.ts +13 -0
- package/dist/styles/all.css +1 -1
- package/dist/styles/index.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ A short selection — the full catalog is in [Storybook](https://dskripchenko.gi
|
|
|
107
107
|
|
|
108
108
|
User docs are translated into four languages — pick yours:
|
|
109
109
|
|
|
110
|
-
- 🇬🇧 **English** (default): [getting-started](./docs/en/getting-started.md), [theming](./docs/en/theming.md), [tokens](./docs/en/tokens.md), [icons](./docs/en/icons.md), [patterns](./docs/en/patterns.md), [validation](./docs/en/validation.md), [charts](./docs/en/charts.md), [i18n](./docs/en/i18n.md)
|
|
110
|
+
- 🇬🇧 **English** (default): [getting-started](./docs/en/getting-started.md), [theming](./docs/en/theming.md), [tokens](./docs/en/tokens.md), [icons](./docs/en/icons.md), [patterns](./docs/en/patterns.md), [validation](./docs/en/validation.md), [charts](./docs/en/charts.md), [markdown](./docs/en/markdown.md), [i18n](./docs/en/i18n.md)
|
|
111
111
|
- 🇷🇺 **Русский**: [docs/ru/](./docs/ru/)
|
|
112
112
|
- 🇩🇪 **Deutsch**: [docs/de/](./docs/de/)
|
|
113
113
|
- 🇨🇳 **中文**: [docs/zh/](./docs/zh/)
|
|
@@ -10,10 +10,32 @@ export interface UidBreadcrumbProps {
|
|
|
10
10
|
collapse?: boolean;
|
|
11
11
|
/** `collapse` mode: the "…" is a button that opens a menu of the collapsed crumbs. Set `false` for a plain "…". */
|
|
12
12
|
collapseMenu?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* `collapse` mode: when even "first › … › current" does not fit, the first
|
|
15
|
+
* crumb collapses into the "…" as well, leaving "… › current". The current
|
|
16
|
+
* crumb stays visible and truncates with an ellipsis.
|
|
17
|
+
*/
|
|
18
|
+
collapseFirst?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* `collapse` mode: an extra element whose width changes re-measure the trail.
|
|
21
|
+
* The trail always watches its own `<nav>` and its parent element; pass an
|
|
22
|
+
* ancestor here when the parent is itself sized by its content (e.g. a flex
|
|
23
|
+
* item without `flex-grow` in a toolbar), so the trail expands again when the
|
|
24
|
+
* room around it grows. A string is a CSS selector matched with `closest()`
|
|
25
|
+
* from the `<nav>`.
|
|
26
|
+
*/
|
|
27
|
+
container?: HTMLElement | string | null;
|
|
13
28
|
}
|
|
14
29
|
/**
|
|
15
30
|
* Lay every crumb out at its natural width, then hide middle crumbs (second
|
|
16
|
-
* one first) until the rest plus the "…" fits the list.
|
|
31
|
+
* one first) until the rest plus the "…" fits the list. With `collapseFirst`
|
|
32
|
+
* the first crumb goes too when "first › … › current" still does not fit.
|
|
33
|
+
*
|
|
34
|
+
* While measuring nothing in the trail shrinks, so the list gets the room its
|
|
35
|
+
* container can give a full trail: the measured width is the available one
|
|
36
|
+
* even when the trail's parent is sized by its content. Siblings that shrink
|
|
37
|
+
* to make room for a full trail take that room back once it collapses, so the
|
|
38
|
+
* collapsed trail is checked once more and folds further while it overflows.
|
|
17
39
|
*/
|
|
18
40
|
declare function recompute(): Promise<void>;
|
|
19
41
|
declare function __VLS_template(): {
|
|
@@ -40,6 +62,8 @@ declare const __VLS_component: import('vue').DefineComponent<UidBreadcrumbProps,
|
|
|
40
62
|
nowrap: boolean;
|
|
41
63
|
collapse: boolean;
|
|
42
64
|
collapseMenu: boolean;
|
|
65
|
+
collapseFirst: boolean;
|
|
66
|
+
container: HTMLElement | string | null;
|
|
43
67
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
44
68
|
navRef: HTMLElement;
|
|
45
69
|
listRef: HTMLOListElement;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { UidMarkdownCalloutKind } from './markdown.js';
|
|
2
|
+
import { UidMarkdownBlockRenderer } from './blockRenderers.js';
|
|
3
|
+
export interface UidMarkdownProps {
|
|
4
|
+
/** The markdown text. */
|
|
5
|
+
source?: string;
|
|
6
|
+
/** Shows a table of contents built from the headings. */
|
|
7
|
+
toc?: boolean;
|
|
8
|
+
/** Deepest heading level in the table of contents, 2 to 6. */
|
|
9
|
+
tocDepth?: number;
|
|
10
|
+
/** Title of the table of contents; the locale's by default. */
|
|
11
|
+
tocLabel?: string;
|
|
12
|
+
/** The base relative links resolve against. */
|
|
13
|
+
linkBase?: string;
|
|
14
|
+
/** Drops a trailing `.md` from relative links; on by default when `linkBase` is set. */
|
|
15
|
+
stripMdExtension?: boolean;
|
|
16
|
+
/** The base relative image paths resolve against. */
|
|
17
|
+
imageBase?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Opens relative and anchor links in the same tab (the default). Off, every
|
|
20
|
+
* link but an anchor opens in a new tab — for a preview next to a form,
|
|
21
|
+
* where leaving the page would lose the input.
|
|
22
|
+
*/
|
|
23
|
+
internalLinksInPlace?: boolean;
|
|
24
|
+
/** Callout titles; override the locale's, kind by kind. */
|
|
25
|
+
calloutTitles?: Partial<Record<UidMarkdownCalloutKind, string>>;
|
|
26
|
+
/** Renderers for fenced blocks by language; override the provided ones. */
|
|
27
|
+
blockRenderers?: Record<string, UidMarkdownBlockRenderer>;
|
|
28
|
+
}
|
|
29
|
+
declare const _default: import('vue').DefineComponent<UidMarkdownProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<UidMarkdownProps> & Readonly<{}>, {
|
|
30
|
+
source: string;
|
|
31
|
+
toc: boolean;
|
|
32
|
+
tocDepth: number;
|
|
33
|
+
tocLabel: string;
|
|
34
|
+
linkBase: string;
|
|
35
|
+
stripMdExtension: boolean;
|
|
36
|
+
imageBase: string;
|
|
37
|
+
internalLinksInPlace: boolean;
|
|
38
|
+
calloutTitles: Partial<Record<UidMarkdownCalloutKind, string>>;
|
|
39
|
+
blockRenderers: Record<string, UidMarkdownBlockRenderer>;
|
|
40
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
41
|
+
root: HTMLDivElement;
|
|
42
|
+
}, HTMLDivElement>;
|
|
43
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
2
|
+
/** What a block renderer returns for one fenced code block. */
|
|
3
|
+
export interface UidMarkdownBlockResult {
|
|
4
|
+
/**
|
|
5
|
+
* Markup to insert in place of the code block.
|
|
6
|
+
*
|
|
7
|
+
* Inserted as is (`v-html`): the renderer is responsible for its safety.
|
|
8
|
+
* Return only markup you built yourself with every piece of user text
|
|
9
|
+
* escaped — for example SVG from @dskripchenko/diagrams, which escapes
|
|
10
|
+
* labels by construction. Never return the block's source unescaped.
|
|
11
|
+
*/
|
|
12
|
+
html?: string;
|
|
13
|
+
/** Why the block could not be rendered; the block is then shown as code with this message. */
|
|
14
|
+
error?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Renders a fenced code block of one language (```mermaid, ```chart, …)
|
|
18
|
+
* instead of showing it as code. May be asynchronous — the block shows a
|
|
19
|
+
* placeholder until it settles. A thrown error or a rejected promise is
|
|
20
|
+
* treated like `{ error }`.
|
|
21
|
+
*/
|
|
22
|
+
export type UidMarkdownBlockRenderer = (code: string, ctx: {
|
|
23
|
+
language: string;
|
|
24
|
+
index: number;
|
|
25
|
+
}) => UidMarkdownBlockResult | Promise<UidMarkdownBlockResult>;
|
|
26
|
+
/** Block renderers by fence language (lower case). */
|
|
27
|
+
export type UidMarkdownBlockRenderers = Readonly<Record<string, UidMarkdownBlockRenderer>>;
|
|
28
|
+
export declare const markdownBlockRenderersKey: InjectionKey<UidMarkdownBlockRenderers>;
|
|
29
|
+
/**
|
|
30
|
+
* Registers block renderers for every UidMarkdown below the calling
|
|
31
|
+
* component — call it in the root component's setup once. Application-wide:
|
|
32
|
+
* `app.provide(markdownBlockRenderersKey, renderers)`. Renderers passed to
|
|
33
|
+
* UidMarkdown through its prop take precedence, language by language.
|
|
34
|
+
*/
|
|
35
|
+
export declare function provideMarkdownBlockRenderers(renderers: UidMarkdownBlockRenderers): void;
|
|
36
|
+
export declare function useMarkdownBlockRenderers(): UidMarkdownBlockRenderers;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as UidMarkdown } from './UidMarkdown.vue';
|
|
2
|
+
export type { UidMarkdownProps } from './UidMarkdown.vue';
|
|
3
|
+
export { createSlugger, escapeHtml, renderMarkdown, resolveAgainst, splitMarkdown, } from './markdown.js';
|
|
4
|
+
export type { MarkdownHeading, MarkdownOptions, MarkdownSegment, Slugger, UidMarkdownCalloutKind, } from './markdown.js';
|
|
5
|
+
export { markdownBlockRenderersKey, provideMarkdownBlockRenderers, useMarkdownBlockRenderers, } from './blockRenderers.js';
|
|
6
|
+
export type { UidMarkdownBlockRenderer, UidMarkdownBlockRenderers, UidMarkdownBlockResult, } from './blockRenderers.js';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small, dependency-free markdown → HTML renderer.
|
|
3
|
+
*
|
|
4
|
+
* It covers the everyday subset — headings, paragraphs, emphasis, inline code,
|
|
5
|
+
* fenced code, links, images, block quotes and callouts, lists, tables and
|
|
6
|
+
* rules — which is what a description, a note or a documentation page in an
|
|
7
|
+
* admin usually holds. A host that needs the full CommonMark grammar registers
|
|
8
|
+
* its own `markdown` field, entry or layout.
|
|
9
|
+
*
|
|
10
|
+
* Safety: the source is HTML-escaped BEFORE any markup is produced, so raw
|
|
11
|
+
* HTML in the markdown is shown as text, never executed; link and image URLs
|
|
12
|
+
* are limited to http(s), mailto, relative and anchor targets.
|
|
13
|
+
*
|
|
14
|
+
* Ported from laravel-admin core, where it was born; the kit is now its home.
|
|
15
|
+
*/
|
|
16
|
+
export declare function escapeHtml(text: string): string;
|
|
17
|
+
/** A heading met while rendering, for a table of contents. */
|
|
18
|
+
export interface MarkdownHeading {
|
|
19
|
+
level: number;
|
|
20
|
+
/** The heading's plain text. */
|
|
21
|
+
text: string;
|
|
22
|
+
id: string;
|
|
23
|
+
}
|
|
24
|
+
/** Turns heading text into a unique anchor id; shared across the chunks of one document. */
|
|
25
|
+
export type Slugger = (text: string) => string;
|
|
26
|
+
export declare function createSlugger(): Slugger;
|
|
27
|
+
export interface MarkdownOptions {
|
|
28
|
+
/** Gives the headings anchor ids. */
|
|
29
|
+
slugger?: Slugger | null;
|
|
30
|
+
/** Called for every heading, in document order. */
|
|
31
|
+
onHeading?: (heading: MarkdownHeading) => void;
|
|
32
|
+
/**
|
|
33
|
+
* The base relative links resolve against, the way a browser resolves them
|
|
34
|
+
* against `<base href>`. Absolute, anchor and scheme links are left alone.
|
|
35
|
+
*/
|
|
36
|
+
linkBase?: string | null;
|
|
37
|
+
/** Drops a trailing `.md` from relative links resolved through linkBase. */
|
|
38
|
+
stripMdExtension?: boolean;
|
|
39
|
+
/** The base relative image paths resolve against. */
|
|
40
|
+
imageBase?: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Opens relative and anchor links in place. By default every link opens in
|
|
43
|
+
* a new tab, which suits a note in a form; a documentation page wants its
|
|
44
|
+
* own links to navigate.
|
|
45
|
+
*/
|
|
46
|
+
internalLinksInPlace?: boolean;
|
|
47
|
+
/** Titles of `[!NOTE]`-style callouts; English when not given. */
|
|
48
|
+
calloutTitles?: Partial<Record<UidMarkdownCalloutKind, string>>;
|
|
49
|
+
}
|
|
50
|
+
export type UidMarkdownCalloutKind = 'note' | 'tip' | 'important' | 'warning' | 'caution';
|
|
51
|
+
/**
|
|
52
|
+
* Resolves an escaped relative URL against a base. The result is escaped
|
|
53
|
+
* again; an absolute base keeps its origin, a path base yields a path.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveAgainst(escapedUrl: string, base: string, stripMd?: boolean): string;
|
|
56
|
+
export declare function renderMarkdown(source: string | null | undefined, opts?: MarkdownOptions): string;
|
|
57
|
+
/** A piece of a markdown document: text to render, or a top-level fenced code block. */
|
|
58
|
+
export type MarkdownSegment = {
|
|
59
|
+
kind: 'text';
|
|
60
|
+
source: string;
|
|
61
|
+
} | {
|
|
62
|
+
kind: 'code';
|
|
63
|
+
code: string;
|
|
64
|
+
language: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Splits a document at its top-level fenced code blocks, so that a caller can
|
|
68
|
+
* draw the code with a real highlighter and the rest with renderMarkdown.
|
|
69
|
+
* Fences inside block quotes stay in the text.
|
|
70
|
+
*/
|
|
71
|
+
export declare function splitMarkdown(source: string | null | undefined): MarkdownSegment[];
|