@k2b/ui 0.13.0 → 0.14.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.
Files changed (35) hide show
  1. package/dist/browser/content/MarkdownView.js +13 -5
  2. package/dist/browser/content/MarkdownView.js.map +1 -1
  3. package/dist/browser/content/index.js +1 -0
  4. package/dist/browser/content/index.js.map +1 -1
  5. package/dist/browser/content/markdown-info-blocks.js +363 -0
  6. package/dist/browser/content/markdown-info-blocks.js.map +1 -0
  7. package/dist/browser/feedback/dialog-core.js +6 -1
  8. package/dist/browser/feedback/dialog-core.js.map +1 -1
  9. package/dist/browser/intl/messages.js +10 -0
  10. package/dist/browser/intl/messages.js.map +1 -1
  11. package/dist/browser/layout/MobileShell.js +48 -6
  12. package/dist/browser/layout/MobileShell.js.map +1 -1
  13. package/dist/browser/layout/TabBar.js +8 -4
  14. package/dist/browser/layout/TabBar.js.map +1 -1
  15. package/dist/ssr/content/MarkdownView.js +13 -5
  16. package/dist/ssr/content/MarkdownView.js.map +1 -1
  17. package/dist/ssr/content/index.js +1 -0
  18. package/dist/ssr/content/index.js.map +1 -1
  19. package/dist/ssr/content/markdown-info-blocks.js +363 -0
  20. package/dist/ssr/content/markdown-info-blocks.js.map +1 -0
  21. package/dist/ssr/feedback/dialog-core.js +6 -1
  22. package/dist/ssr/feedback/dialog-core.js.map +1 -1
  23. package/dist/ssr/intl/messages.js +10 -0
  24. package/dist/ssr/intl/messages.js.map +1 -1
  25. package/dist/ssr/layout/MobileShell.js +48 -6
  26. package/dist/ssr/layout/MobileShell.js.map +1 -1
  27. package/dist/ssr/layout/TabBar.js +3 -2
  28. package/dist/ssr/layout/TabBar.js.map +1 -1
  29. package/dist/styles.css +1 -1
  30. package/dist/types/content/MarkdownView.d.ts +6 -2
  31. package/dist/types/content/index.d.ts +1 -0
  32. package/dist/types/content/markdown-info-blocks.d.ts +67 -0
  33. package/dist/types/intl/messages.d.ts +5 -0
  34. package/dist/types/layout/TabBar.d.ts +4 -1
  35. package/package.json +1 -1
@@ -26,14 +26,18 @@ export type MarkdownRenderOptions = {
26
26
  /** Optional protocol allowlist, including trailing colons. Relative URLs resolve as HTTPS. */
27
27
  linkProtocols?: readonly string[];
28
28
  linkTarget?: "_blank";
29
+ /** Locale for the screen-reader names of untitled info blocks. `MarkdownView` passes the inherited render locale. */
30
+ locale?: string;
29
31
  };
30
32
  export declare const renderSafeMarkdown: (markdown: string, options?: MarkdownRenderOptions) => string;
