@startinblox/components-ds4go 3.0.3 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/.storybook/preview.ts +1 -0
  2. package/biome.json +1 -1
  3. package/dist/custom-getter-ZPFnoSjt-BCNOlbJZ-B4tuxA42.js +338 -0
  4. package/dist/en-BySYJZMr-CWZl5AwU-CWZl5AwU.js +14 -0
  5. package/dist/fr-BZZDTsmw-CNDWt66j-CNDWt66j.js +14 -0
  6. package/dist/index-BSwVRtNS.js +104980 -0
  7. package/dist/index.js +1 -3032
  8. package/dist/quill.snow-C_A_QkE8-D-uedtvC-D-uedtvC.js +13 -0
  9. package/dist/slimselect-NFLzJMfV-DZ7j6Vsj-DZ7j6Vsj.js +5 -0
  10. package/package.json +9 -8
  11. package/src/components/cards/ds4go-card-catalog.ts +132 -0
  12. package/src/components/catalog/ds4go-catalog-filter-holder.ts +459 -0
  13. package/src/components/catalog/ds4go-customer-holder.ts +162 -0
  14. package/src/components/catalog/ds4go-fact-bundle-holder.ts +7 -7
  15. package/src/components/modal/ds4go-customer-modal.ts +134 -0
  16. package/src/components/modal/ds4go-fact-bundle-modal.ts +2 -2
  17. package/src/components/solid-customer-list.ts +195 -0
  18. package/src/components/solid-dsif-explorer-poc.ts +8 -8
  19. package/src/components/solid-dsp-connector.ts +12 -4
  20. package/src/components/solid-fact-bundle-creation.ts +244 -151
  21. package/src/components/solid-fact-bundle.ts +9 -4
  22. package/src/helpers/components/orbitComponent.ts +12 -13
  23. package/src/helpers/i18n/configureLocalization.ts +12 -5
  24. package/src/helpers/index.ts +0 -2
  25. package/src/styles/cards/ds4go-card-catalog.scss +149 -0
  26. package/src/styles/fact-bundle-creation.scss +6 -2
  27. package/src/styles/modal/ds4go-customer-modal.scss +91 -0
  28. package/src/styles/modal/ds4go-fact-bundle-modal.scss +1 -1
  29. package/vite.config.ts +7 -7
  30. package/src/components/solid-boilerplate.ts +0 -76
  31. package/src/helpers/components/ResourceMapper.ts +0 -469
  32. package/src/helpers/components/orbitDspComponent.ts +0 -250
  33. package/src/helpers/mappings/dsp-mapping-config.ts +0 -545
@@ -17,6 +17,13 @@ import ComponentStyles from "@styles/fact-bundle-creation.scss?inline";
17
17
  import { html, nothing, unsafeCSS } from "lit";
18
18
  import { customElement, property, state } from "lit/decorators.js";
19
19
 
20
+ const formatCase = (str: string) => {
21
+ return str
22
+ .replace(/([A-Z])/g, " $1")
23
+ .replace(/^./, (str) => str.toUpperCase())
24
+ .trim();
25
+ }
26
+
20
27
  @customElement("solid-fact-bundle-creation")
