@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.
- package/README.md +1 -1
- package/es/Article/Article.js +127 -0
- package/es/Article/Article.js.map +1 -0
- package/es/Article/ArticleByline.js +133 -0
- package/es/Article/ArticleByline.js.map +1 -0
- package/es/Article/ArticleFootNotes.js +40 -0
- package/es/Article/ArticleFootNotes.js.map +1 -0
- package/es/AudioPlayer/AudioPlayer.js +157 -0
- package/es/AudioPlayer/AudioPlayer.js.map +1 -0
- package/es/AudioPlayer/Controls.js +254 -0
- package/es/AudioPlayer/Controls.js.map +1 -0
- package/es/AudioPlayer/SpeechControl.js +40 -0
- package/es/AudioPlayer/SpeechControl.js.map +1 -0
- package/es/AudioPlayer/index.js +8 -0
- package/es/AudioPlayer/index.js.map +1 -0
- package/es/Breadcrumb/Breadcrumb.js +44 -0
- package/es/Breadcrumb/Breadcrumb.js.map +1 -0
- package/es/Breadcrumb/BreadcrumbItem.js +36 -0
- package/es/Breadcrumb/BreadcrumbItem.js.map +1 -0
- package/es/Breadcrumb/HomeBreadcrumb.js +44 -0
- package/es/Breadcrumb/HomeBreadcrumb.js.map +1 -0
- package/es/Breadcrumb/index.js +9 -0
- package/es/Breadcrumb/index.js.map +1 -0
- package/es/CampaignBlock/CampaignBlock.js +131 -0
- package/es/CampaignBlock/CampaignBlock.js.map +1 -0
- package/es/CodeBlock/CodeBlock.js +25 -0
- package/es/CodeBlock/CodeBlock.js.map +1 -0
- package/es/CodeBlock/codeLanguageOptions.js +114 -0
- package/es/CodeBlock/codeLanguageOptions.js.map +1 -0
- package/es/Concept/Concept.js +50 -0
- package/es/Concept/Concept.js.map +1 -0
- package/es/ContactBlock/ContactBlock.js +145 -0
- package/es/ContactBlock/ContactBlock.js.map +1 -0
- package/es/ContentTypeBadge/ContentTypeBadge.js +41 -0
- package/es/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +25 -0
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +25 -0
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
- package/es/ContentTypeHero/ContentTypeHero.js +39 -0
- package/es/ContentTypeHero/ContentTypeHero.js.map +1 -0
- package/es/CopyParagraphButton/CopyParagraphButton.js +62 -0
- package/es/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
- package/es/CopyParagraphButton/index.js +8 -0
- package/es/CopyParagraphButton/index.js.map +1 -0
- package/es/Embed/AudioEmbed.js +52 -0
- package/es/Embed/AudioEmbed.js.map +1 -0
- package/es/Embed/BrightcoveEmbed.js +96 -0
- package/es/Embed/BrightcoveEmbed.js.map +1 -0
- package/es/Embed/CodeEmbed.js +61 -0
- package/es/Embed/CodeEmbed.js.map +1 -0
- package/es/Embed/ConceptEmbed.js +78 -0
- package/es/Embed/ConceptEmbed.js.map +1 -0
- package/es/Embed/ConceptInlineTriggerButton.js +40 -0
- package/es/Embed/ConceptInlineTriggerButton.js.map +1 -0
- package/es/Embed/ContentLinkEmbed.js +31 -0
- package/es/Embed/ContentLinkEmbed.js.map +1 -0
- package/es/Embed/CopyrightEmbed.js +23 -0
- package/es/Embed/CopyrightEmbed.js.map +1 -0
- package/es/Embed/EmbedErrorPlaceholder.js +43 -0
- package/es/Embed/EmbedErrorPlaceholder.js.map +1 -0
- package/es/Embed/EmbedWrapper.js +26 -0
- package/es/Embed/EmbedWrapper.js.map +1 -0
- package/es/Embed/ExternalEmbed.js +54 -0
- package/es/Embed/ExternalEmbed.js.map +1 -0
- package/es/Embed/FootnoteEmbed.js +27 -0
- package/es/Embed/FootnoteEmbed.js.map +1 -0
- package/es/Embed/GlossEmbed.js +52 -0
- package/es/Embed/GlossEmbed.js.map +1 -0
- package/es/Embed/H5pEmbed.js +38 -0
- package/es/Embed/H5pEmbed.js.map +1 -0
- package/es/Embed/IframeEmbed.js +69 -0
- package/es/Embed/IframeEmbed.js.map +1 -0
- package/es/Embed/ImageEmbed.js +180 -0
- package/es/Embed/ImageEmbed.js.map +1 -0
- package/es/Embed/InlineTriggerButton.js +25 -0
- package/es/Embed/InlineTriggerButton.js.map +1 -0
- package/es/Embed/RelatedContentEmbed.js +38 -0
- package/es/Embed/RelatedContentEmbed.js.map +1 -0
- package/es/Embed/UnknownEmbed.js +20 -0
- package/es/Embed/UnknownEmbed.js.map +1 -0
- package/es/Embed/UuDisclaimerEmbed.js +54 -0
- package/es/Embed/UuDisclaimerEmbed.js.map +1 -0
- package/es/ErrorMessage/ErrorMessage.js +54 -0
- package/es/ErrorMessage/ErrorMessage.js.map +1 -0
- package/es/ErrorMessage/index.js +8 -0
- package/es/ErrorMessage/index.js.map +1 -0
- package/es/FactBox/FactBox.js +121 -0
- package/es/FactBox/FactBox.js.map +1 -0
- package/es/FactBox/index.js +8 -0
- package/es/FactBox/index.js.map +1 -0
- package/es/FileList/File.js +76 -0
- package/es/FileList/File.js.map +1 -0
- package/es/FileList/FileList.js +32 -0
- package/es/FileList/FileList.js.map +1 -0
- package/es/FileList/PdfFile.js +28 -0
- package/es/FileList/PdfFile.js.map +1 -0
- package/es/Gloss/Gloss.js +142 -0
- package/es/Gloss/Gloss.js.map +1 -0
- package/es/Gloss/GlossExample.js +46 -0
- package/es/Gloss/GlossExample.js.map +1 -0
- package/es/Grid/Grid.js +66 -0
- package/es/Grid/Grid.js.map +1 -0
- package/es/Grid/GridParallaxItem.js +21 -0
- package/es/Grid/GridParallaxItem.js.map +1 -0
- package/es/KeyFigure/KeyFigure.js +46 -0
- package/es/KeyFigure/KeyFigure.js.map +1 -0
- package/es/LicenseByline/EmbedByline.js +132 -0
- package/es/LicenseByline/EmbedByline.js.map +1 -0
- package/es/LicenseByline/LicenseLink.js +31 -0
- package/es/LicenseByline/LicenseLink.js.map +1 -0
- package/es/LinkBlock/LinkBlock.js +74 -0
- package/es/LinkBlock/LinkBlock.js.map +1 -0
- package/es/LinkBlock/LinkBlockSection.js +23 -0
- package/es/LinkBlock/LinkBlockSection.js.map +1 -0
- package/es/Pitch/Pitch.js +62 -0
- package/es/Pitch/Pitch.js.map +1 -0
- package/es/RelatedArticleList/RelatedArticleList.js +97 -0
- package/es/RelatedArticleList/RelatedArticleList.js.map +1 -0
- package/es/RelatedArticleList/index.js +8 -0
- package/es/RelatedArticleList/index.js.map +1 -0
- package/es/ResourceBox/ResourceBox.js +74 -0
- package/es/ResourceBox/ResourceBox.js.map +1 -0
- package/es/TagSelector/TagSelector.js +100 -0
- package/es/TagSelector/TagSelector.js.map +1 -0
- package/es/ZendeskButton/ZendeskButton.js +41 -0
- package/es/ZendeskButton/ZendeskButton.js.map +1 -0
- package/es/_virtual/rolldown_runtime.js +11 -0
- package/es/i18n/formatNestedMessages.js +17 -0
- package/es/i18n/formatNestedMessages.js.map +1 -0
- package/es/i18n/i18n.js +29 -0
- package/es/i18n/i18n.js.map +1 -0
- package/es/i18n/useComponentTranslations.js +155 -0
- package/es/i18n/useComponentTranslations.js.map +1 -0
- package/es/index.js +65 -0
- package/es/locale/messages-en.js +438 -0
- package/es/locale/messages-en.js.map +1 -0
- package/es/locale/messages-nb.js +438 -0
- package/es/locale/messages-nb.js.map +1 -0
- package/es/locale/messages-nn.js +438 -0
- package/es/locale/messages-nn.js.map +1 -0
- package/es/locale/messages-se.js +438 -0
- package/es/locale/messages-se.js.map +1 -0
- package/es/model/ContentType.js +72 -0
- package/es/model/ContentType.js.map +1 -0
- package/es/model/SubjectCategories.js +25 -0
- package/es/model/SubjectCategories.js.map +1 -0
- package/es/model/SubjectTypes.js +23 -0
- package/es/model/SubjectTypes.js.map +1 -0
- package/es/model/WordClass.js +53 -0
- package/es/model/WordClass.js.map +1 -0
- package/es/model/index.js +19 -0
- package/es/model/index.js.map +1 -0
- package/es/utils/licenseAttributes.js +16 -0
- package/es/utils/licenseAttributes.js.map +1 -0
- package/es/utils/relativeUrl.js +26 -0
- package/es/utils/relativeUrl.js.map +1 -0
- package/lib/Article/Article.js +134 -0
- package/lib/Article/Article.js.map +1 -0
- package/lib/Article/ArticleByline.js +135 -0
- package/lib/Article/ArticleByline.js.map +1 -0
- package/lib/Article/ArticleFootNotes.js +41 -0
- package/lib/Article/ArticleFootNotes.js.map +1 -0
- package/lib/AudioPlayer/AudioPlayer.js +158 -0
- package/lib/AudioPlayer/AudioPlayer.js.map +1 -0
- package/lib/AudioPlayer/Controls.js +255 -0
- package/lib/AudioPlayer/Controls.js.map +1 -0
- package/lib/AudioPlayer/SpeechControl.js +41 -0
- package/lib/AudioPlayer/SpeechControl.js.map +1 -0
- package/lib/AudioPlayer/index.js +8 -0
- package/lib/AudioPlayer/index.js.map +1 -0
- package/lib/Breadcrumb/Breadcrumb.js +45 -0
- package/lib/Breadcrumb/Breadcrumb.js.map +1 -0
- package/lib/Breadcrumb/BreadcrumbItem.js +37 -0
- package/lib/Breadcrumb/BreadcrumbItem.js.map +1 -0
- package/lib/Breadcrumb/HomeBreadcrumb.js +45 -0
- package/lib/Breadcrumb/HomeBreadcrumb.js.map +1 -0
- package/lib/Breadcrumb/index.js +9 -0
- package/lib/Breadcrumb/index.js.map +1 -0
- package/lib/CampaignBlock/CampaignBlock.js +132 -0
- package/lib/CampaignBlock/CampaignBlock.js.map +1 -0
- package/lib/CodeBlock/CodeBlock.js +26 -0
- package/lib/CodeBlock/CodeBlock.js.map +1 -0
- package/lib/CodeBlock/codeLanguageOptions.js +115 -0
- package/lib/CodeBlock/codeLanguageOptions.js.map +1 -0
- package/lib/Concept/Concept.js +51 -0
- package/lib/Concept/Concept.js.map +1 -0
- package/lib/ContactBlock/ContactBlock.js +147 -0
- package/lib/ContactBlock/ContactBlock.js.map +1 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.js +43 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +26 -0
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +26 -0
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
- package/lib/ContentTypeHero/ContentTypeHero.js +40 -0
- package/lib/ContentTypeHero/ContentTypeHero.js.map +1 -0
- package/lib/CopyParagraphButton/CopyParagraphButton.js +63 -0
- package/lib/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
- package/lib/CopyParagraphButton/index.js +8 -0
- package/lib/CopyParagraphButton/index.js.map +1 -0
- package/lib/Embed/AudioEmbed.js +53 -0
- package/lib/Embed/AudioEmbed.js.map +1 -0
- package/lib/Embed/BrightcoveEmbed.js +97 -0
- package/lib/Embed/BrightcoveEmbed.js.map +1 -0
- package/lib/Embed/CodeEmbed.js +62 -0
- package/lib/Embed/CodeEmbed.js.map +1 -0
- package/lib/Embed/ConceptEmbed.js +81 -0
- package/lib/Embed/ConceptEmbed.js.map +1 -0
- package/lib/Embed/ConceptInlineTriggerButton.js +41 -0
- package/lib/Embed/ConceptInlineTriggerButton.js.map +1 -0
- package/lib/Embed/ContentLinkEmbed.js +32 -0
- package/lib/Embed/ContentLinkEmbed.js.map +1 -0
- package/lib/Embed/CopyrightEmbed.js +24 -0
- package/lib/Embed/CopyrightEmbed.js.map +1 -0
- package/lib/Embed/EmbedErrorPlaceholder.js +44 -0
- package/lib/Embed/EmbedErrorPlaceholder.js.map +1 -0
- package/lib/Embed/EmbedWrapper.js +27 -0
- package/lib/Embed/EmbedWrapper.js.map +1 -0
- package/lib/Embed/ExternalEmbed.js +55 -0
- package/lib/Embed/ExternalEmbed.js.map +1 -0
- package/lib/Embed/FootnoteEmbed.js +28 -0
- package/lib/Embed/FootnoteEmbed.js.map +1 -0
- package/lib/Embed/GlossEmbed.js +53 -0
- package/lib/Embed/GlossEmbed.js.map +1 -0
- package/lib/Embed/H5pEmbed.js +39 -0
- package/lib/Embed/H5pEmbed.js.map +1 -0
- package/lib/Embed/IframeEmbed.js +70 -0
- package/lib/Embed/IframeEmbed.js.map +1 -0
- package/lib/Embed/ImageEmbed.js +183 -0
- package/lib/Embed/ImageEmbed.js.map +1 -0
- package/lib/Embed/InlineTriggerButton.js +26 -0
- package/lib/Embed/InlineTriggerButton.js.map +1 -0
- package/lib/Embed/RelatedContentEmbed.js +39 -0
- package/lib/Embed/RelatedContentEmbed.js.map +1 -0
- package/lib/Embed/UnknownEmbed.js +21 -0
- package/lib/Embed/UnknownEmbed.js.map +1 -0
- package/lib/Embed/UuDisclaimerEmbed.js +55 -0
- package/lib/Embed/UuDisclaimerEmbed.js.map +1 -0
- package/lib/ErrorMessage/ErrorMessage.js +55 -0
- package/lib/ErrorMessage/ErrorMessage.js.map +1 -0
- package/lib/ErrorMessage/index.js +8 -0
- package/lib/ErrorMessage/index.js.map +1 -0
- package/lib/FactBox/FactBox.js +122 -0
- package/lib/FactBox/FactBox.js.map +1 -0
- package/lib/FactBox/index.js +8 -0
- package/lib/FactBox/index.js.map +1 -0
- package/lib/FileList/File.js +78 -0
- package/lib/FileList/File.js.map +1 -0
- package/lib/FileList/FileList.js +35 -0
- package/lib/FileList/FileList.js.map +1 -0
- package/lib/FileList/PdfFile.js +29 -0
- package/lib/FileList/PdfFile.js.map +1 -0
- package/lib/Gloss/Gloss.js +143 -0
- package/lib/Gloss/Gloss.js.map +1 -0
- package/lib/Gloss/GlossExample.js +47 -0
- package/lib/Gloss/GlossExample.js.map +1 -0
- package/lib/Grid/Grid.js +67 -0
- package/lib/Grid/Grid.js.map +1 -0
- package/lib/Grid/GridParallaxItem.js +22 -0
- package/lib/Grid/GridParallaxItem.js.map +1 -0
- package/lib/KeyFigure/KeyFigure.js +47 -0
- package/lib/KeyFigure/KeyFigure.js.map +1 -0
- package/lib/LicenseByline/EmbedByline.js +134 -0
- package/lib/LicenseByline/EmbedByline.js.map +1 -0
- package/lib/LicenseByline/LicenseLink.js +32 -0
- package/lib/LicenseByline/LicenseLink.js.map +1 -0
- package/lib/LinkBlock/LinkBlock.js +75 -0
- package/lib/LinkBlock/LinkBlock.js.map +1 -0
- package/lib/LinkBlock/LinkBlockSection.js +24 -0
- package/lib/LinkBlock/LinkBlockSection.js.map +1 -0
- package/lib/Pitch/Pitch.js +63 -0
- package/lib/Pitch/Pitch.js.map +1 -0
- package/lib/RelatedArticleList/RelatedArticleList.js +99 -0
- package/lib/RelatedArticleList/RelatedArticleList.js.map +1 -0
- package/lib/RelatedArticleList/index.js +8 -0
- package/lib/RelatedArticleList/index.js.map +1 -0
- package/lib/ResourceBox/ResourceBox.js +75 -0
- package/lib/ResourceBox/ResourceBox.js.map +1 -0
- package/lib/TagSelector/TagSelector.js +108 -0
- package/lib/TagSelector/TagSelector.js.map +1 -0
- package/lib/ZendeskButton/ZendeskButton.js +42 -0
- package/lib/ZendeskButton/ZendeskButton.js.map +1 -0
- package/lib/_virtual/rolldown_runtime.js +42 -0
- package/lib/i18n/formatNestedMessages.js +18 -0
- package/lib/i18n/formatNestedMessages.js.map +1 -0
- package/lib/i18n/i18n.js +31 -0
- package/lib/i18n/i18n.js.map +1 -0
- package/lib/i18n/useComponentTranslations.js +163 -0
- package/lib/i18n/useComponentTranslations.js.map +1 -0
- package/lib/index.js +157 -0
- package/lib/locale/messages-en.js +439 -0
- package/lib/locale/messages-en.js.map +1 -0
- package/lib/locale/messages-nb.js +439 -0
- package/lib/locale/messages-nb.js.map +1 -0
- package/lib/locale/messages-nn.js +439 -0
- package/lib/locale/messages-nn.js.map +1 -0
- package/lib/locale/messages-se.js +439 -0
- package/lib/locale/messages-se.js.map +1 -0
- package/lib/model/ContentType.js +94 -0
- package/lib/model/ContentType.js.map +1 -0
- package/lib/model/SubjectCategories.js +30 -0
- package/lib/model/SubjectCategories.js.map +1 -0
- package/lib/model/SubjectTypes.js +28 -0
- package/lib/model/SubjectTypes.js.map +1 -0
- package/lib/model/WordClass.js +58 -0
- package/lib/model/WordClass.js.map +1 -0
- package/lib/model/index.js +19 -0
- package/lib/model/index.js.map +1 -0
- package/lib/utils/licenseAttributes.js +17 -0
- package/lib/utils/licenseAttributes.js.map +1 -0
- package/lib/utils/relativeUrl.js +26 -0
- package/lib/utils/relativeUrl.js.map +1 -0
- package/package.json +12 -11
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
3
|
+
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
4
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
5
|
+
|
|
6
|
+
//#region src/Embed/ContentLinkEmbed.tsx
|
|
7
|
+
const ContentLinkEmbed = ({ embed, isOembed, children }) => {
|
|
8
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
9
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Text, {
|
|
10
|
+
color: "text.error",
|
|
11
|
+
asChild: true,
|
|
12
|
+
consumeCss: true,
|
|
13
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: `${t("embed.linkError")}: ` }), children] })
|
|
14
|
+
});
|
|
15
|
+
const { embedData, data } = embed;
|
|
16
|
+
if (embedData.openIn === "new-context" || isOembed) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
17
|
+
href: data.path,
|
|
18
|
+
"data-embed-type": "content-link",
|
|
19
|
+
target: "_blank",
|
|
20
|
+
rel: "noopener noreferrer",
|
|
21
|
+
children
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
24
|
+
href: data.path,
|
|
25
|
+
children
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var ContentLinkEmbed_default = ContentLinkEmbed;
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.ContentLinkEmbed_default = ContentLinkEmbed_default;
|
|
32
|
+
//# sourceMappingURL=ContentLinkEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentLinkEmbed.js","names":["Text"],"sources":["../../src/Embed/ContentLinkEmbed.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 { ReactNode } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Text } from \"@ndla/primitives\";\nimport type { ContentLinkMetaData } from \"@ndla/types-embed\";\n\ninterface Props {\n embed: ContentLinkMetaData;\n isOembed?: boolean;\n children?: ReactNode;\n}\n\nconst ContentLinkEmbed = ({ embed, isOembed, children }: Props) => {\n const { t } = useTranslation();\n if (embed.status === \"error\") {\n return (\n <Text color=\"text.error\" asChild consumeCss>\n <span>\n <span>{`${t(\"embed.linkError\")}: `}</span>\n {children}\n </span>\n </Text>\n );\n }\n\n const { embedData, data } = embed;\n\n if (embedData.openIn === \"new-context\" || isOembed) {\n return (\n <a href={data.path} data-embed-type=\"content-link\" target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </a>\n );\n }\n\n return <a href={data.path}>{children}</a>;\n};\n\nexport default ContentLinkEmbed;\n"],"mappings":";;;;;;AAmBA,MAAM,mBAAmB,CAAC,EAAE,OAAO,UAAU,UAAiB,KAAK;CACjE,MAAM,EAAE,GAAG,GAAG,mCAAgB;AAC9B,KAAI,MAAM,WAAW,QACnB,wBACE,2BAACA;EAAK,OAAM;EAAa;EAAQ;4BAC/B,4BAAC,qCACC,2BAAC,qBAAO,EAAE,EAAE,kBAAkB,CAAC,MAAW,EACzC,YACI;GACF;CAIX,MAAM,EAAE,WAAW,MAAM,GAAG;AAE5B,KAAI,UAAU,WAAW,iBAAiB,SACxC,wBACE,2BAAC;EAAE,MAAM,KAAK;EAAM,mBAAgB;EAAe,QAAO;EAAS,KAAI;EACpE;GACC;AAIR,wBAAO,2BAAC;EAAE,MAAM,KAAK;EAAO;GAAa;AAC1C;AAED,+BAAe"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedByline = require('../LicenseByline/EmbedByline.js');
|
|
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/Embed/CopyrightEmbed.tsx
|
|
7
|
+
const StyledCopyrightContent = (0, __ndla_styled_system_jsx.styled)("div", { base: { marginBlockEnd: "xsmall" } });
|
|
8
|
+
const CopyrightEmbed = ({ embed, children }) => {
|
|
9
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("figure", {
|
|
10
|
+
"data-embed-type": "copyright",
|
|
11
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledCopyrightContent, {
|
|
12
|
+
"data-copyright-content": "",
|
|
13
|
+
children
|
|
14
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedByline.EmbedByline, {
|
|
15
|
+
type: "copyright",
|
|
16
|
+
copyright: embed.embedData.copyright
|
|
17
|
+
})]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var CopyrightEmbed_default = CopyrightEmbed;
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.CopyrightEmbed_default = CopyrightEmbed_default;
|
|
24
|
+
//# sourceMappingURL=CopyrightEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyrightEmbed.js","names":["EmbedByline"],"sources":["../../src/Embed/CopyrightEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ReactNode } from \"react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { CopyrightMetaData } from \"@ndla/types-embed\";\nimport { EmbedByline } from \"../LicenseByline\";\n\ninterface Props {\n embed: CopyrightMetaData;\n children?: ReactNode;\n}\n\nconst StyledCopyrightContent = styled(\"div\", {\n base: {\n marginBlockEnd: \"xsmall\",\n },\n});\n\nconst CopyrightEmbed = ({ embed, children }: Props) => {\n return (\n <figure data-embed-type=\"copyright\">\n <StyledCopyrightContent data-copyright-content=\"\">{children}</StyledCopyrightContent>\n <EmbedByline type=\"copyright\" copyright={embed.embedData.copyright} />\n </figure>\n );\n};\n\nexport default CopyrightEmbed;\n"],"mappings":";;;;;;AAkBA,MAAM,yBAAyB,qCAAO,OAAO,EAC3C,MAAM,EACJ,gBAAgB,SACjB,EACF,EAAC;AAEF,MAAM,iBAAiB,CAAC,EAAE,OAAO,UAAiB,KAAK;AACrD,wBACE,4BAAC;EAAO,mBAAgB;6BACtB,2BAAC;GAAuB,0BAAuB;GAAI;IAAkC,kBACrF,2BAACA;GAAY,MAAK;GAAY,WAAW,MAAM,UAAU;IAAa;GAC/D;AAEZ;AAED,6BAAe"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedByline = require('../LicenseByline/EmbedByline.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 __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
|
|
7
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
8
|
+
|
|
9
|
+
//#region src/Embed/EmbedErrorPlaceholder.tsx
|
|
10
|
+
const ErrorPlaceholder = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
11
|
+
display: "flex",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
justifyContent: "center",
|
|
14
|
+
background: "background.subtle",
|
|
15
|
+
height: "surface.xsmall",
|
|
16
|
+
border: "1px solid",
|
|
17
|
+
borderColor: "stroke.default",
|
|
18
|
+
borderRadius: "xsmall",
|
|
19
|
+
"& svg": {
|
|
20
|
+
height: "5xlarge",
|
|
21
|
+
width: "5xlarge",
|
|
22
|
+
fill: "stroke.default"
|
|
23
|
+
}
|
|
24
|
+
} });
|
|
25
|
+
const StyledFigure = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figure, { base: { "& > *:not(:first-child)": { marginBlockStart: "3xsmall" } } });
|
|
26
|
+
const EmbedErrorPlaceholder = ({ type, children, figureType, float }) => {
|
|
27
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledFigure, {
|
|
28
|
+
size: figureType,
|
|
29
|
+
float,
|
|
30
|
+
"data-embed-type": type,
|
|
31
|
+
children: [children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorPlaceholder, {
|
|
32
|
+
"data-embed-type": type,
|
|
33
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.ErrorWarningLine, {})
|
|
34
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedByline.EmbedByline, {
|
|
35
|
+
error: true,
|
|
36
|
+
type
|
|
37
|
+
})]
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
var EmbedErrorPlaceholder_default = EmbedErrorPlaceholder;
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.EmbedErrorPlaceholder_default = EmbedErrorPlaceholder_default;
|
|
44
|
+
//# sourceMappingURL=EmbedErrorPlaceholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbedErrorPlaceholder.js","names":["Figure","ErrorWarningLine","EmbedByline"],"sources":["../../src/Embed/EmbedErrorPlaceholder.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 ReactNode } from \"react\";\nimport { ErrorWarningLine } from \"@ndla/icons\";\nimport { Figure, type FigureFloat, type FigureSize } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { EmbedByline } from \"../LicenseByline\";\nimport { type EmbedBylineErrorProps } from \"../LicenseByline/EmbedByline\";\n\ninterface Props {\n type: EmbedBylineErrorProps[\"type\"];\n figureType?: FigureSize;\n float?: FigureFloat;\n children?: ReactNode;\n}\n\nconst ErrorPlaceholder = styled(\"div\", {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"background.subtle\",\n height: \"surface.xsmall\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n borderRadius: \"xsmall\",\n \"& svg\": {\n height: \"5xlarge\",\n width: \"5xlarge\",\n fill: \"stroke.default\",\n },\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n \"& > *:not(:first-child)\": {\n marginBlockStart: \"3xsmall\",\n },\n },\n});\n\nconst EmbedErrorPlaceholder = ({ type, children, figureType, float }: Props) => {\n return (\n <StyledFigure size={figureType} float={float} data-embed-type={type}>\n {children ?? (\n <ErrorPlaceholder data-embed-type={type}>\n <ErrorWarningLine />\n </ErrorPlaceholder>\n )}\n <EmbedByline error type={type} />\n </StyledFigure>\n );\n};\n\nexport default EmbedErrorPlaceholder;\n"],"mappings":";;;;;;;;;AAsBA,MAAM,mBAAmB,qCAAO,OAAO,EACrC,MAAM;CACJ,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,aAAa;CACb,cAAc;CACd,SAAS;EACP,QAAQ;EACR,OAAO;EACP,MAAM;CACP;AACF,EACF,EAAC;AAEF,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM,EACJ,2BAA2B,EACzB,kBAAkB,UACnB,EACF,EACF,EAAC;AAEF,MAAM,wBAAwB,CAAC,EAAE,MAAM,UAAU,YAAY,OAAc,KAAK;AAC9E,wBACE,4BAAC;EAAa,MAAM;EAAmB;EAAO,mBAAiB;aAC5D,4BACC,2BAAC;GAAiB,mBAAiB;6BACjC,2BAACC,kCAAmB;IACH,kBAErB,2BAACC;GAAY;GAAY;IAAQ;GACpB;AAElB;AAED,oCAAe"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
3
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
4
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
5
|
+
const __ark_ui_react = require_rolldown_runtime.__toESM(require("@ark-ui/react"));
|
|
6
|
+
const __ndla_styled_system_css = require_rolldown_runtime.__toESM(require("@ndla/styled-system/css"));
|
|
7
|
+
|
|
8
|
+
//#region src/Embed/EmbedWrapper.tsx
|
|
9
|
+
const embedWrapperRecipe = (0, __ndla_styled_system_css.cva)({
|
|
10
|
+
base: { position: "relative" },
|
|
11
|
+
defaultVariants: { noClear: false },
|
|
12
|
+
variants: { noClear: {
|
|
13
|
+
true: { "& + [data-embed-wrapper]": { clear: "both" } },
|
|
14
|
+
false: { clear: "both" }
|
|
15
|
+
} }
|
|
16
|
+
});
|
|
17
|
+
const StyledEmbedWrapper = (0, __ndla_styled_system_jsx.styled)(__ark_ui_react.ark.div, {}, { baseComponent: true });
|
|
18
|
+
const EmbedWrapper = (0, react.forwardRef)(({ noClear, css: cssProp,...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledEmbedWrapper, {
|
|
19
|
+
css: __ndla_styled_system_css.css.raw(embedWrapperRecipe.raw({ noClear }), cssProp),
|
|
20
|
+
"data-embed-wrapper": "",
|
|
21
|
+
...props,
|
|
22
|
+
ref
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.EmbedWrapper = EmbedWrapper;
|
|
27
|
+
//# sourceMappingURL=EmbedWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbedWrapper.js","names":["ark"],"sources":["../../src/Embed/EmbedWrapper.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 } from \"react\";\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\";\nimport { css, cva } from \"@ndla/styled-system/css\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { JsxStyleProps, RecipeVariantProps } from \"@ndla/styled-system/types\";\n\nconst embedWrapperRecipe = cva({\n base: {\n position: \"relative\",\n },\n defaultVariants: {\n noClear: false,\n },\n variants: {\n noClear: {\n true: {\n \"& + [data-embed-wrapper]\": {\n clear: \"both\",\n },\n },\n false: {\n clear: \"both\",\n },\n },\n },\n});\n\nexport type EmbedWrapperVariantProps = RecipeVariantProps<typeof embedWrapperRecipe>;\n\nexport type EmbedWrapperProps = HTMLArkProps<\"div\"> & JsxStyleProps & EmbedWrapperVariantProps;\n\nconst StyledEmbedWrapper = styled(ark.div, {}, { baseComponent: true });\n\nexport const EmbedWrapper = forwardRef<HTMLDivElement, EmbedWrapperProps>(\n ({ noClear, css: cssProp, ...props }, ref) => (\n <StyledEmbedWrapper\n css={css.raw(embedWrapperRecipe.raw({ noClear }), cssProp)}\n data-embed-wrapper=\"\"\n {...props}\n ref={ref}\n />\n ),\n);\n"],"mappings":";;;;;;;;AAcA,MAAM,qBAAqB,kCAAI;CAC7B,MAAM,EACJ,UAAU,WACX;CACD,iBAAiB,EACf,SAAS,MACV;CACD,UAAU,EACR,SAAS;EACP,MAAM,EACJ,4BAA4B,EAC1B,OAAO,OACR,EACF;EACD,OAAO,EACL,OAAO,OACR;CACF,EACF;AACF,EAAC;AAMF,MAAM,qBAAqB,qCAAOA,mBAAI,KAAK,CAAE,GAAE,EAAE,eAAe,KAAM,EAAC;AAEvE,MAAa,eAAe,sBAC1B,CAAC,EAAE,SAAS,KAAK,QAAS,GAAG,OAAO,EAAE,wBACpC,2BAAC;CACC,KAAK,6BAAI,IAAI,mBAAmB,IAAI,EAAE,QAAS,EAAC,EAAE,QAAQ;CAC1D,sBAAmB;CACnB,GAAI;CACC;EACL,CAEL"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
|
+
const require_ResourceBox = require('../ResourceBox/ResourceBox.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 react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
9
|
+
|
|
10
|
+
//#region src/Embed/ExternalEmbed.tsx
|
|
11
|
+
const StyledFigure = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figure, { base: { "& iframe": {
|
|
12
|
+
height: "auto",
|
|
13
|
+
width: "100%"
|
|
14
|
+
} } });
|
|
15
|
+
const ExternalEmbed = ({ embed }) => {
|
|
16
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
17
|
+
const figRef = (0, react.useRef)(null);
|
|
18
|
+
(0, react.useEffect)(() => {
|
|
19
|
+
const iframe = figRef.current?.querySelector("iframe");
|
|
20
|
+
if (iframe) {
|
|
21
|
+
const [width, height] = [Number.parseInt(iframe.width), Number.parseInt(iframe.height)];
|
|
22
|
+
iframe.style.aspectRatio = `${width ? width : 16}/${height ? height : 9}`;
|
|
23
|
+
iframe.width = "";
|
|
24
|
+
iframe.height = "";
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, { type: "external" });
|
|
28
|
+
const { embedData, data } = embed;
|
|
29
|
+
if (embedData.type === "fullscreen") {
|
|
30
|
+
const image = {
|
|
31
|
+
src: data.iframeImage?.image.imageUrl,
|
|
32
|
+
alt: embedData.alt !== void 0 ? embedData.alt : data.iframeImage?.alttext?.alttext ?? ""
|
|
33
|
+
};
|
|
34
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Figure, {
|
|
35
|
+
"data-embed-type": "external",
|
|
36
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ResourceBox.ResourceBox_default, {
|
|
37
|
+
image,
|
|
38
|
+
title: embedData.title ?? "",
|
|
39
|
+
url: embedData.url,
|
|
40
|
+
caption: embedData.caption ?? "",
|
|
41
|
+
buttonText: t("license.other.itemImage.ariaLabel")
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledFigure, {
|
|
46
|
+
"data-embed-type": "external",
|
|
47
|
+
ref: figRef,
|
|
48
|
+
dangerouslySetInnerHTML: { __html: data?.oembed?.html ?? "" }
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
var ExternalEmbed_default = ExternalEmbed;
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
exports.ExternalEmbed_default = ExternalEmbed_default;
|
|
55
|
+
//# sourceMappingURL=ExternalEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExternalEmbed.js","names":["Figure","EmbedErrorPlaceholder","ResourceBox"],"sources":["../../src/Embed/ExternalEmbed.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 { useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { OembedMetaData } from \"@ndla/types-embed\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport { ResourceBox } from \"../ResourceBox\";\n\ninterface Props {\n embed: OembedMetaData;\n}\n\nconst StyledFigure = styled(Figure, {\n base: {\n \"& iframe\": {\n height: \"auto\",\n width: \"100%\",\n },\n },\n});\n\nconst ExternalEmbed = ({ embed }: Props) => {\n const { t } = useTranslation();\n const figRef = useRef<HTMLElement>(null);\n\n useEffect(() => {\n const iframe = figRef.current?.querySelector(\"iframe\");\n if (iframe) {\n const [width, height] = [Number.parseInt(iframe.width), Number.parseInt(iframe.height)];\n iframe.style.aspectRatio = `${width ? width : 16}/${height ? height : 9}`;\n iframe.width = \"\";\n iframe.height = \"\";\n }\n }, []);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"external\" />;\n }\n\n const { embedData, data } = embed;\n\n if (embedData.type === \"fullscreen\") {\n const image = {\n src: data.iframeImage?.image.imageUrl,\n alt: embedData.alt !== undefined ? embedData.alt : (data.iframeImage?.alttext?.alttext ?? \"\"),\n };\n return (\n <Figure data-embed-type=\"external\">\n <ResourceBox\n image={image}\n title={embedData.title ?? \"\"}\n url={embedData.url}\n caption={embedData.caption ?? \"\"}\n buttonText={t(\"license.other.itemImage.ariaLabel\")}\n />\n </Figure>\n );\n }\n\n return (\n <StyledFigure\n data-embed-type=\"external\"\n ref={figRef}\n dangerouslySetInnerHTML={{ __html: data?.oembed?.html ?? \"\" }}\n />\n );\n};\nexport default ExternalEmbed;\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM,EACJ,YAAY;CACV,QAAQ;CACR,OAAO;AACR,EACF,EACF,EAAC;AAEF,MAAM,gBAAgB,CAAC,EAAE,OAAc,KAAK;CAC1C,MAAM,EAAE,GAAG,GAAG,mCAAgB;CAC9B,MAAM,SAAS,kBAAoB,KAAK;AAExC,sBAAU,MAAM;EACd,MAAM,SAAS,OAAO,SAAS,cAAc,SAAS;AACtD,MAAI,QAAQ;GACV,MAAM,CAAC,OAAO,OAAO,GAAG,CAAC,OAAO,SAAS,OAAO,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,AAAC;AACvF,UAAO,MAAM,eAAe,EAAE,QAAQ,QAAQ,GAAG,GAAG,SAAS,SAAS,EAAE;AACxE,UAAO,QAAQ;AACf,UAAO,SAAS;EACjB;CACF,GAAE,CAAE,EAAC;AAEN,KAAI,MAAM,WAAW,QACnB,wBAAO,2BAACC,+DAAsB,MAAK,aAAa;CAGlD,MAAM,EAAE,WAAW,MAAM,GAAG;AAE5B,KAAI,UAAU,SAAS,cAAc;EACnC,MAAM,QAAQ;GACZ,KAAK,KAAK,aAAa,MAAM;GAC7B,KAAK,UAAU,iBAAoB,UAAU,MAAO,KAAK,aAAa,SAAS,WAAW;EAC3F;AACD,yBACE,2BAACD;GAAO,mBAAgB;6BACtB,2BAACE;IACQ;IACP,OAAO,UAAU,SAAS;IAC1B,KAAK,UAAU;IACf,SAAS,UAAU,WAAW;IAC9B,YAAY,EAAE,oCAAoC;KAClD;IACK;CAEZ;AAED,wBACE,2BAAC;EACC,mBAAgB;EAChB,KAAK;EACL,yBAAyB,EAAE,QAAQ,MAAM,QAAQ,QAAQ,GAAI;GAC7D;AAEL;AACD,4BAAe"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
3
|
+
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
4
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
5
|
+
|
|
6
|
+
//#region src/Embed/FootnoteEmbed.tsx
|
|
7
|
+
const StyledSup = (0, __ndla_styled_system_jsx.styled)("sup", { base: { "& a": {
|
|
8
|
+
textStyle: "label.xsmall",
|
|
9
|
+
marginInlineStart: "1"
|
|
10
|
+
} } });
|
|
11
|
+
const FootnoteEmbed = ({ embed }) => {
|
|
12
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
13
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: t("error") });
|
|
14
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
15
|
+
id: `ref${embed.data.entryNum}`,
|
|
16
|
+
"data-embed-type": "footnote",
|
|
17
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledSup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
18
|
+
href: `#note${embed.data.entryNum}`,
|
|
19
|
+
target: "_self",
|
|
20
|
+
children: `[${embed.data.entryNum}]`
|
|
21
|
+
}) })
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var FootnoteEmbed_default = FootnoteEmbed;
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.FootnoteEmbed_default = FootnoteEmbed_default;
|
|
28
|
+
//# sourceMappingURL=FootnoteEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FootnoteEmbed.js","names":[],"sources":["../../src/Embed/FootnoteEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { useTranslation } from \"react-i18next\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { FootnoteMetaData } from \"@ndla/types-embed\";\n\ninterface Props {\n embed: FootnoteMetaData;\n}\n\nconst StyledSup = styled(\"sup\", {\n base: {\n \"& a\": {\n textStyle: \"label.xsmall\",\n marginInlineStart: \"1\",\n },\n },\n});\n\nconst FootnoteEmbed = ({ embed }: Props) => {\n const { t } = useTranslation();\n if (embed.status === \"error\") {\n return <div>{t(\"error\")}</div>;\n }\n\n return (\n <span id={`ref${embed.data.entryNum}`} data-embed-type=\"footnote\">\n <StyledSup>\n <a href={`#note${embed.data.entryNum}`} target=\"_self\">{`[${embed.data.entryNum}]`}</a>\n </StyledSup>\n </span>\n );\n};\n\nexport default FootnoteEmbed;\n"],"mappings":";;;;;;AAgBA,MAAM,YAAY,qCAAO,OAAO,EAC9B,MAAM,EACJ,OAAO;CACL,WAAW;CACX,mBAAmB;AACpB,EACF,EACF,EAAC;AAEF,MAAM,gBAAgB,CAAC,EAAE,OAAc,KAAK;CAC1C,MAAM,EAAE,GAAG,GAAG,mCAAgB;AAC9B,KAAI,MAAM,WAAW,QACnB,wBAAO,2BAAC,mBAAK,EAAE,QAAQ,GAAO;AAGhC,wBACE,2BAAC;EAAK,KAAK,KAAK,MAAM,KAAK,SAAS;EAAG,mBAAgB;4BACrD,2BAAC,uCACC,2BAAC;GAAE,OAAO,OAAO,MAAM,KAAK,SAAS;GAAG,QAAO;cAAU,GAAG,MAAM,KAAK,SAAS;IAAO,GAC7E;GACP;AAEV;AAED,4BAAe"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
|
+
const require_ConceptInlineTriggerButton = require('./ConceptInlineTriggerButton.js');
|
|
4
|
+
const require_Gloss = require('../Gloss/Gloss.js');
|
|
5
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
6
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
7
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
8
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
9
|
+
const __ark_ui_react = require_rolldown_runtime.__toESM(require("@ark-ui/react"));
|
|
10
|
+
|
|
11
|
+
//#region src/Embed/GlossEmbed.tsx
|
|
12
|
+
const StyledPopoverContent = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.PopoverContent, { base: { width: "surface.xlarge" } });
|
|
13
|
+
const GlossEmbed = ({ embed }) => {
|
|
14
|
+
const contentRef = (0, react.useRef)(null);
|
|
15
|
+
if (embed.status === "error" && embed.embedData.type === "inline") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: embed.embedData.linkText });
|
|
16
|
+
if (embed.status === "error" || !embed.data.concept.glossData) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, { type: "gloss" });
|
|
17
|
+
const { concept, visualElement } = embed.data;
|
|
18
|
+
const audio = visualElement?.status === "success" && visualElement.resource === "audio" ? {
|
|
19
|
+
src: visualElement.data.audioFile.url,
|
|
20
|
+
title: visualElement.data.title.title
|
|
21
|
+
} : void 0;
|
|
22
|
+
if (embed.embedData.type === "inline") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.PopoverRoot, {
|
|
23
|
+
initialFocusEl: () => contentRef.current,
|
|
24
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.PopoverTrigger, {
|
|
25
|
+
asChild: true,
|
|
26
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ConceptInlineTriggerButton.ConceptInlineTriggerButton, { children: embed.embedData.linkText })
|
|
27
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ark_ui_react.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledPopoverContent, {
|
|
28
|
+
ref: contentRef,
|
|
29
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Figure, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Gloss.Gloss_default, {
|
|
30
|
+
glossData: concept.glossData,
|
|
31
|
+
title: concept.title,
|
|
32
|
+
audio,
|
|
33
|
+
exampleIds: embed.embedData.exampleIds,
|
|
34
|
+
exampleLangs: embed.embedData.exampleLangs
|
|
35
|
+
}) })
|
|
36
|
+
}) })]
|
|
37
|
+
});
|
|
38
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Figure, {
|
|
39
|
+
"data-embed-type": "gloss",
|
|
40
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Gloss.Gloss_default, {
|
|
41
|
+
glossData: concept.glossData,
|
|
42
|
+
title: concept.title,
|
|
43
|
+
audio,
|
|
44
|
+
exampleIds: embed.embedData.exampleIds,
|
|
45
|
+
exampleLangs: embed.embedData.exampleLangs,
|
|
46
|
+
variant: "bordered"
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.GlossEmbed = GlossEmbed;
|
|
53
|
+
//# sourceMappingURL=GlossEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlossEmbed.js","names":["PopoverContent","EmbedErrorPlaceholder","PopoverRoot","PopoverTrigger","ConceptInlineTriggerButton","Portal","Figure","Gloss"],"sources":["../../src/Embed/GlossEmbed.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 { useRef } from \"react\";\nimport { Portal } from \"@ark-ui/react\";\nimport { Figure, PopoverContent, PopoverRoot, PopoverTrigger } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { ConceptMetaData } from \"@ndla/types-embed\";\nimport { ConceptInlineTriggerButton } from \"./ConceptInlineTriggerButton\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport { Gloss } from \"../Gloss\";\n\ninterface Props {\n embed: ConceptMetaData;\n}\n\nconst StyledPopoverContent = styled(PopoverContent, {\n base: {\n width: \"surface.xlarge\",\n },\n});\n\nexport const GlossEmbed = ({ embed }: Props) => {\n const contentRef = useRef<HTMLDivElement>(null);\n if (embed.status === \"error\" && embed.embedData.type === \"inline\") {\n return <span>{embed.embedData.linkText}</span>;\n }\n if (embed.status === \"error\" || !embed.data.concept.glossData) {\n return <EmbedErrorPlaceholder type=\"gloss\" />;\n }\n\n const { concept, visualElement } = embed.data;\n\n const audio =\n visualElement?.status === \"success\" && visualElement.resource === \"audio\"\n ? {\n src: visualElement.data.audioFile.url,\n title: visualElement.data.title.title,\n }\n : undefined;\n\n if (embed.embedData.type === \"inline\") {\n return (\n <PopoverRoot initialFocusEl={() => contentRef.current}>\n <PopoverTrigger asChild>\n <ConceptInlineTriggerButton>{embed.embedData.linkText}</ConceptInlineTriggerButton>\n </PopoverTrigger>\n <Portal>\n <StyledPopoverContent ref={contentRef}>\n <Figure>\n <Gloss\n glossData={concept.glossData}\n title={concept.title}\n audio={audio}\n exampleIds={embed.embedData.exampleIds}\n exampleLangs={embed.embedData.exampleLangs}\n />\n </Figure>\n </StyledPopoverContent>\n </Portal>\n </PopoverRoot>\n );\n }\n\n return (\n <Figure data-embed-type=\"gloss\">\n <Gloss\n glossData={concept.glossData}\n title={concept.title}\n audio={audio}\n exampleIds={embed.embedData.exampleIds}\n exampleLangs={embed.embedData.exampleLangs}\n variant=\"bordered\"\n />\n </Figure>\n );\n};\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,uBAAuB,qCAAOA,kCAAgB,EAClD,MAAM,EACJ,OAAO,iBACR,EACF,EAAC;AAEF,MAAa,aAAa,CAAC,EAAE,OAAc,KAAK;CAC9C,MAAM,aAAa,kBAAuB,KAAK;AAC/C,KAAI,MAAM,WAAW,WAAW,MAAM,UAAU,SAAS,SACvD,wBAAO,2BAAC,oBAAM,MAAM,UAAU,WAAgB;AAEhD,KAAI,MAAM,WAAW,YAAY,MAAM,KAAK,QAAQ,UAClD,wBAAO,2BAACC,+DAAsB,MAAK,UAAU;CAG/C,MAAM,EAAE,SAAS,eAAe,GAAG,MAAM;CAEzC,MAAM,QACJ,eAAe,WAAW,aAAa,cAAc,aAAa,UAC9D;EACE,KAAK,cAAc,KAAK,UAAU;EAClC,OAAO,cAAc,KAAK,MAAM;CACjC;AAGP,KAAI,MAAM,UAAU,SAAS,SAC3B,wBACE,4BAACC;EAAY,gBAAgB,MAAM,WAAW;6BAC5C,2BAACC;GAAe;6BACd,2BAACC,2EAA4B,MAAM,UAAU,WAAsC;IACpE,kBACjB,2BAACC,mDACC,2BAAC;GAAqB,KAAK;6BACzB,2BAACC,sDACC,2BAACC;IACC,WAAW,QAAQ;IACnB,OAAO,QAAQ;IACR;IACP,YAAY,MAAM,UAAU;IAC5B,cAAc,MAAM,UAAU;KAC9B,GACK;IACY,GAChB;GACG;AAIlB,wBACE,2BAACD;EAAO,mBAAgB;4BACtB,2BAACC;GACC,WAAW,QAAQ;GACnB,OAAO,QAAQ;GACR;GACP,YAAY,MAAM,UAAU;GAC5B,cAAc,MAAM,UAAU;GAC9B,SAAQ;IACR;GACK;AAEZ"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.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 react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
6
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
7
|
+
|
|
8
|
+
//#region src/Embed/H5pEmbed.tsx
|
|
9
|
+
const StyledFigure = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figure, { base: { "& iframe": {
|
|
10
|
+
height: "auto",
|
|
11
|
+
width: "100%"
|
|
12
|
+
} } });
|
|
13
|
+
const FigureOembed = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figure, { base: {
|
|
14
|
+
width: "100%",
|
|
15
|
+
"& iframe": { width: "100%" }
|
|
16
|
+
} });
|
|
17
|
+
const H5pEmbed = ({ embed }) => {
|
|
18
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
19
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, { type: "h5p" });
|
|
20
|
+
if (embed.data.oembed) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FigureOembed, {
|
|
21
|
+
"data-embed-type": "h5p",
|
|
22
|
+
dangerouslySetInnerHTML: { __html: embed.data.oembed.html ?? "" }
|
|
23
|
+
});
|
|
24
|
+
const title = embed.embedData.title?.trim() ? embed.embedData.title : embed.data.h5pLicenseInformation?.h5p.title?.trim() ? embed.data.h5pLicenseInformation.h5p.title : embed.embedData.url;
|
|
25
|
+
const titleWithPrefix = `${t("embed.type.h5p")}: ${title}`;
|
|
26
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledFigure, {
|
|
27
|
+
"data-embed-type": "h5p",
|
|
28
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
|
|
29
|
+
title: titleWithPrefix,
|
|
30
|
+
"aria-label": titleWithPrefix,
|
|
31
|
+
src: embed.embedData.url
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var H5pEmbed_default = H5pEmbed;
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.H5pEmbed_default = H5pEmbed_default;
|
|
39
|
+
//# sourceMappingURL=H5pEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"H5pEmbed.js","names":["Figure","EmbedErrorPlaceholder"],"sources":["../../src/Embed/H5pEmbed.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { useTranslation } from \"react-i18next\";\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { H5pMetaData } from \"@ndla/types-embed\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\n\ninterface Props {\n embed: H5pMetaData;\n}\n\nconst StyledFigure = styled(Figure, {\n base: {\n \"& iframe\": {\n height: \"auto\",\n width: \"100%\",\n },\n },\n});\n\nconst FigureOembed = styled(Figure, {\n base: {\n width: \"100%\",\n \"& iframe\": {\n width: \"100%\",\n },\n },\n});\n\nconst H5pEmbed = ({ embed }: Props) => {\n const { t } = useTranslation();\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"h5p\" />;\n }\n\n if (embed.data.oembed) {\n return <FigureOembed data-embed-type=\"h5p\" dangerouslySetInnerHTML={{ __html: embed.data.oembed.html ?? \"\" }} />;\n }\n\n const title = embed.embedData.title?.trim()\n ? embed.embedData.title\n : embed.data.h5pLicenseInformation?.h5p.title?.trim()\n ? embed.data.h5pLicenseInformation.h5p.title\n : embed.embedData.url;\n\n const titleWithPrefix = `${t(\"embed.type.h5p\")}: ${title}`;\n\n return (\n <StyledFigure data-embed-type=\"h5p\">\n <iframe title={titleWithPrefix} aria-label={titleWithPrefix} src={embed.embedData.url} />\n </StyledFigure>\n );\n};\n\nexport default H5pEmbed;\n"],"mappings":";;;;;;;;AAkBA,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM,EACJ,YAAY;CACV,QAAQ;CACR,OAAO;AACR,EACF,EACF,EAAC;AAEF,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM;CACJ,OAAO;CACP,YAAY,EACV,OAAO,OACR;AACF,EACF,EAAC;AAEF,MAAM,WAAW,CAAC,EAAE,OAAc,KAAK;CACrC,MAAM,EAAE,GAAG,GAAG,mCAAgB;AAC9B,KAAI,MAAM,WAAW,QACnB,wBAAO,2BAACC,+DAAsB,MAAK,QAAQ;AAG7C,KAAI,MAAM,KAAK,OACb,wBAAO,2BAAC;EAAa,mBAAgB;EAAM,yBAAyB,EAAE,QAAQ,MAAM,KAAK,OAAO,QAAQ,GAAI;GAAI;CAGlH,MAAM,QAAQ,MAAM,UAAU,OAAO,MAAM,GACvC,MAAM,UAAU,QAChB,MAAM,KAAK,uBAAuB,IAAI,OAAO,MAAM,GACjD,MAAM,KAAK,sBAAsB,IAAI,QACrC,MAAM,UAAU;CAEtB,MAAM,mBAAmB,EAAE,EAAE,iBAAiB,CAAC,IAAI,MAAM;AAEzD,wBACE,2BAAC;EAAa,mBAAgB;4BAC5B,2BAAC;GAAO,OAAO;GAAiB,cAAY;GAAiB,KAAK,MAAM,UAAU;IAAO;GAC5E;AAElB;AAED,uBAAe"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
|
+
const require_ResourceBox = require('../ResourceBox/ResourceBox.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 react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
9
|
+
|
|
10
|
+
//#region src/Embed/IframeEmbed.tsx
|
|
11
|
+
const StyledIframe = (0, __ndla_styled_system_jsx.styled)("iframe", { base: {
|
|
12
|
+
width: "100%",
|
|
13
|
+
border: 0
|
|
14
|
+
} });
|
|
15
|
+
const StyledFigure = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figure, { base: { clear: "both" } });
|
|
16
|
+
const IframeEmbed = ({ embed }) => {
|
|
17
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
18
|
+
const iframeRef = (0, react.useRef)(null);
|
|
19
|
+
(0, react.useEffect)(() => {
|
|
20
|
+
const iframe = iframeRef.current;
|
|
21
|
+
if (iframe) {
|
|
22
|
+
const [width$1, height$1] = [Number.parseInt(iframe.width), Number.parseInt(iframe.height)];
|
|
23
|
+
iframe.style.aspectRatio = `${width$1 ? width$1 : 16}/${height$1 ? height$1 : 9}`;
|
|
24
|
+
iframe.width = "";
|
|
25
|
+
iframe.height = "";
|
|
26
|
+
}
|
|
27
|
+
}, []);
|
|
28
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, { type: "external" });
|
|
29
|
+
const { embedData, data } = embed;
|
|
30
|
+
if (embedData.type === "fullscreen") {
|
|
31
|
+
const iframeImage = embed.status === "success" ? data.iframeImage : void 0;
|
|
32
|
+
const alt = embedData.alt !== void 0 ? embedData.alt : iframeImage?.alttext.alttext;
|
|
33
|
+
const image = {
|
|
34
|
+
src: iframeImage?.image.imageUrl,
|
|
35
|
+
alt: alt ?? ""
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledFigure, {
|
|
38
|
+
"data-embed-type": "iframe",
|
|
39
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ResourceBox.ResourceBox_default, {
|
|
40
|
+
image,
|
|
41
|
+
title: embedData.title ?? "",
|
|
42
|
+
url: embedData.url,
|
|
43
|
+
caption: embedData.caption ?? "",
|
|
44
|
+
buttonText: t("license.other.itemImage.ariaLabel")
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const { width, height, url } = embedData;
|
|
49
|
+
const strippedWidth = typeof width === "number" ? width : width?.replace(/\s*px/, "");
|
|
50
|
+
const strippedHeight = typeof height === "number" ? height : height?.replace(/\s*px/, "");
|
|
51
|
+
const title = `${t("embed.type.external")}: ${embedData.title?.trim() ? embedData.title : url}`;
|
|
52
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledFigure, {
|
|
53
|
+
"data-embed-type": "iframe",
|
|
54
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledIframe, {
|
|
55
|
+
ref: iframeRef,
|
|
56
|
+
title,
|
|
57
|
+
"aria-label": title,
|
|
58
|
+
src: url,
|
|
59
|
+
width: strippedWidth,
|
|
60
|
+
height: strippedHeight,
|
|
61
|
+
allow: "fullscreen; encrypted-media",
|
|
62
|
+
loading: "lazy"
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
var IframeEmbed_default = IframeEmbed;
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
exports.IframeEmbed_default = IframeEmbed_default;
|
|
70
|
+
//# sourceMappingURL=IframeEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IframeEmbed.js","names":["Figure","width","height","EmbedErrorPlaceholder","ResourceBox"],"sources":["../../src/Embed/IframeEmbed.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 { useEffect, useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { IframeMetaData } from \"@ndla/types-embed\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport { ResourceBox } from \"../ResourceBox\";\n\ninterface Props {\n embed: IframeMetaData;\n}\n\nconst StyledIframe = styled(\"iframe\", {\n base: {\n width: \"100%\",\n border: 0,\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n },\n});\n\nconst IframeEmbed = ({ embed }: Props) => {\n const { t } = useTranslation();\n const iframeRef = useRef<HTMLIFrameElement>(null);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (iframe) {\n const [width, height] = [Number.parseInt(iframe.width), Number.parseInt(iframe.height)];\n iframe.style.aspectRatio = `${width ? width : 16}/${height ? height : 9}`;\n iframe.width = \"\";\n iframe.height = \"\";\n }\n }, []);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"external\" />;\n }\n\n const { embedData, data } = embed;\n\n if (embedData.type === \"fullscreen\") {\n const iframeImage = embed.status === \"success\" ? data.iframeImage : undefined;\n const alt = embedData.alt !== undefined ? embedData.alt : iframeImage?.alttext.alttext;\n const image = { src: iframeImage?.image.imageUrl, alt: alt ?? \"\" };\n return (\n <StyledFigure data-embed-type=\"iframe\">\n <ResourceBox\n image={image}\n title={embedData.title ?? \"\"}\n url={embedData.url}\n caption={embedData.caption ?? \"\"}\n buttonText={t(\"license.other.itemImage.ariaLabel\")}\n />\n </StyledFigure>\n );\n }\n\n const { width, height, url } = embedData;\n\n const strippedWidth = typeof width === \"number\" ? width : width?.replace(/\\s*px/, \"\");\n const strippedHeight = typeof height === \"number\" ? height : height?.replace(/\\s*px/, \"\");\n const title = `${t(\"embed.type.external\")}: ${embedData.title?.trim() ? embedData.title : url}`;\n\n return (\n <StyledFigure data-embed-type=\"iframe\">\n <StyledIframe\n ref={iframeRef}\n title={title}\n aria-label={title}\n src={url}\n width={strippedWidth}\n height={strippedHeight}\n allow=\"fullscreen; encrypted-media\"\n loading=\"lazy\"\n />\n </StyledFigure>\n );\n};\n\nexport default IframeEmbed;\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,eAAe,qCAAO,UAAU,EACpC,MAAM;CACJ,OAAO;CACP,QAAQ;AACT,EACF,EAAC;AAEF,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM,EACJ,OAAO,OACR,EACF,EAAC;AAEF,MAAM,cAAc,CAAC,EAAE,OAAc,KAAK;CACxC,MAAM,EAAE,GAAG,GAAG,mCAAgB;CAC9B,MAAM,YAAY,kBAA0B,KAAK;AAEjD,sBAAU,MAAM;EACd,MAAM,SAAS,UAAU;AACzB,MAAI,QAAQ;GACV,MAAM,CAACC,SAAOC,SAAO,GAAG,CAAC,OAAO,SAAS,OAAO,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,AAAC;AACvF,UAAO,MAAM,eAAe,EAAED,UAAQA,UAAQ,GAAG,GAAGC,WAASA,WAAS,EAAE;AACxE,UAAO,QAAQ;AACf,UAAO,SAAS;EACjB;CACF,GAAE,CAAE,EAAC;AAEN,KAAI,MAAM,WAAW,QACnB,wBAAO,2BAACC,+DAAsB,MAAK,aAAa;CAGlD,MAAM,EAAE,WAAW,MAAM,GAAG;AAE5B,KAAI,UAAU,SAAS,cAAc;EACnC,MAAM,cAAc,MAAM,WAAW,YAAY,KAAK;EACtD,MAAM,MAAM,UAAU,iBAAoB,UAAU,MAAM,aAAa,QAAQ;EAC/E,MAAM,QAAQ;GAAE,KAAK,aAAa,MAAM;GAAU,KAAK,OAAO;EAAI;AAClE,yBACE,2BAAC;GAAa,mBAAgB;6BAC5B,2BAACC;IACQ;IACP,OAAO,UAAU,SAAS;IAC1B,KAAK,UAAU;IACf,SAAS,UAAU,WAAW;IAC9B,YAAY,EAAE,oCAAoC;KAClD;IACW;CAElB;CAED,MAAM,EAAE,OAAO,QAAQ,KAAK,GAAG;CAE/B,MAAM,uBAAuB,UAAU,WAAW,QAAQ,OAAO,QAAQ,SAAS,GAAG;CACrF,MAAM,wBAAwB,WAAW,WAAW,SAAS,QAAQ,QAAQ,SAAS,GAAG;CACzF,MAAM,SAAS,EAAE,EAAE,sBAAsB,CAAC,IAAI,UAAU,OAAO,MAAM,GAAG,UAAU,QAAQ,IAAI;AAE9F,wBACE,2BAAC;EAAa,mBAAgB;4BAC5B,2BAAC;GACC,KAAK;GACE;GACP,cAAY;GACZ,KAAK;GACL,OAAO;GACP,QAAQ;GACR,OAAM;GACN,SAAQ;IACR;GACW;AAElB;AAED,0BAAe"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_EmbedByline = require('../LicenseByline/EmbedByline.js');
|
|
3
|
+
const require_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
4
|
+
const require_licenseAttributes = require('../utils/licenseAttributes.js');
|
|
5
|
+
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
6
|
+
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
7
|
+
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
8
|
+
const html_react_parser = require_rolldown_runtime.__toESM(require("html-react-parser"));
|
|
9
|
+
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
10
|
+
const __ndla_icons = require_rolldown_runtime.__toESM(require("@ndla/icons"));
|
|
11
|
+
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
12
|
+
|
|
13
|
+
//#region src/Embed/ImageEmbed.tsx
|
|
14
|
+
const getFigureProps = (size, float) => {
|
|
15
|
+
const actualFloat = float === "left" ? "left" : float === "right" ? "right" : void 0;
|
|
16
|
+
const replacedSize = size?.replace("-hide-byline", "") ?? "full";
|
|
17
|
+
const actualSize = replacedSize === "fullwidth" ? "full" : replacedSize;
|
|
18
|
+
return {
|
|
19
|
+
float: actualFloat,
|
|
20
|
+
size: actualSize === "full" && float ? "medium" : actualSize
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const getSizes = (size, align) => {
|
|
24
|
+
if (align && size === "full") return "(min-width: 1024px) 512px, (min-width: 768px) 350px, 100vw";
|
|
25
|
+
if (align && size === "small") return "(min-width: 1024px) 350px, (min-width: 768px) 180px, 100vw";
|
|
26
|
+
if (align && size === "xsmall") return "(min-width: 1024px) 180px, (min-width: 768px) 180px, 100vw";
|
|
27
|
+
return "(min-width: 1024px) 1024px, 100vw";
|
|
28
|
+
};
|
|
29
|
+
const getFocalPoint = (data) => {
|
|
30
|
+
const focalX = Number.parseFloat(data.focalX ?? "");
|
|
31
|
+
const focalY = Number.parseFloat(data.focalY ?? "");
|
|
32
|
+
if (!Number.isNaN(focalX) && !Number.isNaN(focalY)) return {
|
|
33
|
+
x: focalX,
|
|
34
|
+
y: focalY
|
|
35
|
+
};
|
|
36
|
+
return void 0;
|
|
37
|
+
};
|
|
38
|
+
const getCrop = (data) => {
|
|
39
|
+
const lowerRightX = Number.parseFloat(data.lowerRightX ?? "");
|
|
40
|
+
const lowerRightY = Number.parseFloat(data.lowerRightY ?? "");
|
|
41
|
+
const upperLeftX = Number.parseFloat(data.upperLeftX ?? "");
|
|
42
|
+
const upperLeftY = Number.parseFloat(data.upperLeftY ?? "");
|
|
43
|
+
if (!Number.isNaN(lowerRightX) && !Number.isNaN(lowerRightY) && !Number.isNaN(upperLeftX) && !Number.isNaN(upperLeftY)) return {
|
|
44
|
+
startX: lowerRightX,
|
|
45
|
+
startY: lowerRightY,
|
|
46
|
+
endX: upperLeftX,
|
|
47
|
+
endY: upperLeftY
|
|
48
|
+
};
|
|
49
|
+
return void 0;
|
|
50
|
+
};
|
|
51
|
+
const expandedSizes = "(min-width: 1024px) 1024px, 100vw";
|
|
52
|
+
const ImageWrapper = (0, __ndla_styled_system_jsx.styled)("div", {
|
|
53
|
+
base: {
|
|
54
|
+
overflow: "hidden",
|
|
55
|
+
position: "relative",
|
|
56
|
+
width: "100%",
|
|
57
|
+
"& img": { width: "100%" }
|
|
58
|
+
},
|
|
59
|
+
variants: {
|
|
60
|
+
svg: {
|
|
61
|
+
true: {
|
|
62
|
+
display: "flex",
|
|
63
|
+
justifyContent: "center"
|
|
64
|
+
},
|
|
65
|
+
false: {}
|
|
66
|
+
},
|
|
67
|
+
border: {
|
|
68
|
+
true: {
|
|
69
|
+
border: "1px solid",
|
|
70
|
+
borderColor: "stroke.subtle",
|
|
71
|
+
borderRadius: "xsmall",
|
|
72
|
+
"& img": { borderRadius: "0" }
|
|
73
|
+
},
|
|
74
|
+
false: {}
|
|
75
|
+
},
|
|
76
|
+
expandable: {
|
|
77
|
+
true: { cursor: "pointer" },
|
|
78
|
+
false: {}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const StyledFigure = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figure, { base: {
|
|
83
|
+
zIndex: "docked",
|
|
84
|
+
_hover: {
|
|
85
|
+
"& [data-byline-button]": { background: "background.default" },
|
|
86
|
+
"& button[data-expanded]": { transform: "scale(1.2)" }
|
|
87
|
+
},
|
|
88
|
+
"& button[data-expanded='true']": { "& svg": { transform: "rotate(-45deg)" } }
|
|
89
|
+
} });
|
|
90
|
+
const ExpandButton = (0, __ndla_styled_system_jsx.styled)("button", { base: {
|
|
91
|
+
display: "flex",
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
justifyContent: "center",
|
|
94
|
+
cursor: "pointer",
|
|
95
|
+
position: "absolute",
|
|
96
|
+
padding: "0",
|
|
97
|
+
top: "xsmall",
|
|
98
|
+
right: "xsmall",
|
|
99
|
+
width: "medium",
|
|
100
|
+
height: "medium",
|
|
101
|
+
border: "2px solid",
|
|
102
|
+
borderColor: "background.default",
|
|
103
|
+
transitionProperty: "transform, background-color, color",
|
|
104
|
+
transitionDuration: "normal",
|
|
105
|
+
transitionTimingFunction: "ease-out",
|
|
106
|
+
color: "background.default",
|
|
107
|
+
backgroundColor: "surface.action",
|
|
108
|
+
borderRadius: "large",
|
|
109
|
+
"& svg": {
|
|
110
|
+
transitionProperty: "transform",
|
|
111
|
+
transitionDuration: "normal",
|
|
112
|
+
transitionTimingFunction: "ease-out"
|
|
113
|
+
},
|
|
114
|
+
tabletDown: { display: "none" }
|
|
115
|
+
} }, { defaultProps: { type: "button" } });
|
|
116
|
+
const ImageEmbed = ({ embed, previewAlt, lang, renderContext = "article", children }) => {
|
|
117
|
+
const [imageSizes, setImageSizes] = (0, react.useState)(void 0);
|
|
118
|
+
const figureProps = getFigureProps(embed.embedData.size, embed.embedData.align);
|
|
119
|
+
const { t } = (0, react_i18next.useTranslation)();
|
|
120
|
+
const parsedDescription = (0, react.useMemo)(() => {
|
|
121
|
+
if (embed.embedData.caption || renderContext === "article") return embed.embedData.caption ? (0, html_react_parser.default)(embed.embedData.caption) : void 0;
|
|
122
|
+
if (embed.status === "success" && embed.data.caption.caption) return (0, html_react_parser.default)(embed.data.caption.caption);
|
|
123
|
+
}, [embed, renderContext]);
|
|
124
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, {
|
|
125
|
+
type: "image",
|
|
126
|
+
figureType: figureProps?.size,
|
|
127
|
+
float: figureProps?.float
|
|
128
|
+
});
|
|
129
|
+
const { data, embedData } = embed;
|
|
130
|
+
const altText = embedData.alt || "";
|
|
131
|
+
const sizes = getSizes(embedData.size, embedData.align);
|
|
132
|
+
const focalPoint = getFocalPoint(embedData);
|
|
133
|
+
const crop = getCrop(embedData);
|
|
134
|
+
const toggleImageSize = () => {
|
|
135
|
+
setImageSizes((sizes$1) => !sizes$1 ? expandedSizes : void 0);
|
|
136
|
+
};
|
|
137
|
+
const licenseProps = require_licenseAttributes.licenseAttributes(data.copyright.license.license, lang, embedData.url);
|
|
138
|
+
const figureSize = figureProps?.float ? figureProps?.size ?? "medium" : "full";
|
|
139
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledFigure, {
|
|
140
|
+
float: figureProps?.float,
|
|
141
|
+
size: imageSizes ? "full" : figureSize,
|
|
142
|
+
"data-embed-type": "image",
|
|
143
|
+
...licenseProps,
|
|
144
|
+
children: [
|
|
145
|
+
children,
|
|
146
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ImageWrapper, {
|
|
147
|
+
border: embedData.border === "true",
|
|
148
|
+
expandable: !!figureProps?.float,
|
|
149
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Image, {
|
|
150
|
+
focalPoint,
|
|
151
|
+
contentType: data.image.contentType,
|
|
152
|
+
crop,
|
|
153
|
+
sizes: imageSizes ?? sizes,
|
|
154
|
+
alt: altText,
|
|
155
|
+
src: data.image.imageUrl,
|
|
156
|
+
lang,
|
|
157
|
+
onClick: figureProps?.float ? toggleImageSize : void 0,
|
|
158
|
+
variant: "rounded"
|
|
159
|
+
}), (embedData.align === "right" || embedData.align === "left") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExpandButton, {
|
|
160
|
+
"aria-label": t(`license.images.itemImage.zoom${imageSizes ? "Out" : ""}ImageButtonLabel`),
|
|
161
|
+
onClick: toggleImageSize,
|
|
162
|
+
"data-expanded": !!imageSizes,
|
|
163
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_icons.AddLine, {})
|
|
164
|
+
})]
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_EmbedByline.EmbedByline, {
|
|
167
|
+
type: "image",
|
|
168
|
+
copyright: data.copyright,
|
|
169
|
+
description: parsedDescription,
|
|
170
|
+
hideDescription: embedData.hideCaption === "true",
|
|
171
|
+
hideCopyright: embedData.hideByline === "true",
|
|
172
|
+
visibleAlt: previewAlt ? embed.embedData.alt : ""
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
var ImageEmbed_default = ImageEmbed;
|
|
178
|
+
|
|
179
|
+
//#endregion
|
|
180
|
+
exports.ImageEmbed_default = ImageEmbed_default;
|
|
181
|
+
exports.getCrop = getCrop;
|
|
182
|
+
exports.getFocalPoint = getFocalPoint;
|
|
183
|
+
//# sourceMappingURL=ImageEmbed.js.map
|