@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,177 +1,121 @@
1
- /**
2
- * Copyright (c) 2016-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 React, { forwardRef, useCallback, useEffect, useId, useMemo, useState } from "react";
10
- import { useTranslation } from "react-i18next";
11
- import { ArrowDownShortLine } from "@ndla/icons";
12
2
  import { IconButton } from "@ndla/primitives";
13
3
  import { styled } from "@ndla/styled-system/jsx";
14
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ import { useTranslation } from "react-i18next";
5
+ import { ArrowDownShortLine } from "@ndla/icons";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+
8
+ //#region src/FactBox/FactBox.tsx
15
9
  const StyledAside = styled("aside", {
16
- base: {
17
- position: "relative",
18
- padding: "medium",
19
- display: "grid",
20
- gridTemplateRows: "0fr",
21
- transitionProperty: "grid-template-rows",
22
- transitionDuration: "slow",
23
- transitionTimingFunction: "ease-in-out",
24
- justifyItems: "center",
25
- border: "1px solid",
26
- borderColor: "stroke.default",
27
- borderRadius: "xsmall",
28
- clear: "both",
29
- _open: {
30
- gridTemplateRows: "1fr"
31
- },
32
- _closed: {
33
- _print: {
34
- overflow: "visible",
35
- maxHeight: "500vh"
36
- }
37
- },
38
- "& > div": {
39
- minHeight: "surface.3xsmall"
40
- }
41
- },
42
- variants: {
43
- overflowHidden: {
44
- true: {
45
- "& > div": {
46
- overflow: "hidden"
47
- }
48
- }
49
- }
50
- }
51
- });
52
- const StyledContent = styled("div", {
53
- base: {
54
- position: "relative",
55
- width: "100%",
56
- // Reset the top margin of the very first child.
57
- "& :first-child": {
58
- marginBlockStart: "0"
59
- },
60
- _after: {
61
- content: '""',
62
- textAlign: "center",
63
- position: "absolute",
64
- inset: "0",
65
- transitionProperty: "opacity",
66
- transitionDuration: "slow",
67
- transitionTimingFunction: "ease-in-out",
68
- gradientFrom: "surface.default/20",
69
- gradientTo: "surface.default/95",
70
- backgroundGradient: "to-b",
71
- opacity: "1",
72
- zIndex: "base",
73
- pointerEvents: "none"
74
- },
75
- _print: {
76
- overflow: "visible",
77
- _after: {
78
- display: "none"
79
- }
80
- },
81
- _open: {
82
- paddingBlockEnd: "xsmall",
83
- _after: {
84
- opacity: "0"
85
- }
86
- }
87
- }
10
+ base: {
11
+ position: "relative",
12
+ padding: "medium",
13
+ display: "grid",
14
+ gridTemplateRows: "0fr",
15
+ transitionProperty: "grid-template-rows",
16
+ transitionDuration: "slow",
17
+ transitionTimingFunction: "ease-in-out",
18
+ justifyItems: "center",
19
+ border: "1px solid",
20
+ borderColor: "stroke.default",
21
+ borderRadius: "xsmall",
22
+ clear: "both",
23
+ _open: { gridTemplateRows: "1fr" },
24
+ _closed: { _print: {
25
+ overflow: "visible",
26
+ maxHeight: "500vh"
27
+ } },
28
+ "& > div": { minHeight: "surface.3xsmall" }
29
+ },
30
+ variants: { overflowHidden: { true: { "& > div": { overflow: "hidden" } } } }
88
31
  });
89
- const StyledIconButton = styled(IconButton, {
90
- base: {
91
- position: "absolute",
92
- bottom: "-medium",
93
- zIndex: "base",
94
- "& svg": {
95
- transitionProperty: "transform",
96
- transitionTimingFunction: "ease-in-out",
97
- transitionDuration: "fast"
98
- },
99
- _open: {
100
- "& svg": {
101
- transform: "rotate(180deg)"
102
- }
103
- },
104
- _print: {
105
- display: "none"
106
- }
107
- }
32
+ const StyledContent = styled("div", { base: {
33
+ position: "relative",
34
+ width: "100%",
35
+ "& :first-child": { marginBlockStart: "0" },
36
+ _after: {
37
+ content: "\"\"",
38
+ textAlign: "center",
39
+ position: "absolute",
40
+ inset: "0",
41
+ transitionProperty: "opacity",
42
+ transitionDuration: "slow",
43
+ transitionTimingFunction: "ease-in-out",
44
+ gradientFrom: "surface.default/20",
45
+ gradientTo: "surface.default/95",
46
+ backgroundGradient: "to-b",
47
+ opacity: "1",
48
+ zIndex: "base",
49
+ pointerEvents: "none"
50
+ },
51
+ _print: {
52
+ overflow: "visible",
53
+ _after: { display: "none" }
54
+ },
55
+ _open: {
56
+ paddingBlockEnd: "xsmall",
57
+ _after: { opacity: "0" }
58
+ }
59
+ } });
60
+ const StyledIconButton = styled(IconButton, { base: {
61
+ position: "absolute",
62
+ bottom: "-medium",
63
+ zIndex: "base",
64
+ "& svg": {
65
+ transitionProperty: "transform",
66
+ transitionTimingFunction: "ease-in-out",
67
+ transitionDuration: "fast"
68
+ },
69
+ _open: { "& svg": { transform: "rotate(180deg)" } },
70
+ _print: { display: "none" }
71
+ } });
72
+ const FactBox = forwardRef(({ children, open, onOpenChange, defaultOpen = false,...rest }, ref) => {
73
+ const { t } = useTranslation();
74
+ const [state, setState] = useState(defaultOpen ? "open" : "closed");
75
+ const [overflowHidden, setOverflowHidden] = useState(!defaultOpen);
76
+ const contentId = useId();
77
+ const inertAttribute = useMemo(() => {
78
+ return state === "closed" ? { inert: typeof React.use === "function" ? true : "" } : {};
79
+ }, [state]);
80
+ useEffect(() => {
81
+ if (open !== void 0) setState(open ? "open" : "closed");
82
+ }, [open]);
83
+ const onClick = useCallback(() => {
84
+ const newState = state === "open" ? "closed" : "open";
85
+ setState(newState);
86
+ onOpenChange?.(newState === "open");
87
+ }, [state, onOpenChange]);
88
+ return /* @__PURE__ */ jsxs(StyledAside, {
89
+ "data-state": state,
90
+ "data-embed-type": "factbox",
91
+ ...rest,
92
+ ref,
93
+ overflowHidden,
94
+ onTransitionStart: (e) => {
95
+ if (e.target === e.currentTarget && state === "closed") setOverflowHidden(true);
96
+ },
97
+ onTransitionEnd: (e) => {
98
+ if (e.target === e.currentTarget && state === "open") setOverflowHidden(false);
99
+ },
100
+ children: [/* @__PURE__ */ jsx(StyledIconButton, {
101
+ "data-state": state,
102
+ onClick,
103
+ contentEditable: false,
104
+ "aria-expanded": state === "open",
105
+ "aria-controls": contentId,
106
+ "aria-label": t(`factbox.${state === "open" ? "close" : "open"}`),
107
+ children: /* @__PURE__ */ jsx(ArrowDownShortLine, {})
108
+ }), /* @__PURE__ */ jsx(StyledContent, {
109
+ id: contentId,
110
+ "data-state": state,
111
+ "aria-hidden": state === "closed",
112
+ ...inertAttribute,
113
+ children
114
+ })]
115
+ });
108
116
  });
