@pageboard/html 0.11.15 → 0.11.17

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 CHANGED
@@ -184,7 +184,7 @@ exports.inlineImage = {
184
184
  avatar: {
185
185
  title: 'avatar',
186
186
  type: 'boolean',
187
- default: true
187
+ default: false
188
188
  },
189
189
  rounded: {
190
190
  title: 'rounded',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageboard/html",
3
- "version": "0.11.15",
3
+ "version": "0.11.17",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -214,18 +214,17 @@ class HTMLElementFieldsetList extends VirtualHTMLElement {
214
214
  const form = this.closest('form');
215
215
  const values = form.read(true);
216
216
  const list = this.#listFromValues(values);
217
- const prefix = this.#prefix;
218
- if (!this.#walk) this.#walk = new WalkIndex(this, (node) => {
219
- if (node.name?.startsWith(prefix)) {
220
- const index = Number(node.name.substring(prefix.length).split('.').shift());
221
- if (Number.isInteger(index) || index >= 0 || index < list.length) {
222
- return index;
223
- }
224
- }
225
- return null;
217
+
218
+ if (!this.#walk) this.#walk = new WalkIndex(this, node => {
219
+ const { index } = this.#parseName(node.name);
220
+ if (index >= 0 && index < list.length) return index;
221
+ else return null;
226
222
  });
227
223
  let index;
228
224
 
225
+ const fileInputs = this.querySelectorAll('[name][type="file"]')
226
+ .map(n => n.cloneNode(true));
227
+
229
228
  switch (action) {
230
229
  case "add":
231
230
  list.splice((this.#walk.findBefore(btn) ?? -1) + 1, 0, this.#model);
@@ -248,6 +247,26 @@ class HTMLElementFieldsetList extends VirtualHTMLElement {
248
247
  }
249
248
  this.#listToValues(values, list);
250
249
  form.fill(values, state.scope);
250
+ const liveFileInputs = this.querySelectorAll('[name][type="file"]');
251
+ for (const node of fileInputs) {
252
+ const { value } = node;
253
+ const { sub } = this.#parseName(node.name);
254
+ const live = liveFileInputs.find(node => node.value == value);
255
+ if (!live) continue;
256
+ if (this.#parseName(live.name).sub === sub) {
257
+ node.name = live.name;
258
+ live.replaceWith(node);
259
+ }
260
+ }
261
+ }
262
+
263
+ #parseName(name) {
264
+ const prefix = this.prefix;
265
+ if (!name?.startsWith(prefix)) return { index: -1 };
266
+ const parts = name.substring(prefix.length).split('.');
267
+ const index = Number(parts.shift());
268
+ if (!Number.isInteger(index)) return { index: -1 };
269
+ return { index, sub: parts.join('.') };
251
270
  }
252
271
 
253
272
  get ownTpl() {
package/ui/fieldset.js CHANGED
@@ -9,7 +9,7 @@ class HTMLCustomFieldSetElement extends HTMLFieldSetElement {
9
9
  }
10
10
 
11
11
  fill(query) {
12
- if (this.isContentEditable || !this.options?.name) return;
12
+ if (this.isContentEditable || !this.options?.name || !this.form) return;
13
13
  if (!query) query = this.form.read(true);
14
14
  const val = query[this.options.name];
15
15
  const disabled = this.disabled = this.hidden = val != this.options.value;
package/ui/form.js CHANGED
@@ -227,7 +227,7 @@ class HTMLCustomFormElement extends HTMLFormElement {
227
227
 
228
228
  form.classList.add('loading');
229
229
 
230
- const data = { $query };
230
+ const data = { $query };
231
231
  return Promise.all(Array.from(form.elements).filter((node) => {
232
232
  return Boolean(node.presubmit);
233
233
  }).map((input) => {