@pod-os/elements 0.29.1-rc.1eba81c.0 → 0.29.1-rc.7bb3cef.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.
@@ -11423,51 +11423,66 @@ const AvailableTools = {
11423
11423
  element: 'pos-app-generic',
11424
11424
  label: 'Generic',
11425
11425
  icon: 'list-ul',
11426
+ types: [],
11426
11427
  },
11427
11428
  RdfDocument: {
11428
11429
  element: 'pos-app-rdf-document',
11429
11430
  label: 'RDF Document',
11430
11431
  icon: 'file-earmark-ruled',
11432
+ types: [
11433
+ {
11434
+ type: 'http://www.w3.org/2007/ont/link#RDFDocument',
11435
+ priority: 20,
11436
+ },
11437
+ ],
11431
11438
  },
11432
11439
  DocumentViewer: {
11433
11440
  element: 'pos-app-document-viewer',
11434
11441
  label: 'Document',
11435
11442
  icon: 'file-text',
11443
+ types: [
11444
+ {
11445
+ type: mimeType('application/pdf'),
11446
+ priority: 30,
11447
+ },
11448
+ {
11449
+ type: 'http://www.w3.org/2007/ont/link#Document',
11450
+ priority: 10,
11451
+ },
11452
+ ],
11436
11453
  },
11437
11454
  ImageViewer: {
11438
11455
  element: 'pos-app-image-viewer',
11439
11456
  label: 'Image',
11440
11457
  icon: 'file-image',
11458
+ types: [
11459
+ {
11460
+ type: 'http://purl.org/dc/terms/Image',
11461
+ priority: 20,
11462
+ },
11463
+ ],
11441
11464
  },
11442
11465
  LdpContainer: {
11443
11466
  element: 'pos-app-ldp-container',
11444
11467
  label: 'Container',
11445
11468
  icon: 'folder',
11469
+ types: [{ type: 'http://www.w3.org/ns/ldp#Container', priority: 30 }],
11446
11470
  },
11447
11471
  };
11448
- // TODO: remove duplication with pos-container-contents/selectIconForTypes
11449
- function containsType(types, typeUri) {
11450
- return types.some(type => type.uri === typeUri);
11472
+ function mimeType(mimeType) {
11473
+ return 'http://www.w3.org/ns/iana/media-types/' + mimeType + '#Resource';
11451
11474
  }
11452
11475
  function selectToolsForTypes(types) {
11453
- if (containsType(types, 'http://www.w3.org/ns/ldp#Container')) {
11454
- return [AvailableTools.LdpContainer, AvailableTools.Generic];
11455
- }
11456
- else if (containsType(types, 'http://www.w3.org/2007/ont/link#RDFDocument')) {
11457
- return [AvailableTools.RdfDocument, AvailableTools.Generic];
11458
- }
11459
- else if (containsType(types, 'http://www.w3.org/ns/iana/media-types/application/pdf#Resource')) {
11460
- return [AvailableTools.DocumentViewer, AvailableTools.Generic];
11461
- }
11462
- else if (containsType(types, 'http://purl.org/dc/terms/Image')) {
11463
- return [AvailableTools.ImageViewer, AvailableTools.Generic];
11464
- }
11465
- else if (containsType(types, 'http://www.w3.org/2007/ont/link#Document')) {
11466
- return [AvailableTools.DocumentViewer, AvailableTools.Generic];
11467
- }
11468
- else {
11469
- return [AvailableTools.Generic];
11470
- }
11476
+ const result = [];
11477
+ Object.values(AvailableTools).forEach(tool => {
11478
+ const matchingTypes = tool.types.filter(typePriority => types.some(type => type.uri === typePriority.type));
11479
+ if (matchingTypes.length > 0) {
11480
+ const highestPriority = Math.max(...matchingTypes.map(t => t.priority));
11481
+ result.push({ tool, priority: highestPriority });
11482
+ }
11483
+ });
11484
+ result.push({ tool: AvailableTools.Generic, priority: 0 });
11485
+ return result.toSorted((a, b) => b.priority - a.priority).map(item => item.tool);
11471
11486
  }
11472
11487
 
11473
11488
  const posTypeRouterCss = "section {\n display: flex;\n flex-direction: row;\n}\n\nsection > :last-child {\n flex-grow: 1;\n}\n\n@media (max-width: 640px) {\n section {\n --toolbar-size: var(--size-14);\n flex-direction: column-reverse;\n padding-bottom: var(--toolbar-size);\n pos-tool-select {\n --button-size: var(--toolbar-size);\n }\n }\n}\n";