@estiva-app/ui 0.39.0 → 0.40.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.
@@ -0,0 +1,78 @@
1
+ import type { ReactNode } from 'react';
2
+ /**
3
+ * Formatted text, drawn: headings, paragraphs, lists, a quote, code, a divider,
4
+ * a table and links.
5
+ *
6
+ * Both apps drew the same thing twice, from the same source — the text tree the
7
+ * protocol package builds (`toRenderTree` → `RenderBlock`, `RenderInline`) —
8
+ * and the two had drifted: headings, list markers, quotes and code differed,
9
+ * one app had tables and the other dropped them, one had links and the other
10
+ * printed the brackets (UIG-30). The look here is Katerina's picks of
11
+ * 28 September, one per difference, most of them Peek's.
12
+ *
13
+ * **It takes the tree, not the text.** The caller parses (the format comes from
14
+ * the item's tag, never from the body) and hands the blocks in. So this package
15
+ * does not depend on the protocol, and a caller can leave out a block it draws
16
+ * elsewhere before passing the rest. The types below are the tree's shape; the
17
+ * protocol's own types fit them.
18
+ *
19
+ * **Safe by construction.** The tree has nothing left to parse, and every
20
+ * string here reaches the page as a React child, so it is text. Nothing is set
21
+ * as HTML.
22
+ *
23
+ * **What a word points at stays the app's.** A person, an item from another
24
+ * app, a name the app recognises in plain text: `renderReference`,
25
+ * `renderText` and `renderBlock` are where each app draws its own.
26
+ */
27
+ /** A run of text and the marks on it — the protocol's `RenderInline`. */
28
+ export interface RichTextRun {
29
+ text: string;
30
+ marks: readonly string[];
31
+ /** A `nostr:` address this run stands for. `text` is the address itself. */
32
+ reference?: string;
33
+ }
34
+ /** A block of the tree — the protocol's `RenderBlock`. */
35
+ export interface RichTextBlock {
36
+ type: string;
37
+ /** What the document called a block the tree does not know. */
38
+ typeName?: string;
39
+ /** The block's address, when it has one. Drawn as `data-block-id`. */
40
+ id?: string;
41
+ level?: 1 | 2 | 3;
42
+ language?: string;
43
+ /** A numbered list's first number. */
44
+ start?: number;
45
+ attrs?: Record<string, unknown>;
46
+ inline?: readonly RichTextRun[];
47
+ children?: readonly RichTextBlock[];
48
+ }
49
+ export type RichTextSize = 'default' | 'small';
50
+ export interface RichTextProps {
51
+ /** The tree, already parsed. */
52
+ blocks: readonly RichTextBlock[];
53
+ /**
54
+ * Default `default`, the size of text you read. `small` is the same text one
55
+ * step down, with every heading, list, quote and table kept: an item shown
56
+ * inside a card.
57
+ */
58
+ size?: RichTextSize;
59
+ /**
60
+ * Draws plain text: what is left of a run once its links are drawn. Where an
61
+ * app turns words it recognises into chips. By default the text as it is.
62
+ */
63
+ renderText?: (text: string) => ReactNode;
64
+ /** Draws a run that stands for an address. By default its text. */
65
+ renderReference?: (reference: string, run: RichTextRun) => ReactNode;
66
+ /**
67
+ * Draws a block this part has no design for (an attachment, a widget). Return
68
+ * `undefined` to leave it to the part, which draws its words.
69
+ */
70
+ renderBlock?: (block: RichTextBlock) => ReactNode | undefined;
71
+ }
72
+ /**
73
+ * RichText's look, for a box you draw yourself: an editor's, so that what is
74
+ * being written looks the same as what is read. Put it on the editor's root.
75
+ */
76
+ export declare function richTextClassName(size?: RichTextSize, className?: string): string;
77
+ export declare function RichText({ blocks, size, renderText, renderReference, renderBlock, }: RichTextProps): import("react").JSX.Element | null;
78
+ //# sourceMappingURL=RichText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../src/RichText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,OAAO,CAAA;AAIlD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACxB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sEAAsE;IACtE,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,MAAM,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;IAC/B,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAA;CACpC;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAE9C,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAA;IAChC;;;;OAIG;IACH,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,CAAA;IACxC,mEAAmE;IACnE,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,SAAS,CAAA;IACpE;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,SAAS,GAAG,SAAS,CAAA;CAC9D;AA0BD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,YAAwB,EAAE,SAAS,CAAC,EAAE,MAAM,UAGnF;AAyKD,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,IAAgB,EAChB,UAA2B,EAC3B,eAA+C,EAC/C,WAAW,GACZ,EAAE,aAAa,sCAQf"}
@@ -242,6 +242,7 @@ var PART_LOOK_PROPS = {
242
242
  RailItem: ["active"],
243
243
  Reaction: ["pressed"],
244
244
  ReactionPicker: ["surface"],
245
+ RichText: ["size"],
245
246
  SectionHeader: ["hover"],
246
247
  SectionLabel: ["tone", "truncate"],
247
248
  Select: ["size"],