@pageboard/html 0.10.8 → 0.10.9

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.
@@ -54,6 +54,7 @@ exports.input_property = {
54
54
  // /.api/form wraps it into block.data
55
55
  list.shift();
56
56
  name = list.join('.');
57
+ const id = scope.$id;
57
58
  let prop = el;
58
59
  let propKey;
59
60
  let required = false;
@@ -77,8 +78,14 @@ exports.input_property = {
77
78
  }
78
79
  node.textContent = "";
79
80
  if (prop.nullable) required = false;
80
- let listOf = prop.anyOf || prop.oneOf;
81
- let propType;
81
+ let propType = prop;
82
+ let multiple = d.multiple;
83
+ if (prop.type == "array" && prop.items && Array.isArray(prop.items) == false) {
84
+ propType = prop.items;
85
+ multiple = true;
86
+ }
87
+
88
+ let listOf = propType.anyOf || propType.oneOf;
82
89
  if (listOf) {
83
90
  const listOfNo = listOf.filter((item) => item.type != "null");
84
91
  if (listOfNo.length != listOf.length) {
@@ -87,7 +94,7 @@ exports.input_property = {
87
94
  if (listOfNo.length == 1 && listOfNo[0].const === undefined) {
88
95
  propType = listOfNo[0];
89
96
  listOf = null;
90
- } else if (d.multiple) {
97
+ } else if (multiple) {
91
98
  listOf = listOfNo;
92
99
  }
93
100
  } else if (Array.isArray(prop.type)) {
@@ -106,7 +113,6 @@ exports.input_property = {
106
113
  listOf = null; // cannot deal with this for now
107
114
  }
108
115
  }
109
- if (!propType) propType = prop;
110
116
 
111
117
  if (listOf) {
112
118
  if (listOf.length <= d.radios) {
@@ -126,7 +132,7 @@ exports.input_property = {
126
132
  content = content.lastElementChild;
127
133
  for (const item of listOf) {
128
134
  content.appendChild(view.render({
129
- type: d.multiple ? 'input_checkbox' : 'input_radio',
135
+ type: multiple ? 'input_checkbox' : 'input_radio',
130
136
  data: {
131
137
  name: name,
132
138
  value: item.type == "null" ? null : item.const,
@@ -151,10 +157,11 @@ exports.input_property = {
151
157
  }));
152
158
  }
153
159
  node.appendChild(view.render({
160
+ id,
154
161
  type: 'input_select',
155
162
  data: {
156
163
  name: name,
157
- multiple: d.multiple,
164
+ multiple: multiple,
158
165
  placeholder: prop.description,
159
166
  disabled: d.disabled,
160
167
  required: required
@@ -170,15 +177,16 @@ exports.input_property = {
170
177
  if (propType.minimum != null && propType.maximum != null) {
171
178
  if (propType.maximum - propType.minimum <= d.range) {
172
179
  return node.appendChild(view.render({
180
+ id,
173
181
  type: 'input_range',
174
182
  data: {
175
183
  name: name,
176
184
  min: propType.minimum,
177
185
  max: propType.maximum,
178
- value: d.multiple ? `${propType.minimum}⩽${propType.maximum}` : propType.default,
186
+ value: multiple ? `${propType.minimum}⩽${propType.maximum}` : propType.default,
179
187
  disabled: d.disabled,
180
188
  required: required,
181
- multiple: d.multiple,
189
+ multiple: multiple,
182
190
  step: step
183
191
  },
184
192
  content: {
@@ -188,6 +196,7 @@ exports.input_property = {
188
196
  }
189
197
  }
190
198
  node.appendChild(view.render({
199
+ id,
191
200
  type: 'input_number',
192
201
  data: {
193
202
  name: name,
@@ -204,6 +213,7 @@ exports.input_property = {
204
213
  }));
205
214
  } else if (propType.type == "boolean") {
206
215
  node.appendChild(view.render({
216
+ id,
207
217
  type: 'input_checkbox',
208
218
  data: {
209
219
  name: name,
@@ -221,6 +231,7 @@ exports.input_property = {
221
231
  type = 'input_text';
222
232
  }
223
233
  node.appendChild(view.render({
234
+ id,
224
235
  type: type,
225
236
  data: {
226
237
  name: name,
@@ -240,6 +251,7 @@ exports.input_property = {
240
251
  type = 'input_text';
241
252
  }
242
253
  node.appendChild(view.render({
254
+ id,
243
255
  type: type,
244
256
  data: {
245
257
  name: name,
@@ -255,7 +267,7 @@ exports.input_property = {
255
267
  }));
256
268
  } else if (propType.$helper && propType.$helper.name == "href") {
257
269
  const limits = {
258
- files: d.multiple ? null : 1
270
+ files: multiple ? null : 1
259
271
  };
260
272
  const filter = propType.$helper.filter;
261
273
  if (filter && filter.type) {
@@ -266,6 +278,7 @@ exports.input_property = {
266
278
  });
267
279
  }
268
280
  node.appendChild(view.render({
281
+ id,
269
282
  type: 'input_file',
270
283
  data: {
271
284
  name: name,
@@ -280,10 +293,11 @@ exports.input_property = {
280
293
  }));
281
294
  } else {
282
295
  node.appendChild(view.render({
296
+ id,
283
297
  type: 'input_text',
284
298
  data: {
285
299
  name: name,
286
- type: propType.format ? 'text' : 'textarea',
300
+ type: (propType.pattern || propType.format) ? 'text' : 'textarea',
287
301
  disabled: d.disabled,
288
302
  default: propType.default,
289
303
  placeholder: propType.description,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageboard/html",
3
- "version": "0.10.8",
3
+ "version": "0.10.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {