@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,75 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const require_relativeUrl = require('../utils/relativeUrl.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 html_react_parser = require_rolldown_runtime.__toESM(require("html-react-parser"));
7
+ const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
8
+ const __ndla_safelink = require_rolldown_runtime.__toESM(require("@ndla/safelink"));
9
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
10
+
11
+ //#region src/LinkBlock/LinkBlock.tsx
12
+ const InfoWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
13
+ display: "flex",
14
+ flexDirection: "column",
15
+ gap: "xsmall"
16
+ } });
17
+ const StyledSafeLink = (0, __ndla_styled_system_jsx.styled)(__ndla_safelink.SafeLink, { base: {
18
+ display: "flex",
19
+ justifyContent: "space-between",
20
+ alignItems: "center",
21
+ background: "surface.default",
22
+ padding: "medium",
23
+ border: "1px solid",
24
+ borderColor: "stroke.subtle",
25
+ borderRadius: "xsmall",
26
+ "& h3": { textDecoration: "underline" },
27
+ "& [data-forward]": {
28
+ transitionProperty: "width, height",
29
+ transitionTimingFunction: "ease-in-out",
30
+ transitionDuration: "fast"
31
+ },
32
+ _hover: {
33
+ "& h3": { textDecoration: "none" },
34
+ "& [data-forward]": {
35
+ width: "large",
36
+ height: "large"
37
+ }
38
+ }
39
+ } });
40
+ const StyledDateContainer = (0, __ndla_styled_system_jsx.styled)("div", { base: {
41
+ display: "flex",
42
+ alignItems: "center",
43
+ gap: "xxsmall"
44
+ } });
45
+ const StyledCalendarEd = (0, __ndla_styled_system_jsx.styled)(__ndla_icons.CalendarLine, { base: { color: "icon.strong" } });
46
+ const LinkBlock = ({ title, articleLanguage, date, url, path }) => {
47
+ const href = require_relativeUrl.getPossiblyRelativeUrl(url, path);
48
+ const formattedDate = (0, react.useMemo)(() => {
49
+ if (!date) return null;
50
+ return new Intl.DateTimeFormat(articleLanguage, {
51
+ timeZone: "CET",
52
+ day: "2-digit",
53
+ month: "long",
54
+ year: "numeric"
55
+ }).format(new Date(date));
56
+ }, [date, articleLanguage]);
57
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledSafeLink, {
58
+ to: href,
59
+ "data-embed-type": "link-block",
60
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(InfoWrapper, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Heading, {
61
+ asChild: true,
62
+ consumeCss: true,
63
+ textStyle: "title.medium",
64
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
65
+ "data-heading": true,
66
+ children: (0, html_react_parser.default)(title)
67
+ })
68
+ }), !!date && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledDateContainer, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledCalendarEd, {}), formattedDate] })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.ArrowRightLine, { "data-forward": true })]
69
+ });
70
+ };
71
+ var LinkBlock_default = LinkBlock;
72
+
73
+ //#endregion
74
+ exports.LinkBlock_default = LinkBlock_default;
75
+ //# sourceMappingURL=LinkBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkBlock.js","names":["SafeLink","CalendarLine","Heading","ArrowRightLine"],"sources":["../../src/LinkBlock/LinkBlock.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 { useMemo } from \"react\";\nimport { ArrowRightLine, CalendarLine } from \"@ndla/icons\";\nimport { Heading } from \"@ndla/primitives\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { LinkBlockEmbedData } from \"@ndla/types-embed\";\nimport { getPossiblyRelativeUrl } from \"../utils/relativeUrl\";\n\nconst InfoWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n },\n});\n\nconst StyledSafeLink = styled(SafeLink, {\n base: {\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n background: \"surface.default\",\n padding: \"medium\",\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n borderRadius: \"xsmall\",\n \"& h3\": {\n textDecoration: \"underline\",\n },\n \"& [data-forward]\": {\n transitionProperty: \"width, height\",\n transitionTimingFunction: \"ease-in-out\",\n transitionDuration: \"fast\",\n },\n _hover: {\n \"& h3\": {\n textDecoration: \"none\",\n },\n \"& [data-forward]\": {\n width: \"large\",\n height: \"large\",\n },\n },\n },\n});\n\nconst StyledDateContainer = styled(\"div\", {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"xxsmall\",\n },\n});\n\nconst StyledCalendarEd = styled(CalendarLine, {\n base: {\n color: \"icon.strong\",\n },\n});\n\ninterface Props extends Omit<LinkBlockEmbedData, \"resource\"> {\n path?: string;\n articleLanguage?: string;\n}\n\nconst LinkBlock = ({ title, articleLanguage, date, url, path }: Props) => {\n const href = getPossiblyRelativeUrl(url, path);\n const formattedDate = useMemo(() => {\n if (!date) return null;\n return new Intl.DateTimeFormat(articleLanguage, {\n timeZone: \"CET\",\n day: \"2-digit\",\n month: \"long\",\n year: \"numeric\",\n }).format(new Date(date));\n }, [date, articleLanguage]);\n return (\n <StyledSafeLink to={href} data-embed-type=\"link-block\">\n <InfoWrapper>\n <Heading asChild consumeCss textStyle=\"title.medium\">\n <h3 data-heading>{parse(title)}</h3>\n </Heading>\n {!!date && (\n <StyledDateContainer>\n <StyledCalendarEd />\n {formattedDate}\n </StyledDateContainer>\n )}\n </InfoWrapper>\n <ArrowRightLine data-forward />\n </StyledSafeLink>\n );\n};\n\nexport default LinkBlock;\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,cAAc,qCAAO,OAAO,EAChC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;AACN,EACF,EAAC;AAEF,MAAM,iBAAiB,qCAAOA,0BAAU,EACtC,MAAM;CACJ,SAAS;CACT,gBAAgB;CAChB,YAAY;CACZ,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,aAAa;CACb,cAAc;CACd,QAAQ,EACN,gBAAgB,YACjB;CACD,oBAAoB;EAClB,oBAAoB;EACpB,0BAA0B;EAC1B,oBAAoB;CACrB;CACD,QAAQ;EACN,QAAQ,EACN,gBAAgB,OACjB;EACD,oBAAoB;GAClB,OAAO;GACP,QAAQ;EACT;CACF;AACF,EACF,EAAC;AAEF,MAAM,sBAAsB,qCAAO,OAAO,EACxC,MAAM;CACJ,SAAS;CACT,YAAY;CACZ,KAAK;AACN,EACF,EAAC;AAEF,MAAM,mBAAmB,qCAAOC,2BAAc,EAC5C,MAAM,EACJ,OAAO,cACR,EACF,EAAC;AAOF,MAAM,YAAY,CAAC,EAAE,OAAO,iBAAiB,MAAM,KAAK,MAAa,KAAK;CACxE,MAAM,OAAO,2CAAuB,KAAK,KAAK;CAC9C,MAAM,gBAAgB,mBAAQ,MAAM;AAClC,OAAK,KAAM,QAAO;AAClB,SAAO,IAAI,KAAK,eAAe,iBAAiB;GAC9C,UAAU;GACV,KAAK;GACL,OAAO;GACP,MAAM;EACP,GAAE,OAAO,IAAI,KAAK,MAAM;CAC1B,GAAE,CAAC,MAAM,eAAgB,EAAC;AAC3B,wBACE,4BAAC;EAAe,IAAI;EAAM,mBAAgB;6BACxC,4BAAC,0CACC,2BAACC;GAAQ;GAAQ;GAAW,WAAU;6BACpC,2BAAC;IAAG;cAAc,+BAAM,MAAM;KAAM;IAC5B,IACP,wBACD,4BAAC,kDACC,2BAAC,qBAAmB,EACnB,iBACmB,IAEZ,kBACd,2BAACC,+BAAe,uBAAe;GAChB;AAEpB;AAED,wBAAe"}
@@ -0,0 +1,24 @@
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/LinkBlock/LinkBlockSection.tsx
7
+ const StyledList = (0, __ndla_styled_system_jsx.styled)("ul", { base: {
8
+ display: "flex",
9
+ flexDirection: "column",
10
+ gap: "xsmall",
11
+ listStyle: "none"
12
+ } });
13
+ const LinkBlockSection = ({ children,...rest }) => {
14
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
15
+ ...rest,
16
+ "data-embed-type": "link-block-list",
17
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledList, { children: react.Children.map(children, (child) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: child })) })
18
+ });
19
+ };
20
+ var LinkBlockSection_default = LinkBlockSection;
21
+
22
+ //#endregion
23
+ exports.LinkBlockSection_default = LinkBlockSection_default;
24
+ //# sourceMappingURL=LinkBlockSection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkBlockSection.js","names":[],"sources":["../../src/LinkBlock/LinkBlockSection.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 { Children, type HTMLAttributes, type ReactNode } from \"react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\ninterface Props extends HTMLAttributes<HTMLElement> {\n children: ReactNode;\n}\n\nconst StyledList = styled(\"ul\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n listStyle: \"none\",\n },\n});\n\nconst LinkBlockSection = ({ children, ...rest }: Props) => {\n return (\n <nav {...rest} data-embed-type=\"link-block-list\">\n <StyledList>\n {Children.map(children, (child) => (\n <li>{child}</li>\n ))}\n </StyledList>\n </nav>\n );\n};\n\nexport default LinkBlockSection;\n"],"mappings":";;;;;;AAeA,MAAM,aAAa,qCAAO,MAAM,EAC9B,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,WAAW;AACZ,EACF,EAAC;AAEF,MAAM,mBAAmB,CAAC,EAAE,SAAU,GAAG,MAAa,KAAK;AACzD,wBACE,2BAAC;EAAI,GAAI;EAAM,mBAAgB;4BAC7B,2BAAC,wBACE,eAAS,IAAI,UAAU,CAAC,0BACvB,2BAAC,kBAAI,QAAW,CAChB,GACS;GACT;AAET;AAED,+BAAe"}
@@ -0,0 +1,63 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const require_relativeUrl = require('../utils/relativeUrl.js');
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 html_react_parser = require_rolldown_runtime.__toESM(require("html-react-parser"));
6
+ const __ndla_safelink = require_rolldown_runtime.__toESM(require("@ndla/safelink"));
7
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
8
+ const __ndla_styled_system_patterns = require_rolldown_runtime.__toESM(require("@ndla/styled-system/patterns"));
9
+
10
+ //#region src/Pitch/Pitch.tsx
11
+ const StyledCardHeading = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.CardHeading, { base: { paddingBlockStart: "medium" } });
12
+ const StyledText = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Text, { base: { paddingBlockEnd: "medium" } });
13
+ const StyledCardRoot = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.CardRoot, { base: {
14
+ border: "0",
15
+ display: "flex",
16
+ flexDirection: "column",
17
+ gap: "small"
18
+ } });
19
+ const StyledCardImage = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.CardImage, { base: {
20
+ aspectRatio: "16/9",
21
+ height: "unset"
22
+ } });
23
+ const Pitch = ({ title, url, metaImage, path, description }) => {
24
+ const href = require_relativeUrl.getPossiblyRelativeUrl(url, path);
25
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledCardRoot, {
26
+ variant: "subtle",
27
+ "data-embed-type": "pitch",
28
+ asChild: true,
29
+ consumeCss: true,
30
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
31
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledCardHeading, {
32
+ textStyle: "heading.small",
33
+ asChild: true,
34
+ consumeCss: true,
35
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_safelink.SafeLink, {
36
+ to: href,
37
+ unstyled: true,
38
+ css: __ndla_styled_system_patterns.linkOverlay.raw(),
39
+ children: (0, html_react_parser.default)(title)
40
+ })
41
+ }),
42
+ !!description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledText, {
43
+ textStyle: "body.xlarge",
44
+ asChild: true,
45
+ consumeCss: true,
46
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: (0, html_react_parser.default)(description) })
47
+ }),
48
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledCardImage, {
49
+ variant: "rounded",
50
+ src: metaImage.url,
51
+ alt: metaImage.alt,
52
+ sizes: "480px",
53
+ fallbackWidth: 300,
54
+ width: 550,
55
+ height: 310
56
+ })
57
+ ] })
58
+ });
59
+ };
60
+
61
+ //#endregion
62
+ exports.Pitch = Pitch;
63
+ //# sourceMappingURL=Pitch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pitch.js","names":["CardHeading","Text","CardRoot","CardImage","SafeLink"],"sources":["../../src/Pitch/Pitch.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 parse from \"html-react-parser\";\nimport { CardHeading, CardImage, CardRoot, Text } from \"@ndla/primitives\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { linkOverlay } from \"@ndla/styled-system/patterns\";\nimport { getPossiblyRelativeUrl } from \"../utils/relativeUrl\";\n\nexport interface Props {\n title: string;\n url: string;\n description?: string;\n metaImage: {\n url: string;\n alt: string;\n };\n path?: string;\n}\n\nconst StyledCardHeading = styled(CardHeading, {\n base: {\n paddingBlockStart: \"medium\",\n },\n});\n\nconst StyledText = styled(Text, {\n base: {\n paddingBlockEnd: \"medium\",\n },\n});\n\nconst StyledCardRoot = styled(CardRoot, {\n base: {\n border: \"0\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"small\",\n },\n});\n\nconst StyledCardImage = styled(CardImage, {\n base: {\n aspectRatio: \"16/9\",\n height: \"unset\",\n },\n});\n\nexport const Pitch = ({ title, url, metaImage, path, description }: Props) => {\n const href = getPossiblyRelativeUrl(url, path);\n\n return (\n <StyledCardRoot variant=\"subtle\" data-embed-type=\"pitch\" asChild consumeCss>\n <div>\n <StyledCardHeading textStyle=\"heading.small\" asChild consumeCss>\n <SafeLink to={href} unstyled css={linkOverlay.raw()}>\n {parse(title)}\n </SafeLink>\n </StyledCardHeading>\n {!!description && (\n <StyledText textStyle=\"body.xlarge\" asChild consumeCss>\n <div>{parse(description)}</div>\n </StyledText>\n )}\n <StyledCardImage\n variant=\"rounded\"\n src={metaImage.url}\n alt={metaImage.alt}\n sizes=\"480px\"\n fallbackWidth={300}\n width={550}\n height={310}\n />\n </div>\n </StyledCardRoot>\n );\n};\n"],"mappings":";;;;;;;;;;AA0BA,MAAM,oBAAoB,qCAAOA,+BAAa,EAC5C,MAAM,EACJ,mBAAmB,SACpB,EACF,EAAC;AAEF,MAAM,aAAa,qCAAOC,wBAAM,EAC9B,MAAM,EACJ,iBAAiB,SAClB,EACF,EAAC;AAEF,MAAM,iBAAiB,qCAAOC,4BAAU,EACtC,MAAM;CACJ,QAAQ;CACR,SAAS;CACT,eAAe;CACf,KAAK;AACN,EACF,EAAC;AAEF,MAAM,kBAAkB,qCAAOC,6BAAW,EACxC,MAAM;CACJ,aAAa;CACb,QAAQ;AACT,EACF,EAAC;AAEF,MAAa,QAAQ,CAAC,EAAE,OAAO,KAAK,WAAW,MAAM,aAAoB,KAAK;CAC5E,MAAM,OAAO,2CAAuB,KAAK,KAAK;AAE9C,wBACE,2BAAC;EAAe,SAAQ;EAAS,mBAAgB;EAAQ;EAAQ;4BAC/D,4BAAC;mBACC,2BAAC;IAAkB,WAAU;IAAgB;IAAQ;8BACnD,2BAACC;KAAS,IAAI;KAAM;KAAS,KAAK,0CAAY,KAAK;eAChD,+BAAM,MAAM;MACJ;KACO;KACjB,+BACD,2BAAC;IAAW,WAAU;IAAc;IAAQ;8BAC1C,2BAAC,mBAAK,+BAAM,YAAY,GAAO;KACpB;mBAEf,2BAAC;IACC,SAAQ;IACR,KAAK,UAAU;IACf,KAAK,UAAU;IACf,OAAM;IACN,eAAe;IACf,OAAO;IACP,QAAQ;KACR;MACE;GACS;AAEpB"}
@@ -0,0 +1,99 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const require_ContentType = require('../model/ContentType.js');
3
+ const require_ContentTypeBadge = require('../ContentTypeBadge/ContentTypeBadge.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 __ndla_safelink = require_rolldown_runtime.__toESM(require("@ndla/safelink"));
10
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
11
+ const __ndla_styled_system_patterns = require_rolldown_runtime.__toESM(require("@ndla/styled-system/patterns"));
12
+
13
+ //#region src/RelatedArticleList/RelatedArticleList.tsx
14
+ const StyledSpan = (0, __ndla_styled_system_jsx.styled)("span", { base: {
15
+ display: "flex",
16
+ gap: "3xsmall"
17
+ } });
18
+ const RelatedArticle = ({ title, introduction, to, linkInfo = "", target = "", type = require_ContentType.contentTypes.SUBJECT_MATERIAL }) => {
19
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.CardRoot, {
20
+ "data-embed-type": "related-article",
21
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.CardContent, { children: [
22
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ContentTypeBadge.ContentTypeBadge, { contentType: type }),
23
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.CardHeading, {
24
+ asChild: true,
25
+ consumeCss: true,
26
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_safelink.SafeLink, {
27
+ unstyled: true,
28
+ to,
29
+ target,
30
+ rel: linkInfo ? "noopener noreferrer" : void 0,
31
+ css: __ndla_styled_system_patterns.linkOverlay.raw(),
32
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledSpan, { children: [title, target === "_blank" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.ExternalLinkLine, {})] })
33
+ }) })
34
+ }),
35
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, { dangerouslySetInnerHTML: { __html: introduction } }),
36
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
37
+ color: "text.subtle",
38
+ textStyle: "label.small",
39
+ children: linkInfo
40
+ })
41
+ ] })
42
+ });
43
+ };
44
+ const HeadingWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
45
+ display: "flex",
46
+ width: "100%",
47
+ justifyContent: "space-between",
48
+ alignItems: "center",
49
+ alignSelf: "flex-start"
50
+ } });
51
+ const ArticlesWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
52
+ display: "grid",
53
+ width: "100%",
54
+ gridTemplateColumns: "repeat(2, 1fr)",
55
+ gap: "medium",
56
+ tabletDown: { gridTemplateColumns: "1fr" }
57
+ } });
58
+ const StyledSection = (0, __ndla_styled_system_jsx.styled)("section", { base: {
59
+ display: "flex",
60
+ flexDirection: "column",
61
+ alignItems: "center",
62
+ gap: "medium",
63
+ clear: "both"
64
+ } });
65
+ const StyledButton = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Button, { base: { marginBlockStart: "xsmall" } });
66
+ const RelatedArticleList = ({ children = [], articleCount, headingLevel: HeadingElement = "h2", headingButtons,...rest }) => {
67
+ const [expanded, setExpanded] = (0, react.useState)(false);
68
+ const { t } = (0, react_i18next.useTranslation)();
69
+ const childCount = (0, react.useMemo)(() => articleCount ?? react.Children.count(children), [children, articleCount]);
70
+ const childrenToShow = (0, react.useMemo)(() => childCount > 2 && !expanded ? children?.slice(0, 2) : children, [
71
+ childCount,
72
+ children,
73
+ expanded
74
+ ]);
75
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledSection, {
76
+ ...rest,
77
+ "data-embed-type": "related-content-list",
78
+ children: [
79
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HeadingWrapper, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Heading, {
80
+ asChild: true,
81
+ consumeCss: true,
82
+ textStyle: "title.large",
83
+ fontWeight: "bold",
84
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HeadingElement, { children: t("related.title") })
85
+ }), headingButtons] }),
86
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ArticlesWrapper, { children: childrenToShow }),
87
+ childCount > 2 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledButton, {
88
+ variant: "secondary",
89
+ onClick: () => setExpanded((p) => !p),
90
+ children: t(`related.show${expanded ? "Less" : "More"}`)
91
+ }) : null
92
+ ]
93
+ });
94
+ };
95
+
96
+ //#endregion
97
+ exports.RelatedArticle = RelatedArticle;
98
+ exports.RelatedArticleList = RelatedArticleList;
99
+ //# sourceMappingURL=RelatedArticleList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelatedArticleList.js","names":["contentTypes","CardRoot","CardContent","ContentTypeBadge","CardHeading","SafeLink","ExternalLinkLine","Text","Button","Heading"],"sources":["../../src/RelatedArticleList/RelatedArticleList.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 { Children, type ComponentPropsWithoutRef, type ReactElement, type ReactNode, useMemo, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { ExternalLinkLine } from \"@ndla/icons\";\nimport { CardContent, CardHeading, CardRoot, Text, Heading, Button } from \"@ndla/primitives\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { linkOverlay } from \"@ndla/styled-system/patterns\";\nimport { ContentTypeBadge } from \"../ContentTypeBadge/ContentTypeBadge\";\nimport { contentTypes } from \"../model/ContentType\";\nimport type { HeadingLevel } from \"../types\";\n\ninterface RelatedArticleProps {\n title: string;\n introduction: string;\n to: string;\n linkInfo?: string;\n target?: string;\n type?: string;\n}\n\nconst StyledSpan = styled(\"span\", {\n base: {\n display: \"flex\",\n gap: \"3xsmall\",\n },\n});\n\nexport const RelatedArticle = ({\n title,\n introduction,\n to,\n linkInfo = \"\",\n target = \"\",\n type = contentTypes.SUBJECT_MATERIAL,\n}: RelatedArticleProps) => {\n return (\n <CardRoot data-embed-type=\"related-article\">\n <CardContent>\n <ContentTypeBadge contentType={type} />\n <CardHeading asChild consumeCss>\n <span>\n <SafeLink\n unstyled\n to={to}\n target={target}\n rel={linkInfo ? \"noopener noreferrer\" : undefined}\n css={linkOverlay.raw()}\n >\n <StyledSpan>\n {title}\n {target === \"_blank\" && <ExternalLinkLine />}\n </StyledSpan>\n </SafeLink>\n </span>\n </CardHeading>\n <Text dangerouslySetInnerHTML={{ __html: introduction }} />\n <Text color=\"text.subtle\" textStyle=\"label.small\">\n {linkInfo}\n </Text>\n </CardContent>\n </CardRoot>\n );\n};\n\nconst HeadingWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n width: \"100%\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n alignSelf: \"flex-start\",\n },\n});\n\nconst ArticlesWrapper = styled(\"div\", {\n base: {\n display: \"grid\",\n width: \"100%\",\n gridTemplateColumns: \"repeat(2, 1fr)\",\n gap: \"medium\",\n tabletDown: {\n gridTemplateColumns: \"1fr\",\n },\n },\n});\n\nconst StyledSection = styled(\"section\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n gap: \"medium\",\n clear: \"both\",\n },\n});\n\nconst StyledButton = styled(Button, {\n base: {\n marginBlockStart: \"xsmall\",\n },\n});\n\ninterface Props extends ComponentPropsWithoutRef<\"section\"> {\n children?: ReactElement[];\n articleCount?: number;\n headingLevel?: HeadingLevel;\n headingButtons?: ReactNode;\n}\n\nexport const RelatedArticleList = ({\n children = [],\n articleCount,\n headingLevel: HeadingElement = \"h2\",\n headingButtons,\n ...rest\n}: Props) => {\n const [expanded, setExpanded] = useState(false);\n const { t } = useTranslation();\n const childCount = useMemo(() => articleCount ?? Children.count(children), [children, articleCount]);\n const childrenToShow = useMemo(\n () => (childCount > 2 && !expanded ? children?.slice(0, 2) : children),\n [childCount, children, expanded],\n );\n\n return (\n <StyledSection {...rest} data-embed-type=\"related-content-list\">\n <HeadingWrapper>\n <Heading asChild consumeCss textStyle=\"title.large\" fontWeight=\"bold\">\n <HeadingElement>{t(\"related.title\")}</HeadingElement>\n </Heading>\n {headingButtons}\n </HeadingWrapper>\n <ArticlesWrapper>{childrenToShow}</ArticlesWrapper>\n {childCount > 2 ? (\n <StyledButton variant=\"secondary\" onClick={() => setExpanded((p) => !p)}>\n {t(`related.show${expanded ? \"Less\" : \"More\"}`)}\n </StyledButton>\n ) : null}\n </StyledSection>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAM,aAAa,qCAAO,QAAQ,EAChC,MAAM;CACJ,SAAS;CACT,KAAK;AACN,EACF,EAAC;AAEF,MAAa,iBAAiB,CAAC,EAC7B,OACA,cACA,IACA,WAAW,IACX,SAAS,IACT,OAAOA,iCAAa,kBACA,KAAK;AACzB,wBACE,2BAACC;EAAS,mBAAgB;4BACxB,4BAACC;mBACC,2BAACC,6CAAiB,aAAa,OAAQ;mBACvC,2BAACC;IAAY;IAAQ;8BACnB,2BAAC,oCACC,2BAACC;KACC;KACI;KACI;KACR,KAAK,WAAW;KAChB,KAAK,0CAAY,KAAK;+BAEtB,4BAAC,yBACE,OACA,WAAW,4BAAY,2BAACC,kCAAmB,IACjC;MACJ,GACN;KACK;mBACd,2BAACC,0BAAK,yBAAyB,EAAE,QAAQ,aAAc,IAAI;mBAC3D,2BAACA;IAAK,OAAM;IAAc,WAAU;cACjC;KACI;MACK;GACL;AAEd;AAED,MAAM,iBAAiB,qCAAO,OAAO,EACnC,MAAM;CACJ,SAAS;CACT,OAAO;CACP,gBAAgB;CAChB,YAAY;CACZ,WAAW;AACZ,EACF,EAAC;AAEF,MAAM,kBAAkB,qCAAO,OAAO,EACpC,MAAM;CACJ,SAAS;CACT,OAAO;CACP,qBAAqB;CACrB,KAAK;CACL,YAAY,EACV,qBAAqB,MACtB;AACF,EACF,EAAC;AAEF,MAAM,gBAAgB,qCAAO,WAAW,EACtC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,YAAY;CACZ,KAAK;CACL,OAAO;AACR,EACF,EAAC;AAEF,MAAM,eAAe,qCAAOC,0BAAQ,EAClC,MAAM,EACJ,kBAAkB,SACnB,EACF,EAAC;AASF,MAAa,qBAAqB,CAAC,EACjC,WAAW,CAAE,GACb,cACA,cAAc,iBAAiB,MAC/B,eACA,GAAG,MACG,KAAK;CACX,MAAM,CAAC,UAAU,YAAY,GAAG,oBAAS,MAAM;CAC/C,MAAM,EAAE,GAAG,GAAG,mCAAgB;CAC9B,MAAM,aAAa,mBAAQ,MAAM,gBAAgB,eAAS,MAAM,SAAS,EAAE,CAAC,UAAU,YAAa,EAAC;CACpG,MAAM,iBAAiB,mBACrB,MAAO,aAAa,MAAM,WAAW,UAAU,MAAM,GAAG,EAAE,GAAG,UAC7D;EAAC;EAAY;EAAU;CAAS,EACjC;AAED,wBACE,4BAAC;EAAc,GAAI;EAAM,mBAAgB;;mBACvC,4BAAC,6CACC,2BAACC;IAAQ;IAAQ;IAAW,WAAU;IAAc,YAAW;8BAC7D,2BAAC,4BAAgB,EAAE,gBAAgB,GAAkB;KAC7C,EACT,kBACc;mBACjB,2BAAC,6BAAiB,iBAAiC;GAClD,aAAa,oBACZ,2BAAC;IAAa,SAAQ;IAAY,SAAS,MAAM,YAAY,CAAC,OAAO,EAAE;cACpE,GAAG,cAAc,WAAW,SAAS,OAAO,EAAE;KAClC,GACb;;GACU;AAEnB"}
@@ -0,0 +1,8 @@
1
+ const require_RelatedArticleList = require('./RelatedArticleList.js');
2
+
3
+ //#region src/RelatedArticleList/index.ts
4
+ var RelatedArticleList_default = require_RelatedArticleList.RelatedArticleList;
5
+
6
+ //#endregion
7
+ exports.RelatedArticleList_default = RelatedArticleList_default;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["RelatedArticleList"],"sources":["../../src/RelatedArticleList/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2017-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 { RelatedArticle, RelatedArticleList } from \"./RelatedArticleList\";\n\nexport { RelatedArticle };\n\nexport default RelatedArticleList;\n"],"mappings":";;;AAYA,iCAAeA"}
@@ -0,0 +1,75 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
2
+ const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
3
+ const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
4
+ const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
5
+ const __ndla_safelink = require_rolldown_runtime.__toESM(require("@ndla/safelink"));
6
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
7
+ const __ndla_core = require_rolldown_runtime.__toESM(require("@ndla/core"));
8
+
9
+ //#region src/ResourceBox/ResourceBox.tsx
10
+ const Container = (0, __ndla_styled_system_jsx.styled)("div", { base: {
11
+ display: "flex",
12
+ padding: "medium",
13
+ borderRadius: "xsmall",
14
+ border: "1px solid",
15
+ borderColor: "stroke.default",
16
+ boxShadow: "full",
17
+ marginBlockEnd: "medium",
18
+ gap: "medium",
19
+ tabletWideDown: { padding: "xsmall" },
20
+ tabletDown: {
21
+ flexDirection: "column",
22
+ gap: "0",
23
+ padding: "0"
24
+ }
25
+ } });
26
+ const ContentWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
27
+ display: "flex",
28
+ flexDirection: "column",
29
+ alignItems: "flex-start",
30
+ gap: "xsmall",
31
+ flex: "1",
32
+ tabletDown: { padding: "xsmall" }
33
+ } });
34
+ const StyledImage = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Image, { base: {
35
+ objectFit: "cover",
36
+ borderRadius: "xsmall",
37
+ width: "fit-content",
38
+ aspectRatio: "1/1",
39
+ tabletDown: {
40
+ width: "100%",
41
+ borderRadius: "0"
42
+ }
43
+ } });
44
+ const StyledText = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Text, { base: { flex: "1" } });
45
+ const ResourceBox = ({ image, title, caption, url, buttonText }) => {
46
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Container, { children: [image ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledImage, {
47
+ src: image.src,
48
+ alt: image.alt,
49
+ sizes: `(min-width: ${__ndla_core.breakpoints.desktop}) 150px, (max-width: ${__ndla_core.breakpoints.tablet} ) 400px, 200px`,
50
+ variant: "rounded"
51
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ContentWrapper, { children: [
52
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Heading, {
53
+ textStyle: "label.large",
54
+ fontWeight: "bold",
55
+ asChild: true,
56
+ consumeCss: true,
57
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title })
58
+ }),
59
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledText, {
60
+ textStyle: "body.medium",
61
+ children: caption
62
+ }),
63
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_safelink.SafeLinkButton, {
64
+ to: url,
65
+ target: "_blank",
66
+ variant: "secondary",
67
+ children: [buttonText, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.ShareBoxLine, {})]
68
+ })
69
+ ] })] });
70
+ };
71
+ var ResourceBox_default = ResourceBox;
72
+
73
+ //#endregion
74
+ exports.ResourceBox_default = ResourceBox_default;
75
+ //# sourceMappingURL=ResourceBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResourceBox.js","names":["Image","Text","breakpoints","Heading","SafeLinkButton","ShareBoxLine"],"sources":["../../src/ResourceBox/ResourceBox.tsx"],"sourcesContent":["/**\n * Copyright (c) 2022-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 { breakpoints } from \"@ndla/core\";\nimport { ShareBoxLine } from \"@ndla/icons\";\nimport { Heading, Image, Text } from \"@ndla/primitives\";\nimport { SafeLinkButton } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\nconst Container = styled(\"div\", {\n base: {\n display: \"flex\",\n padding: \"medium\",\n borderRadius: \"xsmall\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n boxShadow: \"full\",\n marginBlockEnd: \"medium\",\n gap: \"medium\",\n tabletWideDown: {\n padding: \"xsmall\",\n },\n tabletDown: {\n flexDirection: \"column\",\n gap: \"0\",\n padding: \"0\",\n },\n },\n});\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"flex-start\",\n gap: \"xsmall\",\n flex: \"1\",\n tabletDown: {\n padding: \"xsmall\",\n },\n },\n});\n\nconst StyledImage = styled(Image, {\n base: {\n objectFit: \"cover\",\n borderRadius: \"xsmall\",\n width: \"fit-content\",\n aspectRatio: \"1/1\",\n tabletDown: {\n width: \"100%\",\n borderRadius: \"0\",\n },\n },\n});\n\nconst StyledText = styled(Text, {\n base: {\n flex: \"1\",\n },\n});\n\ninterface ImageMeta {\n src: string | undefined;\n alt: string;\n}\n\ninterface Props {\n image?: ImageMeta;\n title: string;\n caption: string;\n url: string;\n buttonText: string;\n}\n\nexport const ResourceBox = ({ image, title, caption, url, buttonText }: Props) => {\n return (\n <Container>\n {image ? (\n <StyledImage\n src={image.src}\n alt={image.alt}\n sizes={`(min-width: ${breakpoints.desktop}) 150px, (max-width: ${breakpoints.tablet} ) 400px, 200px`}\n variant=\"rounded\"\n />\n ) : null}\n <ContentWrapper>\n <Heading textStyle=\"label.large\" fontWeight=\"bold\" asChild consumeCss>\n <h3>{title}</h3>\n </Heading>\n <StyledText textStyle=\"body.medium\">{caption}</StyledText>\n <SafeLinkButton to={url} target=\"_blank\" variant=\"secondary\">\n {buttonText}\n <ShareBoxLine />\n </SafeLinkButton>\n </ContentWrapper>\n </Container>\n );\n};\n\nexport default ResourceBox;\n"],"mappings":";;;;;;;;;AAcA,MAAM,YAAY,qCAAO,OAAO,EAC9B,MAAM;CACJ,SAAS;CACT,SAAS;CACT,cAAc;CACd,QAAQ;CACR,aAAa;CACb,WAAW;CACX,gBAAgB;CAChB,KAAK;CACL,gBAAgB,EACd,SAAS,SACV;CACD,YAAY;EACV,eAAe;EACf,KAAK;EACL,SAAS;CACV;AACF,EACF,EAAC;AAEF,MAAM,iBAAiB,qCAAO,OAAO,EACnC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,YAAY;CACZ,KAAK;CACL,MAAM;CACN,YAAY,EACV,SAAS,SACV;AACF,EACF,EAAC;AAEF,MAAM,cAAc,qCAAOA,yBAAO,EAChC,MAAM;CACJ,WAAW;CACX,cAAc;CACd,OAAO;CACP,aAAa;CACb,YAAY;EACV,OAAO;EACP,cAAc;CACf;AACF,EACF,EAAC;AAEF,MAAM,aAAa,qCAAOC,wBAAM,EAC9B,MAAM,EACJ,MAAM,IACP,EACF,EAAC;AAeF,MAAa,cAAc,CAAC,EAAE,OAAO,OAAO,SAAS,KAAK,YAAmB,KAAK;AAChF,wBACE,4BAAC,wBACE,wBACC,2BAAC;EACC,KAAK,MAAM;EACX,KAAK,MAAM;EACX,QAAQ,cAAcC,wBAAY,QAAQ,uBAAuBA,wBAAY,OAAO;EACpF,SAAQ;GACR,GACA,sBACJ,4BAAC;kBACC,2BAACC;GAAQ,WAAU;GAAc,YAAW;GAAO;GAAQ;6BACzD,2BAAC,kBAAI,QAAW;IACR;kBACV,2BAAC;GAAW,WAAU;aAAe;IAAqB;kBAC1D,4BAACC;GAAe,IAAI;GAAK,QAAO;GAAS,SAAQ;cAC9C,4BACD,2BAACC,8BAAe;IACD;KACF,IACP;AAEf;AAED,0BAAe"}
@@ -0,0 +1,108 @@
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_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
5
+ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
6
+ const __ndla_util = require_rolldown_runtime.__toESM(require("@ndla/util"));
7
+ const __ark_ui_react = require_rolldown_runtime.__toESM(require("@ark-ui/react"));
8
+
9
+ //#region src/TagSelector/TagSelector.tsx
10
+ const TagSelectorRoot = ({ allowCustomValue = true, multiple = true, selectionBehavior = "clear", editable, addOnPaste = false, onValueChange, children, value, translations,...rest }) => {
11
+ const ids = {
12
+ root: (0, react.useId)(),
13
+ input: (0, react.useId)(),
14
+ control: (0, react.useId)()
15
+ };
16
+ const controlRef = (0, react.useRef)(void 0);
17
+ (0, react.useEffect)(() => {
18
+ if (!controlRef.current) controlRef.current = document.getElementById(ids.control);
19
+ }, [ids.control]);
20
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.ComboboxRoot, {
21
+ ids,
22
+ asChild: true,
23
+ allowCustomValue,
24
+ multiple,
25
+ selectionBehavior,
26
+ onValueChange,
27
+ translations,
28
+ onPointerDownOutside: (event) => {
29
+ if ((0, __ndla_util.contains)(controlRef.current, event.detail.originalEvent.target)) event.preventDefault();
30
+ },
31
+ value,
32
+ ...rest,
33
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TagSelectorTagsInputRoot, {
34
+ ids,
35
+ value,
36
+ editable,
37
+ onValueChange,
38
+ addOnPaste,
39
+ translations,
40
+ children
41
+ })
42
+ });
43
+ };
44
+ const TagSelectorTagsInputRoot = (0, react.forwardRef)((props, ref) => {
45
+ const comboboxApi = (0, __ark_ui_react.useComboboxContext)();
46
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputRoot, {
47
+ ref,
48
+ onInputValueChange: (details) => comboboxApi.setInputValue(details.inputValue),
49
+ ...props
50
+ });
51
+ });
52
+ const TagSelectorLabel = __ndla_primitives.ComboboxLabel;
53
+ const TagSelectorItemInput = __ndla_primitives.TagsInputItemInput;
54
+ const TagSelectorTrigger = __ndla_primitives.ComboboxTrigger;
55
+ const TagSelectorControl = (0, react.forwardRef)(({ children,...props }, ref) => {
56
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.ComboboxControl, {
57
+ ref,
58
+ asChild: true,
59
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputControl, {
60
+ ...props,
61
+ children
62
+ })
63
+ });
64
+ });
65
+ const TagSelectorClearTrigger = __ndla_primitives.ComboboxClearTrigger;
66
+ const TagSelectorInputBase = (0, react.forwardRef)(({ children,...props }, ref) => {
67
+ const tagsApi = (0, __ark_ui_react.useTagsInputContext)();
68
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.ComboboxInput, {
69
+ ref,
70
+ asChild: true,
71
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputInput, {
72
+ onKeyDown: (event) => {
73
+ if (event.key === "Enter") tagsApi.addValue(tagsApi.inputValue);
74
+ },
75
+ ...props,
76
+ children
77
+ })
78
+ });
79
+ });
80
+ const TagSelectorInput = (0, react.forwardRef)(({ children,...props }, ref) => {
81
+ const tagsApi = (0, __ark_ui_react.useTagsInputContext)();
82
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [tagsApi.value.map((value, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.TagsInputItem, {
83
+ index,
84
+ value,
85
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.TagsInputItemPreview, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputItemText, { children: value }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputItemDeleteTrigger, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.CloseLine, {}) })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputItemInput, {})]
86
+ }, value)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.ComboboxInput, {
87
+ ref,
88
+ asChild: true,
89
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.TagsInputInput, {
90
+ onKeyDown: (event) => {
91
+ if (event.key === "Enter") tagsApi.addValue(tagsApi.inputValue);
92
+ },
93
+ ...props,
94
+ children
95
+ })
96
+ })] });
97
+ });
98
+
99
+ //#endregion
100
+ exports.TagSelectorClearTrigger = TagSelectorClearTrigger;
101
+ exports.TagSelectorControl = TagSelectorControl;
102
+ exports.TagSelectorInput = TagSelectorInput;
103
+ exports.TagSelectorInputBase = TagSelectorInputBase;
104
+ exports.TagSelectorItemInput = TagSelectorItemInput;
105
+ exports.TagSelectorLabel = TagSelectorLabel;
106
+ exports.TagSelectorRoot = TagSelectorRoot;
107
+ exports.TagSelectorTrigger = TagSelectorTrigger;
108
+ //# sourceMappingURL=TagSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TagSelector.js","names":["ComboboxRoot","TagsInputRoot","ComboboxLabel","TagsInputItemInput","ComboboxTrigger","ComboboxControl","TagsInputControl","ComboboxClearTrigger","ComboboxInput","TagsInputInput","TagsInputItem","TagsInputItemPreview","TagsInputItemText","TagsInputItemDeleteTrigger","CloseLine"],"sources":["../../src/TagSelector/TagSelector.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 { forwardRef, useEffect, useId, useRef } from \"react\";\nimport { type CollectionItem, useTagsInputContext, useComboboxContext } from \"@ark-ui/react\";\nimport { CloseLine } from \"@ndla/icons\";\nimport {\n ComboboxClearTrigger,\n ComboboxControl,\n type ComboboxControlProps,\n ComboboxInput,\n type ComboboxInputProps,\n ComboboxLabel,\n ComboboxRoot,\n type ComboboxRootProps,\n ComboboxTrigger,\n TagsInputControl,\n type TagsInputControlProps,\n TagsInputInput,\n type TagsInputInputProps,\n TagsInputItem,\n TagsInputItemDeleteTrigger,\n TagsInputItemPreview,\n TagsInputItemText,\n TagsInputRoot,\n type TagsInputRootProps,\n TagsInputItemInput,\n} from \"@ndla/primitives\";\nimport { contains } from \"@ndla/util\";\n\nexport type TagSelectorRootProps<T extends CollectionItem> = ComboboxRootProps<T> & TagsInputRootProps;\n\nexport const TagSelectorRoot = <T extends CollectionItem>({\n allowCustomValue = true,\n multiple = true,\n selectionBehavior = \"clear\",\n editable,\n addOnPaste = false,\n onValueChange,\n children,\n value,\n translations,\n ...rest\n}: TagSelectorRootProps<T>) => {\n const ids = {\n root: useId(),\n input: useId(),\n control: useId(),\n };\n\n const controlRef = useRef<HTMLDivElement | undefined>(undefined);\n\n useEffect(() => {\n if (!controlRef.current) {\n controlRef.current = document.getElementById(ids.control) as HTMLDivElement | undefined;\n }\n }, [ids.control]);\n\n return (\n <ComboboxRoot\n ids={ids}\n asChild\n allowCustomValue={allowCustomValue}\n multiple={multiple}\n selectionBehavior={selectionBehavior}\n onValueChange={onValueChange}\n translations={translations}\n onPointerDownOutside={(event) => {\n if (contains(controlRef.current, event.detail.originalEvent.target)) {\n event.preventDefault();\n }\n }}\n value={value}\n {...rest}\n >\n <TagSelectorTagsInputRoot\n ids={ids}\n value={value}\n editable={editable}\n onValueChange={onValueChange}\n addOnPaste={addOnPaste}\n translations={translations}\n >\n {children}\n </TagSelectorTagsInputRoot>\n </ComboboxRoot>\n );\n};\n\nconst TagSelectorTagsInputRoot = forwardRef<HTMLDivElement, TagsInputRootProps>((props, ref) => {\n const comboboxApi = useComboboxContext();\n return (\n <TagsInputRoot\n ref={ref}\n onInputValueChange={(details) => comboboxApi.setInputValue(details.inputValue)}\n {...props}\n />\n );\n});\n\nexport type TagSelectorControlProps = ComboboxControlProps & TagsInputControlProps;\n\nexport const TagSelectorLabel = ComboboxLabel;\n\nexport const TagSelectorItemInput = TagsInputItemInput;\n\nexport const TagSelectorTrigger = ComboboxTrigger;\n\nexport const TagSelectorControl = forwardRef<HTMLDivElement, TagSelectorControlProps>(({ children, ...props }, ref) => {\n return (\n <ComboboxControl ref={ref} asChild>\n <TagsInputControl {...props}>{children}</TagsInputControl>\n </ComboboxControl>\n );\n});\n\nexport const TagSelectorClearTrigger = ComboboxClearTrigger;\n\nexport type TagSelectorInputProps = ComboboxInputProps & TagsInputInputProps;\n\n// If you need to modify the TagsInputItem, you can use this.\nexport const TagSelectorInputBase = forwardRef<HTMLInputElement, TagSelectorInputProps>(\n ({ children, ...props }, ref) => {\n const tagsApi = useTagsInputContext();\n\n return (\n <ComboboxInput ref={ref} asChild>\n <TagsInputInput\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n tagsApi.addValue(tagsApi.inputValue);\n }\n }}\n {...props}\n >\n {children}\n </TagsInputInput>\n </ComboboxInput>\n );\n },\n);\n\nexport const TagSelectorInput = forwardRef<HTMLInputElement, TagSelectorInputProps>(({ children, ...props }, ref) => {\n const tagsApi = useTagsInputContext();\n\n return (\n <>\n {tagsApi.value.map((value, index) => (\n <TagsInputItem index={index} value={value} key={value}>\n <TagsInputItemPreview>\n <TagsInputItemText>{value}</TagsInputItemText>\n <TagsInputItemDeleteTrigger>\n <CloseLine />\n </TagsInputItemDeleteTrigger>\n </TagsInputItemPreview>\n <TagsInputItemInput />\n </TagsInputItem>\n ))}\n <ComboboxInput ref={ref} asChild>\n <TagsInputInput\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n tagsApi.addValue(tagsApi.inputValue);\n }\n }}\n {...props}\n >\n {children}\n </TagsInputInput>\n </ComboboxInput>\n </>\n );\n});\n"],"mappings":";;;;;;;;;AAqCA,MAAa,kBAAkB,CAA2B,EACxD,mBAAmB,MACnB,WAAW,MACX,oBAAoB,SACpB,UACA,aAAa,OACb,eACA,UACA,OACA,aACA,GAAG,MACqB,KAAK;CAC7B,MAAM,MAAM;EACV,MAAM,kBAAO;EACb,OAAO,kBAAO;EACd,SAAS,kBAAO;CACjB;CAED,MAAM,aAAa,yBAA6C;AAEhE,sBAAU,MAAM;AACd,OAAK,WAAW,QACd,YAAW,UAAU,SAAS,eAAe,IAAI,QAAQ;CAE5D,GAAE,CAAC,IAAI,OAAQ,EAAC;AAEjB,wBACE,2BAACA;EACM;EACL;EACkB;EACR;EACS;EACJ;EACD;EACd,sBAAsB,CAAC,UAAU;AAC/B,OAAI,0BAAS,WAAW,SAAS,MAAM,OAAO,cAAc,OAAO,CACjE,OAAM,gBAAgB;EAEzB;EACM;EACP,GAAI;4BAEJ,2BAAC;GACM;GACE;GACG;GACK;GACH;GACE;GAEb;IACwB;GACd;AAElB;AAED,MAAM,2BAA2B,sBAA+C,CAAC,OAAO,QAAQ;CAC9F,MAAM,cAAc,wCAAoB;AACxC,wBACE,2BAACC;EACM;EACL,oBAAoB,CAAC,YAAY,YAAY,cAAc,QAAQ,WAAW;EAC9E,GAAI;GACJ;AAEL,EAAC;AAIF,MAAa,mBAAmBC;AAEhC,MAAa,uBAAuBC;AAEpC,MAAa,qBAAqBC;AAElC,MAAa,qBAAqB,sBAAoD,CAAC,EAAE,SAAU,GAAG,OAAO,EAAE,QAAQ;AACrH,wBACE,2BAACC;EAAqB;EAAK;4BACzB,2BAACC;GAAiB,GAAI;GAAQ;IAA4B;GAC1C;AAErB,EAAC;AAEF,MAAa,0BAA0BC;AAKvC,MAAa,uBAAuB,sBAClC,CAAC,EAAE,SAAU,GAAG,OAAO,EAAE,QAAQ;CAC/B,MAAM,UAAU,yCAAqB;AAErC,wBACE,2BAACC;EAAmB;EAAK;4BACvB,2BAACC;GACC,WAAW,CAAC,UAAU;AACpB,QAAI,MAAM,QAAQ,QAChB,SAAQ,SAAS,QAAQ,WAAW;GAEvC;GACD,GAAI;GAEH;IACc;GACH;AAEnB,EACF;AAED,MAAa,mBAAmB,sBAAoD,CAAC,EAAE,SAAU,GAAG,OAAO,EAAE,QAAQ;CACnH,MAAM,UAAU,yCAAqB;AAErC,wBACE,qEACG,QAAQ,MAAM,IAAI,CAAC,OAAO,0BACzB,4BAACC;EAAqB;EAAc;6BAClC,4BAACC,qEACC,2BAACC,iDAAmB,QAA0B,kBAC9C,2BAACC,0EACC,2BAACC,2BAAY,GACc,IACR,kBACvB,2BAACX,yCAAqB;IAPwB,MAQhC,CAChB,kBACF,2BAACK;EAAmB;EAAK;4BACvB,2BAACC;GACC,WAAW,CAAC,UAAU;AACpB,QAAI,MAAM,QAAQ,QAChB,SAAQ,SAAS,QAAQ,WAAW;GAEvC;GACD,GAAI;GAEH;IACc;GACH,IACf;AAEN,EAAC"}
@@ -0,0 +1,42 @@
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 react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
5
+
6
+ //#region src/ZendeskButton/ZendeskButton.tsx
7
+ const ZendeskButton = (0, react.forwardRef)(({ locale, variant = "secondary", widgetKey, children,...rest }, ref) => {
8
+ const [loading, setLoading] = (0, react.useState)(false);
9
+ const handleClick = () => {
10
+ if (window && !window.zE) {
11
+ setLoading(true);
12
+ const script = document.createElement("script");
13
+ script.id = "ze-snippet";
14
+ script.type = "text/javascript";
15
+ script.async = true;
16
+ script.onload = () => {
17
+ if (window.zE) {
18
+ window.zE("webWidget", "setLocale", locale);
19
+ window.zE("webWidget:on", "close", () => {
20
+ setLoading(false);
21
+ });
22
+ window.zE("webWidget", "open");
23
+ }
24
+ };
25
+ script.src = `https://static.zdassets.com/ekr/snippet.js?key=${widgetKey}`;
26
+ document.body.appendChild(script);
27
+ } else if (window?.zE) window.zE("webWidget", "open");
28
+ };
29
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Button, {
30
+ onClick: handleClick,
31
+ variant,
32
+ id: "zendeskButton",
33
+ disabled: loading,
34
+ ...rest,
35
+ ref,
36
+ children
37
+ });
38
+ });
39
+
40
+ //#endregion
41
+ exports.ZendeskButton = ZendeskButton;
42
+ //# sourceMappingURL=ZendeskButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZendeskButton.js","names":["Button"],"sources":["../../src/ZendeskButton/ZendeskButton.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 { forwardRef, useState } from \"react\";\nimport { Button, type ButtonProps } from \"@ndla/primitives\";\n\n// TODO: Let's consider abandoning `disabled` on the button here. It should instead just open/close the widget based on its current state.\n\nexport interface ZendeskButtonProps extends ButtonProps {\n widgetKey: string;\n locale: string;\n}\n\ndeclare global {\n interface Window {\n zE: (modifier: string, action: string, callback?: (() => void) | string) => void;\n }\n}\n\nexport const ZendeskButton = forwardRef<HTMLButtonElement, ZendeskButtonProps>(\n ({ locale, variant = \"secondary\", widgetKey, children, ...rest }, ref) => {\n const [loading, setLoading] = useState(false);\n const handleClick = () => {\n if (window && !window.zE) {\n setLoading(true);\n // Asynchronously load zendesk scripts for better performance\n const script = document.createElement(\"script\");\n script.id = \"ze-snippet\";\n script.type = \"text/javascript\";\n script.async = true;\n script.onload = () => {\n if (window.zE) {\n window.zE(\"webWidget\", \"setLocale\", locale);\n window.zE(\"webWidget:on\", \"close\", () => {\n setLoading(false);\n });\n window.zE(\"webWidget\", \"open\");\n }\n };\n script.src = `https://static.zdassets.com/ekr/snippet.js?key=${widgetKey}`;\n document.body.appendChild(script);\n } else if (window?.zE) {\n window.zE(\"webWidget\", \"open\");\n }\n };\n\n return (\n <Button onClick={handleClick} variant={variant} id=\"zendeskButton\" disabled={loading} {...rest} ref={ref}>\n {children}\n </Button>\n );\n },\n);\n"],"mappings":";;;;;;AAwBA,MAAa,gBAAgB,sBAC3B,CAAC,EAAE,QAAQ,UAAU,aAAa,WAAW,SAAU,GAAG,MAAM,EAAE,QAAQ;CACxE,MAAM,CAAC,SAAS,WAAW,GAAG,oBAAS,MAAM;CAC7C,MAAM,cAAc,MAAM;AACxB,MAAI,WAAW,OAAO,IAAI;AACxB,cAAW,KAAK;GAEhB,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,UAAO,KAAK;AACZ,UAAO,OAAO;AACd,UAAO,QAAQ;AACf,UAAO,SAAS,MAAM;AACpB,QAAI,OAAO,IAAI;AACb,YAAO,GAAG,aAAa,aAAa,OAAO;AAC3C,YAAO,GAAG,gBAAgB,SAAS,MAAM;AACvC,iBAAW,MAAM;KAClB,EAAC;AACF,YAAO,GAAG,aAAa,OAAO;IAC/B;GACF;AACD,UAAO,OAAO,iDAAiD,UAAU;AACzE,YAAS,KAAK,YAAY,OAAO;EAClC,WAAU,QAAQ,GACjB,QAAO,GAAG,aAAa,OAAO;CAEjC;AAED,wBACE,2BAACA;EAAO,SAAS;EAAsB;EAAS,IAAG;EAAgB,UAAU;EAAS,GAAI;EAAW;EAClG;GACM;AAEZ,EACF"}
@@ -0,0 +1,42 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
16
+ key = keys[i];
17
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: ((k) => from[k]).bind(null, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
25
+ value: mod,
26
+ enumerable: true
27
+ }) : target, mod));
28
+
29
+ //#endregion
30
+
31
+ Object.defineProperty(exports, '__export', {
32
+ enumerable: true,
33
+ get: function () {
34
+ return __export;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, '__toESM', {
38
+ enumerable: true,
39
+ get: function () {
40
+ return __toESM;
41
+ }
42
+ });