31
33
  /**
32
34
  * Markdown View Component (SSR)
33
35
  *
34
36
  * Renders untrusted Markdown safely by default. Raw HTML and unsafe link
35
- * protocols are escaped. Already-rendered HTML requires the deliberately named
36
- * `trustedHtml` boundary; the caller owns sanitization in that mode.
37
+ * protocols are escaped. Info blocks (`:::note`, `:::info`, `:::success`,
38
+ * `:::warning`, `:::danger`) render as the calm `NoticeCard`. Already-rendered
39
+ * HTML requires the deliberately named `trustedHtml` boundary; the caller owns
40
+ * sanitization in that mode.
37
41
  *
38
42
  * @example
39
43
  * ```tsx
@@ -31,6 +31,7 @@ export { default as Lightbox } from "./Lightbox";
31
31
  export type { LogTableEntry } from "./LogEntriesTable";
32
32
  export { default as LogEntriesTable } from "./LogEntriesTable";
33
33
  export { default as MarkdownView, type MarkdownRenderOptions, type MarkdownViewProps, renderSafeMarkdown } from "./MarkdownView";
34
+ export { type MarkdownInfoBlock, type MarkdownInfoBlockRenderInput, type MarkdownInfoBlockType, markdownInfoBlocks, renderMarkdownInfoBlock, scanMarkdownInfoBlock, } from "./markdown-info-blocks";
34
35
  export { Pagination, type PaginationProps } from "./Pagination";
35
36
  export type { PdfPreviewProps, PdfPreviewRequest } from "./PdfPreview";
36
37
  export { default as PdfPreview } from "./PdfPreview";
@@ -0,0 +1,67 @@
1
+ import { type MarkedExtension } from "marked";
2
+ /**
3
+ * Markdown info blocks: one grammar and one look for every Markdown surface.
4
+ *
5
+ * ```markdown
6
+ * :::warning Before deleting
7
+ * Deleting an item cannot be undone.
8
+ * :::
9
+ * ```
10
+ *
11
+ * The opening line holds `:::`, a type in any letter case, and an optional
12
+ * plain-text title. The block ends at a line holding only `:::`, indented no
13
+ * deeper than the opener; code, lists, quotes, and HTML inside the body cannot
14
+ * end it. The body is ordinary Markdown. A block that is never closed stays
15
+ * ordinary text.
16
+ */
17
+ declare const TONES: {
18
+ readonly note: "neutral";
19
+ readonly info: "info";
20
+ readonly success: "success";
21
+ readonly warning: "warning";
22
+ readonly danger: "danger";
23
+ };
24
+ export type MarkdownInfoBlockType = keyof typeof TONES;
25
+ export type MarkdownInfoBlock = {
26
+ type: MarkdownInfoBlockType;
27
+ /** Plain-text title from the opening line. */
28
+ title?: string;
29
+ /** Raw Markdown between the opening and closing lines, with `\n` line breaks. */
30
+ body: string;
31
+ /** Source length through the closing line, or the whole source when the block is not closed. */
32
+ length: number;
33
+ closed: boolean;
34
+ };
35
+ export type MarkdownInfoBlockRenderInput = {
36
+ type: MarkdownInfoBlockType;
37
+ title?: string;
38
+ /** Already rendered body HTML. The caller owns its sanitization. */
39
+ bodyHtml: string;
40
+ /** Locale for the screen-reader name of an untitled block. */
41
+ locale?: string;
42
+ };
43
+ /**
44
+ * Reads the info block that starts `source`. Returns `null` when the first
45
+ * line is not an info-block opener. Applications with their own Markdown
46
+ * pipeline use this to recognize exactly the blocks `MarkdownView` renders.
47
+ * Any line endings are accepted; `length` counts `source` as given.
48
+ */
49
+ export declare const scanMarkdownInfoBlock: (source: string) => MarkdownInfoBlock | null;
50
+ /**
51
+ * Renders an info block as the calm `NoticeCard`: the tone tints the surface,
52
+ * the text stays neutral, and there is no icon. A title is the visible heading
53
+ * and names the block; without one, the localized type name is announced to
54
+ * screen readers only.
55
+ */
56
+ export declare const renderMarkdownInfoBlock: (input: MarkdownInfoBlockRenderInput) => string;
57
+ /**
58
+ * `marked` extension for info blocks at the top level of a document. Blocks
59
+ * inside lists, quotes, or another block stay ordinary text. The body goes
60
+ * through the host's own Markdown renderer, so its escaping and link rules
61
+ * apply unchanged. Locales that share a UI message catalog get the same
62
+ * extension, so a host may cache one `marked` instance per extension.
63
+ */
64
+ export declare const markdownInfoBlocks: (options?: {
65
+ locale?: string;
66
+ }) => MarkedExtension;
67
+ export {};
@@ -33,6 +33,11 @@ declare const uiMessages: import("@k2b/stdlib").Catalog<{
33
33
  close: string;
34
34
  closeDialog: string;
35
35
  copied: string;
36
+ infoBlockNote: string;
37
+ infoBlockInfo: string;
38
+ infoBlockSuccess: string;
39
+ infoBlockWarning: string;
40
+ infoBlockDanger: string;
36
41
  copy: string;
37
42
  closeLightbox: string;
38
43
  couldNotLoadData: string;
@@ -5,6 +5,8 @@ export type TabBarItem = {
5
5
  /** Icon class, for example `ti ti-home`. */
6
6
  icon: string;
7
7
  href: string;
8
+ /** The header title of the page this item opens, shown while that page loads. Defaults to `label`. */
9
+ title?: string;
8
10
  /** The page this item leads to is open. */
9
11
  current?: boolean;
10
12
  };
@@ -17,7 +19,8 @@ export type TabBarProps = {
17
19
  };
18
20
  /**
19
21
  * Bottom navigation between a phone app's top-level pages: native links with equal widths, an icon above each label,
20
- * and `aria-current="page"` on the open page. Place it in `MobileShell`'s footer; it pads the bottom safe area.
22
+ * and `aria-current="page"` on the open page. Place it in `MobileShell`'s footer; it pads the bottom safe area. There a
23
+ * tab switches at the first touch: the shell shows the item's `title` while its page loads.
21
24
  */
22
25
  export declare function TabBar(props: TabBarProps): JSX.Element;
23
26
  export default TabBar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k2b/ui",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Production-ready components for SolidJS applications.",
5
5
  "repository": {
6
6
  "type": "git",