@ndla/ui 56.0.123-alpha.0 → 56.0.124-alpha.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 (347) hide show
  1. package/es/Article/Article.js +122 -194
  2. package/es/Article/Article.js.map +1 -0
  3. package/es/Article/ArticleByline.js +121 -170
  4. package/es/Article/ArticleByline.js.map +1 -0
  5. package/es/Article/ArticleFootNotes.js +38 -58
  6. package/es/Article/ArticleFootNotes.js.map +1 -0
  7. package/es/AudioPlayer/AudioPlayer.js +151 -212
  8. package/es/AudioPlayer/AudioPlayer.js.map +1 -0
  9. package/es/AudioPlayer/Controls.js +246 -324
  10. package/es/AudioPlayer/Controls.js.map +1 -0
  11. package/es/AudioPlayer/SpeechControl.js +36 -52
  12. package/es/AudioPlayer/SpeechControl.js.map +1 -0
  13. package/es/AudioPlayer/index.js +7 -9
  14. package/es/AudioPlayer/index.js.map +1 -0
  15. package/es/Breadcrumb/Breadcrumb.js +42 -58
  16. package/es/Breadcrumb/Breadcrumb.js.map +1 -0
  17. package/es/Breadcrumb/BreadcrumbItem.js +33 -59
  18. package/es/Breadcrumb/BreadcrumbItem.js.map +1 -0
  19. package/es/Breadcrumb/HomeBreadcrumb.js +41 -74
  20. package/es/Breadcrumb/HomeBreadcrumb.js.map +1 -0
  21. package/es/Breadcrumb/index.js +8 -10
  22. package/es/Breadcrumb/index.js.map +1 -0
  23. package/es/CampaignBlock/CampaignBlock.js +124 -173
  24. package/es/CampaignBlock/CampaignBlock.js.map +1 -0
  25. package/es/CodeBlock/CodeBlock.js +21 -31
  26. package/es/CodeBlock/CodeBlock.js.map +1 -0
  27. package/es/CodeBlock/codeLanguageOptions.js +112 -82
  28. package/es/CodeBlock/codeLanguageOptions.js.map +1 -0
  29. package/es/Concept/Concept.js +46 -68
  30. package/es/Concept/Concept.js.map +1 -0
  31. package/es/ContactBlock/ContactBlock.js +137 -191
  32. package/es/ContactBlock/ContactBlock.js.map +1 -0
  33. package/es/ContentTypeBadge/ContentTypeBadge.js +38 -47
  34. package/es/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
  35. package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +21 -28
  36. package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
  37. package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +21 -28
  38. package/es/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
  39. package/es/ContentTypeHero/ContentTypeHero.js +36 -47
  40. package/es/ContentTypeHero/ContentTypeHero.js.map +1 -0
  41. package/es/CopyParagraphButton/CopyParagraphButton.js +57 -78
  42. package/es/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
  43. package/es/CopyParagraphButton/index.js +7 -10
  44. package/es/CopyParagraphButton/index.js.map +1 -0
  45. package/es/Embed/AudioEmbed.js +49 -73
  46. package/es/Embed/AudioEmbed.js.map +1 -0
  47. package/es/Embed/BrightcoveEmbed.js +90 -127
  48. package/es/Embed/BrightcoveEmbed.js.map +1 -0
  49. package/es/Embed/CodeEmbed.js +55 -73
  50. package/es/Embed/CodeEmbed.js.map +1 -0
  51. package/es/Embed/ConceptEmbed.js +72 -117
  52. package/es/Embed/ConceptEmbed.js.map +1 -0
  53. package/es/Embed/ConceptInlineTriggerButton.js +39 -44
  54. package/es/Embed/ConceptInlineTriggerButton.js.map +1 -0
  55. package/es/Embed/ContentLinkEmbed.js +29 -49
  56. package/es/Embed/ContentLinkEmbed.js.map +1 -0
  57. package/es/Embed/CopyrightEmbed.js +21 -31
  58. package/es/Embed/CopyrightEmbed.js.map +1 -0
  59. package/es/Embed/EmbedErrorPlaceholder.js +40 -55
  60. package/es/Embed/EmbedErrorPlaceholder.js.map +1 -0
  61. package/es/Embed/EmbedWrapper.js +21 -46
  62. package/es/Embed/EmbedWrapper.js.map +1 -0
  63. package/es/Embed/ExternalEmbed.js +50 -70
  64. package/es/Embed/ExternalEmbed.js.map +1 -0
  65. package/es/Embed/FootnoteEmbed.js +25 -42
  66. package/es/Embed/FootnoteEmbed.js.map +1 -0
  67. package/es/Embed/GlossEmbed.js +49 -77
  68. package/es/Embed/GlossEmbed.js.map +1 -0
  69. package/es/Embed/H5pEmbed.js +35 -58
  70. package/es/Embed/H5pEmbed.js.map +1 -0
  71. package/es/Embed/IframeEmbed.js +65 -89
  72. package/es/Embed/IframeEmbed.js.map +1 -0
  73. package/es/Embed/ImageEmbed.js +167 -225
  74. package/es/Embed/ImageEmbed.js.map +1 -0
  75. package/es/Embed/InlineTriggerButton.js +20 -32
  76. package/es/Embed/InlineTriggerButton.js.map +1 -0
  77. package/es/Embed/RelatedContentEmbed.js +36 -53
  78. package/es/Embed/RelatedContentEmbed.js.map +1 -0
  79. package/es/Embed/UnknownEmbed.js +18 -29
  80. package/es/Embed/UnknownEmbed.js.map +1 -0
  81. package/es/Embed/UuDisclaimerEmbed.js +51 -85
  82. package/es/Embed/UuDisclaimerEmbed.js.map +1 -0
  83. package/es/ErrorMessage/ErrorMessage.js +51 -92
  84. package/es/ErrorMessage/ErrorMessage.js.map +1 -0
  85. package/es/ErrorMessage/index.js +7 -9
  86. package/es/ErrorMessage/index.js.map +1 -0
  87. package/es/FactBox/FactBox.js +114 -170
  88. package/es/FactBox/FactBox.js.map +1 -0
  89. package/es/FactBox/index.js +7 -9
  90. package/es/FactBox/index.js.map +1 -0
  91. package/es/FileList/File.js +70 -95
  92. package/es/FileList/File.js.map +1 -0
  93. package/es/FileList/FileList.js +31 -46
  94. package/es/FileList/FileList.js.map +1 -0
  95. package/es/FileList/PdfFile.js +27 -49
  96. package/es/FileList/PdfFile.js.map +1 -0
  97. package/es/Gloss/Gloss.js +133 -166
  98. package/es/Gloss/Gloss.js.map +1 -0
  99. package/es/Gloss/GlossExample.js +42 -60
  100. package/es/Gloss/GlossExample.js.map +1 -0
  101. package/es/Grid/Grid.js +63 -91
  102. package/es/Grid/Grid.js.map +1 -0
  103. package/es/Grid/GridParallaxItem.js +19 -30
  104. package/es/Grid/GridParallaxItem.js.map +1 -0
  105. package/es/KeyFigure/KeyFigure.js +44 -61
  106. package/es/KeyFigure/KeyFigure.js.map +1 -0
  107. package/es/LicenseByline/EmbedByline.js +126 -206
  108. package/es/LicenseByline/EmbedByline.js.map +1 -0
  109. package/es/LicenseByline/LicenseLink.js +28 -53
  110. package/es/LicenseByline/LicenseLink.js.map +1 -0
  111. package/es/LinkBlock/LinkBlock.js +70 -99
  112. package/es/LinkBlock/LinkBlock.js.map +1 -0
  113. package/es/LinkBlock/LinkBlockSection.js +20 -32
  114. package/es/LinkBlock/LinkBlockSection.js.map +1 -0
  115. package/es/Pitch/Pitch.js +59 -80
  116. package/es/Pitch/Pitch.js.map +1 -0
  117. package/es/RelatedArticleList/RelatedArticleList.js +91 -129
  118. package/es/RelatedArticleList/RelatedArticleList.js.map +1 -0
  119. package/es/RelatedArticleList/index.js +7 -10
  120. package/es/RelatedArticleList/index.js.map +1 -0
  121. package/es/ResourceBox/ResourceBox.js +71 -96
  122. package/es/ResourceBox/ResourceBox.js.map +1 -0
  123. package/es/TagSelector/TagSelector.js +93 -136
  124. package/es/TagSelector/TagSelector.js.map +1 -0
  125. package/es/ZendeskButton/ZendeskButton.js +38 -52
  126. package/es/ZendeskButton/ZendeskButton.js.map +1 -0
  127. package/es/_virtual/rolldown_runtime.js +11 -0
  128. package/es/i18n/formatNestedMessages.js +16 -24
  129. package/es/i18n/formatNestedMessages.js.map +1 -0
  130. package/es/i18n/i18n.js +25 -31
  131. package/es/i18n/i18n.js.map +1 -0
  132. package/es/i18n/useComponentTranslations.js +147 -203
  133. package/es/i18n/useComponentTranslations.js.map +1 -0
  134. package/es/index.js +64 -44
  135. package/es/locale/messages-en.js +435 -459
  136. package/es/locale/messages-en.js.map +1 -0
  137. package/es/locale/messages-nb.js +435 -459
  138. package/es/locale/messages-nb.js.map +1 -0
  139. package/es/locale/messages-nn.js +435 -459
  140. package/es/locale/messages-nn.js.map +1 -0
  141. package/es/locale/messages-se.js +435 -459
  142. package/es/locale/messages-se.js.map +1 -0
  143. package/es/model/ContentType.js +69 -65
  144. package/es/model/ContentType.js.map +1 -0
  145. package/es/model/SubjectCategories.js +23 -10
  146. package/es/model/SubjectCategories.js.map +1 -0
  147. package/es/model/SubjectTypes.js +21 -9
  148. package/es/model/SubjectTypes.js.map +1 -0
  149. package/es/model/WordClass.js +51 -43
  150. package/es/model/WordClass.js.map +1 -0
  151. package/es/model/index.js +16 -18
  152. package/es/model/index.js.map +1 -0
  153. package/es/utils/licenseAttributes.js +15 -17
  154. package/es/utils/licenseAttributes.js.map +1 -0
  155. package/es/utils/relativeUrl.js +21 -32
  156. package/es/utils/relativeUrl.js.map +1 -0
  157. package/lib/Article/Article.js +130 -203
  158. package/lib/Article/Article.js.map +1 -0
  159. package/lib/Article/ArticleByline.js +125 -179
  160. package/lib/Article/ArticleByline.js.map +1 -0
  161. package/lib/Article/ArticleFootNotes.js +39 -65
  162. package/lib/Article/ArticleFootNotes.js.map +1 -0
  163. package/lib/AudioPlayer/AudioPlayer.js +155 -221
  164. package/lib/AudioPlayer/AudioPlayer.js.map +1 -0
  165. package/lib/AudioPlayer/Controls.js +249 -332
  166. package/lib/AudioPlayer/Controls.js.map +1 -0
  167. package/lib/AudioPlayer/SpeechControl.js +39 -60
  168. package/lib/AudioPlayer/SpeechControl.js.map +1 -0
  169. package/lib/AudioPlayer/index.js +7 -15
  170. package/lib/AudioPlayer/index.js.map +1 -0
  171. package/lib/Breadcrumb/Breadcrumb.js +43 -65
  172. package/lib/Breadcrumb/Breadcrumb.js.map +1 -0
  173. package/lib/Breadcrumb/BreadcrumbItem.js +34 -65
  174. package/lib/Breadcrumb/BreadcrumbItem.js.map +1 -0
  175. package/lib/Breadcrumb/HomeBreadcrumb.js +43 -82
  176. package/lib/Breadcrumb/HomeBreadcrumb.js.map +1 -0
  177. package/lib/Breadcrumb/index.js +8 -22
  178. package/lib/Breadcrumb/index.js.map +1 -0
  179. package/lib/CampaignBlock/CampaignBlock.js +128 -183
  180. package/lib/CampaignBlock/CampaignBlock.js.map +1 -0
  181. package/lib/CodeBlock/CodeBlock.js +23 -38
  182. package/lib/CodeBlock/CodeBlock.js.map +1 -0
  183. package/lib/CodeBlock/codeLanguageOptions.js +112 -87
  184. package/lib/CodeBlock/codeLanguageOptions.js.map +1 -0
  185. package/lib/Concept/Concept.js +48 -75
  186. package/lib/Concept/Concept.js.map +1 -0
  187. package/lib/ContactBlock/ContactBlock.js +141 -200
  188. package/lib/ContactBlock/ContactBlock.js.map +1 -0
  189. package/lib/ContentTypeBadge/ContentTypeBadge.js +40 -54
  190. package/lib/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
  191. package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +23 -35
  192. package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
  193. package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +23 -35
  194. package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
  195. package/lib/ContentTypeHero/ContentTypeHero.js +37 -54
  196. package/lib/ContentTypeHero/ContentTypeHero.js.map +1 -0
  197. package/lib/CopyParagraphButton/CopyParagraphButton.js +61 -87
  198. package/lib/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
  199. package/lib/CopyParagraphButton/index.js +7 -21
  200. package/lib/CopyParagraphButton/index.js.map +1 -0
  201. package/lib/Embed/AudioEmbed.js +51 -82
  202. package/lib/Embed/AudioEmbed.js.map +1 -0
  203. package/lib/Embed/BrightcoveEmbed.js +93 -138
  204. package/lib/Embed/BrightcoveEmbed.js.map +1 -0
  205. package/lib/Embed/CodeEmbed.js +59 -83
  206. package/lib/Embed/CodeEmbed.js.map +1 -0
  207. package/lib/Embed/ConceptEmbed.js +77 -127
  208. package/lib/Embed/ConceptEmbed.js.map +1 -0
  209. package/lib/Embed/ConceptInlineTriggerButton.js +39 -49
  210. package/lib/Embed/ConceptInlineTriggerButton.js.map +1 -0
  211. package/lib/Embed/ContentLinkEmbed.js +30 -55
  212. package/lib/Embed/ContentLinkEmbed.js.map +1 -0
  213. package/lib/Embed/CopyrightEmbed.js +22 -37
  214. package/lib/Embed/CopyrightEmbed.js.map +1 -0
  215. package/lib/Embed/EmbedErrorPlaceholder.js +42 -62
  216. package/lib/Embed/EmbedErrorPlaceholder.js.map +1 -0
  217. package/lib/Embed/EmbedWrapper.js +24 -54
  218. package/lib/Embed/EmbedWrapper.js.map +1 -0
  219. package/lib/Embed/ExternalEmbed.js +53 -79
  220. package/lib/Embed/ExternalEmbed.js.map +1 -0
  221. package/lib/Embed/FootnoteEmbed.js +26 -48
  222. package/lib/Embed/FootnoteEmbed.js.map +1 -0
  223. package/lib/Embed/GlossEmbed.js +51 -86
  224. package/lib/Embed/GlossEmbed.js.map +1 -0
  225. package/lib/Embed/H5pEmbed.js +37 -66
  226. package/lib/Embed/H5pEmbed.js.map +1 -0
  227. package/lib/Embed/IframeEmbed.js +68 -98
  228. package/lib/Embed/IframeEmbed.js.map +1 -0
  229. package/lib/Embed/ImageEmbed.js +173 -238
  230. package/lib/Embed/ImageEmbed.js.map +1 -0
  231. package/lib/Embed/InlineTriggerButton.js +23 -40
  232. package/lib/Embed/InlineTriggerButton.js.map +1 -0
  233. package/lib/Embed/RelatedContentEmbed.js +37 -59
  234. package/lib/Embed/RelatedContentEmbed.js.map +1 -0
  235. package/lib/Embed/UnknownEmbed.js +19 -35
  236. package/lib/Embed/UnknownEmbed.js.map +1 -0
  237. package/lib/Embed/UuDisclaimerEmbed.js +53 -92
  238. package/lib/Embed/UuDisclaimerEmbed.js.map +1 -0
  239. package/lib/ErrorMessage/ErrorMessage.js +53 -99
  240. package/lib/ErrorMessage/ErrorMessage.js.map +1 -0
  241. package/lib/ErrorMessage/index.js +7 -15
  242. package/lib/ErrorMessage/index.js.map +1 -0
  243. package/lib/FactBox/FactBox.js +118 -180
  244. package/lib/FactBox/FactBox.js.map +1 -0
  245. package/lib/FactBox/index.js +7 -15
  246. package/lib/FactBox/index.js.map +1 -0
  247. package/lib/FileList/File.js +75 -105
  248. package/lib/FileList/File.js.map +1 -0
  249. package/lib/FileList/FileList.js +33 -52
  250. package/lib/FileList/FileList.js.map +1 -0
  251. package/lib/FileList/PdfFile.js +27 -55
  252. package/lib/FileList/PdfFile.js.map +1 -0
  253. package/lib/Gloss/Gloss.js +138 -176
  254. package/lib/Gloss/Gloss.js.map +1 -0
  255. package/lib/Gloss/GlossExample.js +45 -68
  256. package/lib/Gloss/GlossExample.js.map +1 -0
  257. package/lib/Grid/Grid.js +64 -98
  258. package/lib/Grid/Grid.js.map +1 -0
  259. package/lib/Grid/GridParallaxItem.js +19 -36
  260. package/lib/Grid/GridParallaxItem.js.map +1 -0
  261. package/lib/KeyFigure/KeyFigure.js +45 -68
  262. package/lib/KeyFigure/KeyFigure.js.map +1 -0
  263. package/lib/LicenseByline/EmbedByline.js +130 -216
  264. package/lib/LicenseByline/EmbedByline.js.map +1 -0
  265. package/lib/LicenseByline/LicenseLink.js +29 -59
  266. package/lib/LicenseByline/LicenseLink.js.map +1 -0
  267. package/lib/LinkBlock/LinkBlock.js +73 -108
  268. package/lib/LinkBlock/LinkBlock.js.map +1 -0
  269. package/lib/LinkBlock/LinkBlockSection.js +22 -39
  270. package/lib/LinkBlock/LinkBlockSection.js.map +1 -0
  271. package/lib/Pitch/Pitch.js +61 -89
  272. package/lib/Pitch/Pitch.js.map +1 -0
  273. package/lib/RelatedArticleList/RelatedArticleList.js +96 -140
  274. package/lib/RelatedArticleList/RelatedArticleList.js.map +1 -0
  275. package/lib/RelatedArticleList/index.js +7 -20
  276. package/lib/RelatedArticleList/index.js.map +1 -0
  277. package/lib/ResourceBox/ResourceBox.js +73 -104
  278. package/lib/ResourceBox/ResourceBox.js.map +1 -0
  279. package/lib/TagSelector/TagSelector.js +103 -145
  280. package/lib/TagSelector/TagSelector.js.map +1 -0
  281. package/lib/ZendeskButton/ZendeskButton.js +39 -58
  282. package/lib/ZendeskButton/ZendeskButton.js.map +1 -0
  283. package/lib/_virtual/rolldown_runtime.js +42 -0
  284. package/lib/i18n/formatNestedMessages.js +16 -30
  285. package/lib/i18n/formatNestedMessages.js.map +1 -0
  286. package/lib/i18n/i18n.js +28 -38
  287. package/lib/i18n/i18n.js.map +1 -0
  288. package/lib/i18n/useComponentTranslations.js +154 -215
  289. package/lib/i18n/useComponentTranslations.js.map +1 -0
  290. package/lib/index.js +156 -598
  291. package/lib/locale/messages-en.js +436 -466
  292. package/lib/locale/messages-en.js.map +1 -0
  293. package/lib/locale/messages-nb.js +436 -466
  294. package/lib/locale/messages-nb.js.map +1 -0
  295. package/lib/locale/messages-nn.js +436 -466
  296. package/lib/locale/messages-nn.js.map +1 -0
  297. package/lib/locale/messages-se.js +436 -466
  298. package/lib/locale/messages-se.js.map +1 -0
  299. package/lib/model/ContentType.js +90 -70
  300. package/lib/model/ContentType.js.map +1 -0
  301. package/lib/model/SubjectCategories.js +26 -14
  302. package/lib/model/SubjectCategories.js.map +1 -0
  303. package/lib/model/SubjectTypes.js +24 -13
  304. package/lib/model/SubjectTypes.js.map +1 -0
  305. package/lib/model/WordClass.js +55 -48
  306. package/lib/model/WordClass.js.map +1 -0
  307. package/lib/model/index.js +16 -25
  308. package/lib/model/index.js.map +1 -0
  309. package/lib/utils/licenseAttributes.js +14 -22
  310. package/lib/utils/licenseAttributes.js.map +1 -0
  311. package/lib/utils/relativeUrl.js +20 -38
  312. package/lib/utils/relativeUrl.js.map +1 -0
  313. package/package.json +12 -11
  314. package/es/Article/index.js +0 -11
  315. package/es/CampaignBlock/index.js +0 -9
  316. package/es/CodeBlock/index.js +0 -10
  317. package/es/ContactBlock/index.js +0 -9
  318. package/es/ContentTypeHero/index.js +0 -9
  319. package/es/Embed/index.js +0 -25
  320. package/es/Embed/types.js +0 -1
  321. package/es/FileList/index.js +0 -11
  322. package/es/Gloss/index.js +0 -10
  323. package/es/Grid/index.js +0 -10
  324. package/es/KeyFigure/index.js +0 -9
  325. package/es/LicenseByline/index.js +0 -10
  326. package/es/LinkBlock/index.js +0 -10
  327. package/es/Pitch/index.js +0 -9
  328. package/es/ResourceBox/index.js +0 -10
  329. package/es/i18n/index.js +0 -11
  330. package/es/types.js +0 -1
  331. package/lib/Article/index.js +0 -68
  332. package/lib/CampaignBlock/index.js +0 -13
  333. package/lib/CodeBlock/index.js +0 -20
  334. package/lib/ContactBlock/index.js +0 -18
  335. package/lib/ContentTypeHero/index.js +0 -12
  336. package/lib/Embed/index.js +0 -150
  337. package/lib/Embed/types.js +0 -5
  338. package/lib/FileList/index.js +0 -44
  339. package/lib/Gloss/index.js +0 -20
  340. package/lib/Grid/index.js +0 -19
  341. package/lib/KeyFigure/index.js +0 -13
  342. package/lib/LicenseByline/index.js +0 -19
  343. package/lib/LinkBlock/index.js +0 -20
  344. package/lib/Pitch/index.js +0 -12
  345. package/lib/ResourceBox/index.js +0 -13
  346. package/lib/i18n/index.js +0 -68
  347. package/lib/types.js +0 -5