117
+ var FactBox_default = FactBox;
109
118
 
110
- // TODO: Consider moving the open trigger depending on whether the content is open or closed.
111
-
112
- const FactBox = /*#__PURE__*/forwardRef((_ref, ref) => {
113
- let {
114
- children,
115
- open,
116
- onOpenChange,
117
- defaultOpen = false,
118
- ...rest
119
- } = _ref;
120
- const {
121
- t
122
- } = useTranslation();
123
- const [state, setState] = useState(defaultOpen ? "open" : "closed");
124
- const [overflowHidden, setOverflowHidden] = useState(!defaultOpen);
125
- const contentId = useId();
126
- // Inert has existed since early 2023. It allows us to disable tabindex inside the content if it is closed, allowing us to be accessible for users with newish browsers. React 18 removes this because it doesn't recognize the attribute. This is a workaround for that.
127
- // When running in React 18, we need to use an empty string instead of true.
128
- // TODO: Remove this hack once we upgrade to React 19 as a peer dep.
129
- const inertAttribute = useMemo(() => {
130
- return state === "closed" ? {
131
- inert: typeof React.use === "function" ? true : ""
132
- } : {};
133
- }, [state]);
134
- useEffect(() => {
135
- if (open !== undefined) {
136
- setState(open ? "open" : "closed");
137
- }
138
- }, [open]);
139
- const onClick = useCallback(() => {
140
- const newState = state === "open" ? "closed" : "open";
141
- setState(newState);
142
- onOpenChange?.(newState === "open");
143
- }, [state, onOpenChange]);
144
- return /*#__PURE__*/_jsxs(StyledAside, {
145
- "data-state": state,
146
- "data-embed-type": "factbox",
147
- ...rest,
148
- ref: ref,
149
- overflowHidden: overflowHidden,
150
- onTransitionStart: e => {
151
- if (e.target === e.currentTarget && state === "closed") {
152
- setOverflowHidden(true);
153
- }
154
- },
155
- onTransitionEnd: e => {
156
- if (e.target === e.currentTarget && state === "open") {
157
- setOverflowHidden(false);
158
- }
159
- },
160
- children: [/*#__PURE__*/_jsx(StyledIconButton, {
161
- "data-state": state,
162
- onClick: onClick,
163
- contentEditable: false,
164
- "aria-expanded": state === "open",
165
- "aria-controls": contentId,
166
- "aria-label": t(`factbox.${state === "open" ? "close" : "open"}`),
167
- children: /*#__PURE__*/_jsx(ArrowDownShortLine, {})
168
- }), /*#__PURE__*/_jsx(StyledContent, {
169
- id: contentId,
170
- "data-state": state,
171
- "aria-hidden": state === "closed",
172
- ...inertAttribute,
173
- children: children
174
- })]
175
- });
176
- });
177
- export default FactBox;
119
+ //#endregion
120
+ export { FactBox_default };
121
+ //# sourceMappingURL=FactBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FactBox.js","names":[],"sources":["../../src/FactBox/FactBox.tsx"],"sourcesContent":["/**\n * Copyright (c) 2016-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 React, {\n type ComponentProps,\n type ReactNode,\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useState,\n} from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { ArrowDownShortLine } from \"@ndla/icons\";\nimport { IconButton } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\ninterface Props extends ComponentProps<\"aside\"> {\n children?: ReactNode;\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\nconst StyledAside = styled(\"aside\", {\n base: {\n position: \"relative\",\n padding: \"medium\",\n display: \"grid\",\n gridTemplateRows: \"0fr\",\n transitionProperty: \"grid-template-rows\",\n transitionDuration: \"slow\",\n transitionTimingFunction: \"ease-in-out\",\n justifyItems: \"center\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n borderRadius: \"xsmall\",\n clear: \"both\",\n _open: {\n gridTemplateRows: \"1fr\",\n },\n _closed: {\n _print: {\n overflow: \"visible\",\n maxHeight: \"500vh\",\n },\n },\n \"& > div\": {\n minHeight: \"surface.3xsmall\",\n },\n },\n variants: {\n overflowHidden: {\n true: {\n \"& > div\": {\n overflow: \"hidden\",\n },\n },\n },\n },\n});\n\nconst StyledContent = styled(\"div\", {\n base: {\n position: \"relative\",\n width: \"100%\",\n // Reset the top margin of the very first child.\n \"& :first-child\": {\n marginBlockStart: \"0\",\n },\n _after: {\n content: '\"\"',\n textAlign: \"center\",\n position: \"absolute\",\n inset: \"0\",\n transitionProperty: \"opacity\",\n transitionDuration: \"slow\",\n transitionTimingFunction: \"ease-in-out\",\n gradientFrom: \"surface.default/20\",\n gradientTo: \"surface.default/95\",\n backgroundGradient: \"to-b\",\n opacity: \"1\",\n zIndex: \"base\",\n pointerEvents: \"none\",\n },\n _print: {\n overflow: \"visible\",\n _after: {\n display: \"none\",\n },\n },\n _open: {\n paddingBlockEnd: \"xsmall\",\n _after: {\n opacity: \"0\",\n },\n },\n },\n});\n\nconst StyledIconButton = styled(IconButton, {\n base: {\n position: \"absolute\",\n bottom: \"-medium\",\n zIndex: \"base\",\n \"& svg\": {\n transitionProperty: \"transform\",\n transitionTimingFunction: \"ease-in-out\",\n transitionDuration: \"fast\",\n },\n _open: {\n \"& svg\": {\n transform: \"rotate(180deg)\",\n },\n },\n _print: {\n display: \"none\",\n },\n },\n});\n\n// TODO: Consider moving the open trigger depending on whether the content is open or closed.\n\nconst FactBox = forwardRef<HTMLElement, Props>(\n ({ children, open, onOpenChange, defaultOpen = false, ...rest }, ref) => {\n const { t } = useTranslation();\n const [state, setState] = useState<\"open\" | \"closed\">(defaultOpen ? \"open\" : \"closed\");\n const [overflowHidden, setOverflowHidden] = useState(!defaultOpen);\n const contentId = useId();\n // Inert has existed since early 2023. It allows us to disable tabindex inside the content if it is closed, allowing us to be accessible for users with newish browsers. React 18 removes this because it doesn't recognize the attribute. This is a workaround for that.\n // When running in React 18, we need to use an empty string instead of true.\n // TODO: Remove this hack once we upgrade to React 19 as a peer dep.\n const inertAttribute = useMemo(() => {\n return state === \"closed\" ? { inert: typeof React.use === \"function\" ? true : \"\" } : {};\n }, [state]) as { inert?: boolean };\n\n useEffect(() => {\n if (open !== undefined) {\n setState(open ? \"open\" : \"closed\");\n }\n }, [open]);\n\n const onClick = useCallback(() => {\n const newState = state === \"open\" ? \"closed\" : \"open\";\n setState(newState);\n onOpenChange?.(newState === \"open\");\n }, [state, onOpenChange]);\n\n return (\n <StyledAside\n data-state={state}\n data-embed-type=\"factbox\"\n {...rest}\n ref={ref}\n overflowHidden={overflowHidden}\n onTransitionStart={(e) => {\n if (e.target === e.currentTarget && state === \"closed\") {\n setOverflowHidden(true);\n }\n }}\n onTransitionEnd={(e) => {\n if (e.target === e.currentTarget && state === \"open\") {\n setOverflowHidden(false);\n }\n }}\n >\n <StyledIconButton\n data-state={state}\n onClick={onClick}\n contentEditable={false}\n aria-expanded={state === \"open\"}\n aria-controls={contentId}\n aria-label={t(`factbox.${state === \"open\" ? \"close\" : \"open\"}`)}\n >\n <ArrowDownShortLine />\n </StyledIconButton>\n <StyledContent id={contentId} data-state={state} aria-hidden={state === \"closed\"} {...inertAttribute}>\n {children}\n </StyledContent>\n </StyledAside>\n );\n },\n);\n\nexport default FactBox;\n"],"mappings":";;;;;;;;AA8BA,MAAM,cAAc,OAAO,SAAS;CAClC,MAAM;EACJ,UAAU;EACV,SAAS;EACT,SAAS;EACT,kBAAkB;EAClB,oBAAoB;EACpB,oBAAoB;EACpB,0BAA0B;EAC1B,cAAc;EACd,QAAQ;EACR,aAAa;EACb,cAAc;EACd,OAAO;EACP,OAAO,EACL,kBAAkB,MACnB;EACD,SAAS,EACP,QAAQ;GACN,UAAU;GACV,WAAW;EACZ,EACF;EACD,WAAW,EACT,WAAW,kBACZ;CACF;CACD,UAAU,EACR,gBAAgB,EACd,MAAM,EACJ,WAAW,EACT,UAAU,SACX,EACF,EACF,EACF;AACF,EAAC;AAEF,MAAM,gBAAgB,OAAO,OAAO,EAClC,MAAM;CACJ,UAAU;CACV,OAAO;CAEP,kBAAkB,EAChB,kBAAkB,IACnB;CACD,QAAQ;EACN,SAAS;EACT,WAAW;EACX,UAAU;EACV,OAAO;EACP,oBAAoB;EACpB,oBAAoB;EACpB,0BAA0B;EAC1B,cAAc;EACd,YAAY;EACZ,oBAAoB;EACpB,SAAS;EACT,QAAQ;EACR,eAAe;CAChB;CACD,QAAQ;EACN,UAAU;EACV,QAAQ,EACN,SAAS,OACV;CACF;CACD,OAAO;EACL,iBAAiB;EACjB,QAAQ,EACN,SAAS,IACV;CACF;AACF,EACF,EAAC;AAEF,MAAM,mBAAmB,OAAO,YAAY,EAC1C,MAAM;CACJ,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,SAAS;EACP,oBAAoB;EACpB,0BAA0B;EAC1B,oBAAoB;CACrB;CACD,OAAO,EACL,SAAS,EACP,WAAW,iBACZ,EACF;CACD,QAAQ,EACN,SAAS,OACV;AACF,EACF,EAAC;AAIF,MAAM,UAAU,WACd,CAAC,EAAE,UAAU,MAAM,cAAc,cAAc,MAAO,GAAG,MAAM,EAAE,QAAQ;CACvE,MAAM,EAAE,GAAG,GAAG,gBAAgB;CAC9B,MAAM,CAAC,OAAO,SAAS,GAAG,SAA4B,cAAc,SAAS,SAAS;CACtF,MAAM,CAAC,gBAAgB,kBAAkB,GAAG,UAAU,YAAY;CAClE,MAAM,YAAY,OAAO;CAIzB,MAAM,iBAAiB,QAAQ,MAAM;AACnC,SAAO,UAAU,WAAW,EAAE,cAAc,MAAM,QAAQ,aAAa,OAAO,GAAI,IAAG,CAAE;CACxF,GAAE,CAAC,KAAM,EAAC;AAEX,WAAU,MAAM;AACd,MAAI,gBACF,UAAS,OAAO,SAAS,SAAS;CAErC,GAAE,CAAC,IAAK,EAAC;CAEV,MAAM,UAAU,YAAY,MAAM;EAChC,MAAM,WAAW,UAAU,SAAS,WAAW;AAC/C,WAAS,SAAS;AAClB,iBAAe,aAAa,OAAO;CACpC,GAAE,CAAC,OAAO,YAAa,EAAC;AAEzB,wBACE,KAAC;EACC,cAAY;EACZ,mBAAgB;EAChB,GAAI;EACC;EACW;EAChB,mBAAmB,CAAC,MAAM;AACxB,OAAI,EAAE,WAAW,EAAE,iBAAiB,UAAU,SAC5C,mBAAkB,KAAK;EAE1B;EACD,iBAAiB,CAAC,MAAM;AACtB,OAAI,EAAE,WAAW,EAAE,iBAAiB,UAAU,OAC5C,mBAAkB,MAAM;EAE3B;6BAED,IAAC;GACC,cAAY;GACH;GACT,iBAAiB;GACjB,iBAAe,UAAU;GACzB,iBAAe;GACf,cAAY,GAAG,UAAU,UAAU,SAAS,UAAU,OAAO,EAAE;6BAE/D,IAAC,uBAAqB;IACL,kBACnB,IAAC;GAAc,IAAI;GAAW,cAAY;GAAO,eAAa,UAAU;GAAU,GAAI;GACnF;IACa;GACJ;AAEjB,EACF;AAED,sBAAe"}
@@ -1,10 +1,8 @@
1
- /**
2
- * Copyright (c) 2018-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
- */
1
+ import { FactBox_default } from "./FactBox.js";
8
2
 
