ochre-sdk 1.0.51 → 1.0.52
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.
|
@@ -233,6 +233,60 @@ function parseStylesheets(styles) {
|
|
|
233
233
|
return parsedStyles;
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
|
+
* Default values for a collection's display properties, shared between the
|
|
237
|
+
* "collection" component and the "query" component's collection overrides.
|
|
238
|
+
*/
|
|
239
|
+
const COLLECTION_PROPERTY_DEFAULTS = {
|
|
240
|
+
variant: "slide",
|
|
241
|
+
paginationVariant: "default",
|
|
242
|
+
loadingVariant: "skeleton",
|
|
243
|
+
imageLayout: "start",
|
|
244
|
+
isImagePlaceholderDisplayed: true,
|
|
245
|
+
minimumColumnCount: null,
|
|
246
|
+
maximumColumnCount: null,
|
|
247
|
+
expectedItemCount: null,
|
|
248
|
+
isSortDisplayed: false,
|
|
249
|
+
isUsingQueryParams: false,
|
|
250
|
+
isInteractive: true
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Reads the collection display properties explicitly set on a reader, omitting
|
|
254
|
+
* any that are unset. The "collection" component merges these over
|
|
255
|
+
* {@link COLLECTION_PROPERTY_DEFAULTS}, while the "query" component uses them as
|
|
256
|
+
* partial overrides for its embedded collection.
|
|
257
|
+
*/
|
|
258
|
+
function parseCollectionPropertyOverrides(reader) {
|
|
259
|
+
const overrides = {};
|
|
260
|
+
function read(key, label) {
|
|
261
|
+
const value = reader.value(label);
|
|
262
|
+
if (value != null) overrides[key] = value;
|
|
263
|
+
}
|
|
264
|
+
read("variant", "variant");
|
|
265
|
+
read("paginationVariant", "pagination-variant");
|
|
266
|
+
read("loadingVariant", "loading-variant");
|
|
267
|
+
read("imageLayout", "image-layout");
|
|
268
|
+
read("isImagePlaceholderDisplayed", "image-placeholder-displayed");
|
|
269
|
+
read("minimumColumnCount", "minimum-column-count");
|
|
270
|
+
read("maximumColumnCount", "maximum-column-count");
|
|
271
|
+
read("expectedItemCount", "item-count");
|
|
272
|
+
read("isSortDisplayed", "sort-displayed");
|
|
273
|
+
read("isUsingQueryParams", "is-using-query-params");
|
|
274
|
+
read("isInteractive", "is-interactive");
|
|
275
|
+
return overrides;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Parses the "use-property" values defining which item properties a collection
|
|
279
|
+
* displays, returning `null` when none are set.
|
|
280
|
+
*/
|
|
281
|
+
function parseCollectionDisplayedProperties(reader) {
|
|
282
|
+
const property = reader.property("use-property");
|
|
283
|
+
if (property == null) return null;
|
|
284
|
+
return property.values.filter((value) => value.uuid !== null).map((value) => ({
|
|
285
|
+
uuid: value.uuid,
|
|
286
|
+
label: value.label
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
236
290
|
* Parses raw web element properties into a standardized WebElementComponent structure
|
|
237
291
|
*
|
|
238
292
|
* @param componentProperty - Raw component property data in OCHRE format
|
|
@@ -368,39 +422,19 @@ function parseWebElementProperties(componentProperty, elementResource, options,
|
|
|
368
422
|
case "collection": {
|
|
369
423
|
const setLinks = getWebsiteLinks(websiteLinks, "set");
|
|
370
424
|
if (setLinks.length === 0) throw new Error(formatComponentError("Set links not found", componentName, elementResource), { cause: componentProperty });
|
|
371
|
-
const displayedProperties = componentReader.property("use-property");
|
|
372
|
-
const variant = componentReader.valueOr("variant", "slide");
|
|
373
|
-
const paginationVariant = componentReader.valueOr("pagination-variant", "default");
|
|
374
|
-
const loadingVariant = componentReader.valueOr("loading-variant", "skeleton");
|
|
375
|
-
const expectedItemCount = componentReader.valueOr("item-count", null);
|
|
376
|
-
const isUsingQueryParams = componentReader.valueOr("is-using-query-params", false);
|
|
377
425
|
const isFilterResultsBarDisplayed = componentReader.valueOr("filter-results-bar-displayed", false);
|
|
378
426
|
const isFilterInputDisplayed = componentReader.valueOr("filter-input-displayed", false);
|
|
379
427
|
const isFilterLimitedToInputFilter = componentReader.valueOr("filter-limit-to-input-filter", false);
|
|
380
428
|
const isFilterLimitedToLeafPropertyValues = componentReader.valueOr("filter-limit-to-leaf-property-values", false);
|
|
381
|
-
const isSortDisplayed = componentReader.valueOr("sort-displayed", false);
|
|
382
429
|
const isFilterSidebarDisplayed = componentReader.valueOr("filter-sidebar-displayed", false);
|
|
383
430
|
const filterSidebarSort = componentReader.valueOr("filter-sidebar-sort", "default");
|
|
384
|
-
const imageLayout = componentReader.valueOr("image-layout", "start");
|
|
385
|
-
const isImagePlaceholderDisplayed = componentReader.valueOr("image-placeholder-displayed", true);
|
|
386
|
-
const isInteractive = componentReader.valueOr("is-interactive", true);
|
|
387
431
|
const componentOptions = parseWebsiteOptions(elementResource.options, options);
|
|
388
432
|
properties = {
|
|
389
433
|
component: "collection",
|
|
390
434
|
linkUuids: setLinks.map((link) => link.uuid),
|
|
391
|
-
displayedProperties:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
})) ?? null,
|
|
395
|
-
variant,
|
|
396
|
-
paginationVariant,
|
|
397
|
-
loadingVariant,
|
|
398
|
-
imageLayout,
|
|
399
|
-
isImagePlaceholderDisplayed,
|
|
400
|
-
expectedItemCount,
|
|
401
|
-
isSortDisplayed,
|
|
402
|
-
isUsingQueryParams,
|
|
403
|
-
isInteractive,
|
|
435
|
+
displayedProperties: parseCollectionDisplayedProperties(componentReader),
|
|
436
|
+
...COLLECTION_PROPERTY_DEFAULTS,
|
|
437
|
+
...parseCollectionPropertyOverrides(componentReader),
|
|
404
438
|
filter: {
|
|
405
439
|
isSidebarDisplayed: isFilterSidebarDisplayed,
|
|
406
440
|
isResultsBarDisplayed: isFilterResultsBarDisplayed,
|
|
@@ -601,31 +635,9 @@ function parseWebElementProperties(componentProperty, elementResource, options,
|
|
|
601
635
|
}
|
|
602
636
|
if (items.length === 0) throw new Error(formatComponentError("No queries found", componentName, elementResource), { cause: componentProperty });
|
|
603
637
|
const componentOptions = parseWebsiteOptions(elementResource.options, options);
|
|
604
|
-
const collectionProperties =
|
|
605
|
-
const displayedProperties = componentReader
|
|
606
|
-
if (displayedProperties != null) collectionProperties.displayedProperties = displayedProperties
|
|
607
|
-
uuid: value.uuid,
|
|
608
|
-
label: value.label
|
|
609
|
-
}));
|
|
610
|
-
const overrideReader = componentReader.nestedByValue("sub-component-override", "collection");
|
|
611
|
-
const variant = overrideReader.value("variant");
|
|
612
|
-
if (variant != null) collectionProperties.variant = variant;
|
|
613
|
-
const paginationVariant = overrideReader.value("pagination-variant");
|
|
614
|
-
if (paginationVariant != null) collectionProperties.paginationVariant = paginationVariant;
|
|
615
|
-
const loadingVariant = overrideReader.value("loading-variant");
|
|
616
|
-
if (loadingVariant != null) collectionProperties.loadingVariant = loadingVariant;
|
|
617
|
-
const imageLayout = overrideReader.value("image-layout");
|
|
618
|
-
if (imageLayout != null) collectionProperties.imageLayout = imageLayout;
|
|
619
|
-
const isImagePlaceholderDisplayed = overrideReader.value("image-placeholder-displayed");
|
|
620
|
-
if (isImagePlaceholderDisplayed != null) collectionProperties.isImagePlaceholderDisplayed = isImagePlaceholderDisplayed;
|
|
621
|
-
const expectedItemCount = overrideReader.value("item-count");
|
|
622
|
-
if (expectedItemCount != null) collectionProperties.expectedItemCount = expectedItemCount;
|
|
623
|
-
const isSortDisplayed = overrideReader.value("sort-displayed");
|
|
624
|
-
if (isSortDisplayed != null) collectionProperties.isSortDisplayed = isSortDisplayed;
|
|
625
|
-
const isUsingQueryParams = overrideReader.value("is-using-query-params");
|
|
626
|
-
if (isUsingQueryParams != null) collectionProperties.isUsingQueryParams = isUsingQueryParams;
|
|
627
|
-
const isInteractive = overrideReader.value("is-interactive");
|
|
628
|
-
if (isInteractive != null) collectionProperties.isInteractive = isInteractive;
|
|
638
|
+
const collectionProperties = parseCollectionPropertyOverrides(componentReader.nestedByValue("sub-component-override", "collection"));
|
|
639
|
+
const displayedProperties = parseCollectionDisplayedProperties(componentReader);
|
|
640
|
+
if (displayedProperties != null) collectionProperties.displayedProperties = displayedProperties;
|
|
629
641
|
properties = {
|
|
630
642
|
component: "query",
|
|
631
643
|
linkUuids: setLinks.map((link) => link.uuid),
|
package/dist/types/website.d.mts
CHANGED
|
@@ -302,6 +302,8 @@ type WebElementComponent<T extends LanguageCodes = LanguageCodes> = {
|
|
|
302
302
|
loadingVariant: "spinner" | "skeleton" | "animation" | "none";
|
|
303
303
|
imageLayout: "top" | "bottom" | "start" | "end" | null;
|
|
304
304
|
isImagePlaceholderDisplayed: boolean;
|
|
305
|
+
minimumColumnCount: number | null;
|
|
306
|
+
maximumColumnCount: number | null;
|
|
305
307
|
expectedItemCount: number | null;
|
|
306
308
|
isSortDisplayed: boolean;
|
|
307
309
|
isUsingQueryParams: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ochre-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"date-fns": "^4.4.0",
|
|
49
49
|
"fast-equals": "^6.0.0",
|
|
50
|
-
"fast-xml-parser": "^5.
|
|
50
|
+
"fast-xml-parser": "^5.9.0",
|
|
51
51
|
"valibot": "^1.4.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"@types/node": "^24.13.2",
|
|
56
56
|
"bumpp": "^11.1.0",
|
|
57
57
|
"eslint": "^10.5.0",
|
|
58
|
-
"knip": "^6.
|
|
59
|
-
"oxfmt": "^0.
|
|
58
|
+
"knip": "^6.17.1",
|
|
59
|
+
"oxfmt": "^0.55.0",
|
|
60
60
|
"tsdown": "^0.22.2",
|
|
61
61
|
"typescript": "^6.0.3",
|
|
62
|
-
"vitest": "^4.1.
|
|
62
|
+
"vitest": "^4.1.9"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"dev": "tsdown src/index.ts --watch",
|