@@ -1,248 +1,183 @@
1
- "use strict";
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const require_EmbedByline = require('../LicenseByline/EmbedByline.js');
3
+ const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
4
+ const require_licenseAttributes = require('../utils/licenseAttributes.js');
5
+ const react = require_rolldown_runtime.__toESM(require("react"));
6
+ const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
7
+ const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
8
+ const html_react_parser = require_rolldown_runtime.__toESM(require("html-react-parser"));
9
+ const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
10
+ const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
11
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
2
12
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getLicenseCredits = exports.getFocalPoint = exports.getCrop = exports.default = void 0;
7
- var _htmlReactParser = _interopRequireDefault(require("html-react-parser"));
8
- var _react = require("react");
9
- var _reactI18next = require("react-i18next");
10
- var _icons = require("@ndla/icons");
11
- var _primitives = require("@ndla/primitives");
12
- var _jsx2 = require("@ndla/styled-system/jsx");
13
- var _EmbedErrorPlaceholder = _interopRequireDefault(require("./EmbedErrorPlaceholder"));
14
- var _LicenseByline = require("../LicenseByline");
15
- var _licenseAttributes = require("../utils/licenseAttributes");
16
- var _jsxRuntime = require("react/jsx-runtime");
17
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
- /**
19
- * Copyright (c) 2023-present, NDLA.
20
- *
21
- * This source code is licensed under the GPLv3 license found in the
22
- * LICENSE file in the root directory of this source tree.
23
- *
24
- */
25
-
26
- const getLicenseCredits = copyright => {
27
- return {
28
- creators: copyright?.creators ?? [],
29
- rightsholders: copyright?.rightsholders ?? [],
30
- processors: copyright?.processors ?? []
31
- };
32
- };
33
- exports.getLicenseCredits = getLicenseCredits;
13
+ //#region src/Embed/ImageEmbed.tsx
34
14
  const getFigureProps = (size, float) => {
35
- const actualFloat = float === "left" ? "left" : float === "right" ? "right" : undefined;
36
- const replacedSize = size?.replace("-hide-byline", "") ?? "full";
37
- const actualSize = replacedSize === "fullwidth" ? "full" : replacedSize;
38
- return {
39
- float: actualFloat,
40
- // Figure expects you to set a size when floating. If you don't, the figure will simply take up the available width. Fallback to medium in those cases.
41
- size: actualSize === "full" && float ? "medium" : actualSize
42
- };
15
+ const actualFloat = float === "left" ? "left" : float === "right" ? "right" : void 0;
16
+ const replacedSize = size?.replace("-hide-byline", "") ?? "full";
17
+ const actualSize = replacedSize === "fullwidth" ? "full" : replacedSize;
18
+ return {
19
+ float: actualFloat,
20
+ size: actualSize === "full" && float ? "medium" : actualSize
21
+ };
43
22
  };
