@zh-xx/antu 0.14.0 → 0.15.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.
@@ -12,6 +12,33 @@ export interface AntuSpec {
12
12
  export type AntuTheme = 'document' | 'modern' | 'legal'
13
13
  export type AntuLang = 'zh' | 'en'
14
14
 
15
+ /**
16
+ * How a mounted diagram opens and what it shows (issue 200). Every value a reader can change may be set here:
17
+ * the theme and language, the label card and dock folds, and every switch of the flowchart and route map.
18
+ * Unknown keys, wrong types and values outside an enum make `mount` throw.
19
+ */
20
+ export interface AntuViewState {
21
+ theme?: AntuTheme
22
+ lang?: AntuLang
23
+ shell?: { headerFolded?: boolean; dockFolded?: boolean }
24
+ view?: {
25
+ flow?: {
26
+ states?: boolean
27
+ conditions?: boolean
28
+ detail?: boolean
29
+ mainLine?: boolean
30
+ stages?: boolean
31
+ rules?: boolean
32
+ orientation?: 'vertical' | 'horizontal'
33
+ linkStyle?: 'straight' | 'curved'
34
+ }
35
+ route?: { labels?: boolean; states?: boolean }
36
+ }
37
+ }
38
+
39
+ /** The names `persist` may list: one per prefs key whose write may reach the host's store */
40
+ export type AntuPersistName = 'theme' | 'lang' | 'kind' | 'shell.headerFolded' | 'shell.dockFolded' | 'view.flow' | 'view.route'
41
+
15
42
  /** A source as written in the spec's `sources` (`loc` is shaped by the source's `type`, e.g. a contract's { file, clause, page }) */
16
43
  export interface AntuSource {
17
44
  id: string
@@ -51,12 +78,27 @@ export interface MountOptions {
51
78
  theme?: AntuTheme
52
79
  /** The language of the page's own words; the case is never translated. Default: the browser's. */
53
80
  lang?: AntuLang
54
- /** Pieces of the page's chrome to leave out; all shown by default */
55
- ui?: { header?: boolean; capsule?: boolean; minimap?: boolean; zoom?: boolean }
81
+ /**
82
+ * Pieces of the page's chrome to leave out; all shown by default.
83
+ * `panOnScroll: false` lets the wheel scroll the host page (a chat card).
84
+ * `panOnDrag: false` stops press-and-drag from panning. See `cardUi`.
85
+ */
86
+ ui?: {
87
+ header?: boolean
88
+ capsule?: boolean
89
+ minimap?: boolean
90
+ zoom?: boolean
91
+ panOnScroll?: boolean
92
+ panOnDrag?: boolean
93
+ }
56
94
  /** Where the reader's choices are kept: 'none' (default) while mounted only, 'local' in the viewer page's localStorage key, or the host's store */
57
95
  prefs?: 'none' | 'local' | AntuPrefsStore
58
- /** How it opens, ahead of the reader's stored choices (the reader can still change it). An unknown key or a wrong value: `mount` throws. */
59
- initial?: { headerFolded?: boolean }
96
+ /** How it opens, ahead of the reader's stored choices (the reader can still change it). `headerFolded` is the old alias of `shell.headerFolded`. An unknown key or a wrong value: `mount` throws. */
97
+ initial?: AntuViewState & { headerFolded?: boolean }
98
+ /** Values forced for this mount; their controls are hidden (a locked `shell.dockFolded: true` hides the dock). An unknown key or a wrong value: `mount` throws. */
99
+ locked?: AntuViewState
100
+ /** Which of the reader's changes reach the prefs store: true (all, the default), false (none, kept while mounted), or a list of names. An unknown name or a wrong type: `mount` throws. */
101
+ persist?: boolean | AntuPersistName[]
60
102
  onEvent?: (event: AntuEvent) => void
61
103
  }
62
104
 
@@ -85,6 +127,18 @@ export interface AntuHandle {
85
127
  /** Draw `spec` inside `element` (in a shadow root; the element needs a height). Throws if one is already mounted there, or if `kind`/`kinds` name a way of drawing the spec's type does not have. */
86
128
  export function mount(element: HTMLElement, spec: AntuSpec, options?: MountOptions): AntuHandle
87
129
 
130
+ /**
131
+ * Recommended `ui` for a chat card: no label card, capsule, minimap or zoom buttons, and the wheel
132
+ * does not pan the diagram (the host page can still scroll). Spread into `mount(…, { ui: { …cardUi } })`.
133
+ */
134
+ export declare const cardUi: Readonly<{
135
+ header: false
136
+ capsule: false
137
+ minimap: false
138
+ zoom: false
139
+ panOnScroll: false
140
+ }>
141
+
88
142
  /** Check a spec the way the diagram checks it before drawing; each error names its field */
89
143
  export function validate(spec: unknown): { ok: boolean; errors: string[] }
90
144