@seshuk/payload-media-preview 1.0.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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +507 -0
  3. package/dist/components/Cell/Cell.client.d.ts +18 -0
  4. package/dist/components/Cell/Cell.client.js +131 -0
  5. package/dist/components/Cell/Cell.scss +43 -0
  6. package/dist/components/Cell/Cell.server.d.ts +11 -0
  7. package/dist/components/Cell/Cell.server.js +33 -0
  8. package/dist/components/ExternalLinkIcon/ExternalLinkIcon.d.ts +5 -0
  9. package/dist/components/ExternalLinkIcon/ExternalLinkIcon.js +17 -0
  10. package/dist/components/ExternalLinkIcon/ExternalLinkIcon.scss +19 -0
  11. package/dist/components/Field/Field.d.ts +18 -0
  12. package/dist/components/Field/Field.js +107 -0
  13. package/dist/components/Field/Field.scss +14 -0
  14. package/dist/components/MediaPreview.constants.d.ts +4 -0
  15. package/dist/components/MediaPreview.constants.js +28 -0
  16. package/dist/components/MediaPreview.d.ts +10 -0
  17. package/dist/components/MediaPreview.js +57 -0
  18. package/dist/components/MediaPreview.types.d.ts +2 -0
  19. package/dist/components/MediaPreview.types.js +1 -0
  20. package/dist/components/MediaPreview.utils.d.ts +6 -0
  21. package/dist/components/MediaPreview.utils.js +38 -0
  22. package/dist/components/Modal/Modal.constants.d.ts +16 -0
  23. package/dist/components/Modal/Modal.constants.js +16 -0
  24. package/dist/components/Modal/Modal.d.ts +19 -0
  25. package/dist/components/Modal/Modal.js +277 -0
  26. package/dist/components/Modal/Modal.scss +173 -0
  27. package/dist/components/Viewer/AudioViewer.d.ts +3 -0
  28. package/dist/components/Viewer/AudioViewer.js +24 -0
  29. package/dist/components/Viewer/IframeViewer.d.ts +3 -0
  30. package/dist/components/Viewer/IframeViewer.js +14 -0
  31. package/dist/components/Viewer/ImageViewer.d.ts +3 -0
  32. package/dist/components/Viewer/ImageViewer.js +10 -0
  33. package/dist/components/Viewer/VideoViewer.d.ts +3 -0
  34. package/dist/components/Viewer/VideoViewer.js +25 -0
  35. package/dist/components/Viewer/Viewer.d.ts +12 -0
  36. package/dist/components/Viewer/Viewer.js +50 -0
  37. package/dist/components/adapterResolver.d.ts +13 -0
  38. package/dist/components/adapterResolver.js +43 -0
  39. package/dist/exports/client.d.ts +5 -0
  40. package/dist/exports/client.js +5 -0
  41. package/dist/exports/rsc.d.ts +2 -0
  42. package/dist/exports/rsc.js +2 -0
  43. package/dist/field.d.ts +18 -0
  44. package/dist/field.js +36 -0
  45. package/dist/index.d.ts +6 -0
  46. package/dist/index.js +90 -0
  47. package/dist/translations/index.d.ts +8 -0
  48. package/dist/translations/index.js +90 -0
  49. package/dist/translations/locales/ar.d.ts +2 -0
  50. package/dist/translations/locales/ar.js +11 -0
  51. package/dist/translations/locales/az.d.ts +2 -0
  52. package/dist/translations/locales/az.js +11 -0
  53. package/dist/translations/locales/bg.d.ts +2 -0
  54. package/dist/translations/locales/bg.js +11 -0
  55. package/dist/translations/locales/bnBd.d.ts +2 -0
  56. package/dist/translations/locales/bnBd.js +11 -0
  57. package/dist/translations/locales/bnIn.d.ts +2 -0
  58. package/dist/translations/locales/bnIn.js +11 -0
  59. package/dist/translations/locales/ca.d.ts +2 -0
  60. package/dist/translations/locales/ca.js +11 -0
  61. package/dist/translations/locales/cs.d.ts +2 -0
  62. package/dist/translations/locales/cs.js +11 -0
  63. package/dist/translations/locales/da.d.ts +2 -0
  64. package/dist/translations/locales/da.js +11 -0
  65. package/dist/translations/locales/de.d.ts +2 -0
  66. package/dist/translations/locales/de.js +11 -0
  67. package/dist/translations/locales/en.d.ts +2 -0
  68. package/dist/translations/locales/en.js +11 -0
  69. package/dist/translations/locales/es.d.ts +2 -0
  70. package/dist/translations/locales/es.js +11 -0
  71. package/dist/translations/locales/et.d.ts +2 -0
  72. package/dist/translations/locales/et.js +11 -0
  73. package/dist/translations/locales/fa.d.ts +2 -0
  74. package/dist/translations/locales/fa.js +11 -0
  75. package/dist/translations/locales/fr.d.ts +2 -0
  76. package/dist/translations/locales/fr.js +11 -0
  77. package/dist/translations/locales/he.d.ts +2 -0
  78. package/dist/translations/locales/he.js +11 -0
  79. package/dist/translations/locales/hr.d.ts +2 -0
  80. package/dist/translations/locales/hr.js +11 -0
  81. package/dist/translations/locales/hu.d.ts +2 -0
  82. package/dist/translations/locales/hu.js +11 -0
  83. package/dist/translations/locales/hy.d.ts +2 -0
  84. package/dist/translations/locales/hy.js +11 -0
  85. package/dist/translations/locales/id.d.ts +2 -0
  86. package/dist/translations/locales/id.js +11 -0
  87. package/dist/translations/locales/is.d.ts +2 -0
  88. package/dist/translations/locales/is.js +11 -0
  89. package/dist/translations/locales/it.d.ts +2 -0
  90. package/dist/translations/locales/it.js +11 -0
  91. package/dist/translations/locales/ja.d.ts +2 -0
  92. package/dist/translations/locales/ja.js +11 -0
  93. package/dist/translations/locales/ko.d.ts +2 -0
  94. package/dist/translations/locales/ko.js +11 -0
  95. package/dist/translations/locales/lt.d.ts +2 -0
  96. package/dist/translations/locales/lt.js +11 -0
  97. package/dist/translations/locales/lv.d.ts +2 -0
  98. package/dist/translations/locales/lv.js +11 -0
  99. package/dist/translations/locales/my.d.ts +2 -0
  100. package/dist/translations/locales/my.js +11 -0
  101. package/dist/translations/locales/nb.d.ts +2 -0
  102. package/dist/translations/locales/nb.js +11 -0
  103. package/dist/translations/locales/nl.d.ts +2 -0
  104. package/dist/translations/locales/nl.js +11 -0
  105. package/dist/translations/locales/pl.d.ts +2 -0
  106. package/dist/translations/locales/pl.js +11 -0
  107. package/dist/translations/locales/pt.d.ts +2 -0
  108. package/dist/translations/locales/pt.js +11 -0
  109. package/dist/translations/locales/ro.d.ts +2 -0
  110. package/dist/translations/locales/ro.js +11 -0
  111. package/dist/translations/locales/rs.d.ts +2 -0
  112. package/dist/translations/locales/rs.js +11 -0
  113. package/dist/translations/locales/rsLatin.d.ts +2 -0
  114. package/dist/translations/locales/rsLatin.js +11 -0
  115. package/dist/translations/locales/ru.d.ts +2 -0
  116. package/dist/translations/locales/ru.js +11 -0
  117. package/dist/translations/locales/sk.d.ts +2 -0
  118. package/dist/translations/locales/sk.js +11 -0
  119. package/dist/translations/locales/sl.d.ts +2 -0
  120. package/dist/translations/locales/sl.js +11 -0
  121. package/dist/translations/locales/sv.d.ts +2 -0
  122. package/dist/translations/locales/sv.js +11 -0
  123. package/dist/translations/locales/ta.d.ts +2 -0
  124. package/dist/translations/locales/ta.js +11 -0
  125. package/dist/translations/locales/th.d.ts +2 -0
  126. package/dist/translations/locales/th.js +11 -0
  127. package/dist/translations/locales/tr.d.ts +2 -0
  128. package/dist/translations/locales/tr.js +11 -0
  129. package/dist/translations/locales/uk.d.ts +2 -0
  130. package/dist/translations/locales/uk.js +11 -0
  131. package/dist/translations/locales/vi.d.ts +2 -0
  132. package/dist/translations/locales/vi.js +11 -0
  133. package/dist/translations/locales/zh.d.ts +2 -0
  134. package/dist/translations/locales/zh.js +11 -0
  135. package/dist/translations/locales/zhTw.d.ts +2 -0
  136. package/dist/translations/locales/zhTw.js +11 -0
  137. package/dist/translations/types.d.ts +11 -0
  138. package/dist/translations/types.js +1 -0
  139. package/dist/types.d.ts +130 -0
  140. package/dist/types.js +2 -0
  141. package/dist/utils/insertField.d.ts +3 -0
  142. package/dist/utils/insertField.js +97 -0
  143. package/package.json +121 -0