44
23
  const getSizes = (size, align) => {
45
- if (align && size === "full") {
46
- return "(min-width: 1024px) 512px, (min-width: 768px) 350px, 100vw";
47
- }
48
- if (align && size === "small") {
49
- return "(min-width: 1024px) 350px, (min-width: 768px) 180px, 100vw";
50
- }
51
- if (align && size === "xsmall") {
52
- return "(min-width: 1024px) 180px, (min-width: 768px) 180px, 100vw";
53
- }
54
- return "(min-width: 1024px) 1024px, 100vw";
24
+ if (align && size === "full") return "(min-width: 1024px) 512px, (min-width: 768px) 350px, 100vw";
25
+ if (align && size === "small") return "(min-width: 1024px) 350px, (min-width: 768px) 180px, 100vw";
26
+ if (align && size === "xsmall") return "(min-width: 1024px) 180px, (min-width: 768px) 180px, 100vw";
27
+ return "(min-width: 1024px) 1024px, 100vw";
55
28
  };
56
- const getFocalPoint = data => {
57
- const focalX = Number.parseFloat(data.focalX ?? "");
58
- const focalY = Number.parseFloat(data.focalY ?? "");
59
- if (!Number.isNaN(focalX) && !Number.isNaN(focalY)) {
60
- return {
61
- x: focalX,
62
- y: focalY
63
- };
64
- }
65
- return undefined;
29
+ const getFocalPoint = (data) => {
30
+ const focalX = Number.parseFloat(data.focalX ?? "");
31
+ const focalY = Number.parseFloat(data.focalY ?? "");
32
+ if (!Number.isNaN(focalX) && !Number.isNaN(focalY)) return {
33
+ x: focalX,
34
+ y: focalY
35
+ };
36
+ return void 0;
66
37
  };
67
- exports.getFocalPoint = getFocalPoint;
68
- const getCrop = data => {
69
- const lowerRightX = Number.parseFloat(data.lowerRightX ?? "");
70
- const lowerRightY = Number.parseFloat(data.lowerRightY ?? "");
71
- const upperLeftX = Number.parseFloat(data.upperLeftX ?? "");
72
- const upperLeftY = Number.parseFloat(data.upperLeftY ?? "");
73
- if (!Number.isNaN(lowerRightX) && !Number.isNaN(lowerRightY) && !Number.isNaN(upperLeftX) && !Number.isNaN(upperLeftY)) {
74
- return {
75
- startX: lowerRightX,
76
- startY: lowerRightY,
77
- endX: upperLeftX,
78
- endY: upperLeftY
79
- };
80
- }
81
- return undefined;
38
+ const getCrop = (data) => {
39
+ const lowerRightX = Number.parseFloat(data.lowerRightX ?? "");
40
+ const lowerRightY = Number.parseFloat(data.lowerRightY ?? "");
41
+ const upperLeftX = Number.parseFloat(data.upperLeftX ?? "");
42
+ const upperLeftY = Number.parseFloat(data.upperLeftY ?? "");
43
+ if (!Number.isNaN(lowerRightX) && !Number.isNaN(lowerRightY) && !Number.isNaN(upperLeftX) && !Number.isNaN(upperLeftY)) return {
44
+ startX: lowerRightX,
45
+ startY: lowerRightY,
46
+ endX: upperLeftX,
47
+ endY: upperLeftY
48
+ };
49
+ return void 0;
82
50
  };
83
- exports.getCrop = getCrop;
84
51
  const expandedSizes = "(min-width: 1024px) 1024px, 100vw";
85
- const ImageWrapper = (0, _jsx2.styled)("div", {
86
- base: {
87
- overflow: "hidden",
88
- position: "relative",
89
- width: "100%",
90
- "& img": {
91
- width: "100%"
92
- }
93
- },
94
- variants: {
95
- svg: {
96
- true: {
97
- display: "flex",
98
- justifyContent: "center"
99
- },
100
- false: {}
101
- },
102
- border: {
103
- true: {
104
- border: "1px solid",
105
- borderColor: "stroke.subtle",
106
- borderRadius: "xsmall",
107
- "& img": {
108
- borderRadius: "0"
109
- }
110
- },
111
- false: {}
112
- },
113
- expandable: {
114
- true: {
115
- cursor: "pointer"
116
- },
117
- false: {}
118
- }
119
- }
52
+ const ImageWrapper = (0, __ndla_styled_system_jsx.styled)("div", {
53
+ base: {
54
+ overflow: "hidden",
55
+ position: "relative",
56
+ width: "100%",
57
+ "& img": { width: "100%" }
58
+ },
59
+ variants: {
60
+ svg: {
61
+ true: {
62
+ display: "flex",
63
+ justifyContent: "center"
64
+ },
65
+ false: {}
66
+ },
67
+ border: {
68
+ true: {
69
+ border: "1px solid",
70
+ borderColor: "stroke.subtle",
71
+ borderRadius: "xsmall",
72
+ "& img": { borderRadius: "0" }
73
+ },
74
+ false: {}
75
+ },
76
+ expandable: {
77
+ true: { cursor: "pointer" },
78
+ false: {}
79
+ }
80
+ }
120
81
  });
121
- const StyledFigure = (0, _jsx2.styled)(_primitives.Figure, {
122
- base: {
123
- zIndex: "docked",
124
- _hover: {
125
- "& [data-byline-button]": {
126
- background: "background.default"
127
- },
128
- "& button[data-expanded]": {
129
- transform: "scale(1.2)"
130
- }
131
- },
132
- "& button[data-expanded='true']": {
133
- "& svg": {
134
- transform: "rotate(-45deg)"
135
- }
136
- }
137
- }
138
- });
139
- const ExpandButton = (0, _jsx2.styled)("button", {
140
- base: {
141
- display: "flex",
142
- alignItems: "center",
143
- justifyContent: "center",
144
- cursor: "pointer",
145
- position: "absolute",
146
- padding: "0",
147
- top: "xsmall",
148
- right: "xsmall",
149
- width: "medium",
150
- height: "medium",
151
- border: "2px solid",
152
- borderColor: "background.default",
153
- transitionProperty: "transform, background-color, color",
154
- transitionDuration: "normal",
155
- transitionTimingFunction: "ease-out",
156
- color: "background.default",
157
- backgroundColor: "surface.action",
158
- borderRadius: "large",
159
- "& svg": {
160
- transitionProperty: "transform",
161
- transitionDuration: "normal",
162
- transitionTimingFunction: "ease-out"
163
- },
164
- tabletDown: {
165
- display: "none"
166
- }
167
- }
168
- }, {
169
- defaultProps: {
170
- type: "button"
171
- }
172
- });
173
- const ImageEmbed = _ref => {
174
- let {
175
- embed,
176
- previewAlt,
177
- lang,
178
- renderContext = "article",
179
- children
180
- } = _ref;
181
- const [imageSizes, setImageSizes] = (0, _react.useState)(undefined);
182
- const figureProps = getFigureProps(embed.embedData.size, embed.embedData.align);
183
- const {
184
- t
185
- } = (0, _reactI18next.useTranslation)();
186
- const parsedDescription = (0, _react.useMemo)(() => {
187
- if (embed.embedData.caption || renderContext === "article") {
188
- return embed.embedData.caption ? (0, _htmlReactParser.default)(embed.embedData.caption) : undefined;
189
- }
190
- if (embed.status === "success" && embed.data.caption.caption) {
191
- return (0, _htmlReactParser.default)(embed.data.caption.caption);
192
- }
193
- }, [embed, renderContext]);
194
- if (embed.status === "error") {
195
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedErrorPlaceholder.default, {
196
- type: "image",
197
- figureType: figureProps?.size,
198
- float: figureProps?.float
199
- });
200
- }
201
- const {
202
- data,
203
- embedData
204
- } = embed;
205
- const altText = embedData.alt || "";
206
- const sizes = getSizes(embedData.size, embedData.align);
207
- const focalPoint = getFocalPoint(embedData);
208
- const crop = getCrop(embedData);
209
- const toggleImageSize = () => {
210
- setImageSizes(sizes => !sizes ? expandedSizes : undefined);
211
- };
212
- const licenseProps = (0, _licenseAttributes.licenseAttributes)(data.copyright.license.license, lang, embedData.url);
213
- const figureSize = figureProps?.float ? figureProps?.size ?? "medium" : "full";
214
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledFigure, {
215
- float: figureProps?.float,
216
- size: imageSizes ? "full" : figureSize,
217
- "data-embed-type": "image",
218
- ...licenseProps,
219
- children: [children, /*#__PURE__*/(0, _jsxRuntime.jsxs)(ImageWrapper, {
220
- border: embedData.border === "true",
221
- expandable: !!figureProps?.float,
222
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.Image, {
223
- focalPoint: focalPoint,
224
- contentType: data.image.contentType,
225
- crop: crop,
226
- sizes: imageSizes ?? sizes,
227
- alt: altText,
228
- src: data.image.imageUrl,
229
- lang: lang,
230
- onClick: figureProps?.float ? toggleImageSize : undefined,
231
- variant: "rounded"
232
- }), (embedData.align === "right" || embedData.align === "left") && /*#__PURE__*/(0, _jsxRuntime.jsx)(ExpandButton, {
233
- "aria-label": t(`license.images.itemImage.zoom${imageSizes ? "Out" : ""}ImageButtonLabel`),
234
- onClick: toggleImageSize,
235
- "data-expanded": !!imageSizes,
236
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.AddLine, {})
237
- })]
238
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LicenseByline.EmbedByline, {
239
- type: "image",
240
- copyright: data.copyright,
241
- description: parsedDescription,
242
- hideDescription: embedData.hideCaption === "true",
243
- hideCopyright: embedData.hideByline === "true",
244
- visibleAlt: previewAlt ? embed.embedData.alt : ""
245
- })]
246
- });
82
+ const StyledFigure = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figure, { base: {
83
+ zIndex: "docked",
84
+ _hover: {
85
+ "& [data-byline-button]": { background: "background.default" },
86
+ "& button[data-expanded]": { transform: "scale(1.2)" }
87
+ },
88
+ "& button[data-expanded='true']": { "& svg": { transform: "rotate(-45deg)" } }
89
+ } });
90
+ const ExpandButton = (0, __ndla_styled_system_jsx.styled)("button", { base: {
91
+ display: "flex",
92
+ alignItems: "center",
93
+ justifyContent: "center",
94
+ cursor: "pointer",
95
+ position: "absolute",
96
+ padding: "0",
97
+ top: "xsmall",
98
+ right: "xsmall",
99
+ width: "medium",
100
+ height: "medium",
101
+ border: "2px solid",
102
+ borderColor: "background.default",
103
+ transitionProperty: "transform, background-color, color",
104
+ transitionDuration: "normal",
105
+ transitionTimingFunction: "ease-out",
106
+ color: "background.default",
107
+ backgroundColor: "surface.action",
108
+ borderRadius: "large",
109
+ "& svg": {
110
+ transitionProperty: "transform",
111
+ transitionDuration: "normal",
112
+ transitionTimingFunction: "ease-out"
113
+ },
114
+ tabletDown: { display: "none" }
115
+ } }, { defaultProps: { type: "button" } });
116
+ const ImageEmbed = ({ embed, previewAlt, lang, renderContext = "article", children }) => {
117
+ const [imageSizes, setImageSizes] = (0, react.useState)(void 0);
118
+ const figureProps = getFigureProps(embed.embedData.size, embed.embedData.align);
119
+ const { t } = (0, react_i18next.useTranslation)();
120
+ const parsedDescription = (0, react.useMemo)(() => {
121
+ if (embed.embedData.caption || renderContext === "article") return embed.embedData.caption ? (0, html_react_parser.default)(embed.embedData.caption) : void 0;
122
+ if (embed.status === "success" && embed.data.caption.caption) return (0, html_react_parser.default)(embed.data.caption.caption);
123
+ }, [embed, renderContext]);
124
+ if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, {
125
+ type: "image",
126
+ figureType: figureProps?.size,
127
+ float: figureProps?.float
128
+ });
129
+ const { data, embedData } = embed;
130
+ const altText = embedData.alt || "";
131
+ const sizes = getSizes(embedData.size, embedData.align);
132
+ const focalPoint = getFocalPoint(embedData);
133
+ const crop = getCrop(embedData);
134
+ const toggleImageSize = () => {
135
+ setImageSizes((sizes$1) => !sizes$1 ? expandedSizes : void 0);
136
+ };
137
+ const licenseProps = require_licenseAttributes.licenseAttributes(data.copyright.license.license, lang, embedData.url);
138
+ const figureSize = figureProps?.float ? figureProps?.size ?? "medium" : "full";
139
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledFigure, {
140
+ float: figureProps?.float,
141
+ size: imageSizes ? "full" : figureSize,
142
+ "data-embed-type": "image",
143
+ ...licenseProps,
144
+ children: [
145
+ children,
146
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ImageWrapper, {
147
+ border: embedData.border === "true",
148
+ expandable: !!figureProps?.float,
149
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Image, {
150
+ focalPoint,
151
+ contentType: data.image.contentType,
152
+ crop,
153
+ sizes: imageSizes ?? sizes,
154
+ alt: altText,
155
+ src: data.image.imageUrl,
156
+ lang,
157
+ onClick: figureProps?.float ? toggleImageSize : void 0,
158
+ variant: "rounded"
159
+ }), (embedData.align === "right" || embedData.align === "left") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExpandButton, {
160
+ "aria-label": t(`license.images.itemImage.zoom${imageSizes ? "Out" : ""}ImageButtonLabel`),
161
+ onClick: toggleImageSize,
162
+ "data-expanded": !!imageSizes,
163
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.AddLine, {})
164
+ })]
165
+ }),
166
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedByline.EmbedByline, {
167
+ type: "image",
168
+ copyright: data.copyright,
169
+ description: parsedDescription,
170
+ hideDescription: embedData.hideCaption === "true",
171
+ hideCopyright: embedData.hideByline === "true",
172
+ visibleAlt: previewAlt ? embed.embedData.alt : ""
173
+ })
174
+ ]
175
+ });
247
176
  };
