@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,238 +1,180 @@
1
- /**
2
- * Copyright (c) 2023-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import parse from "html-react-parser";
1
+ import { EmbedByline } from "../LicenseByline/EmbedByline.js";
2
+ import { EmbedErrorPlaceholder_default } from "./EmbedErrorPlaceholder.js";
3
+ import { licenseAttributes } from "../utils/licenseAttributes.js";
10
4
  import { useMemo, useState } from "react";
11
- import { useTranslation } from "react-i18next";
12
- import { AddLine } from "@ndla/icons";
13
5
  import { Figure, Image } from "@ndla/primitives";
14
6
  import { styled } from "@ndla/styled-system/jsx";
15
- import EmbedErrorPlaceholder from "./EmbedErrorPlaceholder";
16
- import { EmbedByline } from "../LicenseByline";
17
- import { licenseAttributes } from "../utils/licenseAttributes";
18
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
- export const getLicenseCredits = copyright => {
20
- return {
21
- creators: copyright?.creators ?? [],
22
- rightsholders: copyright?.rightsholders ?? [],
23
- processors: copyright?.processors ?? []
24
- };
25
- };
7
+ import parse from "html-react-parser";
8
+ import { useTranslation } from "react-i18next";
9
+ import { AddLine } from "@ndla/icons";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+
12
+ //#region src/Embed/ImageEmbed.tsx
26
13
  const getFigureProps = (size, float) => {
27
- const actualFloat = float === "left" ? "left" : float === "right" ? "right" : undefined;
28
- const replacedSize = size?.replace("-hide-byline", "") ?? "full";
29
- const actualSize = replacedSize === "fullwidth" ? "full" : replacedSize;
30
- return {
31
- float: actualFloat,
32
- // 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.
33
- size: actualSize === "full" && float ? "medium" : actualSize
34
- };
14
+ const actualFloat = float === "left" ? "left" : float === "right" ? "right" : void 0;
15
+ const replacedSize = size?.replace("-hide-byline", "") ?? "full";
16
+ const actualSize = replacedSize === "fullwidth" ? "full" : replacedSize;
17
+ return {
18
+ float: actualFloat,
19
+ size: actualSize === "full" && float ? "medium" : actualSize
20
+ };
35
21
  };
36
22
  const getSizes = (size, align) => {
37
- if (align && size === "full") {
38
- return "(min-width: 1024px) 512px, (min-width: 768px) 350px, 100vw";
39
- }
40
- if (align && size === "small") {
41
- return "(min-width: 1024px) 350px, (min-width: 768px) 180px, 100vw";
42
- }
43
- if (align && size === "xsmall") {
44
- return "(min-width: 1024px) 180px, (min-width: 768px) 180px, 100vw";
45
- }
46
- return "(min-width: 1024px) 1024px, 100vw";
23
+ if (align && size === "full") return "(min-width: 1024px) 512px, (min-width: 768px) 350px, 100vw";
24
+ if (align && size === "small") return "(min-width: 1024px) 350px, (min-width: 768px) 180px, 100vw";
25
+ if (align && size === "xsmall") return "(min-width: 1024px) 180px, (min-width: 768px) 180px, 100vw";
26
+ return "(min-width: 1024px) 1024px, 100vw";
47
27
  };
48
- export const getFocalPoint = data => {
49
- const focalX = Number.parseFloat(data.focalX ?? "");
50
- const focalY = Number.parseFloat(data.focalY ?? "");
51
- if (!Number.isNaN(focalX) && !Number.isNaN(focalY)) {
52
- return {
53
- x: focalX,
54
- y: focalY
55
- };
56
- }
57
- return undefined;
28
+ const getFocalPoint = (data) => {
29
+ const focalX = Number.parseFloat(data.focalX ?? "");
30
+ const focalY = Number.parseFloat(data.focalY ?? "");
31
+ if (!Number.isNaN(focalX) && !Number.isNaN(focalY)) return {
32
+ x: focalX,
33
+ y: focalY
34
+ };
35
+ return void 0;
58
36
  };
59
- export const getCrop = data => {
60
- const lowerRightX = Number.parseFloat(data.lowerRightX ?? "");
61
- const lowerRightY = Number.parseFloat(data.lowerRightY ?? "");
62
- const upperLeftX = Number.parseFloat(data.upperLeftX ?? "");
63
- const upperLeftY = Number.parseFloat(data.upperLeftY ?? "");
64
- if (!Number.isNaN(lowerRightX) && !Number.isNaN(lowerRightY) && !Number.isNaN(upperLeftX) && !Number.isNaN(upperLeftY)) {
65
- return {
66
- startX: lowerRightX,
67
- startY: lowerRightY,
68
- endX: upperLeftX,
69
- endY: upperLeftY
70
- };
71
- }
72
- return undefined;
37
+ const getCrop = (data) => {
38
+ const lowerRightX = Number.parseFloat(data.lowerRightX ?? "");
39
+ const lowerRightY = Number.parseFloat(data.lowerRightY ?? "");
40
+ const upperLeftX = Number.parseFloat(data.upperLeftX ?? "");
41
+ const upperLeftY = Number.parseFloat(data.upperLeftY ?? "");
42
+ if (!Number.isNaN(lowerRightX) && !Number.isNaN(lowerRightY) && !Number.isNaN(upperLeftX) && !Number.isNaN(upperLeftY)) return {
43
+ startX: lowerRightX,
44
+ startY: lowerRightY,
45
+ endX: upperLeftX,
46
+ endY: upperLeftY
47
+ };
48
+ return void 0;
73
49
  };
74
50
  const expandedSizes = "(min-width: 1024px) 1024px, 100vw";
75
51
  const ImageWrapper = styled("div", {
76
- base: {
77
- overflow: "hidden",
78
- position: "relative",
79
- width: "100%",
80
- "& img": {
81
- width: "100%"
82
- }
83
- },
84
- variants: {
85
- svg: {
86
- true: {
87
- display: "flex",
88
- justifyContent: "center"
89
- },
90
- false: {}
91
- },
92
- border: {
93
- true: {
94
- border: "1px solid",
95
- borderColor: "stroke.subtle",
96
- borderRadius: "xsmall",
97
- "& img": {
98
- borderRadius: "0"
99
- }
100
- },
101
- false: {}
102
- },
103
- expandable: {
104
- true: {
105
- cursor: "pointer"
106
- },
107
- false: {}
108
- }
109
- }
52
+ base: {
53
+ overflow: "hidden",
54
+ position: "relative",
55
+ width: "100%",
56
+ "& img": { width: "100%" }
57
+ },
58
+ variants: {
59
+ svg: {
60
+ true: {
61
+ display: "flex",
62
+ justifyContent: "center"
63
+ },
64
+ false: {}
65
+ },
66
+ border: {
67
+ true: {
68
+ border: "1px solid",
69
+ borderColor: "stroke.subtle",
70
+ borderRadius: "xsmall",
71
+ "& img": { borderRadius: "0" }
72
+ },
73
+ false: {}
74
+ },
75
+ expandable: {
76
+ true: { cursor: "pointer" },
77
+ false: {}
78
+ }
79
+ }
110
80
  });
111
- const StyledFigure = styled(Figure, {
112
- base: {
113
- zIndex: "docked",
114
- _hover: {
115
- "& [data-byline-button]": {
116
- background: "background.default"
117
- },
118
- "& button[data-expanded]": {
119
- transform: "scale(1.2)"
120
- }
121
- },
122
- "& button[data-expanded='true']": {
123
- "& svg": {
124
- transform: "rotate(-45deg)"
125
- }
126
- }
127
- }
128
- });
129
- const ExpandButton = styled("button", {
130
- base: {
131
- display: "flex",
132
- alignItems: "center",
133
- justifyContent: "center",
134
- cursor: "pointer",
135
- position: "absolute",
136
- padding: "0",
137
- top: "xsmall",
138
- right: "xsmall",
139
- width: "medium",
140
- height: "medium",
141
- border: "2px solid",
142
- borderColor: "background.default",
143
- transitionProperty: "transform, background-color, color",
144
- transitionDuration: "normal",
145
- transitionTimingFunction: "ease-out",
146
- color: "background.default",
147
- backgroundColor: "surface.action",
148
- borderRadius: "large",
149
- "& svg": {
150
- transitionProperty: "transform",
151
- transitionDuration: "normal",
152
- transitionTimingFunction: "ease-out"
153
- },
154
- tabletDown: {
155
- display: "none"
156
- }
157
- }
158
- }, {
159
- defaultProps: {
160
- type: "button"
161
- }
162
- });
163
- const ImageEmbed = _ref => {
164
- let {
165
- embed,
166
- previewAlt,
167
- lang,
168
- renderContext = "article",
169
- children
170
- } = _ref;
171
- const [imageSizes, setImageSizes] = useState(undefined);
172
- const figureProps = getFigureProps(embed.embedData.size, embed.embedData.align);
173
- const {
174
- t
175
- } = useTranslation();
176
- const parsedDescription = useMemo(() => {
177
- if (embed.embedData.caption || renderContext === "article") {
178
- return embed.embedData.caption ? parse(embed.embedData.caption) : undefined;
179
- }
180
- if (embed.status === "success" && embed.data.caption.caption) {
181
- return parse(embed.data.caption.caption);
182
- }
183
- }, [embed, renderContext]);
184
- if (embed.status === "error") {
185
- return /*#__PURE__*/_jsx(EmbedErrorPlaceholder, {
186
- type: "image",
187
- figureType: figureProps?.size,
188
- float: figureProps?.float
189
- });
190
- }
191
- const {
192
- data,
193
- embedData
194
- } = embed;
195
- const altText = embedData.alt || "";
196
- const sizes = getSizes(embedData.size, embedData.align);
197
- const focalPoint = getFocalPoint(embedData);
198
- const crop = getCrop(embedData);
199
- const toggleImageSize = () => {
200
- setImageSizes(sizes => !sizes ? expandedSizes : undefined);
201
- };
202
- const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);
203
- const figureSize = figureProps?.float ? figureProps?.size ?? "medium" : "full";
204
- return /*#__PURE__*/_jsxs(StyledFigure, {
205
- float: figureProps?.float,
206
- size: imageSizes ? "full" : figureSize,
207
- "data-embed-type": "image",
208
- ...licenseProps,
209
- children: [children, /*#__PURE__*/_jsxs(ImageWrapper, {
210
- border: embedData.border === "true",
211
- expandable: !!figureProps?.float,
212
- children: [/*#__PURE__*/_jsx(Image, {
213
- focalPoint: focalPoint,
214
- contentType: data.image.contentType,
215
- crop: crop,
216
- sizes: imageSizes ?? sizes,
217
- alt: altText,
218
- src: data.image.imageUrl,
219
- lang: lang,
220
- onClick: figureProps?.float ? toggleImageSize : undefined,
221
- variant: "rounded"
222
- }), (embedData.align === "right" || embedData.align === "left") && /*#__PURE__*/_jsx(ExpandButton, {
223
- "aria-label": t(`license.images.itemImage.zoom${imageSizes ? "Out" : ""}ImageButtonLabel`),
224
- onClick: toggleImageSize,
225
- "data-expanded": !!imageSizes,
226
- children: /*#__PURE__*/_jsx(AddLine, {})
227
- })]
228
- }), /*#__PURE__*/_jsx(EmbedByline, {
229
- type: "image",
230
- copyright: data.copyright,
231
- description: parsedDescription,
232
- hideDescription: embedData.hideCaption === "true",
233
- hideCopyright: embedData.hideByline === "true",
234
- visibleAlt: previewAlt ? embed.embedData.alt : ""
235
- })]
236
- });
81
+ const StyledFigure = styled(Figure, { base: {
82
+ zIndex: "docked",
83
+ _hover: {
84
+ "& [data-byline-button]": { background: "background.default" },
85
+ "& button[data-expanded]": { transform: "scale(1.2)" }
86
+ },
87
+ "& button[data-expanded='true']": { "& svg": { transform: "rotate(-45deg)" } }
88
+ } });
89
+ const ExpandButton = styled("button", { base: {
90
+ display: "flex",
91
+ alignItems: "center",
92
+ justifyContent: "center",
93
+ cursor: "pointer",
94
+ position: "absolute",
95
+ padding: "0",
96
+ top: "xsmall",
97
+ right: "xsmall",
98
+ width: "medium",
99
+ height: "medium",
100
+ border: "2px solid",
101
+ borderColor: "background.default",
102
+ transitionProperty: "transform, background-color, color",
103
+ transitionDuration: "normal",
104
+ transitionTimingFunction: "ease-out",
105
+ color: "background.default",
106
+ backgroundColor: "surface.action",
107
+ borderRadius: "large",
108
+ "& svg": {
109
+ transitionProperty: "transform",
110
+ transitionDuration: "normal",
111
+ transitionTimingFunction: "ease-out"
112
+ },
113
+ tabletDown: { display: "none" }
114
+ } }, { defaultProps: { type: "button" } });
115
+ const ImageEmbed = ({ embed, previewAlt, lang, renderContext = "article", children }) => {
116
+ const [imageSizes, setImageSizes] = useState(void 0);
117
+ const figureProps = getFigureProps(embed.embedData.size, embed.embedData.align);
118
+ const { t } = useTranslation();
119
+ const parsedDescription = useMemo(() => {
120
+ if (embed.embedData.caption || renderContext === "article") return embed.embedData.caption ? parse(embed.embedData.caption) : void 0;
121
+ if (embed.status === "success" && embed.data.caption.caption) return parse(embed.data.caption.caption);
122
+ }, [embed, renderContext]);
123
+ if (embed.status === "error") return /* @__PURE__ */ jsx(EmbedErrorPlaceholder_default, {
124
+ type: "image",
125
+ figureType: figureProps?.size,
126
+ float: figureProps?.float
127
+ });
128
+ const { data, embedData } = embed;
129
+ const altText = embedData.alt || "";
130
+ const sizes = getSizes(embedData.size, embedData.align);
131
+ const focalPoint = getFocalPoint(embedData);
132
+ const crop = getCrop(embedData);
133
+ const toggleImageSize = () => {
134
+ setImageSizes((sizes$1) => !sizes$1 ? expandedSizes : void 0);
135
+ };
136
+ const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);
137
+ const figureSize = figureProps?.float ? figureProps?.size ?? "medium" : "full";
138
+ return /* @__PURE__ */ jsxs(StyledFigure, {
139
+ float: figureProps?.float,
140
+ size: imageSizes ? "full" : figureSize,
141
+ "data-embed-type": "image",
142
+ ...licenseProps,
143
+ children: [
144
+ children,
145
+ /* @__PURE__ */ jsxs(ImageWrapper, {
146
+ border: embedData.border === "true",
147
+ expandable: !!figureProps?.float,
148
+ children: [/* @__PURE__ */ jsx(Image, {
149
+ focalPoint,
150
+ contentType: data.image.contentType,
151
+ crop,
152
+ sizes: imageSizes ?? sizes,
153
+ alt: altText,
154
+ src: data.image.imageUrl,
155
+ lang,
156
+ onClick: figureProps?.float ? toggleImageSize : void 0,
157
+ variant: "rounded"
158
+ }), (embedData.align === "right" || embedData.align === "left") && /* @__PURE__ */ jsx(ExpandButton, {
159
+ "aria-label": t(`license.images.itemImage.zoom${imageSizes ? "Out" : ""}ImageButtonLabel`),
160
+ onClick: toggleImageSize,
161
+ "data-expanded": !!imageSizes,
162
+ children: /* @__PURE__ */ jsx(AddLine, {})
163
+ })]
164
+ }),
165
+ /* @__PURE__ */ jsx(EmbedByline, {
166
+ type: "image",
167
+ copyright: data.copyright,
168
+ description: parsedDescription,
169
+ hideDescription: embedData.hideCaption === "true",
170
+ hideCopyright: embedData.hideByline === "true",
171
+ visibleAlt: previewAlt ? embed.embedData.alt : ""
172
+ })
173
+ ]
174
+ });
237
175
  };
