foldkit-crud 0.1.0 → 0.2.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 +153 -7
- package/dist/index.d.mts +234 -34
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +269 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -57,8 +57,11 @@ pnpm add effect foldkit foldkit-crud foldkit-bundle foldkit-entity foldkit-form
|
|
|
57
57
|
|
|
58
58
|
`EditPostForm` is a `Form.make` result and `EditPostMutation` a Remote mutation
|
|
59
59
|
over the same input struct, as in [`examples/entity`](../../examples/entity).
|
|
60
|
+
`Blog` is that application's Entity domain. The example below is the page
|
|
61
|
+
integration, not a definition of those domain values.
|
|
60
62
|
|
|
61
63
|
```ts
|
|
64
|
+
import { Schema } from 'effect'
|
|
62
65
|
import { Crud } from 'foldkit-crud'
|
|
63
66
|
import { Bundle } from 'foldkit-bundle'
|
|
64
67
|
import { defineMessageUnion } from 'foldkit/message'
|
|
@@ -107,10 +110,25 @@ const subscriptions = Data.subscriptions({ editor: PostEditor.active })
|
|
|
107
110
|
what the form writes is fetched and retained like any Surface's requirement.
|
|
108
111
|
- `after(update)`: wraps `update` so `sync` runs after every Message.
|
|
109
112
|
- `sync`, the Step itself, if you compose `update` another way.
|
|
110
|
-
- `status(model)`,
|
|
113
|
+
- `status(model)`, `saveError(model)` while it is `SaveFailed`, and
|
|
114
|
+
`target(model)`, the id being edited (`null` for a new one or when closed).
|
|
111
115
|
- The save is a Command that needs `RemoteClient`, so the parent scope names it
|
|
112
116
|
with `withServices<RemoteClient>()`.
|
|
113
117
|
|
|
118
|
+
### What starts the work?
|
|
119
|
+
|
|
120
|
+
| Call | What happens |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| `Crud.editor(...)` / `Editor.at(...)` | Build the editor and its parent integration; no request runs. |
|
|
123
|
+
| `Placed.helpers.open(id)` | Return an Update.Step. Apply it inside your parent update to select a row. |
|
|
124
|
+
| `Data.subscriptions({ editor: PostEditor.active })` | Describe the loader; the runtime must install it and provide `RemoteClient`. |
|
|
125
|
+
| `PostEditor.after(update)` | Fill the form after loading and reconcile save status after Messages. |
|
|
126
|
+
| Valid form submission through `onOut` | Return the mutation Command; its result comes back through Remote. |
|
|
127
|
+
|
|
128
|
+
Include the placement's own subscriptions as well if your form uses them.
|
|
129
|
+
Do not interpret `Submitted` as `Saved`: only the returned mutation outcome
|
|
130
|
+
settles the save. The status section below describes what the view should show.
|
|
131
|
+
|
|
114
132
|
### Drawing it
|
|
115
133
|
|
|
116
134
|
The editor wraps the form's Model, so it takes the form's view, lifted:
|
|
@@ -126,7 +144,7 @@ const Slot = Bundle.declare(
|
|
|
126
144
|
)
|
|
127
145
|
|
|
128
146
|
// where the page draws it:
|
|
129
|
-
Placed.view(model, h, { options: pickers(model),
|
|
147
|
+
Placed.view(model, h, { options: pickers(model), words: { submit: 'Save' } })
|
|
130
148
|
```
|
|
131
149
|
|
|
132
150
|
`Crud.editorView` works on any Submodel view of the form that takes view
|
|
@@ -154,7 +172,7 @@ form creates.
|
|
|
154
172
|
| `Closed` | nothing is open |
|
|
155
173
|
| `Loading` | an id is open and its current values have not arrived |
|
|
156
174
|
| `NotFound` | it is gone: the server answered without it, a mutation deleted it, or a live event did. This outranks a save that landed |
|
|
157
|
-
| `LoadFailed` | reading it failed
|
|
175
|
+
| `LoadFailed` | reading it failed, in the request or in decoding what came back. Once the form is filled it stays `Editing`, whatever a later read says |
|
|
158
176
|
| `Editing` | the form is showing, with no save in progress or just settled |
|
|
159
177
|
| `Saving` | this editor's mutation is pending |
|
|
160
178
|
| `Saved` | it was applied |
|
|
@@ -199,16 +217,70 @@ const subscriptions = Data.subscriptions({ authors: AuthorList.active })
|
|
|
199
217
|
```
|
|
200
218
|
|
|
201
219
|
- `Authors.columns` is the selected members in the Selection's order, each with
|
|
202
|
-
its `key`, `member`,
|
|
203
|
-
`title`, else `Form.label` metadata, else the key
|
|
220
|
+
its `key`, `member`, a `label` found the way a form finds one (the schema's
|
|
221
|
+
`title`, else `Form.label` metadata, else the key), and a `display`.
|
|
204
222
|
- `AuthorList.page(model)` is a `RemoteData` of the page: `items` typed by the
|
|
205
223
|
Selection, `hasNext`, `hasPrevious`.
|
|
206
224
|
- `AuthorList.more(model)` is the Command that loads the next page onto this one,
|
|
207
225
|
or `undefined` when there is none. Return it from `update`.
|
|
226
|
+
- `AuthorList.refresh(model)` is the Model with the list asked for again:
|
|
227
|
+
`Data.refresh` over its page and rows. A failed read is not retried on its
|
|
228
|
+
own, so this is what a retry button's Message returns. A placed detail has the
|
|
229
|
+
same `refresh`.
|
|
230
|
+
- `AuthorList.row(id)` is a Projection of one row through the list's Selection,
|
|
231
|
+
whether or not the query finds it now, and `AuthorList.choiceOf(model, id)` is
|
|
232
|
+
that row as a choice once it is read. `Crud.options` uses both for a picker
|
|
233
|
+
that searches.
|
|
208
234
|
- `AuthorList.active` makes the page and its rows a requirement while `input`
|
|
209
235
|
gives a value, so Remote fetches and retains them. Another input is another
|
|
210
236
|
connection.
|
|
211
237
|
|
|
238
|
+
### How a column shows
|
|
239
|
+
|
|
240
|
+
A `Display` is `foldkit-form`'s `Input` from the reading side: how one selected
|
|
241
|
+
member shows, described without a renderer.
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
const Post = Blog.Post.pipe(
|
|
245
|
+
Entity.annotateMembers({
|
|
246
|
+
id: Display.of(Display.hidden()), // read, so a row can be opened by it, and not shown
|
|
247
|
+
cents: Display.of(Display.number(cents => `$${(cents / 100).toFixed(2)}`)),
|
|
248
|
+
}),
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
Display.show(column.display, row[column.key], { yes: 'Live', no: 'Draft' }) // the cell's text
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
| Kind | For |
|
|
255
|
+
| --- | --- |
|
|
256
|
+
| `Text`, `Number` | a value as it is, or through `format` |
|
|
257
|
+
| `Flag` | a boolean, in the words given (`yes` / `no`) |
|
|
258
|
+
| `Hidden` | a member read and not shown |
|
|
259
|
+
| `Ref` | a relation selected with `true`: its id, or ids |
|
|
260
|
+
| `Nested` | a relation read through a Selection: the target's own columns, with `shape` `one`, `many`, or `page` |
|
|
261
|
+
|
|
262
|
+
There is one primitive, as with a form's controls: a `kind`, whether it is
|
|
263
|
+
`shown`, its `data`, and its `text`. The kinds above are made with
|
|
264
|
+
`Display.kind`, and so is yours:
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
const Badge = Display.kind<{ readonly tone: string }>('Badge', {
|
|
268
|
+
text: (_, value) => String(value), // the floor: what it says when nothing draws it specially
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
const Post = Blog.Post.pipe(Entity.annotateMembers({ status: Display.of(Badge.of({ tone: 'soft' })) }))
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
`Badge.is(display)` narrows `display.data`. A drawn view draws it specially once
|
|
275
|
+
given a renderer for `Badge`.
|
|
276
|
+
|
|
277
|
+
It is resolved from the most to the least explicit source: `Display.of`
|
|
278
|
+
metadata on the member, how the relation was selected, then the shape of the
|
|
279
|
+
schema. `Display.show` is the text any view can fall back on; a view that wants
|
|
280
|
+
a link or a badge reads `display` and the value.
|
|
281
|
+
[`foldkit-mixins-crud`](../mixins-crud/README.md) draws a list as a table and a
|
|
282
|
+
detail as a description list from exactly this.
|
|
283
|
+
|
|
212
284
|
### A relation picker's choices
|
|
213
285
|
|
|
214
286
|
A form names a relation's target Entity and leaves listing it to you, because a
|
|
@@ -223,6 +295,28 @@ const pickers = Crud.options(EditPostForm, [AuthorList])
|
|
|
223
295
|
Placed.view(model, h, { options: pickers(model) }) // with foldkit-mixins-form
|
|
224
296
|
```
|
|
225
297
|
|
|
298
|
+
#### When a picker searches
|
|
299
|
+
|
|
300
|
+
```ts
|
|
301
|
+
const AuthorList = Authors.at({
|
|
302
|
+
data: Data,
|
|
303
|
+
// What the picker's search box holds is the form's; here it is the query's input.
|
|
304
|
+
input: model => ({ search: EditPostForm.search(model.editor.form, 'authorId') }),
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
const pickers = Crud.options(EditPostForm, [AuthorList], {
|
|
308
|
+
chosen: model => model.editor.form, // the form's Model, wherever the page keeps it
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
const subscriptions = Data.subscriptions({ authors: AuthorList.active, chosen: pickers.active })
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
A search narrows the list, and what the picker already holds may no longer be
|
|
315
|
+
in it. With `chosen`, those rows stay among the choices, first, and
|
|
316
|
+
`pickers.active` makes them a requirement so Remote reads them and they can be
|
|
317
|
+
named. Without it a `select` would show a post's author as blank the moment a
|
|
318
|
+
search stopped finding them.
|
|
319
|
+
|
|
226
320
|
`pickers(model)` is keyed by the form's keys: `{ authorId: [{ value, label }, …] }`.
|
|
227
321
|
A list is matched to a picker by Entity, so one author list serves `authorId`
|
|
228
322
|
and `editorId` alike. A picker whose target no list is over, or whose list has no `choice`, throws
|
|
@@ -277,11 +371,63 @@ PostDetail.value(model) // RemoteData of the Selection's value
|
|
|
277
371
|
list's `columns` does, and `PostDetail.active` makes the value a requirement
|
|
278
372
|
while an id is shown.
|
|
279
373
|
|
|
374
|
+
## Typed ids
|
|
375
|
+
|
|
376
|
+
When the Entity's `id` is branded, the ids here are too. An editor's
|
|
377
|
+
`helpers.open(id)` takes the `IdOf` of its form's Entity, and `target(model)`
|
|
378
|
+
reads the id being edited as that type. A remover whose mutation's input is just the id names the key, `id: 'id'`, and is
|
|
379
|
+
asked about that key's type; with a fuller input, annotate the function:
|
|
380
|
+
`input: (id: PostId) => ({ id, reason: 'spam' })`. A list's rows
|
|
381
|
+
are its Selection's own value, so `row.id` is a `PostId` when the Selection
|
|
382
|
+
reads `id`.
|
|
383
|
+
|
|
384
|
+
## Sorting a list
|
|
385
|
+
|
|
386
|
+
How a list is sorted is your state and the query's input. `Sort` writes that
|
|
387
|
+
state down once, so the Model, the header clicks, and the server agree:
|
|
388
|
+
|
|
389
|
+
```ts
|
|
390
|
+
const PostSort = Sort.make(['title', 'created']) // the orders offered, by name
|
|
391
|
+
|
|
392
|
+
const PostsQuery = Query.make('Posts', {
|
|
393
|
+
Input: { sort: PostSort.Schema },
|
|
394
|
+
Result: Query.connection(Blog.Post),
|
|
395
|
+
})
|
|
396
|
+
// Model: `postSort: PostSort.Schema`, starting at `PostSort.none`
|
|
397
|
+
// update: `SortedPosts` sets `postSort` to the state the Message carries
|
|
398
|
+
|
|
399
|
+
PostSort.toggle(model.postSort, 'title') // asc, then desc, then the server's own order
|
|
400
|
+
PostSort.inputs(model.postSort, sort => Message.SortedPosts({ sort })) // a drawn table's `sort`
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
`Sort` holds nothing. A name is an order the server offers, never a column; on
|
|
404
|
+
the server, `foldkit-remote-drizzle`'s `sortTerms(sort, { title: posts.title })`
|
|
405
|
+
says what each name means and ignores any other.
|
|
406
|
+
|
|
407
|
+
## Wiring a page
|
|
408
|
+
|
|
409
|
+
Every placed piece has an `active`: what it requires of Remote while it is on
|
|
410
|
+
screen. A piece whose `active` is not wired never loads, and says nothing.
|
|
411
|
+
`Crud.actives` gathers them from the pieces themselves:
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
Data.wiring(Crud.actives({ posts: Posts, authors: Authors, editor: PostEditor, pickers }))
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
It takes a placed editor, list, or detail, and the pickers from `Crud.options`,
|
|
418
|
+
and gives `{ posts: Posts.active, ... }`, for `Data.wiring` or
|
|
419
|
+
`Data.subscriptions`.
|
|
420
|
+
|
|
280
421
|
## Limits
|
|
281
422
|
|
|
282
423
|
- A list has no sorting, filtering, or selection state of its own: those are the
|
|
283
|
-
query's input, which your Model holds.
|
|
284
|
-
|
|
424
|
+
query's input, which your Model holds. Change the input and the list is another
|
|
425
|
+
connection, fetched because it is on screen; `foldkit-remote-drizzle`'s `query`
|
|
426
|
+
reads the input in `where` and `orderBy`. [`examples/entity`](../../examples/entity)
|
|
427
|
+
searches and sorts its post list this way.
|
|
428
|
+
- Headless. Draw a list or a detail with
|
|
429
|
+
[`foldkit-mixins-crud`](../mixins-crud/README.md), or from `columns` and
|
|
430
|
+
`Display.show`. Draw the editor with `Crud.editorView` over a
|
|
285
431
|
[`foldkit-mixins-form`](../mixins-form/README.md) view, or from
|
|
286
432
|
`EditPostForm.controls`. [`examples/entity`](../../examples/entity) draws a
|
|
287
433
|
list and an editor, and runs in a browser.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,145 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { Bundle } from "foldkit-bundle";
|
|
3
|
-
import { AnyEntity, EntityInput, EntityMember, Selection } from "foldkit-entity";
|
|
3
|
+
import { AnyEntity, EntityInput, EntityMember, IdOf, Selection, SelectionPage } from "foldkit-entity";
|
|
4
4
|
import { FormControl, Submitted } from "foldkit-form";
|
|
5
|
+
import { Metadata } from "foldkit-metadata";
|
|
6
|
+
import { ModelRef, Projection } from "foldkit-surface";
|
|
5
7
|
import * as Submodel from "foldkit/submodel";
|
|
6
8
|
import { MutationDescriptor, MutationStatus, Page, QueryDescriptor, RemoteClient, RemoteData, RemoteError, RemoteMessage } from "foldkit-remote";
|
|
7
|
-
import { ModelRef, Projection } from "foldkit-surface";
|
|
8
9
|
import { Command } from "foldkit/command";
|
|
9
10
|
import * as Update from "foldkit/update";
|
|
11
|
+
//#region src/display.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* How one selected member shows: the primitive every kind of Display is a value
|
|
14
|
+
* of. `Display.text()` and `Display.flag()` are values of it, made by
|
|
15
|
+
* `Display.kind`, which is what an application calls for a badge or a relative
|
|
16
|
+
* date. The kinds here are a collection, not a special case.
|
|
17
|
+
*/
|
|
18
|
+
export interface Display<Data = unknown> {
|
|
19
|
+
/** The name a renderer is found by. */
|
|
20
|
+
readonly kind: string;
|
|
21
|
+
/** Whether a view draws it. A member read and not shown, usually the id, is `false`. */
|
|
22
|
+
readonly shown: boolean;
|
|
23
|
+
/** What this kind needs: a format, a relation's target. */
|
|
24
|
+
readonly data: Data;
|
|
25
|
+
/**
|
|
26
|
+
* The value as text: what a cell says when nothing draws it specially. It is
|
|
27
|
+
* never given `null` or `undefined`; `Display.show` says `nothing` for those.
|
|
28
|
+
*/
|
|
29
|
+
readonly text: (value: unknown, words: DisplayWords) => string;
|
|
30
|
+
}
|
|
31
|
+
/** A kind of Display: how its values are made, and how one is told from another. */
|
|
32
|
+
interface DisplayKind<Data> {
|
|
33
|
+
readonly kind: string;
|
|
34
|
+
readonly of: (data: Data) => Display<Data>;
|
|
35
|
+
readonly is: (display: Display) => display is Display<Data>;
|
|
36
|
+
}
|
|
37
|
+
/** A selected member with its words and its Display. A list's column, a detail's line. */
|
|
38
|
+
interface DisplayColumn<Key extends string = string> {
|
|
39
|
+
readonly key: Key;
|
|
40
|
+
readonly label: string;
|
|
41
|
+
readonly member: EntityMember;
|
|
42
|
+
readonly display: Display;
|
|
43
|
+
}
|
|
44
|
+
/** The words a Display needs that are not the value's own. */
|
|
45
|
+
interface DisplayWords {
|
|
46
|
+
/** Default `yes`. */
|
|
47
|
+
readonly yes?: string;
|
|
48
|
+
/** Default `no`. */
|
|
49
|
+
readonly no?: string;
|
|
50
|
+
/** What stands for nothing: `null`, `undefined`, an empty list. Default the empty string. */
|
|
51
|
+
readonly nothing?: string;
|
|
52
|
+
/** Between the items of a list, and between the members of a nested value. Default `, `. */
|
|
53
|
+
readonly separator?: string;
|
|
54
|
+
}
|
|
55
|
+
export declare const Display: {
|
|
56
|
+
/**
|
|
57
|
+
* A kind of Display. `Display.kind<{ tone: string }>('Badge', { text: (_, value) => String(value) })`
|
|
58
|
+
* gives `.of(data)` to make one and `.is(display)` to tell one, exactly as the
|
|
59
|
+
* kinds below were made. `text` is the floor; a view draws it specially once
|
|
60
|
+
* it is given a renderer for `Badge`.
|
|
61
|
+
*/
|
|
62
|
+
kind: <Data = Record<string, never>>(name: string, spec: {
|
|
63
|
+
readonly shown?: boolean;
|
|
64
|
+
readonly text: (data: Data, value: unknown, words: DisplayWords) => string;
|
|
65
|
+
}) => DisplayKind<Data>;
|
|
66
|
+
Text: DisplayKind<{
|
|
67
|
+
readonly format?: ((value: unknown) => string) | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
Number: DisplayKind<{
|
|
70
|
+
readonly format?: ((value: number) => string) | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
Flag: DisplayKind<Record<string, never>>;
|
|
73
|
+
Hidden: DisplayKind<Record<string, never>>;
|
|
74
|
+
Ref: DisplayKind<{
|
|
75
|
+
readonly target: AnyEntity;
|
|
76
|
+
readonly many: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
Nested: DisplayKind<{
|
|
79
|
+
readonly target: AnyEntity;
|
|
80
|
+
readonly shape: "one" | "many" | "page";
|
|
81
|
+
readonly columns: ReadonlyArray<DisplayColumn>;
|
|
82
|
+
}>;
|
|
83
|
+
text: (format?: (value: unknown) => string) => Display;
|
|
84
|
+
number: (format?: (value: number) => string) => Display;
|
|
85
|
+
flag: () => Display;
|
|
86
|
+
/** Read, so a row can be opened or keyed by it, and not shown: usually the id. */
|
|
87
|
+
hidden: () => Display;
|
|
88
|
+
/**
|
|
89
|
+
* Entity metadata: how a member shows wherever it is listed, e.g.
|
|
90
|
+
* `Entity.annotateMembers({ price: Display.of(Display.number(cents => ...)) })`.
|
|
91
|
+
*/
|
|
92
|
+
of: (display: Display) => Metadata;
|
|
93
|
+
/**
|
|
94
|
+
* The Display of one selected member, from the most to the least explicit
|
|
95
|
+
* source: the member's `Display.of` metadata, how the relation was selected,
|
|
96
|
+
* then the shape of its schema. `nested` is the columns of a nested Selection,
|
|
97
|
+
* with `shape` saying how many the relation yields.
|
|
98
|
+
*/
|
|
99
|
+
resolve: (member: EntityMember, nested?: {
|
|
100
|
+
readonly shape: "one" | "many" | "page";
|
|
101
|
+
readonly columns: ReadonlyArray<DisplayColumn>;
|
|
102
|
+
}) => Display;
|
|
103
|
+
/**
|
|
104
|
+
* A value as the text its Display calls for: what a cell says when nothing
|
|
105
|
+
* draws it specially. A view that wants a link or a badge reads the Display
|
|
106
|
+
* and the value itself; this is the floor every view can stand on.
|
|
107
|
+
*/
|
|
108
|
+
show: (display: Display, value: unknown, words?: DisplayWords) => string;
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/sort.d.ts
|
|
112
|
+
/** How a list is sorted: by which of its orders, which way; `null` for the server's own order. */
|
|
113
|
+
type SortState<Column extends string> = {
|
|
114
|
+
readonly by: Column;
|
|
115
|
+
readonly direction: 'asc' | 'desc';
|
|
116
|
+
} | null;
|
|
117
|
+
/** How one column is sorted now, and the Message a click on its header sends. */
|
|
118
|
+
interface SortedColumn<Message> {
|
|
119
|
+
readonly direction?: 'asc' | 'desc' | undefined;
|
|
120
|
+
readonly message: Message;
|
|
121
|
+
}
|
|
122
|
+
export declare const Sort: {
|
|
123
|
+
/**
|
|
124
|
+
* The orders a list offers, by name. A name is an order the server knows, not
|
|
125
|
+
* a column: which columns may sort, and what `title` means in SQL, stay the
|
|
126
|
+
* server's to decide.
|
|
127
|
+
*/
|
|
128
|
+
make: <const Columns extends readonly [string, ...string[]]>(columns: Columns) => {
|
|
129
|
+
columns: Columns;
|
|
130
|
+
/** For the Model field, and for the query's input. */
|
|
131
|
+
Schema: Schema.Codec<SortState<Columns[number]>, SortState<Columns[number]>>;
|
|
132
|
+
/** The server's own order. */
|
|
133
|
+
none: SortState<Columns[number]>;
|
|
134
|
+
toggle: (current: SortState<Columns[number]>, column: Columns[number]) => SortState<Columns[number]>;
|
|
135
|
+
/**
|
|
136
|
+
* What a drawn table takes as `sort`: every order with how it is sorted now
|
|
137
|
+
* and the Message a click sends, made from the state the click leads to.
|
|
138
|
+
*/
|
|
139
|
+
inputs: <Message>(current: SortState<Columns[number]>, message: (next: SortState<Columns[number]>) => Message) => { readonly [K in Columns[number]]: SortedColumn<Message>; };
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
//#endregion
|
|
10
143
|
//#region src/index.d.ts
|
|
11
144
|
/** The parts of a `Form.make` result an editor wraps. */
|
|
12
145
|
export interface EditableForm<Name extends string, FormModel, FormMessage, Value, E extends AnyEntity, Fields extends Schema.Struct.Fields, Members, R = never> {
|
|
@@ -66,6 +199,7 @@ export interface DomainLike<Root> {
|
|
|
66
199
|
readonly query: string;
|
|
67
200
|
} | undefined;
|
|
68
201
|
fetch(ref: any): Command<RemoteMessage, never, RemoteClient>;
|
|
202
|
+
refresh(model: Root, target: any): Root;
|
|
69
203
|
mutation(model: Root, requestId: string): MutationStatus;
|
|
70
204
|
readonly contract: {
|
|
71
205
|
readonly owner?: object | undefined;
|
|
@@ -77,13 +211,11 @@ export interface Choice {
|
|
|
77
211
|
readonly value: string;
|
|
78
212
|
readonly label: string;
|
|
79
213
|
}
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
readonly member: EntityMember;
|
|
86
|
-
}
|
|
214
|
+
/**
|
|
215
|
+
* One column of a list, or one line of a detail: a member the Selection reads,
|
|
216
|
+
* with its words and its `Display`.
|
|
217
|
+
*/
|
|
218
|
+
export type ListColumn<Key extends string = string> = DisplayColumn<Key>;
|
|
87
219
|
export declare const Crud: {
|
|
88
220
|
/**
|
|
89
221
|
* One Entity read through a Selection, for a page that shows it. Like a list
|
|
@@ -97,6 +229,8 @@ export declare const Crud: {
|
|
|
97
229
|
name: Name;
|
|
98
230
|
/** The selected members in the Selection's order, each with its label. */
|
|
99
231
|
fields: readonly ListColumn<keyof Members & string>[];
|
|
232
|
+
/** Type-only: the value shown, for a view to be typed by. Never read. */
|
|
233
|
+
Value: Row;
|
|
100
234
|
/** The detail where it lives: `id` is the one shown, or `undefined` while none is. */
|
|
101
235
|
at: <Root>(where: {
|
|
102
236
|
readonly data: DomainLike<Root>;
|
|
@@ -109,15 +243,29 @@ export declare const Crud: {
|
|
|
109
243
|
projectionOf: (root: Root) => Projection<Root, RemoteData<any>> | undefined;
|
|
110
244
|
};
|
|
111
245
|
value: (root: Root) => RemoteData<Row>;
|
|
246
|
+
/**
|
|
247
|
+
* Asks for the value again: `Data.refresh` over this detail, for a retry
|
|
248
|
+
* button. A failed read is not retried on its own. Unchanged while no id
|
|
249
|
+
* is shown.
|
|
250
|
+
*/
|
|
251
|
+
refresh: (root: Root) => Root;
|
|
112
252
|
};
|
|
113
253
|
};
|
|
114
254
|
/**
|
|
115
255
|
* Deleting through one mutation, with a yes in between: asked, confirmed,
|
|
116
|
-
* deleted. What the mutation's input is for an id is `input`'s to say
|
|
256
|
+
* deleted. What the mutation's input is for an id is `input`'s to say, and the
|
|
257
|
+
* id it names there (`(id: PostId) => ...`) is the id `ask` takes.
|
|
117
258
|
*/
|
|
118
|
-
remover: <const Name extends string, Input>(name: Name, config: {
|
|
259
|
+
remover: <const Name extends string, Input, Id extends string = string, const Key extends keyof Input = never>(name: Name, config: {
|
|
119
260
|
readonly mutation: MutationDescriptor<string, Input, any>;
|
|
120
|
-
readonly input: (id:
|
|
261
|
+
readonly input: (id: Id) => Input;
|
|
262
|
+
} | {
|
|
263
|
+
readonly mutation: MutationDescriptor<string, Input, any>;
|
|
264
|
+
/**
|
|
265
|
+
* The key of the mutation's input that holds the id, when that is all the
|
|
266
|
+
* input is: `id: 'id'` for `{ id }`. The id's type is that key's.
|
|
267
|
+
*/
|
|
268
|
+
readonly id: Key & (Input extends Readonly<Record<Key, string>> ? Key : never);
|
|
121
269
|
}) => {
|
|
122
270
|
bundle: Bundle.Bundle<Name, void, RemoverModel, {
|
|
123
271
|
readonly _tag: "Confirmed";
|
|
@@ -125,9 +273,9 @@ export declare const Crud: {
|
|
|
125
273
|
readonly _tag: "Cancelled";
|
|
126
274
|
}, ConfirmedRemoval, never, never, void, {}, {
|
|
127
275
|
/** Asks whether to delete `id`. Nothing is deleted until `Confirmed`. */
|
|
128
|
-
ask: (_: RemoverModel, id: string) => {
|
|
276
|
+
ask: (_: RemoverModel, id: [Key] extends [never] ? Id : Input[Key] & string) => {
|
|
129
277
|
model: {
|
|
130
|
-
target: string;
|
|
278
|
+
target: [Key] extends [never] ? Id : Input[Key] & string;
|
|
131
279
|
requestId: null;
|
|
132
280
|
};
|
|
133
281
|
};
|
|
@@ -147,7 +295,7 @@ export declare const Crud: {
|
|
|
147
295
|
/** For the placement: a yes becomes the mutation, and its request is remembered. */
|
|
148
296
|
onOut: (confirmed: ConfirmedRemoval) => Step<Root>;
|
|
149
297
|
/** The id being asked about or deleted, for the words of a confirmation. */
|
|
150
|
-
target: (root: Root) => string | null;
|
|
298
|
+
target: (root: Root) => ([Key] extends [never] ? Id : Input[Key] & string) | null;
|
|
151
299
|
status: (root: Root) => RemoverStatus;
|
|
152
300
|
/** Why the last delete failed, while `status` is `DeleteFailed`. */
|
|
153
301
|
error: (root: Root) => RemoteError | undefined;
|
|
@@ -157,11 +305,9 @@ export declare const Crud: {
|
|
|
157
305
|
* A list over one query: which rows to show is the query's, what to show of
|
|
158
306
|
* each is the Selection's. The pages live in Remote; the list holds no state.
|
|
159
307
|
*/
|
|
160
|
-
list: <const Name extends string, EntityName extends string, Members,
|
|
308
|
+
list: <const Name extends string, EntityName extends string, Members, S extends Schema.Constraint, Input>(name: Name, config: {
|
|
161
309
|
readonly query: QueryDescriptor<string, Input, any>;
|
|
162
|
-
readonly selection: Selection<EntityName, Members,
|
|
163
|
-
readonly Type: Row;
|
|
164
|
-
}>;
|
|
310
|
+
readonly selection: Selection<EntityName, Members, S>;
|
|
165
311
|
/** How many rows a page holds. Default 25. */
|
|
166
312
|
readonly pageSize?: number;
|
|
167
313
|
/**
|
|
@@ -169,13 +315,15 @@ export declare const Crud: {
|
|
|
169
315
|
* that identify it to a person. Give it to a list that feeds pickers.
|
|
170
316
|
*/
|
|
171
317
|
readonly choice?: {
|
|
172
|
-
readonly value: (row:
|
|
173
|
-
readonly label: (row:
|
|
318
|
+
readonly value: (row: S["Type"]) => string;
|
|
319
|
+
readonly label: (row: S["Type"]) => string;
|
|
174
320
|
};
|
|
175
321
|
}) => {
|
|
176
322
|
name: Name;
|
|
177
323
|
/** The selected members in the Selection's order, each with its label. */
|
|
178
324
|
columns: readonly ListColumn<keyof Members & string>[];
|
|
325
|
+
/** Type-only: a row, for a view to be typed by. Never read. */
|
|
326
|
+
Row: S["Type"];
|
|
179
327
|
/**
|
|
180
328
|
* The list where it lives. `input` is the query's input as the Model has
|
|
181
329
|
* it (filters, a search term), or `undefined` while the list is not shown.
|
|
@@ -190,10 +338,23 @@ export declare const Crud: {
|
|
|
190
338
|
owner: object;
|
|
191
339
|
projectionOf: (root: Root) => Projection<Root, RemoteData<Page<any>>> | undefined;
|
|
192
340
|
};
|
|
193
|
-
page: (root: Root) => RemoteData<Page<
|
|
341
|
+
page: (root: Root) => RemoteData<Page<S["Type"]>>;
|
|
194
342
|
/** The Command that loads the next page onto this one, or `undefined` when there is none. */
|
|
195
343
|
more: (root: Root) => Command<RemoteMessage, never, RemoteClient> | undefined;
|
|
344
|
+
/**
|
|
345
|
+
* Asks for the list again: `Data.refresh` over its page and rows, for a
|
|
346
|
+
* retry button. A failed read is not retried on its own. Unchanged while
|
|
347
|
+
* the list is not shown.
|
|
348
|
+
*/
|
|
349
|
+
refresh: (root: Root) => Root;
|
|
196
350
|
name: Name;
|
|
351
|
+
/** Whose requirement the list is, for anything that requires beside it. */
|
|
352
|
+
owner: object;
|
|
353
|
+
/**
|
|
354
|
+
* One of the list's Entity through the list's Selection, by id, whether or
|
|
355
|
+
* not the query finds it now: what a picker reads to name what is chosen.
|
|
356
|
+
*/
|
|
357
|
+
row: (id: string) => Projection<Root, RemoteData<any>>;
|
|
197
358
|
/** The Entity the rows are of, which is how a picker finds the list for its target. */
|
|
198
359
|
entity: AnyEntity;
|
|
199
360
|
/** Whether the list was given a `choice`, so its rows can be a picker's choices. */
|
|
@@ -204,6 +365,8 @@ export declare const Crud: {
|
|
|
204
365
|
* server authorizes; nothing is read because a relation exists.
|
|
205
366
|
*/
|
|
206
367
|
choices: (root: Root) => ReadonlyArray<Choice>;
|
|
368
|
+
/** That row as a choice, once it is read. */
|
|
369
|
+
choiceOf: (root: Root, id: string) => Choice | undefined;
|
|
207
370
|
};
|
|
208
371
|
};
|
|
209
372
|
/**
|
|
@@ -220,15 +383,49 @@ export declare const Crud: {
|
|
|
220
383
|
* The choices of every relation picker in a form, from the lists of their
|
|
221
384
|
* targets: `foldkit-mixins-form`'s `options`, keyed by the form's keys. A
|
|
222
385
|
* picker whose target no list here is over is a wiring mistake, reported now.
|
|
386
|
+
*
|
|
387
|
+
* With `chosen`, the form's Model as the page has it, what a picker already
|
|
388
|
+
* holds stays among its choices when the list no longer finds it (a search
|
|
389
|
+
* narrowed it, or it is on a later page), and `active` requires those rows so
|
|
390
|
+
* their words are there. Give `chosen` to any form whose pickers search.
|
|
223
391
|
*/
|
|
224
|
-
options: <Key extends string, Root>(form: {
|
|
392
|
+
options: <Key extends string, Root, FormModel = never>(form: {
|
|
225
393
|
readonly controls: ReadonlyArray<FormControl<Key>>;
|
|
394
|
+
readonly field?: (model: FormModel, key: never) => {
|
|
395
|
+
readonly value: unknown;
|
|
396
|
+
};
|
|
226
397
|
}, lists: ReadonlyArray<{
|
|
227
398
|
readonly name: string;
|
|
228
399
|
readonly entity: AnyEntity;
|
|
229
400
|
readonly offersChoices: boolean;
|
|
401
|
+
readonly owner: object;
|
|
230
402
|
readonly choices: (root: Root) => ReadonlyArray<Choice>;
|
|
231
|
-
|
|
403
|
+
readonly row: (id: string) => Projection<Root, RemoteData<any>>;
|
|
404
|
+
readonly choiceOf: (root: Root, id: string) => Choice | undefined;
|
|
405
|
+
}>, options?: {
|
|
406
|
+
readonly chosen?: (root: Root) => FormModel | undefined;
|
|
407
|
+
}) => ((root: Root) => { readonly [K in Key]?: ReadonlyArray<Choice>; }) & {
|
|
408
|
+
/** For `Data.subscriptions`: what the pickers hold is read, so it can be named. */
|
|
409
|
+
active: {
|
|
410
|
+
name: string;
|
|
411
|
+
owner: object;
|
|
412
|
+
projectionOf: (root: Root) => Projection<Root, {
|
|
413
|
+
readonly [x: string]: RemoteData<any>;
|
|
414
|
+
}> | undefined;
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
/**
|
|
418
|
+
* What the pieces on a page require of Remote, by the names given: a placed
|
|
419
|
+
* editor, list, or detail, or the pickers from `Crud.options`. It is each one's
|
|
420
|
+
* `active`, gathered, so handing the pieces over is enough and none is left out:
|
|
421
|
+
*
|
|
422
|
+
* ```ts
|
|
423
|
+
* Data.wiring(Crud.actives({ posts: Posts, authors: Authors, editor: PostEditor, pickers }))
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
actives: <const Pieces extends Readonly<Record<string, {
|
|
427
|
+
readonly active: unknown;
|
|
428
|
+
}>>>(pieces: Pieces) => { readonly [K in keyof Pieces]: Pieces[K]["active"]; };
|
|
232
429
|
/**
|
|
233
430
|
* An editor for one form and the mutation its value feeds. The form's value
|
|
234
431
|
* must be the mutation's input, which is what declaring the input once and
|
|
@@ -242,10 +439,10 @@ export declare const Crud: {
|
|
|
242
439
|
}) => {
|
|
243
440
|
bundle: Bundle.Bundle<Name, void, EditorModel<FormModel>, FormMessage, Submitted<Value>, R, never, void, {}, {
|
|
244
441
|
/** Edits `id`: the form is emptied, and filled once the current values arrive. */
|
|
245
|
-
open: (_: EditorModel<FormModel>, id:
|
|
442
|
+
open: (_: EditorModel<FormModel>, id: IdOf<E>) => {
|
|
246
443
|
model: {
|
|
247
444
|
mode: "edit";
|
|
248
|
-
target:
|
|
445
|
+
target: IdOf<E>;
|
|
249
446
|
form: FormModel;
|
|
250
447
|
filled: boolean;
|
|
251
448
|
requestId: string | null;
|
|
@@ -266,20 +463,20 @@ export declare const Crud: {
|
|
|
266
463
|
};
|
|
267
464
|
}>;
|
|
268
465
|
/** What the editor loads before it shows the form: every member the form writes. */
|
|
269
|
-
selection: Selection<E["name"], import("foldkit-entity").WrittenSpec<Members>, Schema.Struct<{ readonly [K in keyof import("foldkit-entity").WrittenSpec<Members> & keyof E["members"]]: E["members"][K] extends (infer T) ? T extends E["members"][K] ? T extends import("foldkit-entity").EntityField<any, any, infer S extends Schema.Constraint> | import("foldkit-entity").EntityDerived<any, any, infer S extends Schema.Constraint> ? S : T extends import("foldkit-entity").EntityRelation<any, any, infer Target extends AnyEntity, infer C extends import("foldkit-entity").Cardinality, infer Optional extends boolean> ? import("foldkit-entity").WrittenSpec<Members>[K] extends (infer T_1) ? T_1 extends import("foldkit-entity").WrittenSpec<Members>[K] ? T_1 extends
|
|
466
|
+
selection: Selection<E["name"], import("foldkit-entity").WrittenSpec<Members>, Schema.Struct<{ readonly [K in keyof import("foldkit-entity").WrittenSpec<Members> & keyof E["members"]]: E["members"][K] extends (infer T) ? T extends E["members"][K] ? T extends import("foldkit-entity").EntityField<any, any, infer S extends Schema.Constraint> | import("foldkit-entity").EntityDerived<any, any, infer S extends Schema.Constraint> ? S : T extends import("foldkit-entity").EntityRelation<any, any, infer Target extends AnyEntity, infer C extends import("foldkit-entity").Cardinality, infer Optional extends boolean> ? import("foldkit-entity").WrittenSpec<Members>[K] extends (infer T_1) ? T_1 extends import("foldkit-entity").WrittenSpec<Members>[K] ? T_1 extends SelectionPage<any, infer S_1 extends Schema.Constraint> ? Schema.Struct<{
|
|
270
467
|
readonly items: Schema.$Array<S_1>;
|
|
271
468
|
readonly hasNext: Schema.Boolean;
|
|
272
469
|
readonly hasPrevious: Schema.Boolean;
|
|
273
|
-
}> : C extends "many" ? Schema.$Array<T_1 extends Selection<any, any, infer S_2 extends Schema.Constraint> ? S_2 : Schema.Struct<{
|
|
470
|
+
}> : C extends "many" ? Schema.$Array<T_1 extends Selection<any, any, infer S_2 extends Schema.Constraint, string> ? S_2 : Schema.Struct<{
|
|
274
471
|
readonly entity: Schema.Literal<Target["name"]>;
|
|
275
|
-
readonly id:
|
|
276
|
-
}>> : Optional extends true ? Schema.NullOr<T_1 extends Selection<any, any, infer S_2 extends Schema.Constraint> ? S_2 : Schema.Struct<{
|
|
472
|
+
readonly id: import("foldkit-entity").IdSchemaOf<Target>;
|
|
473
|
+
}>> : Optional extends true ? Schema.NullOr<T_1 extends Selection<any, any, infer S_2 extends Schema.Constraint, string> ? S_2 : Schema.Struct<{
|
|
277
474
|
readonly entity: Schema.Literal<Target["name"]>;
|
|
278
|
-
readonly id:
|
|
279
|
-
}>> : T_1 extends Selection<any, any, infer S_2 extends Schema.Constraint> ? S_2 : Schema.Struct<{
|
|
475
|
+
readonly id: import("foldkit-entity").IdSchemaOf<Target>;
|
|
476
|
+
}>> : T_1 extends Selection<any, any, infer S_2 extends Schema.Constraint, string> ? S_2 : Schema.Struct<{
|
|
280
477
|
readonly entity: Schema.Literal<Target["name"]>;
|
|
281
|
-
readonly id:
|
|
282
|
-
}> : never : never : never : never : never; }>>;
|
|
478
|
+
readonly id: import("foldkit-entity").IdSchemaOf<Target>;
|
|
479
|
+
}> : never : never : never : never : never; }>, IdOf<E>>;
|
|
283
480
|
/**
|
|
284
481
|
* The editor where it lives: `model` is its slice of the parent Model (the
|
|
285
482
|
* field it was declared at), and `data` the Remote domain that registers the
|
|
@@ -310,9 +507,12 @@ export declare const Crud: {
|
|
|
310
507
|
}>(update: (model: Root, message: Message) => Result) => (model: Root, message: Message) => Result;
|
|
311
508
|
/** Why the last save failed, while `status` is `SaveFailed`. */
|
|
312
509
|
saveError: (root: Root) => RemoteError | undefined;
|
|
510
|
+
/** The id being edited, typed as the Entity's own; `null` for a new one or a closed editor. */
|
|
511
|
+
target: (root: Root) => IdOf<E> | null;
|
|
313
512
|
status: (root: Root) => EditorStatus;
|
|
314
513
|
};
|
|
315
514
|
};
|
|
316
515
|
};
|
|
317
516
|
//#endregion
|
|
517
|
+
export type { DisplayColumn, DisplayKind, DisplayWords, SortState, SortedColumn };
|
|
318
518
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/display.ts","../src/sort.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;iBAgBiB,QAAQ;;WAEd;;WAEA;;WAEA,MAAM;;;;;WAKN,OAAO,gBAAgB,OAAO;;;UAIxB,YAAY;WAClB;WACA,KAAK,MAAM,SAAS,QAAQ;WAC5B,KAAK,SAAS,YAAY,WAAW,QAAQ;;;UAIvC,cAAc;WACpB,KAAK;WACL;WACA,QAAQ;WACR,SAAS;;;UAIH;;WAEN;;WAEA;;WAEA;;WAEA;;qBAsGE;;;;;;;EA3EC,OAAA,OAAI,uBAAA,cACJ;aAED;aACA,OAAO,MAAM,MAAM,gBAAgB,OAAO;QAEpD,YAAY;;aAeuB,WAAE;;;aAGC,WAAE;;;;;aASP,QAAA;aAA0B;;;aAa3C,QAAA;aACD;aACE,SAAA,cAAc;;EA4ChB,OAAA,UAAC,8BAA4B;EAC3B,SAAA,UAAC,6BAA2B;EACpC,YAAA;;EAEE,cAAA;;;;;EAME,KAAA,SAAA,YAAO;;;;;;;EASX,UAAA,QAAA,cAAY;aAET;aACA,SAAS,cAAc;QAEjC;;;;;;EAlGkB,OAAA,SAAA,SAAO,gBAAgB,QAAS;;;;;KC1F3C,UAAU;WACX,IAAI;WACJ;;;UAIM,aAAa;WACnB;WACA,SAAS;;qBAGP;;;;;;EAME,aAAA,gDAA8C,SAAW;;;IAkBlD,QAAA,OAAO,MAAK,UAAA,kBAAA,UAAA;;;;;;;;IAQnB,SAAA,SAAO,SAAA,UAAA,kBAAA,UAEJ,MAAI,UAAA,qBAAY,wBACb,KAAC,kBAAa,aAAa;;;;;;iBCb/B,aACf,qBACA,WACA,aACA,OACA,UAAU,WACV,eAAe,OAAO,OAAO,QAC7B,SACA;WAES;aACE,MAAM;aACN,OAAO,OAAO,MAAM;aACpB,SAAS,OAA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WAAA;;;;;;;;;;;;;;EAqBf,gBAAA,eAAe,SAAS;aAA0B;OAAmB,QAC3E,uBACK,WAAW,SAAS,OAAO;;;;;;EAWlC,eAAA,qBACN,yBACA,WACA;aAA+B;KAC/B,OACA,UAAU,WACV,eAAe,OAAO,OAAO,QAC7B,SACA,WAAC,MAEK,MAAI;aAEC,MAAM,aAAa,UAAU,WAAW,aAAa,OAAO,GAAG,QAAQ,SAAS;aAChF,UAAU,2BAA2B;;;;MAwCvB,OAAA,GAAA,YAAA,YAAA,IAAA,KAAK;;;;;UArkBf;UACG;;;;;;;;;UAFH;UAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;IAylBX,KAAA,MAAI;eACE,MAAM,WAAW;eACjB,OAAO,SAAS,MAAI,YAAA;;;MAkCb,QAAA,WAAA,UAAU,WAAS,KAAK;;;;;;;;;;;;;;;MA8BnC,QAAA,SAAS;iBAA0B,OAAO;SAAM,SACtC,OAAO,MAAM,SAAS,YAAY,YAE5C,OAAO,MAAM,SAAS,YAAU;;MAMjB,YAAA,MAAA,SAAO;;MAMV,SAAA,MAAA,SAAO,KAAK;MACZ,SAAA,MAAA,SAAO"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,159 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { Bundle } from "foldkit-bundle";
|
|
3
|
-
import { Entity } from "foldkit-entity";
|
|
4
|
-
import { Form } from "foldkit-form";
|
|
3
|
+
import { Entity, SelectionPageTypeId } from "foldkit-entity";
|
|
4
|
+
import { Form, Input } from "foldkit-form";
|
|
5
|
+
import { Metadata } from "foldkit-metadata";
|
|
6
|
+
import { Projection } from "foldkit-surface";
|
|
5
7
|
import { defineMessageUnion } from "foldkit/message";
|
|
6
8
|
import * as Submodel from "foldkit/submodel";
|
|
9
|
+
//#region src/display.ts
|
|
10
|
+
/**
|
|
11
|
+
* Displays: how one selected member shows in a list or a detail, described
|
|
12
|
+
* without a renderer. It is `foldkit-form`'s `Input` from the reading side: the
|
|
13
|
+
* member says what it is, a Display says how it reads, and which DOM draws it is
|
|
14
|
+
* the application's.
|
|
15
|
+
*/
|
|
16
|
+
const key = Metadata.key("foldkit-crud/display", {
|
|
17
|
+
merge: (displays) => displays.slice(-1),
|
|
18
|
+
summarize: (display) => display.kind
|
|
19
|
+
});
|
|
20
|
+
const fromSchema = (schema) => {
|
|
21
|
+
const ast = Schema.toType(schema).ast;
|
|
22
|
+
const members = ast._tag === "Union" ? (ast.types ?? []).filter((member) => member._tag !== "Null" && member._tag !== "Undefined") : [ast];
|
|
23
|
+
const [only] = members;
|
|
24
|
+
if (members.length === 1 && only?._tag === "Number") return Number_.of({});
|
|
25
|
+
if (members.length === 1 && only?._tag === "Boolean") return Flag.of(nothing);
|
|
26
|
+
return Text.of({});
|
|
27
|
+
};
|
|
28
|
+
/** A kind of Display. The kinds below are made with it, and so is an application's. */
|
|
29
|
+
const kind = (name, spec) => ({
|
|
30
|
+
kind: name,
|
|
31
|
+
of: (data) => Object.freeze({
|
|
32
|
+
kind: name,
|
|
33
|
+
shown: spec.shown ?? true,
|
|
34
|
+
data,
|
|
35
|
+
text: (value, words) => spec.text(data, value, words)
|
|
36
|
+
}),
|
|
37
|
+
is: (display) => display.kind === name
|
|
38
|
+
});
|
|
39
|
+
const show = (display, value, words = {}) => value === null || value === void 0 ? words.nothing ?? "" : display.text(value, words);
|
|
40
|
+
const Text = kind("Text", { text: (data, value) => data.format === void 0 ? String(value) : data.format(value) });
|
|
41
|
+
const Number_ = kind("Number", { text: (data, value) => typeof value === "number" && data.format !== void 0 ? data.format(value) : String(value) });
|
|
42
|
+
const Flag = kind("Flag", { text: (_, value, words) => value === true ? words.yes ?? "yes" : words.no ?? "no" });
|
|
43
|
+
const Hidden = kind("Hidden", {
|
|
44
|
+
shown: false,
|
|
45
|
+
text: () => ""
|
|
46
|
+
});
|
|
47
|
+
/** A relation read as refs: which one, with nothing to say about it but its id. */
|
|
48
|
+
const Ref = kind("Ref", { text: (_, value, words) => {
|
|
49
|
+
const ids = (Array.isArray(value) ? value : [value]).map((ref) => typeof ref === "object" && ref !== null && "id" in ref ? String(ref.id) : String(ref));
|
|
50
|
+
return ids.length === 0 ? words.nothing ?? "" : ids.join(words.separator ?? ", ");
|
|
51
|
+
} });
|
|
52
|
+
/**
|
|
53
|
+
* A relation read through a Selection: the target's own members, each with a
|
|
54
|
+
* Display. `shape` is how many there are: one, a list, or a page of a list.
|
|
55
|
+
*/
|
|
56
|
+
const Nested = kind("Nested", { text: (data, value, words) => {
|
|
57
|
+
const one = (item) => data.columns.filter((column) => column.display.shown).map((column) => show(column.display, item?.[column.key], words)).filter((text) => text !== "").join(" ");
|
|
58
|
+
const items = data.shape === "one" ? [value] : data.shape === "page" ? value.items ?? [] : value;
|
|
59
|
+
return items.length === 0 ? words.nothing ?? "" : items.map(one).join(words.separator ?? ", ");
|
|
60
|
+
} });
|
|
61
|
+
const nothing = Object.freeze({});
|
|
62
|
+
const Display = {
|
|
63
|
+
/**
|
|
64
|
+
* A kind of Display. `Display.kind<{ tone: string }>('Badge', { text: (_, value) => String(value) })`
|
|
65
|
+
* gives `.of(data)` to make one and `.is(display)` to tell one, exactly as the
|
|
66
|
+
* kinds below were made. `text` is the floor; a view draws it specially once
|
|
67
|
+
* it is given a renderer for `Badge`.
|
|
68
|
+
*/
|
|
69
|
+
kind,
|
|
70
|
+
Text,
|
|
71
|
+
Number: Number_,
|
|
72
|
+
Flag,
|
|
73
|
+
Hidden,
|
|
74
|
+
Ref,
|
|
75
|
+
Nested,
|
|
76
|
+
text: (format) => Text.of({ format }),
|
|
77
|
+
number: (format) => Number_.of({ format }),
|
|
78
|
+
flag: () => Flag.of(nothing),
|
|
79
|
+
/** Read, so a row can be opened or keyed by it, and not shown: usually the id. */
|
|
80
|
+
hidden: () => Hidden.of(nothing),
|
|
81
|
+
/**
|
|
82
|
+
* Entity metadata: how a member shows wherever it is listed, e.g.
|
|
83
|
+
* `Entity.annotateMembers({ price: Display.of(Display.number(cents => ...)) })`.
|
|
84
|
+
*/
|
|
85
|
+
of: (display) => key.of(display),
|
|
86
|
+
/**
|
|
87
|
+
* The Display of one selected member, from the most to the least explicit
|
|
88
|
+
* source: the member's `Display.of` metadata, how the relation was selected,
|
|
89
|
+
* then the shape of its schema. `nested` is the columns of a nested Selection,
|
|
90
|
+
* with `shape` saying how many the relation yields.
|
|
91
|
+
*/
|
|
92
|
+
resolve: (member, nested) => {
|
|
93
|
+
const [explicit] = key.get(member.metadata);
|
|
94
|
+
if (explicit !== void 0) return explicit;
|
|
95
|
+
if (member._tag !== "Relation") return fromSchema(member.schema);
|
|
96
|
+
const target = member.target();
|
|
97
|
+
return nested === void 0 ? Ref.of({
|
|
98
|
+
target,
|
|
99
|
+
many: member.cardinality === "many"
|
|
100
|
+
}) : Nested.of({
|
|
101
|
+
target,
|
|
102
|
+
shape: nested.shape,
|
|
103
|
+
columns: nested.columns
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* A value as the text its Display calls for: what a cell says when nothing
|
|
108
|
+
* draws it specially. A view that wants a link or a badge reads the Display
|
|
109
|
+
* and the value itself; this is the floor every view can stand on.
|
|
110
|
+
*/
|
|
111
|
+
show
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/sort.ts
|
|
115
|
+
/**
|
|
116
|
+
* Sorting a list, written once. How a list is sorted is the application's state
|
|
117
|
+
* and its query's input, so this holds none of it: it is the schema of that
|
|
118
|
+
* state, what a click on a header makes of it, and the shape a drawn table
|
|
119
|
+
* takes. The server reads the same state and decides which columns it means.
|
|
120
|
+
*/
|
|
121
|
+
const Sort = {
|
|
122
|
+
/**
|
|
123
|
+
* The orders a list offers, by name. A name is an order the server knows, not
|
|
124
|
+
* a column: which columns may sort, and what `title` means in SQL, stay the
|
|
125
|
+
* server's to decide.
|
|
126
|
+
*/
|
|
127
|
+
make: (columns) => {
|
|
128
|
+
/** A click on a header: ascending, then descending, then the server's own order again. */
|
|
129
|
+
const toggle = (current, column) => current === null || current.by !== column ? {
|
|
130
|
+
by: column,
|
|
131
|
+
direction: "asc"
|
|
132
|
+
} : current.direction === "asc" ? {
|
|
133
|
+
by: column,
|
|
134
|
+
direction: "desc"
|
|
135
|
+
} : null;
|
|
136
|
+
return {
|
|
137
|
+
columns,
|
|
138
|
+
/** For the Model field, and for the query's input. */
|
|
139
|
+
Schema: Schema.NullOr(Schema.Struct({
|
|
140
|
+
by: Schema.Literals(columns),
|
|
141
|
+
direction: Schema.Literals(["asc", "desc"])
|
|
142
|
+
})),
|
|
143
|
+
/** The server's own order. */
|
|
144
|
+
none: null,
|
|
145
|
+
toggle,
|
|
146
|
+
/**
|
|
147
|
+
* What a drawn table takes as `sort`: every order with how it is sorted now
|
|
148
|
+
* and the Message a click sends, made from the state the click leads to.
|
|
149
|
+
*/
|
|
150
|
+
inputs: (current, message) => Object.fromEntries(columns.map((column) => [column, {
|
|
151
|
+
direction: current?.by === column ? current.direction : void 0,
|
|
152
|
+
message: message(toggle(current, column))
|
|
153
|
+
}]))
|
|
154
|
+
};
|
|
155
|
+
} };
|
|
156
|
+
//#endregion
|
|
7
157
|
//#region src/index.ts
|
|
8
158
|
/**
|
|
9
159
|
* `foldkit-crud` — management screens assembled from parts an application
|
|
@@ -19,14 +169,27 @@ const columnLabel = (key, member) => {
|
|
|
19
169
|
const title = member._tag === "Relation" ? void 0 : Schema.resolveAnnotations(member.schema)?.title;
|
|
20
170
|
return typeof title === "string" ? title : Form.labelOf(member) ?? key;
|
|
21
171
|
};
|
|
22
|
-
/** The selected members in the Selection's order, each with its label. */
|
|
172
|
+
/** The selected members in the Selection's order, each with its label and its Display. */
|
|
23
173
|
const columnsOf = (selection) => {
|
|
24
174
|
const members = selection.entity.members;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
175
|
+
const selected = selection.members;
|
|
176
|
+
return Object.keys(selected).map((key) => {
|
|
177
|
+
const member = members[key];
|
|
178
|
+
const how = selected[key];
|
|
179
|
+
const nested = how === true || member._tag !== "Relation" ? void 0 : SelectionPageTypeId in how ? {
|
|
180
|
+
shape: "page",
|
|
181
|
+
columns: columnsOf(how.selection)
|
|
182
|
+
} : {
|
|
183
|
+
shape: member.cardinality === "many" ? "many" : "one",
|
|
184
|
+
columns: columnsOf(how)
|
|
185
|
+
};
|
|
186
|
+
return {
|
|
187
|
+
key,
|
|
188
|
+
label: columnLabel(key, member),
|
|
189
|
+
member,
|
|
190
|
+
display: Display.resolve(member, nested)
|
|
191
|
+
};
|
|
192
|
+
});
|
|
30
193
|
};
|
|
31
194
|
const RemoverMessage = defineMessageUnion({
|
|
32
195
|
Confirmed: {},
|
|
@@ -45,6 +208,8 @@ const Crud = {
|
|
|
45
208
|
name,
|
|
46
209
|
/** The selected members in the Selection's order, each with its label. */
|
|
47
210
|
fields: columnsOf(config.selection),
|
|
211
|
+
/** Type-only: the value shown, for a view to be typed by. Never read. */
|
|
212
|
+
Value: void 0,
|
|
48
213
|
/** The detail where it lives: `id` is the one shown, or `undefined` while none is. */
|
|
49
214
|
at: (where) => {
|
|
50
215
|
const projectionOf = (root) => {
|
|
@@ -58,15 +223,26 @@ const Crud = {
|
|
|
58
223
|
owner: where.data.contract.owner ?? {},
|
|
59
224
|
projectionOf
|
|
60
225
|
},
|
|
61
|
-
value: (root) => projectionOf(root)?.read(root) ?? { _tag: "Initial" }
|
|
226
|
+
value: (root) => projectionOf(root)?.read(root) ?? { _tag: "Initial" },
|
|
227
|
+
/**
|
|
228
|
+
* Asks for the value again: `Data.refresh` over this detail, for a retry
|
|
229
|
+
* button. A failed read is not retried on its own. Unchanged while no id
|
|
230
|
+
* is shown.
|
|
231
|
+
*/
|
|
232
|
+
refresh: (root) => {
|
|
233
|
+
const projection = projectionOf(root);
|
|
234
|
+
return projection === void 0 ? root : where.data.refresh(root, projection);
|
|
235
|
+
}
|
|
62
236
|
};
|
|
63
237
|
}
|
|
64
238
|
}),
|
|
65
239
|
/**
|
|
66
240
|
* Deleting through one mutation, with a yes in between: asked, confirmed,
|
|
67
|
-
* deleted. What the mutation's input is for an id is `input`'s to say
|
|
241
|
+
* deleted. What the mutation's input is for an id is `input`'s to say, and the
|
|
242
|
+
* id it names there (`(id: PostId) => ...`) is the id `ask` takes.
|
|
68
243
|
*/
|
|
69
244
|
remover: (name, config) => {
|
|
245
|
+
const inputFor = (id) => "input" in config ? config.input(id) : { [config.id]: id };
|
|
70
246
|
return {
|
|
71
247
|
bundle: Bundle.make(name, {
|
|
72
248
|
Model: Schema.Struct({
|
|
@@ -102,7 +278,7 @@ const Crud = {
|
|
|
102
278
|
return {
|
|
103
279
|
/** For the placement: a yes becomes the mutation, and its request is remembered. */
|
|
104
280
|
onOut: (confirmed) => (root) => {
|
|
105
|
-
const started = data.mutate(root, config.mutation,
|
|
281
|
+
const started = data.mutate(root, config.mutation, inputFor(confirmed.id));
|
|
106
282
|
return {
|
|
107
283
|
model: slice.set(started.model, {
|
|
108
284
|
target: confirmed.id,
|
|
@@ -137,6 +313,8 @@ const Crud = {
|
|
|
137
313
|
name,
|
|
138
314
|
/** The selected members in the Selection's order, each with its label. */
|
|
139
315
|
columns: columnsOf(selection),
|
|
316
|
+
/** Type-only: a row, for a view to be typed by. Never read. */
|
|
317
|
+
Row: void 0,
|
|
140
318
|
/**
|
|
141
319
|
* The list where it lives. `input` is the query's input as the Model has
|
|
142
320
|
* it (filters, a search term), or `undefined` while the list is not shown.
|
|
@@ -165,7 +343,23 @@ const Crud = {
|
|
|
165
343
|
const next = projection === void 0 ? void 0 : data.next(root, projection);
|
|
166
344
|
return next === void 0 ? void 0 : data.fetch(next);
|
|
167
345
|
},
|
|
346
|
+
/**
|
|
347
|
+
* Asks for the list again: `Data.refresh` over its page and rows, for a
|
|
348
|
+
* retry button. A failed read is not retried on its own. Unchanged while
|
|
349
|
+
* the list is not shown.
|
|
350
|
+
*/
|
|
351
|
+
refresh: (root) => {
|
|
352
|
+
const projection = projectionOf(root);
|
|
353
|
+
return projection === void 0 ? root : data.refresh(root, projection);
|
|
354
|
+
},
|
|
168
355
|
name,
|
|
356
|
+
/** Whose requirement the list is, for anything that requires beside it. */
|
|
357
|
+
owner: data.contract.owner ?? {},
|
|
358
|
+
/**
|
|
359
|
+
* One of the list's Entity through the list's Selection, by id, whether or
|
|
360
|
+
* not the query finds it now: what a picker reads to name what is chosen.
|
|
361
|
+
*/
|
|
362
|
+
row: (id) => data.get(selection, id),
|
|
169
363
|
/** The Entity the rows are of, which is how a picker finds the list for its target. */
|
|
170
364
|
entity: selection.entity,
|
|
171
365
|
/** Whether the list was given a `choice`, so its rows can be a picker's choices. */
|
|
@@ -182,6 +376,15 @@ const Crud = {
|
|
|
182
376
|
value: choice.value(row),
|
|
183
377
|
label: choice.label(row)
|
|
184
378
|
})) : [];
|
|
379
|
+
},
|
|
380
|
+
/** That row as a choice, once it is read. */
|
|
381
|
+
choiceOf: (root, id) => {
|
|
382
|
+
if (choice === void 0) return void 0;
|
|
383
|
+
const read = data.get(selection, id).read(root);
|
|
384
|
+
return read._tag === "Ready" || read._tag === "Refreshing" ? {
|
|
385
|
+
value: choice.value(read.value),
|
|
386
|
+
label: choice.label(read.value)
|
|
387
|
+
} : void 0;
|
|
185
388
|
}
|
|
186
389
|
};
|
|
187
390
|
}
|
|
@@ -201,18 +404,65 @@ const Crud = {
|
|
|
201
404
|
* The choices of every relation picker in a form, from the lists of their
|
|
202
405
|
* targets: `foldkit-mixins-form`'s `options`, keyed by the form's keys. A
|
|
203
406
|
* picker whose target no list here is over is a wiring mistake, reported now.
|
|
407
|
+
*
|
|
408
|
+
* With `chosen`, the form's Model as the page has it, what a picker already
|
|
409
|
+
* holds stays among its choices when the list no longer finds it (a search
|
|
410
|
+
* narrowed it, or it is on a later page), and `active` requires those rows so
|
|
411
|
+
* their words are there. Give `chosen` to any form whose pickers search.
|
|
204
412
|
*/
|
|
205
|
-
options: (form, lists) => {
|
|
413
|
+
options: (form, lists, options = {}) => {
|
|
206
414
|
const pickers = form.controls.flatMap(({ key, control }) => {
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
|
|
415
|
+
if (!Input.RelationOne.is(control) && !Input.RelationMany.is(control)) return [];
|
|
416
|
+
const { target } = control.data;
|
|
417
|
+
const list = lists.find((candidate) => Entity.same(candidate.entity, target));
|
|
418
|
+
if (list === void 0) throw new Error(`Crud.options: "${key}" picks a ${target.name}, and no list given is over ${target.name}`);
|
|
210
419
|
if (!list.offersChoices) throw new Error(`Crud.options: "${key}" would pick from list "${list.name}", which has no "choice"`);
|
|
211
420
|
return [[key, list]];
|
|
212
421
|
});
|
|
213
|
-
|
|
422
|
+
/** The ids each picker holds now: the draft of a `one`, or of a `many`. */
|
|
423
|
+
const held = (root) => {
|
|
424
|
+
const model = options.chosen?.(root);
|
|
425
|
+
const field = form.field;
|
|
426
|
+
if (model === void 0 || field === void 0) return [];
|
|
427
|
+
return pickers.flatMap(([key, list]) => {
|
|
428
|
+
const draft = field(model, key).value;
|
|
429
|
+
return (Array.isArray(draft) ? draft : typeof draft === "string" ? [draft] : []).filter((id) => typeof id === "string" && id !== "").map((id) => [
|
|
430
|
+
key,
|
|
431
|
+
list,
|
|
432
|
+
id
|
|
433
|
+
]);
|
|
434
|
+
});
|
|
435
|
+
};
|
|
436
|
+
const choices = (root) => {
|
|
437
|
+
const chosen = held(root);
|
|
438
|
+
return Object.fromEntries(pickers.map(([key, list]) => {
|
|
439
|
+
const listed = list.choices(root);
|
|
440
|
+
return [key, [...chosen.filter(([heldBy, , id]) => heldBy === key && !listed.some((item) => item.value === id)).flatMap(([, , id]) => list.choiceOf(root, id) ?? []), ...listed]];
|
|
441
|
+
}));
|
|
442
|
+
};
|
|
443
|
+
const [first] = lists;
|
|
444
|
+
return Object.assign(choices, {
|
|
445
|
+
/** For `Data.subscriptions`: what the pickers hold is read, so it can be named. */
|
|
446
|
+
active: {
|
|
447
|
+
name: `${pickers.map(([key]) => key).join("+")} chosen`,
|
|
448
|
+
owner: first?.owner ?? {},
|
|
449
|
+
projectionOf: (root) => {
|
|
450
|
+
const rows = held(root);
|
|
451
|
+
return rows.length === 0 ? void 0 : Projection.struct(Object.fromEntries(rows.map(([key, list, id]) => [`${key}:${id}`, list.row(id)])));
|
|
452
|
+
}
|
|
453
|
+
} });
|
|
214
454
|
},
|
|
215
455
|
/**
|
|
456
|
+
* What the pieces on a page require of Remote, by the names given: a placed
|
|
457
|
+
* editor, list, or detail, or the pickers from `Crud.options`. It is each one's
|
|
458
|
+
* `active`, gathered, so handing the pieces over is enough and none is left out:
|
|
459
|
+
*
|
|
460
|
+
* ```ts
|
|
461
|
+
* Data.wiring(Crud.actives({ posts: Posts, authors: Authors, editor: PostEditor, pickers }))
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
actives: (pieces) => Object.fromEntries(Object.entries(pieces).map(([name, piece]) => [name, piece.active])),
|
|
465
|
+
/**
|
|
216
466
|
* An editor for one form and the mutation its value feeds. The form's value
|
|
217
467
|
* must be the mutation's input, which is what declaring the input once and
|
|
218
468
|
* giving it to both guarantees.
|
|
@@ -348,6 +598,8 @@ const Crud = {
|
|
|
348
598
|
const save = saveOf(root);
|
|
349
599
|
return save._tag === "Failed" ? save.error : void 0;
|
|
350
600
|
},
|
|
601
|
+
/** The id being edited, typed as the Entity's own; `null` for a new one or a closed editor. */
|
|
602
|
+
target: (root) => slice.get(root).target,
|
|
351
603
|
status: (root) => {
|
|
352
604
|
const editor = slice.get(root);
|
|
353
605
|
if (editor.mode === "closed") return "Closed";
|
|
@@ -366,6 +618,6 @@ const Crud = {
|
|
|
366
618
|
}
|
|
367
619
|
};
|
|
368
620
|
//#endregion
|
|
369
|
-
export { Crud };
|
|
621
|
+
export { Crud, Display, Sort };
|
|
370
622
|
|
|
371
623
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `foldkit-crud` — management screens assembled from parts an application\n * already has.\n *\n * An editor joins a `foldkit-form` form, the Remote mutation its value feeds,\n * and the Entity they share: it loads what the form writes, shows it, turns a\n * valid submit into the mutation, and says how that went. Everything it makes is\n * ordinary Foldkit: a Bundle, an ActiveSurface, Update Steps. Nothing is\n * generated from an Entity alone; each capability is declared.\n */\nimport { Schema } from 'effect'\nimport { Bundle } from 'foldkit-bundle'\nimport {\n Entity,\n type AnyEntity,\n type EntityInput,\n type EntityMember,\n type Selection,\n} from 'foldkit-entity'\nimport { Form, type FormControl, type Submitted } from 'foldkit-form'\nimport type {\n MutationDescriptor,\n Page,\n QueryDescriptor,\n MutationStatus,\n RemoteClient,\n RemoteData,\n RemoteError,\n RemoteMessage,\n} from 'foldkit-remote'\nimport type { ActiveSurface, ModelRef, Projection } from 'foldkit-surface'\nimport type { Command } from 'foldkit/command'\nimport { defineMessageUnion } from 'foldkit/message'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport * as Submodel from 'foldkit/submodel'\nimport type * as Update from 'foldkit/update'\n\n/** The parts of a `Form.make` result an editor wraps. */\nexport interface EditableForm<\n Name extends string,\n FormModel,\n FormMessage,\n Value,\n E extends AnyEntity,\n Fields extends Schema.Struct.Fields,\n Members,\n R = never,\n> {\n readonly bundle: {\n readonly name: Name\n readonly Model: Schema.Codec<FormModel, unknown>\n readonly Message: Schema.Codec<FormMessage, unknown>\n readonly update: (\n model: FormModel,\n message: FormMessage,\n args: void,\n ) => Update.ReturnWithOutMessage<FormModel, FormMessage, Submitted<Value>, R>\n }\n readonly input: EntityInput<E, Fields, Members>\n readonly initial: FormModel\n readonly fill: (model: FormModel, values: Partial<Value>) => { readonly model: FormModel }\n}\n\n/**\n * An editor's slice of the parent Model. `target` is the id being edited, or\n * `null` for a new one; `filled` is whether the loaded value has been shown;\n * `requestId` is the save in progress or last settled.\n */\nexport interface EditorModel<FormModel> {\n readonly form: FormModel\n readonly mode: 'closed' | 'new' | 'edit'\n readonly target: string | null\n readonly filled: boolean\n readonly requestId: string | null\n}\n\n/**\n * A remover's slice of the parent Model: the id it was asked to delete and is\n * waiting on a yes for, and the delete in progress or last settled.\n */\nexport interface RemoverModel {\n readonly target: string | null\n readonly requestId: string | null\n}\n\n/** A remover's out Message: the user said yes to deleting `id`. */\nexport interface ConfirmedRemoval {\n readonly _tag: 'Confirmed'\n readonly id: string\n}\n\nexport type RemoverStatus =\n | 'Idle'\n /** Asked to delete an id, and waiting for a yes or a no. */\n | 'Confirming'\n | 'Deleting'\n | 'Deleted'\n | 'DeleteFailed'\n\nexport type EditorStatus =\n | 'Closed'\n /** Editing an id whose current values have not arrived. */\n | 'Loading'\n | 'NotFound'\n | 'LoadFailed'\n | 'Editing'\n | 'Saving'\n | 'Saved'\n | 'SaveFailed'\n\n/** The parts of a bound Remote domain an editor uses. */\nexport interface DomainLike<Root> {\n // Method syntax: the descriptors are checked where the editor is made, not here.\n mutate(\n model: Root,\n mutation: any,\n input: any,\n ): {\n readonly model: Root\n readonly requestId: string\n readonly command: Command<RemoteMessage, never, RemoteClient>\n }\n get(selection: any, id: string): Projection<Root, RemoteData<any>>\n query(query: any, input: any, options: any): Projection<Root, RemoteData<Page<any>>>\n next(model: Root, projection: any): { readonly query: string } | undefined\n fetch(ref: any): Command<RemoteMessage, never, RemoteClient>\n mutation(model: Root, requestId: string): MutationStatus\n readonly contract: { readonly owner?: object | undefined }\n}\n\ntype Step<Root> = Update.Step<Root, RemoteMessage, RemoteClient>\n\n/** One thing a relation picker offers. */\nexport interface Choice {\n readonly value: string\n readonly label: string\n}\n\n/** One column of a list, or one line of a detail: a member the Selection reads. */\nexport interface ListColumn<Key extends string = string> {\n readonly key: Key\n /** The schema's `title` annotation, else `Form.label` metadata, else the key. */\n readonly label: string\n readonly member: EntityMember\n}\n\nconst columnLabel = (key: string, member: EntityMember): string => {\n const title =\n member._tag === 'Relation'\n ? undefined\n : Schema.resolveAnnotations(member.schema as Schema.Top)?.title\n return typeof title === 'string' ? title : (Form.labelOf(member) ?? key)\n}\n\n/** The selected members in the Selection's order, each with its label. */\nconst columnsOf = <Members>(\n selection: Selection<string, Members, Schema.Constraint>,\n): ReadonlyArray<ListColumn<keyof Members & string>> => {\n const members: Readonly<Record<string, EntityMember>> = selection.entity.members\n return Object.keys(selection.members as object).map(key => ({\n key: key as keyof Members & string,\n label: columnLabel(key, members[key]!),\n member: members[key]!,\n }))\n}\n\nconst RemoverMessage = defineMessageUnion({ Confirmed: {}, Cancelled: {} })\ntype RemoverMessage = typeof RemoverMessage.Type\n\nconst idle: RemoverModel = { target: null, requestId: null }\n\nexport const Crud = {\n /**\n * One Entity read through a Selection, for a page that shows it. Like a list\n * it holds no state: the value is Remote's and the id is the application's.\n */\n detail: <const Name extends string, EntityName extends string, Members, Row>(\n name: Name,\n config: {\n readonly selection: Selection<EntityName, Members, Schema.Constraint & { readonly Type: Row }>\n },\n ) => ({\n name,\n /** The selected members in the Selection's order, each with its label. */\n fields: columnsOf(config.selection),\n\n /** The detail where it lives: `id` is the one shown, or `undefined` while none is. */\n at: <Root>(where: {\n readonly data: DomainLike<Root>\n readonly id: (root: Root) => string | undefined\n }) => {\n const projectionOf = (root: Root) => {\n const id = where.id(root)\n return id === undefined ? undefined : where.data.get(config.selection, id)\n }\n return {\n /** For `Data.subscriptions`: the value is fetched and retained while an id is shown. */\n active: {\n name,\n owner: where.data.contract.owner ?? {},\n projectionOf,\n } satisfies ActiveSurface<Root>,\n value: (root: Root): RemoteData<Row> =>\n projectionOf(root)?.read(root) ?? { _tag: 'Initial' },\n }\n },\n }),\n\n /**\n * Deleting through one mutation, with a yes in between: asked, confirmed,\n * deleted. What the mutation's input is for an id is `input`'s to say.\n */\n remover: <const Name extends string, Input>(\n name: Name,\n config: {\n readonly mutation: MutationDescriptor<string, Input, any>\n readonly input: (id: string) => Input\n },\n ) => {\n const bundle = Bundle.make(name, {\n Model: Schema.Struct({\n target: Schema.NullOr(Schema.String),\n requestId: Schema.NullOr(Schema.String),\n }) as unknown as Schema.Codec<RemoverModel, unknown>,\n Message: RemoverMessage,\n init: () => ({ model: idle }),\n update: (model: RemoverModel, message: RemoverMessage) =>\n message._tag === 'Cancelled' || model.target === null\n ? { model: idle }\n : { model, outMessage: { _tag: 'Confirmed', id: model.target } as ConfirmedRemoval },\n helpers: {\n /** Asks whether to delete `id`. Nothing is deleted until `Confirmed`. */\n ask: (_: RemoverModel, id: string) => ({ model: { target: id, requestId: null } }),\n dismiss: () => ({ model: idle }),\n },\n })\n\n return {\n bundle,\n /** The remover's Messages, for the yes and the no of a confirmation. */\n Message: RemoverMessage,\n\n at: <Root>(where: {\n readonly data: DomainLike<Root>\n readonly model: ModelRef<Root, RemoverModel>\n }) => {\n const { data, model: slice } = where\n const outcome = (root: Root): MutationStatus => {\n const { requestId } = slice.get(root)\n return requestId === null ? { _tag: 'Unknown' } : data.mutation(root, requestId)\n }\n return {\n /** For the placement: a yes becomes the mutation, and its request is remembered. */\n onOut:\n (confirmed: ConfirmedRemoval): Step<Root> =>\n root => {\n const started = data.mutate(root, config.mutation, config.input(confirmed.id))\n return {\n model: slice.set(started.model, {\n target: confirmed.id,\n requestId: started.requestId,\n }),\n commands: [started.command],\n }\n },\n\n /** The id being asked about or deleted, for the words of a confirmation. */\n target: (root: Root): string | null => slice.get(root).target,\n\n status: (root: Root): RemoverStatus => {\n const { target } = slice.get(root)\n const deleting = outcome(root)\n return deleting._tag === 'Pending'\n ? 'Deleting'\n : deleting._tag === 'Applied'\n ? 'Deleted'\n : deleting._tag === 'Failed'\n ? 'DeleteFailed'\n : target === null\n ? 'Idle'\n : 'Confirming'\n },\n\n /** Why the last delete failed, while `status` is `DeleteFailed`. */\n error: (root: Root): RemoteError | undefined => {\n const deleting = outcome(root)\n return deleting._tag === 'Failed' ? deleting.error : undefined\n },\n }\n },\n }\n },\n\n /**\n * A list over one query: which rows to show is the query's, what to show of\n * each is the Selection's. The pages live in Remote; the list holds no state.\n */\n list: <const Name extends string, EntityName extends string, Members, Row, Input>(\n name: Name,\n config: {\n readonly query: QueryDescriptor<string, Input, any>\n readonly selection: Selection<EntityName, Members, Schema.Constraint & { readonly Type: Row }>\n /** How many rows a page holds. Default 25. */\n readonly pageSize?: number\n /**\n * How a row reads as a choice in a relation picker: its id, and the words\n * that identify it to a person. Give it to a list that feeds pickers.\n */\n readonly choice?: {\n readonly value: (row: Row) => string\n readonly label: (row: Row) => string\n }\n },\n ) => {\n const { query, selection, pageSize = 25, choice } = config\n const columns = columnsOf(selection)\n\n return {\n name,\n /** The selected members in the Selection's order, each with its label. */\n columns,\n\n /**\n * The list where it lives. `input` is the query's input as the Model has\n * it (filters, a search term), or `undefined` while the list is not shown.\n */\n at: <Root>(where: {\n readonly data: DomainLike<Root>\n readonly input: (root: Root) => Input | undefined\n }) => {\n const { data, input } = where\n const projectionOf = (root: Root) => {\n const value = input(root)\n return value === undefined\n ? undefined\n : data.query(query, value, { select: selection, first: pageSize })\n }\n const page = (root: Root): RemoteData<Page<Row>> =>\n projectionOf(root)?.read(root) ?? { _tag: 'Initial' }\n\n return {\n /** For `Data.subscriptions`: the page and its rows are fetched and retained while shown. */\n active: {\n name,\n owner: data.contract.owner ?? {},\n projectionOf,\n } satisfies ActiveSurface<Root>,\n\n page,\n\n /** The Command that loads the next page onto this one, or `undefined` when there is none. */\n more: (root: Root): Command<RemoteMessage, never, RemoteClient> | undefined => {\n const projection = projectionOf(root)\n const next = projection === undefined ? undefined : data.next(root, projection)\n return next === undefined ? undefined : data.fetch(next)\n },\n\n name,\n /** The Entity the rows are of, which is how a picker finds the list for its target. */\n entity: selection.entity as AnyEntity,\n /** Whether the list was given a `choice`, so its rows can be a picker's choices. */\n offersChoices: choice !== undefined,\n\n /**\n * The loaded rows as a picker's choices, read through `choice`. Listing a\n * relation's target is this query, which the application chose and the\n * server authorizes; nothing is read because a relation exists.\n */\n choices: (root: Root): ReadonlyArray<Choice> => {\n if (choice === undefined)\n throw new Error(`Crud list \"${name}\": give it a \"choice\" to use its rows in a picker`)\n const read = page(root)\n return read._tag === 'Ready' || read._tag === 'Refreshing'\n ? read.value.items.map(row => ({\n value: choice.value(row),\n label: choice.label(row),\n }))\n : []\n },\n }\n },\n }\n },\n\n /**\n * A form's Submodel view as the view of the editor that wraps it, for\n * `Bundle.withView`: the editor's Messages are the form's, and its Model holds\n * the form's under `form`.\n *\n * ```ts\n * Editor.bundle.pipe(Bundle.withView(Crud.editorView(FormView.submodel(form, view))))\n * ```\n */\n editorView: <FormModel, Message, ViewInputs>(\n view: Submodel.View<FormModel, Message, ViewInputs>,\n ): Submodel.View<EditorModel<FormModel>, Message, ViewInputs> =>\n Submodel.defineView<EditorModel<FormModel>, Message, ViewInputs>(((\n model: EditorModel<FormModel>,\n inputs: ViewInputs,\n h: HtmlBuilder<Message>,\n ): Html =>\n (view as (model: FormModel, inputs: ViewInputs, h: HtmlBuilder<Message>) => Html)(\n model.form,\n inputs,\n h,\n )) as never),\n\n /**\n * The choices of every relation picker in a form, from the lists of their\n * targets: `foldkit-mixins-form`'s `options`, keyed by the form's keys. A\n * picker whose target no list here is over is a wiring mistake, reported now.\n */\n options: <Key extends string, Root>(\n form: { readonly controls: ReadonlyArray<FormControl<Key>> },\n lists: ReadonlyArray<{\n readonly name: string\n readonly entity: AnyEntity\n readonly offersChoices: boolean\n readonly choices: (root: Root) => ReadonlyArray<Choice>\n }>,\n ): ((root: Root) => { readonly [K in Key]?: ReadonlyArray<Choice> }) => {\n const pickers = form.controls.flatMap(({ key, control }) => {\n if (control._tag !== 'RelationOne' && control._tag !== 'RelationMany') return []\n const list = lists.find(candidate => Entity.same(candidate.entity, control.target))\n if (list === undefined)\n throw new Error(\n `Crud.options: \"${key}\" picks a ${control.target.name}, and no list given is over ${control.target.name}`,\n )\n if (!list.offersChoices)\n throw new Error(\n `Crud.options: \"${key}\" would pick from list \"${list.name}\", which has no \"choice\"`,\n )\n return [[key, list] as const]\n })\n return root =>\n Object.fromEntries(pickers.map(([key, list]) => [key, list.choices(root)])) as {\n readonly [K in Key]?: ReadonlyArray<Choice>\n }\n },\n\n /**\n * An editor for one form and the mutation its value feeds. The form's value\n * must be the mutation's input, which is what declaring the input once and\n * giving it to both guarantees.\n */\n editor: <\n const Name extends string,\n FormName extends string,\n FormModel,\n FormMessage extends { readonly _tag: string },\n Value,\n E extends AnyEntity,\n Fields extends Schema.Struct.Fields,\n Members,\n R = never,\n >(\n name: Name,\n config: {\n readonly form: EditableForm<FormName, FormModel, FormMessage, Value, E, Fields, Members, R>\n readonly mutation: MutationDescriptor<string, Value, any>\n },\n ) => {\n type Model = EditorModel<FormModel>\n const { form, mutation } = config\n\n const closed: Model = {\n form: form.initial,\n mode: 'closed',\n target: null,\n filled: false,\n requestId: null,\n }\n const Model = Schema.Struct({\n form: form.bundle.Model,\n mode: Schema.Literals(['closed', 'new', 'edit']),\n target: Schema.NullOr(Schema.String),\n filled: Schema.Boolean,\n requestId: Schema.NullOr(Schema.String),\n }) as unknown as Schema.Codec<Model, unknown>\n\n // The editor's Messages are the form's own: it adds state around the form,\n // not a second vocabulary.\n const bundle = Bundle.make(name, {\n Model,\n Message: form.bundle.Message,\n init: () => ({ model: closed }),\n update: (model: Model, message: FormMessage) => {\n const next = form.bundle.update(model.form, message, undefined)\n // An edit after a save starts a new round; the last save no longer describes the form.\n const requestId = message._tag === 'Changed' ? null : model.requestId\n // The form's Commands are the editor's: a check the form started has to run.\n const edited = {\n model: { ...model, form: next.model, requestId },\n ...(next.commands === undefined ? {} : { commands: next.commands }),\n }\n return next.outMessage === undefined ? edited : { ...edited, outMessage: next.outMessage }\n },\n helpers: {\n /** Edits `id`: the form is emptied, and filled once the current values arrive. */\n open: (_: Model, id: string) => ({\n model: { ...closed, mode: 'edit' as const, target: id },\n }),\n /** A blank form for a new one: nothing to load. */\n blank: () => ({ model: { ...closed, mode: 'new' as const, filled: true } }),\n close: () => ({ model: closed }),\n },\n })\n\n const current = Entity.selectFor(form.input)\n\n return {\n bundle,\n /** What the editor loads before it shows the form: every member the form writes. */\n selection: current,\n\n /**\n * The editor where it lives: `model` is its slice of the parent Model (the\n * field it was declared at), and `data` the Remote domain that registers the\n * mutation and the Entity.\n */\n at: <Root>(where: {\n readonly data: DomainLike<Root>\n readonly model: ModelRef<Root, Model>\n }) => {\n const { data, model: slice } = where\n const loaded = (root: Root): RemoteData<any> | undefined => {\n const { mode, target } = slice.get(root)\n return mode === 'edit' && target !== null\n ? data.get(current, target).read(root)\n : undefined\n }\n\n /** Shows the loaded value once, the first time it is there. Later refreshes leave the drafts alone. */\n const sync: Update.Step<Root, never, never> = root => {\n const editor = slice.get(root)\n const read = loaded(root)\n if (editor.filled || read === undefined) return { model: root }\n if (read._tag !== 'Ready' && read._tag !== 'Refreshing') return { model: root }\n const values = Entity.valuesFor(form.input, read.value) as Partial<Value>\n return {\n model: slice.set(root, {\n ...editor,\n form: form.fill(editor.form, values).model,\n filled: true,\n }),\n }\n }\n\n const saveOf = (root: Root): MutationStatus => {\n const { requestId } = slice.get(root)\n return requestId === null ? { _tag: 'Unknown' } : data.mutation(root, requestId)\n }\n\n return {\n /** For the placement: a valid submit becomes the mutation, and its request is remembered. */\n onOut:\n (submitted: Submitted<Value>): Step<Root> =>\n root => {\n const started = data.mutate(root, mutation, submitted.value)\n const editor = slice.get(started.model)\n return {\n model: slice.set(started.model, { ...editor, requestId: started.requestId }),\n commands: [started.command],\n }\n },\n\n /**\n * For `Data.subscriptions`: while an id is being edited, what it loads is\n * a requirement like any Surface's, so Remote fetches and retains it.\n */\n active: {\n name,\n owner: data.contract.owner ?? {},\n projectionOf: root => {\n const { mode, target } = slice.get(root)\n return mode === 'edit' && target !== null ? data.get(current, target) : undefined\n },\n } satisfies ActiveSurface<Root>,\n\n sync,\n\n /**\n * Wraps the application's `update` so `sync` runs after every Message:\n * the value may arrive with any of them.\n */\n after:\n <Message, Result extends { readonly model: Root }>(\n update: (model: Root, message: Message) => Result,\n ) =>\n (model: Root, message: Message): Result => {\n const next = update(model, message)\n return { ...next, model: sync(next.model).model }\n },\n\n /** Why the last save failed, while `status` is `SaveFailed`. */\n saveError: (root: Root): RemoteError | undefined => {\n const save = saveOf(root)\n return save._tag === 'Failed' ? save.error : undefined\n },\n\n status: (root: Root): EditorStatus => {\n const editor = slice.get(root)\n if (editor.mode === 'closed') return 'Closed'\n // Gone outranks everything: a save that landed describes a thing that no longer exists.\n const read = loaded(root)\n if (read?._tag === 'NotFound') return 'NotFound'\n const save = saveOf(root)\n if (save._tag === 'Pending') return 'Saving'\n if (save._tag === 'Failed') return 'SaveFailed'\n if (save._tag === 'Applied') return 'Saved'\n if (editor.filled) return 'Editing'\n return read?._tag === 'Failed' ? 'LoadFailed' : 'Loading'\n },\n }\n },\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkJA,MAAM,eAAe,KAAa,WAAiC;CACjE,MAAM,QACJ,OAAO,SAAS,aACZ,KAAA,IACA,OAAO,mBAAmB,OAAO,MAAoB,CAAC,EAAE;CAC9D,OAAO,OAAO,UAAU,WAAW,QAAS,KAAK,QAAQ,MAAM,KAAK;AACtE;;AAGA,MAAM,aACJ,cACsD;CACtD,MAAM,UAAkD,UAAU,OAAO;CACzE,OAAO,OAAO,KAAK,UAAU,OAAiB,CAAC,CAAC,KAAI,SAAQ;EACrD;EACL,OAAO,YAAY,KAAK,QAAQ,IAAK;EACrC,QAAQ,QAAQ;CAClB,EAAE;AACJ;AAEA,MAAM,iBAAiB,mBAAmB;CAAE,WAAW,CAAC;CAAG,WAAW,CAAC;AAAE,CAAC;AAG1E,MAAM,OAAqB;CAAE,QAAQ;CAAM,WAAW;AAAK;AAE3D,MAAa,OAAO;;;;;CAKlB,SACE,MACA,YAGI;EACJ;;EAEA,QAAQ,UAAU,OAAO,SAAS;;EAGlC,KAAW,UAGL;GACJ,MAAM,gBAAgB,SAAe;IACnC,MAAM,KAAK,MAAM,GAAG,IAAI;IACxB,OAAO,OAAO,KAAA,IAAY,KAAA,IAAY,MAAM,KAAK,IAAI,OAAO,WAAW,EAAE;GAC3E;GACA,OAAO;;IAE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,KAAK,SAAS,WAAW,OAAO;MACpC,IAAI,KAAK,SAAS,UAAU,OAAO;MACnC,IAAI,KAAK,SAAS,WAAW,OAAO;MACpC,IAAI,OAAO,QAAQ,OAAO;MAC1B,OAAO,MAAM,SAAS,WAAW,eAAe;KAClD;IACF;GACF;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/display.ts","../src/sort.ts","../src/index.ts"],"sourcesContent":["/**\n * Displays: how one selected member shows in a list or a detail, described\n * without a renderer. It is `foldkit-form`'s `Input` from the reading side: the\n * member says what it is, a Display says how it reads, and which DOM draws it is\n * the application's.\n */\nimport { Schema } from 'effect'\nimport type { AnyEntity, EntityMember } from 'foldkit-entity'\nimport { Metadata } from 'foldkit-metadata'\n\n/**\n * How one selected member shows: the primitive every kind of Display is a value\n * of. `Display.text()` and `Display.flag()` are values of it, made by\n * `Display.kind`, which is what an application calls for a badge or a relative\n * date. The kinds here are a collection, not a special case.\n */\nexport interface Display<Data = unknown> {\n /** The name a renderer is found by. */\n readonly kind: string\n /** Whether a view draws it. A member read and not shown, usually the id, is `false`. */\n readonly shown: boolean\n /** What this kind needs: a format, a relation's target. */\n readonly data: Data\n /**\n * The value as text: what a cell says when nothing draws it specially. It is\n * never given `null` or `undefined`; `Display.show` says `nothing` for those.\n */\n readonly text: (value: unknown, words: DisplayWords) => string\n}\n\n/** A kind of Display: how its values are made, and how one is told from another. */\nexport interface DisplayKind<Data> {\n readonly kind: string\n readonly of: (data: Data) => Display<Data>\n readonly is: (display: Display) => display is Display<Data>\n}\n\n/** A selected member with its words and its Display. A list's column, a detail's line. */\nexport interface DisplayColumn<Key extends string = string> {\n readonly key: Key\n readonly label: string\n readonly member: EntityMember\n readonly display: Display\n}\n\n/** The words a Display needs that are not the value's own. */\nexport interface DisplayWords {\n /** Default `yes`. */\n readonly yes?: string\n /** Default `no`. */\n readonly no?: string\n /** What stands for nothing: `null`, `undefined`, an empty list. Default the empty string. */\n readonly nothing?: string\n /** Between the items of a list, and between the members of a nested value. Default `, `. */\n readonly separator?: string\n}\n\nconst key = Metadata.key<Display>('foldkit-crud/display', {\n // The last Display attached wins: a later annotation refines an earlier one.\n merge: displays => displays.slice(-1),\n summarize: display => display.kind,\n})\n\ninterface AstLike {\n readonly _tag: string\n readonly types?: ReadonlyArray<AstLike>\n}\n\nconst fromSchema = (schema: Schema.Top): Display => {\n const ast = Schema.toType(schema).ast as unknown as AstLike\n const members =\n ast._tag === 'Union'\n ? (ast.types ?? []).filter(member => member._tag !== 'Null' && member._tag !== 'Undefined')\n : [ast]\n const [only] = members\n if (members.length === 1 && only?._tag === 'Number') return Number_.of({})\n if (members.length === 1 && only?._tag === 'Boolean') return Flag.of(nothing)\n return Text.of({})\n}\n\n/** A kind of Display. The kinds below are made with it, and so is an application's. */\nconst kind = <Data = Record<string, never>>(\n name: string,\n spec: {\n readonly shown?: boolean\n readonly text: (data: Data, value: unknown, words: DisplayWords) => string\n },\n): DisplayKind<Data> => ({\n kind: name,\n of: data =>\n Object.freeze({\n kind: name,\n shown: spec.shown ?? true,\n data,\n text: (value: unknown, words: DisplayWords) => spec.text(data, value, words),\n }),\n is: (display): display is Display<Data> => display.kind === name,\n})\n\nconst show = (display: Display, value: unknown, words: DisplayWords = {}): string =>\n value === null || value === undefined ? (words.nothing ?? '') : display.text(value, words)\n\nconst Text = kind<{ readonly format?: ((value: unknown) => string) | undefined }>('Text', {\n text: (data, value) => (data.format === undefined ? String(value) : data.format(value)),\n})\nconst Number_ = kind<{ readonly format?: ((value: number) => string) | undefined }>('Number', {\n text: (data, value) =>\n typeof value === 'number' && data.format !== undefined ? data.format(value) : String(value),\n})\nconst Flag = kind('Flag', {\n text: (_, value, words) => (value === true ? (words.yes ?? 'yes') : (words.no ?? 'no')),\n})\nconst Hidden = kind('Hidden', { shown: false, text: () => '' })\n/** A relation read as refs: which one, with nothing to say about it but its id. */\nconst Ref = kind<{ readonly target: AnyEntity; readonly many: boolean }>('Ref', {\n text: (_, value, words) => {\n const ids = (Array.isArray(value) ? value : [value]).map(ref =>\n typeof ref === 'object' && ref !== null && 'id' in ref ? String(ref.id) : String(ref),\n )\n return ids.length === 0 ? (words.nothing ?? '') : ids.join(words.separator ?? ', ')\n },\n})\n/**\n * A relation read through a Selection: the target's own members, each with a\n * Display. `shape` is how many there are: one, a list, or a page of a list.\n */\nconst Nested = kind<{\n readonly target: AnyEntity\n readonly shape: 'one' | 'many' | 'page'\n readonly columns: ReadonlyArray<DisplayColumn>\n}>('Nested', {\n text: (data, value, words) => {\n const one = (item: unknown): string =>\n data.columns\n .filter(column => column.display.shown)\n .map(column =>\n show(\n column.display,\n (item as Readonly<Record<string, unknown>> | null)?.[column.key],\n words,\n ),\n )\n .filter(text => text !== '')\n .join(' ')\n const items =\n data.shape === 'one'\n ? [value]\n : data.shape === 'page'\n ? ((value as { readonly items?: ReadonlyArray<unknown> }).items ?? [])\n : (value as ReadonlyArray<unknown>)\n return items.length === 0 ? (words.nothing ?? '') : items.map(one).join(words.separator ?? ', ')\n },\n})\n\nconst nothing: Record<string, never> = Object.freeze({})\n\nexport const Display = {\n /**\n * A kind of Display. `Display.kind<{ tone: string }>('Badge', { text: (_, value) => String(value) })`\n * gives `.of(data)` to make one and `.is(display)` to tell one, exactly as the\n * kinds below were made. `text` is the floor; a view draws it specially once\n * it is given a renderer for `Badge`.\n */\n kind,\n\n // The kinds this package resolves to. A view finds its renderer by `kind`.\n Text,\n Number: Number_,\n Flag,\n Hidden,\n Ref,\n Nested,\n\n text: (format?: (value: unknown) => string): Display => Text.of({ format }),\n number: (format?: (value: number) => string): Display => Number_.of({ format }),\n flag: (): Display => Flag.of(nothing),\n /** Read, so a row can be opened or keyed by it, and not shown: usually the id. */\n hidden: (): Display => Hidden.of(nothing),\n\n /**\n * Entity metadata: how a member shows wherever it is listed, e.g.\n * `Entity.annotateMembers({ price: Display.of(Display.number(cents => ...)) })`.\n */\n of: (display: Display) => key.of(display),\n\n /**\n * The Display of one selected member, from the most to the least explicit\n * source: the member's `Display.of` metadata, how the relation was selected,\n * then the shape of its schema. `nested` is the columns of a nested Selection,\n * with `shape` saying how many the relation yields.\n */\n resolve: (\n member: EntityMember,\n nested?: {\n readonly shape: 'one' | 'many' | 'page'\n readonly columns: ReadonlyArray<DisplayColumn>\n },\n ): Display => {\n const [explicit] = key.get(member.metadata)\n if (explicit !== undefined) return explicit\n if (member._tag !== 'Relation') return fromSchema(member.schema as Schema.Top)\n const target = member.target()\n return nested === undefined\n ? Ref.of({ target, many: member.cardinality === 'many' })\n : Nested.of({ target, shape: nested.shape, columns: nested.columns })\n },\n\n /**\n * A value as the text its Display calls for: what a cell says when nothing\n * draws it specially. A view that wants a link or a badge reads the Display\n * and the value itself; this is the floor every view can stand on.\n */\n show,\n}\n","/**\n * Sorting a list, written once. How a list is sorted is the application's state\n * and its query's input, so this holds none of it: it is the schema of that\n * state, what a click on a header makes of it, and the shape a drawn table\n * takes. The server reads the same state and decides which columns it means.\n */\nimport { Schema } from 'effect'\n\n/** How a list is sorted: by which of its orders, which way; `null` for the server's own order. */\nexport type SortState<Column extends string> = {\n readonly by: Column\n readonly direction: 'asc' | 'desc'\n} | null\n\n/** How one column is sorted now, and the Message a click on its header sends. */\nexport interface SortedColumn<Message> {\n readonly direction?: 'asc' | 'desc' | undefined\n readonly message: Message\n}\n\nexport const Sort = {\n /**\n * The orders a list offers, by name. A name is an order the server knows, not\n * a column: which columns may sort, and what `title` means in SQL, stay the\n * server's to decide.\n */\n make: <const Columns extends readonly [string, ...string[]]>(columns: Columns) => {\n type Column = Columns[number]\n type State = SortState<Column>\n /** A click on a header: ascending, then descending, then the server's own order again. */\n const toggle = (current: State, column: Column): State =>\n current === null || current.by !== column\n ? { by: column, direction: 'asc' }\n : current.direction === 'asc'\n ? { by: column, direction: 'desc' }\n : null\n return {\n columns,\n /** For the Model field, and for the query's input. */\n Schema: Schema.NullOr(\n Schema.Struct({\n by: Schema.Literals(columns),\n direction: Schema.Literals(['asc', 'desc']),\n }),\n ) as unknown as Schema.Codec<State, State>,\n /** The server's own order. */\n none: null as State,\n toggle,\n /**\n * What a drawn table takes as `sort`: every order with how it is sorted now\n * and the Message a click sends, made from the state the click leads to.\n */\n inputs: <Message>(\n current: State,\n message: (next: State) => Message,\n ): { readonly [K in Column]: SortedColumn<Message> } =>\n Object.fromEntries(\n columns.map(column => [\n column,\n {\n direction: current?.by === column ? current.direction : undefined,\n message: message(toggle(current, column)),\n },\n ]),\n ) as { readonly [K in Column]: SortedColumn<Message> },\n }\n },\n}\n","/**\n * `foldkit-crud` — management screens assembled from parts an application\n * already has.\n *\n * An editor joins a `foldkit-form` form, the Remote mutation its value feeds,\n * and the Entity they share: it loads what the form writes, shows it, turns a\n * valid submit into the mutation, and says how that went. Everything it makes is\n * ordinary Foldkit: a Bundle, an ActiveSurface, Update Steps. Nothing is\n * generated from an Entity alone; each capability is declared.\n */\nimport { Schema } from 'effect'\nimport { Bundle } from 'foldkit-bundle'\nimport {\n Entity,\n SelectionPageTypeId,\n type AnyEntity,\n type EntityInput,\n type EntityMember,\n type Selection,\n type IdOf,\n type SelectionPage,\n} from 'foldkit-entity'\nimport { Form, Input, type FormControl, type Submitted } from 'foldkit-form'\nimport { Display, type DisplayColumn } from './display.js'\nimport type {\n MutationDescriptor,\n Page,\n QueryDescriptor,\n MutationStatus,\n RemoteClient,\n RemoteData,\n RemoteError,\n RemoteMessage,\n} from 'foldkit-remote'\nimport { Projection, type ActiveSurface, type ModelRef } from 'foldkit-surface'\nimport type { Command } from 'foldkit/command'\nimport { defineMessageUnion } from 'foldkit/message'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport * as Submodel from 'foldkit/submodel'\nimport type * as Update from 'foldkit/update'\n\n/** The parts of a `Form.make` result an editor wraps. */\nexport interface EditableForm<\n Name extends string,\n FormModel,\n FormMessage,\n Value,\n E extends AnyEntity,\n Fields extends Schema.Struct.Fields,\n Members,\n R = never,\n> {\n readonly bundle: {\n readonly name: Name\n readonly Model: Schema.Codec<FormModel, unknown>\n readonly Message: Schema.Codec<FormMessage, unknown>\n readonly update: (\n model: FormModel,\n message: FormMessage,\n args: void,\n ) => Update.ReturnWithOutMessage<FormModel, FormMessage, Submitted<Value>, R>\n }\n readonly input: EntityInput<E, Fields, Members>\n readonly initial: FormModel\n readonly fill: (model: FormModel, values: Partial<Value>) => { readonly model: FormModel }\n}\n\n/**\n * An editor's slice of the parent Model. `target` is the id being edited, or\n * `null` for a new one; `filled` is whether the loaded value has been shown;\n * `requestId` is the save in progress or last settled.\n */\nexport interface EditorModel<FormModel> {\n readonly form: FormModel\n readonly mode: 'closed' | 'new' | 'edit'\n readonly target: string | null\n readonly filled: boolean\n readonly requestId: string | null\n}\n\n/**\n * A remover's slice of the parent Model: the id it was asked to delete and is\n * waiting on a yes for, and the delete in progress or last settled.\n */\nexport interface RemoverModel {\n readonly target: string | null\n readonly requestId: string | null\n}\n\n/** A remover's out Message: the user said yes to deleting `id`. */\nexport interface ConfirmedRemoval {\n readonly _tag: 'Confirmed'\n readonly id: string\n}\n\nexport type RemoverStatus =\n | 'Idle'\n /** Asked to delete an id, and waiting for a yes or a no. */\n | 'Confirming'\n | 'Deleting'\n | 'Deleted'\n | 'DeleteFailed'\n\nexport type EditorStatus =\n | 'Closed'\n /** Editing an id whose current values have not arrived. */\n | 'Loading'\n | 'NotFound'\n | 'LoadFailed'\n | 'Editing'\n | 'Saving'\n | 'Saved'\n | 'SaveFailed'\n\n/** The parts of a bound Remote domain an editor uses. */\nexport interface DomainLike<Root> {\n // Method syntax: the descriptors are checked where the editor is made, not here.\n mutate(\n model: Root,\n mutation: any,\n input: any,\n ): {\n readonly model: Root\n readonly requestId: string\n readonly command: Command<RemoteMessage, never, RemoteClient>\n }\n get(selection: any, id: string): Projection<Root, RemoteData<any>>\n query(query: any, input: any, options: any): Projection<Root, RemoteData<Page<any>>>\n next(model: Root, projection: any): { readonly query: string } | undefined\n fetch(ref: any): Command<RemoteMessage, never, RemoteClient>\n refresh(model: Root, target: any): Root\n mutation(model: Root, requestId: string): MutationStatus\n readonly contract: { readonly owner?: object | undefined }\n}\n\ntype Step<Root> = Update.Step<Root, RemoteMessage, RemoteClient>\n\n/** One thing a relation picker offers. */\nexport interface Choice {\n readonly value: string\n readonly label: string\n}\n\n/**\n * One column of a list, or one line of a detail: a member the Selection reads,\n * with its words and its `Display`.\n */\nexport type ListColumn<Key extends string = string> = DisplayColumn<Key>\n\nconst columnLabel = (key: string, member: EntityMember): string => {\n const title =\n member._tag === 'Relation'\n ? undefined\n : Schema.resolveAnnotations(member.schema as Schema.Top)?.title\n return typeof title === 'string' ? title : (Form.labelOf(member) ?? key)\n}\n\ntype AnySelection = Selection<string, unknown, Schema.Constraint>\n\n/** The selected members in the Selection's order, each with its label and its Display. */\nconst columnsOf = <Members>(\n selection: Selection<string, Members, Schema.Constraint>,\n): ReadonlyArray<ListColumn<keyof Members & string>> => {\n const members: Readonly<Record<string, EntityMember>> = selection.entity.members\n const selected = selection.members as Readonly<\n Record<string, true | AnySelection | SelectionPage<string, Schema.Constraint>>\n >\n return Object.keys(selected).map(key => {\n const member = members[key]!\n const how = selected[key]!\n // A relation read through a Selection shows the target's own members.\n const nested =\n how === true || member._tag !== 'Relation'\n ? undefined\n : SelectionPageTypeId in how\n ? { shape: 'page' as const, columns: columnsOf(how.selection) }\n : {\n shape: member.cardinality === 'many' ? ('many' as const) : ('one' as const),\n columns: columnsOf(how),\n }\n return {\n key: key as keyof Members & string,\n label: columnLabel(key, member),\n member,\n display: Display.resolve(member, nested),\n }\n })\n}\n\nconst RemoverMessage = defineMessageUnion({ Confirmed: {}, Cancelled: {} })\ntype RemoverMessage = typeof RemoverMessage.Type\n\nconst idle: RemoverModel = { target: null, requestId: null }\n\nexport const Crud = {\n /**\n * One Entity read through a Selection, for a page that shows it. Like a list\n * it holds no state: the value is Remote's and the id is the application's.\n */\n detail: <const Name extends string, EntityName extends string, Members, Row>(\n name: Name,\n config: {\n readonly selection: Selection<EntityName, Members, Schema.Constraint & { readonly Type: Row }>\n },\n ) => ({\n name,\n /** The selected members in the Selection's order, each with its label. */\n fields: columnsOf(config.selection),\n /** Type-only: the value shown, for a view to be typed by. Never read. */\n Value: undefined as unknown as Row,\n\n /** The detail where it lives: `id` is the one shown, or `undefined` while none is. */\n at: <Root>(where: {\n readonly data: DomainLike<Root>\n readonly id: (root: Root) => string | undefined\n }) => {\n const projectionOf = (root: Root) => {\n const id = where.id(root)\n return id === undefined ? undefined : where.data.get(config.selection, id)\n }\n return {\n /** For `Data.subscriptions`: the value is fetched and retained while an id is shown. */\n active: {\n name,\n owner: where.data.contract.owner ?? {},\n projectionOf,\n } satisfies ActiveSurface<Root>,\n value: (root: Root): RemoteData<Row> =>\n projectionOf(root)?.read(root) ?? { _tag: 'Initial' },\n /**\n * Asks for the value again: `Data.refresh` over this detail, for a retry\n * button. A failed read is not retried on its own. Unchanged while no id\n * is shown.\n */\n refresh: (root: Root): Root => {\n const projection = projectionOf(root)\n return projection === undefined ? root : where.data.refresh(root, projection)\n },\n }\n },\n }),\n\n /**\n * Deleting through one mutation, with a yes in between: asked, confirmed,\n * deleted. What the mutation's input is for an id is `input`'s to say, and the\n * id it names there (`(id: PostId) => ...`) is the id `ask` takes.\n */\n remover: <\n const Name extends string,\n Input,\n Id extends string = string,\n const Key extends keyof Input = never,\n >(\n name: Name,\n config:\n | {\n readonly mutation: MutationDescriptor<string, Input, any>\n readonly input: (id: Id) => Input\n }\n | {\n readonly mutation: MutationDescriptor<string, Input, any>\n /**\n * The key of the mutation's input that holds the id, when that is all the\n * input is: `id: 'id'` for `{ id }`. The id's type is that key's.\n */\n readonly id: Key & (Input extends Readonly<Record<Key, string>> ? Key : never)\n },\n ) => {\n type AskedId = [Key] extends [never] ? Id : Input[Key] & string\n const inputFor = (id: string): Input =>\n 'input' in config ? config.input(id as Id) : ({ [config.id]: id } as Input)\n const bundle = Bundle.make(name, {\n Model: Schema.Struct({\n target: Schema.NullOr(Schema.String),\n requestId: Schema.NullOr(Schema.String),\n }) as unknown as Schema.Codec<RemoverModel, unknown>,\n Message: RemoverMessage,\n init: () => ({ model: idle }),\n update: (model: RemoverModel, message: RemoverMessage) =>\n message._tag === 'Cancelled' || model.target === null\n ? { model: idle }\n : { model, outMessage: { _tag: 'Confirmed', id: model.target } as ConfirmedRemoval },\n helpers: {\n /** Asks whether to delete `id`. Nothing is deleted until `Confirmed`. */\n ask: (_: RemoverModel, id: AskedId) => ({ model: { target: id, requestId: null } }),\n dismiss: () => ({ model: idle }),\n },\n })\n\n return {\n bundle,\n /** The remover's Messages, for the yes and the no of a confirmation. */\n Message: RemoverMessage,\n\n at: <Root>(where: {\n readonly data: DomainLike<Root>\n readonly model: ModelRef<Root, RemoverModel>\n }) => {\n const { data, model: slice } = where\n const outcome = (root: Root): MutationStatus => {\n const { requestId } = slice.get(root)\n return requestId === null ? { _tag: 'Unknown' } : data.mutation(root, requestId)\n }\n return {\n /** For the placement: a yes becomes the mutation, and its request is remembered. */\n onOut:\n (confirmed: ConfirmedRemoval): Step<Root> =>\n root => {\n const started = data.mutate(root, config.mutation, inputFor(confirmed.id))\n return {\n model: slice.set(started.model, {\n target: confirmed.id,\n requestId: started.requestId,\n }),\n commands: [started.command],\n }\n },\n\n /** The id being asked about or deleted, for the words of a confirmation. */\n target: (root: Root): AskedId | null => slice.get(root).target as AskedId | null,\n\n status: (root: Root): RemoverStatus => {\n const { target } = slice.get(root)\n const deleting = outcome(root)\n return deleting._tag === 'Pending'\n ? 'Deleting'\n : deleting._tag === 'Applied'\n ? 'Deleted'\n : deleting._tag === 'Failed'\n ? 'DeleteFailed'\n : target === null\n ? 'Idle'\n : 'Confirming'\n },\n\n /** Why the last delete failed, while `status` is `DeleteFailed`. */\n error: (root: Root): RemoteError | undefined => {\n const deleting = outcome(root)\n return deleting._tag === 'Failed' ? deleting.error : undefined\n },\n }\n },\n }\n },\n\n /**\n * A list over one query: which rows to show is the query's, what to show of\n * each is the Selection's. The pages live in Remote; the list holds no state.\n */\n list: <\n const Name extends string,\n EntityName extends string,\n Members,\n S extends Schema.Constraint,\n Input,\n >(\n name: Name,\n config: {\n readonly query: QueryDescriptor<string, Input, any>\n // The row is the Selection's own value, so it is typed with or without a `choice`.\n readonly selection: Selection<EntityName, Members, S>\n /** How many rows a page holds. Default 25. */\n readonly pageSize?: number\n /**\n * How a row reads as a choice in a relation picker: its id, and the words\n * that identify it to a person. Give it to a list that feeds pickers.\n */\n readonly choice?: {\n readonly value: (row: S['Type']) => string\n readonly label: (row: S['Type']) => string\n }\n },\n ) => {\n const { query, selection, pageSize = 25, choice } = config\n const columns = columnsOf(selection)\n\n return {\n name,\n /** The selected members in the Selection's order, each with its label. */\n columns,\n /** Type-only: a row, for a view to be typed by. Never read. */\n Row: undefined as unknown as S['Type'],\n\n /**\n * The list where it lives. `input` is the query's input as the Model has\n * it (filters, a search term), or `undefined` while the list is not shown.\n */\n at: <Root>(where: {\n readonly data: DomainLike<Root>\n readonly input: (root: Root) => Input | undefined\n }) => {\n const { data, input } = where\n const projectionOf = (root: Root) => {\n const value = input(root)\n return value === undefined\n ? undefined\n : data.query(query, value, { select: selection, first: pageSize })\n }\n const page = (root: Root): RemoteData<Page<S['Type']>> =>\n projectionOf(root)?.read(root) ?? { _tag: 'Initial' }\n\n return {\n /** For `Data.subscriptions`: the page and its rows are fetched and retained while shown. */\n active: {\n name,\n owner: data.contract.owner ?? {},\n projectionOf,\n } satisfies ActiveSurface<Root>,\n\n page,\n\n /** The Command that loads the next page onto this one, or `undefined` when there is none. */\n more: (root: Root): Command<RemoteMessage, never, RemoteClient> | undefined => {\n const projection = projectionOf(root)\n const next = projection === undefined ? undefined : data.next(root, projection)\n return next === undefined ? undefined : data.fetch(next)\n },\n\n /**\n * Asks for the list again: `Data.refresh` over its page and rows, for a\n * retry button. A failed read is not retried on its own. Unchanged while\n * the list is not shown.\n */\n refresh: (root: Root): Root => {\n const projection = projectionOf(root)\n return projection === undefined ? root : data.refresh(root, projection)\n },\n\n name,\n /** Whose requirement the list is, for anything that requires beside it. */\n owner: data.contract.owner ?? {},\n /**\n * One of the list's Entity through the list's Selection, by id, whether or\n * not the query finds it now: what a picker reads to name what is chosen.\n */\n row: (id: string): Projection<Root, RemoteData<any>> => data.get(selection, id),\n /** The Entity the rows are of, which is how a picker finds the list for its target. */\n entity: selection.entity as AnyEntity,\n /** Whether the list was given a `choice`, so its rows can be a picker's choices. */\n offersChoices: choice !== undefined,\n\n /**\n * The loaded rows as a picker's choices, read through `choice`. Listing a\n * relation's target is this query, which the application chose and the\n * server authorizes; nothing is read because a relation exists.\n */\n choices: (root: Root): ReadonlyArray<Choice> => {\n if (choice === undefined)\n throw new Error(`Crud list \"${name}\": give it a \"choice\" to use its rows in a picker`)\n const read = page(root)\n return read._tag === 'Ready' || read._tag === 'Refreshing'\n ? read.value.items.map(row => ({\n value: choice.value(row),\n label: choice.label(row),\n }))\n : []\n },\n\n /** That row as a choice, once it is read. */\n choiceOf: (root: Root, id: string): Choice | undefined => {\n if (choice === undefined) return undefined\n const read = data.get(selection, id).read(root)\n return read._tag === 'Ready' || read._tag === 'Refreshing'\n ? { value: choice.value(read.value), label: choice.label(read.value) }\n : undefined\n },\n }\n },\n }\n },\n\n /**\n * A form's Submodel view as the view of the editor that wraps it, for\n * `Bundle.withView`: the editor's Messages are the form's, and its Model holds\n * the form's under `form`.\n *\n * ```ts\n * Editor.bundle.pipe(Bundle.withView(Crud.editorView(FormView.submodel(form, view))))\n * ```\n */\n editorView: <FormModel, Message, ViewInputs>(\n view: Submodel.View<FormModel, Message, ViewInputs>,\n ): Submodel.View<EditorModel<FormModel>, Message, ViewInputs> =>\n Submodel.defineView<EditorModel<FormModel>, Message, ViewInputs>(((\n model: EditorModel<FormModel>,\n inputs: ViewInputs,\n h: HtmlBuilder<Message>,\n ): Html =>\n (view as (model: FormModel, inputs: ViewInputs, h: HtmlBuilder<Message>) => Html)(\n model.form,\n inputs,\n h,\n )) as never),\n\n /**\n * The choices of every relation picker in a form, from the lists of their\n * targets: `foldkit-mixins-form`'s `options`, keyed by the form's keys. A\n * picker whose target no list here is over is a wiring mistake, reported now.\n *\n * With `chosen`, the form's Model as the page has it, what a picker already\n * holds stays among its choices when the list no longer finds it (a search\n * narrowed it, or it is on a later page), and `active` requires those rows so\n * their words are there. Give `chosen` to any form whose pickers search.\n */\n options: <Key extends string, Root, FormModel = never>(\n form: {\n readonly controls: ReadonlyArray<FormControl<Key>>\n readonly field?: (model: FormModel, key: never) => { readonly value: unknown }\n },\n lists: ReadonlyArray<{\n readonly name: string\n readonly entity: AnyEntity\n readonly offersChoices: boolean\n readonly owner: object\n readonly choices: (root: Root) => ReadonlyArray<Choice>\n readonly row: (id: string) => Projection<Root, RemoteData<any>>\n readonly choiceOf: (root: Root, id: string) => Choice | undefined\n }>,\n options: { readonly chosen?: (root: Root) => FormModel | undefined } = {},\n ) => {\n const pickers = form.controls.flatMap(({ key, control }) => {\n if (!Input.RelationOne.is(control) && !Input.RelationMany.is(control)) return []\n const { target } = control.data\n const list = lists.find(candidate => Entity.same(candidate.entity, target))\n if (list === undefined)\n throw new Error(\n `Crud.options: \"${key}\" picks a ${target.name}, and no list given is over ${target.name}`,\n )\n if (!list.offersChoices)\n throw new Error(\n `Crud.options: \"${key}\" would pick from list \"${list.name}\", which has no \"choice\"`,\n )\n return [[key, list] as const]\n })\n\n /** The ids each picker holds now: the draft of a `one`, or of a `many`. */\n const held = (root: Root): ReadonlyArray<readonly [Key, (typeof lists)[number], string]> => {\n const model = options.chosen?.(root)\n const field = form.field as\n ((model: FormModel, key: string) => { readonly value: unknown }) | undefined\n if (model === undefined || field === undefined) return []\n return pickers.flatMap(([key, list]) => {\n const draft = field(model, key).value\n const ids = Array.isArray(draft) ? draft : typeof draft === 'string' ? [draft] : []\n return ids\n .filter((id): id is string => typeof id === 'string' && id !== '')\n .map(id => [key, list, id] as const)\n })\n }\n\n const choices = (root: Root): { readonly [K in Key]?: ReadonlyArray<Choice> } => {\n const chosen = held(root)\n return Object.fromEntries(\n pickers.map(([key, list]) => {\n const listed = list.choices(root)\n const missing = chosen\n .filter(([heldBy, , id]) => heldBy === key && !listed.some(item => item.value === id))\n .flatMap(([, , id]) => list.choiceOf(root, id) ?? [])\n // What is chosen leads, so it is in reach whatever the list shows.\n return [key, [...missing, ...listed]]\n }),\n ) as unknown as { readonly [K in Key]?: ReadonlyArray<Choice> }\n }\n\n const [first] = lists\n return Object.assign(choices, {\n /** For `Data.subscriptions`: what the pickers hold is read, so it can be named. */\n active: {\n name: `${pickers.map(([key]) => key).join('+')} chosen`,\n owner: first?.owner ?? {},\n projectionOf: (root: Root) => {\n const rows = held(root)\n return rows.length === 0\n ? undefined\n : Projection.struct(\n Object.fromEntries(rows.map(([key, list, id]) => [`${key}:${id}`, list.row(id)])),\n )\n },\n } satisfies ActiveSurface<Root>,\n })\n },\n\n /**\n * What the pieces on a page require of Remote, by the names given: a placed\n * editor, list, or detail, or the pickers from `Crud.options`. It is each one's\n * `active`, gathered, so handing the pieces over is enough and none is left out:\n *\n * ```ts\n * Data.wiring(Crud.actives({ posts: Posts, authors: Authors, editor: PostEditor, pickers }))\n * ```\n */\n actives: <const Pieces extends Readonly<Record<string, { readonly active: unknown }>>>(\n pieces: Pieces,\n ): { readonly [K in keyof Pieces]: Pieces[K]['active'] } =>\n Object.fromEntries(Object.entries(pieces).map(([name, piece]) => [name, piece.active])) as {\n readonly [K in keyof Pieces]: Pieces[K]['active']\n },\n\n /**\n * An editor for one form and the mutation its value feeds. The form's value\n * must be the mutation's input, which is what declaring the input once and\n * giving it to both guarantees.\n */\n editor: <\n const Name extends string,\n FormName extends string,\n FormModel,\n FormMessage extends { readonly _tag: string },\n Value,\n E extends AnyEntity,\n Fields extends Schema.Struct.Fields,\n Members,\n R = never,\n >(\n name: Name,\n config: {\n readonly form: EditableForm<FormName, FormModel, FormMessage, Value, E, Fields, Members, R>\n readonly mutation: MutationDescriptor<string, Value, any>\n },\n ) => {\n type Model = EditorModel<FormModel>\n const { form, mutation } = config\n\n const closed: Model = {\n form: form.initial,\n mode: 'closed',\n target: null,\n filled: false,\n requestId: null,\n }\n const Model = Schema.Struct({\n form: form.bundle.Model,\n mode: Schema.Literals(['closed', 'new', 'edit']),\n target: Schema.NullOr(Schema.String),\n filled: Schema.Boolean,\n requestId: Schema.NullOr(Schema.String),\n }) as unknown as Schema.Codec<Model, unknown>\n\n // The editor's Messages are the form's own: it adds state around the form,\n // not a second vocabulary.\n const bundle = Bundle.make(name, {\n Model,\n Message: form.bundle.Message,\n init: () => ({ model: closed }),\n update: (model: Model, message: FormMessage) => {\n const next = form.bundle.update(model.form, message, undefined)\n // An edit after a save starts a new round; the last save no longer describes the form.\n const requestId = message._tag === 'Changed' ? null : model.requestId\n // The form's Commands are the editor's: a check the form started has to run.\n const edited = {\n model: { ...model, form: next.model, requestId },\n ...(next.commands === undefined ? {} : { commands: next.commands }),\n }\n return next.outMessage === undefined ? edited : { ...edited, outMessage: next.outMessage }\n },\n helpers: {\n /** Edits `id`: the form is emptied, and filled once the current values arrive. */\n open: (_: Model, id: IdOf<E>) => ({\n model: { ...closed, mode: 'edit' as const, target: id },\n }),\n /** A blank form for a new one: nothing to load. */\n blank: () => ({ model: { ...closed, mode: 'new' as const, filled: true } }),\n close: () => ({ model: closed }),\n },\n })\n\n const current = Entity.selectFor(form.input)\n\n return {\n bundle,\n /** What the editor loads before it shows the form: every member the form writes. */\n selection: current,\n\n /**\n * The editor where it lives: `model` is its slice of the parent Model (the\n * field it was declared at), and `data` the Remote domain that registers the\n * mutation and the Entity.\n */\n at: <Root>(where: {\n readonly data: DomainLike<Root>\n readonly model: ModelRef<Root, Model>\n }) => {\n const { data, model: slice } = where\n const loaded = (root: Root): RemoteData<any> | undefined => {\n const { mode, target } = slice.get(root)\n return mode === 'edit' && target !== null\n ? data.get(current, target).read(root)\n : undefined\n }\n\n /** Shows the loaded value once, the first time it is there. Later refreshes leave the drafts alone. */\n const sync: Update.Step<Root, never, never> = root => {\n const editor = slice.get(root)\n const read = loaded(root)\n if (editor.filled || read === undefined) return { model: root }\n if (read._tag !== 'Ready' && read._tag !== 'Refreshing') return { model: root }\n const values = Entity.valuesFor(form.input, read.value) as Partial<Value>\n return {\n model: slice.set(root, {\n ...editor,\n form: form.fill(editor.form, values).model,\n filled: true,\n }),\n }\n }\n\n const saveOf = (root: Root): MutationStatus => {\n const { requestId } = slice.get(root)\n return requestId === null ? { _tag: 'Unknown' } : data.mutation(root, requestId)\n }\n\n return {\n /** For the placement: a valid submit becomes the mutation, and its request is remembered. */\n onOut:\n (submitted: Submitted<Value>): Step<Root> =>\n root => {\n const started = data.mutate(root, mutation, submitted.value)\n const editor = slice.get(started.model)\n return {\n model: slice.set(started.model, { ...editor, requestId: started.requestId }),\n commands: [started.command],\n }\n },\n\n /**\n * For `Data.subscriptions`: while an id is being edited, what it loads is\n * a requirement like any Surface's, so Remote fetches and retains it.\n */\n active: {\n name,\n owner: data.contract.owner ?? {},\n projectionOf: root => {\n const { mode, target } = slice.get(root)\n return mode === 'edit' && target !== null ? data.get(current, target) : undefined\n },\n } satisfies ActiveSurface<Root>,\n\n sync,\n\n /**\n * Wraps the application's `update` so `sync` runs after every Message:\n * the value may arrive with any of them.\n */\n after:\n <Message, Result extends { readonly model: Root }>(\n update: (model: Root, message: Message) => Result,\n ) =>\n (model: Root, message: Message): Result => {\n const next = update(model, message)\n return { ...next, model: sync(next.model).model }\n },\n\n /** Why the last save failed, while `status` is `SaveFailed`. */\n saveError: (root: Root): RemoteError | undefined => {\n const save = saveOf(root)\n return save._tag === 'Failed' ? save.error : undefined\n },\n\n /** The id being edited, typed as the Entity's own; `null` for a new one or a closed editor. */\n target: (root: Root): IdOf<E> | null => slice.get(root).target as IdOf<E> | null,\n status: (root: Root): EditorStatus => {\n const editor = slice.get(root)\n if (editor.mode === 'closed') return 'Closed'\n // Gone outranks everything: a save that landed describes a thing that no longer exists.\n const read = loaded(root)\n if (read?._tag === 'NotFound') return 'NotFound'\n const save = saveOf(root)\n if (save._tag === 'Pending') return 'Saving'\n if (save._tag === 'Failed') return 'SaveFailed'\n if (save._tag === 'Applied') return 'Saved'\n if (editor.filled) return 'Editing'\n return read?._tag === 'Failed' ? 'LoadFailed' : 'Loading'\n },\n }\n },\n }\n },\n}\n\nexport { Display, type DisplayColumn, type DisplayKind, type DisplayWords } from './display.js'\nexport { Sort, type SortState, type SortedColumn } from './sort.js'\n"],"mappings":";;;;;;;;;;;;;;;AAyDA,MAAM,MAAM,SAAS,IAAa,wBAAwB;CAExD,QAAO,aAAY,SAAS,MAAM,EAAE;CACpC,YAAW,YAAW,QAAQ;AAChC,CAAC;AAOD,MAAM,cAAc,WAAgC;CAClD,MAAM,MAAM,OAAO,OAAO,MAAM,CAAC,CAAC;CAClC,MAAM,UACJ,IAAI,SAAS,WACR,IAAI,SAAS,CAAC,EAAA,CAAG,QAAO,WAAU,OAAO,SAAS,UAAU,OAAO,SAAS,WAAW,IACxF,CAAC,GAAG;CACV,MAAM,CAAC,QAAQ;CACf,IAAI,QAAQ,WAAW,KAAK,MAAM,SAAS,UAAU,OAAO,QAAQ,GAAG,CAAC,CAAC;CACzE,IAAI,QAAQ,WAAW,KAAK,MAAM,SAAS,WAAW,OAAO,KAAK,GAAG,OAAO;CAC5E,OAAO,KAAK,GAAG,CAAC,CAAC;AACnB;;AAGA,MAAM,QACJ,MACA,UAIuB;CACvB,MAAM;CACN,KAAI,SACF,OAAO,OAAO;EACZ,MAAM;EACN,OAAO,KAAK,SAAS;EACrB;EACA,OAAO,OAAgB,UAAwB,KAAK,KAAK,MAAM,OAAO,KAAK;CAC7E,CAAC;CACH,KAAK,YAAsC,QAAQ,SAAS;AAC9D;AAEA,MAAM,QAAQ,SAAkB,OAAgB,QAAsB,CAAC,MACrE,UAAU,QAAQ,UAAU,KAAA,IAAa,MAAM,WAAW,KAAM,QAAQ,KAAK,OAAO,KAAK;AAE3F,MAAM,OAAO,KAAqE,QAAQ,EACxF,OAAO,MAAM,UAAW,KAAK,WAAW,KAAA,IAAY,OAAO,KAAK,IAAI,KAAK,O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AAQ;OAAU,CAAC;OAC3E,UAAU,CAAC,QAAQ,OAAO;MAC5B;KACF;;;;;KAMF,QAAQ;MACN;MACA,OAAO,KAAK,SAAS,SAAS,CAAC;MAC/B,eAAc,SAAQ;OACpB,MAAM,EAAE,MAAM,WAAW,MAAM,IAAI,IAAI;OACvC,OAAO,SAAS,UAAU,WAAW,OAAO,KAAK,IAAI,SAAS,MAAM,IAAI,KAAA;MAC1E;KACF;KAEA;;;;;KAMA,QAEI,YAED,OAAa,YAA6B;MACzC,MAAM,OAAO,OAAO,OAAO,OAAO;MAClC,OAAO;OAAE,GAAG;OAAM,OAAO,KAAK,KAAK,KAAK,CAAC,CAAC;MAAM;KAClD;;KAGF,YAAY,SAAwC;MAClD,MAAM,OAAO,OAAO,IAAI;MACxB,OAAO,KAAK,SAAS,WAAW,KAAK,QAAQ,KAAA;KAC/C;;KAGA,SAAS,SAA+B,MAAM,IAAI,IAAI,CAAC,CAAC;KACxD,SAAS,SAA6B;MACpC,MAAM,SAAS,MAAM,IAAI,IAAI;MAC7B,IAAI,OAAO,SAAS,UAAU,OAAO;MAErC,MAAM,OAAO,OAAO,IAAI;MACxB,IAAI,MAAM,SAAS,YAAY,OAAO;MACtC,MAAM,OAAO,OAAO,IAAI;MACxB,IAAI,KAAK,SAAS,WAAW,OAAO;MACpC,IAAI,KAAK,SAAS,UAAU,OAAO;MACnC,IAAI,KAAK,SAAS,WAAW,OAAO;MACpC,IAAI,OAAO,QAAQ,OAAO;MAC1B,OAAO,MAAM,SAAS,WAAW,eAAe;KAClD;IACF;GACF;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-crud",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Create, read, update and delete screens for Foldkit Plus, assembled from a form, a Remote operation, and the Entity they share. Each capability is declared, never implied.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -40,10 +40,11 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"foldkit-bundle": "0.2.0",
|
|
43
|
-
"foldkit-entity": "0.
|
|
44
|
-
"foldkit-
|
|
45
|
-
"foldkit-
|
|
46
|
-
"foldkit-
|
|
43
|
+
"foldkit-entity": "0.3.0",
|
|
44
|
+
"foldkit-metadata": "0.1.0",
|
|
45
|
+
"foldkit-surface": "0.4.0",
|
|
46
|
+
"foldkit-form": "0.1.2",
|
|
47
|
+
"foldkit-remote": "0.6.0"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
50
|
"effect": "^4.0.0-rc.112",
|