@optionfactory/ful 1.0.8 → 1.0.10

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/dist/ful.iife.js CHANGED
@@ -88,6 +88,16 @@ var ful = (function (exports, ftl) {
88
88
  this.name = 'Failure';
89
89
  this.problems = problems;
90
90
  }
91
+ dropping(prefix){
92
+ return new Failure(this.message, Failure.dropProblemsContext(this.problems, prefix), this);
93
+ }
94
+ static dropProblemsContext(problems, prefix){
95
+ return problems.map(({type, context, reason, details}) => {
96
+ const nctx = context?.startsWith(prefix) ? context.substring(prefix.length) : context;
97
+ return {type, context: nctx, reason, details};
98
+ })
99
+ }
100
+
91
101
  }
92
102
 
93
103
  class MediaType {
@@ -141,6 +151,9 @@ var ful = (function (exports, ftl) {
141
151
  this.name = 'HttpClientError';
142
152
  this.status = status;
143
153
  }
154
+ dropping(prefix){
155
+ return new HttpClientError(this.message, this.status, Failure.dropProblemsContext(this.problems, prefix), this);
156
+ }
144
157
  /**
145
158
  *
146
159
  * @param {string} type
@@ -1130,15 +1143,16 @@ var ful = (function (exports, ftl) {
1130
1143
  /**
1131
1144
  * @param {{ [x: string]: any; }} obj
1132
1145
  * @param {string} prefix
1146
+ * @param {Set<String>} stops
1133
1147
  * @return {{ [x: string]: any; }}
1134
1148
  */
1135
- static flatten(obj, prefix) {
1149
+ static flatten(obj, prefix, stops) {
1136
1150
  return Object.keys(obj).reduce((acc, k) => {
1137
- const pre = prefix.length ? prefix + '.' : '';
1138
- if (typeof obj[k] === 'object' && obj[k] !== null) {
1139
- Object.assign(acc, Bindings.flatten(obj[k], pre + k));
1151
+ const pre = prefix.length ? prefix + '.' + k : k;
1152
+ if (!stops.has(prefix) && typeof obj[k] === 'object' && obj[k] !== null) {
1153
+ Object.assign(acc, Bindings.flatten(obj[k], pre, stops));
1140
1154
  } else {
1141
- acc[pre + k] = obj[k];
1155
+ acc[pre] = obj[k];
1142
1156
  }
1143
1157
  return acc;
1144
1158
  }, {});
@@ -1233,7 +1247,10 @@ var ful = (function (exports, ftl) {
1233
1247
  }
1234
1248
 
1235
1249
  static mutateIn(form, values){
1236
- for (const [flattenedKey, value] of Object.entries(Bindings.flatten(values, ''))) {
1250
+ const names = Array.from(form.form.elements)
1251
+ .map(el => el.getAttribute("name"))
1252
+ .filter(n => n);
1253
+ for (const [flattenedKey, value] of Object.entries(Bindings.flatten(values, '', new Set(names)))) {
1237
1254
  for(const el of form.querySelectorAll(`[name='${CSS.escape(flattenedKey)}']`)){
1238
1255
  Bindings.mutate(el, value);
1239
1256
  }
@@ -1413,6 +1430,7 @@ var ful = (function (exports, ftl) {
1413
1430
  constructor() {
1414
1431
  super();
1415
1432
  this.internals = this.attachInternals();
1433
+ this.internals.role = 'textbox';
1416
1434
  }
1417
1435
  render({ slots }) {
1418
1436
  const id = ftl.Attributes.uid('ful-input');
@@ -1435,10 +1453,10 @@ var ful = (function (exports, ftl) {
1435
1453
  this.replaceChildren(fragment);
1436
1454
  }
1437
1455
  get value() {
1438
- return this.#input.value;
1456
+ return this.#input.value === '' ? null : this.#input.value;
1439
1457
  }
1440
1458
  set value(value) {
1441
- this.#input.value = value;
1459
+ this.#input.value = value === '' ? null : value;
1442
1460
  }
1443
1461
  get readonly(){
1444
1462
  return this.#input.readOnly;
@@ -1697,6 +1715,7 @@ var ful = (function (exports, ftl) {
1697
1715
  constructor() {
1698
1716
  super();
1699
1717
  this.internals = this.attachInternals();
1718
+ this.internals.role = 'combobox';
1700
1719
  }
1701
1720
  async render({ slots, observed }) {
1702
1721
  const name = this.getAttribute("name");
@@ -1861,6 +1880,7 @@ var ful = (function (exports, ftl) {
1861
1880
  constructor() {
1862
1881
  super();
1863
1882
  this.internals = this.attachInternals();
1883
+ this.internals.role = 'radiogroup';
1864
1884
  }
1865
1885
  render({ slots }) {
1866
1886
  const name = this.getAttribute('name') ?? ftl.Attributes.uid('ful-radiogroup');
@@ -1944,11 +1964,13 @@ var ful = (function (exports, ftl) {
1944
1964
  constructor() {
1945
1965
  super();
1946
1966
  this.internals = this.attachInternals();
1967
+ this.internals.role = 'checkbox';
1947
1968
  }
1948
1969
  render({ slots }) {
1949
1970
  const id = ftl.Attributes.uid("ful-checkbox");
1950
1971
  const fieldErrorId = id + "-error";
1951
1972
  const klass = this.getAttribute('type') == 'switch' ? "form-check form-switch" : "form-check";
1973
+ this.internals.role = this.getAttribute('type') == 'switch' ? 'switch' : 'checkbox';
1952
1974
  const fragment = this.template().withOverlay({ slots, klass, id, fieldErrorId }).render();
1953
1975
  this.#input = fragment.querySelector("input");
1954
1976
  ftl.Attributes.forward('input-', this, this.#input);
@@ -1988,7 +2010,7 @@ var ful = (function (exports, ftl) {
1988
2010
  class Spinner extends ftl.ParsedElement {
1989
2011
  static slots = true;
1990
2012
  static template = `
1991
- <div class="ful-spinner-wrapper">
2013
+ <div class="ful-spinner-wrapper" role="status">
1992
2014
  <div class="ful-spinner-text">{{{{ slots.default }}}}</div>
1993
2015
  <div class="ful-spinner-icon"></div>
1994
2016
  </div>
@@ -2292,10 +2314,6 @@ var ful = (function (exports, ftl) {
2292
2314
  size: this.#latestRequest.pageRequest.size
2293
2315
  }, this.#latestRequest.sortRequest, evt.detail.request);
2294
2316
  });
2295
- if (maybeForm) {
2296
- maybeForm.submitter = async (filterRequest, form) => {
2297
- };
2298
- }
2299
2317
  this.addEventListener('page-requested', async (/** @type any */e) => {
2300
2318
  await this.load({
2301
2319
  page: e.detail.value,