@pageboard/html 0.15.11 → 0.15.12
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/elements/image.js +1 -1
- package/package.json +1 -1
- package/ui/textarea.js +3 -0
- package/elements/input-property.js +0 -345
package/elements/image.js
CHANGED
package/package.json
CHANGED
package/ui/textarea.js
CHANGED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
exports.input_property = {
|
|
2
|
-
// deprecated
|
|
3
|
-
menu: 'form',
|
|
4
|
-
group: 'block',
|
|
5
|
-
context: 'form//',
|
|
6
|
-
properties: {
|
|
7
|
-
name: {
|
|
8
|
-
title: 'Name',
|
|
9
|
-
type: 'string',
|
|
10
|
-
format: 'singleline',
|
|
11
|
-
$helper: 'element-property'
|
|
12
|
-
},
|
|
13
|
-
radios: {
|
|
14
|
-
title: 'Radios < Select',
|
|
15
|
-
type: 'integer',
|
|
16
|
-
default: 5
|
|
17
|
-
},
|
|
18
|
-
range: {
|
|
19
|
-
title: 'Range < Input',
|
|
20
|
-
type: 'integer',
|
|
21
|
-
default: 10
|
|
22
|
-
},
|
|
23
|
-
disabled: {
|
|
24
|
-
title: 'Disabled',
|
|
25
|
-
type: 'boolean',
|
|
26
|
-
default: false
|
|
27
|
-
},
|
|
28
|
-
multiple: {
|
|
29
|
-
title: 'Multiple choices',
|
|
30
|
-
type: 'boolean',
|
|
31
|
-
default: false
|
|
32
|
-
},
|
|
33
|
-
foldable: {
|
|
34
|
-
title: 'Foldable',
|
|
35
|
-
type: 'boolean',
|
|
36
|
-
default: false
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
html: '<div><code>select property name</code></div>',
|
|
40
|
-
fuse: function(node, d, scope) {
|
|
41
|
-
const doc = scope.$doc;
|
|
42
|
-
const dateFormats = ["date", "time", "date-time"];
|
|
43
|
-
let name = d.name;
|
|
44
|
-
if (!name) {
|
|
45
|
-
return node;
|
|
46
|
-
}
|
|
47
|
-
const list = name.split('.');
|
|
48
|
-
const el = scope.$elements[list[0]];
|
|
49
|
-
if (!el) {
|
|
50
|
-
return node;
|
|
51
|
-
}
|
|
52
|
-
// list[0] = "data";
|
|
53
|
-
// /@api/form wraps it into block.data
|
|
54
|
-
list.shift();
|
|
55
|
-
name = list.join('.');
|
|
56
|
-
const id = scope.$id;
|
|
57
|
-
let prop = el;
|
|
58
|
-
let propKey;
|
|
59
|
-
let required = false;
|
|
60
|
-
let cases = null;
|
|
61
|
-
let discKey = null;
|
|
62
|
-
for (let i = 0; i < list.length; i++) {
|
|
63
|
-
propKey = list[i];
|
|
64
|
-
required = prop.required && prop.required.indexOf(propKey) >= 0;
|
|
65
|
-
if (cases) {
|
|
66
|
-
if (Array.isArray(cases)) {
|
|
67
|
-
prop = cases.find(obj => {
|
|
68
|
-
if (obj.properties && obj.properties[discKey] && obj.properties[discKey].const == propKey) {
|
|
69
|
-
return true;
|
|
70
|
-
} else {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
} else {
|
|
75
|
-
prop = cases[propKey];
|
|
76
|
-
}
|
|
77
|
-
name = list.slice(0, i - 1).concat(list.slice(i + 1)).join('.');
|
|
78
|
-
cases = null;
|
|
79
|
-
discKey = null;
|
|
80
|
-
} else {
|
|
81
|
-
if (prop.type == "array" && prop.items && !Array.isArray(prop.items)) {
|
|
82
|
-
prop = prop.items;
|
|
83
|
-
}
|
|
84
|
-
if (prop.select && prop.select.$data == `0/${propKey}`) {
|
|
85
|
-
cases = prop.selectCases;
|
|
86
|
-
} else if (prop.discriminator && prop.discriminator.propertyName == propKey) {
|
|
87
|
-
cases = prop.oneOf;
|
|
88
|
-
discKey = propKey;
|
|
89
|
-
}
|
|
90
|
-
if (prop.properties) prop = prop.properties;
|
|
91
|
-
prop = prop[propKey];
|
|
92
|
-
}
|
|
93
|
-
if (prop == null) break;
|
|
94
|
-
}
|
|
95
|
-
if (!prop) {
|
|
96
|
-
return node;
|
|
97
|
-
}
|
|
98
|
-
node.textContent = "";
|
|
99
|
-
if (prop.nullable) required = false;
|
|
100
|
-
let propType = prop;
|
|
101
|
-
let multiple = d.multiple;
|
|
102
|
-
if (prop.type == "array" && prop.items && Array.isArray(prop.items) == false) {
|
|
103
|
-
propType = prop.items;
|
|
104
|
-
multiple = true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
let listOf = propType.anyOf || propType.oneOf;
|
|
108
|
-
if (listOf) {
|
|
109
|
-
const listOfNo = listOf.filter(item => item.type != "null");
|
|
110
|
-
if (listOfNo.length != listOf.length) {
|
|
111
|
-
required = false;
|
|
112
|
-
}
|
|
113
|
-
if (listOfNo.length == 1 && listOfNo[0].const === undefined) {
|
|
114
|
-
propType = listOfNo[0];
|
|
115
|
-
listOf = null;
|
|
116
|
-
} else if (multiple) {
|
|
117
|
-
listOf = listOfNo;
|
|
118
|
-
}
|
|
119
|
-
} else if (Array.isArray(prop.type)) {
|
|
120
|
-
listOf = prop.type.filter(type => {
|
|
121
|
-
if (type == "null") {
|
|
122
|
-
required = false;
|
|
123
|
-
return false;
|
|
124
|
-
} else {
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
if (listOf.length == 1) {
|
|
129
|
-
propType = listOf[0];
|
|
130
|
-
listOf = null;
|
|
131
|
-
} else {
|
|
132
|
-
listOf = null; // cannot deal with this for now
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (listOf) {
|
|
137
|
-
if (listOf.length <= d.radios) {
|
|
138
|
-
let content;
|
|
139
|
-
if (d.foldable) {
|
|
140
|
-
content = doc.dom(`<element-accordion class="grouped fields">
|
|
141
|
-
<label for="${name}" class="title active caret-icon">${prop.title}</label>
|
|
142
|
-
<div class="content"></div>
|
|
143
|
-
</element-accordion>`);
|
|
144
|
-
} else {
|
|
145
|
-
content = doc.dom(`<div class="grouped fields">
|
|
146
|
-
<label for="${name}" class="title">${prop.title}</label>
|
|
147
|
-
<div class="content"></div>
|
|
148
|
-
</div>`);
|
|
149
|
-
}
|
|
150
|
-
node.appendChild(content);
|
|
151
|
-
content = content.lastElementChild;
|
|
152
|
-
for (const item of listOf) {
|
|
153
|
-
content.appendChild(scope.render({
|
|
154
|
-
type: multiple ? 'input_checkbox' : 'input_radio',
|
|
155
|
-
id,
|
|
156
|
-
data: {
|
|
157
|
-
name: name,
|
|
158
|
-
value: item.type == "null" ? null : item.const,
|
|
159
|
-
disabled: d.disabled
|
|
160
|
-
},
|
|
161
|
-
content: {
|
|
162
|
-
label: item.title
|
|
163
|
-
}
|
|
164
|
-
}));
|
|
165
|
-
}
|
|
166
|
-
} else {
|
|
167
|
-
const frag = doc.createDocumentFragment();
|
|
168
|
-
for (const item of listOf) {
|
|
169
|
-
frag.appendChild(scope.render({
|
|
170
|
-
type: 'input_select_option',
|
|
171
|
-
data: {
|
|
172
|
-
value: item.type == "null" ? null : item.const
|
|
173
|
-
},
|
|
174
|
-
content: {
|
|
175
|
-
label: item.title
|
|
176
|
-
}
|
|
177
|
-
}));
|
|
178
|
-
}
|
|
179
|
-
node.appendChild(scope.render({
|
|
180
|
-
id,
|
|
181
|
-
type: 'input_select',
|
|
182
|
-
data: {
|
|
183
|
-
name: name,
|
|
184
|
-
multiple: multiple,
|
|
185
|
-
disabled: d.disabled,
|
|
186
|
-
required: required
|
|
187
|
-
},
|
|
188
|
-
content: {
|
|
189
|
-
label: prop.title,
|
|
190
|
-
options: frag
|
|
191
|
-
}
|
|
192
|
-
}));
|
|
193
|
-
}
|
|
194
|
-
} else if (propType.type == "integer" || propType.type == "number") {
|
|
195
|
-
const step = propType.multipleOf || (propType.type == "integer" ? 1 : 0.001);
|
|
196
|
-
if (propType.minimum != null && propType.maximum != null) {
|
|
197
|
-
if (propType.maximum - propType.minimum <= d.range) {
|
|
198
|
-
return node.appendChild(scope.render({
|
|
199
|
-
id,
|
|
200
|
-
type: 'input_range',
|
|
201
|
-
data: {
|
|
202
|
-
name: name,
|
|
203
|
-
min: propType.minimum,
|
|
204
|
-
max: propType.maximum,
|
|
205
|
-
value: multiple ? `${propType.minimum}⩽${propType.maximum}` : propType.default,
|
|
206
|
-
disabled: d.disabled,
|
|
207
|
-
required: required,
|
|
208
|
-
multiple: multiple,
|
|
209
|
-
step: step
|
|
210
|
-
},
|
|
211
|
-
content: {
|
|
212
|
-
label: prop.title
|
|
213
|
-
}
|
|
214
|
-
}));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
node.appendChild(scope.render({
|
|
218
|
-
id,
|
|
219
|
-
type: 'input_number',
|
|
220
|
-
data: {
|
|
221
|
-
name: name,
|
|
222
|
-
default: propType.default,
|
|
223
|
-
disabled: d.disabled,
|
|
224
|
-
required: required,
|
|
225
|
-
min: propType.minimum,
|
|
226
|
-
max: propType.maximum,
|
|
227
|
-
step: step
|
|
228
|
-
},
|
|
229
|
-
content: {
|
|
230
|
-
label: prop.title
|
|
231
|
-
}
|
|
232
|
-
}));
|
|
233
|
-
} else if (propType.type == "boolean") {
|
|
234
|
-
node.appendChild(scope.render({
|
|
235
|
-
id,
|
|
236
|
-
type: 'input_checkbox',
|
|
237
|
-
data: {
|
|
238
|
-
name: name,
|
|
239
|
-
value: "true",
|
|
240
|
-
disabled: d.disabled,
|
|
241
|
-
required: required
|
|
242
|
-
},
|
|
243
|
-
content: {
|
|
244
|
-
label: prop.title
|
|
245
|
-
}
|
|
246
|
-
}));
|
|
247
|
-
} else if (propType.type == "object" && Object.keys(propType.properties).sort().join(' ') == "end start" && dateFormats.includes(propType.properties.start.format) && dateFormats.includes(propType.properties.end.format)) {
|
|
248
|
-
node.appendChild(scope.render({
|
|
249
|
-
id,
|
|
250
|
-
type: 'input_date_slot',
|
|
251
|
-
data: {
|
|
252
|
-
nameStart: name,
|
|
253
|
-
nameEnd: name,
|
|
254
|
-
format: propType.properties.start.format.replace('-', ''),
|
|
255
|
-
disabled: d.disabled,
|
|
256
|
-
required: required,
|
|
257
|
-
step: propType.properties.start.step
|
|
258
|
-
},
|
|
259
|
-
content: {
|
|
260
|
-
label: prop.title
|
|
261
|
-
}
|
|
262
|
-
}));
|
|
263
|
-
} else if (propType.type == "string" && dateFormats.includes(propType.format)) {
|
|
264
|
-
if (d.multiple) node.appendChild(scope.render({
|
|
265
|
-
id,
|
|
266
|
-
type: 'input_date_slot',
|
|
267
|
-
data: {
|
|
268
|
-
nameStart: name,
|
|
269
|
-
nameEnd: name,
|
|
270
|
-
format: propType.format.replace('-', ''),
|
|
271
|
-
default: propType.default,
|
|
272
|
-
disabled: d.disabled,
|
|
273
|
-
required: required,
|
|
274
|
-
step: propType.step
|
|
275
|
-
},
|
|
276
|
-
content: {
|
|
277
|
-
label: prop.title
|
|
278
|
-
}
|
|
279
|
-
}));
|
|
280
|
-
else node.appendChild(scope.render({
|
|
281
|
-
id,
|
|
282
|
-
type: 'input_date_time',
|
|
283
|
-
data: {
|
|
284
|
-
name: name,
|
|
285
|
-
format: propType.format.replace('-', ''),
|
|
286
|
-
default: propType.default,
|
|
287
|
-
disabled: d.disabled,
|
|
288
|
-
required: required,
|
|
289
|
-
step: propType.step
|
|
290
|
-
},
|
|
291
|
-
content: {
|
|
292
|
-
label: prop.title
|
|
293
|
-
}
|
|
294
|
-
}));
|
|
295
|
-
} else if (propType.$helper && propType.$helper.name == "href") {
|
|
296
|
-
const limits = {
|
|
297
|
-
files: multiple ? null : 1
|
|
298
|
-
};
|
|
299
|
-
const filter = propType.$helper.filter;
|
|
300
|
-
if (filter && filter.type) {
|
|
301
|
-
limits.types = filter.type.map(type => {
|
|
302
|
-
if (type == "image") return "image/*";
|
|
303
|
-
else if (type == "video") return "video/*";
|
|
304
|
-
else return "*/*";
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
node.appendChild(scope.render({
|
|
308
|
-
id,
|
|
309
|
-
type: 'input_file',
|
|
310
|
-
data: {
|
|
311
|
-
name: name,
|
|
312
|
-
disabled: d.disabled,
|
|
313
|
-
required: required,
|
|
314
|
-
limits: limits
|
|
315
|
-
},
|
|
316
|
-
content: {
|
|
317
|
-
label: prop.title
|
|
318
|
-
}
|
|
319
|
-
}));
|
|
320
|
-
} else {
|
|
321
|
-
const type = (propType.format || propType.pattern) ? 'text' : 'textarea';
|
|
322
|
-
node.appendChild(scope.render({
|
|
323
|
-
id,
|
|
324
|
-
type: 'input_text',
|
|
325
|
-
data: {
|
|
326
|
-
name, type, required,
|
|
327
|
-
disabled: d.disabled,
|
|
328
|
-
default: propType.default
|
|
329
|
-
},
|
|
330
|
-
content: {
|
|
331
|
-
label: prop.title
|
|
332
|
-
}
|
|
333
|
-
}));
|
|
334
|
-
}
|
|
335
|
-
return node;
|
|
336
|
-
},
|
|
337
|
-
stylesheets: [
|
|
338
|
-
'../ui/components/accordion.css',
|
|
339
|
-
'../ui/accordion.css'
|
|
340
|
-
],
|
|
341
|
-
scripts: [
|
|
342
|
-
'../ui/accordion.js'
|
|
343
|
-
]
|
|
344
|
-
};
|
|
345
|
-
|