-
Notifications
You must be signed in to change notification settings - Fork 13
/
value.html
389 lines (368 loc) · 7.9 KB
/
value.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>mv-value tests</title>
<link rel="stylesheet" href="https://get.mavo.io/mavo.css" />
<link rel="stylesheet" href="style.css" />
<style>
[data-foo]::before {
content: "[data-foo=" attr(data-foo) "]";
background: #efc;
}
</style>
<script src="https://get.mavo.io/mavo.js"></script>
<script src="mavotest.js"></script>
</head>
<body>
<h1>mv-value tests</h1>
<script type="application/json" id="countries">{
"country": [
{
"code": "",
"name": "Online"
},
{
"code": "us",
"name": "United States"
},
{
"code": "gb",
"name": "United Kingdom"
}
]
}</script>
<section mv-app="mvvalue">
<h1>Basic</h1>
<table class="reftest">
<tr>
<td><div mv-value="39 + 3">Without expression syntax</div></td>
<td>42</td>
</tr>
<tr>
<td><div mv-value="(39 + 3">With bug</div></td>
<td>With bug</td>
</tr>
<tr>
<td><input mv-value="39 + 3" value="In attribute"></td>
<td><input value="42"></td>
</tr>
<tr title="Empty expression">
<td><div mv-value="">You shouldn't see this</div></td>
<td></td>
</tr>
<tr title="Object">
<td>
<div property="group1" typeof mv-value="group(foo: 1, bar: 2)">
[foo] + [bar] = [foo + bar]
</div>
</td>
<td>1 + 2 = 3</td>
</tr>
<tr title="Object with property">
<td>
<div property="group2" typeof mv-value="group(foo: 1, bar: 2)">
<span property="bar">10</span>
<span property="prop1">3</span>
[foo + bar + prop1]
</div>
</td>
<td>2 3 6</td>
</tr>
<tr title="Nested groups">
<td>
<div property="group3" mv-value="group(prop2: 1, group4: (prop3: 2))">
<span property="prop2"></span>
<div property="group4">
<span property="prop3"></span>
</div>
</div>
</td>
<td>1 <br>2</td>
</tr>
<tr title="Reference collision">
<td>
<span property="prop4">1</span>
<div property="group4" mv-group mv-value="prop4: 2">
[prop4]
</div>
</td>
<td>1 <div>2</div></td>
</tr>
</table>
</section>
<section mv-app="collections">
<h1>Collections</h1>
<table class="reftest">
<tr title="Collection">
<td>
<div property="collection1" mv-multiple mv-group mv-value='[
"number": 1,
"number": 2,
"number": 3
]'>
#<span property=number></span>
</div>
</td>
<td>
#1<br>
#2<br>
#3
</td>
</tr>
<tr title="Collection of primitives">
<td>
<span property="collection2" mv-multiple mv-value='[1, 2, 3]'></span>
</td>
<td>123</td>
</tr>
<tr title="Collection of primitives, interactive" data-click=".mv-add-collection3 wait 3s">
<td>
<span property="collection3" mv-multiple mv-mode="edit" mv-default="[$index]"></span>
</td>
<td>
<span property="collection4" mv-multiple mv-value="collection3"></span>
</td>
</tr>
<tr title="Collection of groups, interactive" data-click=".mv-add-collection5 wait 3s">
<td>
<div property="collection5" mv-multiple mv-mode="edit">
<span property="prop" mv-default="Foo"></span>
<span property="prop1" mv-default="[$index]"></span>
</div>
</td>
<td>
<div property="collection6" mv-multiple mv-group mv-value="collection5">
[prop]
<span property="prop1"></span>
</div>
</td>
</tr>
<tr title="Collection of groups, interactive" data-click=".mv-add-collection7 wait 3s">
<td>
<div property="collection7" mv-multiple mv-mode="edit">
<span property="prop2" mv-default="Foo[$index]"></span>
<span property="prop3" mv-default="[$index]"></span>
</div>
</td>
<td>
<div property="collection8" mv-multiple mv-group mv-value="collection7">
[prop2]
<span property="prop3"></span>
</div>
</td>
</tr>
<tr title="Populating a <select multiple>">
<td>
<select multiple mv-list property="foo" mv-value="[1, 2, 3, 4]">
<option mv-list-item selected></option>
</select>
</td>
<td>
1 2 3 4
</td>
</tr>
<tr title="Populating a <select> which is also a property">
<td>
<select property id="prop1">
<option mv-multiple mv-value="[1, 2, 3, 4]"></option>
</select>
[prop1]
</td>
<td>
1 1
</td>
</tr>
<tr title="Populating a <select multiple> which is also a property">
<td>
<select property id="prop2" multiple>
<option mv-multiple="opt" mv-value="[1, 2, 3, 4]" selected="[opt = 2]"></option>
</select>
[prop2]
</td>
<td>
2 2
</td>
</tr>
</table>
</section>
<section>
<h1>Render array of primitives on collection of groups</h1>
<table class="reftest">
<tr>
<td>
<div mv-app="statuses">
[count(status)]
<dl property="status" mv-multiple mv-value="[1, 2, 3, 4]">
<dt property="prop1">[prop2]</dt>
<dd property="prop2">1</dd>
</dl>
</div>
</td>
<td>
4
1 1
2 2
3 3
4 4
</td>
</tr>
</table>
</section>
<section>
<h1>Render inner property</h1>
<table class="reftest">
<tr mv-app mv-storage="#countries">
<td>
<ul>
<li property="country" mv-multiple>
<span property="code"></span> [code]
<span property="name"></span> [name]
</li>
</ul>
</td>
<td>
<span property="person" mv-multiple mv-value="name"></span>
</td>
<td>
OnlineUnited StatesUnited Kingdom
</td>
</tr>
</table>
</section>
<section>
<h1>mv-value inside collection</h1>
<table class="reftest">
<tr mv-app mv-storage="#countries">
<td>
<ul>
<li property="country" mv-multiple>
<span property="code"></span>
<span property="name"></span>
<span mv-value="code"></span>
<meta mv-value="5 + 5">
<span mv-value="[1, 2, 3]"></span>
</li>
</ul>
</td>
<td>
<ul>
<li>
Online
1, 2, 3
</li><li>
us
United States
us
1, 2, 3
</li><li>
gb
United Kingdom
gb
1, 2, 3
</li>
</ul>
</td>
</tr>
</table>
</section>
<section mv-app class="mv-autoedit">
<h1>Property edited with dynamic select</h1>
<table class="reftest">
<tr>
<td>
<div property="event" mv-multiple>
<span property="name">Event name</span>
<meta property="id" mv-default="[idify(name)]">
</div>
<div property="event" mv-multiple>
<span property="name">Foo Bar</span>
<meta property="id" mv-default="foo-bar">
</div>
</td>
<td>
Event name id
Foo Bar id
</td>
</tr>
<tr>
<td>
<select id="events">
<option mv-multiple="eventOption" value="[id]" mv-value="event" mv-group>[name]</option>
</select>
</td>
<td>Event name</td>
</tr>
<tr>
<td>
<span property="eventId" mv-editor="#events"></span>
</td>
<td>
Event name
</td>
</tr>
<tr>
<td>[eventId]</td>
<td>event-name</td>
</tr>
</table>
</section>
<section mv-app>
<h1>Inside mv-expressions="none"</h1>
<table class="reftest" mv-expressions="none">
<td mv-value="5 + 5"></td>
<td>10</td>
</table>
</section>
<section>
<h1>Cross-references</h1>
<script id="checkboxes" type="application/json">
{
"issue": [
{
"tag": "foo"
},
{
"tag": "bar"
}
]
}
</script>
<table class="reftest" mv-app id="issues" mv-storage="#checkboxes" mv-expressions="{ }">
<tr data-click="label:first-of-type input[type=checkbox] wait 1s">
<td>
<label property="tagFilter" mv-multiple mv-value="unique(issue.tag)">
<input type="checkbox" property="show">
{show}
<span property="tagFilter"></span>
</label>
</td>
<td>
on true foo
on false bar
</td>
</tr>
<tr>
<td>
<span property="selectedTags">{tagFilter.show}</span>
</td>
<td>
true, false
</td>
</tr>
<tr>
<td>
<div property="issue" mv-multiple>
<span property="shown">{selectedTags}</span>
<span property="tag" mv-multiple>Tag</span>
</div>
</td>
<td>
true, false foo
true, false bar
</td>
</tr>
</table>
</section>
</body>
</html>