@optionfactory/ful 0.71.0 → 0.73.0
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.css +1 -1
- package/dist/ful.css.map +1 -1
- package/dist/ful.iife.js +21 -148
- 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 +22 -147
- package/dist/ful.mjs.map +1 -1
- package/package.json +1 -1
package/dist/ful.mjs
CHANGED
|
@@ -566,40 +566,6 @@ class Deferred {
|
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
|
|
569
|
-
// SyncEvent.on($0, 'asd', async e => { await ful.timing.sleep(10_000); return 3; })
|
|
570
|
-
// const success = await new SyncEvent("asd").dispatchTo($0);
|
|
571
|
-
class SyncEvent extends CustomEvent {
|
|
572
|
-
#promises;
|
|
573
|
-
#results;
|
|
574
|
-
constructor(type, options) {
|
|
575
|
-
super(type, {...options, cancelable: true});
|
|
576
|
-
this.#promises = [];
|
|
577
|
-
this.#results = [];
|
|
578
|
-
}
|
|
579
|
-
get results(){
|
|
580
|
-
return this.#results;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
async dispatchTo(el) {
|
|
584
|
-
// unlike "native" events, which are fired by the browser and invoke
|
|
585
|
-
// event handlers asynchronously via the event loop, dispatchEvent()
|
|
586
|
-
// invokes event handlers synchronously.
|
|
587
|
-
// see: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
|
|
588
|
-
el.dispatchEvent(this);
|
|
589
|
-
//we ignore the result of dispatchEvent and use defaultPrevented instead
|
|
590
|
-
//because handlers can be async
|
|
591
|
-
this.#results = await Promise.all(this.#promises);
|
|
592
|
-
return !this.defaultPrevented;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
static on(el, type, h, useCapture) {
|
|
596
|
-
el.addEventListener(type, e => {
|
|
597
|
-
//e *must* be an async event
|
|
598
|
-
e.#promises.push(h(e));
|
|
599
|
-
}, useCapture);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
569
|
class Fragments {
|
|
604
570
|
/**
|
|
605
571
|
*
|
|
@@ -607,11 +573,9 @@ class Fragments {
|
|
|
607
573
|
* @returns
|
|
608
574
|
*/
|
|
609
575
|
static fromHtml(...html) {
|
|
610
|
-
const el = document.createElement("
|
|
576
|
+
const el = document.createElement("template");
|
|
611
577
|
el.innerHTML = html.join("");
|
|
612
|
-
|
|
613
|
-
fragment.append(...el.childNodes);
|
|
614
|
-
return fragment;
|
|
578
|
+
return el.content;
|
|
615
579
|
}
|
|
616
580
|
/**
|
|
617
581
|
*
|
|
@@ -619,9 +583,9 @@ class Fragments {
|
|
|
619
583
|
* @returns
|
|
620
584
|
*/
|
|
621
585
|
static toHtml(fragment) {
|
|
622
|
-
var
|
|
623
|
-
|
|
624
|
-
return
|
|
586
|
+
var el = document.createElement("template");
|
|
587
|
+
el.content.appendChild(fragment);
|
|
588
|
+
return el.innerHTML;
|
|
625
589
|
}
|
|
626
590
|
/**
|
|
627
591
|
*
|
|
@@ -960,18 +924,8 @@ const ParsedElement = (conf) => {
|
|
|
960
924
|
return this.internals.states.has(`--${attr}`);
|
|
961
925
|
},
|
|
962
926
|
set(value) {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
const after = new SyncEvent(`${attr}:${this.initialized ? 'changed' : 'inited'}`, { detail });
|
|
966
|
-
(async () => {
|
|
967
|
-
if (!await before.dispatchTo(this)) {
|
|
968
|
-
return;
|
|
969
|
-
}
|
|
970
|
-
//see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet#using_double_dash_prefixed_idents
|
|
971
|
-
this.internals.states[value ? 'add' : 'delete'](`--${attr}`);
|
|
972
|
-
this.reflect(() => Attributes.toggle(this, attr, value));
|
|
973
|
-
await after.dispatchTo(this);
|
|
974
|
-
})();
|
|
927
|
+
this.internals.states[value ? 'add' : 'delete'](`--${attr}`);
|
|
928
|
+
this.reflect(() => Attributes.toggle(this, attr, value));
|
|
975
929
|
}
|
|
976
930
|
});
|
|
977
931
|
}
|
|
@@ -1033,7 +987,7 @@ function extract(el) {
|
|
|
1033
987
|
if (el.dataset['fulBindType'] === 'boolean') {
|
|
1034
988
|
return !el.value ? null : el.value === 'true';
|
|
1035
989
|
}
|
|
1036
|
-
return el.value || null;
|
|
990
|
+
return el.value === '' || el.value === undefined ? null : el.value;
|
|
1037
991
|
}
|
|
1038
992
|
|
|
1039
993
|
function mutate(el, raw) {
|
|
@@ -1167,9 +1121,7 @@ const makeInputFragment = (el, template, slots) => {
|
|
|
1167
1121
|
input.setAttribute('ful-validation-target', '');
|
|
1168
1122
|
input.addEventListener('change', (evt) => {
|
|
1169
1123
|
evt.stopPropagation();
|
|
1170
|
-
|
|
1171
|
-
evt.preventDefault();
|
|
1172
|
-
}
|
|
1124
|
+
Events.dispatchChange(el, el.value);
|
|
1173
1125
|
});
|
|
1174
1126
|
const id = input.getAttribute('id') || el.getAttribute('input-id') || Attributes.uid('ful-input');
|
|
1175
1127
|
Attributes.forward('input-', el, slots.input);
|
|
@@ -1193,9 +1145,6 @@ class Input extends ParsedElement({
|
|
|
1193
1145
|
return this.input.value;
|
|
1194
1146
|
}
|
|
1195
1147
|
set value(value) {
|
|
1196
|
-
if(!Events.dispatchChange(this, value)){
|
|
1197
|
-
return;
|
|
1198
|
-
}
|
|
1199
1148
|
this.input.value = value;
|
|
1200
1149
|
}
|
|
1201
1150
|
}
|
|
@@ -1274,13 +1223,14 @@ class Select extends ParsedElement({
|
|
|
1274
1223
|
}
|
|
1275
1224
|
callback(data);
|
|
1276
1225
|
};
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
1226
|
this.ts = new TomSelect(input, Object.assign(remote ? {
|
|
1280
1227
|
preload: 'focus',
|
|
1281
1228
|
load: this._unwrappedRemoteLoad,
|
|
1282
1229
|
shouldLoad: (query) => this.shouldLoad ? this.shouldLoad(query) : true
|
|
1283
1230
|
} : {}, tsDefaultConfig, this.tsConfig));
|
|
1231
|
+
this.ts.on('change', value => {
|
|
1232
|
+
Events.dispatchChange(this, this.value);
|
|
1233
|
+
});
|
|
1284
1234
|
//we remove the input to move it
|
|
1285
1235
|
input.addEventListener('change', (evt) => {
|
|
1286
1236
|
evt.stopPropagation();
|
|
@@ -1289,10 +1239,10 @@ class Select extends ParsedElement({
|
|
|
1289
1239
|
template.renderTo(this, { id, tsId, name, input, slots });
|
|
1290
1240
|
}
|
|
1291
1241
|
#loader;
|
|
1292
|
-
set loader(l){
|
|
1242
|
+
set loader(l) {
|
|
1293
1243
|
this.#loader = l;
|
|
1294
1244
|
// loader can be configured later so we load now
|
|
1295
|
-
if(this.hasAttribute('value')){
|
|
1245
|
+
if (this.hasAttribute('value')) {
|
|
1296
1246
|
this.value = this.getAttribute("value");
|
|
1297
1247
|
}
|
|
1298
1248
|
}
|
|
@@ -1301,14 +1251,12 @@ class Select extends ParsedElement({
|
|
|
1301
1251
|
return v === '' ? null : v;
|
|
1302
1252
|
}
|
|
1303
1253
|
set value(value) {
|
|
1304
|
-
if(!Events.dispatchChange(this, value)){
|
|
1305
|
-
return;
|
|
1306
|
-
}
|
|
1307
1254
|
(async () => {
|
|
1308
1255
|
if (this._remote) {
|
|
1309
1256
|
await this._unwrappedRemoteLoad({ byId: value }, this.ts.loadCallback.bind(this.ts));
|
|
1310
1257
|
}
|
|
1311
|
-
|
|
1258
|
+
const silent = true;
|
|
1259
|
+
this.ts.setValue(value, silent);
|
|
1312
1260
|
})();
|
|
1313
1261
|
}
|
|
1314
1262
|
}
|
|
@@ -1350,12 +1298,11 @@ class RadioGroup extends ParsedElement({
|
|
|
1350
1298
|
input.setAttribute('name', `${name}-ignore`);
|
|
1351
1299
|
input.setAttribute('ful-validation-target', '');
|
|
1352
1300
|
input.dataset['fulBindInclude'] = 'never';
|
|
1353
|
-
input.addEventListener('change',
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
});
|
|
1301
|
+
input.addEventListener('change', evt => {
|
|
1302
|
+
evt.stopPropagation();
|
|
1303
|
+
//change is not cancelable
|
|
1304
|
+
Events.dispatchChange(el, this.value);
|
|
1305
|
+
});
|
|
1359
1306
|
const label = Fragments.fromChildNodes(el);
|
|
1360
1307
|
return [input, label];
|
|
1361
1308
|
});
|
|
@@ -1389,77 +1336,5 @@ class Spinner extends ParsedElement({
|
|
|
1389
1336
|
}
|
|
1390
1337
|
}
|
|
1391
1338
|
|
|
1392
|
-
|
|
1393
|
-
constructor() {
|
|
1394
|
-
super();
|
|
1395
|
-
this.progress = [...this.children].filter(e => e.matches("header,ol,ul"));
|
|
1396
|
-
|
|
1397
|
-
this.progress.forEach(p => {
|
|
1398
|
-
const children = [...p.children];
|
|
1399
|
-
const current = children.filter(e => e.matches(".active"))[0];
|
|
1400
|
-
if (current === undefined && children.length > 0) {
|
|
1401
|
-
children[0].classList.add('active');
|
|
1402
|
-
}
|
|
1403
|
-
});
|
|
1404
|
-
if (this.querySelector('section.current') === null) {
|
|
1405
|
-
const firstSection = this.querySelector('section:first-of-type');
|
|
1406
|
-
if (firstSection !== null) {
|
|
1407
|
-
firstSection.classList.add('current');
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
next() {
|
|
1412
|
-
this.progress.forEach(p => {
|
|
1413
|
-
const children = [...p.children];
|
|
1414
|
-
const current = children.filter(e => e.matches(".active"))[0];
|
|
1415
|
-
current?.classList.remove('active');
|
|
1416
|
-
current?.nextElementSibling?.classList.add('active');
|
|
1417
|
-
});
|
|
1418
|
-
const currentSection = this.querySelector('section.current');
|
|
1419
|
-
currentSection.classList.remove("current");
|
|
1420
|
-
currentSection.nextElementSibling.classList.add('current');
|
|
1421
|
-
|
|
1422
|
-
this.dispatchEvent(new CustomEvent('wizard:activate', {
|
|
1423
|
-
bubbles: true,
|
|
1424
|
-
cancelable: true
|
|
1425
|
-
}));
|
|
1426
|
-
|
|
1427
|
-
}
|
|
1428
|
-
prev() {
|
|
1429
|
-
this.progress.forEach(p => {
|
|
1430
|
-
const children = [...p.children];
|
|
1431
|
-
const current = children.filter(e => e.matches(".active"))[0];
|
|
1432
|
-
current?.classList.remove('active');
|
|
1433
|
-
current?.previousElementSibling?.classList.add('active');
|
|
1434
|
-
});
|
|
1435
|
-
const currentSection = this.querySelector('section.current');
|
|
1436
|
-
currentSection.classList.remove("current");
|
|
1437
|
-
currentSection.previousElementSibling.classList.add('current');
|
|
1438
|
-
this.dispatchEvent(new CustomEvent('wizard:activate', {
|
|
1439
|
-
bubbles: true,
|
|
1440
|
-
cancelable: true
|
|
1441
|
-
}));
|
|
1442
|
-
}
|
|
1443
|
-
moveTo(n) {
|
|
1444
|
-
this.progress.forEach(p => {
|
|
1445
|
-
const children = [...p.children];
|
|
1446
|
-
const current = children.filter(e => e.matches(".active"))[0];
|
|
1447
|
-
current?.classList.remove('active');
|
|
1448
|
-
p.children[+n]?.classList.add('active');
|
|
1449
|
-
});
|
|
1450
|
-
const currentSection = this.querySelector('section.current');
|
|
1451
|
-
currentSection?.classList.remove("current");
|
|
1452
|
-
const nthSection = this.querySelector(`section:nth-child(${+n})`);
|
|
1453
|
-
nthSection.classList.add('current');
|
|
1454
|
-
this.dispatchEvent(new CustomEvent('wizard:activate', {
|
|
1455
|
-
bubbles: true,
|
|
1456
|
-
cancelable: true
|
|
1457
|
-
}));
|
|
1458
|
-
}
|
|
1459
|
-
static configure() {
|
|
1460
|
-
return Wizard.custom('ful-wizard');
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
export { Attributes, AuthorizationCodeFlow, AuthorizationCodeFlowInterceptor, AuthorizationCodeFlowSession, Base64, Deferred, ElementsRegistry, Failure, Form, Fragments, Hex, HttpClient, INPUT_TEMPLATE, Input, LightSlots, LocalStorage, Nodes, ParsedElement, RadioGroup, Select, SessionStorage, Spinner, SyncEvent, TemplatesRegistry, VersionedStorage, Wizard, elements, jsonPatch, jsonPost, jsonPut, jsonRequest, makeInputFragment, timing };
|
|
1339
|
+
export { Attributes, AuthorizationCodeFlow, AuthorizationCodeFlowInterceptor, AuthorizationCodeFlowSession, Base64, Deferred, ElementsRegistry, Failure, Form, Fragments, Hex, HttpClient, INPUT_TEMPLATE, Input, LightSlots, LocalStorage, Nodes, ParsedElement, RadioGroup, Select, SessionStorage, Spinner, TemplatesRegistry, VersionedStorage, elements, jsonPatch, jsonPost, jsonPut, jsonRequest, makeInputFragment, timing };
|
|
1465
1340
|
//# sourceMappingURL=ful.mjs.map
|