@ndla/ui 56.0.122-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 (314) hide show
  1. package/README.md +1 -1
  2. package/es/Article/Article.js +127 -0
  3. package/es/Article/Article.js.map +1 -0
  4. package/es/Article/ArticleByline.js +133 -0
  5. package/es/Article/ArticleByline.js.map +1 -0
  6. package/es/Article/ArticleFootNotes.js +40 -0
  7. package/es/Article/ArticleFootNotes.js.map +1 -0
  8. package/es/AudioPlayer/AudioPlayer.js +157 -0
  9. package/es/AudioPlayer/AudioPlayer.js.map +1 -0
  10. package/es/AudioPlayer/Controls.js +254 -0
  11. package/es/AudioPlayer/Controls.js.map +1 -0
  12. package/es/AudioPlayer/SpeechControl.js +40 -0
  13. package/es/AudioPlayer/SpeechControl.js.map +1 -0
  14. package/es/AudioPlayer/index.js +8 -0
  15. package/es/AudioPlayer/index.js.map +1 -0
  16. package/es/Breadcrumb/Breadcrumb.js +44 -0
  17. package/es/Breadcrumb/Breadcrumb.js.map +1 -0
  18. package/es/Breadcrumb/BreadcrumbItem.js +36 -0
  19. package/es/Breadcrumb/BreadcrumbItem.js.map +1 -0
  20. package/es/Breadcrumb/HomeBreadcrumb.js +44 -0
  21. package/es/Breadcrumb/HomeBreadcrumb.js.map +1 -0
  22. package/es/Breadcrumb/index.js +9 -0
  23. package/es/Breadcrumb/index.js.map +1 -0
  24. package/es/CampaignBlock/CampaignBlock.js +131 -0
  25. package/es/CampaignBlock/CampaignBlock.js.map +1 -0
  26. package/es/CodeBlock/CodeBlock.js +25 -0
  27. package/es/CodeBlock/CodeBlock.js.map +1 -0
  28. package/es/CodeBlock/codeLanguageOptions.js +114 -0
  29. package/es/CodeBlock/codeLanguageOptions.js.map +1 -0
  30. package/es/Concept/Concept.js +50 -0
  31. package/es/Concept/Concept.js.map +1 -0
  32. package/es/ContactBlock/ContactBlock.js +145 -0
  33. package/es/ContactBlock/ContactBlock.js.map +1 -0
  34. package/es/ContentTypeBadge/ContentTypeBadge.js +41 -0
  35. package/es/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
  36. package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +25 -0
  37. package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
  38. package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +25 -0
  39. package/es/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
  40. package/es/ContentTypeHero/ContentTypeHero.js +39 -0
  41. package/es/ContentTypeHero/ContentTypeHero.js.map +1 -0
  42. package/es/CopyParagraphButton/CopyParagraphButton.js +62 -0
  43. package/es/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
  44. package/es/CopyParagraphButton/index.js +8 -0
  45. package/es/CopyParagraphButton/index.js.map +1 -0
  46. package/es/Embed/AudioEmbed.js +52 -0
  47. package/es/Embed/AudioEmbed.js.map +1 -0
  48. package/es/Embed/BrightcoveEmbed.js +96 -0
  49. package/es/Embed/BrightcoveEmbed.js.map +1 -0
  50. package/es/Embed/CodeEmbed.js +61 -0
  51. package/es/Embed/CodeEmbed.js.map +1 -0
  52. package/es/Embed/ConceptEmbed.js +78 -0
  53. package/es/Embed/ConceptEmbed.js.map +1 -0
  54. package/es/Embed/ConceptInlineTriggerButton.js +40 -0
  55. package/es/Embed/ConceptInlineTriggerButton.js.map +1 -0
  56. package/es/Embed/ContentLinkEmbed.js +31 -0
  57. package/es/Embed/ContentLinkEmbed.js.map +1 -0
  58. package/es/Embed/CopyrightEmbed.js +23 -0
  59. package/es/Embed/CopyrightEmbed.js.map +1 -0
  60. package/es/Embed/EmbedErrorPlaceholder.js +43 -0
  61. package/es/Embed/EmbedErrorPlaceholder.js.map +1 -0
  62. package/es/Embed/EmbedWrapper.js +26 -0
  63. package/es/Embed/EmbedWrapper.js.map +1 -0
  64. package/es/Embed/ExternalEmbed.js +54 -0
  65. package/es/Embed/ExternalEmbed.js.map +1 -0
  66. package/es/Embed/FootnoteEmbed.js +27 -0
  67. package/es/Embed/FootnoteEmbed.js.map +1 -0
  68. package/es/Embed/GlossEmbed.js +52 -0
  69. package/es/Embed/GlossEmbed.js.map +1 -0
  70. package/es/Embed/H5pEmbed.js +38 -0
  71. package/es/Embed/H5pEmbed.js.map +1 -0
  72. package/es/Embed/IframeEmbed.js +69 -0
  73. package/es/Embed/IframeEmbed.js.map +1 -0
  74. package/es/Embed/ImageEmbed.js +180 -0
  75. package/es/Embed/ImageEmbed.js.map +1 -0
  76. package/es/Embed/InlineTriggerButton.js +25 -0
  77. package/es/Embed/InlineTriggerButton.js.map +1 -0
  78. package/es/Embed/RelatedContentEmbed.js +38 -0
  79. package/es/Embed/RelatedContentEmbed.js.map +1 -0
  80. package/es/Embed/UnknownEmbed.js +20 -0
  81. package/es/Embed/UnknownEmbed.js.map +1 -0
  82. package/es/Embed/UuDisclaimerEmbed.js +54 -0
  83. package/es/Embed/UuDisclaimerEmbed.js.map +1 -0
  84. package/es/ErrorMessage/ErrorMessage.js +54 -0
  85. package/es/ErrorMessage/ErrorMessage.js.map +1 -0
  86. package/es/ErrorMessage/index.js +8 -0
  87. package/es/ErrorMessage/index.js.map +1 -0
  88. package/es/FactBox/FactBox.js +121 -0
  89. package/es/FactBox/FactBox.js.map +1 -0
  90. package/es/FactBox/index.js +8 -0
  91. package/es/FactBox/index.js.map +1 -0
  92. package/es/FileList/File.js +76 -0
  93. package/es/FileList/File.js.map +1 -0
  94. package/es/FileList/FileList.js +32 -0
  95. package/es/FileList/FileList.js.map +1 -0
  96. package/es/FileList/PdfFile.js +28 -0
  97. package/es/FileList/PdfFile.js.map +1 -0
  98. package/es/Gloss/Gloss.js +142 -0
  99. package/es/Gloss/Gloss.js.map +1 -0
  100. package/es/Gloss/GlossExample.js +46 -0
  101. package/es/Gloss/GlossExample.js.map +1 -0
  102. package/es/Grid/Grid.js +66 -0
  103. package/es/Grid/Grid.js.map +1 -0
  104. package/es/Grid/GridParallaxItem.js +21 -0
  105. package/es/Grid/GridParallaxItem.js.map +1 -0
  106. package/es/KeyFigure/KeyFigure.js +46 -0
  107. package/es/KeyFigure/KeyFigure.js.map +1 -0
  108. package/es/LicenseByline/EmbedByline.js +132 -0
  109. package/es/LicenseByline/EmbedByline.js.map +1 -0
  110. package/es/LicenseByline/LicenseLink.js +31 -0
  111. package/es/LicenseByline/LicenseLink.js.map +1 -0
  112. package/es/LinkBlock/LinkBlock.js +74 -0
  113. package/es/LinkBlock/LinkBlock.js.map +1 -0
  114. package/es/LinkBlock/LinkBlockSection.js +23 -0
  115. package/es/LinkBlock/LinkBlockSection.js.map +1 -0
  116. package/es/Pitch/Pitch.js +62 -0
  117. package/es/Pitch/Pitch.js.map +1 -0
  118. package/es/RelatedArticleList/RelatedArticleList.js +97 -0
  119. package/es/RelatedArticleList/RelatedArticleList.js.map +1 -0
  120. package/es/RelatedArticleList/index.js +8 -0
  121. package/es/RelatedArticleList/index.js.map +1 -0
  122. package/es/ResourceBox/ResourceBox.js +74 -0
  123. package/es/ResourceBox/ResourceBox.js.map +1 -0
  124. package/es/TagSelector/TagSelector.js +100 -0
  125. package/es/TagSelector/TagSelector.js.map +1 -0
  126. package/es/ZendeskButton/ZendeskButton.js +41 -0
  127. package/es/ZendeskButton/ZendeskButton.js.map +1 -0
  128. package/es/_virtual/rolldown_runtime.js +11 -0
  129. package/es/i18n/formatNestedMessages.js +17 -0
  130. package/es/i18n/formatNestedMessages.js.map +1 -0
  131. package/es/i18n/i18n.js +29 -0
  132. package/es/i18n/i18n.js.map +1 -0
  133. package/es/i18n/useComponentTranslations.js +155 -0
  134. package/es/i18n/useComponentTranslations.js.map +1 -0
  135. package/es/index.js +65 -0
  136. package/es/locale/messages-en.js +438 -0
  137. package/es/locale/messages-en.js.map +1 -0
  138. package/es/locale/messages-nb.js +438 -0
  139. package/es/locale/messages-nb.js.map +1 -0
  140. package/es/locale/messages-nn.js +438 -0
  141. package/es/locale/messages-nn.js.map +1 -0
  142. package/es/locale/messages-se.js +438 -0
  143. package/es/locale/messages-se.js.map +1 -0
  144. package/es/model/ContentType.js +72 -0
  145. package/es/model/ContentType.js.map +1 -0
  146. package/es/model/SubjectCategories.js +25 -0
  147. package/es/model/SubjectCategories.js.map +1 -0
  148. package/es/model/SubjectTypes.js +23 -0
  149. package/es/model/SubjectTypes.js.map +1 -0
  150. package/es/model/WordClass.js +53 -0
  151. package/es/model/WordClass.js.map +1 -0
  152. package/es/model/index.js +19 -0
  153. package/es/model/index.js.map +1 -0
  154. package/es/utils/licenseAttributes.js +16 -0
  155. package/es/utils/licenseAttributes.js.map +1 -0
  156. package/es/utils/relativeUrl.js +26 -0
  157. package/es/utils/relativeUrl.js.map +1 -0
  158. package/lib/Article/Article.js +134 -0
  159. package/lib/Article/Article.js.map +1 -0
  160. package/lib/Article/ArticleByline.js +135 -0
  161. package/lib/Article/ArticleByline.js.map +1 -0
  162. package/lib/Article/ArticleFootNotes.js +41 -0
  163. package/lib/Article/ArticleFootNotes.js.map +1 -0
  164. package/lib/AudioPlayer/AudioPlayer.js +158 -0
  165. package/lib/AudioPlayer/AudioPlayer.js.map +1 -0
  166. package/lib/AudioPlayer/Controls.js +255 -0
  167. package/lib/AudioPlayer/Controls.js.map +1 -0
  168. package/lib/AudioPlayer/SpeechControl.js +41 -0
  169. package/lib/AudioPlayer/SpeechControl.js.map +1 -0
  170. package/lib/AudioPlayer/index.js +8 -0
  171. package/lib/AudioPlayer/index.js.map +1 -0
  172. package/lib/Breadcrumb/Breadcrumb.js +45 -0
  173. package/lib/Breadcrumb/Breadcrumb.js.map +1 -0
  174. package/lib/Breadcrumb/BreadcrumbItem.js +37 -0
  175. package/lib/Breadcrumb/BreadcrumbItem.js.map +1 -0
  176. package/lib/Breadcrumb/HomeBreadcrumb.js +45 -0
  177. package/lib/Breadcrumb/HomeBreadcrumb.js.map +1 -0
  178. package/lib/Breadcrumb/index.js +9 -0
  179. package/lib/Breadcrumb/index.js.map +1 -0
  180. package/lib/CampaignBlock/CampaignBlock.js +132 -0
  181. package/lib/CampaignBlock/CampaignBlock.js.map +1 -0
  182. package/lib/CodeBlock/CodeBlock.js +26 -0
  183. package/lib/CodeBlock/CodeBlock.js.map +1 -0
  184. package/lib/CodeBlock/codeLanguageOptions.js +115 -0
  185. package/lib/CodeBlock/codeLanguageOptions.js.map +1 -0
  186. package/lib/Concept/Concept.js +51 -0
  187. package/lib/Concept/Concept.js.map +1 -0
  188. package/lib/ContactBlock/ContactBlock.js +147 -0
  189. package/lib/ContactBlock/ContactBlock.js.map +1 -0
  190. package/lib/ContentTypeBadge/ContentTypeBadge.js +43 -0
  191. package/lib/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
  192. package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +26 -0
  193. package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
  194. package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +26 -0
  195. package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
  196. package/lib/ContentTypeHero/ContentTypeHero.js +40 -0
  197. package/lib/ContentTypeHero/ContentTypeHero.js.map +1 -0
  198. package/lib/CopyParagraphButton/CopyParagraphButton.js +63 -0
  199. package/lib/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
  200. package/lib/CopyParagraphButton/index.js +8 -0
  201. package/lib/CopyParagraphButton/index.js.map +1 -0
  202. package/lib/Embed/AudioEmbed.js +53 -0
  203. package/lib/Embed/AudioEmbed.js.map +1 -0
  204. package/lib/Embed/BrightcoveEmbed.js +97 -0
  205. package/lib/Embed/BrightcoveEmbed.js.map +1 -0
  206. package/lib/Embed/CodeEmbed.js +62 -0
  207. package/lib/Embed/CodeEmbed.js.map +1 -0
  208. package/lib/Embed/ConceptEmbed.js +81 -0
  209. package/lib/Embed/ConceptEmbed.js.map +1 -0
  210. package/lib/Embed/ConceptInlineTriggerButton.js +41 -0
  211. package/lib/Embed/ConceptInlineTriggerButton.js.map +1 -0
  212. package/lib/Embed/ContentLinkEmbed.js +32 -0
  213. package/lib/Embed/ContentLinkEmbed.js.map +1 -0
  214. package/lib/Embed/CopyrightEmbed.js +24 -0
  215. package/lib/Embed/CopyrightEmbed.js.map +1 -0
  216. package/lib/Embed/EmbedErrorPlaceholder.js +44 -0
  217. package/lib/Embed/EmbedErrorPlaceholder.js.map +1 -0
  218. package/lib/Embed/EmbedWrapper.js +27 -0
  219. package/lib/Embed/EmbedWrapper.js.map +1 -0
  220. package/lib/Embed/ExternalEmbed.js +55 -0
  221. package/lib/Embed/ExternalEmbed.js.map +1 -0
  222. package/lib/Embed/FootnoteEmbed.js +28 -0
  223. package/lib/Embed/FootnoteEmbed.js.map +1 -0
  224. package/lib/Embed/GlossEmbed.js +53 -0
  225. package/lib/Embed/GlossEmbed.js.map +1 -0
  226. package/lib/Embed/H5pEmbed.js +39 -0
  227. package/lib/Embed/H5pEmbed.js.map +1 -0
  228. package/lib/Embed/IframeEmbed.js +70 -0
  229. package/lib/Embed/IframeEmbed.js.map +1 -0
  230. package/lib/Embed/ImageEmbed.js +183 -0
  231. package/lib/Embed/ImageEmbed.js.map +1 -0
  232. package/lib/Embed/InlineTriggerButton.js +26 -0
  233. package/lib/Embed/InlineTriggerButton.js.map +1 -0
  234. package/lib/Embed/RelatedContentEmbed.js +39 -0
  235. package/lib/Embed/RelatedContentEmbed.js.map +1 -0
  236. package/lib/Embed/UnknownEmbed.js +21 -0
  237. package/lib/Embed/UnknownEmbed.js.map +1 -0
  238. package/lib/Embed/UuDisclaimerEmbed.js +55 -0
  239. package/lib/Embed/UuDisclaimerEmbed.js.map +1 -0
  240. package/lib/ErrorMessage/ErrorMessage.js +55 -0
  241. package/lib/ErrorMessage/ErrorMessage.js.map +1 -0
  242. package/lib/ErrorMessage/index.js +8 -0
  243. package/lib/ErrorMessage/index.js.map +1 -0
  244. package/lib/FactBox/FactBox.js +122 -0
  245. package/lib/FactBox/FactBox.js.map +1 -0
  246. package/lib/FactBox/index.js +8 -0
  247. package/lib/FactBox/index.js.map +1 -0
  248. package/lib/FileList/File.js +78 -0
  249. package/lib/FileList/File.js.map +1 -0
  250. package/lib/FileList/FileList.js +35 -0
  251. package/lib/FileList/FileList.js.map +1 -0
  252. package/lib/FileList/PdfFile.js +29 -0
  253. package/lib/FileList/PdfFile.js.map +1 -0
  254. package/lib/Gloss/Gloss.js +143 -0
  255. package/lib/Gloss/Gloss.js.map +1 -0
  256. package/lib/Gloss/GlossExample.js +47 -0
  257. package/lib/Gloss/GlossExample.js.map +1 -0
  258. package/lib/Grid/Grid.js +67 -0
  259. package/lib/Grid/Grid.js.map +1 -0
  260. package/lib/Grid/GridParallaxItem.js +22 -0
  261. package/lib/Grid/GridParallaxItem.js.map +1 -0
  262. package/lib/KeyFigure/KeyFigure.js +47 -0
  263. package/lib/KeyFigure/KeyFigure.js.map +1 -0
  264. package/lib/LicenseByline/EmbedByline.js +134 -0
  265. package/lib/LicenseByline/EmbedByline.js.map +1 -0
  266. package/lib/LicenseByline/LicenseLink.js +32 -0
  267. package/lib/LicenseByline/LicenseLink.js.map +1 -0
  268. package/lib/LinkBlock/LinkBlock.js +75 -0
  269. package/lib/LinkBlock/LinkBlock.js.map +1 -0
  270. package/lib/LinkBlock/LinkBlockSection.js +24 -0
  271. package/lib/LinkBlock/LinkBlockSection.js.map +1 -0
  272. package/lib/Pitch/Pitch.js +63 -0
  273. package/lib/Pitch/Pitch.js.map +1 -0
  274. package/lib/RelatedArticleList/RelatedArticleList.js +99 -0
  275. package/lib/RelatedArticleList/RelatedArticleList.js.map +1 -0
  276. package/lib/RelatedArticleList/index.js +8 -0
  277. package/lib/RelatedArticleList/index.js.map +1 -0
  278. package/lib/ResourceBox/ResourceBox.js +75 -0
  279. package/lib/ResourceBox/ResourceBox.js.map +1 -0
  280. package/lib/TagSelector/TagSelector.js +108 -0
  281. package/lib/TagSelector/TagSelector.js.map +1 -0
  282. package/lib/ZendeskButton/ZendeskButton.js +42 -0
  283. package/lib/ZendeskButton/ZendeskButton.js.map +1 -0
  284. package/lib/_virtual/rolldown_runtime.js +42 -0
  285. package/lib/i18n/formatNestedMessages.js +18 -0
  286. package/lib/i18n/formatNestedMessages.js.map +1 -0
  287. package/lib/i18n/i18n.js +31 -0
  288. package/lib/i18n/i18n.js.map +1 -0
  289. package/lib/i18n/useComponentTranslations.js +163 -0
  290. package/lib/i18n/useComponentTranslations.js.map +1 -0
  291. package/lib/index.js +157 -0
  292. package/lib/locale/messages-en.js +439 -0
  293. package/lib/locale/messages-en.js.map +1 -0
  294. package/lib/locale/messages-nb.js +439 -0
  295. package/lib/locale/messages-nb.js.map +1 -0
  296. package/lib/locale/messages-nn.js +439 -0
  297. package/lib/locale/messages-nn.js.map +1 -0
  298. package/lib/locale/messages-se.js +439 -0
  299. package/lib/locale/messages-se.js.map +1 -0
  300. package/lib/model/ContentType.js +94 -0
  301. package/lib/model/ContentType.js.map +1 -0
  302. package/lib/model/SubjectCategories.js +30 -0
  303. package/lib/model/SubjectCategories.js.map +1 -0
  304. package/lib/model/SubjectTypes.js +28 -0
  305. package/lib/model/SubjectTypes.js.map +1 -0
  306. package/lib/model/WordClass.js +58 -0
  307. package/lib/model/WordClass.js.map +1 -0
  308. package/lib/model/index.js +19 -0
  309. package/lib/model/index.js.map +1 -0
  310. package/lib/utils/licenseAttributes.js +17 -0
  311. package/lib/utils/licenseAttributes.js.map +1 -0
  312. package/lib/utils/relativeUrl.js +26 -0
  313. package/lib/utils/relativeUrl.js.map +1 -0
  314. package/package.json +12 -11