238
- export default ImageEmbed;
176
+ var ImageEmbed_default = ImageEmbed;
177
+
178
+ //#endregion
179
+ export { ImageEmbed_default, getCrop, getFocalPoint };
180
+ //# sourceMappingURL=ImageEmbed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageEmbed.js","names":["size?: string","float?: string","actualSize: FigureSize","align?: string","data: ImageEmbedData","EmbedErrorPlaceholder","sizes"],"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,37 +1,25 @@
1
- /**
2
- * Copyright (c) 2024-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
1
  import { forwardRef, useCallback, useRef } from "react";
10
2
  import { styled } from "@ndla/styled-system/jsx";
3
+ import { jsx } from "react/jsx-runtime";
11
4
  import { composeRefs } from "@ndla/util";
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- const StyledSpan = styled("span", {
14
- base: {}
5
+
6
+ //#region src/Embed/InlineTriggerButton.tsx
7
+ const StyledSpan = styled("span", { base: {} });
8
+ const InlineTriggerButton = forwardRef(({ onClick,...props }, ref) => {
9
+ const spanRef = useRef(null);
10
+ const onKeyboardEvent = useCallback((event) => {
11
+ if (event.key === "Enter" || event.key === " ") spanRef.current?.click();
12
+ }, []);
13
+ return /* @__PURE__ */ jsx(StyledSpan, {
14
+ ref: composeRefs(spanRef, ref),
15
+ onKeyUp: onKeyboardEvent,
16
+ onClick,
17
+ role: "button",
18
+ tabIndex: 0,
19
+ ...props
20
+ });
15
21
  });