248
- var _default = exports.default = ImageEmbed;
177
+ var ImageEmbed_default = ImageEmbed;
178
+
179
+ //#endregion
180
+ exports.ImageEmbed_default = ImageEmbed_default;
181
+ exports.getCrop = getCrop;
182
+ exports.getFocalPoint = getFocalPoint;
183
+ //# sourceMappingURL=ImageEmbed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageEmbed.js","names":["size?: string","float?: string","actualSize: FigureSize","align?: string","data: ImageEmbedData","Figure","EmbedErrorPlaceholder","sizes","Image","AddLine","EmbedByline"],"sources":["../../src/Embed/ImageEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport parse from \"html-react-parser\";\nimport { type ReactNode, useMemo, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { AddLine } from \"@ndla/icons\";\nimport { Figure, type FigureSize, type FigureVariantProps, Image } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { ImageEmbedData, ImageMetaData } from \"@ndla/types-embed\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport type { RenderContext } from \"./types\";\nimport { EmbedByline } from \"../LicenseByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\n\ninterface Props {\n embed: ImageMetaData;\n previewAlt?: boolean;\n lang?: string;\n renderContext?: RenderContext;\n children?: ReactNode;\n}\n\nexport interface Author {\n name: string;\n type: string;\n}\n\nexport const getLicenseCredits = (copyright?: {\n creators?: Author[];\n rightsholders?: Author[];\n processors?: Author[];\n}) => {\n return {\n creators: copyright?.creators ?? [],\n rightsholders: copyright?.rightsholders ?? [],\n processors: copyright?.processors ?? [],\n };\n};\n\nconst getFigureProps = (size?: string, float?: string): FigureVariantProps => {\n const actualFloat = float === \"left\" ? \"left\" : float === \"right\" ? \"right\" : undefined;\n const replacedSize = size?.replace(\"-hide-byline\", \"\") ?? \"full\";\n const actualSize: FigureSize = (replacedSize === \"fullwidth\" ? \"full\" : replacedSize) as FigureSize;\n return {\n float: actualFloat,\n // Figure expects you to set a size when floating. If you don't, the figure will simply take up the available width. Fallback to medium in those cases.\n size: actualSize === \"full\" && float ? \"medium\" : actualSize,\n };\n};\n\nconst getSizes = (size?: string, align?: string) => {\n if (align && size === \"full\") {\n return \"(min-width: 1024px) 512px, (min-width: 768px) 350px, 100vw\";\n }\n if (align && size === \"small\") {\n return \"(min-width: 1024px) 350px, (min-width: 768px) 180px, 100vw\";\n }\n if (align && size === \"xsmall\") {\n return \"(min-width: 1024px) 180px, (min-width: 768px) 180px, 100vw\";\n }\n return \"(min-width: 1024px) 1024px, 100vw\";\n};\n\nexport const getFocalPoint = (data: ImageEmbedData) => {\n const focalX = Number.parseFloat(data.focalX ?? \"\");\n const focalY = Number.parseFloat(data.focalY ?? \"\");\n if (!Number.isNaN(focalX) && !Number.isNaN(focalY)) {\n return { x: focalX, y: focalY };\n }\n return undefined;\n};\n\nexport const getCrop = (data: ImageEmbedData) => {\n const lowerRightX = Number.parseFloat(data.lowerRightX ?? \"\");\n const lowerRightY = Number.parseFloat(data.lowerRightY ?? \"\");\n const upperLeftX = Number.parseFloat(data.upperLeftX ?? \"\");\n const upperLeftY = Number.parseFloat(data.upperLeftY ?? \"\");\n if (\n !Number.isNaN(lowerRightX) &&\n !Number.isNaN(lowerRightY) &&\n !Number.isNaN(upperLeftX) &&\n !Number.isNaN(upperLeftY)\n ) {\n return {\n startX: lowerRightX,\n startY: lowerRightY,\n endX: upperLeftX,\n endY: upperLeftY,\n };\n }\n return undefined;\n};\n\nconst expandedSizes = \"(min-width: 1024px) 1024px, 100vw\";\n\nconst ImageWrapper = styled(\"div\", {\n base: {\n overflow: \"hidden\",\n position: \"relative\",\n width: \"100%\",\n \"& img\": {\n width: \"100%\",\n },\n },\n variants: {\n svg: {\n true: {\n display: \"flex\",\n justifyContent: \"center\",\n },\n false: {},\n },\n border: {\n true: {\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n borderRadius: \"xsmall\",\n \"& img\": {\n borderRadius: \"0\",\n },\n },\n false: {},\n },\n expandable: {\n true: {\n cursor: \"pointer\",\n },\n false: {},\n },\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n zIndex: \"docked\",\n _hover: {\n \"& [data-byline-button]\": {\n background: \"background.default\",\n },\n \"& button[data-expanded]\": {\n transform: \"scale(1.2)\",\n },\n },\n \"& button[data-expanded='true']\": {\n \"& svg\": {\n transform: \"rotate(-45deg)\",\n },\n },\n },\n});\n\nconst ExpandButton = styled(\n \"button\",\n {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n cursor: \"pointer\",\n position: \"absolute\",\n padding: \"0\",\n top: \"xsmall\",\n right: \"xsmall\",\n width: \"medium\",\n height: \"medium\",\n border: \"2px solid\",\n borderColor: \"background.default\",\n transitionProperty: \"transform, background-color, color\",\n transitionDuration: \"normal\",\n transitionTimingFunction: \"ease-out\",\n color: \"background.default\",\n backgroundColor: \"surface.action\",\n borderRadius: \"large\",\n \"& svg\": {\n transitionProperty: \"transform\",\n transitionDuration: \"normal\",\n transitionTimingFunction: \"ease-out\",\n },\n tabletDown: {\n display: \"none\",\n },\n },\n },\n { defaultProps: { type: \"button\" } },\n);\n\nconst ImageEmbed = ({ embed, previewAlt, lang, renderContext = \"article\", children }: Props) => {\n const [imageSizes, setImageSizes] = useState<string | undefined>(undefined);\n const figureProps = getFigureProps(embed.embedData.size, embed.embedData.align);\n const { t } = useTranslation();\n\n const parsedDescription = useMemo(() => {\n if (embed.embedData.caption || renderContext === \"article\") {\n return embed.embedData.caption ? parse(embed.embedData.caption) : undefined;\n }\n if (embed.status === \"success\" && embed.data.caption.caption) {\n return parse(embed.data.caption.caption);\n }\n }, [embed, renderContext]);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type={\"image\"} figureType={figureProps?.size} float={figureProps?.float} />;\n }\n\n const { data, embedData } = embed;\n\n const altText = embedData.alt || \"\";\n\n const sizes = getSizes(embedData.size, embedData.align);\n\n const focalPoint = getFocalPoint(embedData);\n const crop = getCrop(embedData);\n\n const toggleImageSize = () => {\n setImageSizes((sizes) => (!sizes ? expandedSizes : undefined));\n };\n\n const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);\n\n const figureSize = figureProps?.float ? (figureProps?.size ?? \"medium\") : \"full\";\n\n return (\n <StyledFigure\n float={figureProps?.float}\n size={imageSizes ? \"full\" : figureSize}\n data-embed-type=\"image\"\n {...licenseProps}\n >\n {children}\n <ImageWrapper border={embedData.border === \"true\"} expandable={!!figureProps?.float}>\n <Image\n focalPoint={focalPoint}\n contentType={data.image.contentType}\n crop={crop}\n sizes={imageSizes ?? sizes}\n alt={altText}\n src={data.image.imageUrl}\n lang={lang}\n onClick={figureProps?.float ? toggleImageSize : undefined}\n variant=\"rounded\"\n />\n {(embedData.align === \"right\" || embedData.align === \"left\") && (\n <ExpandButton\n aria-label={t(`license.images.itemImage.zoom${imageSizes ? \"Out\" : \"\"}ImageButtonLabel`)}\n onClick={toggleImageSize}\n data-expanded={!!imageSizes}\n >\n <AddLine />\n </ExpandButton>\n )}\n </ImageWrapper>\n <EmbedByline\n type=\"image\"\n copyright={data.copyright}\n description={parsedDescription}\n hideDescription={embedData.hideCaption === \"true\"}\n hideCopyright={embedData.hideByline === \"true\"}\n visibleAlt={previewAlt ? embed.embedData.alt : \"\"}\n />\n </StyledFigure>\n );\n};\n\nexport default ImageEmbed;\n"],"mappings":"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"}
@@ -1,43 +1,26 @@
1
- "use strict";
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const react = require_rolldown_runtime.__toESM(require("react"));
3
+ const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
4
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
5
+ const __ndla_util = require_rolldown_runtime.__toESM(require("@ndla/util"));
2
6
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
7
+ //#region src/Embed/InlineTriggerButton.tsx
8
+ const StyledSpan = (0, __ndla_styled_system_jsx.styled)("span", { base: {} });
9
+ const InlineTriggerButton = (0, react.forwardRef)(({ onClick,...props }, ref) => {
10
+ const spanRef = (0, react.useRef)(null);
11
+ const onKeyboardEvent = (0, react.useCallback)((event) => {
12
+ if (event.key === "Enter" || event.key === " ") spanRef.current?.click();
13
+ }, []);
14
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledSpan, {
15
+ ref: (0, __ndla_util.composeRefs)(spanRef, ref),
16
+ onKeyUp: onKeyboardEvent,
17
+ onClick,
18
+ role: "button",
19
+ tabIndex: 0,
20
+ ...props
21
+ });
5
22
  });