9
- import FactBox from "./FactBox";
10
- export default FactBox;
3
+ //#region src/FactBox/index.ts
4
+ var FactBox_default$1 = FactBox_default;
5
+
6
+ //#endregion
7
+ export { FactBox_default$1 as FactBox_default };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["FactBox"],"sources":["../../src/FactBox/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2018-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 FactBox from \"./FactBox\";\n\nexport default FactBox;\n"],"mappings":";;;AAUA,wBAAeA"}
@@ -1,101 +1,76 @@
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 { FileListItem } from "./FileList.js";
9
2
  import { forwardRef } from "react";
3
+ import { Text } from "@ndla/primitives";
4
+ import { HStack, styled } from "@ndla/styled-system/jsx";
10
5
  import { useTranslation } from "react-i18next";
11
6
  import { DownloadLine } from "@ndla/icons";
12
- import { Text } from "@ndla/primitives";
13
7
  import { SafeLink } from "@ndla/safelink";
14
- import { HStack, styled } from "@ndla/styled-system/jsx";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
15
9
  import { linkOverlay } from "@ndla/styled-system/patterns";
16
- import { FileListItem } from ".";
17
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
- const StyledSafeLink = styled(SafeLink, {
19
- base: {
20
- textUnderlineOffset: "2px",
21
- textDecoration: "underline",
22
- _hover: {
23
- textDecoration: "none"
24
- }
25
- }
26
- });
27
- const StyledHStack = styled(HStack, {
28
- base: {
29
- position: "relative",
30
- paddingBlock: "small",
31
- paddingInlineEnd: "medium",
32
- paddingInlineStart: "small",
33
- width: "100%"
34
- }
35
- });
36
- export const File = /*#__PURE__*/forwardRef((_ref, ref) => {
37
- let {
38
- title,
39
- url,
40
- fileExists,
41
- fileType,
42
- fileSize,
43
- ...rest
44
- } = _ref;
45
- const {
46
- t
47
- } = useTranslation();
48
- const filename = `${title}-${url.split("/").pop() ?? ""}`;
49
- const downloadUrl = `${url}?download=${filename}`;
50
- const tooltip = `${t("download")} ${filename}`;
51
- return /*#__PURE__*/_jsxs(StyledHStack, {
52
- justify: "space-between",
53
- ref: ref,
54
- ...rest,
55
- children: [/*#__PURE__*/_jsxs(HStack, {
56
- gap: "xxsmall",
57
- children: [/*#__PURE__*/_jsx(DownloadLine, {}), fileExists ? /*#__PURE__*/_jsx(StyledSafeLink, {
58
- unstyled: true,
59
- css: linkOverlay.raw(),
60
- to: downloadUrl,
61
- title: tooltip,
62
- children: title
63
- }) : /*#__PURE__*/_jsx(Text, {
64
- textStyle: "label.medium",
65
- children: title
66
- }), /*#__PURE__*/_jsx(Text, {
67
- textStyle: "label.large",
68
- asChild: true,
69
- consumeCss: true,
70
- children: /*#__PURE__*/_jsxs("span", {
71
- children: ["(", fileType?.toUpperCase(), ")"]
72
- })
73
- })]
74
- }), /*#__PURE__*/_jsx(Text, {
75
- textStyle: "label.large",
76
- asChild: true,
77
- consumeCss: true,
78
- children: /*#__PURE__*/_jsx("span", {
79
- children: fileSize
80
- })
81
- })]
82
- });
10
+
11
+ //#region src/FileList/File.tsx
12
+ const StyledSafeLink = styled(SafeLink, { base: {
13
+ textUnderlineOffset: "2px",
14
+ textDecoration: "underline",
15
+ _hover: { textDecoration: "none" }
16
+ } });
17
+ const StyledHStack = styled(HStack, { base: {
18
+ position: "relative",
19
+ paddingBlock: "small",
20
+ paddingInlineEnd: "medium",
21
+ paddingInlineStart: "small",
22
+ width: "100%"
23
+ } });
24
+ const File = forwardRef(({ title, url, fileExists, fileType, fileSize,...rest }, ref) => {
25
+ const { t } = useTranslation();
26
+ const filename = `${title}-${url.split("/").pop() ?? ""}`;
27
+ const downloadUrl = `${url}?download=${filename}`;
28
+ const tooltip = `${t("download")} ${filename}`;
29
+ return /* @__PURE__ */ jsxs(StyledHStack, {
30
+ justify: "space-between",
31
+ ref,
32
+ ...rest,
33
+ children: [/* @__PURE__ */ jsxs(HStack, {
34
+ gap: "xxsmall",
35
+ children: [
36
+ /* @__PURE__ */ jsx(DownloadLine, {}),
37
+ fileExists ? /* @__PURE__ */ jsx(StyledSafeLink, {
38
+ unstyled: true,
39
+ css: linkOverlay.raw(),
40
+ to: downloadUrl,
41
+ title: tooltip,
42
+ children: title
43
+ }) : /* @__PURE__ */ jsx(Text, {
44
+ textStyle: "label.medium",
45
+ children: title
46
+ }),
47
+ /* @__PURE__ */ jsx(Text, {
48
+ textStyle: "label.large",
49
+ asChild: true,
50
+ consumeCss: true,
51
+ children: /* @__PURE__ */ jsxs("span", { children: [
52
+ "(",
53
+ fileType?.toUpperCase(),
54
+ ")"
55
+ ] })
56
+ })
57
+ ]
58
+ }), /* @__PURE__ */ jsx(Text, {
59
+ textStyle: "label.large",
60
+ asChild: true,
61
+ consumeCss: true,
62
+ children: /* @__PURE__ */ jsx("span", { children: fileSize })
63
+ })]
64
+ });
83
65
  });
84
- export const FileListElement = _ref2 => {
85
- let {
86
- title,
87
- url,
88
- fileExists,
89
- fileType,
90
- fileSize
91
- } = _ref2;
92
- return /*#__PURE__*/_jsx(FileListItem, {
93
- children: /*#__PURE__*/_jsx(File, {
94
- title: title,
95
- url: url,
96
- fileExists: fileExists,
97
- fileType: fileType,
98
- fileSize: fileSize
99
- })
100
- });
101
- };
66
+ const FileListElement = ({ title, url, fileExists, fileType, fileSize }) => /* @__PURE__ */ jsx(FileListItem, { children: /* @__PURE__ */ jsx(File, {
67
+ title,
68
+ url,
69
+ fileExists,
70
+ fileType,
71
+ fileSize
72
+ }) });
73
+
74
+ //#endregion
75
+ export { File, FileListElement };
76
+ //# sourceMappingURL=File.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"File.js","names":[],"sources":["../../src/FileList/File.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 ComponentPropsWithRef, forwardRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { DownloadLine } from \"@ndla/icons\";\nimport { Text } from \"@ndla/primitives\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { HStack, styled } from \"@ndla/styled-system/jsx\";\nimport { linkOverlay } from \"@ndla/styled-system/patterns\";\nimport { FileListItem } from \".\";\n\nexport interface FileProps extends ComponentPropsWithRef<\"div\"> {\n title: string;\n url: string;\n fileExists: boolean;\n fileType: string;\n fileSize?: string;\n}\n\nexport interface FileType {\n title: string;\n formats: FileFormat[];\n fileExists?: boolean;\n}\n\nexport interface FileFormat {\n url: string;\n fileType: string;\n tooltip: string;\n}\n\nconst StyledSafeLink = styled(SafeLink, {\n base: {\n textUnderlineOffset: \"2px\",\n textDecoration: \"underline\",\n _hover: {\n textDecoration: \"none\",\n },\n },\n});\n\nconst StyledHStack = styled(HStack, {\n base: {\n position: \"relative\",\n paddingBlock: \"small\",\n paddingInlineEnd: \"medium\",\n paddingInlineStart: \"small\",\n width: \"100%\",\n },\n});\n\nexport const File = forwardRef<HTMLDivElement, FileProps>(\n ({ title, url, fileExists, fileType, fileSize, ...rest }, ref) => {\n const { t } = useTranslation();\n const filename = `${title}-${url.split(\"/\").pop() ?? \"\"}`;\n const downloadUrl = `${url}?download=${filename}`;\n const tooltip = `${t(\"download\")} ${filename}`;\n\n return (\n <StyledHStack justify=\"space-between\" ref={ref} {...rest}>\n <HStack gap=\"xxsmall\">\n <DownloadLine />\n {fileExists ? (\n <StyledSafeLink unstyled css={linkOverlay.raw()} to={downloadUrl} title={tooltip}>\n {title}\n </StyledSafeLink>\n ) : (\n <Text textStyle=\"label.medium\">{title}</Text>\n )}\n <Text textStyle=\"label.large\" asChild consumeCss>\n <span>({fileType?.toUpperCase()})</span>\n </Text>\n </HStack>\n <Text textStyle=\"label.large\" asChild consumeCss>\n <span>{fileSize}</span>\n </Text>\n </StyledHStack>\n );\n },\n);\n\nexport const FileListElement = ({ title, url, fileExists, fileType, fileSize }: FileProps) => (\n <FileListItem>\n <File title={title} url={url} fileExists={fileExists} fileType={fileType} fileSize={fileSize} />\n </FileListItem>\n);\n"],"mappings":";;;;;;;;;;;AAqCA,MAAM,iBAAiB,OAAO,UAAU,EACtC,MAAM;CACJ,qBAAqB;CACrB,gBAAgB;CAChB,QAAQ,EACN,gBAAgB,OACjB;AACF,EACF,EAAC;AAEF,MAAM,eAAe,OAAO,QAAQ,EAClC,MAAM;CACJ,UAAU;CACV,cAAc;CACd,kBAAkB;CAClB,oBAAoB;CACpB,OAAO;AACR,EACF,EAAC;AAEF,MAAa,OAAO,WAClB,CAAC,EAAE,OAAO,KAAK,YAAY,UAAU,SAAU,GAAG,MAAM,EAAE,QAAQ;CAChE,MAAM,EAAE,GAAG,GAAG,gBAAgB;CAC9B,MAAM,YAAY,EAAE,MAAM,GAAG,IAAI,MAAM,IAAI,CAAC,KAAK,IAAI,GAAG;CACxD,MAAM,eAAe,EAAE,IAAI,YAAY,SAAS;CAChD,MAAM,WAAW,EAAE,EAAE,WAAW,CAAC,GAAG,SAAS;AAE7C,wBACE,KAAC;EAAa,SAAQ;EAAqB;EAAK,GAAI;6BAClD,KAAC;GAAO,KAAI;;oBACV,IAAC,iBAAe;IACf,6BACC,IAAC;KAAe;KAAS,KAAK,YAAY,KAAK;KAAE,IAAI;KAAa,OAAO;eACtE;MACc,mBAEjB,IAAC;KAAK,WAAU;eAAgB;MAAa;oBAE/C,IAAC;KAAK,WAAU;KAAc;KAAQ;+BACpC,KAAC;MAAK;MAAE,UAAU,aAAa;MAAC;SAAQ;MACnC;;IACA,kBACT,IAAC;GAAK,WAAU;GAAc;GAAQ;6BACpC,IAAC,oBAAM,WAAgB;IAClB;GACM;AAElB,EACF;AAED,MAAa,kBAAkB,CAAC,EAAE,OAAO,KAAK,YAAY,UAAU,UAAqB,qBACvF,IAAC,0CACC,IAAC;CAAY;CAAY;CAAiB;CAAsB;CAAoB;EAAY,GACnF"}
@@ -1,47 +1,32 @@
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 { ark } from "@ark-ui/react";
1
+ import "react";
10
2
  import { styled } from "@ndla/styled-system/jsx";
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- export const FileListWrapper = styled(ark.ul, {
13
- base: {
14
- display: "flex",
15
- flexDirection: "column",
16
- gap: "xsmall",
17
- clear: "both"
18
- }
19
- }, {
20
- baseComponent: true
21
- });
22
- export const FileListItem = styled(ark.li, {
23
- base: {
24
- listStyle: "none",
25
- background: "surface.infoSubtle",
26
- borderBlockEnd: "1px solid",
27
- borderColor: "stroke.default",
28
- display: "flex",
29
- justifyContent: "space-between",
30
- _hover: {
31
- backgroundColor: "surface.infoSubtle.hover"
32
- }
33
- }
34
- }, {
35
- baseComponent: true
36
- });
37
- export const FileListEmbed = _ref => {
38
- let {
39
- children,
40
- ...rest
41
- } = _ref;
42
- return /*#__PURE__*/_jsx(FileListWrapper, {
43
- ...rest,
44
- "data-embed-type": "file-list",
45
- children: children
46
- });
47
- };
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { ark } from "@ark-ui/react";
5
+
6
+ //#region src/FileList/FileList.tsx
7
+ const FileListWrapper = styled(ark.ul, { base: {
8
+ display: "flex",
9
+ flexDirection: "column",
10
+ gap: "xsmall",
11
+ clear: "both"
12
+ } }, { baseComponent: true });
13
+ const FileListItem = styled(ark.li, { base: {
14
+ listStyle: "none",
15
+ background: "surface.infoSubtle",
16
+ borderBlockEnd: "1px solid",
17
+ borderColor: "stroke.default",
18
+ display: "flex",
19
+ justifyContent: "space-between",
20
+ _hover: { backgroundColor: "surface.infoSubtle.hover" }
21
+ } }, { baseComponent: true });
22
+ const FileListEmbed = ({ children,...rest }) => {
23
+ return /* @__PURE__ */ jsx(FileListWrapper, {
24
+ ...rest,
25
+ "data-embed-type": "file-list",
26
+ children
27
+ });
28
+ };
29
+
30
+ //#endregion
31
+ export { FileListEmbed, FileListItem, FileListWrapper };
32
+ //# sourceMappingURL=FileList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileList.js","names":[],"sources":["../../src/FileList/FileList.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 ComponentPropsWithoutRef } from \"react\";\nimport { ark } from \"@ark-ui/react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\ninterface Props extends ComponentPropsWithoutRef<\"ul\"> {}\n\nexport const FileListWrapper = styled(\n ark.ul,\n {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n clear: \"both\",\n },\n },\n { baseComponent: true },\n);\n\nexport const FileListItem = styled(\n ark.li,\n {\n base: {\n listStyle: \"none\",\n background: \"surface.infoSubtle\",\n borderBlockEnd: \"1px solid\",\n borderColor: \"stroke.default\",\n display: \"flex\",\n justifyContent: \"space-between\",\n\n _hover: {\n backgroundColor: \"surface.infoSubtle.hover\",\n },\n },\n },\n { baseComponent: true },\n);\n\nexport const FileListEmbed = ({ children, ...rest }: Props) => {\n return (\n <FileListWrapper {...rest} data-embed-type=\"file-list\">\n {children}\n </FileListWrapper>\n );\n};\n"],"mappings":";;;;;;AAcA,MAAa,kBAAkB,OAC7B,IAAI,IACJ,EACE,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,OAAO;AACR,EACF,GACD,EAAE,eAAe,KAAM,EACxB;AAED,MAAa,eAAe,OAC1B,IAAI,IACJ,EACE,MAAM;CACJ,WAAW;CACX,YAAY;CACZ,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,gBAAgB;CAEhB,QAAQ,EACN,iBAAiB,2BAClB;AACF,EACF,GACD,EAAE,eAAe,KAAM,EACxB;AAED,MAAa,gBAAgB,CAAC,EAAE,SAAU,GAAG,MAAa,KAAK;AAC7D,wBACE,IAAC;EAAgB,GAAI;EAAM,mBAAgB;EACxC;GACe;AAErB"}