@startinblox/core 0.20.0-beta.1 → 0.20.0-beta.2
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/index.js
CHANGED
|
@@ -2,8 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
var _a2;
|
|
5
|
-
import { d as defineComponent, u as uniqID, i as importInlineCSS, a as asyncQuerySelector, f as fuzzyCompare, p as parseFieldsString, b as findClosingBracketMatchIndex, c as compare, e as evalTemplateString, g as generalComparator, s as setDeepProperty, t as transformArrayToContainer } from "./helpers-
|
|
6
|
-
import { h } from "./helpers-
|
|
5
|
+
import { d as defineComponent, u as uniqID, i as importInlineCSS, a as asyncQuerySelector, f as fuzzyCompare, p as parseFieldsString, b as findClosingBracketMatchIndex, c as compare, e as evalTemplateString, g as generalComparator, s as setDeepProperty, t as transformArrayToContainer } from "./helpers-BICN491G.js";
|
|
6
|
+
import { h } from "./helpers-BICN491G.js";
|
|
7
7
|
import PubSub$1 from "https://cdn.skypack.dev/pubsub-js";
|
|
8
8
|
if (!("flat" in Array.prototype)) {
|
|
9
9
|
Object.defineProperty(Array.prototype, "flat", {
|
|
@@ -41,13 +41,7 @@ if (!Element.prototype.toggleAttribute) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
const HOOKS = ["created", "attached", "detached"];
|
|
44
|
-
const API = [
|
|
45
|
-
"name",
|
|
46
|
-
"use",
|
|
47
|
-
"attributes",
|
|
48
|
-
"initialState",
|
|
49
|
-
...HOOKS
|
|
50
|
-
];
|
|
44
|
+
const API = ["name", "use", "attributes", "initialState", ...HOOKS];
|
|
51
45
|
class Compositor {
|
|
52
46
|
static merge(component, mixins) {
|
|
53
47
|
return {
|
|
@@ -113,7 +107,9 @@ class Compositor {
|
|
|
113
107
|
static mergeMethods(mixins) {
|
|
114
108
|
const methods2 = /* @__PURE__ */ new Map();
|
|
115
109
|
mixins.reverse().forEach((mixin) => {
|
|
116
|
-
const keys2 = Reflect.ownKeys(mixin).filter(
|
|
110
|
+
const keys2 = Reflect.ownKeys(mixin).filter(
|
|
111
|
+
(key) => typeof key === "string" && API.indexOf(key) < 0 && !Object.getOwnPropertyDescriptor(mixin, key).get && !Object.getOwnPropertyDescriptor(mixin, key).set && typeof mixin[key] === "function"
|
|
112
|
+
);
|
|
117
113
|
keys2.forEach((key) => {
|
|
118
114
|
methods2.set(key, mixin[key]);
|
|
119
115
|
});
|
|
@@ -123,10 +119,20 @@ class Compositor {
|
|
|
123
119
|
static mergeAccessors(mixins) {
|
|
124
120
|
const accessors = {};
|
|
125
121
|
mixins.reverse().forEach((mixin) => {
|
|
126
|
-
Reflect.ownKeys(mixin).filter(
|
|
122
|
+
Reflect.ownKeys(mixin).filter(
|
|
123
|
+
(key) => typeof key === "string" && API.indexOf(key) < 0 && (Object.getOwnPropertyDescriptor(mixin, key).get || Object.getOwnPropertyDescriptor(mixin, key).set)
|
|
124
|
+
).forEach((prop2) => {
|
|
127
125
|
accessors[prop2] = { ...accessors[prop2] };
|
|
128
|
-
if (Reflect.getOwnPropertyDescriptor(mixin, prop2).get)
|
|
129
|
-
|
|
126
|
+
if (Reflect.getOwnPropertyDescriptor(mixin, prop2).get)
|
|
127
|
+
accessors[prop2].get = Reflect.getOwnPropertyDescriptor(
|
|
128
|
+
mixin,
|
|
129
|
+
prop2
|
|
130
|
+
).get;
|
|
131
|
+
if (Reflect.getOwnPropertyDescriptor(mixin, prop2).set)
|
|
132
|
+
accessors[prop2].set = Reflect.getOwnPropertyDescriptor(
|
|
133
|
+
mixin,
|
|
134
|
+
prop2
|
|
135
|
+
).set;
|
|
130
136
|
});
|
|
131
137
|
});
|
|
132
138
|
return accessors;
|
|
@@ -467,7 +473,9 @@ function trackRenderAsync(fn, context2) {
|
|
|
467
473
|
this.profiler.updateStats(componentName, renderTime);
|
|
468
474
|
this.profiler.printStats();
|
|
469
475
|
} else {
|
|
470
|
-
log.debug(
|
|
476
|
+
log.debug(
|
|
477
|
+
`Component ${componentName} rendered in ${renderTime.toFixed(2)} ms`
|
|
478
|
+
);
|
|
471
479
|
}
|
|
472
480
|
return result;
|
|
473
481
|
};
|
|
@@ -557,11 +565,26 @@ class ComponentFactory {
|
|
|
557
565
|
const { initialState, attributes, methods: methods2, hooks, accessors, name } = Compositor.merge(component, Compositor.mergeMixin(component));
|
|
558
566
|
let componentConstructor = class extends Component {
|
|
559
567
|
};
|
|
560
|
-
componentConstructor = ComponentFactory.bindInitialState(
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
componentConstructor = ComponentFactory.
|
|
568
|
+
componentConstructor = ComponentFactory.bindInitialState(
|
|
569
|
+
componentConstructor,
|
|
570
|
+
initialState
|
|
571
|
+
);
|
|
572
|
+
componentConstructor = ComponentFactory.bindAttributes(
|
|
573
|
+
componentConstructor,
|
|
574
|
+
attributes
|
|
575
|
+
);
|
|
576
|
+
componentConstructor = ComponentFactory.bindMethods(
|
|
577
|
+
componentConstructor,
|
|
578
|
+
methods2
|
|
579
|
+
);
|
|
580
|
+
componentConstructor = ComponentFactory.bindAccessors(
|
|
581
|
+
componentConstructor,
|
|
582
|
+
accessors
|
|
583
|
+
);
|
|
584
|
+
componentConstructor = ComponentFactory.bindHooks(
|
|
585
|
+
componentConstructor,
|
|
586
|
+
hooks
|
|
587
|
+
);
|
|
565
588
|
Reflect.defineProperty(componentConstructor, "name", {
|
|
566
589
|
value: name
|
|
567
590
|
});
|
|
@@ -581,7 +604,9 @@ class ComponentFactory {
|
|
|
581
604
|
}
|
|
582
605
|
static bindAttributes(componentConstructor, attributes) {
|
|
583
606
|
if (attributes) {
|
|
584
|
-
const attributesList = Reflect.ownKeys(attributes).map(
|
|
607
|
+
const attributesList = Reflect.ownKeys(attributes).map(
|
|
608
|
+
(key) => String(key)
|
|
609
|
+
);
|
|
585
610
|
const attributesCallback = {};
|
|
586
611
|
attributesList.forEach((key) => {
|
|
587
612
|
const { default: def, type, required, callback } = attributes[key];
|
|
@@ -641,16 +666,29 @@ class ComponentFactory {
|
|
|
641
666
|
}
|
|
642
667
|
});
|
|
643
668
|
Reflect.defineProperty(componentConstructor, "observedAttributes", {
|
|
644
|
-
get: () => attributesList.map(
|
|
669
|
+
get: () => attributesList.map(
|
|
670
|
+
(attr) => attr.replace(/([a-z0-9])([A-Z0-9])/g, "$1-$2").toLowerCase()
|
|
671
|
+
)
|
|
645
672
|
});
|
|
646
|
-
Reflect.defineProperty(
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
673
|
+
Reflect.defineProperty(
|
|
674
|
+
componentConstructor.prototype,
|
|
675
|
+
"attributesCallback",
|
|
676
|
+
{
|
|
677
|
+
value: function(key, newValue, oldValue) {
|
|
678
|
+
if (key in attributesCallback) {
|
|
679
|
+
Reflect.apply(attributesCallback[key], this, [
|
|
680
|
+
newValue,
|
|
681
|
+
oldValue
|
|
682
|
+
]);
|
|
683
|
+
}
|
|
650
684
|
}
|
|
651
685
|
}
|
|
652
|
-
|
|
653
|
-
Reflect.defineProperty(
|
|
686
|
+
);
|
|
687
|
+
Reflect.defineProperty(
|
|
688
|
+
componentConstructor.prototype,
|
|
689
|
+
"attributesCallback",
|
|
690
|
+
attributesCallback
|
|
691
|
+
);
|
|
654
692
|
}
|
|
655
693
|
return componentConstructor;
|
|
656
694
|
}
|
|
@@ -731,7 +769,10 @@ class Sib {
|
|
|
731
769
|
return component.observedAttributes;
|
|
732
770
|
}
|
|
733
771
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
734
|
-
const attr = name.replace(
|
|
772
|
+
const attr = name.replace(
|
|
773
|
+
/([a-z0-9])-([a-z0-9])/g,
|
|
774
|
+
(_c, p1, p2) => `${p1}${p2.toUpperCase()}`
|
|
775
|
+
);
|
|
735
776
|
this.component.attributesCallback(attr, newValue, oldValue);
|
|
736
777
|
}
|
|
737
778
|
connectedCallback() {
|
|
@@ -1323,7 +1364,9 @@ class SpreadDirective extends i$2 {
|
|
|
1323
1364
|
if (part2.type === t.ATTRIBUTE || part2.type === t.PROPERTY) {
|
|
1324
1365
|
element = part2.element;
|
|
1325
1366
|
} else {
|
|
1326
|
-
console.warn(
|
|
1367
|
+
console.warn(
|
|
1368
|
+
"Unsupported part type or missing element, skipping update."
|
|
1369
|
+
);
|
|
1327
1370
|
return T;
|
|
1328
1371
|
}
|
|
1329
1372
|
if (spreadData) {
|
|
@@ -1401,7 +1444,10 @@ function preHTML(strings, ...values) {
|
|
|
1401
1444
|
const { needlessValues: needlessValues2 } = cached;
|
|
1402
1445
|
const isSame = needlessValues2.every((nv) => values[nv.index] === nv.value);
|
|
1403
1446
|
if (isSame) {
|
|
1404
|
-
return x(
|
|
1447
|
+
return x(
|
|
1448
|
+
cached.strings,
|
|
1449
|
+
...filterOutNeedlessValues(values, needlessValues2)
|
|
1450
|
+
);
|
|
1405
1451
|
}
|
|
1406
1452
|
}
|
|
1407
1453
|
}
|
|
@@ -1424,7 +1470,10 @@ function preHTML(strings, ...values) {
|
|
|
1424
1470
|
strings: finalStrings,
|
|
1425
1471
|
needlessValues
|
|
1426
1472
|
});
|
|
1427
|
-
return x(
|
|
1473
|
+
return x(
|
|
1474
|
+
finalStrings,
|
|
1475
|
+
...filterOutNeedlessValues(values, needlessValues)
|
|
1476
|
+
);
|
|
1428
1477
|
}
|
|
1429
1478
|
class PostProcessorRegistry {
|
|
1430
1479
|
constructor(currentPostProcessors = []) {
|
|
@@ -1557,7 +1606,10 @@ const BaseWidgetMixin = {
|
|
|
1557
1606
|
},
|
|
1558
1607
|
render() {
|
|
1559
1608
|
const listValueTransformationsCopy = this.listValueTransformations.deepCopy();
|
|
1560
|
-
listValueTransformationsCopy.attach(
|
|
1609
|
+
listValueTransformationsCopy.attach(
|
|
1610
|
+
this.renderTemplate.bind(this),
|
|
1611
|
+
"BaseWidgetMixin:renderTemplate"
|
|
1612
|
+
);
|
|
1561
1613
|
const nextProcessor = listValueTransformationsCopy.shift();
|
|
1562
1614
|
nextProcessor(this.value, listValueTransformationsCopy);
|
|
1563
1615
|
const listCallbacksCopy = this.listCallbacks.deepCopy();
|
|
@@ -1565,12 +1617,17 @@ const BaseWidgetMixin = {
|
|
|
1565
1617
|
if (nextCallback) {
|
|
1566
1618
|
nextCallback(this.value, listCallbacksCopy);
|
|
1567
1619
|
}
|
|
1568
|
-
this.element.dispatchEvent(
|
|
1620
|
+
this.element.dispatchEvent(
|
|
1621
|
+
new CustomEvent("widgetRendered", { bubbles: true })
|
|
1622
|
+
);
|
|
1569
1623
|
},
|
|
1570
1624
|
renderTemplate(value) {
|
|
1571
1625
|
const template = this.template(value, { ...this.listAttributes });
|
|
1572
1626
|
const listTemplateAdditionsCopy = this.listTemplateAdditions.deepCopy();
|
|
1573
|
-
listTemplateAdditionsCopy.attach(
|
|
1627
|
+
listTemplateAdditionsCopy.attach(
|
|
1628
|
+
this.templateToDOM.bind(this),
|
|
1629
|
+
"BaseWidgetMixin:templateToDOM"
|
|
1630
|
+
);
|
|
1574
1631
|
const nextProcessor = listTemplateAdditionsCopy.shift();
|
|
1575
1632
|
nextProcessor(template, listTemplateAdditionsCopy);
|
|
1576
1633
|
},
|
|
@@ -11144,7 +11201,8 @@ class CustomGetter {
|
|
|
11144
11201
|
if (!path) return;
|
|
11145
11202
|
try {
|
|
11146
11203
|
let isUrl = new URL(path);
|
|
11147
|
-
if (!isUrl.protocol.startsWith("http"))
|
|
11204
|
+
if (!isUrl.protocol.startsWith("http"))
|
|
11205
|
+
throw new Error("Not a valid HTTP url");
|
|
11148
11206
|
if (isUrl) {
|
|
11149
11207
|
let resources = this.resource[this.getExpandedPredicate(path)];
|
|
11150
11208
|
if (!resources) return void 0;
|
|
@@ -11152,7 +11210,13 @@ class CustomGetter {
|
|
|
11152
11210
|
let result = resources ? resources.map((res) => {
|
|
11153
11211
|
let resource = store.get(res["@id"]);
|
|
11154
11212
|
if (resource) return resource;
|
|
11155
|
-
resource = new CustomGetter(
|
|
11213
|
+
resource = new CustomGetter(
|
|
11214
|
+
res["@id"],
|
|
11215
|
+
{ "@id": res["@id"] },
|
|
11216
|
+
this.clientContext,
|
|
11217
|
+
this.serverContext,
|
|
11218
|
+
this.parentId
|
|
11219
|
+
).getProxy();
|
|
11156
11220
|
store.cacheResource(res["@id"], resource);
|
|
11157
11221
|
return resource;
|
|
11158
11222
|
}) : [];
|
|
@@ -11164,7 +11228,11 @@ class CustomGetter {
|
|
|
11164
11228
|
const path2 = [];
|
|
11165
11229
|
let value;
|
|
11166
11230
|
if (!this.isFullResource()) {
|
|
11167
|
-
await this.getResource(
|
|
11231
|
+
await this.getResource(
|
|
11232
|
+
this.resourceId,
|
|
11233
|
+
{ ...this.clientContext, ...this.serverContext },
|
|
11234
|
+
this.parentId
|
|
11235
|
+
);
|
|
11168
11236
|
}
|
|
11169
11237
|
while (true) {
|
|
11170
11238
|
value = await this.resource[this.getExpandedPredicate(path1[0])];
|
|
@@ -11174,10 +11242,18 @@ class CustomGetter {
|
|
|
11174
11242
|
}
|
|
11175
11243
|
if (path2.length === 0) {
|
|
11176
11244
|
if (!value || !value["@id"]) return this.getLiteralValue(value);
|
|
11177
|
-
return await this.getResource(
|
|
11245
|
+
return await this.getResource(
|
|
11246
|
+
value["@id"],
|
|
11247
|
+
{ ...this.clientContext, ...this.serverContext },
|
|
11248
|
+
this.parentId || this.resourceId
|
|
11249
|
+
);
|
|
11178
11250
|
}
|
|
11179
11251
|
if (!value || !value["@id"]) return void 0;
|
|
11180
|
-
let resource = await this.getResource(
|
|
11252
|
+
let resource = await this.getResource(
|
|
11253
|
+
value["@id"],
|
|
11254
|
+
{ ...this.clientContext, ...this.serverContext },
|
|
11255
|
+
this.parentId || this.resourceId
|
|
11256
|
+
);
|
|
11181
11257
|
store.subscribeResourceTo(this.resourceId, value["@id"]);
|
|
11182
11258
|
return resource ? await resource[path2.join(".")] : void 0;
|
|
11183
11259
|
}
|
|
@@ -11195,8 +11271,13 @@ class CustomGetter {
|
|
|
11195
11271
|
if (value.length === 0) return null;
|
|
11196
11272
|
if (Array.isArray(value[0])) {
|
|
11197
11273
|
const ln = store._getLanguage();
|
|
11198
|
-
let translatedValue = value.find(
|
|
11199
|
-
|
|
11274
|
+
let translatedValue = value.find(
|
|
11275
|
+
(v2) => v2["@language"] && v2["@language"] === ln
|
|
11276
|
+
);
|
|
11277
|
+
if (!translatedValue)
|
|
11278
|
+
translatedValue = value.find(
|
|
11279
|
+
(v2) => v2["@language"] && v2["@language"] === "en"
|
|
11280
|
+
);
|
|
11200
11281
|
return translatedValue ? translatedValue["@value"] || null : null;
|
|
11201
11282
|
}
|
|
11202
11283
|
return value;
|
|
@@ -11220,11 +11301,15 @@ class CustomGetter {
|
|
|
11220
11301
|
isContainer() {
|
|
11221
11302
|
if (this.resource["@type"]) {
|
|
11222
11303
|
if (Array.isArray(this.resource["@type"]))
|
|
11223
|
-
return this.containerTypes.some(
|
|
11304
|
+
return this.containerTypes.some(
|
|
11305
|
+
(type) => this.resource["@type"].includes(type)
|
|
11306
|
+
);
|
|
11224
11307
|
return this.containerTypes.includes(this.resource["@type"]);
|
|
11225
11308
|
} else if (this.resource["type"]) {
|
|
11226
11309
|
if (Array.isArray(this.resource["type"]))
|
|
11227
|
-
return this.containerTypes.some(
|
|
11310
|
+
return this.containerTypes.some(
|
|
11311
|
+
(type) => this.resource["type"].includes(type)
|
|
11312
|
+
);
|
|
11228
11313
|
return this.containerTypes.includes(this.resource["type"]);
|
|
11229
11314
|
}
|
|
11230
11315
|
return false;
|
|
@@ -11233,15 +11318,16 @@ class CustomGetter {
|
|
|
11233
11318
|
* Return true if the given key in the current resource in an array
|
|
11234
11319
|
*/
|
|
11235
11320
|
isArray() {
|
|
11236
|
-
if (Array.isArray(this.resource))
|
|
11237
|
-
return true;
|
|
11321
|
+
if (Array.isArray(this.resource)) return true;
|
|
11238
11322
|
return false;
|
|
11239
11323
|
}
|
|
11240
11324
|
/**
|
|
11241
11325
|
* Get all properties of a resource
|
|
11242
11326
|
*/
|
|
11243
11327
|
getProperties() {
|
|
11244
|
-
return Object.keys(this.resource).map(
|
|
11328
|
+
return Object.keys(this.resource).map(
|
|
11329
|
+
(prop2) => this.getCompactedPredicate(prop2)
|
|
11330
|
+
);
|
|
11245
11331
|
}
|
|
11246
11332
|
/**
|
|
11247
11333
|
* Get children of container as objects
|
|
@@ -11259,14 +11345,23 @@ class CustomGetter {
|
|
|
11259
11345
|
let result = children ? children.map((res) => {
|
|
11260
11346
|
let resource = store.get(res["@id"]);
|
|
11261
11347
|
if (resource) return resource;
|
|
11262
|
-
resource = new CustomGetter(
|
|
11348
|
+
resource = new CustomGetter(
|
|
11349
|
+
res["@id"],
|
|
11350
|
+
{ "@id": res["@id"] },
|
|
11351
|
+
this.clientContext,
|
|
11352
|
+
this.serverContext,
|
|
11353
|
+
this.parentId
|
|
11354
|
+
).getProxy();
|
|
11263
11355
|
store.cacheResource(res["@id"], resource);
|
|
11264
11356
|
return resource;
|
|
11265
11357
|
}) : [];
|
|
11266
11358
|
return result;
|
|
11267
11359
|
}
|
|
11268
11360
|
merge(resource) {
|
|
11269
|
-
this.resource = {
|
|
11361
|
+
this.resource = {
|
|
11362
|
+
...this.getResourceData(),
|
|
11363
|
+
...resource.getResourceData()
|
|
11364
|
+
};
|
|
11270
11365
|
}
|
|
11271
11366
|
getResourceData() {
|
|
11272
11367
|
return this.resource;
|
|
@@ -11276,7 +11371,9 @@ class CustomGetter {
|
|
|
11276
11371
|
* @param prop
|
|
11277
11372
|
*/
|
|
11278
11373
|
isFullResource() {
|
|
11279
|
-
let propertiesKeys = Object.keys(this.resource).filter(
|
|
11374
|
+
let propertiesKeys = Object.keys(this.resource).filter(
|
|
11375
|
+
(p2) => !p2.startsWith("@")
|
|
11376
|
+
);
|
|
11280
11377
|
if (this.resource["@id"].startsWith("_:b")) return true;
|
|
11281
11378
|
if (propertiesKeys.length === 1 && propertiesKeys[0] === this.getExpandedPredicate("permissions"))
|
|
11282
11379
|
return false;
|
|
@@ -11286,7 +11383,7 @@ class CustomGetter {
|
|
|
11286
11383
|
/**
|
|
11287
11384
|
* Get permissions of a resource
|
|
11288
11385
|
* @param resourceId
|
|
11289
|
-
* @returns
|
|
11386
|
+
* @returns
|
|
11290
11387
|
*/
|
|
11291
11388
|
async getPermissions() {
|
|
11292
11389
|
let permissions = this.resource[this.getExpandedPredicate("permissions")];
|
|
@@ -11315,13 +11412,24 @@ class CustomGetter {
|
|
|
11315
11412
|
store.clearCache(this.resourceId);
|
|
11316
11413
|
}
|
|
11317
11414
|
getExpandedPredicate(property) {
|
|
11318
|
-
return ContextParser$1.expandTerm(
|
|
11415
|
+
return ContextParser$1.expandTerm(
|
|
11416
|
+
property,
|
|
11417
|
+
{ ...this.clientContext, ...this.serverContext },
|
|
11418
|
+
true
|
|
11419
|
+
);
|
|
11319
11420
|
}
|
|
11320
11421
|
getCompactedPredicate(property) {
|
|
11321
|
-
return ContextParser$1.compactIri(
|
|
11422
|
+
return ContextParser$1.compactIri(
|
|
11423
|
+
property,
|
|
11424
|
+
{ ...this.clientContext, ...this.serverContext },
|
|
11425
|
+
true
|
|
11426
|
+
);
|
|
11322
11427
|
}
|
|
11323
11428
|
getCompactedIri(id2) {
|
|
11324
|
-
return ContextParser$1.compactIri(id2, {
|
|
11429
|
+
return ContextParser$1.compactIri(id2, {
|
|
11430
|
+
...this.clientContext,
|
|
11431
|
+
...this.serverContext
|
|
11432
|
+
});
|
|
11325
11433
|
}
|
|
11326
11434
|
toString() {
|
|
11327
11435
|
return this.getCompactedIri(this.resource["@id"]);
|
|
@@ -11336,13 +11444,13 @@ class CustomGetter {
|
|
|
11336
11444
|
return new Proxy(this, {
|
|
11337
11445
|
get: (resource, property) => {
|
|
11338
11446
|
if (!this.resource) return void 0;
|
|
11339
|
-
if (typeof resource[property] === "function")
|
|
11447
|
+
if (typeof resource[property] === "function")
|
|
11448
|
+
return resource[property].bind(resource);
|
|
11340
11449
|
switch (property) {
|
|
11341
11450
|
case "@id":
|
|
11342
11451
|
if (this.resource["@id"])
|
|
11343
11452
|
return this.getCompactedIri(this.resource["@id"]);
|
|
11344
|
-
else
|
|
11345
|
-
console.log(this.resource, this.resource["@id"]);
|
|
11453
|
+
else console.log(this.resource, this.resource["@id"]);
|
|
11346
11454
|
return;
|
|
11347
11455
|
case "@type":
|
|
11348
11456
|
return this.resource["@type"];
|
|
@@ -11367,7 +11475,9 @@ class CustomGetter {
|
|
|
11367
11475
|
}
|
|
11368
11476
|
function formatAttributesToServerSearchOptions(elementAttributes) {
|
|
11369
11477
|
var _a3, _b, _c;
|
|
11370
|
-
const attributes = new Map(
|
|
11478
|
+
const attributes = new Map(
|
|
11479
|
+
Array.from(elementAttributes).map(({ name, value: value2 }) => [name, value2])
|
|
11480
|
+
);
|
|
11371
11481
|
const fields = (_a3 = attributes.get("server-search-fields")) == null ? void 0 : _a3.split(",").map((field) => field.trim());
|
|
11372
11482
|
const value = (_b = attributes.get("server-search-value")) == null ? void 0 : _b.trim();
|
|
11373
11483
|
const method = (_c = attributes.get("server-search-method")) == null ? void 0 : _c.trim();
|
|
@@ -11392,7 +11502,9 @@ function appendServerSearchToIri(iri, options) {
|
|
|
11392
11502
|
return `${iri}${first}search-fields=${fields}&search-terms=${value}&search-method=${method}`;
|
|
11393
11503
|
}
|
|
11394
11504
|
function formatAttributesToServerPaginationOptions(elementAttributes) {
|
|
11395
|
-
const attributes = new Map(
|
|
11505
|
+
const attributes = new Map(
|
|
11506
|
+
Array.from(elementAttributes).map(({ name, value }) => [name, value])
|
|
11507
|
+
);
|
|
11396
11508
|
const limit = attributes.get("limit");
|
|
11397
11509
|
const offset = attributes.get("offset");
|
|
11398
11510
|
if (!offset || !limit) return;
|
|
@@ -11454,7 +11566,11 @@ class Store {
|
|
|
11454
11566
|
this.subscriptionIndex = /* @__PURE__ */ new Map();
|
|
11455
11567
|
this.subscriptionVirtualContainersIndex = /* @__PURE__ */ new Map();
|
|
11456
11568
|
this.loadingList = /* @__PURE__ */ new Set();
|
|
11457
|
-
this.headers = {
|
|
11569
|
+
this.headers = {
|
|
11570
|
+
Accept: "application/ld+json",
|
|
11571
|
+
"Content-Type": "application/ld+json",
|
|
11572
|
+
"Cache-Control": "must-revalidate"
|
|
11573
|
+
};
|
|
11458
11574
|
this.fetch = this.storeOptions.fetchMethod;
|
|
11459
11575
|
this.session = this.storeOptions.session;
|
|
11460
11576
|
}
|
|
@@ -11468,7 +11584,7 @@ class Store {
|
|
|
11468
11584
|
* @param serverPagination - Server pagination options
|
|
11469
11585
|
* @param serverSearch - Server search options
|
|
11470
11586
|
* @param predicateName - predicate name if we target a specific predicate from the resource, useful for arrays
|
|
11471
|
-
*
|
|
11587
|
+
*
|
|
11472
11588
|
* @returns The fetched resource
|
|
11473
11589
|
*
|
|
11474
11590
|
* @async
|
|
@@ -11484,10 +11600,14 @@ class Store {
|
|
|
11484
11600
|
}
|
|
11485
11601
|
if (localData == null && this.cache.has(key) && !this.loadingList.has(key)) {
|
|
11486
11602
|
const resource = this.get(key);
|
|
11487
|
-
if (resource && ((_a3 = resource.isFullResource) == null ? void 0 : _a3.call(resource)) && !forceFetch)
|
|
11603
|
+
if (resource && ((_a3 = resource.isFullResource) == null ? void 0 : _a3.call(resource)) && !forceFetch)
|
|
11604
|
+
return resource;
|
|
11488
11605
|
}
|
|
11489
11606
|
return new Promise(async (resolve2) => {
|
|
11490
|
-
document.addEventListener(
|
|
11607
|
+
document.addEventListener(
|
|
11608
|
+
"resourceReady",
|
|
11609
|
+
this.resolveResource(key, resolve2)
|
|
11610
|
+
);
|
|
11491
11611
|
if (this.loadingList.has(key)) return;
|
|
11492
11612
|
this.loadingList.add(key);
|
|
11493
11613
|
const clientContext = await myParser.parse(context2);
|
|
@@ -11496,20 +11616,48 @@ class Store {
|
|
|
11496
11616
|
if (localData == null) localData = {};
|
|
11497
11617
|
localData["@id"] = id2;
|
|
11498
11618
|
resource = localData;
|
|
11499
|
-
} else
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11619
|
+
} else
|
|
11620
|
+
try {
|
|
11621
|
+
resource = localData || await this.fetchData(
|
|
11622
|
+
id2,
|
|
11623
|
+
clientContext,
|
|
11624
|
+
parentId,
|
|
11625
|
+
serverPagination,
|
|
11626
|
+
serverSearch
|
|
11627
|
+
);
|
|
11628
|
+
} catch (error2) {
|
|
11629
|
+
console.error(error2);
|
|
11630
|
+
}
|
|
11504
11631
|
if (!resource) {
|
|
11505
11632
|
this.loadingList.delete(key);
|
|
11506
|
-
document.dispatchEvent(
|
|
11633
|
+
document.dispatchEvent(
|
|
11634
|
+
new CustomEvent("resourceReady", {
|
|
11635
|
+
detail: { id: key, resource: null, fetchedResource: null }
|
|
11636
|
+
})
|
|
11637
|
+
);
|
|
11507
11638
|
return;
|
|
11508
11639
|
}
|
|
11509
|
-
const serverContext = await myParser.parse([
|
|
11510
|
-
|
|
11640
|
+
const serverContext = await myParser.parse([
|
|
11641
|
+
resource["@context"] || base_context
|
|
11642
|
+
]);
|
|
11643
|
+
await this.cacheGraph(
|
|
11644
|
+
resource,
|
|
11645
|
+
clientContext,
|
|
11646
|
+
serverContext,
|
|
11647
|
+
parentId ? parentId : key,
|
|
11648
|
+
serverPagination,
|
|
11649
|
+
serverSearch
|
|
11650
|
+
);
|
|
11511
11651
|
this.loadingList.delete(key);
|
|
11512
|
-
document.dispatchEvent(
|
|
11652
|
+
document.dispatchEvent(
|
|
11653
|
+
new CustomEvent("resourceReady", {
|
|
11654
|
+
detail: {
|
|
11655
|
+
id: key,
|
|
11656
|
+
resource: this.get(key),
|
|
11657
|
+
fetchedResource: resource
|
|
11658
|
+
}
|
|
11659
|
+
})
|
|
11660
|
+
);
|
|
11513
11661
|
});
|
|
11514
11662
|
}
|
|
11515
11663
|
async fetchAuthn(iri, options) {
|
|
@@ -11518,7 +11666,8 @@ class Store {
|
|
|
11518
11666
|
if (this.fetch && authenticated) {
|
|
11519
11667
|
return this.fetch.then((fn) => fn(iri, options));
|
|
11520
11668
|
} else {
|
|
11521
|
-
if (options.headers)
|
|
11669
|
+
if (options.headers)
|
|
11670
|
+
options.headers = this._convertHeaders(options.headers);
|
|
11522
11671
|
return fetch(iri, options).then(function(response) {
|
|
11523
11672
|
return response;
|
|
11524
11673
|
});
|
|
@@ -11535,7 +11684,8 @@ class Store {
|
|
|
11535
11684
|
*/
|
|
11536
11685
|
async fetchData(id2, context2 = {}, parentId = "", serverPagination, serverSearch) {
|
|
11537
11686
|
let iri = this._getAbsoluteIri(id2, context2, parentId);
|
|
11538
|
-
if (serverPagination)
|
|
11687
|
+
if (serverPagination)
|
|
11688
|
+
iri = appendServerPaginationToIri(iri, serverPagination);
|
|
11539
11689
|
if (serverSearch) iri = appendServerSearchToIri(iri, serverSearch);
|
|
11540
11690
|
const headers = {
|
|
11541
11691
|
...this.headers,
|
|
@@ -11552,17 +11702,19 @@ class Store {
|
|
|
11552
11702
|
});
|
|
11553
11703
|
}
|
|
11554
11704
|
/**
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11705
|
+
* Cache the whole graph
|
|
11706
|
+
* @param resource - graph fetched
|
|
11707
|
+
* @param clientContext - context of the client app
|
|
11708
|
+
* @param parentContext - context of the server
|
|
11709
|
+
* @param parentId - id of the parent caller
|
|
11710
|
+
* @param serverPagination - Server pagination query params
|
|
11711
|
+
* @param serverSearch - Server search query params
|
|
11712
|
+
*/
|
|
11563
11713
|
async cacheGraph(resource, clientContext, parentContext, parentId, serverPagination, serverSearch) {
|
|
11564
11714
|
const flattenedResources = await jsonld$1.flatten(resource);
|
|
11565
|
-
const compactedResources = await Promise.all(
|
|
11715
|
+
const compactedResources = await Promise.all(
|
|
11716
|
+
flattenedResources.map((r3) => jsonld$1.compact(r3, {}))
|
|
11717
|
+
);
|
|
11566
11718
|
for (let resource2 of compactedResources) {
|
|
11567
11719
|
let id2 = resource2["@id"] || resource2["id"];
|
|
11568
11720
|
let key = resource2["@id"] || resource2["id"];
|
|
@@ -11570,11 +11722,21 @@ class Store {
|
|
|
11570
11722
|
if (key === "/") key = parentId;
|
|
11571
11723
|
if (key.startsWith("_:b")) key = key + parentId;
|
|
11572
11724
|
if (key === id2 && resource2["@type"] == this.getExpandedPredicate("ldp:Container", clientContext)) {
|
|
11573
|
-
if (serverPagination)
|
|
11725
|
+
if (serverPagination)
|
|
11726
|
+
key = appendServerPaginationToIri(key, serverPagination);
|
|
11574
11727
|
if (serverSearch) key = appendServerSearchToIri(key, serverSearch);
|
|
11575
11728
|
}
|
|
11576
|
-
const resourceProxy = new CustomGetter(
|
|
11577
|
-
|
|
11729
|
+
const resourceProxy = new CustomGetter(
|
|
11730
|
+
key,
|
|
11731
|
+
resource2,
|
|
11732
|
+
clientContext,
|
|
11733
|
+
parentContext,
|
|
11734
|
+
parentId,
|
|
11735
|
+
serverPagination,
|
|
11736
|
+
serverSearch
|
|
11737
|
+
).getProxy();
|
|
11738
|
+
if (resourceProxy.isContainer())
|
|
11739
|
+
this.subscribeChildren(resourceProxy, id2);
|
|
11578
11740
|
if (this.get(key)) {
|
|
11579
11741
|
this.cache.get(key).merge(resourceProxy);
|
|
11580
11742
|
} else {
|
|
@@ -11629,7 +11791,8 @@ class Store {
|
|
|
11629
11791
|
* @returns void
|
|
11630
11792
|
*/
|
|
11631
11793
|
async _updateResource(method, resource, id2) {
|
|
11632
|
-
if (!["POST", "PUT", "PATCH", "_LOCAL"].includes(method))
|
|
11794
|
+
if (!["POST", "PUT", "PATCH", "_LOCAL"].includes(method))
|
|
11795
|
+
throw new Error("Error: method not allowed");
|
|
11633
11796
|
const context2 = await myParser.parse([resource["@context"] || {}]);
|
|
11634
11797
|
const expandedId = this._getExpandedId(id2, context2);
|
|
11635
11798
|
return this._fetch(method, resource, id2).then(async (response) => {
|
|
@@ -11642,7 +11805,16 @@ class Store {
|
|
|
11642
11805
|
const nestedResources = await this.getNestedResources(resource, id2);
|
|
11643
11806
|
const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
|
|
11644
11807
|
const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
|
|
11645
|
-
return this.refreshResources([
|
|
11808
|
+
return this.refreshResources([
|
|
11809
|
+
...nestedResources,
|
|
11810
|
+
...resourcesToRefresh
|
|
11811
|
+
]).then(
|
|
11812
|
+
(resourceIds) => this.notifyResources([
|
|
11813
|
+
expandedId,
|
|
11814
|
+
...resourceIds,
|
|
11815
|
+
...resourcesToNotify
|
|
11816
|
+
])
|
|
11817
|
+
);
|
|
11646
11818
|
});
|
|
11647
11819
|
return ((_a3 = response.headers) == null ? void 0 : _a3.get("Location")) || null;
|
|
11648
11820
|
} else {
|
|
@@ -11659,12 +11831,19 @@ class Store {
|
|
|
11659
11831
|
resourceIds = [...new Set(resourceIds.filter((id2) => this.cache.has(id2)))];
|
|
11660
11832
|
const resourceWithContexts = resourceIds.map((resourceId) => {
|
|
11661
11833
|
var _a3;
|
|
11662
|
-
return {
|
|
11834
|
+
return {
|
|
11835
|
+
id: resourceId,
|
|
11836
|
+
context: (_a3 = store.get(resourceId)) == null ? void 0 : _a3.clientContext
|
|
11837
|
+
};
|
|
11663
11838
|
});
|
|
11664
11839
|
for (const resource of resourceWithContexts) {
|
|
11665
11840
|
if (!this._isLocalId(resource.id)) this.clearCache(resource.id);
|
|
11666
11841
|
}
|
|
11667
|
-
await Promise.all(
|
|
11842
|
+
await Promise.all(
|
|
11843
|
+
resourceWithContexts.map(
|
|
11844
|
+
({ id: id2, context: context2 }) => this.getData(id2, context2 || base_context)
|
|
11845
|
+
)
|
|
11846
|
+
);
|
|
11668
11847
|
return resourceIds;
|
|
11669
11848
|
}
|
|
11670
11849
|
/**
|
|
@@ -11717,7 +11896,8 @@ class Store {
|
|
|
11717
11896
|
const resource = this.cache.get(id2);
|
|
11718
11897
|
if (resource["@type"] === "ldp:Container") {
|
|
11719
11898
|
resource["ldp:contains"].forEach((child) => {
|
|
11720
|
-
if (child && child["@type"] === "ldp:Container")
|
|
11899
|
+
if (child && child["@type"] === "ldp:Container")
|
|
11900
|
+
this.cache.delete(child["@id"]);
|
|
11721
11901
|
});
|
|
11722
11902
|
}
|
|
11723
11903
|
this.cache.delete(id2);
|
|
@@ -11779,7 +11959,9 @@ class Store {
|
|
|
11779
11959
|
});
|
|
11780
11960
|
const resourcesToNotify = this.subscriptionIndex.get(expandedId) || [];
|
|
11781
11961
|
const resourcesToRefresh = this.subscriptionVirtualContainersIndex.get(expandedId) || [];
|
|
11782
|
-
this.refreshResources([...resourcesToNotify, ...resourcesToRefresh]).then(
|
|
11962
|
+
this.refreshResources([...resourcesToNotify, ...resourcesToRefresh]).then(
|
|
11963
|
+
(resourceIds) => this.notifyResources(resourceIds)
|
|
11964
|
+
);
|
|
11783
11965
|
return deleted;
|
|
11784
11966
|
}
|
|
11785
11967
|
/**
|
|
@@ -11804,8 +11986,7 @@ class Store {
|
|
|
11804
11986
|
* @returns The fully expanded term
|
|
11805
11987
|
*/
|
|
11806
11988
|
getExpandedPredicate(property, context2) {
|
|
11807
|
-
if (!context2)
|
|
11808
|
-
return ContextParser2.expandTerm(property, base_context, true);
|
|
11989
|
+
if (!context2) return ContextParser2.expandTerm(property, base_context, true);
|
|
11809
11990
|
return ContextParser2.expandTerm(property, context2, true);
|
|
11810
11991
|
}
|
|
11811
11992
|
/**
|
|
@@ -11815,8 +11996,7 @@ class Store {
|
|
|
11815
11996
|
* @returns The compacted term
|
|
11816
11997
|
*/
|
|
11817
11998
|
getCompactedIri(property, context2) {
|
|
11818
|
-
if (!context2)
|
|
11819
|
-
return ContextParser2.compactIri(property, base_context, true);
|
|
11999
|
+
if (!context2) return ContextParser2.compactIri(property, base_context, true);
|
|
11820
12000
|
return ContextParser2.compactIri(property, context2, true);
|
|
11821
12001
|
}
|
|
11822
12002
|
/**
|
|
@@ -11834,7 +12014,9 @@ class Store {
|
|
|
11834
12014
|
*/
|
|
11835
12015
|
subscribeResourceTo(resourceId, nestedResourceId) {
|
|
11836
12016
|
const existingSubscriptions = this.subscriptionIndex.get(nestedResourceId) || [];
|
|
11837
|
-
this.subscriptionIndex.set(nestedResourceId, [
|
|
12017
|
+
this.subscriptionIndex.set(nestedResourceId, [
|
|
12018
|
+
.../* @__PURE__ */ new Set([...existingSubscriptions, resourceId])
|
|
12019
|
+
]);
|
|
11838
12020
|
}
|
|
11839
12021
|
/**
|
|
11840
12022
|
* Make a virtual container listen for changes of a resource
|
|
@@ -11843,7 +12025,9 @@ class Store {
|
|
|
11843
12025
|
*/
|
|
11844
12026
|
subscribeVirtualContainerTo(virtualContainerId, nestedResourceId) {
|
|
11845
12027
|
const existingSubscriptions = this.subscriptionVirtualContainersIndex.get(nestedResourceId) || [];
|
|
11846
|
-
this.subscriptionVirtualContainersIndex.set(nestedResourceId, [
|
|
12028
|
+
this.subscriptionVirtualContainersIndex.set(nestedResourceId, [
|
|
12029
|
+
.../* @__PURE__ */ new Set([...existingSubscriptions, virtualContainerId])
|
|
12030
|
+
]);
|
|
11847
12031
|
}
|
|
11848
12032
|
/**
|
|
11849
12033
|
* Return absolute IRI of the resource
|
|
@@ -11890,7 +12074,9 @@ if (window.sibStore) {
|
|
|
11890
12074
|
if (sibAuth) {
|
|
11891
12075
|
const sibAuthDefined = customElements.whenDefined(sibAuth.localName);
|
|
11892
12076
|
storeOptions.session = sibAuthDefined.then(() => sibAuth.session);
|
|
11893
|
-
storeOptions.fetchMethod = sibAuthDefined.then(
|
|
12077
|
+
storeOptions.fetchMethod = sibAuthDefined.then(
|
|
12078
|
+
() => sibAuth.getFetch()
|
|
12079
|
+
);
|
|
11894
12080
|
}
|
|
11895
12081
|
store = new Store(storeOptions);
|
|
11896
12082
|
window.sibStore = store;
|
|
@@ -11919,15 +12105,20 @@ const AttributeBinderMixin = {
|
|
|
11919
12105
|
async replaceAttributesData(reset = true) {
|
|
11920
12106
|
if (reset) this.resetAttributesData();
|
|
11921
12107
|
const oldAttributes = Array.from(this.element.attributes).reduce((obj, attr) => {
|
|
11922
|
-
if (!attr.value.match(/^store:\/\/(resource|container|user)/))
|
|
11923
|
-
|
|
12108
|
+
if (!attr.value.match(/^store:\/\/(resource|container|user)/))
|
|
12109
|
+
return { ...obj };
|
|
12110
|
+
if (!this.bindedAttributes[attr.name])
|
|
12111
|
+
this.bindedAttributes[attr.name] = attr.value;
|
|
11924
12112
|
return {
|
|
11925
12113
|
...obj,
|
|
11926
12114
|
[attr.name]: attr.value
|
|
11927
12115
|
// add "key: value"
|
|
11928
12116
|
};
|
|
11929
12117
|
}, {});
|
|
11930
|
-
const newAttributes = await this.transformAttributes(
|
|
12118
|
+
const newAttributes = await this.transformAttributes(
|
|
12119
|
+
{ ...oldAttributes },
|
|
12120
|
+
this.resource
|
|
12121
|
+
);
|
|
11931
12122
|
for (let attr of Object.keys(newAttributes)) {
|
|
11932
12123
|
if (oldAttributes[attr] == newAttributes[attr]) continue;
|
|
11933
12124
|
this.element.setAttribute(attr, newAttributes[attr]);
|
|
@@ -12010,7 +12201,8 @@ const ContextMixin = {
|
|
|
12010
12201
|
// take element extra context first
|
|
12011
12202
|
document.querySelector("[data-default-context]")
|
|
12012
12203
|
);
|
|
12013
|
-
if (extraContextElement)
|
|
12204
|
+
if (extraContextElement)
|
|
12205
|
+
return JSON.parse(extraContextElement.textContent || "{}");
|
|
12014
12206
|
return {};
|
|
12015
12207
|
}
|
|
12016
12208
|
};
|
|
@@ -12111,7 +12303,8 @@ const ServerPaginationMixin = {
|
|
|
12111
12303
|
const currentOffset = this.getCurrentOffset(resourceId, this.limit);
|
|
12112
12304
|
var currentPageNumber = this.getCurrentServedPage(resourceId, 1);
|
|
12113
12305
|
const pageCount = Math.ceil(this.pageCount / this.limit);
|
|
12114
|
-
B(
|
|
12306
|
+
B(
|
|
12307
|
+
x`
|
|
12115
12308
|
<button
|
|
12116
12309
|
data-id="prev"
|
|
12117
12310
|
?disabled=${currentOffset <= 0}
|
|
@@ -12127,7 +12320,9 @@ const ServerPaginationMixin = {
|
|
|
12127
12320
|
>→</button>
|
|
12128
12321
|
<span>
|
|
12129
12322
|
</span>
|
|
12130
|
-
`,
|
|
12323
|
+
`,
|
|
12324
|
+
div2
|
|
12325
|
+
);
|
|
12131
12326
|
}
|
|
12132
12327
|
}
|
|
12133
12328
|
};
|
|
@@ -12168,7 +12363,11 @@ const StoreMixin = {
|
|
|
12168
12363
|
type: String,
|
|
12169
12364
|
default: null,
|
|
12170
12365
|
callback: function(value) {
|
|
12171
|
-
if (value)
|
|
12366
|
+
if (value)
|
|
12367
|
+
this.predicateName = store.getExpandedPredicate(
|
|
12368
|
+
this.arrayField,
|
|
12369
|
+
this.context
|
|
12370
|
+
);
|
|
12172
12371
|
}
|
|
12173
12372
|
},
|
|
12174
12373
|
predicateName: {
|
|
@@ -12189,7 +12388,9 @@ const StoreMixin = {
|
|
|
12189
12388
|
get resource() {
|
|
12190
12389
|
var _a3;
|
|
12191
12390
|
let id2 = this.resourceId;
|
|
12192
|
-
const serverPagination = formatAttributesToServerPaginationOptions(
|
|
12391
|
+
const serverPagination = formatAttributesToServerPaginationOptions(
|
|
12392
|
+
this.element.attributes
|
|
12393
|
+
);
|
|
12193
12394
|
const serverSearch = mergeServerSearchOptions(
|
|
12194
12395
|
formatAttributesToServerSearchOptions(this.element.attributes),
|
|
12195
12396
|
(_a3 = this.getDynamicServerSearch) == null ? void 0 : _a3.call(this)
|
|
@@ -12218,15 +12419,28 @@ const StoreMixin = {
|
|
|
12218
12419
|
}
|
|
12219
12420
|
}
|
|
12220
12421
|
this.updateNavigateSubscription();
|
|
12221
|
-
this.subscription = PubSub.subscribe(
|
|
12222
|
-
|
|
12422
|
+
this.subscription = PubSub.subscribe(
|
|
12423
|
+
this.resourceId,
|
|
12424
|
+
this.updateDOM.bind(this)
|
|
12425
|
+
);
|
|
12426
|
+
const serverPagination = formatAttributesToServerPaginationOptions(
|
|
12427
|
+
this.element.attributes
|
|
12428
|
+
);
|
|
12223
12429
|
const dynamicServerSearch = (_a3 = this.getDynamicServerSearch) == null ? void 0 : _a3.call(this);
|
|
12224
12430
|
const serverSearch = mergeServerSearchOptions(
|
|
12225
12431
|
formatAttributesToServerSearchOptions(this.element.attributes),
|
|
12226
12432
|
dynamicServerSearch
|
|
12227
12433
|
);
|
|
12228
12434
|
const forceRefetch = !!dynamicServerSearch;
|
|
12229
|
-
await store.getData(
|
|
12435
|
+
await store.getData(
|
|
12436
|
+
this.resourceId,
|
|
12437
|
+
this.context,
|
|
12438
|
+
void 0,
|
|
12439
|
+
void 0,
|
|
12440
|
+
forceRefetch,
|
|
12441
|
+
serverPagination,
|
|
12442
|
+
serverSearch
|
|
12443
|
+
);
|
|
12230
12444
|
this.updateDOM();
|
|
12231
12445
|
},
|
|
12232
12446
|
toggleLoaderHidden(toggle) {
|
|
@@ -12242,7 +12456,11 @@ const StoreMixin = {
|
|
|
12242
12456
|
setTimeout(
|
|
12243
12457
|
() => (
|
|
12244
12458
|
// Brings the dispatchEvent at the end of the queue
|
|
12245
|
-
this.element.dispatchEvent(
|
|
12459
|
+
this.element.dispatchEvent(
|
|
12460
|
+
new CustomEvent("populate", {
|
|
12461
|
+
detail: { resource: { "@id": this.dataSrc } }
|
|
12462
|
+
})
|
|
12463
|
+
)
|
|
12246
12464
|
)
|
|
12247
12465
|
);
|
|
12248
12466
|
this.toggleLoaderHidden(true);
|
|
@@ -12275,7 +12493,10 @@ const EditableMixin = {
|
|
|
12275
12493
|
}
|
|
12276
12494
|
},
|
|
12277
12495
|
created() {
|
|
12278
|
-
this.listTemplateAdditions.attach(
|
|
12496
|
+
this.listTemplateAdditions.attach(
|
|
12497
|
+
this.addEditButton.bind(this),
|
|
12498
|
+
"EditableMixin:addEditButton"
|
|
12499
|
+
);
|
|
12279
12500
|
},
|
|
12280
12501
|
addEditButton(template, listTemplateAdditions) {
|
|
12281
12502
|
let newTemplate = null;
|
|
@@ -12283,7 +12504,8 @@ const EditableMixin = {
|
|
|
12283
12504
|
newTemplate = x`${template}<button @click=${this.activateEditableField.bind(this)}>${this.buttonLabel}</button>`;
|
|
12284
12505
|
}
|
|
12285
12506
|
const nextProcessor = listTemplateAdditions.shift();
|
|
12286
|
-
if (nextProcessor)
|
|
12507
|
+
if (nextProcessor)
|
|
12508
|
+
nextProcessor(newTemplate || template, listTemplateAdditions);
|
|
12287
12509
|
},
|
|
12288
12510
|
activateEditableField(e2) {
|
|
12289
12511
|
const editableField = this.element.querySelector("[data-editable]");
|
|
@@ -12291,7 +12513,10 @@ const EditableMixin = {
|
|
|
12291
12513
|
editableField.toggleAttribute("contenteditable", true);
|
|
12292
12514
|
editableField.focus();
|
|
12293
12515
|
editButton.toggleAttribute("disabled", true);
|
|
12294
|
-
editableField.addEventListener(
|
|
12516
|
+
editableField.addEventListener(
|
|
12517
|
+
"focusout",
|
|
12518
|
+
() => this.save(editableField, editButton)
|
|
12519
|
+
);
|
|
12295
12520
|
},
|
|
12296
12521
|
save(editableField, editButton) {
|
|
12297
12522
|
editableField.toggleAttribute("contenteditable", false);
|
|
@@ -12385,7 +12610,8 @@ const FormMixin = {
|
|
|
12385
12610
|
},
|
|
12386
12611
|
getValue() {
|
|
12387
12612
|
if (!this.dataHolder || this.dataHolder.length === 0) return this.value;
|
|
12388
|
-
if (this.dataHolder.length > 1)
|
|
12613
|
+
if (this.dataHolder.length > 1)
|
|
12614
|
+
this.showDataHolderError(1, this.dataHolder.length);
|
|
12389
12615
|
return this.getValueFromElement(this.dataHolder[0]);
|
|
12390
12616
|
},
|
|
12391
12617
|
get type() {
|
|
@@ -12395,7 +12621,9 @@ const FormMixin = {
|
|
|
12395
12621
|
return false;
|
|
12396
12622
|
},
|
|
12397
12623
|
get dataHolder() {
|
|
12398
|
-
const dataHolders = Array.from(
|
|
12624
|
+
const dataHolders = Array.from(
|
|
12625
|
+
this.element.querySelectorAll("[data-holder]")
|
|
12626
|
+
);
|
|
12399
12627
|
const widgetDataHolders = dataHolders.filter((element) => {
|
|
12400
12628
|
const dataHolderAncestor = element.parentElement ? element.parentElement.closest("[data-holder]") : null;
|
|
12401
12629
|
return dataHolderAncestor === this.element || !dataHolderAncestor || !this.element.contains(dataHolderAncestor);
|
|
@@ -12406,7 +12634,9 @@ const FormMixin = {
|
|
|
12406
12634
|
return element.component ? element.component.getValue() : element.value;
|
|
12407
12635
|
},
|
|
12408
12636
|
showDataHolderError(expected, found) {
|
|
12409
|
-
console.warn(
|
|
12637
|
+
console.warn(
|
|
12638
|
+
`Expected ${expected} data-holder element in ${this.element.tagName}. Found ${found}`
|
|
12639
|
+
);
|
|
12410
12640
|
}
|
|
12411
12641
|
};
|
|
12412
12642
|
const FormCheckboxMixin = {
|
|
@@ -12486,10 +12716,13 @@ const FormDropdownMixin = {
|
|
|
12486
12716
|
getValue() {
|
|
12487
12717
|
if (!this.dataHolder) return "";
|
|
12488
12718
|
if (!this.multiple) {
|
|
12489
|
-
if (this.dataHolder.length > 1)
|
|
12719
|
+
if (this.dataHolder.length > 1)
|
|
12720
|
+
this.showDataHolderError(1, this.dataHolder.length);
|
|
12490
12721
|
return this.getValueFromElement(this.dataHolder[0]);
|
|
12491
12722
|
}
|
|
12492
|
-
const options = Array.from(
|
|
12723
|
+
const options = Array.from(
|
|
12724
|
+
this.element.querySelectorAll("option")
|
|
12725
|
+
);
|
|
12493
12726
|
return options.filter((el2) => el2.selected).map((el2) => el2.value ? JSON.parse(el2.value) : null);
|
|
12494
12727
|
},
|
|
12495
12728
|
get type() {
|
|
@@ -12522,7 +12755,9 @@ const FormCheckboxesMixin = {
|
|
|
12522
12755
|
this.listAttributes["values"] = [];
|
|
12523
12756
|
},
|
|
12524
12757
|
getValue() {
|
|
12525
|
-
const options = Array.from(
|
|
12758
|
+
const options = Array.from(
|
|
12759
|
+
this.element.querySelectorAll("input")
|
|
12760
|
+
);
|
|
12526
12761
|
return options.filter((el2) => el2.checked).map((el2) => {
|
|
12527
12762
|
if (!el2.value) return null;
|
|
12528
12763
|
let value = el2.value;
|
|
@@ -12546,7 +12781,9 @@ const FormRadioMixin = {
|
|
|
12546
12781
|
this.listAttributes["id"] = uniqID();
|
|
12547
12782
|
},
|
|
12548
12783
|
getValue() {
|
|
12549
|
-
const checkedElement = this.element.querySelector(
|
|
12784
|
+
const checkedElement = this.element.querySelector(
|
|
12785
|
+
"input[type=radio]:checked"
|
|
12786
|
+
);
|
|
12550
12787
|
return checkedElement ? checkedElement.value : "";
|
|
12551
12788
|
}
|
|
12552
12789
|
};
|
|
@@ -12651,7 +12888,8 @@ const MultipleFormMixin = {
|
|
|
12651
12888
|
type: String,
|
|
12652
12889
|
default: "+",
|
|
12653
12890
|
callback: function(value) {
|
|
12654
|
-
if (value !== this.listAttributes["addLabel"])
|
|
12891
|
+
if (value !== this.listAttributes["addLabel"])
|
|
12892
|
+
this.listAttributes["addLabel"] = value;
|
|
12655
12893
|
this.planRender();
|
|
12656
12894
|
}
|
|
12657
12895
|
},
|
|
@@ -12659,7 +12897,8 @@ const MultipleFormMixin = {
|
|
|
12659
12897
|
type: String,
|
|
12660
12898
|
default: "×",
|
|
12661
12899
|
callback: function(value) {
|
|
12662
|
-
if (value !== this.listAttributes["removeLabel"])
|
|
12900
|
+
if (value !== this.listAttributes["removeLabel"])
|
|
12901
|
+
this.listAttributes["removeLabel"] = value;
|
|
12663
12902
|
this.planRender();
|
|
12664
12903
|
}
|
|
12665
12904
|
},
|
|
@@ -12671,7 +12910,8 @@ const MultipleFormMixin = {
|
|
|
12671
12910
|
type: String,
|
|
12672
12911
|
default: void 0,
|
|
12673
12912
|
callback: function(value) {
|
|
12674
|
-
if (value !== this.listAttributes["addClass"])
|
|
12913
|
+
if (value !== this.listAttributes["addClass"])
|
|
12914
|
+
this.listAttributes["addClass"] = value;
|
|
12675
12915
|
this.planRender();
|
|
12676
12916
|
}
|
|
12677
12917
|
},
|
|
@@ -12679,13 +12919,17 @@ const MultipleFormMixin = {
|
|
|
12679
12919
|
type: String,
|
|
12680
12920
|
default: void 0,
|
|
12681
12921
|
callback: function(value) {
|
|
12682
|
-
if (value !== this.listAttributes["removeClass"])
|
|
12922
|
+
if (value !== this.listAttributes["removeClass"])
|
|
12923
|
+
this.listAttributes["removeClass"] = value;
|
|
12683
12924
|
this.planRender();
|
|
12684
12925
|
}
|
|
12685
12926
|
}
|
|
12686
12927
|
},
|
|
12687
12928
|
created() {
|
|
12688
|
-
this.listValueTransformations.attach(
|
|
12929
|
+
this.listValueTransformations.attach(
|
|
12930
|
+
this.setDataSrc.bind(this),
|
|
12931
|
+
"MultipleFormMixin:setDataSrc"
|
|
12932
|
+
);
|
|
12689
12933
|
this.listAttributes["children"] = [];
|
|
12690
12934
|
this.listAttributes["addLabel"] = this.addLabel;
|
|
12691
12935
|
this.listAttributes["removeLabel"] = this.removeLabel;
|
|
@@ -12726,12 +12970,13 @@ const MultipleFormMixin = {
|
|
|
12726
12970
|
const widget = document.createElement(this.widget);
|
|
12727
12971
|
const attributes = {
|
|
12728
12972
|
"data-holder": true,
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12973
|
+
name: this.name,
|
|
12974
|
+
value,
|
|
12975
|
+
range: this.range
|
|
12732
12976
|
};
|
|
12733
12977
|
for (let name of Object.keys(attributes)) {
|
|
12734
|
-
if (typeof attributes[name] === "boolean")
|
|
12978
|
+
if (typeof attributes[name] === "boolean")
|
|
12979
|
+
widget.toggleAttribute(name, attributes[name]);
|
|
12735
12980
|
else widget.setAttribute(name, attributes[name]);
|
|
12736
12981
|
}
|
|
12737
12982
|
this.listAttributes["children"].push(widget);
|
|
@@ -12763,7 +13008,8 @@ const MultipleselectFormMixin = {
|
|
|
12763
13008
|
type: String,
|
|
12764
13009
|
default: "",
|
|
12765
13010
|
callback: function(value) {
|
|
12766
|
-
if (value && value !== this.listAttributes["range"])
|
|
13011
|
+
if (value && value !== this.listAttributes["range"])
|
|
13012
|
+
this.listAttributes["range"] = value;
|
|
12767
13013
|
}
|
|
12768
13014
|
},
|
|
12769
13015
|
enum: {
|
|
@@ -12771,7 +13017,8 @@ const MultipleselectFormMixin = {
|
|
|
12771
13017
|
type: String,
|
|
12772
13018
|
default: "",
|
|
12773
13019
|
callback: function(value) {
|
|
12774
|
-
if (value && value !== this.listAttributes["enum"])
|
|
13020
|
+
if (value && value !== this.listAttributes["enum"])
|
|
13021
|
+
this.listAttributes["enum"] = value;
|
|
12775
13022
|
}
|
|
12776
13023
|
},
|
|
12777
13024
|
orderAsc: {
|
|
@@ -12790,7 +13037,10 @@ const MultipleselectFormMixin = {
|
|
|
12790
13037
|
}
|
|
12791
13038
|
},
|
|
12792
13039
|
created() {
|
|
12793
|
-
this.listValueTransformations.attach(
|
|
13040
|
+
this.listValueTransformations.attach(
|
|
13041
|
+
this.setDataSrc.bind(this),
|
|
13042
|
+
"MultipleselectFormMixin:setDataSrc"
|
|
13043
|
+
);
|
|
12794
13044
|
},
|
|
12795
13045
|
setDataSrc(value, listValueTransformations) {
|
|
12796
13046
|
if (value && value !== this.dataSrc) {
|
|
@@ -12810,7 +13060,8 @@ const MultipleselectFormMixin = {
|
|
|
12810
13060
|
if (nextProcessor) nextProcessor(value, listValueTransformations);
|
|
12811
13061
|
},
|
|
12812
13062
|
populate() {
|
|
12813
|
-
if (!this.resource || !this.resource["ldp:contains"] && !Array.isArray(this.resource))
|
|
13063
|
+
if (!this.resource || !this.resource["ldp:contains"] && !Array.isArray(this.resource))
|
|
13064
|
+
return;
|
|
12814
13065
|
this.setValue(this.resource["ldp:contains"]);
|
|
12815
13066
|
this.planRender();
|
|
12816
13067
|
},
|
|
@@ -12863,7 +13114,10 @@ const SorterMixin = {
|
|
|
12863
13114
|
randomOrder: null
|
|
12864
13115
|
},
|
|
12865
13116
|
attached() {
|
|
12866
|
-
this.listPostProcessors.attach(
|
|
13117
|
+
this.listPostProcessors.attach(
|
|
13118
|
+
this.orderCallback.bind(this),
|
|
13119
|
+
"SorterMixin:orderCallback"
|
|
13120
|
+
);
|
|
12867
13121
|
},
|
|
12868
13122
|
created() {
|
|
12869
13123
|
this.randomOrder = [];
|
|
@@ -12904,17 +13158,20 @@ const SorterMixin = {
|
|
|
12904
13158
|
if (sortingKey) {
|
|
12905
13159
|
let orderToSort = true;
|
|
12906
13160
|
if (this.orderDesc || orderValueToSort == "desc") orderToSort = false;
|
|
12907
|
-
resources = (await Promise.all(
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
13161
|
+
resources = (await Promise.all(
|
|
13162
|
+
resources.map(async (resource) => ({
|
|
13163
|
+
sortingKey: await resource[sortingKey],
|
|
13164
|
+
// fetch sorting value
|
|
13165
|
+
proxy: resource
|
|
13166
|
+
// and keep proxy
|
|
13167
|
+
}))
|
|
13168
|
+
)).sort(this.sortValuesByKey("sortingKey", orderToSort)).map((r3) => r3.proxy);
|
|
12913
13169
|
} else if (this.isRandomSorted()) {
|
|
12914
13170
|
resources = this.shuffleResources(resources);
|
|
12915
13171
|
}
|
|
12916
13172
|
const nextProcessor = listPostProcessors.shift();
|
|
12917
|
-
if (nextProcessor)
|
|
13173
|
+
if (nextProcessor)
|
|
13174
|
+
await nextProcessor(resources, listPostProcessors, div2, context2);
|
|
12918
13175
|
},
|
|
12919
13176
|
isRandomSorted() {
|
|
12920
13177
|
return this.orderByRandom !== null;
|
|
@@ -12927,7 +13184,9 @@ const SorterMixin = {
|
|
|
12927
13184
|
const varB = b2[key];
|
|
12928
13185
|
let comparison = 0;
|
|
12929
13186
|
if (typeof varA === "string" && typeof varB === "string") {
|
|
12930
|
-
comparison = varA.localeCompare(varB, void 0, {
|
|
13187
|
+
comparison = varA.localeCompare(varB, void 0, {
|
|
13188
|
+
sensitivity: "base"
|
|
13189
|
+
});
|
|
12931
13190
|
comparison = asc ? comparison : -comparison;
|
|
12932
13191
|
} else {
|
|
12933
13192
|
if (varA > varB) comparison = asc ? 1 : -1;
|
|
@@ -12960,14 +13219,18 @@ const FederationMixin = {
|
|
|
12960
13219
|
containerFetched: null
|
|
12961
13220
|
},
|
|
12962
13221
|
attached() {
|
|
12963
|
-
this.listPostProcessors.attach(
|
|
13222
|
+
this.listPostProcessors.attach(
|
|
13223
|
+
this.fetchSources.bind(this),
|
|
13224
|
+
"FederationMixin:fetchSources"
|
|
13225
|
+
);
|
|
12964
13226
|
},
|
|
12965
13227
|
async fetchSources(resources, listPostProcessors, div2, context2) {
|
|
12966
13228
|
this.containerFetched = [];
|
|
12967
13229
|
let newResources = await this.getResources(resources);
|
|
12968
13230
|
newResources = [...new Set(newResources)];
|
|
12969
13231
|
const nextProcessor = listPostProcessors.shift();
|
|
12970
|
-
if (nextProcessor)
|
|
13232
|
+
if (nextProcessor)
|
|
13233
|
+
await nextProcessor(newResources, listPostProcessors, div2, context2);
|
|
12971
13234
|
},
|
|
12972
13235
|
async getResources(resources) {
|
|
12973
13236
|
if (!resources) return [];
|
|
@@ -12980,7 +13243,8 @@ const FederationMixin = {
|
|
|
12980
13243
|
if (!this.containerFetched.includes(containerId)) {
|
|
12981
13244
|
this.containerFetched.push(containerId);
|
|
12982
13245
|
const resourcesFetched = await this.fetchSource(containerId);
|
|
12983
|
-
if (resourcesFetched)
|
|
13246
|
+
if (resourcesFetched)
|
|
13247
|
+
newResources.push(...await this.getResources(resourcesFetched));
|
|
12984
13248
|
}
|
|
12985
13249
|
} else {
|
|
12986
13250
|
newResources.push(res);
|
|
@@ -13001,11 +13265,7 @@ const FederationMixin = {
|
|
|
13001
13265
|
};
|
|
13002
13266
|
const RangeMixin = {
|
|
13003
13267
|
name: "range-mixin",
|
|
13004
|
-
use: [
|
|
13005
|
-
StoreMixin,
|
|
13006
|
-
SorterMixin,
|
|
13007
|
-
FederationMixin
|
|
13008
|
-
],
|
|
13268
|
+
use: [StoreMixin, SorterMixin, FederationMixin],
|
|
13009
13269
|
attributes: {
|
|
13010
13270
|
range: {
|
|
13011
13271
|
type: String,
|
|
@@ -13064,19 +13324,20 @@ const RangeMixin = {
|
|
|
13064
13324
|
async populate() {
|
|
13065
13325
|
const resources = this.resource ? this.resource["ldp:contains"] : [];
|
|
13066
13326
|
const listPostProcessorsCopy = this.listPostProcessors.deepCopy();
|
|
13067
|
-
listPostProcessorsCopy.attach(
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
resources,
|
|
13071
|
-
listPostProcessorsCopy,
|
|
13072
|
-
null,
|
|
13073
|
-
this.dataSrc
|
|
13327
|
+
listPostProcessorsCopy.attach(
|
|
13328
|
+
this.setRangeAttribute.bind(this),
|
|
13329
|
+
"RangeMixin:setRangeAttribute"
|
|
13074
13330
|
);
|
|
13331
|
+
const nextProcessor = listPostProcessorsCopy.shift();
|
|
13332
|
+
await nextProcessor(resources, listPostProcessorsCopy, null, this.dataSrc);
|
|
13075
13333
|
},
|
|
13076
13334
|
async setRangeAttribute(resources) {
|
|
13077
13335
|
if (resources) {
|
|
13078
13336
|
const getRangeValue = async (resource) => {
|
|
13079
|
-
let res = await store.getData(
|
|
13337
|
+
let res = await store.getData(
|
|
13338
|
+
resource["@id"],
|
|
13339
|
+
this.context || base_context
|
|
13340
|
+
);
|
|
13080
13341
|
if (res === null) {
|
|
13081
13342
|
res = resource;
|
|
13082
13343
|
}
|
|
@@ -13127,7 +13388,8 @@ const FilterRangeFormMixin = {
|
|
|
13127
13388
|
},
|
|
13128
13389
|
getValue() {
|
|
13129
13390
|
if (!this.dataHolder) return [];
|
|
13130
|
-
if (this.dataHolder.length !== 2)
|
|
13391
|
+
if (this.dataHolder.length !== 2)
|
|
13392
|
+
this.showDataHolderError(2, this.dataHolder.length);
|
|
13131
13393
|
return [
|
|
13132
13394
|
// we expect 2 values, one min and one max
|
|
13133
13395
|
this.getValueFromElement(this.dataHolder[0]),
|
|
@@ -13995,22 +14257,26 @@ const formTemplates = {
|
|
|
13995
14257
|
${attributes.placeholder || "-"}
|
|
13996
14258
|
</option>
|
|
13997
14259
|
` : ""}
|
|
13998
|
-
${(attributes.range || []).map(
|
|
14260
|
+
${(attributes.range || []).map(
|
|
14261
|
+
(el2) => x`
|
|
13999
14262
|
<option
|
|
14000
14263
|
value=${el2.value}
|
|
14001
14264
|
?selected=${!attributes.multiple ? value === el2.selectedValue : attributes.values.includes(el2.selectedValue)}
|
|
14002
14265
|
>
|
|
14003
14266
|
${el2.label}
|
|
14004
14267
|
</option>
|
|
14005
|
-
`
|
|
14006
|
-
|
|
14268
|
+
`
|
|
14269
|
+
)}
|
|
14270
|
+
${Object.entries(attributes.enum || []).map(
|
|
14271
|
+
([key, val]) => x`
|
|
14007
14272
|
<option
|
|
14008
14273
|
value="${key}"
|
|
14009
14274
|
?selected=${!attributes.multiple ? value === key : attributes.values.includes(key)}
|
|
14010
14275
|
>
|
|
14011
14276
|
${val}
|
|
14012
14277
|
</option>
|
|
14013
|
-
`
|
|
14278
|
+
`
|
|
14279
|
+
)}
|
|
14014
14280
|
</select>
|
|
14015
14281
|
`,
|
|
14016
14282
|
dependencies: [FormDropdownMixin, FormMixin, RangeMixin]
|
|
@@ -14020,7 +14286,8 @@ const formTemplates = {
|
|
|
14020
14286
|
<div
|
|
14021
14287
|
name=${o$2(attributes.name)}
|
|
14022
14288
|
>
|
|
14023
|
-
${(attributes.range || []).map(
|
|
14289
|
+
${(attributes.range || []).map(
|
|
14290
|
+
(el2) => x`
|
|
14024
14291
|
<label>
|
|
14025
14292
|
<input
|
|
14026
14293
|
type="radio"
|
|
@@ -14030,8 +14297,10 @@ const formTemplates = {
|
|
|
14030
14297
|
?checked=${value === el2.selectedValue}
|
|
14031
14298
|
> <span>${el2.label}</span>
|
|
14032
14299
|
</label>
|
|
14033
|
-
`
|
|
14034
|
-
|
|
14300
|
+
`
|
|
14301
|
+
)}
|
|
14302
|
+
${Object.entries(attributes.enum || []).map(
|
|
14303
|
+
([key, val]) => x`
|
|
14035
14304
|
<label>
|
|
14036
14305
|
<input
|
|
14037
14306
|
type="radio"
|
|
@@ -14041,7 +14310,8 @@ const formTemplates = {
|
|
|
14041
14310
|
?checked=${value === key}
|
|
14042
14311
|
> <span>${val}</span>
|
|
14043
14312
|
</label>
|
|
14044
|
-
`
|
|
14313
|
+
`
|
|
14314
|
+
)}
|
|
14045
14315
|
`,
|
|
14046
14316
|
dependencies: [FormRadioMixin, FormMixin, RangeMixin]
|
|
14047
14317
|
},
|
|
@@ -14050,7 +14320,8 @@ const formTemplates = {
|
|
|
14050
14320
|
<div
|
|
14051
14321
|
name=${o$2(attributes.name)}
|
|
14052
14322
|
>
|
|
14053
|
-
${(attributes.range || []).map(
|
|
14323
|
+
${(attributes.range || []).map(
|
|
14324
|
+
(el2) => x`
|
|
14054
14325
|
<label>
|
|
14055
14326
|
<input
|
|
14056
14327
|
type="checkbox"
|
|
@@ -14058,14 +14329,17 @@ const formTemplates = {
|
|
|
14058
14329
|
?checked=${attributes.values.includes(el2.selectedValue)}
|
|
14059
14330
|
/> <span>${el2.label}</span>
|
|
14060
14331
|
</label>
|
|
14061
|
-
`
|
|
14062
|
-
|
|
14332
|
+
`
|
|
14333
|
+
)}
|
|
14334
|
+
${Object.entries(attributes.enum || []).map(
|
|
14335
|
+
([key, val]) => x`
|
|
14063
14336
|
<label>
|
|
14064
14337
|
<input type="checkbox"
|
|
14065
14338
|
value="${key}"
|
|
14066
14339
|
/> <span>${val}</span>
|
|
14067
14340
|
</label>
|
|
14068
|
-
`
|
|
14341
|
+
`
|
|
14342
|
+
)}
|
|
14069
14343
|
</select>
|
|
14070
14344
|
`,
|
|
14071
14345
|
dependencies: [FormCheckboxesMixin, FormMixin, RangeMixin]
|
|
@@ -14089,12 +14363,14 @@ const formTemplates = {
|
|
|
14089
14363
|
},
|
|
14090
14364
|
multiple: {
|
|
14091
14365
|
template: (_value, attributes) => x`
|
|
14092
|
-
${(attributes.children || []).map(
|
|
14366
|
+
${(attributes.children || []).map(
|
|
14367
|
+
(child, index2) => x`
|
|
14093
14368
|
<div data-index=${attributes.name + index2}>
|
|
14094
14369
|
${child}
|
|
14095
14370
|
<button type="button" class=${o$2(attributes.removeClass)} @click=${() => attributes.removeItem(index2)}>${attributes.removeLabel}</button>
|
|
14096
14371
|
</div>
|
|
14097
|
-
`
|
|
14372
|
+
`
|
|
14373
|
+
)}
|
|
14098
14374
|
<button type="button" class=${o$2(attributes.addClass)} @click=${attributes.addItem}>${attributes.addLabel}</button>
|
|
14099
14375
|
`,
|
|
14100
14376
|
dependencies: [MultipleFormMixin, FormMixin]
|
|
@@ -14297,7 +14573,10 @@ const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
14297
14573
|
const DateMixin = {
|
|
14298
14574
|
name: "date-mixin",
|
|
14299
14575
|
created() {
|
|
14300
|
-
this.listValueTransformations.attach(
|
|
14576
|
+
this.listValueTransformations.attach(
|
|
14577
|
+
this.transformValue.bind(this),
|
|
14578
|
+
"DateMixin:transformValue"
|
|
14579
|
+
);
|
|
14301
14580
|
},
|
|
14302
14581
|
transformValue(value, listValueTransformations) {
|
|
14303
14582
|
try {
|
|
@@ -14324,7 +14603,10 @@ const DateMixin = {
|
|
|
14324
14603
|
const DateTimeMixin = {
|
|
14325
14604
|
name: "date-time-mixin",
|
|
14326
14605
|
created() {
|
|
14327
|
-
this.listValueTransformations.attach(
|
|
14606
|
+
this.listValueTransformations.attach(
|
|
14607
|
+
this.transformValue.bind(this),
|
|
14608
|
+
"DateTimeMixin:transformValue"
|
|
14609
|
+
);
|
|
14328
14610
|
},
|
|
14329
14611
|
transformValue(value, listValueTransformations) {
|
|
14330
14612
|
const newValue = value ? new Date(value).toLocaleString() : value;
|
|
@@ -14356,7 +14638,10 @@ const o$1 = e$1(e);
|
|
|
14356
14638
|
const MultilineMixin = {
|
|
14357
14639
|
name: "multiline-mixin",
|
|
14358
14640
|
created() {
|
|
14359
|
-
this.listValueTransformations.attach(
|
|
14641
|
+
this.listValueTransformations.attach(
|
|
14642
|
+
this.transformValue.bind(this),
|
|
14643
|
+
"MultilineMixin:transformValue"
|
|
14644
|
+
);
|
|
14360
14645
|
},
|
|
14361
14646
|
transformValue(value, listValueTransformations) {
|
|
14362
14647
|
const newValue = value ? o$1(value.replace(/\n/g, "<br/>")) : value;
|
|
@@ -19583,7 +19868,10 @@ const mila = /* @__PURE__ */ getDefaultExportFromCjs(markdownItLinkAttributes);
|
|
|
19583
19868
|
const MarkdownMixin = {
|
|
19584
19869
|
name: "markdown-mixin",
|
|
19585
19870
|
created() {
|
|
19586
|
-
this.listValueTransformations.attach(
|
|
19871
|
+
this.listValueTransformations.attach(
|
|
19872
|
+
this.transformValue.bind(this),
|
|
19873
|
+
"MarkdownMixin:transformValue"
|
|
19874
|
+
);
|
|
19587
19875
|
},
|
|
19588
19876
|
transformValue(value, listValueTransformations) {
|
|
19589
19877
|
let newValue = "";
|
|
@@ -19612,7 +19900,10 @@ const OembedMixin = {
|
|
|
19612
19900
|
existingOembed: null
|
|
19613
19901
|
},
|
|
19614
19902
|
created() {
|
|
19615
|
-
this.listValueTransformations.attach(
|
|
19903
|
+
this.listValueTransformations.attach(
|
|
19904
|
+
this.transformValue.bind(this),
|
|
19905
|
+
"OembedMixin:transformValue"
|
|
19906
|
+
);
|
|
19616
19907
|
},
|
|
19617
19908
|
async transformValue(value, listValueTransformations) {
|
|
19618
19909
|
if (!value) return;
|
|
@@ -21867,13 +22158,17 @@ function normalizeTruncateCfg(truncate) {
|
|
|
21867
22158
|
const AutolinkMixin = {
|
|
21868
22159
|
name: "autolink-mixin",
|
|
21869
22160
|
created() {
|
|
21870
|
-
this.listValueTransformations.attach(
|
|
22161
|
+
this.listValueTransformations.attach(
|
|
22162
|
+
this.transformValue.bind(this),
|
|
22163
|
+
"AutolinkMixin:transformValue"
|
|
22164
|
+
);
|
|
21871
22165
|
},
|
|
21872
22166
|
transformValue(value, listValueTransformations) {
|
|
21873
22167
|
const template = document.createElement("template");
|
|
21874
22168
|
template.innerHTML = Autolinker.link(value);
|
|
21875
22169
|
const nextProcessor = listValueTransformations.shift();
|
|
21876
|
-
if (nextProcessor)
|
|
22170
|
+
if (nextProcessor)
|
|
22171
|
+
nextProcessor(template.content, listValueTransformations);
|
|
21877
22172
|
}
|
|
21878
22173
|
};
|
|
21879
22174
|
const valueTransformationDirectory = {
|
|
@@ -21888,7 +22183,10 @@ const LabelMixin = {
|
|
|
21888
22183
|
name: "label-mixin",
|
|
21889
22184
|
created() {
|
|
21890
22185
|
this.listAttributes["id"] = uniqID();
|
|
21891
|
-
this.listTemplateAdditions.attach(
|
|
22186
|
+
this.listTemplateAdditions.attach(
|
|
22187
|
+
this.addLabel.bind(this),
|
|
22188
|
+
"LabelMixin:addLabel"
|
|
22189
|
+
);
|
|
21892
22190
|
},
|
|
21893
22191
|
addLabel(template, listTemplateAdditions) {
|
|
21894
22192
|
const newTemplate = x`<label for="${this.listAttributes["id"]}">${this.label || this.name}</label>${template}`;
|
|
@@ -21899,7 +22197,10 @@ const LabelMixin = {
|
|
|
21899
22197
|
const LabelLastMixin = {
|
|
21900
22198
|
name: "label-last-mixin",
|
|
21901
22199
|
created() {
|
|
21902
|
-
this.listTemplateAdditions.attach(
|
|
22200
|
+
this.listTemplateAdditions.attach(
|
|
22201
|
+
this.addLabelLast.bind(this),
|
|
22202
|
+
"LabelLastMixin:addLabelLast"
|
|
22203
|
+
);
|
|
21903
22204
|
},
|
|
21904
22205
|
addLabelLast(template, listTemplateAdditions) {
|
|
21905
22206
|
const newTemplate = x`${template}<label>${this.label || this.name}</label>`;
|
|
@@ -21910,13 +22211,20 @@ const LabelLastMixin = {
|
|
|
21910
22211
|
const AddableMixin = {
|
|
21911
22212
|
name: "addable-mixin",
|
|
21912
22213
|
created() {
|
|
21913
|
-
this.listTemplateAdditions.attach(
|
|
22214
|
+
this.listTemplateAdditions.attach(
|
|
22215
|
+
this.addableValue.bind(this),
|
|
22216
|
+
"AddableMixin:addableValue"
|
|
22217
|
+
);
|
|
21914
22218
|
},
|
|
21915
22219
|
getAddableAttributes() {
|
|
21916
|
-
const addableAttr = Array.from(this.element.attributes).filter(
|
|
22220
|
+
const addableAttr = Array.from(this.element.attributes).filter(
|
|
22221
|
+
(a2) => a2.name.startsWith("addable-")
|
|
22222
|
+
);
|
|
21917
22223
|
const cleanAddableAttr = {};
|
|
21918
|
-
for (let attr of addableAttr)
|
|
21919
|
-
|
|
22224
|
+
for (let attr of addableAttr)
|
|
22225
|
+
cleanAddableAttr[attr.name.replace("addable-", "")] = attr.value;
|
|
22226
|
+
if (!cleanAddableAttr.hasOwnProperty("data-src"))
|
|
22227
|
+
cleanAddableAttr["data-src"] = this.range;
|
|
21920
22228
|
return cleanAddableAttr;
|
|
21921
22229
|
},
|
|
21922
22230
|
addableValue(template, listTemplateAdditions, attributes) {
|
|
@@ -24018,7 +24326,9 @@ const TranslationMixin = {
|
|
|
24018
24326
|
fr: () => import("./fr-ClQZ5-J-.js")
|
|
24019
24327
|
};
|
|
24020
24328
|
if (!translationsModules[langCode]) {
|
|
24021
|
-
console.warn(
|
|
24329
|
+
console.warn(
|
|
24330
|
+
`${langCode}.json translation file may not exist, English is setted by default`
|
|
24331
|
+
);
|
|
24022
24332
|
langCode = "en";
|
|
24023
24333
|
}
|
|
24024
24334
|
const module2 = await translationsModules[langCode]();
|
|
@@ -24074,11 +24384,20 @@ const AutocompletionMixin = {
|
|
|
24074
24384
|
mutationObserver: null
|
|
24075
24385
|
},
|
|
24076
24386
|
created() {
|
|
24077
|
-
importInlineCSS(
|
|
24078
|
-
|
|
24387
|
+
importInlineCSS(
|
|
24388
|
+
"slimselect-base",
|
|
24389
|
+
() => import("./slimselect-BTZP03JZ.js")
|
|
24390
|
+
);
|
|
24391
|
+
importInlineCSS(
|
|
24392
|
+
"slimselect-local",
|
|
24393
|
+
() => import("./slimselect-WIZK5Hmq.js")
|
|
24394
|
+
);
|
|
24079
24395
|
this.slimSelect = null;
|
|
24080
24396
|
this.addToAttributes(true, "autocomplete");
|
|
24081
|
-
this.listCallbacks.attach(
|
|
24397
|
+
this.listCallbacks.attach(
|
|
24398
|
+
this.addCallback.bind(this),
|
|
24399
|
+
"AutocompletionMixin:addCallback"
|
|
24400
|
+
);
|
|
24082
24401
|
},
|
|
24083
24402
|
detached() {
|
|
24084
24403
|
if (this.slimSelect) this.slimSelect.destroy();
|
|
@@ -48117,7 +48436,10 @@ const RichtextMixin = {
|
|
|
48117
48436
|
created() {
|
|
48118
48437
|
importInlineCSS("quill", () => import("./quill.snow-B73wIbzm.js"));
|
|
48119
48438
|
this.quill = null;
|
|
48120
|
-
this.listCallbacks.attach(
|
|
48439
|
+
this.listCallbacks.attach(
|
|
48440
|
+
this.addCallback.bind(this),
|
|
48441
|
+
"RichtextMixin:addCallback"
|
|
48442
|
+
);
|
|
48121
48443
|
},
|
|
48122
48444
|
getPlaceHolderValue() {
|
|
48123
48445
|
return this.element.hasAttribute("placeholder") ? this.element.getAttribute("placeholder") : "";
|
|
@@ -48127,20 +48449,19 @@ const RichtextMixin = {
|
|
|
48127
48449
|
var toolbarOptions = [
|
|
48128
48450
|
["bold", "italic"],
|
|
48129
48451
|
["blockquote"],
|
|
48130
|
-
[{
|
|
48131
|
-
[{
|
|
48452
|
+
[{ header: [1, 2, 3, 4, 5, 6, false] }],
|
|
48453
|
+
[{ list: "ordered" }, { list: "bullet" }],
|
|
48132
48454
|
["link"],
|
|
48133
48455
|
["clean"]
|
|
48134
48456
|
];
|
|
48135
|
-
const richtext = this.element.querySelector(
|
|
48136
|
-
|
|
48137
|
-
richtext,
|
|
48138
|
-
{
|
|
48139
|
-
modules: { toolbar: toolbarOptions },
|
|
48140
|
-
placeholder: this.getPlaceHolderValue(),
|
|
48141
|
-
theme: "snow"
|
|
48142
|
-
}
|
|
48457
|
+
const richtext = this.element.querySelector(
|
|
48458
|
+
"[data-richtext]"
|
|
48143
48459
|
);
|
|
48460
|
+
this.quill = new Quill(richtext, {
|
|
48461
|
+
modules: { toolbar: toolbarOptions },
|
|
48462
|
+
placeholder: this.getPlaceHolderValue(),
|
|
48463
|
+
theme: "snow"
|
|
48464
|
+
});
|
|
48144
48465
|
}
|
|
48145
48466
|
const ops = deltaMd.toDelta(this.value);
|
|
48146
48467
|
this.quill.setContents(ops);
|
|
@@ -48152,11 +48473,15 @@ const RichtextMixin = {
|
|
|
48152
48473
|
if (nextProcessor) nextProcessor(value, listCallbacks);
|
|
48153
48474
|
},
|
|
48154
48475
|
isRequired() {
|
|
48155
|
-
return Array.from(this.element.attributes).some(
|
|
48476
|
+
return Array.from(this.element.attributes).some(
|
|
48477
|
+
(attr) => attr.name === "required"
|
|
48478
|
+
);
|
|
48156
48479
|
},
|
|
48157
48480
|
createHiddenRequiredInput() {
|
|
48158
48481
|
const attributeName = this.getAttributeValue("name");
|
|
48159
|
-
this.hiddenInput = document.querySelector(
|
|
48482
|
+
this.hiddenInput = document.querySelector(
|
|
48483
|
+
`input[name="${attributeName + "-hidden"}"]`
|
|
48484
|
+
);
|
|
48160
48485
|
if (!this.hiddenInput) {
|
|
48161
48486
|
this.hiddenInput = this.createHiddenInput(attributeName + "-hidden");
|
|
48162
48487
|
this.element.appendChild(this.hiddenInput);
|
|
@@ -48174,13 +48499,17 @@ const RichtextMixin = {
|
|
|
48174
48499
|
return input;
|
|
48175
48500
|
},
|
|
48176
48501
|
getAttributeValue(attributeName) {
|
|
48177
|
-
const attribute2 = Array.from(this.element.attributes).find(
|
|
48502
|
+
const attribute2 = Array.from(this.element.attributes).find(
|
|
48503
|
+
(attr) => attr.name === attributeName
|
|
48504
|
+
);
|
|
48178
48505
|
return attribute2 ? attribute2.value : "";
|
|
48179
48506
|
},
|
|
48180
48507
|
displayCustomErrorMessage(message) {
|
|
48181
48508
|
const richtext = this.element.querySelector("[data-richtext]");
|
|
48182
48509
|
if (richtext) {
|
|
48183
|
-
let errorMessageElement = richtext.querySelector(
|
|
48510
|
+
let errorMessageElement = richtext.querySelector(
|
|
48511
|
+
".required-error-message"
|
|
48512
|
+
);
|
|
48184
48513
|
if (!errorMessageElement) {
|
|
48185
48514
|
errorMessageElement = document.createElement("div");
|
|
48186
48515
|
errorMessageElement.className = "required-error-message";
|
|
@@ -48202,9 +48531,10 @@ const RichtextMixin = {
|
|
|
48202
48531
|
},
|
|
48203
48532
|
removeErrorMessageAndStyling() {
|
|
48204
48533
|
const richtext = this.element.querySelector("[data-richtext]");
|
|
48205
|
-
let errorMessageElement = richtext.querySelector(
|
|
48206
|
-
|
|
48207
|
-
|
|
48534
|
+
let errorMessageElement = richtext.querySelector(
|
|
48535
|
+
".required-error-message"
|
|
48536
|
+
);
|
|
48537
|
+
if (errorMessageElement) errorMessageElement.remove();
|
|
48208
48538
|
richtext.classList.remove("error-border-richtext");
|
|
48209
48539
|
}
|
|
48210
48540
|
};
|
|
@@ -48314,7 +48644,8 @@ const WidgetMixin = {
|
|
|
48314
48644
|
this.nameWidgets = [];
|
|
48315
48645
|
},
|
|
48316
48646
|
attached() {
|
|
48317
|
-
if (!this.dataSrc && !this.resource && this.noRender === null)
|
|
48647
|
+
if (!this.dataSrc && !this.resource && this.noRender === null)
|
|
48648
|
+
this.populate();
|
|
48318
48649
|
},
|
|
48319
48650
|
get parentElement() {
|
|
48320
48651
|
return "div";
|
|
@@ -48329,7 +48660,9 @@ const WidgetMixin = {
|
|
|
48329
48660
|
this._div = value;
|
|
48330
48661
|
},
|
|
48331
48662
|
get widgets() {
|
|
48332
|
-
return this.nameWidgets.map(
|
|
48663
|
+
return this.nameWidgets.map(
|
|
48664
|
+
(name) => this.element.querySelector(`[name="${name}"]`)
|
|
48665
|
+
);
|
|
48333
48666
|
},
|
|
48334
48667
|
/**
|
|
48335
48668
|
* Return field list of the component
|
|
@@ -48351,7 +48684,8 @@ const WidgetMixin = {
|
|
|
48351
48684
|
break;
|
|
48352
48685
|
}
|
|
48353
48686
|
}
|
|
48354
|
-
if (!this.dataSrc)
|
|
48687
|
+
if (!this.dataSrc)
|
|
48688
|
+
console.error(new Error('You must provide a "fields" attribute'));
|
|
48355
48689
|
if (!resource) return [];
|
|
48356
48690
|
let fields = [];
|
|
48357
48691
|
for (const prop2 of resource.properties) {
|
|
@@ -48392,7 +48726,10 @@ const WidgetMixin = {
|
|
|
48392
48726
|
const setString = this.fields.match(this.getSetRegexp(field));
|
|
48393
48727
|
if (!setString) return [];
|
|
48394
48728
|
const firstSetBracket = this.fields.indexOf(setString[0]) + setString[0].length - 1;
|
|
48395
|
-
const lastSetBracket = findClosingBracketMatchIndex(
|
|
48729
|
+
const lastSetBracket = findClosingBracketMatchIndex(
|
|
48730
|
+
this.fields,
|
|
48731
|
+
firstSetBracket
|
|
48732
|
+
);
|
|
48396
48733
|
const set2 = this.fields.substring(firstSetBracket + 1, lastSetBracket);
|
|
48397
48734
|
return parseFieldsString(set2);
|
|
48398
48735
|
},
|
|
@@ -48430,10 +48767,14 @@ const WidgetMixin = {
|
|
|
48430
48767
|
if (resource && !((_a3 = resource.isContainer) == null ? void 0 : _a3.call(resource))) {
|
|
48431
48768
|
let fieldValue = await resource[field];
|
|
48432
48769
|
if (fieldValue === null || fieldValue === void 0 || fieldValue === "") {
|
|
48433
|
-
let expandedPredicate = sibStore.getExpandedPredicate(
|
|
48770
|
+
let expandedPredicate = sibStore.getExpandedPredicate(
|
|
48771
|
+
field,
|
|
48772
|
+
this.context
|
|
48773
|
+
);
|
|
48434
48774
|
fieldValue = await resource[expandedPredicate];
|
|
48435
48775
|
}
|
|
48436
|
-
if (fieldValue === null || fieldValue === void 0 || fieldValue === "")
|
|
48776
|
+
if (fieldValue === null || fieldValue === void 0 || fieldValue === "")
|
|
48777
|
+
return void 0;
|
|
48437
48778
|
if (Array.isArray(fieldValue) && !fieldValue["ldp:contains"]) {
|
|
48438
48779
|
return JSON.stringify(fieldValue);
|
|
48439
48780
|
} else if (typeof fieldValue === "object" && fieldValue["@id"] && 1 === Object.keys(fieldValue).length) {
|
|
@@ -48472,7 +48813,8 @@ const WidgetMixin = {
|
|
|
48472
48813
|
widgetFromTagName(tagName) {
|
|
48473
48814
|
let type = tagName.startsWith("solid") ? WidgetType.CUSTOM : WidgetType.USER;
|
|
48474
48815
|
if (!customElements.get(tagName)) {
|
|
48475
|
-
if (tagName.startsWith("solid"))
|
|
48816
|
+
if (tagName.startsWith("solid"))
|
|
48817
|
+
newWidgetFactory(tagName);
|
|
48476
48818
|
else type = WidgetType.NATIVE;
|
|
48477
48819
|
}
|
|
48478
48820
|
return { tagName, type };
|
|
@@ -48530,7 +48872,8 @@ const WidgetMixin = {
|
|
|
48530
48872
|
"add-class",
|
|
48531
48873
|
"remove-class"
|
|
48532
48874
|
];
|
|
48533
|
-
for (let attr of multipleAttributes)
|
|
48875
|
+
for (let attr of multipleAttributes)
|
|
48876
|
+
this.addToAttributes(`multiple-${escapedField}-${attr}`, attr, attrs2);
|
|
48534
48877
|
const defaultAttributes = [
|
|
48535
48878
|
"range",
|
|
48536
48879
|
"enum",
|
|
@@ -48538,6 +48881,7 @@ const WidgetMixin = {
|
|
|
48538
48881
|
"placeholder",
|
|
48539
48882
|
"class",
|
|
48540
48883
|
,
|
|
48884
|
+
/* 'widget', */
|
|
48541
48885
|
"required",
|
|
48542
48886
|
"editable",
|
|
48543
48887
|
"autocomplete",
|
|
@@ -48565,13 +48909,22 @@ const WidgetMixin = {
|
|
|
48565
48909
|
"target-src",
|
|
48566
48910
|
"data-label"
|
|
48567
48911
|
];
|
|
48568
|
-
for (let attr of defaultAttributes)
|
|
48912
|
+
for (let attr of defaultAttributes)
|
|
48913
|
+
this.addToAttributes(`${attr}-${escapedField}`, attr, attrs2);
|
|
48569
48914
|
const addableAttributes = Array.from(this.element.attributes).filter((a2) => a2.name.startsWith(`addable-${escapedField}`));
|
|
48570
|
-
for (let attr of addableAttributes)
|
|
48915
|
+
for (let attr of addableAttributes)
|
|
48916
|
+
this.addToAttributes(
|
|
48917
|
+
attr.name,
|
|
48918
|
+
attr.name.replace(`addable-${escapedField}`, "addable"),
|
|
48919
|
+
attrs2
|
|
48920
|
+
);
|
|
48571
48921
|
const resourceId = resource ? resource["@id"] : null;
|
|
48572
|
-
if (this.multiple(escapedField))
|
|
48573
|
-
|
|
48574
|
-
if (this.
|
|
48922
|
+
if (this.multiple(escapedField))
|
|
48923
|
+
attrs2["widget"] = this.getWidget(escapedField).tagName;
|
|
48924
|
+
if (this.getAction(escapedField) && resourceId)
|
|
48925
|
+
attrs2["src"] = this.element.getAttribute("src-" + escapedField) || resourceId;
|
|
48926
|
+
if (this.editable(escapedField) && resourceId)
|
|
48927
|
+
attrs2["value-id"] = resourceId;
|
|
48575
48928
|
return attrs2;
|
|
48576
48929
|
},
|
|
48577
48930
|
/**
|
|
@@ -48610,7 +48963,11 @@ const WidgetMixin = {
|
|
|
48610
48963
|
attributes["value"] = value;
|
|
48611
48964
|
}
|
|
48612
48965
|
if (value && value["@id"]) attributes["auto-subscribe"] = value["@id"];
|
|
48613
|
-
if (transformAttributes)
|
|
48966
|
+
if (transformAttributes)
|
|
48967
|
+
attributes = await this.transformAttributes(
|
|
48968
|
+
attributes,
|
|
48969
|
+
currentResource
|
|
48970
|
+
);
|
|
48614
48971
|
widgetTemplate = preHTML`<${tagName} ...=${spread(attributes)}></${tagName}>`;
|
|
48615
48972
|
}
|
|
48616
48973
|
this.nameWidgets.push(field);
|
|
@@ -48628,12 +48985,12 @@ const WidgetMixin = {
|
|
|
48628
48985
|
async createSet(field) {
|
|
48629
48986
|
const setWidget = this.getWidget(field, true);
|
|
48630
48987
|
const attrs2 = { name: field };
|
|
48631
|
-
const setAttributes = [
|
|
48632
|
-
|
|
48633
|
-
|
|
48634
|
-
|
|
48635
|
-
|
|
48636
|
-
|
|
48988
|
+
const setAttributes = ["class", "label"];
|
|
48989
|
+
for (let attr of setAttributes)
|
|
48990
|
+
this.addToAttributes(`${attr}-${field}`, attr, attrs2);
|
|
48991
|
+
let widget = this.element.querySelector(
|
|
48992
|
+
`${setWidget.tagName}[name="${field}"]`
|
|
48993
|
+
);
|
|
48637
48994
|
let initializing = false;
|
|
48638
48995
|
if (!widget) {
|
|
48639
48996
|
widget = document.createElement(setWidget.tagName);
|
|
@@ -48661,7 +49018,9 @@ const WidgetMixin = {
|
|
|
48661
49018
|
return preHTML`<${tagName} ...=${spread(attributes)}></${tagName}>`;
|
|
48662
49019
|
}
|
|
48663
49020
|
}
|
|
48664
|
-
const widgetsTemplate = await Promise.all(
|
|
49021
|
+
const widgetsTemplate = await Promise.all(
|
|
49022
|
+
setFields.map((field2) => this.createWidgetTemplate(field2))
|
|
49023
|
+
);
|
|
48665
49024
|
const template = x`${widgetsTemplate}`;
|
|
48666
49025
|
B(template, widget.querySelector("[data-content]") || widget);
|
|
48667
49026
|
return widget;
|
|
@@ -48727,8 +49086,14 @@ const ListMixin = {
|
|
|
48727
49086
|
if ((_d = (_c = this.resource).isContainer) == null ? void 0 : _d.call(_c)) {
|
|
48728
49087
|
this.setElementAttribute("container");
|
|
48729
49088
|
this.renderCallbacks = [];
|
|
48730
|
-
listPostProcessorsCopy.attach(
|
|
48731
|
-
|
|
49089
|
+
listPostProcessorsCopy.attach(
|
|
49090
|
+
this.renderDOM.bind(this),
|
|
49091
|
+
"ListMixin:renderDOM"
|
|
49092
|
+
);
|
|
49093
|
+
listPostProcessorsCopy.attach(
|
|
49094
|
+
this.handleEmptyWidget.bind(this),
|
|
49095
|
+
"ListMixin:handleEmptyWidget"
|
|
49096
|
+
);
|
|
48732
49097
|
const nextProcessor = listPostProcessorsCopy.shift();
|
|
48733
49098
|
await nextProcessor(
|
|
48734
49099
|
this.resource["ldp:contains"],
|
|
@@ -48739,8 +49104,14 @@ const ListMixin = {
|
|
|
48739
49104
|
} else if (this.arrayField && this.predicateName && this.resource[this.predicateName]) {
|
|
48740
49105
|
this.setElementAttribute("container");
|
|
48741
49106
|
this.renderCallbacks = [];
|
|
48742
|
-
listPostProcessorsCopy.attach(
|
|
48743
|
-
|
|
49107
|
+
listPostProcessorsCopy.attach(
|
|
49108
|
+
this.renderDOM.bind(this),
|
|
49109
|
+
"ListMixin:renderDOM"
|
|
49110
|
+
);
|
|
49111
|
+
listPostProcessorsCopy.attach(
|
|
49112
|
+
this.handleEmptyWidget.bind(this),
|
|
49113
|
+
"ListMixin:handleEmptyWidget"
|
|
49114
|
+
);
|
|
48744
49115
|
const nextProcessor = listPostProcessorsCopy.shift();
|
|
48745
49116
|
await nextProcessor(
|
|
48746
49117
|
await this.resource[this.predicateName],
|
|
@@ -48767,12 +49138,7 @@ const ListMixin = {
|
|
|
48767
49138
|
}
|
|
48768
49139
|
const nextProcessor = listPostProcessors.shift();
|
|
48769
49140
|
if (nextProcessor)
|
|
48770
|
-
await nextProcessor(
|
|
48771
|
-
resources,
|
|
48772
|
-
listPostProcessors,
|
|
48773
|
-
div2,
|
|
48774
|
-
context2
|
|
48775
|
-
);
|
|
49141
|
+
await nextProcessor(resources, listPostProcessors, div2, context2);
|
|
48776
49142
|
},
|
|
48777
49143
|
/**
|
|
48778
49144
|
* Show empty widget if no resources in the list
|
|
@@ -48788,16 +49154,14 @@ const ListMixin = {
|
|
|
48788
49154
|
this.emptyWrapper = document.createElement("span");
|
|
48789
49155
|
this.element.appendChild(this.emptyWrapper);
|
|
48790
49156
|
}
|
|
48791
|
-
B(
|
|
49157
|
+
B(
|
|
49158
|
+
resources.length > 0 ? x`` : emptyWidgetTemplate,
|
|
49159
|
+
this.emptyWrapper
|
|
49160
|
+
);
|
|
48792
49161
|
}
|
|
48793
49162
|
const nextProcessor = listPostProcessors.shift();
|
|
48794
49163
|
if (nextProcessor)
|
|
48795
|
-
await nextProcessor(
|
|
48796
|
-
resources,
|
|
48797
|
-
listPostProcessors,
|
|
48798
|
-
div2,
|
|
48799
|
-
context2
|
|
48800
|
-
);
|
|
49164
|
+
await nextProcessor(resources, listPostProcessors, div2, context2);
|
|
48801
49165
|
}
|
|
48802
49166
|
};
|
|
48803
49167
|
const PaginateMixin = {
|
|
@@ -48820,21 +49184,32 @@ const PaginateMixin = {
|
|
|
48820
49184
|
this.currentPage = [];
|
|
48821
49185
|
},
|
|
48822
49186
|
attached() {
|
|
48823
|
-
this.listPostProcessors.attach(
|
|
49187
|
+
this.listPostProcessors.attach(
|
|
49188
|
+
this.paginateCallback.bind(this),
|
|
49189
|
+
"PaginateMixin:paginateCallback"
|
|
49190
|
+
);
|
|
48824
49191
|
},
|
|
48825
49192
|
async paginateCallback(resources, listPostProcessors, div2, context2) {
|
|
48826
49193
|
if (this.paginateBy > 0) {
|
|
48827
49194
|
if (!this.currentPage[context2]) this.currentPage[context2] = 1;
|
|
48828
49195
|
const parentDiv = this.initParentPaginationDiv(div2, context2);
|
|
48829
49196
|
this.renderCallbacks.push({
|
|
48830
|
-
template: this.renderPaginationNav(
|
|
49197
|
+
template: this.renderPaginationNav(
|
|
49198
|
+
this.getPageCount(resources.length),
|
|
49199
|
+
context2,
|
|
49200
|
+
div2
|
|
49201
|
+
),
|
|
48831
49202
|
parent: parentDiv
|
|
48832
49203
|
});
|
|
48833
49204
|
const firstElementIndex = (this.getCurrentPage(context2) - 1) * this.paginateBy;
|
|
48834
|
-
resources = resources.slice(
|
|
49205
|
+
resources = resources.slice(
|
|
49206
|
+
firstElementIndex,
|
|
49207
|
+
firstElementIndex + this.paginateBy
|
|
49208
|
+
);
|
|
48835
49209
|
}
|
|
48836
49210
|
const nextProcessor = listPostProcessors.shift();
|
|
48837
|
-
if (nextProcessor)
|
|
49211
|
+
if (nextProcessor)
|
|
49212
|
+
await nextProcessor(resources, listPostProcessors, div2, context2);
|
|
48838
49213
|
},
|
|
48839
49214
|
getNavElement(div2) {
|
|
48840
49215
|
const insertNode = div2.parentNode || div2;
|
|
@@ -49022,18 +49397,20 @@ const matchFilter = async (resource, filter, query, fieldsAttr, searchForm, filt
|
|
|
49022
49397
|
return matchValue(resource[filter], query, throwOn);
|
|
49023
49398
|
}
|
|
49024
49399
|
try {
|
|
49025
|
-
await Promise.all(
|
|
49026
|
-
(
|
|
49027
|
-
|
|
49028
|
-
|
|
49029
|
-
|
|
49030
|
-
|
|
49031
|
-
|
|
49032
|
-
|
|
49033
|
-
|
|
49034
|
-
|
|
49400
|
+
await Promise.all(
|
|
49401
|
+
(fields || []).map(
|
|
49402
|
+
(field) => matchFilter(
|
|
49403
|
+
resource,
|
|
49404
|
+
field,
|
|
49405
|
+
query,
|
|
49406
|
+
fieldsAttr,
|
|
49407
|
+
searchForm,
|
|
49408
|
+
filterId,
|
|
49409
|
+
true
|
|
49410
|
+
// stop searching when 1 filter is true (= OR)
|
|
49411
|
+
)
|
|
49035
49412
|
)
|
|
49036
|
-
)
|
|
49413
|
+
);
|
|
49037
49414
|
} catch (e2) {
|
|
49038
49415
|
return true;
|
|
49039
49416
|
}
|
|
@@ -49041,19 +49418,21 @@ const matchFilter = async (resource, filter, query, fieldsAttr, searchForm, filt
|
|
|
49041
49418
|
};
|
|
49042
49419
|
const matchFilters = async (resource, filters, filterNames, fields, searchForm, filterId) => {
|
|
49043
49420
|
try {
|
|
49044
|
-
await Promise.all(
|
|
49045
|
-
|
|
49046
|
-
|
|
49047
|
-
|
|
49048
|
-
|
|
49049
|
-
|
|
49050
|
-
|
|
49051
|
-
|
|
49052
|
-
|
|
49053
|
-
|
|
49054
|
-
|
|
49055
|
-
|
|
49056
|
-
|
|
49421
|
+
await Promise.all(
|
|
49422
|
+
filterNames.map(async (filter) => {
|
|
49423
|
+
let match3 = await matchFilter(
|
|
49424
|
+
resource,
|
|
49425
|
+
filter,
|
|
49426
|
+
filters[filter],
|
|
49427
|
+
fields,
|
|
49428
|
+
searchForm,
|
|
49429
|
+
filterId,
|
|
49430
|
+
false
|
|
49431
|
+
// stop searching when 1 filter is false (= AND)
|
|
49432
|
+
);
|
|
49433
|
+
return match3;
|
|
49434
|
+
})
|
|
49435
|
+
);
|
|
49057
49436
|
} catch (e2) {
|
|
49058
49437
|
return false;
|
|
49059
49438
|
}
|
|
@@ -49063,17 +49442,19 @@ const searchInResources = async (resources, filters, fields, searchForm) => {
|
|
|
49063
49442
|
const filterNames = Object.keys(filters);
|
|
49064
49443
|
const filterId = uniqID();
|
|
49065
49444
|
window.cachePropsSearchFilter = {};
|
|
49066
|
-
return Promise.all(
|
|
49067
|
-
|
|
49068
|
-
|
|
49069
|
-
|
|
49070
|
-
|
|
49071
|
-
|
|
49072
|
-
|
|
49073
|
-
|
|
49074
|
-
|
|
49075
|
-
|
|
49076
|
-
|
|
49445
|
+
return Promise.all(
|
|
49446
|
+
resources.map(async (resource) => {
|
|
49447
|
+
let match3 = await matchFilters(
|
|
49448
|
+
resource,
|
|
49449
|
+
filters,
|
|
49450
|
+
filterNames,
|
|
49451
|
+
fields,
|
|
49452
|
+
searchForm,
|
|
49453
|
+
filterId
|
|
49454
|
+
);
|
|
49455
|
+
return match3;
|
|
49456
|
+
})
|
|
49457
|
+
);
|
|
49077
49458
|
};
|
|
49078
49459
|
const FilterMixin = {
|
|
49079
49460
|
name: "filter-mixin",
|
|
@@ -49116,9 +49497,15 @@ const FilterMixin = {
|
|
|
49116
49497
|
if (this.isFilteredOnServer() && filteredBy) {
|
|
49117
49498
|
this.searchForm = document.getElementById(filteredBy);
|
|
49118
49499
|
if (!this.searchForm) throw `#${filteredBy} is not in DOM`;
|
|
49119
|
-
this.searchForm.addEventListener(
|
|
49500
|
+
this.searchForm.addEventListener(
|
|
49501
|
+
"formChange",
|
|
49502
|
+
() => this.onServerSearchChange()
|
|
49503
|
+
);
|
|
49120
49504
|
} else {
|
|
49121
|
-
this.listPostProcessors.attach(
|
|
49505
|
+
this.listPostProcessors.attach(
|
|
49506
|
+
this.filterCallback.bind(this),
|
|
49507
|
+
"FilterMixin:filterCallback"
|
|
49508
|
+
);
|
|
49122
49509
|
}
|
|
49123
49510
|
},
|
|
49124
49511
|
get filters() {
|
|
@@ -49164,7 +49551,13 @@ const FilterMixin = {
|
|
|
49164
49551
|
resources = resources.filter((_v, index2) => filteredResources[index2]);
|
|
49165
49552
|
}
|
|
49166
49553
|
const nextProcessor = listPostProcessors.shift();
|
|
49167
|
-
if (nextProcessor)
|
|
49554
|
+
if (nextProcessor)
|
|
49555
|
+
await nextProcessor(
|
|
49556
|
+
resources,
|
|
49557
|
+
listPostProcessors,
|
|
49558
|
+
div2,
|
|
49559
|
+
context2 + (this.searchCount.get(context2) || "")
|
|
49560
|
+
);
|
|
49168
49561
|
},
|
|
49169
49562
|
async filterList(context2) {
|
|
49170
49563
|
this.searchCount.set(context2, this.searchCount.get(context2) + 1);
|
|
@@ -49179,7 +49572,9 @@ const FilterMixin = {
|
|
|
49179
49572
|
const nextArrayOfObjects = await obj[field];
|
|
49180
49573
|
if (!nextArrayOfObjects) continue;
|
|
49181
49574
|
if (typeof nextArrayOfObjects !== "object") {
|
|
49182
|
-
console.warn(
|
|
49575
|
+
console.warn(
|
|
49576
|
+
`The format value of ${field} is not suitable with auto-range-[field] attribute`
|
|
49577
|
+
);
|
|
49183
49578
|
continue;
|
|
49184
49579
|
}
|
|
49185
49580
|
if (!nextArrayOfObjects.isContainer()) {
|
|
@@ -49232,7 +49627,10 @@ const CounterMixin = {
|
|
|
49232
49627
|
parentCounterDiv: null
|
|
49233
49628
|
},
|
|
49234
49629
|
attached() {
|
|
49235
|
-
this.listPostProcessors.attach(
|
|
49630
|
+
this.listPostProcessors.attach(
|
|
49631
|
+
this.countResources.bind(this),
|
|
49632
|
+
"CounterMixin:countResources"
|
|
49633
|
+
);
|
|
49236
49634
|
},
|
|
49237
49635
|
async countResources(resources, listPostProcessors, div2, context2) {
|
|
49238
49636
|
if (this.counterTemplate) {
|
|
@@ -49244,7 +49642,8 @@ const CounterMixin = {
|
|
|
49244
49642
|
});
|
|
49245
49643
|
}
|
|
49246
49644
|
const nextProcessor = listPostProcessors.shift();
|
|
49247
|
-
if (nextProcessor)
|
|
49645
|
+
if (nextProcessor)
|
|
49646
|
+
await nextProcessor(resources, listPostProcessors, div2, context2);
|
|
49248
49647
|
},
|
|
49249
49648
|
/**
|
|
49250
49649
|
* Create the parent div of the counter in the component.
|
|
@@ -49294,7 +49693,10 @@ const GrouperMixin = {
|
|
|
49294
49693
|
}
|
|
49295
49694
|
},
|
|
49296
49695
|
attached() {
|
|
49297
|
-
this.listPostProcessors.attach(
|
|
49696
|
+
this.listPostProcessors.attach(
|
|
49697
|
+
this.groupResources.bind(this),
|
|
49698
|
+
"GrouperMixin:groupResources"
|
|
49699
|
+
);
|
|
49298
49700
|
},
|
|
49299
49701
|
async groupResources(resources, listPostProcessors, div2, context2) {
|
|
49300
49702
|
const nextProcessor = listPostProcessors.shift();
|
|
@@ -49313,25 +49715,25 @@ const GrouperMixin = {
|
|
|
49313
49715
|
return generalComparator(a2, b2, order2);
|
|
49314
49716
|
});
|
|
49315
49717
|
}
|
|
49316
|
-
const parents = sortedKeys.map((g2) => ({
|
|
49718
|
+
const parents = sortedKeys.map((g2) => ({
|
|
49719
|
+
group: g2,
|
|
49720
|
+
parent: this.renderGroup(g2, div2)
|
|
49721
|
+
}));
|
|
49317
49722
|
for (let { group, parent } of parents) {
|
|
49318
|
-
if (nextProcessor)
|
|
49319
|
-
|
|
49320
|
-
|
|
49321
|
-
|
|
49322
|
-
|
|
49323
|
-
|
|
49324
|
-
|
|
49325
|
-
|
|
49326
|
-
|
|
49723
|
+
if (nextProcessor)
|
|
49724
|
+
await nextProcessor(
|
|
49725
|
+
groups[group].resources,
|
|
49726
|
+
// give only resources from group
|
|
49727
|
+
listPostProcessors.deepCopy(),
|
|
49728
|
+
// copy post processors
|
|
49729
|
+
parent,
|
|
49730
|
+
// parent is group widget
|
|
49731
|
+
context2 + "_" + group
|
|
49732
|
+
);
|
|
49327
49733
|
}
|
|
49328
49734
|
} else {
|
|
49329
|
-
if (nextProcessor)
|
|
49330
|
-
resources,
|
|
49331
|
-
listPostProcessors,
|
|
49332
|
-
div2,
|
|
49333
|
-
context2
|
|
49334
|
-
);
|
|
49735
|
+
if (nextProcessor)
|
|
49736
|
+
await nextProcessor(resources, listPostProcessors, div2, context2);
|
|
49335
49737
|
}
|
|
49336
49738
|
},
|
|
49337
49739
|
/**
|
|
@@ -49339,7 +49741,9 @@ const GrouperMixin = {
|
|
|
49339
49741
|
* @param groupName
|
|
49340
49742
|
*/
|
|
49341
49743
|
renderGroup(groupName, div2) {
|
|
49342
|
-
let groupElt = this.element.querySelector(
|
|
49744
|
+
let groupElt = this.element.querySelector(
|
|
49745
|
+
`${this.groupWidget}[value="${groupName}"]`
|
|
49746
|
+
);
|
|
49343
49747
|
if (!groupElt) {
|
|
49344
49748
|
groupElt = document.createElement(this.groupWidget);
|
|
49345
49749
|
groupElt.setAttribute("value", groupName);
|
|
@@ -49354,24 +49758,30 @@ const HighlighterMixin = {
|
|
|
49354
49758
|
name: "highlighter-mixin",
|
|
49355
49759
|
use: [],
|
|
49356
49760
|
attached() {
|
|
49357
|
-
this.listPostProcessors.attach(
|
|
49761
|
+
this.listPostProcessors.attach(
|
|
49762
|
+
this.hightlightCallback.bind(this),
|
|
49763
|
+
"HighlighterMixin:hightlightCallback"
|
|
49764
|
+
);
|
|
49358
49765
|
},
|
|
49359
49766
|
async hightlightCallback(resources, listPostProcessors, div2, context2) {
|
|
49360
49767
|
for (let attr of this.element.attributes) {
|
|
49361
49768
|
if (attr.name.startsWith("highlight-")) {
|
|
49362
49769
|
const field = attr.name.split("highlight-")[1];
|
|
49363
|
-
resources = await Promise.all(
|
|
49364
|
-
|
|
49365
|
-
|
|
49366
|
-
|
|
49367
|
-
|
|
49368
|
-
|
|
49770
|
+
resources = await Promise.all(
|
|
49771
|
+
resources.map(async (resource) => ({
|
|
49772
|
+
sortingKey: await resource[field],
|
|
49773
|
+
// fetch sorting value
|
|
49774
|
+
proxy: resource
|
|
49775
|
+
// and keep proxy
|
|
49776
|
+
}))
|
|
49777
|
+
);
|
|
49369
49778
|
resources = this.sortHighlighted(resources, "sortingKey", attr.value);
|
|
49370
49779
|
resources = resources.map((resource) => resource.proxy);
|
|
49371
49780
|
}
|
|
49372
49781
|
}
|
|
49373
49782
|
const nextProcessor = listPostProcessors.shift();
|
|
49374
|
-
if (nextProcessor)
|
|
49783
|
+
if (nextProcessor)
|
|
49784
|
+
await nextProcessor(resources, listPostProcessors, div2, context2);
|
|
49375
49785
|
},
|
|
49376
49786
|
sortHighlighted(resources, field, value) {
|
|
49377
49787
|
for (let [index2, res] of resources.entries()) {
|
|
@@ -49407,7 +49817,10 @@ const RequiredMixin = {
|
|
|
49407
49817
|
name: "required-mixin",
|
|
49408
49818
|
use: [],
|
|
49409
49819
|
attached() {
|
|
49410
|
-
this.listPostProcessors.attach(
|
|
49820
|
+
this.listPostProcessors.attach(
|
|
49821
|
+
this.requiredResources.bind(this),
|
|
49822
|
+
"RequiredMixin:requiredResources"
|
|
49823
|
+
);
|
|
49411
49824
|
},
|
|
49412
49825
|
async requiredResources(resources, listPostProcessors, div2, context2) {
|
|
49413
49826
|
const displays = [];
|
|
@@ -49428,7 +49841,13 @@ const RequiredMixin = {
|
|
|
49428
49841
|
}
|
|
49429
49842
|
}
|
|
49430
49843
|
const nextProcessor = listPostProcessors.shift();
|
|
49431
|
-
if (nextProcessor)
|
|
49844
|
+
if (nextProcessor)
|
|
49845
|
+
await nextProcessor(
|
|
49846
|
+
requiredFields.length ? displays : resources,
|
|
49847
|
+
listPostProcessors,
|
|
49848
|
+
div2,
|
|
49849
|
+
context2
|
|
49850
|
+
);
|
|
49432
49851
|
}
|
|
49433
49852
|
};
|
|
49434
49853
|
const SolidDisplay = {
|
|
@@ -49466,7 +49885,8 @@ const SolidDisplay = {
|
|
|
49466
49885
|
},
|
|
49467
49886
|
detached() {
|
|
49468
49887
|
if (this.activeSubscription) PubSub.unsubscribe(this.activeSubscription);
|
|
49469
|
-
if (this.removeActiveSubscription)
|
|
49888
|
+
if (this.removeActiveSubscription)
|
|
49889
|
+
PubSub.unsubscribe(this.removeActiveSubscription);
|
|
49470
49890
|
},
|
|
49471
49891
|
// Update subscription when id changes
|
|
49472
49892
|
updateNavigateSubscription() {
|
|
@@ -49558,12 +49978,7 @@ const SolidDisplay = {
|
|
|
49558
49978
|
B(template, div2);
|
|
49559
49979
|
const nextProcessor = listPostProcessors.shift();
|
|
49560
49980
|
if (nextProcessor)
|
|
49561
|
-
await nextProcessor(
|
|
49562
|
-
resources,
|
|
49563
|
-
listPostProcessors,
|
|
49564
|
-
div2,
|
|
49565
|
-
context2
|
|
49566
|
-
);
|
|
49981
|
+
await nextProcessor(resources, listPostProcessors, div2, context2);
|
|
49567
49982
|
}, "SolidDisplay:renderDom"),
|
|
49568
49983
|
/**
|
|
49569
49984
|
* Get attributes to dispatch to children from current element
|
|
@@ -50266,8 +50681,10 @@ const ValidationMixin = {
|
|
|
50266
50681
|
return dialog.showModal();
|
|
50267
50682
|
},
|
|
50268
50683
|
performAction() {
|
|
50269
|
-
if (this.element.hasAttribute("confirmation-message") && !this.confirmationType)
|
|
50270
|
-
|
|
50684
|
+
if (this.element.hasAttribute("confirmation-message") && !this.confirmationType)
|
|
50685
|
+
console.warn("confirmation-type attribute is missing.");
|
|
50686
|
+
if (!this.confirmationType || this.confirmationType == "confirm" && confirm(this.confirmationMessage || this.t("validation.message")))
|
|
50687
|
+
this.validateModal();
|
|
50271
50688
|
if (this.confirmationType == "dialog") {
|
|
50272
50689
|
this.showModal();
|
|
50273
50690
|
}
|
|
@@ -50363,7 +50780,8 @@ const SolidForm = {
|
|
|
50363
50780
|
}
|
|
50364
50781
|
setDeepProperty(values, name.split("."), value);
|
|
50365
50782
|
});
|
|
50366
|
-
if (this.resource && !((_b = (_a3 = this.resource).isContainer) == null ? void 0 : _b.call(_a3)))
|
|
50783
|
+
if (this.resource && !((_b = (_a3 = this.resource).isContainer) == null ? void 0 : _b.call(_a3)))
|
|
50784
|
+
values["@id"] = this.resourceId;
|
|
50367
50785
|
return values;
|
|
50368
50786
|
},
|
|
50369
50787
|
get isNaked() {
|
|
@@ -50384,7 +50802,8 @@ const SolidForm = {
|
|
|
50384
50802
|
if (!object) {
|
|
50385
50803
|
object = await this.resource[store.getExpandedPredicate(predicate, this.context)];
|
|
50386
50804
|
}
|
|
50387
|
-
if (object && object["@id"] && !value[predicate]["@id"])
|
|
50805
|
+
if (object && object["@id"] && !value[predicate]["@id"])
|
|
50806
|
+
value[predicate]["@id"] = object["@id"];
|
|
50388
50807
|
if (object && !object["@id"] && Array.isArray(object) && value[predicate].length == 0 && object.length > 0) {
|
|
50389
50808
|
value[predicate] = object;
|
|
50390
50809
|
}
|
|
@@ -50467,10 +50886,13 @@ const SolidForm = {
|
|
|
50467
50886
|
let errorNextName = Object.values(member)[0];
|
|
50468
50887
|
let subErrorName = errorFullName === "" ? errorNextName : errorFullName.concat("." + errorNextName);
|
|
50469
50888
|
let errorFieldName = "";
|
|
50470
|
-
if (errorFullName)
|
|
50889
|
+
if (errorFullName)
|
|
50890
|
+
errorFieldName = errorFullName.concat("." + errorNextName);
|
|
50471
50891
|
else errorFieldName = errorNextName;
|
|
50472
50892
|
if (errorFieldName) {
|
|
50473
|
-
let formField = this.element.querySelector(
|
|
50893
|
+
let formField = this.element.querySelector(
|
|
50894
|
+
`[name="${errorFieldName}"]`
|
|
50895
|
+
);
|
|
50474
50896
|
if (formField) {
|
|
50475
50897
|
formField.classList.add("error");
|
|
50476
50898
|
let errorParagraph = document.createElement("p");
|
|
@@ -50481,7 +50903,9 @@ const SolidForm = {
|
|
|
50481
50903
|
errorParagraph.appendChild(errorText);
|
|
50482
50904
|
});
|
|
50483
50905
|
} else if (typeof Object.values(member)[1] === "object") {
|
|
50484
|
-
for (const [key, value] of Object.entries(
|
|
50906
|
+
for (const [key, value] of Object.entries(
|
|
50907
|
+
Object.values(member)[1]
|
|
50908
|
+
)) {
|
|
50485
50909
|
if (Array.isArray(value)) {
|
|
50486
50910
|
value.forEach((error2) => {
|
|
50487
50911
|
let errorText = document.createElement("p");
|
|
@@ -50511,7 +50935,9 @@ const SolidForm = {
|
|
|
50511
50935
|
empty() {
|
|
50512
50936
|
},
|
|
50513
50937
|
showError(e2) {
|
|
50514
|
-
let errors2 = Object.entries(e2).filter(
|
|
50938
|
+
let errors2 = Object.entries(e2).filter(
|
|
50939
|
+
(field) => !field[0].startsWith("@context")
|
|
50940
|
+
);
|
|
50515
50941
|
this.displayErrorMessage(errors2);
|
|
50516
50942
|
const errorTemplate = x`<p>${this.t("solid-form.validation-error")}</p>`;
|
|
50517
50943
|
const parentElement = this.element.querySelector("[data-id=error]");
|
|
@@ -50521,7 +50947,8 @@ const SolidForm = {
|
|
|
50521
50947
|
let formErrors = this.element.querySelectorAll(".error-message");
|
|
50522
50948
|
if (formErrors) formErrors.forEach((error2) => error2.remove());
|
|
50523
50949
|
let errorFields = this.element.querySelectorAll(".error");
|
|
50524
|
-
if (errorFields)
|
|
50950
|
+
if (errorFields)
|
|
50951
|
+
errorFields.forEach((errorField) => errorField.classList.remove("error"));
|
|
50525
50952
|
const parentElement = this.element.querySelector("[data-id=error]");
|
|
50526
50953
|
if (parentElement) B("", parentElement);
|
|
50527
50954
|
},
|
|
@@ -50547,13 +50974,14 @@ const SolidForm = {
|
|
|
50547
50974
|
</div>
|
|
50548
50975
|
`;
|
|
50549
50976
|
},
|
|
50550
|
-
populate: trackRenderAsync(
|
|
50551
|
-
|
|
50552
|
-
|
|
50553
|
-
|
|
50554
|
-
|
|
50555
|
-
|
|
50556
|
-
|
|
50977
|
+
populate: trackRenderAsync(async function() {
|
|
50978
|
+
this.element.oninput = () => this.onInput();
|
|
50979
|
+
this.element.onchange = () => this.onChange();
|
|
50980
|
+
const fields = await this.getFields();
|
|
50981
|
+
const widgetTemplates = await Promise.all(
|
|
50982
|
+
fields.map((field) => this.createWidgetTemplate(field))
|
|
50983
|
+
);
|
|
50984
|
+
const template = x`
|
|
50557
50985
|
<div data-id="error"></div>
|
|
50558
50986
|
${!this.isNaked ? x`
|
|
50559
50987
|
<form
|
|
@@ -50567,10 +50995,8 @@ const SolidForm = {
|
|
|
50567
50995
|
` : x`${widgetTemplates}`}
|
|
50568
50996
|
${this.getModalDialog()}
|
|
50569
50997
|
`;
|
|
50570
|
-
|
|
50571
|
-
|
|
50572
|
-
"SolidForm:populate"
|
|
50573
|
-
)
|
|
50998
|
+
B(template, this.element);
|
|
50999
|
+
}, "SolidForm:populate")
|
|
50574
51000
|
};
|
|
50575
51001
|
Sib.register(SolidForm);
|
|
50576
51002
|
const SolidFormSearch = {
|
|
@@ -50685,7 +51111,9 @@ const SolidFormSearch = {
|
|
|
50685
51111
|
}
|
|
50686
51112
|
const idField = `${this.rangeId}_${fieldName}`;
|
|
50687
51113
|
const id2 = `store://local.${idField}`;
|
|
50688
|
-
const ldpContains = Array.from(autoRangeValues).map((id22) => ({
|
|
51114
|
+
const ldpContains = Array.from(autoRangeValues).map((id22) => ({
|
|
51115
|
+
"@id": id22
|
|
51116
|
+
}));
|
|
50689
51117
|
const data = {
|
|
50690
51118
|
"@type": "ldp:Container",
|
|
50691
51119
|
"@context": this.context,
|
|
@@ -50719,23 +51147,17 @@ const SolidFormSearch = {
|
|
|
50719
51147
|
let parentElementLabel = (_a3 = input == null ? void 0 : input.parentElement) == null ? void 0 : _a3.getAttribute("label");
|
|
50720
51148
|
try {
|
|
50721
51149
|
const selectedLabel = (_b = input.selectedOptions[0].textContent) == null ? void 0 : _b.trim();
|
|
50722
|
-
this.change(
|
|
50723
|
-
|
|
50724
|
-
|
|
50725
|
-
|
|
50726
|
-
|
|
50727
|
-
type: "select"
|
|
50728
|
-
}
|
|
50729
|
-
);
|
|
51150
|
+
this.change(this.value, {
|
|
51151
|
+
value: selectedLabel,
|
|
51152
|
+
inputLabel: parentElementLabel,
|
|
51153
|
+
type: "select"
|
|
51154
|
+
});
|
|
50730
51155
|
} catch {
|
|
50731
|
-
this.change(
|
|
50732
|
-
|
|
50733
|
-
|
|
50734
|
-
|
|
50735
|
-
|
|
50736
|
-
type: "input"
|
|
50737
|
-
}
|
|
50738
|
-
);
|
|
51156
|
+
this.change(this.value, {
|
|
51157
|
+
value: input.value,
|
|
51158
|
+
inputLabel: parentElementLabel,
|
|
51159
|
+
type: "input"
|
|
51160
|
+
});
|
|
50739
51161
|
}
|
|
50740
51162
|
},
|
|
50741
51163
|
getSubmitTemplate() {
|
|
@@ -50754,29 +51176,31 @@ const SolidFormSearch = {
|
|
|
50754
51176
|
this.inputChange(input);
|
|
50755
51177
|
}, this.debounce);
|
|
50756
51178
|
},
|
|
50757
|
-
populate: trackRenderAsync(
|
|
50758
|
-
|
|
50759
|
-
|
|
50760
|
-
|
|
50761
|
-
|
|
50762
|
-
|
|
50763
|
-
|
|
50764
|
-
|
|
50765
|
-
|
|
50766
|
-
|
|
50767
|
-
|
|
50768
|
-
|
|
50769
|
-
|
|
50770
|
-
|
|
51179
|
+
populate: trackRenderAsync(async function() {
|
|
51180
|
+
await this.replaceAttributesData();
|
|
51181
|
+
if (this.submitButton == null) {
|
|
51182
|
+
this.element.addEventListener(
|
|
51183
|
+
"input",
|
|
51184
|
+
(e2) => this.debounceInput(e2.target)
|
|
51185
|
+
);
|
|
51186
|
+
} else {
|
|
51187
|
+
this.element.addEventListener("submit", (e2) => {
|
|
51188
|
+
e2.preventDefault();
|
|
51189
|
+
this.inputChange(e2.target);
|
|
51190
|
+
});
|
|
51191
|
+
}
|
|
51192
|
+
const fields = await this.getFields();
|
|
51193
|
+
const widgetTemplates = await Promise.all(
|
|
51194
|
+
fields.map((field) => this.createWidgetTemplate(field))
|
|
51195
|
+
);
|
|
51196
|
+
const template = x`
|
|
50771
51197
|
<form>
|
|
50772
51198
|
${widgetTemplates}
|
|
50773
51199
|
${this.submitButton == null ? "" : this.getSubmitTemplate()}
|
|
50774
51200
|
</form>
|
|
50775
51201
|
`;
|
|
50776
|
-
|
|
50777
|
-
|
|
50778
|
-
"SolidFormSearch:populate"
|
|
50779
|
-
)
|
|
51202
|
+
B(template, this.element);
|
|
51203
|
+
}, "SolidFormSearch:populate")
|
|
50780
51204
|
};
|
|
50781
51205
|
Sib.register(SolidFormSearch);
|
|
50782
51206
|
const SolidWidget = {
|
|
@@ -50794,12 +51218,7 @@ const SolidWidget = {
|
|
|
50794
51218
|
const template = this.template;
|
|
50795
51219
|
const newWidget = {
|
|
50796
51220
|
name: this.name,
|
|
50797
|
-
use: [
|
|
50798
|
-
BaseWidgetMixin,
|
|
50799
|
-
StoreMixin,
|
|
50800
|
-
FormMixin,
|
|
50801
|
-
ActionMixin
|
|
50802
|
-
],
|
|
51221
|
+
use: [BaseWidgetMixin, StoreMixin, FormMixin, ActionMixin],
|
|
50803
51222
|
attributes: {
|
|
50804
51223
|
label: {
|
|
50805
51224
|
type: String,
|
|
@@ -50810,7 +51229,9 @@ const SolidWidget = {
|
|
|
50810
51229
|
}
|
|
50811
51230
|
},
|
|
50812
51231
|
get template() {
|
|
50813
|
-
return () => this.evalTemplate(template).then(
|
|
51232
|
+
return () => this.evalTemplate(template).then(
|
|
51233
|
+
(tpl) => x`${o$1(tpl)}`
|
|
51234
|
+
);
|
|
50814
51235
|
},
|
|
50815
51236
|
evalTemplate(template2) {
|
|
50816
51237
|
const tpl = evalTemplateString(template2, {
|
|
@@ -50827,7 +51248,8 @@ const SolidWidget = {
|
|
|
50827
51248
|
},
|
|
50828
51249
|
// For form widgets, handle nested solid-form
|
|
50829
51250
|
getValueFromElement(element) {
|
|
50830
|
-
if (element.tagName === "SOLID-FORM")
|
|
51251
|
+
if (element.tagName === "SOLID-FORM")
|
|
51252
|
+
return element.component.value;
|
|
50831
51253
|
else if (element.component) return element.component.getValue();
|
|
50832
51254
|
return element.value;
|
|
50833
51255
|
},
|
|
@@ -50859,28 +51281,27 @@ const SolidAcChecker = {
|
|
|
50859
51281
|
default: ""
|
|
50860
51282
|
}
|
|
50861
51283
|
},
|
|
50862
|
-
populate: trackRenderAsync(
|
|
50863
|
-
|
|
50864
|
-
|
|
50865
|
-
|
|
50866
|
-
|
|
50867
|
-
|
|
50868
|
-
|
|
50869
|
-
|
|
50870
|
-
|
|
50871
|
-
|
|
50872
|
-
|
|
50873
|
-
|
|
50874
|
-
|
|
50875
|
-
|
|
50876
|
-
|
|
50877
|
-
|
|
50878
|
-
|
|
50879
|
-
|
|
50880
|
-
|
|
50881
|
-
|
|
50882
|
-
|
|
50883
|
-
),
|
|
51284
|
+
populate: trackRenderAsync(async function() {
|
|
51285
|
+
if (!this.resource) return;
|
|
51286
|
+
let displayElement;
|
|
51287
|
+
const ContextParser3 = JSONLDContextParser.ContextParser;
|
|
51288
|
+
const permissions = await this.resource.permissions;
|
|
51289
|
+
if (this.permission) {
|
|
51290
|
+
displayElement = permissions.some((p2) => {
|
|
51291
|
+
return ContextParser3.expandTerm(p2, this.context, true) === this.permission;
|
|
51292
|
+
});
|
|
51293
|
+
} else if (this.noPermission) {
|
|
51294
|
+
displayElement = permissions.every((p2) => {
|
|
51295
|
+
return ContextParser3.expandTerm(p2, this.context, true) !== this.noPermission;
|
|
51296
|
+
});
|
|
51297
|
+
} else {
|
|
51298
|
+
console.warn(
|
|
51299
|
+
'solid-ac-checker: you should define at least one of "permission" or "no-permission" attribute.'
|
|
51300
|
+
);
|
|
51301
|
+
return;
|
|
51302
|
+
}
|
|
51303
|
+
if (displayElement) this.element.removeAttribute("hidden");
|
|
51304
|
+
}, "SolidAcChecker:populate"),
|
|
50884
51305
|
empty() {
|
|
50885
51306
|
this.element.setAttribute("hidden", "");
|
|
50886
51307
|
}
|
|
@@ -50929,7 +51350,10 @@ const SolidDelete = {
|
|
|
50929
51350
|
return store.delete(this.dataSrc, this.context).then((response) => {
|
|
50930
51351
|
if (!response.ok) return;
|
|
50931
51352
|
this.goToNext(null);
|
|
50932
|
-
const eventData = {
|
|
51353
|
+
const eventData = {
|
|
51354
|
+
detail: { resource: { "@id": this.dataSrc } },
|
|
51355
|
+
bubbles: true
|
|
51356
|
+
};
|
|
50933
51357
|
this.element.dispatchEvent(new CustomEvent("save", eventData));
|
|
50934
51358
|
this.element.dispatchEvent(new CustomEvent("resourceDeleted", eventData));
|
|
50935
51359
|
});
|
|
@@ -50940,14 +51364,11 @@ const SolidDelete = {
|
|
|
50940
51364
|
update() {
|
|
50941
51365
|
this.render();
|
|
50942
51366
|
},
|
|
50943
|
-
render: trackRenderAsync(
|
|
50944
|
-
|
|
50945
|
-
|
|
50946
|
-
|
|
50947
|
-
|
|
50948
|
-
},
|
|
50949
|
-
"SolidDelete:render"
|
|
50950
|
-
)
|
|
51367
|
+
render: trackRenderAsync(async function() {
|
|
51368
|
+
await this.replaceAttributesData(false);
|
|
51369
|
+
const button = x`<button @click=${this.delete.bind(this)}>${this.dataLabel || this.t("solid-delete.button")}</button>${this.getModalDialog()}`;
|
|
51370
|
+
B(button, this.element);
|
|
51371
|
+
}, "SolidDelete:render")
|
|
50951
51372
|
};
|
|
50952
51373
|
Sib.register(SolidDelete);
|
|
50953
51374
|
const SolidLang = {
|
|
@@ -51157,7 +51578,9 @@ const SolidTable = {
|
|
|
51157
51578
|
},
|
|
51158
51579
|
get selectedLines() {
|
|
51159
51580
|
if (this.selectable === null) return [];
|
|
51160
|
-
return Array.from(
|
|
51581
|
+
return Array.from(
|
|
51582
|
+
this.element.querySelectorAll("input[data-selection]:checked")
|
|
51583
|
+
).map((e2) => {
|
|
51161
51584
|
var _a3;
|
|
51162
51585
|
return (_a3 = e2 == null ? void 0 : e2.closest("[data-resource]")) == null ? void 0 : _a3.getAttribute("data-resource");
|
|
51163
51586
|
});
|
|
@@ -51168,7 +51591,11 @@ const SolidTable = {
|
|
|
51168
51591
|
*/
|
|
51169
51592
|
selectAll(e2) {
|
|
51170
51593
|
if (this.selectable === null) return;
|
|
51171
|
-
for (const checkbox of Array.from(
|
|
51594
|
+
for (const checkbox of Array.from(
|
|
51595
|
+
this.element.querySelectorAll(
|
|
51596
|
+
"input[data-selection]"
|
|
51597
|
+
)
|
|
51598
|
+
)) {
|
|
51172
51599
|
checkbox.checked = e2.target.checked;
|
|
51173
51600
|
}
|
|
51174
51601
|
},
|
|
@@ -51177,7 +51604,11 @@ const SolidTable = {
|
|
|
51177
51604
|
*/
|
|
51178
51605
|
unselectAll() {
|
|
51179
51606
|
if (this.selectable === null) return;
|
|
51180
|
-
for (const checkbox of Array.from(
|
|
51607
|
+
for (const checkbox of Array.from(
|
|
51608
|
+
this.element.querySelectorAll(
|
|
51609
|
+
"input[data-selection]"
|
|
51610
|
+
)
|
|
51611
|
+
)) {
|
|
51181
51612
|
checkbox.checked = false;
|
|
51182
51613
|
}
|
|
51183
51614
|
},
|
|
@@ -51188,7 +51619,9 @@ const SolidTable = {
|
|
|
51188
51619
|
selectLines(lines) {
|
|
51189
51620
|
if (this.selectable === null || lines.length === 0) return;
|
|
51190
51621
|
for (const line of lines) {
|
|
51191
|
-
const checkbox = this.element.querySelector(
|
|
51622
|
+
const checkbox = this.element.querySelector(
|
|
51623
|
+
`[data-resource="${line}"] input[data-selection]`
|
|
51624
|
+
);
|
|
51192
51625
|
if (checkbox) checkbox.checked = true;
|
|
51193
51626
|
}
|
|
51194
51627
|
},
|
|
@@ -51198,7 +51631,8 @@ const SolidTable = {
|
|
|
51198
51631
|
* @param resource
|
|
51199
51632
|
*/
|
|
51200
51633
|
async createCellWidget(field, resource) {
|
|
51201
|
-
if (!this.element.hasAttribute("editable-" + field))
|
|
51634
|
+
if (!this.element.hasAttribute("editable-" + field))
|
|
51635
|
+
return this.createWidgetTemplate(field, resource, true);
|
|
51202
51636
|
const attributes = {};
|
|
51203
51637
|
const formWidgetAttributes = [
|
|
51204
51638
|
// attributes to give to the form widget
|
|
@@ -51215,14 +51649,16 @@ const SolidTable = {
|
|
|
51215
51649
|
"title",
|
|
51216
51650
|
"widget"
|
|
51217
51651
|
];
|
|
51218
|
-
for (let attr of formWidgetAttributes)
|
|
51652
|
+
for (let attr of formWidgetAttributes)
|
|
51653
|
+
this.addToAttributes(`${attr}-${field}`, `${attr}-${field}`, attributes);
|
|
51219
51654
|
const formAttributes = [
|
|
51220
51655
|
// attributes to give to the form
|
|
51221
51656
|
"class",
|
|
51222
51657
|
"submit-button",
|
|
51223
51658
|
"next"
|
|
51224
51659
|
];
|
|
51225
|
-
for (let attr of formAttributes)
|
|
51660
|
+
for (let attr of formAttributes)
|
|
51661
|
+
this.addToAttributes(`${attr}-${field}`, attr, attributes);
|
|
51226
51662
|
return x`
|
|
51227
51663
|
<solid-form
|
|
51228
51664
|
data-src="${resource["@id"]}"
|
|
@@ -51291,12 +51727,7 @@ const SolidTable = {
|
|
|
51291
51727
|
this.selectLines(selectedLines);
|
|
51292
51728
|
const nextProcessor = listPostProcessors.shift();
|
|
51293
51729
|
if (nextProcessor)
|
|
51294
|
-
await nextProcessor(
|
|
51295
|
-
resources,
|
|
51296
|
-
listPostProcessors,
|
|
51297
|
-
div2,
|
|
51298
|
-
context2
|
|
51299
|
-
);
|
|
51730
|
+
await nextProcessor(resources, listPostProcessors, div2, context2);
|
|
51300
51731
|
}, "SolidTable:renderDom")
|
|
51301
51732
|
};
|
|
51302
51733
|
Sib.register(SolidTable);
|
|
@@ -51344,10 +51775,8 @@ const SolidMembership = {
|
|
|
51344
51775
|
if (!store.session) return;
|
|
51345
51776
|
let currentUserSession = await store.session;
|
|
51346
51777
|
if (!currentUserSession) return;
|
|
51347
|
-
if (!this.dataTargetSrc)
|
|
51348
|
-
|
|
51349
|
-
else
|
|
51350
|
-
this.userId = this.dataTargetSrc;
|
|
51778
|
+
if (!this.dataTargetSrc) this.userId = await currentUserSession.webId;
|
|
51779
|
+
else this.userId = this.dataTargetSrc;
|
|
51351
51780
|
if (!this.userId) return;
|
|
51352
51781
|
this.resource = await store.getData(this.resourceId);
|
|
51353
51782
|
if (!this.resource) return;
|
|
@@ -51379,15 +51808,20 @@ const SolidMembership = {
|
|
|
51379
51808
|
this.currentMembers.push({ "@id": this.userId });
|
|
51380
51809
|
let currentRes = {
|
|
51381
51810
|
"@context": this.context,
|
|
51382
|
-
|
|
51811
|
+
user_set: this.currentMembers
|
|
51383
51812
|
};
|
|
51384
51813
|
return store.patch(currentRes, this.dataSrc).then((response) => {
|
|
51385
51814
|
if (!response) {
|
|
51386
|
-
console.warn(
|
|
51815
|
+
console.warn(
|
|
51816
|
+
`Error while joining group ${this.dataSrc} for user ${this.userId}`
|
|
51817
|
+
);
|
|
51387
51818
|
return;
|
|
51388
51819
|
}
|
|
51389
51820
|
this.goToNext(null);
|
|
51390
|
-
const eventData = {
|
|
51821
|
+
const eventData = {
|
|
51822
|
+
detail: { resource: { "@id": this.dataSrc } },
|
|
51823
|
+
bubbles: true
|
|
51824
|
+
};
|
|
51391
51825
|
this.element.dispatchEvent(new CustomEvent("save", eventData));
|
|
51392
51826
|
this.element.dispatchEvent(new CustomEvent("memberAdded", eventData));
|
|
51393
51827
|
this.planRender();
|
|
@@ -51396,21 +51830,25 @@ const SolidMembership = {
|
|
|
51396
51830
|
async leaveGroup() {
|
|
51397
51831
|
let userSet = this.currentMembers.filter((value) => {
|
|
51398
51832
|
const userId = value["@id"];
|
|
51399
|
-
if (userId == this.userId)
|
|
51400
|
-
return false;
|
|
51833
|
+
if (userId == this.userId) return false;
|
|
51401
51834
|
else return true;
|
|
51402
51835
|
});
|
|
51403
51836
|
let currentRes = {
|
|
51404
51837
|
"@context": this.context,
|
|
51405
|
-
|
|
51838
|
+
user_set: userSet
|
|
51406
51839
|
};
|
|
51407
51840
|
return store.patch(currentRes, this.dataSrc).then((response) => {
|
|
51408
51841
|
if (!response) {
|
|
51409
|
-
console.warn(
|
|
51842
|
+
console.warn(
|
|
51843
|
+
`Error while leaving group ${this.dataSrc} for user ${this.userId}`
|
|
51844
|
+
);
|
|
51410
51845
|
return;
|
|
51411
51846
|
}
|
|
51412
51847
|
this.goToNext(null);
|
|
51413
|
-
const eventData = {
|
|
51848
|
+
const eventData = {
|
|
51849
|
+
detail: { resource: { "@id": this.dataSrc } },
|
|
51850
|
+
bubbles: true
|
|
51851
|
+
};
|
|
51414
51852
|
this.element.dispatchEvent(new CustomEvent("save", eventData));
|
|
51415
51853
|
this.element.dispatchEvent(new CustomEvent("memberRemoved", eventData));
|
|
51416
51854
|
this.planRender();
|
|
@@ -51429,12 +51867,11 @@ const SolidMembership = {
|
|
|
51429
51867
|
update() {
|
|
51430
51868
|
this.render();
|
|
51431
51869
|
},
|
|
51432
|
-
render: trackRenderAsync(
|
|
51433
|
-
|
|
51434
|
-
|
|
51435
|
-
|
|
51436
|
-
|
|
51437
|
-
button = x`
|
|
51870
|
+
render: trackRenderAsync(async function() {
|
|
51871
|
+
await this.populate();
|
|
51872
|
+
let button = x``;
|
|
51873
|
+
if (this.isMember) {
|
|
51874
|
+
button = x`
|
|
51438
51875
|
<solid-ac-checker data-src="${this.dataSrc}"
|
|
51439
51876
|
permission="acl:Read"
|
|
51440
51877
|
class=${o$2(`${this.classSubmitButton ? "leave " + this.classSubmitButton : "leave"}`)}
|
|
@@ -51443,8 +51880,8 @@ const SolidMembership = {
|
|
|
51443
51880
|
${this.getModalDialog()}
|
|
51444
51881
|
</solid-ac-checker>
|
|
51445
51882
|
`;
|
|
51446
|
-
|
|
51447
|
-
|
|
51883
|
+
} else {
|
|
51884
|
+
button = x`
|
|
51448
51885
|
<solid-ac-checker data-src="${this.dataSrc}"
|
|
51449
51886
|
permission="acl:Read"
|
|
51450
51887
|
class=${o$2(`${this.classSubmitButton ? "join " + this.classSubmitButton : "join"}`)}
|
|
@@ -51453,11 +51890,9 @@ const SolidMembership = {
|
|
|
51453
51890
|
${this.getModalDialog()}
|
|
51454
51891
|
</solid-ac-checker>
|
|
51455
51892
|
`;
|
|
51456
|
-
|
|
51457
|
-
|
|
51458
|
-
|
|
51459
|
-
"SolidMembership:render"
|
|
51460
|
-
)
|
|
51893
|
+
}
|
|
51894
|
+
B(button, this.element);
|
|
51895
|
+
}, "SolidMembership:render")
|
|
51461
51896
|
};
|
|
51462
51897
|
Sib.register(SolidMembership);
|
|
51463
51898
|
const SolidMemberDelete = {
|
|
@@ -51538,21 +51973,25 @@ const SolidMemberDelete = {
|
|
|
51538
51973
|
async deleteMembership() {
|
|
51539
51974
|
let userSet = this.currentMembers.filter((value) => {
|
|
51540
51975
|
const userId = value["@id"];
|
|
51541
|
-
if (userId == this.dataTargetSrc)
|
|
51542
|
-
return false;
|
|
51976
|
+
if (userId == this.dataTargetSrc) return false;
|
|
51543
51977
|
else return true;
|
|
51544
51978
|
});
|
|
51545
51979
|
let currentRes = {
|
|
51546
51980
|
"@context": this.context,
|
|
51547
|
-
|
|
51981
|
+
user_set: userSet
|
|
51548
51982
|
};
|
|
51549
51983
|
return store.patch(currentRes, this.dataSrc).then((response) => {
|
|
51550
51984
|
if (!response) {
|
|
51551
|
-
console.warn(
|
|
51985
|
+
console.warn(
|
|
51986
|
+
`Error while removing user ${this.dataTargetSrc} from group ${this.dataSrc}`
|
|
51987
|
+
);
|
|
51552
51988
|
return;
|
|
51553
51989
|
}
|
|
51554
51990
|
this.goToNext(null);
|
|
51555
|
-
const eventData = {
|
|
51991
|
+
const eventData = {
|
|
51992
|
+
detail: { resource: { "@id": this.dataSrc } },
|
|
51993
|
+
bubbles: true
|
|
51994
|
+
};
|
|
51556
51995
|
this.element.dispatchEvent(new CustomEvent("save", eventData));
|
|
51557
51996
|
this.element.dispatchEvent(new CustomEvent("memberRemoved", eventData));
|
|
51558
51997
|
this.planRender();
|
|
@@ -51564,12 +52003,11 @@ const SolidMemberDelete = {
|
|
|
51564
52003
|
update() {
|
|
51565
52004
|
this.render();
|
|
51566
52005
|
},
|
|
51567
|
-
render: trackRenderAsync(
|
|
51568
|
-
|
|
51569
|
-
|
|
51570
|
-
|
|
51571
|
-
|
|
51572
|
-
button = x`
|
|
52006
|
+
render: trackRenderAsync(async function() {
|
|
52007
|
+
await this.populate();
|
|
52008
|
+
let button = x``;
|
|
52009
|
+
if (this.isMember) {
|
|
52010
|
+
button = x`
|
|
51573
52011
|
<solid-ac-checker data-src="${this.dataSrc}"
|
|
51574
52012
|
permission="acl:Write"
|
|
51575
52013
|
class=${o$2(this.classSubmitButton)}
|
|
@@ -51581,13 +52019,11 @@ const SolidMemberDelete = {
|
|
|
51581
52019
|
${this.getModalDialog()}
|
|
51582
52020
|
</solid-ac-checker>
|
|
51583
52021
|
`;
|
|
51584
|
-
|
|
51585
|
-
|
|
51586
|
-
|
|
51587
|
-
|
|
51588
|
-
|
|
51589
|
-
"SolidMemberDelete:render"
|
|
51590
|
-
)
|
|
52022
|
+
} else {
|
|
52023
|
+
button = x`<span>${this.dataUnknownMember || this.t("solid-member-unknown.span")}</span>`;
|
|
52024
|
+
}
|
|
52025
|
+
B(button, this.element);
|
|
52026
|
+
}, "SolidMemberDelete:render")
|
|
51591
52027
|
};
|
|
51592
52028
|
Sib.register(SolidMemberDelete);
|
|
51593
52029
|
const SolidMemberAdd = {
|
|
@@ -51643,15 +52079,20 @@ const SolidMemberAdd = {
|
|
|
51643
52079
|
this.currentMembers.push(JSON.parse(this.dataTargetSrc));
|
|
51644
52080
|
let currentRes = {
|
|
51645
52081
|
"@context": this.context,
|
|
51646
|
-
|
|
52082
|
+
user_set: this.currentMembers
|
|
51647
52083
|
};
|
|
51648
52084
|
return store.patch(currentRes, this.resourceId).then((response) => {
|
|
51649
52085
|
if (!response) {
|
|
51650
|
-
console.warn(
|
|
52086
|
+
console.warn(
|
|
52087
|
+
`Error while adding user ${this.dataTargetSrc} to group ${this.resourceId}`
|
|
52088
|
+
);
|
|
51651
52089
|
return;
|
|
51652
52090
|
}
|
|
51653
52091
|
this.goToNext(null);
|
|
51654
|
-
const eventData = {
|
|
52092
|
+
const eventData = {
|
|
52093
|
+
detail: { resource: { "@id": this.dataSrc } },
|
|
52094
|
+
bubbles: true
|
|
52095
|
+
};
|
|
51655
52096
|
this.element.dispatchEvent(new CustomEvent("save", eventData));
|
|
51656
52097
|
this.element.dispatchEvent(new CustomEvent("memberAdded", eventData));
|
|
51657
52098
|
this.planRender();
|
|
@@ -51798,9 +52239,17 @@ class SolidTemplateElement extends HTMLElement {
|
|
|
51798
52239
|
const fullPath = `${path}/${ln}.json`;
|
|
51799
52240
|
return fetch(fullPath).then((result) => {
|
|
51800
52241
|
if (result.ok) {
|
|
51801
|
-
return result.json().catch(
|
|
52242
|
+
return result.json().catch(
|
|
52243
|
+
(e2) => console.error(
|
|
52244
|
+
`Error while parsing the translation file: ${fullPath}`
|
|
52245
|
+
)
|
|
52246
|
+
);
|
|
51802
52247
|
}
|
|
51803
|
-
}).catch(
|
|
52248
|
+
}).catch(
|
|
52249
|
+
(e2) => console.error(
|
|
52250
|
+
`Error while retrieving the translation file: ${fullPath}`
|
|
52251
|
+
)
|
|
52252
|
+
);
|
|
51804
52253
|
}
|
|
51805
52254
|
/**
|
|
51806
52255
|
* Returns current locale of app
|
|
@@ -51904,7 +52353,8 @@ class BaseWidget extends HTMLElement {
|
|
|
51904
52353
|
get value() {
|
|
51905
52354
|
if (this.dataHolder) {
|
|
51906
52355
|
let values = this.dataHolder.map((element) => {
|
|
51907
|
-
if (element instanceof HTMLInputElement && element.type == "checkbox")
|
|
52356
|
+
if (element instanceof HTMLInputElement && element.type == "checkbox")
|
|
52357
|
+
return element.checked;
|
|
51908
52358
|
return this.getValueHolder(element).value;
|
|
51909
52359
|
});
|
|
51910
52360
|
return values.length === 1 ? values[0] : values;
|
|
@@ -51923,17 +52373,15 @@ class BaseWidget extends HTMLElement {
|
|
|
51923
52373
|
}
|
|
51924
52374
|
if (element.dispatchEvent) element.dispatchEvent(new Event("change"));
|
|
51925
52375
|
} else if (this.dataHolder && this.dataHolder.length > 1) {
|
|
51926
|
-
this.dataHolder.forEach(
|
|
51927
|
-
(el2
|
|
51928
|
-
|
|
51929
|
-
|
|
51930
|
-
|
|
51931
|
-
|
|
51932
|
-
element.value = value ? value[index2] : "";
|
|
51933
|
-
}
|
|
51934
|
-
element.dispatchEvent(new Event("change"));
|
|
52376
|
+
this.dataHolder.forEach((el2, index2) => {
|
|
52377
|
+
const element = this.getValueHolder(el2);
|
|
52378
|
+
if (element.type == "checkbox") {
|
|
52379
|
+
element.checked = value ? value[index2] : "";
|
|
52380
|
+
} else {
|
|
52381
|
+
element.value = value ? value[index2] : "";
|
|
51935
52382
|
}
|
|
51936
|
-
|
|
52383
|
+
element.dispatchEvent(new Event("change"));
|
|
52384
|
+
});
|
|
51937
52385
|
}
|
|
51938
52386
|
this.render();
|
|
51939
52387
|
}
|
|
@@ -51950,7 +52398,9 @@ class BaseWidget extends HTMLElement {
|
|
|
51950
52398
|
this.setAttribute("remove-label", label);
|
|
51951
52399
|
}
|
|
51952
52400
|
get dataHolder() {
|
|
51953
|
-
const widgetDataHolders = Array.from(
|
|
52401
|
+
const widgetDataHolders = Array.from(
|
|
52402
|
+
this.querySelectorAll("[data-holder]")
|
|
52403
|
+
).filter((element) => {
|
|
51954
52404
|
const dataHolderAncestor = element.parentElement ? element.parentElement.closest("[data-holder]") : null;
|
|
51955
52405
|
return dataHolderAncestor === this || !dataHolderAncestor || !this.contains(dataHolderAncestor);
|
|
51956
52406
|
});
|
|
@@ -51976,7 +52426,10 @@ class BaseWidget extends HTMLElement {
|
|
|
51976
52426
|
}
|
|
51977
52427
|
set range(range2) {
|
|
51978
52428
|
(async () => {
|
|
51979
|
-
this._listen(
|
|
52429
|
+
this._listen(
|
|
52430
|
+
range2,
|
|
52431
|
+
async () => this._range = await store.getData(range2, this.context)
|
|
52432
|
+
);
|
|
51980
52433
|
this._range = await store.getData(range2, this.context);
|
|
51981
52434
|
this.render();
|
|
51982
52435
|
})();
|
|
@@ -51996,9 +52449,13 @@ class BaseWidget extends HTMLElement {
|
|
|
51996
52449
|
}
|
|
51997
52450
|
}
|
|
51998
52451
|
if ((_a3 = res.isContainer) == null ? void 0 : _a3.call(res)) {
|
|
51999
|
-
let resourcesFromContainer = await store.getData(
|
|
52452
|
+
let resourcesFromContainer = await store.getData(
|
|
52453
|
+
res["@id"],
|
|
52454
|
+
this.context
|
|
52455
|
+
);
|
|
52000
52456
|
this._listen(res["@id"]);
|
|
52001
|
-
if (resourcesFromContainer)
|
|
52457
|
+
if (resourcesFromContainer)
|
|
52458
|
+
resources.push(...resourcesFromContainer["ldp:contains"]);
|
|
52002
52459
|
} else {
|
|
52003
52460
|
resources.push(res);
|
|
52004
52461
|
}
|
|
@@ -52044,10 +52501,13 @@ class BaseWidget extends HTMLElement {
|
|
|
52044
52501
|
_listen(id2, callback = () => {
|
|
52045
52502
|
}) {
|
|
52046
52503
|
if (!this._subscriptions.get(id2)) {
|
|
52047
|
-
this._subscriptions.set(
|
|
52048
|
-
|
|
52049
|
-
|
|
52050
|
-
|
|
52504
|
+
this._subscriptions.set(
|
|
52505
|
+
id2,
|
|
52506
|
+
PubSub.subscribe(id2, async () => {
|
|
52507
|
+
await callback();
|
|
52508
|
+
this.render();
|
|
52509
|
+
})
|
|
52510
|
+
);
|
|
52051
52511
|
}
|
|
52052
52512
|
}
|
|
52053
52513
|
// Editable widgets
|
|
@@ -52058,7 +52518,10 @@ class BaseWidget extends HTMLElement {
|
|
|
52058
52518
|
editButton.innerText = "Modifier";
|
|
52059
52519
|
editButton.onclick = () => this.activateEditableField(editableField, editButton);
|
|
52060
52520
|
editableField.insertAdjacentElement("afterend", editButton);
|
|
52061
|
-
editableField.addEventListener(
|
|
52521
|
+
editableField.addEventListener(
|
|
52522
|
+
"focusout",
|
|
52523
|
+
() => this.save(editableField, editButton)
|
|
52524
|
+
);
|
|
52062
52525
|
}
|
|
52063
52526
|
}
|
|
52064
52527
|
activateEditableField(editableField, editButton) {
|