16
- export const InlineTriggerButton = /*#__PURE__*/forwardRef((_ref, ref) => {
17
- let {
18
- onClick,
19
- ...props
20
- } = _ref;
21
- const spanRef = useRef(null);
22
22
 
23
- // Emulate a button click when pressing Enter or Space
24
- const onKeyboardEvent = useCallback(event => {
25
- if (event.key === "Enter" || event.key === " ") {
26
- spanRef.current?.click();
27
- }
28
- }, []);
29
- return /*#__PURE__*/_jsx(StyledSpan, {
30
- ref: composeRefs(spanRef, ref),
31
- onKeyUp: onKeyboardEvent,
32
- onClick: onClick,
33
- role: "button",
34
- tabIndex: 0,
35
- ...props
36
- });
37
- });
23
+ //#endregion
24
+ export { InlineTriggerButton };
25
+ //# 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,OAAO,QAAQ,EAAE,MAAM,CAAE,EAAE,EAAC;AAE/C,MAAa,sBAAsB,WACjC,CAAC,EAAE,QAAS,GAAG,OAAO,EAAE,QAAQ;CAC9B,MAAM,UAAU,OAAwB,KAAK;CAG7C,MAAM,kBAAkB,YAAY,CAACA,UAA0C;AAC7E,MAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,IACzC,SAAQ,SAAS,OAAO;CAE3B,GAAE,CAAE,EAAC;AAEN,wBACE,IAAC;EACC,KAAK,YAAY,SAAS,IAAI;EAC9B,SAAS;EACA;EACT,MAAK;EACL,UAAU;EACV,GAAI;GACJ;AAEL,EACF"}
@@ -1,55 +1,38 @@
1
- /**
2
- * Copyright (c) 2023-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
1
+ import { contentTypeMapping } from "../model/ContentType.js";
2
+ import { RelatedArticle } from "../RelatedArticleList/RelatedArticleList.js";
9
3
  import { useTranslation } from "react-i18next";
10
- import { contentTypeMapping } from "../model/ContentType";
11
- import { RelatedArticle } from "../RelatedArticleList/RelatedArticleList";
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- const RelatedContentEmbed = _ref => {
14
- let {
15
- embed,
16
- isOembed,
17
- subject,
18
- ndlaFrontendDomain
19
- } = _ref;
20
- const {
21
- t
22
- } = useTranslation();
23
- if (embed.status === "error") {
24
- return null;
25
- }
26
- const {
27
- data,
28
- embedData
29
- } = embed;
30
- if (embedData.articleId && data) {
31
- const typeId = data.resource?.resourceTypes.find(rt => contentTypeMapping[rt.id])?.id;
32
- const type = typeId ? contentTypeMapping[typeId] : undefined;
33
- const context = data.resource?.contexts.find(c => c.rootId === subject);
34
- const url = context?.url ?? data.resource?.url ?? `/article/${embedData.articleId}`;
35
- return /*#__PURE__*/_jsx(RelatedArticle, {
36
- title: data.article.title?.title ?? "",
37
- introduction: data.article.metaDescription?.metaDescription ?? "",
38
- target: isOembed ? "_blank" : undefined,
39
- to: `${ndlaFrontendDomain ?? ""}${url ?? ""}`,
40
- type: type
41
- });
42
- }
43
- if (typeof embedData.url === "string") {
44
- return /*#__PURE__*/_jsx(RelatedArticle, {
45
- title: embedData.title ?? "",
46
- introduction: "",
47
- to: embedData.url,
48
- target: "_blank",
49
- type: "external",
50
- linkInfo: `${t("related.linkInfo")} ${embedData.urlDomain}`
51
- });
52
- }
53
- return null;
4
+ import { jsx } from "react/jsx-runtime";
5
+
6
+ //#region src/Embed/RelatedContentEmbed.tsx
7
+ const RelatedContentEmbed = ({ embed, isOembed, subject, ndlaFrontendDomain }) => {
8
+ const { t } = useTranslation();
9
+ if (embed.status === "error") return null;
10
+ const { data, embedData } = embed;
11
+ if (embedData.articleId && data) {
12
+ const typeId = data.resource?.resourceTypes.find((rt) => contentTypeMapping[rt.id])?.id;
13
+ const type = typeId ? contentTypeMapping[typeId] : void 0;
14
+ const context = data.resource?.contexts.find((c) => c.rootId === subject);
15
+ const url = context?.url ?? data.resource?.url ?? `/article/${embedData.articleId}`;
16
+ return /* @__PURE__ */ jsx(RelatedArticle, {
17
+ title: data.article.title?.title ?? "",
18
+ introduction: data.article.metaDescription?.metaDescription ?? "",
19
+ target: isOembed ? "_blank" : void 0,
20
+ to: `${ndlaFrontendDomain ?? ""}${url ?? ""}`,
21
+ type
22
+ });
23
+ }
24
+ if (typeof embedData.url === "string") return /* @__PURE__ */ jsx(RelatedArticle, {
25
+ title: embedData.title ?? "",
26
+ introduction: "",
27
+ to: embedData.url,
28
+ target: "_blank",
29
+ type: "external",
30
+ linkInfo: `${t("related.linkInfo")} ${embedData.urlDomain}`
31
+ });
32
+ return null;
54
33
  };
55
- export default RelatedContentEmbed;
34
+ var RelatedContentEmbed_default = RelatedContentEmbed;
35
+
36
+ //#endregion
37
+ export { RelatedContentEmbed_default };
38
+ //# sourceMappingURL=RelatedContentEmbed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelatedContentEmbed.js","names":[],"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,gBAAgB;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,OAAO,mBAAmB,GAAG,IAAI,EAAE;EACrF,MAAM,OAAO,SAAS,mBAAmB;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,IAAC;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,IAAC;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"}