@niscorp/nova 0.2.0 → 0.2.1
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/CHANGELOG.md +48 -0
- package/README.md +56 -13
- package/SHELL_DOCS.md +13 -4
- package/dist/adapters/dom/index.cjs.map +1 -1
- package/dist/adapters/dom/index.js +2 -2
- package/dist/adapters/dom/server.js +2 -2
- package/dist/adapters/react/components/index.js +3 -3
- package/dist/adapters/react/index.cjs.map +1 -1
- package/dist/adapters/react/index.js +3 -3
- package/dist/adapters/tty/index.js +1 -1
- package/dist/adapters/vue/components/index.js +3 -3
- package/dist/adapters/vue/index.cjs.map +1 -1
- package/dist/adapters/vue/index.js +4 -4
- package/dist/{chunk-RYIIIXDX.js → chunk-DU2VIJAF.js} +57 -15
- package/dist/chunk-DU2VIJAF.js.map +1 -0
- package/dist/{chunk-VU6NNCEJ.js → chunk-F2H7WP6R.js} +4 -4
- package/dist/{chunk-VU6NNCEJ.js.map → chunk-F2H7WP6R.js.map} +1 -1
- package/dist/{chunk-QXQCPH33.js → chunk-G4LSLLGI.js} +4 -4
- package/dist/{chunk-QXQCPH33.js.map → chunk-G4LSLLGI.js.map} +1 -1
- package/dist/{chunk-MHW5VEIM.js → chunk-SVNK5NIK.js} +3 -3
- package/dist/{chunk-MHW5VEIM.js.map → chunk-SVNK5NIK.js.map} +1 -1
- package/dist/{chunk-UDCXGDLQ.js → chunk-VOD5JA4D.js} +3 -3
- package/dist/{chunk-UDCXGDLQ.js.map → chunk-VOD5JA4D.js.map} +1 -1
- package/dist/chunk-XQTI4Q4I.js +178 -0
- package/dist/chunk-XQTI4Q4I.js.map +1 -0
- package/dist/examples/index.cjs +1186 -0
- package/dist/examples/index.cjs.map +1 -0
- package/dist/examples/index.d.cts +63 -0
- package/dist/examples/index.d.ts +63 -0
- package/dist/examples/index.js +1158 -0
- package/dist/examples/index.js.map +1 -0
- package/dist/i18n/index.js +2 -176
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.cjs +55 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/package.json +19 -8
- package/dist/chunk-RYIIIXDX.js.map +0 -1
|
@@ -0,0 +1,1186 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/examples/actions.ts
|
|
4
|
+
var ACTION_EXAMPLES = [
|
|
5
|
+
{
|
|
6
|
+
id: "counter",
|
|
7
|
+
group: "actions",
|
|
8
|
+
title: "Counter",
|
|
9
|
+
description: "An action with `count` in its data and two triggers. A press on a button is a `ui:click` on its `ref`; the trigger for that `ref` changes the data, and the text over it is drawn again.",
|
|
10
|
+
action: {
|
|
11
|
+
id: "counter",
|
|
12
|
+
data: { count: 0 },
|
|
13
|
+
layout: {
|
|
14
|
+
component: "Stack",
|
|
15
|
+
children: [
|
|
16
|
+
{ component: "Text", children: "Count: {{$.count}}" },
|
|
17
|
+
{ component: "Button", ref: "more", children: "One more" },
|
|
18
|
+
{ component: "Button", ref: "fewer", children: "One fewer" }
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
triggers: [
|
|
22
|
+
{ event: "ui:click", ref: "more", do: [{ increment: "count" }] },
|
|
23
|
+
{ event: "ui:click", ref: "fewer", do: [{ decrement: "count" }] }
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
presses: [{ ref: "more" }, { ref: "more" }, { ref: "fewer" }],
|
|
27
|
+
expected: { says: ["Count: 1", "One more", "One fewer"], data: { count: 1 } }
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "toggle",
|
|
31
|
+
group: "actions",
|
|
32
|
+
title: "Toggle",
|
|
33
|
+
description: "`toggle` flips a boolean. The layout draws a line only while it is true.",
|
|
34
|
+
action: {
|
|
35
|
+
id: "toggle",
|
|
36
|
+
data: { open: false },
|
|
37
|
+
layout: {
|
|
38
|
+
component: "Stack",
|
|
39
|
+
children: [
|
|
40
|
+
{ component: "Button", ref: "flip", children: "Details" },
|
|
41
|
+
{ if: "$.open", then: { component: "Text", children: "Doors open half an hour before." } }
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
triggers: [{ event: "ui:click", ref: "flip", do: [{ toggle: "open" }] }]
|
|
45
|
+
},
|
|
46
|
+
presses: [{ ref: "flip" }],
|
|
47
|
+
expected: { says: ["Details", "Doors open half an hour before."], data: { open: true } }
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: "list",
|
|
51
|
+
group: "actions",
|
|
52
|
+
title: "List",
|
|
53
|
+
description: "`push` adds to the end of a list and `removeAt` takes out the element at a position. The loop over the list follows.",
|
|
54
|
+
action: {
|
|
55
|
+
id: "list",
|
|
56
|
+
data: { guests: ["Ada", "Grace"] },
|
|
57
|
+
layout: {
|
|
58
|
+
component: "Stack",
|
|
59
|
+
children: [
|
|
60
|
+
{ for: "$.guests", as: "guest", do: { component: "Text", children: "$guest" } },
|
|
61
|
+
{ component: "Button", ref: "add", children: "Add Linus" },
|
|
62
|
+
{ component: "Button", ref: "first", children: "Remove the first" }
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
triggers: [
|
|
66
|
+
{ event: "ui:click", ref: "add", do: [{ push: "guests", value: "Linus" }] },
|
|
67
|
+
{ event: "ui:click", ref: "first", do: [{ removeAt: "guests", index: 0 }] }
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
presses: [{ ref: "add" }, { ref: "first" }],
|
|
71
|
+
expected: { says: ["Grace", "Linus", "Add Linus", "Remove the first"], data: { guests: ["Grace", "Linus"] } }
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "input-model",
|
|
75
|
+
group: "actions",
|
|
76
|
+
title: "Input model",
|
|
77
|
+
description: "`model` binds a component to a path both ways: it shows what stands there, and what is typed is written back. No trigger is needed.",
|
|
78
|
+
action: {
|
|
79
|
+
id: "input-model",
|
|
80
|
+
data: { name: "" },
|
|
81
|
+
layout: {
|
|
82
|
+
component: "Stack",
|
|
83
|
+
children: [
|
|
84
|
+
{ component: "Input", ref: "name", model: "$.name", props: { placeholder: "Your name" } },
|
|
85
|
+
{ component: "Text", children: "Hello, {{$.name}}." }
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
presses: [{ ref: "name", type: "ui:model", payload: "Ada" }],
|
|
90
|
+
expected: { says: ["Your name", "Hello, Ada."], data: { name: "Ada" } }
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: "lifecycle",
|
|
94
|
+
group: "actions",
|
|
95
|
+
title: "Lifecycle",
|
|
96
|
+
description: "The steps under `lifecycle.mount` run once, when the action is put on a canvas, before anything is pressed.",
|
|
97
|
+
action: {
|
|
98
|
+
id: "lifecycle",
|
|
99
|
+
data: { status: "waiting" },
|
|
100
|
+
layout: { component: "Text", children: "This action is {{$.status}}." },
|
|
101
|
+
lifecycle: { mount: [{ set: "status", value: "on its canvas" }] }
|
|
102
|
+
},
|
|
103
|
+
presses: [],
|
|
104
|
+
expected: { says: ["This action is on its canvas."], data: { status: "on its canvas" } }
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "reset",
|
|
108
|
+
group: "actions",
|
|
109
|
+
title: "Reset",
|
|
110
|
+
description: "`reset` gives a path back the value it had when the action was opened.",
|
|
111
|
+
action: {
|
|
112
|
+
id: "reset",
|
|
113
|
+
data: { greeting: "Dear Ada" },
|
|
114
|
+
layout: {
|
|
115
|
+
component: "Stack",
|
|
116
|
+
children: [
|
|
117
|
+
{ component: "Text", children: "$.greeting" },
|
|
118
|
+
{ component: "Button", ref: "change", children: "Say hello" },
|
|
119
|
+
{ component: "Button", ref: "back", children: "As it was" }
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
triggers: [
|
|
123
|
+
{ event: "ui:click", ref: "change", do: [{ set: "greeting", value: "Hello, Ada" }] },
|
|
124
|
+
{ event: "ui:click", ref: "back", do: [{ reset: "greeting" }] }
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
presses: [{ ref: "change" }, { ref: "back" }],
|
|
128
|
+
expected: { says: ["Dear Ada", "Say hello", "As it was"], data: { greeting: "Dear Ada" } }
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
// src/examples/composition.ts
|
|
133
|
+
var COMPOSITION_EXAMPLES = [
|
|
134
|
+
{
|
|
135
|
+
id: "slot-fill",
|
|
136
|
+
group: "composition",
|
|
137
|
+
title: "Slot fill",
|
|
138
|
+
description: 'A fragment is chrome with a hole in it, `{ slot: "body" }`. An action opened `with` the fragment has its own layout put into the hole. The action does not mention the frame: whoever opens it decides, so the same action stands framed on one canvas and bare on the other.',
|
|
139
|
+
fragments: {
|
|
140
|
+
"slot-fill.frame": {
|
|
141
|
+
kind: "fragment",
|
|
142
|
+
id: "slot-fill.frame",
|
|
143
|
+
layout: { component: "Stack", children: [{ component: "Text", children: "Tonight" }, { slot: "body" }, { component: "Text", children: "Doors at 19:00" }] }
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
shell: {
|
|
147
|
+
canvases: [
|
|
148
|
+
{ id: "slot-fill.framed", initial: { action: "slot-fill.show", with: ["slot-fill.frame"] } },
|
|
149
|
+
{ id: "slot-fill.bare", initial: "slot-fill.show" }
|
|
150
|
+
],
|
|
151
|
+
actions: { "slot-fill.show": { id: "slot-fill.show", data: { title: "The Tempest" }, layout: { component: "Text", children: "$.title" } } }
|
|
152
|
+
},
|
|
153
|
+
presses: [],
|
|
154
|
+
expected: { says: ["Tonight", "The Tempest", "Doors at 19:00", "The Tempest"], stacks: { "slot-fill.framed": ["slot-fill.show"], "slot-fill.bare": ["slot-fill.show"] } }
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: "reuse",
|
|
158
|
+
group: "composition",
|
|
159
|
+
title: "Reuse",
|
|
160
|
+
description: "One frame around many actions. Each action is opened `with` the same fragment, and the frame\u2019s heading reads each action\u2019s own `label`. Change the fragment and all of them change.",
|
|
161
|
+
fragments: {
|
|
162
|
+
"reuse.tile": { kind: "fragment", id: "reuse.tile", layout: { component: "Stack", children: [{ component: "Text", children: "$.label" }, { slot: "body" }] } }
|
|
163
|
+
},
|
|
164
|
+
shell: {
|
|
165
|
+
canvases: [
|
|
166
|
+
{ id: "reuse.first", initial: { action: "reuse.sold", with: ["reuse.tile"] } },
|
|
167
|
+
{ id: "reuse.second", initial: { action: "reuse.free", with: ["reuse.tile"] } }
|
|
168
|
+
],
|
|
169
|
+
actions: {
|
|
170
|
+
"reuse.sold": { id: "reuse.sold", data: { label: "Sold", seats: 212 }, layout: { component: "Text", children: "{{$.seats}} seats" } },
|
|
171
|
+
"reuse.free": { id: "reuse.free", data: { label: "Free", rows: ["C", "F"] }, layout: { component: "Stack", children: [{ for: "$.rows", as: "row", do: { component: "Text", children: "Row {{$row}}" } }] } }
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
presses: [],
|
|
175
|
+
expected: { says: ["Sold", "212 seats", "Free", "Row C", "Row F"], stacks: { "reuse.first": ["reuse.sold"], "reuse.second": ["reuse.free"] } }
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: "merge-rules",
|
|
179
|
+
group: "composition",
|
|
180
|
+
title: "Merge rules",
|
|
181
|
+
description: "A fragment brings more than layout. Its `data` is merged under the action\u2019s, so where both name a key the action\u2019s value stands. Its `triggers` are added to the action\u2019s, so both sets answer on the one instance.",
|
|
182
|
+
fragments: {
|
|
183
|
+
"merge-rules.star": {
|
|
184
|
+
kind: "fragment",
|
|
185
|
+
id: "merge-rules.star",
|
|
186
|
+
data: { title: "Untitled", starred: false },
|
|
187
|
+
layout: { component: "Stack", children: [{ slot: "body" }, { component: "Button", ref: "star", children: "Star" }] },
|
|
188
|
+
triggers: [{ event: "ui:click", ref: "star", do: [{ toggle: "starred" }] }]
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
shell: {
|
|
192
|
+
canvases: [{ id: "merge-rules.main", initial: { action: "merge-rules.show", with: ["merge-rules.star"] } }],
|
|
193
|
+
actions: {
|
|
194
|
+
"merge-rules.show": {
|
|
195
|
+
id: "merge-rules.show",
|
|
196
|
+
data: { title: "The Tempest", liked: false },
|
|
197
|
+
layout: {
|
|
198
|
+
component: "Stack",
|
|
199
|
+
children: [
|
|
200
|
+
{ component: "Text", children: "$.title" },
|
|
201
|
+
{ component: "Text", children: "starred: {{$.starred}}, liked: {{$.liked}}" },
|
|
202
|
+
{ component: "Button", ref: "like", children: "Like" }
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
triggers: [{ event: "ui:click", ref: "like", do: [{ toggle: "liked" }] }]
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
presses: [{ ref: "star" }, { ref: "like" }],
|
|
210
|
+
expected: { says: ["The Tempest", "starred: true, liked: true", "Like", "Star"], stacks: { "merge-rules.main": ["merge-rules.show"] } }
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: "stacking",
|
|
214
|
+
group: "composition",
|
|
215
|
+
title: "Stacking",
|
|
216
|
+
description: "`with` takes a list. Each fragment wraps what the ones before it made, so the last one named ends up outermost.",
|
|
217
|
+
fragments: {
|
|
218
|
+
"stacking.inner": {
|
|
219
|
+
kind: "fragment",
|
|
220
|
+
id: "stacking.inner",
|
|
221
|
+
layout: { component: "Stack", children: [{ component: "Text", children: "inner begins" }, { slot: "body" }, { component: "Text", children: "inner ends" }] }
|
|
222
|
+
},
|
|
223
|
+
"stacking.outer": {
|
|
224
|
+
kind: "fragment",
|
|
225
|
+
id: "stacking.outer",
|
|
226
|
+
layout: { component: "Stack", children: [{ component: "Text", children: "outer begins" }, { slot: "body" }, { component: "Text", children: "outer ends" }] }
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
shell: {
|
|
230
|
+
canvases: [{ id: "stacking.main", initial: { action: "stacking.core", with: ["stacking.inner", "stacking.outer"] } }],
|
|
231
|
+
actions: { "stacking.core": { id: "stacking.core", layout: { component: "Text", children: "the action" } } }
|
|
232
|
+
},
|
|
233
|
+
presses: [],
|
|
234
|
+
expected: { says: ["outer begins", "inner begins", "the action", "inner ends", "outer ends"], stacks: { "stacking.main": ["stacking.core"] } }
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
id: "modal",
|
|
238
|
+
group: "composition",
|
|
239
|
+
title: "Modal",
|
|
240
|
+
description: "A dialog is an action pushed onto a canvas of its own, opened `with` a fragment that carries the frame and its Cancel. The form inside knows nothing of the frame. Saving says so on a channel the page listens to, and closes itself.",
|
|
241
|
+
fragments: {
|
|
242
|
+
"modal.frame": {
|
|
243
|
+
kind: "fragment",
|
|
244
|
+
id: "modal.frame",
|
|
245
|
+
layout: { component: "Stack", children: [{ component: "Text", children: "New guest" }, { slot: "body" }, { component: "Button", ref: "cancel", children: "Cancel" }] },
|
|
246
|
+
triggers: [{ event: "ui:click", ref: "cancel", do: [{ pop: true }] }]
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
shell: {
|
|
250
|
+
canvases: [{ id: "modal.page", initial: "modal.guests" }, { id: "modal.over" }],
|
|
251
|
+
actions: {
|
|
252
|
+
"modal.guests": {
|
|
253
|
+
id: "modal.guests",
|
|
254
|
+
data: { guests: ["Ada"] },
|
|
255
|
+
layout: {
|
|
256
|
+
component: "Stack",
|
|
257
|
+
children: [
|
|
258
|
+
{ component: "Text", children: "Guests" },
|
|
259
|
+
{ for: "$.guests", as: "guest", do: { component: "Text", children: "$guest" } },
|
|
260
|
+
{ component: "Button", ref: "new", children: "Add a guest" }
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
triggers: [
|
|
264
|
+
{ event: "ui:click", ref: "new", do: [{ push: { action: "modal.form", canvas: "modal.over", with: ["modal.frame"] } }] },
|
|
265
|
+
{ message: "modal.saved", do: [{ push: "guests", value: "@event.payload" }] }
|
|
266
|
+
]
|
|
267
|
+
},
|
|
268
|
+
"modal.form": {
|
|
269
|
+
id: "modal.form",
|
|
270
|
+
data: { name: "" },
|
|
271
|
+
layout: {
|
|
272
|
+
component: "Stack",
|
|
273
|
+
children: [
|
|
274
|
+
{ component: "Input", ref: "name", model: "$.name", props: { placeholder: "Their name" } },
|
|
275
|
+
{ component: "Button", ref: "save", children: "Save" }
|
|
276
|
+
]
|
|
277
|
+
},
|
|
278
|
+
triggers: [{ event: "ui:click", ref: "save", do: [{ emit: { channel: "modal.saved", payload: "$.name" } }, { pop: true }] }]
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
presses: [{ ref: "new" }, { canvas: "modal.over", ref: "name", type: "ui:model", payload: "Grace" }, { canvas: "modal.over", ref: "save" }],
|
|
283
|
+
expected: { says: ["Guests", "Ada", "Grace", "Add a guest"], stacks: { "modal.page": ["modal.guests"], "modal.over": [] } }
|
|
284
|
+
}
|
|
285
|
+
];
|
|
286
|
+
|
|
287
|
+
// src/examples/endpoints.ts
|
|
288
|
+
var ENDPOINT_EXAMPLES = [
|
|
289
|
+
{
|
|
290
|
+
id: "function-endpoint",
|
|
291
|
+
group: "endpoints",
|
|
292
|
+
title: "Function endpoint",
|
|
293
|
+
description: "An endpoint that names a function its host has registered. `call` runs it with the action\u2019s data, and what it answers is written to the endpoint\u2019s `target`.",
|
|
294
|
+
replies: { "function-endpoint.total": { seats: 3, price: 114 } },
|
|
295
|
+
action: {
|
|
296
|
+
id: "function-endpoint",
|
|
297
|
+
data: { total: { seats: 0, price: 0 } },
|
|
298
|
+
layout: {
|
|
299
|
+
component: "Stack",
|
|
300
|
+
children: [
|
|
301
|
+
{ component: "Text", children: "{{$.total.seats}} seats, {{$.total.price}} in all" },
|
|
302
|
+
{ component: "Button", ref: "add", children: "Add it up" }
|
|
303
|
+
]
|
|
304
|
+
},
|
|
305
|
+
endpoints: { total: { fn: "function-endpoint.total", target: "total" } },
|
|
306
|
+
triggers: [{ event: "ui:click", ref: "add", do: [{ call: "total" }] }]
|
|
307
|
+
},
|
|
308
|
+
presses: [{ ref: "add" }],
|
|
309
|
+
expected: { says: ["3 seats, 114 in all", "Add it up"], data: { total: { seats: 3, price: 114 } } }
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
id: "http-endpoint",
|
|
313
|
+
group: "endpoints",
|
|
314
|
+
title: "HTTP endpoint",
|
|
315
|
+
description: "An endpoint that names a URL. The address is a template over the action\u2019s data, and `onSuccess` runs once the answer has been written to `target`.",
|
|
316
|
+
fetches: { "GET /examples/http-endpoint/members/m1": { status: 200, body: { name: "Ada", pass: "season" } } },
|
|
317
|
+
action: {
|
|
318
|
+
id: "http-endpoint",
|
|
319
|
+
data: { id: "m1", state: "not asked", member: { name: "", pass: "" } },
|
|
320
|
+
layout: {
|
|
321
|
+
component: "Stack",
|
|
322
|
+
children: [
|
|
323
|
+
{ component: "Text", children: "State: {{$.state}}" },
|
|
324
|
+
{ if: "$.member.name", then: { component: "Text", children: "{{$.member.name}} has a {{$.member.pass}} pass." } },
|
|
325
|
+
{ component: "Button", ref: "load", children: "Look the member up" }
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
endpoints: { member: { url: "/examples/http-endpoint/members/{{$.id}}", method: "GET", target: "member" } },
|
|
329
|
+
triggers: [{ event: "ui:click", ref: "load", do: [{ set: "state", value: "asking" }, { call: "member", onSuccess: [{ set: "state", value: "answered" }] }] }]
|
|
330
|
+
},
|
|
331
|
+
presses: [{ ref: "load" }],
|
|
332
|
+
expected: { says: ["State: answered", "Ada has a season pass.", "Look the member up"], data: { id: "m1", state: "answered", member: { name: "Ada", pass: "season" } }, asked: [{ method: "GET", url: "/examples/http-endpoint/members/m1" }] }
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
id: "endpoint-error",
|
|
336
|
+
group: "endpoints",
|
|
337
|
+
title: "Endpoint error",
|
|
338
|
+
description: "A call that fails runs its `onError` steps and no others. Inside them `@error` is what went wrong: its `status`, and a `message`.",
|
|
339
|
+
fetches: { "POST /examples/endpoint-error/bookings": { status: 409, body: { message: "That seat has just been taken." } } },
|
|
340
|
+
action: {
|
|
341
|
+
id: "endpoint-error",
|
|
342
|
+
data: { booked: false, problem: "", status: 0 },
|
|
343
|
+
layout: {
|
|
344
|
+
component: "Stack",
|
|
345
|
+
children: [
|
|
346
|
+
{ if: "$.booked", then: { component: "Text", children: "Booked." } },
|
|
347
|
+
{ if: "$.problem", then: { component: "Text", children: "{{$.status}}: {{$.problem}}" } },
|
|
348
|
+
{ component: "Button", ref: "book", children: "Book seat C4" }
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
endpoints: { book: { url: "/examples/endpoint-error/bookings", method: "POST" } },
|
|
352
|
+
triggers: [
|
|
353
|
+
{
|
|
354
|
+
event: "ui:click",
|
|
355
|
+
ref: "book",
|
|
356
|
+
do: [
|
|
357
|
+
{
|
|
358
|
+
call: "book",
|
|
359
|
+
onSuccess: [{ set: "booked", value: true }],
|
|
360
|
+
onError: [
|
|
361
|
+
{ set: "problem", value: "{{@error.message}}" },
|
|
362
|
+
{ set: "status", value: "{{@error.status}}" }
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
]
|
|
366
|
+
}
|
|
367
|
+
]
|
|
368
|
+
},
|
|
369
|
+
presses: [{ ref: "book" }],
|
|
370
|
+
expected: { says: ["409: That seat has just been taken.", "Book seat C4"], data: { booked: false, problem: "That seat has just been taken.", status: 409 }, asked: [{ method: "POST", url: "/examples/endpoint-error/bookings" }] }
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
id: "endpoint-request",
|
|
374
|
+
group: "endpoints",
|
|
375
|
+
title: "Request and headers",
|
|
376
|
+
description: "What is sent is declared on the endpoint. A header is a template over the action\u2019s data, and `request` is a transform that builds the body from that data, so nothing but what it names leaves the action. `response` is a transform over what comes back, before it is written to `target`.",
|
|
377
|
+
fetches: { "POST /examples/endpoint-request/bookings": { status: 200, body: { id: "B-2041", seats: 2 } } },
|
|
378
|
+
action: {
|
|
379
|
+
id: "endpoint-request",
|
|
380
|
+
data: { token: "box-office", member: "m1", seats: ["C4", "C5"], note: "not for the server", booking: "" },
|
|
381
|
+
layout: {
|
|
382
|
+
component: "Stack",
|
|
383
|
+
children: [
|
|
384
|
+
{ if: "$.booking", then: { component: "Text", children: "Booked as {{$.booking}}." } },
|
|
385
|
+
{ component: "Button", ref: "book", children: "Book both seats" }
|
|
386
|
+
]
|
|
387
|
+
},
|
|
388
|
+
endpoints: {
|
|
389
|
+
book: {
|
|
390
|
+
url: "/examples/endpoint-request/bookings",
|
|
391
|
+
method: "POST",
|
|
392
|
+
headers: { authorization: "Bearer {{$.token}}" },
|
|
393
|
+
request: { member: { $ref: "$.member" }, seats: { $length: { $ref: "$.seats" } } },
|
|
394
|
+
response: { $ref: "$.id" },
|
|
395
|
+
target: "booking"
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
triggers: [{ event: "ui:click", ref: "book", do: [{ call: "book" }] }]
|
|
399
|
+
},
|
|
400
|
+
presses: [{ ref: "book" }],
|
|
401
|
+
expected: { says: ["Booked as B-2041.", "Book both seats"], data: { token: "box-office", member: "m1", seats: ["C4", "C5"], note: "not for the server", booking: "B-2041" }, asked: [{ method: "POST", url: "/examples/endpoint-request/bookings", headers: { authorization: "Bearer box-office" }, body: { member: "m1", seats: 2 } }] }
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
id: "endpoint-chain",
|
|
405
|
+
group: "endpoints",
|
|
406
|
+
title: "One call after another",
|
|
407
|
+
description: "A URL and a function in the same action. `onSuccess` of the first call makes the second, which by then finds the first one\u2019s answer in the data. To the steps a call is a call: where it goes is the endpoint\u2019s business.",
|
|
408
|
+
fetches: { "GET /examples/endpoint-chain/members/m1": { status: 200, body: { name: "Ada", seats: ["C4", "C5"] } } },
|
|
409
|
+
replies: { "endpoint-chain.price": { total: 76 } },
|
|
410
|
+
action: {
|
|
411
|
+
id: "endpoint-chain",
|
|
412
|
+
data: { member: { name: "", seats: [] }, price: { total: 0 } },
|
|
413
|
+
layout: {
|
|
414
|
+
component: "Stack",
|
|
415
|
+
children: [
|
|
416
|
+
{ if: "$.member.name", then: { component: "Text", children: "{{$.member.name}} owes {{$.price.total}}." } },
|
|
417
|
+
{ component: "Button", ref: "load", children: "Work out what is owed" }
|
|
418
|
+
]
|
|
419
|
+
},
|
|
420
|
+
endpoints: {
|
|
421
|
+
member: { url: "/examples/endpoint-chain/members/m1", method: "GET", target: "member" },
|
|
422
|
+
price: { fn: "endpoint-chain.price", target: "price" }
|
|
423
|
+
},
|
|
424
|
+
triggers: [{ event: "ui:click", ref: "load", do: [{ call: "member", onSuccess: [{ call: "price" }] }] }]
|
|
425
|
+
},
|
|
426
|
+
presses: [{ ref: "load" }],
|
|
427
|
+
expected: { says: ["Ada owes 76.", "Work out what is owed"], data: { member: { name: "Ada", seats: ["C4", "C5"] }, price: { total: 76 } }, asked: [{ method: "GET", url: "/examples/endpoint-chain/members/m1" }] }
|
|
428
|
+
}
|
|
429
|
+
];
|
|
430
|
+
|
|
431
|
+
// src/i18n/phrases.ts
|
|
432
|
+
var DEFAULT_PHRASE_KEYS = {
|
|
433
|
+
// A starting set, not a standard — an app with its own vocabulary passes its
|
|
434
|
+
// own. Deliberately absent: `name`, `value`, `id`, `icon`, `tone`, `variant`,
|
|
435
|
+
// `key`. Those carry data or design tokens, and translating them is how a
|
|
436
|
+
// person called "Active" gets renamed.
|
|
437
|
+
props: [
|
|
438
|
+
"label",
|
|
439
|
+
"title",
|
|
440
|
+
"subtitle",
|
|
441
|
+
"heading",
|
|
442
|
+
"eyebrow",
|
|
443
|
+
"lead",
|
|
444
|
+
"blurb",
|
|
445
|
+
"placeholder",
|
|
446
|
+
"hint",
|
|
447
|
+
"help",
|
|
448
|
+
"message",
|
|
449
|
+
"empty",
|
|
450
|
+
"emptyHint",
|
|
451
|
+
"emptyLabel",
|
|
452
|
+
"noMatch",
|
|
453
|
+
"caption",
|
|
454
|
+
"description",
|
|
455
|
+
"confirmLabel",
|
|
456
|
+
"cancelLabel",
|
|
457
|
+
"alt",
|
|
458
|
+
"tooltip"
|
|
459
|
+
]};
|
|
460
|
+
|
|
461
|
+
// src/examples/i18n.ts
|
|
462
|
+
var I18N_EXAMPLES = [
|
|
463
|
+
{
|
|
464
|
+
id: "i18n-switch",
|
|
465
|
+
group: "i18n",
|
|
466
|
+
title: "Switch",
|
|
467
|
+
description: "A screen that is already open changes language when its host hands the shell another book. Nova swaps the words as it draws: what a person wrote in the layout, and what stands at a prose key such as `placeholder`. What came from data stays as it is.",
|
|
468
|
+
stage: false,
|
|
469
|
+
action: {
|
|
470
|
+
id: "i18n-switch",
|
|
471
|
+
data: { show: "The Tempest" },
|
|
472
|
+
layout: {
|
|
473
|
+
component: "Stack",
|
|
474
|
+
children: [
|
|
475
|
+
{ component: "Text", children: "Tonight" },
|
|
476
|
+
{ component: "Text", children: "$.show" },
|
|
477
|
+
{ component: "Input", ref: "name", props: { placeholder: "Your name" } },
|
|
478
|
+
{ component: "Button", ref: "book", children: "Book a seat" }
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
presses: [{ phrases: { Tonight: "Heute Abend", "Your name": "Ihr Name", "Book a seat": "Platz buchen" } }],
|
|
483
|
+
expected: { says: ["Heute Abend", "The Tempest", "Ihr Name", "Platz buchen"], data: { show: "The Tempest" } }
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
id: "i18n-keys",
|
|
487
|
+
group: "i18n",
|
|
488
|
+
title: "Authored and bound",
|
|
489
|
+
description: "A product called Pass, and a member whose surname is Pass. The book says what a Pass is in German, and only one of the two is renamed: a text a person wrote into the layout is prose, a text that came from data is not.",
|
|
490
|
+
stage: false,
|
|
491
|
+
phrases: { Pass: "Zehnerblock" },
|
|
492
|
+
action: {
|
|
493
|
+
id: "i18n-keys",
|
|
494
|
+
data: { member: { surname: "Pass" } },
|
|
495
|
+
layout: {
|
|
496
|
+
component: "Stack",
|
|
497
|
+
children: [
|
|
498
|
+
{ component: "Text", children: "Pass" },
|
|
499
|
+
{ component: "Text", children: "$.member.surname" }
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
presses: [],
|
|
504
|
+
expected: { says: ["Zehnerblock", "Pass"], data: { member: { surname: "Pass" } } }
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
id: "i18n-patterns",
|
|
508
|
+
group: "i18n",
|
|
509
|
+
title: "Counted phrases",
|
|
510
|
+
description: "No book can hold \u201C4 left\u201D: the number makes the rows endless. The row is the pattern, `{n} left`. It is translated whole, so the words may change places, and then its holes are closed. They close in the source language too, so a component is never handed the pattern itself.",
|
|
511
|
+
stage: false,
|
|
512
|
+
phrases: { "{n} left": "noch {n}", "{n} of {total}": "{n} von {total}" },
|
|
513
|
+
action: {
|
|
514
|
+
id: "i18n-patterns",
|
|
515
|
+
data: { left: 4, sold: 16, seats: 20 },
|
|
516
|
+
layout: {
|
|
517
|
+
component: "Stack",
|
|
518
|
+
children: [
|
|
519
|
+
{ component: "Badge", props: { label: { phrase: "{n} left", slots: { n: "$.left" } } } },
|
|
520
|
+
{ component: "Badge", props: { label: { phrase: "{n} of {total}", slots: { n: "$.sold", total: "$.seats" } } } }
|
|
521
|
+
]
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
presses: [],
|
|
525
|
+
expected: { says: ["noch 4", "16 von 20"], data: { left: 4, sold: 16, seats: 20 } }
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
id: "i18n-depth",
|
|
529
|
+
group: "i18n",
|
|
530
|
+
title: "Depth and display fields",
|
|
531
|
+
description: "Prose is found at any depth: a column\u2019s `label` two levels down in a table\u2019s spec is the same rule as a bare `label`. And a data field can be marked as words by its name: here every field ending in `_display` is prose, so the status a query made up is translated while `person_name` beside it is never touched, though \u201CPass\u201D is in the book.",
|
|
532
|
+
stage: false,
|
|
533
|
+
phrases: { Member: "Mitglied", Ticket: "Karte", Standing: "Stehplatz", Pass: "Zehnerblock" },
|
|
534
|
+
phraseKeys: { props: DEFAULT_PHRASE_KEYS.props, suffixes: ["_display"] },
|
|
535
|
+
action: {
|
|
536
|
+
id: "i18n-depth",
|
|
537
|
+
data: { rows: [{ person_name: "Pass", ticket_display: "Standing" }] },
|
|
538
|
+
layout: {
|
|
539
|
+
component: "Table",
|
|
540
|
+
props: {
|
|
541
|
+
columns: [
|
|
542
|
+
{ key: "person_name", label: "Member" },
|
|
543
|
+
{ key: "ticket_display", label: "Ticket" }
|
|
544
|
+
],
|
|
545
|
+
rows: "$.rows"
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
presses: [],
|
|
550
|
+
expected: { says: ["Mitglied", "Karte", "Stehplatz"], data: { rows: [{ person_name: "Pass", ticket_display: "Standing" }] } }
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
id: "i18n-formatting",
|
|
554
|
+
group: "i18n",
|
|
555
|
+
title: "Formatting",
|
|
556
|
+
description: "No book can hold a price or a date either. Those are written for a region where they are made, by Prism, with the region named. Words go by language and formatting by region: the same amount in the same currency is written three ways across three countries that share a language.",
|
|
557
|
+
stage: false,
|
|
558
|
+
action: {
|
|
559
|
+
id: "i18n-formatting",
|
|
560
|
+
data: { price_cents: 8900 },
|
|
561
|
+
layout: {
|
|
562
|
+
component: "Stack",
|
|
563
|
+
children: [
|
|
564
|
+
{ component: "Badge", props: { label: { $prism: { $localeMoney: { value: { $ref: "$.price_cents" }, currency: "EUR", locale: "de-AT" } } } } },
|
|
565
|
+
{ component: "Badge", props: { label: { $prism: { $localeMoney: { value: { $ref: "$.price_cents" }, currency: "EUR", locale: "de-DE" } } } } },
|
|
566
|
+
{ component: "Badge", props: { label: { $prism: { $localeMoney: { value: { $ref: "$.price_cents" }, currency: "EUR", locale: "de-CH" } } } } }
|
|
567
|
+
]
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
presses: [],
|
|
571
|
+
expected: { says: ["\u20AC\xA089,00", "89,00\xA0\u20AC", "EUR\xA089.00"], data: { price_cents: 8900 } }
|
|
572
|
+
}
|
|
573
|
+
];
|
|
574
|
+
|
|
575
|
+
// src/examples/layouts.ts
|
|
576
|
+
var LAYOUT_EXAMPLES = [
|
|
577
|
+
{
|
|
578
|
+
id: "path",
|
|
579
|
+
group: "layouts",
|
|
580
|
+
title: "Path",
|
|
581
|
+
description: "A string that starts with `$.` is a path into the data. It is replaced by what stands there; a value further in is reached by a longer path.",
|
|
582
|
+
action: {
|
|
583
|
+
id: "path",
|
|
584
|
+
data: { member: { name: "Ada", city: "London" } },
|
|
585
|
+
layout: {
|
|
586
|
+
component: "Stack",
|
|
587
|
+
children: [
|
|
588
|
+
{ component: "Text", children: "$.member.name" },
|
|
589
|
+
{ component: "Text", children: "$.member.city" }
|
|
590
|
+
]
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
presses: [],
|
|
594
|
+
expected: { says: ["Ada", "London"], data: { member: { name: "Ada", city: "London" } } }
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
id: "templates",
|
|
598
|
+
group: "layouts",
|
|
599
|
+
title: "Templates",
|
|
600
|
+
description: "A string with `{{\u2026}}` in it is a template. Each expression between the braces is resolved and written into the sentence.",
|
|
601
|
+
action: {
|
|
602
|
+
id: "templates",
|
|
603
|
+
data: { name: "Ada", count: 3 },
|
|
604
|
+
layout: {
|
|
605
|
+
component: "Stack",
|
|
606
|
+
children: [
|
|
607
|
+
{ component: "Text", children: "Hello, {{$.name}}." },
|
|
608
|
+
{ component: "Text", children: "{{$.count}} new messages" }
|
|
609
|
+
]
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
presses: [],
|
|
613
|
+
expected: { says: ["Hello, Ada.", "3 new messages"], data: { name: "Ada", count: 3 } }
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
id: "conditional",
|
|
617
|
+
group: "layouts",
|
|
618
|
+
title: "Conditional",
|
|
619
|
+
description: "An `if` node draws its `then` when the path holds something and its `else` when it does not. Without an `else`, it draws nothing.",
|
|
620
|
+
action: {
|
|
621
|
+
id: "conditional",
|
|
622
|
+
data: { signedIn: true, basket: [] },
|
|
623
|
+
layout: {
|
|
624
|
+
component: "Stack",
|
|
625
|
+
children: [
|
|
626
|
+
{ if: "$.signedIn", then: { component: "Text", children: "Welcome back." }, else: { component: "Text", children: "Sign in to go on." } },
|
|
627
|
+
{ if: "$.basket.0", then: { component: "Text", children: "There is something in your basket." }, else: { component: "Text", children: "Your basket is empty." } },
|
|
628
|
+
{ if: "$.basket.0", then: { component: "Text", children: "Go to the till." } }
|
|
629
|
+
]
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
presses: [],
|
|
633
|
+
expected: { says: ["Welcome back.", "Your basket is empty."], data: { signedIn: true, basket: [] } }
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
id: "missing-paths",
|
|
637
|
+
group: "layouts",
|
|
638
|
+
title: "Missing paths",
|
|
639
|
+
description: "A path with nothing at it is not an error. On its own it draws nothing, and in a template it leaves its place empty.",
|
|
640
|
+
action: {
|
|
641
|
+
id: "missing-paths",
|
|
642
|
+
data: { member: { name: "Ada" } },
|
|
643
|
+
layout: {
|
|
644
|
+
component: "Stack",
|
|
645
|
+
children: [
|
|
646
|
+
{ component: "Text", children: "$.member.name" },
|
|
647
|
+
{ component: "Text", children: "$.member.nickname" },
|
|
648
|
+
{ component: "Text", children: "Known as {{$.member.nickname}}." }
|
|
649
|
+
]
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
presses: [],
|
|
653
|
+
expected: { says: ["Ada", "Known as ."], data: { member: { name: "Ada" } } }
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
id: "loop",
|
|
657
|
+
group: "layouts",
|
|
658
|
+
title: "Loop",
|
|
659
|
+
description: "A `for` node draws its `do` once for each element of a list. `as` names the element for the bindings inside, and `key` names the field that tells one element from another.",
|
|
660
|
+
action: {
|
|
661
|
+
id: "loop",
|
|
662
|
+
data: {
|
|
663
|
+
members: [
|
|
664
|
+
{ id: "m1", name: "Ada" },
|
|
665
|
+
{ id: "m2", name: "Grace" },
|
|
666
|
+
{ id: "m3", name: "Linus" }
|
|
667
|
+
]
|
|
668
|
+
},
|
|
669
|
+
layout: {
|
|
670
|
+
component: "Stack",
|
|
671
|
+
children: [{ for: "$.members", as: "member", key: "id", do: { component: "Text", children: "$member.name" } }]
|
|
672
|
+
}
|
|
673
|
+
},
|
|
674
|
+
presses: [],
|
|
675
|
+
expected: { says: ["Ada", "Grace", "Linus"], data: { members: [{ id: "m1", name: "Ada" }, { id: "m2", name: "Grace" }, { id: "m3", name: "Linus" }] } }
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
id: "loop-index",
|
|
679
|
+
group: "layouts",
|
|
680
|
+
title: "Index",
|
|
681
|
+
description: "Inside a loop, `$index` is the position of the element, counted from zero.",
|
|
682
|
+
action: {
|
|
683
|
+
id: "loop-index",
|
|
684
|
+
data: { steps: ["Book", "Pay", "Go"] },
|
|
685
|
+
layout: {
|
|
686
|
+
component: "Stack",
|
|
687
|
+
children: [{ for: "$.steps", as: "step", do: { component: "Text", children: "{{$index}}: {{$step}}" } }]
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
presses: [],
|
|
691
|
+
expected: { says: ["0: Book", "1: Pay", "2: Go"], data: { steps: ["Book", "Pay", "Go"] } }
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
id: "nested-loops",
|
|
695
|
+
group: "layouts",
|
|
696
|
+
title: "Nested loops",
|
|
697
|
+
description: "A loop inside a loop. The inner one reads the outer one's element as well as its own.",
|
|
698
|
+
action: {
|
|
699
|
+
id: "nested-loops",
|
|
700
|
+
data: {
|
|
701
|
+
rows: [
|
|
702
|
+
{ name: "A", seats: [1, 2] },
|
|
703
|
+
{ name: "B", seats: [1, 2, 3] }
|
|
704
|
+
]
|
|
705
|
+
},
|
|
706
|
+
layout: {
|
|
707
|
+
component: "Stack",
|
|
708
|
+
children: [{ for: "$.rows", as: "row", key: "name", do: { for: "$row.seats", as: "seat", do: { component: "Text", children: "{{$row.name}}{{$seat}}" } } }]
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
presses: [],
|
|
712
|
+
expected: { says: ["A1", "A2", "B1", "B2", "B3"], data: { rows: [{ name: "A", seats: [1, 2] }, { name: "B", seats: [1, 2, 3] }] } }
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
id: "directives",
|
|
716
|
+
group: "layouts",
|
|
717
|
+
title: "Directives",
|
|
718
|
+
description: "Where a value is wanted, a directive works one out. `$eq` says whether two values are the same; here it decides an `if`, so the layout can ask more of the data than whether something is there.",
|
|
719
|
+
action: {
|
|
720
|
+
id: "directives",
|
|
721
|
+
data: { tab: "members", seats: 2 },
|
|
722
|
+
layout: {
|
|
723
|
+
component: "Stack",
|
|
724
|
+
children: [
|
|
725
|
+
{ if: { $eq: ["$.tab", "members"] }, then: { component: "Text", children: "Showing members" }, else: { component: "Text", children: "Showing everyone" } },
|
|
726
|
+
{ if: { $eq: ["$.seats", 1] }, then: { component: "Text", children: "One seat" }, else: { component: "Text", children: "{{$.seats}} seats" } }
|
|
727
|
+
]
|
|
728
|
+
}
|
|
729
|
+
},
|
|
730
|
+
presses: [],
|
|
731
|
+
expected: { says: ["Showing members", "2 seats"], data: { tab: "members", seats: 2 } }
|
|
732
|
+
}
|
|
733
|
+
];
|
|
734
|
+
|
|
735
|
+
// src/examples/shells.ts
|
|
736
|
+
var SHELL_EXAMPLES = [
|
|
737
|
+
{
|
|
738
|
+
id: "push-pop",
|
|
739
|
+
group: "shells",
|
|
740
|
+
title: "Push and pop",
|
|
741
|
+
description: "A canvas is a stack. `push` puts an action on top of it and `pop` takes the top one off again, so Back is real: the screen underneath was never gone.",
|
|
742
|
+
shell: {
|
|
743
|
+
canvases: [{ id: "push-pop.main", initial: "push-pop.menu" }],
|
|
744
|
+
actions: {
|
|
745
|
+
"push-pop.menu": {
|
|
746
|
+
id: "push-pop.menu",
|
|
747
|
+
layout: {
|
|
748
|
+
component: "Stack",
|
|
749
|
+
children: [
|
|
750
|
+
{ component: "Text", children: "Box office" },
|
|
751
|
+
{ component: "Button", ref: "seats", children: "Seats" },
|
|
752
|
+
{ component: "Button", ref: "prices", children: "Prices" }
|
|
753
|
+
]
|
|
754
|
+
},
|
|
755
|
+
triggers: [
|
|
756
|
+
{ event: "ui:click", ref: "seats", do: [{ push: { action: "push-pop.seats" } }] },
|
|
757
|
+
{ event: "ui:click", ref: "prices", do: [{ push: { action: "push-pop.prices" } }] }
|
|
758
|
+
]
|
|
759
|
+
},
|
|
760
|
+
"push-pop.seats": {
|
|
761
|
+
id: "push-pop.seats",
|
|
762
|
+
layout: { component: "Stack", children: [{ component: "Text", children: "Row C is free." }, { component: "Button", ref: "back", children: "Back" }] },
|
|
763
|
+
triggers: [{ event: "ui:click", ref: "back", do: [{ pop: true }] }]
|
|
764
|
+
},
|
|
765
|
+
"push-pop.prices": {
|
|
766
|
+
id: "push-pop.prices",
|
|
767
|
+
layout: { component: "Stack", children: [{ component: "Text", children: "A seat is 38." }, { component: "Button", ref: "back", children: "Back" }] },
|
|
768
|
+
triggers: [{ event: "ui:click", ref: "back", do: [{ pop: true }] }]
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
presses: [{ ref: "seats" }, { ref: "back" }, { ref: "prices" }],
|
|
773
|
+
expected: { says: ["A seat is 38.", "Back"], stacks: { "push-pop.main": ["push-pop.menu", "push-pop.prices"] } }
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
id: "replace",
|
|
777
|
+
group: "shells",
|
|
778
|
+
title: "Replace",
|
|
779
|
+
description: "`replace` swaps the action on top for another. The stack does not grow, so a run of steps leaves nothing behind to go back through.",
|
|
780
|
+
shell: {
|
|
781
|
+
canvases: [{ id: "replace.main", initial: "replace.seats" }],
|
|
782
|
+
actions: {
|
|
783
|
+
"replace.seats": {
|
|
784
|
+
id: "replace.seats",
|
|
785
|
+
layout: { component: "Stack", children: [{ component: "Text", children: "Step 1: choose seats" }, { component: "Button", ref: "next", children: "Next" }] },
|
|
786
|
+
triggers: [{ event: "ui:click", ref: "next", do: [{ replace: { action: "replace.payment" } }] }]
|
|
787
|
+
},
|
|
788
|
+
"replace.payment": {
|
|
789
|
+
id: "replace.payment",
|
|
790
|
+
layout: { component: "Stack", children: [{ component: "Text", children: "Step 2: pay" }, { component: "Button", ref: "next", children: "Next" }] },
|
|
791
|
+
triggers: [{ event: "ui:click", ref: "next", do: [{ replace: { action: "replace.done" } }] }]
|
|
792
|
+
},
|
|
793
|
+
"replace.done": { id: "replace.done", layout: { component: "Text", children: "Step 3: booked" } }
|
|
794
|
+
}
|
|
795
|
+
},
|
|
796
|
+
presses: [{ ref: "next" }, { ref: "next" }],
|
|
797
|
+
expected: { says: ["Step 3: booked"], stacks: { "replace.main": ["replace.done"] } }
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
id: "multi-canvas",
|
|
801
|
+
group: "shells",
|
|
802
|
+
title: "Multi-canvas",
|
|
803
|
+
description: "Two canvases side by side. The one on the left replaces what stands on the other, by naming it: `canvas` on a `replace`. The left one is not touched.",
|
|
804
|
+
shell: {
|
|
805
|
+
canvases: [
|
|
806
|
+
{ id: "multi-canvas.nav", initial: "multi-canvas.days" },
|
|
807
|
+
{ id: "multi-canvas.content", initial: "multi-canvas.tonight" }
|
|
808
|
+
],
|
|
809
|
+
canvasLayout: {
|
|
810
|
+
component: "Stack",
|
|
811
|
+
children: [
|
|
812
|
+
{ component: "CanvasSlot", props: { canvasId: "multi-canvas.nav" } },
|
|
813
|
+
{ component: "CanvasSlot", props: { canvasId: "multi-canvas.content" } }
|
|
814
|
+
]
|
|
815
|
+
},
|
|
816
|
+
actions: {
|
|
817
|
+
"multi-canvas.days": {
|
|
818
|
+
id: "multi-canvas.days",
|
|
819
|
+
layout: {
|
|
820
|
+
component: "Stack",
|
|
821
|
+
children: [
|
|
822
|
+
{ component: "Button", ref: "tonight", children: "Tonight" },
|
|
823
|
+
{ component: "Button", ref: "tomorrow", children: "Tomorrow" }
|
|
824
|
+
]
|
|
825
|
+
},
|
|
826
|
+
triggers: [
|
|
827
|
+
{ event: "ui:click", ref: "tonight", do: [{ replace: { action: "multi-canvas.tonight", canvas: "multi-canvas.content" } }] },
|
|
828
|
+
{ event: "ui:click", ref: "tomorrow", do: [{ replace: { action: "multi-canvas.tomorrow", canvas: "multi-canvas.content" } }] }
|
|
829
|
+
]
|
|
830
|
+
},
|
|
831
|
+
"multi-canvas.tonight": { id: "multi-canvas.tonight", layout: { component: "Text", children: "Tonight: The Tempest" } },
|
|
832
|
+
"multi-canvas.tomorrow": { id: "multi-canvas.tomorrow", layout: { component: "Text", children: "Tomorrow: Twelfth Night" } }
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
presses: [{ ref: "tomorrow" }],
|
|
836
|
+
expected: { says: ["Tonight", "Tomorrow", "Tomorrow: Twelfth Night"], stacks: { "multi-canvas.nav": ["multi-canvas.days"], "multi-canvas.content": ["multi-canvas.tomorrow"] } }
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
id: "messages",
|
|
840
|
+
group: "shells",
|
|
841
|
+
title: "Messages",
|
|
842
|
+
description: "Actions on different canvases do not reach into each other. One says something on a channel with `emit`; any action with a `message` trigger for that channel hears it.",
|
|
843
|
+
shell: {
|
|
844
|
+
canvases: [
|
|
845
|
+
{ id: "messages.till", initial: "messages.sell" },
|
|
846
|
+
{ id: "messages.board", initial: "messages.count" }
|
|
847
|
+
],
|
|
848
|
+
actions: {
|
|
849
|
+
"messages.sell": {
|
|
850
|
+
id: "messages.sell",
|
|
851
|
+
layout: { component: "Button", ref: "sell", children: "Sell a seat" },
|
|
852
|
+
triggers: [{ event: "ui:click", ref: "sell", do: [{ emit: { channel: "messages.sold", payload: 1 } }] }]
|
|
853
|
+
},
|
|
854
|
+
"messages.count": {
|
|
855
|
+
id: "messages.count",
|
|
856
|
+
data: { sold: 0 },
|
|
857
|
+
layout: { component: "Text", children: "Sold tonight: {{$.sold}}" },
|
|
858
|
+
triggers: [{ message: "messages.sold", do: [{ increment: "sold" }] }]
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
presses: [{ ref: "sell" }, { ref: "sell" }],
|
|
863
|
+
expected: { says: ["Sell a seat", "Sold tonight: 2"], stacks: { "messages.till": ["messages.sell"], "messages.board": ["messages.count"] } }
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
id: "list-canvas",
|
|
867
|
+
group: "shells",
|
|
868
|
+
title: "List canvas",
|
|
869
|
+
description: "A canvas in `list` mode keeps every action pushed onto it on the screen. Its `actionLayout` loops over `$.instances` and gives each one a slot, so a feed is pushes and nothing else.",
|
|
870
|
+
shell: {
|
|
871
|
+
canvases: [
|
|
872
|
+
{ id: "list-canvas.desk", initial: "list-canvas.write" },
|
|
873
|
+
{
|
|
874
|
+
id: "list-canvas.feed",
|
|
875
|
+
mode: "list",
|
|
876
|
+
actionLayout: { component: "Stack", children: [{ for: "$.instances", as: "instance", key: "id", do: { component: "ActionSlot", props: { instanceId: "$instance.id" } } }] }
|
|
877
|
+
}
|
|
878
|
+
],
|
|
879
|
+
actions: {
|
|
880
|
+
"list-canvas.write": {
|
|
881
|
+
id: "list-canvas.write",
|
|
882
|
+
layout: { component: "Button", ref: "note", children: "Post a note" },
|
|
883
|
+
triggers: [{ event: "ui:click", ref: "note", do: [{ push: { action: "list-canvas.note", canvas: "list-canvas.feed", input: { text: "A seat was booked." } } }] }]
|
|
884
|
+
},
|
|
885
|
+
"list-canvas.note": {
|
|
886
|
+
id: "list-canvas.note",
|
|
887
|
+
data: { text: "" },
|
|
888
|
+
input: { type: "object", properties: { text: { type: "string", description: "What the note says." } } },
|
|
889
|
+
layout: { component: "Text", children: "$.text" }
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
presses: [{ ref: "note" }, { ref: "note" }],
|
|
894
|
+
expected: { says: ["Post a note", "A seat was booked.", "A seat was booked."], stacks: { "list-canvas.desk": ["list-canvas.write"], "list-canvas.feed": ["list-canvas.note", "list-canvas.note"] } }
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
id: "frame-condition",
|
|
898
|
+
group: "shells",
|
|
899
|
+
title: "Frame condition",
|
|
900
|
+
description: "The layout that arranges the canvases is a layout like any other, over what the canvases hold. Here it draws the second canvas only while something stands on it, and a line in its place while nothing does.",
|
|
901
|
+
shell: {
|
|
902
|
+
canvases: [{ id: "frame-condition.list", initial: "frame-condition.shows" }, { id: "frame-condition.detail" }],
|
|
903
|
+
canvasLayout: {
|
|
904
|
+
component: "Stack",
|
|
905
|
+
children: [
|
|
906
|
+
{ component: "CanvasSlot", props: { canvasId: "frame-condition.list" } },
|
|
907
|
+
{ if: "$.canvases.1.active", then: { component: "CanvasSlot", props: { canvasId: "frame-condition.detail" } }, else: { component: "Text", children: "Pick a show." } }
|
|
908
|
+
]
|
|
909
|
+
},
|
|
910
|
+
actions: {
|
|
911
|
+
"frame-condition.shows": {
|
|
912
|
+
id: "frame-condition.shows",
|
|
913
|
+
layout: { component: "Button", ref: "open", children: "The Tempest" },
|
|
914
|
+
triggers: [{ event: "ui:click", ref: "open", do: [{ push: { action: "frame-condition.show", canvas: "frame-condition.detail" } }] }]
|
|
915
|
+
},
|
|
916
|
+
"frame-condition.show": { id: "frame-condition.show", layout: { component: "Text", children: "Saturday, 19:30. Row C is free." } }
|
|
917
|
+
}
|
|
918
|
+
},
|
|
919
|
+
presses: [{ ref: "open" }],
|
|
920
|
+
expected: { says: ["The Tempest", "Saturday, 19:30. Row C is free."], stacks: { "frame-condition.list": ["frame-condition.shows"], "frame-condition.detail": ["frame-condition.show"] } }
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
id: "hooks",
|
|
924
|
+
group: "shells",
|
|
925
|
+
title: "Hooks",
|
|
926
|
+
description: "An action is told when it is put on a canvas, covered, uncovered and taken off: `mount`, `suspend`, `resume`, `unmount`. Here the first action writes down each one as it happens. Uncovered, it is told `mount` again and then `resume`, so what it loads on mount is never stale.",
|
|
927
|
+
shell: {
|
|
928
|
+
canvases: [{ id: "hooks.main", initial: "hooks.first" }],
|
|
929
|
+
actions: {
|
|
930
|
+
"hooks.first": {
|
|
931
|
+
id: "hooks.first",
|
|
932
|
+
data: { seen: [] },
|
|
933
|
+
layout: {
|
|
934
|
+
component: "Stack",
|
|
935
|
+
children: [
|
|
936
|
+
{ for: "$.seen", as: "hook", do: { component: "Text", children: "$hook" } },
|
|
937
|
+
{ component: "Button", ref: "cover", children: "Open another on top" }
|
|
938
|
+
]
|
|
939
|
+
},
|
|
940
|
+
lifecycle: {
|
|
941
|
+
mount: [{ push: "seen", value: "mount" }],
|
|
942
|
+
suspend: [{ push: "seen", value: "suspend" }],
|
|
943
|
+
resume: [{ push: "seen", value: "resume" }]
|
|
944
|
+
},
|
|
945
|
+
triggers: [{ event: "ui:click", ref: "cover", do: [{ push: { action: "hooks.second" } }] }]
|
|
946
|
+
},
|
|
947
|
+
"hooks.second": {
|
|
948
|
+
id: "hooks.second",
|
|
949
|
+
layout: { component: "Button", ref: "back", children: "Back" },
|
|
950
|
+
triggers: [{ event: "ui:click", ref: "back", do: [{ pop: true }] }]
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
},
|
|
954
|
+
presses: [{ ref: "cover" }, { ref: "back" }],
|
|
955
|
+
expected: { says: ["mount", "suspend", "mount", "resume", "Open another on top"], stacks: { "hooks.main": ["hooks.first"] } }
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
id: "dashboard",
|
|
959
|
+
group: "shells",
|
|
960
|
+
title: "Dashboard",
|
|
961
|
+
description: "A frame of three canvases. One press on the bar does two things on two other canvases: it replaces what the middle one shows, and it adds a line to a list canvas that keeps them all.",
|
|
962
|
+
shell: {
|
|
963
|
+
canvases: [
|
|
964
|
+
{ id: "dashboard.bar", initial: "dashboard.tabs" },
|
|
965
|
+
{ id: "dashboard.middle", initial: "dashboard.sales" },
|
|
966
|
+
{
|
|
967
|
+
id: "dashboard.log",
|
|
968
|
+
mode: "list",
|
|
969
|
+
actionLayout: { component: "Stack", children: [{ for: "$.instances", as: "instance", key: "id", do: { component: "ActionSlot", props: { instanceId: "$instance.id" } } }] }
|
|
970
|
+
}
|
|
971
|
+
],
|
|
972
|
+
canvasLayout: {
|
|
973
|
+
component: "Stack",
|
|
974
|
+
children: [
|
|
975
|
+
{ component: "CanvasSlot", props: { canvasId: "dashboard.bar" } },
|
|
976
|
+
{ component: "CanvasSlot", props: { canvasId: "dashboard.middle" } },
|
|
977
|
+
{ component: "CanvasSlot", props: { canvasId: "dashboard.log" } }
|
|
978
|
+
]
|
|
979
|
+
},
|
|
980
|
+
actions: {
|
|
981
|
+
"dashboard.tabs": {
|
|
982
|
+
id: "dashboard.tabs",
|
|
983
|
+
layout: {
|
|
984
|
+
component: "Stack",
|
|
985
|
+
children: [
|
|
986
|
+
{ component: "Button", ref: "sales", children: "Sales" },
|
|
987
|
+
{ component: "Button", ref: "seats", children: "Seats" }
|
|
988
|
+
]
|
|
989
|
+
},
|
|
990
|
+
triggers: [
|
|
991
|
+
{
|
|
992
|
+
event: "ui:click",
|
|
993
|
+
ref: "sales",
|
|
994
|
+
do: [{ replace: { action: "dashboard.sales", canvas: "dashboard.middle" } }, { push: { action: "dashboard.line", canvas: "dashboard.log", input: { text: "Looked at sales" } } }]
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
event: "ui:click",
|
|
998
|
+
ref: "seats",
|
|
999
|
+
do: [{ replace: { action: "dashboard.seats", canvas: "dashboard.middle" } }, { push: { action: "dashboard.line", canvas: "dashboard.log", input: { text: "Looked at seats" } } }]
|
|
1000
|
+
}
|
|
1001
|
+
]
|
|
1002
|
+
},
|
|
1003
|
+
"dashboard.sales": { id: "dashboard.sales", layout: { component: "Text", children: "Sold tonight: 212" } },
|
|
1004
|
+
"dashboard.seats": { id: "dashboard.seats", layout: { component: "Text", children: "Free tonight: 38" } },
|
|
1005
|
+
"dashboard.line": {
|
|
1006
|
+
id: "dashboard.line",
|
|
1007
|
+
data: { text: "" },
|
|
1008
|
+
input: { type: "object", properties: { text: { type: "string", description: "What the line says." } } },
|
|
1009
|
+
layout: { component: "Text", children: "$.text" }
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
},
|
|
1013
|
+
presses: [{ ref: "seats" }, { ref: "sales" }],
|
|
1014
|
+
expected: { says: ["Sales", "Seats", "Sold tonight: 212", "Looked at seats", "Looked at sales"], stacks: { "dashboard.bar": ["dashboard.tabs"], "dashboard.middle": ["dashboard.sales"], "dashboard.log": ["dashboard.line", "dashboard.line"] } }
|
|
1015
|
+
}
|
|
1016
|
+
];
|
|
1017
|
+
|
|
1018
|
+
// src/examples/structure.ts
|
|
1019
|
+
var STRUCTURE_EXAMPLES = [
|
|
1020
|
+
{
|
|
1021
|
+
id: "nested-conditionals",
|
|
1022
|
+
group: "layouts",
|
|
1023
|
+
title: "Nested conditionals",
|
|
1024
|
+
description: "An `if` inside an `if`. The outer one asks whether anybody is signed in, the inner one what kind of member they are: three screens from one layout.",
|
|
1025
|
+
action: {
|
|
1026
|
+
id: "nested-conditionals",
|
|
1027
|
+
data: { member: { name: "Ada", staff: true } },
|
|
1028
|
+
layout: {
|
|
1029
|
+
if: "$.member",
|
|
1030
|
+
then: {
|
|
1031
|
+
if: "$.member.staff",
|
|
1032
|
+
then: { component: "Text", children: "{{$.member.name}} works at the box office." },
|
|
1033
|
+
else: { component: "Text", children: "{{$.member.name}} is a member." }
|
|
1034
|
+
},
|
|
1035
|
+
else: { component: "Text", children: "Nobody is signed in." }
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
1038
|
+
presses: [],
|
|
1039
|
+
expected: { says: ["Ada works at the box office."], data: { member: { name: "Ada", staff: true } } }
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
id: "conditional-in-loop",
|
|
1043
|
+
group: "layouts",
|
|
1044
|
+
title: "Conditional in a loop",
|
|
1045
|
+
description: "A condition inside a `for` reads the element of that turn, so each row decides for itself.",
|
|
1046
|
+
action: {
|
|
1047
|
+
id: "conditional-in-loop",
|
|
1048
|
+
data: {
|
|
1049
|
+
seats: [
|
|
1050
|
+
{ id: "C4", taken: true },
|
|
1051
|
+
{ id: "C5", taken: false },
|
|
1052
|
+
{ id: "C6", taken: true }
|
|
1053
|
+
]
|
|
1054
|
+
},
|
|
1055
|
+
layout: {
|
|
1056
|
+
component: "Stack",
|
|
1057
|
+
children: [
|
|
1058
|
+
{
|
|
1059
|
+
for: "$.seats",
|
|
1060
|
+
as: "seat",
|
|
1061
|
+
key: "id",
|
|
1062
|
+
do: { if: "$seat.taken", then: { component: "Text", children: "{{$seat.id}} is taken" }, else: { component: "Text", children: "{{$seat.id}} is free" } }
|
|
1063
|
+
}
|
|
1064
|
+
]
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
presses: [],
|
|
1068
|
+
expected: { says: ["C4 is taken", "C5 is free", "C6 is taken"], data: { seats: [{ id: "C4", taken: true }, { id: "C5", taken: false }, { id: "C6", taken: true }] } }
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
id: "empty-list",
|
|
1072
|
+
group: "layouts",
|
|
1073
|
+
title: "Empty list",
|
|
1074
|
+
description: "A loop over an empty list draws nothing. An `if` on its first element puts a line there where the list would be.",
|
|
1075
|
+
action: {
|
|
1076
|
+
id: "empty-list",
|
|
1077
|
+
data: { bookings: [] },
|
|
1078
|
+
layout: {
|
|
1079
|
+
component: "Stack",
|
|
1080
|
+
children: [
|
|
1081
|
+
{ component: "Text", children: "Your bookings" },
|
|
1082
|
+
{ if: "$.bookings.0", then: { for: "$.bookings", as: "booking", do: { component: "Text", children: "$booking" } }, else: { component: "Text", children: "None yet." } }
|
|
1083
|
+
]
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
presses: [],
|
|
1087
|
+
expected: { says: ["Your bookings", "None yet."], data: { bookings: [] } }
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
id: "layout-refs",
|
|
1091
|
+
group: "layouts",
|
|
1092
|
+
title: "Layout refs",
|
|
1093
|
+
description: "A layout kept under a name is used wherever `{ ref }` names it. It is drawn in the place that names it, so inside a loop it reads the element of that turn.",
|
|
1094
|
+
layouts: {
|
|
1095
|
+
"layout-refs.card": {
|
|
1096
|
+
component: "Stack",
|
|
1097
|
+
children: [
|
|
1098
|
+
{ component: "Text", children: "$member.name" },
|
|
1099
|
+
{ component: "Text", children: "Row {{$member.row}}" }
|
|
1100
|
+
]
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
action: {
|
|
1104
|
+
id: "layout-refs",
|
|
1105
|
+
data: {
|
|
1106
|
+
members: [
|
|
1107
|
+
{ id: "m1", name: "Ada", row: "C" },
|
|
1108
|
+
{ id: "m2", name: "Grace", row: "F" }
|
|
1109
|
+
]
|
|
1110
|
+
},
|
|
1111
|
+
layout: { component: "Stack", children: [{ for: "$.members", as: "member", key: "id", do: { ref: "layout-refs.card" } }] }
|
|
1112
|
+
},
|
|
1113
|
+
presses: [],
|
|
1114
|
+
expected: { says: ["Ada", "Row C", "Grace", "Row F"], data: { members: [{ id: "m1", name: "Ada", row: "C" }, { id: "m2", name: "Grace", row: "F" }] } }
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
id: "set-from",
|
|
1118
|
+
group: "actions",
|
|
1119
|
+
title: "Set from",
|
|
1120
|
+
description: "`set` with `from` copies what stands at one path to another. Here every step first keeps the count it is about to change, so one press takes it back.",
|
|
1121
|
+
action: {
|
|
1122
|
+
id: "set-from",
|
|
1123
|
+
data: { count: 1, before: 1 },
|
|
1124
|
+
layout: {
|
|
1125
|
+
component: "Stack",
|
|
1126
|
+
children: [
|
|
1127
|
+
{ component: "Text", children: "Seats: {{$.count}}" },
|
|
1128
|
+
{ component: "Button", ref: "more", children: "One more" },
|
|
1129
|
+
{ component: "Button", ref: "undo", children: "Undo" }
|
|
1130
|
+
]
|
|
1131
|
+
},
|
|
1132
|
+
triggers: [
|
|
1133
|
+
{
|
|
1134
|
+
event: "ui:click",
|
|
1135
|
+
ref: "more",
|
|
1136
|
+
do: [{ set: "before", from: "count" }, { increment: "count" }]
|
|
1137
|
+
},
|
|
1138
|
+
{ event: "ui:click", ref: "undo", do: [{ set: "count", from: "before" }] }
|
|
1139
|
+
]
|
|
1140
|
+
},
|
|
1141
|
+
presses: [{ ref: "more" }, { ref: "more" }, { ref: "undo" }],
|
|
1142
|
+
expected: { says: ["Seats: 2", "One more", "Undo"], data: { count: 2, before: 2 } }
|
|
1143
|
+
}
|
|
1144
|
+
];
|
|
1145
|
+
|
|
1146
|
+
// src/examples/groups.ts
|
|
1147
|
+
var NOVA_EXAMPLE_GROUPS = [
|
|
1148
|
+
{
|
|
1149
|
+
id: "layouts",
|
|
1150
|
+
title: "Layouts",
|
|
1151
|
+
description: "How a layout becomes a screen: paths, templates, conditions and loops, each resolved against the action's data."
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
id: "actions",
|
|
1155
|
+
title: "Actions",
|
|
1156
|
+
description: "An action is data, a layout over it, and triggers that change the data when something is pressed."
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
id: "endpoints",
|
|
1160
|
+
title: "Endpoints",
|
|
1161
|
+
description: "How an action reaches outside itself: a named call, where its answer lands, and what happens when it fails."
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
id: "composition",
|
|
1165
|
+
title: "Composition",
|
|
1166
|
+
description: "Fragments: a frame and its behaviour kept once, and put around an action by whoever opens it."
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
id: "shells",
|
|
1170
|
+
title: "Shells",
|
|
1171
|
+
description: "Canvases, what stands on them, and how actions move between them and speak to each other."
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
id: "i18n",
|
|
1175
|
+
title: "i18n",
|
|
1176
|
+
description: "Words in the reader\u2019s language: a book keyed on the words as they are written, and rules for which strings are words at all."
|
|
1177
|
+
}
|
|
1178
|
+
];
|
|
1179
|
+
|
|
1180
|
+
// src/examples/index.ts
|
|
1181
|
+
var NOVA_EXAMPLES = [...LAYOUT_EXAMPLES, ...ACTION_EXAMPLES, ...STRUCTURE_EXAMPLES, ...ENDPOINT_EXAMPLES, ...COMPOSITION_EXAMPLES, ...SHELL_EXAMPLES, ...I18N_EXAMPLES];
|
|
1182
|
+
|
|
1183
|
+
exports.NOVA_EXAMPLES = NOVA_EXAMPLES;
|
|
1184
|
+
exports.NOVA_EXAMPLE_GROUPS = NOVA_EXAMPLE_GROUPS;
|
|
1185
|
+
//# sourceMappingURL=index.cjs.map
|
|
1186
|
+
//# sourceMappingURL=index.cjs.map
|