@pageboard/html 0.14.23 → 0.14.25

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/form.js CHANGED
@@ -192,6 +192,6 @@ exports.api_form = {
192
192
  scripts: [ // for asynchronous submits and automatic triggers
193
193
  '../ui/form.js'
194
194
  ],
195
- polyfills: ['fetch']
195
+ polyfills: ['fetch', 'FormDataSubmitter']
196
196
  };
197
197
 
@@ -56,7 +56,7 @@ exports.breadcrumb = {
56
56
  group: "block",
57
57
  html: `<nav class="ui breadcrumb">
58
58
  <div class="divider"></div>
59
- <a href="[$links.up|nth:-1|at:a::1|repeat:link]" class="section">[link.title]</a>
59
+ <a href="[$links.up|nth:-1|at:a::1|repeat:link|.url]" class="section">[link.title]</a>
60
60
  <div class="divider"></div>
61
61
  <div class="active section">[$page.content.title|fail:div::1]</div>
62
62
  </nav>`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageboard/html",
3
- "version": "0.14.23",
3
+ "version": "0.14.25",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -4,7 +4,7 @@ class HTMLElementFieldsetList extends Page.Element {
4
4
  #prefix;
5
5
  #model;
6
6
 
7
- fill(values) {
7
+ fill(values = {}) {
8
8
  if (this.isContentEditable || this.prefix == null) return;
9
9
  const vars = [];
10
10
  for (const [key, val] of Object.entries(values)) {
@@ -83,6 +83,9 @@ class HTMLElementFieldsetList extends Page.Element {
83
83
  for (const node of tpl.content.querySelectorAll('[block-id]')) {
84
84
  node.removeAttribute('block-id');
85
85
  }
86
+ if (this.ownView.children.length == 0) {
87
+ this.#resize();
88
+ }
86
89
  }
87
90
  }
88
91
 
@@ -142,7 +145,7 @@ class HTMLElementFieldsetList extends Page.Element {
142
145
  );
143
146
  const min = Number(this.dataset.min) || 0;
144
147
  const max = Number(this.dataset.max) || Infinity;
145
- let list = this.#list;
148
+ let list = this.#list ??= [];
146
149
  const placeholder = list.length == 0 && min == 0;
147
150
  if (list.length == 0) {
148
151
  list = [{...this.#model, $i: min == 0 ? -1 : 0}];
@@ -177,10 +180,10 @@ class HTMLElementFieldsetList extends Page.Element {
177
180
  node.disabled = i == arr.length - 1;
178
181
  });
179
182
  tpl.querySelectorAll(this.#selector('del')).forEach((node) => {
180
- node.disabled = this.#list.length <= min;
183
+ node.disabled = list.length <= min;
181
184
  });
182
185
  tpl.querySelectorAll(this.#selector('add')).forEach((node) => {
183
- node.disabled = this.#list.length >= max;
186
+ node.disabled = list.length >= max;
184
187
  });
185
188
 
186
189
  const view = this.ownView;
package/ui/form.js CHANGED
@@ -112,8 +112,8 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
112
112
  state.dispatch(this, 'submit');
113
113
  });
114
114
  }
115
- read(withDefaults = false) {
116
- const fd = new FormData(this);
115
+ read(withDefaults = false, submitter) {
116
+ const fd = new FormData(this, submitter);
117
117
  const query = {};
118
118
  fd.forEach((val, key) => {
119
119
  if (val == "") val = null;
@@ -182,12 +182,6 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
182
182
  }
183
183
  }
184
184
  }
185
- // FIXME use e.submitter polyfill when available
186
- // https://github.com/Financial-Times/polyfill-library/issues/1111
187
- const btn = document.activeElement;
188
- if (btn && btn.type == "submit" && btn.name && btn.value) {
189
- query[btn.name] = btn.value;
190
- }
191
185
  return query;
192
186
  }
193
187
  fill(query) {
@@ -295,7 +289,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
295
289
  getMethod(e, state) {
296
290
  const redirect = this.getAttribute('action');
297
291
  const loc = Page.parse(redirect);
298
- Object.assign(loc.query, this.read(false));
292
+ Object.assign(loc.query, this.read(false, e.submitter));
299
293
  if (loc.samePathname(state)) {
300
294
  loc.query = { ...state.query, ...loc.query };
301
295
  }