@@ -0,0 +1,11 @@
1
+ export const ko = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: '닫기',
4
+ label: '미리보기',
5
+ open: '열기',
6
+ titleAudio: '오디오 미리보기',
7
+ titleDocument: '문서 미리보기',
8
+ titleImage: '이미지 미리보기',
9
+ titleVideo: '비디오 미리보기'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const lt: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const lt = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Uždaryti',
4
+ label: 'Peržiūra',
5
+ open: 'Atidaryti',
6
+ titleAudio: 'Garso peržiūra',
7
+ titleDocument: 'Dokumento peržiūra',
8
+ titleImage: 'Vaizdo peržiūra',
9
+ titleVideo: 'Video peržiūra'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const lv: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const lv = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Aizvērt',
4
+ label: 'Priekšskatījums',
5
+ open: 'Atvērt',
6
+ titleAudio: 'Audio priekšskatījums',
7
+ titleDocument: 'Dokumenta priekšskatījums',
8
+ titleImage: 'Attēla priekšskatījums',
9
+ titleVideo: 'Video priekšskatījums'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const my: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const my = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'ပိတ်မည်',
4
+ label: 'အစမ်းကြည့်ရှုခြင်း',
5
+ open: 'ဖွင့်မည်',
6
+ titleAudio: 'အသံ အကြိုကြည့်ရှုခြင်း',
7
+ titleDocument: 'စာရွက်စာတမ်း အကြိုကြည့်ရှုခြင်း',
8
+ titleImage: 'ပုံ အကြိုကြည့်ရှုခြင်း',
9
+ titleVideo: 'ဗီဒီယို အကြိုကြည့်ရှုခြင်း'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const nb: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const nb = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Lukk',
4
+ label: 'Forhåndsvisning',
5
+ open: 'Åpne',
6
+ titleAudio: 'Lydforhåndsvisning',
7
+ titleDocument: 'Dokumentforhåndsvisning',
8
+ titleImage: 'Bildeforhåndsvisning',
9
+ titleVideo: 'Videoforhåndsvisning'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const nl: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const nl = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Sluiten',
4
+ label: 'Voorbeeld',
5
+ open: 'Openen',
6
+ titleAudio: 'Audio preview',
7
+ titleDocument: 'Document preview',
8
+ titleImage: 'Afbeelding preview',
9
+ titleVideo: 'Video preview'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const pl: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const pl = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Zamknij',
4
+ label: 'Podgląd',
5
+ open: 'Otwórz',
6
+ titleAudio: 'Podgląd audio',
7
+ titleDocument: 'Podgląd dokumentu',
8
+ titleImage: 'Podgląd obrazu',
9
+ titleVideo: 'Podgląd wideo'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const pt: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const pt = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Fechar',
4
+ label: 'Visualização',
5
+ open: 'Abrir',
6
+ titleAudio: 'Pré-visualização de áudio',
7
+ titleDocument: 'Pré-visualização de documento',
8
+ titleImage: 'Pré-visualização de imagem',
9
+ titleVideo: 'Pré-visualização de vídeo'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const ro: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const ro = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Închide',
4
+ label: 'Previzualizare',
5
+ open: 'Deschide',
6
+ titleAudio: 'Previzualizare audio',
7
+ titleDocument: 'Previzualizare document',
8
+ titleImage: 'Previzualizare imagine',
9
+ titleVideo: 'Previzualizare video'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const rs: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const rs = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Затвори',
4
+ label: 'Преглед',
5
+ open: 'Отвори',
6
+ titleAudio: 'Преглед аудиа',
7
+ titleDocument: 'Преглед документа',
8
+ titleImage: 'Преглед слике',
9
+ titleVideo: 'Преглед видеа'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const rsLatin: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const rsLatin = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Zatvori',
4
+ label: 'Pregled',
5
+ open: 'Otvori',
6
+ titleAudio: 'Pregled audia',
7
+ titleDocument: 'Pregled dokumenta',
8
+ titleImage: 'Pregled slike',
9
+ titleVideo: 'Pregled videa'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const ru: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const ru = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Закрыть',
4
+ label: 'Предпросмотр',
5
+ open: 'Открыть',
6
+ titleAudio: 'Предпросмотр аудио',
7
+ titleDocument: 'Предпросмотр документа',
8
+ titleImage: 'Предпросмотр изображения',
9
+ titleVideo: 'Предпросмотр видео'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const sk: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const sk = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Zavrieť',
4
+ label: 'Náhľad',
5
+ open: 'Otvoriť',
6
+ titleAudio: 'Náhľad audia',
7
+ titleDocument: 'Náhľad dokumentu',
8
+ titleImage: 'Náhľad obrázka',
9
+ titleVideo: 'Náhľad videa'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const sl: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const sl = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Zapri',
4
+ label: 'Predogled',
5
+ open: 'Odpri',
6
+ titleAudio: 'Predogled zvoka',
7
+ titleDocument: 'Predogled dokumenta',
8
+ titleImage: 'Predogled slike',
9
+ titleVideo: 'Predogled videa'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const sv: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const sv = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Stäng',
4
+ label: 'Förhandsgranskning',
5
+ open: 'Öppna',
6
+ titleAudio: 'Ljudförhandsgranskning',
7
+ titleDocument: 'Dokumentförhandsgranskning',
8
+ titleImage: 'Bildförhandsgranskning',
9
+ titleVideo: 'Videoförhandsgranskning'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const ta: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const ta = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'மூடு',
4
+ label: 'முன்னோட்டம்',
5
+ open: 'திற',
6
+ titleAudio: 'ஆடியோ முன்னோட்டம்',
7
+ titleDocument: 'ஆவண முன்னோட்டம்',
8
+ titleImage: 'படம் முன்னோட்டம்',
9
+ titleVideo: 'வீடியோ முன்னோட்டம்'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const th: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const th = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'ปิด',
4
+ label: 'ตัวอย่าง',
5
+ open: 'เปิด',
6
+ titleAudio: 'ดูตัวอย่างเสียง',
7
+ titleDocument: 'ดูตัวอย่างเอกสาร',
8
+ titleImage: 'ดูตัวอย่างรูปภาพ',
9
+ titleVideo: 'ดูตัวอย่างวิดีโอ'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const tr: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const tr = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Kapat',
4
+ label: 'Önizleme',
5
+ open: 'Aç',
6
+ titleAudio: 'Ses önizleme',
7
+ titleDocument: 'Belge önizleme',
8
+ titleImage: 'Resim önizleme',
9
+ titleVideo: 'Video önizleme'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const uk: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const uk = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Закрити',
4
+ label: 'Попередній перегляд',
5
+ open: 'Відкрити',
6
+ titleAudio: 'Попередній перегляд аудіо',
7
+ titleDocument: 'Попередній перегляд документа',
8
+ titleImage: 'Попередній перегляд зображення',
9
+ titleVideo: 'Попередній перегляд відео'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const vi: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const vi = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: 'Đóng',
4
+ label: 'Xem trước',
5
+ open: 'Mở',
6
+ titleAudio: 'Xem trước âm thanh',
7
+ titleDocument: 'Xem trước tài liệu',
8
+ titleImage: 'Xem trước hình ảnh',
9
+ titleVideo: 'Xem trước video'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const zh: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const zh = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: '关闭',
4
+ label: '预览',
5
+ open: '打开',
6
+ titleAudio: '音频预览',
7
+ titleDocument: '文档预览',
8
+ titleImage: '图片预览',
9
+ titleVideo: '视频预览'
10
+ }
11
+ };
@@ -0,0 +1,2 @@
1
+ import type { PluginDefaultTranslationsObject } from '../types.js';
2
+ export declare const zhTw: PluginDefaultTranslationsObject;
@@ -0,0 +1,11 @@
1
+ export const zhTw = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: '關閉',
4
+ label: '預覽',
5
+ open: '開啟',
6
+ titleAudio: '音訊預覽',
7
+ titleDocument: '文件預覽',
8
+ titleImage: '圖片預覽',
9
+ titleVideo: '影片預覽'
10
+ }
11
+ };
@@ -0,0 +1,11 @@
1
+ export type PluginDefaultTranslationsObject = {
2
+ '@seshuk/payload-media-preview': {
3
+ close: string;
4
+ label: string;
5
+ open: string;
6
+ titleAudio: string;
7
+ titleDocument: string;
8
+ titleImage: string;
9
+ titleVideo: string;
10
+ };
11
+ };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,130 @@
1
+ import type { Plugin, UIField, UploadCollectionSlug } from 'payload';
2
+ export type VideoViewerProps = {
3
+ autoPlay?: boolean;
4
+ className?: string;
5
+ controls?: boolean;
6
+ loop?: boolean;
7
+ mimeType?: string;
8
+ muted?: boolean;
9
+ preload?: 'auto' | 'metadata' | 'none';
10
+ src: string;
11
+ title?: string;
12
+ };
13
+ export type AudioViewerProps = {
14
+ autoPlay?: boolean;
15
+ className?: string;
16
+ controls?: boolean;
17
+ loop?: boolean;
18
+ mimeType?: string;
19
+ muted?: boolean;
20
+ preload?: 'auto' | 'metadata' | 'none';
21
+ src: string;
22
+ title?: string;
23
+ };
24
+ export type ImageViewerProps = {
25
+ alt?: string;
26
+ className?: string;
27
+ src: string;
28
+ };
29
+ export type IframeViewerProps = {
30
+ allow?: string;
31
+ allowFullScreen?: boolean;
32
+ className?: string;
33
+ loading?: 'eager' | 'lazy';
34
+ src: string;
35
+ title?: string;
36
+ };
37
+ export type MediaPreviewAdapterResolveArgs = {
38
+ doc: Record<string, unknown>;
39
+ mimeType?: string;
40
+ url?: string;
41
+ };
42
+ /** Returned by `resolve()` to render the adapter's component inside a modal. */
43
+ export type MediaPreviewAdapterInlineResult = {
44
+ mode: 'inline';
45
+ props: Record<string, unknown>;
46
+ };
47
+ /** Returned by `resolve()` to open a URL in a new browser tab. */
48
+ export type MediaPreviewAdapterNewTabResult = {
49
+ mode: 'newTab';
50
+ url: string;
51
+ };
52
+ export type MediaPreviewAdapterResolveResult = MediaPreviewAdapterInlineResult | MediaPreviewAdapterNewTabResult;
53
+ /** Adapters are tried in order — first non-null `resolve()` result wins. */
54
+ export type MediaPreviewAdapter = {
55
+ /**
56
+ * Import path for the viewer component (e.g. `'my-pkg/client#Player'`).
57
+ * Only needed when `resolve()` can return `mode: 'inline'`.
58
+ */
59
+ Component?: string;
60
+ name: string;
61
+ /**
62
+ * Decide how to preview a document.
63
+ *
64
+ * - Return `{ mode: 'inline', props }` to render `Component` in a modal.
65
+ * - Return `{ mode: 'newTab', url }` to open a link in a new tab.
66
+ * - Return `null` to skip this adapter.
67
+ */
68
+ resolve: (args: MediaPreviewAdapterResolveArgs) => MediaPreviewAdapterResolveResult | null;
69
+ };
70
+ export type InsertPosition = 'first' | 'last' | {
71
+ after: string;
72
+ before?: never;
73
+ } | {
74
+ after?: never;
75
+ before: string;
76
+ };
77
+ export type MediaPreviewContentType = 'audio' | 'document' | 'image' | 'video';
78
+ export type MediaPreviewContentModeType = 'inline' | 'newTab';
79
+ /** `'auto'` adapts to context and device, `'fullscreen'` always uses a modal. */
80
+ export type MediaPreviewMode = 'auto' | 'fullscreen';
81
+ /**
82
+ * Controls how each content type is opened.
83
+ *
84
+ * - `'inline'` — show content in a modal preview.
85
+ * - `'newTab'` — open content in a new browser tab.
86
+ *
87
+ * @default 'inline' for all content types
88
+ */
89
+ export type MediaPreviewContentMode = Record<MediaPreviewContentType, MediaPreviewContentModeType>;
90
+ export type MediaPreviewFieldConfig = {
91
+ /** Payload UI field overrides (`name` and `type` cannot be changed). */
92
+ overrides?: Partial<Omit<UIField, 'name' | 'type'>>;
93
+ /** @default 'last' */
94
+ position?: InsertPosition;
95
+ };
96
+ export type MediaPreviewCollectionConfig = {
97
+ /** Overrides global adapters when set. */
98
+ adapters?: MediaPreviewAdapter[];
99
+ contentMode?: Partial<MediaPreviewContentMode>;
100
+ /**
101
+ * Controls field injection into the collection.
102
+ *
103
+ * - Omit or pass `{}` to inject with defaults.
104
+ * - Pass `{ position, overrides }` to customize the injected field.
105
+ * - Set to `false` to skip injection (for manual placement via `mediaPreviewField()`).
106
+ */
107
+ field?: false | MediaPreviewFieldConfig;
108
+ /**
109
+ * Preview display mode.
110
+ *
111
+ * - `'auto'` — popup in cell (desktop), fullscreen in field and on mobile.
112
+ * - `'fullscreen'` — always fullscreen modal.
113
+ * @default 'auto'
114
+ */
115
+ mode?: MediaPreviewMode;
116
+ };
117
+ export type MediaPreviewPluginConfig = {
118
+ /** Adapters available to all collections. */
119
+ adapters?: MediaPreviewAdapter[];
120
+ /** Use `true` for defaults or an object for fine-tuning. */
121
+ collections: Partial<Record<UploadCollectionSlug, MediaPreviewCollectionConfig | true>>;
122
+ /** @default true */
123
+ enabled?: boolean;
124
+ };
125
+ export type MediaPreviewPlugin = (pluginConfig: MediaPreviewPluginConfig) => Plugin;
126
+ export type MediaPreviewFieldProps = {
127
+ adapterNames?: string[];
128
+ contentMode?: Partial<MediaPreviewContentMode>;
129
+ mode?: MediaPreviewMode;
130
+ };
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ // Internal props
2
+ export { };
@@ -0,0 +1,3 @@
1
+ import type { InsertPosition } from '@/types.js';
2
+ import type { Field } from 'payload';
3
+ export declare const insertField: (fields: Field[], position: InsertPosition, fieldToInsert: Field) => Field[];
@@ -0,0 +1,97 @@
1
+ export const insertField = (fields, position, fieldToInsert)=>{
2
+ if (position === 'first') {
3
+ return [
4
+ fieldToInsert,
5
+ ...fields
6
+ ];
7
+ }
8
+ if (position === 'last') {
9
+ return [
10
+ ...fields,
11
+ fieldToInsert
12
+ ];
13
+ }
14
+ if ('after' in position && position.after) {
15
+ return insertFieldByPath(fields, position.after, fieldToInsert, 'after');
16
+ }
17
+ if ('before' in position && position.before) {
18
+ return insertFieldByPath(fields, position.before, fieldToInsert, 'before');
19
+ }
20
+ return fields;
21
+ };
22
+ const insertFieldByPath = (fields, targetPath, fieldToInsert, placement)=>{
23
+ const pathParts = targetPath.split('.');
24
+ const [currentPart, ...remainingParts] = pathParts;
25
+ if (remainingParts.length === 0) {
26
+ const targetIndex = fields.findIndex((f)=>'name' in f && f.name === currentPart);
27
+ if (targetIndex !== -1) {
28
+ const insertIndex = placement === 'before' ? targetIndex : targetIndex + 1;
29
+ return [
30
+ ...fields.slice(0, insertIndex),
31
+ fieldToInsert,
32
+ ...fields.slice(insertIndex)
33
+ ];
34
+ }
35
+ return fields;
36
+ }
37
+ return fields.map((field)=>{
38
+ if ('name' in field && field.name === currentPart) {
39
+ const remainingPath = remainingParts.join('.');
40
+ if ('fields' in field && Array.isArray(field.fields)) {
41
+ return {
42
+ ...field,
43
+ fields: insertFieldByPath(field.fields, remainingPath, fieldToInsert, placement)
44
+ };
45
+ }
46
+ if ('tabs' in field && Array.isArray(field.tabs)) {
47
+ const tabIndex = parseInt(remainingParts[0]);
48
+ if (!isNaN(tabIndex) && field.tabs[tabIndex]) {
49
+ const tabRemainingPath = remainingParts.slice(1).join('.');
50
+ const updatedTabs = [
51
+ ...field.tabs
52
+ ];
53
+ if ('fields' in updatedTabs[tabIndex] && Array.isArray(updatedTabs[tabIndex].fields)) {
54
+ updatedTabs[tabIndex] = {
55
+ ...updatedTabs[tabIndex],
56
+ fields: insertFieldByPath(updatedTabs[tabIndex].fields, tabRemainingPath, fieldToInsert, placement)
57
+ };
58
+ }
59
+ return {
60
+ ...field,
61
+ tabs: updatedTabs
62
+ };
63
+ }
64
+ }
65
+ }
66
+ if ('fields' in field && Array.isArray(field.fields)) {
67
+ const updatedFields = insertFieldByPath(field.fields, targetPath, fieldToInsert, placement);
68
+ if (updatedFields !== field.fields) {
69
+ return {
70
+ ...field,
71
+ fields: updatedFields
72
+ };
73
+ }
74
+ }
75
+ if ('tabs' in field && Array.isArray(field.tabs)) {
76
+ const updatedTabs = field.tabs.map((tab)=>{
77
+ if ('fields' in tab && Array.isArray(tab.fields)) {
78
+ const updatedFields = insertFieldByPath(tab.fields, targetPath, fieldToInsert, placement);
79
+ if (updatedFields !== tab.fields) {
80
+ return {
81
+ ...tab,
82
+ fields: updatedFields
83
+ };
84
+ }
85
+ }
86
+ return tab;
87
+ });
88
+ if (JSON.stringify(updatedTabs) !== JSON.stringify(field.tabs)) {
89
+ return {
90
+ ...field,
91
+ tabs: updatedTabs
92
+ };
93
+ }
94
+ }
95
+ return field;
96
+ });
97
+ };