@optionfactory/ful 0.72.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 +16 -141
- 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 +17 -140
- 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
|
*
|
|
@@ -958,18 +924,8 @@ const ParsedElement = (conf) => {
|
|
|
958
924
|
return this.internals.states.has(`--${attr}`);
|
|
959
925
|
},
|
|
960
926
|
set(value) {
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
const after = new SyncEvent(`${attr}:${this.initialized ? 'changed' : 'inited'}`, { detail });
|
|
964
|
-
(async () => {
|
|
965
|
-
if (!await before.dispatchTo(this)) {
|
|
966
|
-
return;
|
|
967
|
-
}
|
|
968
|
-
//see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet#using_double_dash_prefixed_idents
|
|
969
|
-
this.internals.states[value ? 'add' : 'delete'](`--${attr}`);
|
|
970
|
-
this.reflect(() => Attributes.toggle(this, attr, value));
|
|
971
|
-
await after.dispatchTo(this);
|
|
972
|
-
})();
|
|
927
|
+
this.internals.states[value ? 'add' : 'delete'](`--${attr}`);
|
|
928
|
+
this.reflect(() => Attributes.toggle(this, attr, value));
|
|
973
929
|
}
|
|
974
930
|
});
|
|
975
931
|
}
|
|
@@ -1031,7 +987,7 @@ function extract(el) {
|
|
|
1031
987
|
if (el.dataset['fulBindType'] === 'boolean') {
|
|
1032
988
|
return !el.value ? null : el.value === 'true';
|
|
1033
989
|
}
|
|
1034
|
-
return el.value || null;
|
|
990
|
+
return el.value === '' || el.value === undefined ? null : el.value;
|
|
1035
991
|
}
|
|
1036
992
|
|
|
1037
993
|
function mutate(el, raw) {
|
|
@@ -1165,9 +1121,7 @@ const makeInputFragment = (el, template, slots) => {
|
|
|
1165
1121
|
input.setAttribute('ful-validation-target', '');
|
|
1166
1122
|
input.addEventListener('change', (evt) => {
|
|
1167
1123
|
evt.stopPropagation();
|
|
1168
|
-
|
|
1169
|
-
evt.preventDefault();
|
|
1170
|
-
}
|
|
1124
|
+
Events.dispatchChange(el, el.value);
|
|
1171
1125
|
});
|
|
1172
1126
|
const id = input.getAttribute('id') || el.getAttribute('input-id') || Attributes.uid('ful-input');
|
|
1173
1127
|
Attributes.forward('input-', el, slots.input);
|
|
@@ -1191,9 +1145,6 @@ class Input extends ParsedElement({
|
|
|
1191
1145
|
return this.input.value;
|
|
1192
1146
|
}
|
|
1193
1147
|
set value(value) {
|
|
1194
|
-
if(!Events.dispatchChange(this, value)){
|
|
1195
|
-
return;
|
|
1196
|
-
}
|
|
1197
1148
|
this.input.value = value;
|
|
1198
1149
|
}
|
|
1199
1150
|
}
|
|
@@ -1272,13 +1223,14 @@ class Select extends ParsedElement({
|
|
|
1272
1223
|
}
|
|
1273
1224
|
callback(data);
|
|
1274
1225
|
};
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
1226
|
this.ts = new TomSelect(input, Object.assign(remote ? {
|
|
1278
1227
|
preload: 'focus',
|
|
1279
1228
|
load: this._unwrappedRemoteLoad,
|
|
1280
1229
|
shouldLoad: (query) => this.shouldLoad ? this.shouldLoad(query) : true
|
|
1281
1230
|
} : {}, tsDefaultConfig, this.tsConfig));
|
|
1231
|
+
this.ts.on('change', value => {
|
|
1232
|
+
Events.dispatchChange(this, this.value);
|
|
1233
|
+
});
|
|
1282
1234
|
//we remove the input to move it
|
|
1283
1235
|
input.addEventListener('change', (evt) => {
|
|
1284
1236
|
evt.stopPropagation();
|
|
@@ -1287,10 +1239,10 @@ class Select extends ParsedElement({
|
|
|
1287
1239
|
template.renderTo(this, { id, tsId, name, input, slots });
|
|
1288
1240
|
}
|
|
1289
1241
|
#loader;
|
|
1290
|
-
set loader(l){
|
|
1242
|
+
set loader(l) {
|
|
1291
1243
|
this.#loader = l;
|
|
1292
1244
|
// loader can be configured later so we load now
|
|
1293
|
-
if(this.hasAttribute('value')){
|
|
1245
|
+
if (this.hasAttribute('value')) {
|
|
1294
1246
|
this.value = this.getAttribute("value");
|
|
1295
1247
|
}
|
|
1296
1248
|
}
|
|
@@ -1299,14 +1251,12 @@ class Select extends ParsedElement({
|
|
|
1299
1251
|
return v === '' ? null : v;
|
|
1300
1252
|
}
|
|
1301
1253
|
set value(value) {
|
|
1302
|
-
if(!Events.dispatchChange(this, value)){
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
1254
|
(async () => {
|
|
1306
1255
|
if (this._remote) {
|
|
1307
1256
|
await this._unwrappedRemoteLoad({ byId: value }, this.ts.loadCallback.bind(this.ts));
|
|
1308
1257
|
}
|
|
1309
|
-
|
|
1258
|
+
const silent = true;
|
|
1259
|
+
this.ts.setValue(value, silent);
|
|
1310
1260
|
})();
|
|
1311
1261
|
}
|
|
1312
1262
|
}
|
|
@@ -1348,12 +1298,11 @@ class RadioGroup extends ParsedElement({
|
|
|
1348
1298
|
input.setAttribute('name', `${name}-ignore`);
|
|
1349
1299
|
input.setAttribute('ful-validation-target', '');
|
|
1350
1300
|
input.dataset['fulBindInclude'] = 'never';
|
|
1351
|
-
input.addEventListener('change',
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
});
|
|
1301
|
+
input.addEventListener('change', evt => {
|
|
1302
|
+
evt.stopPropagation();
|
|
1303
|
+
//change is not cancelable
|
|
1304
|
+
Events.dispatchChange(el, this.value);
|
|
1305
|
+
});
|
|
1357
1306
|
const label = Fragments.fromChildNodes(el);
|
|
1358
1307
|
return [input, label];
|
|
1359
1308
|
});
|
|
@@ -1387,77 +1336,5 @@ class Spinner extends ParsedElement({
|
|
|
1387
1336
|
}
|
|
1388
1337
|
}
|
|
1389
1338
|
|
|
1390
|
-
|
|
1391
|
-
constructor() {
|
|
1392
|
-
super();
|
|
1393
|
-
this.progress = [...this.children].filter(e => e.matches("header,ol,ul"));
|
|
1394
|
-
|
|
1395
|
-
this.progress.forEach(p => {
|
|
1396
|
-
const children = [...p.children];
|
|
1397
|
-
const current = children.filter(e => e.matches(".active"))[0];
|
|
1398
|
-
if (current === undefined && children.length > 0) {
|
|
1399
|
-
children[0].classList.add('active');
|
|
1400
|
-
}
|
|
1401
|
-
});
|
|
1402
|
-
if (this.querySelector('section.current') === null) {
|
|
1403
|
-
const firstSection = this.querySelector('section:first-of-type');
|
|
1404
|
-
if (firstSection !== null) {
|
|
1405
|
-
firstSection.classList.add('current');
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
next() {
|
|
1410
|
-
this.progress.forEach(p => {
|
|
1411
|
-
const children = [...p.children];
|
|
1412
|
-
const current = children.filter(e => e.matches(".active"))[0];
|
|
1413
|
-
current?.classList.remove('active');
|
|
1414
|
-
current?.nextElementSibling?.classList.add('active');
|
|
1415
|
-
});
|
|
1416
|
-
const currentSection = this.querySelector('section.current');
|
|
1417
|
-
currentSection.classList.remove("current");
|
|
1418
|
-
currentSection.nextElementSibling.classList.add('current');
|
|
1419
|
-
|
|
1420
|
-
this.dispatchEvent(new CustomEvent('wizard:activate', {
|
|
1421
|
-
bubbles: true,
|
|
1422
|
-
cancelable: true
|
|
1423
|
-
}));
|
|
1424
|
-
|
|
1425
|
-
}
|
|
1426
|
-
prev() {
|
|
1427
|
-
this.progress.forEach(p => {
|
|
1428
|
-
const children = [...p.children];
|
|
1429
|
-
const current = children.filter(e => e.matches(".active"))[0];
|
|
1430
|
-
current?.classList.remove('active');
|
|
1431
|
-
current?.previousElementSibling?.classList.add('active');
|
|
1432
|
-
});
|
|
1433
|
-
const currentSection = this.querySelector('section.current');
|
|
1434
|
-
currentSection.classList.remove("current");
|
|
1435
|
-
currentSection.previousElementSibling.classList.add('current');
|
|
1436
|
-
this.dispatchEvent(new CustomEvent('wizard:activate', {
|
|
1437
|
-
bubbles: true,
|
|
1438
|
-
cancelable: true
|
|
1439
|
-
}));
|
|
1440
|
-
}
|
|
1441
|
-
moveTo(n) {
|
|
1442
|
-
this.progress.forEach(p => {
|
|
1443
|
-
const children = [...p.children];
|
|
1444
|
-
const current = children.filter(e => e.matches(".active"))[0];
|
|
1445
|
-
current?.classList.remove('active');
|
|
1446
|
-
p.children[+n]?.classList.add('active');
|
|
1447
|
-
});
|
|
1448
|
-
const currentSection = this.querySelector('section.current');
|
|
1449
|
-
currentSection?.classList.remove("current");
|
|
1450
|
-
const nthSection = this.querySelector(`section:nth-child(${+n})`);
|
|
1451
|
-
nthSection.classList.add('current');
|
|
1452
|
-
this.dispatchEvent(new CustomEvent('wizard:activate', {
|
|
1453
|
-
bubbles: true,
|
|
1454
|
-
cancelable: true
|
|
1455
|
-
}));
|
|
1456
|
-
}
|
|
1457
|
-
static configure() {
|
|
1458
|
-
return Wizard.custom('ful-wizard');
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
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 };
|
|
1463
1340
|
//# sourceMappingURL=ful.mjs.map
|