6
- exports.InlineTriggerButton = void 0;
7
- var _react = require("react");
8
- var _jsx2 = require("@ndla/styled-system/jsx");
9
- var _util = require("@ndla/util");
10
- var _jsxRuntime = require("react/jsx-runtime");
11
- /**
12
- * Copyright (c) 2024-present, NDLA.
13
- *
14
- * This source code is licensed under the GPLv3 license found in the
15
- * LICENSE file in the root directory of this source tree.
16
- *
17
- */
18
23
 
19
- const StyledSpan = (0, _jsx2.styled)("span", {
20
- base: {}
21
- });
22
- const InlineTriggerButton = exports.InlineTriggerButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
23
- let {
24
- onClick,
25
- ...props
26
- } = _ref;
27
- const spanRef = (0, _react.useRef)(null);
28
-
29
- // Emulate a button click when pressing Enter or Space
30
- const onKeyboardEvent = (0, _react.useCallback)(event => {
31
- if (event.key === "Enter" || event.key === " ") {
32
- spanRef.current?.click();
33
- }
34
- }, []);
35
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledSpan, {
36
- ref: (0, _util.composeRefs)(spanRef, ref),
37
- onKeyUp: onKeyboardEvent,
38
- onClick: onClick,
39
- role: "button",
40
- tabIndex: 0,
41
- ...props
42
- });
43
- });
24
+ //#endregion
25
+ exports.InlineTriggerButton = InlineTriggerButton;
26
+ //# sourceMappingURL=InlineTriggerButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InlineTriggerButton.js","names":["event: KeyboardEvent<HTMLSpanElement>"],"sources":["../../src/Embed/InlineTriggerButton.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type ComponentPropsWithRef, type KeyboardEvent, forwardRef, useCallback, useRef } from \"react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { composeRefs } from \"@ndla/util\";\n\nconst StyledSpan = styled(\"span\", { base: {} });\n\nexport const InlineTriggerButton = forwardRef<HTMLSpanElement, ComponentPropsWithRef<\"span\">>(\n ({ onClick, ...props }, ref) => {\n const spanRef = useRef<HTMLSpanElement>(null);\n\n // Emulate a button click when pressing Enter or Space\n const onKeyboardEvent = useCallback((event: KeyboardEvent<HTMLSpanElement>) => {\n if (event.key === \"Enter\" || event.key === \" \") {\n spanRef.current?.click();\n }\n }, []);\n\n return (\n <StyledSpan\n ref={composeRefs(spanRef, ref)}\n onKeyUp={onKeyboardEvent}\n onClick={onClick}\n role=\"button\"\n tabIndex={0}\n {...props}\n />\n );\n },\n);\n"],"mappings":";;;;;;;AAYA,MAAM,aAAa,qCAAO,QAAQ,EAAE,MAAM,CAAE,EAAE,EAAC;AAE/C,MAAa,sBAAsB,sBACjC,CAAC,EAAE,QAAS,GAAG,OAAO,EAAE,QAAQ;CAC9B,MAAM,UAAU,kBAAwB,KAAK;CAG7C,MAAM,kBAAkB,uBAAY,CAACA,UAA0C;AAC7E,MAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,IACzC,SAAQ,SAAS,OAAO;CAE3B,GAAE,CAAE,EAAC;AAEN,wBACE,2BAAC;EACC,KAAK,6BAAY,SAAS,IAAI;EAC9B,SAAS;EACA;EACT,MAAK;EACL,UAAU;EACV,GAAI;GACJ;AAEL,EACF"}
@@ -1,61 +1,39 @@
1
- "use strict";
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const require_ContentType = require('../model/ContentType.js');
3
+ const require_RelatedArticleList = require('../RelatedArticleList/RelatedArticleList.js');
4
+ const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
5
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
2
6
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _reactI18next = require("react-i18next");
8
- var _ContentType = require("../model/ContentType");
9
- var _RelatedArticleList = require("../RelatedArticleList/RelatedArticleList");
10
- var _jsxRuntime = require("react/jsx-runtime");
11
- /**
12
- * Copyright (c) 2023-present, NDLA.
13
- *
14
- * This source code is licensed under the GPLv3 license found in the
15
- * LICENSE file in the root directory of this source tree.
16
- *
17
- */
18
-
19
- const RelatedContentEmbed = _ref => {
20
- let {
21
- embed,
22
- isOembed,
23
- subject,
24
- ndlaFrontendDomain
25
- } = _ref;
26
- const {
27
- t
28
- } = (0, _reactI18next.useTranslation)();
29
- if (embed.status === "error") {
30
- return null;
31
- }
32
- const {
33
- data,
34
- embedData
35
- } = embed;
36
- if (embedData.articleId && data) {
37
- const typeId = data.resource?.resourceTypes.find(rt => _ContentType.contentTypeMapping[rt.id])?.id;
38
- const type = typeId ? _ContentType.contentTypeMapping[typeId] : undefined;
39
- const context = data.resource?.contexts.find(c => c.rootId === subject);
40
- const url = context?.url ?? data.resource?.url ?? `/article/${embedData.articleId}`;
41
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RelatedArticleList.RelatedArticle, {
42
- title: data.article.title?.title ?? "",
43
- introduction: data.article.metaDescription?.metaDescription ?? "",
44
- target: isOembed ? "_blank" : undefined,
45
- to: `${ndlaFrontendDomain ?? ""}${url ?? ""}`,
46
- type: type
47
- });
48
- }
49
- if (typeof embedData.url === "string") {
50
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_RelatedArticleList.RelatedArticle, {
51
- title: embedData.title ?? "",
52
- introduction: "",
53
- to: embedData.url,
54
- target: "_blank",
55
- type: "external",
56
- linkInfo: `${t("related.linkInfo")} ${embedData.urlDomain}`
57
- });
58
- }
59
- return null;
7
+ //#region src/Embed/RelatedContentEmbed.tsx
8
+ const RelatedContentEmbed = ({ embed, isOembed, subject, ndlaFrontendDomain }) => {
9
+ const { t } = (0, react_i18next.useTranslation)();
10
+ if (embed.status === "error") return null;
11
+ const { data, embedData } = embed;
12
+ if (embedData.articleId && data) {
13
+ const typeId = data.resource?.resourceTypes.find((rt) => require_ContentType.contentTypeMapping[rt.id])?.id;
14
+ const type = typeId ? require_ContentType.contentTypeMapping[typeId] : void 0;
15
+ const context = data.resource?.contexts.find((c) => c.rootId === subject);
16
+ const url = context?.url ?? data.resource?.url ?? `/article/${embedData.articleId}`;
17
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RelatedArticleList.RelatedArticle, {
18
+ title: data.article.title?.title ?? "",
19
+ introduction: data.article.metaDescription?.metaDescription ?? "",
20
+ target: isOembed ? "_blank" : void 0,
21
+ to: `${ndlaFrontendDomain ?? ""}${url ?? ""}`,
22
+ type
23
+ });
24
+ }
25
+ if (typeof embedData.url === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RelatedArticleList.RelatedArticle, {
26
+ title: embedData.title ?? "",
27
+ introduction: "",
28
+ to: embedData.url,
29
+ target: "_blank",
30
+ type: "external",
31
+ linkInfo: `${t("related.linkInfo")} ${embedData.urlDomain}`
32
+ });
33
+ return null;
60
34
  };
