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