@@ -0,0 +1,143 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const require_SpeechControl = require('../AudioPlayer/SpeechControl.js');
3
+ const require_GlossExample = require('./GlossExample.js');
4
+ const react = require_rolldown_runtime.__toESM(require("react"));
5
+ const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
6
+ const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
7
+ const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
8
+ const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
9
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
10
+ const __ark_ui_react = require_rolldown_runtime.__toESM(require("@ark-ui/react"));
11
+
12
+ //#region src/Gloss/Gloss.tsx
13
+ const getFilteredExamples = (glossData, exampleIds, exampleLangs) => {
14
+ if (exampleIds !== void 0 || exampleLangs !== void 0) {
15
+ const exampleIdsList = exampleIds?.toString()?.split(",") ?? [];
16
+ const exampleLangsList = exampleLangs?.split(",") ?? [];
17
+ const filteredExamples = glossData?.examples?.map((examples, i) => {
18
+ if (exampleIdsList.includes(i.toString())) return examples.filter((e) => exampleLangsList.includes(e.language));
19
+ return [];
20
+ }) ?? [];
21
+ const examplesWithoutEmpty = filteredExamples.filter((el) => !!el.length);
22
+ return examplesWithoutEmpty;
23
+ }
24
+ return glossData?.examples ?? [];
25
+ };
26
+ const Container = (0, __ndla_styled_system_jsx.styled)("div", { base: {
27
+ display: "flex",
28
+ alignItems: "center",
29
+ justifyContent: "space-between"
30
+ } });
31
+ const TextWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
32
+ display: "flex",
33
+ gap: "small"
34
+ } });
35
+ const StyledAccordionItemContent = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.AccordionItemContent, { base: { paddingInline: "0" } });
36
+ const StyledContainer = (0, __ndla_styled_system_jsx.styled)(Container, { base: { marginBlockStart: "3xsmall" } });
37
+ const StyledAccordionItem = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.AccordionItem, {
38
+ base: {
39
+ paddingBlock: "small",
40
+ paddingInline: "medium"
41
+ },
42
+ defaultVariants: { variant: "simple" },
43
+ variants: { variant: {
44
+ simple: {},
45
+ bordered: {
46
+ border: "1px solid",
47
+ borderColor: "stroke.subtle",
48
+ borderRadius: "xsmall"
49
+ }
50
+ } }
51
+ });
52
+ const Gloss = ({ title, glossData, audio, exampleIds, exampleLangs, variant }) => {
53
+ const { t } = (0, react_i18next.useTranslation)();
54
+ const filteredExamples = (0, react.useMemo)(() => getFilteredExamples(glossData, exampleIds, exampleLangs), [
55
+ exampleIds,
56
+ exampleLangs,
57
+ glossData
58
+ ]);
59
+ if (!glossData) return null;
60
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.AccordionRoot, {
61
+ multiple: true,
62
+ variant: "clean",
63
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledAccordionItem, {
64
+ value: "gloss",
65
+ variant,
66
+ children: [
67
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Container, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TextWrapper, { children: [
68
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
69
+ textStyle: "label.medium",
70
+ fontWeight: "bold",
71
+ asChild: true,
72
+ consumeCss: true,
73
+ lang: glossData.originalLanguage,
74
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: glossData.gloss })
75
+ }),
76
+ !!glossData.transcriptions.traditional && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
77
+ textStyle: "label.medium",
78
+ asChild: true,
79
+ consumeCss: true,
80
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
81
+ "aria-label": t("gloss.transcriptions.traditional"),
82
+ lang: glossData.originalLanguage,
83
+ children: glossData.transcriptions.traditional
84
+ }, t("gloss.transcriptions.traditional"))
85
+ }),
86
+ !!glossData.transcriptions.pinyin && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
87
+ textStyle: "label.medium",
88
+ asChild: true,
89
+ consumeCss: true,
90
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
91
+ "data-pinyin": "",
92
+ "aria-label": t("gloss.transcriptions.pinyin"),
93
+ lang: glossData.originalLanguage,
94
+ children: glossData.transcriptions.pinyin
95
+ }, t("gloss.transcriptions.pinyin"))
96
+ }),
97
+ !!glossData.wordClass && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
98
+ textStyle: "label.medium",
99
+ asChild: true,
100
+ consumeCss: true,
101
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
102
+ "aria-label": t("gloss.wordClass"),
103
+ children: t(`wordClass.${glossData.wordClass}`).toLowerCase()
104
+ })
105
+ })
106
+ ] }), !!audio?.src && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SpeechControl.SpeechControl_default, {
107
+ src: audio.src,
108
+ title: audio.title,
109
+ type: "gloss"
110
+ })] }),
111
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledContainer, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
112
+ textStyle: "label.medium",
113
+ asChild: true,
114
+ consumeCss: true,
115
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
116
+ lang: title.language,
117
+ children: title.title
118
+ })
119
+ }), !!filteredExamples.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ark_ui_react.AccordionItemTrigger, {
120
+ asChild: true,
121
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.IconButton, {
122
+ variant: "tertiary",
123
+ "aria-label": t("gloss.showExamples"),
124
+ title: t("gloss.showExamples"),
125
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.AccordionItemIndicator, {
126
+ asChild: true,
127
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.ArrowDownShortLine, { size: "medium" })
128
+ })
129
+ })
130
+ })] }),
131
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledAccordionItemContent, { children: filteredExamples.map((examples, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_GlossExample.GlossExample_default, {
132
+ examples,
133
+ originalLanguage: glossData.originalLanguage
134
+ }, `gloss-example-${index}`)) })
135
+ ]
136
+ })
137
+ });
138
+ };
139
+ var Gloss_default = Gloss;
140
+
141
+ //#endregion
142
+ exports.Gloss_default = Gloss_default;
143
+ //# sourceMappingURL=Gloss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gloss.js","names":["glossData: IGlossDataDTO | undefined","exampleIds: string | undefined","exampleLangs: string | undefined","AccordionItemContent","AccordionItem","AccordionRoot","Text","SpeechControl","AccordionItemTrigger","IconButton","AccordionItemIndicator","ArrowDownShortLine","GlossExample"],"sources":["../../src/Gloss/Gloss.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 { useMemo } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { AccordionItemTrigger } from \"@ark-ui/react\";\nimport { ArrowDownShortLine } from \"@ndla/icons\";\nimport {\n AccordionItem,\n AccordionItemContent,\n AccordionItemIndicator,\n AccordionRoot,\n IconButton,\n Text,\n} from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { StyledVariantProps } from \"@ndla/styled-system/types\";\nimport type { IGlossDataDTO, IGlossExampleDTO } from \"@ndla/types-backend/concept-api\";\nimport GlossExample from \"./GlossExample\";\nimport SpeechControl from \"../AudioPlayer/SpeechControl\";\n\n// TODO: Figure out padding between bordered and simple variant.\n// The design says that the content above the accordion content should have enough padding to align with the accordion content.\n// When a gloss is bordered there's way too much padding.\n\nconst getFilteredExamples = (\n glossData: IGlossDataDTO | undefined,\n exampleIds: string | undefined,\n exampleLangs: string | undefined,\n): IGlossExampleDTO[][] => {\n if (exampleIds !== undefined || exampleLangs !== undefined) {\n const exampleIdsList = exampleIds?.toString()?.split(\",\") ?? [];\n const exampleLangsList = exampleLangs?.split(\",\") ?? [];\n\n const filteredExamples =\n glossData?.examples?.map((examples, i) => {\n if (exampleIdsList.includes(i.toString())) {\n return examples.filter((e) => exampleLangsList.includes(e.language));\n }\n return [];\n }) ?? [];\n const examplesWithoutEmpty = filteredExamples.filter((el) => !!el.length);\n return examplesWithoutEmpty;\n }\n return glossData?.examples ?? [];\n};\n\nconst Container = styled(\"div\", {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"space-between\",\n },\n});\n\nconst TextWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"small\",\n },\n});\n\nconst StyledAccordionItemContent = styled(AccordionItemContent, {\n base: {\n paddingInline: \"0\",\n },\n});\n\nconst StyledContainer = styled(Container, {\n base: {\n marginBlockStart: \"3xsmall\",\n },\n});\n\nconst StyledAccordionItem = styled(AccordionItem, {\n base: {\n paddingBlock: \"small\",\n paddingInline: \"medium\",\n },\n defaultVariants: {\n variant: \"simple\",\n },\n variants: {\n variant: {\n simple: {},\n bordered: {\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n borderRadius: \"xsmall\",\n },\n },\n },\n});\n\ntype GlossVariantProps = StyledVariantProps<typeof StyledAccordionItem>;\n\nexport interface Props {\n title: {\n title: string;\n language: string;\n };\n glossData?: IGlossDataDTO;\n audio?: {\n title: string;\n src?: string;\n };\n exampleIds?: string;\n exampleLangs?: string;\n}\n\nconst Gloss = ({ title, glossData, audio, exampleIds, exampleLangs, variant }: Props & GlossVariantProps) => {\n const { t } = useTranslation();\n\n const filteredExamples = useMemo(\n () => getFilteredExamples(glossData, exampleIds, exampleLangs),\n [exampleIds, exampleLangs, glossData],\n );\n\n if (!glossData) return null;\n\n return (\n <AccordionRoot multiple variant=\"clean\">\n <StyledAccordionItem value=\"gloss\" variant={variant}>\n <Container>\n <TextWrapper>\n <Text textStyle=\"label.medium\" fontWeight=\"bold\" asChild consumeCss lang={glossData.originalLanguage}>\n <span>{glossData.gloss}</span>\n </Text>\n {!!glossData.transcriptions.traditional && (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span\n key={t(\"gloss.transcriptions.traditional\")}\n aria-label={t(\"gloss.transcriptions.traditional\")}\n lang={glossData.originalLanguage}\n >\n {glossData.transcriptions.traditional}\n </span>\n </Text>\n )}\n {!!glossData.transcriptions.pinyin && (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span\n data-pinyin=\"\"\n key={t(\"gloss.transcriptions.pinyin\")}\n aria-label={t(\"gloss.transcriptions.pinyin\")}\n lang={glossData.originalLanguage}\n >\n {glossData.transcriptions.pinyin}\n </span>\n </Text>\n )}\n {!!glossData.wordClass && (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span aria-label={t(\"gloss.wordClass\")}>{t(`wordClass.${glossData.wordClass}`).toLowerCase()}</span>\n </Text>\n )}\n </TextWrapper>\n {!!audio?.src && <SpeechControl src={audio.src} title={audio.title} type=\"gloss\" />}\n </Container>\n <StyledContainer>\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span lang={title.language}>{title.title}</span>\n </Text>\n {!!filteredExamples.length && (\n <AccordionItemTrigger asChild>\n <IconButton variant=\"tertiary\" aria-label={t(\"gloss.showExamples\")} title={t(\"gloss.showExamples\")}>\n <AccordionItemIndicator asChild>\n <ArrowDownShortLine size=\"medium\" />\n </AccordionItemIndicator>\n </IconButton>\n </AccordionItemTrigger>\n )}\n </StyledContainer>\n <StyledAccordionItemContent>\n {filteredExamples.map((examples, index) => (\n <GlossExample\n key={`gloss-example-${index}`}\n examples={examples}\n originalLanguage={glossData.originalLanguage}\n />\n ))}\n </StyledAccordionItemContent>\n </StyledAccordionItem>\n </AccordionRoot>\n );\n};\n\nexport default Gloss;\n"],"mappings":"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"}
@@ -0,0 +1,47 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const react = require_rolldown_runtime.__toESM(require("react"));
3
+ const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
4
+ const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
5
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
6
+
7
+ //#region src/Gloss/GlossExample.tsx
8
+ const StyledGlossExample = (0, __ndla_styled_system_jsx.styled)("div", { base: {
9
+ borderTop: "1px solid",
10
+ borderColor: "stroke.subtle",
11
+ paddingBlock: "xsmall",
12
+ paddingInline: "medium",
13
+ _first: {
14
+ background: "surface.brand.1.subtle",
15
+ borderColor: "stroke.default",
16
+ "& p": { fontWeight: "bold" }
17
+ }
18
+ } });
19
+ const PinyinText = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Text, { base: { fontStyle: "italic" } });
20
+ const GlossExample = ({ examples, originalLanguage }) => {
21
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: examples.map((examples$1, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [
22
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledGlossExample, {
23
+ lang: examples$1.language,
24
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
25
+ textStyle: "label.medium",
26
+ lang: examples$1.language,
27
+ children: examples$1.example
28
+ })
29
+ }),
30
+ !!examples$1.transcriptions.pinyin && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledGlossExample, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PinyinText, {
31
+ "data-pinyin": "",
32
+ lang: originalLanguage,
33
+ textStyle: "label.medium",
34
+ children: examples$1.transcriptions?.pinyin
35
+ }) }),
36
+ !!examples$1.transcriptions?.traditional && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledGlossExample, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
37
+ textStyle: "label.medium",
38
+ lang: originalLanguage,
39
+ children: examples$1.transcriptions.traditional
40
+ }) })
41
+ ] }, index)) });
42
+ };
43
+ var GlossExample_default = GlossExample;
44
+
45
+ //#endregion
46
+ exports.GlossExample_default = GlossExample_default;
47
+ //# sourceMappingURL=GlossExample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlossExample.js","names":["Text","examples","Fragment"],"sources":["../../src/Gloss/GlossExample.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 { Fragment } from \"react\";\nimport { Text } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { IGlossExampleDTO } from \"@ndla/types-backend/concept-api\";\n\ninterface Props {\n examples: IGlossExampleDTO[];\n originalLanguage: string | undefined;\n}\n\nconst StyledGlossExample = styled(\"div\", {\n base: {\n borderTop: \"1px solid\",\n borderColor: \"stroke.subtle\",\n paddingBlock: \"xsmall\",\n paddingInline: \"medium\",\n _first: {\n background: \"surface.brand.1.subtle\",\n borderColor: \"stroke.default\",\n \"& p\": {\n fontWeight: \"bold\",\n },\n },\n },\n});\n\nconst PinyinText = styled(Text, {\n base: {\n fontStyle: \"italic\",\n },\n});\n\nconst GlossExample = ({ examples, originalLanguage }: Props) => {\n return (\n <div>\n {examples.map((examples, index) => (\n <Fragment key={index}>\n <StyledGlossExample lang={examples.language}>\n <Text textStyle=\"label.medium\" lang={examples.language}>\n {examples.example}\n </Text>\n </StyledGlossExample>\n {!!examples.transcriptions.pinyin && (\n <StyledGlossExample>\n <PinyinText data-pinyin=\"\" lang={originalLanguage} textStyle=\"label.medium\">\n {examples.transcriptions?.pinyin}\n </PinyinText>\n </StyledGlossExample>\n )}\n {!!examples.transcriptions?.traditional && (\n <StyledGlossExample>\n <Text textStyle=\"label.medium\" lang={originalLanguage}>\n {examples.transcriptions.traditional}\n </Text>\n </StyledGlossExample>\n )}\n </Fragment>\n ))}\n </div>\n );\n};\n\nexport default GlossExample;\n"],"mappings":";;;;;;;AAkBA,MAAM,qBAAqB,qCAAO,OAAO,EACvC,MAAM;CACJ,WAAW;CACX,aAAa;CACb,cAAc;CACd,eAAe;CACf,QAAQ;EACN,YAAY;EACZ,aAAa;EACb,OAAO,EACL,YAAY,OACb;CACF;AACF,EACF,EAAC;AAEF,MAAM,aAAa,qCAAOA,wBAAM,EAC9B,MAAM,EACJ,WAAW,SACZ,EACF,EAAC;AAEF,MAAM,eAAe,CAAC,EAAE,UAAU,kBAAyB,KAAK;AAC9D,wBACE,2BAAC,mBACE,SAAS,IAAI,CAACC,YAAU,0BACvB,4BAACC;kBACC,2BAAC;GAAmB,MAAMD,WAAS;6BACjC,2BAACD;IAAK,WAAU;IAAe,MAAMC,WAAS;cAC3CA,WAAS;KACL;IACY;IAClBA,WAAS,eAAe,0BACzB,2BAAC,gDACC,2BAAC;GAAW,eAAY;GAAG,MAAM;GAAkB,WAAU;aAC1DA,WAAS,gBAAgB;IACf,GACM;IAEpBA,WAAS,gBAAgB,+BAC1B,2BAAC,gDACC,2BAACD;GAAK,WAAU;GAAe,MAAM;aAClCC,WAAS,eAAe;IACpB,GACY;MAlBV,MAoBJ,CACX,GACE;AAET;AAED,2BAAe"}
@@ -0,0 +1,67 @@
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
+
6
+ //#region src/Grid/Grid.tsx
7
+ const GridContainer = (0, __ndla_styled_system_jsx.styled)("div", {
8
+ base: {
9
+ display: "grid",
10
+ justifyContent: "center",
11
+ borderRadius: "xsmall",
12
+ gridRowGap: "large",
13
+ gridColumnGap: "medium",
14
+ width: "100%",
15
+ backgroundColor: "background.subtle",
16
+ minWidth: "surface.xxsmall",
17
+ gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
18
+ "& :not(div[data-parallax-cell='true']) > div[data-embed-type='pitch']": {
19
+ height: "100%",
20
+ "& > :last-child": { marginTop: "auto" }
21
+ },
22
+ tabletDown: { gridTemplateColumns: "repeat(1, minmax(0, 1fr))" },
23
+ tabletToDesktop: {
24
+ gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
25
+ "& > div:nth-child(3):last-child": {
26
+ display: "flex",
27
+ flexFlow: "column",
28
+ justifyContent: "center",
29
+ alignItems: "center",
30
+ gridColumn: "span 2"
31
+ }
32
+ }
33
+ },
34
+ variants: {
35
+ columns: {
36
+ "2": {},
37
+ "2x2": {},
38
+ "3": { desktop: { gridTemplateColumns: "repeat(3, minmax(0, 1fr))" } },
39
+ "4": { desktop: { gridTemplateColumns: "repeat(4, minmax(0, 1fr))" } }
40
+ },
41
+ background: {
42
+ white: { backgroundColor: "surface.default" },
43
+ transparent: { backgroundColor: "transparent" },
44
+ gray: { backgroundColor: "background.subtle" }
45
+ },
46
+ border: { lightBlue: {
47
+ padding: "xsmall",
48
+ border: "1px solid",
49
+ borderColor: "surface.brand.2"
50
+ } }
51
+ }
52
+ });
53
+ const Grid = ({ columns, border, children, background = "gray",...rest }) => {
54
+ const amountOfColumns = children?.length === 3 ? "3" : columns;
55
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GridContainer, {
56
+ "data-embed-type": "grid",
57
+ border: border === "none" ? void 0 : border,
58
+ columns: amountOfColumns,
59
+ background,
60
+ ...rest,
61
+ children
62
+ });
63
+ };
64
+
65
+ //#endregion
66
+ exports.Grid = Grid;
67
+ //# sourceMappingURL=Grid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Grid.js","names":[],"sources":["../../src/Grid/Grid.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 { type ComponentProps, type ReactNode } from \"react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\nconst GridContainer = styled(\"div\", {\n base: {\n display: \"grid\",\n justifyContent: \"center\",\n borderRadius: \"xsmall\",\n gridRowGap: \"large\",\n gridColumnGap: \"medium\",\n width: \"100%\",\n backgroundColor: \"background.subtle\",\n minWidth: \"surface.xxsmall\",\n gridTemplateColumns: \"repeat(2, minmax(0, 1fr))\",\n\n \"& :not(div[data-parallax-cell='true']) > div[data-embed-type='pitch']\": {\n height: \"100%\",\n \"& > :last-child\": {\n marginTop: \"auto\",\n },\n },\n tabletDown: {\n gridTemplateColumns: \"repeat(1, minmax(0, 1fr))\",\n },\n tabletToDesktop: {\n gridTemplateColumns: \"repeat(2, minmax(0, 1fr))\",\n \"& > div:nth-child(3):last-child\": {\n display: \"flex\",\n flexFlow: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gridColumn: \"span 2\",\n },\n },\n },\n variants: {\n columns: {\n \"2\": {},\n \"2x2\": {},\n \"3\": { desktop: { gridTemplateColumns: \"repeat(3, minmax(0, 1fr))\" } },\n \"4\": { desktop: { gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\" } },\n },\n background: {\n white: { backgroundColor: \"surface.default\" },\n transparent: { backgroundColor: \"transparent\" },\n gray: { backgroundColor: \"background.subtle\" },\n },\n border: {\n lightBlue: {\n padding: \"xsmall\",\n border: \"1px solid\",\n borderColor: \"surface.brand.2\",\n },\n },\n },\n});\n\nexport interface GridProps extends ComponentProps<\"div\"> {\n columns: \"2\" | \"3\" | \"4\" | \"2x2\";\n border?: \"none\" | \"lightBlue\";\n background?: \"transparent\" | \"white\" | \"gray\";\n children?: ReactNode[];\n}\n\nexport const Grid = ({ columns, border, children, background = \"gray\", ...rest }: GridProps) => {\n const amountOfColumns = children?.length === 3 ? \"3\" : columns;\n\n return (\n <GridContainer\n data-embed-type=\"grid\"\n border={border === \"none\" ? undefined : border}\n columns={amountOfColumns}\n background={background}\n {...rest}\n >\n {children}\n </GridContainer>\n );\n};\n"],"mappings":";;;;;;AAWA,MAAM,gBAAgB,qCAAO,OAAO;CAClC,MAAM;EACJ,SAAS;EACT,gBAAgB;EAChB,cAAc;EACd,YAAY;EACZ,eAAe;EACf,OAAO;EACP,iBAAiB;EACjB,UAAU;EACV,qBAAqB;EAErB,yEAAyE;GACvE,QAAQ;GACR,mBAAmB,EACjB,WAAW,OACZ;EACF;EACD,YAAY,EACV,qBAAqB,4BACtB;EACD,iBAAiB;GACf,qBAAqB;GACrB,mCAAmC;IACjC,SAAS;IACT,UAAU;IACV,gBAAgB;IAChB,YAAY;IACZ,YAAY;GACb;EACF;CACF;CACD,UAAU;EACR,SAAS;GACP,KAAK,CAAE;GACP,OAAO,CAAE;GACT,KAAK,EAAE,SAAS,EAAE,qBAAqB,4BAA6B,EAAE;GACtE,KAAK,EAAE,SAAS,EAAE,qBAAqB,4BAA6B,EAAE;EACvE;EACD,YAAY;GACV,OAAO,EAAE,iBAAiB,kBAAmB;GAC7C,aAAa,EAAE,iBAAiB,cAAe;GAC/C,MAAM,EAAE,iBAAiB,oBAAqB;EAC/C;EACD,QAAQ,EACN,WAAW;GACT,SAAS;GACT,QAAQ;GACR,aAAa;EACd,EACF;CACF;AACF,EAAC;AASF,MAAa,OAAO,CAAC,EAAE,SAAS,QAAQ,UAAU,aAAa,OAAQ,GAAG,MAAiB,KAAK;CAC9F,MAAM,kBAAkB,UAAU,WAAW,IAAI,MAAM;AAEvD,wBACE,2BAAC;EACC,mBAAgB;EAChB,QAAQ,WAAW,kBAAqB;EACxC,SAAS;EACG;EACZ,GAAI;EAEH;GACa;AAEnB"}
@@ -0,0 +1,22 @@
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
+
6
+ //#region src/Grid/GridParallaxItem.tsx
7
+ const StyledGridParallaxItem = (0, __ndla_styled_system_jsx.styled)("div", { base: {
8
+ position: "relative",
9
+ "& > div": {
10
+ top: "var(--masthead-height, 0px)",
11
+ position: "sticky"
12
+ }
13
+ } });
14
+ const GridParallaxItem = ({ children,...rest }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledGridParallaxItem, {
15
+ ...rest,
16
+ "data-embed-type": "grid-parallax",
17
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children })
18
+ });
19
+
20
+ //#endregion
21
+ exports.GridParallaxItem = GridParallaxItem;
22
+ //# sourceMappingURL=GridParallaxItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GridParallaxItem.js","names":[],"sources":["../../src/Grid/GridParallaxItem.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 HTMLAttributes } from \"react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\nconst StyledGridParallaxItem = styled(\"div\", {\n base: {\n position: \"relative\",\n \"& > div\": {\n top: \"var(--masthead-height, 0px)\",\n position: \"sticky\",\n },\n },\n});\n\nexport const GridParallaxItem = ({ children, ...rest }: HTMLAttributes<HTMLDivElement>) => (\n <StyledGridParallaxItem {...rest} data-embed-type=\"grid-parallax\">\n <div>{children}</div>\n </StyledGridParallaxItem>\n);\n"],"mappings":";;;;;;AAWA,MAAM,yBAAyB,qCAAO,OAAO,EAC3C,MAAM;CACJ,UAAU;CACV,WAAW;EACT,KAAK;EACL,UAAU;CACX;AACF,EACF,EAAC;AAEF,MAAa,mBAAmB,CAAC,EAAE,SAAU,GAAG,MAAsC,qBACpF,2BAAC;CAAuB,GAAI;CAAM,mBAAgB;2BAChD,2BAAC,SAAK,WAAe;EACE"}
@@ -0,0 +1,47 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
3
+ const html_react_parser = require_rolldown_runtime.__toESM(require("html-react-parser"));
4
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
5
+
6
+ //#region src/KeyFigure/KeyFigure.tsx
7
+ const ContentWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
8
+ display: "flex",
9
+ flexDirection: "column",
10
+ alignItems: "center",
11
+ justifyContent: "center",
12
+ gap: "xsmall",
13
+ "&:not(:has(> img))": { paddingBlock: "xxlarge" }
14
+ } });
15
+ const StyledImage = (0, __ndla_styled_system_jsx.styled)("img", { base: {
16
+ height: "surface.3xsmall",
17
+ width: "surface.3xsmall",
18
+ borderRadius: "xsmall"
19
+ } });
20
+ const TitleWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
21
+ textStyle: "heading.large",
22
+ textAlign: "center"
23
+ } });
24
+ const SubTitleWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
25
+ textStyle: "title.medium",
26
+ textAlign: "center"
27
+ } });
28
+ const KeyFigure = ({ image, title, subtitle }) => {
29
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ContentWrapper, {
30
+ "data-embed-type": "key-figure",
31
+ children: [
32
+ !!image && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledImage, {
33
+ src: `${image?.src}?width=150`,
34
+ width: 150,
35
+ height: 150,
36
+ alt: image?.alt
37
+ }),
38
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TitleWrapper, { children: (0, html_react_parser.default)(title) }),
39
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SubTitleWrapper, { children: (0, html_react_parser.default)(subtitle) })
40
+ ]
41
+ });
42
+ };
43
+ var KeyFigure_default = KeyFigure;
44
+
45
+ //#endregion
46
+ exports.KeyFigure_default = KeyFigure_default;
47
+ //# sourceMappingURL=KeyFigure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyFigure.js","names":[],"sources":["../../src/KeyFigure/KeyFigure.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 { styled } from \"@ndla/styled-system/jsx\";\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: \"xsmall\",\n\n \"&:not(:has(> img))\": {\n paddingBlock: \"xxlarge\",\n },\n },\n});\n\nconst StyledImage = styled(\"img\", {\n base: {\n height: \"surface.3xsmall\",\n width: \"surface.3xsmall\",\n borderRadius: \"xsmall\",\n },\n});\n\nconst TitleWrapper = styled(\"div\", {\n base: {\n textStyle: \"heading.large\",\n textAlign: \"center\",\n },\n});\n\nconst SubTitleWrapper = styled(\"div\", {\n base: {\n textStyle: \"title.medium\",\n textAlign: \"center\",\n },\n});\n\nexport interface Props {\n image?: {\n src?: string;\n alt?: string;\n };\n title: string;\n subtitle: string;\n}\n\nconst KeyFigure = ({ image, title, subtitle }: Props) => {\n return (\n <ContentWrapper data-embed-type=\"key-figure\">\n {!!image && <StyledImage src={`${image?.src}?width=150`} width={150} height={150} alt={image?.alt} />}\n <TitleWrapper>{parse(title)}</TitleWrapper>\n <SubTitleWrapper>{parse(subtitle)}</SubTitleWrapper>\n </ContentWrapper>\n );\n};\n\nexport default KeyFigure;\n"],"mappings":";;;;;;AAWA,MAAM,iBAAiB,qCAAO,OAAO,EACnC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,YAAY;CACZ,gBAAgB;CAChB,KAAK;CAEL,sBAAsB,EACpB,cAAc,UACf;AACF,EACF,EAAC;AAEF,MAAM,cAAc,qCAAO,OAAO,EAChC,MAAM;CACJ,QAAQ;CACR,OAAO;CACP,cAAc;AACf,EACF,EAAC;AAEF,MAAM,eAAe,qCAAO,OAAO,EACjC,MAAM;CACJ,WAAW;CACX,WAAW;AACZ,EACF,EAAC;AAEF,MAAM,kBAAkB,qCAAO,OAAO,EACpC,MAAM;CACJ,WAAW;CACX,WAAW;AACZ,EACF,EAAC;AAWF,MAAM,YAAY,CAAC,EAAE,OAAO,OAAO,UAAiB,KAAK;AACvD,wBACE,4BAAC;EAAe,mBAAgB;;KAC3B,yBAAS,2BAAC;IAAY,MAAM,EAAE,OAAO,IAAI;IAAa,OAAO;IAAK,QAAQ;IAAK,KAAK,OAAO;KAAO;mBACrG,2BAAC,0BAAc,+BAAM,MAAM,GAAgB;mBAC3C,2BAAC,6BAAiB,+BAAM,SAAS,GAAmB;;GACrC;AAEpB;AAED,wBAAe"}
@@ -0,0 +1,134 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const require_LicenseLink = require('./LicenseLink.js');
3
+ const react = require_rolldown_runtime.__toESM(require("react"));
4
+ const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
5
+ const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
6
+ const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
7
+ const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
8
+ const __ndla_licenses = require_rolldown_runtime.__toESM(require("@ndla/licenses"));
9
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
10
+
11
+ //#region src/LicenseByline/EmbedByline.tsx
12
+ const BylineWrapper = (0, __ndla_styled_system_jsx.styled)("figcaption", { base: {
13
+ display: "flex",
14
+ flexDirection: "column",
15
+ paddingBlock: "xsmall",
16
+ textStyle: "label.medium",
17
+ color: "text.subtle"
18
+ } });
19
+ const ErrorBylineWrapper = (0, __ndla_styled_system_jsx.styled)(BylineWrapper, { base: {
20
+ border: "1px solid",
21
+ borderColor: "stroke.error",
22
+ borderRadius: "xsmall",
23
+ background: "surface.dangerSubtle",
24
+ paddingInline: "medium",
25
+ paddingBlock: "medium"
26
+ } });
27
+ const StyledText = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Text, { base: { fontStyle: "italic" } });
28
+ const ContentWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
29
+ display: "flex",
30
+ gap: "xsmall",
31
+ alignItems: "center",
32
+ textStyle: "label.medium"
33
+ } });
34
+ const BaseDescription = (0, __ndla_styled_system_jsx.styled)("div", { base: {
35
+ display: "inline-flex",
36
+ whiteSpace: "pre-wrap"
37
+ } });
38
+ const EmbedByline = ({ type, description, children, visibleAlt, hideCopyright,...props }) => {
39
+ const { t } = (0, react_i18next.useTranslation)();
40
+ if (props.error) {
41
+ const typeString = type === "h5p" ? "H5P" : t(`embed.type.${type}`).toLowerCase();
42
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorBylineWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ContentWrapper, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.AlertLine, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BaseDescription, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("embed.embedError", { type: typeString }) }) })] }) });
43
+ }
44
+ const { copyright } = props;
45
+ const hideByline = hideCopyright && !description;
46
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [!hideByline && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BylineWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
47
+ !!hideCopyright && description,
48
+ !hideCopyright && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseContainerContent, {
49
+ type,
50
+ copyright,
51
+ children: description
52
+ }),
53
+ children
54
+ ] }) }), visibleAlt ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledText, {
55
+ color: "text.subtle",
56
+ textStyle: "label.medium",
57
+ asChild: true,
58
+ consumeCss: true,
59
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: `Alt: ${visibleAlt}` })
60
+ }) : null] });
61
+ };
62
+ const StyledDescription = (0, __ndla_styled_system_jsx.styled)(BaseDescription, { base: { mobileWideDown: {
63
+ display: "grid",
64
+ gridTemplateColumns: "1fr auto",
65
+ alignItems: "center",
66
+ overflow: "hidden",
67
+ _open: { display: "inline" }
68
+ } } });
69
+ const TextContent = (0, __ndla_styled_system_jsx.styled)("span", { base: { mobileWideDown: {
70
+ whiteSpace: "nowrap",
71
+ maxHeight: "large",
72
+ overflow: "hidden",
73
+ textOverflow: "ellipsis",
74
+ transitionProperty: "max-height",
75
+ transitionDuration: "slow",
76
+ transitionTimingFunction: "ease-in",
77
+ marginInlineEnd: "4xsmall",
78
+ _open: {
79
+ whiteSpace: "pre-wrap",
80
+ maxHeight: "none"
81
+ }
82
+ } } });
83
+ const StyledButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Button, { base: { mobileWide: { display: "none" } } });
84
+ const LicenseDescription = ({ children, isOpen, setIsOpen }) => {
85
+ const open = isOpen ? { "data-open": "" } : {};
86
+ const { t } = (0, react_i18next.useTranslation)();
87
+ const handleToggle = () => {
88
+ setIsOpen(!isOpen);
89
+ };
90
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContentWrapper, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledDescription, {
91
+ ...open,
92
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextContent, {
93
+ ...open,
94
+ children
95
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledButton, {
96
+ variant: "link",
97
+ size: "small",
98
+ onClick: handleToggle,
99
+ children: isOpen ? `${t("audio.readLessDescriptionLabel")}` : `${t("audio.readMoreDescriptionLabel")}`
100
+ })]
101
+ }) });
102
+ };
103
+ const LicenseContainerContent = ({ children, copyright, type }) => {
104
+ const { t, i18n } = (0, react_i18next.useTranslation)();
105
+ const license = copyright ? (0, __ndla_licenses.getLicenseByAbbreviation)(copyright.license?.license ?? "", i18n.language) : void 0;
106
+ const authors = (0, __ndla_licenses.getLicenseCredits)(copyright);
107
+ const captionAuthors = Object.values(authors).find((i) => i.length > 0) ?? [];
108
+ const [isOpen, setIsOpen] = (0, react.useState)(false);
109
+ const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
110
+ children,
111
+ ` ${t(`embed.type.${type}`)}${captionAuthors.length ? ": " : ""}`,
112
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: captionAuthors.map((author) => author.name).join(", ") }),
113
+ license ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [" / ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_LicenseLink.LicenseLink, {
114
+ license,
115
+ hideLink: !isOpen && !!children
116
+ })] }) : null
117
+ ] });
118
+ if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseDescription, {
119
+ isOpen,
120
+ setIsOpen,
121
+ children: content
122
+ });
123
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
124
+ textStyle: "label.medium",
125
+ asChild: true,
126
+ consumeCss: true,
127
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: content })
128
+ });
129
+ };
130
+
131
+ //#endregion
132
+ exports.EmbedByline = EmbedByline;
133
+ exports.LicenseContainerContent = LicenseContainerContent;
134
+ //# sourceMappingURL=EmbedByline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmbedByline.js","names":["Text","AlertLine","Button","LicenseLink"],"sources":["../../src/LicenseByline/EmbedByline.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 { type Dispatch, type ReactNode, type SetStateAction, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { AlertLine } from \"@ndla/icons\";\nimport { getLicenseByAbbreviation, getLicenseCredits } from \"@ndla/licenses\";\nimport { Button, Text } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { ICopyrightDTO as ArticleCopyright } from \"@ndla/types-backend/article-api\";\nimport type { ICopyrightDTO as AudioCopyright } from \"@ndla/types-backend/audio-api\";\nimport type { IDraftCopyrightDTO as ConceptCopyright } from \"@ndla/types-backend/concept-api\";\nimport type { ICopyrightDTO as ImageCopyright } from \"@ndla/types-backend/image-api\";\nimport type { BrightcoveCopyright } from \"@ndla/types-embed\";\nimport { LicenseLink } from \"./LicenseLink\";\n\ninterface BaseProps {\n description?: ReactNode;\n children?: ReactNode;\n visibleAlt?: string;\n error?: true | false;\n hideDescription?: boolean;\n hideCopyright?: boolean;\n}\n\nexport interface EmbedBylineErrorProps extends BaseProps {\n type: EmbedBylineTypeProps[\"type\"] | \"h5p\" | \"external\" | \"code\";\n error: true;\n}\n\ninterface ImageProps extends BaseProps {\n type: \"image\";\n copyright: ImageCopyright | undefined;\n}\n\ninterface BrightcoveProps extends BaseProps {\n type: \"video\";\n copyright: BrightcoveCopyright | undefined;\n}\n\ninterface AudioProps extends BaseProps {\n type: \"audio\";\n copyright: AudioCopyright | undefined;\n}\n\ninterface PodcastProps extends BaseProps {\n type: \"podcast\";\n copyright: AudioCopyright | undefined;\n}\n\ninterface ConceptProps extends BaseProps {\n type: \"concept\" | \"gloss\";\n copyright: ConceptCopyright | undefined;\n}\n\ninterface CopyrightProps extends BaseProps {\n type: \"copyright\";\n copyright: ArticleCopyright | undefined;\n}\n\nexport type EmbedBylineTypeProps =\n | ImageProps\n | BrightcoveProps\n | AudioProps\n | PodcastProps\n | ConceptProps\n | CopyrightProps;\n\ntype Props = EmbedBylineTypeProps | EmbedBylineErrorProps;\n\nconst BylineWrapper = styled(\"figcaption\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n paddingBlock: \"xsmall\",\n textStyle: \"label.medium\",\n color: \"text.subtle\",\n },\n});\n\nconst ErrorBylineWrapper = styled(BylineWrapper, {\n base: {\n border: \"1px solid\",\n borderColor: \"stroke.error\",\n borderRadius: \"xsmall\",\n background: \"surface.dangerSubtle\",\n paddingInline: \"medium\",\n paddingBlock: \"medium\",\n },\n});\n\nconst StyledText = styled(Text, {\n base: {\n fontStyle: \"italic\",\n },\n});\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"xsmall\",\n alignItems: \"center\",\n textStyle: \"label.medium\",\n },\n});\n\nconst BaseDescription = styled(\"div\", {\n base: {\n display: \"inline-flex\",\n whiteSpace: \"pre-wrap\",\n },\n});\n\nexport const EmbedByline = ({ type, description, children, visibleAlt, hideCopyright, ...props }: Props) => {\n const { t } = useTranslation();\n\n if (props.error) {\n const typeString = type === \"h5p\" ? \"H5P\" : t(`embed.type.${type}`).toLowerCase();\n return (\n <ErrorBylineWrapper>\n <ContentWrapper>\n <AlertLine />\n <BaseDescription>\n <span>{t(\"embed.embedError\", { type: typeString })}</span>\n </BaseDescription>\n </ContentWrapper>\n </ErrorBylineWrapper>\n );\n }\n\n const { copyright } = props;\n const hideByline = hideCopyright && !description;\n\n return (\n <>\n {!hideByline && (\n <BylineWrapper>\n <div>\n {!!hideCopyright && description}\n {!hideCopyright && (\n <LicenseContainerContent type={type} copyright={copyright}>\n {description}\n </LicenseContainerContent>\n )}\n {children}\n </div>\n </BylineWrapper>\n )}\n {visibleAlt ? (\n <StyledText color=\"text.subtle\" textStyle=\"label.medium\" asChild consumeCss>\n <span>{`Alt: ${visibleAlt}`}</span>\n </StyledText>\n ) : null}\n </>\n );\n};\n\ninterface LicenseContainerProps {\n children?: ReactNode;\n copyright: EmbedBylineTypeProps[\"copyright\"];\n type: Props[\"type\"];\n}\n\nconst StyledDescription = styled(BaseDescription, {\n base: {\n mobileWideDown: {\n display: \"grid\",\n gridTemplateColumns: \"1fr auto\",\n alignItems: \"center\",\n overflow: \"hidden\",\n _open: {\n display: \"inline\",\n },\n },\n },\n});\n\nconst TextContent = styled(\"span\", {\n base: {\n mobileWideDown: {\n whiteSpace: \"nowrap\",\n maxHeight: \"large\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n transitionProperty: \"max-height\",\n transitionDuration: \"slow\",\n transitionTimingFunction: \"ease-in\",\n marginInlineEnd: \"4xsmall\",\n _open: {\n whiteSpace: \"pre-wrap\",\n maxHeight: \"none\",\n },\n },\n },\n});\n\nconst StyledButton = styled(Button, {\n base: {\n mobileWide: {\n display: \"none\",\n },\n },\n});\n\ninterface LicenseDescriptionProps {\n children?: ReactNode;\n isOpen: boolean;\n setIsOpen: Dispatch<SetStateAction<boolean>>;\n}\n\nconst LicenseDescription = ({ children, isOpen, setIsOpen }: LicenseDescriptionProps) => {\n const open = isOpen ? { \"data-open\": \"\" } : {};\n const { t } = useTranslation();\n\n const handleToggle = () => {\n setIsOpen(!isOpen);\n };\n\n return (\n <ContentWrapper>\n <StyledDescription {...open}>\n <TextContent {...open}>{children}</TextContent>\n <StyledButton variant=\"link\" size=\"small\" onClick={handleToggle}>\n {isOpen ? `${t(\"audio.readLessDescriptionLabel\")}` : `${t(\"audio.readMoreDescriptionLabel\")}`}\n </StyledButton>\n </StyledDescription>\n </ContentWrapper>\n );\n};\n\nexport const LicenseContainerContent = ({ children, copyright, type }: LicenseContainerProps) => {\n const { t, i18n } = useTranslation();\n const license = copyright ? getLicenseByAbbreviation(copyright.license?.license ?? \"\", i18n.language) : undefined;\n const authors = getLicenseCredits(copyright);\n const captionAuthors = Object.values(authors).find((i) => i.length > 0) ?? [];\n const [isOpen, setIsOpen] = useState<boolean>(false);\n\n const content = (\n <>\n {children}\n {` ${t(`embed.type.${type}`)}${captionAuthors.length ? \": \" : \"\"}`}\n <span>{captionAuthors.map((author) => author.name).join(\", \")}</span>\n {license ? (\n <>\n {\" / \"}\n {<LicenseLink license={license} hideLink={!isOpen && !!children} />}\n </>\n ) : null}\n </>\n );\n\n if (children) {\n return (\n <LicenseDescription isOpen={isOpen} setIsOpen={setIsOpen}>\n {content}\n </LicenseDescription>\n );\n }\n\n return (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span>{content}</span>\n </Text>\n );\n};\n"],"mappings":"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"}
@@ -0,0 +1,32 @@
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 __ndla_safelink = require_rolldown_runtime.__toESM(require("@ndla/safelink"));
5
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
6
+
7
+ //#region src/LicenseByline/LicenseLink.tsx
8
+ const StyledSafeLink = (0, __ndla_styled_system_jsx.styled)(__ndla_safelink.SafeLink, { base: {
9
+ color: "text.link",
10
+ textDecoration: "underline",
11
+ whiteSpace: "nowrap",
12
+ _hover: { textDecoration: "none" },
13
+ _focusWithin: { textDecoration: "none" },
14
+ mobileWideDown: { _disabled: { display: "none" } }
15
+ } });
16
+ const LicenseLink = (0, react.forwardRef)(({ license, hideLink,...rest }, ref) => {
17
+ const disabled = hideLink ? { "data-disabled": "" } : {};
18
+ if (license.abbreviation === "unknown") return null;
19
+ if (license.url?.length) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledSafeLink, {
20
+ to: license.url,
21
+ rel: "license",
22
+ ...disabled,
23
+ ...rest,
24
+ ref,
25
+ children: license.abbreviation
26
+ });
27
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: license.abbreviation });
28
+ });
29
+
30
+ //#endregion
31
+ exports.LicenseLink = LicenseLink;
32
+ //# sourceMappingURL=LicenseLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LicenseLink.js","names":["SafeLink"],"sources":["../../src/LicenseByline/LicenseLink.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 { forwardRef } from \"react\";\nimport type { LicenseLocaleType } from \"@ndla/licenses\";\nimport { SafeLink, type SafeLinkProps } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\ninterface Props extends Omit<SafeLinkProps, \"to\"> {\n license: LicenseLocaleType;\n hideLink?: boolean;\n}\n\nconst StyledSafeLink = styled(SafeLink, {\n base: {\n color: \"text.link\",\n textDecoration: \"underline\",\n whiteSpace: \"nowrap\",\n _hover: {\n textDecoration: \"none\",\n },\n _focusWithin: {\n textDecoration: \"none\",\n },\n mobileWideDown: {\n _disabled: {\n display: \"none\",\n },\n },\n },\n});\n\nexport const LicenseLink = forwardRef<HTMLAnchorElement, Props>(({ license, hideLink, ...rest }, ref) => {\n const disabled = hideLink ? { \"data-disabled\": \"\" } : {};\n if (license.abbreviation === \"unknown\") {\n return null;\n }\n if (license.url?.length) {\n return (\n <StyledSafeLink to={license.url} rel=\"license\" {...disabled} {...rest} ref={ref}>\n {license.abbreviation}\n </StyledSafeLink>\n );\n }\n return <span>{license.abbreviation}</span>;\n});\n"],"mappings":";;;;;;;AAkBA,MAAM,iBAAiB,qCAAOA,0BAAU,EACtC,MAAM;CACJ,OAAO;CACP,gBAAgB;CAChB,YAAY;CACZ,QAAQ,EACN,gBAAgB,OACjB;CACD,cAAc,EACZ,gBAAgB,OACjB;CACD,gBAAgB,EACd,WAAW,EACT,SAAS,OACV,EACF;AACF,EACF,EAAC;AAEF,MAAa,cAAc,sBAAqC,CAAC,EAAE,SAAS,SAAU,GAAG,MAAM,EAAE,QAAQ;CACvG,MAAM,WAAW,WAAW,EAAE,iBAAiB,GAAI,IAAG,CAAE;AACxD,KAAI,QAAQ,iBAAiB,UAC3B,QAAO;AAET,KAAI,QAAQ,KAAK,OACf,wBACE,2BAAC;EAAe,IAAI,QAAQ;EAAK,KAAI;EAAU,GAAI;EAAU,GAAI;EAAW;YACzE,QAAQ;GACM;AAGrB,wBAAO,2BAAC,oBAAM,QAAQ,eAAoB;AAC3C,EAAC"}