@yaks/inspect 0.0.0-stage → 0.2.36
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/Comp.js +469 -0
- package/Comp.js.map +1 -0
- package/Comp.ts +471 -0
- package/Effect.js +136 -0
- package/Effect.js.map +1 -0
- package/Effect.ts +142 -0
- package/Entity.js +112 -0
- package/Entity.js.map +1 -0
- package/Entity.ts +137 -0
- package/Facts.js +143 -0
- package/Facts.js.map +1 -0
- package/Facts.ts +150 -0
- package/Head.js +196 -0
- package/Head.js.map +1 -0
- package/Head.ts +195 -0
- package/Held.js +144 -0
- package/Held.js.map +1 -0
- package/Held.ts +172 -0
- package/History.js +157 -0
- package/History.js.map +1 -0
- package/History.ts +215 -0
- package/Home.js +482 -0
- package/Home.js.map +1 -0
- package/Home.ts +550 -0
- package/LICENSE +202 -0
- package/Links.js +197 -0
- package/Links.js.map +1 -0
- package/Links.ts +212 -0
- package/Package.js +195 -0
- package/Package.js.map +1 -0
- package/Package.ts +191 -0
- package/Past.js +163 -0
- package/Past.js.map +1 -0
- package/Past.ts +181 -0
- package/Prop.js +225 -0
- package/Prop.js.map +1 -0
- package/Prop.ts +208 -0
- package/Query.js +207 -0
- package/Query.js.map +1 -0
- package/Query.ts +229 -0
- package/README.md +141 -2
- package/Words.js +43 -0
- package/Words.js.map +1 -0
- package/Words.ts +70 -0
- package/_dist/Entity.d.ts +7 -0
- package/_dist/Entity.d.ts.map +1 -0
- package/_dist/Facts.d.ts +7 -0
- package/_dist/Facts.d.ts.map +1 -0
- package/_dist/Head.d.ts +22 -0
- package/_dist/Head.d.ts.map +1 -0
- package/_dist/Held.d.ts +37 -0
- package/_dist/Held.d.ts.map +1 -0
- package/_dist/Links.d.ts +9 -0
- package/_dist/Links.d.ts.map +1 -0
- package/_dist/Past.d.ts +65 -0
- package/_dist/Past.d.ts.map +1 -0
- package/_dist/Words.d.ts +27 -0
- package/_dist/Words.d.ts.map +1 -0
- package/_dist/census.d.ts +10 -0
- package/_dist/census.d.ts.map +1 -0
- package/_dist/door.d.ts +28 -0
- package/_dist/door.d.ts.map +1 -0
- package/_dist/front.d.ts +4 -0
- package/_dist/front.d.ts.map +1 -0
- package/_dist/host.d.ts +94 -0
- package/_dist/host.d.ts.map +1 -0
- package/_dist/mod.d.ts +24 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/notes.d.ts +38 -0
- package/_dist/notes.d.ts.map +1 -0
- package/_dist/read.d.ts +59 -0
- package/_dist/read.d.ts.map +1 -0
- package/_dist/reading.d.ts +21 -0
- package/_dist/reading.d.ts.map +1 -0
- package/_dist/registry.d.ts +12 -0
- package/_dist/registry.d.ts.map +1 -0
- package/_dist/schema.d.ts +4 -0
- package/_dist/schema.d.ts.map +1 -0
- package/_dist/state.d.ts +22 -0
- package/_dist/state.d.ts.map +1 -0
- package/_dist/value.d.ts +20 -0
- package/_dist/value.d.ts.map +1 -0
- package/_dist/views.d.ts +3 -0
- package/_dist/views.d.ts.map +1 -0
- package/census.js +50 -0
- package/census.js.map +1 -0
- package/census.ts +76 -0
- package/deno.json +1 -0
- package/door.js +54 -0
- package/door.js.map +1 -0
- package/door.ts +59 -0
- package/front.js +12 -0
- package/front.js.map +1 -0
- package/front.json +76 -0
- package/front.ts +13 -0
- package/grid.js +249 -0
- package/grid.js.map +1 -0
- package/grid.ts +395 -0
- package/host.js +20 -0
- package/host.js.map +1 -0
- package/host.ts +134 -0
- package/mod.js +20 -0
- package/mod.js.map +1 -0
- package/mod.ts +45 -0
- package/notes.js +184 -0
- package/notes.js.map +1 -0
- package/notes.ts +288 -0
- package/package.json +35 -4
- package/read.js +300 -0
- package/read.js.map +1 -0
- package/read.ts +386 -0
- package/reading.js +64 -0
- package/reading.js.map +1 -0
- package/reading.ts +73 -0
- package/registry.js +89 -0
- package/registry.js.map +1 -0
- package/registry.ts +89 -0
- package/rows.js +12 -0
- package/rows.js.map +1 -0
- package/rows.ts +26 -0
- package/schema.js +47 -0
- package/schema.js.map +1 -0
- package/schema.ts +70 -0
- package/state.js +85 -0
- package/state.js.map +1 -0
- package/state.ts +128 -0
- package/terminal-links.ts +16 -0
- package/value.js +67 -0
- package/value.js.map +1 -0
- package/value.ts +79 -0
- package/views.js +4 -0
- package/views.js.map +1 -0
- package/views.ts +6 -0
package/host.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an inspector view is, and what it asks of the host that draws it.
|
|
3
|
+
*
|
|
4
|
+
* A view is a domain component in the sense of https://yak.sh/composable-ui.md:
|
|
5
|
+
* it knows no store. It says which bundles it draws (`match`, a @yaks/render
|
|
6
|
+
* registration), the queries it needs as data (`asks`, a query line by the
|
|
7
|
+
* name it reads the answer under, and `io.ask` for a query that depends on
|
|
8
|
+
* another's answer), and draws what it is handed: the bundle, each answer
|
|
9
|
+
* (`got`), and `io`, its doors to the world outside it. An edit goes out
|
|
10
|
+
* through `io.apply` as bundles; the inspector's own state (./state.ts) is
|
|
11
|
+
* read and written in the page's own graph through `io.state` and `io.set`.
|
|
12
|
+
*
|
|
13
|
+
* The host is what a browser or a terminal supplies once ({@link Host}): the
|
|
14
|
+
* vocabulary, a hook answering asks while the view asking is mounted, where
|
|
15
|
+
* links go, how an entity is named, and the doors that write. `inspector()`
|
|
16
|
+
* (./door.ts) turns a host into the `Door` every view is drawn through.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import type { FunctionComponent, ReactNode } from 'npm:react@19.3.0'
|
|
22
|
+
import type { Bundle, Context, Registration } from 'jsr:@yaks/render@0.2.36'
|
|
23
|
+
import type { Vocab } from 'jsr:@yaks/vocab@0.2.36'
|
|
24
|
+
|
|
25
|
+
export type { Bundle }
|
|
26
|
+
|
|
27
|
+
/** One query's answer, as the host holds it. */
|
|
28
|
+
export type Answer = {
|
|
29
|
+
/** the rows it matched; none for an aggregate */
|
|
30
|
+
rows: Bundle[]
|
|
31
|
+
/** a `.count`'s number */
|
|
32
|
+
count?: number
|
|
33
|
+
/** a `.tally`'s count of each value */
|
|
34
|
+
tally?: Record<string, number>
|
|
35
|
+
/** answered: false while the host is still asking, and after a refusal */
|
|
36
|
+
ready: boolean
|
|
37
|
+
/** why the host refused it */
|
|
38
|
+
error?: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** One query a view asks: a line, answered and kept live while the view is
|
|
42
|
+
* mounted, or `{query, …}`: `once`, answered once, for an answer that reads
|
|
43
|
+
* too much to be asked again after every commit; `typed`, a line the person
|
|
44
|
+
* typed, whose refusal is the answer to their input (the view shows it), not a
|
|
45
|
+
* failure of the view's code. */
|
|
46
|
+
export type Ask = string | { query: string; once?: true; typed?: true }
|
|
47
|
+
|
|
48
|
+
/** The queries a view asks, each by the name its answer is read under. */
|
|
49
|
+
export type Asks = Record<string, Ask>
|
|
50
|
+
|
|
51
|
+
/** A page's own graph, as much as the inspector needs of it: a @yaks/client
|
|
52
|
+
* `client()` is one. */
|
|
53
|
+
export type Front = {
|
|
54
|
+
/** the components it holds: the inspector's own (./front.json), and
|
|
55
|
+
* whatever else the page keeps there (a field's @yaks/filter state) */
|
|
56
|
+
vocab: { comps: string[] }
|
|
57
|
+
mutate: (bundles: Bundle[]) => unknown
|
|
58
|
+
watch: (query: string) => {
|
|
59
|
+
value: Bundle[]
|
|
60
|
+
subscribe: (fn: (rows: Bundle[]) => void) => () => void
|
|
61
|
+
}
|
|
62
|
+
ent: (eid: string) => Bundle | undefined
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** What a browser or a terminal supplies, once. */
|
|
66
|
+
export type Host = {
|
|
67
|
+
/** the graph's vocabulary: what a component is, what may be written */
|
|
68
|
+
vocab: Vocab
|
|
69
|
+
/** the answer to each ask, held while the view asking is mounted: a hook,
|
|
70
|
+
* called once per render with the whole set */
|
|
71
|
+
useAnswers: (asks: Asks) => Record<string, Answer>
|
|
72
|
+
/** write a batch to the graph; a write it refuses rejects, saying why */
|
|
73
|
+
apply: (bundles: Bundle[]) => void | Promise<void>
|
|
74
|
+
/** the page's own graph, where the inspector keeps its state */
|
|
75
|
+
front: Front
|
|
76
|
+
/** an entity the host holds, by eid, read reactively: one an answer
|
|
77
|
+
* brought (the transactions a history asks for beside its changes) */
|
|
78
|
+
get: (eid: string) => Bundle | undefined
|
|
79
|
+
/** where an entity's page is: the host opens it on the view it draws
|
|
80
|
+
* that entity with, as any link to it does */
|
|
81
|
+
link: (eid: string) => string
|
|
82
|
+
/** where an entity reads as it was just after a transaction (./Past.ts);
|
|
83
|
+
* a host without it offers no old versions */
|
|
84
|
+
past?: (eid: string, tx: string) => string
|
|
85
|
+
/** where the inspector's page for a query is */
|
|
86
|
+
find: (query: string) => string
|
|
87
|
+
/** follow an address in place: a link's, or a pressed row's (its
|
|
88
|
+
* entity's `link`). The inspector's own page stacks it on the panes it
|
|
89
|
+
* shows; a card goes there. */
|
|
90
|
+
go: (href: string) => void
|
|
91
|
+
/** the id a person reads: `T-9` */
|
|
92
|
+
id: (b: Bundle) => string
|
|
93
|
+
/** the kind it displays as: `task` */
|
|
94
|
+
kind: (b: Bundle) => string
|
|
95
|
+
/** what to call the entity an eid names, from whatever the host holds */
|
|
96
|
+
name: (eid: string) => string
|
|
97
|
+
/** a moment, in words */
|
|
98
|
+
when: (at: string) => string
|
|
99
|
+
/** whether its controls take input: a browser's do; a terminal paints
|
|
100
|
+
* them, and a value there is read, not typed over */
|
|
101
|
+
edits: boolean
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A view's doors to the world outside it. */
|
|
105
|
+
export type Io = Omit<Host, 'useAnswers' | 'front'> & {
|
|
106
|
+
/** another bundle, drawn through the same registry as `view` */
|
|
107
|
+
show: (b: Bundle, view: string, ctx?: Context) => ReactNode
|
|
108
|
+
/** whether the registry draws this bundle as `view` */
|
|
109
|
+
can: (b: Bundle, view: string) => boolean
|
|
110
|
+
/** the answers to asks a component makes as it draws: a hook, for a query
|
|
111
|
+
* that depends on another's answer */
|
|
112
|
+
ask: (asks: Asks) => Record<string, Answer>
|
|
113
|
+
/** one of the inspector's own entities, read reactively */
|
|
114
|
+
state: (eid: string) => Bundle | undefined
|
|
115
|
+
/** write the inspector's own state */
|
|
116
|
+
set: (bundles: Bundle[]) => void
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** What a view is drawn with. */
|
|
120
|
+
export type Props = {
|
|
121
|
+
/** the bundle it draws */
|
|
122
|
+
e: Bundle
|
|
123
|
+
/** each of its asks, answered */
|
|
124
|
+
got: Record<string, Answer>
|
|
125
|
+
io: Io
|
|
126
|
+
/** what the caller drew it with */
|
|
127
|
+
ctx: Context
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** An inspector view: a registration, what it asks, and its component. */
|
|
131
|
+
export type View = Registration & {
|
|
132
|
+
asks?: (e: Bundle, io: Io, ctx: Context) => Asks
|
|
133
|
+
Render: FunctionComponent<Props>
|
|
134
|
+
}
|
package/mod.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inspect views: entities, vocabulary components, packages, properties,
|
|
3
|
+
* effects, query rows and the map. A host mounts these registrations in its shared registry,
|
|
4
|
+
* answers their declared queries and applies emitted bundles. Browse owns the
|
|
5
|
+
* sidebar and navigation; web and tui are its doors.
|
|
6
|
+
* @module
|
|
7
|
+
*/ export { inspector } from "./door.js";
|
|
8
|
+
export { note, Part, useNamed } from "./notes.js";
|
|
9
|
+
export { usePageNotes } from "./Entity.js";
|
|
10
|
+
export { Past, version, VERSIONS, versions } from "./Past.js";
|
|
11
|
+
export { mention, reads } from "./value.js";
|
|
12
|
+
export { compEid, effectEid } from "./schema.js";
|
|
13
|
+
export { edited, editing, INSPECT } from "./state.js";
|
|
14
|
+
export { all, composed, schemaPages, views } from "./registry.js";
|
|
15
|
+
export { called, face, leaves, shape } from "./read.js";
|
|
16
|
+
export { useCensus } from "./census.js";
|
|
17
|
+
export { useReading, whole } from "./reading.js";
|
|
18
|
+
export { Held } from "./Held.js";
|
|
19
|
+
export { Words } from "./Words.js";
|
|
20
|
+
//# sourceMappingURL=mod.js.map
|
package/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA;;;;;;CAMC,GAED,SAAyC,SAAS,oBAAmB;AACrE,SAAS,IAAI,EAAE,IAAI,EAAkB,QAAQ,qBAAoB;AACjE,SAAuB,YAAY,sBAAqB;AACxD,SAEE,IAAI,EAGJ,OAAO,EACP,QAAQ,EACR,QAAQ,oBACQ;AAIlB,SAAS,OAAO,EAAE,KAAK,qBAAoB;AAC3C,SAAS,OAAO,EAAE,SAAS,sBAAqB;AAYhD,SAAS,MAAM,EAAE,OAAO,EAAE,OAAO,qBAAoB;AACrD,SAAS,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,wBAAuB;AAEjE,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,oBAAmB;AAEvD,SAAsB,SAAS,sBAAqB;AACpD,SAAoC,UAAU,EAAE,KAAK,uBAAsB;AAC3E,SAAS,IAAI,oBAAmC;AAChD,SAAS,KAAK,qBAAqC"}
|
package/mod.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inspect views: entities, vocabulary components, packages, properties,
|
|
3
|
+
* effects, query rows and the map. A host mounts these registrations in its shared registry,
|
|
4
|
+
* answers their declared queries and applies emitted bundles. Browse owns the
|
|
5
|
+
* sidebar and navigation; web and tui are its doors.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export { type DoorProps, type Inspector, inspector } from './door.js'
|
|
10
|
+
export { note, Part, type PartProps, useNamed } from './notes.js'
|
|
11
|
+
export { type PageCtx, usePageNotes } from './Entity.js'
|
|
12
|
+
export {
|
|
13
|
+
type Change,
|
|
14
|
+
Past,
|
|
15
|
+
type PastProps,
|
|
16
|
+
type Version,
|
|
17
|
+
version,
|
|
18
|
+
VERSIONS,
|
|
19
|
+
versions,
|
|
20
|
+
} from './Past.js'
|
|
21
|
+
export type { HeadCtx } from './Head.ts'
|
|
22
|
+
export type { FactsCtx } from './Facts.ts'
|
|
23
|
+
export type { LinksCtx } from './Links.ts'
|
|
24
|
+
export { mention, reads } from './value.js'
|
|
25
|
+
export { compEid, effectEid } from './schema.js'
|
|
26
|
+
export type {
|
|
27
|
+
Answer,
|
|
28
|
+
Ask,
|
|
29
|
+
Asks,
|
|
30
|
+
Bundle,
|
|
31
|
+
Front,
|
|
32
|
+
Host,
|
|
33
|
+
Io,
|
|
34
|
+
Props,
|
|
35
|
+
View,
|
|
36
|
+
} from './host.ts'
|
|
37
|
+
export { edited, editing, INSPECT } from './state.js'
|
|
38
|
+
export { all, composed, schemaPages, views } from './registry.js'
|
|
39
|
+
|
|
40
|
+
export { called, face, leaves, shape } from './read.js'
|
|
41
|
+
|
|
42
|
+
export { type Census, useCensus } from './census.js'
|
|
43
|
+
export { type Reader, type Reading, useReading, whole } from './reading.js'
|
|
44
|
+
export { Held, type HeldProps } from './Held.js'
|
|
45
|
+
export { Words, type WordsProps } from './Words.js'
|
package/notes.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notes: what a person says about a part, left under the heading they saw it
|
|
3
|
+
* under, and picked up as work. Every heading on a page offers a `note`
|
|
4
|
+
* press, which opens one line under it; what is sent is a comment on the
|
|
5
|
+
* page's entity (`comment{target}`) that is also an open task (`task{}`), so
|
|
6
|
+
* it shows under that heading again, and is on every list of open work until
|
|
7
|
+
* someone takes it: `yak task list`, or `yak task list .comment.target=<eid>`
|
|
8
|
+
* for what was said about one part.
|
|
9
|
+
*
|
|
10
|
+
* A comment says nothing of where on its target it was left, so the heading
|
|
11
|
+
* rides in the note's title, after the thing it is about:
|
|
12
|
+
* `task · Properties: status should be an enum`. A note whose title names no
|
|
13
|
+
* heading on the page shows under the page's own.
|
|
14
|
+
*
|
|
15
|
+
* `Part` is a titled section of a page with its note press and its notes.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/ import { groupBy } from "@yaks/fp";
|
|
19
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, useLayoutEffect, useRef } from "react";
|
|
20
|
+
import { Button, Composer, Notes, Section } from "@yaks/ui";
|
|
21
|
+
import { editKeys } from "@yaks/ux/edit-keys";
|
|
22
|
+
import { comp, count, line, named, str } from "./read.js";
|
|
23
|
+
import { rows } from "./rows.js";
|
|
24
|
+
import { edited, key, me, put, refusal, write } from "./state.js";
|
|
25
|
+
/** How many notes a page reads. */ export let NOTES = 100;
|
|
26
|
+
/** The notes left on the entity `eid`, as a query: the comments on it that
|
|
27
|
+
* are tasks. A plain comment is not a note; the page draws it among its
|
|
28
|
+
* links, or a package's page among its comments. */ export let notesOf = (eid)=>`.comment&.task&.comment.target=${eid}&.limit=${NOTES}&*`;
|
|
29
|
+
/**
|
|
30
|
+
* A note's title: the thing it is about, the heading it was left under, and
|
|
31
|
+
* the first line of what it says.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { titled } from './notes.ts'
|
|
35
|
+
* titled('task', 'Properties', 'status should be an enum\nit is text')
|
|
36
|
+
* // 'task · Properties: status should be an enum'
|
|
37
|
+
* titled('T-9', '', 'wrong owner') // 'T-9: wrong owner'
|
|
38
|
+
* ```
|
|
39
|
+
*/ export let titled = (subject, heading, text)=>`${heading ? `${subject} · ${heading}` : subject}: ${line(text, 80)}`;
|
|
40
|
+
/**
|
|
41
|
+
* A note on the entity `eid`, left under `heading`, as the batch that
|
|
42
|
+
* leaves it: a comment on it that is an open task.
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { note } from './notes.ts'
|
|
46
|
+
* note('c1', 'task', 'Properties', 'status should be an enum')
|
|
47
|
+
* // [{
|
|
48
|
+
* // entity: { eid: '$note' },
|
|
49
|
+
* // doc: { title: 'task · Properties: status should be an enum', body: 'status should be an enum' },
|
|
50
|
+
* // comment: { target: 'c1' },
|
|
51
|
+
* // task: {},
|
|
52
|
+
* // }]
|
|
53
|
+
* ```
|
|
54
|
+
*/ export let note = (eid, subject, heading, text)=>[
|
|
55
|
+
{
|
|
56
|
+
entity: {
|
|
57
|
+
eid: '$note'
|
|
58
|
+
},
|
|
59
|
+
doc: {
|
|
60
|
+
title: titled(subject, heading, text),
|
|
61
|
+
body: text
|
|
62
|
+
},
|
|
63
|
+
comment: {
|
|
64
|
+
target: eid
|
|
65
|
+
},
|
|
66
|
+
task: {}
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
* The notes under each heading of a page: by the heading a note's title
|
|
71
|
+
* names, or under the page's own (`''`) when it names none of them.
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { under } from './notes.ts'
|
|
75
|
+
* let n = (title: string) => ({ entity: { eid: title }, doc: { title } })
|
|
76
|
+
* let by = under([n('task · Properties: a'), n('task: b'), n('task · Gone: c')], 'task', ['Properties'])
|
|
77
|
+
* by.get('Properties')!.length // 1
|
|
78
|
+
* by.get('')!.length // 2
|
|
79
|
+
* ```
|
|
80
|
+
*/ export let under = (notes, subject, headings)=>groupBy(notes, (b)=>headings.find((h)=>h && str(b, 'doc', 'title').startsWith(`${subject} · ${h}: `)) ?? '');
|
|
81
|
+
/** What a page calls the thing its notes are about: a component, a property
|
|
82
|
+
* or a package by its name, anything else by its id. */ export let about = (io, e)=>e._comp || e._prop || e._namespace ? str(e, 'doc', 'title') || io.id(e) : io.id(e);
|
|
83
|
+
/** The entities `eids` names, asked for so each is called by its name: a
|
|
84
|
+
* hook, answered while the component asking is mounted. */ export let useNamed = (io, eids)=>{
|
|
85
|
+
let ids = [
|
|
86
|
+
...new Set(eids.filter((e)=>!!e))
|
|
87
|
+
].slice(0, 60);
|
|
88
|
+
io.ask(ids.length ? {
|
|
89
|
+
named: `.entity.eid=${ids.join(',')}`
|
|
90
|
+
} : {});
|
|
91
|
+
};
|
|
92
|
+
/** The component sets `rows` are made of, asked for so each row's kind (and
|
|
93
|
+
* its id) is known when it came carrying one component: a hook. */ export let useSets = (io, rows)=>{
|
|
94
|
+
let sets = [
|
|
95
|
+
...new Set(rows.map((b)=>comp(b, 'entity').archetype).filter(named))
|
|
96
|
+
].slice(0, 60);
|
|
97
|
+
io.ask(sets.length ? {
|
|
98
|
+
sets: `.archetype&.entity.eid=${sets.join(',')}&.fields=archetype.tables`
|
|
99
|
+
} : {});
|
|
100
|
+
};
|
|
101
|
+
/** The notes left on `eid`, and their authors named: a hook. A graph that
|
|
102
|
+
* has no tasks holds no notes. */ export let useNotes = (io, eid)=>{
|
|
103
|
+
let got = io.ask(io.vocab.comp('task') ? {
|
|
104
|
+
notes: notesOf(eid)
|
|
105
|
+
} : {});
|
|
106
|
+
let notes = rows(got.notes);
|
|
107
|
+
useNamed(io, notes.map((b)=>str(b, 'created', 'by')));
|
|
108
|
+
return notes;
|
|
109
|
+
};
|
|
110
|
+
// Whether a note's task is seen to: it wears its `completed` or `cancelled`
|
|
111
|
+
// mark.
|
|
112
|
+
let done = (b)=>!!b.completed || !!b.cancelled;
|
|
113
|
+
export let Note = ({ e: b, io })=>{
|
|
114
|
+
let c = comp(b, 'created');
|
|
115
|
+
return /*#__PURE__*/ h(Notes.Item, {
|
|
116
|
+
key: b.entity.eid,
|
|
117
|
+
mod: done(b) && 'done'
|
|
118
|
+
}, /*#__PURE__*/ h(Notes.Text, {}, str(b, 'doc', 'body') || str(b, 'doc', 'title')), /*#__PURE__*/ h(Notes.Who, {}, typeof c.by == 'string' ? io.get(c.by) ? io.show(io.get(c.by), 'Inspect.Reference.Inline') : io.name(c.by) : ''), /*#__PURE__*/ h(Notes.When, {}, /*#__PURE__*/ h('a', {
|
|
119
|
+
href: io.link(b.entity.eid)
|
|
120
|
+
}, c.at ? io.when(String(c.at)) : io.id(b))));
|
|
121
|
+
};
|
|
122
|
+
// The line a note is typed on: what is typed stays in the element until it
|
|
123
|
+
// is sent, and Escape closes it.
|
|
124
|
+
let Line = ({ io, eid, subject, heading })=>{
|
|
125
|
+
let field = useRef(null);
|
|
126
|
+
useLayoutEffect(()=>field.current?.focus?.(), []);
|
|
127
|
+
let close = ()=>io.set(put({
|
|
128
|
+
note: null
|
|
129
|
+
}));
|
|
130
|
+
let send = (ev)=>{
|
|
131
|
+
ev.preventDefault();
|
|
132
|
+
let text = String(field.current?.value ?? '').trim();
|
|
133
|
+
if (!text) return;
|
|
134
|
+
close();
|
|
135
|
+
write(io, key(eid, heading), note(eid, subject, heading, text));
|
|
136
|
+
};
|
|
137
|
+
return /*#__PURE__*/ h(Composer, {
|
|
138
|
+
as: 'form',
|
|
139
|
+
onSubmit: send
|
|
140
|
+
}, /*#__PURE__*/ h(Composer.Field, {
|
|
141
|
+
elRef: field,
|
|
142
|
+
name: 'note',
|
|
143
|
+
'aria-label': `note on ${heading || subject}`,
|
|
144
|
+
placeholder: 'a note: what is wrong here, or could be better…',
|
|
145
|
+
onKeyDown: editKeys({
|
|
146
|
+
cancel: close
|
|
147
|
+
})
|
|
148
|
+
}), /*#__PURE__*/ h(Composer.Send, {
|
|
149
|
+
type: 'submit'
|
|
150
|
+
}, 'note'));
|
|
151
|
+
};
|
|
152
|
+
/** The notes under a heading, and its note line while it is open. */ export let Said = (p)=>{
|
|
153
|
+
let open = me(p.io).note == key(p.eid, p.heading);
|
|
154
|
+
let notes = p.notes ?? [];
|
|
155
|
+
return notes.length || open ? /*#__PURE__*/ h(Notes, {}, notes.map((b)=>p.io.show(b, 'Inspect.Note')), open ? /*#__PURE__*/ h(Line, p) : null) : null;
|
|
156
|
+
};
|
|
157
|
+
/** The press that opens a heading's note line, and closes it: the head's on
|
|
158
|
+
* any page where the controls take input, a part's while its page is
|
|
159
|
+
* edited. */ export let NoteButton = ({ io, eid, heading, subject })=>{
|
|
160
|
+
let at = key(eid, heading);
|
|
161
|
+
let open = me(io).note == at;
|
|
162
|
+
return io.edits && (!heading || open || edited(io, eid)) ? /*#__PURE__*/ h(Button, {
|
|
163
|
+
type: 'button',
|
|
164
|
+
mod: 'quiet',
|
|
165
|
+
'aria-label': `note on ${heading || subject}`,
|
|
166
|
+
'aria-pressed': open,
|
|
167
|
+
onClick: ()=>io.set(put({
|
|
168
|
+
note: open ? null : at
|
|
169
|
+
}))
|
|
170
|
+
}, 'note') : null;
|
|
171
|
+
};
|
|
172
|
+
/** A titled part of a page: its heading and what it holds, with its note
|
|
173
|
+
* press and the notes left under it. */ export let Part = (p)=>{
|
|
174
|
+
let said = refusal(p.io, key(p.eid, p.heading));
|
|
175
|
+
return /*#__PURE__*/ h(Section, {
|
|
176
|
+
'data-section': p.heading
|
|
177
|
+
}, /*#__PURE__*/ h(Section.Title, {}, p.title ?? p.heading, p.count != null ? /*#__PURE__*/ h(Section.Count, {}, count(p.count)) : null, p.note ? /*#__PURE__*/ h(Section.Note, {}, p.note) : null, said ? /*#__PURE__*/ h(Section.Note, {
|
|
178
|
+
mod: 'refused'
|
|
179
|
+
}, said) : null, p.act, /*#__PURE__*/ h(NoteButton, p)), p.sub ? /*#__PURE__*/ h(Section.Sub, {}, p.sub) : null, /*#__PURE__*/ h(Said, {
|
|
180
|
+
...p,
|
|
181
|
+
notes: p.notes?.get(p.heading)
|
|
182
|
+
}), p.children);
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=notes.js.map
|
package/notes.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notes.js","sources":["./notes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;CAiBC,GAED,SAAS,OAAO,wBAA6B;AAC7C,uCAAuC,GAAG,SACxC,iBAAiB,CAAC,EAGlB,eAAe,EACf,MAAM,gBACiB;AACzB,SAAS,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,wBAA6B;AACtE,SAAS,QAAQ,kCAAuC;AAExD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