21
28
  export class SolidFactBundle extends OrbitComponent {
22
29
  static styles = [unsafeCSS(ComponentStyles)];
@@ -36,9 +43,15 @@ export class SolidFactBundle extends OrbitComponent {
36
43
  @state()
37
44
  bundleDescription = "";
38
45
 
46
+ @state()
47
+ bundleCategory = "";
48
+
39
49
  @state()
40
50
  bundleLanguage = "en";
41
51
 
52
+ @state()
53
+ step = 0;
54
+
42
55
  policyTemplates: { id: string; name: string; policy: OdrlPolicy }[] = [
43
56
  {
44
57
  id: "policy-open-access",
@@ -165,6 +178,12 @@ export class SolidFactBundle extends OrbitComponent {
165
178
  this.spliceLength = this.facts.length;
166
179
  }
167
180
 
181
+ _nextStep() {
182
+ if (this.selectedFacts.length > 0) {
183
+ this.step++;
184
+ }
185
+ }
186
+
168
187
  async _createFactBundle() {
169
188
  if (!this.bundleName || !(this.selectedFacts.length > 0)) {
170
189
  return;
@@ -177,6 +196,7 @@ export class SolidFactBundle extends OrbitComponent {
177
196
  ],
178
197
  "@type": ["ldp:Container", "ds4go:FactBundle"],
179
198
  name: this.bundleName,
199
+ category: this.bundleCategory,
180
200
  description: this.bundleDescription || "",
181
201
  "ldp:contains": this.selectedFacts.map((fact: Resource) => ({
182
202
  "@id": fact["@id"],
@@ -217,7 +237,21 @@ export class SolidFactBundle extends OrbitComponent {
217
237
  name: this.bundleName,
218
238
  description: this.bundleDescription,
219
239
  contenttype: "application/ld+json",
220
- language: this.bundleLanguage,
240
+ "dcterms:language": this.bundleLanguage,
241
+ category: this.bundleCategory,
242
+ bundleSize: this.selectedFacts.length,
243
+ offeredAccess: "40",
244
+ pricingTier: "premium",
245
+ // "dcat:endpointUrl": "https://api.stg.ds4go.startinblox.com/facts/", // ?
246
+ previewLinks: this.selectedFacts.slice(0, 3).join(", "),
247
+ "dsif:pricing": {
248
+ "dsif:costPerAPICall": 0.15,
249
+ "dsif:setupFee": 50,
250
+ "dsif:billingPeriod": "monthly",
251
+ "dsif:currency": "EUR",
252
+ "dsif:description":
253
+ "Premium tier: 40 API calls/month, ideal for media organizations",
254
+ },
221
255
  },
222
256
  dataAddress: {
223
257
  "@type": "DataAddress",
@@ -267,27 +301,29 @@ export class SolidFactBundle extends OrbitComponent {
267
301
  const TemsAssetManagement = document.querySelector(
268
302
  "solid-tems-assets-management",
269
303
  );
270
- if (TemsAssetManagement) {
304
+ if (TemsAssetManagement?.loadAssets) {
271
305
  TemsAssetManagement.loadAssets();
272
306
  }
273
307
 
274
308
  const TemsPoliciesManagement = document.querySelector(
275
309
  "solid-tems-policies-management",
276
310
  );
277
- if (TemsPoliciesManagement) {
311
+ if (TemsPoliciesManagement?.loadPolicies) {
278
312
  TemsPoliciesManagement.loadPolicies();
279
313
  }
280
314
 
281
315
  const TemsContractsManagement = document.querySelector(
282
316
  "solid-tems-contracts-management",
283
317
  );
284
- if (TemsContractsManagement) {
318
+ if (TemsContractsManagement?.loadData) {
285
319
  TemsContractsManagement.loadData();
286
320
  }
287
321
  }
288
322
 
289
323
  this.bundleName = "";
290
324
  this.bundleDescription = "";
325
+ this.bundleDescription = "";
326
+ this.step = 0;
291
327
  this.selectedFacts = [];
292
328
 
293
329
  const factbundleComponent: any = this.orbit?.components.find(
@@ -327,6 +363,13 @@ export class SolidFactBundle extends OrbitComponent {
327
363
  }
328
364
  }
329
365
 
366
+ _selectBundleCategory(e: Event) {
367
+ e.preventDefault();
368
+ if (e.target) {
369
+ this.bundleCategory = e.target.value;
370
+ }
371
+ }
372
+
330
373
  _selectBundleContractPolicy(e: Event) {
331
374
  e.preventDefault();
332
375
  if (e.target) {
@@ -370,75 +413,26 @@ export class SolidFactBundle extends OrbitComponent {
370
413
  return html`<tems-viewport>
371
414
  <tems-header slot="header" heading=${this.header}>
372
415
  <div slot="cta">
373
- <tems-button
374
- type="primary"
375
- disabled=${!allowCreation || nothing}
376
- label=${msg("Create bundle")}
377
- @click=${this._createFactBundle}
378
- ></tems-button>
416
+ ${this.step === 0
417
+ ? html`<tems-button
418
+ type="primary"
419
+ disabled=${this.selectedFacts.length === 0 || nothing}
420
+ label=${msg("Set bundle informations")}
421
+ @click=${this._nextStep}
422
+ ></tems-button>`
423
+ : html`<tems-button
424
+ type="primary"
425
+ disabled=${!allowCreation || nothing}
426
+ label=${msg("Create bundle")}
427
+ @click=${this._createFactBundle}
428
+ ></tems-button>`}
379
429
  </div>
380
430
  </tems-header>
381
431
  <div slot="content">
382
432
  <section class="flex flex-1">
383
- <div>
384
- <div>
385
- <tems-input
386
- type="text"
387
- label=${msg("Bundle name")}
388
- placeholder=${msg("Bundle name")}
389
- required=""
390
- .value=${this.bundleName}
391
- @change=${this._updateBundleName}
392
- ></tems-input>
393
- </div>
394
- <div>
395
- <tems-textarea
396
- rows="4"
397
- label=${msg("Bundle description")}
398
- placeholder=${msg("Bundle description")}
399
- .value=${this.bundleDescription}
400
- @change=${this._updateBundleDescription}
401
- ></tems-textarea>
402
- </div>
403
- <div>
404
- <tems-input
405
- type="text"
406
- label=${msg("Language")}
407
- placeholder=${msg("Language code (en, de, es, fr...)")}
408
- hint=${msg("Comma-separated, eg.: en,de,es,fr)")}
409
- required=""
410
- .value=${this.bundleLanguage}
411
- @change=${this._updateBundleLanguage}
412
- ></tems-input>
413
- </div>
414
- <div class="select">
415
- <tems-label label=${msg("Access policy")}></tems-label>
416
- <select @change=${this._selectBundleAccessPolicy}>
417
- ${this.policyTemplates.map((policy) => {
418
- return html`<option
419
- value="${policy.id}"
420
- ?selected="${policy.id === this.bundleAccessPolicy}"
421
- >
422
- ${policy.name}
423
- </option>`;
424
- })}
425
- </select>
426
- </div>
427
- <div class="select">
428
- <tems-label label=${msg("Contract policy")}></tems-label>
429
- <select @change=${this._selectBundleContractPolicy}>
430
- ${this.policyTemplates.map((policy) => {
431
- return html`<option
432
- value="${policy.id}"
433
- ?selected="${policy.id === this.bundleContractPolicy}"
434
- >
435
- ${policy.name}
436
- </option>`;
437
- })}
438
- </select>
439
- </div>
440
- ${selectedFactsCount > 0
441
- ? html`<tems-division type="h4">
433
+ ${this.step === 0
434
+ ? html`<div>
435
+ <tems-division type="h4">
442
436
  <div>
443
437
  ${msg(
444
438
  str`${selectedFactsCount} selected fact${selectedFactsCount > 1 ? "s" : ""}`,
@@ -459,7 +453,7 @@ export class SolidFactBundle extends OrbitComponent {
459
453
  type: "information",
460
454
  });
461
455
  }
462
- return html`<tems-card-catalog
456
+ return html`<ds4go-card-catalog
463
457
  .object=${import.meta.env.DEV ? fact : nothing}
464
458
  .header=${fact.name || nothing}
465
459
  date=${fact.updated_at || nothing}
@@ -468,91 +462,190 @@ export class SolidFactBundle extends OrbitComponent {
468
462
  fact,
469
463
  )}
470
464
  selected=${true}
471
- ></tems-card-catalog>`;
465
+ ></ds4go-card-catalog>`;
472
466
  })}
473
- </div>`
474
- : nothing}
475
- </div>
476
- ${splicedDatas.length > 0 || this.filterFactText
477
- ? html`<div>
478
- <div>
479
- <tems-search-bar
480
- .displayFilters=${false}
481
- .displaySavedSearch=${false}
482
- .displayViews=${false}
483
- .dropdownCardElement=${false}
484
- .dropdownListElement=${false}
485
- .dropdownTableElement=${false}
486
- .dropdownMapElement=${false}
487
- .displayActiveTags=${false}
488
- .value=${this.filterFactText}
489
- @search=${this._searchFacts}
490
- ></tems-search-bar>
467
+ </div>
491
468
  </div>
492
- ${splicedDatas.length > 0
493
- ? html` <div class="card-grid card-grid-vertical">
494
- ${splicedDatas.map((fact: Resource) => {
495
- const tags = fact.categories.map(
496
- (c: Resource) => ({
497
- name: c.name,
498
- type: "information",
499
- }),
500
- );
501
- if (tags.length > 3) {
502
- const overflowTags = tags.length - 3;
503
- tags.splice(3, overflowTags);
504
- tags.push({
505
- name: `+${overflowTags} ${msg("more")}`,
506
- type: "information",
507
- });
508
- }
509
-
510
- return html`<tems-card-catalog
511
- .object=${import.meta.env.DEV
512
- ? fact
513
- : nothing}
514
- .tags=${tags}
515
- .header=${fact.name || nothing}
516
- .content=${fact.description || nothing}
517
- date=${fact.updated_at || nothing}
518
- @click=${this._toggleFactSelection.bind(
519
- this,
520
- fact,
521
- )}
522
- ></tems-card-catalog>`;
523
- })}
469
+ ${splicedDatas.length > 0 || this.filterFactText
470
+ ? html`<div>
471
+ <div>
472
+ <tems-search-bar
473
+ .displayFilters=${false}
474
+ .displaySavedSearch=${false}
475
+ .displayViews=${false}
476
+ .dropdownCardElement=${false}
477
+ .dropdownListElement=${false}
478
+ .dropdownTableElement=${false}
479
+ .dropdownMapElement=${false}
480
+ .displayActiveTags=${false}
481
+ .value=${this.filterFactText}
482
+ @search=${this._searchFacts}
483
+ ></tems-search-bar>
524
484
  </div>
525
- ${splicedDatas.length < datas.length
526
- ? html`<div
527
- class="flex flex-row justify-content-space-between align-items-flex-end"
528
- >
529
- <div>
530
- ${msg(
531
- str`Displaying ${splicedDatas.length} of ${datas.length} result${datas.length > 1 ? "s" : ""}`,
532
- )}
533
- </div>
534
- <div class="flex flex-row gap-400">
535
- <tems-button
536
- @click=${this._showMoreResults}
537
- type="primary"
538
- size="sm"
539
- label=${msg("Show more results")}
540
- ></tems-button>
541
- <tems-button
542
- @click=${this._showAllResults}
543
- type="primary"
544
- size="sm"
545
- label=${msg("Show all results")}
546
- ></tems-button>
485
+ ${splicedDatas.length > 0
486
+ ? html` <div class="card-grid card-grid-vertical">
487
+ ${splicedDatas.map((fact: Resource) => {
488
+ const tags = fact.categories.map(
489
+ (c: Resource) => ({
490
+ name: c.name,
491
+ type: "information",
492
+ }),
493
+ );
494
+ if (tags.length > 3) {
495
+ const overflowTags = tags.length - 3;
496
+ tags.splice(3, overflowTags);
497
+ tags.push({
498
+ name: `+${overflowTags} ${msg("more")}`,
499
+ type: "information",
500
+ });
501
+ }
502
+
503
+ return html`<ds4go-card-catalog
504
+ .object=${import.meta.env.DEV
505
+ ? fact
506
+ : nothing}
507
+ .tags=${tags}
508
+ .header=${fact.name || nothing}
509
+ .content=${fact.description || nothing}
510
+ date=${fact.updated_at || nothing}
511
+ @click=${this._toggleFactSelection.bind(
512
+ this,
513
+ fact,
514
+ )}
515
+ ></ds4go-card-catalog>`;
516
+ })}
547
517
  </div>
548
- </div>`
549
- : nothing}`
550
- : html`${msg("No results found")}
551
- ${this.filterFactText
552
- ? `for "${this.filterFactText}".`
553
- : ""}`}
554
- </div>`
555
- : nothing}
518
+ ${splicedDatas.length < datas.length
519
+ ? html`<div
520
+ class="flex flex-row justify-content-space-between align-items-flex-end"
521
+ >
522
+ <div>
523
+ ${msg(
524
+ str`Displaying ${splicedDatas.length} of ${datas.length} result${datas.length > 1 ? "s" : ""}`,
525
+ )}
526
+ </div>
527
+ <div class="flex flex-row gap-400">
528
+ <tems-button
529
+ @click=${this._showMoreResults}
530
+ type="primary"
531
+ size="sm"
532
+ label=${msg("Show more results")}
533
+ ></tems-button>
534
+ <tems-button
535
+ @click=${this._showAllResults}
536
+ type="primary"
537
+ size="sm"
538
+ label=${msg("Show all results")}
539
+ ></tems-button>
540
+ </div>
541
+ </div>`
542
+ : nothing}`
543
+ : html`${msg("No results found")}
544
+ ${this.filterFactText
545
+ ? `for "${this.filterFactText}".`
546
+ : ""}`}
547
+ </div>`
548
+ : nothing}`
549
+ : html`<div>
550
+ <div>
551
+ <tems-input
552
+ type="text"
553
+ label=${msg("Bundle name")}
554
+ placeholder=${msg("Bundle name")}
555
+ required=""
556
+ .value=${this.bundleName}
557
+ @change=${this._updateBundleName}
558
+ ></tems-input>
559
+ </div>
560
+ <div>
561
+ <tems-input
562
+ type="text"
563
+ label=${msg("Language")}
564
+ placeholder=${msg(
565
+ "Language code (en, de, es, fr...)",
566
+ )}
567
+ hint=${msg("Comma-separated, eg.: en,de,es,fr)")}
568
+ required=""
569
+ .value=${this.bundleLanguage}
570
+ @change=${this._updateBundleLanguage}
571
+ ></tems-input>
572
+ </div>
573
+ <div class="select">
574
+ <tems-label label=${msg("Category")}></tems-label>
575
+ <select @change=${this._selectBundleCategory}>
576
+ <option
577
+ value=""
578
+ ?selected="${"" === this.bundleCategory}"
579
+ >
580
+ ${msg("No category")}
581
+ </option>
582
+ ${Array.from(
583
+ new Set(
584
+ this.selectedFacts.flatMap((fact) =>
585
+ fact.categories.map(
586
+ (category: Resource) => formatCase(category.name),
587
+ ),
588
+ ),
589
+ ),
590
+ )
591
+ .filter((i) => i)
592
+ .sort((a, b) => a.localeCompare(b))
593
+ .map(
594
+ (category: string) =>
595
+ html`<option
596
+ value="${category}"
597
+ ?selected="${category ===
598
+ this.bundleCategory}"
599
+ >
600
+ ${category}
601
+ </option>`,
602
+ )}
603
+ </select>
604
+ </div>
605
+ </div>
606
+ <div>
607
+ <div>
608
+ <tems-textarea
609
+ rows="5"
610
+ label=${msg("Bundle description")}
611
+ placeholder=${msg("Bundle description")}
612
+ .value=${this.bundleDescription}
613
+ @change=${this._updateBundleDescription}
614
+ ></tems-textarea>
615
+ </div>
616
+ <div class="select">
617
+ <tems-label
618
+ label=${msg("Access policy")}
619
+ ></tems-label>
620
+ <select @change=${this._selectBundleAccessPolicy}>
621
+ ${this.policyTemplates.map((policy) => {
622
+ return html`<option
623
+ value="${policy.id}"
624
+ ?selected="${policy.id ===
625
+ this.bundleAccessPolicy}"
626
+ >
627
+ ${policy.name}
628
+ </option>`;
629
+ })}
630
+ </select>
631
+ </div>
632
+ <div class="select">
633
+ <tems-label
634
+ label=${msg("Contract policy")}
635
+ ></tems-label>
636
+ <select @change=${this._selectBundleContractPolicy}>
637
+ ${this.policyTemplates.map((policy) => {
638
+ return html`<option
639
+ value="${policy.id}"
640
+ ?selected="${policy.id ===
641
+ this.bundleContractPolicy}"
642
+ >
643
+ ${policy.name}
644
+ </option>`;
645
+ })}
646
+ </select>
647
+ </div>
648
+ </div>`}
556
649
  </section>
557
650
  </div>
558
651
  </tems-viewport>`;
@@ -95,7 +95,9 @@ export class SolidFactBundle extends OrbitComponent {
95
95
  `[uniq="${this.orbit?.getComponent("menu")?.uniq}"]`,
96
96
  );
97
97
 
98
- this.bundleCreationComponent = this.orbit?.components.find((c) => c.type === "fact-bundle-creation");
98
+ this.bundleCreationComponent = this.orbit?.components.find(
99
+ (c) => c.type === "fact-bundle-creation",
100
+ );
99
101
 
100
102
  return Promise.resolve();
101
103
  }
@@ -145,7 +147,10 @@ export class SolidFactBundle extends OrbitComponent {
145
147
  this.dataSrc = dataSrc;
146
148
  }
147
149
 
148
- return sort(this.objects, "name", "asc");
150
+ if (this.objects.length > 0) {
151
+ return sort(this.objects, "name", "asc");
152
+ }
153
+ return [];
149
154
  },
150
155
  args: () => [
151
156
  this.defaultDataSrc,
@@ -225,14 +230,14 @@ export class SolidFactBundle extends OrbitComponent {
225
230
  </div>
226
231
  </tems-header>
227
232
  <div slot="content">
228
- <tems-catalog-filter-holder
233
+ <ds4go-catalog-filter-holder
229
234
  .displayFiltering=${this.displayFiltering}
230
235
  @search=${this._search}
231
236
  .search=${this.search}
232
237
  .objects=${datas}
233
238
  .resultCount=${this.resultCount}
234
239
  .filterCount=${this.filterCount}
235
- ></tems-catalog-filter-holder>
240
+ ></ds4go-catalog-filter-holder>
236
241
  <ds4go-fact-bundle-holder
237
242
  .objects=${datas}
238
243
  .search=${this.search}
@@ -98,20 +98,19 @@ export default class extends ComponentObjectsHandler {
98
98
  }
99
99
  }
100
100
  }
101
-
102
- await this._afterAttach();
103
-
104
- this.ready = true;
105
- this.dispatchEvent(
106
- new CustomEvent("component-ready", {
107
- detail: {
108
- component: this.component,
109
- },
110
- }),
111
- );
112
-
113
- return Promise.resolve(true);
114
101
  }
102
+ await this._afterAttach();
103
+
104
+ this.ready = true;
105
+ this.dispatchEvent(
106
+ new CustomEvent("component-ready", {
107
+ detail: {
108
+ component: this.component,
109
+ },
110
+ }),
111
+ );
112
+
113
+ return Promise.resolve(true);
115
114
  }
116
115
  }
117
116
  return Promise.resolve(false);
@@ -10,8 +10,15 @@ const localizedTemplates: Map<string, any> = new Map(
10
10
  ]),
11
11
  );
12
12
 
13
- export const { getLocale, setLocale } = configureLocalization({
14
- sourceLocale,
15
- targetLocales,
16
- loadLocale: async (locale) => localizedTemplates.get(locale),
17
- });
13
+ export const { getLocale, setLocale } = !import.meta.env.BASE_URL.includes(
14
+ "cypress",
15
+ )
16
+ ? configureLocalization({
17
+ sourceLocale,
18
+ targetLocales,
19
+ loadLocale: async (locale) => localizedTemplates.get(locale),
20
+ })
21
+ : {
22
+ getLocale: () => sourceLocale,
23
+ setLocale: () => {},
24
+ };
@@ -1,7 +1,6 @@
1
1
  import { ComponentObjectHandler } from "@helpers/components/componentObjectHandler";
2
2
  import { ComponentObjectsHandler } from "@helpers/components/componentObjectsHandler";
3
3
  import OrbitComponent from "@helpers/components/orbitComponent";
4
- import dspComponent from "@helpers/components/orbitDspComponent";
5
4
  import setupCacheInvalidation from "@helpers/components/setupCacheInvalidation";
6
5
  import setupCacheOnResourceReady from "@helpers/components/setupCacheOnResourceReady";
7
6
  import setupComponentSubscriptions from "@helpers/components/setupComponentSubscriptions";
@@ -21,7 +20,6 @@ import uniq from "@helpers/utils/uniq";
21
20
  import CLIENT_CONTEXT from "@src/context.json";
22
21
 
23
22
  export {
24
- dspComponent,
25
23
  CLIENT_CONTEXT,
26
24
  filterGenerator,
27
25
  filterObjectByDateAfter,