61
- var _default = exports.default = RelatedContentEmbed;
35
+ var RelatedContentEmbed_default = RelatedContentEmbed;
36
+
37
+ //#endregion
38
+ exports.RelatedContentEmbed_default = RelatedContentEmbed_default;
39
+ //# sourceMappingURL=RelatedContentEmbed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelatedContentEmbed.js","names":["contentTypeMapping","RelatedArticle"],"sources":["../../src/Embed/RelatedContentEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { useTranslation } from \"react-i18next\";\nimport type { RelatedContentMetaData } from \"@ndla/types-embed\";\nimport { contentTypeMapping } from \"../model/ContentType\";\nimport { RelatedArticle } from \"../RelatedArticleList/RelatedArticleList\";\n\ninterface Props {\n embed: RelatedContentMetaData;\n isOembed?: boolean;\n subject?: string;\n ndlaFrontendDomain?: string;\n}\n\nconst RelatedContentEmbed = ({ embed, isOembed, subject, ndlaFrontendDomain }: Props) => {\n const { t } = useTranslation();\n if (embed.status === \"error\") {\n return null;\n }\n\n const { data, embedData } = embed;\n\n if (embedData.articleId && data) {\n const typeId = data.resource?.resourceTypes.find((rt) => contentTypeMapping[rt.id])?.id;\n const type = typeId ? contentTypeMapping[typeId] : undefined;\n const context = data.resource?.contexts.find((c) => c.rootId === subject);\n const url = context?.url ?? data.resource?.url ?? `/article/${embedData.articleId}`;\n return (\n <RelatedArticle\n title={data.article.title?.title ?? \"\"}\n introduction={data.article.metaDescription?.metaDescription ?? \"\"}\n target={isOembed ? \"_blank\" : undefined}\n to={`${ndlaFrontendDomain ?? \"\"}${url ?? \"\"}`}\n type={type}\n />\n );\n }\n if (typeof embedData.url === \"string\") {\n return (\n <RelatedArticle\n title={embedData.title ?? \"\"}\n introduction=\"\"\n to={embedData.url}\n target=\"_blank\"\n type=\"external\"\n linkInfo={`${t(\"related.linkInfo\")} ${embedData.urlDomain}`}\n />\n );\n }\n return null;\n};\n\nexport default RelatedContentEmbed;\n"],"mappings":";;;;;;;AAoBA,MAAM,sBAAsB,CAAC,EAAE,OAAO,UAAU,SAAS,oBAA2B,KAAK;CACvF,MAAM,EAAE,GAAG,GAAG,mCAAgB;AAC9B,KAAI,MAAM,WAAW,QACnB,QAAO;CAGT,MAAM,EAAE,MAAM,WAAW,GAAG;AAE5B,KAAI,UAAU,aAAa,MAAM;EAC/B,MAAM,SAAS,KAAK,UAAU,cAAc,KAAK,CAAC,OAAOA,uCAAmB,GAAG,IAAI,EAAE;EACrF,MAAM,OAAO,SAASA,uCAAmB;EACzC,MAAM,UAAU,KAAK,UAAU,SAAS,KAAK,CAAC,MAAM,EAAE,WAAW,QAAQ;EACzE,MAAM,MAAM,SAAS,OAAO,KAAK,UAAU,QAAQ,WAAW,UAAU,UAAU;AAClF,yBACE,2BAACC;GACC,OAAO,KAAK,QAAQ,OAAO,SAAS;GACpC,cAAc,KAAK,QAAQ,iBAAiB,mBAAmB;GAC/D,QAAQ,WAAW;GACnB,KAAK,EAAE,sBAAsB,GAAG,EAAE,OAAO,GAAG;GACtC;IACN;CAEL;AACD,YAAW,UAAU,QAAQ,SAC3B,wBACE,2BAACA;EACC,OAAO,UAAU,SAAS;EAC1B,cAAa;EACb,IAAI,UAAU;EACd,QAAO;EACP,MAAK;EACL,WAAW,EAAE,EAAE,mBAAmB,CAAC,GAAG,UAAU,UAAU;GAC1D;AAGN,QAAO;AACR;AAED,kCAAe"}