forked from SolidOS/solid-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
303 lines (277 loc) · 14.7 KB
/
Copy pathindex.html
File metadata and controls
303 lines (277 loc) · 14.7 KB
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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset='UTF-8'>
<title>solid-ui UI.widgets.forms examples page</title>
<script type="text/javascript" src="../../lib/webpack-bundle.js"></script>
<script>
function showSource(widgetName) {
document.getElementById(`viewSource-${widgetName}`).innerHTML = document.getElementById(`script-${widgetName}`).innerText
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'")
}
</script>
</head>
<body>
<h1>See also:</h1>
<ul>
<li><a href="../../Documentation/forms-intro.html">Forms intro</a></li>
<li><a href="../../Documentation/form-ecosystem.html">Form ecosystem</a></li>
<li><a href="https://solid.github.io/form-playground/playground.html">Form Playground</a></li>
<li><a href="https://solid.github.io/form-playground/browse.html">Form Browse</a></li>
<li><a href="../../Documentation/api/">API docs</a></li>
</ul>
<!-- <h2 id="templateTitle"><a href="#templateTitle">templateTitle</a></h2>
<script id="script-templateTitle">
window.addEventListener('DOMContentLoaded', (event) => {
UI.widgets.templateTitle()
})
</script>
<pre id="viewSource-templateTitle"></pre><script>showSource('templateTitle')</script>
<div id="div-templateTitle"></div> -->
<h2 id="appendFormTrivial"><a href="#appendFormTrivial">appendForm, trivial / Comment Field</a></h2>
<p>This example shows a trivial use of the `appendForm` function, in conjunction with a Comment field.</p>
<script id="script-appendFormTrivial">
window.addEventListener('DOMContentLoaded', async (event) => {
const dom = document
const container = document.getElementById('div-appendFormTrivial')
const already = {}
const subject = UI.rdf.namedNode('http://example.com/#subject')
const form = UI.rdf.namedNode('http://example.com/#form')
const doc = subject.doc()
const callbackFunction = () => {
console.log('callback appendFormTrivial called!')
}
UI.store.add(UI.rdf.namedNode('http://example.com/#form'), UI.ns.rdf('type'), UI.ns.ui('Comment'))
UI.store.add(UI.rdf.namedNode('http://example.com/#form'), UI.ns.ui('contents'), '[a trivial form with just a comment]')
UI.widgets.appendForm(dom, container, already, subject, form, doc)
})
</script>
<pre id="viewSource-appendFormTrivial"></pre><script>showSource('appendFormTrivial')</script>
<div id="div-appendFormTrivial"></div>
<h2 id="appendFormLive"><a href="#appendFormLive">appendForm, live</a></h2>
<script id="script-appendFormLive">
window.addEventListener('DOMContentLoaded', async (event) => {
const dom = document
const container = document.getElementById('div-appendFormLive')
const already = {}
const subject = UI.rdf.namedNode('https://michielbdejong.inrupt.net/profile/card#me')
const form = UI.rdf.namedNode('https://timbl.com/timbl/Public/Test/Forms/individualForm.ttl#form1')
const doc = subject.doc()
const callbackFunction = () => {
console.log('callback appendFormLive called!')
}
await UI.store.fetcher.load(doc)
await UI.store.fetcher.load(form.doc())
UI.widgets.appendForm(dom, container, already, subject, form, doc)
})
</script>
<pre id="viewSource-appendFormLive"></pre><script>showSource('appendFormLive')</script>
<div id="div-appendFormLive"></div>
<h2 id="basicField"><a href="#basicField">basic fields</a></h2>
<script id="script-basicField">
window.addEventListener('DOMContentLoaded', (event) => {
const container = document.getElementById('div-basicField')
const already = {}
const subject = UI.rdf.namedNode('http://example.com/#this')
const form = UI.rdf.namedNode('http://example.com/#form')
const doc = UI.rdf.namedNode('http://example.com/')
const callbackFunction = (ok, errorMessage) => {
console.log(ok, errorMessage, document.getElementById('div-basicField').innerHTML);
}
UI.store.add(form, UI.ns.ui('property'), UI.rdf.namedNode('http://example.com/#some-property'), doc)
// FIXME: https://github.com/solid/solid-ui/issues/239
document.outlineManager = {
appendPropertyTRs: () => {}
}
;[
'PhoneField',
'EmailField',
'ColorField',
'DateField',
'DateTimeField',
'TimeField',
'NumericField',
'IntegerField',
'DecimalField',
'FloatField',
'TextField',
'SingleLineTextField',
'NamedNodeURIField'
].forEach((fieldName) => {
UI.widgets.field[UI.ns.ui(fieldName).uri](
document,
container,
already,
subject,
form,
doc,
callbackFunction
);
})
});
</script>
<pre id="viewSource-basicField"></pre><script>showSource('basicField')</script>
<div id="div-basicField"></div>
<h2 id="formField"><a href="#formField">UI.widgets.field[UI.ns.ui('Form').uri] / UI.widgets.field[UI.ns.ui('Group').uri], no already</a></h2>
<script id="script-formField">
window.addEventListener('DOMContentLoaded', (event) => {
const container = document.getElementById('div-formField')
const already = {}
const subject = UI.rdf.namedNode('http://example.com/#this')
const form = UI.rdf.namedNode('http://example.com/#form')
const store = UI.rdf.namedNode('http://example.com/#store')
const callbackFunction = (ok, errorMessage) => {
console.log(ok, errorMessage, document.getElementById('div-formField').innerHTML);
}
UI.store.add(form, UI.ns.ui('parts'), new UI.rdf.Collection([
UI.rdf.namedNode('http://example.com/#part1'),
UI.rdf.namedNode('http://example.com/#part2')
]), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#part1'), UI.ns.rdf('type'), UI.ns.ui('Comment'))
UI.store.add(UI.rdf.namedNode('http://example.com/#part1'), UI.ns.ui('contents'), '[this is part 1 of the form]')
UI.store.add(UI.rdf.namedNode('http://example.com/#part2'), UI.ns.rdf('type'), UI.ns.ui('Comment'))
UI.store.add(UI.rdf.namedNode('http://example.com/#part2'), UI.ns.ui('contents'), '[this is part 2 of the form]')
// FIXME: https://github.com/solid/solid-ui/issues/239
document.outlineManager = {
appendPropertyTRs: () => {}
}
UI.widgets.field[UI.ns.ui('Form').uri](
document,
container,
already,
subject,
form,
store,
callbackFunction
);
})
</script>
<pre id="viewSource-formField"></pre><script>showSource('formField')</script>
<div id="div-formField"></div>
<h2 id="groupField"><a href="#groupField">UI.widgets.field[UI.ns.ui('Form').uri] / xUI.widgets.field[UI.ns.ui('Group').uri], with already</a></h2>
<script id="script-groupField">
// UI.widgets.field[UI.ns.ui('Group').uri] is currently synonymous with
// UI.widgets.field[UI.ns.ui('Form').uri], but this additional example
// shows the use of `already`.
window.addEventListener('DOMContentLoaded', (event) => {
const container = document.getElementById('div-groupField')
const subject = UI.rdf.namedNode('http://example.com/#this')
const form = UI.rdf.namedNode('http://example.com/#form')
const store = UI.rdf.namedNode('http://example.com/#store')
const key = subject.toNT() + '|' + form.toNT()
const already = {
[key]: true
}
const callbackFunction = (ok, errorMessage) => {
console.log(ok, errorMessage, document.getElementById('div-groupField').innerHTML);
}
// FIXME: https://github.com/solid/solid-ui/issues/239
document.outlineManager = {
appendPropertyTRs: () => {}
}
UI.widgets.field[UI.ns.ui('Group').uri](
document,
container,
already,
subject,
form,
store,
callbackFunction
)
})
</script>
<pre id="viewSource-groupField"></pre><script>showSource('groupField')</script>
<div id="div-groupField"></div>
<h2 id="optionsFieldType"><a href="#optionsFieldType">UI.widgets.field[UI.ns.ui('Options').uri], using RDF types</a></h2>
<script id="script-optionsFieldType">
window.addEventListener('DOMContentLoaded', (event) => {
const container = document.getElementById('div-optionsFieldType')
const already = {}
const subject = UI.rdf.namedNode('http://example.com/#this')
const exampleOptionsField = UI.rdf.namedNode('http://example.com/#exampleOptionsField')
const store = UI.rdf.namedNode('http://example.com/#store')
const callbackFunction = (ok, errorMessage) => {
console.log(ok, errorMessage, document.getElementById('div-optionsFieldType').innerHTML);
}
// UI to display in case subject is a house:
UI.store.add(exampleOptionsField, UI.ns.ui('case'), UI.rdf.namedNode('http://example.com/#if-subject-is-house'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#if-subject-is-house'), UI.ns.ui('for'), UI.rdf.namedNode('http://example.com/#house'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#if-subject-is-house'), UI.ns.ui('use'), UI.rdf.namedNode('http://example.com/#number-of-bedrooms'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#number-of-bedrooms'), UI.ns.rdf('type'), UI.ns.ui('Comment'))
UI.store.add(UI.rdf.namedNode('http://example.com/#number-of-bedrooms'), UI.ns.ui('contents'), '[UI for houses]')
// UI to display in case subject is a cow:
UI.store.add(exampleOptionsField, UI.ns.ui('case'), UI.rdf.namedNode('http://example.com/#if-subject-is-cow'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#if-subject-is-cow'), UI.ns.ui('for'), UI.rdf.namedNode('http://example.com/#cow'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#if-subject-is-cow'), UI.ns.ui('use'), UI.rdf.namedNode('http://example.com/#number-of-legs'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#number-of-legs'), UI.ns.rdf('type'), UI.ns.ui('Comment'))
UI.store.add(UI.rdf.namedNode('http://example.com/#number-of-legs'), UI.ns.ui('contents'), '[UI for cows]')
// Subject is a cow, so it should display [UI for cows]
UI.store.add(subject, UI.ns.rdf('type'), UI.rdf.namedNode('http://example.com/#cow'), UI.rdf.namedNode('http://example.com/'))
// FIXME: https://github.com/solid/solid-ui/issues/239
document.outlineManager = {
appendPropertyTRs: () => {}
}
const result = UI.widgets.field[UI.ns.ui('Options').uri](
document,
container,
already,
subject,
exampleOptionsField,
store,
callbackFunction
)
})
</script>
<pre id="viewSource-optionsFieldType"></pre><script>showSource('optionsFieldType')</script>
<div id="div-optionsFieldType"></div>
<h2 id="optionsFieldDependingOn"><a href="#optionsFieldDependingOn">UI.widgets.field[UI.ns.ui('Options').uri], using dependingOn</a></h2>
<script id="script-optionsFieldDependingOn">
window.addEventListener('DOMContentLoaded', (event) => {
const container = document.getElementById('div-optionsFieldDependingOn')
const already = {}
const subject = UI.rdf.namedNode('http://example.com/#this')
const exampleOptionsField = UI.rdf.namedNode('http://example.com/#exampleOptionsField')
const store = UI.rdf.namedNode('http://example.com/#store')
const callbackFunction = (ok, errorMessage) => {
console.log(ok, errorMessage, document.getElementById('div-optionsFieldDependingOn').innerHTML);
}
// This form depends on colour:
UI.store.add(exampleOptionsField, UI.ns.ui('dependingOn'), UI.rdf.namedNode('http://example.com/#persona'), UI.rdf.namedNode('http://example.com/'))
// UI to display in case subject is blue:
UI.store.add(exampleOptionsField, UI.ns.ui('case'), UI.rdf.namedNode('http://example.com/#if-subject-is-developer'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#if-subject-is-developer'), UI.ns.ui('for'), UI.rdf.namedNode('http://example.com/#developer'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#if-subject-is-developer'), UI.ns.ui('use'), UI.rdf.namedNode('http://example.com/#ui-for-developers'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#ui-for-developers'), UI.ns.rdf('type'), UI.ns.ui('Comment'))
UI.store.add(UI.rdf.namedNode('http://example.com/#ui-for-developers'), UI.ns.ui('contents'), '[UI for developers]')
// UI to display in case subject is red:
UI.store.add(exampleOptionsField, UI.ns.ui('case'), UI.rdf.namedNode('http://example.com/#if-subject-is-power-user'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#if-subject-is-power-user'), UI.ns.ui('for'), UI.rdf.namedNode('http://example.com/#power-user'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#if-subject-is-power-user'), UI.ns.ui('use'), UI.rdf.namedNode('http://example.com/#ui-for-power-users'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(UI.rdf.namedNode('http://example.com/#ui-for-power-users'), UI.ns.rdf('type'), UI.ns.ui('Comment'))
UI.store.add(UI.rdf.namedNode('http://example.com/#ui-for-power-users'), UI.ns.ui('contents'), '[UI for power users]')
// Subject is both a developer and a power user, so it should display both [UI for developers] and [UI for power users]
UI.store.add(subject, UI.rdf.namedNode('http://example.com/#persona'), UI.rdf.namedNode('http://example.com/#developer'), UI.rdf.namedNode('http://example.com/'))
UI.store.add(subject, UI.rdf.namedNode('http://example.com/#persona'), UI.rdf.namedNode('http://example.com/#power-user'), UI.rdf.namedNode('http://example.com/'))
// FIXME: https://github.com/solid/solid-ui/issues/239
document.outlineManager = {
appendPropertyTRs: () => {}
}
const result = UI.widgets.field[UI.ns.ui('Options').uri](
document,
container,
already,
subject,
exampleOptionsField,
store,
callbackFunction
)
})
</script>
<pre id="viewSource-optionsFieldDependingOn"></pre><script>showSource('optionsFieldDependingOn')</script>
<div id="div-optionsFieldDependingOn"></div>
</body>
</html>