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